@nivaro/react 0.2.52 → 0.2.54

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 (191) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +116 -2
  4. package/dist/layout-editor.d.ts +248 -2
  5. package/dist/shared/components/FormWhatsNew.js +60 -0
  6. package/dist/shared/components/ItemEditForm.js +3994 -3876
  7. package/dist/shared/components/RecordReadView.js +219 -211
  8. package/dist/shared/components/TipLayer.js +27 -27
  9. package/dist/shared/components/help-videos/api.js +51 -41
  10. package/dist/shared/components/help-videos/editor/DetailsTab.js +147 -130
  11. package/dist/shared/components/item-edit/FieldAffordances.js +7 -6
  12. package/dist/shared/components/item-edit/FieldRow.js +353 -304
  13. package/dist/shared/components/item-edit/FormHelpVideoButton.js +59 -0
  14. package/dist/shared/components/item-edit/GroupSection.js +419 -396
  15. package/dist/shared/components/item-edit/HeaderTools.js +59 -56
  16. package/dist/shared/components/item-edit/LayoutContentBlock.js +47 -24
  17. package/dist/shared/components/item-edit/lock-why.js +87 -0
  18. package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -0
  19. package/dist/shared/components/layout-editor/AddPanel.js +204 -146
  20. package/dist/shared/components/layout-editor/ArrangeButton.js +34 -0
  21. package/dist/shared/components/layout-editor/AutoArrange.js +86 -0
  22. package/dist/shared/components/layout-editor/CanvasCompare.js +79 -0
  23. package/dist/shared/components/layout-editor/ChangeNote.js +146 -0
  24. package/dist/shared/components/layout-editor/CollabParts.js +170 -0
  25. package/dist/shared/components/layout-editor/DesignNode.js +304 -115
  26. package/dist/shared/components/layout-editor/EditorCanvas.js +21 -20
  27. package/dist/shared/components/layout-editor/EditorTopBar.js +452 -175
  28. package/dist/shared/components/layout-editor/FindReplace.js +188 -0
  29. package/dist/shared/components/layout-editor/FormMapButton.js +141 -0
  30. package/dist/shared/components/layout-editor/HistoryPanel.js +234 -109
  31. package/dist/shared/components/layout-editor/LayoutEditor.js +1101 -307
  32. package/dist/shared/components/layout-editor/LayoutsRail.js +94 -67
  33. package/dist/shared/components/layout-editor/NoteMarker.js +38 -0
  34. package/dist/shared/components/layout-editor/PlacementsTable.js +187 -0
  35. package/dist/shared/components/layout-editor/ScheduleChange.js +106 -0
  36. package/dist/shared/components/layout-editor/SessionHistory.js +84 -0
  37. package/dist/shared/components/layout-editor/StructureMenu.js +413 -0
  38. package/dist/shared/components/layout-editor/UnsavedConfirm.js +103 -0
  39. package/dist/shared/components/layout-editor/ai/AiToolsButton.js +625 -0
  40. package/dist/shared/components/layout-editor/ai/ChangeCheck.js +153 -0
  41. package/dist/shared/components/layout-editor/ai/ai-tools-api.js +80 -0
  42. package/dist/shared/components/layout-editor/ai/assist-ops.js +38 -0
  43. package/dist/shared/components/layout-editor/ai/autofill-ops.js +73 -0
  44. package/dist/shared/components/layout-editor/ai/canvas-capture.js +41 -0
  45. package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +271 -0
  46. package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +182 -0
  47. package/dist/shared/components/layout-editor/ai-forms/MeaningSuggestions.js +109 -0
  48. package/dist/shared/components/layout-editor/ai-forms/SlimPanel.js +170 -0
  49. package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +40 -0
  50. package/dist/shared/components/layout-editor/ai-forms/pending.js +25 -0
  51. package/dist/shared/components/layout-editor/ai-forms/plan.js +263 -0
  52. package/dist/shared/components/layout-editor/ai-rules/AiAskPopover.js +160 -0
  53. package/dist/shared/components/layout-editor/ai-rules/CascadeWriter.js +175 -0
  54. package/dist/shared/components/layout-editor/ai-rules/FieldRuleWriter.js +97 -0
  55. package/dist/shared/components/layout-editor/ai-rules/RuleWriter.js +94 -0
  56. package/dist/shared/components/layout-editor/ai-rules/ValidationSuggest.js +153 -0
  57. package/dist/shared/components/layout-editor/ai-rules/api.js +6 -0
  58. package/dist/shared/components/layout-editor/ai-text/AiTextTools.js +383 -0
  59. package/dist/shared/components/layout-editor/ai-text/text-ops.js +125 -0
  60. package/dist/shared/components/layout-editor/assist/AskPanel.js +278 -0
  61. package/dist/shared/components/layout-editor/assist/ExplainDiff.js +93 -0
  62. package/dist/shared/components/layout-editor/assist/ProposalsButton.js +150 -0
  63. package/dist/shared/components/layout-editor/assist/assist-api.js +63 -0
  64. package/dist/shared/components/layout-editor/assist/jump.js +142 -0
  65. package/dist/shared/components/layout-editor/assist/settings-index.js +118 -0
  66. package/dist/shared/components/layout-editor/auto-arrange.js +101 -0
  67. package/dist/shared/components/layout-editor/bulk/BulkChangesButton.js +221 -0
  68. package/dist/shared/components/layout-editor/bulk/BulkRun.js +237 -0
  69. package/dist/shared/components/layout-editor/bulk/MacrosPanel.js +230 -0
  70. package/dist/shared/components/layout-editor/bulk/bulk-api.js +65 -0
  71. package/dist/shared/components/layout-editor/bulk/field-labels.js +22 -0
  72. package/dist/shared/components/layout-editor/bulk/macro-record.js +142 -0
  73. package/dist/shared/components/layout-editor/bulk/useMacroRecorder.js +65 -0
  74. package/dist/shared/components/layout-editor/bundle-to-active.js +1 -0
  75. package/dist/shared/components/layout-editor/canvas-diff.js +157 -0
  76. package/dist/shared/components/layout-editor/collab/FormFollowShare.js +342 -0
  77. package/dist/shared/components/layout-editor/collab/collab-api.js +77 -0
  78. package/dist/shared/components/layout-editor/commands/CommandPalette.js +221 -0
  79. package/dist/shared/components/layout-editor/commands/intents.js +214 -0
  80. package/dist/shared/components/layout-editor/commands/parse.js +242 -0
  81. package/dist/shared/components/layout-editor/design-context.js +26 -6
  82. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +179 -163
  83. package/dist/shared/components/layout-editor/dnd/collision.js +25 -23
  84. package/dist/shared/components/layout-editor/dnd/rail-drop.js +56 -0
  85. package/dist/shared/components/layout-editor/draft-recovery.js +61 -0
  86. package/dist/shared/components/layout-editor/editor-notes.js +78 -0
  87. package/dist/shared/components/layout-editor/editors/swap-config.js +1 -0
  88. package/dist/shared/components/layout-editor/explain/CanvasRules.js +142 -0
  89. package/dist/shared/components/layout-editor/explain/default-ghosts.js +81 -0
  90. package/dist/shared/components/layout-editor/explain/driver-hover.js +62 -0
  91. package/dist/shared/components/layout-editor/explain/field-sources.js +246 -0
  92. package/dist/shared/components/layout-editor/explain/rule-graph.js +215 -0
  93. package/dist/shared/components/layout-editor/explain/use-explain.js +132 -0
  94. package/dist/shared/components/layout-editor/field-zones.js +116 -0
  95. package/dist/shared/components/layout-editor/form-map.js +138 -0
  96. package/dist/shared/components/layout-editor/history-api.js +87 -0
  97. package/dist/shared/components/layout-editor/inheritance.js +55 -0
  98. package/dist/shared/components/layout-editor/inspect/inspect-api.js +66 -0
  99. package/dist/shared/components/layout-editor/inspect/picker-preview.js +48 -0
  100. package/dist/shared/components/layout-editor/inspect/width-fit.js +87 -0
  101. package/dist/shared/components/layout-editor/inspector/AiFillSetting.js +85 -0
  102. package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +36 -0
  103. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +175 -0
  104. package/dist/shared/components/layout-editor/inspector/ColumnFit.js +112 -0
  105. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +146 -92
  106. package/dist/shared/components/layout-editor/inspector/HelpTab.js +174 -0
  107. package/dist/shared/components/layout-editor/inspector/Inspector.js +256 -175
  108. package/dist/shared/components/layout-editor/inspector/LookTab.js +46 -40
  109. package/dist/shared/components/layout-editor/inspector/OverrideNotice.js +61 -0
  110. package/dist/shared/components/layout-editor/inspector/PickerPreview.js +134 -0
  111. package/dist/shared/components/layout-editor/inspector/PickerTab.js +167 -141
  112. package/dist/shared/components/layout-editor/inspector/RulesTab.js +175 -128
  113. package/dist/shared/components/layout-editor/inspector/Translations.js +156 -0
  114. package/dist/shared/components/layout-editor/inspector/kit.js +3 -3
  115. package/dist/shared/components/layout-editor/inspector/tab-request.js +21 -0
  116. package/dist/shared/components/layout-editor/is-typing.js +9 -0
  117. package/dist/shared/components/layout-editor/keyboard-move.js +66 -0
  118. package/dist/shared/components/layout-editor/lint/LintPanel.js +190 -0
  119. package/dist/shared/components/layout-editor/lint/lint-api.js +52 -0
  120. package/dist/shared/components/layout-editor/load-error.js +37 -0
  121. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +305 -0
  122. package/dist/shared/components/layout-editor/matrix/MatrixGrid.js +181 -0
  123. package/dist/shared/components/layout-editor/matrix/RoleSectionMatrix.js +147 -0
  124. package/dist/shared/components/layout-editor/matrix/matrix-api.js +48 -0
  125. package/dist/shared/components/layout-editor/matrix/role-matrix.js +36 -0
  126. package/dist/shared/components/layout-editor/matrix/state-matrix.js +145 -0
  127. package/dist/shared/components/layout-editor/nav/FindPanel.js +109 -0
  128. package/dist/shared/components/layout-editor/nav/NavTools.js +114 -0
  129. package/dist/shared/components/layout-editor/nav/OutlinePanel.js +228 -0
  130. package/dist/shared/components/layout-editor/nav/ShortcutSheet.js +31 -0
  131. package/dist/shared/components/layout-editor/nav/find.js +20 -0
  132. package/dist/shared/components/layout-editor/nav/tree.js +142 -0
  133. package/dist/shared/components/layout-editor/nav/useEditorNav.js +101 -0
  134. package/dist/shared/components/layout-editor/nav/view-prefs.js +34 -0
  135. package/dist/shared/components/layout-editor/ops/ChangeRequestsPanel.js +143 -0
  136. package/dist/shared/components/layout-editor/ops/DependencyDiagram.js +179 -0
  137. package/dist/shared/components/layout-editor/ops/LayoutOpsBlocks.js +92 -0
  138. package/dist/shared/components/layout-editor/ops/PromotePanel.js +287 -0
  139. package/dist/shared/components/layout-editor/ops/ops-api.js +122 -0
  140. package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -3
  141. package/dist/shared/components/layout-editor/overview/describe-conditions.js +18 -14
  142. package/dist/shared/components/layout-editor/overview/overview-api.js +105 -88
  143. package/dist/shared/components/layout-editor/panel-style.js +8 -7
  144. package/dist/shared/components/layout-editor/parity-keys.json.js +4 -0
  145. package/dist/shared/components/layout-editor/pin.js +25 -0
  146. package/dist/shared/components/layout-editor/presence.js +111 -0
  147. package/dist/shared/components/layout-editor/preview/PreviewModes.js +224 -0
  148. package/dist/shared/components/layout-editor/preview/PreviewPanes.js +262 -0
  149. package/dist/shared/components/layout-editor/preview/preview-api.js +57 -0
  150. package/dist/shared/components/layout-editor/preview/preview-model.js +157 -0
  151. package/dist/shared/components/layout-editor/reuse/FieldMapStep.js +70 -0
  152. package/dist/shared/components/layout-editor/reuse/FormMoreMenu.js +127 -0
  153. package/dist/shared/components/layout-editor/reuse/LibraryRows.js +150 -0
  154. package/dist/shared/components/layout-editor/reuse/NewFormStart.js +20 -0
  155. package/dist/shared/components/layout-editor/reuse/SectionReuseActions.js +291 -0
  156. package/dist/shared/components/layout-editor/reuse/field-match.js +77 -0
  157. package/dist/shared/components/layout-editor/reuse/reuse-api.js +73 -0
  158. package/dist/shared/components/layout-editor/reuse/seed.js +13 -0
  159. package/dist/shared/components/layout-editor/reuse/useFormFromRecord.js +43 -0
  160. package/dist/shared/components/layout-editor/reuse/useRailCopy.js +34 -0
  161. package/dist/shared/components/layout-editor/settings/FormSettings.js +123 -103
  162. package/dist/shared/components/layout-editor/settings/InheritanceSection.js +1 -1
  163. package/dist/shared/components/layout-editor/settings/ToolsSection.js +174 -100
  164. package/dist/shared/components/layout-editor/settings/WhoSection.js +136 -100
  165. package/dist/shared/components/layout-editor/settings/controls.js +8 -8
  166. package/dist/shared/components/layout-editor/settings/settings-registry.js +35 -11
  167. package/dist/shared/components/layout-editor/shortcuts.js +88 -0
  168. package/dist/shared/components/layout-editor/show-when.js +35 -0
  169. package/dist/shared/components/layout-editor/slot-names.js +4 -3
  170. package/dist/shared/components/layout-editor/structure-ops.js +399 -0
  171. package/dist/shared/components/layout-editor/testing/CostLimitSetting.js +42 -0
  172. package/dist/shared/components/layout-editor/testing/TestingPanels.js +551 -0
  173. package/dist/shared/components/layout-editor/testing/testing-api.js +67 -0
  174. package/dist/shared/components/layout-editor/testing/testing-model.js +393 -0
  175. package/dist/shared/components/layout-editor/testing/use-record-check.js +44 -0
  176. package/dist/shared/components/layout-editor/toolbar-kit.js +242 -0
  177. package/dist/shared/components/layout-editor/unsaved-marks.js +72 -0
  178. package/dist/shared/components/layout-editor/usage/FillChip.js +27 -0
  179. package/dist/shared/components/layout-editor/usage/UsagePanel.js +158 -0
  180. package/dist/shared/components/layout-editor/usage/suggest-sections.js +55 -0
  181. package/dist/shared/components/layout-editor/usage/usage-api.js +104 -0
  182. package/dist/shared/components/layout-editor/useLayoutDraft.js +573 -307
  183. package/dist/shared/components/support/SuggestFormChange.js +143 -0
  184. package/dist/shared/lib/ai-fill.js +37 -0
  185. package/dist/shared/lib/form-usage-beacon.js +84 -0
  186. package/dist/shared/lib/layout-i18n.js +66 -0
  187. package/dist/shared/lib/layout-lint.js +490 -0
  188. package/dist/shared/lib/layout-ops.js +110 -106
  189. package/dist/shared/lib/screenshot.js +54 -28
  190. package/dist/shared/lib/visible-when.js +34 -0
  191. package/package.json +1 -1
@@ -1,16 +1,20 @@
1
- import { jsxs as p, jsx as t } from "react/jsx-runtime";
2
- import { useQuery as K } from "@tanstack/react-query";
3
- import { X as L } from "lucide-react";
4
- import { useNivaroClient as P } from "../../../context.js";
5
- import { get as q } from "../../../lib/commands.js";
6
- import { cn as F, titleCase as I } from "../../../lib/utils.js";
7
- import { FieldDefaultValueControl as j } from "../editors/field-default-value.js";
8
- import { RoleConditionRow as B, PipelineStateConditionRow as V } from "../editors/lock-conditions.js";
9
- import { tintCard as D } from "../panel-style.js";
10
- import { useFieldCtx as E } from "./field-context.js";
11
- import { Toggle as m, Setting as f, Segmented as G, AddButton as Q, Section as O, TextInput as A, Choice as N } from "./kit.js";
12
- import { lockConditionsOf as W, layoutGrids as H, asObject as X, defaultValuesOf as z, withDefaultValue as J, lockConditionsColumn as U } from "./model.js";
13
- const Y = /* @__PURE__ */ new Set([
1
+ import { jsxs as c, jsx as l } from "react/jsx-runtime";
2
+ import { useQuery as j } from "@tanstack/react-query";
3
+ import { X as B } from "lucide-react";
4
+ import { useNivaroClient as E } from "../../../context.js";
5
+ import { get as W } from "../../../lib/commands.js";
6
+ import { cn as D, titleCase as G } from "../../../lib/utils.js";
7
+ import { FieldRuleWriter as Q } from "../ai-rules/FieldRuleWriter.js";
8
+ import { RuleWriter as H } from "../ai-rules/RuleWriter.js";
9
+ import { ValidationSuggest as X } from "../ai-rules/ValidationSuggest.js";
10
+ import { FieldDefaultValueControl as z } from "../editors/field-default-value.js";
11
+ import { RoleConditionRow as J, PipelineStateConditionRow as U } from "../editors/lock-conditions.js";
12
+ import { useLayoutEditorHost as Y } from "../host.js";
13
+ import { tintCard as Z } from "../panel-style.js";
14
+ import { useFieldCtx as ee } from "./field-context.js";
15
+ import { Toggle as v, Setting as f, Segmented as le, AddButton as te, Section as R, TextInput as S, Choice as T } from "./kit.js";
16
+ import { lockConditionsOf as ie, layoutGrids as oe, asObject as ae, defaultValuesOf as ne, withDefaultValue as re, lockConditionsColumn as de } from "./model.js";
17
+ const L = /* @__PURE__ */ new Set([
14
18
  "inline-table",
15
19
  "inline-grid",
16
20
  "list-o2m",
@@ -20,279 +24,322 @@ const Y = /* @__PURE__ */ new Set([
20
24
  "o2m",
21
25
  "relation-path"
22
26
  ]);
23
- function Z(a, i) {
24
- const d = P();
25
- return K({
27
+ function se(a, i) {
28
+ const u = E();
29
+ return j({
26
30
  queryKey: ["layout-editor", "field-rows", a, i ?? null],
27
- queryFn: () => d.request(
28
- q(`/field-config/${a}`, i ? { layout_id: i } : void 0)
29
- ).then((s) => Array.isArray(s.data) ? s.data : []),
31
+ queryFn: () => u.request(
32
+ W(`/field-config/${a}`, i ? { layout_id: i } : void 0)
33
+ ).then((m) => Array.isArray(m.data) ? m.data : []),
30
34
  enabled: !!a,
31
35
  staleTime: 6e4
32
36
  });
33
37
  }
34
- function pe() {
35
- const a = E(), { info: i, ov: d, opts: s, env: c, row: y } = a, l = i.label, w = c.bundle.layout, x = y.field.startsWith("__") || i.isPath, h = W(y), b = (e, o) => a.setPlacement({ lock_conditions: U(e) }, o), _ = (e, o, n) => b(
36
- h.map((u, C) => C === e ? { ...u, ...o } : u),
38
+ function Me() {
39
+ const a = ee(), { info: i, ov: u, opts: m, env: s, row: p } = a, o = i.label, y = s.bundle.layout, g = p.field.startsWith("__") || i.isPath, b = ie(p), _ = (e, t) => a.setPlacement({ lock_conditions: de(e) }, t), w = (e, t, n) => _(
40
+ b.map((d, h) => h === e ? { ...d, ...t } : d),
37
41
  n
38
- ), g = H(c.bundle, a.globals, a.relations), $ = !x && i.relKind !== "M2M" && i.relKind !== "O2M" && !Y.has(i.iface ?? "") && g.length > 0, r = X(d.apply_to_lines), v = g.find((e) => e.field === r.grid) ?? null, { data: R = [] } = Z($ ? v == null ? void 0 : v.childCollection : null), S = R.filter(
42
+ ), x = oe(s.bundle, a.globals, a.relations), M = !g && i.relKind !== "M2M" && i.relKind !== "O2M" && !L.has(i.iface ?? "") && x.length > 0, r = ae(u.apply_to_lines), $ = x.find((e) => e.field === r.grid) ?? null, { data: K = [] } = se(M ? $ == null ? void 0 : $.childCollection : null), P = K.filter(
39
43
  (e) => e.field !== "id" && !e.field.startsWith("__") && !e.field.includes(".") && !["alias", "o2m", "m2m"].includes(e.type ?? "")
40
- ), M = (e, o) => a.setOverride("apply_to_lines", e ?? void 0, o), T = z(w), k = typeof s.max_values == "number" ? s.max_values : null;
41
- return /* @__PURE__ */ p("div", { className: "space-y-5", children: [
42
- /* @__PURE__ */ t(
43
- m,
44
+ ), N = (e, t) => a.setOverride("apply_to_lines", e ?? void 0, t), I = Y().isAdmin && !g && !i.relKind && !L.has(i.iface ?? "") && i.type !== "alias" && i.computedType !== "virtual", q = ne(y), A = typeof m.max_values == "number" ? m.max_values : null;
45
+ return /* @__PURE__ */ c("div", { className: "space-y-5", children: [
46
+ /* @__PURE__ */ l(
47
+ v,
44
48
  {
45
49
  k: "field.required",
46
50
  label: "Required",
47
51
  effect: "The form will not save without a value.",
48
- checked: d.required === !0,
52
+ checked: u.required === !0,
49
53
  onChange: (e) => a.setOverride(
50
54
  "required",
51
55
  e ? !0 : void 0,
52
- e ? `Make ${l} required` : `Make ${l} optional`
56
+ e ? `Make ${o} required` : `Make ${o} optional`
53
57
  )
54
58
  }
55
59
  ),
56
- /* @__PURE__ */ t(
57
- m,
60
+ /* @__PURE__ */ l(
61
+ v,
58
62
  {
59
63
  k: "field.readonly",
60
64
  label: "Read-only",
61
65
  effect: "Shown but not editable on this form.",
62
- checked: d.readonly === !0,
66
+ checked: u.readonly === !0,
63
67
  onChange: (e) => a.setOverride(
64
68
  "readonly",
65
69
  e ? !0 : void 0,
66
- e ? `Make ${l} read-only` : `Make ${l} editable`
70
+ e ? `Make ${o} read-only` : `Make ${o} editable`
67
71
  )
68
72
  }
69
73
  ),
70
- (i.computedType === "rollup" || i.computedType === "write") && /* @__PURE__ */ t(
71
- m,
74
+ (i.computedType === "rollup" || i.computedType === "write") && /* @__PURE__ */ l(
75
+ v,
72
76
  {
73
77
  k: "field.editable_computed",
74
78
  label: "Allow manual entry",
75
79
  effect: "Lets people type over the calculated value here; the next recalculation still overwrites it.",
76
- checked: d.editable_computed === !0,
80
+ checked: u.editable_computed === !0,
77
81
  onChange: (e) => a.setOverride(
78
82
  "editable_computed",
79
83
  e ? !0 : void 0,
80
- e ? `Allow typing into ${l}` : `Keep ${l} calculated only`
84
+ e ? `Allow typing into ${o}` : `Keep ${o} calculated only`
81
85
  )
82
86
  }
83
87
  ),
84
- /* @__PURE__ */ t(
88
+ /* @__PURE__ */ l(
85
89
  f,
86
90
  {
87
91
  k: "field.lock_conditions",
88
92
  label: "Read-only when",
89
93
  effect: "Locks the field while any of these holds. No conditions: always editable.",
90
- children: /* @__PURE__ */ p("div", { className: "space-y-2", children: [
91
- h.map((e, o) => /* @__PURE__ */ p(
94
+ children: /* @__PURE__ */ c("div", { className: "space-y-2", children: [
95
+ b.map((e, t) => /* @__PURE__ */ c(
92
96
  "div",
93
97
  {
94
- className: F(D, "space-y-3 p-3"),
98
+ className: D(Z, "space-y-3 p-3"),
95
99
  children: [
96
- /* @__PURE__ */ p("div", { className: "flex items-center gap-1.5", children: [
97
- /* @__PURE__ */ t("div", { className: "flex-1", "data-setting": "field.lock_conditions.type", children: /* @__PURE__ */ t(
98
- G,
100
+ /* @__PURE__ */ c("div", { className: "flex items-center gap-1.5", children: [
101
+ /* @__PURE__ */ l("div", { className: "flex-1", "data-setting": "field.lock_conditions.type", children: /* @__PURE__ */ l(
102
+ le,
99
103
  {
100
104
  value: e.type,
101
105
  options: [
102
106
  { value: "pipeline_state", label: "Pipeline state" },
103
107
  { value: "role", label: "Role" }
104
108
  ],
105
- onChange: (n) => b(
106
- h.map(
107
- (u, C) => C === o ? n === "role" ? { type: "role", role_ids: [] } : { type: "pipeline_state", state_keys: [] } : u
109
+ onChange: (n) => _(
110
+ b.map(
111
+ (d, h) => h === t ? n === "role" ? { type: "role", role_ids: [] } : { type: "pipeline_state", state_keys: [] } : d
108
112
  ),
109
- `Change a lock condition of ${l}`
113
+ `Change a lock condition of ${o}`
110
114
  )
111
115
  }
112
116
  ) }),
113
- /* @__PURE__ */ t(
117
+ /* @__PURE__ */ l(
114
118
  "button",
115
119
  {
116
120
  type: "button",
117
121
  "aria-label": "Remove condition",
118
- onClick: () => b(
119
- h.filter((n, u) => u !== o),
120
- `Remove a lock condition from ${l}`
122
+ onClick: () => _(
123
+ b.filter((n, d) => d !== t),
124
+ `Remove a lock condition from ${o}`
121
125
  ),
122
126
  "data-tip": "Remove condition",
123
127
  className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-slate-500 transition-colors hover:bg-slate-100 hover:text-red-600 dark:hover:bg-muted dark:hover:text-red-400",
124
- children: /* @__PURE__ */ t(L, { className: "h-3.5 w-3.5" })
128
+ children: /* @__PURE__ */ l(B, { className: "h-3.5 w-3.5" })
125
129
  }
126
130
  )
127
131
  ] }),
128
- e.type === "role" ? /* @__PURE__ */ t("div", { "data-setting": "field.lock_conditions.role_ids", children: /* @__PURE__ */ t(
129
- B,
132
+ e.type === "role" ? /* @__PURE__ */ l("div", { "data-setting": "field.lock_conditions.role_ids", children: /* @__PURE__ */ l(
133
+ J,
130
134
  {
131
135
  roleIds: e.role_ids ?? [],
132
- onRoleIdsChange: (n) => _(o, { role_ids: n }, `Change the roles that lock ${l}`)
136
+ onRoleIdsChange: (n) => w(t, { role_ids: n }, `Change the roles that lock ${o}`)
133
137
  }
134
- ) }) : /* @__PURE__ */ t(
135
- V,
138
+ ) }) : /* @__PURE__ */ l(
139
+ U,
136
140
  {
137
- collection: c.collection,
141
+ collection: s.collection,
138
142
  pipelineId: e.pipeline_id,
139
143
  stateKeys: e.state_keys ?? [],
140
- onPipelineChange: (n) => _(
141
- o,
144
+ onPipelineChange: (n) => w(
145
+ t,
142
146
  { pipeline_id: n, state_keys: [] },
143
- `Change the pipeline that locks ${l}`
147
+ `Change the pipeline that locks ${o}`
144
148
  ),
145
- onStateKeysChange: (n) => _(o, { state_keys: n }, `Change the states that lock ${l}`)
149
+ onStateKeysChange: (n) => w(t, { state_keys: n }, `Change the states that lock ${o}`)
146
150
  }
147
151
  )
148
152
  ]
149
153
  },
150
- o
154
+ t
151
155
  )),
152
- /* @__PURE__ */ t(
153
- Q,
154
- {
155
- onClick: () => b(
156
- [...h, { type: "pipeline_state", state_keys: [] }],
157
- `Add a lock condition to ${l}`
158
- ),
159
- children: "+ Add condition"
160
- }
161
- )
156
+ /* @__PURE__ */ c("div", { className: "flex flex-wrap items-center gap-1.5", children: [
157
+ /* @__PURE__ */ l(
158
+ te,
159
+ {
160
+ onClick: () => _(
161
+ [...b, { type: "pipeline_state", state_keys: [] }],
162
+ `Add a lock condition to ${o}`
163
+ ),
164
+ children: "+ Add condition"
165
+ }
166
+ ),
167
+ !g && /* @__PURE__ */ l(
168
+ H,
169
+ {
170
+ layoutId: Number(y.id),
171
+ target: { kind: "lock", field: p.field },
172
+ bundle: s.bundle,
173
+ apply: (e, t) => s.apply(e, t),
174
+ disabled: a.readOnly
175
+ }
176
+ )
177
+ ] })
162
178
  ] })
163
179
  }
164
180
  ),
165
- !x && i.relKind !== "O2M" && /* @__PURE__ */ t(
181
+ !g && i.relKind !== "O2M" && /* @__PURE__ */ c(
166
182
  f,
167
183
  {
168
184
  k: "field.default_value",
169
185
  label: "Default for new records",
170
186
  effect: "Filled in when someone creates a record on this form.",
171
- children: /* @__PURE__ */ t("div", { onBlurCapture: () => c.flush(), children: /* @__PURE__ */ t(
172
- j,
187
+ children: [
188
+ /* @__PURE__ */ l("div", { onBlurCapture: () => s.flush(), children: /* @__PURE__ */ l(
189
+ z,
190
+ {
191
+ value: q[p.field],
192
+ onChange: (e, t) => s.apply(
193
+ [
194
+ {
195
+ op: "layout_update",
196
+ patch: { default_values: re(y, p.field, e) }
197
+ }
198
+ ],
199
+ { label: `Change the default of ${o}`, text: t }
200
+ ),
201
+ isM2O: i.relKind === "M2O",
202
+ isM2M: i.relKind === "M2M",
203
+ relatedCollection: i.relatedCollection,
204
+ settings: { options: a.globalOptions, interface: i.iface },
205
+ abstractType: i.type
206
+ }
207
+ ) }),
208
+ /* @__PURE__ */ l("div", { className: "pt-1", children: /* @__PURE__ */ l(
209
+ Q,
210
+ {
211
+ layoutId: Number(y.id),
212
+ field: p.field,
213
+ disabled: a.readOnly
214
+ }
215
+ ) })
216
+ ]
217
+ }
218
+ ),
219
+ I && /* @__PURE__ */ l(
220
+ f,
221
+ {
222
+ k: "field.validation_rules",
223
+ label: "Checks",
224
+ scope: "field",
225
+ effect: "Learned from the values stored today, each with how many existing values it would refuse.",
226
+ children: /* @__PURE__ */ l(
227
+ X,
173
228
  {
174
- value: T[y.field],
175
- onChange: (e, o) => c.apply(
176
- [
177
- {
178
- op: "layout_update",
179
- patch: { default_values: J(w, y.field, e) }
180
- }
181
- ],
182
- { label: `Change the default of ${l}`, text: o }
183
- ),
184
- isM2O: i.relKind === "M2O",
185
- isM2M: i.relKind === "M2M",
186
- relatedCollection: i.relatedCollection,
187
- settings: { options: a.globalOptions, interface: i.iface },
188
- abstractType: i.type
229
+ layoutId: Number(y.id),
230
+ field: p.field,
231
+ disabled: a.readOnly,
232
+ onApply: (e, t, n) => a.proposeGlobal("field.validation_rules", e.length, n, (d) => {
233
+ const h = d.columns.validation_rules, O = Array.isArray(h) ? h : t, F = (k, C) => k.type === C.type && String(k.value ?? "") === String(C.value ?? ""), V = e.filter((k) => !O.some((C) => F(C, k)));
234
+ return { ...d, columns: { ...d.columns, validation_rules: [...O, ...V] } };
235
+ })
189
236
  }
190
- ) })
237
+ )
191
238
  }
192
239
  ),
193
- i.relKind === "M2M" && /* @__PURE__ */ p(O, { title: "How many", children: [
194
- /* @__PURE__ */ t(
240
+ i.relKind === "M2M" && /* @__PURE__ */ c(R, { title: "How many", children: [
241
+ /* @__PURE__ */ l(
195
242
  f,
196
243
  {
197
244
  k: "field.max_values",
198
245
  label: "Most values",
199
246
  effect: "Empty: no limit. 1 makes it a single pick.",
200
- children: /* @__PURE__ */ t(
201
- A,
247
+ children: /* @__PURE__ */ l(
248
+ S,
202
249
  {
203
250
  type: "number",
204
251
  ariaLabel: "Most values",
205
- value: k == null ? "" : String(k),
252
+ value: A == null ? "" : String(A),
206
253
  placeholder: "No limit",
207
254
  onChange: (e) => {
208
- const o = e === "" ? void 0 : Math.max(1, Math.round(Number(e)));
209
- o !== void 0 && Number.isNaN(o) || a.setOption("max_values", o, `Limit how many ${l} can be picked`, !0);
255
+ const t = e === "" ? void 0 : Math.max(1, Math.round(Number(e)));
256
+ t !== void 0 && Number.isNaN(t) || a.setOption("max_values", t, `Limit how many ${o} can be picked`, !0);
210
257
  }
211
258
  }
212
259
  )
213
260
  }
214
261
  ),
215
- k != null && /* @__PURE__ */ t(
216
- m,
262
+ A != null && /* @__PURE__ */ l(
263
+ v,
217
264
  {
218
265
  k: "field.max_values_enforce_on_write",
219
266
  label: "Refuse more on the server too",
220
267
  effect: "Imports, the API and other forms cannot store more than the limit.",
221
268
  enforced: !0,
222
- checked: s.enforce_on_write === !0,
269
+ checked: m.enforce_on_write === !0,
223
270
  onChange: (e) => a.setOption(
224
271
  "enforce_on_write",
225
272
  e ? !0 : void 0,
226
- e ? `Enforce the limit of ${l} on the server` : `Stop enforcing the limit of ${l}`
273
+ e ? `Enforce the limit of ${o} on the server` : `Stop enforcing the limit of ${o}`
227
274
  )
228
275
  }
229
276
  )
230
277
  ] }),
231
- $ && /* @__PURE__ */ p(O, { title: "Apply to lines", children: [
232
- /* @__PURE__ */ t("p", { className: "text-[12px] leading-snug text-slate-500 dark:text-muted-foreground", children: "A button beside the field copies its value into one column of every line of a grid." }),
233
- /* @__PURE__ */ t(
278
+ M && /* @__PURE__ */ c(R, { title: "Apply to lines", children: [
279
+ /* @__PURE__ */ l("p", { className: "text-[12px] leading-snug text-slate-500 dark:text-muted-foreground", children: "A button beside the field copies its value into one column of every line of a grid." }),
280
+ /* @__PURE__ */ l(
234
281
  f,
235
282
  {
236
283
  k: "field.apply_to_lines.grid",
237
284
  label: "Grid",
238
285
  effect: "The grid whose lines get the value.",
239
- children: /* @__PURE__ */ t(
240
- N,
286
+ children: /* @__PURE__ */ l(
287
+ T,
241
288
  {
242
289
  ariaLabel: "Grid",
243
290
  value: r.grid ?? "",
244
291
  options: [
245
292
  { value: "", label: "Off" },
246
- ...g.map((e) => ({ value: e.field, label: e.label }))
293
+ ...x.map((e) => ({ value: e.field, label: e.label }))
247
294
  ],
248
- onChange: (e) => M(
295
+ onChange: (e) => N(
249
296
  e ? { grid: e, target: "", ...r.label ? { label: r.label } : {} } : null,
250
- e ? `Copy ${l} into lines` : `Stop copying ${l} into lines`
297
+ e ? `Copy ${o} into lines` : `Stop copying ${o} into lines`
251
298
  )
252
299
  }
253
300
  )
254
301
  }
255
302
  ),
256
- /* @__PURE__ */ t(
303
+ /* @__PURE__ */ l(
257
304
  f,
258
305
  {
259
306
  k: "field.apply_to_lines.target",
260
307
  label: "Column",
261
308
  effect: "The column of each line that receives the value.",
262
- children: /* @__PURE__ */ t(
263
- N,
309
+ children: /* @__PURE__ */ l(
310
+ T,
264
311
  {
265
312
  ariaLabel: "Column",
266
313
  disabled: !r.grid,
267
314
  value: r.target ?? "",
268
315
  options: [
269
316
  { value: "", label: r.grid ? "Pick a column…" : "Pick a grid first" },
270
- ...S.map((e) => ({ value: e.field, label: e.label || I(e.field) }))
317
+ ...P.map((e) => ({ value: e.field, label: e.label || G(e.field) }))
271
318
  ],
272
- onChange: (e) => M({ ...r, target: e }, `Copy ${l} into a column`)
319
+ onChange: (e) => N({ ...r, target: e }, `Copy ${o} into a column`)
273
320
  }
274
321
  )
275
322
  }
276
323
  ),
277
- /* @__PURE__ */ t(
324
+ /* @__PURE__ */ l(
278
325
  f,
279
326
  {
280
327
  k: "field.apply_to_lines.label",
281
328
  label: "Button label",
282
329
  effect: "The words on the button.",
283
- children: /* @__PURE__ */ t(
284
- A,
330
+ children: /* @__PURE__ */ l(
331
+ S,
285
332
  {
286
333
  ariaLabel: "Button label",
287
334
  disabled: !r.grid,
288
335
  value: r.label ?? "",
289
336
  placeholder: "Apply to lines",
290
337
  onChange: (e) => {
291
- const { label: o, ...n } = r;
338
+ const { label: t, ...n } = r;
292
339
  a.setOverride(
293
340
  "apply_to_lines",
294
341
  e ? { ...n, label: e } : n,
295
- `Rename the apply-to-lines button of ${l}`,
342
+ `Rename the apply-to-lines button of ${o}`,
296
343
  !0
297
344
  );
298
345
  }
@@ -301,23 +348,23 @@ function pe() {
301
348
  }
302
349
  )
303
350
  ] }),
304
- c.layoutType === "addendum" && /* @__PURE__ */ t(
305
- m,
351
+ s.layoutType === "addendum" && /* @__PURE__ */ l(
352
+ v,
306
353
  {
307
354
  k: "field.prefill_from_parent",
308
355
  label: "Prefill from the record",
309
356
  effect: "A new addendum starts with the record's current value.",
310
- checked: d.prefill_from_parent !== !1,
357
+ checked: u.prefill_from_parent !== !1,
311
358
  onChange: (e) => a.setOverride(
312
359
  "prefill_from_parent",
313
360
  e ? void 0 : !1,
314
- e ? `Prefill ${l} from the record` : `Start ${l} empty on addendums`
361
+ e ? `Prefill ${o} from the record` : `Start ${o} empty on addendums`
315
362
  )
316
363
  }
317
364
  )
318
365
  ] });
319
366
  }
320
367
  export {
321
- pe as RulesTab,
322
- Z as useFieldRows
368
+ Me as RulesTab,
369
+ se as useFieldRows
323
370
  };
@@ -0,0 +1,156 @@
1
+ import { jsx as s, jsxs as b } from "react/jsx-runtime";
2
+ import { readLayoutI18n as g, approveLayoutText as S, withLayoutText as k } from "../../../lib/layout-i18n.js";
3
+ import { titleCase as E } from "../../../lib/utils.js";
4
+ import { useTranslationSummary as C } from "../inspect/inspect-api.js";
5
+ import { effectText as w } from "../panel-style.js";
6
+ import { useFieldCtx as I } from "./field-context.js";
7
+ import { useInspectorEnv as j, Section as A, Setting as $, TextInput as T } from "./kit.js";
8
+ const l = (n) => n.toUpperCase();
9
+ function W() {
10
+ var N;
11
+ const n = I(), { info: c, ov: a, env: v } = n, { data: i } = C(v.collection), d = (i == null ? void 0 : i.locales) ?? [];
12
+ if (!d.length) return null;
13
+ const r = g(a.i18n), y = typeof a.label == "string" && a.label ? a.label : c.label, t = typeof a.note == "string" && a.note || ((N = c.global) == null ? void 0 : N.note) || "", p = d.reduce(
14
+ (e, o) => {
15
+ var f, m, u, L;
16
+ return e + ((f = r[o]) != null && f.label && !((m = r[o]) != null && m.draft) ? 0 : 1) + (t && !((u = r[o]) != null && u.help && !((L = r[o]) != null && L.draft)) ? 1 : 0);
17
+ },
18
+ 0
19
+ ), h = (e, o) => n.setOverride("i18n", e, o, !0), x = (e, o, f) => h(
20
+ k(g(a.i18n), e, o, f),
21
+ `Translate the ${o === "label" ? "label" : "help text"} of ${c.label} (${l(e)})`
22
+ );
23
+ return /* @__PURE__ */ b(
24
+ A,
25
+ {
26
+ title: p ? `Translations · ${p} missing` : "Translations",
27
+ collapsible: !0,
28
+ defaultOpen: !1,
29
+ children: [
30
+ /* @__PURE__ */ b("p", { className: w, children: [
31
+ "Shown to people reading in that language. Empty uses the text above (",
32
+ l((i == null ? void 0 : i.base) ?? "en"),
33
+ ")."
34
+ ] }),
35
+ d.map((e) => {
36
+ var o, f, m;
37
+ return /* @__PURE__ */ b("div", { "data-translation-locale": e, className: "space-y-3", children: [
38
+ ((o = r[e]) == null ? void 0 : o.draft) && /* @__PURE__ */ s(
39
+ O,
40
+ {
41
+ locale: e,
42
+ onApprove: () => n.setOverride(
43
+ "i18n",
44
+ S(g(a.i18n), e),
45
+ `Approve the ${l(e)} translation of ${c.label}`
46
+ )
47
+ }
48
+ ),
49
+ /* @__PURE__ */ s(
50
+ $,
51
+ {
52
+ k: "field.i18n.label",
53
+ label: `Label (${l(e)})`,
54
+ effect: `What this form calls the field in ${l(e)}.`,
55
+ children: /* @__PURE__ */ s(
56
+ T,
57
+ {
58
+ ariaLabel: `Label in ${l(e)}`,
59
+ value: ((f = r[e]) == null ? void 0 : f.label) ?? "",
60
+ placeholder: y,
61
+ onChange: (u) => x(e, "label", u)
62
+ }
63
+ )
64
+ }
65
+ ),
66
+ /* @__PURE__ */ s(
67
+ $,
68
+ {
69
+ k: "field.i18n.help",
70
+ label: `Help text (${l(e)})`,
71
+ effect: t ? "The line of help under the field." : "Shown only once the field has help.",
72
+ children: /* @__PURE__ */ s(
73
+ T,
74
+ {
75
+ ariaLabel: `Help text in ${l(e)}`,
76
+ value: ((m = r[e]) == null ? void 0 : m.help) ?? "",
77
+ placeholder: t,
78
+ onChange: (u) => x(e, "help", u)
79
+ }
80
+ )
81
+ }
82
+ )
83
+ ] }, e);
84
+ })
85
+ ]
86
+ }
87
+ );
88
+ }
89
+ function q({ group: n }) {
90
+ const c = j(), { data: a } = C(c.collection), v = (a == null ? void 0 : a.locales) ?? [];
91
+ if (!v.length || !["section", "tab", "metadata"].includes(n.type)) return null;
92
+ const i = n.label || E(n.key);
93
+ if (!(a != null && a.groups_supported))
94
+ return /* @__PURE__ */ s("p", { "data-setting": "group.i18n", className: w, children: "Section names can be translated once the database is updated (migration 465)." });
95
+ const d = g(n.i18n), r = (t, p, h = !1) => c.apply(
96
+ [
97
+ {
98
+ op: "group_update",
99
+ key: n.key,
100
+ patch: { i18n: t ? JSON.stringify(t) : null }
101
+ }
102
+ ],
103
+ h ? { label: `Approve the ${l(p)} name of ${i}` } : { label: `Translate the name of ${i} (${l(p)})`, text: !0 }
104
+ ), y = (t, p) => r(k(g(n.i18n), t, "label", p), t);
105
+ return /* @__PURE__ */ s(A, { title: "Translations", collapsible: !0, defaultOpen: !1, children: v.map((t) => {
106
+ var p, h;
107
+ return /* @__PURE__ */ b("div", { className: "space-y-2", children: [
108
+ ((p = d[t]) == null ? void 0 : p.draft) && /* @__PURE__ */ s(O, { locale: t, onApprove: () => r(S(d, t), t, !0) }),
109
+ /* @__PURE__ */ s(
110
+ $,
111
+ {
112
+ k: "group.i18n.label",
113
+ label: `Name (${l(t)})`,
114
+ effect: `The heading people reading in ${l(t)} see. Empty uses the name above.`,
115
+ children: /* @__PURE__ */ s(
116
+ T,
117
+ {
118
+ ariaLabel: `Name in ${l(t)}`,
119
+ value: ((h = d[t]) == null ? void 0 : h.label) ?? "",
120
+ placeholder: i,
121
+ onChange: (x) => y(t, x)
122
+ }
123
+ )
124
+ }
125
+ )
126
+ ] }, t);
127
+ }) });
128
+ }
129
+ function O({ locale: n, onApprove: c }) {
130
+ return /* @__PURE__ */ b(
131
+ "p",
132
+ {
133
+ "data-translation-draft": n,
134
+ className: "flex flex-wrap items-center gap-x-2 text-[12px] leading-snug text-amber-700 dark:text-amber-300",
135
+ children: [
136
+ "Suggested ",
137
+ l(n),
138
+ " text, not shown on records yet.",
139
+ /* @__PURE__ */ s(
140
+ "button",
141
+ {
142
+ type: "button",
143
+ "data-approve-translation": n,
144
+ onClick: c,
145
+ className: "font-medium underline",
146
+ children: "Approve"
147
+ }
148
+ )
149
+ ]
150
+ }
151
+ );
152
+ }
153
+ export {
154
+ W as FieldTranslations,
155
+ q as GroupTranslations
156
+ };