@nivaro/react 0.3.36 → 0.3.38

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.
Files changed (102) hide show
  1. package/dist/components/slots/CommentsSlot.js +44 -36
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +9 -1
  5. package/dist/shared/components/AgentBadge.js +26 -0
  6. package/dist/shared/components/AgentQuestionsCard.js +198 -0
  7. package/dist/shared/components/ItemEditForm.js +3329 -3263
  8. package/dist/shared/components/McpConnectionScope.js +480 -0
  9. package/dist/shared/components/MyWorkView.js +223 -208
  10. package/dist/shared/components/RecordReadView.js +620 -575
  11. package/dist/shared/components/chat/ChatPanel.js +683 -671
  12. package/dist/shared/components/imports/DownloadSampleButton.js +69 -0
  13. package/dist/shared/components/imports/ImportConsole.js +106 -104
  14. package/dist/shared/components/imports/RunDetailSheet.js +34 -32
  15. package/dist/shared/components/item-edit/FieldAffordances.js +32 -32
  16. package/dist/shared/components/item-edit/FormTour.js +279 -0
  17. package/dist/shared/components/item-edit/GroupSection.js +377 -360
  18. package/dist/shared/components/item-edit/PersonalDefaultControl.js +28 -28
  19. package/dist/shared/components/item-edit/entry/EntryStrip.js +30 -26
  20. package/dist/shared/components/item-edit/form-density.js +36 -0
  21. package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -46
  22. package/dist/shared/components/item-edit/usePersonalDefaults.js +312 -296
  23. package/dist/shared/components/layout-editor/AddPanel.js +349 -192
  24. package/dist/shared/components/layout-editor/DesignNode.js +126 -112
  25. package/dist/shared/components/layout-editor/EditorTopBar.js +123 -103
  26. package/dist/shared/components/layout-editor/LayoutEditor.js +829 -751
  27. package/dist/shared/components/layout-editor/PlaceTools.js +334 -0
  28. package/dist/shared/components/layout-editor/SlashInsert.js +252 -0
  29. package/dist/shared/components/layout-editor/StructureMenu.js +285 -242
  30. package/dist/shared/components/layout-editor/add-target.js +54 -43
  31. package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +238 -155
  32. package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +1 -1
  33. package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +15 -12
  34. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +347 -189
  35. package/dist/shared/components/layout-editor/dnd/TrashZone.js +60 -32
  36. package/dist/shared/components/layout-editor/dnd/UndoChip.js +76 -0
  37. package/dist/shared/components/layout-editor/dnd/merge-drop.js +33 -0
  38. package/dist/shared/components/layout-editor/dnd/multi-drop.js +87 -0
  39. package/dist/shared/components/layout-editor/dnd/node.js +115 -105
  40. package/dist/shared/components/layout-editor/dnd/sensors.js +23 -0
  41. package/dist/shared/components/layout-editor/dnd/trash-drop.js +34 -28
  42. package/dist/shared/components/layout-editor/dnd/trash-links.js +97 -0
  43. package/dist/shared/components/layout-editor/even-row.js +86 -0
  44. package/dist/shared/components/layout-editor/field-list.js +99 -0
  45. package/dist/shared/components/layout-editor/format-painter.js +102 -0
  46. package/dist/shared/components/layout-editor/grid-guides.js +15 -13
  47. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +150 -132
  48. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +57 -53
  49. package/dist/shared/components/layout-editor/inspector/EvenRowAction.js +31 -0
  50. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +154 -141
  51. package/dist/shared/components/layout-editor/inspector/Inspector.js +209 -178
  52. package/dist/shared/components/layout-editor/inspector/LookTab.js +106 -98
  53. package/dist/shared/components/layout-editor/inspector/RulesTab.js +38 -37
  54. package/dist/shared/components/layout-editor/inspector/kit.js +280 -223
  55. package/dist/shared/components/layout-editor/keyboard-move.js +15 -15
  56. package/dist/shared/components/layout-editor/lint/LabelStyle.js +201 -0
  57. package/dist/shared/components/layout-editor/lint/LintPanel.js +132 -84
  58. package/dist/shared/components/layout-editor/lint/lint-api.js +65 -28
  59. package/dist/shared/components/layout-editor/nav/NavTools.js +14 -12
  60. package/dist/shared/components/layout-editor/nav/ZoomControls.js +145 -0
  61. package/dist/shared/components/layout-editor/nav/useEditorNav.js +34 -32
  62. package/dist/shared/components/layout-editor/nav/view-prefs.js +100 -15
  63. package/dist/shared/components/layout-editor/outputs/LayoutFile.js +89 -0
  64. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +272 -195
  65. package/dist/shared/components/layout-editor/outputs/layout-file-plan.js +176 -0
  66. package/dist/shared/components/layout-editor/outputs/output-api.js +71 -37
  67. package/dist/shared/components/layout-editor/overview/describe-conditions.js +16 -11
  68. package/dist/shared/components/layout-editor/overview/purpose.js +5 -5
  69. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  70. package/dist/shared/components/layout-editor/pin.js +37 -19
  71. package/dist/shared/components/layout-editor/place-clip.js +257 -0
  72. package/dist/shared/components/layout-editor/preview/PreviewModes.js +27 -26
  73. package/dist/shared/components/layout-editor/preview/PreviewPanes.js +148 -117
  74. package/dist/shared/components/layout-editor/preview/SampleRecord.js +113 -0
  75. package/dist/shared/components/layout-editor/preview/preview-model.js +79 -60
  76. package/dist/shared/components/layout-editor/preview/sample-record.js +105 -0
  77. package/dist/shared/components/layout-editor/removed-log.js +151 -0
  78. package/dist/shared/components/layout-editor/reuse/LibraryRows.js +109 -78
  79. package/dist/shared/components/layout-editor/reuse/linked-sections.js +373 -0
  80. package/dist/shared/components/layout-editor/revert-element.js +140 -0
  81. package/dist/shared/components/layout-editor/section-structure.js +193 -170
  82. package/dist/shared/components/layout-editor/settings/EntrySection.js +63 -45
  83. package/dist/shared/components/layout-editor/settings/LayoutSection.js +63 -32
  84. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +179 -137
  85. package/dist/shared/components/layout-editor/settings/WhoSection.js +18 -17
  86. package/dist/shared/components/layout-editor/settings/settings-registry.js +24 -0
  87. package/dist/shared/components/layout-editor/shortcuts.js +21 -16
  88. package/dist/shared/components/layout-editor/structure-ops.js +221 -195
  89. package/dist/shared/components/layout-editor/usage/UsagePanel.js +133 -85
  90. package/dist/shared/components/layout-editor/usage/refusal-lens.js +130 -0
  91. package/dist/shared/components/layout-editor/usage/usage-api.js +12 -11
  92. package/dist/shared/components/panels/CommentPanel.js +47 -45
  93. package/dist/shared/components/panels/RevisionsPanel.js +66 -64
  94. package/dist/shared/components/panels/TaskPanel.js +395 -332
  95. package/dist/shared/components/profile/AgentsPanel.js +196 -147
  96. package/dist/shared/components/profile/ConnectionRollback.js +329 -0
  97. package/dist/shared/components/profile/MyDefaultsCard.js +526 -520
  98. package/dist/shared/lib/entry-config.js +22 -22
  99. package/dist/shared/lib/form-usage-beacon.js +91 -55
  100. package/dist/shared/lib/layout-lint.js +530 -284
  101. package/dist/shared/lib/layout-resolve.js +58 -44
  102. package/package.json +1 -1
@@ -1,15 +1,15 @@
1
- import { jsx as l, jsxs as o, Fragment as X } from "react/jsx-runtime";
2
- import { X as q } from "lucide-react";
3
- import { useMemo as b } from "react";
4
- import { cn as G } from "../../../lib/utils.js";
5
- import { Popover as Q, PopoverTrigger as Y, PopoverContent as Z } from "../../ui/popover.js";
6
- import { bundleToActiveLayout as ee } from "../bundle-to-active.js";
7
- import { useRoleNames as te } from "../overview/overview-api.js";
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 se, useFieldAccess as le } from "./preview-api.js";
11
- import { visibilityChanges as ne, fieldAccessForRole as U, compareMarks as ae, fieldsLockedInState as re, leavingNeeds as oe, whoSeesFields as de, whoTint as ie, DEVICE_WIDTH as ce } from "./preview-model.js";
12
- const W = {
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 F({ title: n, names: h }) {
40
- return h.length === 0 ? null : /* @__PURE__ */ o("div", { className: "mt-2 first:mt-0", children: [
41
- /* @__PURE__ */ o("p", { className: "text-[11.5px] font-semibold text-slate-600 dark:text-muted-foreground", children: [
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 he({ who: n, label: h }) {
51
- const k = n.edit.length + n.read.length, a = k + n.hidden.length;
52
- return /* @__PURE__ */ o(Q, { children: [
53
- /* @__PURE__ */ l(Y, { asChild: !0, children: /* @__PURE__ */ o(
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
- k,
61
+ N,
62
62
  "/",
63
- a,
63
+ s,
64
64
  " roles"
65
65
  ]
66
66
  }
67
67
  ) }),
68
- /* @__PURE__ */ o(Z, { align: "end", className: "w-[280px] p-3", "data-design-pass": "", children: [
69
- /* @__PURE__ */ o("p", { className: "mb-2 text-[12.5px] font-semibold text-slate-900 dark:text-foreground", children: [
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(F, { title: "Can edit", names: n.edit }),
74
- /* @__PURE__ */ l(F, { title: "Read only", names: n.read }),
75
- /* @__PURE__ */ l(F, { title: "Never see it", names: n.hidden }),
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 $({ children: n, onClear: h }) {
81
- return /* @__PURE__ */ o("div", { className: "flex min-w-0 items-start gap-2", children: [
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(q, { className: "h-3.5 w-3.5" })
91
+ children: /* @__PURE__ */ l(Z, { className: "h-3.5 w-3.5" })
92
92
  }
93
93
  )
94
94
  ] });
95
95
  }
96
- const S = (n) => n.join(", ");
97
- function ve({
96
+ const I = (n) => n.join(", ");
97
+ function Ie({
98
98
  collection: n,
99
99
  bundle: h,
100
- parent: k,
101
- preview: a,
102
- onPreview: N,
103
- record: w,
104
- fields: I,
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 = b(() => ee(h, k).active, [h, k]), L = (e) => K(I, e), z = (e) => {
108
- const t = f.groups.find((s) => s.key === e);
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
- }, u = a.values && Object.keys(a.values).length > 0 ? a.values : null, R = b(
111
- () => u ? { ...w ?? {}, ...u } : w,
112
- [w, u]
113
- ), i = b(
114
- () => u ? ne(f, w ?? {}, R ?? {}) : null,
115
- [u, f, w, R]
116
- ), C = a.roleId, p = C ? a.compareRoleId ?? null : null, { data: y = null } = H(n, p ? C : null), { data: v = null } = H(n, p), r = b(() => {
117
- if (!p || !y || !v) return null;
118
- const e = U(y, f), t = U(v, f);
119
- let s = 0;
120
- for (const [c, g] of e) t.get(c) && t.get(c) !== g && s++;
121
- return { marks: ae(f, y, v), differ: s, a: y, b: v };
122
- }, [p, y, v, f]), d = a.state ?? null, { data: M = [] } = se(n, !!d), m = b(() => {
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 = re(f, d.key), t = M.find((g) => g.id === d.pipelineId), s = oe((t == null ? void 0 : t.transitions) ?? [], d.id), c = /* @__PURE__ */ new Map();
125
- for (const g of s)
126
- if (!g.collection || g.collection === n)
127
- for (const E of g.fields) c.set(E, [...c.get(E) ?? [], g.label]);
128
- return { locked: new Set(e), needs: s, needOwn: c };
129
- }, [d, f, M, n]), { data: T = [] } = le(n, !!a.who), { data: O = [] } = te(!!a.who), j = b(() => {
130
- if (!a.who || T.length === 0) return null;
131
- const e = new Set(O.map((s) => s.id.toUpperCase())), t = T.filter(
132
- (s) => !s.role.admin_access && (e.size === 0 || e.has(String(s.role.id).toUpperCase()))
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 de(t, f);
135
- }, [a.who, T, O, f]), J = b(() => {
134
+ return fe(t, f);
135
+ }, [s.who, L, z, f]), Q = x(() => {
136
136
  const e = [];
137
- if (r && e.push(r.marks), m && d && e.push((t) => {
137
+ if (o && e.push(o.marks), m && d && e.push((t) => {
138
138
  if (t.kind !== "field" && t.kind !== "header") return [];
139
- const s = [];
140
- m.locked.has(t.field) && s.push({ text: `Locked in ${d.label}`, tone: "slate" });
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 && s.push({ text: "Needed to move on", tone: "amber", tip: `${S(c)} needs it` }), s;
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), s = new Set(i.hidden);
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 }] : s.has(c.key) ? [{ text: "Hides", tone: "slate" }] : []
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((s) => s(t)).map((s) => ({ ...s, kind: s.kind ?? "preview" }));
151
- }, [r, m, d, i]), V = b(() => {
152
- if (j)
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 = j.get(e.field);
155
+ const t = A.get(e.field);
156
156
  return t ? {
157
- className: W[ie(t)].cls,
158
- chip: /* @__PURE__ */ l(he, { who: t, label: K(I, e.field) })
157
+ className: T[me(t)].cls,
158
+ chip: /* @__PURE__ */ l(ge, { who: t, label: K(j, e.field) })
159
159
  } : null;
160
160
  };
161
- }, [j, I]), A = ce[a.device ?? "desktop"], P = JSON.stringify(u ?? {}), B = (e) => A ? /* @__PURE__ */ l(
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": a.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: A },
166
+ style: { maxWidth: E },
167
167
  children: e
168
168
  }
169
- ) : e, x = [];
170
- p && x.push(
171
- /* @__PURE__ */ o($, { onClear: () => N({ ...a, compareRoleId: null }), children: [
172
- /* @__PURE__ */ l("b", { className: "font-semibold", children: (r == null ? void 0 : r.a.role.name) ?? "…" }),
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: (r == null ? void 0 : r.b.role.name) ?? "…" }),
176
- r && (r.differ === 0 ? " — every field is the same for both." : ` — ${r.differ} ${r.differ === 1 ? "field differs" : "fields differ"}, marked Differs.`)
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 && x.push(
179
- /* @__PURE__ */ o($, { onClear: () => N({ ...a, state: null }), children: [
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__ */ o(X, { children: [
185
+ m.needs.length > 0 && /* @__PURE__ */ r(P, { children: [
186
186
  " · ",
187
187
  m.needs.map(
188
- (e) => `${e.label} needs ${S(e.fields.map((t) => e.collection && e.collection !== n ? t : L(t)))}${e.collection && e.collection !== n ? ` on ${e.collection}` : ""}`
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
- ), u && i && x.push(
194
- /* @__PURE__ */ o($, { onClear: () => N({ ...a, values: null }), children: [
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(u).map(([e, t]) => `${L(e)} = ${t == null || t === "" ? "empty" : String(t)}`).join(", ") }),
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 ${S(i.shown.map(z))}` : "",
202
- i.hidden.length ? `hides ${S(i.hidden.map(z))}` : ""
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
- ), a.who && x.push(
206
- /* @__PURE__ */ o($, { onClear: () => N({ ...a, who: !1 }), children: [
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__ */ o("span", { className: "inline-flex items-center gap-1 text-[12px]", children: [
209
- /* @__PURE__ */ l("span", { "aria-hidden": !0, className: G("h-2.5 w-2.5 rounded-sm", W[e].swatch) }),
210
- W[e].label
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
- !j && /* @__PURE__ */ l("span", { className: "ml-2 text-slate-500 dark:text-muted-foreground", children: "Loading…" })
212
+ !A && /* @__PURE__ */ l("span", { className: "ml-2 text-slate-500 dark:text-muted-foreground", children: "Loading…" })
213
213
  ] }, "who")
214
- ), A && x.push(
215
- /* @__PURE__ */ o($, { onClear: () => N({ ...a, device: "desktop" }), children: [
216
- a.device === "phone" ? "Phone" : "Tablet",
214
+ ), E && g.push(
215
+ /* @__PURE__ */ r(w, { onClear: () => k({ ...s, device: "desktop" }), children: [
216
+ s.device === "phone" ? "Phone" : "Tablet",
217
217
  " width (",
218
- A,
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 D = (e, t) => _({
224
+ const S = (e, t) => q({
223
225
  roleId: e,
224
- record: R,
226
+ record: D,
225
227
  stateKey: (d == null ? void 0 : d.key) ?? null,
226
- marks: J,
227
- overlay: V,
228
+ marks: Q,
229
+ overlay: Y,
228
230
  noDnd: t
229
231
  });
230
- return /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col", children: [
231
- x.length > 0 && /* @__PURE__ */ l(
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: x
238
+ children: g
237
239
  }
238
240
  ),
239
- p ? /* @__PURE__ */ l("div", { className: "flex min-h-0 flex-1 gap-px bg-slate-200 dark:bg-border", children: [
240
- { id: C, name: r == null ? void 0 : r.a.role.name },
241
- { id: p, name: r == null ? void 0 : r.b.role.name }
242
- ].map((e, t) => /* @__PURE__ */ o(
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__ */ o("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: [
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
- B(D(e.id, !0))
255
+ V(S(e.id, !0))
254
256
  ]
255
257
  },
256
- `${e.id}:${P}`
257
- )) }) : /* @__PURE__ */ l("div", { className: "flex min-h-0 flex-1 flex-col", children: B(D(C, !1)) }, P)
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
- ve as PreviewPanes
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
+ };