@nivaro/react 0.3.108 → 0.3.110
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/index.d.ts +3 -0
- package/dist/layout-editor.d.ts +4 -0
- package/dist/shared/components/ItemEditForm.js +1750 -1733
- package/dist/shared/components/imports/CollectionImportPanel.js +631 -595
- package/dist/shared/components/imports/import-picker-options.js +44 -0
- package/dist/shared/components/item-edit/GroupSection.js +30 -29
- package/dist/shared/components/item-edit/InlineTableField.js +441 -438
- package/dist/shared/components/item-edit/NestedRelationEditor.js +36 -36
- package/dist/shared/components/item-edit/RelationCombobox.js +1 -1
- package/dist/shared/components/item-edit/StepsBar.js +24 -23
- package/dist/shared/components/item-edit/form-density.js +1 -0
- package/dist/shared/components/item-edit/section-rows.js +39 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +88 -66
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/lib/activity-sentence.js +4 -4
- package/dist/shared/lib/layout-ops.js +24 -22
- package/package.json +1 -1
|
@@ -16,25 +16,25 @@ const We = /* @__PURE__ */ new Set([
|
|
|
16
16
|
"group",
|
|
17
17
|
"divider"
|
|
18
18
|
]), ze = /* @__PURE__ */ new Set(["__apply_values__", "__create_with_defaults__"]);
|
|
19
|
-
function Be(
|
|
20
|
-
return
|
|
19
|
+
function Be(o, s) {
|
|
20
|
+
return o === s || o == null && s == null ? !0 : o == null || s == null ? !1 : typeof o == "string" && typeof s == "number" || typeof o == "number" && typeof s == "string" ? String(o) === String(s) : JSON.stringify(o) === JSON.stringify(s);
|
|
21
21
|
}
|
|
22
|
-
function xe(
|
|
22
|
+
function xe(o) {
|
|
23
23
|
var x;
|
|
24
|
-
const s =
|
|
24
|
+
const s = o == null ? void 0 : o.response;
|
|
25
25
|
if ((x = s == null ? void 0 : s.violations) != null && x.length) {
|
|
26
26
|
const g = s.violations.map((b) => b.explanation).filter(Boolean).join("; ");
|
|
27
27
|
if (g) return g;
|
|
28
28
|
}
|
|
29
|
-
return s != null && s.message ? s.message : s != null && s.error ? s.error :
|
|
29
|
+
return s != null && s.message ? s.message : s != null && s.error ? s.error : o instanceof Error && o.message ? o.message : "Save failed";
|
|
30
30
|
}
|
|
31
|
-
function Ge(
|
|
32
|
-
if (!Number.isFinite(
|
|
33
|
-
const s = Math.round((
|
|
31
|
+
function Ge(o) {
|
|
32
|
+
if (!Number.isFinite(o)) return o;
|
|
33
|
+
const s = Math.round((o + Math.sign(o) * Number.EPSILON) * 100) / 100;
|
|
34
34
|
return Object.is(s, -0) ? 0 : s;
|
|
35
35
|
}
|
|
36
36
|
function rt({
|
|
37
|
-
parentCollection:
|
|
37
|
+
parentCollection: o,
|
|
38
38
|
relationField: s,
|
|
39
39
|
parentRowId: x,
|
|
40
40
|
stagedMembers: g,
|
|
@@ -53,19 +53,19 @@ function rt({
|
|
|
53
53
|
}) {
|
|
54
54
|
var de, ue;
|
|
55
55
|
const y = Se(), te = Le(), { data: J, isLoading: ye } = j({
|
|
56
|
-
queryKey: ["collection-
|
|
57
|
-
queryFn: () => y.request(L(`/collections/${
|
|
56
|
+
queryKey: ["collection-relations", o],
|
|
57
|
+
queryFn: () => y.request(L(`/collections/${o}`)).then((e) => {
|
|
58
58
|
const t = e.data;
|
|
59
59
|
return (t == null ? void 0 : t.relations) ?? [];
|
|
60
60
|
}),
|
|
61
61
|
staleTime: 10 * 6e4
|
|
62
62
|
}), P = k(
|
|
63
63
|
() => J == null ? void 0 : J.find(
|
|
64
|
-
(e) => e.one_collection ===
|
|
64
|
+
(e) => e.one_collection === o && e.one_field === s
|
|
65
65
|
),
|
|
66
|
-
[J,
|
|
66
|
+
[J, o, s]
|
|
67
67
|
), d = m ?? (P == null ? void 0 : P.many_collection) ?? null, q = m ? null : (P == null ? void 0 : P.many_field) ?? null, { data: Y = [] } = j({
|
|
68
|
-
queryKey: ["collection-
|
|
68
|
+
queryKey: ["collection-relations", d],
|
|
69
69
|
queryFn: () => y.request(L(`/collections/${d}`)).then((e) => {
|
|
70
70
|
const t = e.data;
|
|
71
71
|
return (t == null ? void 0 : t.relations) ?? [];
|
|
@@ -97,10 +97,10 @@ function rt({
|
|
|
97
97
|
}), N = k(() => {
|
|
98
98
|
if (x != null) {
|
|
99
99
|
if (T) {
|
|
100
|
-
const e = S ?? C, t = new Set(e.deleted), r = new Map(e.updated.map((
|
|
101
|
-
const u = r.get(String(
|
|
102
|
-
return { key: String(
|
|
103
|
-
}), i = e.created.map((
|
|
100
|
+
const e = S ?? C, t = new Set(e.deleted), r = new Map(e.updated.map((a) => [a.id, a.changes])), l = I.filter((a) => !t.has(String(a.id))).map((a) => {
|
|
101
|
+
const u = r.get(String(a.id));
|
|
102
|
+
return { key: String(a.id), data: u ? { ...a, ...u } : a };
|
|
103
|
+
}), i = e.created.map((a, u) => ({ key: `created:${u}`, data: a }));
|
|
104
104
|
return [...l, ...i];
|
|
105
105
|
}
|
|
106
106
|
return I.map((e) => ({ key: String(e.id), data: e }));
|
|
@@ -125,22 +125,22 @@ function rt({
|
|
|
125
125
|
function D() {
|
|
126
126
|
X(null), U({}), _(null);
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function oe() {
|
|
129
129
|
te.invalidateQueries({ queryKey: re }), ee && te.invalidateQueries({ queryKey: ee });
|
|
130
130
|
}
|
|
131
|
-
async function
|
|
131
|
+
async function ae() {
|
|
132
132
|
if (!c) return;
|
|
133
133
|
if (x != null && d && (q || m)) {
|
|
134
134
|
const t = new Set(E.map((l) => l.field)), r = Object.fromEntries(
|
|
135
135
|
Object.entries(h).filter(([l]) => t.has(l))
|
|
136
136
|
);
|
|
137
137
|
if (T) {
|
|
138
|
-
const l = S ?? C, i = m ? { ...l, collection: m } : l,
|
|
138
|
+
const l = S ?? C, i = m ? { ...l, collection: m } : l, a = m ? { ...r, ...A ?? {} } : r;
|
|
139
139
|
if (c === "new")
|
|
140
|
-
f == null || f({ ...i, created: [...i.created,
|
|
140
|
+
f == null || f({ ...i, created: [...i.created, a] });
|
|
141
141
|
else if (c.startsWith("created:")) {
|
|
142
142
|
const u = parseInt(c.slice(8), 10), K = [...i.created];
|
|
143
|
-
K[u] =
|
|
143
|
+
K[u] = a, f == null || f({ ...i, created: K });
|
|
144
144
|
} else {
|
|
145
145
|
const u = I.find(($) => String($.id) === c), K = Object.fromEntries(
|
|
146
146
|
Object.entries(r).filter(([$, De]) => !Be(De, u == null ? void 0 : u[$]))
|
|
@@ -157,7 +157,7 @@ function rt({
|
|
|
157
157
|
...r,
|
|
158
158
|
...m ? A ?? {} : { [q]: x }
|
|
159
159
|
})
|
|
160
|
-
) : await y.request(Ae(`/items/${d}/${c}`, r)),
|
|
160
|
+
) : await y.request(Ae(`/items/${d}/${c}`, r)), oe(), D();
|
|
161
161
|
} catch (l) {
|
|
162
162
|
_(xe(l));
|
|
163
163
|
} finally {
|
|
@@ -180,7 +180,7 @@ function rt({
|
|
|
180
180
|
const t = S ?? C, r = m ? { ...t, collection: m } : t;
|
|
181
181
|
if (e.startsWith("created:")) {
|
|
182
182
|
const l = parseInt(e.slice(8), 10);
|
|
183
|
-
f == null || f({ ...r, created: r.created.filter((i,
|
|
183
|
+
f == null || f({ ...r, created: r.created.filter((i, a) => a !== l) });
|
|
184
184
|
} else
|
|
185
185
|
f == null || f({
|
|
186
186
|
...r,
|
|
@@ -189,7 +189,7 @@ function rt({
|
|
|
189
189
|
});
|
|
190
190
|
} else
|
|
191
191
|
try {
|
|
192
|
-
await y.request(Je(`/items/${d}/${e}`)),
|
|
192
|
+
await y.request(Je(`/items/${d}/${e}`)), oe();
|
|
193
193
|
} catch (t) {
|
|
194
194
|
_(xe(t));
|
|
195
195
|
return;
|
|
@@ -213,9 +213,9 @@ function rt({
|
|
|
213
213
|
const e = /* @__PURE__ */ new Map();
|
|
214
214
|
for (const { key: t, data: r } of N) {
|
|
215
215
|
const l = c === t ? h : r;
|
|
216
|
-
for (const [i,
|
|
216
|
+
for (const [i, a] of R) {
|
|
217
217
|
const u = l[i];
|
|
218
|
-
u == null || u === "" || !
|
|
218
|
+
u == null || u === "" || !a.one_collection || (e.has(a.one_collection) || e.set(a.one_collection, /* @__PURE__ */ new Set()), e.get(a.one_collection).add(String(u)));
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
return e;
|
|
@@ -229,7 +229,7 @@ function rt({
|
|
|
229
229
|
const e = {};
|
|
230
230
|
return await Promise.all(
|
|
231
231
|
[...Z.entries()].map(async ([t, r]) => {
|
|
232
|
-
var
|
|
232
|
+
var a;
|
|
233
233
|
const [l, i] = await Promise.all([
|
|
234
234
|
y.request(
|
|
235
235
|
L(`/collections/${t}`)
|
|
@@ -244,7 +244,7 @@ function rt({
|
|
|
244
244
|
e[t] = {};
|
|
245
245
|
for (const u of i.data ?? [])
|
|
246
246
|
e[t][String(u.id)] = Ue(
|
|
247
|
-
(
|
|
247
|
+
(a = l.data) == null ? void 0 : a.display_template,
|
|
248
248
|
u
|
|
249
249
|
);
|
|
250
250
|
})
|
|
@@ -335,7 +335,7 @@ function rt({
|
|
|
335
335
|
{
|
|
336
336
|
field: i,
|
|
337
337
|
value: h[i.field] ?? null,
|
|
338
|
-
onChange: (
|
|
338
|
+
onChange: (a) => se(i.field, a),
|
|
339
339
|
relations: Y,
|
|
340
340
|
collection: d,
|
|
341
341
|
itemId: x != null ? e : "new"
|
|
@@ -348,7 +348,7 @@ function rt({
|
|
|
348
348
|
type: "button",
|
|
349
349
|
disabled: W,
|
|
350
350
|
onClick: (i) => {
|
|
351
|
-
i.stopPropagation(),
|
|
351
|
+
i.stopPropagation(), ae();
|
|
352
352
|
},
|
|
353
353
|
className: "rounded px-2 h-7 bg-nvr-cyan text-white text-[10px] font-medium hover:brightness-110 disabled:opacity-50",
|
|
354
354
|
children: W ? "…" : "Save"
|
|
@@ -437,7 +437,7 @@ function rt({
|
|
|
437
437
|
{
|
|
438
438
|
type: "button",
|
|
439
439
|
disabled: W,
|
|
440
|
-
onClick:
|
|
440
|
+
onClick: ae,
|
|
441
441
|
className: "rounded px-2 h-7 bg-nvr-cyan text-white text-[10px] font-medium hover:brightness-110 disabled:opacity-50",
|
|
442
442
|
children: W ? "…" : "Add"
|
|
443
443
|
}
|
|
@@ -475,9 +475,9 @@ function rt({
|
|
|
475
475
|
) })
|
|
476
476
|
] });
|
|
477
477
|
}
|
|
478
|
-
function Qe(
|
|
479
|
-
return s ?
|
|
480
|
-
minimumFractionDigits: Number.isInteger(
|
|
478
|
+
function Qe(o, s) {
|
|
479
|
+
return s ? o.toLocaleString("en-US", { style: "currency", currency: "USD" }) : o.toLocaleString("en-US", {
|
|
480
|
+
minimumFractionDigits: Number.isInteger(o) ? 0 : 2,
|
|
481
481
|
maximumFractionDigits: 2
|
|
482
482
|
});
|
|
483
483
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as o, jsxs as
|
|
1
|
+
import { jsx as o, jsxs as y } from "react/jsx-runtime";
|
|
2
2
|
import { Check as N } from "lucide-react";
|
|
3
3
|
import { cn as c } from "../../lib/utils.js";
|
|
4
4
|
import { useDesignWrap as R } from "../layout-editor/DesignNode.js";
|
|
5
|
-
import { useLayoutDesign as
|
|
6
|
-
const g = 10,
|
|
5
|
+
import { useLayoutDesign as W } from "../layout-editor/design-context.js";
|
|
6
|
+
const g = 10, C = 2, p = 12;
|
|
7
7
|
function D(t, n, e, r) {
|
|
8
8
|
return t === n ? "active" : r != null && r.has(t) ? "error" : e.has(t) ? "done" : "inactive";
|
|
9
9
|
}
|
|
@@ -14,7 +14,7 @@ function P(t, n) {
|
|
|
14
14
|
}
|
|
15
15
|
function j(t, n) {
|
|
16
16
|
if (t && n) return "none";
|
|
17
|
-
const e = g, r =
|
|
17
|
+
const e = g, r = C;
|
|
18
18
|
return n ? `polygon(0 0, 100% 0, 100% 100%, 0 100%, ${e}px 50%)` : t ? `polygon(0 0, calc(100% - ${e + r}px) 0, calc(100% - ${r}px) 50%, calc(100% - ${e + r}px) 100%, 0 100%)` : `polygon(0 0, calc(100% - ${e + r}px) 0, calc(100% - ${r}px) 50%, calc(100% - ${e + r}px) 100%, 0 100%, ${e}px 50%)`;
|
|
19
19
|
}
|
|
20
20
|
function E(t, n) {
|
|
@@ -28,29 +28,30 @@ function H({
|
|
|
28
28
|
completed: e,
|
|
29
29
|
errorSteps: r,
|
|
30
30
|
dirtySteps: f,
|
|
31
|
-
onStepClick:
|
|
32
|
-
embedded:
|
|
31
|
+
onStepClick: $,
|
|
32
|
+
embedded: _ = !1,
|
|
33
33
|
hiddenSteps: i
|
|
34
34
|
}) {
|
|
35
|
-
const w = R(),
|
|
35
|
+
const w = R(), k = W() != null;
|
|
36
36
|
return /* @__PURE__ */ o(
|
|
37
37
|
"div",
|
|
38
38
|
{
|
|
39
39
|
className: c(
|
|
40
40
|
"relative flex h-9",
|
|
41
|
-
|
|
41
|
+
_ ? "border-b border-slate-200 dark:border-border" : "rounded-lg shadow-[0_0_0_1px_#e2e8f0,0_1px_3px_-1px_rgba(0,0,0,0.06)] dark:shadow-none dark:border dark:border-border"
|
|
42
42
|
),
|
|
43
43
|
children: t.map((a, d) => {
|
|
44
|
-
const
|
|
44
|
+
const l = d === 0, u = d === t.length - 1, b = D(a.key, n, e, r), s = b === "active", v = b === "done", x = b === "error", h = E(l, u), m = /* @__PURE__ */ y(
|
|
45
45
|
"div",
|
|
46
46
|
{
|
|
47
|
-
"data-design-tab":
|
|
47
|
+
"data-design-tab": k ? "" : void 0,
|
|
48
|
+
"data-design-pass": k && a.key.startsWith("__") ? "" : void 0,
|
|
48
49
|
"data-design-hidden": i != null && i.has(a.key) ? "" : void 0,
|
|
49
50
|
className: c("relative min-w-0 flex-1", (i == null ? void 0 : i.has(a.key)) && "opacity-40"),
|
|
50
51
|
style: {
|
|
51
|
-
clipPath: P(
|
|
52
|
+
clipPath: P(l, u),
|
|
52
53
|
zIndex: t.length - d,
|
|
53
|
-
marginLeft:
|
|
54
|
+
marginLeft: l ? 0 : -g,
|
|
54
55
|
// overflow + translateZ: promotes wrapper to compositing layer so
|
|
55
56
|
// Chrome properly clips clip-path'd children to border-radius
|
|
56
57
|
overflow: "hidden",
|
|
@@ -65,30 +66,30 @@ function H({
|
|
|
65
66
|
style: { borderRadius: h }
|
|
66
67
|
}
|
|
67
68
|
),
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
+
/* @__PURE__ */ y(
|
|
69
70
|
"button",
|
|
70
71
|
{
|
|
71
72
|
type: "button",
|
|
72
|
-
onClick: () =>
|
|
73
|
+
onClick: () => $(a.key),
|
|
73
74
|
style: {
|
|
74
|
-
clipPath: j(
|
|
75
|
-
paddingLeft:
|
|
75
|
+
clipPath: j(l, u),
|
|
76
|
+
paddingLeft: l ? 12 : 12 + g,
|
|
76
77
|
paddingRight: 12,
|
|
77
78
|
borderRadius: h
|
|
78
79
|
},
|
|
79
80
|
className: c(
|
|
80
81
|
"group absolute inset-0 flex items-center gap-2 py-0 text-left transition-colors duration-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-nvr-cyan",
|
|
81
|
-
|
|
82
|
+
s ? "bg-[#172940] dark:bg-nvr-cyan/[0.1]" : x ? "bg-[#fef2f2] hover:bg-red-100/60 dark:bg-red-500/[0.05] dark:hover:bg-red-500/[0.08]" : "bg-[#f1f5f9] hover:bg-slate-200/70 dark:bg-[#1e293b] dark:hover:bg-white/[0.04]"
|
|
82
83
|
),
|
|
83
84
|
children: [
|
|
84
|
-
|
|
85
|
+
s && /* @__PURE__ */ o("span", { className: "pointer-events-none absolute inset-x-0 top-0 h-[2px] bg-nvr-cyan" }),
|
|
85
86
|
/* @__PURE__ */ o(
|
|
86
87
|
"span",
|
|
87
88
|
{
|
|
88
89
|
className: c(
|
|
89
90
|
"flex h-[15px] w-[15px] shrink-0 items-center justify-center rounded-full text-[9px] font-bold leading-none transition-colors duration-100",
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
s && "nvr-state-pulse",
|
|
92
|
+
s || v ? "bg-nvr-cyan text-[#172940]" : x ? "bg-red-500 text-white" : "bg-slate-300 text-slate-500 dark:bg-white/[0.12] dark:text-slate-400"
|
|
92
93
|
),
|
|
93
94
|
children: v ? /* @__PURE__ */ o(N, { className: "nvr-pop h-[7px] w-[7px]", strokeWidth: 3 }) : x ? "!" : d + 1
|
|
94
95
|
}
|
|
@@ -98,12 +99,12 @@ function H({
|
|
|
98
99
|
{
|
|
99
100
|
className: c(
|
|
100
101
|
"min-w-0 truncate text-[11px] font-semibold leading-none transition-colors duration-100",
|
|
101
|
-
|
|
102
|
+
s ? "text-white dark:text-nvr-cyan" : v ? "text-slate-400 dark:text-slate-500" : x ? "text-red-600 dark:text-red-400" : "text-slate-400 group-hover:text-slate-600 dark:text-slate-500 dark:group-hover:text-slate-300"
|
|
102
103
|
),
|
|
103
104
|
children: a.label
|
|
104
105
|
}
|
|
105
106
|
),
|
|
106
|
-
(f == null ? void 0 : f.has(a.key)) && !
|
|
107
|
+
(f == null ? void 0 : f.has(a.key)) && !s && /* @__PURE__ */ o(
|
|
107
108
|
"span",
|
|
108
109
|
{
|
|
109
110
|
className: "h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400",
|
|
@@ -117,7 +118,7 @@ function H({
|
|
|
117
118
|
},
|
|
118
119
|
a.key
|
|
119
120
|
);
|
|
120
|
-
return a.key.startsWith("__") ?
|
|
121
|
+
return a.key.startsWith("__") ? m : w({ kind: "group", key: a.key }, m, { asChild: !0, pass: !0 });
|
|
121
122
|
})
|
|
122
123
|
}
|
|
123
124
|
);
|
|
@@ -5,6 +5,7 @@ function m(t) {
|
|
|
5
5
|
const e = "[data-form-density=compact]", o = `
|
|
6
6
|
${e} [data-form-body]{padding:1rem 1.25rem}
|
|
7
7
|
${e} [data-form-body]>:not([hidden])~:not([hidden]),${e} [data-section-stack]>:not([hidden])~:not([hidden]){margin-top:.625rem}
|
|
8
|
+
${e} [data-form-row]{gap:.625rem}
|
|
8
9
|
${e} [data-usage-header]{padding-top:.5rem;padding-bottom:.5rem}
|
|
9
10
|
${e} [data-section-body]{padding:.625rem 1rem .75rem}
|
|
10
11
|
${e} [data-section-grid]{row-gap:.625rem;column-gap:.875rem}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useState as u, useLayoutEffect as c } from "react";
|
|
2
|
+
const f = 720;
|
|
3
|
+
function p(t) {
|
|
4
|
+
if (!t || typeof t != "object") return !1;
|
|
5
|
+
const e = t;
|
|
6
|
+
return (e.type === "section" || e.type === "metadata") && !e.container_id && e.form_width === "half";
|
|
7
|
+
}
|
|
8
|
+
function a(t, e) {
|
|
9
|
+
const i = [];
|
|
10
|
+
let n = null;
|
|
11
|
+
for (const o of t) {
|
|
12
|
+
if (!e(o)) {
|
|
13
|
+
n = null, i.push({ kind: "full", item: o });
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (n && n.length < 2) {
|
|
17
|
+
n.push(o);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
n = [o], i.push({ kind: "pair", items: n });
|
|
21
|
+
}
|
|
22
|
+
return i;
|
|
23
|
+
}
|
|
24
|
+
function h(t, e) {
|
|
25
|
+
const [i, n] = u(!1);
|
|
26
|
+
return c(() => {
|
|
27
|
+
if (!t || !e) return;
|
|
28
|
+
const o = (r) => n(r >= f);
|
|
29
|
+
if (o(t.getBoundingClientRect().width), typeof ResizeObserver > "u") return;
|
|
30
|
+
const s = new ResizeObserver(([r]) => o(r.contentRect.width));
|
|
31
|
+
return s.observe(t), () => s.disconnect();
|
|
32
|
+
}, [t, e]), e && i;
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
f as FORM_PAIR_MIN_PX,
|
|
36
|
+
p as isHalfSection,
|
|
37
|
+
a as sectionRows,
|
|
38
|
+
h as useFormPairs
|
|
39
|
+
};
|