@nivaro/react 0.3.36 → 0.3.38
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/slots/CommentsSlot.js +44 -36
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/shared/components/AgentBadge.js +26 -0
- package/dist/shared/components/AgentQuestionsCard.js +198 -0
- package/dist/shared/components/ItemEditForm.js +3329 -3263
- package/dist/shared/components/McpConnectionScope.js +480 -0
- package/dist/shared/components/MyWorkView.js +223 -208
- package/dist/shared/components/RecordReadView.js +620 -575
- package/dist/shared/components/chat/ChatPanel.js +683 -671
- package/dist/shared/components/imports/DownloadSampleButton.js +69 -0
- package/dist/shared/components/imports/ImportConsole.js +106 -104
- package/dist/shared/components/imports/RunDetailSheet.js +34 -32
- package/dist/shared/components/item-edit/FieldAffordances.js +32 -32
- package/dist/shared/components/item-edit/FormTour.js +279 -0
- package/dist/shared/components/item-edit/GroupSection.js +377 -360
- package/dist/shared/components/item-edit/PersonalDefaultControl.js +28 -28
- package/dist/shared/components/item-edit/entry/EntryStrip.js +30 -26
- package/dist/shared/components/item-edit/form-density.js +36 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -46
- package/dist/shared/components/item-edit/usePersonalDefaults.js +312 -296
- package/dist/shared/components/layout-editor/AddPanel.js +349 -192
- package/dist/shared/components/layout-editor/DesignNode.js +126 -112
- package/dist/shared/components/layout-editor/EditorTopBar.js +123 -103
- package/dist/shared/components/layout-editor/LayoutEditor.js +829 -751
- package/dist/shared/components/layout-editor/PlaceTools.js +334 -0
- package/dist/shared/components/layout-editor/SlashInsert.js +252 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +285 -242
- package/dist/shared/components/layout-editor/add-target.js +54 -43
- package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +238 -155
- package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +1 -1
- package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +15 -12
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +347 -189
- package/dist/shared/components/layout-editor/dnd/TrashZone.js +60 -32
- package/dist/shared/components/layout-editor/dnd/UndoChip.js +76 -0
- package/dist/shared/components/layout-editor/dnd/merge-drop.js +33 -0
- package/dist/shared/components/layout-editor/dnd/multi-drop.js +87 -0
- package/dist/shared/components/layout-editor/dnd/node.js +115 -105
- package/dist/shared/components/layout-editor/dnd/sensors.js +23 -0
- package/dist/shared/components/layout-editor/dnd/trash-drop.js +34 -28
- package/dist/shared/components/layout-editor/dnd/trash-links.js +97 -0
- package/dist/shared/components/layout-editor/even-row.js +86 -0
- package/dist/shared/components/layout-editor/field-list.js +99 -0
- package/dist/shared/components/layout-editor/format-painter.js +102 -0
- package/dist/shared/components/layout-editor/grid-guides.js +15 -13
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +150 -132
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +57 -53
- package/dist/shared/components/layout-editor/inspector/EvenRowAction.js +31 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +154 -141
- package/dist/shared/components/layout-editor/inspector/Inspector.js +209 -178
- package/dist/shared/components/layout-editor/inspector/LookTab.js +106 -98
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +38 -37
- package/dist/shared/components/layout-editor/inspector/kit.js +280 -223
- package/dist/shared/components/layout-editor/keyboard-move.js +15 -15
- package/dist/shared/components/layout-editor/lint/LabelStyle.js +201 -0
- package/dist/shared/components/layout-editor/lint/LintPanel.js +132 -84
- package/dist/shared/components/layout-editor/lint/lint-api.js +65 -28
- package/dist/shared/components/layout-editor/nav/NavTools.js +14 -12
- package/dist/shared/components/layout-editor/nav/ZoomControls.js +145 -0
- package/dist/shared/components/layout-editor/nav/useEditorNav.js +34 -32
- package/dist/shared/components/layout-editor/nav/view-prefs.js +100 -15
- package/dist/shared/components/layout-editor/outputs/LayoutFile.js +89 -0
- package/dist/shared/components/layout-editor/outputs/OutputsButton.js +272 -195
- package/dist/shared/components/layout-editor/outputs/layout-file-plan.js +176 -0
- package/dist/shared/components/layout-editor/outputs/output-api.js +71 -37
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +16 -11
- package/dist/shared/components/layout-editor/overview/purpose.js +5 -5
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/layout-editor/pin.js +37 -19
- package/dist/shared/components/layout-editor/place-clip.js +257 -0
- package/dist/shared/components/layout-editor/preview/PreviewModes.js +27 -26
- package/dist/shared/components/layout-editor/preview/PreviewPanes.js +148 -117
- package/dist/shared/components/layout-editor/preview/SampleRecord.js +113 -0
- package/dist/shared/components/layout-editor/preview/preview-model.js +79 -60
- package/dist/shared/components/layout-editor/preview/sample-record.js +105 -0
- package/dist/shared/components/layout-editor/removed-log.js +151 -0
- package/dist/shared/components/layout-editor/reuse/LibraryRows.js +109 -78
- package/dist/shared/components/layout-editor/reuse/linked-sections.js +373 -0
- package/dist/shared/components/layout-editor/revert-element.js +140 -0
- package/dist/shared/components/layout-editor/section-structure.js +193 -170
- package/dist/shared/components/layout-editor/settings/EntrySection.js +63 -45
- package/dist/shared/components/layout-editor/settings/LayoutSection.js +63 -32
- package/dist/shared/components/layout-editor/settings/ResolveSettings.js +179 -137
- package/dist/shared/components/layout-editor/settings/WhoSection.js +18 -17
- package/dist/shared/components/layout-editor/settings/settings-registry.js +24 -0
- package/dist/shared/components/layout-editor/shortcuts.js +21 -16
- package/dist/shared/components/layout-editor/structure-ops.js +221 -195
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +133 -85
- package/dist/shared/components/layout-editor/usage/refusal-lens.js +130 -0
- package/dist/shared/components/layout-editor/usage/usage-api.js +12 -11
- package/dist/shared/components/panels/CommentPanel.js +47 -45
- package/dist/shared/components/panels/RevisionsPanel.js +66 -64
- package/dist/shared/components/panels/TaskPanel.js +395 -332
- package/dist/shared/components/profile/AgentsPanel.js +196 -147
- package/dist/shared/components/profile/ConnectionRollback.js +329 -0
- package/dist/shared/components/profile/MyDefaultsCard.js +526 -520
- package/dist/shared/lib/entry-config.js +22 -22
- package/dist/shared/lib/form-usage-beacon.js +91 -55
- package/dist/shared/lib/layout-lint.js +530 -284
- package/dist/shared/lib/layout-resolve.js +58 -44
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsxs as a, jsx as e, Fragment as R } from "react/jsx-runtime";
|
|
2
2
|
import { useQueryClient as oe, useQuery as X, useMutation as Y } from "@tanstack/react-query";
|
|
3
|
-
import { FileSpreadsheet as Ne, Download as Z, RotateCcw as ve, Undo2 as ee, Ban as we, ArrowRight as ye, AlertTriangle as Ce, Loader2 as H, Search as
|
|
3
|
+
import { FileSpreadsheet as Ne, Download as Z, RotateCcw as ve, Undo2 as ee, Ban as we, ArrowRight as ye, AlertTriangle as Ce, Loader2 as H, Search as $e, ChevronDown as ie, ChevronRight as ce, Check as ue, Copy as me, ExternalLink as _e } from "lucide-react";
|
|
4
4
|
import { useState as N, useEffect as he, useMemo as pe } from "react";
|
|
5
5
|
import { useNivaroClient as te, useApiFetchConfig as Re, useItemNavigation as Se } from "../../context.js";
|
|
6
|
-
import {
|
|
7
|
-
import { useDebounced as Le } from "../../hooks/useDebounced.js";
|
|
6
|
+
import { useDebounced as Te } from "../../hooks/useDebounced.js";
|
|
8
7
|
import { get as xe, post as J } from "../../lib/commands.js";
|
|
9
|
-
import { parseImportLog as
|
|
10
|
-
import { formatDateTime as se, formatNumber as h, cn as b, formatFileSize as
|
|
8
|
+
import { parseImportLog as Le } from "../../lib/import-log.js";
|
|
9
|
+
import { formatDateTime as se, formatNumber as h, cn as b, formatFileSize as qe, titleCase as Ee } from "../../lib/utils.js";
|
|
10
|
+
import { ExplainButton as Fe } from "../ai/ExplainButton.js";
|
|
11
11
|
import { Button as S } from "../ui/button.js";
|
|
12
12
|
import { Input as Ke } from "../ui/input.js";
|
|
13
13
|
import { Sheet as Pe, SheetContent as De, SheetTitle as je, SheetDescription as Me } from "../ui/sheet.js";
|
|
@@ -57,7 +57,7 @@ const B = 50, K = {
|
|
|
57
57
|
bar: "bg-[#ef4444]",
|
|
58
58
|
dot: "bg-[#ef4444]"
|
|
59
59
|
}
|
|
60
|
-
}, v = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0ea5e9]/60 focus-visible:ring-offset-0", ge = (t) =>
|
|
60
|
+
}, v = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0ea5e9]/60 focus-visible:ring-offset-0", ge = (t) => Ee(
|
|
61
61
|
String(t ?? "").replace(/_junction$/i, " links").replace(/_/g, " ")
|
|
62
62
|
);
|
|
63
63
|
function le(t) {
|
|
@@ -465,7 +465,7 @@ function Ae({
|
|
|
465
465
|
v
|
|
466
466
|
),
|
|
467
467
|
children: [
|
|
468
|
-
/* @__PURE__ */ e(
|
|
468
|
+
/* @__PURE__ */ e(_e, { className: "h-3 w-3" }),
|
|
469
469
|
" Open the record"
|
|
470
470
|
]
|
|
471
471
|
}
|
|
@@ -497,12 +497,12 @@ function Ie({
|
|
|
497
497
|
live: c
|
|
498
498
|
}) {
|
|
499
499
|
var O, U, z;
|
|
500
|
-
const p = te(), u = oe(), { download: s, busy: g, error: r } = ke(), [f, x] = N(""), [m, Q] = N(null), [w, L] = N(1), [q, D] = N(null), C =
|
|
500
|
+
const p = te(), u = oe(), { download: s, busy: g, error: r } = ke(), [f, x] = N(""), [m, Q] = N(null), [w, L] = N(1), [q, D] = N(null), C = Te(f, 300);
|
|
501
501
|
he(() => L(1), [o, m, C, t]);
|
|
502
|
-
const
|
|
503
|
-
queryKey: ["staged-import-run-items", t,
|
|
502
|
+
const $ = { kind: o ?? "", collection: m ?? "", search: C, page: w, limit: B }, y = X({
|
|
503
|
+
queryKey: ["staged-import-run-items", t, $],
|
|
504
504
|
queryFn: () => p.request(
|
|
505
|
-
xe(`/staged-imports/${t}/items`,
|
|
505
|
+
xe(`/staged-imports/${t}/items`, $)
|
|
506
506
|
),
|
|
507
507
|
placeholderData: (d) => d,
|
|
508
508
|
refetchInterval: c ? fe : !1
|
|
@@ -520,14 +520,14 @@ function Ie({
|
|
|
520
520
|
var k;
|
|
521
521
|
return D(((k = d.response) == null ? void 0 : k.error) ?? d.message);
|
|
522
522
|
}
|
|
523
|
-
}), F = ((O = y.data) == null ? void 0 : O.facets) ?? {}, j = Object.keys(F.collection ?? n.collections ?? {}),
|
|
523
|
+
}), F = ((O = y.data) == null ? void 0 : O.facets) ?? {}, j = Object.keys(F.collection ?? n.collections ?? {}), _ = ((U = y.data) == null ? void 0 : U.total) ?? 0, M = ((z = y.data) == null ? void 0 : z.data) ?? [], V = n.items_stored ?? 0, W = [
|
|
524
524
|
{ key: null, label: "All", n: Object.values(F.kind ?? {}).reduce((d, k) => d + k, 0) },
|
|
525
525
|
...["created", "updated", "removed", "skipped", "failed"].map((d) => {
|
|
526
526
|
var k;
|
|
527
527
|
return { key: d, label: K[d].label, n: ((k = F.kind) == null ? void 0 : k[d]) ?? 0 };
|
|
528
528
|
}).filter((d) => d.n > 0 || d.key === o)
|
|
529
529
|
];
|
|
530
|
-
return V === 0 && !y.isLoading &&
|
|
530
|
+
return V === 0 && !y.isLoading && _ === 0 && !C && !o ? /* @__PURE__ */ a("section", { "data-run-records": !0, children: [
|
|
531
531
|
/* @__PURE__ */ e(T, { children: "Records" }),
|
|
532
532
|
/* @__PURE__ */ e("p", { className: "rounded-md border border-dashed border-slate-200 px-3 py-4 text-[12.5px] text-slate-600 dark:border-border dark:text-muted-foreground", children: "This run changed no records and left no rows out. Every row in the file already matched what is stored." })
|
|
533
533
|
] }) : /* @__PURE__ */ a("section", { "data-run-records": !0, children: [
|
|
@@ -538,7 +538,7 @@ function Ie({
|
|
|
538
538
|
P,
|
|
539
539
|
{
|
|
540
540
|
"data-run-items-download": !0,
|
|
541
|
-
disabled: g != null ||
|
|
541
|
+
disabled: g != null || _ === 0,
|
|
542
542
|
onClick: () => s(
|
|
543
543
|
`/staged-imports/${t}/items.csv?kind=${o ?? ""}&collection=${m ?? ""}&search=${encodeURIComponent(C)}`,
|
|
544
544
|
`import-run-${t}${o ? `-${o}` : ""}.csv`
|
|
@@ -607,7 +607,7 @@ function Ie({
|
|
|
607
607
|
}
|
|
608
608
|
),
|
|
609
609
|
/* @__PURE__ */ a("div", { className: "relative ml-auto w-[220px] max-w-full", children: [
|
|
610
|
-
/* @__PURE__ */ e(
|
|
610
|
+
/* @__PURE__ */ e($e, { className: "pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
|
|
611
611
|
/* @__PURE__ */ e(
|
|
612
612
|
Ke,
|
|
613
613
|
{
|
|
@@ -654,14 +654,14 @@ function Ie({
|
|
|
654
654
|
}) })
|
|
655
655
|
}
|
|
656
656
|
),
|
|
657
|
-
|
|
657
|
+
_ > B && /* @__PURE__ */ a("div", { className: "mt-2 flex items-center justify-between text-[11.5px] text-slate-600 dark:text-muted-foreground", children: [
|
|
658
658
|
/* @__PURE__ */ a("span", { className: "tabular-nums", children: [
|
|
659
659
|
h((w - 1) * B + 1),
|
|
660
660
|
"–",
|
|
661
|
-
h(Math.min(w * B,
|
|
661
|
+
h(Math.min(w * B, _)),
|
|
662
662
|
" of",
|
|
663
663
|
" ",
|
|
664
|
-
h(
|
|
664
|
+
h(_)
|
|
665
665
|
] }),
|
|
666
666
|
/* @__PURE__ */ a("span", { className: "flex items-center gap-1", children: [
|
|
667
667
|
/* @__PURE__ */ e(
|
|
@@ -681,7 +681,7 @@ function Ie({
|
|
|
681
681
|
variant: "outline",
|
|
682
682
|
size: "sm",
|
|
683
683
|
className: "h-6 px-2 text-[11.5px]",
|
|
684
|
-
disabled: w * B >=
|
|
684
|
+
disabled: w * B >= _,
|
|
685
685
|
onClick: () => L((d) => d + 1),
|
|
686
686
|
children: "Next"
|
|
687
687
|
}
|
|
@@ -907,12 +907,12 @@ function Nt({
|
|
|
907
907
|
he(() => {
|
|
908
908
|
w(null), q(!1), C(!1);
|
|
909
909
|
}, [n]);
|
|
910
|
-
const
|
|
910
|
+
const $ = Y({
|
|
911
911
|
mutationFn: () => u.request(
|
|
912
912
|
J(`/staged-imports/${n}/report/rebuild`, {})
|
|
913
913
|
),
|
|
914
914
|
onSuccess: () => void s.invalidateQueries({ queryKey: ["staged-import-run", n] })
|
|
915
|
-
}), y = r ? be(r).mode : null, E = (r == null ? void 0 : r.status) === "completed" || (r == null ? void 0 : r.status) === "error", F = l && !!f && E && (f.counts.created > 0 || f.counts.updated > 0), j = !!f,
|
|
915
|
+
}), y = r ? be(r).mode : null, E = (r == null ? void 0 : r.status) === "completed" || (r == null ? void 0 : r.status) === "error", F = l && !!f && E && (f.counts.created > 0 || f.counts.updated > 0), j = !!f, _ = pe(() => r ? /* @__PURE__ */ a("dl", { className: "mt-3 grid grid-cols-2 gap-x-5 gap-y-2 sm:grid-cols-4", children: [
|
|
916
916
|
/* @__PURE__ */ e(I, { label: "Queued by", children: ze(r) ?? "—" }),
|
|
917
917
|
/* @__PURE__ */ e(I, { label: r.finished_at ? "Finished" : r.started_at ? "Started" : "Queued", children: se(r.finished_at ?? r.started_at ?? r.created_at ?? /* @__PURE__ */ new Date()) }),
|
|
918
918
|
/* @__PURE__ */ e(I, { label: "Took", children: /* @__PURE__ */ e("span", { className: "tabular-nums", children: ne(r.duration) }) }),
|
|
@@ -952,7 +952,7 @@ function Nt({
|
|
|
952
952
|
o,
|
|
953
953
|
x != null && ` · ${ne(x)} elapsed`
|
|
954
954
|
] }),
|
|
955
|
-
|
|
955
|
+
_
|
|
956
956
|
] }),
|
|
957
957
|
/* @__PURE__ */ a("div", { className: "min-h-0 flex-1 space-y-6 overflow-y-auto px-5 py-4", children: [
|
|
958
958
|
f ? /* @__PURE__ */ a(R, { children: [
|
|
@@ -995,18 +995,18 @@ function Nt({
|
|
|
995
995
|
{
|
|
996
996
|
type: "button",
|
|
997
997
|
"data-run-rebuild": !0,
|
|
998
|
-
disabled:
|
|
999
|
-
onClick: () =>
|
|
998
|
+
disabled: $.isPending,
|
|
999
|
+
onClick: () => $.mutate(),
|
|
1000
1000
|
className: b(
|
|
1001
1001
|
"font-medium text-[#0369a1] underline-offset-2 hover:underline disabled:opacity-60 dark:text-[#7dd3fc]",
|
|
1002
1002
|
v
|
|
1003
1003
|
),
|
|
1004
|
-
children:
|
|
1004
|
+
children: $.isPending ? "Reading…" : "Read it back from recorded changes"
|
|
1005
1005
|
}
|
|
1006
1006
|
)
|
|
1007
1007
|
] })
|
|
1008
1008
|
] }),
|
|
1009
|
-
|
|
1009
|
+
$.isError && /* @__PURE__ */ e("p", { className: "mt-1.5 max-w-[64ch] text-[12px] text-slate-700 dark:text-foreground", children: ((z = $.error.response) == null ? void 0 : z.error) ?? $.error.message })
|
|
1010
1010
|
] }),
|
|
1011
1011
|
/* @__PURE__ */ a("section", { "data-run-file": !0, children: [
|
|
1012
1012
|
/* @__PURE__ */ e(T, { children: "File" }),
|
|
@@ -1014,14 +1014,15 @@ function Nt({
|
|
|
1014
1014
|
/* @__PURE__ */ e(Ne, { className: "h-4 w-4 shrink-0 text-slate-400" }),
|
|
1015
1015
|
/* @__PURE__ */ a("div", { className: "min-w-0 flex-1", children: [
|
|
1016
1016
|
/* @__PURE__ */ e("p", { className: "truncate font-mono text-[11.5px] text-slate-800 dark:text-foreground", children: r.file_name ?? r.file }),
|
|
1017
|
-
r.file_size != null && /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-500 dark:text-muted-foreground", children:
|
|
1017
|
+
r.file_size != null && /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-500 dark:text-muted-foreground", children: qe(Number(r.file_size)) })
|
|
1018
1018
|
] }),
|
|
1019
1019
|
m && /* @__PURE__ */ e(
|
|
1020
1020
|
"a",
|
|
1021
1021
|
{
|
|
1022
|
-
href: m
|
|
1023
|
-
|
|
1022
|
+
href: `${m}${m.includes("?") ? "&" : "?"}download=1`,
|
|
1023
|
+
download: r.file_name ?? !0,
|
|
1024
1024
|
rel: "noreferrer",
|
|
1025
|
+
"data-run-file-download": !0,
|
|
1025
1026
|
className: b(
|
|
1026
1027
|
"rounded p-1 text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-800 dark:hover:bg-muted",
|
|
1027
1028
|
v
|
|
@@ -1033,7 +1034,7 @@ function Nt({
|
|
|
1033
1034
|
] }) : /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: "No file is attached, so this run cannot be queued again." })
|
|
1034
1035
|
] }),
|
|
1035
1036
|
l && r.status !== "running" && (r.status === "error" || (r.duration ?? 0) >= Ye) && /* @__PURE__ */ e("section", { "data-run-explain": !0, children: /* @__PURE__ */ e(
|
|
1036
|
-
|
|
1037
|
+
Fe,
|
|
1037
1038
|
{
|
|
1038
1039
|
kind: "import-run",
|
|
1039
1040
|
params: { id: r.id },
|
|
@@ -1263,7 +1264,7 @@ function rt({ error: t }) {
|
|
|
1263
1264
|
}
|
|
1264
1265
|
function de({ run: t }) {
|
|
1265
1266
|
const [n, o] = N(!1), l = pe(
|
|
1266
|
-
() =>
|
|
1267
|
+
() => Le(t.logs, t.status === "error"),
|
|
1267
1268
|
[t.logs, t.status]
|
|
1268
1269
|
);
|
|
1269
1270
|
if (!t.logs)
|
|
@@ -1329,5 +1330,6 @@ function de({ run: t }) {
|
|
|
1329
1330
|
] });
|
|
1330
1331
|
}
|
|
1331
1332
|
export {
|
|
1332
|
-
Nt as RunDetailSheet
|
|
1333
|
+
Nt as RunDetailSheet,
|
|
1334
|
+
ke as useDownload
|
|
1333
1335
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as s, jsxs as h, Fragment as
|
|
2
|
-
import { Copy as Q, History as
|
|
1
|
+
import { jsx as s, jsxs as h, Fragment as me } from "react/jsx-runtime";
|
|
2
|
+
import { Copy as Q, History as fe, Eye as be, Sigma as pe, ExternalLink as xe, UserRound as ye, UserRoundPen as he, UserRoundX as ge, Lock as ke, X as ne } from "lucide-react";
|
|
3
3
|
import { useContext as we, createContext as ve, useState as C, useCallback as N, useRef as M, useEffect as B, useLayoutEffect as Ne } from "react";
|
|
4
4
|
import { createPortal as Ce } from "react-dom";
|
|
5
5
|
import { toast as v } from "sonner";
|
|
@@ -131,16 +131,16 @@ function qe({
|
|
|
131
131
|
field: t,
|
|
132
132
|
value: o,
|
|
133
133
|
relations: l,
|
|
134
|
-
collection:
|
|
134
|
+
collection: f,
|
|
135
135
|
itemId: x,
|
|
136
136
|
openRelated: w,
|
|
137
137
|
editable: R = !1
|
|
138
138
|
}) {
|
|
139
139
|
var J, z;
|
|
140
|
-
const [g, T] = C(null), r = Fe(), [k, S] = C(!1), [y, O] = C(null), [U, A] = C(null), [$, j] = C(!1), b = N((e, c) => T({ x: e, y: c }), []), [D, a] = C(null),
|
|
140
|
+
const [g, T] = C(null), r = Fe(), [k, S] = C(!1), [y, O] = C(null), [U, A] = C(null), [$, j] = C(!1), b = N((e, c) => T({ x: e, y: c }), []), [D, a] = C(null), m = M(null), L = M(null), i = N(() => {
|
|
141
141
|
T(null), a(null), S(!1), O(null), A(null), j(!1);
|
|
142
|
-
const e =
|
|
143
|
-
|
|
142
|
+
const e = m.current, c = L.current;
|
|
143
|
+
m.current = null, L.current = null, (e || c) && window.setTimeout(() => {
|
|
144
144
|
var u;
|
|
145
145
|
document.activeElement && document.activeElement !== document.body || (e != null && e.isConnected ? e.focus() : (u = c == null ? void 0 : c()) == null || u.focus());
|
|
146
146
|
}, 0);
|
|
@@ -151,7 +151,7 @@ function qe({
|
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
153
|
const c = e.getBoundingClientRect();
|
|
154
|
-
_.current = null,
|
|
154
|
+
_.current = null, m.current = e, a("menu"), b(c.left, c.bottom + 4);
|
|
155
155
|
},
|
|
156
156
|
[p, i, b]
|
|
157
157
|
), E = N(() => {
|
|
@@ -171,7 +171,7 @@ function qe({
|
|
|
171
171
|
return;
|
|
172
172
|
}
|
|
173
173
|
const F = e.getBoundingClientRect();
|
|
174
|
-
_.current = null,
|
|
174
|
+
_.current = null, m.current = e, L.current = c ?? null, a(u), u === "update" ? P() : E(), b(F.right - ae, F.bottom + 4);
|
|
175
175
|
},
|
|
176
176
|
[p, D, i, b, E, P]
|
|
177
177
|
), _ = M(null), oe = N(
|
|
@@ -192,12 +192,12 @@ function qe({
|
|
|
192
192
|
},
|
|
193
193
|
[b, n]
|
|
194
194
|
), I = l.find(
|
|
195
|
-
(e) => e.many_collection ===
|
|
195
|
+
(e) => e.many_collection === f && e.many_field === t.field && e.one_collection
|
|
196
196
|
), K = x && x !== "new", W = (e) => {
|
|
197
197
|
var u;
|
|
198
198
|
const c = (u = n.current) == null ? void 0 : u.querySelector(e);
|
|
199
199
|
return c ? (c.click(), !0) : !1;
|
|
200
|
-
}, V = !!(r != null && r.allowed(t.field)), X = V && R && !!(r != null && r.hasValue(t.field)), G = V ? (r == null ? void 0 : r.defaultFor(t.field)) ?? null : null, se = X && !G, ie = X && !!G && !(r != null && r.isDefault(t.field)), Y = [
|
|
200
|
+
}, V = !!(r != null && r.allowed(t.field)) && r.manageable(t.field), X = V && R && !!(r != null && r.hasValue(t.field)), G = V ? (r == null ? void 0 : r.defaultFor(t.field)) ?? null : null, se = X && !G, ie = X && !!G && !(r != null && r.isDefault(t.field)), Y = [
|
|
201
201
|
{
|
|
202
202
|
key: "copy",
|
|
203
203
|
label: "Copy value",
|
|
@@ -229,7 +229,7 @@ function qe({
|
|
|
229
229
|
{
|
|
230
230
|
key: "history",
|
|
231
231
|
label: "Value history",
|
|
232
|
-
icon: /* @__PURE__ */ s(
|
|
232
|
+
icon: /* @__PURE__ */ s(fe, { className: "h-3.5 w-3.5" }),
|
|
233
233
|
disabled: !K,
|
|
234
234
|
run: () => {
|
|
235
235
|
W("[data-field-history]") || v.info("No history for this field yet");
|
|
@@ -364,7 +364,7 @@ function Oe({
|
|
|
364
364
|
items: t,
|
|
365
365
|
onClose: o,
|
|
366
366
|
confirm: l,
|
|
367
|
-
anchor:
|
|
367
|
+
anchor: f
|
|
368
368
|
}) {
|
|
369
369
|
Ue();
|
|
370
370
|
const x = M(null), [w, R] = C(0), g = t.filter((a) => !a.disabled);
|
|
@@ -373,8 +373,8 @@ function Oe({
|
|
|
373
373
|
const a = (i) => {
|
|
374
374
|
var d, E;
|
|
375
375
|
const p = i.target;
|
|
376
|
-
(d = x.current) != null && d.contains(p) || (E = p == null ? void 0 : p.closest) != null && E.call(p, $e) && (
|
|
377
|
-
},
|
|
376
|
+
(d = x.current) != null && d.contains(p) || (E = p == null ? void 0 : p.closest) != null && E.call(p, $e) && (f != null && f.contains(p)) || o();
|
|
377
|
+
}, m = (i) => {
|
|
378
378
|
var p;
|
|
379
379
|
if (i.key === "Escape")
|
|
380
380
|
i.preventDefault(), o();
|
|
@@ -399,27 +399,27 @@ function Oe({
|
|
|
399
399
|
d && (d.run(), d.stay || o());
|
|
400
400
|
}
|
|
401
401
|
};
|
|
402
|
-
return window.addEventListener("mousedown", a, !0), window.addEventListener("keydown",
|
|
403
|
-
window.removeEventListener("mousedown", a, !0), window.removeEventListener("keydown",
|
|
402
|
+
return window.addEventListener("mousedown", a, !0), window.addEventListener("keydown", m, !0), (L = x.current) == null || L.focus(), () => {
|
|
403
|
+
window.removeEventListener("mousedown", a, !0), window.removeEventListener("keydown", m, !0);
|
|
404
404
|
};
|
|
405
|
-
}, [o, g, w, l,
|
|
405
|
+
}, [o, g, w, l, f]);
|
|
406
406
|
const T = M(null), r = M(null), k = !!l, S = !!(l != null && l.ready);
|
|
407
407
|
B(() => {
|
|
408
408
|
var a;
|
|
409
409
|
k && ((a = r.current) == null || a.focus());
|
|
410
410
|
}, [k]), B(() => {
|
|
411
|
-
var
|
|
411
|
+
var m;
|
|
412
412
|
if (!S) return;
|
|
413
413
|
const a = document.activeElement;
|
|
414
|
-
(a === r.current || a === x.current || a === document.body) && ((
|
|
414
|
+
(a === r.current || a === x.current || a === document.body) && ((m = T.current) == null || m.focus());
|
|
415
415
|
}, [S]);
|
|
416
416
|
const y = Math.min(ae, window.innerWidth - 16), O = Ee(l == null ? void 0 : l.text), [U, A] = C(() => l ? 96 : t.length * 30 + 12);
|
|
417
417
|
Ne(() => {
|
|
418
|
-
var
|
|
419
|
-
const a = (
|
|
418
|
+
var m;
|
|
419
|
+
const a = (m = x.current) == null ? void 0 : m.offsetHeight;
|
|
420
420
|
a && a !== U && A(a);
|
|
421
421
|
});
|
|
422
|
-
const $ = Math.max(8, Math.min(n.x, window.innerWidth - y - 8)), j = Math.max(8, Math.min(n.y, window.innerHeight - U - 8)), b = (
|
|
422
|
+
const $ = Math.max(8, Math.min(n.x, window.innerWidth - y - 8)), j = Math.max(8, Math.min(n.y, window.innerHeight - U - 8)), b = (f == null ? void 0 : f.closest('[role="dialog"]')) ?? document.body, D = b === document.body ? { position: "fixed", left: $, top: j } : (() => {
|
|
423
423
|
const a = b.getBoundingClientRect();
|
|
424
424
|
return {
|
|
425
425
|
position: "absolute",
|
|
@@ -476,14 +476,14 @@ function Oe({
|
|
|
476
476
|
] })
|
|
477
477
|
] }) : null,
|
|
478
478
|
l ? null : t.map((a) => {
|
|
479
|
-
const
|
|
479
|
+
const m = g.indexOf(a), L = m === w && !a.disabled;
|
|
480
480
|
return /* @__PURE__ */ h(
|
|
481
481
|
"button",
|
|
482
482
|
{
|
|
483
483
|
type: "button",
|
|
484
484
|
role: "menuitem",
|
|
485
485
|
disabled: a.disabled,
|
|
486
|
-
onMouseEnter: () =>
|
|
486
|
+
onMouseEnter: () => m >= 0 && R(m),
|
|
487
487
|
onClick: () => {
|
|
488
488
|
a.run(), a.stay || o();
|
|
489
489
|
},
|
|
@@ -508,7 +508,7 @@ function Oe({
|
|
|
508
508
|
);
|
|
509
509
|
}
|
|
510
510
|
function Je(n) {
|
|
511
|
-
const [t, o] = C(null), [l,
|
|
511
|
+
const [t, o] = C(null), [l, f] = C(!1), x = M(!1), w = M(null);
|
|
512
512
|
B(() => {
|
|
513
513
|
const r = n.current;
|
|
514
514
|
if (!r) return;
|
|
@@ -517,7 +517,7 @@ function Je(n) {
|
|
|
517
517
|
const S = new MutationObserver(k);
|
|
518
518
|
return S.observe(r, { attributes: !0, attributeFilter: ["data-remote-editor"] }), () => S.disconnect();
|
|
519
519
|
}, [n]), B(() => {
|
|
520
|
-
t || (
|
|
520
|
+
t || (f(!1), x.current = !1);
|
|
521
521
|
}, [t]);
|
|
522
522
|
const R = N(
|
|
523
523
|
(r) => {
|
|
@@ -525,15 +525,15 @@ function Je(n) {
|
|
|
525
525
|
const k = r.target;
|
|
526
526
|
k.matches('input, textarea, select, [contenteditable="true"], [role="combobox"]') && (w.current = k, setTimeout(() => {
|
|
527
527
|
x.current || k.blur();
|
|
528
|
-
}, 0),
|
|
528
|
+
}, 0), f(!0));
|
|
529
529
|
},
|
|
530
530
|
[t]
|
|
531
531
|
), g = N(() => {
|
|
532
|
-
x.current = !0,
|
|
532
|
+
x.current = !0, f(!1);
|
|
533
533
|
const r = w.current;
|
|
534
534
|
w.current = null, r && setTimeout(() => r.focus(), 0);
|
|
535
535
|
}, []), T = N(() => {
|
|
536
|
-
|
|
536
|
+
f(!1), w.current = null;
|
|
537
537
|
}, []);
|
|
538
538
|
return { editor: t, confirming: l, onFocusCapture: R, confirm: g, cancel: T };
|
|
539
539
|
}
|
|
@@ -543,7 +543,7 @@ function ze({
|
|
|
543
543
|
onConfirm: o,
|
|
544
544
|
onCancel: l
|
|
545
545
|
}) {
|
|
546
|
-
const
|
|
546
|
+
const f = n.split(/\s+/).map((x) => x[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
|
|
547
547
|
return /* @__PURE__ */ h(
|
|
548
548
|
"div",
|
|
549
549
|
{
|
|
@@ -553,9 +553,9 @@ function ze({
|
|
|
553
553
|
t ? "border border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-100" : "text-amber-700 dark:text-amber-300"
|
|
554
554
|
),
|
|
555
555
|
children: [
|
|
556
|
-
/* @__PURE__ */ s("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-amber-200 text-[9px] font-semibold text-amber-900 dark:bg-amber-500/40 dark:text-amber-50", children:
|
|
556
|
+
/* @__PURE__ */ s("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-amber-200 text-[9px] font-semibold text-amber-900 dark:bg-amber-500/40 dark:text-amber-50", children: f || "?" }),
|
|
557
557
|
/* @__PURE__ */ s("span", { className: "min-w-0 flex-1", children: t ? `${n} is typing here — edit anyway?` : `${n} is editing this field` }),
|
|
558
|
-
t && /* @__PURE__ */ h(
|
|
558
|
+
t && /* @__PURE__ */ h(me, { children: [
|
|
559
559
|
/* @__PURE__ */ s(
|
|
560
560
|
"button",
|
|
561
561
|
{
|