@helsenorge/designsystem-react 15.4.0 → 15.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/AnchorLink.js +4 -4
- package/lib/AnchorLink.js.map +1 -1
- package/lib/AsChildSlot.js.map +1 -1
- package/lib/Avatar.js +2 -2
- package/lib/Avatar.js.map +1 -1
- package/lib/Badge.js +2 -2
- package/lib/Badge.js.map +1 -1
- package/lib/Button.js +6 -6
- package/lib/Button.js.map +1 -1
- package/lib/CHANGELOG.md +25 -0
- package/lib/Checkbox.js +12 -10
- package/lib/Checkbox.js.map +1 -1
- package/lib/Checkbox2.js +2 -2
- package/lib/Checkbox2.js.map +1 -1
- package/lib/CheckboxMarker.js +2 -2
- package/lib/CheckboxMarker.js.map +1 -1
- package/lib/Chip.js +4 -4
- package/lib/Chip.js.map +1 -1
- package/lib/Close.js +3 -3
- package/lib/Close.js.map +1 -1
- package/lib/DictionaryTrigger.js +2 -2
- package/lib/DictionaryTrigger.js.map +1 -1
- package/lib/Drawer.js +13 -13
- package/lib/Drawer.js.map +1 -1
- package/lib/DrawerNavigation.js +1 -1
- package/lib/DrawerNavigation.js.map +1 -1
- package/lib/Duolist.js +5 -5
- package/lib/Duolist.js.map +1 -1
- package/lib/ElementHeader.js +9 -9
- package/lib/ElementHeader.js.map +1 -1
- package/lib/ElementHeaderText.js +4 -4
- package/lib/ElementHeaderText.js.map +1 -1
- package/lib/ErrorWrapper.js +3 -2
- package/lib/ErrorWrapper.js.map +1 -1
- package/lib/Expander.js +9 -8
- package/lib/Expander.js.map +1 -1
- package/lib/FilterButton.js +2 -2
- package/lib/FilterButton.js.map +1 -1
- package/lib/FilterButtonAndChipsWrapper.js +2 -2
- package/lib/FilterButtonAndChipsWrapper.js.map +1 -1
- package/lib/FilterDrawer.js.map +1 -1
- package/lib/FilterLinkList.js +5 -4
- package/lib/FilterLinkList.js.map +1 -1
- package/lib/FilterOverviewSearch.js +2 -2
- package/lib/FilterOverviewSearch.js.map +1 -1
- package/lib/FilterResultCountAndSortWrapper.js.map +1 -1
- package/lib/FilterSearch.js +31 -18
- package/lib/FilterSearch.js.map +1 -1
- package/lib/FormFieldTag.js +2 -2
- package/lib/FormFieldTag.js.map +1 -1
- package/lib/FormGroup.js +5 -5
- package/lib/FormGroup.js.map +1 -1
- package/lib/FormLayout.js +3 -3
- package/lib/FormLayout.js.map +1 -1
- package/lib/HelpDetails.js +5 -4
- package/lib/HelpDetails.js.map +1 -1
- package/lib/HelpTriggerIcon.js +2 -2
- package/lib/HelpTriggerIcon.js.map +1 -1
- package/lib/HelpTriggerStandalone.js +2 -2
- package/lib/HelpTriggerStandalone.js.map +1 -1
- package/lib/HighlightPanel.js +4 -4
- package/lib/HighlightPanel.js.map +1 -1
- package/lib/Highlighter.js +1 -1
- package/lib/Highlighter.js.map +1 -1
- package/lib/HorizontalScroll.js +4 -4
- package/lib/HorizontalScroll.js.map +1 -1
- package/lib/Icon.js +2 -2
- package/lib/Icon.js.map +1 -1
- package/lib/Illustration.js.map +1 -1
- package/lib/InfoTeaser.js +3 -3
- package/lib/InfoTeaser.js.map +1 -1
- package/lib/Input.js +12 -6
- package/lib/Input.js.map +1 -1
- package/lib/LazyIcon.js +1 -0
- package/lib/LazyIcon.js.map +1 -1
- package/lib/LazyIllustration.js.map +1 -1
- package/lib/LinkList.js +36 -33
- package/lib/LinkList.js.map +1 -1
- package/lib/List.js +5 -3
- package/lib/List.js.map +1 -1
- package/lib/ListEditMode.js +8 -7
- package/lib/ListEditMode.js.map +1 -1
- package/lib/LoaderSpinner.js.map +1 -1
- package/lib/MaxCharacters.js +2 -2
- package/lib/MaxCharacters.js.map +1 -1
- package/lib/PanelTitle.js +2 -2
- package/lib/PanelTitle.js.map +1 -1
- package/lib/PopOver.js +7 -4
- package/lib/PopOver.js.map +1 -1
- package/lib/Radio.js +2 -2
- package/lib/Radio.js.map +1 -1
- package/lib/RadioButton.js +5 -5
- package/lib/RadioButton.js.map +1 -1
- package/lib/RadioMarker.js +12 -11
- package/lib/RadioMarker.js.map +1 -1
- package/lib/Select.js +4 -4
- package/lib/Select.js.map +1 -1
- package/lib/SingleSelectItem.js +3 -3
- package/lib/SingleSelectItem.js.map +1 -1
- package/lib/Slider.js +10 -8
- package/lib/Slider.js.map +1 -1
- package/lib/Spacer.js +17 -16
- package/lib/Spacer.js.map +1 -1
- package/lib/StatusDot.js +4 -4
- package/lib/StatusDot.js.map +1 -1
- package/lib/StatusDotList.js +2 -2
- package/lib/StatusDotList.js.map +1 -1
- package/lib/StepButtons.js +5 -5
- package/lib/StepButtons.js.map +1 -1
- package/lib/TabList.js +8 -8
- package/lib/TabList.js.map +1 -1
- package/lib/TabPanel.js +3 -2
- package/lib/TabPanel.js.map +1 -1
- package/lib/TableBody.js +4 -3
- package/lib/TableBody.js.map +1 -1
- package/lib/TableCell.js +4 -3
- package/lib/TableCell.js.map +1 -1
- package/lib/TableExpandedRow.js +8 -5
- package/lib/TableExpandedRow.js.map +1 -1
- package/lib/TableExpanderCell.js +4 -3
- package/lib/TableExpanderCell.js.map +1 -1
- package/lib/TableHead.js +9 -8
- package/lib/TableHead.js.map +1 -1
- package/lib/TableHeadCell.js +6 -6
- package/lib/TableHeadCell.js.map +1 -1
- package/lib/TableRow.js +9 -7
- package/lib/TableRow.js.map +1 -1
- package/lib/Textarea.js +6 -6
- package/lib/Textarea.js.map +1 -1
- package/lib/Title.js +21 -18
- package/lib/Title.js.map +1 -1
- package/lib/Toast.js +3 -3
- package/lib/Toast.js.map +1 -1
- package/lib/VisualCheckbox.js +3 -3
- package/lib/VisualCheckbox.js.map +1 -1
- package/lib/VisualRadio.js +3 -3
- package/lib/VisualRadio.js.map +1 -1
- package/lib/__mocks__/matchMedia.js.map +1 -1
- package/lib/__mocks__/usePseudoClasses.js.map +1 -1
- package/lib/__mocks__/useSize.js.map +1 -1
- package/lib/__mocks__/uuid.js +1 -1
- package/lib/__mocks__/uuid.js.map +1 -1
- package/lib/components/ArticleTeaser/index.js +4 -4
- package/lib/components/ArticleTeaser/index.js.map +1 -1
- package/lib/components/Dropdown/index.js +5 -5
- package/lib/components/Dropdown/index.js.map +1 -1
- package/lib/components/DropdownOld/index.js +3 -3
- package/lib/components/DropdownOld/index.js.map +1 -1
- package/lib/components/EmptyState/index.js +3 -5
- package/lib/components/EmptyState/index.js.map +1 -1
- package/lib/components/ExpanderHierarchy/index.js +8 -7
- package/lib/components/ExpanderHierarchy/index.js.map +1 -1
- package/lib/components/ExpanderList/index.js +12 -11
- package/lib/components/ExpanderList/index.js.map +1 -1
- package/lib/components/EyebrowHeader/index.js.map +1 -1
- package/lib/components/FavoriteButton/index.js +11 -9
- package/lib/components/FavoriteButton/index.js.map +1 -1
- package/lib/components/Filter/FilterSearch/FilterSearch.d.ts +2 -0
- package/lib/components/Filter/FilterSearch/styles.module.scss +32 -7
- package/lib/components/Filter/FilterSearch/styles.module.scss.d.ts +2 -0
- package/lib/components/Filter/index.js.map +1 -1
- package/lib/components/HelpBubble/index.js +3 -3
- package/lib/components/HelpBubble/index.js.map +1 -1
- package/lib/components/HelpExpanderInline/index.js.map +1 -1
- package/lib/components/HelpExpanderStandalone/index.js.map +1 -1
- package/lib/components/HelpPanel/index.js +2 -2
- package/lib/components/HelpPanel/index.js.map +1 -1
- package/lib/components/HelpTooltip/index.js +6 -3
- package/lib/components/HelpTooltip/index.js.map +1 -1
- package/lib/components/HelpTriggerInline/index.js +2 -2
- package/lib/components/HelpTriggerInline/index.js.map +1 -1
- package/lib/components/Icons/AlarmClock.js.map +1 -1
- package/lib/components/Icons/ArrowUpRight.js +4 -4
- package/lib/components/Icons/ArrowUpRight.js.map +1 -1
- package/lib/components/Icons/ArrowUpRightLight.d.ts +3 -0
- package/lib/components/Icons/ArrowUpRightLight.js +17 -0
- package/lib/components/Icons/ArrowUpRightLight.js.map +1 -0
- package/lib/components/Icons/Bus.js.map +1 -1
- package/lib/components/Icons/IconNames.d.ts +1 -1
- package/lib/components/Icons/IconNames.js +1 -0
- package/lib/components/Icons/IconNames.js.map +1 -1
- package/lib/components/Illustrations/BabyMobile.js +5 -4
- package/lib/components/Illustrations/BabyMobile.js.map +1 -1
- package/lib/components/Illustrations/BabyMobileMedium.js.map +1 -1
- package/lib/components/Illustrations/Child.js +5 -4
- package/lib/components/Illustrations/Child.js.map +1 -1
- package/lib/components/Illustrations/ChildMedium.js.map +1 -1
- package/lib/components/Illustrations/Doctor.js +10 -8
- package/lib/components/Illustrations/Doctor.js.map +1 -1
- package/lib/components/Illustrations/DoctorMedium.js.map +1 -1
- package/lib/components/Illustrations/DoctorSmall.js.map +1 -1
- package/lib/components/Illustrations/EyeContact.js +5 -4
- package/lib/components/Illustrations/EyeContact.js.map +1 -1
- package/lib/components/Illustrations/EyeContactMedium.js.map +1 -1
- package/lib/components/Illustrations/FacialRecognitionFingerprint.js +5 -4
- package/lib/components/Illustrations/FacialRecognitionFingerprint.js.map +1 -1
- package/lib/components/Illustrations/FacialRecognitionFingerprintMedium.js.map +1 -1
- package/lib/components/Illustrations/GiveBabyFood.js +5 -4
- package/lib/components/Illustrations/GiveBabyFood.js.map +1 -1
- package/lib/components/Illustrations/GiveBabyFoodMedium.js.map +1 -1
- package/lib/components/Illustrations/HealthcarePersonnel.js +10 -8
- package/lib/components/Illustrations/HealthcarePersonnel.js.map +1 -1
- package/lib/components/Illustrations/HealthcarePersonnelMedium.js.map +1 -1
- package/lib/components/Illustrations/HealthcarePersonnelSmall.js.map +1 -1
- package/lib/components/Illustrations/ReadLetters.js +5 -4
- package/lib/components/Illustrations/ReadLetters.js.map +1 -1
- package/lib/components/Illustrations/ReadLettersMedium.js.map +1 -1
- package/lib/components/Illustrations/SkinToSkin.js +5 -4
- package/lib/components/Illustrations/SkinToSkin.js.map +1 -1
- package/lib/components/Illustrations/SkinToSkinMedium.js.map +1 -1
- package/lib/components/Illustrations/Stork.js +5 -4
- package/lib/components/Illustrations/Stork.js.map +1 -1
- package/lib/components/Illustrations/StorkMedium.js.map +1 -1
- package/lib/components/Illustrations/Stroller.js +5 -4
- package/lib/components/Illustrations/Stroller.js.map +1 -1
- package/lib/components/Illustrations/StrollerMedium.js.map +1 -1
- package/lib/components/Illustrations/Support2.js +5 -4
- package/lib/components/Illustrations/Support2.js.map +1 -1
- package/lib/components/Illustrations/Support2Medium.js.map +1 -1
- package/lib/components/Illustrations/Thinking.js +5 -4
- package/lib/components/Illustrations/Thinking.js.map +1 -1
- package/lib/components/Illustrations/ThinkingMedium.js.map +1 -1
- package/lib/components/Loader/index.js +19 -18
- package/lib/components/Loader/index.js.map +1 -1
- package/lib/components/Logo/index.js.map +1 -1
- package/lib/components/Modal/index.js +10 -10
- package/lib/components/Modal/index.js.map +1 -1
- package/lib/components/NotificationPanel/index.js +12 -9
- package/lib/components/NotificationPanel/index.js.map +1 -1
- package/lib/components/Panel/index.js +25 -24
- package/lib/components/Panel/index.js.map +1 -1
- package/lib/components/PanelList/index.js +3 -3
- package/lib/components/PanelList/index.js.map +1 -1
- package/lib/components/PopMenu/index.js +3 -3
- package/lib/components/PopMenu/index.js.map +1 -1
- package/lib/components/Portal/index.js.map +1 -1
- package/lib/components/Progressbar/index.js +7 -6
- package/lib/components/Progressbar/index.js.map +1 -1
- package/lib/components/PromoPanel/PromoPanel.d.ts +2 -2
- package/lib/components/PromoPanel/index.js +13 -9
- package/lib/components/PromoPanel/index.js.map +1 -1
- package/lib/components/RadioButton/RadioMarker/styles.module.scss +3 -9
- package/lib/components/ServiceMessage/index.js +6 -5
- package/lib/components/ServiceMessage/index.js.map +1 -1
- package/lib/components/SharingStatus/index.js +4 -4
- package/lib/components/SharingStatus/index.js.map +1 -1
- package/lib/components/Step/index.js +2 -2
- package/lib/components/Step/index.js.map +1 -1
- package/lib/components/Stepper/index.js +5 -3
- package/lib/components/Stepper/index.js.map +1 -1
- package/lib/components/StickyNote/index.js +8 -8
- package/lib/components/StickyNote/index.js.map +1 -1
- package/lib/components/Table/index.js +5 -8
- package/lib/components/Table/index.js.map +1 -1
- package/lib/components/Tabs/index.js +4 -4
- package/lib/components/Tabs/index.js.map +1 -1
- package/lib/components/Tag/index.js +3 -2
- package/lib/components/Tag/index.js.map +1 -1
- package/lib/components/TagList/index.js.map +1 -1
- package/lib/components/Tile/index.js +8 -7
- package/lib/components/Tile/index.js.map +1 -1
- package/lib/components/ToastList/index.js +3 -2
- package/lib/components/ToastList/index.js.map +1 -1
- package/lib/components/Toggle/index.js +13 -10
- package/lib/components/Toggle/index.js.map +1 -1
- package/lib/components/Validation/index.js +2 -2
- package/lib/components/Validation/index.js.map +1 -1
- package/lib/components/VisualCheckboxCloud/index.js +2 -2
- package/lib/components/VisualCheckboxCloud/index.js.map +1 -1
- package/lib/components/VisualCheckboxGroup/index.js +3 -3
- package/lib/components/VisualCheckboxGroup/index.js.map +1 -1
- package/lib/components/VisualContentgroupWithImage/index.js +2 -2
- package/lib/components/VisualContentgroupWithImage/index.js.map +1 -1
- package/lib/components/VisualRadioCloud/index.js +2 -2
- package/lib/components/VisualRadioCloud/index.js.map +1 -1
- package/lib/components/VisualRadioGroup/index.js +3 -3
- package/lib/components/VisualRadioGroup/index.js.map +1 -1
- package/lib/floating-ui.react.js +100 -117
- package/lib/floating-ui.react.js.map +1 -1
- package/lib/getFilterChips.js.map +1 -1
- package/lib/hooks/useBreakpoint.js.map +1 -1
- package/lib/hooks/useFocusableElements.js.map +1 -1
- package/lib/hooks/useIsVisible.js.map +1 -1
- package/lib/hooks/useOutsideEvent.js.map +1 -1
- package/lib/hooks/useResizeObserver.js.map +1 -1
- package/lib/hooks/useRovingFocus.js.map +1 -1
- package/lib/hooks/useSize.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/theme/spacers.js +2 -2
- package/lib/theme/spacers.js.map +1 -1
- package/lib/utils/focus.js.map +1 -1
- package/lib/utils/mobile.js.map +1 -1
- package/lib/utils/uuid.js +29 -2
- package/lib/utils/uuid.js.map +1 -0
- package/lib/utils2.js +7 -7
- package/lib/utils2.js.map +1 -1
- package/lib/utils5.js +2 -2
- package/lib/utils5.js.map +1 -1
- package/package.json +1 -1
- package/lib/uuid.js +0 -29
- package/lib/uuid.js.map +0 -1
|
@@ -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 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,gBAAL,yBAAA,eAAA;CACL,cAAA,YAAA;CACA,cAAA,aAAA;CACA,cAAA,WAAA;CACA,cAAA,aAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,YAAL,yBAAA,WAAA;CACL,UAAA,WAAA;CACA,UAAA,YAAA;;AACF,EAAA,CAAA,CAAA;;;ACkEA,IAAM,kBAAkB,YAA8D;CACpF,IAAI,YAAY,cAAc,OAC5B,OAAO,oBAAC,cAAD;EAAM,MAAM,SAAS;EAAO,SAAS;EAAe,OAAO,QAAQ;CAAY,CAAA;MACjF,IAAI,YAAY,cAAc,SACnC,OAAO,oBAAC,cAAD;EAAM,MAAM,SAAS;EAAO,SAAS;EAAiB,OAAO,QAAQ;CAAQ,CAAA;MAC/E,IAAI,YAAY,cAAc,SACnC,OAAO,oBAAC,cAAD;EAAM,MAAM,SAAS;EAAO,SAAS;EAAc,OAAO,QAAQ;CAAU,CAAA;CAErF,OAAO;AACT;AAEA,IAAM,WAAW,SAAiC,SAAwD;CACxG,MAAM,cAAc,eAAe,OAAO;CAC1C,IAAI,aACF,OAAO,oBAAC,OAAD;EAAK,WAAW,OAAO;YAAqB;CAAiB,CAAA;CAEtE,IAAI,MACF,OACE,oBAAC,OAAD;EAAK,WAAW,OAAO;YACpB,YAAuB,MAAM,YAAI,KAChC,MAAM,aAAa,MAAM,EACvB,MAAM,SAAS,MACjB,CAAC;CACA,CAAA;CAGT,OAAO;AACT;AAEA,IAAM,SAA8B,UAAS;CAC3C,MAAM,EACJ,eACA,UA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BAAC,OAAD;UAAK,WAAW,OAAO;oBAAvB;WACG,QAAQ,SAAS,MAAM,IAAI;WAC5B,oBAAC,OAAD;YAAO,IAAI,sBAAsB;YAAoB,YAAW;YAAK,YAAW;YAAS,WAAW;sBACjG,MAAM;WACF,CAAA;WACN,MAAM,sBAAsB,oBAAC,OAAD;YAAK,WAAW,OAAO;sBAA+B,MAAM;WAAwB,CAAA;UAC9G;;SACJ,MAAM,YAAY,oBAAC,OAAD,EAAA,UAAM,MAAM,SAAc,CAAA;SAC5C,CAAC,MAAM,YAAY,oBAAC,KAAD;UAAG,WAAW,OAAO;oBAAqB,MAAM;SAAe,CAAA;SACnF,oBAAC,OAAD,EAAK,KAAK,cAAgB,CAAA;QACvB;SACF;;MACL,oBAAC,OAAD,EACE,WAAW,GAAG,OAAO,kBAAkB,OAAO,0BAA0B,GACrE,OAAO,yBAAyB,CAAC,wBAAwB,oBAC5D,CAAC,EACF,CAAA;MACA,eACC,qBAAC,OAAD;OAAK,WAAW,GAAG,OAAO,0BAA0B,QAAQ,OAAO,0BAA0B,OAAO;iBAApG;QACG,MAAM,aAAa,qBAAqB,oBAAC,gBAAD;SAAQ,SAAS,MAAM;mBAAY;QAA0B,CAAA;QACrG,MAAM,uBAAuB,MAAM,qBAAqB,SAAS,KAChE,oBAAC,gBAAD;SAAQ,SAAQ;SAAa,SAAS,MAAM;mBACzC,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;aAAtC,CACE,oBAAC,SAAD;IAAO,OAAM;cAAS,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 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 './Mod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AW;YAAS,WAAW;YACjG,UAAA,MAAM;WACF,CAAA;WACN,MAAM,sBAAsB,oBAAC,OAAD;YAAK,WAAW,OAAO;YAA+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"}
|
|
@@ -5,16 +5,19 @@ import { useIdWithFallback } from "../../hooks/useIdWithFallback.js";
|
|
|
5
5
|
import { getAriaLabelAttributes } from "../../utils/accessibility.js";
|
|
6
6
|
import { t as Close_default } from "../../Close.js";
|
|
7
7
|
import { t as Expander_default } from "../../Expander.js";
|
|
8
|
-
import
|
|
8
|
+
import classNames 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
|
//#region src/components/NotificationPanel/NotificationPanel.tsx
|
|
13
13
|
var FluidWrapper = ({ fluid, children }) => {
|
|
14
|
-
if (fluid)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
if (fluid) {
|
|
15
|
+
const fluidClasses = classNames(styles["fluid-wrapper"]);
|
|
16
|
+
return /* @__PURE__ */ jsx("div", {
|
|
17
|
+
className: fluidClasses,
|
|
18
|
+
children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
18
21
|
return children;
|
|
19
22
|
};
|
|
20
23
|
var NotificationPanel = (props) => {
|
|
@@ -24,13 +27,13 @@ var NotificationPanel = (props) => {
|
|
|
24
27
|
const isMobile = useIsMobileBreakpoint();
|
|
25
28
|
const renderContent = () => {
|
|
26
29
|
const outlineVariant = compactVariant === "outline";
|
|
27
|
-
const contentClasses =
|
|
28
|
-
const labelClasses =
|
|
30
|
+
const contentClasses = classNames(styles["notification-panel__content"]);
|
|
31
|
+
const labelClasses = classNames(styles["notification-panel__label"], {
|
|
29
32
|
[styles["notification-panel__label--no-content"]]: !children && !expanderChildren,
|
|
30
33
|
[styles["notification-panel__label--compact"]]: !!compactVariant,
|
|
31
34
|
[styles["notification-panel__label--outline"]]: outlineVariant
|
|
32
35
|
});
|
|
33
|
-
const childrenClasses =
|
|
36
|
+
const childrenClasses = classNames(styles["notification-panel__children"], {
|
|
34
37
|
[styles["notification-panel__children--with-label"]]: label,
|
|
35
38
|
[styles["notification-panel__children--expander-no-label"]]: expanderChildren && !label,
|
|
36
39
|
[styles["notification-panel__children--outline"]]: outlineVariant
|
|
@@ -58,7 +61,7 @@ var NotificationPanel = (props) => {
|
|
|
58
61
|
]
|
|
59
62
|
});
|
|
60
63
|
};
|
|
61
|
-
const notificationPanelClasses =
|
|
64
|
+
const notificationPanelClasses = classNames(styles["notification-panel"], styles[`notification-panel--${variant}`], size && styles[`notification-panel--${size}`], {
|
|
62
65
|
[styles["notification-panel--compact"]]: !!compactVariant,
|
|
63
66
|
[styles["notification-panel--compact--basic"]]: compactVariant === "basic",
|
|
64
67
|
[styles["notification-panel--compact--outline"]]: compactVariant === "outline",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"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' | 'none';\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 && ariaRole !== 'none' ? 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,IAAM,gBAA0C,EAAE,OAAO,eAAe;CACtE,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"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' | 'none';\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 && ariaRole !== 'none' ? 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,IAAM,gBAA0C,EAAE,OAAO,eAAe;CACtE,IAAI,OAAO;EACT,MAAM,eAAe,WAAW,OAAO,gBAAgB;EAEvD,OAAO,oBAAC,OAAD;GAAK,WAAW;GAAe;EAAc,CAAA;CACtD;CACA,OAAO;AACT;AAEA,IAAM,qBAAsD,UAAS;CACnE,MAAM,EACJ,UACA,UAAU,Q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MAAM,WAAW,QAAS,YAAY,WAAW,WAAY,KAAA;CAC7D,MAAM,sBAAsB,YAAY,aAAa,SAAS,uBAAuB;EAAE;EAAO,IAAI;CAAQ,CAAC,IAAI,KAAA;CAE/G,OACE,oBAAC,cAAD;EAAqB;EACnB,UAAA,qBAAC,OAAD;GACO;GACL,MAAM;GACN,eAAa;GACb,oBAAkB,YAAY;GAC9B,WAAW;GACX,GAAI;GANN,UAAA;IAQE,oBAAC,mBAAD;KACW;KACT,MAAM,kBAAkB,WAAW,SAAS,SAAS,SAAS;KAC9D,WAAW,OAAO;IACnB,CAAA;IACA,eACC,oBAAC,QAAD;KAAM,WAAW,OAAO;KACtB,UAAA,oBAAC,eAAD;MAAO,WAAW,MAAM;MAA4B;MAAS,OAAM;KAAS,CAAA;IACxE,CAAA;IAEP,cAAc;GACZ;;CACO,CAAA;AAElB;;;AC9KA,IAAA,4BAAe"}
|
|
@@ -10,7 +10,7 @@ import { useExpand } from "../../hooks/useExpand.js";
|
|
|
10
10
|
import ChevronRight from "../Icons/ChevronRight.js";
|
|
11
11
|
import { a as PanelVariant, i as PanelStatus, n as PanelLayout, r as PanelStacking, t as PanelListContext } from "../../utils4.js";
|
|
12
12
|
import { t as PanelTitle_default } from "../../PanelTitle.js";
|
|
13
|
-
import
|
|
13
|
+
import classNames 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";
|
|
@@ -34,7 +34,7 @@ var getResources = (language) => {
|
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region src/components/Panel/Panel.tsx
|
|
36
36
|
var ExpandButton = ({ onClick, isExpanded, resources }) => {
|
|
37
|
-
const buttonClassName =
|
|
37
|
+
const buttonClassName = classNames(styles["expander__button"], isExpanded && styles["expander__button--expanded"]);
|
|
38
38
|
return /* @__PURE__ */ jsxs(Button_default, {
|
|
39
39
|
variant: "borderless",
|
|
40
40
|
textClassName: styles["expander__button__text"],
|
|
@@ -49,11 +49,6 @@ var ExpandButton = ({ onClick, isExpanded, resources }) => {
|
|
|
49
49
|
};
|
|
50
50
|
var PanelRoot = ({ layout = PanelLayout.vertical, variant = PanelVariant.fill, color = "neutral", stacking = PanelStacking.default, testId, children, expanded = false, focusable, status = PanelStatus.none, buttonBottomAriaLabel, buttonBottomOnClick, buttonBottomText, className, resources, onExpand, highlightText, ref }) => {
|
|
51
51
|
const panelListContext = React.useContext(PanelListContext);
|
|
52
|
-
const [preContainer, setPreContainer] = React.useState([]);
|
|
53
|
-
const [title, setTitle] = React.useState([]);
|
|
54
|
-
const [content, setContent] = React.useState([]);
|
|
55
|
-
const [expandableContent, setExpandableContent] = React.useState([]);
|
|
56
|
-
const [hasIcon, setHasIcon] = React.useState(false);
|
|
57
52
|
const [isExpanded, setIsExpanded] = useExpand(expanded, onExpand);
|
|
58
53
|
const localRef = React.useRef(null);
|
|
59
54
|
const panelRef = ref ?? localRef;
|
|
@@ -67,7 +62,7 @@ var PanelRoot = ({ layout = PanelLayout.vertical, variant = PanelVariant.fill, c
|
|
|
67
62
|
...getResources(language),
|
|
68
63
|
...resources
|
|
69
64
|
};
|
|
70
|
-
React.
|
|
65
|
+
const { preContainer, title, content, expandableContent, hasIcon } = React.useMemo(() => {
|
|
71
66
|
let index = 0;
|
|
72
67
|
let localHasIcon = false;
|
|
73
68
|
const newPreContainer = [];
|
|
@@ -88,12 +83,14 @@ var PanelRoot = ({ layout = PanelLayout.vertical, variant = PanelVariant.fill, c
|
|
|
88
83
|
else if (child.type === ExpandedContent) newExpandableContent.push(React.cloneElement(child, { key }));
|
|
89
84
|
}
|
|
90
85
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
return {
|
|
87
|
+
preContainer: newPreContainer,
|
|
88
|
+
title: newTitle,
|
|
89
|
+
content: newContent,
|
|
90
|
+
expandableContent: newExpandableContent,
|
|
91
|
+
hasIcon: localHasIcon
|
|
92
|
+
};
|
|
93
|
+
}, [children, effectiveHighlightText]);
|
|
97
94
|
React.useEffect(() => {
|
|
98
95
|
if (expanded) return;
|
|
99
96
|
if (isExpanded) {
|
|
@@ -112,22 +109,22 @@ var PanelRoot = ({ layout = PanelLayout.vertical, variant = PanelVariant.fill, c
|
|
|
112
109
|
}
|
|
113
110
|
}, [isExpanded]);
|
|
114
111
|
const colorScheme = effectiveVariant === PanelVariant.fill ? color : "white";
|
|
115
|
-
const outerClassnames =
|
|
112
|
+
const outerClassnames = classNames(effectiveClassName, {
|
|
116
113
|
[styles["panel__border--outline--outer"]]: effectiveVariant === PanelVariant.outline,
|
|
117
114
|
[styles["panel__border--line"]]: effectiveVariant === PanelVariant.line,
|
|
118
115
|
[styles["panel__border--fill--neutral"]]: effectiveVariant === PanelVariant.fill && colorScheme === "neutral",
|
|
119
116
|
[styles["panel__border--fill--new"]]: effectiveVariant === PanelVariant.fill && status === PanelStatus.new,
|
|
120
117
|
[styles["panel__border--fill--status"]]: effectiveVariant === PanelVariant.fill && status !== PanelStatus.none
|
|
121
118
|
});
|
|
122
|
-
const panelClassnames =
|
|
119
|
+
const panelClassnames = classNames(styles["panel"], styles[`panel--${colorScheme}`], styles["panel--status"], {
|
|
123
120
|
[styles["panel--line"]]: effectiveVariant === PanelVariant.line,
|
|
124
121
|
[styles["panel--new"]]: status === PanelStatus.new,
|
|
125
122
|
[styles["panel--draft"]]: status === PanelStatus.draft,
|
|
126
123
|
[styles["panel--error"]]: status === PanelStatus.error,
|
|
127
124
|
[styles["panel--icon"]]: hasIcon
|
|
128
125
|
});
|
|
129
|
-
const contentContainerLayout =
|
|
130
|
-
const expanderBorderLayout =
|
|
126
|
+
const contentContainerLayout = classNames(styles["panel__content"], styles[`panel__content--${layout}`], { [styles[`panel__content--b-first`]]: stacking === PanelStacking.bFirst });
|
|
127
|
+
const expanderBorderLayout = classNames({
|
|
131
128
|
[styles["panel__expander__border--expanded"]]: isExpanded && status === PanelStatus.none,
|
|
132
129
|
[styles[`panel__expander__border--not-expanded--${colorScheme}`]]: !isExpanded && status === PanelStatus.none,
|
|
133
130
|
[styles[`panel__expander__border--not-expanded--line`]]: !isExpanded && status === PanelStatus.none && effectiveVariant === PanelVariant.line
|
|
@@ -138,7 +135,7 @@ var PanelRoot = ({ layout = PanelLayout.vertical, variant = PanelVariant.fill, c
|
|
|
138
135
|
return expandableContent.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
139
136
|
className: outerClassnames,
|
|
140
137
|
children: /* @__PURE__ */ jsx("div", {
|
|
141
|
-
className:
|
|
138
|
+
className: classNames({ [styles["panel__border--outline--inner"]]: effectiveVariant === PanelVariant.outline }),
|
|
142
139
|
children: /* @__PURE__ */ jsx("div", {
|
|
143
140
|
className: expanderBorderLayout,
|
|
144
141
|
children: /* @__PURE__ */ jsxs("div", {
|
|
@@ -178,7 +175,7 @@ var PanelRoot = ({ layout = PanelLayout.vertical, variant = PanelVariant.fill, c
|
|
|
178
175
|
}) : /* @__PURE__ */ jsx("div", {
|
|
179
176
|
className: outerClassnames,
|
|
180
177
|
children: /* @__PURE__ */ jsx("div", {
|
|
181
|
-
className:
|
|
178
|
+
className: classNames({ [styles["panel__border--outline--inner"]]: effectiveVariant === PanelVariant.outline }),
|
|
182
179
|
children: /* @__PURE__ */ jsxs("div", {
|
|
183
180
|
className: panelClassnames,
|
|
184
181
|
"data-testid": testId,
|
|
@@ -222,26 +219,30 @@ var PreContainer = ({ children }) => {
|
|
|
222
219
|
});
|
|
223
220
|
};
|
|
224
221
|
var A = ({ children }) => {
|
|
222
|
+
const styling = classNames(styles["panel__content__item"], styles["panel__content__item--a"]);
|
|
225
223
|
return /* @__PURE__ */ jsx("div", {
|
|
226
|
-
className:
|
|
224
|
+
className: styling,
|
|
227
225
|
children
|
|
228
226
|
});
|
|
229
227
|
};
|
|
230
228
|
var B = ({ children }) => {
|
|
229
|
+
const styling = classNames(styles["panel__content__item"], styles["panel__content__item--b"]);
|
|
231
230
|
return /* @__PURE__ */ jsx("div", {
|
|
232
|
-
className:
|
|
231
|
+
className: styling,
|
|
233
232
|
children
|
|
234
233
|
});
|
|
235
234
|
};
|
|
236
235
|
var C = ({ children }) => {
|
|
236
|
+
const styling = classNames(styles["panel__content__item"], styles["panel__content__item--c"]);
|
|
237
237
|
return /* @__PURE__ */ jsx("div", {
|
|
238
|
-
className:
|
|
238
|
+
className: styling,
|
|
239
239
|
children
|
|
240
240
|
});
|
|
241
241
|
};
|
|
242
242
|
var ExpandedContent = ({ children }) => {
|
|
243
|
+
const styling = classNames(styles["panel__expander__content"]);
|
|
243
244
|
return /* @__PURE__ */ jsx("div", {
|
|
244
|
-
className:
|
|
245
|
+
className: styling,
|
|
245
246
|
children
|
|
246
247
|
});
|
|
247
248
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"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,IAAa,gBAAgB,aAAmD;CAC9E,QAAQ,UAAR;EACE,KAAK,gBAAgB,SACnB,OAAO;EACT,KAAK,gBAAgB;EACrB,SACE,OAAO;CACX;AACF;;;ACkDA,IAAM,gBAAgB,EACpB,SACA,YACA,gBAKuB;CACvB,MAAM,kBAAkB,GAAW,OAAO,qBAAqB,cAAc,OAAO,6BAA6B;CAEjH,OACE,qBAAC,gBAAD;EACE,SAAQ;EACR,eAAe,OAAO;EACtB,kBAAkB;EAClB,iBAAe;EACN;YALX,CAOE,oBAAC,cAAD;GAAM,SAAS,aAAa,YAAY;GAAa,MAAM,SAAS;EAAS,CAAA,GAC7E,oBAAC,QAAD,EAAA,UAAO,aAAa,UAAU,oBAAoB,UAAU,iBAAuB,CAAA,CAC7E;;AAEZ;AACA,IAAM,aAAmC,EACvC,SAAS,YAAY,UACrB,UAAU,aAAa,MACvB,QAAQ,WACR,WAAW,cAAc,SACzB,QACA,UACA,WAAW,OACX,WACA,SAAS,YAAY,MACrB,uBACA,qBACA,kBACA,WACA,WACA,UACA,eACA,UACgB;CAChB,MAAM,mBAAmB,MAAM,WAAW,gBAAgB;CAC1D,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAA4B,CAAC,CAAC;CAC5E,MAAM,CAAC,OAAO,YAAY,MAAM,SAA4B,CAAC,CAAC;CAC9D,MAAM,CAAC,SAAS,cAAc,MAAM,SAA4B,CAAC,CAAC;CAClE,MAAM,CAAC,mBAAmB,wBAAwB,MAAM,SAA4B,CAAC,CAAC;CACtF,MAAM,CAAC,SAAS,cAAc,MAAM,SAAS,KAAK;CAClD,MAAM,CAAC,YAAY,iBAAiB,UAAU,UAAU,QAAQ;CAChE,MAAM,W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B,qBAAC,gBAAD;OAAQ,SAAQ;OAAa,MAAK;OAAS,MAAK;OAAS,SAAS;OAAqB,cAAY;iBAAnG,CACG,kBACD,oBAAC,cAAD;QAAM,SAAS;QAAc,MAAM,SAAS;OAAS,CAAA,CAC/C;;KACL,CAAA;IAEJ;;EACF,CAAA;CACF,CAAA;AAET;AAOA,IAAa,gBAAwC,EAAE,eAAe;CACpE,OAAO,oBAAC,OAAD;EAAK,WAAW,OAAO;EAA0B;CAAc,CAAA;AACxE;AAEA,IAAa,KAA6B,EAAE,eAAe;CAEzD,OAAO,oBAAC,OAAD;EAAK,WADI,GAAW,OAAO,yBAAyB,OAAO,0BAC3C;EAAU;CAAc,CAAA;AACjD;AAEA,IAAa,KAA6B,EAAE,eAAe;CAEzD,OAAO,oBAAC,OAAD;EAAK,WADI,GAAW,OAAO,yBAAyB,OAAO,0BAC3C;EAAU;CAAc,CAAA;AACjD;AAEA,IAAa,KAA6B,EAAE,eAAe;CAEzD,OAAO,oBAAC,OAAD;EAAK,WADI,GAAW,OAAO,yBAAyB,OAAO,0BAC3C;EAAU;CAAc,CAAA;AACjD;AAEA,IAAa,mBAA2C,EAAE,eAAe;CAEvE,OAAO,oBAAC,OAAD;EAAK,WADI,GAAW,OAAO,2BACX;EAAU;CAAc,CAAA;AACjD;AAUA,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,gBAAe"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"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 [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 const { preContainer, title, content, expandableContent, hasIcon } = React.useMemo(() => {\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 return {\n preContainer: newPreContainer,\n title: newTitle,\n content: newContent,\n expandableContent: newExpandableContent,\n hasIcon: localHasIcon,\n };\n }, [children, effectiveHighlightText]);\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,IAAa,gBAAgB,aAAmD;CAC9E,QAAQ,UAAR;EACE,KAAK,gBAAgB,SACnB,OAAO;EACT,KAAK,gBAAgB;EACrB,SACE,OAAO;CACX;AACF;;;ACkDA,IAAM,gBAAgB,EACpB,SACA,YACA,gBAKuB;CACvB,MAAM,kBAAkB,WAAW,OAAO,qBAAqB,cAAc,OAAO,6BAA6B;CAEjH,OACE,qBAAC,gBAAD;EACE,SAAQ;EACR,eAAe,OAAO;EACtB,kBAAkB;EAClB,iBAAe;EACN;EALX,UAAA,CAOE,oBAAC,cAAD;GAAM,SAAS,aAAa,YAAY;GAAa,MAAM,SAAS;EAAS,CAAA,GAC7E,oBAAC,QAAD,EAAA,UAAO,aAAa,UAAU,oBAAoB,UAAU,iBAAuB,CAAA,CAC7E;;AAEZ;AACA,IAAM,aAAmC,EACvC,SAAS,YAAY,UACrB,UAAU,aAAa,MACvB,QAAQ,WACR,WAAW,cAAc,SACzB,QACA,UACA,WAAW,OACX,WACA,SAAS,YAAY,MACrB,uBACA,qBACA,kBACA,WACA,WACA,UACA,eACA,UACgB;CAChB,MAAM,mBAAmB,MAAM,WAAW,gBAAgB;CAC1D,MAAM,CAAC,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@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnalyticsId } from "../../constants.js";
|
|
2
2
|
import { a as PanelVariant, t as PanelListContext } from "../../utils4.js";
|
|
3
|
-
import
|
|
3
|
+
import classNames from "classnames";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import styles from "./styles.module.scss";
|
|
@@ -10,7 +10,7 @@ var PanelList = (props) => {
|
|
|
10
10
|
const contextValue = React.useMemo(() => ({
|
|
11
11
|
variant,
|
|
12
12
|
highlightText,
|
|
13
|
-
applyPanelClassName: (existingClassName) =>
|
|
13
|
+
applyPanelClassName: (existingClassName) => classNames(existingClassName, styles[`panel-list__panel--${variant}`])
|
|
14
14
|
}), [variant, highlightText]);
|
|
15
15
|
return /* @__PURE__ */ jsx(PanelListContext.Provider, {
|
|
16
16
|
value: contextValue,
|
|
@@ -18,7 +18,7 @@ var PanelList = (props) => {
|
|
|
18
18
|
ref,
|
|
19
19
|
"data-testid": testId,
|
|
20
20
|
"data-analyticsid": AnalyticsId.PanelList,
|
|
21
|
-
className:
|
|
21
|
+
className: classNames({ [styles["panel-list--outline"]]: variant === PanelVariant.outline }),
|
|
22
22
|
children
|
|
23
23
|
})
|
|
24
24
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"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,IAAM,aAAuC,UAA0B;CACrE,MAAM,EAAE,QAAQ,UAAU,UAAU,aAAa,MAAM,eAAe,QAAQ;CAE9E,MAAM,eAAsC,MAAM,eACzC;EACL;EACA;EACA,sBAAsB,sBAA+B,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"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,IAAM,aAAuC,UAA0B;CACrE,MAAM,EAAE,QAAQ,UAAU,UAAU,aAAa,MAAM,eAAe,QAAQ;CAE9E,MAAM,eAAsC,MAAM,eACzC;EACL;EACA;EACA,sBAAsB,sBAA+B,WAAW,mBAAmB,OAAO,sBAAsB,UAAU;CAC5H,IACA,CAAC,SAAS,aAAa,CACzB;CAEA,OACE,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO;EAChC,UAAA,oBAAC,OAAD;GACO;GACL,eAAa;GACb,oBAAkB,YAAY;GAC9B,WAAW,WAAW,GAAG,OAAO,yBAAyB,YAAY,aAAa,QAAQ,CAAC;GAE1F;EACE,CAAA;CACoB,CAAA;AAE/B;;;AC5CA,IAAA,oBAAe"}
|
|
@@ -10,7 +10,7 @@ import X from "../Icons/X.js";
|
|
|
10
10
|
import { t as PopOver_default } from "../../PopOver.js";
|
|
11
11
|
import VerticalDots from "../Icons/VerticalDots.js";
|
|
12
12
|
import { t as LinkList_default } from "../../LinkList.js";
|
|
13
|
-
import
|
|
13
|
+
import classNames 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";
|
|
@@ -47,7 +47,7 @@ var PopMenu = (props) => {
|
|
|
47
47
|
const renderChildren = () => {
|
|
48
48
|
if (isComponent(children, LinkList_default)) return /* @__PURE__ */ jsx(PopOver_default, {
|
|
49
49
|
testId: popOverTestId,
|
|
50
|
-
className:
|
|
50
|
+
className: classNames(styles["pop-menu__pop-over"], popOverClassName),
|
|
51
51
|
controllerRef: iconRef,
|
|
52
52
|
role: "dialog",
|
|
53
53
|
show: isOpen,
|
|
@@ -80,7 +80,7 @@ var PopMenu = (props) => {
|
|
|
80
80
|
});
|
|
81
81
|
return /* @__PURE__ */ jsxs("div", {
|
|
82
82
|
ref: outerRef,
|
|
83
|
-
className:
|
|
83
|
+
className: classNames(popMenuClassName),
|
|
84
84
|
"data-analyticsid": AnalyticsId.PopMenu,
|
|
85
85
|
children: [/* @__PURE__ */ jsxs(Button_default, {
|
|
86
86
|
variant: "borderless",
|
|
@@ -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 { 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,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,gBAAgB,gBAAgB;EAC9B,UAAU,KAAK;CACjB,CAAC;CAED,MAAM,EAAE,WAAW,2BAA2B,iBAAiB,gBAAgB;CAC/E,MAAM,iBAAiB,WAAW,SAAS,SAAS,SAAS;CAE7D,MAAM,eAAe,OAA0B;EAC7C,UAAU,KAAK;EACf,IAAI,IAAI,GAAG;CACb;CAEA,MAAM,uBAAuD;EAC3D,IAAI,YAA2B,UAAU,gBAAQ,GAC/C,OACE,oBAAC,iBAAD;GACE,QAAQ;GACR,WAAW,
|
|
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 { 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,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,gBAAgB,gBAAgB;EAC9B,UAAU,KAAK;CACjB,CAAC;CAED,MAAM,EAAE,WAAW,2BAA2B,iBAAiB,gBAAgB;CAC/E,MAAM,iBAAiB,WAAW,SAAS,SAAS,SAAS;CAE7D,MAAM,eAAe,OAA0B;EAC7C,UAAU,KAAK;EACf,IAAI,IAAI,GAAG;CACb;CAEA,MAAM,uBAAuD;EAC3D,IAAI,YAA2B,UAAU,gBAAQ,GAC/C,OACE,oBAAC,iBAAD;GACE,QAAQ;GACR,WAAW,WAAW,OAAO,uBAAuB,gBAAgB;GACpE,eAAe;GACf,MAAK;GACL,MAAM;GAEL,UAAA,MAAM,SAAS,IAAI,WAAU,UAC5B,MAAM,aAAa,OAAO,EACxB,UAAU,MAAM,SAAS,IAAI,MAAM,MAAM,WAAU,UACjD,YAAuB,OAAO,iBAAS,IAAI,IACvC,MAAM,aAAa,OAAO,EACxB,UAAU,UACR,kBAAkB,MAAM,MAAM,WAAW,MAAM,MAAM,QAAQ,KAAK,CAAC,EACvE,CAAC,IACD,KACN,EACF,CAAC,CACH;EACO,CAAA;CAGf;CAEA,MAAM,0BAAgC;EACpC,UAAU,CAAC,MAAM;CACnB;CAEA,MAAM,gBACJ,WAAW,OAAO,YAAY,WAC5B,oBAAC,kBAAD;EAAU,UAAU;EAAS,MAAM,SAAS;EAAQ,WAAW;CAAyB,CAAA,IAExF,WAAW,oBAAC,cAAD;EAAe;EAAS,MAAM,SAAS;EAAQ,WAAW;CAAyB,CAAA;CAGlG,MAAM,WAAW,UACf,gBAEA,oBAAC,cAAD;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;GANvC,UAAA;IAQG,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;;;AC/IA,IAAA,kBAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Portal/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport { AnalyticsId } from '../../constants';\n\nexport interface PortalProps {\n /** Add custom class to portal, default class is portal-container */\n className?: string;\n /** Content to be displayed in Portal */\n children?: React.ReactNode;\n /** Default is document.body */\n parent?: HTMLElement;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport default function Portal({ children, parent, className, testId }: PortalProps): React.ReactPortal {\n // Create div to contain everything\n const el = React.useMemo(() => document.createElement('div'), []);\n el.setAttribute('data-analyticsid', AnalyticsId.Portal);\n if (testId) {\n el.setAttribute('data-testid', testId);\n }\n // On mount function\n React.useEffect(() => {\n // work out target in the DOM based on parent prop\n const target = parent && !!parent.appendChild ? parent : document.body;\n // Default classes\n const classList = ['portal-container'];\n // If className prop is present add each class the classList\n if (className) className.split(' ').forEach(item => classList.push(item));\n classList.forEach(item => el.classList.add(item));\n\n target.appendChild(el);\n // On unmount function\n return (): void => {\n // Remove element from dom\n target.removeChild(el);\n };\n }, [el, parent, className]);\n\n return createPortal(children, el);\n}\n"],"mappings":";;;;AAiBA,SAAwB,OAAO,EAAE,UAAU,QAAQ,WAAW,UAA0C;CAEtG,MAAM,KAAK,MAAM,cAAc,SAAS,cAAc,KAAK,GAAG,CAAC,CAAC;CAChE,GAAG,aAAa,oBAAoB,YAAY,MAAM;CACtD,IAAI,QACF,GAAG,aAAa,eAAe,MAAM;CAGvC,MAAM,gBAAgB;EAEpB,MAAM,SAAS,UAAU,CAAC,CAAC,OAAO,cAAc,SAAS,SAAS;EAElE,MAAM,YAAY,CAAC,kBAAkB;EAErC,IAAI,WAAW,UAAU,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Portal/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport { AnalyticsId } from '../../constants';\n\nexport interface PortalProps {\n /** Add custom class to portal, default class is portal-container */\n className?: string;\n /** Content to be displayed in Portal */\n children?: React.ReactNode;\n /** Default is document.body */\n parent?: HTMLElement;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport default function Portal({ children, parent, className, testId }: PortalProps): React.ReactPortal {\n // Create div to contain everything\n const el = React.useMemo(() => document.createElement('div'), []);\n el.setAttribute('data-analyticsid', AnalyticsId.Portal);\n if (testId) {\n el.setAttribute('data-testid', testId);\n }\n // On mount function\n React.useEffect(() => {\n // work out target in the DOM based on parent prop\n const target = parent && !!parent.appendChild ? parent : document.body;\n // Default classes\n const classList = ['portal-container'];\n // If className prop is present add each class the classList\n if (className) className.split(' ').forEach(item => classList.push(item));\n classList.forEach(item => el.classList.add(item));\n\n target.appendChild(el);\n // On unmount function\n return (): void => {\n // Remove element from dom\n target.removeChild(el);\n };\n }, [el, parent, className]);\n\n return createPortal(children, el);\n}\n"],"mappings":";;;;AAiBA,SAAwB,OAAO,EAAE,UAAU,QAAQ,WAAW,UAA0C;CAEtG,MAAM,KAAK,MAAM,cAAc,SAAS,cAAc,KAAK,GAAG,CAAC,CAAC;CAChE,GAAG,aAAa,oBAAoB,YAAY,MAAM;CACtD,IAAI,QACF,GAAG,aAAa,eAAe,MAAM;CAGvC,MAAM,gBAAgB;EAEpB,MAAM,SAAS,UAAU,CAAC,CAAC,OAAO,cAAc,SAAS,SAAS;EAElE,MAAM,YAAY,CAAC,kBAAkB;EAErC,IAAI,WAAW,UAAU,MAAM,GAAG,CAAC,CAAC,SAAQ,SAAQ,UAAU,KAAK,IAAI,CAAC;EACxE,UAAU,SAAQ,SAAQ,GAAG,UAAU,IAAI,IAAI,CAAC;EAEhD,OAAO,YAAY,EAAE;EAErB,aAAmB;GAEjB,OAAO,YAAY,EAAE;EACvB;CACF,GAAG;EAAC;EAAI;EAAQ;CAAS,CAAC;CAE1B,OAAO,aAAa,UAAU,EAAE;AAClC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ZIndex } from "../../constants.js";
|
|
2
2
|
import { palette } from "../../theme/palette.js";
|
|
3
|
-
import
|
|
3
|
+
import classNames 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";
|
|
@@ -44,13 +44,14 @@ var Progressbar = ({ value, size = ProgressbarSize.large, mode = ProgressBarMode
|
|
|
44
44
|
useEffect(() => {
|
|
45
45
|
if (overlay === Overlay.parent && wrapperRef.current?.parentElement?.style) wrapperRef.current.parentElement.style.position = "relative";
|
|
46
46
|
}, []);
|
|
47
|
+
const wrapperClasses = classNames({
|
|
48
|
+
[styles["progressbar--overlay"]]: overlay,
|
|
49
|
+
[styles["progressbar--overlay-screen"]]: overlay === Overlay.screen,
|
|
50
|
+
[styles["progressbar--overlay-parent"]]: overlay === Overlay.parent
|
|
51
|
+
});
|
|
47
52
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
48
53
|
ref: wrapperRef,
|
|
49
|
-
className:
|
|
50
|
-
[styles["progressbar--overlay"]]: overlay,
|
|
51
|
-
[styles["progressbar--overlay-screen"]]: overlay === Overlay.screen,
|
|
52
|
-
[styles["progressbar--overlay-parent"]]: overlay === Overlay.parent
|
|
53
|
-
}),
|
|
54
|
+
className: wrapperClasses,
|
|
54
55
|
"data-testid": testId,
|
|
55
56
|
role: "progressbar",
|
|
56
57
|
"aria-valuemin": 0,
|