@helsenorge/designsystem-react 9.0.0-beta.0 → 9.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -3
- package/FormGroup.js +45 -38
- package/FormGroup.js.map +1 -1
- package/Input.js.map +1 -1
- package/Label.js +58 -54
- package/Label.js.map +1 -1
- package/Slider.js +218 -0
- package/Slider.js.map +1 -0
- package/components/ExpanderList/styles.module.scss +5 -0
- package/components/Input/Input.d.ts +1 -1
- package/components/Label/Label.d.ts +5 -2
- package/components/Slider/Slider.d.ts +9 -4
- package/components/Slider/index.js +3 -189
- package/components/Slider/index.js.map +1 -1
- package/components/Slider/styles.module.scss +19 -6
- package/components/Slider/styles.module.scss.d.ts +3 -0
- package/components/Toggle/index.js +424 -432
- package/components/Toggle/index.js.map +1 -1
- package/components/Validation/index.js +15 -14
- package/components/Validation/index.js.map +1 -1
- package/docs/FormExample/FormExample.d.ts +1 -0
- package/package.json +1 -1
package/Slider.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { jsxs as w, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import oe, { useState as V, useRef as de, useEffect as p } from "react";
|
|
3
|
+
import U from "classnames";
|
|
4
|
+
import { AnalyticsId as ce } from "./constants.js";
|
|
5
|
+
import { usePseudoClasses as ue } from "./hooks/usePseudoClasses.js";
|
|
6
|
+
import { useSize as me } from "./hooks/useSize.js";
|
|
7
|
+
import { useUuid as C } from "./hooks/useUuid.js";
|
|
8
|
+
import { getAriaLabelAttributes as fe } from "./utils/accessibility.js";
|
|
9
|
+
import { isMutableRefObject as pe, mergeRefs as he } from "./utils/refs.js";
|
|
10
|
+
import { E as ve } from "./ErrorWrapper.js";
|
|
11
|
+
import { T as _e } from "./Title.js";
|
|
12
|
+
import r from "./components/Slider/styles.module.scss";
|
|
13
|
+
const be = (h, f, i) => {
|
|
14
|
+
const [R, v] = V(h), _ = (b) => {
|
|
15
|
+
b > i ? v(i) : b < f ? v(f) : v(b);
|
|
16
|
+
};
|
|
17
|
+
return p(() => {
|
|
18
|
+
_(h);
|
|
19
|
+
}, [f, i]), [R, _];
|
|
20
|
+
}, ge = oe.forwardRef((h, f) => {
|
|
21
|
+
const {
|
|
22
|
+
title: i,
|
|
23
|
+
ariaLabel: R,
|
|
24
|
+
error: v,
|
|
25
|
+
errorText: _,
|
|
26
|
+
errorTextId: b,
|
|
27
|
+
errorWrapperClassName: F,
|
|
28
|
+
labelLeft: j,
|
|
29
|
+
labelRight: P,
|
|
30
|
+
disabled: d = !1,
|
|
31
|
+
onChange: A,
|
|
32
|
+
steps: n,
|
|
33
|
+
step: g = 1,
|
|
34
|
+
minValue: a = 0,
|
|
35
|
+
maxValue: c = n ? n.length - 1 : 100,
|
|
36
|
+
selected: L = !0,
|
|
37
|
+
testId: H,
|
|
38
|
+
value: m,
|
|
39
|
+
...q
|
|
40
|
+
} = h, [B, X] = V(!1), [k, $] = V(typeof m > "u" ? L : !0), [l, u] = be(
|
|
41
|
+
typeof m > "u" ? (c - a) / 2 + a : m,
|
|
42
|
+
a,
|
|
43
|
+
c
|
|
44
|
+
), G = C(b), y = C(), I = C(), x = C(), M = de(null), { refObject: E, isFocused: J } = ue(pe(f) ? f : null), Q = he([f, E]), { width: O } = me(M) || { width: 0 }, W = c / 10, Y = !!_ || !!v;
|
|
45
|
+
p(() => {
|
|
46
|
+
const t = () => {
|
|
47
|
+
X(!1);
|
|
48
|
+
};
|
|
49
|
+
return document.addEventListener("pointerup", t), () => {
|
|
50
|
+
document.removeEventListener("pointerup", t);
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
53
|
+
const z = (t) => {
|
|
54
|
+
var K;
|
|
55
|
+
const e = ((K = M.current) == null ? void 0 : K.getBoundingClientRect().x) ?? 0, o = (t - e) / O, S = c - a;
|
|
56
|
+
let N = o * S + a;
|
|
57
|
+
return N = Math.round(N / g) * g, N = Math.max(a, Math.min(c, N)), N;
|
|
58
|
+
};
|
|
59
|
+
p(() => {
|
|
60
|
+
const t = (e) => {
|
|
61
|
+
if (!d && B) {
|
|
62
|
+
const o = z(e.clientX);
|
|
63
|
+
u(o);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return document.addEventListener("pointermove", t), () => {
|
|
67
|
+
document.removeEventListener("pointermove", t);
|
|
68
|
+
};
|
|
69
|
+
}, [B]), p(() => {
|
|
70
|
+
m !== l && typeof m < "u" && (D(), u(m));
|
|
71
|
+
}, [m]), p(() => {
|
|
72
|
+
typeof m > "u" && L !== k && $(L);
|
|
73
|
+
}, [L]);
|
|
74
|
+
const D = () => {
|
|
75
|
+
k === !1 && $(!0);
|
|
76
|
+
}, Z = (t) => {
|
|
77
|
+
if (d) return;
|
|
78
|
+
let e = !1;
|
|
79
|
+
switch (t.key) {
|
|
80
|
+
case "ArrowLeft":
|
|
81
|
+
case "ArrowDown":
|
|
82
|
+
u(l - g), e = !0;
|
|
83
|
+
break;
|
|
84
|
+
case "PageDown":
|
|
85
|
+
u(l - W), e = !0;
|
|
86
|
+
break;
|
|
87
|
+
case "ArrowRight":
|
|
88
|
+
case "ArrowUp":
|
|
89
|
+
u(l + g), e = !0;
|
|
90
|
+
break;
|
|
91
|
+
case "PageUp":
|
|
92
|
+
u(l + W), e = !0;
|
|
93
|
+
break;
|
|
94
|
+
case "Home":
|
|
95
|
+
u(a), e = !0;
|
|
96
|
+
break;
|
|
97
|
+
case "End":
|
|
98
|
+
u(c), e = !0;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
e && (D(), t.preventDefault(), t.stopPropagation());
|
|
102
|
+
}, ee = (t) => {
|
|
103
|
+
var o;
|
|
104
|
+
if (d) return;
|
|
105
|
+
const e = z(t.clientX);
|
|
106
|
+
u(e), (o = E.current) == null || o.focus();
|
|
107
|
+
}, te = (t) => {
|
|
108
|
+
var e;
|
|
109
|
+
d || (X(!0), D(), t.preventDefault(), t.stopPropagation(), (e = E.current) == null || e.focus());
|
|
110
|
+
}, re = c !== a ? O / (c - a) * (l - a) : 0, ne = () => {
|
|
111
|
+
const t = n ? Math.round((l - a) / g) : null;
|
|
112
|
+
if (n && t !== null && t >= 0 && t < n.length) {
|
|
113
|
+
const e = n[t], o = e.emojiUniCode, S = typeof e.label < "u" ? e.label.toString() : void 0;
|
|
114
|
+
return o && S ? `${o} ${S}` : o || S;
|
|
115
|
+
}
|
|
116
|
+
}, ae = fe({
|
|
117
|
+
label: R,
|
|
118
|
+
id: (() => {
|
|
119
|
+
if (i && j && P)
|
|
120
|
+
return [y, I, x].join(" ");
|
|
121
|
+
if (i && j)
|
|
122
|
+
return [y, I].join(" ");
|
|
123
|
+
if (i && P)
|
|
124
|
+
return [y, x].join(" ");
|
|
125
|
+
if (i)
|
|
126
|
+
return y;
|
|
127
|
+
})(),
|
|
128
|
+
prefer: "label"
|
|
129
|
+
}), T = (t, e) => ({ left: `${t / (e - 1) * 100}%` });
|
|
130
|
+
p(() => {
|
|
131
|
+
k && A && A({
|
|
132
|
+
target: {
|
|
133
|
+
name: h.name,
|
|
134
|
+
value: l
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}, [l, k]);
|
|
138
|
+
const se = () => /* @__PURE__ */ s("div", { className: r["slider__emoji-container"], children: n == null ? void 0 : n.map((t, e) => t.emojiUniCode && /* @__PURE__ */ s(
|
|
139
|
+
"div",
|
|
140
|
+
{
|
|
141
|
+
"aria-hidden": !0,
|
|
142
|
+
className: r.slider__emoji,
|
|
143
|
+
style: T(e, n.length),
|
|
144
|
+
children: t.emojiUniCode
|
|
145
|
+
},
|
|
146
|
+
"emoji" + e
|
|
147
|
+
)) }), ie = () => n == null ? void 0 : n.map((t, e) => /* @__PURE__ */ s("div", { className: r.slider__track__step, style: T(e, n.length) }, "step" + e)), le = () => /* @__PURE__ */ s("div", { className: r["slider__value-container"], children: n == null ? void 0 : n.map((t, e) => typeof t.label < "u" && /* @__PURE__ */ s(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
"aria-hidden": !0,
|
|
151
|
+
className: r.slider__value,
|
|
152
|
+
style: T(e, n.length),
|
|
153
|
+
children: t.label
|
|
154
|
+
},
|
|
155
|
+
"label" + e
|
|
156
|
+
)) });
|
|
157
|
+
return /* @__PURE__ */ w(ve, { className: F, errorText: _, errorTextId: G, children: [
|
|
158
|
+
/* @__PURE__ */ s(
|
|
159
|
+
"input",
|
|
160
|
+
{
|
|
161
|
+
"aria-valuetext": ne(),
|
|
162
|
+
className: r["sr-only-slider"],
|
|
163
|
+
disabled: d,
|
|
164
|
+
min: a,
|
|
165
|
+
max: c,
|
|
166
|
+
onChange: A,
|
|
167
|
+
onKeyDown: Z,
|
|
168
|
+
value: l,
|
|
169
|
+
ref: Q,
|
|
170
|
+
type: "range",
|
|
171
|
+
...q,
|
|
172
|
+
...ae
|
|
173
|
+
}
|
|
174
|
+
),
|
|
175
|
+
/* @__PURE__ */ w("div", { className: r.slider, "data-testid": H, "data-analyticsid": ce.Slider, children: [
|
|
176
|
+
i && /* @__PURE__ */ s(_e, { className: r.slider__title, htmlMarkup: "h3", margin: 0, appearance: "title3", id: y, children: i }),
|
|
177
|
+
/* @__PURE__ */ w("div", { className: r["slider__content-container"], children: [
|
|
178
|
+
se(),
|
|
179
|
+
/* @__PURE__ */ w(
|
|
180
|
+
"div",
|
|
181
|
+
{
|
|
182
|
+
ref: M,
|
|
183
|
+
className: U(r["slider__track-wrapper"], d && r["slider__track-wrapper--disabled"]),
|
|
184
|
+
onClick: ee,
|
|
185
|
+
onPointerDown: te,
|
|
186
|
+
children: [
|
|
187
|
+
/* @__PURE__ */ s("div", { className: U(r.slider__track, d && r["slider__track--disabled"]), children: ie() }),
|
|
188
|
+
/* @__PURE__ */ s(
|
|
189
|
+
"div",
|
|
190
|
+
{
|
|
191
|
+
className: U(r.slider__marker, {
|
|
192
|
+
[r["slider__marker--disabled"]]: d,
|
|
193
|
+
[r["slider__marker--selected"]]: k,
|
|
194
|
+
[r["slider__marker--invalid"]]: Y,
|
|
195
|
+
[r["slider__marker--focused"]]: !d && J
|
|
196
|
+
}),
|
|
197
|
+
style: {
|
|
198
|
+
left: `${re}px`
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
le()
|
|
206
|
+
] }),
|
|
207
|
+
(j || P) && /* @__PURE__ */ w("span", { className: r.slider__options, children: [
|
|
208
|
+
/* @__PURE__ */ s("span", { id: I, children: j }),
|
|
209
|
+
/* @__PURE__ */ s("span", { id: x, children: P })
|
|
210
|
+
] })
|
|
211
|
+
] })
|
|
212
|
+
] });
|
|
213
|
+
});
|
|
214
|
+
ge.displayName = "Slider";
|
|
215
|
+
export {
|
|
216
|
+
ge as S
|
|
217
|
+
};
|
|
218
|
+
//# sourceMappingURL=Slider.js.map
|
package/Slider.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Slider.js","sources":["../src/components/Slider/Slider.tsx"],"sourcesContent":["import React, { useEffect, useState, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { useSize } from '../../hooks/useSize';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport ErrorWrapper, { ErrorWrapperClassNameProps } from '../ErrorWrapper';\nimport Title from '../Title';\n\nimport styles from './styles.module.scss';\n\nconst useSafeNumberValue = (initial: number, min: number, max: number): [number, (value: number) => void] => {\n const [value, setValue] = useState(initial);\n\n const setSafeValue = (newValue: number): void => {\n if (newValue > max) {\n setValue(max);\n } else if (newValue < min) {\n setValue(min);\n } else {\n setValue(newValue);\n }\n };\n\n useEffect(() => {\n setSafeValue(initial);\n }, [min, max]);\n\n return [value, setSafeValue];\n};\n\nexport type SliderStep = {\n label?: number | string;\n emojiUniCode?: string;\n};\n\nexport interface SliderProps\n extends ErrorWrapperClassNameProps,\n Pick<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'onChange' | 'onBlur'> {\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 /**\tSets the title of the slider. */\n title?: string;\n /** Adds the left hand label to the element. */\n labelLeft?: string;\n /** Adds the right hand label to the element. */\n labelRight?: string;\n /**\tSets aria-label of the slider. */\n ariaLabel?: string;\n /** Disables the slider element. */\n disabled?: boolean;\n /** Sets the minimum allowed value on the slider - this overrides the use of steps prop for minValue/maxValue. */\n minValue?: number;\n /** Sets the maximum allowed value on the slider - this overrides the use of steps prop for minValue/maxValue. */\n maxValue?: number;\n /** If set to false will only trigger onChange once a user interaction has been made, updates to this prop will be taken into account - true by default */\n selected?: boolean;\n /** Sets the steps data for the slider */\n steps?: SliderStep[];\n /** Sets the step to move per point in the slider */\n step?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets the value of the slider */\n value?: number;\n}\n\nexport const Slider = React.forwardRef((props: SliderProps, ref: React.Ref<HTMLInputElement>) => {\n const {\n title,\n ariaLabel,\n error,\n errorText,\n errorTextId,\n errorWrapperClassName,\n labelLeft,\n labelRight,\n disabled = false,\n onChange,\n steps,\n step = 1,\n minValue = 0,\n maxValue = steps ? steps.length - 1 : 100,\n selected = true,\n testId,\n value,\n ...rest\n } = props;\n\n const [isMoving, setIsMoving] = useState(false);\n const [selectedState, setSelectedState] = useState(typeof value === 'undefined' ? selected : true);\n const [valueState, setValueState] = useSafeNumberValue(\n typeof value === 'undefined' ? (maxValue - minValue) / 2 + minValue : value,\n minValue,\n maxValue\n );\n\n const errorTextUuid = useUuid(errorTextId);\n const titleId = useUuid();\n const labelLeftId = useUuid();\n const labelRightId = useUuid();\n const trackRef = useRef<HTMLDivElement>(null);\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n\n const { width: trackWidth } = useSize(trackRef) || { width: 0 };\n const largeStep = maxValue / 10;\n const invalid = !!errorText || !!error;\n\n useEffect(() => {\n const handlePointerUp = (): void => {\n setIsMoving(false);\n };\n\n document.addEventListener('pointerup', handlePointerUp);\n\n return (): void => {\n document.removeEventListener('pointerup', handlePointerUp);\n };\n }, []);\n\n const getValueBasedOnMarkerPosition = (markerPosition: number): number => {\n const trackPosition = trackRef.current?.getBoundingClientRect().x ?? 0;\n\n // Calculate the normalized position (0 to 1) of the marker along the track\n const normalizedPosition = (markerPosition - trackPosition) / trackWidth;\n const valueRange = maxValue - minValue;\n // Calculate the value without considering the step\n let value = normalizedPosition * valueRange + minValue;\n // Adjust the value to account for the step increment\n const stepCount = Math.round(value / step);\n value = stepCount * step;\n value = Math.max(minValue, Math.min(maxValue, value));\n\n return value;\n };\n\n useEffect(() => {\n const handlePointerMove = (e: PointerEvent): void => {\n if (!disabled && isMoving) {\n const newValue = getValueBasedOnMarkerPosition(e.clientX);\n setValueState(newValue);\n }\n };\n\n document.addEventListener('pointermove', handlePointerMove);\n\n return (): void => {\n document.removeEventListener('pointermove', handlePointerMove);\n };\n }, [isMoving]);\n\n useEffect(() => {\n if (value !== valueState && typeof value !== 'undefined') {\n handleSelected();\n setValueState(value);\n }\n }, [value]);\n\n useEffect(() => {\n if (typeof value === 'undefined' && selected !== selectedState) {\n setSelectedState(selected);\n }\n }, [selected]);\n\n const handleSelected = (): void => {\n if (selectedState === false) {\n setSelectedState(true);\n }\n };\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLDivElement> = e => {\n if (disabled) return;\n\n let flag = false;\n\n switch (e.key) {\n case 'ArrowLeft':\n case 'ArrowDown':\n setValueState(valueState - step);\n flag = true;\n break;\n case 'PageDown':\n setValueState(valueState - largeStep);\n flag = true;\n break;\n case 'ArrowRight':\n case 'ArrowUp':\n setValueState(valueState + step);\n flag = true;\n break;\n case 'PageUp':\n setValueState(valueState + largeStep);\n flag = true;\n break;\n case 'Home':\n setValueState(minValue);\n flag = true;\n break;\n case 'End':\n setValueState(maxValue);\n flag = true;\n break;\n default:\n break;\n }\n\n if (flag) {\n handleSelected();\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleTrackClick: React.MouseEventHandler<HTMLDivElement> = e => {\n if (disabled) return;\n\n const newValue = getValueBasedOnMarkerPosition(e.clientX);\n setValueState(newValue);\n refObject.current?.focus();\n };\n\n const handlePointerDown: React.PointerEventHandler<HTMLDivElement> = e => {\n if (disabled) return;\n\n setIsMoving(true);\n handleSelected();\n\n e.preventDefault();\n e.stopPropagation();\n\n refObject.current?.focus();\n };\n\n const markerXPos = maxValue !== minValue ? (trackWidth / (maxValue - minValue)) * (valueState - minValue) : 0;\n\n const getAriaValueText = (): string | undefined => {\n const stepIndex = steps ? Math.round((valueState - minValue) / step) : null;\n\n if (steps && stepIndex !== null && stepIndex >= 0 && stepIndex < steps.length) {\n const step = steps[stepIndex];\n const emojiCode = step.emojiUniCode;\n const label = typeof step.label !== 'undefined' ? step.label.toString() : undefined;\n\n return emojiCode && label ? `${emojiCode} ${label}` : emojiCode || label;\n }\n\n return undefined;\n };\n\n const getAriaLabeledById = (): string | undefined => {\n if (title && labelLeft && labelRight) {\n return [titleId, labelLeftId, labelRightId].join(' ');\n }\n if (title && labelLeft) {\n return [titleId, labelLeftId].join(' ');\n }\n if (title && labelRight) {\n return [titleId, labelRightId].join(' ');\n }\n if (title) {\n return titleId;\n }\n };\n\n const ariaLabelAttributes = getAriaLabelAttributes({\n label: ariaLabel,\n id: getAriaLabeledById(),\n prefer: 'label',\n });\n\n const getXPositionStyling = (index: number, stepsLength: number): { left: string } => {\n return { left: `${(index / (stepsLength - 1)) * 100}%` };\n };\n\n useEffect(() => {\n if (selectedState && onChange) {\n onChange({\n target: {\n name: props.name,\n value: valueState,\n },\n } as unknown as React.ChangeEvent<HTMLInputElement>);\n }\n }, [valueState, selectedState]);\n\n const renderEmojies = (): React.ReactNode => {\n return (\n <div className={styles['slider__emoji-container']}>\n {steps?.map((step, index) => {\n return (\n step.emojiUniCode && (\n <div\n aria-hidden={true}\n key={'emoji' + index}\n className={styles['slider__emoji']}\n style={getXPositionStyling(index, steps.length)}\n >\n {step.emojiUniCode}\n </div>\n )\n );\n })}\n </div>\n );\n };\n\n const renderSteps = (): React.ReactNode => {\n return steps?.map((_step, index) => {\n return <div key={'step' + index} className={styles['slider__track__step']} style={getXPositionStyling(index, steps.length)} />;\n });\n };\n\n const renderStepLabels = (): React.ReactNode => {\n return (\n <div className={styles['slider__value-container']}>\n {steps?.map((step, index) => {\n return (\n typeof step.label !== 'undefined' && (\n <div\n aria-hidden={true}\n key={'label' + index}\n className={styles['slider__value']}\n style={getXPositionStyling(index, steps.length)}\n >\n {step.label}\n </div>\n )\n );\n })}\n </div>\n );\n };\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextUuid}>\n <input\n aria-valuetext={getAriaValueText()}\n className={styles['sr-only-slider']}\n disabled={disabled}\n min={minValue}\n max={maxValue}\n onChange={onChange}\n onKeyDown={handleKeyDown}\n value={valueState}\n ref={mergedRefs}\n type=\"range\"\n {...rest}\n {...ariaLabelAttributes}\n />\n <div className={styles.slider} data-testid={testId} data-analyticsid={AnalyticsId.Slider}>\n {title && (\n <Title className={styles['slider__title']} htmlMarkup={'h3'} margin={0} appearance={'title3'} id={titleId}>\n {title}\n </Title>\n )}\n <div className={styles['slider__content-container']}>\n {renderEmojies()}\n {/* Slider streken er klikkbar med mus/touch */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\n <div\n ref={trackRef}\n className={classNames(styles['slider__track-wrapper'], disabled && styles['slider__track-wrapper--disabled'])}\n onClick={handleTrackClick}\n onPointerDown={handlePointerDown}\n >\n <div className={classNames(styles.slider__track, disabled && styles['slider__track--disabled'])}>{renderSteps()}</div>\n <div\n className={classNames(styles.slider__marker, {\n [styles['slider__marker--disabled']]: disabled,\n [styles['slider__marker--selected']]: selectedState,\n [styles['slider__marker--invalid']]: invalid,\n [styles['slider__marker--focused']]: !disabled && isFocused,\n })}\n style={{\n left: `${markerXPos}px`,\n }}\n />\n </div>\n {renderStepLabels()}\n </div>\n {(labelLeft || labelRight) && (\n <span className={styles.slider__options}>\n <span id={labelLeftId}>{labelLeft}</span>\n <span id={labelRightId}>{labelRight}</span>\n </span>\n )}\n </div>\n </ErrorWrapper>\n );\n});\n\nSlider.displayName = 'Slider';\n\nexport default Slider;\n"],"names":["useSafeNumberValue","initial","min","max","value","setValue","useState","setSafeValue","newValue","useEffect","Slider","React","props","ref","title","ariaLabel","error","errorText","errorTextId","errorWrapperClassName","labelLeft","labelRight","disabled","onChange","steps","step","minValue","maxValue","selected","testId","rest","isMoving","setIsMoving","selectedState","setSelectedState","valueState","setValueState","errorTextUuid","useUuid","titleId","labelLeftId","labelRightId","trackRef","useRef","refObject","isFocused","usePseudoClasses","isMutableRefObject","mergedRefs","mergeRefs","trackWidth","useSize","largeStep","invalid","handlePointerUp","getValueBasedOnMarkerPosition","markerPosition","trackPosition","_a","normalizedPosition","valueRange","handlePointerMove","handleSelected","handleKeyDown","e","flag","handleTrackClick","handlePointerDown","markerXPos","getAriaValueText","stepIndex","emojiCode","label","ariaLabelAttributes","getAriaLabelAttributes","getXPositionStyling","index","stepsLength","renderEmojies","jsx","styles","renderSteps","_step","renderStepLabels","ErrorWrapper","jsxs","AnalyticsId","Title","classNames"],"mappings":";;;;;;;;;;;;AAeA,MAAMA,KAAqB,CAACC,GAAiBC,GAAaC,MAAmD;AAC3G,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAASL,CAAO,GAEpCM,IAAe,CAACC,MAA2B;AAC/C,IAAIA,IAAWL,IACbE,EAASF,CAAG,IACHK,IAAWN,IACpBG,EAASH,CAAG,IAEZG,EAASG,CAAQ;AAAA,EACnB;AAGF,SAAAC,EAAU,MAAM;AACd,IAAAF,EAAaN,CAAO;AAAA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uBAAuB,GAAG1D,KAAY0D,EAAO,iCAAiC,CAAC;AAAA,YAC5G,SAASd;AAAA,YACT,eAAeC;AAAA,YAEf,UAAA;AAAA,cAAC,gBAAAY,EAAA,OAAA,EAAI,WAAWS,EAAWR,EAAO,eAAe1D,KAAY0D,EAAO,yBAAyB,CAAC,GAAI,UAAAC,GAAc,EAAA,CAAA;AAAA,cAChH,gBAAAF;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAWS,EAAWR,EAAO,gBAAgB;AAAA,oBAC3C,CAACA,EAAO,0BAA0B,CAAC,GAAG1D;AAAA,oBACtC,CAAC0D,EAAO,0BAA0B,CAAC,GAAG/C;AAAA,oBACtC,CAAC+C,EAAO,yBAAyB,CAAC,GAAG3B;AAAA,oBACrC,CAAC2B,EAAO,yBAAyB,CAAC,GAAG,CAAC1D,KAAYuB;AAAA,kBAAA,CACnD;AAAA,kBACD,OAAO;AAAA,oBACL,MAAM,GAAGuB,EAAU;AAAA,kBACrB;AAAA,gBAAA;AAAA,cACF;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,QACCe,GAAiB;AAAA,MAAA,GACpB;AAAA,OACE/D,KAAaC,MACb,gBAAAgE,EAAC,QAAK,EAAA,WAAWL,EAAO,iBACtB,UAAA;AAAA,QAAC,gBAAAD,EAAA,QAAA,EAAK,IAAIvC,GAAc,UAAUpB,GAAA;AAAA,QACjC,gBAAA2D,EAAA,QAAA,EAAK,IAAItC,GAAe,UAAWpB,GAAA;AAAA,MAAA,GACtC;AAAA,IAAA,GAEJ;AAAA,EACF,EAAA,CAAA;AAEJ,CAAC;AAEDX,GAAO,cAAc;"}
|
|
@@ -3,7 +3,7 @@ import { FormOnColor, FormSize } from '../../constants';
|
|
|
3
3
|
import { ErrorWrapperClassNameProps } from '../ErrorWrapper';
|
|
4
4
|
import { SvgIcon } from '../Icon';
|
|
5
5
|
import { IconName } from '../Icons/IconNames';
|
|
6
|
-
export interface InputProps extends ErrorWrapperClassNameProps, Pick<React.InputHTMLAttributes<HTMLInputElement>, 'disabled' | 'readOnly' | 'autoComplete' | 'name' | 'placeholder' | 'defaultValue' | 'required' | 'value' | 'min' | 'max' | 'aria-describedby' | 'aria-labelledby' | 'onBlur' | 'onClick' | 'onChange' | 'onFocus' | 'onKeyDown' | 'autoFocus'> {
|
|
6
|
+
export interface InputProps extends ErrorWrapperClassNameProps, Pick<React.InputHTMLAttributes<HTMLInputElement>, 'disabled' | 'readOnly' | 'autoComplete' | 'name' | 'placeholder' | 'defaultValue' | 'required' | 'value' | 'min' | 'max' | 'aria-describedby' | 'aria-labelledby' | 'onBlur' | 'onClick' | 'onChange' | 'onFocus' | 'onKeyDown' | 'autoFocus' | 'inputMode'> {
|
|
7
7
|
/** The number at which the input field starts when you increment or decrement it */
|
|
8
8
|
baseIncrementValue?: number;
|
|
9
9
|
/** Adds custom classes to the element. */
|
|
@@ -5,6 +5,7 @@ export type LabelText = {
|
|
|
5
5
|
text: string;
|
|
6
6
|
type?: 'semibold' | 'normal';
|
|
7
7
|
};
|
|
8
|
+
export type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'span' | 'label' | 'p';
|
|
8
9
|
export interface LabelProps {
|
|
9
10
|
/** Component shown after label - discourage use of this */
|
|
10
11
|
afterLabelChildren?: React.ReactNode;
|
|
@@ -18,6 +19,8 @@ export interface LabelProps {
|
|
|
18
19
|
className?: string;
|
|
19
20
|
/** Id that is put on the "for" attribute of the label */
|
|
20
21
|
htmlFor?: string;
|
|
22
|
+
/** Changes the underlying element of the label */
|
|
23
|
+
htmlMarkup?: LabelTags;
|
|
21
24
|
/** Id som plasseres på <label/> */
|
|
22
25
|
labelId?: string;
|
|
23
26
|
/** Array of main label strings. Can be of type semibold or normal */
|
|
@@ -34,7 +37,7 @@ export interface LabelProps {
|
|
|
34
37
|
testId?: string;
|
|
35
38
|
}
|
|
36
39
|
export declare const getLabelText: (label: React.ReactNode) => string;
|
|
37
|
-
export declare const renderLabel: (label: React.ReactNode, inputId: string, onColor: FormOnColor) => React.ReactNode;
|
|
38
|
-
export declare const renderLabelAsParent: (label: React.ReactNode, children: React.ReactNode, inputId: string, onColor: FormOnColor, labelClassName?: string, labelTextClassName?: string, sublabelWrapperClassName?: string, large?: boolean) => React.ReactNode;
|
|
40
|
+
export declare const renderLabel: (label: React.ReactNode, inputId: string, onColor: FormOnColor, markup?: LabelTags) => React.ReactNode;
|
|
41
|
+
export declare const renderLabelAsParent: (label: React.ReactNode, children: React.ReactNode, inputId: string, onColor: FormOnColor, labelClassName?: string, labelTextClassName?: string, sublabelWrapperClassName?: string, large?: boolean, markup?: LabelTags) => React.ReactNode;
|
|
39
42
|
declare const Label: FunctionComponent<LabelProps>;
|
|
40
43
|
export default Label;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ErrorWrapperClassNameProps } from '../ErrorWrapper';
|
|
2
3
|
export type SliderStep = {
|
|
3
4
|
label?: number | string;
|
|
4
5
|
emojiUniCode?: string;
|
|
5
6
|
};
|
|
6
|
-
export interface SliderProps {
|
|
7
|
+
export interface SliderProps extends ErrorWrapperClassNameProps, Pick<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'onChange' | 'onBlur'> {
|
|
8
|
+
/** Activates Error style for the input */
|
|
9
|
+
error?: boolean;
|
|
10
|
+
/** Error text to show above the component */
|
|
11
|
+
errorText?: string;
|
|
12
|
+
/** Error text id */
|
|
13
|
+
errorTextId?: string;
|
|
7
14
|
/** Sets the title of the slider. */
|
|
8
15
|
title?: string;
|
|
9
16
|
/** Adds the left hand label to the element. */
|
|
@@ -18,8 +25,6 @@ export interface SliderProps {
|
|
|
18
25
|
minValue?: number;
|
|
19
26
|
/** Sets the maximum allowed value on the slider - this overrides the use of steps prop for minValue/maxValue. */
|
|
20
27
|
maxValue?: number;
|
|
21
|
-
/** Function to be called when the value state has changed. */
|
|
22
|
-
onChange?: (value: number) => void;
|
|
23
28
|
/** If set to false will only trigger onChange once a user interaction has been made, updates to this prop will be taken into account - true by default */
|
|
24
29
|
selected?: boolean;
|
|
25
30
|
/** Sets the steps data for the slider */
|
|
@@ -31,5 +36,5 @@ export interface SliderProps {
|
|
|
31
36
|
/** Sets the value of the slider */
|
|
32
37
|
value?: number;
|
|
33
38
|
}
|
|
34
|
-
export declare const Slider: React.
|
|
39
|
+
export declare const Slider: React.ForwardRefExoticComponent<SliderProps & React.RefAttributes<HTMLInputElement>>;
|
|
35
40
|
export default Slider;
|
|
@@ -1,192 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useState as E, useRef as K, useEffect as _ } from "react";
|
|
3
|
-
import D from "classnames";
|
|
4
|
-
import { AnalyticsId as x } from "../../constants.js";
|
|
5
|
-
import { useSize as V } from "../../hooks/useSize.js";
|
|
6
|
-
import { useUuid as L } from "../../hooks/useUuid.js";
|
|
7
|
-
import { getAriaLabelAttributes as ee } from "../../utils/accessibility.js";
|
|
8
|
-
import { T as re } from "../../Title.js";
|
|
9
|
-
import n from "./styles.module.scss";
|
|
10
|
-
const te = (s, v, f) => {
|
|
11
|
-
const [h, o] = E(s), p = (t) => {
|
|
12
|
-
t > f ? o(f) : t < v ? o(v) : o(t);
|
|
13
|
-
};
|
|
14
|
-
return _(() => {
|
|
15
|
-
p(s);
|
|
16
|
-
}, [v, f]), [h, p];
|
|
17
|
-
}, he = ({
|
|
18
|
-
title: s,
|
|
19
|
-
ariaLabel: v,
|
|
20
|
-
labelLeft: f,
|
|
21
|
-
labelRight: h,
|
|
22
|
-
disabled: o = !1,
|
|
23
|
-
onChange: p,
|
|
24
|
-
steps: t,
|
|
25
|
-
step: k = 1,
|
|
26
|
-
minValue: i = 0,
|
|
27
|
-
maxValue: l = t ? t.length - 1 : 100,
|
|
28
|
-
selected: N = !0,
|
|
29
|
-
testId: H,
|
|
30
|
-
value: m
|
|
31
|
-
}) => {
|
|
32
|
-
const [U, B] = E(!1), [g, R] = E(typeof m > "u" ? N : !0), [a, u] = te(
|
|
33
|
-
typeof m > "u" ? (l - i) / 2 + i : m,
|
|
34
|
-
i,
|
|
35
|
-
l
|
|
36
|
-
), y = L(), j = L(), P = L(), A = K(null), I = K(null), { width: T } = V(A) || { width: 0 }, X = l / 10;
|
|
37
|
-
_(() => {
|
|
38
|
-
const r = () => {
|
|
39
|
-
B(!1);
|
|
40
|
-
};
|
|
41
|
-
return document.addEventListener("pointerup", r), () => {
|
|
42
|
-
document.removeEventListener("pointerup", r);
|
|
43
|
-
};
|
|
44
|
-
}, []);
|
|
45
|
-
const $ = (r) => {
|
|
46
|
-
var z;
|
|
47
|
-
const e = ((z = A.current) == null ? void 0 : z.getBoundingClientRect().x) ?? 0, c = (r - e) / T, S = l - i;
|
|
48
|
-
let w = c * S + i;
|
|
49
|
-
return w = Math.round(w / k) * k, w = Math.max(i, Math.min(l, w)), w;
|
|
50
|
-
};
|
|
51
|
-
_(() => {
|
|
52
|
-
const r = (e) => {
|
|
53
|
-
if (!o && U) {
|
|
54
|
-
const c = $(e.clientX);
|
|
55
|
-
u(c);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
return document.addEventListener("pointermove", r), () => {
|
|
59
|
-
document.removeEventListener("pointermove", r);
|
|
60
|
-
};
|
|
61
|
-
}, [U]), _(() => {
|
|
62
|
-
m !== a && typeof m < "u" && (M(), u(m));
|
|
63
|
-
}, [m]), _(() => {
|
|
64
|
-
!o && g && p && p(a);
|
|
65
|
-
}, [a, g]), _(() => {
|
|
66
|
-
typeof m > "u" && N !== g && R(N);
|
|
67
|
-
}, [N]);
|
|
68
|
-
const M = () => {
|
|
69
|
-
g === !1 && R(!0);
|
|
70
|
-
}, O = (r) => {
|
|
71
|
-
if (o) return;
|
|
72
|
-
let e = !1;
|
|
73
|
-
switch (r.key) {
|
|
74
|
-
case "ArrowLeft":
|
|
75
|
-
case "ArrowDown":
|
|
76
|
-
u(a - k), e = !0;
|
|
77
|
-
break;
|
|
78
|
-
case "PageDown":
|
|
79
|
-
u(a - X), e = !0;
|
|
80
|
-
break;
|
|
81
|
-
case "ArrowRight":
|
|
82
|
-
case "ArrowUp":
|
|
83
|
-
u(a + k), e = !0;
|
|
84
|
-
break;
|
|
85
|
-
case "PageUp":
|
|
86
|
-
u(a + X), e = !0;
|
|
87
|
-
break;
|
|
88
|
-
case "Home":
|
|
89
|
-
u(i), e = !0;
|
|
90
|
-
break;
|
|
91
|
-
case "End":
|
|
92
|
-
u(l), e = !0;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
e && (M(), r.preventDefault(), r.stopPropagation());
|
|
96
|
-
}, W = (r) => {
|
|
97
|
-
var c;
|
|
98
|
-
if (o) return;
|
|
99
|
-
const e = $(r.clientX);
|
|
100
|
-
u(e), (c = I.current) == null || c.focus();
|
|
101
|
-
}, q = (r) => {
|
|
102
|
-
var e;
|
|
103
|
-
o || (B(!0), M(), r.preventDefault(), r.stopPropagation(), (e = I.current) == null || e.focus());
|
|
104
|
-
}, F = l !== i ? T / (l - i) * (a - i) : 0, G = () => {
|
|
105
|
-
const r = t ? Math.round((a - i) / k) : null;
|
|
106
|
-
if (t && r !== null && r >= 0 && r < t.length) {
|
|
107
|
-
const e = t[r], c = e.emojiUniCode, S = typeof e.label < "u" ? e.label.toString() : void 0;
|
|
108
|
-
return c && S ? `${c} ${S}` : c || S;
|
|
109
|
-
}
|
|
110
|
-
}, J = ee({
|
|
111
|
-
label: v,
|
|
112
|
-
id: (() => {
|
|
113
|
-
if (s && f && h)
|
|
114
|
-
return [y, j, P].join(" ");
|
|
115
|
-
if (s && f)
|
|
116
|
-
return [y, j].join(" ");
|
|
117
|
-
if (s && h)
|
|
118
|
-
return [y, P].join(" ");
|
|
119
|
-
if (s)
|
|
120
|
-
return y;
|
|
121
|
-
})(),
|
|
122
|
-
prefer: "label"
|
|
123
|
-
}), C = (r, e) => ({ left: `${r / (e - 1) * 100}%` }), Q = () => /* @__PURE__ */ d("div", { className: n["slider__emoji-container"], children: t == null ? void 0 : t.map((r, e) => r.emojiUniCode && /* @__PURE__ */ d(
|
|
124
|
-
"div",
|
|
125
|
-
{
|
|
126
|
-
"aria-hidden": !0,
|
|
127
|
-
className: n.slider__emoji,
|
|
128
|
-
style: C(e, t.length),
|
|
129
|
-
children: r.emojiUniCode
|
|
130
|
-
},
|
|
131
|
-
"emoji" + e
|
|
132
|
-
)) }), Y = () => t == null ? void 0 : t.map((r, e) => /* @__PURE__ */ d("div", { className: n.slider__track__step, style: C(e, t.length) }, "step" + e)), Z = () => /* @__PURE__ */ d("div", { className: n["slider__value-container"], children: t == null ? void 0 : t.map((r, e) => typeof r.label < "u" && /* @__PURE__ */ d(
|
|
133
|
-
"div",
|
|
134
|
-
{
|
|
135
|
-
"aria-hidden": !0,
|
|
136
|
-
className: n.slider__value,
|
|
137
|
-
style: C(e, t.length),
|
|
138
|
-
children: r.label
|
|
139
|
-
},
|
|
140
|
-
"label" + e
|
|
141
|
-
)) });
|
|
142
|
-
return /* @__PURE__ */ b("div", { className: n.slider, "data-testid": H, "data-analyticsid": x.Slider, children: [
|
|
143
|
-
s && /* @__PURE__ */ d(re, { className: n.slider__title, htmlMarkup: "h3", margin: 0, appearance: "title3", id: y, children: s }),
|
|
144
|
-
/* @__PURE__ */ b("div", { className: n["slider__content-container"], children: [
|
|
145
|
-
Q(),
|
|
146
|
-
/* @__PURE__ */ b(
|
|
147
|
-
"div",
|
|
148
|
-
{
|
|
149
|
-
ref: A,
|
|
150
|
-
className: D(n["slider__track-wrapper"], o && n["slider__track-wrapper--disabled"]),
|
|
151
|
-
onClick: W,
|
|
152
|
-
onPointerDown: q,
|
|
153
|
-
children: [
|
|
154
|
-
/* @__PURE__ */ d("div", { className: D(n.slider__track, o && n["slider__track--disabled"]), children: Y() }),
|
|
155
|
-
/* @__PURE__ */ d(
|
|
156
|
-
"div",
|
|
157
|
-
{
|
|
158
|
-
role: o ? void 0 : "slider",
|
|
159
|
-
ref: I,
|
|
160
|
-
className: D(n.slider__marker, {
|
|
161
|
-
[n["slider__marker--disabled"]]: o,
|
|
162
|
-
[n["slider__marker--selected"]]: g
|
|
163
|
-
}),
|
|
164
|
-
style: {
|
|
165
|
-
left: `${F}px`
|
|
166
|
-
},
|
|
167
|
-
onKeyDown: O,
|
|
168
|
-
"aria-valuenow": a,
|
|
169
|
-
"aria-valuetext": G(),
|
|
170
|
-
"aria-valuemin": i,
|
|
171
|
-
"aria-valuemax": l,
|
|
172
|
-
tabIndex: o ? void 0 : 0,
|
|
173
|
-
"aria-disabled": o,
|
|
174
|
-
...J
|
|
175
|
-
}
|
|
176
|
-
)
|
|
177
|
-
]
|
|
178
|
-
}
|
|
179
|
-
),
|
|
180
|
-
Z()
|
|
181
|
-
] }),
|
|
182
|
-
(f || h) && /* @__PURE__ */ b("span", { className: n.slider__options, children: [
|
|
183
|
-
/* @__PURE__ */ d("span", { id: j, children: f }),
|
|
184
|
-
/* @__PURE__ */ d("span", { id: P, children: h })
|
|
185
|
-
] })
|
|
186
|
-
] });
|
|
187
|
-
};
|
|
1
|
+
import { S as a } from "../../Slider.js";
|
|
188
2
|
export {
|
|
189
|
-
|
|
190
|
-
|
|
3
|
+
a as Slider,
|
|
4
|
+
a as default
|
|
191
5
|
};
|
|
192
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Slider/Slider.tsx"],"sourcesContent":["import React, { useEffect, useState, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useSize } from '../../hooks/useSize';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport Title from '../Title';\n\nimport styles from './styles.module.scss';\n\nconst useSafeNumberValue = (initial: number, min: number, max: number): [number, (value: number) => void] => {\n const [value, setValue] = useState(initial);\n\n const setSafeValue = (newValue: number): void => {\n if (newValue > max) {\n setValue(max);\n } else if (newValue < min) {\n setValue(min);\n } else {\n setValue(newValue);\n }\n };\n\n useEffect(() => {\n setSafeValue(initial);\n }, [min, max]);\n\n return [value, setSafeValue];\n};\n\nexport type SliderStep = {\n label?: number | string;\n emojiUniCode?: string;\n};\n\nexport interface SliderProps {\n /**\tSets the title of the slider. */\n title?: string;\n /** Adds the left hand label to the element. */\n labelLeft?: string;\n /** Adds the right hand label to the element. */\n labelRight?: string;\n /**\tSets aria-label of the slider. */\n ariaLabel?: string;\n /** Disables the slider element. */\n disabled?: boolean;\n /** Sets the minimum allowed value on the slider - this overrides the use of steps prop for minValue/maxValue. */\n minValue?: number;\n /** Sets the maximum allowed value on the slider - this overrides the use of steps prop for minValue/maxValue. */\n maxValue?: number;\n /** Function to be called when the value state has changed. */\n onChange?: (value: number) => void;\n /** If set to false will only trigger onChange once a user interaction has been made, updates to this prop will be taken into account - true by default */\n selected?: boolean;\n /** Sets the steps data for the slider */\n steps?: SliderStep[];\n /** Sets the step to move per point in the slider */\n step?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets the value of the slider */\n value?: number;\n}\n\nexport const Slider: React.FC<SliderProps> = ({\n title,\n ariaLabel,\n labelLeft,\n labelRight,\n disabled = false,\n onChange,\n steps,\n step = 1,\n minValue = 0,\n maxValue = steps ? steps.length - 1 : 100,\n selected = true,\n testId,\n value,\n}) => {\n const [isMoving, setIsMoving] = useState(false);\n const [selectedState, setSelectedState] = useState(typeof value === 'undefined' ? selected : true);\n const [valueState, setValueState] = useSafeNumberValue(\n typeof value === 'undefined' ? (maxValue - minValue) / 2 + minValue : value,\n minValue,\n maxValue\n );\n\n const titleId = useUuid();\n const labelLeftId = useUuid();\n const labelRightId = useUuid();\n const trackRef = useRef<HTMLDivElement>(null);\n const markerRef = useRef<HTMLDivElement>(null);\n const { width: trackWidth } = useSize(trackRef) || { width: 0 };\n const largeStep = maxValue / 10;\n\n useEffect(() => {\n const handlePointerUp = (): void => {\n setIsMoving(false);\n };\n\n document.addEventListener('pointerup', handlePointerUp);\n\n return () => {\n document.removeEventListener('pointerup', handlePointerUp);\n };\n }, []);\n\n const getValueBasedOnMarkerPosition = (markerPosition: number): number => {\n const trackPosition = trackRef.current?.getBoundingClientRect().x ?? 0;\n\n // Calculate the normalized position (0 to 1) of the marker along the track\n const normalizedPosition = (markerPosition - trackPosition) / trackWidth;\n const valueRange = maxValue - minValue;\n // Calculate the value without considering the step\n let value = normalizedPosition * valueRange + minValue;\n // Adjust the value to account for the step increment\n const stepCount = Math.round(value / step);\n value = stepCount * step;\n value = Math.max(minValue, Math.min(maxValue, value));\n\n return value;\n };\n\n useEffect(() => {\n const handlePointerMove = (e: PointerEvent): void => {\n if (!disabled && isMoving) {\n const newValue = getValueBasedOnMarkerPosition(e.clientX);\n setValueState(newValue);\n }\n };\n\n document.addEventListener('pointermove', handlePointerMove);\n\n return () => {\n document.removeEventListener('pointermove', handlePointerMove);\n };\n }, [isMoving]);\n\n useEffect(() => {\n if (value !== valueState && typeof value !== 'undefined') {\n handleSelected();\n setValueState(value);\n }\n }, [value]);\n\n useEffect(() => {\n if (!disabled && selectedState && onChange) {\n onChange(valueState);\n }\n }, [valueState, selectedState]);\n\n useEffect(() => {\n if (typeof value === 'undefined' && selected !== selectedState) {\n setSelectedState(selected);\n }\n }, [selected]);\n\n const handleSelected = (): void => {\n if (selectedState === false) {\n setSelectedState(true);\n }\n };\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLDivElement> = e => {\n if (disabled) return;\n\n let flag = false;\n\n switch (e.key) {\n case 'ArrowLeft':\n case 'ArrowDown':\n setValueState(valueState - step);\n flag = true;\n break;\n case 'PageDown':\n setValueState(valueState - largeStep);\n flag = true;\n break;\n case 'ArrowRight':\n case 'ArrowUp':\n setValueState(valueState + step);\n flag = true;\n break;\n case 'PageUp':\n setValueState(valueState + largeStep);\n flag = true;\n break;\n case 'Home':\n setValueState(minValue);\n flag = true;\n break;\n case 'End':\n setValueState(maxValue);\n flag = true;\n break;\n default:\n break;\n }\n\n if (flag) {\n handleSelected();\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleTrackClick: React.MouseEventHandler<HTMLDivElement> = e => {\n if (disabled) return;\n\n const newValue = getValueBasedOnMarkerPosition(e.clientX);\n setValueState(newValue);\n markerRef.current?.focus();\n };\n\n const handlePointerDown: React.PointerEventHandler<HTMLDivElement> = e => {\n if (disabled) return;\n\n setIsMoving(true);\n handleSelected();\n\n e.preventDefault();\n e.stopPropagation();\n\n markerRef.current?.focus();\n };\n\n const markerXPos = maxValue !== minValue ? (trackWidth / (maxValue - minValue)) * (valueState - minValue) : 0;\n\n const getAriaValueText = (): string | undefined => {\n const stepIndex = steps ? Math.round((valueState - minValue) / step) : null;\n\n if (steps && stepIndex !== null && stepIndex >= 0 && stepIndex < steps.length) {\n const step = steps[stepIndex];\n const emojiCode = step.emojiUniCode;\n const label = typeof step.label !== 'undefined' ? step.label.toString() : undefined;\n\n return emojiCode && label ? `${emojiCode} ${label}` : emojiCode || label;\n }\n\n return undefined;\n };\n\n const getAriaLabeledById = (): string | undefined => {\n if (title && labelLeft && labelRight) {\n return [titleId, labelLeftId, labelRightId].join(' ');\n }\n if (title && labelLeft) {\n return [titleId, labelLeftId].join(' ');\n }\n if (title && labelRight) {\n return [titleId, labelRightId].join(' ');\n }\n if (title) {\n return titleId;\n }\n };\n\n const ariaLabelAttributes = getAriaLabelAttributes({\n label: ariaLabel,\n id: getAriaLabeledById(),\n prefer: 'label',\n });\n\n const getXPositionStyling = (index: number, stepsLength: number): { left: string } => {\n return { left: `${(index / (stepsLength - 1)) * 100}%` };\n };\n\n const renderEmojies = (): React.ReactNode => {\n return (\n <div className={styles['slider__emoji-container']}>\n {steps?.map((step, index) => {\n return (\n step.emojiUniCode && (\n <div\n aria-hidden={true}\n key={'emoji' + index}\n className={styles['slider__emoji']}\n style={getXPositionStyling(index, steps.length)}\n >\n {step.emojiUniCode}\n </div>\n )\n );\n })}\n </div>\n );\n };\n\n const renderSteps = (): React.ReactNode => {\n return steps?.map((_step, index) => {\n return <div key={'step' + index} className={styles['slider__track__step']} style={getXPositionStyling(index, steps.length)} />;\n });\n };\n\n const renderStepLabels = (): React.ReactNode => {\n return (\n <div className={styles['slider__value-container']}>\n {steps?.map((step, index) => {\n return (\n typeof step.label !== 'undefined' && (\n <div\n aria-hidden={true}\n key={'label' + index}\n className={styles['slider__value']}\n style={getXPositionStyling(index, steps.length)}\n >\n {step.label}\n </div>\n )\n );\n })}\n </div>\n );\n };\n\n return (\n <div className={styles.slider} data-testid={testId} data-analyticsid={AnalyticsId.Slider}>\n {title && (\n <Title className={styles['slider__title']} htmlMarkup={'h3'} margin={0} appearance={'title3'} id={titleId}>\n {title}\n </Title>\n )}\n <div className={styles['slider__content-container']}>\n {renderEmojies()}\n {/* Komponenten er tilgjengelig for mus/keyboard gjennom bruk av slideren */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\n <div\n ref={trackRef}\n className={classNames(styles['slider__track-wrapper'], disabled && styles['slider__track-wrapper--disabled'])}\n onClick={handleTrackClick}\n onPointerDown={handlePointerDown}\n >\n <div className={classNames(styles.slider__track, disabled && styles['slider__track--disabled'])}>{renderSteps()}</div>\n <div\n role={disabled ? undefined : 'slider'}\n ref={markerRef}\n className={classNames(styles.slider__marker, {\n [styles['slider__marker--disabled']]: disabled,\n [styles['slider__marker--selected']]: selectedState,\n })}\n style={{\n left: `${markerXPos}px`,\n }}\n onKeyDown={handleKeyDown}\n aria-valuenow={valueState}\n aria-valuetext={getAriaValueText()}\n aria-valuemin={minValue}\n aria-valuemax={maxValue}\n tabIndex={disabled ? undefined : 0}\n aria-disabled={disabled}\n {...ariaLabelAttributes}\n />\n </div>\n {renderStepLabels()}\n </div>\n {(labelLeft || labelRight) && (\n <span className={styles.slider__options}>\n <span id={labelLeftId}>{labelLeft}</span>\n <span id={labelRightId}>{labelRight}</span>\n </span>\n )}\n </div>\n );\n};\n\nexport default Slider;\n"],"names":["useSafeNumberValue","initial","min","max","value","setValue","useState","setSafeValue","newValue","useEffect","Slider","title","ariaLabel","labelLeft","labelRight","disabled","onChange","steps","step","minValue","maxValue","selected","testId","isMoving","setIsMoving","selectedState","setSelectedState","valueState","setValueState","titleId","useUuid","labelLeftId","labelRightId","trackRef","useRef","markerRef","trackWidth","useSize","largeStep","handlePointerUp","getValueBasedOnMarkerPosition","markerPosition","trackPosition","_a","normalizedPosition","valueRange","handlePointerMove","handleSelected","handleKeyDown","e","flag","handleTrackClick","handlePointerDown","markerXPos","getAriaValueText","stepIndex","emojiCode","label","ariaLabelAttributes","getAriaLabelAttributes","getXPositionStyling","index","stepsLength","renderEmojies","jsx","styles","renderSteps","_step","renderStepLabels","jsxs","AnalyticsId","Title","classNames"],"mappings":";;;;;;;;;AAYA,MAAMA,KAAqB,CAACC,GAAiBC,GAAaC,MAAmD;AAC3G,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAASL,CAAO,GAEpCM,IAAe,CAACC,MAA2B;AAC/C,IAAIA,IAAWL,IACbE,EAASF,CAAG,IACHK,IAAWN,IACpBG,EAASH,CAAG,IAEZG,EAASG,CAAQ;AAAA,EACnB;AAGF,SAAAC,EAAU,MAAM;AACd,IAAAF,EAAaN,CAAO;AAAA,EAAA,GACnB,CAACC,GAAKC,CAAG,CAAC,GAEN,CAACC,GAAOG,CAAY;AAC7B,GAoCaG,KAAgC,CAAC;AAAA,EAC5C,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,UAAAC,IAAW;AAAA,EACX,UAAAC,IAAWH,IAAQA,EAAM,SAAS,IAAI;AAAA,EACtC,UAAAI,IAAW;AAAA,EACX,QAAAC;AAAA,EACA,OAAAlB;AACF,MAAM;AACJ,QAAM,CAACmB,GAAUC,CAAW,IAAIlB,EAAS,EAAK,GACxC,CAACmB,GAAeC,CAAgB,IAAIpB,EAAS,OAAOF,IAAU,MAAciB,I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A,YAAC,gBAAAY,EAAA,OAAA,EAAI,WAAWQ,EAAWP,EAAO,eAAelD,KAAYkD,EAAO,yBAAyB,CAAC,GAAI,UAAAC,EAAc,EAAA,CAAA;AAAA,YAChH,gBAAAF;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAMjD,IAAW,SAAY;AAAA,gBAC7B,KAAKoB;AAAA,gBACL,WAAWqC,EAAWP,EAAO,gBAAgB;AAAA,kBAC3C,CAACA,EAAO,0BAA0B,CAAC,GAAGlD;AAAA,kBACtC,CAACkD,EAAO,0BAA0B,CAAC,GAAGxC;AAAA,gBAAA,CACvC;AAAA,gBACD,OAAO;AAAA,kBACL,MAAM,GAAG4B,CAAU;AAAA,gBACrB;AAAA,gBACA,WAAWL;AAAA,gBACX,iBAAerB;AAAA,gBACf,kBAAgB2B,EAAiB;AAAA,gBACjC,iBAAenC;AAAA,gBACf,iBAAeC;AAAA,gBACf,UAAUL,IAAW,SAAY;AAAA,gBACjC,iBAAeA;AAAA,gBACd,GAAG2C;AAAA,cAAA;AAAA,YACN;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,MACCU,EAAiB;AAAA,IAAA,GACpB;AAAA,KACEvD,KAAaC,MACb,gBAAAuD,EAAC,QAAK,EAAA,WAAWJ,EAAO,iBACtB,UAAA;AAAA,MAAC,gBAAAD,EAAA,QAAA,EAAK,IAAIjC,GAAc,UAAUlB,GAAA;AAAA,MACjC,gBAAAmD,EAAA,QAAA,EAAK,IAAIhC,GAAe,UAAWlB,GAAA;AAAA,IAAA,GACtC;AAAA,EAEJ,EAAA,CAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
@import '../../scss/spacers';
|
|
2
2
|
@import '../../scss/breakpoints';
|
|
3
3
|
@import '../../scss/palette';
|
|
4
|
+
@import '../../scss/screen-reader';
|
|
5
|
+
@import '../../scss/supernova/styles/colors';
|
|
4
6
|
|
|
5
7
|
$track-height-offset: 1rem;
|
|
6
8
|
$mark-size: getSpacer(l);
|
|
7
9
|
|
|
10
|
+
.sr-only-slider {
|
|
11
|
+
@include sr-only;
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
.slider {
|
|
9
15
|
display: flex;
|
|
10
16
|
flex-direction: column;
|
|
11
17
|
row-gap: getSpacer(s);
|
|
12
18
|
width: 100%;
|
|
13
|
-
padding: getSpacer(m) 0;
|
|
14
19
|
position: relative;
|
|
15
20
|
outline: none !important;
|
|
16
21
|
|
|
@@ -87,10 +92,16 @@ $mark-size: getSpacer(l);
|
|
|
87
92
|
outline: none;
|
|
88
93
|
cursor: pointer;
|
|
89
94
|
|
|
90
|
-
|
|
95
|
+
&--focused {
|
|
91
96
|
outline: 0.15rem solid $black;
|
|
92
97
|
}
|
|
93
98
|
|
|
99
|
+
&--focused#{&}--selected {
|
|
100
|
+
&::after {
|
|
101
|
+
background-color: $blueberry700;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
94
105
|
&--selected {
|
|
95
106
|
&::after {
|
|
96
107
|
content: '';
|
|
@@ -100,13 +111,16 @@ $mark-size: getSpacer(l);
|
|
|
100
111
|
border-radius: 10rem;
|
|
101
112
|
background-color: $blueberry600;
|
|
102
113
|
|
|
103
|
-
:hover >
|
|
104
|
-
:focus > & {
|
|
114
|
+
:hover > & {
|
|
105
115
|
background-color: $blueberry700;
|
|
106
116
|
}
|
|
107
117
|
}
|
|
108
118
|
}
|
|
109
119
|
|
|
120
|
+
&--invalid {
|
|
121
|
+
border-color: var(--color-notification-border-error);
|
|
122
|
+
}
|
|
123
|
+
|
|
110
124
|
&--disabled {
|
|
111
125
|
border-color: $neutral500;
|
|
112
126
|
cursor: default;
|
|
@@ -115,8 +129,7 @@ $mark-size: getSpacer(l);
|
|
|
115
129
|
border-color: $neutral500;
|
|
116
130
|
background-color: $neutral200;
|
|
117
131
|
|
|
118
|
-
:hover >
|
|
119
|
-
:focus > & {
|
|
132
|
+
:hover > & {
|
|
120
133
|
background-color: $neutral200;
|
|
121
134
|
}
|
|
122
135
|
}
|