@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
@@ -1,22 +1,23 @@
1
- import { jsxs as d, jsx as o, Fragment as H } from "react/jsx-runtime";
1
+ import { jsxs as d, jsx as o, Fragment as K } from "react/jsx-runtime";
2
2
  import { useQuery as te } from "@tanstack/react-query";
3
- import { Search as re, LayoutPanelTop as oe, Plus as K, CopyPlus as ae, Check as ne } from "lucide-react";
4
- import { useState as W, useMemo as Q } from "react";
5
- import { useNivaroClient as ie } from "../../context.js";
6
- import { get as se } from "../../lib/commands.js";
7
- import { HEADER_GROUP_KEY as A, isCanvasSlot as le } from "../../lib/layout-ops.js";
8
- import { listLayoutSlots as de } from "../../lib/layout-slots.js";
9
- import { titleCase as $, cn as V } from "../../lib/utils.js";
10
- import { sectionOp as ce, fieldSpot as j, placeOp as Y, slotSpot as pe } from "./add-target.js";
11
- import { MeaningSuggestions as ue } from "./ai-forms/MeaningSuggestions.js";
12
- import { useAddDragSource as me } from "./dnd/node.js";
13
- import { useFormFields as _e } from "./inspect/inspect-api.js";
14
- import { textMatcher as ge } from "./nav/find.js";
15
- import { useOverviewFields as fe } from "./overview/overview-api.js";
16
- import { LibraryRows as he } from "./reuse/LibraryRows.js";
17
- import { slotName as R } from "./slot-names.js";
18
- import { useFieldFillRates as xe, fillText as ye } from "./usage/usage-api.js";
19
- const ke = [
3
+ import { Search as re, LayoutPanelTop as oe, Sigma as ae, Plus as Q, CopyPlus as ie, Check as ne } from "lucide-react";
4
+ import { useState as W, useMemo as Y } from "react";
5
+ import { useNivaroClient as se } from "../../context.js";
6
+ import { get as le } from "../../lib/commands.js";
7
+ import { HEADER_GROUP_KEY as R, isCanvasSlot as de } from "../../lib/layout-ops.js";
8
+ import { listLayoutSlots as ce } from "../../lib/layout-slots.js";
9
+ import { nextDisplayFormulaField as me } from "../../lib/placement-behaviour.js";
10
+ import { titleCase as $, cn as X } from "../../lib/utils.js";
11
+ import { sectionOp as ue, fieldSpot as j, slotSpot as pe, placeOp as z } from "./add-target.js";
12
+ import { MeaningSuggestions as _e } from "./ai-forms/MeaningSuggestions.js";
13
+ import { useAddDragSource as fe } from "./dnd/node.js";
14
+ import { useFormFields as ge } from "./inspect/inspect-api.js";
15
+ import { textMatcher as he } from "./nav/find.js";
16
+ import { useOverviewFields as xe } from "./overview/overview-api.js";
17
+ import { LibraryRows as ye } from "./reuse/LibraryRows.js";
18
+ import { slotName as O } from "./slot-names.js";
19
+ import { useFieldFillRates as ke, fillText as be } from "./usage/usage-api.js";
20
+ const we = [
20
21
  "__pipeline__",
21
22
  "__comments__",
22
23
  "__tasks__",
@@ -26,7 +27,7 @@ const ke = [
26
27
  "__owners__",
27
28
  "__pdf__",
28
29
  "__subtitle__"
29
- ], z = {
30
+ ], J = {
30
31
  __pipeline__: "State track and actions",
31
32
  __comments__: "Notes and replies",
32
33
  __tasks__: "To-dos on this record",
@@ -36,18 +37,18 @@ const ke = [
36
37
  __owners__: "Who owns it at each step",
37
38
  __pdf__: "Generate and download a PDF",
38
39
  __subtitle__: "A line of values under the title"
39
- }, be = ["review_list", "rollup"];
40
- function J(a) {
40
+ }, Ne = ["review_list", "rollup"];
41
+ function V(a) {
41
42
  return {
42
43
  widget_id: a.id,
43
- input_bindings: be.includes(a.widget_type) ? [{ key: "record_id", binding_type: "item_field", binding_value: "id" }] : []
44
+ input_bindings: Ne.includes(a.widget_type) ? [{ key: "record_id", binding_type: "item_field", binding_value: "id" }] : []
44
45
  };
45
46
  }
46
- function Ne(a) {
47
- const i = a.interface ?? "";
48
- if (i.includes("o2m") || i === "list-o2m" || i === "inline-grid") return "Grid";
49
- if (i.includes("m2m") || i.includes("m2a")) return "Several records";
50
- if (i.includes("m2o")) return "Record";
47
+ function ve(a) {
48
+ const n = a.interface ?? "";
49
+ if (n.includes("o2m") || n === "list-o2m" || n === "inline-grid") return "Grid";
50
+ if (n.includes("m2m") || n.includes("m2a")) return "Several records";
51
+ if (n.includes("m2o")) return "Record";
51
52
  switch (a.type) {
52
53
  case "string":
53
54
  case "uuid":
@@ -74,39 +75,39 @@ function Ne(a) {
74
75
  return a.type ? $(a.type) : "";
75
76
  }
76
77
  }
77
- const we = "h-8 w-full rounded-md border border-slate-200 bg-white pl-7 pr-2.5 text-[12.5px] text-slate-800 outline-none placeholder:text-slate-400 focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-foreground dark:placeholder:text-muted-foreground", N = "px-2 pb-1 pt-3 text-[11.5px] font-semibold text-slate-500 dark:text-muted-foreground";
78
+ const Ce = "h-8 w-full rounded-md border border-slate-200 bg-white pl-7 pr-2.5 text-[12.5px] text-slate-800 outline-none placeholder:text-slate-400 focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-foreground dark:placeholder:text-muted-foreground", N = "px-2 pb-1 pt-3 text-[11.5px] font-semibold text-slate-500 dark:text-muted-foreground";
78
79
  function M({ children: a }) {
79
80
  return /* @__PURE__ */ d("span", { className: "inline-flex shrink-0 items-center gap-0.5 text-[11px] font-medium text-[#0089ad] dark:text-nvr-cyan", children: [
80
81
  /* @__PURE__ */ o(ne, { className: "h-3 w-3" }),
81
82
  a
82
83
  ] });
83
84
  }
84
- function w({
85
+ function y({
85
86
  title: a,
86
- sub: i,
87
+ sub: n,
87
88
  aside: c,
88
89
  onClick: u,
89
90
  attrs: l,
90
91
  extra: g,
91
92
  drag: _ = null
92
93
  }) {
93
- const m = me(_), t = /* @__PURE__ */ d(
94
+ const p = fe(_), t = /* @__PURE__ */ d(
94
95
  "button",
95
96
  {
96
97
  type: "button",
97
- ...m.props,
98
+ ...p.props,
98
99
  onClick: () => {
99
- m.clickBlocked() || u();
100
+ p.clickBlocked() || u();
100
101
  },
101
102
  ...l,
102
- className: V(
103
+ className: X(
103
104
  "group flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted",
104
- m.dragging && "opacity-40"
105
+ p.dragging && "opacity-40"
105
106
  ),
106
107
  children: [
107
108
  /* @__PURE__ */ d("span", { className: "flex min-w-0 flex-1 flex-col", children: [
108
109
  /* @__PURE__ */ o("span", { className: "truncate text-[12.5px] font-medium text-slate-900 dark:text-foreground", children: a }),
109
- i && /* @__PURE__ */ o("span", { className: "truncate text-[11.5px] text-slate-500 dark:text-muted-foreground", children: i })
110
+ n && /* @__PURE__ */ o("span", { className: "truncate text-[11.5px] text-slate-500 dark:text-muted-foreground", children: n })
110
111
  ] }),
111
112
  c
112
113
  ]
@@ -117,60 +118,60 @@ function w({
117
118
  g
118
119
  ] }) : t;
119
120
  }
120
- function He({
121
+ function Ye({
121
122
  bundle: a,
122
- collection: i,
123
+ collection: n,
123
124
  selected: c,
124
125
  apply: u,
125
126
  onSelect: l
126
127
  }) {
127
- const g = ie(), [_, m] = W(""), [t, s] = W("form"), { data: f = [] } = fe(i), { data: T } = xe(i), { data: X = [], error: L } = te({
128
+ const g = se(), [_, p] = W(""), [t, s] = W("form"), { data: h = [] } = xe(n), { data: D } = ke(n), { data: Z = [], error: T } = te({
128
129
  queryKey: ["layout-editor", "widgets"],
129
- queryFn: () => g.request(se("/widgets-internal")).then((e) => e.data ?? []),
130
+ queryFn: () => g.request(le("/widgets-internal")).then((e) => e.data ?? []),
130
131
  staleTime: 6e4,
131
132
  retry: !1
132
- }), [v, D] = W(null), h = ge(_), P = Q(() => {
133
+ }), [v, L] = W(null), f = he(_), P = Y(() => {
133
134
  const e = /* @__PURE__ */ new Map();
134
135
  for (const r of a.placements) e.set(r.field, [...e.get(r.field) ?? [], r]);
135
136
  return e;
136
- }, [a.placements]), C = (e) => (P.get(e) ?? []).find((r) => r.group_key !== A), E = (e) => (P.get(e) ?? []).find((r) => r.group_key === A), S = (e) => e.group_key === A ? { kind: "header", field: e.field } : {
137
+ }, [a.placements]), C = (e) => (P.get(e) ?? []).find((r) => r.group_key !== R), E = (e) => (P.get(e) ?? []).find((r) => r.group_key === R), S = (e) => e.group_key === R ? { kind: "header", field: e.field } : {
137
138
  kind: e.field.startsWith("__") ? "slot" : "field",
138
139
  field: e.field,
139
140
  group_key: e.group_key
140
- }, Z = (e, r, n) => {
141
- const p = t === "header" ? j(a, c, "header") : le({ field: e, group_key: null }) ? pe(a, c) : e === "__subtitle__" ? { group_key: null, index: 0 } : j(a, c);
142
- u([Y(e, p, n)], { label: `Add ${r}` }), l(S({ field: e, group_key: p.group_key }));
143
- }, F = (e, r, n, p) => n ? null : {
141
+ }, B = (e, r, i) => {
142
+ const m = t === "header" ? j(a, c, "header") : de({ field: e, group_key: null }) ? pe(a, c) : e === "__subtitle__" ? { group_key: null, index: 0 } : j(a, c);
143
+ u([z(e, m, i)], { label: `Add ${r}` }), l(S({ field: e, group_key: m.group_key }));
144
+ }, F = (e, r, i, m) => i ? null : {
144
145
  field: e,
145
146
  label: r,
146
- patch: p,
147
+ patch: m,
147
148
  to: t,
148
- onAdded: (b) => {
149
- const x = b[0];
149
+ onAdded: (w) => {
150
+ const x = w[0];
150
151
  (x == null ? void 0 : x.op) === "place" && l(S({ field: e, group_key: x.group_key }));
151
152
  }
152
- }, O = (e, r, n) => {
153
- D(null);
154
- const p = t === "header" ? E(e) : C(e);
155
- p ? l(S(p)) : Z(e, r, n);
153
+ }, A = (e, r, i) => {
154
+ L(null);
155
+ const m = t === "header" ? E(e) : C(e);
156
+ m ? l(S(m)) : B(e, r, i);
156
157
  }, ee = (e, r) => {
157
- var p;
158
- const n = j(a, c);
159
- if ((P.get(e) ?? []).some((b) => b.group_key === n.group_key)) {
160
- const b = n.group_key === null ? "Ungrouped" : ((p = a.groups.find((x) => x.key === n.group_key)) == null ? void 0 : p.label) ?? n.group_key;
161
- D({
158
+ var m;
159
+ const i = j(a, c);
160
+ if ((P.get(e) ?? []).some((w) => w.group_key === i.group_key)) {
161
+ const w = i.group_key === null ? "Ungrouped" : ((m = a.groups.find((x) => x.key === i.group_key)) == null ? void 0 : m.label) ?? i.group_key;
162
+ L({
162
163
  field: e,
163
- text: `${r} is already in ${b}. Select another section first.`
164
+ text: `${r} is already in ${w}. Select another section first.`
164
165
  });
165
166
  return;
166
167
  }
167
- D(null), u([Y(e, n)], { label: `Add another ${r}` }), l(S({ field: e, group_key: n.group_key }));
168
- }, { data: B = [] } = _e(i), G = Q(
169
- () => ve(a, B, f),
170
- [a, B, f]
171
- ).filter((e) => h(e.title, e.field)).slice(0, 8), I = f.filter((e) => e.field && !e.field.startsWith("__")).map((e) => ({ ...e, title: e.label || $(e.field) })).filter((e) => h(e.title, e.field)).sort((e, r) => e.title.localeCompare(r.title)), U = [...ke, ...de().map((e) => `__ext_${e}__`)].filter(
168
+ L(null), u([z(e, i)], { label: `Add another ${r}` }), l(S({ field: e, group_key: i.group_key }));
169
+ }, { data: G = [] } = ge(n), I = Y(
170
+ () => Se(a, G, h),
171
+ [a, G, h]
172
+ ).filter((e) => f(e.title, e.field)).slice(0, 8), U = h.filter((e) => e.field && !e.field.startsWith("__")).map((e) => ({ ...e, title: e.label || $(e.field) })).filter((e) => f(e.title, e.field)).sort((e, r) => e.title.localeCompare(r.title)), q = [...we, ...ce().map((e) => `__ext_${e}__`)].filter(
172
173
  (e) => t === "header" ? e === "__owners__" : !0
173
- ).filter((e) => h(R(e), z[e])), q = X.filter((e) => h(e.name, e.widget_type)), y = ce(a, c), k = y.op === "group_create" ? y.label.replace(/^New /, "") : "";
174
+ ).filter((e) => f(O(e), J[e])), H = Z.filter((e) => f(e.name, e.widget_type)), k = ue(a, c), b = k.op === "group_create" ? k.label.replace(/^New /, "") : "";
174
175
  return /* @__PURE__ */ d("div", { "data-editor-add": "", className: "flex flex-col px-2 pb-4", children: [
175
176
  /* @__PURE__ */ d("div", { className: "sticky top-0 z-10 flex flex-col gap-2 bg-white px-1 pb-1 pt-2 dark:bg-card", children: [
176
177
  /* @__PURE__ */ d("div", { className: "relative", children: [
@@ -179,10 +180,10 @@ function He({
179
180
  "input",
180
181
  {
181
182
  value: _,
182
- onChange: (e) => m(e.target.value),
183
+ onChange: (e) => p(e.target.value),
183
184
  placeholder: "Find a field, panel or widget",
184
185
  "aria-label": "Find something to add",
185
- className: we
186
+ className: Ce
186
187
  }
187
188
  )
188
189
  ] }),
@@ -194,7 +195,7 @@ function He({
194
195
  type: "button",
195
196
  "aria-pressed": t === e,
196
197
  onClick: () => s(e),
197
- className: V(
198
+ className: X(
198
199
  "rounded-md px-2 py-0.5 font-medium transition-colors",
199
200
  t === e ? "bg-accent text-slate-900 dark:text-foreground" : "hover:bg-muted hover:text-slate-800 dark:hover:text-foreground"
200
201
  ),
@@ -204,60 +205,76 @@ function He({
204
205
  ))
205
206
  ] })
206
207
  ] }),
207
- t === "form" && h(k, "section", "tab", "step") && /* @__PURE__ */ d(H, { children: [
208
+ t === "form" && f(b, "section", "tab", "step") && /* @__PURE__ */ d(K, { children: [
208
209
  /* @__PURE__ */ o("p", { className: N, children: "Layout" }),
209
210
  /* @__PURE__ */ o(
210
- w,
211
+ y,
211
212
  {
212
- title: k.charAt(0).toUpperCase() + k.slice(1),
213
- sub: `A new ${k.toLowerCase()} after the selection`,
213
+ title: b.charAt(0).toUpperCase() + b.slice(1),
214
+ sub: `A new ${b.toLowerCase()} after the selection`,
214
215
  attrs: { "data-add-section": "" },
215
216
  aside: /* @__PURE__ */ o(oe, { className: "h-3.5 w-3.5 text-slate-400" }),
216
217
  onClick: () => {
217
- u([y], { label: `Add ${k.toLowerCase()}` }), y.op === "group_create" && l({ kind: "group", key: y.key });
218
+ u([k], { label: `Add ${b.toLowerCase()}` }), k.op === "group_create" && l({ kind: "group", key: k.key });
218
219
  }
219
220
  }
220
221
  )
221
222
  ] }),
222
- t === "form" && !_.trim() && /* @__PURE__ */ o(ue, { bundle: a, collection: i, apply: u }),
223
- t === "form" && G.length > 0 && /* @__PURE__ */ d(H, { children: [
223
+ t === "form" && !["table", "file"].includes(String(a.layout.layout_type ?? "grouped")) && f("Display formula", "formula calculation remaining total") && /* @__PURE__ */ o(
224
+ y,
225
+ {
226
+ title: "Display formula",
227
+ sub: "A read-only figure worked out from fields on the form, never saved",
228
+ attrs: { "data-add-formula": "" },
229
+ aside: /* @__PURE__ */ o(ae, { className: "h-3.5 w-3.5 text-slate-400" }),
230
+ onClick: () => B(
231
+ me(a.placements.map((e) => e.field)),
232
+ "a display formula",
233
+ {
234
+ overrides: { label: "Formula", display_formula: { expr: "", format: "" } }
235
+ }
236
+ )
237
+ }
238
+ ),
239
+ t === "form" && !_.trim() && /* @__PURE__ */ o(_e, { bundle: a, collection: n, apply: u }),
240
+ t === "form" && I.length > 0 && /* @__PURE__ */ d(K, { children: [
224
241
  /* @__PURE__ */ o("p", { className: N, children: "On other forms" }),
225
- G.map((e) => /* @__PURE__ */ o(
226
- w,
242
+ I.map((e) => /* @__PURE__ */ o(
243
+ y,
227
244
  {
228
245
  title: e.title,
229
246
  sub: `On ${e.count} of ${e.of} other forms · ${e.names.join(", ")}`,
230
247
  attrs: { "data-add-suggested": e.field },
231
- aside: /* @__PURE__ */ o(K, { className: "h-3.5 w-3.5 shrink-0 text-slate-400 opacity-0 group-hover:opacity-100" }),
232
- onClick: () => O(e.field, e.title),
248
+ aside: /* @__PURE__ */ o(Q, { className: "h-3.5 w-3.5 shrink-0 text-slate-400 opacity-0 group-hover:opacity-100" }),
249
+ onClick: () => A(e.field, e.title),
233
250
  drag: F(e.field, e.title, null)
234
251
  },
235
252
  e.field
236
253
  ))
237
254
  ] }),
238
255
  t === "form" && /* @__PURE__ */ o(
239
- he,
256
+ ye,
240
257
  {
241
258
  bundle: a,
242
- collection: i,
259
+ collection: n,
243
260
  selected: c,
244
261
  apply: u,
245
262
  onSelect: l,
246
- matches: h
263
+ matches: f
247
264
  }
248
265
  ),
249
266
  /* @__PURE__ */ o("p", { className: N, children: "Fields" }),
250
- I.map((e) => {
267
+ U.map((e) => {
251
268
  const r = t === "header" ? E(e.field) : C(e.field);
252
269
  return /* @__PURE__ */ d("div", { children: [
253
270
  /* @__PURE__ */ o(
254
- w,
271
+ y,
255
272
  {
256
273
  title: e.title,
257
- sub: [e.field, Ne(e), T ? ye(T.pct.get(e.field), T.total) : null].filter(Boolean).join(" · "),
274
+ sub: [e.field, ve(e), D ? be(D.pct.get(e.field), D.total) : null].filter(Boolean).join(" · "),
258
275
  attrs: { "data-add-field": e.field, "data-on-form": r ? "true" : void 0 },
259
- aside: r ? /* @__PURE__ */ o(M, { children: t === "header" ? "in header" : "on this form" }) : /* @__PURE__ */ o(K, { className: "h-3.5 w-3.5 shrink-0 text-slate-400 opacity-0 group-hover:opacity-100" }),
260
- onClick: () => O(e.field, e.title),
276
+ aside: r ? /* @__PURE__ */ o(M, { children: t === "header" ? "in header" : "on this form" }) : /* @__PURE__ */ o(Q, { className: "h-3.5 w-3.5 shrink-0 text-slate-400 opacity-0 group-hover:opacity-100" }),
277
+ onClick: () => A(e.field, e.title),
261
278
  drag: F(e.field, e.title, r),
262
279
  extra: r && t === "form" ? /* @__PURE__ */ o(
263
280
  "button",
@@ -268,7 +285,7 @@ function He({
268
285
  "data-tip": "Add another copy after the selection",
269
286
  onClick: () => ee(e.field, e.title),
270
287
  className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-slate-400 transition-colors hover:bg-muted hover:text-slate-700 dark:hover:text-foreground",
271
- children: /* @__PURE__ */ o(ae, { className: "h-3.5 w-3.5" })
288
+ children: /* @__PURE__ */ o(ie, { className: "h-3.5 w-3.5" })
272
289
  }
273
290
  ) : null
274
291
  }
@@ -284,10 +301,10 @@ function He({
284
301
  )
285
302
  ] }, e.field);
286
303
  }),
287
- !I.length && /* @__PURE__ */ o("p", { className: "px-2 py-1.5 text-[12px] text-slate-500 dark:text-muted-foreground", children: "No fields match." }),
288
- U.length > 0 && /* @__PURE__ */ o("p", { className: N, children: "Panels" }),
289
- U.map((e) => {
290
- const r = t === "header" ? E(e) : C(e), n = e === "__subtitle__" ? {
304
+ !U.length && /* @__PURE__ */ o("p", { className: "px-2 py-1.5 text-[12px] text-slate-500 dark:text-muted-foreground", children: "No fields match." }),
305
+ q.length > 0 && /* @__PURE__ */ o("p", { className: N, children: "Panels" }),
306
+ q.map((e) => {
307
+ const r = t === "header" ? E(e) : C(e), i = e === "__subtitle__" ? {
291
308
  input_bindings: [
292
309
  {
293
310
  key: "__subtitle_config__",
@@ -297,56 +314,56 @@ function He({
297
314
  ]
298
315
  } : void 0;
299
316
  return /* @__PURE__ */ o(
300
- w,
317
+ y,
301
318
  {
302
- title: R(e),
303
- sub: z[e] ?? "Extension panel",
319
+ title: O(e),
320
+ sub: J[e] ?? "Extension panel",
304
321
  attrs: { "data-add-slot": e, "data-on-form": r ? "true" : void 0 },
305
322
  aside: r ? /* @__PURE__ */ o(M, { children: "on this form" }) : null,
306
- onClick: () => O(e, R(e), n),
307
- drag: e === "__subtitle__" ? null : F(e, R(e), r)
323
+ onClick: () => A(e, O(e), i),
324
+ drag: e === "__subtitle__" ? null : F(e, O(e), r)
308
325
  },
309
326
  e
310
327
  );
311
328
  }),
312
- t === "form" && (q.length > 0 || L) && /* @__PURE__ */ o("p", { className: N, children: "Widgets" }),
313
- t === "form" && L && /* @__PURE__ */ d("p", { role: "alert", className: "px-2 py-1.5 text-[12px] text-red-700 dark:text-red-300", children: [
329
+ t === "form" && (H.length > 0 || T) && /* @__PURE__ */ o("p", { className: N, children: "Widgets" }),
330
+ t === "form" && T && /* @__PURE__ */ d("p", { role: "alert", className: "px-2 py-1.5 text-[12px] text-red-700 dark:text-red-300", children: [
314
331
  "Widgets could not be loaded: ",
315
- L.message
332
+ T.message
316
333
  ] }),
317
- t === "form" && q.map((e) => {
318
- const r = `__widget_${e.id}__`, n = C(r);
334
+ t === "form" && H.map((e) => {
335
+ const r = `__widget_${e.id}__`, i = C(r);
319
336
  return /* @__PURE__ */ o(
320
- w,
337
+ y,
321
338
  {
322
339
  title: e.name,
323
340
  sub: $(e.widget_type),
324
- attrs: { "data-add-widget": String(e.id), "data-on-form": n ? "true" : void 0 },
325
- aside: n ? /* @__PURE__ */ o(M, { children: "on this form" }) : null,
326
- onClick: () => O(r, e.name, J(e)),
327
- drag: F(r, e.name, n, J(e))
341
+ attrs: { "data-add-widget": String(e.id), "data-on-form": i ? "true" : void 0 },
342
+ aside: i ? /* @__PURE__ */ o(M, { children: "on this form" }) : null,
343
+ onClick: () => A(r, e.name, V(e)),
344
+ drag: F(r, e.name, i, V(e))
328
345
  },
329
346
  e.id
330
347
  );
331
348
  })
332
349
  ] });
333
350
  }
334
- function ve(a, i, c) {
335
- const u = String(a.layout.layout_type || "grouped"), l = i.filter(
351
+ function Se(a, n, c) {
352
+ const u = String(a.layout.layout_type || "grouped"), l = n.filter(
336
353
  (t) => Number(t.layout_id) !== Number(a.layout.id) && t.layout_type === u
337
354
  );
338
355
  if (!l.length) return [];
339
356
  const g = new Set(
340
- a.placements.filter((t) => t.group_key !== A).map((t) => t.field)
341
- ), _ = new Map(c.map((t) => [t.field, t])), m = /* @__PURE__ */ new Map();
357
+ a.placements.filter((t) => t.group_key !== R).map((t) => t.field)
358
+ ), _ = new Map(c.map((t) => [t.field, t])), p = /* @__PURE__ */ new Map();
342
359
  for (const t of l)
343
360
  for (const s of t.fields)
344
- !g.has(s) && _.has(s) && m.set(s, [...m.get(s) ?? [], t.name]);
345
- return [...m.entries()].map(([t, s]) => {
346
- var f;
361
+ !g.has(s) && _.has(s) && p.set(s, [...p.get(s) ?? [], t.name]);
362
+ return [...p.entries()].map(([t, s]) => {
363
+ var h;
347
364
  return {
348
365
  field: t,
349
- title: ((f = _.get(t)) == null ? void 0 : f.label) || $(t),
366
+ title: ((h = _.get(t)) == null ? void 0 : h.label) || $(t),
350
367
  count: s.length,
351
368
  of: l.length,
352
369
  names: s.slice(0, 3).concat(s.length > 3 ? [`${s.length - 3} more`] : [])
@@ -354,6 +371,6 @@ function ve(a, i, c) {
354
371
  }).sort((t, s) => s.count - t.count || t.title.localeCompare(s.title));
355
372
  }
356
373
  export {
357
- He as AddPanel,
358
- ve as otherFormSuggestions
374
+ Ye as AddPanel,
375
+ Se as otherFormSuggestions
359
376
  };
@@ -1,20 +1,20 @@
1
1
  import { jsxs as r, jsx as a } from "react/jsx-runtime";
2
- import { useState as k, useMemo as v } from "react";
2
+ import { useState as v, useMemo as b } from "react";
3
3
  import { cn as u } from "../../lib/utils.js";
4
- import { Popover as b, PopoverAnchor as N, PopoverContent as y } from "../ui/popover.js";
4
+ import { Popover as N, PopoverAnchor as y, PopoverContent as w } from "../ui/popover.js";
5
5
  import { inputBase as f } from "./panel-style.js";
6
- import { unsavedText as w } from "./UnsavedConfirm.js";
7
- function A(e) {
6
+ import { unsavedText as C } from "./UnsavedConfirm.js";
7
+ function D(e) {
8
8
  const t = e == null ? void 0 : e.change_note;
9
9
  return t === "note" || t === "note_ticket" ? t : null;
10
10
  }
11
- function C(e, t) {
11
+ function P(e, t) {
12
12
  return e ? t.reason.trim().length < 3 ? !1 : e !== "note_ticket" || t.ticket.trim().length > 0 : !0;
13
13
  }
14
- function D(e) {
14
+ function F(e) {
15
15
  return { reason: e.reason.trim(), ticket: e.ticket.trim() || null };
16
16
  }
17
- function P({
17
+ function S({
18
18
  policy: e,
19
19
  value: t,
20
20
  onChange: o,
@@ -60,7 +60,7 @@ function P({
60
60
  ] })
61
61
  ] });
62
62
  }
63
- function F({
63
+ function K({
64
64
  open: e,
65
65
  anchor: t,
66
66
  policy: o,
@@ -68,14 +68,15 @@ function F({
68
68
  value: s,
69
69
  onChange: n,
70
70
  onSave: p,
71
- onClose: l
71
+ onClose: l,
72
+ intro: x
72
73
  }) {
73
- const [c, d] = k(!1), x = v(
74
+ const [c, d] = v(!1), g = b(
74
75
  () => ({ current: t ?? document.body }),
75
76
  [t]
76
77
  );
77
78
  if (!e) return null;
78
- const m = C(o, s), h = async () => {
79
+ const m = P(o, s), h = async () => {
79
80
  if (!(!m || c)) {
80
81
  d(!0);
81
82
  try {
@@ -86,22 +87,22 @@ function F({
86
87
  }
87
88
  };
88
89
  return /* @__PURE__ */ r(
89
- b,
90
+ N,
90
91
  {
91
92
  open: !0,
92
- onOpenChange: (g) => {
93
- !g && !c && l();
93
+ onOpenChange: (k) => {
94
+ !k && !c && l();
94
95
  },
95
96
  children: [
96
- /* @__PURE__ */ a(N, { virtualRef: x }),
97
- /* @__PURE__ */ r(y, { align: "end", className: "w-[320px] p-3", "data-change-note-save": "", children: [
97
+ /* @__PURE__ */ a(y, { virtualRef: g }),
98
+ /* @__PURE__ */ r(w, { align: "end", className: "w-[320px] p-3", "data-change-note-save": "", children: [
98
99
  /* @__PURE__ */ r("p", { className: "text-[13px] font-semibold text-slate-900 dark:text-foreground", children: [
99
100
  "Save ",
100
- w(i)
101
+ C(i)
101
102
  ] }),
102
- /* @__PURE__ */ a("p", { className: "mb-2 mt-0.5 text-[12px] leading-snug text-slate-600 dark:text-muted-foreground", children: "This layout keeps a reason with every save. It shows in History." }),
103
+ /* @__PURE__ */ a("p", { className: "mb-2 mt-0.5 text-[12px] leading-snug text-slate-600 dark:text-muted-foreground", children: x ?? "This layout keeps a reason with every save. It shows in History." }),
103
104
  /* @__PURE__ */ a(
104
- P,
105
+ S,
105
106
  {
106
107
  policy: o,
107
108
  value: s,
@@ -138,9 +139,9 @@ function F({
138
139
  );
139
140
  }
140
141
  export {
141
- P as ChangeNoteFields,
142
- F as ChangeNoteSave,
143
- D as changeNoteMeta,
144
- A as changeNotePolicyOf,
145
- C as changeNoteReady
142
+ S as ChangeNoteFields,
143
+ K as ChangeNoteSave,
144
+ F as changeNoteMeta,
145
+ D as changeNotePolicyOf,
146
+ P as changeNoteReady
146
147
  };