asma-ui-core 3.81.0 → 3.81.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.
|
@@ -1,106 +1,123 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { HelperRow as
|
|
3
|
-
import { useHelperSlot as
|
|
4
|
-
import
|
|
5
|
-
import { useId as
|
|
6
|
-
import { jsx as
|
|
7
|
-
var
|
|
8
|
-
const
|
|
9
|
-
bottom: `${
|
|
10
|
-
height: `${
|
|
1
|
+
import { cn as u } from "../../../helpers/cn.js";
|
|
2
|
+
import { HelperRow as ft } from "../../../helpers/HelperRow.js";
|
|
3
|
+
import { useHelperSlot as ht } from "../../../helpers/useHelperSlot.js";
|
|
4
|
+
import y from "./StyledSlider.module.js";
|
|
5
|
+
import { useId as pt, useRef as O, useState as Q } from "react";
|
|
6
|
+
import { jsx as b, jsxs as H } from "react/jsx-runtime";
|
|
7
|
+
var U = (i, l, o) => o === l ? 0 : Math.min(100, Math.max(0, (i - l) / (o - l) * 100)), mt = (i) => Array.isArray(i) ? [i[0] ?? 0, i[1] ?? 0] : null, wt = ({ dataTest: i, min: l = 0, max: o = 100, step: h = 1, value: w, defaultValue: W, disabled: p, size: z = "medium", orientation: C = "horizontal", marks: M, name: Z, className: k, classes: s, slotProps: x, error: v, errorText: tt, helperText: L, reserveHelperText: et, ariaLabel: S, ariaLabelledBy: rt, onChange: A, onChangeCommitted: _ }) => {
|
|
8
|
+
const j = pt(), n = C === "vertical", a = z === "small" ? 6 : 8, d = O(null), g = O(null), [lt, N] = Q(null), [nt, F] = Q(W ?? l), I = lt ?? w ?? nt, c = mt(I), f = c !== null, B = v ? tt ?? L : L, { show: K, role: ot } = ht("StyledSlider", v, B, et), V = (M === !0 && Number.isFinite(h) && h > 0 && o > l ? Array.from({ length: Math.floor((o - l) / h) + 1 }, (t, r) => ({ value: l + h * r })) : Array.isArray(M) ? M : []).filter((t) => t.value >= l && t.value <= o), X = f ? Math.min(c[0], c[1]) : l, R = f ? Math.max(c[0], c[1]) : I, Y = (t) => f ? t >= X && t <= R : t <= R, $ = f ? U(X, l, o) : 0, q = U(R, l, o) - $, at = n ? {
|
|
9
|
+
bottom: `${$}%`,
|
|
10
|
+
height: `${q}%`
|
|
11
11
|
} : {
|
|
12
|
-
left: `${
|
|
13
|
-
width: `${
|
|
14
|
-
},
|
|
15
|
-
const
|
|
16
|
-
return
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
left: `${$}%`,
|
|
13
|
+
width: `${q}%`
|
|
14
|
+
}, E = (t) => {
|
|
15
|
+
const r = U(t, l, o);
|
|
16
|
+
return n ? { bottom: `${r}%` } : { left: `${r}%` };
|
|
17
|
+
}, T = (t) => {
|
|
18
|
+
const r = t.currentTarget.getBoundingClientRect(), e = n ? 1 - (t.clientY - (r.top + a)) / (r.height - a * 2) : (t.clientX - (r.left + a)) / (r.width - a * 2), m = l + Math.round(Math.min(1, Math.max(0, e)) * ((o - l) / h)) * h;
|
|
19
|
+
return Math.min(o, Math.max(l, m));
|
|
20
|
+
}, ct = (t) => f && Math.abs((c?.[1] ?? l) - t) < Math.abs((c?.[0] ?? l) - t) ? 1 : 0, ut = (t) => {
|
|
21
|
+
if (p) return;
|
|
22
|
+
const r = T(t), e = ct(r);
|
|
23
|
+
d.current = e, g.current = t.pointerId, t.currentTarget.setPointerCapture(t.pointerId);
|
|
24
|
+
const m = P(r, e);
|
|
25
|
+
N(m), A?.(t, m, e);
|
|
26
|
+
}, it = (t) => {
|
|
27
|
+
if (p || d.current === null || t.pointerId !== g.current) return;
|
|
28
|
+
const r = d.current, e = P(T(t), r);
|
|
29
|
+
N(e), A?.(t, e, r);
|
|
30
|
+
}, st = (t) => {
|
|
31
|
+
if (p || d.current === null || t.pointerId !== g.current) return;
|
|
32
|
+
const r = d.current, e = P(T(t), r);
|
|
33
|
+
w === void 0 && F(e), _?.(t, e), t.currentTarget.hasPointerCapture(t.pointerId) && t.currentTarget.releasePointerCapture(t.pointerId), N(null), d.current = null, g.current = null;
|
|
34
|
+
}, dt = (t) => {
|
|
35
|
+
d.current === null || t.pointerId !== g.current || (N(null), d.current = null, g.current = null);
|
|
36
|
+
}, P = (t, r) => {
|
|
37
|
+
if (!f) return t;
|
|
38
|
+
const e = [c?.[0] ?? 0, c?.[1] ?? 0];
|
|
39
|
+
return e[r] = t, r === 0 && e[0] > e[1] && (e[0] = e[1]), r === 1 && e[1] < e[0] && (e[1] = e[0]), e;
|
|
40
|
+
}, G = (t, r, e, m) => {
|
|
41
|
+
const J = P(e, m);
|
|
42
|
+
w === void 0 && F(J), t && t(r, J, m);
|
|
43
|
+
}, D = (t, r) => /* @__PURE__ */ b("input", {
|
|
30
44
|
type: "range",
|
|
31
|
-
"data-testid": f ? `${
|
|
32
|
-
name:
|
|
33
|
-
min:
|
|
45
|
+
"data-testid": f ? `${i}-thumb-${t}` : i,
|
|
46
|
+
name: Z,
|
|
47
|
+
min: l,
|
|
34
48
|
max: o,
|
|
35
|
-
step:
|
|
36
|
-
value:
|
|
37
|
-
disabled:
|
|
38
|
-
"aria-orientation":
|
|
39
|
-
"aria-label": typeof
|
|
40
|
-
"aria-labelledby":
|
|
41
|
-
"aria-invalid":
|
|
42
|
-
"aria-describedby":
|
|
43
|
-
className:
|
|
44
|
-
onChange: (
|
|
45
|
-
|
|
46
|
-
onKeyUp: (r) => N(V, r, Number(r.currentTarget.value), t)
|
|
49
|
+
step: h,
|
|
50
|
+
value: r,
|
|
51
|
+
disabled: p,
|
|
52
|
+
"aria-orientation": C,
|
|
53
|
+
"aria-label": typeof S == "function" ? S(t) : S,
|
|
54
|
+
"aria-labelledby": rt,
|
|
55
|
+
"aria-invalid": v ? !0 : void 0,
|
|
56
|
+
"aria-describedby": K ? j : void 0,
|
|
57
|
+
className: u(y.SliderInput, n ? y.Vertical : y.Horizontal, !n && "z-0", z === "small" && y.Small, p && y.Disabled, s?.thumb, x?.thumb?.className),
|
|
58
|
+
onChange: (e) => G(A, e, Number(e.currentTarget.value), t),
|
|
59
|
+
onKeyUp: (e) => G(_, e, Number(e.currentTarget.value), t)
|
|
47
60
|
}, t);
|
|
48
|
-
return /* @__PURE__ */
|
|
49
|
-
className:
|
|
61
|
+
return /* @__PURE__ */ H("div", {
|
|
62
|
+
className: u("relative flex", n ? "h-full w-8 flex-col items-center" : "mt-px w-full flex-col", s?.root, k),
|
|
50
63
|
children: [
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
-
className:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
/* @__PURE__ */ H("div", {
|
|
65
|
+
className: u("relative", n ? "h-full w-8" : "h-4 w-full"),
|
|
66
|
+
style: { touchAction: "none" },
|
|
67
|
+
onPointerDown: ut,
|
|
68
|
+
onPointerMove: it,
|
|
69
|
+
onPointerUp: st,
|
|
70
|
+
onPointerCancel: dt,
|
|
71
|
+
children: [/* @__PURE__ */ H("div", {
|
|
72
|
+
className: u("absolute", n ? "left-1/2 w-1 -translate-x-1/2" : "top-[calc(50%+6px)] h-1 -translate-y-1/2"),
|
|
73
|
+
style: n ? {
|
|
74
|
+
top: a,
|
|
75
|
+
bottom: a
|
|
59
76
|
} : {
|
|
60
|
-
left:
|
|
61
|
-
right:
|
|
77
|
+
left: a,
|
|
78
|
+
right: a
|
|
62
79
|
},
|
|
63
80
|
children: [
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
/* @__PURE__ */
|
|
66
|
-
className:
|
|
67
|
-
style:
|
|
81
|
+
/* @__PURE__ */ b("div", { className: u("absolute inset-0 rounded-full bg-delta-100", s?.rail, x?.rail?.className) }),
|
|
82
|
+
/* @__PURE__ */ b("div", {
|
|
83
|
+
className: u("absolute rounded-full", n ? "left-0 w-full" : "top-0 h-full", p ? "bg-delta-200" : "bg-gama-500", s?.track),
|
|
84
|
+
style: at
|
|
68
85
|
}),
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
className:
|
|
73
|
-
style:
|
|
86
|
+
V.map((t) => {
|
|
87
|
+
const r = Y(t.value);
|
|
88
|
+
return /* @__PURE__ */ b("span", {
|
|
89
|
+
className: u("absolute z-10 box-border h-2 w-2 -translate-x-1/2 rounded-full border border-solid", n ? "left-1/2 translate-y-1/2" : "top-1/2 -translate-y-1/2", r ? u(p ? "border-delta-200 bg-delta-200" : "border-gama-500 bg-gama-500", s?.markActive) : u("border-delta-300 bg-white", s?.mark)),
|
|
90
|
+
style: E(t.value)
|
|
74
91
|
}, t.value);
|
|
75
92
|
})
|
|
76
93
|
]
|
|
77
|
-
}), f ? [
|
|
94
|
+
}), f ? [D(0, c[0]), D(1, c[1])] : D(0, I)]
|
|
78
95
|
}),
|
|
79
|
-
|
|
80
|
-
className:
|
|
81
|
-
style:
|
|
82
|
-
top:
|
|
83
|
-
bottom:
|
|
96
|
+
V.some((t) => t.label != null) && /* @__PURE__ */ b("div", {
|
|
97
|
+
className: u(n ? "pointer-events-none absolute inset-x-0" : "relative mt-[14px] h-6"),
|
|
98
|
+
style: n ? {
|
|
99
|
+
top: a,
|
|
100
|
+
bottom: a
|
|
84
101
|
} : {
|
|
85
|
-
marginLeft:
|
|
86
|
-
marginRight:
|
|
102
|
+
marginLeft: a,
|
|
103
|
+
marginRight: a
|
|
87
104
|
},
|
|
88
|
-
children:
|
|
89
|
-
className:
|
|
90
|
-
style:
|
|
105
|
+
children: V.map((t) => t.label == null ? null : /* @__PURE__ */ b("span", {
|
|
106
|
+
className: u("absolute text-base font-semibold text-delta-700", n ? "left-[37px] translate-y-1/2" : "-translate-x-1/2", Y(t.value) && s?.markLabelActive, s?.markLabel, x?.markLabel?.className),
|
|
107
|
+
style: E(t.value),
|
|
91
108
|
children: t.label
|
|
92
109
|
}, t.value))
|
|
93
110
|
}),
|
|
94
|
-
|
|
95
|
-
id:
|
|
96
|
-
role:
|
|
97
|
-
error:
|
|
98
|
-
message:
|
|
111
|
+
K && /* @__PURE__ */ b(ft, {
|
|
112
|
+
id: j,
|
|
113
|
+
role: ot,
|
|
114
|
+
error: v,
|
|
115
|
+
message: B,
|
|
99
116
|
className: "m-0 items-center"
|
|
100
117
|
})
|
|
101
118
|
]
|
|
102
119
|
});
|
|
103
120
|
};
|
|
104
121
|
export {
|
|
105
|
-
|
|
122
|
+
wt as StyledSlider
|
|
106
123
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
SliderInput:
|
|
3
|
-
Horizontal:
|
|
4
|
-
Vertical:
|
|
5
|
-
Small:
|
|
1
|
+
var r = "_SliderInput_18nr0_1", a = "_Horizontal_18nr0_15", l = "_Vertical_18nr0_24", _ = "_Small_18nr0_83", e = "_Disabled_18nr0_92", t = {
|
|
2
|
+
SliderInput: r,
|
|
3
|
+
Horizontal: a,
|
|
4
|
+
Vertical: l,
|
|
5
|
+
Small: _,
|
|
6
6
|
Disabled: e
|
|
7
7
|
};
|
|
8
8
|
export {
|