@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,142 @@
1
+ import { jsxs as x, Fragment as M, jsx as d } from "react/jsx-runtime";
2
+ import { useContext as E, useRef as C, useState as S, useLayoutEffect as T, useEffect as k, useSyncExternalStore as O } from "react";
3
+ import { cn as L } from "../../lib/utils.js";
4
+ import { useLayoutDesign as j } from "./design-context.js";
5
+ import { DndStoreContext as N } from "./dnd/node.js";
6
+ import { WIDTH_LABELS as D, GRID_WIDTHS as R } from "./field-zones.js";
7
+ const B = () => () => {
8
+ };
9
+ function H() {
10
+ const t = E(N);
11
+ return O(
12
+ (t == null ? void 0 : t.subscribe) ?? B,
13
+ () => !!(t != null && t.guidesOn()),
14
+ () => !1
15
+ );
16
+ }
17
+ function J({ gapClass: t = "gap-x-4" }) {
18
+ const r = j(), i = H();
19
+ return !r || !i ? null : /* @__PURE__ */ d(
20
+ "div",
21
+ {
22
+ "aria-hidden": !0,
23
+ "data-design-grid-guides": "",
24
+ className: L("pointer-events-none absolute inset-0 grid grid-cols-12", t),
25
+ children: Array.from({ length: 12 }, (a, l) => /* @__PURE__ */ d(
26
+ "div",
27
+ {
28
+ className: "rounded-sm bg-nvr-cyan/[0.05] ring-1 ring-inset ring-nvr-cyan/10 dark:bg-nvr-cyan/[0.06] dark:ring-nvr-cyan/15"
29
+ },
30
+ l
31
+ ))
32
+ }
33
+ );
34
+ }
35
+ function W(t, r, i) {
36
+ const a = (r - 11 * i) / 12;
37
+ if (!(a > 0)) return 12;
38
+ const l = (t + i) / (a + i);
39
+ let c = 12;
40
+ for (const o of R) Math.abs(o - l) < Math.abs(c - l) && (c = o);
41
+ return c;
42
+ }
43
+ const h = [...R].sort((t, r) => t - r), P = (t) => {
44
+ const r = /span\s+(\d+)/.exec(t.style.gridColumn);
45
+ return r ? Number(r[1]) : 12;
46
+ }, _ = (t) => !!t && getComputedStyle(t).display === "grid" && getComputedStyle(t).gridTemplateColumns.trim().split(/\s+/).length === 12;
47
+ function Q({ onCommit: t }) {
48
+ const r = E(N), i = C(null), a = C(null), [l, c] = S(!1), [o, g] = S(null), p = () => {
49
+ var e;
50
+ return ((e = i.current) == null ? void 0 : e.closest("[data-design-target]")) ?? null;
51
+ };
52
+ T(() => {
53
+ var e;
54
+ c(_(((e = p()) == null ? void 0 : e.parentElement) ?? null));
55
+ }, []);
56
+ const u = (e) => {
57
+ const n = a.current;
58
+ n && (a.current = null, n.cell.style.gridColumn = n.original, r == null || r.setResizing(!1), g(null), e && n.span !== n.start && t(n.span));
59
+ };
60
+ k(() => {
61
+ if (o === null) return;
62
+ const e = (n) => {
63
+ n.key === "Escape" && (n.preventDefault(), n.stopPropagation(), u(!1));
64
+ };
65
+ return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
66
+ }), k(() => () => u(!1), []);
67
+ const y = p(), f = y ? P(y) : 12, z = (e) => {
68
+ var b, w;
69
+ const n = p(), s = n == null ? void 0 : n.parentElement;
70
+ if (!n || !s || e.button !== 0) return;
71
+ e.preventDefault(), e.stopPropagation(), (w = (b = e.currentTarget).setPointerCapture) == null || w.call(b, e.pointerId);
72
+ const I = getComputedStyle(s), v = P(n);
73
+ a.current = {
74
+ cell: n,
75
+ left: n.getBoundingClientRect().left,
76
+ width: s.getBoundingClientRect().width,
77
+ gap: Number.parseFloat(I.columnGap) || 0,
78
+ start: v,
79
+ span: v,
80
+ original: n.style.gridColumn
81
+ }, r == null || r.setResizing(!0), g(v);
82
+ }, A = (e) => {
83
+ const n = a.current;
84
+ if (!n) return;
85
+ const s = W(e.clientX - n.left, n.width, n.gap);
86
+ s !== n.span && (n.span = s, n.cell.style.gridColumn = `span ${s}`, g(s));
87
+ }, G = (e) => {
88
+ if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
89
+ e.preventDefault(), e.stopPropagation();
90
+ const n = h.indexOf(f), s = h[Math.max(0, Math.min(h.length - 1, n + (e.key === "ArrowRight" ? 1 : -1)))];
91
+ s !== void 0 && s !== f && t(s);
92
+ }, m = o ?? f;
93
+ return /* @__PURE__ */ x(M, { children: [
94
+ /* @__PURE__ */ x(
95
+ "span",
96
+ {
97
+ ref: i,
98
+ role: "slider",
99
+ tabIndex: 0,
100
+ "aria-label": "Width",
101
+ "aria-valuemin": 3,
102
+ "aria-valuemax": 12,
103
+ "aria-valuenow": m,
104
+ "aria-valuetext": D[m] ?? `${m} of 12 columns`,
105
+ "data-design-resize": "",
106
+ "data-design-pass": "",
107
+ "data-tip": o === null ? "Drag to change the width" : void 0,
108
+ onPointerDown: z,
109
+ onPointerMove: A,
110
+ onPointerUp: () => u(!0),
111
+ onPointerCancel: () => u(!1),
112
+ onLostPointerCapture: () => u(!0),
113
+ onKeyDown: G,
114
+ onClick: (e) => e.stopPropagation(),
115
+ className: L(
116
+ "absolute -right-[7px] top-1/2 z-20 flex h-7 w-3 -translate-y-1/2 cursor-col-resize items-center justify-center gap-[2px] rounded-sm bg-white ring-1 ring-nvr-cyan transition-colors hover:bg-nvr-cyan/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-nvr-cyan dark:bg-card motion-reduce:transition-none",
117
+ o !== null && "bg-nvr-cyan/10",
118
+ !l && "hidden"
119
+ ),
120
+ children: [
121
+ /* @__PURE__ */ d("span", { className: "h-3 w-px bg-nvr-cyan" }),
122
+ /* @__PURE__ */ d("span", { className: "h-3 w-px bg-nvr-cyan" })
123
+ ]
124
+ }
125
+ ),
126
+ o !== null && /* @__PURE__ */ d(
127
+ "span",
128
+ {
129
+ "aria-hidden": !0,
130
+ "data-design-resize-chip": "",
131
+ className: "pointer-events-none absolute -top-2.5 right-3 z-20 rounded bg-nvr-cyan px-1.5 text-[11px] font-medium leading-5 text-white",
132
+ children: D[o] ?? o
133
+ }
134
+ )
135
+ ] });
136
+ }
137
+ export {
138
+ J as GridGuides,
139
+ Q as ResizeHandle,
140
+ W as snapSpan,
141
+ H as useGridGuides
142
+ };
@@ -0,0 +1,402 @@
1
+ import { jsxs as h, jsx as a, Fragment as C } from "react/jsx-runtime";
2
+ import { X as $ } from "lucide-react";
3
+ import { useMemo as N } from "react";
4
+ import { validateExpression as R } from "../../../lib/expression.js";
5
+ import { displayFormulaOf as T, textRulesOf as O, counterOf as L, confirmChangeOf as F } from "../../../lib/placement-behaviour.js";
6
+ import { cn as A } from "../../../lib/utils.js";
7
+ import { RoleConditionRow as M, PipelineStateConditionRow as w } from "../editors/lock-conditions.js";
8
+ import { useColumnFacts as I, columnOf as W } from "../inspect/inspect-api.js";
9
+ import { effectText as D, tintCard as P } from "../panel-style.js";
10
+ import { isRelational as j } from "./applies.js";
11
+ import { useFieldCtx as b } from "./field-context.js";
12
+ import { useInspectorEnv as q, Setting as p, TextInput as v, TextArea as K, Segmented as k, DraftInput as E, AddButton as H, Toggle as _ } from "./kit.js";
13
+ const U = "rounded p-0.5 text-slate-400 transition-colors hover:bg-muted hover:text-slate-700 dark:hover:text-foreground";
14
+ function z(o) {
15
+ if (j(o)) return !1;
16
+ const s = o.iface ?? "";
17
+ return ["string", "text", "richtext", "rich_text", "markdown", "wysiwyg"].includes(o.type) || /textarea|rich|wysiwyg|markdown/i.test(s);
18
+ }
19
+ function S(o, s) {
20
+ return !s.startsWith("__") && !o.isPath && o.type !== "alias" && o.relKind !== "M2M" && o.relKind !== "O2M" && o.computedType !== "virtual" && o.computedType !== "read";
21
+ }
22
+ function re() {
23
+ const o = b(), { ov: s, info: d, env: f, row: l } = o, i = d.label, c = O(s), u = (r, n, e) => o.setOverride("text_rules", r.length ? r : void 0, n, e), t = (r, n, e, m) => u(
24
+ c.map((g, y) => y === r ? { ...g, ...n } : g),
25
+ e,
26
+ m
27
+ );
28
+ return l.field.startsWith("__") ? null : /* @__PURE__ */ h(
29
+ p,
30
+ {
31
+ k: "field.text_rules",
32
+ label: "Label and help by state or role",
33
+ effect: "Different words in a workflow state or for a role: “Requested date” becomes “Delivered date” once Completed. The first rule that matches wins; the record page, read view and PDF follow it.",
34
+ children: [
35
+ c.map((r, n) => /* @__PURE__ */ h(
36
+ "div",
37
+ {
38
+ "data-text-rule": n,
39
+ className: A(P, "space-y-2 px-2.5 py-2"),
40
+ children: [
41
+ /* @__PURE__ */ h("div", { className: "flex items-center gap-2", children: [
42
+ /* @__PURE__ */ a("div", { className: "flex-1", children: /* @__PURE__ */ a(
43
+ k,
44
+ {
45
+ value: r.type,
46
+ options: [
47
+ { value: "pipeline_state", label: "In a state" },
48
+ { value: "role", label: "For a role" }
49
+ ],
50
+ onChange: (e) => t(
51
+ n,
52
+ e === "role" ? {
53
+ type: "role",
54
+ role_ids: [],
55
+ state_keys: void 0,
56
+ pipeline_id: void 0
57
+ } : { type: "pipeline_state", state_keys: [], role_ids: void 0 },
58
+ `Change when ${i} reads differently`
59
+ )
60
+ }
61
+ ) }),
62
+ /* @__PURE__ */ a(
63
+ "button",
64
+ {
65
+ type: "button",
66
+ "aria-label": "Remove this rule",
67
+ "data-tip": "Remove this rule",
68
+ className: U,
69
+ onClick: () => u(
70
+ c.filter((e, m) => m !== n),
71
+ `Remove a label rule from ${i}`
72
+ ),
73
+ children: /* @__PURE__ */ a($, { className: "h-3.5 w-3.5" })
74
+ }
75
+ )
76
+ ] }),
77
+ r.type === "role" ? /* @__PURE__ */ a(
78
+ M,
79
+ {
80
+ roleIds: r.role_ids ?? [],
81
+ onRoleIdsChange: (e) => t(n, { role_ids: e }, `Change the roles for ${i}`)
82
+ }
83
+ ) : /* @__PURE__ */ a(
84
+ w,
85
+ {
86
+ collection: f.collection,
87
+ pipelineId: r.pipeline_id,
88
+ stateKeys: r.state_keys ?? [],
89
+ onPipelineChange: (e) => t(n, { pipeline_id: e, state_keys: [] }, `Change the pipeline for ${i}`),
90
+ onStateKeysChange: (e) => t(n, { state_keys: e }, `Change the states for ${i}`)
91
+ }
92
+ ),
93
+ /* @__PURE__ */ a(
94
+ v,
95
+ {
96
+ ariaLabel: "Label in this case",
97
+ value: r.label ?? "",
98
+ placeholder: `Label (${i})`,
99
+ onChange: (e) => t(n, { label: e || void 0 }, `Change a label rule of ${i}`, !0)
100
+ }
101
+ ),
102
+ /* @__PURE__ */ a(
103
+ v,
104
+ {
105
+ ariaLabel: "Help text in this case",
106
+ value: r.note ?? "",
107
+ placeholder: "Help text (unchanged when empty)",
108
+ onChange: (e) => t(n, { note: e || void 0 }, `Change a help rule of ${i}`, !0)
109
+ }
110
+ )
111
+ ]
112
+ },
113
+ n
114
+ )),
115
+ /* @__PURE__ */ a(
116
+ H,
117
+ {
118
+ onClick: () => u(
119
+ [...c, { type: "pipeline_state", state_keys: [] }],
120
+ `Add a label rule to ${i}`
121
+ ),
122
+ children: "+ Add a rule"
123
+ }
124
+ )
125
+ ]
126
+ }
127
+ );
128
+ }
129
+ function le() {
130
+ const o = b(), { ov: s, info: d, env: f, row: l } = o, { data: i } = I(f.collection), c = W(i, l.field);
131
+ if (!z(d) || l.field.startsWith("__")) return null;
132
+ const u = d.label, t = L(s), r = (c == null ? void 0 : c.max_length) != null && c.max_length > 0 ? c.max_length : null, n = (e, m, g) => o.setOverride("counter", e, m, g);
133
+ return /* @__PURE__ */ h("div", { "data-setting": "field.counter", className: "space-y-3", children: [
134
+ /* @__PURE__ */ a(
135
+ _,
136
+ {
137
+ k: "field.counter.on",
138
+ label: "Counter and limit",
139
+ effect: r ? `Counts as people type. The limit starts at the column size (${r.toLocaleString()} characters); past it the form will not save.` : "Counts as people type; past a limit the form will not save.",
140
+ checked: !!t,
141
+ onChange: (e) => n(
142
+ e ? { unit: "characters", ...r ? { limit: r } : {} } : void 0,
143
+ e ? `Count the characters of ${u}` : `Stop counting ${u}`
144
+ )
145
+ }
146
+ ),
147
+ t && /* @__PURE__ */ h(C, { children: [
148
+ /* @__PURE__ */ a(p, { k: "field.counter.unit", label: "Count", effect: "Characters or words.", children: /* @__PURE__ */ a(
149
+ k,
150
+ {
151
+ value: t.unit,
152
+ options: [
153
+ { value: "characters", label: "Characters" },
154
+ { value: "words", label: "Words" }
155
+ ],
156
+ onChange: (e) => n(
157
+ {
158
+ unit: e,
159
+ ...e === "words" ? {} : t.limit != null ? { limit: t.limit } : r ? { limit: r } : {}
160
+ },
161
+ `Count the ${e} of ${u}`
162
+ )
163
+ }
164
+ ) }),
165
+ /* @__PURE__ */ a(
166
+ p,
167
+ {
168
+ k: "field.counter.limit",
169
+ label: "Limit",
170
+ effect: t.unit === "words" ? "Most words allowed. Empty counts without a limit." : `Most characters allowed. Empty counts without a limit${r ? `; the column holds ${r.toLocaleString()}` : ""}.`,
171
+ children: /* @__PURE__ */ a(
172
+ v,
173
+ {
174
+ type: "number",
175
+ ariaLabel: "Limit",
176
+ value: t.limit == null ? "" : String(t.limit),
177
+ placeholder: t.unit === "characters" && r ? String(r) : "No limit",
178
+ onChange: (e) => {
179
+ const m = e === "" ? void 0 : Math.max(1, Math.floor(Number(e)));
180
+ m !== void 0 && !Number.isFinite(m) || n(
181
+ { unit: t.unit, ...m ? { limit: m } : {} },
182
+ `Set the limit of ${u}`,
183
+ !0
184
+ );
185
+ }
186
+ }
187
+ )
188
+ }
189
+ )
190
+ ] })
191
+ ] });
192
+ }
193
+ function ie() {
194
+ var i;
195
+ const o = b(), { ov: s, info: d, row: f } = o;
196
+ if (f.field.startsWith("__")) return null;
197
+ const l = s.required === !0 || s.required === void 0 && !!((i = d.global) != null && i.required);
198
+ return /* @__PURE__ */ a(
199
+ _,
200
+ {
201
+ k: "field.recommended",
202
+ label: "Recommended",
203
+ effect: l ? "Required already wins; switch Required off to make this a recommendation." : "An amber marker and a reminder on save listing what is still empty. Saving is never blocked.",
204
+ checked: s.recommended === !0 && !l,
205
+ disabled: l,
206
+ onChange: (c) => o.setOverride(
207
+ "recommended",
208
+ c ? !0 : void 0,
209
+ c ? `Recommend ${d.label}` : `Stop recommending ${d.label}`
210
+ )
211
+ }
212
+ );
213
+ }
214
+ function se() {
215
+ const o = b(), { ov: s, info: d, env: f, row: l } = o;
216
+ if (!S(d, l.field)) return null;
217
+ const i = d.label, c = F(s), u = s.confirm_change && typeof s.confirm_change == "object" ? s.confirm_change : {}, t = typeof u.pipeline_id == "string" ? u.pipeline_id : void 0, r = (n, e) => o.setOverride("confirm_change", n, e);
218
+ return /* @__PURE__ */ h("div", { "data-setting": "field.confirm_change", className: "space-y-3", children: [
219
+ /* @__PURE__ */ a(
220
+ _,
221
+ {
222
+ k: "field.confirm_change.on",
223
+ label: "Confirm changes on saved records",
224
+ effect: "Changing it on an existing record asks “Are you sure?” and a short reason, kept with the change in the history. New records are not asked.",
225
+ checked: !!c,
226
+ onChange: (n) => r(
227
+ n ? { state_keys: [] } : void 0,
228
+ n ? `Confirm changes to ${i}` : `Stop confirming changes to ${i}`
229
+ )
230
+ }
231
+ ),
232
+ c && /* @__PURE__ */ a(
233
+ p,
234
+ {
235
+ k: "field.confirm_change.states",
236
+ label: "Only in these states",
237
+ effect: c.state_keys.length ? "Asked only while the record is in a ticked state." : "No state ticked: asked in every state.",
238
+ children: /* @__PURE__ */ a(
239
+ w,
240
+ {
241
+ collection: f.collection,
242
+ pipelineId: t,
243
+ stateKeys: c.state_keys,
244
+ onPipelineChange: (n) => r(
245
+ { ...n ? { pipeline_id: n } : {}, state_keys: [] },
246
+ `Change the pipeline that confirms ${i}`
247
+ ),
248
+ onStateKeysChange: (n) => r(
249
+ { ...t ? { pipeline_id: t } : {}, state_keys: n },
250
+ `Change the states that confirm ${i}`
251
+ )
252
+ }
253
+ )
254
+ }
255
+ )
256
+ ] });
257
+ }
258
+ function ce() {
259
+ const o = b(), { ov: s, info: d, row: f } = o;
260
+ return !S(d, f.field) || d.computedType ? null : /* @__PURE__ */ a(
261
+ _,
262
+ {
263
+ k: "field.repeat_last",
264
+ label: "Repeat last value",
265
+ effect: "A “Repeat last” button beside the label fills in what this person entered on their previous record here.",
266
+ checked: s.repeat_last === !0,
267
+ onChange: (l) => o.setOverride(
268
+ "repeat_last",
269
+ l ? !0 : void 0,
270
+ l ? `Offer to repeat the last ${d.label}` : `Stop offering to repeat ${d.label}`
271
+ )
272
+ }
273
+ );
274
+ }
275
+ const B = [
276
+ { value: "", label: "Plain" },
277
+ { value: "integer", label: "Whole" },
278
+ { value: "number", label: "Decimal" },
279
+ { value: "currency", label: "Money" },
280
+ { value: "percent", label: "Percent" }
281
+ ];
282
+ function de({
283
+ row: o,
284
+ fields: s
285
+ }) {
286
+ const d = q(), f = N(() => {
287
+ const e = o.overrides;
288
+ if (typeof e == "string")
289
+ try {
290
+ return JSON.parse(e) ?? {};
291
+ } catch {
292
+ return {};
293
+ }
294
+ return e && typeof e == "object" ? e : {};
295
+ }, [o.overrides]), l = T(f) ?? { expr: "", format: "", currency: null }, i = typeof f.label == "string" ? f.label : "", c = { field: o.field, group_key: o.group_key }, u = (e, m, g) => {
296
+ const y = { ...f, ...e };
297
+ for (const x of Object.keys(y)) y[x] === void 0 && delete y[x];
298
+ d.apply([{ op: "update_placement", at: c, patch: { overrides: y } }], {
299
+ label: m,
300
+ text: g
301
+ });
302
+ }, t = l.expr.trim() ? R(l.expr, s) : null, r = new Set(
303
+ d.bundle.placements.filter((e) => !e.field.startsWith("__")).map((e) => e.field)
304
+ ), n = t != null && t.ok ? t.tokens.filter((e) => !r.has(e.split(".")[0])) : [];
305
+ return /* @__PURE__ */ h("div", { className: "space-y-5", children: [
306
+ /* @__PURE__ */ a(p, { k: "display_formula.label", label: "Label", effect: "What the form calls the value.", children: /* @__PURE__ */ a(
307
+ v,
308
+ {
309
+ ariaLabel: "Label",
310
+ value: i,
311
+ placeholder: "Remaining",
312
+ onChange: (e) => u({ label: e || void 0 }, "Rename the formula", !0)
313
+ }
314
+ ) }),
315
+ /* @__PURE__ */ h(
316
+ p,
317
+ {
318
+ k: "display_formula.expr",
319
+ label: "Formula",
320
+ effect: /* @__PURE__ */ h(C, { children: [
321
+ "Fields in double braces, for example",
322
+ " ",
323
+ /* @__PURE__ */ a("code", { className: "font-mono text-[11.5px]", children: "{{budget}} - {{committed}}" }),
324
+ ". Worked out on the page from what is on the form; never saved."
325
+ ] }),
326
+ children: [
327
+ /* @__PURE__ */ a(
328
+ K,
329
+ {
330
+ ariaLabel: "Formula",
331
+ rows: 3,
332
+ mono: !0,
333
+ value: l.expr,
334
+ onChange: (e) => u({ display_formula: { ...l, expr: e } }, "Change the formula", !0)
335
+ }
336
+ ),
337
+ t && !t.ok && /* @__PURE__ */ a(
338
+ "p",
339
+ {
340
+ role: "alert",
341
+ "data-formula-error": "",
342
+ className: "text-[12px] text-red-700 dark:text-red-300",
343
+ children: t.error
344
+ }
345
+ ),
346
+ (t == null ? void 0 : t.ok) && t.unknownTokens.length > 0 && /* @__PURE__ */ h("p", { "data-formula-unknown": "", className: "text-[12px] text-amber-700 dark:text-amber-300", children: [
347
+ "Not fields of this collection:",
348
+ " ",
349
+ /* @__PURE__ */ a("span", { className: "font-mono", children: t.unknownTokens.join(", ") })
350
+ ] }),
351
+ (t == null ? void 0 : t.ok) && !t.unknownTokens.length && n.length > 0 && /* @__PURE__ */ h("p", { "data-formula-offform": "", className: D, children: [
352
+ "Not on this form, so they read as empty here:",
353
+ " ",
354
+ /* @__PURE__ */ a("span", { className: "font-mono", children: n.join(", ") })
355
+ ] })
356
+ ]
357
+ }
358
+ ),
359
+ /* @__PURE__ */ a(p, { k: "display_formula.format", label: "Show as", effect: "How the number is written.", children: /* @__PURE__ */ a(
360
+ k,
361
+ {
362
+ value: l.format,
363
+ options: B,
364
+ onChange: (e) => u({ display_formula: { ...l, format: e } }, "Change how the formula shows")
365
+ }
366
+ ) }),
367
+ l.format === "currency" && /* @__PURE__ */ a(
368
+ p,
369
+ {
370
+ k: "display_formula.currency",
371
+ label: "Currency",
372
+ effect: "Three-letter code, for example USD.",
373
+ children: /* @__PURE__ */ a(
374
+ E,
375
+ {
376
+ ariaLabel: "Currency",
377
+ value: l.currency ?? "",
378
+ mono: !0,
379
+ placeholder: "USD",
380
+ onCommit: (e) => {
381
+ const m = e.trim().toUpperCase();
382
+ m && !/^[A-Z]{3}$/.test(m) || u(
383
+ { display_formula: { ...l, currency: m || null } },
384
+ "Change the currency of the formula",
385
+ !0
386
+ );
387
+ }
388
+ }
389
+ )
390
+ }
391
+ )
392
+ ] });
393
+ }
394
+ export {
395
+ se as ConfirmChangeSetting,
396
+ le as CounterSetting,
397
+ de as DisplayFormulaSettings,
398
+ ie as RecommendedToggle,
399
+ ce as RepeatLastToggle,
400
+ re as TextRulesSetting,
401
+ z as takesText
402
+ };