@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.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +204 -6
- package/dist/index.js +442 -439
- package/dist/layout-editor.d.ts +80 -0
- package/dist/layout-editor.js +11 -0
- package/dist/shared/components/ItemEditForm.js +4117 -3882
- package/dist/shared/components/RecordDrilldownSheet.js +114 -97
- package/dist/shared/components/RecordReadView.js +662 -596
- package/dist/shared/components/ai/ExplainButton.js +1 -1
- package/dist/shared/components/chat/ChatPanel.js +1053 -993
- package/dist/shared/components/import/DocumentAutofillButton.js +141 -129
- package/dist/shared/components/item-edit/GroupSection.js +489 -466
- package/dist/shared/components/item-edit/HeaderBand.js +47 -44
- package/dist/shared/components/item-edit/M2MStagingContext.js +3 -3
- package/dist/shared/components/item-edit/O2MStagingContext.js +1 -1
- package/dist/shared/components/item-edit/RecordGrantTools.js +206 -0
- package/dist/shared/components/item-edit/StepsBar.js +49 -43
- package/dist/shared/components/item-edit/SummaryPanel.js +2 -1
- package/dist/shared/components/item-edit/config-update.js +6 -0
- package/dist/shared/components/item-edit/layout-editing-quiet.js +25 -0
- package/dist/shared/components/layout-editor/AddPanel.js +301 -0
- package/dist/shared/components/layout-editor/DesignNode.js +173 -0
- package/dist/shared/components/layout-editor/EditorCanvas.js +52 -0
- package/dist/shared/components/layout-editor/EditorTopBar.js +241 -0
- package/dist/shared/components/layout-editor/HistoryPanel.js +179 -0
- package/dist/shared/components/layout-editor/LayoutEditor.js +393 -0
- package/dist/shared/components/layout-editor/LayoutsRail.js +89 -0
- package/dist/shared/components/layout-editor/add-target.js +103 -0
- package/dist/shared/components/layout-editor/bundle-to-active.js +86 -0
- package/dist/shared/components/layout-editor/canvases/PdfCanvas.js +90 -0
- package/dist/shared/components/layout-editor/canvases/TableColumnsCanvas.js +246 -0
- package/dist/shared/components/layout-editor/collection-meta.js +22 -0
- package/dist/shared/components/layout-editor/design-canvas.js +81 -0
- package/dist/shared/components/layout-editor/design-context.js +21 -0
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +225 -0
- package/dist/shared/components/layout-editor/dnd/collision.js +107 -0
- package/dist/shared/components/layout-editor/dnd/node.js +164 -0
- package/dist/shared/components/layout-editor/dnd/order.js +122 -0
- package/dist/shared/components/layout-editor/editors/DefaultValuesEditor.js +223 -0
- package/dist/shared/components/layout-editor/editors/QuickPickerStepsEditor.js +129 -0
- package/dist/shared/components/layout-editor/editors/ReadPresentationEditor.js +134 -0
- package/dist/shared/components/layout-editor/editors/RecordConditionsEditor.js +249 -0
- package/dist/shared/components/layout-editor/editors/RolesPicker.js +77 -0
- package/dist/shared/components/layout-editor/editors/cascade-filters.js +556 -0
- package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +150 -0
- package/dist/shared/components/layout-editor/editors/controls.js +73 -0
- package/dist/shared/components/layout-editor/editors/editor-api.js +21 -0
- package/dist/shared/components/layout-editor/editors/editor-queries.js +25 -0
- package/dist/shared/components/layout-editor/editors/field-default-value.js +131 -0
- package/dist/shared/components/layout-editor/editors/grid-presets.js +310 -0
- package/dist/shared/components/layout-editor/editors/inline-display.js +157 -0
- package/dist/shared/components/layout-editor/editors/layout-picker.js +80 -0
- package/dist/shared/components/layout-editor/editors/layout-rows.js +55 -0
- package/dist/shared/components/layout-editor/editors/lock-conditions.js +109 -0
- package/dist/shared/components/layout-editor/editors/o2m-agg-field.js +25 -0
- package/dist/shared/components/layout-editor/editors/pdf-field-config.js +107 -0
- package/dist/shared/components/layout-editor/editors/report-widget-config.js +94 -0
- package/dist/shared/components/layout-editor/editors/row-rule-check.js +225 -0
- package/dist/shared/components/layout-editor/editors/row-rule-row.js +1353 -0
- package/dist/shared/components/layout-editor/editors/swap-config.js +245 -0
- package/dist/shared/components/layout-editor/focus-buffer.js +32 -0
- package/dist/shared/components/layout-editor/host.js +15 -0
- package/dist/shared/components/layout-editor/inspector/AdvancedTab.js +296 -0
- package/dist/shared/components/layout-editor/inspector/GridTab.js +767 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +456 -0
- package/dist/shared/components/layout-editor/inspector/HeaderItemInspector.js +268 -0
- package/dist/shared/components/layout-editor/inspector/Inspector.js +332 -0
- package/dist/shared/components/layout-editor/inspector/LookTab.js +310 -0
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +333 -0
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +323 -0
- package/dist/shared/components/layout-editor/inspector/SlotInspector.js +179 -0
- package/dist/shared/components/layout-editor/inspector/SubtitleInspector.js +154 -0
- package/dist/shared/components/layout-editor/inspector/WidgetInspector.js +262 -0
- package/dist/shared/components/layout-editor/inspector/applies.js +27 -0
- package/dist/shared/components/layout-editor/inspector/field-context.js +134 -0
- package/dist/shared/components/layout-editor/inspector/interfaces.js +126 -0
- package/dist/shared/components/layout-editor/inspector/kit.js +595 -0
- package/dist/shared/components/layout-editor/inspector/model.js +307 -0
- package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -0
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +121 -0
- package/dist/shared/components/layout-editor/overview/overview-api.js +141 -0
- package/dist/shared/components/layout-editor/overview/purpose.js +62 -0
- package/dist/shared/components/layout-editor/overview/record-count.js +65 -0
- package/dist/shared/components/layout-editor/panel-frame.js +99 -0
- package/dist/shared/components/layout-editor/panel-style.js +19 -0
- package/dist/shared/components/layout-editor/pickers/field-picker.js +230 -0
- package/dist/shared/components/layout-editor/pickers/icon-picker.js +233 -0
- package/dist/shared/components/layout-editor/pickers/relation-label.js +34 -0
- package/dist/shared/components/layout-editor/pickers/relation-picker.js +136 -0
- package/dist/shared/components/layout-editor/record-queries.js +15 -0
- package/dist/shared/components/layout-editor/settings/AddendumSection.js +52 -0
- package/dist/shared/components/layout-editor/settings/ButtonsSection.js +45 -0
- package/dist/shared/components/layout-editor/settings/DefaultsSection.js +67 -0
- package/dist/shared/components/layout-editor/settings/FormSettings.js +146 -0
- package/dist/shared/components/layout-editor/settings/InheritanceSection.js +37 -0
- package/dist/shared/components/layout-editor/settings/LayoutSection.js +70 -0
- package/dist/shared/components/layout-editor/settings/PdfSection.js +176 -0
- package/dist/shared/components/layout-editor/settings/ReadSection.js +79 -0
- package/dist/shared/components/layout-editor/settings/TextSetting.js +55 -0
- package/dist/shared/components/layout-editor/settings/ToggleSetting.js +33 -0
- package/dist/shared/components/layout-editor/settings/ToolsSection.js +179 -0
- package/dist/shared/components/layout-editor/settings/WhoSection.js +213 -0
- package/dist/shared/components/layout-editor/settings/controls.js +214 -0
- package/dist/shared/components/layout-editor/settings/section-props.js +17 -0
- package/dist/shared/components/layout-editor/settings/settings-api.js +151 -0
- package/dist/shared/components/layout-editor/settings/settings-registry.js +445 -0
- package/dist/shared/components/layout-editor/slot-names.js +20 -0
- package/dist/shared/components/layout-editor/summary-pref.js +21 -0
- package/dist/shared/components/layout-editor/useLayoutDraft.js +474 -0
- package/dist/shared/components/pipeline/relations.js +28 -23
- package/dist/shared/components/ui/dialog.js +11 -11
- package/dist/shared/components/ui/popover.js +17 -17
- package/dist/shared/components/ui/scroll-area.js +38 -0
- package/dist/shared/hooks/useRelationOptions.js +60 -0
- package/dist/shared/lib/layout-grants.js +9 -0
- package/dist/shared/lib/layout-ops.js +348 -0
- package/dist/shared/lib/layout-slots.js +11 -7
- package/dist/shared/lib/presence-state.js +43 -13
- package/dist/shared/lib/request-gate.js +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { jsxs as s, jsx as r, Fragment as J } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as V } from "@tanstack/react-query";
|
|
3
|
+
import { Search as X, LayoutPanelTop as Z, CopyPlus as ee, Plus as te, Check as re } from "lucide-react";
|
|
4
|
+
import { useState as D, useMemo as oe } from "react";
|
|
5
|
+
import { useNivaroClient as ae } from "../../context.js";
|
|
6
|
+
import { get as ne } from "../../lib/commands.js";
|
|
7
|
+
import { HEADER_GROUP_KEY as F, isCanvasSlot as ie } from "../../lib/layout-ops.js";
|
|
8
|
+
import { listLayoutSlots as se } from "../../lib/layout-slots.js";
|
|
9
|
+
import { titleCase as E, cn as H } from "../../lib/utils.js";
|
|
10
|
+
import { sectionOp as de, fieldSpot as $, placeOp as I, slotSpot as le } from "./add-target.js";
|
|
11
|
+
import { useAddDragSource as ce } from "./dnd/node.js";
|
|
12
|
+
import { useOverviewFields as pe } from "./overview/overview-api.js";
|
|
13
|
+
import { slotName as w } from "./slot-names.js";
|
|
14
|
+
const ue = [
|
|
15
|
+
"__pipeline__",
|
|
16
|
+
"__comments__",
|
|
17
|
+
"__tasks__",
|
|
18
|
+
"__addendums__",
|
|
19
|
+
"__referenced_by__",
|
|
20
|
+
"__related_records__",
|
|
21
|
+
"__owners__",
|
|
22
|
+
"__pdf__",
|
|
23
|
+
"__subtitle__"
|
|
24
|
+
], U = {
|
|
25
|
+
__pipeline__: "State track and actions",
|
|
26
|
+
__comments__: "Notes and replies",
|
|
27
|
+
__tasks__: "To-dos on this record",
|
|
28
|
+
__addendums__: "Changes made to the saved record",
|
|
29
|
+
__referenced_by__: "Records that point at this one",
|
|
30
|
+
__related_records__: "Records linked to this one",
|
|
31
|
+
__owners__: "Who owns it at each step",
|
|
32
|
+
__pdf__: "Generate and download a PDF",
|
|
33
|
+
__subtitle__: "A line of values under the title"
|
|
34
|
+
}, _e = ["review_list", "rollup"];
|
|
35
|
+
function q(o) {
|
|
36
|
+
return {
|
|
37
|
+
widget_id: o.id,
|
|
38
|
+
input_bindings: _e.includes(o.widget_type) ? [{ key: "record_id", binding_type: "item_field", binding_value: "id" }] : []
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function me(o) {
|
|
42
|
+
const i = o.interface ?? "";
|
|
43
|
+
if (i.includes("o2m") || i === "list-o2m" || i === "inline-grid") return "Grid";
|
|
44
|
+
if (i.includes("m2m") || i.includes("m2a")) return "Several records";
|
|
45
|
+
if (i.includes("m2o")) return "Record";
|
|
46
|
+
switch (o.type) {
|
|
47
|
+
case "string":
|
|
48
|
+
case "uuid":
|
|
49
|
+
return "Text";
|
|
50
|
+
case "text":
|
|
51
|
+
return "Long text";
|
|
52
|
+
case "integer":
|
|
53
|
+
case "bigInteger":
|
|
54
|
+
case "decimal":
|
|
55
|
+
case "float":
|
|
56
|
+
return "Number";
|
|
57
|
+
case "boolean":
|
|
58
|
+
return "Yes / no";
|
|
59
|
+
case "date":
|
|
60
|
+
return "Date";
|
|
61
|
+
case "dateTime":
|
|
62
|
+
case "timestamp":
|
|
63
|
+
return "Date and time";
|
|
64
|
+
case "json":
|
|
65
|
+
return "Data";
|
|
66
|
+
case "alias":
|
|
67
|
+
return "Group";
|
|
68
|
+
default:
|
|
69
|
+
return o.type ? E(o.type) : "";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const ge = "h-8 w-full rounded-md border border-slate-200 bg-white pl-7 pr-2.5 text-[12.5px] text-slate-800 outline-none placeholder:text-slate-400 focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-foreground dark:placeholder:text-muted-foreground", v = "px-2 pb-1 pt-3 text-[11.5px] font-semibold text-slate-500 dark:text-muted-foreground";
|
|
73
|
+
function P({ children: o }) {
|
|
74
|
+
return /* @__PURE__ */ s("span", { className: "inline-flex shrink-0 items-center gap-0.5 text-[11px] font-medium text-[#0089ad] dark:text-nvr-cyan", children: [
|
|
75
|
+
/* @__PURE__ */ r(re, { className: "h-3 w-3" }),
|
|
76
|
+
o
|
|
77
|
+
] });
|
|
78
|
+
}
|
|
79
|
+
function C({
|
|
80
|
+
title: o,
|
|
81
|
+
sub: i,
|
|
82
|
+
aside: l,
|
|
83
|
+
onClick: u,
|
|
84
|
+
attrs: c,
|
|
85
|
+
extra: h,
|
|
86
|
+
drag: x = null
|
|
87
|
+
}) {
|
|
88
|
+
const _ = ce(x), n = /* @__PURE__ */ s(
|
|
89
|
+
"button",
|
|
90
|
+
{
|
|
91
|
+
type: "button",
|
|
92
|
+
..._.props,
|
|
93
|
+
onClick: () => {
|
|
94
|
+
_.clickBlocked() || u();
|
|
95
|
+
},
|
|
96
|
+
...c,
|
|
97
|
+
className: H(
|
|
98
|
+
"group flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted",
|
|
99
|
+
_.dragging && "opacity-40"
|
|
100
|
+
),
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ s("span", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
103
|
+
/* @__PURE__ */ r("span", { className: "truncate text-[12.5px] font-medium text-slate-900 dark:text-foreground", children: o }),
|
|
104
|
+
i && /* @__PURE__ */ r("span", { className: "truncate text-[11.5px] text-slate-500 dark:text-muted-foreground", children: i })
|
|
105
|
+
] }),
|
|
106
|
+
l
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
return h ? /* @__PURE__ */ s("div", { className: "flex items-center gap-0.5", children: [
|
|
111
|
+
n,
|
|
112
|
+
h
|
|
113
|
+
] }) : n;
|
|
114
|
+
}
|
|
115
|
+
function Re({
|
|
116
|
+
bundle: o,
|
|
117
|
+
collection: i,
|
|
118
|
+
selected: l,
|
|
119
|
+
apply: u,
|
|
120
|
+
onSelect: c
|
|
121
|
+
}) {
|
|
122
|
+
const h = ae(), [x, _] = D(""), [n, K] = D("form"), { data: M = [] } = pe(i), { data: Q = [], error: A } = V({
|
|
123
|
+
queryKey: ["layout-editor", "widgets"],
|
|
124
|
+
queryFn: () => h.request(ne("/widgets-internal")).then((e) => e.data ?? []),
|
|
125
|
+
staleTime: 6e4,
|
|
126
|
+
retry: !1
|
|
127
|
+
}), [y, S] = D(null), W = x.trim().toLowerCase(), k = (...e) => !W || e.some((t) => t == null ? void 0 : t.toLowerCase().includes(W)), L = oe(() => {
|
|
128
|
+
const e = /* @__PURE__ */ new Map();
|
|
129
|
+
for (const t of o.placements) e.set(t.field, [...e.get(t.field) ?? [], t]);
|
|
130
|
+
return e;
|
|
131
|
+
}, [o.placements]), b = (e) => (L.get(e) ?? []).find((t) => t.group_key !== F), O = (e) => (L.get(e) ?? []).find((t) => t.group_key === F), N = (e) => e.group_key === F ? { kind: "header", field: e.field } : {
|
|
132
|
+
kind: e.field.startsWith("__") ? "slot" : "field",
|
|
133
|
+
field: e.field,
|
|
134
|
+
group_key: e.group_key
|
|
135
|
+
}, Y = (e, t, a) => {
|
|
136
|
+
const d = n === "header" ? $(o, l, "header") : ie({ field: e, group_key: null }) ? le(o, l) : e === "__subtitle__" ? { group_key: null, index: 0 } : $(o, l);
|
|
137
|
+
u([I(e, d, a)], { label: `Add ${t}` }), c(N({ field: e, group_key: d.group_key }));
|
|
138
|
+
}, R = (e, t, a, d) => a ? null : {
|
|
139
|
+
field: e,
|
|
140
|
+
label: t,
|
|
141
|
+
patch: d,
|
|
142
|
+
to: n,
|
|
143
|
+
onAdded: (f) => {
|
|
144
|
+
const p = f[0];
|
|
145
|
+
(p == null ? void 0 : p.op) === "place" && c(N({ field: e, group_key: p.group_key }));
|
|
146
|
+
}
|
|
147
|
+
}, T = (e, t, a) => {
|
|
148
|
+
S(null);
|
|
149
|
+
const d = n === "header" ? O(e) : b(e);
|
|
150
|
+
d ? c(N(d)) : Y(e, t, a);
|
|
151
|
+
}, z = (e, t) => {
|
|
152
|
+
var d;
|
|
153
|
+
const a = $(o, l);
|
|
154
|
+
if ((L.get(e) ?? []).some((f) => f.group_key === a.group_key)) {
|
|
155
|
+
const f = a.group_key === null ? "Ungrouped" : ((d = o.groups.find((p) => p.key === a.group_key)) == null ? void 0 : d.label) ?? a.group_key;
|
|
156
|
+
S({
|
|
157
|
+
field: e,
|
|
158
|
+
text: `${t} is already in ${f}. Select another section first.`
|
|
159
|
+
});
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
S(null), u([I(e, a)], { label: `Add another ${t}` }), c(N({ field: e, group_key: a.group_key }));
|
|
163
|
+
}, j = M.filter((e) => e.field && !e.field.startsWith("__")).map((e) => ({ ...e, title: e.label || E(e.field) })).filter((e) => k(e.title, e.field)).sort((e, t) => e.title.localeCompare(t.title)), B = [...ue, ...se().map((e) => `__ext_${e}__`)].filter(
|
|
164
|
+
(e) => n === "header" ? e === "__owners__" : !0
|
|
165
|
+
).filter((e) => k(w(e), U[e])), G = Q.filter((e) => k(e.name, e.widget_type)), m = de(o, l), g = m.op === "group_create" ? m.label.replace(/^New /, "") : "";
|
|
166
|
+
return /* @__PURE__ */ s("div", { "data-editor-add": "", className: "flex flex-col px-2 pb-4", children: [
|
|
167
|
+
/* @__PURE__ */ s("div", { className: "sticky top-0 z-10 flex flex-col gap-2 bg-white px-1 pb-1 pt-2 dark:bg-card", children: [
|
|
168
|
+
/* @__PURE__ */ s("div", { className: "relative", children: [
|
|
169
|
+
/* @__PURE__ */ r(X, { className: "pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
|
|
170
|
+
/* @__PURE__ */ r(
|
|
171
|
+
"input",
|
|
172
|
+
{
|
|
173
|
+
value: x,
|
|
174
|
+
onChange: (e) => _(e.target.value),
|
|
175
|
+
placeholder: "Find a field, panel or widget",
|
|
176
|
+
"aria-label": "Find something to add",
|
|
177
|
+
className: ge
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
] }),
|
|
181
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-1 text-[12px] text-slate-500 dark:text-muted-foreground", children: [
|
|
182
|
+
/* @__PURE__ */ r("span", { className: "mr-1", children: "Add to" }),
|
|
183
|
+
["form", "header"].map((e) => /* @__PURE__ */ r(
|
|
184
|
+
"button",
|
|
185
|
+
{
|
|
186
|
+
type: "button",
|
|
187
|
+
"aria-pressed": n === e,
|
|
188
|
+
onClick: () => K(e),
|
|
189
|
+
className: H(
|
|
190
|
+
"rounded-md px-2 py-0.5 font-medium transition-colors",
|
|
191
|
+
n === e ? "bg-accent text-slate-900 dark:text-foreground" : "hover:bg-muted hover:text-slate-800 dark:hover:text-foreground"
|
|
192
|
+
),
|
|
193
|
+
children: e === "form" ? "Form" : "Header strip"
|
|
194
|
+
},
|
|
195
|
+
e
|
|
196
|
+
))
|
|
197
|
+
] })
|
|
198
|
+
] }),
|
|
199
|
+
n === "form" && k(g, "section", "tab", "step") && /* @__PURE__ */ s(J, { children: [
|
|
200
|
+
/* @__PURE__ */ r("p", { className: v, children: "Layout" }),
|
|
201
|
+
/* @__PURE__ */ r(
|
|
202
|
+
C,
|
|
203
|
+
{
|
|
204
|
+
title: g.charAt(0).toUpperCase() + g.slice(1),
|
|
205
|
+
sub: `A new ${g.toLowerCase()} after the selection`,
|
|
206
|
+
attrs: { "data-add-section": "" },
|
|
207
|
+
aside: /* @__PURE__ */ r(Z, { className: "h-3.5 w-3.5 text-slate-400" }),
|
|
208
|
+
onClick: () => {
|
|
209
|
+
u([m], { label: `Add ${g.toLowerCase()}` }), m.op === "group_create" && c({ kind: "group", key: m.key });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
] }),
|
|
214
|
+
/* @__PURE__ */ r("p", { className: v, children: "Fields" }),
|
|
215
|
+
j.map((e) => {
|
|
216
|
+
const t = n === "header" ? O(e.field) : b(e.field);
|
|
217
|
+
return /* @__PURE__ */ s("div", { children: [
|
|
218
|
+
/* @__PURE__ */ r(
|
|
219
|
+
C,
|
|
220
|
+
{
|
|
221
|
+
title: e.title,
|
|
222
|
+
sub: [e.field, me(e)].filter(Boolean).join(" · "),
|
|
223
|
+
attrs: { "data-add-field": e.field, "data-on-form": t ? "true" : void 0 },
|
|
224
|
+
aside: t ? /* @__PURE__ */ r(P, { children: n === "header" ? "in header" : "on this form" }) : /* @__PURE__ */ r(te, { className: "h-3.5 w-3.5 shrink-0 text-slate-400 opacity-0 group-hover:opacity-100" }),
|
|
225
|
+
onClick: () => T(e.field, e.title),
|
|
226
|
+
drag: R(e.field, e.title, t),
|
|
227
|
+
extra: t && n === "form" ? /* @__PURE__ */ r(
|
|
228
|
+
"button",
|
|
229
|
+
{
|
|
230
|
+
type: "button",
|
|
231
|
+
"aria-label": `Add another copy of ${e.title}`,
|
|
232
|
+
"data-add-copy": e.field,
|
|
233
|
+
"data-tip": "Add another copy after the selection",
|
|
234
|
+
onClick: () => z(e.field, e.title),
|
|
235
|
+
className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-slate-400 transition-colors hover:bg-muted hover:text-slate-700 dark:hover:text-foreground",
|
|
236
|
+
children: /* @__PURE__ */ r(ee, { className: "h-3.5 w-3.5" })
|
|
237
|
+
}
|
|
238
|
+
) : null
|
|
239
|
+
}
|
|
240
|
+
),
|
|
241
|
+
(y == null ? void 0 : y.field) === e.field && /* @__PURE__ */ r(
|
|
242
|
+
"p",
|
|
243
|
+
{
|
|
244
|
+
role: "status",
|
|
245
|
+
"data-add-notice": "",
|
|
246
|
+
className: "px-2 pb-1 text-[11.5px] text-amber-700 dark:text-amber-300",
|
|
247
|
+
children: y.text
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
|
+
] }, e.field);
|
|
251
|
+
}),
|
|
252
|
+
!j.length && /* @__PURE__ */ r("p", { className: "px-2 py-1.5 text-[12px] text-slate-500 dark:text-muted-foreground", children: "No fields match." }),
|
|
253
|
+
B.length > 0 && /* @__PURE__ */ r("p", { className: v, children: "Panels" }),
|
|
254
|
+
B.map((e) => {
|
|
255
|
+
const t = n === "header" ? O(e) : b(e), a = e === "__subtitle__" ? {
|
|
256
|
+
input_bindings: [
|
|
257
|
+
{
|
|
258
|
+
key: "__subtitle_config__",
|
|
259
|
+
binding_type: "static",
|
|
260
|
+
binding_value: JSON.stringify({ fields: [], separator: " · " })
|
|
261
|
+
}
|
|
262
|
+
]
|
|
263
|
+
} : void 0;
|
|
264
|
+
return /* @__PURE__ */ r(
|
|
265
|
+
C,
|
|
266
|
+
{
|
|
267
|
+
title: w(e),
|
|
268
|
+
sub: U[e] ?? "Extension panel",
|
|
269
|
+
attrs: { "data-add-slot": e, "data-on-form": t ? "true" : void 0 },
|
|
270
|
+
aside: t ? /* @__PURE__ */ r(P, { children: "on this form" }) : null,
|
|
271
|
+
onClick: () => T(e, w(e), a),
|
|
272
|
+
drag: e === "__subtitle__" ? null : R(e, w(e), t)
|
|
273
|
+
},
|
|
274
|
+
e
|
|
275
|
+
);
|
|
276
|
+
}),
|
|
277
|
+
n === "form" && (G.length > 0 || A) && /* @__PURE__ */ r("p", { className: v, children: "Widgets" }),
|
|
278
|
+
n === "form" && A && /* @__PURE__ */ s("p", { role: "alert", className: "px-2 py-1.5 text-[12px] text-red-700 dark:text-red-300", children: [
|
|
279
|
+
"Widgets could not be loaded: ",
|
|
280
|
+
A.message
|
|
281
|
+
] }),
|
|
282
|
+
n === "form" && G.map((e) => {
|
|
283
|
+
const t = `__widget_${e.id}__`, a = b(t);
|
|
284
|
+
return /* @__PURE__ */ r(
|
|
285
|
+
C,
|
|
286
|
+
{
|
|
287
|
+
title: e.name,
|
|
288
|
+
sub: E(e.widget_type),
|
|
289
|
+
attrs: { "data-add-widget": String(e.id), "data-on-form": a ? "true" : void 0 },
|
|
290
|
+
aside: a ? /* @__PURE__ */ r(P, { children: "on this form" }) : null,
|
|
291
|
+
onClick: () => T(t, e.name, q(e)),
|
|
292
|
+
drag: R(t, e.name, a, q(e))
|
|
293
|
+
},
|
|
294
|
+
e.id
|
|
295
|
+
);
|
|
296
|
+
})
|
|
297
|
+
] });
|
|
298
|
+
}
|
|
299
|
+
export {
|
|
300
|
+
Re as AddPanel
|
|
301
|
+
};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { jsx as u, Fragment as O, jsxs as f } from "react/jsx-runtime";
|
|
2
|
+
import { EyeOff as W, Lock as Z } from "lucide-react";
|
|
3
|
+
import { isValidElement as L, cloneElement as H } from "react";
|
|
4
|
+
import { cn as U } from "../../lib/utils.js";
|
|
5
|
+
import { useLayoutDesign as A, targetKey as j } from "./design-context.js";
|
|
6
|
+
import { useDesignDndNode as V, NO_DND as q, useDesignDropBody as G } from "./dnd/node.js";
|
|
7
|
+
const z = (t, e) => {
|
|
8
|
+
typeof t == "function" ? t(e) : t && typeof t == "object" && (t.current = e);
|
|
9
|
+
};
|
|
10
|
+
function C(...t) {
|
|
11
|
+
const e = {};
|
|
12
|
+
for (const s of t)
|
|
13
|
+
for (const [o, i] of Object.entries(s)) {
|
|
14
|
+
const d = e[o];
|
|
15
|
+
i !== void 0 && (d === void 0 ? e[o] = i : o === "className" ? e[o] = `${d} ${i}` : o === "style" ? e[o] = { ...d, ...i } : o === "ref" ? e[o] = (n) => {
|
|
16
|
+
z(d, n), z(i, n);
|
|
17
|
+
} : /^on[A-Z]/.test(o) && typeof d == "function" && typeof i == "function" ? e[o] = (...n) => {
|
|
18
|
+
d(...n), i(...n);
|
|
19
|
+
} : e[o] = i);
|
|
20
|
+
}
|
|
21
|
+
return e;
|
|
22
|
+
}
|
|
23
|
+
const B = {
|
|
24
|
+
before: { top: -5, left: 0, right: 0, height: 3 },
|
|
25
|
+
after: { bottom: -5, left: 0, right: 0, height: 3 }
|
|
26
|
+
};
|
|
27
|
+
function J({
|
|
28
|
+
target: t,
|
|
29
|
+
children: e,
|
|
30
|
+
inline: s,
|
|
31
|
+
asChild: o,
|
|
32
|
+
pass: i,
|
|
33
|
+
...d
|
|
34
|
+
}) {
|
|
35
|
+
var _, w;
|
|
36
|
+
const n = A(), c = (n == null ? void 0 : n.inheritedFrom(t)) ?? null, E = d["data-design-copy"] !== void 0, F = d["data-header-folded"] !== void 0, p = !n || !!c || E, g = V((n == null ? void 0 : n.dnd) ?? q, t, { disabled: p, noDrop: F });
|
|
37
|
+
if (!n) return /* @__PURE__ */ u(O, { children: e });
|
|
38
|
+
const y = j(t), x = n.selected != null && j(n.selected) === y, r = ((_ = n.roleMark) == null ? void 0 : _.call(n, t)) ?? null, k = p ? {} : g.props, I = g.dragging, b = p ? null : g.slot, l = o && L(e) ? e : null, $ = (l == null ? void 0 : l.props.className) ?? "", P = /(^|\s)(absolute|fixed|sticky|relative)(\s|$)/.test($), R = U(
|
|
39
|
+
!P && "relative",
|
|
40
|
+
"cursor-pointer rounded-md outline-offset-2",
|
|
41
|
+
!l && (s ? "inline-block" : "block"),
|
|
42
|
+
x ? "outline outline-2 outline-nvr-cyan" : "hover:outline hover:outline-1 hover:outline-slate-300 dark:hover:outline-slate-600",
|
|
43
|
+
"focus-visible:outline focus-visible:outline-2 focus-visible:outline-nvr-cyan",
|
|
44
|
+
I && "opacity-40",
|
|
45
|
+
// Hidden for the previewed role: faint, its tags not.
|
|
46
|
+
(r == null ? void 0 : r.kind) === "hidden" && "[&>:not([data-design-badges])]:opacity-40"
|
|
47
|
+
), K = (a) => {
|
|
48
|
+
const m = a.target;
|
|
49
|
+
if (m.closest("[data-design-target]") !== a.currentTarget) return;
|
|
50
|
+
n.onSelect(t);
|
|
51
|
+
const T = m.closest("[data-design-pass]");
|
|
52
|
+
T && a.currentTarget.contains(T) || (a.preventDefault(), a.stopPropagation());
|
|
53
|
+
}, M = (a) => {
|
|
54
|
+
a.key !== "Enter" || a.target !== a.currentTarget || a.currentTarget.tagName !== "BUTTON" && (a.preventDefault(), n.onSelect(t));
|
|
55
|
+
}, D = d["data-design-tab"] !== void 0 || ((w = l == null ? void 0 : l.props) == null ? void 0 : w["data-design-tab"]) !== void 0, N = {
|
|
56
|
+
"data-design-target": y,
|
|
57
|
+
"data-selected": x ? "true" : void 0,
|
|
58
|
+
"data-design-pass": i ? "" : void 0,
|
|
59
|
+
"data-drop-slot": b ?? void 0,
|
|
60
|
+
"data-role-mark": r == null ? void 0 : r.kind,
|
|
61
|
+
// Locked nodes get no dnd attributes; they still take focus to be selected.
|
|
62
|
+
...p ? { role: "button", tabIndex: 0 } : {},
|
|
63
|
+
...D && c ? { "data-tip": `From ${c}` } : {},
|
|
64
|
+
className: R,
|
|
65
|
+
onClickCapture: K,
|
|
66
|
+
onKeyDown: M
|
|
67
|
+
}, S = (r == null ? void 0 : r.kind) === "hidden" ? W : Z, h = D && c && !r ? (
|
|
68
|
+
// Steps and tabs: a dot above the label, the parent's name in the tip.
|
|
69
|
+
/* @__PURE__ */ u(
|
|
70
|
+
"span",
|
|
71
|
+
{
|
|
72
|
+
"data-design-badges": "",
|
|
73
|
+
className: "pointer-events-none absolute left-1/2 top-1 z-10 h-1.5 w-1.5 -translate-x-1/2 rounded-full bg-slate-500 dark:bg-slate-400",
|
|
74
|
+
children: /* @__PURE__ */ f("span", { className: "sr-only", children: [
|
|
75
|
+
"from ",
|
|
76
|
+
c
|
|
77
|
+
] })
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
) : c || r ? /* @__PURE__ */ f(
|
|
81
|
+
"span",
|
|
82
|
+
{
|
|
83
|
+
"data-design-badges": "",
|
|
84
|
+
className: "pointer-events-none absolute -top-2 right-1 z-10 flex items-center gap-1",
|
|
85
|
+
children: [
|
|
86
|
+
r && /* @__PURE__ */ f(
|
|
87
|
+
"span",
|
|
88
|
+
{
|
|
89
|
+
"data-design-role-tag": r.kind,
|
|
90
|
+
className: "inline-flex items-center gap-0.5 rounded bg-amber-50 px-1 text-[11px] text-amber-800 ring-1 ring-amber-200 dark:bg-amber-500/15 dark:text-amber-200 dark:ring-amber-500/30",
|
|
91
|
+
children: [
|
|
92
|
+
/* @__PURE__ */ u(S, { "aria-hidden": !0, className: "h-3 w-3" }),
|
|
93
|
+
r.kind === "hidden" ? "Hidden" : "Read-only",
|
|
94
|
+
" for ",
|
|
95
|
+
r.role
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
c && /* @__PURE__ */ f("span", { className: "rounded bg-slate-100 px-1 text-[11px] text-slate-600 dark:bg-slate-800 dark:text-slate-300", children: [
|
|
100
|
+
"from ",
|
|
101
|
+
c
|
|
102
|
+
] })
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
) : null, v = b ? /* @__PURE__ */ u(
|
|
106
|
+
"span",
|
|
107
|
+
{
|
|
108
|
+
"aria-hidden": !0,
|
|
109
|
+
"data-design-drop-indicator": b,
|
|
110
|
+
className: "pointer-events-none absolute z-30 rounded-full bg-nvr-cyan shadow-[0_0_0_2px_#fff] dark:shadow-[0_0_0_2px_#0f172a]",
|
|
111
|
+
style: g.indicator ?? B[b]
|
|
112
|
+
}
|
|
113
|
+
) : null;
|
|
114
|
+
if (l) {
|
|
115
|
+
const { children: a, ...m } = l.props;
|
|
116
|
+
return H(
|
|
117
|
+
l,
|
|
118
|
+
// The child's own classes, style, ref and handlers are kept and merged.
|
|
119
|
+
C(m, d, k, N),
|
|
120
|
+
h || v ? /* @__PURE__ */ f(O, { children: [
|
|
121
|
+
h,
|
|
122
|
+
v,
|
|
123
|
+
a
|
|
124
|
+
] }) : a
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return /* @__PURE__ */ f(s ? "span" : "div", { ...C(d, k, N), children: [
|
|
128
|
+
h,
|
|
129
|
+
v,
|
|
130
|
+
e
|
|
131
|
+
] });
|
|
132
|
+
}
|
|
133
|
+
function Q(t, e, s, o = {}) {
|
|
134
|
+
if (!t || s == null || s === !1) return s;
|
|
135
|
+
const i = L(s) ? s.key ?? void 0 : void 0;
|
|
136
|
+
return /* @__PURE__ */ u(J, { target: e, ...o, children: s }, i);
|
|
137
|
+
}
|
|
138
|
+
function re() {
|
|
139
|
+
const t = A();
|
|
140
|
+
return (e, s, o) => Q(t, e, s, o);
|
|
141
|
+
}
|
|
142
|
+
function ae({ groupKey: t }) {
|
|
143
|
+
const { ref: e, slot: s, indicator: o } = G(t);
|
|
144
|
+
return /* @__PURE__ */ u(
|
|
145
|
+
"span",
|
|
146
|
+
{
|
|
147
|
+
ref: e,
|
|
148
|
+
"aria-hidden": !0,
|
|
149
|
+
hidden: !s,
|
|
150
|
+
"data-design-drop-body": t,
|
|
151
|
+
"data-design-drop-indicator": s ?? void 0,
|
|
152
|
+
className: "pointer-events-none absolute z-30 rounded-full bg-nvr-cyan shadow-[0_0_0_2px_#fff] dark:shadow-[0_0_0_2px_#0f172a]",
|
|
153
|
+
style: s ? o ?? B[s] : void 0
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
function ie() {
|
|
158
|
+
return /* @__PURE__ */ u(
|
|
159
|
+
"div",
|
|
160
|
+
{
|
|
161
|
+
"data-design-drop-zone": "",
|
|
162
|
+
className: "flex h-16 items-center justify-center rounded-lg border border-dashed border-slate-300 text-[12px] text-slate-400 dark:border-slate-600 dark:text-slate-500",
|
|
163
|
+
children: "Drop fields here"
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
ae as DesignDropBody,
|
|
169
|
+
ie as DesignDropZone,
|
|
170
|
+
J as DesignNode,
|
|
171
|
+
Q as designWrap,
|
|
172
|
+
re as useDesignWrap
|
|
173
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { ItemEditForm as c } from "../ItemEditForm.js";
|
|
3
|
+
import { RecordReadView as u } from "../RecordReadView.js";
|
|
4
|
+
import { PdfCanvas as v } from "./canvases/PdfCanvas.js";
|
|
5
|
+
import { TableColumnsCanvas as p } from "./canvases/TableColumnsCanvas.js";
|
|
6
|
+
import { LayoutDesignContext as f } from "./design-context.js";
|
|
7
|
+
import { useOverviewFields as l } from "./overview/overview-api.js";
|
|
8
|
+
function h(e) {
|
|
9
|
+
switch (e) {
|
|
10
|
+
case "summary":
|
|
11
|
+
case "detail":
|
|
12
|
+
return "read-view";
|
|
13
|
+
case "file":
|
|
14
|
+
return "pdf";
|
|
15
|
+
case "table":
|
|
16
|
+
return "table";
|
|
17
|
+
default:
|
|
18
|
+
return "item-edit-form";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function x(e) {
|
|
22
|
+
const { data: r = [] } = l(e.collection);
|
|
23
|
+
return /* @__PURE__ */ t(p, { ...e, fields: r });
|
|
24
|
+
}
|
|
25
|
+
function w(e) {
|
|
26
|
+
const { data: r = [] } = l(e.collection);
|
|
27
|
+
return /* @__PURE__ */ t(v, { ...e, fields: r });
|
|
28
|
+
}
|
|
29
|
+
function g({
|
|
30
|
+
collection: e,
|
|
31
|
+
bundle: r,
|
|
32
|
+
layout: n,
|
|
33
|
+
record: d,
|
|
34
|
+
design: a,
|
|
35
|
+
apply: m,
|
|
36
|
+
whenIdle: s
|
|
37
|
+
}) {
|
|
38
|
+
const o = h(String(r.layout.layout_type ?? "grouped"));
|
|
39
|
+
let i;
|
|
40
|
+
return o === "item-edit-form" ? i = /* @__PURE__ */ t(
|
|
41
|
+
c,
|
|
42
|
+
{
|
|
43
|
+
collection: e,
|
|
44
|
+
documentTitle: !1,
|
|
45
|
+
design: { layout: n, record: d, context: a }
|
|
46
|
+
}
|
|
47
|
+
) : o === "read-view" ? i = /* @__PURE__ */ t(u, { collection: e, design: { layout: n, record: d, context: a } }) : o === "pdf" ? i = /* @__PURE__ */ t(f.Provider, { value: a, children: /* @__PURE__ */ t(w, { bundle: r, collection: e, whenIdle: s }) }) : i = /* @__PURE__ */ t(f.Provider, { value: a, children: /* @__PURE__ */ t(x, { bundle: r, apply: m, collection: e }) }), /* @__PURE__ */ t("div", { "data-editor-canvas": "", "data-renderer": o, className: "flex min-h-full flex-col", children: i });
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
g as EditorCanvas,
|
|
51
|
+
h as canvasRenderer
|
|
52
|
+
};
|