@helsenorge/designsystem-react 7.3.0 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/components/Checkbox/Checkbox.js +24 -23
- package/components/Checkbox/Checkbox.js.map +1 -1
- package/components/HighlightBox/styles.module.scss +11 -7
- package/components/Input/Input.js +25 -24
- package/components/Input/Input.js.map +1 -1
- package/components/LinkList/LinkList.js +25 -24
- package/components/LinkList/LinkList.js.map +1 -1
- package/components/PopMenu/PopMenu.d.ts +12 -0
- package/components/PopMenu/PopMenu.js +74 -74
- package/components/PopMenu/PopMenu.js.map +1 -1
- package/components/PopMenu/PopMenu.stories.d.ts +7 -1
- package/components/PopMenu/index.js +3 -2
- package/components/PopMenu/styles.module.scss +1 -1
- package/components/PopOver/PopOver.js +34 -34
- package/components/PopOver/PopOver.js.map +1 -1
- package/components/PopOver/styles.module.scss +4 -7
- package/components/PopOver/styles.module.scss.d.ts +1 -0
- package/components/PromoPanel/PromoPanel.stories.d.ts +1 -0
- package/components/RadioButton/RadioButton.js +27 -26
- package/components/RadioButton/RadioButton.js.map +1 -1
- package/components/Select/Select.d.ts +1 -1
- package/components/Select/Select.js +23 -22
- package/components/Select/Select.js.map +1 -1
- package/components/ServiceMessage/ServiceMessage.stories.d.ts +1 -1
- package/components/Textarea/Textarea.js +34 -33
- package/components/Textarea/Textarea.js.map +1 -1
- package/package.json +1 -1
- package/scss/supernova/index.css +3 -0
- package/scss/supernova/styles/colors.css +173 -0
- package/utils/accessibility.d.ts +12 -0
- package/utils/accessibility.js +17 -8
- package/utils/accessibility.js.map +1 -1
|
@@ -27,7 +27,7 @@ export interface SelectProps extends Pick<React.SelectHTMLAttributes<HTMLSelectE
|
|
|
27
27
|
/** Gives defaultvalue to the comp. Preferred over selected prop on option by react */
|
|
28
28
|
defaultValue?: string | number;
|
|
29
29
|
/** Adds custom classes to the wrapper tag */
|
|
30
|
-
wrapperClassName?:
|
|
30
|
+
wrapperClassName?: string;
|
|
31
31
|
}
|
|
32
32
|
export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLSelectElement>>;
|
|
33
33
|
export default Select;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import r from "react";
|
|
2
2
|
import s from "classnames";
|
|
3
|
-
import { FormMode as
|
|
3
|
+
import { FormMode as B, AnalyticsId as F, IconSize as H, AVERAGE_CHARACTER_WIDTH_PX as M } from "../../constants.js";
|
|
4
4
|
import { useUuid as w } from "../../hooks/useUuid.js";
|
|
5
5
|
import { getColor as v } from "../../theme/currys/color.js";
|
|
6
|
+
import { getAriaDescribedBy as U } from "../../utils/accessibility.js";
|
|
6
7
|
import V from "../ErrorWrapper/ErrorWrapper.js";
|
|
7
8
|
import { Icon as X } from "../Icon/Icon.js";
|
|
8
|
-
import
|
|
9
|
-
import { renderLabel as
|
|
9
|
+
import G from "../Icons/ChevronDown.js";
|
|
10
|
+
import { renderLabel as L } from "../Label/Label.js";
|
|
10
11
|
import e from "../Select/styles.module.scss";
|
|
11
|
-
const
|
|
12
|
+
const P = (o) => `calc(${o * M}px + 2rem)`, j = (o, t) => t ? v("neutral", 500) : v(o ? "cherry" : "blueberry", 600), k = r.forwardRef(function(t, c) {
|
|
12
13
|
const {
|
|
13
14
|
className: y,
|
|
14
15
|
children: I,
|
|
@@ -20,16 +21,16 @@ const G = (o) => `calc(${o * U}px + 2rem)`, L = (o, t) => t ? v("neutral", 500)
|
|
|
20
21
|
label: S,
|
|
21
22
|
selectId: d,
|
|
22
23
|
name: W = d,
|
|
23
|
-
mode: n =
|
|
24
|
-
testId:
|
|
24
|
+
mode: n = B.onwhite,
|
|
25
|
+
testId: g,
|
|
25
26
|
width: m,
|
|
26
27
|
required: p,
|
|
27
|
-
value:
|
|
28
|
-
defaultValue:
|
|
28
|
+
value: N,
|
|
29
|
+
defaultValue: A,
|
|
29
30
|
autoComplete: u = "off",
|
|
30
|
-
wrapperClassName:
|
|
31
|
-
...
|
|
32
|
-
} = t, f = w(d), b = w(x), C = n === "onblueberry", a = n === "oninvalid" || !!i || !!E, _ =
|
|
31
|
+
wrapperClassName: R,
|
|
32
|
+
...T
|
|
33
|
+
} = t, f = w(d), b = w(x), C = n === "onblueberry", a = n === "oninvalid" || !!i || !!E, _ = j(a, !!l), D = m ? P(m) : void 0, $ = s(
|
|
33
34
|
e["select-inner-wrapper"],
|
|
34
35
|
{
|
|
35
36
|
[e["select-inner-wrapper--transparent"]]: h === "transparent",
|
|
@@ -38,32 +39,32 @@ const G = (o) => `calc(${o * U}px + 2rem)`, L = (o, t) => t ? v("neutral", 500)
|
|
|
38
39
|
[e["select-inner-wrapper--disabled"]]: l
|
|
39
40
|
},
|
|
40
41
|
y
|
|
41
|
-
),
|
|
42
|
+
), q = s(e.select, {
|
|
42
43
|
[e["select--on-blueberry"]]: C,
|
|
43
44
|
[e["select--invalid"]]: a
|
|
44
|
-
}),
|
|
45
|
-
return /* @__PURE__ */ r.createElement(V, { errorText: i, errorTextId: b }, /* @__PURE__ */ r.createElement("div", { "data-testid":
|
|
45
|
+
}), z = s(e["select-wrapper"], R);
|
|
46
|
+
return /* @__PURE__ */ r.createElement(V, { errorText: i, errorTextId: b }, /* @__PURE__ */ r.createElement("div", { "data-testid": g, "data-analyticsid": F.Select, className: z, style: { maxWidth: D } }, L(S, f, n), /* @__PURE__ */ r.createElement("div", { className: $ }, /* @__PURE__ */ r.createElement(X, { className: e["select-arrow"], svgIcon: G, color: _, size: H.XSmall }), /* @__PURE__ */ r.createElement(
|
|
46
47
|
"select",
|
|
47
48
|
{
|
|
48
49
|
"aria-invalid": !!a,
|
|
49
50
|
id: f,
|
|
50
51
|
name: W,
|
|
51
|
-
className:
|
|
52
|
+
className: q,
|
|
52
53
|
disabled: l,
|
|
53
54
|
ref: c,
|
|
54
55
|
required: p,
|
|
55
|
-
"aria-describedby":
|
|
56
|
+
"aria-describedby": U(t, b),
|
|
56
57
|
"aria-required": !!p,
|
|
57
|
-
value:
|
|
58
|
-
defaultValue:
|
|
58
|
+
value: N,
|
|
59
|
+
defaultValue: A,
|
|
59
60
|
autoComplete: u || void 0,
|
|
60
|
-
...
|
|
61
|
+
...T
|
|
61
62
|
},
|
|
62
63
|
I
|
|
63
64
|
))));
|
|
64
|
-
}),
|
|
65
|
+
}), le = k;
|
|
65
66
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
k as Select,
|
|
68
|
+
le as default
|
|
68
69
|
};
|
|
69
70
|
//# sourceMappingURL=Select.js.map
|
|
@@ -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, FormMode, IconSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport ErrorWrapper 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 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 mode?: keyof typeof FormMode;\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?:
|
|
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, FormMode, IconSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport ErrorWrapper 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 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 mode?: keyof typeof FormMode;\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 label,\n selectId,\n name = selectId,\n mode = FormMode.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 = mode === 'onblueberry';\n const invalid = mode === '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 errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Select} className={selectWrapperClasses} style={{ maxWidth }}>\n {renderLabel(label, uuid, mode as FormMode)}\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","label","selectId","name","mode","FormMode","testId","width","required","value","defaultValue","autoComplete","wrapperClassName","rest","uuid","useUuid","errorTextUuid","onBlueberry","iconColor","maxWidth","selectInnerWrapperClasses","classNames","selectStyles","selectClasses","selectWrapperClasses","ErrorWrapper","AnalyticsId","renderLabel","Icon","ChevronDown","IconSize","getAriaDescribedBy","Select$1"],"mappings":";;;;;;;;;;;AAkDA,MAAMA,IAAoB,CAACC,MAGlB,QAAQA,IAAaC,CAA0B,cAGlDC,IAAe,CAACC,GAAkBC,MAE/BA,IAAWC,EAAS,WAAW,GAAG,IAAIA,EAD3BF,IAAU,WAAW,aAC0B,GAAG,GAGzDG,IAASC,EAAM,WAAW,SAA4BC,GAAoBC,GAAmC;AAClH,QAAA;AAAA,IACJ,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,UAAAR;AAAA,IACA,OAAAS;AAAA,IACA,WAAAC;AAAA,IACA,aAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,MAAAC,IAAOD;AAAA,IACP,MAAAE,IAAOC,EAAS;AAAA,IAChB,QAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,kBAAAC;AAAA,IACA,GAAGC;AAAA,EACD,IAAApB,GAEEqB,IAAOC,EAAQb,CAAQ,GACvBc,IAAgBD,EAAQf,CAAW,GACnCiB,IAAcb,MAAS,eACvBhB,IAAUgB,MAAS,eAAe,CAAC,CAACL,KAAa,CAAC,CAACD,GACnDoB,IAAY/B,EAAaC,GAAS,CAAC,CAACC,CAAQ,GAC5C8B,IAAWZ,IAAQvB,EAAkBuB,CAAK,IAAI,Q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AA,EAEL,CAAA,CACF,CACF;AAEJ,CAAC,GAEDoC,KAAezC;"}
|
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
import o, { useState as A, useRef as te, useEffect as
|
|
1
|
+
import o, { useState as A, useRef as te, useEffect as B } from "react";
|
|
2
2
|
import p from "classnames";
|
|
3
3
|
import { FormMode as m, AnalyticsId as re, AVERAGE_CHARACTER_WIDTH_PX as ae } from "../../constants.js";
|
|
4
4
|
import { useUuid as oe } from "../../hooks/useUuid.js";
|
|
5
|
-
import {
|
|
6
|
-
import ie from "
|
|
7
|
-
import
|
|
8
|
-
import ce from "../
|
|
5
|
+
import { getAriaDescribedBy as ne } from "../../utils/accessibility.js";
|
|
6
|
+
import { uuid as ie } from "../../utils/uuid.js";
|
|
7
|
+
import se from "../ErrorWrapper/ErrorWrapper.js";
|
|
8
|
+
import { renderLabel as ce } from "../Label/Label.js";
|
|
9
|
+
import de from "../MaxCharacters/MaxCharacters.js";
|
|
9
10
|
import t from "../Textarea/styles.module.scss";
|
|
10
|
-
const
|
|
11
|
+
const le = (a) => `calc(${a * ae}px + 2rem + 16px + 4px)`, N = o.forwardRef((a, x) => {
|
|
11
12
|
const {
|
|
12
13
|
maxCharacters: n,
|
|
13
14
|
maxText: h,
|
|
14
15
|
width: f,
|
|
15
|
-
testId:
|
|
16
|
+
testId: $,
|
|
16
17
|
defaultValue: s,
|
|
17
18
|
marginBottom: M,
|
|
18
19
|
transparent: k,
|
|
19
20
|
mode: i = m.onwhite,
|
|
20
|
-
label:
|
|
21
|
-
textareaId: b =
|
|
21
|
+
label: D,
|
|
22
|
+
textareaId: b = ie(),
|
|
22
23
|
minRows: g = 3,
|
|
23
24
|
maxRows: c = 10,
|
|
24
25
|
grow: w,
|
|
25
|
-
error:
|
|
26
|
+
error: L,
|
|
26
27
|
errorText: C,
|
|
27
|
-
errorTextId:
|
|
28
|
+
errorTextId: S,
|
|
28
29
|
autoFocus: F,
|
|
29
30
|
disabled: U,
|
|
30
31
|
name: V,
|
|
31
32
|
autoComplete: T = "off",
|
|
32
|
-
placeholder:
|
|
33
|
-
readOnly:
|
|
34
|
-
required:
|
|
33
|
+
placeholder: q,
|
|
34
|
+
readOnly: z,
|
|
35
|
+
required: G,
|
|
35
36
|
onChange: E,
|
|
36
|
-
...
|
|
37
|
-
} = a, [
|
|
38
|
-
|
|
37
|
+
...O
|
|
38
|
+
} = a, [P, W] = A(g), [y, R] = A(s || ""), d = te(null), v = oe(S);
|
|
39
|
+
B(() => {
|
|
39
40
|
R(s || "");
|
|
40
41
|
}, [s]);
|
|
41
42
|
const _ = (e) => {
|
|
@@ -43,18 +44,18 @@ const de = (a) => `calc(${a * ae}px + 2rem + 16px + 4px)`, $ = o.forwardRef((a,
|
|
|
43
44
|
e.rows = g;
|
|
44
45
|
const r = Math.floor((e.scrollHeight - 16) / 28);
|
|
45
46
|
r === l && (e.rows = r), r >= c && (e.rows = c, e.scrollTop = e.scrollHeight), r < c ? W(r) : W(c);
|
|
46
|
-
},
|
|
47
|
+
}, X = i === m.ondark, j = i === m.onblueberry, J = !!n && y.toString().length > n, H = i === m.oninvalid || !!C || !!L || J, K = p(t.textarea, {
|
|
47
48
|
[t["textarea--gutterBottom"]]: M
|
|
48
49
|
}), Q = p(t["input-container"], {
|
|
49
50
|
[t["input-container--transparent"]]: k,
|
|
50
|
-
[t["input-container--on-blueberry"]]:
|
|
51
|
-
[t["input-container--on-dark"]]:
|
|
51
|
+
[t["input-container--on-blueberry"]]: j,
|
|
52
|
+
[t["input-container--on-dark"]]: X,
|
|
52
53
|
[t["input-container--invalid"]]: H,
|
|
53
54
|
[t["input-container--disabled"]]: a.disabled
|
|
54
55
|
}), Y = p(t["input-container__input"], {
|
|
55
56
|
[t["input-container__input--disabled"]]: a.disabled
|
|
56
57
|
});
|
|
57
|
-
|
|
58
|
+
B(() => {
|
|
58
59
|
var e, u, l;
|
|
59
60
|
if (w && ((e = d.current) != null && e.children) && ((u = d.current) != null && u.children[0])) {
|
|
60
61
|
const r = (l = d.current) == null ? void 0 : l.children[0];
|
|
@@ -65,29 +66,29 @@ const de = (a) => `calc(${a * ae}px + 2rem + 16px + 4px)`, $ = o.forwardRef((a,
|
|
|
65
66
|
w && _(e.target), R(e.target.value);
|
|
66
67
|
}, ee = (e) => {
|
|
67
68
|
E && E(e), Z(e);
|
|
68
|
-
}, I = f ?
|
|
69
|
-
return /* @__PURE__ */ o.createElement(
|
|
69
|
+
}, I = f ? le(f) : void 0;
|
|
70
|
+
return /* @__PURE__ */ o.createElement(se, { errorText: C, errorTextId: v }, /* @__PURE__ */ o.createElement("div", { "data-testid": $, "data-analyticsid": re.Textarea, className: K }, ce(D, b, i), /* @__PURE__ */ o.createElement("div", { className: Q, ref: d, style: { maxWidth: I } }, /* @__PURE__ */ o.createElement(
|
|
70
71
|
"textarea",
|
|
71
72
|
{
|
|
72
|
-
rows:
|
|
73
|
+
rows: P,
|
|
73
74
|
defaultValue: s,
|
|
74
75
|
id: b,
|
|
75
76
|
className: Y,
|
|
76
77
|
ref: x,
|
|
77
|
-
"aria-describedby":
|
|
78
|
+
"aria-describedby": ne(a, v),
|
|
78
79
|
"aria-invalid": !!H,
|
|
79
80
|
autoFocus: F,
|
|
80
81
|
disabled: U,
|
|
81
82
|
name: V,
|
|
82
83
|
autoComplete: T || void 0,
|
|
83
|
-
placeholder:
|
|
84
|
-
readOnly:
|
|
85
|
-
required:
|
|
84
|
+
placeholder: q,
|
|
85
|
+
readOnly: z,
|
|
86
|
+
required: G,
|
|
86
87
|
onChange: ee,
|
|
87
|
-
...
|
|
88
|
+
...O
|
|
88
89
|
}
|
|
89
90
|
)), n && /* @__PURE__ */ o.createElement(
|
|
90
|
-
|
|
91
|
+
de,
|
|
91
92
|
{
|
|
92
93
|
maxCharacters: n,
|
|
93
94
|
length: y.toString().length,
|
|
@@ -97,9 +98,9 @@ const de = (a) => `calc(${a * ae}px + 2rem + 16px + 4px)`, $ = o.forwardRef((a,
|
|
|
97
98
|
}
|
|
98
99
|
)));
|
|
99
100
|
});
|
|
100
|
-
|
|
101
|
-
const
|
|
101
|
+
N.displayName = "Textarea";
|
|
102
|
+
const Te = N;
|
|
102
103
|
export {
|
|
103
|
-
|
|
104
|
+
Te as default
|
|
104
105
|
};
|
|
105
106
|
//# sourceMappingURL=Textarea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","sources":["../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX, FormMode } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { renderLabel } from '../Label';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\nexport interface TextareaProps\n extends Pick<\n React.InputHTMLAttributes<HTMLTextAreaElement>,\n | 'aria-describedby'\n | 'autoFocus'\n | 'disabled'\n | 'name'\n | 'autoComplete'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'defaultValue'\n | 'onChange'\n > {\n /** max character limit in textarea */\n maxCharacters?: number;\n /** The text is displayed in the end of the text-counter */\n maxText?: string;\n /** Width of textarea in characters (approximate) */\n width?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** If true, the component will have a bottom margin. */\n marginBottom?: boolean;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Changes the visuals of the textarea */\n mode?: keyof typeof FormMode;\n /** Label of the input */\n label?: React.ReactNode;\n /** id of the textarea */\n textareaId?: string;\n /** max rows */\n maxRows?: number;\n /** min rows */\n minRows?: number;\n /** auto-grows until maxRows */\n grow?: boolean;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n}\n\nconst getTextareaMaxWidth = (characters: number): string => {\n const paddingWidth = '2rem';\n const scrollbarWidth = '16px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${scrollbarWidth} + ${borderWidth})`;\n};\n\nconst Textarea = React.forwardRef((props: TextareaProps, ref: React.Ref<HTMLTextAreaElement>) => {\n const {\n maxCharacters,\n maxText,\n width,\n testId,\n defaultValue,\n marginBottom: gutterBottom,\n transparent,\n mode = FormMode.onwhite,\n label,\n textareaId = uuid(),\n minRows = 3,\n maxRows = 10,\n grow,\n error,\n errorText,\n errorTextId,\n autoFocus,\n disabled,\n name,\n autoComplete = 'off',\n placeholder,\n readOnly,\n required,\n onChange,\n ...rest\n } = props;\n\n const [rows, setRows] = useState(minRows);\n const [textareaInput, setTextareaInput] = useState(defaultValue || '');\n const referanse = useRef<HTMLDivElement>(null);\n const errorTextUuid = useUuid(errorTextId);\n\n useEffect(() => {\n setTextareaInput(defaultValue || '');\n }, [defaultValue]);\n\n const resizeHeight = (target: HTMLTextAreaElement): void => {\n const textareaLineHeight = 28;\n\n const previousRows = target.rows;\n target.rows = minRows; // reset number of rows in textarea\n\n const currentRows = Math.floor((target.scrollHeight - 16) / textareaLineHeight); // scrollHeight - 16px of padding to calculate the rows\n\n if (currentRows === previousRows) {\n target.rows = currentRows;\n }\n\n if (currentRows >= maxRows) {\n target.rows = maxRows;\n target.scrollTop = target.scrollHeight;\n }\n\n if (currentRows < maxRows) {\n setRows(currentRows);\n } else {\n setRows(maxRows);\n }\n };\n\n const onDark = mode === FormMode.ondark;\n const onBlueberry = mode === FormMode.onblueberry;\n const maxCharactersExceeded = !!maxCharacters && textareaInput.toString().length > maxCharacters;\n const onError = mode === FormMode.oninvalid || !!errorText || !!error || maxCharactersExceeded;\n\n const textareaWrapperClass = cn(styles.textarea, {\n [styles['textarea--gutterBottom']]: gutterBottom,\n });\n\n const contentWrapperClass = cn(styles['input-container'], {\n [styles['input-container--transparent']]: transparent,\n [styles['input-container--on-blueberry']]: onBlueberry,\n [styles['input-container--on-dark']]: onDark,\n [styles['input-container--invalid']]: onError,\n [styles['input-container--disabled']]: props.disabled,\n });\n\n const textareaClass = cn(styles['input-container__input'], {\n [styles[`input-container__input--disabled`]]: props.disabled,\n });\n\n useEffect(() => {\n if (grow && referanse.current?.children && referanse.current?.children[0]) {\n const textarea = referanse.current?.children[0] as HTMLTextAreaElement;\n resizeHeight(textarea);\n }\n }, []);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n if (grow) {\n resizeHeight(e.target);\n }\n setTextareaInput(e.target.value);\n };\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n if (onChange) {\n onChange(e);\n }\n handleChange(e);\n };\n\n const maxWidth = width ? getTextareaMaxWidth(width) : undefined;\n\n return (\n <ErrorWrapper errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Textarea} className={textareaWrapperClass}>\n {renderLabel(label, textareaId, mode as FormMode)}\n <div className={contentWrapperClass} ref={referanse} style={{ maxWidth }}>\n <textarea\n rows={rows}\n defaultValue={defaultValue}\n id={textareaId}\n className={textareaClass}\n ref={ref}\n aria-describedby={[props['aria-describedby'] || '', errorTextUuid].join(' ')}\n aria-invalid={!!onError}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n disabled={disabled}\n name={name}\n autoComplete={autoComplete ? autoComplete : undefined}\n placeholder={placeholder}\n readOnly={readOnly}\n required={required}\n onChange={onChangeHandler}\n {...rest}\n />\n </div>\n {maxCharacters && (\n <MaxCharacters\n maxCharacters={maxCharacters}\n length={textareaInput.toString().length}\n maxText={maxText}\n mode={mode}\n maxWidth={maxWidth}\n />\n )}\n </div>\n </ErrorWrapper>\n );\n});\n\nTextarea.displayName = 'Textarea';\n\nexport default Textarea;\n"],"names":["getTextareaMaxWidth","characters","AVERAGE_CHARACTER_WIDTH_PX","Textarea","React","props","ref","maxCharacters","maxText","width","testId","defaultValue","gutterBottom","transparent","mode","FormMode","label","textareaId","uuid","minRows","maxRows","grow","error","errorText","errorTextId","autoFocus","disabled","name","autoComplete","placeholder","readOnly","required","onChange","rest","rows","setRows","useState","textareaInput","setTextareaInput","referanse","useRef","errorTextUuid","useUuid","useEffect","resizeHeight","target","previousRows","currentRows","onDark","onBlueberry","maxCharactersExceeded","onError","textareaWrapperClass","cn","styles","contentWrapperClass","textareaClass","_a","_b","textarea","_c","handleChange","onChangeHandler","maxWidth","ErrorWrapper","AnalyticsId","renderLabel","MaxCharacters","Textarea$1"],"mappings":";;;;;;;;;AA2DA,MAAMA,KAAsB,CAACC,MAKpB,QAAQA,IAAaC,EAA0B,2BAGlDC,IAAWC,EAAM,WAAW,CAACC,GAAsBC,MAAwC;AACzF,QAAA;AAAA,IACJ,eAAAC;AAAA,IACA,SAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAcC;AAAA,IACd,aAAAC;AAAA,IACA,MAAAC,IAAOC,EAAS;AAAA,IAChB,OAAAC;AAAA,IACA,YAAAC,IAAaC,GAAK;AAAA,IAClB,SAAAC,IAAU;AAAA,IACV,SAAAC,IAAU;AAAA,IACV,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,aAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,MAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,aAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,GAAGC;AAAA,EACD,IAAA5B,GAEE,CAAC6B,GAAMC,CAAO,IAAIC,EAASjB,CAAO,GAClC,CAACkB,GAAeC,CAAgB,IAAIF,EAASzB,KAAgB,EAAE,GAC/D4B,IAAYC,GAAuB,IAAI,GACvCC,IAAgBC,GAAQlB,CAAW;AAEzC,EAAAmB,EAAU,MAAM;AACd,IAAAL,EAAiB3B,KAAgB,EAAE;AAAA,EAAA,GAClC,CAACA,CAAY,CAA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,SAAA7B;AAAA,MACA,MAAAM;AAAA,MACA,UAAAiD;AAAA,IAAA;AAAA,EAGN,CAAA,CACF;AAEJ,CAAC;AAED5D,EAAS,cAAc;AAEvB,MAAAiE,KAAejE;"}
|
|
1
|
+
{"version":3,"file":"Textarea.js","sources":["../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX, FormMode } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { renderLabel } from '../Label';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\nexport interface TextareaProps\n extends Pick<\n React.InputHTMLAttributes<HTMLTextAreaElement>,\n | 'aria-describedby'\n | 'autoFocus'\n | 'disabled'\n | 'name'\n | 'autoComplete'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'defaultValue'\n | 'onChange'\n > {\n /** max character limit in textarea */\n maxCharacters?: number;\n /** The text is displayed in the end of the text-counter */\n maxText?: string;\n /** Width of textarea in characters (approximate) */\n width?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** If true, the component will have a bottom margin. */\n marginBottom?: boolean;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Changes the visuals of the textarea */\n mode?: keyof typeof FormMode;\n /** Label of the input */\n label?: React.ReactNode;\n /** id of the textarea */\n textareaId?: string;\n /** max rows */\n maxRows?: number;\n /** min rows */\n minRows?: number;\n /** auto-grows until maxRows */\n grow?: boolean;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n}\n\nconst getTextareaMaxWidth = (characters: number): string => {\n const paddingWidth = '2rem';\n const scrollbarWidth = '16px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${scrollbarWidth} + ${borderWidth})`;\n};\n\nconst Textarea = React.forwardRef((props: TextareaProps, ref: React.Ref<HTMLTextAreaElement>) => {\n const {\n maxCharacters,\n maxText,\n width,\n testId,\n defaultValue,\n marginBottom: gutterBottom,\n transparent,\n mode = FormMode.onwhite,\n label,\n textareaId = uuid(),\n minRows = 3,\n maxRows = 10,\n grow,\n error,\n errorText,\n errorTextId,\n autoFocus,\n disabled,\n name,\n autoComplete = 'off',\n placeholder,\n readOnly,\n required,\n onChange,\n ...rest\n } = props;\n\n const [rows, setRows] = useState(minRows);\n const [textareaInput, setTextareaInput] = useState(defaultValue || '');\n const referanse = useRef<HTMLDivElement>(null);\n const errorTextUuid = useUuid(errorTextId);\n\n useEffect(() => {\n setTextareaInput(defaultValue || '');\n }, [defaultValue]);\n\n const resizeHeight = (target: HTMLTextAreaElement): void => {\n const textareaLineHeight = 28;\n\n const previousRows = target.rows;\n target.rows = minRows; // reset number of rows in textarea\n\n const currentRows = Math.floor((target.scrollHeight - 16) / textareaLineHeight); // scrollHeight - 16px of padding to calculate the rows\n\n if (currentRows === previousRows) {\n target.rows = currentRows;\n }\n\n if (currentRows >= maxRows) {\n target.rows = maxRows;\n target.scrollTop = target.scrollHeight;\n }\n\n if (currentRows < maxRows) {\n setRows(currentRows);\n } else {\n setRows(maxRows);\n }\n };\n\n const onDark = mode === FormMode.ondark;\n const onBlueberry = mode === FormMode.onblueberry;\n const maxCharactersExceeded = !!maxCharacters && textareaInput.toString().length > maxCharacters;\n const onError = mode === FormMode.oninvalid || !!errorText || !!error || maxCharactersExceeded;\n\n const textareaWrapperClass = cn(styles.textarea, {\n [styles['textarea--gutterBottom']]: gutterBottom,\n });\n\n const contentWrapperClass = cn(styles['input-container'], {\n [styles['input-container--transparent']]: transparent,\n [styles['input-container--on-blueberry']]: onBlueberry,\n [styles['input-container--on-dark']]: onDark,\n [styles['input-container--invalid']]: onError,\n [styles['input-container--disabled']]: props.disabled,\n });\n\n const textareaClass = cn(styles['input-container__input'], {\n [styles[`input-container__input--disabled`]]: props.disabled,\n });\n\n useEffect(() => {\n if (grow && referanse.current?.children && referanse.current?.children[0]) {\n const textarea = referanse.current?.children[0] as HTMLTextAreaElement;\n resizeHeight(textarea);\n }\n }, []);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n if (grow) {\n resizeHeight(e.target);\n }\n setTextareaInput(e.target.value);\n };\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n if (onChange) {\n onChange(e);\n }\n handleChange(e);\n };\n\n const maxWidth = width ? getTextareaMaxWidth(width) : undefined;\n\n return (\n <ErrorWrapper errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Textarea} className={textareaWrapperClass}>\n {renderLabel(label, textareaId, mode as FormMode)}\n <div className={contentWrapperClass} ref={referanse} style={{ maxWidth }}>\n <textarea\n rows={rows}\n defaultValue={defaultValue}\n id={textareaId}\n className={textareaClass}\n ref={ref}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n aria-invalid={!!onError}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n disabled={disabled}\n name={name}\n autoComplete={autoComplete ? autoComplete : undefined}\n placeholder={placeholder}\n readOnly={readOnly}\n required={required}\n onChange={onChangeHandler}\n {...rest}\n />\n </div>\n {maxCharacters && (\n <MaxCharacters\n maxCharacters={maxCharacters}\n length={textareaInput.toString().length}\n maxText={maxText}\n mode={mode}\n maxWidth={maxWidth}\n />\n )}\n </div>\n </ErrorWrapper>\n );\n});\n\nTextarea.displayName = 'Textarea';\n\nexport default Textarea;\n"],"names":["getTextareaMaxWidth","characters","AVERAGE_CHARACTER_WIDTH_PX","Textarea","React","props","ref","maxCharacters","maxText","width","testId","defaultValue","gutterBottom","transparent","mode","FormMode","label","textareaId","uuid","minRows","maxRows","grow","error","errorText","errorTextId","autoFocus","disabled","name","autoComplete","placeholder","readOnly","required","onChange","rest","rows","setRows","useState","textareaInput","setTextareaInput","referanse","useRef","errorTextUuid","useUuid","useEffect","resizeHeight","target","previousRows","currentRows","onDark","onBlueberry","maxCharactersExceeded","onError","textareaWrapperClass","cn","styles","contentWrapperClass","textareaClass","_a","_b","textarea","_c","handleChange","onChangeHandler","maxWidth","ErrorWrapper","AnalyticsId","renderLabel","getAriaDescribedBy","MaxCharacters","Textarea$1"],"mappings":";;;;;;;;;;AA4DA,MAAMA,KAAsB,CAACC,MAKpB,QAAQA,IAAaC,EAA0B,2BAGlDC,IAAWC,EAAM,WAAW,CAACC,GAAsBC,MAAwC;AACzF,QAAA;AAAA,IACJ,eAAAC;AAAA,IACA,SAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAcC;AAAA,IACd,aAAAC;AAAA,IACA,MAAAC,IAAOC,EAAS;AAAA,IAChB,OAAAC;AAAA,IACA,YAAAC,IAAaC,GAAK;AAAA,IAClB,SAAAC,IAAU;AAAA,IACV,SAAAC,IAAU;AAAA,IACV,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,aAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,MAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,aAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,GAAGC;AAAA,EACD,IAAA5B,GAEE,CAAC6B,GAAMC,CAAO,IAAIC,EAASjB,CAAO,GAClC,CAACkB,GAAeC,CAAgB,IAAIF,EAASzB,KAAgB,EAAE,GAC/D4B,IAAYC,GAAuB,IAAI,GACvCC,IAAgBC,GAAQlB,CAAW;AAEzC,EAAAmB,EAAU,MAAM;AACd,IAAAL,EAAiB3B,KAAgB,EAAE;AAAA,EAAA,GAClC,CAACA,CAAY,CAAC;AAEX,QAAAiC,IAAe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A;AAAA,EAGN,CAAA,CACF;AAEJ,CAAC;AAED5D,EAAS,cAAc;AAEvB,MAAAkE,KAAelE;"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/* stylelint-disable color-hex-length */
|
|
2
|
+
|
|
3
|
+
/* This file was generated by Supernova and should not be changed manually */
|
|
4
|
+
:root {
|
|
5
|
+
--core-color-black: #000000;
|
|
6
|
+
--core-color-white: #ffffff;
|
|
7
|
+
--core-color-blueberry-50: #e4f7f9;
|
|
8
|
+
--core-color-neutral-500: #989693;
|
|
9
|
+
--core-color-neutral-700: #62625f;
|
|
10
|
+
--color-action-text-ondark: #ffffff;
|
|
11
|
+
|
|
12
|
+
/* Hoverfarge for bakgrunn på interaktive elementer - onLight */
|
|
13
|
+
--color-action-background-transparent-onlight-hover: #126f8721;
|
|
14
|
+
|
|
15
|
+
/* Hoverfarge for bakgrunn på interaktive elementer - onLight selected */
|
|
16
|
+
--color-action-background-transparent-onlight-hoverselected: #126f872b;
|
|
17
|
+
--color-notification-background-info: #e4f7f9;
|
|
18
|
+
--color-notification-background-error: #fff2ea;
|
|
19
|
+
--color-destructive-graphics-normal: #c83521;
|
|
20
|
+
--color-base-text-onlight: #000000;
|
|
21
|
+
--color-action-background-ondark: #ffffff;
|
|
22
|
+
--color-action-border-ondark: #ffffff;
|
|
23
|
+
--color-action-border-ondark-focus: #ffffff;
|
|
24
|
+
--color-action-graphics-ondark: #ffffff;
|
|
25
|
+
--color-base-text-ondark: #ffffff;
|
|
26
|
+
--color-base-background-neutral: #f5f3f3;
|
|
27
|
+
--color-base-background-white: #ffffff;
|
|
28
|
+
--color-base-graphics-ondark: #ffffff;
|
|
29
|
+
--color-disabled-text-ondark: #ffffff;
|
|
30
|
+
--color-action-border-onlight: #188097;
|
|
31
|
+
--color-action-border-onlight-hover: #08667c;
|
|
32
|
+
--color-action-border-onlight-focus: #000000;
|
|
33
|
+
--color-action-text-onlight: #126f87;
|
|
34
|
+
--color-action-text-onlight-hover: #08667c;
|
|
35
|
+
--color-action-graphics-onlight: #188097;
|
|
36
|
+
--color-action-graphics-onlight-hover: #126f87;
|
|
37
|
+
--color-action-graphics-ondark-hover: #e4f7f9;
|
|
38
|
+
--color-action-background-ondark-hover: #e4f7f9;
|
|
39
|
+
--color-action-background-ondark-selected: #cae7ed;
|
|
40
|
+
--color-action-background-ondark-hoverselected: #afdae3;
|
|
41
|
+
--color-action-background-onlight: #188097;
|
|
42
|
+
--color-action-background-onlight-hover: #08667c;
|
|
43
|
+
--color-notification-background-warning: #fdf8df;
|
|
44
|
+
--color-notification-background-success: #e6f8ee;
|
|
45
|
+
--color-notification-border-info: #08667c;
|
|
46
|
+
--color-notification-border-error: #a31f0e;
|
|
47
|
+
--color-notification-border-warning: #ab7c00;
|
|
48
|
+
--color-notification-border-success: #078141;
|
|
49
|
+
--color-notification-graphics-info: #08667c;
|
|
50
|
+
--color-notification-graphics-error: #a31f0e;
|
|
51
|
+
--color-notification-graphics-warning: #ab7c00;
|
|
52
|
+
--color-notification-graphics-success: #078141;
|
|
53
|
+
--color-notification-status-warning: #ebc840;
|
|
54
|
+
--color-notification-status-success: #099150;
|
|
55
|
+
--color-destructive-graphics-hover: #b62e1c;
|
|
56
|
+
--color-destructive-text-normal: #b62e1c;
|
|
57
|
+
--color-destructive-text-hover: #a31f0e;
|
|
58
|
+
--color-disabled-background: #d6d4d3;
|
|
59
|
+
--color-disabled-text: #62625f;
|
|
60
|
+
--color-disabled-border: #7d7c79;
|
|
61
|
+
--color-disabled-graphics: #62625f;
|
|
62
|
+
--color-disabled-border-ondark: #d6d4d3;
|
|
63
|
+
--color-disabled-graphics-ondark: #d6d4d3;
|
|
64
|
+
--color-base-background-blueberry: #e4f7f9;
|
|
65
|
+
--color-base-background-cherry: #fff2ea;
|
|
66
|
+
--color-base-background-dark-blueberry: #188097;
|
|
67
|
+
--color-base-background-dark-cherry: #c83521;
|
|
68
|
+
--color-base-graphics-onlight: #000000;
|
|
69
|
+
--color-base-border-ondark: #d6d4d3;
|
|
70
|
+
--color-base-border-onlight: #989693;
|
|
71
|
+
--color-base-border-onlight-emphasized: #62625f;
|
|
72
|
+
--color-help-background: #efe4fd;
|
|
73
|
+
--color-help-graphics: #5b22a6;
|
|
74
|
+
--color-help-border: #5b22a6;
|
|
75
|
+
--core-color-blueberry-100: #cae7ed;
|
|
76
|
+
--core-color-blueberry-200: #afdae3;
|
|
77
|
+
--core-color-blueberry-300: #7abecc;
|
|
78
|
+
--core-color-blueberry-400: #58aabb;
|
|
79
|
+
--core-color-blueberry-500: #188097;
|
|
80
|
+
--core-color-blueberry-600: #126f87;
|
|
81
|
+
--core-color-blueberry-700: #08667c;
|
|
82
|
+
--core-color-blueberry-800: #06596c;
|
|
83
|
+
--core-color-blueberry-900: #084350;
|
|
84
|
+
--core-color-neutral-50: #f5f3f3;
|
|
85
|
+
--core-color-neutral-100: #eae7e7;
|
|
86
|
+
--core-color-neutral-200: #d6d4d3;
|
|
87
|
+
--core-color-neutral-300: #bdbab9;
|
|
88
|
+
--core-color-neutral-400: #aaa8a6;
|
|
89
|
+
--core-color-neutral-600: #7d7c79;
|
|
90
|
+
--core-color-neutral-800: #474745;
|
|
91
|
+
--core-color-neutral-900: #2b2c2b;
|
|
92
|
+
--core-color-banana-50: #fdf8df;
|
|
93
|
+
--core-color-banana-100: #fcf2bf;
|
|
94
|
+
--core-color-banana-200: #f9ea9f;
|
|
95
|
+
--core-color-banana-300: #f5e080;
|
|
96
|
+
--core-color-banana-400: #ebc840;
|
|
97
|
+
--core-color-banana-500: #ddab06;
|
|
98
|
+
--core-color-banana-600: #c59302;
|
|
99
|
+
--core-color-banana-700: #ab7c00;
|
|
100
|
+
--core-color-banana-800: #916500;
|
|
101
|
+
--core-color-banana-900: #764f00;
|
|
102
|
+
--core-color-cherry-50: #fff2ea;
|
|
103
|
+
--core-color-cherry-100: #f7e1d2;
|
|
104
|
+
--core-color-cherry-200: #eec0a5;
|
|
105
|
+
--core-color-cherry-300: #e39376;
|
|
106
|
+
--core-color-cherry-400: #d56147;
|
|
107
|
+
--core-color-cherry-500: #c83521;
|
|
108
|
+
--core-color-cherry-600: #b62e1c;
|
|
109
|
+
--core-color-cherry-700: #a31f0e;
|
|
110
|
+
--core-color-cherry-800: #912112;
|
|
111
|
+
--core-color-cherry-900: #7e1c0e;
|
|
112
|
+
--core-color-kiwi-50: #e6f8ee;
|
|
113
|
+
--core-color-kiwi-100: #c2edd6;
|
|
114
|
+
--core-color-kiwi-200: #9de2bf;
|
|
115
|
+
--core-color-kiwi-300: #79d6aa;
|
|
116
|
+
--core-color-kiwi-400: #56ca96;
|
|
117
|
+
--core-color-kiwi-500: #33be84;
|
|
118
|
+
--core-color-kiwi-600: #10b172;
|
|
119
|
+
--core-color-kiwi-700: #0ca161;
|
|
120
|
+
--core-color-kiwi-800: #099150;
|
|
121
|
+
--core-color-kiwi-900: #078141;
|
|
122
|
+
--core-color-plum-50: #efe4fd;
|
|
123
|
+
--core-color-plum-100: #d7bdf9;
|
|
124
|
+
--core-color-plum-200: #bf98f3;
|
|
125
|
+
--core-color-plum-300: #a875eb;
|
|
126
|
+
--core-color-plum-400: #9153e2;
|
|
127
|
+
--core-color-plum-500: #7a33d7;
|
|
128
|
+
--core-color-plum-600: #6a2abf;
|
|
129
|
+
--core-color-plum-700: #5b22a6;
|
|
130
|
+
--core-color-plum-800: #4c1b8c;
|
|
131
|
+
--core-color-plum-900: #3c1471;
|
|
132
|
+
--color-destructive-background-emphasized: #f7e1d2;
|
|
133
|
+
--color-destructive-background-normal: #fff2ea;
|
|
134
|
+
--brandcolor-white: #ffffff;
|
|
135
|
+
--brandcolor-black: #000000;
|
|
136
|
+
--brandcolor-neutral-verylight: #f5f3f3;
|
|
137
|
+
--brandcolor-neutral-light: #eae7e7;
|
|
138
|
+
--brandcolor-neutral-mediumlight: #d6d4d3;
|
|
139
|
+
--brandcolor-neutral-medium: #989693;
|
|
140
|
+
--brandcolor-neutral-dark: #62625f;
|
|
141
|
+
--brandcolor-neutral-verydark: #2b2c2b;
|
|
142
|
+
--brandcolor-blueberry-verylight: #e4f7f9;
|
|
143
|
+
--brandcolor-blueberry-light: #cae7ed;
|
|
144
|
+
--brandcolor-blueberry-mediumlight: #afdae3;
|
|
145
|
+
--brandcolor-blueberry-medium: #188097;
|
|
146
|
+
--brandcolor-blueberry-mediumdark: #126f87;
|
|
147
|
+
--brandcolor-blueberry-dark: #08667c;
|
|
148
|
+
--brandcolor-cherry-verylight: #fff2ea;
|
|
149
|
+
--brandcolor-cherry-light: #f7e1d2;
|
|
150
|
+
--brandcolor-cherry-medium: #c83521;
|
|
151
|
+
--brandcolor-cherry-mediumdark: #b62e1c;
|
|
152
|
+
--brandcolor-cherry-dark: #a31f0e;
|
|
153
|
+
--color-notification-status-info: #188097;
|
|
154
|
+
--color-notification-status-error: #c83521;
|
|
155
|
+
--color-destructive-border-normal: #c83521;
|
|
156
|
+
--color-action-border-ondark-hover: #e4f7f9;
|
|
157
|
+
|
|
158
|
+
/* Hoverfarge for bakgrunn på interaktive elementer - onDark */
|
|
159
|
+
--color-action-background-transparent-ondark-hover: #00000026;
|
|
160
|
+
|
|
161
|
+
/* Hoverfarge for bakgrunn på interaktive elementer - onDark selected */
|
|
162
|
+
--color-action-background-transparent-ondark-hoverselected: #00000040;
|
|
163
|
+
--color-base-background-dark-neutral: #2b2c2b;
|
|
164
|
+
|
|
165
|
+
/* Placeholdertext in input- and textarea-controls */
|
|
166
|
+
--color-placeholder-text-onlight: #62625f;
|
|
167
|
+
--color-base-border-onlight-subtle: #d6d4d3;
|
|
168
|
+
--color-base-border-neutral: #d6d4d3;
|
|
169
|
+
|
|
170
|
+
/* Subtle border for Blueberry 50 background */
|
|
171
|
+
--color-base-border-blueberry: #afdae3;
|
|
172
|
+
--color-base-border-cherry: #eec0a5;
|
|
173
|
+
}
|
package/utils/accessibility.d.ts
CHANGED
|
@@ -6,4 +6,16 @@ interface AriaLabelAttributesConfig {
|
|
|
6
6
|
}
|
|
7
7
|
export type AriaLabelAttributes = Pick<AriaAttributes, 'aria-label' | 'aria-labelledby'>;
|
|
8
8
|
export declare const getAriaLabelAttributes: (config: AriaLabelAttributesConfig) => AriaLabelAttributes | undefined;
|
|
9
|
+
export interface ErrorAriaProps {
|
|
10
|
+
'aria-describedby'?: string;
|
|
11
|
+
errorText?: string;
|
|
12
|
+
errorTextId?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get IDs to be used with aria-describedby in form components like <Input />
|
|
16
|
+
* @param props Props from form component
|
|
17
|
+
* @param errorTextUuid Unique ID of the form component's error text
|
|
18
|
+
* @returns Element IDs or undefined if there is no aria-description
|
|
19
|
+
*/
|
|
20
|
+
export declare const getAriaDescribedBy: (props: ErrorAriaProps, errorTextUuid?: string) => string | undefined;
|
|
9
21
|
export {};
|
package/utils/accessibility.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
const l = (
|
|
2
|
-
const { label:
|
|
3
|
-
if (
|
|
1
|
+
const l = (e) => {
|
|
2
|
+
const { label: i, id: r, prefer: a = "id" } = e;
|
|
3
|
+
if (r && a === "id")
|
|
4
4
|
return {
|
|
5
|
-
"aria-labelledby":
|
|
5
|
+
"aria-labelledby": r
|
|
6
6
|
};
|
|
7
|
-
if (
|
|
7
|
+
if (i)
|
|
8
8
|
return {
|
|
9
|
-
"aria-label":
|
|
9
|
+
"aria-label": i
|
|
10
10
|
};
|
|
11
|
-
if (
|
|
11
|
+
if (r)
|
|
12
12
|
return {
|
|
13
|
-
"aria-labelledby":
|
|
13
|
+
"aria-labelledby": r
|
|
14
14
|
};
|
|
15
|
+
}, b = (e, i) => {
|
|
16
|
+
const r = e["aria-describedby"], t = !!(e.errorText || e.errorTextId) ? i : void 0;
|
|
17
|
+
if (r && !t)
|
|
18
|
+
return r;
|
|
19
|
+
if (!r && t)
|
|
20
|
+
return t;
|
|
21
|
+
if (r && t)
|
|
22
|
+
return r + " " + t;
|
|
15
23
|
};
|
|
16
24
|
export {
|
|
25
|
+
b as getAriaDescribedBy,
|
|
17
26
|
l as getAriaLabelAttributes
|
|
18
27
|
};
|
|
19
28
|
//# sourceMappingURL=accessibility.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessibility.js","sources":["../../src/utils/accessibility.ts"],"sourcesContent":["import { AriaAttributes } from 'react';\n\ninterface AriaLabelAttributesConfig {\n label?: string;\n id?: string;\n prefer?: 'id' | 'label';\n}\n\nexport type AriaLabelAttributes = Pick<AriaAttributes, 'aria-label' | 'aria-labelledby'>;\n\nexport const getAriaLabelAttributes = (config: AriaLabelAttributesConfig): AriaLabelAttributes | undefined => {\n const { label, id, prefer = 'id' } = config;\n\n if (id && prefer === 'id') {\n return {\n 'aria-labelledby': id,\n };\n }\n\n if (label) {\n return {\n 'aria-label': label,\n };\n }\n\n if (id) {\n return {\n 'aria-labelledby': id,\n };\n }\n};\n"],"names":["getAriaLabelAttributes","config","label","id","prefer"],"mappings":"AAUa,MAAAA,IAAyB,CAACC,MAAuE;AAC5G,QAAM,EAAE,OAAAC,GAAO,IAAAC,GAAI,QAAAC,IAAS,SAASH;AAEjC,MAAAE,KAAMC,MAAW;AACZ,WAAA;AAAA,MACL,mBAAmBD;AAAA,IAAA;AAIvB,MAAID;AACK,WAAA;AAAA,MACL,cAAcA;AAAA,IAAA;AAIlB,MAAIC;AACK,WAAA;AAAA,MACL,mBAAmBA;AAAA,IAAA;AAGzB;"}
|
|
1
|
+
{"version":3,"file":"accessibility.js","sources":["../../src/utils/accessibility.ts"],"sourcesContent":["import { AriaAttributes } from 'react';\n\ninterface AriaLabelAttributesConfig {\n label?: string;\n id?: string;\n prefer?: 'id' | 'label';\n}\n\nexport type AriaLabelAttributes = Pick<AriaAttributes, 'aria-label' | 'aria-labelledby'>;\n\nexport const getAriaLabelAttributes = (config: AriaLabelAttributesConfig): AriaLabelAttributes | undefined => {\n const { label, id, prefer = 'id' } = config;\n\n if (id && prefer === 'id') {\n return {\n 'aria-labelledby': id,\n };\n }\n\n if (label) {\n return {\n 'aria-label': label,\n };\n }\n\n if (id) {\n return {\n 'aria-labelledby': id,\n };\n }\n};\n\nexport interface ErrorAriaProps {\n 'aria-describedby'?: string;\n errorText?: string;\n errorTextId?: string;\n}\n\n/**\n * Get IDs to be used with aria-describedby in form components like <Input />\n * @param props Props from form component\n * @param errorTextUuid Unique ID of the form component's error text\n * @returns Element IDs or undefined if there is no aria-description\n */\nexport const getAriaDescribedBy = (props: ErrorAriaProps, errorTextUuid?: string): string | undefined => {\n const ariaDescribedBy: string | undefined = props['aria-describedby'];\n const hasErrorText: boolean = !!(props.errorText || props.errorTextId);\n const errorTextId: string | undefined = hasErrorText ? errorTextUuid : undefined;\n\n if (ariaDescribedBy && !errorTextId) {\n return ariaDescribedBy;\n } else if (!ariaDescribedBy && errorTextId) {\n return errorTextId;\n } else if (ariaDescribedBy && errorTextId) {\n return ariaDescribedBy + ' ' + errorTextId;\n }\n};\n"],"names":["getAriaLabelAttributes","config","label","id","prefer","getAriaDescribedBy","props","errorTextUuid","ariaDescribedBy","errorTextId"],"mappings":"AAUa,MAAAA,IAAyB,CAACC,MAAuE;AAC5G,QAAM,EAAE,OAAAC,GAAO,IAAAC,GAAI,QAAAC,IAAS,SAASH;AAEjC,MAAAE,KAAMC,MAAW;AACZ,WAAA;AAAA,MACL,mBAAmBD;AAAA,IAAA;AAIvB,MAAID;AACK,WAAA;AAAA,MACL,cAAcA;AAAA,IAAA;AAIlB,MAAIC;AACK,WAAA;AAAA,MACL,mBAAmBA;AAAA,IAAA;AAGzB,GAcaE,IAAqB,CAACC,GAAuBC,MAA+C;AACjG,QAAAC,IAAsCF,EAAM,kBAAkB,GAE9DG,IADwB,CAAC,EAAEH,EAAM,aAAaA,EAAM,eACHC,IAAgB;AAEnE,MAAAC,KAAmB,CAACC;AACf,WAAAD;AACT,MAAW,CAACA,KAAmBC;AACtB,WAAAA;AACT,MAAWD,KAAmBC;AAC5B,WAAOD,IAAkB,MAAMC;AAEnC;"}
|