UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

58 lines (57 loc) 1.65 kB
"use client"; import React from 'react'; import clsx from 'clsx'; import { applySpacing } 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 = { label: null, className: null, children: null, skeleton: false }; const TagGroup = localProps => { const context = React.useContext(Context); const { label, className, children: childrenProp, ...props } = extendPropsWithContext(localProps, defaultProps, context === null || context === void 0 ? void 0 : context.TagGroup, { skeleton: context === null || context === void 0 ? void 0 : context.skeleton }); let children = childrenProp; if (Array.isArray(childrenProp)) { children = [...childrenProp].map(child => { return child; }); } const spacingProps = applySpacing(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