@helsenorge/designsystem-react 10.0.2 → 10.2.0

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 (181) hide show
  1. package/AnchorLink.js +2 -2
  2. package/AnchorLink.js.map +1 -1
  3. package/Avatar.js +2 -2
  4. package/Avatar.js.map +1 -1
  5. package/Badge.js +3 -3
  6. package/Badge.js.map +1 -1
  7. package/Button.js +4 -4
  8. package/Button.js.map +1 -1
  9. package/CHANGELOG.md +38 -0
  10. package/Checkbox.js +2 -2
  11. package/Checkbox.js.map +1 -1
  12. package/Close.js +2 -2
  13. package/Close.js.map +1 -1
  14. package/ErrorBoundary.js +2 -2
  15. package/ErrorBoundary.js.map +1 -1
  16. package/Expander.js +2 -2
  17. package/Expander.js.map +1 -1
  18. package/FormGroup.js +12 -12
  19. package/FormGroup.js.map +1 -1
  20. package/FormLayout.js +3 -3
  21. package/FormLayout.js.map +1 -1
  22. package/HelpBubble.js +2 -2
  23. package/HelpBubble.js.map +1 -1
  24. package/HighlightPanel.js +2 -2
  25. package/HighlightPanel.js.map +1 -1
  26. package/Icon.js +3 -3
  27. package/Icon.js.map +1 -1
  28. package/Illustration.js +3 -3
  29. package/Illustration.js.map +1 -1
  30. package/Input.js +2 -2
  31. package/Input.js.map +1 -1
  32. package/Label.js +8 -8
  33. package/Label.js.map +1 -1
  34. package/LazyIcon.js +1 -1
  35. package/LazyIllustration.js +3 -3
  36. package/LazyIllustration.js.map +1 -1
  37. package/LinkList.js +6 -6
  38. package/LinkList.js.map +1 -1
  39. package/ListHeader.js +7 -7
  40. package/ListHeader.js.map +1 -1
  41. package/Panel.js +2 -2
  42. package/Panel.js.map +1 -1
  43. package/PopOver.js +2 -2
  44. package/PopOver.js.map +1 -1
  45. package/RadioButton.js +2 -2
  46. package/RadioButton.js.map +1 -1
  47. package/Select.js +2 -2
  48. package/Select.js.map +1 -1
  49. package/Slider.js +3 -3
  50. package/Slider.js.map +1 -1
  51. package/Spacer.js +2 -2
  52. package/Spacer.js.map +1 -1
  53. package/StatusDot.js +1 -1
  54. package/StepButtons.js +4 -4
  55. package/StepButtons.js.map +1 -1
  56. package/TabList.js +4 -4
  57. package/TabList.js.map +1 -1
  58. package/Table.js +2 -2
  59. package/Table.js.map +1 -1
  60. package/TableBody.js +2 -2
  61. package/TableBody.js.map +1 -1
  62. package/TableExpandedRow.js +2 -2
  63. package/TableExpandedRow.js.map +1 -1
  64. package/TableHead.js +2 -2
  65. package/TableHead.js.map +1 -1
  66. package/TableRow.js +2 -2
  67. package/TableRow.js.map +1 -1
  68. package/Textarea.js +2 -2
  69. package/Textarea.js.map +1 -1
  70. package/Title.js +2 -2
  71. package/Title.js.map +1 -1
  72. package/TooltipWord.js +2 -2
  73. package/TooltipWord.js.map +1 -1
  74. package/Trigger.js +3 -3
  75. package/Trigger.js.map +1 -1
  76. package/components/Button/styles.module.scss +5 -0
  77. package/components/DictionaryTrigger/index.js +2 -2
  78. package/components/DictionaryTrigger/index.js.map +1 -1
  79. package/components/Drawer/Drawer.d.ts +41 -0
  80. package/components/Drawer/Drawer.test.d.ts +1 -0
  81. package/components/Drawer/index.d.ts +3 -0
  82. package/components/Drawer/index.js +350 -0
  83. package/components/Drawer/index.js.map +1 -0
  84. package/components/Drawer/styles.module.scss +127 -0
  85. package/components/Drawer/styles.module.scss.d.ts +16 -0
  86. package/components/Dropdown/index.js +3 -3
  87. package/components/Dropdown/index.js.map +1 -1
  88. package/components/Duolist/index.js +4 -4
  89. package/components/Duolist/index.js.map +1 -1
  90. package/components/ExpanderHierarchy/index.js +5 -5
  91. package/components/ExpanderHierarchy/index.js.map +1 -1
  92. package/components/ExpanderList/index.js +8 -8
  93. package/components/ExpanderList/index.js.map +1 -1
  94. package/components/HelpQuestion/index.js +2 -2
  95. package/components/HelpQuestion/index.js.map +1 -1
  96. package/components/HighlightPanel/styles.module.scss +4 -36
  97. package/components/HighlightPanel/styles.module.scss.d.ts +1 -2
  98. package/components/Icons/EuropeanHealthCard.js +1 -1
  99. package/components/Icons/GroupTwins.js +1 -1
  100. package/components/Icons/Inbox.js +1 -1
  101. package/components/Icons/LawBook.js +1 -1
  102. package/components/Icons/PersonCancel.js +1 -1
  103. package/components/Icons/PersonWithBrain.js +1 -1
  104. package/components/Icons/Puzzle.js +1 -1
  105. package/components/Icons/Snapchat.js +1 -1
  106. package/components/Illustrations/IllustrationNames.d.ts +1 -1
  107. package/components/Illustrations/IllustrationNames.js +4 -2
  108. package/components/Illustrations/IllustrationNames.js.map +1 -1
  109. package/components/Illustrations/ReadLetters.d.ts +9 -0
  110. package/components/Illustrations/ReadLetters.js +11 -0
  111. package/components/Illustrations/ReadLetters.js.map +1 -0
  112. package/components/Illustrations/ReadLettersMedium.d.ts +4 -0
  113. package/components/Illustrations/ReadLettersMedium.js +110 -0
  114. package/components/Illustrations/ReadLettersMedium.js.map +1 -0
  115. package/components/Illustrations/Support2.d.ts +9 -0
  116. package/components/Illustrations/Support2.js +11 -0
  117. package/components/Illustrations/Support2.js.map +1 -0
  118. package/components/Illustrations/Support2Medium.d.ts +4 -0
  119. package/components/Illustrations/Support2Medium.js +232 -0
  120. package/components/Illustrations/Support2Medium.js.map +1 -0
  121. package/components/Label/styles.module.scss +16 -12
  122. package/components/Label/styles.module.scss.d.ts +3 -1
  123. package/components/List/styles.module.scss +7 -7
  124. package/components/Modal/index.js +71 -82
  125. package/components/Modal/index.js.map +1 -1
  126. package/components/Modal/styles.module.scss +12 -6
  127. package/components/NotificationPanel/index.js +3 -3
  128. package/components/NotificationPanel/index.js.map +1 -1
  129. package/components/PanelList/index.js +5 -5
  130. package/components/PanelList/index.js.map +1 -1
  131. package/components/PopMenu/index.js +5 -5
  132. package/components/PopMenu/index.js.map +1 -1
  133. package/components/Portal/index.js +3 -3
  134. package/components/Portal/index.js.map +1 -1
  135. package/components/PromoPanel/index.js +2 -2
  136. package/components/PromoPanel/index.js.map +1 -1
  137. package/components/StickyNote/index.js +12 -6
  138. package/components/StickyNote/index.js.map +1 -1
  139. package/components/Tabs/Tabs.d.ts +2 -0
  140. package/components/Tabs/index.js +8 -4
  141. package/components/Tabs/index.js.map +1 -1
  142. package/components/TagList/index.js +2 -2
  143. package/components/TagList/index.js.map +1 -1
  144. package/components/Tile/index.js +6 -6
  145. package/components/Tile/index.js.map +1 -1
  146. package/components/Toggle/index.js +3 -3910
  147. package/components/Toggle/index.js.map +1 -1
  148. package/components/Tooltip/index.js +2 -2
  149. package/components/Tooltip/index.js.map +1 -1
  150. package/components/Validation/index.js +6 -6
  151. package/components/Validation/index.js.map +1 -1
  152. package/constants.d.ts +1 -0
  153. package/constants.js +1 -0
  154. package/constants.js.map +1 -1
  155. package/hoc/withBreakpoint/withBreakpoint.js +2 -2
  156. package/hoc/withBreakpoint/withBreakpoint.js.map +1 -1
  157. package/hooks/useBreakpoint.d.ts +0 -4
  158. package/hooks/useBreakpoint.js +23 -18
  159. package/hooks/useBreakpoint.js.map +1 -1
  160. package/hooks/useEventListenerState.js +3 -3
  161. package/hooks/useEventListenerState.js.map +1 -1
  162. package/hooks/useOutsideEvent.d.ts +4 -4
  163. package/hooks/useOutsideEvent.js +5 -4
  164. package/hooks/useOutsideEvent.js.map +1 -1
  165. package/hooks/useReturnFocusOnUnmount.d.ts +5 -0
  166. package/hooks/useReturnFocusOnUnmount.js +20 -0
  167. package/hooks/useReturnFocusOnUnmount.js.map +1 -0
  168. package/package.json +1 -1
  169. package/scss/_breakpoints.scss +6 -0
  170. package/scss/_font-mixins.scss +55 -0
  171. package/scss/typography.module.scss +24 -0
  172. package/scss/typography.module.scss.d.ts +6 -0
  173. package/scss/typography.stories.tsx +24 -0
  174. package/theme/index.js +2 -2
  175. package/use-animate.js +3952 -0
  176. package/use-animate.js.map +1 -0
  177. package/utils/accessibility.d.ts +1 -0
  178. package/utils/accessibility.js +6 -1
  179. package/utils/accessibility.js.map +1 -1
  180. package/utils/component.js +4 -4
  181. package/utils/component.js.map +1 -1
@@ -1,5 +1,5 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import React, { useRef, useContext, useEffect, useState } from "react";
2
+ import React__default, { useRef, useContext, useEffect, useState } from "react";
3
3
  import { T as TooltipWord } from "../../TooltipWord.js";
4
4
  import { useDelayedState } from "../../hooks/useDelayedState.js";
5
5
  import { useUuid } from "../../hooks/useUuid.js";
@@ -75,7 +75,7 @@ const Tooltip = ({ children, description, testId }) => {
75
75
  /* @__PURE__ */ jsx(HelpBubble, { helpBubbleId, controllerRef: wordRef, role: "tooltip", showBubble: showTooltip || keepOpen, children: description })
76
76
  ] });
77
77
  };
78
- const TooltipOpenContext = React.createContext({
78
+ const TooltipOpenContext = React__default.createContext({
79
79
  currentTooltip: void 0
80
80
  });
81
81
  const TooltipOpenProvider = ({ children }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import React, { useContext, useState, useEffect, useRef } from 'react';\n\nimport TooltipWord from './TooltipWord';\nimport { useDelayedState } from '../../hooks/useDelayedState';\nimport { useUuid } from '../../hooks/useUuid';\nimport HelpBubble from '../HelpBubble';\n\nconst HOVER_DELAY_MS = 200;\n\nexport interface TooltipProps {\n /** Ordet som skal ha en tilhørende tooltip */\n children: string;\n /** Teksten som skal vises i tooltip */\n description: React.ReactNode;\n /** Valgfri test-id */\n testId?: string;\n}\n\nexport const Tooltip: React.FC<TooltipProps> = ({ children, description, testId }) => {\n const helpBubbleId = useUuid();\n const wordRef = useRef<HTMLButtonElement>(null);\n const { currentTooltip, setCurrentTooltip } = useContext(TooltipOpenContext);\n const [{ showTooltip, keepOpen }, setShowTooltipDelayed, setShowTooltip] = useDelayedState(\n { showTooltip: false, keepOpen: false },\n HOVER_DELAY_MS\n );\n\n useEffect(() => {\n if (!setCurrentTooltip) {\n return;\n }\n if (showTooltip) {\n setCurrentTooltip(helpBubbleId);\n } else {\n setCurrentTooltip(undefined);\n }\n }, [showTooltip]);\n\n useEffect(() => {\n if (currentTooltip !== helpBubbleId && typeof currentTooltip !== 'undefined') {\n setShowTooltip(prevState => ({ showTooltip: false, keepOpen: prevState.keepOpen }));\n }\n }, [currentTooltip]);\n\n const handleDocumentClick = (): void => {\n if (!showTooltip) {\n setShowTooltip({ showTooltip: false, keepOpen: false });\n }\n };\n\n useEffect(() => {\n document.addEventListener('mouseup', handleDocumentClick);\n return (): void => {\n document.removeEventListener('mouseup', handleDocumentClick);\n };\n }, []);\n\n const handleTooltipClick = (): void => {\n setShowTooltip(prevState => ({ showTooltip: !prevState.showTooltip, keepOpen: !prevState.keepOpen }));\n };\n\n const handleFocus = (): void => {\n if (!currentTooltip) {\n setShowTooltipDelayed(prevState => ({ showTooltip: true, keepOpen: prevState.keepOpen }));\n }\n };\n\n const handleBlur = (): void => {\n setShowTooltip(prevState => ({ showTooltip: false, keepOpen: prevState.keepOpen }));\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLSpanElement>): void => {\n if (e.key === 'Enter') {\n setShowTooltip(prevState => ({ showTooltip: !prevState.showTooltip, keepOpen: !prevState.keepOpen }));\n }\n if (e.key === 'Escape') {\n setShowTooltip({ showTooltip: false, keepOpen: false });\n }\n };\n\n return (\n <>\n <TooltipWord\n ref={wordRef}\n onClick={handleTooltipClick}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n ariaDescribedById={helpBubbleId}\n testId={testId}\n >\n {children}\n </TooltipWord>\n <HelpBubble helpBubbleId={helpBubbleId} controllerRef={wordRef} role=\"tooltip\" showBubble={showTooltip || keepOpen}>\n {description}\n </HelpBubble>\n </>\n );\n};\n\nexport type TooltipContext = {\n currentTooltip?: string;\n setCurrentTooltip?: (id?: string) => void;\n};\n\nconst TooltipOpenContext = React.createContext<TooltipContext>({\n currentTooltip: undefined,\n});\n\ninterface TooltipOpenProviderProps {\n children?: React.ReactNode;\n}\n\nexport const TooltipOpenProvider: React.FC<TooltipOpenProviderProps> = ({ children }) => {\n const [currentTooltip, setCurrentTooltip] = useState<string>();\n\n return <TooltipOpenContext.Provider value={{ currentTooltip, setCurrentTooltip }}>{children}</TooltipOpenContext.Provider>;\n};\n\nexport default Tooltip;\n"],"names":[],"mappings":";;;;;;AAOA,MAAM,iBAAiB;AAWhB,MAAM,UAAkC,CAAC,EAAE,UAAU,aAAa,aAAa;AACpF,QAAM,eAAe,QAAQ;AACvB,QAAA,UAAU,OAA0B,IAAI;AAC9C,QAAM,EAAE,gBAAgB,sBAAsB,WAAW,kBAAkB;AAC3E,QAAM,CAAC,EAAE,aAAa,SAAY,GAAA,uBAAuB,cAAc,IAAI;AAAA,IACzE,EAAE,aAAa,OAAO,UAAU,MAAM;AAAA,IACtC;AAAA,EACF;AAEA,YAAU,MAAM;AACd,QAAI,CAAC,mBAAmB;AACtB;AAAA,IAAA;AAEF,QAAI,aAAa;AACf,wBAAkB,YAAY;AAAA,IAAA,OACzB;AACL,wBAAkB,MAAS;AAAA,IAAA;AAAA,EAC7B,GACC,CAAC,WAAW,CAAC;AAEhB,YAAU,MAAM;AACd,QAAI,mBAAmB,gBAAgB,OAAO,mBAAmB,aAAa;AAC5E,qBAAe,gBAAc,EAAE,aAAa,OAAO,UAAU,UAAU,WAAW;AAAA,IAAA;AAAA,EACpF,GACC,CAAC,cAAc,CAAC;AAEnB,QAAM,sBAAsB,MAAY;AACtC,QAAI,CAAC,aAAa;AAChB,qBAAe,EAAE,aAAa,OAAO,UAAU,OAAO;AAAA,IAAA;AAAA,EAE1D;AAEA,YAAU,MAAM;AACL,aAAA,iBAAiB,WAAW,mBAAmB;AACxD,WAAO,MAAY;AACR,eAAA,oBAAoB,WAAW,mBAAmB;AAAA,IAC7D;AAAA,EACF,GAAG,EAAE;AAEL,QAAM,qBAAqB,MAAY;AACtB,mBAAA,CAAA,eAAc,EAAE,aAAa,CAAC,UAAU,aAAa,UAAU,CAAC,UAAU,SAAW,EAAA;AAAA,EACtG;AAEA,QAAM,cAAc,MAAY;AAC9B,QAAI,CAAC,gBAAgB;AACnB,4BAAsB,gBAAc,EAAE,aAAa,MAAM,UAAU,UAAU,WAAW;AAAA,IAAA;AAAA,EAE5F;AAEA,QAAM,aAAa,MAAY;AAC7B,mBAAe,gBAAc,EAAE,aAAa,OAAO,UAAU,UAAU,WAAW;AAAA,EACpF;AAEM,QAAA,gBAAgB,CAAC,MAAkD;AACnE,QAAA,EAAE,QAAQ,SAAS;AACN,qBAAA,CAAA,eAAc,EAAE,aAAa,CAAC,UAAU,aAAa,UAAU,CAAC,UAAU,SAAW,EAAA;AAAA,IAAA;AAElG,QAAA,EAAE,QAAQ,UAAU;AACtB,qBAAe,EAAE,aAAa,OAAO,UAAU,OAAO;AAAA,IAAA;AAAA,EAE1D;AAEA,SAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAK;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,WAAW;AAAA,QACX,mBAAmB;AAAA,QACnB;AAAA,QAEC;AAAA,MAAA;AAAA,IACH;AAAA,IACA,oBAAC,YAAW,EAAA,cAA4B,eAAe,SAAS,MAAK,WAAU,YAAY,eAAe,UACvG,UACH,YAAA,CAAA;AAAA,EAAA,GACF;AAEJ;AAOA,MAAM,qBAAqB,MAAM,cAA8B;AAAA,EAC7D,gBAAgB;AAClB,CAAC;AAMM,MAAM,sBAA0D,CAAC,EAAE,eAAe;AACvF,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAiB;AAEtD,SAAA,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,EAAE,gBAAgB,qBAAsB,UAAS;AAC9F;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import React, { useContext, useState, useEffect, useRef } from 'react';\n\nimport TooltipWord from './TooltipWord';\nimport { useDelayedState } from '../../hooks/useDelayedState';\nimport { useUuid } from '../../hooks/useUuid';\nimport HelpBubble from '../HelpBubble';\n\nconst HOVER_DELAY_MS = 200;\n\nexport interface TooltipProps {\n /** Ordet som skal ha en tilhørende tooltip */\n children: string;\n /** Teksten som skal vises i tooltip */\n description: React.ReactNode;\n /** Valgfri test-id */\n testId?: string;\n}\n\nexport const Tooltip: React.FC<TooltipProps> = ({ children, description, testId }) => {\n const helpBubbleId = useUuid();\n const wordRef = useRef<HTMLButtonElement>(null);\n const { currentTooltip, setCurrentTooltip } = useContext(TooltipOpenContext);\n const [{ showTooltip, keepOpen }, setShowTooltipDelayed, setShowTooltip] = useDelayedState(\n { showTooltip: false, keepOpen: false },\n HOVER_DELAY_MS\n );\n\n useEffect(() => {\n if (!setCurrentTooltip) {\n return;\n }\n if (showTooltip) {\n setCurrentTooltip(helpBubbleId);\n } else {\n setCurrentTooltip(undefined);\n }\n }, [showTooltip]);\n\n useEffect(() => {\n if (currentTooltip !== helpBubbleId && typeof currentTooltip !== 'undefined') {\n setShowTooltip(prevState => ({ showTooltip: false, keepOpen: prevState.keepOpen }));\n }\n }, [currentTooltip]);\n\n const handleDocumentClick = (): void => {\n if (!showTooltip) {\n setShowTooltip({ showTooltip: false, keepOpen: false });\n }\n };\n\n useEffect(() => {\n document.addEventListener('mouseup', handleDocumentClick);\n return (): void => {\n document.removeEventListener('mouseup', handleDocumentClick);\n };\n }, []);\n\n const handleTooltipClick = (): void => {\n setShowTooltip(prevState => ({ showTooltip: !prevState.showTooltip, keepOpen: !prevState.keepOpen }));\n };\n\n const handleFocus = (): void => {\n if (!currentTooltip) {\n setShowTooltipDelayed(prevState => ({ showTooltip: true, keepOpen: prevState.keepOpen }));\n }\n };\n\n const handleBlur = (): void => {\n setShowTooltip(prevState => ({ showTooltip: false, keepOpen: prevState.keepOpen }));\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLSpanElement>): void => {\n if (e.key === 'Enter') {\n setShowTooltip(prevState => ({ showTooltip: !prevState.showTooltip, keepOpen: !prevState.keepOpen }));\n }\n if (e.key === 'Escape') {\n setShowTooltip({ showTooltip: false, keepOpen: false });\n }\n };\n\n return (\n <>\n <TooltipWord\n ref={wordRef}\n onClick={handleTooltipClick}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n ariaDescribedById={helpBubbleId}\n testId={testId}\n >\n {children}\n </TooltipWord>\n <HelpBubble helpBubbleId={helpBubbleId} controllerRef={wordRef} role=\"tooltip\" showBubble={showTooltip || keepOpen}>\n {description}\n </HelpBubble>\n </>\n );\n};\n\nexport type TooltipContext = {\n currentTooltip?: string;\n setCurrentTooltip?: (id?: string) => void;\n};\n\nconst TooltipOpenContext = React.createContext<TooltipContext>({\n currentTooltip: undefined,\n});\n\ninterface TooltipOpenProviderProps {\n children?: React.ReactNode;\n}\n\nexport const TooltipOpenProvider: React.FC<TooltipOpenProviderProps> = ({ children }) => {\n const [currentTooltip, setCurrentTooltip] = useState<string>();\n\n return <TooltipOpenContext.Provider value={{ currentTooltip, setCurrentTooltip }}>{children}</TooltipOpenContext.Provider>;\n};\n\nexport default Tooltip;\n"],"names":["React"],"mappings":";;;;;;AAOA,MAAM,iBAAiB;AAWhB,MAAM,UAAkC,CAAC,EAAE,UAAU,aAAa,aAAa;AACpF,QAAM,eAAe,QAAQ;AACvB,QAAA,UAAU,OAA0B,IAAI;AAC9C,QAAM,EAAE,gBAAgB,sBAAsB,WAAW,kBAAkB;AAC3E,QAAM,CAAC,EAAE,aAAa,SAAY,GAAA,uBAAuB,cAAc,IAAI;AAAA,IACzE,EAAE,aAAa,OAAO,UAAU,MAAM;AAAA,IACtC;AAAA,EACF;AAEA,YAAU,MAAM;AACd,QAAI,CAAC,mBAAmB;AACtB;AAAA,IAAA;AAEF,QAAI,aAAa;AACf,wBAAkB,YAAY;AAAA,IAAA,OACzB;AACL,wBAAkB,MAAS;AAAA,IAAA;AAAA,EAC7B,GACC,CAAC,WAAW,CAAC;AAEhB,YAAU,MAAM;AACd,QAAI,mBAAmB,gBAAgB,OAAO,mBAAmB,aAAa;AAC5E,qBAAe,g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AAS,MAAK,WAAU,YAAY,eAAe,UACvG,UACH,YAAA,CAAA;AAAA,EAAA,GACF;AAEJ;AAOA,MAAM,qBAAqBA,eAAM,cAA8B;AAAA,EAC7D,gBAAgB;AAClB,CAAC;AAMM,MAAM,sBAA0D,CAAC,EAAE,eAAe;AACvF,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAiB;AAEtD,SAAA,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,EAAE,gBAAgB,qBAAsB,UAAS;AAC9F;"}
@@ -1,5 +1,5 @@
1
1
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import React from "react";
2
+ import React__default from "react";
3
3
  import classNames from "classnames";
4
4
  import { A as AnchorLink } from "../../AnchorLink.js";
5
5
  import { L as List } from "../../List.js";
@@ -50,10 +50,10 @@ const ValidationSummary = (props) => {
50
50
  }
51
51
  );
52
52
  };
53
- const Validation = React.forwardRef((props, ref) => {
53
+ const Validation = React__default.forwardRef((props, ref) => {
54
54
  const validationErrorClass = styles["validation__error-wrapper"];
55
55
  const cloneFormElement = (child) => {
56
- return React.cloneElement(child, {
56
+ return React__default.cloneElement(child, {
57
57
  ...child.props,
58
58
  errorWrapperClassName: validationErrorClass
59
59
  });
@@ -62,15 +62,15 @@ const Validation = React.forwardRef((props, ref) => {
62
62
  if (isComponent(child, FormGroup) || isComponent(child, Checkbox) || isComponent(child, RadioButton) || isComponent(child, Textarea) || isComponent(child, Input) || isComponent(child, Select) || isComponent(child, Slider) || isComponentWithDisplayName(child, "DateTimePickerWrapper") || isComponentWithDisplayName(child, "DatePicker") || isComponentWithDisplayName(child, "DateTime")) {
63
63
  return cloneFormElement(child);
64
64
  }
65
- if (React.isValidElement(child) && child.type === React.Fragment) {
66
- return React.Children.map(child.props.children, (child2) => {
65
+ if (React__default.isValidElement(child) && child.type === React__default.Fragment) {
66
+ return React__default.Children.map(child.props.children, (child2) => {
67
67
  return renderChild(child2);
68
68
  });
69
69
  }
70
70
  return child;
71
71
  };
72
72
  return /* @__PURE__ */ jsxs(Fragment, { children: [
73
- /* @__PURE__ */ jsx("div", { "data-testid": props.testId, "data-analyticsid": AnalyticsId.Validation, className: props.className, ref, children: React.Children.map(props.children, (child) => renderChild(child)) }),
73
+ /* @__PURE__ */ jsx("div", { "data-testid": props.testId, "data-analyticsid": AnalyticsId.Validation, className: props.className, ref, children: React__default.Children.map(props.children, (child) => renderChild(child)) }),
74
74
  /* @__PURE__ */ jsx(ValidationSummary, { errorTitle: props.errorTitle, errors: props.errors })
75
75
  ] });
76
76
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Validation/ErrorListItem.tsx","../../../src/components/Validation/ErrorList.tsx","../../../src/components/Validation/ValidationSummary.tsx","../../../src/components/Validation/Validation.tsx"],"sourcesContent":["import React from 'react';\n\nimport { ErrorDetails, FocusableElement } from './types';\nimport AnchorLink, { AnchorLinkOnClickEvent } from '../AnchorLink';\n\ninterface ErrorElementProps {\n name: string;\n error: ErrorDetails;\n}\n\nconst ErrorListItem: React.FC<ErrorElementProps> = props => {\n const handleClick = (event?: AnchorLinkOnClickEvent, element?: FocusableElement): void => {\n event?.preventDefault();\n element?.focus && element?.focus();\n };\n\n if (props.error.ref) {\n return (\n <AnchorLink href={`#${props.name}`} onClick={(e): void => handleClick(e, props.error.ref)}>\n {props.error.message}\n </AnchorLink>\n );\n }\n\n return <>{props.error.message}</>;\n};\n\nexport default ErrorListItem;\n","import React from 'react';\n\nimport ErrorListItem from './ErrorListItem';\nimport { ValidationErrors } from './types';\nimport List from '../List';\n\ninterface ErrorListProps {\n errors: ValidationErrors;\n}\n\nconst ErrorList: React.FC<ErrorListProps> = props => (\n <List>\n {Object.entries(props.errors).map(([name, error]) => (\n <List.Item key={name}>\n <ErrorListItem name={name} error={error} />\n </List.Item>\n ))}\n </List>\n);\n\nexport default ErrorList;\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport ErrorList from './ErrorList';\nimport { ValidationErrors } from './types';\nimport { useUuid } from '../../hooks/useUuid';\nimport Title, { TitleTags } from '../Title';\n\nimport styles from './styles.module.scss';\n\ninterface ValidationSummaryProps {\n /** Error summary title */\n errorTitle?: string;\n /** Error list */\n errors?: ValidationErrors;\n /** Markup props for error summary title. Default: h2 */\n errorTitleHtmlMarkup?: TitleTags;\n /** Will be shown last */\n children?: React.ReactNode;\n}\n\nconst ValidationSummary: React.FC<ValidationSummaryProps> = props => {\n const { errorTitleHtmlMarkup = 'h2' } = props;\n const titleId = useUuid();\n\n const hasErrors = !!props.errors && Object.entries(props.errors).length > 0;\n\n const summaryClasses = classNames(styles['validation__summary'], hasErrors && styles['validation__summary--visible']);\n\n return (\n <div\n role={'status'}\n aria-atomic={'true'}\n aria-live={'polite'}\n aria-relevant={'all'}\n aria-labelledby={hasErrors && props.errorTitle ? titleId : undefined}\n className={summaryClasses}\n >\n {hasErrors && (\n <>\n {props.errorTitle && (\n <Title appearance=\"title4\" id={titleId} htmlMarkup={errorTitleHtmlMarkup} margin={{ marginTop: 0, marginBottom: 1 }}>\n {props.errorTitle}\n </Title>\n )}\n <ErrorList errors={props.errors!} />\n </>\n )}\n {props.children}\n </div>\n );\n};\n\nexport default ValidationSummary;\n","import React from 'react';\n\nimport { ValidationErrors } from './types';\nimport ValidationSummary from './ValidationSummary';\nimport { AnalyticsId, FormSize } from '../../constants';\nimport { isComponent, isComponentWithDisplayName } from '../../utils/component';\nimport Checkbox, { CheckboxProps } from '../Checkbox';\nimport { ErrorWrapperClassNameProps } from '../ErrorWrapper';\nimport FormGroup, { FormGroupProps } from '../FormGroup/FormGroup';\nimport Input, { InputProps } from '../Input';\nimport RadioButton, { RadioButtonProps } from '../RadioButton';\nimport Select, { SelectProps } from '../Select';\nimport Slider, { SliderProps } from '../Slider';\nimport Textarea, { TextareaProps } from '../Textarea';\n\nimport styles from './styles.module.scss';\n\ninterface ValidationProps {\n /** Error summary title */\n errorTitle?: string;\n /** Validation errors. If errors include references to HTML elements, the errors will be rendered as links with an onClick handler to focus the element. */\n errors?: ValidationErrors;\n /** Items in the Validation compontent */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Validation = React.forwardRef((props: ValidationProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const validationErrorClass = styles['validation__error-wrapper'];\n\n const cloneFormElement = <T extends ErrorWrapperClassNameProps>(child: React.ReactElement<T>): React.ReactElement<T> => {\n return React.cloneElement(child, {\n ...child.props,\n errorWrapperClassName: validationErrorClass,\n });\n };\n\n const renderChild = (child: React.ReactNode): React.ReactNode => {\n if (\n isComponent<FormGroupProps>(child, FormGroup) ||\n isComponent<CheckboxProps>(child, Checkbox) ||\n isComponent<RadioButtonProps>(child, RadioButton) ||\n isComponent<TextareaProps>(child, Textarea) ||\n isComponent<InputProps>(child, Input) ||\n isComponent<SelectProps>(child, Select) ||\n isComponent<SliderProps>(child, Slider) ||\n isComponentWithDisplayName<ErrorWrapperClassNameProps>(child, 'DateTimePickerWrapper') ||\n isComponentWithDisplayName<ErrorWrapperClassNameProps>(child, 'DatePicker') ||\n isComponentWithDisplayName<ErrorWrapperClassNameProps>(child, 'DateTime')\n ) {\n return cloneFormElement<ErrorWrapperClassNameProps>(child);\n }\n if (React.isValidElement(child) && child.type === React.Fragment) {\n return React.Children.map(child.props.children, (child: React.ReactNode) => {\n return renderChild(child);\n });\n }\n\n return child;\n };\n\n return (\n <>\n <div data-testid={props.testId} data-analyticsid={AnalyticsId.Validation} className={props.className} ref={ref}>\n {React.Children.map(props.children, (child: React.ReactNode) => renderChild(child))}\n </div>\n <ValidationSummary errorTitle={props.errorTitle} errors={props.errors} />\n </>\n );\n});\n\nValidation.displayName = 'Validation';\n\nexport default Validation;\n"],"names":["child"],"mappings":";;;;;;;;;;;;;;;;;AAUA,MAAM,gBAA6C,CAAS,UAAA;AACpD,QAAA,cAAc,CAAC,OAAgC,YAAqC;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MAAA;AAAA,IAAA;AAAA,EACT;AAEJ;ACpBO,MAAM,aAAa,MAAM,WAAW,CAAC,OAAwB,QAA4C;AACxG,QAAA,uBAAuB,OAAO,2BAA2B;AAEzD,QAAA,mBAAmB,CAAuC,UAAwD;AAC/G,WAAA,MAAM,aAAa,OAAO;AAAA,MAC/B,GAAG,MAAM;AAAA,MACT,uBAAuB;AAAA,IAAA,CACxB;AAAA,EACH;AAEM,QAAA,cAAc,CAAC,UAA4C;AAC/D,QACE,YAA4B,OAAO,SAAS,KAC5C,YAA2B,OAAO,QAAQ,KAC1C,YAA8B,OAAO,WAAW,KAChD,YAA2B,OAAO,QAAQ,KAC1C,YAAwB,OAAO,KAAK,KACpC,YAAyB,OAAO,MAAM,KACtC,YAAyB,OAAO,MAAM,KACtC,2BAAuD,OAAO,uBAAuB,KACrF,2BAAuD,OAAO,YAAY,KAC1E,2BAAuD,OAAO,UAAU,GACxE;AACA,aAAO,iBAA6C,KAAK;AAAA,IAAA;AAE3D,QAAI,MAAM,eAAe,KAAK,KAAK,MAAM,SAAS,MAAM,UAAU;AAChE,aAAO,MAAM,SAAS,IAAI,MAAM,MAAM,UAAU,CAACA,WAA2B;AAC1E,eAAO,YAAYA,MAAK;AAAA,MAAA,CACzB;AAAA,IAAA;AAGI,WAAA;AAAA,EACT;AAEA,SAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAC,oBAAA,OAAA,EAAI,eAAa,MAAM,QAAQ,oBAAkB,YAAY,YAAY,WAAW,MAAM,WAAW,KACnG,UAAM,MAAA,SAAS,IAAI,MAAM,UAAU,CAAC,UAA2B,YAAY,KAAK,CAAC,EACpF,CAAA;AAAA,wBACC,mBAAkB,EAAA,YAAY,MAAM,YAAY,QAAQ,MAAM,OAAQ,CAAA;AAAA,EAAA,GACzE;AAEJ,CAAC;AAED,WAAW,cAAc;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Validation/ErrorListItem.tsx","../../../src/components/Validation/ErrorList.tsx","../../../src/components/Validation/ValidationSummary.tsx","../../../src/components/Validation/Validation.tsx"],"sourcesContent":["import React from 'react';\n\nimport { ErrorDetails, FocusableElement } from './types';\nimport AnchorLink, { AnchorLinkOnClickEvent } from '../AnchorLink';\n\ninterface ErrorElementProps {\n name: string;\n error: ErrorDetails;\n}\n\nconst ErrorListItem: React.FC<ErrorElementProps> = props => {\n const handleClick = (event?: AnchorLinkOnClickEvent, element?: FocusableElement): void => {\n event?.preventDefault();\n element?.focus && element?.focus();\n };\n\n if (props.error.ref) {\n return (\n <AnchorLink href={`#${props.name}`} onClick={(e): void => handleClick(e, props.error.ref)}>\n {props.error.message}\n </AnchorLink>\n );\n }\n\n return <>{props.error.message}</>;\n};\n\nexport default ErrorListItem;\n","import React from 'react';\n\nimport ErrorListItem from './ErrorListItem';\nimport { ValidationErrors } from './types';\nimport List from '../List';\n\ninterface ErrorListProps {\n errors: ValidationErrors;\n}\n\nconst ErrorList: React.FC<ErrorListProps> = props => (\n <List>\n {Object.entries(props.errors).map(([name, error]) => (\n <List.Item key={name}>\n <ErrorListItem name={name} error={error} />\n </List.Item>\n ))}\n </List>\n);\n\nexport default ErrorList;\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport ErrorList from './ErrorList';\nimport { ValidationErrors } from './types';\nimport { useUuid } from '../../hooks/useUuid';\nimport Title, { TitleTags } from '../Title';\n\nimport styles from './styles.module.scss';\n\ninterface ValidationSummaryProps {\n /** Error summary title */\n errorTitle?: string;\n /** Error list */\n errors?: ValidationErrors;\n /** Markup props for error summary title. Default: h2 */\n errorTitleHtmlMarkup?: TitleTags;\n /** Will be shown last */\n children?: React.ReactNode;\n}\n\nconst ValidationSummary: React.FC<ValidationSummaryProps> = props => {\n const { errorTitleHtmlMarkup = 'h2' } = props;\n const titleId = useUuid();\n\n const hasErrors = !!props.errors && Object.entries(props.errors).length > 0;\n\n const summaryClasses = classNames(styles['validation__summary'], hasErrors && styles['validation__summary--visible']);\n\n return (\n <div\n role={'status'}\n aria-atomic={'true'}\n aria-live={'polite'}\n aria-relevant={'all'}\n aria-labelledby={hasErrors && props.errorTitle ? titleId : undefined}\n className={summaryClasses}\n >\n {hasErrors && (\n <>\n {props.errorTitle && (\n <Title appearance=\"title4\" id={titleId} htmlMarkup={errorTitleHtmlMarkup} margin={{ marginTop: 0, marginBottom: 1 }}>\n {props.errorTitle}\n </Title>\n )}\n <ErrorList errors={props.errors!} />\n </>\n )}\n {props.children}\n </div>\n );\n};\n\nexport default ValidationSummary;\n","import React from 'react';\n\nimport { ValidationErrors } from './types';\nimport ValidationSummary from './ValidationSummary';\nimport { AnalyticsId, FormSize } from '../../constants';\nimport { isComponent, isComponentWithDisplayName } from '../../utils/component';\nimport Checkbox, { CheckboxProps } from '../Checkbox';\nimport { ErrorWrapperClassNameProps } from '../ErrorWrapper';\nimport FormGroup, { FormGroupProps } from '../FormGroup/FormGroup';\nimport Input, { InputProps } from '../Input';\nimport RadioButton, { RadioButtonProps } from '../RadioButton';\nimport Select, { SelectProps } from '../Select';\nimport Slider, { SliderProps } from '../Slider';\nimport Textarea, { TextareaProps } from '../Textarea';\n\nimport styles from './styles.module.scss';\n\ninterface ValidationProps {\n /** Error summary title */\n errorTitle?: string;\n /** Validation errors. If errors include references to HTML elements, the errors will be rendered as links with an onClick handler to focus the element. */\n errors?: ValidationErrors;\n /** Items in the Validation compontent */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Validation = React.forwardRef((props: ValidationProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const validationErrorClass = styles['validation__error-wrapper'];\n\n const cloneFormElement = <T extends ErrorWrapperClassNameProps>(child: React.ReactElement<T>): React.ReactElement<T> => {\n return React.cloneElement(child, {\n ...child.props,\n errorWrapperClassName: validationErrorClass,\n });\n };\n\n const renderChild = (child: React.ReactNode): React.ReactNode => {\n if (\n isComponent<FormGroupProps>(child, FormGroup) ||\n isComponent<CheckboxProps>(child, Checkbox) ||\n isComponent<RadioButtonProps>(child, RadioButton) ||\n isComponent<TextareaProps>(child, Textarea) ||\n isComponent<InputProps>(child, Input) ||\n isComponent<SelectProps>(child, Select) ||\n isComponent<SliderProps>(child, Slider) ||\n isComponentWithDisplayName<ErrorWrapperClassNameProps>(child, 'DateTimePickerWrapper') ||\n isComponentWithDisplayName<ErrorWrapperClassNameProps>(child, 'DatePicker') ||\n isComponentWithDisplayName<ErrorWrapperClassNameProps>(child, 'DateTime')\n ) {\n return cloneFormElement<ErrorWrapperClassNameProps>(child);\n }\n if (React.isValidElement(child) && child.type === React.Fragment) {\n return React.Children.map(child.props.children, (child: React.ReactNode) => {\n return renderChild(child);\n });\n }\n\n return child;\n };\n\n return (\n <>\n <div data-testid={props.testId} data-analyticsid={AnalyticsId.Validation} className={props.className} ref={ref}>\n {React.Children.map(props.children, (child: React.ReactNode) => renderChild(child))}\n </div>\n <ValidationSummary errorTitle={props.errorTitle} errors={props.errors} />\n </>\n );\n});\n\nValidation.displayName = 'Validation';\n\nexport default Validation;\n"],"names":["React","child"],"mappings":";;;;;;;;;;;;;;;;;AAUA,MAAM,gBAA6C,CAAS,UAAA;AACpD,QAAA,cAAc,CAAC,OAAgC,YAAqC;AACxF,mCAAO;AACE,wCAAA,WAAS,mCAAS;AAAA,EAC7B;AAEI,MAAA,MAAM,MAAM,KAAK;AACnB,+BACG,YAAW,EAAA,MAAM,IAAI,MAAM,IAAI,IAAI,SAAS,CAAC,MAAY,YAAY,GAAG,MAAM,MAAM,GAAG,GACrF,UAAA,MAAM,MAAM,SACf;AAAA,EAAA;AAIG,SAAA,oBAAA,UAAA,EAAG,UAAM,MAAA,MAAM,SAAQ;AAChC;ACfA,MAAM,YAAsC,CAC1C,UAAA,oBAAC,MACE,EAAA,UAAA,OAAO,QAAQ,MAAM,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,MAC7C,oBAAC,KAAK,MAAL,EACC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KACpC,YAAyB,OAAO,MAAM,KACtC,YAAyB,OAAO,MAAM,KACtC,2BAAuD,OAAO,uBAAuB,KACrF,2BAAuD,OAAO,YAAY,KAC1E,2BAAuD,OAAO,UAAU,GACxE;AACA,aAAO,iBAA6C,KAAK;AAAA,IAAA;AAE3D,QAAIA,eAAM,eAAe,KAAK,KAAK,MAAM,SAASA,eAAM,UAAU;AAChE,aAAOA,eAAM,SAAS,IAAI,MAAM,MAAM,UAAU,CAACC,WAA2B;AAC1E,eAAO,YAAYA,MAAK;AAAA,MAAA,CACzB;AAAA,IAAA;AAGI,WAAA;AAAA,EACT;AAEA,SAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAC,oBAAA,OAAA,EAAI,eAAa,MAAM,QAAQ,oBAAkB,YAAY,YAAY,WAAW,MAAM,WAAW,KACnG,UAAMD,eAAA,SAAS,IAAI,MAAM,UAAU,CAAC,UAA2B,YAAY,KAAK,CAAC,EACpF,CAAA;AAAA,wBACC,mBAAkB,EAAA,YAAY,MAAM,YAAY,QAAQ,MAAM,OAAQ,CAAA;AAAA,EAAA,GACzE;AAEJ,CAAC;AAED,WAAW,cAAc;"}
package/constants.d.ts CHANGED
@@ -59,6 +59,7 @@ export declare enum AnalyticsId {
59
59
  Chip = "chip",
60
60
  Close = "close",
61
61
  DictionaryTrigger = "dictionary-trigger",
62
+ Drawer = "Drawer",
62
63
  Dropdown = "dropdown",
63
64
  Duolist = "duolist",
64
65
  EmptyState = "empty-state",
package/constants.js CHANGED
@@ -37,6 +37,7 @@ var AnalyticsId = /* @__PURE__ */ ((AnalyticsId2) => {
37
37
  AnalyticsId2["Chip"] = "chip";
38
38
  AnalyticsId2["Close"] = "close";
39
39
  AnalyticsId2["DictionaryTrigger"] = "dictionary-trigger";
40
+ AnalyticsId2["Drawer"] = "Drawer";
40
41
  AnalyticsId2["Dropdown"] = "dropdown";
41
42
  AnalyticsId2["Duolist"] = "duolist";
42
43
  AnalyticsId2["EmptyState"] = "empty-state";
package/constants.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export enum IconSize {\n XXSmall = 24,\n XSmall = 38,\n Small = 48,\n Medium = 64,\n Large = 80,\n XLarge = 130,\n}\n\nexport enum ZIndex {\n Modal = 1300000,\n PopOver = 11000,\n OverlayScreen = 9999,\n LightBoxButtons = 1000,\n}\n\nexport const AVERAGE_CHARACTER_WIDTH_PX = 12;\n\nexport interface HTMLButtonProps {\n autoFocus?: boolean;\n disabled?: boolean;\n form?: string;\n formAction?: string;\n formEncType?: string;\n formMethod?: string;\n formNoValidate?: boolean;\n formTarget?: string;\n name?: string;\n type?: 'submit' | 'reset' | 'button' | string;\n value?: string | string[] | number;\n id?: string;\n}\n\nexport type AnchorTarget = '_self' | '_blank' | '_parent' | '_top';\n\nexport interface HTMLAnchorProps {\n download?: string;\n href?: string;\n hrefLang?: string;\n media?: string;\n ping?: string;\n rel?: AnchorTarget;\n target?: string;\n referrerPolicy?:\n | ''\n | 'same-origin'\n | 'no-referrer'\n | 'no-referrer-when-downgrade'\n | 'origin'\n | 'origin-when-cross-origin'\n | 'strict-origin'\n | 'strict-origin-when-cross-origin'\n | 'unsafe-url';\n}\n\nexport type ButtonVariant = 'secondary' | 'tertiary' | string | undefined | null;\n\nexport enum FormOnColor {\n onwhite = 'onwhite',\n ongrey = 'ongrey',\n onblueberry = 'onblueberry',\n ondark = 'ondark',\n oninvalid = 'oninvalid',\n}\n\nexport enum FormSize {\n medium = 'medium',\n large = 'large',\n}\n\nexport enum AnalyticsId {\n AnchorLink = 'anchor-link',\n Avatar = 'avatar',\n Badge = 'badge',\n Button = 'button',\n Checkbox = 'checkbox',\n Chip = 'chip',\n Close = 'close',\n DictionaryTrigger = 'dictionary-trigger',\n Dropdown = 'dropdown',\n Duolist = 'duolist',\n EmptyState = 'empty-state',\n Expander = 'expander',\n ExpanderHierarchy = 'expander-hierarchy',\n ExpanderHierarchyExpander = 'expander-hierarchy-expander',\n ExpanderList = 'expander-list',\n ExpanderListExpander = 'expander-list-expander',\n EyebrowHeader = 'eyebrow-header',\n FormGroup = 'form-group',\n FormLayout = 'form-layout',\n HelpBubble = 'help-bubble',\n HelpQuestion = 'help-question',\n HighlightPanel = 'highlight-panel',\n Icon = 'icon',\n Illustration = 'Illustration',\n Input = 'input',\n Label = 'label',\n Link = 'link',\n LinkList = 'link-list',\n List = 'list',\n Loader = 'loader',\n Logo = 'logo',\n Modal = 'modal',\n NotificationPanel = 'notification-panel',\n Panel = 'panel',\n PanelList = 'panel-list',\n PopMenu = 'pop-menu',\n PopOver = 'pop-over',\n Portal = 'portal',\n PromoPanel = 'promo-panel',\n RadioButton = 'radio-button',\n Select = 'select',\n SharingStatus = 'sharing-status',\n Slider = 'slider',\n Spacer = 'spacer',\n StatusDot = 'status-dot',\n Step = 'step',\n StepButtons = 'step-buttons',\n Stepper = 'stepper',\n Sublabel = 'sublabel',\n Table = 'table',\n Tag = 'tag',\n TagList = 'tag-list',\n Textarea = 'textarea',\n Tile = 'tile',\n Title = 'title',\n Toggle = 'toggle',\n Tooltip = 'tooltip',\n Trigger = 'trigger',\n Validation = 'validation',\n}\n\nexport enum KeyboardEventKey {\n Enter = 'Enter',\n Escape = 'Escape',\n ArrowDown = 'ArrowDown',\n ArrowUp = 'ArrowUp',\n ArrowRight = 'ArrowRight',\n ArrowLeft = 'ArrowLeft',\n Home = 'Home',\n End = 'End',\n Space = ' ',\n Tab = 'Tab',\n}\n"],"names":["IconSize","ZIndex","FormOnColor","FormSize","AnalyticsId","KeyboardEventKey"],"mappings":"AAAY,IAAA,6BAAAA,cAAL;AACLA,YAAAA,UAAA,aAAU,EAAV,IAAA;AACAA,YAAAA,UAAA,YAAS,EAAT,IAAA;AACAA,YAAAA,UAAA,WAAQ,EAAR,IAAA;AACAA,YAAAA,UAAA,YAAS,EAAT,IAAA;AACAA,YAAAA,UAAA,WAAQ,EAAR,IAAA;AACAA,YAAAA,UAAA,YAAS,GAAT,IAAA;AAN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}
1
+ {"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export enum IconSize {\n XXSmall = 24,\n XSmall = 38,\n Small = 48,\n Medium = 64,\n Large = 80,\n XLarge = 130,\n}\n\nexport enum ZIndex {\n Modal = 1300000,\n PopOver = 11000,\n OverlayScreen = 9999,\n LightBoxButtons = 1000,\n}\n\nexport const AVERAGE_CHARACTER_WIDTH_PX = 12;\n\nexport interface HTMLButtonProps {\n autoFocus?: boolean;\n disabled?: boolean;\n form?: string;\n formAction?: string;\n formEncType?: string;\n formMethod?: string;\n formNoValidate?: boolean;\n formTarget?: string;\n name?: string;\n type?: 'submit' | 'reset' | 'button' | string;\n value?: string | string[] | number;\n id?: string;\n}\n\nexport type AnchorTarget = '_self' | '_blank' | '_parent' | '_top';\n\nexport interface HTMLAnchorProps {\n download?: string;\n href?: string;\n hrefLang?: string;\n media?: string;\n ping?: string;\n rel?: AnchorTarget;\n target?: string;\n referrerPolicy?:\n | ''\n | 'same-origin'\n | 'no-referrer'\n | 'no-referrer-when-downgrade'\n | 'origin'\n | 'origin-when-cross-origin'\n | 'strict-origin'\n | 'strict-origin-when-cross-origin'\n | 'unsafe-url';\n}\n\nexport type ButtonVariant = 'secondary' | 'tertiary' | string | undefined | null;\n\nexport enum FormOnColor {\n onwhite = 'onwhite',\n ongrey = 'ongrey',\n onblueberry = 'onblueberry',\n ondark = 'ondark',\n oninvalid = 'oninvalid',\n}\n\nexport enum FormSize {\n medium = 'medium',\n large = 'large',\n}\n\nexport enum AnalyticsId {\n AnchorLink = 'anchor-link',\n Avatar = 'avatar',\n Badge = 'badge',\n Button = 'button',\n Checkbox = 'checkbox',\n Chip = 'chip',\n Close = 'close',\n DictionaryTrigger = 'dictionary-trigger',\n Drawer = 'Drawer',\n Dropdown = 'dropdown',\n Duolist = 'duolist',\n EmptyState = 'empty-state',\n Expander = 'expander',\n ExpanderHierarchy = 'expander-hierarchy',\n ExpanderHierarchyExpander = 'expander-hierarchy-expander',\n ExpanderList = 'expander-list',\n ExpanderListExpander = 'expander-list-expander',\n EyebrowHeader = 'eyebrow-header',\n FormGroup = 'form-group',\n FormLayout = 'form-layout',\n HelpBubble = 'help-bubble',\n HelpQuestion = 'help-question',\n HighlightPanel = 'highlight-panel',\n Icon = 'icon',\n Illustration = 'Illustration',\n Input = 'input',\n Label = 'label',\n Link = 'link',\n LinkList = 'link-list',\n List = 'list',\n Loader = 'loader',\n Logo = 'logo',\n Modal = 'modal',\n NotificationPanel = 'notification-panel',\n Panel = 'panel',\n PanelList = 'panel-list',\n PopMenu = 'pop-menu',\n PopOver = 'pop-over',\n Portal = 'portal',\n PromoPanel = 'promo-panel',\n RadioButton = 'radio-button',\n Select = 'select',\n SharingStatus = 'sharing-status',\n Slider = 'slider',\n Spacer = 'spacer',\n StatusDot = 'status-dot',\n Step = 'step',\n StepButtons = 'step-buttons',\n Stepper = 'stepper',\n Sublabel = 'sublabel',\n Table = 'table',\n Tag = 'tag',\n TagList = 'tag-list',\n Textarea = 'textarea',\n Tile = 'tile',\n Title = 'title',\n Toggle = 'toggle',\n Tooltip = 'tooltip',\n Trigger = 'trigger',\n Validation = 'validation',\n}\n\nexport enum KeyboardEventKey {\n Enter = 'Enter',\n Escape = 'Escape',\n ArrowDown = 'ArrowDown',\n ArrowUp = 'ArrowUp',\n ArrowRight = 'ArrowRight',\n ArrowLeft = 'ArrowLeft',\n Home = 'Home',\n End = 'End',\n Space = ' ',\n Tab = 'Tab',\n}\n"],"names":["IconSize","ZIndex","FormOnColor","FormSize","AnalyticsId","KeyboardEventKey"],"mappings":"AAAY,IAAA,6BAAAA,cAAL;AACLA,YAAAA,UAAA,aAAU,EAAV,IAAA;AACAA,YAAAA,UAAA,YAAS,EAAT,IAAA;AACAA,YAAAA,UAAA,WAAQ,EAAR,IAAA;AACAA,YAAAA,UAAA,YAAS,EAAT,IAAA;AACAA,YAAAA,UAAA,WAAQ,EAAR,IAAA;AACAA,YAAAA,UAAA,YAAS,GAAT,IAAA;AANUA,SA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AAA,CAAA,CAAA;"}
@@ -1,8 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import React from "react";
2
+ import React__default from "react";
3
3
  import { useBreakpoint } from "../../hooks/useBreakpoint.js";
4
4
  function withBreakpoint(Component) {
5
- return React.forwardRef((props, ref) => {
5
+ return React__default.forwardRef((props, ref) => {
6
6
  const breakpoint = useBreakpoint();
7
7
  return /* @__PURE__ */ jsx(Component, { ref, ...props, breakpoint });
8
8
  });
@@ -1 +1 @@
1
- {"version":3,"file":"withBreakpoint.js","sources":["../../../src/hoc/withBreakpoint/withBreakpoint.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\n\nexport interface BreakpointProps {\n breakpoint: Breakpoint;\n}\n\n// Hentet fra https://github.com/DefinitelyTyped/DefinitelyTyped/issues/35834#issuecomment-497605842\nexport function withBreakpoint<P extends BreakpointProps, C extends React.ComponentClass<P>>(\n Component: C & React.ComponentType<P>\n): React.ForwardRefExoticComponent<Omit<React.ComponentPropsWithoutRef<C> & { ref?: React.Ref<InstanceType<C>> }, keyof BreakpointProps>>;\n\nexport function withBreakpoint<P extends BreakpointProps & { ref?: React.Ref<unknown> }>(\n Component: React.ForwardRefExoticComponent<P>\n): React.ForwardRefExoticComponent<Omit<P, keyof BreakpointProps>>;\n\nexport function withBreakpoint<P extends BreakpointProps>(\n Component: React.FunctionComponent<P>\n): React.ForwardRefExoticComponent<Omit<P, keyof BreakpointProps>>;\n\nexport function withBreakpoint<P extends BreakpointProps>(Component: React.ComponentType<P>) {\n return React.forwardRef((props, ref) => {\n const breakpoint = useBreakpoint();\n return <Component ref={ref} {...(props as P)} breakpoint={breakpoint} />;\n });\n}\n\nexport default withBreakpoint;\n"],"names":[],"mappings":";;;AAqBO,SAAS,eAA0C,WAAmC;AAC3F,SAAO,MAAM,WAAW,CAAC,OAAO,QAAQ;AACtC,UAAM,aAAa,cAAc;AACjC,WAAQ,oBAAA,WAAA,EAAU,KAAW,GAAI,OAAa,YAAwB;AAAA,EAAA,CACvE;AACH;"}
1
+ {"version":3,"file":"withBreakpoint.js","sources":["../../../src/hoc/withBreakpoint/withBreakpoint.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\n\nexport interface BreakpointProps {\n breakpoint: Breakpoint;\n}\n\n// Hentet fra https://github.com/DefinitelyTyped/DefinitelyTyped/issues/35834#issuecomment-497605842\nexport function withBreakpoint<P extends BreakpointProps, C extends React.ComponentClass<P>>(\n Component: C & React.ComponentType<P>\n): React.ForwardRefExoticComponent<Omit<React.ComponentPropsWithoutRef<C> & { ref?: React.Ref<InstanceType<C>> }, keyof BreakpointProps>>;\n\nexport function withBreakpoint<P extends BreakpointProps & { ref?: React.Ref<unknown> }>(\n Component: React.ForwardRefExoticComponent<P>\n): React.ForwardRefExoticComponent<Omit<P, keyof BreakpointProps>>;\n\nexport function withBreakpoint<P extends BreakpointProps>(\n Component: React.FunctionComponent<P>\n): React.ForwardRefExoticComponent<Omit<P, keyof BreakpointProps>>;\n\nexport function withBreakpoint<P extends BreakpointProps>(Component: React.ComponentType<P>) {\n return React.forwardRef((props, ref) => {\n const breakpoint = useBreakpoint();\n return <Component ref={ref} {...(props as P)} breakpoint={breakpoint} />;\n });\n}\n\nexport default withBreakpoint;\n"],"names":["React"],"mappings":";;;AAqBO,SAAS,eAA0C,WAAmC;AAC3F,SAAOA,eAAM,WAAW,CAAC,OAAO,QAAQ;AACtC,UAAM,aAAa,cAAc;AACjC,WAAQ,oBAAA,WAAA,EAAU,KAAW,GAAI,OAAa,YAAwB;AAAA,EAAA,CACvE;AACH;"}
@@ -6,8 +6,4 @@ export declare enum Breakpoint {
6
6
  lg,
7
7
  xl
8
8
  }
9
- /**
10
- * Lytt på endringer i breakpoint basert på media queries. Trigger re-render bare når breakpoint er endret.
11
- * @returns Gjeldende breakpoint
12
- */
13
9
  export declare const useBreakpoint: () => Breakpoint;
@@ -9,10 +9,19 @@ var Breakpoint = ((Breakpoint2) => {
9
9
  Breakpoint2[Breakpoint2["xl"] = breakpoints.xl] = "xl";
10
10
  return Breakpoint2;
11
11
  })(Breakpoint || {});
12
+ function getCurrentBreakpoint() {
13
+ const mediaQueryList = Object.entries(screen).reverse().map(([size, mediaQuery]) => {
14
+ return {
15
+ breakpoint: Breakpoint[size],
16
+ mq: window.matchMedia(mediaQuery)
17
+ };
18
+ });
19
+ const matched = mediaQueryList.find((entry) => entry.mq.matches);
20
+ return (matched == null ? void 0 : matched.breakpoint) ?? Breakpoint.xxs;
21
+ }
12
22
  const useBreakpoint = () => {
13
- const [breakpoint, setBreakpoint] = useState(Breakpoint.xxs);
23
+ const [breakpoint, setBreakpoint] = useState(() => getCurrentBreakpoint());
14
24
  useEffect(() => {
15
- var _a;
16
25
  const handleMediaQueryEvent = (event) => {
17
26
  switch (event.media) {
18
27
  case screen.xl:
@@ -32,27 +41,23 @@ const useBreakpoint = () => {
32
41
  return;
33
42
  default:
34
43
  setBreakpoint(Breakpoint.xxs);
35
- return;
36
44
  }
37
45
  };
38
- const mediaQueryList = Object.entries(screen).reverse().map(([size, mediaQuery]) => {
39
- return { breakpoint: Breakpoint[size], mediaQuery: window.matchMedia(mediaQuery) };
40
- });
41
- mediaQueryList.forEach((x) => {
42
- if (x.mediaQuery.addEventListener) {
43
- x.mediaQuery.addEventListener("change", handleMediaQueryEvent);
44
- } else if (x.mediaQuery.addListener) {
45
- x.mediaQuery.addListener(handleMediaQueryEvent);
46
+ const mediaQueryList = Object.entries(screen).map(([_size, mediaQuery]) => {
47
+ const mq = window.matchMedia(mediaQuery);
48
+ if (mq.addEventListener) {
49
+ mq.addEventListener("change", handleMediaQueryEvent);
50
+ } else if (mq.addListener) {
51
+ mq.addListener(handleMediaQueryEvent);
46
52
  }
53
+ return mq;
47
54
  });
48
- const initialBreakpoint = ((_a = mediaQueryList.find((x) => x.mediaQuery.matches)) == null ? void 0 : _a.breakpoint) ?? breakpoint;
49
- setBreakpoint(initialBreakpoint);
50
55
  return () => {
51
- mediaQueryList.forEach((x) => {
52
- if (x.mediaQuery.removeEventListener) {
53
- x.mediaQuery.removeEventListener("change", handleMediaQueryEvent);
54
- } else if (x.mediaQuery.removeListener) {
55
- x.mediaQuery.removeListener(handleMediaQueryEvent);
56
+ mediaQueryList.forEach((mq) => {
57
+ if (mq.removeEventListener) {
58
+ mq.removeEventListener("change", handleMediaQueryEvent);
59
+ } else if (mq.removeListener) {
60
+ mq.removeListener(handleMediaQueryEvent);
56
61
  }
57
62
  });
58
63
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useBreakpoint.js","sources":["../../src/hooks/useBreakpoint.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\n\nimport { breakpoints, screen } from '../theme/grid';\n\nexport enum Breakpoint {\n xxs = breakpoints.xxs,\n xs = breakpoints.xs,\n sm = breakpoints.sm,\n md = breakpoints.md,\n lg = breakpoints.lg,\n xl = breakpoints.xl,\n}\n\n/**\n * Lytt endringer i breakpoint basert media queries. Trigger re-render bare når breakpoint er endret.\n * @returns Gjeldende breakpoint\n */\nexport const useBreakpoint = (): Breakpoint => {\n const [breakpoint, setBreakpoint] = useState<Breakpoint>(Breakpoint.xxs);\n\n useEffect(() => {\n const handleMediaQueryEvent = (event: MediaQueryListEvent): void => {\n switch (event.media) {\n case screen.xl:\n setBreakpoint(event.matches ? Breakpoint.xl : Breakpoint.lg);\n return;\n case screen.lg:\n setBreakpoint(event.matches ? Breakpoint.lg : Breakpoint.md);\n return;\n case screen.md:\n setBreakpoint(event.matches ? Breakpoint.md : Breakpoint.sm);\n return;\n case screen.sm:\n setBreakpoint(event.matches ? Breakpoint.sm : Breakpoint.xs);\n return;\n case screen.xs:\n setBreakpoint(event.matches ? Breakpoint.xs : Breakpoint.xxs);\n return;\n default:\n setBreakpoint(Breakpoint.xxs);\n return;\n }\n };\n\n // Lytt etter endringer for hvert breakpoint\n const mediaQueryList = Object.entries(screen)\n .reverse()\n .map(([size, mediaQuery]) => {\n return { breakpoint: Breakpoint[size as keyof typeof Breakpoint], mediaQuery: window.matchMedia(mediaQuery) };\n });\n mediaQueryList.forEach(x => {\n // iOS <=13 har ikke støtte for addEventListener/removeEventListener på MediaQueryList,\n // men har støtte for addListener\n if (x.mediaQuery.addEventListener) {\n x.mediaQuery.addEventListener('change', handleMediaQueryEvent);\n } else if (x.mediaQuery.addListener) {\n x.mediaQuery.addListener(handleMediaQueryEvent);\n }\n });\n\n // Finn breakpoint ved første render\n const initialBreakpoint = mediaQueryList.find(x => x.mediaQuery.matches)?.breakpoint ?? breakpoint;\n setBreakpoint(initialBreakpoint);\n\n return (): void => {\n mediaQueryList.forEach(x => {\n if (x.mediaQuery.removeEventListener) {\n x.mediaQuery.removeEventListener('change', handleMediaQueryEvent);\n } else if (x.mediaQuery.removeListener) {\n x.mediaQuery.removeListener(handleMediaQueryEvent);\n }\n });\n };\n }, []);\n\n return breakpoint;\n};\n"],"names":["Breakpoint"],"mappings":";;AAIY,IAAA,cAAL,CAAKA,gBAAL;AACLA,cAAAA,YAAA,KAAM,IAAA,YAAY,GAAlB,IAAA;AACAA,cAAAA,YAAA,IAAK,IAAA,YAAY,EAAjB,IAAA;AACAA,cAAAA,YAAA,IAAK,IAAA,YAAY,EAAjB,IAAA;AACAA,cAAAA,YAAA,IAAK,IAAA,YAAY,EAAjB,IAAA;AACAA,cAAAA,YAAA,IAAK,IAAA,YAAY,EAAjB,IAAA;AACAA,cAAAA,YAAA,IAAK,IAAA,YAAY,EAAjB,IAAA;AANUA,SAAAA;AAAA,GAAA,cAAA,CAAA,CAAA;AAaL,MAAM,gBAAgB,MAAkB;AAC7C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAqB,WAAW,GAAG;AAEvE,YAAU,MAAM;;AACR,UAAA,wBAAwB,CAAC,UAAqC;AAClE,cAAQ,MAAM,OAAO;AAAA,QACnB,KAAK,OAAO;AACV,wBAAc,MAAM,UAAU,WAAW,KAAK,WAAW,EAAE;AAC3D;AAA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from 'react';\n\nimport { breakpoints, screen } from '../theme/grid';\n\nexport enum Breakpoint {\n xxs = breakpoints.xxs,\n xs = breakpoints.xs,\n sm = breakpoints.sm,\n md = breakpoints.md,\n lg = breakpoints.lg,\n xl = breakpoints.xl,\n}\n\nfunction getCurrentBreakpoint(): Breakpoint {\n // We read from largest -> smallest or vice versa\n // so that the first match is the \"highest\" one that applies\n const mediaQueryList = Object.entries(screen)\n .reverse() // e.g. check xl, lg, md, etc. in descending order\n .map(([size, mediaQuery]) => {\n return {\n breakpoint: Breakpoint[size as keyof typeof Breakpoint],\n mq: window.matchMedia(mediaQuery),\n };\n });\n\n const matched = mediaQueryList.find(entry => entry.mq.matches);\n return matched?.breakpoint ?? Breakpoint.xxs;\n}\n\nexport const useBreakpoint = (): Breakpoint => {\n const [breakpoint, setBreakpoint] = useState<Breakpoint>(() => getCurrentBreakpoint());\n\n useEffect(() => {\n const handleMediaQueryEvent = (event: MediaQueryListEvent): void => {\n switch (event.media) {\n case screen.xl:\n setBreakpoint(event.matches ? Breakpoint.xl : Breakpoint.lg);\n return;\n case screen.lg:\n setBreakpoint(event.matches ? Breakpoint.lg : Breakpoint.md);\n return;\n case screen.md:\n setBreakpoint(event.matches ? Breakpoint.md : Breakpoint.sm);\n return;\n case screen.sm:\n setBreakpoint(event.matches ? Breakpoint.sm : Breakpoint.xs);\n return;\n case screen.xs:\n setBreakpoint(event.matches ? Breakpoint.xs : Breakpoint.xxs);\n return;\n default:\n setBreakpoint(Breakpoint.xxs);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const mediaQueryList = Object.entries(screen).map(([_size, mediaQuery]) => {\n const mq = window.matchMedia(mediaQuery);\n // iOS <=13 har ikke støtte for addEventListener/removeEventListener på MediaQueryList,\n // men har støtte for addListener\n if (mq.addEventListener) {\n mq.addEventListener('change', handleMediaQueryEvent);\n } else if (mq.addListener) {\n mq.addListener(handleMediaQueryEvent);\n }\n return mq;\n });\n\n return (): void => {\n mediaQueryList.forEach(mq => {\n if (mq.removeEventListener) {\n mq.removeEventListener('change', handleMediaQueryEvent);\n } else if (mq.removeListener) {\n mq.removeListener(handleMediaQueryEvent);\n }\n });\n };\n }, []);\n\n return breakpoint;\n};\n"],"names":["Breakpoint"],"mappings":";;AAIY,IAAA,cAAL,CAAKA,gBAAL;AACLA,cAAAA,YAAA,KAAM,IAAA,YAAY,GAAlB,IAAA;AACAA,cAAAA,YAAA,IAAK,IAAA,YAAY,EAAjB,IAAA;AACAA,cAAAA,YAAA,IAAK,IAAA,YAAY,EAAjB,IAAA;AACAA,cAAAA,YAAA,IAAK,IAAA,YAAY,EAAjB,IAAA;AACAA,cAAAA,YAAA,IAAK,IAAA,YAAY,EAAjB,IAAA;AACAA,cAAAA,YAAA,IAAK,IAAA,YAAY,EAAjB,IAAA;AANUA,SAAAA;AAAA,GAAA,cAAA,CAAA,CAAA;AASZ,SAAS,uBAAmC;AAG1C,QAAM,iBAAiB,OAAO,QAAQ,MAAM,EACzC,QACA,EAAA,IAAI,CAAC,CAAC,MAAM,UAAU,MAAM;AACpB,WAAA;AAAA,MACL,YAAY,WAAW,IAA+B;AAAA,MACtD,IAAI,OAAO,WAAW,UAAU;AAAA,IAClC;AAAA,EAAA,CACD;AAEH,QAAM,UAAU,eAAe,KAAK,CAAS,UAAA,MAAM,GAAG,OAAO;AACtD,UAAA,mCAAS,eAAc,WAAW;AAC3C;AAEO,MAAM,gBAAgB,MAAkB;AAC7C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAqB,MAAM,sBAAsB;AAErF,YAAU,MAAM;AACR,UAAA,wBAAwB,CAAC,UAAqC;AAClE,cAAQ,MAAM,OAAO;AAAA,QACnB,KAAK,OAAO;AACV,wBAAc,MAAM,UAAU,WAAW,KAAK,WAAW,EAAE;AAC3D;AAAA,QACF,KAAK,OAAO;AACV,wBAAc,MAAM,UAAU,WAAW,KAAK,WAAW,EAAE;AAC3D;AAAA,QACF,KAAK,OAAO;AACV,wBAAc,MAAM,UAAU,WAAW,KAAK,WAAW,EAAE;AAC3D;AAAA,QACF,KAAK,OAAO;AACV,wBAAc,MAAM,UAAU,WAAW,KAAK,WAAW,EAAE;AAC3D;AAAA,QACF,KAAK,OAAO;AACV,wBAAc,MAAM,UAAU,WAAW,KAAK,WAAW,GAAG;AAC5D;AAAA,QACF;AACE,wBAAc,WAAW,GAAG;AAAA,MAAA;AAAA,IAElC;AAGM,UAAA,iBAAiB,OAAO,QAAQ,MAAM,EAAE,IAAI,CAAC,CAAC,OAAO,UAAU,MAAM;AACnE,YAAA,KAAK,OAAO,WAAW,UAAU;AAGvC,UAAI,GAAG,kBAAkB;AACpB,WAAA,iBAAiB,UAAU,qBAAqB;AAAA,MAAA,WAC1C,GAAG,aAAa;AACzB,WAAG,YAAY,qBAAqB;AAAA,MAAA;AAE/B,aAAA;AAAA,IAAA,CACR;AAED,WAAO,MAAY;AACjB,qBAAe,QAAQ,CAAM,OAAA;AAC3B,YAAI,GAAG,qBAAqB;AACvB,aAAA,oBAAoB,UAAU,qBAAqB;AAAA,QAAA,WAC7C,GAAG,gBAAgB;AAC5B,aAAG,eAAe,qBAAqB;AAAA,QAAA;AAAA,MACzC,CACD;AAAA,IACH;AAAA,EACF,GAAG,EAAE;AAEE,SAAA;AACT;"}
@@ -1,7 +1,7 @@
1
- import React from "react";
1
+ import React__default from "react";
2
2
  const useEventListenerState = (initial) => {
3
- const [value, _setValue] = React.useState(initial);
4
- const valueRef = React.useRef(value);
3
+ const [value, _setValue] = React__default.useState(initial);
4
+ const valueRef = React__default.useRef(value);
5
5
  const setValue = (x) => {
6
6
  valueRef.current = x;
7
7
  _setValue(x);
@@ -1 +1 @@
1
- {"version":3,"file":"useEventListenerState.js","sources":["../../src/hooks/useEventListenerState.ts"],"sourcesContent":["import React from 'react';\n\nexport const useEventListenerState = <T>(initial?: T): [valueRef: React.MutableRefObject<T | undefined>, setValue: (x: T) => void] => {\n const [value, _setValue] = React.useState<T | undefined>(initial);\n\n const valueRef = React.useRef(value);\n\n const setValue = (x: T) => {\n valueRef.current = x;\n _setValue(x);\n };\n\n return [valueRef, setValue];\n};\n"],"names":[],"mappings":";AAEa,MAAA,wBAAwB,CAAI,YAA6F;AACpI,QAAM,CAAC,OAAO,SAAS,IAAI,MAAM,SAAwB,OAAO;AAE1D,QAAA,WAAW,MAAM,OAAO,KAAK;AAE7B,QAAA,WAAW,CAAC,MAAS;AACzB,aAAS,UAAU;AACnB,cAAU,CAAC;AAAA,EACb;AAEO,SAAA,CAAC,UAAU,QAAQ;AAC5B;"}
1
+ {"version":3,"file":"useEventListenerState.js","sources":["../../src/hooks/useEventListenerState.ts"],"sourcesContent":["import React from 'react';\n\nexport const useEventListenerState = <T>(initial?: T): [valueRef: React.MutableRefObject<T | undefined>, setValue: (x: T) => void] => {\n const [value, _setValue] = React.useState<T | undefined>(initial);\n\n const valueRef = React.useRef(value);\n\n const setValue = (x: T) => {\n valueRef.current = x;\n _setValue(x);\n };\n\n return [valueRef, setValue];\n};\n"],"names":["React"],"mappings":";AAEa,MAAA,wBAAwB,CAAI,YAA6F;AACpI,QAAM,CAAC,OAAO,SAAS,IAAIA,eAAM,SAAwB,OAAO;AAE1D,QAAA,WAAWA,eAAM,OAAO,KAAK;AAE7B,QAAA,WAAW,CAAC,MAAS;AACzB,aAAS,UAAU;AACnB,cAAU,CAAC;AAAA,EACb;AAEO,SAAA,CAAC,UAAU,QAAQ;AAC5B;"}
@@ -1,9 +1,9 @@
1
1
  type OutsideEvents = keyof PickByValue<HTMLElementEventMap, MouseEvent | FocusEvent>;
2
2
  /**
3
- * Custom hook for klikk eller fokus utenfor et gitt element
4
- * @param ref Sjekker om det klikkes utenfor dette elementet
5
- * @param handleClick Callback-funksjon ved klikk utenfor elementet
3
+ * Custom hook for klikk eller fokus utenfor et gitt element (eller flere elementer)
4
+ * @param ref Sjekker om det klikkes utenfor dette elementet/elementene
5
+ * @param callback Callback-funksjon ved klikk utenfor elementet/elementene
6
6
  * @param events Type eventer å lytte på. Default: mousedown
7
7
  */
8
- export declare const useOutsideEvent: (ref: React.RefObject<HTMLElement>, handleClick: (event: HTMLElementEventMap[OutsideEvents]) => void, events?: OutsideEvents[]) => void;
8
+ export declare const useOutsideEvent: (ref: React.RefObject<HTMLElement> | React.RefObject<HTMLElement>[], callback: (event: HTMLElementEventMap[OutsideEvents]) => void, events?: OutsideEvents[]) => void;
9
9
  export {};
@@ -1,8 +1,9 @@
1
1
  import { useEffect } from "react";
2
- const useOutsideEvent = (ref, handleClick, events = ["mousedown"]) => {
2
+ const useOutsideEvent = (ref, callback, events = ["mousedown"]) => {
3
+ const refArray = Array.isArray(ref) ? ref : [ref];
3
4
  const handleOutsideEvent = (event) => {
4
- if (ref.current && !event.composedPath().includes(ref.current)) {
5
- handleClick(event);
5
+ if (refArray.every((ref2) => ref2.current && !event.composedPath().includes(ref2.current))) {
6
+ callback(event);
6
7
  }
7
8
  };
8
9
  useEffect(() => {
@@ -10,7 +11,7 @@ const useOutsideEvent = (ref, handleClick, events = ["mousedown"]) => {
10
11
  return () => {
11
12
  events.forEach((eventName) => document.removeEventListener(eventName, handleOutsideEvent));
12
13
  };
13
- }, [ref, handleClick, events]);
14
+ }, [refArray, callback, events]);
14
15
  };
15
16
  export {
16
17
  useOutsideEvent
@@ -1 +1 @@
1
- {"version":3,"file":"useOutsideEvent.js","sources":["../../src/hooks/useOutsideEvent.ts"],"sourcesContent":["import { useEffect } from 'react';\n\ntype OutsideEvents = keyof PickByValue<HTMLElementEventMap, MouseEvent | FocusEvent>;\n\n/**\n * Custom hook for klikk eller fokus utenfor et gitt element\n * @param ref Sjekker om det klikkes utenfor dette elementet\n * @param handleClick Callback-funksjon ved klikk utenfor elementet\n * @param events Type eventer å lytte på. Default: mousedown\n */\nexport const useOutsideEvent = (\n ref: React.RefObject<HTMLElement>,\n handleClick: (event: HTMLElementEventMap[OutsideEvents]) => void,\n events: OutsideEvents[] = ['mousedown']\n): void => {\n const handleOutsideEvent = (event: HTMLElementEventMap[OutsideEvents]): void => {\n if (ref.current && !event.composedPath().includes(ref.current)) {\n handleClick(event);\n }\n };\n\n useEffect(() => {\n events.forEach(eventName => document.addEventListener(eventName, handleOutsideEvent));\n\n return (): void => {\n events.forEach(eventName => document.removeEventListener(eventName, handleOutsideEvent));\n };\n }, [ref, handleClick, events]);\n};\n"],"names":[],"mappings":";AAUO,MAAM,kBAAkB,CAC7B,KACA,aACA,SAA0B,CAAC,WAAW,MAC7B;AACH,QAAA,qBAAqB,CAAC,UAAoD;AAC1E,QAAA,IAAI,WAAW,CAAC,MAAM,eAAe,SAAS,IAAI,OAAO,GAAG;AAC9D,kBAAY,KAAK;AAAA,IAAA;AAAA,EAErB;AAEA,YAAU,MAAM;AACd,WAAO,QAAQ,CAAa,cAAA,SAAS,iBAAiB,WAAW,kBAAkB,CAAC;AAEpF,WAAO,MAAY;AACjB,aAAO,QAAQ,CAAa,cAAA,SAAS,oBAAoB,WAAW,kBAAkB,CAAC;AAAA,IACzF;AAAA,EACC,GAAA,CAAC,KAAK,aAAa,MAAM,CAAC;AAC/B;"}
1
+ {"version":3,"file":"useOutsideEvent.js","sources":["../../src/hooks/useOutsideEvent.ts"],"sourcesContent":["import { useEffect } from 'react';\n\ntype OutsideEvents = keyof PickByValue<HTMLElementEventMap, MouseEvent | FocusEvent>;\n\n/**\n * Custom hook for klikk eller fokus utenfor et gitt element (eller flere elementer)\n * @param ref Sjekker om det klikkes utenfor dette elementet/elementene\n * @param callback Callback-funksjon ved klikk utenfor elementet/elementene\n * @param events Type eventer å lytte på. Default: mousedown\n */\nexport const useOutsideEvent = (\n ref: React.RefObject<HTMLElement> | React.RefObject<HTMLElement>[],\n callback: (event: HTMLElementEventMap[OutsideEvents]) => void,\n events: OutsideEvents[] = ['mousedown']\n): void => {\n const refArray = Array.isArray(ref) ? ref : [ref];\n\n const handleOutsideEvent = (event: HTMLElementEventMap[OutsideEvents]): void => {\n if (refArray.every(ref => ref.current && !event.composedPath().includes(ref.current))) {\n callback(event);\n }\n };\n\n useEffect(() => {\n events.forEach(eventName => document.addEventListener(eventName, handleOutsideEvent));\n\n return (): void => {\n events.forEach(eventName => document.removeEventListener(eventName, handleOutsideEvent));\n };\n }, [refArray, callback, events]);\n};\n"],"names":["ref"],"mappings":";AAUO,MAAM,kBAAkB,CAC7B,KACA,UACA,SAA0B,CAAC,WAAW,MAC7B;AACT,QAAM,WAAW,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG;AAE1C,QAAA,qBAAqB,CAAC,UAAoD;AAC9E,QAAI,SAAS,MAAM,CAAAA,SAAOA,KAAI,WAAW,CAAC,MAAM,aAAA,EAAe,SAASA,KAAI,OAAO,CAAC,GAAG;AACrF,eAAS,KAAK;AAAA,IAAA;AAAA,EAElB;AAEA,YAAU,MAAM;AACd,WAAO,QAAQ,CAAa,cAAA,SAAS,iBAAiB,WAAW,kBAAkB,CAAC;AAEpF,WAAO,MAAY;AACjB,aAAO,QAAQ,CAAa,cAAA,SAAS,oBAAoB,WAAW,kBAAkB,CAAC;AAAA,IACzF;AAAA,EACC,GAAA,CAAC,UAAU,UAAU,MAAM,CAAC;AACjC;"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * A hook that stores the currently focused element when the component mounts,
3
+ * and returns focus to it when the component unmounts.
4
+ */
5
+ export declare const useReturnFocusOnUnmount: (ref: React.RefObject<HTMLElement>) => void;
@@ -0,0 +1,20 @@
1
+ import { useRef, useEffect } from "react";
2
+ import { getDocumentActiveElement } from "../utils/focus.js";
3
+ const useReturnFocusOnUnmount = (ref) => {
4
+ const previouslyFocusedElementRef = useRef(null);
5
+ useEffect(() => {
6
+ const activeElement = ref.current ? getDocumentActiveElement(ref.current) : null;
7
+ if (activeElement instanceof HTMLElement) {
8
+ previouslyFocusedElementRef.current = activeElement;
9
+ }
10
+ return () => {
11
+ if (previouslyFocusedElementRef.current instanceof HTMLElement && document.contains(previouslyFocusedElementRef.current)) {
12
+ previouslyFocusedElementRef.current.focus();
13
+ }
14
+ };
15
+ }, []);
16
+ };
17
+ export {
18
+ useReturnFocusOnUnmount
19
+ };
20
+ //# sourceMappingURL=useReturnFocusOnUnmount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReturnFocusOnUnmount.js","sources":["../../src/hooks/useReturnFocusOnUnmount.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nimport { getDocumentActiveElement } from '../utils/focus';\n\n/**\n * A hook that stores the currently focused element when the component mounts,\n * and returns focus to it when the component unmounts.\n */\nexport const useReturnFocusOnUnmount = (ref: React.RefObject<HTMLElement>): void => {\n const previouslyFocusedElementRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n // Captures which element was focused on mount\n // const activeElement = document.activeElement;\n const activeElement = ref.current ? getDocumentActiveElement(ref.current) : null;\n if (activeElement instanceof HTMLElement) {\n previouslyFocusedElementRef.current = activeElement;\n }\n\n // Restores focus to the stored element on unmount\n return (): void => {\n if (previouslyFocusedElementRef.current instanceof HTMLElement && document.contains(previouslyFocusedElementRef.current)) {\n previouslyFocusedElementRef.current.focus();\n }\n };\n }, []);\n};\n"],"names":[],"mappings":";;AAQa,MAAA,0BAA0B,CAAC,QAA4C;AAC5E,QAAA,8BAA8B,OAA2B,IAAI;AAEnE,YAAU,MAAM;AAGd,UAAM,gBAAgB,IAAI,UAAU,yBAAyB,IAAI,OAAO,IAAI;AAC5E,QAAI,yBAAyB,aAAa;AACxC,kCAA4B,UAAU;AAAA,IAAA;AAIxC,WAAO,MAAY;AACjB,UAAI,4BAA4B,mBAAmB,eAAe,SAAS,SAAS,4BAA4B,OAAO,GAAG;AACxH,oCAA4B,QAAQ,MAAM;AAAA,MAAA;AAAA,IAE9C;AAAA,EACF,GAAG,EAAE;AACP;"}
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "git+https://github.com/helsenorge/designsystem.git"
8
8
  },
9
9
  "homepage": "https://helsenorge.design",
10
- "version": "10.0.2",
10
+ "version": "10.2.0",
11
11
  "author": "Helsenorge",
12
12
  "license": "MIT",
13
13
  "dependencies": {
@@ -21,3 +21,9 @@ $container-max-widths: (
21
21
  md: 612px,
22
22
  lg: 1056px,
23
23
  );
24
+
25
+ @mixin tiny-screens-media-query {
26
+ @media (width <= 319px), (height <= 308px) {
27
+ @content;
28
+ }
29
+ }
@@ -135,6 +135,28 @@
135
135
  }
136
136
  }
137
137
 
138
+ @mixin sublabel {
139
+ font-size: 1rem;
140
+ line-height: 1.2rem;
141
+ font-weight: 600;
142
+
143
+ @media (min-width: map.get($grid-breakpoints, md)) {
144
+ font-size: 1.125rem;
145
+ line-height: 1.463rem;
146
+ }
147
+ }
148
+
149
+ @mixin sublabel-subdued {
150
+ font-size: 1rem;
151
+ line-height: 1.2rem;
152
+ font-weight: 400;
153
+
154
+ @media (min-width: map.get($grid-breakpoints, md)) {
155
+ font-size: 1.125rem;
156
+ line-height: 1.463rem;
157
+ }
158
+ }
159
+
138
160
  @mixin compact-data {
139
161
  font-size: 1rem;
140
162
  line-height: 1.5rem;
@@ -183,3 +205,36 @@
183
205
  line-height: 1.75rem;
184
206
  }
185
207
  }
208
+
209
+ @mixin text-list {
210
+ font-size: 1.125rem;
211
+ line-height: 1.375rem;
212
+ font-weight: 400;
213
+
214
+ @media (min-width: map.get($grid-breakpoints, md)) {
215
+ font-size: 1.25rem;
216
+ line-height: 1.625rem;
217
+ }
218
+ }
219
+
220
+ @mixin definition-list-type {
221
+ font-size: 1.125rem;
222
+ line-height: 1.375rem;
223
+ font-weight: 600;
224
+
225
+ @media (min-width: map.get($grid-breakpoints, md)) {
226
+ font-size: 1.25rem;
227
+ line-height: 1.625rem;
228
+ }
229
+ }
230
+
231
+ @mixin definition-list-data {
232
+ font-size: 1.125rem;
233
+ line-height: 1.375rem;
234
+ font-weight: 400;
235
+
236
+ @media (min-width: map.get($grid-breakpoints, md)) {
237
+ font-size: 1.25rem;
238
+ line-height: 1.625rem;
239
+ }
240
+ }
@@ -60,6 +60,18 @@ import designsystemtypography from './scss/typography.scss'
60
60
  @include label;
61
61
  }
62
62
 
63
+ .label-subdued {
64
+ @include label-subdued;
65
+ }
66
+
67
+ .sublabel {
68
+ @include sublabel;
69
+ }
70
+
71
+ .sublabel-subdued {
72
+ @include sublabel-subdued;
73
+ }
74
+
63
75
  .compact-data {
64
76
  @include compact-data;
65
77
  }
@@ -107,6 +119,18 @@ import designsystemtypography from './scss/typography.scss'
107
119
  @include input-text-large;
108
120
  }
109
121
 
122
+ .text-list {
123
+ @include text-list;
124
+ }
125
+
126
+ .definition-list-type {
127
+ @include definition-list-type;
128
+ }
129
+
130
+ .definition-list-data {
131
+ @include definition-list-data;
132
+ }
133
+
110
134
  .anchorlink-wrapper {
111
135
  a {
112
136
  display: inline;
@@ -2,6 +2,8 @@ export type Styles = {
2
2
  'anchorlink-wrapper': string;
3
3
  body: string;
4
4
  'compact-data': string;
5
+ 'definition-list-data': string;
6
+ 'definition-list-type': string;
5
7
  'focused-content': string;
6
8
  form: string;
7
9
  'image-caption': string;
@@ -9,11 +11,15 @@ export type Styles = {
9
11
  'input-text': string;
10
12
  'input-text-large': string;
11
13
  label: string;
14
+ 'label-subdued': string;
12
15
  legend: string;
13
16
  preamble: string;
14
17
  'status-timestamp': string;
15
18
  strong: string;
19
+ sublabel: string;
20
+ 'sublabel-subdued': string;
16
21
  'table-cell': string;
22
+ 'text-list': string;
17
23
  'title-feature': string;
18
24
  title1: string;
19
25
  title2: string;
@@ -65,6 +65,18 @@ export const Label: Story = {
65
65
  render: args => <div className={designsystemtypography.label}>{args.tekst}</div>,
66
66
  };
67
67
 
68
+ export const LabelSubdued: Story = {
69
+ render: args => <div className={designsystemtypography['label-subdued']}>{args.tekst}</div>,
70
+ };
71
+
72
+ export const Sublabel: Story = {
73
+ render: args => <div className={designsystemtypography.sublabel}>{args.tekst}</div>,
74
+ };
75
+
76
+ export const SublabelSubdued: Story = {
77
+ render: args => <div className={designsystemtypography['sublabel-subdued']}>{args.tekst}</div>,
78
+ };
79
+
68
80
  export const CompactData: Story = {
69
81
  render: args => <div className={designsystemtypography['compact-data']}>{args.tekst}</div>,
70
82
  };
@@ -97,6 +109,18 @@ export const InputTextLarge: Story = {
97
109
  render: args => <div className={designsystemtypography['input-text-large']}>{args.tekst}</div>,
98
110
  };
99
111
 
112
+ export const TextList: Story = {
113
+ render: args => <div className={designsystemtypography['text-list']}>{args.tekst}</div>,
114
+ };
115
+
116
+ export const DefinitionListType: Story = {
117
+ render: args => <div className={designsystemtypography['definition-list-type']}>{args.tekst}</div>,
118
+ };
119
+
120
+ export const DefinitionListData: Story = {
121
+ render: args => <div className={designsystemtypography['definition-list-data']}>{args.tekst}</div>,
122
+ };
123
+
100
124
  export const AnchorlinkWrapper: Story = {
101
125
  render: args => (
102
126
  <div className={designsystemtypography['anchorlink-wrapper']}>
package/theme/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { screen, breakpoints } from "./grid.js";
1
+ import { breakpoints, screen } from "./grid.js";
2
2
  import { palette } from "./palette.js";
3
- import { spacer, spacers } from "./spacers.js";
3
+ import { spacers, spacer } from "./spacers.js";
4
4
  const theme = {
5
5
  spacer,
6
6
  spacers,