UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

56 lines (55 loc) 1.61 kB
"use client"; import React, { useContext } from 'react'; import clsx from 'clsx'; import { applySpacing } from "../space/SpacingUtils.js"; import { validateDOMAttributes, warn } from "../../shared/component-helper.js"; import StatRootContext from "./StatRootContext.js"; import useStatSkeleton from "./useStatSkeleton.js"; import Provider from "../../shared/Provider.js"; import { jsx as _jsx } from "react/jsx-runtime"; function Content(props) { const { inRoot } = useContext(StatRootContext); const { children, className = null, style = null, element: elementProp, direction = 'horizontal', skeleton = null, ...rest } = props; const Element = elementProp !== null && elementProp !== void 0 ? elementProp : inRoot ? 'dd' : 'span'; const { hasSkeleton, skeletonClass, applySkeletonAttributes } = useStatSkeleton(skeleton); if (!inRoot) { warn('Stat.Content should be used inside Stat.Root'); } const attributes = validateDOMAttributes(props, applySpacing(props, { ...rest, style, className: clsx(`dnb-stat dnb-stat__content-item dnb-stat__content-item--${direction}`, skeletonClass, className) })); applySkeletonAttributes(attributes); return _jsx(StatRootContext, { value: { inRoot, skeleton: hasSkeleton }, children: _jsx(Provider, { skeleton: hasSkeleton, children: _jsx(Element, { ...attributes, children: children }) }) }); } Content._supportsSpacingProps = true; Content._statRole = 'content'; export default Content; //# sourceMappingURL=Content.js.map