@helsenorge/designsystem-react 14.6.0 → 14.7.1

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 (281) 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 +6 -6
  8. package/lib/Button.js.map +1 -1
  9. package/lib/CHANGELOG.md +17 -0
  10. package/lib/Checkbox.js +6 -6
  11. package/lib/Checkbox.js.map +1 -1
  12. package/lib/Chip.js +60 -0
  13. package/lib/Chip.js.map +1 -0
  14. package/lib/Close.js +3 -3
  15. package/lib/Close.js.map +1 -1
  16. package/lib/DictionaryTrigger.js +2 -2
  17. package/lib/DictionaryTrigger.js.map +1 -1
  18. package/lib/Drawer.js +42 -19
  19. package/lib/Drawer.js.map +1 -1
  20. package/lib/DrawerNavigation.js +81 -0
  21. package/lib/DrawerNavigation.js.map +1 -0
  22. package/lib/DrawerNavigation2.js +5 -0
  23. package/lib/DrawerNavigation2.js.map +1 -0
  24. package/lib/Duolist.js +5 -5
  25. package/lib/Duolist.js.map +1 -1
  26. package/lib/ElementHeader.js +9 -9
  27. package/lib/ElementHeader.js.map +1 -1
  28. package/lib/ElementHeaderText.js +4 -4
  29. package/lib/ElementHeaderText.js.map +1 -1
  30. package/lib/ErrorWrapper.js +2 -2
  31. package/lib/ErrorWrapper.js.map +1 -1
  32. package/lib/Expander.js +8 -8
  33. package/lib/Expander.js.map +1 -1
  34. package/lib/Filter.js +44 -0
  35. package/lib/Filter.js.map +1 -0
  36. package/lib/FilterButton.js +40 -0
  37. package/lib/FilterButton.js.map +1 -0
  38. package/lib/FilterButtonAndChipsWrapper.js +14 -0
  39. package/lib/FilterButtonAndChipsWrapper.js.map +1 -0
  40. package/lib/FilterDrawer.js +91 -0
  41. package/lib/FilterDrawer.js.map +1 -0
  42. package/lib/FilterLinkList.js +61 -0
  43. package/lib/FilterLinkList.js.map +1 -0
  44. package/lib/FilterLinkList2.js +5 -0
  45. package/lib/FilterLinkList2.js.map +1 -0
  46. package/lib/FilterOverviewLinkList.js +22 -0
  47. package/lib/FilterOverviewLinkList.js.map +1 -0
  48. package/lib/FilterOverviewSearch.js +16 -0
  49. package/lib/FilterOverviewSearch.js.map +1 -0
  50. package/lib/FilterResultCountAndSortWrapper.js +19 -0
  51. package/lib/FilterResultCountAndSortWrapper.js.map +1 -0
  52. package/lib/FilterSearch.js +87 -0
  53. package/lib/FilterSearch.js.map +1 -0
  54. package/lib/FilterSearch2.js +5 -0
  55. package/lib/FilterSearch2.js.map +1 -0
  56. package/lib/FilterSort.js +30 -0
  57. package/lib/FilterSort.js.map +1 -0
  58. package/lib/FormFieldTag.js +2 -2
  59. package/lib/FormFieldTag.js.map +1 -1
  60. package/lib/FormGroup.js +6 -6
  61. package/lib/FormGroup.js.map +1 -1
  62. package/lib/FormLayout.js +3 -3
  63. package/lib/FormLayout.js.map +1 -1
  64. package/lib/HelpDetails.js +3 -3
  65. package/lib/HelpDetails.js.map +1 -1
  66. package/lib/HelpTriggerIcon.js +2 -2
  67. package/lib/HelpTriggerIcon.js.map +1 -1
  68. package/lib/HelpTriggerStandalone.js +2 -2
  69. package/lib/HelpTriggerStandalone.js.map +1 -1
  70. package/lib/HighlightPanel.js +3 -3
  71. package/lib/HighlightPanel.js.map +1 -1
  72. package/lib/HorizontalScroll.js +4 -4
  73. package/lib/HorizontalScroll.js.map +1 -1
  74. package/lib/Icon.js +2 -2
  75. package/lib/Icon.js.map +1 -1
  76. package/lib/InfoTeaser.js +3 -3
  77. package/lib/InfoTeaser.js.map +1 -1
  78. package/lib/Input.js +4 -4
  79. package/lib/Input.js.map +1 -1
  80. package/lib/LinkList.js +5 -5
  81. package/lib/LinkList.js.map +1 -1
  82. package/lib/List.js +2 -2
  83. package/lib/List.js.map +1 -1
  84. package/lib/ListEditMode.js +4 -4
  85. package/lib/ListEditMode.js.map +1 -1
  86. package/lib/MaxCharacters.js +2 -2
  87. package/lib/MaxCharacters.js.map +1 -1
  88. package/lib/PanelTitle.js +2 -2
  89. package/lib/PanelTitle.js.map +1 -1
  90. package/lib/PopOver.js +2 -2
  91. package/lib/PopOver.js.map +1 -1
  92. package/lib/Search.js +26 -0
  93. package/lib/Search.js.map +1 -0
  94. package/lib/Select.js +7 -6
  95. package/lib/Select.js.map +1 -1
  96. package/lib/SingleSelectItem.js +3 -3
  97. package/lib/SingleSelectItem.js.map +1 -1
  98. package/lib/Slider.js +4 -4
  99. package/lib/Slider.js.map +1 -1
  100. package/lib/Spacer.js +2 -2
  101. package/lib/Spacer.js.map +1 -1
  102. package/lib/StatusDot.js +4 -4
  103. package/lib/StatusDot.js.map +1 -1
  104. package/lib/StatusDotList.js +2 -2
  105. package/lib/StatusDotList.js.map +1 -1
  106. package/lib/StepButtons.js +5 -5
  107. package/lib/StepButtons.js.map +1 -1
  108. package/lib/TabList.js +8 -8
  109. package/lib/TabList.js.map +1 -1
  110. package/lib/TabPanel.js +2 -2
  111. package/lib/TabPanel.js.map +1 -1
  112. package/lib/TableBody.js +2 -2
  113. package/lib/TableBody.js.map +1 -1
  114. package/lib/TableCell.js +2 -2
  115. package/lib/TableCell.js.map +1 -1
  116. package/lib/TableExpandedRow.js +4 -4
  117. package/lib/TableExpandedRow.js.map +1 -1
  118. package/lib/TableExpanderCell.js +2 -2
  119. package/lib/TableExpanderCell.js.map +1 -1
  120. package/lib/TableHead.js +2 -2
  121. package/lib/TableHead.js.map +1 -1
  122. package/lib/TableHeadCell.js +3 -3
  123. package/lib/TableHeadCell.js.map +1 -1
  124. package/lib/TableRow.js +3 -3
  125. package/lib/TableRow.js.map +1 -1
  126. package/lib/Textarea.js +4 -4
  127. package/lib/Textarea.js.map +1 -1
  128. package/lib/Title.js +4 -3
  129. package/lib/Title.js.map +1 -1
  130. package/lib/Toast.js +3 -3
  131. package/lib/Toast.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/Chip/index.js +1 -59
  135. package/lib/components/Drawer/Drawer.d.ts +6 -0
  136. package/lib/components/Drawer/styles.module.scss +19 -0
  137. package/lib/components/Drawer/styles.module.scss.d.ts +1 -0
  138. package/lib/components/Dropdown/index.js +5 -5
  139. package/lib/components/Dropdown/index.js.map +1 -1
  140. package/lib/components/DropdownOld/index.js +3 -3
  141. package/lib/components/DropdownOld/index.js.map +1 -1
  142. package/lib/components/EmptyState/index.js +2 -2
  143. package/lib/components/EmptyState/index.js.map +1 -1
  144. package/lib/components/ExpanderHierarchy/index.js +7 -7
  145. package/lib/components/ExpanderHierarchy/index.js.map +1 -1
  146. package/lib/components/ExpanderList/index.js +6 -6
  147. package/lib/components/ExpanderList/index.js.map +1 -1
  148. package/lib/components/FavoriteButton/index.js +2 -2
  149. package/lib/components/FavoriteButton/index.js.map +1 -1
  150. package/lib/components/Filter/DrawerNavigation/DrawerNavigation.d.ts +35 -0
  151. package/lib/components/Filter/DrawerNavigation/FinnFastlegeFlyt.example.d.ts +2 -0
  152. package/lib/components/Filter/DrawerNavigation/FinnFastlegeFlyt.module.scss +15 -0
  153. package/lib/components/Filter/DrawerNavigation/FinnFastlegeFlyt.module.scss.d.ts +11 -0
  154. package/lib/components/Filter/DrawerNavigation/index.d.ts +4 -0
  155. package/lib/components/Filter/DrawerNavigation/index.js +3 -0
  156. package/lib/components/Filter/DrawerNavigation/useDrawerNavigation.d.ts +7 -0
  157. package/lib/components/Filter/FilterButton/FilterButton.d.ts +7 -0
  158. package/lib/components/Filter/FilterButton/index.d.ts +3 -0
  159. package/lib/components/Filter/FilterButton/index.js +2 -0
  160. package/lib/components/Filter/FilterButton/styles.module.scss +52 -0
  161. package/lib/components/Filter/FilterButton/styles.module.scss.d.ts +12 -0
  162. package/lib/components/Filter/FilterButtonAndChipsWrapper/FilterButtonAndChipsWrapper.d.ts +11 -0
  163. package/lib/components/Filter/FilterButtonAndChipsWrapper/index.d.ts +3 -0
  164. package/lib/components/Filter/FilterButtonAndChipsWrapper/index.js +2 -0
  165. package/lib/components/Filter/FilterButtonAndChipsWrapper/styles.module.scss +8 -0
  166. package/lib/components/Filter/FilterButtonAndChipsWrapper/styles.module.scss.d.ts +9 -0
  167. package/lib/components/Filter/FilterDrawer/FilterDrawer.d.ts +42 -0
  168. package/lib/components/Filter/FilterDrawer/index.d.ts +3 -0
  169. package/lib/components/Filter/FilterDrawer/index.js +2 -0
  170. package/lib/components/Filter/FilterDrawer/styles.module.scss +29 -0
  171. package/lib/components/Filter/FilterDrawer/styles.module.scss.d.ts +10 -0
  172. package/lib/components/Filter/FilterLinkList/FilterLinkList.d.ts +35 -0
  173. package/lib/components/Filter/FilterLinkList/FilterLinkList.module.scss +89 -0
  174. package/lib/components/Filter/FilterLinkList/FilterLinkList.module.scss.d.ts +14 -0
  175. package/lib/components/Filter/FilterLinkList/index.d.ts +3 -0
  176. package/lib/components/Filter/FilterLinkList/index.js +3 -0
  177. package/lib/components/Filter/FilterOverviewLinkList/FilterOverviewLinkList.d.ts +19 -0
  178. package/lib/components/Filter/FilterOverviewLinkList/index.d.ts +3 -0
  179. package/lib/components/Filter/FilterOverviewLinkList/index.js +2 -0
  180. package/lib/components/Filter/FilterOverviewSearch/FilterOverviewSearch.d.ts +9 -0
  181. package/lib/components/Filter/FilterOverviewSearch/index.d.ts +3 -0
  182. package/lib/components/Filter/FilterOverviewSearch/index.js +2 -0
  183. package/lib/components/Filter/FilterOverviewSearch/styles.module.scss +14 -0
  184. package/lib/components/Filter/FilterOverviewSearch/styles.module.scss.d.ts +9 -0
  185. package/lib/components/Filter/FilterResultCountAndSortWrapper/FilterResultCountAndSortWrapper.d.ts +8 -0
  186. package/lib/components/Filter/FilterResultCountAndSortWrapper/index.d.ts +3 -0
  187. package/lib/components/Filter/FilterResultCountAndSortWrapper/index.js +2 -0
  188. package/lib/components/Filter/FilterResultCountAndSortWrapper/styles.module.scss +17 -0
  189. package/lib/components/Filter/FilterResultCountAndSortWrapper/styles.module.scss.d.ts +11 -0
  190. package/lib/components/Filter/FilterSearch/FilterSearch.d.ts +19 -0
  191. package/lib/components/Filter/FilterSearch/index.d.ts +3 -0
  192. package/lib/components/Filter/FilterSearch/index.js +2 -0
  193. package/lib/components/Filter/FilterSearch/styles.module.scss +181 -0
  194. package/lib/components/Filter/FilterSearch/styles.module.scss.d.ts +16 -0
  195. package/lib/components/Filter/FilterSort/FilterSort.d.ts +8 -0
  196. package/lib/components/Filter/FilterSort/index.d.ts +3 -0
  197. package/lib/components/Filter/FilterSort/index.js +2 -0
  198. package/lib/components/Filter/FilterSort/styles.module.scss +33 -0
  199. package/lib/components/Filter/FilterSort/styles.module.scss.d.ts +11 -0
  200. package/lib/components/Filter/getFilterChips/getFilterChips.d.ts +17 -0
  201. package/lib/components/Filter/getFilterChips/index.d.ts +3 -0
  202. package/lib/components/Filter/getFilterChips/index.js +2 -0
  203. package/lib/components/Filter/index.d.ts +25 -0
  204. package/lib/components/Filter/index.js +137 -0
  205. package/lib/components/Filter/index.js.map +1 -0
  206. package/lib/components/Filter/resourceHelper.d.ts +3 -0
  207. package/lib/components/Filter/resourcesMock.d.ts +41 -0
  208. package/lib/components/Filter/useFilter.d.ts +20 -0
  209. package/lib/components/Filter/useFilterDrawer.d.ts +11 -0
  210. package/lib/components/Filter/utils.d.ts +81 -0
  211. package/lib/components/HelpBubble/index.js +3 -3
  212. package/lib/components/HelpBubble/index.js.map +1 -1
  213. package/lib/components/HelpPanel/index.js +2 -2
  214. package/lib/components/HelpPanel/index.js.map +1 -1
  215. package/lib/components/HelpTriggerInline/index.js +2 -2
  216. package/lib/components/HelpTriggerInline/index.js.map +1 -1
  217. package/lib/components/Icons/Filter.js +1 -43
  218. package/lib/components/Icons/Search.js +1 -25
  219. package/lib/components/Label/utils.d.ts +1 -0
  220. package/lib/components/Loader/index.js +4 -4
  221. package/lib/components/Loader/index.js.map +1 -1
  222. package/lib/components/Modal/index.js +9 -9
  223. package/lib/components/Modal/index.js.map +1 -1
  224. package/lib/components/NotificationPanel/index.js +6 -6
  225. package/lib/components/NotificationPanel/index.js.map +1 -1
  226. package/lib/components/Panel/index.js +12 -12
  227. package/lib/components/Panel/index.js.map +1 -1
  228. package/lib/components/PanelList/index.js +3 -3
  229. package/lib/components/PanelList/index.js.map +1 -1
  230. package/lib/components/PopMenu/index.js +3 -3
  231. package/lib/components/PopMenu/index.js.map +1 -1
  232. package/lib/components/Progressbar/index.js +2 -2
  233. package/lib/components/Progressbar/index.js.map +1 -1
  234. package/lib/components/PromoPanel/index.js +2 -2
  235. package/lib/components/PromoPanel/index.js.map +1 -1
  236. package/lib/components/Select/Select.d.ts +2 -0
  237. package/lib/components/Select/styles.module.scss +1 -0
  238. package/lib/components/ServiceMessage/index.js +5 -5
  239. package/lib/components/ServiceMessage/index.js.map +1 -1
  240. package/lib/components/SharingStatus/index.js +4 -4
  241. package/lib/components/SharingStatus/index.js.map +1 -1
  242. package/lib/components/Step/index.js +2 -2
  243. package/lib/components/Step/index.js.map +1 -1
  244. package/lib/components/Stepper/index.js +2 -2
  245. package/lib/components/Stepper/index.js.map +1 -1
  246. package/lib/components/StickyNote/index.js +8 -8
  247. package/lib/components/StickyNote/index.js.map +1 -1
  248. package/lib/components/Table/index.js +2 -2
  249. package/lib/components/Table/index.js.map +1 -1
  250. package/lib/components/Tabs/index.js +4 -4
  251. package/lib/components/Tabs/index.js.map +1 -1
  252. package/lib/components/Tag/index.js +2 -2
  253. package/lib/components/Tag/index.js.map +1 -1
  254. package/lib/components/Tile/index.js +4 -4
  255. package/lib/components/Tile/index.js.map +1 -1
  256. package/lib/components/Title/Title.d.ts +2 -0
  257. package/lib/components/Toggle/index.js +7 -7
  258. package/lib/components/Toggle/index.js.map +1 -1
  259. package/lib/components/Validation/index.js +2 -2
  260. package/lib/components/Validation/index.js.map +1 -1
  261. package/lib/getFilterChips.js +30 -0
  262. package/lib/getFilterChips.js.map +1 -0
  263. package/lib/index.d.ts +1 -0
  264. package/lib/index.js +2 -1
  265. package/lib/resource.js +4 -0
  266. package/lib/resource.js.map +1 -0
  267. package/lib/resourceHelper.js +31 -0
  268. package/lib/resourceHelper.js.map +1 -0
  269. package/lib/resources/HN.Designsystem.Drawer.nn-NO.json.d.ts +7 -0
  270. package/lib/resources/HN.Designsystem.Filter.en-GB.json.d.ts +13 -0
  271. package/lib/resources/HN.Designsystem.Filter.nb-NO.json.d.ts +13 -0
  272. package/lib/utils/resource.d.ts +6 -0
  273. package/lib/utils/resource.js +2 -0
  274. package/lib/utils2.js +11 -9
  275. package/lib/utils2.js.map +1 -1
  276. package/lib/utils3.js +5 -5
  277. package/lib/utils3.js.map +1 -1
  278. package/package.json +1 -1
  279. package/lib/components/Chip/index.js.map +0 -1
  280. package/lib/components/Icons/Filter.js.map +0 -1
  281. package/lib/components/Icons/Search.js.map +0 -1
package/lib/Drawer.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { n as uuid_default } from "./uuid.js";
2
2
  import { c as ZIndex, n as AnalyticsId, o as KeyboardEventKey, s as LanguageLocales } from "./constants2.js";
3
+ import { t as Icon_default } from "./Icon.js";
3
4
  import { n as useLanguage } from "./useLanguage.js";
4
5
  import { t as useIsMobileBreakpoint } from "./useIsMobileBreakpoint.js";
5
6
  import { t as Button_default } from "./Button.js";
@@ -11,8 +12,9 @@ import { t as useOutsideEvent } from "./useOutsideEvent.js";
11
12
  import { t as Close_default } from "./Close.js";
12
13
  import { t as useReturnFocusOnUnmount } from "./useReturnFocusOnUnmount.js";
13
14
  import { n as enableBodyScroll, t as disableBodyScroll } from "./scroll.js";
15
+ import { t as ChevronLeft_default } from "./ChevronLeft.js";
14
16
  import { t as Title_default } from "./Title2.js";
15
- import classNames from "classnames";
17
+ import cn from "classnames";
16
18
  import React, { useEffect, useRef } from "react";
17
19
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
18
20
  import { AnimatePresence, useAnimate, usePresence } from "motion/react";
@@ -25,9 +27,14 @@ var HN_Designsystem_Drawer_nb_NO_default = {
25
27
  ariaLabelBackButton: "Gå tilbake",
26
28
  ariaLabelCloseBtn: "Lukk"
27
29
  };
30
+ var HN_Designsystem_Drawer_nn_NO_default = {
31
+ ariaLabelCloseBtn: "Lukk",
32
+ ariaLabelBackButton: "Gå tilbake"
33
+ };
28
34
  const getResources = (language) => {
29
35
  switch (language) {
30
36
  case LanguageLocales.ENGLISH: return HN_Designsystem_Drawer_en_GB_default;
37
+ case LanguageLocales.NORWEGIAN_NYNORSK: return HN_Designsystem_Drawer_nn_NO_default;
31
38
  case LanguageLocales.NORWEGIAN:
32
39
  default: return HN_Designsystem_Drawer_nb_NO_default;
33
40
  }
@@ -41,7 +48,7 @@ var Drawer = (props) => {
41
48
  }) });
42
49
  };
43
50
  var InnerDrawer = (props) => {
44
- const { ariaLabel, ariaLabelledBy, children, closeColor = "blueberry", desktopDirection = "left", footerContent, headerClasses, noCloseButton = false, onPrimaryAction, onRequestClose, onSecondaryAction, primaryActionText, secondaryActionText, title, titleHtmlMarkup = "h3", titleId = uuid_default(), zIndex = ZIndex.OverlayScreen, resources, isMobile } = props;
51
+ const { ariaLabel, ariaLabelledBy, children, closeColor = "blueberry", desktopDirection = "left", footerContent, headerClasses, noCloseButton = false, onPrimaryAction, onRequestClose, onSecondaryAction, primaryActionText, secondaryActionText, title, titleHtmlMarkup = "h3", titleId = uuid_default(), zIndex = ZIndex.OverlayScreen, resources, isMobile, withBackButton, onRequestBack, contentClassName } = props;
45
52
  const ariaLabelAttributes = getAriaLabelAttributes({
46
53
  label: ariaLabel,
47
54
  id: ariaLabelledBy,
@@ -54,6 +61,7 @@ var InnerDrawer = (props) => {
54
61
  const bottomContent = useRef(null);
55
62
  const headerRef = useRef(null);
56
63
  const footerRef = useRef(null);
64
+ const titleRef = useRef(null);
57
65
  const [scope, animate] = useAnimate();
58
66
  const [isPresent, safeToRemove] = usePresence();
59
67
  const [headerHeight, setHeaderHeight] = React.useState(0);
@@ -66,7 +74,7 @@ var InnerDrawer = (props) => {
66
74
  ...resources
67
75
  };
68
76
  const contentIsScrollable = contentRef.current && contentRef.current.scrollHeight > contentRef.current.clientHeight;
69
- const headerStyling = classNames(styles.drawer__header, headerClasses);
77
+ const headerStyling = cn(styles.drawer__header, headerClasses);
70
78
  const hasFooterContent = typeof footerContent !== "undefined" && footerContent || onPrimaryAction || onSecondaryAction;
71
79
  useFocusTrap_default(containerRef, true);
72
80
  useReturnFocusOnUnmount(containerRef);
@@ -143,6 +151,9 @@ var InnerDrawer = (props) => {
143
151
  const handleCTA = (callback) => {
144
152
  if (callback) callback();
145
153
  };
154
+ useEffect(() => {
155
+ titleRef.current?.focus();
156
+ }, [title]);
146
157
  return /* @__PURE__ */ jsxs("div", {
147
158
  className: styles.drawer,
148
159
  ref: scope,
@@ -153,7 +164,7 @@ var InnerDrawer = (props) => {
153
164
  ref: overlayRef,
154
165
  "aria-hidden": "true"
155
166
  }), /* @__PURE__ */ jsxs("div", {
156
- className: classNames(styles.drawer__container, { [styles["drawer__container--right"]]: desktopDirection === "right" }),
167
+ className: cn(styles.drawer__container, { [styles["drawer__container--right"]]: desktopDirection === "right" }),
157
168
  ref: containerRef,
158
169
  role: "dialog",
159
170
  "aria-modal": "true",
@@ -165,28 +176,40 @@ var InnerDrawer = (props) => {
165
176
  /* @__PURE__ */ jsxs("div", {
166
177
  className: headerStyling,
167
178
  ref: headerRef,
168
- children: [/* @__PURE__ */ jsx(Title_default, {
169
- id: ariaLabelAttributes?.["aria-labelledby"],
170
- className: styles["drawer__header__title"],
171
- htmlMarkup: titleHtmlMarkup,
172
- appearance: "title3",
173
- children: title
174
- }), !noCloseButton && onRequestClose != void 0 && /* @__PURE__ */ jsx(Close_default, {
175
- ariaLabel: mergedResources.ariaLabelCloseBtn,
176
- color: closeColor,
177
- onClick: onRequestClose,
178
- className: styles["drawer__header__close-button"]
179
- })]
179
+ children: [
180
+ /* @__PURE__ */ jsx(Title_default, {
181
+ id: ariaLabelAttributes?.["aria-labelledby"],
182
+ className: styles["drawer__header__title"],
183
+ htmlMarkup: titleHtmlMarkup,
184
+ appearance: "title3",
185
+ ref: titleRef,
186
+ tabIndex: -1,
187
+ children: title
188
+ }),
189
+ withBackButton && onRequestBack !== void 0 && /* @__PURE__ */ jsx(Button_default, {
190
+ ariaLabel: mergedResources.ariaLabelBackButton,
191
+ onClick: onRequestBack,
192
+ variant: "borderless",
193
+ wrapperClassName: styles["drawer__header__back-button"],
194
+ children: /* @__PURE__ */ jsx(Icon_default, { svgIcon: ChevronLeft_default })
195
+ }),
196
+ !noCloseButton && onRequestClose != void 0 && /* @__PURE__ */ jsx(Close_default, {
197
+ ariaLabel: mergedResources.ariaLabelCloseBtn,
198
+ color: closeColor,
199
+ onClick: onRequestClose,
200
+ className: styles["drawer__header__close-button"]
201
+ })
202
+ ]
180
203
  }),
181
204
  /* @__PURE__ */ jsx("div", {
182
- className: classNames(styles["drawer__content__shadow"], styles["drawer__content__shadow--top"]),
205
+ className: cn(styles["drawer__content__shadow"], styles["drawer__content__shadow--top"]),
183
206
  style: {
184
207
  opacity: !topContentVisible && contentIsScrollable ? 1 : 0,
185
208
  top: headerHeight
186
209
  }
187
210
  }),
188
211
  /* @__PURE__ */ jsxs("div", {
189
- className: styles.drawer__content,
212
+ className: cn(styles.drawer__content, contentClassName),
190
213
  tabIndex: contentIsScrollable ? 0 : void 0,
191
214
  role: contentIsScrollable ? "region" : void 0,
192
215
  ...contentIsScrollable ? ariaLabelAttributes : {},
@@ -204,7 +227,7 @@ var InnerDrawer = (props) => {
204
227
  ]
205
228
  }),
206
229
  /* @__PURE__ */ jsx("div", {
207
- className: classNames(styles["drawer__content__shadow"], styles["drawer__content__shadow--bottom"]),
230
+ className: cn(styles["drawer__content__shadow"], styles["drawer__content__shadow--bottom"]),
208
231
  style: {
209
232
  opacity: !bottomContentVisible && contentIsScrollable ? 1 : 0,
210
233
  bottom: hasFooterContent ? footerHeight : 0
package/lib/Drawer.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.js","names":["Drawer: React.FC<DrawerProps>","InnerDrawer: React.FC<InnerDrawerProps>","mergedResources: HNDesignsystemDrawer"],"sources":["../src/resources/HN.Designsystem.Drawer.en-GB.json","../src/resources/HN.Designsystem.Drawer.nb-NO.json","../src/components/Drawer/resourceHelper.ts","../src/components/Drawer/Drawer.tsx","../src/components/Drawer/index.ts"],"sourcesContent":["{\n \"ariaLabelBackButton\": \"Go back\",\n \"ariaLabelCloseBtn\": \"Close\"\n}\n","{\n \"ariaLabelBackButton\": \"Gå tilbake\",\n \"ariaLabelCloseBtn\": \"Lukk\"\n}\n","import type { HNDesignsystemDrawer } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Drawer.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Drawer.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemDrawer => {\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 } from 'react';\n\nimport classNames from 'classnames';\nimport { AnimatePresence, useAnimate, usePresence } from 'motion/react';\n\nimport type { HNDesignsystemDrawer } from '../../resources/Resources';\nimport type { TitleTags } from '../Title';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, KeyboardEventKey, LanguageLocales, ZIndex } from '../../constants';\nimport useFocusTrap from '../../hooks/useFocusTrap';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useKeyboardEvent } from '../../hooks/useKeyboardEvent';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { useReturnFocusOnUnmount } from '../../hooks/useReturnFocusOnUnmount';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { disableBodyScroll, enableBodyScroll } from '../../utils/scroll';\nimport uuid from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Title from '../Title';\n\nimport styles from './styles.module.scss';\n\ntype DesktopDirections = 'left' | 'right';\n\nexport interface DrawerProps extends InnerDrawerProps {\n /** Opens and closes the drawer */\n isOpen: boolean;\n}\n\nexport interface InnerDrawerProps {\n /** Sets the aria-label of the drawer */\n ariaLabel?: string;\n /** Sets the aria-labelledby of the drawer */\n ariaLabelledBy?: string;\n /** Sets the style of the Drawer Close button. Meant for use by HelpDrawer */\n closeColor?: 'blueberry' | 'plum';\n /** Direction of the drawer on desktop. Default: left */\n desktopDirection?: DesktopDirections;\n /** Sets the style of the Drawer header */\n headerClasses?: string;\n /** Title to display in the header of the drawer */\n title: string;\n /** id of the drawer title */\n titleId?: string;\n /** Changes the underlying element of the title. Default: h3 */\n titleHtmlMarkup?: TitleTags;\n /** Callback that triggers when clicking on close button or outside the drawer, update isOpen state when this triggers */\n onRequestClose?: () => void;\n /** Optional footer content that can be rendered instead of default CTA(s) */\n footerContent?: React.ReactNode;\n /** Main content of the drawer */\n children?: React.ReactNode;\n /** Hides the close button */\n noCloseButton?: boolean;\n /** Primary CTA callback */\n onPrimaryAction?: () => void;\n /** Text for primary CTA button if you want a default CTA button rendered (instead of `footerContent`) */\n primaryActionText?: string;\n /** Text for secondary CTA button if you want a default CTA button rendered (instead of `footerContent`) */\n secondaryActionText?: string;\n /** Secondary CTA callback */\n onSecondaryAction?: () => void;\n /** Customize the z-index of the drawer */\n zIndex?: number;\n /** Resources for component */\n resources?: Partial<HNDesignsystemDrawer>;\n /** Sets mobile styling and animation from outer level Drawer */\n isMobile?: boolean;\n}\n\nconst Drawer: React.FC<DrawerProps> = props => {\n const { isOpen, ...rest } = props;\n const isMobile = useIsMobileBreakpoint();\n\n return <AnimatePresence>{isOpen && <InnerDrawer {...rest} isMobile={isMobile} />}</AnimatePresence>;\n};\n\nconst InnerDrawer: React.FC<InnerDrawerProps> = props => {\n const {\n ariaLabel,\n ariaLabelledBy,\n children,\n closeColor = 'blueberry',\n desktopDirection = 'left',\n footerContent,\n headerClasses,\n noCloseButton = false,\n onPrimaryAction,\n onRequestClose,\n onSecondaryAction,\n primaryActionText,\n secondaryActionText,\n title,\n titleHtmlMarkup = 'h3',\n titleId = uuid(),\n zIndex = ZIndex.OverlayScreen,\n resources,\n isMobile,\n } = props;\n\n const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledBy, fallbackId: titleId });\n const overlayRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n // topContent and bottomContent are used to detect scroll position for shadow effects\n const topContent = useRef<HTMLDivElement>(null);\n const bottomContent = useRef<HTMLDivElement>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n const footerRef = useRef<HTMLDivElement>(null);\n const [scope, animate] = useAnimate();\n const [isPresent, safeToRemove] = usePresence();\n const [headerHeight, setHeaderHeight] = React.useState(0);\n const [footerHeight, setFooterHeight] = React.useState(0);\n const topContentVisible = useIsVisible(topContent);\n const bottomContentVisible = useIsVisible(bottomContent, 0);\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemDrawer = {\n ...defaultResources,\n ...resources,\n };\n\n const contentIsScrollable = contentRef.current && contentRef.current.scrollHeight > contentRef.current.clientHeight;\n const headerStyling = classNames(styles.drawer__header, headerClasses);\n const hasFooterContent = (typeof footerContent !== 'undefined' && footerContent) || onPrimaryAction || onSecondaryAction;\n\n useFocusTrap(containerRef, true);\n useReturnFocusOnUnmount(containerRef);\n useOutsideEvent(containerRef, () => {\n if (onRequestClose) onRequestClose();\n });\n useKeyboardEvent(containerRef, () => onRequestClose && onRequestClose(), [KeyboardEventKey.Escape]);\n\n // Close animasjon, vi kaller `onClose()` til slutt\n const closeDrawer = (): void => {\n if (!overlayRef.current || !containerRef.current) return;\n\n animate(overlayRef.current, { opacity: 0, pointerEvents: 'none' }, { duration: 0.3, ease: 'easeInOut' });\n\n if (isMobile) {\n animate(\n containerRef.current,\n { y: '100%' },\n {\n duration: 0.3,\n ease: 'easeInOut',\n onComplete: () => {\n if (safeToRemove) safeToRemove();\n },\n }\n );\n } else {\n animate(\n containerRef.current,\n { x: desktopDirection === 'left' ? '-100%' : '100%' },\n {\n duration: 0.3,\n ease: 'easeInOut',\n onComplete: () => {\n if (safeToRemove) safeToRemove();\n },\n }\n );\n }\n };\n\n useEffect(() => {\n containerRef.current?.focus();\n disableBodyScroll();\n\n return (): void => {\n enableBodyScroll();\n };\n }, []);\n\n // Measure header and footer heights\n useEffect(() => {\n const updateHeights = (): void => {\n if (headerRef.current) {\n setHeaderHeight(headerRef.current.offsetHeight);\n }\n if (footerRef.current) {\n setFooterHeight(footerRef.current.offsetHeight);\n }\n };\n\n updateHeights();\n\n // Update heights when content changes\n const resizeObserver = new ResizeObserver(updateHeights);\n if (headerRef.current) {\n resizeObserver.observe(headerRef.current);\n }\n if (footerRef.current) {\n resizeObserver.observe(footerRef.current);\n }\n\n return (): void => {\n resizeObserver.disconnect();\n };\n }, [hasFooterContent]);\n\n // Open animation.\n useEffect(() => {\n if (!overlayRef.current || !containerRef.current) return;\n\n if (!isPresent) {\n closeDrawer();\n return;\n }\n\n if (isMobile) {\n animate(containerRef.current, { y: '0' }, { duration: 0.3, ease: 'easeInOut' });\n } else {\n animate(containerRef.current, { x: '0' }, { duration: 0.3, ease: 'easeInOut' });\n }\n\n animate(overlayRef.current, { opacity: 1, pointerEvents: 'auto' }, { duration: 0.3, ease: 'easeInOut' });\n }, [isPresent]);\n\n const handleCTA = (callback?: () => void): void => {\n if (callback) {\n callback();\n }\n };\n\n return (\n <div className={styles.drawer} ref={scope} style={{ zIndex }} data-analyticsid={AnalyticsId.Drawer}>\n <div className={styles.drawer__overlay} ref={overlayRef} aria-hidden=\"true\" />\n <div\n className={classNames(styles.drawer__container, {\n [styles['drawer__container--right']]: desktopDirection === 'right',\n })}\n ref={containerRef}\n role=\"dialog\"\n aria-modal=\"true\"\n tabIndex={-1}\n {...ariaLabelAttributes}\n >\n <div className={styles.drawer__container__inner}>\n <div className={headerStyling} ref={headerRef}>\n <Title\n id={ariaLabelAttributes?.['aria-labelledby']}\n className={styles['drawer__header__title']}\n htmlMarkup={titleHtmlMarkup}\n appearance=\"title3\"\n >\n {title}\n </Title>\n {!noCloseButton && onRequestClose != undefined && (\n <Close\n ariaLabel={mergedResources.ariaLabelCloseBtn}\n color={closeColor}\n onClick={onRequestClose}\n className={styles['drawer__header__close-button']}\n />\n )}\n </div>\n <div\n className={classNames(styles['drawer__content__shadow'], styles['drawer__content__shadow--top'])}\n style={{\n opacity: !topContentVisible && contentIsScrollable ? 1 : 0,\n top: headerHeight,\n }}\n />\n <div\n className={styles.drawer__content}\n tabIndex={contentIsScrollable ? 0 : undefined}\n role={contentIsScrollable ? 'region' : undefined}\n {...(contentIsScrollable ? ariaLabelAttributes : {})}\n ref={contentRef}\n >\n <div ref={topContent} />\n <div className={styles['drawer__content__children']}>{children}</div>\n <div ref={bottomContent} style={{ height: '1px' }} />\n </div>\n <div\n className={classNames(styles['drawer__content__shadow'], styles['drawer__content__shadow--bottom'])}\n style={{\n opacity: !bottomContentVisible && contentIsScrollable ? 1 : 0,\n bottom: hasFooterContent ? footerHeight : 0,\n }}\n />\n </div>\n {hasFooterContent && (\n <div className={styles.drawer__footer} ref={footerRef}>\n {footerContent ? (\n footerContent\n ) : (\n <>\n {onPrimaryAction && <Button onClick={() => handleCTA(onPrimaryAction)}>{primaryActionText}</Button>}\n {onSecondaryAction && (\n <Button variant=\"borderless\" onClick={() => handleCTA(onSecondaryAction)}>\n {secondaryActionText}\n </Button>\n )}\n </>\n )}\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default Drawer;\n","import Drawer from './Drawer';\nexport * from './Drawer';\nexport default Drawer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;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;MAClB,UAAU,sBAAsB,IAAI,KAAA;MACpC,MAAM,sBAAsB,WAAW,KAAA;MACvC,GAAK,sBAAsB,sBAAsB,EAAE;MACnD,KAAK;;OAEL,oBAAC,OAAA,EAAI,KAAK,YAAA,CAAc;OACxB,oBAAC,OAAA;QAAI,WAAW,OAAO;QAA+B;SAAe;OACrE,oBAAC,OAAA;QAAI,KAAK;QAAe,OAAO,EAAE,QAAQ,OAAO;SAAI;;OACjD;KACN,oBAAC,OAAA;MACC,WAAW,WAAW,OAAO,4BAA4B,OAAO,mCAAmC;MACnG,OAAO;OACL,SAAS,CAAC,wBAAwB,sBAAsB,IAAI;OAC5D,QAAQ,mBAAmB,eAAe;OAC3C;OACD;;KACE,EACL,oBACC,oBAAC,OAAA;IAAI,WAAW,OAAO;IAAgB,KAAK;cACzC,gBACC,gBAEA,qBAAA,UAAA,EAAA,UAAA,CACG,mBAAmB,oBAAC,gBAAA;KAAO,eAAe,UAAU,gBAAgB;eAAG;MAA2B,EAClG,qBACC,oBAAC,gBAAA;KAAO,SAAQ;KAAa,eAAe,UAAU,kBAAkB;eACrE;MACM,CAAA,EAAA,CAEV;KAED,CAAA;IAEJ,CAAA;GACF;;AChTV,IAAA,mBDoTe"}
1
+ {"version":3,"file":"Drawer.js","names":["Drawer: React.FC<DrawerProps>","InnerDrawer: React.FC<InnerDrawerProps>","mergedResources: HNDesignsystemDrawer"],"sources":["../src/resources/HN.Designsystem.Drawer.en-GB.json","../src/resources/HN.Designsystem.Drawer.nb-NO.json","../src/resources/HN.Designsystem.Drawer.nn-NO.json","../src/components/Drawer/resourceHelper.ts","../src/components/Drawer/Drawer.tsx","../src/components/Drawer/index.ts"],"sourcesContent":["{\n \"ariaLabelBackButton\": \"Go back\",\n \"ariaLabelCloseBtn\": \"Close\"\n}\n","{\n \"ariaLabelBackButton\": \"Gå tilbake\",\n \"ariaLabelCloseBtn\": \"Lukk\"\n}\n","{\n \"ariaLabelCloseBtn\": \"Lukk\",\n \"ariaLabelBackButton\": \"Gå tilbake\"\n}\n","import type { HNDesignsystemDrawer } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Drawer.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Drawer.nb-NO.json';\nimport nnNO from '../../resources/HN.Designsystem.Drawer.nn-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemDrawer => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN_NYNORSK:\n return nnNO;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React, { useEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\nimport { AnimatePresence, useAnimate, usePresence } from 'motion/react';\n\nimport type { HNDesignsystemDrawer } from '../../resources/Resources';\nimport type { TitleTags } from '../Title';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, KeyboardEventKey, LanguageLocales, ZIndex } from '../../constants';\nimport useFocusTrap from '../../hooks/useFocusTrap';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useKeyboardEvent } from '../../hooks/useKeyboardEvent';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { useReturnFocusOnUnmount } from '../../hooks/useReturnFocusOnUnmount';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { disableBodyScroll, enableBodyScroll } from '../../utils/scroll';\nimport uuid from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Icon from '../Icon';\nimport ChevronLeft from '../Icons/ChevronLeft';\nimport Title from '../Title';\n\nimport styles from './styles.module.scss';\n\ntype DesktopDirections = 'left' | 'right';\n\nexport interface DrawerProps extends InnerDrawerProps {\n /** Opens and closes the drawer */\n isOpen: boolean;\n}\n\nexport interface InnerDrawerProps {\n /** Sets the aria-label of the drawer */\n ariaLabel?: string;\n /** Sets the aria-labelledby of the drawer */\n ariaLabelledBy?: string;\n /** Sets the style of the Drawer Close button. Meant for use by HelpDrawer */\n closeColor?: 'blueberry' | 'plum';\n /** Direction of the drawer on desktop. Default: left */\n desktopDirection?: DesktopDirections;\n /** Sets the style of the Drawer header */\n headerClasses?: string;\n /** Title to display in the header of the drawer */\n title: string;\n /** id of the drawer title */\n titleId?: string;\n /** Changes the underlying element of the title. Default: h3 */\n titleHtmlMarkup?: TitleTags;\n /** Callback that triggers when clicking on close button or outside the drawer, update isOpen state when this triggers */\n onRequestClose?: () => void;\n /** Optional footer content that can be rendered instead of default CTA(s) */\n footerContent?: React.ReactNode;\n /** Main content of the drawer */\n children?: React.ReactNode;\n /** Hides the close button */\n noCloseButton?: boolean;\n /** Primary CTA callback */\n onPrimaryAction?: () => void;\n /** Text for primary CTA button if you want a default CTA button rendered (instead of `footerContent`) */\n primaryActionText?: string;\n /** Text for secondary CTA button if you want a default CTA button rendered (instead of `footerContent`) */\n secondaryActionText?: string;\n /** Secondary CTA callback */\n onSecondaryAction?: () => void;\n /** Customize the z-index of the drawer */\n zIndex?: number;\n /** Resources for component */\n resources?: Partial<HNDesignsystemDrawer>;\n /** Sets mobile styling and animation from outer level Drawer */\n isMobile?: boolean;\n /** Shows a back button to the left of title */\n withBackButton?: boolean;\n /** Callback for the back button */\n onRequestBack?: () => void;\n /** Sets classname for content part in Drawer */\n contentClassName?: string;\n}\n\nconst Drawer: React.FC<DrawerProps> = props => {\n const { isOpen, ...rest } = props;\n const isMobile = useIsMobileBreakpoint();\n\n return <AnimatePresence>{isOpen && <InnerDrawer {...rest} isMobile={isMobile} />}</AnimatePresence>;\n};\n\nconst InnerDrawer: React.FC<InnerDrawerProps> = props => {\n const {\n ariaLabel,\n ariaLabelledBy,\n children,\n closeColor = 'blueberry',\n desktopDirection = 'left',\n footerContent,\n headerClasses,\n noCloseButton = false,\n onPrimaryAction,\n onRequestClose,\n onSecondaryAction,\n primaryActionText,\n secondaryActionText,\n title,\n titleHtmlMarkup = 'h3',\n titleId = uuid(),\n zIndex = ZIndex.OverlayScreen,\n resources,\n isMobile,\n withBackButton,\n onRequestBack,\n contentClassName,\n } = props;\n\n const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledBy, fallbackId: titleId });\n const overlayRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n // topContent and bottomContent are used to detect scroll position for shadow effects\n const topContent = useRef<HTMLDivElement>(null);\n const bottomContent = useRef<HTMLDivElement>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n const footerRef = useRef<HTMLDivElement>(null);\n const titleRef = useRef<HTMLHeadingElement>(null);\n const [scope, animate] = useAnimate();\n const [isPresent, safeToRemove] = usePresence();\n const [headerHeight, setHeaderHeight] = React.useState(0);\n const [footerHeight, setFooterHeight] = React.useState(0);\n const topContentVisible = useIsVisible(topContent);\n const bottomContentVisible = useIsVisible(bottomContent, 0);\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemDrawer = {\n ...defaultResources,\n ...resources,\n };\n\n // eslint-disable-next-line react-hooks/refs\n const contentIsScrollable = contentRef.current && contentRef.current.scrollHeight > contentRef.current.clientHeight;\n const headerStyling = classNames(styles.drawer__header, headerClasses);\n const hasFooterContent = (typeof footerContent !== 'undefined' && footerContent) || onPrimaryAction || onSecondaryAction;\n\n useFocusTrap(containerRef, true);\n useReturnFocusOnUnmount(containerRef);\n useOutsideEvent(containerRef, () => {\n if (onRequestClose) onRequestClose();\n });\n useKeyboardEvent(containerRef, () => onRequestClose && onRequestClose(), [KeyboardEventKey.Escape]);\n\n // Close animasjon, vi kaller `onClose()` til slutt\n const closeDrawer = (): void => {\n if (!overlayRef.current || !containerRef.current) return;\n\n animate(overlayRef.current, { opacity: 0, pointerEvents: 'none' }, { duration: 0.3, ease: 'easeInOut' });\n\n if (isMobile) {\n animate(\n containerRef.current,\n { y: '100%' },\n {\n duration: 0.3,\n ease: 'easeInOut',\n onComplete: () => {\n if (safeToRemove) safeToRemove();\n },\n }\n );\n } else {\n animate(\n containerRef.current,\n { x: desktopDirection === 'left' ? '-100%' : '100%' },\n {\n duration: 0.3,\n ease: 'easeInOut',\n onComplete: () => {\n if (safeToRemove) safeToRemove();\n },\n }\n );\n }\n };\n\n useEffect(() => {\n containerRef.current?.focus();\n disableBodyScroll();\n\n return (): void => {\n enableBodyScroll();\n };\n }, []);\n\n // Measure header and footer heights\n useEffect(() => {\n const updateHeights = (): void => {\n if (headerRef.current) {\n setHeaderHeight(headerRef.current.offsetHeight);\n }\n if (footerRef.current) {\n setFooterHeight(footerRef.current.offsetHeight);\n }\n };\n\n updateHeights();\n\n // Update heights when content changes\n const resizeObserver = new ResizeObserver(updateHeights);\n if (headerRef.current) {\n resizeObserver.observe(headerRef.current);\n }\n if (footerRef.current) {\n resizeObserver.observe(footerRef.current);\n }\n\n return (): void => {\n resizeObserver.disconnect();\n };\n }, [hasFooterContent]);\n\n // Open animation.\n useEffect(() => {\n if (!overlayRef.current || !containerRef.current) return;\n\n if (!isPresent) {\n closeDrawer();\n return;\n }\n\n if (isMobile) {\n animate(containerRef.current, { y: '0' }, { duration: 0.3, ease: 'easeInOut' });\n } else {\n animate(containerRef.current, { x: '0' }, { duration: 0.3, ease: 'easeInOut' });\n }\n\n animate(overlayRef.current, { opacity: 1, pointerEvents: 'auto' }, { duration: 0.3, ease: 'easeInOut' });\n }, [isPresent]);\n\n const handleCTA = (callback?: () => void): void => {\n if (callback) {\n callback();\n }\n };\n\n useEffect(() => {\n titleRef.current?.focus();\n }, [title]);\n\n return (\n <div className={styles.drawer} ref={scope} style={{ zIndex }} data-analyticsid={AnalyticsId.Drawer}>\n <div className={styles.drawer__overlay} ref={overlayRef} aria-hidden=\"true\" />\n <div\n className={classNames(styles.drawer__container, {\n [styles['drawer__container--right']]: desktopDirection === 'right',\n })}\n ref={containerRef}\n role=\"dialog\"\n aria-modal=\"true\"\n tabIndex={-1}\n {...ariaLabelAttributes}\n >\n <div className={styles.drawer__container__inner}>\n <div className={headerStyling} ref={headerRef}>\n <Title\n id={ariaLabelAttributes?.['aria-labelledby']}\n className={styles['drawer__header__title']}\n htmlMarkup={titleHtmlMarkup}\n appearance=\"title3\"\n ref={titleRef}\n tabIndex={-1}\n >\n {title}\n </Title>\n {withBackButton && onRequestBack !== undefined && (\n <Button\n ariaLabel={mergedResources.ariaLabelBackButton}\n onClick={onRequestBack}\n variant=\"borderless\"\n wrapperClassName={styles['drawer__header__back-button']}\n >\n <Icon svgIcon={ChevronLeft} />\n </Button>\n )}\n {!noCloseButton && onRequestClose != undefined && (\n <Close\n ariaLabel={mergedResources.ariaLabelCloseBtn}\n color={closeColor}\n onClick={onRequestClose}\n className={styles['drawer__header__close-button']}\n />\n )}\n </div>\n <div\n className={classNames(styles['drawer__content__shadow'], styles['drawer__content__shadow--top'])}\n style={{\n opacity: !topContentVisible && contentIsScrollable ? 1 : 0,\n top: headerHeight,\n }}\n />\n <div\n className={classNames(styles.drawer__content, contentClassName)}\n tabIndex={contentIsScrollable ? 0 : undefined}\n role={contentIsScrollable ? 'region' : undefined}\n {...(contentIsScrollable ? ariaLabelAttributes : {})}\n ref={contentRef}\n >\n <div ref={topContent} />\n <div className={styles['drawer__content__children']}>{children}</div>\n <div ref={bottomContent} style={{ height: '1px' }} />\n </div>\n <div\n className={classNames(styles['drawer__content__shadow'], styles['drawer__content__shadow--bottom'])}\n style={{\n opacity: !bottomContentVisible && contentIsScrollable ? 1 : 0,\n bottom: hasFooterContent ? footerHeight : 0,\n }}\n />\n </div>\n {hasFooterContent && (\n <div className={styles.drawer__footer} ref={footerRef}>\n {footerContent ? (\n footerContent\n ) : (\n <>\n {onPrimaryAction && <Button onClick={() => handleCTA(onPrimaryAction)}>{primaryActionText}</Button>}\n {onSecondaryAction && (\n <Button variant=\"borderless\" onClick={() => handleCTA(onSecondaryAction)}>\n {secondaryActionText}\n </Button>\n )}\n </>\n )}\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default Drawer;\n","import Drawer from './Drawer';\nexport * from './Drawer';\nexport default Drawer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AGOA,MAAa,gBAAgB,aAAoD;AAC/E,SAAQ,UAAR;EACE,KAAK,gBAAgB,QACnB,QAAO;EACT,KAAK,gBAAgB,kBACnB,QAAO;EACT,KAAK,gBAAgB;EACrB,QACE,QAAO;;;ACmEb,IAAMA,UAAgC,UAAS;CAC7C,MAAM,EAAE,QAAQ,GAAG,SAAS;CAC5B,MAAM,WAAW,uBAAuB;AAExC,QAAO,oBAAC,iBAAA,EAAA,UAAiB,UAAU,oBAAC,aAAA;EAAY,GAAI;EAAgB;GAAY,EAAA,CAAmB;;AAGrG,IAAMC,eAA0C,UAAS;CACvD,MAAM,EACJ,WACA,gBACA,UACA,aAAa,aACb,mBAAmB,QACnB,eACA,eACA,gBAAgB,OAChB,iBACA,gBACA,mBACA,mBACA,qBACA,OACA,kBAAkB,MAClB,UAAU,cAAM,EAChB,SAAS,OAAO,eAChB,WACA,UACA,gBACA,eACA,qBACE;CAEJ,MAAM,sBAAsB,uBAAuB;EAAE,OAAO;EAAW,IAAI;EAAgB,YAAY;EAAS,CAAC;CACjH,MAAM,aAAa,OAAuB,KAAK;CAC/C,MAAM,eAAe,OAAuB,KAAK;CACjD,MAAM,aAAa,OAAuB,KAAK;CAE/C,MAAM,aAAa,OAAuB,KAAK;CAC/C,MAAM,gBAAgB,OAAuB,KAAK;CAClD,MAAM,YAAY,OAAuB,KAAK;CAC9C,MAAM,YAAY,OAAuB,KAAK;CAC9C,MAAM,WAAW,OAA2B,KAAK;CACjD,MAAM,CAAC,OAAO,WAAW,YAAY;CACrC,MAAM,CAAC,WAAW,gBAAgB,aAAa;CAC/C,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS,EAAE;CACzD,MAAM,CAAC,cAA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ED,CAAA;IAEJ,CAAA;GACF;;AC7UV,IAAA,mBDiVe"}
@@ -0,0 +1,81 @@
1
+ import { t as Drawer_default } from "./Drawer.js";
2
+ import { Children, createContext, isValidElement, useCallback, useContext, useMemo, useState } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ const DrawerNavigationContext = createContext(null);
5
+ function useDrawerNavigation() {
6
+ const context = useContext(DrawerNavigationContext);
7
+ if (!context) throw new Error("useDrawerNavigation must be used inside a <DrawerNavigation> component");
8
+ return context;
9
+ }
10
+ function DrawerView(_props) {
11
+ return null;
12
+ }
13
+ function parseChildren(children) {
14
+ const views = [];
15
+ const other = [];
16
+ Children.forEach(children, (child) => {
17
+ if (isValidElement(child) && child.type === DrawerView) views.push({
18
+ id: child.props.id,
19
+ title: child.props.title,
20
+ home: child.props.home,
21
+ children: child.props.children,
22
+ onCloseButton: child.props.onCloseButton,
23
+ footer: child.props.footer,
24
+ drawerContentClassname: child.props.drawerContentClassname
25
+ });
26
+ else other.push(child);
27
+ });
28
+ return {
29
+ views,
30
+ other
31
+ };
32
+ }
33
+ function DrawerNavigation({ children, isOpen, initialView, onCloseButton, footer }) {
34
+ const { views, other } = useMemo(() => parseChildren(children), [children]);
35
+ const homeView = views.find((v) => v.home) ?? views[0];
36
+ const [viewStack, setViewStack] = useState([homeView?.id]);
37
+ const goToView = useCallback((id) => {
38
+ if (views.some((v) => v.id === id)) setViewStack((stack) => [...stack, id]);
39
+ }, [views]);
40
+ const goBack = useCallback(() => {
41
+ setViewStack((stack) => stack.length > 1 ? stack.slice(0, -1) : stack);
42
+ }, []);
43
+ const goToViewAndClearStack = useCallback((id) => {
44
+ if (views.some((v) => v.id === id)) setViewStack(id === homeView?.id ? [homeView.id] : [homeView?.id, id]);
45
+ }, [views, homeView]);
46
+ const currentViewId = viewStack[viewStack.length - 1];
47
+ const currentView = views.find((v) => v.id === currentViewId);
48
+ const navigate = useMemo(() => ({
49
+ goBack,
50
+ goToView,
51
+ goToViewAndClearStack
52
+ }), [
53
+ goBack,
54
+ goToView,
55
+ goToViewAndClearStack
56
+ ]);
57
+ const [prevIsOpen, setPrevIsOpen] = useState(isOpen);
58
+ if (prevIsOpen !== isOpen) {
59
+ setPrevIsOpen(isOpen);
60
+ if (!isOpen) setViewStack([homeView?.id]);
61
+ else if (initialView && views.some((v) => v.id === initialView)) setViewStack(initialView === homeView?.id ? [homeView.id] : [homeView?.id, initialView]);
62
+ }
63
+ return /* @__PURE__ */ jsxs(DrawerNavigationContext.Provider, {
64
+ value: navigate,
65
+ children: [/* @__PURE__ */ jsx(Drawer_default, {
66
+ isOpen,
67
+ title: currentView?.title ?? "Filter",
68
+ withBackButton: viewStack.length > 1,
69
+ onRequestBack: goBack,
70
+ onRequestClose: currentView?.onCloseButton ?? onCloseButton,
71
+ footerContent: currentView?.footer ?? footer,
72
+ contentClassName: currentView?.drawerContentClassname,
73
+ children: currentView?.children
74
+ }), other]
75
+ });
76
+ }
77
+ DrawerNavigation.View = DrawerView;
78
+ var DrawerNavigation_default = DrawerNavigation;
79
+ export { DrawerNavigationContext as n, useDrawerNavigation as r, DrawerNavigation_default as t };
80
+
81
+ //# sourceMappingURL=DrawerNavigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DrawerNavigation.js","names":["views: DrawerViewProps[]","other: React.ReactNode[]"],"sources":["../src/components/Filter/DrawerNavigation/useDrawerNavigation.ts","../src/components/Filter/DrawerNavigation/DrawerNavigation.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nexport interface NavigateProps<ViewId extends string = string> {\n goToView: (id: ViewId) => void;\n goBack: () => void;\n goToViewAndClearStack: (id: ViewId) => void;\n}\n\nexport const DrawerNavigationContext = createContext<NavigateProps | null>(null);\n\nexport function useDrawerNavigation<ViewId extends string = string>(): NavigateProps<ViewId> {\n const context = useContext(DrawerNavigationContext);\n if (!context) {\n throw new Error('useDrawerNavigation must be used inside a <DrawerNavigation> component');\n }\n return context as NavigateProps<ViewId>;\n}\n","import type React from 'react';\nimport { Children, isValidElement, useCallback, useMemo, useState } from 'react';\n\nimport { type NavigateProps, DrawerNavigationContext } from './useDrawerNavigation';\nimport Drawer from '../../Drawer';\n\nexport interface DrawerViewProps<ViewId extends string = string> {\n /** Id for the view. Important for navigation */\n id: ViewId;\n /** Title used for Drawer in current view */\n title: string;\n /** Mark this view as the home/default view */\n home?: boolean;\n /** Content inside the drawer for this view */\n children: React.ReactNode;\n /** Default onClose callback for drawer. Will override onCloseButton on parent */\n onCloseButton?: () => void;\n /** Content sent to footer section of Drawer. Will override footer on parent */\n footer?: React.ReactNode;\n /** Classname set on the content inside Drawer */\n drawerContentClassname?: string;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction DrawerView<ViewId extends string>(_props: DrawerViewProps<ViewId>): React.ReactNode {\n // DrawerView is never rendered directly — DrawerNavigation reads its props\n return null;\n}\n\nexport interface DrawerNavigationProps {\n /** Views and other children components inside the Drawer navigation. Views are put in stack */\n children: React.ReactNode;\n /** Is drawer open or closed */\n isOpen: boolean;\n /** Navigate to this view when the drawer opens. Defaults to home view. */\n initialView?: string;\n /** Default onClose callback for drawer. View onCloseButton callback will override this. */\n onCloseButton?: () => void;\n /** Content sent to footer section of Drawer. View footer will override this */\n footer?: React.ReactNode;\n}\n\nfunction parseChildren(children: React.ReactNode): { views: DrawerViewProps[]; other: React.ReactNode[] } {\n const views: DrawerViewProps[] = [];\n const other: React.ReactNode[] = [];\n Children.forEach(children, child => {\n if (isValidElement<DrawerViewProps>(child) && child.type === DrawerView) {\n views.push({\n id: child.props.id,\n title: child.props.title,\n home: child.props.home,\n children: child.props.children,\n onCloseButton: child.props.onCloseButton,\n footer: child.props.footer,\n drawerContentClassname: child.props.drawerContentClassname,\n });\n } else {\n /** Added possibility of other children to support Modals that need navigation context */\n other.push(child);\n }\n });\n return { views, other };\n}\n\nfunction DrawerNavigation({ children, isOpen, initialView, onCloseButton, footer }: DrawerNavigationProps): React.ReactNode {\n const { views, other } = useMemo(() => parseChildren(children), [children]);\n\n const homeView = views.find(v => v.home) ?? views[0];\n const [viewStack, setViewStack] = useState<string[]>([homeView?.id]);\n\n const goToView = useCallback(\n (id: string): void => {\n if (views.some(v => v.id === id)) {\n setViewStack(stack => [...stack, id]);\n }\n },\n [views]\n );\n\n const goBack = useCallback((): void => {\n setViewStack(stack => (stack.length > 1 ? stack.slice(0, -1) : stack));\n }, []);\n\n const goToViewAndClearStack = useCallback(\n (id: string): void => {\n if (views.some(v => v.id === id)) {\n setViewStack(id === homeView?.id ? [homeView.id] : [homeView?.id, id]);\n }\n },\n [views, homeView]\n );\n\n const currentViewId = viewStack[viewStack.length - 1];\n const currentView = views.find(v => v.id === currentViewId);\n\n const navigate = useMemo<NavigateProps>(() => ({ goBack, goToView, goToViewAndClearStack }), [goBack, goToView, goToViewAndClearStack]);\n\n const [prevIsOpen, setPrevIsOpen] = useState(isOpen);\n if (prevIsOpen !== isOpen) {\n setPrevIsOpen(isOpen);\n if (!isOpen) {\n setViewStack([homeView?.id]);\n } else if (initialView && views.some(v => v.id === initialView)) {\n setViewStack(initialView === homeView?.id ? [homeView.id] : [homeView?.id, initialView]);\n }\n }\n\n return (\n <DrawerNavigationContext.Provider value={navigate}>\n <Drawer\n isOpen={isOpen}\n title={currentView?.title ?? 'Filter'}\n withBackButton={viewStack.length > 1}\n onRequestBack={goBack}\n onRequestClose={currentView?.onCloseButton ?? onCloseButton}\n footerContent={currentView?.footer ?? footer}\n contentClassName={currentView?.drawerContentClassname}\n >\n {currentView?.children}\n </Drawer>\n {other}\n </DrawerNavigationContext.Provider>\n );\n}\n\nDrawerNavigation.View = DrawerView;\n\nexport default DrawerNavigation;\n"],"mappings":";;;AAQA,MAAa,0BAA0B,cAAoC,KAAK;AAEhF,SAAgB,sBAA6E;CAC3F,MAAM,UAAU,WAAW,wBAAwB;AACnD,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,yEAAyE;AAE3F,QAAO;;ACST,SAAS,WAAkC,QAAkD;AAE3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AE,OAAO,cAAc;CAE3D,MAAM,WAAW,eAA8B;EAAE;EAAQ;EAAU;EAAuB,GAAG;EAAC;EAAQ;EAAU;EAAsB,CAAC;CAEvI,MAAM,CAAC,YAAY,iBAAiB,SAAS,OAAO;AACpD,KAAI,eAAe,QAAQ;AACzB,gBAAc,OAAO;AACrB,MAAI,CAAC,OACH,cAAa,CAAC,UAAU,GAAG,CAAC;WACnB,eAAe,MAAM,MAAK,MAAK,EAAE,OAAO,YAAY,CAC7D,cAAa,gBAAgB,UAAU,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,UAAU,IAAI,YAAY,CAAC;;AAI5F,QACE,qBAAC,wBAAwB,UAAA;EAAS,OAAO;aACvC,oBAAC,gBAAA;GACS;GACR,OAAO,aAAa,SAAS;GAC7B,gBAAgB,UAAU,SAAS;GACnC,eAAe;GACf,gBAAgB,aAAa,iBAAiB;GAC9C,eAAe,aAAa,UAAU;GACtC,kBAAkB,aAAa;aAE9B,aAAa;IACP,EACR,MAAA;GACgC;;AAIvC,iBAAiB,OAAO;AAExB,IAAA,2BAAe"}
@@ -0,0 +1,5 @@
1
+ import { t as DrawerNavigation_default } from "./DrawerNavigation.js";
2
+ var DrawerNavigation_default$1 = DrawerNavigation_default;
3
+ export { DrawerNavigation_default$1 as t };
4
+
5
+ //# sourceMappingURL=DrawerNavigation2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DrawerNavigation2.js","names":[],"sources":["../src/components/Filter/DrawerNavigation/index.ts"],"sourcesContent":["import DrawerNavigation from './DrawerNavigation';\nexport * from './DrawerNavigation';\nexport * from './useDrawerNavigation';\nexport default DrawerNavigation;\n"],"mappings":";AAGA,IAAA,6BAAe"}
package/lib/Duolist.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { n as AnalyticsId } from "./constants2.js";
2
2
  import { n as useBreakpoint, t as Breakpoint } from "./useBreakpoint.js";
3
3
  import { t as Spacer_default } from "./Spacer.js";
4
- import classNames from "classnames";
4
+ import cn from "classnames";
5
5
  import React from "react";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  import duolistStyles from "./components/Duolist/styles.module.scss";
@@ -10,11 +10,11 @@ const DuolistGroup = (props) => {
10
10
  const firstBold = boldColumn === "first";
11
11
  const secondBold = boldColumn === "second";
12
12
  const nonFormatted = format === "non-formatted";
13
- const dtClassNames = classNames(duolistStyles["duolist__dt"], {
13
+ const dtClassNames = cn(duolistStyles["duolist__dt"], {
14
14
  [duolistStyles["duolist__dt--bold"]]: firstBold,
15
15
  [duolistStyles["duolist__dt--non-formatted"]]: nonFormatted
16
16
  });
17
- const ddClassNames = classNames(duolistStyles["duolist__dd"], {
17
+ const ddClassNames = cn(duolistStyles["duolist__dd"], {
18
18
  [duolistStyles["duolist__dd--bold"]]: secondBold,
19
19
  [duolistStyles["duolist__dd--non-formatted"]]: nonFormatted
20
20
  });
@@ -40,11 +40,11 @@ const Duolist = (props) => {
40
40
  const nonFormatted = format === "non-formatted";
41
41
  const breakpoint = useBreakpoint();
42
42
  const useCollapsedMode = useCollapsedFromAndBelowBreakpoint && breakpoint <= Breakpoint[useCollapsedFromAndBelowBreakpoint];
43
- const duolistWrapperClasses = classNames({
43
+ const duolistWrapperClasses = cn({
44
44
  [duolistStyles["duolist-wrapper--border"]]: hasBorder,
45
45
  [duolistStyles["duolist-wrapper--extra-padding-top"]]: extraPaddingTop
46
46
  }, className);
47
- const duolistClasses = classNames(duolistStyles.duolist, {
47
+ const duolistClasses = cn(duolistStyles.duolist, {
48
48
  [duolistStyles["duolist--line"]]: hasLines,
49
49
  [duolistStyles["duolist--non-formatted"]]: nonFormatted,
50
50
  [duolistStyles["duolist--collapsed"]]: useCollapsedMode,
@@ -1 +1 @@
1
- {"version":3,"file":"Duolist.js","names":["DuolistGroup: React.FC<DuolistGroupProps>","Duolist: React.FC<DuolistProps>"],"sources":["../src/components/Duolist/Duolist.tsx","../src/components/Duolist/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { TitleProps } from '../Title';\n\nimport { AnalyticsId } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport Spacer from '../Spacer';\n\nimport duolistStyles from './styles.module.scss';\n\nexport type DuolistVariants = 'normal' | 'line';\nexport type BoldColumn = 'first' | 'second' | 'none';\nexport type Border = 'no-border' | 'border';\nexport type Formats = 'formatted' | 'non-formatted';\n\nexport interface DuolistProps {\n /** Determines which column is bold */\n boldColumn?: BoldColumn;\n /** Label of the Duolist */\n border?: Border;\n /** Label of the Duolist */\n label?: React.ReactElement<TitleProps>;\n /** Formatted or non-formatted visual variants */\n format?: Formats;\n /** Character separator for non-formatted format */\n separator?: string;\n /** Sets the visual variant of the Duolist. */\n variant?: DuolistVariants;\n /** Sets the content of the Duolist. */\n children: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Width of the description column in percentage */\n descriptionWidth?: number;\n /** Use collapsed mode on columns from chosen breakpoint and below. */\n useCollapsedFromAndBelowBreakpoint?: keyof typeof Breakpoint;\n}\n\nexport interface DuolistGroupProps {\n /** Determines which column is bold */\n boldColumn?: BoldColumn;\n /** Sets content of the <dd> tag. */\n description: React.ReactNode;\n /** Formatted or non-formatted visual variants */\n format?: Formats;\n /** Character separator for non-formatted format */\n separator?: string;\n /** Sets content of the <dt> tag. */\n term: React.ReactNode;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const DuolistGroup: React.FC<DuolistGroupProps> = props => {\n const { format = 'formatted', boldColumn = format === 'non-formatted' ? 'none' : 'first', description, separator = ': ', term } = props;\n\n const firstBold = boldColumn === 'first';\n const secondBold = boldColumn === 'second';\n const nonFormatted = format === 'non-formatted';\n\n const dtClassNames = classNames(duolistStyles['duolist__dt'], {\n [duolistStyles['duolist__dt--bold']]: firstBold,\n [duolistStyles['duolist__dt--non-formatted']]: nonFormatted,\n });\n const ddClassNames = classNames(duolistStyles['duolist__dd'], {\n [duolistStyles['duolist__dd--bold']]: secondBold,\n [duolistStyles['duolist__dd--non-formatted']]: nonFormatted,\n });\n\n const renderContent = () => {\n return (\n <>\n <dt\n data-separator={nonFormatted ? separator : undefined}\n className={dtClassNames}\n data-testid={props.testId && `${props.testId}-term`}\n >\n {term}\n </dt>\n <dd className={ddClassNames} data-testid={props.testId && `${props.testId}-description`}>\n {description}\n </dd>\n </>\n );\n };\n\n return nonFormatted ? <div>{renderContent()}</div> : <>{renderContent()}</>;\n};\n\nexport const Duolist: React.FC<DuolistProps> = props => {\n const {\n boldColumn,\n border = 'no-border',\n descriptionWidth,\n label,\n format = 'formatted',\n separator,\n variant = 'normal',\n children,\n className,\n testId,\n useCollapsedFromAndBelowBreakpoint,\n } = props;\n\n const hasBorder = border === 'border';\n const hasLines = variant === 'line';\n const extraPaddingTop = hasBorder && (label || hasLines);\n const nonFormatted = format === 'non-formatted';\n const breakpoint = useBreakpoint();\n const useCollapsedMode = useCollapsedFromAndBelowBreakpoint && breakpoint <= Breakpoint[useCollapsedFromAndBelowBreakpoint];\n\n const duolistWrapperClasses = classNames(\n {\n [duolistStyles['duolist-wrapper--border']]: hasBorder,\n [duolistStyles['duolist-wrapper--extra-padding-top']]: extraPaddingTop,\n },\n className\n );\n\n const duolistClasses = classNames(duolistStyles.duolist, {\n [duolistStyles['duolist--line']]: hasLines,\n [duolistStyles['duolist--non-formatted']]: nonFormatted,\n [duolistStyles['duolist--collapsed']]: useCollapsedMode,\n [duolistStyles['duolist--not-collapsed']]: !useCollapsedMode,\n });\n\n const duolistColumnStyle = descriptionWidth ? descriptionWidth + '%' : 'minmax(60%, 1fr)';\n\n return (\n <div className={duolistWrapperClasses} data-testid={testId} data-analyticsid={AnalyticsId.Duolist}>\n {label && (\n <>\n {label}\n <Spacer />\n </>\n )}\n <dl\n style={!nonFormatted ? { gridTemplateColumns: useCollapsedMode ? `1fr` : `auto ${duolistColumnStyle}` } : undefined}\n className={duolistClasses}\n >\n {React.Children.map(children, (child: React.ReactNode | React.ReactElement<DuolistGroupProps>) => {\n if (child === null || typeof child === 'undefined') return;\n const duolistGroup = child as React.ReactElement<DuolistGroupProps>;\n if (duolistGroup.type === DuolistGroup) {\n return React.cloneElement(child as React.ReactElement<DuolistGroupProps>, {\n ...duolistGroup.props,\n boldColumn: duolistGroup.props.boldColumn ?? boldColumn,\n format: duolistGroup.props.format ?? format,\n separator: duolistGroup.props.separator ?? separator,\n });\n }\n })}\n </dl>\n </div>\n );\n};\n\nexport default Duolist;\n","import Duolist from './Duolist';\nexport * from './Duolist';\nexport default Duolist;\n"],"mappings":";;;;;;;AAyDA,MAAaA,gBAA4C,UAAS;CAChE,MAAM,EAAE,SAAS,aAAa,aAAa,WAAW,kBAAkB,SAAS,SAAS,aAAa,YAAY,MAAM,SAAS;CAElI,MAAM,YAAY,eAAe;CACjC,MAAM,aAAa,eAAe;CAClC,MAAM,eAAe,WAAW;CAEhC,MAAM,eAAe,WAAW,cAAc,gBAAgB;GAC3D,cAAc,uBAAuB;GACrC,cAAc,gCAAgC;EAChD,CAAC;CACF,MAAM,eAAe,WAAW,cAAc,gBAAgB;GAC3D,cAAc,uBAAuB;GACrC,cAAc,gCAAgC;EAChD,CAAC;CAEF,MAAM,sBAAsB;AAC1B,SACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,MAAA;GACC,kBAAgB,eAAe,YAAY,KAAA;GAC3C,WAAW;GACX,eAAa,MAAM,UAAU,GAAG,MAAM,OAAO;aAE5C;IACE,EACL,oBAAC,MAAA;GAAG,WAAW;GAAc,eAAa,MAAM,UAAU,GAAG,MAAM,OAAO;aACvE;IACE,CAAA,EAAA,CACJ;;AAIP,QAAO,eAAe,oBAAC,OAAA,EAAA,UAAK,eAAe,EAAA,CAAO,GAAG,oBAAA,UAAA,EAAA,UAAG,eAAe,EAAA,CAAI;;AAG7E,MAAaC,WAAkC,UAAS;CACtD,MAAM,EACJ,YACA,SAAS,aACT,kBACA,OACA,SAAS,aACT,WACA,UAAU,UACV,UACA,WACA,QACA,uCACE;CAEJ,MAAM,YAAY,WAAW;CAC7B,MAAM,WAAW,YAAY;CAC7B,MAAM,kBAAkB,cAAc,SAAS;CAC/C,MAAM,eAAe,WAAW;CAChC,MAAM,aAAa,eAAe;CAClC,MAAM,mBAAmB,sCAAsC,cAAc,WAAW;CAExF,MAAM,wBAAwB,WAC5B;GACG,cAAc,6BAA6B;GAC3C,cAAc,wCAAwC;EACxD,EACD,UACD;CAED,MAAM,iBAAiB,WAAW,cAAc,SAAS;GACtD,cAAc,mBAAmB;GACjC,cAAc,4BAA4B;GAC1C,cAAc,wBAAwB;GACtC,cAAc,4BAA4B,CAAC;EAC7C,CAAC;CAEF,MAAM,qBAAqB,mBAAmB,mBAAmB,MAAM;AAEvE,QACE,qBAAC,OAAA;EAAI,WAAW;EAAuB,eAAa;EAAQ,oBAAkB,YAAY;aACvF,SACC,qBAAA,UAAA,EAAA,UAAA,CACG,OACD,oBAAC,gBAAA,EAAA,CAAS,CAAA,EAAA,CACT,EAEL,oBAAC,MAAA;GACC,OAAO,CAAC,eAAe,EAAE,qBAAqB,mBAAmB,QAAQ,QAAQ,sBAAsB,GAAG,KAAA;GAC1G,WAAW;aAEV,MAAM,SAAS,IAAI,WAAW,UAAmE;AAChG,QAAI,UAAU,QAAQ,OAAO,UAAU,YAAa;IACpD,MAAM,eAAe;AACrB,QAAI,aAAa,SAAS,aACxB,QAAO,MAAM,aAAa,OAAgD;KACxE,GAAG,aAAa;KAChB,YAAY,aAAa,MAAM,cAAc;KAC7C,QAAQ,aAAa,MAAM,UAAU;KACrC,WAAW,aAAa,MAAM,aAAa;KAC5C,CAAC;KAEJ;IACC,CAAA;GACD;;AC3JV,IAAA,oBD+Je"}
1
+ {"version":3,"file":"Duolist.js","names":["DuolistGroup: React.FC<DuolistGroupProps>","Duolist: React.FC<DuolistProps>"],"sources":["../src/components/Duolist/Duolist.tsx","../src/components/Duolist/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { TitleProps } from '../Title';\n\nimport { AnalyticsId } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport Spacer from '../Spacer';\n\nimport duolistStyles from './styles.module.scss';\n\nexport type DuolistVariants = 'normal' | 'line';\nexport type BoldColumn = 'first' | 'second' | 'none';\nexport type Border = 'no-border' | 'border';\nexport type Formats = 'formatted' | 'non-formatted';\n\nexport interface DuolistProps {\n /** Determines which column is bold */\n boldColumn?: BoldColumn;\n /** Label of the Duolist */\n border?: Border;\n /** Label of the Duolist */\n label?: React.ReactElement<TitleProps>;\n /** Formatted or non-formatted visual variants */\n format?: Formats;\n /** Character separator for non-formatted format */\n separator?: string;\n /** Sets the visual variant of the Duolist. */\n variant?: DuolistVariants;\n /** Sets the content of the Duolist. */\n children: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Width of the description column in percentage */\n descriptionWidth?: number;\n /** Use collapsed mode on columns from chosen breakpoint and below. */\n useCollapsedFromAndBelowBreakpoint?: keyof typeof Breakpoint;\n}\n\nexport interface DuolistGroupProps {\n /** Determines which column is bold */\n boldColumn?: BoldColumn;\n /** Sets content of the <dd> tag. */\n description: React.ReactNode;\n /** Formatted or non-formatted visual variants */\n format?: Formats;\n /** Character separator for non-formatted format */\n separator?: string;\n /** Sets content of the <dt> tag. */\n term: React.ReactNode;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const DuolistGroup: React.FC<DuolistGroupProps> = props => {\n const { format = 'formatted', boldColumn = format === 'non-formatted' ? 'none' : 'first', description, separator = ': ', term } = props;\n\n const firstBold = boldColumn === 'first';\n const secondBold = boldColumn === 'second';\n const nonFormatted = format === 'non-formatted';\n\n const dtClassNames = classNames(duolistStyles['duolist__dt'], {\n [duolistStyles['duolist__dt--bold']]: firstBold,\n [duolistStyles['duolist__dt--non-formatted']]: nonFormatted,\n });\n const ddClassNames = classNames(duolistStyles['duolist__dd'], {\n [duolistStyles['duolist__dd--bold']]: secondBold,\n [duolistStyles['duolist__dd--non-formatted']]: nonFormatted,\n });\n\n const renderContent = () => {\n return (\n <>\n <dt\n data-separator={nonFormatted ? separator : undefined}\n className={dtClassNames}\n data-testid={props.testId && `${props.testId}-term`}\n >\n {term}\n </dt>\n <dd className={ddClassNames} data-testid={props.testId && `${props.testId}-description`}>\n {description}\n </dd>\n </>\n );\n };\n\n return nonFormatted ? <div>{renderContent()}</div> : <>{renderContent()}</>;\n};\n\nexport const Duolist: React.FC<DuolistProps> = props => {\n const {\n boldColumn,\n border = 'no-border',\n descriptionWidth,\n label,\n format = 'formatted',\n separator,\n variant = 'normal',\n children,\n className,\n testId,\n useCollapsedFromAndBelowBreakpoint,\n } = props;\n\n const hasBorder = border === 'border';\n const hasLines = variant === 'line';\n const extraPaddingTop = hasBorder && (label || hasLines);\n const nonFormatted = format === 'non-formatted';\n const breakpoint = useBreakpoint();\n const useCollapsedMode = useCollapsedFromAndBelowBreakpoint && breakpoint <= Breakpoint[useCollapsedFromAndBelowBreakpoint];\n\n const duolistWrapperClasses = classNames(\n {\n [duolistStyles['duolist-wrapper--border']]: hasBorder,\n [duolistStyles['duolist-wrapper--extra-padding-top']]: extraPaddingTop,\n },\n className\n );\n\n const duolistClasses = classNames(duolistStyles.duolist, {\n [duolistStyles['duolist--line']]: hasLines,\n [duolistStyles['duolist--non-formatted']]: nonFormatted,\n [duolistStyles['duolist--collapsed']]: useCollapsedMode,\n [duolistStyles['duolist--not-collapsed']]: !useCollapsedMode,\n });\n\n const duolistColumnStyle = descriptionWidth ? descriptionWidth + '%' : 'minmax(60%, 1fr)';\n\n return (\n <div className={duolistWrapperClasses} data-testid={testId} data-analyticsid={AnalyticsId.Duolist}>\n {label && (\n <>\n {label}\n <Spacer />\n </>\n )}\n <dl\n style={!nonFormatted ? { gridTemplateColumns: useCollapsedMode ? `1fr` : `auto ${duolistColumnStyle}` } : undefined}\n className={duolistClasses}\n >\n {React.Children.map(children, (child: React.ReactNode | React.ReactElement<DuolistGroupProps>) => {\n if (child === null || typeof child === 'undefined') return;\n const duolistGroup = child as React.ReactElement<DuolistGroupProps>;\n if (duolistGroup.type === DuolistGroup) {\n return React.cloneElement(child as React.ReactElement<DuolistGroupProps>, {\n ...duolistGroup.props,\n boldColumn: duolistGroup.props.boldColumn ?? boldColumn,\n format: duolistGroup.props.format ?? format,\n separator: duolistGroup.props.separator ?? separator,\n });\n }\n })}\n </dl>\n </div>\n );\n};\n\nexport default Duolist;\n","import Duolist from './Duolist';\nexport * from './Duolist';\nexport default Duolist;\n"],"mappings":";;;;;;;AAyDA,MAAaA,gBAA4C,UAAS;CAChE,MAAM,EAAE,SAAS,aAAa,aAAa,WAAW,kBAAkB,SAAS,SAAS,aAAa,YAAY,MAAM,SAAS;CAElI,MAAM,YAAY,eAAe;CACjC,MAAM,aAAa,eAAe;CAClC,MAAM,eAAe,WAAW;CAEhC,MAAM,eAAe,GAAW,cAAc,gBAAgB;GAC3D,cAAc,uBAAuB;GACrC,cAAc,gCAAgC;EAChD,CAAC;CACF,MAAM,eAAe,GAAW,cAAc,gBAAgB;GAC3D,cAAc,uBAAuB;GACrC,cAAc,gCAAgC;EAChD,CAAC;CAEF,MAAM,sBAAsB;AAC1B,SACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,MAAA;GACC,kBAAgB,eAAe,YAAY,KAAA;GAC3C,WAAW;GACX,eAAa,MAAM,UAAU,GAAG,MAAM,OAAO;aAE5C;IACE,EACL,oBAAC,MAAA;GAAG,WAAW;GAAc,eAAa,MAAM,UAAU,GAAG,MAAM,OAAO;aACvE;IACE,CAAA,EAAA,CACJ;;AAIP,QAAO,eAAe,oBAAC,OAAA,EAAA,UAAK,eAAe,EAAA,CAAO,GAAG,oBAAA,UAAA,EAAA,UAAG,eAAe,EAAA,CAAI;;AAG7E,MAAaC,WAAkC,UAAS;CACtD,MAAM,EACJ,YACA,SAAS,aACT,kBACA,OACA,SAAS,aACT,WACA,UAAU,UACV,UACA,WACA,QACA,uCACE;CAEJ,MAAM,YAAY,WAAW;CAC7B,MAAM,WAAW,YAAY;CAC7B,MAAM,kBAAkB,cAAc,SAAS;CAC/C,MAAM,eAAe,WAAW;CAChC,MAAM,aAAa,eAAe;CAClC,MAAM,mBAAmB,sCAAsC,cAAc,WAAW;CAExF,MAAM,wBAAwB,GAC5B;GACG,cAAc,6BAA6B;GAC3C,cAAc,wCAAwC;EACxD,EACD,UACD;CAED,MAAM,iBAAiB,GAAW,cAAc,SAAS;GACtD,cAAc,mBAAmB;GACjC,cAAc,4BAA4B;GAC1C,cAAc,wBAAwB;GACtC,cAAc,4BAA4B,CAAC;EAC7C,CAAC;CAEF,MAAM,qBAAqB,mBAAmB,mBAAmB,MAAM;AAEvE,QACE,qBAAC,OAAA;EAAI,WAAW;EAAuB,eAAa;EAAQ,oBAAkB,YAAY;aACvF,SACC,qBAAA,UAAA,EAAA,UAAA,CACG,OACD,oBAAC,gBAAA,EAAA,CAAS,CAAA,EAAA,CACT,EAEL,oBAAC,MAAA;GACC,OAAO,CAAC,eAAe,EAAE,qBAAqB,mBAAmB,QAAQ,QAAQ,sBAAsB,GAAG,KAAA;GAC1G,WAAW;aAEV,MAAM,SAAS,IAAI,WAAW,UAAmE;AAChG,QAAI,UAAU,QAAQ,OAAO,UAAU,YAAa;IACpD,MAAM,eAAe;AACrB,QAAI,aAAa,SAAS,aACxB,QAAO,MAAM,aAAa,OAAgD;KACxE,GAAG,aAAa;KAChB,YAAY,aAAa,MAAM,cAAc;KAC7C,QAAQ,aAAa,MAAM,UAAU;KACrC,WAAW,aAAa,MAAM,aAAa;KAC5C,CAAC;KAEJ;IACC,CAAA;GACD;;AC3JV,IAAA,oBD+Je"}
@@ -9,7 +9,7 @@ import { t as StatusDot_default } from "./StatusDot.js";
9
9
  import { t as Highlighter_default } from "./Highlighter.js";
10
10
  import { n as ElementHeaderText, r as ElementHeaderText_default } from "./ElementHeaderText.js";
11
11
  import { n as StatusDotList, t as StatusDotList_default } from "./StatusDotList.js";
12
- import classNames from "classnames";
12
+ import cn from "classnames";
13
13
  import React from "react";
14
14
  import { jsx, jsxs } from "react/jsx-runtime";
15
15
  import styles from "./components/ElementHeader/styles.module.scss";
@@ -74,17 +74,17 @@ const ElementHeaderRoot = (props) => {
74
74
  const contentIsString = typeof children === "string";
75
75
  const mappedChildren = mapChildren(children);
76
76
  const hasStatusDots = !!mappedChildren?.statusDotChildren?.length || !!mappedChildren?.statusDotMCChild;
77
- const listLabelClasses = classNames(styles["element-header"], { [styles["element-header--compact"]]: size === "compact" }, className);
78
- const badgeContainerClasses = classNames(styles["element-header__badge-container"]);
79
- const badgeClasses = classNames(styles["element-header__badge"]);
80
- const statusdotContainerClasses = classNames(styles["element-header__statusdot-container"]);
81
- const chevronClasses = classNames(styles["element-header__chevron"]);
82
- const contentClasses = classNames(styles["element-header__content"], {
77
+ const listLabelClasses = cn(styles["element-header"], { [styles["element-header--compact"]]: size === "compact" }, className);
78
+ const badgeContainerClasses = cn(styles["element-header__badge-container"]);
79
+ const badgeClasses = cn(styles["element-header__badge"]);
80
+ const statusdotContainerClasses = cn(styles["element-header__statusdot-container"]);
81
+ const chevronClasses = cn(styles["element-header__chevron"]);
82
+ const contentClasses = cn(styles["element-header__content"], {
83
83
  [styles["element-header__content--element"]]: !contentIsString,
84
84
  [styles["element-header__content--compact"]]: size === "compact"
85
85
  });
86
- const iconClasses = classNames(styles["element-header__icon"], { [styles["element-header__icon--with-statusdot"]]: hasStatusDots });
87
- const avatarClasses = classNames(styles["element-header__avatar"], {});
86
+ const iconClasses = cn(styles["element-header__icon"], { [styles["element-header__icon--with-statusdot"]]: hasStatusDots });
87
+ const avatarClasses = cn(styles["element-header__avatar"], {});
88
88
  const CustomTag = titleHtmlMarkup;
89
89
  const iconPropIsIconComponent = isComponent(icon, Icon_default);
90
90
  const iconPropIsLazyIconComponent = !iconPropIsIconComponent && isComponent(icon, LazyIcon_default);
@@ -1 +1 @@
1
- {"version":3,"file":"ElementHeader.js","names":["mapChildren: ChildrenMapper","avatarChild: React.ReactElement<AvatarProps> | undefined","badgeChildren: React.ReactElement<BadgeProps>[]","statusDotChildren: React.ReactElement<StatusDotProps>[]","statusDotMCChild: React.ReactElement<StatusDotListProps> | undefined","elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[]","stringChildren: string[]","remainingChildren: React.ReactNode[]","ElementHeaderRoot: ElementHeaderType"],"sources":["../src/components/ElementHeader/utils.tsx","../src/components/ElementHeader/ElementHeader.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { AvatarProps } from '../Avatar';\nimport type { BadgeProps } from '../Badge';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport ElementHeader, { type ElementHeaderChildren, type ElementHeaderProps } from './ElementHeader';\nimport { ElementHeaderText, type ElementHeaderTextProps } from './ElementHeaderText';\nimport { StatusDotList, type StatusDotListProps } from './StatusDotList';\nimport { isComponent, isComponentWithChildren } from '../../utils/component';\nimport Avatar from '../Avatar';\nimport Badge from '../Badge';\nimport StatusDot from '../StatusDot';\n\ntype ChildrenMapper = (children: React.ReactNode, isJsxChild?: boolean) => ElementHeaderChildren | undefined;\n\nexport const mapChildren: ChildrenMapper = (children, isJsxChild = false) => {\n let avatarChild: React.ReactElement<AvatarProps> | undefined;\n const badgeChildren: React.ReactElement<BadgeProps>[] = [];\n const statusDotChildren: React.ReactElement<StatusDotProps>[] = [];\n let statusDotMCChild: React.ReactElement<StatusDotListProps> | undefined;\n const elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[] = [];\n const stringChildren: string[] = [];\n const remainingChildren: React.ReactNode[] = [];\n\n React.Children.forEach(children, child => {\n if (child === null || typeof child === 'undefined') return;\n if (isComponent<AvatarProps>(child, Avatar)) {\n avatarChild = child;\n } else if (isComponent<ElementHeaderTextProps>(child, ElementHeaderText)) {\n elementHeaderTextChildren.push(child);\n } else if (isComponent<BadgeProps>(child, Badge)) {\n badgeChildren.push(child);\n } else if (isComponent<StatusDotListProps>(child, StatusDotList)) {\n statusDotMCChild = child;\n } else if (isComponent<StatusDotProps>(child, StatusDot)) {\n statusDotChildren.push(child);\n } else if (typeof child === 'string') {\n stringChildren.push(child);\n } else {\n remainingChildren.push(child);\n }\n });\n\n // Dette og recursive mapChildren under(gjøres en gang) er for å passe på at jsx children også sjekkes for Avatar og liknende innhold.\n // Slik opprettholder vi stylingen i tilfeller hvor vertikaler har wrappet elementer i en parent span eller div.\n const hasSpecialChildren =\n avatarChild !== undefined ||\n elementHeaderTextChildren.length > 0 ||\n statusDotChildren.length > 0 ||\n statusDotMCChild !== undefined ||\n (badgeChildren !== undefined && stringChildren.length > 0);\n const noRemainingRecursiveChildren =\n remainingChildren.length === 0 ||\n (isComponentWithChildren(remainingChildren[0]) && typeof remainingChildren[0]?.props?.children === 'undefined');\n\n if (isJsxChild || hasSpecialChildren || noRemainingRecursiveChildren) {\n return {\n avatarChild,\n elementHeaderTextChildren: elementHeaderTextChildren,\n badgeChildren,\n statusDotChildren,\n statusDotMCChild,\n stringChildren,\n remainingChildren,\n };\n }\n\n if (isComponentWithChildren(remainingChildren[0])) {\n return mapChildren(remainingChildren[0]?.props?.children, true);\n }\n};\n\nexport const renderElementHeader = (\n element: React.ReactNode,\n options: Pick<\n ElementHeaderProps,\n 'titleHtmlMarkup' | 'isHovered' | 'size' | 'parentType' | 'chevronIcon' | 'icon' | 'highlightText' | 'closeButton'\n >\n): React.ReactElement | undefined => {\n const { titleHtmlMarkup, isHovered, size, parentType, chevronIcon, icon, highlightText, closeButton } = options;\n\n if (isComponent<ElementHeaderProps>(element, ElementHeader)) {\n return React.cloneElement(element, {\n chevronIcon,\n icon,\n isHovered,\n size,\n parentType,\n highlightText,\n closeButton,\n });\n }\n if (element) {\n return (\n <ElementHeader\n highlightText={highlightText}\n titleHtmlMarkup={titleHtmlMarkup}\n parentType={parentType}\n chevronIcon={chevronIcon}\n icon={icon}\n isHovered={isHovered}\n size={size}\n closeButton={closeButton}\n >\n {element}\n </ElementHeader>\n );\n }\n};\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { AvatarProps, AvatarType } from '../Avatar';\nimport type { BadgeProps, BadgeType } from '../Badge';\nimport type { IconProps, SvgIcon } from '../Icon';\nimport type { LazyIconProps } from '../LazyIcon';\nimport type { StatusDotProps, StatusDotType } from '../StatusDot';\nimport type { TitleTags } from '../Title';\nimport type { ElementHeaderTextProps, ElementHeaderTextType } from './ElementHeaderText/ElementHeaderText';\nimport type { StatusDotListProps, StatusDotListType } from './StatusDotList/StatusDotList';\n\nimport ElementHeaderText from './ElementHeaderText/ElementHeaderText';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { isComponent } from '../../utils/component';\nimport { AvatarSize } from '../Avatar';\nimport Icon, { IconSize } from '../Icon';\nimport StatusDotList from './StatusDotList';\nimport Highlighter from '../Highlighter';\nimport LazyIcon from '../LazyIcon';\nimport { mapChildren } from './utils';\n\nimport styles from './styles.module.scss';\n\nexport type ElementHeaderSize = 'compact' | 'small' | 'medium' | 'large';\nexport type ParentType = 'linklist' | 'expanderlist';\n\nexport interface ElementHeaderType extends React.FC<ElementHeaderProps> {\n Avatar?: AvatarType;\n Badge?: BadgeType;\n ElementHeaderText?: ElementHeaderTextType;\n StatusDot?: StatusDotType;\n StatusDotList?: StatusDotListType;\n}\n\nexport interface ElementHeaderProps {\n /** Adds custom classes to the ElementHeader element. */\n className?: string;\n /** Chevron to render inside of the ElementHeader */\n chevronIcon?: SvgIcon;\n /** Close button to be rendered inside of ElementHeader. This renders in place of chevronIcon */\n closeButton?: React.ReactElement;\n /** Children to be rendered inside of ElementHeader */\n children: React.ReactNode;\n /** Changes the underlying element of the title. Default: h2*/\n titleHtmlMarkup?: TitleTags;\n /** icon to be rendered inside of ElementHeader */\n icon?: React.ReactElement;\n /** whether or not the parent is hovered */\n isHovered?: boolean;\n /** Adjusts styling based on parent */\n parentType?: ParentType;\n /** Changes size of the ElementHeader. */\n size?: ElementHeaderSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Highlights text in title. Used for search results */\n highlightText?: string;\n}\n\nexport interface ElementHeaderChildren {\n avatarChild?: React.ReactElement<AvatarProps>;\n elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[];\n badgeChildren?: React.ReactElement<BadgeProps>[];\n statusDotChildren?: React.ReactElement<StatusDotProps>[];\n statusDotMCChild?: React.ReactElement<StatusDotListProps>;\n elementChild?: React.ReactElement;\n stringChildren: string[];\n remainingChildren: React.ReactNode[];\n}\n\nexport const ElementHeaderRoot: ElementHeaderType = props => {\n const {\n className = '',\n titleHtmlMarkup = 'h2',\n parentType = 'linklist',\n chevronIcon,\n closeButton,\n children,\n icon,\n isHovered,\n size,\n testId,\n highlightText,\n } = props;\n const breakpoint = useBreakpoint();\n const showIcon = size !== 'small' && !!icon;\n const contentIsString = typeof children === 'string';\n const mappedChildren = mapChildren(children);\n const hasStatusDots = !!mappedChildren?.statusDotChildren?.length || !!mappedChildren?.statusDotMCChild;\n\n const listLabelClasses = cn(styles['element-header'], { [styles['element-header--compact']]: size === 'compact' }, className);\n const badgeContainerClasses = cn(styles['element-header__badge-container']);\n const badgeClasses = cn(styles['element-header__badge']);\n const statusdotContainerClasses = cn(styles['element-header__statusdot-container']);\n const chevronClasses = cn(styles['element-header__chevron']);\n const contentClasses = cn(styles['element-header__content'], {\n [styles['element-header__content--element']]: !contentIsString,\n [styles['element-header__content--compact']]: size === 'compact',\n });\n const iconClasses = cn(styles['element-header__icon'], { [styles['element-header__icon--with-statusdot']]: hasStatusDots });\n const avatarClasses = cn(styles['element-header__avatar'], {});\n const CustomTag = titleHtmlMarkup;\n const iconPropIsIconComponent = isComponent<IconProps>(icon, Icon);\n const iconPropIsLazyIconComponent = !iconPropIsIconComponent && isComponent<LazyIconProps>(icon, LazyIcon);\n\n let iconComponent;\n if (iconPropIsIconComponent) {\n iconComponent = React.cloneElement(icon as React.ReactElement<IconProps>, {\n size: breakpoint < Breakpoint.md ? IconSize.XSmall : IconSize.Small,\n isHovered,\n });\n } else if (iconPropIsLazyIconComponent) {\n iconComponent = React.cloneElement(icon as React.ReactElement<LazyIconProps>, {\n size: breakpoint < Breakpoint.md ? IconSize.XSmall : IconSize.Small,\n isHovered,\n });\n } else {\n iconComponent = icon;\n }\n\n return (\n <span data-testid={testId} className={listLabelClasses}>\n {showIcon && icon && <span className={iconClasses}>{iconComponent}</span>}\n {size !== 'small' && mappedChildren?.avatarChild && (\n <span className={avatarClasses}>{React.cloneElement(mappedChildren.avatarChild, { size: AvatarSize.xsmall })}</span>\n )}\n\n <span className={contentClasses} data-hasstatusdots={hasStatusDots}>\n {mappedChildren?.elementHeaderTextChildren}\n {!!mappedChildren?.stringChildren.length && (\n <CustomTag className={styles['element-header__title']}>\n <Highlighter searchText={highlightText}>{mappedChildren.stringChildren}</Highlighter>\n </CustomTag>\n )}\n <Highlighter searchText={highlightText}>{mappedChildren?.remainingChildren}</Highlighter>\n </span>\n\n {hasStatusDots && (\n <span className={statusdotContainerClasses}>\n {!!mappedChildren?.statusDotChildren && <StatusDotList>{mappedChildren.statusDotChildren}</StatusDotList>}\n {!!mappedChildren?.statusDotMCChild && mappedChildren?.statusDotMCChild}\n </span>\n )}\n\n <span className={badgeContainerClasses}>\n {mappedChildren?.badgeChildren &&\n mappedChildren.badgeChildren.map((badgeChild, index) => {\n return (\n <span key={index} className={badgeClasses} data-parenttype={parentType}>\n {badgeChild}\n </span>\n );\n })}\n </span>\n {chevronIcon && typeof closeButton === 'undefined' && (\n <span className={chevronClasses} data-parenttype={parentType}>\n <Icon svgIcon={chevronIcon} isHovered={isHovered} size={IconSize.XSmall} />\n </span>\n )}\n {closeButton && (\n <span className={chevronClasses} data-parenttype={parentType}>\n {closeButton}\n </span>\n )}\n </span>\n );\n};\n\ntype ElementHeaderComponent = typeof ElementHeaderRoot & {\n Text: React.FC<ElementHeaderTextProps>;\n StatusDotList: React.FC<StatusDotListProps>;\n};\nElementHeaderRoot.displayName = 'ElementHeader';\nconst ElementHeader = ElementHeaderRoot as ElementHeaderComponent;\nElementHeader.Text = ElementHeaderText;\nElementHeader.Text.displayName = 'ElementHeader.Text';\nElementHeader.StatusDotList = StatusDotList;\nElementHeader.StatusDotList.displayName = 'ElementHeader.StatusDotList';\n\nexport default ElementHeader;\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAaA,eAA+B,UAAU,aAAa,UAAU;CAC3E,IAAIC;CACJ,MAAMC,gBAAkD,EAAE;CAC1D,MAAMC,oBAA0D,EAAE;CAClE,IAAIC;CACJ,MAAMC,4BAA0E,EAAE;CAClF,MAAMC,iBAA2B,EAAE;CACnC,MAAMC,oBAAuC,EAAE;AAE/C,OAAM,SAAS,QAAQ,WAAU,UAAS;AACxC,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAa;AACpD,MAAI,YAAyB,OAAO,eAAO,CACzC,eAAc;WACL,YAAoC,OAAO,kBAAkB,CACtE,2BAA0B,KAAK,MAAM;WAC5B,YAAwB,OAAO,cAAM,CAC9C,eAAc,KAAK,MAAM;WAChB,YAAgC,OAAO,cAAc,CAC9D,oBAAmB;WACV,YAA4B,OAAO,kBAAU,CACtD,mBAAkB,KAAK,MAAM;WACpB,OAAO,UAAU,SAC1B,gBAAe,KAAK,MAAM;MAE1B,mBAAkB,KAAK,MAAM;GAE/B;CAIF,MAAM,qBACJ,gBAAgB,KAAA,KAChB,0BAA0B,SAAS,KACnC,kBAAkB,SAAS,KAC3B,qBAAqB,KAAA,KACpB,kBAAkB,KAAA,KAAa,eAAe,SAAS;CAC1D,MAAM,+BACJ,kBAAkB,WAAW,KAC5B,wBAAwB,kBAAkB,GAAG,IAAI,OAAO,kBAAkB,IAAI,OAAO,aAAa;AAErG,KAAI,cAAc,sBAAsB,6BACtC,QAAO;EACL;EAC2B;EAC3B;EACA;EACA;EACA;EACA;EACD;AAGH,KAAI,wBAAwB,kBAAkB,GAAG,CAC/C,QAAO,YAAY,kBAAkB,IAAI,OAAO,UAAU,KAAK;;AAInE,MAAa,uBACX,SAC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W;IAAgB,mBAAiB;cAC/C;KACI;;GAEJ;;AAQX,kBAAkB,cAAc;AAChC,IAAM,gBAAgB;AACtB,cAAc,OAAO;AACrB,cAAc,KAAK,cAAc;AACjC,cAAc,gBAAgB;AAC9B,cAAc,cAAc,cAAc;AAE1C,IAAA,wBAAe"}
1
+ {"version":3,"file":"ElementHeader.js","names":["mapChildren: ChildrenMapper","avatarChild: React.ReactElement<AvatarProps> | undefined","badgeChildren: React.ReactElement<BadgeProps>[]","statusDotChildren: React.ReactElement<StatusDotProps>[]","statusDotMCChild: React.ReactElement<StatusDotListProps> | undefined","elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[]","stringChildren: string[]","remainingChildren: React.ReactNode[]","ElementHeaderRoot: ElementHeaderType"],"sources":["../src/components/ElementHeader/utils.tsx","../src/components/ElementHeader/ElementHeader.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { AvatarProps } from '../Avatar';\nimport type { BadgeProps } from '../Badge';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport ElementHeader, { type ElementHeaderChildren, type ElementHeaderProps } from './ElementHeader';\nimport { ElementHeaderText, type ElementHeaderTextProps } from './ElementHeaderText';\nimport { StatusDotList, type StatusDotListProps } from './StatusDotList';\nimport { isComponent, isComponentWithChildren } from '../../utils/component';\nimport Avatar from '../Avatar';\nimport Badge from '../Badge';\nimport StatusDot from '../StatusDot';\n\ntype ChildrenMapper = (children: React.ReactNode, isJsxChild?: boolean) => ElementHeaderChildren | undefined;\n\nexport const mapChildren: ChildrenMapper = (children, isJsxChild = false) => {\n let avatarChild: React.ReactElement<AvatarProps> | undefined;\n const badgeChildren: React.ReactElement<BadgeProps>[] = [];\n const statusDotChildren: React.ReactElement<StatusDotProps>[] = [];\n let statusDotMCChild: React.ReactElement<StatusDotListProps> | undefined;\n const elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[] = [];\n const stringChildren: string[] = [];\n const remainingChildren: React.ReactNode[] = [];\n\n React.Children.forEach(children, child => {\n if (child === null || typeof child === 'undefined') return;\n if (isComponent<AvatarProps>(child, Avatar)) {\n avatarChild = child;\n } else if (isComponent<ElementHeaderTextProps>(child, ElementHeaderText)) {\n elementHeaderTextChildren.push(child);\n } else if (isComponent<BadgeProps>(child, Badge)) {\n badgeChildren.push(child);\n } else if (isComponent<StatusDotListProps>(child, StatusDotList)) {\n statusDotMCChild = child;\n } else if (isComponent<StatusDotProps>(child, StatusDot)) {\n statusDotChildren.push(child);\n } else if (typeof child === 'string') {\n stringChildren.push(child);\n } else {\n remainingChildren.push(child);\n }\n });\n\n // Dette og recursive mapChildren under(gjøres en gang) er for å passe på at jsx children også sjekkes for Avatar og liknende innhold.\n // Slik opprettholder vi stylingen i tilfeller hvor vertikaler har wrappet elementer i en parent span eller div.\n const hasSpecialChildren =\n avatarChild !== undefined ||\n elementHeaderTextChildren.length > 0 ||\n statusDotChildren.length > 0 ||\n statusDotMCChild !== undefined ||\n (badgeChildren !== undefined && stringChildren.length > 0);\n const noRemainingRecursiveChildren =\n remainingChildren.length === 0 ||\n (isComponentWithChildren(remainingChildren[0]) && typeof remainingChildren[0]?.props?.children === 'undefined');\n\n if (isJsxChild || hasSpecialChildren || noRemainingRecursiveChildren) {\n return {\n avatarChild,\n elementHeaderTextChildren: elementHeaderTextChildren,\n badgeChildren,\n statusDotChildren,\n statusDotMCChild,\n stringChildren,\n remainingChildren,\n };\n }\n\n if (isComponentWithChildren(remainingChildren[0])) {\n return mapChildren(remainingChildren[0]?.props?.children, true);\n }\n};\n\nexport const renderElementHeader = (\n element: React.ReactNode,\n options: Pick<\n ElementHeaderProps,\n 'titleHtmlMarkup' | 'isHovered' | 'size' | 'parentType' | 'chevronIcon' | 'icon' | 'highlightText' | 'closeButton'\n >\n): React.ReactElement | undefined => {\n const { titleHtmlMarkup, isHovered, size, parentType, chevronIcon, icon, highlightText, closeButton } = options;\n\n if (isComponent<ElementHeaderProps>(element, ElementHeader)) {\n return React.cloneElement(element, {\n chevronIcon,\n icon,\n isHovered,\n size,\n parentType,\n highlightText,\n closeButton,\n });\n }\n if (element) {\n return (\n <ElementHeader\n highlightText={highlightText}\n titleHtmlMarkup={titleHtmlMarkup}\n parentType={parentType}\n chevronIcon={chevronIcon}\n icon={icon}\n isHovered={isHovered}\n size={size}\n closeButton={closeButton}\n >\n {element}\n </ElementHeader>\n );\n }\n};\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { AvatarProps, AvatarType } from '../Avatar';\nimport type { BadgeProps, BadgeType } from '../Badge';\nimport type { IconProps, SvgIcon } from '../Icon';\nimport type { LazyIconProps } from '../LazyIcon';\nimport type { StatusDotProps, StatusDotType } from '../StatusDot';\nimport type { TitleTags } from '../Title';\nimport type { ElementHeaderTextProps, ElementHeaderTextType } from './ElementHeaderText/ElementHeaderText';\nimport type { StatusDotListProps, StatusDotListType } from './StatusDotList/StatusDotList';\n\nimport ElementHeaderText from './ElementHeaderText/ElementHeaderText';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { isComponent } from '../../utils/component';\nimport { AvatarSize } from '../Avatar';\nimport Icon, { IconSize } from '../Icon';\nimport StatusDotList from './StatusDotList';\nimport Highlighter from '../Highlighter';\nimport LazyIcon from '../LazyIcon';\nimport { mapChildren } from './utils';\n\nimport styles from './styles.module.scss';\n\nexport type ElementHeaderSize = 'compact' | 'small' | 'medium' | 'large';\nexport type ParentType = 'linklist' | 'expanderlist';\n\nexport interface ElementHeaderType extends React.FC<ElementHeaderProps> {\n Avatar?: AvatarType;\n Badge?: BadgeType;\n ElementHeaderText?: ElementHeaderTextType;\n StatusDot?: StatusDotType;\n StatusDotList?: StatusDotListType;\n}\n\nexport interface ElementHeaderProps {\n /** Adds custom classes to the ElementHeader element. */\n className?: string;\n /** Chevron to render inside of the ElementHeader */\n chevronIcon?: SvgIcon;\n /** Close button to be rendered inside of ElementHeader. This renders in place of chevronIcon */\n closeButton?: React.ReactElement;\n /** Children to be rendered inside of ElementHeader */\n children: React.ReactNode;\n /** Changes the underlying element of the title. Default: h2*/\n titleHtmlMarkup?: TitleTags;\n /** icon to be rendered inside of ElementHeader */\n icon?: React.ReactElement;\n /** whether or not the parent is hovered */\n isHovered?: boolean;\n /** Adjusts styling based on parent */\n parentType?: ParentType;\n /** Changes size of the ElementHeader. */\n size?: ElementHeaderSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Highlights text in title. Used for search results */\n highlightText?: string;\n}\n\nexport interface ElementHeaderChildren {\n avatarChild?: React.ReactElement<AvatarProps>;\n elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[];\n badgeChildren?: React.ReactElement<BadgeProps>[];\n statusDotChildren?: React.ReactElement<StatusDotProps>[];\n statusDotMCChild?: React.ReactElement<StatusDotListProps>;\n elementChild?: React.ReactElement;\n stringChildren: string[];\n remainingChildren: React.ReactNode[];\n}\n\nexport const ElementHeaderRoot: ElementHeaderType = props => {\n const {\n className = '',\n titleHtmlMarkup = 'h2',\n parentType = 'linklist',\n chevronIcon,\n closeButton,\n children,\n icon,\n isHovered,\n size,\n testId,\n highlightText,\n } = props;\n const breakpoint = useBreakpoint();\n const showIcon = size !== 'small' && !!icon;\n const contentIsString = typeof children === 'string';\n const mappedChildren = mapChildren(children);\n const hasStatusDots = !!mappedChildren?.statusDotChildren?.length || !!mappedChildren?.statusDotMCChild;\n\n const listLabelClasses = cn(styles['element-header'], { [styles['element-header--compact']]: size === 'compact' }, className);\n const badgeContainerClasses = cn(styles['element-header__badge-container']);\n const badgeClasses = cn(styles['element-header__badge']);\n const statusdotContainerClasses = cn(styles['element-header__statusdot-container']);\n const chevronClasses = cn(styles['element-header__chevron']);\n const contentClasses = cn(styles['element-header__content'], {\n [styles['element-header__content--element']]: !contentIsString,\n [styles['element-header__content--compact']]: size === 'compact',\n });\n const iconClasses = cn(styles['element-header__icon'], { [styles['element-header__icon--with-statusdot']]: hasStatusDots });\n const avatarClasses = cn(styles['element-header__avatar'], {});\n const CustomTag = titleHtmlMarkup;\n const iconPropIsIconComponent = isComponent<IconProps>(icon, Icon);\n const iconPropIsLazyIconComponent = !iconPropIsIconComponent && isComponent<LazyIconProps>(icon, LazyIcon);\n\n let iconComponent;\n if (iconPropIsIconComponent) {\n iconComponent = React.cloneElement(icon as React.ReactElement<IconProps>, {\n size: breakpoint < Breakpoint.md ? IconSize.XSmall : IconSize.Small,\n isHovered,\n });\n } else if (iconPropIsLazyIconComponent) {\n iconComponent = React.cloneElement(icon as React.ReactElement<LazyIconProps>, {\n size: breakpoint < Breakpoint.md ? IconSize.XSmall : IconSize.Small,\n isHovered,\n });\n } else {\n iconComponent = icon;\n }\n\n return (\n <span data-testid={testId} className={listLabelClasses}>\n {showIcon && icon && <span className={iconClasses}>{iconComponent}</span>}\n {size !== 'small' && mappedChildren?.avatarChild && (\n <span className={avatarClasses}>{React.cloneElement(mappedChildren.avatarChild, { size: AvatarSize.xsmall })}</span>\n )}\n\n <span className={contentClasses} data-hasstatusdots={hasStatusDots}>\n {mappedChildren?.elementHeaderTextChildren}\n {!!mappedChildren?.stringChildren.length && (\n <CustomTag className={styles['element-header__title']}>\n <Highlighter searchText={highlightText}>{mappedChildren.stringChildren}</Highlighter>\n </CustomTag>\n )}\n <Highlighter searchText={highlightText}>{mappedChildren?.remainingChildren}</Highlighter>\n </span>\n\n {hasStatusDots && (\n <span className={statusdotContainerClasses}>\n {!!mappedChildren?.statusDotChildren && <StatusDotList>{mappedChildren.statusDotChildren}</StatusDotList>}\n {!!mappedChildren?.statusDotMCChild && mappedChildren?.statusDotMCChild}\n </span>\n )}\n\n <span className={badgeContainerClasses}>\n {mappedChildren?.badgeChildren &&\n mappedChildren.badgeChildren.map((badgeChild, index) => {\n return (\n <span key={index} className={badgeClasses} data-parenttype={parentType}>\n {badgeChild}\n </span>\n );\n })}\n </span>\n {chevronIcon && typeof closeButton === 'undefined' && (\n <span className={chevronClasses} data-parenttype={parentType}>\n <Icon svgIcon={chevronIcon} isHovered={isHovered} size={IconSize.XSmall} />\n </span>\n )}\n {closeButton && (\n <span className={chevronClasses} data-parenttype={parentType}>\n {closeButton}\n </span>\n )}\n </span>\n );\n};\n\ntype ElementHeaderComponent = typeof ElementHeaderRoot & {\n Text: React.FC<ElementHeaderTextProps>;\n StatusDotList: React.FC<StatusDotListProps>;\n};\nElementHeaderRoot.displayName = 'ElementHeader';\nconst ElementHeader = ElementHeaderRoot as ElementHeaderComponent;\nElementHeader.Text = ElementHeaderText;\nElementHeader.Text.displayName = 'ElementHeader.Text';\nElementHeader.StatusDotList = StatusDotList;\nElementHeader.StatusDotList.displayName = 'ElementHeader.StatusDotList';\n\nexport default ElementHeader;\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAaA,eAA+B,UAAU,aAAa,UAAU;CAC3E,IAAIC;CACJ,MAAMC,gBAAkD,EAAE;CAC1D,MAAMC,oBAA0D,EAAE;CAClE,IAAIC;CACJ,MAAMC,4BAA0E,EAAE;CAClF,MAAMC,iBAA2B,EAAE;CACnC,MAAMC,oBAAuC,EAAE;AAE/C,OAAM,SAAS,QAAQ,WAAU,UAAS;AACxC,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAa;AACpD,MAAI,YAAyB,OAAO,eAAO,CACzC,eAAc;WACL,YAAoC,OAAO,kBAAkB,CACtE,2BAA0B,KAAK,MAAM;WAC5B,YAAwB,OAAO,cAAM,CAC9C,eAAc,KAAK,MAAM;WAChB,YAAgC,OAAO,cAAc,CAC9D,oBAAmB;WACV,YAA4B,OAAO,kBAAU,CACtD,mBAAkB,KAAK,MAAM;WACpB,OAAO,UAAU,SAC1B,gBAAe,KAAK,MAAM;MAE1B,mBAAkB,KAAK,MAAM;GAE/B;CAIF,MAAM,qBACJ,gBAAgB,KAAA,KAChB,0BAA0B,SAAS,KACnC,kBAAkB,SAAS,KAC3B,qBAAqB,KAAA,KACpB,kBAAkB,KAAA,KAAa,eAAe,SAAS;CAC1D,MAAM,+BACJ,kBAAkB,WAAW,KAC5B,wBAAwB,kBAAkB,GAAG,IAAI,OAAO,kBAA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,mBAAiB;gBACzD;QADQ,MAEJ;MAET;KACC;GACN,eAAe,OAAO,gBAAgB,eACrC,oBAAC,QAAA;IAAK,WAAW;IAAgB,mBAAiB;cAChD,oBAAC,cAAA;KAAK,SAAS;KAAwB;KAAW,MAAM,SAAS;MAAU;KACtE;GAER,eACC,oBAAC,QAAA;IAAK,WAAW;IAAgB,mBAAiB;cAC/C;KACI;;GAEJ;;AAQX,kBAAkB,cAAc;AAChC,IAAM,gBAAgB;AACtB,cAAc,OAAO;AACrB,cAAc,KAAK,cAAc;AACjC,cAAc,gBAAgB;AAC9B,cAAc,cAAc,cAAc;AAE1C,IAAA,wBAAe"}
@@ -1,12 +1,12 @@
1
1
  import { t as Highlighter_default } from "./Highlighter.js";
2
- import classNames from "classnames";
2
+ import cn from "classnames";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import styles from "./components/ElementHeader/styles.module.scss";
5
5
  const ElementHeaderText = (props) => {
6
6
  const { firstText, firstTextEmphasised = false, secondText = void 0, secondTextEmphasised = false, subText = false, className = "", testId, titleHtmlMarkup = "span", highlightText } = props;
7
- const headerTextWrapperClasses = classNames(className, styles["text-wrapper"], { [styles["text-wrapper--sub-level"]]: subText });
8
- const firstHeaderTextSegmentClasses = classNames({ [styles["text-wrapper__text--emphasised"]]: firstTextEmphasised });
9
- const secondHeaderTextSegmentClasses = classNames({ [styles["text-wrapper__text--emphasised"]]: secondTextEmphasised });
7
+ const headerTextWrapperClasses = cn(className, styles["text-wrapper"], { [styles["text-wrapper--sub-level"]]: subText });
8
+ const firstHeaderTextSegmentClasses = cn({ [styles["text-wrapper__text--emphasised"]]: firstTextEmphasised });
9
+ const secondHeaderTextSegmentClasses = cn({ [styles["text-wrapper__text--emphasised"]]: secondTextEmphasised });
10
10
  const CustomTag = titleHtmlMarkup;
11
11
  return /* @__PURE__ */ jsx("span", {
12
12
  "data-testid": testId,
@@ -1 +1 @@
1
- {"version":3,"file":"ElementHeaderText.js","names":["ElementHeaderText: React.FC<ElementHeaderTextProps>"],"sources":["../src/components/ElementHeader/ElementHeaderText/ElementHeaderText.tsx","../src/components/ElementHeader/ElementHeaderText/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport type { TitleTags } from '../../Title';\n\nimport Highlighter from '../../Highlighter';\nimport styles from '../styles.module.scss';\n\nexport type ElementHeaderTextType = typeof ElementHeaderText;\n\nexport interface ElementHeaderTextProps {\n /** The first text in the ElementHeaderText Component */\n firstText: string;\n /** Will style the first text as bold */\n firstTextEmphasised?: boolean;\n /** The second text in the ElementHeaderText Component */\n secondText?: string;\n /** Will style the second text as bold */\n secondTextEmphasised?: boolean;\n /** Whether or not this ElementHeaderText is a sub text */\n subText?: boolean;\n /** Adds custom classes to the ElementHeaderText component. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Changes the underlying element of the text. Default: span*/\n titleHtmlMarkup?: TitleTags;\n /** Highlights text. Used for search results */\n highlightText?: string;\n}\n\nexport const ElementHeaderText: React.FC<ElementHeaderTextProps> = props => {\n const {\n firstText,\n firstTextEmphasised = false,\n secondText = undefined,\n secondTextEmphasised = false,\n subText = false,\n className = '',\n testId,\n titleHtmlMarkup = 'span',\n highlightText,\n } = props;\n\n const headerTextWrapperClasses = cn(className, styles['text-wrapper'], {\n [styles['text-wrapper--sub-level']]: subText,\n });\n const firstHeaderTextSegmentClasses = cn({\n [styles['text-wrapper__text--emphasised']]: firstTextEmphasised,\n });\n const secondHeaderTextSegmentClasses = cn({\n [styles['text-wrapper__text--emphasised']]: secondTextEmphasised,\n });\n const CustomTag = titleHtmlMarkup;\n\n return (\n <span data-testid={testId} className={headerTextWrapperClasses}>\n <CustomTag className={styles['element-header__title']}>\n <Highlighter searchText={highlightText}>\n <span className={firstHeaderTextSegmentClasses}>{firstText}</span>\n {secondText && <span className={secondHeaderTextSegmentClasses}>{secondText}</span>}\n </Highlighter>\n </CustomTag>\n </span>\n );\n};\n\nexport default ElementHeaderText;\n","import ElementHeaderText from './ElementHeaderText';\nexport * from './ElementHeaderText';\nexport default ElementHeaderText;\n"],"mappings":";;;;AA8BA,MAAaA,qBAAsD,UAAS;CAC1E,MAAM,EACJ,WACA,sBAAsB,OACtB,aAAa,KAAA,GACb,uBAAuB,OACvB,UAAU,OACV,YAAY,IACZ,QACA,kBAAkB,QAClB,kBACE;CAEJ,MAAM,2BAA2B,WAAG,WAAW,OAAO,iBAAiB,GACpE,OAAO,6BAA6B,SACtC,CAAC;CACF,MAAM,gCAAgC,WAAG,GACtC,OAAO,oCAAoC,qBAC7C,CAAC;CACF,MAAM,iCAAiC,WAAG,GACvC,OAAO,oCAAoC,sBAC7C,CAAC;CACF,MAAM,YAAY;AAElB,QACE,oBAAC,QAAA;EAAK,eAAa;EAAQ,WAAW;YACpC,oBAAC,WAAA;GAAU,WAAW,OAAO;aAC3B,qBAAC,qBAAA;IAAY,YAAY;eACvB,oBAAC,QAAA;KAAK,WAAW;eAAgC;MAAiB,EACjE,cAAc,oBAAC,QAAA;KAAK,WAAW;eAAiC;MAAkB,CAAA;KACvE;IACJ;GACP;;AAIX,IAAA,4BAAe;AChEf,IAAA,8BAAe"}
1
+ {"version":3,"file":"ElementHeaderText.js","names":["ElementHeaderText: React.FC<ElementHeaderTextProps>"],"sources":["../src/components/ElementHeader/ElementHeaderText/ElementHeaderText.tsx","../src/components/ElementHeader/ElementHeaderText/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport type { TitleTags } from '../../Title';\n\nimport Highlighter from '../../Highlighter';\nimport styles from '../styles.module.scss';\n\nexport type ElementHeaderTextType = typeof ElementHeaderText;\n\nexport interface ElementHeaderTextProps {\n /** The first text in the ElementHeaderText Component */\n firstText: string;\n /** Will style the first text as bold */\n firstTextEmphasised?: boolean;\n /** The second text in the ElementHeaderText Component */\n secondText?: string;\n /** Will style the second text as bold */\n secondTextEmphasised?: boolean;\n /** Whether or not this ElementHeaderText is a sub text */\n subText?: boolean;\n /** Adds custom classes to the ElementHeaderText component. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Changes the underlying element of the text. Default: span*/\n titleHtmlMarkup?: TitleTags;\n /** Highlights text. Used for search results */\n highlightText?: string;\n}\n\nexport const ElementHeaderText: React.FC<ElementHeaderTextProps> = props => {\n const {\n firstText,\n firstTextEmphasised = false,\n secondText = undefined,\n secondTextEmphasised = false,\n subText = false,\n className = '',\n testId,\n titleHtmlMarkup = 'span',\n highlightText,\n } = props;\n\n const headerTextWrapperClasses = cn(className, styles['text-wrapper'], {\n [styles['text-wrapper--sub-level']]: subText,\n });\n const firstHeaderTextSegmentClasses = cn({\n [styles['text-wrapper__text--emphasised']]: firstTextEmphasised,\n });\n const secondHeaderTextSegmentClasses = cn({\n [styles['text-wrapper__text--emphasised']]: secondTextEmphasised,\n });\n const CustomTag = titleHtmlMarkup;\n\n return (\n <span data-testid={testId} className={headerTextWrapperClasses}>\n <CustomTag className={styles['element-header__title']}>\n <Highlighter searchText={highlightText}>\n <span className={firstHeaderTextSegmentClasses}>{firstText}</span>\n {secondText && <span className={secondHeaderTextSegmentClasses}>{secondText}</span>}\n </Highlighter>\n </CustomTag>\n </span>\n );\n};\n\nexport default ElementHeaderText;\n","import ElementHeaderText from './ElementHeaderText';\nexport * from './ElementHeaderText';\nexport default ElementHeaderText;\n"],"mappings":";;;;AA8BA,MAAaA,qBAAsD,UAAS;CAC1E,MAAM,EACJ,WACA,sBAAsB,OACtB,aAAa,KAAA,GACb,uBAAuB,OACvB,UAAU,OACV,YAAY,IACZ,QACA,kBAAkB,QAClB,kBACE;CAEJ,MAAM,2BAA2B,GAAG,WAAW,OAAO,iBAAiB,GACpE,OAAO,6BAA6B,SACtC,CAAC;CACF,MAAM,gCAAgC,GAAG,GACtC,OAAO,oCAAoC,qBAC7C,CAAC;CACF,MAAM,iCAAiC,GAAG,GACvC,OAAO,oCAAoC,sBAC7C,CAAC;CACF,MAAM,YAAY;AAElB,QACE,oBAAC,QAAA;EAAK,eAAa;EAAQ,WAAW;YACpC,oBAAC,WAAA;GAAU,WAAW,OAAO;aAC3B,qBAAC,qBAAA;IAAY,YAAY;eACvB,oBAAC,QAAA;KAAK,WAAW;eAAgC;MAAiB,EACjE,cAAc,oBAAC,QAAA;KAAK,WAAW;eAAiC;MAAkB,CAAA;KACvE;IACJ;GACP;;AAIX,IAAA,4BAAe;AChEf,IAAA,8BAAe"}
@@ -1,10 +1,10 @@
1
- import classNames from "classnames";
1
+ import cn from "classnames";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import styles from "./components/ErrorWrapper/styles.module.scss";
4
4
  const ErrorWrapper = (props) => {
5
5
  const { renderError = true } = props;
6
6
  return /* @__PURE__ */ jsxs("div", {
7
- className: classNames(props.errorText && renderError && styles[`error-wrapper--with-error`], props.className),
7
+ className: cn(props.errorText && renderError && styles[`error-wrapper--with-error`], props.className),
8
8
  "data-testid": props.testId,
9
9
  children: [/* @__PURE__ */ jsx("span", {
10
10
  ref: props.errorMessageRef,
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorWrapper.js","names":["ErrorWrapper: React.FC<ErrorWrapperProps>"],"sources":["../src/components/ErrorWrapper/ErrorWrapper.tsx","../src/components/ErrorWrapper/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport styles from './styles.module.scss';\n\nexport interface ErrorWrapperClassNameProps {\n errorWrapperClassName?: string;\n}\n\nexport interface ErrorWrapperProps {\n /** Form component */\n children?: React.ReactNode;\n /** Error message */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds a ref to the error message p tag */\n errorMessageRef?: React.Ref<HTMLDivElement>;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const ErrorWrapper: React.FC<ErrorWrapperProps> = props => {\n const { renderError = true } = props;\n\n const errorWrapperClasses = cn(props.errorText && renderError && styles[`error-wrapper--with-error`], props.className);\n\n return (\n <div className={errorWrapperClasses} data-testid={props.testId}>\n <span ref={props.errorMessageRef} tabIndex={-1}>\n {props.errorText && (\n <p className={styles['error-wrapper__errors']} id={props.errorTextId}>\n {props.errorText}\n </p>\n )}\n </span>\n {props.children}\n </div>\n );\n};\n\nexport default ErrorWrapper;\n","import ErrorWrapper from './ErrorWrapper';\nexport * from './ErrorWrapper';\nexport default ErrorWrapper;\n"],"mappings":";;;AAyBA,MAAaA,gBAA4C,UAAS;CAChE,MAAM,EAAE,cAAc,SAAS;AAI/B,QACE,qBAAC,OAAA;EAAI,WAHqB,WAAG,MAAM,aAAa,eAAe,OAAO,8BAA8B,MAAM,UAAU;EAG/E,eAAa,MAAM;aACtD,oBAAC,QAAA;GAAK,KAAK,MAAM;GAAiB,UAAU;aACzC,MAAM,aACL,oBAAC,KAAA;IAAE,WAAW,OAAO;IAA0B,IAAI,MAAM;cACtD,MAAM;KACL;IAED,EACN,MAAM,SAAA;GACH;;ACtCV,IAAA,yBD0Ce"}
1
+ {"version":3,"file":"ErrorWrapper.js","names":["ErrorWrapper: React.FC<ErrorWrapperProps>"],"sources":["../src/components/ErrorWrapper/ErrorWrapper.tsx","../src/components/ErrorWrapper/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport styles from './styles.module.scss';\n\nexport interface ErrorWrapperClassNameProps {\n errorWrapperClassName?: string;\n}\n\nexport interface ErrorWrapperProps {\n /** Form component */\n children?: React.ReactNode;\n /** Error message */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds a ref to the error message p tag */\n errorMessageRef?: React.Ref<HTMLDivElement>;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const ErrorWrapper: React.FC<ErrorWrapperProps> = props => {\n const { renderError = true } = props;\n\n const errorWrapperClasses = cn(props.errorText && renderError && styles[`error-wrapper--with-error`], props.className);\n\n return (\n <div className={errorWrapperClasses} data-testid={props.testId}>\n <span ref={props.errorMessageRef} tabIndex={-1}>\n {props.errorText && (\n <p className={styles['error-wrapper__errors']} id={props.errorTextId}>\n {props.errorText}\n </p>\n )}\n </span>\n {props.children}\n </div>\n );\n};\n\nexport default ErrorWrapper;\n","import ErrorWrapper from './ErrorWrapper';\nexport * from './ErrorWrapper';\nexport default ErrorWrapper;\n"],"mappings":";;;AAyBA,MAAaA,gBAA4C,UAAS;CAChE,MAAM,EAAE,cAAc,SAAS;AAI/B,QACE,qBAAC,OAAA;EAAI,WAHqB,GAAG,MAAM,aAAa,eAAe,OAAO,8BAA8B,MAAM,UAAU;EAG/E,eAAa,MAAM;aACtD,oBAAC,QAAA;GAAK,KAAK,MAAM;GAAiB,UAAU;aACzC,MAAM,aACL,oBAAC,KAAA;IAAE,WAAW,OAAO;IAA0B,IAAI,MAAM;cACtD,MAAM;KACL;IAED,EACN,MAAM,SAAA;GACH;;ACtCV,IAAA,yBD0Ce"}