@nivaro/react 0.3.36 → 0.3.37

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 (102) hide show
  1. package/dist/components/slots/CommentsSlot.js +44 -36
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +9 -1
  5. package/dist/shared/components/AgentBadge.js +26 -0
  6. package/dist/shared/components/AgentQuestionsCard.js +198 -0
  7. package/dist/shared/components/ItemEditForm.js +3329 -3263
  8. package/dist/shared/components/McpConnectionScope.js +480 -0
  9. package/dist/shared/components/MyWorkView.js +223 -208
  10. package/dist/shared/components/RecordReadView.js +620 -575
  11. package/dist/shared/components/chat/ChatPanel.js +683 -671
  12. package/dist/shared/components/imports/DownloadSampleButton.js +69 -0
  13. package/dist/shared/components/imports/ImportConsole.js +106 -104
  14. package/dist/shared/components/imports/RunDetailSheet.js +11 -10
  15. package/dist/shared/components/item-edit/FieldAffordances.js +32 -32
  16. package/dist/shared/components/item-edit/FormTour.js +279 -0
  17. package/dist/shared/components/item-edit/GroupSection.js +377 -360
  18. package/dist/shared/components/item-edit/PersonalDefaultControl.js +28 -28
  19. package/dist/shared/components/item-edit/entry/EntryStrip.js +30 -26
  20. package/dist/shared/components/item-edit/form-density.js +36 -0
  21. package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -46
  22. package/dist/shared/components/item-edit/usePersonalDefaults.js +312 -296
  23. package/dist/shared/components/layout-editor/AddPanel.js +349 -192
  24. package/dist/shared/components/layout-editor/DesignNode.js +126 -112
  25. package/dist/shared/components/layout-editor/EditorTopBar.js +123 -103
  26. package/dist/shared/components/layout-editor/LayoutEditor.js +829 -751
  27. package/dist/shared/components/layout-editor/PlaceTools.js +334 -0
  28. package/dist/shared/components/layout-editor/SlashInsert.js +252 -0
  29. package/dist/shared/components/layout-editor/StructureMenu.js +285 -242
  30. package/dist/shared/components/layout-editor/add-target.js +54 -43
  31. package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +238 -155
  32. package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +1 -1
  33. package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +15 -12
  34. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +347 -189
  35. package/dist/shared/components/layout-editor/dnd/TrashZone.js +60 -32
  36. package/dist/shared/components/layout-editor/dnd/UndoChip.js +76 -0
  37. package/dist/shared/components/layout-editor/dnd/merge-drop.js +33 -0
  38. package/dist/shared/components/layout-editor/dnd/multi-drop.js +87 -0
  39. package/dist/shared/components/layout-editor/dnd/node.js +115 -105
  40. package/dist/shared/components/layout-editor/dnd/sensors.js +23 -0
  41. package/dist/shared/components/layout-editor/dnd/trash-drop.js +34 -28
  42. package/dist/shared/components/layout-editor/dnd/trash-links.js +97 -0
  43. package/dist/shared/components/layout-editor/even-row.js +86 -0
  44. package/dist/shared/components/layout-editor/field-list.js +99 -0
  45. package/dist/shared/components/layout-editor/format-painter.js +102 -0
  46. package/dist/shared/components/layout-editor/grid-guides.js +15 -13
  47. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +150 -132
  48. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +57 -53
  49. package/dist/shared/components/layout-editor/inspector/EvenRowAction.js +31 -0
  50. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +154 -141
  51. package/dist/shared/components/layout-editor/inspector/Inspector.js +209 -178
  52. package/dist/shared/components/layout-editor/inspector/LookTab.js +106 -98
  53. package/dist/shared/components/layout-editor/inspector/RulesTab.js +38 -37
  54. package/dist/shared/components/layout-editor/inspector/kit.js +280 -223
  55. package/dist/shared/components/layout-editor/keyboard-move.js +15 -15
  56. package/dist/shared/components/layout-editor/lint/LabelStyle.js +201 -0
  57. package/dist/shared/components/layout-editor/lint/LintPanel.js +132 -84
  58. package/dist/shared/components/layout-editor/lint/lint-api.js +65 -28
  59. package/dist/shared/components/layout-editor/nav/NavTools.js +14 -12
  60. package/dist/shared/components/layout-editor/nav/ZoomControls.js +145 -0
  61. package/dist/shared/components/layout-editor/nav/useEditorNav.js +34 -32
  62. package/dist/shared/components/layout-editor/nav/view-prefs.js +100 -15
  63. package/dist/shared/components/layout-editor/outputs/LayoutFile.js +89 -0
  64. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +272 -195
  65. package/dist/shared/components/layout-editor/outputs/layout-file-plan.js +176 -0
  66. package/dist/shared/components/layout-editor/outputs/output-api.js +71 -37
  67. package/dist/shared/components/layout-editor/overview/describe-conditions.js +16 -11
  68. package/dist/shared/components/layout-editor/overview/purpose.js +5 -5
  69. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  70. package/dist/shared/components/layout-editor/pin.js +37 -19
  71. package/dist/shared/components/layout-editor/place-clip.js +257 -0
  72. package/dist/shared/components/layout-editor/preview/PreviewModes.js +27 -26
  73. package/dist/shared/components/layout-editor/preview/PreviewPanes.js +148 -117
  74. package/dist/shared/components/layout-editor/preview/SampleRecord.js +113 -0
  75. package/dist/shared/components/layout-editor/preview/preview-model.js +79 -60
  76. package/dist/shared/components/layout-editor/preview/sample-record.js +105 -0
  77. package/dist/shared/components/layout-editor/removed-log.js +151 -0
  78. package/dist/shared/components/layout-editor/reuse/LibraryRows.js +109 -78
  79. package/dist/shared/components/layout-editor/reuse/linked-sections.js +373 -0
  80. package/dist/shared/components/layout-editor/revert-element.js +140 -0
  81. package/dist/shared/components/layout-editor/section-structure.js +193 -170
  82. package/dist/shared/components/layout-editor/settings/EntrySection.js +63 -45
  83. package/dist/shared/components/layout-editor/settings/LayoutSection.js +63 -32
  84. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +179 -137
  85. package/dist/shared/components/layout-editor/settings/WhoSection.js +18 -17
  86. package/dist/shared/components/layout-editor/settings/settings-registry.js +24 -0
  87. package/dist/shared/components/layout-editor/shortcuts.js +21 -16
  88. package/dist/shared/components/layout-editor/structure-ops.js +221 -195
  89. package/dist/shared/components/layout-editor/usage/UsagePanel.js +133 -85
  90. package/dist/shared/components/layout-editor/usage/refusal-lens.js +130 -0
  91. package/dist/shared/components/layout-editor/usage/usage-api.js +12 -11
  92. package/dist/shared/components/panels/CommentPanel.js +47 -45
  93. package/dist/shared/components/panels/RevisionsPanel.js +66 -64
  94. package/dist/shared/components/panels/TaskPanel.js +395 -332
  95. package/dist/shared/components/profile/AgentsPanel.js +196 -147
  96. package/dist/shared/components/profile/ConnectionRollback.js +329 -0
  97. package/dist/shared/components/profile/MyDefaultsCard.js +526 -520
  98. package/dist/shared/lib/entry-config.js +22 -22
  99. package/dist/shared/lib/form-usage-beacon.js +91 -55
  100. package/dist/shared/lib/layout-lint.js +530 -284
  101. package/dist/shared/lib/layout-resolve.js +58 -44
  102. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { jsx as r, jsxs as o } from "react/jsx-runtime";
2
- import { UserRound as v, UserRoundPlus as S, UserRoundPen as C, UserRoundX as U, Check as Y, Undo2 as E } from "lucide-react";
2
+ import { UserRound as v, Undo2 as S, UserRoundPlus as C, UserRoundPen as U, UserRoundX as Y, Check as E } from "lucide-react";
3
3
  import { useState as F, Fragment as P, useInsertionEffect as I } from "react";
4
4
  import { toast as c } from "sonner";
5
5
  import { usePersonalDefaultsApi as D } from "./usePersonalDefaults.js";
@@ -7,7 +7,7 @@ function T(e) {
7
7
  return e.applied && e.hasDefault ? "applied" : e.editable ? e.loaded ? e.failed && !e.hasDefault ? e.hasValue ? "offer" : null : e.hasDefault ? e.hasValue ? e.isDefault ? "saved" : "update" : "saved-empty" : e.hasValue ? "offer" : "reserve" : "reserve" : null;
8
8
  }
9
9
  function K(e, t, a) {
10
- return e != null && e.allowed(t) ? T({
10
+ return e != null && e.allowed(t) ? e.manageable(t) ? T({
11
11
  editable: a,
12
12
  loaded: e.loaded,
13
13
  hasValue: e.hasValue(t),
@@ -15,12 +15,12 @@ function K(e, t, a) {
15
15
  isDefault: e.isDefault(t),
16
16
  applied: e.applied(t),
17
17
  failed: e.failed
18
- }) : null;
18
+ }) : e.applied(t) && e.defaultFor(t) !== null ? "applied" : null : null;
19
19
  }
20
20
  function g(e, t) {
21
- var d, l, f;
21
+ var d, s, f;
22
22
  const a = e;
23
- return ((l = (d = a == null ? void 0 : a.response) == null ? void 0 : d.data) == null ? void 0 : l.error) ?? ((f = a == null ? void 0 : a.data) == null ? void 0 : f.error) ?? (a == null ? void 0 : a.error) ?? (a == null ? void 0 : a.message) ?? t;
23
+ return ((s = (d = a == null ? void 0 : a.response) == null ? void 0 : d.data) == null ? void 0 : s.error) ?? ((f = a == null ? void 0 : a.data) == null ? void 0 : f.error) ?? (a == null ? void 0 : a.error) ?? (a == null ? void 0 : a.message) ?? t;
24
24
  }
25
25
  function R(e, t) {
26
26
  return e.clear(t).then(
@@ -87,30 +87,30 @@ function W({
87
87
  label: t,
88
88
  state: a,
89
89
  confirmOpen: d,
90
- onConfirm: l,
90
+ onConfirm: s,
91
91
  onUndo: f,
92
92
  onCleared: h
93
93
  }) {
94
94
  L();
95
- const s = D(), [x, k] = F(!1), i = t || e, b = a !== "saved-empty", m = /* @__PURE__ */ o(
95
+ const l = D(), [x, b] = F(!1), u = t || e, k = a !== "saved-empty", m = /* @__PURE__ */ o(
96
96
  "button",
97
97
  {
98
98
  type: "button",
99
99
  "data-personal-default-clear": e,
100
- "aria-label": b ? `Clear your saved default for ${i} (the field keeps its value)` : `Clear your saved default for ${i}`,
101
- "data-tip": b ? "Forget your saved default — this field keeps its value" : "Forget your saved default",
100
+ "aria-label": k ? `Clear your saved default for ${u} (the field keeps its value)` : `Clear your saved default for ${u}`,
101
+ "data-tip": k ? "Forget your saved default — this field keeps its value" : "Forget your saved default",
102
102
  "data-pd-action": !0,
103
103
  tabIndex: -1,
104
- disabled: x || !s,
104
+ disabled: x || !l,
105
105
  "aria-busy": x || void 0,
106
106
  onClick: () => {
107
- s && (k(!0), R(s, e).then((n) => {
108
- k(!1), n && (h == null || h());
107
+ l && (b(!0), R(l, e).then((n) => {
108
+ b(!1), n && (h == null || h());
109
109
  }));
110
110
  },
111
111
  className: y,
112
112
  children: [
113
- /* @__PURE__ */ r(U, { "data-pd-icon": !0, className: "h-3 w-3", "aria-hidden": !0 }),
113
+ /* @__PURE__ */ r(Y, { "data-pd-icon": !0, className: "h-3 w-3", "aria-hidden": !0 }),
114
114
  /* @__PURE__ */ r("span", { "data-pd-label": !0, children: "Clear default" })
115
115
  ]
116
116
  },
@@ -120,23 +120,23 @@ function W({
120
120
  {
121
121
  type: "button",
122
122
  ...n === "make" ? { "data-personal-default-make": e } : { "data-personal-default-update": e },
123
- "aria-label": n === "make" ? `Make this your default for ${i}` : `Update your saved default for ${i} to this value`,
123
+ "aria-label": n === "make" ? `Make this your default for ${u}` : `Update your saved default for ${u} to this value`,
124
124
  "aria-haspopup": "dialog",
125
125
  "aria-expanded": d === n,
126
126
  "data-tip": n === "make" ? "Start your new records with this value" : "Start your new records with this value instead",
127
127
  "data-pd-action": !0,
128
128
  tabIndex: -1,
129
- onClick: (p) => l(p.currentTarget, n),
129
+ onClick: (p) => s(p.currentTarget, n),
130
130
  className: y,
131
131
  children: [
132
- n === "make" ? /* @__PURE__ */ r(S, { className: "h-3 w-3", "aria-hidden": !0 }) : /* @__PURE__ */ r(C, { className: "h-3 w-3", "aria-hidden": !0 }),
132
+ n === "make" ? /* @__PURE__ */ r(C, { className: "h-3 w-3", "aria-hidden": !0 }) : /* @__PURE__ */ r(U, { className: "h-3 w-3", "aria-hidden": !0 }),
133
133
  /* @__PURE__ */ r("span", { "data-pd-primary": !0, children: n === "make" ? "Make default" : "Update default" })
134
134
  ]
135
135
  },
136
136
  n
137
137
  );
138
- let u = [];
139
- return a === "offer" ? u = [w("make")] : a === "update" ? u = [w("update"), m] : a === "saved" || a === "saved-empty" ? u = [
138
+ let i = [];
139
+ return a === "offer" ? i = [w("make")] : a === "update" ? i = [w("update"), m] : a === "saved" || a === "saved-empty" ? i = [
140
140
  /* @__PURE__ */ o(
141
141
  "span",
142
142
  {
@@ -144,7 +144,7 @@ function W({
144
144
  "data-tip": a === "saved" ? "Your new records start with this value" : "You have a saved default for this field — new records start with it",
145
145
  className: V,
146
146
  children: [
147
- a === "saved" ? /* @__PURE__ */ r(Y, { className: "h-3 w-3 text-sky-700 dark:text-sky-300", "aria-hidden": !0 }) : /* @__PURE__ */ r(v, { className: "h-3 w-3", "aria-hidden": !0 }),
147
+ a === "saved" ? /* @__PURE__ */ r(E, { className: "h-3 w-3 text-sky-700 dark:text-sky-300", "aria-hidden": !0 }) : /* @__PURE__ */ r(v, { className: "h-3 w-3", "aria-hidden": !0 }),
148
148
  /* @__PURE__ */ r("span", { className: "sr-only", children: "Your default" }),
149
149
  /* @__PURE__ */ r("span", { "data-pd-label": !0, "aria-hidden": !0, children: "Your default" })
150
150
  ]
@@ -152,7 +152,7 @@ function W({
152
152
  "status"
153
153
  ),
154
154
  m
155
- ] : a === "applied" && (u = [
155
+ ] : a === "applied" && (i = [
156
156
  /* @__PURE__ */ o(
157
157
  "span",
158
158
  {
@@ -172,28 +172,28 @@ function W({
172
172
  {
173
173
  type: "button",
174
174
  "data-personal-default-undo": e,
175
- "aria-label": `Undo: empty ${i} (your saved default stays)`,
175
+ "aria-label": `Undo: empty ${u} (your saved default stays)`,
176
176
  "data-tip": "Empty this field — your saved default stays",
177
177
  "data-pd-action": !0,
178
178
  onClick: f,
179
179
  className: y,
180
180
  children: [
181
- /* @__PURE__ */ r(E, { className: "h-3 w-3", "aria-hidden": !0 }),
181
+ /* @__PURE__ */ r(S, { className: "h-3 w-3", "aria-hidden": !0 }),
182
182
  /* @__PURE__ */ r("span", { "data-pd-label": !0, children: "Undo" })
183
183
  ]
184
184
  },
185
185
  "undo"
186
186
  ),
187
- m
187
+ ...(l == null ? void 0 : l.manageable(e)) === !1 ? [] : [m]
188
188
  ]), /* @__PURE__ */ r(
189
189
  "span",
190
190
  {
191
191
  "data-personal-default-slot": e,
192
192
  "data-state": a,
193
- "data-pd-new": s != null && s.isNew ? "" : void 0,
193
+ "data-pd-new": l != null && l.isNew ? "" : void 0,
194
194
  "aria-hidden": a === "reserve" ? !0 : void 0,
195
195
  className: "inline-flex shrink-0 items-center justify-end",
196
- children: u.map((n, p) => /* @__PURE__ */ o(P, { children: [
196
+ children: i.map((n, p) => /* @__PURE__ */ o(P, { children: [
197
197
  p > 0 && /* @__PURE__ */ r(j, {}),
198
198
  n
199
199
  ] }, String(n.key ?? p)))
@@ -203,14 +203,14 @@ function W({
203
203
  function X({ field: e }) {
204
204
  const t = D();
205
205
  if (!(t != null && t.allowed(e))) return null;
206
- const a = t.loaded && t.isDefault(e), d = t.loaded && t.defaultFor(e) !== null, l = a ? "Your default: new records you start get this value." : d ? "You have your own default for this field, different from this value." : "You can save your own default for this field (Edit mode).";
206
+ const a = t.loaded && t.isDefault(e), d = t.loaded && t.defaultFor(e) !== null, s = a ? "Your default: new records you start get this value." : d ? "You have your own default for this field, different from this value." : "You can save your own default for this field (Edit mode).";
207
207
  return /* @__PURE__ */ r(
208
208
  "span",
209
209
  {
210
210
  "data-personal-default-mark": a ? "mine" : d ? "saved" : "allowed",
211
- "data-tip": l,
211
+ "data-tip": s,
212
212
  role: "img",
213
- "aria-label": l,
213
+ "aria-label": s,
214
214
  className: a ? "ml-1.5 inline-flex align-middle text-cyan-700 dark:text-nvr-cyan" : "ml-1.5 inline-flex align-middle text-slate-500 dark:text-slate-400",
215
215
  children: /* @__PURE__ */ r(v, { "aria-hidden": !0, className: "h-3 w-3", strokeWidth: 2.25 })
216
216
  }
@@ -1,54 +1,58 @@
1
- import { jsxs as i, jsx as a } from "react/jsx-runtime";
2
- import { badgeClasses as m } from "../../../lib/entry-badge-style.js";
1
+ import { jsxs as a, jsx as n } from "react/jsx-runtime";
2
+ import { badgeClasses as c } from "../../../lib/entry-badge-style.js";
3
3
  import { cn as o } from "../../../lib/utils.js";
4
- function u({
4
+ function h({
5
5
  badge: t,
6
6
  mode: r,
7
- auto: s,
8
- onMode: d
7
+ auto: d,
8
+ onMode: l,
9
+ tour: s
9
10
  }) {
10
- if (!t && !r) return null;
11
- const n = (e, l, p) => /* @__PURE__ */ a(
11
+ if (!t && !r && !s) return null;
12
+ const i = (e, p, m) => /* @__PURE__ */ n(
12
13
  "button",
13
14
  {
14
15
  type: "button",
15
16
  "aria-pressed": r === e,
16
- "data-tip": p,
17
+ "data-tip": m,
17
18
  "data-entry-mode": e,
18
- onClick: () => d(e === s ? null : e),
19
+ onClick: () => l(e === d ? null : e),
19
20
  className: o(
20
21
  "h-6 rounded px-2 text-[11.5px] font-medium transition-colors",
21
22
  r === e ? "bg-white text-slate-900 shadow-sm dark:bg-card dark:text-foreground" : "text-slate-500 hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground"
22
23
  ),
23
- children: l
24
+ children: p
24
25
  }
25
26
  );
26
- return /* @__PURE__ */ i("div", { "data-entry-strip": "", className: "flex flex-wrap items-center justify-between gap-2", children: [
27
- t ? /* @__PURE__ */ a(
27
+ return /* @__PURE__ */ a("div", { "data-entry-strip": "", className: "flex flex-wrap items-center justify-between gap-2", children: [
28
+ t ? /* @__PURE__ */ n(
28
29
  "span",
29
30
  {
30
31
  "data-form-badge": "",
31
32
  "data-tip": "The form this record is open in",
32
33
  className: o(
33
34
  "inline-flex h-5 items-center rounded-full px-2 text-[11px] font-medium",
34
- m(t.color)
35
+ c(t.color)
35
36
  ),
36
37
  children: t.tag
37
38
  }
38
- ) : /* @__PURE__ */ a("span", {}),
39
- r && /* @__PURE__ */ i(
40
- "fieldset",
41
- {
42
- "aria-label": "How to show this form",
43
- className: "m-0 inline-flex min-w-0 items-center gap-0.5 rounded-md border-0 bg-slate-100 p-0.5 dark:bg-muted",
44
- children: [
45
- n("beginner", "Guided steps", "One step at a time, with Next and Back"),
46
- n("expert", "Tabs", "Every tab open, in any order")
47
- ]
48
- }
49
- )
39
+ ) : /* @__PURE__ */ n("span", {}),
40
+ /* @__PURE__ */ a("span", { className: "flex min-w-0 flex-wrap items-center gap-2", children: [
41
+ s,
42
+ r && /* @__PURE__ */ a(
43
+ "fieldset",
44
+ {
45
+ "aria-label": "How to show this form",
46
+ className: "m-0 inline-flex min-w-0 items-center gap-0.5 rounded-md border-0 bg-slate-100 p-0.5 dark:bg-muted",
47
+ children: [
48
+ i("beginner", "Guided steps", "One step at a time, with Next and Back"),
49
+ i("expert", "Tabs", "Every tab open, in any order")
50
+ ]
51
+ }
52
+ )
53
+ ] })
50
54
  ] });
51
55
  }
52
56
  export {
53
- u as EntryStrip
57
+ h as EntryStrip
54
58
  };
@@ -0,0 +1,36 @@
1
+ import { useInsertionEffect as n } from "react";
2
+ function m(t) {
3
+ return (t == null ? void 0 : t.density) === "compact" ? "compact" : "comfortable";
4
+ }
5
+ const e = "[data-form-density=compact]", o = `
6
+ ${e} [data-form-body]{padding:1rem 1.25rem}
7
+ ${e} [data-form-body]>:not([hidden])~:not([hidden]),${e} [data-section-stack]>:not([hidden])~:not([hidden]){margin-top:.625rem}
8
+ ${e} [data-usage-header]{padding-top:.5rem;padding-bottom:.5rem}
9
+ ${e} [data-section-body]{padding:.625rem 1rem .75rem}
10
+ ${e} [data-section-grid]{row-gap:.625rem;column-gap:.875rem}
11
+ ${e} [data-summary-strip]{padding-top:.375rem;padding-bottom:.375rem}
12
+ ${e} [data-field]>:not([hidden])~:not([hidden]){margin-top:.25rem}
13
+ ${e} [data-read-head]{padding-top:.375rem;padding-bottom:.375rem}
14
+ ${e} [data-read-body]{padding:.75rem 1rem 1rem}
15
+ ${e} [data-read-dl]{row-gap:.75rem;column-gap:1rem}
16
+ @media (hover: hover) and (pointer: fine){
17
+ ${e} [data-section-key] .h-9{height:2rem}
18
+ ${e} [data-section-key] .h-10{height:2.25rem}
19
+ ${e} [data-section-key] textarea{min-height:3.5rem}
20
+ }
21
+ @media (max-width: 639px){
22
+ ${e} [data-form-body]{padding:.75rem}
23
+ }
24
+ `, a = "nvr-form-density-css";
25
+ function i(t) {
26
+ n(() => {
27
+ if (!t || typeof document > "u" || document.getElementById(a)) return;
28
+ const d = document.createElement("style");
29
+ d.id = a, d.textContent = o, document.head.appendChild(d);
30
+ }, [t]);
31
+ }
32
+ export {
33
+ o as FORM_DENSITY_CSS,
34
+ m as formDensityOf,
35
+ i as useFormDensityCss
36
+ };
@@ -1,65 +1,78 @@
1
- import { useRef as u, useEffect as h, useCallback as L } from "react";
2
- import { useApiFetchConfig as F } from "../../context.js";
3
- import { StepClock as R, onSectionUse as U, SectionTally as B, sessionEvent as H, queueFormUsage as q } from "../../lib/form-usage-beacon.js";
4
- function V({
5
- enabled: b,
6
- layoutId: s,
1
+ import { useRef as u, useEffect as D, useCallback as E, useMemo as B } from "react";
2
+ import { useApiFetchConfig as H } from "../../context.js";
3
+ import { StepClock as T, RefusalTally as q, onSectionUse as x, SectionTally as A, sessionEvent as P, queueFormUsage as V } from "../../lib/form-usage-beacon.js";
4
+ function J({
5
+ enabled: M,
6
+ layoutId: r,
7
7
  collection: c,
8
- itemId: d,
9
- step: i
8
+ itemId: l,
9
+ step: a
10
10
  }) {
11
- const l = F(), f = u(l);
12
- f.current = l;
13
- const v = u(i);
14
- v.current = i;
15
- const o = u(null), p = b && s != null && !!c;
16
- return h(() => {
17
- if (!p || s == null) return;
11
+ const d = H(), f = u(d);
12
+ f.current = d;
13
+ const p = u(a);
14
+ p.current = a;
15
+ const s = u(null), v = M && r != null && !!c;
16
+ D(() => {
17
+ if (!v || r == null) return;
18
18
  const n = () => typeof document > "u" || document.visibilityState !== "hidden", e = {
19
- clock: new R(v.current, Date.now(), n()),
19
+ clock: new T(p.current, Date.now(), n()),
20
20
  openSent: !1,
21
21
  saved: !1,
22
22
  elapsed: 0,
23
- saveMs: null
23
+ saveMs: null,
24
+ refusals: new q()
24
25
  };
25
- o.current = e;
26
- const r = new B(), D = U((t) => {
27
- t.layoutId === s && t.collection === c && r.note(t.kind, t.key);
28
- }), a = (t) => {
29
- const { steps: E, total: S } = e.clock.take(Date.now());
30
- e.elapsed += S;
31
- const g = r.pending(), w = H({
32
- layoutId: s,
26
+ s.current = e;
27
+ const t = new A(), R = x((o) => {
28
+ o.layoutId === r && o.collection === c && t.note(o.kind, o.key);
29
+ }), i = (o) => {
30
+ const { steps: C, total: g } = e.clock.take(Date.now());
31
+ e.elapsed += g;
32
+ const h = t.pending(), b = e.refusals.take(), y = P({
33
+ layoutId: r,
33
34
  collection: c,
34
- item: d,
35
+ item: l,
35
36
  openSent: e.openSent,
36
37
  saved: e.saved,
37
38
  step: e.clock.currentStep,
38
- steps: E,
39
- total: S,
39
+ steps: C,
40
+ total: g,
40
41
  elapsed: e.elapsed,
41
- final: t,
42
- sections: g,
43
- saveMs: e.saveMs
42
+ final: o,
43
+ sections: h,
44
+ saveMs: e.saveMs,
45
+ refused: b
44
46
  });
45
- if (!w) return;
46
- r.markSent(g), e.openSent = !0, e.saved = !1, e.saveMs = null;
47
- const { apiBase: y, authHeaders: M, credentials: C } = f.current;
48
- q(w, { apiBase: y, authHeaders: M, credentials: C });
49
- }, m = () => {
50
- document.visibilityState === "hidden" ? (a(!1), e.clock.pause(Date.now())) : e.clock.resume(Date.now());
51
- }, k = () => a(!0);
52
- return document.addEventListener("visibilitychange", m), window.addEventListener("pagehide", k), () => {
53
- document.removeEventListener("visibilitychange", m), window.removeEventListener("pagehide", k), a(!0), D(), o.current === e && (o.current = null);
47
+ if (!y) {
48
+ e.refusals.restore(b);
49
+ return;
50
+ }
51
+ t.markSent(h), e.openSent = !0, e.saved = !1, e.saveMs = null;
52
+ const { apiBase: L, authHeaders: F, credentials: U } = f.current;
53
+ V(y, { apiBase: L, authHeaders: F, credentials: U });
54
+ }, w = () => {
55
+ document.visibilityState === "hidden" ? (i(!1), e.clock.pause(Date.now())) : e.clock.resume(Date.now());
56
+ }, S = () => i(!0);
57
+ return document.addEventListener("visibilitychange", w), window.addEventListener("pagehide", S), () => {
58
+ document.removeEventListener("visibilitychange", w), window.removeEventListener("pagehide", S), i(!0), R(), s.current === e && (s.current = null);
54
59
  };
55
- }, [p, s, c, d]), h(() => {
60
+ }, [v, r, c, l]), D(() => {
56
61
  var n;
57
- (n = o.current) == null || n.clock.step(i, Date.now());
58
- }, [i]), { markSaved: L(() => {
59
- const n = o.current;
62
+ (n = s.current) == null || n.clock.step(a, Date.now());
63
+ }, [a]);
64
+ const m = E(() => {
65
+ const n = s.current;
60
66
  n && (n.saved || (n.saveMs = n.elapsed + n.clock.peek(Date.now())), n.saved = !0);
61
- }, []) };
67
+ }, []), k = E(
68
+ (n, e) => {
69
+ var t;
70
+ return (t = s.current) == null ? void 0 : t.refusals.note(n, e);
71
+ },
72
+ []
73
+ );
74
+ return B(() => ({ markSaved: m, markRefused: k }), [m, k]);
62
75
  }
63
76
  export {
64
- V as useFormUsageBeacon
77
+ J as useFormUsageBeacon
65
78
  };