@helsenorge/designsystem-react 14.0.0 → 14.1.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 (182) 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 +30 -19
  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 +5 -5
  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 +1 -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 +4 -0
  125. package/lib/components/Icons/AdditionalIconInformation.js +4 -0
  126. package/lib/components/Icons/AdditionalIconInformation.js.map +1 -1
  127. package/lib/components/Icons/IconNames.d.ts +1 -1
  128. package/lib/components/Icons/IconNames.js +1 -0
  129. package/lib/components/Icons/IconNames.js.map +1 -1
  130. package/lib/components/Icons/MeasuringTape.d.ts +3 -0
  131. package/lib/components/Icons/MeasuringTape.js +8 -0
  132. package/lib/components/Icons/MeasuringTape.js.map +1 -0
  133. package/lib/components/Loader/index.js +4 -4
  134. package/lib/components/Loader/index.js.map +1 -1
  135. package/lib/components/Modal/index.js +9 -9
  136. package/lib/components/Modal/index.js.map +1 -1
  137. package/lib/components/NotificationPanel/index.js +6 -6
  138. package/lib/components/NotificationPanel/index.js.map +1 -1
  139. package/lib/components/Panel/index.js +12 -12
  140. package/lib/components/Panel/index.js.map +1 -1
  141. package/lib/components/PanelList/index.js +3 -3
  142. package/lib/components/PanelList/index.js.map +1 -1
  143. package/lib/components/PopMenu/index.js +3 -3
  144. package/lib/components/PopMenu/index.js.map +1 -1
  145. package/lib/components/Progressbar/index.js +2 -2
  146. package/lib/components/Progressbar/index.js.map +1 -1
  147. package/lib/components/PromoPanel/index.js +2 -2
  148. package/lib/components/PromoPanel/index.js.map +1 -1
  149. package/lib/components/ServiceMessage/index.js +5 -5
  150. package/lib/components/ServiceMessage/index.js.map +1 -1
  151. package/lib/components/SharingStatus/index.js +4 -4
  152. package/lib/components/SharingStatus/index.js.map +1 -1
  153. package/lib/components/Step/index.js +2 -2
  154. package/lib/components/Step/index.js.map +1 -1
  155. package/lib/components/Stepper/index.js +2 -2
  156. package/lib/components/Stepper/index.js.map +1 -1
  157. package/lib/components/StickyNote/index.js +8 -8
  158. package/lib/components/StickyNote/index.js.map +1 -1
  159. package/lib/components/Table/index.js +2 -2
  160. package/lib/components/Table/index.js.map +1 -1
  161. package/lib/components/Tabs/index.js +4 -4
  162. package/lib/components/Tabs/index.js.map +1 -1
  163. package/lib/components/Tag/index.js +2 -2
  164. package/lib/components/Tag/index.js.map +1 -1
  165. package/lib/components/Tile/index.js +6 -5
  166. package/lib/components/Tile/index.js.map +1 -1
  167. package/lib/components/Toggle/index.js +16 -16
  168. package/lib/components/Toggle/index.js.map +1 -1
  169. package/lib/components/Toggle/styles.module.scss +4 -4
  170. package/lib/components/Validation/index.js +2 -2
  171. package/lib/components/Validation/index.js.map +1 -1
  172. package/lib/declaration.d.ts +9 -0
  173. package/lib/global.d.ts +3 -0
  174. package/lib/resources/Resources.d.ts +145 -0
  175. package/lib/scss/bootstrap/scss/mixins/_grid.scss +2 -1
  176. package/lib/types.d.ts +1 -0
  177. package/lib/utils2.js +7 -7
  178. package/lib/utils2.js.map +1 -1
  179. package/lib/utils3.js +5 -5
  180. package/lib/utils3.js.map +1 -1
  181. package/package.json +1 -1
  182. package/scss/bootstrap/scss/mixins/_grid.scss +2 -1
@@ -15,7 +15,7 @@ import { t as AlertSignFill_default } from "../../AlertSignFill.js";
15
15
  import { t as AlertSignStroke_default } from "../../AlertSignStroke.js";
16
16
  import { t as CheckOutline_default } from "../../CheckOutline.js";
17
17
  import { t as Portal } from "../../Portal.js";
18
- import classNames from "classnames";
18
+ import cn from "classnames";
19
19
  import React, { useEffect } from "react";
20
20
  import { jsx, jsxs } from "react/jsx-runtime";
21
21
  import styles from "./styles.module.scss";
@@ -109,8 +109,8 @@ var Modal = (props) => {
109
109
  useEffect(() => {
110
110
  dialogRef.current?.focus();
111
111
  }, []);
112
- const dialogClasses = classNames(className, styles.modal, variant && styles[`modal--${variant}`], size && styles[`modal--${size}`], contentIsScrollable && !showActions && styles["modal--no-actions"]);
113
- const titleClasses = classNames({
112
+ const dialogClasses = cn(className, styles.modal, variant && styles[`modal--${variant}`], size && styles[`modal--${size}`], contentIsScrollable && !showActions && styles["modal--no-actions"]);
113
+ const titleClasses = cn({
114
114
  [styles["modal__title--error"]]: variant === ModalVariants.error,
115
115
  [styles["modal__title--success"]]: variant === ModalVariants.success
116
116
  });
@@ -132,9 +132,9 @@ var Modal = (props) => {
132
132
  ...ariaLabelAttributes,
133
133
  ref: dialogRef,
134
134
  children: [
135
- /* @__PURE__ */ jsx("div", { className: classNames(styles["modal__shadow"], styles["modal__shadow--top"], { [styles["modal__shadow--show"]]: !topContentVisible && contentIsScrollable }) }),
135
+ /* @__PURE__ */ jsx("div", { className: cn(styles["modal__shadow"], styles["modal__shadow--top"], { [styles["modal__shadow--show"]]: !topContentVisible && contentIsScrollable }) }),
136
136
  /* @__PURE__ */ jsxs("div", {
137
- className: classNames(styles.modal__contentWrapper),
137
+ className: cn(styles.modal__contentWrapper),
138
138
  tabIndex: contentIsScrollable ? 0 : void 0,
139
139
  role: contentIsScrollable ? "region" : void 0,
140
140
  ...contentIsScrollable ? ariaLabelAttributes : {},
@@ -142,14 +142,14 @@ var Modal = (props) => {
142
142
  children: [!props.noCloseButton && /* @__PURE__ */ jsx("div", {
143
143
  className: styles.modal__closeWrapper,
144
144
  children: /* @__PURE__ */ jsx("div", {
145
- className: classNames(styles.modal__closeWrapper__close),
145
+ className: cn(styles.modal__closeWrapper__close),
146
146
  children: /* @__PURE__ */ jsx(Close_default, {
147
147
  onClick: props.onClose,
148
148
  ariaLabel: props.ariaLabelCloseBtn
149
149
  })
150
150
  })
151
151
  }), /* @__PURE__ */ jsxs("div", {
152
- className: classNames(size && styles[`modal__contentWrapper__scroll--${size}`]),
152
+ className: cn(size && styles[`modal__contentWrapper__scroll--${size}`]),
153
153
  children: [
154
154
  /* @__PURE__ */ jsx("div", { ref: topContent }),
155
155
  /* @__PURE__ */ jsxs("div", {
@@ -178,9 +178,9 @@ var Modal = (props) => {
178
178
  ]
179
179
  })]
180
180
  }),
181
- /* @__PURE__ */ jsx("div", { className: classNames(styles["modal__shadow"], styles["modal__shadow--bottom"], { [styles["modal__shadow--show"]]: !bottomContentVisible && contentIsScrollable }) }),
181
+ /* @__PURE__ */ jsx("div", { className: cn(styles["modal__shadow"], styles["modal__shadow--bottom"], { [styles["modal__shadow--show"]]: !bottomContentVisible && contentIsScrollable }) }),
182
182
  showActions && /* @__PURE__ */ jsxs("div", {
183
- className: classNames(styles["modal__call-to-action"], size && styles[`modal__call-to-action--${size}`]),
183
+ className: cn(styles["modal__call-to-action"], size && styles[`modal__call-to-action--${size}`]),
184
184
  children: [
185
185
  props.onSuccess && primaryButtonText && /* @__PURE__ */ jsx(Button_default, {
186
186
  onClick: props.onSuccess,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Modal: React.FC<ModalProps>"],"sources":["../../../src/components/Modal/constants.ts","../../../src/components/Modal/Modal.tsx","../../../src/components/Modal/index.ts"],"sourcesContent":["export enum ModalVariants {\n normal = 'normal',\n warning = 'warning',\n error = 'error',\n success = 'success',\n}\n\nexport enum ModalSize {\n large = 'large',\n medium = 'medium',\n}\n","import React, { useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport type { IconProps } from '../Icon';\n\nimport { ModalSize, ModalVariants } from './constants';\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport useFocusTrap from '../../hooks/useFocusTrap';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useReturnFocusOnUnmount } from '../../hooks/useReturnFocusOnUnmount';\nimport { palette } from '../../theme/palette';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { isComponent } from '../../utils/component';\nimport { disableBodyScroll, enableBodyScroll } from '../../utils/scroll';\nimport { uuid } from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport AlertSignFill from '../Icons/AlertSignFill';\nimport AlertSignStroke from '../Icons/AlertSignStroke';\nimport CheckOutline from '../Icons/CheckOutline';\nimport Portal from '../Portal';\nimport Title from '../Title/Title';\n\nimport styles from './styles.module.scss';\n\nexport interface ModalProps {\n /** Title of the modal */\n title: string;\n /** id of the modal title */\n titleId?: string;\n /** Description of the modal. Will not render if the modal has children. */\n description?: string;\n /** Optional footer content that can be rendered instead of default CTA(s) */\n footerContent?: React.ReactNode;\n /** Changes the visual representation of the modal */\n variant?: keyof typeof ModalVariants;\n /** Change width of the modal (default: large) */\n size?: keyof typeof ModalSize;\n /** Icon displayed in title */\n icon?: React.ReactElement;\n /** Hides the close button */\n noCloseButton?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Primary button text */\n primaryButtonText?: string;\n /** Secondary button text */\n secondaryButtonText?: string;\n /** Sets the aria-label of the modal */\n ariaLabel?: string;\n /** Sets the aria-labelledby of the modal */\n ariaLabelledBy?: string;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Alternative component to modal */\n children?: React.ReactNode;\n /** Component shown after title */\n afterTitleChildren?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Customize the z-index of the modal */\n zIndex?: number;\n /** Function is called when user clicks primary button */\n onSuccess?: () => void;\n /** Function is called when user clicks secondary button, clicks escape or outside the modal */\n onClose?: () => void;\n /** When enabled the component will be rendered in the bottom of document.body */\n printable?: boolean;\n /** If disabled, clicking escape or outside the modal will not close it */\n disableCloseEvents?: boolean;\n /** Aria role used for the Modal. Default is dialog */\n role?: 'dialog' | 'alertdialog';\n}\n\nconst getVariantIcon = (variant?: ModalProps['variant']): React.JSX.Element | null => {\n if (variant === ModalVariants.error) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignFill} color={palette.cherry500} />;\n } else if (variant === ModalVariants.warning) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignStroke} color={palette.black} />;\n } else if (variant === ModalVariants.success) {\n return <Icon size={IconSize.Small} svgIcon={CheckOutline} color={palette.kiwi900} />;\n }\n return null;\n};\n\nconst getIcon = (variant?: ModalProps['variant'], icon?: ModalProps['icon']): React.JSX.Element | null => {\n const variantIcon = getVariantIcon(variant);\n if (variantIcon) {\n return <div className={styles.modal__iconWrapper}>{variantIcon}</div>;\n }\n if (icon) {\n return (\n <div className={styles.modal__iconWrapper}>\n {isComponent<IconProps>(icon, Icon) &&\n React.cloneElement(icon, {\n size: IconSize.Small,\n })}\n </div>\n );\n }\n return null;\n};\n\nconst Modal: React.FC<ModalProps> = props => {\n const {\n footerContent,\n variant = ModalVariants.normal,\n primaryButtonText = 'OK',\n titleId = uuid(),\n className = '',\n size = ModalSize.large,\n zIndex = ZIndex.OverlayScreen,\n role = 'dialog',\n } = props;\n\n const topContent = React.useRef<HTMLDivElement>(null);\n const modalContentRef = React.useRef<HTMLDivElement>(null);\n const dialogRef = React.useRef<HTMLDivElement>(null);\n useFocusTrap(dialogRef, true);\n const topContentVisible = useIsVisible(topContent);\n const bottomContent = React.useRef<HTMLDivElement>(null);\n const bottomContentVisible = useIsVisible(bottomContent);\n const contentIsScrollable = modalContentRef.current && modalContentRef.current.scrollHeight > modalContentRef.current.clientHeight;\n useReturnFocusOnUnmount(dialogRef);\n\n function handleKeyboardEvent(e: KeyboardEvent): void {\n if (e.key === 'Escape' && props.onClose) {\n e.stopPropagation();\n props.onClose();\n }\n }\n\n function handleClickEvent(event: MouseEvent): void {\n if (event.target && overlayRef.current === event.target && props.onClose) {\n event.stopPropagation();\n props.onClose();\n }\n }\n\n const overlayRef = React.useRef<HTMLDivElement>(null);\n\n const showActions = (props.secondaryButtonText && props.secondaryButtonText?.length > 0) || props.onSuccess || footerContent;\n\n const ariaLabelAttributes = getAriaLabelAttributes({ label: props.ariaLabel, id: props.ariaLabelledBy, fallbackId: titleId });\n\n useEffect(() => {\n const overlayElement = overlayRef.current;\n disableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.addEventListener('keydown', handleKeyboardEvent);\n overlayElement.addEventListener('click', handleClickEvent);\n }\n return (): void => {\n enableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.removeEventListener('keydown', handleKeyboardEvent);\n overlayElement.removeEventListener('click', handleClickEvent);\n }\n };\n }, [props.disableCloseEvents]);\n\n useEffect(() => {\n dialogRef.current?.focus();\n }, []);\n\n const dialogClasses = cn(\n className,\n styles.modal,\n variant && styles[`modal--${variant}`],\n size && styles[`modal--${size}`],\n contentIsScrollable && !showActions && styles['modal--no-actions']\n );\n\n const titleClasses = cn({\n [styles['modal__title--error']]: variant === ModalVariants.error,\n [styles['modal__title--success']]: variant === ModalVariants.success,\n });\n\n const Component = (\n <div data-testid=\"dialog-container\">\n <div\n ref={overlayRef}\n className={styles['modal-overlay']}\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.Modal}\n style={{ zIndex }}\n >\n <div className={styles.align}>\n <div className={dialogClasses} role={role} aria-modal=\"true\" tabIndex={-1} {...ariaLabelAttributes} ref={dialogRef}>\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--top'], {\n [styles['modal__shadow--show']]: !topContentVisible && contentIsScrollable,\n })}\n />\n <div\n className={cn(styles.modal__contentWrapper)}\n tabIndex={contentIsScrollable ? 0 : undefined}\n role={contentIsScrollable ? 'region' : undefined}\n {...(contentIsScrollable ? ariaLabelAttributes : {})}\n ref={modalContentRef}\n >\n {!props.noCloseButton && (\n <div className={styles.modal__closeWrapper}>\n <div className={cn(styles.modal__closeWrapper__close)}>\n <Close onClick={props.onClose} ariaLabel={props.ariaLabelCloseBtn} />\n </div>\n </div>\n )}\n <div className={cn(size && styles[`modal__contentWrapper__scroll--${size}`])}>\n <div ref={topContent} />\n <div className={styles.modal__contentWrapper__title}>\n {getIcon(variant, props.icon)}\n <Title id={ariaLabelAttributes?.['aria-labelledby']} htmlMarkup=\"h3\" appearance=\"title3\" className={titleClasses}>\n {props.title}\n </Title>\n {props.afterTitleChildren && <div className={styles['modal__afterTitleChildren']}>{props.afterTitleChildren}</div>}\n </div>\n {props.children && <div>{props.children}</div>}\n {!props.children && <p className={styles.modal__description}>{props.description}</p>}\n <div ref={bottomContent} />\n </div>\n </div>\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--bottom'], {\n [styles['modal__shadow--show']]: !bottomContentVisible && contentIsScrollable,\n })}\n />\n {showActions && (\n <div className={cn(styles['modal__call-to-action'], size && styles[`modal__call-to-action--${size}`])}>\n {props.onSuccess && primaryButtonText && <Button onClick={props.onSuccess}>{primaryButtonText}</Button>}\n {props.secondaryButtonText && props.secondaryButtonText?.length > 0 && (\n <Button variant=\"borderless\" onClick={props.onClose}>\n {props.secondaryButtonText}\n </Button>\n )}\n {footerContent}\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n );\n\n if (props.printable) {\n const printModal = 'print-modal';\n return (\n <Portal className={printModal} testId=\"print-modal\">\n <style media=\"print\">{`body > *:not(.${printModal}) {display: none;}`}</style>\n {Component}\n </Portal>\n );\n }\n\n return Component;\n};\n\nexport default Modal;\n","import Modal from './Modal';\nexport { ModalVariants, ModalSize } from './constants';\nexport * from './Modal';\nexport default Modal;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAY,gBAAA,yBAAA,iBAAL;AACL,iBAAA,YAAA;AACA,iBAAA,aAAA;AACA,iBAAA,WAAA;AACA,iBAAA,aAAA;;;AAGF,IAAY,YAAA,yBAAA,aAAL;AACL,aAAA,WAAA;AACA,aAAA,YAAA;;;ACmEF,IAAM,kBAAkB,YAA8D;AACpF,KAAI,YAAY,cAAc,MAC5B,QAAO,oBAAC,cAAA;EAAK,MAAM,SAAS;EAAO,SAAS;EAAe,OAAO,QAAQ;GAAa;UAC9E,YAAY,cAAc,QACnC,QAAO,oBAAC,cAAA;EAAK,MAAM,SAAS;EAAO,SAAS;EAAiB,OAAO,QAAQ;GAAS;UAC5E,YAAY,cAAc,QACnC,QAAO,oBAAC,cAAA;EAAK,MAAM,SAAS;EAAO,SAAS;EAAc,OAAO,QAAQ;GAAW;AAEtF,QAAO;;AAGT,IAAM,WAAW,SAAiC,SAAwD;CACxG,MAAM,cAAc,eAAe,QAAQ;AAC3C,KAAI,YACF,QAAO,oBAAC,OAAA;EAAI,WAAW,OAAO;YAAqB;GAAkB;AAEvE,KAAI,KACF,QACE,oBAAC,OAAA;EAAI,WAAW,OAAO;YACpB,YAAuB,MAAM,aAAK,IACjC,MAAM,aAAa,MAAM,EACvB,MAAM,SAAS,OAChB,CAAC;GACA;AAGV,QAAO;;AAGT,IAAMA,SAA8B,UAAS;CAC3C,MAAM,EACJ,eACA,UAAU,cAAc,QACxB,oBA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M,IAAI,sBAAsB;YAAoB,YAAW;YAAK,YAAW;YAAS,WAAW;sBACjG,MAAM;aACD;WACP,MAAM,sBAAsB,oBAAC,OAAA;YAAI,WAAW,OAAO;sBAA+B,MAAM;aAAyB;;WAC9G;SACL,MAAM,YAAY,oBAAC,OAAA,EAAA,UAAK,MAAM,UAAA,CAAe;SAC7C,CAAC,MAAM,YAAY,oBAAC,KAAA;UAAE,WAAW,OAAO;oBAAqB,MAAM;WAAgB;SACpF,oBAAC,OAAA,EAAI,KAAK,eAAA,CAAiB;;SACvB,CAAA;QACF;MACN,oBAAC,OAAA,EACC,WAAW,WAAG,OAAO,kBAAkB,OAAO,0BAA0B,GACrE,OAAO,yBAAyB,CAAC,wBAAwB,qBAC3D,CAAC,EAAA,CACF;MACD,eACC,qBAAC,OAAA;OAAI,WAAW,WAAG,OAAO,0BAA0B,QAAQ,OAAO,0BAA0B,QAAQ;;QAClG,MAAM,aAAa,qBAAqB,oBAAC,gBAAA;SAAO,SAAS,MAAM;mBAAY;UAA2B;QACtG,MAAM,uBAAuB,MAAM,qBAAqB,SAAS,KAChE,oBAAC,gBAAA;SAAO,SAAQ;SAAa,SAAS,MAAM;mBACzC,MAAM;UACA;QAEV;;QACG;;MAEJ;KACF;IACF;GACF;AAGR,KAAI,MAAM,WAAW;EACnB,MAAM,aAAa;AACnB,SACE,qBAAC,QAAA;GAAO,WAAW;GAAY,QAAO;cACpC,oBAAC,SAAA;IAAM,OAAM;cAAS,iBAAiB,WAAW;KAA4B,EAC7E,UAAA;IACM;;AAIb,QAAO;;AC7PT,IAAA,gBDgQe"}
1
+ {"version":3,"file":"index.js","names":["Modal: React.FC<ModalProps>"],"sources":["../../../src/components/Modal/constants.ts","../../../src/components/Modal/Modal.tsx","../../../src/components/Modal/index.ts"],"sourcesContent":["export enum ModalVariants {\n normal = 'normal',\n warning = 'warning',\n error = 'error',\n success = 'success',\n}\n\nexport enum ModalSize {\n large = 'large',\n medium = 'medium',\n}\n","import React, { useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport type { IconProps } from '../Icon';\n\nimport { ModalSize, ModalVariants } from './constants';\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport useFocusTrap from '../../hooks/useFocusTrap';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useReturnFocusOnUnmount } from '../../hooks/useReturnFocusOnUnmount';\nimport { palette } from '../../theme/palette';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { isComponent } from '../../utils/component';\nimport { disableBodyScroll, enableBodyScroll } from '../../utils/scroll';\nimport { uuid } from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport AlertSignFill from '../Icons/AlertSignFill';\nimport AlertSignStroke from '../Icons/AlertSignStroke';\nimport CheckOutline from '../Icons/CheckOutline';\nimport Portal from '../Portal';\nimport Title from '../Title/Title';\n\nimport styles from './styles.module.scss';\n\nexport interface ModalProps {\n /** Title of the modal */\n title: string;\n /** id of the modal title */\n titleId?: string;\n /** Description of the modal. Will not render if the modal has children. */\n description?: string;\n /** Optional footer content that can be rendered instead of default CTA(s) */\n footerContent?: React.ReactNode;\n /** Changes the visual representation of the modal */\n variant?: keyof typeof ModalVariants;\n /** Change width of the modal (default: large) */\n size?: keyof typeof ModalSize;\n /** Icon displayed in title */\n icon?: React.ReactElement;\n /** Hides the close button */\n noCloseButton?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Primary button text */\n primaryButtonText?: string;\n /** Secondary button text */\n secondaryButtonText?: string;\n /** Sets the aria-label of the modal */\n ariaLabel?: string;\n /** Sets the aria-labelledby of the modal */\n ariaLabelledBy?: string;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Alternative component to modal */\n children?: React.ReactNode;\n /** Component shown after title */\n afterTitleChildren?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Customize the z-index of the modal */\n zIndex?: number;\n /** Function is called when user clicks primary button */\n onSuccess?: () => void;\n /** Function is called when user clicks secondary button, clicks escape or outside the modal */\n onClose?: () => void;\n /** When enabled the component will be rendered in the bottom of document.body */\n printable?: boolean;\n /** If disabled, clicking escape or outside the modal will not close it */\n disableCloseEvents?: boolean;\n /** Aria role used for the Modal. Default is dialog */\n role?: 'dialog' | 'alertdialog';\n}\n\nconst getVariantIcon = (variant?: ModalProps['variant']): React.JSX.Element | null => {\n if (variant === ModalVariants.error) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignFill} color={palette.cherry500} />;\n } else if (variant === ModalVariants.warning) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignStroke} color={palette.black} />;\n } else if (variant === ModalVariants.success) {\n return <Icon size={IconSize.Small} svgIcon={CheckOutline} color={palette.kiwi900} />;\n }\n return null;\n};\n\nconst getIcon = (variant?: ModalProps['variant'], icon?: ModalProps['icon']): React.JSX.Element | null => {\n const variantIcon = getVariantIcon(variant);\n if (variantIcon) {\n return <div className={styles.modal__iconWrapper}>{variantIcon}</div>;\n }\n if (icon) {\n return (\n <div className={styles.modal__iconWrapper}>\n {isComponent<IconProps>(icon, Icon) &&\n React.cloneElement(icon, {\n size: IconSize.Small,\n })}\n </div>\n );\n }\n return null;\n};\n\nconst Modal: React.FC<ModalProps> = props => {\n const {\n footerContent,\n variant = ModalVariants.normal,\n primaryButtonText = 'OK',\n titleId = uuid(),\n className = '',\n size = ModalSize.large,\n zIndex = ZIndex.OverlayScreen,\n role = 'dialog',\n } = props;\n\n const topContent = React.useRef<HTMLDivElement>(null);\n const modalContentRef = React.useRef<HTMLDivElement>(null);\n const dialogRef = React.useRef<HTMLDivElement>(null);\n useFocusTrap(dialogRef, true);\n const topContentVisible = useIsVisible(topContent);\n const bottomContent = React.useRef<HTMLDivElement>(null);\n const bottomContentVisible = useIsVisible(bottomContent);\n const contentIsScrollable = modalContentRef.current && modalContentRef.current.scrollHeight > modalContentRef.current.clientHeight;\n useReturnFocusOnUnmount(dialogRef);\n\n function handleKeyboardEvent(e: KeyboardEvent): void {\n if (e.key === 'Escape' && props.onClose) {\n e.stopPropagation();\n props.onClose();\n }\n }\n\n function handleClickEvent(event: MouseEvent): void {\n if (event.target && overlayRef.current === event.target && props.onClose) {\n event.stopPropagation();\n props.onClose();\n }\n }\n\n const overlayRef = React.useRef<HTMLDivElement>(null);\n\n const showActions = (props.secondaryButtonText && props.secondaryButtonText?.length > 0) || props.onSuccess || footerContent;\n\n const ariaLabelAttributes = getAriaLabelAttributes({ label: props.ariaLabel, id: props.ariaLabelledBy, fallbackId: titleId });\n\n useEffect(() => {\n const overlayElement = overlayRef.current;\n disableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.addEventListener('keydown', handleKeyboardEvent);\n overlayElement.addEventListener('click', handleClickEvent);\n }\n return (): void => {\n enableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.removeEventListener('keydown', handleKeyboardEvent);\n overlayElement.removeEventListener('click', handleClickEvent);\n }\n };\n }, [props.disableCloseEvents]);\n\n useEffect(() => {\n dialogRef.current?.focus();\n }, []);\n\n const dialogClasses = cn(\n className,\n styles.modal,\n variant && styles[`modal--${variant}`],\n size && styles[`modal--${size}`],\n contentIsScrollable && !showActions && styles['modal--no-actions']\n );\n\n const titleClasses = cn({\n [styles['modal__title--error']]: variant === ModalVariants.error,\n [styles['modal__title--success']]: variant === ModalVariants.success,\n });\n\n const Component = (\n <div data-testid=\"dialog-container\">\n <div\n ref={overlayRef}\n className={styles['modal-overlay']}\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.Modal}\n style={{ zIndex }}\n >\n <div className={styles.align}>\n <div className={dialogClasses} role={role} aria-modal=\"true\" tabIndex={-1} {...ariaLabelAttributes} ref={dialogRef}>\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--top'], {\n [styles['modal__shadow--show']]: !topContentVisible && contentIsScrollable,\n })}\n />\n <div\n className={cn(styles.modal__contentWrapper)}\n tabIndex={contentIsScrollable ? 0 : undefined}\n role={contentIsScrollable ? 'region' : undefined}\n {...(contentIsScrollable ? ariaLabelAttributes : {})}\n ref={modalContentRef}\n >\n {!props.noCloseButton && (\n <div className={styles.modal__closeWrapper}>\n <div className={cn(styles.modal__closeWrapper__close)}>\n <Close onClick={props.onClose} ariaLabel={props.ariaLabelCloseBtn} />\n </div>\n </div>\n )}\n <div className={cn(size && styles[`modal__contentWrapper__scroll--${size}`])}>\n <div ref={topContent} />\n <div className={styles.modal__contentWrapper__title}>\n {getIcon(variant, props.icon)}\n <Title id={ariaLabelAttributes?.['aria-labelledby']} htmlMarkup=\"h3\" appearance=\"title3\" className={titleClasses}>\n {props.title}\n </Title>\n {props.afterTitleChildren && <div className={styles['modal__afterTitleChildren']}>{props.afterTitleChildren}</div>}\n </div>\n {props.children && <div>{props.children}</div>}\n {!props.children && <p className={styles.modal__description}>{props.description}</p>}\n <div ref={bottomContent} />\n </div>\n </div>\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--bottom'], {\n [styles['modal__shadow--show']]: !bottomContentVisible && contentIsScrollable,\n })}\n />\n {showActions && (\n <div className={cn(styles['modal__call-to-action'], size && styles[`modal__call-to-action--${size}`])}>\n {props.onSuccess && primaryButtonText && <Button onClick={props.onSuccess}>{primaryButtonText}</Button>}\n {props.secondaryButtonText && props.secondaryButtonText?.length > 0 && (\n <Button variant=\"borderless\" onClick={props.onClose}>\n {props.secondaryButtonText}\n </Button>\n )}\n {footerContent}\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n );\n\n if (props.printable) {\n const printModal = 'print-modal';\n return (\n <Portal className={printModal} testId=\"print-modal\">\n <style media=\"print\">{`body > *:not(.${printModal}) {display: none;}`}</style>\n {Component}\n </Portal>\n );\n }\n\n return Component;\n};\n\nexport default Modal;\n","import Modal from './Modal';\nexport { ModalVariants, ModalSize } from './constants';\nexport * from './Modal';\nexport default Modal;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAY,gBAAA,yBAAA,iBAAL;AACL,iBAAA,YAAA;AACA,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AO,0BAA0B,GACrE,OAAO,yBAAyB,CAAC,wBAAwB,qBAC3D,CAAC,EAAA,CACF;MACD,eACC,qBAAC,OAAA;OAAI,WAAW,GAAG,OAAO,0BAA0B,QAAQ,OAAO,0BAA0B,QAAQ;;QAClG,MAAM,aAAa,qBAAqB,oBAAC,gBAAA;SAAO,SAAS,MAAM;mBAAY;UAA2B;QACtG,MAAM,uBAAuB,MAAM,qBAAqB,SAAS,KAChE,oBAAC,gBAAA;SAAO,SAAQ;SAAa,SAAS,MAAM;mBACzC,MAAM;UACA;QAEV;;QACG;;MAEJ;KACF;IACF;GACF;AAGR,KAAI,MAAM,WAAW;EACnB,MAAM,aAAa;AACnB,SACE,qBAAC,QAAA;GAAO,WAAW;GAAY,QAAO;cACpC,oBAAC,SAAA;IAAM,OAAM;cAAS,iBAAiB,WAAW;KAA4B,EAC7E,UAAA;IACM;;AAIb,QAAO;;AC7PT,IAAA,gBDgQe"}
@@ -5,13 +5,13 @@ import { t as useIdWithFallback } from "../../useIdWithFallback.js";
5
5
  import { n as getAriaLabelAttributes } from "../../accessibility.js";
6
6
  import { t as Close_default } from "../../Close.js";
7
7
  import { t as Expander_default } from "../../Expander.js";
8
- import classNames from "classnames";
8
+ import cn from "classnames";
9
9
  import React from "react";
10
10
  import { jsx, jsxs } from "react/jsx-runtime";
11
11
  import styles from "./styles.module.scss";
12
12
  var FluidWrapper = ({ fluid, children }) => {
13
13
  if (fluid) return /* @__PURE__ */ jsx("div", {
14
- className: classNames(styles["fluid-wrapper"]),
14
+ className: cn(styles["fluid-wrapper"]),
15
15
  children
16
16
  });
17
17
  return children;
@@ -23,13 +23,13 @@ var NotificationPanel = (props) => {
23
23
  const isMobile = useIsMobileBreakpoint();
24
24
  const renderContent = () => {
25
25
  const outlineVariant = compactVariant === "outline";
26
- const contentClasses = classNames(styles["notification-panel__content"]);
27
- const labelClasses = classNames(styles["notification-panel__label"], {
26
+ const contentClasses = cn(styles["notification-panel__content"]);
27
+ const labelClasses = cn(styles["notification-panel__label"], {
28
28
  [styles["notification-panel__label--no-content"]]: !children && !expanderChildren,
29
29
  [styles["notification-panel__label--compact"]]: !!compactVariant,
30
30
  [styles["notification-panel__label--outline"]]: outlineVariant
31
31
  });
32
- const childrenClasses = classNames(styles["notification-panel__children"], {
32
+ const childrenClasses = cn(styles["notification-panel__children"], {
33
33
  [styles["notification-panel__children--with-label"]]: label,
34
34
  [styles["notification-panel__children--expander-no-label"]]: expanderChildren && !label,
35
35
  [styles["notification-panel__children--outline"]]: outlineVariant
@@ -57,7 +57,7 @@ var NotificationPanel = (props) => {
57
57
  ]
58
58
  });
59
59
  };
60
- const notificationPanelClasses = classNames(styles["notification-panel"], styles[`notification-panel--${variant}`], size && styles[`notification-panel--${size}`], {
60
+ const notificationPanelClasses = cn(styles["notification-panel"], styles[`notification-panel--${variant}`], size && styles[`notification-panel--${size}`], {
61
61
  [styles["notification-panel--compact"]]: !!compactVariant,
62
62
  [styles["notification-panel--compact--basic"]]: compactVariant === "basic",
63
63
  [styles["notification-panel--compact--outline"]]: compactVariant === "outline",
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["FluidWrapper: React.FC<WrapFluidProps>","NotificationPanel: React.FC<NotificationPanelProps>"],"sources":["../../../src/components/NotificationPanel/NotificationPanel.tsx","../../../src/components/NotificationPanel/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport NotificationBadge from '../Badge/NotificationBadge';\nimport Close from '../Close';\nimport Expander from '../Expander';\n\nimport styles from './styles.module.scss';\n\nexport type NotificationPanelVariants = 'info' | 'warn' | 'error' | 'success';\nexport type NotificationCompactVariants = 'basic' | 'outline';\nexport type NotificationPanelSizes = 'small' | 'medium' | 'large';\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'span';\n\nexport interface NotificationPanelProps {\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds inner child elements. */\n children?: React.ReactNode;\n /** Adds inner expander elements. */\n expanderChildren?: React.ReactNode;\n /** Text for expanderButton. */\n expanderButtonText?: string;\n /** Text for expanderButton when closed. */\n expanderButtonClosedText?: string;\n /** Makes expander be open from start. */\n expanderOpenFromStart?: boolean;\n /** Changes the visual representation of the notification panel. */\n variant?: NotificationPanelVariants;\n /** Makes the panel more compact. Available in basic and outline. */\n compactVariant?: NotificationCompactVariants;\n /** Sets a fixed size for the content container. */\n size?: NotificationPanelSizes;\n /** Used in combination with dismissiable property to close the notification panel. */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Toggles the close button in the top right corner. */\n dismissable?: boolean;\n /** Enables a fluid outer container that spans the entire width of parent. */\n fluid?: boolean;\n /** Sets a label for the notification panel. */\n label?: string;\n /** Changes the underlying element of the label. */\n labelHtmlMarkup?: LabelTags;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Custom id for the label */\n labelId?: string;\n /** Custom role for the panel. Default is no role. If variant is alert or crisis, the aria role will be set to \"alert\" unless the role-prop is also set. */\n role?: 'region' | 'alert' | 'status';\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the component */\n ref?: React.Ref<HTMLDivElement | null>;\n}\n\ntype WrapFluidProps = Pick<NotificationPanelProps, 'fluid'> & {\n children: React.ReactElement;\n};\n\nconst FluidWrapper: React.FC<WrapFluidProps> = ({ fluid, children }) => {\n if (fluid) {\n const fluidClasses = classNames(styles['fluid-wrapper']);\n\n return <div className={fluidClasses}>{children}</div>;\n }\n return children;\n};\n\nconst NotificationPanel: React.FC<NotificationPanelProps> = props => {\n const {\n children,\n variant = 'info',\n dismissable = false,\n onClick,\n expanderChildren,\n expanderButtonText,\n expanderButtonClosedText,\n expanderOpenFromStart = false,\n compactVariant,\n label,\n labelId: labelIdProp,\n labelHtmlMarkup = 'h1',\n fluid = false,\n size,\n className,\n role,\n testId,\n ref,\n } = props;\n const labelId = useIdWithFallback(labelIdProp);\n const [expanderOpen, setExpanderOpen] = React.useState(expanderOpenFromStart);\n const isMobile = useIsMobileBreakpoint();\n\n const renderContent = (): React.ReactNode => {\n const outlineVariant = compactVariant === 'outline';\n const contentClasses = classNames(styles['notification-panel__content']);\n const labelClasses = classNames(styles['notification-panel__label'], {\n [styles['notification-panel__label--no-content']]: !children && !expanderChildren,\n [styles['notification-panel__label--compact']]: !!compactVariant,\n [styles['notification-panel__label--outline']]: outlineVariant,\n });\n const childrenClasses = classNames(styles['notification-panel__children'], {\n [styles['notification-panel__children--with-label']]: label,\n [styles['notification-panel__children--expander-no-label']]: expanderChildren && !label,\n [styles['notification-panel__children--outline']]: outlineVariant,\n });\n const CustomTag = labelHtmlMarkup;\n\n return (\n <div className={contentClasses} id={!label ? labelId : undefined}>\n {label && (\n <CustomTag className={labelClasses} id={labelId}>\n {label}\n </CustomTag>\n )}\n {children && <div className={childrenClasses}>{children}</div>}\n {expanderChildren && expanderButtonText && expanderButtonClosedText && !compactVariant && (\n <Expander\n title={expanderOpen ? expanderButtonText : expanderButtonClosedText}\n onExpand={setExpanderOpen}\n expanded={expanderOpen}\n testId=\"expand\"\n >\n {expanderChildren}\n </Expander>\n )}\n </div>\n );\n };\n\n const notificationPanelClasses = classNames(\n styles['notification-panel'],\n styles[`notification-panel--${variant}`],\n size && styles[`notification-panel--${size}`],\n {\n [styles['notification-panel--compact']]: !!compactVariant,\n [styles['notification-panel--compact--basic']]: compactVariant === 'basic',\n [styles['notification-panel--compact--outline']]: compactVariant === 'outline',\n [styles['notification-panel--with-content']]: expanderChildren || (label && children),\n [styles['notification-panel--dismissable']]: dismissable,\n },\n className\n );\n\n const ariaRole = role || (variant === 'error' && 'alert') || undefined;\n const ariaLabelAttributes = ariaRole ? getAriaLabelAttributes({ label, id: labelId }) : undefined;\n\n return (\n <FluidWrapper fluid={fluid}>\n <div\n ref={ref}\n role={ariaRole}\n data-testid={testId}\n data-analyticsid={AnalyticsId.NotificationPanel}\n className={notificationPanelClasses}\n {...ariaLabelAttributes}\n >\n <NotificationBadge\n variant={variant}\n size={compactVariant || isMobile ? IconSize.XSmall : IconSize.Small}\n className={styles['notification-panel__icon']}\n />\n {dismissable && (\n <span className={styles['notification-panel__close']}>\n <Close ariaLabel={props.ariaLabelCloseBtn} onClick={onClick} color=\"black\" />\n </span>\n )}\n {renderContent()}\n </div>\n </FluidWrapper>\n );\n};\n\nexport default NotificationPanel;\n","import NotificationPanel from './NotificationPanel';\nexport * from './NotificationPanel';\nexport default NotificationPanel;\n"],"mappings":";;;;;;;;;;;AAgEA,IAAMA,gBAA0C,EAAE,OAAO,eAAe;AACtE,KAAI,MAGF,QAAO,oBAAC,OAAA;EAAI,WAFS,WAAW,OAAO,iBAAiB;EAElB;GAAe;AAEvD,QAAO;;AAGT,IAAMC,qBAAsD,UAAS;CACnE,MAAM,EACJ,UACA,UAAU,QACV,cAAc,OACd,SACA,kBACA,oBACA,0BACA,wBAAwB,OACxB,gBACA,OACA,SAAS,aACT,kBAAkB,MAClB,QAAQ,OACR,MACA,WACA,MACA,QACA,QACE;CACJ,MAAM,UAAU,kBAAkB,YAAY;CAC9C,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS,sBAAsB;CAC7E,MAAM,WAAW,uBAAuB;CAExC,MAAM,sBAAuC;EAC3C,MAAM,iBAAiB,mBAAmB;EAC1C,MAAM,iBAAiB,WAAW,OAAO,+BAA+B;EACxE,MAAM,eAAe,WAAW,OAAO,8BAA8B;IAClE,OAAO,2CAA2C,CAAC,YAAY,CAAC;IAChE,OAAO,wCAAwC,CAAC,CAAC;IACjD,OAAO,wCAAwC;GACjD,CAAC;EACF,MAAM,kBAAkB,WAAW,OAAO,iCAAiC;IACxE,OAAO,8CAA8C;IACrD,OAAO,qDAAqD,oBAAoB,CAAC;IACjF,OAAO,2CAA2C;GACpD,CAAC;AAGF,SACE,qBAAC,OAAA;GAAI,WAAW;GAAgB,IAAI,CAAC,QAAQ,UAAU,KAAA;;IACpD,SACC,oBALY,iBAKX;KAAU,WAAW;KAAc,IAAI;eACrC;MACS;IAEb,YAAY,oBAAC,OAAA;KAAI,WAAW;KAAkB;MAAe;IAC7D,oBAAoB,sBAAsB,4BAA4B,CAAC,kBACtE,oBAAC,kBAAA;KACC,OAAO,eAAe,qBAAqB;KAC3C,UAAU;KACV,UAAU;KACV,QAAO;eAEN;MACQ;;IAET;;CAIV,MAAM,2BAA2B,WAC/B,OAAO,uBACP,OAAO,uBAAuB,YAC9B,QAAQ,OAAO,uBAAuB,SACtC;GACG,OAAO,iCAAiC,CAAC,CAAC;GAC1C,OAAO,wCAAwC,mBAAmB;GAClE,OAAO,0CAA0C,mBAAmB;GACpE,OAAO,sCAAsC,oBAAqB,SAAS;GAC3E,OAAO,qCAAqC;EAC9C,EACD,UACD;CAED,MAAM,WAAW,QAAS,YAAY,WAAW,WAAY,KAAA;CAC7D,MAAM,sBAAsB,WAAW,uBAAuB;EAAE;EAAO,IAAI;EAAS,CAAC,GAAG,KAAA;AAExF,QACE,oBAAC,cAAA;EAAoB;YACnB,qBAAC,OAAA;GACM;GACL,MAAM;GACN,eAAa;GACb,oBAAkB,YAAY;GAC9B,WAAW;GACX,GAAI;;IAEJ,oBAAC,2BAAA;KACU;KACT,MAAM,kBAAkB,WAAW,SAAS,SAAS,SAAS;KAC9D,WAAW,OAAO;MAClB;IACD,eACC,oBAAC,QAAA;KAAK,WAAW,OAAO;eACtB,oBAAC,eAAA;MAAM,WAAW,MAAM;MAA4B;MAAS,OAAM;OAAU;MACxE;IAER,eAAe;;IACZ;GACO;;AC5KnB,IAAA,4BDgLe"}
1
+ {"version":3,"file":"index.js","names":["FluidWrapper: React.FC<WrapFluidProps>","NotificationPanel: React.FC<NotificationPanelProps>"],"sources":["../../../src/components/NotificationPanel/NotificationPanel.tsx","../../../src/components/NotificationPanel/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport NotificationBadge from '../Badge/NotificationBadge';\nimport Close from '../Close';\nimport Expander from '../Expander';\n\nimport styles from './styles.module.scss';\n\nexport type NotificationPanelVariants = 'info' | 'warn' | 'error' | 'success';\nexport type NotificationCompactVariants = 'basic' | 'outline';\nexport type NotificationPanelSizes = 'small' | 'medium' | 'large';\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'span';\n\nexport interface NotificationPanelProps {\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds inner child elements. */\n children?: React.ReactNode;\n /** Adds inner expander elements. */\n expanderChildren?: React.ReactNode;\n /** Text for expanderButton. */\n expanderButtonText?: string;\n /** Text for expanderButton when closed. */\n expanderButtonClosedText?: string;\n /** Makes expander be open from start. */\n expanderOpenFromStart?: boolean;\n /** Changes the visual representation of the notification panel. */\n variant?: NotificationPanelVariants;\n /** Makes the panel more compact. Available in basic and outline. */\n compactVariant?: NotificationCompactVariants;\n /** Sets a fixed size for the content container. */\n size?: NotificationPanelSizes;\n /** Used in combination with dismissiable property to close the notification panel. */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Toggles the close button in the top right corner. */\n dismissable?: boolean;\n /** Enables a fluid outer container that spans the entire width of parent. */\n fluid?: boolean;\n /** Sets a label for the notification panel. */\n label?: string;\n /** Changes the underlying element of the label. */\n labelHtmlMarkup?: LabelTags;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Custom id for the label */\n labelId?: string;\n /** Custom role for the panel. Default is no role. If variant is alert or crisis, the aria role will be set to \"alert\" unless the role-prop is also set. */\n role?: 'region' | 'alert' | 'status';\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the component */\n ref?: React.Ref<HTMLDivElement | null>;\n}\n\ntype WrapFluidProps = Pick<NotificationPanelProps, 'fluid'> & {\n children: React.ReactElement;\n};\n\nconst FluidWrapper: React.FC<WrapFluidProps> = ({ fluid, children }) => {\n if (fluid) {\n const fluidClasses = classNames(styles['fluid-wrapper']);\n\n return <div className={fluidClasses}>{children}</div>;\n }\n return children;\n};\n\nconst NotificationPanel: React.FC<NotificationPanelProps> = props => {\n const {\n children,\n variant = 'info',\n dismissable = false,\n onClick,\n expanderChildren,\n expanderButtonText,\n expanderButtonClosedText,\n expanderOpenFromStart = false,\n compactVariant,\n label,\n labelId: labelIdProp,\n labelHtmlMarkup = 'h1',\n fluid = false,\n size,\n className,\n role,\n testId,\n ref,\n } = props;\n const labelId = useIdWithFallback(labelIdProp);\n const [expanderOpen, setExpanderOpen] = React.useState(expanderOpenFromStart);\n const isMobile = useIsMobileBreakpoint();\n\n const renderContent = (): React.ReactNode => {\n const outlineVariant = compactVariant === 'outline';\n const contentClasses = classNames(styles['notification-panel__content']);\n const labelClasses = classNames(styles['notification-panel__label'], {\n [styles['notification-panel__label--no-content']]: !children && !expanderChildren,\n [styles['notification-panel__label--compact']]: !!compactVariant,\n [styles['notification-panel__label--outline']]: outlineVariant,\n });\n const childrenClasses = classNames(styles['notification-panel__children'], {\n [styles['notification-panel__children--with-label']]: label,\n [styles['notification-panel__children--expander-no-label']]: expanderChildren && !label,\n [styles['notification-panel__children--outline']]: outlineVariant,\n });\n const CustomTag = labelHtmlMarkup;\n\n return (\n <div className={contentClasses} id={!label ? labelId : undefined}>\n {label && (\n <CustomTag className={labelClasses} id={labelId}>\n {label}\n </CustomTag>\n )}\n {children && <div className={childrenClasses}>{children}</div>}\n {expanderChildren && expanderButtonText && expanderButtonClosedText && !compactVariant && (\n <Expander\n title={expanderOpen ? expanderButtonText : expanderButtonClosedText}\n onExpand={setExpanderOpen}\n expanded={expanderOpen}\n testId=\"expand\"\n >\n {expanderChildren}\n </Expander>\n )}\n </div>\n );\n };\n\n const notificationPanelClasses = classNames(\n styles['notification-panel'],\n styles[`notification-panel--${variant}`],\n size && styles[`notification-panel--${size}`],\n {\n [styles['notification-panel--compact']]: !!compactVariant,\n [styles['notification-panel--compact--basic']]: compactVariant === 'basic',\n [styles['notification-panel--compact--outline']]: compactVariant === 'outline',\n [styles['notification-panel--with-content']]: expanderChildren || (label && children),\n [styles['notification-panel--dismissable']]: dismissable,\n },\n className\n );\n\n const ariaRole = role || (variant === 'error' && 'alert') || undefined;\n const ariaLabelAttributes = ariaRole ? getAriaLabelAttributes({ label, id: labelId }) : undefined;\n\n return (\n <FluidWrapper fluid={fluid}>\n <div\n ref={ref}\n role={ariaRole}\n data-testid={testId}\n data-analyticsid={AnalyticsId.NotificationPanel}\n className={notificationPanelClasses}\n {...ariaLabelAttributes}\n >\n <NotificationBadge\n variant={variant}\n size={compactVariant || isMobile ? IconSize.XSmall : IconSize.Small}\n className={styles['notification-panel__icon']}\n />\n {dismissable && (\n <span className={styles['notification-panel__close']}>\n <Close ariaLabel={props.ariaLabelCloseBtn} onClick={onClick} color=\"black\" />\n </span>\n )}\n {renderContent()}\n </div>\n </FluidWrapper>\n );\n};\n\nexport default NotificationPanel;\n","import NotificationPanel from './NotificationPanel';\nexport * from './NotificationPanel';\nexport default NotificationPanel;\n"],"mappings":";;;;;;;;;;;AAgEA,IAAMA,gBAA0C,EAAE,OAAO,eAAe;AACtE,KAAI,MAGF,QAAO,oBAAC,OAAA;EAAI,WAFS,GAAW,OAAO,iBAAiB;EAElB;GAAe;AAEvD,QAAO;;AAGT,IAAMC,qBAAsD,UAAS;CACnE,MAAM,EACJ,UACA,UAAU,QACV,cAAc,OACd,SACA,kBACA,oBACA,0BACA,wBAAwB,OACxB,gBACA,OACA,SAAS,aACT,kBAAkB,MAClB,QAAQ,OACR,MACA,WACA,MACA,QACA,QACE;CACJ,MAAM,UAAU,kBAAkB,YAAY;CAC9C,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS,sBAAsB;C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A;KACU;KACT,MAAM,kBAAkB,WAAW,SAAS,SAAS,SAAS;KAC9D,WAAW,OAAO;MAClB;IACD,eACC,oBAAC,QAAA;KAAK,WAAW,OAAO;eACtB,oBAAC,eAAA;MAAM,WAAW,MAAM;MAA4B;MAAS,OAAM;OAAU;MACxE;IAER,eAAe;;IACZ;GACO;;AC5KnB,IAAA,4BDgLe"}
@@ -10,7 +10,7 @@ import { t as useExpand } from "../../useExpand.js";
10
10
  import { t as ChevronRight_default } from "../../ChevronRight.js";
11
11
  import { a as PanelVariant, i as PanelStatus, n as PanelLayout, r as PanelStacking, t as PanelListContext } from "../../utils5.js";
12
12
  import { t as PanelTitle_default } from "../../PanelTitle.js";
13
- import classNames from "classnames";
13
+ import cn from "classnames";
14
14
  import React from "react";
15
15
  import { jsx, jsxs } from "react/jsx-runtime";
16
16
  import styles from "./styles.module.scss";
@@ -30,7 +30,7 @@ const getResources = (language) => {
30
30
  }
31
31
  };
32
32
  var ExpandButton = ({ onClick, isExpanded, resources }) => {
33
- const buttonClassName = classNames(styles["expander__button"], isExpanded && styles["expander__button--expanded"]);
33
+ const buttonClassName = cn(styles["expander__button"], isExpanded && styles["expander__button--expanded"]);
34
34
  return /* @__PURE__ */ jsxs(Button_default, {
35
35
  variant: "borderless",
36
36
  textClassName: styles["expander__button__text"],
@@ -108,22 +108,22 @@ var PanelRoot = ({ layout = PanelLayout.vertical, variant = PanelVariant.fill, c
108
108
  }
109
109
  }, [isExpanded]);
110
110
  const colorScheme = effectiveVariant === PanelVariant.fill ? color : "white";
111
- const outerClassnames = classNames(effectiveClassName, {
111
+ const outerClassnames = cn(effectiveClassName, {
112
112
  [styles["panel__border--outline--outer"]]: effectiveVariant === PanelVariant.outline,
113
113
  [styles["panel__border--line"]]: effectiveVariant === PanelVariant.line,
114
114
  [styles["panel__border--fill--neutral"]]: effectiveVariant === PanelVariant.fill && colorScheme === "neutral",
115
115
  [styles["panel__border--fill--new"]]: effectiveVariant === PanelVariant.fill && status === PanelStatus.new,
116
116
  [styles["panel__border--fill--status"]]: effectiveVariant === PanelVariant.fill && status !== PanelStatus.none
117
117
  });
118
- const panelClassnames = classNames(styles["panel"], styles[`panel--${colorScheme}`], styles["panel--status"], {
118
+ const panelClassnames = cn(styles["panel"], styles[`panel--${colorScheme}`], styles["panel--status"], {
119
119
  [styles["panel--line"]]: effectiveVariant === PanelVariant.line,
120
120
  [styles["panel--new"]]: status === PanelStatus.new,
121
121
  [styles["panel--draft"]]: status === PanelStatus.draft,
122
122
  [styles["panel--error"]]: status === PanelStatus.error,
123
123
  [styles["panel--icon"]]: hasIcon
124
124
  });
125
- const contentContainerLayout = classNames(styles["panel__content"], styles[`panel__content--${layout}`], { [styles[`panel__content--b-first`]]: stacking === PanelStacking.bFirst });
126
- const expanderBorderLayout = classNames({
125
+ const contentContainerLayout = cn(styles["panel__content"], styles[`panel__content--${layout}`], { [styles[`panel__content--b-first`]]: stacking === PanelStacking.bFirst });
126
+ const expanderBorderLayout = cn({
127
127
  [styles["panel__expander__border--expanded"]]: isExpanded && status === PanelStatus.none,
128
128
  [styles[`panel__expander__border--not-expanded--${colorScheme}`]]: !isExpanded && status === PanelStatus.none,
129
129
  [styles[`panel__expander__border--not-expanded--line`]]: !isExpanded && status === PanelStatus.none && effectiveVariant === PanelVariant.line
@@ -134,7 +134,7 @@ var PanelRoot = ({ layout = PanelLayout.vertical, variant = PanelVariant.fill, c
134
134
  return expandableContent.length > 0 ? /* @__PURE__ */ jsx("div", {
135
135
  className: outerClassnames,
136
136
  children: /* @__PURE__ */ jsx("div", {
137
- className: classNames({ [styles["panel__border--outline--inner"]]: effectiveVariant === PanelVariant.outline }),
137
+ className: cn({ [styles["panel__border--outline--inner"]]: effectiveVariant === PanelVariant.outline }),
138
138
  children: /* @__PURE__ */ jsx("div", {
139
139
  className: expanderBorderLayout,
140
140
  children: /* @__PURE__ */ jsxs("div", {
@@ -174,7 +174,7 @@ var PanelRoot = ({ layout = PanelLayout.vertical, variant = PanelVariant.fill, c
174
174
  }) : /* @__PURE__ */ jsx("div", {
175
175
  className: outerClassnames,
176
176
  children: /* @__PURE__ */ jsx("div", {
177
- className: classNames({ [styles["panel__border--outline--inner"]]: effectiveVariant === PanelVariant.outline }),
177
+ className: cn({ [styles["panel__border--outline--inner"]]: effectiveVariant === PanelVariant.outline }),
178
178
  children: /* @__PURE__ */ jsxs("div", {
179
179
  className: panelClassnames,
180
180
  "data-testid": testId,
@@ -219,25 +219,25 @@ const PreContainer = ({ children }) => {
219
219
  };
220
220
  const A = ({ children }) => {
221
221
  return /* @__PURE__ */ jsx("div", {
222
- className: classNames(styles["panel__content__item"], styles["panel__content__item--a"]),
222
+ className: cn(styles["panel__content__item"], styles["panel__content__item--a"]),
223
223
  children
224
224
  });
225
225
  };
226
226
  const B = ({ children }) => {
227
227
  return /* @__PURE__ */ jsx("div", {
228
- className: classNames(styles["panel__content__item"], styles["panel__content__item--b"]),
228
+ className: cn(styles["panel__content__item"], styles["panel__content__item--b"]),
229
229
  children
230
230
  });
231
231
  };
232
232
  const C = ({ children }) => {
233
233
  return /* @__PURE__ */ jsx("div", {
234
- className: classNames(styles["panel__content__item"], styles["panel__content__item--c"]),
234
+ className: cn(styles["panel__content__item"], styles["panel__content__item--c"]),
235
235
  children
236
236
  });
237
237
  };
238
238
  const ExpandedContent = ({ children }) => {
239
239
  return /* @__PURE__ */ jsx("div", {
240
- className: classNames(styles["panel__expander__content"]),
240
+ className: cn(styles["panel__expander__content"]),
241
241
  children
242
242
  });
243
243
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["PanelRoot: React.FC<PanelProps>","mergedResources: HNDesignsystemPanel","newPreContainer: React.ReactNode[]","newTitle: React.ReactNode[]","newContent: React.ReactNode[]","newExpandableContent: React.ReactNode[]","PreContainer: React.FC<ContentProps>","A: React.FC<ContentProps>","B: React.FC<ContentProps>","C: React.FC<ContentProps>","ExpandedContent: React.FC<ContentProps>"],"sources":["../../../src/resources/HN.Designsystem.Panel.en-GB.json","../../../src/resources/HN.Designsystem.Panel.nb-NO.json","../../../src/components/Panel/resourceHelper.ts","../../../src/components/Panel/Panel.tsx","../../../src/components/Panel/index.ts"],"sourcesContent":["{\n \"expandButtonOpen\": \"See details\",\n \"expandButtonClose\": \"Hide details\"\n}\n","{\n \"expandButtonOpen\": \"Se detaljer\",\n \"expandButtonClose\": \"Skjul detaljer\"\n}\n","import type { HNDesignsystemPanel } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Panel.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Panel.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemPanel => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { PanelTitleProps } from './PanelTitle';\nimport type { HNDesignsystemPanel } from '../../resources/Resources';\nimport type { PaletteNames } from '../../theme/palette';\n\nimport { LanguageLocales } from '../../constants';\nimport { useExpand } from '../../hooks/useExpand';\nimport Button from '../Button';\nimport Icon, { IconSize } from '../Icon';\nimport { PanelLayout, PanelStacking, PanelStatus, PanelVariant } from './constants';\nimport PanelTitle from './PanelTitle';\nimport { getResources } from './resourceHelper';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { isComponent } from '../../utils/component';\nimport Highlighter from '../Highlighter';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronRight from '../Icons/ChevronRight';\nimport ChevronUp from '../Icons/ChevronUp';\nimport { PanelListContext } from '../PanelList/utils';\n\nimport styles from './styles.module.scss';\n\nexport type PanelColors = Extract<PaletteNames, 'white' | 'neutral'>;\n\nexport interface PanelProps {\n /** Aria label on call to action button */\n buttonBottomAriaLabel?: string;\n /** Sets the text on the bottom call to action button */\n buttonBottomText?: string;\n /** Sets the action on the bottom call to action button */\n buttonBottomOnClick?: () => void;\n /** Expands or collapses the panel. Only applicable when ExpandedContent is used */\n expanded?: boolean;\n /** Whether the panel can be focused */\n focusable?: boolean;\n /** Sets the layout and order of the content boxes */\n layout?: PanelLayout;\n /** Sets the visual variant of panel */\n variant?: PanelVariant;\n /** Sets the color for panel if it has variant fill */\n color?: PanelColors;\n /** Sets classes on the outermost container of the panel */\n className?: string;\n /** Action called when toggling expansion of ExpandedContent */\n onExpand?: (isExpanded?: boolean) => void;\n /** Sets the stacking order of the content boxes */\n stacking?: PanelStacking;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Children elements to be rendered inside the panel */\n children?: React.ReactNode;\n /** Displays a status on the left side: default normal */\n status?: PanelStatus;\n /** Resources for component */\n resources?: Partial<HNDesignsystemPanel>;\n /** Highlights text in title and content. Used for search results */\n highlightText?: string;\n /** Ref passed to the panel container */\n ref?: React.Ref<HTMLDivElement | null>;\n}\n\nconst ExpandButton = ({\n onClick,\n isExpanded,\n resources,\n}: {\n onClick: () => void;\n isExpanded: boolean | undefined;\n resources: Partial<HNDesignsystemPanel>;\n}): React.JSX.Element => {\n const buttonClassName = classNames(styles['expander__button'], isExpanded && styles['expander__button--expanded']);\n\n return (\n <Button\n variant=\"borderless\"\n textClassName={styles['expander__button__text']}\n wrapperClassName={buttonClassName}\n aria-expanded={isExpanded}\n onClick={onClick}\n >\n <Icon svgIcon={isExpanded ? ChevronUp : ChevronDown} size={IconSize.XSmall} />\n <span>{isExpanded ? resources.expandButtonClose : resources.expandButtonOpen}</span>\n </Button>\n );\n};\nconst PanelRoot: React.FC<PanelProps> = ({\n layout = PanelLayout.vertical,\n variant = PanelVariant.fill,\n color = 'neutral',\n stacking = PanelStacking.default,\n testId,\n children,\n expanded = false,\n focusable,\n status = PanelStatus.none,\n buttonBottomAriaLabel,\n buttonBottomOnClick,\n buttonBottomText,\n className,\n resources,\n onExpand,\n highlightText,\n ref,\n}: PanelProps) => {\n const panelListContext = React.useContext(PanelListContext);\n const [preContainer, setPreContainer] = React.useState<React.ReactNode[]>([]);\n const [title, setTitle] = React.useState<React.ReactNode[]>([]);\n const [content, setContent] = React.useState<React.ReactNode[]>([]);\n const [expandableContent, setExpandableContent] = React.useState<React.ReactNode[]>([]);\n const [hasIcon, setHasIcon] = React.useState(false);\n const [isExpanded, setIsExpanded] = useExpand(expanded, onExpand);\n const localRef = React.useRef<HTMLDivElement>(null);\n const panelRef = ref ?? localRef;\n const expandedContentRef = React.useRef<HTMLDivElement>(null);\n const defaultScroll = 100;\n\n // Use context values if available, otherwise use props\n const effectiveVariant = panelListContext?.variant ?? variant;\n const effectiveHighlightText = panelListContext?.highlightText ?? highlightText;\n const effectiveClassName = panelListContext?.applyPanelClassName(className) ?? className;\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemPanel = {\n ...defaultResources,\n ...resources,\n };\n\n React.useEffect(() => {\n let index = 0;\n let localHasIcon = false;\n const newPreContainer: React.ReactNode[] = [];\n const newTitle: React.ReactNode[] = [];\n const newContent: React.ReactNode[] = [];\n const newExpandableContent: React.ReactNode[] = [];\n\n React.Children.forEach(children, child => {\n if (React.isValidElement(child)) {\n const key = child.key ?? `panel-child-${index++}`;\n\n if (child.type === PreContainer) {\n newPreContainer.push(React.cloneElement(child, { key }));\n } else if (isComponent<PanelTitleProps>(child, PanelTitle)) {\n newTitle.push(\n React.cloneElement(child as React.ReactElement<PanelTitleProps>, {\n key,\n highlightText: child.props.highlightText || effectiveHighlightText,\n })\n );\n if (child.props.icon) {\n localHasIcon = true;\n }\n } else if (child.type === A || child.type === B || child.type === C) {\n newContent.push(React.cloneElement(child, { key }));\n } else if (child.type === ExpandedContent) {\n newExpandableContent.push(React.cloneElement(child, { key }));\n }\n }\n });\n\n setPreContainer(newPreContainer);\n setTitle(newTitle);\n setContent(newContent);\n setExpandableContent(newExpandableContent);\n setHasIcon(localHasIcon);\n }, [children]);\n\n React.useEffect(() => {\n if (expanded) {\n // Hvis panel åpnes controlled skal ikke scroll skje\n return;\n }\n // Scroller oppover når expanded content åpnes uncontrolled\n if (isExpanded) {\n if ('current' in panelRef && panelRef.current && expandedContentRef.current) {\n const panelRect = panelRef.current.getBoundingClientRect();\n const expandedContentRect = expandedContentRef.current.getBoundingClientRect();\n\n const scrollAmount = Math.min(defaultScroll, panelRect.top - 20);\n\n // Scroller kun oppover, og kun dersom expandedContent havner utenfor skjermen når åpnet\n if (scrollAmount > 0 && expandedContentRect.bottom > window.innerHeight) {\n const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n if (prefersReducedMotion) {\n return;\n }\n window.scrollBy({\n top: scrollAmount,\n behavior: 'smooth',\n });\n }\n }\n }\n }, [isExpanded]);\n\n const colorScheme = effectiveVariant === PanelVariant.fill ? color : 'white';\n\n const outerClassnames = classNames(effectiveClassName, {\n [styles['panel__border--outline--outer']]: effectiveVariant === PanelVariant.outline,\n [styles['panel__border--line']]: effectiveVariant === PanelVariant.line,\n [styles['panel__border--fill--neutral']]: effectiveVariant === PanelVariant.fill && colorScheme === 'neutral',\n [styles['panel__border--fill--new']]: effectiveVariant === PanelVariant.fill && status === PanelStatus.new,\n [styles['panel__border--fill--status']]: effectiveVariant === PanelVariant.fill && status !== PanelStatus.none,\n });\n const panelClassnames = classNames(styles['panel'], styles[`panel--${colorScheme}`], styles['panel--status'], {\n [styles['panel--line']]: effectiveVariant === PanelVariant.line,\n [styles['panel--new']]: status === PanelStatus.new,\n [styles['panel--draft']]: status === PanelStatus.draft,\n [styles['panel--error']]: status === PanelStatus.error,\n [styles['panel--icon']]: hasIcon,\n });\n const contentContainerLayout = classNames(styles['panel__content'], styles[`panel__content--${layout}`], {\n [styles[`panel__content--b-first`]]: stacking === PanelStacking.bFirst,\n });\n const expanderBorderLayout = classNames({\n [styles['panel__expander__border--expanded']]: isExpanded && status === PanelStatus.none,\n [styles[`panel__expander__border--not-expanded--${colorScheme}`]]: !isExpanded && status === PanelStatus.none,\n [styles[`panel__expander__border--not-expanded--line`]]:\n !isExpanded && status === PanelStatus.none && effectiveVariant === PanelVariant.line,\n });\n\n const handleExpandClick = (): void => {\n setIsExpanded(!isExpanded);\n };\n\n return expandableContent.length > 0 ? (\n <div className={outerClassnames}>\n <div className={classNames({ [styles['panel__border--outline--inner']]: effectiveVariant === PanelVariant.outline })}>\n <div className={expanderBorderLayout}>\n <div className={panelClassnames} data-testid={testId} ref={panelRef} tabIndex={focusable ? -1 : undefined}>\n <Highlighter searchText={effectiveHighlightText}>\n {preContainer}\n {title}\n </Highlighter>\n <div className={contentContainerLayout}>\n <Highlighter searchText={effectiveHighlightText}>{content}</Highlighter>\n </div>\n <ExpandButton onClick={handleExpandClick} isExpanded={isExpanded} resources={mergedResources} />\n {isExpanded && (\n <div ref={expandedContentRef} data-testid={testId + '-details'}>\n <div className={styles['panel__expander__separator']} />\n <Highlighter searchText={effectiveHighlightText}>{expandableContent}</Highlighter>\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n ) : (\n <div className={outerClassnames}>\n <div className={classNames({ [styles['panel__border--outline--inner']]: effectiveVariant === PanelVariant.outline })}>\n <div className={panelClassnames} data-testid={testId} ref={panelRef} tabIndex={focusable ? -1 : undefined}>\n <Highlighter searchText={effectiveHighlightText}>\n {preContainer}\n {title}\n </Highlighter>\n <div className={contentContainerLayout}>\n <Highlighter searchText={effectiveHighlightText}>{content}</Highlighter>\n </div>\n {buttonBottomText && buttonBottomOnClick && (\n <div className={styles['panel__button-bottom']}>\n <Button variant=\"borderless\" type=\"button\" size=\"medium\" onClick={buttonBottomOnClick} aria-label={buttonBottomAriaLabel}>\n {buttonBottomText}\n <Icon svgIcon={ChevronRight} size={IconSize.XSmall} />\n </Button>\n </div>\n )}\n </div>\n </div>\n </div>\n );\n};\n\nexport interface ContentProps {\n /** Children elements to be rendered inside the content box */\n children?: React.ReactNode;\n}\n\nexport const PreContainer: React.FC<ContentProps> = ({ children }) => {\n return <div className={styles['panel__pre-container']}>{children}</div>;\n};\n\nexport const A: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__content__item'], styles['panel__content__item--a']);\n return <div className={styling}>{children}</div>;\n};\n\nexport const B: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__content__item'], styles['panel__content__item--b']);\n return <div className={styling}>{children}</div>;\n};\n\nexport const C: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__content__item'], styles['panel__content__item--c']);\n return <div className={styling}>{children}</div>;\n};\n\nexport const ExpandedContent: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__expander__content']);\n return <div className={styling}>{children}</div>;\n};\n\ntype PanelComponent = typeof PanelRoot & {\n PreContainer: React.FC<ContentProps>;\n Title: React.FC<PanelTitleProps>;\n A: React.FC<ContentProps>;\n B: React.FC<ContentProps>;\n C: React.FC<ContentProps>;\n ExpandedContent: React.FC<ContentProps>;\n};\nPanelRoot.displayName = 'Panel';\nconst Panel = PanelRoot as PanelComponent;\nPanel.PreContainer = PreContainer;\nPanel.Title = PanelTitle;\nPanel.A = A;\nPanel.B = B;\nPanel.C = C;\nPanel.ExpandedContent = ExpandedContent;\n\nexport default Panel;\n","import Panel from './Panel';\nexport { PanelLayout, PanelStacking, PanelStatus, PanelVariant } from './constants';\nexport * from './Panel';\nexport default Panel;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AEMA,MAAa,gBAAgB,aAAmD;AAC9E,SAAQ,UAAR;EACE,KAAK,gBAAgB,QACnB,QAAO;EACT,KAAK,gBAAgB;EACrB,QACE,QAAO;;;ACoDb,IAAM,gBAAgB,EACpB,SACA,YACA,gBAKuB;CACvB,MAAM,kBAAkB,WAAW,OAAO,qBAAqB,cAAc,OAAO,8BAA8B;AAElH,QACE,qBAAC,gBAAA;EACC,SAAQ;EACR,eAAe,OAAO;EACtB,kBAAkB;EAClB,iBAAe;EACN;aAET,oBAAC,cAAA;GAAK,SAAS,aAAa,oBAAY;GAAa,MAAM,SAAS;IAAU,EAC9E,oBAAC,QAAA,EAAA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B;EAC7B;GAAe;;AAWlD,UAAU,cAAc;AACxB,IAAM,QAAQ;AACd,MAAM,eAAe;AACrB,MAAM,QAAQ;AACd,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,kBAAkB;AC9TxB,IAAA,gBDgUe"}
1
+ {"version":3,"file":"index.js","names":["PanelRoot: React.FC<PanelProps>","mergedResources: HNDesignsystemPanel","newPreContainer: React.ReactNode[]","newTitle: React.ReactNode[]","newContent: React.ReactNode[]","newExpandableContent: React.ReactNode[]","PreContainer: React.FC<ContentProps>","A: React.FC<ContentProps>","B: React.FC<ContentProps>","C: React.FC<ContentProps>","ExpandedContent: React.FC<ContentProps>"],"sources":["../../../src/resources/HN.Designsystem.Panel.en-GB.json","../../../src/resources/HN.Designsystem.Panel.nb-NO.json","../../../src/components/Panel/resourceHelper.ts","../../../src/components/Panel/Panel.tsx","../../../src/components/Panel/index.ts"],"sourcesContent":["{\n \"expandButtonOpen\": \"See details\",\n \"expandButtonClose\": \"Hide details\"\n}\n","{\n \"expandButtonOpen\": \"Se detaljer\",\n \"expandButtonClose\": \"Skjul detaljer\"\n}\n","import type { HNDesignsystemPanel } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Panel.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Panel.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemPanel => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { PanelTitleProps } from './PanelTitle';\nimport type { HNDesignsystemPanel } from '../../resources/Resources';\nimport type { PaletteNames } from '../../theme/palette';\n\nimport { LanguageLocales } from '../../constants';\nimport { useExpand } from '../../hooks/useExpand';\nimport Button from '../Button';\nimport Icon, { IconSize } from '../Icon';\nimport { PanelLayout, PanelStacking, PanelStatus, PanelVariant } from './constants';\nimport PanelTitle from './PanelTitle';\nimport { getResources } from './resourceHelper';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { isComponent } from '../../utils/component';\nimport Highlighter from '../Highlighter';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronRight from '../Icons/ChevronRight';\nimport ChevronUp from '../Icons/ChevronUp';\nimport { PanelListContext } from '../PanelList/utils';\n\nimport styles from './styles.module.scss';\n\nexport type PanelColors = Extract<PaletteNames, 'white' | 'neutral'>;\n\nexport interface PanelProps {\n /** Aria label on call to action button */\n buttonBottomAriaLabel?: string;\n /** Sets the text on the bottom call to action button */\n buttonBottomText?: string;\n /** Sets the action on the bottom call to action button */\n buttonBottomOnClick?: () => void;\n /** Expands or collapses the panel. Only applicable when ExpandedContent is used */\n expanded?: boolean;\n /** Whether the panel can be focused */\n focusable?: boolean;\n /** Sets the layout and order of the content boxes */\n layout?: PanelLayout;\n /** Sets the visual variant of panel */\n variant?: PanelVariant;\n /** Sets the color for panel if it has variant fill */\n color?: PanelColors;\n /** Sets classes on the outermost container of the panel */\n className?: string;\n /** Action called when toggling expansion of ExpandedContent */\n onExpand?: (isExpanded?: boolean) => void;\n /** Sets the stacking order of the content boxes */\n stacking?: PanelStacking;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Children elements to be rendered inside the panel */\n children?: React.ReactNode;\n /** Displays a status on the left side: default normal */\n status?: PanelStatus;\n /** Resources for component */\n resources?: Partial<HNDesignsystemPanel>;\n /** Highlights text in title and content. Used for search results */\n highlightText?: string;\n /** Ref passed to the panel container */\n ref?: React.Ref<HTMLDivElement | null>;\n}\n\nconst ExpandButton = ({\n onClick,\n isExpanded,\n resources,\n}: {\n onClick: () => void;\n isExpanded: boolean | undefined;\n resources: Partial<HNDesignsystemPanel>;\n}): React.JSX.Element => {\n const buttonClassName = classNames(styles['expander__button'], isExpanded && styles['expander__button--expanded']);\n\n return (\n <Button\n variant=\"borderless\"\n textClassName={styles['expander__button__text']}\n wrapperClassName={buttonClassName}\n aria-expanded={isExpanded}\n onClick={onClick}\n >\n <Icon svgIcon={isExpanded ? ChevronUp : ChevronDown} size={IconSize.XSmall} />\n <span>{isExpanded ? resources.expandButtonClose : resources.expandButtonOpen}</span>\n </Button>\n );\n};\nconst PanelRoot: React.FC<PanelProps> = ({\n layout = PanelLayout.vertical,\n variant = PanelVariant.fill,\n color = 'neutral',\n stacking = PanelStacking.default,\n testId,\n children,\n expanded = false,\n focusable,\n status = PanelStatus.none,\n buttonBottomAriaLabel,\n buttonBottomOnClick,\n buttonBottomText,\n className,\n resources,\n onExpand,\n highlightText,\n ref,\n}: PanelProps) => {\n const panelListContext = React.useContext(PanelListContext);\n const [preContainer, setPreContainer] = React.useState<React.ReactNode[]>([]);\n const [title, setTitle] = React.useState<React.ReactNode[]>([]);\n const [content, setContent] = React.useState<React.ReactNode[]>([]);\n const [expandableContent, setExpandableContent] = React.useState<React.ReactNode[]>([]);\n const [hasIcon, setHasIcon] = React.useState(false);\n const [isExpanded, setIsExpanded] = useExpand(expanded, onExpand);\n const localRef = React.useRef<HTMLDivElement>(null);\n const panelRef = ref ?? localRef;\n const expandedContentRef = React.useRef<HTMLDivElement>(null);\n const defaultScroll = 100;\n\n // Use context values if available, otherwise use props\n const effectiveVariant = panelListContext?.variant ?? variant;\n const effectiveHighlightText = panelListContext?.highlightText ?? highlightText;\n const effectiveClassName = panelListContext?.applyPanelClassName(className) ?? className;\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemPanel = {\n ...defaultResources,\n ...resources,\n };\n\n React.useEffect(() => {\n let index = 0;\n let localHasIcon = false;\n const newPreContainer: React.ReactNode[] = [];\n const newTitle: React.ReactNode[] = [];\n const newContent: React.ReactNode[] = [];\n const newExpandableContent: React.ReactNode[] = [];\n\n React.Children.forEach(children, child => {\n if (React.isValidElement(child)) {\n const key = child.key ?? `panel-child-${index++}`;\n\n if (child.type === PreContainer) {\n newPreContainer.push(React.cloneElement(child, { key }));\n } else if (isComponent<PanelTitleProps>(child, PanelTitle)) {\n newTitle.push(\n React.cloneElement(child as React.ReactElement<PanelTitleProps>, {\n key,\n highlightText: child.props.highlightText || effectiveHighlightText,\n })\n );\n if (child.props.icon) {\n localHasIcon = true;\n }\n } else if (child.type === A || child.type === B || child.type === C) {\n newContent.push(React.cloneElement(child, { key }));\n } else if (child.type === ExpandedContent) {\n newExpandableContent.push(React.cloneElement(child, { key }));\n }\n }\n });\n\n setPreContainer(newPreContainer);\n setTitle(newTitle);\n setContent(newContent);\n setExpandableContent(newExpandableContent);\n setHasIcon(localHasIcon);\n }, [children]);\n\n React.useEffect(() => {\n if (expanded) {\n // Hvis panel åpnes controlled skal ikke scroll skje\n return;\n }\n // Scroller oppover når expanded content åpnes uncontrolled\n if (isExpanded) {\n if ('current' in panelRef && panelRef.current && expandedContentRef.current) {\n const panelRect = panelRef.current.getBoundingClientRect();\n const expandedContentRect = expandedContentRef.current.getBoundingClientRect();\n\n const scrollAmount = Math.min(defaultScroll, panelRect.top - 20);\n\n // Scroller kun oppover, og kun dersom expandedContent havner utenfor skjermen når åpnet\n if (scrollAmount > 0 && expandedContentRect.bottom > window.innerHeight) {\n const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n if (prefersReducedMotion) {\n return;\n }\n window.scrollBy({\n top: scrollAmount,\n behavior: 'smooth',\n });\n }\n }\n }\n }, [isExpanded]);\n\n const colorScheme = effectiveVariant === PanelVariant.fill ? color : 'white';\n\n const outerClassnames = classNames(effectiveClassName, {\n [styles['panel__border--outline--outer']]: effectiveVariant === PanelVariant.outline,\n [styles['panel__border--line']]: effectiveVariant === PanelVariant.line,\n [styles['panel__border--fill--neutral']]: effectiveVariant === PanelVariant.fill && colorScheme === 'neutral',\n [styles['panel__border--fill--new']]: effectiveVariant === PanelVariant.fill && status === PanelStatus.new,\n [styles['panel__border--fill--status']]: effectiveVariant === PanelVariant.fill && status !== PanelStatus.none,\n });\n const panelClassnames = classNames(styles['panel'], styles[`panel--${colorScheme}`], styles['panel--status'], {\n [styles['panel--line']]: effectiveVariant === PanelVariant.line,\n [styles['panel--new']]: status === PanelStatus.new,\n [styles['panel--draft']]: status === PanelStatus.draft,\n [styles['panel--error']]: status === PanelStatus.error,\n [styles['panel--icon']]: hasIcon,\n });\n const contentContainerLayout = classNames(styles['panel__content'], styles[`panel__content--${layout}`], {\n [styles[`panel__content--b-first`]]: stacking === PanelStacking.bFirst,\n });\n const expanderBorderLayout = classNames({\n [styles['panel__expander__border--expanded']]: isExpanded && status === PanelStatus.none,\n [styles[`panel__expander__border--not-expanded--${colorScheme}`]]: !isExpanded && status === PanelStatus.none,\n [styles[`panel__expander__border--not-expanded--line`]]:\n !isExpanded && status === PanelStatus.none && effectiveVariant === PanelVariant.line,\n });\n\n const handleExpandClick = (): void => {\n setIsExpanded(!isExpanded);\n };\n\n return expandableContent.length > 0 ? (\n <div className={outerClassnames}>\n <div className={classNames({ [styles['panel__border--outline--inner']]: effectiveVariant === PanelVariant.outline })}>\n <div className={expanderBorderLayout}>\n <div className={panelClassnames} data-testid={testId} ref={panelRef} tabIndex={focusable ? -1 : undefined}>\n <Highlighter searchText={effectiveHighlightText}>\n {preContainer}\n {title}\n </Highlighter>\n <div className={contentContainerLayout}>\n <Highlighter searchText={effectiveHighlightText}>{content}</Highlighter>\n </div>\n <ExpandButton onClick={handleExpandClick} isExpanded={isExpanded} resources={mergedResources} />\n {isExpanded && (\n <div ref={expandedContentRef} data-testid={testId + '-details'}>\n <div className={styles['panel__expander__separator']} />\n <Highlighter searchText={effectiveHighlightText}>{expandableContent}</Highlighter>\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n ) : (\n <div className={outerClassnames}>\n <div className={classNames({ [styles['panel__border--outline--inner']]: effectiveVariant === PanelVariant.outline })}>\n <div className={panelClassnames} data-testid={testId} ref={panelRef} tabIndex={focusable ? -1 : undefined}>\n <Highlighter searchText={effectiveHighlightText}>\n {preContainer}\n {title}\n </Highlighter>\n <div className={contentContainerLayout}>\n <Highlighter searchText={effectiveHighlightText}>{content}</Highlighter>\n </div>\n {buttonBottomText && buttonBottomOnClick && (\n <div className={styles['panel__button-bottom']}>\n <Button variant=\"borderless\" type=\"button\" size=\"medium\" onClick={buttonBottomOnClick} aria-label={buttonBottomAriaLabel}>\n {buttonBottomText}\n <Icon svgIcon={ChevronRight} size={IconSize.XSmall} />\n </Button>\n </div>\n )}\n </div>\n </div>\n </div>\n );\n};\n\nexport interface ContentProps {\n /** Children elements to be rendered inside the content box */\n children?: React.ReactNode;\n}\n\nexport const PreContainer: React.FC<ContentProps> = ({ children }) => {\n return <div className={styles['panel__pre-container']}>{children}</div>;\n};\n\nexport const A: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__content__item'], styles['panel__content__item--a']);\n return <div className={styling}>{children}</div>;\n};\n\nexport const B: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__content__item'], styles['panel__content__item--b']);\n return <div className={styling}>{children}</div>;\n};\n\nexport const C: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__content__item'], styles['panel__content__item--c']);\n return <div className={styling}>{children}</div>;\n};\n\nexport const ExpandedContent: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__expander__content']);\n return <div className={styling}>{children}</div>;\n};\n\ntype PanelComponent = typeof PanelRoot & {\n PreContainer: React.FC<ContentProps>;\n Title: React.FC<PanelTitleProps>;\n A: React.FC<ContentProps>;\n B: React.FC<ContentProps>;\n C: React.FC<ContentProps>;\n ExpandedContent: React.FC<ContentProps>;\n};\nPanelRoot.displayName = 'Panel';\nconst Panel = PanelRoot as PanelComponent;\nPanel.PreContainer = PreContainer;\nPanel.Title = PanelTitle;\nPanel.A = A;\nPanel.B = B;\nPanel.C = C;\nPanel.ExpandedContent = ExpandedContent;\n\nexport default Panel;\n","import Panel from './Panel';\nexport { PanelLayout, PanelStacking, PanelStatus, PanelVariant }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W,OAAO;EAA0B;GAAe;;AAGzE,MAAaC,KAA6B,EAAE,eAAe;AAEzD,QAAO,oBAAC,OAAA;EAAI,WADI,GAAW,OAAO,yBAAyB,OAAO,2BAA2B;EAC5D;GAAe;;AAGlD,MAAaC,KAA6B,EAAE,eAAe;AAEzD,QAAO,oBAAC,OAAA;EAAI,WADI,GAAW,OAAO,yBAAyB,OAAO,2BAA2B;EAC5D;GAAe;;AAGlD,MAAaC,KAA6B,EAAE,eAAe;AAEzD,QAAO,oBAAC,OAAA;EAAI,WADI,GAAW,OAAO,yBAAyB,OAAO,2BAA2B;EAC5D;GAAe;;AAGlD,MAAaC,mBAA2C,EAAE,eAAe;AAEvE,QAAO,oBAAC,OAAA;EAAI,WADI,GAAW,OAAO,4BAA4B;EAC7B;GAAe;;AAWlD,UAAU,cAAc;AACxB,IAAM,QAAQ;AACd,MAAM,eAAe;AACrB,MAAM,QAAQ;AACd,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,kBAAkB;AC9TxB,IAAA,gBDgUe"}
@@ -1,6 +1,6 @@
1
1
  import { n as AnalyticsId } from "../../constants2.js";
2
2
  import { a as PanelVariant, t as PanelListContext } from "../../utils5.js";
3
- import classNames from "classnames";
3
+ import cn from "classnames";
4
4
  import React from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import styles from "./styles.module.scss";
@@ -9,7 +9,7 @@ var PanelList = (props) => {
9
9
  const contextValue = React.useMemo(() => ({
10
10
  variant,
11
11
  highlightText,
12
- applyPanelClassName: (existingClassName) => classNames(existingClassName, styles[`panel-list__panel--${variant}`])
12
+ applyPanelClassName: (existingClassName) => cn(existingClassName, styles[`panel-list__panel--${variant}`])
13
13
  }), [variant, highlightText]);
14
14
  return /* @__PURE__ */ jsx(PanelListContext.Provider, {
15
15
  value: contextValue,
@@ -17,7 +17,7 @@ var PanelList = (props) => {
17
17
  ref,
18
18
  "data-testid": testId,
19
19
  "data-analyticsid": AnalyticsId.PanelList,
20
- className: classNames({ [styles["panel-list--outline"]]: variant === PanelVariant.outline }),
20
+ className: cn({ [styles["panel-list--outline"]]: variant === PanelVariant.outline }),
21
21
  children
22
22
  })
23
23
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["PanelList: React.FC<PanelListProps>","contextValue: PanelListContextValue"],"sources":["../../../src/components/PanelList/PanelList.tsx","../../../src/components/PanelList/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { PanelListContext, type PanelListContextValue } from './utils';\nimport { AnalyticsId } from '../../constants';\nimport { PanelVariant } from '../Panel/constants';\n\nimport styles from './styles.module.scss';\n\nexport interface PanelListProps {\n /** Panels to render inside the PanelList */\n children?: React.ReactNode;\n /** Changes the visual representation of the panel. Default: fill */\n variant?: PanelVariant;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Highlights text in title and content. Used for search results */\n highlightText?: string;\n /** Ref passed to the container element */\n ref?: React.Ref<HTMLDivElement | null>;\n}\n\nconst PanelList: React.FC<PanelListProps> = (props: PanelListProps) => {\n const { testId, children, variant = PanelVariant.fill, highlightText, ref } = props;\n\n const contextValue: PanelListContextValue = React.useMemo(\n () => ({\n variant,\n highlightText,\n applyPanelClassName: (existingClassName?: string) => classNames(existingClassName, styles[`panel-list__panel--${variant}`]),\n }),\n [variant, highlightText]\n );\n\n return (\n <PanelListContext.Provider value={contextValue}>\n <div\n ref={ref}\n data-testid={testId}\n data-analyticsid={AnalyticsId.PanelList}\n className={classNames({ [styles['panel-list--outline']]: variant === PanelVariant.outline })}\n >\n {children}\n </div>\n </PanelListContext.Provider>\n );\n};\n\nexport default PanelList;\n","import PanelList from './PanelList';\nexport * from './PanelList';\nexport * from './utils';\nexport default PanelList;\n"],"mappings":";;;;;;AAuBA,IAAMA,aAAuC,UAA0B;CACrE,MAAM,EAAE,QAAQ,UAAU,UAAU,aAAa,MAAM,eAAe,QAAQ;CAE9E,MAAMC,eAAsC,MAAM,eACzC;EACL;EACA;EACA,sBAAsB,sBAA+B,WAAW,mBAAmB,OAAO,sBAAsB,WAAW;EAC5H,GACD,CAAC,SAAS,cAAc,CACzB;AAED,QACE,oBAAC,iBAAiB,UAAA;EAAS,OAAO;YAChC,oBAAC,OAAA;GACM;GACL,eAAa;GACb,oBAAkB,YAAY;GAC9B,WAAW,WAAW,GAAG,OAAO,yBAAyB,YAAY,aAAa,SAAS,CAAC;GAE3F;IACG;GACoB;;AC1ChC,IAAA,oBD8Ce"}
1
+ {"version":3,"file":"index.js","names":["PanelList: React.FC<PanelListProps>","contextValue: PanelListContextValue"],"sources":["../../../src/components/PanelList/PanelList.tsx","../../../src/components/PanelList/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { PanelListContext, type PanelListContextValue } from './utils';\nimport { AnalyticsId } from '../../constants';\nimport { PanelVariant } from '../Panel/constants';\n\nimport styles from './styles.module.scss';\n\nexport interface PanelListProps {\n /** Panels to render inside the PanelList */\n children?: React.ReactNode;\n /** Changes the visual representation of the panel. Default: fill */\n variant?: PanelVariant;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Highlights text in title and content. Used for search results */\n highlightText?: string;\n /** Ref passed to the container element */\n ref?: React.Ref<HTMLDivElement | null>;\n}\n\nconst PanelList: React.FC<PanelListProps> = (props: PanelListProps) => {\n const { testId, children, variant = PanelVariant.fill, highlightText, ref } = props;\n\n const contextValue: PanelListContextValue = React.useMemo(\n () => ({\n variant,\n highlightText,\n applyPanelClassName: (existingClassName?: string) => classNames(existingClassName, styles[`panel-list__panel--${variant}`]),\n }),\n [variant, highlightText]\n );\n\n return (\n <PanelListContext.Provider value={contextValue}>\n <div\n ref={ref}\n data-testid={testId}\n data-analyticsid={AnalyticsId.PanelList}\n className={classNames({ [styles['panel-list--outline']]: variant === PanelVariant.outline })}\n >\n {children}\n </div>\n </PanelListContext.Provider>\n );\n};\n\nexport default PanelList;\n","import PanelList from './PanelList';\nexport * from './PanelList';\nexport * from './utils';\nexport default PanelList;\n"],"mappings":";;;;;;AAuBA,IAAMA,aAAuC,UAA0B;CACrE,MAAM,EAAE,QAAQ,UAAU,UAAU,aAAa,MAAM,eAAe,QAAQ;CAE9E,MAAMC,eAAsC,MAAM,eACzC;EACL;EACA;EACA,sBAAsB,sBAA+B,GAAW,mBAAmB,OAAO,sBAAsB,WAAW;EAC5H,GACD,CAAC,SAAS,cAAc,CACzB;AAED,QACE,oBAAC,iBAAiB,UAAA;EAAS,OAAO;YAChC,oBAAC,OAAA;GACM;GACL,eAAa;GACb,oBAAkB,YAAY;GAC9B,WAAW,GAAW,GAAG,OAAO,yBAAyB,YAAY,aAAa,SAAS,CAAC;GAE3F;IACG;GACoB;;AC1ChC,IAAA,oBD8Ce"}
@@ -10,7 +10,7 @@ import { t as X_default } from "../../X.js";
10
10
  import { t as PopOver_default } from "../../PopOver.js";
11
11
  import { t as VerticalDots_default } from "../../VerticalDots.js";
12
12
  import { t as LinkList_default } from "../../LinkList.js";
13
- import classNames from "classnames";
13
+ import cn from "classnames";
14
14
  import React, { useRef, useState } from "react";
15
15
  import { jsx, jsxs } from "react/jsx-runtime";
16
16
  import styles from "./styles.module.scss";
@@ -44,7 +44,7 @@ const PopMenu = (props) => {
44
44
  const renderChildren = () => {
45
45
  if (isComponent(children, LinkList_default)) return /* @__PURE__ */ jsx(PopOver_default, {
46
46
  testId: popOverTestId,
47
- className: classNames(styles["pop-menu__pop-over"], popOverClassName),
47
+ className: cn(styles["pop-menu__pop-over"], popOverClassName),
48
48
  controllerRef: iconRef,
49
49
  role: "dialog",
50
50
  show: isOpen,
@@ -77,7 +77,7 @@ const PopMenu = (props) => {
77
77
  });
78
78
  return /* @__PURE__ */ jsxs("div", {
79
79
  ref: outerRef,
80
- className: classNames(popMenuClassName),
80
+ className: cn(popMenuClassName),
81
81
  "data-analyticsid": AnalyticsId.PopMenu,
82
82
  children: [/* @__PURE__ */ jsxs(Button_default, {
83
83
  variant: "borderless",
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["PopMenu: React.FC<PopMenuProps>"],"sources":["../../../src/components/PopMenu/constants.ts","../../../src/components/PopMenu/PopMenu.tsx","../../../src/components/PopMenu/index.ts"],"sourcesContent":["export enum PopMenuVariant {\n onWhite = 'on-white',\n onGray = 'on-gray',\n onBlueberry = 'on-blueberry',\n}\n\nexport enum PopMenuLabelPosition {\n right = 'right',\n left = 'left',\n}\n","import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { SvgIcon } from '../Icon';\nimport type { IconName } from '../Icons/IconNames';\nimport type { LinkListProps, LinkProps } from '../LinkList';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { isComponent } from '../../utils/component';\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport VerticalDots from '../Icons/VerticalDots';\nimport X from '../Icons/X';\nimport LazyIcon from '../LazyIcon';\nimport LinkList from '../LinkList';\nimport PopOver from '../PopOver';\nimport { PopMenuLabelPosition, type PopMenuVariant } from './constants';\n\nimport styles from './styles.module.scss';\n\nexport interface PopMenuProps {\n /** Content shown inside PopOver. Can only be a LinkList */\n children: React.ReactElement<LinkListProps>;\n /** Adds custom classes to the popover element. */\n popOverClassName?: string;\n /** Adds custom classes to the element. */\n popMenuClassName?: string;\n /** @deprecated Changes responsive design for the trigger buttons. */\n popMenuVariant?: PopMenuVariant;\n /** Sets the data-testid attribute for the button that opens. */\n openButtonTestId?: string;\n /** Sets the data-testid attribute for the button that closes. */\n closeButtonTestId?: string;\n /** Sets the data-testid attribute for the popover. */\n popOverTestId?: string;\n /** Sets the arial-label attribute for the openButton. */\n openButtonAriaLabel?: string;\n /** Sets the arial-label attribute for the closeButton. */\n closeButtonAriaLabel?: string;\n /** Sets the icon on the trigger button. */\n svgIcon?: SvgIcon | IconName;\n /** Optional text next to the trigger button. */\n labelText?: string;\n /** Placement of the label text relative to the trigger button. */\n labelTextPosition?: PopMenuLabelPosition;\n}\n\nexport const PopMenu: React.FC<PopMenuProps> = (props: PopMenuProps) => {\n const triggerButtonRef = useRef<HTMLButtonElement>(null);\n const iconRef = useRef(null);\n const outerRef = useRef<HTMLDivElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n const {\n children,\n popOverClassName,\n popMenuClassName,\n openButtonTestId,\n closeButtonTestId,\n popOverTestId,\n openButtonAriaLabel,\n closeButtonAriaLabel,\n svgIcon,\n labelText,\n labelTextPosition = PopMenuLabelPosition.right,\n } = props;\n const isMobile = useIsMobileBreakpoint();\n\n useOutsideEvent(outerRef, () => {\n setIsOpen(false);\n });\n\n const { isHovered: triggerButtonIsHovered } = usePseudoClasses(triggerButtonRef);\n const mobileIconSize = isMobile ? IconSize.XSmall : IconSize.Small;\n\n const handleClick = (cb?: () => void): void => {\n setIsOpen(false);\n if (cb) cb();\n };\n\n const renderChildren = (): React.ReactElement | undefined => {\n if (isComponent<LinkListProps>(children, LinkList)) {\n return (\n <PopOver\n testId={popOverTestId}\n className={classNames(styles['pop-menu__pop-over'], popOverClassName)}\n controllerRef={iconRef}\n role=\"dialog\"\n show={isOpen}\n >\n {React.Children.map(children, child =>\n React.cloneElement(child, {\n children: React.Children.map(child.props.children, child =>\n isComponent<LinkProps>(child, LinkList.Link)\n ? React.cloneElement(child, {\n onClick: (event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) =>\n handleClick(() => child.props.onClick && child.props.onClick(event)),\n })\n : child\n ),\n })\n )}\n </PopOver>\n );\n }\n };\n\n const toggleOpenOnClick = (): void => {\n setIsOpen(!isOpen);\n };\n\n const iconComponent =\n svgIcon && typeof svgIcon === 'string' ? (\n <LazyIcon iconName={svgIcon} size={IconSize.XSmall} isHovered={triggerButtonIsHovered} />\n ) : (\n svgIcon && <Icon svgIcon={svgIcon} size={IconSize.XSmall} isHovered={triggerButtonIsHovered} />\n );\n\n const openIcon = svgIcon ? (\n iconComponent\n ) : (\n <Icon ref={iconRef} svgIcon={svgIcon ?? VerticalDots} size={mobileIconSize} isHovered={triggerButtonIsHovered} />\n );\n\n const closeIcon = <Icon svgIcon={X} ref={iconRef} size={mobileIconSize} isHovered={triggerButtonIsHovered} />;\n\n return (\n <div ref={outerRef} className={classNames(popMenuClassName)} data-analyticsid={AnalyticsId.PopMenu}>\n <Button\n variant=\"borderless\"\n aria-expanded={isOpen}\n onClick={toggleOpenOnClick}\n ref={triggerButtonRef}\n ariaLabel={isOpen ? closeButtonAriaLabel : openButtonAriaLabel}\n testId={isOpen ? closeButtonTestId : openButtonTestId}\n >\n {labelText && labelTextPosition == PopMenuLabelPosition.left && <span>{labelText}</span>}\n {isOpen ? closeIcon : openIcon}\n {labelText && labelTextPosition == PopMenuLabelPosition.right && <span>{labelText}</span>}\n </Button>\n {isOpen && renderChildren()}\n </div>\n );\n};\n\nexport default PopMenu;\n","import PopMenu from './PopMenu';\nexport { PopMenuVariant, PopMenuLabelPosition } from './constants';\nexport * from './PopMenu';\nexport default PopMenu;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAY,iBAAA,yBAAA,kBAAL;AACL,kBAAA,aAAA;AACA,kBAAA,YAAA;AACA,kBAAA,iBAAA;;;AAGF,IAAY,uBAAA,yBAAA,wBAAL;AACL,wBAAA,WAAA;AACA,wBAAA,UAAA;;;AC2CF,MAAaA,WAAmC,UAAwB;CACtE,MAAM,mBAAmB,OAA0B,KAAK;CACxD,MAAM,UAAU,OAAO,KAAK;CAC5B,MAAM,WAAW,OAAuB,KAAK;CAC7C,MAAM,CAAC,QAAQ,aAAa,SAAS,MAAM;CAC3C,MAAM,EACJ,UACA,kBACA,kBACA,kBACA,mBACA,eACA,qBACA,sBACA,SACA,WACA,oBAAoB,qBAAqB,UACvC;CACJ,MAAM,WAAW,uBAAuB;AAExC,iBAAgB,gBAAgB;AAC9B,YAAU,MAAM;GAChB;CAEF,MAAM,EAAE,WAAW,2BAA2B,iB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,QAAQ,oBAAC,QAAA,EAAA,UAAM,WAAA,CAAiB;IACvF,SAAS,YAAY;IACrB,aAAa,qBAAqB,qBAAqB,SAAS,oBAAC,QAAA,EAAA,UAAM,WAAA,CAAiB;;IAClF,EACR,UAAU,gBAAgB,CAAA;GACvB;;AC7IV,IAAA,kBDiJe"}
1
+ {"version":3,"file":"index.js","names":["PopMenu: React.FC<PopMenuProps>"],"sources":["../../../src/components/PopMenu/constants.ts","../../../src/components/PopMenu/PopMenu.tsx","../../../src/components/PopMenu/index.ts"],"sourcesContent":["export enum PopMenuVariant {\n onWhite = 'on-white',\n onGray = 'on-gray',\n onBlueberry = 'on-blueberry',\n}\n\nexport enum PopMenuLabelPosition {\n right = 'right',\n left = 'left',\n}\n","import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { SvgIcon } from '../Icon';\nimport type { IconName } from '../Icons/IconNames';\nimport type { LinkListProps, LinkProps } from '../LinkList';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { isComponent } from '../../utils/component';\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport VerticalDots from '../Icons/VerticalDots';\nimport X from '../Icons/X';\nimport LazyIcon from '../LazyIcon';\nimport LinkList from '../LinkList';\nimport PopOver from '../PopOver';\nimport { PopMenuLabelPosition, type PopMenuVariant } from './constants';\n\nimport styles from './styles.module.scss';\n\nexport interface PopMenuProps {\n /** Content shown inside PopOver. Can only be a LinkList */\n children: React.ReactElement<LinkListProps>;\n /** Adds custom classes to the popover element. */\n popOverClassName?: string;\n /** Adds custom classes to the element. */\n popMenuClassName?: string;\n /** @deprecated Changes responsive design for the trigger buttons. */\n popMenuVariant?: PopMenuVariant;\n /** Sets the data-testid attribute for the button that opens. */\n openButtonTestId?: string;\n /** Sets the data-testid attribute for the button that closes. */\n closeButtonTestId?: string;\n /** Sets the data-testid attribute for the popover. */\n popOverTestId?: string;\n /** Sets the arial-label attribute for the openButton. */\n openButtonAriaLabel?: string;\n /** Sets the arial-label attribute for the closeButton. */\n closeButtonAriaLabel?: string;\n /** Sets the icon on the trigger button. */\n svgIcon?: SvgIcon | IconName;\n /** Optional text next to the trigger button. */\n labelText?: string;\n /** Placement of the label text relative to the trigger button. */\n labelTextPosition?: PopMenuLabelPosition;\n}\n\nexport const PopMenu: React.FC<PopMenuProps> = (props: PopMenuProps) => {\n const triggerButtonRef = useRef<HTMLButtonElement>(null);\n const iconRef = useRef(null);\n const outerRef = useRef<HTMLDivElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n const {\n children,\n popOverClassName,\n popMenuClassName,\n openButtonTestId,\n closeButtonTestId,\n popOverTestId,\n openButtonAriaLabel,\n closeButtonAriaLabel,\n svgIcon,\n labelText,\n labelTextPosition = PopMenuLabelPosition.right,\n } = props;\n const isMobile = useIsMobileBreakpoint();\n\n useOutsideEvent(outerRef, () => {\n setIsOpen(false);\n });\n\n const { isHovered: triggerButtonIsHovered } = usePseudoClasses(triggerButtonRef);\n const mobileIconSize = isMobile ? IconSize.XSmall : IconSize.Small;\n\n const handleClick = (cb?: () => void): void => {\n setIsOpen(false);\n if (cb) cb();\n };\n\n const renderChildren = (): React.ReactElement | undefined => {\n if (isComponent<LinkListProps>(children, LinkList)) {\n return (\n <PopOver\n testId={popOverTestId}\n className={classNames(styles['pop-menu__pop-over'], popOverClassName)}\n controllerRef={iconRef}\n role=\"dialog\"\n show={isOpen}\n >\n {React.Children.map(children, child =>\n React.cloneElement(child, {\n children: React.Children.map(child.props.children, child =>\n isComponent<LinkProps>(child, LinkList.Link)\n ? React.cloneElement(child, {\n onClick: (event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) =>\n handleClick(() => child.props.onClick && child.props.onClick(event)),\n })\n : child\n ),\n })\n )}\n </PopOver>\n );\n }\n };\n\n const toggleOpenOnClick = (): void => {\n setIsOpen(!isOpen);\n };\n\n const iconComponent =\n svgIcon && typeof svgIcon === 'string' ? (\n <LazyIcon iconName={svgIcon} size={IconSize.XSmall} isHovered={triggerButtonIsHovered} />\n ) : (\n svgIcon && <Icon svgIcon={svgIcon} size={IconSize.XSmall} isHovered={triggerButtonIsHovered} />\n );\n\n const openIcon = svgIcon ? (\n iconComponent\n ) : (\n <Icon ref={iconRef} svgIcon={svgIcon ?? VerticalDots} size={mobileIconSize} isHovered={triggerButtonIsHovered} />\n );\n\n const closeIcon = <Icon svgIcon={X} ref={iconRef} size={mobileIconSize} isHovered={triggerButtonIsHovered} />;\n\n return (\n <div ref={outerRef} className={classNames(popMenuClassName)} data-analyticsid={AnalyticsId.PopMenu}>\n <Button\n variant=\"borderless\"\n aria-expanded={isOpen}\n onClick={toggleOpenOnClick}\n ref={triggerButtonRef}\n ariaLabel={isOpen ? closeButtonAriaLabel : openButtonAriaLabel}\n testId={isOpen ? closeButtonTestId : openButtonTestId}\n >\n {labelText && labelTextPosition == PopMenuLabelPosition.left && <span>{labelText}</span>}\n {isOpen ? closeIcon : openIcon}\n {labelText && labelTextPosition == PopMenuLabelPosition.right && <span>{labelText}</span>}\n </Button>\n {isOpen && renderChildren()}\n </div>\n );\n};\n\nexport default PopMenu;\n","import PopMenu from './PopMenu';\nexport { PopMenuVariant, PopMenuLabelPosition } from './constants';\nexport * from './PopMenu';\nexport default PopMenu;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAY,iBAAA,yBAAA,kBAAL;AACL,kBAAA,aAAA;AACA,kBAAA,YAAA;AACA,kBAAA,iBAAA;;;AAGF,IAAY,uBAAA,yBAAA,wBAAL;AACL,wBAAA,WAAA;AACA,wBAAA,UAAA;;;AC2CF,MAAaA,WAAmC,UAAwB;CACtE,MAAM,mBAAmB,OAA0B,KAAK;CACxD,MAAM,UAAU,OAAO,KAAK;CAC5B,MAAM,WAAW,OAAuB,KAAK;CAC7C,MAAM,CAAC,QAAQ,aAA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BAAC,OAAA;EAAI,KAAK;EAAU,WAAW,GAAW,iBAAiB;EAAE,oBAAkB,YAAY;aACzF,qBAAC,gBAAA;GACC,SAAQ;GACR,iBAAe;GACf,SAAS;GACT,KAAK;GACL,WAAW,SAAS,uBAAuB;GAC3C,QAAQ,SAAS,oBAAoB;;IAEpC,aAAa,qBAAqB,qBAAqB,QAAQ,oBAAC,QAAA,EAAA,UAAM,WAAA,CAAiB;IACvF,SAAS,YAAY;IACrB,aAAa,qBAAqB,qBAAqB,SAAS,oBAAC,QAAA,EAAA,UAAM,WAAA,CAAiB;;IAClF,EACR,UAAU,gBAAgB,CAAA;GACvB;;AC7IV,IAAA,kBDiJe"}
@@ -1,6 +1,6 @@
1
1
  import { c as ZIndex } from "../../constants2.js";
2
2
  import { t as palette } from "../../palette.js";
3
- import classNames from "classnames";
3
+ import cn from "classnames";
4
4
  import { useEffect, useRef } from "react";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  import styles from "./styles.module.scss";
@@ -43,7 +43,7 @@ var Progressbar = ({ value, size = ProgressbarSize.large, mode = ProgressBarMode
43
43
  }, []);
44
44
  return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
45
45
  ref: wrapperRef,
46
- className: classNames({
46
+ className: cn({
47
47
  [styles["progressbar--overlay"]]: overlay,
48
48
  [styles["progressbar--overlay-screen"]]: overlay === Overlay.screen,
49
49
  [styles["progressbar--overlay-parent"]]: overlay === Overlay.parent
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Progressbar: React.FC<ProgressbarProps>"],"sources":["../../../src/components/Progressbar/constants.ts","../../../src/components/Progressbar/Progressbar.tsx","../../../src/components/Progressbar/index.ts"],"sourcesContent":["export enum ProgressbarSize {\n small = 'small',\n medium = 'medium',\n large = 'large',\n}\n\nexport enum ProgressBarMode {\n ondark = 'ondark',\n onlight = 'onlight',\n}\n\nexport enum Overlay {\n screen = 'screen',\n parent = 'parent',\n}\n","import { useRef, useEffect } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Overlay, ProgressBarMode, ProgressbarSize } from './constants';\nimport { ZIndex } from '../../constants';\nimport { palette } from '../../theme/palette';\n\nimport styles from './styles.module.scss';\n\nexport interface ProgressbarProps {\n /** The value of the progressbar given in percent. Value between 0 and 100 */\n value: number;\n /** Size of the progressbar. Default is large */\n size?: ProgressbarSize;\n /** Changes the visuals of the ProgressBar. Default is onLight */\n mode?: ProgressBarMode;\n /** Loader is displayed with grey background covering the entire screen */\n overlay?: keyof typeof Overlay;\n /** Aria label for the progressbar */\n ariaLabel?: string;\n /** Sets the data-testid attribute */\n testId?: string;\n}\n\nconst Progressbar: React.FC<ProgressbarProps> = ({\n value,\n size = ProgressbarSize.large,\n mode = ProgressBarMode.onlight,\n overlay,\n testId,\n ariaLabel,\n}: ProgressbarProps) => {\n if (overlay) {\n mode = ProgressBarMode.ondark;\n }\n // Restrict value to be between 0 and 100\n value = Math.max(0, Math.min(value, 100));\n\n let width;\n if (size === ProgressbarSize.large) {\n width = 96;\n } else if (size === ProgressbarSize.medium) {\n width = 50;\n } else {\n width = 44;\n }\n\n const totalRadius = width / 2;\n const strokeWidth = 8;\n const radius = totalRadius - strokeWidth / 2;\n const viewBoxSize = totalRadius * 2;\n const viewBoxCenter = totalRadius;\n const circleBackgroundColor = mode === ProgressBarMode.onlight ? palette.blueberry100 : palette.neutral700;\n const mainColor = mode === ProgressBarMode.onlight ? palette.blueberry600 : palette.white;\n const circumference = 2 * Math.PI * radius;\n const strokeDashoffset = circumference - (value / 100) * circumference;\n const valueText = `${value}%`;\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (overlay === Overlay.parent && wrapperRef.current?.parentElement?.style) {\n wrapperRef.current.parentElement.style.position = 'relative';\n }\n }, []);\n\n const wrapperClasses = classNames({\n [styles['progressbar--overlay']]: overlay,\n [styles['progressbar--overlay-screen']]: overlay === Overlay.screen,\n [styles['progressbar--overlay-parent']]: overlay === Overlay.parent,\n });\n\n return (\n <>\n <div\n ref={wrapperRef}\n className={wrapperClasses}\n data-testid={testId}\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={value}\n aria-label={ariaLabel}\n style={overlay === Overlay.screen ? { zIndex: ZIndex.OverlayScreen } : {}}\n >\n <svg\n role=\"presentation\"\n width={viewBoxSize}\n height={viewBoxSize}\n viewBox={`0 0 ${viewBoxSize} ${viewBoxSize}`}\n className={styles['progressbar__svg']}\n >\n <circle cx={viewBoxCenter} cy={viewBoxCenter} r={radius} stroke={circleBackgroundColor} strokeWidth={strokeWidth} fill=\"none\" />\n <circle\n cx={viewBoxCenter}\n cy={viewBoxCenter}\n r={radius}\n stroke={mainColor}\n strokeWidth={strokeWidth}\n fill=\"none\"\n strokeDasharray={circumference}\n strokeDashoffset={strokeDashoffset}\n className={styles['progressbar__progress-circle']}\n transform={`rotate(-90 ${viewBoxCenter} ${viewBoxCenter})`}\n />\n <text\n className=\"progress-wheel__text--large\"\n fontSize={'1.5rem'}\n fill={mainColor}\n x={viewBoxCenter}\n y={viewBoxCenter}\n textAnchor=\"middle\"\n alignmentBaseline=\"middle\"\n >\n {size === ProgressbarSize.large && valueText}\n </text>\n </svg>\n </div>\n <div className={styles['progressbar__sr-only-text']} aria-live=\"assertive\" aria-atomic=\"true\">\n {valueText}\n </div>\n </>\n );\n};\n\nexport default Progressbar;\n","import Progressbar from './Progressbar';\nexport { ProgressbarSize, ProgressBarMode, Overlay } from './constants';\nexport * from './Progressbar';\nexport default Progressbar;\n"],"mappings":";;;;;;AAAA,IAAY,kBAAA,yBAAA,mBAAL;AACL,mBAAA,WAAA;AACA,mBAAA,YAAA;AACA,mBAAA,WAAA;;;AAGF,IAAY,kBAAA,yBAAA,mBAAL;AACL,mBAAA,YAAA;AACA,mBAAA,aAAA;;;AAGF,IAAY,UAAA,yBAAA,WAAL;AACL,WAAA,YAAA;AACA,WAAA,YAAA;;;ACYF,IAAMA,eAA2C,EAC/C,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Ae,GAAG;KAAQ,QAAQ;KAAoC;KAAa,MAAK;MAAS;IAChI,oBAAC,UAAA;KACC,IAAI;KACJ,IAAI;KACJ,GAAG;KACH,QAAQ;KACK;KACb,MAAK;KACL,iBAAiB;KACC;KAClB,WAAW,OAAO;KAClB,WAAW,cAAc,cAAc,GAAG,cAAc;MACxD;IACF,oBAAC,QAAA;KACC,WAAU;KACV,UAAU;KACV,MAAM;KACN,GAAG;KACH,GAAG;KACH,YAAW;KACX,mBAAkB;eAEjB,SAAS,gBAAgB,SAAS;MAC9B;;IACH;GACF,EACN,oBAAC,OAAA;EAAI,WAAW,OAAO;EAA8B,aAAU;EAAY,eAAY;YACpF;GACG,CAAA,EAAA,CACL;;ACvHP,IAAA,sBD2He"}
1
+ {"version":3,"file":"index.js","names":["Progressbar: React.FC<ProgressbarProps>"],"sources":["../../../src/components/Progressbar/constants.ts","../../../src/components/Progressbar/Progressbar.tsx","../../../src/components/Progressbar/index.ts"],"sourcesContent":["export enum ProgressbarSize {\n small = 'small',\n medium = 'medium',\n large = 'large',\n}\n\nexport enum ProgressBarMode {\n ondark = 'ondark',\n onlight = 'onlight',\n}\n\nexport enum Overlay {\n screen = 'screen',\n parent = 'parent',\n}\n","import { useRef, useEffect } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Overlay, ProgressBarMode, ProgressbarSize } from './constants';\nimport { ZIndex } from '../../constants';\nimport { palette } from '../../theme/palette';\n\nimport styles from './styles.module.scss';\n\nexport interface ProgressbarProps {\n /** The value of the progressbar given in percent. Value between 0 and 100 */\n value: number;\n /** Size of the progressbar. Default is large */\n size?: ProgressbarSize;\n /** Changes the visuals of the ProgressBar. Default is onLight */\n mode?: ProgressBarMode;\n /** Loader is displayed with grey background covering the entire screen */\n overlay?: keyof typeof Overlay;\n /** Aria label for the progressbar */\n ariaLabel?: string;\n /** Sets the data-testid attribute */\n testId?: string;\n}\n\nconst Progressbar: React.FC<ProgressbarProps> = ({\n value,\n size = ProgressbarSize.large,\n mode = ProgressBarMode.onlight,\n overlay,\n testId,\n ariaLabel,\n}: ProgressbarProps) => {\n if (overlay) {\n mode = ProgressBarMode.ondark;\n }\n // Restrict value to be between 0 and 100\n value = Math.max(0, Math.min(value, 100));\n\n let width;\n if (size === ProgressbarSize.large) {\n width = 96;\n } else if (size === ProgressbarSize.medium) {\n width = 50;\n } else {\n width = 44;\n }\n\n const totalRadius = width / 2;\n const strokeWidth = 8;\n const radius = totalRadius - strokeWidth / 2;\n const viewBoxSize = totalRadius * 2;\n const viewBoxCenter = totalRadius;\n const circleBackgroundColor = mode === ProgressBarMode.onlight ? palette.blueberry100 : palette.neutral700;\n const mainColor = mode === ProgressBarMode.onlight ? palette.blueberry600 : palette.white;\n const circumference = 2 * Math.PI * radius;\n const strokeDashoffset = circumference - (value / 100) * circumference;\n const valueText = `${value}%`;\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (overlay === Overlay.parent && wrapperRef.current?.parentElement?.style) {\n wrapperRef.current.parentElement.style.position = 'relative';\n }\n }, []);\n\n const wrapperClasses = classNames({\n [styles['progressbar--overlay']]: overlay,\n [styles['progressbar--overlay-screen']]: overlay === Overlay.screen,\n [styles['progressbar--overlay-parent']]: overlay === Overlay.parent,\n });\n\n return (\n <>\n <div\n ref={wrapperRef}\n className={wrapperClasses}\n data-testid={testId}\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={value}\n aria-label={ariaLabel}\n style={overlay === Overlay.screen ? { zIndex: ZIndex.OverlayScreen } : {}}\n >\n <svg\n role=\"presentation\"\n width={viewBoxSize}\n height={viewBoxSize}\n viewBox={`0 0 ${viewBoxSize} ${viewBoxSize}`}\n className={styles['progressbar__svg']}\n >\n <circle cx={viewBoxCenter} cy={viewBoxCenter} r={radius} stroke={circleBackgroundColor} strokeWidth={strokeWidth} fill=\"none\" />\n <circle\n cx={viewBoxCenter}\n cy={viewBoxCenter}\n r={radius}\n stroke={mainColor}\n strokeWidth={strokeWidth}\n fill=\"none\"\n strokeDasharray={circumference}\n strokeDashoffset={strokeDashoffset}\n className={styles['progressbar__progress-circle']}\n transform={`rotate(-90 ${viewBoxCenter} ${viewBoxCenter})`}\n />\n <text\n className=\"progress-wheel__text--large\"\n fontSize={'1.5rem'}\n fill={mainColor}\n x={viewBoxCenter}\n y={viewBoxCenter}\n textAnchor=\"middle\"\n alignmentBaseline=\"middle\"\n >\n {size === ProgressbarSize.large && valueText}\n </text>\n </svg>\n </div>\n <div className={styles['progressbar__sr-only-text']} aria-live=\"assertive\" aria-atomic=\"true\">\n {valueText}\n </div>\n </>\n );\n};\n\nexport default Progressbar;\n","import Progressbar from './Progressbar';\nexport { ProgressbarSize, ProgressBarMode, Overlay } from './constants';\nexport * from './Progressbar';\nexport default Progressbar;\n"],"mappings":";;;;;;AAAA,IAAY,kBAAA,yBAAA,mBAAL;AACL,mBAAA,WAAA;AACA,mBAAA,YAAA;AACA,mBAAA,WAAA;;;AAGF,IAAY,kBAAA,yBAAA,mBAAL;AACL,mBAAA,YAAA;AACA,mBAAA,aAAA;;;AAGF,IAAY,UAAA,yBAAA,WAAL;AACL,WAAA,YAAA;AACA,WAAA,YAAA;;;ACYF,IAAMA,eAA2C,EAC/C,OACA,OAAO,gBAAgB,OACvB,OAAO,gBAAgB,SACvB,SACA,QACA,gBACsB;AACtB,KAAI,QACF,QAAO,gBAAgB;AAGzB,SAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,OAAO,IAAI,CAAC;CAEzC,IAAI;AACJ,KAAI,SAAS,gBAAgB,MAC3B,SAAQ;UACC,SAAS,gBAAgB,OAClC,SAAQ;KAER,SAAQ;CAGV,MAAM,cAAc,QAAQ;CAC5B,MAAM,cAAc;CACpB,MAAM,SAAS,cAAc,cAAc;CAC3C,MAAM,cAAc,cAAc;CAClC,MAAM,gBAAgB;CACtB,MAAM,wBAAwB,SAAS,gBAAgB,UAAU,QAAQ,eAAe,QAAQ;CAChG,MAAM,YAAY,SAAS,gBAAgB,UA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