@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
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const p = (n) => n.replace(/_/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (i) => i.toUpperCase()), h = /^(nivaro_|directus_)/i, d = (n) => (n.display_name || n.plural || "").trim() || p(n.collection);
|
|
2
|
+
function _(n, i = /* @__PURE__ */ new Set(), t = "") {
|
|
3
|
+
const l = n.filter((e) => (e == null ? void 0 : e.collection) && !h.test(e.collection)), r = new Set(l.map((e) => e.group).filter((e) => !!e)), s = new Map(
|
|
4
|
+
l.filter((e) => r.has(e.collection)).map((e) => [e.collection, e])
|
|
5
|
+
), f = (e) => e.collection === t || !r.has(e.collection) && !e.hidden && !e.singleton && !i.has(e.collection), a = (e) => e && r.has(e) ? d(s.get(e) ?? { collection: e }) : "Other", c = (e) => {
|
|
6
|
+
var o;
|
|
7
|
+
return ((o = s.get(e)) == null ? void 0 : o.sort) ?? 9999;
|
|
8
|
+
}, g = [...r].sort(
|
|
9
|
+
(e, o) => c(e) - c(o) || a(e).localeCompare(a(o))
|
|
10
|
+
), u = new Map(g.map((e, o) => [e, o]));
|
|
11
|
+
return l.filter(f).map((e) => ({
|
|
12
|
+
value: e.collection,
|
|
13
|
+
label: d(e),
|
|
14
|
+
hint: e.collection,
|
|
15
|
+
group: a(e.group),
|
|
16
|
+
_rank: e.group && u.has(e.group) ? u.get(e.group) : 1e6
|
|
17
|
+
})).sort((e, o) => e._rank - o._rank || e.label.localeCompare(o.label)).map(({ _rank: e, ...o }) => o);
|
|
18
|
+
}
|
|
19
|
+
const m = (n) => (Array.isArray(n.special) ? n.special : String(n.special ?? "").split(",")).map((i) => i.trim().toLowerCase()).filter(Boolean), S = /* @__PURE__ */ new Set(["user-created", "user-updated", "date-created", "date-updated", "uuid"]);
|
|
20
|
+
function w(n) {
|
|
21
|
+
const i = m(n), t = String(n.interface ?? "").toLowerCase();
|
|
22
|
+
return i.includes("m2m") || t.includes("m2m") ? "links several" : i.includes("m2o") || t.includes("m2o") ? "link" : i.includes("cast-boolean") || n.type === "boolean" ? "yes / no" : /date|time/.test(String(n.type ?? "")) ? "date" : /integer|decimal|float|bigint/.test(String(n.type ?? "")) ? "number" : "";
|
|
23
|
+
}
|
|
24
|
+
function b(n, i = "") {
|
|
25
|
+
return n.filter((t) => {
|
|
26
|
+
if (!(t != null && t.field)) return !1;
|
|
27
|
+
if (t.field === i) return !0;
|
|
28
|
+
const l = m(t), r = String(t.interface ?? "").toLowerCase();
|
|
29
|
+
return !(t.hidden || t.readonly || t.computed_type || l.some((s) => S.has(s)) || l.includes("o2m") || r.includes("o2m") || l.includes("alias") && !l.includes("m2m"));
|
|
30
|
+
}).map((t, l) => ({ f: t, i: l })).sort((t, l) => (t.f.sort ?? 1e6) - (l.f.sort ?? 1e6) || t.i - l.i).map(({ f: t }) => {
|
|
31
|
+
const l = w(t);
|
|
32
|
+
return {
|
|
33
|
+
value: t.field,
|
|
34
|
+
label: p(t.field),
|
|
35
|
+
hint: l ? `${t.field} · ${l}` : t.field
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
d as collectionName,
|
|
41
|
+
_ as collectionPickerOptions,
|
|
42
|
+
b as fieldPickerOptions,
|
|
43
|
+
p as titleCase
|
|
44
|
+
};
|
|
@@ -536,7 +536,7 @@ function bn({
|
|
|
536
536
|
return M != null && M !== "" && !(Array.isArray(M) && M.length === 0);
|
|
537
537
|
}) : O;
|
|
538
538
|
if (c.length === 0) return null;
|
|
539
|
-
const x = "text-[9px] font-semibold uppercase tracking-wider text-slate-400 dark:text-slate-500 shrink-0", S = "text-[12px] font-semibold text-slate-700 dark:text-slate-300", D = "text-[12px] text-slate-300 dark:text-slate-600",
|
|
539
|
+
const x = "text-[9px] font-semibold uppercase tracking-wider text-slate-400 dark:text-slate-500 shrink-0", S = "text-[12px] font-semibold text-slate-700 dark:text-slate-300", D = "text-[12px] text-slate-300 dark:text-slate-600", z = "flex items-baseline gap-1.5", pe = (_) => {
|
|
540
540
|
if (_ === "__owners__") {
|
|
541
541
|
const u = (m == null ? void 0 : m.label_override) || "Owners";
|
|
542
542
|
return /* @__PURE__ */ y("div", { className: "flex items-center gap-1.5", children: [
|
|
@@ -589,14 +589,14 @@ function bn({
|
|
|
589
589
|
} else
|
|
590
590
|
I = B.toLocaleString(void 0, { maximumFractionDigits: 2 });
|
|
591
591
|
}
|
|
592
|
-
return /* @__PURE__ */ y("div", { className:
|
|
592
|
+
return /* @__PURE__ */ y("div", { className: z, children: [
|
|
593
593
|
/* @__PURE__ */ e("span", { className: x, children: T }),
|
|
594
594
|
/* @__PURE__ */ e("span", { className: S, children: I })
|
|
595
595
|
] });
|
|
596
596
|
}
|
|
597
597
|
if (d && _ in d) {
|
|
598
598
|
const u = d[_];
|
|
599
|
-
return /* @__PURE__ */ y("div", { className:
|
|
599
|
+
return /* @__PURE__ */ y("div", { className: z, children: [
|
|
600
600
|
/* @__PURE__ */ e("span", { className: x, children: C }),
|
|
601
601
|
/* @__PURE__ */ y("span", { className: S, children: [
|
|
602
602
|
u,
|
|
@@ -607,7 +607,7 @@ function bn({
|
|
|
607
607
|
}
|
|
608
608
|
if (F && _ in F) {
|
|
609
609
|
const u = F[_];
|
|
610
|
-
return /* @__PURE__ */ y("div", { className:
|
|
610
|
+
return /* @__PURE__ */ y("div", { className: z, children: [
|
|
611
611
|
/* @__PURE__ */ e("span", { className: x, children: C }),
|
|
612
612
|
/* @__PURE__ */ y("span", { className: S, children: [
|
|
613
613
|
u,
|
|
@@ -621,14 +621,14 @@ function bn({
|
|
|
621
621
|
);
|
|
622
622
|
if (P != null && P.one_collection) {
|
|
623
623
|
const u = Array.isArray(q) ? q : q != null && q !== "" ? [q] : [];
|
|
624
|
-
return /* @__PURE__ */ y("div", { className:
|
|
624
|
+
return /* @__PURE__ */ y("div", { className: z, children: [
|
|
625
625
|
/* @__PURE__ */ e("span", { className: x, children: C }),
|
|
626
626
|
u.length === 0 ? /* @__PURE__ */ e("span", { className: D, children: "—" }) : P.one_collection === "nivaro_users" ? /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1.5 gap-y-0.5", children: u.map((T) => /* @__PURE__ */ e(nt, { userId: String(T) }, String(T))) }) : /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1.5", children: u.map((T) => /* @__PURE__ */ e(re, { relCollection: P.one_collection, id: T }, String(T))) })
|
|
627
627
|
] });
|
|
628
628
|
}
|
|
629
629
|
if (Array.isArray(q)) {
|
|
630
630
|
const u = a.find((B) => B.many_field === _ && B.junction_field), T = u == null ? void 0 : u.one_collection;
|
|
631
|
-
return /* @__PURE__ */ y("div", { className:
|
|
631
|
+
return /* @__PURE__ */ y("div", { className: z, children: [
|
|
632
632
|
/* @__PURE__ */ e("span", { className: x, children: C }),
|
|
633
633
|
q.length === 0 ? /* @__PURE__ */ e("span", { className: D, children: "—" }) : T ? /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1.5 gap-y-0.5", children: q.map(
|
|
634
634
|
(B) => T === "nivaro_users" ? /* @__PURE__ */ e(nt, { userId: String(B) }, String(B)) : /* @__PURE__ */ e(re, { relCollection: T, id: B }, String(B))
|
|
@@ -639,7 +639,7 @@ function bn({
|
|
|
639
639
|
] })
|
|
640
640
|
] });
|
|
641
641
|
}
|
|
642
|
-
return /* @__PURE__ */ y("div", { className:
|
|
642
|
+
return /* @__PURE__ */ y("div", { className: z, children: [
|
|
643
643
|
/* @__PURE__ */ e("span", { className: x, children: C }),
|
|
644
644
|
q == null || q === "" ? /* @__PURE__ */ e("span", { className: D, children: "—" }) : /* @__PURE__ */ e("span", { className: S, children: Fe(q, H) })
|
|
645
645
|
] });
|
|
@@ -673,7 +673,7 @@ const zn = It(function({
|
|
|
673
673
|
isOpen: x,
|
|
674
674
|
onToggle: S,
|
|
675
675
|
summaryFields: D,
|
|
676
|
-
m2mCounts:
|
|
676
|
+
m2mCounts: z,
|
|
677
677
|
o2mCounts: pe,
|
|
678
678
|
o2mAggValues: _,
|
|
679
679
|
summaryAggConfigs: M,
|
|
@@ -708,14 +708,14 @@ const zn = It(function({
|
|
|
708
708
|
}, [Z == null ? void 0 : Z.seq]), ne(() => {
|
|
709
709
|
X && At(X.target) === t.key && xe(!1);
|
|
710
710
|
}, [X == null ? void 0 : X.seq]);
|
|
711
|
-
const Ie = S !== void 0,
|
|
711
|
+
const Ie = S !== void 0, V = Te ?? (Ie ? !x : ht);
|
|
712
712
|
ne(() => {
|
|
713
|
-
ie && !
|
|
714
|
-
}, [ie,
|
|
713
|
+
ie && !V && (se == null || se(t.key));
|
|
714
|
+
}, [ie, V, se, t.key]);
|
|
715
715
|
const ge = Te !== null ? () => xe((f) => !f) : Ie ? S : () => ft((f) => !f), Me = !j && I != null, ye = () => {
|
|
716
716
|
Me && ot({ layoutId: Number(I), collection: r, kind: "opened", key: t.key });
|
|
717
717
|
}, gt = () => {
|
|
718
|
-
|
|
718
|
+
V && ye(), ge == null || ge();
|
|
719
719
|
}, yt = !g && i.some((f) => m[f.field]), Pe = j ? "always" : t.visibility_mode ?? "always";
|
|
720
720
|
if (Pe === "new_only" && !O || Pe === "existing_only" && O) return null;
|
|
721
721
|
const ee = A ?? [], _t = !O && ee.some((f) => f.widget_id != null && Be[f.field] === void 0);
|
|
@@ -740,6 +740,7 @@ const zn = It(function({
|
|
|
740
740
|
{
|
|
741
741
|
"data-loads-on-open": ie ? "" : void 0,
|
|
742
742
|
"data-section-key": t.key,
|
|
743
|
+
"data-collapsed": V ? "" : void 0,
|
|
743
744
|
className: E(
|
|
744
745
|
"nvr-section-enter rounded-xl border border-slate-200 bg-white dark:bg-card dark:border-border",
|
|
745
746
|
g && "bg-slate-50/60 dark:bg-slate-900/20",
|
|
@@ -768,7 +769,7 @@ const zn = It(function({
|
|
|
768
769
|
// Round the bottom only when nothing renders below the header — an
|
|
769
770
|
// expanded body (or collapsed summary strip) square-joins it, and a
|
|
770
771
|
// rounded hover overlay would leave see-through notches at the seam.
|
|
771
|
-
|
|
772
|
+
V && !(D && D.length > 0) && "rounded-b-xl"
|
|
772
773
|
),
|
|
773
774
|
children: [
|
|
774
775
|
Ge && /* @__PURE__ */ e(Ge, { className: "h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500" }),
|
|
@@ -781,7 +782,7 @@ const zn = It(function({
|
|
|
781
782
|
"data-design-pass": j ? "" : void 0,
|
|
782
783
|
className: E(
|
|
783
784
|
"h-4 w-4 text-slate-400 dark:text-slate-500 transition-transform duration-200",
|
|
784
|
-
|
|
785
|
+
V && "-rotate-90"
|
|
785
786
|
)
|
|
786
787
|
}
|
|
787
788
|
)
|
|
@@ -789,7 +790,7 @@ const zn = It(function({
|
|
|
789
790
|
}
|
|
790
791
|
)
|
|
791
792
|
),
|
|
792
|
-
|
|
793
|
+
V && D && D.length > 0 && /* @__PURE__ */ e(
|
|
793
794
|
bn,
|
|
794
795
|
{
|
|
795
796
|
summaryFields: D,
|
|
@@ -801,7 +802,7 @@ const zn = It(function({
|
|
|
801
802
|
ownersCollection: C,
|
|
802
803
|
ownersItemId: q,
|
|
803
804
|
ownersAssignment: P,
|
|
804
|
-
m2mCounts:
|
|
805
|
+
m2mCounts: z,
|
|
805
806
|
o2mCounts: pe,
|
|
806
807
|
o2mAggValues: _,
|
|
807
808
|
summaryAggConfigs: M,
|
|
@@ -809,7 +810,7 @@ const zn = It(function({
|
|
|
809
810
|
hideEmpty: !!t.summary_hide_empty || !!W
|
|
810
811
|
}
|
|
811
812
|
),
|
|
812
|
-
|
|
813
|
+
V && !ie && t.hide_when_empty && ee.length > 0 && /* @__PURE__ */ e("div", { className: "hidden", children: ee.filter((f) => f.widget_id != null).map((f) => /* @__PURE__ */ e(
|
|
813
814
|
Qe,
|
|
814
815
|
{
|
|
815
816
|
widgetId: f.widget_id,
|
|
@@ -823,7 +824,7 @@ const zn = It(function({
|
|
|
823
824
|
},
|
|
824
825
|
f.field
|
|
825
826
|
)) }),
|
|
826
|
-
!
|
|
827
|
+
!V && /* @__PURE__ */ y(
|
|
827
828
|
"div",
|
|
828
829
|
{
|
|
829
830
|
"data-section-body": "",
|
|
@@ -903,8 +904,8 @@ const zn = It(function({
|
|
|
903
904
|
children: [
|
|
904
905
|
/* @__PURE__ */ e("dt", { className: "text-[11px] font-medium text-slate-400 truncate", children: U.label || ut(U.field) }),
|
|
905
906
|
/* @__PURE__ */ e("dd", { className: "mt-0.5 break-words", children: (b == null ? void 0 : b.one_collection) === "nivaro_users" ? (() => {
|
|
906
|
-
const k = a[U.field],
|
|
907
|
-
return
|
|
907
|
+
const k = a[U.field], J = Array.isArray(k) ? k : k != null && k !== "" ? [k] : [];
|
|
908
|
+
return J.length === 0 ? /* @__PURE__ */ e("span", { className: "text-[13px] text-slate-400", children: "—" }) : /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5", children: J.map((G) => /* @__PURE__ */ e(pt, { userId: String(G) }, String(G))) });
|
|
908
909
|
})() : b != null && b.one_collection ? /* @__PURE__ */ e(re, { relCollection: b.one_collection, id: a[U.field] }) : /* @__PURE__ */ e("span", { className: "text-[13px] text-slate-700", children: Fe(a[U.field], U) }) })
|
|
909
910
|
]
|
|
910
911
|
},
|
|
@@ -965,7 +966,7 @@ const zn = It(function({
|
|
|
965
966
|
}
|
|
966
967
|
if (b._t === "pdf") {
|
|
967
968
|
if (!I) return null;
|
|
968
|
-
const w = b.slot.col_span ?? 12,
|
|
969
|
+
const w = b.slot.col_span ?? 12, R = ((Ee = b.slot.label_override) == null ? void 0 : Ee.trim()) || "Generate PDF";
|
|
969
970
|
return K(
|
|
970
971
|
le("__pdf__"),
|
|
971
972
|
/* @__PURE__ */ e("div", { style: { gridColumn: `span ${w}` }, children: /* @__PURE__ */ e(
|
|
@@ -976,21 +977,21 @@ const zn = It(function({
|
|
|
976
977
|
layoutId: I,
|
|
977
978
|
attachField: T ?? null,
|
|
978
979
|
filenameTemplate: B,
|
|
979
|
-
label:
|
|
980
|
+
label: R
|
|
980
981
|
}
|
|
981
982
|
) }, "__pdf__")
|
|
982
983
|
);
|
|
983
984
|
}
|
|
984
985
|
if (b._t === "widget") {
|
|
985
986
|
if (!b.slot.widget_id) return null;
|
|
986
|
-
const w = b.slot.col_span ?? 12,
|
|
987
|
+
const w = b.slot.col_span ?? 12, R = et(b.slot.input_bindings);
|
|
987
988
|
return K(
|
|
988
989
|
le(b.slot.field),
|
|
989
990
|
/* @__PURE__ */ e("div", { style: { gridColumn: `span ${w}` }, children: /* @__PURE__ */ e(
|
|
990
991
|
Qe,
|
|
991
992
|
{
|
|
992
993
|
widgetId: b.slot.widget_id,
|
|
993
|
-
inputBindings:
|
|
994
|
+
inputBindings: R,
|
|
994
995
|
itemDraft: a,
|
|
995
996
|
label: b.slot.label_override ?? void 0,
|
|
996
997
|
defaultExpanded: b.slot.default_expanded ?? !0,
|
|
@@ -1003,14 +1004,14 @@ const zn = It(function({
|
|
|
1003
1004
|
) }, b.slot.field)
|
|
1004
1005
|
);
|
|
1005
1006
|
}
|
|
1006
|
-
const k = b.f,
|
|
1007
|
+
const k = b.f, J = fe == null ? void 0 : fe[k.field], G = J == null ? void 0 : J.entries, kt = (J == null ? void 0 : J.separator) ?? null, oe = a[k.field], Ve = oe != null && oe !== "", Je = G != null && G.length && Ve ? ((We = o.find(
|
|
1007
1008
|
(w) => w.many_collection === r && w.many_field === k.field && !w.junction_field
|
|
1008
1009
|
)) == null ? void 0 : We.one_collection) ?? null : null, Re = (L == null ? void 0 : L.enabled) && k.field === L.primary_field, ze = (() => {
|
|
1009
1010
|
const w = a[(L == null ? void 0 : L.primary_field) ?? ""];
|
|
1010
1011
|
return w != null && w !== "";
|
|
1011
1012
|
})(), He = (Q ?? []).some((w) => {
|
|
1012
|
-
const
|
|
1013
|
-
return
|
|
1013
|
+
const R = a[w.field];
|
|
1014
|
+
return R != null && R !== "";
|
|
1014
1015
|
}), St = Re && Oe ? /* @__PURE__ */ y("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
1015
1016
|
/* @__PURE__ */ e(
|
|
1016
1017
|
"button",
|
|
@@ -1066,8 +1067,8 @@ const zn = It(function({
|
|
|
1066
1067
|
}
|
|
1067
1068
|
)
|
|
1068
1069
|
] }) : void 0, $t = Re && je && (Q != null && Q.length) ? /* @__PURE__ */ e("div", { className: "mt-2 rounded-lg border border-slate-200 bg-slate-50 dark:border-border dark:bg-slate-900/40 p-3", children: /* @__PURE__ */ e("div", { className: "grid grid-cols-2 gap-3", children: Q.map((w) => {
|
|
1069
|
-
const
|
|
1070
|
-
return /* @__PURE__ */ e("div", { style: { gridColumn: `span ${
|
|
1070
|
+
const R = (he == null ? void 0 : he[w.field]) ?? 2;
|
|
1071
|
+
return /* @__PURE__ */ e("div", { style: { gridColumn: `span ${R}` }, children: /* @__PURE__ */ e(
|
|
1071
1072
|
Se,
|
|
1072
1073
|
{
|
|
1073
1074
|
field: w,
|