@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
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as r, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { X as J } from "lucide-react";
|
|
3
3
|
import { useState as l } from "react";
|
|
4
|
+
import { userErrorMessage as T } from "../../../lib/safe-error.js";
|
|
4
5
|
import { Command as _, CommandInput as y, CommandList as k, CommandGroup as N, CommandItem as C } from "../../ui/command.js";
|
|
5
6
|
import { Popover as i, PopoverTrigger as c, PopoverContent as p } from "../../ui/popover.js";
|
|
6
|
-
function
|
|
7
|
+
function q({
|
|
7
8
|
rule: t,
|
|
8
9
|
parentFields: h,
|
|
9
10
|
childFields: u,
|
|
@@ -12,8 +13,8 @@ function X({
|
|
|
12
13
|
}) {
|
|
13
14
|
var v, g;
|
|
14
15
|
const [S, f] = l(!1), [j, m] = l(!1), [E, R] = l(!1), [P, b] = l(""), [s, d] = l(null), x = !!t.on_unavailable && typeof t.on_unavailable == "object";
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
-
/* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5", children: [
|
|
17
|
+
/* @__PURE__ */ r(i, { open: S, onOpenChange: f, children: [
|
|
17
18
|
/* @__PURE__ */ e(c, { asChild: !0, children: /* @__PURE__ */ e(
|
|
18
19
|
"button",
|
|
19
20
|
{
|
|
@@ -23,7 +24,7 @@ function X({
|
|
|
23
24
|
children: t.parent_field ? ((v = h.find((a) => a.value === t.parent_field)) == null ? void 0 : v.label) ?? t.parent_field : /* @__PURE__ */ e("span", { className: "text-slate-400", children: "parent field…" })
|
|
24
25
|
}
|
|
25
26
|
) }),
|
|
26
|
-
/* @__PURE__ */ e(p, { className: "w-52 p-0", align: "start", children: /* @__PURE__ */
|
|
27
|
+
/* @__PURE__ */ e(p, { className: "w-52 p-0", align: "start", children: /* @__PURE__ */ r(_, { children: [
|
|
27
28
|
/* @__PURE__ */ e(y, { placeholder: "Search…", className: "h-8 text-[12px]" }),
|
|
28
29
|
/* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(N, { children: h.map((a) => /* @__PURE__ */ e(
|
|
29
30
|
C,
|
|
@@ -40,7 +41,7 @@ function X({
|
|
|
40
41
|
] }) })
|
|
41
42
|
] }),
|
|
42
43
|
/* @__PURE__ */ e("span", { className: "text-[11px] text-slate-400 shrink-0", children: "→" }),
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
+
/* @__PURE__ */ r(i, { open: j, onOpenChange: m, children: [
|
|
44
45
|
/* @__PURE__ */ e(c, { asChild: !0, children: /* @__PURE__ */ e(
|
|
45
46
|
"button",
|
|
46
47
|
{
|
|
@@ -50,7 +51,7 @@ function X({
|
|
|
50
51
|
children: t.child_field ? ((g = u.find((a) => a.value === t.child_field)) == null ? void 0 : g.label) ?? t.child_field : /* @__PURE__ */ e("span", { className: "text-slate-400", children: "child field…" })
|
|
51
52
|
}
|
|
52
53
|
) }),
|
|
53
|
-
/* @__PURE__ */ e(p, { className: "w-52 p-0", align: "start", children: /* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ e(p, { className: "w-52 p-0", align: "start", children: /* @__PURE__ */ r(_, { children: [
|
|
54
55
|
/* @__PURE__ */ e(y, { placeholder: "Search…", className: "h-8 text-[12px]" }),
|
|
55
56
|
/* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(N, { children: u.map((a) => /* @__PURE__ */ e(
|
|
56
57
|
C,
|
|
@@ -66,7 +67,7 @@ function X({
|
|
|
66
67
|
)) }) })
|
|
67
68
|
] }) })
|
|
68
69
|
] }),
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ r(
|
|
70
71
|
i,
|
|
71
72
|
{
|
|
72
73
|
open: E,
|
|
@@ -85,9 +86,9 @@ function X({
|
|
|
85
86
|
children: "⇄"
|
|
86
87
|
}
|
|
87
88
|
) }),
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ r(p, { className: "w-[420px] p-3 space-y-2", align: "end", children: [
|
|
89
90
|
/* @__PURE__ */ e("p", { className: "text-[11px] font-medium text-slate-700 dark:text-foreground", children: "On unavailable — swap to a default" }),
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ r("p", { className: "text-[11px] text-slate-500", children: [
|
|
91
92
|
"When the parent field is changed and a row’s value is no longer offered, re-point the row to the option that keeps ",
|
|
92
93
|
/* @__PURE__ */ e("code", { children: "keep" }),
|
|
93
94
|
" from the old value and takes",
|
|
@@ -104,17 +105,17 @@ function X({
|
|
|
104
105
|
const w = a.target.value.trim();
|
|
105
106
|
if (!w) {
|
|
106
107
|
d(null);
|
|
107
|
-
const { on_unavailable:
|
|
108
|
+
const { on_unavailable: n, ...I } = t;
|
|
108
109
|
o(I);
|
|
109
110
|
return;
|
|
110
111
|
}
|
|
111
112
|
try {
|
|
112
|
-
const
|
|
113
|
-
if (!
|
|
113
|
+
const n = JSON.parse(w);
|
|
114
|
+
if (!n || typeof n != "object" || !n.replace)
|
|
114
115
|
throw new Error('needs a "replace" map');
|
|
115
|
-
d(null), o({ ...t, on_unavailable:
|
|
116
|
-
} catch (
|
|
117
|
-
d(
|
|
116
|
+
d(null), o({ ...t, on_unavailable: n });
|
|
117
|
+
} catch (n) {
|
|
118
|
+
d(T(n, "Invalid JSON"));
|
|
118
119
|
}
|
|
119
120
|
},
|
|
120
121
|
rows: 9,
|
|
@@ -146,5 +147,5 @@ function X({
|
|
|
146
147
|
] });
|
|
147
148
|
}
|
|
148
149
|
export {
|
|
149
|
-
|
|
150
|
+
q as CascadeRuleRow
|
|
150
151
|
};
|
|
@@ -4,15 +4,16 @@ import { PlayCircle as L, X as Q, Plus as R, StickyNote as V } from "lucide-reac
|
|
|
4
4
|
import { useState as y, useEffect as j } from "react";
|
|
5
5
|
import { useNivaroClient as T } from "../../../context.js";
|
|
6
6
|
import { get as $ } from "../../../lib/commands.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
7
|
+
import { userErrorMessage as K } from "../../../lib/safe-error.js";
|
|
8
|
+
import { cn as M } from "../../../lib/utils.js";
|
|
9
|
+
import { useHelpVideosForForm as X, fetchHelpVideo as D, helpVideoApi as z } from "../../help-videos/api.js";
|
|
10
|
+
import { Command as G, CommandInput as J, CommandList as U, CommandEmpty as W, CommandItem as Y } from "../../ui/command.js";
|
|
11
|
+
import { Popover as Z, PopoverTrigger as ee, PopoverContent as te } from "../../ui/popover.js";
|
|
12
|
+
import { noteOf as oe, NOTE_TEXT_MAX as ae, noteByline as re, noteOps as ne } from "../editor-notes.js";
|
|
13
|
+
import { inputBase as ie } from "../panel-style.js";
|
|
13
14
|
import { useInspectorEnv as q, Setting as A } from "./kit.js";
|
|
14
|
-
const E = "inline-flex h-7 items-center gap-1 rounded-md border border-slate-200 bg-white px-2.5 text-[12px] font-medium text-slate-700 transition-colors hover:bg-slate-50 disabled:opacity-40 dark:border-border dark:bg-background dark:text-foreground dark:hover:bg-muted",
|
|
15
|
-
function
|
|
15
|
+
const E = "inline-flex h-7 items-center gap-1 rounded-md border border-slate-200 bg-white px-2.5 text-[12px] font-medium text-slate-700 transition-colors hover:bg-slate-50 disabled:opacity-40 dark:border-border dark:bg-background dark:text-foreground dark:hover:bg-muted", se = "inline-flex h-7 items-center rounded-md bg-nvr-cyan px-2.5 text-[12px] font-medium text-white transition-colors hover:bg-[#00b8e0] disabled:opacity-40";
|
|
16
|
+
function le() {
|
|
16
17
|
const n = T();
|
|
17
18
|
return _({
|
|
18
19
|
queryKey: ["layout-editor", "me"],
|
|
@@ -20,11 +21,11 @@ function se() {
|
|
|
20
21
|
queryFn: () => n.request($("/users/me")).then((r) => r.data)
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
const c = q(), { data: a } =
|
|
24
|
+
function we({ target: n, name: r }) {
|
|
25
|
+
const c = q(), { data: a } = le(), t = oe(c.bundle, n), [p, i] = y((t == null ? void 0 : t.text) ?? "");
|
|
25
26
|
j(() => i((t == null ? void 0 : t.text) ?? ""), [t == null ? void 0 : t.text]);
|
|
26
27
|
const m = p.trim() !== ((t == null ? void 0 : t.text) ?? ""), d = (l, f) => {
|
|
27
|
-
const h =
|
|
28
|
+
const h = ne(c.bundle, n, l);
|
|
28
29
|
h.length && c.apply(h, { label: f });
|
|
29
30
|
}, u = () => {
|
|
30
31
|
if (!p.trim()) return d(null, `Remove the note on ${r}`);
|
|
@@ -49,21 +50,21 @@ function ke({ target: n, name: r }) {
|
|
|
49
50
|
{
|
|
50
51
|
"aria-label": "Note for editors",
|
|
51
52
|
rows: 3,
|
|
52
|
-
maxLength:
|
|
53
|
+
maxLength: ae,
|
|
53
54
|
value: p,
|
|
54
55
|
placeholder: "Finance asked for this in Q3",
|
|
55
56
|
onChange: (l) => i(l.target.value),
|
|
56
|
-
className:
|
|
57
|
+
className: M(ie, "h-auto py-1.5 leading-snug")
|
|
57
58
|
}
|
|
58
59
|
),
|
|
59
|
-
t && /* @__PURE__ */ o("p", { "data-note-byline": "", className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children:
|
|
60
|
+
t && /* @__PURE__ */ o("p", { "data-note-byline": "", className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: re(t) }),
|
|
60
61
|
/* @__PURE__ */ s("div", { className: "flex flex-wrap gap-2", children: [
|
|
61
62
|
/* @__PURE__ */ o(
|
|
62
63
|
"button",
|
|
63
64
|
{
|
|
64
65
|
type: "button",
|
|
65
66
|
"data-note-save": "",
|
|
66
|
-
className:
|
|
67
|
+
className: se,
|
|
67
68
|
disabled: !m,
|
|
68
69
|
onClick: u,
|
|
69
70
|
children: t ? "Save note" : "Pin note"
|
|
@@ -84,24 +85,24 @@ function ke({ target: n, name: r }) {
|
|
|
84
85
|
}
|
|
85
86
|
);
|
|
86
87
|
}
|
|
87
|
-
function
|
|
88
|
+
function Ce({
|
|
88
89
|
kind: n,
|
|
89
90
|
name: r,
|
|
90
91
|
label: c
|
|
91
92
|
}) {
|
|
92
|
-
var
|
|
93
|
-
const a = q(), t = T(), p = I(), { data: i } = X(a.collection), m = n === "field" ? (
|
|
93
|
+
var N, w;
|
|
94
|
+
const a = q(), t = T(), p = I(), { data: i } = X(a.collection), m = n === "field" ? (N = i == null ? void 0 : i.fields) == null ? void 0 : N[r] : (w = i == null ? void 0 : i.sections) == null ? void 0 : w[r], d = Array.isArray(m) ? m : [], [u, l] = y(!1), [f, h] = y(!1), [g, v] = y(null), x = _({
|
|
94
95
|
queryKey: ["help-videos", "library", { status: "published", picker: !0 }],
|
|
95
96
|
enabled: u,
|
|
96
97
|
staleTime: 6e4,
|
|
97
98
|
queryFn: () => t.request($("/help-videos", { status: "published", limit: 100 })).then((e) => e.data)
|
|
98
|
-
}), b = { kind: n, key: a.collection, state_key: r }, O = (e) => e.kind === b.kind && e.key === b.key && e.state_key === b.state_key,
|
|
99
|
-
h(!0),
|
|
99
|
+
}), b = { kind: n, key: a.collection, state_key: r }, O = (e) => e.kind === b.kind && e.key === b.key && e.state_key === b.state_key, k = async (e, F) => {
|
|
100
|
+
h(!0), v(null);
|
|
100
101
|
try {
|
|
101
|
-
const S = ((await
|
|
102
|
-
await
|
|
103
|
-
} catch (
|
|
104
|
-
|
|
102
|
+
const S = ((await D(t, e)).contexts ?? []).filter((H) => !O(H));
|
|
103
|
+
await z(t).setContexts(e, F ? [...S, b] : S), await p.invalidateQueries({ queryKey: ["help-videos"] });
|
|
104
|
+
} catch (C) {
|
|
105
|
+
v(K(C, "Could not change the video"));
|
|
105
106
|
} finally {
|
|
106
107
|
h(!1);
|
|
107
108
|
}
|
|
@@ -131,7 +132,7 @@ function Ne({
|
|
|
131
132
|
"aria-label": `Take ${e.title} off ${c}`,
|
|
132
133
|
"data-tip": "Take it off",
|
|
133
134
|
disabled: f,
|
|
134
|
-
onClick: () => void
|
|
135
|
+
onClick: () => void k(e.id, !1),
|
|
135
136
|
className: "rounded p-0.5 text-slate-400 hover:bg-muted hover:text-slate-700 disabled:opacity-40 dark:hover:text-foreground",
|
|
136
137
|
children: /* @__PURE__ */ o(Q, { className: "h-3.5 w-3.5" })
|
|
137
138
|
}
|
|
@@ -140,21 +141,21 @@ function Ne({
|
|
|
140
141
|
},
|
|
141
142
|
e.id
|
|
142
143
|
)) }),
|
|
143
|
-
/* @__PURE__ */ s(
|
|
144
|
-
/* @__PURE__ */ o(
|
|
144
|
+
/* @__PURE__ */ s(Z, { open: u, onOpenChange: l, children: [
|
|
145
|
+
/* @__PURE__ */ o(ee, { asChild: !0, children: /* @__PURE__ */ s("button", { type: "button", className: E, disabled: f, "data-help-video-pick": "", children: [
|
|
145
146
|
/* @__PURE__ */ o(R, { className: "h-3.5 w-3.5" }),
|
|
146
147
|
"Attach a video"
|
|
147
148
|
] }) }),
|
|
148
|
-
/* @__PURE__ */ o(
|
|
149
|
-
/* @__PURE__ */ o(
|
|
150
|
-
/* @__PURE__ */ s(
|
|
151
|
-
/* @__PURE__ */ o(
|
|
149
|
+
/* @__PURE__ */ o(te, { align: "start", className: "w-[300px] p-0", children: /* @__PURE__ */ s(G, { children: [
|
|
150
|
+
/* @__PURE__ */ o(J, { placeholder: "Find a published video…" }),
|
|
151
|
+
/* @__PURE__ */ s(U, { className: "max-h-[260px] overscroll-contain", children: [
|
|
152
|
+
/* @__PURE__ */ o(W, { children: x.isLoading ? "Loading videos…" : "No published videos to attach." }),
|
|
152
153
|
B.map((e) => /* @__PURE__ */ o(
|
|
153
|
-
|
|
154
|
+
Y,
|
|
154
155
|
{
|
|
155
156
|
value: `${e.title} ${e.id}`,
|
|
156
157
|
onSelect: () => {
|
|
157
|
-
l(!1),
|
|
158
|
+
l(!1), k(e.id, !0);
|
|
158
159
|
},
|
|
159
160
|
children: /* @__PURE__ */ o("span", { className: "truncate", children: e.title })
|
|
160
161
|
},
|
|
@@ -163,12 +164,12 @@ function Ne({
|
|
|
163
164
|
] })
|
|
164
165
|
] }) })
|
|
165
166
|
] }),
|
|
166
|
-
|
|
167
|
+
g && /* @__PURE__ */ o("p", { role: "alert", className: "text-[12px] text-red-700 dark:text-red-300", children: g })
|
|
167
168
|
]
|
|
168
169
|
}
|
|
169
170
|
);
|
|
170
171
|
}
|
|
171
172
|
export {
|
|
172
|
-
|
|
173
|
-
|
|
173
|
+
Ce as HelpVideoSetting,
|
|
174
|
+
we as NoteSetting
|
|
174
175
|
};
|
|
@@ -2,17 +2,18 @@ import { jsxs as h, jsx as r, Fragment as J } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState as Q, useMemo as P } from "react";
|
|
3
3
|
import { toast as O } from "sonner";
|
|
4
4
|
import { HEADER_GROUP_KEY as _ } from "../../../lib/layout-ops.js";
|
|
5
|
+
import { userErrorMessage as X } from "../../../lib/safe-error.js";
|
|
5
6
|
import { cn as F } from "../../../lib/utils.js";
|
|
6
|
-
import { Skeleton as
|
|
7
|
-
import { targetOfKey as
|
|
8
|
-
import { resetPlacementOps as
|
|
9
|
-
import { useCollectionMeta as
|
|
10
|
-
import { overridePlacementOps as
|
|
11
|
-
import { LoadError as
|
|
12
|
-
import { useCollectionPipelines as
|
|
13
|
-
import { useCellMenu as
|
|
14
|
-
import { useSaveRequirements as
|
|
15
|
-
import { CELL_KINDS as z, stateCell as K, movesFrom as
|
|
7
|
+
import { Skeleton as ee } from "../../ui/skeleton.js";
|
|
8
|
+
import { targetOfKey as te, keyOf as re, isFieldRow as T, fieldZones as oe, zoneItems as ne } from "../field-zones.js";
|
|
9
|
+
import { resetPlacementOps as le } from "../inheritance.js";
|
|
10
|
+
import { useCollectionMeta as ae } from "../inspector/field-context.js";
|
|
11
|
+
import { overridePlacementOps as se, describeField as ie } from "../inspector/model.js";
|
|
12
|
+
import { LoadError as de } from "../load-error.js";
|
|
13
|
+
import { useCollectionPipelines as ce } from "../preview/preview-api.js";
|
|
14
|
+
import { useCellMenu as me, MatrixMenu as ue, matrixCorner as he, matrixTh as H, matrixRowHead as fe, InheritChip as pe, matrixCellTd as Z, MatrixCellButton as j, matrixZoneTd as we } from "./MatrixGrid.js";
|
|
15
|
+
import { useSaveRequirements as be } from "./matrix-api.js";
|
|
16
|
+
import { CELL_KINDS as z, stateCell as K, movesFrom as ge, everyStateValue as L, everyStateOps as xe, cellChange as ye } from "./state-matrix.js";
|
|
16
17
|
const x = {
|
|
17
18
|
normal: "Editable",
|
|
18
19
|
readonly: "Read-only",
|
|
@@ -24,18 +25,18 @@ const x = {
|
|
|
24
25
|
required: "required",
|
|
25
26
|
hidden: "hidden"
|
|
26
27
|
}, D = "*", A = (o) => `${o.field}${o.group_key ?? ""}`;
|
|
27
|
-
function
|
|
28
|
-
const f = new Set((a == null ? void 0 : a.placements.map((n) => n.field)) ?? []),
|
|
28
|
+
function ve(o, a) {
|
|
29
|
+
const f = new Set((a == null ? void 0 : a.placements.map((n) => n.field)) ?? []), p = (n) => ({
|
|
29
30
|
row: n,
|
|
30
31
|
source: f.has(n.field) ? "override" : "own"
|
|
31
|
-
}), v = [], g = o.placements.filter((n) => n.group_key === _ && T(n)).sort((n,
|
|
32
|
-
g.length && v.push({ key: _, label: "Header strip", rows: g.map(
|
|
33
|
-
for (const n of
|
|
34
|
-
const
|
|
35
|
-
|
|
32
|
+
}), v = [], g = o.placements.filter((n) => n.group_key === _ && T(n)).sort((n, w) => n.sort - w.sort);
|
|
33
|
+
g.length && v.push({ key: _, label: "Header strip", rows: g.map(p) });
|
|
34
|
+
for (const n of oe(o)) {
|
|
35
|
+
const w = ne(o, n.key).filter(T);
|
|
36
|
+
w.length && v.push({ key: n.key ?? "", label: n.label, rows: w.map(p) });
|
|
36
37
|
}
|
|
37
38
|
if (a) {
|
|
38
|
-
const n = new Set(o.placements.map((b) => b.field)),
|
|
39
|
+
const n = new Set(o.placements.map((b) => b.field)), w = /* @__PURE__ */ new Set(), C = a.placements.filter((b) => !T(b) || n.has(b.field) || w.has(b.field) ? !1 : (w.add(b.field), !0));
|
|
39
40
|
C.length && v.push({
|
|
40
41
|
key: "parent",
|
|
41
42
|
label: `From ${String(a.layout.name ?? "the parent layout")}`,
|
|
@@ -44,19 +45,19 @@ function ye(o, a) {
|
|
|
44
45
|
}
|
|
45
46
|
return v;
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
+
function He({
|
|
48
49
|
bundle: o,
|
|
49
50
|
parent: a,
|
|
50
51
|
collection: f,
|
|
51
|
-
apply:
|
|
52
|
+
apply: p,
|
|
52
53
|
onSelect: v
|
|
53
54
|
}) {
|
|
54
|
-
const { data: g } =
|
|
55
|
+
const { data: g } = ae(f), {
|
|
55
56
|
data: n = [],
|
|
56
|
-
isLoading:
|
|
57
|
+
isLoading: w,
|
|
57
58
|
isError: C,
|
|
58
59
|
refetch: b
|
|
59
|
-
} =
|
|
60
|
+
} = ce(f, !0), [V, W] = Q(null), s = n.find((e) => e.id === V) ?? n[0] ?? null, k = (s == null ? void 0 : s.states) ?? [], N = (s == null ? void 0 : s.transitions) ?? [], M = be(f), y = me(), R = P(() => ve(o, a), [o, a]), q = String((a == null ? void 0 : a.layout.name) ?? "the parent layout"), E = (e) => ie(e.field, (g == null ? void 0 : g.fields) ?? [], (g == null ? void 0 : g.relations) ?? [], e).label, l = P(() => {
|
|
60
61
|
if (!y.open) return null;
|
|
61
62
|
const e = y.open.lastIndexOf("|"), t = y.open.slice(0, e), d = y.open.slice(e + 1);
|
|
62
63
|
for (const c of R)
|
|
@@ -72,7 +73,7 @@ function Pe({
|
|
|
72
73
|
blocked: null
|
|
73
74
|
})) : (() => {
|
|
74
75
|
var m;
|
|
75
|
-
const e = l.state, t = K(l.row, e, N), d =
|
|
76
|
+
const e = l.state, t = K(l.row, e, N), d = ge(N, e), c = d.length === 1 ? `"${(m = d[0]) == null ? void 0 : m.label}"` : `the ${d.length} moves out`;
|
|
76
77
|
return z.map((i) => {
|
|
77
78
|
const u = t.options[i];
|
|
78
79
|
return {
|
|
@@ -87,15 +88,15 @@ function Pe({
|
|
|
87
88
|
if (!l) return;
|
|
88
89
|
const t = E(l.row);
|
|
89
90
|
if (l.state == null) {
|
|
90
|
-
const m =
|
|
91
|
-
m.length &&
|
|
91
|
+
const m = xe(l.row, e);
|
|
92
|
+
m.length && p(m, { label: `${t}: ${x[e].toLowerCase()} on every state` });
|
|
92
93
|
return;
|
|
93
94
|
}
|
|
94
95
|
if (!s) return;
|
|
95
|
-
const d = l.state, c =
|
|
96
|
-
if (c && (c.ops.length &&
|
|
96
|
+
const d = l.state, c = ye(l.row, d, s.id, N, e);
|
|
97
|
+
if (c && (c.ops.length && p(c.ops, { label: `${t}: ${x[e].toLowerCase()} in ${d.label}` }), c.requirements.length !== 0))
|
|
97
98
|
try {
|
|
98
|
-
await
|
|
99
|
+
await M(c.requirements);
|
|
99
100
|
const m = c.requirements.map((i) => `"${i.label}"`).join(", ");
|
|
100
101
|
O.success(
|
|
101
102
|
e === "required" ? `${m} now ${c.requirements.length === 1 ? "asks" : "ask"} for ${t}` : `${m} no longer ${c.requirements.length === 1 ? "asks" : "ask"} for ${t}`,
|
|
@@ -103,7 +104,7 @@ function Pe({
|
|
|
103
104
|
description: `Saved to the ${s.name} pipeline`,
|
|
104
105
|
action: {
|
|
105
106
|
label: "Undo",
|
|
106
|
-
onClick: () => void
|
|
107
|
+
onClick: () => void M(c.requirements, "before").catch(
|
|
107
108
|
(i) => O.error(U(i))
|
|
108
109
|
)
|
|
109
110
|
}
|
|
@@ -112,13 +113,13 @@ function Pe({
|
|
|
112
113
|
} catch (m) {
|
|
113
114
|
O.error(`The pipeline was not changed: ${U(m)}`);
|
|
114
115
|
}
|
|
115
|
-
},
|
|
116
|
+
}, I = R.reduce((e, t) => e + t.rows.length, 0);
|
|
116
117
|
return /* @__PURE__ */ h("div", { "data-field-state-matrix": "", className: "flex min-h-full flex-col gap-2 p-4", children: [
|
|
117
118
|
/* @__PURE__ */ h("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
118
119
|
/* @__PURE__ */ h("p", { className: "m-0 min-w-0 flex-1 text-[12px] text-slate-500 dark:text-muted-foreground", children: [
|
|
119
|
-
|
|
120
|
+
I,
|
|
120
121
|
" ",
|
|
121
|
-
|
|
122
|
+
I === 1 ? "field" : "fields",
|
|
122
123
|
" by workflow state. Read-only uses the field's Read-only when; Required asks for the value before the record leaves the state."
|
|
123
124
|
] }),
|
|
124
125
|
n.length > 1 && /* @__PURE__ */ r(
|
|
@@ -143,7 +144,7 @@ function Pe({
|
|
|
143
144
|
}
|
|
144
145
|
)
|
|
145
146
|
] }),
|
|
146
|
-
C ? /* @__PURE__ */ r(
|
|
147
|
+
C ? /* @__PURE__ */ r(de, { what: "the workflow states", onRetry: () => void b() }) : !w && !s && /* @__PURE__ */ r(
|
|
147
148
|
"p",
|
|
148
149
|
{
|
|
149
150
|
role: "note",
|
|
@@ -151,8 +152,8 @@ function Pe({
|
|
|
151
152
|
children: "No pipeline runs on this collection, so only Every state applies."
|
|
152
153
|
}
|
|
153
154
|
),
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
w ? /* @__PURE__ */ r(ee, { className: "h-48 w-full rounded-lg" }) : /* @__PURE__ */ r(
|
|
156
|
+
ue,
|
|
156
157
|
{
|
|
157
158
|
menu: y,
|
|
158
159
|
title: l ? `${E(l.row)} · ${l.state ? l.state.label : "Every state"}` : "",
|
|
@@ -161,7 +162,7 @@ function Pe({
|
|
|
161
162
|
onPick: (e) => void G(e),
|
|
162
163
|
children: /* @__PURE__ */ r("div", { className: "min-h-0 flex-1 overflow-auto rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: /* @__PURE__ */ h("table", { className: "border-separate border-spacing-0 text-[12.5px]", children: [
|
|
163
164
|
/* @__PURE__ */ r("thead", { children: /* @__PURE__ */ h("tr", { children: [
|
|
164
|
-
/* @__PURE__ */ r("th", { className:
|
|
165
|
+
/* @__PURE__ */ r("th", { className: he, children: "Field" }),
|
|
165
166
|
/* @__PURE__ */ r(
|
|
166
167
|
"th",
|
|
167
168
|
{
|
|
@@ -192,19 +193,19 @@ function Pe({
|
|
|
192
193
|
] }) }),
|
|
193
194
|
/* @__PURE__ */ h("tbody", { children: [
|
|
194
195
|
R.map((e) => /* @__PURE__ */ r(
|
|
195
|
-
|
|
196
|
+
ke,
|
|
196
197
|
{
|
|
197
198
|
zone: e,
|
|
198
199
|
colSpan: k.length + 1,
|
|
199
200
|
render: (t) => {
|
|
200
201
|
const d = E(t.row), c = A(t.row), m = t.source === "inherited" ? `From ${q} — override it to change it here` : null, i = L(t.row);
|
|
201
202
|
return /* @__PURE__ */ h("tr", { "data-matrix-row": t.row.field, children: [
|
|
202
|
-
/* @__PURE__ */ h("th", { scope: "row", className:
|
|
203
|
+
/* @__PURE__ */ h("th", { scope: "row", className: fe, children: [
|
|
203
204
|
/* @__PURE__ */ r(
|
|
204
205
|
"button",
|
|
205
206
|
{
|
|
206
207
|
type: "button",
|
|
207
|
-
onClick: (u) => v(
|
|
208
|
+
onClick: (u) => v(te(re(t.row)), {
|
|
208
209
|
additive: u.shiftKey || u.metaKey || u.ctrlKey
|
|
209
210
|
}),
|
|
210
211
|
"data-tip": "Select it on the form",
|
|
@@ -213,16 +214,16 @@ function Pe({
|
|
|
213
214
|
}
|
|
214
215
|
),
|
|
215
216
|
t.source !== "own" && a && /* @__PURE__ */ r(
|
|
216
|
-
|
|
217
|
+
pe,
|
|
217
218
|
{
|
|
218
219
|
kind: t.source === "inherited" ? "inherited" : "override",
|
|
219
220
|
parentName: q,
|
|
220
221
|
action: t.source === "inherited" ? "override" : "reset",
|
|
221
222
|
actionLabel: t.source === "inherited" ? `Override ${d} on this form` : `Reset ${d} to ${q}`,
|
|
222
223
|
actionTip: t.source === "inherited" ? "Copy it onto this form to change it here" : `Take ${q}'s placement of it again`,
|
|
223
|
-
onAction: () => t.source === "inherited" ?
|
|
224
|
+
onAction: () => t.source === "inherited" ? p(se(o, a, t.row), {
|
|
224
225
|
label: `Override ${d} on this form`
|
|
225
|
-
}) :
|
|
226
|
+
}) : p(le(o, t.row.field), {
|
|
226
227
|
label: `Reset ${d} to ${q}`
|
|
227
228
|
})
|
|
228
229
|
}
|
|
@@ -275,7 +276,7 @@ function Pe({
|
|
|
275
276
|
)
|
|
276
277
|
] });
|
|
277
278
|
}
|
|
278
|
-
function
|
|
279
|
+
function ke({
|
|
279
280
|
zone: o,
|
|
280
281
|
colSpan: a,
|
|
281
282
|
render: f
|
|
@@ -295,11 +296,11 @@ function ve({
|
|
|
295
296
|
] });
|
|
296
297
|
}
|
|
297
298
|
function U(o) {
|
|
298
|
-
var f,
|
|
299
|
-
const a = (
|
|
300
|
-
return typeof a == "string" ? a : o
|
|
299
|
+
var f, p;
|
|
300
|
+
const a = (p = (f = o == null ? void 0 : o.response) == null ? void 0 : f.data) == null ? void 0 : p.error;
|
|
301
|
+
return typeof a == "string" ? a : X(o, "Something went wrong");
|
|
301
302
|
}
|
|
302
303
|
export {
|
|
303
|
-
|
|
304
|
-
|
|
304
|
+
He as FieldStateMatrix,
|
|
305
|
+
ve as matrixZones
|
|
305
306
|
};
|