@nice2dev/ui 1.4.14 → 1.4.16
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/CHANGELOG.md +80 -0
- package/dist/{NiceColorPicker-BLwYNSXJ.cjs → NiceColorPicker-79rkvaSk.cjs} +1 -1
- package/dist/NiceDataGrid-B1AOjgjm.cjs +10 -0
- package/dist/NiceForm-fmePSeA9.cjs +1 -0
- package/dist/{NiceHtmlEditor-BzECmDO3.cjs → NiceHtmlEditor-By7R1wRo.cjs} +1 -1
- package/dist/{NiceMention-CYRqPKGU.cjs → NiceMention-i7n2BoMw.cjs} +1 -1
- package/dist/{NiceModuleLifecyclePanel-CiYbPcHV.cjs → NiceModuleLifecyclePanel-DVHQuhc-.cjs} +1 -1
- package/dist/{NicePagination-BAxwqeEd.cjs → NicePagination-D9JguOl0.cjs} +1 -1
- package/dist/NicePivotGrid-B_7iQJys.cjs +2 -0
- package/dist/NiceSavedQueryPanel-ChY4HwpM.cjs +587 -0
- package/dist/{NiceScheduler-BqYiHPvz.cjs → NiceScheduler-B2DamQ_L.cjs} +1 -1
- package/dist/backup/NiceBackupScheduler.mjs +171 -119
- package/dist/charts/NiceOrganizationChart.mjs +159 -59
- package/dist/charts/orgChartExport.mjs +71 -0
- package/dist/charts/tidyTree.mjs +43 -0
- package/dist/charts-C3Q3r8Yz.cjs +918 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +9 -0
- package/dist/{core-lazy-BQexApr7.cjs → core-lazy-ChKRuEPb.cjs} +1 -1
- package/dist/data/NiceDataGrid.mjs +301 -320
- package/dist/data/NiceRowEditDialog.mjs +57 -0
- package/dist/data/NiceTreeGrid.mjs +478 -433
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +43 -2
- package/dist/{devops-cgRBnZVX.cjs → devops-o6Zm0VKB.cjs} +3 -3
- package/dist/devops.cjs +1 -1
- package/dist/editors/forms/NiceForm.mjs +216 -167
- package/dist/editors/inputs/NiceUpload.mjs +238 -238
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +13 -1
- package/dist/feedback.cjs +1 -1
- package/dist/index.cjs +254 -254
- package/dist/index.d.ts +198 -5
- package/dist/index.mjs +928 -920
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +11 -1
- package/dist/navigation.cjs +1 -1
- package/dist/no-code/NiceDataMapper.mjs +398 -361
- package/dist/no-code-CN_q6TcB.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.d.ts +11 -1
- package/dist/style.css +1 -1
- package/dist/tools/NicePermissionMatrix.mjs +171 -138
- package/dist/tools/NiceRoleEditor.mjs +334 -297
- package/package.json +4 -4
- package/dist/NiceDataGrid-D3qRQSjy.cjs +0 -10
- package/dist/NiceForm-BWb4LTQJ.cjs +0 -1
- package/dist/NicePivotGrid-Cxu5PECg.cjs +0 -152
- package/dist/NiceSavedQueryPanel-C1nxEmMu.cjs +0 -587
- package/dist/charts-BzlvCCg9.cjs +0 -768
- package/dist/no-code-B1jzfUF5.cjs +0 -331
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsxs as y, Fragment as
|
|
2
|
-
import { useNiceTranslation as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
1
|
+
import { jsxs as y, Fragment as Oe, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as br, NiceIcon as N } from "@nice2dev/ui-core";
|
|
3
|
+
import _r, { forwardRef as vr, useState as je, useRef as F, useEffect as R, useCallback as m, useImperativeHandle as Ur, useMemo as wr } from "react";
|
|
4
|
+
const yr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, ce = (o) => {
|
|
5
5
|
if (o === 0)
|
|
6
6
|
return "0 B";
|
|
7
|
-
const z = 1024, d = ["B", "KB", "MB", "GB", "TB"],
|
|
8
|
-
return `${parseFloat((o / Math.pow(z,
|
|
9
|
-
},
|
|
10
|
-
if (
|
|
7
|
+
const z = 1024, d = ["B", "KB", "MB", "GB", "TB"], _ = Math.floor(Math.log(o) / Math.log(z));
|
|
8
|
+
return `${parseFloat((o / Math.pow(z, _)).toFixed(2))} ${d[_]}`;
|
|
9
|
+
}, de = (o) => o.startsWith("image/"), ue = (o) => o.startsWith("video/"), Be = (o) => o.startsWith("audio/"), kr = (o) => de(o) ? "image" : ue(o) ? "video" : Be(o) ? "music" : /pdf|word|document|text|json|xml/.test(o) ? "file" : /excel|spreadsheet/.test(o) ? "table" : /powerpoint|presentation/.test(o) ? "monitor" : /zip|rar|7z/.test(o) ? "box" : "folder", Fr = (o) => {
|
|
10
|
+
if (de(o.type) || ue(o.type) || Be(o.type))
|
|
11
11
|
return URL.createObjectURL(o);
|
|
12
|
-
},
|
|
12
|
+
}, zr = {
|
|
13
13
|
xxs: 24,
|
|
14
14
|
xs: 32,
|
|
15
15
|
sm: 48,
|
|
@@ -17,115 +17,115 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
17
17
|
lg: 120,
|
|
18
18
|
xl: 160,
|
|
19
19
|
xxl: 200
|
|
20
|
-
},
|
|
21
|
-
const
|
|
22
|
-
d.chunk ? (
|
|
20
|
+
}, xr = (o, z) => (d) => {
|
|
21
|
+
const _ = new FormData();
|
|
22
|
+
d.chunk ? (_.append("chunk", d.chunk), _.append("chunkIndex", String(d.chunkIndex)), _.append("totalChunks", String(d.totalChunks)), _.append("fileName", d.file.name), _.append("fileId", d.fileId || "")) : _.append("file", d.file);
|
|
23
23
|
const u = new XMLHttpRequest();
|
|
24
24
|
return new Promise((k) => {
|
|
25
|
-
u.upload.addEventListener("progress", (
|
|
26
|
-
|
|
25
|
+
u.upload.addEventListener("progress", (h) => {
|
|
26
|
+
h.lengthComputable && d.onProgress && d.onProgress(h.loaded / h.total * 100);
|
|
27
27
|
}), u.addEventListener("load", () => {
|
|
28
28
|
if (u.status >= 200 && u.status < 300)
|
|
29
29
|
try {
|
|
30
|
-
const
|
|
30
|
+
const h = JSON.parse(u.responseText);
|
|
31
31
|
k({
|
|
32
32
|
success: !0,
|
|
33
|
-
url:
|
|
34
|
-
fileId:
|
|
35
|
-
metadata:
|
|
33
|
+
url: h.url,
|
|
34
|
+
fileId: h.fileId || h.id,
|
|
35
|
+
metadata: h
|
|
36
36
|
});
|
|
37
37
|
} catch {
|
|
38
38
|
k({ success: !0, url: u.responseText });
|
|
39
39
|
}
|
|
40
40
|
else
|
|
41
41
|
k({ success: !1, error: `Upload failed: ${u.status} ${u.statusText}` });
|
|
42
|
-
}), u.addEventListener("error", () => k({ success: !1, error: "Network error" })), u.addEventListener("abort", () => k({ success: !1, error: "Upload cancelled" })), d.signal && d.signal.addEventListener("abort", () => u.abort()), u.open("POST", o), z && Object.entries(z).forEach(([
|
|
42
|
+
}), u.addEventListener("error", () => k({ success: !1, error: "Network error" })), u.addEventListener("abort", () => k({ success: !1, error: "Upload cancelled" })), d.signal && d.signal.addEventListener("abort", () => u.abort()), u.open("POST", o), z && Object.entries(z).forEach(([h, D]) => u.setRequestHeader(h, D)), u.send(_);
|
|
43
43
|
});
|
|
44
|
-
},
|
|
45
|
-
/* @__PURE__ */
|
|
44
|
+
}, $r = /* @__PURE__ */ Object.assign(
|
|
45
|
+
/* @__PURE__ */ vr((o, z) => {
|
|
46
46
|
const {
|
|
47
47
|
accept: d,
|
|
48
|
-
multiple:
|
|
48
|
+
multiple: _,
|
|
49
49
|
maxFileSize: u,
|
|
50
50
|
maxFiles: k,
|
|
51
|
-
minFileSize:
|
|
52
|
-
onFilesSelected:
|
|
51
|
+
minFileSize: h,
|
|
52
|
+
onFilesSelected: D,
|
|
53
53
|
uploadMode: x = "instant",
|
|
54
|
-
labelText:
|
|
55
|
-
text:
|
|
56
|
-
dropzoneText:
|
|
57
|
-
browseText:
|
|
58
|
-
dragActiveText:
|
|
59
|
-
labelPlacement:
|
|
60
|
-
icon:
|
|
61
|
-
showFileList:
|
|
62
|
-
imagePreview:
|
|
63
|
-
showPreview:
|
|
64
|
-
listMode:
|
|
65
|
-
previewSize:
|
|
66
|
-
fileProgress:
|
|
67
|
-
renderPreview:
|
|
68
|
-
renderFileItem:
|
|
69
|
-
variant:
|
|
70
|
-
trigger:
|
|
71
|
-
dropChildren:
|
|
72
|
-
autoUpload:
|
|
54
|
+
labelText: He,
|
|
55
|
+
text: We,
|
|
56
|
+
dropzoneText: Ie,
|
|
57
|
+
browseText: pe,
|
|
58
|
+
dragActiveText: Ke,
|
|
59
|
+
labelPlacement: Qe = "right",
|
|
60
|
+
icon: me = "upload",
|
|
61
|
+
showFileList: Ve = !0,
|
|
62
|
+
imagePreview: he,
|
|
63
|
+
showPreview: fe = !0,
|
|
64
|
+
listMode: Xe = "list",
|
|
65
|
+
previewSize: Ge = "md",
|
|
66
|
+
fileProgress: Je,
|
|
67
|
+
renderPreview: ge,
|
|
68
|
+
renderFileItem: be,
|
|
69
|
+
variant: _e = "dropzone",
|
|
70
|
+
trigger: Ze,
|
|
71
|
+
dropChildren: X,
|
|
72
|
+
autoUpload: ve = !1,
|
|
73
73
|
uploadHandler: T,
|
|
74
74
|
uploadUrl: S,
|
|
75
|
-
uploadHeaders:
|
|
76
|
-
concurrentUploads:
|
|
77
|
-
maxRetries:
|
|
75
|
+
uploadHeaders: Ue,
|
|
76
|
+
concurrentUploads: we = 3,
|
|
77
|
+
maxRetries: G = 3,
|
|
78
78
|
chunkSize: O = 5 * 1024 * 1024,
|
|
79
|
-
chunkThreshold:
|
|
80
|
-
validateFile:
|
|
81
|
-
keepFilesAfterUpload:
|
|
82
|
-
initialFiles:
|
|
83
|
-
disabled:
|
|
79
|
+
chunkThreshold: ye = 10 * 1024 * 1024,
|
|
80
|
+
validateFile: J,
|
|
81
|
+
keepFilesAfterUpload: ke = !0,
|
|
82
|
+
initialFiles: Ye,
|
|
83
|
+
disabled: g,
|
|
84
84
|
readOnly: v,
|
|
85
|
-
onFilesAdded:
|
|
86
|
-
onUploadComplete:
|
|
87
|
-
onUploadError:
|
|
88
|
-
onProgress:
|
|
89
|
-
onFileRemoved:
|
|
90
|
-
onChange:
|
|
91
|
-
apiRef:
|
|
92
|
-
pasteFromClipboard:
|
|
93
|
-
className:
|
|
94
|
-
style:
|
|
95
|
-
"data-testid":
|
|
96
|
-
} = o, { t: i } =
|
|
97
|
-
}),
|
|
85
|
+
onFilesAdded: Fe,
|
|
86
|
+
onUploadComplete: ze,
|
|
87
|
+
onUploadError: xe,
|
|
88
|
+
onProgress: Ce,
|
|
89
|
+
onFileRemoved: Ne,
|
|
90
|
+
onChange: Re,
|
|
91
|
+
apiRef: qe,
|
|
92
|
+
pasteFromClipboard: $e,
|
|
93
|
+
className: er,
|
|
94
|
+
style: rr,
|
|
95
|
+
"data-testid": tr
|
|
96
|
+
} = o, j = _ ?? _e !== "button", { t: i } = br(), [U, b] = je(() => Ye ?? []), [Z, Y] = je(!1), f = F(U), Ee = F(null), E = F(/* @__PURE__ */ new Map()), B = F([]), q = F(/* @__PURE__ */ new Set()), L = F(0), Le = F(() => {
|
|
97
|
+
}), Me = F(Re), M = !!(T || S);
|
|
98
98
|
R(() => {
|
|
99
|
-
|
|
99
|
+
f.current = U;
|
|
100
100
|
}, [U]), R(() => {
|
|
101
|
-
|
|
101
|
+
Me.current = Re;
|
|
102
102
|
}), R(() => {
|
|
103
|
-
|
|
103
|
+
Me.current?.(U);
|
|
104
104
|
}, [U]), R(
|
|
105
105
|
() => () => {
|
|
106
|
-
|
|
106
|
+
f.current.forEach((e) => e.previewUrl && URL.revokeObjectURL(e.previewUrl));
|
|
107
107
|
},
|
|
108
108
|
[]
|
|
109
109
|
);
|
|
110
110
|
const C = m(
|
|
111
|
-
(e) =>
|
|
112
|
-
[
|
|
113
|
-
),
|
|
111
|
+
(e) => D(e.map((r) => r.file)),
|
|
112
|
+
[D]
|
|
113
|
+
), Pe = m(
|
|
114
114
|
(e) => {
|
|
115
|
-
if (
|
|
116
|
-
const r =
|
|
115
|
+
if (J) {
|
|
116
|
+
const r = J(e);
|
|
117
117
|
if (r)
|
|
118
118
|
return r;
|
|
119
119
|
}
|
|
120
120
|
if (u && e.size > u)
|
|
121
121
|
return i("fileUpload.error.tooLarge", "File is too large. Maximum size: {size}").replace(
|
|
122
122
|
"{size}",
|
|
123
|
-
|
|
123
|
+
ce(u)
|
|
124
124
|
);
|
|
125
|
-
if (
|
|
125
|
+
if (h && e.size < h)
|
|
126
126
|
return i("fileUpload.error.tooSmall", "File is too small. Minimum size: {size}").replace(
|
|
127
127
|
"{size}",
|
|
128
|
-
|
|
128
|
+
ce(h)
|
|
129
129
|
);
|
|
130
130
|
if (d) {
|
|
131
131
|
const r = d.split(",").map((n) => n.trim().toLowerCase()), t = e.type.toLowerCase(), l = "." + (e.name.split(".").pop()?.toLowerCase() ?? "");
|
|
@@ -137,49 +137,49 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
137
137
|
}
|
|
138
138
|
return null;
|
|
139
139
|
},
|
|
140
|
-
[
|
|
141
|
-
),
|
|
140
|
+
[J, u, h, d, i]
|
|
141
|
+
), H = m(() => T || (S ? xr(S, Ue) : null), [T, S, Ue]), Ae = m(
|
|
142
142
|
async (e, r, t) => {
|
|
143
143
|
const l = e.file, s = Math.ceil(l.size / O);
|
|
144
144
|
let n = 0, p = { success: !1 };
|
|
145
145
|
for (let c = 0; c < s; c++) {
|
|
146
146
|
if (t.aborted)
|
|
147
147
|
throw new Error("Upload cancelled");
|
|
148
|
-
const w = c * O,
|
|
149
|
-
let
|
|
150
|
-
for (; !
|
|
148
|
+
const w = c * O, hr = Math.min(w + O, l.size), ie = l.slice(w, hr);
|
|
149
|
+
let V = 0, le = !1;
|
|
150
|
+
for (; !le && V < G; )
|
|
151
151
|
try {
|
|
152
152
|
p = await r({
|
|
153
153
|
file: l,
|
|
154
|
-
chunk:
|
|
154
|
+
chunk: ie,
|
|
155
155
|
chunkIndex: c,
|
|
156
156
|
totalChunks: s,
|
|
157
157
|
fileId: e.id,
|
|
158
|
-
onProgress: (
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
(
|
|
158
|
+
onProgress: (oe) => {
|
|
159
|
+
const fr = (n + ie.size * oe / 100) / l.size * 100;
|
|
160
|
+
b(
|
|
161
|
+
(gr) => gr.map((se) => se.id === e.id ? { ...se, progress: fr } : se)
|
|
162
162
|
);
|
|
163
163
|
},
|
|
164
164
|
signal: t
|
|
165
|
-
}), p.success ? (
|
|
166
|
-
} catch (
|
|
167
|
-
if (
|
|
168
|
-
throw
|
|
165
|
+
}), p.success ? (le = !0, n += ie.size) : V++;
|
|
166
|
+
} catch (oe) {
|
|
167
|
+
if (V++, V >= G)
|
|
168
|
+
throw oe;
|
|
169
169
|
}
|
|
170
|
-
if (!
|
|
170
|
+
if (!le)
|
|
171
171
|
throw new Error(`Failed to upload chunk ${c + 1}/${s}`);
|
|
172
172
|
}
|
|
173
173
|
return p;
|
|
174
174
|
},
|
|
175
|
-
[O,
|
|
176
|
-
),
|
|
175
|
+
[O, G]
|
|
176
|
+
), De = m(
|
|
177
177
|
async (e, r) => {
|
|
178
|
-
const t =
|
|
178
|
+
const t = f.current.find((s) => s.id === e);
|
|
179
179
|
if (!t || t.status === "uploading" || t.status === "success")
|
|
180
180
|
return;
|
|
181
181
|
const l = new AbortController();
|
|
182
|
-
E.current.set(e, l),
|
|
182
|
+
E.current.set(e, l), q.current.add(e), b(
|
|
183
183
|
(s) => s.map(
|
|
184
184
|
(n) => n.id === e ? { ...n, status: "uploading", progress: 0, error: void 0 } : n
|
|
185
185
|
)
|
|
@@ -187,14 +187,14 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
187
187
|
try {
|
|
188
188
|
const s = t.file;
|
|
189
189
|
let n;
|
|
190
|
-
if (s.size >
|
|
190
|
+
if (s.size > ye ? n = await Ae(t, r, l.signal) : n = await r({
|
|
191
191
|
file: s,
|
|
192
192
|
onProgress: (p) => {
|
|
193
|
-
|
|
193
|
+
b((c) => c.map((w) => w.id === e ? { ...w, progress: p } : w)), Ce?.(t, p);
|
|
194
194
|
},
|
|
195
195
|
signal: l.signal
|
|
196
196
|
}), n.success) {
|
|
197
|
-
if (
|
|
197
|
+
if (b(
|
|
198
198
|
(p) => p.map(
|
|
199
199
|
(c) => c.id === e ? {
|
|
200
200
|
...c,
|
|
@@ -204,16 +204,16 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
204
204
|
uploadedAt: /* @__PURE__ */ new Date()
|
|
205
205
|
} : c
|
|
206
206
|
)
|
|
207
|
-
),
|
|
208
|
-
const p =
|
|
209
|
-
p?.previewUrl && URL.revokeObjectURL(p.previewUrl),
|
|
207
|
+
), ze?.({ ...t, status: "success", uploadedUrl: n.url }), !ke) {
|
|
208
|
+
const p = f.current.find((c) => c.id === e);
|
|
209
|
+
p?.previewUrl && URL.revokeObjectURL(p.previewUrl), b((c) => c.filter((w) => w.id !== e));
|
|
210
210
|
}
|
|
211
211
|
} else
|
|
212
212
|
throw new Error(n.error || "Upload failed");
|
|
213
213
|
} catch (s) {
|
|
214
214
|
const n = s;
|
|
215
215
|
if (n.name === "AbortError" || n.message === "Upload cancelled")
|
|
216
|
-
|
|
216
|
+
b(
|
|
217
217
|
(p) => p.map(
|
|
218
218
|
(c) => c.id === e ? {
|
|
219
219
|
...c,
|
|
@@ -224,101 +224,101 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
224
224
|
);
|
|
225
225
|
else {
|
|
226
226
|
const p = n.message || i("fileUpload.error.generic", "Upload error");
|
|
227
|
-
|
|
227
|
+
b(
|
|
228
228
|
(c) => c.map(
|
|
229
229
|
(w) => w.id === e ? { ...w, status: "error", error: p } : w
|
|
230
230
|
)
|
|
231
|
-
),
|
|
231
|
+
), xe?.(t, p);
|
|
232
232
|
}
|
|
233
233
|
} finally {
|
|
234
|
-
E.current.delete(e),
|
|
234
|
+
E.current.delete(e), q.current.delete(e), Le.current();
|
|
235
235
|
}
|
|
236
236
|
},
|
|
237
237
|
[
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
ye,
|
|
239
|
+
Ae,
|
|
240
|
+
Ce,
|
|
240
241
|
ze,
|
|
242
|
+
xe,
|
|
241
243
|
ke,
|
|
242
|
-
Fe,
|
|
243
|
-
we,
|
|
244
244
|
i
|
|
245
245
|
]
|
|
246
|
-
),
|
|
246
|
+
), ee = F(De);
|
|
247
247
|
R(() => {
|
|
248
|
-
|
|
248
|
+
ee.current = De;
|
|
249
249
|
});
|
|
250
|
-
const
|
|
251
|
-
const e =
|
|
250
|
+
const P = m(() => {
|
|
251
|
+
const e = H();
|
|
252
252
|
if (e)
|
|
253
|
-
for (;
|
|
254
|
-
const r =
|
|
255
|
-
r &&
|
|
253
|
+
for (; B.current.length > 0 && q.current.size < we; ) {
|
|
254
|
+
const r = B.current.shift();
|
|
255
|
+
r && ee.current(r, e);
|
|
256
256
|
}
|
|
257
|
-
}, [
|
|
257
|
+
}, [H, we]);
|
|
258
258
|
R(() => {
|
|
259
|
-
|
|
259
|
+
Le.current = P;
|
|
260
260
|
});
|
|
261
|
-
const
|
|
261
|
+
const re = m(
|
|
262
262
|
(e) => {
|
|
263
|
-
const r =
|
|
263
|
+
const r = H();
|
|
264
264
|
if (!r) {
|
|
265
265
|
console.error("No upload handler configured");
|
|
266
266
|
return;
|
|
267
267
|
}
|
|
268
|
-
|
|
268
|
+
ee.current(e, r);
|
|
269
269
|
},
|
|
270
|
-
[
|
|
271
|
-
),
|
|
270
|
+
[H]
|
|
271
|
+
), nr = m(
|
|
272
272
|
(e) => {
|
|
273
|
-
E.current.get(e)?.abort(),
|
|
273
|
+
E.current.get(e)?.abort(), b(
|
|
274
274
|
(r) => r.map(
|
|
275
275
|
(t) => t.id === e && t.status === "uploading" ? { ...t, status: "cancelled", error: i("fileUpload.status.cancelled", "Cancelled") } : t
|
|
276
276
|
)
|
|
277
277
|
);
|
|
278
278
|
},
|
|
279
279
|
[i]
|
|
280
|
-
),
|
|
280
|
+
), te = m(
|
|
281
281
|
(e) => {
|
|
282
|
-
|
|
282
|
+
b(
|
|
283
283
|
(r) => r.map(
|
|
284
284
|
(t) => t.id === e ? { ...t, status: "pending", progress: 0, error: void 0 } : t
|
|
285
285
|
)
|
|
286
|
-
),
|
|
286
|
+
), re(e);
|
|
287
287
|
},
|
|
288
|
-
[
|
|
289
|
-
),
|
|
288
|
+
[re]
|
|
289
|
+
), ar = m(
|
|
290
290
|
(e) => {
|
|
291
|
-
const r =
|
|
291
|
+
const r = f.current.find((l) => l.id === e);
|
|
292
292
|
if (!r)
|
|
293
293
|
return;
|
|
294
294
|
E.current.get(e)?.abort(), r.previewUrl && URL.revokeObjectURL(r.previewUrl);
|
|
295
|
-
const t =
|
|
296
|
-
|
|
295
|
+
const t = f.current.filter((l) => l.id !== e);
|
|
296
|
+
f.current = t, b((l) => l.filter((s) => s.id !== e)), Ne?.(r), x === "instant" && C(t);
|
|
297
297
|
},
|
|
298
|
-
[
|
|
299
|
-
),
|
|
300
|
-
|
|
301
|
-
}, [
|
|
302
|
-
E.current.forEach((e) => e.abort()),
|
|
298
|
+
[Ne, x, C]
|
|
299
|
+
), ne = m(() => {
|
|
300
|
+
f.current.filter((e) => e.status === "pending").forEach((e) => B.current.push(e.id)), P();
|
|
301
|
+
}, [P]), W = m(() => {
|
|
302
|
+
E.current.forEach((e) => e.abort()), b(
|
|
303
303
|
(e) => e.map(
|
|
304
304
|
(r) => r.status === "uploading" ? { ...r, status: "cancelled", error: i("fileUpload.status.cancelled", "Cancelled") } : r
|
|
305
305
|
)
|
|
306
306
|
);
|
|
307
|
-
}, [i]),
|
|
308
|
-
|
|
309
|
-
}, [
|
|
310
|
-
|
|
311
|
-
}, [
|
|
307
|
+
}, [i]), I = m(() => {
|
|
308
|
+
W(), f.current.forEach((e) => e.previewUrl && URL.revokeObjectURL(e.previewUrl)), b([]), x === "instant" && C([]);
|
|
309
|
+
}, [W, x, C]), ae = m(() => {
|
|
310
|
+
f.current.filter((e) => e.status === "error").forEach((e) => te(e.id));
|
|
311
|
+
}, [te]), $ = m(
|
|
312
312
|
(e) => {
|
|
313
|
-
if (
|
|
313
|
+
if (g || v)
|
|
314
314
|
return;
|
|
315
|
-
const r =
|
|
316
|
-
let t =
|
|
315
|
+
const r = f.current;
|
|
316
|
+
let t = j ? e : e.slice(0, 1);
|
|
317
317
|
k && (t = t.slice(0, Math.max(0, k - r.length)));
|
|
318
318
|
const l = t.map((n) => {
|
|
319
|
-
const p =
|
|
319
|
+
const p = Pe(n);
|
|
320
320
|
return {
|
|
321
|
-
id:
|
|
321
|
+
id: yr(),
|
|
322
322
|
file: n,
|
|
323
323
|
name: n.name,
|
|
324
324
|
size: n.size,
|
|
@@ -326,39 +326,39 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
326
326
|
status: p ? "error" : "pending",
|
|
327
327
|
progress: 0,
|
|
328
328
|
error: p || void 0,
|
|
329
|
-
previewUrl:
|
|
329
|
+
previewUrl: Fr(n)
|
|
330
330
|
};
|
|
331
|
-
}), s =
|
|
332
|
-
|
|
331
|
+
}), s = j ? [...r, ...l] : l;
|
|
332
|
+
b(s), f.current = s, Fe?.(l), x === "instant" && C(s), ve && (l.filter((n) => n.status === "pending").forEach((n) => B.current.push(n.id)), P());
|
|
333
333
|
},
|
|
334
334
|
[
|
|
335
|
-
|
|
335
|
+
g,
|
|
336
336
|
v,
|
|
337
|
-
|
|
337
|
+
j,
|
|
338
338
|
k,
|
|
339
|
-
|
|
340
|
-
|
|
339
|
+
Pe,
|
|
340
|
+
Fe,
|
|
341
341
|
x,
|
|
342
342
|
C,
|
|
343
|
-
|
|
344
|
-
|
|
343
|
+
ve,
|
|
344
|
+
P
|
|
345
345
|
]
|
|
346
|
-
),
|
|
347
|
-
|
|
348
|
-
|
|
346
|
+
), A = m(() => Ee.current?.click(), []);
|
|
347
|
+
Ur(
|
|
348
|
+
qe,
|
|
349
349
|
() => ({
|
|
350
350
|
addFiles: $,
|
|
351
|
-
uploadAll:
|
|
352
|
-
cancelAll:
|
|
353
|
-
clearAll:
|
|
354
|
-
getFiles: () =>
|
|
355
|
-
getFile: (e) =>
|
|
356
|
-
retryFailed:
|
|
357
|
-
openFileBrowser:
|
|
351
|
+
uploadAll: ne,
|
|
352
|
+
cancelAll: W,
|
|
353
|
+
clearAll: I,
|
|
354
|
+
getFiles: () => f.current,
|
|
355
|
+
getFile: (e) => f.current.find((r) => r.id === e),
|
|
356
|
+
retryFailed: ae,
|
|
357
|
+
openFileBrowser: A
|
|
358
358
|
}),
|
|
359
|
-
[$,
|
|
359
|
+
[$, ne, W, I, ae, A]
|
|
360
360
|
), R(() => {
|
|
361
|
-
if (
|
|
361
|
+
if (!$e || g || v)
|
|
362
362
|
return;
|
|
363
363
|
const e = (r) => {
|
|
364
364
|
const t = r.clipboardData?.items;
|
|
@@ -373,21 +373,21 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
373
373
|
l.length > 0 && (r.preventDefault(), $(l));
|
|
374
374
|
};
|
|
375
375
|
return document.addEventListener("paste", e), () => document.removeEventListener("paste", e);
|
|
376
|
-
}, [
|
|
377
|
-
const
|
|
378
|
-
e.preventDefault(), !(
|
|
379
|
-
}, ir = (e) => {
|
|
380
|
-
e.preventDefault(), L.current--, L.current <= 0 && (L.current = 0, Z(!1));
|
|
376
|
+
}, [$e, g, v, $]);
|
|
377
|
+
const ir = (e) => {
|
|
378
|
+
e.preventDefault(), !(g || v) && (L.current++, Y(!0));
|
|
381
379
|
}, lr = (e) => {
|
|
382
|
-
e.preventDefault(), L.current
|
|
380
|
+
e.preventDefault(), L.current--, L.current <= 0 && (L.current = 0, Y(!1));
|
|
383
381
|
}, or = (e) => {
|
|
382
|
+
e.preventDefault(), L.current = 0, Y(!1), !(g || v) && $(Array.from(e.dataTransfer.files));
|
|
383
|
+
}, sr = (e) => {
|
|
384
384
|
e.target.files && $(Array.from(e.target.files)), e.target.value = "";
|
|
385
|
-
},
|
|
385
|
+
}, K = wr(() => {
|
|
386
386
|
const e = { total: U.length, pending: 0, uploading: 0, success: 0, error: 0 };
|
|
387
387
|
for (const r of U)
|
|
388
388
|
r.status === "pending" ? e.pending++ : r.status === "uploading" ? e.uploading++ : r.status === "success" ? e.success++ : r.status === "error" && e.error++;
|
|
389
389
|
return e;
|
|
390
|
-
}, [U]),
|
|
390
|
+
}, [U]), Q = He ?? We ?? Ie ?? i("dropOrClick", "Drop files here or click to browse"), Te = Ke ?? i("fileUpload.dropzone.dragActive", "Drop files here"), cr = (e) => i(
|
|
391
391
|
`fileUpload.status.${e}`,
|
|
392
392
|
{
|
|
393
393
|
pending: "Pending",
|
|
@@ -396,11 +396,11 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
396
396
|
error: "Error",
|
|
397
397
|
cancelled: "Cancelled"
|
|
398
398
|
}[e]
|
|
399
|
-
),
|
|
400
|
-
if (
|
|
401
|
-
return
|
|
402
|
-
const r =
|
|
403
|
-
return t && e.previewUrl &&
|
|
399
|
+
), dr = (e) => M || e.status !== "pending", ur = (e) => {
|
|
400
|
+
if (ge)
|
|
401
|
+
return ge(e);
|
|
402
|
+
const r = zr[Ge] ?? 80, t = he ?? fe;
|
|
403
|
+
return t && e.previewUrl && de(e.type) ? /* @__PURE__ */ a(
|
|
404
404
|
"img",
|
|
405
405
|
{
|
|
406
406
|
src: e.previewUrl,
|
|
@@ -408,7 +408,7 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
408
408
|
className: "nice-fileuploader__thumb nice-upload__thumb nice-upload__preview",
|
|
409
409
|
style: { width: r, height: r, objectFit: "cover" }
|
|
410
410
|
}
|
|
411
|
-
) : t && e.previewUrl &&
|
|
411
|
+
) : t && e.previewUrl && ue(e.type) ? /* @__PURE__ */ y(
|
|
412
412
|
"span",
|
|
413
413
|
{
|
|
414
414
|
className: "nice-upload__preview",
|
|
@@ -418,26 +418,26 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
418
418
|
/* @__PURE__ */ a("span", { className: "nice-upload__preview-overlay", "aria-hidden": "true", children: /* @__PURE__ */ a(N, { name: "play", size: 20 }) })
|
|
419
419
|
]
|
|
420
420
|
}
|
|
421
|
-
) : /* @__PURE__ */ a("span", { className: "nice-upload__preview nice-upload__preview--icon", "aria-hidden": "true", children: /* @__PURE__ */ a(N, { name:
|
|
422
|
-
},
|
|
421
|
+
) : /* @__PURE__ */ a("span", { className: "nice-upload__preview nice-upload__preview--icon", "aria-hidden": "true", children: /* @__PURE__ */ a(N, { name: kr(e.type), size: Math.round(r * 0.5) }) });
|
|
422
|
+
}, pr = (e) => {
|
|
423
423
|
const r = {
|
|
424
|
-
upload: () =>
|
|
425
|
-
cancel: () =>
|
|
426
|
-
retry: () =>
|
|
427
|
-
remove: () =>
|
|
424
|
+
upload: () => re(e.id),
|
|
425
|
+
cancel: () => nr(e.id),
|
|
426
|
+
retry: () => te(e.id),
|
|
427
|
+
remove: () => ar(e.id)
|
|
428
428
|
};
|
|
429
|
-
if (
|
|
430
|
-
return /* @__PURE__ */ a(
|
|
431
|
-
const t =
|
|
429
|
+
if (be)
|
|
430
|
+
return /* @__PURE__ */ a(_r.Fragment, { children: be(e, r) }, e.id);
|
|
431
|
+
const t = Je?.[e.name] ?? e.progress, l = dr(e);
|
|
432
432
|
return /* @__PURE__ */ y(
|
|
433
433
|
"div",
|
|
434
434
|
{
|
|
435
435
|
className: `nice-fileuploader__file nice-upload__file nice-upload__item nice-upload__item--${e.status}`,
|
|
436
436
|
children: [
|
|
437
|
-
(
|
|
437
|
+
(he ?? fe) && ur(e),
|
|
438
438
|
/* @__PURE__ */ a("span", { className: "nice-fileuploader__filename nice-upload__filename", title: e.name, children: e.name }),
|
|
439
|
-
/* @__PURE__ */ a("span", { className: "nice-fileuploader__filesize nice-upload__filesize", children:
|
|
440
|
-
l && /* @__PURE__ */ a("span", { className: `nice-upload__badge nice-upload__badge--${e.status}`, children:
|
|
439
|
+
/* @__PURE__ */ a("span", { className: "nice-fileuploader__filesize nice-upload__filesize", children: ce(e.size) }),
|
|
440
|
+
l && /* @__PURE__ */ a("span", { className: `nice-upload__badge nice-upload__badge--${e.status}`, children: cr(e.status) }),
|
|
441
441
|
(e.status === "uploading" || t != null && t > 0 && t < 100) && /* @__PURE__ */ a(
|
|
442
442
|
"div",
|
|
443
443
|
{
|
|
@@ -467,7 +467,7 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
467
467
|
children: i("fileUpload.openFile", "Open file")
|
|
468
468
|
}
|
|
469
469
|
),
|
|
470
|
-
!v && !
|
|
470
|
+
!v && !g && /* @__PURE__ */ y("span", { className: "nice-upload__item-actions", children: [
|
|
471
471
|
M && e.status === "pending" && /* @__PURE__ */ a(
|
|
472
472
|
"button",
|
|
473
473
|
{
|
|
@@ -517,96 +517,96 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
517
517
|
},
|
|
518
518
|
e.id
|
|
519
519
|
);
|
|
520
|
-
},
|
|
521
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
522
|
-
},
|
|
520
|
+
}, mr = (e) => {
|
|
521
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), A());
|
|
522
|
+
}, Se = /* @__PURE__ */ a(
|
|
523
523
|
"input",
|
|
524
524
|
{
|
|
525
|
-
ref:
|
|
525
|
+
ref: Ee,
|
|
526
526
|
type: "file",
|
|
527
527
|
accept: d,
|
|
528
|
-
multiple:
|
|
528
|
+
multiple: j,
|
|
529
529
|
hidden: !0,
|
|
530
|
-
disabled:
|
|
531
|
-
onChange:
|
|
530
|
+
disabled: g,
|
|
531
|
+
onChange: sr
|
|
532
532
|
}
|
|
533
533
|
);
|
|
534
534
|
return /* @__PURE__ */ y(
|
|
535
535
|
"div",
|
|
536
536
|
{
|
|
537
537
|
ref: z,
|
|
538
|
-
className: `nice-fileuploader nice-upload ${
|
|
539
|
-
style:
|
|
540
|
-
"data-testid":
|
|
538
|
+
className: `nice-fileuploader nice-upload ${g ? "nice-fileuploader--disabled nice-upload--disabled" : ""} ${v ? "nice-upload--readonly" : ""} ${er || ""}`,
|
|
539
|
+
style: rr,
|
|
540
|
+
"data-testid": tr,
|
|
541
541
|
children: [
|
|
542
|
-
|
|
542
|
+
_e === "button" ? /* @__PURE__ */ y(Oe, { children: [
|
|
543
543
|
/* @__PURE__ */ a(
|
|
544
544
|
"button",
|
|
545
545
|
{
|
|
546
546
|
type: "button",
|
|
547
547
|
className: "nice-upload__trigger nice-btn nice-btn--primary",
|
|
548
|
-
onClick:
|
|
549
|
-
disabled:
|
|
550
|
-
children:
|
|
548
|
+
onClick: A,
|
|
549
|
+
disabled: g || v,
|
|
550
|
+
children: Ze ?? i("filePicker.label", "Choose files")
|
|
551
551
|
}
|
|
552
552
|
),
|
|
553
|
-
|
|
553
|
+
Se
|
|
554
554
|
] }) : !v && /* @__PURE__ */ y(
|
|
555
555
|
"div",
|
|
556
556
|
{
|
|
557
|
-
className: `nice-fileuploader__dropzone nice-upload__dropzone nice-upload__dropzone--label-${
|
|
557
|
+
className: `nice-fileuploader__dropzone nice-upload__dropzone nice-upload__dropzone--label-${Qe} ${!X && !Q ? "nice-upload__dropzone--icon-only" : ""} ${Z ? "nice-fileuploader__dropzone--active nice-upload__dropzone--active" : ""}`,
|
|
558
558
|
role: "button",
|
|
559
|
-
tabIndex:
|
|
560
|
-
"aria-disabled":
|
|
561
|
-
"aria-label": !
|
|
562
|
-
onDragEnter:
|
|
559
|
+
tabIndex: g ? -1 : 0,
|
|
560
|
+
"aria-disabled": g || void 0,
|
|
561
|
+
"aria-label": !X && !Q ? i("filePicker.label", "Choose files") : void 0,
|
|
562
|
+
onDragEnter: ir,
|
|
563
563
|
onDragOver: (e) => e.preventDefault(),
|
|
564
|
-
onDragLeave:
|
|
565
|
-
onDrop:
|
|
566
|
-
onClick: () => !
|
|
567
|
-
onKeyDown:
|
|
564
|
+
onDragLeave: lr,
|
|
565
|
+
onDrop: or,
|
|
566
|
+
onClick: () => !g && A(),
|
|
567
|
+
onKeyDown: mr,
|
|
568
568
|
children: [
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
(
|
|
573
|
-
|
|
574
|
-
|
|
569
|
+
Se,
|
|
570
|
+
X ?? /* @__PURE__ */ y(Oe, { children: [
|
|
571
|
+
me && /* @__PURE__ */ a("div", { className: "nice-upload__icon", "aria-hidden": "true", children: /* @__PURE__ */ a(N, { name: me, size: "lg" }) }),
|
|
572
|
+
(Z ? Te : Q) && /* @__PURE__ */ y("div", { className: "nice-fileuploader__label nice-upload__label", children: [
|
|
573
|
+
Z ? Te : Q,
|
|
574
|
+
pe && /* @__PURE__ */ y("span", { className: "nice-upload__browse", children: [
|
|
575
575
|
" ",
|
|
576
|
-
|
|
576
|
+
pe
|
|
577
577
|
] })
|
|
578
578
|
] })
|
|
579
579
|
] })
|
|
580
580
|
]
|
|
581
581
|
}
|
|
582
582
|
),
|
|
583
|
-
|
|
583
|
+
Ve && U.length > 0 && // a file's status and error are announced as they change
|
|
584
584
|
/* @__PURE__ */ a(
|
|
585
585
|
"div",
|
|
586
586
|
{
|
|
587
|
-
className: `nice-fileuploader__list nice-upload__list nice-upload__list--${
|
|
587
|
+
className: `nice-fileuploader__list nice-upload__list nice-upload__list--${Xe}`,
|
|
588
588
|
"aria-live": "polite",
|
|
589
|
-
children: U.map(
|
|
589
|
+
children: U.map(pr)
|
|
590
590
|
}
|
|
591
591
|
),
|
|
592
592
|
M && U.length > 0 && !v && /* @__PURE__ */ y("div", { className: "nice-upload__bulk", children: [
|
|
593
|
-
|
|
593
|
+
K.pending > 0 && /* @__PURE__ */ a(
|
|
594
594
|
"button",
|
|
595
595
|
{
|
|
596
596
|
type: "button",
|
|
597
597
|
className: "nice-btn nice-btn--primary nice-btn--sm",
|
|
598
|
-
onClick:
|
|
598
|
+
onClick: ne,
|
|
599
599
|
children: i("fileUpload.bulk.uploadAll", "Upload all ({n})").replace(
|
|
600
600
|
"{n}",
|
|
601
|
-
String(
|
|
601
|
+
String(K.pending)
|
|
602
602
|
)
|
|
603
603
|
}
|
|
604
604
|
),
|
|
605
|
-
|
|
605
|
+
K.error > 0 && /* @__PURE__ */ a("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: ae, children: i("fileUpload.bulk.retryFailed", "Retry failed ({n})").replace(
|
|
606
606
|
"{n}",
|
|
607
|
-
String(
|
|
607
|
+
String(K.error)
|
|
608
608
|
) }),
|
|
609
|
-
/* @__PURE__ */ a("button", { type: "button", className: "nice-btn nice-btn--sm", onClick:
|
|
609
|
+
/* @__PURE__ */ a("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: I, children: i("fileUpload.bulk.clear", "Clear") })
|
|
610
610
|
] }),
|
|
611
611
|
!M && x === "useButtons" && U.length > 0 && !v && /* @__PURE__ */ y("div", { className: "nice-fileuploader__actions nice-upload__actions", children: [
|
|
612
612
|
/* @__PURE__ */ a(
|
|
@@ -614,11 +614,11 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
614
614
|
{
|
|
615
615
|
type: "button",
|
|
616
616
|
className: "nice-btn nice-btn--primary nice-btn--sm",
|
|
617
|
-
onClick: () => C(
|
|
617
|
+
onClick: () => C(f.current),
|
|
618
618
|
children: i("upload", "Upload")
|
|
619
619
|
}
|
|
620
620
|
),
|
|
621
|
-
/* @__PURE__ */ a("button", { type: "button", className: "nice-btn nice-btn--sm", onClick:
|
|
621
|
+
/* @__PURE__ */ a("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: I, children: i("clearAll", "Clear All") })
|
|
622
622
|
] })
|
|
623
623
|
]
|
|
624
624
|
}
|
|
@@ -627,5 +627,5 @@ const wr = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
|
627
627
|
{ displayName: "NiceUpload" }
|
|
628
628
|
);
|
|
629
629
|
export {
|
|
630
|
-
|
|
630
|
+
$r as NiceUpload
|
|
631
631
|
};
|