jaguar-form 1.0.6 → 1.0.8
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 +8 -0
- package/dist/{Cascader-ZIkXvvC3.js → Cascader-COGUcdDS.js} +4 -4
- package/dist/{Select-BIBk_TT6.js → Select-BxwT7MHH.js} +118 -107
- package/dist/{TreeSelect-BQCyCCqa.js → TreeSelect-W5sgU5nW.js} +4 -4
- package/dist/{compound-BX_PoTK5.js → compound-nXxRSVJu.js} +27 -27
- package/dist/compound.js +1 -1
- package/dist/core.js +1 -1
- package/dist/date-time.js +1 -1
- package/dist/{form-CSfUExUT.js → form-D6O5PqrZ.js} +62 -49
- package/dist/form.js +3 -3
- package/dist/{icons-BwE05e0C.js → icons-B1dOXz-r.js} +1 -1
- package/dist/{image-upload-D9oPG0Eh.js → image-upload-BFVs81x3.js} +46 -42
- package/dist/image-upload.js +1 -1
- package/dist/index.js +15 -15
- package/dist/input.js +1 -1
- package/dist/inputs-w_es2t_C.js +862 -0
- package/dist/{lazy-tree-NCX3ntYm.js → lazy-tree-DNvNf_Yv.js} +51 -43
- package/dist/{pickers-Bci1y8cc.js → pickers-5zLmSrsp.js} +3 -3
- package/dist/select.js +2 -2
- package/dist/selection-CA_66JX9.js +223 -0
- package/dist/{slider-AM0Egz9P.js → slider-Bhd1Z4LP.js} +35 -35
- package/dist/slider.js +1 -1
- package/dist/{store-CFSQW-Fv.js → store-C9eBd8Y7.js} +205 -194
- package/dist/style.css +1 -1
- package/dist/tree-select.js +1 -1
- package/dist/types/components/extended-inputs.d.ts +4 -1
- package/dist/types/components/image-upload/index.d.ts +1 -1
- package/dist/types/components/inputs.d.ts +28 -8
- package/dist/types/config/index.d.ts +32 -1
- package/dist/types/entries/input.d.ts +2 -2
- package/dist/types/form/index.d.ts +3 -0
- package/dist/types/form/store.d.ts +1 -0
- package/dist/types/primitives/Control.d.ts +7 -2
- package/dist/{useControllable-QDX_UWRh.js → useControllable-Dt38Jg9E.js} +54 -21
- package/package.json +1 -1
- package/dist/inputs-Dx3xOy9q.js +0 -718
- package/dist/selection-DCIzhR5q.js +0 -197
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { o as n, t as r } from "./selection-
|
|
1
|
+
import { l as e, t } from "./useControllable-Dt38Jg9E.js";
|
|
2
|
+
import { o as n, t as r } from "./selection-CA_66JX9.js";
|
|
3
3
|
import { useCallback as i, useLayoutEffect as a, useMemo as o, useRef as s, useState as c } from "react";
|
|
4
4
|
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
5
5
|
// src/primitives/selection.tsx
|
|
@@ -78,8 +78,13 @@ function f({ options: t, mode: i = "tags", maxTagCount: o = "responsive", maxTag
|
|
|
78
78
|
]
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
var p = (e) => e.value;
|
|
82
|
+
function m({ options: t, onRemove: r, onClear: i, readOnly: a }) {
|
|
83
|
+
let s = e(), [l, f] = c(""), m = o(() => {
|
|
84
|
+
if (!l) return t;
|
|
85
|
+
let e = l.toLowerCase();
|
|
86
|
+
return t.filter((t) => (t.searchText ?? (typeof t.label == "string" ? t.label : String(t.value))).toLowerCase().includes(e));
|
|
87
|
+
}, [t, l]);
|
|
83
88
|
return /* @__PURE__ */ d("div", {
|
|
84
89
|
className: "rfe-selected-panel",
|
|
85
90
|
children: [
|
|
@@ -99,9 +104,9 @@ function p({ options: t, onRemove: r, onClear: i, readOnly: a }) {
|
|
|
99
104
|
placeholder: s.search,
|
|
100
105
|
"aria-label": s.search
|
|
101
106
|
}),
|
|
102
|
-
/* @__PURE__ */ u(
|
|
103
|
-
items:
|
|
104
|
-
getKey:
|
|
107
|
+
/* @__PURE__ */ u(_, {
|
|
108
|
+
items: m,
|
|
109
|
+
getKey: p,
|
|
105
110
|
render: (e) => /* @__PURE__ */ d("div", {
|
|
106
111
|
className: "rfe-option",
|
|
107
112
|
children: [/* @__PURE__ */ u("span", {
|
|
@@ -123,8 +128,8 @@ function p({ options: t, onRemove: r, onClear: i, readOnly: a }) {
|
|
|
123
128
|
]
|
|
124
129
|
});
|
|
125
130
|
}
|
|
126
|
-
var
|
|
127
|
-
function
|
|
131
|
+
var h = (e, t) => t;
|
|
132
|
+
function g(e, t) {
|
|
128
133
|
let n = 0, r = e.length - 1;
|
|
129
134
|
for (; n < r;) {
|
|
130
135
|
let i = Math.floor((n + r + 1) / 2);
|
|
@@ -132,8 +137,9 @@ function h(e, t) {
|
|
|
132
137
|
}
|
|
133
138
|
return Math.min(n, e.length - 2);
|
|
134
139
|
}
|
|
135
|
-
function
|
|
140
|
+
function _({ items: e, render: t, getKey: n = h, itemHeight: r = 36, maxHeight: l = 216, activeIndex: f, variableHeight: p = !1, id: m, className: _, role: v, label: y, multiple: b, activeId: x, tabIndex: S }) {
|
|
136
141
|
let [C, w] = c(0), [T, E] = c(l), [D, O] = c(0), k = s(null), A = s(/* @__PURE__ */ new Map()), j = s(null), M = s(0), N = s(0), P = o(() => e.map(n), [e, n]), F = o(() => {
|
|
142
|
+
if (!p) return [];
|
|
137
143
|
let e = [0];
|
|
138
144
|
for (let t of P) e.push(e[e.length - 1] + (p ? A.current.get(t) ?? r : r));
|
|
139
145
|
return e;
|
|
@@ -142,7 +148,7 @@ function g({ items: e, render: t, getKey: n = m, itemHeight: r = 36, maxHeight:
|
|
|
142
148
|
r,
|
|
143
149
|
p,
|
|
144
150
|
D
|
|
145
|
-
]), I = F.at(-1) ?? 0, L = e.length > 100, R = L && e.length ? Math.max(0,
|
|
151
|
+
]), I = p ? F.at(-1) ?? 0 : e.length * r, L = e.length > 100, R = (e) => p ? F[e] : e * r, z = (t) => p ? g(F, t) : Math.min(e.length - 1, Math.floor(t / Math.max(1, r))), B = L && e.length ? Math.max(0, z(C) - 4) : 0, V = L && e.length ? Math.min(e.length, z(C + T) + 6) : e.length;
|
|
146
152
|
a(() => {
|
|
147
153
|
let e = k.current;
|
|
148
154
|
if (!e) return;
|
|
@@ -160,13 +166,15 @@ function g({ items: e, render: t, getKey: n = m, itemHeight: r = 36, maxHeight:
|
|
|
160
166
|
}, [I, T]), a(() => {
|
|
161
167
|
let t = k.current;
|
|
162
168
|
if (!t || f === void 0 || f < 0 || f >= e.length) return;
|
|
163
|
-
let n =
|
|
169
|
+
let n = R(f), r = R(f + 1);
|
|
164
170
|
n < t.scrollTop ? t.scrollTop = n : r > t.scrollTop + t.clientHeight && (t.scrollTop = r - t.clientHeight), w(t.scrollTop);
|
|
165
171
|
}, [
|
|
166
172
|
f,
|
|
167
173
|
F,
|
|
168
174
|
e.length,
|
|
169
|
-
T
|
|
175
|
+
T,
|
|
176
|
+
r,
|
|
177
|
+
p
|
|
170
178
|
]), a(() => {
|
|
171
179
|
if (!p || !k.current) return;
|
|
172
180
|
let e = k.current, t = new ResizeObserver((e) => {
|
|
@@ -183,16 +191,16 @@ function g({ items: e, render: t, getKey: n = m, itemHeight: r = 36, maxHeight:
|
|
|
183
191
|
}, [
|
|
184
192
|
p,
|
|
185
193
|
P,
|
|
186
|
-
|
|
187
|
-
|
|
194
|
+
B,
|
|
195
|
+
V
|
|
188
196
|
]), a(() => {
|
|
189
197
|
let e = new Set(P);
|
|
190
198
|
for (let t of A.current.keys()) e.has(t) || A.current.delete(t);
|
|
191
199
|
}, [P]), a(() => () => cancelAnimationFrame(N.current), []);
|
|
192
|
-
let
|
|
200
|
+
let H = i((e) => {
|
|
193
201
|
let t = e.currentTarget.scrollTop;
|
|
194
202
|
cancelAnimationFrame(N.current), N.current = requestAnimationFrame(() => w(t));
|
|
195
|
-
}, []),
|
|
203
|
+
}, []), U = f !== void 0 && f >= 0 && f < e.length, W = U && f >= B && f < V, G = (e, n) => /* @__PURE__ */ u("div", {
|
|
196
204
|
role: "presentation",
|
|
197
205
|
"data-virtual-index": n,
|
|
198
206
|
"data-variable-row": p || void 0,
|
|
@@ -201,46 +209,46 @@ function g({ items: e, render: t, getKey: n = m, itemHeight: r = 36, maxHeight:
|
|
|
201
209
|
}, P[n]);
|
|
202
210
|
return /* @__PURE__ */ u("div", {
|
|
203
211
|
className: `rfe-list${_ ? ` ${_}` : ""}`,
|
|
204
|
-
id:
|
|
212
|
+
id: m,
|
|
205
213
|
role: v,
|
|
206
214
|
tabIndex: S,
|
|
207
215
|
"aria-label": y,
|
|
208
216
|
"aria-multiselectable": b || void 0,
|
|
209
|
-
"aria-activedescendant":
|
|
217
|
+
"aria-activedescendant": U ? x : void 0,
|
|
210
218
|
ref: k,
|
|
211
219
|
style: {
|
|
212
220
|
maxHeight: l,
|
|
213
221
|
overflowY: "auto"
|
|
214
222
|
},
|
|
215
|
-
onScroll:
|
|
223
|
+
onScroll: H,
|
|
216
224
|
children: L ? /* @__PURE__ */ d("div", {
|
|
217
225
|
role: "presentation",
|
|
218
226
|
style: {
|
|
219
227
|
height: I,
|
|
220
228
|
position: "relative"
|
|
221
229
|
},
|
|
222
|
-
children: [
|
|
230
|
+
children: [U && !W && /* @__PURE__ */ u("div", {
|
|
223
231
|
role: "presentation",
|
|
224
232
|
style: {
|
|
225
233
|
position: "absolute",
|
|
226
|
-
top:
|
|
234
|
+
top: R(f),
|
|
227
235
|
insetInline: 0
|
|
228
236
|
},
|
|
229
|
-
children:
|
|
237
|
+
children: G(e[f], f)
|
|
230
238
|
}), /* @__PURE__ */ u("div", {
|
|
231
239
|
role: "presentation",
|
|
232
240
|
style: {
|
|
233
241
|
position: "absolute",
|
|
234
|
-
top:
|
|
242
|
+
top: R(B),
|
|
235
243
|
insetInline: 0
|
|
236
244
|
},
|
|
237
|
-
children: e.slice(
|
|
245
|
+
children: e.slice(B, V).map((e, t) => G(e, B + t))
|
|
238
246
|
})]
|
|
239
|
-
}) : e.map(
|
|
247
|
+
}) : e.map(G)
|
|
240
248
|
});
|
|
241
249
|
}
|
|
242
250
|
// src/utils/tree.ts
|
|
243
|
-
function
|
|
251
|
+
function v(e) {
|
|
244
252
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = [], a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = e.slice().reverse().map((e) => ({
|
|
245
253
|
node: e,
|
|
246
254
|
blocked: !1
|
|
@@ -280,17 +288,17 @@ function _(e) {
|
|
|
280
288
|
incomplete: o
|
|
281
289
|
};
|
|
282
290
|
}
|
|
283
|
-
function
|
|
291
|
+
function y(e, t, n = 1e400) {
|
|
284
292
|
let r = new Set(e), i = new Set(t);
|
|
285
293
|
if (t.every((e) => r.has(e))) return e.filter((e) => !i.has(e));
|
|
286
294
|
for (let e of t) r.add(e);
|
|
287
295
|
return r.size <= n ? [...r] : e;
|
|
288
296
|
}
|
|
289
|
-
function
|
|
297
|
+
function b(e, t) {
|
|
290
298
|
let n = e.reduce((e, n) => e + Number(t.has(n)), 0);
|
|
291
299
|
return n === 0 ? "none" : n === e.length ? "all" : "partial";
|
|
292
300
|
}
|
|
293
|
-
function
|
|
301
|
+
function x(e, t, n, r = /* @__PURE__ */ new Set()) {
|
|
294
302
|
let i = new Uint32Array(e.length + 1);
|
|
295
303
|
for (let t = 0; t < e.length; t++) i[t + 1] = i[t] + Number(n.has(e[t]));
|
|
296
304
|
let a = (e) => {
|
|
@@ -309,7 +317,7 @@ function b(e, t, n, r = /* @__PURE__ */ new Set()) {
|
|
|
309
317
|
}
|
|
310
318
|
};
|
|
311
319
|
}
|
|
312
|
-
function
|
|
320
|
+
function S(e, t) {
|
|
313
321
|
let n = [], r = e.slice().reverse();
|
|
314
322
|
for (; r.length;) {
|
|
315
323
|
let e = r.pop();
|
|
@@ -319,7 +327,7 @@ function x(e, t) {
|
|
|
319
327
|
return n;
|
|
320
328
|
}
|
|
321
329
|
// src/components/select/useSelection.ts
|
|
322
|
-
function
|
|
330
|
+
function C(e) {
|
|
323
331
|
let [n, r] = t(e.value, e.defaultValue ?? (e.multiple ? [] : null), (t) => {
|
|
324
332
|
e.multiple, e.onChange?.(t);
|
|
325
333
|
}), i = o(() => Array.isArray(n) ? n : n == null ? [] : [n], [n]), [l, u] = t(e.open, e.defaultOpen ?? !1, e.onOpenChange), d = !!(e.disabled || e.loading), f = l && !d, [p, m] = c(i), h = s({
|
|
@@ -355,10 +363,10 @@ function S(e) {
|
|
|
355
363
|
};
|
|
356
364
|
}
|
|
357
365
|
// src/utils/lazy-tree.ts
|
|
358
|
-
var
|
|
359
|
-
function
|
|
360
|
-
let r =
|
|
361
|
-
if (!i || !
|
|
366
|
+
var w = (e) => e.hasChildren === !0 && e.children === void 0, T = (e) => !!(e.children?.length || w(e));
|
|
367
|
+
function E(e, t, n) {
|
|
368
|
+
let r = v(e), i = r.map.get(t);
|
|
369
|
+
if (!i || !w(i)) return e;
|
|
362
370
|
let a = {
|
|
363
371
|
...i,
|
|
364
372
|
children: n,
|
|
@@ -372,9 +380,9 @@ function T(e, t, n) {
|
|
|
372
380
|
}, o = e;
|
|
373
381
|
}
|
|
374
382
|
let s = e.map((e) => Object.is(e.value, o) ? a : e);
|
|
375
|
-
return
|
|
383
|
+
return v(s), s;
|
|
376
384
|
}
|
|
377
|
-
function
|
|
385
|
+
function D(e, t) {
|
|
378
386
|
let n = e, r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = () => t(n, new Map(i)), o = () => {
|
|
379
387
|
for (let e of r.values()) e.abort();
|
|
380
388
|
r.clear(), i.clear();
|
|
@@ -386,8 +394,8 @@ function E(e, t) {
|
|
|
386
394
|
dispose: o,
|
|
387
395
|
async load(e, t) {
|
|
388
396
|
if (r.has(e)) return !1;
|
|
389
|
-
let o =
|
|
390
|
-
if (!o || !
|
|
397
|
+
let o = v(n).map.get(e);
|
|
398
|
+
if (!o || !w(o)) return !1;
|
|
391
399
|
let s = new AbortController();
|
|
392
400
|
r.set(e, s), i.set(e, "loading"), a();
|
|
393
401
|
let c = () => r.get(e) === s && !s.signal.aborted;
|
|
@@ -395,14 +403,14 @@ function E(e, t) {
|
|
|
395
403
|
let l = await t(o, { signal: s.signal });
|
|
396
404
|
if (!c()) return !1;
|
|
397
405
|
if (!Array.isArray(l)) throw TypeError("loadChildren must return an array");
|
|
398
|
-
return n =
|
|
406
|
+
return n = E(n, e, l), r.delete(e), i.delete(e), a(), !0;
|
|
399
407
|
} catch {
|
|
400
408
|
return c() && (r.delete(e), i.set(e, "error"), a()), !1;
|
|
401
409
|
}
|
|
402
410
|
}
|
|
403
411
|
};
|
|
404
412
|
}
|
|
405
|
-
function
|
|
413
|
+
function O(e, t, n, r) {
|
|
406
414
|
let i = n.trim().toLocaleLowerCase(), a = [], o = e.map((t, n) => ({
|
|
407
415
|
node: t,
|
|
408
416
|
depth: 0,
|
|
@@ -447,4 +455,4 @@ function D(e, t, n, r) {
|
|
|
447
455
|
};
|
|
448
456
|
});
|
|
449
457
|
}
|
|
450
|
-
export {
|
|
458
|
+
export { C as a, x as c, m as d, f, O as i, v as l, T as n, b as o, _ as p, w as r, S as s, D as t, y as u };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useId as e, useLayoutEffect as t, useMemo as n, useRef as r, useState as i } from "react";
|
|
2
2
|
import a from "dayjs";
|
|
3
3
|
import { i as o } from "./locale-yHkdw2xz.js";
|
|
4
|
-
import {
|
|
5
|
-
import { n as l, o as u, r as d, s as f } from "./selection-
|
|
6
|
-
import { t as p } from "./icons-
|
|
4
|
+
import { c as s, t as c } from "./useControllable-Dt38Jg9E.js";
|
|
5
|
+
import { n as l, o as u, r as d, s as f } from "./selection-CA_66JX9.js";
|
|
6
|
+
import { t as p } from "./icons-B1dOXz-r.js";
|
|
7
7
|
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
8
8
|
// src/utils/date.ts
|
|
9
9
|
var _ = (e) => String(e).padStart(2, "0");
|
package/dist/select.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as e, t } from "./Select-
|
|
2
|
-
import { t as n } from "./Cascader-
|
|
1
|
+
import { n as e, t } from "./Select-BxwT7MHH.js";
|
|
2
|
+
import { t as n } from "./Cascader-COGUcdDS.js";
|
|
3
3
|
export { n as Cascader, t as MultiSelect, e as Select };
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { a as e, c as t, i as n, r, s as i, u as a } from "./useControllable-Dt38Jg9E.js";
|
|
2
|
+
import { t as o } from "./icons-B1dOXz-r.js";
|
|
3
|
+
import { createContext as s, useCallback as c, useContext as l, useEffect as u, useId as d, useLayoutEffect as f, useRef as p, useState as m, useSyncExternalStore as h } from "react";
|
|
4
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
5
|
+
import { FloatingFocusManager as v, FloatingNode as y, FloatingOverlay as b, FloatingPortal as x, FloatingTree as S, autoUpdate as C, flip as w, offset as T, shift as E, size as D, useDismiss as O, useFloating as ee, useFloatingNodeId as te, useFloatingTree as k, useInteractions as A, useRole as j, useTransitionStyles as M } from "@floating-ui/react";
|
|
6
|
+
// src/primitives/Control.tsx
|
|
7
|
+
function N({ children: e, actions: t, prefix: n, suffix: r, prefixIcon: s, suffixIcon: c, size: l, variant: u, status: d, disabled: f, readOnly: p, className: m, style: h, floatingLabel: v, floatingFilled: y, floatingOpen: b, id: x, "aria-invalid": S }) {
|
|
8
|
+
let C = i();
|
|
9
|
+
return /* @__PURE__ */ _("div", {
|
|
10
|
+
className: a("rfe-control", !!v && "rfe-floating-shell", m),
|
|
11
|
+
style: h,
|
|
12
|
+
"data-size": l ?? C.size,
|
|
13
|
+
"data-variant": u ?? C.variant,
|
|
14
|
+
"data-status": S ? "error" : d ?? "default",
|
|
15
|
+
"data-disabled": f || void 0,
|
|
16
|
+
"data-readonly": p || void 0,
|
|
17
|
+
"data-floating-filled": y || void 0,
|
|
18
|
+
"data-floating-open": b || void 0,
|
|
19
|
+
children: [
|
|
20
|
+
(s || n) && /* @__PURE__ */ _("span", {
|
|
21
|
+
className: "rfe-affix",
|
|
22
|
+
children: [/* @__PURE__ */ g(o, { source: s }), n]
|
|
23
|
+
}),
|
|
24
|
+
e,
|
|
25
|
+
(c || r) && /* @__PURE__ */ _("span", {
|
|
26
|
+
className: "rfe-affix",
|
|
27
|
+
children: [/* @__PURE__ */ g(o, { source: c }), r]
|
|
28
|
+
}),
|
|
29
|
+
t,
|
|
30
|
+
v && /* @__PURE__ */ g("label", {
|
|
31
|
+
className: "rfe-shell-label",
|
|
32
|
+
htmlFor: x,
|
|
33
|
+
children: v
|
|
34
|
+
})
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function P({ name: e, source: t, label: n, onClick: r, disabled: i, hidden: a, repeat: s }) {
|
|
39
|
+
let c = p(null), l = p(!1), d = p(!1), f = p(r);
|
|
40
|
+
f.current = r;
|
|
41
|
+
let m = () => {
|
|
42
|
+
l.current = !1, c.current !== null && clearTimeout(c.current), c.current = null;
|
|
43
|
+
};
|
|
44
|
+
return u(() => {
|
|
45
|
+
if (s) return window.addEventListener("blur", m), () => {
|
|
46
|
+
window.removeEventListener("blur", m), m();
|
|
47
|
+
};
|
|
48
|
+
}, [!!s]), u(() => {
|
|
49
|
+
(i || a) && m();
|
|
50
|
+
}, [i, a]), /* @__PURE__ */ g("button", {
|
|
51
|
+
className: "rfe-action",
|
|
52
|
+
type: "button",
|
|
53
|
+
"aria-label": n,
|
|
54
|
+
title: n,
|
|
55
|
+
disabled: i || a,
|
|
56
|
+
style: a ? { visibility: "hidden" } : void 0,
|
|
57
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
58
|
+
onPointerDown: s ? (e) => {
|
|
59
|
+
if (e.button !== 0 || i || a) return;
|
|
60
|
+
m(), d.current = !1, l.current = !0, e.currentTarget.setPointerCapture?.(e.pointerId);
|
|
61
|
+
let t = () => {
|
|
62
|
+
l.current && (d.current = !0, f.current(), l.current && (c.current = setTimeout(t, Math.max(16, s.interval ?? 80))));
|
|
63
|
+
};
|
|
64
|
+
c.current = setTimeout(t, Math.max(0, s.delay ?? 400));
|
|
65
|
+
} : void 0,
|
|
66
|
+
onPointerUp: m,
|
|
67
|
+
onPointerCancel: m,
|
|
68
|
+
onLostPointerCapture: m,
|
|
69
|
+
onBlur: m,
|
|
70
|
+
onClick: (e) => {
|
|
71
|
+
e.stopPropagation(), e.detail !== 0 && d.current ? d.current = !1 : (d.current = !1, r());
|
|
72
|
+
},
|
|
73
|
+
children: /* @__PURE__ */ g(o, {
|
|
74
|
+
name: e,
|
|
75
|
+
source: t
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// src/components/compound/context.ts
|
|
80
|
+
var F = s(null), I = () => l(F), L = "(max-width: 560px)", R = "(prefers-reduced-motion: reduce)", z = (e) => {
|
|
81
|
+
let t = window.matchMedia(R);
|
|
82
|
+
return t.addEventListener("change", e), () => t.removeEventListener("change", e);
|
|
83
|
+
}, ne = () => typeof window < "u" && window.matchMedia(R).matches, re = (e) => {
|
|
84
|
+
let t = window.matchMedia(L);
|
|
85
|
+
return t.addEventListener("change", e), () => t.removeEventListener("change", e);
|
|
86
|
+
}, ie = () => typeof window < "u" && window.matchMedia(L).matches;
|
|
87
|
+
function B(e) {
|
|
88
|
+
return k() ? /* @__PURE__ */ g(V, { ...e }) : /* @__PURE__ */ g(S, { children: /* @__PURE__ */ g(V, { ...e }) });
|
|
89
|
+
}
|
|
90
|
+
function V({ open: a, onOpenChange: o, children: s, trigger: l, placement: u = "bottom-start", popupWidth: p = "trigger", popupMaxHeight: S = 320, portalContainer: k, role: N = "dialog", label: P, popupMode: F, layout: L = "content", initialFocus: R = 0 }) {
|
|
91
|
+
let B = I(), [V, H] = m(null), U = i(), W = t(), G = d(), K = te(), q = h(re, ie, () => !1), J = h(z, ne, () => !1), Y = F ?? U.popupMode, X = Y === "sheet" || Y === "auto" && q, [ae, oe] = m(null), { refs: Z, floatingStyles: se, context: Q, placement: ce } = ee({
|
|
92
|
+
nodeId: K,
|
|
93
|
+
open: a,
|
|
94
|
+
onOpenChange: o,
|
|
95
|
+
placement: u,
|
|
96
|
+
strategy: X ? "fixed" : "absolute",
|
|
97
|
+
whileElementsMounted: X ? void 0 : C,
|
|
98
|
+
middleware: X ? [] : [
|
|
99
|
+
T(6),
|
|
100
|
+
w(),
|
|
101
|
+
E({ padding: 8 }),
|
|
102
|
+
D({
|
|
103
|
+
padding: 8,
|
|
104
|
+
apply({ availableHeight: e, availableWidth: t, rects: n, elements: r }) {
|
|
105
|
+
Object.assign(r.floating.style, {
|
|
106
|
+
maxHeight: `${Math.max(0, Math.min(e, S))}px`,
|
|
107
|
+
maxWidth: `${Math.max(0, t)}px`,
|
|
108
|
+
width: `${Math.max(0, Math.min(t, p === "trigger" ? n.reference.width : p))}px`
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
}), le = c((e) => {
|
|
114
|
+
Z.setFloating(e), H(e);
|
|
115
|
+
}, [Z.setFloating]);
|
|
116
|
+
f(() => {
|
|
117
|
+
if (a && V) return B?.registerPopup(V);
|
|
118
|
+
}, [
|
|
119
|
+
a,
|
|
120
|
+
V,
|
|
121
|
+
B
|
|
122
|
+
]);
|
|
123
|
+
let ue = c((e) => {
|
|
124
|
+
Z.setReference(e), oe(e?.closest("dialog[open]") ?? null);
|
|
125
|
+
}, [Z.setReference]), de = O(Q, { bubbles: {
|
|
126
|
+
escapeKey: !1,
|
|
127
|
+
outsidePress: !0
|
|
128
|
+
} }), fe = j(Q, { role: N }), { getReferenceProps: pe, getFloatingProps: me } = A([de, fe]), { isMounted: he, styles: ge } = M(Q, {
|
|
129
|
+
duration: n(U.motion) && !J ? {
|
|
130
|
+
open: r(U.motion, 160),
|
|
131
|
+
close: r(U.motion, 100)
|
|
132
|
+
} : 0,
|
|
133
|
+
initial: ({ side: e }) => ({
|
|
134
|
+
opacity: 0,
|
|
135
|
+
transform: X ? "translateY(16px)" : `translateY(${e === "top" ? 4 : -4}px) scale(.985)`
|
|
136
|
+
})
|
|
137
|
+
}), _e = {
|
|
138
|
+
lang: W.code,
|
|
139
|
+
dir: W.direction,
|
|
140
|
+
"data-theme": U.theme,
|
|
141
|
+
"data-density": U.density,
|
|
142
|
+
"data-motion": n(U.motion) ? "on" : "off"
|
|
143
|
+
}, $ = /* @__PURE__ */ g(v, {
|
|
144
|
+
context: Q,
|
|
145
|
+
modal: X,
|
|
146
|
+
initialFocus: R,
|
|
147
|
+
disabled: !a,
|
|
148
|
+
returnFocus: !0,
|
|
149
|
+
children: /* @__PURE__ */ g("div", {
|
|
150
|
+
..._e,
|
|
151
|
+
className: "rfe-scope rfe-popup-position",
|
|
152
|
+
"data-sheet": X || void 0,
|
|
153
|
+
ref: le,
|
|
154
|
+
style: {
|
|
155
|
+
...e(U),
|
|
156
|
+
...X ? {
|
|
157
|
+
position: "fixed",
|
|
158
|
+
insetInline: 0,
|
|
159
|
+
bottom: 0,
|
|
160
|
+
width: "100%",
|
|
161
|
+
maxWidth: "100%",
|
|
162
|
+
maxHeight: "85dvh"
|
|
163
|
+
} : se
|
|
164
|
+
},
|
|
165
|
+
...me({
|
|
166
|
+
id: G,
|
|
167
|
+
"aria-label": P,
|
|
168
|
+
"aria-modal": X || void 0
|
|
169
|
+
}),
|
|
170
|
+
children: /* @__PURE__ */ _("div", {
|
|
171
|
+
className: "rfe-panel",
|
|
172
|
+
"data-layout": L,
|
|
173
|
+
"data-side": ce.split("-")[0],
|
|
174
|
+
style: {
|
|
175
|
+
...ge,
|
|
176
|
+
pointerEvents: a ? "auto" : "none"
|
|
177
|
+
},
|
|
178
|
+
inert: !a,
|
|
179
|
+
children: [X && /* @__PURE__ */ g("span", {
|
|
180
|
+
className: "rfe-sheet-handle",
|
|
181
|
+
"aria-hidden": "true"
|
|
182
|
+
}), s]
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
});
|
|
186
|
+
return /* @__PURE__ */ _(y, {
|
|
187
|
+
id: K,
|
|
188
|
+
children: [l(pe({
|
|
189
|
+
"aria-expanded": a,
|
|
190
|
+
"aria-controls": a ? G : void 0
|
|
191
|
+
}), ue, G), he && /* @__PURE__ */ g(x, {
|
|
192
|
+
root: k ?? ae ?? void 0,
|
|
193
|
+
children: X ? /* @__PURE__ */ g(b, {
|
|
194
|
+
lockScroll: a,
|
|
195
|
+
className: "rfe-sheet-overlay",
|
|
196
|
+
style: e(U),
|
|
197
|
+
children: $
|
|
198
|
+
}) : $
|
|
199
|
+
})]
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
// src/utils/selection.ts
|
|
203
|
+
function H(e, t, n, r) {
|
|
204
|
+
if (e <= 0) return -1;
|
|
205
|
+
let i = n === "ArrowUp" || n === "End", a = i ? -1 : 1, o = n === "Home" ? 0 : n === "End" ? e - 1 : t < 0 ? i ? e - 1 : 0 : t + a;
|
|
206
|
+
for (; o >= 0 && o < e;) {
|
|
207
|
+
if (r(o)) return o;
|
|
208
|
+
o += a;
|
|
209
|
+
}
|
|
210
|
+
return t >= 0 && t < e && r(t) ? t : -1;
|
|
211
|
+
}
|
|
212
|
+
function U(e, t, n, r, i = 1, a = 4) {
|
|
213
|
+
if (e <= 0 || i <= 0 || !n) return 0;
|
|
214
|
+
let o = (o) => {
|
|
215
|
+
let s = 1, c = 0, l = t.slice(0, o).map((t) => Math.min(t, e));
|
|
216
|
+
o < n && l.push(Math.min(r, e));
|
|
217
|
+
for (let t of l) if (c && c + a + t > e && (s++, c = 0), c += t + (c ? a : 0), s > i) return !1;
|
|
218
|
+
return !0;
|
|
219
|
+
}, s = Math.min(t.length, n);
|
|
220
|
+
for (; s > 0 && !o(s);) s--;
|
|
221
|
+
return s;
|
|
222
|
+
}
|
|
223
|
+
export { I as a, F as i, H as n, P as o, B as r, N as s, U as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useId as e, useLayoutEffect as t, useMemo as n, useRef as r, useState as i } from "react";
|
|
2
|
-
import { a,
|
|
2
|
+
import { c as a, s as o, t as s, u as c } from "./useControllable-Dt38Jg9E.js";
|
|
3
3
|
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
4
4
|
// src/components/slider/math.ts
|
|
5
5
|
function f(e = 0, t = 100, n = 1) {
|
|
@@ -35,20 +35,20 @@ function _(e, t, n = 1) {
|
|
|
35
35
|
return Math.abs(r - i) < 1e-9 ? e[0] === e[1] ? t < e[0] ? 0 : t > e[1] ? 1 : n : n : r < i ? 0 : 1;
|
|
36
36
|
}
|
|
37
37
|
// src/components/slider/index.tsx
|
|
38
|
-
function v(
|
|
39
|
-
let g = o(), { text: v, direction: y } = a(), b = y === "rtl", x = e(), { min: S, max: C, step: w } = f(
|
|
38
|
+
function v(s) {
|
|
39
|
+
let g = o(), { text: v, direction: y } = a(), b = y === "rtl", x = e(), { min: S, max: C, step: w } = f(s.min, s.max, s.step), T = s.values.length === 2, E = !!(s.disabled || s.loading), D = E || s.readOnly, O = s.formatValue ?? String, [k, A] = i(null), [j, M] = i(null), [te, N] = i(null), [P, ne] = i({
|
|
40
40
|
width: 0,
|
|
41
41
|
first: 0,
|
|
42
42
|
second: 0
|
|
43
|
-
}), F = r(null), I = r(null), L = r([]), R = r(
|
|
43
|
+
}), F = r(null), I = r(null), L = r([]), R = r(s.values), z = r(!1), B = r(null), V = r(1);
|
|
44
44
|
t(() => {
|
|
45
|
-
B.current || (R.current =
|
|
46
|
-
}, [
|
|
47
|
-
let H = (e) => b ? 100 - m(e, S, C) : m(e, S, C), U =
|
|
48
|
-
|
|
45
|
+
B.current || (R.current = s.values);
|
|
46
|
+
}, [s.values]);
|
|
47
|
+
let H = (e) => b ? 100 - m(e, S, C) : m(e, S, C), U = s.values.map(H), re = H(S), W = U.at(-1), G = T ? U[0] : re, K = n(() => Object.entries(s.marks ?? {}).filter(([e]) => Number.isFinite(Number(e)) && Number(e) >= S && Number(e) <= C).sort(([e], [t]) => Number(e) - Number(t)), [
|
|
48
|
+
s.marks,
|
|
49
49
|
S,
|
|
50
50
|
C
|
|
51
|
-
]), ie =
|
|
51
|
+
]), ie = s.thumbLabels ?? [v.minimum, v.maximum], q = s.tooltip ?? "auto", J = (e) => !E && (q === "always" || q === "auto" && (k === e || j === e || te === e)), Y = s.values.map(O);
|
|
52
52
|
t(() => {
|
|
53
53
|
if (!F.current) return;
|
|
54
54
|
let e = () => {
|
|
@@ -67,10 +67,10 @@ function v(c) {
|
|
|
67
67
|
}, [Y.join("\0"), T]);
|
|
68
68
|
let X = T && J(0) && J(1) && P.width > 0 && Math.abs(U[1] - U[0]) * P.width / 100 < (P.first + P.second) / 2 + 8, Z = (e, t) => {
|
|
69
69
|
if (D) return;
|
|
70
|
-
let n = T ? ee(R.current, e, t, S, C, w,
|
|
71
|
-
n.every((e, t) => e === R.current[t]) || (R.current = n, z.current = !0, V.current = e,
|
|
70
|
+
let n = T ? ee(R.current, e, t, S, C, w, s.minDistance) : [p(t, S, C, w)];
|
|
71
|
+
n.every((e, t) => e === R.current[t]) || (R.current = n, z.current = !0, V.current = e, s.update(n));
|
|
72
72
|
}, Q = () => {
|
|
73
|
-
B.current = null, A(null), z.current && (z.current = !1,
|
|
73
|
+
B.current = null, A(null), z.current && (z.current = !1, s.onChangeEnd?.([...R.current]));
|
|
74
74
|
}, $ = (e) => {
|
|
75
75
|
let t = F.current?.getBoundingClientRect() ?? e.currentTarget.getBoundingClientRect(), n = Math.max(0, Math.min(1, (e.clientX - t.left) / Math.max(1, t.width)));
|
|
76
76
|
return S + (b ? 1 - n : n) * (C - S);
|
|
@@ -88,21 +88,21 @@ function v(c) {
|
|
|
88
88
|
if (!T || D) return;
|
|
89
89
|
let t = $(e), n = B.current;
|
|
90
90
|
n ? n.pointer === e.pointerId && (n.overlap && Math.abs(t - n.start) > w / 4 && (n.index = t < n.start ? 0 : 1, n.overlap = !1, A(n.index), I.current?.querySelectorAll("input")[n.index]?.focus({ preventScroll: !0 })), Z(n.index, t)) : N(_(R.current, t, V.current));
|
|
91
|
-
}, se = T ? h(S, C, w,
|
|
91
|
+
}, se = T ? h(S, C, w, s.minDistance) : 0;
|
|
92
92
|
return /* @__PURE__ */ d("div", {
|
|
93
|
-
className:
|
|
93
|
+
className: c("rfe-slider", s.className),
|
|
94
94
|
dir: y,
|
|
95
|
-
style:
|
|
96
|
-
"data-size":
|
|
97
|
-
"data-status":
|
|
95
|
+
style: s.style,
|
|
96
|
+
"data-size": s.size ?? g.size,
|
|
97
|
+
"data-status": s["aria-invalid"] ? "error" : s.status ?? "default",
|
|
98
98
|
"data-disabled": E || void 0,
|
|
99
|
-
"data-readonly":
|
|
99
|
+
"data-readonly": s.readOnly || void 0,
|
|
100
100
|
"data-range": T || void 0,
|
|
101
101
|
children: [
|
|
102
|
-
|
|
102
|
+
s.showValue && /* @__PURE__ */ u("div", {
|
|
103
103
|
className: "rfe-slider-heading",
|
|
104
104
|
children: /* @__PURE__ */ u("output", {
|
|
105
|
-
htmlFor:
|
|
105
|
+
htmlFor: s.values.map((e, t) => t === 0 ? s.id ?? `${x}-0` : `${x}-1`).join(" "),
|
|
106
106
|
children: Y.join(" – ")
|
|
107
107
|
})
|
|
108
108
|
}),
|
|
@@ -129,7 +129,7 @@ function v(c) {
|
|
|
129
129
|
}),
|
|
130
130
|
K.map(([e]) => /* @__PURE__ */ u("span", {
|
|
131
131
|
className: "rfe-slider-tick",
|
|
132
|
-
"data-selected": Number(e) >= (T ?
|
|
132
|
+
"data-selected": Number(e) >= (T ? s.values[0] : S) && Number(e) <= s.values.at(-1),
|
|
133
133
|
style: { left: `${H(Number(e))}%` }
|
|
134
134
|
}, e)),
|
|
135
135
|
U.map((e, t) => /* @__PURE__ */ u("span", {
|
|
@@ -148,30 +148,30 @@ function v(c) {
|
|
|
148
148
|
children: Y.join(" – ")
|
|
149
149
|
})
|
|
150
150
|
]
|
|
151
|
-
}),
|
|
151
|
+
}), s.values.map((e, t) => /* @__PURE__ */ u("input", {
|
|
152
152
|
className: "rfe-slider-input",
|
|
153
153
|
style: { zIndex: k === t || j === t ? 3 : t + 1 },
|
|
154
|
-
id: t === 0 ?
|
|
155
|
-
name:
|
|
154
|
+
id: t === 0 ? s.id ?? `${x}-0` : `${x}-1`,
|
|
155
|
+
name: s.name,
|
|
156
156
|
type: "range",
|
|
157
157
|
min: S,
|
|
158
158
|
max: C,
|
|
159
159
|
step: w,
|
|
160
160
|
value: e,
|
|
161
161
|
disabled: E,
|
|
162
|
-
"aria-readonly":
|
|
163
|
-
"aria-invalid":
|
|
164
|
-
"aria-describedby":
|
|
165
|
-
"aria-label": T ? [
|
|
162
|
+
"aria-readonly": s.readOnly || void 0,
|
|
163
|
+
"aria-invalid": s["aria-invalid"] ?? (s.status === "error" || void 0),
|
|
164
|
+
"aria-describedby": s["aria-describedby"],
|
|
165
|
+
"aria-label": T ? [s["aria-label"], ie[t]].filter(Boolean).join(" · ") : s["aria-label"] ?? (s.id ? void 0 : v.slider),
|
|
166
166
|
"aria-valuetext": O(e),
|
|
167
|
-
"aria-valuemin": T && t === 1 ?
|
|
168
|
-
"aria-valuemax": T && t === 0 ?
|
|
167
|
+
"aria-valuemin": T && t === 1 ? s.values[0] + se : S,
|
|
168
|
+
"aria-valuemax": T && t === 0 ? s.values[1] - se : C,
|
|
169
169
|
onChange: (e) => Z(t, Number(e.target.value)),
|
|
170
170
|
onFocus: () => {
|
|
171
171
|
M(t), V.current = t;
|
|
172
172
|
},
|
|
173
173
|
onBlur: () => {
|
|
174
|
-
M(null), B.current || Q(),
|
|
174
|
+
M(null), B.current || Q(), s.onBlur?.();
|
|
175
175
|
},
|
|
176
176
|
onPointerDown: (e) => {
|
|
177
177
|
D ? e.preventDefault() : A(t);
|
|
@@ -193,7 +193,7 @@ function v(c) {
|
|
|
193
193
|
].includes(e.key) && Q();
|
|
194
194
|
},
|
|
195
195
|
onKeyDown: (e) => {
|
|
196
|
-
|
|
196
|
+
s.readOnly && [
|
|
197
197
|
"ArrowLeft",
|
|
198
198
|
"ArrowRight",
|
|
199
199
|
"ArrowUp",
|
|
@@ -206,7 +206,7 @@ function v(c) {
|
|
|
206
206
|
}
|
|
207
207
|
}, t))]
|
|
208
208
|
}),
|
|
209
|
-
(
|
|
209
|
+
(s.showLimits || K.length > 0) && /* @__PURE__ */ u("div", {
|
|
210
210
|
className: "rfe-slider-labels",
|
|
211
211
|
"aria-hidden": "true",
|
|
212
212
|
children: K.length ? K.map(([e, t]) => /* @__PURE__ */ u("span", {
|
|
@@ -224,7 +224,7 @@ function v(c) {
|
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
226
|
function y(e) {
|
|
227
|
-
let { min: t, max: n, step: r } = f(e.min, e.max, e.step), [i, a] =
|
|
227
|
+
let { min: t, max: n, step: r } = f(e.min, e.max, e.step), [i, a] = s(e.value, e.defaultValue ?? t, e.onChange);
|
|
228
228
|
return /* @__PURE__ */ u(v, {
|
|
229
229
|
...e,
|
|
230
230
|
values: [p(i, t, n, r)],
|
|
@@ -233,7 +233,7 @@ function y(e) {
|
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
235
|
function b(e) {
|
|
236
|
-
let { min: t, max: n, step: r } = f(e.min, e.max, e.step), [i, a] =
|
|
236
|
+
let { min: t, max: n, step: r } = f(e.min, e.max, e.step), [i, a] = s(e.value, e.defaultValue ?? [t, n], e.onChange);
|
|
237
237
|
return /* @__PURE__ */ u(v, {
|
|
238
238
|
...e,
|
|
239
239
|
values: g(i, t, n, r, e.minDistance),
|
package/dist/slider.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as RangeSlider, n as Slider } from "./slider-
|
|
1
|
+
export { t as RangeSlider, n as Slider } from "./slider-Bhd1Z4LP.js";
|