@nivaro/react 0.2.54 → 0.2.55

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 (150) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +99 -98
  3. package/dist/index.d.ts +339 -2
  4. package/dist/index.js +644 -618
  5. package/dist/layout-editor.d.ts +4 -0
  6. package/dist/shared/components/BackgroundRunOffer.js +117 -0
  7. package/dist/shared/components/BroadcastView.js +214 -213
  8. package/dist/shared/components/CollectionBrowserView.js +2592 -2695
  9. package/dist/shared/components/ItemEditForm.js +4066 -3832
  10. package/dist/shared/components/JobsTray.js +100 -55
  11. package/dist/shared/components/MyWorkView.js +91 -89
  12. package/dist/shared/components/NotificationBell.js +80 -79
  13. package/dist/shared/components/ProfileView.js +568 -520
  14. package/dist/shared/components/RecordCompare.js +254 -0
  15. package/dist/shared/components/RecordReadView.js +599 -552
  16. package/dist/shared/components/ReportView.js +578 -543
  17. package/dist/shared/components/RowPresence.js +91 -0
  18. package/dist/shared/components/WidgetSlot.js +474 -458
  19. package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
  20. package/dist/shared/components/ai/AskPanel.js +139 -119
  21. package/dist/shared/components/ai/FirstWeekCard.js +126 -0
  22. package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
  23. package/dist/shared/components/bulk/bulk-field-options.js +45 -0
  24. package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
  25. package/dist/shared/components/chat/ChannelArchive.js +326 -0
  26. package/dist/shared/components/chat/ChannelExtras.js +141 -121
  27. package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
  28. package/dist/shared/components/chat/ChatPanel.js +1695 -1733
  29. package/dist/shared/components/chat/Composer.js +357 -303
  30. package/dist/shared/components/chat/MessageActions.js +92 -0
  31. package/dist/shared/components/chat/MessageFormat.js +290 -264
  32. package/dist/shared/components/chat/OutboxBubbles.js +146 -0
  33. package/dist/shared/components/chat/RequestIdCard.js +135 -0
  34. package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
  35. package/dist/shared/components/chat/RoomParts.js +213 -274
  36. package/dist/shared/components/chat/ScreenClip.js +184 -0
  37. package/dist/shared/components/chat/chat-core.js +402 -483
  38. package/dist/shared/components/chat/chat-drafts.js +59 -0
  39. package/dist/shared/components/chat/chat-emoji.js +348 -0
  40. package/dist/shared/components/chat/chat-local-time.js +41 -0
  41. package/dist/shared/components/chat/chat-outbox.js +303 -0
  42. package/dist/shared/components/chat/chat-window.js +163 -0
  43. package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
  44. package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
  45. package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
  46. package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
  47. package/dist/shared/components/help-videos/api.js +76 -73
  48. package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
  49. package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
  50. package/dist/shared/components/item-edit/FieldAffordances.js +2 -2
  51. package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
  52. package/dist/shared/components/item-edit/FieldRow.js +292 -279
  53. package/dist/shared/components/item-edit/GroupSection.js +698 -574
  54. package/dist/shared/components/item-edit/InlineTableField.js +3 -1
  55. package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
  56. package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
  57. package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
  58. package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
  59. package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
  60. package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
  61. package/dist/shared/components/item-edit/lazy-sections.js +36 -0
  62. package/dist/shared/components/item-edit/lock-why.js +39 -32
  63. package/dist/shared/components/item-edit/picker-miss.js +26 -0
  64. package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
  65. package/dist/shared/components/item-edit/useFormUsageBeacon.js +51 -45
  66. package/dist/shared/components/layout-editor/AddPanel.js +134 -117
  67. package/dist/shared/components/layout-editor/ChangeNote.js +25 -24
  68. package/dist/shared/components/layout-editor/CollabParts.js +80 -75
  69. package/dist/shared/components/layout-editor/DesignNode.js +126 -120
  70. package/dist/shared/components/layout-editor/EditorCanvas.js +30 -27
  71. package/dist/shared/components/layout-editor/EditorTopBar.js +203 -192
  72. package/dist/shared/components/layout-editor/HistoryPanel.js +120 -104
  73. package/dist/shared/components/layout-editor/LayoutEditor.js +768 -671
  74. package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
  75. package/dist/shared/components/layout-editor/StagedChip.js +22 -0
  76. package/dist/shared/components/layout-editor/StructureMenu.js +237 -186
  77. package/dist/shared/components/layout-editor/collab/FormFollowShare.js +149 -103
  78. package/dist/shared/components/layout-editor/collab/collab-api.js +29 -26
  79. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +81 -80
  80. package/dist/shared/components/layout-editor/dnd/node.js +69 -57
  81. package/dist/shared/components/layout-editor/draft-recovery.js +113 -43
  82. package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
  83. package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
  84. package/dist/shared/components/layout-editor/entry/presets.js +71 -0
  85. package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
  86. package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
  87. package/dist/shared/components/layout-editor/grid-guides.js +142 -0
  88. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
  89. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +61 -57
  90. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +247 -151
  91. package/dist/shared/components/layout-editor/inspector/Inspector.js +176 -155
  92. package/dist/shared/components/layout-editor/inspector/LookTab.js +167 -116
  93. package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
  94. package/dist/shared/components/layout-editor/inspector/PickerTab.js +84 -82
  95. package/dist/shared/components/layout-editor/inspector/RulesTab.js +66 -62
  96. package/dist/shared/components/layout-editor/inspector/kit.js +69 -68
  97. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
  98. package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
  99. package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
  100. package/dist/shared/components/layout-editor/overview/describe-conditions.js +6 -0
  101. package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
  102. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  103. package/dist/shared/components/layout-editor/restore-piece.js +192 -0
  104. package/dist/shared/components/layout-editor/section-structure.js +241 -0
  105. package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
  106. package/dist/shared/components/layout-editor/settings/FormSettings.js +41 -39
  107. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
  108. package/dist/shared/components/layout-editor/settings/ToolsSection.js +147 -111
  109. package/dist/shared/components/layout-editor/settings/WhoSection.js +29 -26
  110. package/dist/shared/components/layout-editor/settings/settings-registry.js +114 -17
  111. package/dist/shared/components/layout-editor/staged-api.js +64 -0
  112. package/dist/shared/components/layout-editor/structure-ops.js +81 -77
  113. package/dist/shared/components/layout-editor/testing/TestingPanels.js +65 -60
  114. package/dist/shared/components/layout-editor/testing/testing-model.js +198 -185
  115. package/dist/shared/components/layout-editor/toolbar-kit.js +11 -11
  116. package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
  117. package/dist/shared/components/layout-editor/usage/UsagePanel.js +144 -70
  118. package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
  119. package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
  120. package/dist/shared/components/layout-editor/useLayoutDraft.js +25 -24
  121. package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
  122. package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
  123. package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
  124. package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
  125. package/dist/shared/components/profile/AgentsPanel.js +479 -0
  126. package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
  127. package/dist/shared/components/support/SupportAnalytics.js +171 -0
  128. package/dist/shared/components/support/SupportView.js +75 -73
  129. package/dist/shared/lib/background-runs.js +150 -0
  130. package/dist/shared/lib/delivery-ack.js +9 -0
  131. package/dist/shared/lib/entry-badge-style.js +13 -0
  132. package/dist/shared/lib/entry-config.js +71 -0
  133. package/dist/shared/lib/form-sections.js +64 -0
  134. package/dist/shared/lib/form-structure.js +99 -0
  135. package/dist/shared/lib/form-usage-beacon.js +101 -52
  136. package/dist/shared/lib/jobs-tray.js +25 -23
  137. package/dist/shared/lib/keyset-pager.js +37 -0
  138. package/dist/shared/lib/layout-ops.js +84 -82
  139. package/dist/shared/lib/layout-resolve.js +113 -0
  140. package/dist/shared/lib/placement-behaviour.js +144 -0
  141. package/dist/shared/lib/prefetch.js +149 -0
  142. package/dist/shared/lib/presence-hooks.js +199 -0
  143. package/dist/shared/lib/record-outbox.js +82 -81
  144. package/dist/shared/lib/replay-socket.js +93 -0
  145. package/dist/shared/lib/request-gate.js +51 -50
  146. package/dist/shared/lib/room-gaps.js +96 -0
  147. package/dist/shared/lib/search-log.js +27 -0
  148. package/dist/shared/lib/socket-realtime.js +101 -80
  149. package/dist/shared/lib/worker-socket.js +200 -0
  150. package/package.json +1 -1
@@ -0,0 +1,255 @@
1
+ import { jsx as t, jsxs as r } from "react/jsx-runtime";
2
+ import { useQueryClient as W } from "@tanstack/react-query";
3
+ import { Lock as O, Smartphone as P } from "lucide-react";
4
+ import { useState as x, useEffect as A } from "react";
5
+ import { toast as q } from "sonner";
6
+ import { useItemEditAuth as D, useNivaroClient as M } from "../../../context.js";
7
+ import { post as R, patch as T } from "../../../lib/commands.js";
8
+ import { freezeOf as U, activeFreeze as _, localDay as S, dayWords as k, freezePatch as E, activeWindowOf as j, windowState as B, windowWords as Q, phoneOf as L, phoneOfPatch as V, activeWindowPatch as G, conditionsWithKey as H } from "../../../lib/layout-resolve.js";
9
+ import { cn as g } from "../../../lib/utils.js";
10
+ import { useLayoutEditorHost as J } from "../host.js";
11
+ import { useInvalidateLayouts as X, apiFailure as Y } from "../overview/overview-api.js";
12
+ import { amberStrip as Z } from "../panel-style.js";
13
+ import { Setting as $, smallBtn as b, quietText as w, inputCls as I, PickList as ee } from "./controls.js";
14
+ import { useCollectionLayoutList as te, settingsKeys as ne } from "./settings-api.js";
15
+ import { layoutKindOf as ae } from "./settings-registry.js";
16
+ const F = g(I, "h-8 w-[150px] font-mono dark:[color-scheme:dark]");
17
+ function ge(m) {
18
+ const { layout: c } = m, e = j(c.conditions), [a, l] = x((e == null ? void 0 : e.from) ?? ""), [s, u] = x((e == null ? void 0 : e.until) ?? "");
19
+ A(() => {
20
+ l((e == null ? void 0 : e.from) ?? ""), u((e == null ? void 0 : e.until) ?? "");
21
+ }, [e == null ? void 0 : e.from, e == null ? void 0 : e.until]);
22
+ const p = !!a && !!s && a > s, f = (o, i) => {
23
+ o && i && o > i || (o || null) === ((e == null ? void 0 : e.from) ?? null) && (i || null) === ((e == null ? void 0 : e.until) ?? null) || m.set(
24
+ G(c.conditions, { from: o || null, until: i || null }),
25
+ o || i ? "Set active dates" : "Clear active dates"
26
+ );
27
+ }, d = B(e, S());
28
+ return /* @__PURE__ */ t(
29
+ $,
30
+ {
31
+ k: "layout.conditions.active_window",
32
+ note: p ? /* @__PURE__ */ t("span", { className: "text-amber-700 dark:text-amber-300", children: "The end comes before the start." }) : e && d ? /* @__PURE__ */ t("span", { "data-active-window-state": d, children: d === "open" ? `In use now, ${Q(e)}.` : d === "before" ? `Not in use yet: starts ${k(e.from)}.` : `No longer in use: ended ${k(e.until)}.` }) : null,
33
+ children: /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-2", children: [
34
+ /* @__PURE__ */ r("label", { className: "flex flex-col gap-1", children: [
35
+ /* @__PURE__ */ t("span", { className: w, children: "From" }),
36
+ /* @__PURE__ */ t(
37
+ "input",
38
+ {
39
+ type: "date",
40
+ "aria-label": "Active from",
41
+ value: a,
42
+ max: s || void 0,
43
+ onChange: (o) => {
44
+ l(o.target.value), f(o.target.value, s);
45
+ },
46
+ className: F
47
+ }
48
+ )
49
+ ] }),
50
+ /* @__PURE__ */ r("label", { className: "flex flex-col gap-1", children: [
51
+ /* @__PURE__ */ t("span", { className: w, children: "Until" }),
52
+ /* @__PURE__ */ t(
53
+ "input",
54
+ {
55
+ type: "date",
56
+ "aria-label": "Active until",
57
+ value: s,
58
+ min: a || void 0,
59
+ onChange: (o) => {
60
+ u(o.target.value), f(a, o.target.value);
61
+ },
62
+ className: F
63
+ }
64
+ )
65
+ ] }),
66
+ (a || s) && /* @__PURE__ */ t(
67
+ "button",
68
+ {
69
+ type: "button",
70
+ className: g(b, "mb-0.5"),
71
+ onClick: () => {
72
+ l(""), u(""), f("", "");
73
+ },
74
+ children: "Clear"
75
+ }
76
+ )
77
+ ] })
78
+ }
79
+ );
80
+ }
81
+ function xe(m) {
82
+ const { layout: c, collection: e } = m, a = Number(c.id), l = J(), s = M(), u = W(), p = X(e), f = te(e), [d, o] = x(!1), i = f.filter((n) => ae(n) === "grouped"), h = L(c.conditions), N = i.find((n) => n.id !== a && L(n.conditions) === a) ?? null, v = h != null ? i.find((n) => n.id === h) ?? null : null, C = (n) => {
83
+ l.layoutLink && l.navigate(l.layoutLink(e, n));
84
+ }, K = async () => {
85
+ o(!0);
86
+ try {
87
+ const n = String(c.name || "Form"), z = await s.request(
88
+ R(`/collection-layouts/${a}/clone`, { name: `${n} (phone)`.slice(0, 255) })
89
+ ), y = z == null ? void 0 : z.data;
90
+ if (!(y != null && y.id)) throw new Error("No id came back");
91
+ await s.request(
92
+ T(`/collection-layouts/${y.id}`, {
93
+ conditions: H(y.conditions, "phone_of", a)
94
+ })
95
+ ), u.invalidateQueries({ queryKey: ne.layouts(e) }), p(), q.success("Phone version made: remove what a phone does not need"), C(Number(y.id));
96
+ } catch (n) {
97
+ q.error(Y(n, "Could not make the phone version").message);
98
+ } finally {
99
+ o(!1);
100
+ }
101
+ };
102
+ return /* @__PURE__ */ t(
103
+ $,
104
+ {
105
+ k: "layout.conditions.phone_of",
106
+ note: h != null ? /* @__PURE__ */ r("span", { "data-phone-of": h, children: [
107
+ "This form opens instead of",
108
+ " ",
109
+ /* @__PURE__ */ t("strong", { className: "font-medium text-slate-700 dark:text-foreground", children: (v == null ? void 0 : v.name) ?? `form ${h}` }),
110
+ " ",
111
+ "on small screens, for the records and roles that form gets."
112
+ ] }) : null,
113
+ children: N ? /* @__PURE__ */ r(
114
+ "div",
115
+ {
116
+ "data-phone-version": N.id,
117
+ className: "flex flex-wrap items-center gap-2 text-[12.5px] text-slate-700 dark:text-foreground",
118
+ children: [
119
+ /* @__PURE__ */ t(P, { className: "h-3.5 w-3.5 shrink-0 text-slate-500 dark:text-muted-foreground" }),
120
+ /* @__PURE__ */ t("span", { className: "min-w-0 truncate", children: N.name }),
121
+ l.layoutLink && /* @__PURE__ */ t("button", { type: "button", className: b, onClick: () => C(N.id), children: "Open" })
122
+ ]
123
+ }
124
+ ) : /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2", children: [
125
+ /* @__PURE__ */ t(
126
+ ee,
127
+ {
128
+ ariaLabel: "Phone version of",
129
+ value: h != null ? String(h) : null,
130
+ placeholder: "Not a phone version",
131
+ clearLabel: "Not a phone version",
132
+ options: i.filter((n) => n.id !== a && L(n.conditions) == null).map((n) => ({ value: String(n.id), label: n.name })),
133
+ onChange: (n) => m.set(
134
+ V(c.conditions, n ? Number(n) : null),
135
+ n ? "Make this a phone version" : "Stop being a phone version"
136
+ ),
137
+ className: "w-[220px]"
138
+ }
139
+ ),
140
+ h == null && /* @__PURE__ */ r(
141
+ "button",
142
+ {
143
+ type: "button",
144
+ className: b,
145
+ disabled: d,
146
+ "data-action": "make-phone-version",
147
+ onClick: () => void K(),
148
+ children: [
149
+ /* @__PURE__ */ t(P, { className: "h-3.5 w-3.5" }),
150
+ d ? "Making…" : "Make a phone version"
151
+ ]
152
+ }
153
+ ),
154
+ v && l.layoutLink && /* @__PURE__ */ r("button", { type: "button", className: b, onClick: () => C(v.id), children: [
155
+ "Open ",
156
+ v.name
157
+ ] })
158
+ ] })
159
+ }
160
+ );
161
+ }
162
+ function Ne(m) {
163
+ const { layout: c } = m, { userId: e } = D(), a = U(c.conditions), l = _(c.conditions), [s, u] = x(""), [p, f] = x(""), d = s > S() && p.trim().length >= 3, o = () => {
164
+ d && (m.set(
165
+ E(c.conditions, {
166
+ until: s,
167
+ reason: p.trim().slice(0, 300),
168
+ by: e || null,
169
+ at: (/* @__PURE__ */ new Date()).toISOString()
170
+ }),
171
+ `Freeze edits until ${k(s)}`
172
+ ), u(""), f(""));
173
+ };
174
+ return /* @__PURE__ */ t($, { k: "layout.conditions.freeze", children: a ? /* @__PURE__ */ r(
175
+ "div",
176
+ {
177
+ "data-layout-frozen": a.until,
178
+ className: g(
179
+ "flex flex-wrap items-center gap-2 rounded-md border px-2.5 py-2 text-[12.5px]",
180
+ l ? Z : "border-slate-200 text-slate-600 dark:border-border dark:text-muted-foreground"
181
+ ),
182
+ children: [
183
+ /* @__PURE__ */ t(O, { className: "h-3.5 w-3.5 shrink-0" }),
184
+ /* @__PURE__ */ r("span", { className: "min-w-0 flex-1", children: [
185
+ l ? "Frozen until " : "The freeze ended on ",
186
+ k(a.until),
187
+ a.reason ? `: ${a.reason}` : ""
188
+ ] }),
189
+ /* @__PURE__ */ t(
190
+ "button",
191
+ {
192
+ type: "button",
193
+ className: b,
194
+ "data-action": "lift-freeze",
195
+ onClick: () => m.set(
196
+ E(c.conditions, null),
197
+ l ? "Lift the edit freeze" : "Remove the ended freeze"
198
+ ),
199
+ children: l ? "Lift" : "Remove"
200
+ }
201
+ )
202
+ ]
203
+ }
204
+ ) : /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-2", children: [
205
+ /* @__PURE__ */ r("label", { className: "flex flex-col gap-1", children: [
206
+ /* @__PURE__ */ t("span", { className: w, children: "Until" }),
207
+ /* @__PURE__ */ t(
208
+ "input",
209
+ {
210
+ type: "date",
211
+ "aria-label": "Frozen until",
212
+ value: s,
213
+ min: S(),
214
+ onChange: (i) => u(i.target.value),
215
+ className: F
216
+ }
217
+ )
218
+ ] }),
219
+ /* @__PURE__ */ r("label", { className: "flex min-w-[180px] flex-1 flex-col gap-1", children: [
220
+ /* @__PURE__ */ t("span", { className: w, children: "Reason people see" }),
221
+ /* @__PURE__ */ t(
222
+ "input",
223
+ {
224
+ value: p,
225
+ maxLength: 300,
226
+ placeholder: "e.g. Go-live on Monday",
227
+ onChange: (i) => f(i.target.value),
228
+ onKeyDown: (i) => {
229
+ i.key === "Enter" && o();
230
+ },
231
+ className: g(I, "h-8")
232
+ }
233
+ )
234
+ ] }),
235
+ /* @__PURE__ */ r(
236
+ "button",
237
+ {
238
+ type: "button",
239
+ className: g(b, "mb-0.5"),
240
+ disabled: !d,
241
+ "data-action": "freeze",
242
+ onClick: o,
243
+ children: [
244
+ /* @__PURE__ */ t(O, { className: "h-3.5 w-3.5" }),
245
+ "Freeze"
246
+ ]
247
+ }
248
+ )
249
+ ] }) });
250
+ }
251
+ export {
252
+ ge as ActiveDatesSetting,
253
+ Ne as FreezeSetting,
254
+ xe as PhoneVersionSetting
255
+ };
@@ -1,87 +1,123 @@
1
1
  import { jsxs as h, Fragment as S, jsx as t } from "react/jsx-runtime";
2
- import { useQuery as C } from "@tanstack/react-query";
3
- import { ExternalLink as $ } from "lucide-react";
4
- import { useState as N, useRef as I, useEffect as x, useMemo as L } from "react";
2
+ import { useQuery as L } from "@tanstack/react-query";
3
+ import { ExternalLink as T } from "lucide-react";
4
+ import { useState as _, useRef as I, useEffect as b, useMemo as A } from "react";
5
5
  import { useNivaroClient as R } from "../../../context.js";
6
- import { get as T } from "../../../lib/commands.js";
7
- import { applyLayoutOps as E } from "../../../lib/layout-ops.js";
6
+ import { get as E } from "../../../lib/commands.js";
7
+ import { applyLayoutOps as O } from "../../../lib/layout-ops.js";
8
8
  import { cn as g } from "../../../lib/utils.js";
9
- import { AiTextTools as O } from "../ai-text/AiTextTools.js";
10
- import { HistoryPanel as P } from "../HistoryPanel.js";
11
- import { useLayoutEditorHost as _ } from "../host.js";
9
+ import { AiTextTools as P } from "../ai-text/AiTextTools.js";
10
+ import { HistoryPanel as F } from "../HistoryPanel.js";
11
+ import { useLayoutEditorHost as N } from "../host.js";
12
12
  import { LayoutOpsBlocks as q } from "../ops/LayoutOpsBlocks.js";
13
- import { useRoleNames as F } from "../overview/overview-api.js";
14
- import { tintCard as H, labelText as j } from "../panel-style.js";
15
- import { RelationPicker as B } from "../pickers/relation-picker.js";
16
- import { CostLimitSetting as D } from "../testing/CostLimitSetting.js";
13
+ import { useRoleNames as H } from "../overview/overview-api.js";
14
+ import { tintCard as j, labelText as B } from "../panel-style.js";
15
+ import { RelationPicker as D } from "../pickers/relation-picker.js";
16
+ import { CostLimitSetting as U } from "../testing/CostLimitSetting.js";
17
17
  import { humanizeOpError as z } from "../useLayoutDraft.js";
18
- import { Setting as y, smallBtn as A, quietText as m, PickList as G, useSettingVisible as v, Segmented as K } from "./controls.js";
19
- import { useRolePreview as M } from "./settings-api.js";
18
+ import { Setting as y, smallBtn as C, quietText as f, PickList as w, useSettingVisible as v, Segmented as M } from "./controls.js";
19
+ import { FreezeSetting as W } from "./ResolveSettings.js";
20
+ import { useRolePreview as G } from "./settings-api.js";
20
21
  import { settingDef as k } from "./settings-registry.js";
21
- function Ne(e) {
22
- const r = Number(e.layout.id);
22
+ function xe(e) {
23
+ const i = Number(e.layout.id);
23
24
  return /* @__PURE__ */ h(S, { children: [
24
- /* @__PURE__ */ t(V, { ...e }),
25
25
  /* @__PURE__ */ t(J, { ...e }),
26
- /* @__PURE__ */ t(b, { k: "tool.describe", layoutId: r }),
27
- /* @__PURE__ */ t(b, { k: "tool.ai_review", layoutId: r, bundle: e.bundle, apply: e.apply }),
28
- /* @__PURE__ */ t(X, { ...e }),
29
- /* @__PURE__ */ t(D, { ...e }),
30
- /* @__PURE__ */ t(Y, { layoutId: r }),
26
+ /* @__PURE__ */ t(Y, { ...e }),
27
+ /* @__PURE__ */ t(x, { k: "tool.describe", layoutId: i }),
28
+ /* @__PURE__ */ t(x, { k: "tool.ai_review", layoutId: i, bundle: e.bundle, apply: e.apply }),
29
+ /* @__PURE__ */ t(Z, { ...e }),
31
30
  /* @__PURE__ */ t(U, { ...e }),
32
- /* @__PURE__ */ t(Z, { layoutId: r }),
31
+ /* @__PURE__ */ t(ee, { layoutId: i }),
32
+ /* @__PURE__ */ t(Q, { ...e }),
33
+ /* @__PURE__ */ t(V, { ...e }),
34
+ /* @__PURE__ */ t(W, { ...e }),
35
+ /* @__PURE__ */ t(te, { layoutId: i }),
33
36
  /* @__PURE__ */ t(
34
37
  q,
35
38
  {
36
39
  collection: e.collection,
37
- layoutId: r,
40
+ layoutId: i,
38
41
  name: String(e.layout.name ?? "")
39
42
  }
40
43
  )
41
44
  ] });
42
45
  }
43
- const Q = {
46
+ const K = {
44
47
  off: "Turn off Ask why on every save",
45
48
  note: "Ask for a reason on every save",
46
49
  note_ticket: "Ask for a reason and a ticket on every save"
47
50
  };
48
- function U({ layout: e, set: r }) {
49
- const n = e.change_note, a = n === "note" || n === "note_ticket" ? n : "off";
51
+ function Q({ layout: e, set: i }) {
52
+ const a = e.change_note, r = a === "note" || a === "note_ticket" ? a : "off";
50
53
  return /* @__PURE__ */ t(
51
54
  y,
52
55
  {
53
56
  k: "layout.change_note",
54
57
  control: /* @__PURE__ */ t(
55
- K,
58
+ M,
56
59
  {
57
60
  ariaLabel: "Ask why on every save",
58
- value: a,
61
+ value: r,
59
62
  options: [
60
63
  { value: "off", label: "Off" },
61
64
  { value: "note", label: "Reason" },
62
65
  { value: "note_ticket", label: "Reason + ticket" }
63
66
  ],
64
- onChange: (o) => r({ change_note: o === "off" ? null : o }, Q[o])
67
+ onChange: (o) => i({ change_note: o === "off" ? null : o }, K[o])
65
68
  }
66
69
  ),
67
- note: a === "off" ? null : "Autosave stays off for this form: every save waits for its reason."
70
+ note: r === "off" ? null : "Autosave stays off for this form: every save waits for its reason."
71
+ }
72
+ );
73
+ }
74
+ function V({ bundle: e, layout: i, set: a }) {
75
+ var c;
76
+ const r = A(
77
+ () => e.groups.filter(
78
+ (n) => n.parent_key === null && !n.key.startsWith("__") && (n.type === "section" || n.type === "container")
79
+ ).sort((n, d) => n.sort - d.sort).map((n) => ({ value: n.key, label: n.label || n.key })),
80
+ [e.groups]
81
+ ), o = typeof i.email_summary_group == "string" ? i.email_summary_group : null, s = (c = r.find((n) => n.value === o)) == null ? void 0 : c.label;
82
+ return /* @__PURE__ */ t(
83
+ y,
84
+ {
85
+ k: "layout.email_summary_group",
86
+ control: /* @__PURE__ */ t(
87
+ w,
88
+ {
89
+ ariaLabel: "Section for notification emails",
90
+ value: o,
91
+ options: o && !s ? [...r, { value: o, label: `Missing section (${o})` }] : r,
92
+ clearLabel: "None (header strip)",
93
+ placeholder: "None (header strip)",
94
+ emptyText: "This form has no sections yet",
95
+ onChange: (n) => {
96
+ var d;
97
+ return a(
98
+ { email_summary_group: n },
99
+ n ? `Use ${((d = r.find((l) => l.value === n)) == null ? void 0 : d.label) ?? n} in emails` : "Use the header strip in emails"
100
+ );
101
+ }
102
+ }
103
+ )
68
104
  }
69
105
  );
70
106
  }
71
- function V({ collection: e, layout: r }) {
72
- const n = _(), [a, o] = N(null), l = r.slug ? String(r.slug) : null, c = a ? `${n.recordLink(e, a)}${l ? `?layout=${encodeURIComponent(l)}` : ""}` : null;
107
+ function J({ collection: e, layout: i }) {
108
+ const a = N(), [r, o] = _(null), s = i.slug ? String(i.slug) : null, c = r ? `${a.recordLink(e, r)}${s ? `?layout=${encodeURIComponent(s)}` : ""}` : null;
73
109
  return /* @__PURE__ */ t(
74
110
  y,
75
111
  {
76
112
  k: "tool.preview_record",
77
- note: l ? `The record opens pinned to this form (?layout=${l}).` : "Without a link name the record opens on whichever layout it resolves to.",
113
+ note: s ? `The record opens pinned to this form (?layout=${s}).` : "Without a link name the record opens on whichever layout it resolves to.",
78
114
  children: /* @__PURE__ */ h("div", { className: "flex flex-wrap items-center gap-1.5", children: [
79
115
  /* @__PURE__ */ t("div", { className: "min-w-[180px] flex-1", children: /* @__PURE__ */ t(
80
- B,
116
+ D,
81
117
  {
82
118
  relatedCollection: e,
83
- value: a,
84
- onChange: (s) => o(s == null || s === "" ? null : String(s)),
119
+ value: r,
120
+ onChange: (n) => o(n == null || n === "" ? null : String(n)),
85
121
  placeholder: "Pick a record…"
86
122
  }
87
123
  ) }),
@@ -93,9 +129,9 @@ function V({ collection: e, layout: r }) {
93
129
  rel: "noreferrer",
94
130
  "aria-disabled": !c,
95
131
  "data-layout-record-preview-open": !0,
96
- className: g(A, !c && "pointer-events-none opacity-40"),
132
+ className: g(C, !c && "pointer-events-none opacity-40"),
97
133
  children: [
98
- /* @__PURE__ */ t($, { className: "h-3.5 w-3.5" }),
134
+ /* @__PURE__ */ t(T, { className: "h-3.5 w-3.5" }),
99
135
  "Open in a new tab"
100
136
  ]
101
137
  }
@@ -104,121 +140,121 @@ function V({ collection: e, layout: r }) {
104
140
  }
105
141
  );
106
142
  }
107
- function W(e, r) {
108
- var l;
143
+ function X(e, i) {
144
+ var s;
109
145
  if (e.role.admin_access)
110
146
  return `As ${e.role.name}: admin — default layout, every field.`;
111
- if (!e.can_read) return `As ${e.role.name}: cannot read ${r} at all.`;
112
- const n = [`gets “${((l = e.layout) == null ? void 0 : l.name) ?? "no layout"}”`], a = e.hidden_fields.length, o = e.readonly_fields.length;
113
- return a && n.push(`${a} field${a === 1 ? "" : "s"} hidden`), o && n.push(`${o} read-only`), e.can_update || n.push("cannot edit"), `As ${e.role.name}: ${n.join(" · ")}`;
147
+ if (!e.can_read) return `As ${e.role.name}: cannot read ${i} at all.`;
148
+ const a = [`gets “${((s = e.layout) == null ? void 0 : s.name) ?? "no layout"}”`], r = e.hidden_fields.length, o = e.readonly_fields.length;
149
+ return r && a.push(`${r} field${r === 1 ? "" : "s"} hidden`), o && a.push(`${o} read-only`), e.can_update || a.push("cannot edit"), `As ${e.role.name}: ${a.join(" · ")}`;
114
150
  }
115
- function J({
151
+ function Y({
116
152
  collection: e,
117
- onPreviewRole: r,
118
- previewRoleId: n,
119
- onPreviewRoleChange: a
153
+ onPreviewRole: i,
154
+ previewRoleId: a,
155
+ onPreviewRoleChange: r
120
156
  }) {
121
- const { data: o = [] } = F(!0), [l, c] = N(null), s = a ? n ?? null : l, u = a ?? c, { data: i = null, isFetching: p } = M(e, s), f = I(r);
122
- return f.current = r, x(() => {
123
- var d;
124
- (d = f.current) == null || d.call(f, s ? i : null);
125
- }, [s, i]), x(() => () => {
126
- var d;
127
- return (d = f.current) == null ? void 0 : d.call(f, null);
157
+ const { data: o = [] } = H(!0), [s, c] = _(null), n = r ? a ?? null : s, d = r ?? c, { data: l = null, isFetching: p } = G(e, n), m = I(i);
158
+ return m.current = i, b(() => {
159
+ var u;
160
+ (u = m.current) == null || u.call(m, n ? l : null);
161
+ }, [n, l]), b(() => () => {
162
+ var u;
163
+ return (u = m.current) == null ? void 0 : u.call(m, null);
128
164
  }, []), /* @__PURE__ */ t(
129
165
  y,
130
166
  {
131
167
  k: "tool.preview_as_role",
132
168
  control: /* @__PURE__ */ t(
133
- G,
169
+ w,
134
170
  {
135
171
  ariaLabel: "Preview as role",
136
- value: s,
137
- options: [...o].sort((d, w) => d.name.localeCompare(w.name)).map((d) => ({ value: d.id, label: d.name })),
172
+ value: n,
173
+ options: [...o].sort((u, $) => u.name.localeCompare($.name)).map((u) => ({ value: u.id, label: u.name })),
138
174
  clearLabel: "Nobody (off)",
139
- onChange: u
175
+ onChange: d
140
176
  }
141
177
  ),
142
- children: s && /* @__PURE__ */ t("div", { "data-role-preview": !0, className: g(H, "p-3 text-[12px]"), children: p && !i ? /* @__PURE__ */ t("p", { className: m, children: "Checking…" }) : i ? /* @__PURE__ */ h(S, { children: [
178
+ children: n && /* @__PURE__ */ t("div", { "data-role-preview": !0, className: g(j, "p-3 text-[12px]"), children: p && !l ? /* @__PURE__ */ t("p", { className: f, children: "Checking…" }) : l ? /* @__PURE__ */ h(S, { children: [
143
179
  /* @__PURE__ */ t(
144
180
  "p",
145
181
  {
146
182
  className: g(
147
183
  "text-slate-700 dark:text-foreground",
148
- !i.can_read && "text-[#9c2f47] dark:text-[#f08aa1]"
184
+ !l.can_read && "text-[#9c2f47] dark:text-[#f08aa1]"
149
185
  ),
150
- children: W(i, e)
186
+ children: X(l, e)
151
187
  }
152
188
  ),
153
- i.note && /* @__PURE__ */ t("p", { className: g("mt-1", m), children: i.note })
154
- ] }) : /* @__PURE__ */ t("p", { className: m, children: "Could not preview this role." }) })
189
+ l.note && /* @__PURE__ */ t("p", { className: g("mt-1", f), children: l.note })
190
+ ] }) : /* @__PURE__ */ t("p", { className: f, children: "Could not preview this role." }) })
155
191
  }
156
192
  );
157
193
  }
158
- function b({
194
+ function x({
159
195
  k: e,
160
- layoutId: r,
161
- bundle: n,
162
- apply: a
196
+ layoutId: i,
197
+ bundle: a,
198
+ apply: r
163
199
  }) {
164
- var s, u;
165
- const o = _(), l = L(
166
- () => n && a ? {
167
- bundle: n,
168
- apply: a,
169
- check: (i) => {
200
+ var n, d;
201
+ const o = N(), s = A(
202
+ () => a && r ? {
203
+ bundle: a,
204
+ apply: r,
205
+ check: (l) => {
170
206
  try {
171
- return E(n, i), null;
207
+ return O(a, l), null;
172
208
  } catch (p) {
173
209
  return z(p instanceof Error ? p.message : String(p));
174
210
  }
175
211
  }
176
212
  } : void 0,
177
- [n, a]
178
- ), c = e === "tool.ai_review" ? (s = o.aiReviewSlot) == null ? void 0 : s.call(o, r, l) : (u = o.explainSlot) == null ? void 0 : u.call(o, {
213
+ [a, r]
214
+ ), c = e === "tool.ai_review" ? (n = o.aiReviewSlot) == null ? void 0 : n.call(o, i, s) : (d = o.explainSlot) == null ? void 0 : d.call(o, {
179
215
  kind: "config",
180
216
  type: "layout",
181
- id: r,
217
+ id: i,
182
218
  label: "Describe this form"
183
219
  });
184
- return /* @__PURE__ */ t(y, { k: e, children: c ?? /* @__PURE__ */ t("p", { className: m, children: "Not offered in this app." }) });
220
+ return /* @__PURE__ */ t(y, { k: e, children: c ?? /* @__PURE__ */ t("p", { className: f, children: "Not offered in this app." }) });
185
221
  }
186
- function X({ layout: e, bundle: r, collection: n, apply: a }) {
187
- const o = _();
188
- return /* @__PURE__ */ t(y, { k: "tool.ai_text", children: o.isAdmin && a ? /* @__PURE__ */ t(
189
- O,
222
+ function Z({ layout: e, bundle: i, collection: a, apply: r }) {
223
+ const o = N();
224
+ return /* @__PURE__ */ t(y, { k: "tool.ai_text", children: o.isAdmin && r ? /* @__PURE__ */ t(
225
+ P,
190
226
  {
191
227
  layoutId: Number(e.id),
192
- bundle: r,
193
- collection: n,
194
- apply: a
228
+ bundle: i,
229
+ collection: a,
230
+ apply: r
195
231
  }
196
- ) : /* @__PURE__ */ t("p", { className: m, children: "Not offered here: administrators only." }) });
232
+ ) : /* @__PURE__ */ t("p", { className: f, children: "Not offered here: administrators only." }) });
197
233
  }
198
- function Y({ layoutId: e }) {
199
- var l, c;
200
- const r = v("tool.version_history"), n = v("tool.version_diff"), a = v("tool.version_restore");
201
- if (!r && !n && !a) return null;
234
+ function ee({ layoutId: e }) {
235
+ var s, c;
236
+ const i = v("tool.version_history"), a = v("tool.version_diff"), r = v("tool.version_restore");
237
+ if (!i && !a && !r) return null;
202
238
  const o = k("tool.version_history");
203
239
  return /* @__PURE__ */ h("div", { "data-setting": "tool.version_history", className: "space-y-1.5", children: [
204
- /* @__PURE__ */ t("p", { className: j, children: o == null ? void 0 : o.label }),
205
- /* @__PURE__ */ t(P, { layoutId: e }),
206
- /* @__PURE__ */ h("p", { className: m, children: [
240
+ /* @__PURE__ */ t("p", { className: B, children: o == null ? void 0 : o.label }),
241
+ /* @__PURE__ */ t(F, { layoutId: e }),
242
+ /* @__PURE__ */ h("p", { className: f, children: [
207
243
  o == null ? void 0 : o.effect,
208
244
  " ",
209
- (l = k("tool.version_diff")) == null ? void 0 : l.effect,
245
+ (s = k("tool.version_diff")) == null ? void 0 : s.effect,
210
246
  " ",
211
247
  (c = k("tool.version_restore")) == null ? void 0 : c.effect
212
248
  ] })
213
249
  ] });
214
250
  }
215
- function Z({ layoutId: e }) {
216
- const r = R(), [n, a] = N(!1), { data: o, isFetching: l, isError: c, refetch: s } = C({
251
+ function te({ layoutId: e }) {
252
+ const i = R(), [a, r] = _(!1), { data: o, isFetching: s, isError: c, refetch: n } = L({
217
253
  queryKey: ["layout-editor", "drift"],
218
- queryFn: () => r.request(T("/collection-layouts/drift")).then((i) => Array.isArray(i == null ? void 0 : i.data) ? i.data : []),
219
- enabled: n,
254
+ queryFn: () => i.request(E("/collection-layouts/drift")).then((l) => Array.isArray(l == null ? void 0 : l.data) ? l.data : []),
255
+ enabled: a,
220
256
  staleTime: 0
221
- }), u = o == null ? void 0 : o.find((i) => Number(i.layout_id) === e);
257
+ }), d = o == null ? void 0 : o.find((l) => Number(l.layout_id) === e);
222
258
  return /* @__PURE__ */ h(
223
259
  y,
224
260
  {
@@ -227,27 +263,27 @@ function Z({ layoutId: e }) {
227
263
  "button",
228
264
  {
229
265
  type: "button",
230
- className: A,
231
- disabled: l,
232
- onClick: () => n ? void s() : a(!0),
233
- children: l ? "Checking…" : "Check now"
266
+ className: C,
267
+ disabled: s,
268
+ onClick: () => a ? void n() : r(!0),
269
+ children: s ? "Checking…" : "Check now"
234
270
  }
235
271
  ),
236
272
  children: [
237
- n && !l && c && /* @__PURE__ */ t("p", { className: "text-[12px] text-[#9c2f47] dark:text-[#f08aa1]", children: "The check failed." }),
238
- n && o && !l && /* @__PURE__ */ t("div", { "data-layout-drift": !0, className: "text-[12px]", children: u ? /* @__PURE__ */ t("ul", { className: "space-y-1", children: u.warnings.map((i) => /* @__PURE__ */ t(
273
+ a && !s && c && /* @__PURE__ */ t("p", { className: "text-[12px] text-[#9c2f47] dark:text-[#f08aa1]", children: "The check failed." }),
274
+ a && o && !s && /* @__PURE__ */ t("div", { "data-layout-drift": !0, className: "text-[12px]", children: d ? /* @__PURE__ */ t("ul", { className: "space-y-1", children: d.warnings.map((l) => /* @__PURE__ */ t(
239
275
  "li",
240
276
  {
241
277
  className: "rounded bg-[#fae6eb] px-1.5 py-1 text-[#9c2f47] dark:bg-[#3d1621] dark:text-[#f08aa1]",
242
- children: i
278
+ children: l
243
279
  },
244
- i
245
- )) }) : /* @__PURE__ */ t("p", { className: m, children: "No drift: the form matches its last saved version." }) })
280
+ l
281
+ )) }) : /* @__PURE__ */ t("p", { className: f, children: "No drift: the form matches its last saved version." }) })
246
282
  ]
247
283
  }
248
284
  );
249
285
  }
250
286
  export {
251
- Ne as ToolsSection,
252
- W as rolePreviewSummary
287
+ xe as ToolsSection,
288
+ X as rolePreviewSummary
253
289
  };