@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,90 @@
|
|
|
1
|
+
import { jsxs as o, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useState as m } from "react";
|
|
3
|
+
import { useApiFetchConfig as v } from "../../../context.js";
|
|
4
|
+
import { UNGROUPED_KEY as w } from "../../../lib/layout-ops.js";
|
|
5
|
+
import { titleCase as N } from "../../../lib/utils.js";
|
|
6
|
+
import { DesignNode as u } from "../DesignNode.js";
|
|
7
|
+
import { useLayoutDesign as _ } from "../design-context.js";
|
|
8
|
+
const L = (r) => r.startsWith("__");
|
|
9
|
+
function C(r, d) {
|
|
10
|
+
let s = r.overrides;
|
|
11
|
+
if (typeof s == "string")
|
|
12
|
+
try {
|
|
13
|
+
s = JSON.parse(s);
|
|
14
|
+
} catch {
|
|
15
|
+
s = null;
|
|
16
|
+
}
|
|
17
|
+
const l = s == null ? void 0 : s.label;
|
|
18
|
+
return typeof l == "string" ? l : r.label_override ?? (d || N(r.field));
|
|
19
|
+
}
|
|
20
|
+
function S({ bundle: r, collection: d, fields: s = [], whenIdle: l }) {
|
|
21
|
+
const n = _(), b = (n == null ? void 0 : n.showHidden) ?? !1, h = r.groups.filter((e) => e.key !== w && e.type !== "ungrouped").sort((e, i) => e.sort - i.sort), c = v(), [x, p] = m(!1), [y, f] = m(!1), g = new Map(s.map((e) => [e.field, e.label ?? null]));
|
|
22
|
+
return /* @__PURE__ */ o("div", { className: "flex flex-col gap-4 p-4", "data-pdf-canvas": d, children: [
|
|
23
|
+
/* @__PURE__ */ o("div", { className: "flex items-center justify-between gap-3", children: [
|
|
24
|
+
/* @__PURE__ */ a("p", { className: "text-[12px] text-slate-500 dark:text-slate-400", children: "Each section below becomes a section in the PDF, in this order." }),
|
|
25
|
+
/* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
|
|
26
|
+
y && /* @__PURE__ */ a("span", { className: "text-[12px] text-red-600 dark:text-red-400", children: "Could not build the preview." }),
|
|
27
|
+
/* @__PURE__ */ a(
|
|
28
|
+
"button",
|
|
29
|
+
{
|
|
30
|
+
type: "button",
|
|
31
|
+
"data-pdf-preview": "",
|
|
32
|
+
"data-design-pass": "",
|
|
33
|
+
disabled: x,
|
|
34
|
+
onClick: async () => {
|
|
35
|
+
p(!0), f(!1);
|
|
36
|
+
const e = window.open("", "_blank");
|
|
37
|
+
e && (e.opener = null);
|
|
38
|
+
try {
|
|
39
|
+
await (l == null ? void 0 : l());
|
|
40
|
+
const i = await fetch(
|
|
41
|
+
`${c.apiBase}/collection-layouts/${r.layout.id}/preview-html`,
|
|
42
|
+
{ headers: c.authHeaders, credentials: c.credentials }
|
|
43
|
+
);
|
|
44
|
+
if (!i.ok) throw new Error(String(i.status));
|
|
45
|
+
const t = URL.createObjectURL(new Blob([await i.text()], { type: "text/html" }));
|
|
46
|
+
e ? e.location.href = t : window.open(t, "_blank"), setTimeout(() => URL.revokeObjectURL(t), 6e4);
|
|
47
|
+
} catch {
|
|
48
|
+
e == null || e.close(), f(!0);
|
|
49
|
+
} finally {
|
|
50
|
+
p(!1);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
className: "rounded-md bg-nvr-cyan px-3 py-1.5 text-[12px] font-medium text-white disabled:opacity-60",
|
|
54
|
+
children: "Preview with sample values"
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
] })
|
|
58
|
+
] }),
|
|
59
|
+
h.map((e) => {
|
|
60
|
+
const i = r.placements.filter((t) => t.group_key === e.key && !L(t.field)).filter((t) => t.is_visible || b).sort((t, k) => t.sort - k.sort);
|
|
61
|
+
return /* @__PURE__ */ a(u, { target: { kind: "group", key: e.key }, children: /* @__PURE__ */ o("section", { className: "rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: [
|
|
62
|
+
/* @__PURE__ */ a("h3", { className: "border-b border-slate-200 px-3 py-2 text-[13px] font-semibold dark:border-border", children: e.label }),
|
|
63
|
+
/* @__PURE__ */ o("div", { className: "grid grid-cols-1 gap-2 p-3 sm:grid-cols-2", children: [
|
|
64
|
+
i.length === 0 && /* @__PURE__ */ a("p", { className: "text-[12px] text-slate-500 dark:text-slate-400", children: "No fields yet." }),
|
|
65
|
+
i.map((t) => /* @__PURE__ */ a(
|
|
66
|
+
u,
|
|
67
|
+
{
|
|
68
|
+
target: { kind: "field", field: t.field, group_key: t.group_key },
|
|
69
|
+
children: /* @__PURE__ */ o(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
className: `rounded-md border border-slate-200 px-3 py-2 dark:border-border ${t.is_visible ? "" : "opacity-50"}`,
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ a("div", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: C(t, g.get(t.field)) }),
|
|
75
|
+
/* @__PURE__ */ a("div", { className: "h-4 rounded bg-slate-100 dark:bg-slate-800" })
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
},
|
|
80
|
+
`${t.field}:${t.group_key}`
|
|
81
|
+
))
|
|
82
|
+
] })
|
|
83
|
+
] }) }, e.key);
|
|
84
|
+
})
|
|
85
|
+
] });
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
S as PdfCanvas,
|
|
89
|
+
C as pdfLabel
|
|
90
|
+
};
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { jsxs as i, jsx as t, Fragment as A } from "react/jsx-runtime";
|
|
2
|
+
import { Plus as O, ChevronLeft as E, ChevronRight as F } from "lucide-react";
|
|
3
|
+
import { useMemo as L, useState as P } from "react";
|
|
4
|
+
import { UNGROUPED_KEY as S, isCanvasSlot as $ } from "../../../lib/layout-ops.js";
|
|
5
|
+
import { cn as u, titleCase as x } from "../../../lib/utils.js";
|
|
6
|
+
import { Command as D, CommandInput as M, CommandList as R, CommandEmpty as T, CommandItem as I } from "../../ui/command.js";
|
|
7
|
+
import { Popover as Z, PopoverTrigger as H, PopoverContent as K } from "../../ui/popover.js";
|
|
8
|
+
import { DesignDropBody as U, DesignNode as k } from "../DesignNode.js";
|
|
9
|
+
import { useLayoutDesign as v, targetKey as g } from "../design-context.js";
|
|
10
|
+
import { TABLE_FORM_ZONES as j } from "../dnd/collision.js";
|
|
11
|
+
const [z, B] = j, W = (e) => e.label_override ?? x(e.field);
|
|
12
|
+
function Y(e, l) {
|
|
13
|
+
return e.placements.filter((r) => r.group_key === l && !$(r)).sort((r, a) => r.sort - a.sort || (r.id ?? 0) - (a.id ?? 0));
|
|
14
|
+
}
|
|
15
|
+
const q = (e) => e.filter((l) => !l.field.startsWith("__"));
|
|
16
|
+
function G(e, l) {
|
|
17
|
+
const r = Y(e, l);
|
|
18
|
+
return { rows: q(r), members: r };
|
|
19
|
+
}
|
|
20
|
+
function N(e, l, r) {
|
|
21
|
+
const a = W(e), o = { field: e.field, group_key: e.group_key }, d = l.rows.indexOf(e), f = l.rows.length, m = (h) => {
|
|
22
|
+
const p = l.rows[h], C = l.members.filter((w) => w !== e).indexOf(p) + (h > d ? 1 : 0);
|
|
23
|
+
r([{ op: "move", from: o, to_group_key: e.group_key, index: C }], {
|
|
24
|
+
label: `Move ${a}`
|
|
25
|
+
});
|
|
26
|
+
}, c = "rounded p-0.5 text-slate-400 hover:bg-slate-200 hover:text-slate-700 disabled:opacity-30 dark:hover:bg-slate-700 dark:hover:text-slate-200", s = /* @__PURE__ */ i(A, { children: [
|
|
27
|
+
/* @__PURE__ */ t(
|
|
28
|
+
"button",
|
|
29
|
+
{
|
|
30
|
+
type: "button",
|
|
31
|
+
className: c,
|
|
32
|
+
"aria-label": `Move ${a} left`,
|
|
33
|
+
disabled: d === 0,
|
|
34
|
+
onClick: () => m(d - 1),
|
|
35
|
+
children: /* @__PURE__ */ t(E, { className: "h-3 w-3" })
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
/* @__PURE__ */ t(
|
|
39
|
+
"button",
|
|
40
|
+
{
|
|
41
|
+
type: "button",
|
|
42
|
+
className: c,
|
|
43
|
+
"aria-label": `Move ${a} right`,
|
|
44
|
+
disabled: d === f - 1,
|
|
45
|
+
onClick: () => m(d + 1),
|
|
46
|
+
children: /* @__PURE__ */ t(F, { className: "h-3 w-3" })
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
] });
|
|
50
|
+
return { label: a, arrows: s };
|
|
51
|
+
}
|
|
52
|
+
function y(e) {
|
|
53
|
+
var r;
|
|
54
|
+
const l = (r = v()) == null ? void 0 : r.selected;
|
|
55
|
+
return !!l && g(l) === g({ kind: "field", field: e.field, group_key: e.group_key });
|
|
56
|
+
}
|
|
57
|
+
const _ = "hidden group-hover:flex group-focus-within:flex";
|
|
58
|
+
function V({ row: e, zone: l, apply: r }) {
|
|
59
|
+
const { label: a, arrows: o } = N(e, l, r), d = y(e);
|
|
60
|
+
return /* @__PURE__ */ t(k, { asChild: !0, target: { kind: "field", field: e.field, group_key: e.group_key }, children: /* @__PURE__ */ i(
|
|
61
|
+
"th",
|
|
62
|
+
{
|
|
63
|
+
"data-table-cell": e.field,
|
|
64
|
+
className: u(
|
|
65
|
+
"group px-3 py-2 text-left font-medium text-slate-500 text-[11px] dark:text-slate-400",
|
|
66
|
+
!e.is_visible && "opacity-50"
|
|
67
|
+
),
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ t("span", { className: "block truncate", children: a }),
|
|
70
|
+
/* @__PURE__ */ t(
|
|
71
|
+
"span",
|
|
72
|
+
{
|
|
73
|
+
"data-design-pass": "",
|
|
74
|
+
className: u(
|
|
75
|
+
"absolute right-1 top-1/2 -translate-y-1/2 items-center gap-0.5 rounded bg-slate-50 dark:bg-slate-800",
|
|
76
|
+
d ? "flex" : _
|
|
77
|
+
),
|
|
78
|
+
children: o
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
) });
|
|
84
|
+
}
|
|
85
|
+
function J({ row: e, zone: l, apply: r }) {
|
|
86
|
+
const { label: a, arrows: o } = N(e, l, r), d = y(e);
|
|
87
|
+
return /* @__PURE__ */ t(k, { asChild: !0, target: { kind: "field", field: e.field, group_key: e.group_key }, children: /* @__PURE__ */ i(
|
|
88
|
+
"div",
|
|
89
|
+
{
|
|
90
|
+
"data-table-cell": e.field,
|
|
91
|
+
className: u(
|
|
92
|
+
"group flex items-center gap-1 rounded-md border border-slate-200 bg-white px-2.5 py-1.5 text-[11px] font-medium text-slate-500 dark:border-border dark:bg-card dark:text-slate-400",
|
|
93
|
+
!e.is_visible && "opacity-50"
|
|
94
|
+
),
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ t("span", { className: "truncate", children: a }),
|
|
97
|
+
/* @__PURE__ */ t(
|
|
98
|
+
"span",
|
|
99
|
+
{
|
|
100
|
+
"data-design-pass": "",
|
|
101
|
+
className: u("items-center gap-0.5", d ? "flex" : _),
|
|
102
|
+
children: o
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
) });
|
|
108
|
+
}
|
|
109
|
+
function Q({
|
|
110
|
+
zone: e,
|
|
111
|
+
title: l,
|
|
112
|
+
taken: r,
|
|
113
|
+
fields: a,
|
|
114
|
+
apply: o,
|
|
115
|
+
size: d
|
|
116
|
+
}) {
|
|
117
|
+
const [f, m] = P(!1), c = a.filter((s) => s.field && !s.field.startsWith("__") && !r.has(s.field)).map((s) => ({ field: s.field, title: s.label || x(s.field) })).sort((s, h) => s.title.localeCompare(h.title));
|
|
118
|
+
return /* @__PURE__ */ i(Z, { open: f, onOpenChange: m, children: [
|
|
119
|
+
/* @__PURE__ */ t(H, { asChild: !0, children: /* @__PURE__ */ i(
|
|
120
|
+
"button",
|
|
121
|
+
{
|
|
122
|
+
type: "button",
|
|
123
|
+
"aria-label": `Add field to ${l}`,
|
|
124
|
+
className: "inline-flex h-7 items-center gap-1 rounded-md border border-dashed border-slate-300 px-2 text-[12px] font-medium text-slate-500 hover:border-nvr-cyan hover:text-slate-800 dark:border-slate-600 dark:text-slate-400 dark:hover:text-slate-200",
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ t(O, { className: "h-3 w-3" }),
|
|
127
|
+
"Add field"
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
) }),
|
|
131
|
+
/* @__PURE__ */ t(K, { align: "start", className: "w-64 p-0", children: /* @__PURE__ */ i(D, { children: [
|
|
132
|
+
/* @__PURE__ */ t(M, { placeholder: "Find a field" }),
|
|
133
|
+
/* @__PURE__ */ i(R, { children: [
|
|
134
|
+
/* @__PURE__ */ t(T, { children: "No fields left to add." }),
|
|
135
|
+
c.map((s) => /* @__PURE__ */ t(
|
|
136
|
+
I,
|
|
137
|
+
{
|
|
138
|
+
value: `${s.title} ${s.field}`,
|
|
139
|
+
onSelect: () => {
|
|
140
|
+
m(!1), o([{ op: "place", field: s.field, group_key: e, index: d }], {
|
|
141
|
+
label: `Add ${s.title}`
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
children: s.title
|
|
145
|
+
},
|
|
146
|
+
s.field
|
|
147
|
+
))
|
|
148
|
+
] })
|
|
149
|
+
] }) })
|
|
150
|
+
] });
|
|
151
|
+
}
|
|
152
|
+
function b({
|
|
153
|
+
title: e,
|
|
154
|
+
hint: l,
|
|
155
|
+
bundle: r,
|
|
156
|
+
zone: a,
|
|
157
|
+
apply: o,
|
|
158
|
+
columns: d,
|
|
159
|
+
fields: f,
|
|
160
|
+
showHidden: m
|
|
161
|
+
}) {
|
|
162
|
+
const c = L(() => G(r, a), [r, a]), { rows: s, members: h } = c, p = s.filter((n) => n.is_visible || m);
|
|
163
|
+
return /* @__PURE__ */ i(
|
|
164
|
+
"section",
|
|
165
|
+
{
|
|
166
|
+
"data-table-zone": a ?? "columns",
|
|
167
|
+
className: "overflow-hidden rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card",
|
|
168
|
+
children: [
|
|
169
|
+
/* @__PURE__ */ i("div", { className: "border-b border-slate-200 bg-slate-50 px-3 py-2 dark:border-border dark:bg-slate-800/40", children: [
|
|
170
|
+
/* @__PURE__ */ t("h3", { className: "text-[13px] font-semibold text-slate-800 dark:text-foreground", children: e }),
|
|
171
|
+
/* @__PURE__ */ t("p", { className: "text-[12px] text-slate-500 dark:text-slate-400", children: l })
|
|
172
|
+
] }),
|
|
173
|
+
/* @__PURE__ */ i("div", { className: "relative", "data-table-body": a ?? "columns", children: [
|
|
174
|
+
/* @__PURE__ */ t(U, { groupKey: a ?? S }),
|
|
175
|
+
p.length === 0 ? /* @__PURE__ */ t("p", { className: "px-3 py-3 text-[12px] text-slate-500 dark:text-slate-400", children: "No fields yet. Add one below, or drag one here." }) : d ? /* @__PURE__ */ t("table", { className: "w-full table-fixed", "data-table-header": "", children: /* @__PURE__ */ t("thead", { className: "border-b border-slate-200 bg-slate-50 dark:border-border dark:bg-slate-800/40", children: /* @__PURE__ */ t("tr", { children: p.map((n) => /* @__PURE__ */ t(V, { row: n, zone: c, apply: o }, n.field)) }) }) }) : /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1.5 p-2", children: p.map((n) => /* @__PURE__ */ t(J, { row: n, zone: c, apply: o }, n.field)) })
|
|
176
|
+
] }),
|
|
177
|
+
/* @__PURE__ */ t("div", { className: "border-t border-slate-200 px-2 py-1.5 dark:border-border", children: /* @__PURE__ */ t(
|
|
178
|
+
Q,
|
|
179
|
+
{
|
|
180
|
+
zone: a,
|
|
181
|
+
title: e,
|
|
182
|
+
taken: new Set(s.map((n) => n.field)),
|
|
183
|
+
fields: f,
|
|
184
|
+
apply: o,
|
|
185
|
+
size: h.length
|
|
186
|
+
}
|
|
187
|
+
) })
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
function ne({
|
|
193
|
+
bundle: e,
|
|
194
|
+
apply: l,
|
|
195
|
+
collection: r,
|
|
196
|
+
fields: a = []
|
|
197
|
+
}) {
|
|
198
|
+
var d;
|
|
199
|
+
const o = ((d = v()) == null ? void 0 : d.showHidden) ?? !1;
|
|
200
|
+
return /* @__PURE__ */ i("div", { className: "flex flex-col gap-4 p-4", "data-table-canvas": r, children: [
|
|
201
|
+
/* @__PURE__ */ t(
|
|
202
|
+
b,
|
|
203
|
+
{
|
|
204
|
+
title: "Columns",
|
|
205
|
+
hint: "The columns of the grid, left to right. The grid gives them equal width.",
|
|
206
|
+
bundle: e,
|
|
207
|
+
zone: null,
|
|
208
|
+
apply: l,
|
|
209
|
+
columns: !0,
|
|
210
|
+
fields: a,
|
|
211
|
+
showHidden: o
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
/* @__PURE__ */ t(
|
|
215
|
+
b,
|
|
216
|
+
{
|
|
217
|
+
title: "Apply values",
|
|
218
|
+
hint: 'Fields in the "apply to all rows" form.',
|
|
219
|
+
bundle: e,
|
|
220
|
+
zone: z,
|
|
221
|
+
apply: l,
|
|
222
|
+
columns: !1,
|
|
223
|
+
fields: a,
|
|
224
|
+
showHidden: o
|
|
225
|
+
}
|
|
226
|
+
),
|
|
227
|
+
/* @__PURE__ */ t(
|
|
228
|
+
b,
|
|
229
|
+
{
|
|
230
|
+
title: "Create with defaults",
|
|
231
|
+
hint: 'Fields in the "with defaults" form when adding several rows.',
|
|
232
|
+
bundle: e,
|
|
233
|
+
zone: B,
|
|
234
|
+
apply: l,
|
|
235
|
+
columns: !1,
|
|
236
|
+
fields: a,
|
|
237
|
+
showHidden: o
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
] });
|
|
241
|
+
}
|
|
242
|
+
export {
|
|
243
|
+
z as APPLY_ZONE,
|
|
244
|
+
B as DEFAULTS_ZONE,
|
|
245
|
+
ne as TableColumnsCanvas
|
|
246
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useQuery as n } from "@tanstack/react-query";
|
|
2
|
+
import { useNivaroClient as l } from "../../context.js";
|
|
3
|
+
import { get as i } from "../../lib/commands.js";
|
|
4
|
+
const u = (e) => ["layout-editor", "collection-meta", e];
|
|
5
|
+
function y(e) {
|
|
6
|
+
return e && typeof e == "object" && !Array.isArray(e) ? e : null;
|
|
7
|
+
}
|
|
8
|
+
function m(e, t = {}) {
|
|
9
|
+
const o = l();
|
|
10
|
+
return n({
|
|
11
|
+
queryKey: u(e),
|
|
12
|
+
queryFn: () => o.request(i(`/collections/${e}`)).then((r) => y(r == null ? void 0 : r.data)),
|
|
13
|
+
enabled: !!e && (t.enabled ?? !0),
|
|
14
|
+
staleTime: 5 * 6e4,
|
|
15
|
+
...t.select ? { select: t.select } : {},
|
|
16
|
+
...t.retry === void 0 ? {} : { retry: t.retry }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
u as collectionMetaKey,
|
|
21
|
+
m as useCollectionBody
|
|
22
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as m, useMemo as C } from "react";
|
|
3
|
+
import { useNivaroClient as g, NivaroProvider as h } from "../../context.js";
|
|
4
|
+
import { RealtimeContext as v } from "../../lib/realtime.js";
|
|
5
|
+
import { LayoutDesignContext as f } from "./design-context.js";
|
|
6
|
+
const P = /^\/(field-config\/[^/]+\/project|widgets-internal\/[^/]+\/render|items\/[^/]+\/[^/]+\/child-summary|items\/[^/]+\/auto-id-preview|pipelines\/instance\/[^/]+\/owners\/batch|addendums\/summary|at-risk\/evaluate|items\/batch-read|users\/cards)$/;
|
|
7
|
+
function D(n) {
|
|
8
|
+
const e = (n._method ?? "GET").toUpperCase();
|
|
9
|
+
return e === "GET" ? !0 : e === "POST" && P.test((n._path ?? "").split("?")[0]);
|
|
10
|
+
}
|
|
11
|
+
const d = () => Promise.reject(new Error("Layout preview: changes are not saved"));
|
|
12
|
+
function b(n, e) {
|
|
13
|
+
return new Proxy(n, {
|
|
14
|
+
get(o, a, i) {
|
|
15
|
+
if (a === "request")
|
|
16
|
+
return (s) => {
|
|
17
|
+
const r = s;
|
|
18
|
+
return D(r) ? o.request(s) : (e == null || e({ method: (r._method ?? "GET").toUpperCase(), path: r._path ?? "" }), d());
|
|
19
|
+
};
|
|
20
|
+
if (a === "graphql" || a === "upload" || a === "importParse")
|
|
21
|
+
return () => (e == null || e({ method: String(a), path: "" }), d());
|
|
22
|
+
const u = Reflect.get(o, a, i);
|
|
23
|
+
return typeof u == "function" ? u.bind(o) : u;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const w = 'input, textarea, select, [contenteditable=""], [contenteditable="true"]', l = (n) => !!n.closest("[data-design-pass]"), y = (n) => {
|
|
28
|
+
var o;
|
|
29
|
+
const e = n.target;
|
|
30
|
+
return !!((o = e == null ? void 0 : e.closest) != null && o.call(e, w));
|
|
31
|
+
};
|
|
32
|
+
function S({
|
|
33
|
+
design: n,
|
|
34
|
+
onRefusedWrite: e,
|
|
35
|
+
children: o
|
|
36
|
+
}) {
|
|
37
|
+
const a = g(), i = m(e);
|
|
38
|
+
i.current = e;
|
|
39
|
+
const u = C(() => b(a, (t) => {
|
|
40
|
+
var c;
|
|
41
|
+
return (c = i.current) == null ? void 0 : c.call(i, t);
|
|
42
|
+
}), [a]), s = (t) => {
|
|
43
|
+
t.preventDefault(), t.stopPropagation();
|
|
44
|
+
}, r = (t) => {
|
|
45
|
+
y(t) && s(t);
|
|
46
|
+
};
|
|
47
|
+
return /* @__PURE__ */ p(h, { client: u, children: /* @__PURE__ */ p(v.Provider, { value: null, children: /* @__PURE__ */ p(f.Provider, { value: n, children: /* @__PURE__ */ p(
|
|
48
|
+
"div",
|
|
49
|
+
{
|
|
50
|
+
className: "contents",
|
|
51
|
+
"data-design-canvas": "",
|
|
52
|
+
onClickCapture: (t) => {
|
|
53
|
+
const c = t.target;
|
|
54
|
+
c.closest("[data-design-target]") || l(c) || s(t);
|
|
55
|
+
},
|
|
56
|
+
onPointerDownCapture: (t) => {
|
|
57
|
+
l(t.target) || t.preventDefault();
|
|
58
|
+
},
|
|
59
|
+
onMouseDownCapture: (t) => {
|
|
60
|
+
l(t.target) || t.preventDefault();
|
|
61
|
+
},
|
|
62
|
+
onKeyDownCapture: (t) => {
|
|
63
|
+
t.key !== "Tab" && r(t);
|
|
64
|
+
},
|
|
65
|
+
onBeforeInputCapture: r,
|
|
66
|
+
onInputCapture: r,
|
|
67
|
+
onChangeCapture: r,
|
|
68
|
+
onPasteCapture: r,
|
|
69
|
+
onCutCapture: r,
|
|
70
|
+
onDropCapture: r,
|
|
71
|
+
onSubmitCapture: s,
|
|
72
|
+
onContextMenuCapture: (t) => t.stopPropagation(),
|
|
73
|
+
children: o
|
|
74
|
+
}
|
|
75
|
+
) }) }) });
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
S as DesignCanvas,
|
|
79
|
+
b as designReadOnlyClient,
|
|
80
|
+
D as isDesignAllowedRequest
|
|
81
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createContext as r, useContext as n } from "react";
|
|
2
|
+
const t = r(null);
|
|
3
|
+
function u() {
|
|
4
|
+
return n(t);
|
|
5
|
+
}
|
|
6
|
+
function i(e) {
|
|
7
|
+
switch (e.kind) {
|
|
8
|
+
case "field":
|
|
9
|
+
case "slot":
|
|
10
|
+
return `${e.kind}:${e.field}:${e.group_key ?? ""}`;
|
|
11
|
+
case "group":
|
|
12
|
+
return `group:${e.key}`;
|
|
13
|
+
case "header":
|
|
14
|
+
return `header:${e.field}`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
t as LayoutDesignContext,
|
|
19
|
+
i as targetKey,
|
|
20
|
+
u as useLayoutDesign
|
|
21
|
+
};
|