@nivaro/react 0.2.51 → 0.2.53

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.
Files changed (117) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +207 -6
  4. package/dist/index.js +442 -439
  5. package/dist/layout-editor.d.ts +80 -0
  6. package/dist/layout-editor.js +11 -0
  7. package/dist/shared/components/ItemEditForm.js +4015 -3835
  8. package/dist/shared/components/RecordDrilldownSheet.js +114 -97
  9. package/dist/shared/components/RecordReadView.js +637 -570
  10. package/dist/shared/components/ai/ExplainButton.js +1 -1
  11. package/dist/shared/components/item-edit/GroupSection.js +489 -466
  12. package/dist/shared/components/item-edit/HeaderBand.js +47 -44
  13. package/dist/shared/components/item-edit/M2MStagingContext.js +3 -3
  14. package/dist/shared/components/item-edit/O2MStagingContext.js +1 -1
  15. package/dist/shared/components/item-edit/RecordGrantTools.js +206 -0
  16. package/dist/shared/components/item-edit/StepsBar.js +49 -43
  17. package/dist/shared/components/item-edit/SummaryPanel.js +1 -1
  18. package/dist/shared/components/item-edit/config-update.js +6 -0
  19. package/dist/shared/components/item-edit/layout-editing-quiet.js +25 -0
  20. package/dist/shared/components/layout-editor/AddPanel.js +301 -0
  21. package/dist/shared/components/layout-editor/DesignNode.js +173 -0
  22. package/dist/shared/components/layout-editor/EditorCanvas.js +52 -0
  23. package/dist/shared/components/layout-editor/EditorTopBar.js +241 -0
  24. package/dist/shared/components/layout-editor/HistoryPanel.js +179 -0
  25. package/dist/shared/components/layout-editor/LayoutEditor.js +393 -0
  26. package/dist/shared/components/layout-editor/LayoutsRail.js +89 -0
  27. package/dist/shared/components/layout-editor/add-target.js +103 -0
  28. package/dist/shared/components/layout-editor/bundle-to-active.js +86 -0
  29. package/dist/shared/components/layout-editor/canvases/PdfCanvas.js +90 -0
  30. package/dist/shared/components/layout-editor/canvases/TableColumnsCanvas.js +246 -0
  31. package/dist/shared/components/layout-editor/collection-meta.js +22 -0
  32. package/dist/shared/components/layout-editor/design-canvas.js +81 -0
  33. package/dist/shared/components/layout-editor/design-context.js +21 -0
  34. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +225 -0
  35. package/dist/shared/components/layout-editor/dnd/collision.js +107 -0
  36. package/dist/shared/components/layout-editor/dnd/node.js +164 -0
  37. package/dist/shared/components/layout-editor/dnd/order.js +122 -0
  38. package/dist/shared/components/layout-editor/editors/DefaultValuesEditor.js +223 -0
  39. package/dist/shared/components/layout-editor/editors/QuickPickerStepsEditor.js +129 -0
  40. package/dist/shared/components/layout-editor/editors/ReadPresentationEditor.js +134 -0
  41. package/dist/shared/components/layout-editor/editors/RecordConditionsEditor.js +249 -0
  42. package/dist/shared/components/layout-editor/editors/RolesPicker.js +77 -0
  43. package/dist/shared/components/layout-editor/editors/cascade-filters.js +556 -0
  44. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +150 -0
  45. package/dist/shared/components/layout-editor/editors/controls.js +73 -0
  46. package/dist/shared/components/layout-editor/editors/editor-api.js +21 -0
  47. package/dist/shared/components/layout-editor/editors/editor-queries.js +25 -0
  48. package/dist/shared/components/layout-editor/editors/field-default-value.js +131 -0
  49. package/dist/shared/components/layout-editor/editors/grid-presets.js +310 -0
  50. package/dist/shared/components/layout-editor/editors/inline-display.js +157 -0
  51. package/dist/shared/components/layout-editor/editors/layout-picker.js +80 -0
  52. package/dist/shared/components/layout-editor/editors/layout-rows.js +55 -0
  53. package/dist/shared/components/layout-editor/editors/lock-conditions.js +109 -0
  54. package/dist/shared/components/layout-editor/editors/o2m-agg-field.js +25 -0
  55. package/dist/shared/components/layout-editor/editors/pdf-field-config.js +107 -0
  56. package/dist/shared/components/layout-editor/editors/report-widget-config.js +94 -0
  57. package/dist/shared/components/layout-editor/editors/row-rule-check.js +225 -0
  58. package/dist/shared/components/layout-editor/editors/row-rule-row.js +1353 -0
  59. package/dist/shared/components/layout-editor/editors/swap-config.js +245 -0
  60. package/dist/shared/components/layout-editor/focus-buffer.js +32 -0
  61. package/dist/shared/components/layout-editor/host.js +15 -0
  62. package/dist/shared/components/layout-editor/inspector/AdvancedTab.js +296 -0
  63. package/dist/shared/components/layout-editor/inspector/GridTab.js +767 -0
  64. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +456 -0
  65. package/dist/shared/components/layout-editor/inspector/HeaderItemInspector.js +268 -0
  66. package/dist/shared/components/layout-editor/inspector/Inspector.js +332 -0
  67. package/dist/shared/components/layout-editor/inspector/LookTab.js +310 -0
  68. package/dist/shared/components/layout-editor/inspector/PickerTab.js +333 -0
  69. package/dist/shared/components/layout-editor/inspector/RulesTab.js +323 -0
  70. package/dist/shared/components/layout-editor/inspector/SlotInspector.js +179 -0
  71. package/dist/shared/components/layout-editor/inspector/SubtitleInspector.js +154 -0
  72. package/dist/shared/components/layout-editor/inspector/WidgetInspector.js +262 -0
  73. package/dist/shared/components/layout-editor/inspector/applies.js +27 -0
  74. package/dist/shared/components/layout-editor/inspector/field-context.js +134 -0
  75. package/dist/shared/components/layout-editor/inspector/interfaces.js +126 -0
  76. package/dist/shared/components/layout-editor/inspector/kit.js +595 -0
  77. package/dist/shared/components/layout-editor/inspector/model.js +307 -0
  78. package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -0
  79. package/dist/shared/components/layout-editor/overview/describe-conditions.js +121 -0
  80. package/dist/shared/components/layout-editor/overview/overview-api.js +141 -0
  81. package/dist/shared/components/layout-editor/overview/purpose.js +62 -0
  82. package/dist/shared/components/layout-editor/overview/record-count.js +65 -0
  83. package/dist/shared/components/layout-editor/panel-frame.js +99 -0
  84. package/dist/shared/components/layout-editor/panel-style.js +19 -0
  85. package/dist/shared/components/layout-editor/pickers/field-picker.js +230 -0
  86. package/dist/shared/components/layout-editor/pickers/icon-picker.js +233 -0
  87. package/dist/shared/components/layout-editor/pickers/relation-label.js +34 -0
  88. package/dist/shared/components/layout-editor/pickers/relation-picker.js +136 -0
  89. package/dist/shared/components/layout-editor/record-queries.js +15 -0
  90. package/dist/shared/components/layout-editor/settings/AddendumSection.js +52 -0
  91. package/dist/shared/components/layout-editor/settings/ButtonsSection.js +45 -0
  92. package/dist/shared/components/layout-editor/settings/DefaultsSection.js +67 -0
  93. package/dist/shared/components/layout-editor/settings/FormSettings.js +146 -0
  94. package/dist/shared/components/layout-editor/settings/InheritanceSection.js +37 -0
  95. package/dist/shared/components/layout-editor/settings/LayoutSection.js +70 -0
  96. package/dist/shared/components/layout-editor/settings/PdfSection.js +176 -0
  97. package/dist/shared/components/layout-editor/settings/ReadSection.js +79 -0
  98. package/dist/shared/components/layout-editor/settings/TextSetting.js +55 -0
  99. package/dist/shared/components/layout-editor/settings/ToggleSetting.js +33 -0
  100. package/dist/shared/components/layout-editor/settings/ToolsSection.js +179 -0
  101. package/dist/shared/components/layout-editor/settings/WhoSection.js +213 -0
  102. package/dist/shared/components/layout-editor/settings/controls.js +214 -0
  103. package/dist/shared/components/layout-editor/settings/section-props.js +17 -0
  104. package/dist/shared/components/layout-editor/settings/settings-api.js +151 -0
  105. package/dist/shared/components/layout-editor/settings/settings-registry.js +445 -0
  106. package/dist/shared/components/layout-editor/slot-names.js +20 -0
  107. package/dist/shared/components/layout-editor/summary-pref.js +21 -0
  108. package/dist/shared/components/layout-editor/useLayoutDraft.js +474 -0
  109. package/dist/shared/components/pipeline/relations.js +28 -23
  110. package/dist/shared/components/ui/popover.js +17 -17
  111. package/dist/shared/components/ui/scroll-area.js +38 -0
  112. package/dist/shared/hooks/useRelationOptions.js +60 -0
  113. package/dist/shared/lib/layout-grants.js +9 -0
  114. package/dist/shared/lib/layout-ops.js +348 -0
  115. package/dist/shared/lib/layout-slots.js +11 -7
  116. package/dist/shared/lib/request-gate.js +1 -1
  117. package/package.json +5 -1
@@ -0,0 +1,65 @@
1
+ const i = /\{\{/;
2
+ function a(n) {
3
+ return n === "true" ? !0 : n === "false" ? !1 : n;
4
+ }
5
+ function f(n, e) {
6
+ if (typeof n.value == "string" && i.test(n.value)) return null;
7
+ const l = n.value == null || n.value === "", r = n.field, t = a(n.value);
8
+ switch (n.op) {
9
+ case "null":
10
+ return { [r]: { _null: !e } };
11
+ case "nnull":
12
+ return { [r]: { _null: e } };
13
+ case "eq":
14
+ case "neq":
15
+ return l ? { [r]: { _null: n.op === "eq" !== e } } : n.op === "eq" !== e ? { [r]: { _eq: t } } : { _or: [{ [r]: { _neq: t } }, { [r]: { _null: !0 } }] };
16
+ case "gt":
17
+ return { [r]: { [e ? "_lte" : "_gt"]: t } };
18
+ case "gte":
19
+ return { [r]: { [e ? "_lt" : "_gte"]: t } };
20
+ case "lt":
21
+ return { [r]: { [e ? "_gte" : "_lt"]: t } };
22
+ case "lte":
23
+ return { [r]: { [e ? "_gt" : "_lte"]: t } };
24
+ default:
25
+ return null;
26
+ }
27
+ }
28
+ function c(n) {
29
+ const e = [];
30
+ for (const l of n) {
31
+ const r = f(l, !1);
32
+ if (!r) return null;
33
+ e.push(r);
34
+ }
35
+ return e.length ? { _and: e } : null;
36
+ }
37
+ function _(n) {
38
+ const e = [];
39
+ for (const l of n) {
40
+ const r = f(l, !0);
41
+ if (!r) return null;
42
+ e.push(r);
43
+ }
44
+ return e.length ? { _or: e } : null;
45
+ }
46
+ function d(n, e) {
47
+ var r, t, u;
48
+ if (n.section !== "forms" || (r = n.reason.role_ids) != null && r.length) return null;
49
+ if (n.reason.kind === "record_rule")
50
+ return (t = n.reason.rules) != null && t.length ? c(n.reason.rules) : null;
51
+ if (n.reason.kind !== "default" && n.reason.kind !== "fallback") return null;
52
+ const l = [];
53
+ for (const s of e) {
54
+ if (s.reason.kind !== "record_rule" || !((u = s.reason.rules) != null && u.length)) continue;
55
+ const o = _(s.reason.rules);
56
+ if (!o) return null;
57
+ l.push(o);
58
+ }
59
+ return l.length ? { _and: l } : {};
60
+ }
61
+ export {
62
+ _ as notRulesFilter,
63
+ d as recordCountFilter,
64
+ c as rulesFilter
65
+ };
@@ -0,0 +1,99 @@
1
+ import { jsxs as k, jsx as o } from "react/jsx-runtime";
2
+ import { useRef as g } from "react";
3
+ import { cn as d } from "../../lib/utils.js";
4
+ import { useOverflowTip as u } from "../TipLayer.js";
5
+ import { effectText as p } from "./panel-style.js";
6
+ const y = (e) => typeof e == "string" || typeof e == "number" ? String(e) : null;
7
+ function R({
8
+ eyebrow: e,
9
+ title: r,
10
+ sub: n,
11
+ children: l
12
+ }) {
13
+ const i = u(y(e)), a = u(y(r));
14
+ return /* @__PURE__ */ k(
15
+ "div",
16
+ {
17
+ "data-panel-header": "",
18
+ className: "shrink-0 border-b border-slate-200 px-4 pb-3 pt-3.5 dark:border-border",
19
+ children: [
20
+ e && /* @__PURE__ */ o("p", { ref: i, "data-panel-eyebrow": "", className: d(p, "truncate"), children: e }),
21
+ /* @__PURE__ */ o(
22
+ "h2",
23
+ {
24
+ ref: a,
25
+ className: "truncate text-[14px] font-semibold leading-6 text-slate-900 dark:text-foreground",
26
+ children: r
27
+ }
28
+ ),
29
+ n && /* @__PURE__ */ o("div", { className: d(p, "truncate"), children: n }),
30
+ l && /* @__PURE__ */ o("div", { className: "mt-3", children: l })
31
+ ]
32
+ }
33
+ );
34
+ }
35
+ function T({
36
+ children: e,
37
+ className: r,
38
+ tabpanel: n
39
+ }) {
40
+ return /* @__PURE__ */ o(
41
+ "div",
42
+ {
43
+ "data-panel-body": "",
44
+ ...n ? { role: "tabpanel", id: n.id, "aria-labelledby": n.labelledBy } : {},
45
+ className: d("min-h-0 flex-1 space-y-5 overflow-y-auto px-4 pb-8 pt-4", r),
46
+ children: e
47
+ }
48
+ );
49
+ }
50
+ const x = (e, r) => `${e}-tab-${r}`, h = (e) => `${e}-panel`;
51
+ function $({
52
+ tabs: e,
53
+ active: r,
54
+ onChange: n,
55
+ idBase: l,
56
+ label: i
57
+ }) {
58
+ const a = g(null);
59
+ return /* @__PURE__ */ o(
60
+ "div",
61
+ {
62
+ ref: a,
63
+ role: "tablist",
64
+ "aria-label": i,
65
+ onKeyDown: (t) => {
66
+ var f, m;
67
+ const c = e.findIndex((b) => b.key === r), s = t.key === "ArrowRight" ? (c + 1) % e.length : t.key === "ArrowLeft" ? (c - 1 + e.length) % e.length : t.key === "Home" ? 0 : t.key === "End" ? e.length - 1 : -1;
68
+ s < 0 || (t.preventDefault(), n(e[s].key), (m = (f = a.current) == null ? void 0 : f.ownerDocument.getElementById(x(l, e[s].key))) == null || m.focus());
69
+ },
70
+ className: "-mx-1 flex flex-wrap gap-0.5",
71
+ children: e.map((t) => /* @__PURE__ */ o(
72
+ "button",
73
+ {
74
+ id: x(l, t.key),
75
+ type: "button",
76
+ role: "tab",
77
+ "aria-selected": r === t.key,
78
+ "aria-controls": h(l),
79
+ tabIndex: r === t.key ? 0 : -1,
80
+ "data-inspector-tab": t.key,
81
+ onClick: () => n(t.key),
82
+ className: d(
83
+ "h-7 rounded-md px-2.5 text-[12px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50",
84
+ r === t.key ? "bg-slate-100 font-medium text-slate-900 dark:bg-muted dark:text-foreground" : "text-slate-600 hover:bg-slate-50 hover:text-slate-900 dark:hover:bg-muted/60 dark:hover:text-foreground"
85
+ ),
86
+ children: t.label
87
+ },
88
+ t.key
89
+ ))
90
+ }
91
+ );
92
+ }
93
+ export {
94
+ T as PanelBody,
95
+ R as PanelHeader,
96
+ $ as PanelTabs,
97
+ x as tabId,
98
+ h as tabPanelId
99
+ };
@@ -0,0 +1,19 @@
1
+ const t = "text-[13px] font-medium leading-5 text-slate-800 dark:text-foreground", r = "text-[12px] leading-snug text-slate-500 dark:text-muted-foreground", o = "text-[13px] font-semibold leading-5 text-slate-900 dark:text-foreground", d = "h-8 w-full rounded-md border border-slate-200 bg-white px-2.5 text-[13px] text-slate-800 outline-none placeholder:text-slate-400 focus:border-nvr-cyan disabled:opacity-50 dark:border-border dark:bg-background dark:text-foreground dark:placeholder:text-muted-foreground", n = (e) => [
2
+ "grid gap-0.5 rounded-md bg-slate-100 p-0.5 dark:bg-muted",
3
+ e > 4 ? "grid-cols-3" : ["grid-cols-1", "grid-cols-2", "grid-cols-3", "grid-cols-4"][Math.max(0, e - 1)]
4
+ ].join(" "), a = (e) => [
5
+ "h-7 min-w-0 truncate rounded px-1.5 text-[12px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 disabled:opacity-40",
6
+ e ? "bg-white font-medium text-slate-900 ring-1 ring-slate-200 dark:bg-background dark:text-foreground dark:ring-border" : (
7
+ // slate-600 on the track clears AA in both themes (the host re-points it in dark).
8
+ "text-slate-600 hover:text-slate-900 dark:hover:text-foreground"
9
+ )
10
+ ].join(" "), i = "rounded-md bg-[#f6f8fa] ring-1 ring-inset ring-slate-200/70 dark:bg-white/[0.04] dark:ring-white/[0.07]";
11
+ export {
12
+ r as effectText,
13
+ o as groupTitle,
14
+ d as inputBase,
15
+ t as labelText,
16
+ a as segOption,
17
+ n as segTrack,
18
+ i as tintCard
19
+ };
@@ -0,0 +1,230 @@
1
+ import { jsxs as c, jsx as n } from "react/jsx-runtime";
2
+ import { ChevronRight as M, X as P, Search as S, Loader2 as F } from "lucide-react";
3
+ import { useState as k, useRef as E, useLayoutEffect as R, useEffect as z } from "react";
4
+ import { createPortal as $ } from "react-dom";
5
+ import { titleCase as _ } from "../../../lib/utils.js";
6
+ import { Popover as B, PopoverTrigger as T, PopoverContent as q } from "../../ui/popover.js";
7
+ import { useCollectionBody as H } from "../collection-meta.js";
8
+ function U({
9
+ collection: l,
10
+ fields: d,
11
+ relations: f,
12
+ value: r,
13
+ valueLabel: i,
14
+ onChange: h,
15
+ onClear: a,
16
+ placeholder: g
17
+ }) {
18
+ const [o, s] = k(!1), [m, u] = k(""), x = E(null), y = E(null), [b, v] = k(null);
19
+ R(() => {
20
+ if (!o) return;
21
+ const t = () => {
22
+ var N;
23
+ const p = (N = x.current) == null ? void 0 : N.getBoundingClientRect();
24
+ if (!p) return;
25
+ const L = Math.min(p.left, window.innerWidth - 288 - 8), C = Math.min(p.bottom + 4, window.innerHeight - 60);
26
+ v({ top: C, left: Math.max(8, L) });
27
+ };
28
+ return t(), window.addEventListener("scroll", t, !0), window.addEventListener("resize", t), () => {
29
+ window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", t);
30
+ };
31
+ }, [o]), z(() => {
32
+ if (!o) return;
33
+ const t = (p) => {
34
+ var L, C, N;
35
+ const w = p.target;
36
+ (L = x.current) != null && L.contains(w) || (C = y.current) != null && C.contains(w) || (N = w.closest) != null && N.call(w, "[data-radix-popper-content-wrapper]") || s(!1);
37
+ };
38
+ return document.addEventListener("mousedown", t), () => document.removeEventListener("mousedown", t);
39
+ }, [o]);
40
+ const e = [...d].sort((t, p) => t.field.localeCompare(p.field)).filter((t) => t.field.toLowerCase().includes(m.trim().toLowerCase()));
41
+ return /* @__PURE__ */ c("div", { className: "relative", children: [
42
+ /* @__PURE__ */ c(
43
+ "button",
44
+ {
45
+ type: "button",
46
+ ref: x,
47
+ onClick: () => s((t) => !t),
48
+ 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 && a ? "pl-2.5 pr-8" : "px-2.5"}`,
49
+ children: [
50
+ /* @__PURE__ */ n(
51
+ "span",
52
+ {
53
+ className: r ? "font-mono text-[12px] flex-1 text-left truncate" : "text-slate-400 flex-1 text-left truncate whitespace-nowrap",
54
+ children: i || r || g || "Select field…"
55
+ }
56
+ ),
57
+ /* @__PURE__ */ n(M, { className: "h-3.5 w-3.5 text-slate-400 shrink-0" })
58
+ ]
59
+ }
60
+ ),
61
+ r && a && /* @__PURE__ */ n(
62
+ "button",
63
+ {
64
+ type: "button",
65
+ onClick: (t) => {
66
+ t.stopPropagation(), a();
67
+ },
68
+ 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",
69
+ children: /* @__PURE__ */ n(P, { className: "h-3 w-3" })
70
+ }
71
+ ),
72
+ o && b && $(
73
+ /* @__PURE__ */ n(
74
+ "div",
75
+ {
76
+ ref: y,
77
+ style: { position: "fixed", top: b.top, left: b.left },
78
+ className: "z-50 w-72 rounded-xl border border-slate-200 bg-white shadow-lg dark:border-border dark:bg-card",
79
+ children: /* @__PURE__ */ c("div", { className: "p-2", children: [
80
+ /* @__PURE__ */ c("div", { className: "relative mb-1.5", children: [
81
+ /* @__PURE__ */ n(S, { className: "absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
82
+ /* @__PURE__ */ n(
83
+ "input",
84
+ {
85
+ value: m,
86
+ onChange: (t) => u(t.target.value),
87
+ placeholder: "Search fields…",
88
+ 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"
89
+ }
90
+ )
91
+ ] }),
92
+ /* @__PURE__ */ c("div", { className: "max-h-72 overflow-y-auto", children: [
93
+ e.map((t) => /* @__PURE__ */ n(
94
+ O,
95
+ {
96
+ field: t,
97
+ collection: l,
98
+ relations: f,
99
+ pathPrefix: [],
100
+ labelPrefix: [],
101
+ depth: 0,
102
+ onSelect: (p) => {
103
+ h(p), s(!1);
104
+ }
105
+ },
106
+ t.field
107
+ )),
108
+ e.length === 0 && /* @__PURE__ */ n("div", { className: "px-2 py-3 text-center text-[12px] text-slate-400", children: "No fields" })
109
+ ] })
110
+ ] })
111
+ }
112
+ ),
113
+ document.body
114
+ )
115
+ ] });
116
+ }
117
+ function Q({
118
+ relatedCollection: l,
119
+ pathPrefix: d,
120
+ labelPrefix: f,
121
+ onSelect: r
122
+ }) {
123
+ const { data: i, isLoading: h } = H(l);
124
+ if (h)
125
+ return /* @__PURE__ */ c("div", { className: "py-2 text-[12px] text-slate-400 flex items-center gap-2 px-2", children: [
126
+ /* @__PURE__ */ n(F, { className: "h-3.5 w-3.5 animate-spin" }),
127
+ "Loading…"
128
+ ] });
129
+ const a = [...((i == null ? void 0 : i.fields) ?? []).filter((o) => !o.hidden)].sort(
130
+ (o, s) => o.field.localeCompare(s.field)
131
+ ), g = (i == null ? void 0 : i.relations) ?? [];
132
+ return /* @__PURE__ */ c("div", { className: "max-h-64 overflow-y-auto", children: [
133
+ a.map((o) => /* @__PURE__ */ n(
134
+ O,
135
+ {
136
+ field: o,
137
+ collection: l,
138
+ relations: g,
139
+ pathPrefix: d,
140
+ labelPrefix: f,
141
+ depth: 0,
142
+ onSelect: r
143
+ },
144
+ o.field
145
+ )),
146
+ a.length === 0 && /* @__PURE__ */ n("div", { className: "px-2 py-1.5 text-[12px] text-slate-400", children: "No fields" })
147
+ ] });
148
+ }
149
+ function O({
150
+ field: l,
151
+ collection: d,
152
+ relations: f,
153
+ pathPrefix: r,
154
+ labelPrefix: i,
155
+ depth: h,
156
+ onSelect: a
157
+ }) {
158
+ const [g, o] = k(!1), s = f.find(
159
+ (e) => e.many_collection === d && e.many_field === l.field && e.junction_field === null && e.one_collection
160
+ ) ?? null, m = s ? null : f.find(
161
+ (e) => e.many_collection === d && e.many_field === l.field && e.junction_field !== null && e.one_collection
162
+ ) ?? null, u = !s && !m ? f.find(
163
+ (e) => e.one_collection === d && e.one_field === l.field && e.junction_field !== null && e.many_collection
164
+ ) ?? null : null, x = m ?? u, y = !s && !x ? f.find(
165
+ (e) => e.one_collection === d && e.one_field === l.field && e.junction_field === null && e.many_collection
166
+ ) ?? null : null, b = u ? f.find(
167
+ (e) => e.many_collection === u.many_collection && e.many_field === u.junction_field && e.one_collection
168
+ ) ?? null : null, v = (s == null ? void 0 : s.one_collection) ?? (m == null ? void 0 : m.one_collection) ?? (b == null ? void 0 : b.one_collection) ?? (u == null ? void 0 : u.many_collection) ?? (y == null ? void 0 : y.many_collection) ?? null, j = s ? "M2O" : x ? "M2M" : y ? "O2M" : null;
169
+ return v ? /* @__PURE__ */ c(B, { open: g, onOpenChange: o, children: [
170
+ /* @__PURE__ */ n(T, { asChild: !0, children: /* @__PURE__ */ c(
171
+ "button",
172
+ {
173
+ type: "button",
174
+ 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",
175
+ style: { paddingLeft: `${0.5 + h * 1}rem` },
176
+ children: [
177
+ /* @__PURE__ */ n("span", { className: "flex-1", children: _(l.field) }),
178
+ j && /* @__PURE__ */ n("span", { className: "rounded px-1 py-0.5 text-[10px] font-medium bg-slate-100 text-slate-500", children: j }),
179
+ /* @__PURE__ */ n(M, { className: "h-3.5 w-3.5 text-slate-400 shrink-0" })
180
+ ]
181
+ }
182
+ ) }),
183
+ /* @__PURE__ */ c(q, { side: "right", align: "start", sideOffset: 4, className: "w-56 p-1", children: [
184
+ (s || x) && /* @__PURE__ */ n(
185
+ "button",
186
+ {
187
+ type: "button",
188
+ onClick: () => {
189
+ a({
190
+ path: [...r, l.field],
191
+ pathLabels: [...i, _(l.field)],
192
+ fieldType: l.type,
193
+ relatedCollection: v ?? void 0
194
+ }), o(!1);
195
+ },
196
+ className: "w-full rounded-md px-2 py-1 text-left text-[12px] text-slate-500 hover:bg-slate-50 italic",
197
+ children: "(select this field)"
198
+ }
199
+ ),
200
+ /* @__PURE__ */ n(
201
+ Q,
202
+ {
203
+ relatedCollection: v,
204
+ pathPrefix: [...r, l.field],
205
+ labelPrefix: [...i, _(l.field)],
206
+ onSelect: (e) => {
207
+ a(e), o(!1);
208
+ }
209
+ }
210
+ )
211
+ ] })
212
+ ] }) : /* @__PURE__ */ n(
213
+ "button",
214
+ {
215
+ type: "button",
216
+ onClick: () => a({
217
+ path: [...r, l.field],
218
+ pathLabels: [...i, _(l.field)],
219
+ fieldType: l.type,
220
+ relatedCollection: h > 0 ? d : void 0
221
+ }),
222
+ className: "w-full rounded-md px-2 py-1.5 text-left text-[13px] text-slate-700 hover:bg-slate-50",
223
+ style: { paddingLeft: `${0.5 + h * 1}rem` },
224
+ children: _(l.field)
225
+ }
226
+ );
227
+ }
228
+ export {
229
+ U as FieldPicker
230
+ };
@@ -0,0 +1,233 @@
1
+ import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
+ import * as N from "lucide-react";
3
+ import { ChevronDown as S, Search as y, X as x } from "lucide-react";
4
+ import { useState as C } from "react";
5
+ import { cn as f } from "../../../lib/utils.js";
6
+ import { Button as v } from "../../ui/button.js";
7
+ import { Popover as L, PopoverTrigger as P, PopoverContent as B } from "../../ui/popover.js";
8
+ const M = [
9
+ "Activity",
10
+ "AlignLeft",
11
+ "Archive",
12
+ "ArrowRight",
13
+ "AtSign",
14
+ "Award",
15
+ "BarChart",
16
+ "BarChart2",
17
+ "Bell",
18
+ "Bookmark",
19
+ "Book",
20
+ "BookOpen",
21
+ "Box",
22
+ "Briefcase",
23
+ "Building",
24
+ "Building2",
25
+ "Calendar",
26
+ "Camera",
27
+ "Check",
28
+ "CheckCircle",
29
+ "ChevronRight",
30
+ "Circle",
31
+ "Clipboard",
32
+ "Clock",
33
+ "Cloud",
34
+ "Code",
35
+ "Code2",
36
+ "Cpu",
37
+ "CreditCard",
38
+ "Database",
39
+ "DollarSign",
40
+ "Download",
41
+ "Edit",
42
+ "Edit2",
43
+ "ExternalLink",
44
+ "Eye",
45
+ "EyeOff",
46
+ "File",
47
+ "FileText",
48
+ "Files",
49
+ "Film",
50
+ "Filter",
51
+ "Flag",
52
+ "Flame",
53
+ "Folder",
54
+ "FolderOpen",
55
+ "Globe",
56
+ "GraduationCap",
57
+ "Grid",
58
+ "Hammer",
59
+ "Heart",
60
+ "HelpCircle",
61
+ "History",
62
+ "Home",
63
+ "Image",
64
+ "Inbox",
65
+ "Info",
66
+ "Key",
67
+ "Laptop",
68
+ "Layers",
69
+ "Layout",
70
+ "LayoutDashboard",
71
+ "Link",
72
+ "List",
73
+ "Lock",
74
+ "LogIn",
75
+ "Mail",
76
+ "Map",
77
+ "MapPin",
78
+ "Maximize",
79
+ "MessageCircle",
80
+ "MessageSquare",
81
+ "Mic",
82
+ "Minimize",
83
+ "Monitor",
84
+ "Moon",
85
+ "Music",
86
+ "Navigation",
87
+ "Network",
88
+ "Package",
89
+ "Paperclip",
90
+ "Pencil",
91
+ "Phone",
92
+ "PieChart",
93
+ "Pin",
94
+ "Plus",
95
+ "Printer",
96
+ "RefreshCw",
97
+ "RotateCcw",
98
+ "Save",
99
+ "Search",
100
+ "Send",
101
+ "Settings",
102
+ "Settings2",
103
+ "Share2",
104
+ "Shield",
105
+ "ShoppingBag",
106
+ "ShoppingCart",
107
+ "Sliders",
108
+ "SlidersHorizontal",
109
+ "Smartphone",
110
+ "Star",
111
+ "Sun",
112
+ "Table",
113
+ "Tag",
114
+ "Tags",
115
+ "Target",
116
+ "Terminal",
117
+ "Timer",
118
+ "Trash2",
119
+ "TrendingUp",
120
+ "Trophy",
121
+ "Truck",
122
+ "Unlock",
123
+ "Upload",
124
+ "User",
125
+ "UserCheck",
126
+ "UserCircle",
127
+ "UserPlus",
128
+ "Users",
129
+ "Video",
130
+ "Wallet",
131
+ "Wifi",
132
+ "Workflow",
133
+ "Wrench",
134
+ "X",
135
+ "Zap",
136
+ "ZoomIn",
137
+ "GitBranch",
138
+ "GitMerge"
139
+ ];
140
+ function T(t) {
141
+ return t.split("-").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join("");
142
+ }
143
+ function k(t) {
144
+ return t.replace(/([A-Z])/g, (n, s, l) => l > 0 ? `-${s.toLowerCase()}` : s.toLowerCase());
145
+ }
146
+ function b(t) {
147
+ return N[t];
148
+ }
149
+ function H({
150
+ value: t,
151
+ onChange: n,
152
+ className: s,
153
+ trigger: l
154
+ }) {
155
+ const [w, i] = C(!1), [c, d] = C(""), h = t ? T(t) : null, m = h ? b(h) : null, u = M.filter((r) => {
156
+ const o = c.toLowerCase();
157
+ return r.toLowerCase().includes(o) || k(r).includes(o);
158
+ });
159
+ return /* @__PURE__ */ a(L, { open: w, onOpenChange: i, children: [
160
+ /* @__PURE__ */ e(P, { asChild: !0, children: l ?? /* @__PURE__ */ a(
161
+ v,
162
+ {
163
+ type: "button",
164
+ variant: "outline",
165
+ className: f("w-full justify-between text-[13px] font-normal", s),
166
+ children: [
167
+ /* @__PURE__ */ a("span", { className: "flex items-center gap-2 truncate", children: [
168
+ m ? /* @__PURE__ */ e(m, { className: "h-4 w-4 shrink-0 text-slate-600 dark:text-slate-400" }) : /* @__PURE__ */ e("span", { className: "h-4 w-4 shrink-0" }),
169
+ t ? /* @__PURE__ */ e("span", { className: "truncate text-slate-700 dark:text-slate-200", children: t }) : /* @__PURE__ */ e("span", { className: "text-slate-400", children: "Select an icon…" })
170
+ ] }),
171
+ /* @__PURE__ */ e(S, { className: "ml-2 h-3.5 w-3.5 shrink-0 text-slate-400" })
172
+ ]
173
+ }
174
+ ) }),
175
+ /* @__PURE__ */ a(B, { className: "w-[300px] p-3", align: "start", children: [
176
+ /* @__PURE__ */ a("div", { className: "mb-2.5 flex items-center gap-1.5 rounded-md border border-slate-200 bg-slate-50 px-2 py-1 dark:border-slate-700 dark:bg-slate-900", children: [
177
+ /* @__PURE__ */ e(y, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
178
+ /* @__PURE__ */ e(
179
+ "input",
180
+ {
181
+ autoFocus: !0,
182
+ className: "min-w-0 flex-1 bg-transparent text-[12px] outline-none placeholder:text-slate-400",
183
+ placeholder: "Search icons…",
184
+ value: c,
185
+ onChange: (r) => d(r.target.value)
186
+ }
187
+ ),
188
+ c && /* @__PURE__ */ e("button", { type: "button", onClick: () => d(""), children: /* @__PURE__ */ e(x, { className: "h-3 w-3 text-slate-400 hover:text-slate-600" }) })
189
+ ] }),
190
+ /* @__PURE__ */ a("div", { className: "grid max-h-[220px] grid-cols-8 gap-0.5 overflow-y-auto", children: [
191
+ u.map((r) => {
192
+ const o = b(r);
193
+ if (!o) return null;
194
+ const p = k(r), g = t === p;
195
+ return /* @__PURE__ */ e(
196
+ "button",
197
+ {
198
+ type: "button",
199
+ title: p,
200
+ onClick: () => {
201
+ n(g ? "" : p), i(!1), d("");
202
+ },
203
+ className: f(
204
+ "flex items-center justify-center rounded p-1.5 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800",
205
+ g && "bg-nvr-cyan/10 text-nvr-navy dark:bg-nvr-cyan/20 dark:text-nvr-cyan"
206
+ ),
207
+ children: /* @__PURE__ */ e(o, { className: "h-[15px] w-[15px]" })
208
+ },
209
+ r
210
+ );
211
+ }),
212
+ u.length === 0 && /* @__PURE__ */ e("p", { className: "col-span-8 py-6 text-center text-[12px] text-slate-400", children: "No icons found" })
213
+ ] }),
214
+ t && /* @__PURE__ */ e("div", { className: "mt-2 border-t border-slate-100 pt-2 dark:border-slate-800", children: /* @__PURE__ */ a(
215
+ "button",
216
+ {
217
+ type: "button",
218
+ onClick: () => {
219
+ n(""), i(!1);
220
+ },
221
+ className: "flex items-center gap-1.5 text-[11px] text-slate-400 hover:text-slate-600 dark:hover:text-slate-300",
222
+ children: [
223
+ /* @__PURE__ */ e(x, { className: "h-3 w-3" }),
224
+ "Clear icon"
225
+ ]
226
+ }
227
+ ) })
228
+ ] })
229
+ ] });
230
+ }
231
+ export {
232
+ H as IconPicker
233
+ };
@@ -0,0 +1,34 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { useQuery as f } from "@tanstack/react-query";
3
+ import { useNivaroClient as y } from "../../../context.js";
4
+ import { get as u } from "../../../lib/commands.js";
5
+ import { USER_SYSTEM_COLS as d, userDisplayLabel as _, renderDisplayTemplate as h } from "../../pipeline/relations.js";
6
+ import { Skeleton as x } from "../../ui/skeleton.js";
7
+ import { useCollectionBody as L } from "../collection-meta.js";
8
+ function O({ relatedCollection: t, id: e }) {
9
+ const o = y(), l = e != null && e !== "", m = (/* @__PURE__ */ new Set([
10
+ "directus_users",
11
+ "directus_files",
12
+ "directus_activity",
13
+ "directus_roles",
14
+ "nivaro_users"
15
+ ])).has(t), r = d.has(t), { data: a } = L(t, {
16
+ enabled: !m,
17
+ retry: !1
18
+ }), c = (a == null ? void 0 : a.display_template) ?? null, { data: n, isLoading: p } = f({
19
+ queryKey: ["relation-item", t, String(e)],
20
+ queryFn: () => r ? o.request(u(`/users/${e}`)).then((i) => i.data) : o.request(u(`/items/${t}/${e}`, { fields: "*" })).then((i) => i.data),
21
+ enabled: l && (r || !m),
22
+ staleTime: 1800 * 1e3,
23
+ retry: !1
24
+ });
25
+ if (!l)
26
+ return /* @__PURE__ */ s("span", { className: "text-slate-300", children: "—" });
27
+ if (p)
28
+ return /* @__PURE__ */ s(x, { className: "h-3.5 w-24 rounded" });
29
+ const S = n ? r ? _(n) : h(c, n) : String(e);
30
+ return /* @__PURE__ */ s("span", { className: "text-[12px] text-slate-700", children: S ?? /* @__PURE__ */ s("span", { className: "font-mono text-slate-400", children: String(e) }) });
31
+ }
32
+ export {
33
+ O as RelationLabel
34
+ };