@helsenorge/designsystem-react 7.0.0-beta.1 → 7.0.0-beta.5
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 +29 -0
- package/__mocks__/usePseudoClasses.d.ts +1 -0
- package/__mocks__/usePseudoClasses.js +5 -0
- package/__mocks__/usePseudoClasses.js.map +1 -0
- package/components/AnchorLink/AnchorLink.d.ts +2 -1
- package/components/AnchorLink/AnchorLink.js.map +1 -1
- package/components/Badge/Badge.stories.d.ts +1 -1
- package/components/Button/Button.d.ts +2 -1
- package/components/Button/Button.js +88 -88
- package/components/Button/Button.js.map +1 -1
- package/components/Button/Button.stories.d.ts +1 -0
- package/components/Button/styles.module.scss +4 -0
- package/components/Button/styles.module.scss.d.ts +1 -0
- package/components/Checkbox/Checkbox.d.ts +2 -0
- package/components/Checkbox/Checkbox.js +72 -70
- package/components/Checkbox/Checkbox.js.map +1 -1
- package/components/Dropdown/Dropdown.d.ts +2 -0
- package/components/Dropdown/Dropdown.js +32 -31
- package/components/Dropdown/Dropdown.js.map +1 -1
- package/components/ErrorWrapper/ErrorWrapper.d.ts +4 -2
- package/components/ErrorWrapper/ErrorWrapper.js +7 -7
- package/components/ErrorWrapper/ErrorWrapper.js.map +1 -1
- package/components/Expander/Expander.d.ts +2 -0
- package/components/Expander/Expander.js +30 -29
- package/components/Expander/Expander.js.map +1 -1
- package/components/ExpanderHierarchy/expander.module.scss +0 -20
- package/components/ExpanderHierarchy/expander.module.scss.d.ts +0 -1
- package/components/ExpanderList/ExpanderList.d.ts +4 -0
- package/components/ExpanderList/ExpanderList.js +78 -75
- package/components/ExpanderList/ExpanderList.js.map +1 -1
- package/components/ExpanderList/ExpanderList.stories.d.ts +1 -1
- package/components/FormExample/FormExample.js +136 -216
- package/components/FormExample/FormExample.js.map +1 -1
- package/components/FormGroup/FormGroup.d.ts +2 -0
- package/components/FormGroup/FormGroup.js +62 -48
- package/components/FormGroup/FormGroup.js.map +1 -1
- package/components/FormGroup/FormGroup.stories.d.ts +1 -0
- package/components/FormLayout/styles.module.scss +1 -2
- package/components/GridExample/GridExample.js +1 -1
- package/components/GridExample/GridExample.js.map +1 -1
- package/components/HelpQuestion/styles.module.scss +3 -3
- package/components/Icon/Icon.stories.d.ts +5 -2
- package/components/Input/Input.d.ts +2 -0
- package/components/Input/Input.js +75 -74
- package/components/Input/Input.js.map +1 -1
- package/components/Input/Input.stories.d.ts +2 -2
- package/components/LinkList/LinkList.stories.d.ts +1 -1
- package/components/Loader/Loader.stories.d.ts +1 -1
- package/components/Logo/Logo.stories.d.ts +1 -1
- package/components/NotificationPanel/DetailButton/styles.module.scss +1 -1
- package/components/PopMenu/PopMenu.js +73 -61
- package/components/PopMenu/PopMenu.js.map +1 -1
- package/components/PopOver/PopOver.d.ts +2 -0
- package/components/PopOver/PopOver.js +37 -36
- package/components/PopOver/PopOver.js.map +1 -1
- package/components/RadioButton/RadioButton.d.ts +2 -0
- package/components/RadioButton/RadioButton.js +62 -60
- package/components/RadioButton/RadioButton.js.map +1 -1
- package/components/Select/Select.d.ts +2 -0
- package/components/Select/Select.js +40 -39
- package/components/Select/Select.js.map +1 -1
- package/components/SharingStatus/styles.module.scss +2 -0
- package/components/Textarea/Textarea.d.ts +4 -0
- package/components/Textarea/Textarea.js +70 -67
- package/components/Textarea/Textarea.js.map +1 -1
- package/components/Trigger/styles.module.scss +24 -4
- package/components/Validation/ErrorList.d.ts +7 -0
- package/components/Validation/ErrorList.js +8 -0
- package/components/Validation/ErrorList.js.map +1 -0
- package/components/Validation/ErrorListItem.d.ts +8 -0
- package/components/Validation/ErrorListItem.js +12 -0
- package/components/Validation/ErrorListItem.js.map +1 -0
- package/components/Validation/Validation.d.ts +9 -1
- package/components/Validation/Validation.js +15 -13
- package/components/Validation/Validation.js.map +1 -1
- package/components/Validation/ValidationSummary.d.ts +15 -0
- package/components/Validation/ValidationSummary.js +17 -0
- package/components/Validation/ValidationSummary.js.map +1 -0
- package/components/Validation/styles.module.scss +13 -5
- package/components/Validation/styles.module.scss.d.ts +4 -1
- package/components/Validation/types.d.ts +9 -0
- package/constants.d.ts +1 -0
- package/constants.js +1 -1
- package/constants.js.map +1 -1
- package/fonts/source-sans-pro-200-extralight.woff +0 -0
- package/fonts/source-sans-pro-200-extralight.woff2 +0 -0
- package/fonts/source-sans-pro-300-light.woff +0 -0
- package/fonts/source-sans-pro-300-light.woff2 +0 -0
- package/fonts/source-sans-pro-400-regular.woff +0 -0
- package/fonts/source-sans-pro-400-regular.woff2 +0 -0
- package/fonts/source-sans-pro-600-semibold.woff +0 -0
- package/fonts/source-sans-pro-600-semibold.woff2 +0 -0
- package/fonts/source-sans-pro-700-bold.woff +0 -0
- package/fonts/source-sans-pro-700-bold.woff2 +0 -0
- package/fonts/source-sans-pro-900-black.woff +0 -0
- package/fonts/source-sans-pro-900-black.woff2 +0 -0
- package/package.json +3 -3
- package/scss/_icon.scss +8 -0
- package/utils/tests/setup-test.d.ts +1 -0
|
@@ -1,107 +1,109 @@
|
|
|
1
|
-
import l, { useState as
|
|
1
|
+
import l, { useState as X, useEffect as $ } from "react";
|
|
2
2
|
import t from "classnames";
|
|
3
|
-
import { FormMode as
|
|
4
|
-
import { usePseudoClasses as
|
|
3
|
+
import { FormMode as i, FormSize as J, AnalyticsId as K, IconSize as Q } from "../../constants.js";
|
|
4
|
+
import { usePseudoClasses as V } from "../../hooks/usePseudoClasses.js";
|
|
5
|
+
import { useUuid as Y } from "../../hooks/useUuid.js";
|
|
5
6
|
import { getColor as h } from "../../theme/currys/color.js";
|
|
6
|
-
import { isMutableRefObject as
|
|
7
|
-
import { uuid as
|
|
8
|
-
import { Icon as
|
|
9
|
-
import
|
|
10
|
-
import { getLabelText as
|
|
7
|
+
import { isMutableRefObject as Z, mergeRefs as ee } from "../../utils/refs.js";
|
|
8
|
+
import { uuid as ce } from "../../utils/uuid.js";
|
|
9
|
+
import { Icon as re } from "../Icon/Icon.js";
|
|
10
|
+
import oe from "../Icons/Check.js";
|
|
11
|
+
import { getLabelText as ae, renderLabelAsParent as le } from "../Label/Label.js";
|
|
11
12
|
import e from "./styles.module.scss";
|
|
12
|
-
const
|
|
13
|
+
const I = l.forwardRef((x, d) => {
|
|
13
14
|
const {
|
|
14
|
-
className:
|
|
15
|
+
className: N,
|
|
15
16
|
checked: k = !1,
|
|
16
17
|
disabled: a,
|
|
17
18
|
label: m,
|
|
18
|
-
inputId: p =
|
|
19
|
-
mode: n =
|
|
20
|
-
name:
|
|
21
|
-
size:
|
|
19
|
+
inputId: p = ce(),
|
|
20
|
+
mode: n = i.onwhite,
|
|
21
|
+
name: E = p,
|
|
22
|
+
size: S,
|
|
22
23
|
errorText: s,
|
|
23
24
|
error: g = !!s,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
errorTextId: R,
|
|
26
|
+
value: T = ae(m),
|
|
27
|
+
testId: z,
|
|
28
|
+
required: F,
|
|
27
29
|
onChange: u,
|
|
28
|
-
...
|
|
29
|
-
} = x, [
|
|
30
|
+
...L
|
|
31
|
+
} = x, [r, w] = X(k), f = Y(R), C = n === i.onwhite, y = n === i.ongrey, v = n === i.onblueberry, o = g || n === i.oninvalid, b = n === i.ondark, c = S === J.large, { refObject: j, isFocused: W } = V(Z(d) ? d : null), A = ee([d, j]), M = t(e["checkbox-wrapper"], {
|
|
30
32
|
[e["checkbox-wrapper--with-error"]]: s,
|
|
31
33
|
[e["checkbox-wrapper--large"]]: c
|
|
32
|
-
}),
|
|
34
|
+
}), O = t(e["checkbox-label"], {
|
|
33
35
|
[e["checkbox-label--disabled"]]: a,
|
|
34
|
-
[e["checkbox-label--on-dark"]]:
|
|
36
|
+
[e["checkbox-label--on-dark"]]: b,
|
|
35
37
|
[e["checkbox-label--large"]]: c,
|
|
36
|
-
[e["checkbox-label__large--checked"]]: c &&
|
|
37
|
-
[e["checkbox-label__large--focus"]]: c &&
|
|
38
|
-
[e["checkbox-label__large--on-white"]]: c &&
|
|
39
|
-
[e["checkbox-label__large--on-grey"]]: c &&
|
|
40
|
-
[e["checkbox-label__large--on-blueberry"]]: c &&
|
|
41
|
-
[e["checkbox-label__large--on-invalid"]]: c &&
|
|
38
|
+
[e["checkbox-label__large--checked"]]: c && r,
|
|
39
|
+
[e["checkbox-label__large--focus"]]: c && W,
|
|
40
|
+
[e["checkbox-label__large--on-white"]]: c && C,
|
|
41
|
+
[e["checkbox-label__large--on-grey"]]: c && y,
|
|
42
|
+
[e["checkbox-label__large--on-blueberry"]]: c && v,
|
|
43
|
+
[e["checkbox-label__large--on-invalid"]]: c && o,
|
|
42
44
|
[e["checkbox-label__large--disabled"]]: c && a
|
|
43
|
-
}),
|
|
44
|
-
[e["checkbox__icon-wrapper--on-white"]]:
|
|
45
|
-
[e["checkbox__icon-wrapper--on-grey"]]:
|
|
46
|
-
[e["checkbox__icon-wrapper--on-invalid"]]:
|
|
45
|
+
}), P = t(e.checkbox, N), U = t(e["checkbox__icon-wrapper"], {
|
|
46
|
+
[e["checkbox__icon-wrapper--on-white"]]: C,
|
|
47
|
+
[e["checkbox__icon-wrapper--on-grey"]]: y,
|
|
48
|
+
[e["checkbox__icon-wrapper--on-invalid"]]: o,
|
|
47
49
|
[e["checkbox__icon-wrapper--disabled"]]: a,
|
|
48
|
-
[e["checkbox__icon-wrapper__regular--checked"]]: !c &&
|
|
49
|
-
[e["checkbox__icon-wrapper__regular--invalid"]]: !c &&
|
|
50
|
-
[e["checkbox__icon-wrapper__regular--on-dark"]]: !c &&
|
|
51
|
-
[e["checkbox__icon-wrapper__large--checked"]]: c &&
|
|
52
|
-
[e["checkbox__icon-wrapper__large--invalid"]]: c &&
|
|
53
|
-
[e["checkbox__icon-wrapper--on-dark"]]:
|
|
54
|
-
[e["checkbox__icon-wrapper--on-blueberry"]]:
|
|
55
|
-
[e["checkbox__icon-wrapper--invalid"]]:
|
|
56
|
-
[e["checkbox__icon-wrapper__large--invalid"]]: c &&
|
|
57
|
-
[e["checkbox__icon-wrapper__large--disabled"]]: a && c &&
|
|
58
|
-
[e["checkbox__icon-wrapper__large--checked--invalid"]]: c &&
|
|
59
|
-
[e["checkbox__icon-wrapper__large--checked--disabled"]]: a && c &&
|
|
60
|
-
}),
|
|
61
|
-
[e["checkbox-label__text__large--checked"]]: c &&
|
|
62
|
-
[e["checkbox-label__text__large--invalid"]]: c &&
|
|
63
|
-
[e["checkbox-label__text--on-dark"]]:
|
|
50
|
+
[e["checkbox__icon-wrapper__regular--checked"]]: !c && r,
|
|
51
|
+
[e["checkbox__icon-wrapper__regular--invalid"]]: !c && r && o,
|
|
52
|
+
[e["checkbox__icon-wrapper__regular--on-dark"]]: !c && r && b,
|
|
53
|
+
[e["checkbox__icon-wrapper__large--checked"]]: c && r,
|
|
54
|
+
[e["checkbox__icon-wrapper__large--invalid"]]: c && o,
|
|
55
|
+
[e["checkbox__icon-wrapper--on-dark"]]: b,
|
|
56
|
+
[e["checkbox__icon-wrapper--on-blueberry"]]: v,
|
|
57
|
+
[e["checkbox__icon-wrapper--invalid"]]: o,
|
|
58
|
+
[e["checkbox__icon-wrapper__large--invalid"]]: c && r && o,
|
|
59
|
+
[e["checkbox__icon-wrapper__large--disabled"]]: a && c && r,
|
|
60
|
+
[e["checkbox__icon-wrapper__large--checked--invalid"]]: c && r && o,
|
|
61
|
+
[e["checkbox__icon-wrapper__large--checked--disabled"]]: a && c && r
|
|
62
|
+
}), q = t(e["checkbox-label__text"], {
|
|
63
|
+
[e["checkbox-label__text__large--checked"]]: c && r,
|
|
64
|
+
[e["checkbox-label__text__large--invalid"]]: c && r && o,
|
|
65
|
+
[e["checkbox-label__text--on-dark"]]: b,
|
|
64
66
|
[e["checkbox-label__text--disabled"]]: a
|
|
65
|
-
}),
|
|
67
|
+
}), B = t(e["checkbox-errors"]);
|
|
66
68
|
let _ = h("white");
|
|
67
|
-
(
|
|
69
|
+
(b || c && r) && (_ = h("blueberry", 900)), o && c && r && (_ = h("white")), a && (_ = h("neutral", 400)), $(() => {
|
|
68
70
|
w(k);
|
|
69
71
|
}, [k]);
|
|
70
|
-
const
|
|
71
|
-
u && u(
|
|
72
|
-
},
|
|
72
|
+
const D = (H) => {
|
|
73
|
+
u && u(H), w(!r);
|
|
74
|
+
}, G = () => /* @__PURE__ */ l.createElement(l.Fragment, null, /* @__PURE__ */ l.createElement(
|
|
73
75
|
"input",
|
|
74
76
|
{
|
|
75
77
|
id: p,
|
|
76
|
-
name:
|
|
77
|
-
className:
|
|
78
|
+
name: E,
|
|
79
|
+
className: P,
|
|
78
80
|
type: "checkbox",
|
|
79
|
-
checked:
|
|
81
|
+
checked: r,
|
|
80
82
|
disabled: a,
|
|
81
|
-
value:
|
|
82
|
-
ref:
|
|
83
|
-
"aria-describedby": x["aria-describedby"]
|
|
83
|
+
value: T,
|
|
84
|
+
ref: A,
|
|
85
|
+
"aria-describedby": [x["aria-describedby"] || "", f].join(" "),
|
|
84
86
|
"aria-invalid": g,
|
|
85
|
-
required:
|
|
86
|
-
onChange:
|
|
87
|
-
...
|
|
87
|
+
required: F,
|
|
88
|
+
onChange: D,
|
|
89
|
+
...L
|
|
88
90
|
}
|
|
89
|
-
), /* @__PURE__ */ l.createElement("span", { className:
|
|
90
|
-
return /* @__PURE__ */ l.createElement("div", { "data-testid":
|
|
91
|
+
), /* @__PURE__ */ l.createElement("span", { className: U }, r && /* @__PURE__ */ l.createElement(re, { color: _, className: e.checkbox__icon, svgIcon: oe, size: Q.XSmall })));
|
|
92
|
+
return /* @__PURE__ */ l.createElement("div", { "data-testid": z, "data-analyticsid": K.Checkbox, className: M }, s && /* @__PURE__ */ l.createElement("p", { className: B, id: f }, s), le(
|
|
91
93
|
m,
|
|
92
|
-
|
|
94
|
+
G(),
|
|
93
95
|
p,
|
|
94
96
|
n,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
O,
|
|
98
|
+
q,
|
|
97
99
|
e["checkbox-sublabel-wrapper"],
|
|
98
100
|
c
|
|
99
101
|
));
|
|
100
102
|
});
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
+
I.displayName = "Checkbox";
|
|
104
|
+
const ge = I;
|
|
103
105
|
export {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
I as Checkbox,
|
|
107
|
+
ge as default
|
|
106
108
|
};
|
|
107
109
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormMode, FormSize, IconSize } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getColor } from '../../theme/currys/color';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport Icon from '../Icon';\nimport Check from '../Icons/Check';\nimport { getLabelText, renderLabelAsParent } from '../Label';\n\nimport checkboxStyles from './styles.module.scss';\n\nexport interface CheckboxProps\n extends Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the checkbox - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** input id of the checkbox */\n inputId?: string;\n /** Changes the visuals of the checkbox */\n mode?: keyof typeof FormMode;\n /** Changes the visuals of the checkbox */\n size?: keyof typeof FormSize;\n /** Activates Error style for the checkbox - 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 /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Checkbox = React.forwardRef((props: CheckboxProps, ref: React.Ref<HTMLInputElement>) => {\n const {\n className,\n checked = false,\n disabled,\n label,\n inputId = uuid(),\n mode = FormMode.onwhite,\n name = inputId,\n size,\n errorText,\n error = !!errorText,\n value = getLabelText(label),\n testId,\n required,\n onChange,\n ...rest\n } = props;\n const [isChecked, setIsChecked] = useState(checked);\n const onWhite = mode === FormMode.onwhite;\n const onGrey = mode === FormMode.ongrey;\n const onBlueberry = mode === FormMode.onblueberry;\n const onInvalid = error || mode === FormMode.oninvalid;\n const onDark = mode === FormMode.ondark;\n const large = size === FormSize.large;\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n\n const checkboxWrapperClasses = classNames(checkboxStyles['checkbox-wrapper'], {\n [checkboxStyles['checkbox-wrapper--with-error']]: errorText,\n [checkboxStyles['checkbox-wrapper--large']]: large,\n });\n const checkboxLabelClasses = classNames(checkboxStyles['checkbox-label'], {\n [checkboxStyles['checkbox-label--disabled']]: disabled,\n [checkboxStyles['checkbox-label--on-dark']]: onDark,\n [checkboxStyles['checkbox-label--large']]: large,\n [checkboxStyles['checkbox-label__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__large--focus']]: large && isFocused,\n [checkboxStyles['checkbox-label__large--on-white']]: large && onWhite,\n [checkboxStyles['checkbox-label__large--on-grey']]: large && onGrey,\n [checkboxStyles['checkbox-label__large--on-blueberry']]: large && onBlueberry,\n [checkboxStyles['checkbox-label__large--on-invalid']]: large && onInvalid,\n [checkboxStyles['checkbox-label__large--disabled']]: large && disabled,\n });\n const checkboxClasses = classNames(checkboxStyles.checkbox, className);\n const checkboxIconWrapperClasses = classNames(checkboxStyles['checkbox__icon-wrapper'], {\n [checkboxStyles['checkbox__icon-wrapper--on-white']]: onWhite,\n [checkboxStyles['checkbox__icon-wrapper--on-grey']]: onGrey,\n [checkboxStyles['checkbox__icon-wrapper--on-invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--disabled']]: disabled,\n [checkboxStyles['checkbox__icon-wrapper__regular--checked']]: !large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__regular--invalid']]: !large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__regular--on-dark']]: !large && isChecked && onDark,\n [checkboxStyles['checkbox__icon-wrapper__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--on-dark']]: onDark,\n [checkboxStyles['checkbox__icon-wrapper--on-blueberry']]: onBlueberry,\n [checkboxStyles['checkbox__icon-wrapper--invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--disabled']]: disabled && large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--disabled']]: disabled && large && isChecked,\n });\n const labelTextClasses = classNames(checkboxStyles['checkbox-label__text'], {\n [checkboxStyles['checkbox-label__text__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__text__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox-label__text--on-dark']]: onDark,\n [checkboxStyles['checkbox-label__text--disabled']]: disabled,\n });\n const errorStyles = classNames(checkboxStyles['checkbox-errors']);\n\n let iconColor = getColor('white');\n if (onDark || (large && isChecked)) iconColor = getColor('blueberry', 900);\n if (onInvalid && large && isChecked) iconColor = getColor('white');\n if (disabled) iconColor = getColor('neutral', 400);\n\n useEffect(() => {\n setIsChecked(checked);\n }, [checked]);\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLInputElement>): void => {\n if (onChange) {\n onChange(e);\n }\n\n setIsChecked(!isChecked);\n };\n\n const getLabelContent = (): React.ReactNode => {\n return (\n <>\n <input\n id={inputId}\n name={name}\n className={checkboxClasses}\n type=\"checkbox\"\n checked={isChecked}\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n aria-describedby={props['aria-describedby'] ?? undefined}\n aria-invalid={error}\n required={required}\n onChange={onChangeHandler}\n {...rest}\n />\n <span className={checkboxIconWrapperClasses}>\n {isChecked && <Icon color={iconColor} className={checkboxStyles['checkbox__icon']} svgIcon={Check} size={IconSize.XSmall} />}\n </span>\n </>\n );\n };\n\n return (\n <div data-testid={testId} data-analyticsid={AnalyticsId.Checkbox} className={checkboxWrapperClasses}>\n {errorText && <p className={errorStyles}>{errorText}</p>}\n {renderLabelAsParent(\n label,\n getLabelContent(),\n inputId,\n mode as FormMode,\n checkboxLabelClasses,\n labelTextClasses,\n checkboxStyles['checkbox-sublabel-wrapper'],\n large\n )}\n </div>\n );\n});\n\nCheckbox.displayName = 'Checkbox';\n\nexport default Checkbox;\n"],"names":["Checkbox","React","props","ref","className","checked","disabled","label","inputId","uuid","mode","FormMode","name","size","errorText","error","value","getLabelText","testId","required","onChange","rest","isChecked","setIsChecked","useState","onWhite","onGrey","onBlueberry","onInvalid","onDark","large","FormSize","refObject","isFocused","usePseudoClasses","isMutableRefObject","mergedRefs","mergeRefs","checkboxWrapperClasses","classNames","checkboxStyles","checkboxLabelClasses","checkboxClasses","checkboxIconWrapperClasses","labelTextClasses","errorStyles","iconColor","getColor","useEffect","onChangeHandler","e","getLabelContent","Icon","Check","IconSize","AnalyticsId","renderLabelAsParent","Checkbox$1"],"mappings":";;;;;;;;;;;AAsCO,MAAMA,IAAWC,EAAM,WAAW,CAACC,GAAsBC,MAAqC;AAC7F,QAAA;AAAA,IACJ,WAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC,IAAUC,EAAK;AAAA,IACf,MAAAC,IAAOC,EAAS;AAAA,IAChB,MAAAC,IAAOJ;AAAA,IACP,MAAAK;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC,IAAQ,CAAC,CAACD;AAAA,IACV,OAAAE,IAAQC,GAAaV,CAAK;AAAA,IAC1B,QAAAW;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,GAAGC;AAAA,EACD,IAAAnB,GACE,CAACoB,GAAWC,CAAY,IAAIC,EAASnB,CAAO,GAC5CoB,IAAUf,MAASC,E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"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormMode, FormSize, IconSize } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys/color';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport Icon from '../Icon';\nimport Check from '../Icons/Check';\nimport { getLabelText, renderLabelAsParent } from '../Label';\n\nimport checkboxStyles from './styles.module.scss';\n\nexport interface CheckboxProps\n extends Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the checkbox - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** input id of the checkbox */\n inputId?: string;\n /** Changes the visuals of the checkbox */\n mode?: keyof typeof FormMode;\n /** Changes the visuals of the checkbox */\n size?: keyof typeof FormSize;\n /** Activates Error style for the checkbox - 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 Checkbox = React.forwardRef((props: CheckboxProps, ref: React.Ref<HTMLInputElement>) => {\n const {\n className,\n checked = false,\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 onChange,\n ...rest\n } = props;\n const [isChecked, setIsChecked] = useState(checked);\n const errorTextUuid = useUuid(errorTextId);\n const onWhite = mode === FormMode.onwhite;\n const onGrey = mode === FormMode.ongrey;\n const onBlueberry = mode === FormMode.onblueberry;\n const onInvalid = error || mode === FormMode.oninvalid;\n const onDark = mode === FormMode.ondark;\n const large = size === FormSize.large;\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n\n const checkboxWrapperClasses = classNames(checkboxStyles['checkbox-wrapper'], {\n [checkboxStyles['checkbox-wrapper--with-error']]: errorText,\n [checkboxStyles['checkbox-wrapper--large']]: large,\n });\n const checkboxLabelClasses = classNames(checkboxStyles['checkbox-label'], {\n [checkboxStyles['checkbox-label--disabled']]: disabled,\n [checkboxStyles['checkbox-label--on-dark']]: onDark,\n [checkboxStyles['checkbox-label--large']]: large,\n [checkboxStyles['checkbox-label__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__large--focus']]: large && isFocused,\n [checkboxStyles['checkbox-label__large--on-white']]: large && onWhite,\n [checkboxStyles['checkbox-label__large--on-grey']]: large && onGrey,\n [checkboxStyles['checkbox-label__large--on-blueberry']]: large && onBlueberry,\n [checkboxStyles['checkbox-label__large--on-invalid']]: large && onInvalid,\n [checkboxStyles['checkbox-label__large--disabled']]: large && disabled,\n });\n const checkboxClasses = classNames(checkboxStyles.checkbox, className);\n const checkboxIconWrapperClasses = classNames(checkboxStyles['checkbox__icon-wrapper'], {\n [checkboxStyles['checkbox__icon-wrapper--on-white']]: onWhite,\n [checkboxStyles['checkbox__icon-wrapper--on-grey']]: onGrey,\n [checkboxStyles['checkbox__icon-wrapper--on-invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--disabled']]: disabled,\n [checkboxStyles['checkbox__icon-wrapper__regular--checked']]: !large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__regular--invalid']]: !large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__regular--on-dark']]: !large && isChecked && onDark,\n [checkboxStyles['checkbox__icon-wrapper__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--on-dark']]: onDark,\n [checkboxStyles['checkbox__icon-wrapper--on-blueberry']]: onBlueberry,\n [checkboxStyles['checkbox__icon-wrapper--invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--disabled']]: disabled && large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--disabled']]: disabled && large && isChecked,\n });\n const labelTextClasses = classNames(checkboxStyles['checkbox-label__text'], {\n [checkboxStyles['checkbox-label__text__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__text__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox-label__text--on-dark']]: onDark,\n [checkboxStyles['checkbox-label__text--disabled']]: disabled,\n });\n const errorStyles = classNames(checkboxStyles['checkbox-errors']);\n\n let iconColor = getColor('white');\n if (onDark || (large && isChecked)) iconColor = getColor('blueberry', 900);\n if (onInvalid && large && isChecked) iconColor = getColor('white');\n if (disabled) iconColor = getColor('neutral', 400);\n\n useEffect(() => {\n setIsChecked(checked);\n }, [checked]);\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLInputElement>): void => {\n if (onChange) {\n onChange(e);\n }\n\n setIsChecked(!isChecked);\n };\n\n const getLabelContent = (): React.ReactNode => {\n return (\n <>\n <input\n id={inputId}\n name={name}\n className={checkboxClasses}\n type=\"checkbox\"\n checked={isChecked}\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n aria-describedby={[props['aria-describedby'] || '', errorTextUuid].join(' ')}\n aria-invalid={error}\n required={required}\n onChange={onChangeHandler}\n {...rest}\n />\n <span className={checkboxIconWrapperClasses}>\n {isChecked && <Icon color={iconColor} className={checkboxStyles['checkbox__icon']} svgIcon={Check} size={IconSize.XSmall} />}\n </span>\n </>\n );\n };\n\n return (\n <div data-testid={testId} data-analyticsid={AnalyticsId.Checkbox} className={checkboxWrapperClasses}>\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 checkboxLabelClasses,\n labelTextClasses,\n checkboxStyles['checkbox-sublabel-wrapper'],\n large\n )}\n </div>\n );\n});\n\nCheckbox.displayName = 'Checkbox';\n\nexport default Checkbox;\n"],"names":["Checkbox","React","props","ref","className","checked","disabled","label","inputId","uuid","mode","FormMode","name","size","errorText","error","errorTextId","value","getLabelText","testId","required","onChange","rest","isChecked","setIsChecked","useState","errorTextUuid","useUuid","onWhite","onGrey","onBlueberry","onInvalid","onDark","large","FormSize","refObject","isFocused","usePseudoClasses","isMutableRefObject","mergedRefs","mergeRefs","checkboxWrapperClasses","classNames","checkboxStyles","checkboxLabelClasses","checkboxClasses","checkboxIconWrapperClasses","labelTextClasses","errorStyles","iconColor","getColor","useEffect","onChangeHandler","e","getLabelContent","Icon","Check","IconSize","AnalyticsId","renderLabelAsParent","Checkbox$1"],"mappings":";;;;;;;;;;;;AAyCO,MAAMA,IAAWC,EAAM,WAAW,CAACC,GAAsBC,MAAqC;AAC7F,QAAA;AAAA,IACJ,WAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC,IAAUC,GAAK;AAAA,IACf,MAAAC,IAAOC,EAAS;AAAA,IAChB,MAAAC,IAAOJ;AAAA,IACP,MAAAK;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC,IAAQ,CAAC,CAACD;AAAA,IACV,aAAAE;AAAA,IACA,OAAAC,IAAQC,GAAaX,CAAK;AAAA,IAC1B,QAAAY;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,GAAGC;AAAA,EACD,IAAApB,GACE,CAACqB,GAAWC,CAAY,IAAIC,EAASpB,CAAO,GAC5CqB,IAAgBC,EAAQX,CAAW,GACnCY,IAAUlB,MAASC,EAAS,SAC5BkB,IAASnB,MAASC,EAAS,QAC3BmB,IAAcpB,MAASC,EAAS,aAChCoB,IAAY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AAanB,CAAO;AAAA,EAAA,GACnB,CAACA,CAAO,CAAC;AAEN,QAAA+C,IAAkB,CAACC,MAAiD;AACxE,IAAIhC,KACFA,EAASgC,CAAC,GAGZ7B,EAAa,CAACD,CAAS;AAAA,EAAA,GAGnB+B,IAAkB,MAGlBrD,gBAAAA,EAAA,cAAAA,EAAA,UAAA,MAAAA,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAIO;AAAA,MACJ,MAAAI;AAAA,MACA,WAAWiC;AAAA,MACX,MAAK;AAAA,MACL,SAAStB;AAAA,MACT,UAAAjB;AAAA,MACA,OAAAW;AAAA,MACA,KAAKsB;AAAA,MACL,oBAAkB,CAACrC,EAAM,kBAAkB,KAAK,IAAIwB,CAAa,EAAE,KAAK,GAAG;AAAA,MAC3E,gBAAcX;AAAA,MACd,UAAAK;AAAA,MACA,UAAUgC;AAAA,MACT,GAAG9B;AAAA,IAAA;AAAA,EACN,mCACC,QAAK,EAAA,WAAWwB,KACdvB,KAAatB,gBAAAA,EAAA,cAACsD,MAAK,OAAON,GAAW,WAAWN,EAAe,gBAAmB,SAASa,IAAO,MAAMC,EAAS,OAAQ,CAAA,CAC5H,CACF;AAIJ,yCACG,OAAI,EAAA,eAAatC,GAAQ,oBAAkBuC,EAAY,UAAU,WAAWjB,EAC1E,GAAA3B,qCACE,KAAE,EAAA,WAAWkC,GAAa,IAAItB,EAAA,GAC5BZ,CACH,GAED6C;AAAA,IACCpD;AAAA,IACA+C,EAAgB;AAAA,IAChB9C;AAAA,IACAE;AAAA,IACAkC;AAAA,IACAG;AAAA,IACAJ,EAAe,2BAA2B;AAAA,IAC1CV;AAAA,EAAA,CAEJ;AAEJ,CAAC;AAEDjC,EAAS,cAAc;AAEvB,MAAA4D,KAAe5D;"}
|
|
@@ -30,6 +30,8 @@ export interface DropdownProps {
|
|
|
30
30
|
disabled?: boolean;
|
|
31
31
|
/** Sets the data-testid attribute on the dropdown button. */
|
|
32
32
|
testId?: string;
|
|
33
|
+
/** Overrides the default z-index of the DropDownContent */
|
|
34
|
+
zIndex?: number;
|
|
33
35
|
}
|
|
34
36
|
declare const Dropdown: React.FC<DropdownProps>;
|
|
35
37
|
export default Dropdown;
|
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import r, { useRef as g, useState as
|
|
1
|
+
import r, { useRef as g, useState as X } from "react";
|
|
2
2
|
import k from "classnames";
|
|
3
3
|
import { theme as C } from "../../theme/index.js";
|
|
4
4
|
import "../../hooks/useBreakpoint.js";
|
|
5
|
-
import { useHover as
|
|
5
|
+
import { useHover as Z } from "../../hooks/useHover.js";
|
|
6
6
|
import { useSize as j } from "../../hooks/useSize.js";
|
|
7
7
|
import { useToggle as q } from "../../hooks/useToggle.js";
|
|
8
8
|
import { useKeyboardEvent as F } from "../../hooks/useKeyboardEvent.js";
|
|
9
9
|
import { useOutsideEvent as G } from "../../hooks/useOutsideEvent.js";
|
|
10
10
|
import { useUuid as _ } from "../../hooks/useUuid.js";
|
|
11
|
-
import { KeyboardEventKey as n, AnalyticsId as
|
|
12
|
-
import { mergeRefs as
|
|
13
|
-
import
|
|
14
|
-
import { Icon as
|
|
15
|
-
import
|
|
11
|
+
import { ZIndex as J, KeyboardEventKey as n, AnalyticsId as Q, IconSize as Y } from "../../constants.js";
|
|
12
|
+
import { mergeRefs as M } from "../../utils/refs.js";
|
|
13
|
+
import ee from "../Button/Button.js";
|
|
14
|
+
import { Icon as oe } from "../Icon/Icon.js";
|
|
15
|
+
import re from "../Icons/PlusSmall.js";
|
|
16
16
|
import o from "./styles.module.scss";
|
|
17
|
-
var
|
|
18
|
-
const
|
|
17
|
+
var te = /* @__PURE__ */ ((d) => (d.onwhite = "onwhite", d.ongrey = "ongrey", d.onblueberry = "onblueberry", d.oncherry = "oncherry", d))(te || {});
|
|
18
|
+
const ne = (d) => {
|
|
19
19
|
const {
|
|
20
20
|
label: R,
|
|
21
21
|
placeholder: $,
|
|
22
22
|
closeText: A = "Lukk",
|
|
23
23
|
noCloseButton: H = !1,
|
|
24
24
|
onToggle: K,
|
|
25
|
-
open:
|
|
25
|
+
open: O = !1,
|
|
26
26
|
children: y,
|
|
27
27
|
mode: c = "onwhite",
|
|
28
|
-
transparent:
|
|
28
|
+
transparent: S = !1,
|
|
29
29
|
fluid: b = !1,
|
|
30
30
|
testId: z,
|
|
31
|
-
disabled: i
|
|
32
|
-
|
|
31
|
+
disabled: i,
|
|
32
|
+
zIndex: D = J.PopOver
|
|
33
|
+
} = d, p = g(null), w = g(null), { hoverRef: m, isHovered: L } = Z(), { value: l, toggleValue: h } = q(!i && O, K), a = g(r.Children.map(y, () => r.createRef())), [u, P] = X(), { width: T } = j(m) || {}, E = _(), I = _(), x = _(), v = () => {
|
|
33
34
|
var e;
|
|
34
35
|
h(), (e = w.current) == null || e.focus();
|
|
35
36
|
}, f = () => {
|
|
@@ -37,7 +38,7 @@ const re = (d) => {
|
|
|
37
38
|
h(), (e = m.current) == null || e.focus();
|
|
38
39
|
};
|
|
39
40
|
F(p, (e) => {
|
|
40
|
-
var
|
|
41
|
+
var N;
|
|
41
42
|
if (e.preventDefault(), !a.current)
|
|
42
43
|
return;
|
|
43
44
|
if (l) {
|
|
@@ -46,12 +47,12 @@ const re = (d) => {
|
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
49
|
} else {
|
|
49
|
-
|
|
50
|
+
v();
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
|
-
const t = a.current.findIndex((
|
|
53
|
+
const t = a.current.findIndex((W) => W.current === e.target);
|
|
53
54
|
let s = t;
|
|
54
|
-
e.key === n.Home ? s = 0 : e.key === n.End ? s = a.current.length - 1 : e.key === n.ArrowDown && t < a.current.length - 1 ? s = t + 1 : e.key === n.ArrowUp && t > 0 ? s = t - 1 : e.key === n.Enter && t !== -1 && (s = t), s !== -1 && ((
|
|
55
|
+
e.key === n.Home ? s = 0 : e.key === n.End ? s = a.current.length - 1 : e.key === n.ArrowDown && t < a.current.length - 1 ? s = t + 1 : e.key === n.ArrowUp && t > 0 ? s = t - 1 : e.key === n.Enter && t !== -1 && (s = t), s !== -1 && ((N = a.current[s].current) == null || N.focus(), P(s));
|
|
55
56
|
}, [
|
|
56
57
|
n.ArrowDown,
|
|
57
58
|
n.ArrowUp,
|
|
@@ -67,20 +68,20 @@ const re = (d) => {
|
|
|
67
68
|
[o["dropdown__toggle--on-grey"]]: c === "ongrey",
|
|
68
69
|
[o["dropdown__toggle--on-blueberry"]]: c === "onblueberry",
|
|
69
70
|
[o["dropdown__toggle--on-cherry"]]: c === "oncherry",
|
|
70
|
-
[o["dropdown__toggle--transparent"]]:
|
|
71
|
+
[o["dropdown__toggle--transparent"]]: S,
|
|
71
72
|
[o["dropdown__toggle--fluid"]]: b,
|
|
72
73
|
[o["dropdown__toggle--open"]]: l
|
|
73
74
|
}
|
|
74
|
-
), B = k(o.dropdown__content, l && o["dropdown__content--open"]),
|
|
75
|
+
), B = k(o.dropdown__content, l && o["dropdown__content--open"]), V = r.Children.map(y, (e, t) => /* @__PURE__ */ r.createElement("li", { className: o.dropdown__input, role: "option", id: `${x}-${t}`, "aria-selected": t === u }, r.isValidElement(e) && a.current && a.current[t] ? r.cloneElement(e, { ref: M([e.props.ref, a.current[t]]) }) : e));
|
|
75
76
|
return /* @__PURE__ */ r.createElement("div", { className: o.dropdown, ref: p }, /* @__PURE__ */ r.createElement("span", { id: E, className: o.dropdown__label }, R), /* @__PURE__ */ r.createElement(
|
|
76
77
|
"button",
|
|
77
78
|
{
|
|
78
79
|
type: "button",
|
|
79
|
-
onClick: () => !l &&
|
|
80
|
+
onClick: () => !l && v(),
|
|
80
81
|
className: U,
|
|
81
82
|
ref: m,
|
|
82
83
|
"data-testid": z,
|
|
83
|
-
"data-analyticsid":
|
|
84
|
+
"data-analyticsid": Q.Dropdown,
|
|
84
85
|
disabled: i,
|
|
85
86
|
"aria-labelledby": I,
|
|
86
87
|
"aria-haspopup": "listbox",
|
|
@@ -88,16 +89,16 @@ const re = (d) => {
|
|
|
88
89
|
},
|
|
89
90
|
/* @__PURE__ */ r.createElement("span", { id: I, className: o.dropdown__toggle__label }, $),
|
|
90
91
|
/* @__PURE__ */ r.createElement(
|
|
91
|
-
|
|
92
|
+
oe,
|
|
92
93
|
{
|
|
93
94
|
color: i ? C.palette.neutral700 : C.palette.blueberry600,
|
|
94
|
-
svgIcon:
|
|
95
|
+
svgIcon: re,
|
|
95
96
|
className: o.dropdown__icon,
|
|
96
|
-
isHovered: !i &&
|
|
97
|
-
size:
|
|
97
|
+
isHovered: !i && L,
|
|
98
|
+
size: Y.XSmall
|
|
98
99
|
}
|
|
99
100
|
)
|
|
100
|
-
), /* @__PURE__ */ r.createElement("div", { className: B, style: { width: b ? "100%" : `${T}px
|
|
101
|
+
), /* @__PURE__ */ r.createElement("div", { className: B, style: { width: b ? "100%" : `${T}px`, zIndex: D } }, /* @__PURE__ */ r.createElement(
|
|
101
102
|
"ul",
|
|
102
103
|
{
|
|
103
104
|
className: o.dropdown__options,
|
|
@@ -107,11 +108,11 @@ const re = (d) => {
|
|
|
107
108
|
"aria-activedescendant": typeof u < "u" ? `${x}-${u}` : void 0,
|
|
108
109
|
ref: w
|
|
109
110
|
},
|
|
110
|
-
|
|
111
|
-
), !H && /* @__PURE__ */ r.createElement("div", { className: o.dropdown__close }, /* @__PURE__ */ r.createElement(
|
|
112
|
-
},
|
|
111
|
+
V
|
|
112
|
+
), !H && /* @__PURE__ */ r.createElement("div", { className: o.dropdown__close }, /* @__PURE__ */ r.createElement(ee, { onClick: f, fluid: !0, "aria-expanded": l }, A))));
|
|
113
|
+
}, Ie = ne;
|
|
113
114
|
export {
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
te as DropdownMode,
|
|
116
|
+
Ie as default
|
|
116
117
|
};
|
|
117
118
|
//# sourceMappingURL=Dropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sources":["../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport {\n AnalyticsId,\n IconSize,\n KeyboardEventKey,\n theme,\n useHover,\n useKeyboardEvent,\n useOutsideEvent,\n useSize,\n useToggle,\n useUuid,\n} from '../..';\nimport { mergeRefs } from '../../utils/refs';\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport PlusSmall from '../Icons/PlusSmall';\n\nimport styles from './styles.module.scss';\n\nexport enum DropdownMode {\n onwhite = 'onwhite',\n ongrey = 'ongrey',\n onblueberry = 'onblueberry',\n oncherry = 'oncherry',\n}\n\nexport interface DropdownProps {\n /** Label for dropdown. Synlig for skjermlesere. */\n label: string;\n /** Tekst på knappen som åpner dropdownen */\n placeholder: string;\n /** Sets the dropdown content */\n children: React.ReactNode;\n /** Close button text */\n closeText?: string;\n /** No close button */\n noCloseButton?: boolean;\n /** Called when dropdown is open/closed. */\n onToggle?: (isOpen: boolean) => void;\n /** Om dropdown er åpen */\n open?: boolean;\n /** Changes the visuals of the dropdown */\n mode?: keyof typeof DropdownMode;\n /** Makes the background transparent */\n transparent?: boolean;\n /** Makes the background transparent */\n fluid?: boolean;\n /** Makes the dropdown disabled */\n disabled?: boolean;\n /** Sets the data-testid attribute on the dropdown button. */\n testId?: string;\n}\n\nconst Dropdown: React.FC<DropdownProps> = props => {\n const {\n label,\n placeholder,\n closeText = 'Lukk',\n noCloseButton = false,\n onToggle,\n open = false,\n children,\n mode = DropdownMode.onwhite,\n transparent = false,\n fluid = false,\n testId,\n disabled,\n } = props;\n const dropdownRef = useRef<HTMLDivElement>(null);\n const optionsRef = useRef<HTMLUListElement>(null);\n const { hoverRef: buttonRef, isHovered } = useHover<HTMLButtonElement>();\n const { value: isOpen, toggleValue: toggleIsOpen } = useToggle(!disabled && open, onToggle);\n const inputRefList = useRef(React.Children.map(children, () => React.createRef<HTMLElement>()));\n const [currentIndex, setCurrentIndex] = useState<number>();\n const { width: buttonWidth } = useSize(buttonRef) || {};\n const labelId = useUuid();\n const toggleLabelId = useUuid();\n const optionIdPrefix = useUuid();\n\n const handleOpen = (): void => {\n toggleIsOpen();\n optionsRef.current?.focus();\n };\n\n const handleClose = (): void => {\n toggleIsOpen();\n buttonRef.current?.focus();\n };\n\n const handleKeyboardNavigation = (event: KeyboardEvent): void => {\n event.preventDefault();\n\n if (!inputRefList.current) {\n return;\n }\n\n if (!isOpen) {\n handleOpen();\n return;\n } else if (event.key === KeyboardEventKey.Escape && isOpen) {\n handleClose();\n return;\n }\n\n const index = inputRefList.current.findIndex(x => x.current === event.target);\n let nextIndex = index;\n\n if (event.key === KeyboardEventKey.Home) {\n nextIndex = 0;\n } else if (event.key === KeyboardEventKey.End) {\n nextIndex = inputRefList.current.length - 1;\n } else if (event.key === KeyboardEventKey.ArrowDown && index < inputRefList.current.length - 1) {\n nextIndex = index + 1;\n } else if (event.key === KeyboardEventKey.ArrowUp && index > 0) {\n nextIndex = index - 1;\n } else if (event.key === KeyboardEventKey.Enter && index !== -1) {\n nextIndex = index;\n }\n if (nextIndex !== -1) {\n inputRefList.current[nextIndex].current?.focus();\n setCurrentIndex(nextIndex);\n }\n };\n\n useKeyboardEvent(dropdownRef, handleKeyboardNavigation, [\n KeyboardEventKey.ArrowDown,\n KeyboardEventKey.ArrowUp,\n KeyboardEventKey.End,\n KeyboardEventKey.Enter,\n KeyboardEventKey.Escape,\n KeyboardEventKey.Home,\n ]);\n\n useOutsideEvent(dropdownRef, () => isOpen && handleClose());\n\n const toggleClasses = classNames(\n styles.dropdown__toggle,\n !disabled && {\n [styles['dropdown__toggle--on-white']]: mode === DropdownMode.onwhite,\n [styles['dropdown__toggle--on-grey']]: mode === DropdownMode.ongrey,\n [styles['dropdown__toggle--on-blueberry']]: mode === DropdownMode.onblueberry,\n [styles['dropdown__toggle--on-cherry']]: mode === DropdownMode.oncherry,\n [styles['dropdown__toggle--transparent']]: transparent,\n [styles['dropdown__toggle--fluid']]: fluid,\n [styles['dropdown__toggle--open']]: isOpen,\n }\n );\n\n const contentClasses = classNames(styles.dropdown__content, isOpen && styles['dropdown__content--open']);\n\n const renderChildren = React.Children.map(children, (child, index) => (\n <li className={styles.dropdown__input} role=\"option\" id={`${optionIdPrefix}-${index}`} aria-selected={index === currentIndex}>\n {React.isValidElement(child) && inputRefList.current && inputRefList.current[index]\n ? React.cloneElement(child as React.ReactElement, { ref: mergeRefs([child.props.ref, inputRefList.current[index]]) })\n : child}\n </li>\n ));\n\n return (\n <div className={styles.dropdown} ref={dropdownRef}>\n <span id={labelId} className={styles.dropdown__label}>\n {label}\n </span>\n <button\n type=\"button\"\n onClick={() => !isOpen && handleOpen()}\n className={toggleClasses}\n ref={buttonRef}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Dropdown}\n disabled={disabled}\n aria-labelledby={toggleLabelId}\n aria-haspopup=\"listbox\"\n aria-expanded={isOpen}\n >\n <span id={toggleLabelId} className={styles.dropdown__toggle__label}>\n {placeholder}\n </span>\n <Icon\n color={disabled ? theme.palette.neutral700 : theme.palette.blueberry600}\n svgIcon={PlusSmall}\n className={styles.dropdown__icon}\n isHovered={!disabled && isHovered}\n size={IconSize.XSmall}\n />\n </button>\n <div className={contentClasses} style={{ width: fluid ? '100%' : `${buttonWidth}px` }}>\n <ul\n className={styles.dropdown__options}\n role=\"listbox\"\n aria-labelledby={labelId}\n tabIndex={-1}\n aria-activedescendant={typeof currentIndex !== 'undefined' ? `${optionIdPrefix}-${currentIndex}` : undefined}\n ref={optionsRef}\n >\n {renderChildren}\n </ul>\n {!noCloseButton && (\n <div className={styles.dropdown__close}>\n <Button onClick={handleClose} fluid aria-expanded={isOpen}>\n {closeText}\n </Button>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default Dropdown;\n"],"names":["DropdownMode","Dropdown","props","label","placeholder","closeText","noCloseButton","onToggle","open","children","mode","transparent","fluid","testId","disabled","dropdownRef","useRef","optionsRef","buttonRef","isHovered","useHover","isOpen","toggleIsOpen","useToggle","inputRefList","React","currentIndex","setCurrentIndex","useState","buttonWidth","useSize","labelId","useUuid","toggleLabelId","optionIdPrefix","handleOpen","_a","handleClose","useKeyboardEvent","event","KeyboardEventKey","index","x","nextIndex","useOutsideEvent","toggleClasses","classNames","styles","contentClasses","renderChildren","child","mergeRefs","AnalyticsId","Icon","theme","PlusSmall","IconSize","Button","Dropdown$1"],"mappings":";;;;;;;;;;;;;;;;AAuBY,IAAAA,uBAAAA,OACVA,EAAA,UAAU,WACVA,EAAA,SAAS,UACTA,EAAA,cAAc,eACdA,EAAA,WAAW,YAJDA,IAAAA,MAAA,CAAA,CAAA;AAkCZ,MAAMC,KAAoC,CAASC,MAAA;AAC3C,QAAA;AAAA,IACJ,OAAAC;AAAA,IACA,aAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,eAAAC,IAAgB;AAAA,IAChB,UAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,UAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,aAAAC,IAAc;AAAA,IACd,OAAAC,IAAQ;AAAA,IACR,QAAAC;AAAA,IACA,UAAAC;AAAA,EACE,IAAAZ,GACEa,IAAcC,EAAuB,IAAI,GACzCC,IAAaD,EAAyB,IAAI,GAC1C,EAAE,UAAUE,GAAW,WAAAC,MAAcC,EAA4B,GACjE,EAAE,OAAOC,GAAQ,aAAaC,EAAA,IAAiBC,EAAU,CAACT,KAAYN,GAAMD,CAAQ,GACpFiB,IAAeR,EAAOS,EAAM,SAAS,IAAIhB,GAAU,MAAMgB,EAAM,UAAwB,CAAA,CAAC,GACxF,CAACC,GAAcC,CAAe,IAAIC,EAAiB,GACnD,EAAE,OAAOC,EAAA,IAAgBC,EAAQZ,CAAS,KAAK,IAC/Ca,IAAUC,KACVC,IAAgBD,KAChBE,IAAiBF,KAEjBG,IAAa,MAAY;;AAChB,IAAAb,MACbc,IAAAnB,EAAW,YAAX,QAAAmB,EAAoB;AAAA,EAAM,GAGtBC,IAAc,MAAY;;AACjB,IAAAf,MACbc,IAAAlB,EAAU,YAAV,QAAAkB,EAAm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;AAAA,QACC,OAAOvC,IAAWwC,EAAM,QAAQ,aAAaA,EAAM,QAAQ;AAAA,QAC3D,SAASC;AAAA,QACT,WAAWR,EAAO;AAAA,QAClB,WAAW,CAACjC,KAAYK;AAAA,QACxB,MAAMqC,EAAS;AAAA,MAAA;AAAA,IACjB;AAAA,EAAA,GAEF/B,gBAAAA,EAAA,cAAC,OAAI,EAAA,WAAWuB,GAAgB,OAAO,EAAE,OAAOpC,IAAQ,SAAS,GAAGiB,CAAW,KAC7E,EAAA,GAAAJ,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWsB,EAAO;AAAA,MAClB,MAAK;AAAA,MACL,mBAAiBhB;AAAA,MACjB,UAAU;AAAA,MACV,yBAAuB,OAAOL,IAAiB,MAAc,GAAGQ,CAAc,IAAIR,CAAY,KAAK;AAAA,MACnG,KAAKT;AAAA,IAAA;AAAA,IAEJgC;AAAA,EAAA,GAEF,CAAC3C,qCACC,OAAI,EAAA,WAAWyC,EAAO,gBACrB,GAAAtB,gBAAAA,EAAA,cAACgC,KAAO,SAASpB,GAAa,OAAK,IAAC,iBAAehB,KAChDhB,CACH,CACF,CAEJ,CACF;AAEJ,GAEAqD,KAAezD;"}
|
|
1
|
+
{"version":3,"file":"Dropdown.js","sources":["../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport {\n AnalyticsId,\n IconSize,\n KeyboardEventKey,\n ZIndex,\n theme,\n useHover,\n useKeyboardEvent,\n useOutsideEvent,\n useSize,\n useToggle,\n useUuid,\n} from '../..';\nimport { mergeRefs } from '../../utils/refs';\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport PlusSmall from '../Icons/PlusSmall';\n\nimport styles from './styles.module.scss';\n\nexport enum DropdownMode {\n onwhite = 'onwhite',\n ongrey = 'ongrey',\n onblueberry = 'onblueberry',\n oncherry = 'oncherry',\n}\n\nexport interface DropdownProps {\n /** Label for dropdown. Synlig for skjermlesere. */\n label: string;\n /** Tekst på knappen som åpner dropdownen */\n placeholder: string;\n /** Sets the dropdown content */\n children: React.ReactNode;\n /** Close button text */\n closeText?: string;\n /** No close button */\n noCloseButton?: boolean;\n /** Called when dropdown is open/closed. */\n onToggle?: (isOpen: boolean) => void;\n /** Om dropdown er åpen */\n open?: boolean;\n /** Changes the visuals of the dropdown */\n mode?: keyof typeof DropdownMode;\n /** Makes the background transparent */\n transparent?: boolean;\n /** Makes the background transparent */\n fluid?: boolean;\n /** Makes the dropdown disabled */\n disabled?: boolean;\n /** Sets the data-testid attribute on the dropdown button. */\n testId?: string;\n /** Overrides the default z-index of the DropDownContent */\n zIndex?: number;\n}\n\nconst Dropdown: React.FC<DropdownProps> = props => {\n const {\n label,\n placeholder,\n closeText = 'Lukk',\n noCloseButton = false,\n onToggle,\n open = false,\n children,\n mode = DropdownMode.onwhite,\n transparent = false,\n fluid = false,\n testId,\n disabled,\n zIndex = ZIndex.PopOver,\n } = props;\n const dropdownRef = useRef<HTMLDivElement>(null);\n const optionsRef = useRef<HTMLUListElement>(null);\n const { hoverRef: buttonRef, isHovered } = useHover<HTMLButtonElement>();\n const { value: isOpen, toggleValue: toggleIsOpen } = useToggle(!disabled && open, onToggle);\n const inputRefList = useRef(React.Children.map(children, () => React.createRef<HTMLElement>()));\n const [currentIndex, setCurrentIndex] = useState<number>();\n const { width: buttonWidth } = useSize(buttonRef) || {};\n const labelId = useUuid();\n const toggleLabelId = useUuid();\n const optionIdPrefix = useUuid();\n\n const handleOpen = (): void => {\n toggleIsOpen();\n optionsRef.current?.focus();\n };\n\n const handleClose = (): void => {\n toggleIsOpen();\n buttonRef.current?.focus();\n };\n\n const handleKeyboardNavigation = (event: KeyboardEvent): void => {\n event.preventDefault();\n\n if (!inputRefList.current) {\n return;\n }\n\n if (!isOpen) {\n handleOpen();\n return;\n } else if (event.key === KeyboardEventKey.Escape && isOpen) {\n handleClose();\n return;\n }\n\n const index = inputRefList.current.findIndex(x => x.current === event.target);\n let nextIndex = index;\n\n if (event.key === KeyboardEventKey.Home) {\n nextIndex = 0;\n } else if (event.key === KeyboardEventKey.End) {\n nextIndex = inputRefList.current.length - 1;\n } else if (event.key === KeyboardEventKey.ArrowDown && index < inputRefList.current.length - 1) {\n nextIndex = index + 1;\n } else if (event.key === KeyboardEventKey.ArrowUp && index > 0) {\n nextIndex = index - 1;\n } else if (event.key === KeyboardEventKey.Enter && index !== -1) {\n nextIndex = index;\n }\n if (nextIndex !== -1) {\n inputRefList.current[nextIndex].current?.focus();\n setCurrentIndex(nextIndex);\n }\n };\n\n useKeyboardEvent(dropdownRef, handleKeyboardNavigation, [\n KeyboardEventKey.ArrowDown,\n KeyboardEventKey.ArrowUp,\n KeyboardEventKey.End,\n KeyboardEventKey.Enter,\n KeyboardEventKey.Escape,\n KeyboardEventKey.Home,\n ]);\n\n useOutsideEvent(dropdownRef, () => isOpen && handleClose());\n\n const toggleClasses = classNames(\n styles.dropdown__toggle,\n !disabled && {\n [styles['dropdown__toggle--on-white']]: mode === DropdownMode.onwhite,\n [styles['dropdown__toggle--on-grey']]: mode === DropdownMode.ongrey,\n [styles['dropdown__toggle--on-blueberry']]: mode === DropdownMode.onblueberry,\n [styles['dropdown__toggle--on-cherry']]: mode === DropdownMode.oncherry,\n [styles['dropdown__toggle--transparent']]: transparent,\n [styles['dropdown__toggle--fluid']]: fluid,\n [styles['dropdown__toggle--open']]: isOpen,\n }\n );\n\n const contentClasses = classNames(styles.dropdown__content, isOpen && styles['dropdown__content--open']);\n\n const renderChildren = React.Children.map(children, (child, index) => (\n <li className={styles.dropdown__input} role=\"option\" id={`${optionIdPrefix}-${index}`} aria-selected={index === currentIndex}>\n {React.isValidElement(child) && inputRefList.current && inputRefList.current[index]\n ? React.cloneElement(child as React.ReactElement, { ref: mergeRefs([child.props.ref, inputRefList.current[index]]) })\n : child}\n </li>\n ));\n\n return (\n <div className={styles.dropdown} ref={dropdownRef}>\n <span id={labelId} className={styles.dropdown__label}>\n {label}\n </span>\n <button\n type=\"button\"\n onClick={(): false | void => !isOpen && handleOpen()}\n className={toggleClasses}\n ref={buttonRef}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Dropdown}\n disabled={disabled}\n aria-labelledby={toggleLabelId}\n aria-haspopup=\"listbox\"\n aria-expanded={isOpen}\n >\n <span id={toggleLabelId} className={styles.dropdown__toggle__label}>\n {placeholder}\n </span>\n <Icon\n color={disabled ? theme.palette.neutral700 : theme.palette.blueberry600}\n svgIcon={PlusSmall}\n className={styles.dropdown__icon}\n isHovered={!disabled && isHovered}\n size={IconSize.XSmall}\n />\n </button>\n <div className={contentClasses} style={{ width: fluid ? '100%' : `${buttonWidth}px`, zIndex: zIndex }}>\n <ul\n className={styles.dropdown__options}\n role=\"listbox\"\n aria-labelledby={labelId}\n tabIndex={-1}\n aria-activedescendant={typeof currentIndex !== 'undefined' ? `${optionIdPrefix}-${currentIndex}` : undefined}\n ref={optionsRef}\n >\n {renderChildren}\n </ul>\n {!noCloseButton && (\n <div className={styles.dropdown__close}>\n <Button onClick={handleClose} fluid aria-expanded={isOpen}>\n {closeText}\n </Button>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default Dropdown;\n"],"names":["DropdownMode","Dropdown","props","label","placeholder","closeText","noCloseButton","onToggle","open","children","mode","transparent","fluid","testId","disabled","zIndex","ZIndex","dropdownRef","useRef","optionsRef","buttonRef","isHovered","useHover","isOpen","toggleIsOpen","useToggle","inputRefList","React","currentIndex","setCurrentIndex","useState","buttonWidth","useSize","labelId","useUuid","toggleLabelId","optionIdPrefix","handleOpen","_a","handleClose","useKeyboardEvent","event","KeyboardEventKey","index","x","nextIndex","useOutsideEvent","toggleClasses","classNames","styles","contentClasses","renderChildren","child","mergeRefs","AnalyticsId","Icon","theme","PlusSmall","IconSize","Button","Dropdown$1"],"mappings":";;;;;;;;;;;;;;;;AAwBY,IAAAA,uBAAAA,OACVA,EAAA,UAAU,WACVA,EAAA,SAAS,UACTA,EAAA,cAA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AAgB,OAAO,EAAE,OAAOtC,IAAQ,SAAS,GAAGmB,CAAW,MAAM,QAAAhB,EACnF,EAAA,GAAAY,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWsB,EAAO;AAAA,MAClB,MAAK;AAAA,MACL,mBAAiBhB;AAAA,MACjB,UAAU;AAAA,MACV,yBAAuB,OAAOL,IAAiB,MAAc,GAAGQ,CAAc,IAAIR,CAAY,KAAK;AAAA,MACnG,KAAKT;AAAA,IAAA;AAAA,IAEJgC;AAAA,EAAA,GAEF,CAAC7C,qCACC,OAAI,EAAA,WAAW2C,EAAO,gBACrB,GAAAtB,gBAAAA,EAAA,cAACgC,MAAO,SAASpB,GAAa,OAAK,IAAC,iBAAehB,KAChDlB,CACH,CACF,CAEJ,CACF;AAEJ,GAEAuD,KAAe3D;"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface ErrorWrapperProps {
|
|
3
|
-
/** Error message */
|
|
4
|
-
errorText?: string;
|
|
5
3
|
/** Form component */
|
|
6
4
|
children?: React.ReactNode;
|
|
5
|
+
/** Error message */
|
|
6
|
+
errorText?: string;
|
|
7
|
+
/** Error text id */
|
|
8
|
+
errorTextId?: string;
|
|
7
9
|
/** Adds custom classes to the element. */
|
|
8
10
|
className?: string;
|
|
9
11
|
/** Sets the data-testid attribute. */
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from "react";
|
|
2
2
|
import o from "classnames";
|
|
3
3
|
import e from "./styles.module.scss";
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
return /* @__PURE__ */
|
|
7
|
-
},
|
|
4
|
+
const s = (r) => {
|
|
5
|
+
const a = o(e["error-wrapper"], r.errorText && e["error-wrapper--with-error"], r.className);
|
|
6
|
+
return /* @__PURE__ */ t.createElement("div", { className: a, "data-testid": r.testId }, r.errorText && /* @__PURE__ */ t.createElement("p", { className: e["error-wrapper__errors"], id: r.errorTextId }, r.errorText), r.children);
|
|
7
|
+
}, d = s;
|
|
8
8
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
s as ErrorWrapper,
|
|
10
|
+
d as default
|
|
11
11
|
};
|
|
12
12
|
//# sourceMappingURL=ErrorWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorWrapper.js","sources":["../../../src/components/ErrorWrapper/ErrorWrapper.tsx"],"sourcesContent":["import React from 'react';\n\nimport cn from 'classnames';\n\nimport styles from './styles.module.scss';\n\nexport interface ErrorWrapperProps {\n /** Error message */\n errorText?: string;\n /**
|
|
1
|
+
{"version":3,"file":"ErrorWrapper.js","sources":["../../../src/components/ErrorWrapper/ErrorWrapper.tsx"],"sourcesContent":["import React from 'react';\n\nimport cn from 'classnames';\n\nimport styles from './styles.module.scss';\n\nexport interface ErrorWrapperProps {\n /** Form component */\n children?: React.ReactNode;\n /** Error message */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const ErrorWrapper: React.FC<ErrorWrapperProps> = props => {\n const errorWrapperClasses = cn(styles['error-wrapper'], props.errorText && styles[`error-wrapper--with-error`], props.className);\n\n return (\n <div className={errorWrapperClasses} data-testid={props.testId}>\n {props.errorText && (\n <p className={styles['error-wrapper__errors']} id={props.errorTextId}>\n {props.errorText}\n </p>\n )}\n {props.children}\n </div>\n );\n};\n\nexport default ErrorWrapper;\n"],"names":["ErrorWrapper","props","errorWrapperClasses","cn","styles","React","ErrorWrapper$1"],"mappings":";;;AAmBO,MAAMA,IAA4C,CAASC,MAAA;AAC1D,QAAAC,IAAsBC,EAAGC,EAAO,eAAe,GAAGH,EAAM,aAAaG,EAAO,2BAA2B,GAAGH,EAAM,SAAS;AAG7H,SAAAI,gBAAAA,EAAA,cAAC,SAAI,WAAWH,GAAqB,eAAaD,EAAM,OAAA,GACrDA,EAAM,aACJI,gBAAAA,EAAA,cAAA,KAAA,EAAE,WAAWD,EAAO,uBAAuB,GAAG,IAAIH,EAAM,eACtDA,EAAM,SACT,GAEDA,EAAM,QACT;AAEJ,GAEAK,IAAeN;"}
|
|
@@ -30,6 +30,8 @@ export interface ExpanderProps {
|
|
|
30
30
|
renderChildrenWhenClosed?: boolean;
|
|
31
31
|
/** Sets the data-testid attribute on the expander button. */
|
|
32
32
|
testId?: string;
|
|
33
|
+
/** Overrides the default z-index of the expander header */
|
|
34
|
+
zIndex?: number;
|
|
33
35
|
}
|
|
34
36
|
declare const Expander: React.FC<ExpanderProps>;
|
|
35
37
|
export default Expander;
|