@nivaro/react 0.3.9 → 0.3.11
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/components/fields/FileField.js +20 -19
- package/dist/full.css +1 -1
- package/dist/hooks/useNivaroForm.js +129 -126
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +103 -4
- package/dist/index.js +512 -501
- package/dist/shared/components/CollectionBrowserView.js +1632 -1564
- package/dist/shared/components/ConformanceView.js +36 -35
- package/dist/shared/components/ForceReloadBanner.js +58 -34
- package/dist/shared/components/ItemEditForm.js +4386 -4142
- package/dist/shared/components/JsonMapEditor.js +18 -17
- package/dist/shared/components/MatrixEditor.js +8 -7
- package/dist/shared/components/MyWorkView.js +32 -31
- package/dist/shared/components/PageRenderer.js +527 -479
- package/dist/shared/components/QueryStatStrip.js +74 -70
- package/dist/shared/components/RecordGridEditor.js +76 -75
- package/dist/shared/components/ReportView.js +818 -827
- package/dist/shared/components/SheetHeaderBody.js +16 -14
- package/dist/shared/components/ai/AiMemorySuggestions.js +15 -14
- package/dist/shared/components/ai/AskPanel.js +55 -54
- package/dist/shared/components/bulk/BulkActionButtons.js +30 -29
- package/dist/shared/components/bulk/PushBulkButtons.js +57 -56
- package/dist/shared/components/chat/SlashCommands.js +30 -29
- package/dist/shared/components/chat/chat-outbox.js +76 -75
- package/dist/shared/components/help-videos/recorder/useLeaveWarning.js +6 -5
- package/dist/shared/components/integrations/console/SignalCard.js +124 -123
- package/dist/shared/components/integrations/console/SnoozeMenu.js +24 -23
- package/dist/shared/components/item-edit/CatalogPickerField.js +1029 -933
- package/dist/shared/components/item-edit/CloneDialog.js +85 -78
- package/dist/shared/components/item-edit/FieldRenderer.js +161 -156
- package/dist/shared/components/item-edit/FieldRow.js +20 -19
- package/dist/shared/components/item-edit/FilePickerField.js +52 -40
- package/dist/shared/components/item-edit/GroupSection.js +221 -221
- package/dist/shared/components/item-edit/InlineGridField.js +41 -41
- package/dist/shared/components/item-edit/InlineTableField.js +2287 -2275
- package/dist/shared/components/item-edit/M2MCombobox.js +46 -44
- package/dist/shared/components/item-edit/MembershipSetField.js +24 -23
- package/dist/shared/components/item-edit/NestedRelationEditor.js +11 -11
- package/dist/shared/components/item-edit/QuickCreateButton.js +8 -7
- package/dist/shared/components/item-edit/QuickPicker.js +263 -216
- package/dist/shared/components/item-edit/RecordLiveSync.js +101 -100
- package/dist/shared/components/item-edit/RelationCombobox.js +285 -245
- package/dist/shared/components/item-edit/RichTextEditorImpl.js +42 -32
- package/dist/shared/components/item-edit/RowHistorySheet.js +130 -134
- package/dist/shared/components/item-edit/SummaryPanel.js +305 -279
- package/dist/shared/components/item-edit/helpers.js +133 -134
- package/dist/shared/components/item-edit/line-qty.js +57 -0
- package/dist/shared/components/item-edit/option-disambiguate.js +53 -0
- package/dist/shared/components/item-edit/staged-links.js +86 -0
- package/dist/shared/components/layout-editor/LayoutEditor.js +275 -274
- package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +18 -17
- package/dist/shared/components/layout-editor/inspector/HelpTab.js +37 -36
- package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +50 -49
- package/dist/shared/components/panels/AddendumLinesDiff.js +87 -90
- package/dist/shared/components/panels/CommentPanel.js +350 -315
- package/dist/shared/components/panels/ItemLockBanner.js +297 -230
- package/dist/shared/components/panels/PipelinePanel.js +719 -701
- package/dist/shared/components/profile/AiMemoryCard.js +15 -14
- package/dist/shared/components/profile/PersonAdminTools.js +70 -67
- package/dist/shared/components/queue/QueueItemSheet.js +36 -35
- package/dist/shared/components/queue/QueueQuickFilters.js +43 -41
- package/dist/shared/components/queue/QueueWorklist.js +1026 -957
- package/dist/shared/components/widgets/ReviewListWidget.js +99 -93
- package/dist/shared/lib/client-version.js +63 -0
- package/dist/shared/lib/force-reload.js +36 -0
- package/dist/shared/lib/load-error.js +11 -10
- package/dist/shared/lib/obligation-banner.js +14 -13
- package/dist/shared/lib/obligation-reason-text.js +13 -0
- package/dist/shared/lib/presence-live.js +54 -35
- package/dist/shared/lib/query-filter-seed.js +34 -11
- package/dist/shared/lib/record-outbox.js +76 -75
- package/dist/shared/lib/safe-error.js +39 -0
- package/dist/shared/lib/sanitize-html.js +24 -15
- package/dist/shared/lib/server-clock.js +11 -7
- package/dist/shared/lib/sheet-def.js +38 -22
- package/dist/shared/lib/unique-options.js +10 -0
- package/dist/shared/lib/unsaved-work.js +62 -0
- package/dist/shared/lib/utils.js +57 -43
- package/dist/shared/lib/validation-rules.js +58 -34
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ import { FormHelpVideoButton as ft } from "./FormHelpVideoButton.js";
|
|
|
18
18
|
import { getCascadeFilters as yt, SYSTEM_FIELDS as bt, parseJson as gt, buildCascadeFilter as vt, CascadeEffectController as wt } from "./helpers.js";
|
|
19
19
|
import { isDerivedForRecord as kt } from "./live-rollups.js";
|
|
20
20
|
import { useM2MStaging as _t } from "./M2MStagingContext.js";
|
|
21
|
-
import { usePlacementTextContext as Nt, placementFieldText as Ct, isDisplayFormulaRow as Ft, fieldCounterConfig as Lt, fieldIsRecommended as Rt, RecommendedMarker as
|
|
21
|
+
import { usePlacementTextContext as Nt, placementFieldText as Ct, isDisplayFormulaRow as Ft, fieldCounterConfig as Lt, fieldIsRecommended as Rt, RecommendedMarker as St, RepeatLastButton as $t, DisplayFormulaValue as Tt, FieldCounter as qt } from "./placement-behaviour.js";
|
|
22
22
|
import { resolveOptionFilterTokens as jt } from "../../lib/option-filter-tokens.js";
|
|
23
23
|
const Pt = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger", "number"]), Et = /* @__PURE__ */ new Set(["string", "text", "richtext", "textarea", "markdown", "json", "csv"]), At = /* @__PURE__ */ new Set([
|
|
24
24
|
"input",
|
|
@@ -337,7 +337,7 @@ function hn({
|
|
|
337
337
|
const ee = Mt.has(e.interface ?? ""), F = tt(), b = _t(), pe = Ce(), te = I(), [he, B] = ce(!1), s = dt(), ne = ue(null), {
|
|
338
338
|
onContextMenu: Le,
|
|
339
339
|
onKeyDown: Re,
|
|
340
|
-
menu:
|
|
340
|
+
menu: Se
|
|
341
341
|
} = ct({
|
|
342
342
|
wrapperRef: ne,
|
|
343
343
|
field: e,
|
|
@@ -346,7 +346,7 @@ function hn({
|
|
|
346
346
|
collection: c,
|
|
347
347
|
itemId: i,
|
|
348
348
|
openRelated: s == null ? void 0 : s.openRelated
|
|
349
|
-
}),
|
|
349
|
+
}), S = ut(ne), $e = Nt(), xe = s == null ? void 0 : s.remoteChanges[e.field], E = s == null ? void 0 : s.lockReasons[e.field], L = s == null ? void 0 : s.applyToLines[e.field], H = nt(e._overrides, v, Kt(e)), ae = !!(s != null && s.fromAutofill) && !!e._overrides && e._overrides[at] === !0;
|
|
350
350
|
async function Te() {
|
|
351
351
|
var t;
|
|
352
352
|
if (H.perField) return qe();
|
|
@@ -388,7 +388,7 @@ function hn({
|
|
|
388
388
|
B(!1);
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
|
-
const
|
|
391
|
+
const $ = yt(e.dependency_config), fe = $.flatMap((t) => {
|
|
392
392
|
const r = p.find(
|
|
393
393
|
(N) => N.one_collection === c && N.one_field === t.parent_field
|
|
394
394
|
);
|
|
@@ -423,7 +423,7 @@ function hn({
|
|
|
423
423
|
), W = ot()[e.field] ?? [];
|
|
424
424
|
if (!U && (!_ || !e.layout_assigned && (e.hidden || bt.has(e.field))))
|
|
425
425
|
return null;
|
|
426
|
-
const re = o[e.field] ?? null, V = Ct(e,
|
|
426
|
+
const re = o[e.field] ?? null, V = Ct(e, $e), A = V.label ?? se(e.field), T = Ft(e), ye = T ? null : Lt(e), Ee = !T && !m && !e.readonly && ((we = e._overrides) == null ? void 0 : we.repeat_last) === !0, Ae = kt(e, o), De = (_e = (ke = gt(e.options)) == null ? void 0 : ke.auto_id) == null ? void 0 : _e.pattern, w = (() => {
|
|
427
427
|
const t = p.find(
|
|
428
428
|
(x) => x.one_collection === c && x.one_field === e.field
|
|
429
429
|
);
|
|
@@ -444,7 +444,7 @@ function hn({
|
|
|
444
444
|
var r;
|
|
445
445
|
return ((F == null ? void 0 : F.collection) === c ? (r = F == null ? void 0 : F.fieldLabels) == null ? void 0 : r[t] : void 0) ?? se(String(t));
|
|
446
446
|
}, q = vt({
|
|
447
|
-
rules:
|
|
447
|
+
rules: $,
|
|
448
448
|
// A parent whose value THIS field's own pick derived must not narrow this
|
|
449
449
|
// field's options — otherwise picking a region locks the region picker
|
|
450
450
|
// into the zone the pick itself filled, and cross-zone changes read as
|
|
@@ -513,13 +513,13 @@ function hn({
|
|
|
513
513
|
),
|
|
514
514
|
onContextMenu: Le,
|
|
515
515
|
onKeyDown: Re,
|
|
516
|
-
onFocusCapture:
|
|
516
|
+
onFocusCapture: S.onFocusCapture,
|
|
517
517
|
children: [
|
|
518
|
-
|
|
519
|
-
|
|
518
|
+
Se,
|
|
519
|
+
$.length > 0 && /* @__PURE__ */ n(
|
|
520
520
|
wt,
|
|
521
521
|
{
|
|
522
|
-
cascadeRules:
|
|
522
|
+
cascadeRules: $,
|
|
523
523
|
cascadeFilter: M,
|
|
524
524
|
currentValue: Ke,
|
|
525
525
|
relatedCollection: Oe,
|
|
@@ -531,7 +531,7 @@ function hn({
|
|
|
531
531
|
A !== "" && /* @__PURE__ */ d(it, { "data-field-label": !0, className: "text-sm font-medium", children: [
|
|
532
532
|
/* @__PURE__ */ n(Ne, { text: A, collection: c }),
|
|
533
533
|
e.required && /* @__PURE__ */ n("span", { className: "ml-0.5 text-destructive", children: "*" }),
|
|
534
|
-
Rt(e) && /* @__PURE__ */ n(
|
|
534
|
+
Rt(e) && /* @__PURE__ */ n(St, {})
|
|
535
535
|
] }),
|
|
536
536
|
V.note && /* @__PURE__ */ n(Q, { delayDuration: 100, children: /* @__PURE__ */ d(Y, { children: [
|
|
537
537
|
/* @__PURE__ */ n(J, { asChild: !0, children: /* @__PURE__ */ n(ze, { className: "h-3.5 w-3.5 shrink-0 cursor-help text-slate-400 hover:text-slate-600" }) }),
|
|
@@ -549,7 +549,7 @@ function hn({
|
|
|
549
549
|
!T && i && i !== "new" && /* @__PURE__ */ n(Ht, { collection: c, itemId: i, field: e.field }),
|
|
550
550
|
i && i !== "new" && Ae && /* @__PURE__ */ n(Ut, { collection: c, itemId: i, field: e.field }),
|
|
551
551
|
Ee && /* @__PURE__ */ n(
|
|
552
|
-
|
|
552
|
+
$t,
|
|
553
553
|
{
|
|
554
554
|
collection: c,
|
|
555
555
|
itemId: i,
|
|
@@ -632,8 +632,8 @@ function hn({
|
|
|
632
632
|
/* @__PURE__ */ n(J, { asChild: !0, children: /* @__PURE__ */ n("span", { className: "inline-flex items-center text-amber-400 dark:text-amber-500", children: /* @__PURE__ */ n(Ye, { className: "h-3 w-3" }) }) }),
|
|
633
633
|
/* @__PURE__ */ n(X, { side: "top", className: "text-[12px]", children: "This field is locked" })
|
|
634
634
|
] }) }) : null,
|
|
635
|
-
|
|
636
|
-
const t = !!M && Object.keys(M).length > 0 && G.length > 0, r =
|
|
635
|
+
$.length > 0 && (() => {
|
|
636
|
+
const t = !!M && Object.keys(M).length > 0 && G.length > 0, r = $.map(
|
|
637
637
|
(x) => z(String(x.parent_field))
|
|
638
638
|
);
|
|
639
639
|
return /* @__PURE__ */ n(Q, { delayDuration: 100, children: /* @__PURE__ */ d(Y, { children: [
|
|
@@ -641,6 +641,7 @@ function hn({
|
|
|
641
641
|
"button",
|
|
642
642
|
{
|
|
643
643
|
type: "button",
|
|
644
|
+
"aria-label": "Show the fields that narrow this list",
|
|
644
645
|
onClick: Be,
|
|
645
646
|
className: P(
|
|
646
647
|
"inline-flex items-center transition-colors",
|
|
@@ -653,13 +654,13 @@ function hn({
|
|
|
653
654
|
] }) });
|
|
654
655
|
})()
|
|
655
656
|
] }),
|
|
656
|
-
|
|
657
|
+
S.editor && !m && /* @__PURE__ */ n(
|
|
657
658
|
pt,
|
|
658
659
|
{
|
|
659
|
-
editor:
|
|
660
|
-
confirming:
|
|
661
|
-
onConfirm:
|
|
662
|
-
onCancel:
|
|
660
|
+
editor: S.editor,
|
|
661
|
+
confirming: S.confirming,
|
|
662
|
+
onConfirm: S.confirm,
|
|
663
|
+
onCancel: S.cancel
|
|
663
664
|
}
|
|
664
665
|
),
|
|
665
666
|
h ?? /* @__PURE__ */ n(
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs as i, jsx as e, Fragment as A } from "react/jsx-runtime";
|
|
2
2
|
import { useQueryClient as pe, useQuery as Z } from "@tanstack/react-query";
|
|
3
3
|
import { Clock as fe, Download as xe, Loader2 as D, Upload as ie, X as I, Plus as ze, File as ue, FileVideo as Se, FileAudio as je, FileText as ae, FileSpreadsheet as Pe, FileCode as We } from "lucide-react";
|
|
4
|
-
import { useId as re, useState as
|
|
4
|
+
import { useId as re, useState as w, useRef as ge, useEffect as B } from "react";
|
|
5
5
|
import { useNivaroClient as ce, useGridFlush as be, useParentDraft as ye } from "../../context.js";
|
|
6
|
-
import { useFileHealth as
|
|
6
|
+
import { useFileHealth as ve } from "../../hooks/useFileHealth.js";
|
|
7
7
|
import { get as ee, post as me, del as he } from "../../lib/commands.js";
|
|
8
8
|
import { cn as oe } from "../../lib/utils.js";
|
|
9
|
-
import { FilePreviewLightbox as
|
|
9
|
+
import { FilePreviewLightbox as we } from "../FilePreviewLightbox.js";
|
|
10
10
|
import { useOnceVisible as Ne, useFileUsage as ke, FileUsageChip as _e } from "./FileUsage.js";
|
|
11
11
|
import { useM2MStaging as Ke } from "./M2MStagingContext.js";
|
|
12
12
|
function te(s) {
|
|
@@ -51,7 +51,7 @@ function Le({
|
|
|
51
51
|
onClose: y,
|
|
52
52
|
getUrl: L
|
|
53
53
|
}) {
|
|
54
|
-
const N = ce(), [h, u] =
|
|
54
|
+
const N = ce(), [h, u] = w(""), { data: g = [], isLoading: p } = Z({
|
|
55
55
|
queryKey: ["file-browser", h],
|
|
56
56
|
queryFn: () => N.request(
|
|
57
57
|
ee("/files", {
|
|
@@ -69,7 +69,16 @@ function Le({
|
|
|
69
69
|
"Select file",
|
|
70
70
|
a ? "s" : ""
|
|
71
71
|
] }),
|
|
72
|
-
/* @__PURE__ */ e(
|
|
72
|
+
/* @__PURE__ */ e(
|
|
73
|
+
"button",
|
|
74
|
+
{
|
|
75
|
+
type: "button",
|
|
76
|
+
"aria-label": "Close",
|
|
77
|
+
onClick: y,
|
|
78
|
+
className: "text-slate-400 hover:text-slate-600",
|
|
79
|
+
children: /* @__PURE__ */ e(I, { className: "h-3.5 w-3.5" })
|
|
80
|
+
}
|
|
81
|
+
)
|
|
73
82
|
] }),
|
|
74
83
|
/* @__PURE__ */ e("div", { className: "px-3 pt-2 pb-1 shrink-0", children: /* @__PURE__ */ e(
|
|
75
84
|
"input",
|
|
@@ -86,7 +95,7 @@ function Le({
|
|
|
86
95
|
p && /* @__PURE__ */ e("div", { className: "flex justify-center py-6", children: /* @__PURE__ */ e(D, { className: "h-5 w-5 animate-spin text-slate-300" }) }),
|
|
87
96
|
!p && g.length === 0 && /* @__PURE__ */ e("p", { className: "text-center text-[12px] text-slate-400 py-6", children: "No files found" }),
|
|
88
97
|
!p && g.length > 0 && /* @__PURE__ */ e("div", { className: "grid grid-cols-5 gap-2", children: g.map((c) => {
|
|
89
|
-
const
|
|
98
|
+
const v = s.includes(c.id);
|
|
90
99
|
return /* @__PURE__ */ i(
|
|
91
100
|
"button",
|
|
92
101
|
{
|
|
@@ -94,7 +103,7 @@ function Le({
|
|
|
94
103
|
onClick: () => S(c.id),
|
|
95
104
|
className: oe(
|
|
96
105
|
"nvr-rise-in group flex flex-col items-center gap-1 rounded-lg p-1.5 text-left transition-colors border",
|
|
97
|
-
|
|
106
|
+
v ? "border-nvr-cyan bg-nvr-cyan/5" : "border-transparent hover:border-slate-200 hover:bg-slate-50"
|
|
98
107
|
),
|
|
99
108
|
children: [
|
|
100
109
|
/* @__PURE__ */ i("div", { className: "relative", children: [
|
|
@@ -107,7 +116,7 @@ function Le({
|
|
|
107
116
|
size: "md"
|
|
108
117
|
}
|
|
109
118
|
),
|
|
110
|
-
|
|
119
|
+
v && /* @__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(
|
|
111
120
|
"svg",
|
|
112
121
|
{
|
|
113
122
|
className: "h-2.5 w-2.5 text-white",
|
|
@@ -150,7 +159,7 @@ function Ye({
|
|
|
150
159
|
allowPick: L = !0
|
|
151
160
|
}) {
|
|
152
161
|
var z, X;
|
|
153
|
-
const N = ce(), h = pe(), u = be(), g = re(), [p, c] =
|
|
162
|
+
const N = ce(), h = pe(), u = be(), g = re(), [p, c] = w(!1), [v, R] = w(!1), [H, E] = w(null), [m, W] = w(null), [J, K] = w(null), x = ge(null), r = !m && s ? String(s) : null, U = (d) => N.fileUrl(d), f = ye(), $ = ((z = f == null ? void 0 : f.draft) == null ? void 0 : z.id) != null ? String(f.draft.id) : null, [O, G] = Ne(!!r), _ = ke(
|
|
154
163
|
f == null ? void 0 : f.collection,
|
|
155
164
|
$,
|
|
156
165
|
r ? [r] : [],
|
|
@@ -170,7 +179,7 @@ function Ye({
|
|
|
170
179
|
a(d.id), W(null), h.invalidateQueries({ queryKey: ["file-browser"] });
|
|
171
180
|
}), () => u.unregister(g);
|
|
172
181
|
}, [u, m, g, N, a, h]);
|
|
173
|
-
const q =
|
|
182
|
+
const q = ve([r]), { data: n, isLoading: C } = Z({
|
|
174
183
|
queryKey: ["file-meta", r],
|
|
175
184
|
queryFn: () => N.request(ee(`/files/${r}/meta`)).then((d) => d.data ?? null),
|
|
176
185
|
enabled: !!r,
|
|
@@ -183,7 +192,7 @@ function Ye({
|
|
|
183
192
|
if (x.current && (x.current.value = ""), u)
|
|
184
193
|
W(P);
|
|
185
194
|
else {
|
|
186
|
-
|
|
195
|
+
R(!0), window.dispatchEvent(
|
|
187
196
|
new CustomEvent("nvr:upload-state", { detail: { name: P.name, state: "start" } })
|
|
188
197
|
);
|
|
189
198
|
try {
|
|
@@ -191,7 +200,7 @@ function Ye({
|
|
|
191
200
|
a(se.id), h.invalidateQueries({ queryKey: ["file-browser"] });
|
|
192
201
|
} catch {
|
|
193
202
|
} finally {
|
|
194
|
-
|
|
203
|
+
R(!1), window.dispatchEvent(
|
|
195
204
|
new CustomEvent("nvr:upload-state", { detail: { name: P.name, state: "done" } })
|
|
196
205
|
);
|
|
197
206
|
}
|
|
@@ -205,7 +214,7 @@ function Ye({
|
|
|
205
214
|
}
|
|
206
215
|
const b = !!m;
|
|
207
216
|
return /* @__PURE__ */ i("div", { className: "relative", children: [
|
|
208
|
-
H && /* @__PURE__ */ e(
|
|
217
|
+
H && /* @__PURE__ */ e(we, { file: H, onClose: () => E(null) }),
|
|
209
218
|
b || !!r ? /* @__PURE__ */ i(
|
|
210
219
|
"div",
|
|
211
220
|
{
|
|
@@ -227,7 +236,7 @@ function Ye({
|
|
|
227
236
|
title: "Preview",
|
|
228
237
|
onClick: () => E({
|
|
229
238
|
id: r,
|
|
230
|
-
url:
|
|
239
|
+
url: U(r),
|
|
231
240
|
name: (n == null ? void 0 : n.title) || (n == null ? void 0 : n.filename_download) || r,
|
|
232
241
|
type: (n == null ? void 0 : n.type) ?? null,
|
|
233
242
|
size: (n == null ? void 0 : n.filesize) ?? null
|
|
@@ -236,7 +245,7 @@ function Ye({
|
|
|
236
245
|
children: /* @__PURE__ */ e(
|
|
237
246
|
V,
|
|
238
247
|
{
|
|
239
|
-
url:
|
|
248
|
+
url: U(r),
|
|
240
249
|
type: (n == null ? void 0 : n.type) ?? null,
|
|
241
250
|
filename: (n == null ? void 0 : n.filename_download) ?? "",
|
|
242
251
|
size: "sm"
|
|
@@ -284,7 +293,7 @@ function Ye({
|
|
|
284
293
|
!b && r && /* @__PURE__ */ e(
|
|
285
294
|
"a",
|
|
286
295
|
{
|
|
287
|
-
href: `${
|
|
296
|
+
href: `${U(r)}?download=1`,
|
|
288
297
|
title: "Download",
|
|
289
298
|
className: "shrink-0 text-slate-400 hover:text-nvr-cyan p-0.5",
|
|
290
299
|
children: /* @__PURE__ */ e(xe, { className: "h-3.5 w-3.5" })
|
|
@@ -309,10 +318,10 @@ function Ye({
|
|
|
309
318
|
var d;
|
|
310
319
|
return (d = x.current) == null ? void 0 : d.click();
|
|
311
320
|
},
|
|
312
|
-
disabled:
|
|
321
|
+
disabled: v,
|
|
313
322
|
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",
|
|
314
323
|
children: [
|
|
315
|
-
|
|
324
|
+
v ? /* @__PURE__ */ e(D, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(ie, { className: "h-3 w-3" }),
|
|
316
325
|
"Upload"
|
|
317
326
|
]
|
|
318
327
|
}
|
|
@@ -323,6 +332,7 @@ function Ye({
|
|
|
323
332
|
"button",
|
|
324
333
|
{
|
|
325
334
|
type: "button",
|
|
335
|
+
"aria-label": "Remove file",
|
|
326
336
|
onClick: le,
|
|
327
337
|
className: "text-slate-300 hover:text-red-400 p-0.5",
|
|
328
338
|
children: /* @__PURE__ */ e(I, { className: "h-3.5 w-3.5" })
|
|
@@ -351,10 +361,10 @@ function Ye({
|
|
|
351
361
|
var d;
|
|
352
362
|
return (d = x.current) == null ? void 0 : d.click();
|
|
353
363
|
},
|
|
354
|
-
disabled:
|
|
364
|
+
disabled: v,
|
|
355
365
|
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",
|
|
356
366
|
children: [
|
|
357
|
-
|
|
367
|
+
v ? /* @__PURE__ */ e(D, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(ie, { className: "h-3.5 w-3.5" }),
|
|
358
368
|
"Upload"
|
|
359
369
|
]
|
|
360
370
|
}
|
|
@@ -374,7 +384,7 @@ function Ye({
|
|
|
374
384
|
multi: !1,
|
|
375
385
|
onSelect: M,
|
|
376
386
|
onClose: () => c(!1),
|
|
377
|
-
getUrl:
|
|
387
|
+
getUrl: U
|
|
378
388
|
}
|
|
379
389
|
)
|
|
380
390
|
}
|
|
@@ -390,7 +400,7 @@ function Ze({
|
|
|
390
400
|
allowPick: N = !0,
|
|
391
401
|
pendingSave: h = !1
|
|
392
402
|
}) {
|
|
393
|
-
const u = ce(), g = pe(), p = be(), c = re(),
|
|
403
|
+
const u = ce(), g = pe(), p = be(), c = re(), v = re(), R = Ke(), [H, E] = w(!1), [m, W] = w(!1), [J, K] = w(null), [x, r] = w([]), U = ge(null), [f, $] = w([]), [O, G] = w(/* @__PURE__ */ new Set()), _ = s.junction_field ?? "", q = s.many_field ?? "", n = s.one_field ?? `${s.many_collection}.${_}`, C = a === "new", j = (l) => u.fileUrl(l);
|
|
394
404
|
B(() => () => {
|
|
395
405
|
r((l) => (l.forEach((t) => URL.revokeObjectURL(t.url)), []));
|
|
396
406
|
}, []), B(() => {
|
|
@@ -406,11 +416,11 @@ function Ze({
|
|
|
406
416
|
}, [p, x, c, h]), B(() => {
|
|
407
417
|
if (!p || !h) return;
|
|
408
418
|
if (!(f.length > 0 || O.size > 0 || x.length > 0)) {
|
|
409
|
-
p.unregister(
|
|
419
|
+
p.unregister(v);
|
|
410
420
|
return;
|
|
411
421
|
}
|
|
412
422
|
const t = f, o = new Set(O), F = x;
|
|
413
|
-
return p.register(
|
|
423
|
+
return p.register(v, async () => {
|
|
414
424
|
const de = [];
|
|
415
425
|
for (const Q of F) {
|
|
416
426
|
const T = await u.upload(Q.file);
|
|
@@ -430,8 +440,8 @@ function Ze({
|
|
|
430
440
|
$([]), G(/* @__PURE__ */ new Set()), r([]), g.invalidateQueries({
|
|
431
441
|
queryKey: ["m2m-items", s.many_collection, q, a]
|
|
432
442
|
}), g.invalidateQueries({ queryKey: ["file-browser"] });
|
|
433
|
-
}), () => p.unregister(
|
|
434
|
-
}, [p, h, f, O, x,
|
|
443
|
+
}), () => p.unregister(v);
|
|
444
|
+
}, [p, h, f, O, x, v]);
|
|
435
445
|
const { data: M = [] } = Z({
|
|
436
446
|
queryKey: ["m2m-items", s.many_collection, q, a],
|
|
437
447
|
queryFn: () => u.request(
|
|
@@ -443,12 +453,12 @@ function Ze({
|
|
|
443
453
|
).then((l) => l.data ?? []),
|
|
444
454
|
enabled: !!a && !C,
|
|
445
455
|
staleTime: 3e4
|
|
446
|
-
}), le = C &&
|
|
456
|
+
}), le = C && R ? R.getStagedLinks(n) : [], b = M.map((l) => String(l[_])), k = C ? le : h ? [...b.filter((l) => !O.has(l)), ...f] : b, z = ye(), [X, d] = Ne(b.length > 0), P = ke(
|
|
447
457
|
z == null ? void 0 : z.collection,
|
|
448
458
|
C ? null : a,
|
|
449
459
|
b,
|
|
450
460
|
d
|
|
451
|
-
), Y =
|
|
461
|
+
), Y = ve(k), { data: se = {} } = Z({
|
|
452
462
|
queryKey: ["files-meta", ...k.sort()],
|
|
453
463
|
queryFn: async () => {
|
|
454
464
|
if (!k.length) return {};
|
|
@@ -465,9 +475,9 @@ function Ze({
|
|
|
465
475
|
enabled: k.length > 0,
|
|
466
476
|
staleTime: 6e4
|
|
467
477
|
});
|
|
468
|
-
async function
|
|
469
|
-
if (C &&
|
|
470
|
-
|
|
478
|
+
async function Re(l) {
|
|
479
|
+
if (C && R) {
|
|
480
|
+
R.unstageLink(n, l);
|
|
471
481
|
return;
|
|
472
482
|
}
|
|
473
483
|
if (h) {
|
|
@@ -479,8 +489,8 @@ function Ze({
|
|
|
479
489
|
}
|
|
480
490
|
async function ne(l) {
|
|
481
491
|
if (!k.includes(l)) {
|
|
482
|
-
if (C &&
|
|
483
|
-
|
|
492
|
+
if (C && R) {
|
|
493
|
+
R.stageLink(n, l);
|
|
484
494
|
return;
|
|
485
495
|
}
|
|
486
496
|
if (h) {
|
|
@@ -492,13 +502,13 @@ function Ze({
|
|
|
492
502
|
), g.invalidateQueries({ queryKey: ["m2m-items", s.many_collection, q, a] });
|
|
493
503
|
}
|
|
494
504
|
}
|
|
495
|
-
function
|
|
505
|
+
function Ue(l) {
|
|
496
506
|
URL.revokeObjectURL(l), r((t) => t.filter((o) => o.url !== l));
|
|
497
507
|
}
|
|
498
508
|
async function qe(l) {
|
|
499
509
|
const t = Array.from(l.target.files ?? []);
|
|
500
510
|
if (t.length)
|
|
501
|
-
if (
|
|
511
|
+
if (U.current && (U.current.value = ""), p) {
|
|
502
512
|
const o = t.map((F) => ({ file: F, url: URL.createObjectURL(F) }));
|
|
503
513
|
r((F) => [...F, ...o]);
|
|
504
514
|
} else {
|
|
@@ -516,7 +526,7 @@ function Ze({
|
|
|
516
526
|
}
|
|
517
527
|
}
|
|
518
528
|
return /* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
519
|
-
J && /* @__PURE__ */ e(
|
|
529
|
+
J && /* @__PURE__ */ e(we, { file: J, onClose: () => K(null) }),
|
|
520
530
|
(k.length > 0 || x.length > 0) && /* @__PURE__ */ i("div", { ref: X, className: "flex flex-col gap-1.5", children: [
|
|
521
531
|
k.map((l) => {
|
|
522
532
|
var o;
|
|
@@ -608,7 +618,8 @@ function Ze({
|
|
|
608
618
|
"button",
|
|
609
619
|
{
|
|
610
620
|
type: "button",
|
|
611
|
-
|
|
621
|
+
"aria-label": "Remove file",
|
|
622
|
+
onClick: () => Re(l),
|
|
612
623
|
className: "text-slate-300 hover:text-red-400 p-0.5 shrink-0",
|
|
613
624
|
children: /* @__PURE__ */ e(I, { className: "h-3.5 w-3.5" })
|
|
614
625
|
}
|
|
@@ -647,7 +658,8 @@ function Ze({
|
|
|
647
658
|
"button",
|
|
648
659
|
{
|
|
649
660
|
type: "button",
|
|
650
|
-
|
|
661
|
+
"aria-label": "Remove file",
|
|
662
|
+
onClick: () => Ue(l.url),
|
|
651
663
|
className: "text-slate-300 hover:text-red-400 p-0.5 shrink-0",
|
|
652
664
|
children: /* @__PURE__ */ e(I, { className: "h-3.5 w-3.5" })
|
|
653
665
|
}
|
|
@@ -696,7 +708,7 @@ function Ze({
|
|
|
696
708
|
type: "button",
|
|
697
709
|
onClick: () => {
|
|
698
710
|
var l;
|
|
699
|
-
return (l =
|
|
711
|
+
return (l = U.current) == null ? void 0 : l.click();
|
|
700
712
|
},
|
|
701
713
|
disabled: m,
|
|
702
714
|
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,7 +721,7 @@ function Ze({
|
|
|
709
721
|
/* @__PURE__ */ e(
|
|
710
722
|
"input",
|
|
711
723
|
{
|
|
712
|
-
ref:
|
|
724
|
+
ref: U,
|
|
713
725
|
type: "file",
|
|
714
726
|
multiple: !0,
|
|
715
727
|
className: "hidden",
|