@helsenorge/designsystem-react 7.13.4 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -3
- package/__mocks__/matchMedia.d.ts +1 -1
- package/components/Checkbox/Checkbox.js +47 -46
- package/components/Checkbox/Checkbox.js.map +1 -1
- package/components/Checkbox/styles.module.scss +101 -29
- package/components/Checkbox/styles.module.scss.d.ts +0 -1
- package/components/Chip/Chip.d.ts +31 -0
- package/components/Chip/Chip.js +30 -0
- package/components/Chip/Chip.js.map +1 -0
- package/components/Chip/index.d.ts +3 -0
- package/components/Chip/index.js +9 -0
- package/components/Chip/styles.module.scss +98 -0
- package/components/Chip/styles.module.scss.d.ts +21 -0
- package/components/ErrorWrapper/ErrorWrapper.js +5 -5
- package/components/ErrorWrapper/ErrorWrapper.js.map +1 -1
- package/components/ErrorWrapper/styles.module.scss +0 -5
- package/components/EyebrowHeader/EyebrowHeader.d.ts +17 -0
- package/components/EyebrowHeader/EyebrowHeader.js +12 -0
- package/components/EyebrowHeader/EyebrowHeader.js.map +1 -0
- package/components/EyebrowHeader/index.d.ts +3 -0
- package/components/EyebrowHeader/index.js +5 -0
- package/components/EyebrowHeader/styles.module.scss +5 -0
- package/components/FormGroup/styles.module.scss +3 -0
- package/components/GridExample/GridExample.d.ts +1 -0
- package/components/GridExample/GridExample.js.map +1 -1
- package/components/HelpPanel/HelpPanel.d.ts +2 -2
- package/components/HelpPanel/HelpPanel.js +10 -10
- package/components/HelpPanel/HelpPanel.js.map +1 -1
- package/components/{HighlightBox/HighlightBox.d.ts → HighlightPanel/HighlightPanel.d.ts} +10 -10
- package/components/HighlightPanel/HighlightPanel.js +61 -0
- package/components/HighlightPanel/HighlightPanel.js.map +1 -0
- package/components/HighlightPanel/index.d.ts +3 -0
- package/components/HighlightPanel/index.js +7 -0
- package/components/HighlightPanel/index.js.map +1 -0
- package/components/{HighlightBox → HighlightPanel}/styles.module.scss +17 -17
- package/components/HighlightPanel/styles.module.scss.d.ts +25 -0
- package/components/HorizontalScroll/HorizontalScroll.d.ts +1 -0
- package/components/HorizontalScroll/HorizontalScroll.js.map +1 -1
- package/components/NotificationPanel/NotificationPanel.d.ts +1 -1
- package/components/NotificationPanel/NotificationPanel.js +23 -23
- package/components/NotificationPanel/NotificationPanel.js.map +1 -1
- package/components/NotificationPanel/styles.module.scss +0 -14
- package/components/NotificationPanel/styles.module.scss.d.ts +0 -1
- package/components/RadioButton/RadioButton.js +42 -41
- package/components/RadioButton/RadioButton.js.map +1 -1
- package/components/RadioButton/styles.module.scss +41 -35
- package/components/ServiceMessage/ServiceMessage.js +25 -25
- package/components/ServiceMessage/ServiceMessage.js.map +1 -1
- package/components/ServiceMessage/styles.module.scss +0 -13
- package/components/ServiceMessage/styles.module.scss.d.ts +0 -1
- package/components/Tabs/Tabs.d.ts +1 -0
- package/components/Tabs/Tabs.js.map +1 -1
- package/components/Tag/Tag.d.ts +3 -9
- package/components/Tag/Tag.js +16 -42
- package/components/Tag/Tag.js.map +1 -1
- package/components/Tag/index.js +5 -6
- package/components/Tag/styles.module.scss +5 -105
- package/components/Tag/styles.module.scss.d.ts +0 -4
- package/components/TagList/TagList.d.ts +1 -0
- package/components/TagList/TagList.js.map +1 -1
- package/components/Tooltip/Tooltip.d.ts +4 -1
- package/components/Tooltip/Tooltip.js.map +1 -1
- package/components/Validation/Validation.d.ts +0 -5
- package/components/Validation/Validation.js +11 -12
- package/components/Validation/Validation.js.map +1 -1
- package/components/Validation/ValidationSummary.js +2 -2
- package/components/Validation/ValidationSummary.js.map +1 -1
- package/components/Validation/styles.module.scss +20 -14
- package/components/Validation/styles.module.scss.d.ts +5 -5
- package/constants.d.ts +5 -2
- package/constants.js +2 -2
- package/constants.js.map +1 -1
- package/package.json +3 -3
- package/scss/supernova/index.css +2 -2
- package/scss/supernova/styles/colors.css +1 -1
- package/utils/tests/setup-test.d.ts +1 -1
- package/_virtual/assert.js +0 -5
- package/_virtual/assert.js.map +0 -1
- package/_virtual/ast.js +0 -5
- package/_virtual/ast.js.map +0 -1
- package/_virtual/code.js +0 -5
- package/_virtual/code.js.map +0 -1
- package/_virtual/doctrine.js +0 -5
- package/_virtual/doctrine.js.map +0 -1
- package/_virtual/errors.js +0 -5
- package/_virtual/errors.js.map +0 -1
- package/_virtual/index.js +0 -5
- package/_virtual/inherits_browser.js +0 -5
- package/_virtual/inherits_browser.js.map +0 -1
- package/_virtual/keyword.js +0 -5
- package/_virtual/keyword.js.map +0 -1
- package/_virtual/typed.js +0 -5
- package/_virtual/typed.js.map +0 -1
- package/_virtual/types.js +0 -5
- package/_virtual/types.js.map +0 -1
- package/_virtual/util.js +0 -5
- package/_virtual/util.js.map +0 -1
- package/_virtual/utility.js +0 -5
- package/_virtual/utility.js.map +0 -1
- package/_virtual/utils.js +0 -5
- package/_virtual/utils.js.map +0 -1
- package/components/HighlightBox/HighlightBox.js +0 -61
- package/components/HighlightBox/HighlightBox.js.map +0 -1
- package/components/HighlightBox/index.d.ts +0 -3
- package/components/HighlightBox/index.js +0 -7
- package/components/HighlightBox/styles.module.scss.d.ts +0 -25
- /package/components/{HighlightBox → Chip}/index.js.map +0 -0
- /package/{_virtual → components/EyebrowHeader}/index.js.map +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import t from "react";
|
|
2
|
-
import
|
|
2
|
+
import l from "classnames";
|
|
3
3
|
import { AnalyticsId as R, IconSize as C } from "../../constants.js";
|
|
4
4
|
import { useUuid as T } from "../../hooks/useUuid.js";
|
|
5
5
|
import { getColor as F } from "../../theme/currys/color.js";
|
|
@@ -8,19 +8,19 @@ import $ from "../Badge/NotificationBadge.js";
|
|
|
8
8
|
import H from "../Close/Close.js";
|
|
9
9
|
import M from "../Expander/Expander.js";
|
|
10
10
|
import e from "../NotificationPanel/styles.module.scss";
|
|
11
|
-
const U = ({ fluid:
|
|
12
|
-
if (
|
|
13
|
-
const i =
|
|
14
|
-
return /* @__PURE__ */ t.createElement("div", { className: i },
|
|
11
|
+
const U = ({ fluid: c, children: r }) => {
|
|
12
|
+
if (c) {
|
|
13
|
+
const i = l(e["fluid-wrapper"]);
|
|
14
|
+
return /* @__PURE__ */ t.createElement("div", { className: i }, r);
|
|
15
15
|
}
|
|
16
|
-
return
|
|
17
|
-
}, Z = t.forwardRef((
|
|
16
|
+
return r;
|
|
17
|
+
}, Z = t.forwardRef((c, r) => {
|
|
18
18
|
const {
|
|
19
19
|
children: i,
|
|
20
|
-
variant:
|
|
20
|
+
variant: s = "info",
|
|
21
21
|
dismissable: m = !1,
|
|
22
22
|
onClick: E,
|
|
23
|
-
expanderChildren:
|
|
23
|
+
expanderChildren: o,
|
|
24
24
|
expanderButtonText: d,
|
|
25
25
|
expanderButtonClosedText: f,
|
|
26
26
|
expanderOpenFromStart: N = !1,
|
|
@@ -33,17 +33,17 @@ const U = ({ fluid: r, children: s }) => {
|
|
|
33
33
|
labelId: S,
|
|
34
34
|
role: g,
|
|
35
35
|
testId: w
|
|
36
|
-
} =
|
|
37
|
-
const b = a === "outline", k =
|
|
38
|
-
[e["notification-panel__label--no-content"]]: !i && !
|
|
36
|
+
} = c, p = T(S), A = () => {
|
|
37
|
+
const b = a === "outline", k = l(e["notification-panel__content"]), y = l(e["notification-panel__label"], {
|
|
38
|
+
[e["notification-panel__label--no-content"]]: !i && !o,
|
|
39
39
|
[e["notification-panel__label--compact"]]: !!a,
|
|
40
40
|
[e["notification-panel__label--outline"]]: b
|
|
41
|
-
}), z =
|
|
41
|
+
}), z = l(e["notification-panel__children"], {
|
|
42
42
|
[e["notification-panel__children--with-label"]]: n,
|
|
43
|
-
[e["notification-panel__children--expander-no-label"]]:
|
|
43
|
+
[e["notification-panel__children--expander-no-label"]]: o && !n,
|
|
44
44
|
[e["notification-panel__children--outline"]]: b
|
|
45
45
|
}), O = h, [x, P] = t.useState(N);
|
|
46
|
-
return /* @__PURE__ */ t.createElement("div", { className: k, id: n ? void 0 : p }, n && /* @__PURE__ */ t.createElement(O, { className: y, id: p }, n), i && /* @__PURE__ */ t.createElement("div", { className: z }, i),
|
|
46
|
+
return /* @__PURE__ */ t.createElement("div", { className: k, id: n ? void 0 : p }, n && /* @__PURE__ */ t.createElement(O, { className: y, id: p }, n), i && /* @__PURE__ */ t.createElement("div", { className: z }, i), o && d && f && !a && /* @__PURE__ */ t.createElement(
|
|
47
47
|
M,
|
|
48
48
|
{
|
|
49
49
|
title: x ? d : f,
|
|
@@ -51,25 +51,25 @@ const U = ({ fluid: r, children: s }) => {
|
|
|
51
51
|
expanded: x,
|
|
52
52
|
testId: "expand"
|
|
53
53
|
},
|
|
54
|
-
|
|
54
|
+
o
|
|
55
55
|
));
|
|
56
|
-
}, B =
|
|
56
|
+
}, B = l(
|
|
57
57
|
e["notification-panel"],
|
|
58
|
-
e[`notification-panel--${
|
|
58
|
+
e[`notification-panel--${s}`],
|
|
59
59
|
u && e[`notification-panel--${u}`],
|
|
60
60
|
{
|
|
61
61
|
[e["notification-panel--compact"]]: !!a,
|
|
62
62
|
[e["notification-panel--compact--basic"]]: a === "basic",
|
|
63
63
|
[e["notification-panel--compact--outline"]]: a === "outline",
|
|
64
|
-
[e["notification-panel--with-content"]]:
|
|
64
|
+
[e["notification-panel--with-content"]]: o || n && i,
|
|
65
65
|
[e["notification-panel--dismissable"]]: m
|
|
66
66
|
},
|
|
67
67
|
I
|
|
68
|
-
), _ = g ||
|
|
68
|
+
), _ = g || s === "error" && "alert" || void 0, L = _ ? V({ label: n, id: p }) : void 0;
|
|
69
69
|
return /* @__PURE__ */ t.createElement(U, { fluid: v }, /* @__PURE__ */ t.createElement(
|
|
70
70
|
"div",
|
|
71
71
|
{
|
|
72
|
-
ref:
|
|
72
|
+
ref: r,
|
|
73
73
|
role: _,
|
|
74
74
|
"data-testid": w,
|
|
75
75
|
"data-analyticsid": R.NotificationPanel,
|
|
@@ -79,12 +79,12 @@ const U = ({ fluid: r, children: s }) => {
|
|
|
79
79
|
/* @__PURE__ */ t.createElement(
|
|
80
80
|
$,
|
|
81
81
|
{
|
|
82
|
-
variant:
|
|
82
|
+
variant: s,
|
|
83
83
|
size: a ? C.XSmall : C.Small,
|
|
84
84
|
className: e["notification-panel__icon"]
|
|
85
85
|
}
|
|
86
86
|
),
|
|
87
|
-
m && /* @__PURE__ */ t.createElement("span", { className: e["notification-panel__close"] }, /* @__PURE__ */ t.createElement(H, { ariaLabel:
|
|
87
|
+
m && /* @__PURE__ */ t.createElement("span", { className: e["notification-panel__close"] }, /* @__PURE__ */ t.createElement(H, { ariaLabel: c.ariaLabelCloseBtn, onClick: E, color: F("black") })),
|
|
88
88
|
A()
|
|
89
89
|
));
|
|
90
90
|
});
|
|
@@ -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 { 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"],"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,IAAc;AAAA,IACd,SAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,uBAAAC,IAAwB;AAAA,IACxB,gBAAAC;AAAA,IACA,OAAAC;AAAA,IACA,iBAAAC,IAAkB;AAAA,IAClB,OAAAlB,IAAQ;AAAA,IACR,MAAAmB;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,MAAAC;AAAA,IACA,QAAAC;AAAA,EACE,IAAAhB,GACEiB,IAAOC,EAAQJ,CAAO,GACtBK,IAAgB,MAAmB;AACvC,UAAMC,IAAiBX,MAAmB,WACpCY,IAAiBzB,EAAWC,EAAO,6BAA6B,CAAC,GACjEyB,IAAe1B,EAAWC,EAAO,2BAA2B,GAAG;AAAA,MACnE,CAACA,EAAO,uCAAuC,CAAC,GAAG,CAACH,KAAY,CAACW;AAAA,MACjE,CAACR,EAAO,oCAAoC,CAAC,GAAG,CAAC,C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AACG,EAAO,iCAAiC,CAAC,GAAGM;AAAA,IAC/C;AAAA,IACAU;AAAA,EAAA,GAGIgB,IAAWd,MAAUb,MAAY,WAAWA,MAAY,YAAY,WAAY,QAChF4B,IAAsBD,IAAWE,EAAuB,EAAE,OAAArB,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,MAAM4B;AAAA,MACN,eAAab;AAAA,MACb,oBAAkBgB,EAAY;AAAA,MAC9B,WAAWJ;AAAA,MACV,GAAGE;AAAA,IAAA;AAAA,IAEJhC,gBAAAA,EAAA;AAAA,MAACmC;AAAA,MAAA;AAAA,QACC,SAAS/B,KAAW,UAAU,UAAUA;AAAA,QACxC,MAAMO,IAAiByB,EAAS,SAASA,EAAS;AAAA,QAClD,WAAWrC,EAAO,0BAA0B;AAAA,MAAA;AAAA,IAC9C;AAAA,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;"}
|
|
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' | 'error' | 'success';\nexport type NotificationCompactVariants = 'basic' | 'outline';\nexport type NotificationPanelSizes = 'small' | 'medium' | 'large';\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'span';\n\nexport interface NotificationPanelProps {\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds inner child elements. */\n children?: React.ReactNode;\n /** Adds inner expander elements. */\n expanderChildren?: React.ReactNode;\n /** Text for expanderButton. */\n expanderButtonText?: string;\n /** Text for expanderButton when closed. */\n expanderButtonClosedText?: string;\n /** Makes expander be open from start. */\n expanderOpenFromStart?: boolean;\n /** Changes the visual representation of the notification panel. */\n variant?: NotificationPanelVariants;\n /** Makes the panel more compact. Available in basic and outline. */\n compactVariant?: NotificationCompactVariants;\n /** Sets a fixed size for the content container. */\n size?: NotificationPanelSizes;\n /** Used in combination with dismissiable property to close the notification panel. */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Toggles the close button in the top right corner. */\n dismissable?: boolean;\n /** Enables a fluid outer container that spans the entire width of parent. */\n fluid?: boolean;\n /** Sets a label for the notification panel. */\n label?: string;\n /** Changes the underlying element of the label. */\n labelHtmlMarkup?: LabelTags;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Custom id for the label */\n labelId?: string;\n /** Custom role for the panel. Default is no role. If variant is alert or crisis, the aria role will be set to \"alert\" unless the role-prop is also set. */\n role?: 'region' | 'alert';\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\ntype WrapFluidProps = Pick<NotificationPanelProps, 'fluid'> & {\n children: React.ReactElement;\n};\n\nconst FluidWrapper: React.FC<WrapFluidProps> = ({ fluid, children }) => {\n if (fluid) {\n const fluidClasses = classNames(styles['fluid-wrapper']);\n\n return <div className={fluidClasses}>{children}</div>;\n }\n return children;\n};\n\nconst NotificationPanel = React.forwardRef<HTMLDivElement, NotificationPanelProps>((props, ref) => {\n const {\n children,\n variant = 'info',\n dismissable = false,\n onClick,\n expanderChildren,\n expanderButtonText,\n expanderButtonClosedText,\n expanderOpenFromStart = false,\n compactVariant,\n label,\n labelHtmlMarkup = 'h1',\n fluid = false,\n size,\n className,\n labelId,\n role,\n testId,\n } = props;\n const uuid = useUuid(labelId);\n const renderContent = (): JSX.Element => {\n const outlineVariant = compactVariant === 'outline';\n const contentClasses = classNames(styles['notification-panel__content']);\n const labelClasses = classNames(styles['notification-panel__label'], {\n [styles['notification-panel__label--no-content']]: !children && !expanderChildren,\n [styles['notification-panel__label--compact']]: !!compactVariant,\n [styles['notification-panel__label--outline']]: outlineVariant,\n });\n const childrenClasses = classNames(styles['notification-panel__children'], {\n [styles['notification-panel__children--with-label']]: label,\n [styles['notification-panel__children--expander-no-label']]: expanderChildren && !label,\n [styles['notification-panel__children--outline']]: outlineVariant,\n });\n const CustomTag = labelHtmlMarkup;\n\n const [expanderOpen, setExpanderOpen] = React.useState(expanderOpenFromStart);\n return (\n <div className={contentClasses} id={!label ? uuid : undefined}>\n {label && (\n <CustomTag className={labelClasses} id={uuid}>\n {label}\n </CustomTag>\n )}\n {children && <div className={childrenClasses}>{children}</div>}\n {expanderChildren && expanderButtonText && expanderButtonClosedText && !compactVariant && (\n <Expander\n title={expanderOpen ? expanderButtonText : expanderButtonClosedText}\n onExpand={setExpanderOpen}\n expanded={expanderOpen}\n testId=\"expand\"\n >\n {expanderChildren}\n </Expander>\n )}\n </div>\n );\n };\n\n const notificationPanelClasses = classNames(\n styles['notification-panel'],\n styles[`notification-panel--${variant}`],\n size && styles[`notification-panel--${size}`],\n {\n [styles['notification-panel--compact']]: !!compactVariant,\n [styles['notification-panel--compact--basic']]: compactVariant === 'basic',\n [styles['notification-panel--compact--outline']]: compactVariant === 'outline',\n [styles['notification-panel--with-content']]: expanderChildren || (label && children),\n [styles['notification-panel--dismissable']]: dismissable,\n },\n className\n );\n\n const ariaRole = role || (variant === 'error' && 'alert') || undefined;\n const ariaLabelAttributes = ariaRole ? getAriaLabelAttributes({ label, id: uuid }) : undefined;\n\n return (\n <FluidWrapper fluid={fluid}>\n <div\n ref={ref}\n role={ariaRole}\n data-testid={testId}\n data-analyticsid={AnalyticsId.NotificationPanel}\n className={notificationPanelClasses}\n {...ariaLabelAttributes}\n >\n <NotificationBadge\n variant={variant}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n className={styles['notification-panel__icon']}\n />\n {dismissable && (\n <span className={styles['notification-panel__close']}>\n <Close ariaLabel={props.ariaLabelCloseBtn} onClick={onClick} color={getColor('black')} />\n </span>\n )}\n {renderContent()}\n </div>\n </FluidWrapper>\n );\n});\n\nexport default NotificationPanel;\n"],"names":["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"],"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,IAAc;AAAA,IACd,SAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,uBAAAC,IAAwB;AAAA,IACxB,gBAAAC;AAAA,IACA,OAAAC;AAAA,IACA,iBAAAC,IAAkB;AAAA,IAClB,OA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;AAEJ,CAAC;"}
|
|
@@ -84,20 +84,6 @@
|
|
|
84
84
|
border: none;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
&--alert {
|
|
88
|
-
border: 0.125rem solid $cherry700;
|
|
89
|
-
background-color: $cherry50;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
&--alert#{&}--compact {
|
|
93
|
-
box-shadow: none;
|
|
94
|
-
background-color: transparent;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
&--alert#{&}--compact--basic {
|
|
98
|
-
border: none;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
87
|
&--error {
|
|
102
88
|
border: 0.125rem solid $cherry700;
|
|
103
89
|
background-color: $cherry50;
|
|
@@ -15,7 +15,6 @@ export type Styles = {
|
|
|
15
15
|
'notification-panel__label--compact': string;
|
|
16
16
|
'notification-panel__label--no-content': string;
|
|
17
17
|
'notification-panel__label--outline': string;
|
|
18
|
-
'notification-panel--alert': string;
|
|
19
18
|
'notification-panel--compact': string;
|
|
20
19
|
'notification-panel--compact--basic': string;
|
|
21
20
|
'notification-panel--compact--outline': string;
|
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { FormMode as i, FormSize as
|
|
4
|
-
import { usePseudoClasses as
|
|
5
|
-
import { useUuid as
|
|
6
|
-
import { getAriaDescribedBy as
|
|
7
|
-
import { isMutableRefObject as
|
|
8
|
-
import { uuid as
|
|
1
|
+
import c, { useState as P } from "react";
|
|
2
|
+
import m from "classnames";
|
|
3
|
+
import { FormMode as i, FormSize as U, AnalyticsId as W } from "../../constants.js";
|
|
4
|
+
import { usePseudoClasses as q } from "../../hooks/usePseudoClasses.js";
|
|
5
|
+
import { useUuid as G } from "../../hooks/useUuid.js";
|
|
6
|
+
import { getAriaDescribedBy as H } from "../../utils/accessibility.js";
|
|
7
|
+
import { isMutableRefObject as J, mergeRefs as K } from "../../utils/refs.js";
|
|
8
|
+
import { uuid as Q } from "../../utils/uuid.js";
|
|
9
|
+
import { ErrorWrapper as V } from "../ErrorWrapper/ErrorWrapper.js";
|
|
9
10
|
import { getLabelText as X, renderLabelAsParent as Y } from "../Label/Label.js";
|
|
10
11
|
import e from "../RadioButton/styles.module.scss";
|
|
11
|
-
const
|
|
12
|
-
const n = o === "oninvalid", t =
|
|
13
|
-
return
|
|
12
|
+
const be = (l, o, a, s) => {
|
|
13
|
+
const n = o === "oninvalid", t = l === s;
|
|
14
|
+
return m({
|
|
14
15
|
[e["radio-button-label__large--on-grey"]]: a && o === "ongrey" && !t,
|
|
15
16
|
[e["radio-button-label__large--on-blueberry"]]: o === "onblueberry" && !t && a,
|
|
16
17
|
[e["radio-button-label__large--selected"]]: a && t && !n,
|
|
17
18
|
[e["radio-button-label__large--selected-invalid"]]: a && t && n
|
|
18
19
|
});
|
|
19
|
-
}, Z =
|
|
20
|
+
}, Z = c.forwardRef((l, o) => {
|
|
20
21
|
const {
|
|
21
22
|
className: a,
|
|
22
|
-
defaultChecked:
|
|
23
|
+
defaultChecked: s = !1,
|
|
23
24
|
onChange: n,
|
|
24
25
|
disabled: t,
|
|
25
26
|
label: f,
|
|
26
|
-
inputId:
|
|
27
|
+
inputId: p = Q(),
|
|
27
28
|
mode: d = i.onwhite,
|
|
28
|
-
name: v =
|
|
29
|
+
name: v = p,
|
|
29
30
|
size: w,
|
|
30
|
-
errorText:
|
|
31
|
-
error: k = !!
|
|
31
|
+
errorText: _,
|
|
32
|
+
error: k = !!_,
|
|
32
33
|
errorTextId: B,
|
|
33
34
|
value: R = X(f),
|
|
34
|
-
testId:
|
|
35
|
+
testId: x,
|
|
35
36
|
required: L,
|
|
36
|
-
labelClassNames:
|
|
37
|
+
labelClassNames: N,
|
|
37
38
|
...I
|
|
38
|
-
} =
|
|
39
|
-
[e["radio-button-wrapper--with-error"]]:
|
|
39
|
+
} = l, g = k || d === i.oninvalid, y = d === i.ondark, h = d === i.onblueberry, T = d === i.oninvalid, r = w === U.large, [E, A] = P(s), { refObject: F, isFocused: b } = q(J(o) ? o : null), S = K([o, F]), C = G(B), j = m(e["radio-button-wrapper"], {
|
|
40
|
+
[e["radio-button-wrapper--with-error"]]: _,
|
|
40
41
|
[e["radio-button-wrapper__large"]]: r,
|
|
41
|
-
[e["radio-button-wrapper__large--focused"]]: r &&
|
|
42
|
-
[e["radio-button-wrapper__large--selected"]]: r &&
|
|
43
|
-
[e["radio-button-wrapper__large--invalid"]]: r &&
|
|
44
|
-
[e["radio-button-wrapper__large--on-blueberry"]]: r && h &&
|
|
45
|
-
}), z =
|
|
42
|
+
[e["radio-button-wrapper__large--focused"]]: r && b,
|
|
43
|
+
[e["radio-button-wrapper__large--selected"]]: r && E && b,
|
|
44
|
+
[e["radio-button-wrapper__large--invalid"]]: r && T && b,
|
|
45
|
+
[e["radio-button-wrapper__large--on-blueberry"]]: r && h && b
|
|
46
|
+
}), z = m(
|
|
46
47
|
e["radio-button-label"],
|
|
47
48
|
{
|
|
48
49
|
[e["radio-button-label--disabled"]]: t,
|
|
@@ -51,8 +52,8 @@ const se = (s, o, a, b) => {
|
|
|
51
52
|
[e["radio-button-label__large"]]: r,
|
|
52
53
|
[e["radio-button-label__large--disabled"]]: r && t
|
|
53
54
|
},
|
|
54
|
-
|
|
55
|
-
), D =
|
|
55
|
+
N
|
|
56
|
+
), D = m(
|
|
56
57
|
e["radio-button"],
|
|
57
58
|
{
|
|
58
59
|
[e["radio-button--on-dark"]]: y,
|
|
@@ -64,40 +65,40 @@ const se = (s, o, a, b) => {
|
|
|
64
65
|
[e["radio-button__large--invalid"]]: r && g
|
|
65
66
|
},
|
|
66
67
|
a
|
|
67
|
-
), M =
|
|
68
|
-
A(
|
|
69
|
-
},
|
|
68
|
+
), M = (u) => {
|
|
69
|
+
A(u.target.checked), n && n(u);
|
|
70
|
+
}, O = () => /* @__PURE__ */ c.createElement(
|
|
70
71
|
"input",
|
|
71
72
|
{
|
|
72
|
-
id:
|
|
73
|
+
id: p,
|
|
73
74
|
name: v,
|
|
74
75
|
className: D,
|
|
75
76
|
type: "radio",
|
|
76
77
|
disabled: t,
|
|
77
78
|
value: R,
|
|
78
|
-
ref:
|
|
79
|
-
defaultChecked:
|
|
80
|
-
"aria-describedby":
|
|
79
|
+
ref: S,
|
|
80
|
+
defaultChecked: s,
|
|
81
|
+
"aria-describedby": H(l, C),
|
|
81
82
|
required: L,
|
|
82
83
|
...I,
|
|
83
|
-
onChange: (
|
|
84
|
+
onChange: (u) => M(u)
|
|
84
85
|
}
|
|
85
86
|
);
|
|
86
|
-
return /* @__PURE__ */
|
|
87
|
+
return /* @__PURE__ */ c.createElement(V, { errorText: _, errorTextId: C }, /* @__PURE__ */ c.createElement("div", { "data-testid": x, "data-analyticsid": W.RadioButton, className: j }, Y(
|
|
87
88
|
f,
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
O(),
|
|
90
|
+
p,
|
|
90
91
|
d,
|
|
91
92
|
z,
|
|
92
93
|
void 0,
|
|
93
94
|
e["radiobutton-sublabel-wrapper"],
|
|
94
95
|
r
|
|
95
|
-
));
|
|
96
|
+
)));
|
|
96
97
|
});
|
|
97
98
|
Z.displayName = "RadioButton";
|
|
98
99
|
export {
|
|
99
100
|
Z as RadioButton,
|
|
100
101
|
Z as default,
|
|
101
|
-
|
|
102
|
+
be as getRadioLabelClasses
|
|
102
103
|
};
|
|
103
104
|
//# sourceMappingURL=RadioButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioButton.js","sources":["../../../src/components/RadioButton/RadioButton.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormMode, FormSize } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport { getLabelText, renderLabelAsParent } from '../Label';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport interface RadioButtonProps\n extends Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'defaultChecked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the radioButton - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** Adds custom classes to the label element. */\n labelClassNames?: string;\n /** input id of the radioButton */\n inputId?: string;\n /** Changes the visuals of the radioButton */\n mode?: keyof typeof FormMode;\n /** Changes the visuals of the radioButton */\n size?: keyof typeof FormSize;\n /** Activates Error style for the radioButton - This is can be true while errorText is empty, when in a FormGroup */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const getRadioLabelClasses = (radioId: string, mode: FormMode, large: boolean, checkedRadioId?: string): string | undefined => {\n const onCherry = mode === 'oninvalid';\n const checked = radioId === checkedRadioId;\n\n return classNames({\n [radioButtonStyles['radio-button-label__large--on-grey']]: large && mode === 'ongrey' && !checked,\n [radioButtonStyles['radio-button-label__large--on-blueberry']]: mode === 'onblueberry' && !checked && large,\n [radioButtonStyles['radio-button-label__large--selected']]: large && checked && !onCherry,\n [radioButtonStyles['radio-button-label__large--selected-invalid']]: large && checked && onCherry,\n });\n};\n\nexport const RadioButton = React.forwardRef((props: RadioButtonProps, ref: React.Ref<HTMLInputElement>) => {\n const {\n className,\n defaultChecked = false,\n onChange,\n disabled,\n label,\n inputId = uuid(),\n mode = FormMode.onwhite,\n name = inputId,\n size,\n errorText,\n error = !!errorText,\n errorTextId,\n value = getLabelText(label),\n testId,\n required,\n labelClassNames,\n ...rest\n } = props;\n const invalid = error || mode === FormMode.oninvalid;\n const onDark = mode === FormMode.ondark;\n const onBlueberry = mode === FormMode.onblueberry;\n const onCherry = mode === FormMode.oninvalid;\n const isLarge = size === FormSize.large;\n const [checked, changeChecked] = useState<boolean>(defaultChecked);\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n const errorTextUuid = useUuid(errorTextId);\n\n const radioButtonWrapperClasses = classNames(radioButtonStyles['radio-button-wrapper'], {\n [radioButtonStyles['radio-button-wrapper--with-error']]: errorText,\n [radioButtonStyles['radio-button-wrapper__large']]: isLarge,\n [radioButtonStyles['radio-button-wrapper__large--focused']]: isLarge && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--selected']]: isLarge && checked && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--invalid']]: isLarge && onCherry && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--on-blueberry']]: isLarge && onBlueberry && isFocused,\n });\n const radioButtonLabelClasses = classNames(\n radioButtonStyles['radio-button-label'],\n {\n [radioButtonStyles['radio-button-label--disabled']]: disabled,\n [radioButtonStyles['radio-button-label--on-dark']]: onDark,\n [radioButtonStyles['radio-button-label--invalid']]: invalid,\n [radioButtonStyles['radio-button-label__large']]: isLarge,\n [radioButtonStyles['radio-button-label__large--disabled']]: isLarge && disabled,\n },\n labelClassNames\n );\n const radioButtonClasses = classNames(\n radioButtonStyles['radio-button'],\n {\n [radioButtonStyles['radio-button--on-dark']]: onDark,\n [radioButtonStyles['radio-button--disabled']]: disabled,\n [radioButtonStyles['radio-button--on-blueberry']]: onBlueberry,\n [radioButtonStyles['radio-button--invalid']]: invalid,\n [radioButtonStyles['radio-button__large']]: isLarge,\n [radioButtonStyles['radio-button__large--disabled']]: isLarge && disabled,\n [radioButtonStyles['radio-button__large--invalid']]: isLarge && invalid,\n },\n className\n );\n const errorStyles = classNames(radioButtonStyles['radio-button-errors']);\n\n const change = (e: React.ChangeEvent<HTMLInputElement>): void => {\n changeChecked(e.target.checked);\n onChange && onChange(e);\n };\n\n const getLabelContent = (): React.ReactNode => (\n <input\n id={inputId}\n name={name}\n className={radioButtonClasses}\n type=\"radio\"\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n defaultChecked={defaultChecked}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n required={required}\n {...rest}\n onChange={(e): void => change(e)}\n />\n );\n\n return (\n <div data-testid={testId} data-analyticsid={AnalyticsId.RadioButton} className={radioButtonWrapperClasses}>\n {errorText && (\n <p className={errorStyles} id={errorTextUuid}>\n {errorText}\n </p>\n )}\n {renderLabelAsParent(\n label,\n getLabelContent(),\n inputId,\n mode as FormMode,\n radioButtonLabelClasses,\n undefined,\n radioButtonStyles['radiobutton-sublabel-wrapper'],\n isLarge\n )}\n </div>\n );\n});\n\nRadioButton.displayName = 'RadioButton';\n\nexport default RadioButton;\n"],"names":["getRadioLabelClasses","radioId","mode","large","checkedRadioId","onCherry","checked","classNames","radioButtonStyles","RadioButton","React","props","ref","className","defaultChecked","onChange","disabled","label","inputId","uuid","FormMode","name","size","errorText","error","errorTextId","value","getLabelText","testId","required","labelClassNames","rest","invalid","onDark","onBlueberry","isLarge","FormSize","changeChecked","useState","refObject","isFocused","usePseudoClasses","isMutableRefObject","mergedRefs","mergeRefs","errorTextUuid","useUuid","radioButtonWrapperClasses","radioButtonLabelClasses","radioButtonClasses","errorStyles","change","e","getLabelContent","getAriaDescribedBy","AnalyticsId","renderLabelAsParent"],"mappings":";;;;;;;;;;AAyCO,MAAMA,KAAuB,CAACC,GAAiBC,GAAgBC,GAAgBC,MAAgD;AACpI,QAAMC,IAAWH,MAAS,aACpBI,IAAUL,MAAYG;AAE5B,SAAOG,EAAW;AAAA,IAChB,CAACC,EAAkB,oCAAoC,CAAC,GAAGL,KAASD,MAAS,YAAY,CAACI;AAAA,IAC1F,CAACE,EAAkB,yCAAyC,CAAC,GAAGN,MAAS,iBAAiB,CAACI,KAAWH;AAAA,IACtG,CAACK,EAAkB,qCAAqC,CAAC,GAAGL,KAASG,KAAW,CAACD;AAAA,IACjF,CAACG,EAAkB,6CAA6C,CAAC,GAAGL,KAASG,KAAWD;AAAA,EAAA,CACzF;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,EAAmB3C,GAAOkC,CAAa;AAAA,MACzD,UAAAhB;AAAA,MACC,GAAGE;AAAA,MACJ,UAAU,CAACqB,MAAYD,EAAOC,CAAC;AAAA,IAAA;AAAA,EAAA;AAInC,yCACG,OAAI,EAAA,eAAaxB,GAAQ,oBAAkB2B,EAAY,aAAa,WAAWR,EAC7E,GAAAxB,qCACE,KAAE,EAAA,WAAW2B,GAAa,IAAIL,EAAA,GAC5BtB,CACH,GAEDiC;AAAA,IACCvC;AAAA,IACAoC,EAAgB;AAAA,IAChBnC;AAAA,IACAhB;AAAA,IACA8C;AAAA,IACA;AAAA,IACAxC,EAAkB,8BAA8B;AAAA,IAChD2B;AAAA,EAAA,CAEJ;AAEJ,CAAC;AAED1B,EAAY,cAAc;"}
|
|
1
|
+
{"version":3,"file":"RadioButton.js","sources":["../../../src/components/RadioButton/RadioButton.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormMode, FormSize } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { getLabelText, renderLabelAsParent } from '../Label';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport interface RadioButtonProps\n extends Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'defaultChecked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the radioButton - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** Adds custom classes to the label element. */\n labelClassNames?: string;\n /** input id of the radioButton */\n inputId?: string;\n /** Changes the visuals of the radioButton */\n mode?: keyof typeof FormMode;\n /** Changes the visuals of the radioButton */\n size?: keyof typeof FormSize;\n /** Activates Error style for the radioButton - This is can be true while errorText is empty, when in a FormGroup */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const getRadioLabelClasses = (radioId: string, mode: FormMode, large: boolean, checkedRadioId?: string): string | undefined => {\n const onCherry = mode === 'oninvalid';\n const checked = radioId === checkedRadioId;\n\n return classNames({\n [radioButtonStyles['radio-button-label__large--on-grey']]: large && mode === 'ongrey' && !checked,\n [radioButtonStyles['radio-button-label__large--on-blueberry']]: mode === 'onblueberry' && !checked && large,\n [radioButtonStyles['radio-button-label__large--selected']]: large && checked && !onCherry,\n [radioButtonStyles['radio-button-label__large--selected-invalid']]: large && checked && onCherry,\n });\n};\n\nexport const RadioButton = React.forwardRef((props: RadioButtonProps, ref: React.Ref<HTMLInputElement>) => {\n const {\n className,\n defaultChecked = false,\n onChange,\n disabled,\n label,\n inputId = uuid(),\n mode = FormMode.onwhite,\n name = inputId,\n size,\n errorText,\n error = !!errorText,\n errorTextId,\n value = getLabelText(label),\n testId,\n required,\n labelClassNames,\n ...rest\n } = props;\n const invalid = error || mode === FormMode.oninvalid;\n const onDark = mode === FormMode.ondark;\n const onBlueberry = mode === FormMode.onblueberry;\n const onCherry = mode === FormMode.oninvalid;\n const isLarge = size === FormSize.large;\n const [checked, changeChecked] = useState<boolean>(defaultChecked);\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n const errorTextUuid = useUuid(errorTextId);\n\n const radioButtonWrapperClasses = classNames(radioButtonStyles['radio-button-wrapper'], {\n [radioButtonStyles['radio-button-wrapper--with-error']]: errorText,\n [radioButtonStyles['radio-button-wrapper__large']]: isLarge,\n [radioButtonStyles['radio-button-wrapper__large--focused']]: isLarge && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--selected']]: isLarge && checked && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--invalid']]: isLarge && onCherry && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--on-blueberry']]: isLarge && onBlueberry && isFocused,\n });\n const radioButtonLabelClasses = classNames(\n radioButtonStyles['radio-button-label'],\n {\n [radioButtonStyles['radio-button-label--disabled']]: disabled,\n [radioButtonStyles['radio-button-label--on-dark']]: onDark,\n [radioButtonStyles['radio-button-label--invalid']]: invalid,\n [radioButtonStyles['radio-button-label__large']]: isLarge,\n [radioButtonStyles['radio-button-label__large--disabled']]: isLarge && disabled,\n },\n labelClassNames\n );\n const radioButtonClasses = classNames(\n radioButtonStyles['radio-button'],\n {\n [radioButtonStyles['radio-button--on-dark']]: onDark,\n [radioButtonStyles['radio-button--disabled']]: disabled,\n [radioButtonStyles['radio-button--on-blueberry']]: onBlueberry,\n [radioButtonStyles['radio-button--invalid']]: invalid,\n [radioButtonStyles['radio-button__large']]: isLarge,\n [radioButtonStyles['radio-button__large--disabled']]: isLarge && disabled,\n [radioButtonStyles['radio-button__large--invalid']]: isLarge && invalid,\n },\n className\n );\n\n const change = (e: React.ChangeEvent<HTMLInputElement>): void => {\n changeChecked(e.target.checked);\n onChange && onChange(e);\n };\n\n const getLabelContent = (): React.ReactNode => (\n <input\n id={inputId}\n name={name}\n className={radioButtonClasses}\n type=\"radio\"\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n defaultChecked={defaultChecked}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n required={required}\n {...rest}\n onChange={(e): void => change(e)}\n />\n );\n\n return (\n <ErrorWrapper errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.RadioButton} className={radioButtonWrapperClasses}>\n {renderLabelAsParent(\n label,\n getLabelContent(),\n inputId,\n mode as FormMode,\n radioButtonLabelClasses,\n undefined,\n radioButtonStyles['radiobutton-sublabel-wrapper'],\n isLarge\n )}\n </div>\n </ErrorWrapper>\n );\n});\n\nRadioButton.displayName = 'RadioButton';\n\nexport default RadioButton;\n"],"names":["getRadioLabelClasses","radioId","mode","large","checkedRadioId","onCherry","checked","classNames","radioButtonStyles","RadioButton","React","props","ref","className","defaultChecked","onChange","disabled","label","inputId","uuid","FormMode","name","size","errorText","error","errorTextId","value","getLabelText","testId","required","labelClassNames","rest","invalid","onDark","onBlueberry","isLarge","FormSize","changeChecked","useState","refObject","isFocused","usePseudoClasses","isMutableRefObject","mergedRefs","mergeRefs","errorTextUuid","useUuid","radioButtonWrapperClasses","radioButtonLabelClasses","radioButtonClasses","change","e","getLabelContent","getAriaDescribedBy","ErrorWrapper","AnalyticsId","renderLabelAsParent"],"mappings":";;;;;;;;;;;AA0CO,MAAMA,KAAuB,CAACC,GAAiBC,GAAgBC,GAAgBC,MAAgD;AACpI,QAAMC,IAAWH,MAAS,aACpBI,IAAUL,MAAYG;AAE5B,SAAOG,EAAW;AAAA,IAChB,CAACC,EAAkB,oCAAoC,CAAC,GAAGL,KAASD,MAAS,YAAY,CAACI;AAAA,IAC1F,CAACE,EAAkB,yCAAyC,CAAC,GAAGN,MAAS,iBAAiB,CAACI,KAAWH;AAAA,IACtG,CAACK,EAAkB,qCAAqC,CAAC,GAAGL,KAASG,KAAW,CAACD;AAAA,IACjF,CAACG,EAAkB,6CAA6C,CAAC,GAAGL,KAASG,KAAWD;AAAA,EAAA,CACzF;AACH,GAEaI,IAAcC,EAAM,WAAW,CAACC,GAAyBC,MAAqC;AACnG,QAAA;AAAA,IACJ,WAAAC;AAAA,IACA,gBAAAC,IAAiB;AAAA,IACjB,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC,IAAUC,EAAK;AAAA,IACf,MAAAjB,IAAOkB,EAAS;AAAA,IAChB,MAAAC,IAAOH;AAAA,IACP,MAAAI;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC,IAAQ,CAAC,CAACD;AAAA,IACV,aAAAE;AAAA,IACA,OAAAC,IAAQC,EAAaV,CAAK;AAAA,IAC1B,QAAAW;AAAA,IAC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;AAEJ,CAAC;AAED1B,EAAY,cAAc;"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
@use 'sass:map';
|
|
2
|
+
@use 'sass:meta';
|
|
3
|
+
@use 'sass:string';
|
|
2
4
|
@import '../../scss/spacers';
|
|
3
5
|
@import '../../scss/breakpoints';
|
|
4
6
|
@import '../../scss/palette';
|
|
5
7
|
@import '../../scss/font-settings';
|
|
6
8
|
|
|
9
|
+
@mixin dashed-border() {
|
|
10
|
+
box-shadow: none;
|
|
11
|
+
|
|
12
|
+
$encoded-color: string.slice(meta.inspect($neutral600), 2);
|
|
13
|
+
|
|
14
|
+
background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='100' ry='100' stroke='%23#{$encoded-color}' stroke-width='4' stroke-dasharray='0.5, 7' stroke-dashoffset='0' stroke-linecap='square'/%3e%3c/svg%3e");
|
|
15
|
+
border-radius: 100px;
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
.radio-button-errors {
|
|
8
19
|
font-size: $font-size-sm;
|
|
9
20
|
font-weight: 600;
|
|
@@ -13,7 +24,6 @@
|
|
|
13
24
|
|
|
14
25
|
.radio-button-wrapper {
|
|
15
26
|
cursor: pointer;
|
|
16
|
-
margin: getSpacer(s) 0;
|
|
17
27
|
|
|
18
28
|
&--with-error {
|
|
19
29
|
padding: getSpacer(s) getSpacer(2xs) getSpacer(m);
|
|
@@ -50,14 +60,6 @@
|
|
|
50
60
|
}
|
|
51
61
|
}
|
|
52
62
|
|
|
53
|
-
.radio-button-wrapper:first-of-type {
|
|
54
|
-
margin-top: 0;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.radio-button-wrapper:last-of-type {
|
|
58
|
-
margin-bottom: 0;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
63
|
.radio-button-label {
|
|
62
64
|
display: flex;
|
|
63
65
|
align-items: flex-start;
|
|
@@ -130,17 +132,6 @@
|
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
|
|
133
|
-
&__large#{&}__large--disabled {
|
|
134
|
-
background-color: $neutral50;
|
|
135
|
-
|
|
136
|
-
&:hover {
|
|
137
|
-
background-color: $neutral50;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
&:focus {
|
|
141
|
-
background-color: $neutral50;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
135
|
&__large#{&}__large--on-grey {
|
|
145
136
|
background-color: $white;
|
|
146
137
|
|
|
@@ -174,6 +165,19 @@
|
|
|
174
165
|
}
|
|
175
166
|
}
|
|
176
167
|
|
|
168
|
+
&__large#{&}__large--disabled {
|
|
169
|
+
color: $neutral700;
|
|
170
|
+
background-color: $neutral50;
|
|
171
|
+
|
|
172
|
+
&:hover {
|
|
173
|
+
background-color: $neutral50;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&:focus {
|
|
177
|
+
background-color: $neutral50;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
177
181
|
@media (min-width: map.get($grid-breakpoints, md)) {
|
|
178
182
|
&__large {
|
|
179
183
|
padding: 1.68rem getSpacer(l);
|
|
@@ -290,16 +294,18 @@
|
|
|
290
294
|
|
|
291
295
|
&--disabled {
|
|
292
296
|
cursor: default;
|
|
293
|
-
|
|
294
|
-
|
|
297
|
+
|
|
298
|
+
@include dashed-border;
|
|
299
|
+
|
|
300
|
+
background-color: transparent;
|
|
295
301
|
|
|
296
302
|
&:hover {
|
|
297
|
-
box-shadow:
|
|
298
|
-
background-color:
|
|
303
|
+
box-shadow: none;
|
|
304
|
+
background-color: transparent;
|
|
299
305
|
}
|
|
300
306
|
|
|
301
307
|
:hover > & {
|
|
302
|
-
background-color:
|
|
308
|
+
background-color: transparent;
|
|
303
309
|
}
|
|
304
310
|
|
|
305
311
|
&:active {
|
|
@@ -336,16 +342,14 @@
|
|
|
336
342
|
background-color: $blueberry200;
|
|
337
343
|
}
|
|
338
344
|
|
|
339
|
-
&--disabled:checked::before {
|
|
340
|
-
box-shadow: 0 0 0 0;
|
|
341
|
-
background-color: $neutral400;
|
|
342
|
-
color: $neutral600;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
345
|
&--invalid:checked::before {
|
|
346
346
|
background-color: $cherry600;
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
+
&--disabled:checked::before {
|
|
350
|
+
background-color: transparent;
|
|
351
|
+
}
|
|
352
|
+
|
|
349
353
|
&__large {
|
|
350
354
|
&:checked {
|
|
351
355
|
outline: none;
|
|
@@ -402,12 +406,14 @@
|
|
|
402
406
|
}
|
|
403
407
|
|
|
404
408
|
&--disabled {
|
|
405
|
-
&:hover
|
|
406
|
-
|
|
409
|
+
&:hover,
|
|
410
|
+
&:focus,
|
|
411
|
+
&:checked:hover {
|
|
412
|
+
box-shadow: none;
|
|
407
413
|
}
|
|
408
414
|
|
|
409
|
-
&:
|
|
410
|
-
|
|
415
|
+
&:checked::before {
|
|
416
|
+
background-color: $neutral600;
|
|
411
417
|
}
|
|
412
418
|
}
|
|
413
419
|
}
|
|
@@ -15,72 +15,72 @@ import U from "../Icons/ChevronUp.js";
|
|
|
15
15
|
import B from "../Icons/Forward.js";
|
|
16
16
|
import j from "../Icons/X.js";
|
|
17
17
|
import s from "../ServiceMessage/styles.module.scss";
|
|
18
|
-
const F = ({ label:
|
|
19
|
-
const d = z(), { isHovered: a, hoverRef: g } = u(),
|
|
18
|
+
const F = ({ label: o, variant: c, id: m, hasExpander: r, isExpanded: i, dismissable: v, onExpand: l, onDismiss: _, closeBtnText: n }) => {
|
|
19
|
+
const d = z(), { isHovered: a, hoverRef: g } = u(), t = d < L.lg ? E.XSmall : E.Small, N = r ? "button" : "span", f = p(
|
|
20
20
|
s["service-message__label-container"],
|
|
21
21
|
r && s["service-message__label-container--has-expander"]
|
|
22
22
|
);
|
|
23
|
-
return /* @__PURE__ */ e.createElement("div", { className: f, ref: g }, /* @__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(y, { variant:
|
|
23
|
+
return /* @__PURE__ */ e.createElement("div", { className: f, ref: g }, /* @__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(y, { variant: c, size: t, isHovered: a }), /* @__PURE__ */ e.createElement("h1", { className: s["service-message__title"], id: m }, /* @__PURE__ */ e.createElement(
|
|
24
24
|
N,
|
|
25
25
|
{
|
|
26
26
|
className: s["service-message__toggle"],
|
|
27
|
-
onClick: r ?
|
|
28
|
-
"aria-expanded": r ?
|
|
27
|
+
onClick: r ? l : void 0,
|
|
28
|
+
"aria-expanded": r ? i : void 0
|
|
29
29
|
},
|
|
30
|
-
|
|
31
|
-
)), r && /* @__PURE__ */ e.createElement(C, { size:
|
|
32
|
-
}, $ = ({ info:
|
|
33
|
-
const { hoverRef: n, isHovered: d } = u(), { hoverRef: a, isHovered: g } = u(),
|
|
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"] },
|
|
30
|
+
o
|
|
31
|
+
)), r && /* @__PURE__ */ e.createElement(C, { size: t, svgIcon: i ? U : M, isHovered: a }), !r && v && /* @__PURE__ */ e.createElement(A, { onClick: _, ariaLabel: n, className: s["service-message__close"] }))))));
|
|
32
|
+
}, $ = ({ info: o, extraInfo: c, urlTitle: m, url: r, target: i, dismissable: v, closeBtnText: l, onDismiss: _ }) => {
|
|
33
|
+
const { hoverRef: n, isHovered: d } = u(), { hoverRef: a, isHovered: g } = u(), t = 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"] }, o && /* @__PURE__ */ e.createElement("p", { className: s["service-message__info"] }, o), c && /* @__PURE__ */ e.createElement("p", { className: p(s["service-message__info"], s["service-message__info--extra"]) }, c), /* @__PURE__ */ e.createElement("div", { className: s["service-message__actions"] }, t && /* @__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: d })), v && /* @__PURE__ */ e.createElement(
|
|
35
35
|
"button",
|
|
36
36
|
{
|
|
37
37
|
ref: a,
|
|
38
38
|
className: p(s["service-message__action"], s["service-message__action--close"]),
|
|
39
|
-
"aria-label":
|
|
39
|
+
"aria-label": l,
|
|
40
40
|
onClick: _
|
|
41
41
|
},
|
|
42
|
-
|
|
42
|
+
l,
|
|
43
43
|
/* @__PURE__ */ e.createElement(C, { size: E.XSmall, svgIcon: j, color: H("blueberry", 700), isHovered: g })
|
|
44
44
|
))))));
|
|
45
45
|
}, ae = ({
|
|
46
|
-
label:
|
|
47
|
-
dismissable:
|
|
46
|
+
label: o,
|
|
47
|
+
dismissable: c = !0,
|
|
48
48
|
onDismiss: m,
|
|
49
49
|
info: r,
|
|
50
|
-
extraInfo:
|
|
50
|
+
extraInfo: i,
|
|
51
51
|
urlTitle: v,
|
|
52
|
-
url:
|
|
52
|
+
url: l,
|
|
53
53
|
target: _ = "_self",
|
|
54
54
|
closeBtnText: n = "fjern melding",
|
|
55
55
|
expanderOpenFromStart: d = !1,
|
|
56
56
|
variant: a = "error",
|
|
57
57
|
testId: g
|
|
58
58
|
}) => {
|
|
59
|
-
const [
|
|
60
|
-
b && N(!
|
|
59
|
+
const [t, N] = h(d), f = w(), b = !!r || !!i, R = a === "error" ? "alert" : "region", S = X({ label: o, id: f }), k = () => {
|
|
60
|
+
b && N(!t);
|
|
61
61
|
}, I = p(s["service-message"], s[`service-message--${a}`]);
|
|
62
62
|
return /* @__PURE__ */ e.createElement("div", { className: I, role: R, ...S, "data-testid": g }, /* @__PURE__ */ e.createElement(
|
|
63
63
|
F,
|
|
64
64
|
{
|
|
65
|
-
label:
|
|
65
|
+
label: o,
|
|
66
66
|
variant: a,
|
|
67
67
|
id: f,
|
|
68
68
|
hasExpander: b,
|
|
69
|
-
isExpanded:
|
|
70
|
-
dismissable:
|
|
69
|
+
isExpanded: t,
|
|
70
|
+
dismissable: c,
|
|
71
71
|
onExpand: k,
|
|
72
72
|
onDismiss: m,
|
|
73
73
|
closeBtnText: n
|
|
74
74
|
}
|
|
75
|
-
), b &&
|
|
75
|
+
), b && t && /* @__PURE__ */ e.createElement(
|
|
76
76
|
$,
|
|
77
77
|
{
|
|
78
78
|
info: r,
|
|
79
|
-
extraInfo:
|
|
79
|
+
extraInfo: i,
|
|
80
80
|
urlTitle: v,
|
|
81
|
-
url:
|
|
81
|
+
url: l,
|
|
82
82
|
target: _,
|
|
83
|
-
dismissable:
|
|
83
|
+
dismissable: c,
|
|
84
84
|
onDismiss: m,
|
|
85
85
|
closeBtnText: n
|
|
86
86
|
}
|