@dnb/eufemia 10.63.2 → 10.63.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/cjs/components/avatar/Avatar.d.ts +1 -1
- package/cjs/components/avatar/Avatar.js.map +1 -1
- package/cjs/components/avatar/AvatarGroup.d.ts +1 -1
- package/cjs/components/avatar/AvatarGroup.js.map +1 -1
- package/cjs/components/badge/Badge.d.ts +1 -1
- package/cjs/components/badge/Badge.js.map +1 -1
- package/cjs/components/lib.d.ts +2 -2
- package/cjs/components/section/Section.js +1 -1
- package/cjs/components/section/Section.js.map +1 -1
- package/cjs/components/tag/Tag.d.ts +2 -2
- package/cjs/components/tag/Tag.js.map +1 -1
- package/cjs/components/tag/TagGroup.d.ts +1 -1
- package/cjs/components/tag/TagGroup.js.map +1 -1
- package/cjs/extensions/forms/DataContext/Provider/Provider.d.ts +3 -0
- package/cjs/extensions/forms/DataContext/Provider/Provider.js +31 -28
- package/cjs/extensions/forms/DataContext/Provider/Provider.js.map +1 -1
- package/cjs/extensions/forms/Form/Visibility/useVisibility.js +6 -6
- package/cjs/extensions/forms/Form/Visibility/useVisibility.js.map +1 -1
- package/cjs/extensions/forms/Form/data-context/useData.js +14 -10
- package/cjs/extensions/forms/Form/data-context/useData.js.map +1 -1
- package/cjs/shared/Eufemia.d.ts +1 -1
- package/cjs/shared/Eufemia.js +2 -2
- package/cjs/shared/Eufemia.js.map +1 -1
- package/cjs/shared/error-helper.d.ts +0 -6
- package/cjs/shared/error-helper.js +6 -3
- package/cjs/shared/error-helper.js.map +1 -1
- package/cjs/style/core/scopes.scss +1 -1
- package/cjs/style/dnb-ui-basis.css +1 -1
- package/cjs/style/dnb-ui-basis.min.css +1 -1
- package/cjs/style/dnb-ui-body.css +1 -1
- package/cjs/style/dnb-ui-body.min.css +1 -1
- package/cjs/style/dnb-ui-core.css +1 -1
- package/cjs/style/dnb-ui-core.min.css +1 -1
- package/components/avatar/Avatar.d.ts +1 -1
- package/components/avatar/Avatar.js.map +1 -1
- package/components/avatar/AvatarGroup.d.ts +1 -1
- package/components/avatar/AvatarGroup.js.map +1 -1
- package/components/badge/Badge.d.ts +1 -1
- package/components/badge/Badge.js.map +1 -1
- package/components/lib.d.ts +2 -2
- package/components/section/Section.js +1 -1
- package/components/section/Section.js.map +1 -1
- package/components/tag/Tag.d.ts +2 -2
- package/components/tag/Tag.js.map +1 -1
- package/components/tag/TagGroup.d.ts +1 -1
- package/components/tag/TagGroup.js.map +1 -1
- package/es/components/avatar/Avatar.d.ts +1 -1
- package/es/components/avatar/Avatar.js.map +1 -1
- package/es/components/avatar/AvatarGroup.d.ts +1 -1
- package/es/components/avatar/AvatarGroup.js.map +1 -1
- package/es/components/badge/Badge.d.ts +1 -1
- package/es/components/badge/Badge.js.map +1 -1
- package/es/components/lib.d.ts +2 -2
- package/es/components/section/Section.js +1 -1
- package/es/components/section/Section.js.map +1 -1
- package/es/components/tag/Tag.d.ts +2 -2
- package/es/components/tag/Tag.js.map +1 -1
- package/es/components/tag/TagGroup.d.ts +1 -1
- package/es/components/tag/TagGroup.js.map +1 -1
- package/es/extensions/forms/DataContext/Provider/Provider.d.ts +3 -0
- package/es/extensions/forms/DataContext/Provider/Provider.js +31 -28
- package/es/extensions/forms/DataContext/Provider/Provider.js.map +1 -1
- package/es/extensions/forms/Form/Visibility/useVisibility.js +6 -6
- package/es/extensions/forms/Form/Visibility/useVisibility.js.map +1 -1
- package/es/extensions/forms/Form/data-context/useData.js +14 -10
- package/es/extensions/forms/Form/data-context/useData.js.map +1 -1
- package/es/shared/Eufemia.d.ts +1 -1
- package/es/shared/Eufemia.js +2 -2
- package/es/shared/Eufemia.js.map +1 -1
- package/es/shared/error-helper.d.ts +0 -6
- package/es/shared/error-helper.js +6 -3
- package/es/shared/error-helper.js.map +1 -1
- package/es/style/core/scopes.scss +1 -1
- package/es/style/dnb-ui-basis.css +1 -1
- package/es/style/dnb-ui-basis.min.css +1 -1
- package/es/style/dnb-ui-body.css +1 -1
- package/es/style/dnb-ui-body.min.css +1 -1
- package/es/style/dnb-ui-core.css +1 -1
- package/es/style/dnb-ui-core.min.css +1 -1
- package/esm/dnb-ui-basis.min.mjs +1 -1
- package/esm/dnb-ui-components.min.mjs +1 -1
- package/esm/dnb-ui-elements.min.mjs +1 -1
- package/esm/dnb-ui-extensions.min.mjs +2 -2
- package/esm/dnb-ui-lib.min.mjs +1 -1
- package/extensions/forms/DataContext/Provider/Provider.d.ts +3 -0
- package/extensions/forms/DataContext/Provider/Provider.js +31 -28
- package/extensions/forms/DataContext/Provider/Provider.js.map +1 -1
- package/extensions/forms/Form/Visibility/useVisibility.js +6 -6
- package/extensions/forms/Form/Visibility/useVisibility.js.map +1 -1
- package/extensions/forms/Form/data-context/useData.js +14 -10
- package/extensions/forms/Form/data-context/useData.js.map +1 -1
- package/package.json +1 -1
- package/shared/Eufemia.d.ts +1 -1
- package/shared/Eufemia.js +2 -2
- package/shared/Eufemia.js.map +1 -1
- package/shared/error-helper.d.ts +0 -6
- package/shared/error-helper.js +6 -3
- package/shared/error-helper.js.map +1 -1
- package/style/core/scopes.scss +1 -1
- package/style/dnb-ui-basis.css +1 -1
- package/style/dnb-ui-basis.min.css +1 -1
- package/style/dnb-ui-body.css +1 -1
- package/style/dnb-ui-body.min.css +1 -1
- package/style/dnb-ui-core.css +1 -1
- package/style/dnb-ui-core.min.css +1 -1
- package/umd/dnb-ui-basis.min.js +1 -1
- package/umd/dnb-ui-components.min.js +1 -1
- package/umd/dnb-ui-elements.min.js +1 -1
- package/umd/dnb-ui-extensions.min.js +2 -2
- package/umd/dnb-ui-lib.min.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","names":["React","classnames","IconPrimary","Button","Context","warn","extendPropsWithContext","TagGroup","TagGroupContext","createSpacingClasses","defaultProps","skeleton","omitOnKeyUpDeleteEvent","Tag","localProps","_context$translation","context","useContext","tagGroupContext","allProps","translation","_handleDeprecatedBeha","handleDeprecatedBehavior","className","children","text","hasLabel","variant","onClick","removeIconTitle","addIconTitle","props","_objectWithoutProperties","_excluded","content","addIcon","isInteractive","spacingClasses","tagClassNames","buttonAttr","isDeleteKeyboardEvent","keyboardEvent","key","handleDeleteKeyUp","event","element","type","icon","getIcon","createElement","_extends","size","icon_position","on_click","onKeyUp","e","undefined","_ref","onDelete","_excluded2","title","inherit_color","_svg","width","height","fill","xmlns","d","strokeWidth","strokeLinecap","strokeLinejoin","Group","_formElement","_supportsSpacingProps"],"sources":["../../../../src/components/tag/Tag.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport IconPrimary from '../icon-primary/IconPrimary'\nimport type { IconIcon } from '../icon/Icon'\nimport Button, { ButtonProps } from '../button/Button'\n\n// Shared\nimport Context from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\nimport {\n warn,\n extendPropsWithContext,\n} from '../../shared/component-helper'\n\n// Internal\nimport TagGroup from './TagGroup'\nimport { TagGroupContext } from './TagContext'\nimport { createSpacingClasses } from '../space/SpacingHelper'\n\nexport interface TagProps {\n /**\n * The content of the tag element, can be a string or a React Element.\n * Default: null\n */\n text?: string | React.ReactNode\n\n /**\n * Icon displaying on the left side\n * Default: null\n */\n icon?: IconIcon\n\n /**\n * If a label is given, typical inside a table or dl (definition list), then you can disable Tag.Group as a dependent of Tag. Use `true` to omit the `Tag group required:` warning.\n * Default: null\n */\n hasLabel?: boolean\n\n /**\n * Defines the variant\n * Default: 'default'\n */\n variant?: 'default' | 'clickable' | 'addable' | 'removable'\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * Skeleton should be applied when loading content\n * Default: null\n */\n skeleton?: SkeletonShow\n\n /**\n * The content of the tag element, can be a string or a React Element. Will be overwritten by text prop\n * Default: null\n */\n children?: string | React.ReactNode // ReactNode allows multiple elements, strings, numbers, fragments, portals...\n\n /**\n * Handle the click event on 'tag' element\n * Default: null\n */\n onClick?: React.MouseEventHandler<HTMLButtonElement>\n\n /**\n * Handle the delete event on 'tag' element\n * Default: null\n * @deprecated Use `onClick` instead. With `variant='removable'`\n */\n onDelete?: React.MouseEventHandler<HTMLButtonElement>\n\n /**\n * Handle the delete event on 'tag' element\n * Default: null\n */\n omitOnKeyUpDeleteEvent?: boolean\n\n /**\n * Internal property\n * Has translation in context\n */\n removeIconTitle?: string\n\n /**\n * Internal property\n * Has translation in context\n */\n addIconTitle?: string\n}\n\nexport const defaultProps = {\n skeleton: null,\n omitOnKeyUpDeleteEvent: false,\n}\n\nconst Tag = (localProps: TagProps & SpacingProps) => {\n // Every component should have a context\n const context = React.useContext(Context)\n const tagGroupContext = React.useContext(TagGroupContext)\n\n // Extract additional props from global context\n const allProps = extendPropsWithContext(\n localProps,\n defaultProps,\n context?.translation?.Tag,\n context?.Tag,\n tagGroupContext\n )\n\n const {\n className,\n skeleton,\n children,\n text,\n hasLabel,\n variant = 'default',\n onClick,\n omitOnKeyUpDeleteEvent,\n removeIconTitle, // has a translation in context\n addIconTitle, // has a translation in context\n ...props\n } = handleDeprecatedBehavior(allProps)\n\n const content = text || children\n\n const addIcon = variant === 'removable' || variant === 'addable'\n const isInteractive = variant !== 'default'\n const spacingClasses = createSpacingClasses(props)\n const tagClassNames = classnames(\n 'dnb-tag',\n className,\n spacingClasses,\n isInteractive && 'dnb-tag--interactive',\n `dnb-tag--${variant}`\n )\n const buttonAttr: typeof props & Pick<ButtonProps, 'element' | 'type'> =\n props\n\n const isDeleteKeyboardEvent = (keyboardEvent) => {\n return (\n keyboardEvent.key === 'Backspace' || keyboardEvent.key === 'Delete'\n )\n }\n\n const handleDeleteKeyUp = (event) => {\n if (isDeleteKeyboardEvent(event) && onClick) {\n onClick(event)\n }\n }\n\n if (!isInteractive) {\n buttonAttr.element = 'span'\n buttonAttr.type = ''\n }\n\n if (addIcon) {\n buttonAttr.icon = getIcon(\n variant === 'addable' ? addIconTitle : removeIconTitle\n )\n }\n\n if (!tagGroupContext && !hasLabel) {\n warn(\n `Tag group required: A Tag requires a Tag.Group with label description as a parent component. This is to ensure correct semantic and accessibility.`\n )\n }\n\n return (\n <Button\n variant=\"unstyled\"\n size=\"small\"\n icon_position={addIcon ? 'right' : 'left'}\n className={tagClassNames}\n on_click={onClick}\n text={content}\n skeleton={skeleton}\n onKeyUp={\n variant === 'removable' && !omitOnKeyUpDeleteEvent\n ? (e) => handleDeleteKeyUp(e)\n : undefined\n }\n {...buttonAttr}\n />\n )\n}\n\n/**\n * Support deprecated behavior by mutating the props.\n * Deprecated behavior: variant 'clickable' and 'removable' is defined by the 'onClick' and 'onDelete' props\n */\nconst handleDeprecatedBehavior: (allProps: TagProps) => TagProps = ({\n onDelete,\n ...allProps\n}) => {\n if (!allProps.variant) {\n if (allProps.onClick) {\n allProps.variant = 'clickable'\n } else if (onDelete) {\n allProps.onClick = onDelete\n allProps.variant = 'removable'\n }\n }\n return allProps\n}\nconst getIcon = (title: string) => (\n <IconPrimary\n title={title}\n inherit_color={false}\n icon={\n <svg\n width=\"16\"\n height=\"16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M0 8a8 8 0 1 1 16 0A8 8 0 1 1 0 8Z\"\n className=\"dnb-icon-close-circle-path\"\n />\n <path\n d=\"m5.5 10.5 5-5m0 5-5-5\"\n className=\"dnb-icon-close-cross-path\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n }\n />\n)\n\nTag.Group = TagGroup\n\nTag._formElement = true\nTag._supportsSpacingProps = true\n\nexport default Tag\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAGnC,OAAOC,WAAW,MAAM,6BAA6B;AAErD,OAAOC,MAAM,MAAuB,kBAAkB;AAGtD,OAAOC,OAAO,MAAM,sBAAsB;AAG1C,SACEC,IAAI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,wBAAA,CAAAyB,IAAA,EAAAE,UAAA;EAEX,IAAI,CAACxC,QAAQ,CAACQ,OAAO,EAAE;IACrB,IAAIR,QAAQ,CAACS,OAAO,EAAE;MACpBT,QAAQ,CAACQ,OAAO,GAAG,WAAW;IAChC,CAAC,MAAM,IAAI+B,QAAQ,EAAE;MACnBvC,QAAQ,CAACS,OAAO,GAAG8B,QAAQ;MAC3BvC,QAAQ,CAACQ,OAAO,GAAG,WAAW;IAChC;EACF;EACA,OAAOR,QAAQ;AACjB,CAAC;AACD,MAAM6B,OAAO,GAAIY,KAAa,IAC5B5D,KAAA,CAAAiD,aAAA,CAAC/C,WAAW;EACV0D,KAAK,EAAEA,KAAM;EACbC,aAAa,EAAE,KAAM;EACrBd,IAAI,EAAAe,IAAA,KAAAA,IAAA,GACF9D,KAAA,CAAAiD,aAAA;IACEc,KAAK,EAAC,IAAI;IACVC,MAAM,EAAC,IAAI;IACXC,IAAI,EAAC,MAAM;IACXC,KAAK,EAAC;EAA4B,GAElClE,KAAA,CAAAiD,aAAA;IACEkB,CAAC,EAAC,oCAAoC;IACtC5C,SAAS,EAAC;EAA4B,CACvC,CAAC,EACFvB,KAAA,CAAAiD,aAAA;IACEkB,CAAC,EAAC,uBAAuB;IACzB5C,SAAS,EAAC,2BAA2B;IACrC6C,WAAW,EAAC,KAAK;IACjBC,aAAa,EAAC,OAAO;IACrBC,cAAc,EAAC;EAAO,CACvB,CACE,CAAC;AACP,CACF,CACF;AAEDzD,GAAG,CAAC0D,KAAK,GAAGhE,QAAQ;AAEpBM,GAAG,CAAC2D,YAAY,GAAG,IAAI;AACvB3D,GAAG,CAAC4D,qBAAqB,GAAG,IAAI;AAEhC,eAAe5D,GAAG"}
|
|
1
|
+
{"version":3,"file":"Tag.js","names":["React","classnames","IconPrimary","Button","Context","warn","extendPropsWithContext","TagGroup","TagGroupContext","createSpacingClasses","defaultProps","skeleton","omitOnKeyUpDeleteEvent","Tag","localProps","_context$translation","context","useContext","tagGroupContext","allProps","translation","_handleDeprecatedBeha","handleDeprecatedBehavior","className","children","text","hasLabel","variant","onClick","removeIconTitle","addIconTitle","props","_objectWithoutProperties","_excluded","content","addIcon","isInteractive","spacingClasses","tagClassNames","buttonAttr","isDeleteKeyboardEvent","keyboardEvent","key","handleDeleteKeyUp","event","element","type","icon","getIcon","createElement","_extends","size","icon_position","on_click","onKeyUp","e","undefined","_ref","onDelete","_excluded2","title","inherit_color","_svg","width","height","fill","xmlns","d","strokeWidth","strokeLinecap","strokeLinejoin","Group","_formElement","_supportsSpacingProps"],"sources":["../../../../src/components/tag/Tag.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport IconPrimary from '../icon-primary/IconPrimary'\nimport type { IconIcon } from '../icon/Icon'\nimport Button, { ButtonProps } from '../button/Button'\n\n// Shared\nimport Context from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\nimport {\n warn,\n extendPropsWithContext,\n} from '../../shared/component-helper'\n\n// Internal\nimport TagGroup from './TagGroup'\nimport { TagGroupContext } from './TagContext'\nimport { createSpacingClasses } from '../space/SpacingHelper'\n\nexport interface TagProps {\n /**\n * The content of the tag element, can be a string or a React Element.\n * Default: null\n */\n text?: string | React.ReactNode\n\n /**\n * Icon displaying on the left side\n * Default: null\n */\n icon?: IconIcon\n\n /**\n * If a label is given, typical inside a table or dl (definition list), then you can disable Tag.Group as a dependent of Tag. Use `true` to omit the `Tag group required:` warning.\n * Default: null\n */\n hasLabel?: boolean\n\n /**\n * Defines the variant\n * Default: 'default'\n */\n variant?: 'default' | 'clickable' | 'addable' | 'removable'\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * Skeleton should be applied when loading content\n * Default: null\n */\n skeleton?: SkeletonShow\n\n /**\n * The content of the tag element, can be a string or a React Element. Will be overwritten by text prop\n * Default: null\n */\n children?: string | React.ReactNode // ReactNode allows multiple elements, strings, numbers, fragments, portals...\n\n /**\n * Handle the click event on 'tag' element\n * Default: null\n */\n onClick?: React.MouseEventHandler<HTMLButtonElement>\n\n /**\n * Handle the delete event on 'tag' element\n * Default: null\n * @deprecated Use `onClick` instead. With `variant='removable'`\n */\n onDelete?: React.MouseEventHandler<HTMLButtonElement>\n\n /**\n * Handle the delete event on 'tag' element\n * Default: null\n */\n omitOnKeyUpDeleteEvent?: boolean\n\n /**\n * Internal property\n * Has translation in context\n */\n removeIconTitle?: string\n\n /**\n * Internal property\n * Has translation in context\n */\n addIconTitle?: string\n}\n\nexport const defaultProps = {\n skeleton: null,\n omitOnKeyUpDeleteEvent: false,\n}\n\nconst Tag = (\n localProps: TagProps & SpacingProps & React.HTMLProps<HTMLElement>\n) => {\n // Every component should have a context\n const context = React.useContext(Context)\n const tagGroupContext = React.useContext(TagGroupContext)\n\n // Extract additional props from global context\n const allProps = extendPropsWithContext(\n localProps,\n defaultProps,\n context?.translation?.Tag,\n context?.Tag,\n tagGroupContext\n )\n\n const {\n className,\n skeleton,\n children,\n text,\n hasLabel,\n variant = 'default',\n onClick,\n omitOnKeyUpDeleteEvent,\n removeIconTitle, // has a translation in context\n addIconTitle, // has a translation in context\n ...props\n } = handleDeprecatedBehavior(allProps)\n\n const content = text || children\n\n const addIcon = variant === 'removable' || variant === 'addable'\n const isInteractive = variant !== 'default'\n const spacingClasses = createSpacingClasses(props)\n const tagClassNames = classnames(\n 'dnb-tag',\n className,\n spacingClasses,\n isInteractive && 'dnb-tag--interactive',\n `dnb-tag--${variant}`\n )\n const buttonAttr: typeof props & Pick<ButtonProps, 'element' | 'type'> =\n props\n\n const isDeleteKeyboardEvent = (keyboardEvent) => {\n return (\n keyboardEvent.key === 'Backspace' || keyboardEvent.key === 'Delete'\n )\n }\n\n const handleDeleteKeyUp = (event) => {\n if (isDeleteKeyboardEvent(event) && onClick) {\n onClick(event)\n }\n }\n\n if (!isInteractive) {\n buttonAttr.element = 'span'\n buttonAttr.type = ''\n }\n\n if (addIcon) {\n buttonAttr.icon = getIcon(\n variant === 'addable' ? addIconTitle : removeIconTitle\n )\n }\n\n if (!tagGroupContext && !hasLabel) {\n warn(\n `Tag group required: A Tag requires a Tag.Group with label description as a parent component. This is to ensure correct semantic and accessibility.`\n )\n }\n\n return (\n <Button\n variant=\"unstyled\"\n size=\"small\"\n icon_position={addIcon ? 'right' : 'left'}\n className={tagClassNames}\n on_click={onClick}\n text={content}\n skeleton={skeleton}\n onKeyUp={\n variant === 'removable' && !omitOnKeyUpDeleteEvent\n ? (e) => handleDeleteKeyUp(e)\n : undefined\n }\n {...buttonAttr}\n />\n )\n}\n\n/**\n * Support deprecated behavior by mutating the props.\n * Deprecated behavior: variant 'clickable' and 'removable' is defined by the 'onClick' and 'onDelete' props\n */\nconst handleDeprecatedBehavior: (allProps: TagProps) => TagProps = ({\n onDelete,\n ...allProps\n}) => {\n if (!allProps.variant) {\n if (allProps.onClick) {\n allProps.variant = 'clickable'\n } else if (onDelete) {\n allProps.onClick = onDelete\n allProps.variant = 'removable'\n }\n }\n return allProps\n}\nconst getIcon = (title: string) => (\n <IconPrimary\n title={title}\n inherit_color={false}\n icon={\n <svg\n width=\"16\"\n height=\"16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M0 8a8 8 0 1 1 16 0A8 8 0 1 1 0 8Z\"\n className=\"dnb-icon-close-circle-path\"\n />\n <path\n d=\"m5.5 10.5 5-5m0 5-5-5\"\n className=\"dnb-icon-close-cross-path\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n }\n />\n)\n\nTag.Group = TagGroup\n\nTag._formElement = true\nTag._supportsSpacingProps = true\n\nexport default Tag\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAGnC,OAAOC,WAAW,MAAM,6BAA6B;AAErD,OAAOC,MAAM,MAAuB,kBAAkB;AAGtD,OAAOC,OAAO,MA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AD,IAAA;IADItC,QAAQ,GAAAa,wBAAA,CAAAyB,IAAA,EAAAE,UAAA;EAEX,IAAI,CAACxC,QAAQ,CAACQ,OAAO,EAAE;IACrB,IAAIR,QAAQ,CAACS,OAAO,EAAE;MACpBT,QAAQ,CAACQ,OAAO,GAAG,WAAW;IAChC,CAAC,MAAM,IAAI+B,QAAQ,EAAE;MACnBvC,QAAQ,CAACS,OAAO,GAAG8B,QAAQ;MAC3BvC,QAAQ,CAACQ,OAAO,GAAG,WAAW;IAChC;EACF;EACA,OAAOR,QAAQ;AACjB,CAAC;AACD,MAAM6B,OAAO,GAAIY,KAAa,IAC5B5D,KAAA,CAAAiD,aAAA,CAAC/C,WAAW;EACV0D,KAAK,EAAEA,KAAM;EACbC,aAAa,EAAE,KAAM;EACrBd,IAAI,EAAAe,IAAA,KAAAA,IAAA,GACF9D,KAAA,CAAAiD,aAAA;IACEc,KAAK,EAAC,IAAI;IACVC,MAAM,EAAC,IAAI;IACXC,IAAI,EAAC,MAAM;IACXC,KAAK,EAAC;EAA4B,GAElClE,KAAA,CAAAiD,aAAA;IACEkB,CAAC,EAAC,oCAAoC;IACtC5C,SAAS,EAAC;EAA4B,CACvC,CAAC,EACFvB,KAAA,CAAAiD,aAAA;IACEkB,CAAC,EAAC,uBAAuB;IACzB5C,SAAS,EAAC,2BAA2B;IACrC6C,WAAW,EAAC,KAAK;IACjBC,aAAa,EAAC,OAAO;IACrBC,cAAc,EAAC;EAAO,CACvB,CACE,CAAC;AACP,CACF,CACF;AAEDzD,GAAG,CAAC0D,KAAK,GAAGhE,QAAQ;AAEpBM,GAAG,CAAC2D,YAAY,GAAG,IAAI;AACvB3D,GAAG,CAAC4D,qBAAqB,GAAG,IAAI;AAEhC,eAAe5D,GAAG"}
|
|
@@ -30,7 +30,7 @@ export declare const defaultProps: {
|
|
|
30
30
|
skeleton: boolean;
|
|
31
31
|
};
|
|
32
32
|
declare const TagGroup: {
|
|
33
|
-
(localProps: TagGroupProps & SpacingProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
(localProps: TagGroupProps & SpacingProps & Omit<React.HTMLProps<HTMLElement>, 'label'>): import("react/jsx-runtime").JSX.Element;
|
|
34
34
|
_supportsSpacingProps: boolean;
|
|
35
35
|
};
|
|
36
36
|
export default TagGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagGroup.js","names":["React","classnames","createSpacingClasses","validateDOMAttributes","extendPropsWithContext","Context","TagGroupContext","defaultProps","label","className","children","skeleton","TagGroup","localProps","context","useContext","_extendPropsWithConte","childrenProp","props","_objectWithoutProperties","_excluded","Array","isArray","map","child","spacingClasses","_validateDOMAttribute","attributes","_excluded2","createElement","Provider","value","_extends","_supportsSpacingProps"],"sources":["../../../../src/components/tag/TagGroup.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport { createSpacingClasses } from '../space/SpacingHelper'\n\n// Shared\nimport {\n validateDOMAttributes,\n extendPropsWithContext,\n} from '../../shared/component-helper'\nimport Context from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport { TagGroupContext } from './TagContext'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\n\nexport interface TagGroupProps {\n /**\n * Aria label to describe the tag group\n * Default: null\n */\n label: React.ReactNode\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * The tags to group.\n * Default: null\n */\n children?: React.ReactNode\n\n /**\n * Skeleton should be applied when loading content\n * Default: false\n */\n skeleton?: SkeletonShow\n}\n\nexport const defaultProps = {\n label: null,\n className: null,\n children: null,\n skeleton: false,\n}\n\nconst TagGroup = (localProps: TagGroupProps
|
|
1
|
+
{"version":3,"file":"TagGroup.js","names":["React","classnames","createSpacingClasses","validateDOMAttributes","extendPropsWithContext","Context","TagGroupContext","defaultProps","label","className","children","skeleton","TagGroup","localProps","context","useContext","_extendPropsWithConte","childrenProp","props","_objectWithoutProperties","_excluded","Array","isArray","map","child","spacingClasses","_validateDOMAttribute","attributes","_excluded2","createElement","Provider","value","_extends","_supportsSpacingProps"],"sources":["../../../../src/components/tag/TagGroup.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport { createSpacingClasses } from '../space/SpacingHelper'\n\n// Shared\nimport {\n validateDOMAttributes,\n extendPropsWithContext,\n} from '../../shared/component-helper'\nimport Context from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport { TagGroupContext } from './TagContext'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\n\nexport interface TagGroupProps {\n /**\n * Aria label to describe the tag group\n * Default: null\n */\n label: React.ReactNode\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * The tags to group.\n * Default: null\n */\n children?: React.ReactNode\n\n /**\n * Skeleton should be applied when loading content\n * Default: false\n */\n skeleton?: SkeletonShow\n}\n\nexport const defaultProps = {\n label: null,\n className: null,\n children: null,\n skeleton: false,\n}\n\nconst TagGroup = (\n localProps: TagGroupProps &\n SpacingProps &\n Omit<React.HTMLProps<HTMLElement>, 'label'>\n) => {\n // Every component should have a context\n const context = React.useContext(Context)\n // Extract additional props from global context\n const {\n label,\n className,\n children: childrenProp,\n ...props\n } = extendPropsWithContext(localProps, defaultProps, context?.TagGroup, {\n skeleton: context?.skeleton,\n })\n\n let children = childrenProp\n\n if (Array.isArray(childrenProp)) {\n children = [...childrenProp].map((child) => {\n return child\n })\n }\n\n const spacingClasses = createSpacingClasses(props)\n const {\n skeleton, // eslint-disable-line\n ...attributes\n } = validateDOMAttributes({}, props)\n\n return (\n <TagGroupContext.Provider value={props}>\n <span\n className={classnames('dnb-tag__group', spacingClasses, className)}\n {...attributes}\n >\n <span className=\"dnb-sr-only\">{label}</span>\n {children}\n </span>\n </TagGroupContext.Provider>\n )\n}\n\nTagGroup._supportsSpacingProps = true\n\nexport default TagGroup\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AA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ACC,KAAK,EAAEb;EAAM,GACrClB,KAAA,CAAA6B,aAAA,SAAAG,QAAA;IACEvB,SAAS,EAAER,UAAU,CAAC,gBAAgB,EAAEwB,cAAc,EAAEhB,SAAS;EAAE,GAC/DkB,UAAU,GAEd3B,KAAA,CAAA6B,aAAA;IAAMpB,SAAS,EAAC;EAAa,GAAED,KAAY,CAAC,EAC3CE,QACG,CACkB,CAAC;AAE/B,CAAC;AAEDE,QAAQ,CAACqB,qBAAqB,GAAG,IAAI;AAErC,eAAerB,QAAQ"}
|
|
@@ -6,7 +6,7 @@ import AvatarGroup from './AvatarGroup';
|
|
|
6
6
|
export type AvatarSizes = 'small' | 'medium' | 'large' | 'x-large';
|
|
7
7
|
export type AvatarVariants = 'primary' | 'secondary' | 'tertiary';
|
|
8
8
|
export type AvatarImgProps = ImgProps;
|
|
9
|
-
export interface AvatarProps {
|
|
9
|
+
export interface AvatarProps extends Omit<React.HTMLProps<HTMLElement>, 'size'> {
|
|
10
10
|
/**
|
|
11
11
|
* Used in combination with `src` to provide an alt attribute for the `img` element.
|
|
12
12
|
* Default: null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","names":["React","classnames","createSpacingClasses","createSkeletonClass","Img","Context","validateDOMAttributes","extendPropsWithContext","warn","AvatarGroup","AvatarGroupContext","defaultProps","size","variant","skeleton","Avatar","localProps","context","useContext","avatarGroupContext","allProps","alt","className","children","childrenProp","src","imgProps","hasLabel","props","_objectWithoutProperties","_excluded","skeletonClasses","spacingClasses","childrenIsString","imageProps","_objectSpread","createElement","firstLetterUpperCase","charAt","toUpperCase","_extends","Group","_supportsSpacingProps"],"sources":["../../../../src/components/avatar/Avatar.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport { createSpacingClasses } from '../space/SpacingHelper'\nimport { createSkeletonClass } from '../skeleton/SkeletonHelper'\n\n// Elements\nimport Img, { ImgProps } from '../../elements/img/Img'\n\n// Shared\nimport Context from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\nimport {\n validateDOMAttributes,\n extendPropsWithContext,\n warn,\n} from '../../shared/component-helper'\n\n// Internal\nimport AvatarGroup, { AvatarGroupContext } from './AvatarGroup'\n\nexport type AvatarSizes = 'small' | 'medium' | 'large' | 'x-large'\nexport type AvatarVariants = 'primary' | 'secondary' | 'tertiary'\n\nexport type AvatarImgProps = ImgProps\n\nexport interface AvatarProps {\n /**\n * Used in combination with `src` to provide an alt attribute for the `img` element.\n * Default: null\n */\n alt?: string\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * Skeleton should be applied when loading content\n * Default: null\n */\n skeleton?: SkeletonShow\n\n /**\n * The content of the component. Can be used instead of prop \"data\".\n * Default: null\n */\n children?: React.ReactNode\n\n /**\n * The size of the component.\n * Default: medium.\n */\n size?: AvatarSizes\n\n /**\n * Specifies the path to the image\n * Default: null\n */\n src?: string\n\n /**\n * Props applied to the `img` element if the component is used to display an image.\n * Default: null\n */\n imgProps?: ImgProps\n\n /**\n * The variant of the component.\n * Default: primary.\n */\n variant?: AvatarVariants\n\n /**\n * If an avatar is hidden from the screen reader (by setting aria-hidden={true}) or if label is given, typical inside a table or dl (definition list), then you can disable Avatar.Group as a dependent of Avatar.\n * Use `true` to omit the `Avatar group required:` warning.\n * Default: null\n */\n hasLabel?: boolean\n}\n\nexport const defaultProps = {\n size: 'medium',\n variant: 'primary',\n skeleton: false,\n}\n\nconst Avatar = (localProps: AvatarProps & SpacingProps) => {\n // Every component should have a context\n const context = React.useContext(Context)\n const avatarGroupContext = React.useContext(AvatarGroupContext)\n\n // Extract additional props from global context\n const allProps = extendPropsWithContext(\n localProps,\n defaultProps,\n context?.Avatar,\n { skeleton: context?.skeleton },\n avatarGroupContext\n )\n\n const {\n alt,\n className,\n children: childrenProp,\n size,\n skeleton,\n variant,\n src,\n imgProps,\n hasLabel,\n ...props\n } = allProps\n\n let children = null\n\n const skeletonClasses = createSkeletonClass('shape', skeleton, context)\n const spacingClasses = createSpacingClasses(props)\n\n const childrenIsString = typeof childrenProp === 'string'\n\n if (src || imgProps) {\n const imageProps = { src, alt, ...imgProps }\n children = <Img {...imageProps} />\n } else if (childrenIsString) {\n const firstLetterUpperCase = childrenProp.charAt(0).toUpperCase()\n children = <span aria-hidden>{firstLetterUpperCase}</span>\n } else {\n children = childrenProp\n }\n\n if (!avatarGroupContext && !hasLabel) {\n warn(\n `Avatar group required: An Avatar requires an Avatar.Group with label description as a parent component. This is to ensure correct semantic and accessibility.`\n )\n }\n\n validateDOMAttributes(allProps, props)\n\n return (\n <span\n className={classnames(\n 'dnb-avatar',\n `dnb-avatar--${variant || 'primary'}`,\n `dnb-avatar--size-${size || 'medium'}`,\n skeletonClasses,\n spacingClasses,\n className\n )}\n {...props}\n >\n {childrenIsString && (\n <span className=\"dnb-sr-only\">{childrenProp}</span>\n )}\n {children}\n </span>\n )\n}\n\nAvatar.Group = AvatarGroup\n\nexport { AvatarGroup }\n\nAvatar._supportsSpacingProps = true\n\nexport default Avatar\n"],"mappings":";;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAGnC,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,mBAAmB,QAAQ,4BAA4B;AAGhE,OAAOC,GAAG,MAAoB,wBAAwB;AAGtD,OAAOC,OAAO,MAAM,sBAAsB;AAG1C,SACEC,qBAAqB,EACrBC,sBAAsB,EACtBC,IAAI,QACC,+BAA+B;AAGtC,OAAOC,WAAW,IAAIC,kBAAkB,QAAQ,eAAe;
|
|
1
|
+
{"version":3,"file":"Avatar.js","names":["React","classnames","createSpacingClasses","createSkeletonClass","Img","Context","validateDOMAttributes","extendPropsWithContext","warn","AvatarGroup","AvatarGroupContext","defaultProps","size","variant","skeleton","Avatar","localProps","context","useContext","avatarGroupContext","allProps","alt","className","children","childrenProp","src","imgProps","hasLabel","props","_objectWithoutProperties","_excluded","skeletonClasses","spacingClasses","childrenIsString","imageProps","_objectSpread","createElement","firstLetterUpperCase","charAt","toUpperCase","_extends","Group","_supportsSpacingProps"],"sources":["../../../../src/components/avatar/Avatar.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport { createSpacingClasses } from '../space/SpacingHelper'\nimport { createSkeletonClass } from '../skeleton/SkeletonHelper'\n\n// Elements\nimport Img, { ImgProps } from '../../elements/img/Img'\n\n// Shared\nimport Context from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\nimport {\n validateDOMAttributes,\n extendPropsWithContext,\n warn,\n} from '../../shared/component-helper'\n\n// Internal\nimport AvatarGroup, { AvatarGroupContext } from './AvatarGroup'\n\nexport type AvatarSizes = 'small' | 'medium' | 'large' | 'x-large'\nexport type AvatarVariants = 'primary' | 'secondary' | 'tertiary'\n\nexport type AvatarImgProps = ImgProps\n\nexport interface AvatarProps\n extends Omit<React.HTMLProps<HTMLElement>, 'size'> {\n /**\n * Used in combination with `src` to provide an alt attribute for the `img` element.\n * Default: null\n */\n alt?: string\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * Skeleton should be applied when loading content\n * Default: null\n */\n skeleton?: SkeletonShow\n\n /**\n * The content of the component. Can be used instead of prop \"data\".\n * Default: null\n */\n children?: React.ReactNode\n\n /**\n * The size of the component.\n * Default: medium.\n */\n size?: AvatarSizes\n\n /**\n * Specifies the path to the image\n * Default: null\n */\n src?: string\n\n /**\n * Props applied to the `img` element if the component is used to display an image.\n * Default: null\n */\n imgProps?: ImgProps\n\n /**\n * The variant of the component.\n * Default: primary.\n */\n variant?: AvatarVariants\n\n /**\n * If an avatar is hidden from the screen reader (by setting aria-hidden={true}) or if label is given, typical inside a table or dl (definition list), then you can disable Avatar.Group as a dependent of Avatar.\n * Use `true` to omit the `Avatar group required:` warning.\n * Default: null\n */\n hasLabel?: boolean\n}\n\nexport const defaultProps = {\n size: 'medium',\n variant: 'primary',\n skeleton: false,\n}\n\nconst Avatar = (localProps: AvatarProps & SpacingProps) => {\n // Every component should have a context\n const context = React.useContext(Context)\n const avatarGroupContext = React.useContext(AvatarGroupContext)\n\n // Extract additional props from global context\n const allProps = extendPropsWithContext(\n localProps,\n defaultProps,\n context?.Avatar,\n { skeleton: context?.skeleton },\n avatarGroupContext\n )\n\n const {\n alt,\n className,\n children: childrenProp,\n size,\n skeleton,\n variant,\n src,\n imgProps,\n hasLabel,\n ...props\n } = allProps\n\n let children = null\n\n const skeletonClasses = createSkeletonClass('shape', skeleton, context)\n const spacingClasses = createSpacingClasses(props)\n\n const childrenIsString = typeof childrenProp === 'string'\n\n if (src || imgProps) {\n const imageProps = { src, alt, ...imgProps }\n children = <Img {...imageProps} />\n } else if (childrenIsString) {\n const firstLetterUpperCase = childrenProp.charAt(0).toUpperCase()\n children = <span aria-hidden>{firstLetterUpperCase}</span>\n } else {\n children = childrenProp\n }\n\n if (!avatarGroupContext && !hasLabel) {\n warn(\n `Avatar group required: An Avatar requires an Avatar.Group with label description as a parent component. This is to ensure correct semantic and accessibility.`\n )\n }\n\n validateDOMAttributes(allProps, props)\n\n return (\n <span\n className={classnames(\n 'dnb-avatar',\n `dnb-avatar--${variant || 'primary'}`,\n `dnb-avatar--size-${size || 'medium'}`,\n skeletonClasses,\n spacingClasses,\n className\n )}\n {...props}\n >\n {childrenIsString && (\n <span className=\"dnb-sr-only\">{childrenProp}</span>\n )}\n {children}\n </span>\n )\n}\n\nAvatar.Group = AvatarGroup\n\nexport { AvatarGroup }\n\nAvatar._supportsSpacingProps = true\n\nexport default Avatar\n"],"mappings":";;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAGnC,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,mBAAmB,QAAQ,4BAA4B;AAGhE,OAAOC,GAAG,MAAoB,wBAAwB;AAGtD,OAAO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AAA,CAAAoC,aAAA,CAAChC,GAAG,EAAK8B,UAAa,CAAC;EACpC,CAAC,MAAM,IAAID,gBAAgB,EAAE;IAC3B,MAAMI,oBAAoB,GAAGb,YAAY,CAACc,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;IACjEhB,QAAQ,GAAGvB,KAAA,CAAAoC,aAAA;MAAM;IAAW,GAAEC,oBAA2B,CAAC;EAC5D,CAAC,MAAM;IACLd,QAAQ,GAAGC,YAAY;EACzB;EAEA,IAAI,CAACL,kBAAkB,IAAI,CAACQ,QAAQ,EAAE;IACpCnB,IAAI,CACD,+JACH,CAAC;EACH;EAEAF,qBAAqB,CAACc,QAAQ,EAAEQ,KAAK,CAAC;EAEtC,OACE5B,KAAA,CAAAoC,aAAA,SAAAI,QAAA;IACElB,SAAS,EAAErB,UAAU,2BAEJY,OAAO,IAAI,SAAS,qBACfD,IAAI,IAAI,QAAS,IACrCmB,eAAe,EACfC,cAAc,EACdV,SACF;EAAE,GACEM,KAAK,GAERK,gBAAgB,IACfjC,KAAA,CAAAoC,aAAA;IAAMd,SAAS,EAAC;EAAa,GAAEE,YAAmB,CACnD,EACAD,QACG,CAAC;AAEX,CAAC;AAEDR,MAAM,CAAC0B,KAAK,GAAGhC,WAAW;AAE1B,SAASA,WAAW;AAEpBM,MAAM,CAAC2B,qBAAqB,GAAG,IAAI;AAEnC,eAAe3B,MAAM"}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { AvatarSizes, AvatarVariants } from './Avatar';
|
|
3
3
|
import type { SpacingProps } from '../../shared/types';
|
|
4
4
|
import type { SkeletonShow } from '../skeleton/Skeleton';
|
|
5
|
-
export interface AvatarGroupProps {
|
|
5
|
+
export interface AvatarGroupProps extends Omit<React.HTMLProps<HTMLElement>, 'size' | 'label'> {
|
|
6
6
|
/**
|
|
7
7
|
* Label to describe the avatar group
|
|
8
8
|
* Default: null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarGroup.js","names":["React","classnames","createSpacingClasses","validateDOMAttributes","extendPropsWithContext","Context","defaultProps","label","className","maxElements","size","children","variant","skeleton","AvatarGroupContext","createContext","AvatarGroup","localProps","context","useContext","_extendPropsWithConte","childrenProp","maxElementsProp","props","_objectWithoutProperties","_excluded","numOfHiddenAvatars","Array","isArray","total","length","slice","map","child","i","appliedSize","appliedVariant","cloneElement","style","_objectSpread","zIndex","key","spacingClasses","_validateDOMAttribute","attributes","_excluded2","createElement","Provider","value","_extends","ElementsHidden","_supportsSpacingProps"],"sources":["../../../../src/components/avatar/AvatarGroup.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport { createSpacingClasses } from '../space/SpacingHelper'\nimport { AvatarSizes, AvatarVariants } from './Avatar'\n\n// Shared\nimport {\n validateDOMAttributes,\n extendPropsWithContext,\n} from '../../shared/component-helper'\nimport Context from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\n\nexport interface AvatarGroupProps {\n /**\n * Label to describe the avatar group\n * Default: null\n */\n label: React.ReactNode\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * Number of max displayed elements, including the \"elements hidden text (+x)\".\n * Default: 4\n */\n maxElements?: number\n\n /**\n * The avatars to group.\n * Default: null\n */\n children?: React.ReactNode\n\n /**\n * The size of the Avatars, and \"elements hidden text (+x)\".\n * Default: medium.\n */\n size?: AvatarSizes\n\n /**\n * The variant of the Avatars.\n * Default: primary.\n */\n variant?: AvatarVariants\n\n /**\n * Skeleton should be applied when loading content\n * Default: false\n */\n skeleton?: SkeletonShow\n}\n\nexport const defaultProps = {\n label: null,\n className: null,\n maxElements: 4,\n size: 'medium',\n children: null,\n variant: 'primary',\n skeleton: false,\n}\n\nexport const AvatarGroupContext = React.createContext(null)\n\nconst AvatarGroup = (localProps: AvatarGroupProps & SpacingProps) => {\n // Every component should have a context\n const context = React.useContext(Context)\n // Extract additional props from global context\n const {\n label,\n className,\n children: childrenProp,\n size,\n maxElements: maxElementsProp,\n variant,\n ...props\n } = extendPropsWithContext(\n localProps,\n defaultProps,\n context?.AvatarGroup,\n {\n skeleton: context?.skeleton,\n }\n )\n\n const maxElements =\n maxElementsProp && maxElementsProp > 0 ? maxElementsProp : 4\n\n let children = childrenProp\n let numOfHiddenAvatars = 0\n\n if (Array.isArray(childrenProp)) {\n const total = childrenProp.length\n\n if (total > maxElements) {\n numOfHiddenAvatars = total - maxElements + 1\n }\n\n children = childrenProp\n .slice(0, total - numOfHiddenAvatars)\n .map((child, i) => {\n const appliedSize = child.props.size ? child.props.size : size\n const appliedVariant = child.props.variant\n ? child.props.variant\n : variant\n return React.cloneElement(child, {\n size: appliedSize,\n variant: appliedVariant,\n style: { ...child.props.style, zIndex: total - i },\n key: i,\n })\n })\n }\n\n const spacingClasses = createSpacingClasses(props)\n const {\n skeleton, // eslint-disable-line\n ...attributes\n } = validateDOMAttributes({}, props)\n\n return (\n <AvatarGroupContext.Provider value={props}>\n <span\n className={classnames(\n 'dnb-avatar__group',\n spacingClasses,\n className\n )}\n {...attributes}\n >\n <span className=\"dnb-sr-only\">{label}</span>\n\n {children}\n\n {numOfHiddenAvatars ? (\n <ElementsHidden size={size}>\n +{numOfHiddenAvatars}\n </ElementsHidden>\n ) : null}\n </span>\n </AvatarGroupContext.Provider>\n )\n}\n\nexport interface ElementsHiddenProps {\n /**\n * The avatars to group.\n * Default: null\n */\n children?: React.ReactNode\n\n /**\n * The size of the \"elements hidden text (+x)\".\n * Default: medium.\n */\n size?: AvatarSizes\n}\n\nfunction ElementsHidden(props: ElementsHiddenProps) {\n const { size, children } = props\n return (\n <span\n className={classnames(\n 'dnb-avatar__group--elements-left',\n `dnb-avatar__group--elements-left--size-${size || 'medium'}`\n )}\n >\n {children}\n </span>\n )\n}\n\nAvatarGroup._supportsSpacingProps = true\n\nexport default AvatarGroup\n"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAGnC,SAASC,oBAAoB,QAAQ,wBAAwB;AAI7D,SACEC,qBAAqB,EACrBC,sBAAsB,QACjB,+BAA+B;AACtC,OAAOC,OAAO,MAAM,sBAAsB;
|
|
1
|
+
{"version":3,"file":"AvatarGroup.js","names":["React","classnames","createSpacingClasses","validateDOMAttributes","extendPropsWithContext","Context","defaultProps","label","className","maxElements","size","children","variant","skeleton","AvatarGroupContext","createContext","AvatarGroup","localProps","context","useContext","_extendPropsWithConte","childrenProp","maxElementsProp","props","_objectWithoutProperties","_excluded","numOfHiddenAvatars","Array","isArray","total","length","slice","map","child","i","appliedSize","appliedVariant","cloneElement","style","_objectSpread","zIndex","key","spacingClasses","_validateDOMAttribute","attributes","_excluded2","createElement","Provider","value","_extends","ElementsHidden","_supportsSpacingProps"],"sources":["../../../../src/components/avatar/AvatarGroup.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport { createSpacingClasses } from '../space/SpacingHelper'\nimport { AvatarSizes, AvatarVariants } from './Avatar'\n\n// Shared\nimport {\n validateDOMAttributes,\n extendPropsWithContext,\n} from '../../shared/component-helper'\nimport Context from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\n\nexport interface AvatarGroupProps\n extends Omit<React.HTMLProps<HTMLElement>, 'size' | 'label'> {\n /**\n * Label to describe the avatar group\n * Default: null\n */\n label: React.ReactNode\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * Number of max displayed elements, including the \"elements hidden text (+x)\".\n * Default: 4\n */\n maxElements?: number\n\n /**\n * The avatars to group.\n * Default: null\n */\n children?: React.ReactNode\n\n /**\n * The size of the Avatars, and \"elements hidden text (+x)\".\n * Default: medium.\n */\n size?: AvatarSizes\n\n /**\n * The variant of the Avatars.\n * Default: primary.\n */\n variant?: AvatarVariants\n\n /**\n * Skeleton should be applied when loading content\n * Default: false\n */\n skeleton?: SkeletonShow\n}\n\nexport const defaultProps = {\n label: null,\n className: null,\n maxElements: 4,\n size: 'medium',\n children: null,\n variant: 'primary',\n skeleton: false,\n}\n\nexport const AvatarGroupContext = React.createContext(null)\n\nconst AvatarGroup = (localProps: AvatarGroupProps & SpacingProps) => {\n // Every component should have a context\n const context = React.useContext(Context)\n // Extract additional props from global context\n const {\n label,\n className,\n children: childrenProp,\n size,\n maxElements: maxElementsProp,\n variant,\n ...props\n } = extendPropsWithContext(\n localProps,\n defaultProps,\n context?.AvatarGroup,\n {\n skeleton: context?.skeleton,\n }\n )\n\n const maxElements =\n maxElementsProp && maxElementsProp > 0 ? maxElementsProp : 4\n\n let children = childrenProp\n let numOfHiddenAvatars = 0\n\n if (Array.isArray(childrenProp)) {\n const total = childrenProp.length\n\n if (total > maxElements) {\n numOfHiddenAvatars = total - maxElements + 1\n }\n\n children = childrenProp\n .slice(0, total - numOfHiddenAvatars)\n .map((child, i) => {\n const appliedSize = child.props.size ? child.props.size : size\n const appliedVariant = child.props.variant\n ? child.props.variant\n : variant\n return React.cloneElement(child, {\n size: appliedSize,\n variant: appliedVariant,\n style: { ...child.props.style, zIndex: total - i },\n key: i,\n })\n })\n }\n\n const spacingClasses = createSpacingClasses(props)\n const {\n skeleton, // eslint-disable-line\n ...attributes\n } = validateDOMAttributes({}, props)\n\n return (\n <AvatarGroupContext.Provider value={props}>\n <span\n className={classnames(\n 'dnb-avatar__group',\n spacingClasses,\n className\n )}\n {...attributes}\n >\n <span className=\"dnb-sr-only\">{label}</span>\n\n {children}\n\n {numOfHiddenAvatars ? (\n <ElementsHidden size={size}>\n +{numOfHiddenAvatars}\n </ElementsHidden>\n ) : null}\n </span>\n </AvatarGroupContext.Provider>\n )\n}\n\nexport interface ElementsHiddenProps {\n /**\n * The avatars to group.\n * Default: null\n */\n children?: React.ReactNode\n\n /**\n * The size of the \"elements hidden text (+x)\".\n * Default: medium.\n */\n size?: AvatarSizes\n}\n\nfunction ElementsHidden(props: ElementsHiddenProps) {\n const { size, children } = props\n return (\n <span\n className={classnames(\n 'dnb-avatar__group--elements-left',\n `dnb-avatar__group--elements-left--size-${size || 'medium'}`\n )}\n >\n {children}\n </span>\n )\n}\n\nAvatarGroup._supportsSpacingProps = true\n\nexport default AvatarGroup\n"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAGnC,SAASC,oBAAoB,QAAQ,wBAAwB;AAI7D,SACEC,qBAAqB,EACrBC,sBAAsB,QACjB,+BAA+B;AACtC,OAAOC,OAAO,MAAM,sBAAsB;AAiD1C,OAAO,MAAMC,YAAY,GAAG;EAC1BC,KAAK,EAAE,IAAI;EACXC,SAAS,EAAE,IAAI;EACfC,WAAW,EAAE,CAAC;EACdC,IAAI,EAAE,QAAQ;EACdC,QAAQ,EAAE,IAAI;EACdC,OAAO,EAAE,SAAS;EAClBC,QAAQ,EAAE;AACZ,CAAC;AAED,OAAO,MAAMC,kBAAkB,GAAGd,KAAK,CAACe,aAAa,CAAC,IAAI,CAAC;AAE3D,MAAMC,WAAW,GAAIC,UAA2C,IAAK;EAEnE,MAAMC,OAAO,GAAGlB,KAAK,CAACmB,UAAU,CAACd,OAAO,CAAC;EAEzC,MAAAe,qBAAA,GAQIhB,sBAAsB,CACxBa,UAAU,EACVX,YAAY,EACZY,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEF,WAAW,EACpB;MACEH,QAAQ,EAAEK,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEL;IACrB,CACF,CAAC;IAfK;MACJN,KAAK;MACLC,SAAS;MACTG,QAAQ,EAAEU,YAAY;MACtBX,IAAI;MACJD,WAAW,EAAEa,eAAe;MAC5BV;IAEF,CAAC,GAAAQ,qBAAA;IADIG,KAAK,GAAAC,wBAAA,CAAAJ,qBAAA,EAAAK,SAAA;EAUV,MAAMhB,WAAW,GACfa,eAAe,IAAIA,eAAe,GAAG,CAAC,GAAG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,QAAQ;IAACC,KAAK,EAAEzB;EAAM,GACxCvB,KAAA,CAAA8C,aAAA,SAAAG,QAAA;IACEzC,SAAS,EAAEP,UAAU,CACnB,mBAAmB,EACnByC,cAAc,EACdlC,SACF;EAAE,GACEoC,UAAU,GAEd5C,KAAA,CAAA8C,aAAA;IAAMtC,SAAS,EAAC;EAAa,GAAED,KAAY,CAAC,EAE3CI,QAAQ,EAERe,kBAAkB,GACjB1B,KAAA,CAAA8C,aAAA,CAACI,cAAc;IAACxC,IAAI,EAAEA;EAAK,GAAC,GACzB,EAACgB,kBACY,CAAC,GACf,IACA,CACqB,CAAC;AAElC,CAAC;AAgBD,SAASwB,cAAcA,CAAC3B,KAA0B,EAAE;EAClD,MAAM;IAAEb,IAAI;IAAEC;EAAS,CAAC,GAAGY,KAAK;EAChC,OACEvB,KAAA,CAAA8C,aAAA;IACEtC,SAAS,6EAEmCE,IAAI,IAAI,QAAS;EAC3D,GAEDC,QACG,CAAC;AAEX;AAEAK,WAAW,CAACmC,qBAAqB,GAAG,IAAI;AAExC,eAAenC,WAAW"}
|
|
@@ -43,7 +43,7 @@ export type BadgeProps = {
|
|
|
43
43
|
*/
|
|
44
44
|
variant?: 'information' | 'notification';
|
|
45
45
|
};
|
|
46
|
-
type BadgeAndSpacingProps = BadgeProps & SpacingProps
|
|
46
|
+
type BadgeAndSpacingProps = BadgeProps & SpacingProps & Omit<React.HTMLProps<HTMLElement>, 'content' | 'label'>;
|
|
47
47
|
export declare const defaultProps: {
|
|
48
48
|
label: any;
|
|
49
49
|
className: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","names":["React","classnames","createSpacingClasses","createSkeletonClass","Context","warn","extendPropsWithContext","validateDOMAttributes","defaultProps","label","className","skeleton","children","content","vertical","horizontal","variant","Badge","localProps","context","useContext","allProps","createElement","BadgeRoot","BadgeElem","_extends","props","contentProp","restProps","_objectWithoutProperties","_excluded","skeletonClasses","spacingClasses","contentIsNum","variantIsNotification","isInline","role","_supportsSpacingProps"],"sources":["../../../../src/components/badge/Badge.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport { createSpacingClasses } from '../space/SpacingHelper'\nimport { createSkeletonClass } from '../skeleton/SkeletonHelper'\n\n// Shared\nimport Context, { ContextProps } from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\nimport {\n warn,\n extendPropsWithContext,\n validateDOMAttributes,\n} from '../../shared/component-helper'\n\nexport type BadgeProps = {\n /**\n * Aria label to describe the badge\n * Default: null\n */\n label?: React.ReactNode\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * Skeleton should be applied when loading content\n * Default: null\n */\n skeleton?: SkeletonShow\n\n /**\n * The content to display the badge on top of.\n * Default: null\n */\n children?: React.ReactNode\n\n /**\n * The content of the component.\n * Default: null\n */\n content?: string | number | React.ReactNode\n\n /**\n * The vertical positioning of the component.\n * Default: null\n */\n vertical?: 'bottom' | 'top'\n\n /**\n * The horizontal positioning of the component.\n * Default: null\n */\n horizontal?: 'left' | 'right'\n\n /**\n * The variant of the component.\n * Default: information.\n */\n variant?: 'information' | 'notification'\n}\n\ntype BadgeAndSpacingProps = BadgeProps
|
|
1
|
+
{"version":3,"file":"Badge.js","names":["React","classnames","createSpacingClasses","createSkeletonClass","Context","warn","extendPropsWithContext","validateDOMAttributes","defaultProps","label","className","skeleton","children","content","vertical","horizontal","variant","Badge","localProps","context","useContext","allProps","createElement","BadgeRoot","BadgeElem","_extends","props","contentProp","restProps","_objectWithoutProperties","_excluded","skeletonClasses","spacingClasses","contentIsNum","variantIsNotification","isInline","role","_supportsSpacingProps"],"sources":["../../../../src/components/badge/Badge.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport { createSpacingClasses } from '../space/SpacingHelper'\nimport { createSkeletonClass } from '../skeleton/SkeletonHelper'\n\n// Shared\nimport Context, { ContextProps } from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\nimport {\n warn,\n extendPropsWithContext,\n validateDOMAttributes,\n} from '../../shared/component-helper'\n\nexport type BadgeProps = {\n /**\n * Aria label to describe the badge\n * Default: null\n */\n label?: React.ReactNode\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * Skeleton should be applied when loading content\n * Default: null\n */\n skeleton?: SkeletonShow\n\n /**\n * The content to display the badge on top of.\n * Default: null\n */\n children?: React.ReactNode\n\n /**\n * The content of the component.\n * Default: null\n */\n content?: string | number | React.ReactNode\n\n /**\n * The vertical positioning of the component.\n * Default: null\n */\n vertical?: 'bottom' | 'top'\n\n /**\n * The horizontal positioning of the component.\n * Default: null\n */\n horizontal?: 'left' | 'right'\n\n /**\n * The variant of the component.\n * Default: information.\n */\n variant?: 'information' | 'notification'\n}\n\ntype BadgeAndSpacingProps = BadgeProps &\n SpacingProps &\n Omit<React.HTMLProps<HTMLElement>, 'content' | 'label'>\n\nexport const defaultProps = {\n label: null,\n className: null,\n skeleton: false,\n children: null,\n content: null,\n vertical: null,\n horizontal: null,\n variant: 'information',\n}\n\nfunction Badge(localProps: BadgeAndSpacingProps) {\n // Every component should have a context\n const context = React.useContext(Context)\n\n // Extract additional props from global context\n const allProps = extendPropsWithContext(\n localProps,\n defaultProps,\n context?.Badge,\n { skeleton: context?.skeleton }\n )\n const { children } = allProps\n\n if (children) {\n return (\n <BadgeRoot>\n {children}\n <BadgeElem context={context} {...allProps} />\n </BadgeRoot>\n )\n }\n\n return <BadgeElem context={context} {...allProps} />\n}\n\nfunction BadgeRoot({ children }: { children: React.ReactNode }) {\n return <span className=\"dnb-badge__root\">{children}</span>\n}\n\nfunction BadgeElem(\n props: BadgeAndSpacingProps & { context: ContextProps }\n) {\n const {\n label,\n className,\n children,\n skeleton,\n horizontal,\n vertical,\n content: contentProp,\n variant,\n context,\n ...restProps\n } = props\n\n // to remove spacing props, etc.\n validateDOMAttributes(props, restProps)\n\n const skeletonClasses = createSkeletonClass('shape', skeleton, context)\n const spacingClasses = createSpacingClasses(props)\n const contentIsNum = typeof contentProp === 'number'\n const variantIsNotification = variant === 'notification'\n\n const content =\n variantIsNotification && contentIsNum && contentProp > 9\n ? '9+'\n : contentProp\n\n if (variantIsNotification && !contentIsNum) {\n warn(\n `Type of content should be a number: A notification badge is best suited to display content of type number.`\n )\n }\n if (!label && contentIsNum) {\n warn(\n `Label required: A Badge with a number as content requires a label describing the content of the badge. This is to ensure correct semantic and accessibility.`\n )\n }\n\n const isInline = !children && content\n\n return (\n <span\n role=\"status\"\n className={classnames(\n 'dnb-badge',\n `dnb-badge--variant-${variant}`,\n horizontal && `dnb-badge--horizontal-${horizontal}`,\n vertical && `dnb-badge--vertical-${vertical}`,\n isInline && 'dnb-badge--inline',\n skeletonClasses,\n spacingClasses,\n className\n )}\n {...restProps}\n >\n {label && <span className=\"dnb-sr-only\">{label} </span>}\n {content}\n </span>\n )\n}\n\nBadge._supportsSpacingProps = true\n\nexport default Badge\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAGnC,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,mBAAmB,QAAQ,4BAA4B;AAGhE,OAAOC,OAAO,MAAwB,sBAAsB;AAG5D,SACEC,IAAI,EACJC,sBAAsB,EACtBC,qBAAqB,QAChB,+BAA+B;AAwDtC,OAAO,MAAMC,YAAY,GAAG;EAC1BC,KAAK,EAAE,IAAI;EACXC,SAAS,EAAE,IAAI;EACfC,QAAQ,EAAE,KAAK;EACfC,QAAQ,EAAE,IAAI;EACdC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE,IAAI;EACdC,UAAU,EAAE,IAAI;EAChBC,OAAO,EAAE;AACX,CAAC;AAED,SAASC,KAAKA,CAACC,UAAgC,EAAE;EAE/C,MAAMC,OAAO,GAAGnB,KAAK,CAACoB,UAA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MO,qBAAqB,GAAGlB,OAAO,KAAK,cAAc;EAExD,MAAMH,OAAO,GACXqB,qBAAqB,IAAID,YAAY,IAAIN,WAAW,GAAG,CAAC,GACpD,IAAI,GACJA,WAAW;EAEjB,IAAIO,qBAAqB,IAAI,CAACD,YAAY,EAAE;IAC1C5B,IAAI,CACD,4GACH,CAAC;EACH;EACA,IAAI,CAACI,KAAK,IAAIwB,YAAY,EAAE;IAC1B5B,IAAI,CACD,8JACH,CAAC;EACH;EAEA,MAAM8B,QAAQ,GAAG,CAACvB,QAAQ,IAAIC,OAAO;EAErC,OACEb,KAAA,CAAAsB,aAAA,SAAAG,QAAA;IACEW,IAAI,EAAC,QAAQ;IACb1B,SAAS,EAAET,UAAU,iCAEGe,OAAQ,IAI9Be,eAAe,EACfC,cAAc,EACdtB,SAAS,EALTK,UAAU,IAAK,yBAAwBA,UAAW,EAAC,EACnDD,QAAQ,IAAK,uBAAsBA,QAAS,EAAC,EAC7CqB,QAAQ,IAAI,mBAId;EAAE,GACEP,SAAS,GAEZnB,KAAK,IAAIT,KAAA,CAAAsB,aAAA;IAAMZ,SAAS,EAAC;EAAa,GAAED,KAAK,EAAC,GAAO,CAAC,EACtDI,OACG,CAAC;AAEX;AAEAI,KAAK,CAACoB,qBAAqB,GAAG,IAAI;AAElC,eAAepB,KAAK"}
|
package/es/components/lib.d.ts
CHANGED
|
@@ -164,12 +164,12 @@ export declare const getComponents: () => {
|
|
|
164
164
|
(localProps: import("./tag/Tag").TagProps & import("./space/types").SpacingElementProps & {
|
|
165
165
|
space?: import("./space/types").SpaceTypeAll;
|
|
166
166
|
innerSpace?: import("./space/types").SpaceTypeAll | import("./space/types").SpaceTypeMedia;
|
|
167
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
167
|
+
} & import("react").HTMLProps<HTMLElement>): import("react/jsx-runtime").JSX.Element;
|
|
168
168
|
Group: {
|
|
169
169
|
(localProps: import("./tag/TagGroup").TagGroupProps & import("./space/types").SpacingElementProps & {
|
|
170
170
|
space?: import("./space/types").SpaceTypeAll;
|
|
171
171
|
innerSpace?: import("./space/types").SpaceTypeAll | import("./space/types").SpaceTypeMedia;
|
|
172
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
172
|
+
} & Omit<import("react").HTMLProps<HTMLElement>, "label">): import("react/jsx-runtime").JSX.Element;
|
|
173
173
|
_supportsSpacingProps: boolean;
|
|
174
174
|
};
|
|
175
175
|
_formElement: boolean;
|
|
@@ -46,7 +46,7 @@ export function SectionParams(localProps) {
|
|
|
46
46
|
}));
|
|
47
47
|
}
|
|
48
48
|
function getColor(value) {
|
|
49
|
-
if (value.includes('--')) {
|
|
49
|
+
if (String(value).includes('--')) {
|
|
50
50
|
return value;
|
|
51
51
|
}
|
|
52
52
|
return value ? !/#|var/.test(value) ? `var(--color-${value})` : value : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Section.js","names":["React","classnames","Context","isTrue","extendPropsWithContext","Space","defaultProps","element","Section","localProps","createElement","SectionParams","context","useContext","props","variant","breakout","outset","roundedCorner","textColor","backgroundColor","dropShadow","outline","innerRef","className","children","spacing","style_type","inner_ref","attributes","_objectWithoutProperties","_excluded","internalRef","useRef","elementRef","Object","freeze","_objectSpread","style","computeStyle","value","getColor","String","includes","test","undefined","property","name","valueCallback","media","small","medium","large","result","size","_media","_media2","_name","_supportsSpacingProps"],"sources":["../../../../src/components/section/Section.tsx"],"sourcesContent":["/**\n * Web Section Component\n *\n */\n\nimport React from 'react'\nimport classnames from 'classnames'\nimport Context from '../../shared/Context'\nimport {\n isTrue,\n extendPropsWithContext,\n} from '../../shared/component-helper'\nimport type {\n DynamicElement,\n ResponsiveProp,\n SpacingProps,\n} from '../../shared/types'\nimport Space from '../space/Space'\n\nexport type SectionVariants = 'error' | 'info' | 'warning' | 'success'\n\nexport type SectionStyleTypes =\n | 'divider'\n | 'white'\n | 'transparent'\n\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'lavender'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'pistachio'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'emerald-green'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'sea-green'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'fire-red'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'fire-red-8'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'sand-yellow'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'black-3'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'mint-green'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'mint-green-12'\n\nexport type SectionSpacing =\n | boolean\n | 'x-small'\n | 'small'\n | 'medium'\n | 'large'\n | 'x-large'\n | 'xx-large'\n\nexport type TextColor = string\nexport type OutlineColor = string | boolean\nexport type BackgroundColor = string\nexport type DropShadow = boolean\n\nexport type SectionProps = {\n /**\n * Defines the semantic purpose and subsequently the style of the visual helper. Will take precedence over the style_type prop\n */\n variant?: SectionVariants | string\n\n /**\n * Define if the background color should break-out to a fullscreen view. Defaults to `true`.\n */\n breakout?: boolean | ResponsiveProp<boolean>\n\n /**\n * Define if the Card should break out negatively on larger screens. You can not use `breakout` and `outset` together.\n * Defaults to `false`\n */\n outset?: boolean | ResponsiveProp<boolean>\n\n /**\n * Define if the section should have rounded corners. Defaults to `false`.\n */\n roundedCorner?: boolean | ResponsiveProp<boolean>\n\n /**\n * Define a custom border color. Use a Eufemia color.\n */\n outline?: OutlineColor | ResponsiveProp<OutlineColor>\n\n /**\n * Define a custom text color to compliment the backgroundColor. Use a Eufemia color.\n */\n textColor?: TextColor | ResponsiveProp<TextColor>\n\n /**\n * Define a custom background color, instead of a variant. Use a Eufemia color.\n */\n backgroundColor?: BackgroundColor | ResponsiveProp<BackgroundColor>\n\n /**\n * Define a custom drop-shadow.\n */\n dropShadow?: DropShadow | ResponsiveProp<DropShadow>\n\n /**\n * Define what HTML element should be used. Defaults to `<section>`.\n */\n element?: DynamicElement\n\n /**\n * Define a React.Ref.\n */\n innerRef?: React.RefObject<HTMLElement>\n\n /**\n * @deprecated in v11 use \"innerSpace\" prop instead\n */\n spacing?: SectionSpacing | ResponsiveProp<SectionSpacing>\n /**\n * @deprecated in v11 use \"background\" prop instead\n */\n style_type?: SectionStyleTypes | string\n /**\n * @deprecated in v11 use \"innerRef\" prop instead\n */\n inner_ref?: React.RefObject<HTMLElement>\n}\n\nexport type SectionAllProps = SectionProps &\n SpacingProps &\n Omit<React.HTMLProps<HTMLElement>, 'ref'>\n\ntype SectionReturnParams = Record<string, unknown> & {\n className: string\n innerRef: React.RefObject<HTMLElement>\n children: React.ReactNode\n style: React.CSSProperties\n}\n\nconst defaultProps = {\n element: 'section',\n}\n\nexport default function Section(localProps: SectionAllProps) {\n return <Space {...SectionParams(localProps)} />\n}\n\nexport function SectionParams(\n localProps: SectionAllProps\n): SectionReturnParams {\n const context = React.useContext(Context)\n\n // use only the props from context, who are available here anyway\n const props = extendPropsWithContext(\n localProps,\n defaultProps,\n context.Section\n )\n\n const {\n variant,\n breakout = !props.outset,\n outset,\n roundedCorner,\n textColor,\n backgroundColor,\n dropShadow,\n outline,\n innerRef,\n\n className,\n children,\n\n spacing,\n style_type,\n inner_ref,\n\n ...attributes\n } = props\n\n const internalRef = React.useRef<HTMLElement>()\n const elementRef = innerRef || inner_ref || internalRef\n\n return Object.freeze({\n ...attributes,\n className: classnames(\n 'dnb-section',\n `dnb-section--${variant ? variant : style_type || 'default'}`,\n spacing &&\n `dnb-section--spacing-${isTrue(spacing) ? 'large' : spacing}`,\n className\n ),\n style: {\n ...computeStyle(\n breakout,\n 'breakout',\n (value) => `var(--breakout--${value ? 'on' : 'off'})`\n ),\n ...computeStyle(outset, 'outset', (value) => (value ? '1' : '0')),\n ...computeStyle(\n roundedCorner,\n 'rounded-corner',\n (value) => value && 'var(--rounded-corner--value)'\n ),\n ...computeStyle(textColor, 'text-color', (value) => getColor(value)),\n ...computeStyle(backgroundColor, 'background-color', (value) =>\n getColor(value)\n ),\n ...computeStyle(\n dropShadow,\n 'drop-shadow',\n (value) => value && 'var(--shadow-default)'\n ),\n ...computeStyle(outline, 'outline-color', (value) =>\n String(value) === 'true'\n ? 'var(--outline-color--value)'\n : getColor(value)\n ),\n ...attributes?.style,\n } as React.CSSProperties,\n innerRef: elementRef,\n children,\n })\n}\n\nfunction getColor(value: string) {\n if (value.includes('--')) {\n return value\n }\n return value\n ? !/#|var/.test(value)\n ? `var(--color-${value})`\n : value\n : undefined\n}\n\nfunction computeStyle(\n property: ResponsiveProp<unknown> | boolean | string,\n name: string,\n valueCallback: (value: string) => string | undefined\n) {\n let media = property as ResponsiveProp<unknown>\n\n if (media !== null && typeof media !== 'object') {\n media = {\n small: property,\n medium: property,\n large: property,\n } as ResponsiveProp<unknown>\n }\n\n const result = {}\n\n for (const size in media as ResponsiveProp<unknown>) {\n if (typeof media?.[size] !== 'undefined') {\n const value = valueCallback(media?.[size])\n if (typeof value === 'string') {\n result[`--${name}--${size}`] = value\n }\n }\n }\n\n return result\n}\n\nSection._name = 'Section'\nSection._supportsSpacingProps = true\n"],"mappings":";;;;;;;AAKA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,OAAO,MAAM,sBAAsB;AAC1C,SACEC,MAAM,EACNC,sBAAsB,QACjB,+BAA+B;AAMtC,OAAOC,KAAK,MAAM,gBAAgB;AAyHlC,MAAMC,YAAY,GAAG;EACnBC,OAAO,EAAE;AACX,CAAC;AAED,eAAe,SAASC,OAAOA,CAACC,UAA2B,EAAE;EAC3D,OAAOT,KAAA,CAAAU,aAAA,CAACL,KAAK,EAAKM,aAAa,CAACF,UAAU,CAAI,CAAC;AACjD;AAEA,OAAO,SAASE,aAAaA,CAC3BF,UAA2B,E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CAAC,MAAK,WAAW,EAAE;MAAA,IAAAE,OAAA;MACxC,MAAMhB,KAAK,GAAGQ,aAAa,EAAAQ,OAAA,GAACP,KAAK,cAAAO,OAAA,uBAALA,OAAA,CAAQF,IAAI,CAAC,CAAC;MAC1C,IAAI,OAAOd,KAAK,KAAK,QAAQ,EAAE;QAC7Ba,MAAM,CAAE,KAAIN,IAAK,KAAIO,IAAK,EAAC,CAAC,GAAGd,KAAK;MACtC;IACF;EACF;EAEA,OAAOa,MAAM;AACf;AAEA7C,OAAO,CAACiD,KAAK,GAAG,SAAS;AACzBjD,OAAO,CAACkD,qBAAqB,GAAG,IAAI"}
|
|
1
|
+
{"version":3,"file":"Section.js","names":["React","classnames","Context","isTrue","extendPropsWithContext","Space","defaultProps","element","Section","localProps","createElement","SectionParams","context","useContext","props","variant","breakout","outset","roundedCorner","textColor","backgroundColor","dropShadow","outline","innerRef","className","children","spacing","style_type","inner_ref","attributes","_objectWithoutProperties","_excluded","internalRef","useRef","elementRef","Object","freeze","_objectSpread","style","computeStyle","value","getColor","String","includes","test","undefined","property","name","valueCallback","media","small","medium","large","result","size","_media","_media2","_name","_supportsSpacingProps"],"sources":["../../../../src/components/section/Section.tsx"],"sourcesContent":["/**\n * Web Section Component\n *\n */\n\nimport React from 'react'\nimport classnames from 'classnames'\nimport Context from '../../shared/Context'\nimport {\n isTrue,\n extendPropsWithContext,\n} from '../../shared/component-helper'\nimport type {\n DynamicElement,\n ResponsiveProp,\n SpacingProps,\n} from '../../shared/types'\nimport Space from '../space/Space'\n\nexport type SectionVariants = 'error' | 'info' | 'warning' | 'success'\n\nexport type SectionStyleTypes =\n | 'divider'\n | 'white'\n | 'transparent'\n\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'lavender'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'pistachio'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'emerald-green'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'sea-green'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'fire-red'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'fire-red-8'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'sand-yellow'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'black-3'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'mint-green'\n /** @deprecated in v11 use \"variant\" or \"backgroundColor\" prop instead */\n | 'mint-green-12'\n\nexport type SectionSpacing =\n | boolean\n | 'x-small'\n | 'small'\n | 'medium'\n | 'large'\n | 'x-large'\n | 'xx-large'\n\nexport type TextColor = string\nexport type OutlineColor = string | boolean\nexport type BackgroundColor = string\nexport type DropShadow = boolean\n\nexport type SectionProps = {\n /**\n * Defines the semantic purpose and subsequently the style of the visual helper. Will take precedence over the style_type prop\n */\n variant?: SectionVariants | string\n\n /**\n * Define if the background color should break-out to a fullscreen view. Defaults to `true`.\n */\n breakout?: boolean | ResponsiveProp<boolean>\n\n /**\n * Define if the Card should break out negatively on larger screens. You can not use `breakout` and `outset` together.\n * Defaults to `false`\n */\n outset?: boolean | ResponsiveProp<boolean>\n\n /**\n * Define if the section should have rounded corners. Defaults to `false`.\n */\n roundedCorner?: boolean | ResponsiveProp<boolean>\n\n /**\n * Define a custom border color. Use a Eufemia color.\n */\n outline?: OutlineColor | ResponsiveProp<OutlineColor>\n\n /**\n * Define a custom text color to compliment the backgroundColor. Use a Eufemia color.\n */\n textColor?: TextColor | ResponsiveProp<TextColor>\n\n /**\n * Define a custom background color, instead of a variant. Use a Eufemia color.\n */\n backgroundColor?: BackgroundColor | ResponsiveProp<BackgroundColor>\n\n /**\n * Define a custom drop-shadow.\n */\n dropShadow?: DropShadow | ResponsiveProp<DropShadow>\n\n /**\n * Define what HTML element should be used. Defaults to `<section>`.\n */\n element?: DynamicElement\n\n /**\n * Define a React.Ref.\n */\n innerRef?: React.RefObject<HTMLElement>\n\n /**\n * @deprecated in v11 use \"innerSpace\" prop instead\n */\n spacing?: SectionSpacing | ResponsiveProp<SectionSpacing>\n /**\n * @deprecated in v11 use \"background\" prop instead\n */\n style_type?: SectionStyleTypes | string\n /**\n * @deprecated in v11 use \"innerRef\" prop instead\n */\n inner_ref?: React.RefObject<HTMLElement>\n}\n\nexport type SectionAllProps = SectionProps &\n SpacingProps &\n Omit<React.HTMLProps<HTMLElement>, 'ref'>\n\ntype SectionReturnParams = Record<string, unknown> & {\n className: string\n innerRef: React.RefObject<HTMLElement>\n children: React.ReactNode\n style: React.CSSProperties\n}\n\nconst defaultProps = {\n element: 'section',\n}\n\nexport default function Section(localProps: SectionAllProps) {\n return <Space {...SectionParams(localProps)} />\n}\n\nexport function SectionParams(\n localProps: SectionAllProps\n): SectionReturnParams {\n const context = React.useContext(Context)\n\n // use only the props from context, who are available here anyway\n const props = extendPropsWithContext(\n localProps,\n defaultProps,\n context.Section\n )\n\n const {\n variant,\n breakout = !props.outset,\n outset,\n roundedCorner,\n textColor,\n backgroundColor,\n dropShadow,\n outline,\n innerRef,\n\n className,\n children,\n\n spacing,\n style_type,\n inner_ref,\n\n ...attributes\n } = props\n\n const internalRef = React.useRef<HTMLElement>()\n const elementRef = innerRef || inner_ref || internalRef\n\n return Object.freeze({\n ...attributes,\n className: classnames(\n 'dnb-section',\n `dnb-section--${variant ? variant : style_type || 'default'}`,\n spacing &&\n `dnb-section--spacing-${isTrue(spacing) ? 'large' : spacing}`,\n className\n ),\n style: {\n ...computeStyle(\n breakout,\n 'breakout',\n (value) => `var(--breakout--${value ? 'on' : 'off'})`\n ),\n ...computeStyle(outset, 'outset', (value) => (value ? '1' : '0')),\n ...computeStyle(\n roundedCorner,\n 'rounded-corner',\n (value) => value && 'var(--rounded-corner--value)'\n ),\n ...computeStyle(textColor, 'text-color', (value) => getColor(value)),\n ...computeStyle(backgroundColor, 'background-color', (value) =>\n getColor(value)\n ),\n ...computeStyle(\n dropShadow,\n 'drop-shadow',\n (value) => value && 'var(--shadow-default)'\n ),\n ...computeStyle(outline, 'outline-color', (value) =>\n String(value) === 'true'\n ? 'var(--outline-color--value)'\n : getColor(value)\n ),\n ...attributes?.style,\n } as React.CSSProperties,\n innerRef: elementRef,\n children,\n })\n}\n\nfunction getColor(value: string) {\n if (String(value).includes('--')) {\n return value\n }\n return value\n ? !/#|var/.test(value)\n ? `var(--color-${value})`\n : value\n : undefined\n}\n\nfunction computeStyle(\n property: ResponsiveProp<unknown> | boolean | string,\n name: string,\n valueCallback: (value: string) => string | undefined\n) {\n let media = property as ResponsiveProp<unknown>\n\n if (media !== null && typeof media !== 'object') {\n media = {\n small: property,\n medium: property,\n large: property,\n } as ResponsiveProp<unknown>\n }\n\n const result = {}\n\n for (const size in media as ResponsiveProp<unknown>) {\n if (typeof media?.[size] !== 'undefined') {\n const value = valueCallback(media?.[size])\n if (typeof value === 'string') {\n result[`--${name}--${size}`] = value\n }\n }\n }\n\n return result\n}\n\nSection._name = 'Section'\nSection._supportsSpacingProps = true\n"],"mappings":";;;;;;;AAKA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,OAAO,MAAM,sBAAsB;AAC1C,SACEC,MAAM,EACNC,sBAAsB,QACjB,+BAA+B;AAMtC,OAAOC,KAAK,MAAM,gBAAgB;AAyHlC,MAAMC,YAAY,GAAG;EACnBC,OAAO,EAAE;AACX,CAAC;AAED,eAAe,SAASC,OAAOA,CAACC,UAA2B,EAAE;EAC3D,OAAOT,KAAA,CAAAU,aAAA,CAACL,KAAK,EAAKM,aAAa,CAACF,UAAU,CAAI,CAAC;AACjD;AAEA,OAAO,SAASE,aAAaA,CAC3BF,UAA2B,EACN;EACrB,MAAMG,OAAO,GAAGZ,KAAK,CAACa,UAAU,CAACX,OAAO,CAAC;EAGzC,MAAMY,KAAK,GAAGV,sBAAsB,CAClCK,UAAU,EACVH,YAAY,EACZ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AA,uBAALA,OAAA,CAAQF,IAAI,CAAC,CAAC;MAC1C,IAAI,OAAOd,KAAK,KAAK,QAAQ,EAAE;QAC7Ba,MAAM,CAAE,KAAIN,IAAK,KAAIO,IAAK,EAAC,CAAC,GAAGd,KAAK;MACtC;IACF;EACF;EAEA,OAAOa,MAAM;AACf;AAEA7C,OAAO,CAACiD,KAAK,GAAG,SAAS;AACzBjD,OAAO,CAACkD,qBAAqB,GAAG,IAAI"}
|
|
@@ -70,12 +70,12 @@ export declare const defaultProps: {
|
|
|
70
70
|
omitOnKeyUpDeleteEvent: boolean;
|
|
71
71
|
};
|
|
72
72
|
declare const Tag: {
|
|
73
|
-
(localProps: TagProps & SpacingProps): import("react/jsx-runtime").JSX.Element;
|
|
73
|
+
(localProps: TagProps & SpacingProps & React.HTMLProps<HTMLElement>): import("react/jsx-runtime").JSX.Element;
|
|
74
74
|
Group: {
|
|
75
75
|
(localProps: import("./TagGroup").TagGroupProps & import("../space/types").SpacingElementProps & {
|
|
76
76
|
space?: import("../space/types").SpaceTypeAll;
|
|
77
77
|
innerSpace?: import("../space/types").SpaceTypeAll | import("../space/types").SpaceTypeMedia;
|
|
78
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
78
|
+
} & Omit<React.HTMLProps<HTMLElement>, "label">): import("react/jsx-runtime").JSX.Element;
|
|
79
79
|
_supportsSpacingProps: boolean;
|
|
80
80
|
};
|
|
81
81
|
_formElement: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","names":["React","classnames","IconPrimary","Button","Context","warn","extendPropsWithContext","TagGroup","TagGroupContext","createSpacingClasses","defaultProps","skeleton","omitOnKeyUpDeleteEvent","Tag","localProps","_context$translation","context","useContext","tagGroupContext","allProps","translation","_handleDeprecatedBeha","handleDeprecatedBehavior","className","children","text","hasLabel","variant","onClick","removeIconTitle","addIconTitle","props","_objectWithoutProperties","_excluded","content","addIcon","isInteractive","spacingClasses","tagClassNames","buttonAttr","isDeleteKeyboardEvent","keyboardEvent","key","handleDeleteKeyUp","event","element","type","icon","getIcon","createElement","_extends","size","icon_position","on_click","onKeyUp","e","undefined","_ref","onDelete","_excluded2","title","inherit_color","_svg","width","height","fill","xmlns","d","strokeWidth","strokeLinecap","strokeLinejoin","Group","_formElement","_supportsSpacingProps"],"sources":["../../../../src/components/tag/Tag.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport IconPrimary from '../icon-primary/IconPrimary'\nimport type { IconIcon } from '../icon/Icon'\nimport Button, { ButtonProps } from '../button/Button'\n\n// Shared\nimport Context from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\nimport {\n warn,\n extendPropsWithContext,\n} from '../../shared/component-helper'\n\n// Internal\nimport TagGroup from './TagGroup'\nimport { TagGroupContext } from './TagContext'\nimport { createSpacingClasses } from '../space/SpacingHelper'\n\nexport interface TagProps {\n /**\n * The content of the tag element, can be a string or a React Element.\n * Default: null\n */\n text?: string | React.ReactNode\n\n /**\n * Icon displaying on the left side\n * Default: null\n */\n icon?: IconIcon\n\n /**\n * If a label is given, typical inside a table or dl (definition list), then you can disable Tag.Group as a dependent of Tag. Use `true` to omit the `Tag group required:` warning.\n * Default: null\n */\n hasLabel?: boolean\n\n /**\n * Defines the variant\n * Default: 'default'\n */\n variant?: 'default' | 'clickable' | 'addable' | 'removable'\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * Skeleton should be applied when loading content\n * Default: null\n */\n skeleton?: SkeletonShow\n\n /**\n * The content of the tag element, can be a string or a React Element. Will be overwritten by text prop\n * Default: null\n */\n children?: string | React.ReactNode // ReactNode allows multiple elements, strings, numbers, fragments, portals...\n\n /**\n * Handle the click event on 'tag' element\n * Default: null\n */\n onClick?: React.MouseEventHandler<HTMLButtonElement>\n\n /**\n * Handle the delete event on 'tag' element\n * Default: null\n * @deprecated Use `onClick` instead. With `variant='removable'`\n */\n onDelete?: React.MouseEventHandler<HTMLButtonElement>\n\n /**\n * Handle the delete event on 'tag' element\n * Default: null\n */\n omitOnKeyUpDeleteEvent?: boolean\n\n /**\n * Internal property\n * Has translation in context\n */\n removeIconTitle?: string\n\n /**\n * Internal property\n * Has translation in context\n */\n addIconTitle?: string\n}\n\nexport const defaultProps = {\n skeleton: null,\n omitOnKeyUpDeleteEvent: false,\n}\n\nconst Tag = (localProps: TagProps & SpacingProps) => {\n // Every component should have a context\n const context = React.useContext(Context)\n const tagGroupContext = React.useContext(TagGroupContext)\n\n // Extract additional props from global context\n const allProps = extendPropsWithContext(\n localProps,\n defaultProps,\n context?.translation?.Tag,\n context?.Tag,\n tagGroupContext\n )\n\n const {\n className,\n skeleton,\n children,\n text,\n hasLabel,\n variant = 'default',\n onClick,\n omitOnKeyUpDeleteEvent,\n removeIconTitle, // has a translation in context\n addIconTitle, // has a translation in context\n ...props\n } = handleDeprecatedBehavior(allProps)\n\n const content = text || children\n\n const addIcon = variant === 'removable' || variant === 'addable'\n const isInteractive = variant !== 'default'\n const spacingClasses = createSpacingClasses(props)\n const tagClassNames = classnames(\n 'dnb-tag',\n className,\n spacingClasses,\n isInteractive && 'dnb-tag--interactive',\n `dnb-tag--${variant}`\n )\n const buttonAttr: typeof props & Pick<ButtonProps, 'element' | 'type'> =\n props\n\n const isDeleteKeyboardEvent = (keyboardEvent) => {\n return (\n keyboardEvent.key === 'Backspace' || keyboardEvent.key === 'Delete'\n )\n }\n\n const handleDeleteKeyUp = (event) => {\n if (isDeleteKeyboardEvent(event) && onClick) {\n onClick(event)\n }\n }\n\n if (!isInteractive) {\n buttonAttr.element = 'span'\n buttonAttr.type = ''\n }\n\n if (addIcon) {\n buttonAttr.icon = getIcon(\n variant === 'addable' ? addIconTitle : removeIconTitle\n )\n }\n\n if (!tagGroupContext && !hasLabel) {\n warn(\n `Tag group required: A Tag requires a Tag.Group with label description as a parent component. This is to ensure correct semantic and accessibility.`\n )\n }\n\n return (\n <Button\n variant=\"unstyled\"\n size=\"small\"\n icon_position={addIcon ? 'right' : 'left'}\n className={tagClassNames}\n on_click={onClick}\n text={content}\n skeleton={skeleton}\n onKeyUp={\n variant === 'removable' && !omitOnKeyUpDeleteEvent\n ? (e) => handleDeleteKeyUp(e)\n : undefined\n }\n {...buttonAttr}\n />\n )\n}\n\n/**\n * Support deprecated behavior by mutating the props.\n * Deprecated behavior: variant 'clickable' and 'removable' is defined by the 'onClick' and 'onDelete' props\n */\nconst handleDeprecatedBehavior: (allProps: TagProps) => TagProps = ({\n onDelete,\n ...allProps\n}) => {\n if (!allProps.variant) {\n if (allProps.onClick) {\n allProps.variant = 'clickable'\n } else if (onDelete) {\n allProps.onClick = onDelete\n allProps.variant = 'removable'\n }\n }\n return allProps\n}\nconst getIcon = (title: string) => (\n <IconPrimary\n title={title}\n inherit_color={false}\n icon={\n <svg\n width=\"16\"\n height=\"16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M0 8a8 8 0 1 1 16 0A8 8 0 1 1 0 8Z\"\n className=\"dnb-icon-close-circle-path\"\n />\n <path\n d=\"m5.5 10.5 5-5m0 5-5-5\"\n className=\"dnb-icon-close-cross-path\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n }\n />\n)\n\nTag.Group = TagGroup\n\nTag._formElement = true\nTag._supportsSpacingProps = true\n\nexport default Tag\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAGnC,OAAOC,WAAW,MAAM,6BAA6B;AAErD,OAAOC,MAAM,MAAuB,kBAAkB;AAGtD,OAAOC,OAAO,MAAM,sBAAsB;AAG1C,SACEC,IAAI,EACJC,sBAAsB,QACjB,+BAA+B;AAGtC,OAAOC,QAAQ,MAAM,YAAY;AACjC,SAASC,eAAe,QAAQ,cAAc;AAC9C,SAASC,oBAAoB,QAAQ,wBAAwB;AA6E7D,O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OAAO,GAAG,WAAW;IAChC,CAAC,MAAM,IAAI+B,QAAQ,EAAE;MACnBvC,QAAQ,CAACS,OAAO,GAAG8B,QAAQ;MAC3BvC,QAAQ,CAACQ,OAAO,GAAG,WAAW;IAChC;EACF;EACA,OAAOR,QAAQ;AACjB,CAAC;AACD,MAAM6B,OAAO,GAAIY,KAAa,IAC5B5D,KAAA,CAAAiD,aAAA,CAAC/C,WAAW;EACV0D,KAAK,EAAEA,KAAM;EACbC,aAAa,EAAE,KAAM;EACrBd,IAAI,EAAAe,IAAA,KAAAA,IAAA,GACF9D,KAAA,CAAAiD,aAAA;IACEc,KAAK,EAAC,IAAI;IACVC,MAAM,EAAC,IAAI;IACXC,IAAI,EAAC,MAAM;IACXC,KAAK,EAAC;EAA4B,GAElClE,KAAA,CAAAiD,aAAA;IACEkB,CAAC,EAAC,oCAAoC;IACtC5C,SAAS,EAAC;EAA4B,CACvC,CAAC,EACFvB,KAAA,CAAAiD,aAAA;IACEkB,CAAC,EAAC,uBAAuB;IACzB5C,SAAS,EAAC,2BAA2B;IACrC6C,WAAW,EAAC,KAAK;IACjBC,aAAa,EAAC,OAAO;IACrBC,cAAc,EAAC;EAAO,CACvB,CACE,CAAC;AACP,CACF,CACF;AAEDzD,GAAG,CAAC0D,KAAK,GAAGhE,QAAQ;AAEpBM,GAAG,CAAC2D,YAAY,GAAG,IAAI;AACvB3D,GAAG,CAAC4D,qBAAqB,GAAG,IAAI;AAEhC,eAAe5D,GAAG"}
|
|
1
|
+
{"version":3,"file":"Tag.js","names":["React","classnames","IconPrimary","Button","Context","warn","extendPropsWithContext","TagGroup","TagGroupContext","createSpacingClasses","defaultProps","skeleton","omitOnKeyUpDeleteEvent","Tag","localProps","_context$translation","context","useContext","tagGroupContext","allProps","translation","_handleDeprecatedBeha","handleDeprecatedBehavior","className","children","text","hasLabel","variant","onClick","removeIconTitle","addIconTitle","props","_objectWithoutProperties","_excluded","content","addIcon","isInteractive","spacingClasses","tagClassNames","buttonAttr","isDeleteKeyboardEvent","keyboardEvent","key","handleDeleteKeyUp","event","element","type","icon","getIcon","createElement","_extends","size","icon_position","on_click","onKeyUp","e","undefined","_ref","onDelete","_excluded2","title","inherit_color","_svg","width","height","fill","xmlns","d","strokeWidth","strokeLinecap","strokeLinejoin","Group","_formElement","_supportsSpacingProps"],"sources":["../../../../src/components/tag/Tag.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport IconPrimary from '../icon-primary/IconPrimary'\nimport type { IconIcon } from '../icon/Icon'\nimport Button, { ButtonProps } from '../button/Button'\n\n// Shared\nimport Context from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\nimport {\n warn,\n extendPropsWithContext,\n} from '../../shared/component-helper'\n\n// Internal\nimport TagGroup from './TagGroup'\nimport { TagGroupContext } from './TagContext'\nimport { createSpacingClasses } from '../space/SpacingHelper'\n\nexport interface TagProps {\n /**\n * The content of the tag element, can be a string or a React Element.\n * Default: null\n */\n text?: string | React.ReactNode\n\n /**\n * Icon displaying on the left side\n * Default: null\n */\n icon?: IconIcon\n\n /**\n * If a label is given, typical inside a table or dl (definition list), then you can disable Tag.Group as a dependent of Tag. Use `true` to omit the `Tag group required:` warning.\n * Default: null\n */\n hasLabel?: boolean\n\n /**\n * Defines the variant\n * Default: 'default'\n */\n variant?: 'default' | 'clickable' | 'addable' | 'removable'\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * Skeleton should be applied when loading content\n * Default: null\n */\n skeleton?: SkeletonShow\n\n /**\n * The content of the tag element, can be a string or a React Element. Will be overwritten by text prop\n * Default: null\n */\n children?: string | React.ReactNode // ReactNode allows multiple elements, strings, numbers, fragments, portals...\n\n /**\n * Handle the click event on 'tag' element\n * Default: null\n */\n onClick?: React.MouseEventHandler<HTMLButtonElement>\n\n /**\n * Handle the delete event on 'tag' element\n * Default: null\n * @deprecated Use `onClick` instead. With `variant='removable'`\n */\n onDelete?: React.MouseEventHandler<HTMLButtonElement>\n\n /**\n * Handle the delete event on 'tag' element\n * Default: null\n */\n omitOnKeyUpDeleteEvent?: boolean\n\n /**\n * Internal property\n * Has translation in context\n */\n removeIconTitle?: string\n\n /**\n * Internal property\n * Has translation in context\n */\n addIconTitle?: string\n}\n\nexport const defaultProps = {\n skeleton: null,\n omitOnKeyUpDeleteEvent: false,\n}\n\nconst Tag = (\n localProps: TagProps & SpacingProps & React.HTMLProps<HTMLElement>\n) => {\n // Every component should have a context\n const context = React.useContext(Context)\n const tagGroupContext = React.useContext(TagGroupContext)\n\n // Extract additional props from global context\n const allProps = extendPropsWithContext(\n localProps,\n defaultProps,\n context?.translation?.Tag,\n context?.Tag,\n tagGroupContext\n )\n\n const {\n className,\n skeleton,\n children,\n text,\n hasLabel,\n variant = 'default',\n onClick,\n omitOnKeyUpDeleteEvent,\n removeIconTitle, // has a translation in context\n addIconTitle, // has a translation in context\n ...props\n } = handleDeprecatedBehavior(allProps)\n\n const content = text || children\n\n const addIcon = variant === 'removable' || variant === 'addable'\n const isInteractive = variant !== 'default'\n const spacingClasses = createSpacingClasses(props)\n const tagClassNames = classnames(\n 'dnb-tag',\n className,\n spacingClasses,\n isInteractive && 'dnb-tag--interactive',\n `dnb-tag--${variant}`\n )\n const buttonAttr: typeof props & Pick<ButtonProps, 'element' | 'type'> =\n props\n\n const isDeleteKeyboardEvent = (keyboardEvent) => {\n return (\n keyboardEvent.key === 'Backspace' || keyboardEvent.key === 'Delete'\n )\n }\n\n const handleDeleteKeyUp = (event) => {\n if (isDeleteKeyboardEvent(event) && onClick) {\n onClick(event)\n }\n }\n\n if (!isInteractive) {\n buttonAttr.element = 'span'\n buttonAttr.type = ''\n }\n\n if (addIcon) {\n buttonAttr.icon = getIcon(\n variant === 'addable' ? addIconTitle : removeIconTitle\n )\n }\n\n if (!tagGroupContext && !hasLabel) {\n warn(\n `Tag group required: A Tag requires a Tag.Group with label description as a parent component. This is to ensure correct semantic and accessibility.`\n )\n }\n\n return (\n <Button\n variant=\"unstyled\"\n size=\"small\"\n icon_position={addIcon ? 'right' : 'left'}\n className={tagClassNames}\n on_click={onClick}\n text={content}\n skeleton={skeleton}\n onKeyUp={\n variant === 'removable' && !omitOnKeyUpDeleteEvent\n ? (e) => handleDeleteKeyUp(e)\n : undefined\n }\n {...buttonAttr}\n />\n )\n}\n\n/**\n * Support deprecated behavior by mutating the props.\n * Deprecated behavior: variant 'clickable' and 'removable' is defined by the 'onClick' and 'onDelete' props\n */\nconst handleDeprecatedBehavior: (allProps: TagProps) => TagProps = ({\n onDelete,\n ...allProps\n}) => {\n if (!allProps.variant) {\n if (allProps.onClick) {\n allProps.variant = 'clickable'\n } else if (onDelete) {\n allProps.onClick = onDelete\n allProps.variant = 'removable'\n }\n }\n return allProps\n}\nconst getIcon = (title: string) => (\n <IconPrimary\n title={title}\n inherit_color={false}\n icon={\n <svg\n width=\"16\"\n height=\"16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M0 8a8 8 0 1 1 16 0A8 8 0 1 1 0 8Z\"\n className=\"dnb-icon-close-circle-path\"\n />\n <path\n d=\"m5.5 10.5 5-5m0 5-5-5\"\n className=\"dnb-icon-close-cross-path\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n }\n />\n)\n\nTag.Group = TagGroup\n\nTag._formElement = true\nTag._supportsSpacingProps = true\n\nexport default Tag\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAGnC,OAAOC,WAAW,MAAM,6BAA6B;AAErD,OAAOC,MAAM,MAAuB,kBAAkB;AAGtD,OAAOC,OAAO,MAAM,sBAAsB;AAG1C,SACEC,IAAI,EACJC,sBAAsB,QACjB,+BAA+B;AAGtC,OAAOC,QAAQ,MAAM,YAAY;AACjC,SAASC,eAAe,QAAQ,cAAc;AAC9C,SAASC,oBA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,EAAE;MACpBT,QAAQ,CAACQ,OAAO,GAAG,WAAW;IAChC,CAAC,MAAM,IAAI+B,QAAQ,EAAE;MACnBvC,QAAQ,CAACS,OAAO,GAAG8B,QAAQ;MAC3BvC,QAAQ,CAACQ,OAAO,GAAG,WAAW;IAChC;EACF;EACA,OAAOR,QAAQ;AACjB,CAAC;AACD,MAAM6B,OAAO,GAAIY,KAAa,IAC5B5D,KAAA,CAAAiD,aAAA,CAAC/C,WAAW;EACV0D,KAAK,EAAEA,KAAM;EACbC,aAAa,EAAE,KAAM;EACrBd,IAAI,EAAAe,IAAA,KAAAA,IAAA,GACF9D,KAAA,CAAAiD,aAAA;IACEc,KAAK,EAAC,IAAI;IACVC,MAAM,EAAC,IAAI;IACXC,IAAI,EAAC,MAAM;IACXC,KAAK,EAAC;EAA4B,GAElClE,KAAA,CAAAiD,aAAA;IACEkB,CAAC,EAAC,oCAAoC;IACtC5C,SAAS,EAAC;EAA4B,CACvC,CAAC,EACFvB,KAAA,CAAAiD,aAAA;IACEkB,CAAC,EAAC,uBAAuB;IACzB5C,SAAS,EAAC,2BAA2B;IACrC6C,WAAW,EAAC,KAAK;IACjBC,aAAa,EAAC,OAAO;IACrBC,cAAc,EAAC;EAAO,CACvB,CACE,CAAC;AACP,CACF,CACF;AAEDzD,GAAG,CAAC0D,KAAK,GAAGhE,QAAQ;AAEpBM,GAAG,CAAC2D,YAAY,GAAG,IAAI;AACvB3D,GAAG,CAAC4D,qBAAqB,GAAG,IAAI;AAEhC,eAAe5D,GAAG"}
|
|
@@ -30,7 +30,7 @@ export declare const defaultProps: {
|
|
|
30
30
|
skeleton: boolean;
|
|
31
31
|
};
|
|
32
32
|
declare const TagGroup: {
|
|
33
|
-
(localProps: TagGroupProps & SpacingProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
(localProps: TagGroupProps & SpacingProps & Omit<React.HTMLProps<HTMLElement>, 'label'>): import("react/jsx-runtime").JSX.Element;
|
|
34
34
|
_supportsSpacingProps: boolean;
|
|
35
35
|
};
|
|
36
36
|
export default TagGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagGroup.js","names":["React","classnames","createSpacingClasses","validateDOMAttributes","extendPropsWithContext","Context","TagGroupContext","defaultProps","label","className","children","skeleton","TagGroup","localProps","context","useContext","_extendPropsWithConte","childrenProp","props","_objectWithoutProperties","_excluded","Array","isArray","map","child","spacingClasses","_validateDOMAttribute","attributes","_excluded2","createElement","Provider","value","_extends","_supportsSpacingProps"],"sources":["../../../../src/components/tag/TagGroup.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport { createSpacingClasses } from '../space/SpacingHelper'\n\n// Shared\nimport {\n validateDOMAttributes,\n extendPropsWithContext,\n} from '../../shared/component-helper'\nimport Context from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport { TagGroupContext } from './TagContext'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\n\nexport interface TagGroupProps {\n /**\n * Aria label to describe the tag group\n * Default: null\n */\n label: React.ReactNode\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * The tags to group.\n * Default: null\n */\n children?: React.ReactNode\n\n /**\n * Skeleton should be applied when loading content\n * Default: false\n */\n skeleton?: SkeletonShow\n}\n\nexport const defaultProps = {\n label: null,\n className: null,\n children: null,\n skeleton: false,\n}\n\nconst TagGroup = (localProps: TagGroupProps
|
|
1
|
+
{"version":3,"file":"TagGroup.js","names":["React","classnames","createSpacingClasses","validateDOMAttributes","extendPropsWithContext","Context","TagGroupContext","defaultProps","label","className","children","skeleton","TagGroup","localProps","context","useContext","_extendPropsWithConte","childrenProp","props","_objectWithoutProperties","_excluded","Array","isArray","map","child","spacingClasses","_validateDOMAttribute","attributes","_excluded2","createElement","Provider","value","_extends","_supportsSpacingProps"],"sources":["../../../../src/components/tag/TagGroup.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\n// Components\nimport { createSpacingClasses } from '../space/SpacingHelper'\n\n// Shared\nimport {\n validateDOMAttributes,\n extendPropsWithContext,\n} from '../../shared/component-helper'\nimport Context from '../../shared/Context'\nimport type { SpacingProps } from '../../shared/types'\nimport { TagGroupContext } from './TagContext'\nimport type { SkeletonShow } from '../skeleton/Skeleton'\n\nexport interface TagGroupProps {\n /**\n * Aria label to describe the tag group\n * Default: null\n */\n label: React.ReactNode\n\n /**\n * Custom className on the component root\n * Default: null\n */\n className?: string\n\n /**\n * The tags to group.\n * Default: null\n */\n children?: React.ReactNode\n\n /**\n * Skeleton should be applied when loading content\n * Default: false\n */\n skeleton?: SkeletonShow\n}\n\nexport const defaultProps = {\n label: null,\n className: null,\n children: null,\n skeleton: false,\n}\n\nconst TagGroup = (\n localProps: TagGroupProps &\n SpacingProps &\n Omit<React.HTMLProps<HTMLElement>, 'label'>\n) => {\n // Every component should have a context\n const context = React.useContext(Context)\n // Extract additional props from global context\n const {\n label,\n className,\n children: childrenProp,\n ...props\n } = extendPropsWithContext(localProps, defaultProps, context?.TagGroup, {\n skeleton: context?.skeleton,\n })\n\n let children = childrenProp\n\n if (Array.isArray(childrenProp)) {\n children = [...childrenProp].map((child) => {\n return child\n })\n }\n\n const spacingClasses = createSpacingClasses(props)\n const {\n skeleton, // eslint-disable-line\n ...attributes\n } = validateDOMAttributes({}, props)\n\n return (\n <TagGroupContext.Provider value={props}>\n <span\n className={classnames('dnb-tag__group', spacingClasses, className)}\n {...attributes}\n >\n <span className=\"dnb-sr-only\">{label}</span>\n {children}\n </span>\n </TagGroupContext.Provider>\n )\n}\n\nTagGroup._supportsSpacingProps = true\n\nexport default TagGroup\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAGnC,SAASC,oBAAoB,QAAQ,wBAAwB;AAG7D,SACEC,qBAAqB,EACrBC,sBAAsB,QACjB,+BAA+B;AACtC,OAAOC,OAAO,MAAM,sBAAsB;AAE1C,SAASC,eAAe,QA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/DkB,UAAU,GAEd3B,KAAA,CAAA6B,aAAA;IAAMpB,SAAS,EAAC;EAAa,GAAED,KAAY,CAAC,EAC3CE,QACG,CACkB,CAAC;AAE/B,CAAC;AAEDE,QAAQ,CAACqB,qBAAqB,GAAG,IAAI;AAErC,eAAerB,QAAQ"}
|
|
@@ -14,8 +14,11 @@ export type SharedAttachments<Data = unknown> = {
|
|
|
14
14
|
setShowAllErrors?: ContextState['setShowAllErrors'];
|
|
15
15
|
setSubmitState?: ContextState['setSubmitState'];
|
|
16
16
|
rerenderUseDataHook?: () => void;
|
|
17
|
+
updateDataValue?: ContextState['updateDataValue'];
|
|
17
18
|
clearData?: () => void;
|
|
19
|
+
setData?: ContextState['setData'];
|
|
18
20
|
fieldConnectionsRef?: ContextState['fieldConnectionsRef'];
|
|
21
|
+
internalDataRef?: ContextState['internalDataRef'];
|
|
19
22
|
};
|
|
20
23
|
export type Props<Data extends JsonObject> = IsolationProviderProps<Data> & {
|
|
21
24
|
/**
|
|
@@ -387,34 +387,6 @@ export default function Provider(props) {
|
|
|
387
387
|
isEmptyDataRef.current = false;
|
|
388
388
|
});
|
|
389
389
|
}, [emptyData, id, onClear, setSharedData]);
|
|
390
|
-
useLayoutEffect(() => {
|
|
391
|
-
if (id) {
|
|
392
|
-
if (initialData && !sharedData.data) {
|
|
393
|
-
extendSharedData(initialData, {
|
|
394
|
-
preventSyncOfSameInstance: true
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
}, [id, initialData, extendSharedData, sharedData.data]);
|
|
399
|
-
useLayoutEffect(() => {
|
|
400
|
-
if (id) {
|
|
401
|
-
extendAttachment({
|
|
402
|
-
visibleDataHandler,
|
|
403
|
-
filterDataHandler,
|
|
404
|
-
hasErrors,
|
|
405
|
-
hasFieldError,
|
|
406
|
-
setShowAllErrors,
|
|
407
|
-
setSubmitState,
|
|
408
|
-
clearData,
|
|
409
|
-
fieldConnectionsRef
|
|
410
|
-
}, {
|
|
411
|
-
preventSyncOfSameInstance: true
|
|
412
|
-
});
|
|
413
|
-
if (filterSubmitData) {
|
|
414
|
-
rerenderUseDataHook === null || rerenderUseDataHook === void 0 ? void 0 : rerenderUseDataHook();
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}, [extendAttachment, visibleDataHandler, filterDataHandler, filterSubmitData, hasErrors, hasFieldError, id, rerenderUseDataHook, setShowAllErrors, setSubmitState, clearData, extendSharedData]);
|
|
418
390
|
useMemo(() => {
|
|
419
391
|
executeAjvValidator();
|
|
420
392
|
}, [internalDataRef.current]);
|
|
@@ -764,6 +736,37 @@ export default function Provider(props) {
|
|
|
764
736
|
customStatus: undefined
|
|
765
737
|
});
|
|
766
738
|
}, [setFormState, setSubmitState]);
|
|
739
|
+
useLayoutEffect(() => {
|
|
740
|
+
if (id) {
|
|
741
|
+
if (initialData && !sharedData.data) {
|
|
742
|
+
extendSharedData(initialData, {
|
|
743
|
+
preventSyncOfSameInstance: true
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}, [id, initialData, extendSharedData, sharedData.data]);
|
|
748
|
+
useLayoutEffect(() => {
|
|
749
|
+
if (id) {
|
|
750
|
+
extendAttachment({
|
|
751
|
+
visibleDataHandler,
|
|
752
|
+
filterDataHandler,
|
|
753
|
+
hasErrors,
|
|
754
|
+
hasFieldError,
|
|
755
|
+
setShowAllErrors,
|
|
756
|
+
setSubmitState,
|
|
757
|
+
clearData,
|
|
758
|
+
setData,
|
|
759
|
+
updateDataValue,
|
|
760
|
+
fieldConnectionsRef,
|
|
761
|
+
internalDataRef
|
|
762
|
+
}, {
|
|
763
|
+
preventSyncOfSameInstance: true
|
|
764
|
+
});
|
|
765
|
+
if (filterSubmitData) {
|
|
766
|
+
rerenderUseDataHook === null || rerenderUseDataHook === void 0 ? void 0 : rerenderUseDataHook();
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}, [clearData, extendAttachment, filterDataHandler, filterSubmitData, hasErrors, hasFieldError, id, rerenderUseDataHook, setData, setShowAllErrors, setSubmitState, updateDataValue, visibleDataHandler]);
|
|
767
770
|
const {
|
|
768
771
|
bufferedFormState: formState
|
|
769
772
|
} = useFormStatusBuffer({
|