UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

55 lines (54 loc) 1.5 kB
"use client"; import { useContext } from 'react'; import clsx from 'clsx'; import { useSpacing } from "../space/SpacingUtils.js"; import { validateDOMAttributes, extendPropsWithContext } from "../../shared/component-helper.js"; import Context from "../../shared/Context.js"; import { TagGroupContext } from "./TagContext.js"; import withComponentMarkers from "../../shared/helpers/withComponentMarkers.js"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; const defaultProps = { skeleton: false }; const TagGroup = localProps => { const context = useContext(Context); const { label, className, children: childrenProp, ...props } = extendPropsWithContext(localProps, defaultProps, context?.TagGroup, { skeleton: context?.skeleton }); let children = childrenProp; if (Array.isArray(childrenProp)) { children = [...childrenProp].map(child => { return child; }); } const spacingProps = useSpacing(props, { className: clsx('dnb-tag__group', className) }); const { skeleton, ...attributes } = validateDOMAttributes({}, { ...props, ...spacingProps }); return _jsx(TagGroupContext, { value: props, children: _jsxs("span", { ...attributes, children: [_jsx("span", { className: "dnb-sr-only", children: label }), children] }) }); }; withComponentMarkers(TagGroup, { _supportsSpacingProps: true }); export default TagGroup; //# sourceMappingURL=TagGroup.js.map