@nivaro/react 0.2.50 → 0.2.52

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 (121) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +204 -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 +4117 -3882
  8. package/dist/shared/components/RecordDrilldownSheet.js +114 -97
  9. package/dist/shared/components/RecordReadView.js +662 -596
  10. package/dist/shared/components/ai/ExplainButton.js +1 -1
  11. package/dist/shared/components/chat/ChatPanel.js +1053 -993
  12. package/dist/shared/components/import/DocumentAutofillButton.js +141 -129
  13. package/dist/shared/components/item-edit/GroupSection.js +489 -466
  14. package/dist/shared/components/item-edit/HeaderBand.js +47 -44
  15. package/dist/shared/components/item-edit/M2MStagingContext.js +3 -3
  16. package/dist/shared/components/item-edit/O2MStagingContext.js +1 -1
  17. package/dist/shared/components/item-edit/RecordGrantTools.js +206 -0
  18. package/dist/shared/components/item-edit/StepsBar.js +49 -43
  19. package/dist/shared/components/item-edit/SummaryPanel.js +2 -1
  20. package/dist/shared/components/item-edit/config-update.js +6 -0
  21. package/dist/shared/components/item-edit/layout-editing-quiet.js +25 -0
  22. package/dist/shared/components/layout-editor/AddPanel.js +301 -0
  23. package/dist/shared/components/layout-editor/DesignNode.js +173 -0
  24. package/dist/shared/components/layout-editor/EditorCanvas.js +52 -0
  25. package/dist/shared/components/layout-editor/EditorTopBar.js +241 -0
  26. package/dist/shared/components/layout-editor/HistoryPanel.js +179 -0
  27. package/dist/shared/components/layout-editor/LayoutEditor.js +393 -0
  28. package/dist/shared/components/layout-editor/LayoutsRail.js +89 -0
  29. package/dist/shared/components/layout-editor/add-target.js +103 -0
  30. package/dist/shared/components/layout-editor/bundle-to-active.js +86 -0
  31. package/dist/shared/components/layout-editor/canvases/PdfCanvas.js +90 -0
  32. package/dist/shared/components/layout-editor/canvases/TableColumnsCanvas.js +246 -0
  33. package/dist/shared/components/layout-editor/collection-meta.js +22 -0
  34. package/dist/shared/components/layout-editor/design-canvas.js +81 -0
  35. package/dist/shared/components/layout-editor/design-context.js +21 -0
  36. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +225 -0
  37. package/dist/shared/components/layout-editor/dnd/collision.js +107 -0
  38. package/dist/shared/components/layout-editor/dnd/node.js +164 -0
  39. package/dist/shared/components/layout-editor/dnd/order.js +122 -0
  40. package/dist/shared/components/layout-editor/editors/DefaultValuesEditor.js +223 -0
  41. package/dist/shared/components/layout-editor/editors/QuickPickerStepsEditor.js +129 -0
  42. package/dist/shared/components/layout-editor/editors/ReadPresentationEditor.js +134 -0
  43. package/dist/shared/components/layout-editor/editors/RecordConditionsEditor.js +249 -0
  44. package/dist/shared/components/layout-editor/editors/RolesPicker.js +77 -0
  45. package/dist/shared/components/layout-editor/editors/cascade-filters.js +556 -0
  46. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +150 -0
  47. package/dist/shared/components/layout-editor/editors/controls.js +73 -0
  48. package/dist/shared/components/layout-editor/editors/editor-api.js +21 -0
  49. package/dist/shared/components/layout-editor/editors/editor-queries.js +25 -0
  50. package/dist/shared/components/layout-editor/editors/field-default-value.js +131 -0
  51. package/dist/shared/components/layout-editor/editors/grid-presets.js +310 -0
  52. package/dist/shared/components/layout-editor/editors/inline-display.js +157 -0
  53. package/dist/shared/components/layout-editor/editors/layout-picker.js +80 -0
  54. package/dist/shared/components/layout-editor/editors/layout-rows.js +55 -0
  55. package/dist/shared/components/layout-editor/editors/lock-conditions.js +109 -0
  56. package/dist/shared/components/layout-editor/editors/o2m-agg-field.js +25 -0
  57. package/dist/shared/components/layout-editor/editors/pdf-field-config.js +107 -0
  58. package/dist/shared/components/layout-editor/editors/report-widget-config.js +94 -0
  59. package/dist/shared/components/layout-editor/editors/row-rule-check.js +225 -0
  60. package/dist/shared/components/layout-editor/editors/row-rule-row.js +1353 -0
  61. package/dist/shared/components/layout-editor/editors/swap-config.js +245 -0
  62. package/dist/shared/components/layout-editor/focus-buffer.js +32 -0
  63. package/dist/shared/components/layout-editor/host.js +15 -0
  64. package/dist/shared/components/layout-editor/inspector/AdvancedTab.js +296 -0
  65. package/dist/shared/components/layout-editor/inspector/GridTab.js +767 -0
  66. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +456 -0
  67. package/dist/shared/components/layout-editor/inspector/HeaderItemInspector.js +268 -0
  68. package/dist/shared/components/layout-editor/inspector/Inspector.js +332 -0
  69. package/dist/shared/components/layout-editor/inspector/LookTab.js +310 -0
  70. package/dist/shared/components/layout-editor/inspector/PickerTab.js +333 -0
  71. package/dist/shared/components/layout-editor/inspector/RulesTab.js +323 -0
  72. package/dist/shared/components/layout-editor/inspector/SlotInspector.js +179 -0
  73. package/dist/shared/components/layout-editor/inspector/SubtitleInspector.js +154 -0
  74. package/dist/shared/components/layout-editor/inspector/WidgetInspector.js +262 -0
  75. package/dist/shared/components/layout-editor/inspector/applies.js +27 -0
  76. package/dist/shared/components/layout-editor/inspector/field-context.js +134 -0
  77. package/dist/shared/components/layout-editor/inspector/interfaces.js +126 -0
  78. package/dist/shared/components/layout-editor/inspector/kit.js +595 -0
  79. package/dist/shared/components/layout-editor/inspector/model.js +307 -0
  80. package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -0
  81. package/dist/shared/components/layout-editor/overview/describe-conditions.js +121 -0
  82. package/dist/shared/components/layout-editor/overview/overview-api.js +141 -0
  83. package/dist/shared/components/layout-editor/overview/purpose.js +62 -0
  84. package/dist/shared/components/layout-editor/overview/record-count.js +65 -0
  85. package/dist/shared/components/layout-editor/panel-frame.js +99 -0
  86. package/dist/shared/components/layout-editor/panel-style.js +19 -0
  87. package/dist/shared/components/layout-editor/pickers/field-picker.js +230 -0
  88. package/dist/shared/components/layout-editor/pickers/icon-picker.js +233 -0
  89. package/dist/shared/components/layout-editor/pickers/relation-label.js +34 -0
  90. package/dist/shared/components/layout-editor/pickers/relation-picker.js +136 -0
  91. package/dist/shared/components/layout-editor/record-queries.js +15 -0
  92. package/dist/shared/components/layout-editor/settings/AddendumSection.js +52 -0
  93. package/dist/shared/components/layout-editor/settings/ButtonsSection.js +45 -0
  94. package/dist/shared/components/layout-editor/settings/DefaultsSection.js +67 -0
  95. package/dist/shared/components/layout-editor/settings/FormSettings.js +146 -0
  96. package/dist/shared/components/layout-editor/settings/InheritanceSection.js +37 -0
  97. package/dist/shared/components/layout-editor/settings/LayoutSection.js +70 -0
  98. package/dist/shared/components/layout-editor/settings/PdfSection.js +176 -0
  99. package/dist/shared/components/layout-editor/settings/ReadSection.js +79 -0
  100. package/dist/shared/components/layout-editor/settings/TextSetting.js +55 -0
  101. package/dist/shared/components/layout-editor/settings/ToggleSetting.js +33 -0
  102. package/dist/shared/components/layout-editor/settings/ToolsSection.js +179 -0
  103. package/dist/shared/components/layout-editor/settings/WhoSection.js +213 -0
  104. package/dist/shared/components/layout-editor/settings/controls.js +214 -0
  105. package/dist/shared/components/layout-editor/settings/section-props.js +17 -0
  106. package/dist/shared/components/layout-editor/settings/settings-api.js +151 -0
  107. package/dist/shared/components/layout-editor/settings/settings-registry.js +445 -0
  108. package/dist/shared/components/layout-editor/slot-names.js +20 -0
  109. package/dist/shared/components/layout-editor/summary-pref.js +21 -0
  110. package/dist/shared/components/layout-editor/useLayoutDraft.js +474 -0
  111. package/dist/shared/components/pipeline/relations.js +28 -23
  112. package/dist/shared/components/ui/dialog.js +11 -11
  113. package/dist/shared/components/ui/popover.js +17 -17
  114. package/dist/shared/components/ui/scroll-area.js +38 -0
  115. package/dist/shared/hooks/useRelationOptions.js +60 -0
  116. package/dist/shared/lib/layout-grants.js +9 -0
  117. package/dist/shared/lib/layout-ops.js +348 -0
  118. package/dist/shared/lib/layout-slots.js +11 -7
  119. package/dist/shared/lib/presence-state.js +43 -13
  120. package/dist/shared/lib/request-gate.js +1 -1
  121. package/package.json +5 -1
@@ -0,0 +1,38 @@
1
+ import { jsxs as d, jsx as e } from "react/jsx-runtime";
2
+ import * as r from "@radix-ui/react-scroll-area";
3
+ import * as s from "react";
4
+ import { cn as t } from "../../lib/utils.js";
5
+ const m = s.forwardRef(({ className: o, children: l, ...a }, c) => /* @__PURE__ */ d(
6
+ r.Root,
7
+ {
8
+ ref: c,
9
+ className: t("relative overflow-hidden", o),
10
+ ...a,
11
+ children: [
12
+ /* @__PURE__ */ e(r.Viewport, { className: "h-full w-full rounded-[inherit]", children: l }),
13
+ /* @__PURE__ */ e(i, {}),
14
+ /* @__PURE__ */ e(r.Corner, {})
15
+ ]
16
+ }
17
+ ));
18
+ m.displayName = r.Root.displayName;
19
+ const i = s.forwardRef(({ className: o, orientation: l = "vertical", ...a }, c) => /* @__PURE__ */ e(
20
+ r.ScrollAreaScrollbar,
21
+ {
22
+ ref: c,
23
+ orientation: l,
24
+ className: t(
25
+ "flex touch-none select-none transition-colors",
26
+ l === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]",
27
+ l === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]",
28
+ o
29
+ ),
30
+ ...a,
31
+ children: /* @__PURE__ */ e(r.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-border" })
32
+ }
33
+ ));
34
+ i.displayName = r.ScrollAreaScrollbar.displayName;
35
+ export {
36
+ m as ScrollArea,
37
+ i as ScrollBar
38
+ };
@@ -0,0 +1,60 @@
1
+ import { useState as b, useRef as O, useEffect as q } from "react";
2
+ import { get as I } from "../lib/commands.js";
3
+ function R(e, t, s) {
4
+ if (t) {
5
+ let r = !1;
6
+ const o = t.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (c, f) => {
7
+ let i = S(e, f);
8
+ return (i == null || i === "") && f.includes(".") && (i = S(e, f.split(".").pop())), i != null && i !== "" ? (r = !0, String(i)) : "";
9
+ }).replace(/\s+/g, " ").trim();
10
+ if (r && o) return o;
11
+ }
12
+ for (const r of ["name", "title", "label", "display_name"]) {
13
+ const n = e[r];
14
+ if (typeof n == "string" && n.trim()) return n;
15
+ }
16
+ const u = /* @__PURE__ */ new Set(["id", "uuid", "_id", "created", "changed", "updated", "deleted"]);
17
+ for (const [r, n] of Object.entries(e))
18
+ if (!(u.has(r) || r.endsWith("_at") || r.endsWith("_id") || r === "machine_name") && typeof n == "string" && n.trim() && !/^[a-z0-9_-]+$/.test(n))
19
+ return n;
20
+ return String(s ?? "");
21
+ }
22
+ function S(e, t) {
23
+ return t.split(".").reduce((s, u) => {
24
+ if (s && typeof s == "object") return s[u];
25
+ }, e);
26
+ }
27
+ function j(e) {
28
+ const t = e.id ?? e.uuid ?? e._id;
29
+ return typeof t == "string" || typeof t == "number" ? t : String(t ?? "");
30
+ }
31
+ function $(e, t, s) {
32
+ const { search: u, limit: r = 50, displayTemplate: n = null, enabled: o = !0, filter: c } = s ?? {}, [f, i] = b([]), [v, d] = b(!1), [k, h] = b(null), m = O(0);
33
+ return q(() => {
34
+ if (!e || !t || !o) {
35
+ d(!1);
36
+ return;
37
+ }
38
+ const _ = ++m.current;
39
+ let g = !0;
40
+ d(!0), h(null);
41
+ const y = { limit: r };
42
+ return u && (y.search = u), c && (y.filter = JSON.stringify(c)), e.request(I(`/items/${t}`, y)).then((a) => {
43
+ if (!g || _ !== m.current) return;
44
+ const E = a.data ?? [];
45
+ i(
46
+ E.map((l) => {
47
+ const p = j(l);
48
+ return { id: p, label: R(l, n, p), raw: l };
49
+ }).sort((l, p) => l.label.localeCompare(p.label))
50
+ ), d(!1);
51
+ }).catch((a) => {
52
+ !g || _ !== m.current || (h(a instanceof Error ? a : new Error(String(a))), d(!1));
53
+ }), () => {
54
+ g = !1;
55
+ };
56
+ }, [e, t, u, r, n, o, c]), { options: f, loading: v, error: k };
57
+ }
58
+ export {
59
+ $ as useRelationOptions
60
+ };
@@ -0,0 +1,9 @@
1
+ function s(e, r) {
2
+ return {
3
+ schedule: r || !!(e != null && e.allow_schedule),
4
+ disablePickers: r || !!(e != null && e.allow_disable_pickers)
5
+ };
6
+ }
7
+ export {
8
+ s as layoutGrantedTools
9
+ };
@@ -0,0 +1,348 @@
1
+ var j = Object.defineProperty;
2
+ var L = (t, e, o) => e in t ? j(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var x = (t, e, o) => L(t, typeof e != "symbol" ? e + "" : e, o);
4
+ const P = [
5
+ "label_override",
6
+ "is_visible",
7
+ "default_expanded",
8
+ "col_span",
9
+ "overrides",
10
+ "show_row_revisions",
11
+ "allow_revision_restore",
12
+ "lock_conditions",
13
+ "input_bindings",
14
+ "widget_id",
15
+ "show_approval_chain"
16
+ ], Y = [
17
+ "label",
18
+ "type",
19
+ "icon",
20
+ "is_collapsed",
21
+ "tab_mode",
22
+ "hide_when_empty",
23
+ "visibility_mode",
24
+ "summary_fields",
25
+ "summary_hide_empty",
26
+ "swap_config",
27
+ "skip_if_filled",
28
+ "content",
29
+ "content_tone",
30
+ "visible_when",
31
+ "hidden_for_roles",
32
+ "locked_for_roles",
33
+ "read_width"
34
+ ], z = [
35
+ "name",
36
+ "slug",
37
+ "create_label",
38
+ "create_hidden",
39
+ "sort",
40
+ "is_active",
41
+ "disable_comments",
42
+ "disable_tasks",
43
+ "tab_mode",
44
+ "validate_before_next",
45
+ "summary_enabled",
46
+ "summary_hide_empty",
47
+ "ai_enabled",
48
+ "accordion_mode",
49
+ "disable_revisions",
50
+ "disable_clone",
51
+ "disable_delete",
52
+ "row_order_field",
53
+ "pdf_theme",
54
+ "pdf_template_id",
55
+ "pdf_cover_enabled",
56
+ "pdf_cover_title_field",
57
+ "pdf_cover_subtitle",
58
+ "pdf_show_logo",
59
+ "pdf_page_size",
60
+ "pdf_orientation",
61
+ "pdf_button_label",
62
+ "conditions",
63
+ "allow_schedule",
64
+ "allow_disable_pickers",
65
+ "layout_type",
66
+ "addendum_layout_id",
67
+ "workflow_template_id",
68
+ "single_active_addendum",
69
+ "addendum_default_view",
70
+ "record_conditions",
71
+ "default_values",
72
+ "display_mode",
73
+ "parent_layout_id",
74
+ "hide_integrity_banner",
75
+ "hide_sla_banner",
76
+ "changes_tray",
77
+ "dossier_enabled",
78
+ "dossier_label",
79
+ "quick_picker",
80
+ "sheet_width",
81
+ "header_fields",
82
+ "hide_empty"
83
+ ], m = ["section", "tab", "metadata", "container", "content"], d = "__ungrouped__", C = "__header__", F = [
84
+ "__apply_values__",
85
+ "__create_with_defaults__"
86
+ ], I = [
87
+ "__pipeline__",
88
+ "__tasks__",
89
+ "__comments__",
90
+ "__addendums__",
91
+ "__referenced_by__",
92
+ "__related_records__"
93
+ ], U = /^__ext_[a-z][a-z0-9-]{1,60}__$/, G = ["__ungrouped_pos__"], D = /* @__PURE__ */ new Map([
94
+ [d, 1],
95
+ ["__pipeline__", 2],
96
+ ["__tasks__", 3],
97
+ ["__comments__", 4],
98
+ ["__owners__", 5],
99
+ ["__pdf__", 6],
100
+ ["__addendums__", 7],
101
+ ["__referenced_by__", 8],
102
+ ["__related_records__", 9]
103
+ ]), R = (t) => D.get(t) ?? (U.test(t) ? 8 : 0);
104
+ class M extends Error {
105
+ constructor(o, s) {
106
+ super(o);
107
+ x(this, "op_index");
108
+ this.name = "LayoutOpError", this.op_index = s;
109
+ }
110
+ }
111
+ function f(t) {
112
+ return t.group_key !== null ? !1 : I.includes(t.field) || t.field === "__owners__" || t.field === "__pdf__" || U.test(t.field);
113
+ }
114
+ function H(t, e) {
115
+ return {
116
+ field: t,
117
+ group_key: e,
118
+ sort: 0,
119
+ label_override: null,
120
+ is_visible: !0,
121
+ default_expanded: !0,
122
+ col_span: null,
123
+ overrides: null,
124
+ show_row_revisions: !1,
125
+ allow_revision_restore: !0,
126
+ lock_conditions: null,
127
+ input_bindings: null,
128
+ widget_id: null,
129
+ show_approval_chain: !1
130
+ };
131
+ }
132
+ function K(t, e, o, s) {
133
+ return {
134
+ key: t,
135
+ label: e,
136
+ type: o,
137
+ parent_key: s,
138
+ sort: 0,
139
+ icon: null,
140
+ is_collapsed: !1,
141
+ tab_mode: null,
142
+ hide_when_empty: !1,
143
+ visibility_mode: "always",
144
+ summary_fields: null,
145
+ summary_hide_empty: !1,
146
+ swap_config: null,
147
+ skip_if_filled: null,
148
+ content: null,
149
+ content_tone: null,
150
+ visible_when: null,
151
+ hidden_for_roles: null,
152
+ locked_for_roles: null,
153
+ read_width: null
154
+ };
155
+ }
156
+ 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);
157
+ function V(t) {
158
+ return {
159
+ ...t,
160
+ groups: [...t.groups].sort(
161
+ (e, o) => g(e.parent_key ?? "", o.parent_key ?? "") || e.sort - o.sort || h(e, o) || g(e.key, o.key)
162
+ ),
163
+ placements: [...t.placements].sort(
164
+ (e, o) => g(e.group_key ?? "", o.group_key ?? "") || e.sort - o.sort || h(e, o) || g(e.field, o.field)
165
+ )
166
+ };
167
+ }
168
+ function p(t, e) {
169
+ return t.placements.map((o, s) => ({ p: o, i: s })).filter(({ p: o }) => o.group_key === e && !f(o)).sort((o, s) => o.p.sort - s.p.sort || h(o.p, s.p) || o.i - s.i).map(({ p: o }) => o);
170
+ }
171
+ function u(t, e) {
172
+ const o = [];
173
+ return t.groups.forEach((s, _) => {
174
+ s.parent_key === e && o.push({ m: s, tie: R(s.key), i: _ });
175
+ }), e === null && t.placements.forEach((s, _) => {
176
+ f(s) && o.push({ m: s, tie: R(s.field), i: t.groups.length + _ });
177
+ }), o.sort((s, _) => s.m.sort - _.m.sort || s.tie - _.tie || h(s.m, _.m) || s.i - _.i).map((s) => s.m);
178
+ }
179
+ function c(t) {
180
+ t.forEach((e, o) => {
181
+ e.sort = o;
182
+ });
183
+ }
184
+ function X(t) {
185
+ const e = /* @__PURE__ */ new Set();
186
+ for (const s of t.placements) f(s) || e.add(s.group_key);
187
+ for (const s of e) c(p(t, s));
188
+ const o = /* @__PURE__ */ new Set([null]);
189
+ for (const s of t.groups) o.add(s.parent_key);
190
+ for (const s of o) c(u(t, s));
191
+ }
192
+ function W(t, e) {
193
+ const o = {
194
+ layout: { ...t.layout },
195
+ groups: t.groups.map((s) => ({ ...s })),
196
+ placements: t.placements.map((s) => ({ ...s }))
197
+ };
198
+ if (!Array.isArray(e)) throw new M("ops must be an array", 0);
199
+ return e.forEach((s, _) => {
200
+ B(o, s, _), X(o);
201
+ }), V({ ...o, rev: t.rev });
202
+ }
203
+ function B(t, e, o) {
204
+ const s = (n) => {
205
+ throw new M(n, o);
206
+ };
207
+ (!e || typeof e != "object") && s("Each op must be an object");
208
+ const _ = (n, r, i) => {
209
+ (typeof i != "number" || !Number.isFinite(i)) && s("index must be a number");
210
+ const l = Math.max(0, Math.min(n.length, Math.floor(i)));
211
+ return [...n.slice(0, l), r, ...n.slice(l)];
212
+ }, y = (n, r) => {
213
+ if (n == null) return {};
214
+ (typeof n != "object" || Array.isArray(n)) && s("patch must be an object");
215
+ for (const i of Object.keys(n))
216
+ r.includes(i) || s(`Unknown setting "${i}"`);
217
+ return n;
218
+ }, A = (n) => {
219
+ const r = y(n, Y);
220
+ return r.type !== void 0 && !m.includes(r.type) && s(`Group type must be one of ${m.join(", ")}`), r.read_width != null && !["full", "half", "third"].includes(r.read_width) && s("read_width must be 'full', 'half', 'third' or null"), r;
221
+ }, k = (n) => {
222
+ (!n || typeof n.field != "string") && s("A placement needs a field");
223
+ const r = n;
224
+ G.includes(r.field) && s(`"${r.field}" is a reserved name`);
225
+ const i = t.placements.find(
226
+ (l) => l.field === r.field && l.group_key === (r.group_key ?? null)
227
+ );
228
+ return i || s(`"${r.field}" is not placed in ${r.group_key ?? "Ungrouped"}`), i;
229
+ }, b = (n) => {
230
+ n === d && s("The Ungrouped zone can only be moved");
231
+ const r = t.groups.find((i) => i.key === n);
232
+ return r || s(`No group "${String(n)}"`), r;
233
+ }, O = (n) => {
234
+ if (n === null || n === C || t.layout.layout_type === "table" && F.includes(n)) return;
235
+ const r = t.groups.find((i) => i.key === n);
236
+ (!r || r.key === d) && s(`No group "${n}"`), r.type === "container" && s("Fields go in the tabs of a container"), r.type === "content" && s("A text block holds text, not fields");
237
+ }, S = (n, r) => {
238
+ if (n === null) return;
239
+ const i = t.groups.find((l) => l.key === n);
240
+ (i == null ? void 0 : i.type) !== "container" && s(`"${n}" is not a container`), r !== "tab" && s("Only tabs go inside a container");
241
+ }, $ = (n, r) => {
242
+ const i = f(n) ? u(t, null).filter((l) => l !== n) : p(t, n.group_key).filter((l) => l !== n);
243
+ c(_(i, n, r));
244
+ };
245
+ switch (e.op) {
246
+ case "place": {
247
+ (typeof e.field != "string" || !e.field) && s("place needs a field"), G.includes(e.field) && s(`"${e.field}" is a reserved name`);
248
+ const n = e.group_key ?? null;
249
+ O(n), t.placements.some((i) => i.field === e.field && i.group_key === n) && s(`"${e.field}" is already in ${n ?? "Ungrouped"}`);
250
+ const r = {
251
+ ...H(e.field, n),
252
+ ...y(e.patch, P)
253
+ };
254
+ t.placements.push(r), $(r, e.index);
255
+ return;
256
+ }
257
+ case "move": {
258
+ const n = k(e.from), r = e.to_group_key ?? null;
259
+ r !== n.group_key && (O(r), t.placements.some((i) => i.field === n.field && i.group_key === r) && s(`"${n.field}" is already in ${r ?? "Ungrouped"}`), n.group_key = r), $(n, e.index);
260
+ return;
261
+ }
262
+ case "update_placement": {
263
+ const n = k(e.at);
264
+ Object.assign(n, y(e.patch, P));
265
+ return;
266
+ }
267
+ case "remove": {
268
+ const n = k(e.at);
269
+ t.placements = t.placements.filter((r) => r !== n);
270
+ return;
271
+ }
272
+ case "group_create": {
273
+ (typeof e.key != "string" || !e.key.trim()) && s("A group needs a key"), e.key.startsWith("__") && s("Group keys starting with __ are reserved"), t.groups.some((v) => v.key === e.key) && s(`A group "${e.key}" already exists`), typeof e.label != "string" && s("A group needs a label");
274
+ const n = A(e.patch), r = n.type ?? e.group_type;
275
+ m.includes(r) || s(`Group type must be one of ${m.join(", ")}`);
276
+ const i = e.parent_key ?? null;
277
+ S(i, r);
278
+ const l = { ...K(e.key, e.label, r, i), ...n }, w = u(t, i);
279
+ t.groups.push(l), c(_(w, l, e.index));
280
+ return;
281
+ }
282
+ case "group_update": {
283
+ const n = b(e.key), r = A(e.patch);
284
+ r.type !== void 0 && r.type !== n.type && (n.parent_key !== null && r.type !== "tab" && s("Only tabs go inside a container"), n.type === "container" && t.groups.some((i) => i.parent_key === n.key) && s("Move the tabs out of this container first"), (r.type === "container" || r.type === "content") && p(t, n.key).length && s("Move the fields out of this section first")), Object.assign(n, r);
285
+ return;
286
+ }
287
+ case "group_move": {
288
+ const n = e.parent_key ?? null;
289
+ let r;
290
+ if (e.key === d || f({ field: e.key, group_key: null })) {
291
+ n !== null && s("This stays at the top level of the form");
292
+ const i = e.key === d ? t.groups.find((l) => l.key === d) : t.placements.find((l) => l.field === e.key && l.group_key === null);
293
+ i || s(`"${e.key}" is not on this form`), r = i;
294
+ } else {
295
+ const i = b(e.key);
296
+ S(n, i.type), i.parent_key = n, r = i;
297
+ }
298
+ c(
299
+ _(
300
+ u(t, n).filter((i) => i !== r),
301
+ r,
302
+ e.index
303
+ )
304
+ );
305
+ return;
306
+ }
307
+ case "group_remove": {
308
+ const n = b(e.key);
309
+ e.placements !== "ungroup" && e.placements !== "delete" && s("placements must be 'ungroup' or 'delete'");
310
+ const r = u(t, n.parent_key), i = u(t, n.key);
311
+ for (const a of i) a.parent_key = n.parent_key;
312
+ const l = r.indexOf(n);
313
+ c([...r.slice(0, l), ...i, ...r.slice(l + 1)]), t.groups = t.groups.filter((a) => a !== n);
314
+ const w = p(t, n.key);
315
+ if (t.placements = t.placements.filter((a) => a.group_key !== n.key), e.placements === "delete") return;
316
+ const v = p(t, null), N = u(t, null), E = w.filter(
317
+ (a) => !t.placements.some((T) => T.field === a.field && T.group_key === null)
318
+ );
319
+ for (const a of E)
320
+ a.group_key = null, t.placements.push(a);
321
+ c([...v, ...E.filter((a) => !f(a))]), c([...N, ...E.filter((a) => f(a))]);
322
+ return;
323
+ }
324
+ case "layout_update": {
325
+ Object.assign(t.layout, y(e.patch, z));
326
+ return;
327
+ }
328
+ default:
329
+ s(`Unknown op "${String(e.op)}"`);
330
+ }
331
+ }
332
+ export {
333
+ I as CANVAS_SLOT_KEYS,
334
+ Y as GROUP_PATCH_KEYS,
335
+ m as GROUP_TYPES,
336
+ C as HEADER_GROUP_KEY,
337
+ z as LAYOUT_PATCH_KEYS,
338
+ M as LayoutOpError,
339
+ P as PLACEMENT_PATCH_KEYS,
340
+ G as RESERVED_FIELDS,
341
+ F as TABLE_FORM_GROUP_KEYS,
342
+ d as UNGROUPED_KEY,
343
+ W as applyLayoutOps,
344
+ f as isCanvasSlot,
345
+ K as newGroup,
346
+ H as newPlacement,
347
+ V as sortBundleRows
348
+ };
@@ -1,17 +1,21 @@
1
- const o = /* @__PURE__ */ new Map();
1
+ const e = /* @__PURE__ */ new Map();
2
2
  function n(t) {
3
- !(t != null && t.key) || typeof t.mount != "function" || /^[a-z][a-z0-9-]{1,60}$/.test(t.key) && o.set(t.key, t);
3
+ !(t != null && t.key) || typeof t.mount != "function" || /^[a-z][a-z0-9-]{1,60}$/.test(t.key) && e.set(t.key, t);
4
4
  }
5
5
  function r(t) {
6
- return t ? o.get(t) ?? null : null;
6
+ return t ? e.get(t) ?? null : null;
7
7
  }
8
- function f(t) {
9
- const e = t.match(/^__ext_([a-z][a-z0-9-]{1,60})__$/);
10
- return e ? e[1] : null;
8
+ function f() {
9
+ return [...e.keys()].sort();
10
+ }
11
+ function u(t) {
12
+ const o = t.match(/^__ext_([a-z][a-z0-9-]{1,60})__$/);
13
+ return o ? o[1] : null;
11
14
  }
12
15
  typeof window < "u" && (window.__nvrRegisterLayoutSlot = n);
13
16
  export {
14
- f as extSlotKey,
17
+ u as extSlotKey,
15
18
  r as getLayoutSlot,
19
+ f as listLayoutSlots,
16
20
  n as registerLayoutSlot
17
21
  };
@@ -1,19 +1,49 @@
1
- function a(e) {
2
- const t = Math.max(0, Math.floor(e.minutes)), n = t >= 60 ? `${Math.floor(t / 60)}h ${t % 60}m` : `${t}m`;
3
- return e.label ? `stuck on ${e.label} for ${n}` : `stuck for ${n}`;
1
+ function $(n) {
2
+ const t = Math.max(0, Math.floor(n.minutes)), e = t >= 60 ? `${Math.floor(t / 60)}h ${t % 60}m` : `${t}m`;
3
+ return n.label ? `stuck on ${n.label} for ${e}` : `stuck for ${e}`;
4
4
  }
5
- function s(e) {
6
- if (!e) return null;
7
- const t = e.split("?")[0].split("/").filter(Boolean);
5
+ function m(n) {
6
+ if (!n) return null;
7
+ const t = n.split("?")[0].split("/").filter(Boolean);
8
8
  if (t.length === 0) return "Home";
9
- const n = /* @__PURE__ */ new Set(["records", "collections", "p"]), o = t.filter((r) => !n.has(r));
10
- return o.length === 0 ? "Home" : o.map((r, l) => l === 0 ? r.replace(/[-_]/g, " ").replace(/\b\w/g, (i) => i.toUpperCase()) : r).join(" › ");
9
+ const e = /* @__PURE__ */ new Set(["records", "collections", "p"]), o = t.filter((l) => !e.has(l));
10
+ return o.length === 0 ? "Home" : o.map((l, r) => r === 0 ? l.replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()) : l).join(" › ");
11
11
  }
12
- function c(e) {
13
- return e.online ? e.away ? "away" : (e.idle_minutes ?? 0) >= 5 ? "idle" : "online" : "offline";
12
+ const a = /* @__PURE__ */ new Set(["API", "admin"]);
13
+ function d(n, t, e, o, l) {
14
+ if (!n || !n.startsWith("/") || n.startsWith("//") || /[\\\s]/.test(n)) return null;
15
+ const r = n.split("#")[0], c = /^\/(?:records|collections)\/([A-Za-z0-9_]+)\/([^/?#]+)/.exec(r);
16
+ let s = null;
17
+ c && c[2] !== "new" && o && (s = o(c[1], encodeURIComponent(c[2])));
18
+ const i = (e == null ? void 0 : e.replace(/\/$/, "")) ?? "";
19
+ let u = null;
20
+ try {
21
+ u = i && l ? new URL(i, l).origin : null;
22
+ } catch {
23
+ u = null;
24
+ }
25
+ const f = !!u && u === l;
26
+ return s || (t && a.has(t) ? s = f ? r : i ? `${i}${r}` : null : s = f ? null : r), p(s, l, u);
27
+ }
28
+ function p(n, t, e) {
29
+ if (!n || !t) return null;
30
+ try {
31
+ const o = new URL(n, t);
32
+ return o.protocol !== "http:" && o.protocol !== "https:" ? null : o.origin === t || o.origin === e ? n : null;
33
+ } catch {
34
+ return null;
35
+ }
36
+ }
37
+ function h(n, t) {
38
+ return /^https?:\/\//i.test(n) ? n : `${typeof window > "u" ? "" : window.location.origin}${n}`;
39
+ }
40
+ function w(n) {
41
+ return n.online ? n.away ? "away" : (n.idle_minutes ?? 0) >= 5 ? "idle" : "online" : "offline";
14
42
  }
15
43
  export {
16
- c as presenceWord,
17
- s as prettyPagePath,
18
- a as stuckText
44
+ h as fullHref,
45
+ d as presencePlaceHref,
46
+ w as presenceWord,
47
+ m as prettyPagePath,
48
+ $ as stuckText
19
49
  };
@@ -167,7 +167,7 @@ function H(e) {
167
167
  }), u === void 0 && (u = setTimeout(l, Z));
168
168
  });
169
169
  }
170
- const O = 3e3, W = /^\/(collections\/[A-Za-z_][A-Za-z0-9_-]*|field-config\/[A-Za-z_][A-Za-z0-9_-]*|collection-layouts(\/active|\/summary\/[A-Za-z_][A-Za-z0-9_-]*)?|chat\/room-types|users\/me)$/, F = /^\/(record-views|item-locks|drafts|presence|rum|comments|notifications|tasks|field-rules\/evaluate|chat\/(?!room-types)|field-config\/[^/]+\/(evaluate-visibility|evaluate-defaults|evaluate-lock|cascade)$|items\/(?!nivaro_|directus_)[^/]+|users\/cards$|files\/verify$)/;
170
+ const O = 3e3, W = /^\/(collections\/[A-Za-z_][A-Za-z0-9_-]*|field-config\/[A-Za-z_][A-Za-z0-9_-]*|collection-layouts(\/active|\/summary\/[A-Za-z_][A-Za-z0-9_-]*)?|chat\/room-types|users\/me)$/, F = /^\/(record-views|item-locks|drafts|presence|rum|comments|notifications|tasks|field-rules\/evaluate|chat\/(?!room-types)|field-config\/[^/]+\/(evaluate-visibility|evaluate-defaults|evaluate-lock|cascade|project)$|items\/(?!nivaro_|directus_)[^/]+|users\/cards$|files\/verify$)/;
171
171
  function K(e) {
172
172
  const o = (e._path ?? "").split("?")[0];
173
173
  return (e._method ?? "GET").toUpperCase() === "POST" && q.test(o) ? !0 : F.test(o);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.2.50",
3
+ "version": "0.2.52",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,6 +11,10 @@
11
11
  "import": "./dist/index.js",
12
12
  "types": "./dist/index.d.ts"
13
13
  },
14
+ "./layout-editor": {
15
+ "import": "./dist/layout-editor.js",
16
+ "types": "./dist/layout-editor.d.ts"
17
+ },
14
18
  "./tailwind-preset": "./tailwind-preset.cjs",
15
19
  "./styles.css": "./styles.css",
16
20
  "./full.css": "./dist/full.css"