jaguar-form 1.0.1 → 1.0.2
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 +18 -0
- package/dist/{Control-fWNQOzmu.js → Control-C6d18GL4.js} +2 -2
- package/dist/{Select-BFLDNUiq.js → Select-DTSlMsRZ.js} +5 -5
- package/dist/{TreeSelect-D8smQmgp.js → TreeSelect-Dl_uTfIf.js} +5 -5
- package/dist/compound-Cw0juTQp.js +320 -0
- package/dist/compound.js +1 -0
- package/dist/core.js +3 -1
- package/dist/date-time.js +1 -1
- package/dist/form-Cih4H8PU.js +412 -0
- package/dist/form.js +4 -3
- package/dist/{icons-KmLuj5v3.js → icons-BDtmWaBt.js} +1 -1
- package/dist/{image-upload-CkX8vlWK.js → image-upload-Cm_41Fcr.js} +2 -2
- package/dist/image-upload.js +1 -1
- package/dist/index.js +14 -12
- package/dist/input.js +1 -1
- package/dist/{inputs-DNNFmj2K.js → inputs-dLfnlXTx.js} +3 -3
- package/dist/{pickers-BOMKe7vt.js → pickers-g2TPgXFC.js} +4 -4
- package/dist/select.js +1 -1
- package/dist/selection-CIEa1uce.js +146 -0
- package/dist/{slider-BwDcSnnI.js → slider-CNwkLMmo.js} +1 -1
- package/dist/slider.js +1 -1
- package/dist/{store-DmlIFdPW.js → store-DOn9K-EA.js} +171 -229
- package/dist/style.css +1 -1
- package/dist/tree-select.js +1 -1
- package/dist/types/components/compound/ControlGroup.d.ts +29 -0
- package/dist/types/components/compound/context.d.ts +5 -0
- package/dist/types/components/compound/index.d.ts +40 -0
- package/dist/types/components/compound/model.d.ts +14 -0
- package/dist/types/components/compound/types.d.ts +24 -0
- package/dist/types/config/index.d.ts +2 -0
- package/dist/types/entries/compound.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/{useControllable-Dl8gno_5.js → useControllable-Zax42z2F.js} +6 -1
- package/dist/{useSelection-FYP8nzFQ.js → useSelection-BX5VFNcj.js} +3 -3
- package/dist/validation-D6vk5NAv.js +61 -0
- package/package.json +5 -1
- package/dist/form-zqtJgUQ3.js +0 -407
- package/dist/selection-Bfrk6SoB.js +0 -136
package/dist/form-zqtJgUQ3.js
DELETED
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
import { a as e } from "./useControllable-Dl8gno_5.js";
|
|
2
|
-
import { r as t } from "./locale-yHkdw2xz.js";
|
|
3
|
-
import { i as n, t as r } from "./image-upload-CkX8vlWK.js";
|
|
4
|
-
import { n as i, t as a } from "./slider-BwDcSnnI.js";
|
|
5
|
-
import { cloneElement as o, createContext as s, isValidElement as c, useCallback as l, useContext as u, useEffect as d, useId as f, useMemo as p, useRef as m, useState as h, useSyncExternalStore as g } from "react";
|
|
6
|
-
import { m as _, n as v, t as y } from "./store-DmlIFdPW.js";
|
|
7
|
-
import { a as b, c as x, d as S, f as C, l as w, n as T, o as E, r as D, s as O, t as k, u as A } from "./inputs-DNNFmj2K.js";
|
|
8
|
-
import { n as j, t as M } from "./Select-BFLDNUiq.js";
|
|
9
|
-
import { t as N } from "./TreeSelect-D8smQmgp.js";
|
|
10
|
-
import { a as P, c as F, i as I, l as L, n as R, o as z, r as ee, s as te, t as B, u as V } from "./pickers-BOMKe7vt.js";
|
|
11
|
-
import { jsx as H, jsxs as U } from "react/jsx-runtime";
|
|
12
|
-
// src/form/index.tsx
|
|
13
|
-
var W = s(null);
|
|
14
|
-
function G(e = {}) {
|
|
15
|
-
let [t] = h(() => {
|
|
16
|
-
let t = e.fields ?? [], n = {
|
|
17
|
-
...Object.fromEntries(t.map((e) => [e.name, e.defaultValue])),
|
|
18
|
-
...e.defaultValues
|
|
19
|
-
}, r = Object.fromEntries(t.filter((e) => e.transform).map((e) => [e.name, e.transform]));
|
|
20
|
-
return y(n, {
|
|
21
|
-
nested: e.nested,
|
|
22
|
-
initialValues: e.initialValues,
|
|
23
|
-
adapter: {
|
|
24
|
-
...e.adapter,
|
|
25
|
-
fields: {
|
|
26
|
-
...r,
|
|
27
|
-
...e.adapter?.fields
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
return t;
|
|
33
|
-
}
|
|
34
|
-
function K({ form: e, children: t }) {
|
|
35
|
-
return /* @__PURE__ */ H(W.Provider, {
|
|
36
|
-
value: e,
|
|
37
|
-
children: t
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
function q() {
|
|
41
|
-
let e = u(W);
|
|
42
|
-
if (!e) throw Error("FormProvider is required");
|
|
43
|
-
return e;
|
|
44
|
-
}
|
|
45
|
-
function J(e) {
|
|
46
|
-
let t = q(), n = l((n) => t.subscribe(e, n), [t, e]), r = l(() => t.getFieldState(e), [t, e]), i = g(n, r, r);
|
|
47
|
-
return {
|
|
48
|
-
...i,
|
|
49
|
-
value: i.value,
|
|
50
|
-
setValue: (n) => t.setValue(e, n),
|
|
51
|
-
onBlur: () => t.blur(e)
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function Y(e) {
|
|
55
|
-
let t = q(), n = l((n) => t.subscribe(e, n), [t, e]), r = l(() => t.getValue(e), [t, e]);
|
|
56
|
-
return g(n, r, r);
|
|
57
|
-
}
|
|
58
|
-
function ne(e) {
|
|
59
|
-
let t = q(), n = Y(e), r = f(), i = m(0), a = m([]), o = (e) => ({
|
|
60
|
-
key: `${r}-${++i.current}`,
|
|
61
|
-
value: e
|
|
62
|
-
}), s = (e) => {
|
|
63
|
-
let t = [...a.current];
|
|
64
|
-
return e.map((e) => {
|
|
65
|
-
let n = t.findIndex((t) => v(t.value, e));
|
|
66
|
-
return n < 0 ? o(e) : {
|
|
67
|
-
...t.splice(n, 1)[0],
|
|
68
|
-
value: e
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
}, c = p(() => s(Array.isArray(n) ? n : []), [n]);
|
|
72
|
-
d(() => {
|
|
73
|
-
a.current = c;
|
|
74
|
-
}, [c]);
|
|
75
|
-
let l = (n) => {
|
|
76
|
-
let r = t.getValue(e), i = s(Array.isArray(r) ? r : []), c = n.type === "insert" ? {
|
|
77
|
-
...n,
|
|
78
|
-
value: o(n.value)
|
|
79
|
-
} : n.type === "update" ? {
|
|
80
|
-
...n,
|
|
81
|
-
value: {
|
|
82
|
-
key: i[n.index]?.key ?? "",
|
|
83
|
-
value: n.value
|
|
84
|
-
}
|
|
85
|
-
} : n, l = _(i, c);
|
|
86
|
-
return a.current = l, t.editFieldArray(e, n);
|
|
87
|
-
};
|
|
88
|
-
return {
|
|
89
|
-
fields: c,
|
|
90
|
-
append: (n) => {
|
|
91
|
-
let r = t.getValue(e);
|
|
92
|
-
return l({
|
|
93
|
-
type: "insert",
|
|
94
|
-
index: Array.isArray(r) ? r.length : 0,
|
|
95
|
-
value: n
|
|
96
|
-
});
|
|
97
|
-
},
|
|
98
|
-
prepend: (e) => l({
|
|
99
|
-
type: "insert",
|
|
100
|
-
index: 0,
|
|
101
|
-
value: e
|
|
102
|
-
}),
|
|
103
|
-
insert: (e, t) => l({
|
|
104
|
-
type: "insert",
|
|
105
|
-
index: e,
|
|
106
|
-
value: t
|
|
107
|
-
}),
|
|
108
|
-
remove: (e) => l({
|
|
109
|
-
type: "remove",
|
|
110
|
-
index: e
|
|
111
|
-
}),
|
|
112
|
-
move: (e, t) => l({
|
|
113
|
-
type: "move",
|
|
114
|
-
from: e,
|
|
115
|
-
to: t
|
|
116
|
-
}),
|
|
117
|
-
update: (e, t) => l({
|
|
118
|
-
type: "update",
|
|
119
|
-
index: e,
|
|
120
|
-
value: t
|
|
121
|
-
}),
|
|
122
|
-
replace: (n) => t.setValue(e, n)
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
function re(e = (e) => e) {
|
|
126
|
-
let t = q(), n = m(null), r = l(() => {
|
|
127
|
-
let r = e(t.getFormSummary());
|
|
128
|
-
return n.current && v(n.current.value, r) ? n.current.value : (n.current = { value: r }, r);
|
|
129
|
-
}, [t, e]);
|
|
130
|
-
return g(t.subscribeAll, r, r);
|
|
131
|
-
}
|
|
132
|
-
function ie() {
|
|
133
|
-
let e = q();
|
|
134
|
-
return g(e.subscribeAll, e.getVersion, e.getVersion), {
|
|
135
|
-
values: e.getValues(),
|
|
136
|
-
changedValues: e.getChangedValues()
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
var ae = (e) => e, oe = {
|
|
140
|
-
imageUpload: r,
|
|
141
|
-
input: b,
|
|
142
|
-
number: E,
|
|
143
|
-
password: O,
|
|
144
|
-
textarea: C,
|
|
145
|
-
switch: S,
|
|
146
|
-
checkbox: T,
|
|
147
|
-
radio: x,
|
|
148
|
-
checkboxGroup: D,
|
|
149
|
-
select: j,
|
|
150
|
-
multiSelect: M,
|
|
151
|
-
treeSelect: N,
|
|
152
|
-
date: B,
|
|
153
|
-
dateRange: R,
|
|
154
|
-
time: te,
|
|
155
|
-
timeRange: F,
|
|
156
|
-
dateTime: ee,
|
|
157
|
-
dateTimeRange: I,
|
|
158
|
-
month: P,
|
|
159
|
-
year: L,
|
|
160
|
-
monthRange: z,
|
|
161
|
-
yearRange: V,
|
|
162
|
-
search: w,
|
|
163
|
-
segmented: A,
|
|
164
|
-
slider: i,
|
|
165
|
-
rangeSlider: a
|
|
166
|
-
};
|
|
167
|
-
function X({ label: e, description: t, error: n, required: r, id: i, children: a, span: o = 1 }) {
|
|
168
|
-
return /* @__PURE__ */ U("div", {
|
|
169
|
-
className: "rfe-field",
|
|
170
|
-
style: { gridColumn: `span ${o}` },
|
|
171
|
-
children: [e && /* @__PURE__ */ U("label", {
|
|
172
|
-
htmlFor: i,
|
|
173
|
-
className: "rfe-field-label",
|
|
174
|
-
children: [e, r && /* @__PURE__ */ H("span", {
|
|
175
|
-
className: "rfe-required",
|
|
176
|
-
children: " *"
|
|
177
|
-
})]
|
|
178
|
-
}), /* @__PURE__ */ U("div", {
|
|
179
|
-
className: "rfe-field-content",
|
|
180
|
-
children: [a, n ? /* @__PURE__ */ H("div", {
|
|
181
|
-
id: i ? `${i}-help` : void 0,
|
|
182
|
-
role: "alert",
|
|
183
|
-
className: "rfe-error",
|
|
184
|
-
children: n
|
|
185
|
-
}) : t && /* @__PURE__ */ H("div", {
|
|
186
|
-
id: i ? `${i}-help` : void 0,
|
|
187
|
-
className: "rfe-description",
|
|
188
|
-
children: t
|
|
189
|
-
})]
|
|
190
|
-
})]
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
var Z = (e, t) => typeof e.visible == "function" ? e.visible(t) : e.visible !== !1;
|
|
194
|
-
function se(e) {
|
|
195
|
-
return [
|
|
196
|
-
...e.required && !e.rules?.some((e) => e.required) ? [{ required: !0 }] : [],
|
|
197
|
-
...e.rules ?? [],
|
|
198
|
-
...e.type === "imageUpload" && e.componentProps?.mode === "upload" ? [n] : []
|
|
199
|
-
];
|
|
200
|
-
}
|
|
201
|
-
function ce({ field: n, components: r, fields: i, validateOn: a }) {
|
|
202
|
-
let o = q(), s = J(n.name), c = e(), u = f(), m = n.dependsOn, h = p(() => ({
|
|
203
|
-
rules: se(n),
|
|
204
|
-
debounce: n.debounce,
|
|
205
|
-
dependsOn: m,
|
|
206
|
-
validateOn: n.validateOn ?? a,
|
|
207
|
-
defaultValue: n.defaultValue,
|
|
208
|
-
visible: (e) => Z(n, e)
|
|
209
|
-
}), [
|
|
210
|
-
n,
|
|
211
|
-
m,
|
|
212
|
-
a
|
|
213
|
-
]);
|
|
214
|
-
d(() => o.registerField(n.name, { ...h }), [o, n.name]), d(() => o.updateField(n.name, h), [
|
|
215
|
-
o,
|
|
216
|
-
n.name,
|
|
217
|
-
h
|
|
218
|
-
]);
|
|
219
|
-
let _ = l((e) => {
|
|
220
|
-
if (!m) return typeof n.visible == "function" || typeof n.disabled == "function" ? o.subscribeAll(e) : () => {};
|
|
221
|
-
let t = m.map((t) => o.subscribe(t, e));
|
|
222
|
-
return () => t.forEach((e) => e());
|
|
223
|
-
}, [
|
|
224
|
-
o,
|
|
225
|
-
m,
|
|
226
|
-
n.visible,
|
|
227
|
-
n.disabled
|
|
228
|
-
]);
|
|
229
|
-
g(_, o.getVersion, o.getVersion);
|
|
230
|
-
let v = typeof n.visible == "function" || typeof n.disabled == "function" ? o.getValues() : $;
|
|
231
|
-
if (!Z(n, v)) return null;
|
|
232
|
-
let y = r[n.type] ?? oe[n.type], b = {
|
|
233
|
-
...n.componentProps,
|
|
234
|
-
id: u,
|
|
235
|
-
name: n.name,
|
|
236
|
-
value: s.value ?? ([
|
|
237
|
-
"input",
|
|
238
|
-
"password",
|
|
239
|
-
"textarea",
|
|
240
|
-
"search"
|
|
241
|
-
].includes(n.type) ? "" : n.type === "switch" || n.type === "checkbox" ? !1 : n.type === "imageUpload" || n.type === "multiSelect" || n.type === "checkboxGroup" || n.type === "treeSelect" && n.componentProps?.multiple ? [] : n.type === "slider" ? 0 : n.type === "rangeSlider" ? [0, 100] : null),
|
|
242
|
-
onChange: (e) => {
|
|
243
|
-
o.setValue(n.name, e);
|
|
244
|
-
},
|
|
245
|
-
onBlur: () => {
|
|
246
|
-
o.blur(n.name);
|
|
247
|
-
},
|
|
248
|
-
status: s.error ? "error" : "default",
|
|
249
|
-
"aria-invalid": !!s.error,
|
|
250
|
-
disabled: typeof n.disabled == "function" ? n.disabled(v) : n.disabled ?? n.componentProps?.disabled,
|
|
251
|
-
"aria-describedby": s.error || n.description ? `${u}-help` : void 0
|
|
252
|
-
};
|
|
253
|
-
return /* @__PURE__ */ U(X, {
|
|
254
|
-
label: n.label,
|
|
255
|
-
required: n.required,
|
|
256
|
-
description: n.description,
|
|
257
|
-
error: t(s.issue, s.error, c),
|
|
258
|
-
id: u,
|
|
259
|
-
span: n.span,
|
|
260
|
-
children: [n.render ? n.render(b) : y ? /* @__PURE__ */ H(y, { ...b }) : /* @__PURE__ */ H("div", {
|
|
261
|
-
className: "rfe-error",
|
|
262
|
-
children: c.t("unknownField", { type: n.type })
|
|
263
|
-
}), s.validating && /* @__PURE__ */ H("small", {
|
|
264
|
-
role: "status",
|
|
265
|
-
className: "rfe-description",
|
|
266
|
-
children: c.t("validating")
|
|
267
|
-
})]
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
var Q = s("blur"), le = [], $ = {}, ue = {};
|
|
271
|
-
function de({ nested: t, initialValues: n, adapter: r, submitHiddenFields: i = !1, validateOn: a = "blur", form: o, fields: s = le, defaultValues: c = $, components: l = ue, children: u, columns: d = 1, layout: f = "vertical", onSubmit: p, onError: g, submitText: _, resetText: v, showActions: y = !0 }) {
|
|
272
|
-
let b = e(), x = G(o ? {} : {
|
|
273
|
-
fields: s,
|
|
274
|
-
defaultValues: c,
|
|
275
|
-
initialValues: n,
|
|
276
|
-
adapter: r,
|
|
277
|
-
nested: t
|
|
278
|
-
}), S = o ?? x, [C, w] = h(!1), [T, E] = h(""), D = m(!1), O = m(null);
|
|
279
|
-
return /* @__PURE__ */ H(K, {
|
|
280
|
-
form: S,
|
|
281
|
-
children: /* @__PURE__ */ H(Q.Provider, {
|
|
282
|
-
value: a,
|
|
283
|
-
children: /* @__PURE__ */ U("form", {
|
|
284
|
-
ref: O,
|
|
285
|
-
className: "rfe-form",
|
|
286
|
-
"data-layout": f,
|
|
287
|
-
noValidate: !0,
|
|
288
|
-
onSubmit: async (e) => {
|
|
289
|
-
if (e.preventDefault(), !D.current) {
|
|
290
|
-
D.current = !0, w(!0), E("");
|
|
291
|
-
try {
|
|
292
|
-
let e = S.getDataVersion(), t = await S.validate();
|
|
293
|
-
if (S.getDataVersion() !== e || !t) {
|
|
294
|
-
requestAnimationFrame(() => O.current?.querySelector("[aria-invalid=\"true\"]")?.focus());
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
await p?.(S.getSubmitValues(i));
|
|
298
|
-
} catch (e) {
|
|
299
|
-
E(e instanceof Error ? e.message : b.t("submitFailed")), g?.(e);
|
|
300
|
-
} finally {
|
|
301
|
-
D.current = !1, w(!1);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
},
|
|
305
|
-
children: [
|
|
306
|
-
/* @__PURE__ */ U("div", {
|
|
307
|
-
className: "rfe-form-grid",
|
|
308
|
-
style: { gridTemplateColumns: `repeat(${Math.max(1, d)},minmax(0,1fr))` },
|
|
309
|
-
children: [s.map((e) => /* @__PURE__ */ H(ce, {
|
|
310
|
-
field: e,
|
|
311
|
-
components: l,
|
|
312
|
-
fields: s,
|
|
313
|
-
validateOn: a
|
|
314
|
-
}, e.name)), u]
|
|
315
|
-
}),
|
|
316
|
-
T && /* @__PURE__ */ H("div", {
|
|
317
|
-
role: "alert",
|
|
318
|
-
className: "rfe-error",
|
|
319
|
-
children: T
|
|
320
|
-
}),
|
|
321
|
-
y && /* @__PURE__ */ U("div", {
|
|
322
|
-
className: "rfe-form-actions",
|
|
323
|
-
children: [/* @__PURE__ */ H(k, {
|
|
324
|
-
variant: "secondary",
|
|
325
|
-
disabled: C,
|
|
326
|
-
onClick: () => {
|
|
327
|
-
S.reset(), E("");
|
|
328
|
-
},
|
|
329
|
-
children: v ?? b.t("reset")
|
|
330
|
-
}), /* @__PURE__ */ H(k, {
|
|
331
|
-
type: "submit",
|
|
332
|
-
loading: C,
|
|
333
|
-
children: _ ?? b.t("save")
|
|
334
|
-
})]
|
|
335
|
-
})
|
|
336
|
-
]
|
|
337
|
-
})
|
|
338
|
-
})
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
function fe({ children: i, name: a, label: s, description: m, required: h, rules: _, defaultValue: v, dependsOn: y, debounce: b, validateOn: x, span: S, disabled: C, visible: w, componentProps: T }) {
|
|
342
|
-
let E = q(), D = u(Q), O = x ?? D, k = J(a), A = e(), j = f(), M = c(i) && i.type === r && i.props.mode === "upload", N = p(() => ({
|
|
343
|
-
rules: [
|
|
344
|
-
...h && !_?.some((e) => e.required) ? [{ required: !0 }] : [],
|
|
345
|
-
..._ ?? [],
|
|
346
|
-
...M ? [n] : []
|
|
347
|
-
],
|
|
348
|
-
defaultValue: v,
|
|
349
|
-
dependsOn: y,
|
|
350
|
-
debounce: b,
|
|
351
|
-
validateOn: O,
|
|
352
|
-
visible: (e) => typeof w == "function" ? w(e) : w !== !1
|
|
353
|
-
}), [
|
|
354
|
-
h,
|
|
355
|
-
_,
|
|
356
|
-
v,
|
|
357
|
-
y,
|
|
358
|
-
b,
|
|
359
|
-
O,
|
|
360
|
-
w,
|
|
361
|
-
M
|
|
362
|
-
]);
|
|
363
|
-
d(() => E.registerField(a, { ...N }), [E, a]), d(() => E.updateField(a, N), [
|
|
364
|
-
E,
|
|
365
|
-
a,
|
|
366
|
-
N
|
|
367
|
-
]);
|
|
368
|
-
let P = l((e) => typeof w == "function" || typeof C == "function" ? E.subscribeAll(e) : () => {}, [
|
|
369
|
-
E,
|
|
370
|
-
w,
|
|
371
|
-
C
|
|
372
|
-
]);
|
|
373
|
-
g(P, E.getVersion, E.getVersion);
|
|
374
|
-
let F = typeof w == "function" || typeof C == "function" ? E.getValues() : $;
|
|
375
|
-
if (!N.visible(F)) return null;
|
|
376
|
-
let I = {
|
|
377
|
-
...T,
|
|
378
|
-
id: j,
|
|
379
|
-
name: a,
|
|
380
|
-
value: k.value,
|
|
381
|
-
onChange: (e) => {
|
|
382
|
-
E.setValue(a, e);
|
|
383
|
-
},
|
|
384
|
-
onBlur: () => {
|
|
385
|
-
E.blur(a);
|
|
386
|
-
},
|
|
387
|
-
disabled: typeof C == "function" ? C(F) : C,
|
|
388
|
-
status: k.error ? "error" : "default",
|
|
389
|
-
"aria-invalid": !!k.error,
|
|
390
|
-
"aria-describedby": k.error || m ? `${j}-help` : void 0
|
|
391
|
-
};
|
|
392
|
-
return /* @__PURE__ */ U(X, {
|
|
393
|
-
id: j,
|
|
394
|
-
label: s,
|
|
395
|
-
required: h,
|
|
396
|
-
description: m,
|
|
397
|
-
error: t(k.issue, k.error, A),
|
|
398
|
-
span: S,
|
|
399
|
-
children: [typeof i == "function" ? i(I) : c(i) ? o(i, I) : i, k.validating && /* @__PURE__ */ H("small", {
|
|
400
|
-
role: "status",
|
|
401
|
-
className: "rfe-description",
|
|
402
|
-
children: A.t("validating")
|
|
403
|
-
})]
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
var pe = Object.assign(de, { Field: fe }), me = (e) => e;
|
|
407
|
-
export { ae as a, G as c, re as d, Y as f, me as i, q as l, X as n, J as o, K as r, ne as s, pe as t, ie as u };
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { a as e, i as t, r as n } from "./useControllable-Dl8gno_5.js";
|
|
2
|
-
import { useCallback as r, useId as i, useState as a, useSyncExternalStore as o } from "react";
|
|
3
|
-
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
4
|
-
import { FloatingFocusManager as l, FloatingNode as u, FloatingOverlay as d, FloatingPortal as f, FloatingTree as p, autoUpdate as m, flip as h, offset as g, shift as _, size as v, useDismiss as y, useFloating as b, useFloatingNodeId as x, useFloatingTree as S, useInteractions as C, useRole as ee, useTransitionStyles as w } from "@floating-ui/react";
|
|
5
|
-
// src/primitives/Popup.tsx
|
|
6
|
-
var T = "(max-width: 560px)", te = (e) => {
|
|
7
|
-
let t = window.matchMedia(T);
|
|
8
|
-
return t.addEventListener("change", e), () => t.removeEventListener("change", e);
|
|
9
|
-
}, E = () => typeof window < "u" && window.matchMedia(T).matches;
|
|
10
|
-
function D(e) {
|
|
11
|
-
return S() ? /* @__PURE__ */ s(O, { ...e }) : /* @__PURE__ */ s(p, { children: /* @__PURE__ */ s(O, { ...e }) });
|
|
12
|
-
}
|
|
13
|
-
function O({ open: p, onOpenChange: S, children: T, trigger: D, placement: O = "bottom-start", popupWidth: k = "trigger", popupMaxHeight: A = 320, portalContainer: j, role: M = "dialog", label: N, popupMode: P, layout: F = "content" }) {
|
|
14
|
-
let I = t(), L = e(), R = i(), z = x(), B = o(te, E, () => !1), V = P ?? I.popupMode, H = V === "sheet" || V === "auto" && B, [U, W] = a(null), { refs: G, floatingStyles: K, context: q, placement: J } = b({
|
|
15
|
-
nodeId: z,
|
|
16
|
-
open: p,
|
|
17
|
-
onOpenChange: S,
|
|
18
|
-
placement: O,
|
|
19
|
-
strategy: H ? "fixed" : "absolute",
|
|
20
|
-
whileElementsMounted: H ? void 0 : m,
|
|
21
|
-
middleware: H ? [] : [
|
|
22
|
-
g(6),
|
|
23
|
-
h(),
|
|
24
|
-
_({ padding: 8 }),
|
|
25
|
-
v({
|
|
26
|
-
padding: 8,
|
|
27
|
-
apply({ availableHeight: e, availableWidth: t, rects: n, elements: r }) {
|
|
28
|
-
Object.assign(r.floating.style, {
|
|
29
|
-
maxHeight: `${Math.max(0, Math.min(e, A))}px`,
|
|
30
|
-
maxWidth: `${Math.max(0, t)}px`,
|
|
31
|
-
width: `${Math.max(0, Math.min(t, k === "trigger" ? n.reference.width : k))}px`
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
]
|
|
36
|
-
}), Y = r((e) => {
|
|
37
|
-
G.setReference(e), W(e?.closest("dialog[open]") ?? null);
|
|
38
|
-
}, [G.setReference]), X = y(q, { bubbles: {
|
|
39
|
-
escapeKey: !1,
|
|
40
|
-
outsidePress: !0
|
|
41
|
-
} }), Z = ee(q, { role: M }), { getReferenceProps: Q, getFloatingProps: ne } = C([X, Z]), { isMounted: re, styles: ie } = w(q, {
|
|
42
|
-
duration: I.motion ? {
|
|
43
|
-
open: 160,
|
|
44
|
-
close: 100
|
|
45
|
-
} : 0,
|
|
46
|
-
initial: ({ side: e }) => ({
|
|
47
|
-
opacity: 0,
|
|
48
|
-
transform: H ? "translateY(16px)" : `translateY(${e === "top" ? 4 : -4}px) scale(.985)`
|
|
49
|
-
})
|
|
50
|
-
}), ae = {
|
|
51
|
-
lang: L.code,
|
|
52
|
-
dir: L.direction,
|
|
53
|
-
"data-theme": I.theme,
|
|
54
|
-
"data-density": I.density,
|
|
55
|
-
"data-motion": I.motion ? "on" : "off"
|
|
56
|
-
}, $ = /* @__PURE__ */ s(l, {
|
|
57
|
-
context: q,
|
|
58
|
-
modal: H,
|
|
59
|
-
initialFocus: 0,
|
|
60
|
-
disabled: !p,
|
|
61
|
-
returnFocus: !0,
|
|
62
|
-
children: /* @__PURE__ */ s("div", {
|
|
63
|
-
...ae,
|
|
64
|
-
className: "rfe-scope rfe-popup-position",
|
|
65
|
-
"data-sheet": H || void 0,
|
|
66
|
-
ref: G.setFloating,
|
|
67
|
-
style: {
|
|
68
|
-
...n(I.tokens),
|
|
69
|
-
...H ? {
|
|
70
|
-
position: "fixed",
|
|
71
|
-
insetInline: 0,
|
|
72
|
-
bottom: 0,
|
|
73
|
-
width: "100%",
|
|
74
|
-
maxWidth: "100%",
|
|
75
|
-
maxHeight: "85dvh"
|
|
76
|
-
} : K
|
|
77
|
-
},
|
|
78
|
-
...ne({
|
|
79
|
-
id: R,
|
|
80
|
-
"aria-label": N,
|
|
81
|
-
"aria-modal": H || void 0
|
|
82
|
-
}),
|
|
83
|
-
children: /* @__PURE__ */ c("div", {
|
|
84
|
-
className: "rfe-panel",
|
|
85
|
-
"data-layout": F,
|
|
86
|
-
"data-side": J.split("-")[0],
|
|
87
|
-
style: {
|
|
88
|
-
...ie,
|
|
89
|
-
pointerEvents: p ? "auto" : "none"
|
|
90
|
-
},
|
|
91
|
-
inert: !p,
|
|
92
|
-
children: [H && /* @__PURE__ */ s("span", {
|
|
93
|
-
className: "rfe-sheet-handle",
|
|
94
|
-
"aria-hidden": "true"
|
|
95
|
-
}), T]
|
|
96
|
-
})
|
|
97
|
-
})
|
|
98
|
-
});
|
|
99
|
-
return /* @__PURE__ */ c(u, {
|
|
100
|
-
id: z,
|
|
101
|
-
children: [D(Q({
|
|
102
|
-
"aria-expanded": p,
|
|
103
|
-
"aria-controls": p ? R : void 0
|
|
104
|
-
}), Y, R), re && /* @__PURE__ */ s(f, {
|
|
105
|
-
root: j ?? U ?? void 0,
|
|
106
|
-
children: H ? /* @__PURE__ */ s(d, {
|
|
107
|
-
lockScroll: p,
|
|
108
|
-
className: "rfe-sheet-overlay",
|
|
109
|
-
style: n(I.tokens),
|
|
110
|
-
children: $
|
|
111
|
-
}) : $
|
|
112
|
-
})]
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
// src/utils/selection.ts
|
|
116
|
-
function k(e, t, n, r) {
|
|
117
|
-
if (e <= 0) return -1;
|
|
118
|
-
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;
|
|
119
|
-
for (; o >= 0 && o < e;) {
|
|
120
|
-
if (r(o)) return o;
|
|
121
|
-
o += a;
|
|
122
|
-
}
|
|
123
|
-
return t >= 0 && t < e && r(t) ? t : -1;
|
|
124
|
-
}
|
|
125
|
-
function A(e, t, n, r, i = 1, a = 4) {
|
|
126
|
-
if (e <= 0 || i <= 0 || !n) return 0;
|
|
127
|
-
let o = (o) => {
|
|
128
|
-
let s = 1, c = 0, l = t.slice(0, o).map((t) => Math.min(t, e));
|
|
129
|
-
o < n && l.push(Math.min(r, e));
|
|
130
|
-
for (let t of l) if (c && c + a + t > e && (s++, c = 0), c += t + (c ? a : 0), s > i) return !1;
|
|
131
|
-
return !0;
|
|
132
|
-
}, s = Math.min(t.length, n);
|
|
133
|
-
for (; s > 0 && !o(s);) s--;
|
|
134
|
-
return s;
|
|
135
|
-
}
|
|
136
|
-
export { k as n, D as r, A as t };
|