@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
@@ -0,0 +1,143 @@
1
+ import { jsxs as t, jsx as a } from "react/jsx-runtime";
2
+ import { useQueryClient as S, useMutation as q } from "@tanstack/react-query";
3
+ import { Loader2 as F } from "lucide-react";
4
+ import { useState as m, useMemo as M } from "react";
5
+ import { useNivaroClient as R } from "../../context.js";
6
+ import { invalidateRecordTasks as j } from "../../lib/record-tasks.js";
7
+ import { sendChangeRequest as L } from "../layout-editor/ops/ops-api.js";
8
+ import { Popover as Q, PopoverAnchor as T, PopoverContent as A } from "../ui/popover.js";
9
+ import { SimpleSelect as E } from "../ui/SimpleSelect.js";
10
+ function G({
11
+ open: u,
12
+ onOpenChange: r,
13
+ anchor: c,
14
+ collection: p,
15
+ item: g,
16
+ layoutId: w,
17
+ layoutName: x,
18
+ fields: l,
19
+ onSent: s
20
+ }) {
21
+ const N = R(), o = S(), [n, h] = m(""), [d, b] = m(""), [f, v] = m(null), k = () => {
22
+ h(""), b(""), v(null);
23
+ }, i = q({
24
+ mutationFn: () => {
25
+ var e;
26
+ return L(N, {
27
+ collection: p,
28
+ item: g,
29
+ layout_id: w,
30
+ field: n || null,
31
+ field_label: ((e = l.find((P) => P.field === n)) == null ? void 0 : e.label) ?? null,
32
+ message: d.trim()
33
+ });
34
+ },
35
+ onSuccess: (e) => {
36
+ o.invalidateQueries({ queryKey: ["support-tickets"] }), o.invalidateQueries({ queryKey: ["support-summary"] }), j(o, p, g), s == null || s(e), k(), r(!1);
37
+ },
38
+ onError: (e) => v(e.message || "Could not send the suggestion")
39
+ }), y = d.trim().length > 0 && !i.isPending, C = M(() => ({ current: c }), [c]);
40
+ return u ? /* @__PURE__ */ t(
41
+ Q,
42
+ {
43
+ open: u,
44
+ onOpenChange: (e) => {
45
+ e || k(), r(e);
46
+ },
47
+ children: [
48
+ /* @__PURE__ */ a(T, { virtualRef: C }),
49
+ /* @__PURE__ */ t(
50
+ A,
51
+ {
52
+ align: "end",
53
+ role: "dialog",
54
+ "aria-label": "Suggest a form change",
55
+ className: "max-h-[min(80vh,620px)] w-[400px] max-w-[calc(100vw-24px)] overflow-y-auto overscroll-contain p-0",
56
+ "data-suggest-form-change": !0,
57
+ children: [
58
+ /* @__PURE__ */ t("div", { className: "px-4 pt-3.5", children: [
59
+ /* @__PURE__ */ a("p", { className: "text-[13.5px] font-semibold text-slate-900 dark:text-slate-100", children: "Suggest a form change" }),
60
+ /* @__PURE__ */ t("p", { className: "mt-0.5 text-[12px] leading-snug text-slate-500 dark:text-muted-foreground", children: [
61
+ "Tell the administrators how this form",
62
+ x ? ` (${x})` : "",
63
+ " could work better — a field to add, move, rename or explain. You can follow it under My requests."
64
+ ] })
65
+ ] }),
66
+ /* @__PURE__ */ t(
67
+ "form",
68
+ {
69
+ className: "space-y-3 px-4 pb-4 pt-3",
70
+ onSubmit: (e) => {
71
+ e.preventDefault(), y && i.mutate();
72
+ },
73
+ children: [
74
+ l.length > 0 && /* @__PURE__ */ t("div", { children: [
75
+ /* @__PURE__ */ a("span", { className: "mb-1 block text-[12px] font-medium text-slate-700 dark:text-slate-200", children: "About a field (optional)" }),
76
+ /* @__PURE__ */ a(
77
+ E,
78
+ {
79
+ ariaLabel: "Field",
80
+ value: n,
81
+ onChange: h,
82
+ options: [
83
+ { value: "", label: "The form in general" },
84
+ ...l.map((e) => ({ value: e.field, label: e.label }))
85
+ ],
86
+ className: "h-8 w-full text-[12.5px]",
87
+ triggerProps: { "data-suggest-field": "" }
88
+ }
89
+ )
90
+ ] }),
91
+ /* @__PURE__ */ t("label", { className: "block", children: [
92
+ /* @__PURE__ */ a("span", { className: "mb-1 block text-[12px] font-medium text-slate-700 dark:text-slate-200", children: "What should change?" }),
93
+ /* @__PURE__ */ a(
94
+ "textarea",
95
+ {
96
+ "data-suggest-message": !0,
97
+ value: d,
98
+ onChange: (e) => b(e.target.value),
99
+ rows: 4,
100
+ maxLength: 4e3,
101
+ placeholder: "e.g. Put Vendor next to PO number — we always check them together",
102
+ className: "w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-[13px] text-slate-900 outline-none focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-slate-100"
103
+ }
104
+ )
105
+ ] }),
106
+ f && /* @__PURE__ */ a("p", { className: "text-[12px] text-red-600 dark:text-red-400", role: "alert", children: f }),
107
+ /* @__PURE__ */ t("div", { className: "flex justify-end gap-2 pt-1", children: [
108
+ /* @__PURE__ */ a(
109
+ "button",
110
+ {
111
+ type: "button",
112
+ onClick: () => r(!1),
113
+ className: "h-8 rounded-md border border-slate-200 px-3 text-[12.5px] text-slate-700 hover:bg-slate-50 dark:border-border dark:text-slate-200 dark:hover:bg-white/5",
114
+ children: "Cancel"
115
+ }
116
+ ),
117
+ /* @__PURE__ */ t(
118
+ "button",
119
+ {
120
+ type: "submit",
121
+ "data-suggest-send": !0,
122
+ disabled: !y,
123
+ className: "inline-flex h-8 items-center gap-1.5 rounded-md border border-nvr-cyan/60 bg-nvr-cyan/10 px-3 text-[12.5px] font-medium text-nvr-navy hover:bg-nvr-cyan/15 disabled:opacity-50 dark:text-nvr-cyan",
124
+ children: [
125
+ i.isPending && /* @__PURE__ */ a(F, { className: "h-3.5 w-3.5 animate-spin" }),
126
+ "Send suggestion"
127
+ ]
128
+ }
129
+ )
130
+ ] })
131
+ ]
132
+ }
133
+ )
134
+ ]
135
+ }
136
+ )
137
+ ]
138
+ }
139
+ ) : null;
140
+ }
141
+ export {
142
+ G as SuggestFormChange
143
+ };
@@ -0,0 +1,37 @@
1
+ const i = "ai_generate", u = 2e3, l = /\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g;
2
+ function p(o) {
3
+ let t = o;
4
+ for (let s = 0; s < 4 && typeof t == "string"; s++)
5
+ try {
6
+ t = JSON.parse(t);
7
+ } catch {
8
+ return null;
9
+ }
10
+ const e = t == null ? void 0 : t[i];
11
+ if (!e || typeof e != "object" || Array.isArray(e)) return null;
12
+ const r = e, n = typeof r.prompt == "string" && r.prompt.trim() ? r.prompt.slice(0, 2e3) : null, c = n ? a(n) : Array.isArray(r.tokens) ? r.tokens.filter((s) => typeof s == "string") : [];
13
+ return {
14
+ enabled: r.enabled === !0,
15
+ prompt: n,
16
+ hasPrompt: !!n || r.has_prompt === !0,
17
+ tokens: c
18
+ };
19
+ }
20
+ function a(o) {
21
+ const t = [];
22
+ for (const e of o.matchAll(l)) t.includes(e[1]) || t.push(e[1]);
23
+ return t;
24
+ }
25
+ const f = "autofill_check";
26
+ function A(o, t, e) {
27
+ const r = p(o);
28
+ return r ? { show: r.enabled && r.hasPrompt, perField: !0 } : { show: e && !!t, perField: !1 };
29
+ }
30
+ export {
31
+ i as AI_FILL_KEY,
32
+ f as AUTOFILL_CHECK_KEY,
33
+ u as PROMPT_MAX,
34
+ a as promptTokens,
35
+ p as readAiFill,
36
+ A as showsAiButton
37
+ };
@@ -0,0 +1,84 @@
1
+ var p = Object.defineProperty;
2
+ var d = (e, t, n) => t in e ? p(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var r = (e, t, n) => d(e, typeof t != "symbol" ? t + "" : t, n);
4
+ const s = [];
5
+ let u = null, l = null, a = !1;
6
+ const h = 20, f = 15e3;
7
+ function c() {
8
+ if (l && (clearTimeout(l), l = null), !u || s.length === 0) return;
9
+ const { apiBase: e, authHeaders: t, credentials: n } = u;
10
+ for (; s.length; ) {
11
+ const i = JSON.stringify({ events: s.splice(0, h) });
12
+ try {
13
+ const o = `${e}/layout-usage/beacon`;
14
+ !(Object.keys(t).length > 0) && typeof navigator < "u" && typeof navigator.sendBeacon == "function" && navigator.sendBeacon(o, new Blob([i], { type: "application/json" })) || fetch(o, {
15
+ method: "POST",
16
+ credentials: n,
17
+ headers: { "Content-Type": "application/json", ...t },
18
+ body: i,
19
+ keepalive: !0
20
+ }).catch(() => {
21
+ });
22
+ } catch {
23
+ }
24
+ }
25
+ }
26
+ function v() {
27
+ a || typeof window > "u" || (a = !0, window.addEventListener("pagehide", c), document.addEventListener("visibilitychange", () => {
28
+ document.visibilityState === "hidden" && c();
29
+ }));
30
+ }
31
+ function _(e, t) {
32
+ u = t, s.push(e), v(), s.length >= h ? c() : l || (l = setTimeout(c, f));
33
+ }
34
+ class M {
35
+ constructor(t, n, i = !0) {
36
+ r(this, "steps", {});
37
+ r(this, "current");
38
+ r(this, "since");
39
+ this.current = t, this.since = i ? n : null;
40
+ }
41
+ settle(t) {
42
+ if (this.since == null) return;
43
+ const n = Math.max(0, t - this.since);
44
+ n > 0 && (this.steps[this.current] = (this.steps[this.current] ?? 0) + n), this.since = t;
45
+ }
46
+ step(t, n) {
47
+ t !== this.current && (this.settle(n), this.current = t);
48
+ }
49
+ pause(t) {
50
+ this.settle(t), this.since = null;
51
+ }
52
+ resume(t) {
53
+ this.since == null && (this.since = t);
54
+ }
55
+ get currentStep() {
56
+ return this.current;
57
+ }
58
+ /** The time so far, and start counting afresh (the clock keeps running). */
59
+ take(t) {
60
+ this.settle(t);
61
+ const n = this.steps;
62
+ return this.steps = {}, { steps: n, total: Object.values(n).reduce((i, o) => i + o, 0) };
63
+ }
64
+ }
65
+ const g = 400, S = 3e3;
66
+ function B(e) {
67
+ return !e.saved && !e.openSent && e.elapsed < g || !e.saved && e.openSent && e.total <= 0 ? null : {
68
+ layout_id: e.layoutId,
69
+ collection: e.collection,
70
+ item: e.item,
71
+ open: !e.openSent,
72
+ saved: e.saved,
73
+ abandoned_step: e.final && e.item == null && !e.saved && e.elapsed >= S ? e.step : null,
74
+ steps: e.steps
75
+ };
76
+ }
77
+ export {
78
+ S as MIN_ABANDON_MS,
79
+ g as MIN_SESSION_MS,
80
+ M as StepClock,
81
+ c as flushFormUsage,
82
+ _ as queueFormUsage,
83
+ B as sessionEvent
84
+ };
@@ -0,0 +1,66 @@
1
+ function f(t) {
2
+ let e = t;
3
+ if (typeof e == "string")
4
+ try {
5
+ e = JSON.parse(e);
6
+ } catch {
7
+ return {};
8
+ }
9
+ if (!e || typeof e != "object" || Array.isArray(e)) return {};
10
+ const n = {};
11
+ for (const [l, r] of Object.entries(e)) {
12
+ if (!r || typeof r != "object" || Array.isArray(r)) continue;
13
+ const o = r, i = {};
14
+ for (const s of ["label", "help"]) {
15
+ const a = o[s];
16
+ typeof a == "string" && a.trim() && (i[s] = a);
17
+ }
18
+ !i.label && !i.help || (o.draft === !0 && (i.draft = !0), n[l] = i);
19
+ }
20
+ return n;
21
+ }
22
+ function u(t, e, n, l) {
23
+ const r = { ...t[e] ?? {} };
24
+ l.trim() ? r[n] = l : delete r[n];
25
+ const o = { ...t };
26
+ return r.label || r.help ? o[e] = r : delete o[e], Object.keys(o).length ? o : void 0;
27
+ }
28
+ function d(t, e) {
29
+ const { draft: n, ...l } = t[e] ?? {};
30
+ return { ...t, [e]: l };
31
+ }
32
+ function y() {
33
+ var e;
34
+ let t = null;
35
+ try {
36
+ t = ((e = globalThis.localStorage) == null ? void 0 : e.getItem("nivaro_admin_locale")) ?? null;
37
+ } catch {
38
+ t = null;
39
+ }
40
+ return !t && typeof document < "u" && (t = document.documentElement.lang || null), !t && typeof navigator < "u" && (t = navigator.language || null), (t ?? "en").toLowerCase();
41
+ }
42
+ function c(t, e, n) {
43
+ var s;
44
+ const l = Object.keys(t).filter((a) => !t[a].draft), r = l.find((a) => a.toLowerCase() === e), o = e.split(/[-_]/)[0], i = r ?? l.find((a) => a.toLowerCase().split(/[-_]/)[0] === o);
45
+ return i && ((s = t[i]) == null ? void 0 : s[n]) || null;
46
+ }
47
+ function b(t, e) {
48
+ const n = t._overrides, l = n && typeof n == "object" && !Array.isArray(n) ? n.i18n : null;
49
+ if (!l) return t;
50
+ const r = f(l), o = t.label === "" ? null : c(r, e, "label"), i = c(r, e, "help");
51
+ return !o && !i ? t : { ...t, ...o ? { label: o } : {}, ...i ? { note: i } : {} };
52
+ }
53
+ function p(t, e) {
54
+ if (!t.i18n) return t;
55
+ const n = c(f(t.i18n), e, "label");
56
+ return n ? { ...t, label: n } : t;
57
+ }
58
+ export {
59
+ d as approveLayoutText,
60
+ y as formLocale,
61
+ c as layoutText,
62
+ f as readLayoutI18n,
63
+ b as translateFieldRow,
64
+ p as translateGroup,
65
+ u as withLayoutText
66
+ };