@helsenorge/designsystem-react 15.2.0 → 15.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/AnchorLink.js +2 -2
- package/lib/AnchorLink.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 +7 -7
- package/lib/Button.js.map +1 -1
- package/lib/CHANGELOG.md +11 -0
- package/lib/Checkbox.js +5 -5
- 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 +11 -11
- package/lib/Drawer.js.map +1 -1
- package/lib/DrawerNavigation.js +1 -0
- 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 +2 -2
- package/lib/ErrorWrapper.js.map +1 -1
- package/lib/Expander.js +8 -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 +0 -2
- package/lib/FilterDrawer.js.map +1 -1
- package/lib/FilterLinkList.js +4 -4
- package/lib/FilterLinkList.js.map +1 -1
- package/lib/FilterOverviewSearch.js +2 -2
- package/lib/FilterOverviewSearch.js.map +1 -1
- package/lib/FilterSearch.js +6 -6
- 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 +3 -3
- 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 +3 -3
- package/lib/HighlightPanel.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/InfoTeaser.js +3 -3
- package/lib/InfoTeaser.js.map +1 -1
- package/lib/Input.js +4 -4
- package/lib/Input.js.map +1 -1
- package/lib/LinkList.js +5 -5
- package/lib/LinkList.js.map +1 -1
- package/lib/List.js +2 -2
- package/lib/List.js.map +1 -1
- package/lib/ListEditMode.js +4 -4
- package/lib/ListEditMode.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 +2 -2
- package/lib/PopOver.js.map +1 -1
- package/lib/Radio.js +2 -2
- package/lib/Radio.js.map +1 -1
- package/lib/RadioButton.js +4 -4
- package/lib/RadioButton.js.map +1 -1
- package/lib/RadioMarker.js +2 -2
- 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 +4 -4
- package/lib/Slider.js.map +1 -1
- package/lib/Spacer.js +2 -2
- 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 +2 -2
- package/lib/TabPanel.js.map +1 -1
- package/lib/TableBody.js +2 -2
- package/lib/TableBody.js.map +1 -1
- package/lib/TableCell.js +2 -2
- package/lib/TableCell.js.map +1 -1
- package/lib/TableExpandedRow.js +4 -4
- package/lib/TableExpandedRow.js.map +1 -1
- package/lib/TableExpanderCell.js +2 -2
- package/lib/TableExpanderCell.js.map +1 -1
- package/lib/TableHead.js +2 -2
- package/lib/TableHead.js.map +1 -1
- package/lib/TableHeadCell.js +3 -3
- package/lib/TableHeadCell.js.map +1 -1
- package/lib/TableRow.js +3 -3
- package/lib/TableRow.js.map +1 -1
- package/lib/Textarea.js +4 -4
- package/lib/Textarea.js.map +1 -1
- package/lib/Title.js +2 -2
- 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/components/ArticleTeaser/index.js +4 -4
- package/lib/components/ArticleTeaser/index.js.map +1 -1
- package/lib/components/Drawer/Drawer.d.ts +3 -0
- package/lib/components/Drawer/styles.module.scss +24 -0
- package/lib/components/Drawer/styles.module.scss.d.ts +3 -0
- 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 +2 -2
- package/lib/components/EmptyState/index.js.map +1 -1
- package/lib/components/ExpanderHierarchy/index.js +7 -7
- package/lib/components/ExpanderHierarchy/index.js.map +1 -1
- package/lib/components/ExpanderList/index.js +6 -6
- package/lib/components/ExpanderList/index.js.map +1 -1
- package/lib/components/FavoriteButton/index.js +2 -2
- package/lib/components/FavoriteButton/index.js.map +1 -1
- package/lib/components/Filter/FilterDrawer/styles.module.scss +0 -11
- package/lib/components/Filter/FilterDrawer/styles.module.scss.d.ts +0 -1
- package/lib/components/HelpBubble/index.js +3 -3
- package/lib/components/HelpBubble/index.js.map +1 -1
- package/lib/components/HelpDrawer/HelpDrawer.d.ts +1 -1
- package/lib/components/HelpDrawer/index.js +2 -1
- package/lib/components/HelpDrawer/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/HelpTriggerInline/index.js +2 -2
- package/lib/components/HelpTriggerInline/index.js.map +1 -1
- package/lib/components/Loader/index.js +4 -4
- package/lib/components/Loader/index.js.map +1 -1
- package/lib/components/Modal/index.js +9 -9
- package/lib/components/Modal/index.js.map +1 -1
- package/lib/components/NotificationPanel/index.js +6 -6
- package/lib/components/NotificationPanel/index.js.map +1 -1
- package/lib/components/Panel/index.js +12 -12
- 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/Progressbar/index.js +2 -2
- package/lib/components/Progressbar/index.js.map +1 -1
- package/lib/components/PromoPanel/index.js +2 -2
- package/lib/components/PromoPanel/index.js.map +1 -1
- package/lib/components/ServiceMessage/index.js +5 -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 +2 -2
- 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 +2 -2
- 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/constants.d.ts +2 -1
- package/lib/components/Tag/index.js +3 -2
- package/lib/components/Tag/index.js.map +1 -1
- package/lib/components/Tag/styles.module.scss +5 -0
- package/lib/components/Tag/styles.module.scss.d.ts +1 -0
- package/lib/components/Tile/index.js +4 -4
- package/lib/components/Tile/index.js.map +1 -1
- package/lib/components/Toggle/index.js +7 -7
- 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/utils2.js +7 -7
- package/lib/utils2.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,14 +5,14 @@ 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 cn from "classnames";
|
|
9
9
|
import React from "react";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import styles from "./styles.module.scss";
|
|
12
12
|
//#region src/components/NotificationPanel/NotificationPanel.tsx
|
|
13
13
|
var FluidWrapper = ({ fluid, children }) => {
|
|
14
14
|
if (fluid) return /* @__PURE__ */ jsx("div", {
|
|
15
|
-
className:
|
|
15
|
+
className: cn(styles["fluid-wrapper"]),
|
|
16
16
|
children
|
|
17
17
|
});
|
|
18
18
|
return children;
|
|
@@ -24,13 +24,13 @@ var NotificationPanel = (props) => {
|
|
|
24
24
|
const isMobile = useIsMobileBreakpoint();
|
|
25
25
|
const renderContent = () => {
|
|
26
26
|
const outlineVariant = compactVariant === "outline";
|
|
27
|
-
const contentClasses =
|
|
28
|
-
const labelClasses =
|
|
27
|
+
const contentClasses = cn(styles["notification-panel__content"]);
|
|
28
|
+
const labelClasses = cn(styles["notification-panel__label"], {
|
|
29
29
|
[styles["notification-panel__label--no-content"]]: !children && !expanderChildren,
|
|
30
30
|
[styles["notification-panel__label--compact"]]: !!compactVariant,
|
|
31
31
|
[styles["notification-panel__label--outline"]]: outlineVariant
|
|
32
32
|
});
|
|
33
|
-
const childrenClasses =
|
|
33
|
+
const childrenClasses = cn(styles["notification-panel__children"], {
|
|
34
34
|
[styles["notification-panel__children--with-label"]]: label,
|
|
35
35
|
[styles["notification-panel__children--expander-no-label"]]: expanderChildren && !label,
|
|
36
36
|
[styles["notification-panel__children--outline"]]: outlineVariant
|
|
@@ -58,7 +58,7 @@ var NotificationPanel = (props) => {
|
|
|
58
58
|
]
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
|
-
const notificationPanelClasses =
|
|
61
|
+
const notificationPanelClasses = cn(styles["notification-panel"], styles[`notification-panel--${variant}`], size && styles[`notification-panel--${size}`], {
|
|
62
62
|
[styles["notification-panel--compact"]]: !!compactVariant,
|
|
63
63
|
[styles["notification-panel--compact--basic"]]: compactVariant === "basic",
|
|
64
64
|
[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,OAGF,OAAO,oBAAC,OAAD;EAAK,WAFS,
|
|
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,OAGF,OAAO,oBAAC,OAAD;EAAK,WAFS,GAAW,OAAO,gBAEhB;EAAe;CAAc,CAAA;CAEtD,OAAO;AACT;AAEA,IAAM,qBAAsD,UAAS;CACnE,MAAM,EACJ,UACA,UAAU,QACV,cAAc,OACd,SACA,kBACA,oBACA,0BACA,wBAAwB,OACxB,gBACA,OACA,SAAS,aACT,kBAAkB,MAClB,QAAQ,OACR,MACA,WACA,MACA,QACA,QACE;CACJ,MAAM,UAAU,kBAAkB,WAAW;CAC7C,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS,qBAAqB;CAC5E,MAAM,WAAW,sBAAsB;CAEvC,MAAM,sBAAuC;EAC3C,MAAM,iBAAiB,mBAAmB;EAC1C,MAAM,iBAAiB,GAAW,OAAO,8BAA8B;EACvE,MAAM,eAAe,GAAW,O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,QAAD;KAAM,WAAW,OAAO;eACtB,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 cn from "classnames";
|
|
14
14
|
import React from "react";
|
|
15
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
16
|
import styles from "./styles.module.scss";
|
|
@@ -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 = cn(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"],
|
|
@@ -112,22 +112,22 @@ var PanelRoot = ({ layout = PanelLayout.vertical, variant = PanelVariant.fill, c
|
|
|
112
112
|
}
|
|
113
113
|
}, [isExpanded]);
|
|
114
114
|
const colorScheme = effectiveVariant === PanelVariant.fill ? color : "white";
|
|
115
|
-
const outerClassnames =
|
|
115
|
+
const outerClassnames = cn(effectiveClassName, {
|
|
116
116
|
[styles["panel__border--outline--outer"]]: effectiveVariant === PanelVariant.outline,
|
|
117
117
|
[styles["panel__border--line"]]: effectiveVariant === PanelVariant.line,
|
|
118
118
|
[styles["panel__border--fill--neutral"]]: effectiveVariant === PanelVariant.fill && colorScheme === "neutral",
|
|
119
119
|
[styles["panel__border--fill--new"]]: effectiveVariant === PanelVariant.fill && status === PanelStatus.new,
|
|
120
120
|
[styles["panel__border--fill--status"]]: effectiveVariant === PanelVariant.fill && status !== PanelStatus.none
|
|
121
121
|
});
|
|
122
|
-
const panelClassnames =
|
|
122
|
+
const panelClassnames = cn(styles["panel"], styles[`panel--${colorScheme}`], styles["panel--status"], {
|
|
123
123
|
[styles["panel--line"]]: effectiveVariant === PanelVariant.line,
|
|
124
124
|
[styles["panel--new"]]: status === PanelStatus.new,
|
|
125
125
|
[styles["panel--draft"]]: status === PanelStatus.draft,
|
|
126
126
|
[styles["panel--error"]]: status === PanelStatus.error,
|
|
127
127
|
[styles["panel--icon"]]: hasIcon
|
|
128
128
|
});
|
|
129
|
-
const contentContainerLayout =
|
|
130
|
-
const expanderBorderLayout =
|
|
129
|
+
const contentContainerLayout = cn(styles["panel__content"], styles[`panel__content--${layout}`], { [styles[`panel__content--b-first`]]: stacking === PanelStacking.bFirst });
|
|
130
|
+
const expanderBorderLayout = cn({
|
|
131
131
|
[styles["panel__expander__border--expanded"]]: isExpanded && status === PanelStatus.none,
|
|
132
132
|
[styles[`panel__expander__border--not-expanded--${colorScheme}`]]: !isExpanded && status === PanelStatus.none,
|
|
133
133
|
[styles[`panel__expander__border--not-expanded--line`]]: !isExpanded && status === PanelStatus.none && effectiveVariant === PanelVariant.line
|
|
@@ -138,7 +138,7 @@ var PanelRoot = ({ layout = PanelLayout.vertical, variant = PanelVariant.fill, c
|
|
|
138
138
|
return expandableContent.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
139
139
|
className: outerClassnames,
|
|
140
140
|
children: /* @__PURE__ */ jsx("div", {
|
|
141
|
-
className:
|
|
141
|
+
className: cn({ [styles["panel__border--outline--inner"]]: effectiveVariant === PanelVariant.outline }),
|
|
142
142
|
children: /* @__PURE__ */ jsx("div", {
|
|
143
143
|
className: expanderBorderLayout,
|
|
144
144
|
children: /* @__PURE__ */ jsxs("div", {
|
|
@@ -178,7 +178,7 @@ var PanelRoot = ({ layout = PanelLayout.vertical, variant = PanelVariant.fill, c
|
|
|
178
178
|
}) : /* @__PURE__ */ jsx("div", {
|
|
179
179
|
className: outerClassnames,
|
|
180
180
|
children: /* @__PURE__ */ jsx("div", {
|
|
181
|
-
className:
|
|
181
|
+
className: cn({ [styles["panel__border--outline--inner"]]: effectiveVariant === PanelVariant.outline }),
|
|
182
182
|
children: /* @__PURE__ */ jsxs("div", {
|
|
183
183
|
className: panelClassnames,
|
|
184
184
|
"data-testid": testId,
|
|
@@ -223,25 +223,25 @@ var PreContainer = ({ children }) => {
|
|
|
223
223
|
};
|
|
224
224
|
var A = ({ children }) => {
|
|
225
225
|
return /* @__PURE__ */ jsx("div", {
|
|
226
|
-
className:
|
|
226
|
+
className: cn(styles["panel__content__item"], styles["panel__content__item--a"]),
|
|
227
227
|
children
|
|
228
228
|
});
|
|
229
229
|
};
|
|
230
230
|
var B = ({ children }) => {
|
|
231
231
|
return /* @__PURE__ */ jsx("div", {
|
|
232
|
-
className:
|
|
232
|
+
className: cn(styles["panel__content__item"], styles["panel__content__item--b"]),
|
|
233
233
|
children
|
|
234
234
|
});
|
|
235
235
|
};
|
|
236
236
|
var C = ({ children }) => {
|
|
237
237
|
return /* @__PURE__ */ jsx("div", {
|
|
238
|
-
className:
|
|
238
|
+
className: cn(styles["panel__content__item"], styles["panel__content__item--c"]),
|
|
239
239
|
children
|
|
240
240
|
});
|
|
241
241
|
};
|
|
242
242
|
var ExpandedContent = ({ children }) => {
|
|
243
243
|
return /* @__PURE__ */ jsx("div", {
|
|
244
|
-
className:
|
|
244
|
+
className: cn(styles["panel__expander__content"]),
|
|
245
245
|
children
|
|
246
246
|
});
|
|
247
247
|
};
|
|
@@ -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,WAAW,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,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,WAAW,OAAO,yBAAyB,OAAO,0BAC3C;EAAU;CAAc,CAAA;AACjD;AAEA,IAAa,mBAA2C,EAAE,eAAe;CAEvE,OAAO,oBAAC,OAAD;EAAK,WADI,WAAW,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 [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":";;;;;;;;;;;;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;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,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 cn from "classnames";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import styles from "./styles.module.scss";
|
|
@@ -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) => cn(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: cn({ [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,GAAW,mBAAmB,OAAO,sBAAsB,UAAU;CAC5H,IACA,CAAC,SAAS,aAAa,CACzB;CAEA,OACE,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO;YAChC,oBAAC,OAAD;GACO;GACL,eAAa;GACb,oBAAkB,YAAY;GAC9B,WAAW,GAAW,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 cn from "classnames";
|
|
14
14
|
import React, { useRef, useState } from "react";
|
|
15
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
16
|
import styles from "./styles.module.scss";
|
|
@@ -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: cn(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: cn(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,WA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AC,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,GAAW,gBAAgB;EAAG,oBAAkB,YAAY;YAA3F,CACE,qBAAC,gBAAD;GACE,SAAQ;GACR,iBAAe;GACf,SAAS;GACT,KAAK;GACL,WAAW,SAAS,uBAAuB;GAC3C,QAAQ,SAAS,oBAAoB;aANvC;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;MACP,UAAU,eAAe,CACvB;;AAET;;;AC/IA,IAAA,kBAAe"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ZIndex } from "../../constants.js";
|
|
2
2
|
import { palette } from "../../theme/palette.js";
|
|
3
|
-
import
|
|
3
|
+
import cn from "classnames";
|
|
4
4
|
import { useEffect, useRef } from "react";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import styles from "./styles.module.scss";
|
|
@@ -46,7 +46,7 @@ var Progressbar = ({ value, size = ProgressbarSize.large, mode = ProgressBarMode
|
|
|
46
46
|
}, []);
|
|
47
47
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
48
48
|
ref: wrapperRef,
|
|
49
|
-
className:
|
|
49
|
+
className: cn({
|
|
50
50
|
[styles["progressbar--overlay"]]: overlay,
|
|
51
51
|
[styles["progressbar--overlay-screen"]]: overlay === Overlay.screen,
|
|
52
52
|
[styles["progressbar--overlay-parent"]]: overlay === Overlay.parent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Progressbar/constants.ts","../../../src/components/Progressbar/Progressbar.tsx","../../../src/components/Progressbar/index.ts"],"sourcesContent":["export enum ProgressbarSize {\n small = 'small',\n medium = 'medium',\n large = 'large',\n}\n\nexport enum ProgressBarMode {\n ondark = 'ondark',\n onlight = 'onlight',\n}\n\nexport enum Overlay {\n screen = 'screen',\n parent = 'parent',\n}\n","import { useRef, useEffect } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Overlay, ProgressBarMode, ProgressbarSize } from './constants';\nimport { ZIndex } from '../../constants';\nimport { palette } from '../../theme/palette';\n\nimport styles from './styles.module.scss';\n\nexport interface ProgressbarProps {\n /** The value of the progressbar given in percent. Value between 0 and 100 */\n value: number;\n /** Size of the progressbar. Default is large */\n size?: ProgressbarSize;\n /** Changes the visuals of the ProgressBar. Default is onLight */\n mode?: ProgressBarMode;\n /** Loader is displayed with grey background covering the entire screen */\n overlay?: keyof typeof Overlay;\n /** Aria label for the progressbar */\n ariaLabel?: string;\n /** Sets the data-testid attribute */\n testId?: string;\n}\n\nconst Progressbar: React.FC<ProgressbarProps> = ({\n value,\n size = ProgressbarSize.large,\n mode = ProgressBarMode.onlight,\n overlay,\n testId,\n ariaLabel,\n}: ProgressbarProps) => {\n if (overlay) {\n mode = ProgressBarMode.ondark;\n }\n // Restrict value to be between 0 and 100\n value = Math.max(0, Math.min(value, 100));\n\n let width;\n if (size === ProgressbarSize.large) {\n width = 96;\n } else if (size === ProgressbarSize.medium) {\n width = 50;\n } else {\n width = 44;\n }\n\n const totalRadius = width / 2;\n const strokeWidth = 8;\n const radius = totalRadius - strokeWidth / 2;\n const viewBoxSize = totalRadius * 2;\n const viewBoxCenter = totalRadius;\n const circleBackgroundColor = mode === ProgressBarMode.onlight ? palette.blueberry100 : palette.neutral700;\n const mainColor = mode === ProgressBarMode.onlight ? palette.blueberry600 : palette.white;\n const circumference = 2 * Math.PI * radius;\n const strokeDashoffset = circumference - (value / 100) * circumference;\n const valueText = `${value}%`;\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (overlay === Overlay.parent && wrapperRef.current?.parentElement?.style) {\n wrapperRef.current.parentElement.style.position = 'relative';\n }\n }, []);\n\n const wrapperClasses = classNames({\n [styles['progressbar--overlay']]: overlay,\n [styles['progressbar--overlay-screen']]: overlay === Overlay.screen,\n [styles['progressbar--overlay-parent']]: overlay === Overlay.parent,\n });\n\n return (\n <>\n <div\n ref={wrapperRef}\n className={wrapperClasses}\n data-testid={testId}\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={value}\n aria-label={ariaLabel}\n style={overlay === Overlay.screen ? { zIndex: ZIndex.OverlayScreen } : {}}\n >\n <svg\n role=\"presentation\"\n width={viewBoxSize}\n height={viewBoxSize}\n viewBox={`0 0 ${viewBoxSize} ${viewBoxSize}`}\n className={styles['progressbar__svg']}\n >\n <circle cx={viewBoxCenter} cy={viewBoxCenter} r={radius} stroke={circleBackgroundColor} strokeWidth={strokeWidth} fill=\"none\" />\n <circle\n cx={viewBoxCenter}\n cy={viewBoxCenter}\n r={radius}\n stroke={mainColor}\n strokeWidth={strokeWidth}\n fill=\"none\"\n strokeDasharray={circumference}\n strokeDashoffset={strokeDashoffset}\n className={styles['progressbar__progress-circle']}\n transform={`rotate(-90 ${viewBoxCenter} ${viewBoxCenter})`}\n />\n <text\n className=\"progress-wheel__text--large\"\n fontSize={'1.5rem'}\n fill={mainColor}\n x={viewBoxCenter}\n y={viewBoxCenter}\n textAnchor=\"middle\"\n alignmentBaseline=\"middle\"\n >\n {size === ProgressbarSize.large && valueText}\n </text>\n </svg>\n </div>\n <div className={styles['progressbar__sr-only-text']} aria-live=\"assertive\" aria-atomic=\"true\">\n {valueText}\n </div>\n </>\n );\n};\n\nexport default Progressbar;\n","import Progressbar from './Progressbar';\nexport { ProgressbarSize, ProgressBarMode, Overlay } from './constants';\nexport * from './Progressbar';\nexport default Progressbar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../../src/components/Progressbar/constants.ts","../../../src/components/Progressbar/Progressbar.tsx","../../../src/components/Progressbar/index.ts"],"sourcesContent":["export enum ProgressbarSize {\n small = 'small',\n medium = 'medium',\n large = 'large',\n}\n\nexport enum ProgressBarMode {\n ondark = 'ondark',\n onlight = 'onlight',\n}\n\nexport enum Overlay {\n screen = 'screen',\n parent = 'parent',\n}\n","import { useRef, useEffect } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Overlay, ProgressBarMode, ProgressbarSize } from './constants';\nimport { ZIndex } from '../../constants';\nimport { palette } from '../../theme/palette';\n\nimport styles from './styles.module.scss';\n\nexport interface ProgressbarProps {\n /** The value of the progressbar given in percent. Value between 0 and 100 */\n value: number;\n /** Size of the progressbar. Default is large */\n size?: ProgressbarSize;\n /** Changes the visuals of the ProgressBar. Default is onLight */\n mode?: ProgressBarMode;\n /** Loader is displayed with grey background covering the entire screen */\n overlay?: keyof typeof Overlay;\n /** Aria label for the progressbar */\n ariaLabel?: string;\n /** Sets the data-testid attribute */\n testId?: string;\n}\n\nconst Progressbar: React.FC<ProgressbarProps> = ({\n value,\n size = ProgressbarSize.large,\n mode = ProgressBarMode.onlight,\n overlay,\n testId,\n ariaLabel,\n}: ProgressbarProps) => {\n if (overlay) {\n mode = ProgressBarMode.ondark;\n }\n // Restrict value to be between 0 and 100\n value = Math.max(0, Math.min(value, 100));\n\n let width;\n if (size === ProgressbarSize.large) {\n width = 96;\n } else if (size === ProgressbarSize.medium) {\n width = 50;\n } else {\n width = 44;\n }\n\n const totalRadius = width / 2;\n const strokeWidth = 8;\n const radius = totalRadius - strokeWidth / 2;\n const viewBoxSize = totalRadius * 2;\n const viewBoxCenter = totalRadius;\n const circleBackgroundColor = mode === ProgressBarMode.onlight ? palette.blueberry100 : palette.neutral700;\n const mainColor = mode === ProgressBarMode.onlight ? palette.blueberry600 : palette.white;\n const circumference = 2 * Math.PI * radius;\n const strokeDashoffset = circumference - (value / 100) * circumference;\n const valueText = `${value}%`;\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (overlay === Overlay.parent && wrapperRef.current?.parentElement?.style) {\n wrapperRef.current.parentElement.style.position = 'relative';\n }\n }, []);\n\n const wrapperClasses = classNames({\n [styles['progressbar--overlay']]: overlay,\n [styles['progressbar--overlay-screen']]: overlay === Overlay.screen,\n [styles['progressbar--overlay-parent']]: overlay === Overlay.parent,\n });\n\n return (\n <>\n <div\n ref={wrapperRef}\n className={wrapperClasses}\n data-testid={testId}\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={value}\n aria-label={ariaLabel}\n style={overlay === Overlay.screen ? { zIndex: ZIndex.OverlayScreen } : {}}\n >\n <svg\n role=\"presentation\"\n width={viewBoxSize}\n height={viewBoxSize}\n viewBox={`0 0 ${viewBoxSize} ${viewBoxSize}`}\n className={styles['progressbar__svg']}\n >\n <circle cx={viewBoxCenter} cy={viewBoxCenter} r={radius} stroke={circleBackgroundColor} strokeWidth={strokeWidth} fill=\"none\" />\n <circle\n cx={viewBoxCenter}\n cy={viewBoxCenter}\n r={radius}\n stroke={mainColor}\n strokeWidth={strokeWidth}\n fill=\"none\"\n strokeDasharray={circumference}\n strokeDashoffset={strokeDashoffset}\n className={styles['progressbar__progress-circle']}\n transform={`rotate(-90 ${viewBoxCenter} ${viewBoxCenter})`}\n />\n <text\n className=\"progress-wheel__text--large\"\n fontSize={'1.5rem'}\n fill={mainColor}\n x={viewBoxCenter}\n y={viewBoxCenter}\n textAnchor=\"middle\"\n alignmentBaseline=\"middle\"\n >\n {size === ProgressbarSize.large && valueText}\n </text>\n </svg>\n </div>\n <div className={styles['progressbar__sr-only-text']} aria-live=\"assertive\" aria-atomic=\"true\">\n {valueText}\n </div>\n </>\n );\n};\n\nexport default Progressbar;\n","import Progressbar from './Progressbar';\nexport { ProgressbarSize, ProgressBarMode, Overlay } from './constants';\nexport * from './Progressbar';\nexport default Progressbar;\n"],"mappings":";;;;;;;AAAA,IAAY,kBAAL,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,YAAY,QAAQ;EAC/D,CAMiB;EACX,eAAa;EACb,MAAK;EACL,iBAAe;EACf,iBAAe;EACf,iBAAe;EACf,cAAY;EACZ,OAAO,YAAY,QAAQ,SAAS,EAAE,QAAQ,OAAO,cAAc,IAAI,CAAC;YAExE,qBAAC,OAAD;GACE,MAAK;GACL,OAAO;GACP,QAAQ;GACR,SAAS,OAAO,YAAY,GAAG;GAC/B,WAAW,OAAO;aALpB;IAOE,oBAAC,UAAD;KAAQ,IAAI;KAAe,IAAI;KAAe,GAAG;KAAQ,QAAQ;KAAoC;KAAa,MAAK;IAAQ,CAAA;IAC/H,oBAAC,UAAD;KACE,IAAI;KACJ,IAAI;KACJ,GAAG;KACH,QAAQ;KACK;KACb,MAAK;KACL,iBAAiB;KACC;KAClB,WAAW,OAAO;KAClB,WAAW,cAAc,cAAc,GAAG,cAAc;IACzD,CAAA;IACD,oBAAC,QAAD;KACE,WAAU;KACV,UAAU;KACV,MAAM;KACN,GAAG;KACH,GAAG;KACH,YAAW;KACX,mBAAkB;eAEjB,SAAS,gBAAgB,SAAS;IAC/B,CAAA;GACH;;CACF,CAAA,GACL,oBAAC,OAAD;EAAK,WAAW,OAAO;EAA8B,aAAU;EAAY,eAAY;YACpF;CACE,CAAA,CACL,EAAA,CAAA;AAEN;;;ACzHA,IAAA,sBAAe"}
|
|
@@ -7,7 +7,7 @@ import { Breakpoint, useBreakpoint } from "../../hooks/useBreakpoint.js";
|
|
|
7
7
|
import ArrowRight from "../Icons/ArrowRight.js";
|
|
8
8
|
import Title_default from "../Title/index.js";
|
|
9
9
|
import { t as LazyIllustration_default } from "../../LazyIllustration.js";
|
|
10
|
-
import
|
|
10
|
+
import cn from "classnames";
|
|
11
11
|
import React from "react";
|
|
12
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
import styles from "./styles.module.scss";
|
|
@@ -30,7 +30,7 @@ var PromoPanel = (props) => {
|
|
|
30
30
|
const { isHovered, refObject } = usePseudoClasses();
|
|
31
31
|
const { color = "neutral", titleHtmlMarkup = "h2", linkHtmlMarkup = "a" } = props;
|
|
32
32
|
const breakpoint = useBreakpoint();
|
|
33
|
-
const promoPanelClasses =
|
|
33
|
+
const promoPanelClasses = cn(styles.promopanel, styles[`promopanel--${color}`], !props.illustration && styles["promopanel--no-illustration"]);
|
|
34
34
|
const promoPanelLink = /* @__PURE__ */ jsx(PromoPanelLink, {
|
|
35
35
|
href: props.href,
|
|
36
36
|
target: props.target,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/PromoPanel/PromoPanel.tsx","../../../src/components/PromoPanel/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { PaletteNames } from '../../theme/palette';\nimport type { AnchorLinkTags, AnchorLinkTargets } from '../AnchorLink';\nimport type { TitleTags } from '../Title';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getColor } from '../../theme/currys/color';\nimport Icon from '../Icon';\nimport ArrowRight from '../Icons/ArrowRight';\nimport ArrowUpRight from '../Icons/ArrowUpRight';\nimport LazyIllustration from '../LazyIllustration';\nimport Title from '../Title';\n\nimport styles from './styles.module.scss';\n\nexport type PromoPanelColors = Extract<PaletteNames, 'neutral' | 'blueberry' | 'cherry'>;\n\nexport interface PromoPanelProps {\n /** Used as the link text if set. title or children must be set for the link to have accessible text. */\n title?: string;\n /** Used as the link text if title is not set. */\n children?: string;\n /** Illustration element */\n illustration?: 'Doctor' | 'HealthcarePersonnel';\n /** Changes the underlying element of the title. */\n titleHtmlMarkup?: TitleTags;\n /** Changes the background color. Default: white */\n color?: PromoPanelColors;\n /** Not used if linkComponent is set */\n href?: string;\n /** Anchor link target. If linkComponent is set, this prop is only used to display the right icon for external links. */\n target?: AnchorLinkTargets;\n /** HTML markup for anchor link. Not used if linkComponent is set. Default: a */\n linkHtmlMarkup?: AnchorLinkTags;\n /** Function that is called when clicked. Not used if linkComponent is set. */\n linkOnClick?: () => void;\n /** Custom link component. Must be \"a\" a or \"button\" element with no styling. */\n linkComponent?: React.ReactElement;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\ninterface PromoPanelLinkProps {\n children?: string;\n href?: string;\n target?: AnchorLinkTargets;\n linkComponent?: React.ReactElement;\n linkHtmlMarkup?: AnchorLinkTags;\n linkOnClick?: () => void;\n}\n\nconst PromoPanelLink: React.FC<PromoPanelLinkProps> = props => {\n if (props.linkComponent) {\n return React.cloneElement(props.linkComponent, undefined, props.children);\n }\n\n if (props.linkHtmlMarkup === 'button') {\n return (\n <button type={'button'} onClick={props.linkOnClick}>\n {props.children}\n </button>\n );\n }\n return (\n <a href={props.href} target={props.target} onClick={props.linkOnClick}>\n {props.children}\n </a>\n );\n};\n\nconst PromoPanel: React.FC<PromoPanelProps> = props => {\n const { isHovered, refObject } = usePseudoClasses<HTMLDivElement>();\n\n const { color = 'neutral', titleHtmlMarkup = 'h2', linkHtmlMarkup = 'a' } = props;\n\n const breakpoint = useBreakpoint();\n\n const promoPanelClasses = classNames(\n styles.promopanel,\n styles[`promopanel--${color}`],\n !props.illustration && styles['promopanel--no-illustration']\n );\n\n const promoPanelLink = (\n <PromoPanelLink\n href={props.href}\n target={props.target}\n linkComponent={props.linkComponent}\n linkHtmlMarkup={linkHtmlMarkup}\n linkOnClick={props.linkOnClick}\n >\n {props.title || props.children}\n </PromoPanelLink>\n );\n\n const illustrationSize = ((): number => {\n if (breakpoint >= Breakpoint.md) {\n return 156;\n }\n\n return 110;\n })();\n\n return (\n <div className={promoPanelClasses} data-testid={props.testId} data-analyticsid={AnalyticsId.PromoPanel} ref={refObject}>\n {props.illustration && (\n <LazyIllustration\n illustrationName={props.illustration}\n size={illustrationSize}\n color={color}\n className={styles.promopanel__illustration}\n />\n )}\n <div className={styles.promopanel__content}>\n {props.title && (\n <Title htmlMarkup={titleHtmlMarkup} appearance={'title3'}>\n {promoPanelLink}\n </Title>\n )}\n {!props.title ? promoPanelLink : props.children}\n </div>\n <Icon\n className={styles.promopanel__icon}\n svgIcon={props.target === '_blank' ? ArrowUpRight : ArrowRight}\n size={breakpoint >= Breakpoint.md ? IconSize.Small : IconSize.XSmall}\n isHovered={isHovered}\n color={getColor('blueberry', 500)}\n hoverColor={getColor('blueberry', 600)}\n />\n </div>\n );\n};\n\nexport default PromoPanel;\n","import PromoPanel from './PromoPanel';\nexport * from './PromoPanel';\nexport default PromoPanel;\n"],"mappings":";;;;;;;;;;;;;;AAwDA,IAAM,kBAAgD,UAAS;CAC7D,IAAI,MAAM,eACR,OAAO,MAAM,aAAa,MAAM,eAAe,KAAA,GAAW,MAAM,QAAQ;CAG1E,IAAI,MAAM,mBAAmB,UAC3B,OACE,oBAAC,UAAD;EAAQ,MAAM;EAAU,SAAS,MAAM;YACpC,MAAM;CACD,CAAA;CAGZ,OACE,oBAAC,KAAD;EAAG,MAAM,MAAM;EAAM,QAAQ,MAAM;EAAQ,SAAS,MAAM;YACvD,MAAM;CACN,CAAA;AAEP;AAEA,IAAM,cAAwC,UAAS;CACrD,MAAM,EAAE,WAAW,cAAc,iBAAiC;CAElE,MAAM,EAAE,QAAQ,WAAW,kBAAkB,MAAM,iBAAiB,QAAQ;CAE5E,MAAM,aAAa,cAAc;CAEjC,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/PromoPanel/PromoPanel.tsx","../../../src/components/PromoPanel/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { PaletteNames } from '../../theme/palette';\nimport type { AnchorLinkTags, AnchorLinkTargets } from '../AnchorLink';\nimport type { TitleTags } from '../Title';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getColor } from '../../theme/currys/color';\nimport Icon from '../Icon';\nimport ArrowRight from '../Icons/ArrowRight';\nimport ArrowUpRight from '../Icons/ArrowUpRight';\nimport LazyIllustration from '../LazyIllustration';\nimport Title from '../Title';\n\nimport styles from './styles.module.scss';\n\nexport type PromoPanelColors = Extract<PaletteNames, 'neutral' | 'blueberry' | 'cherry'>;\n\nexport interface PromoPanelProps {\n /** Used as the link text if set. title or children must be set for the link to have accessible text. */\n title?: string;\n /** Used as the link text if title is not set. */\n children?: string;\n /** Illustration element */\n illustration?: 'Doctor' | 'HealthcarePersonnel';\n /** Changes the underlying element of the title. */\n titleHtmlMarkup?: TitleTags;\n /** Changes the background color. Default: white */\n color?: PromoPanelColors;\n /** Not used if linkComponent is set */\n href?: string;\n /** Anchor link target. If linkComponent is set, this prop is only used to display the right icon for external links. */\n target?: AnchorLinkTargets;\n /** HTML markup for anchor link. Not used if linkComponent is set. Default: a */\n linkHtmlMarkup?: AnchorLinkTags;\n /** Function that is called when clicked. Not used if linkComponent is set. */\n linkOnClick?: () => void;\n /** Custom link component. Must be \"a\" a or \"button\" element with no styling. */\n linkComponent?: React.ReactElement;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\ninterface PromoPanelLinkProps {\n children?: string;\n href?: string;\n target?: AnchorLinkTargets;\n linkComponent?: React.ReactElement;\n linkHtmlMarkup?: AnchorLinkTags;\n linkOnClick?: () => void;\n}\n\nconst PromoPanelLink: React.FC<PromoPanelLinkProps> = props => {\n if (props.linkComponent) {\n return React.cloneElement(props.linkComponent, undefined, props.children);\n }\n\n if (props.linkHtmlMarkup === 'button') {\n return (\n <button type={'button'} onClick={props.linkOnClick}>\n {props.children}\n </button>\n );\n }\n return (\n <a href={props.href} target={props.target} onClick={props.linkOnClick}>\n {props.children}\n </a>\n );\n};\n\nconst PromoPanel: React.FC<PromoPanelProps> = props => {\n const { isHovered, refObject } = usePseudoClasses<HTMLDivElement>();\n\n const { color = 'neutral', titleHtmlMarkup = 'h2', linkHtmlMarkup = 'a' } = props;\n\n const breakpoint = useBreakpoint();\n\n const promoPanelClasses = classNames(\n styles.promopanel,\n styles[`promopanel--${color}`],\n !props.illustration && styles['promopanel--no-illustration']\n );\n\n const promoPanelLink = (\n <PromoPanelLink\n href={props.href}\n target={props.target}\n linkComponent={props.linkComponent}\n linkHtmlMarkup={linkHtmlMarkup}\n linkOnClick={props.linkOnClick}\n >\n {props.title || props.children}\n </PromoPanelLink>\n );\n\n const illustrationSize = ((): number => {\n if (breakpoint >= Breakpoint.md) {\n return 156;\n }\n\n return 110;\n })();\n\n return (\n <div className={promoPanelClasses} data-testid={props.testId} data-analyticsid={AnalyticsId.PromoPanel} ref={refObject}>\n {props.illustration && (\n <LazyIllustration\n illustrationName={props.illustration}\n size={illustrationSize}\n color={color}\n className={styles.promopanel__illustration}\n />\n )}\n <div className={styles.promopanel__content}>\n {props.title && (\n <Title htmlMarkup={titleHtmlMarkup} appearance={'title3'}>\n {promoPanelLink}\n </Title>\n )}\n {!props.title ? promoPanelLink : props.children}\n </div>\n <Icon\n className={styles.promopanel__icon}\n svgIcon={props.target === '_blank' ? ArrowUpRight : ArrowRight}\n size={breakpoint >= Breakpoint.md ? IconSize.Small : IconSize.XSmall}\n isHovered={isHovered}\n color={getColor('blueberry', 500)}\n hoverColor={getColor('blueberry', 600)}\n />\n </div>\n );\n};\n\nexport default PromoPanel;\n","import PromoPanel from './PromoPanel';\nexport * from './PromoPanel';\nexport default PromoPanel;\n"],"mappings":";;;;;;;;;;;;;;AAwDA,IAAM,kBAAgD,UAAS;CAC7D,IAAI,MAAM,eACR,OAAO,MAAM,aAAa,MAAM,eAAe,KAAA,GAAW,MAAM,QAAQ;CAG1E,IAAI,MAAM,mBAAmB,UAC3B,OACE,oBAAC,UAAD;EAAQ,MAAM;EAAU,SAAS,MAAM;YACpC,MAAM;CACD,CAAA;CAGZ,OACE,oBAAC,KAAD;EAAG,MAAM,MAAM;EAAM,QAAQ,MAAM;EAAQ,SAAS,MAAM;YACvD,MAAM;CACN,CAAA;AAEP;AAEA,IAAM,cAAwC,UAAS;CACrD,MAAM,EAAE,WAAW,cAAc,iBAAiC;CAElE,MAAM,EAAE,QAAQ,WAAW,kBAAkB,MAAM,iBAAiB,QAAQ;CAE5E,MAAM,aAAa,cAAc;CAEjC,MAAM,oBAAoB,GACxB,OAAO,YACP,OAAO,eAAe,UACtB,CAAC,MAAM,gBAAgB,OAAO,8BAChC;CAEA,MAAM,iBACJ,oBAAC,gBAAD;EACE,MAAM,MAAM;EACZ,QAAQ,MAAM;EACd,eAAe,MAAM;EACL;EAChB,aAAa,MAAM;YAElB,MAAM,SAAS,MAAM;CACR,CAAA;CAGlB,MAAM,0BAAkC;EACtC,IAAI,cAAc,WAAW,IAC3B,OAAO;EAGT,OAAO;CACT,GAAG;CAEH,OACE,qBAAC,OAAD;EAAK,WAAW;EAAmB,eAAa,MAAM;EAAQ,oBAAkB,YAAY;EAAY,KAAK;YAA7G;GACG,MAAM,gBACL,oBAAC,0BAAD;IACE,kBAAkB,MAAM;IACxB,MAAM;IACC;IACP,WAAW,OAAO;GACnB,CAAA;GAEH,qBAAC,OAAD;IAAK,WAAW,OAAO;cAAvB,CACG,MAAM,SACL,oBAAC,eAAD;KAAO,YAAY;KAAiB,YAAY;eAC7C;IACI,CAAA,GAER,CAAC,MAAM,QAAQ,iBAAiB,MAAM,QACpC;;GACL,oBAAC,cAAD;IACE,WAAW,OAAO;IAClB,SAAS,MAAM,WAAW,WAAW,eAAe;IACpD,MAAM,cAAc,WAAW,KAAK,SAAS,QAAQ,SAAS;IACnD;IACX,OAAO,SAAS,aAAa,GAAG;IAChC,YAAY,SAAS,aAAa,GAAG;GACtC,CAAA;EACE;;AAET;;;ACtIA,IAAA,qBAAe"}
|
|
@@ -12,7 +12,7 @@ import ChevronDown from "../Icons/ChevronDown.js";
|
|
|
12
12
|
import ChevronUp from "../Icons/ChevronUp.js";
|
|
13
13
|
import { i as renderElementHeader } from "../../ElementHeader.js";
|
|
14
14
|
import Forward from "../Icons/Forward.js";
|
|
15
|
-
import
|
|
15
|
+
import cn from "classnames";
|
|
16
16
|
import { useId, useState } from "react";
|
|
17
17
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
18
|
import styles from "./styles.module.scss";
|
|
@@ -21,7 +21,7 @@ var Label = ({ label, variant, id, hasExpander, isExpanded, dismissable, onExpan
|
|
|
21
21
|
const breakpoint = useBreakpoint();
|
|
22
22
|
const { isHovered, refObject } = usePseudoClasses();
|
|
23
23
|
const iconSize = breakpoint < breakpoints.lg ? IconSize.XSmall : IconSize.Small;
|
|
24
|
-
const labelContainerClasses =
|
|
24
|
+
const labelContainerClasses = cn(styles["service-message__label-container"], styles[`service-message__label-container--${variant}`], hasExpander && styles[`service-message__label-container--has-expander`]);
|
|
25
25
|
const elementHeader = renderElementHeader(label, {
|
|
26
26
|
titleHtmlMarkup: "span",
|
|
27
27
|
isHovered,
|
|
@@ -89,7 +89,7 @@ var Content = ({ info, extraInfo, urlTitle, url, target, dismissable, closeBtnTe
|
|
|
89
89
|
children: info
|
|
90
90
|
}),
|
|
91
91
|
extraInfo && /* @__PURE__ */ jsx("p", {
|
|
92
|
-
className:
|
|
92
|
+
className: cn(styles["service-message__info"], styles["service-message__info--extra"]),
|
|
93
93
|
children: extraInfo
|
|
94
94
|
}),
|
|
95
95
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -107,7 +107,7 @@ var Content = ({ info, extraInfo, urlTitle, url, target, dismissable, closeBtnTe
|
|
|
107
107
|
})]
|
|
108
108
|
}), dismissable && /* @__PURE__ */ jsxs("button", {
|
|
109
109
|
ref: closeButtonRef,
|
|
110
|
-
className:
|
|
110
|
+
className: cn(styles["service-message__action"], styles["service-message__action--close"]),
|
|
111
111
|
"aria-label": closeBtnText,
|
|
112
112
|
onClick: onDismiss,
|
|
113
113
|
children: [closeBtnText, /* @__PURE__ */ jsx(Icon_default, {
|
|
@@ -137,7 +137,7 @@ var ServiceMessage = ({ label, dismissable = true, onDismiss, info, extraInfo, u
|
|
|
137
137
|
if (hasExpander) setIsExpanded(!isExpanded);
|
|
138
138
|
};
|
|
139
139
|
return /* @__PURE__ */ jsxs("div", {
|
|
140
|
-
className:
|
|
140
|
+
className: cn(styles["service-message"], styles[`service-message--${variant}`]),
|
|
141
141
|
role: ariaRole,
|
|
142
142
|
...ariaLabelAttributes,
|
|
143
143
|
"data-testid": testId,
|