@dnb/eufemia 10.63.1 → 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.
Files changed (222) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/cjs/components/avatar/Avatar.d.ts +1 -1
  3. package/cjs/components/avatar/Avatar.js.map +1 -1
  4. package/cjs/components/avatar/AvatarGroup.d.ts +1 -1
  5. package/cjs/components/avatar/AvatarGroup.js.map +1 -1
  6. package/cjs/components/badge/Badge.d.ts +1 -1
  7. package/cjs/components/badge/Badge.js.map +1 -1
  8. package/cjs/components/lib.d.ts +2 -2
  9. package/cjs/components/modal/Modal.d.ts +2 -1
  10. package/cjs/components/modal/Modal.js +10 -4
  11. package/cjs/components/modal/Modal.js.map +1 -1
  12. package/cjs/components/modal/ModalContent.d.ts +10 -8
  13. package/cjs/components/modal/ModalContent.js +48 -23
  14. package/cjs/components/modal/ModalContent.js.map +1 -1
  15. package/cjs/components/modal/ModalRoot.d.ts +2 -0
  16. package/cjs/components/modal/ModalRoot.js.map +1 -1
  17. package/cjs/components/modal/types.d.ts +11 -3
  18. package/cjs/components/modal/types.js.map +1 -1
  19. package/cjs/components/section/Section.js +1 -1
  20. package/cjs/components/section/Section.js.map +1 -1
  21. package/cjs/components/tag/Tag.d.ts +2 -2
  22. package/cjs/components/tag/Tag.js.map +1 -1
  23. package/cjs/components/tag/TagGroup.d.ts +1 -1
  24. package/cjs/components/tag/TagGroup.js.map +1 -1
  25. package/cjs/elements/code/style/code-mixins.scss +4 -0
  26. package/cjs/extensions/forms/DataContext/Context.d.ts +1 -1
  27. package/cjs/extensions/forms/DataContext/Context.js.map +1 -1
  28. package/cjs/extensions/forms/DataContext/Provider/Provider.d.ts +3 -0
  29. package/cjs/extensions/forms/DataContext/Provider/Provider.js +33 -30
  30. package/cjs/extensions/forms/DataContext/Provider/Provider.js.map +1 -1
  31. package/cjs/extensions/forms/Form/Visibility/useVisibility.js +6 -6
  32. package/cjs/extensions/forms/Form/Visibility/useVisibility.js.map +1 -1
  33. package/cjs/extensions/forms/Form/data-context/useData.js +14 -10
  34. package/cjs/extensions/forms/Form/data-context/useData.js.map +1 -1
  35. package/cjs/extensions/forms/Form/data-context/useValidation.js +1 -1
  36. package/cjs/extensions/forms/Form/data-context/useValidation.js.map +1 -1
  37. package/cjs/extensions/forms/Wizard/Container/WizardContainer.js +1 -1
  38. package/cjs/extensions/forms/Wizard/Container/WizardContainer.js.map +1 -1
  39. package/cjs/extensions/forms/hooks/useExternalValue.js +2 -2
  40. package/cjs/extensions/forms/hooks/useExternalValue.js.map +1 -1
  41. package/cjs/extensions/forms/hooks/useFieldProps.js +23 -16
  42. package/cjs/extensions/forms/hooks/useFieldProps.js.map +1 -1
  43. package/cjs/shared/Eufemia.d.ts +1 -1
  44. package/cjs/shared/Eufemia.js +2 -2
  45. package/cjs/shared/Eufemia.js.map +1 -1
  46. package/cjs/shared/error-helper.d.ts +0 -6
  47. package/cjs/shared/error-helper.js +6 -3
  48. package/cjs/shared/error-helper.js.map +1 -1
  49. package/cjs/style/core/scopes.scss +1 -1
  50. package/cjs/style/dnb-ui-basis.css +1 -1
  51. package/cjs/style/dnb-ui-basis.min.css +1 -1
  52. package/cjs/style/dnb-ui-body.css +1 -1
  53. package/cjs/style/dnb-ui-body.min.css +1 -1
  54. package/cjs/style/dnb-ui-core.css +1 -1
  55. package/cjs/style/dnb-ui-core.min.css +1 -1
  56. package/cjs/style/dnb-ui-elements.css +3 -0
  57. package/cjs/style/dnb-ui-elements.min.css +1 -1
  58. package/cjs/style/themes/theme-eiendom/eiendom-theme-basis.css +3 -0
  59. package/cjs/style/themes/theme-eiendom/eiendom-theme-basis.min.css +1 -1
  60. package/cjs/style/themes/theme-eiendom/eiendom-theme-elements.css +3 -0
  61. package/cjs/style/themes/theme-eiendom/eiendom-theme-elements.min.css +1 -1
  62. package/cjs/style/themes/theme-sbanken/sbanken-theme-basis.css +3 -0
  63. package/cjs/style/themes/theme-sbanken/sbanken-theme-basis.min.css +1 -1
  64. package/cjs/style/themes/theme-sbanken/sbanken-theme-elements.css +3 -0
  65. package/cjs/style/themes/theme-sbanken/sbanken-theme-elements.min.css +1 -1
  66. package/cjs/style/themes/theme-ui/ui-theme-basis.css +3 -0
  67. package/cjs/style/themes/theme-ui/ui-theme-basis.min.css +1 -1
  68. package/cjs/style/themes/theme-ui/ui-theme-elements.css +3 -0
  69. package/cjs/style/themes/theme-ui/ui-theme-elements.min.css +1 -1
  70. package/cjs/style/themes/theme-ui/ui-theme-tags.css +3 -0
  71. package/cjs/style/themes/theme-ui/ui-theme-tags.min.css +1 -1
  72. package/components/avatar/Avatar.d.ts +1 -1
  73. package/components/avatar/Avatar.js.map +1 -1
  74. package/components/avatar/AvatarGroup.d.ts +1 -1
  75. package/components/avatar/AvatarGroup.js.map +1 -1
  76. package/components/badge/Badge.d.ts +1 -1
  77. package/components/badge/Badge.js.map +1 -1
  78. package/components/lib.d.ts +2 -2
  79. package/components/modal/Modal.d.ts +2 -1
  80. package/components/modal/Modal.js +10 -4
  81. package/components/modal/Modal.js.map +1 -1
  82. package/components/modal/ModalContent.d.ts +10 -8
  83. package/components/modal/ModalContent.js +48 -23
  84. package/components/modal/ModalContent.js.map +1 -1
  85. package/components/modal/ModalRoot.d.ts +2 -0
  86. package/components/modal/ModalRoot.js.map +1 -1
  87. package/components/modal/types.d.ts +11 -3
  88. package/components/modal/types.js.map +1 -1
  89. package/components/section/Section.js +1 -1
  90. package/components/section/Section.js.map +1 -1
  91. package/components/tag/Tag.d.ts +2 -2
  92. package/components/tag/Tag.js.map +1 -1
  93. package/components/tag/TagGroup.d.ts +1 -1
  94. package/components/tag/TagGroup.js.map +1 -1
  95. package/elements/code/style/code-mixins.scss +4 -0
  96. package/es/components/avatar/Avatar.d.ts +1 -1
  97. package/es/components/avatar/Avatar.js.map +1 -1
  98. package/es/components/avatar/AvatarGroup.d.ts +1 -1
  99. package/es/components/avatar/AvatarGroup.js.map +1 -1
  100. package/es/components/badge/Badge.d.ts +1 -1
  101. package/es/components/badge/Badge.js.map +1 -1
  102. package/es/components/lib.d.ts +2 -2
  103. package/es/components/modal/Modal.d.ts +2 -1
  104. package/es/components/modal/Modal.js +10 -4
  105. package/es/components/modal/Modal.js.map +1 -1
  106. package/es/components/modal/ModalContent.d.ts +10 -8
  107. package/es/components/modal/ModalContent.js +44 -20
  108. package/es/components/modal/ModalContent.js.map +1 -1
  109. package/es/components/modal/ModalRoot.d.ts +2 -0
  110. package/es/components/modal/ModalRoot.js.map +1 -1
  111. package/es/components/modal/types.d.ts +11 -3
  112. package/es/components/modal/types.js.map +1 -1
  113. package/es/components/section/Section.js +1 -1
  114. package/es/components/section/Section.js.map +1 -1
  115. package/es/components/tag/Tag.d.ts +2 -2
  116. package/es/components/tag/Tag.js.map +1 -1
  117. package/es/components/tag/TagGroup.d.ts +1 -1
  118. package/es/components/tag/TagGroup.js.map +1 -1
  119. package/es/elements/code/style/code-mixins.scss +4 -0
  120. package/es/extensions/forms/DataContext/Context.d.ts +1 -1
  121. package/es/extensions/forms/DataContext/Context.js.map +1 -1
  122. package/es/extensions/forms/DataContext/Provider/Provider.d.ts +3 -0
  123. package/es/extensions/forms/DataContext/Provider/Provider.js +33 -30
  124. package/es/extensions/forms/DataContext/Provider/Provider.js.map +1 -1
  125. package/es/extensions/forms/Form/Visibility/useVisibility.js +6 -6
  126. package/es/extensions/forms/Form/Visibility/useVisibility.js.map +1 -1
  127. package/es/extensions/forms/Form/data-context/useData.js +14 -10
  128. package/es/extensions/forms/Form/data-context/useData.js.map +1 -1
  129. package/es/extensions/forms/Form/data-context/useValidation.js +1 -1
  130. package/es/extensions/forms/Form/data-context/useValidation.js.map +1 -1
  131. package/es/extensions/forms/Wizard/Container/WizardContainer.js +1 -1
  132. package/es/extensions/forms/Wizard/Container/WizardContainer.js.map +1 -1
  133. package/es/extensions/forms/hooks/useExternalValue.js +2 -2
  134. package/es/extensions/forms/hooks/useExternalValue.js.map +1 -1
  135. package/es/extensions/forms/hooks/useFieldProps.js +23 -16
  136. package/es/extensions/forms/hooks/useFieldProps.js.map +1 -1
  137. package/es/shared/Eufemia.d.ts +1 -1
  138. package/es/shared/Eufemia.js +2 -2
  139. package/es/shared/Eufemia.js.map +1 -1
  140. package/es/shared/error-helper.d.ts +0 -6
  141. package/es/shared/error-helper.js +6 -3
  142. package/es/shared/error-helper.js.map +1 -1
  143. package/es/style/core/scopes.scss +1 -1
  144. package/es/style/dnb-ui-basis.css +1 -1
  145. package/es/style/dnb-ui-basis.min.css +1 -1
  146. package/es/style/dnb-ui-body.css +1 -1
  147. package/es/style/dnb-ui-body.min.css +1 -1
  148. package/es/style/dnb-ui-core.css +1 -1
  149. package/es/style/dnb-ui-core.min.css +1 -1
  150. package/es/style/dnb-ui-elements.css +3 -0
  151. package/es/style/dnb-ui-elements.min.css +1 -1
  152. package/es/style/themes/theme-eiendom/eiendom-theme-basis.css +3 -0
  153. package/es/style/themes/theme-eiendom/eiendom-theme-basis.min.css +1 -1
  154. package/es/style/themes/theme-eiendom/eiendom-theme-elements.css +3 -0
  155. package/es/style/themes/theme-eiendom/eiendom-theme-elements.min.css +1 -1
  156. package/es/style/themes/theme-sbanken/sbanken-theme-basis.css +3 -0
  157. package/es/style/themes/theme-sbanken/sbanken-theme-basis.min.css +1 -1
  158. package/es/style/themes/theme-sbanken/sbanken-theme-elements.css +3 -0
  159. package/es/style/themes/theme-sbanken/sbanken-theme-elements.min.css +1 -1
  160. package/es/style/themes/theme-ui/ui-theme-basis.css +3 -0
  161. package/es/style/themes/theme-ui/ui-theme-basis.min.css +1 -1
  162. package/es/style/themes/theme-ui/ui-theme-elements.css +3 -0
  163. package/es/style/themes/theme-ui/ui-theme-elements.min.css +1 -1
  164. package/es/style/themes/theme-ui/ui-theme-tags.css +3 -0
  165. package/es/style/themes/theme-ui/ui-theme-tags.min.css +1 -1
  166. package/esm/dnb-ui-basis.min.mjs +1 -1
  167. package/esm/dnb-ui-components.min.mjs +1 -1
  168. package/esm/dnb-ui-elements.min.mjs +1 -1
  169. package/esm/dnb-ui-extensions.min.mjs +2 -2
  170. package/esm/dnb-ui-lib.min.mjs +1 -1
  171. package/extensions/forms/DataContext/Context.d.ts +1 -1
  172. package/extensions/forms/DataContext/Context.js.map +1 -1
  173. package/extensions/forms/DataContext/Provider/Provider.d.ts +3 -0
  174. package/extensions/forms/DataContext/Provider/Provider.js +33 -30
  175. package/extensions/forms/DataContext/Provider/Provider.js.map +1 -1
  176. package/extensions/forms/Form/Visibility/useVisibility.js +6 -6
  177. package/extensions/forms/Form/Visibility/useVisibility.js.map +1 -1
  178. package/extensions/forms/Form/data-context/useData.js +14 -10
  179. package/extensions/forms/Form/data-context/useData.js.map +1 -1
  180. package/extensions/forms/Form/data-context/useValidation.js +1 -1
  181. package/extensions/forms/Form/data-context/useValidation.js.map +1 -1
  182. package/extensions/forms/Wizard/Container/WizardContainer.js +1 -1
  183. package/extensions/forms/Wizard/Container/WizardContainer.js.map +1 -1
  184. package/extensions/forms/hooks/useExternalValue.js +2 -2
  185. package/extensions/forms/hooks/useExternalValue.js.map +1 -1
  186. package/extensions/forms/hooks/useFieldProps.js +23 -16
  187. package/extensions/forms/hooks/useFieldProps.js.map +1 -1
  188. package/package.json +1 -1
  189. package/shared/Eufemia.d.ts +1 -1
  190. package/shared/Eufemia.js +2 -2
  191. package/shared/Eufemia.js.map +1 -1
  192. package/shared/error-helper.d.ts +0 -6
  193. package/shared/error-helper.js +6 -3
  194. package/shared/error-helper.js.map +1 -1
  195. package/style/core/scopes.scss +1 -1
  196. package/style/dnb-ui-basis.css +1 -1
  197. package/style/dnb-ui-basis.min.css +1 -1
  198. package/style/dnb-ui-body.css +1 -1
  199. package/style/dnb-ui-body.min.css +1 -1
  200. package/style/dnb-ui-core.css +1 -1
  201. package/style/dnb-ui-core.min.css +1 -1
  202. package/style/dnb-ui-elements.css +3 -0
  203. package/style/dnb-ui-elements.min.css +1 -1
  204. package/style/themes/theme-eiendom/eiendom-theme-basis.css +3 -0
  205. package/style/themes/theme-eiendom/eiendom-theme-basis.min.css +1 -1
  206. package/style/themes/theme-eiendom/eiendom-theme-elements.css +3 -0
  207. package/style/themes/theme-eiendom/eiendom-theme-elements.min.css +1 -1
  208. package/style/themes/theme-sbanken/sbanken-theme-basis.css +3 -0
  209. package/style/themes/theme-sbanken/sbanken-theme-basis.min.css +1 -1
  210. package/style/themes/theme-sbanken/sbanken-theme-elements.css +3 -0
  211. package/style/themes/theme-sbanken/sbanken-theme-elements.min.css +1 -1
  212. package/style/themes/theme-ui/ui-theme-basis.css +3 -0
  213. package/style/themes/theme-ui/ui-theme-basis.min.css +1 -1
  214. package/style/themes/theme-ui/ui-theme-elements.css +3 -0
  215. package/style/themes/theme-ui/ui-theme-elements.min.css +1 -1
  216. package/style/themes/theme-ui/ui-theme-tags.css +3 -0
  217. package/style/themes/theme-ui/ui-theme-tags.min.css +1 -1
  218. package/umd/dnb-ui-basis.min.js +1 -1
  219. package/umd/dnb-ui-components.min.js +1 -1
  220. package/umd/dnb-ui-elements.min.js +1 -1
  221. package/umd/dnb-ui-extensions.min.js +1 -1
  222. package/umd/dnb-ui-lib.min.js +1 -1
@@ -16,6 +16,8 @@ export interface ModalRootProps extends ModalContentProps {
16
16
  * The content which will appear when triggering the modal/drawer.
17
17
  */
18
18
  children?: ReactChildType;
19
+ /** For internal use only */
20
+ modalContentCloseRef?: React.RefObject<any>;
19
21
  }
20
22
  interface ModalRootState {
21
23
  isMounted: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"ModalRoot.js","names":["React","ReactDOM","warn","isTrue","ModalContent","ModalRoot","PureComponent","constructor","arguments","_defineProperty","isMounted","insertModalRoot","id","window","__modalRoot","document","getElementById","createElement","setAttribute","body","insertBefore","firstChild","e","componentDidMount","direct_dom_return","root_id","props","portalElem","className","appendChild","setState","componentWillUnmount","removeChild","render","_this$props","children","_objectWithoutProperties","_excluded","state","createPortal"],"sources":["../../../../src/components/modal/ModalRoot.tsx"],"sourcesContent":["import React from 'react'\nimport ReactDOM from 'react-dom'\nimport { warn, isTrue } from '../../shared/component-helper'\nimport ModalContent from './ModalContent'\nimport { ModalContentProps, ReactChildType } from './types'\n\ndeclare global {\n interface Window {\n __modalRoot: HTMLElement\n }\n}\n\nexport interface ModalRootProps extends ModalContentProps {\n /**\n * The id used internal in the modal/drawer root element. Defaults to `root`, so the element id will be `dnb-modal-root`.\n */\n id?: string\n root_id?: string\n direct_dom_return?: boolean\n\n /**\n * The content which will appear when triggering the modal/drawer.\n */\n children?: ReactChildType\n}\n\ninterface ModalRootState {\n isMounted: boolean\n}\n\nexport default class ModalRoot extends React.PureComponent<\n ModalRootProps,\n ModalRootState\n> {\n portalElem: HTMLDivElement | null\n static defaultProps = {\n id: null,\n root_id: 'root',\n direct_dom_return: false,\n children: null,\n }\n\n state = {\n isMounted: false,\n }\n\n static insertModalRoot(id) {\n if (typeof window === 'undefined') {\n return false\n }\n\n try {\n id = `dnb-modal-${id || 'root'}`\n window.__modalRoot = document.getElementById(id)\n if (!window.__modalRoot) {\n window.__modalRoot = document.createElement('div')\n window.__modalRoot.setAttribute('id', id)\n document.body.insertBefore(\n window.__modalRoot,\n document.body.firstChild\n )\n }\n } catch (e) {\n warn('Modal: Could not insert dnb-modal-root', e)\n }\n\n return window.__modalRoot\n }\n\n componentDidMount() {\n const { direct_dom_return = false, root_id = 'root' } = this.props\n if (!isTrue(direct_dom_return)) {\n ModalRoot.insertModalRoot(root_id)\n\n try {\n if (!this.portalElem) {\n this.portalElem = document.createElement('div')\n this.portalElem.className = 'dnb-modal-root__inner'\n }\n if (\n this.portalElem &&\n typeof window !== 'undefined' &&\n window.__modalRoot\n ) {\n window.__modalRoot.appendChild(this.portalElem)\n }\n } catch (e) {\n warn(e)\n }\n this.setState({ isMounted: true })\n }\n }\n\n componentWillUnmount() {\n try {\n if (\n this.portalElem &&\n typeof window !== 'undefined' &&\n window.__modalRoot &&\n window.__modalRoot.removeChild\n ) {\n window.__modalRoot.removeChild(this.portalElem)\n this.portalElem = null\n }\n } catch (e) {\n warn(e)\n }\n }\n\n render() {\n const { children, direct_dom_return, ...props } = this.props\n\n if (isTrue(direct_dom_return)) {\n return <ModalContent {...props}>{children}</ModalContent>\n }\n\n if (\n this.portalElem &&\n typeof window !== 'undefined' &&\n window.__modalRoot &&\n this.state.isMounted\n ) {\n return ReactDOM.createPortal(\n <ModalContent {...props}>{children}</ModalContent>,\n this.portalElem\n )\n }\n\n return null\n }\n}\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,QAAQ,MAAM,WAAW;AAChC,SAASC,IAAI,EAAEC,MAAM,QAAQ,+BAA+B;AAC5D,OAAOC,YAAY,MAAM,gBAAgB;AA2BzC,eAAe,MAAMC,SAAS,SAASL,KAAK,CAACM,aAAa,CAGxD;EAAAC,YAAA;IAAA,SAAAC,SAAA;IAAAC,eAAA;IAAAA,eAAA,gBASQ;MACNC,SAAS,EAAE;IACb,CAAC;EAAA;EAED,OAAOC,eAAeA,CAACC,EAAE,EAAE;IACzB,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;MACjC,OAAO,KAAK;IACd;IAEA,IAAI;MACFD,EAAE,GAAI,aAAYA,EAAE,IAAI,MAAO,EAAC;MAChCC,MAAM,CAACC,WAAW,GAAGC,QAAQ,CAACC,cAAc,CAACJ,EAAE,CAAC;MAChD,IAAI,CAACC,MAAM,CAACC,WAAW,EAAE;QACvBD,MAAM,CAACC,WAAW,GAAGC,QAAQ,CAACE,aAAa,CAAC,KAAK,CAAC;QAClDJ,MAAM,CAACC,WAAW,CAACI,YAAY,CAAC,IAAI,EAAEN,EAAE,CAAC;QACzCG,QAAQ,CAACI,IAAI,CAACC,YAAY,CACxBP,MAAM,CAACC,WAAW,EAClBC,QAAQ,CAACI,IAAI,CAACE,UAChB,CAAC;MACH;IACF,CAAC,CAAC,OAAOC,CAAC,EAAE;MACVpB,IAAI,CAAC,wCAAwC,EAAEoB,CAAC,CAAC;IACnD;IAEA,OAAO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A;MAAPR,KAAK,GAAAU,wBAAA,CAAAF,WAAA,EAAAG,SAAA;IAE7C,IAAIlC,MAAM,CAACqB,iBAAiB,CAAC,EAAE;MAC7B,OAAOxB,KAAA,CAAAiB,aAAA,CAACb,YAAY,EAAKsB,KAAK,EAAGS,QAAuB,CAAC;IAC3D;IAEA,IACE,IAAI,CAACR,UAAU,IACf,OAAOd,MAAM,KAAK,WAAW,IAC7BA,MAAM,CAACC,WAAW,IAClB,IAAI,CAACwB,KAAK,CAAC5B,SAAS,EACpB;MACA,OAAOT,QAAQ,CAACsC,YAAY,CAC1BvC,KAAA,CAAAiB,aAAA,CAACb,YAAY,EAAKsB,KAAK,EAAGS,QAAuB,CAAC,EAClD,IAAI,CAACR,UACP,CAAC;IACH;IAEA,OAAO,IAAI;EACb;AACF;AAAClB,eAAA,CApGoBJ,SAAS,kBAKN;EACpBO,EAAE,EAAE,IAAI;EACRa,OAAO,EAAE,MAAM;EACfD,iBAAiB,EAAE,KAAK;EACxBW,QAAQ,EAAE;AACZ,CAAC"}
1
+ {"version":3,"file":"ModalRoot.js","names":["React","ReactDOM","warn","isTrue","ModalContent","ModalRoot","PureComponent","constructor","arguments","_defineProperty","isMounted","insertModalRoot","id","window","__modalRoot","document","getElementById","createElement","setAttribute","body","insertBefore","firstChild","e","componentDidMount","direct_dom_return","root_id","props","portalElem","className","appendChild","setState","componentWillUnmount","removeChild","render","_this$props","children","_objectWithoutProperties","_excluded","state","createPortal"],"sources":["../../../../src/components/modal/ModalRoot.tsx"],"sourcesContent":["import React from 'react'\nimport ReactDOM from 'react-dom'\nimport { warn, isTrue } from '../../shared/component-helper'\nimport ModalContent from './ModalContent'\nimport { ModalContentProps, ReactChildType } from './types'\n\ndeclare global {\n interface Window {\n __modalRoot: HTMLElement\n }\n}\n\nexport interface ModalRootProps extends ModalContentProps {\n /**\n * The id used internal in the modal/drawer root element. Defaults to `root`, so the element id will be `dnb-modal-root`.\n */\n id?: string\n root_id?: string\n direct_dom_return?: boolean\n\n /**\n * The content which will appear when triggering the modal/drawer.\n */\n children?: ReactChildType\n\n /** For internal use only */\n modalContentCloseRef?: React.RefObject<any>\n}\n\ninterface ModalRootState {\n isMounted: boolean\n}\n\nexport default class ModalRoot extends React.PureComponent<\n ModalRootProps,\n ModalRootState\n> {\n portalElem: HTMLDivElement | null\n static defaultProps = {\n id: null,\n root_id: 'root',\n direct_dom_return: false,\n children: null,\n }\n\n state = {\n isMounted: false,\n }\n\n static insertModalRoot(id) {\n if (typeof window === 'undefined') {\n return false\n }\n\n try {\n id = `dnb-modal-${id || 'root'}`\n window.__modalRoot = document.getElementById(id)\n if (!window.__modalRoot) {\n window.__modalRoot = document.createElement('div')\n window.__modalRoot.setAttribute('id', id)\n document.body.insertBefore(\n window.__modalRoot,\n document.body.firstChild\n )\n }\n } catch (e) {\n warn('Modal: Could not insert dnb-modal-root', e)\n }\n\n return window.__modalRoot\n }\n\n componentDidMount() {\n const { direct_dom_return = false, root_id = 'root' } = this.props\n if (!isTrue(direct_dom_return)) {\n ModalRoot.insertModalRoot(root_id)\n\n try {\n if (!this.portalElem) {\n this.portalElem = document.createElement('div')\n this.portalElem.className = 'dnb-modal-root__inner'\n }\n if (\n this.portalElem &&\n typeof window !== 'undefined' &&\n window.__modalRoot\n ) {\n window.__modalRoot.appendChild(this.portalElem)\n }\n } catch (e) {\n warn(e)\n }\n this.setState({ isMounted: true })\n }\n }\n\n componentWillUnmount() {\n try {\n if (\n this.portalElem &&\n typeof window !== 'undefined' &&\n window.__modalRoot &&\n window.__modalRoot.removeChild\n ) {\n window.__modalRoot.removeChild(this.portalElem)\n this.portalElem = null\n }\n } catch (e) {\n warn(e)\n }\n }\n\n render() {\n const { children, direct_dom_return, ...props } = this.props\n\n if (isTrue(direct_dom_return)) {\n return <ModalContent {...props}>{children}</ModalContent>\n }\n\n if (\n this.portalElem &&\n typeof window !== 'undefined' &&\n window.__modalRoot &&\n this.state.isMounted\n ) {\n return ReactDOM.createPortal(\n <ModalContent {...props}>{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MAAM,KAAK,WAAW,IAC7BA,MAAM,CAACC,WAAW,IAClB,IAAI,CAACwB,KAAK,CAAC5B,SAAS,EACpB;MACA,OAAOT,QAAQ,CAACsC,YAAY,CAC1BvC,KAAA,CAAAiB,aAAA,CAACb,YAAY,EAAKsB,KAAK,EAAGS,QAAuB,CAAC,EAClD,IAAI,CAACR,UACP,CAAC;IACH;IAEA,OAAO,IAAI;EACb;AACF;AAAClB,eAAA,CApGoBJ,SAAS,kBAKN;EACpBO,EAAE,EAAE,IAAI;EACRa,OAAO,EAAE,MAAM;EACfD,iBAAiB,EAAE,KAAK;EACxBW,QAAQ,EAAE;AACZ,CAAC"}
@@ -11,6 +11,12 @@ export type ModalTriggerVariant = 'primary' | 'secondary' | 'tertiary' | 'signal
11
11
  export type ModalTriggerIconPosition = 'left' | 'right';
12
12
  export type ModalContentMinWidth = string | number;
13
13
  export type ModalContentMaxWidth = string | number;
14
+ export type TriggeredBy = 'handler' | 'button' | 'overlay' | 'keyboard' | 'unmount';
15
+ export type CloseHandlerParams = {
16
+ triggeredBy: TriggeredBy;
17
+ triggeredByEvent?: Event;
18
+ };
19
+ export type CloseHandler = (params?: CloseHandlerParams) => void;
14
20
  export interface ModalProps extends ModalRootProps {
15
21
  /**
16
22
  * The id used internal in the modal/drawer root element. Defaults to `root`, so the element id will be `dnb-modal-root`.
@@ -69,16 +75,16 @@ export interface ModalProps extends ModalRootProps {
69
75
  id?: string;
70
76
  event?: Event;
71
77
  triggeredBy?: string;
72
- close?: (...args: any[]) => any;
78
+ close?: CloseHandler;
73
79
  }) => void;
74
80
  /**
75
81
  * Set a function to call the callback function, once the modal/drawer should open: `open_modal={(open) => open()}`
76
82
  */
77
- open_modal?: (open?: (e: Event) => void, elem?: any) => () => void | void;
83
+ open_modal?: (open?: (e: Event) => void, instance?: any) => () => void | void;
78
84
  /**
79
85
  * Set a function to call the callback function, once the modal/drawer should close: `close_modal={(close) => close()}`
80
86
  */
81
- close_modal?: (close?: (...args: any[]) => void, elem?: any) => () => void | void;
87
+ close_modal?: (close?: CloseHandler, instance?: any) => () => void | void;
82
88
  /**
83
89
  * Provide a custom trigger component. Like trigger={<Anchor href="/" />}. It will set the focus on it when the modal/drawer gets closed.
84
90
  */
@@ -238,5 +244,7 @@ export interface ModalContentProps {
238
244
  dialog_role?: 'dialog' | 'alertdialog' | 'region';
239
245
  content_ref?: React.RefObject<HTMLElement>;
240
246
  scroll_ref?: React.RefObject<HTMLElement>;
247
+ open_state?: ModalOpenState;
248
+ modalContentCloseRef?: React.MutableRefObject<any>;
241
249
  }
242
250
  export type TriggerAttributes = ButtonProps;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../src/components/modal/types.ts"],"sourcesContent":["import * as React from 'react'\nimport type { CloseButtonProps } from './parts/CloseButton'\nimport type { ButtonProps } from '../button/Button'\nimport type { ModalRootProps } from './ModalRoot'\n\nexport type ReactChildType = React.ReactNode | ((...args: any[]) => any)\n\nexport type ModalFullscreen = 'auto' | boolean\nexport type ModalAlignContent = 'left' | 'center' | 'centered' | 'right'\nexport type ModalContainerPlacement = 'left' | 'right' | 'top' | 'bottom'\nexport type ModalOpenState = 'opened' | 'closed' | boolean\nexport type ModalTriggerVariant =\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'signal'\nexport type ModalTriggerIconPosition = 'left' | 'right'\nexport type ModalContentMinWidth = string | number\nexport type ModalContentMaxWidth = string | number\n\nexport interface ModalProps extends ModalRootProps {\n /**\n * The id used internal in the modal/drawer root element. Defaults to `root`, so the element id will be `dnb-modal-root`.\n */\n id?: string\n\n /**\n * Will disable the trigger button.\n */\n disabled?: boolean\n\n /**\n * Forces the modal/drawer to delay the opening. The delay is given in `ms`.\n */\n open_delay?: string | number\n\n /**\n * If set to `true` (boolean or string), then the user can&#39;t close the modal/drawer.\n */\n prevent_close?: boolean\n\n /**\n * Duration of animation open/close in ms. Defaults to 300ms.\n */\n animation_duration?: string | number\n\n /**\n * If set to `true`, no open/close animation will be shown. Defaults to false.\n */\n no_animation?: boolean\n\n /**\n * Use this prop to control the open/close state by setting either: `opened` / `closed` or `true` / `false`.\n */\n open_state?: ModalOpenState\n\n /**\n * The content which will appear when triggering the modal/drawer.\n */\n children?: ReactChildType\n\n /**\n * Omits default showing trigger button\n */\n omit_trigger_button?: boolean\n\n /**\n * This event gets triggered once the modal shows up. Returns the modal id: `{ id }`.\n */\n on_open?: ({ id }: { id?: string }) => void\n\n /**\n * This event gets triggered once the modal gets closed. Returns the modal id: `{ id, event, triggeredBy }`.\n */\n on_close?: ({\n id,\n event,\n triggeredBy,\n }: {\n id?: string\n event?: Event\n triggeredBy?: string\n }) => void\n\n /**\n * This event gets triggered once the user tries to close the modal, but `prevent_close` is set to \"true\". Returns a callback `close` you can call to trigger the close mechanism. More details below. Returns the modal id: `{ id, event, close: Method, triggeredBy }`\n */\n on_close_prevent?: ({\n id,\n event,\n triggeredBy,\n close,\n }: {\n id?: string\n event?: Event\n triggeredBy?: string\n close?: (...args: any[]) => any\n }) => void\n\n /**\n * Set a function to call the callback function, once the modal/drawer should open: `open_modal={(open) => open()}`\n */\n open_modal?: (open?: (e: Event) => void, elem?: any) => () => void | void\n\n /**\n * Set a function to call the callback function, once the modal/drawer should close: `close_modal={(close) => close()}`\n */\n close_modal?: (\n close?: (...args: any[]) => void,\n elem?: any\n ) => () => void | void\n\n /**\n * Provide a custom trigger component. Like trigger={<Anchor href=\"/\" />}. It will set the focus on it when the modal/drawer gets closed.\n */\n trigger?: ReactChildType\n\n /**\n * Send along custom HTML attributes or properties to the trigger button.\n */\n trigger_attributes?: TriggerAttributes\n\n /**\n * The content which will appear when triggering the modal/drawer.\n */\n modal_content?: ReactChildType\n\n /**\n * If true, the drawer will not open in a new DOM but directly in current DOM. Defaults to `false`.\n */\n direct_dom_return?: boolean\n\n /**\n * To get the inner content Element, pass in your own React ref\n */\n content_ref?: React.RefObject<HTMLElement>\n\n /**\n * To get the scroll Element, pass in your own React ref\n */\n scroll_ref?: React.RefObject<HTMLElement>\n}\n\nexport interface ModalContentProps {\n /**\n * The content which will appear when triggering the modal/drawer.\n */\n modal_content?: ReactChildType\n\n /**\n * The content which will appear in the bar, above the header, and side-by-side the close button.\n */\n bar_content?: ReactChildType\n\n /**\n * The content which will appear in the header of the modal/drawer the modal/drawer.\n */\n header_content?: ReactChildType\n hide?: boolean\n\n /**\n * The id used internal for the trigger button and modal component.\n */\n id?: string\n\n /**\n * The id used internal in the modal/drawer root element. Defaults to `root`, so the element id will be `dnb-modal-root`.\n */\n root_id?: string\n\n /**\n * The ID of the trigger component, describing the modal/drawer content. Defaults to the internal `trigger`, so make sure you define the trigger title.\n */\n labelled_by?: string\n\n /**\n * The Modal handles the first focus – automatically. How ever, you can defined a custom focus selector the will be used instead `focus_selector=\".css-selector\"`.\n */\n focus_selector?: string\n\n /**\n * Defines an unique identifier to a modal. Use it in case you have to refer in some way to the modal/drawer content wrapper.\n */\n content_id?: string\n\n /**\n * The modal/drawer title. Displays on the very top of the content.\n */\n title?: React.ReactNode\n\n /**\n * The aria label of the dialog when no labelled_by and no title is given. Defaults to `Vindu`.\n */\n dialog_title?: string\n\n /**\n * If boolean, the close button will not be shown.\n */\n hide_close_button?: boolean\n\n /**\n * Define any valid Eufemia Button property or HTML attribute inside an object.\n */\n close_button_attributes?: CloseButtonProps\n\n /**\n * If set to `false` then the modal/drawer content will be shown without any spacing. Defaults to `true`.\n */\n spacing?: boolean\n\n /**\n * By default the modal/drawer content gets added the core style class `dnb-core-style`. Use `false` to disable this behavior.\n */\n prevent_core_style?: boolean\n animation_duration?: string | number\n\n /**\n * Disable clicking the background overlay to close the modal\n */\n prevent_overlay_close?: boolean\n\n /**\n * If set to `true`, no open/close animation will be shown. Defaults to false.\n */\n no_animation?: boolean\n\n /**\n * Same as `no_animation`, but gets triggered only if the viewport width is less than `40em`. Defaults to false.\n */\n no_animation_on_mobile?: boolean\n\n /**\n * The minimum Modal content width, defined by a CSS width value like `50vw` (50% of the viewport). Be careful on using fixed `min_width` so you don&#39;t break responsiveness. Defaults to `30rem` (average width is set to `60vw`).\n */\n min_width?: ModalContentMinWidth\n\n /**\n * The maximum Modal content width, defined by a CSS width value like `20rem`. Defaults to `60rem` (average width is set to `60vw`).\n */\n max_width?: ModalContentMaxWidth\n\n /**\n * If set to `true` then the modal/drawer content will be shown as fullscreen, without showing the original content behind. Can be set to `false` to omit the auto fullscreen. Defaults to `auto`.\n */\n fullscreen?: ModalFullscreen\n\n /**\n * Define the inner horizontal alignment of the content. Can be set to `left`, `center`, `right` and `centered`. If `centered`, then the content will also be centered vertically. Defaults to `left`.\n */\n align_content?: 'right' | 'left' | 'centered' | 'center'\n\n /**\n * For `drawer` mode only. Defines the placement on what side the Drawer should be opened. Can be set to `left`, `right`, `top` and `bottom`. Defaults to `right`.\n */\n container_placement?: 'left' | 'right' | 'top' | 'bottom'\n\n /**\n * Define the vertical alignment of the container. Can be set to `top` or `center`. Defaults to `center`.\n */\n vertical_alignment?: 'top' | 'center'\n\n /**\n * Give the content wrapper a custom class name (maps to `dnb-modal__content`).\n */\n content_class?: string\n\n /**\n * @deprecated – use className instead. Will be removed in v11.\n */\n class?: string\n\n /**\n * Give the page overlay a custom class name (maps to `dnb-modal__overlay`).\n */\n overlay_class?: string\n\n /**\n * Define an array with HTML class selectors (`['.element-selector']`) which should not get invalidated when the modal opens/closes. Use this in order to let some parts of your site still be accessible by screen readers.\n */\n bypass_invalidation_selectors?: Array<string>\n\n /**\n * For internal usage\n * Will close the modal\n */\n close?: (...args: any[]) => any\n\n /**\n * Give the inner Dialog or Drawer component a className (only works with mode)\n */\n className?: string\n\n /**\n * The content which will appear when triggering the modal/drawer.\n */\n children?: ReactChildType\n\n /**\n * The displayed text for the 'close' button. Defaults to `Lukk`.\n */\n close_title?: string\n\n /**\n * Internal\n */\n dialog_role?: 'dialog' | 'alertdialog' | 'region'\n content_ref?: React.RefObject<HTMLElement>\n scroll_ref?: React.RefObject<HTMLElement>\n}\n\nexport type TriggerAttributes = ButtonProps\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/components/modal/types.ts"],"sourcesContent":["import * as React from 'react'\nimport type { CloseButtonProps } from './parts/CloseButton'\nimport type { ButtonProps } from '../button/Button'\nimport type { ModalRootProps } from './ModalRoot'\n\nexport type ReactChildType = React.ReactNode | ((...args: any[]) => any)\n\nexport type ModalFullscreen = 'auto' | boolean\nexport type ModalAlignContent = 'left' | 'center' | 'centered' | 'right'\nexport type ModalContainerPlacement = 'left' | 'right' | 'top' | 'bottom'\nexport type ModalOpenState = 'opened' | 'closed' | boolean\nexport type ModalTriggerVariant =\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'signal'\nexport type ModalTriggerIconPosition = 'left' | 'right'\nexport type ModalContentMinWidth = string | number\nexport type ModalContentMaxWidth = string | number\n\nexport type TriggeredBy =\n | 'handler'\n | 'button'\n | 'overlay'\n | 'keyboard'\n | 'unmount'\nexport type CloseHandlerParams = {\n triggeredBy: TriggeredBy\n triggeredByEvent?: Event\n}\nexport type CloseHandler = (params?: CloseHandlerParams) => void\n\nexport interface ModalProps extends ModalRootProps {\n /**\n * The id used internal in the modal/drawer root element. Defaults to `root`, so the element id will be `dnb-modal-root`.\n */\n id?: string\n\n /**\n * Will disable the trigger button.\n */\n disabled?: boolean\n\n /**\n * Forces the modal/drawer to delay the opening. The delay is given in `ms`.\n */\n open_delay?: string | number\n\n /**\n * If set to `true` (boolean or string), then the user can&#39;t close the modal/drawer.\n */\n prevent_close?: boolean\n\n /**\n * Duration of animation open/close in ms. Defaults to 300ms.\n */\n animation_duration?: string | number\n\n /**\n * If set to `true`, no open/close animation will be shown. Defaults to false.\n */\n no_animation?: boolean\n\n /**\n * Use this prop to control the open/close state by setting either: `opened` / `closed` or `true` / `false`.\n */\n open_state?: ModalOpenState\n\n /**\n * The content which will appear when triggering the modal/drawer.\n */\n children?: ReactChildType\n\n /**\n * Omits default showing trigger button\n */\n omit_trigger_button?: boolean\n\n /**\n * This event gets triggered once the modal shows up. Returns the modal id: `{ id }`.\n */\n on_open?: ({ id }: { id?: string }) => void\n\n /**\n * This event gets triggered once the modal gets closed. Returns the modal id: `{ id, event, triggeredBy }`.\n */\n on_close?: ({\n id,\n event,\n triggeredBy,\n }: {\n id?: string\n event?: Event\n triggeredBy?: string\n }) => void\n\n /**\n * This event gets triggered once the user tries to close the modal, but `prevent_close` is set to \"true\". Returns a callback `close` you can call to trigger the close mechanism. More details below. Returns the modal id: `{ id, event, close: Method, triggeredBy }`\n */\n on_close_prevent?: ({\n id,\n event,\n triggeredBy,\n close,\n }: {\n id?: string\n event?: Event\n triggeredBy?: string\n close?: CloseHandler\n }) => void\n\n /**\n * Set a function to call the callback function, once the modal/drawer should open: `open_modal={(open) => open()}`\n */\n open_modal?: (\n open?: (e: Event) => void,\n instance?: any\n ) => () => void | void\n\n /**\n * Set a function to call the callback function, once the modal/drawer should close: `close_modal={(close) => close()}`\n */\n close_modal?: (close?: CloseHandler, instance?: any) => () => void | void\n\n /**\n * Provide a custom trigger component. Like trigger={<Anchor href=\"/\" />}. It will set the focus on it when the modal/drawer gets closed.\n */\n trigger?: ReactChildType\n\n /**\n * Send along custom HTML attributes or properties to the trigger button.\n */\n trigger_attributes?: TriggerAttributes\n\n /**\n * The content which will appear when triggering the modal/drawer.\n */\n modal_content?: ReactChildType\n\n /**\n * If true, the drawer will not open in a new DOM but directly in current DOM. Defaults to `false`.\n */\n direct_dom_return?: boolean\n\n /**\n * To get the inner content Element, pass in your own React ref\n */\n content_ref?: React.RefObject<HTMLElement>\n\n /**\n * To get the scroll Element, pass in your own React ref\n */\n scroll_ref?: React.RefObject<HTMLElement>\n}\n\nexport interface ModalContentProps {\n /**\n * The content which will appear when triggering the modal/drawer.\n */\n modal_content?: ReactChildType\n\n /**\n * The content which will appear in the bar, above the header, and side-by-side the close button.\n */\n bar_content?: ReactChildType\n\n /**\n * The content which will appear in the header of the modal/drawer the modal/drawer.\n */\n header_content?: ReactChildType\n hide?: boolean\n\n /**\n * The id used internal for the trigger button and modal component.\n */\n id?: string\n\n /**\n * The id used internal in the modal/drawer root element. Defaults to `root`, so the element id will be `dnb-modal-root`.\n */\n root_id?: string\n\n /**\n * The ID of the trigger component, describing the modal/drawer content. Defaults to the internal `trigger`, so make sure you define the trigger title.\n */\n labelled_by?: string\n\n /**\n * The Modal handles the first focus – automatically. How ever, you can defined a custom focus selector the will be used instead `focus_selector=\".css-selector\"`.\n */\n focus_selector?: string\n\n /**\n * Defines an unique identifier to a modal. Use it in case you have to refer in some way to the modal/drawer content wrapper.\n */\n content_id?: string\n\n /**\n * The modal/drawer title. Displays on the very top of the content.\n */\n title?: React.ReactNode\n\n /**\n * The aria label of the dialog when no labelled_by and no title is given. Defaults to `Vindu`.\n */\n dialog_title?: string\n\n /**\n * If boolean, the close button will not be shown.\n */\n hide_close_button?: boolean\n\n /**\n * Define any valid Eufemia Button property or HTML attribute inside an object.\n */\n close_button_attributes?: CloseButtonProps\n\n /**\n * If set to `false` then the modal/drawer content will be shown without any spacing. Defaults to `true`.\n */\n spacing?: boolean\n\n /**\n * By default the modal/drawer content gets added the core style class `dnb-core-style`. Use `false` to disable this behavior.\n */\n prevent_core_style?: boolean\n animation_duration?: string | number\n\n /**\n * Disable clicking the background overlay to close the modal\n */\n prevent_overlay_close?: boolean\n\n /**\n * If set to `true`, no open/close animation will be shown. Defaults to false.\n */\n no_animation?: boolean\n\n /**\n * Same as `no_animation`, but gets triggered only if the viewport width is less than `40em`. Defaults to false.\n */\n no_animation_on_mobile?: boolean\n\n /**\n * The minimum Modal content width, defined by a CSS width value like `50vw` (50% of the viewport). Be careful on using fixed `min_width` so you don&#39;t break responsiveness. Defaults to `30rem` (average width is set to `60vw`).\n */\n min_width?: ModalContentMinWidth\n\n /**\n * The maximum Modal content width, defined by a CSS width value like `20rem`. Defaults to `60rem` (average width is set to `60vw`).\n */\n max_width?: ModalContentMaxWidth\n\n /**\n * If set to `true` then the modal/drawer content will be shown as fullscreen, without showing the original content behind. Can be set to `false` to omit the auto fullscreen. Defaults to `auto`.\n */\n fullscreen?: ModalFullscreen\n\n /**\n * Define the inner horizontal alignment of the content. Can be set to `left`, `center`, `right` and `centered`. If `centered`, then the content will also be centered vertically. Defaults to `left`.\n */\n align_content?: 'right' | 'left' | 'centered' | 'center'\n\n /**\n * For `drawer` mode only. Defines the placement on what side the Drawer should be opened. Can be set to `left`, `right`, `top` and `bottom`. Defaults to `right`.\n */\n container_placement?: 'left' | 'right' | 'top' | 'bottom'\n\n /**\n * Define the vertical alignment of the container. Can be set to `top` or `center`. Defaults to `center`.\n */\n vertical_alignment?: 'top' | 'center'\n\n /**\n * Give the content wrapper a custom class name (maps to `dnb-modal__content`).\n */\n content_class?: string\n\n /**\n * @deprecated – use className instead. Will be removed in v11.\n */\n class?: string\n\n /**\n * Give the page overlay a custom class name (maps to `dnb-modal__overlay`).\n */\n overlay_class?: string\n\n /**\n * Define an array with HTML class selectors (`['.element-selector']`) which should not get invalidated when the modal opens/closes. Use this in order to let some parts of your site still be accessible by screen readers.\n */\n bypass_invalidation_selectors?: Array<string>\n\n /**\n * For internal usage\n * Will close the modal\n */\n close?: (...args: any[]) => any\n\n /**\n * Give the inner Dialog or Drawer component a className (only works with mode)\n */\n className?: string\n\n /**\n * The content which will appear when triggering the modal/drawer.\n */\n children?: ReactChildType\n\n /**\n * The displayed text for the 'close' button. Defaults to `Lukk`.\n */\n close_title?: string\n\n /**\n * Internal\n */\n dialog_role?: 'dialog' | 'alertdialog' | 'region'\n content_ref?: React.RefObject<HTMLElement>\n scroll_ref?: React.RefObject<HTMLElement>\n open_state?: ModalOpenState\n modalContentCloseRef?: React.MutableRefObject<any>\n}\n\nexport type TriggerAttributes = ButtonProps\n"],"mappings":""}
@@ -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,EACN;EACrB,MAAMG,OAAO,GAAGZ,KAAK,CAACa,UAAU,CAACX,OAAO,CAAC;EAGzC,MAAMY,KAAK,GAAGV,sBAAsB,CAClCK,UAAU,EACVH,YAAY,EACZM,OAAO,CAACJ,OACV,CAAC;EAED,MAAM;MACJO,OAAO;MACPC,QAAQ,GAAG,CAACF,KAAK,CAACG,MAAM;MACxBA,MAAM;MACNC,aAAa;MACbC,SAAS;MACTC,eAAe;MACfC,UAAU;MACVC,OAAO;MACPC,QAAQ;MAERC,SAAS;MACTC,QAAQ;MAERC,OAAO;MACPC,UAAU;MACVC;IAGF,CAAC,GAAGd,KAAK;IADJe,UAAU,GAAAC,wBAAA,CACXhB,KAAK,EAAAiB,SAAA;EAET,MAAMC,WAAW,GAAGhC,KAAK,CAACiC,MAAM,CAAc,CAAC;EAC/C,MAAM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AC;AACJ;AAEA,SAASgB,QAAQA,CAACD,KAAa,EAAE;EAC/B,IAAIA,KAAK,CAACG,QAAQ,CAAC,IAAI,CAAC,EAAE;IACxB,OAAOH,KAAK;EACd;EACA,OAAOA,KAAK,GACR,CAAC,OAAO,CAACI,IAAI,CAACJ,KAAK,CAAC,GACjB,eAAcA,KAAM,GAAE,GACvBA,KAAK,GACPK,SAAS;AACf;AAEA,SAASN,YAAYA,CACnBO,QAAoD,EACpDC,IAAY,EACZC,aAAoD,EACpD;EACA,IAAIC,KAAK,GAAGH,QAAmC;EAE/C,IAAIG,KAAK,KAAK,IAAI,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC/CA,KAAK,GAAG;MACNC,KAAK,EAAEJ,QAAQ;MACfK,MAAM,EAAEL,QAAQ;MAChBM,KAAK,EAAEN;IACT,CAA4B;EAC9B;EAEA,MAAMO,MAAM,GAAG,CAAC,CAAC;EAEjB,KAAK,MAAMC,IAAI,IAAIL,KAAK,EAA6B;IAAA,IAAAM,MAAA;IACnD,IAAI,SAAAA,MAAA,GAAON,KAAK,cAAAM,MAAA,uBAALA,MAAA,CAAQD,IAAI,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,EACZM,OAAO,CAACJ,OACV,CAAC;EAED,MAAM;MACJO,OAAO;MACPC,QAAQ,GAAG,CAACF,KAAK,CAACG,MAAM;MACxBA,MAAM;MACNC,aAAa;MACbC,SAAS;MACTC,eAAe;MACfC,UAAU;MACVC,OAAO;MACPC,QAAQ;MAERC,SAAS;MACTC,QAAQ;MAERC,OAAO;MACPC,UAAU;MACVC;IAGF,CAAC,GAAGd,KAAK;IADJe,UAAU,GAAAC,wBAAA,CACXhB,KAAK,EAAAiB,SAAA;EAET,MAAMC,WAAW,GAAGhC,KAAK,CAACiC,MAAM,CAAc,CAAC;EAC/C,MAAMC,UAAU,GAAGX,QAAQ,IAAIK,SAAS,IAAII,WAAW;EAEvD,OAAOG,MAAM,CAACC,MAAM,CAAAC,aAAA,CAAAA,aAAA,KACfR,UAAU;IACbL,SAAS,EAAEvB,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AK;EACd;EACA,OAAOA,KAAK,GACR,CAAC,OAAO,CAACI,IAAI,CAACJ,KAAK,CAAC,GACjB,eAAcA,KAAM,GAAE,GACvBA,KAAK,GACPK,SAAS;AACf;AAEA,SAASN,YAAYA,CACnBO,QAAoD,EACpDC,IAAY,EACZC,aAAoD,EACpD;EACA,IAAIC,KAAK,GAAGH,QAAmC;EAE/C,IAAIG,KAAK,KAAK,IAAI,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC/CA,KAAK,GAAG;MACNC,KAAK,EAAEJ,QAAQ;MACfK,MAAM,EAAEL,QAAQ;MAChBM,KAAK,EAAEN;IACT,CAA4B;EAC9B;EAEA,MAAMO,MAAM,GAAG,CAAC,CAAC;EAEjB,KAAK,MAAMC,IAAI,IAAIL,KAAK,EAA6B;IAAA,IAAAM,MAAA;IACnD,IAAI,SAAAA,MAAA,GAAON,KAAK,cAAAM,MAAA,uBAALA,MAAA,CAAQD,IAAI,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"}
@@ -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,OAAO,MAAMC,YAAY,GAAG;EAC1BC,QAAQ,EAAE,IAAI;EACdC,sBAAsB,EAAE;AAC1B,CAAC;AAED,MAAMC,GAAG,GAAIC,UAAmC,IAAK;EAAA,IAAAC,oBAAA;EAEnD,MAAMC,OAAO,GAAGhB,KAAK,CAACiB,UAAU,CAACb,OAAO,CAAC;EACzC,MAAMc,eAAe,GAAGlB,KAAK,CAACiB,UAAU,CAACT,eAAe,CAAC;EAGzD,MAAMW,QAAQ,GAAGb,sBAAsB,CACrCQ,UAAU,EACVJ,YAAY,EACZM,OAAO,aAAPA,OAAO,wBAAAD,oBAAA,GAAPC,OAAO,CAAEI,WAAW,cAAAL,oBAAA,uBAApBA,oBAAA,CAAsBF,GAAG,EACzBG,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEH,GAAG,EACZK,eACF,CAAC;EAED,MAAAG,qBAAA,GAYIC,wBAAwB,CAACH,QAAQ,CAAC;IAZhC;MACJI,SAAS;MACTZ,QAAQ;MACRa,QAAQ;MACRC,IAAI;M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AAS,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,oBAAoB,QAAQ,wBAAwB;AA6E7D,OAAO,MAAMC,YAAY,GAAG;EAC1BC,QAAQ,EAAE,IAAI;EACdC,sBAAsB,EAAE;AAC1B,CAAC;AAED,MAAMC,GAAG,GACPC,UAAkE,IAC/D;EAAA,IAAAC,oBAAA;EAEH,MAAMC,OAAO,GAAGhB,KAAK,CAACiB,UAAU,CAACb,OAAO,CAAC;EACzC,MAAMc,eAAe,GAAGlB,KAAK,CAACiB,UAAU,CAACT,eAAe,CAAC;EAGzD,MAAMW,QAAQ,GAAGb,sBAAsB,CACrCQ,UAAU,EACVJ,YAAY,EACZM,OAAO,aAAPA,OAAO,wBAAAD,oBAAA,GAAPC,OAAO,CAAEI,WAAW,cAAAL,oBAAA,uBAApBA,oBAAA,CAAsBF,GAAG,EACzBG,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEH,GAAG,EACZK,eACF,CAAC;EAED,MAAAG,qBAAA,GAYIC,wBAAwB,CAACH,QAAQ,CAAC;IAZhC;MACJI,SAAS;MACTZ,QAAQ;MACRa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AC,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 & 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 ...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,QAAQ,cAAc;AA6B9C,OAAO,MAAMC,YAAY,GAAG;EAC1BC,KAAK,EAAE,IAAI;EACXC,SAAS,EAAE,IAAI;EACfC,QAAQ,EAAE,IAAI;EACdC,QAAQ,EAAE;AACZ,CAAC;AAED,MAAMC,QAAQ,GAAIC,UAAwC,IAAK;EAE7D,MAAMC,OAAO,GAAGd,KAAK,CAACe,UAAU,CAACV,OAAO,CAAC;EAEzC,MAAAW,qBAAA,GAKIZ,sBAAsB,CAACS,UAAU,EAAEN,YAAY,EAAEO,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEF,QAAQ,EAAE;MACtED,QAAQ,EAAEG,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEH;IACrB,CAAC,CAAC;IAPI;MACJH,KAAK;MACLC,SAAS;MACTC,QAAQ,EAAEO;IAEZ,CAAC,GAAAD,qBAAA;IADIE,KAAK,GAAAC,wBAAA,CAAAH,qBAAA,EAAAI,SAAA;EAKV,IAAIV,QAAQ,GAAGO,YAAY;EAE3B,IAAII,KAAK,CAACC,OAAO,CAACL,YAAY,CAAC,EAAE;IAC/BP,QAAQ,GAAG,CAAC,GAAGO,YAAY,CAAC,CAACM,GAAG,CAAEC,KAAK,IAAK;MAC1C,OAAOA,KAAK;IACd,CAAC,CAAC;EACJ;EAEA,MAAMC,cAAc,GAAGvB,oBAAoB,CAACgB,KAAK,CAAC;EAClD,MAAAQ,qBAAA,GAGIvB,qBAAqB,CAAC,CAAC,CAAC,EAAEe,KAAK,CAAC;IAH9B;MACJP;IAEF,CAAC,GAAAe,qBAAA;IADIC,UAAU,GAAAR,wBAAA,CAAAO,qBAAA,EAAAE,UAAA;EAGf,OACE5B,KAAA,CAAA6B,aAAA,CAACvB,eAAe,CAACwB,QAAQ;IAACC,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"}
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,OA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,aAAA,CAACvB,eAAe,CAACwB,QAAQ;IAACC,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"}
@@ -22,6 +22,10 @@
22
22
  color: inherit;
23
23
 
24
24
  border-radius: 0.1875em;
25
+
26
+ & .dnb-anchor {
27
+ font-size: inherit;
28
+ }
25
29
  }
26
30
 
27
31
  @mixin preStyle() {
@@ -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;AAgE/D,OAAO,MAAMC,YAAY,GAAG;EAC1BC,IAAI,EAAE,QAAQ;EACdC,OAAO,EAAE,SAAS;EAClBC,QAAQ,EAAE;AACZ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BAA2B,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"}
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,OAAOC,OAAO,MAAM,sBAAsB;AAG1C,SACEC,qBAAqB,EACrBC,sBAAsB,EACtBC,IAAI,QACC,+BAA+B;AAGtC,OAAOC,WAAW,IAAIC,kBAAkB,QAAQ,eAAe;AAiE/D,OAAO,MAAMC,YAAY,GAAG;EAC1BC,IAAI,EAAE,QAAQ;EACdC,OAAO,EAAE,SAAS;EAClBC,QAAQ,EAAE;AACZ,CAAC;AAED,MAAMC,MAAM,GAAIC,UAAsC,IAAK;EAEzD,MAAMC,OAAO,GAAGjB,KAAK,CAACkB,UAAU,CAACb,OAAO,CAAC;EACzC,MAAMc,kBAAkB,GAAGnB,KAAK,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;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;AAgD1C,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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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":";;;;;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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 & SpacingProps\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;AAsDtC,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,UAAU,CAAChB,OAAO,CAAC;EAGzC,MAAMiB,QAAQ,GAAGf,sBAAsB,CACrCY,UAAU,EACVV,YAAY,EACZW,OAAO,aAAPA,OAAO,uBAAPA,OAA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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"}
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,UAAU,CAAChB,OAAO,CAAC;EAGzC,MAAMiB,QAAQ,GAAGf,sBAAsB,CACrCY,UAAU,EACVV,YAAY,EACZW,OAAO,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,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"}
@@ -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;
@@ -36,6 +36,7 @@ declare class Modal extends React.PureComponent<ModalPropTypes & ToCamelCasePart
36
36
  _tryToOpenTimeout: NodeJS.Timeout;
37
37
  activeElement: Element;
38
38
  isInTransition: boolean;
39
+ modalContentCloseRef: React.RefObject<any>;
39
40
  state: {
40
41
  hide: boolean;
41
42
  modalActive: boolean;
@@ -97,7 +98,7 @@ declare class Modal extends React.PureComponent<ModalPropTypes & ToCamelCasePart
97
98
  open: (e: Event) => void;
98
99
  close: (event: Event, { ifIsLatest, triggeredBy }?: {
99
100
  ifIsLatest: boolean;
100
- triggeredBy?: any;
101
+ triggeredBy?: string;
101
102
  }) => void;
102
103
  removeActiveState(): void;
103
104
  /**
@@ -3,7 +3,7 @@
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
5
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
6
- const _excluded = ["root_id", "content_id", "disabled", "labelled_by", "focus_selector", "header_content", "bar_content", "bypass_invalidation_selectors", "vertical_alignment", "id", "open_state", "open_delay", "omit_trigger_button", "trigger", "trigger_attributes"];
6
+ const _excluded = ["root_id", "content_id", "disabled", "labelled_by", "focus_selector", "header_content", "bar_content", "bypass_invalidation_selectors", "vertical_alignment", "id", "open_delay", "omit_trigger_button", "trigger", "trigger_attributes"];
7
7
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
8
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
9
  import React from 'react';
@@ -71,6 +71,7 @@ class Modal extends React.PureComponent {
71
71
  _defineProperty(this, "_tryToOpenTimeout", void 0);
72
72
  _defineProperty(this, "activeElement", void 0);
73
73
  _defineProperty(this, "isInTransition", void 0);
74
+ _defineProperty(this, "modalContentCloseRef", void 0);
74
75
  _defineProperty(this, "state", {
75
76
  hide: false,
76
77
  modalActive: false,
@@ -193,10 +194,14 @@ class Modal extends React.PureComponent {
193
194
  });
194
195
  _defineProperty(this, "close", (event, {
195
196
  ifIsLatest,
196
- triggeredBy = null
197
+ triggeredBy = 'handler'
197
198
  } = {
198
199
  ifIsLatest: true
199
200
  }) => {
201
+ var _this$modalContentClo, _this$modalContentClo2;
202
+ (_this$modalContentClo = (_this$modalContentClo2 = this.modalContentCloseRef).current) === null || _this$modalContentClo === void 0 ? void 0 : _this$modalContentClo.call(_this$modalContentClo2, event, {
203
+ triggeredBy
204
+ });
200
205
  const {
201
206
  prevent_close = false
202
207
  } = this.props;
@@ -225,6 +230,7 @@ class Modal extends React.PureComponent {
225
230
  });
226
231
  this._id = props.id || makeUniqueId('modal-');
227
232
  this._triggerRef = React.createRef();
233
+ this.modalContentCloseRef = React.createRef();
228
234
  this._onUnmount = [];
229
235
  }
230
236
  componentDidMount() {
@@ -301,7 +307,6 @@ class Modal extends React.PureComponent {
301
307
  bypass_invalidation_selectors = null,
302
308
  vertical_alignment = 'center',
303
309
  id,
304
- open_state,
305
310
  open_delay,
306
311
  omit_trigger_button = false,
307
312
  trigger = null,
@@ -354,7 +359,8 @@ class Modal extends React.PureComponent {
354
359
  bypass_invalidation_selectors: bypass_invalidation_selectors,
355
360
  close: this.close,
356
361
  hide: hide,
357
- title: rest.title || fallbackTitle
362
+ title: rest.title || fallbackTitle,
363
+ modalContentCloseRef: this.modalContentCloseRef
358
364
  })));
359
365
  };
360
366
  return React.createElement(SuffixContext.Consumer, null, render);