@nivaro/react 0.2.51 → 0.2.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +207 -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 +4015 -3835
- package/dist/shared/components/RecordDrilldownSheet.js +114 -97
- package/dist/shared/components/RecordReadView.js +637 -570
- package/dist/shared/components/ai/ExplainButton.js +1 -1
- 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 +1 -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/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/request-gate.js +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { jsxs as n, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { X as J } from "lucide-react";
|
|
3
|
+
import { useState as l } from "react";
|
|
4
|
+
import { Command as _, CommandInput as y, CommandList as k, CommandGroup as N, CommandItem as C } from "../../ui/command.js";
|
|
5
|
+
import { Popover as i, PopoverTrigger as c, PopoverContent as p } from "../../ui/popover.js";
|
|
6
|
+
function X({
|
|
7
|
+
rule: t,
|
|
8
|
+
parentFields: h,
|
|
9
|
+
childFields: u,
|
|
10
|
+
onChange: o,
|
|
11
|
+
onRemove: O
|
|
12
|
+
}) {
|
|
13
|
+
var v, g;
|
|
14
|
+
const [S, f] = l(!1), [j, m] = l(!1), [E, R] = l(!1), [P, b] = l(""), [s, d] = l(null), x = !!t.on_unavailable && typeof t.on_unavailable == "object";
|
|
15
|
+
return /* @__PURE__ */ n("div", { className: "flex items-center gap-1.5", children: [
|
|
16
|
+
/* @__PURE__ */ n(i, { open: S, onOpenChange: f, children: [
|
|
17
|
+
/* @__PURE__ */ e(c, { asChild: !0, children: /* @__PURE__ */ e(
|
|
18
|
+
"button",
|
|
19
|
+
{
|
|
20
|
+
type: "button",
|
|
21
|
+
"data-setting": "field.parent_cascades.parent_field",
|
|
22
|
+
className: "flex-1 h-7 rounded border border-slate-200 bg-white px-2 text-[11px] text-left truncate hover:border-slate-400 focus:outline-none focus:ring-1 focus:ring-nvr-cyan min-w-0 dark:bg-card dark:border-border",
|
|
23
|
+
children: t.parent_field ? ((v = h.find((a) => a.value === t.parent_field)) == null ? void 0 : v.label) ?? t.parent_field : /* @__PURE__ */ e("span", { className: "text-slate-400", children: "parent field…" })
|
|
24
|
+
}
|
|
25
|
+
) }),
|
|
26
|
+
/* @__PURE__ */ e(p, { className: "w-52 p-0", align: "start", children: /* @__PURE__ */ n(_, { children: [
|
|
27
|
+
/* @__PURE__ */ e(y, { placeholder: "Search…", className: "h-8 text-[12px]" }),
|
|
28
|
+
/* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(N, { children: h.map((a) => /* @__PURE__ */ e(
|
|
29
|
+
C,
|
|
30
|
+
{
|
|
31
|
+
value: a.value,
|
|
32
|
+
onSelect: () => {
|
|
33
|
+
o({ ...t, parent_field: a.value }), f(!1);
|
|
34
|
+
},
|
|
35
|
+
className: "text-[12px]",
|
|
36
|
+
children: a.label
|
|
37
|
+
},
|
|
38
|
+
a.value
|
|
39
|
+
)) }) })
|
|
40
|
+
] }) })
|
|
41
|
+
] }),
|
|
42
|
+
/* @__PURE__ */ e("span", { className: "text-[11px] text-slate-400 shrink-0", children: "→" }),
|
|
43
|
+
/* @__PURE__ */ n(i, { open: j, onOpenChange: m, children: [
|
|
44
|
+
/* @__PURE__ */ e(c, { asChild: !0, children: /* @__PURE__ */ e(
|
|
45
|
+
"button",
|
|
46
|
+
{
|
|
47
|
+
type: "button",
|
|
48
|
+
"data-setting": "field.parent_cascades.child_field",
|
|
49
|
+
className: "flex-1 h-7 rounded border border-slate-200 bg-white px-2 text-[11px] text-left truncate hover:border-slate-400 focus:outline-none focus:ring-1 focus:ring-nvr-cyan min-w-0 dark:bg-card dark:border-border",
|
|
50
|
+
children: t.child_field ? ((g = u.find((a) => a.value === t.child_field)) == null ? void 0 : g.label) ?? t.child_field : /* @__PURE__ */ e("span", { className: "text-slate-400", children: "child field…" })
|
|
51
|
+
}
|
|
52
|
+
) }),
|
|
53
|
+
/* @__PURE__ */ e(p, { className: "w-52 p-0", align: "start", children: /* @__PURE__ */ n(_, { children: [
|
|
54
|
+
/* @__PURE__ */ e(y, { placeholder: "Search…", className: "h-8 text-[12px]" }),
|
|
55
|
+
/* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(N, { children: u.map((a) => /* @__PURE__ */ e(
|
|
56
|
+
C,
|
|
57
|
+
{
|
|
58
|
+
value: a.value,
|
|
59
|
+
onSelect: () => {
|
|
60
|
+
o({ ...t, child_field: a.value }), m(!1);
|
|
61
|
+
},
|
|
62
|
+
className: "text-[12px]",
|
|
63
|
+
children: a.label
|
|
64
|
+
},
|
|
65
|
+
a.value
|
|
66
|
+
)) }) })
|
|
67
|
+
] }) })
|
|
68
|
+
] }),
|
|
69
|
+
/* @__PURE__ */ n(
|
|
70
|
+
i,
|
|
71
|
+
{
|
|
72
|
+
open: E,
|
|
73
|
+
onOpenChange: (a) => {
|
|
74
|
+
R(a), a && (b(x ? JSON.stringify(t.on_unavailable, null, 2) : ""), d(null));
|
|
75
|
+
},
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ e(c, { asChild: !0, children: /* @__PURE__ */ e(
|
|
78
|
+
"button",
|
|
79
|
+
{
|
|
80
|
+
type: "button",
|
|
81
|
+
"data-setting": "field.parent_cascades.on_unavailable",
|
|
82
|
+
"aria-label": "When the value is no longer offered",
|
|
83
|
+
"data-tip": "On unavailable: swap the row to a default when the parent change orphans its value",
|
|
84
|
+
className: `h-7 w-7 shrink-0 rounded border text-[11px] transition-colors ${x ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-400 hover:border-slate-400 hover:text-slate-700 dark:border-border dark:text-muted-foreground dark:hover:text-foreground"}`,
|
|
85
|
+
children: "⇄"
|
|
86
|
+
}
|
|
87
|
+
) }),
|
|
88
|
+
/* @__PURE__ */ n(p, { className: "w-[420px] p-3 space-y-2", align: "end", children: [
|
|
89
|
+
/* @__PURE__ */ e("p", { className: "text-[11px] font-medium text-slate-700 dark:text-foreground", children: "On unavailable — swap to a default" }),
|
|
90
|
+
/* @__PURE__ */ n("p", { className: "text-[11px] text-slate-500", children: [
|
|
91
|
+
"When the parent field is changed and a row’s value is no longer offered, re-point the row to the option that keeps ",
|
|
92
|
+
/* @__PURE__ */ e("code", { children: "keep" }),
|
|
93
|
+
" from the old value and takes",
|
|
94
|
+
" ",
|
|
95
|
+
/* @__PURE__ */ e("code", { children: "replace" }),
|
|
96
|
+
" from the parent’s defaults (pinned_options entry shape). Row rules then run as if the user picked it. Empty = flag only."
|
|
97
|
+
] }),
|
|
98
|
+
/* @__PURE__ */ e(
|
|
99
|
+
"textarea",
|
|
100
|
+
{
|
|
101
|
+
value: P,
|
|
102
|
+
onChange: (a) => {
|
|
103
|
+
b(a.target.value);
|
|
104
|
+
const w = a.target.value.trim();
|
|
105
|
+
if (!w) {
|
|
106
|
+
d(null);
|
|
107
|
+
const { on_unavailable: r, ...I } = t;
|
|
108
|
+
o(I);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
const r = JSON.parse(w);
|
|
113
|
+
if (!r || typeof r != "object" || !r.replace)
|
|
114
|
+
throw new Error('needs a "replace" map');
|
|
115
|
+
d(null), o({ ...t, on_unavailable: r });
|
|
116
|
+
} catch (r) {
|
|
117
|
+
d(r instanceof Error ? r.message : "Invalid JSON");
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
rows: 9,
|
|
121
|
+
spellCheck: !1,
|
|
122
|
+
placeholder: `{
|
|
123
|
+
"keep": ["sub_category"],
|
|
124
|
+
"replace": { "core_category": [ { "parent_field": "project", "parent_collection": "projects", "source_field": "default_core_category" } ] },
|
|
125
|
+
"label": "Category"
|
|
126
|
+
}`,
|
|
127
|
+
className: `w-full rounded border bg-white px-2 py-1.5 font-mono text-[11px] leading-snug dark:bg-card ${s ? "border-red-400" : "border-slate-200 dark:border-border"}`
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
s && /* @__PURE__ */ e("p", { className: "text-[11px] text-red-500", children: s })
|
|
131
|
+
] })
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
),
|
|
135
|
+
/* @__PURE__ */ e(
|
|
136
|
+
"button",
|
|
137
|
+
{
|
|
138
|
+
type: "button",
|
|
139
|
+
onClick: O,
|
|
140
|
+
"aria-label": "Remove rule",
|
|
141
|
+
"data-tip": "Remove rule",
|
|
142
|
+
className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-slate-500 transition-colors hover:bg-slate-100 hover:text-red-600 dark:hover:bg-muted dark:hover:text-red-400",
|
|
143
|
+
children: /* @__PURE__ */ e(J, { className: "h-3.5 w-3.5" })
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
] });
|
|
147
|
+
}
|
|
148
|
+
export {
|
|
149
|
+
X as CascadeRuleRow
|
|
150
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsxs as t, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronsUpDown as h, Check as x } from "lucide-react";
|
|
3
|
+
import { useState as u } from "react";
|
|
4
|
+
import { cn as s } from "../../../lib/utils.js";
|
|
5
|
+
import { Button as f } from "../../ui/button.js";
|
|
6
|
+
import { Command as b, CommandInput as C, CommandList as g, CommandEmpty as N, CommandGroup as w, CommandItem as v } from "../../ui/command.js";
|
|
7
|
+
import { Popover as y, PopoverTrigger as k, PopoverContent as S } from "../../ui/popover.js";
|
|
8
|
+
function G({
|
|
9
|
+
value: r,
|
|
10
|
+
onChange: c,
|
|
11
|
+
options: n,
|
|
12
|
+
placeholder: i,
|
|
13
|
+
disabled: p
|
|
14
|
+
}) {
|
|
15
|
+
const [m, l] = u(!1), a = n.find((o) => o.value === r);
|
|
16
|
+
return /* @__PURE__ */ t(y, { open: m, onOpenChange: l, children: [
|
|
17
|
+
/* @__PURE__ */ e(k, { asChild: !0, children: /* @__PURE__ */ t(
|
|
18
|
+
f,
|
|
19
|
+
{
|
|
20
|
+
variant: "outline",
|
|
21
|
+
role: "combobox",
|
|
22
|
+
"aria-expanded": m,
|
|
23
|
+
disabled: p,
|
|
24
|
+
className: "h-8 w-full justify-between rounded-md border-slate-200 bg-white px-2.5 text-[13px] font-normal dark:border-border dark:bg-background",
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ e(
|
|
27
|
+
"span",
|
|
28
|
+
{
|
|
29
|
+
className: s(
|
|
30
|
+
"truncate",
|
|
31
|
+
!a && (r ? "font-mono text-[12px]" : "text-muted-foreground")
|
|
32
|
+
),
|
|
33
|
+
children: a ? a.label : r || (i ?? "Select…")
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
/* @__PURE__ */ e(h, { className: "ml-1 h-3 w-3 shrink-0 opacity-50" })
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
) }),
|
|
40
|
+
/* @__PURE__ */ e(S, { className: "w-[240px] p-0", align: "start", children: /* @__PURE__ */ t(b, { children: [
|
|
41
|
+
/* @__PURE__ */ e(C, { placeholder: "Search…", className: "h-8 text-[12px]" }),
|
|
42
|
+
/* @__PURE__ */ t(g, { children: [
|
|
43
|
+
/* @__PURE__ */ e(N, { className: "py-3 text-center text-[12px] text-muted-foreground", children: "No results" }),
|
|
44
|
+
/* @__PURE__ */ e(w, { children: n.map((o) => /* @__PURE__ */ t(
|
|
45
|
+
v,
|
|
46
|
+
{
|
|
47
|
+
value: o.value,
|
|
48
|
+
onSelect: (d) => {
|
|
49
|
+
c(d === r ? "" : d), l(!1);
|
|
50
|
+
},
|
|
51
|
+
className: "text-[12px]",
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ e(
|
|
54
|
+
x,
|
|
55
|
+
{
|
|
56
|
+
className: s(
|
|
57
|
+
"mr-2 h-3 w-3",
|
|
58
|
+
r === o.value ? "opacity-100" : "opacity-0"
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
o.label
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
o.value
|
|
66
|
+
)) })
|
|
67
|
+
] })
|
|
68
|
+
] }) })
|
|
69
|
+
] });
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
G as Combobox
|
|
73
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useMemo as n } from "react";
|
|
2
|
+
import { useNivaroClient as a } from "../../../context.js";
|
|
3
|
+
import { patch as p, post as u, get as i } from "../../../lib/commands.js";
|
|
4
|
+
function e(t) {
|
|
5
|
+
const r = t == null ? void 0 : t.status, s = t == null ? void 0 : t.response;
|
|
6
|
+
throw !(t instanceof Error) || r == null ? t : Object.assign(new Error(t.message), { status: r, response: { status: r, data: s } });
|
|
7
|
+
}
|
|
8
|
+
function l() {
|
|
9
|
+
const t = a();
|
|
10
|
+
return n(
|
|
11
|
+
() => ({
|
|
12
|
+
get: (r, s) => t.request(i(r, s == null ? void 0 : s.params)).then((o) => ({ data: o }), e),
|
|
13
|
+
post: (r, s) => t.request(u(r, s)).then((o) => ({ data: o }), e),
|
|
14
|
+
patch: (r, s) => t.request(p(r, s)).then((o) => ({ data: o }), e)
|
|
15
|
+
}),
|
|
16
|
+
[t]
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
l as useEditorApi
|
|
21
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useQuery as s } from "@tanstack/react-query";
|
|
2
|
+
import { useEditorApi as a } from "./editor-api.js";
|
|
3
|
+
const d = {
|
|
4
|
+
/** A collection's field rows (GET /field-config/:c), always the array. */
|
|
5
|
+
fieldList: (e) => ["layout-editor", "field-list", e],
|
|
6
|
+
/** Relations touching a collection (GET /data-model/relations/for/:c), always the array. */
|
|
7
|
+
relationsFor: (e) => ["layout-editor", "relations-for", e]
|
|
8
|
+
};
|
|
9
|
+
function y(e) {
|
|
10
|
+
const o = a();
|
|
11
|
+
return s({
|
|
12
|
+
queryKey: d.fieldList(e),
|
|
13
|
+
queryFn: () => o.get(`/field-config/${e}`).then((r) => {
|
|
14
|
+
var i;
|
|
15
|
+
const t = ((i = r.data) == null ? void 0 : i.data) ?? r.data;
|
|
16
|
+
return Array.isArray(t) ? t : [];
|
|
17
|
+
}),
|
|
18
|
+
enabled: !!e,
|
|
19
|
+
staleTime: 6e4
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
d as editorQueryKeys,
|
|
24
|
+
y as useEditorFieldList
|
|
25
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsxs as m, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { Input as x } from "../../ui/input.js";
|
|
3
|
+
import { SimpleSelect as b } from "../../ui/SimpleSelect.js";
|
|
4
|
+
import { useFocusBuffer as N } from "../focus-buffer.js";
|
|
5
|
+
import { RelationLabel as S } from "../pickers/relation-label.js";
|
|
6
|
+
import { RelationPicker as g } from "../pickers/relation-picker.js";
|
|
7
|
+
function D({
|
|
8
|
+
value: t,
|
|
9
|
+
onChange: p,
|
|
10
|
+
isM2O: d,
|
|
11
|
+
isM2M: i,
|
|
12
|
+
relatedCollection: o,
|
|
13
|
+
settings: a,
|
|
14
|
+
abstractType: c
|
|
15
|
+
}) {
|
|
16
|
+
const u = p;
|
|
17
|
+
let s;
|
|
18
|
+
if (i && o) {
|
|
19
|
+
const r = Array.isArray(t) ? t : [];
|
|
20
|
+
s = /* @__PURE__ */ m("div", { className: "space-y-1", children: [
|
|
21
|
+
r.length > 0 && /* @__PURE__ */ n("div", { className: "flex flex-wrap gap-1", children: r.map((l) => /* @__PURE__ */ m(
|
|
22
|
+
"span",
|
|
23
|
+
{
|
|
24
|
+
className: "inline-flex max-w-full items-center gap-1 rounded border border-slate-200 bg-slate-50 px-1.5 py-0.5 text-[11px] text-slate-700 dark:bg-muted dark:border-border dark:text-foreground",
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ n("span", { className: "truncate", children: /* @__PURE__ */ n(S, { relatedCollection: o, id: l }) }),
|
|
27
|
+
/* @__PURE__ */ n(
|
|
28
|
+
"button",
|
|
29
|
+
{
|
|
30
|
+
type: "button",
|
|
31
|
+
onClick: () => u(r.filter((e) => String(e) !== String(l))),
|
|
32
|
+
className: "shrink-0 text-slate-400 hover:text-red-500",
|
|
33
|
+
children: "×"
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
String(l)
|
|
39
|
+
)) }),
|
|
40
|
+
/* @__PURE__ */ n(
|
|
41
|
+
g,
|
|
42
|
+
{
|
|
43
|
+
relatedCollection: o,
|
|
44
|
+
value: null,
|
|
45
|
+
onChange: (l) => {
|
|
46
|
+
l == null || l === "" || r.some((e) => String(e) === String(l)) || u([...r, l]);
|
|
47
|
+
},
|
|
48
|
+
placeholder: "Add…"
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
] });
|
|
52
|
+
} else if (d && o)
|
|
53
|
+
s = /* @__PURE__ */ n(
|
|
54
|
+
g,
|
|
55
|
+
{
|
|
56
|
+
relatedCollection: o,
|
|
57
|
+
value: t ?? null,
|
|
58
|
+
onChange: (r) => u(r ?? null),
|
|
59
|
+
placeholder: "Pick a record…"
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
else if (c === "boolean")
|
|
63
|
+
s = /* @__PURE__ */ n(
|
|
64
|
+
b,
|
|
65
|
+
{
|
|
66
|
+
value: t === !0 ? "true" : t === !1 ? "false" : "",
|
|
67
|
+
onChange: (r) => u(r === "" ? null : r === "true"),
|
|
68
|
+
className: "h-7 w-full rounded border-slate-200 bg-white px-1.5 py-1 text-[11px] dark:bg-card dark:border-border",
|
|
69
|
+
options: [
|
|
70
|
+
{ value: "", label: "—" },
|
|
71
|
+
{ value: "true", label: "Yes" },
|
|
72
|
+
{ value: "false", label: "No" }
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
else {
|
|
77
|
+
const r = (() => {
|
|
78
|
+
const e = a.options;
|
|
79
|
+
if (e && typeof e == "object") return e;
|
|
80
|
+
if (typeof e == "string")
|
|
81
|
+
try {
|
|
82
|
+
return JSON.parse(e);
|
|
83
|
+
} catch {
|
|
84
|
+
return {};
|
|
85
|
+
}
|
|
86
|
+
return {};
|
|
87
|
+
})(), l = Array.isArray(r.choices) ? r.choices : null;
|
|
88
|
+
(a.interface ?? "") === "select-dropdown" && l && l.length > 0 ? s = /* @__PURE__ */ n(
|
|
89
|
+
b,
|
|
90
|
+
{
|
|
91
|
+
value: t != null ? String(t) : "",
|
|
92
|
+
onChange: (e) => {
|
|
93
|
+
if (e === "") return u(null);
|
|
94
|
+
const f = l.find((h) => String(h.value) === e);
|
|
95
|
+
u((f == null ? void 0 : f.value) ?? e);
|
|
96
|
+
},
|
|
97
|
+
className: "h-7 w-full rounded border-slate-200 bg-white px-1.5 py-1 text-[11px] dark:bg-card dark:border-border",
|
|
98
|
+
options: [
|
|
99
|
+
{ value: "", label: "—" },
|
|
100
|
+
...l.map((e) => ({ value: String(e.value), label: e.text ?? String(e.value) }))
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
) : s = /* @__PURE__ */ n(k, { value: t, numeric: c === "integer" || c === "decimal" || c === "float" || c === "number", onChange: (f) => u(f, !0) });
|
|
104
|
+
}
|
|
105
|
+
return s;
|
|
106
|
+
}
|
|
107
|
+
function k({
|
|
108
|
+
value: t,
|
|
109
|
+
numeric: p,
|
|
110
|
+
onChange: d
|
|
111
|
+
}) {
|
|
112
|
+
const i = N(t != null ? String(t) : "");
|
|
113
|
+
return /* @__PURE__ */ n(
|
|
114
|
+
x,
|
|
115
|
+
{
|
|
116
|
+
value: i.value,
|
|
117
|
+
onChange: (o) => {
|
|
118
|
+
const a = o.target.value;
|
|
119
|
+
if (i.set(a), a === "") return d(null);
|
|
120
|
+
d(p && !Number.isNaN(Number(a)) ? Number(a) : a);
|
|
121
|
+
},
|
|
122
|
+
...i.props,
|
|
123
|
+
"aria-label": "Default value",
|
|
124
|
+
placeholder: "No default",
|
|
125
|
+
className: "h-7 text-[11px]"
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
export {
|
|
130
|
+
D as FieldDefaultValueControl
|
|
131
|
+
};
|