jaguar-form 1.0.4 → 1.0.6
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 +38 -2
- package/dist/Cascader-ZIkXvvC3.js +226 -0
- package/dist/Select-BIBk_TT6.js +415 -0
- package/dist/TreeSelect-BQCyCCqa.js +350 -0
- package/dist/{compound-D4_6P0d_.js → compound-BX_PoTK5.js} +100 -88
- package/dist/compound.js +1 -1
- package/dist/core.js +1 -1
- package/dist/date-time.js +1 -1
- package/dist/demo-plant.svg +1 -0
- package/dist/form-CSfUExUT.js +599 -0
- package/dist/form.js +3 -3
- package/dist/{icons-BI3fdIey.js → icons-BwE05e0C.js} +1 -1
- package/dist/{image-upload-VtUlQgzJ.js → image-upload-D9oPG0Eh.js} +252 -179
- package/dist/image-upload.js +1 -1
- package/dist/index.js +15 -14
- package/dist/input.js +1 -1
- package/dist/inputs-Dx3xOy9q.js +718 -0
- package/dist/{useSelection-C0OEFZUE.js → lazy-tree-NCX3ntYm.js} +96 -4
- package/dist/locale/load.js +7 -3
- package/dist/pickers-Bci1y8cc.js +634 -0
- package/dist/select.js +3 -1
- package/dist/selection-DCIzhR5q.js +197 -0
- package/dist/{slider-CNwkLMmo.js → slider-AM0Egz9P.js} +1 -1
- package/dist/slider.js +1 -1
- package/dist/store-CFSQW-Fv.js +622 -0
- package/dist/style.css +1 -1
- package/dist/tree-select.js +1 -1
- package/dist/types/components/compound/ControlGroup.d.ts +5 -2
- package/dist/types/components/compound/index.d.ts +10 -1
- package/dist/types/components/extended-inputs.d.ts +34 -0
- package/dist/types/components/image-upload/ManagedImageUpload.d.ts +11 -4
- package/dist/types/components/image-upload/index.d.ts +3 -2
- package/dist/types/components/image-upload/upload.d.ts +1 -1
- package/dist/types/components/image-upload/usePreparation.d.ts +7 -0
- package/dist/types/components/image-upload/validation.d.ts +16 -0
- package/dist/types/components/inputs.d.ts +42 -4
- package/dist/types/components/select/Cascader.d.ts +13 -0
- package/dist/types/components/select/types.d.ts +10 -1
- package/dist/types/components/select/useRemoteOptions.d.ts +18 -0
- package/dist/types/components/select.d.ts +3 -0
- package/dist/types/config/index.d.ts +3 -0
- package/dist/types/entries/input.d.ts +5 -2
- package/dist/types/entries/select.d.ts +3 -0
- package/dist/types/form/adapter.d.ts +1 -0
- package/dist/types/form/index.d.ts +85 -10
- package/dist/types/form/store.d.ts +21 -1
- package/dist/types/locale/load.d.ts +2 -1
- package/dist/types/primitives/Control.d.ts +3 -1
- package/dist/types/primitives/Popup.d.ts +1 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/utils/cascader.d.ts +12 -0
- package/dist/types/utils/decimal.d.ts +22 -0
- package/dist/types/utils/remote-options.d.ts +24 -0
- package/dist/useControllable-QDX_UWRh.js +102 -0
- package/package.json +1 -1
- package/dist/Control-B36bu6zQ.js +0 -47
- package/dist/Select-BG2H-YnK.js +0 -252
- package/dist/TreeSelect-CkPtMg-g.js +0 -440
- package/dist/form-DTI0Sqsy.js +0 -413
- package/dist/inputs-BOP8Ryne.js +0 -403
- package/dist/pickers-C9QTR2XN.js +0 -631
- package/dist/selection-CIEa1uce.js +0 -146
- package/dist/store-DOn9K-EA.js +0 -491
- package/dist/useControllable-Zax42z2F.js +0 -87
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect as e, useId as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
|
|
2
|
-
import { a, i as o, s, t as c } from "./useControllable-
|
|
3
|
-
import { t as l } from "./icons-
|
|
2
|
+
import { a, i as o, s, t as c } from "./useControllable-QDX_UWRh.js";
|
|
3
|
+
import { t as l } from "./icons-BwE05e0C.js";
|
|
4
4
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
5
5
|
// src/components/image-upload/validation.ts
|
|
6
6
|
var f = "image/jpeg,image/png,image/webp";
|
|
@@ -28,9 +28,21 @@ function h(e, t, n) {
|
|
|
28
28
|
let r = [...e];
|
|
29
29
|
return r.splice(n, 0, r.splice(t, 1)[0]), r;
|
|
30
30
|
}
|
|
31
|
+
function g(e, t, n, r = !1) {
|
|
32
|
+
let i = r && t === 1 && e >= 1;
|
|
33
|
+
return {
|
|
34
|
+
full: e >= t && !i,
|
|
35
|
+
replacing: i,
|
|
36
|
+
remaining: i ? 1 : Math.max(0, t - e)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function _(e, t = 3) {
|
|
40
|
+
let n = Number.isFinite(t) ? Math.max(0, Math.floor(t)) : 3;
|
|
41
|
+
return e ? n : Math.min(1, n);
|
|
42
|
+
}
|
|
31
43
|
// src/components/image-upload/sorting.tsx
|
|
32
|
-
var
|
|
33
|
-
function
|
|
44
|
+
var v = "application/x-rfe-image-sort";
|
|
45
|
+
function y(e, n, a) {
|
|
34
46
|
let o = t(), s = r(null), [c, l] = i(null), u = (t, r) => {
|
|
35
47
|
a && t !== r && t >= 0 && r >= 0 && t < e.length && r < e.length && n(h(e, t, r));
|
|
36
48
|
}, d = () => {
|
|
@@ -41,13 +53,13 @@ function _(e, n, a) {
|
|
|
41
53
|
row: (e) => ({
|
|
42
54
|
"data-sort-over": c === e || void 0,
|
|
43
55
|
onDragOver: (t) => {
|
|
44
|
-
a && s.current !== null && t.dataTransfer.types.includes(
|
|
56
|
+
a && s.current !== null && t.dataTransfer.types.includes(v) && (t.preventDefault(), t.stopPropagation(), t.dataTransfer.dropEffect = "move", l(e));
|
|
45
57
|
},
|
|
46
58
|
onDragLeave: (t) => {
|
|
47
59
|
t.relatedTarget instanceof Node && t.currentTarget.contains(t.relatedTarget) || l((t) => t === e ? null : t);
|
|
48
60
|
},
|
|
49
61
|
onDrop: (t) => {
|
|
50
|
-
if (s.current === null || t.dataTransfer.getData(
|
|
62
|
+
if (s.current === null || t.dataTransfer.getData(v) !== o) return;
|
|
51
63
|
t.preventDefault(), t.stopPropagation();
|
|
52
64
|
let n = s.current;
|
|
53
65
|
d(), u(n, e);
|
|
@@ -55,12 +67,12 @@ function _(e, n, a) {
|
|
|
55
67
|
}),
|
|
56
68
|
move: u,
|
|
57
69
|
dragStart: (e, t) => {
|
|
58
|
-
a ? (s.current = e, t.dataTransfer.effectAllowed = "move", t.dataTransfer.setData(
|
|
70
|
+
a ? (s.current = e, t.dataTransfer.effectAllowed = "move", t.dataTransfer.setData(v, o), t.dataTransfer.setData("text/plain", o)) : t.preventDefault();
|
|
59
71
|
},
|
|
60
72
|
reset: d
|
|
61
73
|
};
|
|
62
74
|
}
|
|
63
|
-
function
|
|
75
|
+
function b({ index: e, count: t, name: n, onMove: r, onDragStart: i, onDragEnd: o }) {
|
|
64
76
|
let { t: s } = a();
|
|
65
77
|
return /* @__PURE__ */ d("div", {
|
|
66
78
|
className: "rfe-image-sort",
|
|
@@ -95,8 +107,46 @@ function v({ index: e, count: t, name: n, onMove: r, onDragStart: i, onDragEnd:
|
|
|
95
107
|
]
|
|
96
108
|
});
|
|
97
109
|
}
|
|
110
|
+
// src/components/image-upload/usePreparation.ts
|
|
111
|
+
function x(t, n) {
|
|
112
|
+
let a = r(null), [o, s] = i(!1), c = () => {
|
|
113
|
+
a.current?.abort(), a.current = null, s(!1);
|
|
114
|
+
};
|
|
115
|
+
return e(() => () => {
|
|
116
|
+
a.current?.abort(), a.current = null;
|
|
117
|
+
}, []), e(() => {
|
|
118
|
+
n && c();
|
|
119
|
+
}, [n]), {
|
|
120
|
+
busy: o,
|
|
121
|
+
cancel: c,
|
|
122
|
+
prepare: async (e, r) => {
|
|
123
|
+
if (n || a.current) return;
|
|
124
|
+
if (!t.beforeUpload) {
|
|
125
|
+
r(e);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
let i = new AbortController();
|
|
129
|
+
a.current = i, s(!0);
|
|
130
|
+
try {
|
|
131
|
+
let n = [];
|
|
132
|
+
for (let r of e) {
|
|
133
|
+
if (i.signal.aborted) return;
|
|
134
|
+
try {
|
|
135
|
+
let e = await t.beforeUpload(r, { signal: i.signal });
|
|
136
|
+
e !== !1 && n.push(e);
|
|
137
|
+
} catch (e) {
|
|
138
|
+
i.signal.aborted || t.onPrepareError?.(e, r);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
!i.signal.aborted && a.current === i && r(n);
|
|
142
|
+
} finally {
|
|
143
|
+
a.current === i && (a.current = null, s(!1));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
98
148
|
// src/components/image-upload/upload.ts
|
|
99
|
-
function
|
|
149
|
+
function S(e) {
|
|
100
150
|
if (typeof e != "string" || !e.trim()) return !1;
|
|
101
151
|
try {
|
|
102
152
|
return ["http:", "https:"].includes(new URL(e, "https://example.invalid").protocol);
|
|
@@ -104,14 +154,14 @@ function y(e) {
|
|
|
104
154
|
return !1;
|
|
105
155
|
}
|
|
106
156
|
}
|
|
107
|
-
var
|
|
157
|
+
var C = { validate: (e) => {
|
|
108
158
|
if (e != null) {
|
|
109
159
|
if (!Array.isArray(e)) return { code: "invalidType" };
|
|
110
160
|
if (e.some((e) => e?.status === "uploading" || e?.status === "ready")) return { code: "processing" };
|
|
111
|
-
if (e.some((e) => e?.status !== "success" || !
|
|
161
|
+
if (e.some((e) => e?.status !== "success" || !S(e.url))) return { code: "validationFailed" };
|
|
112
162
|
}
|
|
113
163
|
} };
|
|
114
|
-
function
|
|
164
|
+
function w(e) {
|
|
115
165
|
let t = /* @__PURE__ */ new Map(), n = (e) => {
|
|
116
166
|
let n = t.get(e);
|
|
117
167
|
n && (t.delete(e), n.abort());
|
|
@@ -145,7 +195,7 @@ function x(e) {
|
|
|
145
195
|
});
|
|
146
196
|
if (!o()) return !1;
|
|
147
197
|
let s = typeof n == "string" ? n : n.url;
|
|
148
|
-
if (!
|
|
198
|
+
if (!S(s)) throw Error("Invalid uploaded image URL");
|
|
149
199
|
return t.delete(r.uid), e(r.uid, {
|
|
150
200
|
url: s,
|
|
151
201
|
name: typeof n == "string" ? r.name : n.name ?? r.name,
|
|
@@ -164,9 +214,9 @@ function x(e) {
|
|
|
164
214
|
};
|
|
165
215
|
}
|
|
166
216
|
// src/components/image-upload/ManagedImageUpload.tsx
|
|
167
|
-
var
|
|
217
|
+
var T = [], E = 0;
|
|
168
218
|
function ee({ item: t, blocked: n, preview: o, onRemove: s, onRetry: c, onCancel: f, icons: p, sortActions: m, sortProps: h }) {
|
|
169
|
-
let { t: g } = a(), [_, v] = i(""), [
|
|
219
|
+
let { t: g } = a(), [_, v] = i(""), [y, b] = i(!1), x = r(null);
|
|
170
220
|
e(() => {
|
|
171
221
|
if (!t.file) {
|
|
172
222
|
v("");
|
|
@@ -175,8 +225,8 @@ function ee({ item: t, blocked: n, preview: o, onRemove: s, onRetry: c, onCancel
|
|
|
175
225
|
let e = URL.createObjectURL(t.file);
|
|
176
226
|
return v(e), () => URL.revokeObjectURL(e);
|
|
177
227
|
}, [t.file]);
|
|
178
|
-
let C =
|
|
179
|
-
return e(() =>
|
|
228
|
+
let C = S(t.url) ? t.url : _;
|
|
229
|
+
return e(() => b(!1), [C]), /* @__PURE__ */ d("div", {
|
|
180
230
|
className: "rfe-image-tile",
|
|
181
231
|
"data-upload-status": t.status,
|
|
182
232
|
...h,
|
|
@@ -184,19 +234,19 @@ function ee({ item: t, blocked: n, preview: o, onRemove: s, onRetry: c, onCancel
|
|
|
184
234
|
/* @__PURE__ */ d("div", {
|
|
185
235
|
className: "rfe-image-media",
|
|
186
236
|
children: [
|
|
187
|
-
C && !
|
|
237
|
+
C && !y ? /* @__PURE__ */ u("img", {
|
|
188
238
|
src: C,
|
|
189
239
|
alt: t.name,
|
|
190
|
-
onError: () =>
|
|
240
|
+
onError: () => b(!0)
|
|
191
241
|
}) : /* @__PURE__ */ u("div", {
|
|
192
242
|
className: "rfe-image-placeholder",
|
|
193
243
|
children: /* @__PURE__ */ u(l, { name: "empty" })
|
|
194
244
|
}),
|
|
195
|
-
o && C && !
|
|
245
|
+
o && C && !y && /* @__PURE__ */ u("button", {
|
|
196
246
|
type: "button",
|
|
197
247
|
className: "rfe-image-preview",
|
|
198
248
|
"aria-label": `${g("preview")} ${t.name}`,
|
|
199
|
-
onClick: () =>
|
|
249
|
+
onClick: () => x.current?.showModal(),
|
|
200
250
|
children: /* @__PURE__ */ u(l, {
|
|
201
251
|
name: "passwordVisible",
|
|
202
252
|
source: p?.preview
|
|
@@ -258,17 +308,17 @@ function ee({ item: t, blocked: n, preview: o, onRemove: s, onRetry: c, onCancel
|
|
|
258
308
|
}),
|
|
259
309
|
m,
|
|
260
310
|
o && /* @__PURE__ */ d("dialog", {
|
|
261
|
-
ref:
|
|
311
|
+
ref: x,
|
|
262
312
|
className: "rfe-image-dialog",
|
|
263
313
|
"aria-label": t.name,
|
|
264
314
|
onClick: (e) => {
|
|
265
|
-
e.target === e.currentTarget &&
|
|
315
|
+
e.target === e.currentTarget && x.current?.close();
|
|
266
316
|
},
|
|
267
317
|
children: [/* @__PURE__ */ u("button", {
|
|
268
318
|
type: "button",
|
|
269
319
|
className: "rfe-image-dialog-close",
|
|
270
320
|
"aria-label": g("closePreview"),
|
|
271
|
-
onClick: () =>
|
|
321
|
+
onClick: () => x.current?.close(),
|
|
272
322
|
children: /* @__PURE__ */ u(l, { name: "clear" })
|
|
273
323
|
}), C && /* @__PURE__ */ u("img", {
|
|
274
324
|
src: C,
|
|
@@ -278,113 +328,126 @@ function ee({ item: t, blocked: n, preview: o, onRemove: s, onRetry: c, onCancel
|
|
|
278
328
|
]
|
|
279
329
|
});
|
|
280
330
|
}
|
|
281
|
-
function
|
|
282
|
-
let { t: f } = a(), p = o(), h = t(),
|
|
283
|
-
|
|
331
|
+
function D(c) {
|
|
332
|
+
let { t: f } = a(), p = o(), h = t(), v = c.id ?? h, [S, C] = i(c.defaultValue ?? T), D = c.value ?? S, O = r(D), k = r(() => {}), [A] = i(() => w((e, t) => {
|
|
333
|
+
O.current.some((t) => t.uid === e) && k.current(O.current.map((n) => n.uid === e ? {
|
|
284
334
|
...n,
|
|
285
335
|
...t
|
|
286
336
|
} : n));
|
|
287
|
-
})), [
|
|
337
|
+
})), [j, te] = i([]), [ne, M] = i(!1), N = r(null);
|
|
288
338
|
n(() => {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
},
|
|
339
|
+
O.current = D, k.current = (e) => {
|
|
340
|
+
O.current = e, c.value === void 0 && C(e), c.onChange?.(e);
|
|
341
|
+
}, A.retain(new Set(D.filter((e) => e.status === "uploading").map((e) => e.uid)));
|
|
292
342
|
}, [
|
|
293
|
-
|
|
343
|
+
D,
|
|
294
344
|
c.value,
|
|
295
345
|
c.onChange,
|
|
296
|
-
|
|
297
|
-
]), e(() => () =>
|
|
298
|
-
let
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
346
|
+
A
|
|
347
|
+
]), e(() => () => A.dispose(), [A]);
|
|
348
|
+
let P = c.multiple !== !1, F = _(P, c.maxCount), I = F <= 1, L = c.maxSize ?? 5, re = c.accept ?? "image/jpeg,image/png,image/webp", R = !!(c.disabled || c.readOnly || c.loading), z = x(c, R), B = JSON.stringify(D.map((e) => e.uid)), ie = r(B);
|
|
349
|
+
n(() => {
|
|
350
|
+
ie.current !== B && z.cancel(), ie.current = B;
|
|
351
|
+
}, [B]);
|
|
352
|
+
let V = R || z.busy, { full: H } = g(D.length, F, P, c.replaceable), U = y(D, (e) => k.current(e), !!c.sortable && !V && P && D.length > 1), W = (e) => {
|
|
353
|
+
V || H || !e.length || z.prepare(e, (e) => {
|
|
354
|
+
let t = I ? [] : O.current, n = m([], e, {
|
|
355
|
+
maxCount: Math.max(0, F - t.length),
|
|
356
|
+
maxSize: L,
|
|
357
|
+
accept: re
|
|
358
|
+
});
|
|
359
|
+
if (te(n.rejected), n.rejected.length && c.onReject?.(n.rejected), !n.accepted.length) return;
|
|
360
|
+
if (I) {
|
|
361
|
+
A.dispose();
|
|
362
|
+
for (let e of O.current) c.onRemove?.(e);
|
|
363
|
+
}
|
|
364
|
+
let r = n.accepted.map((e) => ({
|
|
365
|
+
uid: `${v}-${++E}`,
|
|
366
|
+
name: e.name,
|
|
367
|
+
file: e,
|
|
368
|
+
status: c.mode === "mixed" ? "local" : "uploading",
|
|
369
|
+
progress: 0
|
|
370
|
+
}));
|
|
371
|
+
if (k.current([...t, ...r]), c.mode === "upload") for (let e of r) A.start(e, c.upload);
|
|
304
372
|
});
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
let
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
status: "uploading",
|
|
312
|
-
progress: 0
|
|
313
|
-
}));
|
|
314
|
-
E.current([...t, ...r]);
|
|
315
|
-
for (let e of r) D.start(e, c.upload);
|
|
316
|
-
}, V = (e) => {
|
|
317
|
-
L || (D.abort(e), E.current(T.current.filter((t) => t.uid !== e)), k([]));
|
|
318
|
-
}, te = (e) => {
|
|
319
|
-
L || (D.abort(e), E.current(T.current.map((t) => t.uid === e ? {
|
|
373
|
+
}, ae = (e) => {
|
|
374
|
+
if (V) return;
|
|
375
|
+
let t = O.current.find((t) => t.uid === e);
|
|
376
|
+
t && c.onRemove?.(t), A.abort(e), k.current(O.current.filter((t) => t.uid !== e)), te([]);
|
|
377
|
+
}, G = (e) => {
|
|
378
|
+
V || (A.abort(e), k.current(O.current.map((t) => t.uid === e ? {
|
|
320
379
|
...t,
|
|
321
380
|
status: "ready",
|
|
322
381
|
progress: 0
|
|
323
382
|
} : t)));
|
|
324
|
-
},
|
|
383
|
+
}, K = I && D.length ? f("replaceImage") : f("addImage"), q = c.status === "error" || c["aria-invalid"], J = [
|
|
384
|
+
c["aria-describedby"],
|
|
385
|
+
`${v}-hint`,
|
|
386
|
+
j.length ? `${v}-rejected` : void 0
|
|
387
|
+
].filter(Boolean).join(" "), oe = {
|
|
325
388
|
type: f("imageType"),
|
|
326
|
-
size: f("imageSize", { max:
|
|
389
|
+
size: f("imageSize", { max: L }),
|
|
327
390
|
count: f("imageCount")
|
|
328
391
|
};
|
|
329
392
|
return /* @__PURE__ */ d("div", {
|
|
330
393
|
role: "group",
|
|
331
|
-
id:
|
|
332
|
-
tabIndex:
|
|
394
|
+
id: H || c.readOnly ? v : void 0,
|
|
395
|
+
tabIndex: H && !c.disabled ? 0 : void 0,
|
|
333
396
|
className: s("rfe-image-upload", c.className),
|
|
334
397
|
style: c.style,
|
|
335
398
|
"data-size": c.size ?? p.size,
|
|
336
|
-
"data-status":
|
|
399
|
+
"data-status": q ? "error" : c.status ?? "default",
|
|
337
400
|
"data-disabled": c.disabled || void 0,
|
|
338
|
-
"data-dragging":
|
|
339
|
-
"aria-label": c["aria-label"] ??
|
|
340
|
-
"aria-describedby":
|
|
341
|
-
"aria-invalid":
|
|
342
|
-
"aria-busy":
|
|
401
|
+
"data-dragging": ne || void 0,
|
|
402
|
+
"aria-label": c["aria-label"] ?? K,
|
|
403
|
+
"aria-describedby": J,
|
|
404
|
+
"aria-invalid": q || void 0,
|
|
405
|
+
"aria-busy": z.busy || D.some((e) => e.status === "uploading") || void 0,
|
|
343
406
|
onBlur: (e) => {
|
|
344
407
|
e.currentTarget.contains(e.relatedTarget) || c.onBlur?.();
|
|
345
408
|
},
|
|
346
409
|
onDragOver: (e) => {
|
|
347
|
-
c.dragDrop !== !1 && e.dataTransfer.types.includes("Files") && (e.preventDefault(), e.dataTransfer.dropEffect =
|
|
410
|
+
c.dragDrop !== !1 && e.dataTransfer.types.includes("Files") && (e.preventDefault(), e.dataTransfer.dropEffect = V || H ? "none" : "copy", !V && !H && M(!0));
|
|
348
411
|
},
|
|
349
412
|
onDragLeave: (e) => {
|
|
350
|
-
e.relatedTarget instanceof Node && e.currentTarget.contains(e.relatedTarget) ||
|
|
413
|
+
e.relatedTarget instanceof Node && e.currentTarget.contains(e.relatedTarget) || M(!1);
|
|
351
414
|
},
|
|
352
415
|
onDrop: (e) => {
|
|
353
|
-
c.dragDrop !== !1 && e.dataTransfer.types.includes("Files") && (e.preventDefault(),
|
|
416
|
+
c.dragDrop !== !1 && e.dataTransfer.types.includes("Files") && (e.preventDefault(), M(!1), W(Array.from(e.dataTransfer.files)));
|
|
354
417
|
},
|
|
355
418
|
children: [
|
|
356
419
|
/* @__PURE__ */ d("div", {
|
|
357
420
|
className: "rfe-image-grid",
|
|
358
421
|
children: [
|
|
359
|
-
|
|
422
|
+
D.map((e, t) => /* @__PURE__ */ u(ee, {
|
|
360
423
|
item: e,
|
|
361
|
-
sortProps:
|
|
362
|
-
sortActions:
|
|
424
|
+
sortProps: U.enabled ? U.row(t) : void 0,
|
|
425
|
+
sortActions: U.enabled ? /* @__PURE__ */ u(b, {
|
|
363
426
|
index: t,
|
|
364
|
-
count:
|
|
427
|
+
count: D.length,
|
|
365
428
|
name: e.name,
|
|
366
|
-
onMove:
|
|
367
|
-
onDragStart: (e) =>
|
|
368
|
-
onDragEnd:
|
|
429
|
+
onMove: U.move,
|
|
430
|
+
onDragStart: (e) => U.dragStart(t, e),
|
|
431
|
+
onDragEnd: U.reset
|
|
369
432
|
}) : void 0,
|
|
370
|
-
blocked:
|
|
371
|
-
preview: c.preview
|
|
433
|
+
blocked: V,
|
|
434
|
+
preview: (c.previewable ?? c.preview ?? !0) && !c.disabled,
|
|
372
435
|
icons: c.icons,
|
|
373
|
-
onRemove: () =>
|
|
374
|
-
onCancel: () =>
|
|
436
|
+
onRemove: () => ae(e.uid),
|
|
437
|
+
onCancel: () => G(e.uid),
|
|
375
438
|
onRetry: () => {
|
|
376
|
-
!
|
|
439
|
+
c.mode === "upload" && !V && !A.has(e.uid) && A.start(e, c.upload);
|
|
377
440
|
}
|
|
378
441
|
}, e.uid)),
|
|
379
|
-
!
|
|
442
|
+
!H && !c.readOnly && /* @__PURE__ */ d("button", {
|
|
380
443
|
type: "button",
|
|
381
|
-
id:
|
|
444
|
+
id: v,
|
|
382
445
|
className: "rfe-image-add",
|
|
383
|
-
disabled:
|
|
384
|
-
"aria-label": c["aria-label"] ??
|
|
385
|
-
"aria-describedby":
|
|
386
|
-
"aria-invalid":
|
|
387
|
-
onClick: () =>
|
|
446
|
+
disabled: V,
|
|
447
|
+
"aria-label": c["aria-label"] ?? K,
|
|
448
|
+
"aria-describedby": J,
|
|
449
|
+
"aria-invalid": q || void 0,
|
|
450
|
+
onClick: () => N.current?.click(),
|
|
388
451
|
children: [
|
|
389
452
|
/* @__PURE__ */ u("span", {
|
|
390
453
|
className: "rfe-image-add-icon",
|
|
@@ -393,51 +456,53 @@ function w(c) {
|
|
|
393
456
|
source: c.icons?.add
|
|
394
457
|
})
|
|
395
458
|
}),
|
|
396
|
-
/* @__PURE__ */ u("span", { children:
|
|
459
|
+
/* @__PURE__ */ u("span", { children: K }),
|
|
397
460
|
c.dragDrop !== !1 && /* @__PURE__ */ u("small", { children: f("dropImage") })
|
|
398
461
|
]
|
|
399
462
|
}),
|
|
400
463
|
/* @__PURE__ */ u("input", {
|
|
401
|
-
ref:
|
|
464
|
+
ref: N,
|
|
402
465
|
type: "file",
|
|
403
466
|
name: c.name,
|
|
404
|
-
accept:
|
|
405
|
-
multiple:
|
|
406
|
-
disabled:
|
|
467
|
+
accept: re,
|
|
468
|
+
multiple: !I && P,
|
|
469
|
+
disabled: V || H,
|
|
407
470
|
hidden: !0,
|
|
408
471
|
onChange: (e) => {
|
|
409
|
-
|
|
472
|
+
W(Array.from(e.currentTarget.files ?? [])), e.currentTarget.value = "";
|
|
410
473
|
}
|
|
411
474
|
})
|
|
412
475
|
]
|
|
413
476
|
}),
|
|
414
477
|
/* @__PURE__ */ d("div", {
|
|
415
478
|
className: "rfe-image-meta",
|
|
416
|
-
|
|
417
|
-
|
|
479
|
+
id: `${v}-hint`,
|
|
480
|
+
children: [/* @__PURE__ */ u("span", { children: f("imageHint", { max: L }) }), (c.showCount ?? F > 1) && /* @__PURE__ */ d("span", { children: [
|
|
481
|
+
D.length,
|
|
418
482
|
" / ",
|
|
419
|
-
|
|
483
|
+
F
|
|
420
484
|
] })]
|
|
421
485
|
}),
|
|
422
|
-
!!
|
|
486
|
+
!!j.length && /* @__PURE__ */ u("div", {
|
|
423
487
|
className: "rfe-image-rejected",
|
|
488
|
+
id: `${v}-rejected`,
|
|
424
489
|
role: "alert",
|
|
425
|
-
children:
|
|
490
|
+
children: j.map(({ file: e, reason: t }, n) => /* @__PURE__ */ d("div", { children: [
|
|
426
491
|
e.name,
|
|
427
492
|
": ",
|
|
428
|
-
|
|
493
|
+
oe[t]
|
|
429
494
|
] }, n))
|
|
430
495
|
})
|
|
431
496
|
]
|
|
432
497
|
});
|
|
433
498
|
}
|
|
434
499
|
// src/components/image-upload/index.tsx
|
|
435
|
-
var
|
|
436
|
-
function
|
|
437
|
-
let t =
|
|
438
|
-
return t === void 0 && (t = ++
|
|
500
|
+
var O = [], k = /* @__PURE__ */ new WeakMap(), A = 0;
|
|
501
|
+
function j(e) {
|
|
502
|
+
let t = k.get(e);
|
|
503
|
+
return t === void 0 && (t = ++A, k.set(e, t)), t;
|
|
439
504
|
}
|
|
440
|
-
function
|
|
505
|
+
function te({ file: t, onRemove: n, preview: o, removeIcon: s, previewIcon: c, sortActions: f, sortProps: p }) {
|
|
441
506
|
let { t: m } = a(), [h, g] = i(""), [_, v] = i(!1), y = r(null);
|
|
442
507
|
return e(() => {
|
|
443
508
|
let e = URL.createObjectURL(t);
|
|
@@ -507,132 +572,140 @@ function k({ file: t, onRemove: n, preview: o, removeIcon: s, previewIcon: c, so
|
|
|
507
572
|
]
|
|
508
573
|
});
|
|
509
574
|
}
|
|
510
|
-
function
|
|
511
|
-
let
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
575
|
+
function ne({ id: e, name: p, value: h, defaultValue: v, onChange: S, onBlur: C, disabled: w, readOnly: T, loading: E, status: ee, size: D, variant: k, className: A, style: ne, multiple: M = !0, dragDrop: N = !0, preview: P = !0, sortable: F = !1, maxCount: I = 3, maxSize: L = 5, accept: re = f, icons: R, onReject: z, showCount: B, replaceable: ie = !1, previewable: V, beforeUpload: H, onPrepareError: U, ...W }) {
|
|
576
|
+
let ae = o(), { t: G } = a(), K = t(), q = e ?? K, [J, oe] = c(h, v ?? O, S), Y = Array.isArray(J) ? J : O, [se, ce] = i([]), [le, ue] = i(!1), de = r(null), X = _(M, I), fe = X <= 1, pe = !!(w || T || E), me = x({
|
|
577
|
+
beforeUpload: H,
|
|
578
|
+
onPrepareError: U
|
|
579
|
+
}, pe), he = r(Y);
|
|
580
|
+
n(() => {
|
|
581
|
+
(he.current.length !== Y.length || he.current.some((e, t) => e !== Y[t])) && me.cancel(), he.current = Y;
|
|
582
|
+
}, [Y]);
|
|
583
|
+
let Z = pe || me.busy, { full: Q } = g(Y.length, X, M, ie), $ = y(Y, oe, F && !Z && M && Y.length > 1), ge = (e) => {
|
|
584
|
+
Z || Q || !e.length || me.prepare(e, (e) => {
|
|
585
|
+
let t = m(fe ? [] : Y, e, {
|
|
586
|
+
maxCount: X,
|
|
587
|
+
maxSize: L,
|
|
588
|
+
accept: re
|
|
589
|
+
});
|
|
590
|
+
ce(t.rejected), t.rejected.length && z?.(t.rejected), (fe ? t.accepted.length > 0 : t.accepted.length !== Y.length) && oe(t.accepted);
|
|
517
591
|
});
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
`${
|
|
526
|
-
K.length ? `${H}-rejected` : void 0
|
|
592
|
+
}, _e = {
|
|
593
|
+
type: G("imageType"),
|
|
594
|
+
size: G("imageSize", { max: L }),
|
|
595
|
+
count: G("imageCount")
|
|
596
|
+
}, ve = fe && Y.length ? G("replaceImage") : G("addImage"), ye = ee === "error" || W["aria-invalid"], be = [
|
|
597
|
+
W["aria-describedby"],
|
|
598
|
+
`${q}-hint`,
|
|
599
|
+
se.length ? `${q}-rejected` : void 0
|
|
527
600
|
].filter(Boolean).join(" ");
|
|
528
601
|
return /* @__PURE__ */ d("div", {
|
|
529
|
-
id:
|
|
530
|
-
tabIndex:
|
|
602
|
+
id: Q || T ? q : void 0,
|
|
603
|
+
tabIndex: Q && !w ? 0 : void 0,
|
|
531
604
|
role: "group",
|
|
532
|
-
"aria-label":
|
|
533
|
-
"aria-describedby":
|
|
534
|
-
"aria-invalid":
|
|
535
|
-
className: s("rfe-image-upload",
|
|
536
|
-
style:
|
|
537
|
-
"data-size":
|
|
538
|
-
"data-variant":
|
|
539
|
-
"data-status":
|
|
540
|
-
"data-disabled":
|
|
541
|
-
"data-readonly":
|
|
542
|
-
"data-dragging":
|
|
543
|
-
"aria-busy":
|
|
605
|
+
"aria-label": W["aria-label"] ?? ve,
|
|
606
|
+
"aria-describedby": be,
|
|
607
|
+
"aria-invalid": ye || void 0,
|
|
608
|
+
className: s("rfe-image-upload", A),
|
|
609
|
+
style: ne,
|
|
610
|
+
"data-size": D ?? ae.size,
|
|
611
|
+
"data-variant": k ?? ae.variant,
|
|
612
|
+
"data-status": ye ? "error" : ee ?? "default",
|
|
613
|
+
"data-disabled": w || void 0,
|
|
614
|
+
"data-readonly": T || void 0,
|
|
615
|
+
"data-dragging": le && !Z || void 0,
|
|
616
|
+
"aria-busy": E || me.busy || void 0,
|
|
544
617
|
onBlur: (e) => {
|
|
545
|
-
e.currentTarget.contains(e.relatedTarget) ||
|
|
618
|
+
e.currentTarget.contains(e.relatedTarget) || C?.();
|
|
546
619
|
},
|
|
547
620
|
onDragOver: (e) => {
|
|
548
|
-
|
|
621
|
+
N && e.dataTransfer.types.includes("Files") && (e.preventDefault(), e.dataTransfer.dropEffect = Z || Q ? "none" : "copy", !Z && !Q && ue(!0));
|
|
549
622
|
},
|
|
550
623
|
onDragLeave: (e) => {
|
|
551
|
-
e.relatedTarget instanceof Node && e.currentTarget.contains(e.relatedTarget) ||
|
|
624
|
+
e.relatedTarget instanceof Node && e.currentTarget.contains(e.relatedTarget) || ue(!1);
|
|
552
625
|
},
|
|
553
626
|
onDrop: (e) => {
|
|
554
|
-
|
|
627
|
+
N && e.dataTransfer.types.includes("Files") && (e.preventDefault(), ue(!1), Z || ge(Array.from(e.dataTransfer.files)));
|
|
555
628
|
},
|
|
556
629
|
children: [
|
|
557
630
|
/* @__PURE__ */ d("div", {
|
|
558
631
|
className: "rfe-image-grid",
|
|
559
632
|
children: [
|
|
560
|
-
|
|
633
|
+
Y.map((e, t) => /* @__PURE__ */ u(te, {
|
|
561
634
|
file: e,
|
|
562
|
-
sortProps:
|
|
563
|
-
sortActions:
|
|
635
|
+
sortProps: $.enabled ? $.row(t) : void 0,
|
|
636
|
+
sortActions: $.enabled ? /* @__PURE__ */ u(b, {
|
|
564
637
|
index: t,
|
|
565
|
-
count:
|
|
638
|
+
count: Y.length,
|
|
566
639
|
name: e.name,
|
|
567
|
-
onMove:
|
|
568
|
-
onDragStart: (e) =>
|
|
569
|
-
onDragEnd:
|
|
640
|
+
onMove: $.move,
|
|
641
|
+
onDragStart: (e) => $.dragStart(t, e),
|
|
642
|
+
onDragEnd: $.reset
|
|
570
643
|
}) : void 0,
|
|
571
|
-
preview:
|
|
572
|
-
removeIcon:
|
|
573
|
-
previewIcon:
|
|
574
|
-
onRemove:
|
|
575
|
-
|
|
644
|
+
preview: (V ?? P) && !w,
|
|
645
|
+
removeIcon: R?.remove,
|
|
646
|
+
previewIcon: R?.preview,
|
|
647
|
+
onRemove: Z ? void 0 : () => {
|
|
648
|
+
ce([]), oe(Y.filter((e, n) => n !== t));
|
|
576
649
|
}
|
|
577
|
-
}, `${
|
|
578
|
-
!
|
|
579
|
-
id:
|
|
650
|
+
}, `${j(e)}-${Y.slice(0, t).filter((t) => t === e).length}`)),
|
|
651
|
+
!Q && !T && /* @__PURE__ */ d("button", {
|
|
652
|
+
id: q,
|
|
580
653
|
type: "button",
|
|
581
654
|
className: "rfe-image-add",
|
|
582
|
-
disabled:
|
|
583
|
-
"aria-label":
|
|
584
|
-
"aria-describedby":
|
|
585
|
-
"aria-invalid":
|
|
586
|
-
onClick: () =>
|
|
655
|
+
disabled: Z,
|
|
656
|
+
"aria-label": W["aria-label"] ?? ve,
|
|
657
|
+
"aria-describedby": be,
|
|
658
|
+
"aria-invalid": ye || void 0,
|
|
659
|
+
onClick: () => de.current?.click(),
|
|
587
660
|
children: [
|
|
588
661
|
/* @__PURE__ */ u("span", {
|
|
589
662
|
className: "rfe-image-add-icon",
|
|
590
663
|
children: /* @__PURE__ */ u(l, {
|
|
591
|
-
name:
|
|
592
|
-
source:
|
|
664
|
+
name: E ? "loading" : "imageAdd",
|
|
665
|
+
source: E ? void 0 : R?.add
|
|
593
666
|
})
|
|
594
667
|
}),
|
|
595
|
-
/* @__PURE__ */ u("span", { children:
|
|
596
|
-
|
|
668
|
+
/* @__PURE__ */ u("span", { children: E ? G("processing") : ve }),
|
|
669
|
+
N && !E && /* @__PURE__ */ u("small", { children: G("dropImage") })
|
|
597
670
|
]
|
|
598
671
|
}),
|
|
599
672
|
/* @__PURE__ */ u("input", {
|
|
600
|
-
ref:
|
|
673
|
+
ref: de,
|
|
601
674
|
type: "file",
|
|
602
|
-
name:
|
|
603
|
-
accept:
|
|
604
|
-
multiple:
|
|
605
|
-
disabled:
|
|
675
|
+
name: p,
|
|
676
|
+
accept: re,
|
|
677
|
+
multiple: !fe && M,
|
|
678
|
+
disabled: Z || Q,
|
|
606
679
|
hidden: !0,
|
|
607
680
|
onChange: (e) => {
|
|
608
|
-
|
|
681
|
+
ge(Array.from(e.currentTarget.files ?? [])), e.currentTarget.value = "";
|
|
609
682
|
}
|
|
610
683
|
})
|
|
611
684
|
]
|
|
612
685
|
}),
|
|
613
686
|
/* @__PURE__ */ d("div", {
|
|
614
687
|
className: "rfe-image-meta",
|
|
615
|
-
id: `${
|
|
616
|
-
children: [/* @__PURE__ */ u("span", { children:
|
|
617
|
-
|
|
688
|
+
id: `${q}-hint`,
|
|
689
|
+
children: [/* @__PURE__ */ u("span", { children: G("imageHint", { max: L }) }), (B ?? X > 1) && /* @__PURE__ */ d("span", { children: [
|
|
690
|
+
Y.length,
|
|
618
691
|
" / ",
|
|
619
|
-
|
|
692
|
+
X
|
|
620
693
|
] })]
|
|
621
694
|
}),
|
|
622
|
-
!!
|
|
695
|
+
!!se.length && /* @__PURE__ */ u("div", {
|
|
623
696
|
className: "rfe-image-rejected",
|
|
624
|
-
id: `${
|
|
697
|
+
id: `${q}-rejected`,
|
|
625
698
|
role: "alert",
|
|
626
|
-
children:
|
|
699
|
+
children: se.map(({ file: e, reason: t }, n) => /* @__PURE__ */ d("div", { children: [
|
|
627
700
|
e.name,
|
|
628
701
|
":",
|
|
629
|
-
|
|
702
|
+
_e[t]
|
|
630
703
|
] }, n))
|
|
631
704
|
})
|
|
632
705
|
]
|
|
633
706
|
});
|
|
634
707
|
}
|
|
635
|
-
function
|
|
636
|
-
return e.mode === "upload" ? /* @__PURE__ */ u(
|
|
708
|
+
function M(e) {
|
|
709
|
+
return e.mode === "upload" || e.mode === "mixed" ? /* @__PURE__ */ u(D, { ...e }) : /* @__PURE__ */ u(ne, { ...e });
|
|
637
710
|
}
|
|
638
|
-
export {
|
|
711
|
+
export { C as i, w as n, S as r, M as t };
|