@blakesteve/roster 5.10.0 → 5.11.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/README.md +165 -3
- package/dist/components/atoms/PasswordInput/PasswordInput.cjs +1 -1
- package/dist/components/atoms/PasswordInput/PasswordInput.js +5 -5
- package/dist/components/atoms/Select/select-variants.cjs +1 -1
- package/dist/components/atoms/Select/select-variants.js +11 -2
- package/dist/components/molecules/Menu/Menu.cjs +1 -1
- package/dist/components/molecules/Menu/Menu.js +60 -53
- package/dist/components/molecules/RangeSlider/RangeSlider.cjs +1 -0
- package/dist/components/molecules/RangeSlider/RangeSlider.d.ts +74 -0
- package/dist/components/molecules/RangeSlider/RangeSlider.js +164 -0
- package/dist/components/molecules/Slider/Slider.cjs +1 -0
- package/dist/components/molecules/Slider/Slider.d.ts +87 -0
- package/dist/components/molecules/Slider/Slider.js +128 -0
- package/dist/components/molecules/Slider/track-parts.cjs +1 -0
- package/dist/components/molecules/Slider/track-parts.d.ts +64 -0
- package/dist/components/molecules/Slider/track-parts.js +121 -0
- package/dist/components/molecules/Slider/track.cjs +1 -0
- package/dist/components/molecules/Slider/track.d.ts +115 -0
- package/dist/components/molecules/Slider/track.js +152 -0
- package/dist/index.d.ts +2 -0
- package/dist/meta.json +3 -3
- package/dist/roster.cjs +1 -1
- package/dist/roster.css +1 -1
- package/dist/roster.js +67 -63
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { jsx as c, jsxs as N, Fragment as j } from "react/jsx-runtime";
|
|
|
3
3
|
import * as i from "react";
|
|
4
4
|
import { Portal as q } from "../../../node_modules/@headlessui/react/dist/components/portal/portal.js";
|
|
5
5
|
import { useFloating as ge, offset as he, flip as be, shift as ye, size as ve } from "../../../node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js";
|
|
6
|
-
import { cn as
|
|
6
|
+
import { cn as S } from "../../../lib/utils.js";
|
|
7
7
|
import { POPUP_PANEL as we } from "../../../internal/popup.js";
|
|
8
8
|
import { Button as xe } from "../../atoms/Button/Button.js";
|
|
9
9
|
import { nextByTypeahead as ke } from "./menu-typeahead.js";
|
|
@@ -23,41 +23,41 @@ function _(e) {
|
|
|
23
23
|
return r;
|
|
24
24
|
}
|
|
25
25
|
const Se = "[data-menu-item]", X = 100, Pe = 75, Me = 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"]), [contenteditable]:not([contenteditable="false"])';
|
|
26
|
-
function
|
|
26
|
+
function D(e) {
|
|
27
27
|
return e ? [...e.querySelectorAll(Se)].filter((r) => r.closest("[data-menu-panel]") === e) : [];
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
e && (e.focus({ preventScroll: !0 }), e.scrollIntoView?.({ block: "nearest" }));
|
|
29
|
+
function E(e) {
|
|
30
|
+
e && (e.setAttribute("data-key-focus", ""), e.addEventListener("blur", () => e.removeAttribute("data-key-focus"), { once: !0 }), e.focus({ preventScroll: !0 }), e.scrollIntoView?.({ block: "nearest" }));
|
|
31
31
|
}
|
|
32
32
|
function z(e) {
|
|
33
33
|
return !!e && getComputedStyle(e).direction === "rtl";
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function Ae(e, r) {
|
|
36
36
|
const n = [...document.querySelectorAll(Me)].filter(
|
|
37
|
-
(t) => t === e || t.tabIndex >= 0 && !t.matches(":disabled") && !t.closest("[data-menu-panel], [inert]") && t.getClientRects().length > 0 && getComputedStyle(t).visibility !== "hidden" && !
|
|
37
|
+
(t) => t === e || t.tabIndex >= 0 && !t.matches(":disabled") && !t.closest("[data-menu-panel], [inert]") && t.getClientRects().length > 0 && getComputedStyle(t).visibility !== "hidden" && !Te(t, r)
|
|
38
38
|
), s = n.indexOf(e);
|
|
39
39
|
((r ? n[s - 1] : n[s + 1]) ?? e).focus();
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function Te(e, r) {
|
|
42
42
|
if (!(e instanceof HTMLInputElement) || e.type !== "radio" || !e.name) return !1;
|
|
43
43
|
const n = [...e.ownerDocument.querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)].filter(
|
|
44
44
|
(a) => a.form === e.form && !a.disabled
|
|
45
45
|
);
|
|
46
46
|
return (n.find((a) => a.checked) ?? (r ? n[n.length - 1] : n[0])) !== e;
|
|
47
47
|
}
|
|
48
|
-
const
|
|
48
|
+
const R = { x: Number.NaN, y: Number.NaN };
|
|
49
49
|
let U = !1;
|
|
50
50
|
function Ce() {
|
|
51
51
|
U || typeof window > "u" || (U = !0, window.addEventListener(
|
|
52
52
|
"pointermove",
|
|
53
53
|
(e) => {
|
|
54
|
-
|
|
54
|
+
R.x = e.clientX, R.y = e.clientY;
|
|
55
55
|
},
|
|
56
56
|
{ passive: !0 }
|
|
57
57
|
));
|
|
58
58
|
}
|
|
59
59
|
function J(e) {
|
|
60
|
-
return !Number.isNaN(
|
|
60
|
+
return !Number.isNaN(R.x) && (e.clientX !== R.x || e.clientY !== R.y);
|
|
61
61
|
}
|
|
62
62
|
const V = (e) => `radial-gradient(farthest-side at 50% ${e === "top" ? "0" : "100%"}, var(--menu-edge), transparent)`, Q = {
|
|
63
63
|
backgroundImage: "var(--menu-edge-top, none), var(--menu-edge-bottom, none)",
|
|
@@ -65,7 +65,7 @@ const V = (e) => `radial-gradient(farthest-side at 50% ${e === "top" ? "0" : "10
|
|
|
65
65
|
backgroundSize: "100% 0.5rem",
|
|
66
66
|
backgroundRepeat: "no-repeat"
|
|
67
67
|
};
|
|
68
|
-
function
|
|
68
|
+
function Le(e) {
|
|
69
69
|
i.useLayoutEffect(() => {
|
|
70
70
|
if (!e) return;
|
|
71
71
|
const r = () => {
|
|
@@ -83,7 +83,7 @@ function Z(e, r) {
|
|
|
83
83
|
const [n, s] = e.split("-"), a = r ? "right" : "left", t = r ? "left" : "right";
|
|
84
84
|
return n === "top" || n === "bottom" ? `${n === "bottom" ? "top" : "bottom"} ${s === "end" ? t : s === "start" ? a : "center"}` : `${s === "end" ? "bottom" : "top"} ${n === "right" ? "left" : "right"}`;
|
|
85
85
|
}
|
|
86
|
-
const ee = /* @__PURE__ */
|
|
86
|
+
const ee = /* @__PURE__ */ S(
|
|
87
87
|
"rst:font-ui",
|
|
88
88
|
we,
|
|
89
89
|
/* Its own width wherever it lands: a fixed panel sized by the room to its
|
|
@@ -137,7 +137,7 @@ function re(e, r, n, s, a, t = !1) {
|
|
|
137
137
|
},
|
|
138
138
|
[a, p]
|
|
139
139
|
);
|
|
140
|
-
return
|
|
140
|
+
return Le(d), { ...u, setPanel: f, panelEl: d };
|
|
141
141
|
}
|
|
142
142
|
const ne = 500;
|
|
143
143
|
function oe() {
|
|
@@ -154,21 +154,21 @@ function se({
|
|
|
154
154
|
return (t) => {
|
|
155
155
|
const d = e.current;
|
|
156
156
|
if (!d || !d.contains(t.target) || (!t.ctrlKey && !t.metaKey && !t.altKey && t.stopPropagation(), t.defaultPrevented)) return;
|
|
157
|
-
const o =
|
|
157
|
+
const o = D(d), u = o.indexOf(document.activeElement), p = z(d);
|
|
158
158
|
switch (t.key) {
|
|
159
159
|
case "ArrowDown":
|
|
160
|
-
t.preventDefault(), t.stopPropagation(),
|
|
160
|
+
t.preventDefault(), t.stopPropagation(), E(o[(u + 1) % o.length]);
|
|
161
161
|
return;
|
|
162
162
|
case "ArrowUp":
|
|
163
|
-
t.preventDefault(), t.stopPropagation(),
|
|
163
|
+
t.preventDefault(), t.stopPropagation(), E(o[u <= 0 ? o.length - 1 : u - 1]);
|
|
164
164
|
return;
|
|
165
165
|
case "Home":
|
|
166
166
|
case "PageUp":
|
|
167
|
-
t.preventDefault(), t.stopPropagation(),
|
|
167
|
+
t.preventDefault(), t.stopPropagation(), E(o[0]);
|
|
168
168
|
return;
|
|
169
169
|
case "End":
|
|
170
170
|
case "PageDown":
|
|
171
|
-
t.preventDefault(), t.stopPropagation(),
|
|
171
|
+
t.preventDefault(), t.stopPropagation(), E(o[o.length - 1]);
|
|
172
172
|
return;
|
|
173
173
|
case "Escape":
|
|
174
174
|
t.preventDefault(), t.stopPropagation(), n();
|
|
@@ -176,7 +176,7 @@ function se({
|
|
|
176
176
|
case "Tab": {
|
|
177
177
|
t.preventDefault(), t.stopPropagation();
|
|
178
178
|
const f = a.triggerRef.current;
|
|
179
|
-
a.close(!1), f &&
|
|
179
|
+
a.close(!1), f && Ae(f, t.shiftKey);
|
|
180
180
|
return;
|
|
181
181
|
}
|
|
182
182
|
case "ArrowLeft":
|
|
@@ -189,7 +189,7 @@ function se({
|
|
|
189
189
|
if (t.key === " " && !m) return;
|
|
190
190
|
t.preventDefault(), r.current = { text: m ? r.current.text + t.key : t.key, at: f };
|
|
191
191
|
const l = o.map((x) => x.dataset.menuText ?? x.textContent ?? ""), b = ke(l, u, r.current.text);
|
|
192
|
-
b !== -1 &&
|
|
192
|
+
b !== -1 && E(o[b]);
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
195
|
}
|
|
@@ -238,7 +238,7 @@ const Ve = i.forwardRef(function({ plain: r = !1, className: n, onClick: s, onKe
|
|
|
238
238
|
P(y), typeof o == "function" ? o(y) : o && (o.current = y);
|
|
239
239
|
},
|
|
240
240
|
[P, o]
|
|
241
|
-
),
|
|
241
|
+
), A = {
|
|
242
242
|
id: h.triggerId,
|
|
243
243
|
"aria-haspopup": "menu",
|
|
244
244
|
"aria-expanded": h.open,
|
|
@@ -254,20 +254,20 @@ const Ve = i.forwardRef(function({ plain: r = !1, className: n, onClick: s, onKe
|
|
|
254
254
|
y.preventDefault();
|
|
255
255
|
const k = h.open ? document.getElementById(h.panelId) : null;
|
|
256
256
|
if (k) {
|
|
257
|
-
const
|
|
258
|
-
|
|
257
|
+
const L = D(k);
|
|
258
|
+
E(v === "last" ? L[L.length - 1] : L[0]);
|
|
259
259
|
return;
|
|
260
260
|
}
|
|
261
261
|
h.openWith(v);
|
|
262
262
|
}
|
|
263
263
|
};
|
|
264
|
-
return r ? /* @__PURE__ */ c("button", { ref: M, type: "button", className: n, ...I, ...
|
|
264
|
+
return r ? /* @__PURE__ */ c("button", { ref: M, type: "button", className: n, ...I, ...A, children: t }) : (
|
|
265
265
|
/* min 44 by 44 whatever the size: the target a finger needs. */
|
|
266
266
|
/* @__PURE__ */ c(
|
|
267
267
|
xe,
|
|
268
268
|
{
|
|
269
269
|
ref: M,
|
|
270
|
-
className:
|
|
270
|
+
className: S("rst:min-h-11 rst:min-w-11", n),
|
|
271
271
|
variant: u,
|
|
272
272
|
colorScheme: p,
|
|
273
273
|
size: f,
|
|
@@ -277,7 +277,7 @@ const Ve = i.forwardRef(function({ plain: r = !1, className: n, onClick: s, onKe
|
|
|
277
277
|
endIcon: x,
|
|
278
278
|
surface: g,
|
|
279
279
|
...I,
|
|
280
|
-
...
|
|
280
|
+
...A,
|
|
281
281
|
children: t
|
|
282
282
|
}
|
|
283
283
|
)
|
|
@@ -287,8 +287,8 @@ function je({ children: e, align: r = "start", offset: n = 4, className: s, ...a
|
|
|
287
287
|
const t = C("MenuItems"), { mounted: d, closed: o, leaving: u } = te(t.open), p = i.useRef(null), f = z(t.triggerEl), { setPanel: m, panelEl: l, floatingStyles: b, placement: x, isPositioned: g } = re(t.triggerEl, d, `bottom-${r}`, n, p), I = ae(), { typedRef: h, typingAhead: P } = oe(), M = se({ panelRef: p, typedRef: h, onEscape: () => t.close(!0) });
|
|
288
288
|
i.useLayoutEffect(() => {
|
|
289
289
|
if (!t.open || !l) return;
|
|
290
|
-
const v =
|
|
291
|
-
k === "first" && v[0] ?
|
|
290
|
+
const v = D(l), k = t.focusOnOpen.current;
|
|
291
|
+
k === "first" && v[0] ? E(v[0]) : k === "last" && v.length ? E(v[v.length - 1]) : l.focus({ preventScroll: !0 });
|
|
292
292
|
}, [t.open, l, t.focusOnOpen]), i.useLayoutEffect(() => {
|
|
293
293
|
if (!g || !l) return;
|
|
294
294
|
const v = document.activeElement;
|
|
@@ -296,7 +296,7 @@ function je({ children: e, align: r = "start", offset: n = 4, className: s, ...a
|
|
|
296
296
|
}, [g, l]), i.useLayoutEffect(() => {
|
|
297
297
|
!t.open && l?.contains(document.activeElement) && t.triggerRef.current?.focus({ preventScroll: !0 });
|
|
298
298
|
}, [t.open, l, t.triggerRef]);
|
|
299
|
-
const
|
|
299
|
+
const A = (v) => {
|
|
300
300
|
const k = v.relatedTarget;
|
|
301
301
|
k && !k.closest(`[data-menu-tree="${t.treeId}"]`) && t.close(!1);
|
|
302
302
|
};
|
|
@@ -317,9 +317,9 @@ function je({ children: e, align: r = "start", offset: n = 4, className: s, ...a
|
|
|
317
317
|
"data-closed": o ? "" : void 0,
|
|
318
318
|
"data-leaving": u ? "" : void 0,
|
|
319
319
|
onKeyDown: M,
|
|
320
|
-
onBlur:
|
|
320
|
+
onBlur: A,
|
|
321
321
|
style: { ...b, ...Q, transformOrigin: Z(x, f) },
|
|
322
|
-
className:
|
|
322
|
+
className: S(y && "dark", ee, s),
|
|
323
323
|
children: e
|
|
324
324
|
}
|
|
325
325
|
) }) });
|
|
@@ -337,19 +337,26 @@ function ae() {
|
|
|
337
337
|
}
|
|
338
338
|
};
|
|
339
339
|
}
|
|
340
|
-
const O = /* @__PURE__ */
|
|
340
|
+
const O = /* @__PURE__ */ S(
|
|
341
341
|
/* A button or a link reset to a row: no border, no fill, the panel's type. */
|
|
342
342
|
"rst:relative rst:flex rst:w-full rst:min-h-11 rst:items-center rst:gap-2.5 rst:border-0 rst:bg-transparent rst:px-3 rst:py-2 rst:text-start rst:text-sm rst:text-inherit rst:no-underline rst:[font-family:inherit] rst:cursor-pointer rst:select-none rst:outline-none rst:transition-colors",
|
|
343
343
|
/* Focus follows the pointer, so the highlight is focus. In forced colors a
|
|
344
344
|
fill is dropped, so focus draws an outline there instead. */
|
|
345
345
|
"rst:focus:bg-primary-100 rst:focus:text-primary-900 rst:dark:focus:bg-primary-900/30 rst:dark:focus:text-primary-100 rst:forced-colors:focus:outline-solid rst:forced-colors:focus:outline-2 rst:forced-colors:focus:-outline-offset-2",
|
|
346
|
+
/* The tint alone isn't a focus indicator: it measures under 1.2:1 against
|
|
347
|
+
the panel in both themes, on the default surface and a consumer's. So
|
|
348
|
+
keyboard focus adds an inset ring in the focus token, which a consumer
|
|
349
|
+
tunes against their own surfaces, and holds 3:1 on any of them. The
|
|
350
|
+
pointer's focus is the tint alone: the ring follows the mark `focusItem`
|
|
351
|
+
leaves, which only the keyboard's paths set. */
|
|
352
|
+
"rst:data-key-focus:ring-2 rst:data-key-focus:ring-inset rst:data-key-focus:ring-ring",
|
|
346
353
|
"rst:aria-disabled:opacity-50 rst:aria-disabled:cursor-not-allowed"
|
|
347
|
-
), H = "rst:text-error-600 rst:dark:text-error-400 rst:focus:bg-error-50 rst:focus:text-error-700 rst:dark:focus:bg-error-900/30 rst:dark:focus:text-error-300",
|
|
348
|
-
function
|
|
354
|
+
), H = "rst:text-error-600 rst:dark:text-error-400 rst:focus:bg-error-50 rst:focus:text-error-700 rst:dark:focus:bg-error-900/30 rst:dark:focus:text-error-300", Re = () => /* @__PURE__ */ c("svg", { viewBox: "0 0 16 16", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ c("path", { d: "M3.5 8.5 6.5 11.5 12.5 4.5" }) }), De = () => /* @__PURE__ */ c("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", children: /* @__PURE__ */ c("circle", { cx: "8", cy: "8", r: "3.5", fill: "currentColor" }) }), Ne = () => /* @__PURE__ */ c("svg", { viewBox: "0 0 16 16", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", className: "rst:rtl:rotate-180", children: /* @__PURE__ */ c("path", { d: "M6 3.5 10.5 8 6 12.5" }) });
|
|
355
|
+
function T({ icon: e, shortcut: r, description: n, badge: s, children: a }, t, d, o) {
|
|
349
356
|
const u = t ?? e;
|
|
350
357
|
return /* @__PURE__ */ N(j, { children: [
|
|
351
358
|
u != null && /* With a description, the icon lines up with the label, not the middle of both lines. */
|
|
352
|
-
/* @__PURE__ */ c("span", { "aria-hidden": "true", className:
|
|
359
|
+
/* @__PURE__ */ c("span", { "aria-hidden": "true", className: S("rst:flex rst:size-4 rst:shrink-0 rst:items-center rst:justify-center", n != null && "rst:self-start rst:mt-0.5"), "data-menu-lead": "", children: u }),
|
|
353
360
|
/* @__PURE__ */ N("span", { className: "rst:min-w-0 rst:flex-1 rst:break-words", "data-menu-label": "", children: [
|
|
354
361
|
a,
|
|
355
362
|
n != null && /* @__PURE__ */ c("span", { id: o, "aria-hidden": "true", className: "rst:block rst:text-xs rst:opacity-75", "data-menu-description": "", children: n })
|
|
@@ -386,7 +393,7 @@ function F({
|
|
|
386
393
|
};
|
|
387
394
|
}
|
|
388
395
|
function qe({ onSelect: e, href: r, closeOnSelect: n = !0, disabled: s, destructive: a, keyshortcuts: t, textValue: d, className: o, ...u }) {
|
|
389
|
-
const p = C("MenuItem"), f = _("MenuItem"), m = i.useId(), l = F({ disabled: s, closeOnSelect: n, onChoose: (g) => e?.(g) }), b =
|
|
396
|
+
const p = C("MenuItem"), f = _("MenuItem"), m = i.useId(), l = F({ disabled: s, closeOnSelect: n, onChoose: (g) => e?.(g) }), b = S(O, a && H, o), x = {
|
|
390
397
|
role: "menuitem",
|
|
391
398
|
tabIndex: -1,
|
|
392
399
|
"aria-disabled": s ? !0 : void 0,
|
|
@@ -413,11 +420,11 @@ function qe({ onSelect: e, href: r, closeOnSelect: n = !0, disabled: s, destruct
|
|
|
413
420
|
I.preventDefault(), s || I.currentTarget.click();
|
|
414
421
|
}
|
|
415
422
|
},
|
|
416
|
-
children:
|
|
423
|
+
children: T(u, void 0, void 0, m)
|
|
417
424
|
}
|
|
418
425
|
);
|
|
419
426
|
}
|
|
420
|
-
return /* @__PURE__ */ c("button", { type: "button", className: b, ...x, ...l, children:
|
|
427
|
+
return /* @__PURE__ */ c("button", { type: "button", className: b, ...x, ...l, children: T(u, void 0, void 0, m) });
|
|
421
428
|
}
|
|
422
429
|
function Ge({ checked: e, onCheckedChange: r, indicator: n, closeOnSelect: s = !0, disabled: a, destructive: t, keyshortcuts: d, textValue: o, className: u, ...p }) {
|
|
423
430
|
const f = F({ disabled: a, closeOnSelect: s, spaceKeepsOpen: !0, onChoose: () => r(!e) }), m = i.useId();
|
|
@@ -433,9 +440,9 @@ function Ge({ checked: e, onCheckedChange: r, indicator: n, closeOnSelect: s = !
|
|
|
433
440
|
"aria-keyshortcuts": d,
|
|
434
441
|
"data-menu-item": "",
|
|
435
442
|
"data-menu-text": o,
|
|
436
|
-
className:
|
|
443
|
+
className: S(O, t && H, u),
|
|
437
444
|
...f,
|
|
438
|
-
children: n === void 0 ?
|
|
445
|
+
children: n === void 0 ? T(p, /* @__PURE__ */ c("span", { className: e ? void 0 : "rst:invisible", "data-menu-check": "", children: /* @__PURE__ */ c(Re, {}) }), void 0, m) : T(p, void 0, /* @__PURE__ */ c("span", { "aria-hidden": "true", className: "rst:ms-auto rst:flex rst:shrink-0 rst:items-center", children: n }), m)
|
|
439
446
|
}
|
|
440
447
|
);
|
|
441
448
|
}
|
|
@@ -458,9 +465,9 @@ function Xe({ value: e, closeOnSelect: r = !0, disabled: n, destructive: s, keys
|
|
|
458
465
|
"aria-keyshortcuts": a,
|
|
459
466
|
"data-menu-item": "",
|
|
460
467
|
"data-menu-text": t,
|
|
461
|
-
className:
|
|
468
|
+
className: S(O, s && H, d),
|
|
462
469
|
...f,
|
|
463
|
-
children:
|
|
470
|
+
children: T(o, /* @__PURE__ */ c("span", { className: p ? void 0 : "rst:invisible", "data-menu-check": "", children: /* @__PURE__ */ c(De, {}) }), void 0, m)
|
|
464
471
|
}
|
|
465
472
|
);
|
|
466
473
|
}
|
|
@@ -480,14 +487,14 @@ function Oe({ label: e, children: r, className: n }) {
|
|
|
480
487
|
] });
|
|
481
488
|
}
|
|
482
489
|
function Je({ className: e }) {
|
|
483
|
-
return /* @__PURE__ */ c("div", { role: "separator", className:
|
|
490
|
+
return /* @__PURE__ */ c("div", { role: "separator", className: S("rst:my-1 rst:h-[var(--roster-border-width,1px)] rst:bg-[var(--roster-popover-border)]", e) });
|
|
484
491
|
}
|
|
485
492
|
function Qe({ label: e, children: r, icon: n, disabled: s, textValue: a, className: t, panelClassName: d }) {
|
|
486
493
|
const o = C("MenuSubmenu"), u = _("MenuSubmenu"), p = i.useId(), f = `${p}-item`, m = `${p}-menu`, l = u.openSubmenu === f, b = i.useRef(null), [x, g] = i.useState(null), I = i.useCallback((w) => {
|
|
487
494
|
b.current = w, g(w);
|
|
488
|
-
}, []), h = i.useRef(null), P = i.useRef(void 0), M = i.useRef("mouse"), { mounted:
|
|
495
|
+
}, []), h = i.useRef(null), P = i.useRef(void 0), M = i.useRef("mouse"), { mounted: A, closed: y, leaving: v } = te(l), k = z(x), { setPanel: L, panelEl: K, floatingStyles: ie, placement: ue } = re(
|
|
489
496
|
x,
|
|
490
|
-
|
|
497
|
+
A,
|
|
491
498
|
k ? "left-start" : "right-start",
|
|
492
499
|
{ mainAxis: 0, alignmentAxis: -4 },
|
|
493
500
|
h,
|
|
@@ -495,15 +502,15 @@ function Qe({ label: e, children: r, icon: n, disabled: s, textValue: a, classNa
|
|
|
495
502
|
), ce = ae();
|
|
496
503
|
i.useEffect(() => () => window.clearTimeout(P.current), []);
|
|
497
504
|
const W = () => {
|
|
498
|
-
u.setOpenSubmenu(null), b.current
|
|
505
|
+
u.setOpenSubmenu(null), E(b.current);
|
|
499
506
|
}, { typedRef: le, typingAhead: de } = oe(), me = se({ panelRef: h, typedRef: le, onEscape: W, onBack: W });
|
|
500
507
|
i.useLayoutEffect(() => {
|
|
501
|
-
!l || !K || u.focusFirstInSubmenu.current &&
|
|
508
|
+
!l || !K || u.focusFirstInSubmenu.current && E(D(K)[0]);
|
|
502
509
|
}, [l, K, u.focusFirstInSubmenu]);
|
|
503
510
|
const $ = (w) => {
|
|
504
511
|
if (!s) {
|
|
505
512
|
if (l && w && h.current) {
|
|
506
|
-
|
|
513
|
+
E(D(h.current)[0]);
|
|
507
514
|
return;
|
|
508
515
|
}
|
|
509
516
|
u.setOpenSubmenu(f, w);
|
|
@@ -525,7 +532,7 @@ function Qe({ label: e, children: r, icon: n, disabled: s, textValue: a, classNa
|
|
|
525
532
|
"data-menu-item": "",
|
|
526
533
|
"data-menu-text": a,
|
|
527
534
|
"data-menu-tree": o.treeId,
|
|
528
|
-
className:
|
|
535
|
+
className: S(O, l && "rst:bg-gray-100 rst:dark:bg-gray-700/50", t),
|
|
529
536
|
onPointerDown: (w) => {
|
|
530
537
|
M.current = w.pointerType;
|
|
531
538
|
},
|
|
@@ -538,13 +545,13 @@ function Qe({ label: e, children: r, icon: n, disabled: s, textValue: a, classNa
|
|
|
538
545
|
J(w) && (u.hoverItem(f), document.activeElement !== w.currentTarget && w.currentTarget.focus({ preventScroll: !0 }), !l && !s && (window.clearTimeout(P.current), P.current = window.setTimeout(() => $(!1), X)));
|
|
539
546
|
},
|
|
540
547
|
onPointerLeave: () => window.clearTimeout(P.current),
|
|
541
|
-
children:
|
|
548
|
+
children: T({ icon: n, children: e }, void 0, /* @__PURE__ */ c("span", { "aria-hidden": "true", className: "rst:ms-auto rst:flex rst:shrink-0 rst:items-center rst:opacity-70", "data-menu-chevron": "", children: /* @__PURE__ */ c(Ne, {}) }))
|
|
542
549
|
}
|
|
543
550
|
),
|
|
544
|
-
|
|
551
|
+
A && /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(B.Provider, { value: { ...ce, panelRef: h, typingAhead: de }, children: /* @__PURE__ */ c(
|
|
545
552
|
"div",
|
|
546
553
|
{
|
|
547
|
-
ref:
|
|
554
|
+
ref: L,
|
|
548
555
|
id: m,
|
|
549
556
|
dir: k ? "rtl" : "ltr",
|
|
550
557
|
role: "menu",
|
|
@@ -557,7 +564,7 @@ function Qe({ label: e, children: r, icon: n, disabled: s, textValue: a, classNa
|
|
|
557
564
|
onKeyDown: me,
|
|
558
565
|
onPointerEnter: () => u.hoverItem(f),
|
|
559
566
|
style: { ...ie, ...Q, transformOrigin: Z(ue, k) },
|
|
560
|
-
className:
|
|
567
|
+
className: S(fe && "dark", ee, d),
|
|
561
568
|
children: r
|
|
562
569
|
}
|
|
563
570
|
) }) })
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),d=require("react"),G=require("../../../lib/utils.cjs"),ge=require("../../../lib/labels.cjs"),J=require("../../../internal/field-invalid.cjs"),l=require("../Slider/track.cjs"),h=require("../Slider/track-parts.cjs"),ve={low:"Minimum",high:"Maximum",valueText:(s,i)=>i?`${s}, ${i}`:s,range:(s,i)=>`${s} – ${i}`},he=([s,i])=>s<=i?[s,i]:[i,s];function pe({value:s,defaultValue:i,onChange:Q,onCommit:B,min:g=0,max:v=100,step:M=1,pageStep:U,snapPoints:W=[],label:P,helperText:T,errorMessage:R,disabled:a=!1,name:p,formatValue:b=String,labels:X,className:Y,trackClassName:Z,thumbClassName:_,chipClassName:V,labelClassName:ee,messageClassName:te,"aria-invalid":ne,"aria-labelledby":re,"aria-describedby":se,...C}){const j=ge.withLabels(ve,X),x=d.useId(),F=`${x}-label`,N=`${x}-message`,w=[`${x}-low`,`${x}-high`],S=re??(P?F:void 0),c=l.useScale(g,v,M,U),m=s!==void 0,[O,L]=d.useState(i??[g,v]),D=m?s:O,r=he([c.clamp(D[0]),c.clamp(D[1])]),ie=J.isFieldInvalid(!!R,{...C,"aria-invalid":ne}),K=J.withoutInvalidProps(C),f=l.useCommitted(r),[,ae]=d.useReducer(e=>e+1,0),k=(e,t,o)=>{const u=f.current,q=e===0?Math.min(t,u[1]):Math.max(t,u[0]);if(q===u[e])return;const y=e===0?[q,u[1]]:[u[0],q];f.current=y,m?ae():L(y),Q?.(y),o&&B?.(y)},z=d.useRef(null),A=d.useRef(O);l.useFormReset(z,m,()=>{f.current=A.current,L(A.current)},p);const E=d.useRef(null),H=[d.useRef(null),d.useRef(null)],{dragging:I,rtl:le,handlers:oe}=l.useTrackPress({trackRef:E,disabled:a,scale:c,min:g,max:v,values:()=>f.current,set:k,focus:e=>H[e].current?.focus({preventScroll:!0}),commit:()=>B?.(f.current),own:{down:void 0,move:void 0,up:void 0,cancel:void 0,lost:void 0}}),ce=e=>t=>{if(a)return;const o=f.current,u=l.keyTarget(t,o[e],{scale:c,step:M,start:o[e],floor:e===0?g:o[0],ceiling:e===0?o[1]:v,rtl:le()});u!==void 0&&(t.preventDefault(),k(e,u,!0))},ue=e=>{const[t,o]=f.current;k(e<=t?0:e>=o?1:e-t<=o-e?0:1,e,!0)},$=l.inRange(W,g,v),de=[T||R?N:void 0,se].filter(Boolean).join(" ")||void 0,fe="rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background";return n.jsxs("div",{...K,role:"group","aria-labelledby":S,className:G.cn("rst:font-ui rst:flex rst:min-w-0 rst:flex-col rst:gap-1.5",Y),"data-range-slider":"",children:[n.jsx(h.SliderHeader,{labelId:F,label:P,readout:j.range(b(r[0]),b(r[1])),empty:!1,disabled:a,labelClassName:ee}),n.jsx("span",{id:w[0],hidden:!0,children:j.low}),n.jsx("span",{id:w[1],hidden:!0,children:j.high}),n.jsxs("div",{...oe,ref:E,"data-dragging":I?"":void 0,className:G.cn(l.trackClasses(a),Z),children:[n.jsx(h.Rail,{}),n.jsx(h.Fill,{from:c.at(r[0]),to:c.at(r[1]),dragging:I}),n.jsx(h.Marks,{points:$,at:c.at,filled:e=>e>=r[0]&&e<=r[1]}),r.map((e,t)=>n.jsx("span",{ref:H[t],role:"slider",tabIndex:a?void 0:0,"aria-labelledby":[S,w[t]].filter(Boolean).join(" "),"aria-describedby":de,"aria-valuemin":t===0?g:r[0],"aria-valuemax":t===0?r[1]:v,"aria-valuenow":e,"aria-valuetext":j.valueText(b(e),l.nearestPoint($,e)?.label),"aria-orientation":"horizontal","aria-disabled":a||void 0,"aria-invalid":ie||void 0,"data-slider-thumb":t===0?"low":"high",onKeyDown:ce(t),className:l.thumbClasses(I,fe,_),style:{insetInlineStart:l.along(c.at(e))}},t))]}),n.jsx(h.SnapChips,{points:$,labelledBy:S,label:K["aria-label"],pressed:e=>e===r[0]||e===r[1],pick:ue,disabled:a,chipClassName:V}),n.jsx(h.Message,{id:N,helperText:T,errorMessage:R,disabled:a,className:te}),p&&n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:z,type:"hidden",name:p,value:String(r[0]),disabled:a,readOnly:!0}),n.jsx("input",{type:"hidden",name:p,value:String(r[1]),disabled:a,readOnly:!0})]})]})}exports.RangeSlider=pe;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import { SliderSnapPoint } from '../Slider/track';
|
|
3
|
+
/** A range's two values, low then high. */
|
|
4
|
+
export type RangeValue = [number, number];
|
|
5
|
+
/** Every word RangeSlider says. Pass any of them in `labels` to replace it. */
|
|
6
|
+
export interface RangeSliderLabels {
|
|
7
|
+
/** The low thumb's name, heard after the slider's label: "Price Minimum". */
|
|
8
|
+
low: string;
|
|
9
|
+
/** The high thumb's name. */
|
|
10
|
+
high: string;
|
|
11
|
+
/** What a screen reader hears for a thumb's value, with the nearest snap point's label when there is one: "40, Likely". */
|
|
12
|
+
valueText: (value: string, nearest: string | undefined) => string;
|
|
13
|
+
/** The number shown beside the label, both values in one: "20 – 80". */
|
|
14
|
+
range: (low: string, high: string) => string;
|
|
15
|
+
}
|
|
16
|
+
export interface RangeSliderProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue"> {
|
|
17
|
+
/** The two values, low then high. Pass it to control the slider; leave it out for one that starts from `defaultValue`. */
|
|
18
|
+
value?: RangeValue;
|
|
19
|
+
/** Where an uncontrolled slider starts. The whole range, `[min, max]`, by default. */
|
|
20
|
+
defaultValue?: RangeValue;
|
|
21
|
+
/** Each change: a tap, every step of a drag, a key, a snap point. */
|
|
22
|
+
onChange?: (value: RangeValue) => void;
|
|
23
|
+
/** Once a change is finished: a tap, the end of a drag, a key, a snap point. */
|
|
24
|
+
onCommit?: (value: RangeValue) => void;
|
|
25
|
+
/** The lowest value. */
|
|
26
|
+
min?: number;
|
|
27
|
+
/** The highest value. */
|
|
28
|
+
max?: number;
|
|
29
|
+
/** The smallest move: the arrows step by it, and every value lands on it. */
|
|
30
|
+
step?: number;
|
|
31
|
+
/** PageUp and PageDown's move. A tenth of the range, on a step, by default. */
|
|
32
|
+
pageStep?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Named stops, any values and labels. Each gets a mark on the track and a
|
|
35
|
+
* chip under it, which does what a tap on its mark does: moves the nearer
|
|
36
|
+
* thumb there. A point outside `min` to `max` is left out.
|
|
37
|
+
*/
|
|
38
|
+
snapPoints?: SliderSnapPoint[];
|
|
39
|
+
/** The slider's name, shown above the track. */
|
|
40
|
+
label?: string;
|
|
41
|
+
/** Supporting text under the slider. */
|
|
42
|
+
helperText?: string;
|
|
43
|
+
/** The message for an invalid value. Implies the error state. */
|
|
44
|
+
errorMessage?: string;
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
/** A form field name: both values are submitted under it, low then high, as a multiple select's are. */
|
|
47
|
+
name?: string;
|
|
48
|
+
/** How a value is written, in the readout and in what's said. */
|
|
49
|
+
formatValue?: (value: number) => string;
|
|
50
|
+
/** Every word the slider says, with English defaults. */
|
|
51
|
+
labels?: Partial<RangeSliderLabels>;
|
|
52
|
+
/** Classes for the track, the pointer's hit area. */
|
|
53
|
+
trackClassName?: string;
|
|
54
|
+
/** Classes for each thumb. */
|
|
55
|
+
thumbClassName?: string;
|
|
56
|
+
/** Classes for each snap chip. */
|
|
57
|
+
chipClassName?: string;
|
|
58
|
+
/** Classes for the label. */
|
|
59
|
+
labelClassName?: string;
|
|
60
|
+
/** Classes for the helper text or error message. */
|
|
61
|
+
messageClassName?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Two values picked along one track, a low and a high: tapped, dragged,
|
|
65
|
+
* stepped with the keys, or set from a named snap point.
|
|
66
|
+
*
|
|
67
|
+
* Each thumb is a slider of its own to a screen reader and the keyboard, a
|
|
68
|
+
* tab stop named for the slider and for its end ("Price Minimum"), whose
|
|
69
|
+
* range runs to the other thumb: the thumbs meet, and never cross. The track
|
|
70
|
+
* takes a press for the nearer thumb. It starts at the whole range, and has
|
|
71
|
+
* no not-set state: the whole range is what "any" looks like.
|
|
72
|
+
*/
|
|
73
|
+
declare function RangeSlider({ value: controlled, defaultValue, onChange, onCommit, min, max, step, pageStep, snapPoints, label, helperText, errorMessage, disabled, name, formatValue, labels: overrides, className, trackClassName, thumbClassName, chipClassName, labelClassName, messageClassName, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...props }: RangeSliderProps): import("react/jsx-runtime").JSX.Element;
|
|
74
|
+
export { RangeSlider };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as B, jsx as i, Fragment as ue } from "react/jsx-runtime";
|
|
3
|
+
import { useId as fe, useState as ge, useReducer as ve, useRef as g } from "react";
|
|
4
|
+
import { cn as q } from "../../../lib/utils.js";
|
|
5
|
+
import { withLabels as pe } from "../../../lib/labels.js";
|
|
6
|
+
import { isFieldInvalid as he, withoutInvalidProps as me } from "../../../internal/field-invalid.js";
|
|
7
|
+
import { useScale as we, useCommitted as ye, useFormReset as be, useTrackPress as Se, inRange as Re, along as $e, thumbClasses as ke, nearestPoint as Ie, trackClasses as xe, keyTarget as Be } from "../Slider/track.js";
|
|
8
|
+
import { SliderHeader as je, Rail as Ce, Fill as Fe, Marks as Me, SnapChips as Ne, Message as Te } from "../Slider/track-parts.js";
|
|
9
|
+
const Le = {
|
|
10
|
+
low: "Minimum",
|
|
11
|
+
high: "Maximum",
|
|
12
|
+
valueText: (n, o) => o ? `${n}, ${o}` : n,
|
|
13
|
+
range: (n, o) => `${n} – ${o}`
|
|
14
|
+
}, Oe = ([n, o]) => n <= o ? [n, o] : [o, n];
|
|
15
|
+
function qe({
|
|
16
|
+
value: n,
|
|
17
|
+
defaultValue: o,
|
|
18
|
+
onChange: G,
|
|
19
|
+
onCommit: j,
|
|
20
|
+
min: u = 0,
|
|
21
|
+
max: f = 100,
|
|
22
|
+
step: C = 1,
|
|
23
|
+
pageStep: J,
|
|
24
|
+
snapPoints: Q = [],
|
|
25
|
+
label: F,
|
|
26
|
+
helperText: M,
|
|
27
|
+
errorMessage: w,
|
|
28
|
+
disabled: s = !1,
|
|
29
|
+
name: v,
|
|
30
|
+
formatValue: y = String,
|
|
31
|
+
labels: U,
|
|
32
|
+
className: W,
|
|
33
|
+
trackClassName: X,
|
|
34
|
+
thumbClassName: Y,
|
|
35
|
+
chipClassName: Z,
|
|
36
|
+
labelClassName: _,
|
|
37
|
+
messageClassName: V,
|
|
38
|
+
"aria-invalid": ee,
|
|
39
|
+
"aria-labelledby": re,
|
|
40
|
+
"aria-describedby": te,
|
|
41
|
+
...N
|
|
42
|
+
}) {
|
|
43
|
+
const p = pe(Le, U), h = fe(), T = `${h}-label`, L = `${h}-message`, b = [`${h}-low`, `${h}-high`], S = re ?? (F ? T : void 0), l = we(u, f, C, J), R = n !== void 0, [O, P] = ge(o ?? [u, f]), D = R ? n : O, t = Oe([l.clamp(D[0]), l.clamp(D[1])]), ne = he(!!w, { ...N, "aria-invalid": ee }), K = me(N), d = ye(t), [, ie] = ve((e) => e + 1, 0), $ = (e, r, a) => {
|
|
44
|
+
const c = d.current, x = e === 0 ? Math.min(r, c[1]) : Math.max(r, c[0]);
|
|
45
|
+
if (x === c[e]) return;
|
|
46
|
+
const m = e === 0 ? [x, c[1]] : [c[0], x];
|
|
47
|
+
d.current = m, R ? ie() : P(m), G?.(m), a && j?.(m);
|
|
48
|
+
}, z = g(null), A = g(O);
|
|
49
|
+
be(
|
|
50
|
+
z,
|
|
51
|
+
R,
|
|
52
|
+
() => {
|
|
53
|
+
d.current = A.current, P(A.current);
|
|
54
|
+
},
|
|
55
|
+
v
|
|
56
|
+
);
|
|
57
|
+
const E = g(null), H = [g(null), g(null)], { dragging: k, rtl: oe, handlers: se } = Se({
|
|
58
|
+
trackRef: E,
|
|
59
|
+
disabled: s,
|
|
60
|
+
scale: l,
|
|
61
|
+
min: u,
|
|
62
|
+
max: f,
|
|
63
|
+
values: () => d.current,
|
|
64
|
+
set: $,
|
|
65
|
+
focus: (e) => H[e].current?.focus({ preventScroll: !0 }),
|
|
66
|
+
commit: () => j?.(d.current),
|
|
67
|
+
own: { down: void 0, move: void 0, up: void 0, cancel: void 0, lost: void 0 }
|
|
68
|
+
}), ae = (e) => (r) => {
|
|
69
|
+
if (s) return;
|
|
70
|
+
const a = d.current, c = Be(r, a[e], {
|
|
71
|
+
scale: l,
|
|
72
|
+
step: C,
|
|
73
|
+
start: a[e],
|
|
74
|
+
floor: e === 0 ? u : a[0],
|
|
75
|
+
ceiling: e === 0 ? a[1] : f,
|
|
76
|
+
rtl: oe()
|
|
77
|
+
});
|
|
78
|
+
c !== void 0 && (r.preventDefault(), $(e, c, !0));
|
|
79
|
+
}, le = (e) => {
|
|
80
|
+
const [r, a] = d.current;
|
|
81
|
+
$(e <= r ? 0 : e >= a ? 1 : e - r <= a - e ? 0 : 1, e, !0);
|
|
82
|
+
}, I = Re(Q, u, f), ce = [M || w ? L : void 0, te].filter(Boolean).join(" ") || void 0, de = "rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background";
|
|
83
|
+
return /* @__PURE__ */ B(
|
|
84
|
+
"div",
|
|
85
|
+
{
|
|
86
|
+
...K,
|
|
87
|
+
role: "group",
|
|
88
|
+
"aria-labelledby": S,
|
|
89
|
+
className: q("rst:font-ui rst:flex rst:min-w-0 rst:flex-col rst:gap-1.5", W),
|
|
90
|
+
"data-range-slider": "",
|
|
91
|
+
children: [
|
|
92
|
+
/* @__PURE__ */ i(
|
|
93
|
+
je,
|
|
94
|
+
{
|
|
95
|
+
labelId: T,
|
|
96
|
+
label: F,
|
|
97
|
+
readout: p.range(y(t[0]), y(t[1])),
|
|
98
|
+
empty: !1,
|
|
99
|
+
disabled: s,
|
|
100
|
+
labelClassName: _
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
/* @__PURE__ */ i("span", { id: b[0], hidden: !0, children: p.low }),
|
|
104
|
+
/* @__PURE__ */ i("span", { id: b[1], hidden: !0, children: p.high }),
|
|
105
|
+
/* @__PURE__ */ B(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
...se,
|
|
109
|
+
ref: E,
|
|
110
|
+
"data-dragging": k ? "" : void 0,
|
|
111
|
+
className: q(xe(s), X),
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ i(Ce, {}),
|
|
114
|
+
/* @__PURE__ */ i(Fe, { from: l.at(t[0]), to: l.at(t[1]), dragging: k }),
|
|
115
|
+
/* @__PURE__ */ i(Me, { points: I, at: l.at, filled: (e) => e >= t[0] && e <= t[1] }),
|
|
116
|
+
t.map((e, r) => /* @__PURE__ */ i(
|
|
117
|
+
"span",
|
|
118
|
+
{
|
|
119
|
+
ref: H[r],
|
|
120
|
+
role: "slider",
|
|
121
|
+
tabIndex: s ? void 0 : 0,
|
|
122
|
+
"aria-labelledby": [S, b[r]].filter(Boolean).join(" "),
|
|
123
|
+
"aria-describedby": ce,
|
|
124
|
+
"aria-valuemin": r === 0 ? u : t[0],
|
|
125
|
+
"aria-valuemax": r === 0 ? t[1] : f,
|
|
126
|
+
"aria-valuenow": e,
|
|
127
|
+
"aria-valuetext": p.valueText(y(e), Ie(I, e)?.label),
|
|
128
|
+
"aria-orientation": "horizontal",
|
|
129
|
+
"aria-disabled": s || void 0,
|
|
130
|
+
"aria-invalid": ne || void 0,
|
|
131
|
+
"data-slider-thumb": r === 0 ? "low" : "high",
|
|
132
|
+
onKeyDown: ae(r),
|
|
133
|
+
className: ke(k, de, Y),
|
|
134
|
+
style: { insetInlineStart: $e(l.at(e)) }
|
|
135
|
+
},
|
|
136
|
+
r
|
|
137
|
+
))
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ i(
|
|
142
|
+
Ne,
|
|
143
|
+
{
|
|
144
|
+
points: I,
|
|
145
|
+
labelledBy: S,
|
|
146
|
+
label: K["aria-label"],
|
|
147
|
+
pressed: (e) => e === t[0] || e === t[1],
|
|
148
|
+
pick: le,
|
|
149
|
+
disabled: s,
|
|
150
|
+
chipClassName: Z
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
/* @__PURE__ */ i(Te, { id: L, helperText: M, errorMessage: w, disabled: s, className: V }),
|
|
154
|
+
v && /* @__PURE__ */ B(ue, { children: [
|
|
155
|
+
/* @__PURE__ */ i("input", { ref: z, type: "hidden", name: v, value: String(t[0]), disabled: s, readOnly: !0 }),
|
|
156
|
+
/* @__PURE__ */ i("input", { type: "hidden", name: v, value: String(t[1]), disabled: s, readOnly: !0 })
|
|
157
|
+
] })
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
export {
|
|
163
|
+
qe as RangeSlider
|
|
164
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),c=require("react"),z=require("../../../lib/utils.cjs"),be=require("../../../lib/labels.cjs"),A=require("../../../internal/field-invalid.cjs"),s=require("./track.cjs"),d=require("./track-parts.cjs"),pe={notSet:"Not set",valueText:(v,f)=>f?`${v}, ${f}`:v};function ye({value:v,defaultValue:f,onChange:E,onCommit:m,min:i=0,max:o=100,step:x=1,pageStep:H,startValue:M,snapPoints:_=[],label:I,helperText:q,errorMessage:g,disabled:n=!1,name:b,formatValue:G=String,labels:J,className:Q,trackClassName:U,thumbClassName:W,chipClassName:X,labelClassName:Y,messageClassName:Z,"aria-invalid":V,"aria-labelledby":ee,onKeyDown:te,onPointerDown:re,onPointerMove:se,onPointerUp:ne,onPointerCancel:ie,onLostPointerCapture:le,...p}){const y=be.withLabels(pe,J),N=c.useId(),P=`${N}-label`,B=`${N}-message`,C=ee??(I?P:void 0),l=s.useScale(i,o,x,H),T=l.snap(M??i+(o-i)/2),S=v!==void 0,[$,D]=c.useState(f===void 0?T:f),F=S?v:$,t=F===null?null:l.clamp(F),ae=A.isFieldInvalid(!!g,{...p,"aria-invalid":V}),L=A.withoutInvalidProps(p),a=s.useCommitted(t),[,oe]=c.useReducer(e=>e+1,0),j=(e,u)=>{e!==a.current&&(a.current=e,S?oe():D(e),E?.(e),u&&e!==null&&m?.(e))},O=c.useRef(null),K=c.useRef($);s.useFormReset(O,S,()=>{a.current=K.current,D(K.current)},b);const h=c.useRef(null),{dragging:R,rtl:ue,handlers:ce}=s.useTrackPress({trackRef:h,disabled:n,scale:l,min:i,max:o,values:()=>[a.current],set:(e,u,ge)=>j(u,ge),focus:()=>h.current?.focus({preventScroll:!0}),commit:()=>a.current!==null&&m?.(a.current),own:{down:re,move:se,up:ne,cancel:ie,lost:le}}),de=e=>{if(te?.(e),n)return;const u=s.keyTarget(e,a.current,{scale:l,step:x,start:T,floor:i,ceiling:o,rtl:ue()});u!==void 0&&(e.preventDefault(),j(u,!0))},w=s.inRange(_,i,o),k=t===null?null:G(t),ve=k===null?y.notSet:y.valueText(k,s.nearestPoint(w,t)?.label),fe=[q||g?B:void 0,p["aria-describedby"]].filter(Boolean).join(" ")||void 0;return r.jsxs("div",{className:z.cn("rst:font-ui rst:flex rst:min-w-0 rst:flex-col rst:gap-1.5",Q),"data-slider":"",children:[r.jsx(d.SliderHeader,{labelId:P,label:I,readout:k??y.notSet,empty:t===null,disabled:n,labelClassName:Y}),r.jsxs("div",{...L,...ce,ref:h,role:"slider",tabIndex:n?void 0:0,"aria-labelledby":C,"aria-describedby":fe,"aria-valuemin":i,"aria-valuemax":o,"aria-valuenow":t??void 0,"aria-valuetext":ve,"aria-orientation":"horizontal","aria-disabled":n||void 0,"aria-invalid":ae||void 0,"data-dragging":R?"":void 0,"data-empty":t===null?"":void 0,onKeyDown:de,className:z.cn(s.trackClasses(n),"rst:group/slider rst:focus-visible:outline-hidden",t===null&&"rst:focus-visible:ring-2 rst:focus-visible:ring-ring",U),children:[r.jsx(d.Rail,{}),t!==null&&r.jsx(d.Fill,{from:0,to:l.at(t),dragging:R}),r.jsx(d.Marks,{points:w,at:l.at,filled:e=>t!==null&&t>=e}),t!==null&&r.jsx("span",{"aria-hidden":"true","data-slider-thumb":"",className:s.thumbClasses(R,"rst:group-focus-visible/slider:ring-2 rst:group-focus-visible/slider:ring-ring rst:group-focus-visible/slider:ring-offset-2 rst:ring-offset-background",W),style:{insetInlineStart:s.along(l.at(t))}})]}),r.jsx(d.SnapChips,{points:w,labelledBy:C,label:L["aria-label"],pressed:e=>t===e,pick:e=>j(e,!0),disabled:n,chipClassName:X}),r.jsx(d.Message,{id:B,helperText:q,errorMessage:g,disabled:n,className:Z}),b&&r.jsx("input",{ref:O,type:"hidden",name:b,value:t===null?"":String(t),disabled:n,readOnly:!0})]})}exports.Slider=ye;
|