@helsenorge/designsystem-react 14.0.0 → 14.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/lib/AnchorLink.js +2 -2
  2. package/lib/AnchorLink.js.map +1 -1
  3. package/lib/Avatar.js +2 -2
  4. package/lib/Avatar.js.map +1 -1
  5. package/lib/Badge.js +2 -2
  6. package/lib/Badge.js.map +1 -1
  7. package/lib/Button.js +6 -6
  8. package/lib/Button.js.map +1 -1
  9. package/lib/CHANGELOG.md +245 -223
  10. package/lib/Checkbox.js +6 -6
  11. package/lib/Checkbox.js.map +1 -1
  12. package/lib/Close.js +3 -3
  13. package/lib/Close.js.map +1 -1
  14. package/lib/DictionaryTrigger.js +2 -2
  15. package/lib/DictionaryTrigger.js.map +1 -1
  16. package/lib/Drawer.js +13 -7
  17. package/lib/Drawer.js.map +1 -1
  18. package/lib/Duolist.js +5 -5
  19. package/lib/Duolist.js.map +1 -1
  20. package/lib/ElementHeader.js +9 -9
  21. package/lib/ElementHeader.js.map +1 -1
  22. package/lib/ElementHeaderText.js +4 -4
  23. package/lib/ElementHeaderText.js.map +1 -1
  24. package/lib/ErrorWrapper.js +2 -2
  25. package/lib/ErrorWrapper.js.map +1 -1
  26. package/lib/Expander.js +8 -8
  27. package/lib/Expander.js.map +1 -1
  28. package/lib/FormFieldTag.js +2 -2
  29. package/lib/FormFieldTag.js.map +1 -1
  30. package/lib/FormGroup.js +5 -5
  31. package/lib/FormGroup.js.map +1 -1
  32. package/lib/FormLayout.js +3 -3
  33. package/lib/FormLayout.js.map +1 -1
  34. package/lib/HelpDetails.js +3 -3
  35. package/lib/HelpDetails.js.map +1 -1
  36. package/lib/HelpTriggerIcon.js +2 -2
  37. package/lib/HelpTriggerIcon.js.map +1 -1
  38. package/lib/HelpTriggerStandalone.js +2 -2
  39. package/lib/HelpTriggerStandalone.js.map +1 -1
  40. package/lib/HighlightPanel.js +3 -3
  41. package/lib/HighlightPanel.js.map +1 -1
  42. package/lib/HorizontalScroll.js +4 -4
  43. package/lib/HorizontalScroll.js.map +1 -1
  44. package/lib/Icon.js +2 -2
  45. package/lib/Icon.js.map +1 -1
  46. package/lib/InfoTeaser.js +3 -3
  47. package/lib/InfoTeaser.js.map +1 -1
  48. package/lib/Input.js +4 -4
  49. package/lib/Input.js.map +1 -1
  50. package/lib/LazyIcon.js +2 -0
  51. package/lib/LazyIcon.js.map +1 -1
  52. package/lib/LinkList.js +5 -5
  53. package/lib/LinkList.js.map +1 -1
  54. package/lib/List.js +2 -2
  55. package/lib/List.js.map +1 -1
  56. package/lib/ListEditMode.js +4 -4
  57. package/lib/ListEditMode.js.map +1 -1
  58. package/lib/MaxCharacters.js +2 -2
  59. package/lib/MaxCharacters.js.map +1 -1
  60. package/lib/PanelTitle.js +2 -2
  61. package/lib/PanelTitle.js.map +1 -1
  62. package/lib/PopOver.js +2 -2
  63. package/lib/PopOver.js.map +1 -1
  64. package/lib/Select.js +4 -4
  65. package/lib/Select.js.map +1 -1
  66. package/lib/SingleSelectItem.js +3 -3
  67. package/lib/SingleSelectItem.js.map +1 -1
  68. package/lib/Slider.js +4 -4
  69. package/lib/Slider.js.map +1 -1
  70. package/lib/Spacer.js +2 -2
  71. package/lib/Spacer.js.map +1 -1
  72. package/lib/StatusDot.js +4 -4
  73. package/lib/StatusDot.js.map +1 -1
  74. package/lib/StatusDotList.js +2 -2
  75. package/lib/StatusDotList.js.map +1 -1
  76. package/lib/StepButtons.js +5 -5
  77. package/lib/StepButtons.js.map +1 -1
  78. package/lib/TabList.js +8 -8
  79. package/lib/TabList.js.map +1 -1
  80. package/lib/TabPanel.js +2 -2
  81. package/lib/TabPanel.js.map +1 -1
  82. package/lib/TableBody.js +2 -2
  83. package/lib/TableBody.js.map +1 -1
  84. package/lib/TableCell.js +2 -2
  85. package/lib/TableCell.js.map +1 -1
  86. package/lib/TableExpandedRow.js +4 -4
  87. package/lib/TableExpandedRow.js.map +1 -1
  88. package/lib/TableExpanderCell.js +2 -2
  89. package/lib/TableExpanderCell.js.map +1 -1
  90. package/lib/TableHead.js +2 -2
  91. package/lib/TableHead.js.map +1 -1
  92. package/lib/TableHeadCell.js +3 -3
  93. package/lib/TableHeadCell.js.map +1 -1
  94. package/lib/TableRow.js +3 -3
  95. package/lib/TableRow.js.map +1 -1
  96. package/lib/Textarea.js +4 -4
  97. package/lib/Textarea.js.map +1 -1
  98. package/lib/Title.js +2 -2
  99. package/lib/Title.js.map +1 -1
  100. package/lib/Toast.js +3 -3
  101. package/lib/Toast.js.map +1 -1
  102. package/lib/components/ArticleTeaser/index.js +4 -4
  103. package/lib/components/ArticleTeaser/index.js.map +1 -1
  104. package/lib/components/Chip/index.js +2 -2
  105. package/lib/components/Chip/index.js.map +1 -1
  106. package/lib/components/Dropdown/index.js +5 -5
  107. package/lib/components/Dropdown/index.js.map +1 -1
  108. package/lib/components/DropdownOld/index.js +3 -3
  109. package/lib/components/DropdownOld/index.js.map +1 -1
  110. package/lib/components/EmptyState/index.js +2 -2
  111. package/lib/components/EmptyState/index.js.map +1 -1
  112. package/lib/components/ExpanderHierarchy/index.js +7 -7
  113. package/lib/components/ExpanderHierarchy/index.js.map +1 -1
  114. package/lib/components/ExpanderList/index.js +6 -6
  115. package/lib/components/ExpanderList/index.js.map +1 -1
  116. package/lib/components/FavoriteButton/index.js +2 -2
  117. package/lib/components/FavoriteButton/index.js.map +1 -1
  118. package/lib/components/HelpBubble/index.js +3 -3
  119. package/lib/components/HelpBubble/index.js.map +1 -1
  120. package/lib/components/HelpPanel/index.js +2 -2
  121. package/lib/components/HelpPanel/index.js.map +1 -1
  122. package/lib/components/HelpTriggerInline/index.js +2 -2
  123. package/lib/components/HelpTriggerInline/index.js.map +1 -1
  124. package/lib/components/Icons/AdditionalIconInformation.d.ts +8 -0
  125. package/lib/components/Icons/AdditionalIconInformation.js +8 -0
  126. package/lib/components/Icons/AdditionalIconInformation.js.map +1 -1
  127. package/lib/components/Icons/Filter.js +27 -9
  128. package/lib/components/Icons/Filter.js.map +1 -1
  129. package/lib/components/Icons/IconNames.d.ts +1 -1
  130. package/lib/components/Icons/IconNames.js +2 -0
  131. package/lib/components/Icons/IconNames.js.map +1 -1
  132. package/lib/components/Icons/MeasuringTape.d.ts +3 -0
  133. package/lib/components/Icons/MeasuringTape.js +8 -0
  134. package/lib/components/Icons/MeasuringTape.js.map +1 -0
  135. package/lib/components/Icons/Search.js +11 -1
  136. package/lib/components/Icons/Search.js.map +1 -1
  137. package/lib/components/Icons/Sort.d.ts +3 -0
  138. package/lib/components/Icons/Sort.js +48 -0
  139. package/lib/components/Icons/Sort.js.map +1 -0
  140. package/lib/components/Loader/index.js +4 -4
  141. package/lib/components/Loader/index.js.map +1 -1
  142. package/lib/components/Modal/index.js +9 -9
  143. package/lib/components/Modal/index.js.map +1 -1
  144. package/lib/components/NotificationPanel/index.js +6 -6
  145. package/lib/components/NotificationPanel/index.js.map +1 -1
  146. package/lib/components/Panel/index.js +12 -12
  147. package/lib/components/Panel/index.js.map +1 -1
  148. package/lib/components/PanelList/index.js +3 -3
  149. package/lib/components/PanelList/index.js.map +1 -1
  150. package/lib/components/PopMenu/index.js +3 -3
  151. package/lib/components/PopMenu/index.js.map +1 -1
  152. package/lib/components/Progressbar/index.js +2 -2
  153. package/lib/components/Progressbar/index.js.map +1 -1
  154. package/lib/components/PromoPanel/index.js +2 -2
  155. package/lib/components/PromoPanel/index.js.map +1 -1
  156. package/lib/components/ServiceMessage/index.js +5 -5
  157. package/lib/components/ServiceMessage/index.js.map +1 -1
  158. package/lib/components/SharingStatus/index.js +4 -4
  159. package/lib/components/SharingStatus/index.js.map +1 -1
  160. package/lib/components/Step/index.js +2 -2
  161. package/lib/components/Step/index.js.map +1 -1
  162. package/lib/components/Stepper/index.js +2 -2
  163. package/lib/components/Stepper/index.js.map +1 -1
  164. package/lib/components/StickyNote/index.js +12 -11
  165. package/lib/components/StickyNote/index.js.map +1 -1
  166. package/lib/components/Table/index.js +2 -2
  167. package/lib/components/Table/index.js.map +1 -1
  168. package/lib/components/Tabs/index.js +4 -4
  169. package/lib/components/Tabs/index.js.map +1 -1
  170. package/lib/components/Tag/index.js +2 -2
  171. package/lib/components/Tag/index.js.map +1 -1
  172. package/lib/components/Tile/index.js +6 -5
  173. package/lib/components/Tile/index.js.map +1 -1
  174. package/lib/components/Toggle/index.js +16 -16
  175. package/lib/components/Toggle/index.js.map +1 -1
  176. package/lib/components/Toggle/styles.module.scss +4 -4
  177. package/lib/components/Validation/index.js +2 -2
  178. package/lib/components/Validation/index.js.map +1 -1
  179. package/lib/declaration.d.ts +9 -0
  180. package/lib/global.d.ts +3 -0
  181. package/lib/resources/HN.Designsystem.Drawer.en-GB.json.d.ts +2 -1
  182. package/lib/resources/HN.Designsystem.Drawer.nb-NO.json.d.ts +2 -1
  183. package/lib/resources/Resources.d.ts +149 -0
  184. package/lib/scss/bootstrap/scss/mixins/_grid.scss +2 -1
  185. package/lib/types.d.ts +1 -0
  186. package/lib/utils2.js +7 -7
  187. package/lib/utils2.js.map +1 -1
  188. package/lib/utils3.js +5 -5
  189. package/lib/utils3.js.map +1 -1
  190. package/package.json +1 -1
  191. package/scss/bootstrap/scss/mixins/_grid.scss +2 -1
package/lib/Checkbox.js CHANGED
@@ -9,7 +9,7 @@ import { t as useIdWithFallback } from "./useIdWithFallback.js";
9
9
  import { t as getAriaDescribedBy } from "./accessibility.js";
10
10
  import { t as ErrorWrapper_default } from "./ErrorWrapper.js";
11
11
  import { r as renderLabelAsParent, t as getLabelText } from "./utils2.js";
12
- import classNames from "classnames";
12
+ import cn from "classnames";
13
13
  import { useEffect, useState } from "react";
14
14
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
15
15
  import checkboxStyles from "./components/Checkbox/styles.module.scss";
@@ -25,8 +25,8 @@ const Checkbox = (props) => {
25
25
  const large = size === FormSize.large;
26
26
  const { refObject, isFocused } = usePseudoClasses(isMutableRefObject(ref) ? ref : null);
27
27
  const mergedRefs = mergeRefs([ref, refObject]);
28
- const checkboxWrapperClasses = classNames(checkboxStyles["checkbox-wrapper"], { [checkboxStyles["checkbox-wrapper--large"]]: large });
29
- const checkboxLabelClasses = classNames(checkboxStyles["checkbox-label"], {
28
+ const checkboxWrapperClasses = cn(checkboxStyles["checkbox-wrapper"], { [checkboxStyles["checkbox-wrapper--large"]]: large });
29
+ const checkboxLabelClasses = cn(checkboxStyles["checkbox-label"], {
30
30
  [checkboxStyles["checkbox-label--disabled"]]: disabled,
31
31
  [checkboxStyles["checkbox-label--on-dark"]]: onDark,
32
32
  [checkboxStyles["checkbox-label--large"]]: large,
@@ -38,8 +38,8 @@ const Checkbox = (props) => {
38
38
  [checkboxStyles["checkbox-label__large--on-invalid"]]: large && onInvalid,
39
39
  [checkboxStyles["checkbox-label__large--disabled"]]: large && disabled
40
40
  });
41
- const checkboxClasses = classNames(checkboxStyles.checkbox, className);
42
- const checkboxIconWrapperClasses = classNames(checkboxStyles["checkbox__icon-wrapper"], {
41
+ const checkboxClasses = cn(checkboxStyles.checkbox, className);
42
+ const checkboxIconWrapperClasses = cn(checkboxStyles["checkbox__icon-wrapper"], {
43
43
  [checkboxStyles["checkbox__icon-wrapper--on-white"]]: onWhite,
44
44
  [checkboxStyles["checkbox__icon-wrapper--on-grey"]]: onGrey,
45
45
  [checkboxStyles["checkbox__icon-wrapper--on-invalid"]]: onInvalid,
@@ -57,7 +57,7 @@ const Checkbox = (props) => {
57
57
  [checkboxStyles["checkbox__icon-wrapper__large--checked--invalid"]]: large && isChecked && onInvalid,
58
58
  [checkboxStyles["checkbox__icon-wrapper__large--checked--disabled"]]: disabled && large && isChecked
59
59
  });
60
- const labelTextClasses = classNames(checkboxStyles["checkbox-label__text"], {
60
+ const labelTextClasses = cn(checkboxStyles["checkbox-label__text"], {
61
61
  [checkboxStyles["checkbox-label__text__large--checked"]]: large && isChecked,
62
62
  [checkboxStyles["checkbox-label__text__large--invalid"]]: large && isChecked && onInvalid,
63
63
  [checkboxStyles["checkbox-label__text--on-dark"]]: onDark,
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","names":["Checkbox: React.FC<CheckboxProps>"],"sources":["../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\n\nimport { AnalyticsId, FormOnColor, FormSize, IconSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getColor } from '../../theme/currys/color';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport Icon from '../Icon';\nimport Check from '../Icons/Check';\nimport { getLabelText, renderLabelAsParent } from '../Label/utils';\n\nimport checkboxStyles from './styles.module.scss';\n\nexport interface CheckboxProps\n extends\n ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the checkbox - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** input id of the checkbox */\n inputId?: string;\n /** Changes the visuals of the checkbox */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the checkbox */\n size?: keyof typeof FormSize;\n /** Activates Error style for the checkbox - This is can be true while errorText is empty, when in a FormGroup */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref that is passed to the component */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nexport const Checkbox: React.FC<CheckboxProps> = props => {\n const {\n className,\n checked = false,\n disabled,\n label,\n inputId = uuid(),\n onColor = FormOnColor.onwhite,\n name = inputId,\n size,\n errorText,\n error = !!errorText,\n errorTextId: errorTextIdProp,\n errorWrapperClassName,\n value = getLabelText(label),\n testId,\n required,\n onChange,\n ref,\n } = props;\n const [isChecked, setIsChecked] = useState(checked);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n const onWhite = onColor === FormOnColor.onwhite;\n const onGrey = onColor === FormOnColor.ongrey;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const onInvalid = error || onColor === FormOnColor.oninvalid;\n const onDark = onColor === FormOnColor.ondark;\n const large = size === FormSize.large;\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n\n const checkboxWrapperClasses = classNames(checkboxStyles['checkbox-wrapper'], {\n [checkboxStyles['checkbox-wrapper--large']]: large,\n });\n const checkboxLabelClasses = classNames(checkboxStyles['checkbox-label'], {\n [checkboxStyles['checkbox-label--disabled']]: disabled,\n [checkboxStyles['checkbox-label--on-dark']]: onDark,\n [checkboxStyles['checkbox-label--large']]: large,\n [checkboxStyles['checkbox-label__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__large--focus']]: large && isFocused,\n [checkboxStyles['checkbox-label__large--on-white']]: large && onWhite,\n [checkboxStyles['checkbox-label__large--on-grey']]: large && onGrey,\n [checkboxStyles['checkbox-label__large--on-blueberry']]: large && onBlueberry,\n [checkboxStyles['checkbox-label__large--on-invalid']]: large && onInvalid,\n [checkboxStyles['checkbox-label__large--disabled']]: large && disabled,\n });\n const checkboxClasses = classNames(checkboxStyles.checkbox, className);\n const checkboxIconWrapperClasses = classNames(checkboxStyles['checkbox__icon-wrapper'], {\n [checkboxStyles['checkbox__icon-wrapper--on-white']]: onWhite,\n [checkboxStyles['checkbox__icon-wrapper--on-grey']]: onGrey,\n [checkboxStyles['checkbox__icon-wrapper--on-invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--disabled']]: disabled,\n [checkboxStyles['checkbox__icon-wrapper__regular--checked']]: !large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__regular--invalid']]: !large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__regular--on-dark']]: !large && isChecked && onDark,\n [checkboxStyles['checkbox__icon-wrapper__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--on-dark']]: onDark,\n [checkboxStyles['checkbox__icon-wrapper--on-blueberry']]: onBlueberry,\n [checkboxStyles['checkbox__icon-wrapper--invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--disabled']]: disabled && large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--disabled']]: disabled && large && isChecked,\n });\n const labelTextClasses = classNames(checkboxStyles['checkbox-label__text'], {\n [checkboxStyles['checkbox-label__text__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__text__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox-label__text--on-dark']]: onDark,\n [checkboxStyles['checkbox-label__text--disabled']]: disabled,\n });\n\n let iconColor = getColor('white');\n if (onDark || (large && isChecked)) iconColor = getColor('blueberry', 900);\n if (onInvalid && large && isChecked) iconColor = getColor('white');\n if (disabled) iconColor = getColor('neutral', 700);\n\n useEffect(() => {\n setIsChecked(checked);\n }, [checked]);\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLInputElement>): void => {\n if (onChange) {\n onChange(e);\n }\n\n setIsChecked(!isChecked);\n };\n\n const getLabelContent = (): React.ReactNode => {\n return (\n <>\n <input\n id={inputId}\n name={name}\n className={checkboxClasses}\n type=\"checkbox\"\n checked={isChecked}\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n aria-invalid={error}\n required={required}\n onChange={onChangeHandler}\n />\n <span className={checkboxIconWrapperClasses}>\n {isChecked && <Icon color={iconColor} className={checkboxStyles['checkbox__icon']} svgIcon={Check} size={IconSize.XSmall} />}\n </span>\n </>\n );\n };\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Checkbox} className={checkboxWrapperClasses}>\n {renderLabelAsParent({\n label: label,\n children: getLabelContent(),\n inputId: inputId,\n onColor: onColor as FormOnColor,\n labelClassName: checkboxLabelClasses,\n labelTextClassName: labelTextClasses,\n sublabelWrapperClassName: checkboxStyles['checkbox-sublabel-wrapper'],\n large: large,\n afterLabelChildrenClassName: checkboxStyles['checkbox-afterlabelchildren-wrapper'],\n })}\n </div>\n </ErrorWrapper>\n );\n};\n\nexport default Checkbox;\n"],"mappings":";;;;;;;;;;;;;;;AAiDA,MAAaA,YAAoC,UAAS;CACxD,MAAM,EACJ,WACA,UAAU,OACV,UACA,OACA,UAAU,MAAM,EAChB,UAAU,YAAY,SACtB,OAAO,SACP,MACA,WACA,QAAQ,CAAC,CAAC,WACV,aAAa,iBACb,uBACA,QAAQ,aAAa,MAAM,EAC3B,QACA,UACA,UACA,QACE;CACJ,MAAM,CAAC,WAAW,gBAAgB,SAAS,QAAQ;CACnD,MAAM,cAAc,kBAAkB,gBAAgB;CACtD,MAAM,UAAU,YAAY,YAAY;CACxC,MAAM,SAAS,YAAY,YAAY;CACvC,MAAM,cAAc,YAAY,YAAY;CAC5C,MAAM,YAAY,SAAS,YAAY,YAAY;CACnD,MAAM,SAAS,YAAY,YAAY;CACvC,MAAM,QAAQ,SAAS,SAAS;CAChC,MAAM,EAAE,WAAW,cAAc,iBAAmC,mBAAmB,IAAI,GAAG,MAAM,KAAK;CACzG,MAAM,aAAa,UAAU,CAAC,KAAK,UAAU,CAAC;CAE9C,MAAM,yBAAyB,WAAW,eAAe,qBAAqB,GAC3E,eAAe,6BAA6B,OAC9C,CAAC;CACF,MAAM,u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mBAAmB,MAAiD;AACxE,MAAI,SACF,UAAS,EAAE;AAGb,eAAa,CAAC,UAAU;;CAG1B,MAAM,wBAAyC;AAC7C,SACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,SAAA;GACC,IAAI;GACE;GACN,WAAW;GACX,MAAK;GACL,SAAS;GACC;GACH;GACP,KAAK;GACL,oBAAkB,mBAAmB,OAAO,YAAY;GACxD,gBAAc;GACJ;GACV,UAAU;IACV,EACF,oBAAC,QAAA;GAAK,WAAW;aACd,aAAa,oBAAC,cAAA;IAAK,OAAO;IAAW,WAAW,eAAe;IAAmB,SAAS;IAAO,MAAM,SAAS;KAAU;IACvH,CAAA,EAAA,CACN;;AAIP,QACE,oBAAC,sBAAA;EAAa,WAAW;EAAkC;EAAwB;YACjF,oBAAC,OAAA;GAAI,eAAa;GAAQ,oBAAkB,YAAY;GAAU,WAAW;aAC1E,oBAAoB;IACZ;IACP,UAAU,iBAAiB;IAClB;IACA;IACT,gBAAgB;IAChB,oBAAoB;IACpB,0BAA0B,eAAe;IAClC;IACP,6BAA6B,eAAe;IAC7C,CAAC;IACE;GACO;;AAInB,IAAA,mBAAe"}
1
+ {"version":3,"file":"Checkbox.js","names":["Checkbox: React.FC<CheckboxProps>"],"sources":["../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\n\nimport { AnalyticsId, FormOnColor, FormSize, IconSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getColor } from '../../theme/currys/color';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport Icon from '../Icon';\nimport Check from '../Icons/Check';\nimport { getLabelText, renderLabelAsParent } from '../Label/utils';\n\nimport checkboxStyles from './styles.module.scss';\n\nexport interface CheckboxProps\n extends\n ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the checkbox - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** input id of the checkbox */\n inputId?: string;\n /** Changes the visuals of the checkbox */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the checkbox */\n size?: keyof typeof FormSize;\n /** Activates Error style for the checkbox - This is can be true while errorText is empty, when in a FormGroup */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref that is passed to the component */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nexport const Checkbox: React.FC<CheckboxProps> = props => {\n const {\n className,\n checked = false,\n disabled,\n label,\n inputId = uuid(),\n onColor = FormOnColor.onwhite,\n name = inputId,\n size,\n errorText,\n error = !!errorText,\n errorTextId: errorTextIdProp,\n errorWrapperClassName,\n value = getLabelText(label),\n testId,\n required,\n onChange,\n ref,\n } = props;\n const [isChecked, setIsChecked] = useState(checked);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n const onWhite = onColor === FormOnColor.onwhite;\n const onGrey = onColor === FormOnColor.ongrey;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const onInvalid = error || onColor === FormOnColor.oninvalid;\n const onDark = onColor === FormOnColor.ondark;\n const large = size === FormSize.large;\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n\n const checkboxWrapperClasses = classNames(checkboxStyles['checkbox-wrapper'], {\n [checkboxStyles['checkbox-wrapper--large']]: large,\n });\n const checkboxLabelClasses = classNames(checkboxStyles['checkbox-label'], {\n [checkboxStyles['checkbox-label--disabled']]: disabled,\n [checkboxStyles['checkbox-label--on-dark']]: onDark,\n [checkboxStyles['checkbox-label--large']]: large,\n [checkboxStyles['checkbox-label__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__large--focus']]: large && isFocused,\n [checkboxStyles['checkbox-label__large--on-white']]: large && onWhite,\n [checkboxStyles['checkbox-label__large--on-grey']]: large && onGrey,\n [checkboxStyles['checkbox-label__large--on-blueberry']]: large && onBlueberry,\n [checkboxStyles['checkbox-label__large--on-invalid']]: large && onInvalid,\n [checkboxStyles['checkbox-label__large--disabled']]: large && disabled,\n });\n const checkboxClasses = classNames(checkboxStyles.checkbox, className);\n const checkboxIconWrapperClasses = classNames(checkboxStyles['checkbox__icon-wrapper'], {\n [checkboxStyles['checkbox__icon-wrapper--on-white']]: onWhite,\n [checkboxStyles['checkbox__icon-wrapper--on-grey']]: onGrey,\n [checkboxStyles['checkbox__icon-wrapper--on-invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--disabled']]: disabled,\n [checkboxStyles['checkbox__icon-wrapper__regular--checked']]: !large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__regular--invalid']]: !large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__regular--on-dark']]: !large && isChecked && onDark,\n [checkboxStyles['checkbox__icon-wrapper__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--on-dark']]: onDark,\n [checkboxStyles['checkbox__icon-wrapper--on-blueberry']]: onBlueberry,\n [checkboxStyles['checkbox__icon-wrapper--invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--disabled']]: disabled && large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--disabled']]: disabled && large && isChecked,\n });\n const labelTextClasses = classNames(checkboxStyles['checkbox-label__text'], {\n [checkboxStyles['checkbox-label__text__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__text__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox-label__text--on-dark']]: onDark,\n [checkboxStyles['checkbox-label__text--disabled']]: disabled,\n });\n\n let iconColor = getColor('white');\n if (onDark || (large && isChecked)) iconColor = getColor('blueberry', 900);\n if (onInvalid && large && isChecked) iconColor = getColor('white');\n if (disabled) iconColor = getColor('neutral', 700);\n\n useEffect(() => {\n setIsChecked(checked);\n }, [checked]);\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLInputElement>): void => {\n if (onChange) {\n onChange(e);\n }\n\n setIsChecked(!isChecked);\n };\n\n const getLabelContent = (): React.ReactNode => {\n return (\n <>\n <input\n id={inputId}\n name={name}\n className={checkboxClasses}\n type=\"checkbox\"\n checked={isChecked}\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n aria-invalid={error}\n required={required}\n onChange={onChangeHandler}\n />\n <span className={checkboxIconWrapperClasses}>\n {isChecked && <Icon color={iconColor} className={checkboxStyles['checkbox__icon']} svgIcon={Check} size={IconSize.XSmall} />}\n </span>\n </>\n );\n };\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Checkbox} className={checkboxWrapperClasses}>\n {renderLabelAsParent({\n label: label,\n children: getLabelContent(),\n inputId: inputId,\n onColor: onColor as FormOnColor,\n labelClassName: checkboxLabelClasses,\n labelTextClassName: labelTextClasses,\n sublabelWrapperClassName: checkboxStyles['checkbox-sublabel-wrapper'],\n large: large,\n afterLabelChildrenClassName: checkboxStyles['checkbox-afterlabelchildren-wrapper'],\n })}\n </div>\n </ErrorWrapper>\n );\n};\n\nexport default Checkbox;\n"],"mappings":";;;;;;;;;;;;;;;AAiDA,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aAC1E,oBAAoB;IACZ;IACP,UAAU,iBAAiB;IAClB;IACA;IACT,gBAAgB;IAChB,oBAAoB;IACpB,0BAA0B,eAAe;IAClC;IACP,6BAA6B,eAAe;IAC7C,CAAC;IACE;GACO;;AAInB,IAAA,mBAAe"}
package/lib/Close.js CHANGED
@@ -4,7 +4,7 @@ import { n as mergeRefs } from "./refs.js";
4
4
  import { t as Icon_default } from "./Icon.js";
5
5
  import { t as useIsMobileBreakpoint } from "./useIsMobileBreakpoint.js";
6
6
  import { t as X_default } from "./X.js";
7
- import classNames from "classnames";
7
+ import cn from "classnames";
8
8
  import { jsx } from "react/jsx-runtime";
9
9
  import styles from "./components/Close/styles.module.scss";
10
10
  var Close = (props) => {
@@ -15,7 +15,7 @@ var Close = (props) => {
15
15
  if (color === "black") iconColor = "black";
16
16
  else if (color === "plum") iconColor = "var(--core-color-plum-700)";
17
17
  else iconColor = "var(--color-action-graphics-onlight)";
18
- const closeClasses = classNames(styles.close, { [styles["close--small"]]: small }, className);
18
+ const closeClasses = cn(styles.close, { [styles["close--small"]]: small }, className);
19
19
  return /* @__PURE__ */ jsx("button", {
20
20
  ref: mergeRefs([ref, refObject]),
21
21
  "data-testid": testId,
@@ -25,7 +25,7 @@ var Close = (props) => {
25
25
  onClick,
26
26
  type: "button",
27
27
  children: /* @__PURE__ */ jsx("span", {
28
- className: classNames(styles["close__inner-container"], {
28
+ className: cn(styles["close__inner-container"], {
29
29
  [styles["close__inner-container--small"]]: small,
30
30
  [styles["close__inner-container--plum"]]: color == "plum"
31
31
  }),
package/lib/Close.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Close.js","names":["Close: React.FC<CloseProps>"],"sources":["../src/components/Close/Close.tsx","../src/components/Close/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { mergeRefs } from '../../utils/refs';\nimport Icon from '../Icon';\nimport X from '../Icons/X';\n\nimport styles from './styles.module.scss';\n\nexport interface CloseProps {\n /** Keeps the icon small for all screen sizes */\n small?: boolean;\n /** Function is called when user clicks the button */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Sets the aria-label of the button */\n ariaLabel?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Gives color to the svg */\n color?: 'blueberry' | 'black' | 'plum';\n /** Ref that is passed to the component */\n ref?: React.Ref<HTMLButtonElement | null>;\n}\n\nconst Close: React.FC<CloseProps> = props => {\n const { small, testId, ariaLabel = 'Lukk', onClick, className, color = 'blueberry', ref } = props;\n const { refObject, isHovered } = usePseudoClasses();\n\n const iconSize = useIsMobileBreakpoint() || small ? 38 : 48;\n\n let iconColor;\n if (color === 'black') {\n iconColor = 'black';\n } else if (color === 'plum') {\n iconColor = 'var(--core-color-plum-700)';\n } else {\n iconColor = 'var(--color-action-graphics-onlight)';\n }\n\n const closeClasses = classNames(styles.close, { [styles['close--small']]: small }, className);\n\n return (\n <button\n ref={mergeRefs([ref, refObject])}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Close}\n className={closeClasses}\n aria-label={ariaLabel}\n onClick={onClick}\n type=\"button\"\n >\n <span\n className={classNames(styles['close__inner-container'], {\n [styles['close__inner-container--small']]: small,\n [styles['close__inner-container--plum']]: color == 'plum',\n })}\n >\n <Icon svgIcon={X} color={iconColor} size={iconSize} isHovered={isHovered} />\n </span>\n </button>\n );\n};\n\nexport default Close;\n","import Close from './Close';\nexport * from './Close';\nexport default Close;\n"],"mappings":";;;;;;;;;AA4BA,IAAMA,SAA8B,UAAS;CAC3C,MAAM,EAAE,OAAO,QAAQ,YAAY,QAAQ,SAAS,WAAW,QAAQ,aAAa,QAAQ;CAC5F,MAAM,EAAE,WAAW,cAAc,kBAAkB;CAEnD,MAAM,WAAW,uBAAuB,IAAI,QAAQ,KAAK;CAEzD,IAAI;AACJ,KAAI,UAAU,QACZ,aAAY;UACH,UAAU,OACnB,aAAY;KAEZ,aAAY;CAGd,MAAM,eAAe,WAAW,OAAO,OAAO,GAAG,OAAO,kBAAkB,OAAO,EAAE,UAAU;AAE7F,QACE,oBAAC,UAAA;EACC,KAAK,UAAU,CAAC,KAAK,UAAU,CAAC;EAChC,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW;EACX,cAAY;EACH;EACT,MAAK;YAEL,oBAAC,QAAA;GACC,WAAW,WAAW,OAAO,2BAA2B;KACrD,OAAO,mCAAmC;KAC1C,OAAO,kCAAkC,SAAS;IACpD,CAAC;aAEF,oBAAC,cAAA;IAAK,SAAS;IAAG,OAAO;IAAW,MAAM;IAAqB;KAAa;IACvE;GACA;;AC7Db,IAAA,kBDiEe"}
1
+ {"version":3,"file":"Close.js","names":["Close: React.FC<CloseProps>"],"sources":["../src/components/Close/Close.tsx","../src/components/Close/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { mergeRefs } from '../../utils/refs';\nimport Icon from '../Icon';\nimport X from '../Icons/X';\n\nimport styles from './styles.module.scss';\n\nexport interface CloseProps {\n /** Keeps the icon small for all screen sizes */\n small?: boolean;\n /** Function is called when user clicks the button */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Sets the aria-label of the button */\n ariaLabel?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Gives color to the svg */\n color?: 'blueberry' | 'black' | 'plum';\n /** Ref that is passed to the component */\n ref?: React.Ref<HTMLButtonElement | null>;\n}\n\nconst Close: React.FC<CloseProps> = props => {\n const { small, testId, ariaLabel = 'Lukk', onClick, className, color = 'blueberry', ref } = props;\n const { refObject, isHovered } = usePseudoClasses();\n\n const iconSize = useIsMobileBreakpoint() || small ? 38 : 48;\n\n let iconColor;\n if (color === 'black') {\n iconColor = 'black';\n } else if (color === 'plum') {\n iconColor = 'var(--core-color-plum-700)';\n } else {\n iconColor = 'var(--color-action-graphics-onlight)';\n }\n\n const closeClasses = classNames(styles.close, { [styles['close--small']]: small }, className);\n\n return (\n <button\n ref={mergeRefs([ref, refObject])}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Close}\n className={closeClasses}\n aria-label={ariaLabel}\n onClick={onClick}\n type=\"button\"\n >\n <span\n className={classNames(styles['close__inner-container'], {\n [styles['close__inner-container--small']]: small,\n [styles['close__inner-container--plum']]: color == 'plum',\n })}\n >\n <Icon svgIcon={X} color={iconColor} size={iconSize} isHovered={isHovered} />\n </span>\n </button>\n );\n};\n\nexport default Close;\n","import Close from './Close';\nexport * from './Close';\nexport default Close;\n"],"mappings":";;;;;;;;;AA4BA,IAAMA,SAA8B,UAAS;CAC3C,MAAM,EAAE,OAAO,QAAQ,YAAY,QAAQ,SAAS,WAAW,QAAQ,aAAa,QAAQ;CAC5F,MAAM,EAAE,WAAW,cAAc,kBAAkB;CAEnD,MAAM,WAAW,uBAAuB,IAAI,QAAQ,KAAK;CAEzD,IAAI;AACJ,KAAI,UAAU,QACZ,aAAY;UACH,UAAU,OACnB,aAAY;KAEZ,aAAY;CAGd,MAAM,eAAe,GAAW,OAAO,OAAO,GAAG,OAAO,kBAAkB,OAAO,EAAE,UAAU;AAE7F,QACE,oBAAC,UAAA;EACC,KAAK,UAAU,CAAC,KAAK,UAAU,CAAC;EAChC,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW;EACX,cAAY;EACH;EACT,MAAK;YAEL,oBAAC,QAAA;GACC,WAAW,GAAW,OAAO,2BAA2B;KACrD,OAAO,mCAAmC;KAC1C,OAAO,kCAAkC,SAAS;IACpD,CAAC;aAEF,oBAAC,cAAA;IAAK,SAAS;IAAG,OAAO;IAAW,MAAM;IAAqB;KAAa;IACvE;GACA;;AC7Db,IAAA,kBDiEe"}
@@ -1,10 +1,10 @@
1
1
  import { n as AnalyticsId } from "./constants2.js";
2
- import classNames from "classnames";
2
+ import cn from "classnames";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import styles from "./components/DictionaryTrigger/styles.module.scss";
5
5
  var DictionaryTrigger = (props) => {
6
6
  const { children, selected = false, className, testId, ref, ...rest } = props;
7
- const triggerClasses = classNames(styles.dictionarytrigger, className);
7
+ const triggerClasses = cn(styles.dictionarytrigger, className);
8
8
  return /* @__PURE__ */ jsx("button", {
9
9
  type: "button",
10
10
  "data-testid": testId,
@@ -1 +1 @@
1
- {"version":3,"file":"DictionaryTrigger.js","names":["DictionaryTrigger: React.FC<DictionaryTriggerProps>"],"sources":["../src/components/DictionaryTrigger/DictionaryTrigger.tsx","../src/components/DictionaryTrigger/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\n\nimport styles from './styles.module.scss';\n\nexport interface DictionaryTriggerProps extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'onFocus' | 'onBlur'> {\n /**\n * Sets the content of the trigger.\n */\n children: React.ReactNode;\n /**\n * Indicates that the trigger is in use.\n */\n selected?: boolean;\n /**\n * Classname will be applied to the button element.\n */\n className?: string;\n /**\n * Sets the data-testid attribute.\n */\n testId?: string;\n /**\n * ref that is passed to the component\n */\n ref?: React.Ref<HTMLButtonElement | null>;\n}\n\nconst DictionaryTrigger: React.FC<DictionaryTriggerProps> = (props: DictionaryTriggerProps) => {\n const { children, selected = false, className, testId, ref, ...rest } = props;\n const triggerClasses = classNames(styles.dictionarytrigger, className);\n\n return (\n <button\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.DictionaryTrigger}\n className={triggerClasses}\n aria-expanded={selected}\n ref={ref}\n {...rest}\n >\n {children}\n </button>\n );\n};\n\nDictionaryTrigger.displayName = 'DictionaryTrigger';\n\nexport default DictionaryTrigger;\n","import DictionaryTrigger from './DictionaryTrigger';\nexport * from './DictionaryTrigger';\nexport default DictionaryTrigger;\n"],"mappings":";;;;AA6BA,IAAMA,qBAAuD,UAAkC;CAC7F,MAAM,EAAE,UAAU,WAAW,OAAO,WAAW,QAAQ,KAAK,GAAG,SAAS;CACxE,MAAM,iBAAiB,WAAW,OAAO,mBAAmB,UAAU;AAEtE,QACE,oBAAC,UAAA;EACC,MAAK;EACL,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW;EACX,iBAAe;EACV;EACL,GAAI;EAEH;GACM;;AAIb,kBAAkB,cAAc;AC9ChC,IAAA,8BDgDe"}
1
+ {"version":3,"file":"DictionaryTrigger.js","names":["DictionaryTrigger: React.FC<DictionaryTriggerProps>"],"sources":["../src/components/DictionaryTrigger/DictionaryTrigger.tsx","../src/components/DictionaryTrigger/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\n\nimport styles from './styles.module.scss';\n\nexport interface DictionaryTriggerProps extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'onFocus' | 'onBlur'> {\n /**\n * Sets the content of the trigger.\n */\n children: React.ReactNode;\n /**\n * Indicates that the trigger is in use.\n */\n selected?: boolean;\n /**\n * Classname will be applied to the button element.\n */\n className?: string;\n /**\n * Sets the data-testid attribute.\n */\n testId?: string;\n /**\n * ref that is passed to the component\n */\n ref?: React.Ref<HTMLButtonElement | null>;\n}\n\nconst DictionaryTrigger: React.FC<DictionaryTriggerProps> = (props: DictionaryTriggerProps) => {\n const { children, selected = false, className, testId, ref, ...rest } = props;\n const triggerClasses = classNames(styles.dictionarytrigger, className);\n\n return (\n <button\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.DictionaryTrigger}\n className={triggerClasses}\n aria-expanded={selected}\n ref={ref}\n {...rest}\n >\n {children}\n </button>\n );\n};\n\nDictionaryTrigger.displayName = 'DictionaryTrigger';\n\nexport default DictionaryTrigger;\n","import DictionaryTrigger from './DictionaryTrigger';\nexport * from './DictionaryTrigger';\nexport default DictionaryTrigger;\n"],"mappings":";;;;AA6BA,IAAMA,qBAAuD,UAAkC;CAC7F,MAAM,EAAE,UAAU,WAAW,OAAO,WAAW,QAAQ,KAAK,GAAG,SAAS;CACxE,MAAM,iBAAiB,GAAW,OAAO,mBAAmB,UAAU;AAEtE,QACE,oBAAC,UAAA;EACC,MAAK;EACL,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW;EACX,iBAAe;EACV;EACL,GAAI;EAEH;GACM;;AAIb,kBAAkB,cAAc;AC9ChC,IAAA,8BDgDe"}
package/lib/Drawer.js CHANGED
@@ -12,13 +12,19 @@ import { t as Close_default } from "./Close.js";
12
12
  import { t as useReturnFocusOnUnmount } from "./useReturnFocusOnUnmount.js";
13
13
  import { n as enableBodyScroll, t as disableBodyScroll } from "./scroll.js";
14
14
  import { t as Title_default } from "./Title2.js";
15
- import classNames from "classnames";
15
+ import cn from "classnames";
16
16
  import React, { useEffect, useRef } from "react";
17
17
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
18
18
  import { AnimatePresence, useAnimate, usePresence } from "motion/react";
19
19
  import styles from "./components/Drawer/styles.module.scss";
20
- var HN_Designsystem_Drawer_en_GB_default = { ariaLabelCloseBtn: "Close" };
21
- var HN_Designsystem_Drawer_nb_NO_default = { ariaLabelCloseBtn: "Lukk" };
20
+ var HN_Designsystem_Drawer_en_GB_default = {
21
+ ariaLabelCloseBtn: "Close",
22
+ ariaLabelBackButton: "Go back"
23
+ };
24
+ var HN_Designsystem_Drawer_nb_NO_default = {
25
+ ariaLabelCloseBtn: "Lukk",
26
+ ariaLabelBackButton: "Gå tilbake"
27
+ };
22
28
  const getResources = (language) => {
23
29
  switch (language) {
24
30
  case LanguageLocales.ENGLISH: return HN_Designsystem_Drawer_en_GB_default;
@@ -60,7 +66,7 @@ var InnerDrawer = (props) => {
60
66
  ...resources
61
67
  };
62
68
  const contentIsScrollable = contentRef.current && contentRef.current.scrollHeight > contentRef.current.clientHeight;
63
- const headerStyling = classNames(styles.drawer__header, headerClasses);
69
+ const headerStyling = cn(styles.drawer__header, headerClasses);
64
70
  const hasFooterContent = typeof footerContent !== "undefined" && footerContent || onPrimaryAction || onSecondaryAction;
65
71
  useFocusTrap_default(containerRef, true);
66
72
  useReturnFocusOnUnmount(containerRef);
@@ -147,7 +153,7 @@ var InnerDrawer = (props) => {
147
153
  ref: overlayRef,
148
154
  "aria-hidden": "true"
149
155
  }), /* @__PURE__ */ jsxs("div", {
150
- className: classNames(styles.drawer__container, { [styles["drawer__container--right"]]: desktopDirection === "right" }),
156
+ className: cn(styles.drawer__container, { [styles["drawer__container--right"]]: desktopDirection === "right" }),
151
157
  ref: containerRef,
152
158
  role: "dialog",
153
159
  "aria-modal": "true",
@@ -173,7 +179,7 @@ var InnerDrawer = (props) => {
173
179
  })]
174
180
  }),
175
181
  /* @__PURE__ */ jsx("div", {
176
- className: classNames(styles["drawer__content__shadow"], styles["drawer__content__shadow--top"]),
182
+ className: cn(styles["drawer__content__shadow"], styles["drawer__content__shadow--top"]),
177
183
  style: {
178
184
  opacity: !topContentVisible && contentIsScrollable ? 1 : 0,
179
185
  top: headerHeight
@@ -198,7 +204,7 @@ var InnerDrawer = (props) => {
198
204
  ]
199
205
  }),
200
206
  /* @__PURE__ */ jsx("div", {
201
- className: classNames(styles["drawer__content__shadow"], styles["drawer__content__shadow--bottom"]),
207
+ className: cn(styles["drawer__content__shadow"], styles["drawer__content__shadow--bottom"]),
202
208
  style: {
203
209
  opacity: !bottomContentVisible && contentIsScrollable ? 1 : 0,
204
210
  bottom: hasFooterContent ? footerHeight : 0
package/lib/Drawer.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.js","names":["Drawer: React.FC<DrawerProps>","InnerDrawer: React.FC<InnerDrawerProps>","mergedResources: HNDesignsystemDrawer"],"sources":["../src/resources/HN.Designsystem.Drawer.en-GB.json","../src/resources/HN.Designsystem.Drawer.nb-NO.json","../src/components/Drawer/resourceHelper.ts","../src/components/Drawer/Drawer.tsx","../src/components/Drawer/index.ts"],"sourcesContent":["{\n \"ariaLabelCloseBtn\": \"Close\"\n}\n","{\n \"ariaLabelCloseBtn\": \"Lukk\"\n}\n","import type { HNDesignsystemDrawer } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Drawer.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Drawer.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemDrawer => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React, { useEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\nimport { AnimatePresence, useAnimate, usePresence } from 'motion/react';\n\nimport type { HNDesignsystemDrawer } from '../../resources/Resources';\nimport type { TitleTags } from '../Title';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, KeyboardEventKey, LanguageLocales, ZIndex } from '../../constants';\nimport useFocusTrap from '../../hooks/useFocusTrap';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useKeyboardEvent } from '../../hooks/useKeyboardEvent';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { useReturnFocusOnUnmount } from '../../hooks/useReturnFocusOnUnmount';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { disableBodyScroll, enableBodyScroll } from '../../utils/scroll';\nimport uuid from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Title from '../Title';\n\nimport styles from './styles.module.scss';\n\ntype DesktopDirections = 'left' | 'right';\n\nexport interface DrawerProps extends InnerDrawerProps {\n /** Opens and closes the drawer */\n isOpen: boolean;\n}\n\nexport interface InnerDrawerProps {\n /** Sets the aria-label of the drawer */\n ariaLabel?: string;\n /** Sets the aria-labelledby of the drawer */\n ariaLabelledBy?: string;\n /** Sets the style of the Drawer Close button. Meant for use by HelpDrawer */\n closeColor?: 'blueberry' | 'plum';\n /** Direction of the drawer on desktop. Default: left */\n desktopDirection?: DesktopDirections;\n /** Sets the style of the Drawer header */\n headerClasses?: string;\n /** Title to display in the header of the drawer */\n title: string;\n /** id of the drawer title */\n titleId?: string;\n /** Changes the underlying element of the title. Default: h3 */\n titleHtmlMarkup?: TitleTags;\n /** Callback that triggers when clicking on close button or outside the drawer, update isOpen state when this triggers */\n onRequestClose?: () => void;\n /** Optional footer content that can be rendered instead of default CTA(s) */\n footerContent?: React.ReactNode;\n /** Main content of the drawer */\n children?: React.ReactNode;\n /** Hides the close button */\n noCloseButton?: boolean;\n /** Primary CTA callback */\n onPrimaryAction?: () => void;\n /** Text for primary CTA button if you want a default CTA button rendered (instead of `footerContent`) */\n primaryActionText?: string;\n /** Text for secondary CTA button if you want a default CTA button rendered (instead of `footerContent`) */\n secondaryActionText?: string;\n /** Secondary CTA callback */\n onSecondaryAction?: () => void;\n /** Customize the z-index of the drawer */\n zIndex?: number;\n /** Resources for component */\n resources?: Partial<HNDesignsystemDrawer>;\n /** Sets mobile styling and animation from outer level Drawer */\n isMobile?: boolean;\n}\n\nconst Drawer: React.FC<DrawerProps> = props => {\n const { isOpen, ...rest } = props;\n const isMobile = useIsMobileBreakpoint();\n\n return <AnimatePresence>{isOpen && <InnerDrawer {...rest} isMobile={isMobile} />}</AnimatePresence>;\n};\n\nconst InnerDrawer: React.FC<InnerDrawerProps> = props => {\n const {\n ariaLabel,\n ariaLabelledBy,\n children,\n closeColor = 'blueberry',\n desktopDirection = 'left',\n footerContent,\n headerClasses,\n noCloseButton = false,\n onPrimaryAction,\n onRequestClose,\n onSecondaryAction,\n primaryActionText,\n secondaryActionText,\n title,\n titleHtmlMarkup = 'h3',\n titleId = uuid(),\n zIndex = ZIndex.OverlayScreen,\n resources,\n isMobile,\n } = props;\n\n const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledBy, fallbackId: titleId });\n const overlayRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n // topContent and bottomContent are used to detect scroll position for shadow effects\n const topContent = useRef<HTMLDivElement>(null);\n const bottomContent = useRef<HTMLDivElement>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n const footerRef = useRef<HTMLDivElement>(null);\n const [scope, animate] = useAnimate();\n const [isPresent, safeToRemove] = usePresence();\n const [headerHeight, setHeaderHeight] = React.useState(0);\n const [footerHeight, setFooterHeight] = React.useState(0);\n const topContentVisible = useIsVisible(topContent);\n const bottomContentVisible = useIsVisible(bottomContent, 0);\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemDrawer = {\n ...defaultResources,\n ...resources,\n };\n\n const contentIsScrollable = contentRef.current && contentRef.current.scrollHeight > contentRef.current.clientHeight;\n const headerStyling = classNames(styles.drawer__header, headerClasses);\n const hasFooterContent = (typeof footerContent !== 'undefined' && footerContent) || onPrimaryAction || onSecondaryAction;\n\n useFocusTrap(containerRef, true);\n useReturnFocusOnUnmount(containerRef);\n useOutsideEvent(containerRef, () => {\n if (onRequestClose) onRequestClose();\n });\n useKeyboardEvent(containerRef, () => onRequestClose && onRequestClose(), [KeyboardEventKey.Escape]);\n\n // Close animasjon, vi kaller `onClose()` til slutt\n const closeDrawer = (): void => {\n if (!overlayRef.current || !containerRef.current) return;\n\n animate(overlayRef.current, { opacity: 0, pointerEvents: 'none' }, { duration: 0.3, ease: 'easeInOut' });\n\n if (isMobile) {\n animate(\n containerRef.current,\n { y: '100%' },\n {\n duration: 0.3,\n ease: 'easeInOut',\n onComplete: () => {\n if (safeToRemove) safeToRemove();\n },\n }\n );\n } else {\n animate(\n containerRef.current,\n { x: desktopDirection === 'left' ? '-100%' : '100%' },\n {\n duration: 0.3,\n ease: 'easeInOut',\n onComplete: () => {\n if (safeToRemove) safeToRemove();\n },\n }\n );\n }\n };\n\n useEffect(() => {\n containerRef.current?.focus();\n disableBodyScroll();\n\n return (): void => {\n enableBodyScroll();\n };\n }, []);\n\n // Measure header and footer heights\n useEffect(() => {\n const updateHeights = (): void => {\n if (headerRef.current) {\n setHeaderHeight(headerRef.current.offsetHeight);\n }\n if (footerRef.current) {\n setFooterHeight(footerRef.current.offsetHeight);\n }\n };\n\n updateHeights();\n\n // Update heights when content changes\n const resizeObserver = new ResizeObserver(updateHeights);\n if (headerRef.current) {\n resizeObserver.observe(headerRef.current);\n }\n if (footerRef.current) {\n resizeObserver.observe(footerRef.current);\n }\n\n return (): void => {\n resizeObserver.disconnect();\n };\n }, [hasFooterContent]);\n\n // Open animation.\n useEffect(() => {\n if (!overlayRef.current || !containerRef.current) return;\n\n if (!isPresent) {\n closeDrawer();\n return;\n }\n\n if (isMobile) {\n animate(containerRef.current, { y: '0' }, { duration: 0.3, ease: 'easeInOut' });\n } else {\n animate(containerRef.current, { x: '0' }, { duration: 0.3, ease: 'easeInOut' });\n }\n\n animate(overlayRef.current, { opacity: 1, pointerEvents: 'auto' }, { duration: 0.3, ease: 'easeInOut' });\n }, [isPresent]);\n\n const handleCTA = (callback?: () => void): void => {\n if (callback) {\n callback();\n }\n };\n\n return (\n <div className={styles.drawer} ref={scope} style={{ zIndex }} data-analyticsid={AnalyticsId.Drawer}>\n <div className={styles.drawer__overlay} ref={overlayRef} aria-hidden=\"true\" />\n <div\n className={classNames(styles.drawer__container, {\n [styles['drawer__container--right']]: desktopDirection === 'right',\n })}\n ref={containerRef}\n role=\"dialog\"\n aria-modal=\"true\"\n tabIndex={-1}\n {...ariaLabelAttributes}\n >\n <div className={styles.drawer__container__inner}>\n <div className={headerStyling} ref={headerRef}>\n <Title\n id={ariaLabelAttributes?.['aria-labelledby']}\n className={styles['drawer__header__title']}\n htmlMarkup={titleHtmlMarkup}\n appearance=\"title3\"\n >\n {title}\n </Title>\n {!noCloseButton && onRequestClose != undefined && (\n <Close\n ariaLabel={mergedResources.ariaLabelCloseBtn}\n color={closeColor}\n onClick={onRequestClose}\n className={styles['drawer__header__close-button']}\n />\n )}\n </div>\n <div\n className={classNames(styles['drawer__content__shadow'], styles['drawer__content__shadow--top'])}\n style={{\n opacity: !topContentVisible && contentIsScrollable ? 1 : 0,\n top: headerHeight,\n }}\n />\n <div\n className={styles.drawer__content}\n tabIndex={contentIsScrollable ? 0 : undefined}\n role={contentIsScrollable ? 'region' : undefined}\n {...(contentIsScrollable ? ariaLabelAttributes : {})}\n ref={contentRef}\n >\n <div ref={topContent} />\n <div className={styles['drawer__content__children']}>{children}</div>\n <div ref={bottomContent} style={{ height: '1px' }} />\n </div>\n <div\n className={classNames(styles['drawer__content__shadow'], styles['drawer__content__shadow--bottom'])}\n style={{\n opacity: !bottomContentVisible && contentIsScrollable ? 1 : 0,\n bottom: hasFooterContent ? footerHeight : 0,\n }}\n />\n </div>\n {hasFooterContent && (\n <div className={styles.drawer__footer} ref={footerRef}>\n {footerContent ? (\n footerContent\n ) : (\n <>\n {onPrimaryAction && <Button onClick={() => handleCTA(onPrimaryAction)}>{primaryActionText}</Button>}\n {onSecondaryAction && (\n <Button variant=\"borderless\" onClick={() => handleCTA(onSecondaryAction)}>\n {secondaryActionText}\n </Button>\n )}\n </>\n )}\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default Drawer;\n","import Drawer from './Drawer';\nexport * from './Drawer';\nexport default Drawer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AEMA,MAAa,gBAAgB,aAAoD;AAC/E,SAAQ,UAAR;EACE,KAAK,gBAAgB,QACnB,QAAO;EACT,KAAK,gBAAgB;EACrB,QACE,QAAO;;;AC8Db,IAAMA,UAAgC,UAAS;CAC7C,MAAM,EAAE,QAAQ,GAAG,SAAS;CAC5B,MAAM,WAAW,uBAAuB;AAExC,QAAO,oBAAC,iBAAA,EAAA,UAAiB,UAAU,oBAAC,aAAA;EAAY,GAAI;EAAgB;GAAY,EAA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AAW,WAAW,OAAO,4BAA4B,OAAO,mCAAmC;MACnG,OAAO;OACL,SAAS,CAAC,wBAAwB,sBAAsB,IAAI;OAC5D,QAAQ,mBAAmB,eAAe;OAC3C;OACD;;KACE,EACL,oBACC,oBAAC,OAAA;IAAI,WAAW,OAAO;IAAgB,KAAK;cACzC,gBACC,gBAEA,qBAAA,UAAA,EAAA,UAAA,CACG,mBAAmB,oBAAC,gBAAA;KAAO,eAAe,UAAU,gBAAgB;eAAG;MAA2B,EAClG,qBACC,oBAAC,gBAAA;KAAO,SAAQ;KAAa,eAAe,UAAU,kBAAkB;eACrE;MACM,CAAA,EAAA,CAEV;KAED,CAAA;IAEJ,CAAA;GACF;;AChTV,IAAA,mBDoTe"}
1
+ {"version":3,"file":"Drawer.js","names":["Drawer: React.FC<DrawerProps>","InnerDrawer: React.FC<InnerDrawerProps>","mergedResources: HNDesignsystemDrawer"],"sources":["../src/resources/HN.Designsystem.Drawer.en-GB.json","../src/resources/HN.Designsystem.Drawer.nb-NO.json","../src/components/Drawer/resourceHelper.ts","../src/components/Drawer/Drawer.tsx","../src/components/Drawer/index.ts"],"sourcesContent":["{\n \"ariaLabelCloseBtn\": \"Close\",\n \"ariaLabelBackButton\": \"Go back\"\n}\n","{\n \"ariaLabelCloseBtn\": \"Lukk\",\n \"ariaLabelBackButton\": \"Gå tilbake\"\n}\n","import type { HNDesignsystemDrawer } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Drawer.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Drawer.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemDrawer => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React, { useEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\nimport { AnimatePresence, useAnimate, usePresence } from 'motion/react';\n\nimport type { HNDesignsystemDrawer } from '../../resources/Resources';\nimport type { TitleTags } from '../Title';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, KeyboardEventKey, LanguageLocales, ZIndex } from '../../constants';\nimport useFocusTrap from '../../hooks/useFocusTrap';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useKeyboardEvent } from '../../hooks/useKeyboardEvent';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { useReturnFocusOnUnmount } from '../../hooks/useReturnFocusOnUnmount';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { disableBodyScroll, enableBodyScroll } from '../../utils/scroll';\nimport uuid from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Title from '../Title';\n\nimport styles from './styles.module.scss';\n\ntype DesktopDirections = 'left' | 'right';\n\nexport interface DrawerProps extends InnerDrawerProps {\n /** Opens and closes the drawer */\n isOpen: boolean;\n}\n\nexport interface InnerDrawerProps {\n /** Sets the aria-label of the drawer */\n ariaLabel?: string;\n /** Sets the aria-labelledby of the drawer */\n ariaLabelledBy?: string;\n /** Sets the style of the Drawer Close button. Meant for use by HelpDrawer */\n closeColor?: 'blueberry' | 'plum';\n /** Direction of the drawer on desktop. Default: left */\n desktopDirection?: DesktopDirections;\n /** Sets the style of the Drawer header */\n headerClasses?: string;\n /** Title to display in the header of the drawer */\n title: string;\n /** id of the drawer title */\n titleId?: string;\n /** Changes the underlying element of the title. Default: h3 */\n titleHtmlMarkup?: TitleTags;\n /** Callback that triggers when clicking on close button or outside the drawer, update isOpen state when this triggers */\n onRequestClose?: () => void;\n /** Optional footer content that can be rendered instead of default CTA(s) */\n footerContent?: React.ReactNode;\n /** Main content of the drawer */\n children?: React.ReactNode;\n /** Hides the close button */\n noCloseButton?: boolean;\n /** Primary CTA callback */\n onPrimaryAction?: () => void;\n /** Text for primary CTA button if you want a default CTA button rendered (instead of `footerContent`) */\n primaryActionText?: string;\n /** Text for secondary CTA button if you want a default CTA button rendered (instead of `footerContent`) */\n secondaryActionText?: string;\n /** Secondary CTA callback */\n onSecondaryAction?: () => void;\n /** Customize the z-index of the drawer */\n zIndex?: number;\n /** Resources for component */\n resources?: Partial<HNDesignsystemDrawer>;\n /** Sets mobile styling and animation from outer level Drawer */\n isMobile?: boolean;\n}\n\nconst Drawer: React.FC<DrawerProps> = props => {\n const { isOpen, ...rest } = props;\n const isMobile = useIsMobileBreakpoint();\n\n return <AnimatePresence>{isOpen && <InnerDrawer {...rest} isMobile={isMobile} />}</AnimatePresence>;\n};\n\nconst InnerDrawer: React.FC<InnerDrawerProps> = props => {\n const {\n ariaLabel,\n ariaLabelledBy,\n children,\n closeColor = 'blueberry',\n desktopDirection = 'left',\n footerContent,\n headerClasses,\n noCloseButton = false,\n onPrimaryAction,\n onRequestClose,\n onSecondaryAction,\n primaryActionText,\n secondaryActionText,\n title,\n titleHtmlMarkup = 'h3',\n titleId = uuid(),\n zIndex = ZIndex.OverlayScreen,\n resources,\n isMobile,\n } = props;\n\n const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledBy, fallbackId: titleId });\n const overlayRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n // topContent and bottomContent are used to detect scroll position for shadow effects\n const topContent = useRef<HTMLDivElement>(null);\n const bottomContent = useRef<HTMLDivElement>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n const footerRef = useRef<HTMLDivElement>(null);\n const [scope, animate] = useAnimate();\n const [isPresent, safeToRemove] = usePresence();\n const [headerHeight, setHeaderHeight] = React.useState(0);\n const [footerHeight, setFooterHeight] = React.useState(0);\n const topContentVisible = useIsVisible(topContent);\n const bottomContentVisible = useIsVisible(bottomContent, 0);\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemDrawer = {\n ...defaultResources,\n ...resources,\n };\n\n const contentIsScrollable = contentRef.current && contentRef.current.scrollHeight > contentRef.current.clientHeight;\n const headerStyling = classNames(styles.drawer__header, headerClasses);\n const hasFooterContent = (typeof footerContent !== 'undefined' && footerContent) || onPrimaryAction || onSecondaryAction;\n\n useFocusTrap(containerRef, true);\n useReturnFocusOnUnmount(containerRef);\n useOutsideEvent(containerRef, () => {\n if (onRequestClose) onRequestClose();\n });\n useKeyboardEvent(containerRef, () => onRequestClose && onRequestClose(), [KeyboardEventKey.Escape]);\n\n // Close animasjon, vi kaller `onClose()` til slutt\n const closeDrawer = (): void => {\n if (!overlayRef.current || !containerRef.current) return;\n\n animate(overlayRef.current, { opacity: 0, pointerEvents: 'none' }, { duration: 0.3, ease: 'easeInOut' });\n\n if (isMobile) {\n animate(\n containerRef.current,\n { y: '100%' },\n {\n duration: 0.3,\n ease: 'easeInOut',\n onComplete: () => {\n if (safeToRemove) safeToRemove();\n },\n }\n );\n } else {\n animate(\n containerRef.current,\n { x: desktopDirection === 'left' ? '-100%' : '100%' },\n {\n duration: 0.3,\n ease: 'easeInOut',\n onComplete: () => {\n if (safeToRemove) safeToRemove();\n },\n }\n );\n }\n };\n\n useEffect(() => {\n containerRef.current?.focus();\n disableBodyScroll();\n\n return (): void => {\n enableBodyScroll();\n };\n }, []);\n\n // Measure header and footer heights\n useEffect(() => {\n const updateHeights = (): void => {\n if (headerRef.current) {\n setHeaderHeight(headerRef.current.offsetHeight);\n }\n if (footerRef.current) {\n setFooterHeight(footerRef.current.offsetHeight);\n }\n };\n\n updateHeights();\n\n // Update heights when content changes\n const resizeObserver = new ResizeObserver(updateHeights);\n if (headerRef.current) {\n resizeObserver.observe(headerRef.current);\n }\n if (footerRef.current) {\n resizeObserver.observe(footerRef.current);\n }\n\n return (): void => {\n resizeObserver.disconnect();\n };\n }, [hasFooterContent]);\n\n // Open animation.\n useEffect(() => {\n if (!overlayRef.current || !containerRef.current) return;\n\n if (!isPresent) {\n closeDrawer();\n return;\n }\n\n if (isMobile) {\n animate(containerRef.current, { y: '0' }, { duration: 0.3, ease: 'easeInOut' });\n } else {\n animate(containerRef.current, { x: '0' }, { duration: 0.3, ease: 'easeInOut' });\n }\n\n animate(overlayRef.current, { opacity: 1, pointerEvents: 'auto' }, { duration: 0.3, ease: 'easeInOut' });\n }, [isPresent]);\n\n const handleCTA = (callback?: () => void): void => {\n if (callback) {\n callback();\n }\n };\n\n return (\n <div className={styles.drawer} ref={scope} style={{ zIndex }} data-analyticsid={AnalyticsId.Drawer}>\n <div className={styles.drawer__overlay} ref={overlayRef} aria-hidden=\"true\" />\n <div\n className={classNames(styles.drawer__container, {\n [styles['drawer__container--right']]: desktopDirection === 'right',\n })}\n ref={containerRef}\n role=\"dialog\"\n aria-modal=\"true\"\n tabIndex={-1}\n {...ariaLabelAttributes}\n >\n <div className={styles.drawer__container__inner}>\n <div className={headerStyling} ref={headerRef}>\n <Title\n id={ariaLabelAttributes?.['aria-labelledby']}\n className={styles['drawer__header__title']}\n htmlMarkup={titleHtmlMarkup}\n appearance=\"title3\"\n >\n {title}\n </Title>\n {!noCloseButton && onRequestClose != undefined && (\n <Close\n ariaLabel={mergedResources.ariaLabelCloseBtn}\n color={closeColor}\n onClick={onRequestClose}\n className={styles['drawer__header__close-button']}\n />\n )}\n </div>\n <div\n className={classNames(styles['drawer__content__shadow'], styles['drawer__content__shadow--top'])}\n style={{\n opacity: !topContentVisible && contentIsScrollable ? 1 : 0,\n top: headerHeight,\n }}\n />\n <div\n className={styles.drawer__content}\n tabIndex={contentIsScrollable ? 0 : undefined}\n role={contentIsScrollable ? 'region' : undefined}\n {...(contentIsScrollable ? ariaLabelAttributes : {})}\n ref={contentRef}\n >\n <div ref={topContent} />\n <div className={styles['drawer__content__children']}>{children}</div>\n <div ref={bottomContent} style={{ height: '1px' }} />\n </div>\n <div\n className={classNames(styles['drawer__content__shadow'], styles['drawer__content__shadow--bottom'])}\n style={{\n opacity: !bottomContentVisible && contentIsScrollable ? 1 : 0,\n bottom: hasFooterContent ? footerHeight : 0,\n }}\n />\n </div>\n {hasFooterContent && (\n <div className={styles.drawer__footer} ref={footerRef}>\n {footerContent ? (\n footerContent\n ) : (\n <>\n {onPrimaryAction && <Button onClick={() => handleCTA(onPrimaryAction)}>{primaryActionText}</Button>}\n {onSecondaryAction && (\n <Button variant=\"borderless\" onClick={() => handleCTA(onSecondaryAction)}>\n {secondaryActionText}\n </Button>\n )}\n </>\n )}\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default Drawer;\n","import Drawer from './Drawer';\nexport * from './Drawer';\nexport default Drawer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AEMA,MAAa,gBAAgB,aAAoD;AAC/E,SAAQ,UAAR;EACE,KAAK,gBAAgB,QACnB,QAAO;EACT,KAAK,gBAAgB;EACrB,QACE,QAAO;;;AC8Db,IAAMA,UAAgC,UAAS;CAC7C,MAAM,EAAE,QAAQ,GAAG,SAAS;CAC5B,MAAM,WAAW,uBAAuB;AAExC,QAAO,oBAAC,iBAAA,EAAA,UAAiB,UAAU,oBAAC,aAAA;EAAY,GAAI;EAAgB;GAAY,EAAA,CAAmB;;AAGrG,IAAMC,eAA0C,UAAS;CACvD,MAAM,EACJ,WACA,gBACA,UACA,aAAa,aACb,mBAAmB,QACnB,eACA,eACA,gBAAgB,OAChB,iBACA,gBACA,mBACA,mBACA,qBACA,OACA,kBAAkB,MAClB,UAAU,cAAM,EAChB,SAAS,OAAO,eAChB,WACA,aACE;CAEJ,MAAM,sBAAsB,uBAAuB;EAAE,OAAO;EAAW,IAAI;EAAgB,YAAY;EAAS,CAAC;CACjH,MAAM,aAAa,OAAuB,KAAK;CAC/C,MAAM,eAAe,OAAuB,KAAK;CACjD,MAAM,aAAa,OAAuB,KAAK;CAE/C,MAAM,aAAa,OAAuB,KAAK;CAC/C,MAAM,gBAAgB,OAAuB,KAAK;CAClD,MAAM,YAAY,OAAuB,KAAK;CAC9C,MAAM,YA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nalyticsId } from "./constants2.js";
2
2
  import { n as useBreakpoint, t as Breakpoint } from "./useBreakpoint.js";
3
3
  import { t as Spacer_default } from "./Spacer.js";
4
- import classNames from "classnames";
4
+ import cn from "classnames";
5
5
  import React from "react";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  import duolistStyles from "./components/Duolist/styles.module.scss";
@@ -10,11 +10,11 @@ const DuolistGroup = (props) => {
10
10
  const firstBold = boldColumn === "first";
11
11
  const secondBold = boldColumn === "second";
12
12
  const nonFormatted = format === "non-formatted";
13
- const dtClassNames = classNames(duolistStyles["duolist__dt"], {
13
+ const dtClassNames = cn(duolistStyles["duolist__dt"], {
14
14
  [duolistStyles["duolist__dt--bold"]]: firstBold,
15
15
  [duolistStyles["duolist__dt--non-formatted"]]: nonFormatted
16
16
  });
17
- const ddClassNames = classNames(duolistStyles["duolist__dd"], {
17
+ const ddClassNames = cn(duolistStyles["duolist__dd"], {
18
18
  [duolistStyles["duolist__dd--bold"]]: secondBold,
19
19
  [duolistStyles["duolist__dd--non-formatted"]]: nonFormatted
20
20
  });
@@ -40,11 +40,11 @@ const Duolist = (props) => {
40
40
  const nonFormatted = format === "non-formatted";
41
41
  const breakpoint = useBreakpoint();
42
42
  const useCollapsedMode = useCollapsedFromAndBelowBreakpoint && breakpoint <= Breakpoint[useCollapsedFromAndBelowBreakpoint];
43
- const duolistWrapperClasses = classNames({
43
+ const duolistWrapperClasses = cn({
44
44
  [duolistStyles["duolist-wrapper--border"]]: hasBorder,
45
45
  [duolistStyles["duolist-wrapper--extra-padding-top"]]: extraPaddingTop
46
46
  }, className);
47
- const duolistClasses = classNames(duolistStyles.duolist, {
47
+ const duolistClasses = cn(duolistStyles.duolist, {
48
48
  [duolistStyles["duolist--line"]]: hasLines,
49
49
  [duolistStyles["duolist--non-formatted"]]: nonFormatted,
50
50
  [duolistStyles["duolist--collapsed"]]: useCollapsedMode,
@@ -1 +1 @@
1
- {"version":3,"file":"Duolist.js","names":["DuolistGroup: React.FC<DuolistGroupProps>","Duolist: React.FC<DuolistProps>"],"sources":["../src/components/Duolist/Duolist.tsx","../src/components/Duolist/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { TitleProps } from '../Title';\n\nimport { AnalyticsId } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport Spacer from '../Spacer';\n\nimport duolistStyles from './styles.module.scss';\n\nexport type DuolistVariants = 'normal' | 'line';\nexport type BoldColumn = 'first' | 'second' | 'none';\nexport type Border = 'no-border' | 'border';\nexport type Formats = 'formatted' | 'non-formatted';\n\nexport interface DuolistProps {\n /** Determines which column is bold */\n boldColumn?: BoldColumn;\n /** Label of the Duolist */\n border?: Border;\n /** Label of the Duolist */\n label?: React.ReactElement<TitleProps>;\n /** Formatted or non-formatted visual variants */\n format?: Formats;\n /** Character separator for non-formatted format */\n separator?: string;\n /** Sets the visual variant of the Duolist. */\n variant?: DuolistVariants;\n /** Sets the content of the Duolist. */\n children: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Width of the description column in percentage */\n descriptionWidth?: number;\n /** Use collapsed mode on columns from chosen breakpoint and below. */\n useCollapsedFromAndBelowBreakpoint?: keyof typeof Breakpoint;\n}\n\nexport interface DuolistGroupProps {\n /** Determines which column is bold */\n boldColumn?: BoldColumn;\n /** Sets content of the <dd> tag. */\n description: React.ReactNode;\n /** Formatted or non-formatted visual variants */\n format?: Formats;\n /** Character separator for non-formatted format */\n separator?: string;\n /** Sets content of the <dt> tag. */\n term: React.ReactNode;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const DuolistGroup: React.FC<DuolistGroupProps> = props => {\n const { format = 'formatted', boldColumn = format === 'non-formatted' ? 'none' : 'first', description, separator = ': ', term } = props;\n\n const firstBold = boldColumn === 'first';\n const secondBold = boldColumn === 'second';\n const nonFormatted = format === 'non-formatted';\n\n const dtClassNames = classNames(duolistStyles['duolist__dt'], {\n [duolistStyles['duolist__dt--bold']]: firstBold,\n [duolistStyles['duolist__dt--non-formatted']]: nonFormatted,\n });\n const ddClassNames = classNames(duolistStyles['duolist__dd'], {\n [duolistStyles['duolist__dd--bold']]: secondBold,\n [duolistStyles['duolist__dd--non-formatted']]: nonFormatted,\n });\n\n const renderContent = () => {\n return (\n <>\n <dt\n data-separator={nonFormatted ? separator : undefined}\n className={dtClassNames}\n data-testid={props.testId && `${props.testId}-term`}\n >\n {term}\n </dt>\n <dd className={ddClassNames} data-testid={props.testId && `${props.testId}-description`}>\n {description}\n </dd>\n </>\n );\n };\n\n return nonFormatted ? <div>{renderContent()}</div> : <>{renderContent()}</>;\n};\n\nexport const Duolist: React.FC<DuolistProps> = props => {\n const {\n boldColumn,\n border = 'no-border',\n descriptionWidth,\n label,\n format = 'formatted',\n separator,\n variant = 'normal',\n children,\n className,\n testId,\n useCollapsedFromAndBelowBreakpoint,\n } = props;\n\n const hasBorder = border === 'border';\n const hasLines = variant === 'line';\n const extraPaddingTop = hasBorder && (label || hasLines);\n const nonFormatted = format === 'non-formatted';\n const breakpoint = useBreakpoint();\n const useCollapsedMode = useCollapsedFromAndBelowBreakpoint && breakpoint <= Breakpoint[useCollapsedFromAndBelowBreakpoint];\n\n const duolistWrapperClasses = classNames(\n {\n [duolistStyles['duolist-wrapper--border']]: hasBorder,\n [duolistStyles['duolist-wrapper--extra-padding-top']]: extraPaddingTop,\n },\n className\n );\n\n const duolistClasses = classNames(duolistStyles.duolist, {\n [duolistStyles['duolist--line']]: hasLines,\n [duolistStyles['duolist--non-formatted']]: nonFormatted,\n [duolistStyles['duolist--collapsed']]: useCollapsedMode,\n [duolistStyles['duolist--not-collapsed']]: !useCollapsedMode,\n });\n\n const duolistColumnStyle = descriptionWidth ? descriptionWidth + '%' : 'minmax(60%, 1fr)';\n\n return (\n <div className={duolistWrapperClasses} data-testid={testId} data-analyticsid={AnalyticsId.Duolist}>\n {label && (\n <>\n {label}\n <Spacer />\n </>\n )}\n <dl\n style={!nonFormatted ? { gridTemplateColumns: useCollapsedMode ? `1fr` : `auto ${duolistColumnStyle}` } : undefined}\n className={duolistClasses}\n >\n {React.Children.map(children, (child: React.ReactNode | React.ReactElement<DuolistGroupProps>) => {\n if (child === null || typeof child === 'undefined') return;\n const duolistGroup = child as React.ReactElement<DuolistGroupProps>;\n if (duolistGroup.type === DuolistGroup) {\n return React.cloneElement(child as React.ReactElement<DuolistGroupProps>, {\n ...duolistGroup.props,\n boldColumn: duolistGroup.props.boldColumn ?? boldColumn,\n format: duolistGroup.props.format ?? format,\n separator: duolistGroup.props.separator ?? separator,\n });\n }\n })}\n </dl>\n </div>\n );\n};\n\nexport default Duolist;\n","import Duolist from './Duolist';\nexport * from './Duolist';\nexport default Duolist;\n"],"mappings":";;;;;;;AAyDA,MAAaA,gBAA4C,UAAS;CAChE,MAAM,EAAE,SAAS,aAAa,aAAa,WAAW,kBAAkB,SAAS,SAAS,aAAa,YAAY,MAAM,SAAS;CAElI,MAAM,YAAY,eAAe;CACjC,MAAM,aAAa,eAAe;CAClC,MAAM,eAAe,WAAW;CAEhC,MAAM,eAAe,WAAW,cAAc,gBAAgB;GAC3D,cAAc,uBAAuB;GACrC,cAAc,gCAAgC;EAChD,CAAC;CACF,MAAM,eAAe,WAAW,cAAc,gBAAgB;GAC3D,cAAc,uBAAuB;GACrC,cAAc,gCAAgC;EAChD,CAAC;CAEF,MAAM,sBAAsB;AAC1B,SACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,MAAA;GACC,kBAAgB,eAAe,YAAY,KAAA;GAC3C,WAAW;GACX,eAAa,MAAM,UAAU,GAAG,MAAM,OAAO;aAE5C;IACE,EACL,oBAAC,MAAA;GAAG,WAAW;GAAc,eAAa,MAAM,UAAU,GAAG,MAAM,OAAO;aACvE;IACE,CAAA,EAAA,CACJ;;AAIP,QAAO,eAAe,oBAAC,OAAA,EAAA,UAAK,eAAe,EAAA,CAAO,GAAG,oBAAA,UA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up: React.FC<DuolistGroupProps>","Duolist: React.FC<DuolistProps>"],"sources":["../src/components/Duolist/Duolist.tsx","../src/components/Duolist/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { TitleProps } from '../Title';\n\nimport { AnalyticsId } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport Spacer from '../Spacer';\n\nimport duolistStyles from './styles.module.scss';\n\nexport type DuolistVariants = 'normal' | 'line';\nexport type BoldColumn = 'first' | 'second' | 'none';\nexport type Border = 'no-border' | 'border';\nexport type Formats = 'formatted' | 'non-formatted';\n\nexport interface DuolistProps {\n /** Determines which column is bold */\n boldColumn?: BoldColumn;\n /** Label of the Duolist */\n border?: Border;\n /** Label of the Duolist */\n label?: React.ReactElement<TitleProps>;\n /** Formatted or non-formatted visual variants */\n format?: Formats;\n /** Character separator for non-formatted format */\n separator?: string;\n /** Sets the visual variant of the Duolist. */\n variant?: DuolistVariants;\n /** Sets the content of the Duolist. */\n children: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Width of the description column in percentage */\n descriptionWidth?: number;\n /** Use collapsed mode on columns from chosen breakpoint and below. */\n useCollapsedFromAndBelowBreakpoint?: keyof typeof Breakpoint;\n}\n\nexport interface DuolistGroupProps {\n /** Determines which column is bold */\n boldColumn?: BoldColumn;\n /** Sets content of the <dd> tag. */\n description: React.ReactNode;\n /** Formatted or non-formatted visual variants */\n format?: Formats;\n /** Character separator for non-formatted format */\n separator?: string;\n /** Sets content of the <dt> tag. */\n term: React.ReactNode;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const DuolistGroup: React.FC<DuolistGroupProps> = props => {\n const { format = 'formatted', boldColumn = format === 'non-formatted' ? 'none' : 'first', description, separator = ': ', term } = props;\n\n const firstBold = boldColumn === 'first';\n const secondBold = boldColumn === 'second';\n const nonFormatted = format === 'non-formatted';\n\n const dtClassNames = classNames(duolistStyles['duolist__dt'], {\n [duolistStyles['duolist__dt--bold']]: firstBold,\n [duolistStyles['duolist__dt--non-formatted']]: nonFormatted,\n });\n const ddClassNames = classNames(duolistStyles['duolist__dd'], {\n [duolistStyles['duolist__dd--bold']]: secondBold,\n [duolistStyles['duolist__dd--non-formatted']]: nonFormatted,\n });\n\n const renderContent = () => {\n return (\n <>\n <dt\n data-separator={nonFormatted ? separator : undefined}\n className={dtClassNames}\n data-testid={props.testId && `${props.testId}-term`}\n >\n {term}\n </dt>\n <dd className={ddClassNames} data-testid={props.testId && `${props.testId}-description`}>\n {description}\n </dd>\n </>\n );\n };\n\n return nonFormatted ? <div>{renderContent()}</div> : <>{renderContent()}</>;\n};\n\nexport const Duolist: React.FC<DuolistProps> = props => {\n const {\n boldColumn,\n border = 'no-border',\n descriptionWidth,\n label,\n format = 'formatted',\n separator,\n variant = 'normal',\n children,\n className,\n testId,\n useCollapsedFromAndBelowBreakpoint,\n } = props;\n\n const hasBorder = border === 'border';\n const hasLines = variant === 'line';\n const extraPaddingTop = hasBorder && (label || hasLines);\n const nonFormatted = format === 'non-formatted';\n const breakpoint = useBreakpoint();\n const useCollapsedMode = useCollapsedFromAndBelowBreakpoint && breakpoint <= Breakpoint[useCollapsedFromAndBelowBreakpoint];\n\n const duolistWrapperClasses = classNames(\n {\n [duolistStyles['duolist-wrapper--border']]: hasBorder,\n [duolistStyles['duolist-wrapper--extra-padding-top']]: extraPaddingTop,\n },\n className\n );\n\n const duolistClasses = classNames(duolistStyles.duolist, {\n [duolistStyles['duolist--line']]: hasLines,\n [duolistStyles['duolist--non-formatted']]: nonFormatted,\n [duolistStyles['duolist--collapsed']]: useCollapsedMode,\n [duolistStyles['duolist--not-collapsed']]: !useCollapsedMode,\n });\n\n const duolistColumnStyle = descriptionWidth ? descriptionWidth + '%' : 'minmax(60%, 1fr)';\n\n return (\n <div className={duolistWrapperClasses} data-testid={testId} data-analyticsid={AnalyticsId.Duolist}>\n {label && (\n <>\n {label}\n <Spacer />\n </>\n )}\n <dl\n style={!nonFormatted ? { gridTemplateColumns: useCollapsedMode ? `1fr` : `auto ${duolistColumnStyle}` } : undefined}\n className={duolistClasses}\n >\n {React.Children.map(children, (child: React.ReactNode | React.ReactElement<DuolistGroupProps>) => {\n if (child === null || typeof child === 'undefined') return;\n const duolistGroup = child as React.ReactElement<DuolistGroupProps>;\n if (duolistGroup.type === DuolistGroup) {\n return React.cloneElement(child as React.ReactElement<DuolistGroupProps>, {\n ...duolistGroup.props,\n boldColumn: duolistGroup.props.boldColumn ?? boldColumn,\n format: duolistGroup.props.format ?? format,\n separator: duolistGroup.props.separator ?? separator,\n });\n }\n })}\n </dl>\n </div>\n );\n};\n\nexport default Duolist;\n","import Duolist from './Duolist';\nexport * from './Duolist';\nexport default Duolist;\n"],"mappings":";;;;;;;AAyDA,MAAaA,gBAA4C,UAAS;CAChE,MAAM,EAAE,SAAS,aAAa,aAAa,WAAW,kBAAkB,SAAS,SAAS,aAAa,YAAY,MAAM,SAAS;CAElI,MAAM,YAAY,eAAe;CACjC,MAAM,aAAa,eAAe;CAClC,MAAM,eAAe,WAAW;CAEhC,MAAM,eAAe,GAAW,cAAc,gBAAgB;GAC3D,cAAc,uBAAuB;GACrC,cAAc,gCAAgC;EAChD,CAAC;CACF,MAAM,eAAe,GAAW,cAAc,gBAAgB;GAC3D,cAAc,uBAAuB;GACrC,cAAc,gCAAgC;EAChD,CAAC;CAEF,MAAM,sBAAsB;AAC1B,SACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,MAAA;GACC,kBAAgB,eAAe,YAAY,KAAA;GAC3C,WAAW;GACX,eAAa,MAAM,UAAU,GAAG,MAAM,OAAO;aAE5C;IACE,EACL,oBAAC,MAAA;GAAG,WAAW;GAAc,eAAa,MAAM,UAAU,GAAG,MAAM,OAAO;aACvE;IACE,CAAA,EAAA,CACJ;;AAIP,QAAO,eAAe,oBAAC,OAAA,EAAA,UAAK,eAAe,EAAA,CAAO,GAAG,oBAAA,UAA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StatusDot.js";
9
9
  import { t as Highlighter_default } from "./Highlighter.js";
10
10
  import { n as ElementHeaderText, r as ElementHeaderText_default } from "./ElementHeaderText.js";
11
11
  import { n as StatusDotList, t as StatusDotList_default } from "./StatusDotList.js";
12
- import classNames from "classnames";
12
+ import cn from "classnames";
13
13
  import React from "react";
14
14
  import { jsx, jsxs } from "react/jsx-runtime";
15
15
  import styles from "./components/ElementHeader/styles.module.scss";
@@ -74,17 +74,17 @@ const ElementHeaderRoot = (props) => {
74
74
  const contentIsString = typeof children === "string";
75
75
  const mappedChildren = mapChildren(children);
76
76
  const hasStatusDots = !!mappedChildren?.statusDotChildren?.length || !!mappedChildren?.statusDotMCChild;
77
- const listLabelClasses = classNames(styles["element-header"], { [styles["element-header--compact"]]: size === "compact" }, className);
78
- const badgeContainerClasses = classNames(styles["element-header__badge-container"]);
79
- const badgeClasses = classNames(styles["element-header__badge"]);
80
- const statusdotContainerClasses = classNames(styles["element-header__statusdot-container"]);
81
- const chevronClasses = classNames(styles["element-header__chevron"]);
82
- const contentClasses = classNames(styles["element-header__content"], {
77
+ const listLabelClasses = cn(styles["element-header"], { [styles["element-header--compact"]]: size === "compact" }, className);
78
+ const badgeContainerClasses = cn(styles["element-header__badge-container"]);
79
+ const badgeClasses = cn(styles["element-header__badge"]);
80
+ const statusdotContainerClasses = cn(styles["element-header__statusdot-container"]);
81
+ const chevronClasses = cn(styles["element-header__chevron"]);
82
+ const contentClasses = cn(styles["element-header__content"], {
83
83
  [styles["element-header__content--element"]]: !contentIsString,
84
84
  [styles["element-header__content--compact"]]: size === "compact"
85
85
  });
86
- const iconClasses = classNames(styles["element-header__icon"], { [styles["element-header__icon--with-statusdot"]]: hasStatusDots });
87
- const avatarClasses = classNames(styles["element-header__avatar"], {});
86
+ const iconClasses = cn(styles["element-header__icon"], { [styles["element-header__icon--with-statusdot"]]: hasStatusDots });
87
+ const avatarClasses = cn(styles["element-header__avatar"], {});
88
88
  const CustomTag = titleHtmlMarkup;
89
89
  const iconPropIsIconComponent = isComponent(icon, Icon_default);
90
90
  const iconPropIsLazyIconComponent = !iconPropIsIconComponent && isComponent(icon, LazyIcon_default);
@@ -1 +1 @@
1
- {"version":3,"file":"ElementHeader.js","names":["mapChildren: ChildrenMapper","avatarChild: React.ReactElement<AvatarProps> | undefined","badgeChildren: React.ReactElement<BadgeProps>[]","statusDotChildren: React.ReactElement<StatusDotProps>[]","statusDotMCChild: React.ReactElement<StatusDotListProps> | undefined","elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[]","stringChildren: string[]","remainingChildren: React.ReactNode[]","ElementHeaderRoot: ElementHeaderType"],"sources":["../src/components/ElementHeader/utils.tsx","../src/components/ElementHeader/ElementHeader.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { AvatarProps } from '../Avatar';\nimport type { BadgeProps } from '../Badge';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport ElementHeader, { type ElementHeaderChildren, type ElementHeaderProps } from './ElementHeader';\nimport { ElementHeaderText, type ElementHeaderTextProps } from './ElementHeaderText';\nimport { StatusDotList, type StatusDotListProps } from './StatusDotList';\nimport { isComponent, isComponentWithChildren } from '../../utils/component';\nimport Avatar from '../Avatar';\nimport Badge from '../Badge';\nimport StatusDot from '../StatusDot';\n\ntype ChildrenMapper = (children: React.ReactNode, isJsxChild?: boolean) => ElementHeaderChildren | undefined;\n\nexport const mapChildren: ChildrenMapper = (children, isJsxChild = false) => {\n let avatarChild: React.ReactElement<AvatarProps> | undefined;\n const badgeChildren: React.ReactElement<BadgeProps>[] = [];\n const statusDotChildren: React.ReactElement<StatusDotProps>[] = [];\n let statusDotMCChild: React.ReactElement<StatusDotListProps> | undefined;\n const elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[] = [];\n const stringChildren: string[] = [];\n const remainingChildren: React.ReactNode[] = [];\n\n React.Children.forEach(children, child => {\n if (child === null || typeof child === 'undefined') return;\n if (isComponent<AvatarProps>(child, Avatar)) {\n avatarChild = child;\n } else if (isComponent<ElementHeaderTextProps>(child, ElementHeaderText)) {\n elementHeaderTextChildren.push(child);\n } else if (isComponent<BadgeProps>(child, Badge)) {\n badgeChildren.push(child);\n } else if (isComponent<StatusDotListProps>(child, StatusDotList)) {\n statusDotMCChild = child;\n } else if (isComponent<StatusDotProps>(child, StatusDot)) {\n statusDotChildren.push(child);\n } else if (typeof child === 'string') {\n stringChildren.push(child);\n } else {\n remainingChildren.push(child);\n }\n });\n\n // Dette og recursive mapChildren under(gjøres en gang) er for å passe på at jsx children også sjekkes for Avatar og liknende innhold.\n // Slik opprettholder vi stylingen i tilfeller hvor vertikaler har wrappet elementer i en parent span eller div.\n const hasSpecialChildren =\n avatarChild !== undefined ||\n elementHeaderTextChildren.length > 0 ||\n statusDotChildren.length > 0 ||\n statusDotMCChild !== undefined ||\n (badgeChildren !== undefined && stringChildren.length > 0);\n const noRemainingRecursiveChildren =\n remainingChildren.length === 0 ||\n (isComponentWithChildren(remainingChildren[0]) && typeof remainingChildren[0]?.props?.children === 'undefined');\n\n if (isJsxChild || hasSpecialChildren || noRemainingRecursiveChildren) {\n return {\n avatarChild,\n elementHeaderTextChildren: elementHeaderTextChildren,\n badgeChildren,\n statusDotChildren,\n statusDotMCChild,\n stringChildren,\n remainingChildren,\n };\n }\n\n if (isComponentWithChildren(remainingChildren[0])) {\n return mapChildren(remainingChildren[0]?.props?.children, true);\n }\n};\n\nexport const renderElementHeader = (\n element: React.ReactNode,\n options: Pick<\n ElementHeaderProps,\n 'titleHtmlMarkup' | 'isHovered' | 'size' | 'parentType' | 'chevronIcon' | 'icon' | 'highlightText' | 'closeButton'\n >\n): React.ReactElement | undefined => {\n const { titleHtmlMarkup, isHovered, size, parentType, chevronIcon, icon, highlightText, closeButton } = options;\n\n if (isComponent<ElementHeaderProps>(element, ElementHeader)) {\n return React.cloneElement(element, {\n chevronIcon,\n icon,\n isHovered,\n size,\n parentType,\n highlightText,\n closeButton,\n });\n }\n if (element) {\n return (\n <ElementHeader\n highlightText={highlightText}\n titleHtmlMarkup={titleHtmlMarkup}\n parentType={parentType}\n chevronIcon={chevronIcon}\n icon={icon}\n isHovered={isHovered}\n size={size}\n closeButton={closeButton}\n >\n {element}\n </ElementHeader>\n );\n }\n};\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { AvatarProps, AvatarType } from '../Avatar';\nimport type { BadgeProps, BadgeType } from '../Badge';\nimport type { IconProps, SvgIcon } from '../Icon';\nimport type { LazyIconProps } from '../LazyIcon';\nimport type { StatusDotProps, StatusDotType } from '../StatusDot';\nimport type { TitleTags } from '../Title';\nimport type { ElementHeaderTextProps, ElementHeaderTextType } from './ElementHeaderText/ElementHeaderText';\nimport type { StatusDotListProps, StatusDotListType } from './StatusDotList/StatusDotList';\n\nimport ElementHeaderText from './ElementHeaderText/ElementHeaderText';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { isComponent } from '../../utils/component';\nimport { AvatarSize } from '../Avatar';\nimport Icon, { IconSize } from '../Icon';\nimport StatusDotList from './StatusDotList';\nimport Highlighter from '../Highlighter';\nimport LazyIcon from '../LazyIcon';\nimport { mapChildren } from './utils';\n\nimport styles from './styles.module.scss';\n\nexport type ElementHeaderSize = 'compact' | 'small' | 'medium' | 'large';\nexport type ParentType = 'linklist' | 'expanderlist';\n\nexport interface ElementHeaderType extends React.FC<ElementHeaderProps> {\n Avatar?: AvatarType;\n Badge?: BadgeType;\n ElementHeaderText?: ElementHeaderTextType;\n StatusDot?: StatusDotType;\n StatusDotList?: StatusDotListType;\n}\n\nexport interface ElementHeaderProps {\n /** Adds custom classes to the ElementHeader element. */\n className?: string;\n /** Chevron to render inside of the ElementHeader */\n chevronIcon?: SvgIcon;\n /** Close button to be rendered inside of ElementHeader. This renders in place of chevronIcon */\n closeButton?: React.ReactElement;\n /** Children to be rendered inside of ElementHeader */\n children: React.ReactNode;\n /** Changes the underlying element of the title. Default: h2*/\n titleHtmlMarkup?: TitleTags;\n /** icon to be rendered inside of ElementHeader */\n icon?: React.ReactElement;\n /** whether or not the parent is hovered */\n isHovered?: boolean;\n /** Adjusts styling based on parent */\n parentType?: ParentType;\n /** Changes size of the ElementHeader. */\n size?: ElementHeaderSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Highlights text in title. Used for search results */\n highlightText?: string;\n}\n\nexport interface ElementHeaderChildren {\n avatarChild?: React.ReactElement<AvatarProps>;\n elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[];\n badgeChildren?: React.ReactElement<BadgeProps>[];\n statusDotChildren?: React.ReactElement<StatusDotProps>[];\n statusDotMCChild?: React.ReactElement<StatusDotListProps>;\n elementChild?: React.ReactElement;\n stringChildren: string[];\n remainingChildren: React.ReactNode[];\n}\n\nexport const ElementHeaderRoot: ElementHeaderType = props => {\n const {\n className = '',\n titleHtmlMarkup = 'h2',\n parentType = 'linklist',\n chevronIcon,\n closeButton,\n children,\n icon,\n isHovered,\n size,\n testId,\n highlightText,\n } = props;\n const breakpoint = useBreakpoint();\n const showIcon = size !== 'small' && !!icon;\n const contentIsString = typeof children === 'string';\n const mappedChildren = mapChildren(children);\n const hasStatusDots = !!mappedChildren?.statusDotChildren?.length || !!mappedChildren?.statusDotMCChild;\n\n const listLabelClasses = cn(styles['element-header'], { [styles['element-header--compact']]: size === 'compact' }, className);\n const badgeContainerClasses = cn(styles['element-header__badge-container']);\n const badgeClasses = cn(styles['element-header__badge']);\n const statusdotContainerClasses = cn(styles['element-header__statusdot-container']);\n const chevronClasses = cn(styles['element-header__chevron']);\n const contentClasses = cn(styles['element-header__content'], {\n [styles['element-header__content--element']]: !contentIsString,\n [styles['element-header__content--compact']]: size === 'compact',\n });\n const iconClasses = cn(styles['element-header__icon'], { [styles['element-header__icon--with-statusdot']]: hasStatusDots });\n const avatarClasses = cn(styles['element-header__avatar'], {});\n const CustomTag = titleHtmlMarkup;\n const iconPropIsIconComponent = isComponent<IconProps>(icon, Icon);\n const iconPropIsLazyIconComponent = !iconPropIsIconComponent && isComponent<LazyIconProps>(icon, LazyIcon);\n\n let iconComponent;\n if (iconPropIsIconComponent) {\n iconComponent = React.cloneElement(icon as React.ReactElement<IconProps>, {\n size: breakpoint < Breakpoint.md ? IconSize.XSmall : IconSize.Small,\n isHovered,\n });\n } else if (iconPropIsLazyIconComponent) {\n iconComponent = React.cloneElement(icon as React.ReactElement<LazyIconProps>, {\n size: breakpoint < Breakpoint.md ? IconSize.XSmall : IconSize.Small,\n isHovered,\n });\n } else {\n iconComponent = icon;\n }\n\n return (\n <span data-testid={testId} className={listLabelClasses}>\n {showIcon && icon && <span className={iconClasses}>{iconComponent}</span>}\n {size !== 'small' && mappedChildren?.avatarChild && (\n <span className={avatarClasses}>{React.cloneElement(mappedChildren.avatarChild, { size: AvatarSize.xsmall })}</span>\n )}\n\n <span className={contentClasses} data-hasstatusdots={hasStatusDots}>\n {mappedChildren?.elementHeaderTextChildren}\n {!!mappedChildren?.stringChildren.length && (\n <CustomTag className={styles['element-header__title']}>\n <Highlighter searchText={highlightText}>{mappedChildren.stringChildren}</Highlighter>\n </CustomTag>\n )}\n <Highlighter searchText={highlightText}>{mappedChildren?.remainingChildren}</Highlighter>\n </span>\n\n {hasStatusDots && (\n <span className={statusdotContainerClasses}>\n {!!mappedChildren?.statusDotChildren && <StatusDotList>{mappedChildren.statusDotChildren}</StatusDotList>}\n {!!mappedChildren?.statusDotMCChild && mappedChildren?.statusDotMCChild}\n </span>\n )}\n\n <span className={badgeContainerClasses}>\n {mappedChildren?.badgeChildren &&\n mappedChildren.badgeChildren.map((badgeChild, index) => {\n return (\n <span key={index} className={badgeClasses} data-parenttype={parentType}>\n {badgeChild}\n </span>\n );\n })}\n </span>\n {chevronIcon && typeof closeButton === 'undefined' && (\n <span className={chevronClasses} data-parenttype={parentType}>\n <Icon svgIcon={chevronIcon} isHovered={isHovered} size={IconSize.XSmall} />\n </span>\n )}\n {closeButton && (\n <span className={chevronClasses} data-parenttype={parentType}>\n {closeButton}\n </span>\n )}\n </span>\n );\n};\n\ntype ElementHeaderComponent = typeof ElementHeaderRoot & {\n Text: React.FC<ElementHeaderTextProps>;\n StatusDotList: React.FC<StatusDotListProps>;\n};\nElementHeaderRoot.displayName = 'ElementHeader';\nconst ElementHeader = ElementHeaderRoot as ElementHeaderComponent;\nElementHeader.Text = ElementHeaderText;\nElementHeader.Text.displayName = 'ElementHeader.Text';\nElementHeader.StatusDotList = StatusDotList;\nElementHeader.StatusDotList.displayName = 'ElementHeader.StatusDotList';\n\nexport default ElementHeader;\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAaA,eAA+B,UAAU,aAAa,UAAU;CAC3E,IAAIC;CACJ,MAAMC,gBAAkD,EAAE;CAC1D,MAAMC,oBAA0D,EAAE;CAClE,IAAIC;CACJ,MAAMC,4BAA0E,EAAE;CAClF,MAAMC,iBAA2B,EAAE;CACnC,MAAMC,oBAAuC,EAAE;AAE/C,OAAM,SAAS,QAAQ,WAAU,UAAS;AACxC,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAa;AACpD,MAAI,YAAyB,OAAO,eAAO,CACzC,eAAc;WACL,YAAoC,OAAO,kBAAkB,CACtE,2BAA0B,KAAK,MAAM;WAC5B,YAAwB,OAAO,cAAM,CAC9C,eAAc,KAAK,MAAM;WAChB,YAAgC,OAAO,cAAc,CAC9D,oBAAmB;WACV,YAA4B,OAAO,kBAAU,CACtD,mBAAkB,KAAK,MAAM;WACpB,OAAO,UAAU,SAC1B,gBAAe,KAAK,MAAM;MAE1B,mBAAkB,KAAK,MAAM;GAE/B;CAIF,MAAM,qBACJ,gBAAgB,KAAA,KAChB,0BAA0B,SAAS,KACnC,kBAAkB,SAAS,KAC3B,qBAAqB,KAAA,KACpB,kBAAkB,KAAA,KAAa,eAAe,SAAS;CAC1D,MAAM,+BACJ,kBAAkB,WAAW,KAC5B,wBAAwB,kBAAkB,GAAG,IAAI,OAAO,kBAAkB,IAAI,OAAO,aAAa;AAErG,KAAI,cAAc,sBAAsB,6BACtC,QAAO;EACL;EAC2B;EAC3B;EACA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IAAK,WAAW;IAAgB,mBAAiB;cAChD,oBAAC,cAAA;KAAK,SAAS;KAAwB;KAAW,MAAM,SAAS;MAAU;KACtE;GAER,eACC,oBAAC,QAAA;IAAK,WAAW;IAAgB,mBAAiB;cAC/C;KACI;;GAEJ;;AAQX,kBAAkB,cAAc;AAChC,IAAM,gBAAgB;AACtB,cAAc,OAAO;AACrB,cAAc,KAAK,cAAc;AACjC,cAAc,gBAAgB;AAC9B,cAAc,cAAc,cAAc;AAE1C,IAAA,wBAAe"}
1
+ {"version":3,"file":"ElementHeader.js","names":["mapChildren: ChildrenMapper","avatarChild: React.ReactElement<AvatarProps> | undefined","badgeChildren: React.ReactElement<BadgeProps>[]","statusDotChildren: React.ReactElement<StatusDotProps>[]","statusDotMCChild: React.ReactElement<StatusDotListProps> | undefined","elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[]","stringChildren: string[]","remainingChildren: React.ReactNode[]","ElementHeaderRoot: ElementHeaderType"],"sources":["../src/components/ElementHeader/utils.tsx","../src/components/ElementHeader/ElementHeader.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { AvatarProps } from '../Avatar';\nimport type { BadgeProps } from '../Badge';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport ElementHeader, { type ElementHeaderChildren, type ElementHeaderProps } from './ElementHeader';\nimport { ElementHeaderText, type ElementHeaderTextProps } from './ElementHeaderText';\nimport { StatusDotList, type StatusDotListProps } from './StatusDotList';\nimport { isComponent, isComponentWithChildren } from '../../utils/component';\nimport Avatar from '../Avatar';\nimport Badge from '../Badge';\nimport StatusDot from '../StatusDot';\n\ntype ChildrenMapper = (children: React.ReactNode, isJsxChild?: boolean) => ElementHeaderChildren | undefined;\n\nexport const mapChildren: ChildrenMapper = (children, isJsxChild = false) => {\n let avatarChild: React.ReactElement<AvatarProps> | undefined;\n const badgeChildren: React.ReactElement<BadgeProps>[] = [];\n const statusDotChildren: React.ReactElement<StatusDotProps>[] = [];\n let statusDotMCChild: React.ReactElement<StatusDotListProps> | undefined;\n const elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[] = [];\n const stringChildren: string[] = [];\n const remainingChildren: React.ReactNode[] = [];\n\n React.Children.forEach(children, child => {\n if (child === null || typeof child === 'undefined') return;\n if (isComponent<AvatarProps>(child, Avatar)) {\n avatarChild = child;\n } else if (isComponent<ElementHeaderTextProps>(child, ElementHeaderText)) {\n elementHeaderTextChildren.push(child);\n } else if (isComponent<BadgeProps>(child, Badge)) {\n badgeChildren.push(child);\n } else if (isComponent<StatusDotListProps>(child, StatusDotList)) {\n statusDotMCChild = child;\n } else if (isComponent<StatusDotProps>(child, StatusDot)) {\n statusDotChildren.push(child);\n } else if (typeof child === 'string') {\n stringChildren.push(child);\n } else {\n remainingChildren.push(child);\n }\n });\n\n // Dette og recursive mapChildren under(gjøres en gang) er for å passe på at jsx children også sjekkes for Avatar og liknende innhold.\n // Slik opprettholder vi stylingen i tilfeller hvor vertikaler har wrappet elementer i en parent span eller div.\n const hasSpecialChildren =\n avatarChild !== undefined ||\n elementHeaderTextChildren.length > 0 ||\n statusDotChildren.length > 0 ||\n statusDotMCChild !== undefined ||\n (badgeChildren !== undefined && stringChildren.length > 0);\n const noRemainingRecursiveChildren =\n remainingChildren.length === 0 ||\n (isComponentWithChildren(remainingChildren[0]) && typeof remainingChildren[0]?.props?.children === 'undefined');\n\n if (isJsxChild || hasSpecialChildren || noRemainingRecursiveChildren) {\n return {\n avatarChild,\n elementHeaderTextChildren: elementHeaderTextChildren,\n badgeChildren,\n statusDotChildren,\n statusDotMCChild,\n stringChildren,\n remainingChildren,\n };\n }\n\n if (isComponentWithChildren(remainingChildren[0])) {\n return mapChildren(remainingChildren[0]?.props?.children, true);\n }\n};\n\nexport const renderElementHeader = (\n element: React.ReactNode,\n options: Pick<\n ElementHeaderProps,\n 'titleHtmlMarkup' | 'isHovered' | 'size' | 'parentType' | 'chevronIcon' | 'icon' | 'highlightText' | 'closeButton'\n >\n): React.ReactElement | undefined => {\n const { titleHtmlMarkup, isHovered, size, parentType, chevronIcon, icon, highlightText, closeButton } = options;\n\n if (isComponent<ElementHeaderProps>(element, ElementHeader)) {\n return React.cloneElement(element, {\n chevronIcon,\n icon,\n isHovered,\n size,\n parentType,\n highlightText,\n closeButton,\n });\n }\n if (element) {\n return (\n <ElementHeader\n highlightText={highlightText}\n titleHtmlMarkup={titleHtmlMarkup}\n parentType={parentType}\n chevronIcon={chevronIcon}\n icon={icon}\n isHovered={isHovered}\n size={size}\n closeButton={closeButton}\n >\n {element}\n </ElementHeader>\n );\n }\n};\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { AvatarProps, AvatarType } from '../Avatar';\nimport type { BadgeProps, BadgeType } from '../Badge';\nimport type { IconProps, SvgIcon } from '../Icon';\nimport type { LazyIconProps } from '../LazyIcon';\nimport type { StatusDotProps, StatusDotType } from '../StatusDot';\nimport type { TitleTags } from '../Title';\nimport type { ElementHeaderTextProps, ElementHeaderTextType } from './ElementHeaderText/ElementHeaderText';\nimport type { StatusDotListProps, StatusDotListType } from './StatusDotList/StatusDotList';\n\nimport ElementHeaderText from './ElementHeaderText/ElementHeaderText';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { isComponent } from '../../utils/component';\nimport { AvatarSize } from '../Avatar';\nimport Icon, { IconSize } from '../Icon';\nimport StatusDotList from './StatusDotList';\nimport Highlighter from '../Highlighter';\nimport LazyIcon from '../LazyIcon';\nimport { mapChildren } from './utils';\n\nimport styles from './styles.module.scss';\n\nexport type ElementHeaderSize = 'compact' | 'small' | 'medium' | 'large';\nexport type ParentType = 'linklist' | 'expanderlist';\n\nexport interface ElementHeaderType extends React.FC<ElementHeaderProps> {\n Avatar?: AvatarType;\n Badge?: BadgeType;\n ElementHeaderText?: ElementHeaderTextType;\n StatusDot?: StatusDotType;\n StatusDotList?: StatusDotListType;\n}\n\nexport interface ElementHeaderProps {\n /** Adds custom classes to the ElementHeader element. */\n className?: string;\n /** Chevron to render inside of the ElementHeader */\n chevronIcon?: SvgIcon;\n /** Close button to be rendered inside of ElementHeader. This renders in place of chevronIcon */\n closeButton?: React.ReactElement;\n /** Children to be rendered inside of ElementHeader */\n children: React.ReactNode;\n /** Changes the underlying element of the title. Default: h2*/\n titleHtmlMarkup?: TitleTags;\n /** icon to be rendered inside of ElementHeader */\n icon?: React.ReactElement;\n /** whether or not the parent is hovered */\n isHovered?: boolean;\n /** Adjusts styling based on parent */\n parentType?: ParentType;\n /** Changes size of the ElementHeader. */\n size?: ElementHeaderSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Highlights text in title. Used for search results */\n highlightText?: string;\n}\n\nexport interface ElementHeaderChildren {\n avatarChild?: React.ReactElement<AvatarProps>;\n elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[];\n badgeChildren?: React.ReactElement<BadgeProps>[];\n statusDotChildren?: React.ReactElement<StatusDotProps>[];\n statusDotMCChild?: React.ReactElement<StatusDotListProps>;\n elementChild?: React.ReactElement;\n stringChildren: string[];\n remainingChildren: React.ReactNode[];\n}\n\nexport const ElementHeaderRoot: ElementHeaderType = props => {\n const {\n className = '',\n titleHtmlMarkup = 'h2',\n parentType = 'linklist',\n chevronIcon,\n closeButton,\n children,\n icon,\n isHovered,\n size,\n testId,\n highlightText,\n } = props;\n const breakpoint = useBreakpoint();\n const showIcon = size !== 'small' && !!icon;\n const contentIsString = typeof children === 'string';\n const mappedChildren = mapChildren(children);\n const hasStatusDots = !!mappedChildren?.statusDotChildren?.length || !!mappedChildren?.statusDotMCChild;\n\n const listLabelClasses = cn(styles['element-header'], { [styles['element-header--compact']]: size === 'compact' }, className);\n const badgeContainerClasses = cn(styles['element-header__badge-container']);\n const badgeClasses = cn(styles['element-header__badge']);\n const statusdotContainerClasses = cn(styles['element-header__statusdot-container']);\n const chevronClasses = cn(styles['element-header__chevron']);\n const contentClasses = cn(styles['element-header__content'], {\n [styles['element-header__content--element']]: !contentIsString,\n [styles['element-header__content--compact']]: size === 'compact',\n });\n const iconClasses = cn(styles['element-header__icon'], { [styles['element-header__icon--with-statusdot']]: hasStatusDots });\n const avatarClasses = cn(styles['element-header__avatar'], {});\n const CustomTag = titleHtmlMarkup;\n const iconPropIsIconComponent = isComponent<IconProps>(icon, Icon);\n const iconPropIsLazyIconComponent = !iconPropIsIconComponent && isComponent<LazyIconProps>(icon, LazyIcon);\n\n let iconComponent;\n if (iconPropIsIconComponent) {\n iconComponent = React.cloneElement(icon as React.ReactElement<IconProps>, {\n size: breakpoint < Breakpoint.md ? IconSize.XSmall : IconSize.Small,\n isHovered,\n });\n } else if (iconPropIsLazyIconComponent) {\n iconComponent = React.cloneElement(icon as React.ReactElement<LazyIconProps>, {\n size: breakpoint < Breakpoint.md ? IconSize.XSmall : IconSize.Small,\n isHovered,\n });\n } else {\n iconComponent = icon;\n }\n\n return (\n <span data-testid={testId} className={listLabelClasses}>\n {showIcon && icon && <span className={iconClasses}>{iconComponent}</span>}\n {size !== 'small' && mappedChildren?.avatarChild && (\n <span className={avatarClasses}>{React.cloneElement(mappedChildren.avatarChild, { size: AvatarSize.xsmall })}</span>\n )}\n\n <span className={contentClasses} data-hasstatusdots={hasStatusDots}>\n {mappedChildren?.elementHeaderTextChildren}\n {!!mappedChildren?.stringChildren.length && (\n <CustomTag className={styles['element-header__title']}>\n <Highlighter searchText={highlightText}>{mappedChildren.stringChildren}</Highlighter>\n </CustomTag>\n )}\n <Highlighter searchText={highlightText}>{mappedChildren?.remainingChildren}</Highlighter>\n </span>\n\n {hasStatusDots && (\n <span className={statusdotContainerClasses}>\n {!!mappedChildren?.statusDotChildren && <StatusDotList>{mappedChildren.statusDotChildren}</StatusDotList>}\n {!!mappedChildren?.statusDotMCChild && mappedChildren?.statusDotMCChild}\n </span>\n )}\n\n <span className={badgeContainerClasses}>\n {mappedChildren?.badgeChildren &&\n mappedChildren.badgeChildren.map((badgeChild, index) => {\n return (\n <span key={index} className={badgeClasses} data-parenttype={parentType}>\n {badgeChild}\n </span>\n );\n })}\n </span>\n {chevronIcon && typeof closeButton === 'undefined' && (\n <span className={chevronClasses} data-parenttype={parentType}>\n <Icon svgIcon={chevronIcon} isHovered={isHovered} size={IconSize.XSmall} />\n </span>\n )}\n {closeButton && (\n <span className={chevronClasses} data-parenttype={parentType}>\n {closeButton}\n </span>\n )}\n </span>\n );\n};\n\ntype ElementHeaderComponent = typeof ElementHeaderRoot & {\n Text: React.FC<ElementHeaderTextProps>;\n StatusDotList: React.FC<StatusDotListProps>;\n};\nElementHeaderRoot.displayName = 'ElementHeader';\nconst ElementHeader = ElementHeaderRoot as ElementHeaderComponent;\nElementHeader.Text = ElementHeaderText;\nElementHeader.Text.displayName = 'ElementHeader.Text';\nElementHeader.StatusDotList = StatusDotList;\nElementHeader.StatusDotList.displayName = 'ElementHeader.StatusDotList';\n\nexport default ElementHeader;\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAaA,eAA+B,UAAU,aAAa,UAAU;CAC3E,IAAIC;CACJ,MAAMC,gBAAkD,EAAE;CAC1D,MAAMC,oBAA0D,EAAE;CAClE,IAAIC;CACJ,MAAMC,4BAA0E,EAAE;CAClF,MAAMC,iBAA2B,EAAE;CACnC,MAAMC,oBAAuC,EAAE;AAE/C,OAAM,SAAS,QAAQ,WAAU,UAAS;AACxC,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAa;AACpD,MAAI,YAAyB,OAAO,eAAO,CACzC,eAAc;WACL,YAAoC,OAAO,kBAAkB,CACtE,2BAA0B,KAAK,MAAM;WAC5B,YAAwB,OAAO,cAAM,CAC9C,eAAc,KAAK,MAAM;WAChB,YAAgC,OAAO,cAAc,CAC9D,oBAAmB;WACV,YAA4B,OAAO,kBAAU,CACtD,mBAAkB,KAAK,MAAM;WACpB,OAAO,UAAU,SAC1B,gBAAe,KAAK,MAAM;MAE1B,mBAAkB,KAAK,MAAM;GAE/B;CAIF,MAAM,qBACJ,gBAAgB,KAAA,KAChB,0BAA0B,SAAS,KACnC,kBAAkB,SAAS,KAC3B,qBAAq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KAClD;GAGT,oBAAC,QAAA;IAAK,WAAW;cACd,gBAAgB,iBACf,eAAe,cAAc,KAAK,YAAY,UAAU;AACtD,YACE,oBAAC,QAAA;MAAiB,WAAW;MAAc,mBAAiB;gBACzD;QADQ,MAEJ;MAET;KACC;GACN,eAAe,OAAO,gBAAgB,eACrC,oBAAC,QAAA;IAAK,WAAW;IAAgB,mBAAiB;cAChD,oBAAC,cAAA;KAAK,SAAS;KAAwB;KAAW,MAAM,SAAS;MAAU;KACtE;GAER,eACC,oBAAC,QAAA;IAAK,WAAW;IAAgB,mBAAiB;cAC/C;KACI;;GAEJ;;AAQX,kBAAkB,cAAc;AAChC,IAAM,gBAAgB;AACtB,cAAc,OAAO;AACrB,cAAc,KAAK,cAAc;AACjC,cAAc,gBAAgB;AAC9B,cAAc,cAAc,cAAc;AAE1C,IAAA,wBAAe"}
@@ -1,12 +1,12 @@
1
1
  import { t as Highlighter_default } from "./Highlighter.js";
2
- import classNames from "classnames";
2
+ import cn from "classnames";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import styles from "./components/ElementHeader/styles.module.scss";
5
5
  const ElementHeaderText = (props) => {
6
6
  const { firstText, firstTextEmphasised = false, secondText = void 0, secondTextEmphasised = false, subText = false, className = "", testId, titleHtmlMarkup = "span", highlightText } = props;
7
- const headerTextWrapperClasses = classNames(className, styles["text-wrapper"], { [styles["text-wrapper--sub-level"]]: subText });
8
- const firstHeaderTextSegmentClasses = classNames({ [styles["text-wrapper__text--emphasised"]]: firstTextEmphasised });
9
- const secondHeaderTextSegmentClasses = classNames({ [styles["text-wrapper__text--emphasised"]]: secondTextEmphasised });
7
+ const headerTextWrapperClasses = cn(className, styles["text-wrapper"], { [styles["text-wrapper--sub-level"]]: subText });
8
+ const firstHeaderTextSegmentClasses = cn({ [styles["text-wrapper__text--emphasised"]]: firstTextEmphasised });
9
+ const secondHeaderTextSegmentClasses = cn({ [styles["text-wrapper__text--emphasised"]]: secondTextEmphasised });
10
10
  const CustomTag = titleHtmlMarkup;
11
11
  return /* @__PURE__ */ jsx("span", {
12
12
  "data-testid": testId,
@@ -1 +1 @@
1
- {"version":3,"file":"ElementHeaderText.js","names":["ElementHeaderText: React.FC<ElementHeaderTextProps>"],"sources":["../src/components/ElementHeader/ElementHeaderText/ElementHeaderText.tsx","../src/components/ElementHeader/ElementHeaderText/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport type { TitleTags } from '../../Title';\n\nimport Highlighter from '../../Highlighter';\nimport styles from '../styles.module.scss';\n\nexport type ElementHeaderTextType = typeof ElementHeaderText;\n\nexport interface ElementHeaderTextProps {\n /** The first text in the ElementHeaderText Component */\n firstText: string;\n /** Will style the first text as bold */\n firstTextEmphasised?: boolean;\n /** The second text in the ElementHeaderText Component */\n secondText?: string;\n /** Will style the second text as bold */\n secondTextEmphasised?: boolean;\n /** Whether or not this ElementHeaderText is a sub text */\n subText?: boolean;\n /** Adds custom classes to the ElementHeaderText component. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Changes the underlying element of the text. Default: span*/\n titleHtmlMarkup?: TitleTags;\n /** Highlights text. Used for search results */\n highlightText?: string;\n}\n\nexport const ElementHeaderText: React.FC<ElementHeaderTextProps> = props => {\n const {\n firstText,\n firstTextEmphasised = false,\n secondText = undefined,\n secondTextEmphasised = false,\n subText = false,\n className = '',\n testId,\n titleHtmlMarkup = 'span',\n highlightText,\n } = props;\n\n const headerTextWrapperClasses = cn(className, styles['text-wrapper'], {\n [styles['text-wrapper--sub-level']]: subText,\n });\n const firstHeaderTextSegmentClasses = cn({\n [styles['text-wrapper__text--emphasised']]: firstTextEmphasised,\n });\n const secondHeaderTextSegmentClasses = cn({\n [styles['text-wrapper__text--emphasised']]: secondTextEmphasised,\n });\n const CustomTag = titleHtmlMarkup;\n\n return (\n <span data-testid={testId} className={headerTextWrapperClasses}>\n <CustomTag className={styles['element-header__title']}>\n <Highlighter searchText={highlightText}>\n <span className={firstHeaderTextSegmentClasses}>{firstText}</span>\n {secondText && <span className={secondHeaderTextSegmentClasses}>{secondText}</span>}\n </Highlighter>\n </CustomTag>\n </span>\n );\n};\n\nexport default ElementHeaderText;\n","import ElementHeaderText from './ElementHeaderText';\nexport * from './ElementHeaderText';\nexport default ElementHeaderText;\n"],"mappings":";;;;AA8BA,MAAaA,qBAAsD,UAAS;CAC1E,MAAM,EACJ,WACA,sBAAsB,OACtB,aAAa,KAAA,GACb,uBAAuB,OACvB,UAAU,OACV,YAAY,IACZ,QACA,kBAAkB,QAClB,kBACE;CAEJ,MAAM,2BAA2B,WAAG,WAAW,OAAO,iBAAiB,GACpE,OAAO,6BAA6B,SACtC,CAAC;CACF,MAAM,gCAAgC,WAAG,GACtC,OAAO,oCAAoC,qBAC7C,CAAC;CACF,MAAM,iCAAiC,WAAG,GACvC,OAAO,oCAAoC,sBAC7C,CAAC;CACF,MAAM,YAAY;AAElB,QACE,oBAAC,QAAA;EAAK,eAAa;EAAQ,WAAW;YACpC,oBAAC,WAAA;GAAU,WAAW,OAAO;aAC3B,qBAAC,qBAAA;IAAY,YAAY;eACvB,oBAAC,QAAA;KAAK,WAAW;eAAgC;MAAiB,EACjE,cAAc,oBAAC,QAAA;KAAK,WAAW;eAAiC;MAAkB,CAAA;KACvE;IACJ;GACP;;AAIX,IAAA,4BAAe;AChEf,IAAA,8BAAe"}
1
+ {"version":3,"file":"ElementHeaderText.js","names":["ElementHeaderText: React.FC<ElementHeaderTextProps>"],"sources":["../src/components/ElementHeader/ElementHeaderText/ElementHeaderText.tsx","../src/components/ElementHeader/ElementHeaderText/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport type { TitleTags } from '../../Title';\n\nimport Highlighter from '../../Highlighter';\nimport styles from '../styles.module.scss';\n\nexport type ElementHeaderTextType = typeof ElementHeaderText;\n\nexport interface ElementHeaderTextProps {\n /** The first text in the ElementHeaderText Component */\n firstText: string;\n /** Will style the first text as bold */\n firstTextEmphasised?: boolean;\n /** The second text in the ElementHeaderText Component */\n secondText?: string;\n /** Will style the second text as bold */\n secondTextEmphasised?: boolean;\n /** Whether or not this ElementHeaderText is a sub text */\n subText?: boolean;\n /** Adds custom classes to the ElementHeaderText component. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Changes the underlying element of the text. Default: span*/\n titleHtmlMarkup?: TitleTags;\n /** Highlights text. Used for search results */\n highlightText?: string;\n}\n\nexport const ElementHeaderText: React.FC<ElementHeaderTextProps> = props => {\n const {\n firstText,\n firstTextEmphasised = false,\n secondText = undefined,\n secondTextEmphasised = false,\n subText = false,\n className = '',\n testId,\n titleHtmlMarkup = 'span',\n highlightText,\n } = props;\n\n const headerTextWrapperClasses = cn(className, styles['text-wrapper'], {\n [styles['text-wrapper--sub-level']]: subText,\n });\n const firstHeaderTextSegmentClasses = cn({\n [styles['text-wrapper__text--emphasised']]: firstTextEmphasised,\n });\n const secondHeaderTextSegmentClasses = cn({\n [styles['text-wrapper__text--emphasised']]: secondTextEmphasised,\n });\n const CustomTag = titleHtmlMarkup;\n\n return (\n <span data-testid={testId} className={headerTextWrapperClasses}>\n <CustomTag className={styles['element-header__title']}>\n <Highlighter searchText={highlightText}>\n <span className={firstHeaderTextSegmentClasses}>{firstText}</span>\n {secondText && <span className={secondHeaderTextSegmentClasses}>{secondText}</span>}\n </Highlighter>\n </CustomTag>\n </span>\n );\n};\n\nexport default ElementHeaderText;\n","import ElementHeaderText from './ElementHeaderText';\nexport * from './ElementHeaderText';\nexport default ElementHeaderText;\n"],"mappings":";;;;AA8BA,MAAaA,qBAAsD,UAAS;CAC1E,MAAM,EACJ,WACA,sBAAsB,OACtB,aAAa,KAAA,GACb,uBAAuB,OACvB,UAAU,OACV,YAAY,IACZ,QACA,kBAAkB,QAClB,kBACE;CAEJ,MAAM,2BAA2B,GAAG,WAAW,OAAO,iBAAiB,GACpE,OAAO,6BAA6B,SACtC,CAAC;CACF,MAAM,gCAAgC,GAAG,GACtC,OAAO,oCAAoC,qBAC7C,CAAC;CACF,MAAM,iCAAiC,GAAG,GACvC,OAAO,oCAAoC,sBAC7C,CAAC;CACF,MAAM,YAAY;AAElB,QACE,oBAAC,QAAA;EAAK,eAAa;EAAQ,WAAW;YACpC,oBAAC,WAAA;GAAU,WAAW,OAAO;aAC3B,qBAAC,qBAAA;IAAY,YAAY;eACvB,oBAAC,QAAA;KAAK,WAAW;eAAgC;MAAiB,EACjE,cAAc,oBAAC,QAAA;KAAK,WAAW;eAAiC;MAAkB,CAAA;KACvE;IACJ;GACP;;AAIX,IAAA,4BAAe;AChEf,IAAA,8BAAe"}
@@ -1,10 +1,10 @@
1
- import classNames from "classnames";
1
+ import cn from "classnames";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import styles from "./components/ErrorWrapper/styles.module.scss";
4
4
  const ErrorWrapper = (props) => {
5
5
  const { renderError = true } = props;
6
6
  return /* @__PURE__ */ jsxs("div", {
7
- className: classNames(props.errorText && renderError && styles[`error-wrapper--with-error`], props.className),
7
+ className: cn(props.errorText && renderError && styles[`error-wrapper--with-error`], props.className),
8
8
  "data-testid": props.testId,
9
9
  children: [/* @__PURE__ */ jsx("span", {
10
10
  ref: props.errorMessageRef,
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorWrapper.js","names":["ErrorWrapper: React.FC<ErrorWrapperProps>"],"sources":["../src/components/ErrorWrapper/ErrorWrapper.tsx","../src/components/ErrorWrapper/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport styles from './styles.module.scss';\n\nexport interface ErrorWrapperClassNameProps {\n errorWrapperClassName?: string;\n}\n\nexport interface ErrorWrapperProps {\n /** Form component */\n children?: React.ReactNode;\n /** Error message */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds a ref to the error message p tag */\n errorMessageRef?: React.Ref<HTMLDivElement>;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const ErrorWrapper: React.FC<ErrorWrapperProps> = props => {\n const { renderError = true } = props;\n\n const errorWrapperClasses = cn(props.errorText && renderError && styles[`error-wrapper--with-error`], props.className);\n\n return (\n <div className={errorWrapperClasses} data-testid={props.testId}>\n <span ref={props.errorMessageRef} tabIndex={-1}>\n {props.errorText && (\n <p className={styles['error-wrapper__errors']} id={props.errorTextId}>\n {props.errorText}\n </p>\n )}\n </span>\n {props.children}\n </div>\n );\n};\n\nexport default ErrorWrapper;\n","import ErrorWrapper from './ErrorWrapper';\nexport * from './ErrorWrapper';\nexport default ErrorWrapper;\n"],"mappings":";;;AAyBA,MAAaA,gBAA4C,UAAS;CAChE,MAAM,EAAE,cAAc,SAAS;AAI/B,QACE,qBAAC,OAAA;EAAI,WAHqB,WAAG,MAAM,aAAa,eAAe,OAAO,8BAA8B,MAAM,UAAU;EAG/E,eAAa,MAAM;aACtD,oBAAC,QAAA;GAAK,KAAK,MAAM;GAAiB,UAAU;aACzC,MAAM,aACL,oBAAC,KAAA;IAAE,WAAW,OAAO;IAA0B,IAAI,MAAM;cACtD,MAAM;KACL;IAED,EACN,MAAM,SAAA;GACH;;ACtCV,IAAA,yBD0Ce"}
1
+ {"version":3,"file":"ErrorWrapper.js","names":["ErrorWrapper: React.FC<ErrorWrapperProps>"],"sources":["../src/components/ErrorWrapper/ErrorWrapper.tsx","../src/components/ErrorWrapper/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport styles from './styles.module.scss';\n\nexport interface ErrorWrapperClassNameProps {\n errorWrapperClassName?: string;\n}\n\nexport interface ErrorWrapperProps {\n /** Form component */\n children?: React.ReactNode;\n /** Error message */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds a ref to the error message p tag */\n errorMessageRef?: React.Ref<HTMLDivElement>;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const ErrorWrapper: React.FC<ErrorWrapperProps> = props => {\n const { renderError = true } = props;\n\n const errorWrapperClasses = cn(props.errorText && renderError && styles[`error-wrapper--with-error`], props.className);\n\n return (\n <div className={errorWrapperClasses} data-testid={props.testId}>\n <span ref={props.errorMessageRef} tabIndex={-1}>\n {props.errorText && (\n <p className={styles['error-wrapper__errors']} id={props.errorTextId}>\n {props.errorText}\n </p>\n )}\n </span>\n {props.children}\n </div>\n );\n};\n\nexport default ErrorWrapper;\n","import ErrorWrapper from './ErrorWrapper';\nexport * from './ErrorWrapper';\nexport default ErrorWrapper;\n"],"mappings":";;;AAyBA,MAAaA,gBAA4C,UAAS;CAChE,MAAM,EAAE,cAAc,SAAS;AAI/B,QACE,qBAAC,OAAA;EAAI,WAHqB,GAAG,MAAM,aAAa,eAAe,OAAO,8BAA8B,MAAM,UAAU;EAG/E,eAAa,MAAM;aACtD,oBAAC,QAAA;GAAK,KAAK,MAAM;GAAiB,UAAU;aACzC,MAAM,aACL,oBAAC,KAAA;IAAE,WAAW,OAAO;IAA0B,IAAI,MAAM;cACtD,MAAM;KACL;IAED,EACN,MAAM,SAAA;GACH;;ACtCV,IAAA,yBD0Ce"}