@helsenorge/designsystem-react 8.6.0-beta.1 → 9.0.0-beta.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/Button.js +7 -7
- package/Button.js.map +1 -1
- package/CHANGELOG.md +1 -1
- package/Checkbox.js +42 -42
- package/Checkbox.js.map +1 -1
- package/ErrorWrapper.js.map +1 -1
- package/FormGroup.js +30 -30
- package/FormGroup.js.map +1 -1
- package/Icon.js +21 -21
- package/Icon.js.map +1 -1
- package/Input.js +98 -88
- package/Input.js.map +1 -1
- package/Label.js +9 -9
- package/Label.js.map +1 -1
- package/MaxCharacters.js +2 -2
- package/MaxCharacters.js.map +1 -1
- package/RadioButton.js +61 -61
- package/RadioButton.js.map +1 -1
- package/Select.js +34 -33
- package/Select.js.map +1 -1
- package/StatusDot.js +15 -15
- package/StatusDot.js.map +1 -1
- package/TabList.js +88 -53
- package/TabList.js.map +1 -1
- package/TabPanel.js +7 -7
- package/TabPanel.js.map +1 -1
- package/Textarea.js +59 -58
- package/Textarea.js.map +1 -1
- package/Trigger.js +33 -33
- package/Trigger.js.map +1 -1
- package/components/Button/Button.d.ts +2 -2
- package/components/Checkbox/Checkbox.d.ts +4 -3
- package/components/Checkbox/styles.module.scss +0 -14
- package/components/Checkbox/styles.module.scss.d.ts +0 -1
- package/components/Dropdown/Dropdown.d.ts +2 -2
- package/components/Dropdown/index.js +25 -25
- package/components/Dropdown/index.js.map +1 -1
- package/components/ErrorWrapper/ErrorWrapper.d.ts +3 -0
- package/components/ExpanderList/ExpanderList.d.ts +4 -6
- package/components/ExpanderList/index.js +118 -126
- package/components/ExpanderList/index.js.map +1 -1
- package/components/ExpanderList/styles.module.scss +164 -53
- package/components/ExpanderList/styles.module.scss.d.ts +29 -5
- package/components/FormGroup/FormGroup.d.ts +2 -2
- package/components/Icon/Icon.d.ts +4 -4
- package/components/Icons/NoAccess.js +7 -7
- package/components/Icons/NoAccess.js.map +1 -1
- package/components/Input/Input.d.ts +4 -3
- package/components/Label/Label.d.ts +4 -4
- package/components/Label/SubLabel.d.ts +2 -2
- package/components/MaxCharacters/MaxCharacters.d.ts +2 -2
- package/components/RadioButton/RadioButton.d.ts +5 -4
- package/components/RadioButton/styles.module.scss +0 -15
- package/components/RadioButton/styles.module.scss.d.ts +0 -1
- package/components/Select/Select.d.ts +4 -3
- package/components/SharingStatus/SharingStatus.d.ts +1 -1
- package/components/SharingStatus/index.js +5 -5
- package/components/SharingStatus/index.js.map +1 -1
- package/components/SharingStatus/styles.module.scss +0 -16
- package/components/SharingStatus/styles.module.scss.d.ts +0 -4
- package/components/StatusDot/StatusDot.d.ts +3 -3
- package/components/StatusDot/index.js +3 -3
- package/components/Tabs/TabList/TabList.d.ts +3 -3
- package/components/Tabs/TabList/styles.module.scss +63 -51
- package/components/Tabs/TabList/styles.module.scss.d.ts +7 -3
- package/components/Tabs/TabPanel/TabPanel.d.ts +1 -2
- package/components/Tabs/TabPanel/styles.module.scss +11 -26
- package/components/Tabs/TabPanel/styles.module.scss.d.ts +0 -2
- package/components/Tabs/Tabs.d.ts +3 -3
- package/components/Tabs/index.js +57 -72
- package/components/Tabs/index.js.map +1 -1
- package/components/Tabs/styles.module.scss +5 -9
- package/components/Tabs/styles.module.scss.d.ts +0 -1
- package/components/Textarea/Textarea.d.ts +4 -3
- package/components/Toggle/index.js +1222 -1180
- package/components/Toggle/index.js.map +1 -1
- package/components/Trigger/Trigger.d.ts +2 -2
- package/components/Validation/index.js +38 -32
- package/components/Validation/index.js.map +1 -1
- package/constants.d.ts +1 -1
- package/constants.js +1 -1
- package/constants.js.map +1 -1
- package/docs/FormExample/FormExample.d.ts +2 -1
- package/index.js +23 -23
- package/package.json +4 -4
- package/utils/component.d.ts +1 -0
- package/utils/component.js +7 -3
- package/utils/component.js.map +1 -1
package/RadioButton.js
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
1
|
+
import { jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import U, { useState as q } from "react";
|
|
3
3
|
import u from "classnames";
|
|
4
|
-
import {
|
|
5
|
-
import { usePseudoClasses as
|
|
6
|
-
import { useUuid as
|
|
7
|
-
import { getAriaDescribedBy as
|
|
8
|
-
import { isMutableRefObject as
|
|
9
|
-
import { u as
|
|
10
|
-
import { E as
|
|
11
|
-
import { g as
|
|
4
|
+
import { FormOnColor as d, FormSize as M, AnalyticsId as G } from "./constants.js";
|
|
5
|
+
import { usePseudoClasses as H } from "./hooks/usePseudoClasses.js";
|
|
6
|
+
import { useUuid as J } from "./hooks/useUuid.js";
|
|
7
|
+
import { getAriaDescribedBy as K } from "./utils/accessibility.js";
|
|
8
|
+
import { isMutableRefObject as Q, mergeRefs as V } from "./utils/refs.js";
|
|
9
|
+
import { u as X } from "./uuid.js";
|
|
10
|
+
import { E as Y } from "./ErrorWrapper.js";
|
|
11
|
+
import { g as Z, r as $ } from "./Label.js";
|
|
12
12
|
import e from "./components/RadioButton/styles.module.scss";
|
|
13
|
-
const
|
|
14
|
-
const n =
|
|
13
|
+
const me = (l, o, t, c) => {
|
|
14
|
+
const n = o === "oninvalid", a = l === c;
|
|
15
15
|
return u({
|
|
16
|
-
[e["radio-button-label__large--on-grey"]]: t &&
|
|
17
|
-
[e["radio-button-label__large--on-blueberry"]]:
|
|
18
|
-
[e["radio-button-label__large--selected"]]: t &&
|
|
19
|
-
[e["radio-button-label__large--selected-invalid"]]: t &&
|
|
16
|
+
[e["radio-button-label__large--on-grey"]]: t && o === "ongrey" && !a,
|
|
17
|
+
[e["radio-button-label__large--on-blueberry"]]: o === "onblueberry" && !a && t,
|
|
18
|
+
[e["radio-button-label__large--selected"]]: t && a && !n,
|
|
19
|
+
[e["radio-button-label__large--selected-invalid"]]: t && a && n
|
|
20
20
|
});
|
|
21
|
-
},
|
|
21
|
+
}, ee = U.forwardRef((l, o) => {
|
|
22
22
|
const {
|
|
23
23
|
className: t,
|
|
24
24
|
defaultChecked: c,
|
|
25
25
|
onChange: n,
|
|
26
|
-
disabled:
|
|
27
|
-
label:
|
|
28
|
-
inputId:
|
|
29
|
-
|
|
30
|
-
name: v =
|
|
31
|
-
size:
|
|
32
|
-
errorText:
|
|
33
|
-
error:
|
|
34
|
-
errorTextId:
|
|
35
|
-
|
|
26
|
+
disabled: a,
|
|
27
|
+
label: _,
|
|
28
|
+
inputId: m = X(),
|
|
29
|
+
onColor: i = d.onwhite,
|
|
30
|
+
name: v = m,
|
|
31
|
+
size: R,
|
|
32
|
+
errorText: f,
|
|
33
|
+
error: k = !!f,
|
|
34
|
+
errorTextId: w,
|
|
35
|
+
errorWrapperClassName: B,
|
|
36
|
+
value: N = Z(_),
|
|
36
37
|
testId: x,
|
|
37
38
|
required: L,
|
|
38
|
-
labelClassNames:
|
|
39
|
-
...
|
|
40
|
-
} = l,
|
|
41
|
-
[e["radio-button-wrapper--with-error"]]: m,
|
|
39
|
+
labelClassNames: I,
|
|
40
|
+
...T
|
|
41
|
+
} = l, p = k || i === d.oninvalid, y = i === d.ondark, h = i === d.onblueberry, j = i === d.oninvalid, r = R === M.large, [A, F] = q(), { refObject: O, isFocused: s } = H(Q(o) ? o : null), S = V([o, O]), C = J(w), W = u(e["radio-button-wrapper"], {
|
|
42
42
|
[e["radio-button-wrapper__large"]]: r,
|
|
43
43
|
[e["radio-button-wrapper__large--focused"]]: r && s,
|
|
44
|
-
[e["radio-button-wrapper__large--selected"]]: r &&
|
|
45
|
-
[e["radio-button-wrapper__large--invalid"]]: r &&
|
|
44
|
+
[e["radio-button-wrapper__large--selected"]]: r && A && s,
|
|
45
|
+
[e["radio-button-wrapper__large--invalid"]]: r && j && s,
|
|
46
46
|
[e["radio-button-wrapper__large--on-blueberry"]]: r && h && s
|
|
47
|
-
}),
|
|
47
|
+
}), z = u(
|
|
48
48
|
e["radio-button-label"],
|
|
49
49
|
{
|
|
50
|
-
[e["radio-button-label--disabled"]]:
|
|
50
|
+
[e["radio-button-label--disabled"]]: a,
|
|
51
51
|
[e["radio-button-label--on-dark"]]: y,
|
|
52
|
-
[e["radio-button-label--invalid"]]:
|
|
52
|
+
[e["radio-button-label--invalid"]]: p,
|
|
53
53
|
[e["radio-button-label__large"]]: r,
|
|
54
|
-
[e["radio-button-label__large--disabled"]]: r &&
|
|
54
|
+
[e["radio-button-label__large--disabled"]]: r && a
|
|
55
55
|
},
|
|
56
|
-
|
|
57
|
-
),
|
|
56
|
+
I
|
|
57
|
+
), D = u(
|
|
58
58
|
e["radio-button"],
|
|
59
59
|
{
|
|
60
60
|
[e["radio-button--on-dark"]]: y,
|
|
61
|
-
[e["radio-button--disabled"]]:
|
|
61
|
+
[e["radio-button--disabled"]]: a,
|
|
62
62
|
[e["radio-button--on-blueberry"]]: h,
|
|
63
|
-
[e["radio-button--invalid"]]:
|
|
63
|
+
[e["radio-button--invalid"]]: p,
|
|
64
64
|
[e["radio-button__large"]]: r,
|
|
65
|
-
[e["radio-button__large--disabled"]]: r &&
|
|
66
|
-
[e["radio-button__large--invalid"]]: r &&
|
|
65
|
+
[e["radio-button__large--disabled"]]: r && a,
|
|
66
|
+
[e["radio-button__large--invalid"]]: r && p
|
|
67
67
|
},
|
|
68
68
|
t
|
|
69
|
-
),
|
|
70
|
-
|
|
71
|
-
},
|
|
69
|
+
), E = (b) => {
|
|
70
|
+
F(b.target.checked), n && n(b);
|
|
71
|
+
}, P = () => /* @__PURE__ */ g(
|
|
72
72
|
"input",
|
|
73
73
|
{
|
|
74
|
-
id:
|
|
74
|
+
id: m,
|
|
75
75
|
name: v,
|
|
76
|
-
className:
|
|
76
|
+
className: D,
|
|
77
77
|
type: "radio",
|
|
78
|
-
disabled:
|
|
79
|
-
value:
|
|
78
|
+
disabled: a,
|
|
79
|
+
value: N,
|
|
80
80
|
ref: S,
|
|
81
81
|
defaultChecked: c,
|
|
82
|
-
"aria-describedby":
|
|
82
|
+
"aria-describedby": K(l, C),
|
|
83
83
|
required: L,
|
|
84
|
-
...
|
|
85
|
-
onChange: (b) =>
|
|
84
|
+
...T,
|
|
85
|
+
onChange: (b) => E(b)
|
|
86
86
|
}
|
|
87
87
|
);
|
|
88
|
-
return /* @__PURE__ */
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
return /* @__PURE__ */ g(Y, { className: B, errorText: f, errorTextId: C, children: /* @__PURE__ */ g("div", { "data-testid": x, "data-analyticsid": G.RadioButton, className: W, children: $(
|
|
89
|
+
_,
|
|
90
|
+
P(),
|
|
91
|
+
m,
|
|
92
92
|
i,
|
|
93
|
-
|
|
93
|
+
z,
|
|
94
94
|
void 0,
|
|
95
95
|
e["radiobutton-sublabel-wrapper"],
|
|
96
96
|
r
|
|
97
97
|
) }) });
|
|
98
98
|
});
|
|
99
|
-
|
|
99
|
+
ee.displayName = "RadioButton";
|
|
100
100
|
export {
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
ee as R,
|
|
102
|
+
me as g
|
|
103
103
|
};
|
|
104
104
|
//# sourceMappingURL=RadioButton.js.map
|
package/RadioButton.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioButton.js","sources":["../src/components/RadioButton/RadioButton.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormMode, FormSize } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { getLabelText, renderLabelAsParent } from '../Label';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport interface RadioButtonProps\n extends Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | '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. Large version only works when used inside a FormGroup wrapper. */\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,\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>();\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n const errorTextUuid = useUuid(errorTextId);\n\n const radioButtonWrapperClasses = classNames(radioButtonStyles['radio-button-wrapper'], {\n [radioButtonStyles['radio-button-wrapper--with-error']]: errorText,\n [radioButtonStyles['radio-button-wrapper__large']]: isLarge,\n [radioButtonStyles['radio-button-wrapper__large--focused']]: isLarge && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--selected']]: isLarge && checked && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--invalid']]: isLarge && onCherry && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--on-blueberry']]: isLarge && onBlueberry && isFocused,\n });\n const radioButtonLabelClasses = classNames(\n radioButtonStyles['radio-button-label'],\n {\n [radioButtonStyles['radio-button-label--disabled']]: disabled,\n [radioButtonStyles['radio-button-label--on-dark']]: onDark,\n [radioButtonStyles['radio-button-label--invalid']]: invalid,\n [radioButtonStyles['radio-button-label__large']]: isLarge,\n [radioButtonStyles['radio-button-label__large--disabled']]: isLarge && disabled,\n },\n labelClassNames\n );\n const radioButtonClasses = classNames(\n radioButtonStyles['radio-button'],\n {\n [radioButtonStyles['radio-button--on-dark']]: onDark,\n [radioButtonStyles['radio-button--disabled']]: disabled,\n [radioButtonStyles['radio-button--on-blueberry']]: onBlueberry,\n [radioButtonStyles['radio-button--invalid']]: invalid,\n [radioButtonStyles['radio-button__large']]: isLarge,\n [radioButtonStyles['radio-button__large--disabled']]: isLarge && disabled,\n [radioButtonStyles['radio-button__large--invalid']]: isLarge && invalid,\n },\n className\n );\n\n const change = (e: React.ChangeEvent<HTMLInputElement>): void => {\n changeChecked(e.target.checked);\n onChange && onChange(e);\n };\n\n const getLabelContent = (): React.ReactNode => (\n <input\n id={inputId}\n name={name}\n className={radioButtonClasses}\n type=\"radio\"\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n defaultChecked={defaultChecked}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n required={required}\n {...rest}\n onChange={(e): void => change(e)}\n />\n );\n\n return (\n <ErrorWrapper errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.RadioButton} className={radioButtonWrapperClasses}>\n {renderLabelAsParent(\n label,\n getLabelContent(),\n inputId,\n mode as FormMode,\n radioButtonLabelClasses,\n undefined,\n radioButtonStyles['radiobutton-sublabel-wrapper'],\n isLarge\n )}\n </div>\n </ErrorWrapper>\n );\n});\n\nRadioButton.displayName = 'RadioButton';\n\nexport default RadioButton;\n"],"names":["getRadioLabelClasses","radioId","mode","large","checkedRadioId","onCherry","checked","classNames","radioButtonStyles","RadioButton","React","props","ref","className","defaultChecked","onChange","disabled","label","inputId","uuid","FormMode","name","size","errorText","error","errorTextId","value","getLabelText","testId","required","labelClassNames","rest","invalid","onDark","onBlueberry","isLarge","FormSize","changeChecked","useState","refObject","isFocused","usePseudoClasses","isMutableRefObject","mergedRefs","mergeRefs","errorTextUuid","useUuid","radioButtonWrapperClasses","radioButtonLabelClasses","radioButtonClasses","change","e","getLabelContent","jsx","getAriaDescribedBy","ErrorWrapper","AnalyticsId","renderLabelAsParent"],"mappings":";;;;;;;;;;;;AA0CO,MAAMA,KAAuB,CAACC,GAAiBC,GAAgBC,GAAgBC,MAAgD;AACpI,QAAMC,IAAWH,MAAS,aACpBI,IAAUL,MAAYG;AAE5B,SAAOG,EAAW;AAAA,IAChB,CAACC,EAAkB,oCAAoC,CAAC,GAAGL,KAASD,MAAS,YAAY,CAACI;AAAA,IAC1F,CAACE,EAAkB,yCAAyC,CAAC,GAAGN,MAAS,iBAAiB,CAACI,KAAWH;AAAA,IACtG,CAACK,EAAkB,qCAAqC,CAAC,GAAGL,KAASG,KAAW,CAACD;AAAA,IACjF,CAACG,EAAkB,6CAA6C,CAAC,GAAGL,KAASG,KAAWD;AAAA,EAAA,CACzF;AACH,GAEaI,IAAcC,EAAM,WAAW,CAACC,GAAyBC,MAAqC;AACnG,QAAA;AAAA,IACJ,WAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC,IAAUC,EAAK;AAAA,IACf,MAAA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,GAC7E,UAAAU;AAAA,IACCxC;AAAA,IACAmC,EAAgB;AAAA,IAChBlC;AAAA,IACAhB;AAAA,IACA8C;AAAA,IACA;AAAA,IACAxC,EAAkB,8BAA8B;AAAA,IAChD2B;AAAA,EAAA,EAEJ,CAAA,EACF,CAAA;AAEJ,CAAC;AAED1B,EAAY,cAAc;"}
|
|
1
|
+
{"version":3,"file":"RadioButton.js","sources":["../src/components/RadioButton/RadioButton.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper, { ErrorWrapperClassNameProps } from '../ErrorWrapper';\nimport { getLabelText, renderLabelAsParent } from '../Label';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport interface RadioButtonProps\n extends ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | '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 onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the radioButton. Large version only works when used inside a FormGroup wrapper. */\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 = (\n radioId: string,\n onColor: FormOnColor,\n large: boolean,\n checkedRadioId?: string\n): string | undefined => {\n const onCherry = onColor === 'oninvalid';\n const checked = radioId === checkedRadioId;\n\n return classNames({\n [radioButtonStyles['radio-button-label__large--on-grey']]: large && onColor === 'ongrey' && !checked,\n [radioButtonStyles['radio-button-label__large--on-blueberry']]: onColor === '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,\n onChange,\n disabled,\n label,\n inputId = uuid(),\n onColor = FormOnColor.onwhite,\n name = inputId,\n size,\n errorText,\n error = !!errorText,\n errorTextId,\n errorWrapperClassName,\n value = getLabelText(label),\n testId,\n required,\n labelClassNames,\n ...rest\n } = props;\n const invalid = error || onColor === FormOnColor.oninvalid;\n const onDark = onColor === FormOnColor.ondark;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const onCherry = onColor === FormOnColor.oninvalid;\n const isLarge = size === FormSize.large;\n const [checked, changeChecked] = useState<boolean>();\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__large']]: isLarge,\n [radioButtonStyles['radio-button-wrapper__large--focused']]: isLarge && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--selected']]: isLarge && checked && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--invalid']]: isLarge && onCherry && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--on-blueberry']]: isLarge && onBlueberry && isFocused,\n });\n const radioButtonLabelClasses = classNames(\n radioButtonStyles['radio-button-label'],\n {\n [radioButtonStyles['radio-button-label--disabled']]: disabled,\n [radioButtonStyles['radio-button-label--on-dark']]: onDark,\n [radioButtonStyles['radio-button-label--invalid']]: invalid,\n [radioButtonStyles['radio-button-label__large']]: isLarge,\n [radioButtonStyles['radio-button-label__large--disabled']]: isLarge && disabled,\n },\n labelClassNames\n );\n const radioButtonClasses = classNames(\n radioButtonStyles['radio-button'],\n {\n [radioButtonStyles['radio-button--on-dark']]: onDark,\n [radioButtonStyles['radio-button--disabled']]: disabled,\n [radioButtonStyles['radio-button--on-blueberry']]: onBlueberry,\n [radioButtonStyles['radio-button--invalid']]: invalid,\n [radioButtonStyles['radio-button__large']]: isLarge,\n [radioButtonStyles['radio-button__large--disabled']]: isLarge && disabled,\n [radioButtonStyles['radio-button__large--invalid']]: isLarge && invalid,\n },\n className\n );\n\n const change = (e: React.ChangeEvent<HTMLInputElement>): void => {\n changeChecked(e.target.checked);\n onChange && onChange(e);\n };\n\n const getLabelContent = (): React.ReactNode => (\n <input\n id={inputId}\n name={name}\n className={radioButtonClasses}\n type=\"radio\"\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n defaultChecked={defaultChecked}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n required={required}\n {...rest}\n onChange={(e): void => change(e)}\n />\n );\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.RadioButton} className={radioButtonWrapperClasses}>\n {renderLabelAsParent(\n label,\n getLabelContent(),\n inputId,\n onColor as FormOnColor,\n radioButtonLabelClasses,\n undefined,\n radioButtonStyles['radiobutton-sublabel-wrapper'],\n isLarge\n )}\n </div>\n </ErrorWrapper>\n );\n});\n\nRadioButton.displayName = 'RadioButton';\n\nexport default RadioButton;\n"],"names":["getRadioLabelClasses","radioId","onColor","large","checkedRadioId","onCherry","checked","classNames","radioButtonStyles","RadioButton","React","props","ref","className","defaultChecked","onChange","disabled","label","inputId","uuid","FormOnColor","name","size","errorText","error","errorTextId","errorWrapperClassName","value","getLabelText","testId","required","labelClassNames","rest","invalid","onDark","onBlueberry","isLarge","FormSize","changeChecked","useState","refObject","isFocused","usePseudoClasses","isMutableRefObject","mergedRefs","mergeRefs","errorTextUuid","useUuid","radioButtonWrapperClasses","radioButtonLabelClasses","radioButtonClasses","change","e","getLabelContent","jsx","getAriaDescribedBy","ErrorWrapper","AnalyticsId","renderLabelAsParent"],"mappings":";;;;;;;;;;;;AA2CO,MAAMA,KAAuB,CAClCC,GACAC,GACAC,GACAC,MACuB;AACvB,QAAMC,IAAWH,MAAY,aACvBI,IAAUL,MAAYG;AAE5B,SAAOG,EAAW;AAAA,IAChB,CAACC,EAAkB,oCAAoC,CAAC,GAAGL,KAASD,MAAY,YAAY,CAACI;AAAA,IAC7F,CAACE,EAAkB,yCAAyC,CAAC,GAAGN,MAAY,iBAAiB,CAACI,KAAWH;AAAA,IACzG,CAACK,EAAkB,qCAAqC,CAAC,GAAGL,KAASG,KAAW,CAACD;AAAA,IACjF,CAACG,EAAkB,6CAA6C,CAAC,GAAGL,KAASG,KAAWD;AAAA,EAAA,CACzF;AACH,GAEaI,KAAcC,EAAM,WAAW,CAACC,GAAyBC,MAAqC;AACnG,QAAA;AAAA,IACJ,WAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC,IAAUC,EAAK;AAAA,IACf,SAAAjB,IAAUkB,EAAY;AAAA,IACtB,MAAAC,IAAOH;AAAA,IACP,MAAAI;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC,IAAQ,CAAC,CAACD;AAAA,IACV,aAAAE;AAAA,IACA,uBAAAC;AAAA,IACA,OAAAC,IAAQC,EAAaX,CAAK;AAAA,IAC1B,QAAAY;AAAA,IACA,UAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,GAAGC;AAAA,EACD,IAAArB,GACEsB,IAAUT,KAAStB,MAAYkB,EAAY,WAC3Cc,IAAShC,MAAYkB,EAAY,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,CAAC3B,EAAkB,uBAAuB,CAAC,GAAGyB;AAAA,MAC9C,CAACzB,EAAkB,qBAAqB,CAAC,GAAG4B;AAAA,MAC5C,CAAC5B,EAAkB,+BAA+B,CAAC,GAAG4B,KAAWpB;AAAA,MACjE,CAACR,EAAkB,8BAA8B,CAAC,GAAG4B,KAAWH;AAAA,IAClE;AAAA,IACApB;AAAA,EAAA,GAGIsC,IAAS,CAACC,MAAiD;AACjD,IAAAd,EAAAc,EAAE,OAAO,OAAO,GAC9BrC,KAAYA,EAASqC,CAAC;AAAA,EAAA,GAGlBC,IAAkB,MACtB,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAIpC;AAAA,MACJ,MAAAG;AAAA,MACA,WAAW6B;AAAA,MACX,MAAK;AAAA,MACL,UAAAlC;AAAA,MACA,OAAAW;AAAA,MACA,KAAKiB;AAAA,MACL,gBAAA9B;AAAA,MACA,oBAAkByC,EAAmB5C,GAAOmC,CAAa;AAAA,MACzD,UAAAhB;AAAA,MACC,GAAGE;AAAA,MACJ,UAAU,CAACoB,MAAYD,EAAOC,CAAC;AAAA,IAAA;AAAA,EAAA;AAInC,SACG,gBAAAE,EAAAE,GAAA,EAAa,WAAW9B,GAAuB,WAAAH,GAAsB,aAAauB,GACjF,UAAC,gBAAAQ,EAAA,OAAA,EAAI,eAAazB,GAAQ,oBAAkB4B,EAAY,aAAa,WAAWT,GAC7E,UAAAU;AAAA,IACCzC;AAAA,IACAoC,EAAgB;AAAA,IAChBnC;AAAA,IACAhB;AAAA,IACA+C;AAAA,IACA;AAAA,IACAzC,EAAkB,8BAA8B;AAAA,IAChD4B;AAAA,EAAA,EAEJ,CAAA,EACF,CAAA;AAEJ,CAAC;AAED3B,GAAY,cAAc;"}
|
package/Select.js
CHANGED
|
@@ -1,69 +1,70 @@
|
|
|
1
1
|
import { jsx as l, jsxs as w } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import H from "react";
|
|
3
3
|
import n from "classnames";
|
|
4
|
-
import {
|
|
4
|
+
import { FormOnColor as U, AnalyticsId as V, IconSize as X, AVERAGE_CHARACTER_WIDTH_PX as $ } from "./constants.js";
|
|
5
5
|
import { useUuid as h } from "./hooks/useUuid.js";
|
|
6
6
|
import { getColor as v } from "./theme/currys/color.js";
|
|
7
|
-
import { getAriaDescribedBy as
|
|
8
|
-
import { E as
|
|
9
|
-
import { I as
|
|
10
|
-
import
|
|
7
|
+
import { getAriaDescribedBy as G } from "./utils/accessibility.js";
|
|
8
|
+
import { E as L } from "./ErrorWrapper.js";
|
|
9
|
+
import { I as M } from "./Icon.js";
|
|
10
|
+
import O from "./components/Icons/ChevronDown.js";
|
|
11
11
|
import { a as P } from "./Label.js";
|
|
12
12
|
import e from "./components/Select/styles.module.scss";
|
|
13
|
-
const k = (
|
|
13
|
+
const k = (o) => `calc(${o * $}px + 2rem)`, J = (o, r) => r ? v("neutral", 500) : v(o ? "cherry" : "blueberry", 600), ie = H.forwardRef(function(r, i) {
|
|
14
14
|
const {
|
|
15
15
|
className: y,
|
|
16
16
|
children: I,
|
|
17
17
|
concept: x = "normal",
|
|
18
18
|
disabled: a,
|
|
19
|
-
error:
|
|
19
|
+
error: N,
|
|
20
20
|
errorText: c,
|
|
21
21
|
errorTextId: W,
|
|
22
|
+
errorWrapperClassName: S,
|
|
22
23
|
label: g,
|
|
23
24
|
selectId: d,
|
|
24
|
-
name:
|
|
25
|
-
|
|
26
|
-
testId:
|
|
25
|
+
name: A = d,
|
|
26
|
+
onColor: s = U.onwhite,
|
|
27
|
+
testId: R,
|
|
27
28
|
width: m,
|
|
28
29
|
required: p,
|
|
29
|
-
value:
|
|
30
|
-
defaultValue:
|
|
30
|
+
value: T,
|
|
31
|
+
defaultValue: E,
|
|
31
32
|
autoComplete: u = "off",
|
|
32
|
-
wrapperClassName:
|
|
33
|
-
...
|
|
34
|
-
} = r, f = h(d),
|
|
33
|
+
wrapperClassName: D,
|
|
34
|
+
..._
|
|
35
|
+
} = r, f = h(d), C = h(W), b = s === "onblueberry", t = s === "oninvalid" || !!c || !!N, j = J(t, !!a), q = m ? k(m) : void 0, z = n(
|
|
35
36
|
e["select-inner-wrapper"],
|
|
36
37
|
{
|
|
37
38
|
[e["select-inner-wrapper--transparent"]]: x === "transparent",
|
|
38
|
-
[e["select-inner-wrapper--on-blueberry"]]:
|
|
39
|
-
[e["select-inner-wrapper--invalid"]]:
|
|
39
|
+
[e["select-inner-wrapper--on-blueberry"]]: b,
|
|
40
|
+
[e["select-inner-wrapper--invalid"]]: t,
|
|
40
41
|
[e["select-inner-wrapper--disabled"]]: a
|
|
41
42
|
},
|
|
42
43
|
y
|
|
43
|
-
),
|
|
44
|
-
[e["select--on-blueberry"]]:
|
|
45
|
-
[e["select--invalid"]]:
|
|
46
|
-
}),
|
|
47
|
-
return /* @__PURE__ */ l(
|
|
44
|
+
), B = n(e.select, {
|
|
45
|
+
[e["select--on-blueberry"]]: b,
|
|
46
|
+
[e["select--invalid"]]: t
|
|
47
|
+
}), F = n(e["select-wrapper"], D);
|
|
48
|
+
return /* @__PURE__ */ l(L, { className: S, errorText: c, errorTextId: C, children: /* @__PURE__ */ w("div", { "data-testid": R, "data-analyticsid": V.Select, className: F, style: { maxWidth: q }, children: [
|
|
48
49
|
P(g, f, s),
|
|
49
|
-
/* @__PURE__ */ w("div", { className:
|
|
50
|
-
/* @__PURE__ */ l(
|
|
50
|
+
/* @__PURE__ */ w("div", { className: z, children: [
|
|
51
|
+
/* @__PURE__ */ l(M, { className: e["select-arrow"], svgIcon: O, color: j, size: X.XSmall }),
|
|
51
52
|
/* @__PURE__ */ l(
|
|
52
53
|
"select",
|
|
53
54
|
{
|
|
54
|
-
"aria-invalid": !!
|
|
55
|
+
"aria-invalid": !!t,
|
|
55
56
|
id: f,
|
|
56
|
-
name:
|
|
57
|
-
className:
|
|
57
|
+
name: A,
|
|
58
|
+
className: B,
|
|
58
59
|
disabled: a,
|
|
59
60
|
ref: i,
|
|
60
61
|
required: p,
|
|
61
|
-
"aria-describedby":
|
|
62
|
+
"aria-describedby": G(r, C),
|
|
62
63
|
"aria-required": !!p,
|
|
63
|
-
value:
|
|
64
|
-
defaultValue:
|
|
64
|
+
value: T,
|
|
65
|
+
defaultValue: E,
|
|
65
66
|
autoComplete: u || void 0,
|
|
66
|
-
...
|
|
67
|
+
..._,
|
|
67
68
|
children: I
|
|
68
69
|
}
|
|
69
70
|
)
|
|
@@ -71,6 +72,6 @@ const k = (t) => `calc(${t * V}px + 2rem)`, J = (t, r) => r ? v("neutral", 500)
|
|
|
71
72
|
] }) });
|
|
72
73
|
});
|
|
73
74
|
export {
|
|
74
|
-
|
|
75
|
+
ie as S
|
|
75
76
|
};
|
|
76
77
|
//# sourceMappingURL=Select.js.map
|
package/Select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../src/components/Select/Select.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX,
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../src/components/Select/Select.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX, FormOnColor, IconSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport ErrorWrapper, { ErrorWrapperClassNameProps } from '../ErrorWrapper';\nimport Icon from '../Icon';\nimport ChevronDown from '../Icons/ChevronDown';\nimport { renderLabel } from '../Label';\n\nimport selectStyles from './styles.module.scss';\n\ntype SelectConcept = 'normal' | 'transparent';\n\nexport interface SelectProps\n extends ErrorWrapperClassNameProps,\n Pick<\n React.SelectHTMLAttributes<HTMLSelectElement>,\n 'aria-describedby' | 'name' | 'disabled' | 'required' | 'value' | 'onChange' | 'autoComplete'\n > {\n /** Sets the content of the select element. */\n children: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the visuals of the component */\n concept?: SelectConcept;\n /** The label text above the select */\n label?: React.ReactNode;\n /** Changes the visuals of the component */\n onColor?: keyof typeof FormOnColor;\n /** Activates Error style for the select component - 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 /** select id of the select element */\n selectId?: string;\n /** Width of select in characters (approximate) */\n width?: number;\n /** Gives defaultvalue to the comp. Preferred over selected prop on option by react */\n defaultValue?: string | number;\n /** Adds custom classes to the wrapper tag */\n wrapperClassName?: string;\n}\n\nconst getSelectMaxWidth = (characters: number): string => {\n const paddingWidth = '2rem';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth})`;\n};\n\nconst getIconColor = (invalid: boolean, disabled: boolean) => {\n const iconColor = invalid ? 'cherry' : 'blueberry';\n return disabled ? getColor('neutral', 500) : getColor(iconColor, 600);\n};\n\nexport const Select = React.forwardRef(function SelectForwardedRef(props: SelectProps, ref: React.Ref<HTMLSelectElement>) {\n const {\n className,\n children,\n concept = 'normal',\n disabled,\n error,\n errorText,\n errorTextId,\n errorWrapperClassName,\n label,\n selectId,\n name = selectId,\n onColor = FormOnColor.onwhite,\n testId,\n width,\n required,\n value,\n defaultValue,\n autoComplete = 'off',\n wrapperClassName,\n ...rest\n } = props;\n\n const uuid = useUuid(selectId);\n const errorTextUuid = useUuid(errorTextId);\n const onBlueberry = onColor === 'onblueberry';\n const invalid = onColor === 'oninvalid' || !!errorText || !!error;\n const iconColor = getIconColor(invalid, !!disabled);\n const maxWidth = width ? getSelectMaxWidth(width) : undefined;\n\n const selectInnerWrapperClasses = classNames(\n selectStyles['select-inner-wrapper'],\n {\n [selectStyles['select-inner-wrapper--transparent']]: concept === 'transparent',\n [selectStyles['select-inner-wrapper--on-blueberry']]: onBlueberry,\n [selectStyles['select-inner-wrapper--invalid']]: invalid,\n [selectStyles['select-inner-wrapper--disabled']]: disabled,\n },\n className\n );\n\n const selectClasses = classNames(selectStyles.select, {\n [selectStyles['select--on-blueberry']]: onBlueberry,\n [selectStyles['select--invalid']]: invalid,\n });\n\n const selectWrapperClasses = classNames(selectStyles['select-wrapper'], wrapperClassName);\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Select} className={selectWrapperClasses} style={{ maxWidth }}>\n {renderLabel(label, uuid, onColor as FormOnColor)}\n <div className={selectInnerWrapperClasses}>\n <Icon className={selectStyles['select-arrow']} svgIcon={ChevronDown} color={iconColor} size={IconSize.XSmall} />\n <select\n aria-invalid={!!invalid}\n id={uuid}\n name={name}\n className={selectClasses}\n disabled={disabled}\n ref={ref}\n required={required}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n aria-required={!!required}\n value={value}\n defaultValue={defaultValue}\n autoComplete={autoComplete ? autoComplete : undefined}\n {...rest}\n >\n {children}\n </select>\n </div>\n </div>\n </ErrorWrapper>\n );\n});\n\nexport default Select;\n"],"names":["getSelectMaxWidth","characters","AVERAGE_CHARACTER_WIDTH_PX","getIconColor","invalid","disabled","getColor","Select","React","props","ref","className","children","concept","error","errorText","errorTextId","errorWrapperClassName","label","selectId","name","onColor","FormOnColor","testId","width","required","value","defaultValue","autoComplete","wrapperClassName","rest","uuid","useUuid","errorTextUuid","onBlueberry","iconColor","maxWidth","selectInnerWrapperClasses","classNames","selectStyles","selectClasses","selectWrapperClasses","ErrorWrapper","jsxs","AnalyticsId","renderLabel","jsx","Icon","ChevronDown","IconSize","getAriaDescribedBy"],"mappings":";;;;;;;;;;;;AAmDA,MAAMA,IAAoB,CAACC,MAGlB,QAAQA,IAAaC,CAA0B,cAGlDC,IAAe,CAACC,GAAkBC,MAE/BA,IAAWC,EAAS,WAAW,GAAG,IAAIA,EAD3BF,IAAU,WAAW,aAC0B,GAAG,GAGzDG,KAAS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AuB,WAAAF,GAAsB,aAAakB,GACjF,UAAC,gBAAAU,EAAA,OAAA,EAAI,eAAapB,GAAQ,oBAAkBqB,EAAY,QAAQ,WAAWH,GAAsB,OAAO,EAAE,UAAAL,EACvG,GAAA,UAAA;AAAA,IAAYS,EAAA3B,GAAOa,GAAMV,CAAsB;AAAA,IAChD,gBAAAsB,EAAC,OAAI,EAAA,WAAWN,GACd,UAAA;AAAA,MAAC,gBAAAS,EAAAC,GAAA,EAAK,WAAWR,EAAa,cAAc,GAAG,SAASS,GAAa,OAAOb,GAAW,MAAMc,EAAS,OAAQ,CAAA;AAAA,MAC9G,gBAAAH;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,gBAAc,CAAC,CAAC1C;AAAA,UAChB,IAAI2B;AAAA,UACJ,MAAAX;AAAA,UACA,WAAWoB;AAAA,UACX,UAAAnC;AAAA,UACA,KAAAK;AAAA,UACA,UAAAe;AAAA,UACA,oBAAkByB,EAAmBzC,GAAOwB,CAAa;AAAA,UACzD,iBAAe,CAAC,CAACR;AAAA,UACjB,OAAAC;AAAA,UACA,cAAAC;AAAA,UACA,cAAcC,KAA8B;AAAA,UAC3C,GAAGE;AAAA,UAEH,UAAAlB;AAAA,QAAA;AAAA,MACH;AAAA,IAAA,GACF;AAAA,EAAA,EACF,CAAA,EACF,CAAA;AAEJ,CAAC;"}
|
package/StatusDot.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { jsxs as _, jsx as
|
|
1
|
+
import { jsxs as _, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import l from "classnames";
|
|
3
3
|
import "./theme/grid.js";
|
|
4
4
|
import "./hooks/useBreakpoint.js";
|
|
5
5
|
import "react";
|
|
6
|
-
import {
|
|
6
|
+
import { FormOnColor as i, AnalyticsId as w, IconSize as v } from "./constants.js";
|
|
7
7
|
import { getColor as m } from "./theme/currys/color.js";
|
|
8
8
|
import { I as a } from "./Icon.js";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
9
|
+
import N from "./components/Icons/Attachment.js";
|
|
10
|
+
import b from "./components/Icons/Change.js";
|
|
11
|
+
import x from "./components/Icons/Group.js";
|
|
12
|
+
import y from "./components/Icons/NoAccess.js";
|
|
13
13
|
import n from "./components/StatusDot/styles.module.scss";
|
|
14
|
-
var c = ((o) => (o[o.onwhite = i.onwhite] = "onwhite", o[o.ondark = i.ondark] = "ondark", o))(c || {}),
|
|
15
|
-
const A = ({
|
|
16
|
-
const r = { color: o === c.ondark ? m("white") : m("black"), size: v.XXSmall,
|
|
17
|
-
return
|
|
14
|
+
var c = ((o) => (o[o.onwhite = i.onwhite] = "onwhite", o[o.ondark = i.ondark] = "ondark", o))(c || {}), C = /* @__PURE__ */ ((o) => (o.info = "info", o.warning = "warning", o.alert = "alert", o.cancelled = "cancelled", o.active = "active", o.transparent = "transparent", o.recurring = "recurring", o.group = "group", o.noaccess = "noaccess", o.attachment = "attachment", o))(C || {});
|
|
15
|
+
const A = ({ onColor: o, variant: e }) => {
|
|
16
|
+
const r = { color: o === c.ondark ? m("white") : m("black"), size: v.XXSmall, onColor: o };
|
|
17
|
+
return e === "recurring" ? /* @__PURE__ */ s(a, { ...r, svgIcon: b }) : e === "group" ? /* @__PURE__ */ s(a, { ...r, svgIcon: x }) : e === "noaccess" ? /* @__PURE__ */ s(a, { ...r, svgIcon: y, color: m("cherry", 600) }) : e === "attachment" ? /* @__PURE__ */ s(a, { ...r, svgIcon: N }) : null;
|
|
18
18
|
}, L = (o) => {
|
|
19
|
-
const { id:
|
|
19
|
+
const { id: e, onColor: t = c.onwhite, variant: r = "info", text: d, className: p, testId: f } = o, u = r === "recurring" || r === "group" || r === "noaccess" || r === "attachment", g = r === "cancelled", h = l(n.statusdot, g && n["statusdot--cancelled"], p), I = l(n.statusdot__dot, {
|
|
20
20
|
...u ? {} : { [n[`statusdot__dot--${r}`]]: !0 },
|
|
21
21
|
[n["statusdot__dot--on-dark"]]: t === c.ondark
|
|
22
22
|
}), k = l(t === c.ondark && n["statusdot__label--on-dark"]);
|
|
23
|
-
return /* @__PURE__ */ _("span", { id:
|
|
24
|
-
/* @__PURE__ */
|
|
25
|
-
/* @__PURE__ */
|
|
23
|
+
return /* @__PURE__ */ _("span", { id: e, className: h, "data-testid": f, "data-analyticsid": w.StatusDot, children: [
|
|
24
|
+
/* @__PURE__ */ s("span", { className: I, children: /* @__PURE__ */ s(A, { onColor: t, variant: r }) }),
|
|
25
|
+
/* @__PURE__ */ s("span", { className: k, children: d })
|
|
26
26
|
] });
|
|
27
27
|
};
|
|
28
28
|
export {
|
|
29
29
|
L as S,
|
|
30
30
|
c as a,
|
|
31
|
-
|
|
31
|
+
C as b
|
|
32
32
|
};
|
|
33
33
|
//# sourceMappingURL=StatusDot.js.map
|
package/StatusDot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusDot.js","sources":["../src/components/StatusDot/StatusDot.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { IconSize } from '../..';\nimport { AnalyticsId,
|
|
1
|
+
{"version":3,"file":"StatusDot.js","sources":["../src/components/StatusDot/StatusDot.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { IconSize } from '../..';\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport { getColor } from '../../theme/currys';\nimport { Icon } from '../Icon';\nimport Attachment from '../Icons/Attachment';\nimport Change from '../Icons/Change';\nimport Group from '../Icons/Group';\nimport NoAccess from '../Icons/NoAccess';\n\nimport styles from './styles.module.scss';\n\nexport enum StatusDotOnColor {\n onwhite = FormOnColor.onwhite,\n ondark = FormOnColor.ondark,\n}\n\nexport enum StatusDotVariant {\n info = 'info',\n warning = 'warning',\n alert = 'alert',\n cancelled = 'cancelled',\n active = 'active',\n transparent = 'transparent',\n recurring = 'recurring',\n group = 'group',\n noaccess = 'noaccess',\n attachment = 'attachment',\n}\n\nexport interface StatusDotIconProps {\n /** Defines the color of the icon */\n onColor?: keyof typeof StatusDotOnColor;\n /** The variant defines style formatting and what icon to use */\n variant?: keyof typeof StatusDotVariant;\n}\n\nconst StatusDotIcon: React.FC<StatusDotIconProps> = ({ onColor, variant }) => {\n const color = onColor === StatusDotOnColor.ondark ? getColor('white') : getColor('black');\n const iconProps = { color, size: IconSize.XXSmall, onColor };\n\n if (variant === StatusDotVariant.recurring) {\n return <Icon {...iconProps} svgIcon={Change} />;\n } else if (variant === StatusDotVariant.group) {\n return <Icon {...iconProps} svgIcon={Group} />;\n } else if (variant === StatusDotVariant.noaccess) {\n return <Icon {...iconProps} svgIcon={NoAccess} color={getColor('cherry', 600)} />;\n } else if (variant === StatusDotVariant.attachment) {\n return <Icon {...iconProps} svgIcon={Attachment} />;\n }\n\n return null;\n};\n\nexport interface StatusDotProps {\n /** id that is placed on the wrapper */\n id?: string;\n /** Defines the color mode, onwhite, ondark etc. */\n onColor?: keyof typeof StatusDotOnColor;\n /** Visual variants for the statusdot */\n variant?: keyof typeof StatusDotVariant;\n /** Text placed to the right of the statusdot */\n text: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst StatusDot: React.FC<StatusDotProps> = props => {\n const { id, onColor = StatusDotOnColor.onwhite, variant = StatusDotVariant.info, text, className, testId } = props;\n\n const hasIcon =\n variant === StatusDotVariant.recurring ||\n variant === StatusDotVariant.group ||\n variant === StatusDotVariant.noaccess ||\n variant === StatusDotVariant.attachment;\n\n const isCancelled = variant === StatusDotVariant.cancelled;\n\n const statusDotClasses = classNames(styles['statusdot'], isCancelled && styles['statusdot--cancelled'], className);\n const dotClasses = classNames(styles['statusdot__dot'], {\n ...(hasIcon ? {} : { [styles[`statusdot__dot--${variant}`]]: true }),\n [styles['statusdot__dot--on-dark']]: onColor === StatusDotOnColor.ondark,\n });\n const labelClasses = classNames(onColor === StatusDotOnColor.ondark && styles['statusdot__label--on-dark']);\n\n return (\n <span id={id} className={statusDotClasses} data-testid={testId} data-analyticsid={AnalyticsId.StatusDot}>\n <span className={dotClasses}>\n <StatusDotIcon onColor={onColor} variant={variant} />\n </span>\n <span className={labelClasses}>{text}</span>\n </span>\n );\n};\n\nexport default StatusDot;\n"],"names":["StatusDotOnColor","FormOnColor","StatusDotVariant","StatusDotIcon","onColor","variant","iconProps","getColor","IconSize","jsx","Icon","Change","Group","NoAccess","Attachment","StatusDot","props","id","text","className","testId","hasIcon","isCancelled","statusDotClasses","classNames","styles","dotClasses","labelClasses","jsxs","AnalyticsId"],"mappings":";;;;;;;;;;;;;AAeY,IAAAA,KAAL,CAAKA,OACVA,EAAAA,EAAA,UAAUC,EAAY,OAAtB,IAAA,WACAD,EAAAA,EAAA,SAASC,EAAY,MAArB,IAAA,UAFUD,IAAAA,KAAA,CAAA,CAAA,GAKAE,sBAAAA,OACVA,EAAA,OAAO,QACPA,EAAA,UAAU,WACVA,EAAA,QAAQ,SACRA,EAAA,YAAY,aACZA,EAAA,SAAS,UACTA,EAAA,cAAc,eACdA,EAAA,YAAY,aACZA,EAAA,QAAQ,SACRA,EAAA,WAAW,YACXA,EAAA,aAAa,cAVHA,IAAAA,KAAA,CAAA,CAAA;AAoBZ,MAAMC,IAA8C,CAAC,EAAE,SAAAC,GAAS,SAAAC,QAAc;AAE5E,QAAMC,IAAY,EAAE,OADNF,MAAYJ,EAAiB,SAASO,EAAS,OAAO,IAAIA,EAAS,OAAO,GAC7D,MAAMC,EAAS,SAAS,SAAAJ;AAEnD,SAAIC,MAAY,cACN,gBAAAI,EAAAC,GAAA,EAAM,GAAGJ,GAAW,SAASK,EAAQ,CAAA,IACpCN,MAAY,UACb,gBAAAI,EAAAC,GAAA,EAAM,GAAGJ,GAAW,SAASM,EAAO,CAAA,IACnCP,MAAY,aACd,gBAAAI,EAACC,GAAM,EAAA,GAAGJ,GAAW,SAASO,GAAU,OAAON,EAAS,UAAU,GAAG,EAAG,CAAA,IACtEF,MAAY,eACb,gBAAAI,EAAAC,GAAA,EA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