@nivaro/react 0.3.118 → 0.3.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/ItemEditForm.js +2047 -2026
- package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +6 -4
- package/dist/shared/components/item-edit/FieldComments.js +45 -43
- package/dist/shared/components/item-edit/HeaderTools.js +237 -142
- package/dist/shared/components/item-edit/RecordHelpChip.js +10 -10
- package/dist/shared/components/item-edit/addendum-view.js +6 -0
- package/dist/shared/components/layout-editor/pickers/field-picker.js +118 -105
- package/package.json +1 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { jsxs as c, jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { ChevronRight as M, X as
|
|
2
|
+
import { ChevronRight as M, X as k, Search as F, Loader2 as R } from "lucide-react";
|
|
3
3
|
import { useState as E, useRef as O, useLayoutEffect as z, useEffect as H } from "react";
|
|
4
4
|
import { createPortal as $ } from "react-dom";
|
|
5
5
|
import { titleCase as _ } from "../../../lib/utils.js";
|
|
6
|
-
import { Popover as B, PopoverTrigger as T, PopoverContent as
|
|
7
|
-
import { useCollectionBody as
|
|
6
|
+
import { Popover as B, PopoverTrigger as T, PopoverContent as W } from "../../ui/popover.js";
|
|
7
|
+
import { useCollectionBody as q } from "../collection-meta.js";
|
|
8
8
|
function V({
|
|
9
9
|
collection: n,
|
|
10
|
-
fields:
|
|
10
|
+
fields: f,
|
|
11
11
|
relations: u,
|
|
12
|
-
value:
|
|
12
|
+
value: r,
|
|
13
13
|
valueLabel: h,
|
|
14
|
-
onChange:
|
|
15
|
-
onClear:
|
|
16
|
-
placeholder:
|
|
17
|
-
walk:
|
|
14
|
+
onChange: a,
|
|
15
|
+
onClear: p,
|
|
16
|
+
placeholder: s,
|
|
17
|
+
walk: v
|
|
18
18
|
}) {
|
|
19
|
-
const [o,
|
|
19
|
+
const [o, i] = E(!1), [x, m] = E(""), y = O(null), b = O(null), [g, L] = E(null);
|
|
20
20
|
z(() => {
|
|
21
21
|
if (!o) return;
|
|
22
22
|
const t = () => {
|
|
23
23
|
var N;
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
26
|
-
const C = Math.min(
|
|
24
|
+
const d = (N = y.current) == null ? void 0 : N.getBoundingClientRect();
|
|
25
|
+
if (!d) return;
|
|
26
|
+
const C = Math.min(d.left, window.innerWidth - 288 - 8), j = Math.min(d.bottom + 4, window.innerHeight - 60);
|
|
27
27
|
L({ top: j, left: Math.max(8, C) });
|
|
28
28
|
};
|
|
29
29
|
return t(), window.addEventListener("scroll", t, !0), window.addEventListener("resize", t), () => {
|
|
@@ -31,67 +31,70 @@ function V({
|
|
|
31
31
|
};
|
|
32
32
|
}, [o]), H(() => {
|
|
33
33
|
if (!o) return;
|
|
34
|
-
const t = (
|
|
34
|
+
const t = (d) => {
|
|
35
35
|
var C, j, N;
|
|
36
|
-
const
|
|
37
|
-
(C =
|
|
36
|
+
const e = d.target;
|
|
37
|
+
(C = y.current) != null && C.contains(e) || (j = b.current) != null && j.contains(e) || (N = e.closest) != null && N.call(e, "[data-radix-popper-content-wrapper]") || i(!1);
|
|
38
38
|
};
|
|
39
39
|
return document.addEventListener("mousedown", t), () => document.removeEventListener("mousedown", t);
|
|
40
40
|
}, [o]);
|
|
41
|
-
const
|
|
41
|
+
const w = [...f].sort((t, d) => t.field.localeCompare(d.field)).filter((t) => t.field.toLowerCase().includes(x.trim().toLowerCase()));
|
|
42
42
|
return /* @__PURE__ */ c("div", { className: "relative", children: [
|
|
43
43
|
/* @__PURE__ */ c(
|
|
44
44
|
"button",
|
|
45
45
|
{
|
|
46
46
|
type: "button",
|
|
47
|
-
ref:
|
|
48
|
-
onClick: () =>
|
|
49
|
-
className: `flex h-8 w-full items-center justify-between gap-1.5 rounded-md border border-slate-200 bg-white text-[13px] text-slate-700 hover:border-slate-300 ${
|
|
47
|
+
ref: y,
|
|
48
|
+
onClick: () => i((t) => !t),
|
|
49
|
+
className: `flex h-8 w-full items-center justify-between gap-1.5 rounded-md border border-slate-200 bg-white text-[13px] text-slate-700 hover:border-slate-300 ${r && p ? "pl-2.5 pr-8" : "px-2.5"}`,
|
|
50
50
|
children: [
|
|
51
51
|
/* @__PURE__ */ l(
|
|
52
52
|
"span",
|
|
53
53
|
{
|
|
54
|
-
className:
|
|
55
|
-
|
|
54
|
+
className: (
|
|
55
|
+
// A readable label (valueLabel) reads like the rest of the UI; only a raw path is mono.
|
|
56
|
+
r && h ? "text-[12.5px] flex-1 text-left truncate" : r ? "font-mono text-[12px] flex-1 text-left truncate" : "text-slate-400 flex-1 text-left truncate whitespace-nowrap"
|
|
57
|
+
),
|
|
58
|
+
children: h || r || s || "Select field…"
|
|
56
59
|
}
|
|
57
60
|
),
|
|
58
61
|
/* @__PURE__ */ l(M, { className: "h-3.5 w-3.5 text-slate-400 shrink-0" })
|
|
59
62
|
]
|
|
60
63
|
}
|
|
61
64
|
),
|
|
62
|
-
|
|
65
|
+
r && p && /* @__PURE__ */ l(
|
|
63
66
|
"button",
|
|
64
67
|
{
|
|
65
68
|
type: "button",
|
|
66
69
|
onClick: (t) => {
|
|
67
|
-
t.stopPropagation(),
|
|
70
|
+
t.stopPropagation(), p();
|
|
68
71
|
},
|
|
69
72
|
className: "absolute right-2 top-1/2 -translate-y-1/2 flex h-5 w-5 items-center justify-center rounded text-slate-400 hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-muted dark:hover:text-slate-300",
|
|
70
|
-
children: /* @__PURE__ */ l(
|
|
73
|
+
children: /* @__PURE__ */ l(k, { className: "h-3 w-3" })
|
|
71
74
|
}
|
|
72
75
|
),
|
|
73
|
-
o &&
|
|
76
|
+
o && g && $(
|
|
74
77
|
/* @__PURE__ */ l(
|
|
75
78
|
"div",
|
|
76
79
|
{
|
|
77
|
-
ref:
|
|
78
|
-
style: { position: "fixed", top:
|
|
80
|
+
ref: b,
|
|
81
|
+
style: { position: "fixed", top: g.top, left: g.left },
|
|
79
82
|
className: "z-50 w-72 rounded-xl border border-slate-200 bg-white shadow-lg dark:border-border dark:bg-card",
|
|
80
83
|
children: /* @__PURE__ */ c("div", { className: "p-2", children: [
|
|
81
84
|
/* @__PURE__ */ c("div", { className: "relative mb-1.5", children: [
|
|
82
|
-
/* @__PURE__ */ l(
|
|
85
|
+
/* @__PURE__ */ l(F, { className: "absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
|
|
83
86
|
/* @__PURE__ */ l(
|
|
84
87
|
"input",
|
|
85
88
|
{
|
|
86
|
-
value:
|
|
87
|
-
onChange: (t) =>
|
|
89
|
+
value: x,
|
|
90
|
+
onChange: (t) => m(t.target.value),
|
|
88
91
|
placeholder: "Search fields…",
|
|
89
92
|
className: "h-8 w-full rounded-md border border-slate-200 bg-slate-50 pl-8 pr-3 text-[13px] placeholder-slate-400 focus:border-nvr-cyan/50 focus:outline-none focus:ring-2 focus:ring-nvr-cyan/30"
|
|
90
93
|
}
|
|
91
94
|
)
|
|
92
95
|
] }),
|
|
93
96
|
/* @__PURE__ */ c("div", { className: "max-h-72 overflow-y-auto", children: [
|
|
94
|
-
|
|
97
|
+
w.map((t) => /* @__PURE__ */ l(
|
|
95
98
|
P,
|
|
96
99
|
{
|
|
97
100
|
field: t,
|
|
@@ -100,14 +103,14 @@ function V({
|
|
|
100
103
|
pathPrefix: [],
|
|
101
104
|
labelPrefix: [],
|
|
102
105
|
depth: 0,
|
|
103
|
-
walk:
|
|
104
|
-
onSelect: (
|
|
105
|
-
|
|
106
|
+
walk: v,
|
|
107
|
+
onSelect: (d) => {
|
|
108
|
+
a(d), i(!1);
|
|
106
109
|
}
|
|
107
110
|
},
|
|
108
111
|
t.field
|
|
109
112
|
)),
|
|
110
|
-
|
|
113
|
+
w.length === 0 && /* @__PURE__ */ l("div", { className: "px-2 py-3 text-center text-[12px] text-slate-400", children: "No fields" })
|
|
111
114
|
] })
|
|
112
115
|
] })
|
|
113
116
|
}
|
|
@@ -116,70 +119,70 @@ function V({
|
|
|
116
119
|
)
|
|
117
120
|
] });
|
|
118
121
|
}
|
|
119
|
-
function
|
|
122
|
+
function Q({
|
|
120
123
|
relatedCollection: n,
|
|
121
|
-
pathPrefix:
|
|
124
|
+
pathPrefix: f,
|
|
122
125
|
labelPrefix: u,
|
|
123
|
-
onSelect:
|
|
126
|
+
onSelect: r,
|
|
124
127
|
walk: h
|
|
125
128
|
}) {
|
|
126
|
-
const { data:
|
|
127
|
-
if (
|
|
129
|
+
const { data: a, isLoading: p } = q(n);
|
|
130
|
+
if (p)
|
|
128
131
|
return /* @__PURE__ */ c("div", { className: "py-2 text-[12px] text-slate-400 flex items-center gap-2 px-2", children: [
|
|
129
|
-
/* @__PURE__ */ l(
|
|
132
|
+
/* @__PURE__ */ l(R, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
130
133
|
"Loading…"
|
|
131
134
|
] });
|
|
132
|
-
const
|
|
133
|
-
(o,
|
|
134
|
-
),
|
|
135
|
+
const s = [...((a == null ? void 0 : a.fields) ?? []).filter((o) => !o.hidden)].sort(
|
|
136
|
+
(o, i) => o.field.localeCompare(i.field)
|
|
137
|
+
), v = (a == null ? void 0 : a.relations) ?? [];
|
|
135
138
|
return /* @__PURE__ */ c("div", { className: "max-h-64 overflow-y-auto", children: [
|
|
136
|
-
|
|
139
|
+
s.map((o) => /* @__PURE__ */ l(
|
|
137
140
|
P,
|
|
138
141
|
{
|
|
139
142
|
field: o,
|
|
140
143
|
collection: n,
|
|
141
|
-
relations:
|
|
142
|
-
pathPrefix:
|
|
144
|
+
relations: v,
|
|
145
|
+
pathPrefix: f,
|
|
143
146
|
labelPrefix: u,
|
|
144
147
|
depth: 0,
|
|
145
148
|
walk: h,
|
|
146
|
-
onSelect:
|
|
149
|
+
onSelect: r
|
|
147
150
|
},
|
|
148
151
|
o.field
|
|
149
152
|
)),
|
|
150
|
-
|
|
153
|
+
s.length === 0 && /* @__PURE__ */ l("div", { className: "px-2 py-1.5 text-[12px] text-slate-400", children: "No fields" })
|
|
151
154
|
] });
|
|
152
155
|
}
|
|
153
156
|
function P({
|
|
154
157
|
field: n,
|
|
155
|
-
collection:
|
|
158
|
+
collection: f,
|
|
156
159
|
relations: u,
|
|
157
|
-
pathPrefix:
|
|
160
|
+
pathPrefix: r,
|
|
158
161
|
labelPrefix: h,
|
|
159
|
-
depth:
|
|
160
|
-
onSelect:
|
|
161
|
-
walk:
|
|
162
|
+
depth: a,
|
|
163
|
+
onSelect: p,
|
|
164
|
+
walk: s
|
|
162
165
|
}) {
|
|
163
|
-
const [
|
|
164
|
-
(e) => e.many_collection ===
|
|
165
|
-
) ?? null,
|
|
166
|
-
(e) => e.many_collection ===
|
|
167
|
-
) ?? null,
|
|
168
|
-
(e) => e.one_collection ===
|
|
169
|
-
) ?? null : null,
|
|
170
|
-
(e) => e.one_collection ===
|
|
171
|
-
) ?? null : null,
|
|
172
|
-
(e) => e.many_collection ===
|
|
173
|
-
) ?? null : null, L = (
|
|
174
|
-
if (
|
|
175
|
-
const
|
|
176
|
-
return
|
|
166
|
+
const [v, o] = E(!1), i = u.find(
|
|
167
|
+
(e) => e.many_collection === f && e.many_field === n.field && e.junction_field === null && e.one_collection
|
|
168
|
+
) ?? null, x = i ? null : u.find(
|
|
169
|
+
(e) => e.many_collection === f && e.many_field === n.field && e.junction_field !== null && e.one_collection
|
|
170
|
+
) ?? null, m = !i && !x ? u.find(
|
|
171
|
+
(e) => e.one_collection === f && e.one_field === n.field && e.junction_field !== null && e.many_collection
|
|
172
|
+
) ?? null : null, y = x ?? m, b = !i && !y ? u.find(
|
|
173
|
+
(e) => e.one_collection === f && e.one_field === n.field && e.junction_field === null && e.many_collection
|
|
174
|
+
) ?? null : null, g = m ? u.find(
|
|
175
|
+
(e) => e.many_collection === m.many_collection && e.many_field === m.junction_field && e.one_collection
|
|
176
|
+
) ?? null : null, L = (i == null ? void 0 : i.one_collection) ?? (x == null ? void 0 : x.one_collection) ?? (g == null ? void 0 : g.one_collection) ?? (m == null ? void 0 : m.many_collection) ?? (b == null ? void 0 : b.many_collection) ?? null;
|
|
177
|
+
if (s != null && s.m2oOnly && L && !i) return null;
|
|
178
|
+
const w = (s == null ? void 0 : s.maxHops) != null && r.length >= s.maxHops ? null : L, t = i ? "M2O" : y ? "M2M" : b ? "O2M" : null, d = typeof window < "u" && window.innerWidth < 640;
|
|
179
|
+
return w ? /* @__PURE__ */ c(B, { open: v, onOpenChange: o, children: [
|
|
177
180
|
/* @__PURE__ */ l(T, { asChild: !0, children: /* @__PURE__ */ c(
|
|
178
181
|
"button",
|
|
179
182
|
{
|
|
180
183
|
type: "button",
|
|
181
|
-
className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-slate-700 hover:bg-slate-50 data-[state=open]:bg-slate-100",
|
|
182
|
-
style: { paddingLeft: `${0.5 +
|
|
184
|
+
className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-slate-700 hover:bg-slate-50 data-[state=open]:bg-slate-100 dark:data-[state=open]:bg-muted",
|
|
185
|
+
style: { paddingLeft: `${0.5 + a * 1}rem` },
|
|
183
186
|
children: [
|
|
184
187
|
/* @__PURE__ */ l("span", { className: "flex-1", children: _(n.field) }),
|
|
185
188
|
t && /* @__PURE__ */ l("span", { className: "rounded px-1 py-0.5 text-[10px] font-medium bg-slate-100 text-slate-500", children: t }),
|
|
@@ -187,48 +190,58 @@ function P({
|
|
|
187
190
|
]
|
|
188
191
|
}
|
|
189
192
|
) }),
|
|
190
|
-
/* @__PURE__ */ c(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
193
|
+
/* @__PURE__ */ c(
|
|
194
|
+
W,
|
|
195
|
+
{
|
|
196
|
+
side: d ? "bottom" : "right",
|
|
197
|
+
align: d ? "end" : "start",
|
|
198
|
+
sideOffset: 4,
|
|
199
|
+
collisionPadding: 8,
|
|
200
|
+
className: "w-56 p-1",
|
|
201
|
+
children: [
|
|
202
|
+
(i || y) && /* @__PURE__ */ l(
|
|
203
|
+
"button",
|
|
204
|
+
{
|
|
205
|
+
type: "button",
|
|
206
|
+
onClick: () => {
|
|
207
|
+
p({
|
|
208
|
+
path: [...r, n.field],
|
|
209
|
+
pathLabels: [...h, _(n.field)],
|
|
210
|
+
fieldType: n.type,
|
|
211
|
+
relatedCollection: w ?? void 0
|
|
212
|
+
}), o(!1);
|
|
213
|
+
},
|
|
214
|
+
className: "w-full rounded-md px-2 py-1 text-left text-[12px] text-slate-500 hover:bg-slate-50 italic",
|
|
215
|
+
children: "(select this field)"
|
|
216
|
+
}
|
|
217
|
+
),
|
|
218
|
+
/* @__PURE__ */ l(
|
|
219
|
+
Q,
|
|
220
|
+
{
|
|
221
|
+
relatedCollection: w,
|
|
222
|
+
pathPrefix: [...r, n.field],
|
|
223
|
+
labelPrefix: [...h, _(n.field)],
|
|
224
|
+
walk: s,
|
|
225
|
+
onSelect: (e) => {
|
|
226
|
+
p(e), o(!1);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
)
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
)
|
|
220
233
|
] }) : /* @__PURE__ */ l(
|
|
221
234
|
"button",
|
|
222
235
|
{
|
|
223
236
|
type: "button",
|
|
224
|
-
onClick: () =>
|
|
225
|
-
path: [...
|
|
237
|
+
onClick: () => p({
|
|
238
|
+
path: [...r, n.field],
|
|
226
239
|
pathLabels: [...h, _(n.field)],
|
|
227
240
|
fieldType: n.type,
|
|
228
|
-
relatedCollection:
|
|
241
|
+
relatedCollection: a > 0 ? f : void 0
|
|
229
242
|
}),
|
|
230
243
|
className: "w-full rounded-md px-2 py-1.5 text-left text-[13px] text-slate-700 hover:bg-slate-50",
|
|
231
|
-
style: { paddingLeft: `${0.5 +
|
|
244
|
+
style: { paddingLeft: `${0.5 + a * 1}rem` },
|
|
232
245
|
children: _(n.field)
|
|
233
246
|
}
|
|
234
247
|
);
|