@helsenorge/designsystem-react 12.5.0 → 12.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/AsChildSlot.js +74 -0
  2. package/AsChildSlot.js.map +1 -0
  3. package/CHANGELOG.md +72 -0
  4. package/Drawer.js +58 -4
  5. package/Drawer.js.map +1 -1
  6. package/FormFieldTag.js +48 -0
  7. package/FormFieldTag.js.map +1 -0
  8. package/FormGroup.js +11 -3
  9. package/FormGroup.js.map +1 -1
  10. package/HN.Designsystem.Dropdown.nb-NO.js +13 -0
  11. package/HN.Designsystem.Dropdown.nb-NO.js.map +1 -0
  12. package/HelpDetails.js +1 -1
  13. package/Label.js +3 -0
  14. package/Label.js.map +1 -1
  15. package/LinkList.js +1 -0
  16. package/LinkList.js.map +1 -1
  17. package/SingleSelectItem.js +96 -0
  18. package/SingleSelectItem.js.map +1 -0
  19. package/clamp.js +11 -0
  20. package/clamp.js.map +1 -0
  21. package/components/ArticleTeaser/styles.module.scss +3 -5
  22. package/components/AsChildSlot/AsChildSlot.d.ts +23 -0
  23. package/components/AsChildSlot/AsChildSlot.test.d.ts +1 -0
  24. package/components/AsChildSlot/index.d.ts +3 -0
  25. package/components/AsChildSlot/index.js +6 -0
  26. package/components/AsChildSlot/index.js.map +1 -0
  27. package/components/AsChildSlot/styles.module.scss +13 -0
  28. package/components/AsChildSlot/styles.module.scss.d.ts +9 -0
  29. package/components/Drawer/styles.module.scss +45 -26
  30. package/components/Drawer/styles.module.scss.d.ts +5 -0
  31. package/components/Dropdown/Dropdown.d.ts +19 -21
  32. package/components/Dropdown/Dropdown.test.d.ts +1 -0
  33. package/components/Dropdown/SingleSelect/SingleSelect.d.ts +18 -0
  34. package/components/Dropdown/SingleSelect/SingleSelect.test.d.ts +1 -0
  35. package/components/Dropdown/SingleSelect/SingleSelectItem.d.ts +21 -0
  36. package/components/Dropdown/SingleSelect/index.d.ts +3 -0
  37. package/components/Dropdown/SingleSelect/index.js +6 -0
  38. package/components/Dropdown/SingleSelect/index.js.map +1 -0
  39. package/components/Dropdown/SingleSelect/styles.module.scss +54 -0
  40. package/components/Dropdown/SingleSelect/styles.module.scss.d.ts +14 -0
  41. package/components/Dropdown/index.js +140 -76
  42. package/components/Dropdown/index.js.map +1 -1
  43. package/components/Dropdown/styles.module.scss +90 -136
  44. package/components/Dropdown/styles.module.scss.d.ts +8 -9
  45. package/components/DropdownOld/DropdownOld.d.ts +42 -0
  46. package/components/DropdownOld/index.d.ts +3 -0
  47. package/components/DropdownOld/index.js +194 -0
  48. package/components/DropdownOld/index.js.map +1 -0
  49. package/components/DropdownOld/resourceHelper.d.ts +3 -0
  50. package/components/DropdownOld/styles.module.scss +230 -0
  51. package/components/DropdownOld/styles.module.scss.d.ts +25 -0
  52. package/components/FormFieldTag/FormFieldTag.d.ts +15 -0
  53. package/components/FormFieldTag/FormFieldTag.test.d.ts +1 -0
  54. package/components/FormFieldTag/index.d.ts +3 -0
  55. package/components/FormFieldTag/index.js +5 -0
  56. package/components/FormFieldTag/index.js.map +1 -0
  57. package/components/FormFieldTag/resourceHelper.d.ts +3 -0
  58. package/components/FormFieldTag/styles.module.scss +23 -0
  59. package/components/FormFieldTag/styles.module.scss.d.ts +10 -0
  60. package/components/FormGroup/FormGroup.d.ts +2 -0
  61. package/components/FormGroup/styles.module.scss +3 -0
  62. package/components/Icons/EmoticonAnnoyed.js +8 -11
  63. package/components/Icons/EmoticonAnnoyed.js.map +1 -1
  64. package/components/Icons/EmoticonDelighted.js +8 -4
  65. package/components/Icons/EmoticonDelighted.js.map +1 -1
  66. package/components/Icons/EmoticonDisappointed.js +8 -4
  67. package/components/Icons/EmoticonDisappointed.js.map +1 -1
  68. package/components/Icons/EmoticonHappy.js +8 -4
  69. package/components/Icons/EmoticonHappy.js.map +1 -1
  70. package/components/Icons/EmoticonMeh.js +8 -4
  71. package/components/Icons/EmoticonMeh.js.map +1 -1
  72. package/components/Label/Label.d.ts +2 -0
  73. package/components/LinkList/styles.module.scss +47 -61
  74. package/components/LinkList/styles.module.scss.d.ts +1 -0
  75. package/components/ListEditMode/styles.module.scss +1 -0
  76. package/components/NotificationPanel/index.js +3 -1
  77. package/components/NotificationPanel/index.js.map +1 -1
  78. package/components/NotificationPanel/styles.module.scss +10 -5
  79. package/components/StickyNote/Close.d.ts +11 -0
  80. package/components/StickyNote/Triangle.d.ts +5 -1
  81. package/components/StickyNote/index.js +100 -49
  82. package/components/StickyNote/index.js.map +1 -1
  83. package/components/StickyNote/styles.module.scss +106 -34
  84. package/components/StickyNote/styles.module.scss.d.ts +6 -1
  85. package/constants.d.ts +1 -0
  86. package/constants.js +1 -0
  87. package/constants.js.map +1 -1
  88. package/designsystem-react.css +146 -98
  89. package/package.json +1 -1
  90. package/resources/HN.Designsystem.FormFieldTag.nb-NO.json.d.ts +8 -0
  91. package/scss/supernova/styles/colors.css +146 -98
  92. package/scss/supernova/styles/typography.css +2 -2
  93. package/use-animate.js +1 -7
  94. package/use-animate.js.map +1 -1
  95. /package/{resources/index.d.ts → components/DropdownOld/DropdownOld.test.d.ts} +0 -0
package/AsChildSlot.js ADDED
@@ -0,0 +1,74 @@
1
+ import React__default from "react";
2
+ import { mergeRefs } from "./utils/refs.js";
3
+ import styles from "./components/AsChildSlot/styles.module.scss";
4
+ const isAriaDisabled = (v) => v === true || v === "true";
5
+ const AsChildSlot = React__default.forwardRef(
6
+ ({ children, className, content, disabled, onSelect, ariaCurrent, elementRef }, forwardedRef) => {
7
+ const childElement = React__default.Children.toArray(children).filter(React__default.isValidElement)[0];
8
+ const nodeRef = React__default.useRef(null);
9
+ const childRef = childElement == null ? void 0 : childElement.ref;
10
+ const mergedRef = mergeRefs([
11
+ (node) => {
12
+ nodeRef.current = node;
13
+ },
14
+ childRef,
15
+ elementRef
16
+ ]);
17
+ const childProps = (childElement == null ? void 0 : childElement.props) || {};
18
+ const childDisabled = !!childProps.disabled || isAriaDisabled(childProps["aria-disabled"]);
19
+ const isDisabled = !!disabled || childDisabled;
20
+ React__default.useImperativeHandle(
21
+ forwardedRef,
22
+ () => ({
23
+ click: () => {
24
+ var _a;
25
+ if (isDisabled) return;
26
+ (_a = nodeRef.current) == null ? void 0 : _a.click();
27
+ }
28
+ }),
29
+ [isDisabled]
30
+ );
31
+ if (!childElement) return null;
32
+ const childOnClick = childProps.onClick;
33
+ const wrappedOnClick = (e) => {
34
+ if (isDisabled) {
35
+ e.preventDefault();
36
+ e.stopPropagation();
37
+ return;
38
+ }
39
+ onSelect == null ? void 0 : onSelect(e);
40
+ childOnClick == null ? void 0 : childOnClick(e);
41
+ };
42
+ const childOnKeyDown = childProps.onKeyDown;
43
+ const wrappedOnKeyDown = (e) => {
44
+ var _a;
45
+ childOnKeyDown == null ? void 0 : childOnKeyDown(e);
46
+ if (e.defaultPrevented) return;
47
+ if (e.key === " " || e.key === "Spacebar" || e.code === "Space") {
48
+ if (isDisabled) {
49
+ e.preventDefault();
50
+ return;
51
+ }
52
+ e.preventDefault();
53
+ (_a = nodeRef.current) == null ? void 0 : _a.click();
54
+ }
55
+ };
56
+ const isButtonLike = typeof childProps.href === "undefined";
57
+ return React__default.cloneElement(childElement, {
58
+ ref: mergedRef,
59
+ className: `${styles["as-child-reset"]} ${className ?? ""}`,
60
+ style: void 0,
61
+ "aria-disabled": isDisabled || void 0,
62
+ "aria-current": ariaCurrent,
63
+ ...isButtonLike && !("type" in childProps) ? { type: "button" } : null,
64
+ onClick: wrappedOnClick,
65
+ onKeyDown: wrappedOnKeyDown,
66
+ children: content
67
+ });
68
+ }
69
+ );
70
+ AsChildSlot.displayName = "AsChildSlot";
71
+ export {
72
+ AsChildSlot as A
73
+ };
74
+ //# sourceMappingURL=AsChildSlot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsChildSlot.js","sources":["../src/components/AsChildSlot/AsChildSlot.tsx"],"sourcesContent":["import React from 'react';\n\nimport { mergeRefs } from '../../utils/refs';\n\nimport styles from './styles.module.scss';\n\nexport interface AsChildSlotHandle {\n /** Click the child’s DOM node */\n click: () => void;\n}\n\nexport interface AsChildSlotProps {\n /** Pass one element/component that we will map to a DOM element (<a>, <button>, React Router <Link>) */\n children?: React.ReactNode;\n /** Class names to apply to the visible element */\n className?: string;\n /** Content to render inside the visible element - For example the text and icons of the parent component that renders AsChildSlot */\n content?: React.ReactNode;\n /** Disabled state passed down (merged with child’s disabled/aria-disabled) */\n disabled?: boolean;\n /** Called before the child’s onClick when visible */\n onSelect?: (e: React.SyntheticEvent) => void;\n /** Optional states to apply to the DOM element */\n ariaCurrent?: 'page' | 'true';\n /** DOM ref for the element we end up rendering */\n elementRef?: React.Ref<HTMLElement>;\n}\n\nconst isAriaDisabled = (v: unknown): boolean => v === true || v === 'true';\n\nexport const AsChildSlot = React.forwardRef<AsChildSlotHandle, AsChildSlotProps>(\n ({ children, className, content, disabled, onSelect, ariaCurrent, elementRef }, forwardedRef) => {\n const childElement = React.Children.toArray(children).filter(React.isValidElement)[0] as React.ReactElement | undefined;\n const nodeRef = React.useRef<HTMLElement | null>(null);\n const childRef = (childElement as unknown as { ref?: React.Ref<HTMLElement> | undefined })?.ref;\n const mergedRef = mergeRefs<HTMLElement>([\n (node): void => {\n nodeRef.current = node;\n },\n childRef,\n elementRef,\n ]);\n\n const childProps =\n (childElement?.props as Partial<React.DOMAttributes<HTMLElement>> &\n Partial<React.AnchorHTMLAttributes<HTMLElement>> &\n Partial<React.ButtonHTMLAttributes<HTMLElement>> & { disabled?: boolean; href?: unknown }) || {};\n const childDisabled = !!childProps.disabled || isAriaDisabled((childProps as React.AriaAttributes)['aria-disabled']);\n const isDisabled = !!disabled || childDisabled;\n\n // Exposes a callable click() to the parents.\n React.useImperativeHandle(\n forwardedRef,\n () => ({\n click: (): void => {\n if (isDisabled) return;\n nodeRef.current?.click();\n },\n }),\n [isDisabled]\n );\n\n if (!childElement) return null;\n\n // Actual user mouse interaction\n const childOnClick = childProps.onClick as React.MouseEventHandler<HTMLElement> | undefined;\n const wrappedOnClick: React.MouseEventHandler<HTMLElement> = e => {\n if (isDisabled) {\n e.preventDefault();\n e.stopPropagation();\n return;\n }\n onSelect?.(e);\n childOnClick?.(e);\n };\n\n // Actual user keyboard interaction\n const childOnKeyDown = childProps.onKeyDown as React.KeyboardEventHandler<HTMLElement> | undefined;\n const wrappedOnKeyDown: React.KeyboardEventHandler<HTMLElement> = e => {\n childOnKeyDown?.(e);\n if (e.defaultPrevented) return;\n if (e.key === ' ' || e.key === 'Spacebar' || e.code === 'Space') {\n if (isDisabled) {\n e.preventDefault();\n return;\n }\n e.preventDefault();\n nodeRef.current?.click();\n }\n };\n\n const isButtonLike = typeof childProps.href === 'undefined';\n\n return React.cloneElement(childElement, {\n ref: mergedRef,\n className: `${styles['as-child-reset']} ${className ?? ''}`,\n style: undefined,\n 'aria-disabled': isDisabled || undefined,\n 'aria-current': ariaCurrent,\n ...(isButtonLike && !('type' in childProps) ? { type: 'button' } : null),\n onClick: wrappedOnClick,\n onKeyDown: wrappedOnKeyDown,\n children: content,\n });\n }\n);\n\nAsChildSlot.displayName = 'AsChildSlot';\n\nexport default AsChildSlot;\n"],"names":["React"],"mappings":";;;AA4BA,MAAM,iBAAiB,CAAC,MAAwB,MAAM,QAAQ,MAAM;AAE7D,MAAM,cAAcA,eAAM;AAAA,EAC/B,CAAC,EAAE,UAAU,WAAW,SAAS,UAAU,UAAU,aAAa,WAAA,GAAc,iBAAiB;AAC/F,UAAM,eAAeA,eAAM,SAAS,QAAQ,QAAQ,EAAE,OAAOA,eAAM,cAAc,EAAE,CAAC;AACpF,UAAM,UAAUA,eAAM,OAA2B,IAAI;AACrD,UAAM,WAAY,6CAA0E;AAC5F,UAAM,YAAY,UAAuB;AAAA,MACvC,CAAC,SAAe;AACd,gBAAQ,UAAU;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAED,UAAM,cACH,6CAAc,UAEiF,CAAA;AAClG,UAAM,gBAAgB,CAAC,CAAC,WAAW,YAAY,eAAgB,WAAoC,eAAe,CAAC;AACnH,UAAM,aAAa,CAAC,CAAC,YAAY;AAGjCA,mBAAM;AAAA,MACJ;AAAA,MACA,OAAO;AAAA,QACL,OAAO,MAAY;;AACjB,cAAI,WAAY;AAChB,wBAAQ,YAAR,mBAAiB;AAAA,QACnB;AAAA,MAAA;AAAA,MAEF,CAAC,UAAU;AAAA,IAAA;AAGb,QAAI,CAAC,aAAc,QAAO;AAG1B,UAAM,eAAe,WAAW;AAChC,UAAM,iBAAuD,CAAA,MAAK;AAChE,UAAI,YAAY;AACd,UAAE,eAAA;AACF,UAAE,gBAAA;AACF;AAAA,MACF;AACA,2CAAW;AACX,mDAAe;AAAA,IACjB;AAGA,UAAM,iBAAiB,WAAW;AAClC,UAAM,mBAA4D,CAAA,MAAK;;AACrE,uDAAiB;AACjB,UAAI,EAAE,iBAAkB;AACxB,UAAI,EAAE,QAAQ,OAAO,EAAE,QAAQ,cAAc,EAAE,SAAS,SAAS;AAC/D,YAAI,YAAY;AACd,YAAE,eAAA;AACF;AAAA,QACF;AACA,UAAE,eAAA;AACF,sBAAQ,YAAR,mBAAiB;AAAA,MACnB;AAAA,IACF;AAEA,UAAM,eAAe,OAAO,WAAW,SAAS;AAEhD,WAAOA,eAAM,aAAa,cAAc;AAAA,MACtC,KAAK;AAAA,MACL,WAAW,GAAG,OAAO,gBAAgB,CAAC,IAAI,aAAa,EAAE;AAAA,MACzD,OAAO;AAAA,MACP,iBAAiB,cAAc;AAAA,MAC/B,gBAAgB;AAAA,MAChB,GAAI,gBAAgB,EAAE,UAAU,cAAc,EAAE,MAAM,aAAa;AAAA,MACnE,SAAS;AAAA,MACT,WAAW;AAAA,MACX,UAAU;AAAA,IAAA,CACX;AAAA,EACH;AACF;AAEA,YAAY,cAAc;"}
package/CHANGELOG.md CHANGED
@@ -1,3 +1,75 @@
1
+ ## [12.8.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.7.0&targetVersion=GTv12.8.0) (2025-10-28)
2
+
3
+ ### Features
4
+
5
+ - nye tokens fra supernova ([aa6ba72](https://github.com/helsenorge/designsystem/commit/aa6ba72e73349197ef27248491a54a827711a04d)), closes
6
+ [#362358](https://github.com/helsenorge/designsystem/issues/362358)
7
+ - **articleteaser:** ta i bruk nye tokens
8
+ ([e1bd030](https://github.com/helsenorge/designsystem/commit/e1bd030ccf429e1320438d9b514dcea589a32b84)), closes
9
+ [#352016](https://github.com/helsenorge/designsystem/issues/352016)
10
+ - **dropdown:** nytt dropdown komponent med aschildslot komponent og renamet gamle til dropdownold
11
+ ([80e6e88](https://github.com/helsenorge/designsystem/commit/80e6e886cefcfa07e4419d3b6081aa1f58a14ad3)), closes
12
+ [#358846](https://github.com/helsenorge/designsystem/issues/358846)
13
+ - **linklist:** ta i bruk nye tokens for farger
14
+ ([658e44f](https://github.com/helsenorge/designsystem/commit/658e44f0e0a9d1dcd2e703a5b7a5ba0674a8654d)), closes
15
+ [#362129](https://github.com/helsenorge/designsystem/issues/362129)
16
+
17
+ ### Bug Fixes
18
+
19
+ - **drawer:** fjern overflow hidden på ytterste nivå
20
+ ([66bfa99](https://github.com/helsenorge/designsystem/commit/66bfa996a9a3efa53f8c44aa54d13d72243fd24f)), closes
21
+ [#361695](https://github.com/helsenorge/designsystem/issues/361695)
22
+ - **drawer:** legg skygge oppå content og match logikken med Modal
23
+ ([793232d](https://github.com/helsenorge/designsystem/commit/793232de0d2ad7785022ba9a866e623716769b33)), closes
24
+ [#361521](https://github.com/helsenorge/designsystem/issues/361521)
25
+ - **icons:** fiks svg på to ikoner ([44da111](https://github.com/helsenorge/designsystem/commit/44da111275eac5240fefab46bc2f92e5bae680b9)),
26
+ closes [#362501](https://github.com/helsenorge/designsystem/issues/362501)
27
+ - **icons:** oppdatert versjon av emoticon ikoner
28
+ ([b845c21](https://github.com/helsenorge/designsystem/commit/b845c2121d799e5b0558e9f0087c013cb51a938c)), closes
29
+ [#362501](https://github.com/helsenorge/designsystem/issues/362501)
30
+ - **listeditmode:** legg til manglende pointer på knapper
31
+ ([e7fbc2f](https://github.com/helsenorge/designsystem/commit/e7fbc2fbd686e2b53836db42b6e6bed792f8af2f)), closes
32
+ [#354199](https://github.com/helsenorge/designsystem/issues/354199)
33
+ - **notificationpanel:** bruk riktig størrelse på ikon og padding rundt på mobil
34
+ ([23c984b](https://github.com/helsenorge/designsystem/commit/23c984be87836adc108abf4d3633db9fbf18583d)), closes
35
+ [#361176](https://github.com/helsenorge/designsystem/issues/361176)
36
+
37
+ ## [12.7.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.6.4&targetVersion=GTv12.7.0) (2025-10-17)
38
+
39
+ ### Features
40
+
41
+ - **formgroup:** endre prop for FormFieldTag til å være lik som i label
42
+ ([850b4e0](https://github.com/helsenorge/designsystem/commit/850b4e0cdc5888dbe29ba894c23e460dfe9d4930)), closes
43
+ [#362503](https://github.com/helsenorge/designsystem/issues/362503)
44
+
45
+ ## [12.6.4](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.6.1&targetVersion=GTv12.6.4) (2025-10-16)
46
+
47
+ ### Reverts
48
+
49
+ - Revert "v12.6.3" ([973e6b8](https://github.com/helsenorge/designsystem/commit/973e6b8893fc765892a993adf83d93f4d5bfd5dd))
50
+
51
+ ## [12.6.1](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.6.0&targetVersion=GTv12.6.1) (2025-10-16)
52
+
53
+ ## [12.6.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.5.0&targetVersion=GTv12.6.0) (2025-10-16)
54
+
55
+ ### Features
56
+
57
+ - **formfieldtag:** ny komponent for å markere obligatoriske felter
58
+ ([43186e8](https://github.com/helsenorge/designsystem/commit/43186e85e06d6b3e34124c3afd372180ecff9af9)), closes
59
+ [#361861](https://github.com/helsenorge/designsystem/issues/361861)
60
+ - **stickynote:** justeringer etter ny figma komponent
61
+ ([b3afb5a](https://github.com/helsenorge/designsystem/commit/b3afb5a41f1400bef0afce40b244deafcac7b505)), closes
62
+ [#361520](https://github.com/helsenorge/designsystem/issues/361520)
63
+
64
+ ### Bug Fixes
65
+
66
+ - **formfieldtag:** fiks display for at den holder seg i riktig størrelse
67
+ ([1e53dc1](https://github.com/helsenorge/designsystem/commit/1e53dc1cf52215a3476a1d6d86c36f8108b0fbc1)), closes
68
+ [#361861](https://github.com/helsenorge/designsystem/issues/361861)
69
+ - **label:** bruk formfieldtag som komponent slik at man får satt id
70
+ ([006e152](https://github.com/helsenorge/designsystem/commit/006e1520cc16b66f637c11c193902510ebd72b76)), closes
71
+ [#361861](https://github.com/helsenorge/designsystem/issues/361861)
72
+
1
73
  ## [12.5.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.4.0&targetVersion=GTv12.5.0) (2025-10-08)
2
74
 
3
75
  ### Features
package/Drawer.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import { createContext, useId, useRef, useContext, useInsertionEffect, useCallback, useMemo, useEffect, Children, isValidElement, useLayoutEffect, useState } from "react";
3
+ import React__default, { createContext, useId, useRef, useContext, useInsertionEffect, useCallback, useMemo, useEffect, Children, isValidElement, useLayoutEffect, useState } from "react";
4
4
  import classNames from "classnames";
5
5
  import { LanguageLocales, ZIndex, KeyboardEventKey, AnalyticsId } from "./constants.js";
6
6
  import { useFocusTrap } from "./hooks/useFocusTrap.js";
7
7
  import { useIsMobileBreakpoint } from "./hooks/useIsMobileBreakpoint.js";
8
+ import { useIsVisible } from "./hooks/useIsVisible.js";
8
9
  import { useKeyboardEvent } from "./hooks/useKeyboardEvent.js";
9
10
  import { useOutsideEvent } from "./hooks/useOutsideEvent.js";
10
11
  import { useReturnFocusOnUnmount } from "./hooks/useReturnFocusOnUnmount.js";
@@ -266,8 +267,16 @@ const InnerDrawer = (props) => {
266
267
  const overlayRef = useRef(null);
267
268
  const containerRef = useRef(null);
268
269
  const contentRef = useRef(null);
270
+ const topContent = useRef(null);
271
+ const bottomContent = useRef(null);
272
+ const headerRef = useRef(null);
273
+ const footerRef = useRef(null);
269
274
  const [scope, animate] = useAnimate();
270
275
  const [isPresent, safeToRemove] = usePresence();
276
+ const [headerHeight, setHeaderHeight] = React__default.useState(0);
277
+ const [footerHeight, setFooterHeight] = React__default.useState(0);
278
+ const topContentVisible = useIsVisible(topContent);
279
+ const bottomContentVisible = useIsVisible(bottomContent, 0);
271
280
  const { language } = useLanguage(LanguageLocales.NORWEGIAN);
272
281
  const defaultResources = getResources(language);
273
282
  const mergedResources = {
@@ -294,6 +303,27 @@ const InnerDrawer = (props) => {
294
303
  enableBodyScroll();
295
304
  };
296
305
  }, []);
306
+ useEffect(() => {
307
+ const updateHeights = () => {
308
+ if (headerRef.current) {
309
+ setHeaderHeight(headerRef.current.offsetHeight);
310
+ }
311
+ if (footerRef.current) {
312
+ setFooterHeight(footerRef.current.offsetHeight);
313
+ }
314
+ };
315
+ updateHeights();
316
+ const resizeObserver = new ResizeObserver(updateHeights);
317
+ if (headerRef.current) {
318
+ resizeObserver.observe(headerRef.current);
319
+ }
320
+ if (footerRef.current) {
321
+ resizeObserver.observe(footerRef.current);
322
+ }
323
+ return () => {
324
+ resizeObserver.disconnect();
325
+ };
326
+ }, [hasFooterContent]);
297
327
  useEffect(() => {
298
328
  if (!overlayRef.current || !containerRef.current) return;
299
329
  if (!isPresent) {
@@ -356,7 +386,7 @@ const InnerDrawer = (props) => {
356
386
  ...ariaLabelAttributes,
357
387
  children: [
358
388
  /* @__PURE__ */ jsxs("div", { className: styles.drawer__container__inner, children: [
359
- /* @__PURE__ */ jsxs("div", { className: headerStyling, children: [
389
+ /* @__PURE__ */ jsxs("div", { className: headerStyling, ref: headerRef, children: [
360
390
  /* @__PURE__ */ jsx(Title, { id: ariaLabelAttributes == null ? void 0 : ariaLabelAttributes["aria-labelledby"], htmlMarkup: titleHtmlMarkup, appearance: "title3", children: title }),
361
391
  !noCloseButton && onRequestClose != void 0 && /* @__PURE__ */ jsx(
362
392
  Close,
@@ -369,6 +399,16 @@ const InnerDrawer = (props) => {
369
399
  )
370
400
  ] }),
371
401
  /* @__PURE__ */ jsx(
402
+ "div",
403
+ {
404
+ className: classNames(styles["drawer__content__shadow"], styles["drawer__content__shadow--top"]),
405
+ style: {
406
+ opacity: !topContentVisible && contentIsScrollable ? 1 : 0,
407
+ top: headerHeight
408
+ }
409
+ }
410
+ ),
411
+ /* @__PURE__ */ jsxs(
372
412
  "div",
373
413
  {
374
414
  className: styles.drawer__content,
@@ -376,11 +416,25 @@ const InnerDrawer = (props) => {
376
416
  role: contentIsScrollable ? "region" : void 0,
377
417
  ...contentIsScrollable ? ariaLabelAttributes : {},
378
418
  ref: contentRef,
379
- children
419
+ children: [
420
+ /* @__PURE__ */ jsx("div", { ref: topContent }),
421
+ /* @__PURE__ */ jsx("div", { className: styles["drawer__content__children"], children }),
422
+ /* @__PURE__ */ jsx("div", { ref: bottomContent, style: { height: "1px" } })
423
+ ]
424
+ }
425
+ ),
426
+ /* @__PURE__ */ jsx(
427
+ "div",
428
+ {
429
+ className: classNames(styles["drawer__content__shadow"], styles["drawer__content__shadow--bottom"]),
430
+ style: {
431
+ opacity: !bottomContentVisible && contentIsScrollable ? 1 : 0,
432
+ bottom: hasFooterContent ? footerHeight : 0
433
+ }
380
434
  }
381
435
  )
382
436
  ] }),
383
- hasFooterContent && /* @__PURE__ */ jsx("div", { className: styles.drawer__footer, children: footerContent ? footerContent : /* @__PURE__ */ jsxs(Fragment, { children: [
437
+ hasFooterContent && /* @__PURE__ */ jsx("div", { className: styles.drawer__footer, ref: footerRef, children: footerContent ? footerContent : /* @__PURE__ */ jsxs(Fragment, { children: [
384
438
  onPrimaryAction && /* @__PURE__ */ jsx(Button, { onClick: () => handleCTA(onPrimaryAction), children: primaryActionText }),
385
439
  onSecondaryAction && /* @__PURE__ */ jsx(Button, { variant: "borderless", onClick: () => handleCTA(onSecondaryAction), children: secondaryActionText })
386
440
  ] }) })
package/Drawer.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.js","sources":["../../../node_modules/motion/dist/es/framer-motion/dist/es/context/LayoutGroupContext.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/context/PresenceContext.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/context/MotionConfigContext.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/components/AnimatePresence/utils.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/utils/use-isomorphic-effect.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs","../src/components/Drawer/resourceHelper.ts","../src/components/Drawer/Drawer.tsx"],"sourcesContent":["\"use client\";\nimport { createContext } from 'react';\n\nconst LayoutGroupContext = createContext({});\n\nexport { LayoutGroupContext };\n","\"use client\";\nimport { createContext } from 'react';\n\n/**\n * @public\n */\nconst PresenceContext = createContext(null);\n\nexport { PresenceContext };\n","\"use client\";\nimport { createContext } from 'react';\n\n/**\n * @public\n */\nconst MotionConfigContext = createContext({\n transformPagePoint: (p) => p,\n isStatic: false,\n reducedMotion: \"never\",\n});\n\nexport { MotionConfigContext };\n","\"use client\";\nimport { jsx } from 'react/jsx-runtime';\nimport * as React from 'react';\nimport { useId, useRef, useContext, useInsertionEffect } from 'react';\nimport { MotionConfigContext } from '../../context/MotionConfigContext.mjs';\n\n/**\n * Measurement functionality has to be within a separate component\n * to leverage snapshot lifecycle.\n */\nclass PopChildMeasure extends React.Component {\n getSnapshotBeforeUpdate(prevProps) {\n const element = this.props.childRef.current;\n if (element && prevProps.isPresent && !this.props.isPresent) {\n const size = this.props.sizeRef.current;\n size.height = element.offsetHeight || 0;\n size.width = element.offsetWidth || 0;\n size.top = element.offsetTop;\n size.left = element.offsetLeft;\n }\n return null;\n }\n /**\n * Required with getSnapshotBeforeUpdate to stop React complaining.\n */\n componentDidUpdate() { }\n render() {\n return this.props.children;\n }\n}\nfunction PopChild({ children, isPresent }) {\n const id = useId();\n const ref = useRef(null);\n const size = useRef({\n width: 0,\n height: 0,\n top: 0,\n left: 0,\n });\n const { nonce } = useContext(MotionConfigContext);\n /**\n * We create and inject a style block so we can apply this explicit\n * sizing in a non-destructive manner by just deleting the style block.\n *\n * We can't apply size via render as the measurement happens\n * in getSnapshotBeforeUpdate (post-render), likewise if we apply the\n * styles directly on the DOM node, we might be overwriting\n * styles set via the style prop.\n */\n useInsertionEffect(() => {\n const { width, height, top, left } = size.current;\n if (isPresent || !ref.current || !width || !height)\n return;\n ref.current.dataset.motionPopId = id;\n const style = document.createElement(\"style\");\n if (nonce)\n style.nonce = nonce;\n document.head.appendChild(style);\n if (style.sheet) {\n style.sheet.insertRule(`\n [data-motion-pop-id=\"${id}\"] {\n position: absolute !important;\n width: ${width}px !important;\n height: ${height}px !important;\n top: ${top}px !important;\n left: ${left}px !important;\n }\n `);\n }\n return () => {\n document.head.removeChild(style);\n };\n }, [isPresent]);\n return (jsx(PopChildMeasure, { isPresent: isPresent, childRef: ref, sizeRef: size, children: React.cloneElement(children, { ref }) }));\n}\n\nexport { PopChild };\n","\"use client\";\nimport { jsx } from 'react/jsx-runtime';\nimport * as React from 'react';\nimport { useId, useCallback, useMemo } from 'react';\nimport { PresenceContext } from '../../context/PresenceContext.mjs';\nimport { useConstant } from '../../utils/use-constant.mjs';\nimport { PopChild } from './PopChild.mjs';\n\nconst PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode, }) => {\n const presenceChildren = useConstant(newChildrenMap);\n const id = useId();\n const memoizedOnExitComplete = useCallback((childId) => {\n presenceChildren.set(childId, true);\n for (const isComplete of presenceChildren.values()) {\n if (!isComplete)\n return; // can stop searching when any is incomplete\n }\n onExitComplete && onExitComplete();\n }, [presenceChildren, onExitComplete]);\n const context = useMemo(() => ({\n id,\n initial,\n isPresent,\n custom,\n onExitComplete: memoizedOnExitComplete,\n register: (childId) => {\n presenceChildren.set(childId, false);\n return () => presenceChildren.delete(childId);\n },\n }), \n /**\n * If the presence of a child affects the layout of the components around it,\n * we want to make a new context value to ensure they get re-rendered\n * so they can detect that layout change.\n */\n presenceAffectsLayout\n ? [Math.random(), memoizedOnExitComplete]\n : [isPresent, memoizedOnExitComplete]);\n useMemo(() => {\n presenceChildren.forEach((_, key) => presenceChildren.set(key, false));\n }, [isPresent]);\n /**\n * If there's no `motion` components to fire exit animations, we want to remove this\n * component immediately.\n */\n React.useEffect(() => {\n !isPresent &&\n !presenceChildren.size &&\n onExitComplete &&\n onExitComplete();\n }, [isPresent]);\n if (mode === \"popLayout\") {\n children = jsx(PopChild, { isPresent: isPresent, children: children });\n }\n return (jsx(PresenceContext.Provider, { value: context, children: children }));\n};\nfunction newChildrenMap() {\n return new Map();\n}\n\nexport { PresenceChild };\n","import { useContext, useId, useEffect, useCallback } from 'react';\nimport { PresenceContext } from '../../context/PresenceContext.mjs';\n\n/**\n * When a component is the child of `AnimatePresence`, it can use `usePresence`\n * to access information about whether it's still present in the React tree.\n *\n * ```jsx\n * import { usePresence } from \"framer-motion\"\n *\n * export const Component = () => {\n * const [isPresent, safeToRemove] = usePresence()\n *\n * useEffect(() => {\n * !isPresent && setTimeout(safeToRemove, 1000)\n * }, [isPresent])\n *\n * return <div />\n * }\n * ```\n *\n * If `isPresent` is `false`, it means that a component has been removed the tree, but\n * `AnimatePresence` won't really remove it until `safeToRemove` has been called.\n *\n * @public\n */\nfunction usePresence(subscribe = true) {\n const context = useContext(PresenceContext);\n if (context === null)\n return [true, null];\n const { isPresent, onExitComplete, register } = context;\n // It's safe to call the following hooks conditionally (after an early return) because the context will always\n // either be null or non-null for the lifespan of the component.\n const id = useId();\n useEffect(() => {\n if (subscribe)\n register(id);\n }, [subscribe]);\n const safeToRemove = useCallback(() => subscribe && onExitComplete && onExitComplete(id), [id, onExitComplete, subscribe]);\n return !isPresent && onExitComplete ? [false, safeToRemove] : [true];\n}\n/**\n * Similar to `usePresence`, except `useIsPresent` simply returns whether or not the component is present.\n * There is no `safeToRemove` function.\n *\n * ```jsx\n * import { useIsPresent } from \"framer-motion\"\n *\n * export const Component = () => {\n * const isPresent = useIsPresent()\n *\n * useEffect(() => {\n * !isPresent && console.log(\"I've been removed!\")\n * }, [isPresent])\n *\n * return <div />\n * }\n * ```\n *\n * @public\n */\nfunction useIsPresent() {\n return isPresent(useContext(PresenceContext));\n}\nfunction isPresent(context) {\n return context === null ? true : context.isPresent;\n}\n\nexport { isPresent, useIsPresent, usePresence };\n","import { Children, isValidElement } from 'react';\n\nconst getChildKey = (child) => child.key || \"\";\nfunction onlyElements(children) {\n const filtered = [];\n // We use forEach here instead of map as map mutates the component key by preprending `.$`\n Children.forEach(children, (child) => {\n if (isValidElement(child))\n filtered.push(child);\n });\n return filtered;\n}\n\nexport { getChildKey, onlyElements };\n","import { useLayoutEffect, useEffect } from 'react';\nimport { isBrowser } from './is-browser.mjs';\n\nconst useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;\n\nexport { useIsomorphicLayoutEffect };\n","\"use client\";\nimport { jsx, Fragment } from 'react/jsx-runtime';\nimport { useMemo, useRef, useState, useContext } from 'react';\nimport { LayoutGroupContext } from '../../context/LayoutGroupContext.mjs';\nimport { useConstant } from '../../utils/use-constant.mjs';\nimport { PresenceChild } from './PresenceChild.mjs';\nimport { usePresence } from './use-presence.mjs';\nimport { onlyElements, getChildKey } from './utils.mjs';\nimport { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs';\n\n/**\n * `AnimatePresence` enables the animation of components that have been removed from the tree.\n *\n * When adding/removing more than a single child, every child **must** be given a unique `key` prop.\n *\n * Any `motion` components that have an `exit` property defined will animate out when removed from\n * the tree.\n *\n * ```jsx\n * import { motion, AnimatePresence } from 'framer-motion'\n *\n * export const Items = ({ items }) => (\n * <AnimatePresence>\n * {items.map(item => (\n * <motion.div\n * key={item.id}\n * initial={{ opacity: 0 }}\n * animate={{ opacity: 1 }}\n * exit={{ opacity: 0 }}\n * />\n * ))}\n * </AnimatePresence>\n * )\n * ```\n *\n * You can sequence exit animations throughout a tree using variants.\n *\n * If a child contains multiple `motion` components with `exit` props, it will only unmount the child\n * once all `motion` components have finished animating out. Likewise, any components using\n * `usePresence` all need to call `safeToRemove`.\n *\n * @public\n */\nconst AnimatePresence = ({ children, custom, initial = true, onExitComplete, presenceAffectsLayout = true, mode = \"sync\", propagate = false, }) => {\n const [isParentPresent, safeToRemove] = usePresence(propagate);\n /**\n * Filter any children that aren't ReactElements. We can only track components\n * between renders with a props.key.\n */\n const presentChildren = useMemo(() => onlyElements(children), [children]);\n /**\n * Track the keys of the currently rendered children. This is used to\n * determine which children are exiting.\n */\n const presentKeys = propagate && !isParentPresent ? [] : presentChildren.map(getChildKey);\n /**\n * If `initial={false}` we only want to pass this to components in the first render.\n */\n const isInitialRender = useRef(true);\n /**\n * A ref containing the currently present children. When all exit animations\n * are complete, we use this to re-render the component with the latest children\n * *committed* rather than the latest children *rendered*.\n */\n const pendingPresentChildren = useRef(presentChildren);\n /**\n * Track which exiting children have finished animating out.\n */\n const exitComplete = useConstant(() => new Map());\n /**\n * Save children to render as React state. To ensure this component is concurrent-safe,\n * we check for exiting children via an effect.\n */\n const [diffedChildren, setDiffedChildren] = useState(presentChildren);\n const [renderedChildren, setRenderedChildren] = useState(presentChildren);\n useIsomorphicLayoutEffect(() => {\n isInitialRender.current = false;\n pendingPresentChildren.current = presentChildren;\n /**\n * Update complete status of exiting children.\n */\n for (let i = 0; i < renderedChildren.length; i++) {\n const key = getChildKey(renderedChildren[i]);\n if (!presentKeys.includes(key)) {\n if (exitComplete.get(key) !== true) {\n exitComplete.set(key, false);\n }\n }\n else {\n exitComplete.delete(key);\n }\n }\n }, [renderedChildren, presentKeys.length, presentKeys.join(\"-\")]);\n const exitingChildren = [];\n if (presentChildren !== diffedChildren) {\n let nextChildren = [...presentChildren];\n /**\n * Loop through all the currently rendered components and decide which\n * are exiting.\n */\n for (let i = 0; i < renderedChildren.length; i++) {\n const child = renderedChildren[i];\n const key = getChildKey(child);\n if (!presentKeys.includes(key)) {\n nextChildren.splice(i, 0, child);\n exitingChildren.push(child);\n }\n }\n /**\n * If we're in \"wait\" mode, and we have exiting children, we want to\n * only render these until they've all exited.\n */\n if (mode === \"wait\" && exitingChildren.length) {\n nextChildren = exitingChildren;\n }\n setRenderedChildren(onlyElements(nextChildren));\n setDiffedChildren(presentChildren);\n /**\n * Early return to ensure once we've set state with the latest diffed\n * children, we can immediately re-render.\n */\n return;\n }\n if (process.env.NODE_ENV !== \"production\" &&\n mode === \"wait\" &&\n renderedChildren.length > 1) {\n console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to \"wait\". This will lead to odd visual behaviour.`);\n }\n /**\n * If we've been provided a forceRender function by the LayoutGroupContext,\n * we can use it to force a re-render amongst all surrounding components once\n * all components have finished animating out.\n */\n const { forceRender } = useContext(LayoutGroupContext);\n return (jsx(Fragment, { children: renderedChildren.map((child) => {\n const key = getChildKey(child);\n const isPresent = propagate && !isParentPresent\n ? false\n : presentChildren === renderedChildren ||\n presentKeys.includes(key);\n const onExit = () => {\n if (exitComplete.has(key)) {\n exitComplete.set(key, true);\n }\n else {\n return;\n }\n let isEveryExitComplete = true;\n exitComplete.forEach((isExitComplete) => {\n if (!isExitComplete)\n isEveryExitComplete = false;\n });\n if (isEveryExitComplete) {\n forceRender === null || forceRender === void 0 ? void 0 : forceRender();\n setRenderedChildren(pendingPresentChildren.current);\n propagate && (safeToRemove === null || safeToRemove === void 0 ? void 0 : safeToRemove());\n onExitComplete && onExitComplete();\n }\n };\n return (jsx(PresenceChild, { isPresent: isPresent, initial: !isInitialRender.current || initial\n ? undefined\n : false, custom: isPresent ? undefined : custom, presenceAffectsLayout: presenceAffectsLayout, mode: mode, onExitComplete: isPresent ? undefined : onExit, children: child }, key));\n }) }));\n};\n\nexport { AnimatePresence };\n","import { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Drawer.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Drawer.nb-NO.json';\nimport { HNDesignsystemDrawer } from '../../resources/Resources';\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 { getResources } from './resourceHelper';\nimport { AnalyticsId, KeyboardEventKey, LanguageLocales, ZIndex } from '../../constants';\nimport useFocusTrap from '../../hooks/useFocusTrap';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { useKeyboardEvent } from '../../hooks/useKeyboardEvent';\nimport { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { useReturnFocusOnUnmount } from '../../hooks/useReturnFocusOnUnmount';\nimport { HNDesignsystemDrawer } from '../../resources/Resources';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { useLanguage } from '../../utils/language';\nimport { disableBodyScroll, enableBodyScroll } from '../../utils/scroll';\nimport uuid from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Title, { TitleTags } 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 /** @deprecated Close button aria-label */\n ariaLabelCloseBtn?: 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 ariaLabelCloseBtn,\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 const [scope, animate] = useAnimate();\n const [isPresent, safeToRemove] = usePresence();\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemDrawer = {\n ...defaultResources,\n ...resources,\n ariaLabelCloseBtn: ariaLabelCloseBtn || resources?.ariaLabelCloseBtn || defaultResources.ariaLabelCloseBtn,\n };\n\n const contentIsScrollable = contentRef.current && contentRef.current.scrollHeight > contentRef.current.clientHeight;\n const headerStyling = classNames(styles.drawer__header, headerClasses, {\n [styles['drawer__header--no-close-button']]: noCloseButton,\n });\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 useEffect(() => {\n containerRef.current?.focus();\n disableBodyScroll();\n\n return (): void => {\n enableBodyScroll();\n };\n }, []);\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 // 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 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}>\n <Title id={ariaLabelAttributes?.['aria-labelledby']} htmlMarkup={titleHtmlMarkup} appearance=\"title3\">\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={styles.drawer__content}\n tabIndex={contentIsScrollable ? 0 : undefined}\n role={contentIsScrollable ? 'region' : undefined}\n {...(contentIsScrollable ? ariaLabelAttributes : {})}\n ref={contentRef}\n >\n {children}\n </div>\n </div>\n {hasFooterContent && (\n <div className={styles.drawer__footer}>\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"],"names":["ariaLabelCloseBtn"],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,MAAM,qBAAqB,cAAc,EAAE;ACG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EAAO,SAAQ,cAAa,SAAS,MAAM,UAAU,iBAAiB,GACpE,UAAA,oBAAA,CACH;AAAA,UAAA,EAAA,CAEJ,EAAA,CAEJ;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAEJ,GACF;AAEJ;","x_google_ignoreList":[0,1,2,3,4,5,6,7,8]}
1
+ {"version":3,"file":"Drawer.js","sources":["../../../node_modules/motion/dist/es/framer-motion/dist/es/context/LayoutGroupContext.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/context/PresenceContext.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/context/MotionConfigContext.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/components/AnimatePresence/utils.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/utils/use-isomorphic-effect.mjs","../../../node_modules/motion/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs","../src/components/Drawer/resourceHelper.ts","../src/components/Drawer/Drawer.tsx"],"sourcesContent":["\"use client\";\nimport { createContext } from 'react';\n\nconst LayoutGroupContext = createContext({});\n\nexport { LayoutGroupContext };\n","\"use client\";\nimport { createContext } from 'react';\n\n/**\n * @public\n */\nconst PresenceContext = createContext(null);\n\nexport { PresenceContext };\n","\"use client\";\nimport { createContext } from 'react';\n\n/**\n * @public\n */\nconst MotionConfigContext = createContext({\n transformPagePoint: (p) => p,\n isStatic: false,\n reducedMotion: \"never\",\n});\n\nexport { MotionConfigContext };\n","\"use client\";\nimport { jsx } from 'react/jsx-runtime';\nimport * as React from 'react';\nimport { useId, useRef, useContext, useInsertionEffect } from 'react';\nimport { MotionConfigContext } from '../../context/MotionConfigContext.mjs';\n\n/**\n * Measurement functionality has to be within a separate component\n * to leverage snapshot lifecycle.\n */\nclass PopChildMeasure extends React.Component {\n getSnapshotBeforeUpdate(prevProps) {\n const element = this.props.childRef.current;\n if (element && prevProps.isPresent && !this.props.isPresent) {\n const size = this.props.sizeRef.current;\n size.height = element.offsetHeight || 0;\n size.width = element.offsetWidth || 0;\n size.top = element.offsetTop;\n size.left = element.offsetLeft;\n }\n return null;\n }\n /**\n * Required with getSnapshotBeforeUpdate to stop React complaining.\n */\n componentDidUpdate() { }\n render() {\n return this.props.children;\n }\n}\nfunction PopChild({ children, isPresent }) {\n const id = useId();\n const ref = useRef(null);\n const size = useRef({\n width: 0,\n height: 0,\n top: 0,\n left: 0,\n });\n const { nonce } = useContext(MotionConfigContext);\n /**\n * We create and inject a style block so we can apply this explicit\n * sizing in a non-destructive manner by just deleting the style block.\n *\n * We can't apply size via render as the measurement happens\n * in getSnapshotBeforeUpdate (post-render), likewise if we apply the\n * styles directly on the DOM node, we might be overwriting\n * styles set via the style prop.\n */\n useInsertionEffect(() => {\n const { width, height, top, left } = size.current;\n if (isPresent || !ref.current || !width || !height)\n return;\n ref.current.dataset.motionPopId = id;\n const style = document.createElement(\"style\");\n if (nonce)\n style.nonce = nonce;\n document.head.appendChild(style);\n if (style.sheet) {\n style.sheet.insertRule(`\n [data-motion-pop-id=\"${id}\"] {\n position: absolute !important;\n width: ${width}px !important;\n height: ${height}px !important;\n top: ${top}px !important;\n left: ${left}px !important;\n }\n `);\n }\n return () => {\n document.head.removeChild(style);\n };\n }, [isPresent]);\n return (jsx(PopChildMeasure, { isPresent: isPresent, childRef: ref, sizeRef: size, children: React.cloneElement(children, { ref }) }));\n}\n\nexport { PopChild };\n","\"use client\";\nimport { jsx } from 'react/jsx-runtime';\nimport * as React from 'react';\nimport { useId, useCallback, useMemo } from 'react';\nimport { PresenceContext } from '../../context/PresenceContext.mjs';\nimport { useConstant } from '../../utils/use-constant.mjs';\nimport { PopChild } from './PopChild.mjs';\n\nconst PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode, }) => {\n const presenceChildren = useConstant(newChildrenMap);\n const id = useId();\n const memoizedOnExitComplete = useCallback((childId) => {\n presenceChildren.set(childId, true);\n for (const isComplete of presenceChildren.values()) {\n if (!isComplete)\n return; // can stop searching when any is incomplete\n }\n onExitComplete && onExitComplete();\n }, [presenceChildren, onExitComplete]);\n const context = useMemo(() => ({\n id,\n initial,\n isPresent,\n custom,\n onExitComplete: memoizedOnExitComplete,\n register: (childId) => {\n presenceChildren.set(childId, false);\n return () => presenceChildren.delete(childId);\n },\n }), \n /**\n * If the presence of a child affects the layout of the components around it,\n * we want to make a new context value to ensure they get re-rendered\n * so they can detect that layout change.\n */\n presenceAffectsLayout\n ? [Math.random(), memoizedOnExitComplete]\n : [isPresent, memoizedOnExitComplete]);\n useMemo(() => {\n presenceChildren.forEach((_, key) => presenceChildren.set(key, false));\n }, [isPresent]);\n /**\n * If there's no `motion` components to fire exit animations, we want to remove this\n * component immediately.\n */\n React.useEffect(() => {\n !isPresent &&\n !presenceChildren.size &&\n onExitComplete &&\n onExitComplete();\n }, [isPresent]);\n if (mode === \"popLayout\") {\n children = jsx(PopChild, { isPresent: isPresent, children: children });\n }\n return (jsx(PresenceContext.Provider, { value: context, children: children }));\n};\nfunction newChildrenMap() {\n return new Map();\n}\n\nexport { PresenceChild };\n","import { useContext, useId, useEffect, useCallback } from 'react';\nimport { PresenceContext } from '../../context/PresenceContext.mjs';\n\n/**\n * When a component is the child of `AnimatePresence`, it can use `usePresence`\n * to access information about whether it's still present in the React tree.\n *\n * ```jsx\n * import { usePresence } from \"framer-motion\"\n *\n * export const Component = () => {\n * const [isPresent, safeToRemove] = usePresence()\n *\n * useEffect(() => {\n * !isPresent && setTimeout(safeToRemove, 1000)\n * }, [isPresent])\n *\n * return <div />\n * }\n * ```\n *\n * If `isPresent` is `false`, it means that a component has been removed the tree, but\n * `AnimatePresence` won't really remove it until `safeToRemove` has been called.\n *\n * @public\n */\nfunction usePresence(subscribe = true) {\n const context = useContext(PresenceContext);\n if (context === null)\n return [true, null];\n const { isPresent, onExitComplete, register } = context;\n // It's safe to call the following hooks conditionally (after an early return) because the context will always\n // either be null or non-null for the lifespan of the component.\n const id = useId();\n useEffect(() => {\n if (subscribe)\n register(id);\n }, [subscribe]);\n const safeToRemove = useCallback(() => subscribe && onExitComplete && onExitComplete(id), [id, onExitComplete, subscribe]);\n return !isPresent && onExitComplete ? [false, safeToRemove] : [true];\n}\n/**\n * Similar to `usePresence`, except `useIsPresent` simply returns whether or not the component is present.\n * There is no `safeToRemove` function.\n *\n * ```jsx\n * import { useIsPresent } from \"framer-motion\"\n *\n * export const Component = () => {\n * const isPresent = useIsPresent()\n *\n * useEffect(() => {\n * !isPresent && console.log(\"I've been removed!\")\n * }, [isPresent])\n *\n * return <div />\n * }\n * ```\n *\n * @public\n */\nfunction useIsPresent() {\n return isPresent(useContext(PresenceContext));\n}\nfunction isPresent(context) {\n return context === null ? true : context.isPresent;\n}\n\nexport { isPresent, useIsPresent, usePresence };\n","import { Children, isValidElement } from 'react';\n\nconst getChildKey = (child) => child.key || \"\";\nfunction onlyElements(children) {\n const filtered = [];\n // We use forEach here instead of map as map mutates the component key by preprending `.$`\n Children.forEach(children, (child) => {\n if (isValidElement(child))\n filtered.push(child);\n });\n return filtered;\n}\n\nexport { getChildKey, onlyElements };\n","import { useLayoutEffect, useEffect } from 'react';\nimport { isBrowser } from './is-browser.mjs';\n\nconst useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;\n\nexport { useIsomorphicLayoutEffect };\n","\"use client\";\nimport { jsx, Fragment } from 'react/jsx-runtime';\nimport { useMemo, useRef, useState, useContext } from 'react';\nimport { LayoutGroupContext } from '../../context/LayoutGroupContext.mjs';\nimport { useConstant } from '../../utils/use-constant.mjs';\nimport { PresenceChild } from './PresenceChild.mjs';\nimport { usePresence } from './use-presence.mjs';\nimport { onlyElements, getChildKey } from './utils.mjs';\nimport { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs';\n\n/**\n * `AnimatePresence` enables the animation of components that have been removed from the tree.\n *\n * When adding/removing more than a single child, every child **must** be given a unique `key` prop.\n *\n * Any `motion` components that have an `exit` property defined will animate out when removed from\n * the tree.\n *\n * ```jsx\n * import { motion, AnimatePresence } from 'framer-motion'\n *\n * export const Items = ({ items }) => (\n * <AnimatePresence>\n * {items.map(item => (\n * <motion.div\n * key={item.id}\n * initial={{ opacity: 0 }}\n * animate={{ opacity: 1 }}\n * exit={{ opacity: 0 }}\n * />\n * ))}\n * </AnimatePresence>\n * )\n * ```\n *\n * You can sequence exit animations throughout a tree using variants.\n *\n * If a child contains multiple `motion` components with `exit` props, it will only unmount the child\n * once all `motion` components have finished animating out. Likewise, any components using\n * `usePresence` all need to call `safeToRemove`.\n *\n * @public\n */\nconst AnimatePresence = ({ children, custom, initial = true, onExitComplete, presenceAffectsLayout = true, mode = \"sync\", propagate = false, }) => {\n const [isParentPresent, safeToRemove] = usePresence(propagate);\n /**\n * Filter any children that aren't ReactElements. We can only track components\n * between renders with a props.key.\n */\n const presentChildren = useMemo(() => onlyElements(children), [children]);\n /**\n * Track the keys of the currently rendered children. This is used to\n * determine which children are exiting.\n */\n const presentKeys = propagate && !isParentPresent ? [] : presentChildren.map(getChildKey);\n /**\n * If `initial={false}` we only want to pass this to components in the first render.\n */\n const isInitialRender = useRef(true);\n /**\n * A ref containing the currently present children. When all exit animations\n * are complete, we use this to re-render the component with the latest children\n * *committed* rather than the latest children *rendered*.\n */\n const pendingPresentChildren = useRef(presentChildren);\n /**\n * Track which exiting children have finished animating out.\n */\n const exitComplete = useConstant(() => new Map());\n /**\n * Save children to render as React state. To ensure this component is concurrent-safe,\n * we check for exiting children via an effect.\n */\n const [diffedChildren, setDiffedChildren] = useState(presentChildren);\n const [renderedChildren, setRenderedChildren] = useState(presentChildren);\n useIsomorphicLayoutEffect(() => {\n isInitialRender.current = false;\n pendingPresentChildren.current = presentChildren;\n /**\n * Update complete status of exiting children.\n */\n for (let i = 0; i < renderedChildren.length; i++) {\n const key = getChildKey(renderedChildren[i]);\n if (!presentKeys.includes(key)) {\n if (exitComplete.get(key) !== true) {\n exitComplete.set(key, false);\n }\n }\n else {\n exitComplete.delete(key);\n }\n }\n }, [renderedChildren, presentKeys.length, presentKeys.join(\"-\")]);\n const exitingChildren = [];\n if (presentChildren !== diffedChildren) {\n let nextChildren = [...presentChildren];\n /**\n * Loop through all the currently rendered components and decide which\n * are exiting.\n */\n for (let i = 0; i < renderedChildren.length; i++) {\n const child = renderedChildren[i];\n const key = getChildKey(child);\n if (!presentKeys.includes(key)) {\n nextChildren.splice(i, 0, child);\n exitingChildren.push(child);\n }\n }\n /**\n * If we're in \"wait\" mode, and we have exiting children, we want to\n * only render these until they've all exited.\n */\n if (mode === \"wait\" && exitingChildren.length) {\n nextChildren = exitingChildren;\n }\n setRenderedChildren(onlyElements(nextChildren));\n setDiffedChildren(presentChildren);\n /**\n * Early return to ensure once we've set state with the latest diffed\n * children, we can immediately re-render.\n */\n return;\n }\n if (process.env.NODE_ENV !== \"production\" &&\n mode === \"wait\" &&\n renderedChildren.length > 1) {\n console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to \"wait\". This will lead to odd visual behaviour.`);\n }\n /**\n * If we've been provided a forceRender function by the LayoutGroupContext,\n * we can use it to force a re-render amongst all surrounding components once\n * all components have finished animating out.\n */\n const { forceRender } = useContext(LayoutGroupContext);\n return (jsx(Fragment, { children: renderedChildren.map((child) => {\n const key = getChildKey(child);\n const isPresent = propagate && !isParentPresent\n ? false\n : presentChildren === renderedChildren ||\n presentKeys.includes(key);\n const onExit = () => {\n if (exitComplete.has(key)) {\n exitComplete.set(key, true);\n }\n else {\n return;\n }\n let isEveryExitComplete = true;\n exitComplete.forEach((isExitComplete) => {\n if (!isExitComplete)\n isEveryExitComplete = false;\n });\n if (isEveryExitComplete) {\n forceRender === null || forceRender === void 0 ? void 0 : forceRender();\n setRenderedChildren(pendingPresentChildren.current);\n propagate && (safeToRemove === null || safeToRemove === void 0 ? void 0 : safeToRemove());\n onExitComplete && onExitComplete();\n }\n };\n return (jsx(PresenceChild, { isPresent: isPresent, initial: !isInitialRender.current || initial\n ? undefined\n : false, custom: isPresent ? undefined : custom, presenceAffectsLayout: presenceAffectsLayout, mode: mode, onExitComplete: isPresent ? undefined : onExit, children: child }, key));\n }) }));\n};\n\nexport { AnimatePresence };\n","import { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Drawer.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Drawer.nb-NO.json';\nimport { HNDesignsystemDrawer } from '../../resources/Resources';\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 { 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 { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { useReturnFocusOnUnmount } from '../../hooks/useReturnFocusOnUnmount';\nimport { HNDesignsystemDrawer } from '../../resources/Resources';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { useLanguage } from '../../utils/language';\nimport { disableBodyScroll, enableBodyScroll } from '../../utils/scroll';\nimport uuid from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Title, { TitleTags } 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 /** @deprecated Close button aria-label */\n ariaLabelCloseBtn?: 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 ariaLabelCloseBtn,\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 ariaLabelCloseBtn: ariaLabelCloseBtn || resources?.ariaLabelCloseBtn || defaultResources.ariaLabelCloseBtn,\n };\n\n const contentIsScrollable = contentRef.current && contentRef.current.scrollHeight > contentRef.current.clientHeight;\n const headerStyling = classNames(styles.drawer__header, headerClasses, {\n [styles['drawer__header--no-close-button']]: noCloseButton,\n });\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 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 // 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 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 id={ariaLabelAttributes?.['aria-labelledby']} htmlMarkup={titleHtmlMarkup} appearance=\"title3\">\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"],"names":["ariaLabelCloseBtn","React"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,MAAM,qBAAqB,cAAc,EAAE;ACG3C,MAAM,kBAAkB,cAAc,IAAI;ACA1C,MAAM,sBAAsB,cAAc;A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EAAI,WAAW,OAAO,gBAAgB,KAAK,WACzC,UAAA,gBACC,gBAEA,qBAAA,UAAA,EACG,UAAA;AAAA,YAAA,uCAAoB,QAAA,EAAO,SAAS,MAAM,UAAU,eAAe,GAAI,UAAA,mBAAkB;AAAA,YACzF,qBACC,oBAAC,QAAA,EAAO,SAAQ,cAAa,SAAS,MAAM,UAAU,iBAAiB,GACpE,UAAA,oBAAA,CACH;AAAA,UAAA,EAAA,CAEJ,EAAA,CAEJ;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAEJ,GACF;AAEJ;","x_google_ignoreList":[0,1,2,3,4,5,6,7,8]}
@@ -0,0 +1,48 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import classNames from "classnames";
3
+ import { LanguageLocales, AnalyticsId } from "./constants.js";
4
+ import { useLanguage } from "./utils/language.js";
5
+ import styles from "./components/FormFieldTag/styles.module.scss";
6
+ const allRequired = "Alle felt må fylles ut";
7
+ const requiredField = "Må fylles ut";
8
+ const optional = "Valgfritt";
9
+ const nbNO = {
10
+ allRequired,
11
+ requiredField,
12
+ optional
13
+ };
14
+ const getResources = (language) => {
15
+ switch (language) {
16
+ case LanguageLocales.NORWEGIAN:
17
+ default:
18
+ return nbNO;
19
+ }
20
+ };
21
+ const FormFieldTag = (props) => {
22
+ const { id, level, resources, testId } = props;
23
+ const { language } = useLanguage(LanguageLocales.NORWEGIAN);
24
+ const defaultResources = getResources(language);
25
+ const mergedResources = {
26
+ ...defaultResources,
27
+ ...resources
28
+ };
29
+ const textMap = {
30
+ "all-required": mergedResources.allRequired,
31
+ "required-field": mergedResources.requiredField,
32
+ optional: mergedResources.optional
33
+ };
34
+ return /* @__PURE__ */ jsx(
35
+ "span",
36
+ {
37
+ id,
38
+ "data-testid": testId,
39
+ "data-analyticsid": AnalyticsId.FormFieldTag,
40
+ className: classNames(styles["form-field-tag"], { [styles["form-field-tag--optional"]]: level === "optional" }),
41
+ children: textMap[level]
42
+ }
43
+ );
44
+ };
45
+ export {
46
+ FormFieldTag as F
47
+ };
48
+ //# sourceMappingURL=FormFieldTag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormFieldTag.js","sources":["../src/components/FormFieldTag/resourceHelper.ts","../src/components/FormFieldTag/FormFieldTag.tsx"],"sourcesContent":["import { LanguageLocales } from '../../constants';\nimport nbNO from '../../resources/HN.Designsystem.FormFieldTag.nb-NO.json';\nimport { HNDesignsystemFormFieldTag } from '../../resources/Resources';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemFormFieldTag => {\n switch (language) {\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, LanguageLocales } from '../../constants';\nimport { HNDesignsystemFormFieldTag } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\n\nimport styles from './styles.module.scss';\n\nexport type FormFieldTagLevel = 'all-required' | 'required-field' | 'optional';\n\nexport interface FormFieldTagProps {\n /** Id that is placed on the component */\n id?: string;\n /** What level is the required tag, sets the styling and the text. */\n level: FormFieldTagLevel;\n /** Texts if overriding SOT */\n resources?: HNDesignsystemFormFieldTag;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst FormFieldTag: React.FC<FormFieldTagProps> = props => {\n const { id, level, resources, testId } = props;\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemFormFieldTag = {\n ...defaultResources,\n ...resources,\n };\n\n const textMap = {\n 'all-required': mergedResources.allRequired,\n 'required-field': mergedResources.requiredField,\n optional: mergedResources.optional,\n };\n\n return (\n <span\n id={id}\n data-testid={testId}\n data-analyticsid={AnalyticsId.FormFieldTag}\n className={classNames(styles['form-field-tag'], { [styles['form-field-tag--optional']]: level === 'optional' })}\n >\n {textMap[level]}\n </span>\n );\n};\n\nexport default FormFieldTag;\n"],"names":[],"mappings":";;;;;;;;;;;;;AAIO,MAAM,eAAe,CAAC,aAA0D;AACrF,UAAQ,UAAA;AAAA,IACN,KAAK,gBAAgB;AAAA,IACrB;AACE,aAAO;AAAA,EAAA;AAEb;ACcA,MAAM,eAA4C,CAAA,UAAS;AACzD,QAAM,EAAE,IAAI,OAAO,WAAW,WAAW;AAEzC,QAAM,EAAE,SAAA,IAAa,YAA6B,gBAAgB,SAAS;AAC3E,QAAM,mBAAmB,aAAa,QAAQ;AAE9C,QAAM,kBAA8C;AAAA,IAClD,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAGL,QAAM,UAAU;AAAA,IACd,gBAAgB,gBAAgB;AAAA,IAChC,kBAAkB,gBAAgB;AAAA,IAClC,UAAU,gBAAgB;AAAA,EAAA;AAG5B,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,eAAa;AAAA,MACb,oBAAkB,YAAY;AAAA,MAC9B,WAAW,WAAW,OAAO,gBAAgB,GAAG,EAAE,CAAC,OAAO,0BAA0B,CAAC,GAAG,UAAU,YAAY;AAAA,MAE7G,kBAAQ,KAAK;AAAA,IAAA;AAAA,EAAA;AAGpB;"}
package/FormGroup.js CHANGED
@@ -1,4 +1,4 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import React__default, { useState } from "react";
3
3
  import classNames from "classnames";
4
4
  import { FormOnColor, FormSize, AnalyticsId } from "./constants.js";
@@ -6,6 +6,7 @@ import { useUuid } from "./hooks/useUuid.js";
6
6
  import { isComponent } from "./utils/component.js";
7
7
  import { C as Checkbox } from "./Checkbox.js";
8
8
  import { E as ErrorWrapper } from "./ErrorWrapper.js";
9
+ import { F as FormFieldTag } from "./FormFieldTag.js";
9
10
  import { F as FormLayout } from "./FormLayout.js";
10
11
  import { I as Input } from "./Input.js";
11
12
  import { R as RadioButton, g as getRadioLabelClasses } from "./RadioButton.js";
@@ -19,6 +20,7 @@ const FormGroup = React__default.forwardRef((props, ref) => {
19
20
  ariaLabelledBy,
20
21
  className,
21
22
  fieldsetClassName,
23
+ formFieldTag,
22
24
  legendClassName,
23
25
  onColor = FormOnColor.onwhite,
24
26
  size = FormSize.medium,
@@ -118,11 +120,17 @@ const FormGroup = React__default.forwardRef((props, ref) => {
118
120
  const formGroupContent = () => {
119
121
  return /* @__PURE__ */ jsxs("div", { children: [
120
122
  htmlMarkup === "div" && /* @__PURE__ */ jsxs("div", { className: fieldsetClasses, children: [
121
- props.legend && /* @__PURE__ */ jsx("h5", { className: legendClasses, children: props.legend }),
123
+ props.legend && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("h5", { className: legendClasses, children: [
124
+ props.legend,
125
+ formFieldTag && isComponent(formFieldTag, FormFieldTag) && React__default.cloneElement(formFieldTag)
126
+ ] }) }),
122
127
  React__default.Children.map(props.children, mapFormComponent)
123
128
  ] }),
124
129
  htmlMarkup === "fieldset" && /* @__PURE__ */ jsxs("fieldset", { "aria-labelledby": ariaLabelledBy, name: props.fieldsetName, className: fieldsetClasses, children: [
125
- props.legend && /* @__PURE__ */ jsx("legend", { className: legendClasses, children: props.legend }),
130
+ props.legend && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("legend", { className: legendClasses, children: [
131
+ props.legend,
132
+ formFieldTag && isComponent(formFieldTag, FormFieldTag) && React__default.cloneElement(formFieldTag)
133
+ ] }) }),
126
134
  React__default.Children.map(props.children, mapFormComponent)
127
135
  ] })
128
136
  ] });
package/FormGroup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"FormGroup.js","sources":["../src/components/FormGroup/FormGroup.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { isComponent } from '../../utils/component';\nimport Checkbox, { CheckboxProps } from '../Checkbox/Checkbox';\nimport ErrorWrapper from '../ErrorWrapper';\nimport FormLayout, { FormLayoutProps } from '../FormLayout';\nimport Input, { InputProps } from '../Input/Input';\nimport RadioButton, { RadioButtonProps, getRadioLabelClasses } from '../RadioButton/RadioButton';\nimport Select, { SelectProps } from '../Select';\nimport Slider, { SliderProps } from '../Slider';\nimport Textarea, { TextareaProps } from '../Textarea';\nimport Title from '../Title';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport type FormGroupTags = 'fieldset' | 'div';\n\nexport interface FormGroupProps {\n /** Can be used as a replacement text for legend in cases where the group title already exists externally */\n ariaLabelledBy?: string;\n /** title for the the fieldset */\n title?: string;\n /** text placed in the legend tag of the fieldset */\n legend?: string;\n /** Items in the FormGroup component */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds custom classes to the errorWrapper. */\n errorWrapperClassName?: string;\n /** Adds custom classes to the fieldset element. */\n fieldsetClassName?: string;\n /** Adds custom classes to the legend element. */\n legendClassName?: string;\n /** Changes the visuals of the formgroup */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Error message */\n error?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets the data-testid attribute for the error-wrapper. */\n errorWrapperTestId?: string;\n /** Unique name for the child input element */\n name?: string;\n /** Unique name for the fieldset */\n fieldsetName?: string;\n /** Sets div instead of fieldset tag */\n htmlMarkup?: FormGroupTags;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n}\n\nexport const FormGroup = React.forwardRef((props: FormGroupProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const {\n ariaLabelledBy,\n className,\n fieldsetClassName,\n legendClassName,\n onColor = FormOnColor.onwhite,\n size = FormSize.medium,\n error,\n errorTextId,\n name,\n htmlMarkup = 'fieldset',\n renderError = true,\n errorWrapperClassName,\n errorWrapperTestId,\n } = props;\n const [checkedRadioId, setCheckedRadioId] = useState<string>();\n const radioGroupId = useUuid();\n const errorTextUuid = useUuid(errorTextId);\n const onDark = onColor === FormOnColor.ondark;\n const isLarge = size === FormSize.large;\n const formGroupWrapperClasses = classNames(formGroupStyles['form-group-wrapper'], className);\n const titleClasses = classNames({\n [formGroupStyles['form-group-wrapper__title--on-dark']]: onDark && !error,\n });\n\n const legendClasses = classNames(\n formGroupStyles['field-set__legend'],\n {\n [formGroupStyles['field-set__legend--on-dark']]: onDark && !error,\n },\n legendClassName\n );\n\n const fieldsetClasses = classNames(formGroupStyles['field-set'], fieldsetClassName);\n\n const mapFormComponent = (child: React.ReactNode, index: number): React.ReactNode => {\n if (isComponent<FormLayoutProps>(child, FormLayout)) {\n return React.cloneElement(child, {\n size,\n mapHelper: mapFormComponent,\n });\n } else if (isComponent<FormGroupProps>(child, FormGroup)) {\n return React.cloneElement(child, {\n onColor,\n size,\n error,\n renderError: false,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<CheckboxProps>(child, Checkbox)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n size,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<RadioButtonProps>(child, RadioButton)) {\n const radioId = typeof child.props.inputId === 'undefined' ? radioGroupId + index : child.props.inputId;\n return React.cloneElement(child, {\n inputId: radioId,\n name: name ?? child.props.name,\n onColor,\n size,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n setCheckedRadioId(event.target.id);\n if (child.props.onChange) child.props.onChange(event);\n },\n error: !!error,\n errorTextId: errorTextUuid,\n labelClassNames: getRadioLabelClasses(radioId, onColor as FormOnColor, isLarge, checkedRadioId),\n });\n } else if (isComponent<InputProps>(child, Input)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n size,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<TextareaProps>(child, Textarea)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<SelectProps>(child, Select)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<SliderProps>(child, Slider)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n }\n return child;\n };\n\n const formGroupContent = (): React.ReactNode => {\n return (\n <div>\n {htmlMarkup === 'div' && (\n <div className={fieldsetClasses}>\n {props.legend && <h5 className={legendClasses}>{props.legend}</h5>}\n {React.Children.map(props.children, mapFormComponent)}\n </div>\n )}\n {htmlMarkup === 'fieldset' && (\n <fieldset aria-labelledby={ariaLabelledBy} name={props.fieldsetName} className={fieldsetClasses}>\n {props.legend && <legend className={legendClasses}>{props.legend}</legend>}\n {React.Children.map(props.children, mapFormComponent)}\n </fieldset>\n )}\n </div>\n );\n };\n\n return (\n <div data-testid={props.testId} data-analyticsid={AnalyticsId.FormGroup} className={formGroupWrapperClasses}>\n {props.title && (\n <Title className={titleClasses} htmlMarkup={'h4'} appearance={'title4'} margin={{ marginTop: 0, marginBottom: error ? 1 : 2 }}>\n {props.title}\n </Title>\n )}\n <ErrorWrapper\n className={errorWrapperClassName}\n errorText={error}\n testId={errorWrapperTestId}\n errorTextId={errorTextUuid}\n errorMessageRef={ref}\n renderError={renderError}\n >\n {formGroupContent()}\n </ErrorWrapper>\n </div>\n );\n});\n\nFormGroup.displayName = 'FormGroup';\n\nexport default FormGroup;\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;AA4DO,MAAM,YAAYA,eAAM,WAAW,CAAC,OAAuB,QAA4C;AAC5G,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,YAAY;AAAA,IACtB,OAAO,SAAS;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,cAAc;AAAA,IACd;AAAA,IACA;AAAA,EAAA,IACE;AACJ,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAA;A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eAAM,SAAS,IAAI,MAAM,UAAU,gBAAgB;AAAA,MAAA,GACtD;AAAA,MAED,eAAe,cACd,qBAAC,YAAA,EAAS,mBAAiB,gBAAgB,MAAM,MAAM,cAAc,WAAW,iBAC7E,UAAA;AAAA,QAAA,MAAM,UAAU,oBAAC,UAAA,EAAO,WAAW,eAAgB,gBAAM,QAAO;AAAA,QAChEA,eAAM,SAAS,IAAI,MAAM,UAAU,gBAAgB;AAAA,MAAA,EAAA,CACtD;AAAA,IAAA,GAEJ;AAAA,EAEJ;AAEA,SACE,qBAAC,SAAI,eAAa,MAAM,QAAQ,oBAAkB,YAAY,WAAW,WAAW,yBACjF,UAAA;AAAA,IAAA,MAAM,SACL,oBAAC,OAAA,EAAM,WAAW,cAAc,YAAY,MAAM,YAAY,UAAU,QAAQ,EAAE,WAAW,GAAG,cAAc,QAAQ,IAAI,EAAA,GACvH,gBAAM,OACT;AAAA,IAEF;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAW;AAAA,QACX,WAAW;AAAA,QACX,QAAQ;AAAA,QACR,aAAa;AAAA,QACb,iBAAiB;AAAA,QACjB;AAAA,QAEC,UAAA,iBAAA;AAAA,MAAiB;AAAA,IAAA;AAAA,EACpB,GACF;AAEJ,CAAC;AAED,UAAU,cAAc;"}
1
+ {"version":3,"file":"FormGroup.js","sources":["../src/components/FormGroup/FormGroup.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { isComponent } from '../../utils/component';\nimport Checkbox, { CheckboxProps } from '../Checkbox/Checkbox';\nimport ErrorWrapper from '../ErrorWrapper';\nimport FormFieldTag, { FormFieldTagProps } from '../FormFieldTag';\nimport FormLayout, { FormLayoutProps } from '../FormLayout';\nimport Input, { InputProps } from '../Input/Input';\nimport RadioButton, { RadioButtonProps, getRadioLabelClasses } from '../RadioButton/RadioButton';\nimport Select, { SelectProps } from '../Select';\nimport Slider, { SliderProps } from '../Slider';\nimport Textarea, { TextareaProps } from '../Textarea';\nimport Title from '../Title';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport type FormGroupTags = 'fieldset' | 'div';\n\nexport interface FormGroupProps {\n /** Can be used as a replacement text for legend in cases where the group title already exists externally */\n ariaLabelledBy?: string;\n /** title for the the fieldset */\n title?: string;\n /** text placed in the legend tag of the fieldset */\n legend?: string;\n /** Items in the FormGroup component */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds custom classes to the errorWrapper. */\n errorWrapperClassName?: string;\n /** Adds custom classes to the fieldset element. */\n fieldsetClassName?: string;\n /** Sets a tag that describes whether the form group is required or optional */\n formFieldTag?: React.ReactNode;\n /** Adds custom classes to the legend element. */\n legendClassName?: string;\n /** Changes the visuals of the formgroup */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Error message */\n error?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets the data-testid attribute for the error-wrapper. */\n errorWrapperTestId?: string;\n /** Unique name for the child input element */\n name?: string;\n /** Unique name for the fieldset */\n fieldsetName?: string;\n /** Sets div instead of fieldset tag */\n htmlMarkup?: FormGroupTags;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n}\n\nexport const FormGroup = React.forwardRef((props: FormGroupProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const {\n ariaLabelledBy,\n className,\n fieldsetClassName,\n formFieldTag,\n legendClassName,\n onColor = FormOnColor.onwhite,\n size = FormSize.medium,\n error,\n errorTextId,\n name,\n htmlMarkup = 'fieldset',\n renderError = true,\n errorWrapperClassName,\n errorWrapperTestId,\n } = props;\n const [checkedRadioId, setCheckedRadioId] = useState<string>();\n const radioGroupId = useUuid();\n const errorTextUuid = useUuid(errorTextId);\n const onDark = onColor === FormOnColor.ondark;\n const isLarge = size === FormSize.large;\n const formGroupWrapperClasses = classNames(formGroupStyles['form-group-wrapper'], className);\n const titleClasses = classNames({\n [formGroupStyles['form-group-wrapper__title--on-dark']]: onDark && !error,\n });\n\n const legendClasses = classNames(\n formGroupStyles['field-set__legend'],\n {\n [formGroupStyles['field-set__legend--on-dark']]: onDark && !error,\n },\n legendClassName\n );\n\n const fieldsetClasses = classNames(formGroupStyles['field-set'], fieldsetClassName);\n\n const mapFormComponent = (child: React.ReactNode, index: number): React.ReactNode => {\n if (isComponent<FormLayoutProps>(child, FormLayout)) {\n return React.cloneElement(child, {\n size,\n mapHelper: mapFormComponent,\n });\n } else if (isComponent<FormGroupProps>(child, FormGroup)) {\n return React.cloneElement(child, {\n onColor,\n size,\n error,\n renderError: false,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<CheckboxProps>(child, Checkbox)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n size,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<RadioButtonProps>(child, RadioButton)) {\n const radioId = typeof child.props.inputId === 'undefined' ? radioGroupId + index : child.props.inputId;\n return React.cloneElement(child, {\n inputId: radioId,\n name: name ?? child.props.name,\n onColor,\n size,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n setCheckedRadioId(event.target.id);\n if (child.props.onChange) child.props.onChange(event);\n },\n error: !!error,\n errorTextId: errorTextUuid,\n labelClassNames: getRadioLabelClasses(radioId, onColor as FormOnColor, isLarge, checkedRadioId),\n });\n } else if (isComponent<InputProps>(child, Input)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n size,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<TextareaProps>(child, Textarea)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<SelectProps>(child, Select)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<SliderProps>(child, Slider)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n }\n return child;\n };\n\n const formGroupContent = (): React.ReactNode => {\n return (\n <div>\n {htmlMarkup === 'div' && (\n <div className={fieldsetClasses}>\n {props.legend && (\n <>\n <h5 className={legendClasses}>\n {props.legend}\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n </h5>\n </>\n )}\n {React.Children.map(props.children, mapFormComponent)}\n </div>\n )}\n {htmlMarkup === 'fieldset' && (\n <fieldset aria-labelledby={ariaLabelledBy} name={props.fieldsetName} className={fieldsetClasses}>\n {props.legend && (\n <>\n <legend className={legendClasses}>\n {props.legend}\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n </legend>\n </>\n )}\n {React.Children.map(props.children, mapFormComponent)}\n </fieldset>\n )}\n </div>\n );\n };\n\n return (\n <div data-testid={props.testId} data-analyticsid={AnalyticsId.FormGroup} className={formGroupWrapperClasses}>\n {props.title && (\n <Title className={titleClasses} htmlMarkup={'h4'} appearance={'title4'} margin={{ marginTop: 0, marginBottom: error ? 1 : 2 }}>\n {props.title}\n </Title>\n )}\n <ErrorWrapper\n className={errorWrapperClassName}\n errorText={error}\n testId={errorWrapperTestId}\n errorTextId={errorTextUuid}\n errorMessageRef={ref}\n renderError={renderError}\n >\n {formGroupContent()}\n </ErrorWrapper>\n </div>\n );\n});\n\nFormGroup.displayName = 'FormGroup';\n\nexport default FormGroup;\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;AA+DO,MAAM,YAAYA,eAAM,WAAW,CAAC,OAAuB,QAA4C;AAC5G,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,YAAY;AAAA,IACtB,OAAO,SAAS;AAAA,IAChB;AAAA,IACA;AAAA,IAC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