@helsenorge/designsystem-react 10.1.0 → 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AnchorLink.js +2 -2
- package/AnchorLink.js.map +1 -1
- package/Avatar.js +2 -2
- package/Avatar.js.map +1 -1
- package/Badge.js +3 -3
- package/Badge.js.map +1 -1
- package/Button.js +4 -4
- package/Button.js.map +1 -1
- package/CHANGELOG.md +1367 -801
- package/Checkbox.js +2 -2
- package/Checkbox.js.map +1 -1
- package/Close.js +2 -2
- package/Close.js.map +1 -1
- package/ErrorBoundary.js +2 -2
- package/ErrorBoundary.js.map +1 -1
- package/FormGroup.js +12 -12
- package/FormGroup.js.map +1 -1
- package/FormLayout.js +3 -3
- package/FormLayout.js.map +1 -1
- package/HelpBubble.js +2 -2
- package/HelpBubble.js.map +1 -1
- package/HighlightPanel.js +2 -2
- package/HighlightPanel.js.map +1 -1
- package/Icon.js +3 -3
- package/Icon.js.map +1 -1
- package/Illustration.js +3 -3
- package/Illustration.js.map +1 -1
- package/Input.js +2 -2
- package/Input.js.map +1 -1
- package/Label.js +8 -8
- package/Label.js.map +1 -1
- package/LazyIcon.js +1 -1
- package/LazyIllustration.js +3 -3
- package/LazyIllustration.js.map +1 -1
- package/LinkList.js +6 -6
- package/LinkList.js.map +1 -1
- package/ListHeader.js +7 -7
- package/ListHeader.js.map +1 -1
- package/Panel.js +2 -2
- package/Panel.js.map +1 -1
- package/PopOver.js +2 -2
- package/PopOver.js.map +1 -1
- package/RadioButton.js +2 -2
- package/RadioButton.js.map +1 -1
- package/Select.js +2 -2
- package/Select.js.map +1 -1
- package/Slider.js +3 -3
- package/Slider.js.map +1 -1
- package/Spacer.js +2 -2
- package/Spacer.js.map +1 -1
- package/StatusDot.js +1 -1
- package/StepButtons.js +4 -4
- package/StepButtons.js.map +1 -1
- package/TabList.js +4 -4
- package/TabList.js.map +1 -1
- package/Table.js +2 -2
- package/Table.js.map +1 -1
- package/TableBody.js +2 -2
- package/TableBody.js.map +1 -1
- package/TableExpandedRow.js +2 -2
- package/TableExpandedRow.js.map +1 -1
- package/TableHead.js +2 -2
- package/TableHead.js.map +1 -1
- package/TableRow.js +2 -2
- package/TableRow.js.map +1 -1
- package/Textarea.js +2 -2
- package/Textarea.js.map +1 -1
- package/Title.js +2 -2
- package/Title.js.map +1 -1
- package/TooltipWord.js +2 -2
- package/TooltipWord.js.map +1 -1
- package/Trigger.js +3 -3
- package/Trigger.js.map +1 -1
- package/components/Button/styles.module.scss +5 -0
- package/components/DictionaryTrigger/index.js +2 -2
- package/components/DictionaryTrigger/index.js.map +1 -1
- package/components/Drawer/Drawer.d.ts +41 -0
- package/components/Drawer/Drawer.test.d.ts +1 -0
- package/components/Drawer/index.d.ts +3 -0
- package/components/Drawer/index.js +350 -0
- package/components/Drawer/index.js.map +1 -0
- package/components/Drawer/styles.module.scss +127 -0
- package/components/Drawer/styles.module.scss.d.ts +16 -0
- package/components/Dropdown/index.js +3 -3
- package/components/Dropdown/index.js.map +1 -1
- package/components/Duolist/index.js +4 -4
- package/components/Duolist/index.js.map +1 -1
- package/components/ExpanderHierarchy/index.js +5 -5
- package/components/ExpanderHierarchy/index.js.map +1 -1
- package/components/ExpanderList/index.js +8 -8
- package/components/ExpanderList/index.js.map +1 -1
- package/components/HelpQuestion/index.js +2 -2
- package/components/HelpQuestion/index.js.map +1 -1
- package/components/HighlightPanel/styles.module.scss +4 -36
- package/components/HighlightPanel/styles.module.scss.d.ts +1 -2
- package/components/Icons/EuropeanHealthCard.js +1 -1
- package/components/Icons/GroupTwins.js +1 -1
- package/components/Icons/Inbox.js +1 -1
- package/components/Icons/LawBook.js +1 -1
- package/components/Icons/PersonCancel.js +1 -1
- package/components/Icons/PersonWithBrain.js +1 -1
- package/components/Icons/Puzzle.js +1 -1
- package/components/Icons/Snapchat.js +1 -1
- package/components/Illustrations/IllustrationNames.d.ts +1 -1
- package/components/Illustrations/IllustrationNames.js +4 -2
- package/components/Illustrations/IllustrationNames.js.map +1 -1
- package/components/Illustrations/ReadLetters.d.ts +9 -0
- package/components/Illustrations/ReadLetters.js +11 -0
- package/components/Illustrations/ReadLetters.js.map +1 -0
- package/components/Illustrations/ReadLettersMedium.d.ts +4 -0
- package/components/Illustrations/ReadLettersMedium.js +110 -0
- package/components/Illustrations/ReadLettersMedium.js.map +1 -0
- package/components/Illustrations/Support2.d.ts +9 -0
- package/components/Illustrations/Support2.js +11 -0
- package/components/Illustrations/Support2.js.map +1 -0
- package/components/Illustrations/Support2Medium.d.ts +4 -0
- package/components/Illustrations/Support2Medium.js +232 -0
- package/components/Illustrations/Support2Medium.js.map +1 -0
- package/components/Label/styles.module.scss +16 -12
- package/components/Label/styles.module.scss.d.ts +3 -1
- package/components/List/styles.module.scss +7 -7
- package/components/Modal/index.js +71 -82
- package/components/Modal/index.js.map +1 -1
- package/components/Modal/styles.module.scss +12 -6
- package/components/NotificationPanel/index.js +3 -3
- package/components/NotificationPanel/index.js.map +1 -1
- package/components/PanelList/index.js +5 -5
- package/components/PanelList/index.js.map +1 -1
- package/components/PopMenu/index.js +5 -5
- package/components/PopMenu/index.js.map +1 -1
- package/components/Portal/index.js +3 -3
- package/components/Portal/index.js.map +1 -1
- package/components/PromoPanel/index.js +2 -2
- package/components/PromoPanel/index.js.map +1 -1
- package/components/Tabs/index.js +3 -3
- package/components/Tabs/index.js.map +1 -1
- package/components/TagList/index.js +2 -2
- package/components/TagList/index.js.map +1 -1
- package/components/Tile/index.js +6 -6
- package/components/Tile/index.js.map +1 -1
- package/components/Toggle/index.js +3 -3910
- package/components/Toggle/index.js.map +1 -1
- package/components/Tooltip/index.js +2 -2
- package/components/Tooltip/index.js.map +1 -1
- package/components/Validation/index.js +6 -6
- package/components/Validation/index.js.map +1 -1
- package/constants.d.ts +1 -0
- package/constants.js +1 -0
- package/constants.js.map +1 -1
- package/hoc/withBreakpoint/withBreakpoint.js +2 -2
- package/hoc/withBreakpoint/withBreakpoint.js.map +1 -1
- package/hooks/useBreakpoint.d.ts +0 -4
- package/hooks/useBreakpoint.js +23 -18
- package/hooks/useBreakpoint.js.map +1 -1
- package/hooks/useEventListenerState.js +3 -3
- package/hooks/useEventListenerState.js.map +1 -1
- package/hooks/useReturnFocusOnUnmount.d.ts +5 -0
- package/hooks/useReturnFocusOnUnmount.js +20 -0
- package/hooks/useReturnFocusOnUnmount.js.map +1 -0
- package/package.json +1 -1
- package/scss/_breakpoints.scss +6 -0
- package/scss/_font-mixins.scss +55 -0
- package/scss/typography.module.scss +24 -0
- package/scss/typography.module.scss.d.ts +6 -0
- package/scss/typography.stories.tsx +24 -0
- package/theme/index.js +2 -2
- package/use-animate.js +3952 -0
- package/use-animate.js.map +1 -0
- package/utils/accessibility.d.ts +1 -0
- package/utils/accessibility.js +6 -1
- package/utils/accessibility.js.map +1 -1
- package/utils/component.js +4 -4
- package/utils/component.js.map +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import React__default, { useEffect } from "react";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import { ZIndex, AnalyticsId, IconSize } from "../../constants.js";
|
|
5
5
|
import { useFocusTrap } from "../../hooks/useFocusTrap.js";
|
|
6
6
|
import { useIsVisible } from "../../hooks/useIsVisible.js";
|
|
7
|
+
import { useReturnFocusOnUnmount } from "../../hooks/useReturnFocusOnUnmount.js";
|
|
7
8
|
import { palette } from "../../theme/palette.js";
|
|
9
|
+
import { getAriaLabelAttributes } from "../../utils/accessibility.js";
|
|
8
10
|
import { u as uuid } from "../../uuid.js";
|
|
9
11
|
import { B as Button } from "../../Button.js";
|
|
10
12
|
import { C as Close } from "../../Close.js";
|
|
@@ -44,7 +46,7 @@ const getIcon = (variant, icon) => {
|
|
|
44
46
|
return /* @__PURE__ */ jsx("div", { className: styles.modal__iconWrapper, children: variantIcon });
|
|
45
47
|
}
|
|
46
48
|
if (icon) {
|
|
47
|
-
return /* @__PURE__ */ jsx("div", { className: styles.modal__iconWrapper, children:
|
|
49
|
+
return /* @__PURE__ */ jsx("div", { className: styles.modal__iconWrapper, children: React__default.cloneElement(icon, {
|
|
48
50
|
size: IconSize.Small
|
|
49
51
|
}) });
|
|
50
52
|
}
|
|
@@ -60,14 +62,15 @@ const Modal = (props) => {
|
|
|
60
62
|
size = "large",
|
|
61
63
|
zIndex = ZIndex.Modal
|
|
62
64
|
} = props;
|
|
63
|
-
const topContent =
|
|
64
|
-
const modalContentRef =
|
|
65
|
-
const dialogRef =
|
|
65
|
+
const topContent = React__default.useRef(null);
|
|
66
|
+
const modalContentRef = React__default.useRef(null);
|
|
67
|
+
const dialogRef = React__default.useRef(null);
|
|
66
68
|
useFocusTrap(dialogRef, true);
|
|
67
69
|
const topContentVisible = useIsVisible(topContent);
|
|
68
|
-
const bottomContent =
|
|
70
|
+
const bottomContent = React__default.useRef(null);
|
|
69
71
|
const bottomContentVisible = useIsVisible(bottomContent);
|
|
70
72
|
const contentIsScrollable = modalContentRef.current && modalContentRef.current.scrollHeight > modalContentRef.current.clientHeight;
|
|
73
|
+
useReturnFocusOnUnmount(dialogRef);
|
|
71
74
|
function handleKeyboardEvent(e) {
|
|
72
75
|
if (e.key === "Escape" && props.onClose) {
|
|
73
76
|
e.stopPropagation();
|
|
@@ -87,10 +90,9 @@ const Modal = (props) => {
|
|
|
87
90
|
document.body.style.removeProperty("overflow");
|
|
88
91
|
}
|
|
89
92
|
const imageView = variant === "image";
|
|
90
|
-
const overlayRef =
|
|
93
|
+
const overlayRef = React__default.useRef(null);
|
|
91
94
|
const showActions = props.secondaryButtonText && ((_a = props.secondaryButtonText) == null ? void 0 : _a.length) > 0 || props.onSuccess;
|
|
92
|
-
const
|
|
93
|
-
const ariaLabelledBy = props.ariaLabelledBy ? props.ariaLabelledBy : !props.ariaLabel ? titleId : void 0;
|
|
95
|
+
const ariaLabelAttributes = getAriaLabelAttributes({ label: props.ariaLabel, id: props.ariaLabelledBy, fallbackId: titleId });
|
|
94
96
|
useEffect(() => {
|
|
95
97
|
const overlayElement = overlayRef.current;
|
|
96
98
|
disableBodyScroll();
|
|
@@ -130,79 +132,66 @@ const Modal = (props) => {
|
|
|
130
132
|
"data-testid": props.testId,
|
|
131
133
|
"data-analyticsid": AnalyticsId.Modal,
|
|
132
134
|
style: { zIndex },
|
|
133
|
-
children: /* @__PURE__ */ jsx("div", { className: styles.align, children: /* @__PURE__ */ jsxs(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
"div",
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
{
|
|
194
|
-
className: classNames(styles["modal__shadow"], styles["modal__shadow--bottom"], {
|
|
195
|
-
[styles["modal__shadow--show"]]: !bottomContentVisible && contentIsScrollable
|
|
196
|
-
})
|
|
197
|
-
}
|
|
198
|
-
),
|
|
199
|
-
showActions && /* @__PURE__ */ jsxs("div", { className: classNames(styles["modal__call-to-action"], size && styles[`modal__call-to-action--${size}`]), children: [
|
|
200
|
-
props.onSuccess && /* @__PURE__ */ jsx(Button, { onClick: props.onSuccess, children: primaryButtonText }),
|
|
201
|
-
props.secondaryButtonText && ((_b = props.secondaryButtonText) == null ? void 0 : _b.length) > 0 && /* @__PURE__ */ jsx(Button, { variant: "borderless", onClick: props.onClose, children: props.secondaryButtonText })
|
|
202
|
-
] })
|
|
203
|
-
]
|
|
204
|
-
}
|
|
205
|
-
) })
|
|
135
|
+
children: /* @__PURE__ */ jsx("div", { className: styles.align, children: /* @__PURE__ */ jsxs("div", { className: dialogClasses, role: "dialog", "aria-modal": "true", tabIndex: -1, ...ariaLabelAttributes, ref: dialogRef, children: [
|
|
136
|
+
/* @__PURE__ */ jsx(
|
|
137
|
+
"div",
|
|
138
|
+
{
|
|
139
|
+
className: classNames(styles["modal__shadow"], styles["modal__shadow--top"], {
|
|
140
|
+
[styles["modal__shadow--show"]]: !topContentVisible && contentIsScrollable
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
/* @__PURE__ */ jsxs(
|
|
145
|
+
"div",
|
|
146
|
+
{
|
|
147
|
+
className: classNames(styles.modal__contentWrapper, {
|
|
148
|
+
[styles["modal__contentWrapper--image"]]: imageView
|
|
149
|
+
}),
|
|
150
|
+
tabIndex: contentIsScrollable ? 0 : void 0,
|
|
151
|
+
role: contentIsScrollable ? "region" : void 0,
|
|
152
|
+
...contentIsScrollable ? ariaLabelAttributes : {},
|
|
153
|
+
ref: modalContentRef,
|
|
154
|
+
children: [
|
|
155
|
+
!props.noCloseButton && /* @__PURE__ */ jsx("div", { className: styles.modal__closeWrapper, children: /* @__PURE__ */ jsx("div", { className: classNames(styles.modal__closeWrapper__close), children: /* @__PURE__ */ jsx(Close, { onClick: props.onClose, ariaLabel: props.ariaLabelCloseBtn }) }) }),
|
|
156
|
+
/* @__PURE__ */ jsxs(
|
|
157
|
+
"div",
|
|
158
|
+
{
|
|
159
|
+
className: classNames(size && styles[`modal__contentWrapper__scroll--${size}`], {
|
|
160
|
+
[styles["modal__contentWrapper__scroll--image"]]: imageView
|
|
161
|
+
}),
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ jsx("div", { ref: topContent }),
|
|
164
|
+
/* @__PURE__ */ jsxs("div", { className: styles.modal__contentWrapper__title, children: [
|
|
165
|
+
getIcon(variant, props.icon),
|
|
166
|
+
/* @__PURE__ */ jsx(Title, { id: ariaLabelAttributes == null ? void 0 : ariaLabelAttributes["aria-labelledby"], htmlMarkup: "h3", appearance: "title3", className: titleClasses, children: props.title }),
|
|
167
|
+
props.afterTitleChildren && /* @__PURE__ */ jsx("div", { className: styles["modal__afterTitleChildren"], children: props.afterTitleChildren })
|
|
168
|
+
] }),
|
|
169
|
+
imageView && /* @__PURE__ */ jsxs("div", { children: [
|
|
170
|
+
/* @__PURE__ */ jsx("div", { className: styles["modal__contentWrapper__imageWrapper"], children: props.children }),
|
|
171
|
+
/* @__PURE__ */ jsx("span", { className: styles["modal__contentWrapper__imageDescription"], children: props.description })
|
|
172
|
+
] }),
|
|
173
|
+
!imageView && props.children && /* @__PURE__ */ jsx("div", { children: props.children }),
|
|
174
|
+
!imageView && !props.children && /* @__PURE__ */ jsx("p", { className: styles.modal__description, children: props.description }),
|
|
175
|
+
/* @__PURE__ */ jsx("div", { ref: bottomContent })
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
/* @__PURE__ */ jsx(
|
|
183
|
+
"div",
|
|
184
|
+
{
|
|
185
|
+
className: classNames(styles["modal__shadow"], styles["modal__shadow--bottom"], {
|
|
186
|
+
[styles["modal__shadow--show"]]: !bottomContentVisible && contentIsScrollable
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
),
|
|
190
|
+
showActions && /* @__PURE__ */ jsxs("div", { className: classNames(styles["modal__call-to-action"], size && styles[`modal__call-to-action--${size}`]), children: [
|
|
191
|
+
props.onSuccess && /* @__PURE__ */ jsx(Button, { onClick: props.onSuccess, children: primaryButtonText }),
|
|
192
|
+
props.secondaryButtonText && ((_b = props.secondaryButtonText) == null ? void 0 : _b.length) > 0 && /* @__PURE__ */ jsx(Button, { variant: "borderless", onClick: props.onClose, children: props.secondaryButtonText })
|
|
193
|
+
] })
|
|
194
|
+
] }) })
|
|
206
195
|
}
|
|
207
196
|
) });
|
|
208
197
|
if (props.printable) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport useFocusTrap from '../../hooks/useFocusTrap';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { palette } from '../../theme/palette';\nimport { uuid } from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport AlertSignFill from '../Icons/AlertSignFill';\nimport AlertSignStroke from '../Icons/AlertSignStroke';\nimport CheckOutline from '../Icons/CheckOutline';\nimport Portal from '../Portal';\nimport Title from '../Title/Title';\n\nimport styles from './styles.module.scss';\n\nexport enum ModalVariants {\n normal = 'normal',\n warning = 'warning',\n error = 'error',\n success = 'success',\n image = 'image',\n}\n\nexport enum ModalSize {\n large = 'large',\n medium = 'medium',\n}\n\nexport interface ModalProps {\n /** Title of the modal */\n title: string;\n /** id of the modal title */\n titleId?: string;\n /** Description of the modal. Will not render if the modal has children. */\n description?: string;\n /** Changes the visual representation of the modal */\n variant?: keyof typeof ModalVariants;\n /** Change width of the modal (default: large) */\n size?: keyof typeof ModalSize;\n /** Icon displayed in title */\n icon?: React.ReactElement;\n /** Hides the close button */\n noCloseButton?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Primary button text */\n primaryButtonText?: string;\n /** Secondary button text */\n secondaryButtonText?: string;\n /** Sets the aria-label of the modal */\n ariaLabel?: string;\n /** Sets the aria-labelledby of the modal */\n ariaLabelledBy?: string;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Alternative component to modal */\n children?: React.ReactNode;\n /** Component shown after title */\n afterTitleChildren?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Customize the z-index of the modal */\n zIndex?: number;\n /** Function is called when user clicks primary button */\n onSuccess?: () => void;\n /** Function is called when user clicks secondary button, clicks escape or outside the modal */\n onClose?: () => void;\n /** When enabled the component will be rendered in the bottom of document.body */\n printable?: boolean;\n /** If disabled, clicking escape or outside the modal will not close it */\n disableCloseEvents?: boolean;\n}\n\nconst getVariantIcon = (variant?: ModalProps['variant']): JSX.Element | null => {\n if (variant === ModalVariants.error) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignFill} color={palette.cherry500} />;\n } else if (variant === ModalVariants.warning) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignStroke} color={palette.black} />;\n } else if (variant === ModalVariants.success) {\n return <Icon size={IconSize.Small} svgIcon={CheckOutline} color={palette.kiwi900} />;\n }\n return null;\n};\n\nconst getIcon = (variant?: ModalProps['variant'], icon?: ModalProps['icon']): JSX.Element | null => {\n const variantIcon = getVariantIcon(variant);\n if (variantIcon) {\n return <div className={styles.modal__iconWrapper}>{variantIcon}</div>;\n }\n if (icon) {\n return (\n <div className={styles.modal__iconWrapper}>\n {React.cloneElement(icon, {\n size: IconSize.Small,\n })}\n </div>\n );\n }\n return null;\n};\n\nconst Modal: React.FC<ModalProps> = props => {\n const {\n variant = ModalVariants.normal,\n primaryButtonText = 'OK',\n titleId = uuid(),\n className = '',\n size = ModalSize.large,\n zIndex = ZIndex.Modal,\n } = props;\n\n const topContent = React.useRef<HTMLDivElement>(null);\n const modalContentRef = React.useRef<HTMLDivElement>(null);\n const dialogRef = React.useRef<HTMLDivElement>(null);\n useFocusTrap(dialogRef, true);\n const topContentVisible = useIsVisible(topContent);\n const bottomContent = React.useRef<HTMLDivElement>(null);\n const bottomContentVisible = useIsVisible(bottomContent);\n const contentIsScrollable = modalContentRef.current && modalContentRef.current.scrollHeight > modalContentRef.current.clientHeight;\n\n function handleKeyboardEvent(e: KeyboardEvent): void {\n if (e.key === 'Escape' && props.onClose) {\n e.stopPropagation();\n props.onClose();\n }\n }\n\n function handleClickEvent(event: MouseEvent): void {\n if (event.target && overlayRef.current === event.target && props.onClose) {\n event.stopPropagation();\n props.onClose();\n }\n }\n\n function disableBodyScroll(): void {\n document.body.style.overflow = 'hidden';\n }\n\n function enableBodyScroll(): void {\n document.body.style.removeProperty('overflow');\n }\n\n /* Displays a full window size modal with image */\n const imageView = variant === ModalVariants.image;\n\n const overlayRef = React.useRef<HTMLDivElement>(null);\n\n const showActions = (props.secondaryButtonText && props.secondaryButtonText?.length > 0) || props.onSuccess;\n\n // ariaLabelledBy prioriteres over ariaLabel, men dersom ariaLabel brukes trengs ikke ariaLabelledBy\n const ariaLabel = !props.ariaLabelledBy ? props.ariaLabel : undefined;\n const ariaLabelledBy = props.ariaLabelledBy ? props.ariaLabelledBy : !props.ariaLabel ? titleId : undefined;\n\n useEffect(() => {\n const overlayElement = overlayRef.current;\n disableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.addEventListener('keydown', handleKeyboardEvent);\n overlayElement.addEventListener('click', handleClickEvent);\n }\n return (): void => {\n enableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.removeEventListener('keydown', handleKeyboardEvent);\n overlayElement.removeEventListener('click', handleClickEvent);\n }\n };\n }, [props.disableCloseEvents]);\n\n useEffect(() => {\n dialogRef.current?.focus();\n }, []);\n\n const dialogClasses = cn(\n className,\n styles.modal,\n variant && styles[`modal--${variant}`],\n size && styles[`modal--${size}`],\n contentIsScrollable && !showActions && styles['modal--no-actions']\n );\n\n const titleClasses = cn({\n [styles['modal__title--error']]: variant === ModalVariants.error,\n [styles['modal__title--success']]: variant === ModalVariants.success,\n });\n\n const Component = (\n <div data-testid=\"dialog-container\">\n <div\n ref={overlayRef}\n className={styles['modal-overlay']}\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.Modal}\n style={{ zIndex }}\n >\n <div className={styles.align}>\n <div\n className={dialogClasses}\n role=\"dialog\"\n aria-modal=\"true\"\n tabIndex={-1}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n ref={dialogRef}\n >\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--top'], {\n [styles['modal__shadow--show']]: !topContentVisible && contentIsScrollable,\n })}\n />\n <div\n className={cn(styles.modal__contentWrapper, {\n [styles['modal__contentWrapper--image']]: imageView,\n })}\n tabIndex={contentIsScrollable ? 0 : undefined}\n role={contentIsScrollable ? 'region' : undefined}\n aria-label={contentIsScrollable ? ariaLabel : undefined}\n aria-labelledby={contentIsScrollable ? ariaLabelledBy : undefined}\n ref={modalContentRef}\n >\n {!props.noCloseButton && (\n <div className={styles.modal__closeWrapper}>\n <div className={cn(styles.modal__closeWrapper__close)}>\n <Close onClick={props.onClose} ariaLabel={props.ariaLabelCloseBtn} />\n </div>\n </div>\n )}\n <div\n className={cn(size && styles[`modal__contentWrapper__scroll--${size}`], {\n [styles['modal__contentWrapper__scroll--image']]: imageView,\n })}\n >\n <div ref={topContent} />\n <div className={styles.modal__contentWrapper__title}>\n {getIcon(variant, props.icon)}\n <Title id={ariaLabelledBy} htmlMarkup=\"h3\" appearance=\"title3\" className={titleClasses}>\n {props.title}\n </Title>\n {props.afterTitleChildren && <div className={styles['modal__afterTitleChildren']}>{props.afterTitleChildren}</div>}\n </div>\n {imageView && (\n <div>\n <div className={styles['modal__contentWrapper__imageWrapper']}>{props.children}</div>\n <span className={styles['modal__contentWrapper__imageDescription']}>{props.description}</span>\n </div>\n )}\n {!imageView && props.children && <div>{props.children}</div>}\n {!imageView && !props.children && <p className={styles.modal__description}>{props.description}</p>}\n <div ref={bottomContent} />\n </div>\n </div>\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--bottom'], {\n [styles['modal__shadow--show']]: !bottomContentVisible && contentIsScrollable,\n })}\n />\n {showActions && (\n <div className={cn(styles['modal__call-to-action'], size && styles[`modal__call-to-action--${size}`])}>\n {props.onSuccess && <Button onClick={props.onSuccess}>{primaryButtonText}</Button>}\n {props.secondaryButtonText && props.secondaryButtonText?.length > 0 && (\n <Button variant=\"borderless\" onClick={props.onClose}>\n {props.secondaryButtonText}\n </Button>\n )}\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n );\n\n if (props.printable) {\n const printModal = 'print-modal';\n return (\n <Portal className={printModal} testId=\"print-modal\">\n <style media=\"print\">{`body > *:not(.${printModal}) {display: none;}`}</style>\n {Component}\n </Portal>\n );\n }\n\n return Component;\n};\n\nexport default Modal;\n"],"names":["ModalVariants","ModalSize","_a","cn"],"mappings":";;;;;;;;;;;;;;;;;AAoBY,IAAA,kCAAAA,mBAAL;AACLA,iBAAA,QAAS,IAAA;AACTA,iBAAA,SAAU,IAAA;AACVA,iBAAA,OAAQ,IAAA;AACRA,iBAAA,SAAU,IAAA;AACVA,iBAAA,OAAQ,IAAA;AALEA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;AAQA,IAAA,8BAAAC,eAAL;AACLA,aAAA,OAAQ,IAAA;AACRA,aAAA,QAAS,IAAA;AAFCA,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAkDZ,MAAM,iBAAiB,CAAC,YAAwD;AAC9E,MAAI,YAAY,SAAqB;AAC5B,WAAA,oBAAC,QAAK,MAAM,SAAS,OAAO,SAAS,eAAe,OAAO,QAAQ,UAAW,CAAA;AAAA,EAAA,WAC5E,YAAY,WAAuB;AACrC,WAAA,oBAAC,QAAK,MAAM,SAAS,OAAO,SAAS,iBAAiB,OAAO,QAAQ,MAAO,CAAA;AAAA,EAAA,WAC1E,YAAY,WAAuB;AACrC,WAAA,oBAAC,QAAK,MAAM,SAAS,OAAO,SAAS,cAAc,OAAO,QAAQ,QAAS,CAAA;AAAA,EAAA;AAE7E,SAAA;AACT;AAEA,M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O,SAAS,MAAM,WAAY,UAAkB,mBAAA;AAAA,cACxE,MAAM,yBAAuB,WAAM,wBAAN,mBAA2B,UAAS,KAChE,oBAAC,QAAO,EAAA,SAAQ,cAAa,SAAS,MAAM,SACzC,gBAAM,oBACT,CAAA;AAAA,YAAA,EAEJ,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA,EAGN,CAAA;AAAA,IAAA;AAAA,EAAA,GAEJ;AAGF,MAAI,MAAM,WAAW;AACnB,UAAM,aAAa;AACnB,WACG,qBAAA,QAAA,EAAO,WAAW,YAAY,QAAO,eACpC,UAAA;AAAA,MAAA,oBAAC,SAAM,EAAA,OAAM,SAAS,UAAA,iBAAiB,UAAU,sBAAqB;AAAA,MACrE;AAAA,IAAA,GACH;AAAA,EAAA;AAIG,SAAA;AACT;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport useFocusTrap from '../../hooks/useFocusTrap';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useReturnFocusOnUnmount } from '../../hooks/useReturnFocusOnUnmount';\nimport { palette } from '../../theme/palette';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { uuid } from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport AlertSignFill from '../Icons/AlertSignFill';\nimport AlertSignStroke from '../Icons/AlertSignStroke';\nimport CheckOutline from '../Icons/CheckOutline';\nimport Portal from '../Portal';\nimport Title from '../Title/Title';\n\nimport styles from './styles.module.scss';\n\nexport enum ModalVariants {\n normal = 'normal',\n warning = 'warning',\n error = 'error',\n success = 'success',\n image = 'image',\n}\n\nexport enum ModalSize {\n large = 'large',\n medium = 'medium',\n}\n\nexport interface ModalProps {\n /** Title of the modal */\n title: string;\n /** id of the modal title */\n titleId?: string;\n /** Description of the modal. Will not render if the modal has children. */\n description?: string;\n /** Changes the visual representation of the modal */\n variant?: keyof typeof ModalVariants;\n /** Change width of the modal (default: large) */\n size?: keyof typeof ModalSize;\n /** Icon displayed in title */\n icon?: React.ReactElement;\n /** Hides the close button */\n noCloseButton?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Primary button text */\n primaryButtonText?: string;\n /** Secondary button text */\n secondaryButtonText?: string;\n /** Sets the aria-label of the modal */\n ariaLabel?: string;\n /** Sets the aria-labelledby of the modal */\n ariaLabelledBy?: string;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Alternative component to modal */\n children?: React.ReactNode;\n /** Component shown after title */\n afterTitleChildren?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Customize the z-index of the modal */\n zIndex?: number;\n /** Function is called when user clicks primary button */\n onSuccess?: () => void;\n /** Function is called when user clicks secondary button, clicks escape or outside the modal */\n onClose?: () => void;\n /** When enabled the component will be rendered in the bottom of document.body */\n printable?: boolean;\n /** If disabled, clicking escape or outside the modal will not close it */\n disableCloseEvents?: boolean;\n}\n\nconst getVariantIcon = (variant?: ModalProps['variant']): JSX.Element | null => {\n if (variant === ModalVariants.error) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignFill} color={palette.cherry500} />;\n } else if (variant === ModalVariants.warning) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignStroke} color={palette.black} />;\n } else if (variant === ModalVariants.success) {\n return <Icon size={IconSize.Small} svgIcon={CheckOutline} color={palette.kiwi900} />;\n }\n return null;\n};\n\nconst getIcon = (variant?: ModalProps['variant'], icon?: ModalProps['icon']): JSX.Element | null => {\n const variantIcon = getVariantIcon(variant);\n if (variantIcon) {\n return <div className={styles.modal__iconWrapper}>{variantIcon}</div>;\n }\n if (icon) {\n return (\n <div className={styles.modal__iconWrapper}>\n {React.cloneElement(icon, {\n size: IconSize.Small,\n })}\n </div>\n );\n }\n return null;\n};\n\nconst Modal: React.FC<ModalProps> = props => {\n const {\n variant = ModalVariants.normal,\n primaryButtonText = 'OK',\n titleId = uuid(),\n className = '',\n size = ModalSize.large,\n zIndex = ZIndex.Modal,\n } = props;\n\n const topContent = React.useRef<HTMLDivElement>(null);\n const modalContentRef = React.useRef<HTMLDivElement>(null);\n const dialogRef = React.useRef<HTMLDivElement>(null);\n useFocusTrap(dialogRef, true);\n const topContentVisible = useIsVisible(topContent);\n const bottomContent = React.useRef<HTMLDivElement>(null);\n const bottomContentVisible = useIsVisible(bottomContent);\n const contentIsScrollable = modalContentRef.current && modalContentRef.current.scrollHeight > modalContentRef.current.clientHeight;\n useReturnFocusOnUnmount(dialogRef);\n\n function handleKeyboardEvent(e: KeyboardEvent): void {\n if (e.key === 'Escape' && props.onClose) {\n e.stopPropagation();\n props.onClose();\n }\n }\n\n function handleClickEvent(event: MouseEvent): void {\n if (event.target && overlayRef.current === event.target && props.onClose) {\n event.stopPropagation();\n props.onClose();\n }\n }\n\n function disableBodyScroll(): void {\n document.body.style.overflow = 'hidden';\n }\n\n function enableBodyScroll(): void {\n document.body.style.removeProperty('overflow');\n }\n\n /* Displays a full window size modal with image */\n const imageView = variant === ModalVariants.image;\n\n const overlayRef = React.useRef<HTMLDivElement>(null);\n\n const showActions = (props.secondaryButtonText && props.secondaryButtonText?.length > 0) || props.onSuccess;\n\n const ariaLabelAttributes = getAriaLabelAttributes({ label: props.ariaLabel, id: props.ariaLabelledBy, fallbackId: titleId });\n\n useEffect(() => {\n const overlayElement = overlayRef.current;\n disableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.addEventListener('keydown', handleKeyboardEvent);\n overlayElement.addEventListener('click', handleClickEvent);\n }\n return (): void => {\n enableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.removeEventListener('keydown', handleKeyboardEvent);\n overlayElement.removeEventListener('click', handleClickEvent);\n }\n };\n }, [props.disableCloseEvents]);\n\n useEffect(() => {\n dialogRef.current?.focus();\n }, []);\n\n const dialogClasses = cn(\n className,\n styles.modal,\n variant && styles[`modal--${variant}`],\n size && styles[`modal--${size}`],\n contentIsScrollable && !showActions && styles['modal--no-actions']\n );\n\n const titleClasses = cn({\n [styles['modal__title--error']]: variant === ModalVariants.error,\n [styles['modal__title--success']]: variant === ModalVariants.success,\n });\n\n const Component = (\n <div data-testid=\"dialog-container\">\n <div\n ref={overlayRef}\n className={styles['modal-overlay']}\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.Modal}\n style={{ zIndex }}\n >\n <div className={styles.align}>\n <div className={dialogClasses} role=\"dialog\" aria-modal=\"true\" tabIndex={-1} {...ariaLabelAttributes} ref={dialogRef}>\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--top'], {\n [styles['modal__shadow--show']]: !topContentVisible && contentIsScrollable,\n })}\n />\n <div\n className={cn(styles.modal__contentWrapper, {\n [styles['modal__contentWrapper--image']]: imageView,\n })}\n tabIndex={contentIsScrollable ? 0 : undefined}\n role={contentIsScrollable ? 'region' : undefined}\n {...(contentIsScrollable ? ariaLabelAttributes : {})}\n ref={modalContentRef}\n >\n {!props.noCloseButton && (\n <div className={styles.modal__closeWrapper}>\n <div className={cn(styles.modal__closeWrapper__close)}>\n <Close onClick={props.onClose} ariaLabel={props.ariaLabelCloseBtn} />\n </div>\n </div>\n )}\n <div\n className={cn(size && styles[`modal__contentWrapper__scroll--${size}`], {\n [styles['modal__contentWrapper__scroll--image']]: imageView,\n })}\n >\n <div ref={topContent} />\n <div className={styles.modal__contentWrapper__title}>\n {getIcon(variant, props.icon)}\n <Title id={ariaLabelAttributes?.['aria-labelledby']} htmlMarkup=\"h3\" appearance=\"title3\" className={titleClasses}>\n {props.title}\n </Title>\n {props.afterTitleChildren && <div className={styles['modal__afterTitleChildren']}>{props.afterTitleChildren}</div>}\n </div>\n {imageView && (\n <div>\n <div className={styles['modal__contentWrapper__imageWrapper']}>{props.children}</div>\n <span className={styles['modal__contentWrapper__imageDescription']}>{props.description}</span>\n </div>\n )}\n {!imageView && props.children && <div>{props.children}</div>}\n {!imageView && !props.children && <p className={styles.modal__description}>{props.description}</p>}\n <div ref={bottomContent} />\n </div>\n </div>\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--bottom'], {\n [styles['modal__shadow--show']]: !bottomContentVisible && contentIsScrollable,\n })}\n />\n {showActions && (\n <div className={cn(styles['modal__call-to-action'], size && styles[`modal__call-to-action--${size}`])}>\n {props.onSuccess && <Button onClick={props.onSuccess}>{primaryButtonText}</Button>}\n {props.secondaryButtonText && props.secondaryButtonText?.length > 0 && (\n <Button variant=\"borderless\" onClick={props.onClose}>\n {props.secondaryButtonText}\n </Button>\n )}\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n );\n\n if (props.printable) {\n const printModal = 'print-modal';\n return (\n <Portal className={printModal} testId=\"print-modal\">\n <style media=\"print\">{`body > *:not(.${printModal}) {display: none;}`}</style>\n {Component}\n </Portal>\n );\n }\n\n return Component;\n};\n\nexport default Modal;\n"],"names":["ModalVariants","ModalSize","React","_a","cn"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBY,IAAA,kCAAAA,mBAAL;AACLA,iBAAA,QAAS,IAAA;AACTA,iBAAA,SAAU,IAAA;AACVA,iBAAA,OAAQ,IAAA;AACRA,iBAAA,SAAU,IAAA;AACVA,iBAAA,OAAQ,IAAA;AALEA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;AAQA,IAAA,8BAAAC,eAAL;AACLA,aAAA,OAAQ,IAAA;AACRA,aAAA,QAAS,IAAA;AAFCA,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAkDZ,MAAM,iBAAiB,CAAC,YAAwD;AAC9E,MAAI,YAAY,SAAqB;AAC5B,WAAA,oBAAC,QAAK,MAAM,SAAS,OAAO,SAAS,eAAe,OAAO,QAAQ,UAAW,CAAA;AAAA,EAAA,WAC5E,YAAY,WAAuB;AACrC,WAAA,oBAAC,QAAK,MAAM,SAAS,OAAO,SAAS,iBAAiB,OAAO,QAAQ,MAAO,CAA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oBAAA,QAAA,EAAO,SAAS,MAAM,WAAY,UAAkB,mBAAA;AAAA,UACxE,MAAM,yBAAuB,WAAM,wBAAN,mBAA2B,UAAS,KAChE,oBAAC,QAAO,EAAA,SAAQ,cAAa,SAAS,MAAM,SACzC,gBAAM,oBACT,CAAA;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA,EAAA,CAEJ,EACF,CAAA;AAAA,IAAA;AAAA,EAAA,GAEJ;AAGF,MAAI,MAAM,WAAW;AACnB,UAAM,aAAa;AACnB,WACG,qBAAA,QAAA,EAAO,WAAW,YAAY,QAAO,eACpC,UAAA;AAAA,MAAA,oBAAC,SAAM,EAAA,OAAM,SAAS,UAAA,iBAAiB,UAAU,sBAAqB;AAAA,MACrE;AAAA,IAAA,GACH;AAAA,EAAA;AAIG,SAAA;AACT;"}
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
box-shadow: 0 0 5px 0 rgb(0 0 0 / 50%);
|
|
35
35
|
background-color: $white;
|
|
36
36
|
animation: open 200ms 1;
|
|
37
|
+
outline: none;
|
|
37
38
|
|
|
38
39
|
&__title {
|
|
39
40
|
&--error {
|
|
@@ -92,7 +93,7 @@
|
|
|
92
93
|
width: 696px;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
@
|
|
96
|
+
@include tiny-screens-media-query {
|
|
96
97
|
padding-bottom: getSpacer(2xs);
|
|
97
98
|
}
|
|
98
99
|
}
|
|
@@ -170,12 +171,17 @@
|
|
|
170
171
|
overflow: auto;
|
|
171
172
|
overflow-x: hidden;
|
|
172
173
|
|
|
174
|
+
&:focus-visible {
|
|
175
|
+
outline: 1px solid $black;
|
|
176
|
+
outline-offset: -1px;
|
|
177
|
+
}
|
|
178
|
+
|
|
173
179
|
@media print {
|
|
174
180
|
overflow: hidden;
|
|
175
181
|
max-height: none;
|
|
176
182
|
}
|
|
177
183
|
|
|
178
|
-
@
|
|
184
|
+
@include tiny-screens-media-query {
|
|
179
185
|
max-height: calc(100dvh - 4rem);
|
|
180
186
|
}
|
|
181
187
|
|
|
@@ -191,7 +197,7 @@
|
|
|
191
197
|
padding: getSpacer(xl) getSpacer(xl) getSpacer(2xs);
|
|
192
198
|
}
|
|
193
199
|
|
|
194
|
-
@
|
|
200
|
+
@include tiny-screens-media-query {
|
|
195
201
|
padding: getSpacer(2xs) getSpacer(2xs) getSpacer(4xs);
|
|
196
202
|
}
|
|
197
203
|
}
|
|
@@ -203,7 +209,7 @@
|
|
|
203
209
|
padding: getSpacer(xl) getSpacer(m) getSpacer(2xs);
|
|
204
210
|
}
|
|
205
211
|
|
|
206
|
-
@
|
|
212
|
+
@include tiny-screens-media-query {
|
|
207
213
|
padding: getSpacer(2xs) getSpacer(3xs) getSpacer(4xs);
|
|
208
214
|
}
|
|
209
215
|
}
|
|
@@ -258,7 +264,7 @@
|
|
|
258
264
|
padding: getSpacer(l) getSpacer(xl) 0;
|
|
259
265
|
}
|
|
260
266
|
|
|
261
|
-
@
|
|
267
|
+
@include tiny-screens-media-query {
|
|
262
268
|
padding: getSpacer(2xs) getSpacer(2xs) 0;
|
|
263
269
|
}
|
|
264
270
|
}
|
|
@@ -266,7 +272,7 @@
|
|
|
266
272
|
&--medium {
|
|
267
273
|
padding: getSpacer(m) getSpacer(m) 0;
|
|
268
274
|
|
|
269
|
-
@
|
|
275
|
+
@include tiny-screens-media-query {
|
|
270
276
|
padding: getSpacer(2xs) getSpacer(2xs) 0;
|
|
271
277
|
}
|
|
272
278
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import React__default from "react";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import { AnalyticsId, IconSize } from "../../constants.js";
|
|
5
5
|
import { useUuid } from "../../hooks/useUuid.js";
|
|
@@ -16,7 +16,7 @@ const FluidWrapper = ({ fluid, children }) => {
|
|
|
16
16
|
}
|
|
17
17
|
return children;
|
|
18
18
|
};
|
|
19
|
-
const NotificationPanel =
|
|
19
|
+
const NotificationPanel = React__default.forwardRef((props, ref) => {
|
|
20
20
|
const {
|
|
21
21
|
children,
|
|
22
22
|
variant = "info",
|
|
@@ -51,7 +51,7 @@ const NotificationPanel = React.forwardRef((props, ref) => {
|
|
|
51
51
|
[styles["notification-panel__children--outline"]]: outlineVariant
|
|
52
52
|
});
|
|
53
53
|
const CustomTag = labelHtmlMarkup;
|
|
54
|
-
const [expanderOpen, setExpanderOpen] =
|
|
54
|
+
const [expanderOpen, setExpanderOpen] = React__default.useState(expanderOpenFromStart);
|
|
55
55
|
return /* @__PURE__ */ jsxs("div", { className: contentClasses, id: !label ? uuid : void 0, children: [
|
|
56
56
|
label && /* @__PURE__ */ jsx(CustomTag, { className: labelClasses, id: uuid, children: label }),
|
|
57
57
|
children && /* @__PURE__ */ jsx("div", { className: childrenClasses, children }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/NotificationPanel/NotificationPanel.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\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';\n /** Sets the data-testid attribute. */\n testId?: string;\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.forwardRef<HTMLDivElement, NotificationPanelProps>((props, ref) => {\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 labelHtmlMarkup = 'h1',\n fluid = false,\n size,\n className,\n labelId,\n role,\n testId,\n } = props;\n const uuid = useUuid(labelId);\n const renderContent = (): JSX.Element => {\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 const [expanderOpen, setExpanderOpen] = React.useState(expanderOpenFromStart);\n return (\n <div className={contentClasses} id={!label ? uuid : undefined}>\n {label && (\n <CustomTag className={labelClasses} id={uuid}>\n {label}\n </CustomTag>\n )}\n {children && <div className={childrenClasses}>{children}</div>}\n {expanderChildren && expanderButtonText && expanderButtonClosedText && !compactVariant && (\n <Expander\n title={expanderOpen ? expanderButtonText : expanderButtonClosedText}\n onExpand={setExpanderOpen}\n expanded={expanderOpen}\n testId=\"expand\"\n >\n {expanderChildren}\n </Expander>\n )}\n </div>\n );\n };\n\n const notificationPanelClasses = classNames(\n styles['notification-panel'],\n styles[`notification-panel--${variant}`],\n size && styles[`notification-panel--${size}`],\n {\n [styles['notification-panel--compact']]: !!compactVariant,\n [styles['notification-panel--compact--basic']]: compactVariant === 'basic',\n [styles['notification-panel--compact--outline']]: compactVariant === 'outline',\n [styles['notification-panel--with-content']]: expanderChildren || (label && children),\n [styles['notification-panel--dismissable']]: dismissable,\n },\n className\n );\n\n const ariaRole = role || (variant === 'error' && 'alert') || undefined;\n const ariaLabelAttributes = ariaRole ? getAriaLabelAttributes({ label, id: uuid }) : 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 ? 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={getColor('black')} />\n </span>\n )}\n {renderContent()}\n </div>\n </FluidWrapper>\n );\n});\n\nexport default NotificationPanel;\n"],"names":[],"mappings":";;;;;;;;;;;AA8DA,MAAM,eAAyC,CAAC,EAAE,OAAO,eAAe;AACtE,MAAI,OAAO;AACT,UAAM,eAAe,WAAW,OAAO,eAAe,CAAC;AAEvD,WAAQ,oBAAA,OAAA,EAAI,WAAW,cAAe,SAAS,CAAA;AAAA,EAAA;AAE1C,SAAA;AACT;AAEA,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/NotificationPanel/NotificationPanel.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\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';\n /** Sets the data-testid attribute. */\n testId?: string;\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.forwardRef<HTMLDivElement, NotificationPanelProps>((props, ref) => {\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 labelHtmlMarkup = 'h1',\n fluid = false,\n size,\n className,\n labelId,\n role,\n testId,\n } = props;\n const uuid = useUuid(labelId);\n const renderContent = (): JSX.Element => {\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 const [expanderOpen, setExpanderOpen] = React.useState(expanderOpenFromStart);\n return (\n <div className={contentClasses} id={!label ? uuid : undefined}>\n {label && (\n <CustomTag className={labelClasses} id={uuid}>\n {label}\n </CustomTag>\n )}\n {children && <div className={childrenClasses}>{children}</div>}\n {expanderChildren && expanderButtonText && expanderButtonClosedText && !compactVariant && (\n <Expander\n title={expanderOpen ? expanderButtonText : expanderButtonClosedText}\n onExpand={setExpanderOpen}\n expanded={expanderOpen}\n testId=\"expand\"\n >\n {expanderChildren}\n </Expander>\n )}\n </div>\n );\n };\n\n const notificationPanelClasses = classNames(\n styles['notification-panel'],\n styles[`notification-panel--${variant}`],\n size && styles[`notification-panel--${size}`],\n {\n [styles['notification-panel--compact']]: !!compactVariant,\n [styles['notification-panel--compact--basic']]: compactVariant === 'basic',\n [styles['notification-panel--compact--outline']]: compactVariant === 'outline',\n [styles['notification-panel--with-content']]: expanderChildren || (label && children),\n [styles['notification-panel--dismissable']]: dismissable,\n },\n className\n );\n\n const ariaRole = role || (variant === 'error' && 'alert') || undefined;\n const ariaLabelAttributes = ariaRole ? getAriaLabelAttributes({ label, id: uuid }) : 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 ? 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={getColor('black')} />\n </span>\n )}\n {renderContent()}\n </div>\n </FluidWrapper>\n );\n});\n\nexport default NotificationPanel;\n"],"names":["React"],"mappings":";;;;;;;;;;;AA8DA,MAAM,eAAyC,CAAC,EAAE,OAAO,eAAe;AACtE,MAAI,OAAO;AACT,UAAM,eAAe,WAAW,OAAO,eAAe,CAAC;AAEvD,WAAQ,oBAAA,OAAA,EAAI,WAAW,cAAe,SAAS,CAAA;AAAA,EAAA;AAE1C,SAAA;AACT;AAEA,MAAM,oBAAoBA,eAAM,WAAmD,CAAC,OA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AC;"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import React__default from "react";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import { AnalyticsId } from "../../constants.js";
|
|
5
5
|
import { b as PanelVariant, P as Panel } from "../../Panel.js";
|
|
6
6
|
import styles from "./styles.module.scss";
|
|
7
|
-
const isPanelComponent = (element) =>
|
|
8
|
-
const PanelList =
|
|
7
|
+
const isPanelComponent = (element) => React__default.isValidElement(element) && element.type === Panel;
|
|
8
|
+
const PanelList = React__default.forwardRef(function BadgeForwardedRef(props, ref) {
|
|
9
9
|
const { testId, children, variant = PanelVariant.fill } = props;
|
|
10
|
-
const renderPanel = (panel, firstChild) =>
|
|
10
|
+
const renderPanel = (panel, firstChild) => React__default.cloneElement(panel, {
|
|
11
11
|
variant,
|
|
12
12
|
noTopBorder: variant === PanelVariant.line && !firstChild,
|
|
13
13
|
className: classNames(panel.props.className, variant !== PanelVariant.line && styles["panel-list__panel"])
|
|
14
14
|
});
|
|
15
|
-
return /* @__PURE__ */ jsx("div", { ref, "data-testid": testId, "data-analyticsid": AnalyticsId.PanelList, children:
|
|
15
|
+
return /* @__PURE__ */ jsx("div", { ref, "data-testid": testId, "data-analyticsid": AnalyticsId.PanelList, children: React__default.Children.map(children, (child, index) => isPanelComponent(child) ? renderPanel(child, index === 0) : child) });
|
|
16
16
|
});
|
|
17
17
|
export {
|
|
18
18
|
PanelList as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/PanelList/PanelList.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport Panel, { PanelProps, PanelVariant } from '../Panel';\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?: keyof typeof PanelVariant;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst isPanelComponent = (element: {} | null | undefined): element is React.ReactElement<PanelProps> =>\n React.isValidElement<PanelProps>(element) && (element as React.ReactElement).type === Panel;\n\nconst PanelList = React.forwardRef(function BadgeForwardedRef(props: PanelListProps, ref: React.ForwardedRef<HTMLDivElement>) {\n const { testId, children, variant = PanelVariant.fill } = props;\n\n const renderPanel = (panel: React.ReactElement<PanelProps>, firstChild: boolean) =>\n React.cloneElement(panel, {\n variant: variant,\n noTopBorder: variant === PanelVariant.line && !firstChild,\n className: classNames(panel.props.className, variant !== PanelVariant.line && styles['panel-list__panel']),\n });\n\n return (\n <div ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.PanelList}>\n {React.Children.map(children, (child, index) => (isPanelComponent(child) ? renderPanel(child, index === 0) : child))}\n </div>\n );\n});\n\nexport default PanelList;\n"],"names":[],"mappings":";;;;;;AAkBA,MAAM,mBAAmB,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/PanelList/PanelList.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport Panel, { PanelProps, PanelVariant } from '../Panel';\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?: keyof typeof PanelVariant;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst isPanelComponent = (element: {} | null | undefined): element is React.ReactElement<PanelProps> =>\n React.isValidElement<PanelProps>(element) && (element as React.ReactElement).type === Panel;\n\nconst PanelList = React.forwardRef(function BadgeForwardedRef(props: PanelListProps, ref: React.ForwardedRef<HTMLDivElement>) {\n const { testId, children, variant = PanelVariant.fill } = props;\n\n const renderPanel = (panel: React.ReactElement<PanelProps>, firstChild: boolean) =>\n React.cloneElement(panel, {\n variant: variant,\n noTopBorder: variant === PanelVariant.line && !firstChild,\n className: classNames(panel.props.className, variant !== PanelVariant.line && styles['panel-list__panel']),\n });\n\n return (\n <div ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.PanelList}>\n {React.Children.map(children, (child, index) => (isPanelComponent(child) ? renderPanel(child, index === 0) : child))}\n </div>\n );\n});\n\nexport default PanelList;\n"],"names":["React"],"mappings":";;;;;;AAkBA,MAAM,mBAAmB,CAAC,YACxBA,eAAM,eAA2B,OAAO,KAAM,QAA+B,SAAS;AAExF,MAAM,YAAYA,eAAM,WAAW,SAAS,kBAAkB,OAAuB,KAAyC;AAC5H,QAAM,EAAE,QAAQ,UAAU,UAAU,aAAa,SAAS;AAE1D,QAAM,cAAc,CAAC,OAAuC,eAC1DA,eAAM,aAAa,OAAO;AAAA,IACxB;AAAA,IACA,aAAa,YAAY,aAAa,QAAQ,CAAC;AAAA,IAC/C,WAAW,WAAW,MAAM,MAAM,WAAW,YAAY,aAAa,QAAQ,OAAO,mBAAmB,CAAC;AAAA,EAAA,CAC1G;AAGD,SAAA,oBAAC,OAAI,EAAA,KAAU,eAAa,QAAQ,oBAAkB,YAAY,WAC/D,UAAMA,eAAA,SAAS,IAAI,UAAU,CAAC,OAAO,UAAW,iBAAiB,KAAK,IAAI,YAAY,OAAO,UAAU,CAAC,IAAI,KAAM,EACrH,CAAA;AAEJ,CAAC;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import React__default, { useRef, useState } from "react";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import { IconSize, AnalyticsId } from "../../constants.js";
|
|
5
5
|
import { useBreakpoint } from "../../hooks/useBreakpoint.js";
|
|
@@ -71,12 +71,12 @@ const PopMenu = (props) => {
|
|
|
71
71
|
arrowClassName: styles["pop-menu__pop-over-arrow"],
|
|
72
72
|
controllerRef: iconRef,
|
|
73
73
|
popOverRef,
|
|
74
|
-
children:
|
|
74
|
+
children: React__default.Children.map(
|
|
75
75
|
children,
|
|
76
|
-
(child) =>
|
|
77
|
-
children:
|
|
76
|
+
(child) => React__default.cloneElement(child, {
|
|
77
|
+
children: React__default.Children.map(
|
|
78
78
|
child.props.children,
|
|
79
|
-
(child2) => isComponent(child2, LinkList.Link) ?
|
|
79
|
+
(child2) => isComponent(child2, LinkList.Link) ? React__default.cloneElement(child2, {
|
|
80
80
|
onClick: (event) => handleClick(() => child2.props.onClick && child2.props.onClick(event))
|
|
81
81
|
}) : child2
|
|
82
82
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/PopMenu/PopMenu.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { getColor } from '../../theme/currys';\nimport { breakpoints } from '../../theme/grid';\nimport { isComponent } from '../../utils/component';\nimport Icon, { SvgIcon } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\nimport VerticalDots from '../Icons/VerticalDots';\nimport X from '../Icons/X';\nimport LazyIcon from '../LazyIcon';\nimport LinkList, { LinkListProps, LinkProps } from '../LinkList';\nimport PopOver from '../PopOver';\n\nimport styles from './styles.module.scss';\n\nexport 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\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 /** 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<HTMLDivElement>(null);\n const popOverRef = useRef<HTMLDivElement>(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 popMenuVariant = PopMenuVariant.onWhite,\n openButtonAriaLabel,\n closeButtonAriaLabel,\n svgIcon,\n labelText,\n labelTextPosition = PopMenuLabelPosition.right,\n } = props;\n const buttonClasses = classNames(styles['pop-menu-button'], {\n [styles[`pop-menu-button--${popMenuVariant}`]]: popMenuVariant,\n });\n const breakpoint = useBreakpoint();\n const mobile = breakpoint < breakpoints.md;\n\n useOutsideEvent(outerRef, () => {\n setIsOpen(false);\n });\n\n const { isHovered: triggerButtonIsHovered } = useHover(triggerButtonRef);\n const mobileIconSize = mobile ? IconSize.XSmall : IconSize.Small;\n\n const handleClick = (cb?: () => void): void => {\n setIsOpen(false);\n cb && cb();\n };\n\n const renderChildren = () => {\n if (isComponent<LinkListProps>(children, LinkList)) {\n return (\n <PopOver\n testId={popOverTestId}\n className={classNames(styles['pop-menu__pop-over'], popOverClassName)}\n arrowClassName={styles['pop-menu__pop-over-arrow']}\n controllerRef={iconRef}\n popOverRef={popOverRef}\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 = (e?: React.MouseEvent<HTMLElement, MouseEvent>): void => {\n e && e.stopPropagation();\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 svgIcon={svgIcon ?? VerticalDots} color={getColor('black')} size={mobileIconSize} isHovered={triggerButtonIsHovered} />\n );\n\n const closeIcon = <Icon svgIcon={X} color={getColor('black')} size={mobileIconSize} isHovered={triggerButtonIsHovered} />;\n\n const triggerButton = (\n <button\n ref={triggerButtonRef}\n data-testid={isOpen ? closeButtonTestId : openButtonTestId}\n className={buttonClasses}\n aria-label={isOpen ? closeButtonAriaLabel : openButtonAriaLabel}\n aria-expanded={isOpen}\n onClick={toggleOpenOnClick}\n type=\"button\"\n >\n {labelText && labelTextPosition == PopMenuLabelPosition.left && <span>{labelText}</span>}\n {<div ref={iconRef}>{isOpen ? closeIcon : openIcon}</div>}\n {labelText && labelTextPosition == PopMenuLabelPosition.right && <span>{labelText}</span>}\n </button>\n );\n\n return (\n <div ref={outerRef} className={classNames(styles['pop-menu-button'], popMenuClassName)} data-analyticsid={AnalyticsId.PopMenu}>\n {triggerButton}\n {isOpen && renderChildren()}\n </div>\n );\n};\n\nexport default PopMenu;\n"],"names":["PopMenuVariant","PopMenuLabelPosition","child"],"mappings":";;;;;;;;;;;;;;;;;AAqBY,IAAA,mCAAAA,oBAAL;AACLA,kBAAA,SAAU,IAAA;AACVA,kBAAA,QAAS,IAA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AA,UACf;AAAA,UAEC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/PopMenu/PopMenu.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { getColor } from '../../theme/currys';\nimport { breakpoints } from '../../theme/grid';\nimport { isComponent } from '../../utils/component';\nimport Icon, { SvgIcon } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\nimport VerticalDots from '../Icons/VerticalDots';\nimport X from '../Icons/X';\nimport LazyIcon from '../LazyIcon';\nimport LinkList, { LinkListProps, LinkProps } from '../LinkList';\nimport PopOver from '../PopOver';\n\nimport styles from './styles.module.scss';\n\nexport 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\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 /** 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<HTMLDivElement>(null);\n const popOverRef = useRef<HTMLDivElement>(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 popMenuVariant = PopMenuVariant.onWhite,\n openButtonAriaLabel,\n closeButtonAriaLabel,\n svgIcon,\n labelText,\n labelTextPosition = PopMenuLabelPosition.right,\n } = props;\n const buttonClasses = classNames(styles['pop-menu-button'], {\n [styles[`pop-menu-button--${popMenuVariant}`]]: popMenuVariant,\n });\n const breakpoint = useBreakpoint();\n const mobile = breakpoint < breakpoints.md;\n\n useOutsideEvent(outerRef, () => {\n setIsOpen(false);\n });\n\n const { isHovered: triggerButtonIsHovered } = useHover(triggerButtonRef);\n const mobileIconSize = mobile ? IconSize.XSmall : IconSize.Small;\n\n const handleClick = (cb?: () => void): void => {\n setIsOpen(false);\n cb && cb();\n };\n\n const renderChildren = () => {\n if (isComponent<LinkListProps>(children, LinkList)) {\n return (\n <PopOver\n testId={popOverTestId}\n className={classNames(styles['pop-menu__pop-over'], popOverClassName)}\n arrowClassName={styles['pop-menu__pop-over-arrow']}\n controllerRef={iconRef}\n popOverRef={popOverRef}\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 = (e?: React.MouseEvent<HTMLElement, MouseEvent>): void => {\n e && e.stopPropagation();\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 svgIcon={svgIcon ?? VerticalDots} color={getColor('black')} size={mobileIconSize} isHovered={triggerButtonIsHovered} />\n );\n\n const closeIcon = <Icon svgIcon={X} color={getColor('black')} size={mobileIconSize} isHovered={triggerButtonIsHovered} />;\n\n const triggerButton = (\n <button\n ref={triggerButtonRef}\n data-testid={isOpen ? closeButtonTestId : openButtonTestId}\n className={buttonClasses}\n aria-label={isOpen ? closeButtonAriaLabel : openButtonAriaLabel}\n aria-expanded={isOpen}\n onClick={toggleOpenOnClick}\n type=\"button\"\n >\n {labelText && labelTextPosition == PopMenuLabelPosition.left && <span>{labelText}</span>}\n {<div ref={iconRef}>{isOpen ? closeIcon : openIcon}</div>}\n {labelText && labelTextPosition == PopMenuLabelPosition.right && <span>{labelText}</span>}\n </button>\n );\n\n return (\n <div ref={outerRef} className={classNames(styles['pop-menu-button'], popMenuClassName)} data-analyticsid={AnalyticsId.PopMenu}>\n {triggerButton}\n {isOpen && renderChildren()}\n </div>\n );\n};\n\nexport default PopMenu;\n"],"names":["PopMenuVariant","PopMenuLabelPosition","React","child"],"mappings":";;;;;;;;;;;;;;;;;AAqBY,IAAA,mCAAAA,oBAAL;AACLA,kBAAA,SAAU,IAAA;AACVA,kBAAA,QAAS,IAAA;AACTA,kBAAA,aAAc,IAAA;AAHJA,SAAAA;AAAA,GAAA,kBAAA,CAAA,CAAA;AAMA,IAAA,yCAAAC,0BAAL;AACLA,wBAAA,OAAQ,IAAA;AACRA,wBAAA,MAAO,IAAA;AAFGA,SAAAA;AAAA,GAAA,wBAAA,CAAA,CAAA;AAgCC,MAAA,UAAkC,CAAC,UAAwB;AAChE,QAAA,mBAAmB,OAA0B,IAAI;AACjD,QAAA,UAAU,OAAuB,IAAI;AACrC,QAAA,a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AA,EAAA,GAC5B;AAEJ;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from "react";
|
|
2
2
|
import { createPortal } from "react-dom";
|
|
3
3
|
import { AnalyticsId } from "../../constants.js";
|
|
4
4
|
function Portal({ children, parent, className, testId }) {
|
|
5
|
-
const el =
|
|
5
|
+
const el = React__default.useMemo(() => document.createElement("div"), []);
|
|
6
6
|
el.setAttribute("data-analyticsid", AnalyticsId.Portal);
|
|
7
7
|
if (testId) {
|
|
8
8
|
el.setAttribute("data-testid", testId);
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
React__default.useEffect(() => {
|
|
11
11
|
const target = parent && !!parent.appendChild ? parent : document.body;
|
|
12
12
|
const classList = ["portal-container"];
|
|
13
13
|
if (className) className.split(" ").forEach((item) => classList.push(item));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Portal/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport { AnalyticsId } from '../../constants';\n\nexport interface PortalProps {\n /** Add custom class to portal, default class is portal-container */\n className?: string;\n /** Content to be displayed in Portal */\n children?: React.ReactNode;\n /** Default is document.body */\n parent?: HTMLElement;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport default function Portal({ children, parent, className, testId }: PortalProps): React.ReactPortal {\n // Create div to contain everything\n const el = React.useMemo(() => document.createElement('div'), []);\n el.setAttribute('data-analyticsid', AnalyticsId.Portal);\n if (testId) {\n el.setAttribute('data-testid', testId);\n }\n // On mount function\n React.useEffect(() => {\n // work out target in the DOM based on parent prop\n const target = parent && !!parent.appendChild ? parent : document.body;\n // Default classes\n const classList = ['portal-container'];\n // If className prop is present add each class the classList\n if (className) className.split(' ').forEach(item => classList.push(item));\n classList.forEach(item => el.classList.add(item));\n\n target.appendChild(el);\n // On unmount function\n return (): void => {\n // Remove element from dom\n target.removeChild(el);\n };\n }, [el, parent, className]);\n\n return createPortal(children, el);\n}\n"],"names":[],"mappings":";;;AAiBA,SAAwB,OAAO,EAAE,UAAU,QAAQ,WAAW,UAA0C;AAEhG,QAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Portal/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport { AnalyticsId } from '../../constants';\n\nexport interface PortalProps {\n /** Add custom class to portal, default class is portal-container */\n className?: string;\n /** Content to be displayed in Portal */\n children?: React.ReactNode;\n /** Default is document.body */\n parent?: HTMLElement;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport default function Portal({ children, parent, className, testId }: PortalProps): React.ReactPortal {\n // Create div to contain everything\n const el = React.useMemo(() => document.createElement('div'), []);\n el.setAttribute('data-analyticsid', AnalyticsId.Portal);\n if (testId) {\n el.setAttribute('data-testid', testId);\n }\n // On mount function\n React.useEffect(() => {\n // work out target in the DOM based on parent prop\n const target = parent && !!parent.appendChild ? parent : document.body;\n // Default classes\n const classList = ['portal-container'];\n // If className prop is present add each class the classList\n if (className) className.split(' ').forEach(item => classList.push(item));\n classList.forEach(item => el.classList.add(item));\n\n target.appendChild(el);\n // On unmount function\n return (): void => {\n // Remove element from dom\n target.removeChild(el);\n };\n }, [el, parent, className]);\n\n return createPortal(children, el);\n}\n"],"names":["React"],"mappings":";;;AAiBA,SAAwB,OAAO,EAAE,UAAU,QAAQ,WAAW,UAA0C;AAEhG,QAAA,KAAKA,eAAM,QAAQ,MAAM,SAAS,cAAc,KAAK,GAAG,EAAE;AAC7D,KAAA,aAAa,oBAAoB,YAAY,MAAM;AACtD,MAAI,QAAQ;AACP,OAAA,aAAa,eAAe,MAAM;AAAA,EAAA;AAGvCA,iBAAM,UAAU,MAAM;AAEpB,UAAM,SAAS,UAAU,CAAC,CAAC,OAAO,cAAc,SAAS,SAAS;AAE5D,UAAA,YAAY,CAAC,kBAAkB;AAEjC,QAAA,UAAqB,WAAA,MAAM,GAAG,EAAE,QAAQ,CAAQ,SAAA,UAAU,KAAK,IAAI,CAAC;AACxE,cAAU,QAAQ,CAAQ,SAAA,GAAG,UAAU,IAAI,IAAI,CAAC;AAEhD,WAAO,YAAY,EAAE;AAErB,WAAO,MAAY;AAEjB,aAAO,YAAY,EAAE;AAAA,IACvB;AAAA,EACC,GAAA,CAAC,IAAI,QAAQ,SAAS,CAAC;AAEnB,SAAA,aAAa,UAAU,EAAE;AAClC;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import React__default from "react";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import { AnalyticsId, IconSize } from "../../constants.js";
|
|
5
5
|
import { useBreakpoint, Breakpoint } from "../../hooks/useBreakpoint.js";
|
|
@@ -13,7 +13,7 @@ import { T as Title } from "../../Title.js";
|
|
|
13
13
|
import styles from "./styles.module.scss";
|
|
14
14
|
const PromoPanelLink = (props) => {
|
|
15
15
|
if (props.linkComponent) {
|
|
16
|
-
return
|
|
16
|
+
return React__default.cloneElement(props.linkComponent, { children: props.children });
|
|
17
17
|
}
|
|
18
18
|
if (props.linkHtmlMarkup === "button") {
|
|
19
19
|
return /* @__PURE__ */ jsx("button", { type: "button", onClick: props.linkOnClick, children: props.children });
|