@nivaro/react 0.3.36 → 0.3.37
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/components/slots/CommentsSlot.js +44 -36
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/shared/components/AgentBadge.js +26 -0
- package/dist/shared/components/AgentQuestionsCard.js +198 -0
- package/dist/shared/components/ItemEditForm.js +3329 -3263
- package/dist/shared/components/McpConnectionScope.js +480 -0
- package/dist/shared/components/MyWorkView.js +223 -208
- package/dist/shared/components/RecordReadView.js +620 -575
- package/dist/shared/components/chat/ChatPanel.js +683 -671
- package/dist/shared/components/imports/DownloadSampleButton.js +69 -0
- package/dist/shared/components/imports/ImportConsole.js +106 -104
- package/dist/shared/components/imports/RunDetailSheet.js +11 -10
- package/dist/shared/components/item-edit/FieldAffordances.js +32 -32
- package/dist/shared/components/item-edit/FormTour.js +279 -0
- package/dist/shared/components/item-edit/GroupSection.js +377 -360
- package/dist/shared/components/item-edit/PersonalDefaultControl.js +28 -28
- package/dist/shared/components/item-edit/entry/EntryStrip.js +30 -26
- package/dist/shared/components/item-edit/form-density.js +36 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -46
- package/dist/shared/components/item-edit/usePersonalDefaults.js +312 -296
- package/dist/shared/components/layout-editor/AddPanel.js +349 -192
- package/dist/shared/components/layout-editor/DesignNode.js +126 -112
- package/dist/shared/components/layout-editor/EditorTopBar.js +123 -103
- package/dist/shared/components/layout-editor/LayoutEditor.js +829 -751
- package/dist/shared/components/layout-editor/PlaceTools.js +334 -0
- package/dist/shared/components/layout-editor/SlashInsert.js +252 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +285 -242
- package/dist/shared/components/layout-editor/add-target.js +54 -43
- package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +238 -155
- package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +1 -1
- package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +15 -12
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +347 -189
- package/dist/shared/components/layout-editor/dnd/TrashZone.js +60 -32
- package/dist/shared/components/layout-editor/dnd/UndoChip.js +76 -0
- package/dist/shared/components/layout-editor/dnd/merge-drop.js +33 -0
- package/dist/shared/components/layout-editor/dnd/multi-drop.js +87 -0
- package/dist/shared/components/layout-editor/dnd/node.js +115 -105
- package/dist/shared/components/layout-editor/dnd/sensors.js +23 -0
- package/dist/shared/components/layout-editor/dnd/trash-drop.js +34 -28
- package/dist/shared/components/layout-editor/dnd/trash-links.js +97 -0
- package/dist/shared/components/layout-editor/even-row.js +86 -0
- package/dist/shared/components/layout-editor/field-list.js +99 -0
- package/dist/shared/components/layout-editor/format-painter.js +102 -0
- package/dist/shared/components/layout-editor/grid-guides.js +15 -13
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +150 -132
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +57 -53
- package/dist/shared/components/layout-editor/inspector/EvenRowAction.js +31 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +154 -141
- package/dist/shared/components/layout-editor/inspector/Inspector.js +209 -178
- package/dist/shared/components/layout-editor/inspector/LookTab.js +106 -98
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +38 -37
- package/dist/shared/components/layout-editor/inspector/kit.js +280 -223
- package/dist/shared/components/layout-editor/keyboard-move.js +15 -15
- package/dist/shared/components/layout-editor/lint/LabelStyle.js +201 -0
- package/dist/shared/components/layout-editor/lint/LintPanel.js +132 -84
- package/dist/shared/components/layout-editor/lint/lint-api.js +65 -28
- package/dist/shared/components/layout-editor/nav/NavTools.js +14 -12
- package/dist/shared/components/layout-editor/nav/ZoomControls.js +145 -0
- package/dist/shared/components/layout-editor/nav/useEditorNav.js +34 -32
- package/dist/shared/components/layout-editor/nav/view-prefs.js +100 -15
- package/dist/shared/components/layout-editor/outputs/LayoutFile.js +89 -0
- package/dist/shared/components/layout-editor/outputs/OutputsButton.js +272 -195
- package/dist/shared/components/layout-editor/outputs/layout-file-plan.js +176 -0
- package/dist/shared/components/layout-editor/outputs/output-api.js +71 -37
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +16 -11
- package/dist/shared/components/layout-editor/overview/purpose.js +5 -5
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/layout-editor/pin.js +37 -19
- package/dist/shared/components/layout-editor/place-clip.js +257 -0
- package/dist/shared/components/layout-editor/preview/PreviewModes.js +27 -26
- package/dist/shared/components/layout-editor/preview/PreviewPanes.js +148 -117
- package/dist/shared/components/layout-editor/preview/SampleRecord.js +113 -0
- package/dist/shared/components/layout-editor/preview/preview-model.js +79 -60
- package/dist/shared/components/layout-editor/preview/sample-record.js +105 -0
- package/dist/shared/components/layout-editor/removed-log.js +151 -0
- package/dist/shared/components/layout-editor/reuse/LibraryRows.js +109 -78
- package/dist/shared/components/layout-editor/reuse/linked-sections.js +373 -0
- package/dist/shared/components/layout-editor/revert-element.js +140 -0
- package/dist/shared/components/layout-editor/section-structure.js +193 -170
- package/dist/shared/components/layout-editor/settings/EntrySection.js +63 -45
- package/dist/shared/components/layout-editor/settings/LayoutSection.js +63 -32
- package/dist/shared/components/layout-editor/settings/ResolveSettings.js +179 -137
- package/dist/shared/components/layout-editor/settings/WhoSection.js +18 -17
- package/dist/shared/components/layout-editor/settings/settings-registry.js +24 -0
- package/dist/shared/components/layout-editor/shortcuts.js +21 -16
- package/dist/shared/components/layout-editor/structure-ops.js +221 -195
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +133 -85
- package/dist/shared/components/layout-editor/usage/refusal-lens.js +130 -0
- package/dist/shared/components/layout-editor/usage/usage-api.js +12 -11
- package/dist/shared/components/panels/CommentPanel.js +47 -45
- package/dist/shared/components/panels/RevisionsPanel.js +66 -64
- package/dist/shared/components/panels/TaskPanel.js +395 -332
- package/dist/shared/components/profile/AgentsPanel.js +196 -147
- package/dist/shared/components/profile/ConnectionRollback.js +329 -0
- package/dist/shared/components/profile/MyDefaultsCard.js +526 -520
- package/dist/shared/lib/entry-config.js +22 -22
- package/dist/shared/lib/form-usage-beacon.js +91 -55
- package/dist/shared/lib/layout-lint.js +530 -284
- package/dist/shared/lib/layout-resolve.js +58 -44
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx as l, jsxs as
|
|
2
|
-
import { X as
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { Popover as
|
|
6
|
-
import { bundleToActiveLayout as
|
|
7
|
-
import { useRoleNames as
|
|
1
|
+
import { jsx as l, jsxs as r, Fragment as P } from "react/jsx-runtime";
|
|
2
|
+
import { X as Z } from "lucide-react";
|
|
3
|
+
import { useMemo as x } from "react";
|
|
4
|
+
import { cn as ee } from "../../../lib/utils.js";
|
|
5
|
+
import { Popover as te, PopoverTrigger as le, PopoverContent as se } from "../../ui/popover.js";
|
|
6
|
+
import { bundleToActiveLayout as ae } from "../bundle-to-active.js";
|
|
7
|
+
import { useRoleNames as ne } from "../overview/overview-api.js";
|
|
8
8
|
import { useRolePreview as H } from "../settings/settings-api.js";
|
|
9
9
|
import { fieldName as K } from "./PreviewModes.js";
|
|
10
|
-
import { useCollectionPipelines as
|
|
11
|
-
import { visibilityChanges as
|
|
12
|
-
const
|
|
10
|
+
import { useCollectionPipelines as re, useFieldAccess as oe } from "./preview-api.js";
|
|
11
|
+
import { visibilityChanges as de, fieldAccessForRole as U, compareMarks as ie, fieldsLockedInState as ce, leavingNeeds as he, whoSeesFields as fe, whoTint as me, DEVICE_WIDTH as be, ALL_DEVICE_GAP as G, DEVICE_ORDER as ue, DEVICE_LABEL as J, ALL_DEVICE_WIDTH as X } from "./preview-model.js";
|
|
12
|
+
const T = {
|
|
13
13
|
all: {
|
|
14
14
|
cls: "bg-emerald-50 dark:bg-emerald-500/10",
|
|
15
15
|
swatch: "bg-emerald-200 dark:bg-emerald-500/40",
|
|
@@ -36,9 +36,9 @@ const W = {
|
|
|
36
36
|
label: "No role"
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
function
|
|
40
|
-
return h.length === 0 ? null : /* @__PURE__ */
|
|
41
|
-
/* @__PURE__ */
|
|
39
|
+
function W({ title: n, names: h }) {
|
|
40
|
+
return h.length === 0 ? null : /* @__PURE__ */ r("div", { className: "mt-2 first:mt-0", children: [
|
|
41
|
+
/* @__PURE__ */ r("p", { className: "text-[11.5px] font-semibold text-slate-600 dark:text-muted-foreground", children: [
|
|
42
42
|
n,
|
|
43
43
|
" (",
|
|
44
44
|
h.length,
|
|
@@ -47,10 +47,10 @@ function F({ title: n, names: h }) {
|
|
|
47
47
|
/* @__PURE__ */ l("p", { className: "mt-0.5 text-[12px] leading-snug text-slate-800 dark:text-foreground", children: h.join(", ") })
|
|
48
48
|
] });
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
return /* @__PURE__ */
|
|
53
|
-
/* @__PURE__ */ l(
|
|
50
|
+
function ge({ who: n, label: h }) {
|
|
51
|
+
const N = n.edit.length + n.read.length, s = N + n.hidden.length;
|
|
52
|
+
return /* @__PURE__ */ r(te, { children: [
|
|
53
|
+
/* @__PURE__ */ l(le, { asChild: !0, children: /* @__PURE__ */ r(
|
|
54
54
|
"button",
|
|
55
55
|
{
|
|
56
56
|
type: "button",
|
|
@@ -58,27 +58,27 @@ function he({ who: n, label: h }) {
|
|
|
58
58
|
"aria-label": `Who sees ${h}`,
|
|
59
59
|
className: "inline-flex items-center rounded bg-white px-1 text-[11px] font-medium text-slate-700 ring-1 ring-slate-300 hover:bg-slate-50 dark:bg-card dark:text-foreground dark:ring-border dark:hover:bg-muted",
|
|
60
60
|
children: [
|
|
61
|
-
|
|
61
|
+
N,
|
|
62
62
|
"/",
|
|
63
|
-
|
|
63
|
+
s,
|
|
64
64
|
" roles"
|
|
65
65
|
]
|
|
66
66
|
}
|
|
67
67
|
) }),
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
/* @__PURE__ */
|
|
68
|
+
/* @__PURE__ */ r(se, { align: "end", className: "w-[280px] p-3", "data-design-pass": "", children: [
|
|
69
|
+
/* @__PURE__ */ r("p", { className: "mb-2 text-[12.5px] font-semibold text-slate-900 dark:text-foreground", children: [
|
|
70
70
|
"Who sees ",
|
|
71
71
|
h
|
|
72
72
|
] }),
|
|
73
|
-
/* @__PURE__ */ l(
|
|
74
|
-
/* @__PURE__ */ l(
|
|
75
|
-
/* @__PURE__ */ l(
|
|
73
|
+
/* @__PURE__ */ l(W, { title: "Can edit", names: n.edit }),
|
|
74
|
+
/* @__PURE__ */ l(W, { title: "Read only", names: n.read }),
|
|
75
|
+
/* @__PURE__ */ l(W, { title: "Never see it", names: n.hidden }),
|
|
76
76
|
/* @__PURE__ */ l("p", { className: "mt-2 text-[11.5px] leading-snug text-slate-500 dark:text-muted-foreground", children: "From each role’s permissions and this form’s section and lock rules. Administrators see every field." })
|
|
77
77
|
] })
|
|
78
78
|
] });
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
return /* @__PURE__ */
|
|
80
|
+
function w({ children: n, onClear: h }) {
|
|
81
|
+
return /* @__PURE__ */ r("div", { className: "flex min-w-0 items-start gap-2", children: [
|
|
82
82
|
/* @__PURE__ */ l("div", { className: "min-w-0 flex-1 text-[12.5px] leading-snug text-slate-700 dark:text-slate-200", children: n }),
|
|
83
83
|
/* @__PURE__ */ l(
|
|
84
84
|
"button",
|
|
@@ -88,175 +88,206 @@ function $({ children: n, onClear: h }) {
|
|
|
88
88
|
"data-tip": "Turn off",
|
|
89
89
|
onClick: h,
|
|
90
90
|
className: "inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-slate-500 hover:bg-muted hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground",
|
|
91
|
-
children: /* @__PURE__ */ l(
|
|
91
|
+
children: /* @__PURE__ */ l(Z, { className: "h-3.5 w-3.5" })
|
|
92
92
|
}
|
|
93
93
|
)
|
|
94
94
|
] });
|
|
95
95
|
}
|
|
96
|
-
const
|
|
97
|
-
function
|
|
96
|
+
const I = (n) => n.join(", ");
|
|
97
|
+
function Ie({
|
|
98
98
|
collection: n,
|
|
99
99
|
bundle: h,
|
|
100
|
-
parent:
|
|
101
|
-
preview:
|
|
102
|
-
onPreview:
|
|
103
|
-
record:
|
|
104
|
-
fields:
|
|
105
|
-
renderPane:
|
|
100
|
+
parent: N,
|
|
101
|
+
preview: s,
|
|
102
|
+
onPreview: k,
|
|
103
|
+
record: v,
|
|
104
|
+
fields: j,
|
|
105
|
+
renderPane: q
|
|
106
106
|
}) {
|
|
107
|
-
const f =
|
|
108
|
-
const t = f.groups.find((
|
|
107
|
+
const f = x(() => ae(h, N).active, [h, N]), _ = (e) => K(j, e), F = (e) => {
|
|
108
|
+
const t = f.groups.find((a) => a.key === e);
|
|
109
109
|
return (t == null ? void 0 : t.label) || e;
|
|
110
|
-
},
|
|
111
|
-
() =>
|
|
112
|
-
[
|
|
113
|
-
), i =
|
|
114
|
-
() =>
|
|
115
|
-
[
|
|
116
|
-
),
|
|
117
|
-
if (!
|
|
118
|
-
const e = U(
|
|
119
|
-
let
|
|
120
|
-
for (const [c,
|
|
121
|
-
return { marks:
|
|
122
|
-
}, [
|
|
110
|
+
}, b = s.values && Object.keys(s.values).length > 0 ? s.values : null, D = x(
|
|
111
|
+
() => b ? { ...v ?? {}, ...b } : v,
|
|
112
|
+
[v, b]
|
|
113
|
+
), i = x(
|
|
114
|
+
() => b ? de(f, v ?? {}, D ?? {}) : null,
|
|
115
|
+
[b, f, v, D]
|
|
116
|
+
), y = s.roleId, u = y ? s.compareRoleId ?? null : null, { data: C = null } = H(n, u ? y : null), { data: $ = null } = H(n, u), o = x(() => {
|
|
117
|
+
if (!u || !C || !$) return null;
|
|
118
|
+
const e = U(C, f), t = U($, f);
|
|
119
|
+
let a = 0;
|
|
120
|
+
for (const [c, p] of e) t.get(c) && t.get(c) !== p && a++;
|
|
121
|
+
return { marks: ie(f, C, $), differ: a, a: C, b: $ };
|
|
122
|
+
}, [u, C, $, f]), d = s.state ?? null, { data: O = [] } = re(n, !!d), m = x(() => {
|
|
123
123
|
if (!d) return null;
|
|
124
|
-
const e =
|
|
125
|
-
for (const
|
|
126
|
-
if (!
|
|
127
|
-
for (const
|
|
128
|
-
return { locked: new Set(e), needs:
|
|
129
|
-
}, [d, f,
|
|
130
|
-
if (!
|
|
131
|
-
const e = new Set(
|
|
132
|
-
(
|
|
124
|
+
const e = ce(f, d.key), t = O.find((p) => p.id === d.pipelineId), a = he((t == null ? void 0 : t.transitions) ?? [], d.id), c = /* @__PURE__ */ new Map();
|
|
125
|
+
for (const p of a)
|
|
126
|
+
if (!p.collection || p.collection === n)
|
|
127
|
+
for (const B of p.fields) c.set(B, [...c.get(B) ?? [], p.label]);
|
|
128
|
+
return { locked: new Set(e), needs: a, needOwn: c };
|
|
129
|
+
}, [d, f, O, n]), { data: L = [] } = oe(n, !!s.who), { data: z = [] } = ne(!!s.who), A = x(() => {
|
|
130
|
+
if (!s.who || L.length === 0) return null;
|
|
131
|
+
const e = new Set(z.map((a) => a.id.toUpperCase())), t = L.filter(
|
|
132
|
+
(a) => !a.role.admin_access && (e.size === 0 || e.has(String(a.role.id).toUpperCase()))
|
|
133
133
|
);
|
|
134
|
-
return
|
|
135
|
-
}, [
|
|
134
|
+
return fe(t, f);
|
|
135
|
+
}, [s.who, L, z, f]), Q = x(() => {
|
|
136
136
|
const e = [];
|
|
137
|
-
if (
|
|
137
|
+
if (o && e.push(o.marks), m && d && e.push((t) => {
|
|
138
138
|
if (t.kind !== "field" && t.kind !== "header") return [];
|
|
139
|
-
const
|
|
140
|
-
m.locked.has(t.field) &&
|
|
139
|
+
const a = [];
|
|
140
|
+
m.locked.has(t.field) && a.push({ text: `Locked in ${d.label}`, tone: "slate" });
|
|
141
141
|
const c = m.needOwn.get(t.field);
|
|
142
|
-
return c &&
|
|
142
|
+
return c && a.push({ text: "Needed to move on", tone: "amber", tip: `${I(c)} needs it` }), a;
|
|
143
143
|
}), i && (i.shown.length || i.hidden.length)) {
|
|
144
|
-
const t = new Set(i.shown),
|
|
144
|
+
const t = new Set(i.shown), a = new Set(i.hidden);
|
|
145
145
|
e.push(
|
|
146
|
-
(c) => c.kind !== "group" ? [] : t.has(c.key) ? [{ text: "Appears", tone: "emerald", highlight: !0 }] :
|
|
146
|
+
(c) => c.kind !== "group" ? [] : t.has(c.key) ? [{ text: "Appears", tone: "emerald", highlight: !0 }] : a.has(c.key) ? [{ text: "Hides", tone: "slate" }] : []
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
149
|
if (e.length !== 0)
|
|
150
|
-
return (t) => e.flatMap((
|
|
151
|
-
}, [
|
|
152
|
-
if (
|
|
150
|
+
return (t) => e.flatMap((a) => a(t)).map((a) => ({ ...a, kind: a.kind ?? "preview" }));
|
|
151
|
+
}, [o, m, d, i]), Y = x(() => {
|
|
152
|
+
if (A)
|
|
153
153
|
return (e) => {
|
|
154
154
|
if (e.kind !== "field" && e.kind !== "header") return null;
|
|
155
|
-
const t =
|
|
155
|
+
const t = A.get(e.field);
|
|
156
156
|
return t ? {
|
|
157
|
-
className:
|
|
158
|
-
chip: /* @__PURE__ */ l(
|
|
157
|
+
className: T[me(t)].cls,
|
|
158
|
+
chip: /* @__PURE__ */ l(ge, { who: t, label: K(j, e.field) })
|
|
159
159
|
} : null;
|
|
160
160
|
};
|
|
161
|
-
}, [
|
|
161
|
+
}, [A, j]), M = s.device === "all", E = s.device === "all" ? null : be[s.device ?? "desktop"], R = JSON.stringify(b ?? {}), V = (e) => E ? /* @__PURE__ */ l(
|
|
162
162
|
"div",
|
|
163
163
|
{
|
|
164
|
-
"data-preview-device":
|
|
164
|
+
"data-preview-device": s.device,
|
|
165
165
|
className: "mx-auto flex min-h-0 w-full flex-1 flex-col border-x border-dashed border-slate-300 bg-white dark:border-slate-600 dark:bg-background",
|
|
166
|
-
style: { maxWidth:
|
|
166
|
+
style: { maxWidth: E },
|
|
167
167
|
children: e
|
|
168
168
|
}
|
|
169
|
-
) : e,
|
|
170
|
-
|
|
171
|
-
/* @__PURE__ */
|
|
172
|
-
/* @__PURE__ */ l("b", { className: "font-semibold", children: (
|
|
169
|
+
) : e, g = [];
|
|
170
|
+
u && g.push(
|
|
171
|
+
/* @__PURE__ */ r(w, { onClear: () => k({ ...s, compareRoleId: null }), children: [
|
|
172
|
+
/* @__PURE__ */ l("b", { className: "font-semibold", children: (o == null ? void 0 : o.a.role.name) ?? "…" }),
|
|
173
173
|
" beside",
|
|
174
174
|
" ",
|
|
175
|
-
/* @__PURE__ */ l("b", { className: "font-semibold", children: (
|
|
176
|
-
|
|
175
|
+
/* @__PURE__ */ l("b", { className: "font-semibold", children: (o == null ? void 0 : o.b.role.name) ?? "…" }),
|
|
176
|
+
o && (o.differ === 0 ? " — every field is the same for both." : ` — ${o.differ} ${o.differ === 1 ? "field differs" : "fields differ"}, marked Differs.`)
|
|
177
177
|
] }, "compare")
|
|
178
|
-
), d && m &&
|
|
179
|
-
/* @__PURE__ */
|
|
178
|
+
), d && m && g.push(
|
|
179
|
+
/* @__PURE__ */ r(w, { onClear: () => k({ ...s, state: null }), children: [
|
|
180
180
|
"As if in ",
|
|
181
181
|
/* @__PURE__ */ l("b", { className: "font-semibold", children: d.label }),
|
|
182
182
|
":",
|
|
183
183
|
" ",
|
|
184
184
|
m.locked.size === 0 ? "no field locks" : `${m.locked.size} ${m.locked.size === 1 ? "field locks" : "fields lock"}`,
|
|
185
|
-
m.needs.length > 0 && /* @__PURE__ */
|
|
185
|
+
m.needs.length > 0 && /* @__PURE__ */ r(P, { children: [
|
|
186
186
|
" · ",
|
|
187
187
|
m.needs.map(
|
|
188
|
-
(e) => `${e.label} needs ${
|
|
188
|
+
(e) => `${e.label} needs ${I(e.fields.map((t) => e.collection && e.collection !== n ? t : _(t)))}${e.collection && e.collection !== n ? ` on ${e.collection}` : ""}`
|
|
189
189
|
).join(" · ")
|
|
190
190
|
] }),
|
|
191
191
|
"."
|
|
192
192
|
] }, "state")
|
|
193
|
-
),
|
|
194
|
-
/* @__PURE__ */
|
|
193
|
+
), b && i && g.push(
|
|
194
|
+
/* @__PURE__ */ r(w, { onClear: () => k({ ...s, values: null }), children: [
|
|
195
195
|
"What if",
|
|
196
196
|
" ",
|
|
197
|
-
/* @__PURE__ */ l("b", { className: "font-semibold", children: Object.entries(
|
|
197
|
+
/* @__PURE__ */ l("b", { className: "font-semibold", children: Object.entries(b).map(([e, t]) => `${_(e)} = ${t == null || t === "" ? "empty" : String(t)}`).join(", ") }),
|
|
198
198
|
":",
|
|
199
199
|
" ",
|
|
200
200
|
i.shown.length === 0 && i.hidden.length === 0 ? "nothing appears or disappears." : [
|
|
201
|
-
i.shown.length ? `shows ${
|
|
202
|
-
i.hidden.length ? `hides ${
|
|
201
|
+
i.shown.length ? `shows ${I(i.shown.map(F))}` : "",
|
|
202
|
+
i.hidden.length ? `hides ${I(i.hidden.map(F))}` : ""
|
|
203
203
|
].filter(Boolean).join("; ") + "."
|
|
204
204
|
] }, "values")
|
|
205
|
-
),
|
|
206
|
-
/* @__PURE__ */
|
|
205
|
+
), s.who && g.push(
|
|
206
|
+
/* @__PURE__ */ r(w, { onClear: () => k({ ...s, who: !1 }), children: [
|
|
207
207
|
/* @__PURE__ */ l("span", { className: "mr-2", children: "Who sees each field:" }),
|
|
208
|
-
/* @__PURE__ */ l("span", { className: "inline-flex flex-wrap items-center gap-x-3 gap-y-1 align-middle", children: ["all", "most", "some", "few", "none"].map((e) => /* @__PURE__ */
|
|
209
|
-
/* @__PURE__ */ l("span", { "aria-hidden": !0, className:
|
|
210
|
-
|
|
208
|
+
/* @__PURE__ */ l("span", { className: "inline-flex flex-wrap items-center gap-x-3 gap-y-1 align-middle", children: ["all", "most", "some", "few", "none"].map((e) => /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1 text-[12px]", children: [
|
|
209
|
+
/* @__PURE__ */ l("span", { "aria-hidden": !0, className: ee("h-2.5 w-2.5 rounded-sm", T[e].swatch) }),
|
|
210
|
+
T[e].label
|
|
211
211
|
] }, e)) }),
|
|
212
|
-
!
|
|
212
|
+
!A && /* @__PURE__ */ l("span", { className: "ml-2 text-slate-500 dark:text-muted-foreground", children: "Loading…" })
|
|
213
213
|
] }, "who")
|
|
214
|
-
),
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
-
|
|
214
|
+
), E && g.push(
|
|
215
|
+
/* @__PURE__ */ r(w, { onClear: () => k({ ...s, device: "desktop" }), children: [
|
|
216
|
+
s.device === "phone" ? "Phone" : "Tablet",
|
|
217
217
|
" width (",
|
|
218
|
-
|
|
218
|
+
E,
|
|
219
219
|
" px): columns wrap as they do on that screen."
|
|
220
220
|
] }, "device")
|
|
221
|
+
), M && g.push(
|
|
222
|
+
/* @__PURE__ */ l(w, { onClear: () => k({ ...s, device: "desktop" }), children: u ? "Every device at once waits while two roles are side by side: each role shows at full width." : /* @__PURE__ */ l(P, { children: "Desktop, tablet and phone side by side. Drag fields on the desktop pane; the others follow. Tools → Fit to screen shows all three." }) }, "devices")
|
|
221
223
|
);
|
|
222
|
-
const
|
|
224
|
+
const S = (e, t) => q({
|
|
223
225
|
roleId: e,
|
|
224
|
-
record:
|
|
226
|
+
record: D,
|
|
225
227
|
stateKey: (d == null ? void 0 : d.key) ?? null,
|
|
226
|
-
marks:
|
|
227
|
-
overlay:
|
|
228
|
+
marks: Q,
|
|
229
|
+
overlay: Y,
|
|
228
230
|
noDnd: t
|
|
229
231
|
});
|
|
230
|
-
return /* @__PURE__ */
|
|
231
|
-
|
|
232
|
+
return /* @__PURE__ */ r("div", { className: "flex min-h-0 flex-1 flex-col", children: [
|
|
233
|
+
g.length > 0 && /* @__PURE__ */ l(
|
|
232
234
|
"div",
|
|
233
235
|
{
|
|
234
236
|
"data-preview-strip": "",
|
|
235
237
|
className: "sticky top-0 z-20 flex shrink-0 flex-col gap-1 border-b border-slate-200 bg-white px-4 py-2 dark:border-border dark:bg-card",
|
|
236
|
-
children:
|
|
238
|
+
children: g
|
|
237
239
|
}
|
|
238
240
|
),
|
|
239
|
-
|
|
240
|
-
{ id:
|
|
241
|
-
{ id:
|
|
242
|
-
].map((e, t) => /* @__PURE__ */
|
|
241
|
+
u ? /* @__PURE__ */ l("div", { className: "flex min-h-0 flex-1 gap-px bg-slate-200 dark:bg-border", children: [
|
|
242
|
+
{ id: y, name: o == null ? void 0 : o.a.role.name },
|
|
243
|
+
{ id: u, name: o == null ? void 0 : o.b.role.name }
|
|
244
|
+
].map((e, t) => /* @__PURE__ */ r(
|
|
243
245
|
"section",
|
|
244
246
|
{
|
|
245
247
|
"data-preview-pane": t === 0 ? "a" : "b",
|
|
246
248
|
"aria-label": `As ${e.name ?? "role"}`,
|
|
247
249
|
className: "flex min-w-0 flex-1 flex-col bg-slate-50 dark:bg-background",
|
|
248
250
|
children: [
|
|
249
|
-
/* @__PURE__ */
|
|
251
|
+
/* @__PURE__ */ r("p", { className: "shrink-0 border-b border-slate-200 bg-white px-4 py-1.5 text-[12px] font-semibold text-slate-700 dark:border-border dark:bg-card dark:text-foreground", children: [
|
|
250
252
|
"As ",
|
|
251
253
|
e.name ?? "…"
|
|
252
254
|
] }),
|
|
253
|
-
|
|
255
|
+
V(S(e.id, !0))
|
|
254
256
|
]
|
|
255
257
|
},
|
|
256
|
-
`${e.id}:${
|
|
257
|
-
)) }) : /* @__PURE__ */ l(
|
|
258
|
+
`${e.id}:${R}`
|
|
259
|
+
)) }) : M ? /* @__PURE__ */ l(
|
|
260
|
+
"div",
|
|
261
|
+
{
|
|
262
|
+
"data-preview-devices": "",
|
|
263
|
+
className: "flex min-h-0 flex-1 overflow-x-auto bg-slate-100 dark:bg-background",
|
|
264
|
+
style: { gap: G, padding: G },
|
|
265
|
+
children: ue.map((e, t) => /* @__PURE__ */ r(
|
|
266
|
+
"section",
|
|
267
|
+
{
|
|
268
|
+
"data-preview-pane": e,
|
|
269
|
+
"data-preview-device": e,
|
|
270
|
+
"aria-label": `${J[e]} width`,
|
|
271
|
+
className: "flex min-h-0 shrink-0 flex-col overflow-hidden rounded-md border border-slate-200 bg-white dark:border-border dark:bg-card",
|
|
272
|
+
style: { width: X[e] + 2 },
|
|
273
|
+
children: [
|
|
274
|
+
/* @__PURE__ */ r("p", { className: "flex shrink-0 items-baseline justify-between gap-2 border-b border-slate-200 px-3 py-1.5 text-[12px] dark:border-border", children: [
|
|
275
|
+
/* @__PURE__ */ l("span", { className: "font-semibold text-slate-700 dark:text-foreground", children: J[e] }),
|
|
276
|
+
/* @__PURE__ */ r("span", { className: "tabular-nums text-slate-500 dark:text-muted-foreground", children: [
|
|
277
|
+
X[e],
|
|
278
|
+
" px"
|
|
279
|
+
] })
|
|
280
|
+
] }),
|
|
281
|
+
/* @__PURE__ */ l("div", { className: "flex min-h-0 flex-1 flex-col bg-white dark:bg-background", children: S(y, t > 0) })
|
|
282
|
+
]
|
|
283
|
+
},
|
|
284
|
+
e
|
|
285
|
+
))
|
|
286
|
+
},
|
|
287
|
+
R
|
|
288
|
+
) : /* @__PURE__ */ l("div", { className: "flex min-h-0 flex-1 flex-col", children: V(S(y, !1)) }, R)
|
|
258
289
|
] });
|
|
259
290
|
}
|
|
260
291
|
export {
|
|
261
|
-
|
|
292
|
+
Ie as PreviewPanes
|
|
262
293
|
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsxs as c, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { Dices as p, X as x } from "lucide-react";
|
|
3
|
+
import { useState as k } from "react";
|
|
4
|
+
import { useNivaroClient as y } from "../../../context.js";
|
|
5
|
+
import { get as b } from "../../../lib/commands.js";
|
|
6
|
+
import { cn as g } from "../../../lib/utils.js";
|
|
7
|
+
import { useCollectionMeta as N } from "../inspector/field-context.js";
|
|
8
|
+
import { samplePickers as v, buildSampleRecord as w } from "./sample-record.js";
|
|
9
|
+
const S = 8, C = () => Math.floor(Math.random() * 2 ** 31);
|
|
10
|
+
function u(l) {
|
|
11
|
+
const t = y(), { data: e } = N(l), [o, a] = k(!1);
|
|
12
|
+
return { make: async () => {
|
|
13
|
+
if (!e) return null;
|
|
14
|
+
a(!0);
|
|
15
|
+
try {
|
|
16
|
+
const d = v(e.fields, e.relations).slice(0, S), i = {};
|
|
17
|
+
return await Promise.all(
|
|
18
|
+
d.map(async (m) => {
|
|
19
|
+
try {
|
|
20
|
+
const h = await t.request(
|
|
21
|
+
b(`/items/${encodeURIComponent(m.collection)}`, { fields: "id", limit: 5 })
|
|
22
|
+
);
|
|
23
|
+
i[m.field] = (h.data ?? []).map((r) => r == null ? void 0 : r.id).filter((r) => r != null && r !== "");
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
), w({
|
|
28
|
+
fields: e.fields,
|
|
29
|
+
relations: e.relations,
|
|
30
|
+
relatedIds: i,
|
|
31
|
+
seed: C()
|
|
32
|
+
});
|
|
33
|
+
} finally {
|
|
34
|
+
a(!1);
|
|
35
|
+
}
|
|
36
|
+
}, ready: !!e, busy: o };
|
|
37
|
+
}
|
|
38
|
+
const f = "inline-flex items-center gap-1.5 text-[12px] font-medium text-sky-700 hover:underline disabled:pointer-events-none disabled:opacity-50 dark:text-nvr-cyan";
|
|
39
|
+
function E({
|
|
40
|
+
collection: l,
|
|
41
|
+
empty: t,
|
|
42
|
+
onSample: e
|
|
43
|
+
}) {
|
|
44
|
+
const { make: o, ready: a, busy: n } = u(l), d = async () => {
|
|
45
|
+
const i = await o();
|
|
46
|
+
i && e(i);
|
|
47
|
+
};
|
|
48
|
+
return /* @__PURE__ */ c("div", { "data-sample-offer": t ? "empty" : "", className: g(t ? "mt-1 px-2" : "mt-1.5"), children: [
|
|
49
|
+
t && /* @__PURE__ */ s("p", { className: "pb-1 text-[12px] leading-snug text-slate-500 dark:text-muted-foreground", children: "No records yet. A sample fills the form with made-up values; nothing is saved." }),
|
|
50
|
+
/* @__PURE__ */ c(
|
|
51
|
+
"button",
|
|
52
|
+
{
|
|
53
|
+
type: "button",
|
|
54
|
+
"data-sample-record": "",
|
|
55
|
+
disabled: !a || n,
|
|
56
|
+
onClick: () => void d(),
|
|
57
|
+
className: f,
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ s(p, { className: "h-3.5 w-3.5" }),
|
|
60
|
+
n ? "Making a sample…" : "Use a sample record"
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] });
|
|
65
|
+
}
|
|
66
|
+
function U({
|
|
67
|
+
collection: l,
|
|
68
|
+
onSample: t,
|
|
69
|
+
onClear: e
|
|
70
|
+
}) {
|
|
71
|
+
const { make: o, busy: a } = u(l);
|
|
72
|
+
return /* @__PURE__ */ c("span", { className: "inline-flex max-w-full flex-wrap items-center gap-2", children: [
|
|
73
|
+
/* @__PURE__ */ c(
|
|
74
|
+
"span",
|
|
75
|
+
{
|
|
76
|
+
"data-sample-chip": "",
|
|
77
|
+
className: "inline-flex max-w-full items-center gap-1.5 rounded-full bg-nvr-cyan/10 px-2.5 py-1 text-[12px] font-medium text-slate-800 dark:text-foreground",
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ s(p, { className: "h-3.5 w-3.5 shrink-0 text-slate-500 dark:text-muted-foreground" }),
|
|
80
|
+
/* @__PURE__ */ s("span", { className: "truncate", children: "Sample record" }),
|
|
81
|
+
/* @__PURE__ */ s(
|
|
82
|
+
"button",
|
|
83
|
+
{
|
|
84
|
+
type: "button",
|
|
85
|
+
"aria-label": "Stop using the sample record",
|
|
86
|
+
onClick: e,
|
|
87
|
+
className: "text-slate-500 hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground",
|
|
88
|
+
children: /* @__PURE__ */ s(x, { className: "h-3 w-3" })
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ s(
|
|
95
|
+
"button",
|
|
96
|
+
{
|
|
97
|
+
type: "button",
|
|
98
|
+
"data-sample-reroll": "",
|
|
99
|
+
disabled: a,
|
|
100
|
+
onClick: () => void o().then((n) => {
|
|
101
|
+
n && t(n);
|
|
102
|
+
}),
|
|
103
|
+
className: f,
|
|
104
|
+
children: a ? "Making…" : "New sample"
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
] });
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
U as SampleRecordChip,
|
|
111
|
+
E as SampleRecordOffer,
|
|
112
|
+
u as useMakeSample
|
|
113
|
+
};
|