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 i } from "../../../helpers/cn.js";
2
- import { HelperRow as et } from "../../../helpers/HelperRow.js";
3
- import { useHelperSlot as lt } from "../../../helpers/useHelperSlot.js";
4
- import g from "./StyledSlider.module.js";
5
- import { useId as at, useState as rt } from "react";
6
- import { jsx as p, jsxs as U } from "react/jsx-runtime";
7
- var H = (c, e, o) => o === e ? 0 : Math.min(100, Math.max(0, (c - e) / (o - e) * 100)), ot = (c) => Array.isArray(c) ? [c[0] ?? 0, c[1] ?? 0] : null, ft = ({ dataTest: c, min: e = 0, max: o = 100, step: b = 1, value: T, defaultValue: E, disabled: v, size: z = "medium", orientation: L = "horizontal", marks: M, name: G, className: J, classes: u, slotProps: S, error: y, errorText: O, helperText: _, reserveHelperText: Q, ariaLabel: w, ariaLabelledBy: W, onChange: j, onChangeCommitted: V }) => {
8
- const B = at(), a = L === "vertical", d = z === "small" ? 6 : 8, [Z, k] = rt(E ?? e), A = T ?? Z, n = ot(A), f = n !== null, D = y ? O ?? _ : _, { show: F, role: C } = lt("StyledSlider", y, D, Q), $ = (M === !0 && Number.isFinite(b) && b > 0 && o > e ? Array.from({ length: Math.floor((o - e) / b) + 1 }, (t, l) => ({ value: e + b * l })) : Array.isArray(M) ? M : []).filter((t) => t.value >= e && t.value <= o), K = f ? Math.min(n[0], n[1]) : e, x = f ? Math.max(n[0], n[1]) : A, X = (t) => f ? t >= K && t <= x : t <= x, P = f ? H(K, e, o) : 0, Y = H(x, e, o) - P, I = a ? {
9
- bottom: `${P}%`,
10
- height: `${Y}%`
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: `${P}%`,
13
- width: `${Y}%`
14
- }, q = (t) => {
15
- const l = H(t, e, o);
16
- return a ? { bottom: `${l}%` } : { left: `${l}%` };
17
- }, tt = (t) => {
18
- if (v) return;
19
- const l = t.currentTarget.getBoundingClientRect(), r = a ? 1 - (t.clientY - l.top) / l.height : (t.clientX - l.left) / l.width, m = e + Math.round(Math.min(1, Math.max(0, r)) * ((o - e) / b)) * b, h = Math.min(o, Math.max(e, m));
20
- N(j, t, h, f && Math.abs((n?.[1] ?? e) - h) < Math.abs((n?.[0] ?? e) - h) ? 1 : 0);
21
- }, N = (t, l, r, m) => {
22
- let h = r;
23
- if (!f) h = r;
24
- else {
25
- const s = [n?.[0] ?? 0, n?.[1] ?? 0];
26
- s[m] = r, m === 0 && s[0] > s[1] && (s[0] = s[1]), m === 1 && s[1] < s[0] && (s[1] = s[0]), h = s;
27
- }
28
- T === void 0 && k(h), t && t(l, h, m);
29
- }, R = (t, l) => /* @__PURE__ */ p("input", {
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 ? `${c}-thumb-${t}` : c,
32
- name: G,
33
- min: e,
45
+ "data-testid": f ? `${i}-thumb-${t}` : i,
46
+ name: Z,
47
+ min: l,
34
48
  max: o,
35
- step: b,
36
- value: l,
37
- disabled: v,
38
- "aria-orientation": L,
39
- "aria-label": typeof w == "function" ? w(t) : w,
40
- "aria-labelledby": W,
41
- "aria-invalid": y ? !0 : void 0,
42
- "aria-describedby": F ? B : void 0,
43
- className: i(g.SliderInput, a ? g.Vertical : g.Horizontal, !a && "z-0", z === "small" && g.Small, v && g.Disabled, u?.thumb, S?.thumb?.className),
44
- onChange: (r) => N(j, r, Number(r.currentTarget.value), t),
45
- onPointerUp: (r) => N(V, r, Number(r.currentTarget.value), t),
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__ */ U("div", {
49
- className: i("relative flex", a ? "h-full w-8 flex-col items-center" : "mt-px w-full flex-col", u?.root, J),
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__ */ U("div", {
52
- className: i("relative", a ? "h-full w-8" : "h-4 w-full"),
53
- children: [/* @__PURE__ */ U("div", {
54
- onPointerUp: tt,
55
- className: i("absolute", a ? "left-1/2 w-1 -translate-x-1/2" : "top-[calc(50%+6px)] h-1 -translate-y-1/2"),
56
- style: a ? {
57
- top: d,
58
- bottom: d
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: d,
61
- right: d
77
+ left: a,
78
+ right: a
62
79
  },
63
80
  children: [
64
- /* @__PURE__ */ p("div", { className: i("absolute inset-0 rounded-full bg-delta-100", u?.rail, S?.rail?.className) }),
65
- /* @__PURE__ */ p("div", {
66
- className: i("absolute rounded-full", a ? "left-0 w-full" : "top-0 h-full", v ? "bg-delta-200" : "bg-gama-500", u?.track),
67
- style: I
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
- $.map((t) => {
70
- const l = X(t.value);
71
- return /* @__PURE__ */ p("span", {
72
- className: i("absolute z-10 box-border h-2 w-2 -translate-x-1/2 rounded-full border border-solid", a ? "left-1/2 translate-y-1/2" : "top-1/2 -translate-y-1/2", l ? i(v ? "border-delta-200 bg-delta-200" : "border-gama-500 bg-gama-500", u?.markActive) : i("border-delta-300 bg-white", u?.mark)),
73
- style: q(t.value)
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 ? [R(0, n[0]), R(1, n[1])] : R(0, A)]
94
+ }), f ? [D(0, c[0]), D(1, c[1])] : D(0, I)]
78
95
  }),
79
- $.some((t) => t.label != null) && /* @__PURE__ */ p("div", {
80
- className: i(a ? "pointer-events-none absolute inset-x-0" : "relative mt-[14px] h-6"),
81
- style: a ? {
82
- top: d,
83
- bottom: d
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: d,
86
- marginRight: d
102
+ marginLeft: a,
103
+ marginRight: a
87
104
  },
88
- children: $.map((t) => t.label == null ? null : /* @__PURE__ */ p("span", {
89
- className: i("absolute text-base font-semibold text-delta-700", a ? "left-[37px] translate-y-1/2" : "-translate-x-1/2", X(t.value) && u?.markLabelActive, u?.markLabel, S?.markLabel?.className),
90
- style: q(t.value),
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
- F && /* @__PURE__ */ p(et, {
95
- id: B,
96
- role: C,
97
- error: y,
98
- message: D,
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
- ft as StyledSlider
122
+ wt as StyledSlider
106
123
  };
@@ -1,8 +1,8 @@
1
- var a = "_SliderInput_1f963_1", l = "_Horizontal_1f963_15", _ = "_Vertical_1f963_24", r = "_Small_1f963_83", e = "_Disabled_1f963_92", t = {
2
- SliderInput: a,
3
- Horizontal: l,
4
- Vertical: _,
5
- Small: r,
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 {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.81.0",
6
+ "version": "3.81.1",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",