@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
|
@@ -441,10 +441,10 @@ function ee(e) {
|
|
|
441
441
|
return `${/^[aeiou]/i.test(e) ? "an" : "a"} ${e}`;
|
|
442
442
|
}
|
|
443
443
|
function ne(e, n) {
|
|
444
|
-
const t =
|
|
445
|
-
if (!i(e.parent_id)) return
|
|
446
|
-
const
|
|
447
|
-
return !
|
|
444
|
+
const t = _(b(e.parent_collection, n).singular), r = `${/^[aeiou]/i.test(t) ? "an" : "a"} ${t} record`;
|
|
445
|
+
if (!i(e.parent_id)) return r;
|
|
446
|
+
const o = I(e.parent_collection, e.parent_id, n);
|
|
447
|
+
return !o || o === w ? r : o;
|
|
448
448
|
}
|
|
449
449
|
function D(e) {
|
|
450
450
|
const n = i(e.value);
|
|
@@ -31,6 +31,7 @@ const R = [
|
|
|
31
31
|
"hidden_for_roles",
|
|
32
32
|
"locked_for_roles",
|
|
33
33
|
"read_width",
|
|
34
|
+
"form_width",
|
|
34
35
|
"editor_note",
|
|
35
36
|
"i18n"
|
|
36
37
|
], Y = [
|
|
@@ -155,7 +156,8 @@ function H(t, e, s, o) {
|
|
|
155
156
|
visible_when: null,
|
|
156
157
|
hidden_for_roles: null,
|
|
157
158
|
locked_for_roles: null,
|
|
158
|
-
read_width: null
|
|
159
|
+
read_width: null,
|
|
160
|
+
form_width: null
|
|
159
161
|
};
|
|
160
162
|
}
|
|
161
163
|
const g = (t, e) => t < e ? -1 : t > e ? 1 : 0, h = (t, e) => (t.id ?? Number.MAX_SAFE_INTEGER) - (e.id ?? Number.MAX_SAFE_INTEGER);
|
|
@@ -175,11 +177,11 @@ function p(t, e) {
|
|
|
175
177
|
}
|
|
176
178
|
function u(t, e) {
|
|
177
179
|
const s = [];
|
|
178
|
-
return t.groups.forEach((o,
|
|
179
|
-
o.parent_key === e && s.push({ m: o, tie: P(o.key), i:
|
|
180
|
-
}), e === null && t.placements.forEach((o,
|
|
181
|
-
f(o) && s.push({ m: o, tie: P(o.field), i: t.groups.length +
|
|
182
|
-
}), s.sort((o,
|
|
180
|
+
return t.groups.forEach((o, _) => {
|
|
181
|
+
o.parent_key === e && s.push({ m: o, tie: P(o.key), i: _ });
|
|
182
|
+
}), e === null && t.placements.forEach((o, _) => {
|
|
183
|
+
f(o) && s.push({ m: o, tie: P(o.field), i: t.groups.length + _ });
|
|
184
|
+
}), s.sort((o, _) => o.m.sort - _.m.sort || o.tie - _.tie || h(o.m, _.m) || o.i - _.i).map((o) => o.m);
|
|
183
185
|
}
|
|
184
186
|
function c(t) {
|
|
185
187
|
t.forEach((e, s) => {
|
|
@@ -201,8 +203,8 @@ function J(t, e) {
|
|
|
201
203
|
placements: t.placements.map((o) => ({ ...o }))
|
|
202
204
|
};
|
|
203
205
|
if (!Array.isArray(e)) throw new N("ops must be an array", 0);
|
|
204
|
-
return e.forEach((o,
|
|
205
|
-
B(s, o,
|
|
206
|
+
return e.forEach((o, _) => {
|
|
207
|
+
B(s, o, _), V(s);
|
|
206
208
|
}), K({ ...s, rev: t.rev });
|
|
207
209
|
}
|
|
208
210
|
function B(t, e, s) {
|
|
@@ -210,10 +212,10 @@ function B(t, e, s) {
|
|
|
210
212
|
throw new N(n, s);
|
|
211
213
|
};
|
|
212
214
|
(!e || typeof e != "object") && o("Each op must be an object");
|
|
213
|
-
const
|
|
215
|
+
const _ = (n, r, i) => {
|
|
214
216
|
(typeof i != "number" || !Number.isFinite(i)) && o("index must be a number");
|
|
215
|
-
const
|
|
216
|
-
return [...n.slice(0,
|
|
217
|
+
const l = Math.max(0, Math.min(n.length, Math.floor(i)));
|
|
218
|
+
return [...n.slice(0, l), r, ...n.slice(l)];
|
|
217
219
|
}, y = (n, r) => {
|
|
218
220
|
if (n == null) return {};
|
|
219
221
|
(typeof n != "object" || Array.isArray(n)) && o("patch must be an object");
|
|
@@ -222,13 +224,13 @@ function B(t, e, s) {
|
|
|
222
224
|
return n;
|
|
223
225
|
}, A = (n) => {
|
|
224
226
|
const r = y(n, L);
|
|
225
|
-
return r.type !== void 0 && !m.includes(r.type) && o(`Group type must be one of ${m.join(", ")}`), r.read_width != null && !["full", "half", "third"].includes(r.read_width) && o("read_width must be 'full', 'half', 'third' or null"), r.editor_note != null && (typeof r.editor_note != "string" || r.editor_note.length > 4e3) && o("A note must be text of at most 4000 characters"), r;
|
|
227
|
+
return r.type !== void 0 && !m.includes(r.type) && o(`Group type must be one of ${m.join(", ")}`), r.read_width != null && !["full", "half", "third"].includes(r.read_width) && o("read_width must be 'full', 'half', 'third' or null"), r.form_width != null && !["full", "half"].includes(r.form_width) && o("form_width must be 'full', 'half' or null"), r.editor_note != null && (typeof r.editor_note != "string" || r.editor_note.length > 4e3) && o("A note must be text of at most 4000 characters"), r;
|
|
226
228
|
}, k = (n) => {
|
|
227
229
|
(!n || typeof n.field != "string") && o("A placement needs a field");
|
|
228
230
|
const r = n;
|
|
229
231
|
M.includes(r.field) && o(`"${r.field}" is a reserved name`);
|
|
230
232
|
const i = t.placements.find(
|
|
231
|
-
(
|
|
233
|
+
(l) => l.field === r.field && l.group_key === (r.group_key ?? null)
|
|
232
234
|
);
|
|
233
235
|
return i || o(`"${r.field}" is not placed in ${r.group_key ?? "Ungrouped"}`), i;
|
|
234
236
|
}, b = (n) => {
|
|
@@ -241,11 +243,11 @@ function B(t, e, s) {
|
|
|
241
243
|
(!r || r.key === d) && o(`No group "${n}"`), r.type === "container" && o("Fields go in the tabs of a container"), r.type === "content" && o("A text block holds text, not fields");
|
|
242
244
|
}, T = (n, r) => {
|
|
243
245
|
if (n === null) return;
|
|
244
|
-
const i = t.groups.find((
|
|
246
|
+
const i = t.groups.find((l) => l.key === n);
|
|
245
247
|
(i == null ? void 0 : i.type) !== "container" && o(`"${n}" is not a container`), r !== "tab" && o("Only tabs go inside a container");
|
|
246
248
|
}, S = (n, r) => {
|
|
247
|
-
const i = f(n) ? u(t, null).filter((
|
|
248
|
-
c(
|
|
249
|
+
const i = f(n) ? u(t, null).filter((l) => l !== n) : p(t, n.group_key).filter((l) => l !== n);
|
|
250
|
+
c(_(i, n, r));
|
|
249
251
|
};
|
|
250
252
|
switch (e.op) {
|
|
251
253
|
case "place": {
|
|
@@ -280,8 +282,8 @@ function B(t, e, s) {
|
|
|
280
282
|
m.includes(r) || o(`Group type must be one of ${m.join(", ")}`);
|
|
281
283
|
const i = e.parent_key ?? null;
|
|
282
284
|
T(i, r);
|
|
283
|
-
const
|
|
284
|
-
t.groups.push(
|
|
285
|
+
const l = { ...H(e.key, e.label, r, i), ...n }, w = u(t, i);
|
|
286
|
+
t.groups.push(l), c(_(w, l, e.index));
|
|
285
287
|
return;
|
|
286
288
|
}
|
|
287
289
|
case "group_update": {
|
|
@@ -294,14 +296,14 @@ function B(t, e, s) {
|
|
|
294
296
|
let r;
|
|
295
297
|
if (e.key === d || f({ field: e.key, group_key: null })) {
|
|
296
298
|
n !== null && o("This stays at the top level of the form");
|
|
297
|
-
const i = e.key === d ? t.groups.find((
|
|
299
|
+
const i = e.key === d ? t.groups.find((l) => l.key === d) : t.placements.find((l) => l.field === e.key && l.group_key === null);
|
|
298
300
|
i || o(`"${e.key}" is not on this form`), r = i;
|
|
299
301
|
} else {
|
|
300
302
|
const i = b(e.key);
|
|
301
303
|
T(n, i.type), i.parent_key = n, r = i;
|
|
302
304
|
}
|
|
303
305
|
c(
|
|
304
|
-
|
|
306
|
+
_(
|
|
305
307
|
u(t, n).filter((i) => i !== r),
|
|
306
308
|
r,
|
|
307
309
|
e.index
|
|
@@ -314,8 +316,8 @@ function B(t, e, s) {
|
|
|
314
316
|
e.placements !== "ungroup" && e.placements !== "delete" && o("placements must be 'ungroup' or 'delete'");
|
|
315
317
|
const r = u(t, n.parent_key), i = u(t, n.key);
|
|
316
318
|
for (const a of i) a.parent_key = n.parent_key;
|
|
317
|
-
const
|
|
318
|
-
c([...r.slice(0,
|
|
319
|
+
const l = r.indexOf(n);
|
|
320
|
+
c([...r.slice(0, l), ...i, ...r.slice(l + 1)]), t.groups = t.groups.filter((a) => a !== n);
|
|
319
321
|
const w = p(t, n.key);
|
|
320
322
|
if (t.placements = t.placements.filter((a) => a.group_key !== n.key), e.placements === "delete") return;
|
|
321
323
|
const v = p(t, null), U = u(t, null), E = w.filter(
|