@helsenorge/designsystem-react 15.2.0 → 15.4.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 (234) hide show
  1. package/lib/AnchorLink.js +2 -2
  2. package/lib/AnchorLink.js.map +1 -1
  3. package/lib/Avatar.js +2 -2
  4. package/lib/Avatar.js.map +1 -1
  5. package/lib/Badge.js +2 -2
  6. package/lib/Badge.js.map +1 -1
  7. package/lib/Button.js +7 -7
  8. package/lib/Button.js.map +1 -1
  9. package/lib/CHANGELOG.md +23 -0
  10. package/lib/Checkbox.js +5 -5
  11. package/lib/Checkbox.js.map +1 -1
  12. package/lib/Checkbox2.js +2 -2
  13. package/lib/Checkbox2.js.map +1 -1
  14. package/lib/CheckboxMarker.js +2 -2
  15. package/lib/CheckboxMarker.js.map +1 -1
  16. package/lib/Chip.js +4 -4
  17. package/lib/Chip.js.map +1 -1
  18. package/lib/Close.js +3 -3
  19. package/lib/Close.js.map +1 -1
  20. package/lib/DictionaryTrigger.js +2 -2
  21. package/lib/DictionaryTrigger.js.map +1 -1
  22. package/lib/Drawer.js +56 -39
  23. package/lib/Drawer.js.map +1 -1
  24. package/lib/DrawerNavigation.js +107 -8
  25. package/lib/DrawerNavigation.js.map +1 -1
  26. package/lib/Duolist.js +5 -5
  27. package/lib/Duolist.js.map +1 -1
  28. package/lib/ElementHeader.js +9 -9
  29. package/lib/ElementHeader.js.map +1 -1
  30. package/lib/ElementHeaderText.js +4 -4
  31. package/lib/ElementHeaderText.js.map +1 -1
  32. package/lib/ErrorWrapper.js +2 -2
  33. package/lib/ErrorWrapper.js.map +1 -1
  34. package/lib/Expander.js +8 -8
  35. package/lib/Expander.js.map +1 -1
  36. package/lib/FilterButton.js +2 -2
  37. package/lib/FilterButton.js.map +1 -1
  38. package/lib/FilterButtonAndChipsWrapper.js +2 -2
  39. package/lib/FilterButtonAndChipsWrapper.js.map +1 -1
  40. package/lib/FilterDrawer.js +0 -2
  41. package/lib/FilterDrawer.js.map +1 -1
  42. package/lib/FilterLinkList.js +4 -4
  43. package/lib/FilterLinkList.js.map +1 -1
  44. package/lib/FilterOverviewSearch.js +2 -2
  45. package/lib/FilterOverviewSearch.js.map +1 -1
  46. package/lib/FilterSearch.js +6 -6
  47. package/lib/FilterSearch.js.map +1 -1
  48. package/lib/FormFieldTag.js +2 -2
  49. package/lib/FormFieldTag.js.map +1 -1
  50. package/lib/FormGroup.js +5 -5
  51. package/lib/FormGroup.js.map +1 -1
  52. package/lib/FormLayout.js +3 -3
  53. package/lib/FormLayout.js.map +1 -1
  54. package/lib/HelpDetails.js +3 -3
  55. package/lib/HelpDetails.js.map +1 -1
  56. package/lib/HelpTriggerIcon.js +2 -2
  57. package/lib/HelpTriggerIcon.js.map +1 -1
  58. package/lib/HelpTriggerStandalone.js +2 -2
  59. package/lib/HelpTriggerStandalone.js.map +1 -1
  60. package/lib/HighlightPanel.js +3 -3
  61. package/lib/HighlightPanel.js.map +1 -1
  62. package/lib/HorizontalScroll.js +4 -4
  63. package/lib/HorizontalScroll.js.map +1 -1
  64. package/lib/Icon.js +2 -2
  65. package/lib/Icon.js.map +1 -1
  66. package/lib/InfoTeaser.js +12 -11
  67. package/lib/InfoTeaser.js.map +1 -1
  68. package/lib/Input.js +4 -4
  69. package/lib/Input.js.map +1 -1
  70. package/lib/LazyIcon.js +2 -0
  71. package/lib/LazyIcon.js.map +1 -1
  72. package/lib/LinkList.js +5 -5
  73. package/lib/LinkList.js.map +1 -1
  74. package/lib/List.js +2 -2
  75. package/lib/List.js.map +1 -1
  76. package/lib/ListEditMode.js +4 -4
  77. package/lib/ListEditMode.js.map +1 -1
  78. package/lib/MaxCharacters.js +2 -2
  79. package/lib/MaxCharacters.js.map +1 -1
  80. package/lib/PanelTitle.js +2 -2
  81. package/lib/PanelTitle.js.map +1 -1
  82. package/lib/PopOver.js +2 -2
  83. package/lib/PopOver.js.map +1 -1
  84. package/lib/Radio.js +2 -2
  85. package/lib/Radio.js.map +1 -1
  86. package/lib/RadioButton.js +4 -4
  87. package/lib/RadioButton.js.map +1 -1
  88. package/lib/RadioMarker.js +2 -2
  89. package/lib/RadioMarker.js.map +1 -1
  90. package/lib/Select.js +4 -4
  91. package/lib/Select.js.map +1 -1
  92. package/lib/SingleSelectItem.js +3 -3
  93. package/lib/SingleSelectItem.js.map +1 -1
  94. package/lib/Slider.js +4 -4
  95. package/lib/Slider.js.map +1 -1
  96. package/lib/Spacer.js +2 -2
  97. package/lib/Spacer.js.map +1 -1
  98. package/lib/StatusDot.js +4 -4
  99. package/lib/StatusDot.js.map +1 -1
  100. package/lib/StatusDotList.js +2 -2
  101. package/lib/StatusDotList.js.map +1 -1
  102. package/lib/StepButtons.js +5 -5
  103. package/lib/StepButtons.js.map +1 -1
  104. package/lib/TabList.js +8 -8
  105. package/lib/TabList.js.map +1 -1
  106. package/lib/TabPanel.js +2 -2
  107. package/lib/TabPanel.js.map +1 -1
  108. package/lib/TableBody.js +2 -2
  109. package/lib/TableBody.js.map +1 -1
  110. package/lib/TableCell.js +2 -2
  111. package/lib/TableCell.js.map +1 -1
  112. package/lib/TableExpandedRow.js +4 -4
  113. package/lib/TableExpandedRow.js.map +1 -1
  114. package/lib/TableExpanderCell.js +2 -2
  115. package/lib/TableExpanderCell.js.map +1 -1
  116. package/lib/TableHead.js +2 -2
  117. package/lib/TableHead.js.map +1 -1
  118. package/lib/TableHeadCell.js +3 -3
  119. package/lib/TableHeadCell.js.map +1 -1
  120. package/lib/TableRow.js +3 -3
  121. package/lib/TableRow.js.map +1 -1
  122. package/lib/Textarea.js +4 -4
  123. package/lib/Textarea.js.map +1 -1
  124. package/lib/Title.js +2 -2
  125. package/lib/Title.js.map +1 -1
  126. package/lib/Toast.js +3 -3
  127. package/lib/Toast.js.map +1 -1
  128. package/lib/VisualCheckbox.js +3 -3
  129. package/lib/VisualCheckbox.js.map +1 -1
  130. package/lib/VisualRadio.js +3 -3
  131. package/lib/VisualRadio.js.map +1 -1
  132. package/lib/components/ArticleTeaser/index.js +4 -4
  133. package/lib/components/ArticleTeaser/index.js.map +1 -1
  134. package/lib/components/Drawer/Drawer.d.ts +6 -1
  135. package/lib/components/Drawer/DrawerHeaderContent.d.ts +22 -0
  136. package/lib/components/Drawer/DrawerHeaderContent.module.scss +51 -0
  137. package/lib/components/Drawer/DrawerHeaderContent.module.scss.d.ts +12 -0
  138. package/lib/components/Drawer/styles.module.scss +20 -10
  139. package/lib/components/Drawer/styles.module.scss.d.ts +3 -2
  140. package/lib/components/Dropdown/index.js +5 -5
  141. package/lib/components/Dropdown/index.js.map +1 -1
  142. package/lib/components/DropdownOld/index.js +3 -3
  143. package/lib/components/DropdownOld/index.js.map +1 -1
  144. package/lib/components/EmptyState/index.js +2 -2
  145. package/lib/components/EmptyState/index.js.map +1 -1
  146. package/lib/components/ExpanderHierarchy/index.js +7 -7
  147. package/lib/components/ExpanderHierarchy/index.js.map +1 -1
  148. package/lib/components/ExpanderList/index.js +6 -6
  149. package/lib/components/ExpanderList/index.js.map +1 -1
  150. package/lib/components/FavoriteButton/index.js +2 -2
  151. package/lib/components/FavoriteButton/index.js.map +1 -1
  152. package/lib/components/Filter/DrawerNavigation/styles.module.scss +15 -0
  153. package/lib/components/Filter/DrawerNavigation/styles.module.scss.d.ts +11 -0
  154. package/lib/components/Filter/FilterDrawer/styles.module.scss +0 -11
  155. package/lib/components/Filter/FilterDrawer/styles.module.scss.d.ts +0 -1
  156. package/lib/components/HelpBubble/index.js +3 -3
  157. package/lib/components/HelpBubble/index.js.map +1 -1
  158. package/lib/components/HelpDrawer/HelpDrawer.d.ts +1 -1
  159. package/lib/components/HelpDrawer/index.js +2 -1
  160. package/lib/components/HelpDrawer/index.js.map +1 -1
  161. package/lib/components/HelpPanel/index.js +2 -2
  162. package/lib/components/HelpPanel/index.js.map +1 -1
  163. package/lib/components/HelpTriggerInline/index.js +2 -2
  164. package/lib/components/HelpTriggerInline/index.js.map +1 -1
  165. package/lib/components/Highlighter/styles.module.scss +1 -1
  166. package/lib/components/Icons/AdditionalIconInformation.d.ts +12 -0
  167. package/lib/components/Icons/AdditionalIconInformation.js +13 -1
  168. package/lib/components/Icons/AdditionalIconInformation.js.map +1 -1
  169. package/lib/components/Icons/IconNames.d.ts +1 -1
  170. package/lib/components/Icons/IconNames.js +2 -0
  171. package/lib/components/Icons/IconNames.js.map +1 -1
  172. package/lib/components/Icons/ThumbsDown.d.ts +4 -0
  173. package/lib/components/Icons/ThumbsDown.js +15 -0
  174. package/lib/components/Icons/ThumbsDown.js.map +1 -0
  175. package/lib/components/Icons/ThumbsUp.d.ts +4 -0
  176. package/lib/components/Icons/ThumbsUp.js +15 -0
  177. package/lib/components/Icons/ThumbsUp.js.map +1 -0
  178. package/lib/components/InfoTeaser/InfoTeaser.d.ts +4 -0
  179. package/lib/components/Loader/index.js +4 -4
  180. package/lib/components/Loader/index.js.map +1 -1
  181. package/lib/components/Modal/index.js +9 -9
  182. package/lib/components/Modal/index.js.map +1 -1
  183. package/lib/components/NotificationPanel/index.js +6 -6
  184. package/lib/components/NotificationPanel/index.js.map +1 -1
  185. package/lib/components/Panel/index.js +12 -12
  186. package/lib/components/Panel/index.js.map +1 -1
  187. package/lib/components/PanelList/index.js +3 -3
  188. package/lib/components/PanelList/index.js.map +1 -1
  189. package/lib/components/PopMenu/index.js +3 -3
  190. package/lib/components/PopMenu/index.js.map +1 -1
  191. package/lib/components/Progressbar/index.js +2 -2
  192. package/lib/components/Progressbar/index.js.map +1 -1
  193. package/lib/components/PromoPanel/index.js +2 -2
  194. package/lib/components/PromoPanel/index.js.map +1 -1
  195. package/lib/components/ServiceMessage/index.js +5 -5
  196. package/lib/components/ServiceMessage/index.js.map +1 -1
  197. package/lib/components/SharingStatus/index.js +4 -4
  198. package/lib/components/SharingStatus/index.js.map +1 -1
  199. package/lib/components/Step/index.js +2 -2
  200. package/lib/components/Step/index.js.map +1 -1
  201. package/lib/components/Stepper/index.js +2 -2
  202. package/lib/components/Stepper/index.js.map +1 -1
  203. package/lib/components/StickyNote/index.js +8 -8
  204. package/lib/components/StickyNote/index.js.map +1 -1
  205. package/lib/components/Table/index.js +2 -2
  206. package/lib/components/Table/index.js.map +1 -1
  207. package/lib/components/Tabs/index.js +4 -4
  208. package/lib/components/Tabs/index.js.map +1 -1
  209. package/lib/components/Tag/constants.d.ts +2 -1
  210. package/lib/components/Tag/index.js +3 -2
  211. package/lib/components/Tag/index.js.map +1 -1
  212. package/lib/components/Tag/styles.module.scss +5 -0
  213. package/lib/components/Tag/styles.module.scss.d.ts +1 -0
  214. package/lib/components/Tile/index.js +4 -4
  215. package/lib/components/Tile/index.js.map +1 -1
  216. package/lib/components/Toggle/index.js +7 -7
  217. package/lib/components/Toggle/index.js.map +1 -1
  218. package/lib/components/Validation/index.js +2 -2
  219. package/lib/components/Validation/index.js.map +1 -1
  220. package/lib/components/VisualCheckboxCloud/index.js +2 -2
  221. package/lib/components/VisualCheckboxCloud/index.js.map +1 -1
  222. package/lib/components/VisualCheckboxGroup/index.js +3 -3
  223. package/lib/components/VisualCheckboxGroup/index.js.map +1 -1
  224. package/lib/components/VisualContentgroupWithImage/index.js +2 -2
  225. package/lib/components/VisualContentgroupWithImage/index.js.map +1 -1
  226. package/lib/components/VisualRadioCloud/index.js +2 -2
  227. package/lib/components/VisualRadioCloud/index.js.map +1 -1
  228. package/lib/components/VisualRadioGroup/index.js +3 -3
  229. package/lib/components/VisualRadioGroup/index.js.map +1 -1
  230. package/lib/hooks/useFocusTrap.js +4 -2
  231. package/lib/hooks/useFocusTrap.js.map +1 -1
  232. package/lib/utils2.js +7 -7
  233. package/lib/utils2.js.map +1 -1
  234. package/package.json +1 -1
package/lib/Toast.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.js","names":[],"sources":["../src/components/Toast/Toast.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport CheckFill from '../Icons/CheckFill';\n\nimport styles from './styles.module.scss';\n\nexport interface ToastProps {\n /** Sets the data-testid attribute. */\n testId?: string;\n /** The title to display in the toast */\n title: string;\n /** The message to display in the toast */\n message?: string;\n /** Callback when toast is closed */\n onClose?: () => void;\n}\n\nconst Toast: React.FC<ToastProps> = ({ testId, title, message, onClose }) => {\n const isMobile = useIsMobileBreakpoint();\n\n const handleClose = (): void => {\n if (onClose) {\n onClose();\n }\n };\n\n return (\n <output className={styles['toast']} data-testid={testId}>\n <Icon\n size={isMobile ? IconSize.XSmall : IconSize.Small}\n svgIcon={CheckFill}\n className={classNames(styles['toast__icon'], styles['toast__icon--check'])}\n />\n <div className={styles['toast__text-container']}>\n <span className={styles['toast__title']}>{title}</span>\n {message && <span className={styles['toast__description']}>{message}</span>}\n </div>\n <Close\n onClick={handleClose}\n color=\"black\"\n className={classNames(styles['toast__icon'], styles['toast__icon--close'])}\n testId={`${testId}-close`}\n />\n </output>\n );\n};\n\nexport default Toast;\n"],"mappings":";;;;;;;;;AAoBA,IAAM,SAA+B,EAAE,QAAQ,OAAO,SAAS,cAAc;CAC3E,MAAM,WAAW,sBAAsB;CAEvC,MAAM,oBAA0B;EAC9B,IAAI,SACF,QAAQ;CAEZ;CAEA,OACE,qBAAC,UAAD;EAAQ,WAAW,OAAO;EAAU,eAAa;YAAjD;GACE,oBAAC,cAAD;IACE,MAAM,WAAW,SAAS,SAAS,SAAS;IAC5C,SAAS;IACT,WAAW,WAAW,OAAO,gBAAgB,OAAO,qBAAqB;GAC1E,CAAA;GACD,qBAAC,OAAD;IAAK,WAAW,OAAO;cAAvB,CACE,oBAAC,QAAD;KAAM,WAAW,OAAO;eAAkB;IAAY,CAAA,GACrD,WAAW,oBAAC,QAAD;KAAM,WAAW,OAAO;eAAwB;IAAc,CAAA,CACvE;;GACL,oBAAC,eAAD;IACE,SAAS;IACT,OAAM;IACN,WAAW,WAAW,OAAO,gBAAgB,OAAO,qBAAqB;IACzE,QAAQ,GAAG,OAAO;GACnB,CAAA;EACK;;AAEZ"}
1
+ {"version":3,"file":"Toast.js","names":[],"sources":["../src/components/Toast/Toast.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport CheckFill from '../Icons/CheckFill';\n\nimport styles from './styles.module.scss';\n\nexport interface ToastProps {\n /** Sets the data-testid attribute. */\n testId?: string;\n /** The title to display in the toast */\n title: string;\n /** The message to display in the toast */\n message?: string;\n /** Callback when toast is closed */\n onClose?: () => void;\n}\n\nconst Toast: React.FC<ToastProps> = ({ testId, title, message, onClose }) => {\n const isMobile = useIsMobileBreakpoint();\n\n const handleClose = (): void => {\n if (onClose) {\n onClose();\n }\n };\n\n return (\n <output className={styles['toast']} data-testid={testId}>\n <Icon\n size={isMobile ? IconSize.XSmall : IconSize.Small}\n svgIcon={CheckFill}\n className={classNames(styles['toast__icon'], styles['toast__icon--check'])}\n />\n <div className={styles['toast__text-container']}>\n <span className={styles['toast__title']}>{title}</span>\n {message && <span className={styles['toast__description']}>{message}</span>}\n </div>\n <Close\n onClick={handleClose}\n color=\"black\"\n className={classNames(styles['toast__icon'], styles['toast__icon--close'])}\n testId={`${testId}-close`}\n />\n </output>\n );\n};\n\nexport default Toast;\n"],"mappings":";;;;;;;;;AAoBA,IAAM,SAA+B,EAAE,QAAQ,OAAO,SAAS,cAAc;CAC3E,MAAM,WAAW,sBAAsB;CAEvC,MAAM,oBAA0B;EAC9B,IAAI,SACF,QAAQ;CAEZ;CAEA,OACE,qBAAC,UAAD;EAAQ,WAAW,OAAO;EAAU,eAAa;YAAjD;GACE,oBAAC,cAAD;IACE,MAAM,WAAW,SAAS,SAAS,SAAS;IAC5C,SAAS;IACT,WAAW,GAAW,OAAO,gBAAgB,OAAO,qBAAqB;GAC1E,CAAA;GACD,qBAAC,OAAD;IAAK,WAAW,OAAO;cAAvB,CACE,oBAAC,QAAD;KAAM,WAAW,OAAO;eAAkB;IAAY,CAAA,GACrD,WAAW,oBAAC,QAAD;KAAM,WAAW,OAAO;eAAwB;IAAc,CAAA,CACvE;;GACL,oBAAC,eAAD;IACE,SAAS;IACT,OAAM;IACN,WAAW,GAAW,OAAO,gBAAgB,OAAO,qBAAqB;IACzE,QAAQ,GAAG,OAAO;GACnB,CAAA;EACK;;AAEZ"}
@@ -3,7 +3,7 @@ import { t as CheckboxMarker } from "./CheckboxMarker.js";
3
3
  import { useIdWithFallback } from "./hooks/useIdWithFallback.js";
4
4
  import { getAriaDescribedBy } from "./utils/accessibility.js";
5
5
  import { t as ErrorWrapper_default } from "./ErrorWrapper.js";
6
- import classNames from "classnames";
6
+ import cn from "classnames";
7
7
  import { useState } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  import styles from "./components/VisualCheckboxGroup/VisualCheckbox/styles.module.scss";
@@ -11,7 +11,7 @@ import styles from "./components/VisualCheckboxGroup/VisualCheckbox/styles.modul
11
11
  var VisualContent = (props) => {
12
12
  const { children, className, testId } = props;
13
13
  return /* @__PURE__ */ jsx("span", {
14
- className: classNames(styles["visual-checkbox__visual-content"], className),
14
+ className: cn(styles["visual-checkbox__visual-content"], className),
15
15
  "data-testid": testId,
16
16
  "aria-hidden": "true",
17
17
  children
@@ -38,7 +38,7 @@ var VisualCheckbox = (props) => {
38
38
  errorText,
39
39
  errorTextId,
40
40
  children: /* @__PURE__ */ jsxs("label", {
41
- className: classNames(styles["visual-checkbox"], styles[`visual-checkbox--variant-${variant}`], {
41
+ className: cn(styles["visual-checkbox"], styles[`visual-checkbox--variant-${variant}`], {
42
42
  [styles["visual-checkbox--checked"]]: isChecked,
43
43
  [styles["visual-checkbox--invalid"]]: error
44
44
  }, className),
@@ -1 +1 @@
1
- {"version":3,"file":"VisualCheckbox.js","names":[],"sources":["../src/components/VisualCheckboxGroup/VisualCheckbox/VisualContent.tsx","../src/components/VisualCheckboxGroup/VisualCheckbox/VisualCheckbox.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport styles from './styles.module.scss';\n\nexport interface VisualContentProps {\n /** Content rendered inside the circular area – typically an <img> or illustration component. */\n children: React.ReactNode;\n /** Adds custom classes to the root element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const VisualContent: React.FC<VisualContentProps> = props => {\n const { children, className, testId } = props;\n\n return (\n <span className={classNames(styles['visual-checkbox__visual-content'], className)} data-testid={testId} aria-hidden=\"true\">\n {children}\n </span>\n );\n};\n\nexport default VisualContent;\n","import { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../../ErrorWrapper';\n\nimport VisualContent from './VisualContent';\nimport { AnalyticsId } from '../../../constants';\nimport { useIdWithFallback } from '../../../hooks/useIdWithFallback';\nimport { getAriaDescribedBy } from '../../../utils/accessibility';\nimport CheckboxMarker from '../../Checkbox/CheckboxMarker/CheckboxMarker';\nimport ErrorWrapper from '../../ErrorWrapper';\n\nimport styles from './styles.module.scss';\n\nexport type VisualCheckboxVariant = 'line' | 'rectangle';\n\nexport interface VisualCheckboxProps\n extends ErrorWrapperClassNameProps, Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'id' | 'className' | 'children' | 'size'> {\n /** Adds custom classes to the root element. */\n className?: string;\n /** Label rendered inside the checkbox frame. */\n children: string;\n /** Content rendered inside the circular visual slot. */\n visualContent: React.ReactNode;\n /** Layout variant. `line` is a thin horizontal pill, `rectangle` is a vertical card. */\n variant?: VisualCheckboxVariant;\n /** input id of the underlying checkbox */\n inputId?: string;\n /** Activates error styling. Can be true while errorText is empty (e.g. when used in a FormGroup). */\n error?: boolean;\n /** Error text to show above the component. */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref forwarded to the underlying input element. */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nconst VisualCheckbox: React.FC<VisualCheckboxProps> = props => {\n const {\n className,\n checked,\n defaultChecked,\n children,\n visualContent,\n variant = 'line',\n inputId: inputIdProp,\n errorText,\n error = !!errorText,\n errorTextId: errorTextIdProp,\n errorWrapperClassName,\n testId,\n onChange,\n ref,\n ...rest\n } = props;\n\n const inputId = useIdWithFallback(inputIdProp);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n const [isChecked, setIsChecked] = useState<boolean>(!!(checked ?? defaultChecked));\n const [prevChecked, setPrevChecked] = useState<boolean | undefined>(checked);\n if (prevChecked !== checked) {\n setPrevChecked(checked);\n if (checked !== undefined && checked !== isChecked) {\n setIsChecked(checked);\n }\n }\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>): void => {\n setIsChecked(e.target.checked);\n onChange?.(e);\n };\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <label\n className={classNames(\n styles['visual-checkbox'],\n styles[`visual-checkbox--variant-${variant}`],\n {\n [styles['visual-checkbox--checked']]: isChecked,\n [styles['visual-checkbox--invalid']]: error,\n },\n className\n )}\n htmlFor={inputId}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Checkbox}\n >\n <VisualContent>{visualContent}</VisualContent>\n <input\n {...rest}\n id={inputId}\n ref={ref}\n className={styles['visual-checkbox__input']}\n type=\"checkbox\"\n checked={isChecked}\n aria-invalid={error}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n onChange={handleChange}\n />\n <span className={styles['visual-checkbox__frame']}>\n <span className={styles['visual-checkbox__label']}>{children}</span>\n <CheckboxMarker checked={isChecked} error={error} size={'large'} />\n </span>\n </label>\n </ErrorWrapper>\n );\n};\n\nexport default VisualCheckbox;\n"],"mappings":";;;;;;;;;;AAaA,IAAa,iBAA8C,UAAS;CAClE,MAAM,EAAE,UAAU,WAAW,WAAW;CAExC,OACE,oBAAC,QAAD;EAAM,WAAW,WAAW,OAAO,oCAAoC,SAAS;EAAG,eAAa;EAAQ,eAAY;EACjH;CACG,CAAA;AAEV;;;ACoBA,IAAM,kBAAgD,UAAS;CAC7D,MAAM,EACJ,WACA,SACA,gBACA,UACA,eACA,UAAU,QACV,SAAS,aACT,WACA,QAAQ,CAAC,CAAC,WACV,aAAa,iBACb,uBACA,QACA,UACA,KACA,GAAG,SACD;CAEJ,MAAM,UAAU,kBAAkB,WAAW;CAC7C,MAAM,cAAc,kBAAkB,eAAe;CACrD,MAAM,CAAC,WAAW,gBAAgB,SAAkB,CAAC,EAAE,WAAW,eAAe;CACjF,MAAM,CAAC,aAAa,kBAAkB,SAA8B,OAAO;CAC3E,IAAI,gBAAgB,SAAS;EAC3B,eAAe,OAAO;EACtB,IAAI,YAAY,KAAA,KAAa,YAAY,WACvC,aAAa,OAAO;CAExB;CAEA,MAAM,gBAAgB,MAAiD;EACrE,aAAa,EAAE,OAAO,OAAO;EAC7B,WAAW,CAAC;CACd;CAEA,OACE,oBAAC,sBAAD;EAAc,WAAW;EAAkC;EAAwB;YACjF,qBAAC,SAAD;GACE,WAAW,WACT,OAAO,oBACP,OAAO,4BAA4B,YACnC;KACG,OAAO,8BAA8B;KACrC,OAAO,8BAA8B;GACxC,GACA,SACF;GACA,SAAS;GACT,eAAa;GACb,oBAAkB,YAAY;aAZhC;IAcE,oBAAC,eAAD,EAAA,UAAgB,cAA6B,CAAA;IAC7C,oBAAC,SAAD;KACE,GAAI;KACJ,IAAI;KACC;KACL,WAAW,OAAO;KAClB,MAAK;KACL,SAAS;KACT,gBAAc;KACd,oBAAkB,mBAAmB,OAAO,WAAW;KACvD,UAAU;IACX,CAAA;IACD,qBAAC,QAAD;KAAM,WAAW,OAAO;eAAxB,CACE,oBAAC,QAAD;MAAM,WAAW,OAAO;MAA4B;KAAe,CAAA,GACnE,oBAAC,gBAAD;MAAgB,SAAS;MAAkB;MAAO,MAAM;KAAU,CAAA,CAC9D;;GACD;;CACK,CAAA;AAElB"}
1
+ {"version":3,"file":"VisualCheckbox.js","names":[],"sources":["../src/components/VisualCheckboxGroup/VisualCheckbox/VisualContent.tsx","../src/components/VisualCheckboxGroup/VisualCheckbox/VisualCheckbox.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport styles from './styles.module.scss';\n\nexport interface VisualContentProps {\n /** Content rendered inside the circular area – typically an <img> or illustration component. */\n children: React.ReactNode;\n /** Adds custom classes to the root element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const VisualContent: React.FC<VisualContentProps> = props => {\n const { children, className, testId } = props;\n\n return (\n <span className={classNames(styles['visual-checkbox__visual-content'], className)} data-testid={testId} aria-hidden=\"true\">\n {children}\n </span>\n );\n};\n\nexport default VisualContent;\n","import { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../../ErrorWrapper';\n\nimport VisualContent from './VisualContent';\nimport { AnalyticsId } from '../../../constants';\nimport { useIdWithFallback } from '../../../hooks/useIdWithFallback';\nimport { getAriaDescribedBy } from '../../../utils/accessibility';\nimport CheckboxMarker from '../../Checkbox/CheckboxMarker/CheckboxMarker';\nimport ErrorWrapper from '../../ErrorWrapper';\n\nimport styles from './styles.module.scss';\n\nexport type VisualCheckboxVariant = 'line' | 'rectangle';\n\nexport interface VisualCheckboxProps\n extends ErrorWrapperClassNameProps, Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'id' | 'className' | 'children' | 'size'> {\n /** Adds custom classes to the root element. */\n className?: string;\n /** Label rendered inside the checkbox frame. */\n children: string;\n /** Content rendered inside the circular visual slot. */\n visualContent: React.ReactNode;\n /** Layout variant. `line` is a thin horizontal pill, `rectangle` is a vertical card. */\n variant?: VisualCheckboxVariant;\n /** input id of the underlying checkbox */\n inputId?: string;\n /** Activates error styling. Can be true while errorText is empty (e.g. when used in a FormGroup). */\n error?: boolean;\n /** Error text to show above the component. */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref forwarded to the underlying input element. */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nconst VisualCheckbox: React.FC<VisualCheckboxProps> = props => {\n const {\n className,\n checked,\n defaultChecked,\n children,\n visualContent,\n variant = 'line',\n inputId: inputIdProp,\n errorText,\n error = !!errorText,\n errorTextId: errorTextIdProp,\n errorWrapperClassName,\n testId,\n onChange,\n ref,\n ...rest\n } = props;\n\n const inputId = useIdWithFallback(inputIdProp);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n const [isChecked, setIsChecked] = useState<boolean>(!!(checked ?? defaultChecked));\n const [prevChecked, setPrevChecked] = useState<boolean | undefined>(checked);\n if (prevChecked !== checked) {\n setPrevChecked(checked);\n if (checked !== undefined && checked !== isChecked) {\n setIsChecked(checked);\n }\n }\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>): void => {\n setIsChecked(e.target.checked);\n onChange?.(e);\n };\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <label\n className={classNames(\n styles['visual-checkbox'],\n styles[`visual-checkbox--variant-${variant}`],\n {\n [styles['visual-checkbox--checked']]: isChecked,\n [styles['visual-checkbox--invalid']]: error,\n },\n className\n )}\n htmlFor={inputId}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Checkbox}\n >\n <VisualContent>{visualContent}</VisualContent>\n <input\n {...rest}\n id={inputId}\n ref={ref}\n className={styles['visual-checkbox__input']}\n type=\"checkbox\"\n checked={isChecked}\n aria-invalid={error}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n onChange={handleChange}\n />\n <span className={styles['visual-checkbox__frame']}>\n <span className={styles['visual-checkbox__label']}>{children}</span>\n <CheckboxMarker checked={isChecked} error={error} size={'large'} />\n </span>\n </label>\n </ErrorWrapper>\n );\n};\n\nexport default VisualCheckbox;\n"],"mappings":";;;;;;;;;;AAaA,IAAa,iBAA8C,UAAS;CAClE,MAAM,EAAE,UAAU,WAAW,WAAW;CAExC,OACE,oBAAC,QAAD;EAAM,WAAW,GAAW,OAAO,oCAAoC,SAAS;EAAG,eAAa;EAAQ,eAAY;EAC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3
3
  import { getAriaDescribedBy } from "./utils/accessibility.js";
4
4
  import { t as ErrorWrapper_default } from "./ErrorWrapper.js";
5
5
  import { t as RadioMarker } from "./RadioMarker.js";
6
- import classNames from "classnames";
6
+ import cn from "classnames";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  import styles from "./components/VisualRadioGroup/VisualRadio/styles.module.scss";
9
9
  //#region src/components/VisualRadioGroup/VisualRadio/VisualContent.tsx
10
10
  var VisualContent = (props) => {
11
11
  const { children, className, testId } = props;
12
12
  return /* @__PURE__ */ jsx("span", {
13
- className: classNames(styles["visual-radio__visual-content"], className),
13
+ className: cn(styles["visual-radio__visual-content"], className),
14
14
  "data-testid": testId,
15
15
  "aria-hidden": "true",
16
16
  children
@@ -27,7 +27,7 @@ var VisualRadio = (props) => {
27
27
  errorText,
28
28
  errorTextId,
29
29
  children: /* @__PURE__ */ jsxs("label", {
30
- className: classNames(styles["visual-radio"], styles[`visual-radio--variant-${variant}`], { [styles["visual-radio--invalid"]]: error }, className),
30
+ className: cn(styles["visual-radio"], styles[`visual-radio--variant-${variant}`], { [styles["visual-radio--invalid"]]: error }, className),
31
31
  htmlFor: inputId,
32
32
  "data-testid": testId,
33
33
  "data-analyticsid": AnalyticsId.RadioButton,
@@ -1 +1 @@
1
- {"version":3,"file":"VisualRadio.js","names":[],"sources":["../src/components/VisualRadioGroup/VisualRadio/VisualContent.tsx","../src/components/VisualRadioGroup/VisualRadio/VisualRadio.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport styles from './styles.module.scss';\n\nexport interface VisualContentProps {\n /** Content rendered inside the circular area – typically an <img> or illustration component. */\n children: React.ReactNode;\n /** Adds custom classes to the root element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const VisualContent: React.FC<VisualContentProps> = props => {\n const { children, className, testId } = props;\n\n return (\n <span className={classNames(styles['visual-radio__visual-content'], className)} data-testid={testId} aria-hidden=\"true\">\n {children}\n </span>\n );\n};\n\nexport default VisualContent;\n","import classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../../ErrorWrapper';\n\nimport VisualContent from './VisualContent';\nimport { AnalyticsId } from '../../../constants';\nimport { useIdWithFallback } from '../../../hooks/useIdWithFallback';\nimport { getAriaDescribedBy } from '../../../utils/accessibility';\nimport ErrorWrapper from '../../ErrorWrapper';\nimport RadioMarker from '../../RadioButton/RadioMarker/RadioMarker';\n\nimport styles from './styles.module.scss';\n\nexport type VisualRadioVariant = 'line' | 'rectangle';\n\nexport interface VisualRadioProps\n extends ErrorWrapperClassNameProps, Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'id' | 'className' | 'children' | 'size'> {\n /** Adds custom classes to the root element. */\n className?: string;\n /** Label rendered inside the radio frame. */\n children: string;\n /** Content rendered inside the circular visual slot. */\n visualContent?: React.ReactNode;\n /** Layout variant. `line` is a thin horizontal pill, `rectangle` is a vertical card. */\n variant?: VisualRadioVariant;\n /** input id of the underlying radio */\n inputId?: string;\n /** Activates error styling. Can be true while errorText is empty (e.g. when used in a FormGroup). */\n error?: boolean;\n /** Error text to show above the component. */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref forwarded to the underlying input element. */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nconst VisualRadio: React.FC<VisualRadioProps> = props => {\n const {\n className,\n children,\n visualContent,\n variant = 'line',\n inputId: inputIdProp,\n errorText,\n error = !!errorText,\n errorTextId: errorTextIdProp,\n errorWrapperClassName,\n testId,\n ref,\n ...rest\n } = props;\n\n const inputId = useIdWithFallback(inputIdProp);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <label\n className={classNames(\n styles['visual-radio'],\n styles[`visual-radio--variant-${variant}`],\n { [styles['visual-radio--invalid']]: error },\n className\n )}\n htmlFor={inputId}\n data-testid={testId}\n data-analyticsid={AnalyticsId.RadioButton}\n >\n {visualContent !== undefined && <VisualContent>{visualContent}</VisualContent>}\n {/* eslint-disable-next-line jsx-a11y/role-supports-aria-props -- aria-invalid is a global ARIA state, valid on radio inputs */}\n <input\n {...rest}\n id={inputId}\n ref={ref}\n className={styles['visual-radio__input']}\n type=\"radio\"\n checked={rest.checked}\n aria-invalid={error}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n onChange={rest.onChange}\n />\n <span className={styles['visual-radio__frame']}>\n <span className={styles['visual-radio__label']}>{children}</span>\n <RadioMarker error={error} size={'large'} />\n </span>\n </label>\n </ErrorWrapper>\n );\n};\n\nexport default VisualRadio;\n"],"mappings":";;;;;;;;;AAaA,IAAa,iBAA8C,UAAS;CAClE,MAAM,EAAE,UAAU,WAAW,WAAW;CAExC,OACE,oBAAC,QAAD;EAAM,WAAW,WAAW,OAAO,iCAAiC,SAAS;EAAG,eAAa;EAAQ,eAAY;EAC9G;CACG,CAAA;AAEV;;;ACkBA,IAAM,eAA0C,UAAS;CACvD,MAAM,EACJ,WACA,UACA,eACA,UAAU,QACV,SAAS,aACT,WACA,QAAQ,CAAC,CAAC,WACV,aAAa,iBACb,uBACA,QACA,KACA,GAAG,SACD;CAEJ,MAAM,UAAU,kBAAkB,WAAW;CAC7C,MAAM,cAAc,kBAAkB,eAAe;CAErD,OACE,oBAAC,sBAAD;EAAc,WAAW;EAAkC;EAAwB;YACjF,qBAAC,SAAD;GACE,WAAW,WACT,OAAO,iBACP,OAAO,yBAAyB,YAChC,GAAG,OAAO,2BAA2B,MAAM,GAC3C,SACF;GACA,SAAS;GACT,eAAa;GACb,oBAAkB,YAAY;aAThC;IAWG,kBAAkB,KAAA,KAAa,oBAAC,eAAD,EAAA,UAAgB,cAA6B,CAAA;IAE7E,oBAAC,SAAD;KACE,GAAI;KACJ,IAAI;KACC;KACL,WAAW,OAAO;KAClB,MAAK;KACL,SAAS,KAAK;KACd,gBAAc;KACd,oBAAkB,mBAAmB,OAAO,WAAW;KACvD,UAAU,KAAK;IAChB,CAAA;IACD,qBAAC,QAAD;KAAM,WAAW,OAAO;eAAxB,CACE,oBAAC,QAAD;MAAM,WAAW,OAAO;MAAyB;KAAe,CAAA,GAChE,oBAAC,aAAD;MAAoB;MAAO,MAAM;KAAU,CAAA,CACvC;;GACD;;CACK,CAAA;AAElB"}
1
+ {"version":3,"file":"VisualRadio.js","names":[],"sources":["../src/components/VisualRadioGroup/VisualRadio/VisualContent.tsx","../src/components/VisualRadioGroup/VisualRadio/VisualRadio.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport styles from './styles.module.scss';\n\nexport interface VisualContentProps {\n /** Content rendered inside the circular area – typically an <img> or illustration component. */\n children: React.ReactNode;\n /** Adds custom classes to the root element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const VisualContent: React.FC<VisualContentProps> = props => {\n const { children, className, testId } = props;\n\n return (\n <span className={classNames(styles['visual-radio__visual-content'], className)} data-testid={testId} aria-hidden=\"true\">\n {children}\n </span>\n );\n};\n\nexport default VisualContent;\n","import classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../../ErrorWrapper';\n\nimport VisualContent from './VisualContent';\nimport { AnalyticsId } from '../../../constants';\nimport { useIdWithFallback } from '../../../hooks/useIdWithFallback';\nimport { getAriaDescribedBy } from '../../../utils/accessibility';\nimport ErrorWrapper from '../../ErrorWrapper';\nimport RadioMarker from '../../RadioButton/RadioMarker/RadioMarker';\n\nimport styles from './styles.module.scss';\n\nexport type VisualRadioVariant = 'line' | 'rectangle';\n\nexport interface VisualRadioProps\n extends ErrorWrapperClassNameProps, Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'id' | 'className' | 'children' | 'size'> {\n /** Adds custom classes to the root element. */\n className?: string;\n /** Label rendered inside the radio frame. */\n children: string;\n /** Content rendered inside the circular visual slot. */\n visualContent?: React.ReactNode;\n /** Layout variant. `line` is a thin horizontal pill, `rectangle` is a vertical card. */\n variant?: VisualRadioVariant;\n /** input id of the underlying radio */\n inputId?: string;\n /** Activates error styling. Can be true while errorText is empty (e.g. when used in a FormGroup). */\n error?: boolean;\n /** Error text to show above the component. */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref forwarded to the underlying input element. */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nconst VisualRadio: React.FC<VisualRadioProps> = props => {\n const {\n className,\n children,\n visualContent,\n variant = 'line',\n inputId: inputIdProp,\n errorText,\n error = !!errorText,\n errorTextId: errorTextIdProp,\n errorWrapperClassName,\n testId,\n ref,\n ...rest\n } = props;\n\n const inputId = useIdWithFallback(inputIdProp);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <label\n className={classNames(\n styles['visual-radio'],\n styles[`visual-radio--variant-${variant}`],\n { [styles['visual-radio--invalid']]: error },\n className\n )}\n htmlFor={inputId}\n data-testid={testId}\n data-analyticsid={AnalyticsId.RadioButton}\n >\n {visualContent !== undefined && <VisualContent>{visualContent}</VisualContent>}\n {/* eslint-disable-next-line jsx-a11y/role-supports-aria-props -- aria-invalid is a global ARIA state, valid on radio inputs */}\n <input\n {...rest}\n id={inputId}\n ref={ref}\n className={styles['visual-radio__input']}\n type=\"radio\"\n checked={rest.checked}\n aria-invalid={error}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n onChange={rest.onChange}\n />\n <span className={styles['visual-radio__frame']}>\n <span className={styles['visual-radio__label']}>{children}</span>\n <RadioMarker error={error} size={'large'} />\n </span>\n </label>\n </ErrorWrapper>\n );\n};\n\nexport default VisualRadio;\n"],"mappings":";;;;;;;;;AAaA,IAAa,iBAA8C,UAAS;CAClE,MAAM,EAAE,UAAU,WAAW,WAAW;CAExC,OACE,oBAAC,QAAD;EAAM,WAAW,GAAW,OAAO,iCAAiC,SAAS;EAAG,eAAa;EAAQ,eAAY;EAC9G;CACG,CAAA;AAEV;;;ACkBA,IAAM,eAA0C,UAAS;CACvD,MAAM,EACJ,WACA,UACA,eACA,UAAU,QACV,SAAS,aACT,WACA,QAAQ,CAAC,CAAC,WACV,aAAa,iBACb,uBACA,QACA,KACA,GAAG,SACD;CAEJ,MAAM,UAAU,kBAAkB,WAAW;CAC7C,MAAM,cAAc,kBAAkB,eAAe;CAErD,OACE,oBAAC,sBAAD;EAAc,WAAW;EAAkC;EAAwB;YACjF,qBAAC,SAAD;GACE,WAAW,GACT,OAAO,iBACP,OAAO,yBAAyB,YAChC,GAAG,OAAO,2BAA2B,MAAM,GAC3C,SACF;GACA,SAAS;GACT,eAAa;GACb,oBAAkB,YAAY;aAThC;IAWG,kBAAkB,KAAA,KAAa,oBAAC,eAAD,EAAA,UAAgB,cAA6B,CAAA;IAE7E,oBAAC,SAAD;KACE,GAAI;KACJ,IAAI;KACC;KACL,WAAW,OAAO;KAClB,MAAK;KACL,SAAS,KAAK;KACd,gBAAc;KACd,oBAAkB,mBAAmB,OAAO,WAAW;KACvD,UAAU,KAAK;IAChB,CAAA;IACD,qBAAC,QAAD;KAAM,WAAW,OAAO;eAAxB,CACE,oBAAC,QAAD;MAAM,WAAW,OAAO;MAAyB;KAAe,CAAA,GAChE,oBAAC,aAAD;MAAoB;MAAO,MAAM;KAAU,CAAA,CACvC;;GACD;;CACK,CAAA;AAElB"}
@@ -1,6 +1,6 @@
1
1
  import { AnalyticsId, LanguageLocales } from "../../constants.js";
2
2
  import { useLanguage } from "../../hooks/useLanguage.js";
3
- import classNames from "classnames";
3
+ import cn from "classnames";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import styles from "./styles.module.scss";
6
6
  var HN_Designsystem_ArticleTeaser_en_GB_default = {
@@ -31,16 +31,16 @@ var ArticleTeaser = (props) => {
31
31
  ...resources
32
32
  };
33
33
  return /* @__PURE__ */ jsxs(WrapperTag, {
34
- className: classNames(styles.articleteaser),
34
+ className: cn(styles.articleteaser),
35
35
  "data-testid": testId,
36
36
  "data-analyticsid": AnalyticsId.ArticleTeaser,
37
37
  children: [/* @__PURE__ */ jsx("div", {
38
- className: classNames(styles["articleteaser__content"], { [styles["articleteaser__content--collapsed"]]: !expanded }),
38
+ className: cn(styles["articleteaser__content"], { [styles["articleteaser__content--collapsed"]]: !expanded }),
39
39
  style: { maxHeight: expanded ? "none" : props.heightCollapsed },
40
40
  children
41
41
  }), /* @__PURE__ */ jsx("button", {
42
42
  type: "button",
43
- className: classNames(styles["articleteaser__button"], { [styles["articleteaser__button--expanded"]]: expanded }),
43
+ className: cn(styles["articleteaser__button"], { [styles["articleteaser__button--expanded"]]: expanded }),
44
44
  onClick: onExpand,
45
45
  "aria-expanded": expanded,
46
46
  "aria-controls": contentId,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/resources/HN.Designsystem.ArticleTeaser.en-GB.json","../../../src/resources/HN.Designsystem.ArticleTeaser.nb-NO.json","../../../src/components/ArticleTeaser/resourceHelper.ts","../../../src/components/ArticleTeaser/ArticleTeaser.tsx","../../../src/components/ArticleTeaser/index.ts"],"sourcesContent":["{\n \"expandButtonClose\": \"Show more\",\n \"expandButtonOpen\": \"Show less\"\n}\n","{\n \"expandButtonClose\": \"Vis mer\",\n \"expandButtonOpen\": \"Vis mindre\"\n}\n","import type { HNDesignsystemArticleTeaser } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.ArticleTeaser.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.ArticleTeaser.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemArticleTeaser => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import classNames from 'classnames';\n\nimport type { HNDesignsystemArticleTeaser } from '../../resources/Resources';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, LanguageLocales } from '../../constants';\nimport { useLanguage } from '../../hooks/useLanguage';\n\nimport styles from './styles.module.scss';\n\nexport type ArticleTeaserTags = 'div' | 'section' | 'aside' | 'article';\n\nexport interface ArticleTeaserProps {\n /** Callback for the button. Should be used for setting the expanded boolean */\n onExpand: () => void;\n /** What's in the box? */\n children: React.ReactNode;\n /** Id of the content, used to set aria-controls */\n contentId: string;\n /** If the component is expanded or not */\n expanded: boolean;\n /** For overriding the height of the collapsed teaser */\n heightCollapsed?: string;\n /** Changes the underlying element of the wrapper */\n htmlMarkup?: ArticleTeaserTags;\n /** Resources for component */\n resources?: Partial<HNDesignsystemArticleTeaser>;\n /** Sets the data-testid attribute */\n testId?: string;\n}\n\nconst ArticleTeaser: React.FC<ArticleTeaserProps> = props => {\n const { onExpand, children, contentId, expanded, htmlMarkup = 'div', resources, testId } = props;\n const WrapperTag = htmlMarkup;\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemArticleTeaser = {\n ...defaultResources,\n ...resources,\n };\n\n return (\n <WrapperTag className={classNames(styles.articleteaser)} data-testid={testId} data-analyticsid={AnalyticsId.ArticleTeaser}>\n <div\n className={classNames(styles['articleteaser__content'], {\n [styles['articleteaser__content--collapsed']]: !expanded,\n })}\n style={{\n maxHeight: expanded ? 'none' : props.heightCollapsed,\n }}\n >\n {children}\n </div>\n <button\n type=\"button\"\n className={classNames(styles['articleteaser__button'], {\n [styles['articleteaser__button--expanded']]: expanded,\n })}\n onClick={onExpand}\n aria-expanded={expanded}\n aria-controls={contentId}\n >\n {expanded ? mergedResources.expandButtonOpen : mergedResources.expandButtonClose}\n </button>\n </WrapperTag>\n );\n};\n\nexport default ArticleTeaser;\n","import ArticleTeaser from './ArticleTeaser';\nexport * from './ArticleTeaser';\nexport default ArticleTeaser;\n"],"mappings":";;;;;;;;;;;;;;;AEMA,IAAa,gBAAgB,aAA2D;CACtF,QAAQ,UAAR;EACE,KAAK,gBAAgB,SACnB,OAAO;EACT,KAAK,gBAAgB;EACrB,SACE,OAAO;CACX;AACF;;;ACiBA,IAAM,iBAA8C,UAAS;CAC3D,MAAM,EAAE,UAAU,UAAU,WAAW,UAAU,aAAa,OAAO,WAAW,WAAW;CAC3F,MAAM,aAAa;CAEnB,MAAM,EAAE,aAAa,YAA6B,gBAAgB,SAAS;CAG3E,MAAM,kBAA+C;EACnD,GAHuB,aAAa,QAGjC;EACH,GAAG;CACL;CAEA,OACE,qBAAC,YAAD;EAAY,WAAW,WAAW,OAAO,aAAa;EAAG,eAAa;EAAQ,oBAAkB,YAAY;YAA5G,CACE,oBAAC,OAAD;GACE,WAAW,WAAW,OAAO,2BAA2B,GACrD,OAAO,uCAAuC,CAAC,SAClD,CAAC;GACD,OAAO,EACL,WAAW,WAAW,SAAS,MAAM,gBACvC;GAEC;EACE,CAAA,GACL,oBAAC,UAAD;GACE,MAAK;GACL,WAAW,WAAW,OAAO,0BAA0B,GACpD,OAAO,qCAAqC,SAC/C,CAAC;GACD,SAAS;GACT,iBAAe;GACf,iBAAe;aAEd,WAAW,gBAAgB,mBAAmB,gBAAgB;EACzD,CAAA,CACE;;AAEhB;;;AClEA,IAAA,wBAAe"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/resources/HN.Designsystem.ArticleTeaser.en-GB.json","../../../src/resources/HN.Designsystem.ArticleTeaser.nb-NO.json","../../../src/components/ArticleTeaser/resourceHelper.ts","../../../src/components/ArticleTeaser/ArticleTeaser.tsx","../../../src/components/ArticleTeaser/index.ts"],"sourcesContent":["{\n \"expandButtonClose\": \"Show more\",\n \"expandButtonOpen\": \"Show less\"\n}\n","{\n \"expandButtonClose\": \"Vis mer\",\n \"expandButtonOpen\": \"Vis mindre\"\n}\n","import type { HNDesignsystemArticleTeaser } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.ArticleTeaser.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.ArticleTeaser.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemArticleTeaser => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import classNames from 'classnames';\n\nimport type { HNDesignsystemArticleTeaser } from '../../resources/Resources';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, LanguageLocales } from '../../constants';\nimport { useLanguage } from '../../hooks/useLanguage';\n\nimport styles from './styles.module.scss';\n\nexport type ArticleTeaserTags = 'div' | 'section' | 'aside' | 'article';\n\nexport interface ArticleTeaserProps {\n /** Callback for the button. Should be used for setting the expanded boolean */\n onExpand: () => void;\n /** What's in the box? */\n children: React.ReactNode;\n /** Id of the content, used to set aria-controls */\n contentId: string;\n /** If the component is expanded or not */\n expanded: boolean;\n /** For overriding the height of the collapsed teaser */\n heightCollapsed?: string;\n /** Changes the underlying element of the wrapper */\n htmlMarkup?: ArticleTeaserTags;\n /** Resources for component */\n resources?: Partial<HNDesignsystemArticleTeaser>;\n /** Sets the data-testid attribute */\n testId?: string;\n}\n\nconst ArticleTeaser: React.FC<ArticleTeaserProps> = props => {\n const { onExpand, children, contentId, expanded, htmlMarkup = 'div', resources, testId } = props;\n const WrapperTag = htmlMarkup;\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemArticleTeaser = {\n ...defaultResources,\n ...resources,\n };\n\n return (\n <WrapperTag className={classNames(styles.articleteaser)} data-testid={testId} data-analyticsid={AnalyticsId.ArticleTeaser}>\n <div\n className={classNames(styles['articleteaser__content'], {\n [styles['articleteaser__content--collapsed']]: !expanded,\n })}\n style={{\n maxHeight: expanded ? 'none' : props.heightCollapsed,\n }}\n >\n {children}\n </div>\n <button\n type=\"button\"\n className={classNames(styles['articleteaser__button'], {\n [styles['articleteaser__button--expanded']]: expanded,\n })}\n onClick={onExpand}\n aria-expanded={expanded}\n aria-controls={contentId}\n >\n {expanded ? mergedResources.expandButtonOpen : mergedResources.expandButtonClose}\n </button>\n </WrapperTag>\n );\n};\n\nexport default ArticleTeaser;\n","import ArticleTeaser from './ArticleTeaser';\nexport * from './ArticleTeaser';\nexport default ArticleTeaser;\n"],"mappings":";;;;;;;;;;;;;;;AEMA,IAAa,gBAAgB,aAA2D;CACtF,QAAQ,UAAR;EACE,KAAK,gBAAgB,SACnB,OAAO;EACT,KAAK,gBAAgB;EACrB,SACE,OAAO;CACX;AACF;;;ACiBA,IAAM,iBAA8C,UAAS;CAC3D,MAAM,EAAE,UAAU,UAAU,WAAW,UAAU,aAAa,OAAO,WAAW,WAAW;CAC3F,MAAM,aAAa;CAEnB,MAAM,EAAE,aAAa,YAA6B,gBAAgB,SAAS;CAG3E,MAAM,kBAA+C;EACnD,GAHuB,aAAa,QAGjC;EACH,GAAG;CACL;CAEA,OACE,qBAAC,YAAD;EAAY,WAAW,GAAW,OAAO,aAAa;EAAG,eAAa;EAAQ,oBAAkB,YAAY;YAA5G,CACE,oBAAC,OAAD;GACE,WAAW,GAAW,OAAO,2BAA2B,GACrD,OAAO,uCAAuC,CAAC,SAClD,CAAC;GACD,OAAO,EACL,WAAW,WAAW,SAAS,MAAM,gBACvC;GAEC;EACE,CAAA,GACL,oBAAC,UAAD;GACE,MAAK;GACL,WAAW,GAAW,OAAO,0BAA0B,GACpD,OAAO,qCAAqC,SAC/C,CAAC;GACD,SAAS;GACT,iBAAe;GACf,iBAAe;aAEd,WAAW,gBAAgB,mBAAmB,gBAAgB;EACzD,CAAA,CACE;;AAEhB;;;AClEA,IAAA,wBAAe"}
@@ -2,6 +2,7 @@ import { default as React } from 'react';
2
2
  import { HNDesignsystemDrawer } from '../../resources/Resources';
3
3
  import { TitleTags } from '../Title';
4
4
  type DesktopDirections = 'left' | 'right';
5
+ type PaddingSizes = 'normal' | 'extra';
5
6
  export interface DrawerProps extends InnerDrawerProps {
6
7
  /** Opens and closes the drawer */
7
8
  isOpen: boolean;
@@ -17,8 +18,10 @@ export interface InnerDrawerProps {
17
18
  desktopDirection?: DesktopDirections;
18
19
  /** Sets the style of the Drawer header */
19
20
  headerClasses?: string;
21
+ /** Optional content that replaces the default title (and back button) in the header. The close button is still rendered. */
22
+ headerContent?: React.ReactNode;
20
23
  /** Title to display in the header of the drawer */
21
- title: string;
24
+ title?: string;
22
25
  /** id of the drawer title */
23
26
  titleId?: string;
24
27
  /** Changes the underlying element of the title. Default: h3 */
@@ -51,6 +54,8 @@ export interface InnerDrawerProps {
51
54
  onRequestBack?: () => void;
52
55
  /** Sets classname for content part in Drawer */
53
56
  contentClassName?: string;
57
+ /** Sets the content padding of the Drawer */
58
+ paddingSize?: PaddingSizes;
54
59
  }
55
60
  declare const Drawer: React.FC<DrawerProps>;
56
61
  export default Drawer;
@@ -0,0 +1,22 @@
1
+ import { default as React } from 'react';
2
+ import { TitleTags } from '../Title';
3
+ export interface DrawerHeaderContentProps {
4
+ /** Title shown in the header */
5
+ title?: React.ReactNode;
6
+ /** id of the title element */
7
+ titleId?: string;
8
+ /** Ref passed to the title heading element */
9
+ titleRef?: React.Ref<HTMLHeadingElement | null>;
10
+ /** Changes the underlying element of the title. Default: h3 */
11
+ titleHtmlMarkup?: TitleTags;
12
+ /** Shows a back button before the title. When present the title is centered. */
13
+ withBackButton?: boolean;
14
+ /** Callback for the back button */
15
+ onRequestBack?: () => void;
16
+ /** Sets the aria-label of the back button */
17
+ backButtonAriaLabel?: string;
18
+ /** Adds custom classes to the root element. */
19
+ className?: string;
20
+ }
21
+ declare const DrawerHeaderContent: React.FC<DrawerHeaderContentProps>;
22
+ export default DrawerHeaderContent;
@@ -0,0 +1,51 @@
1
+ @use '../../scss/breakpoints' as breakpoints;
2
+
3
+ .header-content {
4
+ position: relative;
5
+ display: flex;
6
+ flex: 1;
7
+ align-items: center;
8
+ min-width: 0;
9
+ min-height: 100%;
10
+
11
+ @include breakpoints.tiny-screens-media-query {
12
+ flex-direction: column-reverse;
13
+ align-items: flex-start;
14
+ }
15
+
16
+ &__title {
17
+ display: flex;
18
+ align-self: flex-start;
19
+ align-items: center;
20
+ justify-content: flex-start;
21
+ margin-top: 0.5rem;
22
+
23
+ &--centered {
24
+ position: relative;
25
+ inset: 0;
26
+ align-items: flex-start;
27
+ margin: 0.5rem auto 0;
28
+ pointer-events: none;
29
+
30
+ @include breakpoints.tiny-screens-media-query {
31
+ position: static;
32
+ inset: auto;
33
+ justify-content: flex-start;
34
+ }
35
+ }
36
+
37
+ :focus,
38
+ :focus-visible {
39
+ outline: none;
40
+ }
41
+ }
42
+
43
+ &__back-button {
44
+ // Moves the button visually to the left but keeps it in the DOM order for screen readers and keyboard navigation
45
+ order: -1;
46
+
47
+ @include breakpoints.tiny-screens-media-query {
48
+ order: 0;
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,12 @@
1
+ export type Styles = {
2
+ 'header-content': string;
3
+ 'header-content__back-button': string;
4
+ 'header-content__title': string;
5
+ 'header-content__title--centered': string;
6
+ };
7
+
8
+ export type ClassNames = keyof Styles;
9
+
10
+ declare const styles: Styles;
11
+
12
+ export default styles;
@@ -82,23 +82,17 @@
82
82
  align-items: flex-start;
83
83
  }
84
84
 
85
- &__title {
86
- margin-top: 0.5rem !important;
85
+ &--padding-extra {
86
+ padding: var(--core-space-xs) var(--core-space-xs) var(--core-space-xs) var(--core-space-s);
87
87
 
88
- &:focus,
89
- &:focus-visible {
90
- outline: none;
88
+ @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
89
+ padding: var(--core-space-xs) var(--core-space-xs) var(--core-space-xs) var(--core-space-m);
91
90
  }
92
91
  }
93
92
 
94
93
  &__close-button {
95
94
  align-self: flex-start;
96
95
  }
97
-
98
- &__back-button {
99
- // Moves the button visually to the left but keeps it in the DOM order for screen readers and keyboard navigation
100
- order: -1;
101
- }
102
96
  }
103
97
 
104
98
  &__content {
@@ -119,6 +113,14 @@
119
113
  @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
120
114
  padding: var(--core-space-s) var(--core-space-xs);
121
115
  }
116
+
117
+ &--padding-extra {
118
+ padding: var(--core-space-xs) var(--core-space-s);
119
+
120
+ @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
121
+ padding: var(--core-space-xs) var(--core-space-m);
122
+ }
123
+ }
122
124
  }
123
125
 
124
126
  &__shadow {
@@ -181,5 +183,13 @@
181
183
  @supports (font: -apple-system-body) and (-webkit-appearance: none) {
182
184
  padding-bottom: 2.5rem;
183
185
  }
186
+
187
+ &--padding-extra {
188
+ padding: var(--core-space-s) var(--core-space-s);
189
+
190
+ @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
191
+ padding: var(--core-space-m) var(--core-space-m);
192
+ }
193
+ }
184
194
  }
185
195
  }
@@ -5,15 +5,16 @@ export type Styles = {
5
5
  'drawer__container--right': string;
6
6
  drawer__content: string;
7
7
  drawer__content__children: string;
8
+ 'drawer__content__children--padding-extra': string;
8
9
  drawer__content__shadow: string;
9
10
  'drawer__content__shadow--bottom': string;
10
11
  'drawer__content__shadow--show': string;
11
12
  'drawer__content__shadow--top': string;
12
13
  drawer__footer: string;
14
+ 'drawer__footer--padding-extra': string;
13
15
  drawer__header: string;
14
- 'drawer__header__back-button': string;
15
16
  'drawer__header__close-button': string;
16
- drawer__header__title: string;
17
+ 'drawer__header--padding-extra': string;
17
18
  drawer__overlay: string;
18
19
  };
19
20
 
@@ -18,7 +18,7 @@ import ChevronDown from "../Icons/ChevronDown.js";
18
18
  import ChevronUp from "../Icons/ChevronUp.js";
19
19
  import PlusSmall from "../Icons/PlusSmall.js";
20
20
  import Label_default from "../Label/index.js";
21
- import classNames from "classnames";
21
+ import cn from "classnames";
22
22
  import React, { useEffect, useId, useRef } from "react";
23
23
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
24
24
  import { clamp } from "motion/react";
@@ -86,14 +86,14 @@ var DropdownBase = (props) => {
86
86
  ...getResources(language),
87
87
  ...resources
88
88
  };
89
- const toggleClasses = classNames(styles.dropdown__toggle, {
89
+ const toggleClasses = cn(styles.dropdown__toggle, {
90
90
  [styles["dropdown__toggle--open"]]: isOpen && !disabled,
91
91
  [styles["dropdown__toggle--with-icon"]]: typeof svgIcon !== "undefined",
92
92
  [styles["dropdown__toggle--transparent"]]: variant === "transparent",
93
93
  [styles["dropdown__toggle--borderless"]]: variant === "borderless"
94
94
  });
95
- const contentClasses = classNames(styles.dropdown__content, isOpen && styles["dropdown__content--open"]);
96
- const listItemClasses = classNames(styles["dropdown__list-item"], { [styles["dropdown__list-item--single-select"]]: isSingleSelect });
95
+ const contentClasses = cn(styles.dropdown__content, isOpen && styles["dropdown__content--open"]);
96
+ const listItemClasses = cn(styles["dropdown__list-item"], { [styles["dropdown__list-item--single-select"]]: isSingleSelect });
97
97
  const { refs, floatingStyles } = useFloating({
98
98
  strategy: "fixed",
99
99
  placement: "bottom-start",
@@ -190,7 +190,7 @@ var DropdownBase = (props) => {
190
190
  const label = element.props.label;
191
191
  if (React.isValidElement(label) && isComponent(label, Label_default)) return React.cloneElement(element, {
192
192
  ref: mergeRefs([element.props.ref, childrenRefList.current[index]]),
193
- label: React.cloneElement(label, { labelClassName: classNames(label.props?.labelClassName, styles["dropdown__multiselect-item"]) })
193
+ label: React.cloneElement(label, { labelClassName: cn(label.props?.labelClassName, styles["dropdown__multiselect-item"]) })
194
194
  });
195
195
  }
196
196
  return React.cloneElement(child, { ref: mergeRefs([element.props.ref, childrenRefList.current[index]]) });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Dropdown/resourceHelper.ts","../../../src/components/Dropdown/SingleSelect/SingleSelect.tsx","../../../src/components/Dropdown/Dropdown.tsx","../../../src/components/Dropdown/index.ts"],"sourcesContent":["import type { HNDesignsystemDropdown } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Dropdown.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Dropdown.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemDropdown => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React from 'react';\n\nimport { SingleSelectContext } from './utils';\n\nexport type SingleSelectContextType = {\n name?: string;\n disabled?: boolean;\n required?: boolean;\n value?: string;\n onValueChange?: (newValue: string, e?: React.SyntheticEvent) => void;\n};\n\nexport interface SingleSelectProps {\n name?: string;\n disabled?: boolean;\n defaultValue?: string;\n onValueChange?: (newValue: string, e?: React.SyntheticEvent) => void;\n children: React.ReactNode;\n}\n\nexport const SingleSelect: React.FC<SingleSelectProps> = ({ name, disabled, defaultValue, onValueChange, children }) => {\n const [selected, setSelected] = React.useState<string | undefined>(defaultValue);\n\n const context = React.useMemo<SingleSelectContextType>(\n () => ({\n name,\n disabled,\n value: selected,\n onValueChange: (v, e): void => {\n setSelected(v);\n onValueChange?.(v, e);\n },\n }),\n [name, disabled, selected, onValueChange]\n );\n\n return <SingleSelectContext.Provider value={context}>{children}</SingleSelectContext.Provider>;\n};\n","import type { ComponentType } from 'react';\nimport React, { useEffect, useRef, useId } from 'react';\n\nimport { autoUpdate, offset, shift, size, useFloating, flip } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { clamp } from 'motion/react';\n\nimport type { SingleSelectItemProps } from './SingleSelect/SingleSelectItem';\nimport type { HNDesignsystemDropdown } from '../../resources/Resources';\nimport type { CheckboxProps } from '../Checkbox';\nimport type { SvgIcon } from '../Icon';\nimport type { IconName } from '../Icons/IconNames';\nimport type { LabelProps } from '../Label';\n\nimport {\n AnalyticsId,\n IconSize,\n KeyboardEventKey,\n LanguageLocales,\n ZIndex,\n usePseudoClasses,\n useKeyboardEvent,\n useOutsideEvent,\n useToggle,\n} from '../..';\nimport { getResources } from './resourceHelper';\nimport { SingleSelectItem } from './SingleSelect/SingleSelectItem';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { isComponent } from '../../utils/component';\nimport { mergeRefs } from '../../utils/refs';\nimport Button from '../Button';\nimport Checkbox from '../Checkbox';\nimport Icon from '../Icon';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronUp from '../Icons/ChevronUp';\nimport PlusSmall from '../Icons/PlusSmall';\nimport Label from '../Label';\nimport LazyIcon from '../LazyIcon';\nimport { SingleSelect } from './SingleSelect/SingleSelect';\n\nimport styles from './styles.module.scss';\n\ntype DropdownVariants = 'fill' | 'transparent' | 'borderless';\n\nexport interface DropdownProps {\n /** Text on the trigger button that opens the dropdown */\n triggerText: string;\n /** Sets the dropdown content */\n children: React.ReactNode;\n /** Minimum width for the dropdown in pixels. Does not affect trigger button. */\n dropdownMinWidth?: number;\n /** Minimum width for the trigger in pixels. Does not apply for borderless variant */\n triggerMinWidth?: number;\n /** Disables rendring of the close button in the list */\n noCloseButton?: boolean;\n /** Called when dropdown is open/closed */\n onToggle?: (isOpen: boolean) => void;\n /** Whether the dropdown is open or not */\n open?: boolean;\n /** Makes the dropdown disabled */\n disabled?: boolean;\n /** Sets the data-testid attribute on the dropdown button */\n testId?: string;\n /** Overrides the default z-index of the DropDownContent */\n zIndex?: number;\n /** Resources for component */\n resources?: Partial<HNDesignsystemDropdown>;\n /** Adds an icon to the trigger */\n svgIcon?: SvgIcon | IconName;\n /** Sets the visual variant of the Dropdown */\n variant?: DropdownVariants;\n}\n\nexport const DropdownBase: React.FC<DropdownProps> = props => {\n const {\n triggerText,\n noCloseButton = false,\n onToggle,\n dropdownMinWidth,\n triggerMinWidth,\n open = false,\n children,\n testId,\n disabled,\n zIndex = ZIndex.PopOver,\n resources,\n svgIcon,\n variant = 'fill',\n } = props;\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const optionsRef = useRef<HTMLUListElement>(null);\n const childrenRefList = useRef(React.Children.map(children, () => React.createRef<HTMLElement>()));\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const { isHovered } = usePseudoClasses<HTMLButtonElement | null>(buttonRef);\n const openedByKeyboard = useRef<boolean>(false);\n const { value: isOpen, toggleValue: toggleIsOpen } = useToggle(!disabled && open, onToggle);\n const isMobile = useIsMobileBreakpoint();\n const triggerActualMinWidth = variant !== 'borderless' && typeof triggerMinWidth != 'undefined' ? `${triggerMinWidth}px` : 'auto';\n const triggerMinWidthLimit = isMobile ? 96 : 112;\n const dropdownFloatingPadding = 15;\n const maxWidth = isMobile ? 384 : 400;\n const maxHeight = isMobile ? 384 : 464;\n const toggleTextId = useId();\n const optionIdPrefix = useId();\n const contentId = useId();\n const leftIconProps = {\n className: styles['dropdown__left-icon'],\n size: IconSize.XSmall,\n isHovered: !disabled && isHovered,\n };\n\n const isSingleSelect = React.Children.toArray(children).every(\n child => React.isValidElement(child) && isComponent<SingleSelectItemProps>(child, SingleSelectItem)\n );\n const isMultiSelect = React.Children.toArray(children).every(\n child => React.isValidElement(child) && isComponent<CheckboxProps>(child, Checkbox)\n );\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n const mergedResources: HNDesignsystemDropdown = {\n ...defaultResources,\n ...resources,\n };\n\n const toggleClasses = classNames(styles.dropdown__toggle, {\n [styles['dropdown__toggle--open']]: isOpen && !disabled,\n [styles['dropdown__toggle--with-icon']]: typeof svgIcon !== 'undefined',\n [styles['dropdown__toggle--transparent']]: variant === 'transparent',\n [styles['dropdown__toggle--borderless']]: variant === 'borderless',\n });\n const contentClasses = classNames(styles.dropdown__content, isOpen && styles['dropdown__content--open']);\n const listItemClasses = classNames(styles['dropdown__list-item'], { [styles['dropdown__list-item--single-select']]: isSingleSelect });\n\n const { refs, floatingStyles } = useFloating({\n strategy: 'fixed',\n placement: 'bottom-start',\n middleware: [\n offset(8),\n // Hvis det ikke er plass på høyre side flipper vi dropdownlisten fra bottom-start til bottom-end\n flip({ mainAxis: false, fallbackPlacements: ['bottom-end'], padding: dropdownFloatingPadding }),\n // Shift fungerer som en fallback for flip og unngår at availableWidth ikke oppdaterer seg ved skjermbreddeendring\n shift({ padding: dropdownFloatingPadding }),\n // Hvis det ikke er plass på noen av sidene krymper vi bredden på listen med size\n size({\n padding: dropdownFloatingPadding,\n apply({ availableWidth, availableHeight, elements, rects }) {\n const triggerW = rects.reference.width;\n const minProp = typeof dropdownMinWidth !== 'undefined' ? clamp(0, maxWidth, dropdownMinWidth) : 0;\n const targetW = Math.max(triggerW, minProp);\n\n Object.assign(elements.floating.style, {\n maxWidth: `${Math.min(targetW, availableWidth)}px`,\n maxHeight: `${Math.min(maxHeight, availableHeight)}px`,\n overflowY: 'auto',\n overflowX: 'hidden',\n });\n },\n }),\n ],\n whileElementsMounted: isOpen ? autoUpdate : undefined,\n });\n\n const handleOpen = (isKeyboard: boolean): void => {\n openedByKeyboard.current = isKeyboard;\n toggleIsOpen();\n };\n\n const handleClose = (): void => {\n if (!isOpen) return;\n\n toggleIsOpen();\n buttonRef.current?.focus();\n };\n\n useEffect(() => {\n if (isOpen && openedByKeyboard.current) {\n const firstEnabled = childrenRefList.current?.find(r => r.current && !r.current.hasAttribute('disabled'));\n firstEnabled?.current?.focus();\n openedByKeyboard.current = false;\n }\n }, [isOpen]);\n\n const focusByIndex = (nextIndex: number): void => {\n childrenRefList.current?.[nextIndex]?.current?.focus();\n };\n\n const isListNavKey = (key: string): boolean =>\n key === KeyboardEventKey.ArrowDown || key === KeyboardEventKey.ArrowUp || key === KeyboardEventKey.Home || key === KeyboardEventKey.End;\n\n const handleKeyboardNavigation = (event: KeyboardEvent): void => {\n if (!childrenRefList.current) return;\n\n const key = event.key as KeyboardEventKey;\n\n if (key === KeyboardEventKey.Escape) {\n if (isOpen) {\n event.preventDefault();\n handleClose();\n }\n return;\n }\n\n if (!isOpen) {\n if (isListNavKey(key)) {\n event.preventDefault();\n handleOpen(true);\n }\n return;\n }\n\n if (!isListNavKey(key)) {\n return;\n }\n\n const index = childrenRefList.current.findIndex(x => x.current === (event.target as HTMLElement));\n let nextIndex = index;\n\n if (key === KeyboardEventKey.Home) {\n nextIndex = 0;\n } else if (key === KeyboardEventKey.End) {\n nextIndex = childrenRefList.current.length - 1;\n } else if (key === KeyboardEventKey.ArrowDown && index < childrenRefList.current.length - 1) {\n nextIndex = index + 1;\n } else if (key === KeyboardEventKey.ArrowUp && index > 0) {\n nextIndex = index - 1;\n }\n\n if (nextIndex !== -1) {\n event.preventDefault();\n focusByIndex(nextIndex);\n }\n };\n\n useKeyboardEvent(dropdownRef, handleKeyboardNavigation, [\n KeyboardEventKey.ArrowDown,\n KeyboardEventKey.ArrowUp,\n KeyboardEventKey.End,\n KeyboardEventKey.Enter,\n KeyboardEventKey.Escape,\n KeyboardEventKey.Home,\n KeyboardEventKey.Space,\n ]);\n\n useOutsideEvent(dropdownRef, () => isOpen && handleClose());\n\n const renderChildren = React.Children.map(children, (child, index) => {\n const element = child as React.ReactElement<{ ref?: React.Ref<HTMLElement | null> }>;\n\n return (\n <li className={listItemClasses} id={`${optionIdPrefix}-${index}`}>\n {React.isValidElement(element) && childrenRefList.current && childrenRefList.current[index]\n ? ((): React.ReactElement => {\n if (isMultiSelect && isComponent<CheckboxProps>(element, Checkbox)) {\n const label = element.props.label;\n if (React.isValidElement(label) && isComponent<LabelProps>(label, Label)) {\n return React.cloneElement(element, {\n ref: mergeRefs([element.props.ref, childrenRefList.current[index]]),\n label: React.cloneElement(label, {\n labelClassName: classNames((label.props as LabelProps)?.labelClassName, styles['dropdown__multiselect-item']),\n }),\n });\n }\n }\n\n return React.cloneElement(child as React.ReactElement<Record<string, unknown>>, {\n ref: mergeRefs([element.props.ref, childrenRefList.current[index]]),\n });\n })()\n : child}\n </li>\n );\n });\n\n return (\n <div className={styles.dropdown} ref={dropdownRef}>\n <button\n type=\"button\"\n onClick={(): false | void => handleOpen(false)}\n className={toggleClasses}\n ref={mergeRefs([buttonRef, refs.setReference])}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Dropdown}\n disabled={disabled}\n aria-labelledby={toggleTextId}\n aria-haspopup={true}\n aria-controls={contentId}\n aria-expanded={isOpen}\n style={{\n width: triggerActualMinWidth,\n maxWidth: '100%',\n minWidth: `${triggerMinWidthLimit}px`,\n }}\n >\n {svgIcon && (\n <>\n {typeof svgIcon === 'string' ? (\n <LazyIcon {...leftIconProps} iconName={svgIcon} />\n ) : (\n <Icon {...leftIconProps} svgIcon={svgIcon} />\n )}\n </>\n )}\n <span id={toggleTextId} className={styles.dropdown__toggle__text}>\n {triggerText}\n </span>\n <Icon\n svgIcon={!isSingleSelect ? PlusSmall : isOpen ? ChevronUp : ChevronDown}\n className={styles['dropdown__right-icon']}\n isHovered={!disabled && isHovered}\n size={IconSize.XSmall}\n />\n </button>\n <div\n key={dropdownMinWidth ?? 'auto'}\n id={contentId}\n className={contentClasses}\n ref={refs.setFloating}\n style={{\n ...floatingStyles,\n zIndex: zIndex,\n }}\n >\n <ul className={styles.dropdown__options} role=\"group\" aria-labelledby={toggleTextId} tabIndex={-1} ref={optionsRef}>\n {isSingleSelect && <SingleSelect onValueChange={() => handleClose()}>{renderChildren}</SingleSelect>}\n {isMultiSelect && renderChildren}\n </ul>\n {!isSingleSelect && !noCloseButton && (\n <div className={styles.dropdown__close}>\n <Button onClick={handleClose}>{mergedResources.closeText}</Button>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport interface DropdownCompound extends React.FC<DropdownProps> {\n SingleSelectItem: ComponentType<SingleSelectItemProps>;\n}\nconst Dropdown = DropdownBase as DropdownCompound;\nDropdown.SingleSelectItem = SingleSelectItem;\nDropdownBase.displayName = 'Dropdown';\n\nexport default Dropdown;\n","import Dropdown from './Dropdown';\nexport * from './Dropdown';\nexport default Dropdown;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAa,gBAAgB,aAAsD;CACjF,QAAQ,UAAR;EACE,KAAK,gBAAgB,SACnB,OAAO;EACT,KAAK,gBAAgB;EACrB,SACE,OAAO;CACX;AACF;;;ACMA,IAAa,gBAA6C,EAAE,MAAM,UAAU,cAAc,eAA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OAAO;IACP,UAAU;IACV,UAAU,GAAG,qBAAqB;GACpC;aAhBF;IAkBG,WACC,oBAAA,UAAA,EAAA,UACG,OAAO,YAAY,WAClB,oBAAC,kBAAD;KAAU,GAAI;KAAe,UAAU;IAAU,CAAA,IAEjD,oBAAC,cAAD;KAAM,GAAI;KAAwB;IAAU,CAAA,EAE9C,CAAA;IAEJ,oBAAC,QAAD;KAAM,IAAI;KAAc,WAAW,OAAO;eACvC;IACG,CAAA;IACN,oBAAC,cAAD;KACE,SAAS,CAAC,iBAAiB,YAAY,SAAS,YAAY;KAC5D,WAAW,OAAO;KAClB,WAAW,CAAC,YAAY;KACxB,MAAM,SAAS;IAChB,CAAA;GACK;MACR,qBAAC,OAAD;GAEE,IAAI;GACJ,WAAW;GACX,KAAK,KAAK;GACV,OAAO;IACL,GAAG;IACK;GACV;aARF,CAUE,qBAAC,MAAD;IAAI,WAAW,OAAO;IAAmB,MAAK;IAAQ,mBAAiB;IAAc,UAAU;IAAI,KAAK;cAAxG,CACG,kBAAkB,oBAAC,cAAD;KAAc,qBAAqB,YAAY;eAAI;IAA6B,CAAA,GAClG,iBAAiB,cAChB;OACH,CAAC,kBAAkB,CAAC,iBACnB,oBAAC,OAAD;IAAK,WAAW,OAAO;cACrB,oBAAC,gBAAD;KAAQ,SAAS;eAAc,gBAAgB;IAAkB,CAAA;GAC9D,CAAA,CAEJ;KAlBE,oBAAoB,MAkBtB,CACF;;AAET;AAKA,IAAM,WAAW;AACjB,SAAS,mBAAmB;AAC5B,aAAa,cAAc;;;ACtV3B,IAAA,mBAAe"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Dropdown/resourceHelper.ts","../../../src/components/Dropdown/SingleSelect/SingleSelect.tsx","../../../src/components/Dropdown/Dropdown.tsx","../../../src/components/Dropdown/index.ts"],"sourcesContent":["import type { HNDesignsystemDropdown } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Dropdown.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Dropdown.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemDropdown => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React from 'react';\n\nimport { SingleSelectContext } from './utils';\n\nexport type SingleSelectContextType = {\n name?: string;\n disabled?: boolean;\n required?: boolean;\n value?: string;\n onValueChange?: (newValue: string, e?: React.SyntheticEvent) => void;\n};\n\nexport interface SingleSelectProps {\n name?: string;\n disabled?: boolean;\n defaultValue?: string;\n onValueChange?: (newValue: string, e?: React.SyntheticEvent) => void;\n children: React.ReactNode;\n}\n\nexport const SingleSelect: React.FC<SingleSelectProps> = ({ name, disabled, defaultValue, onValueChange, children }) => {\n const [selected, setSelected] = React.useState<string | undefined>(defaultValue);\n\n const context = React.useMemo<SingleSelectContextType>(\n () => ({\n name,\n disabled,\n value: selected,\n onValueChange: (v, e): void => {\n setSelected(v);\n onValueChange?.(v, e);\n },\n }),\n [name, disabled, selected, onValueChange]\n );\n\n return <SingleSelectContext.Provider value={context}>{children}</SingleSelectContext.Provider>;\n};\n","import type { ComponentType } from 'react';\nimport React, { useEffect, useRef, useId } from 'react';\n\nimport { autoUpdate, offset, shift, size, useFloating, flip } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { clamp } from 'motion/react';\n\nimport type { SingleSelectItemProps } from './SingleSelect/SingleSelectItem';\nimport type { HNDesignsystemDropdown } from '../../resources/Resources';\nimport type { CheckboxProps } from '../Checkbox';\nimport type { SvgIcon } from '../Icon';\nimport type { IconName } from '../Icons/IconNames';\nimport type { LabelProps } from '../Label';\n\nimport {\n AnalyticsId,\n IconSize,\n KeyboardEventKey,\n LanguageLocales,\n ZIndex,\n usePseudoClasses,\n useKeyboardEvent,\n useOutsideEvent,\n useToggle,\n} from '../..';\nimport { getResources } from './resourceHelper';\nimport { SingleSelectItem } from './SingleSelect/SingleSelectItem';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { isComponent } from '../../utils/component';\nimport { mergeRefs } from '../../utils/refs';\nimport Button from '../Button';\nimport Checkbox from '../Checkbox';\nimport Icon from '../Icon';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronUp from '../Icons/ChevronUp';\nimport PlusSmall from '../Icons/PlusSmall';\nimport Label from '../Label';\nimport LazyIcon from '../LazyIcon';\nimport { SingleSelect } from './SingleSelect/SingleSelect';\n\nimport styles from './styles.module.scss';\n\ntype DropdownVariants = 'fill' | 'transparent' | 'borderless';\n\nexport interface DropdownProps {\n /** Text on the trigger button that opens the dropdown */\n triggerText: string;\n /** Sets the dropdown content */\n children: React.ReactNode;\n /** Minimum width for the dropdown in pixels. Does not affect trigger button. */\n dropdownMinWidth?: number;\n /** Minimum width for the trigger in pixels. Does not apply for borderless variant */\n triggerMinWidth?: number;\n /** Disables rendring of the close button in the list */\n noCloseButton?: boolean;\n /** Called when dropdown is open/closed */\n onToggle?: (isOpen: boolean) => void;\n /** Whether the dropdown is open or not */\n open?: boolean;\n /** Makes the dropdown disabled */\n disabled?: boolean;\n /** Sets the data-testid attribute on the dropdown button */\n testId?: string;\n /** Overrides the default z-index of the DropDownContent */\n zIndex?: number;\n /** Resources for component */\n resources?: Partial<HNDesignsystemDropdown>;\n /** Adds an icon to the trigger */\n svgIcon?: SvgIcon | IconName;\n /** Sets the visual variant of the Dropdown */\n variant?: DropdownVariants;\n}\n\nexport const DropdownBase: React.FC<DropdownProps> = props => {\n const {\n triggerText,\n noCloseButton = false,\n onToggle,\n dropdownMinWidth,\n triggerMinWidth,\n open = false,\n children,\n testId,\n disabled,\n zIndex = ZIndex.PopOver,\n resources,\n svgIcon,\n variant = 'fill',\n } = props;\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const optionsRef = useRef<HTMLUListElement>(null);\n const childrenRefList = useRef(React.Children.map(children, () => React.createRef<HTMLElement>()));\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const { isHovered } = usePseudoClasses<HTMLButtonElement | null>(buttonRef);\n const openedByKeyboard = useRef<boolean>(false);\n const { value: isOpen, toggleValue: toggleIsOpen } = useToggle(!disabled && open, onToggle);\n const isMobile = useIsMobileBreakpoint();\n const triggerActualMinWidth = variant !== 'borderless' && typeof triggerMinWidth != 'undefined' ? `${triggerMinWidth}px` : 'auto';\n const triggerMinWidthLimit = isMobile ? 96 : 112;\n const dropdownFloatingPadding = 15;\n const maxWidth = isMobile ? 384 : 400;\n const maxHeight = isMobile ? 384 : 464;\n const toggleTextId = useId();\n const optionIdPrefix = useId();\n const contentId = useId();\n const leftIconProps = {\n className: styles['dropdown__left-icon'],\n size: IconSize.XSmall,\n isHovered: !disabled && isHovered,\n };\n\n const isSingleSelect = React.Children.toArray(children).every(\n child => React.isValidElement(child) && isComponent<SingleSelectItemProps>(child, SingleSelectItem)\n );\n const isMultiSelect = React.Children.toArray(children).every(\n child => React.isValidElement(child) && isComponent<CheckboxProps>(child, Checkbox)\n );\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n const mergedResources: HNDesignsystemDropdown = {\n ...defaultResources,\n ...resources,\n };\n\n const toggleClasses = classNames(styles.dropdown__toggle, {\n [styles['dropdown__toggle--open']]: isOpen && !disabled,\n [styles['dropdown__toggle--with-icon']]: typeof svgIcon !== 'undefined',\n [styles['dropdown__toggle--transparent']]: variant === 'transparent',\n [styles['dropdown__toggle--borderless']]: variant === 'borderless',\n });\n const contentClasses = classNames(styles.dropdown__content, isOpen && styles['dropdown__content--open']);\n const listItemClasses = classNames(styles['dropdown__list-item'], { [styles['dropdown__list-item--single-select']]: isSingleSelect });\n\n const { refs, floatingStyles } = useFloating({\n strategy: 'fixed',\n placement: 'bottom-start',\n middleware: [\n offset(8),\n // Hvis det ikke er plass på høyre side flipper vi dropdownlisten fra bottom-start til bottom-end\n flip({ mainAxis: false, fallbackPlacements: ['bottom-end'], padding: dropdownFloatingPadding }),\n // Shift fungerer som en fallback for flip og unngår at availableWidth ikke oppdaterer seg ved skjermbreddeendring\n shift({ padding: dropdownFloatingPadding }),\n // Hvis det ikke er plass på noen av sidene krymper vi bredden på listen med size\n size({\n padding: dropdownFloatingPadding,\n apply({ availableWidth, availableHeight, elements, rects }) {\n const triggerW = rects.reference.width;\n const minProp = typeof dropdownMinWidth !== 'undefined' ? clamp(0, maxWidth, dropdownMinWidth) : 0;\n const targetW = Math.max(triggerW, minProp);\n\n Object.assign(elements.floating.style, {\n maxWidth: `${Math.min(targetW, availableWidth)}px`,\n maxHeight: `${Math.min(maxHeight, availableHeight)}px`,\n overflowY: 'auto',\n overflowX: 'hidden',\n });\n },\n }),\n ],\n whileElementsMounted: isOpen ? autoUpdate : undefined,\n });\n\n const handleOpen = (isKeyboard: boolean): void => {\n openedByKeyboard.current = isKeyboard;\n toggleIsOpen();\n };\n\n const handleClose = (): void => {\n if (!isOpen) return;\n\n toggleIsOpen();\n buttonRef.current?.focus();\n };\n\n useEffect(() => {\n if (isOpen && openedByKeyboard.current) {\n const firstEnabled = childrenRefList.current?.find(r => r.current && !r.current.hasAttribute('disabled'));\n firstEnabled?.current?.focus();\n openedByKeyboard.current = false;\n }\n }, [isOpen]);\n\n const focusByIndex = (nextIndex: number): void => {\n childrenRefList.current?.[nextIndex]?.current?.focus();\n };\n\n const isListNavKey = (key: string): boolean =>\n key === KeyboardEventKey.ArrowDown || key === KeyboardEventKey.ArrowUp || key === KeyboardEventKey.Home || key === KeyboardEventKey.End;\n\n const handleKeyboardNavigation = (event: KeyboardEvent): void => {\n if (!childrenRefList.current) return;\n\n const key = event.key as KeyboardEventKey;\n\n if (key === KeyboardEventKey.Escape) {\n if (isOpen) {\n event.preventDefault();\n handleClose();\n }\n return;\n }\n\n if (!isOpen) {\n if (isListNavKey(key)) {\n event.preventDefault();\n handleOpen(true);\n }\n return;\n }\n\n if (!isListNavKey(key)) {\n return;\n }\n\n const index = childrenRefList.current.findIndex(x => x.current === (event.target as HTMLElement));\n let nextIndex = index;\n\n if (key === KeyboardEventKey.Home) {\n nextIndex = 0;\n } else if (key === KeyboardEventKey.End) {\n nextIndex = childrenRefList.current.length - 1;\n } else if (key === KeyboardEventKey.ArrowDown && index < childrenRefList.current.length - 1) {\n nextIndex = index + 1;\n } else if (key === KeyboardEventKey.ArrowUp && index > 0) {\n nextIndex = index - 1;\n }\n\n if (nextIndex !== -1) {\n event.preventDefault();\n focusByIndex(nextIndex);\n }\n };\n\n useKeyboardEvent(dropdownRef, handleKeyboardNavigation, [\n KeyboardEventKey.ArrowDown,\n KeyboardEventKey.ArrowUp,\n KeyboardEventKey.End,\n KeyboardEventKey.Enter,\n KeyboardEventKey.Escape,\n KeyboardEventKey.Home,\n KeyboardEventKey.Space,\n ]);\n\n useOutsideEvent(dropdownRef, () => isOpen && handleClose());\n\n const renderChildren = React.Children.map(children, (child, index) => {\n const element = child as React.ReactElement<{ ref?: React.Ref<HTMLElement | null> }>;\n\n return (\n <li className={listItemClasses} id={`${optionIdPrefix}-${index}`}>\n {React.isValidElement(element) && childrenRefList.current && childrenRefList.current[index]\n ? ((): React.ReactElement => {\n if (isMultiSelect && isComponent<CheckboxProps>(element, Checkbox)) {\n const label = element.props.label;\n if (React.isValidElement(label) && isComponent<LabelProps>(label, Label)) {\n return React.cloneElement(element, {\n ref: mergeRefs([element.props.ref, childrenRefList.current[index]]),\n label: React.cloneElement(label, {\n labelClassName: classNames((label.props as LabelProps)?.labelClassName, styles['dropdown__multiselect-item']),\n }),\n });\n }\n }\n\n return React.cloneElement(child as React.ReactElement<Record<string, unknown>>, {\n ref: mergeRefs([element.props.ref, childrenRefList.current[index]]),\n });\n })()\n : child}\n </li>\n );\n });\n\n return (\n <div className={styles.dropdown} ref={dropdownRef}>\n <button\n type=\"button\"\n onClick={(): false | void => handleOpen(false)}\n className={toggleClasses}\n ref={mergeRefs([buttonRef, refs.setReference])}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Dropdown}\n disabled={disabled}\n aria-labelledby={toggleTextId}\n aria-haspopup={true}\n aria-controls={contentId}\n aria-expanded={isOpen}\n style={{\n width: triggerActualMinWidth,\n maxWidth: '100%',\n minWidth: `${triggerMinWidthLimit}px`,\n }}\n >\n {svgIcon && (\n <>\n {typeof svgIcon === 'string' ? (\n <LazyIcon {...leftIconProps} iconName={svgIcon} />\n ) : (\n <Icon {...leftIconProps} svgIcon={svgIcon} />\n )}\n </>\n )}\n <span id={toggleTextId} className={styles.dropdown__toggle__text}>\n {triggerText}\n </span>\n <Icon\n svgIcon={!isSingleSelect ? PlusSmall : isOpen ? ChevronUp : ChevronDown}\n className={styles['dropdown__right-icon']}\n isHovered={!disabled && isHovered}\n size={IconSize.XSmall}\n />\n </button>\n <div\n key={dropdownMinWidth ?? 'auto'}\n id={contentId}\n className={contentClasses}\n ref={refs.setFloating}\n style={{\n ...floatingStyles,\n zIndex: zIndex,\n }}\n >\n <ul className={styles.dropdown__options} role=\"group\" aria-labelledby={toggleTextId} tabIndex={-1} ref={optionsRef}>\n {isSingleSelect && <SingleSelect onValueChange={() => handleClose()}>{renderChildren}</SingleSelect>}\n {isMultiSelect && renderChildren}\n </ul>\n {!isSingleSelect && !noCloseButton && (\n <div className={styles.dropdown__close}>\n <Button onClick={handleClose}>{mergedResources.closeText}</Button>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport interface DropdownCompound extends React.FC<DropdownProps> {\n SingleSelectItem: ComponentType<SingleSelectItemProps>;\n}\nconst Dropdown = DropdownBase as DropdownCompound;\nDropdown.SingleSelectItem = SingleSelectItem;\nDropdownBase.displayName = 'Dropdown';\n\nexport default Dropdown;\n","import Dropdown from './Dropdown';\nexport * from './Dropdown';\nexport default Dropdown;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAa,gBAAgB,aAAsD;CACjF,QAAQ,UAAR;EACE,KAAK,gBAAgB,SACnB,OAAO;EACT,KAAK,gBAAgB;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AAY;GACpB;GACV,mBAAiB;GACjB,iBAAe;GACf,iBAAe;GACf,iBAAe;GACf,OAAO;IACL,OAAO;IACP,UAAU;IACV,UAAU,GAAG,qBAAqB;GACpC;aAhBF;IAkBG,WACC,oBAAA,UAAA,EAAA,UACG,OAAO,YAAY,WAClB,oBAAC,kBAAD;KAAU,GAAI;KAAe,UAAU;IAAU,CAAA,IAEjD,oBAAC,cAAD;KAAM,GAAI;KAAwB;IAAU,CAAA,EAE9C,CAAA;IAEJ,oBAAC,QAAD;KAAM,IAAI;KAAc,WAAW,OAAO;eACvC;IACG,CAAA;IACN,oBAAC,cAAD;KACE,SAAS,CAAC,iBAAiB,YAAY,SAAS,YAAY;KAC5D,WAAW,OAAO;KAClB,WAAW,CAAC,YAAY;KACxB,MAAM,SAAS;IAChB,CAAA;GACK;MACR,qBAAC,OAAD;GAEE,IAAI;GACJ,WAAW;GACX,KAAK,KAAK;GACV,OAAO;IACL,GAAG;IACK;GACV;aARF,CAUE,qBAAC,MAAD;IAAI,WAAW,OAAO;IAAmB,MAAK;IAAQ,mBAAiB;IAAc,UAAU;IAAI,KAAK;cAAxG,CACG,kBAAkB,oBAAC,cAAD;KAAc,qBAAqB,YAAY;eAAI;IAA6B,CAAA,GAClG,iBAAiB,cAChB;OACH,CAAC,kBAAkB,CAAC,iBACnB,oBAAC,OAAD;IAAK,WAAW,OAAO;cACrB,oBAAC,gBAAD;KAAQ,SAAS;eAAc,gBAAgB;IAAkB,CAAA;GAC9D,CAAA,CAEJ;KAlBE,oBAAoB,MAkBtB,CACF;;AAET;AAKA,IAAM,WAAW;AACjB,SAAS,mBAAmB;AAC5B,aAAa,cAAc;;;ACtV3B,IAAA,mBAAe"}
@@ -10,7 +10,7 @@ import { useKeyboardEvent } from "../../hooks/useKeyboardEvent.js";
10
10
  import { useOutsideEvent } from "../../hooks/useOutsideEvent.js";
11
11
  import { n as HN_Designsystem_Dropdown_en_GB_default, t as HN_Designsystem_Dropdown_nb_NO_default } from "../../HN.Designsystem.Dropdown.nb-NO.js";
12
12
  import PlusSmall from "../Icons/PlusSmall.js";
13
- import classNames from "classnames";
13
+ import cn from "classnames";
14
14
  import React, { useEffect, useId, useRef } from "react";
15
15
  import { jsx, jsxs } from "react/jsx-runtime";
16
16
  import styles from "./styles.module.scss";
@@ -99,7 +99,7 @@ var DropdownOld = (props) => {
99
99
  KeyboardEventKey.Space
100
100
  ]);
101
101
  useOutsideEvent(dropdownRef, () => isOpen && handleClose());
102
- const toggleClasses = classNames(styles.dropdown__toggle, !disabled && {
102
+ const toggleClasses = cn(styles.dropdown__toggle, !disabled && {
103
103
  [styles["dropdown__toggle--on-white"]]: onColor === DropdownOldOnColor.onwhite,
104
104
  [styles["dropdown__toggle--on-grey"]]: onColor === DropdownOldOnColor.ongrey,
105
105
  [styles["dropdown__toggle--on-blueberry"]]: onColor === DropdownOldOnColor.onblueberry,
@@ -108,7 +108,7 @@ var DropdownOld = (props) => {
108
108
  [styles["dropdown__toggle--fluid"]]: fluid,
109
109
  [styles["dropdown__toggle--open"]]: isOpen
110
110
  });
111
- const contentClasses = classNames(styles.dropdown__content, isOpen && styles["dropdown__content--open"]);
111
+ const contentClasses = cn(styles.dropdown__content, isOpen && styles["dropdown__content--open"]);
112
112
  const renderChildren = React.Children.map(children, (child, index) => {
113
113
  const element = child;
114
114
  return /* @__PURE__ */ jsx("li", {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/DropdownOld/constants.ts","../../../src/components/DropdownOld/resourceHelper.ts","../../../src/components/DropdownOld/DropdownOld.tsx","../../../src/components/DropdownOld/index.ts"],"sourcesContent":["export enum DropdownOldOnColor {\n onwhite = 'onwhite',\n ongrey = 'ongrey',\n onblueberry = 'onblueberry',\n oncherry = 'oncherry',\n}\n","import type { HNDesignsystemDropdown } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Dropdown.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Dropdown.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemDropdown => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React, { useEffect, useRef, useId } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { HNDesignsystemDropdown } from '../../resources/Resources';\n\nimport { DropdownOldOnColor } from './constants';\nimport {\n AnalyticsId,\n IconSize,\n KeyboardEventKey,\n LanguageLocales,\n ZIndex,\n theme,\n usePseudoClasses,\n useKeyboardEvent,\n useOutsideEvent,\n useToggle,\n} from '../..';\nimport { getResources } from './resourceHelper';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { mergeRefs } from '../../utils/refs';\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport PlusSmall from '../Icons/PlusSmall';\n\nimport styles from './styles.module.scss';\n\nexport interface DropdownOldProps {\n /** Label for dropdown. Visible for screen readers */\n label: string;\n /** Text on the trigger button that opens the dropdown */\n placeholder: string;\n /** Sets the dropdown content */\n children: React.ReactNode;\n /** @deprecated Close button text */\n closeText?: string;\n /** Minimum width for the dropdown in pixels. Does not affect trigger button */\n dropdownMinWidth?: number;\n /** No close button */\n noCloseButton?: boolean;\n /** Called when dropdown is open/closed */\n onToggle?: (isOpen: boolean) => void;\n /** Whether the dropdown is open or not */\n open?: boolean;\n /** Changes the visuals of the dropdown */\n onColor?: keyof typeof DropdownOldOnColor;\n /** Makes the background of the trigger transparent */\n transparent?: boolean;\n /** Makes the width of the full component adjust to its parent */\n fluid?: boolean;\n /** Makes the dropdown disabled */\n disabled?: boolean;\n /** Sets the data-testid attribute on the dropdown button */\n testId?: string;\n /** Overrides the default z-index of the DropDownContent */\n zIndex?: number;\n /** Resources for component */\n resources?: Partial<HNDesignsystemDropdown>;\n}\n\nconst DropdownOld: React.FC<DropdownOldProps> = props => {\n const {\n label,\n placeholder,\n noCloseButton = false,\n onToggle,\n dropdownMinWidth,\n open = false,\n children,\n onColor = DropdownOldOnColor.onwhite,\n transparent = false,\n fluid = false,\n testId,\n disabled,\n zIndex = ZIndex.PopOver,\n resources,\n } = props;\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const optionsRef = useRef<HTMLUListElement>(null);\n const { refObject: buttonRef, isHovered } = usePseudoClasses<HTMLButtonElement>();\n const openedByKeyboard = useRef<boolean>(false);\n const { value: isOpen, toggleValue: toggleIsOpen } = useToggle(!disabled && open, onToggle);\n const inputRefList = useRef(React.Children.map(children, () => React.createRef<HTMLElement>()));\n const labelId = useId();\n const toggleLabelId = useId();\n const optionIdPrefix = useId();\n const contentId = useId();\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemDropdown = {\n ...defaultResources,\n ...resources,\n closeText: props.closeText ?? resources?.closeText ?? defaultResources.closeText,\n };\n\n const handleOpen = (isKeyboard: boolean): void => {\n openedByKeyboard.current = isKeyboard;\n toggleIsOpen();\n };\n\n const handleClose = (): void => {\n toggleIsOpen();\n buttonRef.current?.focus();\n };\n\n useEffect(() => {\n if (isOpen && openedByKeyboard.current) {\n const firstEnabled = inputRefList.current?.find(r => r.current && !r.current.hasAttribute('disabled'));\n firstEnabled?.current?.focus();\n openedByKeyboard.current = false;\n }\n }, [isOpen]);\n\n const handleKeyboardNavigation = (event: KeyboardEvent): void => {\n if (!inputRefList.current) {\n return;\n }\n\n if (event.key === KeyboardEventKey.Escape) {\n if (isOpen) handleClose();\n return;\n }\n\n if (!isOpen) {\n handleOpen(true);\n event.preventDefault();\n return;\n }\n\n const index = inputRefList.current.findIndex(x => x.current === event.target);\n let nextIndex = index;\n\n if (event.key === KeyboardEventKey.Home) {\n nextIndex = 0;\n } else if (event.key === KeyboardEventKey.End) {\n nextIndex = inputRefList.current.length - 1;\n } else if (event.key === KeyboardEventKey.ArrowDown && index < inputRefList.current.length - 1) {\n nextIndex = index + 1;\n } else if (event.key === KeyboardEventKey.ArrowUp && index > 0) {\n nextIndex = index - 1;\n } else if (event.key === KeyboardEventKey.Enter && index !== -1) {\n nextIndex = index;\n }\n\n if (nextIndex !== -1 && event.key !== KeyboardEventKey.Space) {\n event.preventDefault();\n\n inputRefList.current[nextIndex].current?.focus();\n }\n };\n\n useKeyboardEvent(dropdownRef, handleKeyboardNavigation, [\n KeyboardEventKey.ArrowDown,\n KeyboardEventKey.ArrowUp,\n KeyboardEventKey.End,\n KeyboardEventKey.Enter,\n KeyboardEventKey.Escape,\n KeyboardEventKey.Home,\n KeyboardEventKey.Space,\n ]);\n\n useOutsideEvent(dropdownRef, () => isOpen && handleClose());\n\n const toggleClasses = classNames(\n styles.dropdown__toggle,\n !disabled && {\n [styles['dropdown__toggle--on-white']]: onColor === DropdownOldOnColor.onwhite,\n [styles['dropdown__toggle--on-grey']]: onColor === DropdownOldOnColor.ongrey,\n [styles['dropdown__toggle--on-blueberry']]: onColor === DropdownOldOnColor.onblueberry,\n [styles['dropdown__toggle--on-cherry']]: onColor === DropdownOldOnColor.oncherry,\n [styles['dropdown__toggle--transparent']]: transparent,\n [styles['dropdown__toggle--fluid']]: fluid,\n [styles['dropdown__toggle--open']]: isOpen,\n }\n );\n\n const contentClasses = classNames(styles.dropdown__content, isOpen && styles['dropdown__content--open']);\n\n const renderChildren = React.Children.map(children, (child, index) => {\n const element = child as React.ReactElement<{ children?: React.ReactNode; ref?: React.Ref<HTMLElement | null> }>;\n\n return (\n <li className={styles.dropdown__input} id={`${optionIdPrefix}-${index}`}>\n {React.isValidElement(element) && inputRefList.current && inputRefList.current[index]\n ? React.cloneElement(element, {\n ref: mergeRefs([element.props.ref, inputRefList.current[index]]),\n })\n : child}\n </li>\n );\n });\n\n return (\n <div className={styles.dropdown} ref={dropdownRef}>\n <span id={labelId} className={styles.dropdown__label}>\n {label}\n </span>\n <button\n type=\"button\"\n onClick={(): false | void => handleOpen(false)}\n className={toggleClasses}\n ref={buttonRef}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Dropdown}\n disabled={disabled}\n aria-labelledby={toggleLabelId}\n aria-haspopup={true}\n aria-controls={contentId}\n aria-expanded={isOpen}\n >\n <span id={toggleLabelId} className={styles.dropdown__toggle__label}>\n {placeholder}\n </span>\n <Icon\n color={disabled ? theme.palette.neutral700 : theme.palette.blueberry600}\n svgIcon={PlusSmall}\n className={styles.dropdown__icon}\n isHovered={!disabled && isHovered}\n size={IconSize.XSmall}\n />\n </button>\n <div\n id={contentId}\n className={contentClasses}\n style={{ width: fluid ? '100%' : `auto`, minWidth: dropdownMinWidth ?? 'auto', zIndex: zIndex }}\n >\n <ul className={styles.dropdown__options} role=\"group\" aria-labelledby={labelId} tabIndex={-1} ref={optionsRef}>\n {renderChildren}\n </ul>\n {!noCloseButton && (\n <div className={styles.dropdown__close}>\n <Button onClick={handleClose}>{mergedResources.closeText}</Button>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default DropdownOld;\n","import DropdownOld from './DropdownOld';\nexport { DropdownOldOnColor } from './constants';\nexport * from './DropdownOld';\nexport default DropdownOld;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAY,qBAAL,yBAAA,oBAAA;CACL,mBAAA,aAAA;CACA,mBAAA,YAAA;CACA,mBAAA,iBAAA;CACA,mBAAA,cAAA;;AACF,EAAA,CAAA,CAAA;;;ACCA,IAAa,gBAAgB,aAAsD;CACjF,QAAQ,UAAR;EACE,KAAK,gBAAgB,SACnB,OAAO;EACT,KAAK,gBAAgB;EACrB,SACE,OAAO;CACX;AACF;;;AC+CA,IAAM,eAA0C,UAAS;CACvD,MAAM,EACJ,OACA,aACA,gBAAgB,OAChB,UACA,kBACA,OAAO,OACP,UACA,UAAU,mBAAmB,SAC7B,cAAc,OACd,QAAQ,OACR,QACA,UACA,SAAS,OAAO,SAChB,cACE;CAEJ,MAAM,cAAc,OAAuB,IAAI;CAC/C,MAAM,aAAa,OAAyB,IAAI;CAChD,MAAM,EAAE,WAAW,WAAW,cAAc,iBAAoC;CAChF,M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IAAI;IAAS,WAAW,OAAO;cAClC;GACG,CAAA;GACN,qBAAC,UAAD;IACE,MAAK;IACL,eAA6B,WAAW,KAAK;IAC7C,WAAW;IACX,KAAK;IACL,eAAa;IACb,oBAAkB,YAAY;IACpB;IACV,mBAAiB;IACjB,iBAAe;IACf,iBAAe;IACf,iBAAe;cAXjB,CAaE,oBAAC,QAAD;KAAM,IAAI;KAAe,WAAW,OAAO;eACxC;IACG,CAAA,GACN,oBAAC,cAAD;KACE,OAAO,WAAW,MAAM,QAAQ,aAAa,MAAM,QAAQ;KAC3D,SAAS;KACT,WAAW,OAAO;KAClB,WAAW,CAAC,YAAY;KACxB,MAAM,SAAS;IAChB,CAAA,CACK;;GACR,qBAAC,OAAD;IACE,IAAI;IACJ,WAAW;IACX,OAAO;KAAE,OAAO,QAAQ,SAAS;KAAQ,UAAU,oBAAoB;KAAgB;IAAO;cAHhG,CAKE,oBAAC,MAAD;KAAI,WAAW,OAAO;KAAmB,MAAK;KAAQ,mBAAiB;KAAS,UAAU;KAAI,KAAK;eAChG;IACC,CAAA,GACH,CAAC,iBACA,oBAAC,OAAD;KAAK,WAAW,OAAO;eACrB,oBAAC,gBAAD;MAAQ,SAAS;gBAAc,gBAAgB;KAAkB,CAAA;IAC9D,CAAA,CAEJ;;EACF;;AAET;;;AC7OA,IAAA,sBAAe"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/DropdownOld/constants.ts","../../../src/components/DropdownOld/resourceHelper.ts","../../../src/components/DropdownOld/DropdownOld.tsx","../../../src/components/DropdownOld/index.ts"],"sourcesContent":["export enum DropdownOldOnColor {\n onwhite = 'onwhite',\n ongrey = 'ongrey',\n onblueberry = 'onblueberry',\n oncherry = 'oncherry',\n}\n","import type { HNDesignsystemDropdown } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Dropdown.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Dropdown.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemDropdown => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React, { useEffect, useRef, useId } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { HNDesignsystemDropdown } from '../../resources/Resources';\n\nimport { DropdownOldOnColor } from './constants';\nimport {\n AnalyticsId,\n IconSize,\n KeyboardEventKey,\n LanguageLocales,\n ZIndex,\n theme,\n usePseudoClasses,\n useKeyboardEvent,\n useOutsideEvent,\n useToggle,\n} from '../..';\nimport { getResources } from './resourceHelper';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { mergeRefs } from '../../utils/refs';\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport PlusSmall from '../Icons/PlusSmall';\n\nimport styles from './styles.module.scss';\n\nexport interface DropdownOldProps {\n /** Label for dropdown. Visible for screen readers */\n label: string;\n /** Text on the trigger button that opens the dropdown */\n placeholder: string;\n /** Sets the dropdown content */\n children: React.ReactNode;\n /** @deprecated Close button text */\n closeText?: string;\n /** Minimum width for the dropdown in pixels. Does not affect trigger button */\n dropdownMinWidth?: number;\n /** No close button */\n noCloseButton?: boolean;\n /** Called when dropdown is open/closed */\n onToggle?: (isOpen: boolean) => void;\n /** Whether the dropdown is open or not */\n open?: boolean;\n /** Changes the visuals of the dropdown */\n onColor?: keyof typeof DropdownOldOnColor;\n /** Makes the background of the trigger transparent */\n transparent?: boolean;\n /** Makes the width of the full component adjust to its parent */\n fluid?: boolean;\n /** Makes the dropdown disabled */\n disabled?: boolean;\n /** Sets the data-testid attribute on the dropdown button */\n testId?: string;\n /** Overrides the default z-index of the DropDownContent */\n zIndex?: number;\n /** Resources for component */\n resources?: Partial<HNDesignsystemDropdown>;\n}\n\nconst DropdownOld: React.FC<DropdownOldProps> = props => {\n const {\n label,\n placeholder,\n noCloseButton = false,\n onToggle,\n dropdownMinWidth,\n open = false,\n children,\n onColor = DropdownOldOnColor.onwhite,\n transparent = false,\n fluid = false,\n testId,\n disabled,\n zIndex = ZIndex.PopOver,\n resources,\n } = props;\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const optionsRef = useRef<HTMLUListElement>(null);\n const { refObject: buttonRef, isHovered } = usePseudoClasses<HTMLButtonElement>();\n const openedByKeyboard = useRef<boolean>(false);\n const { value: isOpen, toggleValue: toggleIsOpen } = useToggle(!disabled && open, onToggle);\n const inputRefList = useRef(React.Children.map(children, () => React.createRef<HTMLElement>()));\n const labelId = useId();\n const toggleLabelId = useId();\n const optionIdPrefix = useId();\n const contentId = useId();\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemDropdown = {\n ...defaultResources,\n ...resources,\n closeText: props.closeText ?? resources?.closeText ?? defaultResources.closeText,\n };\n\n const handleOpen = (isKeyboard: boolean): void => {\n openedByKeyboard.current = isKeyboard;\n toggleIsOpen();\n };\n\n const handleClose = (): void => {\n toggleIsOpen();\n buttonRef.current?.focus();\n };\n\n useEffect(() => {\n if (isOpen && openedByKeyboard.current) {\n const firstEnabled = inputRefList.current?.find(r => r.current && !r.current.hasAttribute('disabled'));\n firstEnabled?.current?.focus();\n openedByKeyboard.current = false;\n }\n }, [isOpen]);\n\n const handleKeyboardNavigation = (event: KeyboardEvent): void => {\n if (!inputRefList.current) {\n return;\n }\n\n if (event.key === KeyboardEventKey.Escape) {\n if (isOpen) handleClose();\n return;\n }\n\n if (!isOpen) {\n handleOpen(true);\n event.preventDefault();\n return;\n }\n\n const index = inputRefList.current.findIndex(x => x.current === event.target);\n let nextIndex = index;\n\n if (event.key === KeyboardEventKey.Home) {\n nextIndex = 0;\n } else if (event.key === KeyboardEventKey.End) {\n nextIndex = inputRefList.current.length - 1;\n } else if (event.key === KeyboardEventKey.ArrowDown && index < inputRefList.current.length - 1) {\n nextIndex = index + 1;\n } else if (event.key === KeyboardEventKey.ArrowUp && index > 0) {\n nextIndex = index - 1;\n } else if (event.key === KeyboardEventKey.Enter && index !== -1) {\n nextIndex = index;\n }\n\n if (nextIndex !== -1 && event.key !== KeyboardEventKey.Space) {\n event.preventDefault();\n\n inputRefList.current[nextIndex].current?.focus();\n }\n };\n\n useKeyboardEvent(dropdownRef, handleKeyboardNavigation, [\n KeyboardEventKey.ArrowDown,\n KeyboardEventKey.ArrowUp,\n KeyboardEventKey.End,\n KeyboardEventKey.Enter,\n KeyboardEventKey.Escape,\n KeyboardEventKey.Home,\n KeyboardEventKey.Space,\n ]);\n\n useOutsideEvent(dropdownRef, () => isOpen && handleClose());\n\n const toggleClasses = classNames(\n styles.dropdown__toggle,\n !disabled && {\n [styles['dropdown__toggle--on-white']]: onColor === DropdownOldOnColor.onwhite,\n [styles['dropdown__toggle--on-grey']]: onColor === DropdownOldOnColor.ongrey,\n [styles['dropdown__toggle--on-blueberry']]: onColor === DropdownOldOnColor.onblueberry,\n [styles['dropdown__toggle--on-cherry']]: onColor === DropdownOldOnColor.oncherry,\n [styles['dropdown__toggle--transparent']]: transparent,\n [styles['dropdown__toggle--fluid']]: fluid,\n [styles['dropdown__toggle--open']]: isOpen,\n }\n );\n\n const contentClasses = classNames(styles.dropdown__content, isOpen && styles['dropdown__content--open']);\n\n const renderChildren = React.Children.map(children, (child, index) => {\n const element = child as React.ReactElement<{ children?: React.ReactNode; ref?: React.Ref<HTMLElement | null> }>;\n\n return (\n <li className={styles.dropdown__input} id={`${optionIdPrefix}-${index}`}>\n {React.isValidElement(element) && inputRefList.current && inputRefList.current[index]\n ? React.cloneElement(element, {\n ref: mergeRefs([element.props.ref, inputRefList.current[index]]),\n })\n : child}\n </li>\n );\n });\n\n return (\n <div className={styles.dropdown} ref={dropdownRef}>\n <span id={labelId} className={styles.dropdown__label}>\n {label}\n </span>\n <button\n type=\"button\"\n onClick={(): false | void => handleOpen(false)}\n className={toggleClasses}\n ref={buttonRef}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Dropdown}\n disabled={disabled}\n aria-labelledby={toggleLabelId}\n aria-haspopup={true}\n aria-controls={contentId}\n aria-expanded={isOpen}\n >\n <span id={toggleLabelId} className={styles.dropdown__toggle__label}>\n {placeholder}\n </span>\n <Icon\n color={disabled ? theme.palette.neutral700 : theme.palette.blueberry600}\n svgIcon={PlusSmall}\n className={styles.dropdown__icon}\n isHovered={!disabled && isHovered}\n size={IconSize.XSmall}\n />\n </button>\n <div\n id={contentId}\n className={contentClasses}\n style={{ width: fluid ? '100%' : `auto`, minWidth: dropdownMinWidth ?? 'auto', zIndex: zIndex }}\n >\n <ul className={styles.dropdown__options} role=\"group\" aria-labelledby={labelId} tabIndex={-1} ref={optionsRef}>\n {renderChildren}\n </ul>\n {!noCloseButton && (\n <div className={styles.dropdown__close}>\n <Button onClick={handleClose}>{mergedResources.closeText}</Button>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default DropdownOld;\n","import DropdownOld from './DropdownOld';\nexport { DropdownOldOnColor } from './constants';\nexport * from './DropdownOld';\nexport default DropdownOld;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAY,qBAAL,yBAAA,oBAAA;CACL,mBAAA,aAAA;CACA,mBAAA,YAAA;CACA,mBAAA,iBAAA;CACA,mBAAA,cAAA;;AACF,EAAA,CAAA,CAAA;;;ACCA,IAAa,gBAAgB,aAAsD;CACjF,QAAQ,UAAR;EACE,KAAK,gBAAgB,SACnB,OAAO;EACT,KAAK,gBAAgB;EACrB,SACE,OAAO;CACX;AACF;;;AC+CA,IAAM,eAA0C,UAAS;CACvD,MAAM,EACJ,OACA,aACA,gBAAgB,OAChB,UACA,kBACA,OAAO,OACP,UACA,UAAU,mBAAmB,SAC7B,cAAc,OACd,QAAQ,OACR,QACA,UACA,SAAS,OAAO,SAChB,cACE;CAEJ,MAAM,cAAc,OAAuB,IAAI;CAC/C,MAAM,aAAa,OAAyB,IAAI;CAChD,MAAM,EAAE,WAAW,WAAW,cAAc,iBAAoC;CAChF,MAAM,mBAAmB,OAAgB,KAAK;C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