@nivaro/react 0.3.35 → 0.3.37
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 +13 -4
- 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 -572
- 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 +11 -10
- 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 +80 -63
- 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 +146 -131
- package/dist/shared/components/layout-editor/EditorCanvas.js +25 -17
- package/dist/shared/components/layout-editor/EditorTopBar.js +268 -206
- package/dist/shared/components/layout-editor/LayoutEditor.js +810 -731
- 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 +379 -185
- package/dist/shared/components/layout-editor/dnd/TrashZone.js +96 -0
- 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/rail-drop.js +4 -4
- package/dist/shared/components/layout-editor/dnd/sensors.js +23 -0
- package/dist/shared/components/layout-editor/dnd/trash-drop.js +58 -0
- 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/panel-frame.js +1 -1
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/layout-editor/personal-default-marks.js +40 -0
- 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 +149 -118
- 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,667 +1,673 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { toast as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { get as
|
|
8
|
-
import { isEmptyValue as
|
|
9
|
-
import { userErrorMessage as
|
|
10
|
-
import { titleCase as
|
|
11
|
-
import { FieldRenderer as
|
|
12
|
-
import { getCascadeFilters as
|
|
13
|
-
import { M2MStagingContext as
|
|
14
|
-
import { PERSONAL_DEFAULT_GHOST_BUTTON as
|
|
15
|
-
import { pickedCollection as
|
|
16
|
-
import { personalDefaultsKey as
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
queryKey: ["field-config", s, null],
|
|
27
|
-
queryFn: () => e.request(T(`/field-config/${s}`)).then((d) => d.data ?? []),
|
|
1
|
+
import { jsxs as o, jsx as s, Fragment as fe } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as me, useQuery as I, useMutation as te, useQueries as O } from "@tanstack/react-query";
|
|
3
|
+
import { BookmarkCheck as pe, Pencil as xe, UserRoundX as he, Plus as ge, X as ye, Check as be } from "lucide-react";
|
|
4
|
+
import { useMemo as E, useState as _, useRef as D, useEffect as X } from "react";
|
|
5
|
+
import { toast as V } from "sonner";
|
|
6
|
+
import { useNivaroClient as z, useItemEditAuth as ve, ParentDraftContext as Ne } from "../../context.js";
|
|
7
|
+
import { get as M, del as ke, put as we } from "../../lib/commands.js";
|
|
8
|
+
import { isEmptyValue as K, cascadeParents as Se } from "../../lib/personal-defaults.js";
|
|
9
|
+
import { userErrorMessage as Ce } from "../../lib/safe-error.js";
|
|
10
|
+
import { titleCase as H, cn as $, formatDate as qe } from "../../lib/utils.js";
|
|
11
|
+
import { FieldRenderer as Pe } from "../item-edit/FieldRenderer.js";
|
|
12
|
+
import { getCascadeFilters as ae, buildCascadeFilter as Te } from "../item-edit/helpers.js";
|
|
13
|
+
import { M2MStagingContext as Ee } from "../item-edit/M2MStagingContext.js";
|
|
14
|
+
import { PERSONAL_DEFAULT_GHOST_BUTTON as Y } from "../item-edit/PersonalDefaultPill.js";
|
|
15
|
+
import { pickedCollection as Fe } from "../item-edit/personal-default-checks.js";
|
|
16
|
+
import { personalDefaultsKey as Me } from "../item-edit/usePersonalDefaults.js";
|
|
17
|
+
import { Skeleton as U } from "../ui/skeleton.js";
|
|
18
|
+
import { describeValue as W, loadDefaultLabels as $e, labelKey as _e } from "./my-defaults-labels.js";
|
|
19
|
+
import { SectionCard as De, EmptyLine as Ke, Pill as Re, ConfirmButton as Le } from "./primitives.js";
|
|
20
|
+
const B = { fields: [], relations: [], label: "", ready: !1 };
|
|
21
|
+
function Ue(a) {
|
|
22
|
+
const e = z(), n = O({
|
|
23
|
+
queries: a.map((l) => ({
|
|
24
|
+
queryKey: ["field-config", l, null],
|
|
25
|
+
queryFn: () => e.request(M(`/field-config/${l}`)).then((c) => c.data ?? []),
|
|
28
26
|
staleTime: 6e4
|
|
29
27
|
}))
|
|
30
|
-
}),
|
|
31
|
-
queries: a.map((
|
|
32
|
-
queryKey: ["relations",
|
|
33
|
-
queryFn: () => e.request(
|
|
28
|
+
}), i = O({
|
|
29
|
+
queries: a.map((l) => ({
|
|
30
|
+
queryKey: ["relations", l],
|
|
31
|
+
queryFn: () => e.request(M(`/data-model/relations/for/${l}`)).then((c) => c.data ?? []),
|
|
34
32
|
staleTime: 6e4
|
|
35
33
|
}))
|
|
36
|
-
}),
|
|
37
|
-
queries: a.map((
|
|
38
|
-
queryKey: ["col-meta",
|
|
39
|
-
queryFn: () => e.request(
|
|
34
|
+
}), f = O({
|
|
35
|
+
queries: a.map((l) => ({
|
|
36
|
+
queryKey: ["col-meta", l],
|
|
37
|
+
queryFn: () => e.request(M(`/collections/${l}`)).then((c) => c.data ?? null),
|
|
40
38
|
staleTime: 6e4
|
|
41
39
|
}))
|
|
42
|
-
}),
|
|
43
|
-
return a.forEach((
|
|
44
|
-
var
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
fields: ((
|
|
48
|
-
relations: ((y =
|
|
49
|
-
label:
|
|
50
|
-
ready: !((
|
|
40
|
+
}), d = /* @__PURE__ */ new Map();
|
|
41
|
+
return a.forEach((l, c) => {
|
|
42
|
+
var k, x, g, y, b, v;
|
|
43
|
+
const u = (x = (k = f[c]) == null ? void 0 : k.data) == null ? void 0 : x.display_name;
|
|
44
|
+
d.set(l, {
|
|
45
|
+
fields: ((g = n[c]) == null ? void 0 : g.data) ?? [],
|
|
46
|
+
relations: ((y = i[c]) == null ? void 0 : y.data) ?? [],
|
|
47
|
+
label: u != null && u.trim() ? u : H(l),
|
|
48
|
+
ready: !((b = n[c]) != null && b.isPending) && !((v = i[c]) != null && v.isPending)
|
|
51
49
|
});
|
|
52
|
-
}),
|
|
50
|
+
}), d;
|
|
53
51
|
}
|
|
54
|
-
function
|
|
55
|
-
var
|
|
56
|
-
const
|
|
57
|
-
return (
|
|
52
|
+
function T(a, e) {
|
|
53
|
+
var i;
|
|
54
|
+
const n = a.fields.find((f) => f.field === e);
|
|
55
|
+
return (i = n == null ? void 0 : n.label) != null && i.trim() ? n.label : H(e);
|
|
58
56
|
}
|
|
59
|
-
function
|
|
60
|
-
const
|
|
57
|
+
function Ae(a, e) {
|
|
58
|
+
const n = Object.keys(e.context ?? {}).filter((l) => !K(e.context[l])), i = new Map(a.fields.map((l) => [l.field, l])), d = Se(
|
|
61
59
|
e.field,
|
|
62
|
-
(
|
|
63
|
-
var
|
|
64
|
-
return
|
|
60
|
+
(l) => {
|
|
61
|
+
var c;
|
|
62
|
+
return ae(((c = i.get(l)) == null ? void 0 : c.dependency_config) ?? null);
|
|
65
63
|
}
|
|
66
|
-
).reverse().filter((
|
|
67
|
-
return [...
|
|
64
|
+
).reverse().filter((l) => n.includes(l));
|
|
65
|
+
return [...d, ...n.filter((l) => !d.includes(l))];
|
|
68
66
|
}
|
|
69
67
|
function Z(a, e) {
|
|
70
68
|
if (a.kind === "text") return { text: a.text, state: "ok" };
|
|
71
69
|
if (a.kind === "unknown") return { text: "Saved value", state: "ok" };
|
|
72
70
|
if (e.loading) return { text: "", state: "loading" };
|
|
73
71
|
if (e.failed) return { text: "Could not load this value", state: "failed" };
|
|
74
|
-
const
|
|
75
|
-
let
|
|
76
|
-
for (const
|
|
77
|
-
const
|
|
78
|
-
e.map.has(
|
|
72
|
+
const n = [];
|
|
73
|
+
let i = 0;
|
|
74
|
+
for (const f of a.ids) {
|
|
75
|
+
const d = _e(a.target, f);
|
|
76
|
+
e.map.has(d) ? n.push(e.map.get(d) ?? "Untitled record") : i++;
|
|
79
77
|
}
|
|
80
|
-
return
|
|
78
|
+
return n.length === 0 ? { text: "No longer available", state: "gone" } : (i && n.push(`${i} no longer available`), { text: n.join(", "), state: "ok" });
|
|
81
79
|
}
|
|
82
|
-
function
|
|
83
|
-
var
|
|
84
|
-
const e = a,
|
|
85
|
-
return typeof
|
|
80
|
+
function ne(a) {
|
|
81
|
+
var i, f;
|
|
82
|
+
const e = a, n = ((f = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : f.error) ?? (e == null ? void 0 : e.error);
|
|
83
|
+
return typeof n == "string" && n.trim() ? n : Ce(a, "Could not save");
|
|
86
84
|
}
|
|
87
|
-
function
|
|
88
|
-
const
|
|
89
|
-
data:
|
|
90
|
-
isPending:
|
|
85
|
+
function ot({ userId: a, name: e }) {
|
|
86
|
+
const n = z(), i = me(), f = ve(), d = !!a && String(a).toUpperCase() !== String(f.userId).toUpperCase(), l = !d || f.isAdmin, c = d ? `/field-defaults/users/${encodeURIComponent(String(a))}` : "/field-defaults/mine", u = d ? String(a) : "me", k = ["field-defaults-card", u], {
|
|
87
|
+
data: x,
|
|
88
|
+
isPending: g,
|
|
91
89
|
isError: y,
|
|
92
|
-
refetch:
|
|
90
|
+
refetch: b,
|
|
93
91
|
isRefetching: v
|
|
94
|
-
} =
|
|
95
|
-
queryKey:
|
|
96
|
-
queryFn: () =>
|
|
97
|
-
enabled:
|
|
92
|
+
} = I({
|
|
93
|
+
queryKey: k,
|
|
94
|
+
queryFn: () => n.request(M(c, { on_layout: 1 })).then((t) => t.data ?? []),
|
|
95
|
+
enabled: l,
|
|
98
96
|
staleTime: 3e4
|
|
99
|
-
}), { data:
|
|
100
|
-
queryKey: ["field-defaults-allowed",
|
|
101
|
-
queryFn: () =>
|
|
102
|
-
enabled:
|
|
97
|
+
}), { data: p, isPending: S } = I({
|
|
98
|
+
queryKey: ["field-defaults-allowed", u],
|
|
99
|
+
queryFn: () => n.request(M(`${c}/allowed`)).then((t) => t.data ?? []),
|
|
100
|
+
enabled: l,
|
|
103
101
|
staleTime: 6e4
|
|
104
|
-
}),
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}),
|
|
110
|
-
enabled: s && !i,
|
|
111
|
-
staleTime: 6e4
|
|
112
|
-
}), [k, F] = w(!1), [C, z] = w(""), G = S(() => {
|
|
113
|
-
const l = new Set((c ?? []).map((r) => r.collection));
|
|
114
|
-
return C && l.add(C), [...l];
|
|
115
|
-
}, [c, C]), E = We(G), A = G.every((l) => {
|
|
102
|
+
}), w = E(() => {
|
|
103
|
+
const t = new Set((x ?? []).map((r) => r.collection));
|
|
104
|
+
for (const r of p ?? []) t.add(r.collection);
|
|
105
|
+
return [...t];
|
|
106
|
+
}, [x, p]), h = Ue(w), P = w.every((t) => {
|
|
116
107
|
var r;
|
|
117
|
-
return (r =
|
|
118
|
-
}),
|
|
119
|
-
const
|
|
120
|
-
if (!
|
|
121
|
-
for (const r of
|
|
122
|
-
const N =
|
|
123
|
-
|
|
124
|
-
value:
|
|
125
|
-
context:
|
|
126
|
-
|
|
127
|
-
|
|
108
|
+
return (r = h.get(t)) == null ? void 0 : r.ready;
|
|
109
|
+
}), C = E(() => {
|
|
110
|
+
const t = /* @__PURE__ */ new Map();
|
|
111
|
+
if (!P) return t;
|
|
112
|
+
for (const r of x ?? []) {
|
|
113
|
+
const N = h.get(r.collection) ?? B, q = (m) => N.fields.find((F) => F.field === m);
|
|
114
|
+
t.set(String(r.id), {
|
|
115
|
+
value: W(q(r.field), N.relations, r.collection, r.value),
|
|
116
|
+
context: Ae(N, r).map((m) => [
|
|
117
|
+
m,
|
|
118
|
+
W(q(m), N.relations, r.collection, r.context[m])
|
|
128
119
|
])
|
|
129
120
|
});
|
|
130
121
|
}
|
|
131
|
-
return
|
|
132
|
-
}, [
|
|
133
|
-
const
|
|
134
|
-
for (const r of
|
|
135
|
-
for (const N of [r.value, ...r.context.map(([,
|
|
136
|
-
N.kind === "records" &&
|
|
137
|
-
return
|
|
138
|
-
}, [
|
|
139
|
-
data:
|
|
140
|
-
isPending:
|
|
141
|
-
isError:
|
|
142
|
-
} =
|
|
143
|
-
queryKey: ["field-defaults-card-labels",
|
|
144
|
-
queryFn: () =>
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
(
|
|
148
|
-
queryKey: ["col-meta",
|
|
149
|
-
queryFn: () =>
|
|
150
|
-
|
|
122
|
+
return t;
|
|
123
|
+
}, [x, h, P]), R = E(() => {
|
|
124
|
+
const t = /* @__PURE__ */ new Map();
|
|
125
|
+
for (const r of C.values())
|
|
126
|
+
for (const N of [r.value, ...r.context.map(([, q]) => q)])
|
|
127
|
+
N.kind === "records" && t.set(N.target, [.../* @__PURE__ */ new Set([...t.get(N.target) ?? [], ...N.ids])].sort());
|
|
128
|
+
return t;
|
|
129
|
+
}, [C]), oe = [...R].map(([t, r]) => `${t}:${r.join(",")}`).sort().join("|"), {
|
|
130
|
+
data: de,
|
|
131
|
+
isPending: ce,
|
|
132
|
+
isError: G
|
|
133
|
+
} = I({
|
|
134
|
+
queryKey: ["field-defaults-card-labels", oe],
|
|
135
|
+
queryFn: () => $e(
|
|
136
|
+
n,
|
|
137
|
+
R,
|
|
138
|
+
(t) => i.fetchQuery({
|
|
139
|
+
queryKey: ["col-meta", t],
|
|
140
|
+
queryFn: () => n.request(
|
|
141
|
+
M(`/collections/${t}`)
|
|
151
142
|
).then((r) => r.data ?? null),
|
|
152
143
|
staleTime: 6e4
|
|
153
144
|
}).then((r) => (r == null ? void 0 : r.display_template) ?? null)
|
|
154
145
|
),
|
|
155
|
-
enabled:
|
|
146
|
+
enabled: P && R.size > 0,
|
|
156
147
|
staleTime: 6e4
|
|
157
|
-
}),
|
|
158
|
-
map:
|
|
159
|
-
loading:
|
|
160
|
-
failed:
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
},
|
|
164
|
-
mutationFn: (
|
|
165
|
-
onSuccess: (
|
|
166
|
-
|
|
148
|
+
}), ue = {
|
|
149
|
+
map: de ?? /* @__PURE__ */ new Map(),
|
|
150
|
+
loading: R.size > 0 && !G && (!P || ce),
|
|
151
|
+
failed: G
|
|
152
|
+
}, A = (t) => {
|
|
153
|
+
i.invalidateQueries({ queryKey: k }), !d && t && i.invalidateQueries({ queryKey: Me(t) });
|
|
154
|
+
}, Q = te({
|
|
155
|
+
mutationFn: (t) => n.request(ke(`${c}/${t.id}`)),
|
|
156
|
+
onSuccess: (t, r) => {
|
|
157
|
+
A(r.collection), V.success("Default cleared");
|
|
167
158
|
},
|
|
168
|
-
onError: (
|
|
159
|
+
onError: (t) => V.error(ne(t))
|
|
169
160
|
});
|
|
170
|
-
if (!
|
|
161
|
+
if (!l || !d && (g || S && !y || !y && (x ?? []).length === 0 && ((p == null ? void 0 : p.length) ?? 0) === 0))
|
|
171
162
|
return null;
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
163
|
+
const j = /* @__PURE__ */ new Map();
|
|
164
|
+
for (const t of p ?? []) {
|
|
165
|
+
const r = new Set(
|
|
166
|
+
(x ?? []).filter((m) => m.collection === t.collection).map((m) => m.field)
|
|
167
|
+
), N = h.get(t.collection), q = t.fields.filter((m) => !r.has(m)).sort(
|
|
168
|
+
(m, F) => N ? T(N, m).localeCompare(T(N, F)) : m.localeCompare(F)
|
|
169
|
+
);
|
|
170
|
+
q.length && j.set(t.collection, q);
|
|
171
|
+
}
|
|
172
|
+
const J = w.filter((t) => (x ?? []).some((r) => r.collection === t) || j.has(t)).map((t) => {
|
|
173
|
+
var r, N;
|
|
174
|
+
return {
|
|
175
|
+
collection: t,
|
|
176
|
+
label: ((r = h.get(t)) == null ? void 0 : r.label) || ((N = (p ?? []).find((q) => q.collection === t)) == null ? void 0 : N.label) || H(t)
|
|
177
|
+
};
|
|
178
|
+
}).sort((t, r) => t.label.localeCompare(r.label)), L = (e == null ? void 0 : e.trim()) || "This person";
|
|
179
|
+
return /* @__PURE__ */ o(
|
|
180
|
+
De,
|
|
178
181
|
{
|
|
179
|
-
icon: /* @__PURE__ */
|
|
180
|
-
title:
|
|
181
|
-
hint:
|
|
182
|
+
icon: /* @__PURE__ */ s(pe, { className: "h-4 w-4" }),
|
|
183
|
+
title: d ? "Personal defaults" : "My defaults",
|
|
184
|
+
hint: d ? `New records ${e != null && e.trim() ? L : "they"} start are filled in with these` : "New records you start are filled in with these",
|
|
182
185
|
testId: "my-defaults",
|
|
183
|
-
actions: i && !k && ((h == null ? void 0 : h.length) ?? 0) > 0 ? /* @__PURE__ */ p(
|
|
184
|
-
"button",
|
|
185
|
-
{
|
|
186
|
-
type: "button",
|
|
187
|
-
"data-default-add": !0,
|
|
188
|
-
onClick: () => F(!0),
|
|
189
|
-
className: "inline-flex h-7 items-center gap-1 rounded-md px-2 text-[11.5px] font-medium text-slate-600 transition-colors hover:bg-muted hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 dark:text-slate-300 dark:hover:text-white",
|
|
190
|
-
children: [
|
|
191
|
-
/* @__PURE__ */ n(be, { className: "h-3.5 w-3.5" }),
|
|
192
|
-
" Add default"
|
|
193
|
-
]
|
|
194
|
-
}
|
|
195
|
-
) : null,
|
|
196
186
|
children: [
|
|
197
|
-
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
-
/* @__PURE__ */
|
|
200
|
-
] },
|
|
201
|
-
/* @__PURE__ */
|
|
202
|
-
/* @__PURE__ */
|
|
187
|
+
g ? /* @__PURE__ */ s("div", { className: "space-y-3", "aria-busy": "true", children: [0, 1, 2].map((t) => /* @__PURE__ */ o("div", { className: "flex items-center gap-3", children: [
|
|
188
|
+
/* @__PURE__ */ s(U, { className: "h-3.5 w-24" }),
|
|
189
|
+
/* @__PURE__ */ s(U, { className: "h-3.5 w-40" })
|
|
190
|
+
] }, t)) }) : y ? /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
191
|
+
/* @__PURE__ */ s(Ke, { children: "Could not load the saved defaults." }),
|
|
192
|
+
/* @__PURE__ */ s(
|
|
203
193
|
"button",
|
|
204
194
|
{
|
|
205
195
|
type: "button",
|
|
206
196
|
"data-default-retry": !0,
|
|
207
197
|
disabled: v,
|
|
208
|
-
onClick: () => void
|
|
198
|
+
onClick: () => void b(),
|
|
209
199
|
className: "inline-flex h-7 items-center rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-slate-700 transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 disabled:opacity-50 dark:border-border dark:text-slate-200",
|
|
210
200
|
children: v ? "Trying…" : "Retry"
|
|
211
201
|
}
|
|
212
202
|
)
|
|
213
|
-
] }) :
|
|
214
|
-
|
|
215
|
-
" On a record form, open a field’s ⋯ menu and choose",
|
|
216
|
-
" ",
|
|
217
|
-
/* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: "Save as my default" }),
|
|
218
|
-
i ? ((h == null ? void 0 : h.length) ?? 0) > 0 ? " — or add one here." : "." : " — new records then start with that value."
|
|
219
|
-
] }) : /* @__PURE__ */ n("div", { className: "space-y-4", children: pe.map((l) => /* @__PURE__ */ p("section", { "data-default-group": l.collection, children: [
|
|
220
|
-
/* @__PURE__ */ n("h4", { className: "mb-1 text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: l.label }),
|
|
221
|
-
/* @__PURE__ */ n("ul", { className: "divide-y divide-slate-100 dark:divide-border/60", children: (c ?? []).filter((r) => r.collection === l.collection).map((r) => {
|
|
222
|
-
var N;
|
|
223
|
-
return /* @__PURE__ */ n(
|
|
224
|
-
tt,
|
|
225
|
-
{
|
|
226
|
-
row: r,
|
|
227
|
-
meta: E.get(r.collection) ?? W,
|
|
228
|
-
parts: j.get(String(r.id)),
|
|
229
|
-
labels: me,
|
|
230
|
-
base: d,
|
|
231
|
-
onSaved: () => I(r.collection),
|
|
232
|
-
onClear: () => O.mutate(r),
|
|
233
|
-
clearing: O.isPending && ((N = O.variables) == null ? void 0 : N.id) === r.id
|
|
234
|
-
},
|
|
235
|
-
r.id
|
|
236
|
-
);
|
|
237
|
-
}) })
|
|
238
|
-
] }, l.collection)) }),
|
|
239
|
-
i && (h == null ? void 0 : h.length) === 0 && /* @__PURE__ */ p("p", { className: "mt-3 text-[11.5px] text-slate-500 dark:text-slate-400", children: [
|
|
240
|
-
"No form gives ",
|
|
241
|
-
e != null && e.trim() ? Y : "this person",
|
|
242
|
-
" a personal default yet. Turn on Personal default for a field in the layout editor."
|
|
243
|
-
] }),
|
|
244
|
-
i && k && /* @__PURE__ */ n(
|
|
245
|
-
nt,
|
|
203
|
+
] }) : J.length === 0 ? /* @__PURE__ */ s(
|
|
204
|
+
"p",
|
|
246
205
|
{
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
onCollection: z,
|
|
251
|
-
base: d,
|
|
252
|
-
onDone: () => {
|
|
253
|
-
F(!1), z("");
|
|
254
|
-
},
|
|
255
|
-
onSaved: (l) => I(l)
|
|
206
|
+
"data-default-empty": !0,
|
|
207
|
+
className: "max-w-[65ch] text-[12.5px] leading-relaxed text-slate-600 dark:text-slate-300",
|
|
208
|
+
children: d ? `${L} hasn’t saved any defaults yet.` : "You have no defaults yet."
|
|
256
209
|
}
|
|
257
|
-
)
|
|
210
|
+
) : /* @__PURE__ */ o("div", { className: "space-y-5", children: [
|
|
211
|
+
(x ?? []).length === 0 && /* @__PURE__ */ o(
|
|
212
|
+
"p",
|
|
213
|
+
{
|
|
214
|
+
"data-default-empty": !0,
|
|
215
|
+
className: "max-w-[65ch] text-[12.5px] leading-relaxed text-slate-600 dark:text-slate-300",
|
|
216
|
+
children: [
|
|
217
|
+
d ? `${L} hasn’t saved any defaults yet. Set one below, or they can choose ` : "Nothing set yet. Set a field below, or choose ",
|
|
218
|
+
/* @__PURE__ */ s("span", { className: "font-medium text-slate-800 dark:text-slate-100", children: "Make default" }),
|
|
219
|
+
" ",
|
|
220
|
+
"beside its label on a new record."
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
),
|
|
224
|
+
J.map((t) => {
|
|
225
|
+
const r = (x ?? []).filter((m) => m.collection === t.collection).length, N = j.get(t.collection) ?? [], q = h.get(t.collection) ?? B;
|
|
226
|
+
return /* @__PURE__ */ o("section", { "data-default-group": t.collection, children: [
|
|
227
|
+
/* @__PURE__ */ o("h4", { className: "flex items-baseline gap-1.5 border-b border-slate-200 pb-1.5 text-[12.5px] font-semibold text-slate-800 dark:border-border dark:text-slate-100", children: [
|
|
228
|
+
/* @__PURE__ */ s("span", { "data-default-group-label": !0, children: t.label }),
|
|
229
|
+
/* @__PURE__ */ o("span", { className: "text-[11.5px] font-normal tabular-nums text-slate-500 dark:text-slate-400", children: [
|
|
230
|
+
r,
|
|
231
|
+
" of ",
|
|
232
|
+
r + N.length,
|
|
233
|
+
" set"
|
|
234
|
+
] })
|
|
235
|
+
] }),
|
|
236
|
+
/* @__PURE__ */ o("ul", { className: "divide-y divide-slate-100 dark:divide-border/60", children: [
|
|
237
|
+
(x ?? []).filter((m) => m.collection === t.collection).map((m) => {
|
|
238
|
+
var F;
|
|
239
|
+
return /* @__PURE__ */ s(
|
|
240
|
+
Qe,
|
|
241
|
+
{
|
|
242
|
+
row: m,
|
|
243
|
+
meta: h.get(m.collection) ?? B,
|
|
244
|
+
parts: C.get(String(m.id)),
|
|
245
|
+
labels: ue,
|
|
246
|
+
base: c,
|
|
247
|
+
onSaved: () => A(m.collection),
|
|
248
|
+
onClear: () => Q.mutate(m),
|
|
249
|
+
clearing: Q.isPending && ((F = Q.variables) == null ? void 0 : F.id) === m.id
|
|
250
|
+
},
|
|
251
|
+
m.id
|
|
252
|
+
);
|
|
253
|
+
}),
|
|
254
|
+
N.map((m) => /* @__PURE__ */ s(
|
|
255
|
+
Ie,
|
|
256
|
+
{
|
|
257
|
+
collection: t.collection,
|
|
258
|
+
field: m,
|
|
259
|
+
meta: q,
|
|
260
|
+
base: c,
|
|
261
|
+
forOther: d,
|
|
262
|
+
onSaved: () => A(t.collection)
|
|
263
|
+
},
|
|
264
|
+
`unset:${m}`
|
|
265
|
+
))
|
|
266
|
+
] })
|
|
267
|
+
] }, t.collection);
|
|
268
|
+
})
|
|
269
|
+
] }),
|
|
270
|
+
d && (p == null ? void 0 : p.length) === 0 && /* @__PURE__ */ o("p", { className: "mt-3 text-[11.5px] text-slate-500 dark:text-slate-400", children: [
|
|
271
|
+
"No form gives ",
|
|
272
|
+
e != null && e.trim() ? L : "this person",
|
|
273
|
+
" a personal default yet. Turn on Personal default for a field in the layout editor."
|
|
274
|
+
] })
|
|
258
275
|
]
|
|
259
276
|
}
|
|
260
277
|
);
|
|
261
278
|
}
|
|
262
|
-
const
|
|
263
|
-
function
|
|
279
|
+
const le = 'input:not([type=hidden]), textarea, [role=combobox], button, [tabindex]:not([tabindex="-1"])', ee = "No form you can be given offers a personal default for this field now, so it is not used. Clear it, or ask an admin to turn it back on.";
|
|
280
|
+
function Qe({
|
|
264
281
|
row: a,
|
|
265
282
|
meta: e,
|
|
266
|
-
parts:
|
|
267
|
-
labels:
|
|
268
|
-
base:
|
|
269
|
-
onSaved:
|
|
270
|
-
onClear:
|
|
271
|
-
clearing:
|
|
283
|
+
parts: n,
|
|
284
|
+
labels: i,
|
|
285
|
+
base: f,
|
|
286
|
+
onSaved: d,
|
|
287
|
+
onClear: l,
|
|
288
|
+
clearing: c
|
|
272
289
|
}) {
|
|
273
|
-
const [
|
|
274
|
-
|
|
275
|
-
var
|
|
276
|
-
|
|
277
|
-
}, [
|
|
290
|
+
const [u, k] = _(!1), x = D(null), g = D(!1);
|
|
291
|
+
X(() => {
|
|
292
|
+
var h;
|
|
293
|
+
u || !g.current || (g.current = !1, (h = x.current) == null || h.focus());
|
|
294
|
+
}, [u]);
|
|
278
295
|
const y = () => {
|
|
279
|
-
|
|
280
|
-
},
|
|
281
|
-
if (
|
|
282
|
-
const C = Z(
|
|
283
|
-
return C.state === "loading" ? null : C.state === "gone" || C.state === "failed" ? `${
|
|
284
|
-
}),
|
|
285
|
-
return /* @__PURE__ */
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
296
|
+
g.current = !0, k(!1);
|
|
297
|
+
}, b = a.on_layout === !1, v = e.fields.find((h) => h.field === a.field), p = n ? Z(n.value, i) : { text: "", state: "loading" }, S = ((n == null ? void 0 : n.context) ?? []).map(([h, P]) => {
|
|
298
|
+
if (P.kind === "unknown") return T(e, h);
|
|
299
|
+
const C = Z(P, i);
|
|
300
|
+
return C.state === "loading" ? null : C.state === "gone" || C.state === "failed" ? `${T(e, h)} (unavailable)` : C.text;
|
|
301
|
+
}), w = ((n == null ? void 0 : n.context) ?? []).length > 0 && S.some((h) => h === null);
|
|
302
|
+
return /* @__PURE__ */ o(
|
|
303
|
+
"li",
|
|
304
|
+
{
|
|
305
|
+
"data-default-row": a.id,
|
|
306
|
+
"data-editing": u ? "" : void 0,
|
|
307
|
+
className: $(
|
|
308
|
+
"-mx-2 flex flex-col gap-2 rounded-md px-2 py-2.5 sm:flex-row sm:items-start sm:gap-3",
|
|
309
|
+
u && "bg-slate-50 dark:bg-muted/40"
|
|
294
310
|
),
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
311
|
+
children: [
|
|
312
|
+
/* @__PURE__ */ o("div", { className: "min-w-0 flex-1 gap-x-4 gap-y-1 sm:grid sm:grid-cols-[minmax(0,11rem)_minmax(0,1fr)]", children: [
|
|
313
|
+
/* @__PURE__ */ s(
|
|
314
|
+
"p",
|
|
315
|
+
{
|
|
316
|
+
"data-default-field": !0,
|
|
317
|
+
className: $(
|
|
318
|
+
"truncate text-[12.5px] text-slate-600 dark:text-slate-300",
|
|
319
|
+
u ? "sm:pt-2" : "sm:pt-px"
|
|
320
|
+
),
|
|
321
|
+
children: T(e, a.field)
|
|
306
322
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
323
|
+
),
|
|
324
|
+
/* @__PURE__ */ o("div", { className: "min-w-0", children: [
|
|
325
|
+
u && v ? /* @__PURE__ */ s(
|
|
326
|
+
je,
|
|
327
|
+
{
|
|
328
|
+
row: a,
|
|
329
|
+
field: v,
|
|
330
|
+
relations: e.relations,
|
|
331
|
+
base: f,
|
|
332
|
+
onCancel: y,
|
|
333
|
+
onSaved: () => {
|
|
334
|
+
y(), d();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
) : p.state === "loading" ? /* @__PURE__ */ s(U, { className: "mt-0.5 h-3.5 w-32" }) : /* @__PURE__ */ s(
|
|
338
|
+
"p",
|
|
339
|
+
{
|
|
340
|
+
"data-default-value": !0,
|
|
341
|
+
"data-tip": p.state === "gone" ? "The saved record was removed, or is no longer visible to you" : void 0,
|
|
342
|
+
className: $(
|
|
343
|
+
"truncate text-[13px]",
|
|
344
|
+
p.state === "gone" || p.state === "failed" ? "italic text-slate-500 dark:text-slate-400" : b ? "text-slate-500 dark:text-slate-400" : "font-medium text-slate-800 dark:text-slate-100"
|
|
345
|
+
),
|
|
346
|
+
children: p.text
|
|
347
|
+
}
|
|
316
348
|
),
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
ee
|
|
349
|
+
/* @__PURE__ */ o("p", { className: "mt-1 flex flex-wrap items-center gap-x-1.5 gap-y-1 text-[11.5px] text-slate-500 dark:text-slate-400", children: [
|
|
350
|
+
w ? /* @__PURE__ */ s(U, { className: "h-3 w-28" }) : S.length > 0 ? /* @__PURE__ */ o("span", { "data-default-context": !0, children: [
|
|
351
|
+
"For ",
|
|
352
|
+
S.join(" · ")
|
|
353
|
+
] }) : null,
|
|
354
|
+
!u && (w || S.length > 0) && /* @__PURE__ */ s("span", { "aria-hidden": !0, children: "·" }),
|
|
355
|
+
!u && /* @__PURE__ */ o("span", { children: [
|
|
356
|
+
a.updated_by ? "Set by an admin" : "Saved",
|
|
357
|
+
" ",
|
|
358
|
+
qe(a.updated_at)
|
|
359
|
+
] }),
|
|
360
|
+
b && /* @__PURE__ */ o("span", { "data-tip": ee, children: [
|
|
361
|
+
/* @__PURE__ */ s(Re, { tone: "amber", testId: "stale", children: /* @__PURE__ */ s("span", { "data-default-stale": !0, children: "No longer on any form" }) }),
|
|
362
|
+
/* @__PURE__ */ o("span", { className: "sr-only", children: [
|
|
363
|
+
". ",
|
|
364
|
+
ee
|
|
365
|
+
] })
|
|
366
|
+
] })
|
|
336
367
|
] })
|
|
337
368
|
] })
|
|
338
|
-
] })
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
"div",
|
|
343
|
-
{
|
|
344
|
-
className: R(
|
|
345
|
-
"flex shrink-0 items-center gap-0.5 transition-opacity duration-150",
|
|
346
|
-
// Reserve the slot; show on hover / keyboard focus, always on touch and when stale.
|
|
347
|
-
// …and while Clear is armed (the pointer may have left before the second press).
|
|
348
|
-
!f && "opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 [@media(hover:none)]:opacity-100 [&:has([data-armed])]:opacity-100"
|
|
349
|
-
),
|
|
350
|
-
children: [
|
|
351
|
-
!f && v && /* @__PURE__ */ n(
|
|
369
|
+
] }),
|
|
370
|
+
!u && // Always visible: hover-only actions hid the only way to change or clear a default.
|
|
371
|
+
/* @__PURE__ */ o("div", { className: "flex shrink-0 items-center gap-1 sm:pt-px", children: [
|
|
372
|
+
!b && v && /* @__PURE__ */ o(
|
|
352
373
|
"button",
|
|
353
374
|
{
|
|
354
|
-
ref:
|
|
375
|
+
ref: x,
|
|
355
376
|
type: "button",
|
|
356
377
|
"data-default-change": !0,
|
|
357
|
-
"aria-label": `Change the default for ${
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
378
|
+
"aria-label": `Change the default for ${T(e, a.field)}`,
|
|
379
|
+
onClick: () => k(!0),
|
|
380
|
+
className: Y,
|
|
381
|
+
children: [
|
|
382
|
+
/* @__PURE__ */ s(xe, { className: "h-3 w-3" }),
|
|
383
|
+
" Change"
|
|
384
|
+
]
|
|
362
385
|
}
|
|
363
386
|
),
|
|
364
|
-
/* @__PURE__ */
|
|
365
|
-
|
|
387
|
+
/* @__PURE__ */ s(
|
|
388
|
+
Le,
|
|
366
389
|
{
|
|
367
|
-
onConfirm:
|
|
368
|
-
disabled:
|
|
369
|
-
title: `Clear the default for ${
|
|
370
|
-
confirmTitle: `Clear the default for ${
|
|
371
|
-
confirmLabel: /* @__PURE__ */
|
|
372
|
-
className: "inline-flex h-7 items-center rounded px-
|
|
390
|
+
onConfirm: l,
|
|
391
|
+
disabled: c,
|
|
392
|
+
title: `Clear the default for ${T(e, a.field)}`,
|
|
393
|
+
confirmTitle: `Clear the default for ${T(e, a.field)}?`,
|
|
394
|
+
confirmLabel: /* @__PURE__ */ s("span", { "data-default-clear": !0, className: "px-0.5 text-[11.5px] font-semibold", children: "Clear it?" }),
|
|
395
|
+
className: "inline-flex h-7 items-center gap-1 rounded-md px-2 text-[11.5px] font-medium text-slate-500 transition-colors hover:bg-muted hover:text-red-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 disabled:opacity-50 dark:text-slate-400 dark:hover:text-red-400",
|
|
373
396
|
armedClassName: "bg-red-50 text-red-700 hover:bg-red-100 dark:bg-red-500/10 dark:text-red-400 dark:hover:bg-red-500/15",
|
|
374
|
-
children: /* @__PURE__ */
|
|
397
|
+
children: /* @__PURE__ */ o("span", { "data-default-clear": !0, className: "inline-flex items-center gap-1", children: [
|
|
398
|
+
/* @__PURE__ */ s(he, { className: "h-3 w-3" }),
|
|
399
|
+
" Clear"
|
|
400
|
+
] })
|
|
375
401
|
}
|
|
376
402
|
)
|
|
377
|
-
]
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
403
|
+
] })
|
|
404
|
+
]
|
|
405
|
+
}
|
|
406
|
+
);
|
|
381
407
|
}
|
|
382
|
-
function
|
|
408
|
+
function se({
|
|
383
409
|
collection: a,
|
|
384
410
|
field: e,
|
|
385
|
-
relations:
|
|
386
|
-
context:
|
|
387
|
-
value:
|
|
388
|
-
onChange:
|
|
411
|
+
relations: n,
|
|
412
|
+
context: i,
|
|
413
|
+
value: f,
|
|
414
|
+
onChange: d
|
|
389
415
|
}) {
|
|
390
|
-
var
|
|
391
|
-
const
|
|
392
|
-
() => Array.isArray(
|
|
393
|
-
[
|
|
394
|
-
),
|
|
395
|
-
() =>
|
|
396
|
-
getStagedLinks: () =>
|
|
416
|
+
var b;
|
|
417
|
+
const l = E(() => ({ ...e, readonly: !1, hidden: !1 }), [e]), c = ((b = Fe(n, a, e.field)) == null ? void 0 : b.kind) === "m2m", u = E(
|
|
418
|
+
() => Array.isArray(f) ? f : K(f) ? [] : [f],
|
|
419
|
+
[f]
|
|
420
|
+
), k = E(
|
|
421
|
+
() => c ? {
|
|
422
|
+
getStagedLinks: () => u,
|
|
397
423
|
getStagedUnlinks: () => /* @__PURE__ */ new Set(),
|
|
398
|
-
stageLink: (v,
|
|
399
|
-
unstageLink: (v,
|
|
424
|
+
stageLink: (v, p) => d(u.some((S) => String(S) === String(p)) ? u : [...u, p]),
|
|
425
|
+
unstageLink: (v, p) => d(u.filter((S) => String(S) !== String(p))),
|
|
400
426
|
stageUnlink: () => {
|
|
401
427
|
},
|
|
402
428
|
unstageUnlink: () => {
|
|
403
429
|
}
|
|
404
430
|
} : null,
|
|
405
|
-
[
|
|
406
|
-
),
|
|
407
|
-
() =>
|
|
408
|
-
rules:
|
|
409
|
-
parentValue: (v) =>
|
|
431
|
+
[c, u, d]
|
|
432
|
+
), x = E(
|
|
433
|
+
() => Te({
|
|
434
|
+
rules: ae(e.dependency_config),
|
|
435
|
+
parentValue: (v) => K(i[v]) ? null : i[v]
|
|
410
436
|
}).filter,
|
|
411
|
-
[e.dependency_config,
|
|
412
|
-
),
|
|
413
|
-
|
|
437
|
+
[e.dependency_config, i]
|
|
438
|
+
), g = E(() => ({ collection: a, draft: { ...i } }), [a, i]), y = /* @__PURE__ */ s(
|
|
439
|
+
Pe,
|
|
414
440
|
{
|
|
415
|
-
field:
|
|
416
|
-
value:
|
|
417
|
-
onChange:
|
|
418
|
-
relations:
|
|
441
|
+
field: l,
|
|
442
|
+
value: c ? void 0 : f,
|
|
443
|
+
onChange: d,
|
|
444
|
+
relations: n,
|
|
419
445
|
collection: a,
|
|
420
446
|
itemId: "new",
|
|
421
|
-
cascadeFilter:
|
|
447
|
+
cascadeFilter: x
|
|
422
448
|
}
|
|
423
449
|
);
|
|
424
|
-
return /* @__PURE__ */
|
|
450
|
+
return /* @__PURE__ */ s(Ne.Provider, { value: g, children: k ? /* @__PURE__ */ s(Ee.Provider, { value: k, children: y }) : y });
|
|
425
451
|
}
|
|
426
|
-
function
|
|
452
|
+
function re({
|
|
427
453
|
canSave: a,
|
|
428
454
|
pending: e,
|
|
429
|
-
onSave:
|
|
430
|
-
onCancel:
|
|
455
|
+
onSave: n,
|
|
456
|
+
onCancel: i
|
|
431
457
|
}) {
|
|
432
|
-
return /* @__PURE__ */
|
|
433
|
-
/* @__PURE__ */
|
|
434
|
-
/* @__PURE__ */
|
|
458
|
+
return /* @__PURE__ */ o("span", { className: "flex h-9 shrink-0 items-center gap-1.5", children: [
|
|
459
|
+
/* @__PURE__ */ o("button", { type: "button", onClick: i, className: Y, children: [
|
|
460
|
+
/* @__PURE__ */ s(ye, { className: "h-3 w-3" }),
|
|
435
461
|
" Cancel"
|
|
436
462
|
] }),
|
|
437
|
-
/* @__PURE__ */
|
|
463
|
+
/* @__PURE__ */ s(
|
|
438
464
|
"button",
|
|
439
465
|
{
|
|
440
466
|
type: "button",
|
|
441
467
|
"data-default-save": !0,
|
|
442
468
|
disabled: !a || e,
|
|
443
|
-
onClick:
|
|
469
|
+
onClick: n,
|
|
444
470
|
className: "inline-flex h-7 items-center gap-1 rounded-md bg-nvr-cyan px-2.5 text-[11.5px] font-semibold text-white transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 focus-visible:ring-offset-1 disabled:opacity-50",
|
|
445
|
-
children: e ? "Saving…" : /* @__PURE__ */
|
|
446
|
-
/* @__PURE__ */
|
|
471
|
+
children: e ? "Saving…" : /* @__PURE__ */ o(fe, { children: [
|
|
472
|
+
/* @__PURE__ */ s(be, { className: "h-3 w-3" }),
|
|
447
473
|
" Save"
|
|
448
474
|
] })
|
|
449
475
|
}
|
|
450
476
|
)
|
|
451
477
|
] });
|
|
452
478
|
}
|
|
453
|
-
function
|
|
454
|
-
const
|
|
455
|
-
return { save:
|
|
456
|
-
mutationFn: (
|
|
479
|
+
function ie(a, e) {
|
|
480
|
+
const n = z(), [i, f] = _(null);
|
|
481
|
+
return { save: te({
|
|
482
|
+
mutationFn: (l) => n.request(we(a, l)),
|
|
457
483
|
onSuccess: () => {
|
|
458
|
-
|
|
484
|
+
f(null), V.success("Default saved"), e();
|
|
459
485
|
},
|
|
460
|
-
onError: (
|
|
461
|
-
}), error:
|
|
486
|
+
onError: (l) => f(ne(l))
|
|
487
|
+
}), error: i };
|
|
462
488
|
}
|
|
463
|
-
function
|
|
489
|
+
function je({
|
|
464
490
|
row: a,
|
|
465
491
|
field: e,
|
|
466
|
-
relations:
|
|
467
|
-
base:
|
|
468
|
-
onCancel:
|
|
469
|
-
onSaved:
|
|
492
|
+
relations: n,
|
|
493
|
+
base: i,
|
|
494
|
+
onCancel: f,
|
|
495
|
+
onSaved: d
|
|
470
496
|
}) {
|
|
471
|
-
const [
|
|
472
|
-
return
|
|
473
|
-
const
|
|
474
|
-
var v,
|
|
475
|
-
const
|
|
476
|
-
return
|
|
497
|
+
const [l, c] = _(a.value), { save: u, error: k } = ie(i, d), x = D(null);
|
|
498
|
+
return X(() => {
|
|
499
|
+
const g = () => {
|
|
500
|
+
var v, p;
|
|
501
|
+
const b = (p = (v = x.current) == null ? void 0 : v.querySelector("[data-default-control]")) == null ? void 0 : p.querySelector(le);
|
|
502
|
+
return b == null || b.focus(), !!b;
|
|
477
503
|
};
|
|
478
|
-
if (
|
|
479
|
-
const y = window.setTimeout(
|
|
504
|
+
if (g()) return;
|
|
505
|
+
const y = window.setTimeout(g, 50);
|
|
480
506
|
return () => window.clearTimeout(y);
|
|
481
|
-
}, []), /* @__PURE__ */
|
|
507
|
+
}, []), /* @__PURE__ */ o(
|
|
482
508
|
"fieldset",
|
|
483
509
|
{
|
|
484
|
-
ref:
|
|
510
|
+
ref: x,
|
|
485
511
|
className: "m-0 min-w-0 space-y-1.5 border-0 p-0",
|
|
486
512
|
"data-default-editor": !0,
|
|
487
|
-
onKeyDown: (
|
|
513
|
+
onKeyDown: (g) => {
|
|
488
514
|
var y;
|
|
489
|
-
|
|
515
|
+
g.key !== "Escape" || g.defaultPrevented || (y = x.current) != null && y.contains(g.target) && (g.stopPropagation(), f());
|
|
490
516
|
},
|
|
491
517
|
children: [
|
|
492
|
-
/* @__PURE__ */
|
|
518
|
+
/* @__PURE__ */ o("legend", { className: "sr-only", children: [
|
|
493
519
|
"Change the default for ",
|
|
494
520
|
e.label || e.field
|
|
495
521
|
] }),
|
|
496
|
-
/* @__PURE__ */
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
field: e,
|
|
501
|
-
relations: t,
|
|
502
|
-
context: a.context ?? {},
|
|
503
|
-
value: s,
|
|
504
|
-
onChange: d
|
|
505
|
-
}
|
|
506
|
-
) }),
|
|
507
|
-
x && /* @__PURE__ */ n("p", { role: "alert", className: "text-[11.5px] text-red-600 dark:text-red-400", children: x }),
|
|
508
|
-
/* @__PURE__ */ n(
|
|
509
|
-
oe,
|
|
510
|
-
{
|
|
511
|
-
canSave: !M(s),
|
|
512
|
-
pending: m.isPending,
|
|
513
|
-
onCancel: u,
|
|
514
|
-
onSave: () => m.mutate({
|
|
522
|
+
/* @__PURE__ */ o("div", { className: "flex flex-wrap items-start gap-2", children: [
|
|
523
|
+
/* @__PURE__ */ s("div", { "data-default-control": !0, className: "min-w-[12rem] max-w-[28rem] flex-1", children: /* @__PURE__ */ s(
|
|
524
|
+
se,
|
|
525
|
+
{
|
|
515
526
|
collection: a.collection,
|
|
516
|
-
field:
|
|
517
|
-
|
|
518
|
-
context: a.context ?? {}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
527
|
+
field: e,
|
|
528
|
+
relations: n,
|
|
529
|
+
context: a.context ?? {},
|
|
530
|
+
value: l,
|
|
531
|
+
onChange: c
|
|
532
|
+
}
|
|
533
|
+
) }),
|
|
534
|
+
/* @__PURE__ */ s(
|
|
535
|
+
re,
|
|
536
|
+
{
|
|
537
|
+
canSave: !K(l),
|
|
538
|
+
pending: u.isPending,
|
|
539
|
+
onCancel: f,
|
|
540
|
+
onSave: () => u.mutate({
|
|
541
|
+
collection: a.collection,
|
|
542
|
+
field: a.field,
|
|
543
|
+
value: l,
|
|
544
|
+
context: a.context ?? {}
|
|
545
|
+
})
|
|
546
|
+
}
|
|
547
|
+
)
|
|
548
|
+
] }),
|
|
549
|
+
k && /* @__PURE__ */ s("p", { role: "alert", className: "text-[11.5px] text-red-600 dark:text-red-400", children: k })
|
|
522
550
|
]
|
|
523
551
|
}
|
|
524
552
|
);
|
|
525
553
|
}
|
|
526
|
-
function
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
disabled: s
|
|
534
|
-
}) {
|
|
535
|
-
const [d, m] = w(!1), x = e.find((c) => c.value === a);
|
|
536
|
-
return /* @__PURE__ */ p(Qe, { open: d, onOpenChange: m, children: [
|
|
537
|
-
/* @__PURE__ */ n(Ve, { asChild: !0, children: /* @__PURE__ */ p(
|
|
538
|
-
"button",
|
|
539
|
-
{
|
|
540
|
-
type: "button",
|
|
541
|
-
role: "combobox",
|
|
542
|
-
"aria-expanded": d,
|
|
543
|
-
"aria-label": o,
|
|
544
|
-
"data-default-pick": i,
|
|
545
|
-
disabled: s,
|
|
546
|
-
className: "flex h-8 w-full items-center justify-between gap-2 rounded-md border border-slate-200 bg-white px-2.5 text-left text-[12.5px] text-slate-700 transition-colors hover:border-slate-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 disabled:cursor-not-allowed disabled:bg-slate-50 disabled:hover:border-slate-200 dark:border-border dark:bg-background dark:text-slate-200 dark:hover:border-slate-600 dark:disabled:bg-muted/40 dark:disabled:hover:border-border",
|
|
547
|
-
children: [
|
|
548
|
-
/* @__PURE__ */ n("span", { className: R("truncate", !x && "text-slate-500 dark:text-slate-400"), children: (x == null ? void 0 : x.label) ?? t }),
|
|
549
|
-
/* @__PURE__ */ n(Ne, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
|
|
550
|
-
]
|
|
551
|
-
}
|
|
552
|
-
) }),
|
|
553
|
-
/* @__PURE__ */ n(Be, { className: "w-[260px] p-0", align: "start", children: /* @__PURE__ */ p(Le, { children: [
|
|
554
|
-
/* @__PURE__ */ n(Ue, { placeholder: "Search…", className: "h-8 text-[12px]" }),
|
|
555
|
-
/* @__PURE__ */ p(Re, { children: [
|
|
556
|
-
/* @__PURE__ */ n(je, { className: "py-3 text-center text-[12px] text-slate-500 dark:text-slate-400", children: "No matches" }),
|
|
557
|
-
/* @__PURE__ */ n(Ie, { children: e.map((c) => /* @__PURE__ */ p(
|
|
558
|
-
Oe,
|
|
559
|
-
{
|
|
560
|
-
value: `${c.label} ${c.value}`,
|
|
561
|
-
onSelect: () => {
|
|
562
|
-
u(c.value), m(!1);
|
|
563
|
-
},
|
|
564
|
-
className: "text-[12px]",
|
|
565
|
-
children: [
|
|
566
|
-
/* @__PURE__ */ n(
|
|
567
|
-
ne,
|
|
568
|
-
{
|
|
569
|
-
className: R("mr-2 h-3 w-3", c.value === a ? "opacity-100" : "opacity-0")
|
|
570
|
-
}
|
|
571
|
-
),
|
|
572
|
-
c.label
|
|
573
|
-
]
|
|
574
|
-
},
|
|
575
|
-
c.value
|
|
576
|
-
)) })
|
|
577
|
-
] })
|
|
578
|
-
] }) })
|
|
579
|
-
] });
|
|
580
|
-
}
|
|
581
|
-
function nt({
|
|
582
|
-
allowed: a,
|
|
583
|
-
metas: e,
|
|
584
|
-
collection: t,
|
|
585
|
-
onCollection: o,
|
|
586
|
-
base: u,
|
|
587
|
-
onDone: i,
|
|
588
|
-
onSaved: s
|
|
554
|
+
function Ie({
|
|
555
|
+
collection: a,
|
|
556
|
+
field: e,
|
|
557
|
+
meta: n,
|
|
558
|
+
base: i,
|
|
559
|
+
forOther: f,
|
|
560
|
+
onSaved: d
|
|
589
561
|
}) {
|
|
590
|
-
const [
|
|
591
|
-
|
|
592
|
-
}),
|
|
593
|
-
|
|
594
|
-
|
|
562
|
+
const [l, c] = _(!1), [u, k] = _(null), { save: x, error: g } = ie(i, () => {
|
|
563
|
+
c(!1), k(null), d();
|
|
564
|
+
}), y = n.fields.find((w) => w.field === e), b = T(n, e), v = D(null), p = D(null);
|
|
565
|
+
X(() => {
|
|
566
|
+
if (!l) return;
|
|
567
|
+
const w = window.setTimeout(() => {
|
|
568
|
+
var h, P, C;
|
|
569
|
+
(C = (P = (h = p.current) == null ? void 0 : h.querySelector("[data-default-control]")) == null ? void 0 : P.querySelector(le)) == null || C.focus();
|
|
570
|
+
}, 30);
|
|
571
|
+
return () => window.clearTimeout(w);
|
|
572
|
+
}, [l]);
|
|
573
|
+
const S = () => {
|
|
574
|
+
c(!1), k(null), requestAnimationFrame(() => {
|
|
575
|
+
var w;
|
|
576
|
+
return (w = v.current) == null ? void 0 : w.focus();
|
|
577
|
+
});
|
|
578
|
+
};
|
|
579
|
+
return /* @__PURE__ */ o(
|
|
580
|
+
"li",
|
|
595
581
|
{
|
|
596
|
-
"data-default-
|
|
597
|
-
|
|
582
|
+
"data-default-unset": e,
|
|
583
|
+
"data-editing": l ? "" : void 0,
|
|
584
|
+
className: $(
|
|
585
|
+
"-mx-2 flex flex-col gap-2 rounded-md px-2 py-2.5 sm:flex-row sm:items-start sm:gap-3",
|
|
586
|
+
l && "bg-slate-50 dark:bg-muted/40"
|
|
587
|
+
),
|
|
598
588
|
children: [
|
|
599
|
-
/* @__PURE__ */
|
|
600
|
-
/* @__PURE__ */
|
|
601
|
-
|
|
589
|
+
/* @__PURE__ */ o("div", { className: "min-w-0 flex-1 gap-x-4 gap-y-1 sm:grid sm:grid-cols-[minmax(0,11rem)_minmax(0,1fr)]", children: [
|
|
590
|
+
/* @__PURE__ */ s(
|
|
591
|
+
"p",
|
|
602
592
|
{
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
return {
|
|
610
|
-
value: g.collection,
|
|
611
|
-
label: g.label ?? ((q = e.get(g.collection)) == null ? void 0 : q.label) ?? _(g.collection)
|
|
612
|
-
};
|
|
613
|
-
}),
|
|
614
|
-
onChange: (g) => {
|
|
615
|
-
o(g), m(""), c(null);
|
|
616
|
-
}
|
|
593
|
+
"data-default-field": !0,
|
|
594
|
+
className: $(
|
|
595
|
+
"truncate text-[12.5px] text-slate-600 dark:text-slate-300",
|
|
596
|
+
l ? "sm:pt-2" : "sm:pt-px"
|
|
597
|
+
),
|
|
598
|
+
children: b
|
|
617
599
|
}
|
|
618
600
|
),
|
|
619
|
-
/* @__PURE__ */
|
|
620
|
-
|
|
601
|
+
/* @__PURE__ */ s("div", { className: "min-w-0", children: l && y ? /* @__PURE__ */ o(
|
|
602
|
+
"fieldset",
|
|
621
603
|
{
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
604
|
+
ref: p,
|
|
605
|
+
className: "m-0 min-w-0 space-y-1.5 border-0 p-0",
|
|
606
|
+
"data-default-editor": !0,
|
|
607
|
+
onKeyDown: (w) => {
|
|
608
|
+
var h;
|
|
609
|
+
w.key !== "Escape" || w.defaultPrevented || (h = p.current) != null && h.contains(w.target) && (w.stopPropagation(), S());
|
|
610
|
+
},
|
|
611
|
+
children: [
|
|
612
|
+
/* @__PURE__ */ o("legend", { className: "sr-only", children: [
|
|
613
|
+
"Set the default for ",
|
|
614
|
+
b
|
|
615
|
+
] }),
|
|
616
|
+
/* @__PURE__ */ o("div", { className: "flex flex-wrap items-start gap-2", children: [
|
|
617
|
+
/* @__PURE__ */ s("div", { "data-default-control": !0, className: "min-w-[12rem] max-w-[28rem] flex-1", children: /* @__PURE__ */ s(
|
|
618
|
+
se,
|
|
619
|
+
{
|
|
620
|
+
collection: a,
|
|
621
|
+
field: y,
|
|
622
|
+
relations: n.relations,
|
|
623
|
+
context: {},
|
|
624
|
+
value: u,
|
|
625
|
+
onChange: k
|
|
626
|
+
}
|
|
627
|
+
) }),
|
|
628
|
+
/* @__PURE__ */ s(
|
|
629
|
+
re,
|
|
630
|
+
{
|
|
631
|
+
canSave: !K(u),
|
|
632
|
+
pending: x.isPending,
|
|
633
|
+
onCancel: S,
|
|
634
|
+
onSave: () => x.mutate({ collection: a, field: e, value: u, context: {} })
|
|
635
|
+
}
|
|
636
|
+
)
|
|
637
|
+
] }),
|
|
638
|
+
g && /* @__PURE__ */ s("p", { role: "alert", className: "text-[11.5px] text-red-600 dark:text-red-400", children: g }),
|
|
639
|
+
f && /* @__PURE__ */ s("p", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: "Checked as them: they must be able to set the field and pick the value." })
|
|
640
|
+
]
|
|
634
641
|
}
|
|
635
|
-
)
|
|
642
|
+
) : /* @__PURE__ */ s(
|
|
643
|
+
"p",
|
|
644
|
+
{
|
|
645
|
+
"data-default-value": !0,
|
|
646
|
+
className: "pt-px text-[12.5px] italic text-slate-500 dark:text-slate-400",
|
|
647
|
+
children: "Not set"
|
|
648
|
+
}
|
|
649
|
+
) })
|
|
636
650
|
] }),
|
|
637
|
-
|
|
638
|
-
|
|
651
|
+
!l && /* @__PURE__ */ s("div", { className: "flex shrink-0 items-center gap-1 sm:pt-px", children: /* @__PURE__ */ o(
|
|
652
|
+
"button",
|
|
639
653
|
{
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
654
|
+
ref: v,
|
|
655
|
+
type: "button",
|
|
656
|
+
"data-default-set": e,
|
|
657
|
+
"aria-label": `Set a default for ${b}`,
|
|
658
|
+
disabled: !y,
|
|
659
|
+
onClick: () => c(!0),
|
|
660
|
+
className: $(Y, "disabled:opacity-50"),
|
|
661
|
+
children: [
|
|
662
|
+
/* @__PURE__ */ s(ge, { className: "h-3 w-3" }),
|
|
663
|
+
" Set"
|
|
664
|
+
]
|
|
646
665
|
}
|
|
647
|
-
)
|
|
648
|
-
y && /* @__PURE__ */ n("p", { role: "alert", className: "text-[11.5px] text-red-600 dark:text-red-400", children: y }),
|
|
649
|
-
/* @__PURE__ */ p("div", { className: "flex items-center justify-between gap-2", children: [
|
|
650
|
-
/* @__PURE__ */ n("p", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: "Checked as them: they must be able to set the field and pick the value." }),
|
|
651
|
-
/* @__PURE__ */ n(
|
|
652
|
-
oe,
|
|
653
|
-
{
|
|
654
|
-
canSave: !!h && !M(x),
|
|
655
|
-
pending: b.isPending,
|
|
656
|
-
onCancel: i,
|
|
657
|
-
onSave: () => b.mutate({ collection: t, field: d, value: x, context: {} })
|
|
658
|
-
}
|
|
659
|
-
)
|
|
660
|
-
] })
|
|
666
|
+
) })
|
|
661
667
|
]
|
|
662
668
|
}
|
|
663
669
|
);
|
|
664
670
|
}
|
|
665
671
|
export {
|
|
666
|
-
|
|
672
|
+
ot as MyDefaultsCard
|
|
667
673
|
};
|