@helsenorge/designsystem-react 7.3.0 → 7.4.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/Checkbox/Checkbox.js +24 -23
- package/components/Checkbox/Checkbox.js.map +1 -1
- package/components/HighlightBox/styles.module.scss +11 -7
- package/components/Input/Input.js +25 -24
- package/components/Input/Input.js.map +1 -1
- package/components/LinkList/LinkList.js +25 -24
- package/components/LinkList/LinkList.js.map +1 -1
- package/components/PopMenu/PopMenu.d.ts +12 -0
- package/components/PopMenu/PopMenu.js +74 -74
- package/components/PopMenu/PopMenu.js.map +1 -1
- package/components/PopMenu/PopMenu.stories.d.ts +7 -1
- package/components/PopMenu/index.js +3 -2
- package/components/PopMenu/styles.module.scss +1 -1
- package/components/PopOver/PopOver.js +34 -34
- package/components/PopOver/PopOver.js.map +1 -1
- package/components/PopOver/styles.module.scss +4 -7
- package/components/PopOver/styles.module.scss.d.ts +1 -0
- package/components/PromoPanel/PromoPanel.stories.d.ts +1 -0
- package/components/RadioButton/RadioButton.js +27 -26
- package/components/RadioButton/RadioButton.js.map +1 -1
- package/components/Select/Select.d.ts +1 -1
- package/components/Select/Select.js +23 -22
- package/components/Select/Select.js.map +1 -1
- package/components/ServiceMessage/ServiceMessage.stories.d.ts +1 -1
- package/components/Textarea/Textarea.js +34 -33
- package/components/Textarea/Textarea.js.map +1 -1
- package/package.json +1 -1
- package/scss/supernova/index.css +3 -0
- package/scss/supernova/styles/colors.css +173 -0
- package/utils/accessibility.d.ts +12 -0
- package/utils/accessibility.js +17 -8
- package/utils/accessibility.js.map +1 -1
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { IconSize as
|
|
4
|
-
import { useBreakpoint as
|
|
5
|
-
import { useHover as
|
|
6
|
-
import { useOutsideEvent as
|
|
7
|
-
import { getColor as
|
|
8
|
-
import { breakpoints as
|
|
9
|
-
import { isComponent as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import e, { useRef as p, useState as G } from "react";
|
|
2
|
+
import u from "classnames";
|
|
3
|
+
import { IconSize as m, AnalyticsId as W } from "../../constants.js";
|
|
4
|
+
import { useBreakpoint as j } from "../../hooks/useBreakpoint.js";
|
|
5
|
+
import { useHover as q } from "../../hooks/useHover.js";
|
|
6
|
+
import { useOutsideEvent as F } from "../../hooks/useOutsideEvent.js";
|
|
7
|
+
import { getColor as E } from "../../theme/currys/color.js";
|
|
8
|
+
import { breakpoints as J } from "../../theme/grid.js";
|
|
9
|
+
import { isComponent as y } from "../../utils/component.js";
|
|
10
|
+
import { Icon as f } from "../Icon/Icon.js";
|
|
11
|
+
import K from "../Icons/VerticalDots.js";
|
|
12
|
+
import Q from "../Icons/X.js";
|
|
13
|
+
import U from "../LazyIcon/LazyIcon.js";
|
|
14
|
+
import h from "../LinkList/LinkList.js";
|
|
15
|
+
import V from "../PopOver/PopOver.js";
|
|
16
|
+
import l from "../PopMenu/styles.module.scss";
|
|
17
|
+
var Y = /* @__PURE__ */ ((o) => (o.onWhite = "on-white", o.onGray = "on-gray", o.onBlueberry = "on-blueberry", o))(Y || {}), Z = /* @__PURE__ */ ((o) => (o.right = "right", o.left = "left", o))(Z || {});
|
|
18
|
+
const ee = (o) => {
|
|
19
|
+
const d = p(null), v = p(null), B = p(null), b = p(null), [r, c] = G(!1), {
|
|
20
|
+
children: g,
|
|
21
|
+
popOverClassName: O,
|
|
21
22
|
popMenuClassName: N,
|
|
22
|
-
openButtonTestId:
|
|
23
|
-
closeButtonTestId:
|
|
24
|
-
popOverTestId:
|
|
25
|
-
popMenuVariant:
|
|
26
|
-
openButtonAriaLabel:
|
|
27
|
-
closeButtonAriaLabel:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
l
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
openButtonTestId: z,
|
|
24
|
+
closeButtonTestId: H,
|
|
25
|
+
popOverTestId: R,
|
|
26
|
+
popMenuVariant: C = "on-white",
|
|
27
|
+
openButtonAriaLabel: S,
|
|
28
|
+
closeButtonAriaLabel: _,
|
|
29
|
+
svgIcon: n,
|
|
30
|
+
labelText: a,
|
|
31
|
+
labelTextPosition: I = "right"
|
|
32
|
+
/* right */
|
|
33
|
+
} = o, L = u(l["pop-menu-button"], {
|
|
34
|
+
[l[`pop-menu-button--${C}`]]: C
|
|
35
|
+
}), T = j() < J.md;
|
|
36
|
+
F(b, () => {
|
|
37
|
+
c(!1);
|
|
38
|
+
});
|
|
39
|
+
const { isHovered: i } = q(d), k = T ? m.XSmall : m.Small, w = (t) => {
|
|
40
|
+
c(!1), t && t();
|
|
41
|
+
}, x = () => {
|
|
42
|
+
if (y(g, h))
|
|
43
|
+
return /* @__PURE__ */ e.createElement(
|
|
44
|
+
V,
|
|
38
45
|
{
|
|
39
|
-
testId:
|
|
40
|
-
className:
|
|
41
|
-
arrowClassName:
|
|
42
|
-
controllerRef:
|
|
43
|
-
popOverRef:
|
|
46
|
+
testId: R,
|
|
47
|
+
className: u(l["pop-menu__pop-over"], O),
|
|
48
|
+
arrowClassName: l["pop-menu__pop-over-arrow"],
|
|
49
|
+
controllerRef: v,
|
|
50
|
+
popOverRef: B
|
|
44
51
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
(
|
|
48
|
-
children:
|
|
49
|
-
|
|
50
|
-
(
|
|
51
|
-
onClick: (
|
|
52
|
-
}) :
|
|
52
|
+
e.Children.map(
|
|
53
|
+
g,
|
|
54
|
+
(t) => e.cloneElement(t, {
|
|
55
|
+
children: e.Children.map(
|
|
56
|
+
t.props.children,
|
|
57
|
+
(s) => y(s, h.Link) ? e.cloneElement(s, {
|
|
58
|
+
onClick: (D) => w(() => s.props.onClick && s.props.onClick(D))
|
|
59
|
+
}) : s
|
|
53
60
|
)
|
|
54
61
|
})
|
|
55
62
|
)
|
|
56
63
|
);
|
|
57
|
-
},
|
|
58
|
-
t && t.stopPropagation(),
|
|
59
|
-
},
|
|
64
|
+
}, X = (t) => {
|
|
65
|
+
t && t.stopPropagation(), c(!r);
|
|
66
|
+
}, A = n && typeof n == "string" ? /* @__PURE__ */ e.createElement(U, { iconName: n, size: m.XSmall, isHovered: i }) : n && /* @__PURE__ */ e.createElement(f, { svgIcon: n, size: m.XSmall, isHovered: i }), M = n ? A : /* @__PURE__ */ e.createElement(f, { svgIcon: n ?? K, color: E("black"), size: k, isHovered: i }), P = /* @__PURE__ */ e.createElement(f, { svgIcon: Q, color: E("black"), size: k, isHovered: i }), $ = /* @__PURE__ */ e.createElement(
|
|
60
67
|
"button",
|
|
61
68
|
{
|
|
62
|
-
ref:
|
|
63
|
-
"data-testid":
|
|
64
|
-
className:
|
|
65
|
-
"aria-label":
|
|
66
|
-
|
|
69
|
+
ref: d,
|
|
70
|
+
"data-testid": r ? H : z,
|
|
71
|
+
className: L,
|
|
72
|
+
"aria-label": r ? _ : S,
|
|
73
|
+
"aria-expanded": r,
|
|
74
|
+
onClick: X,
|
|
67
75
|
type: "button"
|
|
68
76
|
},
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
ariaLabel: L,
|
|
74
|
-
color: "black",
|
|
75
|
-
className: d,
|
|
76
|
-
testId: E,
|
|
77
|
-
ref: m,
|
|
78
|
-
onClick: (e) => C(!1, e),
|
|
79
|
-
small: b
|
|
80
|
-
}
|
|
77
|
+
a && I == "left" && /* @__PURE__ */ e.createElement("span", null, a),
|
|
78
|
+
/* @__PURE__ */ e.createElement("div", { ref: v }, r ? P : M),
|
|
79
|
+
a && I == "right" && /* @__PURE__ */ e.createElement("span", null, a)
|
|
81
80
|
);
|
|
82
|
-
return /* @__PURE__ */
|
|
83
|
-
},
|
|
81
|
+
return /* @__PURE__ */ e.createElement("div", { ref: b, className: u(l["pop-menu-button"], N), "data-analyticsid": W.PopMenu }, $, r && x());
|
|
82
|
+
}, Ce = ee;
|
|
84
83
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
ee as PopMenu,
|
|
85
|
+
Z as PopMenuLabelPosition,
|
|
86
|
+
Y as PopMenuVariant,
|
|
87
|
+
Ce as default
|
|
88
88
|
};
|
|
89
89
|
//# sourceMappingURL=PopMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopMenu.js","sources":["../../../src/components/PopMenu/PopMenu.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { getColor } from '../../theme/currys';\nimport { breakpoints } from '../../theme/grid';\nimport { isComponent } from '../../utils/component';\nimport
|
|
1
|
+
{"version":3,"file":"PopMenu.js","sources":["../../../src/components/PopMenu/PopMenu.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { getColor } from '../../theme/currys';\nimport { breakpoints } from '../../theme/grid';\nimport { isComponent } from '../../utils/component';\nimport Icon, { SvgIcon } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\nimport VerticalDots from '../Icons/VerticalDots';\nimport X from '../Icons/X';\nimport LazyIcon from '../LazyIcon';\nimport LinkList, { LinkListProps, LinkProps } from '../LinkList';\nimport PopOver from '../PopOver';\n\nimport styles from './styles.module.scss';\n\nexport enum PopMenuVariant {\n onWhite = 'on-white',\n onGray = 'on-gray',\n onBlueberry = 'on-blueberry',\n}\n\nexport enum PopMenuLabelPosition {\n right = 'right',\n left = 'left',\n}\n\nexport interface PopMenuProps {\n /** Content shown inside PopOver. Can only be a LinkList */\n children: React.ReactElement<LinkListProps>;\n /** Adds custom classes to the popover element. */\n popOverClassName?: string;\n /** Adds custom classes to the element. */\n popMenuClassName?: string;\n /** Changes responsive design for the trigger buttons. */\n popMenuVariant?: PopMenuVariant;\n /** Sets the data-testid attribute for the button that opens. */\n openButtonTestId?: string;\n /** Sets the data-testid attribute for the button that closes. */\n closeButtonTestId?: string;\n /** Sets the data-testid attribute for the popover. */\n popOverTestId?: string;\n /** Sets the arial-label attribute for the openButton. */\n openButtonAriaLabel?: string;\n /** Sets the arial-label attribute for the closeButton. */\n closeButtonAriaLabel?: string;\n /** Sets the icon on the trigger button. */\n svgIcon?: SvgIcon | IconName;\n /** Optional text next to the trigger button. */\n labelText?: string;\n /** Placement of the label text relative to the trigger button. */\n labelTextPosition?: PopMenuLabelPosition;\n}\n\nexport const PopMenu: React.FC<PopMenuProps> = (props: PopMenuProps) => {\n const triggerButtonRef = useRef<HTMLButtonElement>(null);\n const iconRef = useRef<HTMLDivElement>(null);\n const popOverRef = useRef<HTMLDivElement>(null);\n const outerRef = useRef<HTMLDivElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n const {\n children,\n popOverClassName,\n popMenuClassName,\n openButtonTestId,\n closeButtonTestId,\n popOverTestId,\n popMenuVariant = PopMenuVariant.onWhite,\n openButtonAriaLabel,\n closeButtonAriaLabel,\n svgIcon,\n labelText,\n labelTextPosition = PopMenuLabelPosition.right,\n } = props;\n const buttonClasses = classNames(styles['pop-menu-button'], {\n [styles[`pop-menu-button--${popMenuVariant}`]]: popMenuVariant,\n });\n const breakpoint = useBreakpoint();\n const mobile = breakpoint < breakpoints.md;\n\n useOutsideEvent(outerRef, () => {\n setIsOpen(false);\n });\n\n const { isHovered: triggerButtonIsHovered } = useHover(triggerButtonRef);\n const mobileIconSize = mobile ? IconSize.XSmall : IconSize.Small;\n\n const handleClick = (cb?: () => void): void => {\n setIsOpen(false);\n cb && cb();\n };\n\n const renderChildren = () => {\n if (isComponent<LinkListProps>(children, LinkList)) {\n return (\n <PopOver\n testId={popOverTestId}\n className={classNames(styles['pop-menu__pop-over'], popOverClassName)}\n arrowClassName={styles['pop-menu__pop-over-arrow']}\n controllerRef={iconRef}\n popOverRef={popOverRef}\n >\n {React.Children.map(children, child =>\n React.cloneElement(child, {\n children: React.Children.map(child.props.children, child =>\n isComponent<LinkProps>(child, LinkList.Link)\n ? React.cloneElement(child, {\n onClick: (event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) =>\n handleClick(() => child.props.onClick && child.props.onClick(event)),\n })\n : child\n ),\n })\n )}\n </PopOver>\n );\n }\n };\n\n const toggleOpenOnClick = (e?: React.MouseEvent<HTMLElement, MouseEvent>): void => {\n e && e.stopPropagation();\n setIsOpen(!isOpen);\n };\n\n const iconComponent =\n svgIcon && typeof svgIcon === 'string' ? (\n <LazyIcon iconName={svgIcon} size={IconSize.XSmall} isHovered={triggerButtonIsHovered} />\n ) : (\n svgIcon && <Icon svgIcon={svgIcon} size={IconSize.XSmall} isHovered={triggerButtonIsHovered} />\n );\n\n const openIcon = svgIcon ? (\n iconComponent\n ) : (\n <Icon svgIcon={svgIcon ?? VerticalDots} color={getColor('black')} size={mobileIconSize} isHovered={triggerButtonIsHovered} />\n );\n\n const closeIcon = <Icon svgIcon={X} color={getColor('black')} size={mobileIconSize} isHovered={triggerButtonIsHovered} />;\n\n const triggerButton = (\n <button\n ref={triggerButtonRef}\n data-testid={isOpen ? closeButtonTestId : openButtonTestId}\n className={buttonClasses}\n aria-label={isOpen ? closeButtonAriaLabel : openButtonAriaLabel}\n aria-expanded={isOpen}\n onClick={toggleOpenOnClick}\n type=\"button\"\n >\n {labelText && labelTextPosition == PopMenuLabelPosition.left && <span>{labelText}</span>}\n {<div ref={iconRef}>{isOpen ? closeIcon : openIcon}</div>}\n {labelText && labelTextPosition == PopMenuLabelPosition.right && <span>{labelText}</span>}\n </button>\n );\n\n return (\n <div ref={outerRef} className={classNames(styles['pop-menu-button'], popMenuClassName)} data-analyticsid={AnalyticsId.PopMenu}>\n {triggerButton}\n {isOpen && renderChildren()}\n </div>\n );\n};\n\nexport default PopMenu;\n"],"names":["PopMenuVariant","PopMenuLabelPosition","PopMenu","props","triggerButtonRef","useRef","iconRef","popOverRef","outerRef","isOpen","setIsOpen","useState","children","popOverClassName","popMenuClassName","openButtonTestId","closeButtonTestId","popOverTestId","popMenuVariant","openButtonAriaLabel","closeButtonAriaLabel","svgIcon","labelText","labelTextPosition","buttonClasses","classNames","styles","mobile","useBreakpoint","breakpoints","useOutsideEvent","triggerButtonIsHovered","useHover","mobileIconSize","IconSize","handleClick","cb","renderChildren","isComponent","LinkList","React","PopOver","child","event","toggleOpenOnClick","e","iconComponent","LazyIcon","Icon","openIcon","VerticalDots","getColor","closeIcon","X","triggerButton","AnalyticsId","PopMenu$1"],"mappings":";;;;;;;;;;;;;;;;AAqBY,IAAAA,sBAAAA,OACVA,EAAA,UAAU,YACVA,EAAA,SAAS,WACTA,EAAA,cAAc,gBAHJA,IAAAA,KAAA,CAAA,CAAA,GAMAC,sBAAAA,OACVA,EAAA,QAAQ,SACRA,EAAA,OAAO,QAFGA,IAAAA,KAAA,CAAA,CAAA;AAgCC,MAAAC,KAAkC,CAACC,MAAwB;AAChE,QAAAC,IAAmBC,EAA0B,IAAI,GACjDC,IAAUD,EAAuB,IAAI,GACrCE,IAAaF,EAAuB,IAAI,GACxCG,IAAWH,EAAuB,IAAI,GACtC,CAACI,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC;AAAA,IACJ,UAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,eAAAC;AAAA,IACA,gBAAAC,IAAiB;AAAA,IACj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'react';
|
|
2
2
|
import { StoryObj } from '@storybook/react';
|
|
3
|
-
import { PopMenuVariant } from './PopMenu';
|
|
3
|
+
import { PopMenuLabelPosition, PopMenuVariant } from './PopMenu';
|
|
4
4
|
declare const meta: {
|
|
5
5
|
title: string;
|
|
6
6
|
component: React.FC<import("./PopMenu").PopMenuProps>;
|
|
@@ -24,10 +24,16 @@ declare const meta: {
|
|
|
24
24
|
control: string;
|
|
25
25
|
options: typeof PopMenuVariant;
|
|
26
26
|
};
|
|
27
|
+
labelTextPosition: {
|
|
28
|
+
control: string;
|
|
29
|
+
options: typeof PopMenuLabelPosition;
|
|
30
|
+
};
|
|
27
31
|
};
|
|
28
32
|
};
|
|
29
33
|
export default meta;
|
|
30
34
|
type Story = StoryObj<typeof meta>;
|
|
31
35
|
export declare const Default: Story;
|
|
36
|
+
export declare const CustomIcon: Story;
|
|
37
|
+
export declare const WithLabel: Story;
|
|
32
38
|
export declare const HorizontalScroll: Story;
|
|
33
39
|
export declare const CenteredOverflow: Story;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import e from "./PopMenu.js";
|
|
2
|
-
import { PopMenu as t, PopMenuVariant as a } from "./PopMenu.js";
|
|
2
|
+
import { PopMenu as r, PopMenuLabelPosition as t, PopMenuVariant as a } from "./PopMenu.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
4
|
+
r as PopMenu,
|
|
5
|
+
t as PopMenuLabelPosition,
|
|
5
6
|
a as PopMenuVariant,
|
|
6
7
|
e as default
|
|
7
8
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import r, { useRef as w, useState as A, useEffect as B } from "react";
|
|
2
|
+
import y from "classnames";
|
|
3
3
|
import { getVerticalPosition as F, getBubbleStyle as L, getArrowStyle as T } from "./utils.js";
|
|
4
4
|
import { ZIndex as V, AnalyticsId as Z } from "../../constants.js";
|
|
5
5
|
import { useInterval as $ } from "../../hooks/useInterval.js";
|
|
@@ -7,51 +7,51 @@ import { useIsVisible as j } from "../../hooks/useIsVisible.js";
|
|
|
7
7
|
import { useLayoutEvent as k } from "../../hooks/useLayoutEvent.js";
|
|
8
8
|
import { useSize as q } from "../../hooks/useSize.js";
|
|
9
9
|
import { mergeRefs as D } from "../../utils/refs.js";
|
|
10
|
-
import
|
|
11
|
-
var G = /* @__PURE__ */ ((
|
|
12
|
-
const
|
|
10
|
+
import t from "../PopOver/styles.module.scss";
|
|
11
|
+
var G = /* @__PURE__ */ ((o) => (o.positionautomatic = "positionautomatic", o.positionbelow = "positionbelow", o.positionabove = "positionabove", o))(G || {});
|
|
12
|
+
const S = r.forwardRef((o, _) => {
|
|
13
13
|
const {
|
|
14
|
-
id:
|
|
15
|
-
children:
|
|
14
|
+
id: R,
|
|
15
|
+
children: g,
|
|
16
16
|
controllerRef: n,
|
|
17
|
-
popOverRef:
|
|
18
|
-
show:
|
|
19
|
-
className:
|
|
20
|
-
variant:
|
|
21
|
-
role:
|
|
22
|
-
testId:
|
|
23
|
-
arrowClassName:
|
|
24
|
-
zIndex:
|
|
25
|
-
} =
|
|
26
|
-
var
|
|
27
|
-
|
|
17
|
+
popOverRef: z,
|
|
18
|
+
show: p = !1,
|
|
19
|
+
className: C = "",
|
|
20
|
+
variant: c = "positionautomatic",
|
|
21
|
+
role: m,
|
|
22
|
+
testId: I,
|
|
23
|
+
arrowClassName: N,
|
|
24
|
+
zIndex: u = V.PopOver
|
|
25
|
+
} = o, f = z || w(null), E = w(null), s = q(f), [e, O] = A(), v = j(n, 0), l = () => {
|
|
26
|
+
var d;
|
|
27
|
+
O((d = n.current) == null ? void 0 : d.getBoundingClientRect());
|
|
28
28
|
};
|
|
29
29
|
$(l, 500), k(l, ["scroll", "resize"], 10), B(() => {
|
|
30
30
|
l();
|
|
31
31
|
}, []);
|
|
32
|
-
const
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
|
|
36
|
-
}), a =
|
|
37
|
-
return /* @__PURE__ */
|
|
32
|
+
const b = m === "tooltip", P = y(t.popover, { [t["popover--visible"]]: b ? p : v }, C), i = e && s && F(e, s, c), x = y(t.popover__arrow, N, {
|
|
33
|
+
[t["popover__arrow--over"]]: i === "positionbelow",
|
|
34
|
+
[t["popover__arrow--under"]]: i === "positionabove",
|
|
35
|
+
[t["popover__arrow--visible"]]: b ? p : v
|
|
36
|
+
}), a = e && s && L(e, s, c), h = a && e && i && T(a, e, i);
|
|
37
|
+
return /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(
|
|
38
38
|
"div",
|
|
39
39
|
{
|
|
40
|
-
id:
|
|
41
|
-
ref: D([
|
|
40
|
+
id: R,
|
|
41
|
+
ref: D([_, f]),
|
|
42
42
|
className: P,
|
|
43
|
-
style: { ...a, zIndex:
|
|
44
|
-
"data-testid":
|
|
43
|
+
style: { ...a, zIndex: u },
|
|
44
|
+
"data-testid": I,
|
|
45
45
|
"data-analyticsid": Z.PopOver,
|
|
46
|
-
role:
|
|
46
|
+
role: m
|
|
47
47
|
},
|
|
48
|
-
|
|
49
|
-
), /* @__PURE__ */
|
|
48
|
+
g
|
|
49
|
+
), /* @__PURE__ */ r.createElement("div", { ref: E, className: x, style: { ...h, zIndex: u } }));
|
|
50
50
|
});
|
|
51
|
-
|
|
52
|
-
const
|
|
51
|
+
S.displayName = "PopOver";
|
|
52
|
+
const eo = S;
|
|
53
53
|
export {
|
|
54
54
|
G as PopOverVariant,
|
|
55
|
-
|
|
55
|
+
eo as default
|
|
56
56
|
};
|
|
57
57
|
//# sourceMappingURL=PopOver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopOver.js","sources":["../../../src/components/PopOver/PopOver.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { getArrowStyle, getBubbleStyle, getVerticalPosition } from './utils';\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport { useInterval } from '../../hooks/useInterval';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useLayoutEvent } from '../../hooks/useLayoutEvent';\nimport { useSize } from '../../hooks/useSize';\nimport { mergeRefs } from '../../utils/refs';\n\nimport styles from './styles.module.scss';\n\nexport enum PopOverVariant {\n positionautomatic = 'positionautomatic',\n positionbelow = 'positionbelow',\n positionabove = 'positionabove',\n}\n\nexport type PopOverRole = 'tooltip';\n\nexport interface PopOverProps {\n /** Id of the PopOver */\n id?: string;\n /** Content shown inside PopOver. Note that if role=\"tooltip\", you must not include interactive/focusable elements. */\n children: React.ReactNode;\n /** Ref for the element the PopOver is placed upon */\n controllerRef: React.RefObject<HTMLElement | SVGSVGElement>;\n /** Ref for the element the PopOver is placed upon */\n popOverRef?: React.RefObject<HTMLDivElement>;\n /** Show the popover. Only applies when role=tooltip. Default: false. */\n show?: boolean;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds custom classes to the arrow element. */\n arrowClassName?: string;\n /** Determines the placement of the popover. Default: automatic positioning. */\n variant?: keyof typeof PopOverVariant;\n /** Sets role of the PopOver element */\n role?: PopOverRole;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Overrides the default z-index of PopOver */\n zIndex?: number;\n}\n\nconst PopOver = React.forwardRef<HTMLDivElement | SVGSVGElement, PopOverProps>((props, ref) => {\n const {\n id,\n children,\n controllerRef,\n popOverRef,\n show = false,\n className = '',\n variant = PopOverVariant.positionautomatic,\n role,\n testId,\n arrowClassName,\n zIndex = ZIndex.PopOver,\n } = props;\n\n const bubbleRef = popOverRef || useRef<HTMLDivElement>(null);\n const arrowRef = useRef<HTMLDivElement>(null);\n const bubbleSize = useSize(bubbleRef);\n const [controllerSize, setControllerSize] = useState<DOMRect>();\n const controllerisVisible = useIsVisible(controllerRef, 0);\n\n const updateControllerSize = (): void => {\n setControllerSize(controllerRef.current?.getBoundingClientRect());\n };\n\n useInterval(updateControllerSize, 500);\n useLayoutEvent(updateControllerSize, ['scroll', 'resize'], 10);\n\n useEffect(() => {\n updateControllerSize();\n }, []);\n\n const isTooltip = role === 'tooltip';\n\n const popOverClasses = classNames(styles.popover, { [styles['popover--visible']]: isTooltip ? show : controllerisVisible }, className);\n const verticalPosition = controllerSize && bubbleSize && getVerticalPosition(controllerSize, bubbleSize, variant);\n const arrowClasses = classNames(styles.popover__arrow, arrowClassName, {\n [styles['popover__arrow--over']]: verticalPosition === PopOverVariant.positionbelow,\n [styles['popover__arrow--under']]: verticalPosition === PopOverVariant.positionabove,\n });\n\n const bubbleStyle = controllerSize && bubbleSize && getBubbleStyle(controllerSize, bubbleSize, variant);\n const arrowStyle = bubbleStyle && controllerSize && verticalPosition && getArrowStyle(bubbleStyle, controllerSize, verticalPosition);\n\n return (\n <>\n <div\n id={id}\n ref={mergeRefs([ref, bubbleRef])}\n className={popOverClasses}\n style={{ ...bubbleStyle, zIndex }}\n data-testid={testId}\n data-analyticsid={AnalyticsId.PopOver}\n role={role}\n >\n {children}\n </div>\n <div ref={arrowRef} className={arrowClasses} style={{ ...arrowStyle, zIndex }} />\n </>\n );\n});\n\nPopOver.displayName = 'PopOver';\n\nexport default PopOver;\n"],"names":["PopOverVariant","PopOver","React","props","ref","id","children","controllerRef","popOverRef","show","className","variant","role","testId","arrowClassName","zIndex","ZIndex","bubbleRef","useRef","arrowRef","bubbleSize","useSize","controllerSize","setControllerSize","useState","controllerisVisible","useIsVisible","updateControllerSize","_a","useInterval","useLayoutEvent","useEffect","isTooltip","popOverClasses","classNames","styles","verticalPosition","getVerticalPosition","arrowClasses","bubbleStyle","getBubbleStyle","arrowStyle","getArrowStyle","mergeRefs","AnalyticsId","PopOver$1"],"mappings":";;;;;;;;;;AAcY,IAAAA,sBAAAA,OACVA,EAAA,oBAAoB,qBACpBA,EAAA,gBAAgB,iBAChBA,EAAA,gBAAgB,iBAHNA,IAAAA,KAAA,CAAA,CAAA;AAiCZ,MAAMC,IAAUC,EAAM,WAAyD,CAACC,GAAOC,MAAQ;AACvF,QAAA;AAAA,IACJ,IAAAC;AAAA,IACA,UAAAC;AAAA,IACA,eAAAC;AAAA,IACA,YAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,WAAAC,IAAY;AAAA,IACZ,SAAAC,IAAU;AAAA,IACV,MAAAC;AAAA,IACA,QAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,QAAAC,IAASC,EAAO;AAAA,EACd,IAAAb,GAEEc,IAAYT,KAAcU,EAAuB,IAAI,GACrDC,IAAWD,EAAuB,IAAI,GACtCE,IAAaC,EAAQJ,CAAS,GAC9B,CAACK,GAAgBC,CAAiB,IAAIC,EAAkB,GACxDC,IAAsBC,EAAanB,GAAe,CAAC,GAEnDoB,IAAuB,MAAY;;AACrB,IAAAJ,GAAAK,IAAArB,EAAc,YAAd,gBAAAqB,EAAuB,uBAAuB;AAAA,EAAA;AAGlE,EAAAC,EAAYF,GAAsB,GAAG,GACrCG,EAAeH,GAAsB,CAAC,UAAU,QAAQ,GAAG,EAAE,GAE7DI,EAAU,MAAM;AACO,IAAAJ;EACvB,GAAG,CAAE,CAAA;AAEL,QAAMK,IAAYpB,MAAS,WAErBqB,IAAiBC,EAAWC,EAAO,SAAS,EAAE,CAACA,EAAO,kBAAkB,CAAC,GAAGH,IAAYvB,IAAOgB,KAAuBf,CAAS,GAC/H0B,IAAmBd,KAAkBF,KAAciB,EAAoBf,GAAgBF,GAAYT,CAAO,GAC1G2B,IAAeJ,EAAWC,EAAO,gBAAgBrB,GAAgB;AAAA,IACrE,CAACqB,EAAO,sBAAsB,CAAC,GAAGC,MAAqB;AAAA,IACvD,CAACD,EAAO,uBAAuB,CAAC,GAAGC,MAAqB;AAAA;AAAA,EAAA,CACzD,
|
|
1
|
+
{"version":3,"file":"PopOver.js","sources":["../../../src/components/PopOver/PopOver.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { getArrowStyle, getBubbleStyle, getVerticalPosition } from './utils';\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport { useInterval } from '../../hooks/useInterval';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useLayoutEvent } from '../../hooks/useLayoutEvent';\nimport { useSize } from '../../hooks/useSize';\nimport { mergeRefs } from '../../utils/refs';\n\nimport styles from './styles.module.scss';\n\nexport enum PopOverVariant {\n positionautomatic = 'positionautomatic',\n positionbelow = 'positionbelow',\n positionabove = 'positionabove',\n}\n\nexport type PopOverRole = 'tooltip';\n\nexport interface PopOverProps {\n /** Id of the PopOver */\n id?: string;\n /** Content shown inside PopOver. Note that if role=\"tooltip\", you must not include interactive/focusable elements. */\n children: React.ReactNode;\n /** Ref for the element the PopOver is placed upon */\n controllerRef: React.RefObject<HTMLElement | SVGSVGElement>;\n /** Ref for the element the PopOver is placed upon */\n popOverRef?: React.RefObject<HTMLDivElement>;\n /** Show the popover. Only applies when role=tooltip. Default: false. */\n show?: boolean;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds custom classes to the arrow element. */\n arrowClassName?: string;\n /** Determines the placement of the popover. Default: automatic positioning. */\n variant?: keyof typeof PopOverVariant;\n /** Sets role of the PopOver element */\n role?: PopOverRole;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Overrides the default z-index of PopOver */\n zIndex?: number;\n}\n\nconst PopOver = React.forwardRef<HTMLDivElement | SVGSVGElement, PopOverProps>((props, ref) => {\n const {\n id,\n children,\n controllerRef,\n popOverRef,\n show = false,\n className = '',\n variant = PopOverVariant.positionautomatic,\n role,\n testId,\n arrowClassName,\n zIndex = ZIndex.PopOver,\n } = props;\n\n const bubbleRef = popOverRef || useRef<HTMLDivElement>(null);\n const arrowRef = useRef<HTMLDivElement>(null);\n const bubbleSize = useSize(bubbleRef);\n const [controllerSize, setControllerSize] = useState<DOMRect>();\n const controllerisVisible = useIsVisible(controllerRef, 0);\n\n const updateControllerSize = (): void => {\n setControllerSize(controllerRef.current?.getBoundingClientRect());\n };\n\n useInterval(updateControllerSize, 500);\n useLayoutEvent(updateControllerSize, ['scroll', 'resize'], 10);\n\n useEffect(() => {\n updateControllerSize();\n }, []);\n\n const isTooltip = role === 'tooltip';\n\n const popOverClasses = classNames(styles.popover, { [styles['popover--visible']]: isTooltip ? show : controllerisVisible }, className);\n const verticalPosition = controllerSize && bubbleSize && getVerticalPosition(controllerSize, bubbleSize, variant);\n const arrowClasses = classNames(styles.popover__arrow, arrowClassName, {\n [styles['popover__arrow--over']]: verticalPosition === PopOverVariant.positionbelow,\n [styles['popover__arrow--under']]: verticalPosition === PopOverVariant.positionabove,\n [styles['popover__arrow--visible']]: isTooltip ? show : controllerisVisible,\n });\n\n const bubbleStyle = controllerSize && bubbleSize && getBubbleStyle(controllerSize, bubbleSize, variant);\n const arrowStyle = bubbleStyle && controllerSize && verticalPosition && getArrowStyle(bubbleStyle, controllerSize, verticalPosition);\n\n return (\n <>\n <div\n id={id}\n ref={mergeRefs([ref, bubbleRef])}\n className={popOverClasses}\n style={{ ...bubbleStyle, zIndex }}\n data-testid={testId}\n data-analyticsid={AnalyticsId.PopOver}\n role={role}\n >\n {children}\n </div>\n <div ref={arrowRef} className={arrowClasses} style={{ ...arrowStyle, zIndex }} />\n </>\n );\n});\n\nPopOver.displayName = 'PopOver';\n\nexport default PopOver;\n"],"names":["PopOverVariant","PopOver","React","props","ref","id","children","controllerRef","popOverRef","show","className","variant","role","testId","arrowClassName","zIndex","ZIndex","bubbleRef","useRef","arrowRef","bubbleSize","useSize","controllerSize","setControllerSize","useState","controllerisVisible","useIsVisible","updateControllerSize","_a","useInterval","useLayoutEvent","useEffect","isTooltip","popOverClasses","classNames","styles","verticalPosition","getVerticalPosition","arrowClasses","bubbleStyle","getBubbleStyle","arrowStyle","getArrowStyle","mergeRefs","AnalyticsId","PopOver$1"],"mappings":";;;;;;;;;;AAcY,IAAAA,sBAAAA,OACVA,EAAA,oBAAoB,qBACpBA,EAAA,gBAAgB,iBAChBA,EAAA,gBAAgB,iBAHNA,IAAAA,KAAA,CAAA,CAAA;AAiCZ,MAAMC,IAAUC,EAAM,WAAyD,CAACC,GAAO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,GAAajB,GAAgBc,CAAgB;AAEnI,SAEIlC,gBAAAA,EAAA,cAAAA,EAAA,UAAA,MAAAA,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAAG;AAAA,MACA,KAAKsC,EAAU,CAACvC,GAAKa,CAAS,CAAC;AAAA,MAC/B,WAAWgB;AAAA,MACX,OAAO,EAAE,GAAGM,GAAa,QAAAxB,EAAO;AAAA,MAChC,eAAaF;AAAA,MACb,oBAAkB+B,EAAY;AAAA,MAC9B,MAAAhC;AAAA,IAAA;AAAA,IAECN;AAAA,EAEH,GAAAJ,gBAAAA,EAAA,cAAC,OAAI,EAAA,KAAKiB,GAAU,WAAWmB,GAAc,OAAO,EAAE,GAAGG,GAAY,QAAA1B,KAAU,CACjF;AAEJ,CAAC;AAEDd,EAAQ,cAAc;AAEtB,MAAA4C,KAAe5C;"}
|
|
@@ -22,10 +22,6 @@
|
|
|
22
22
|
|
|
23
23
|
&--visible {
|
|
24
24
|
visibility: visible;
|
|
25
|
-
|
|
26
|
-
& + #{$popover}__arrow {
|
|
27
|
-
visibility: visible;
|
|
28
|
-
}
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
border: getSpacer(4xs) solid $plum600;
|
|
@@ -46,6 +42,7 @@
|
|
|
46
42
|
border-style: solid;
|
|
47
43
|
border-color: transparent;
|
|
48
44
|
z-index: 3;
|
|
45
|
+
visibility: hidden;
|
|
49
46
|
|
|
50
47
|
&--over {
|
|
51
48
|
border-width: 0.625rem;
|
|
@@ -60,9 +57,9 @@
|
|
|
60
57
|
filter: drop-shadow(var(--drop-shadow-color) 0 0.125rem 0.375rem 0.125rem);
|
|
61
58
|
filter: drop-shadow(0 0.2rem 0 var(--drop-shadow-color));
|
|
62
59
|
}
|
|
63
|
-
}
|
|
64
60
|
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
&--visible {
|
|
62
|
+
visibility: visible;
|
|
63
|
+
}
|
|
67
64
|
}
|
|
68
65
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import p, { useState as
|
|
1
|
+
import p, { useState as q } from "react";
|
|
2
2
|
import l from "classnames";
|
|
3
3
|
import { FormMode as i, FormSize as W, AnalyticsId as $ } from "../../constants.js";
|
|
4
4
|
import { usePseudoClasses as G } from "../../hooks/usePseudoClasses.js";
|
|
5
5
|
import { useUuid as H } from "../../hooks/useUuid.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { getAriaDescribedBy as J } from "../../utils/accessibility.js";
|
|
7
|
+
import { isMutableRefObject as K, mergeRefs as Q } from "../../utils/refs.js";
|
|
8
|
+
import { uuid as V } from "../../utils/uuid.js";
|
|
9
|
+
import { getLabelText as X, renderLabelAsParent as Y } from "../Label/Label.js";
|
|
9
10
|
import e from "../RadioButton/styles.module.scss";
|
|
10
|
-
const
|
|
11
|
+
const se = (s, o, a, b) => {
|
|
11
12
|
const n = o === "oninvalid", r = s === b;
|
|
12
13
|
return l({
|
|
13
14
|
[e["radio-button-label__large--on-grey"]]: a && o === "ongrey" && !r,
|
|
@@ -22,26 +23,26 @@ const ie = (s, o, a, b) => {
|
|
|
22
23
|
onChange: n,
|
|
23
24
|
disabled: r,
|
|
24
25
|
label: f,
|
|
25
|
-
inputId: _ =
|
|
26
|
+
inputId: _ = V(),
|
|
26
27
|
mode: d = i.onwhite,
|
|
27
28
|
name: w = _,
|
|
28
|
-
size:
|
|
29
|
+
size: B,
|
|
29
30
|
errorText: u,
|
|
30
|
-
error:
|
|
31
|
-
errorTextId:
|
|
32
|
-
value: N =
|
|
31
|
+
error: R = !!u,
|
|
32
|
+
errorTextId: k,
|
|
33
|
+
value: N = X(f),
|
|
33
34
|
testId: L,
|
|
34
35
|
required: x,
|
|
35
36
|
labelClassNames: I,
|
|
36
37
|
...S
|
|
37
|
-
} = s, g =
|
|
38
|
+
} = s, g = R || d === i.oninvalid, y = d === i.ondark, h = d === i.onblueberry, T = d === i.oninvalid, t = B === W.large, [A, E] = q(b), { refObject: F, isFocused: c } = G(K(o) ? o : null), j = Q([o, F]), C = H(k), z = l(e["radio-button-wrapper"], {
|
|
38
39
|
[e["radio-button-wrapper--with-error"]]: u,
|
|
39
40
|
[e["radio-button-wrapper__large"]]: t,
|
|
40
41
|
[e["radio-button-wrapper__large--focused"]]: t && c,
|
|
41
|
-
[e["radio-button-wrapper__large--selected"]]: t &&
|
|
42
|
+
[e["radio-button-wrapper__large--selected"]]: t && A && c,
|
|
42
43
|
[e["radio-button-wrapper__large--invalid"]]: t && T && c,
|
|
43
44
|
[e["radio-button-wrapper__large--on-blueberry"]]: t && h && c
|
|
44
|
-
}),
|
|
45
|
+
}), D = l(
|
|
45
46
|
e["radio-button-label"],
|
|
46
47
|
{
|
|
47
48
|
[e["radio-button-label--disabled"]]: r,
|
|
@@ -51,7 +52,7 @@ const ie = (s, o, a, b) => {
|
|
|
51
52
|
[e["radio-button-label__large--disabled"]]: t && r
|
|
52
53
|
},
|
|
53
54
|
I
|
|
54
|
-
),
|
|
55
|
+
), M = l(
|
|
55
56
|
e["radio-button"],
|
|
56
57
|
{
|
|
57
58
|
[e["radio-button--on-dark"]]: y,
|
|
@@ -63,41 +64,41 @@ const ie = (s, o, a, b) => {
|
|
|
63
64
|
[e["radio-button__large--invalid"]]: t && g
|
|
64
65
|
},
|
|
65
66
|
a
|
|
66
|
-
),
|
|
67
|
+
), O = l(e["radio-button-errors"]), P = (m) => {
|
|
67
68
|
E(m.target.checked), n && n(m);
|
|
68
|
-
},
|
|
69
|
+
}, U = () => /* @__PURE__ */ p.createElement(
|
|
69
70
|
"input",
|
|
70
71
|
{
|
|
71
72
|
id: _,
|
|
72
73
|
name: w,
|
|
73
|
-
className:
|
|
74
|
+
className: M,
|
|
74
75
|
type: "radio",
|
|
75
76
|
disabled: r,
|
|
76
77
|
value: N,
|
|
77
|
-
ref:
|
|
78
|
+
ref: j,
|
|
78
79
|
defaultChecked: b,
|
|
79
|
-
"aria-describedby":
|
|
80
|
+
"aria-describedby": J(s, C),
|
|
80
81
|
required: x,
|
|
81
82
|
...S,
|
|
82
|
-
onChange: (m) =>
|
|
83
|
+
onChange: (m) => P(m)
|
|
83
84
|
}
|
|
84
85
|
);
|
|
85
|
-
return /* @__PURE__ */ p.createElement("div", { "data-testid": L, "data-analyticsid": $.RadioButton, className:
|
|
86
|
+
return /* @__PURE__ */ p.createElement("div", { "data-testid": L, "data-analyticsid": $.RadioButton, className: z }, u && /* @__PURE__ */ p.createElement("p", { className: O, id: C }, u), Y(
|
|
86
87
|
f,
|
|
87
|
-
|
|
88
|
+
U(),
|
|
88
89
|
_,
|
|
89
90
|
d,
|
|
90
|
-
|
|
91
|
+
D,
|
|
91
92
|
void 0,
|
|
92
93
|
e["radiobutton-sublabel-wrapper"],
|
|
93
94
|
t
|
|
94
95
|
));
|
|
95
96
|
});
|
|
96
97
|
v.displayName = "RadioButton";
|
|
97
|
-
const
|
|
98
|
+
const be = v;
|
|
98
99
|
export {
|
|
99
100
|
v as RadioButton,
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
be as default,
|
|
102
|
+
se 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 { 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={[props['aria-describedby'] || '', errorTextUuid].join(' ')}\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","AnalyticsId","renderLabelAsParent","RadioButton$1"],"mappings":";;;;;;;;;AAwCO,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,UAAA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AA,IAAA;AAAA,EAAA;AAInC,yCACG,OAAI,EAAA,eAAaxB,GAAQ,oBAAkB0B,EAAY,aAAa,WAAWP,EAC7E,GAAAxB,qCACE,KAAE,EAAA,WAAW2B,GAAa,IAAIL,EAAA,GAC5BtB,CACH,GAEDgC;AAAA,IACCtC;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;AAE1B,MAAA+C,KAAe/C;"}
|
|
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","RadioButton$1"],"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;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,IACA,UAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,GAAGC;AAAA,EACD,IAAApB,GACEqB,I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