@helsenorge/designsystem-react 16.0.0 → 16.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/lib/Button.js +8 -9
  2. package/lib/Button.js.map +1 -1
  3. package/lib/CHANGELOG.md +24 -0
  4. package/lib/Checkbox.js +0 -2
  5. package/lib/Checkbox.js.map +1 -1
  6. package/lib/Drawer.js +30 -30
  7. package/lib/Drawer.js.map +1 -1
  8. package/lib/Expander.js +1 -0
  9. package/lib/Expander.js.map +1 -1
  10. package/lib/HorizontalScroll.js +6 -10
  11. package/lib/HorizontalScroll.js.map +1 -1
  12. package/lib/PopOver.js +2 -3
  13. package/lib/PopOver.js.map +1 -1
  14. package/lib/Radio.js +0 -2
  15. package/lib/Radio.js.map +1 -1
  16. package/lib/StackedCellContent.js +15 -0
  17. package/lib/StackedCellContent.js.map +1 -0
  18. package/lib/TabPanel.js +1 -0
  19. package/lib/TabPanel.js.map +1 -1
  20. package/lib/TableContext.js +26 -0
  21. package/lib/TableContext.js.map +1 -0
  22. package/lib/UNSAFE_TableBody.js +22 -0
  23. package/lib/UNSAFE_TableBody.js.map +1 -0
  24. package/lib/UNSAFE_TableCell.js +26 -0
  25. package/lib/UNSAFE_TableCell.js.map +1 -0
  26. package/lib/UNSAFE_TableDetail.js +17 -0
  27. package/lib/UNSAFE_TableDetail.js.map +1 -0
  28. package/lib/UNSAFE_TableExpandedRow.js +46 -0
  29. package/lib/UNSAFE_TableExpandedRow.js.map +1 -0
  30. package/lib/UNSAFE_TableHead.js +25 -0
  31. package/lib/UNSAFE_TableHead.js.map +1 -0
  32. package/lib/UNSAFE_TableHeadCell.js +182 -0
  33. package/lib/UNSAFE_TableHeadCell.js.map +1 -0
  34. package/lib/UNSAFE_TableRow.js +130 -0
  35. package/lib/UNSAFE_TableRow.js.map +1 -0
  36. package/lib/__mocks__/ResizeObserver.js +4 -1
  37. package/lib/__mocks__/ResizeObserver.js.map +1 -1
  38. package/lib/components/Button/Button.d.ts +1 -1
  39. package/lib/components/Button/styles.module.scss +0 -4
  40. package/lib/components/Button/styles.module.scss.d.ts +0 -1
  41. package/lib/components/Checkbox/styles.module.scss +5 -5
  42. package/lib/components/Checkbox/styles.module.scss.d.ts +12 -1
  43. package/lib/components/Drawer/DrawerHeaderContent.module.scss +10 -1
  44. package/lib/components/Drawer/styles.module.scss +6 -2
  45. package/lib/components/Duolist/styles.module.scss +3 -7
  46. package/lib/components/Expander/styles.module.scss.d.ts +0 -1
  47. package/lib/components/ExpanderHierarchy/index.js +1 -0
  48. package/lib/components/ExpanderHierarchy/index.js.map +1 -1
  49. package/lib/components/ExpanderList/index.js +1 -0
  50. package/lib/components/ExpanderList/index.js.map +1 -1
  51. package/lib/components/ExpanderList/styles.module.scss +1 -0
  52. package/lib/components/HorizontalScroll/HorizontalScroll.d.ts +0 -4
  53. package/lib/components/HorizontalScroll/styles.module.scss +1 -4
  54. package/lib/components/HorizontalScroll/styles.module.scss.d.ts +0 -1
  55. package/lib/components/Label/Label.d.ts +2 -0
  56. package/lib/components/Label/styles.module.scss +16 -0
  57. package/lib/components/Label/utils.d.ts +0 -1
  58. package/lib/components/Modal/index.js +5 -2
  59. package/lib/components/Modal/index.js.map +1 -1
  60. package/lib/components/Panel/styles.module.scss.d.ts +0 -1
  61. package/lib/components/PopMenu/PopMenu.d.ts +4 -0
  62. package/lib/components/PopMenu/index.js +3 -1
  63. package/lib/components/PopMenu/index.js.map +1 -1
  64. package/lib/components/Radio/styles.module.scss +6 -6
  65. package/lib/components/Radio/styles.module.scss.d.ts +12 -1
  66. package/lib/components/Table/index.js +0 -1
  67. package/lib/components/Table/index.js.map +1 -1
  68. package/lib/components/UNSAFE_Table/StackedCellContent.d.ts +9 -0
  69. package/lib/components/UNSAFE_Table/TableCaption.d.ts +10 -0
  70. package/lib/components/UNSAFE_Table/TableContext.d.ts +22 -0
  71. package/lib/components/UNSAFE_Table/UNSAFE_Table.d.ts +37 -0
  72. package/lib/components/UNSAFE_Table/UNSAFE_TableBody/UNSAFE_TableBody.d.ts +10 -0
  73. package/lib/components/UNSAFE_Table/UNSAFE_TableBody/index.d.ts +3 -0
  74. package/lib/components/UNSAFE_Table/UNSAFE_TableBody/index.js +2 -0
  75. package/lib/components/UNSAFE_Table/UNSAFE_TableCell/UNSAFE_TableCell.d.ts +15 -0
  76. package/lib/components/UNSAFE_Table/UNSAFE_TableCell/index.d.ts +3 -0
  77. package/lib/components/UNSAFE_Table/UNSAFE_TableCell/index.js +7 -0
  78. package/lib/components/UNSAFE_Table/UNSAFE_TableCell/index.js.map +1 -0
  79. package/lib/components/UNSAFE_Table/UNSAFE_TableDetail/UNSAFE_TableDetail.d.ts +12 -0
  80. package/lib/components/UNSAFE_Table/UNSAFE_TableDetail/index.d.ts +3 -0
  81. package/lib/components/UNSAFE_Table/UNSAFE_TableDetail/index.js +7 -0
  82. package/lib/components/UNSAFE_Table/UNSAFE_TableDetail/index.js.map +1 -0
  83. package/lib/components/UNSAFE_Table/UNSAFE_TableExpandedRow/UNSAFE_TableExpandedRow.d.ts +17 -0
  84. package/lib/components/UNSAFE_Table/UNSAFE_TableExpandedRow/index.d.ts +3 -0
  85. package/lib/components/UNSAFE_Table/UNSAFE_TableExpandedRow/index.js +7 -0
  86. package/lib/components/UNSAFE_Table/UNSAFE_TableExpandedRow/index.js.map +1 -0
  87. package/lib/components/UNSAFE_Table/UNSAFE_TableExpanderCell/UNSAFE_TableExpanderCellMobile.d.ts +4 -0
  88. package/lib/components/UNSAFE_Table/UNSAFE_TableHead/UNSAFE_TableHead.d.ts +8 -0
  89. package/lib/components/UNSAFE_Table/UNSAFE_TableHead/index.d.ts +3 -0
  90. package/lib/components/UNSAFE_Table/UNSAFE_TableHead/index.js +7 -0
  91. package/lib/components/UNSAFE_Table/UNSAFE_TableHead/index.js.map +1 -0
  92. package/lib/components/UNSAFE_Table/UNSAFE_TableHeadCell/UNSAFE_TableHeadCell.d.ts +15 -0
  93. package/lib/components/UNSAFE_Table/UNSAFE_TableHeadCell/index.d.ts +3 -0
  94. package/lib/components/UNSAFE_Table/UNSAFE_TableHeadCell/index.js +2 -0
  95. package/lib/components/UNSAFE_Table/UNSAFE_TablePopMenuCell/UNSAFE_TablePopMenuCell.d.ts +8 -0
  96. package/lib/components/UNSAFE_Table/UNSAFE_TableRow/UNSAFE_TableRow.d.ts +20 -0
  97. package/lib/components/UNSAFE_Table/UNSAFE_TableRow/index.d.ts +3 -0
  98. package/lib/components/UNSAFE_Table/UNSAFE_TableRow/index.js +2 -0
  99. package/lib/components/UNSAFE_Table/constants.d.ts +29 -0
  100. package/lib/components/UNSAFE_Table/index.d.ts +19 -0
  101. package/lib/components/UNSAFE_Table/index.js +182 -0
  102. package/lib/components/UNSAFE_Table/index.js.map +1 -0
  103. package/lib/components/UNSAFE_Table/resourceHelper.d.ts +3 -0
  104. package/lib/components/UNSAFE_Table/styles.module.scss +621 -0
  105. package/lib/components/UNSAFE_Table/styles.module.scss.d.ts +62 -0
  106. package/lib/components/UNSAFE_Table/useTableExpandedRows.d.ts +12 -0
  107. package/lib/components/UNSAFE_Table/useTableShowMore.d.ts +25 -0
  108. package/lib/components/UNSAFE_Table/utils.d.ts +47 -0
  109. package/lib/constants3.js +42 -0
  110. package/lib/constants3.js.map +1 -0
  111. package/lib/floating-ui.react.js +2 -2
  112. package/lib/floating-ui.react.js.map +1 -1
  113. package/lib/hooks/useSort.d.ts +88 -0
  114. package/lib/hooks/useSort.js +91 -0
  115. package/lib/hooks/useSort.js.map +1 -0
  116. package/lib/hooks/useSort.test.js +11739 -0
  117. package/lib/hooks/useSort.test.js.map +1 -0
  118. package/lib/hooks/useSynchronousResizeObserver.d.ts +11 -0
  119. package/lib/hooks/useSynchronousResizeObserver.js +29 -0
  120. package/lib/hooks/useSynchronousResizeObserver.js.map +1 -0
  121. package/lib/resources/HN.Designsystem.Table.nb-NO.json.d.ts +9 -0
  122. package/lib/resources/Resources.d.ts +19 -0
  123. package/lib/rolldown-runtime.js +33 -0
  124. package/lib/scss/_font-mixins.scss +28 -1
  125. package/lib/scss/typography.module.scss +8 -0
  126. package/lib/scss/typography.module.scss.d.ts +2 -0
  127. package/lib/scss/typography.stories.tsx +8 -0
  128. package/lib/utils/uuid.js +1 -12
  129. package/lib/utils/uuid.js.map +1 -1
  130. package/lib/utils2.js +18 -14
  131. package/lib/utils2.js.map +1 -1
  132. package/package.json +54 -2
  133. package/scss/_font-mixins.scss +28 -1
  134. package/scss/typography.module.scss +8 -0
  135. package/scss/typography.module.scss.d.ts +2 -0
  136. package/scss/typography.stories.tsx +8 -0
@@ -8,9 +8,9 @@ import { getAriaLabelAttributes } from "../../utils/accessibility.js";
8
8
  import useFocusTrap from "../../hooks/useFocusTrap.js";
9
9
  import { useIsVisible } from "../../hooks/useIsVisible.js";
10
10
  import { t as Close_default } from "../../Close.js";
11
+ import { t as Title } from "../../Title.js";
11
12
  import { useReturnFocusOnUnmount } from "../../hooks/useReturnFocusOnUnmount.js";
12
13
  import { disableBodyScroll, enableBodyScroll } from "../../utils/scroll.js";
13
- import { t as Title } from "../../Title.js";
14
14
  import AlertSignFill from "../Icons/AlertSignFill.js";
15
15
  import AlertSignStroke from "../Icons/AlertSignStroke.js";
16
16
  import CheckOutline from "../Icons/CheckOutline.js";
@@ -172,7 +172,10 @@ var Modal = (props) => {
172
172
  })
173
173
  ]
174
174
  }),
175
- props.children && /* @__PURE__ */ jsx("div", { children: props.children }),
175
+ props.children && /* @__PURE__ */ jsx("div", {
176
+ "data-overflow-boundary": true,
177
+ children: props.children
178
+ }),
176
179
  !props.children && /* @__PURE__ */ jsx("p", {
177
180
  className: styles.modal__description,
178
181
  children: props.description
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"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 normal = 'normal',\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.normal,\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,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A+B,UAAA,MAAM;WAAwB,CAAA;UAC9G;;SACJ,MAAM,YAAY,oBAAC,OAAD,EAAA,UAAM,MAAM,SAAc,CAAA;SAC5C,CAAC,MAAM,YAAY,oBAAC,KAAD;UAAG,WAAW,OAAO;UAAqB,UAAA,MAAM;SAAe,CAAA;SACnF,oBAAC,OAAD,EAAK,KAAK,cAAgB,CAAA;QACvB;OACF,CAAA,CAAA;;MACL,oBAAC,OAAD,EACE,WAAW,WAAG,OAAO,kBAAkB,OAAO,0BAA0B,GACrE,OAAO,yBAAyB,CAAC,wBAAwB,oBAC5D,CAAC,EACF,CAAA;MACA,eACC,qBAAC,OAAD;OAAK,WAAW,WAAG,OAAO,0BAA0B,QAAQ,OAAO,0BAA0B,OAAO;OAApG,UAAA;QACG,MAAM,aAAa,qBAAqB,oBAAC,gBAAD;SAAQ,SAAS,MAAM;SAAY,UAAA;QAA0B,CAAA;QACrG,MAAM,uBAAuB,MAAM,qBAAqB,SAAS,KAChE,oBAAC,gBAAD;SAAQ,SAAQ;SAAa,SAAS,MAAM;SACzC,UAAA,MAAM;QACD,CAAA;QAET;OACE;;KAEJ;;GACF,CAAA;EACF,CAAA;CACF,CAAA;CAGP,IAAI,MAAM,WAAW;EACnB,MAAM,aAAa;EACnB,OACE,qBAAC,QAAD;GAAQ,WAAW;GAAY,QAAO;GAAtC,UAAA,CACE,oBAAC,SAAD;IAAO,OAAM;IAAS,UAAA,iBAAiB,WAAW;GAA2B,CAAA,GAC5E,SACK;;CAEZ;CAEA,OAAO;AACT;;;AC9PA,IAAA,gBAAe"}
1
+ {"version":3,"file":"index.js","names":[],"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 normal = 'normal',\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.normal,\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 data-overflow-boundary>{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,gBAAL,yBAAA,eAAA;CACL,cAAA,YAAA;CACA,cAAA,aAAA;CACA,cAAA,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AAK,0BAAA;UAAwB,UAAA,MAAM;SAAc,CAAA;SACnE,CAAC,MAAM,YAAY,oBAAC,KAAD;UAAG,WAAW,OAAO;UAAqB,UAAA,MAAM;SAAe,CAAA;SACnF,oBAAC,OAAD,EAAK,KAAK,cAAgB,CAAA;QACvB;OACF,CAAA,CAAA;;MACL,oBAAC,OAAD,EACE,WAAW,WAAG,OAAO,kBAAkB,OAAO,0BAA0B,GACrE,OAAO,yBAAyB,CAAC,wBAAwB,oBAC5D,CAAC,EACF,CAAA;MACA,eACC,qBAAC,OAAD;OAAK,WAAW,WAAG,OAAO,0BAA0B,QAAQ,OAAO,0BAA0B,OAAO;OAApG,UAAA;QACG,MAAM,aAAa,qBAAqB,oBAAC,gBAAD;SAAQ,SAAS,MAAM;SAAY,UAAA;QAA0B,CAAA;QACrG,MAAM,uBAAuB,MAAM,qBAAqB,SAAS,KAChE,oBAAC,gBAAD;SAAQ,SAAQ;SAAa,SAAS,MAAM;SACzC,UAAA,MAAM;QACD,CAAA;QAET;OACE;;KAEJ;;GACF,CAAA;EACF,CAAA;CACF,CAAA;CAGP,IAAI,MAAM,WAAW;EACnB,MAAM,aAAa;EACnB,OACE,qBAAC,QAAD;GAAQ,WAAW;GAAY,QAAO;GAAtC,UAAA,CACE,oBAAC,SAAD;IAAO,OAAM;IAAS,UAAA,iBAAiB,WAAW;GAA2B,CAAA,GAC5E,SACK;;CAEZ;CAEA,OAAO;AACT;;;AC9PA,IAAA,gBAAe"}
@@ -6,7 +6,6 @@ export type Styles = {
6
6
  'button__left-icon': string;
7
7
  'button__only-icon': string;
8
8
  'button__right-icon': string;
9
- 'button__right-unicode-arrow': string;
10
9
  button__text: string;
11
10
  'button__text--centered': string;
12
11
  'button__text--ellipsis': string;
@@ -10,6 +10,10 @@ export interface PopMenuProps {
10
10
  popOverClassName?: string;
11
11
  /** Adds custom classes to the element. */
12
12
  popMenuClassName?: string;
13
+ /** Adds custom classes to the trigger button element. */
14
+ triggerClassName?: string;
15
+ /** Adds custom classes to the trigger button's inner content element. */
16
+ triggerContentClassName?: string;
13
17
  /** @deprecated Changes responsive design for the trigger buttons. */
14
18
  popMenuVariant?: PopMenuVariant;
15
19
  /** Sets the data-testid attribute for the button that opens. */
@@ -33,7 +33,7 @@ var PopMenu = (props) => {
33
33
  const iconRef = useRef(null);
34
34
  const outerRef = useRef(null);
35
35
  const [isOpen, setIsOpen] = useState(false);
36
- const { children, popOverClassName, popMenuClassName, openButtonTestId, closeButtonTestId, popOverTestId, openButtonAriaLabel, closeButtonAriaLabel, svgIcon, labelText, labelTextPosition = PopMenuLabelPosition.right } = props;
36
+ const { children, popOverClassName, popMenuClassName, triggerClassName, triggerContentClassName, openButtonTestId, closeButtonTestId, popOverTestId, openButtonAriaLabel, closeButtonAriaLabel, svgIcon, labelText, labelTextPosition = PopMenuLabelPosition.right } = props;
37
37
  const isMobile = useIsMobileBreakpoint();
38
38
  const handleClose = useDismissablePopover({
39
39
  popoverRef: outerRef,
@@ -92,6 +92,8 @@ var PopMenu = (props) => {
92
92
  ref: triggerButtonRef,
93
93
  ariaLabel: isOpen ? closeButtonAriaLabel : openButtonAriaLabel,
94
94
  testId: isOpen ? closeButtonTestId : openButtonTestId,
95
+ wrapperClassName: triggerClassName,
96
+ className: triggerContentClassName,
95
97
  children: [
96
98
  labelText && labelTextPosition == PopMenuLabelPosition.left && /* @__PURE__ */ jsx("span", { children: labelText }),
97
99
  isOpen ? closeIcon : openIcon,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"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 { useDismissablePopover } from '../../hooks/useDismissablePopover';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\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 const handleClose = useDismissablePopover({\n popoverRef: outerRef,\n triggerRef: triggerButtonRef,\n isOpen,\n onClose: () => 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 handleClose();\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,iBAAL,yBAAA,gBAAA;CACL,eAAA,aAAA;CACA,eAAA,YAAA;CACA,eAAA,iBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,uBAAL,yBAAA,sBAAA;CACL,qBAAA,WAAA;CACA,qBAAA,UAAA;;AACF,EAAA,CAAA,CAAA;;;AC0CA,IAAa,WAAmC,UAAwB;CACtE,MAAM,mBAAmB,OAA0B,IAAI;CACvD,MAAM,UAAU,OAAO,IAAI;CAC3B,MAAM,WAAW,OAAuB,IAAI;CAC5C,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAC1C,MAAM,EACJ,UACA,kBACA,kBACA,kBACA,mBACA,eACA,qBACA,sBACA,SACA,WACA,oBAAoB,qBAAqB,UACvC;CACJ,MAAM,WAAW,sBAAsB;CAEvC,MAAM,cAAc,sBAAsB;EACxC,YAAY;EACZ,YAAY;EACZ;EACA,eAAe,UAAU,KAAK;CAChC,CAAC;CAED,MAAM,EAAE,WAAW,2BAA2B,iBAAiB,gBAAgB;CAC/E,MAAM,iBAAiB,WAAW,SAAS,SAAS,SAAS;CAE7D,MAAM,eAAe,OAA0B;EAC7C,YAAY;EACZ,IAAI,IAAI,GAAG;CACb;CAEA,MAAM,uBAAuD;EAC3D,IAAI,YAA2B,UAAU,gBAAQ,GAC/C,OACE,o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CAAA;GAClF;EACP,CAAA,GAAA,UAAU,eAAe,CACvB;;AAET;;;AClJA,IAAA,kBAAe"}
1
+ {"version":3,"file":"index.js","names":[],"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 { useDismissablePopover } from '../../hooks/useDismissablePopover';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\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 /** Adds custom classes to the trigger button element. */\n triggerClassName?: string;\n /** Adds custom classes to the trigger button's inner content element. */\n triggerContentClassName?: 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 triggerClassName,\n triggerContentClassName,\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 const handleClose = useDismissablePopover({\n popoverRef: outerRef,\n triggerRef: triggerButtonRef,\n isOpen,\n onClose: () => 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 handleClose();\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 wrapperClassName={triggerClassName}\n className={triggerContentClassName}\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,iBAAL,yBAAA,gBAAA;CACL,eAAA,aAAA;CACA,eAAA,YAAA;CACA,eAAA,iBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,uBAAL,yBAAA,sBAAA;CACL,qBAAA,WAAA;CACA,qBAAA,UAAA;;AACF,EAAA,CAAA,CAAA;;;AC8CA,IAAa,WAAmC,UAAwB;CACtE,MAAM,mBAAmB,OAA0B,IAAI;CACvD,MAAM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AD;EAAM,KAAK;EAAS,SAAS,WAAW;EAAc,MAAM;EAAgB,WAAW;CAAyB,CAAA;CAGlH,MAAM,YAAY,oBAAC,cAAD;EAAM,SAAS;EAAG,KAAK;EAAS,MAAM;EAAgB,WAAW;CAAyB,CAAA;CAE5G,OACE,qBAAC,OAAD;EAAK,KAAK;EAAU,WAAW,WAAW,gBAAgB;EAAG,oBAAkB,YAAY;EAA3F,UAAA,CACE,qBAAC,gBAAD;GACE,SAAQ;GACR,iBAAe;GACf,SAAS;GACT,KAAK;GACL,WAAW,SAAS,uBAAuB;GAC3C,QAAQ,SAAS,oBAAoB;GACrC,kBAAkB;GAClB,WAAW;GARb,UAAA;IAUG,aAAa,qBAAqB,qBAAqB,QAAQ,oBAAC,QAAD,EAAA,UAAO,UAAgB,CAAA;IACtF,SAAS,YAAY;IACrB,aAAa,qBAAqB,qBAAqB,SAAS,oBAAC,QAAD,EAAA,UAAO,UAAgB,CAAA;GAClF;EACP,CAAA,GAAA,UAAU,eAAe,CACvB;;AAET;;;AC1JA,IAAA,kBAAe"}
@@ -3,6 +3,7 @@
3
3
  @use '../../scss/font-settings' as font-settings;
4
4
  @use '../../scss/breakpoints' as breakpoints;
5
5
  @use '../../scss/screen-reader' as *;
6
+ @use '../Label/styles.module' as label;
6
7
 
7
8
  $padding-clickable-area-top-bottom: 8px;
8
9
  $padding-clickable-area-left: 8px;
@@ -145,13 +146,17 @@ $padding-clickable-area-left: 8px;
145
146
 
146
147
  &__large:has(input:checked) {
147
148
  background-color: palette.$blueberry500;
148
- color: palette.$white;
149
+ color: var(--color-base-text-ondark);
149
150
 
150
151
  &:hover {
151
152
  background-color: palette.$blueberry600;
152
153
  }
153
154
  }
154
155
 
156
+ &__large:has(input:checked):not(#{&}__large--invalid, #{&}__large--disabled) {
157
+ @include label.on-dark-tokens;
158
+ }
159
+
155
160
  &__large#{&}__large--disabled {
156
161
  color: palette.$neutral700;
157
162
  background-color: palette.$neutral50;
@@ -180,11 +185,6 @@ $padding-clickable-area-left: 8px;
180
185
  margin-right: var(--core-space-s);
181
186
  }
182
187
 
183
- .radio-sublabel-wrapper {
184
- margin-top: -$padding-clickable-area-top-bottom;
185
- padding-left: calc(2.8rem + $padding-clickable-area-left);
186
- }
187
-
188
188
  .radio-afterlabelchildren-wrapper {
189
189
  padding-top: $padding-clickable-area-top-bottom;
190
190
  }
@@ -1,4 +1,13 @@
1
1
  export type Styles = {
2
+ 'after-label-children': string;
3
+ label: string;
4
+ label__texts: string;
5
+ 'label--on-dark': string;
6
+ 'label--subdued': string;
7
+ 'label-content-wrapper': string;
8
+ 'label-wrapper': string;
9
+ 'label-wrapper--after-label-children': string;
10
+ 'label-wrapper--no-bottom-margin': string;
2
11
  radio: string;
3
12
  'radio__marker-wrapper': string;
4
13
  'radio-afterlabelchildren-wrapper': string;
@@ -12,11 +21,13 @@ export type Styles = {
12
21
  'radio-label--disabled': string;
13
22
  'radio-label--invalid': string;
14
23
  'radio-label--on-dark': string;
15
- 'radio-sublabel-wrapper': string;
16
24
  'radio-wrapper': string;
17
25
  'radio-wrapper__large': string;
18
26
  'radio-wrapper__large--invalid': string;
19
27
  'radio-wrapper__large--on-blueberry': string;
28
+ sublabel: string;
29
+ 'sublabel--on-dark': string;
30
+ 'sublabel--subdued': string;
20
31
  };
21
32
 
22
33
  export type ClassNames = keyof Styles;
@@ -63,7 +63,6 @@ var Table = ({ id, testId, className, children, breakpointConfig = defaultConfig
63
63
  id: scrollAriaLabelledById
64
64
  });
65
65
  if (currentConfig?.variant === ResponsiveTableVariant.horizontalscroll) return /* @__PURE__ */ jsx(HorizontalScroll_default, {
66
- childWidth: tableWidth,
67
66
  testId: "horizontal-scroll",
68
67
  ...ariaLabelAttributes,
69
68
  children: table
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Table/Table.tsx","../../../src/components/Table/index.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { Breakpoint } from '../../hooks/useBreakpoint';\n\nimport { defaultConfig, ModeType, ResponsiveTableVariant } from './constants';\nimport { getCurrentConfig, getBreakpointClass, getCenteredOverflowTableStyle, mapChildrenWithMode, omitProps } from './utils';\nimport { AnalyticsId } from '../../constants';\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useLayoutEvent } from '../../hooks/useLayoutEvent';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport HorizontalScroll from '../HorizontalScroll';\n\nimport styles from './styles.module.scss';\n\nexport interface BreakpointConfig {\n /** Breakpoint at which responsive behaviour will be applied. The table component uses a \"desktop first\" approach. */\n breakpoint: keyof typeof Breakpoint;\n /** Desired behaviour on this breakpoint and all smaller screens. */\n variant: keyof typeof ResponsiveTableVariant;\n /** If variant is horizontallscroll, use a fallback instead of device is not a touch device. */\n fallbackVariant?: keyof typeof ResponsiveTableVariant;\n}\n\nexport interface Props extends Omit<React.ComponentPropsWithoutRef<'table'>, 'style'> {\n /** Unique ID */\n id?: string;\n /** Id used for testing */\n testId?: string;\n /** Customize how the table behaves on various screen widths */\n breakpointConfig?: BreakpointConfig | BreakpointConfig[];\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the content of the table. Use TableHead and TableBody */\n children: React.ReactNode;\n /** For display with less space. Discouraged to use together with interactive elements. */\n mode?: ModeType;\n /** Sets aria-label of the horizontal scroll container. scrollAriaLabel or scrollAriaLabelledById MUST be set if horizontal scrolling is enabled! */\n scrollAriaLabel?: string;\n /** Sets aria-labelledby of the horizontal scroll container. scrollAriaLabel or scrollAriaLabelledById MUST be set if horizontal scrolling is enabled! */\n scrollAriaLabelledById?: string;\n}\n\nexport const Table: React.FC<Props> = ({\n id,\n testId,\n className,\n children,\n breakpointConfig = defaultConfig,\n mode = ModeType.normal,\n scrollAriaLabel,\n scrollAriaLabelledById,\n ...rest\n}) => {\n const [tableWidth, setTableWidth] = useState<number>(0);\n const [parentWidth, setParentWidth] = useState<number>(0);\n const [windowWidth, setWindowWidth] = useState(window.innerWidth);\n const tableRef = useRef<HTMLTableElement>(null);\n const tableIsVisible = useIsVisible(tableRef, 0);\n const breakpoint = useBreakpoint();\n\n const currentConfig = useMemo(\n () => getCurrentConfig(breakpointConfig, breakpoint, tableWidth, windowWidth),\n [breakpointConfig, breakpoint, tableWidth, windowWidth]\n );\n\n useEffect(() => {\n if (\n currentConfig?.variant === ResponsiveTableVariant.centeredoverflow ||\n currentConfig?.variant === ResponsiveTableVariant.horizontalscroll\n ) {\n setTableWidth(tableRef.current?.getBoundingClientRect().width ?? 0);\n }\n if (currentConfig?.variant === ResponsiveTableVariant.centeredoverflow) {\n setParentWidth(tableRef.current?.parentElement?.getBoundingClientRect().width ?? 0);\n }\n }, [currentConfig, breakpoint]);\n\n useLayoutEvent(() => setWindowWidth(window.innerWidth), ['resize'], 100);\n\n useEffect(() => {\n if (tableWidth === 0 && tableIsVisible) {\n setTableWidth(tableRef.current?.getBoundingClientRect().width ?? 0);\n }\n }, [tableWidth, tableIsVisible]);\n\n const tableStyle =\n currentConfig?.variant === ResponsiveTableVariant.centeredoverflow ? getCenteredOverflowTableStyle(parentWidth, tableWidth) : undefined;\n\n const breakpointClass = getBreakpointClass(currentConfig);\n const tableClass = classNames(styles.table, breakpointClass, className);\n const domRest = omitProps(rest as Record<string, unknown>, ['breakpoint', 'variant', 'fallbackVariant', 'headerCategory']);\n\n const table = (\n <table\n className={tableClass}\n id={id}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Table}\n ref={tableRef}\n style={tableStyle}\n {...(domRest as React.ComponentPropsWithoutRef<'table'>)}\n >\n {mapChildrenWithMode(children, mode)}\n </table>\n );\n\n const ariaLabelAttributes = getAriaLabelAttributes({ label: scrollAriaLabel, id: scrollAriaLabelledById });\n\n if (currentConfig?.variant === ResponsiveTableVariant.horizontalscroll) {\n return (\n <HorizontalScroll childWidth={tableWidth} testId=\"horizontal-scroll\" {...ariaLabelAttributes}>\n {table}\n </HorizontalScroll>\n );\n }\n\n return table;\n};\n\nexport default Table;\n","import { Table } from './Table';\n\nexport { TableBody } from './TableBody';\nexport { TableCell } from './TableCell';\nexport { TableExpandedRow } from './TableExpandedRow';\nexport { TableExpanderCell } from './TableExpanderCell';\nexport { TableHead } from './TableHead';\nexport { TableHeadCell } from './TableHeadCell';\nexport { TableRow } from './TableRow';\nexport { SortDirection, HeaderCategory, TextAlign, ResponsiveTableVariant, ModeType, defaultConfig, simpleConfig } from './constants';\n\nexport * from './Table';\nexport * from './utils';\n\nexport default Table;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6CA,IAAa,SAA0B,EACrC,IACA,QACA,WACA,UACA,mBAAmB,eACnB,OAAO,SAAS,QAChB,iBACA,wBACA,GAAG,WACC;CACJ,MAAM,CAAC,YAAY,iBAAiB,SAAiB,CAAC;CACtD,MAAM,CAAC,aAAa,kBAAkB,SAAiB,CAAC;CACxD,MAAM,CAAC,aAAa,kBAAkB,SAAS,OAAO,UAAU;CAChE,MAAM,WAAW,OAAyB,IAAI;CAC9C,MAAM,iBAAiB,aAAa,UAAU,CAAC;CAC/C,MAAM,aAAa,cAAc;CAEjC,MAAM,gBAAgB,cACd,iBAAiB,kBAAkB,YAAY,YAAY,WAAW,GAC5E;EAAC;EAAkB;EAAY;EAAY;CAAW,CACxD;CAEA,gBAAgB;EACd,IACE,eAAe,YAAY,uBAAuB,oBAClD,eAAe,YAAY,uBAAuB,kBAElD,cAAc,SAAS,SAAS,sBAAsB,CAAC,CAAC,SAAS,CAAC;EAEpE,IAAI,eAAe,YAAY,uBAAuB,kBACpD,eAAe,SAAS,SAAS,eAAe,sBAAsB,CAAC,CAAC,SAAS,CAAC;CAEtF,GAAG,CAAC,eAAe,UAAU,CAAC;CAE9B,qBAAqB,eAAe,OAAO,UAAU,GAAG,CAAC,QAAQ,GAAG,GAAG;CAEvE,gBAAgB;EACd,IAAI,eAAe,KAAK,gBACtB,cAAc,SAAS,SAAS,sBAAsB,CAAC,CAAC,SAAS,CAAC;CAEtE,GAAG,CAAC,YAAY,cAAc,CAAC;CAE/B,MAAM,aACJ,eAAe,YAAY,uBAAuB,mBAAmB,8BAA8B,aAAa,UAAU,IAAI,KAAA;CAEhI,MAAM,kBAAkB,mBAAmB,aAAa;CACxD,MAAM,aAAa,WAAW,OAAO,OAAO,iBAAiB,SAAS;CACtE,MAAM,UAAU,UAAU,MAAiC;EAAC;EAAc;EAAW;EAAmB;CAAgB,CAAC;CAEzH,MAAM,QACJ,oBAAC,SAAD;EACE,WAAW;EACP;EACJ,eAAa;EACb,oBAAkB,YAAY;EAC9B,KAAK;EACL,OAAO;EACP,GAAK;EAEJ,UAAA,oBAAoB,UAAU,IAAI;CAC9B,CAAA;CAGT,MAAM,sBAAsB,uBAAuB;EAAE,OAAO;EAAiB,IAAI;CAAuB,CAAC;CAEzG,IAAI,eAAe,YAAY,uBAAuB,kBACpD,OACE,oBAAC,0BAAD;EAAkB,YAAY;EAAY,QAAO;EAAoB,GAAI;EACtE,UAAA;CACe,CAAA;CAItB,OAAO;AACT;;;AC1GA,IAAA,gBAAe"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Table/Table.tsx","../../../src/components/Table/index.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { Breakpoint } from '../../hooks/useBreakpoint';\n\nimport { defaultConfig, ModeType, ResponsiveTableVariant } from './constants';\nimport { getCurrentConfig, getBreakpointClass, getCenteredOverflowTableStyle, mapChildrenWithMode, omitProps } from './utils';\nimport { AnalyticsId } from '../../constants';\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useLayoutEvent } from '../../hooks/useLayoutEvent';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport HorizontalScroll from '../HorizontalScroll';\n\nimport styles from './styles.module.scss';\n\nexport interface BreakpointConfig {\n /** Breakpoint at which responsive behaviour will be applied. The table component uses a \"desktop first\" approach. */\n breakpoint: keyof typeof Breakpoint;\n /** Desired behaviour on this breakpoint and all smaller screens. */\n variant: keyof typeof ResponsiveTableVariant;\n /** If variant is horizontallscroll, use a fallback instead of device is not a touch device. */\n fallbackVariant?: keyof typeof ResponsiveTableVariant;\n}\n\nexport interface Props extends Omit<React.ComponentPropsWithoutRef<'table'>, 'style'> {\n /** Unique ID */\n id?: string;\n /** Id used for testing */\n testId?: string;\n /** Customize how the table behaves on various screen widths */\n breakpointConfig?: BreakpointConfig | BreakpointConfig[];\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the content of the table. Use TableHead and TableBody */\n children: React.ReactNode;\n /** For display with less space. Discouraged to use together with interactive elements. */\n mode?: ModeType;\n /** Sets aria-label of the horizontal scroll container. scrollAriaLabel or scrollAriaLabelledById MUST be set if horizontal scrolling is enabled! */\n scrollAriaLabel?: string;\n /** Sets aria-labelledby of the horizontal scroll container. scrollAriaLabel or scrollAriaLabelledById MUST be set if horizontal scrolling is enabled! */\n scrollAriaLabelledById?: string;\n}\n\nexport const Table: React.FC<Props> = ({\n id,\n testId,\n className,\n children,\n breakpointConfig = defaultConfig,\n mode = ModeType.normal,\n scrollAriaLabel,\n scrollAriaLabelledById,\n ...rest\n}) => {\n const [tableWidth, setTableWidth] = useState<number>(0);\n const [parentWidth, setParentWidth] = useState<number>(0);\n const [windowWidth, setWindowWidth] = useState(window.innerWidth);\n const tableRef = useRef<HTMLTableElement>(null);\n const tableIsVisible = useIsVisible(tableRef, 0);\n const breakpoint = useBreakpoint();\n\n const currentConfig = useMemo(\n () => getCurrentConfig(breakpointConfig, breakpoint, tableWidth, windowWidth),\n [breakpointConfig, breakpoint, tableWidth, windowWidth]\n );\n\n useEffect(() => {\n if (\n currentConfig?.variant === ResponsiveTableVariant.centeredoverflow ||\n currentConfig?.variant === ResponsiveTableVariant.horizontalscroll\n ) {\n setTableWidth(tableRef.current?.getBoundingClientRect().width ?? 0);\n }\n if (currentConfig?.variant === ResponsiveTableVariant.centeredoverflow) {\n setParentWidth(tableRef.current?.parentElement?.getBoundingClientRect().width ?? 0);\n }\n }, [currentConfig, breakpoint]);\n\n useLayoutEvent(() => setWindowWidth(window.innerWidth), ['resize'], 100);\n\n useEffect(() => {\n if (tableWidth === 0 && tableIsVisible) {\n setTableWidth(tableRef.current?.getBoundingClientRect().width ?? 0);\n }\n }, [tableWidth, tableIsVisible]);\n\n const tableStyle =\n currentConfig?.variant === ResponsiveTableVariant.centeredoverflow ? getCenteredOverflowTableStyle(parentWidth, tableWidth) : undefined;\n\n const breakpointClass = getBreakpointClass(currentConfig);\n const tableClass = classNames(styles.table, breakpointClass, className);\n const domRest = omitProps(rest as Record<string, unknown>, ['breakpoint', 'variant', 'fallbackVariant', 'headerCategory']);\n\n const table = (\n <table\n className={tableClass}\n id={id}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Table}\n ref={tableRef}\n style={tableStyle}\n {...(domRest as React.ComponentPropsWithoutRef<'table'>)}\n >\n {mapChildrenWithMode(children, mode)}\n </table>\n );\n\n const ariaLabelAttributes = getAriaLabelAttributes({ label: scrollAriaLabel, id: scrollAriaLabelledById });\n\n if (currentConfig?.variant === ResponsiveTableVariant.horizontalscroll) {\n return (\n <HorizontalScroll testId=\"horizontal-scroll\" {...ariaLabelAttributes}>\n {table}\n </HorizontalScroll>\n );\n }\n\n return table;\n};\n\nexport default Table;\n","import { Table } from './Table';\n\nexport { TableBody } from './TableBody';\nexport { TableCell } from './TableCell';\nexport { TableExpandedRow } from './TableExpandedRow';\nexport { TableExpanderCell } from './TableExpanderCell';\nexport { TableHead } from './TableHead';\nexport { TableHeadCell } from './TableHeadCell';\nexport { TableRow } from './TableRow';\nexport { SortDirection, HeaderCategory, TextAlign, ResponsiveTableVariant, ModeType, defaultConfig, simpleConfig } from './constants';\n\nexport * from './Table';\nexport * from './utils';\n\nexport default Table;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6CA,IAAa,SAA0B,EACrC,IACA,QACA,WAC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A,oBAAoB,UAAU,IAAI;CAC9B,CAAA;CAGT,MAAM,sBAAsB,uBAAuB;EAAE,OAAO;EAAiB,IAAI;CAAuB,CAAC;CAEzG,IAAI,eAAe,YAAY,uBAAuB,kBACpD,OACE,oBAAC,0BAAD;EAAkB,QAAO;EAAoB,GAAI;EAC9C,UAAA;CACe,CAAA;CAItB,OAAO;AACT;;;AC1GA,IAAA,gBAAe"}
@@ -0,0 +1,9 @@
1
+ interface StackedCellContentProps {
2
+ /** Heading shown before the content in the stack variant */
3
+ headingText?: string;
4
+ /** The content */
5
+ children?: React.ReactNode;
6
+ }
7
+ /** Heading + content as rendered in a stacked cell. Shared by UNSAFE_TableCell and UNSAFE_TableDetail. */
8
+ export declare const StackedCellContent: React.FC<StackedCellContentProps>;
9
+ export default StackedCellContent;
@@ -0,0 +1,10 @@
1
+ export interface TableCaptionProps {
2
+ /** Unique ID. Can be used with aria-labelledby, e.g. for the scroll container. */
3
+ id?: string;
4
+ /** Adds custom classes to the element. */
5
+ className?: string;
6
+ /** Sets the content of the caption. */
7
+ children: React.ReactNode;
8
+ }
9
+ export declare const TableCaption: React.FC<TableCaptionProps>;
10
+ export default TableCaption;
@@ -0,0 +1,22 @@
1
+ import { HNDesignsystemTable } from '../../resources/Resources';
2
+ import { ResponsiveTableVariant, TableColors, TableSizes } from './constants';
3
+ export interface TableContextValue {
4
+ /** Resolved responsive variant for the current breakpoint. */
5
+ variant: keyof typeof ResponsiveTableVariant;
6
+ /** Header category for styling. */
7
+ color: TableColors;
8
+ /** For display with less space. */
9
+ size: TableSizes;
10
+ /** Whether zebra stripes are enabled. Applied by UNSAFE_TableBody, which can also override it. */
11
+ zebraStripes: boolean;
12
+ /** Indexes of the columns marked with hideBehindExpander on their UNSAFE_TableHeadCell. */
13
+ hiddenColumns: number[];
14
+ /** Text of each column's UNSAFE_TableHeadCell, used as the default heading of cells in the stack variant. */
15
+ headingTexts: string[];
16
+ /** Resource texts of the Table. */
17
+ resources: HNDesignsystemTable;
18
+ }
19
+ /** Table-wide configuration provided by UNSAFE_Table. */
20
+ export declare const TableContext: import('react').Context<TableContextValue>;
21
+ /** Heading of the column a cell belongs to. Provided per cell by UNSAFE_TableRow. */
22
+ export declare const CellHeadingContext: import('react').Context<string>;
@@ -0,0 +1,37 @@
1
+ import { HNDesignsystemTable } from '../../resources/Resources';
2
+ import { ResponsiveTableVariant, TableColors, TableSizes } from './constants';
3
+ import { Breakpoint } from '../../hooks/useBreakpoint';
4
+ export interface BreakpointConfig {
5
+ /** Breakpoint at which responsive behaviour will be applied. The table component uses a "desktop first" approach. */
6
+ breakpoint: keyof typeof Breakpoint;
7
+ /** Desired behaviour on this breakpoint and all smaller screens. */
8
+ variant: keyof typeof ResponsiveTableVariant;
9
+ /** If variant is horizontallscroll, use a fallback instead of device is not a touch device. */
10
+ fallbackVariant?: keyof typeof ResponsiveTableVariant;
11
+ }
12
+ export interface UNSAFE_TableProps extends Omit<React.ComponentPropsWithoutRef<'table'>, 'style'> {
13
+ /** Customize how the table behaves on various screen widths */
14
+ breakpointConfig?: BreakpointConfig | BreakpointConfig[];
15
+ /** Description of the table for screen readers. Rendered as a visually hidden caption and used to label the scroll container. */
16
+ caption: string;
17
+ /** Sets the content of the table. Use TableHead and UNSAFE_TableBody */
18
+ children: React.ReactNode;
19
+ /** Adds custom classes to the element. */
20
+ className?: string;
21
+ /** Header category for styling. Default: normal */
22
+ color?: TableColors;
23
+ /** Unique ID */
24
+ id?: string;
25
+ /** Resources for component */
26
+ resources?: Partial<HNDesignsystemTable>;
27
+ /** For display with less space. Discouraged to use together with interactive elements. */
28
+ size?: TableSizes;
29
+ /** Width of the head column in percentage in the stack variant. When not set, the column follows the widest heading in the table, but wraps (minimum 30%) when the content needs the space. */
30
+ stackHeadWidth?: number;
31
+ /** Id used for testing */
32
+ testId?: string;
33
+ /** Applies zebra stripes to every other row. Default: false */
34
+ zebraStripes?: boolean;
35
+ }
36
+ export declare const UNSAFE_Table: React.FC<UNSAFE_TableProps>;
37
+ export default UNSAFE_Table;
@@ -0,0 +1,10 @@
1
+ export interface Props extends Omit<React.ComponentPropsWithoutRef<'tbody'>, 'style'> {
2
+ /** Adds custom classes to the element. */
3
+ className?: string;
4
+ /** Sets the content of the table body. Use TableRows */
5
+ children?: React.ReactNode;
6
+ /** Applies zebra stripes to every other row. Overrides the value from UNSAFE_Table. */
7
+ zebraStripes?: boolean;
8
+ }
9
+ export declare const UNSAFE_TableBody: React.FC<Props>;
10
+ export default UNSAFE_TableBody;
@@ -0,0 +1,3 @@
1
+ import { default as UNSAFE_TableBody } from './UNSAFE_TableBody';
2
+ export * from './UNSAFE_TableBody';
3
+ export default UNSAFE_TableBody;
@@ -0,0 +1,2 @@
1
+ import { n as UNSAFE_TableBody, t as UNSAFE_TableBody_default } from "../../../UNSAFE_TableBody.js";
2
+ export { UNSAFE_TableBody, UNSAFE_TableBody_default as default };
@@ -0,0 +1,15 @@
1
+ import { TextAlign } from '../constants';
2
+ export interface Props extends Omit<React.ComponentPropsWithoutRef<'td'>, 'style'> {
3
+ /** text align in cell */
4
+ textAlign?: TextAlign;
5
+ /** nowrap for white space */
6
+ nowrap?: boolean;
7
+ /** Adds custom classes to the element. */
8
+ className?: string;
9
+ /** Sets the content of the table cell */
10
+ children?: React.ReactNode;
11
+ /** For test purposes */
12
+ testId?: string;
13
+ }
14
+ export declare const UNSAFE_TableCell: React.FC<Props>;
15
+ export default UNSAFE_TableCell;
@@ -0,0 +1,3 @@
1
+ import { default as UNSAFE_TableCell } from './UNSAFE_TableCell';
2
+ export * from './UNSAFE_TableCell';
3
+ export default UNSAFE_TableCell;
@@ -0,0 +1,7 @@
1
+ import { t as UNSAFE_TableCell } from "../../../UNSAFE_TableCell.js";
2
+ //#region src/components/UNSAFE_Table/UNSAFE_TableCell/index.ts
3
+ var UNSAFE_TableCell_default = UNSAFE_TableCell;
4
+ //#endregion
5
+ export { UNSAFE_TableCell, UNSAFE_TableCell_default as default };
6
+
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/UNSAFE_Table/UNSAFE_TableCell/index.ts"],"sourcesContent":["import UNSAFE_TableCell from './UNSAFE_TableCell';\nexport * from './UNSAFE_TableCell';\nexport default UNSAFE_TableCell;\n"],"mappings":";;AAEA,IAAA,2BAAe"}
@@ -0,0 +1,12 @@
1
+ export interface Props {
2
+ /** Heading shown before the content */
3
+ headingText: string;
4
+ /** Adds custom classes to the element. */
5
+ className?: string;
6
+ /** The content, typically the value of a column hidden with hideBehindExpander */
7
+ children?: React.ReactNode;
8
+ /** Sets the data-testid attribute. */
9
+ testId?: string;
10
+ }
11
+ export declare const UNSAFE_TableDetail: React.FC<Props>;
12
+ export default UNSAFE_TableDetail;
@@ -0,0 +1,3 @@
1
+ import { default as UNSAFE_TableDetail } from './UNSAFE_TableDetail';
2
+ export * from './UNSAFE_TableDetail';
3
+ export default UNSAFE_TableDetail;
@@ -0,0 +1,7 @@
1
+ import { t as UNSAFE_TableDetail } from "../../../UNSAFE_TableDetail.js";
2
+ //#region src/components/UNSAFE_Table/UNSAFE_TableDetail/index.ts
3
+ var UNSAFE_TableDetail_default = UNSAFE_TableDetail;
4
+ //#endregion
5
+ export { UNSAFE_TableDetail, UNSAFE_TableDetail_default as default };
6
+
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/UNSAFE_Table/UNSAFE_TableDetail/index.ts"],"sourcesContent":["import UNSAFE_TableDetail from './UNSAFE_TableDetail';\nexport * from './UNSAFE_TableDetail';\nexport default UNSAFE_TableDetail;\n"],"mappings":";;AAEA,IAAA,6BAAe"}
@@ -0,0 +1,17 @@
1
+ import { default as React } from 'react';
2
+ export interface Props {
3
+ /** Row is expanded. */
4
+ expanded: boolean;
5
+ /** When hide button inside expanded row is clicked. */
6
+ toggleClick: () => void;
7
+ /** Adds custom classes to the element. */
8
+ className?: string;
9
+ /** Sets the content of the expanded row. */
10
+ children: React.ReactNode;
11
+ /** Only display the expanded row in the stack variant. */
12
+ stackOnly?: boolean;
13
+ /** Row id. For use with aria-controls. */
14
+ id?: string;
15
+ }
16
+ export declare const UNSAFE_TableExpandedRow: ({ expanded, toggleClick, children, className, stackOnly, id }: Props) => React.JSX.Element;
17
+ export default UNSAFE_TableExpandedRow;
@@ -0,0 +1,3 @@
1
+ import { default as UNSAFE_TableExpandedRow } from './UNSAFE_TableExpandedRow';
2
+ export * from './UNSAFE_TableExpandedRow';
3
+ export default UNSAFE_TableExpandedRow;
@@ -0,0 +1,7 @@
1
+ import { t as UNSAFE_TableExpandedRow } from "../../../UNSAFE_TableExpandedRow.js";
2
+ //#region src/components/UNSAFE_Table/UNSAFE_TableExpandedRow/index.ts
3
+ var UNSAFE_TableExpandedRow_default = UNSAFE_TableExpandedRow;
4
+ //#endregion
5
+ export { UNSAFE_TableExpandedRow, UNSAFE_TableExpandedRow_default as default };
6
+
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/UNSAFE_Table/UNSAFE_TableExpandedRow/index.ts"],"sourcesContent":["import UNSAFE_TableExpandedRow from './UNSAFE_TableExpandedRow';\nexport * from './UNSAFE_TableExpandedRow';\nexport default UNSAFE_TableExpandedRow;\n"],"mappings":";;AAEA,IAAA,kCAAe"}
@@ -0,0 +1,4 @@
1
+ import { Props } from '../UNSAFE_TableRow/UNSAFE_TableRow';
2
+ type UNSAFE_TableExpanderCellMobileProps = Pick<Props, 'expanded' | 'onClick' | 'expandableRowId'>;
3
+ declare const UNSAFE_TableExpanderCellMobile: React.FC<UNSAFE_TableExpanderCellMobileProps>;
4
+ export default UNSAFE_TableExpanderCellMobile;
@@ -0,0 +1,8 @@
1
+ export interface Props extends Omit<React.ComponentPropsWithoutRef<'thead'>, 'style'> {
2
+ /** Adds custom classes to the element. */
3
+ className?: string;
4
+ /** Sets the content of the thead. Add table rows */
5
+ children: React.ReactNode;
6
+ }
7
+ export declare const UNSAFE_TableHead: React.FC<Props>;
8
+ export default UNSAFE_TableHead;
@@ -0,0 +1,3 @@
1
+ import { default as UNSAFE_TableHead } from './UNSAFE_TableHead';
2
+ export * from './UNSAFE_TableHead';
3
+ export default UNSAFE_TableHead;
@@ -0,0 +1,7 @@
1
+ import { t as UNSAFE_TableHead } from "../../../UNSAFE_TableHead.js";
2
+ //#region src/components/UNSAFE_Table/UNSAFE_TableHead/index.ts
3
+ var UNSAFE_TableHead_default = UNSAFE_TableHead;
4
+ //#endregion
5
+ export { UNSAFE_TableHead, UNSAFE_TableHead_default as default };
6
+
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/UNSAFE_Table/UNSAFE_TableHead/index.ts"],"sourcesContent":["import UNSAFE_TableHead from './UNSAFE_TableHead';\nexport * from './UNSAFE_TableHead';\nexport default UNSAFE_TableHead;\n"],"mappings":";;AAEA,IAAA,2BAAe"}
@@ -0,0 +1,15 @@
1
+ import { SortDirection } from '../constants';
2
+ export interface Props extends Omit<React.ComponentPropsWithoutRef<'th'>, 'style'> {
3
+ /** Sort direction */
4
+ sortDir?: SortDirection;
5
+ /** Adds custom classes to the element. */
6
+ className?: string;
7
+ /** Sets the content of the td element. */
8
+ children?: React.ReactNode;
9
+ /** Sets the width of the column, e.g. '10rem', '25%' or a number of pixels. Ignored in the stack variant. */
10
+ width?: string | number;
11
+ /** In the stack variant, hides the cells of this column and shows the column heading + content in an automatically rendered expanded row. */
12
+ hideBehindExpander?: boolean;
13
+ }
14
+ export declare const UNSAFE_TableHeadCell: React.FC<Props>;
15
+ export default UNSAFE_TableHeadCell;
@@ -0,0 +1,3 @@
1
+ import { default as UNSAFE_TableHeadCell } from './UNSAFE_TableHeadCell';
2
+ export * from './UNSAFE_TableHeadCell';
3
+ export default UNSAFE_TableHeadCell;
@@ -0,0 +1,2 @@
1
+ import { n as UNSAFE_TableHeadCell, t as UNSAFE_TableHeadCell_default } from "../../../UNSAFE_TableHeadCell.js";
2
+ export { UNSAFE_TableHeadCell, UNSAFE_TableHeadCell_default as default };
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+ import { PopMenuProps } from '../../PopMenu';
3
+ export interface UNSAFE_TablePopMenuCellProps {
4
+ /** PopMenu shown inside the cell. Fills the entire cell. */
5
+ children: React.ReactElement<PopMenuProps>;
6
+ }
7
+ declare const UNSAFE_TablePopMenuCell: React.FC<UNSAFE_TablePopMenuCellProps>;
8
+ export default UNSAFE_TablePopMenuCell;
@@ -0,0 +1,20 @@
1
+ import { default as React } from 'react';
2
+ import { PopMenuProps } from '../../PopMenu';
3
+ export interface Props extends Omit<React.ComponentPropsWithoutRef<'tr'>, 'style'> {
4
+ /** Content to be rendered in an expandable row. Make sure to add an empty TableHeadCell to the beginning of the Table. This content renders below the column content with hideBehindExpander set in the stack variant. */
5
+ expandedContent?: React.ReactNode;
6
+ /** Sets if expanded row is expanded */
7
+ expanded?: boolean;
8
+ /** Id of the expanded row this row controls. For use with aria-controls on the expander button. */
9
+ expandableRowId?: string;
10
+ /** When hide/show button for expanded row is clicked. */
11
+ onClick?: () => void;
12
+ /** Adds custom classes to the element. */
13
+ className?: string;
14
+ /** Sets the cells of the table row element. */
15
+ children?: React.ReactNode;
16
+ /** PopMenu rendered in an extra cell as the last cell in the row. Fills the entire cell. Outside the stack variant labelText is hidden and used as aria-label instead. */
17
+ popMenu?: React.ReactElement<PopMenuProps>;
18
+ }
19
+ export declare const UNSAFE_TableRow: React.FC<Props>;
20
+ export default UNSAFE_TableRow;
@@ -0,0 +1,3 @@
1
+ import { default as UNSAFE_TableRow } from './UNSAFE_TableRow';
2
+ export * from './UNSAFE_TableRow';
3
+ export default UNSAFE_TableRow;