@helsenorge/designsystem-react 7.3.1 → 7.5.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/CHANGELOG.md +28 -0
- package/components/Checkbox/Checkbox.js +24 -23
- package/components/Checkbox/Checkbox.js.map +1 -1
- package/components/HighlightBox/styles.module.scss +11 -7
- package/components/Input/Input.js +25 -24
- package/components/Input/Input.js.map +1 -1
- package/components/LinkList/LinkList.js +25 -24
- package/components/LinkList/LinkList.js.map +1 -1
- package/components/NotificationPanel/NotificationPanel.js +65 -64
- package/components/NotificationPanel/NotificationPanel.js.map +1 -1
- package/components/NotificationPanel/NotificationPanel.stories.d.ts +1 -0
- package/components/NotificationPanel/styles.module.scss +28 -26
- package/components/NotificationPanel/styles.module.scss.d.ts +7 -6
- package/components/PopMenu/PopMenu.d.ts +12 -0
- package/components/PopMenu/PopMenu.js +74 -74
- package/components/PopMenu/PopMenu.js.map +1 -1
- package/components/PopMenu/PopMenu.stories.d.ts +7 -1
- package/components/PopMenu/index.js +3 -2
- package/components/PopMenu/styles.module.scss +1 -1
- package/components/PromoPanel/PromoPanel.stories.d.ts +1 -0
- package/components/RadioButton/RadioButton.js +27 -26
- package/components/RadioButton/RadioButton.js.map +1 -1
- package/components/Select/Select.js +23 -22
- package/components/Select/Select.js.map +1 -1
- package/components/ServiceMessage/ServiceMessage.stories.d.ts +1 -1
- package/components/Textarea/Textarea.js +34 -33
- package/components/Textarea/Textarea.js.map +1 -1
- package/package.json +1 -1
- package/scss/supernova/index.css +3 -0
- package/scss/supernova/styles/colors.css +173 -0
- package/utils/accessibility.d.ts +12 -0
- package/utils/accessibility.js +17 -8
- package/utils/accessibility.js.map +1 -1
|
@@ -1,126 +1,127 @@
|
|
|
1
1
|
import t from "react";
|
|
2
2
|
import c from "classnames";
|
|
3
|
-
import { DetailButton as
|
|
4
|
-
import { IconSize as
|
|
5
|
-
import { useUuid as
|
|
6
|
-
import { getColor as
|
|
7
|
-
import { palette as
|
|
8
|
-
import { getAriaLabelAttributes as
|
|
9
|
-
import
|
|
10
|
-
import { Icon as
|
|
3
|
+
import { DetailButton as B } from "./DetailButton/DetailButton.js";
|
|
4
|
+
import { IconSize as n, AnalyticsId as L } from "../../constants.js";
|
|
5
|
+
import { useUuid as P } from "../../hooks/useUuid.js";
|
|
6
|
+
import { getColor as R } from "../../theme/currys/color.js";
|
|
7
|
+
import { palette as o } from "../../theme/palette.js";
|
|
8
|
+
import { getAriaLabelAttributes as $ } from "../../utils/accessibility.js";
|
|
9
|
+
import V from "../Close/Close.js";
|
|
10
|
+
import { Icon as f } from "../Icon/Icon.js";
|
|
11
11
|
import D from "../Icons/CheckFill.js";
|
|
12
12
|
import M from "../Icons/ErrorSignFill.js";
|
|
13
13
|
import O from "../Icons/InfoSignFill.js";
|
|
14
14
|
import U from "../Icons/TriangleX.js";
|
|
15
15
|
import e from "../NotificationPanel/styles.module.scss";
|
|
16
|
-
const
|
|
16
|
+
const W = ({ fluid: s, children: m }) => {
|
|
17
17
|
if (s) {
|
|
18
18
|
const l = c(e["fluid-wrapper"]);
|
|
19
19
|
return /* @__PURE__ */ t.createElement("div", { className: l }, m);
|
|
20
20
|
}
|
|
21
21
|
return m;
|
|
22
|
-
},
|
|
22
|
+
}, j = t.forwardRef((s, m) => {
|
|
23
23
|
const {
|
|
24
24
|
children: l,
|
|
25
|
-
variant:
|
|
26
|
-
dismissable:
|
|
25
|
+
variant: p = "info",
|
|
26
|
+
dismissable: u = !1,
|
|
27
27
|
onClick: E,
|
|
28
28
|
expanderChildren: r,
|
|
29
29
|
expanderButtonText: b,
|
|
30
|
-
expanderButtonClosedText:
|
|
31
|
-
expanderOpenFromStart:
|
|
30
|
+
expanderButtonClosedText: _,
|
|
31
|
+
expanderOpenFromStart: N = !1,
|
|
32
32
|
compactVariant: a,
|
|
33
33
|
label: i,
|
|
34
|
-
fluid:
|
|
34
|
+
fluid: S = !1,
|
|
35
35
|
size: C,
|
|
36
|
-
className:
|
|
37
|
-
labelId:
|
|
36
|
+
className: I,
|
|
37
|
+
labelId: x,
|
|
38
38
|
role: g,
|
|
39
|
-
testId:
|
|
40
|
-
} = s, d =
|
|
39
|
+
testId: w
|
|
40
|
+
} = s, d = P(x), y = {
|
|
41
41
|
info: /* @__PURE__ */ t.createElement(
|
|
42
|
-
|
|
42
|
+
f,
|
|
43
43
|
{
|
|
44
44
|
svgIcon: O,
|
|
45
|
-
color:
|
|
46
|
-
hoverColor:
|
|
47
|
-
size: a ?
|
|
45
|
+
color: o.blueberry700,
|
|
46
|
+
hoverColor: o.blueberry700,
|
|
47
|
+
size: a ? n.XSmall : n.Small
|
|
48
48
|
}
|
|
49
49
|
),
|
|
50
50
|
warn: /* @__PURE__ */ t.createElement(
|
|
51
|
-
|
|
51
|
+
f,
|
|
52
52
|
{
|
|
53
53
|
svgIcon: M,
|
|
54
|
-
color:
|
|
55
|
-
hoverColor:
|
|
56
|
-
size: a ?
|
|
54
|
+
color: o.banana700,
|
|
55
|
+
hoverColor: o.banana700,
|
|
56
|
+
size: a ? n.XSmall : n.Small
|
|
57
57
|
}
|
|
58
58
|
),
|
|
59
59
|
alert: /* @__PURE__ */ t.createElement(
|
|
60
|
-
|
|
60
|
+
f,
|
|
61
61
|
{
|
|
62
62
|
svgIcon: U,
|
|
63
|
-
color:
|
|
64
|
-
hoverColor:
|
|
65
|
-
size: a ?
|
|
63
|
+
color: o.cherry700,
|
|
64
|
+
hoverColor: o.cherry700,
|
|
65
|
+
size: a ? n.XSmall : n.Small
|
|
66
66
|
}
|
|
67
67
|
),
|
|
68
68
|
success: /* @__PURE__ */ t.createElement(
|
|
69
|
-
|
|
69
|
+
f,
|
|
70
70
|
{
|
|
71
71
|
svgIcon: D,
|
|
72
|
-
color:
|
|
73
|
-
hoverColor:
|
|
74
|
-
size: a ?
|
|
72
|
+
color: o.kiwi900,
|
|
73
|
+
hoverColor: o.kiwi900,
|
|
74
|
+
size: a ? n.XSmall : n.Small
|
|
75
75
|
}
|
|
76
76
|
)
|
|
77
|
-
},
|
|
78
|
-
const
|
|
77
|
+
}, z = () => {
|
|
78
|
+
const h = a === "outline", F = c(e["notification-panel__content"]), X = c(e["notification-panel__label"], {
|
|
79
79
|
[e["notification-panel__label--no-content"]]: !l && !r,
|
|
80
|
-
[e["notification-
|
|
81
|
-
[e["notification-
|
|
82
|
-
}),
|
|
83
|
-
[e["notification-
|
|
84
|
-
[e["notification-panel__children--expander-no-label"]]: r && !i
|
|
80
|
+
[e["notification-panel__label--compact"]]: !!a,
|
|
81
|
+
[e["notification-panel__label--outline"]]: h
|
|
82
|
+
}), A = c(e["notification-panel__children"], {
|
|
83
|
+
[e["notification-panel__children--with-label"]]: i,
|
|
84
|
+
[e["notification-panel__children--expander-no-label"]]: r && !i,
|
|
85
|
+
[e["notification-panel__children--outline"]]: h
|
|
85
86
|
});
|
|
86
|
-
return /* @__PURE__ */ t.createElement("div", { className:
|
|
87
|
-
|
|
87
|
+
return /* @__PURE__ */ t.createElement("div", { className: F, id: i ? void 0 : d }, i && /* @__PURE__ */ t.createElement("h1", { className: X, id: d }, i), l && /* @__PURE__ */ t.createElement("div", { className: A }, l), r && b && _ && !a && /* @__PURE__ */ t.createElement(
|
|
88
|
+
B,
|
|
88
89
|
{
|
|
89
|
-
expanderOpenFromStart:
|
|
90
|
+
expanderOpenFromStart: N,
|
|
90
91
|
content: r,
|
|
91
92
|
buttonText: b,
|
|
92
|
-
buttonClosedText:
|
|
93
|
+
buttonClosedText: _
|
|
93
94
|
}
|
|
94
95
|
));
|
|
95
|
-
},
|
|
96
|
+
}, T = c(
|
|
96
97
|
e["notification-panel"],
|
|
97
|
-
e[`notification-panel--${
|
|
98
|
+
e[`notification-panel--${p}`],
|
|
98
99
|
C && e[`notification-panel--${C}`],
|
|
99
100
|
{
|
|
100
|
-
[e["notification-
|
|
101
|
-
[e["notification-
|
|
102
|
-
[e["notification-
|
|
101
|
+
[e["notification-panel--compact"]]: !!a,
|
|
102
|
+
[e["notification-panel--compact--basic"]]: a === "basic",
|
|
103
|
+
[e["notification-panel--compact--outline"]]: a === "outline",
|
|
103
104
|
[e["notification-panel--with-content"]]: r || i && l,
|
|
104
|
-
[e["notification-panel--dismissable"]]:
|
|
105
|
+
[e["notification-panel--dismissable"]]: u
|
|
105
106
|
},
|
|
106
|
-
|
|
107
|
-
), v = g ||
|
|
108
|
-
return /* @__PURE__ */ t.createElement(
|
|
107
|
+
I
|
|
108
|
+
), v = g || p === "alert" && "alert" || void 0, k = v ? $({ label: i, id: d }) : void 0;
|
|
109
|
+
return /* @__PURE__ */ t.createElement(W, { fluid: S }, /* @__PURE__ */ t.createElement(
|
|
109
110
|
"div",
|
|
110
111
|
{
|
|
111
112
|
ref: m,
|
|
112
113
|
role: v,
|
|
113
|
-
"data-testid":
|
|
114
|
-
"data-analyticsid":
|
|
115
|
-
className:
|
|
116
|
-
...
|
|
114
|
+
"data-testid": w,
|
|
115
|
+
"data-analyticsid": L.NotificationPanel,
|
|
116
|
+
className: T,
|
|
117
|
+
...k
|
|
117
118
|
},
|
|
118
|
-
/* @__PURE__ */ t.createElement("span", { className: e["notification-panel__icon"] }, y[
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
/* @__PURE__ */ t.createElement("span", { className: e["notification-panel__icon"] }, y[p]),
|
|
120
|
+
u && /* @__PURE__ */ t.createElement("span", { className: e["notification-panel__close"] }, /* @__PURE__ */ t.createElement(V, { ariaLabel: s.ariaLabelCloseBtn, onClick: E, color: R("black") })),
|
|
121
|
+
z()
|
|
121
122
|
));
|
|
122
|
-
}),
|
|
123
|
+
}), re = j;
|
|
123
124
|
export {
|
|
124
|
-
|
|
125
|
+
re as default
|
|
125
126
|
};
|
|
126
127
|
//# sourceMappingURL=NotificationPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationPanel.js","sources":["../../../src/components/NotificationPanel/NotificationPanel.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { DetailButton } from './DetailButton/DetailButton';\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { palette } from '../../theme/palette';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport Close from '../Close';\nimport Icon from '../Icon';\nimport CheckFill from '../Icons/CheckFill';\nimport ErrorSignFill from '../Icons/ErrorSignFill';\nimport InfoSignFill from '../Icons/InfoSignFill';\nimport TriangleX from '../Icons/TriangleX';\n\nimport styles from './styles.module.scss';\n\nexport type NotificationPanelVariants = 'info' | 'warn' | 'alert' | 'success';\nexport type NotificationCompactVariants = 'basic' | 'outline';\nexport type NotificationPanelSizes = 'small' | 'medium' | 'large';\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 /** 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 fluid = false,\n size,\n className,\n labelId,\n role,\n testId,\n } = props;\n const uuid = useUuid(labelId);\n const variantToIconMap = {\n info: (\n <Icon\n svgIcon={InfoSignFill}\n color={palette.blueberry700}\n hoverColor={palette.blueberry700}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n />\n ),\n warn: (\n <Icon\n svgIcon={ErrorSignFill}\n color={palette.banana700}\n hoverColor={palette.banana700}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n />\n ),\n alert: (\n <Icon\n svgIcon={TriangleX}\n color={palette.cherry700}\n hoverColor={palette.cherry700}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n />\n ),\n success: (\n <Icon\n svgIcon={CheckFill}\n color={palette.kiwi900}\n hoverColor={palette.kiwi900}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n />\n ),\n };\n const renderContent = (): JSX.Element => {\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__compact--basic']]: compactVariant === 'basic',\n });\n const childrenClasses = classNames(styles['notification-panel__children'], {\n [styles['notification-panel__label-and-content--spacing']]: label,\n [styles['notification-panel__children--expander-no-label']]: expanderChildren && !label,\n });\n\n return (\n <div className={contentClasses} id={!label ? uuid : undefined}>\n {label && (\n <h1 className={labelClasses} id={uuid}>\n {label}\n </h1>\n )}\n {children && !compactVariant && <div className={childrenClasses}>{children}</div>}\n {expanderChildren && expanderButtonText && expanderButtonClosedText && !compactVariant && (\n <DetailButton\n expanderOpenFromStart={expanderOpenFromStart}\n content={expanderChildren}\n buttonText={expanderButtonText}\n buttonClosedText={expanderButtonClosedText}\n />\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 === 'alert' && '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 <span className={styles['notification-panel__icon']}>{variantToIconMap[variant]}</span>\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":["FluidWrapper","fluid","children","fluidClasses","classNames","styles","React","NotificationPanel","props","ref","variant","dismissable","onClick","expanderChildren","expanderButtonText","expanderButtonClosedText","expanderOpenFromStart","compactVariant","label","size","className","labelId","role","testId","uuid","useUuid","variantToIconMap","Icon","InfoSignFill","palette","IconSize","ErrorSignFill","TriangleX","CheckFill","renderContent","contentClasses","labelClasses","childrenClasses","DetailButton","notificationPanelClasses","ariaRole","ariaLabelAttributes","getAriaLabelAttributes","AnalyticsId","Close","getColor","NotificationPanel$1"],"mappings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A,IAC3BA,EAAO,uBAAuBK,CAAO,EAAE;AAAA,IACvCS,KAAQd,EAAO,uBAAuBc,CAAI,EAAE;AAAA,IAC5C;AAAA,MACE,CAACd,EAAO,6BAA6B,CAAC,GAAG,CAAC,CAACY;AAAA,MAC3C,CAACZ,EAAO,oCAAoC,CAAC,GAAGY,MAAmB;AAAA,MACnE,CAACZ,EAAO,sCAAsC,CAAC,GAAGY,MAAmB;AAAA,MACrE,CAACZ,EAAO,kCAAkC,CAAC,GAAGQ,KAAqBK,KAAShB;AAAA,MAC5E,CAACG,EAAO,iCAAiC,CAAC,GAAGM;AAAA,IAC/C;AAAA,IACAS;AAAA,EAAA,GAGIoB,IAAWlB,KAASZ,MAAY,WAAW,WAAY,QACvD+B,IAAsBD,IAAWE,EAAuB,EAAE,OAAAxB,GAAO,IAAIM,EAAA,CAAM,IAAI;AAGnF,SAAAlB,gBAAAA,EAAA,cAACN,KAAa,OAAAC,EACZ,GAAAK,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAG;AAAA,MACA,MAAM+B;AAAA,MACN,eAAajB;AAAA,MACb,oBAAkBoB,EAAY;AAAA,MAC9B,WAAWJ;AAAA,MACV,GAAGE;AAAA,IAAA;AAAA,IAEJnC,gBAAAA,EAAA,cAAC,UAAK,WAAWD,EAAO,0BAA0B,EAAI,GAAAqB,EAAiBhB,CAAO,CAAE;AAAA,IAC/EC,KACEL,gBAAAA,EAAA,cAAA,QAAA,EAAK,WAAWD,EAAO,2BAA2B,EACjD,GAAAC,gBAAAA,EAAA,cAACsC,GAAM,EAAA,WAAWpC,EAAM,mBAAmB,SAAAI,GAAkB,OAAOiC,EAAS,OAAO,GAAG,CACzF;AAAA,IAEDX,EAAc;AAAA,EAAA,CAEnB;AAEJ,CAAC,GAEDY,KAAevC;"}
|
|
1
|
+
{"version":3,"file":"NotificationPanel.js","sources":["../../../src/components/NotificationPanel/NotificationPanel.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { DetailButton } from './DetailButton/DetailButton';\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { palette } from '../../theme/palette';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport Close from '../Close';\nimport Icon from '../Icon';\nimport CheckFill from '../Icons/CheckFill';\nimport ErrorSignFill from '../Icons/ErrorSignFill';\nimport InfoSignFill from '../Icons/InfoSignFill';\nimport TriangleX from '../Icons/TriangleX';\n\nimport styles from './styles.module.scss';\n\nexport type NotificationPanelVariants = 'info' | 'warn' | 'alert' | 'success';\nexport type NotificationCompactVariants = 'basic' | 'outline';\nexport type NotificationPanelSizes = 'small' | 'medium' | 'large';\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 /** 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 fluid = false,\n size,\n className,\n labelId,\n role,\n testId,\n } = props;\n const uuid = useUuid(labelId);\n const variantToIconMap = {\n info: (\n <Icon\n svgIcon={InfoSignFill}\n color={palette.blueberry700}\n hoverColor={palette.blueberry700}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n />\n ),\n warn: (\n <Icon\n svgIcon={ErrorSignFill}\n color={palette.banana700}\n hoverColor={palette.banana700}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n />\n ),\n alert: (\n <Icon\n svgIcon={TriangleX}\n color={palette.cherry700}\n hoverColor={palette.cherry700}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n />\n ),\n success: (\n <Icon\n svgIcon={CheckFill}\n color={palette.kiwi900}\n hoverColor={palette.kiwi900}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n />\n ),\n };\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\n return (\n <div className={contentClasses} id={!label ? uuid : undefined}>\n {label && (\n <h1 className={labelClasses} id={uuid}>\n {label}\n </h1>\n )}\n {children && <div className={childrenClasses}>{children}</div>}\n {expanderChildren && expanderButtonText && expanderButtonClosedText && !compactVariant && (\n <DetailButton\n expanderOpenFromStart={expanderOpenFromStart}\n content={expanderChildren}\n buttonText={expanderButtonText}\n buttonClosedText={expanderButtonClosedText}\n />\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 === 'alert' && '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 <span className={styles['notification-panel__icon']}>{variantToIconMap[variant]}</span>\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":["FluidWrapper","fluid","children","fluidClasses","classNames","styles","React","NotificationPanel","props","ref","variant","dismissable","onClick","expanderChildren","expanderButtonText","expanderButtonClosedText","expanderOpenFromStart","compactVariant","label","size","className","labelId","role","testId","uuid","useUuid","variantToIconMap","Icon","InfoSignFill","palette","IconSize","ErrorSignFill","TriangleX","CheckFill","renderContent","outlineVariant","contentClasses","labelClasses","childrenClasses","DetailButton","notificationPanelClasses","ariaRole","ariaLabelAttributes","getAriaLabelAttributes","AnalyticsId","Close","getColor","NotificationPanel$1"],"mappings":";;;;;;;;;;;;;;;AAgEA,MAAMA,IAAyC,CAAC,EAAE,OAAAC,GAAO,UAAAC,QAAe;AACtE,MAAID,GAAO;AACT,UAAME,IAAeC,EAAWC,EAAO,eAAe,CAAC;AAEvD,WAAQC,gBAAAA,EAAA,cAAA,OAAA,EAAI,WAAWH,EAAA,GAAeD,CAAS;AAAA,EACjD;AACO,SAAAA;AACT,GAEMK,IAAoBD,EAAM,WAAmD,CAACE,GAAOC,MAAQ;AAC3F,QAAA;AAAA,IACJ,UAAAP;AAAA,IACA,SAAAQ,IAAU;AAAA,IACV,aAAAC,IAAc;AAAA,IACd,SAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,uBAAAC,IAAwB;AAAA,IACxB,gBAAAC;AAAA,IACA,OAAAC;AAAA,IACA,OAAAjB,IAAQ;AAAA,IACR,MAAAkB;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,MAAAC;AAAA,IACA,QAAAC;AAAA,EACE,IAAAf,GACEgB,IAAOC,EAAQJ,CAAO,GACtBK,IAAmB;AAAA,IACvB,MACEpB,gBAAAA,EAAA;AAAA,MAACqB;AAAA,MAAA;AAAA,QACC,SAASC;AAAA,QACT,OAAOC,EAAQ;AAAA,QACf,YAAYA,EAAQ;AAAA,QACpB,MAAMZ,IAAiBa,EAAS,SAASA,EAAS;AAAA,MAAA;AAAA,IACpD;AAAA,IAEF,MACExB,gBAAAA,EAAA;AAAA,MAACqB;AAAA,MAAA;AAAA,QACC,SAASI;AAAA,QACT,OAAOF,EAAQ;AAAA,QACf,YAAYA,EAAQ;AAAA,QACpB,MAAMZ,IAAiBa,EAAS,SAASA,EAAS;AAAA,MAAA;AAAA,IACpD;AAAA,IAEF,OACExB,gBAAAA,EAAA;AAAA,MAACqB;AAAA,MAAA;AAAA,QACC,SAASK;AAAA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,CAEnB;AAEJ,CAAC,GAEDa,KAAexC;"}
|
|
@@ -21,9 +21,8 @@
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
&--compact {
|
|
25
25
|
width: fit-content;
|
|
26
|
-
font-weight: 600;
|
|
27
26
|
font-size: $font-size-xs;
|
|
28
27
|
line-height: 1.25rem;
|
|
29
28
|
box-shadow: none;
|
|
@@ -33,10 +32,6 @@
|
|
|
33
32
|
padding-right: getSpacer(s);
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
&--basic {
|
|
37
|
-
font-weight: 400;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
35
|
&--outline {
|
|
41
36
|
border: none;
|
|
42
37
|
}
|
|
@@ -66,12 +61,12 @@
|
|
|
66
61
|
background-color: $blueberry50;
|
|
67
62
|
}
|
|
68
63
|
|
|
69
|
-
&--info
|
|
64
|
+
&--info#{&}--compact {
|
|
70
65
|
box-shadow: none;
|
|
71
66
|
background-color: transparent;
|
|
72
67
|
}
|
|
73
68
|
|
|
74
|
-
&--info
|
|
69
|
+
&--info#{&}--compact--basic {
|
|
75
70
|
border: none;
|
|
76
71
|
}
|
|
77
72
|
|
|
@@ -80,12 +75,12 @@
|
|
|
80
75
|
background-color: $banana50;
|
|
81
76
|
}
|
|
82
77
|
|
|
83
|
-
&--warn
|
|
78
|
+
&--warn#{&}--compact {
|
|
84
79
|
box-shadow: none;
|
|
85
80
|
background-color: transparent;
|
|
86
81
|
}
|
|
87
82
|
|
|
88
|
-
&--warn
|
|
83
|
+
&--warn#{&}--compact--basic {
|
|
89
84
|
border: none;
|
|
90
85
|
}
|
|
91
86
|
|
|
@@ -94,12 +89,12 @@
|
|
|
94
89
|
background-color: $cherry50;
|
|
95
90
|
}
|
|
96
91
|
|
|
97
|
-
&--alert
|
|
92
|
+
&--alert#{&}--compact {
|
|
98
93
|
box-shadow: none;
|
|
99
94
|
background-color: transparent;
|
|
100
95
|
}
|
|
101
96
|
|
|
102
|
-
&--alert
|
|
97
|
+
&--alert#{&}--compact--basic {
|
|
103
98
|
border: none;
|
|
104
99
|
}
|
|
105
100
|
|
|
@@ -108,12 +103,12 @@
|
|
|
108
103
|
background-color: $kiwi50;
|
|
109
104
|
}
|
|
110
105
|
|
|
111
|
-
&--success
|
|
106
|
+
&--success#{&}--compact {
|
|
112
107
|
box-shadow: none;
|
|
113
108
|
background-color: transparent;
|
|
114
109
|
}
|
|
115
110
|
|
|
116
|
-
&--success
|
|
111
|
+
&--success#{&}--compact--basic {
|
|
117
112
|
border: none;
|
|
118
113
|
}
|
|
119
114
|
|
|
@@ -132,10 +127,6 @@
|
|
|
132
127
|
}
|
|
133
128
|
}
|
|
134
129
|
|
|
135
|
-
&__children.notification-panel__label-and-content--spacing {
|
|
136
|
-
font-weight: 500;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
130
|
&__label,
|
|
140
131
|
&__children {
|
|
141
132
|
font-size: $font-size-xs;
|
|
@@ -152,26 +143,33 @@
|
|
|
152
143
|
font-weight: 700;
|
|
153
144
|
margin: getSpacer(2xs) 0 0 0;
|
|
154
145
|
|
|
155
|
-
|
|
156
|
-
font-weight: 600;
|
|
146
|
+
&--compact {
|
|
157
147
|
font-size: $font-size-xs;
|
|
158
148
|
line-height: 1.25rem;
|
|
159
149
|
}
|
|
160
150
|
|
|
161
|
-
|
|
162
|
-
|
|
151
|
+
&--no-content {
|
|
152
|
+
margin: 0;
|
|
163
153
|
}
|
|
164
|
-
}
|
|
165
154
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
155
|
+
&--compact,
|
|
156
|
+
&--no-content {
|
|
157
|
+
font-weight: 600;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&--outline {
|
|
161
|
+
font-weight: 500;
|
|
162
|
+
}
|
|
169
163
|
}
|
|
170
164
|
|
|
171
165
|
&__children {
|
|
172
166
|
font-weight: 600;
|
|
173
167
|
padding: getSpacer(3xs) 0;
|
|
174
168
|
|
|
169
|
+
&--with-label {
|
|
170
|
+
font-weight: 500;
|
|
171
|
+
}
|
|
172
|
+
|
|
175
173
|
&--expander-no-label {
|
|
176
174
|
margin: getSpacer(2xs) 0 0 0;
|
|
177
175
|
|
|
@@ -179,6 +177,10 @@
|
|
|
179
177
|
padding-top: 0;
|
|
180
178
|
}
|
|
181
179
|
}
|
|
180
|
+
|
|
181
|
+
&--outline {
|
|
182
|
+
font-weight: 500;
|
|
183
|
+
}
|
|
182
184
|
}
|
|
183
185
|
|
|
184
186
|
&__icon {
|
|
@@ -6,18 +6,19 @@ export type Styles = {
|
|
|
6
6
|
'notification-panel': string;
|
|
7
7
|
'notification-panel__children': string;
|
|
8
8
|
'notification-panel__children--expander-no-label': string;
|
|
9
|
+
'notification-panel__children--outline': string;
|
|
10
|
+
'notification-panel__children--with-label': string;
|
|
9
11
|
'notification-panel__close': string;
|
|
10
|
-
'notification-panel__compact': string;
|
|
11
|
-
'notification-panel__compact--basic': string;
|
|
12
|
-
'notification-panel__compact--outline': string;
|
|
13
12
|
'notification-panel__content': string;
|
|
14
13
|
'notification-panel__icon': string;
|
|
15
14
|
'notification-panel__label': string;
|
|
16
|
-
'notification-
|
|
17
|
-
'notification-panel__label__compact--basic': string;
|
|
15
|
+
'notification-panel__label--compact': string;
|
|
18
16
|
'notification-panel__label--no-content': string;
|
|
19
|
-
'notification-panel__label
|
|
17
|
+
'notification-panel__label--outline': string;
|
|
20
18
|
'notification-panel--alert': string;
|
|
19
|
+
'notification-panel--compact': string;
|
|
20
|
+
'notification-panel--compact--basic': string;
|
|
21
|
+
'notification-panel--compact--outline': string;
|
|
21
22
|
'notification-panel--dismissable': string;
|
|
22
23
|
'notification-panel--info': string;
|
|
23
24
|
'notification-panel--large': string;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { SvgIcon } from '../Icon';
|
|
3
|
+
import { IconName } from '../Icons/IconNames';
|
|
2
4
|
import { LinkListProps } from '../LinkList';
|
|
3
5
|
export declare enum PopMenuVariant {
|
|
4
6
|
onWhite = "on-white",
|
|
5
7
|
onGray = "on-gray",
|
|
6
8
|
onBlueberry = "on-blueberry"
|
|
7
9
|
}
|
|
10
|
+
export declare enum PopMenuLabelPosition {
|
|
11
|
+
right = "right",
|
|
12
|
+
left = "left"
|
|
13
|
+
}
|
|
8
14
|
export interface PopMenuProps {
|
|
9
15
|
/** Content shown inside PopOver. Can only be a LinkList */
|
|
10
16
|
children: React.ReactElement<LinkListProps>;
|
|
@@ -24,6 +30,12 @@ export interface PopMenuProps {
|
|
|
24
30
|
openButtonAriaLabel?: string;
|
|
25
31
|
/** Sets the arial-label attribute for the closeButton. */
|
|
26
32
|
closeButtonAriaLabel?: string;
|
|
33
|
+
/** Sets the icon on the trigger button. */
|
|
34
|
+
svgIcon?: SvgIcon | IconName;
|
|
35
|
+
/** Optional text next to the trigger button. */
|
|
36
|
+
labelText?: string;
|
|
37
|
+
/** Placement of the label text relative to the trigger button. */
|
|
38
|
+
labelTextPosition?: PopMenuLabelPosition;
|
|
27
39
|
}
|
|
28
40
|
export declare const PopMenu: React.FC<PopMenuProps>;
|
|
29
41
|
export default PopMenu;
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { IconSize as
|
|
4
|
-
import { useBreakpoint as
|
|
5
|
-
import { useHover as
|
|
6
|
-
import { useOutsideEvent as
|
|
7
|
-
import { getColor as
|
|
8
|
-
import { breakpoints as
|
|
9
|
-
import { isComponent as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import e, { useRef as p, useState as G } from "react";
|
|
2
|
+
import u from "classnames";
|
|
3
|
+
import { IconSize as m, AnalyticsId as W } from "../../constants.js";
|
|
4
|
+
import { useBreakpoint as j } from "../../hooks/useBreakpoint.js";
|
|
5
|
+
import { useHover as q } from "../../hooks/useHover.js";
|
|
6
|
+
import { useOutsideEvent as F } from "../../hooks/useOutsideEvent.js";
|
|
7
|
+
import { getColor as E } from "../../theme/currys/color.js";
|
|
8
|
+
import { breakpoints as J } from "../../theme/grid.js";
|
|
9
|
+
import { isComponent as y } from "../../utils/component.js";
|
|
10
|
+
import { Icon as f } from "../Icon/Icon.js";
|
|
11
|
+
import K from "../Icons/VerticalDots.js";
|
|
12
|
+
import Q from "../Icons/X.js";
|
|
13
|
+
import U from "../LazyIcon/LazyIcon.js";
|
|
14
|
+
import h from "../LinkList/LinkList.js";
|
|
15
|
+
import V from "../PopOver/PopOver.js";
|
|
16
|
+
import l from "../PopMenu/styles.module.scss";
|
|
17
|
+
var Y = /* @__PURE__ */ ((o) => (o.onWhite = "on-white", o.onGray = "on-gray", o.onBlueberry = "on-blueberry", o))(Y || {}), Z = /* @__PURE__ */ ((o) => (o.right = "right", o.left = "left", o))(Z || {});
|
|
18
|
+
const ee = (o) => {
|
|
19
|
+
const d = p(null), v = p(null), B = p(null), b = p(null), [r, c] = G(!1), {
|
|
20
|
+
children: g,
|
|
21
|
+
popOverClassName: O,
|
|
21
22
|
popMenuClassName: N,
|
|
22
|
-
openButtonTestId:
|
|
23
|
-
closeButtonTestId:
|
|
24
|
-
popOverTestId:
|
|
25
|
-
popMenuVariant:
|
|
26
|
-
openButtonAriaLabel:
|
|
27
|
-
closeButtonAriaLabel:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
l
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
openButtonTestId: z,
|
|
24
|
+
closeButtonTestId: H,
|
|
25
|
+
popOverTestId: R,
|
|
26
|
+
popMenuVariant: C = "on-white",
|
|
27
|
+
openButtonAriaLabel: S,
|
|
28
|
+
closeButtonAriaLabel: _,
|
|
29
|
+
svgIcon: n,
|
|
30
|
+
labelText: a,
|
|
31
|
+
labelTextPosition: I = "right"
|
|
32
|
+
/* right */
|
|
33
|
+
} = o, L = u(l["pop-menu-button"], {
|
|
34
|
+
[l[`pop-menu-button--${C}`]]: C
|
|
35
|
+
}), T = j() < J.md;
|
|
36
|
+
F(b, () => {
|
|
37
|
+
c(!1);
|
|
38
|
+
});
|
|
39
|
+
const { isHovered: i } = q(d), k = T ? m.XSmall : m.Small, w = (t) => {
|
|
40
|
+
c(!1), t && t();
|
|
41
|
+
}, x = () => {
|
|
42
|
+
if (y(g, h))
|
|
43
|
+
return /* @__PURE__ */ e.createElement(
|
|
44
|
+
V,
|
|
38
45
|
{
|
|
39
|
-
testId:
|
|
40
|
-
className:
|
|
41
|
-
arrowClassName:
|
|
42
|
-
controllerRef:
|
|
43
|
-
popOverRef:
|
|
46
|
+
testId: R,
|
|
47
|
+
className: u(l["pop-menu__pop-over"], O),
|
|
48
|
+
arrowClassName: l["pop-menu__pop-over-arrow"],
|
|
49
|
+
controllerRef: v,
|
|
50
|
+
popOverRef: B
|
|
44
51
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
(
|
|
48
|
-
children:
|
|
49
|
-
|
|
50
|
-
(
|
|
51
|
-
onClick: (
|
|
52
|
-
}) :
|
|
52
|
+
e.Children.map(
|
|
53
|
+
g,
|
|
54
|
+
(t) => e.cloneElement(t, {
|
|
55
|
+
children: e.Children.map(
|
|
56
|
+
t.props.children,
|
|
57
|
+
(s) => y(s, h.Link) ? e.cloneElement(s, {
|
|
58
|
+
onClick: (D) => w(() => s.props.onClick && s.props.onClick(D))
|
|
59
|
+
}) : s
|
|
53
60
|
)
|
|
54
61
|
})
|
|
55
62
|
)
|
|
56
63
|
);
|
|
57
|
-
},
|
|
58
|
-
t && t.stopPropagation(),
|
|
59
|
-
},
|
|
64
|
+
}, X = (t) => {
|
|
65
|
+
t && t.stopPropagation(), c(!r);
|
|
66
|
+
}, A = n && typeof n == "string" ? /* @__PURE__ */ e.createElement(U, { iconName: n, size: m.XSmall, isHovered: i }) : n && /* @__PURE__ */ e.createElement(f, { svgIcon: n, size: m.XSmall, isHovered: i }), M = n ? A : /* @__PURE__ */ e.createElement(f, { svgIcon: n ?? K, color: E("black"), size: k, isHovered: i }), P = /* @__PURE__ */ e.createElement(f, { svgIcon: Q, color: E("black"), size: k, isHovered: i }), $ = /* @__PURE__ */ e.createElement(
|
|
60
67
|
"button",
|
|
61
68
|
{
|
|
62
|
-
ref:
|
|
63
|
-
"data-testid":
|
|
64
|
-
className:
|
|
65
|
-
"aria-label":
|
|
66
|
-
|
|
69
|
+
ref: d,
|
|
70
|
+
"data-testid": r ? H : z,
|
|
71
|
+
className: L,
|
|
72
|
+
"aria-label": r ? _ : S,
|
|
73
|
+
"aria-expanded": r,
|
|
74
|
+
onClick: X,
|
|
67
75
|
type: "button"
|
|
68
76
|
},
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
ariaLabel: L,
|
|
74
|
-
color: "black",
|
|
75
|
-
className: d,
|
|
76
|
-
testId: E,
|
|
77
|
-
ref: m,
|
|
78
|
-
onClick: (e) => C(!1, e),
|
|
79
|
-
small: b
|
|
80
|
-
}
|
|
77
|
+
a && I == "left" && /* @__PURE__ */ e.createElement("span", null, a),
|
|
78
|
+
/* @__PURE__ */ e.createElement("div", { ref: v }, r ? P : M),
|
|
79
|
+
a && I == "right" && /* @__PURE__ */ e.createElement("span", null, a)
|
|
81
80
|
);
|
|
82
|
-
return /* @__PURE__ */
|
|
83
|
-
},
|
|
81
|
+
return /* @__PURE__ */ e.createElement("div", { ref: b, className: u(l["pop-menu-button"], N), "data-analyticsid": W.PopMenu }, $, r && x());
|
|
82
|
+
}, Ce = ee;
|
|
84
83
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
ee as PopMenu,
|
|
85
|
+
Z as PopMenuLabelPosition,
|
|
86
|
+
Y as PopMenuVariant,
|
|
87
|
+
Ce as default
|
|
88
88
|
};
|
|
89
89
|
//# sourceMappingURL=PopMenu.js.map
|