@nivaro/react 0.2.51 → 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 +4044 -3866
- 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,213 @@
|
|
|
1
|
+
import { jsxs as a, Fragment as u, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useState as _ } from "react";
|
|
3
|
+
import { RecordConditionsEditor as O, RecordConditionsJson as R } from "../editors/RecordConditionsEditor.js";
|
|
4
|
+
import { RolesPicker as A } from "../editors/RolesPicker.js";
|
|
5
|
+
import { LAYOUT_TYPES as w } from "../overview/OverviewActions.js";
|
|
6
|
+
import { useRoleNames as D } from "../overview/overview-api.js";
|
|
7
|
+
import { Setting as y, smallBtn as s, quietText as C, Segmented as z } from "./controls.js";
|
|
8
|
+
import { changeLabel as N, flag as x } from "./section-props.js";
|
|
9
|
+
import { useFieldSources as F, useCollectionLayoutList as Y } from "./settings-api.js";
|
|
10
|
+
import { layoutKindOf as j } from "./settings-registry.js";
|
|
11
|
+
import { TextSetting as v } from "./TextSetting.js";
|
|
12
|
+
import { ToggleSetting as I } from "./ToggleSetting.js";
|
|
13
|
+
const f = (e) => {
|
|
14
|
+
var t;
|
|
15
|
+
return ((t = w.find((n) => n.type === e)) == null ? void 0 : t.label) ?? e;
|
|
16
|
+
}, K = (e) => e.toLowerCase().replace(/[^a-z0-9_]/g, "_"), S = (e) => e.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_|_$/g, "");
|
|
17
|
+
function M(e) {
|
|
18
|
+
let t = e;
|
|
19
|
+
if (typeof t == "string")
|
|
20
|
+
try {
|
|
21
|
+
t = JSON.parse(t);
|
|
22
|
+
} catch {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
const n = t == null ? void 0 : t.role_ids;
|
|
26
|
+
return Array.isArray(n) ? n.map(String) : [];
|
|
27
|
+
}
|
|
28
|
+
function ee(e) {
|
|
29
|
+
const { layout: t, collection: n } = e, { fields: m, columns: i, relations: c } = F(n), { data: h = [] } = D(!0), d = M(t.conditions);
|
|
30
|
+
return /* @__PURE__ */ a(u, { children: [
|
|
31
|
+
/* @__PURE__ */ o(P, { ...e }),
|
|
32
|
+
/* @__PURE__ */ o(
|
|
33
|
+
y,
|
|
34
|
+
{
|
|
35
|
+
k: "layout.record_conditions",
|
|
36
|
+
note: /* @__PURE__ */ o(
|
|
37
|
+
R,
|
|
38
|
+
{
|
|
39
|
+
value: t.record_conditions,
|
|
40
|
+
onApply: (r) => e.set({ record_conditions: r }, N("layout.record_conditions"))
|
|
41
|
+
}
|
|
42
|
+
),
|
|
43
|
+
children: /* @__PURE__ */ o(
|
|
44
|
+
O,
|
|
45
|
+
{
|
|
46
|
+
json: !1,
|
|
47
|
+
collection: n,
|
|
48
|
+
value: t.record_conditions,
|
|
49
|
+
fields: m,
|
|
50
|
+
columns: i,
|
|
51
|
+
relations: c,
|
|
52
|
+
onBlur: e.flush,
|
|
53
|
+
onChange: (r, { text: b }) => (b ? e.setText : e.set)(
|
|
54
|
+
{ record_conditions: r },
|
|
55
|
+
N("layout.record_conditions")
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
/* @__PURE__ */ o(y, { k: "layout.conditions.role_ids", children: /* @__PURE__ */ o(
|
|
62
|
+
A,
|
|
63
|
+
{
|
|
64
|
+
value: d,
|
|
65
|
+
roles: h,
|
|
66
|
+
onChange: (r) => e.set(
|
|
67
|
+
{ conditions: r.length ? { role_ids: r } : null },
|
|
68
|
+
r.length > d.length ? "Add a role" : "Remove a role"
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
) }),
|
|
72
|
+
/* @__PURE__ */ o(
|
|
73
|
+
v,
|
|
74
|
+
{
|
|
75
|
+
k: "layout.slug",
|
|
76
|
+
props: e,
|
|
77
|
+
mono: !0,
|
|
78
|
+
placeholder: "e.g. unit_order",
|
|
79
|
+
sanitize: K,
|
|
80
|
+
blurOnly: !0,
|
|
81
|
+
extra: !t.slug && typeof t.name == "string" && S(t.name) ? /* @__PURE__ */ o(
|
|
82
|
+
"button",
|
|
83
|
+
{
|
|
84
|
+
type: "button",
|
|
85
|
+
className: s,
|
|
86
|
+
onClick: () => e.set({ slug: S(String(t.name)) }, "Generate link name"),
|
|
87
|
+
children: "Generate"
|
|
88
|
+
}
|
|
89
|
+
) : null,
|
|
90
|
+
note: t.slug ? /* @__PURE__ */ a(u, { children: [
|
|
91
|
+
"Opens with ",
|
|
92
|
+
/* @__PURE__ */ a("code", { className: "font-mono", children: [
|
|
93
|
+
"?layout=",
|
|
94
|
+
String(t.slug)
|
|
95
|
+
] })
|
|
96
|
+
] }) : null
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
/* @__PURE__ */ o(
|
|
100
|
+
v,
|
|
101
|
+
{
|
|
102
|
+
k: "layout.create_label",
|
|
103
|
+
props: e,
|
|
104
|
+
placeholder: typeof t.name == "string" ? t.name : ""
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ o(I, { k: "layout.create_hidden", props: e })
|
|
108
|
+
] });
|
|
109
|
+
}
|
|
110
|
+
function P(e) {
|
|
111
|
+
const { layout: t, kind: n, bundle: m } = e, [i, c] = _(null), h = m.placements.length + m.groups.length, d = (l) => e.set({ layout_type: l }, `Change kind to ${f(l)}`), r = x(t.is_active), [b, g] = _(!1), p = Y(e.collection).find(
|
|
112
|
+
(l) => l.id !== Number(t.id) && j(l) === n && x(l.is_active)
|
|
113
|
+
), k = n === "grouped" ? "form" : `${f(n).toLowerCase()} layout`, L = () => {
|
|
114
|
+
e.set({ is_active: !0 }, "Make default", { undoable: !1 }), g(!1);
|
|
115
|
+
}, T = n === "file" ? null : /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-2", children: r ? /* @__PURE__ */ a("span", { className: C, "data-default-layout": !0, children: [
|
|
116
|
+
"This is the default ",
|
|
117
|
+
f(n).toLowerCase(),
|
|
118
|
+
" layout: records no rule or role catches use it."
|
|
119
|
+
] }) : b ? /* @__PURE__ */ a(
|
|
120
|
+
"div",
|
|
121
|
+
{
|
|
122
|
+
"data-make-default-confirm": !0,
|
|
123
|
+
className: "w-full rounded-md border border-amber-300 bg-amber-50 p-2 text-[12px] text-amber-900 dark:border-amber-400/30 dark:bg-amber-400/10 dark:text-amber-200",
|
|
124
|
+
children: [
|
|
125
|
+
/* @__PURE__ */ a("p", { children: [
|
|
126
|
+
p ? /* @__PURE__ */ a(u, { children: [
|
|
127
|
+
/* @__PURE__ */ o("strong", { className: "font-semibold", children: p.name }),
|
|
128
|
+
" stops being the default",
|
|
129
|
+
" ",
|
|
130
|
+
k,
|
|
131
|
+
" for records no rule catches."
|
|
132
|
+
] }) : /* @__PURE__ */ a(u, { children: [
|
|
133
|
+
"No ",
|
|
134
|
+
k,
|
|
135
|
+
" is the default yet; this one becomes it."
|
|
136
|
+
] }),
|
|
137
|
+
" ",
|
|
138
|
+
"This cannot be undone with Undo."
|
|
139
|
+
] }),
|
|
140
|
+
/* @__PURE__ */ a("div", { className: "mt-1.5 flex gap-1.5", children: [
|
|
141
|
+
/* @__PURE__ */ o(
|
|
142
|
+
"button",
|
|
143
|
+
{
|
|
144
|
+
type: "button",
|
|
145
|
+
"data-action": "make-default-confirm",
|
|
146
|
+
className: s,
|
|
147
|
+
onClick: L,
|
|
148
|
+
children: "Yes, make default"
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
/* @__PURE__ */ o("button", { type: "button", className: s, onClick: () => g(!1), children: "Cancel" })
|
|
152
|
+
] })
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
) : /* @__PURE__ */ a(u, { children: [
|
|
156
|
+
/* @__PURE__ */ o(
|
|
157
|
+
"button",
|
|
158
|
+
{
|
|
159
|
+
type: "button",
|
|
160
|
+
"data-action": "make-default",
|
|
161
|
+
className: s,
|
|
162
|
+
onClick: () => g(!0),
|
|
163
|
+
children: "Make default"
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
/* @__PURE__ */ o("span", { className: C, children: "Records no rule or role catches would open with this layout." })
|
|
167
|
+
] }) });
|
|
168
|
+
return /* @__PURE__ */ a(y, { k: "layout.layout_type", note: T, children: [
|
|
169
|
+
/* @__PURE__ */ o(
|
|
170
|
+
z,
|
|
171
|
+
{
|
|
172
|
+
ariaLabel: "Kind of layout",
|
|
173
|
+
value: n,
|
|
174
|
+
options: w.map((l) => ({ value: l.type, label: l.label })),
|
|
175
|
+
onChange: (l) => h > 0 ? c(l) : d(l)
|
|
176
|
+
}
|
|
177
|
+
),
|
|
178
|
+
i && /* @__PURE__ */ a(
|
|
179
|
+
"div",
|
|
180
|
+
{
|
|
181
|
+
"data-kind-confirm": i,
|
|
182
|
+
className: "rounded-md border border-amber-300 bg-amber-50 p-2.5 text-[12px] text-amber-900 dark:border-amber-400/30 dark:bg-amber-400/10 dark:text-amber-200",
|
|
183
|
+
children: [
|
|
184
|
+
/* @__PURE__ */ a("p", { children: [
|
|
185
|
+
"Make this a ",
|
|
186
|
+
f(i),
|
|
187
|
+
" layout? Its sections and fields stay, but",
|
|
188
|
+
" ",
|
|
189
|
+
i === "file" ? "tabs, widgets and slot cards do not appear in a PDF." : i === "table" ? "grid columns use only its fields, not its sections." : "some of them may not apply to this kind."
|
|
190
|
+
] }),
|
|
191
|
+
/* @__PURE__ */ a("div", { className: "mt-1.5 flex gap-1.5", children: [
|
|
192
|
+
/* @__PURE__ */ o(
|
|
193
|
+
"button",
|
|
194
|
+
{
|
|
195
|
+
type: "button",
|
|
196
|
+
className: s,
|
|
197
|
+
onClick: () => {
|
|
198
|
+
d(i), c(null);
|
|
199
|
+
},
|
|
200
|
+
children: "Yes, change it"
|
|
201
|
+
}
|
|
202
|
+
),
|
|
203
|
+
/* @__PURE__ */ o("button", { type: "button", className: s, onClick: () => c(null), children: "Cancel" })
|
|
204
|
+
] })
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
] });
|
|
209
|
+
}
|
|
210
|
+
export {
|
|
211
|
+
ee as WhoSection,
|
|
212
|
+
K as sanitizeSlug
|
|
213
|
+
};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronsUpDown as k, Check as f, X as w } from "lucide-react";
|
|
3
|
+
import { createContext as C, isValidElement as S, useState as T, useContext as P } from "react";
|
|
4
|
+
import { cn as i } from "../../../lib/utils.js";
|
|
5
|
+
import { Command as j, CommandInput as O, CommandList as V, CommandEmpty as B, CommandItem as b } from "../../ui/command.js";
|
|
6
|
+
import { Popover as D, PopoverTrigger as E, PopoverContent as I } from "../../ui/popover.js";
|
|
7
|
+
import { inputBase as v, effectText as $, labelText as q, segOption as U, segTrack as X } from "../panel-style.js";
|
|
8
|
+
import { settingDef as z } from "./settings-registry.js";
|
|
9
|
+
const A = C(null);
|
|
10
|
+
function F(e) {
|
|
11
|
+
const n = P(A);
|
|
12
|
+
return !n || n.has(e);
|
|
13
|
+
}
|
|
14
|
+
const Z = v, _ = "inline-flex h-7 items-center gap-1 whitespace-nowrap rounded-md border border-slate-200 bg-white px-2 text-[12px] font-medium text-slate-700 transition-colors hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:bg-card dark:text-foreground dark:hover:bg-muted", g = $;
|
|
15
|
+
function L({
|
|
16
|
+
k: e,
|
|
17
|
+
control: n,
|
|
18
|
+
children: o,
|
|
19
|
+
note: r,
|
|
20
|
+
htmlFor: c
|
|
21
|
+
}) {
|
|
22
|
+
const s = F(e), d = z(e);
|
|
23
|
+
if (!s || !d) return null;
|
|
24
|
+
const m = S(n) && n.type === G;
|
|
25
|
+
return /* @__PURE__ */ l("div", { "data-setting": e, className: "space-y-1.5", children: [
|
|
26
|
+
/* @__PURE__ */ l("div", { className: "flex min-h-5 items-center justify-between gap-3", children: [
|
|
27
|
+
/* @__PURE__ */ t("label", { htmlFor: c, className: i(q, "min-w-0"), children: d.label }),
|
|
28
|
+
m && /* @__PURE__ */ t("div", { className: "flex shrink-0 items-center", children: n })
|
|
29
|
+
] }),
|
|
30
|
+
n && !m && /* @__PURE__ */ t("div", { children: n }),
|
|
31
|
+
o,
|
|
32
|
+
/* @__PURE__ */ t("p", { className: g, children: d.effect }),
|
|
33
|
+
r && /* @__PURE__ */ t("div", { className: g, children: r })
|
|
34
|
+
] });
|
|
35
|
+
}
|
|
36
|
+
function G({
|
|
37
|
+
checked: e,
|
|
38
|
+
onChange: n,
|
|
39
|
+
label: o,
|
|
40
|
+
disabled: r
|
|
41
|
+
}) {
|
|
42
|
+
return /* @__PURE__ */ t(
|
|
43
|
+
"button",
|
|
44
|
+
{
|
|
45
|
+
type: "button",
|
|
46
|
+
role: "switch",
|
|
47
|
+
"aria-checked": e,
|
|
48
|
+
"aria-label": o,
|
|
49
|
+
disabled: r,
|
|
50
|
+
onClick: () => n(!e),
|
|
51
|
+
className: i(
|
|
52
|
+
"relative inline-flex h-[18px] w-8 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 disabled:cursor-not-allowed disabled:opacity-40",
|
|
53
|
+
e ? "bg-nvr-cyan" : "bg-slate-300 dark:bg-slate-600"
|
|
54
|
+
),
|
|
55
|
+
children: /* @__PURE__ */ t(
|
|
56
|
+
"span",
|
|
57
|
+
{
|
|
58
|
+
className: i(
|
|
59
|
+
"inline-block h-3.5 w-3.5 rounded-full bg-white shadow-sm transition-transform",
|
|
60
|
+
e ? "translate-x-[16px]" : "translate-x-[2px]"
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
function ee({
|
|
68
|
+
value: e,
|
|
69
|
+
options: n,
|
|
70
|
+
onChange: o,
|
|
71
|
+
ariaLabel: r,
|
|
72
|
+
disabled: c
|
|
73
|
+
}) {
|
|
74
|
+
return /* @__PURE__ */ t(
|
|
75
|
+
"fieldset",
|
|
76
|
+
{
|
|
77
|
+
"aria-label": r,
|
|
78
|
+
className: i("m-0 min-w-0 border-0", X(n.length)),
|
|
79
|
+
children: n.map((s) => /* @__PURE__ */ t(
|
|
80
|
+
"button",
|
|
81
|
+
{
|
|
82
|
+
type: "button",
|
|
83
|
+
"aria-pressed": e === s.value,
|
|
84
|
+
disabled: c,
|
|
85
|
+
onClick: () => e !== s.value && o(s.value),
|
|
86
|
+
className: U(e === s.value),
|
|
87
|
+
children: s.label
|
|
88
|
+
},
|
|
89
|
+
s.value
|
|
90
|
+
))
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
function te({
|
|
95
|
+
value: e,
|
|
96
|
+
options: n,
|
|
97
|
+
onChange: o,
|
|
98
|
+
placeholder: r = "Pick…",
|
|
99
|
+
clearLabel: c,
|
|
100
|
+
ariaLabel: s,
|
|
101
|
+
disabled: d,
|
|
102
|
+
className: m,
|
|
103
|
+
emptyText: N = "Nothing to pick"
|
|
104
|
+
}) {
|
|
105
|
+
const [y, u] = T(!1), p = n.find((a) => a.value === e), h = (a) => {
|
|
106
|
+
o(a), u(!1);
|
|
107
|
+
}, x = "gap-1.5 px-2 py-1 text-[12px] text-slate-700 data-[selected=true]:bg-muted dark:text-foreground";
|
|
108
|
+
return /* @__PURE__ */ l(D, { open: y, onOpenChange: u, children: [
|
|
109
|
+
/* @__PURE__ */ t(E, { asChild: !0, children: /* @__PURE__ */ l(
|
|
110
|
+
"button",
|
|
111
|
+
{
|
|
112
|
+
type: "button",
|
|
113
|
+
"aria-label": s,
|
|
114
|
+
disabled: d,
|
|
115
|
+
"data-pick-list": s,
|
|
116
|
+
className: i(
|
|
117
|
+
v,
|
|
118
|
+
"flex min-w-[140px] items-center justify-between gap-1.5 text-left hover:border-slate-300",
|
|
119
|
+
m
|
|
120
|
+
),
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ t(
|
|
123
|
+
"span",
|
|
124
|
+
{
|
|
125
|
+
className: i(
|
|
126
|
+
"truncate",
|
|
127
|
+
p ? "text-slate-800 dark:text-foreground" : "text-slate-500"
|
|
128
|
+
),
|
|
129
|
+
children: (p == null ? void 0 : p.label) ?? (e || (c ?? r))
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
/* @__PURE__ */ t(k, { className: "h-3.5 w-3.5 shrink-0 text-slate-500" })
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
) }),
|
|
136
|
+
/* @__PURE__ */ t(I, { className: "w-64 p-0", align: "end", children: /* @__PURE__ */ l(j, { children: [
|
|
137
|
+
/* @__PURE__ */ t(
|
|
138
|
+
O,
|
|
139
|
+
{
|
|
140
|
+
placeholder: "Search…",
|
|
141
|
+
"aria-label": `Search ${s}`,
|
|
142
|
+
className: "h-8 text-[12px]"
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
/* @__PURE__ */ l(V, { className: "max-h-60", "aria-label": s, children: [
|
|
146
|
+
/* @__PURE__ */ t(B, { className: "px-2 py-1.5 text-[12px] text-slate-500 dark:text-slate-400", children: N }),
|
|
147
|
+
c && /* @__PURE__ */ l(
|
|
148
|
+
b,
|
|
149
|
+
{
|
|
150
|
+
value: "—none—",
|
|
151
|
+
keywords: [c],
|
|
152
|
+
onSelect: () => h(null),
|
|
153
|
+
className: i(x, "text-slate-500 dark:text-slate-400"),
|
|
154
|
+
children: [
|
|
155
|
+
/* @__PURE__ */ t(f, { className: i("h-3 w-3", e ? "opacity-0" : "opacity-100") }),
|
|
156
|
+
/* @__PURE__ */ t("span", { children: c })
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
n.map((a) => /* @__PURE__ */ l(
|
|
161
|
+
b,
|
|
162
|
+
{
|
|
163
|
+
value: a.value,
|
|
164
|
+
keywords: [a.label, a.hint ?? ""],
|
|
165
|
+
"data-option": a.value,
|
|
166
|
+
onSelect: () => h(a.value),
|
|
167
|
+
className: i(x, a.value === e && "bg-accent"),
|
|
168
|
+
children: [
|
|
169
|
+
/* @__PURE__ */ t(
|
|
170
|
+
f,
|
|
171
|
+
{
|
|
172
|
+
className: i(
|
|
173
|
+
"h-3 w-3 shrink-0",
|
|
174
|
+
a.value === e ? "opacity-100" : "opacity-0"
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
),
|
|
178
|
+
/* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate", children: a.label }),
|
|
179
|
+
a.hint && /* @__PURE__ */ t("span", { className: "shrink-0 font-mono text-[11px] text-slate-500 dark:text-slate-400", children: a.hint })
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
a.value
|
|
183
|
+
))
|
|
184
|
+
] })
|
|
185
|
+
] }) })
|
|
186
|
+
] });
|
|
187
|
+
}
|
|
188
|
+
function ne({ label: e, onRemove: n }) {
|
|
189
|
+
return /* @__PURE__ */ l("span", { className: "inline-flex max-w-full items-center gap-1 rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[12px] font-medium text-nvr-navy dark:text-nvr-cyan", children: [
|
|
190
|
+
/* @__PURE__ */ t("span", { className: "truncate", children: e }),
|
|
191
|
+
n && /* @__PURE__ */ t(
|
|
192
|
+
"button",
|
|
193
|
+
{
|
|
194
|
+
type: "button",
|
|
195
|
+
"aria-label": `Remove ${e}`,
|
|
196
|
+
onClick: n,
|
|
197
|
+
className: "shrink-0 opacity-70 hover:opacity-100",
|
|
198
|
+
children: /* @__PURE__ */ t(w, { className: "h-3 w-3" })
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
] });
|
|
202
|
+
}
|
|
203
|
+
export {
|
|
204
|
+
ne as Chip,
|
|
205
|
+
te as PickList,
|
|
206
|
+
ee as Segmented,
|
|
207
|
+
L as Setting,
|
|
208
|
+
G as Toggle,
|
|
209
|
+
A as VisibleSettingsContext,
|
|
210
|
+
Z as inputCls,
|
|
211
|
+
g as quietText,
|
|
212
|
+
_ as smallBtn,
|
|
213
|
+
F as useSettingVisible
|
|
214
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { settingDef as o } from "./settings-registry.js";
|
|
2
|
+
const r = (e) => e === !0 || e === 1 || e === "1" || e === "true";
|
|
3
|
+
function a(e, n) {
|
|
4
|
+
var t;
|
|
5
|
+
return `Turn ${n ? "on" : "off"} ${((t = o(e)) == null ? void 0 : t.label) ?? e}`;
|
|
6
|
+
}
|
|
7
|
+
function u(e) {
|
|
8
|
+
var n;
|
|
9
|
+
return `Change ${((n = o(e)) == null ? void 0 : n.label) ?? e}`;
|
|
10
|
+
}
|
|
11
|
+
const c = (e) => e.replace(/^layout\./, "");
|
|
12
|
+
export {
|
|
13
|
+
u as changeLabel,
|
|
14
|
+
c as column,
|
|
15
|
+
r as flag,
|
|
16
|
+
a as toggleLabel
|
|
17
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { useQuery as a } from "@tanstack/react-query";
|
|
2
|
+
import { useNivaroClient as o } from "../../../context.js";
|
|
3
|
+
import { get as l } from "../../../lib/commands.js";
|
|
4
|
+
import { titleCase as c } from "../../../lib/utils.js";
|
|
5
|
+
import { useOverviewFields as f } from "../overview/overview-api.js";
|
|
6
|
+
const u = {
|
|
7
|
+
relations: (e) => ["layout-editor", "relations", e],
|
|
8
|
+
columns: (e) => ["layout-editor", "columns", e],
|
|
9
|
+
layouts: (e, t) => ["layout-editor", "layouts", e, t ?? "all"],
|
|
10
|
+
pipelines: () => ["layout-editor", "pipelines"],
|
|
11
|
+
pdfTemplates: (e) => ["layout-editor", "pdf-templates", e],
|
|
12
|
+
rolePreview: (e, t) => ["layout-editor", "role-preview", e, t]
|
|
13
|
+
}, d = (e) => Array.isArray(e == null ? void 0 : e.data) ? e == null ? void 0 : e.data : [];
|
|
14
|
+
function K(e) {
|
|
15
|
+
const t = p(e), n = y(e), i = q(e);
|
|
16
|
+
return { fields: t, columns: n, relations: i };
|
|
17
|
+
}
|
|
18
|
+
function p(e) {
|
|
19
|
+
return f(e).data ?? [];
|
|
20
|
+
}
|
|
21
|
+
function y(e) {
|
|
22
|
+
const t = o();
|
|
23
|
+
return a({
|
|
24
|
+
queryKey: u.columns(e),
|
|
25
|
+
queryFn: () => t.request(l(`/data-model/${e}`)).then((n) => {
|
|
26
|
+
var i;
|
|
27
|
+
return Array.isArray((i = n == null ? void 0 : n.data) == null ? void 0 : i.columns) ? n.data.columns : [];
|
|
28
|
+
}).catch(() => []),
|
|
29
|
+
staleTime: 6e4
|
|
30
|
+
}).data ?? [];
|
|
31
|
+
}
|
|
32
|
+
function q(e) {
|
|
33
|
+
const t = o();
|
|
34
|
+
return a({
|
|
35
|
+
queryKey: u.relations(e),
|
|
36
|
+
queryFn: () => t.request(l(`/data-model/relations/for/${e}`)).then(d),
|
|
37
|
+
staleTime: 6e4
|
|
38
|
+
}).data ?? [];
|
|
39
|
+
}
|
|
40
|
+
function T(e, t) {
|
|
41
|
+
const n = o();
|
|
42
|
+
return a({
|
|
43
|
+
queryKey: u.layouts(e, t),
|
|
44
|
+
queryFn: () => n.request(
|
|
45
|
+
l("/collection-layouts", {
|
|
46
|
+
collection: e,
|
|
47
|
+
...t ? { layout_type: t } : {}
|
|
48
|
+
})
|
|
49
|
+
).then((i) => d(i).filter((s) => !t || s.layout_type === t)),
|
|
50
|
+
staleTime: 15e3
|
|
51
|
+
}).data ?? [];
|
|
52
|
+
}
|
|
53
|
+
function _(e) {
|
|
54
|
+
const t = o();
|
|
55
|
+
return a({
|
|
56
|
+
queryKey: u.pipelines(),
|
|
57
|
+
queryFn: () => t.request(l("/pipelines")).then((n) => d(n).map((i) => ({ id: String(i.id), name: String(i.name) }))),
|
|
58
|
+
enabled: e,
|
|
59
|
+
staleTime: 5 * 6e4
|
|
60
|
+
}).data ?? [];
|
|
61
|
+
}
|
|
62
|
+
function A(e, t) {
|
|
63
|
+
const n = o();
|
|
64
|
+
return a({
|
|
65
|
+
queryKey: u.pdfTemplates(e),
|
|
66
|
+
queryFn: () => n.request(
|
|
67
|
+
l("/pdf-templates", { collection: e })
|
|
68
|
+
).then((i) => d(i).map((s) => ({ id: Number(s.id), name: String(s.name) }))),
|
|
69
|
+
enabled: t,
|
|
70
|
+
staleTime: 6e4
|
|
71
|
+
}).data ?? [];
|
|
72
|
+
}
|
|
73
|
+
function L(e, t) {
|
|
74
|
+
const n = o();
|
|
75
|
+
return a({
|
|
76
|
+
queryKey: u.rolePreview(e, t ?? ""),
|
|
77
|
+
queryFn: () => n.request(
|
|
78
|
+
l("/collection-layouts/preview-as-role", { collection: e, role_id: t })
|
|
79
|
+
).then((i) => (i == null ? void 0 : i.data) ?? null),
|
|
80
|
+
enabled: !!t,
|
|
81
|
+
staleTime: 15e3
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function g(e, t) {
|
|
85
|
+
var i;
|
|
86
|
+
const n = (i = e.find((s) => s.field === t)) == null ? void 0 : i.label;
|
|
87
|
+
return n != null && n.trim() ? n.trim() : c(t);
|
|
88
|
+
}
|
|
89
|
+
const h = /* @__PURE__ */ new Set([
|
|
90
|
+
"integer",
|
|
91
|
+
"biginteger",
|
|
92
|
+
"bigint",
|
|
93
|
+
"int",
|
|
94
|
+
"smallint",
|
|
95
|
+
"tinyint",
|
|
96
|
+
"decimal",
|
|
97
|
+
"numeric",
|
|
98
|
+
"float",
|
|
99
|
+
"double",
|
|
100
|
+
"real",
|
|
101
|
+
"money"
|
|
102
|
+
]);
|
|
103
|
+
function b(e, t) {
|
|
104
|
+
const n = /* @__PURE__ */ new Set();
|
|
105
|
+
for (const i of t)
|
|
106
|
+
i.one_collection === e && i.one_field && n.add(i.one_field);
|
|
107
|
+
return n;
|
|
108
|
+
}
|
|
109
|
+
function F(e, t, n, i) {
|
|
110
|
+
if (n.length) return n.map((r) => r.name);
|
|
111
|
+
const s = b(e, i), m = (r) => String(r.type ?? "").toLowerCase();
|
|
112
|
+
return t.filter(
|
|
113
|
+
(r) => !r.field.includes(".") && !s.has(r.field) && !m(r).startsWith("alias") && m(r) !== "o2m" && m(r) !== "m2m"
|
|
114
|
+
).map((r) => r.field);
|
|
115
|
+
}
|
|
116
|
+
function O(e, t, n, i) {
|
|
117
|
+
const s = (r) => h.has(String(r ?? "").toLowerCase());
|
|
118
|
+
if (n.length) return n.filter((r) => s(r.data_type)).map((r) => r.name);
|
|
119
|
+
const m = new Set(F(e, t, n, i));
|
|
120
|
+
return t.filter((r) => m.has(r.field) && s(r.type)).map((r) => r.field);
|
|
121
|
+
}
|
|
122
|
+
function P(e, t) {
|
|
123
|
+
return t.map((n) => ({ value: n, label: g(e, n), hint: n })).sort((n, i) => n.label.localeCompare(i.label));
|
|
124
|
+
}
|
|
125
|
+
function R(e) {
|
|
126
|
+
if (e && typeof e == "object") return e;
|
|
127
|
+
if (typeof e != "string") return {};
|
|
128
|
+
try {
|
|
129
|
+
const t = JSON.parse(e);
|
|
130
|
+
return t && typeof t == "object" ? t : {};
|
|
131
|
+
} catch {
|
|
132
|
+
return {};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export {
|
|
136
|
+
g as fieldLabel,
|
|
137
|
+
P as fieldOptions,
|
|
138
|
+
O as numericFieldNames,
|
|
139
|
+
R as parseFieldOptions,
|
|
140
|
+
b as relationAliasNames,
|
|
141
|
+
u as settingsKeys,
|
|
142
|
+
F as storedFieldNames,
|
|
143
|
+
T as useCollectionLayoutList,
|
|
144
|
+
K as useFieldSources,
|
|
145
|
+
A as usePdfTemplates,
|
|
146
|
+
L as useRolePreview,
|
|
147
|
+
p as useSettingsFields,
|
|
148
|
+
q as useSettingsRelations,
|
|
149
|
+
y as useTableColumns,
|
|
150
|
+
_ as useWorkflowTemplates
|
|
151
|
+
};
|