@helsenorge/designsystem-react 7.6.0 → 7.7.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 +17 -0
- package/components/Badge/Badge.d.ts +7 -1
- package/components/Badge/Badge.js +19 -9
- package/components/Badge/Badge.js.map +1 -1
- package/components/Badge/Badge.stories.d.ts +11 -0
- package/components/Badge/NotificationBadge.d.ts +17 -0
- package/components/Badge/NotificationBadge.js +68 -0
- package/components/Badge/NotificationBadge.js.map +1 -0
- package/components/Expander/styles.module.scss +3 -2
- package/components/LinkList/LinkList.stories.d.ts +1 -0
- package/components/ListHeader/ListHeader.d.ts +1 -1
- package/components/ListHeader/ListHeader.js +32 -28
- package/components/ListHeader/ListHeader.js.map +1 -1
- package/components/NotificationPanel/NotificationPanel.d.ts +1 -1
- package/components/NotificationPanel/NotificationPanel.js +69 -103
- package/components/NotificationPanel/NotificationPanel.js.map +1 -1
- package/components/NotificationPanel/NotificationPanel.stories.d.ts +1 -1
- package/components/NotificationPanel/styles.module.scss +14 -0
- package/components/NotificationPanel/styles.module.scss.d.ts +1 -0
- package/components/ServiceMessage/ServiceMessage.js +66 -75
- package/components/ServiceMessage/ServiceMessage.js.map +1 -1
- package/components/ServiceMessage/ServiceMessage.stories.d.ts +1 -1
- package/components/ServiceMessage/styles.module.scss +13 -0
- package/components/ServiceMessage/styles.module.scss.d.ts +1 -0
- package/package.json +1 -1
- package/components/NotificationPanel/DetailButton/DetailButton.d.ts +0 -9
- package/components/NotificationPanel/DetailButton/DetailButton.js +0 -28
- package/components/NotificationPanel/DetailButton/DetailButton.js.map +0 -1
- package/components/NotificationPanel/DetailButton/styles.module.scss +0 -38
- package/components/NotificationPanel/DetailButton/styles.module.scss.d.ts +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [7.6.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.5.0&targetVersion=GTv7.6.0) (2024-05-15)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- **notificationpanel:** legg til prop for å sette html tag for label
|
|
6
|
+
([ebd331a](https://github.com/helsenorge/designsystem/commit/ebd331a75f04099c4ad7e552ff70df8751675734)), closes
|
|
7
|
+
[#324952](https://github.com/helsenorge/designsystem/issues/324952)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- skjemaelementer med error styling overlapper utifra dom rekkefølge
|
|
12
|
+
([b07b7d6](https://github.com/helsenorge/designsystem/commit/b07b7d69391b3e4296e8a8cde8b8d312f835cb03)), closes
|
|
13
|
+
[#324846](https://github.com/helsenorge/designsystem/issues/324846)
|
|
14
|
+
- **expanderlist:** fiks så variant fill ikke mister margin top ved åpning av expander
|
|
15
|
+
([d277c97](https://github.com/helsenorge/designsystem/commit/d277c97660aa8334a44b1183445f55f2037b2263)), closes
|
|
16
|
+
[#324823](https://github.com/helsenorge/designsystem/issues/324823)
|
|
17
|
+
|
|
1
18
|
## [7.5.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.4.0&targetVersion=GTv7.5.0) (2024-05-08)
|
|
2
19
|
|
|
3
20
|
### Features
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { BadgeNotificationVariant } from './NotificationBadge';
|
|
2
3
|
import { PaletteNames } from '../../theme/palette';
|
|
3
4
|
export type BadgeColors = Extract<PaletteNames, 'blueberry' | 'cherry' | 'neutral'>;
|
|
4
5
|
export type BadgeChildren = string | number;
|
|
6
|
+
export type BadgeVariant = 'string' | 'notification';
|
|
5
7
|
export interface BadgeProps {
|
|
6
8
|
/** Sets the content of the badge. */
|
|
7
|
-
children
|
|
9
|
+
children?: BadgeChildren;
|
|
8
10
|
/** Adds custom classes to the element. */
|
|
9
11
|
className?: string;
|
|
10
12
|
/** Changes the badge background color. */
|
|
11
13
|
color?: BadgeColors;
|
|
12
14
|
/** Sets the data-testid attribute. */
|
|
13
15
|
testId?: string;
|
|
16
|
+
/** Changes the type of the badge. Default: string */
|
|
17
|
+
type?: BadgeVariant;
|
|
18
|
+
/** Type of notification badge. Only works if type is 'notification'. */
|
|
19
|
+
notificationVariant?: BadgeNotificationVariant;
|
|
14
20
|
}
|
|
15
21
|
export type BadgeType = React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLElement>>;
|
|
16
22
|
declare const Badge: BadgeType;
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import t from "react";
|
|
2
|
+
import m from "classnames";
|
|
3
|
+
import g from "./NotificationBadge.js";
|
|
4
|
+
import { IconSize as b, AnalyticsId as d } from "../../constants.js";
|
|
4
5
|
import e from "../Badge/styles.module.scss";
|
|
5
|
-
const
|
|
6
|
-
const { children:
|
|
6
|
+
const u = t.forwardRef(function(n, s) {
|
|
7
|
+
const { children: c, className: r = "", color: a = "blueberry", testId: i, type: l = "string", notificationVariant: o = "info" } = n, f = m(
|
|
7
8
|
e.badge,
|
|
8
9
|
{
|
|
9
10
|
[e["badge--blueberry"]]: a === "blueberry",
|
|
10
11
|
[e["badge--cherry"]]: a === "cherry",
|
|
11
12
|
[e["badge--neutral"]]: a === "neutral"
|
|
12
13
|
},
|
|
13
|
-
|
|
14
|
+
r
|
|
14
15
|
);
|
|
15
|
-
return
|
|
16
|
-
|
|
16
|
+
return l === "notification" && o !== void 0 ? /* @__PURE__ */ t.createElement(
|
|
17
|
+
g,
|
|
18
|
+
{
|
|
19
|
+
variant: o,
|
|
20
|
+
size: b.XSmall,
|
|
21
|
+
className: r,
|
|
22
|
+
testId: i,
|
|
23
|
+
"data-analyticsid": d.Badge
|
|
24
|
+
}
|
|
25
|
+
) : /* @__PURE__ */ t.createElement("span", { className: f, ref: s, "data-testid": i, "data-analyticsid": d.Badge }, c);
|
|
26
|
+
}), R = u;
|
|
17
27
|
export {
|
|
18
|
-
|
|
28
|
+
R as default
|
|
19
29
|
};
|
|
20
30
|
//# sourceMappingURL=Badge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sources":["../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { PaletteNames } from '../../theme/palette';\n\nimport badgeStyles from './styles.module.scss';\n\nexport type BadgeColors = Extract<PaletteNames, 'blueberry' | 'cherry' | 'neutral'>;\nexport type BadgeChildren = string | number;\n\nexport interface BadgeProps {\n /** Sets the content of the badge. */\n children
|
|
1
|
+
{"version":3,"file":"Badge.js","sources":["../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport NotificationBadge, { BadgeNotificationVariant } from './NotificationBadge';\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { PaletteNames } from '../../theme/palette';\n\nimport badgeStyles from './styles.module.scss';\n\nexport type BadgeColors = Extract<PaletteNames, 'blueberry' | 'cherry' | 'neutral'>;\nexport type BadgeChildren = string | number;\nexport type BadgeVariant = 'string' | 'notification';\n\nexport interface BadgeProps {\n /** Sets the content of the badge. */\n children?: BadgeChildren;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the badge background color. */\n color?: BadgeColors;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Changes the type of the badge. Default: string */\n type?: BadgeVariant;\n /** Type of notification badge. Only works if type is 'notification'. */\n notificationVariant?: BadgeNotificationVariant;\n}\n\nexport type BadgeType = React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLElement>>;\nconst Badge: BadgeType = React.forwardRef(function BadgeForwardedRef(props: BadgeProps, ref: React.ForwardedRef<HTMLElement>) {\n const { children, className = '', color = 'blueberry', testId, type = 'string', notificationVariant = 'info' } = props;\n const badgeClasses = classNames(\n badgeStyles.badge,\n {\n [badgeStyles['badge--blueberry']]: color === 'blueberry',\n [badgeStyles['badge--cherry']]: color === 'cherry',\n [badgeStyles['badge--neutral']]: color === 'neutral',\n },\n className\n );\n\n if (type === 'notification' && notificationVariant !== undefined) {\n return (\n <NotificationBadge\n variant={notificationVariant}\n size={IconSize.XSmall}\n className={className}\n testId={testId}\n data-analyticsid={AnalyticsId.Badge}\n />\n );\n }\n\n return (\n <span className={badgeClasses} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.Badge}>\n {children}\n </span>\n );\n});\n\nexport default Badge;\n"],"names":["Badge","React","props","ref","children","className","color","testId","type","notificationVariant","badgeClasses","classNames","badgeStyles","NotificationBadge","IconSize","AnalyticsId","Badge$1"],"mappings":";;;;;AA8BA,MAAMA,IAAmBC,EAAM,WAAW,SAA2BC,GAAmBC,GAAsC;AACtH,QAAA,EAAE,UAAAC,GAAU,WAAAC,IAAY,IAAI,OAAAC,IAAQ,aAAa,QAAAC,GAAQ,MAAAC,IAAO,UAAU,qBAAAC,IAAsB,OAAA,IAAWP,GAC3GQ,IAAeC;AAAA,IACnBC,EAAY;AAAA,IACZ;AAAA,MACE,CAACA,EAAY,kBAAkB,CAAC,GAAGN,MAAU;AAAA,MAC7C,CAACM,EAAY,eAAe,CAAC,GAAGN,MAAU;AAAA,MAC1C,CAACM,EAAY,gBAAgB,CAAC,GAAGN,MAAU;AAAA,IAC7C;AAAA,IACAD;AAAA,EAAA;AAGE,SAAAG,MAAS,kBAAkBC,MAAwB,SAEnDR,gBAAAA,EAAA;AAAA,IAACY;AAAA,IAAA;AAAA,MACC,SAASJ;AAAA,MACT,MAAMK,EAAS;AAAA,MACf,WAAAT;AAAA,MACA,QAAAE;AAAA,MACA,oBAAkBQ,EAAY;AAAA,IAAA;AAAA,EAAA,IAMlCd,gBAAAA,EAAA,cAAC,QAAK,EAAA,WAAWS,GAAc,KAAAP,GAAU,eAAaI,GAAQ,oBAAkBQ,EAAY,MAAA,GACzFX,CACH;AAEJ,CAAC,GAEDY,IAAehB;"}
|
|
@@ -14,6 +14,8 @@ declare const meta: {
|
|
|
14
14
|
args: {
|
|
15
15
|
children: string;
|
|
16
16
|
color: "blueberry";
|
|
17
|
+
type: "string";
|
|
18
|
+
notificationVariant: "info";
|
|
17
19
|
};
|
|
18
20
|
argTypes: {
|
|
19
21
|
children: {
|
|
@@ -23,9 +25,18 @@ declare const meta: {
|
|
|
23
25
|
control: string;
|
|
24
26
|
options: string[];
|
|
25
27
|
};
|
|
28
|
+
type: {
|
|
29
|
+
control: string;
|
|
30
|
+
options: string[];
|
|
31
|
+
};
|
|
32
|
+
notificationVariant: {
|
|
33
|
+
control: string;
|
|
34
|
+
options: string[];
|
|
35
|
+
};
|
|
26
36
|
};
|
|
27
37
|
};
|
|
28
38
|
export default meta;
|
|
29
39
|
type Story = StoryObj<typeof meta>;
|
|
30
40
|
export declare const Default: Story;
|
|
31
41
|
export declare const Variants: Story;
|
|
42
|
+
export declare const Notification: Story;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconSize } from '../../constants';
|
|
3
|
+
export type BadgeNotificationVariant = 'info' | 'warn' | 'error' | 'success';
|
|
4
|
+
export interface NotificationBadgeProps {
|
|
5
|
+
/** Changes the type of the badge */
|
|
6
|
+
variant: BadgeNotificationVariant;
|
|
7
|
+
/** Sets the size of the badge */
|
|
8
|
+
size: IconSize;
|
|
9
|
+
/** Adds custom classes to the element */
|
|
10
|
+
className?: string;
|
|
11
|
+
/** Sets the data-testid attribute. */
|
|
12
|
+
testId?: string;
|
|
13
|
+
/** Sets hover state */
|
|
14
|
+
isHovered?: boolean;
|
|
15
|
+
}
|
|
16
|
+
declare const NotificationBadge: (props: NotificationBadgeProps) => React.JSX.Element;
|
|
17
|
+
export default NotificationBadge;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import c from "react";
|
|
2
|
+
import { palette as r } from "../../theme/palette.js";
|
|
3
|
+
import { Icon as n } from "../Icon/Icon.js";
|
|
4
|
+
import s from "../Icons/CheckFill.js";
|
|
5
|
+
import m from "../Icons/ErrorSignFill.js";
|
|
6
|
+
import f from "../Icons/InfoSignFill.js";
|
|
7
|
+
import v from "../Icons/TriangleX.js";
|
|
8
|
+
const g = (i) => {
|
|
9
|
+
const { variant: l, size: e, className: o = "", testId: t, isHovered: a = !1 } = i;
|
|
10
|
+
switch (l) {
|
|
11
|
+
case "info":
|
|
12
|
+
return /* @__PURE__ */ c.createElement(
|
|
13
|
+
n,
|
|
14
|
+
{
|
|
15
|
+
svgIcon: f,
|
|
16
|
+
color: r.blueberry700,
|
|
17
|
+
hoverColor: r.blueberry700,
|
|
18
|
+
size: e,
|
|
19
|
+
className: o,
|
|
20
|
+
testId: t,
|
|
21
|
+
isHovered: a
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
case "warn":
|
|
25
|
+
return /* @__PURE__ */ c.createElement(
|
|
26
|
+
n,
|
|
27
|
+
{
|
|
28
|
+
svgIcon: m,
|
|
29
|
+
color: r.banana700,
|
|
30
|
+
hoverColor: r.banana700,
|
|
31
|
+
size: e,
|
|
32
|
+
className: o,
|
|
33
|
+
testId: t,
|
|
34
|
+
isHovered: a
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
case "error":
|
|
38
|
+
return /* @__PURE__ */ c.createElement(
|
|
39
|
+
n,
|
|
40
|
+
{
|
|
41
|
+
svgIcon: v,
|
|
42
|
+
color: r.cherry700,
|
|
43
|
+
hoverColor: r.cherry700,
|
|
44
|
+
size: e,
|
|
45
|
+
className: o,
|
|
46
|
+
testId: t,
|
|
47
|
+
isHovered: a
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
case "success":
|
|
51
|
+
return /* @__PURE__ */ c.createElement(
|
|
52
|
+
n,
|
|
53
|
+
{
|
|
54
|
+
svgIcon: s,
|
|
55
|
+
color: r.kiwi900,
|
|
56
|
+
hoverColor: r.kiwi900,
|
|
57
|
+
size: e,
|
|
58
|
+
className: o,
|
|
59
|
+
testId: t,
|
|
60
|
+
isHovered: a
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}, E = g;
|
|
65
|
+
export {
|
|
66
|
+
E as default
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=NotificationBadge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationBadge.js","sources":["../../../src/components/Badge/NotificationBadge.tsx"],"sourcesContent":["import React from 'react';\n\nimport { IconSize } from '../../constants';\nimport { palette } from '../../theme/palette';\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\nexport type BadgeNotificationVariant = 'info' | 'warn' | 'error' | 'success';\n\nexport interface NotificationBadgeProps {\n /** Changes the type of the badge */\n variant: BadgeNotificationVariant;\n /** Sets the size of the badge */\n size: IconSize;\n /** Adds custom classes to the element */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets hover state */\n isHovered?: boolean;\n}\n\nconst NotificationBadge = (props: NotificationBadgeProps): React.JSX.Element => {\n const { variant, size, className = '', testId, isHovered = false } = props;\n switch (variant) {\n case 'info':\n return (\n <Icon\n svgIcon={InfoSignFill}\n color={palette.blueberry700}\n hoverColor={palette.blueberry700}\n size={size}\n className={className}\n testId={testId}\n isHovered={isHovered}\n />\n );\n case 'warn':\n return (\n <Icon\n svgIcon={ErrorSignFill}\n color={palette.banana700}\n hoverColor={palette.banana700}\n size={size}\n className={className}\n testId={testId}\n isHovered={isHovered}\n />\n );\n case 'error':\n return (\n <Icon\n svgIcon={TriangleX}\n color={palette.cherry700}\n hoverColor={palette.cherry700}\n size={size}\n className={className}\n testId={testId}\n isHovered={isHovered}\n />\n );\n case 'success':\n return (\n <Icon\n svgIcon={CheckFill}\n color={palette.kiwi900}\n hoverColor={palette.kiwi900}\n size={size}\n className={className}\n testId={testId}\n isHovered={isHovered}\n />\n );\n }\n};\n\nexport default NotificationBadge;\n"],"names":["NotificationBadge","props","variant","size","className","testId","isHovered","React","Icon","InfoSignFill","palette","ErrorSignFill","TriangleX","CheckFill","NotificationBadge$1"],"mappings":";;;;;;;AAyBA,MAAMA,IAAoB,CAACC,MAAqD;AACxE,QAAA,EAAE,SAAAC,GAAS,MAAAC,GAAM,WAAAC,IAAY,IAAI,QAAAC,GAAQ,WAAAC,IAAY,GAAU,IAAAL;AACrE,UAAQC,GAAS;AAAA,IACf,KAAK;AAED,aAAAK,gBAAAA,EAAA;AAAA,QAACC;AAAA,QAAA;AAAA,UACC,SAASC;AAAA,UACT,OAAOC,EAAQ;AAAA,UACf,YAAYA,EAAQ;AAAA,UACpB,MAAAP;AAAA,UACA,WAAAC;AAAA,UACA,QAAAC;AAAA,UACA,WAAAC;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN,KAAK;AAED,aAAAC,gBAAAA,EAAA;AAAA,QAACC;AAAA,QAAA;AAAA,UACC,SAASG;AAAA,UACT,OAAOD,EAAQ;AAAA,UACf,YAAYA,EAAQ;AAAA,UACpB,MAAAP;AAAA,UACA,WAAAC;AAAA,UACA,QAAAC;AAAA,UACA,WAAAC;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN,KAAK;AAED,aAAAC,gBAAAA,EAAA;AAAA,QAACC;AAAA,QAAA;AAAA,UACC,SAASI;AAAA,UACT,OAAOF,EAAQ;AAAA,UACf,YAAYA,EAAQ;AAAA,UACpB,MAAAP;AAAA,UACA,WAAAC;AAAA,UACA,QAAAC;AAAA,UACA,WAAAC;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN,KAAK;AAED,aAAAC,gBAAAA,EAAA;AAAA,QAACC;AAAA,QAAA;AAAA,UACC,SAASK;AAAA,UACT,OAAOH,EAAQ;AAAA,UACf,YAAYA,EAAQ;AAAA,UACpB,MAAAP;AAAA,UACA,WAAAC;AAAA,UACA,QAAAC;AAAA,UACA,WAAAC;AAAA,QAAA;AAAA,MAAA;AAAA,EAGR;AACF,GAEAQ,IAAed;"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
@import '../../scss/breakpoints';
|
|
4
4
|
@import '../../scss/palette';
|
|
5
5
|
@import '../../scss/font-settings';
|
|
6
|
+
@import '../../scss/supernova/styles/colors';
|
|
6
7
|
|
|
7
8
|
.expander {
|
|
8
9
|
position: relative;
|
|
@@ -53,11 +54,11 @@
|
|
|
53
54
|
text-align: left;
|
|
54
55
|
|
|
55
56
|
&:hover {
|
|
56
|
-
background-color:
|
|
57
|
+
background-color: var(--color-action-background-transparent-onlight-hover);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
&--expanded {
|
|
60
|
-
background-color:
|
|
61
|
+
background-color: var(--color-action-background-transparent-onlight-hover);
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -32,7 +32,7 @@ export interface ListHeaderProps {
|
|
|
32
32
|
interface ListHeaderChildren {
|
|
33
33
|
avatarChild?: React.ReactElement<AvatarProps>;
|
|
34
34
|
listHeaderTextChildren: React.ReactElement<ListHeaderTextProps>[];
|
|
35
|
-
|
|
35
|
+
badgeChildren?: React.ReactElement<BadgeProps>[];
|
|
36
36
|
elementChild?: React.ReactElement;
|
|
37
37
|
stringChildren: string[];
|
|
38
38
|
remainingChildren: React.ReactNode[];
|
|
@@ -1,80 +1,84 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import a from "react";
|
|
2
|
+
import _ from "classnames";
|
|
3
3
|
import L from "./ListHeaderText/ListHeaderText.js";
|
|
4
|
-
import { useBreakpoint as
|
|
4
|
+
import { useBreakpoint as A, Breakpoint as $ } from "../../hooks/useBreakpoint.js";
|
|
5
5
|
import { isComponent as u, isComponentWithChildren as N } from "../../utils/component.js";
|
|
6
|
-
import
|
|
7
|
-
import R from "../
|
|
8
|
-
import
|
|
6
|
+
import { uuid as B } from "../../utils/uuid.js";
|
|
7
|
+
import R, { AvatarSize as X } from "../Avatar/Avatar.js";
|
|
8
|
+
import w from "../Badge/Badge.js";
|
|
9
|
+
import { Icon as M } from "../Icon/Icon.js";
|
|
9
10
|
import { IconSize as C } from "../../constants.js";
|
|
10
11
|
import t from "../ListHeader/styles.module.scss";
|
|
11
|
-
const
|
|
12
|
+
const U = (m, f, h, i, c, o) => {
|
|
12
13
|
if (u(m, E))
|
|
13
|
-
return
|
|
14
|
+
return a.cloneElement(m, {
|
|
14
15
|
chevronIcon: c,
|
|
15
16
|
icon: o,
|
|
16
|
-
isHovered:
|
|
17
|
+
isHovered: h,
|
|
17
18
|
size: i
|
|
18
19
|
});
|
|
19
20
|
if (m)
|
|
20
|
-
return /* @__PURE__ */
|
|
21
|
+
return /* @__PURE__ */ a.createElement(E, { titleHtmlMarkup: f, chevronIcon: c, icon: o, isHovered: h, size: i }, m);
|
|
21
22
|
}, b = (m, f = !1) => {
|
|
22
23
|
var d, g, s, e;
|
|
23
|
-
let
|
|
24
|
-
const c = [], o = [], l = [];
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
let h;
|
|
25
|
+
const i = [], c = [], o = [], l = [];
|
|
26
|
+
a.Children.forEach(m, (r) => {
|
|
27
|
+
r === null || typeof r > "u" || (u(r, R) ? h = r : u(r, L) ? c.push(r) : u(r, w) ? i.push(r) : typeof r == "string" ? o.push(r) : l.push(r));
|
|
27
28
|
});
|
|
28
|
-
const n =
|
|
29
|
+
const n = h !== void 0 || c.length > 0 || i !== void 0 && o.length > 0, v = l.length === 0 || N(l[0]) && typeof ((g = (d = l[0]) == null ? void 0 : d.props) == null ? void 0 : g.children) > "u";
|
|
29
30
|
if (f || n || v)
|
|
30
|
-
return { avatarChild:
|
|
31
|
+
return { avatarChild: h, listHeaderTextChildren: c, badgeChildren: i, stringChildren: o, remainingChildren: l };
|
|
31
32
|
if (N(l[0]))
|
|
32
33
|
return b((e = (s = l[0]) == null ? void 0 : s.props) == null ? void 0 : e.children, !0);
|
|
33
34
|
}, E = (m) => {
|
|
34
|
-
const { className: f = "", titleHtmlMarkup:
|
|
35
|
+
const { className: f = "", titleHtmlMarkup: h = "h2", chevronIcon: i, children: c, icon: o, isHovered: l, size: n, testId: v } = m, d = A(), g = n !== "small" && !!(i || o), s = typeof c == "string", e = b(c), r = (e == null ? void 0 : e.avatarChild) || (e == null ? void 0 : e.listHeaderTextChildren) && e.listHeaderTextChildren.length > 0 || (e == null ? void 0 : e.remainingChildren) && (e == null ? void 0 : e.remainingChildren.length) > 0, H = _(
|
|
35
36
|
t["list-header"],
|
|
36
37
|
{
|
|
37
38
|
[t["list-header--for-element-content"]]: !s,
|
|
38
|
-
[t["list-header--top-align-content"]]:
|
|
39
|
+
[t["list-header--top-align-content"]]: r
|
|
39
40
|
},
|
|
40
41
|
f
|
|
41
|
-
), x =
|
|
42
|
+
), x = _(
|
|
42
43
|
t["list-header__badge"],
|
|
43
44
|
{
|
|
44
45
|
[t["list-header__badge--for-string-content"]]: s
|
|
45
46
|
},
|
|
46
47
|
!s && n && t[`list-header__badge--${n}`]
|
|
47
|
-
),
|
|
48
|
+
), y = _(t["list-header__chevron"], !s && n && t[`list-header__chevron--${n}`], {
|
|
48
49
|
[t["list-header__chevron--for-string-content"]]: s
|
|
49
|
-
}),
|
|
50
|
+
}), S = _(t["list-header__content"], {
|
|
50
51
|
[t["list-header__content--string"]]: s,
|
|
51
52
|
[t["list-header__content--element"]]: !s,
|
|
52
53
|
[t["list-header__content--spacing"]]: !(e != null && e.avatarChild) && !o
|
|
53
|
-
}), I =
|
|
54
|
+
}), I = _(
|
|
54
55
|
t["list-header__icon"],
|
|
55
56
|
!s && n && (n === "medium" || n === "large") && t[`list-header__icon--for-element-content--${n}`],
|
|
56
57
|
{
|
|
57
58
|
[t["list-header__icon--for-string-content"]]: s,
|
|
58
59
|
[t["list-header__icon--for-element-content"]]: !s
|
|
59
60
|
}
|
|
60
|
-
), T =
|
|
61
|
+
), T = _(
|
|
61
62
|
t["list-header__avatar"],
|
|
62
63
|
!s && n && (n === "medium" || n === "large") && t[`list-header__avatar--for-element-content--${n}`],
|
|
63
64
|
{
|
|
64
65
|
[t["list-header__avatar--for-string-content"]]: s,
|
|
65
66
|
[t["list-header__avatar--for-element-content"]]: !s
|
|
66
67
|
}
|
|
67
|
-
),
|
|
68
|
-
return /* @__PURE__ */
|
|
69
|
-
size: d ===
|
|
68
|
+
), k = h;
|
|
69
|
+
return /* @__PURE__ */ a.createElement("span", { "data-testid": v, className: H }, g && o && /* @__PURE__ */ a.createElement("span", { className: I }, a.cloneElement(o, {
|
|
70
|
+
size: d === $.xs ? C.XSmall : C.Small,
|
|
70
71
|
isHovered: l
|
|
71
|
-
})), n !== "small" && (e == null ? void 0 : e.avatarChild) && /* @__PURE__ */
|
|
72
|
+
})), n !== "small" && (e == null ? void 0 : e.avatarChild) && /* @__PURE__ */ a.createElement("span", { className: T }, a.cloneElement(e.avatarChild, { size: X.xsmall })), /* @__PURE__ */ a.createElement("span", { className: S }, e == null ? void 0 : e.listHeaderTextChildren, !!(e != null && e.stringChildren.length) && /* @__PURE__ */ a.createElement(k, { className: t["list-header__title"] }, e.stringChildren), e == null ? void 0 : e.remainingChildren), (e == null ? void 0 : e.badgeChildren) && e.badgeChildren.map((p) => {
|
|
73
|
+
const z = B();
|
|
74
|
+
return /* @__PURE__ */ a.createElement("span", { key: z, className: x }, p);
|
|
75
|
+
}), g && i && /* @__PURE__ */ a.createElement("span", { className: y }, /* @__PURE__ */ a.createElement(M, { svgIcon: i, isHovered: l, size: C.XSmall })));
|
|
72
76
|
};
|
|
73
77
|
E.displayName = "ListHeader";
|
|
74
78
|
export {
|
|
75
79
|
E as ListHeader,
|
|
76
80
|
E as default,
|
|
77
81
|
b as mapChildren,
|
|
78
|
-
|
|
82
|
+
U as renderListHeader
|
|
79
83
|
};
|
|
80
84
|
//# sourceMappingURL=ListHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListHeader.js","sources":["../../../src/components/ListHeader/ListHeader.tsx"],"sourcesContent":["import React from 'react';\n\nimport cn from 'classnames';\n\nimport ListHeaderText, { ListHeaderTextProps, ListHeaderTextType } from './ListHeaderText/ListHeaderText';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { isComponent, isComponentWithChildren } from '../../utils/component';\nimport Avatar, { AvatarProps, AvatarSize, AvatarType } from '../Avatar';\nimport Badge, { BadgeProps, BadgeType } from '../Badge';\nimport Icon, { IconSize, SvgIcon } from '../Icon';\nimport { TitleTags } from '../Title';\n\nimport styles from './styles.module.scss';\n\nexport type ListHeaderSize = 'small' | 'medium' | 'large';\n\nexport interface ListHeaderType extends React.FC<ListHeaderProps> {\n Avatar?: AvatarType;\n Badge?: BadgeType;\n ListHeaderText?: ListHeaderTextType;\n}\n\nexport const renderListHeader = (\n element: React.ReactNode,\n titleHtmlMarkup: TitleTags,\n isHovered: boolean,\n size: ListHeaderSize,\n chevronIcon?: SvgIcon,\n icon?: React.ReactElement\n): JSX.Element | undefined => {\n if (isComponent<ListHeaderProps>(element, ListHeader)) {\n return React.cloneElement(element, {\n chevronIcon,\n icon,\n isHovered,\n size,\n });\n }\n if (element) {\n return (\n <ListHeader titleHtmlMarkup={titleHtmlMarkup} chevronIcon={chevronIcon} icon={icon} isHovered={isHovered} size={size}>\n {element}\n </ListHeader>\n );\n }\n};\n\nexport interface ListHeaderProps {\n /** Adds custom classes to the ListHeader element. */\n className?: string;\n /** Chevron to render inside of the ListHeader */\n chevronIcon?: SvgIcon;\n /** Children to be rendered inside of ListHeader */\n children: React.ReactNode;\n /** Changes the underlying element of the title. Default: h2*/\n titleHtmlMarkup?: TitleTags;\n /** icon to be rendered inside of ListHeader */\n icon?: React.ReactElement;\n /** whether or not the parent is hovered */\n isHovered?: boolean;\n /** Changes size of the ListHeader. */\n size?: ListHeaderSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\ninterface ListHeaderChildren {\n avatarChild?: React.ReactElement<AvatarProps>;\n listHeaderTextChildren: React.ReactElement<ListHeaderTextProps>[];\n badgeChild?: React.ReactElement<BadgeProps>;\n elementChild?: React.ReactElement;\n stringChildren: string[];\n remainingChildren: React.ReactNode[];\n}\n\ntype ChildrenMapper = (children: React.ReactNode, isJsxChild?: boolean) => ListHeaderChildren | undefined;\n\nexport const mapChildren: ChildrenMapper = (children, isJsxChild = false) => {\n let avatarChild: React.ReactElement<AvatarProps> | undefined;\n let badgeChild: React.ReactElement<BadgeProps> | undefined;\n const listHeaderTextChildren: React.ReactElement<ListHeaderTextProps>[] = [];\n const stringChildren: string[] = [];\n const remainingChildren: React.ReactNode[] = [];\n\n React.Children.forEach(children, child => {\n if (child === null || typeof child === 'undefined') return;\n if (isComponent<AvatarProps>(child, Avatar)) {\n avatarChild = child;\n } else if (isComponent<ListHeaderTextProps>(child, ListHeaderText)) {\n listHeaderTextChildren.push(child);\n } else if (isComponent<BadgeProps>(child, Badge)) {\n badgeChild = child;\n } else if (typeof child === 'string') {\n stringChildren.push(child);\n } else {\n remainingChildren.push(child);\n }\n });\n\n // Dette og recursive mapChildren under(gjøres en gang) er for å passe på at jsx children også sjekkes for Avatar og liknende innhold.\n // Slik opprettholder vi stylingen i tilfeller hvor vertikaler har wrappet elementer i en parent span eller div.\n const hasSpecialChildren =\n avatarChild !== undefined || listHeaderTextChildren.length > 0 || (badgeChild !== undefined && stringChildren.length > 0);\n const noRemainingRecursiveChildren =\n remainingChildren.length === 0 ||\n (isComponentWithChildren(remainingChildren[0]) && typeof remainingChildren[0]?.props?.children === 'undefined');\n\n if (isJsxChild || hasSpecialChildren || noRemainingRecursiveChildren) {\n return { avatarChild, listHeaderTextChildren, badgeChild, stringChildren, remainingChildren };\n }\n\n if (isComponentWithChildren(remainingChildren[0])) {\n return mapChildren(remainingChildren[0]?.props?.children, true);\n }\n};\n\nexport const ListHeader: ListHeaderType = props => {\n const { className = '', titleHtmlMarkup = 'h2', chevronIcon, children, icon, isHovered, size, testId } = props;\n const breakpoint = useBreakpoint();\n const showChevronAndIcon = size !== 'small' && !!(chevronIcon || icon);\n const contentIsString = typeof children === 'string';\n const mappedChildren = mapChildren(children);\n const topAlignContent =\n mappedChildren?.avatarChild ||\n (mappedChildren?.listHeaderTextChildren && mappedChildren.listHeaderTextChildren.length > 0) ||\n (mappedChildren?.remainingChildren && mappedChildren?.remainingChildren.length > 0);\n\n const listLabelClasses = cn(\n styles['list-header'],\n {\n [styles['list-header--for-element-content']]: !contentIsString,\n [styles['list-header--top-align-content']]: topAlignContent,\n },\n className\n );\n const badgeClasses = cn(\n styles['list-header__badge'],\n {\n [styles['list-header__badge--for-string-content']]: contentIsString,\n },\n !contentIsString && size && styles[`list-header__badge--${size}`]\n );\n const chevronClasses = cn(styles['list-header__chevron'], !contentIsString && size && styles[`list-header__chevron--${size}`], {\n [styles['list-header__chevron--for-string-content']]: contentIsString,\n });\n const contentClasses = cn(styles['list-header__content'], {\n [styles['list-header__content--string']]: contentIsString,\n [styles['list-header__content--element']]: !contentIsString,\n [styles['list-header__content--spacing']]: !mappedChildren?.avatarChild && !icon,\n });\n const iconClasses = cn(\n styles['list-header__icon'],\n !contentIsString && size && (size === 'medium' || size === 'large') && styles[`list-header__icon--for-element-content--${size}`],\n {\n [styles['list-header__icon--for-string-content']]: contentIsString,\n [styles['list-header__icon--for-element-content']]: !contentIsString,\n }\n );\n const avatarClasses = cn(\n styles['list-header__avatar'],\n !contentIsString && size && (size === 'medium' || size === 'large') && styles[`list-header__avatar--for-element-content--${size}`],\n {\n [styles['list-header__avatar--for-string-content']]: contentIsString,\n [styles['list-header__avatar--for-element-content']]: !contentIsString,\n }\n );\n const CustomTag = titleHtmlMarkup;\n return (\n <span data-testid={testId} className={listLabelClasses}>\n {showChevronAndIcon && icon && (\n <span className={iconClasses}>\n {React.cloneElement(icon, {\n size: breakpoint === Breakpoint.xs ? IconSize.XSmall : IconSize.Small,\n isHovered,\n })}\n </span>\n )}\n {size !== 'small' && mappedChildren?.avatarChild && (\n <span className={avatarClasses}>{React.cloneElement(mappedChildren.avatarChild, { size: AvatarSize.xsmall })}</span>\n )}\n <span className={contentClasses}>\n {mappedChildren?.listHeaderTextChildren}\n {!!mappedChildren?.stringChildren.length && (\n <CustomTag className={styles['list-header__title']}>{mappedChildren.stringChildren}</CustomTag>\n )}\n {mappedChildren?.remainingChildren}\n </span>\n\n {mappedChildren?.badgeChild && <span className={badgeClasses}>{mappedChildren.badgeChild}</span>}\n {showChevronAndIcon && chevronIcon && (\n <span className={chevronClasses}>\n <Icon svgIcon={chevronIcon} isHovered={isHovered} size={IconSize.XSmall} />\n </span>\n )}\n </span>\n );\n};\n\nListHeader.displayName = 'ListHeader';\n\nexport default ListHeader;\n"],"names":["renderListHeader","element","titleHtmlMarkup","isHovered","size","chevronIcon","icon","isComponent","ListHeader","React","mapChildren","children","isJsxChild","avatarChild","badgeChild","listHeaderTextChildren","stringChildren","remainingChildren","child","Avatar","ListHeaderText","Badge","hasSpecialChildren","noRemainingRecursiveChildren","isComponentWithChildren","_b","_a","_d","_c","props","className","testId","breakpoint","useBreakpoint","showChevronAndIcon","contentIsString","mappedChildren","topAlignContent","listLabelClasses","cn","styles","badgeClasses","chevronClasses","contentClasses","iconClasses","avatarClasses","CustomTag","Breakpoint","IconSize","AvatarSize","Icon"],"mappings":";;;;;;;;;;AAsBO,MAAMA,IAAmB,CAC9BC,GACAC,GACAC,GACAC,GACAC,GACAC,MAC4B;AACxB,MAAAC,EAA6BN,GAASO,CAAU;AAC3C,WAAAC,EAAM,aAAaR,GAAS;AAAA,MACjC,aAAAI;AAAA,MACA,MAAAC;AAAA,MACA,WAAAH;AAAA,MACA,MAAAC;AAAA,IAAA,CACD;AAEH,MAAIH;AACF,2CACGO,GAAW,EAAA,iBAAAN,GAAkC,aAAAG,GAA0B,MAAAC,GAAY,WAAAH,GAAsB,MAAAC,KACvGH,CACH;AAGN,GAgCaS,IAA8B,CAACC,GAAUC,IAAa,OAAU;;AACvE,MAAAC,GACAC;AACJ,QAAMC,IAAoE,CAAA,GACpEC,IAA2B,CAAA,GAC3BC,IAAuC,CAAA;AAEvCR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ader/ListHeader.tsx"],"sourcesContent":["import React from 'react';\n\nimport cn from 'classnames';\n\nimport ListHeaderText, { ListHeaderTextProps, ListHeaderTextType } from './ListHeaderText/ListHeaderText';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { isComponent, isComponentWithChildren } from '../../utils/component';\nimport uuid from '../../utils/uuid';\nimport Avatar, { AvatarProps, AvatarSize, AvatarType } from '../Avatar';\nimport Badge, { BadgeProps, BadgeType } from '../Badge';\nimport Icon, { IconSize, SvgIcon } from '../Icon';\nimport { TitleTags } from '../Title';\n\nimport styles from './styles.module.scss';\n\nexport type ListHeaderSize = 'small' | 'medium' | 'large';\n\nexport interface ListHeaderType extends React.FC<ListHeaderProps> {\n Avatar?: AvatarType;\n Badge?: BadgeType;\n ListHeaderText?: ListHeaderTextType;\n}\n\nexport const renderListHeader = (\n element: React.ReactNode,\n titleHtmlMarkup: TitleTags,\n isHovered: boolean,\n size: ListHeaderSize,\n chevronIcon?: SvgIcon,\n icon?: React.ReactElement\n): JSX.Element | undefined => {\n if (isComponent<ListHeaderProps>(element, ListHeader)) {\n return React.cloneElement(element, {\n chevronIcon,\n icon,\n isHovered,\n size,\n });\n }\n if (element) {\n return (\n <ListHeader titleHtmlMarkup={titleHtmlMarkup} chevronIcon={chevronIcon} icon={icon} isHovered={isHovered} size={size}>\n {element}\n </ListHeader>\n );\n }\n};\n\nexport interface ListHeaderProps {\n /** Adds custom classes to the ListHeader element. */\n className?: string;\n /** Chevron to render inside of the ListHeader */\n chevronIcon?: SvgIcon;\n /** Children to be rendered inside of ListHeader */\n children: React.ReactNode;\n /** Changes the underlying element of the title. Default: h2*/\n titleHtmlMarkup?: TitleTags;\n /** icon to be rendered inside of ListHeader */\n icon?: React.ReactElement;\n /** whether or not the parent is hovered */\n isHovered?: boolean;\n /** Changes size of the ListHeader. */\n size?: ListHeaderSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\ninterface ListHeaderChildren {\n avatarChild?: React.ReactElement<AvatarProps>;\n listHeaderTextChildren: React.ReactElement<ListHeaderTextProps>[];\n badgeChildren?: React.ReactElement<BadgeProps>[];\n elementChild?: React.ReactElement;\n stringChildren: string[];\n remainingChildren: React.ReactNode[];\n}\n\ntype ChildrenMapper = (children: React.ReactNode, isJsxChild?: boolean) => ListHeaderChildren | undefined;\n\nexport const mapChildren: ChildrenMapper = (children, isJsxChild = false) => {\n let avatarChild: React.ReactElement<AvatarProps> | undefined;\n const badgeChildren: React.ReactElement<BadgeProps>[] = [];\n const listHeaderTextChildren: React.ReactElement<ListHeaderTextProps>[] = [];\n const stringChildren: string[] = [];\n const remainingChildren: React.ReactNode[] = [];\n\n React.Children.forEach(children, child => {\n if (child === null || typeof child === 'undefined') return;\n if (isComponent<AvatarProps>(child, Avatar)) {\n avatarChild = child;\n } else if (isComponent<ListHeaderTextProps>(child, ListHeaderText)) {\n listHeaderTextChildren.push(child);\n } else if (isComponent<BadgeProps>(child, Badge)) {\n badgeChildren.push(child);\n } else if (typeof child === 'string') {\n stringChildren.push(child);\n } else {\n remainingChildren.push(child);\n }\n });\n\n // Dette og recursive mapChildren under(gjøres en gang) er for å passe på at jsx children også sjekkes for Avatar og liknende innhold.\n // Slik opprettholder vi stylingen i tilfeller hvor vertikaler har wrappet elementer i en parent span eller div.\n const hasSpecialChildren =\n avatarChild !== undefined || listHeaderTextChildren.length > 0 || (badgeChildren !== undefined && stringChildren.length > 0);\n const noRemainingRecursiveChildren =\n remainingChildren.length === 0 ||\n (isComponentWithChildren(remainingChildren[0]) && typeof remainingChildren[0]?.props?.children === 'undefined');\n\n if (isJsxChild || hasSpecialChildren || noRemainingRecursiveChildren) {\n return { avatarChild, listHeaderTextChildren, badgeChildren, stringChildren, remainingChildren };\n }\n\n if (isComponentWithChildren(remainingChildren[0])) {\n return mapChildren(remainingChildren[0]?.props?.children, true);\n }\n};\n\nexport const ListHeader: ListHeaderType = props => {\n const { className = '', titleHtmlMarkup = 'h2', chevronIcon, children, icon, isHovered, size, testId } = props;\n const breakpoint = useBreakpoint();\n const showChevronAndIcon = size !== 'small' && !!(chevronIcon || icon);\n const contentIsString = typeof children === 'string';\n const mappedChildren = mapChildren(children);\n const topAlignContent =\n mappedChildren?.avatarChild ||\n (mappedChildren?.listHeaderTextChildren && mappedChildren.listHeaderTextChildren.length > 0) ||\n (mappedChildren?.remainingChildren && mappedChildren?.remainingChildren.length > 0);\n\n const listLabelClasses = cn(\n styles['list-header'],\n {\n [styles['list-header--for-element-content']]: !contentIsString,\n [styles['list-header--top-align-content']]: topAlignContent,\n },\n className\n );\n const badgeClasses = cn(\n styles['list-header__badge'],\n {\n [styles['list-header__badge--for-string-content']]: contentIsString,\n },\n !contentIsString && size && styles[`list-header__badge--${size}`]\n );\n const chevronClasses = cn(styles['list-header__chevron'], !contentIsString && size && styles[`list-header__chevron--${size}`], {\n [styles['list-header__chevron--for-string-content']]: contentIsString,\n });\n const contentClasses = cn(styles['list-header__content'], {\n [styles['list-header__content--string']]: contentIsString,\n [styles['list-header__content--element']]: !contentIsString,\n [styles['list-header__content--spacing']]: !mappedChildren?.avatarChild && !icon,\n });\n const iconClasses = cn(\n styles['list-header__icon'],\n !contentIsString && size && (size === 'medium' || size === 'large') && styles[`list-header__icon--for-element-content--${size}`],\n {\n [styles['list-header__icon--for-string-content']]: contentIsString,\n [styles['list-header__icon--for-element-content']]: !contentIsString,\n }\n );\n const avatarClasses = cn(\n styles['list-header__avatar'],\n !contentIsString && size && (size === 'medium' || size === 'large') && styles[`list-header__avatar--for-element-content--${size}`],\n {\n [styles['list-header__avatar--for-string-content']]: contentIsString,\n [styles['list-header__avatar--for-element-content']]: !contentIsString,\n }\n );\n const CustomTag = titleHtmlMarkup;\n return (\n <span data-testid={testId} className={listLabelClasses}>\n {showChevronAndIcon && icon && (\n <span className={iconClasses}>\n {React.cloneElement(icon, {\n size: breakpoint === Breakpoint.xs ? IconSize.XSmall : IconSize.Small,\n isHovered,\n })}\n </span>\n )}\n {size !== 'small' && mappedChildren?.avatarChild && (\n <span className={avatarClasses}>{React.cloneElement(mappedChildren.avatarChild, { size: AvatarSize.xsmall })}</span>\n )}\n <span className={contentClasses}>\n {mappedChildren?.listHeaderTextChildren}\n {!!mappedChildren?.stringChildren.length && (\n <CustomTag className={styles['list-header__title']}>{mappedChildren.stringChildren}</CustomTag>\n )}\n {mappedChildren?.remainingChildren}\n </span>\n\n {mappedChildren?.badgeChildren &&\n mappedChildren.badgeChildren.map(badgeChild => {\n const id = uuid();\n return (\n <span key={id} className={badgeClasses}>\n {badgeChild}\n </span>\n );\n })}\n {showChevronAndIcon && chevronIcon && (\n <span className={chevronClasses}>\n <Icon svgIcon={chevronIcon} isHovered={isHovered} size={IconSize.XSmall} />\n </span>\n )}\n </span>\n );\n};\n\nListHeader.displayName = 'ListHeader';\n\nexport default ListHeader;\n"],"names":["renderListHeader","element","titleHtmlMarkup","isHovered","size","chevronIcon","icon","isComponent","ListHeader","React","mapChildren","children","isJsxChild","avatarChild","badgeChildren","listHeaderTextChildren","stringChildren","remainingChildren","child","Avatar","ListHeaderText","Badge","hasSpecialChildren","noRemainingRecursiveChildren","isComponentWithChildren","_b","_a","_d","_c","props","className","testId","breakpoint","useBreakpoint","showChevronAndIcon","contentIsString","mappedChildren","topAlignContent","listLabelClasses","cn","styles","badgeClasses","chevronClasses","contentClasses","iconClasses","avatarClasses","CustomTag","Breakpoint","IconSize","AvatarSize","badgeChild","id","uuid","Icon"],"mappings":";;;;;;;;;;;AAuBO,MAAMA,IAAmB,CAC9BC,GACAC,GACAC,GACAC,GACAC,GACAC,MAC4B;AACxB,MAAAC,EAA6BN,GAASO,CAAU;AAC3C,WAAAC,EAAM,aAAaR,GAAS;AAAA,MACjC,aAAAI;AAAA,MACA,MAAAC;AAAA,MACA,WAAAH;AAAA,MACA,MAAAC;AAAA,IAAA,CACD;AAEH,MAAIH;AACF,2CACGO,GAAW,EAAA,iBAAAN,GAAkC,aAAAG,GAA0B,MAAAC,GAAY,WAAAH,GAAsB,MAAAC,K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7B,KACrBI,gBAAAA,EAAA,cAAC,UAAK,WAAWiC,EAAA,GACdjC,gBAAAA,EAAA,cAAA4C,GAAA,EAAK,SAAShD,GAAa,WAAAF,GAAsB,MAAM6C,EAAS,QAAQ,CAC3E,CAEJ;AAEJ;AAEAxC,EAAW,cAAc;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export type NotificationPanelVariants = 'info' | 'warn' | 'alert' | 'success';
|
|
2
|
+
export type NotificationPanelVariants = 'info' | 'warn' | 'alert' | 'error' | 'success';
|
|
3
3
|
export type NotificationCompactVariants = 'basic' | 'outline';
|
|
4
4
|
export type NotificationPanelSizes = 'small' | 'medium' | 'large';
|
|
5
5
|
export type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'span';
|
|
@@ -1,128 +1,94 @@
|
|
|
1
1
|
import t from "react";
|
|
2
2
|
import c from "classnames";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { Icon as p } from "../Icon/Icon.js";
|
|
11
|
-
import H from "../Icons/CheckFill.js";
|
|
12
|
-
import O from "../Icons/ErrorSignFill.js";
|
|
13
|
-
import U from "../Icons/InfoSignFill.js";
|
|
14
|
-
import W from "../Icons/TriangleX.js";
|
|
3
|
+
import { AnalyticsId as R, IconSize as C } from "../../constants.js";
|
|
4
|
+
import { useUuid as T } from "../../hooks/useUuid.js";
|
|
5
|
+
import { getColor as $ } from "../../theme/currys/color.js";
|
|
6
|
+
import { getAriaLabelAttributes as F } from "../../utils/accessibility.js";
|
|
7
|
+
import V from "../Badge/NotificationBadge.js";
|
|
8
|
+
import H from "../Close/Close.js";
|
|
9
|
+
import M from "../Expander/Expander.js";
|
|
15
10
|
import e from "../NotificationPanel/styles.module.scss";
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
return /* @__PURE__ */ t.createElement("div", { className:
|
|
11
|
+
const U = ({ fluid: r, children: s }) => {
|
|
12
|
+
if (r) {
|
|
13
|
+
const i = c(e["fluid-wrapper"]);
|
|
14
|
+
return /* @__PURE__ */ t.createElement("div", { className: i }, s);
|
|
20
15
|
}
|
|
21
|
-
return
|
|
22
|
-
},
|
|
16
|
+
return s;
|
|
17
|
+
}, W = t.forwardRef((r, s) => {
|
|
23
18
|
const {
|
|
24
|
-
children:
|
|
25
|
-
variant:
|
|
26
|
-
dismissable:
|
|
19
|
+
children: i,
|
|
20
|
+
variant: o = "info",
|
|
21
|
+
dismissable: m = !1,
|
|
27
22
|
onClick: E,
|
|
28
|
-
expanderChildren:
|
|
29
|
-
expanderButtonText:
|
|
30
|
-
expanderButtonClosedText:
|
|
23
|
+
expanderChildren: l,
|
|
24
|
+
expanderButtonText: d,
|
|
25
|
+
expanderButtonClosedText: f,
|
|
31
26
|
expanderOpenFromStart: N = !1,
|
|
32
27
|
compactVariant: a,
|
|
33
|
-
label:
|
|
34
|
-
labelHtmlMarkup:
|
|
35
|
-
fluid:
|
|
36
|
-
size:
|
|
37
|
-
className:
|
|
38
|
-
labelId:
|
|
39
|
-
role:
|
|
40
|
-
testId:
|
|
41
|
-
} =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
svgIcon: U,
|
|
46
|
-
color: n.blueberry700,
|
|
47
|
-
hoverColor: n.blueberry700,
|
|
48
|
-
size: a ? o.XSmall : o.Small
|
|
49
|
-
}
|
|
50
|
-
),
|
|
51
|
-
warn: /* @__PURE__ */ t.createElement(
|
|
52
|
-
p,
|
|
53
|
-
{
|
|
54
|
-
svgIcon: O,
|
|
55
|
-
color: n.banana700,
|
|
56
|
-
hoverColor: n.banana700,
|
|
57
|
-
size: a ? o.XSmall : o.Small
|
|
58
|
-
}
|
|
59
|
-
),
|
|
60
|
-
alert: /* @__PURE__ */ t.createElement(
|
|
61
|
-
p,
|
|
62
|
-
{
|
|
63
|
-
svgIcon: W,
|
|
64
|
-
color: n.cherry700,
|
|
65
|
-
hoverColor: n.cherry700,
|
|
66
|
-
size: a ? o.XSmall : o.Small
|
|
67
|
-
}
|
|
68
|
-
),
|
|
69
|
-
success: /* @__PURE__ */ t.createElement(
|
|
70
|
-
p,
|
|
71
|
-
{
|
|
72
|
-
svgIcon: H,
|
|
73
|
-
color: n.kiwi900,
|
|
74
|
-
hoverColor: n.kiwi900,
|
|
75
|
-
size: a ? o.XSmall : o.Small
|
|
76
|
-
}
|
|
77
|
-
)
|
|
78
|
-
}, k = () => {
|
|
79
|
-
const h = a === "outline", X = c(e["notification-panel__content"]), A = c(e["notification-panel__label"], {
|
|
80
|
-
[e["notification-panel__label--no-content"]]: !l && !r,
|
|
28
|
+
label: n,
|
|
29
|
+
labelHtmlMarkup: h = "h1",
|
|
30
|
+
fluid: v = !1,
|
|
31
|
+
size: u,
|
|
32
|
+
className: I,
|
|
33
|
+
labelId: S,
|
|
34
|
+
role: g,
|
|
35
|
+
testId: w
|
|
36
|
+
} = r, p = T(S), A = () => {
|
|
37
|
+
const b = a === "outline", P = c(e["notification-panel__content"]), k = c(e["notification-panel__label"], {
|
|
38
|
+
[e["notification-panel__label--no-content"]]: !i && !l,
|
|
81
39
|
[e["notification-panel__label--compact"]]: !!a,
|
|
82
|
-
[e["notification-panel__label--outline"]]:
|
|
83
|
-
}),
|
|
84
|
-
[e["notification-panel__children--with-label"]]:
|
|
85
|
-
[e["notification-panel__children--expander-no-label"]]:
|
|
86
|
-
[e["notification-panel__children--outline"]]:
|
|
87
|
-
}),
|
|
88
|
-
return /* @__PURE__ */ t.createElement("div", { className:
|
|
89
|
-
|
|
40
|
+
[e["notification-panel__label--outline"]]: b
|
|
41
|
+
}), y = c(e["notification-panel__children"], {
|
|
42
|
+
[e["notification-panel__children--with-label"]]: n,
|
|
43
|
+
[e["notification-panel__children--expander-no-label"]]: l && !n,
|
|
44
|
+
[e["notification-panel__children--outline"]]: b
|
|
45
|
+
}), z = h, [x, O] = t.useState(N);
|
|
46
|
+
return /* @__PURE__ */ t.createElement("div", { className: P, id: n ? void 0 : p }, n && /* @__PURE__ */ t.createElement(z, { className: k, id: p }, n), i && /* @__PURE__ */ t.createElement("div", { className: y }, i), l && d && f && !a && /* @__PURE__ */ t.createElement(
|
|
47
|
+
M,
|
|
90
48
|
{
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
49
|
+
title: x ? d : f,
|
|
50
|
+
onExpand: O,
|
|
51
|
+
expanded: x,
|
|
52
|
+
testId: "expand"
|
|
53
|
+
},
|
|
54
|
+
l
|
|
96
55
|
));
|
|
97
|
-
},
|
|
56
|
+
}, B = c(
|
|
98
57
|
e["notification-panel"],
|
|
99
|
-
e[`notification-panel--${
|
|
100
|
-
|
|
58
|
+
e[`notification-panel--${o}`],
|
|
59
|
+
u && e[`notification-panel--${u}`],
|
|
101
60
|
{
|
|
102
61
|
[e["notification-panel--compact"]]: !!a,
|
|
103
62
|
[e["notification-panel--compact--basic"]]: a === "basic",
|
|
104
63
|
[e["notification-panel--compact--outline"]]: a === "outline",
|
|
105
|
-
[e["notification-panel--with-content"]]:
|
|
106
|
-
[e["notification-panel--dismissable"]]:
|
|
64
|
+
[e["notification-panel--with-content"]]: l || n && i,
|
|
65
|
+
[e["notification-panel--dismissable"]]: m
|
|
107
66
|
},
|
|
108
|
-
|
|
109
|
-
),
|
|
110
|
-
return /* @__PURE__ */ t.createElement(
|
|
67
|
+
I
|
|
68
|
+
), _ = g || (o === "alert" || o === "error") && "alert" || void 0, L = _ ? F({ label: n, id: p }) : void 0;
|
|
69
|
+
return /* @__PURE__ */ t.createElement(U, { fluid: v }, /* @__PURE__ */ t.createElement(
|
|
111
70
|
"div",
|
|
112
71
|
{
|
|
113
|
-
ref:
|
|
114
|
-
role:
|
|
115
|
-
"data-testid":
|
|
72
|
+
ref: s,
|
|
73
|
+
role: _,
|
|
74
|
+
"data-testid": w,
|
|
116
75
|
"data-analyticsid": R.NotificationPanel,
|
|
117
|
-
className:
|
|
118
|
-
...
|
|
76
|
+
className: B,
|
|
77
|
+
...L
|
|
119
78
|
},
|
|
120
|
-
/* @__PURE__ */ t.createElement(
|
|
121
|
-
|
|
122
|
-
|
|
79
|
+
/* @__PURE__ */ t.createElement(
|
|
80
|
+
V,
|
|
81
|
+
{
|
|
82
|
+
variant: o == "alert" ? "error" : o,
|
|
83
|
+
size: a ? C.XSmall : C.Small,
|
|
84
|
+
className: e["notification-panel__icon"]
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
m && /* @__PURE__ */ t.createElement("span", { className: e["notification-panel__close"] }, /* @__PURE__ */ t.createElement(H, { ariaLabel: r.ariaLabelCloseBtn, onClick: E, color: $("black") })),
|
|
88
|
+
A()
|
|
123
89
|
));
|
|
124
|
-
}),
|
|
90
|
+
}), ee = W;
|
|
125
91
|
export {
|
|
126
|
-
|
|
92
|
+
ee as default
|
|
127
93
|
};
|
|
128
94
|
//# 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';\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 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 const CustomTag = labelHtmlMarkup;\n\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 <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","labelHtmlMarkup","size","className","labelId","role","testId","uuid","useUuid","variantToIconMap","Icon","InfoSignFill","palette","IconSize","ErrorSignFill","TriangleX","CheckFill","renderContent","outlineVariant","contentClasses","labelClasses","childrenClasses","CustomTag","DetailButton","notificationPanelClasses","ariaRole","ariaLabelAttributes","getAriaLabelAttributes","AnalyticsId","Close","getColor","NotificationPanel$1"],"mappings":";;;;;;;;;;;;;;;AAmEA,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;AAC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,CAACf,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,IACAU;AAAA,EAAA,GAGIsB,IAAWpB,KAASb,MAAY,WAAW,WAAY,QACvDkC,IAAsBD,IAAWE,EAAuB,EAAE,OAAA3B,GAAO,IAAIO,EAAA,CAAM,IAAI;AAGnF,SAAAnB,gBAAAA,EAAA,cAACN,KAAa,OAAAC,EACZ,GAAAK,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAG;AAAA,MACA,MAAMkC;AAAA,MACN,eAAanB;AAAA,MACb,oBAAkBsB,EAAY;AAAA,MAC9B,WAAWJ;AAAA,MACV,GAAGE;AAAA,IAAA;AAAA,IAEJtC,gBAAAA,EAAA,cAAC,UAAK,WAAWD,EAAO,0BAA0B,EAAI,GAAAsB,EAAiBjB,CAAO,CAAE;AAAA,IAC/EC,KACEL,gBAAAA,EAAA,cAAA,QAAA,EAAK,WAAWD,EAAO,2BAA2B,EACjD,GAAAC,gBAAAA,EAAA,cAACyC,GAAM,EAAA,WAAWvC,EAAM,mBAAmB,SAAAI,GAAkB,OAAOoC,EAAS,OAAO,GAAG,CACzF;AAAA,IAEDb,EAAc;AAAA,EAAA,CAEnB;AAEJ,CAAC,GAEDc,KAAe1C;"}
|
|
1
|
+
{"version":3,"file":"NotificationPanel.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' | 'alert' | '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 === 'alert' || 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 == 'alert' ? 'error' : 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":["FluidWrapper","fluid","children","fluidClasses","classNames","styles","React","NotificationPanel","props","ref","variant","dismissable","onClick","expanderChildren","expanderButtonText","expanderButtonClosedText","expanderOpenFromStart","compactVariant","label","labelHtmlMarkup","size","className","labelId","role","testId","uuid","useUuid","renderContent","outlineVariant","contentClasses","labelClasses","childrenClasses","CustomTag","expanderOpen","setExpanderOpen","Expander","notificationPanelClasses","ariaRole","ariaLabelAttributes","getAriaLabelAttributes","AnalyticsId","NotificationBadge","IconSize","Close","getColor","NotificationPanel$1"],"mappings":";;;;;;;;;;AA8DA,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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A,IACCM,KACEL,gBAAAA,EAAA,cAAA,QAAA,EAAK,WAAWD,EAAO,2BAA2B,EACjD,GAAAC,gBAAAA,EAAA,cAACqC,GAAM,EAAA,WAAWnC,EAAM,mBAAmB,SAAAI,GAAkB,OAAOgC,EAAS,OAAO,GAAG,CACzF;AAAA,IAEDjB,EAAc;AAAA,EAAA,CAEnB;AAEJ,CAAC,GAEDkB,KAAetC;"}
|
|
@@ -98,6 +98,20 @@
|
|
|
98
98
|
border: none;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
&--error {
|
|
102
|
+
border: 0.125rem solid $cherry700;
|
|
103
|
+
background-color: $cherry50;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&--error#{&}--compact {
|
|
107
|
+
box-shadow: none;
|
|
108
|
+
background-color: transparent;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&--error#{&}--compact--basic {
|
|
112
|
+
border: none;
|
|
113
|
+
}
|
|
114
|
+
|
|
101
115
|
&--success {
|
|
102
116
|
border: 0.125rem solid $kiwi900;
|
|
103
117
|
background-color: $kiwi50;
|
|
@@ -20,6 +20,7 @@ export type Styles = {
|
|
|
20
20
|
'notification-panel--compact--basic': string;
|
|
21
21
|
'notification-panel--compact--outline': string;
|
|
22
22
|
'notification-panel--dismissable': string;
|
|
23
|
+
'notification-panel--error': string;
|
|
23
24
|
'notification-panel--info': string;
|
|
24
25
|
'notification-panel--large': string;
|
|
25
26
|
'notification-panel--medium': string;
|
|
@@ -1,101 +1,92 @@
|
|
|
1
|
-
import e, { useState as
|
|
2
|
-
import
|
|
3
|
-
import { useBreakpoint as
|
|
4
|
-
import { useHover as
|
|
5
|
-
import { useUuid as
|
|
6
|
-
import { getColor as
|
|
7
|
-
import { breakpoints as
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { Icon as
|
|
12
|
-
import { IconSize as
|
|
13
|
-
import L from "../Icons/CheckFill.js";
|
|
1
|
+
import e, { useState as h } from "react";
|
|
2
|
+
import p from "classnames";
|
|
3
|
+
import { useBreakpoint as z } from "../../hooks/useBreakpoint.js";
|
|
4
|
+
import { useHover as u } from "../../hooks/useHover.js";
|
|
5
|
+
import { useUuid as w } from "../../hooks/useUuid.js";
|
|
6
|
+
import { getColor as H } from "../../theme/currys/color.js";
|
|
7
|
+
import { breakpoints as L } from "../../theme/grid.js";
|
|
8
|
+
import { getAriaLabelAttributes as M } from "../../utils/accessibility.js";
|
|
9
|
+
import X from "../Badge/NotificationBadge.js";
|
|
10
|
+
import y from "../Close/Close.js";
|
|
11
|
+
import { Icon as C } from "../Icon/Icon.js";
|
|
12
|
+
import { IconSize as E } from "../../constants.js";
|
|
14
13
|
import A from "../Icons/ChevronDown.js";
|
|
15
14
|
import U from "../Icons/ChevronUp.js";
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const d = w(), { isHovered: o, hoverRef: p } = h(), a = d < M.lg ? N.XSmall : N.Small, C = {
|
|
24
|
-
info: /* @__PURE__ */ e.createElement(n, { svgIcon: B, color: t.blueberry700, hoverColor: t.blueberry700, size: a, isHovered: o }),
|
|
25
|
-
warn: /* @__PURE__ */ e.createElement(n, { svgIcon: $, color: t.banana700, hoverColor: t.banana700, size: a, isHovered: o }),
|
|
26
|
-
alert: /* @__PURE__ */ e.createElement(n, { svgIcon: q, color: t.cherry700, hoverColor: t.cherry700, size: a, isHovered: o }),
|
|
27
|
-
success: /* @__PURE__ */ e.createElement(n, { svgIcon: L, color: t.kiwi900, hoverColor: t.kiwi900, size: a, isHovered: o })
|
|
28
|
-
}, b = s ? "button" : "span", E = u(
|
|
29
|
-
r["service-message__label-container"],
|
|
30
|
-
s && r["service-message__label-container--has-expander"]
|
|
15
|
+
import B from "../Icons/Forward.js";
|
|
16
|
+
import $ from "../Icons/X.js";
|
|
17
|
+
import s from "../ServiceMessage/styles.module.scss";
|
|
18
|
+
const j = ({ label: c, variant: t, id: m, hasExpander: r, isExpanded: i, dismissable: v, onExpand: l, onDismiss: _, closeBtnText: n }) => {
|
|
19
|
+
const g = z(), { isHovered: a, hoverRef: d } = u(), o = g < L.lg ? E.XSmall : E.Small, N = r ? "button" : "span", f = p(
|
|
20
|
+
s["service-message__label-container"],
|
|
21
|
+
r && s["service-message__label-container--has-expander"]
|
|
31
22
|
);
|
|
32
|
-
return /* @__PURE__ */ e.createElement("div", { className:
|
|
33
|
-
|
|
23
|
+
return /* @__PURE__ */ e.createElement("div", { className: f, ref: d }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__container"] }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__row"] }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__col"] }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__label"] }, /* @__PURE__ */ e.createElement(X, { variant: t == "alert" ? "error" : t, size: o, isHovered: a }), /* @__PURE__ */ e.createElement("h1", { className: s["service-message__title"], id: m }, /* @__PURE__ */ e.createElement(
|
|
24
|
+
N,
|
|
34
25
|
{
|
|
35
|
-
className:
|
|
36
|
-
onClick:
|
|
37
|
-
"aria-expanded":
|
|
26
|
+
className: s["service-message__toggle"],
|
|
27
|
+
onClick: r ? l : void 0,
|
|
28
|
+
"aria-expanded": r ? i : void 0
|
|
38
29
|
},
|
|
39
30
|
c
|
|
40
|
-
)),
|
|
41
|
-
},
|
|
42
|
-
const { hoverRef:
|
|
43
|
-
return /* @__PURE__ */ e.createElement("div", { className:
|
|
31
|
+
)), r && /* @__PURE__ */ e.createElement(C, { size: o, svgIcon: i ? U : A, isHovered: a }), !r && v && /* @__PURE__ */ e.createElement(y, { onClick: _, ariaLabel: n, className: s["service-message__close"] }))))));
|
|
32
|
+
}, F = ({ info: c, extraInfo: t, urlTitle: m, url: r, target: i, dismissable: v, closeBtnText: l, onDismiss: _ }) => {
|
|
33
|
+
const { hoverRef: n, isHovered: g } = u(), { hoverRef: a, isHovered: d } = u(), o = r && m;
|
|
34
|
+
return /* @__PURE__ */ e.createElement("div", { className: s["service-message__container"] }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__row"] }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__col"] }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__content"] }, c && /* @__PURE__ */ e.createElement("p", { className: s["service-message__info"] }, c), t && /* @__PURE__ */ e.createElement("p", { className: p(s["service-message__info"], s["service-message__info--extra"]) }, t), /* @__PURE__ */ e.createElement("div", { className: s["service-message__actions"] }, o && /* @__PURE__ */ e.createElement("a", { className: s["service-message__action"], href: r, ref: n, target: i }, m, /* @__PURE__ */ e.createElement(C, { size: E.XSmall, svgIcon: B, color: H("blueberry", 700), isHovered: g })), v && /* @__PURE__ */ e.createElement(
|
|
44
35
|
"button",
|
|
45
36
|
{
|
|
46
|
-
ref:
|
|
47
|
-
className:
|
|
48
|
-
"aria-label":
|
|
49
|
-
onClick:
|
|
37
|
+
ref: a,
|
|
38
|
+
className: p(s["service-message__action"], s["service-message__action--close"]),
|
|
39
|
+
"aria-label": l,
|
|
40
|
+
onClick: _
|
|
50
41
|
},
|
|
51
|
-
|
|
52
|
-
/* @__PURE__ */ e.createElement(
|
|
42
|
+
l,
|
|
43
|
+
/* @__PURE__ */ e.createElement(C, { size: E.XSmall, svgIcon: $, color: H("blueberry", 700), isHovered: d })
|
|
53
44
|
))))));
|
|
54
|
-
},
|
|
45
|
+
}, q = ({
|
|
55
46
|
label: c,
|
|
56
|
-
dismissable:
|
|
47
|
+
dismissable: t = !0,
|
|
57
48
|
onDismiss: m,
|
|
58
|
-
info:
|
|
49
|
+
info: r,
|
|
59
50
|
extraInfo: i,
|
|
60
|
-
urlTitle:
|
|
61
|
-
url:
|
|
62
|
-
target:
|
|
63
|
-
closeBtnText:
|
|
64
|
-
expanderOpenFromStart:
|
|
65
|
-
variant:
|
|
66
|
-
testId:
|
|
51
|
+
urlTitle: v,
|
|
52
|
+
url: l,
|
|
53
|
+
target: _ = "_self",
|
|
54
|
+
closeBtnText: n = "fjern melding",
|
|
55
|
+
expanderOpenFromStart: g = !1,
|
|
56
|
+
variant: a = "error",
|
|
57
|
+
testId: d
|
|
67
58
|
}) => {
|
|
68
|
-
const [
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
return /* @__PURE__ */ e.createElement("div", { className:
|
|
72
|
-
|
|
59
|
+
const [o, N] = h(g), f = w(), b = !!r || !!i, S = a === "alert" || a === "error" ? "alert" : "region", R = M({ label: c, id: f }), k = () => {
|
|
60
|
+
b && N(!o);
|
|
61
|
+
}, I = p(s["service-message"], s[`service-message--${a}`]);
|
|
62
|
+
return /* @__PURE__ */ e.createElement("div", { className: I, role: S, ...R, "data-testid": d }, /* @__PURE__ */ e.createElement(
|
|
63
|
+
j,
|
|
73
64
|
{
|
|
74
65
|
label: c,
|
|
75
|
-
variant:
|
|
76
|
-
id:
|
|
77
|
-
hasExpander:
|
|
78
|
-
isExpanded:
|
|
79
|
-
dismissable:
|
|
80
|
-
onExpand:
|
|
66
|
+
variant: a,
|
|
67
|
+
id: f,
|
|
68
|
+
hasExpander: b,
|
|
69
|
+
isExpanded: o,
|
|
70
|
+
dismissable: t,
|
|
71
|
+
onExpand: k,
|
|
81
72
|
onDismiss: m,
|
|
82
|
-
closeBtnText:
|
|
73
|
+
closeBtnText: n
|
|
83
74
|
}
|
|
84
|
-
),
|
|
85
|
-
|
|
75
|
+
), b && o && /* @__PURE__ */ e.createElement(
|
|
76
|
+
F,
|
|
86
77
|
{
|
|
87
|
-
info:
|
|
78
|
+
info: r,
|
|
88
79
|
extraInfo: i,
|
|
89
|
-
urlTitle:
|
|
90
|
-
url:
|
|
91
|
-
target:
|
|
92
|
-
dismissable:
|
|
80
|
+
urlTitle: v,
|
|
81
|
+
url: l,
|
|
82
|
+
target: _,
|
|
83
|
+
dismissable: t,
|
|
93
84
|
onDismiss: m,
|
|
94
|
-
closeBtnText:
|
|
85
|
+
closeBtnText: n
|
|
95
86
|
}
|
|
96
87
|
));
|
|
97
|
-
},
|
|
88
|
+
}, te = q;
|
|
98
89
|
export {
|
|
99
|
-
|
|
90
|
+
te as default
|
|
100
91
|
};
|
|
101
92
|
//# sourceMappingURL=ServiceMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceMessage.js","sources":["../../../src/components/ServiceMessage/ServiceMessage.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { breakpoints } from '../../theme/grid';\nimport { palette } from '../../theme/palette';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { AnchorLinkTargets } from '../AnchorLink';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport CheckFill from '../Icons/CheckFill';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronUp from '../Icons/ChevronUp';\nimport ErrorSignFill from '../Icons/ErrorSignFill';\nimport Forward from '../Icons/Forward';\nimport InfoSignFill from '../Icons/InfoSignFill';\nimport TriangleX from '../Icons/TriangleX';\nimport X from '../Icons/X';\nimport { NotificationPanelVariants } from '../NotificationPanel';\n\nimport styles from './styles.module.scss';\n\ninterface LabelProps {\n label: string;\n variant: NotificationPanelVariants;\n id: string;\n hasExpander: boolean;\n isExpanded: boolean;\n dismissable: boolean;\n onExpand: () => void;\n onDismiss?: () => void;\n closeBtnText?: string;\n}\n\nconst Label: React.FC<LabelProps> = ({ label, variant, id, hasExpander, isExpanded, dismissable, onExpand, onDismiss, closeBtnText }) => {\n const breakpoint = useBreakpoint();\n const { isHovered, hoverRef } = useHover<HTMLDivElement>();\n\n const iconSize = breakpoint < breakpoints.lg ? IconSize.XSmall : IconSize.Small;\n const variantToIconMap = {\n info: (\n <Icon svgIcon={InfoSignFill} color={palette.blueberry700} hoverColor={palette.blueberry700} size={iconSize} isHovered={isHovered} />\n ),\n warn: <Icon svgIcon={ErrorSignFill} color={palette.banana700} hoverColor={palette.banana700} size={iconSize} isHovered={isHovered} />,\n alert: <Icon svgIcon={TriangleX} color={palette.cherry700} hoverColor={palette.cherry700} size={iconSize} isHovered={isHovered} />,\n success: <Icon svgIcon={CheckFill} color={palette.kiwi900} hoverColor={palette.kiwi900} size={iconSize} isHovered={isHovered} />,\n };\n const CustomTag = hasExpander ? 'button' : 'span';\n\n const labelContainerClasses = classNames(\n styles['service-message__label-container'],\n hasExpander && styles[`service-message__label-container--has-expander`]\n );\n\n return (\n <div className={labelContainerClasses} ref={hoverRef}>\n <div className={styles['service-message__container']}>\n <div className={styles['service-message__row']}>\n <div className={styles['service-message__col']}>\n <div className={styles['service-message__label']}>\n {variantToIconMap[variant]}\n <h1 className={styles['service-message__title']} id={id}>\n <CustomTag\n className={styles['service-message__toggle']}\n onClick={hasExpander ? onExpand : undefined}\n aria-expanded={hasExpander ? isExpanded : undefined}\n >\n {label}\n </CustomTag>\n </h1>\n {hasExpander && <Icon size={iconSize} svgIcon={isExpanded ? ChevronUp : ChevronDown} isHovered={isHovered} />}\n {!hasExpander && dismissable && (\n <Close onClick={onDismiss} ariaLabel={closeBtnText} className={styles['service-message__close']} />\n )}\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\ninterface ContentProps {\n info?: string;\n extraInfo?: string;\n urlTitle?: string;\n url?: string;\n target?: AnchorLinkTargets;\n dismissable: boolean;\n onDismiss?: () => void;\n closeBtnText?: string;\n}\n\nconst Content: React.FC<ContentProps> = ({ info, extraInfo, urlTitle, url, target, dismissable, closeBtnText, onDismiss }) => {\n const { hoverRef: readMoreRef, isHovered: readMoreHoverRefIsHovered } = useHover<HTMLAnchorElement>();\n const { hoverRef: closeButtonRef, isHovered: closeButtonIsHovered } = useHover<HTMLButtonElement>();\n\n const hasUrl = url && urlTitle;\n\n return (\n <div className={styles['service-message__container']}>\n <div className={styles['service-message__row']}>\n <div className={styles['service-message__col']}>\n <div className={styles['service-message__content']}>\n {info && <p className={styles['service-message__info']}>{info}</p>}\n {extraInfo && (\n <p className={classNames(styles['service-message__info'], styles['service-message__info--extra'])}>{extraInfo}</p>\n )}\n <div className={styles['service-message__actions']}>\n {hasUrl && (\n <a className={styles['service-message__action']} href={url} ref={readMoreRef} target={target}>\n {urlTitle}\n <Icon size={IconSize.XSmall} svgIcon={Forward} color={getColor('blueberry', 700)} isHovered={readMoreHoverRefIsHovered} />\n </a>\n )}\n\n {dismissable && (\n <button\n ref={closeButtonRef}\n className={classNames(styles['service-message__action'], styles['service-message__action--close'])}\n aria-label={closeBtnText}\n onClick={onDismiss}\n >\n {closeBtnText}\n <Icon size={IconSize.XSmall} svgIcon={X} color={getColor('blueberry', 700)} isHovered={closeButtonIsHovered} />\n </button>\n )}\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport interface ServiceMessageProps {\n /** Sets a label for the notification panel. */\n label: string;\n /** String displayed in service-message when expanded */\n info?: string;\n /** String displayed in service-message when expanded, with a smaller font */\n extraInfo?: string;\n /** function that runs on dismiss */\n onDismiss?: () => void;\n /** Allows for dismiss to be an option, also for ServiceMessage with only label as content */\n dismissable?: boolean;\n /** Makes expander be open from start. */\n expanderOpenFromStart?: boolean;\n /** Name that describes a url-link for the user*/\n urlTitle?: string;\n /** Url for further information*/\n url?: string;\n /** Sets target for the anchorlink to the url*/\n target?: AnchorLinkTargets;\n /** Text on close-button in service messages. */\n closeBtnText?: string;\n /** Changes the visual representation. */\n variant?: NotificationPanelVariants;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst ServiceMessage: React.FC<ServiceMessageProps> = ({\n label,\n dismissable = true,\n onDismiss,\n info,\n extraInfo,\n urlTitle,\n url,\n target = '_self',\n closeBtnText = 'fjern melding',\n expanderOpenFromStart = false,\n variant = 'alert',\n testId,\n}) => {\n const [isExpanded, setIsExpanded] = useState<boolean>(expanderOpenFromStart);\n\n const labelId = useUuid();\n const hasExpander = !!info || !!extraInfo;\n\n const ariaRole = variant === 'alert' ? 'alert' : 'region';\n const ariaLabelAttributes = getAriaLabelAttributes({ label, id: labelId });\n\n const handleClick = (): void => {\n hasExpander && setIsExpanded(!isExpanded);\n };\n\n const classes = classNames(styles['service-message'], styles[`service-message--${variant}`]);\n\n return (\n <div className={classes} role={ariaRole} {...ariaLabelAttributes} data-testid={testId}>\n <Label\n label={label}\n variant={variant}\n id={labelId}\n hasExpander={hasExpander}\n isExpanded={isExpanded}\n dismissable={dismissable}\n onExpand={handleClick}\n onDismiss={onDismiss}\n closeBtnText={closeBtnText}\n />\n {hasExpander && isExpanded && (\n <Content\n info={info}\n extraInfo={extraInfo}\n urlTitle={urlTitle}\n url={url}\n target={target}\n dismissable={dismissable}\n onDismiss={onDismiss}\n closeBtnText={closeBtnText}\n />\n )}\n </div>\n );\n};\n\nexport default ServiceMessage;\n"],"names":["Label","label","variant","id","hasExpander","isExpanded","dismissable","onExpand","onDismiss","closeBtnText","breakpoint","useBreakpoint","isHovered","hoverRef","useHover","iconSize","breakpoints","IconSize","variantToIconMap","React","Icon","InfoSignFill","palette","ErrorSignFill","TriangleX","CheckFill","CustomTag","labelContainerClasses","classNames","styles","ChevronUp","ChevronDown","Close","Content","info","extraInfo","urlTitle","url","target","readMoreRef","readMoreHoverRefIsHovered","closeButtonRef","closeButtonIsHovered","hasUrl","Forward","getColor","X","ServiceMessage","expanderOpenFromStart","testId","setIsExpanded","useState","labelId","useUuid","ariaRole","ariaLabelAttributes","getAriaLabelAttributes","handleClick","classes","ServiceMessage$1"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCA,MAAMA,IAA8B,CAAC,EAAE,OAAAC,GAAO,SAAAC,GAAS,IAAAC,GAAI,aAAAC,GAAa,YAAAC,GAAY,aAAAC,GAAa,UAAAC,GAAU,WAAAC,GAAW,cAAAC,EAAA,MAAmB;AACvI,QAAMC,IAAaC,KACb,EAAE,WAAAC,GAAW,UAAAC,EAAS,IAAIC,EAAyB,GAEnDC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AaN,EAC7E,GAAA9B,gBAAAA,EAAA;AAAA,IAACnB;AAAA,IAAA;AAAA,MACC,OAAAC;AAAA,MACA,SAAAC;AAAA,MACA,IAAIkD;AAAA,MACJ,aAAAhD;AAAA,MACA,YAAAC;AAAA,MACA,aAAAC;AAAA,MACA,UAAUmD;AAAA,MACV,WAAAjD;AAAA,MACA,cAAAC;AAAA,IAAA;AAAA,EAAA,GAEDL,KAAeC,KACdc,gBAAAA,EAAA;AAAA,IAACc;AAAA,IAAA;AAAA,MACC,MAAAC;AAAA,MACA,WAAAC;AAAA,MACA,UAAAC;AAAA,MACA,KAAAC;AAAA,MACA,QAAAC;AAAA,MACA,aAAAhC;AAAA,MACA,WAAAE;AAAA,MACA,cAAAC;AAAA,IAAA;AAAA,EAAA,CAGN;AAEJ,GAEAkD,KAAeZ;"}
|
|
1
|
+
{"version":3,"file":"ServiceMessage.js","sources":["../../../src/components/ServiceMessage/ServiceMessage.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { breakpoints } from '../../theme/grid';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { AnchorLinkTargets } from '../AnchorLink';\nimport NotificationBadge from '../Badge/NotificationBadge';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronUp from '../Icons/ChevronUp';\nimport Forward from '../Icons/Forward';\nimport X from '../Icons/X';\nimport { NotificationPanelVariants } from '../NotificationPanel';\n\nimport styles from './styles.module.scss';\n\ninterface LabelProps {\n label: string;\n variant: NotificationPanelVariants;\n id: string;\n hasExpander: boolean;\n isExpanded: boolean;\n dismissable: boolean;\n onExpand: () => void;\n onDismiss?: () => void;\n closeBtnText?: string;\n}\n\nconst Label: React.FC<LabelProps> = ({ label, variant, id, hasExpander, isExpanded, dismissable, onExpand, onDismiss, closeBtnText }) => {\n const breakpoint = useBreakpoint();\n const { isHovered, hoverRef } = useHover<HTMLDivElement>();\n\n const iconSize = breakpoint < breakpoints.lg ? IconSize.XSmall : IconSize.Small;\n const CustomTag = hasExpander ? 'button' : 'span';\n\n const labelContainerClasses = classNames(\n styles['service-message__label-container'],\n hasExpander && styles[`service-message__label-container--has-expander`]\n );\n\n return (\n <div className={labelContainerClasses} ref={hoverRef}>\n <div className={styles['service-message__container']}>\n <div className={styles['service-message__row']}>\n <div className={styles['service-message__col']}>\n <div className={styles['service-message__label']}>\n <NotificationBadge variant={variant == 'alert' ? 'error' : variant} size={iconSize} isHovered={isHovered} />\n <h1 className={styles['service-message__title']} id={id}>\n <CustomTag\n className={styles['service-message__toggle']}\n onClick={hasExpander ? onExpand : undefined}\n aria-expanded={hasExpander ? isExpanded : undefined}\n >\n {label}\n </CustomTag>\n </h1>\n {hasExpander && <Icon size={iconSize} svgIcon={isExpanded ? ChevronUp : ChevronDown} isHovered={isHovered} />}\n {!hasExpander && dismissable && (\n <Close onClick={onDismiss} ariaLabel={closeBtnText} className={styles['service-message__close']} />\n )}\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\ninterface ContentProps {\n info?: string;\n extraInfo?: string;\n urlTitle?: string;\n url?: string;\n target?: AnchorLinkTargets;\n dismissable: boolean;\n onDismiss?: () => void;\n closeBtnText?: string;\n}\n\nconst Content: React.FC<ContentProps> = ({ info, extraInfo, urlTitle, url, target, dismissable, closeBtnText, onDismiss }) => {\n const { hoverRef: readMoreRef, isHovered: readMoreHoverRefIsHovered } = useHover<HTMLAnchorElement>();\n const { hoverRef: closeButtonRef, isHovered: closeButtonIsHovered } = useHover<HTMLButtonElement>();\n\n const hasUrl = url && urlTitle;\n\n return (\n <div className={styles['service-message__container']}>\n <div className={styles['service-message__row']}>\n <div className={styles['service-message__col']}>\n <div className={styles['service-message__content']}>\n {info && <p className={styles['service-message__info']}>{info}</p>}\n {extraInfo && (\n <p className={classNames(styles['service-message__info'], styles['service-message__info--extra'])}>{extraInfo}</p>\n )}\n <div className={styles['service-message__actions']}>\n {hasUrl && (\n <a className={styles['service-message__action']} href={url} ref={readMoreRef} target={target}>\n {urlTitle}\n <Icon size={IconSize.XSmall} svgIcon={Forward} color={getColor('blueberry', 700)} isHovered={readMoreHoverRefIsHovered} />\n </a>\n )}\n\n {dismissable && (\n <button\n ref={closeButtonRef}\n className={classNames(styles['service-message__action'], styles['service-message__action--close'])}\n aria-label={closeBtnText}\n onClick={onDismiss}\n >\n {closeBtnText}\n <Icon size={IconSize.XSmall} svgIcon={X} color={getColor('blueberry', 700)} isHovered={closeButtonIsHovered} />\n </button>\n )}\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport interface ServiceMessageProps {\n /** Sets a label for the notification panel. */\n label: string;\n /** String displayed in service-message when expanded */\n info?: string;\n /** String displayed in service-message when expanded, with a smaller font */\n extraInfo?: string;\n /** function that runs on dismiss */\n onDismiss?: () => void;\n /** Allows for dismiss to be an option, also for ServiceMessage with only label as content */\n dismissable?: boolean;\n /** Makes expander be open from start. */\n expanderOpenFromStart?: boolean;\n /** Name that describes a url-link for the user*/\n urlTitle?: string;\n /** Url for further information*/\n url?: string;\n /** Sets target for the anchorlink to the url*/\n target?: AnchorLinkTargets;\n /** Text on close-button in service messages. */\n closeBtnText?: string;\n /** Changes the visual representation. */\n variant?: NotificationPanelVariants;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst ServiceMessage: React.FC<ServiceMessageProps> = ({\n label,\n dismissable = true,\n onDismiss,\n info,\n extraInfo,\n urlTitle,\n url,\n target = '_self',\n closeBtnText = 'fjern melding',\n expanderOpenFromStart = false,\n variant = 'error',\n testId,\n}) => {\n const [isExpanded, setIsExpanded] = useState<boolean>(expanderOpenFromStart);\n\n const labelId = useUuid();\n const hasExpander = !!info || !!extraInfo;\n\n const ariaRole = variant === 'alert' || variant === 'error' ? 'alert' : 'region';\n const ariaLabelAttributes = getAriaLabelAttributes({ label, id: labelId });\n\n const handleClick = (): void => {\n hasExpander && setIsExpanded(!isExpanded);\n };\n\n const classes = classNames(styles['service-message'], styles[`service-message--${variant}`]);\n\n return (\n <div className={classes} role={ariaRole} {...ariaLabelAttributes} data-testid={testId}>\n <Label\n label={label}\n variant={variant}\n id={labelId}\n hasExpander={hasExpander}\n isExpanded={isExpanded}\n dismissable={dismissable}\n onExpand={handleClick}\n onDismiss={onDismiss}\n closeBtnText={closeBtnText}\n />\n {hasExpander && isExpanded && (\n <Content\n info={info}\n extraInfo={extraInfo}\n urlTitle={urlTitle}\n url={url}\n target={target}\n dismissable={dismissable}\n onDismiss={onDismiss}\n closeBtnText={closeBtnText}\n />\n )}\n </div>\n );\n};\n\nexport default ServiceMessage;\n"],"names":["Label","label","variant","id","hasExpander","isExpanded","dismissable","onExpand","onDismiss","closeBtnText","breakpoint","useBreakpoint","isHovered","hoverRef","useHover","iconSize","breakpoints","IconSize","CustomTag","labelContainerClasses","classNames","styles","React","NotificationBadge","Icon","ChevronUp","ChevronDown","Close","Content","info","extraInfo","urlTitle","url","target","readMoreRef","readMoreHoverRefIsHovered","closeButtonRef","closeButtonIsHovered","hasUrl","Forward","getColor","X","ServiceMessage","expanderOpenFromStart","testId","setIsExpanded","useState","labelId","useUuid","ariaRole","ariaLabelAttributes","getAriaLabelAttributes","handleClick","classes","ServiceMessage$1"],"mappings":";;;;;;;;;;;;;;;;;AAkCA,MAAMA,IAA8B,CAAC,EAAE,OAAAC,GAAO,SAAAC,GAAS,IAAAC,GAAI,aAAAC,GAAa,YAAAC,GAAY,aAAAC,GAAa,UAAAC,GAAU,WAAAC,GAAW,cAAAC,EAAA,MAAmB;AACvI,QAAMC,IAAaC,KACb,EAAE,WAAAC,GAAW,UAAAC,EAAS,IAAIC,EAAyB,GAEnDC,IAAWL,IAAaM,EAAY,KAAKC,EAAS,SAASA,EAAS,OACpEC,IAAYd,IAAc,WAAW,QAErCe,IAAwB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 -67,6 +67,19 @@
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
&--error {
|
|
71
|
+
background-color: $cherry50;
|
|
72
|
+
|
|
73
|
+
&:hover {
|
|
74
|
+
background-color: rgba-to-rgb(rgba($cherry500, 0.1), $cherry50);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&#{$servicemessage},
|
|
78
|
+
&#{$servicemessage}__label-container {
|
|
79
|
+
border-color: $cherry700;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
70
83
|
&__container {
|
|
71
84
|
@include make-container;
|
|
72
85
|
@include make-container-max-widths;
|
|
@@ -16,6 +16,7 @@ export type Styles = {
|
|
|
16
16
|
'service-message__title': string;
|
|
17
17
|
'service-message__toggle': string;
|
|
18
18
|
'service-message--alert': string;
|
|
19
|
+
'service-message--error': string;
|
|
19
20
|
'service-message--info': string;
|
|
20
21
|
'service-message--success': string;
|
|
21
22
|
'service-message--warn': string;
|
package/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import e, { useState as f } from "react";
|
|
2
|
-
import n from "classnames";
|
|
3
|
-
import { AnalyticsId as _ } from "../../../constants.js";
|
|
4
|
-
import { useUuid as u } from "../../../hooks/useUuid.js";
|
|
5
|
-
import { getAriaLabelAttributes as b } from "../../../utils/accessibility.js";
|
|
6
|
-
import v from "../../Button/Button.js";
|
|
7
|
-
import { Icon as x } from "../../Icon/Icon.js";
|
|
8
|
-
import E from "../../Icons/ChevronDown.js";
|
|
9
|
-
import I from "../../Icons/ChevronUp.js";
|
|
10
|
-
import a from "../../NotificationPanel/DetailButton/styles.module.scss";
|
|
11
|
-
const T = ({ content: i, buttonText: r, buttonClosedText: s, expanderOpenFromStart: c }) => {
|
|
12
|
-
const [t, l] = f(c), o = t ? r : s, m = u(), p = b({
|
|
13
|
-
label: o,
|
|
14
|
-
id: m,
|
|
15
|
-
prefer: "label"
|
|
16
|
-
}), d = {
|
|
17
|
-
onClick: () => l(!t),
|
|
18
|
-
variant: "borderless",
|
|
19
|
-
className: n(a["notification-panel__detail"], a["notification-panel__detail-button"]),
|
|
20
|
-
"aria-expanded": t,
|
|
21
|
-
...p
|
|
22
|
-
};
|
|
23
|
-
return /* @__PURE__ */ e.createElement("div", { className: a["notification-panel__detail-section"] }, /* @__PURE__ */ e.createElement("div", { className: a["notification-panel__detail-section__button--wrapper"] }, /* @__PURE__ */ e.createElement(v, { testId: "expand", "data-analyticsid": _.Expander, ...d }, o, /* @__PURE__ */ e.createElement(x, { svgIcon: t ? I : E }))), t && /* @__PURE__ */ e.createElement("div", { className: n(a["notification-panel__detail-section__content"]) }, i));
|
|
24
|
-
};
|
|
25
|
-
export {
|
|
26
|
-
T as DetailButton
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=DetailButton.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DetailButton.js","sources":["../../../../src/components/NotificationPanel/DetailButton/DetailButton.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../../constants';\nimport { useUuid } from '../../../hooks/useUuid';\nimport { AriaLabelAttributes, getAriaLabelAttributes } from '../../../utils/accessibility';\nimport Button, { ButtonProps } from '../../Button';\nimport Icon from '../../Icon';\nimport ChevronDown from '../../Icons/ChevronDown';\nimport ChevronUp from '../../Icons/ChevronUp';\n\nimport styles from './styles.module.scss';\n\ntype Props = {\n content: React.ReactNode;\n buttonClosedText: string;\n buttonText: string;\n expanderOpenFromStart: boolean;\n};\nexport const DetailButton: React.FC<Props> = ({ content, buttonText, buttonClosedText, expanderOpenFromStart }: Props): JSX.Element => {\n const [isExpanded, setIsExpanded] = useState<boolean>(expanderOpenFromStart);\n const activeButtonText = isExpanded ? buttonText : buttonClosedText;\n\n const buttonTextId = useUuid();\n\n const ariaLabelAttributes = getAriaLabelAttributes({\n label: activeButtonText,\n id: buttonTextId,\n prefer: 'label',\n });\n\n const commonProps: Partial<ButtonProps> & AriaLabelAttributes = {\n onClick: () => setIsExpanded(!isExpanded),\n variant: 'borderless',\n className: classNames(styles['notification-panel__detail'], styles['notification-panel__detail-button']),\n 'aria-expanded': isExpanded,\n ...ariaLabelAttributes,\n };\n\n return (\n <div className={styles['notification-panel__detail-section']}>\n <div className={styles['notification-panel__detail-section__button--wrapper']}>\n <Button testId=\"expand\" data-analyticsid={AnalyticsId.Expander} {...commonProps}>\n {activeButtonText}\n <Icon svgIcon={isExpanded ? ChevronUp : ChevronDown} />\n </Button>\n </div>\n {isExpanded && <div className={classNames(styles['notification-panel__detail-section__content'])}>{content}</div>}\n </div>\n );\n};\n"],"names":["DetailButton","content","buttonText","buttonClosedText","expanderOpenFromStart","isExpanded","setIsExpanded","useState","activeButtonText","buttonTextId","useUuid","ariaLabelAttributes","getAriaLabelAttributes","commonProps","classNames","styles","React","Button","AnalyticsId","Icon","ChevronUp","ChevronDown"],"mappings":";;;;;;;;;;AAoBO,MAAMA,IAAgC,CAAC,EAAE,SAAAC,GAAS,YAAAC,GAAY,kBAAAC,GAAkB,uBAAAC,QAAgD;AACrI,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAkBH,CAAqB,GACrEI,IAAmBH,IAAaH,IAAaC,GAE7CM,IAAeC,KAEfC,IAAsBC,EAAuB;AAAA,IACjD,OAAOJ;AAAA,IACP,IAAIC;AAAA,IACJ,QAAQ;AAAA,EAAA,CACT,GAEKI,IAA0D;AAAA,IAC9D,SAAS,MAAMP,EAAc,CAACD,CAAU;AAAA,IACxC,SAAS;AAAA,IACT,WAAWS,EAAWC,EAAO,4BAA4B,GAAGA,EAAO,mCAAmC,CAAC;AAAA,IACvG,iBAAiBV;AAAA,IACjB,GAAGM;AAAA,EAAA;AAGL,yCACG,OAAI,EAAA,WAAWI,EAAO,oCAAoC,EAAA,mCACxD,OAAI,EAAA,WAAWA,EAAO,qDAAqD,KACzEC,gBAAAA,EAAA,cAAAC,GAAA,EAAO,QAAO,UAAS,oBAAkBC,EAAY,UAAW,GAAGL,EACjE,GAAAL,mCACAW,GAAK,EAAA,SAASd,IAAae,IAAYC,EAAA,CAAa,CACvD,CACF,GACChB,KAAeW,gBAAAA,EAAA,cAAA,OAAA,EAAI,WAAWF,EAAWC,EAAO,6CAA6C,CAAC,KAAId,CAAQ,CAC7G;AAEJ;"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
@import '../../../scss/spacers';
|
|
2
|
-
@import '../../../scss/breakpoints';
|
|
3
|
-
@import '../../../scss/font-settings';
|
|
4
|
-
@import '../../../scss/palette';
|
|
5
|
-
|
|
6
|
-
.notification-panel__detail-section {
|
|
7
|
-
display: flex;
|
|
8
|
-
flex-direction: column-reverse;
|
|
9
|
-
|
|
10
|
-
&__button--wrapper {
|
|
11
|
-
padding: 0.375rem 0 0.625rem;
|
|
12
|
-
font-size: $font-size-xs;
|
|
13
|
-
line-height: $lineheight-size-xs;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&__content {
|
|
17
|
-
padding: getSpacer(3xs) 0;
|
|
18
|
-
font-size: $font-size-xs;
|
|
19
|
-
line-height: $lineheight-size-xs;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
html .notification-panel__detail.notification-panel__detail-button {
|
|
24
|
-
text-decoration: underline;
|
|
25
|
-
text-decoration-color: $blueberry600;
|
|
26
|
-
margin-left: -0.25rem;
|
|
27
|
-
padding: 0 0 0 getSpacer(3xs);
|
|
28
|
-
white-space: nowrap;
|
|
29
|
-
overflow: initial;
|
|
30
|
-
text-overflow: clip;
|
|
31
|
-
font-size: $font-size-sm;
|
|
32
|
-
line-height: 1.625rem;
|
|
33
|
-
height: 1.625rem;
|
|
34
|
-
|
|
35
|
-
@media (width >= 0) {
|
|
36
|
-
min-height: unset;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type Styles = {
|
|
2
|
-
'notification-panel__detail': string;
|
|
3
|
-
'notification-panel__detail-button': string;
|
|
4
|
-
'notification-panel__detail-section': string;
|
|
5
|
-
'notification-panel__detail-section__button--wrapper': string;
|
|
6
|
-
'notification-panel__detail-section__content': string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type ClassNames = keyof Styles;
|
|
10
|
-
|
|
11
|
-
declare const styles: Styles;
|
|
12
|
-
|
|
13
|
-
export default styles;
|