@nivaro/react 0.3.68 → 0.3.70
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/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/ItemEditForm.js +1754 -1742
- package/dist/shared/components/item-edit/FieldRenderer.js +186 -182
- package/dist/shared/components/item-edit/FileDownloadCount.js +94 -0
- package/dist/shared/components/item-edit/FilePickerField.js +319 -302
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +175 -138
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +53 -52
- package/dist/shared/lib/activity-sentence.js +154 -144
- package/dist/shared/lib/placement-behaviour.js +39 -31
- package/package.json +1 -1
|
@@ -1,69 +1,70 @@
|
|
|
1
|
-
import { jsxs as i, jsx as e, Fragment as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Clock as
|
|
4
|
-
import { useId as
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { useFileHealth as
|
|
7
|
-
import { get as
|
|
8
|
-
import { cn as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
1
|
+
import { jsxs as i, jsx as e, Fragment as J } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as be, useQuery as ee } from "@tanstack/react-query";
|
|
3
|
+
import { Clock as we, Download as ye, Loader2 as te, Upload as de, X as le, Plus as Ke, File as fe, FileVideo as Pe, FileAudio as Oe, FileText as oe, FileSpreadsheet as Qe, FileCode as Ee } from "lucide-react";
|
|
4
|
+
import { useId as ce, useState as L, useRef as Ne, useEffect as G } from "react";
|
|
5
|
+
import { useNivaroClient as me, useGridFlush as ve, useParentDraft as ke } from "../../context.js";
|
|
6
|
+
import { useFileHealth as _e } from "../../hooks/useFileHealth.js";
|
|
7
|
+
import { get as se, post as xe, del as ge } from "../../lib/commands.js";
|
|
8
|
+
import { cn as ue, formatDateTime as Te } from "../../lib/utils.js";
|
|
9
|
+
import { useFileDownloadStats as Fe, FileDownloadCount as Re } from "./FileDownloadCount.js";
|
|
10
|
+
import { useOnceVisible as Ce, useFileUsage as $e, FileUsageChip as Le } from "./FileUsage.js";
|
|
11
|
+
import { useFileDownload as qe } from "./file-download.js";
|
|
12
|
+
import { useM2MStaging as Ae } from "./M2MStagingContext.js";
|
|
13
|
+
function he(s) {
|
|
13
14
|
var y;
|
|
14
|
-
const a = ((s == null ? void 0 : s.title) ?? "").trim(),
|
|
15
|
-
if (!a) return
|
|
16
|
-
const
|
|
17
|
-
return
|
|
15
|
+
const a = ((s == null ? void 0 : s.title) ?? "").trim(), N = ((s == null ? void 0 : s.filename_download) ?? "").trim();
|
|
16
|
+
if (!a) return N;
|
|
17
|
+
const p = (y = /\.([A-Za-z0-9]{1,8})$/.exec(N)) == null ? void 0 : y[1];
|
|
18
|
+
return p ? new RegExp(`\\.${p}$`, "i").test(a) ? a : `${a}.${p}` : a;
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function ne(s) {
|
|
20
21
|
return s ? s < 1024 ? `${s} B` : s < 1024 * 1024 ? `${(s / 1024).toFixed(1)} KB` : `${(s / (1024 * 1024)).toFixed(1)} MB` : null;
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
return s ?
|
|
23
|
+
function Ue(s) {
|
|
24
|
+
return s ? Te(s) : null;
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function Me(s) {
|
|
26
27
|
return !!s && s.startsWith("image/");
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
-
return s ? s.startsWith("video/") ? /* @__PURE__ */ e(
|
|
29
|
+
function Be(s, a) {
|
|
30
|
+
return s ? s.startsWith("video/") ? /* @__PURE__ */ e(Pe, { className: a, strokeWidth: 1.5 }) : s.startsWith("audio/") ? /* @__PURE__ */ e(Oe, { className: a, strokeWidth: 1.5 }) : s === "application/pdf" ? /* @__PURE__ */ e(oe, { className: a, strokeWidth: 1.5 }) : s.startsWith("text/") ? /* @__PURE__ */ e(oe, { className: a, strokeWidth: 1.5 }) : s.includes("spreadsheet") || s.includes("excel") || s === "text/csv" ? /* @__PURE__ */ e(Qe, { className: a, strokeWidth: 1.5 }) : s.includes("wordprocessing") || s.includes("msword") ? /* @__PURE__ */ e(oe, { className: a, strokeWidth: 1.5 }) : s.includes("json") || s.includes("javascript") || s.includes("typescript") || s.includes("xml") ? /* @__PURE__ */ e(Ee, { className: a, strokeWidth: 1.5 }) : /* @__PURE__ */ e(fe, { className: a, strokeWidth: 1.5 }) : /* @__PURE__ */ e(fe, { className: a, strokeWidth: 1.5 });
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
+
function X({
|
|
32
33
|
url: s,
|
|
33
34
|
type: a,
|
|
34
|
-
filename:
|
|
35
|
-
size:
|
|
35
|
+
filename: N,
|
|
36
|
+
size: p = "md"
|
|
36
37
|
}) {
|
|
37
|
-
const y =
|
|
38
|
-
return
|
|
38
|
+
const y = p === "sm" ? "h-10 w-10" : p === "lg" ? "h-20 w-20" : "h-14 w-14";
|
|
39
|
+
return Me(a) ? /* @__PURE__ */ e(
|
|
39
40
|
"img",
|
|
40
41
|
{
|
|
41
42
|
src: s,
|
|
42
|
-
alt:
|
|
43
|
+
alt: N,
|
|
43
44
|
"data-file-thumb": !0,
|
|
44
|
-
className:
|
|
45
|
+
className: ue(y, "object-cover rounded shrink-0"),
|
|
45
46
|
loading: "lazy",
|
|
46
|
-
onError: (
|
|
47
|
-
|
|
47
|
+
onError: (j) => {
|
|
48
|
+
j.target.style.display = "none";
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
) : /* @__PURE__ */ e("div", { className:
|
|
51
|
+
) : /* @__PURE__ */ e("div", { className: ue(y, "flex items-center justify-center rounded bg-slate-100 shrink-0"), children: Be(a, p === "sm" ? "h-4 w-4" : "h-6 w-6") });
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
+
function Se({
|
|
53
54
|
selected: s,
|
|
54
55
|
multi: a,
|
|
55
|
-
onSelect:
|
|
56
|
-
onClose:
|
|
56
|
+
onSelect: N,
|
|
57
|
+
onClose: p,
|
|
57
58
|
getUrl: y
|
|
58
59
|
}) {
|
|
59
|
-
const
|
|
60
|
-
queryKey: ["file-browser",
|
|
61
|
-
queryFn: () =>
|
|
62
|
-
|
|
60
|
+
const j = me(), [x, _] = L(""), { data: F = [], isLoading: c } = ee({
|
|
61
|
+
queryKey: ["file-browser", x],
|
|
62
|
+
queryFn: () => j.request(
|
|
63
|
+
se("/files", {
|
|
63
64
|
limit: "60",
|
|
64
65
|
sort: "-uploaded_on",
|
|
65
66
|
fields: "id,filename_download,title,type,filesize,width,height,missing_at",
|
|
66
|
-
...
|
|
67
|
+
...x ? { search: x } : {}
|
|
67
68
|
})
|
|
68
69
|
).then((d) => d.data ?? []),
|
|
69
70
|
staleTime: 3e4
|
|
@@ -79,9 +80,9 @@ function Re({
|
|
|
79
80
|
{
|
|
80
81
|
type: "button",
|
|
81
82
|
"aria-label": "Close",
|
|
82
|
-
onClick:
|
|
83
|
+
onClick: p,
|
|
83
84
|
className: "text-slate-400 hover:text-slate-600",
|
|
84
|
-
children: /* @__PURE__ */ e(
|
|
85
|
+
children: /* @__PURE__ */ e(le, { className: "h-3.5 w-3.5" })
|
|
85
86
|
}
|
|
86
87
|
)
|
|
87
88
|
] }),
|
|
@@ -90,30 +91,30 @@ function Re({
|
|
|
90
91
|
{
|
|
91
92
|
type: "text",
|
|
92
93
|
placeholder: "Search files…",
|
|
93
|
-
value:
|
|
94
|
-
onChange: (d) =>
|
|
94
|
+
value: x,
|
|
95
|
+
onChange: (d) => _(d.target.value),
|
|
95
96
|
className: "w-full h-7 rounded border border-slate-200 px-2 text-[12px] focus:outline-none focus:ring-1 focus:ring-nvr-cyan",
|
|
96
97
|
autoFocus: !0
|
|
97
98
|
}
|
|
98
99
|
) }),
|
|
99
100
|
/* @__PURE__ */ i("div", { className: "overflow-y-auto flex-1 p-3", children: [
|
|
100
|
-
|
|
101
|
-
!
|
|
102
|
-
!
|
|
103
|
-
const
|
|
101
|
+
c && /* @__PURE__ */ e("div", { className: "flex justify-center py-6", children: /* @__PURE__ */ e(te, { className: "h-5 w-5 animate-spin text-slate-300" }) }),
|
|
102
|
+
!c && F.length === 0 && /* @__PURE__ */ e("p", { className: "text-center text-[12px] text-slate-400 py-6", children: "No files found" }),
|
|
103
|
+
!c && F.length > 0 && /* @__PURE__ */ e("div", { className: "grid grid-cols-5 gap-2", children: F.map((d) => {
|
|
104
|
+
const g = s.includes(d.id);
|
|
104
105
|
return /* @__PURE__ */ i(
|
|
105
106
|
"button",
|
|
106
107
|
{
|
|
107
108
|
type: "button",
|
|
108
|
-
onClick: () =>
|
|
109
|
-
className:
|
|
109
|
+
onClick: () => N(d.id),
|
|
110
|
+
className: ue(
|
|
110
111
|
"nvr-rise-in group flex flex-col items-center gap-1 rounded-lg p-1.5 text-left transition-colors border",
|
|
111
|
-
|
|
112
|
+
g ? "border-nvr-cyan bg-nvr-cyan/5" : "border-transparent hover:border-slate-200 hover:bg-slate-50"
|
|
112
113
|
),
|
|
113
114
|
children: [
|
|
114
115
|
/* @__PURE__ */ i("div", { className: "relative", children: [
|
|
115
116
|
/* @__PURE__ */ e(
|
|
116
|
-
|
|
117
|
+
X,
|
|
117
118
|
{
|
|
118
119
|
url: y(d.id),
|
|
119
120
|
type: d.type,
|
|
@@ -121,7 +122,7 @@ function Re({
|
|
|
121
122
|
size: "md"
|
|
122
123
|
}
|
|
123
124
|
),
|
|
124
|
-
|
|
125
|
+
g && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center rounded bg-nvr-cyan/20", children: /* @__PURE__ */ e("div", { className: "h-4 w-4 rounded-full bg-nvr-cyan flex items-center justify-center", children: /* @__PURE__ */ e(
|
|
125
126
|
"svg",
|
|
126
127
|
{
|
|
127
128
|
className: "h-2.5 w-2.5 text-white",
|
|
@@ -145,7 +146,7 @@ function Re({
|
|
|
145
146
|
{
|
|
146
147
|
"data-file-name": !0,
|
|
147
148
|
className: "text-[10px] text-slate-500 truncate w-full text-center leading-tight",
|
|
148
|
-
children:
|
|
149
|
+
children: he(d)
|
|
149
150
|
}
|
|
150
151
|
)
|
|
151
152
|
]
|
|
@@ -156,97 +157,104 @@ function Re({
|
|
|
156
157
|
] })
|
|
157
158
|
] });
|
|
158
159
|
}
|
|
159
|
-
function
|
|
160
|
+
function st({
|
|
160
161
|
value: s,
|
|
161
162
|
onChange: a,
|
|
162
|
-
disabled:
|
|
163
|
-
allowUpload:
|
|
164
|
-
allowPick: y = !0
|
|
163
|
+
disabled: N,
|
|
164
|
+
allowUpload: p = !0,
|
|
165
|
+
allowPick: y = !0,
|
|
166
|
+
showUsage: j = !0,
|
|
167
|
+
showDownloads: x = !0
|
|
165
168
|
}) {
|
|
166
|
-
var
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
+
var D, V, H;
|
|
170
|
+
const _ = me(), F = be(), c = ve(), d = ce(), [g, W] = L(!1), [q, U] = L(!1), [f, P] = L(null), [Z, A] = L(null), b = Ne(null), r = !f && s ? String(s) : null, v = (m) => _.fileUrl(m), z = qe(), h = ke(), K = ((D = h == null ? void 0 : h.draft) == null ? void 0 : D.id) != null ? String(h.draft.id) : null, [Y, R] = Ce(!!r), C = $e(
|
|
171
|
+
h == null ? void 0 : h.collection,
|
|
169
172
|
K,
|
|
170
173
|
r ? [r] : [],
|
|
171
|
-
|
|
174
|
+
R && j
|
|
175
|
+
), M = Fe(
|
|
176
|
+
h == null ? void 0 : h.collection,
|
|
177
|
+
K,
|
|
178
|
+
r ? [r] : [],
|
|
179
|
+
R && x
|
|
172
180
|
);
|
|
173
|
-
|
|
181
|
+
G(() => {
|
|
174
182
|
if (!f) {
|
|
175
|
-
|
|
183
|
+
A(null);
|
|
176
184
|
return;
|
|
177
185
|
}
|
|
178
|
-
const
|
|
179
|
-
return
|
|
180
|
-
}, [f]),
|
|
181
|
-
if (!(!
|
|
182
|
-
return
|
|
183
|
-
const
|
|
184
|
-
a(
|
|
185
|
-
}), () =>
|
|
186
|
-
}, [
|
|
187
|
-
const
|
|
186
|
+
const m = URL.createObjectURL(f);
|
|
187
|
+
return A(m), () => URL.revokeObjectURL(m);
|
|
188
|
+
}, [f]), G(() => {
|
|
189
|
+
if (!(!c || !f))
|
|
190
|
+
return c.register(d, async () => {
|
|
191
|
+
const m = await _.upload(f);
|
|
192
|
+
a(m.id), P(null), F.invalidateQueries({ queryKey: ["file-browser"] });
|
|
193
|
+
}), () => c.unregister(d);
|
|
194
|
+
}, [c, f, d, _, a, F]);
|
|
195
|
+
const k = _e([r]), { data: n, isLoading: B } = ee({
|
|
188
196
|
queryKey: ["file-meta", r],
|
|
189
|
-
queryFn: () =>
|
|
197
|
+
queryFn: () => _.request(se(`/files/${r}/meta`)).then((m) => m.data ?? null),
|
|
190
198
|
enabled: !!r,
|
|
191
199
|
staleTime: 6e4
|
|
192
200
|
});
|
|
193
|
-
async function
|
|
194
|
-
var
|
|
195
|
-
const
|
|
196
|
-
if (
|
|
197
|
-
if (
|
|
198
|
-
|
|
201
|
+
async function Q(m) {
|
|
202
|
+
var I;
|
|
203
|
+
const O = (I = m.target.files) == null ? void 0 : I[0];
|
|
204
|
+
if (O)
|
|
205
|
+
if (b.current && (b.current.value = ""), c)
|
|
206
|
+
P(O);
|
|
199
207
|
else {
|
|
200
|
-
|
|
201
|
-
new CustomEvent("nvr:upload-state", { detail: { name:
|
|
208
|
+
U(!0), window.dispatchEvent(
|
|
209
|
+
new CustomEvent("nvr:upload-state", { detail: { name: O.name, state: "start" } })
|
|
202
210
|
);
|
|
203
211
|
try {
|
|
204
|
-
const
|
|
205
|
-
a(
|
|
212
|
+
const ie = await _.upload(O);
|
|
213
|
+
a(ie.id), F.invalidateQueries({ queryKey: ["file-browser"] });
|
|
206
214
|
} catch {
|
|
207
215
|
} finally {
|
|
208
|
-
|
|
209
|
-
new CustomEvent("nvr:upload-state", { detail: { name:
|
|
216
|
+
U(!1), window.dispatchEvent(
|
|
217
|
+
new CustomEvent("nvr:upload-state", { detail: { name: O.name, state: "done" } })
|
|
210
218
|
);
|
|
211
219
|
}
|
|
212
220
|
}
|
|
213
221
|
}
|
|
214
|
-
function
|
|
215
|
-
|
|
222
|
+
function ae(m) {
|
|
223
|
+
P(null), a(m), W(!1);
|
|
216
224
|
}
|
|
217
|
-
function
|
|
218
|
-
|
|
225
|
+
function S() {
|
|
226
|
+
P(null), a(null);
|
|
219
227
|
}
|
|
220
|
-
const
|
|
228
|
+
const u = !!f;
|
|
221
229
|
return /* @__PURE__ */ i("div", { className: "relative", children: [
|
|
222
|
-
|
|
230
|
+
u || !!r ? /* @__PURE__ */ i(
|
|
223
231
|
"div",
|
|
224
232
|
{
|
|
225
|
-
ref:
|
|
233
|
+
ref: Y,
|
|
226
234
|
className: "flex items-center gap-2 rounded-lg border border-slate-200 p-2 bg-slate-50",
|
|
227
235
|
children: [
|
|
228
|
-
|
|
229
|
-
|
|
236
|
+
u ? /* @__PURE__ */ e(
|
|
237
|
+
X,
|
|
230
238
|
{
|
|
231
|
-
url:
|
|
239
|
+
url: Z ?? "",
|
|
232
240
|
type: f.type || null,
|
|
233
241
|
filename: f.name,
|
|
234
242
|
size: "sm"
|
|
235
243
|
}
|
|
236
|
-
) :
|
|
244
|
+
) : B ? /* @__PURE__ */ e("div", { className: "h-10 w-10 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))] animate-pulse" }) : (
|
|
237
245
|
// Every file click downloads (2026-11-08): no in-app preview.
|
|
238
246
|
/* @__PURE__ */ e(
|
|
239
247
|
"a",
|
|
240
248
|
{
|
|
241
|
-
href: `${
|
|
249
|
+
href: `${v(r)}?download=1`,
|
|
242
250
|
download: (n == null ? void 0 : n.filename_download) || !0,
|
|
243
|
-
onClick:
|
|
251
|
+
onClick: z(`${v(r)}?download=1`, n == null ? void 0 : n.filename_download),
|
|
244
252
|
title: "Download",
|
|
245
253
|
className: "shrink-0",
|
|
246
254
|
children: /* @__PURE__ */ e(
|
|
247
|
-
|
|
255
|
+
X,
|
|
248
256
|
{
|
|
249
|
-
url:
|
|
257
|
+
url: v(r),
|
|
250
258
|
type: (n == null ? void 0 : n.type) ?? null,
|
|
251
259
|
filename: (n == null ? void 0 : n.filename_download) ?? "",
|
|
252
260
|
size: "sm"
|
|
@@ -257,9 +265,9 @@ function Ze({
|
|
|
257
265
|
),
|
|
258
266
|
/* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
|
|
259
267
|
/* @__PURE__ */ i("div", { className: "flex items-center gap-1", children: [
|
|
260
|
-
|
|
261
|
-
/* @__PURE__ */ e("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children:
|
|
262
|
-
!
|
|
268
|
+
u && /* @__PURE__ */ e(we, { className: "h-3 w-3 text-amber-400 shrink-0" }),
|
|
269
|
+
/* @__PURE__ */ e("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children: u ? f.name : he(n) || r }),
|
|
270
|
+
!u && (k.verdict(r) ?? !!(n != null && n.missing_at)) && /* @__PURE__ */ e(
|
|
263
271
|
"span",
|
|
264
272
|
{
|
|
265
273
|
className: "shrink-0 rounded bg-red-500/10 px-1.5 py-0.5 text-[9.5px] font-semibold uppercase tracking-wide text-red-600 dark:text-red-400",
|
|
@@ -268,77 +276,78 @@ function Ze({
|
|
|
268
276
|
}
|
|
269
277
|
)
|
|
270
278
|
] }),
|
|
271
|
-
/* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children:
|
|
279
|
+
/* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: u ? /* @__PURE__ */ i(J, { children: [
|
|
272
280
|
f.type && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: f.type }),
|
|
273
|
-
/* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children:
|
|
281
|
+
/* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: ne(f.size) }),
|
|
274
282
|
/* @__PURE__ */ e("span", { className: "text-[10px] text-amber-500", children: "Pending upload" })
|
|
275
|
-
] }) : /* @__PURE__ */ i(
|
|
283
|
+
] }) : /* @__PURE__ */ i(J, { children: [
|
|
276
284
|
(n == null ? void 0 : n.type) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: n.type }),
|
|
277
|
-
(n == null ? void 0 : n.filesize) != null && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children:
|
|
278
|
-
(n == null ? void 0 : n.uploaded_on) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children:
|
|
285
|
+
(n == null ? void 0 : n.filesize) != null && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: ne(n.filesize) }),
|
|
286
|
+
(n == null ? void 0 : n.uploaded_on) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: Ue(n.uploaded_on) }),
|
|
279
287
|
(n == null ? void 0 : n.uploaded_by_name) && /* @__PURE__ */ i("span", { className: "text-[10px] text-slate-500", children: [
|
|
280
288
|
"by ",
|
|
281
289
|
n.uploaded_by_name
|
|
282
290
|
] })
|
|
283
291
|
] }) })
|
|
284
292
|
] }),
|
|
285
|
-
!
|
|
286
|
-
|
|
293
|
+
j && !u && r && /* @__PURE__ */ e(
|
|
294
|
+
Le,
|
|
287
295
|
{
|
|
288
296
|
fileId: r,
|
|
289
|
-
uses: (
|
|
290
|
-
loading:
|
|
291
|
-
collection:
|
|
297
|
+
uses: (V = C.data) == null ? void 0 : V[r],
|
|
298
|
+
loading: C.isLoading,
|
|
299
|
+
collection: h == null ? void 0 : h.collection,
|
|
292
300
|
itemId: K
|
|
293
301
|
}
|
|
294
302
|
),
|
|
295
|
-
!
|
|
303
|
+
x && !u && r && /* @__PURE__ */ e(Re, { fileId: r, stat: (H = M.data) == null ? void 0 : H[r] }),
|
|
304
|
+
!u && r && /* @__PURE__ */ e(
|
|
296
305
|
"a",
|
|
297
306
|
{
|
|
298
|
-
href: `${
|
|
299
|
-
onClick:
|
|
307
|
+
href: `${v(r)}?download=1`,
|
|
308
|
+
onClick: z(`${v(r)}?download=1`, n == null ? void 0 : n.filename_download),
|
|
300
309
|
title: "Download",
|
|
301
310
|
className: "shrink-0 text-slate-400 hover:text-nvr-cyan p-0.5",
|
|
302
|
-
children: /* @__PURE__ */ e(
|
|
311
|
+
children: /* @__PURE__ */ e(ye, { className: "h-3.5 w-3.5" })
|
|
303
312
|
}
|
|
304
313
|
),
|
|
305
|
-
!
|
|
314
|
+
!N && /* @__PURE__ */ i("div", { className: "flex items-center gap-1 shrink-0", children: [
|
|
306
315
|
y && /* @__PURE__ */ e(
|
|
307
316
|
"button",
|
|
308
317
|
{
|
|
309
318
|
type: "button",
|
|
310
|
-
onClick: () =>
|
|
319
|
+
onClick: () => W(!0),
|
|
311
320
|
className: "h-6 px-2 rounded border border-slate-200 text-[11px] text-slate-600 hover:border-slate-400",
|
|
312
321
|
children: "Replace"
|
|
313
322
|
}
|
|
314
323
|
),
|
|
315
|
-
|
|
324
|
+
p && /* @__PURE__ */ i(J, { children: [
|
|
316
325
|
/* @__PURE__ */ i(
|
|
317
326
|
"button",
|
|
318
327
|
{
|
|
319
328
|
type: "button",
|
|
320
329
|
onClick: () => {
|
|
321
|
-
var
|
|
322
|
-
return (
|
|
330
|
+
var m;
|
|
331
|
+
return (m = b.current) == null ? void 0 : m.click();
|
|
323
332
|
},
|
|
324
|
-
disabled:
|
|
333
|
+
disabled: q,
|
|
325
334
|
className: "h-6 px-2 rounded border border-slate-200 text-[11px] text-slate-600 hover:border-slate-400 disabled:opacity-40 flex items-center gap-1",
|
|
326
335
|
children: [
|
|
327
|
-
|
|
336
|
+
q ? /* @__PURE__ */ e(te, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(de, { className: "h-3 w-3" }),
|
|
328
337
|
"Upload"
|
|
329
338
|
]
|
|
330
339
|
}
|
|
331
340
|
),
|
|
332
|
-
/* @__PURE__ */ e("input", { ref:
|
|
341
|
+
/* @__PURE__ */ e("input", { ref: b, type: "file", className: "hidden", onChange: Q })
|
|
333
342
|
] }),
|
|
334
343
|
/* @__PURE__ */ e(
|
|
335
344
|
"button",
|
|
336
345
|
{
|
|
337
346
|
type: "button",
|
|
338
347
|
"aria-label": "Remove file",
|
|
339
|
-
onClick:
|
|
348
|
+
onClick: S,
|
|
340
349
|
className: "text-slate-300 hover:text-red-400 p-0.5",
|
|
341
|
-
children: /* @__PURE__ */ e(
|
|
350
|
+
children: /* @__PURE__ */ e(le, { className: "h-3.5 w-3.5" })
|
|
342
351
|
}
|
|
343
352
|
)
|
|
344
353
|
] })
|
|
@@ -349,190 +358,197 @@ function Ze({
|
|
|
349
358
|
"button",
|
|
350
359
|
{
|
|
351
360
|
type: "button",
|
|
352
|
-
disabled:
|
|
353
|
-
onClick: () =>
|
|
361
|
+
disabled: N,
|
|
362
|
+
onClick: () => W(!0),
|
|
354
363
|
className: "flex h-9 flex-1 items-center gap-2 rounded-md border border-dashed border-slate-300 px-3 text-[12px] text-slate-400 hover:border-slate-400 hover:text-slate-600 disabled:opacity-40 transition-colors",
|
|
355
364
|
children: "Select file…"
|
|
356
365
|
}
|
|
357
366
|
),
|
|
358
|
-
|
|
367
|
+
p && !N && /* @__PURE__ */ i(J, { children: [
|
|
359
368
|
/* @__PURE__ */ i(
|
|
360
369
|
"button",
|
|
361
370
|
{
|
|
362
371
|
type: "button",
|
|
363
372
|
onClick: () => {
|
|
364
|
-
var
|
|
365
|
-
return (
|
|
373
|
+
var m;
|
|
374
|
+
return (m = b.current) == null ? void 0 : m.click();
|
|
366
375
|
},
|
|
367
|
-
disabled:
|
|
376
|
+
disabled: q,
|
|
368
377
|
className: "flex h-9 items-center gap-1.5 rounded-md border border-dashed border-slate-300 px-3 text-[12px] text-slate-400 hover:border-slate-400 hover:text-slate-600 disabled:opacity-40 transition-colors",
|
|
369
378
|
children: [
|
|
370
|
-
|
|
379
|
+
q ? /* @__PURE__ */ e(te, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(de, { className: "h-3.5 w-3.5" }),
|
|
371
380
|
"Upload"
|
|
372
381
|
]
|
|
373
382
|
}
|
|
374
383
|
),
|
|
375
|
-
/* @__PURE__ */ e("input", { ref:
|
|
384
|
+
/* @__PURE__ */ e("input", { ref: b, type: "file", className: "hidden", onChange: Q })
|
|
376
385
|
] })
|
|
377
386
|
] }),
|
|
378
|
-
|
|
387
|
+
g && /* @__PURE__ */ e(
|
|
379
388
|
"div",
|
|
380
389
|
{
|
|
381
390
|
className: "absolute z-50 mt-1 rounded-lg border border-slate-200 bg-white shadow-lg dark:border-border dark:bg-card",
|
|
382
391
|
style: { minWidth: 480 },
|
|
383
392
|
children: /* @__PURE__ */ e(
|
|
384
|
-
|
|
393
|
+
Se,
|
|
385
394
|
{
|
|
386
395
|
selected: r ? [r] : [],
|
|
387
396
|
multi: !1,
|
|
388
|
-
onSelect:
|
|
389
|
-
onClose: () =>
|
|
390
|
-
getUrl:
|
|
397
|
+
onSelect: ae,
|
|
398
|
+
onClose: () => W(!1),
|
|
399
|
+
getUrl: v
|
|
391
400
|
}
|
|
392
401
|
)
|
|
393
402
|
}
|
|
394
403
|
)
|
|
395
404
|
] });
|
|
396
405
|
}
|
|
397
|
-
function
|
|
406
|
+
function nt({
|
|
398
407
|
relation: s,
|
|
399
408
|
parentId: a,
|
|
400
|
-
allRelations:
|
|
401
|
-
disabled:
|
|
409
|
+
allRelations: N,
|
|
410
|
+
disabled: p,
|
|
402
411
|
allowUpload: y = !0,
|
|
403
|
-
allowPick:
|
|
404
|
-
pendingSave:
|
|
412
|
+
allowPick: j = !0,
|
|
413
|
+
pendingSave: x = !1,
|
|
414
|
+
showUsage: _ = !0,
|
|
415
|
+
showDownloads: F = !0
|
|
405
416
|
}) {
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
r((
|
|
409
|
-
}, []),
|
|
410
|
-
if (!
|
|
411
|
-
const
|
|
412
|
-
return
|
|
413
|
-
for (const
|
|
414
|
-
const o = await
|
|
415
|
-
URL.revokeObjectURL(
|
|
417
|
+
const c = me(), d = be(), g = ve(), W = ce(), q = ce(), U = Ae(), [f, P] = L(!1), [Z, A] = L(!1), [b, r] = L([]), v = Ne(null), [z, h] = L([]), [K, Y] = L(/* @__PURE__ */ new Set()), R = s.junction_field ?? "", C = s.many_field ?? "", M = s.one_field ?? `${s.many_collection}.${R}`, k = a === "new", n = (t) => c.fileUrl(t), B = qe();
|
|
418
|
+
G(() => () => {
|
|
419
|
+
r((t) => (t.forEach((l) => URL.revokeObjectURL(l.url)), []));
|
|
420
|
+
}, []), G(() => {
|
|
421
|
+
if (!g || !b.length || x) return;
|
|
422
|
+
const t = b;
|
|
423
|
+
return g.register(W, async () => {
|
|
424
|
+
for (const l of t) {
|
|
425
|
+
const o = await c.upload(l.file);
|
|
426
|
+
URL.revokeObjectURL(l.url), await re(o.id);
|
|
416
427
|
}
|
|
417
|
-
r([]),
|
|
418
|
-
}), () =>
|
|
419
|
-
}, [
|
|
420
|
-
if (!
|
|
421
|
-
if (!(
|
|
422
|
-
|
|
428
|
+
r([]), d.invalidateQueries({ queryKey: ["file-browser"] });
|
|
429
|
+
}), () => g.unregister(W);
|
|
430
|
+
}, [g, b, W, x]), G(() => {
|
|
431
|
+
if (!g || !x) return;
|
|
432
|
+
if (!(z.length > 0 || K.size > 0 || b.length > 0)) {
|
|
433
|
+
g.unregister(q);
|
|
423
434
|
return;
|
|
424
435
|
}
|
|
425
|
-
const
|
|
426
|
-
return
|
|
427
|
-
const
|
|
428
|
-
for (const
|
|
429
|
-
const
|
|
430
|
-
URL.revokeObjectURL(
|
|
436
|
+
const l = z, o = new Set(K), w = b;
|
|
437
|
+
return g.register(q, async () => {
|
|
438
|
+
const pe = [];
|
|
439
|
+
for (const E of w) {
|
|
440
|
+
const T = await c.upload(E.file);
|
|
441
|
+
URL.revokeObjectURL(E.url), pe.push(T.id);
|
|
431
442
|
}
|
|
432
|
-
for (const
|
|
433
|
-
await
|
|
434
|
-
|
|
435
|
-
[
|
|
436
|
-
[
|
|
443
|
+
for (const E of [...l, ...pe])
|
|
444
|
+
await c.request(
|
|
445
|
+
xe(`/items/${s.many_collection}`, {
|
|
446
|
+
[C]: a,
|
|
447
|
+
[R]: E
|
|
437
448
|
})
|
|
438
449
|
);
|
|
439
|
-
for (const
|
|
440
|
-
const
|
|
441
|
-
|
|
450
|
+
for (const E of o) {
|
|
451
|
+
const T = Q.find((ze) => String(ze[R]) === E);
|
|
452
|
+
T != null && T.id && await c.request(ge(`/items/${s.many_collection}/${T.id}`));
|
|
442
453
|
}
|
|
443
|
-
|
|
444
|
-
queryKey: ["m2m-items", s.many_collection,
|
|
445
|
-
}),
|
|
446
|
-
}), () =>
|
|
447
|
-
}, [
|
|
448
|
-
const { data:
|
|
449
|
-
queryKey: ["m2m-items", s.many_collection,
|
|
450
|
-
queryFn: () =>
|
|
451
|
-
|
|
452
|
-
filter: JSON.stringify({ [
|
|
454
|
+
h([]), Y(/* @__PURE__ */ new Set()), r([]), d.invalidateQueries({
|
|
455
|
+
queryKey: ["m2m-items", s.many_collection, C, a]
|
|
456
|
+
}), d.invalidateQueries({ queryKey: ["file-browser"] });
|
|
457
|
+
}), () => g.unregister(q);
|
|
458
|
+
}, [g, x, z, K, b, q]);
|
|
459
|
+
const { data: Q = [] } = ee({
|
|
460
|
+
queryKey: ["m2m-items", s.many_collection, C, a],
|
|
461
|
+
queryFn: () => c.request(
|
|
462
|
+
se(`/items/${s.many_collection}`, {
|
|
463
|
+
filter: JSON.stringify({ [C]: { _eq: a } }),
|
|
453
464
|
limit: "200",
|
|
454
|
-
fields: `id,${
|
|
465
|
+
fields: `id,${R}`
|
|
455
466
|
})
|
|
456
|
-
).then((
|
|
457
|
-
enabled: !!a && !
|
|
467
|
+
).then((t) => t.data ?? []),
|
|
468
|
+
enabled: !!a && !k,
|
|
458
469
|
staleTime: 3e4
|
|
459
|
-
}),
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
),
|
|
465
|
-
|
|
470
|
+
}), ae = k && U ? U.getStagedLinks(M) : [], S = Q.map((t) => String(t[R])), u = k ? ae : x ? [...S.filter((t) => !K.has(t)), ...z] : S, $ = ke(), [D, V] = Ce(S.length > 0), H = $e(
|
|
471
|
+
$ == null ? void 0 : $.collection,
|
|
472
|
+
k ? null : a,
|
|
473
|
+
S,
|
|
474
|
+
V && _
|
|
475
|
+
), m = Fe(
|
|
476
|
+
$ == null ? void 0 : $.collection,
|
|
477
|
+
k ? null : a,
|
|
478
|
+
S,
|
|
479
|
+
V && F
|
|
480
|
+
), O = _e(u), { data: I = {} } = ee({
|
|
481
|
+
queryKey: ["files-meta", ...u.sort()],
|
|
466
482
|
queryFn: async () => {
|
|
467
|
-
if (!
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
filter: JSON.stringify({ id: { _in:
|
|
471
|
-
limit: String(
|
|
483
|
+
if (!u.length) return {};
|
|
484
|
+
const t = await c.request(
|
|
485
|
+
se("/files", {
|
|
486
|
+
filter: JSON.stringify({ id: { _in: u } }),
|
|
487
|
+
limit: String(u.length),
|
|
472
488
|
fields: "id,filename_download,title,type,filesize,uploaded_on,uploaded_by_name,missing_at"
|
|
473
489
|
})
|
|
474
|
-
).then((o) => o.data ?? []),
|
|
475
|
-
for (const o of
|
|
476
|
-
return
|
|
490
|
+
).then((o) => o.data ?? []), l = {};
|
|
491
|
+
for (const o of t) l[o.id] = o;
|
|
492
|
+
return l;
|
|
477
493
|
},
|
|
478
|
-
enabled:
|
|
494
|
+
enabled: u.length > 0,
|
|
479
495
|
staleTime: 6e4
|
|
480
496
|
});
|
|
481
|
-
async function
|
|
482
|
-
if (
|
|
483
|
-
|
|
497
|
+
async function ie(t) {
|
|
498
|
+
if (k && U) {
|
|
499
|
+
U.unstageLink(M, t);
|
|
484
500
|
return;
|
|
485
501
|
}
|
|
486
|
-
if (
|
|
487
|
-
|
|
502
|
+
if (x) {
|
|
503
|
+
z.includes(t) ? h((o) => o.filter((w) => w !== t)) : Y((o) => /* @__PURE__ */ new Set([...o, t]));
|
|
488
504
|
return;
|
|
489
505
|
}
|
|
490
|
-
const
|
|
491
|
-
|
|
506
|
+
const l = Q.find((o) => String(o[R]) === t);
|
|
507
|
+
l != null && l.id && (await c.request(ge(`/items/${s.many_collection}/${l.id}`)), d.invalidateQueries({ queryKey: ["m2m-items", s.many_collection, C, a] }));
|
|
492
508
|
}
|
|
493
|
-
async function
|
|
494
|
-
if (!
|
|
495
|
-
if (
|
|
496
|
-
|
|
509
|
+
async function re(t) {
|
|
510
|
+
if (!u.includes(t)) {
|
|
511
|
+
if (k && U) {
|
|
512
|
+
U.stageLink(M, t);
|
|
497
513
|
return;
|
|
498
514
|
}
|
|
499
|
-
if (
|
|
500
|
-
|
|
515
|
+
if (x) {
|
|
516
|
+
h((l) => l.includes(t) ? l : [...l, t]);
|
|
501
517
|
return;
|
|
502
518
|
}
|
|
503
|
-
await
|
|
504
|
-
|
|
505
|
-
),
|
|
519
|
+
await c.request(
|
|
520
|
+
xe(`/items/${s.many_collection}`, { [C]: a, [R]: t })
|
|
521
|
+
), d.invalidateQueries({ queryKey: ["m2m-items", s.many_collection, C, a] });
|
|
506
522
|
}
|
|
507
523
|
}
|
|
508
|
-
function
|
|
509
|
-
URL.revokeObjectURL(
|
|
524
|
+
function je(t) {
|
|
525
|
+
URL.revokeObjectURL(t), r((l) => l.filter((o) => o.url !== t));
|
|
510
526
|
}
|
|
511
|
-
async function
|
|
512
|
-
const
|
|
513
|
-
if (
|
|
514
|
-
if (
|
|
515
|
-
const o =
|
|
516
|
-
r((
|
|
527
|
+
async function We(t) {
|
|
528
|
+
const l = Array.from(t.target.files ?? []);
|
|
529
|
+
if (l.length)
|
|
530
|
+
if (v.current && (v.current.value = ""), g) {
|
|
531
|
+
const o = l.map((w) => ({ file: w, url: URL.createObjectURL(w) }));
|
|
532
|
+
r((w) => [...w, ...o]);
|
|
517
533
|
} else {
|
|
518
|
-
|
|
534
|
+
A(!0);
|
|
519
535
|
try {
|
|
520
|
-
for (const o of
|
|
521
|
-
const
|
|
522
|
-
await
|
|
536
|
+
for (const o of l) {
|
|
537
|
+
const w = await c.upload(o);
|
|
538
|
+
await re(w.id);
|
|
523
539
|
}
|
|
524
|
-
|
|
540
|
+
d.invalidateQueries({ queryKey: ["file-browser"] });
|
|
525
541
|
} catch {
|
|
526
542
|
} finally {
|
|
527
|
-
|
|
543
|
+
A(!1);
|
|
528
544
|
}
|
|
529
545
|
}
|
|
530
546
|
}
|
|
531
547
|
return /* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
532
|
-
(
|
|
533
|
-
|
|
534
|
-
var o;
|
|
535
|
-
const
|
|
548
|
+
(u.length > 0 || b.length > 0) && /* @__PURE__ */ i("div", { ref: D, className: "flex flex-col gap-1.5", children: [
|
|
549
|
+
u.map((t) => {
|
|
550
|
+
var o, w;
|
|
551
|
+
const l = I[t];
|
|
536
552
|
return /* @__PURE__ */ i(
|
|
537
553
|
"div",
|
|
538
554
|
{
|
|
@@ -541,17 +557,17 @@ function Ye({
|
|
|
541
557
|
/* @__PURE__ */ e(
|
|
542
558
|
"a",
|
|
543
559
|
{
|
|
544
|
-
href: `${
|
|
545
|
-
download: (
|
|
546
|
-
onClick:
|
|
560
|
+
href: `${n(t)}?download=1`,
|
|
561
|
+
download: (l == null ? void 0 : l.filename_download) || !0,
|
|
562
|
+
onClick: B(`${n(t)}?download=1`, l == null ? void 0 : l.filename_download),
|
|
547
563
|
title: "Download",
|
|
548
564
|
className: "shrink-0",
|
|
549
565
|
children: /* @__PURE__ */ e(
|
|
550
|
-
|
|
566
|
+
X,
|
|
551
567
|
{
|
|
552
|
-
url:
|
|
553
|
-
type: (
|
|
554
|
-
filename: (
|
|
568
|
+
url: n(t),
|
|
569
|
+
type: (l == null ? void 0 : l.type) ?? null,
|
|
570
|
+
filename: (l == null ? void 0 : l.filename_download) ?? t,
|
|
555
571
|
size: "sm"
|
|
556
572
|
}
|
|
557
573
|
)
|
|
@@ -561,26 +577,26 @@ function Ye({
|
|
|
561
577
|
/* @__PURE__ */ e(
|
|
562
578
|
"a",
|
|
563
579
|
{
|
|
564
|
-
href: `${
|
|
565
|
-
download: (
|
|
566
|
-
onClick:
|
|
580
|
+
href: `${n(t)}?download=1`,
|
|
581
|
+
download: (l == null ? void 0 : l.filename_download) || !0,
|
|
582
|
+
onClick: B(`${n(t)}?download=1`, l == null ? void 0 : l.filename_download),
|
|
567
583
|
title: "Download",
|
|
568
584
|
"data-file-name": !0,
|
|
569
585
|
className: "block w-full truncate text-left text-[12px] font-medium text-slate-700 hover:underline",
|
|
570
|
-
children:
|
|
586
|
+
children: he(l) || t
|
|
571
587
|
}
|
|
572
588
|
),
|
|
573
589
|
/* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: [
|
|
574
|
-
(
|
|
575
|
-
(
|
|
576
|
-
(
|
|
577
|
-
(
|
|
590
|
+
(l == null ? void 0 : l.type) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: l.type }),
|
|
591
|
+
(l == null ? void 0 : l.filesize) != null && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: ne(l.filesize) }),
|
|
592
|
+
(l == null ? void 0 : l.uploaded_on) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: Ue(l.uploaded_on) }),
|
|
593
|
+
(l == null ? void 0 : l.uploaded_by_name) && /* @__PURE__ */ i("span", { className: "text-[10px] text-slate-500", children: [
|
|
578
594
|
"by ",
|
|
579
|
-
|
|
595
|
+
l.uploaded_by_name
|
|
580
596
|
] })
|
|
581
597
|
] })
|
|
582
598
|
] }),
|
|
583
|
-
(
|
|
599
|
+
(O.verdict(t) ?? !!(l != null && l.missing_at)) && /* @__PURE__ */ e(
|
|
584
600
|
"span",
|
|
585
601
|
{
|
|
586
602
|
className: "shrink-0 self-center rounded bg-red-500/10 px-1.5 py-0.5 text-[9.5px] font-semibold uppercase tracking-wide text-red-600 dark:text-red-400",
|
|
@@ -588,91 +604,92 @@ function Ye({
|
|
|
588
604
|
children: "file missing"
|
|
589
605
|
}
|
|
590
606
|
),
|
|
591
|
-
!
|
|
592
|
-
|
|
607
|
+
_ && !k && S.includes(t) && /* @__PURE__ */ e(
|
|
608
|
+
Le,
|
|
593
609
|
{
|
|
594
|
-
fileId:
|
|
595
|
-
uses: (o =
|
|
596
|
-
loading:
|
|
597
|
-
collection:
|
|
610
|
+
fileId: t,
|
|
611
|
+
uses: (o = H.data) == null ? void 0 : o[t],
|
|
612
|
+
loading: H.isLoading,
|
|
613
|
+
collection: $ == null ? void 0 : $.collection,
|
|
598
614
|
itemId: a
|
|
599
615
|
}
|
|
600
616
|
),
|
|
617
|
+
F && !k && S.includes(t) && /* @__PURE__ */ e(Re, { fileId: t, stat: (w = m.data) == null ? void 0 : w[t] }),
|
|
601
618
|
/* @__PURE__ */ e(
|
|
602
619
|
"a",
|
|
603
620
|
{
|
|
604
|
-
href: `${
|
|
605
|
-
onClick:
|
|
621
|
+
href: `${n(t)}?download=1`,
|
|
622
|
+
onClick: B(`${n(t)}?download=1`, l == null ? void 0 : l.filename_download),
|
|
606
623
|
title: "Download",
|
|
607
624
|
className: "shrink-0 text-slate-400 hover:text-nvr-cyan p-0.5",
|
|
608
|
-
children: /* @__PURE__ */ e(
|
|
625
|
+
children: /* @__PURE__ */ e(ye, { className: "h-3.5 w-3.5" })
|
|
609
626
|
}
|
|
610
627
|
),
|
|
611
|
-
!
|
|
628
|
+
!p && /* @__PURE__ */ e(
|
|
612
629
|
"button",
|
|
613
630
|
{
|
|
614
631
|
type: "button",
|
|
615
632
|
"aria-label": "Remove file",
|
|
616
|
-
onClick: () =>
|
|
633
|
+
onClick: () => ie(t),
|
|
617
634
|
className: "text-slate-300 hover:text-red-400 p-0.5 shrink-0",
|
|
618
|
-
children: /* @__PURE__ */ e(
|
|
635
|
+
children: /* @__PURE__ */ e(le, { className: "h-3.5 w-3.5" })
|
|
619
636
|
}
|
|
620
637
|
)
|
|
621
638
|
]
|
|
622
639
|
},
|
|
623
|
-
|
|
640
|
+
t
|
|
624
641
|
);
|
|
625
642
|
}),
|
|
626
|
-
|
|
643
|
+
b.map((t) => /* @__PURE__ */ i(
|
|
627
644
|
"div",
|
|
628
645
|
{
|
|
629
646
|
className: "flex items-center gap-2 rounded-lg border border-amber-200 p-2 bg-amber-50/50",
|
|
630
647
|
children: [
|
|
631
648
|
/* @__PURE__ */ e(
|
|
632
|
-
|
|
649
|
+
X,
|
|
633
650
|
{
|
|
634
|
-
url:
|
|
635
|
-
type:
|
|
636
|
-
filename:
|
|
651
|
+
url: t.url,
|
|
652
|
+
type: t.file.type || null,
|
|
653
|
+
filename: t.file.name,
|
|
637
654
|
size: "sm"
|
|
638
655
|
}
|
|
639
656
|
),
|
|
640
657
|
/* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
|
|
641
658
|
/* @__PURE__ */ i("div", { className: "flex items-center gap-1", children: [
|
|
642
|
-
/* @__PURE__ */ e(
|
|
643
|
-
/* @__PURE__ */ e("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children:
|
|
659
|
+
/* @__PURE__ */ e(we, { className: "h-3 w-3 text-amber-400 shrink-0" }),
|
|
660
|
+
/* @__PURE__ */ e("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children: t.file.name })
|
|
644
661
|
] }),
|
|
645
662
|
/* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: [
|
|
646
|
-
|
|
647
|
-
/* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children:
|
|
663
|
+
t.file.type && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: t.file.type }),
|
|
664
|
+
/* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: ne(t.file.size) }),
|
|
648
665
|
/* @__PURE__ */ e("span", { className: "text-[10px] text-amber-500", children: "Pending upload" })
|
|
649
666
|
] })
|
|
650
667
|
] }),
|
|
651
|
-
!
|
|
668
|
+
!p && /* @__PURE__ */ e(
|
|
652
669
|
"button",
|
|
653
670
|
{
|
|
654
671
|
type: "button",
|
|
655
672
|
"aria-label": "Remove file",
|
|
656
|
-
onClick: () =>
|
|
673
|
+
onClick: () => je(t.url),
|
|
657
674
|
className: "text-slate-300 hover:text-red-400 p-0.5 shrink-0",
|
|
658
|
-
children: /* @__PURE__ */ e(
|
|
675
|
+
children: /* @__PURE__ */ e(le, { className: "h-3.5 w-3.5" })
|
|
659
676
|
}
|
|
660
677
|
)
|
|
661
678
|
]
|
|
662
679
|
},
|
|
663
|
-
|
|
680
|
+
t.url
|
|
664
681
|
))
|
|
665
682
|
] }),
|
|
666
|
-
!
|
|
667
|
-
|
|
683
|
+
!p && /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
|
|
684
|
+
j && /* @__PURE__ */ i("div", { className: "relative", children: [
|
|
668
685
|
/* @__PURE__ */ i(
|
|
669
686
|
"button",
|
|
670
687
|
{
|
|
671
688
|
type: "button",
|
|
672
|
-
onClick: () =>
|
|
689
|
+
onClick: () => P((t) => !t),
|
|
673
690
|
className: "flex h-8 items-center gap-1.5 rounded border border-dashed border-slate-300 px-3 text-[12px] text-slate-400 hover:border-slate-400 hover:text-slate-600 transition-colors",
|
|
674
691
|
children: [
|
|
675
|
-
/* @__PURE__ */ e(
|
|
692
|
+
/* @__PURE__ */ e(Ke, { className: "h-3.5 w-3.5" }),
|
|
676
693
|
"Add existing…"
|
|
677
694
|
]
|
|
678
695
|
}
|
|
@@ -683,31 +700,31 @@ function Ye({
|
|
|
683
700
|
className: "absolute z-50 mt-1 rounded-lg border border-slate-200 bg-white shadow-lg dark:border-border dark:bg-card",
|
|
684
701
|
style: { minWidth: 480 },
|
|
685
702
|
children: /* @__PURE__ */ e(
|
|
686
|
-
|
|
703
|
+
Se,
|
|
687
704
|
{
|
|
688
|
-
selected:
|
|
705
|
+
selected: u,
|
|
689
706
|
multi: !0,
|
|
690
|
-
onSelect: (
|
|
691
|
-
onClose: () =>
|
|
692
|
-
getUrl:
|
|
707
|
+
onSelect: (t) => re(t),
|
|
708
|
+
onClose: () => P(!1),
|
|
709
|
+
getUrl: n
|
|
693
710
|
}
|
|
694
711
|
)
|
|
695
712
|
}
|
|
696
713
|
)
|
|
697
714
|
] }),
|
|
698
|
-
y && /* @__PURE__ */ i(
|
|
715
|
+
y && /* @__PURE__ */ i(J, { children: [
|
|
699
716
|
/* @__PURE__ */ i(
|
|
700
717
|
"button",
|
|
701
718
|
{
|
|
702
719
|
type: "button",
|
|
703
720
|
onClick: () => {
|
|
704
|
-
var
|
|
705
|
-
return (
|
|
721
|
+
var t;
|
|
722
|
+
return (t = v.current) == null ? void 0 : t.click();
|
|
706
723
|
},
|
|
707
|
-
disabled:
|
|
724
|
+
disabled: Z,
|
|
708
725
|
className: "flex h-8 items-center gap-1.5 rounded border border-dashed border-slate-300 px-3 text-[12px] text-slate-400 hover:border-slate-400 hover:text-slate-600 disabled:opacity-40 transition-colors",
|
|
709
726
|
children: [
|
|
710
|
-
|
|
727
|
+
Z ? /* @__PURE__ */ e(te, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(de, { className: "h-3.5 w-3.5" }),
|
|
711
728
|
"Upload…"
|
|
712
729
|
]
|
|
713
730
|
}
|
|
@@ -715,11 +732,11 @@ function Ye({
|
|
|
715
732
|
/* @__PURE__ */ e(
|
|
716
733
|
"input",
|
|
717
734
|
{
|
|
718
|
-
ref:
|
|
735
|
+
ref: v,
|
|
719
736
|
type: "file",
|
|
720
737
|
multiple: !0,
|
|
721
738
|
className: "hidden",
|
|
722
|
-
onChange:
|
|
739
|
+
onChange: We
|
|
723
740
|
}
|
|
724
741
|
)
|
|
725
742
|
] })
|
|
@@ -727,7 +744,7 @@ function Ye({
|
|
|
727
744
|
] });
|
|
728
745
|
}
|
|
729
746
|
export {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
747
|
+
nt as FileM2MField,
|
|
748
|
+
st as FilePickerField,
|
|
749
|
+
he as fileDisplayName
|
|
733
750
|
};
|