@nivaro/react 0.3.49 → 0.3.51

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 (46) hide show
  1. package/dist/components/InlineGridField.js +166 -105
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +38 -4
  5. package/dist/shared/components/ItemEditForm.js +5258 -5034
  6. package/dist/shared/components/QueryTable.js +489 -347
  7. package/dist/shared/components/ReportView.js +105 -99
  8. package/dist/shared/components/alerts/AlertManagerView.js +327 -301
  9. package/dist/shared/components/item-edit/CatalogPickerField.js +1230 -1175
  10. package/dist/shared/components/item-edit/CloneDialog.js +192 -142
  11. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +58 -53
  12. package/dist/shared/components/item-edit/FieldRenderer.js +249 -244
  13. package/dist/shared/components/item-edit/FieldRow.js +402 -370
  14. package/dist/shared/components/item-edit/FilePickerField.js +315 -307
  15. package/dist/shared/components/item-edit/InlineGridField.js +92 -90
  16. package/dist/shared/components/item-edit/InlineTableField.js +3119 -2951
  17. package/dist/shared/components/item-edit/MidairCollisionDialog.js +175 -0
  18. package/dist/shared/components/item-edit/PlanGrid.js +162 -162
  19. package/dist/shared/components/item-edit/PolishFields.js +169 -162
  20. package/dist/shared/components/item-edit/RecordHeaderActions.js +76 -75
  21. package/dist/shared/components/item-edit/RecordLiveSync.js +93 -91
  22. package/dist/shared/components/item-edit/RelationCombobox.js +198 -191
  23. package/dist/shared/components/item-edit/SummaryPanel.js +282 -259
  24. package/dist/shared/components/item-edit/UserChip.js +233 -200
  25. package/dist/shared/components/item-edit/ValidationSummary.js +64 -47
  26. package/dist/shared/components/item-edit/header-midair.js +51 -0
  27. package/dist/shared/components/item-edit/helpers.js +181 -155
  28. package/dist/shared/components/item-edit/line-midair.js +207 -0
  29. package/dist/shared/components/item-edit/soft-rules.js +27 -0
  30. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  31. package/dist/shared/components/panels/CommentPanel.js +290 -284
  32. package/dist/shared/components/panels/ItemLockBanner.js +414 -358
  33. package/dist/shared/components/panels/PipelinePanel.js +1241 -992
  34. package/dist/shared/components/panels/RecordIntegrityBanner.js +1 -1
  35. package/dist/shared/components/panels/TaskPanel.js +71 -61
  36. package/dist/shared/components/panels/TransitionRequirementsDialog.js +569 -439
  37. package/dist/shared/components/panels/requirement-side-effects.js +40 -0
  38. package/dist/shared/components/queue/QueueWorklist.js +925 -871
  39. package/dist/shared/components/queue/column-chooser.js +21 -0
  40. package/dist/shared/components/queue/live-state-aspect.js +6 -0
  41. package/dist/shared/components/ui/number-draft-input.js +93 -0
  42. package/dist/shared/components/widgets/ReviewListWidget.js +191 -166
  43. package/dist/shared/lib/draft-store.js +48 -34
  44. package/dist/shared/lib/error-hints.js +1 -0
  45. package/dist/shared/lib/query-stats.js +60 -60
  46. package/package.json +1 -1
@@ -1,209 +1,259 @@
1
- import { jsxs as r, jsx as t } from "react/jsx-runtime";
2
- import { Copy as O, RotateCcw as T } from "lucide-react";
3
- import { useState as b } from "react";
4
- import { toast as v } from "sonner";
5
- import { useNivaroClient as $ } from "../../context.js";
6
- import { post as q } from "../../lib/commands.js";
7
- import { titleCase as E, cn as R } from "../../lib/utils.js";
1
+ import { jsxs as a, jsx as t } from "react/jsx-runtime";
2
+ import { Copy as O, RotateCcw as $ } from "lucide-react";
3
+ import { useState as N } from "react";
4
+ import { toast as b } from "sonner";
5
+ import { useNivaroClient as q } from "../../context.js";
6
+ import { post as E } from "../../lib/commands.js";
7
+ import { titleCase as H, cn as R } from "../../lib/utils.js";
8
8
  import { Button as w } from "../ui/button.js";
9
- import { Dialog as H, DialogTrigger as K, DialogContent as P, DialogHeader as Y, DialogTitle as A, DialogFooter as G } from "../ui/dialog.js";
10
- import { Input as m } from "../ui/input.js";
9
+ import { Dialog as K, DialogTrigger as P, DialogContent as Y, DialogHeader as A, DialogTitle as G, DialogFooter as Q } from "../ui/dialog.js";
10
+ import { Input as v } from "../ui/input.js";
11
11
  import { Label as z } from "../ui/label.js";
12
- import { Switch as B } from "../ui/switch.js";
13
- const Q = /* @__PURE__ */ new Set(["id", "created_at", "updated_at", "created_by", "updated_by"]);
14
- function U(l, n, s) {
15
- if (Q.has(l.field) || l.computed_formula) return !1;
16
- const i = l.interface ?? "";
17
- return !(["sub_rows", "repeater", "rich_text", "file", "image", "o2m", "m2m", "m2a"].includes(i) || ["sub_rows", "repeater", "rich_text"].includes(l.type) || n.some((p) => p.one_collection === s && p.one_field === l.field));
12
+ import { NumberDraftInput as L } from "../ui/number-draft-input.js";
13
+ import { Switch as j } from "../ui/switch.js";
14
+ const U = /* @__PURE__ */ new Set(["id", "created_at", "updated_at", "created_by", "updated_by"]);
15
+ function V(n, l, r) {
16
+ if (U.has(n.field) || n.computed_formula) return !1;
17
+ const s = n.interface ?? "";
18
+ return !(["sub_rows", "repeater", "rich_text", "file", "image", "o2m", "m2m", "m2a"].includes(s) || ["sub_rows", "repeater", "rich_text"].includes(n.type) || l.some((f) => f.one_collection === r && f.one_field === n.field));
18
19
  }
19
- function W(l) {
20
- return l.interface === "sub_rows" || l.type === "sub_rows";
20
+ function W(n) {
21
+ return n.interface === "sub_rows" || n.type === "sub_rows";
21
22
  }
22
- function X(l) {
23
- if (!l) return "";
23
+ function X(n) {
24
+ if (!n) return "";
24
25
  try {
25
- return new Date(String(l)).toISOString().slice(0, 16);
26
+ return new Date(String(n)).toISOString().slice(0, 16);
26
27
  } catch {
27
28
  return "";
28
29
  }
29
30
  }
30
- function Z({ field: l, value: n, onChange: s }) {
31
- return l.type === "boolean" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
31
+ function Z({
32
+ field: n,
33
+ value: l,
34
+ onChange: r
35
+ }) {
36
+ return n.type === "boolean" ? /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
32
37
  /* @__PURE__ */ t(
33
38
  "input",
34
39
  {
35
40
  type: "checkbox",
36
- checked: !!n,
37
- onChange: (i) => s(i.target.checked),
41
+ checked: !!l,
42
+ onChange: (s) => r(s.target.checked),
38
43
  className: "h-4 w-4 accent-nvr-cyan rounded"
39
44
  }
40
45
  ),
41
- /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: n ? "Yes" : "No" })
42
- ] }) : l.type === "datetime" || l.interface === "datetime" ? /* @__PURE__ */ t(
43
- m,
46
+ /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: l ? "Yes" : "No" })
47
+ ] }) : n.type === "datetime" || n.interface === "datetime" ? /* @__PURE__ */ t(
48
+ v,
44
49
  {
45
50
  type: "datetime-local",
46
- value: X(n),
47
- onChange: (i) => s(i.target.value ? new Date(i.target.value).toISOString() : null),
51
+ value: X(l),
52
+ onChange: (s) => r(s.target.value ? new Date(s.target.value).toISOString() : null),
48
53
  className: "h-7 text-[12px]"
49
54
  }
50
- ) : l.type === "date" ? /* @__PURE__ */ t(
51
- m,
55
+ ) : n.type === "date" ? /* @__PURE__ */ t(
56
+ v,
52
57
  {
53
58
  type: "date",
54
- value: n ? String(n).slice(0, 10) : "",
55
- onChange: (i) => s(i.target.value || null),
59
+ value: l ? String(l).slice(0, 10) : "",
60
+ onChange: (s) => r(s.target.value || null),
56
61
  className: "h-7 text-[12px]"
57
62
  }
58
- ) : l.type === "integer" || l.type === "bigInteger" ? /* @__PURE__ */ t(
59
- m,
63
+ ) : n.type === "integer" || n.type === "bigInteger" ? /* @__PURE__ */ t(
64
+ L,
60
65
  {
61
66
  type: "number",
62
67
  step: "1",
63
- value: n == null ? "" : String(n),
64
- onChange: (i) => s(i.target.value === "" ? null : Number(i.target.value)),
68
+ value: l,
69
+ onValue: r,
65
70
  className: "h-7 text-[12px]"
66
71
  }
67
- ) : l.type === "float" || l.type === "decimal" || l.type === "double" ? /* @__PURE__ */ t(
68
- m,
72
+ ) : n.type === "float" || n.type === "decimal" || n.type === "double" ? /* @__PURE__ */ t(
73
+ L,
69
74
  {
70
75
  type: "number",
71
76
  step: "any",
72
- value: n == null ? "" : String(n),
73
- onChange: (i) => s(i.target.value === "" ? null : Number(i.target.value)),
77
+ value: l,
78
+ onValue: r,
74
79
  className: "h-7 text-[12px]"
75
80
  }
76
81
  ) : /* @__PURE__ */ t(
77
- m,
82
+ v,
78
83
  {
79
- value: n == null ? "" : String(n),
80
- onChange: (i) => s(i.target.value || null),
84
+ value: l == null ? "" : String(l),
85
+ onChange: (s) => r(s.target.value || null),
81
86
  className: "h-7 text-[12px]",
82
87
  placeholder: "(empty)"
83
88
  }
84
89
  );
85
90
  }
86
- function ue({ collection: l, itemId: n, fields: s, relations: i, currentValues: f, onSuccess: p }) {
87
- const L = $(), [j, h] = b(!1), [C, S] = b(!1), [k, g] = b({}), [_, I] = b({}), x = s.filter((e) => U(e, i, l)), y = s.filter(W);
88
- function J() {
91
+ function fe({
92
+ collection: n,
93
+ itemId: l,
94
+ fields: r,
95
+ relations: s,
96
+ currentValues: m,
97
+ onSuccess: f
98
+ }) {
99
+ const B = q(), [J, p] = N(!1), [C, k] = N(!1), [S, h] = N({}), [_, I] = N({}), x = r.filter((e) => V(e, s, n)), g = r.filter(W);
100
+ function M() {
89
101
  const e = {};
90
102
  for (const o of x)
91
- e[o.field] = { include: !0, value: f[o.field] ?? null };
92
- g(e);
93
- const a = {};
94
- for (const o of y) a[o.field] = !0;
95
- I(a), h(!0);
103
+ e[o.field] = { include: !0, value: m[o.field] ?? null };
104
+ h(e);
105
+ const i = {};
106
+ for (const o of g) i[o.field] = !0;
107
+ I(i), p(!0);
96
108
  }
97
- function D(e, a) {
98
- return JSON.stringify(a.value) !== JSON.stringify(f[e] ?? null);
109
+ function D(e, i) {
110
+ return JSON.stringify(i.value) !== JSON.stringify(m[e] ?? null);
99
111
  }
100
- async function M() {
112
+ async function T() {
101
113
  var e;
102
- S(!0);
114
+ k(!0);
103
115
  try {
104
- const a = {}, o = [];
116
+ const i = {}, o = [];
105
117
  for (const d of x) {
106
- const N = k[d.field];
107
- if (N) {
108
- if (!N.include) {
118
+ const y = S[d.field];
119
+ if (y) {
120
+ if (!y.include) {
109
121
  o.push(d.field);
110
122
  continue;
111
123
  }
112
- D(d.field, N) && (a[d.field] = N.value);
124
+ D(d.field, y) && (i[d.field] = y.value);
113
125
  }
114
126
  }
115
- const c = y.filter((d) => _[d.field]).map((d) => d.field), u = await L.request(
116
- q(`/items/${l}/${n}/clone`, { field_overrides: a, exclude_fields: o, include_sub_rows: c })
127
+ const c = g.filter((d) => _[d.field]).map((d) => d.field), u = await B.request(
128
+ E(`/items/${n}/${l}/clone`, {
129
+ field_overrides: i,
130
+ exclude_fields: o,
131
+ include_sub_rows: c
132
+ })
117
133
  );
118
- h(!1);
134
+ p(!1);
119
135
  const F = (e = u == null ? void 0 : u.data) == null ? void 0 : e.id;
120
136
  if (F == null) {
121
- v.success("Item cloned — open it from the list");
137
+ b.success("Item cloned — open it from the list");
122
138
  return;
123
139
  }
124
- v.success("Item cloned"), p(F);
140
+ b.success("Item cloned"), f(F);
125
141
  } catch {
126
- v.error("Failed to clone item");
142
+ b.error("Failed to clone item");
127
143
  } finally {
128
- S(!1);
144
+ k(!1);
129
145
  }
130
146
  }
131
- return /* @__PURE__ */ r(H, { open: j, onOpenChange: (e) => {
132
- e ? J() : h(!1);
133
- }, children: [
134
- /* @__PURE__ */ t(K, { asChild: !0, children: /* @__PURE__ */ r(w, { size: "sm", variant: "outline", className: "gap-1.5", children: [
135
- /* @__PURE__ */ t(O, { className: "h-3.5 w-3.5" }),
136
- "Clone"
137
- ] }) }),
138
- /* @__PURE__ */ r(P, { className: "flex max-h-[85vh] max-w-lg flex-col overflow-hidden", children: [
139
- /* @__PURE__ */ t(Y, { className: "shrink-0 px-6 pt-6", children: /* @__PURE__ */ t(A, { className: "text-[15px]", children: "Clone item" }) }),
140
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-y-auto px-6 py-4", children: /* @__PURE__ */ r("div", { className: "space-y-4", children: [
141
- x.length > 0 && /* @__PURE__ */ r("div", { children: [
142
- /* @__PURE__ */ t("p", { className: "mb-2 text-[11px] font-medium uppercase tracking-wide text-slate-400", children: "Field values" }),
143
- /* @__PURE__ */ t("div", { className: "space-y-2", children: x.map((e) => {
144
- const a = k[e.field];
145
- if (!a) return null;
146
- const o = D(e.field, a);
147
- return /* @__PURE__ */ r("div", { className: "flex items-start gap-2", children: [
148
- /* @__PURE__ */ t(
149
- B,
150
- {
151
- checked: a.include,
152
- onCheckedChange: () => g((c) => ({ ...c, [e.field]: { ...c[e.field], include: !c[e.field].include } })),
153
- className: "mt-1 shrink-0 scale-75"
154
- }
155
- ),
156
- /* @__PURE__ */ t(z, { className: R("mt-1.5 w-32 shrink-0 truncate text-[12px]", !a.include && "text-slate-400 line-through"), children: E(e.field) }),
157
- /* @__PURE__ */ t("div", { className: R("flex-1", !a.include && "pointer-events-none opacity-40"), children: /* @__PURE__ */ t(
158
- Z,
159
- {
160
- field: e,
161
- value: a.value,
162
- onChange: (c) => g((u) => ({ ...u, [e.field]: { ...u[e.field], value: c } }))
163
- }
164
- ) }),
165
- o && a.include && /* @__PURE__ */ t(
166
- "button",
167
- {
168
- type: "button",
169
- title: "Reset to original",
170
- onClick: () => g((c) => ({ ...c, [e.field]: { ...c[e.field], value: f[e.field] ?? null } })),
171
- className: "mt-1.5 shrink-0 text-slate-400 hover:text-slate-600",
172
- children: /* @__PURE__ */ t(T, { className: "h-3.5 w-3.5" })
173
- }
174
- )
175
- ] }, e.field);
176
- }) })
177
- ] }),
178
- y.length > 0 && /* @__PURE__ */ r("div", { children: [
179
- /* @__PURE__ */ t("p", { className: "mb-2 text-[11px] font-medium uppercase tracking-wide text-slate-400", children: "Sub-rows" }),
180
- /* @__PURE__ */ t("div", { className: "space-y-2", children: y.map((e) => /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
181
- /* @__PURE__ */ t(
182
- B,
183
- {
184
- checked: !!_[e.field],
185
- onCheckedChange: (a) => I((o) => ({ ...o, [e.field]: a })),
186
- className: "shrink-0 scale-75"
187
- }
188
- ),
189
- /* @__PURE__ */ r(z, { className: "text-[12px]", children: [
190
- "Include ",
191
- /* @__PURE__ */ t("span", { className: "font-mono", children: e.field }),
192
- " sub-rows"
147
+ return /* @__PURE__ */ a(
148
+ K,
149
+ {
150
+ open: J,
151
+ onOpenChange: (e) => {
152
+ e ? M() : p(!1);
153
+ },
154
+ children: [
155
+ /* @__PURE__ */ t(P, { asChild: !0, children: /* @__PURE__ */ a(w, { size: "sm", variant: "outline", className: "gap-1.5", children: [
156
+ /* @__PURE__ */ t(O, { className: "h-3.5 w-3.5" }),
157
+ "Clone"
158
+ ] }) }),
159
+ /* @__PURE__ */ a(Y, { className: "flex max-h-[85vh] max-w-lg flex-col overflow-hidden", children: [
160
+ /* @__PURE__ */ t(A, { className: "shrink-0 px-6 pt-6", children: /* @__PURE__ */ t(G, { className: "text-[15px]", children: "Clone item" }) }),
161
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-y-auto px-6 py-4", children: /* @__PURE__ */ a("div", { className: "space-y-4", children: [
162
+ x.length > 0 && /* @__PURE__ */ a("div", { children: [
163
+ /* @__PURE__ */ t("p", { className: "mb-2 text-[11px] font-medium uppercase tracking-wide text-slate-400", children: "Field values" }),
164
+ /* @__PURE__ */ t("div", { className: "space-y-2", children: x.map((e) => {
165
+ const i = S[e.field];
166
+ if (!i) return null;
167
+ const o = D(e.field, i);
168
+ return /* @__PURE__ */ a("div", { className: "flex items-start gap-2", children: [
169
+ /* @__PURE__ */ t(
170
+ j,
171
+ {
172
+ checked: i.include,
173
+ onCheckedChange: () => h((c) => ({
174
+ ...c,
175
+ [e.field]: { ...c[e.field], include: !c[e.field].include }
176
+ })),
177
+ className: "mt-1 shrink-0 scale-75"
178
+ }
179
+ ),
180
+ /* @__PURE__ */ t(
181
+ z,
182
+ {
183
+ className: R(
184
+ "mt-1.5 w-32 shrink-0 truncate text-[12px]",
185
+ !i.include && "text-slate-400 line-through"
186
+ ),
187
+ children: H(e.field)
188
+ }
189
+ ),
190
+ /* @__PURE__ */ t(
191
+ "div",
192
+ {
193
+ className: R(
194
+ "flex-1",
195
+ !i.include && "pointer-events-none opacity-40"
196
+ ),
197
+ children: /* @__PURE__ */ t(
198
+ Z,
199
+ {
200
+ field: e,
201
+ value: i.value,
202
+ onChange: (c) => h((u) => ({
203
+ ...u,
204
+ [e.field]: { ...u[e.field], value: c }
205
+ }))
206
+ }
207
+ )
208
+ }
209
+ ),
210
+ o && i.include && /* @__PURE__ */ t(
211
+ "button",
212
+ {
213
+ type: "button",
214
+ title: "Reset to original",
215
+ onClick: () => h((c) => ({
216
+ ...c,
217
+ [e.field]: { ...c[e.field], value: m[e.field] ?? null }
218
+ })),
219
+ className: "mt-1.5 shrink-0 text-slate-400 hover:text-slate-600",
220
+ children: /* @__PURE__ */ t($, { className: "h-3.5 w-3.5" })
221
+ }
222
+ )
223
+ ] }, e.field);
224
+ }) })
225
+ ] }),
226
+ g.length > 0 && /* @__PURE__ */ a("div", { children: [
227
+ /* @__PURE__ */ t("p", { className: "mb-2 text-[11px] font-medium uppercase tracking-wide text-slate-400", children: "Sub-rows" }),
228
+ /* @__PURE__ */ t("div", { className: "space-y-2", children: g.map((e) => /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
229
+ /* @__PURE__ */ t(
230
+ j,
231
+ {
232
+ checked: !!_[e.field],
233
+ onCheckedChange: (i) => I((o) => ({ ...o, [e.field]: i })),
234
+ className: "shrink-0 scale-75"
235
+ }
236
+ ),
237
+ /* @__PURE__ */ a(z, { className: "text-[12px]", children: [
238
+ "Include ",
239
+ /* @__PURE__ */ t("span", { className: "font-mono", children: e.field }),
240
+ " sub-rows"
241
+ ] })
242
+ ] }, e.field)) })
193
243
  ] })
194
- ] }, e.field)) })
195
- ] })
196
- ] }) }),
197
- /* @__PURE__ */ r(G, { className: "shrink-0 border-t border-slate-100 px-6 py-4 dark:border-border", children: [
198
- /* @__PURE__ */ t(w, { variant: "outline", size: "sm", onClick: () => h(!1), children: "Cancel" }),
199
- /* @__PURE__ */ r(w, { size: "sm", disabled: C, onClick: M, children: [
200
- /* @__PURE__ */ t(O, { className: "mr-1.5 h-3.5 w-3.5" }),
201
- C ? "Cloning…" : "Clone"
244
+ ] }) }),
245
+ /* @__PURE__ */ a(Q, { className: "shrink-0 border-t border-slate-100 px-6 py-4 dark:border-border", children: [
246
+ /* @__PURE__ */ t(w, { variant: "outline", size: "sm", onClick: () => p(!1), children: "Cancel" }),
247
+ /* @__PURE__ */ a(w, { size: "sm", disabled: C, onClick: T, children: [
248
+ /* @__PURE__ */ t(O, { className: "mr-1.5 h-3.5 w-3.5" }),
249
+ C ? "Cloning…" : "Clone"
250
+ ] })
251
+ ] })
202
252
  ] })
203
- ] })
204
- ] })
205
- ] });
253
+ ]
254
+ }
255
+ );
206
256
  }
207
257
  export {
208
- ue as CloneDialog
258
+ fe as CloneDialog
209
259
  };
@@ -1,139 +1,144 @@
1
- import { jsxs as t, jsx as n } from "react/jsx-runtime";
2
- import { History as _, ExternalLink as C, RotateCcw as R, Trash2 as S } from "lucide-react";
3
- import { useState as D } from "react";
1
+ import { jsxs as a, jsx as n } from "react/jsx-runtime";
2
+ import { History as R, ExternalLink as S, RotateCcw as D, Trash2 as T } from "lucide-react";
3
+ import { useState as N, useEffect as E } from "react";
4
4
  import { useItemNavigation as H } from "../../context.js";
5
- import { formatRelative as v, titleCase as k } from "../../lib/utils.js";
6
- const w = (r) => {
7
- if (r == null || r === "") return "empty";
8
- if (typeof r == "boolean") return r ? "Yes" : "No";
9
- const c = typeof r == "object" ? JSON.stringify(r) : String(r);
5
+ import { formatRelative as k, titleCase as w } from "../../lib/utils.js";
6
+ const y = (t) => {
7
+ if (t == null || t === "") return "empty";
8
+ if (typeof t == "boolean") return t ? "Yes" : "No";
9
+ const c = typeof t == "object" ? JSON.stringify(t) : String(t);
10
10
  return c.length > 60 ? `${c.slice(0, 60)}…` : c;
11
11
  };
12
- function L({
13
- draft: r,
12
+ function q({
13
+ draft: t,
14
14
  labelFor: c,
15
- current: g,
16
- recordChanged: y,
17
- onRestore: $,
18
- onDiscard: j,
15
+ current: f,
16
+ recordChanged: $,
17
+ onRestore: j,
18
+ onDiscard: O,
19
19
  createdId: s = null,
20
20
  collection: x,
21
21
  renderValue: p
22
22
  }) {
23
- const [f, O] = D(!1), N = H(), b = Object.entries(r.fields ?? {}), h = s !== null, u = Object.values(r.pending_rows ?? {}).reduce((e, a) => e + a.length, 0), l = Object.values(r.pending_edits ?? {}).reduce(
24
- (e, a) => e + Object.keys(a).length,
23
+ const [g, _] = N(!1), [, C] = N(0);
24
+ E(() => {
25
+ const e = setInterval(() => C((r) => r + 1), 3e4);
26
+ return () => clearInterval(e);
27
+ }, []);
28
+ const v = H(), b = Object.entries(t.fields ?? {}), h = s !== null, u = Object.values(t.pending_rows ?? {}).reduce((e, r) => e + r.length, 0), l = Object.values(t.pending_edits ?? {}).reduce(
29
+ (e, r) => e + Object.keys(r).length,
25
30
  0
26
- ), o = Object.values(r.pending_deletes ?? {}).reduce((e, a) => e + a.length, 0), m = Object.values(r.m2m_links ?? {}).reduce((e, a) => e + a.length, 0), d = Object.values(r.m2m_unlinks ?? {}).reduce((e, a) => e + a.length, 0), i = [];
27
- return b.length && i.push(`${b.length} field${b.length === 1 ? "" : "s"}`), u && i.push(`${u} new line${u === 1 ? "" : "s"}`), l && i.push(`${l} line edit${l === 1 ? "" : "s"}`), o && i.push(`${o} line removal${o === 1 ? "" : "s"}`), m && i.push(`${m} link${m === 1 ? "" : "s"}`), d && i.push(`${d} unlink${d === 1 ? "" : "s"}`), /* @__PURE__ */ t(
31
+ ), o = Object.values(t.pending_deletes ?? {}).reduce((e, r) => e + r.length, 0), m = Object.values(t.m2m_links ?? {}).reduce((e, r) => e + r.length, 0), d = Object.values(t.m2m_unlinks ?? {}).reduce((e, r) => e + r.length, 0), i = [];
32
+ return b.length && i.push(`${b.length} field${b.length === 1 ? "" : "s"}`), u && i.push(`${u} new line${u === 1 ? "" : "s"}`), l && i.push(`${l} line edit${l === 1 ? "" : "s"}`), o && i.push(`${o} line removal${o === 1 ? "" : "s"}`), m && i.push(`${m} link${m === 1 ? "" : "s"}`), d && i.push(`${d} unlink${d === 1 ? "" : "s"}`), /* @__PURE__ */ a(
28
33
  "div",
29
34
  {
30
35
  className: "mb-2 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-[12.5px] text-amber-900 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-200",
31
36
  "data-nvr-draft-recovery": !0,
32
37
  children: [
33
- /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-2", children: [
34
- /* @__PURE__ */ n(_, { className: "h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400" }),
35
- /* @__PURE__ */ t("span", { className: "min-w-0 flex-1", children: [
36
- h ? /* @__PURE__ */ t("span", { className: "font-semibold", "data-nvr-draft-created": !0, children: [
38
+ /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2", children: [
39
+ /* @__PURE__ */ n(R, { className: "h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400" }),
40
+ /* @__PURE__ */ a("span", { className: "min-w-0 flex-1", children: [
41
+ h ? /* @__PURE__ */ a("span", { className: "font-semibold", "data-nvr-draft-created": !0, children: [
37
42
  "These changes from ",
38
- v(r.saved_at),
43
+ k(t.saved_at),
39
44
  " were already saved",
40
45
  s ? ` as record ${s}` : " as a new record",
41
46
  " — restoring them makes a second one."
42
- ] }) : /* @__PURE__ */ t("span", { className: "font-semibold", children: [
47
+ ] }) : /* @__PURE__ */ a("span", { className: "font-semibold", children: [
43
48
  "Restore your unsaved changes from ",
44
- v(r.saved_at),
49
+ k(t.saved_at),
45
50
  "?"
46
51
  ] }),
47
52
  " ",
48
53
  /* @__PURE__ */ n("span", { className: "text-amber-800/80 dark:text-amber-200/80", children: i.join(" · ") }),
49
- y && /* @__PURE__ */ n("span", { className: "ml-1 rounded bg-amber-200/70 px-1 py-px text-[10.5px] font-semibold uppercase tracking-wide text-amber-900 dark:bg-amber-500/30 dark:text-amber-100", children: "record changed since — review before restoring" })
54
+ $ && /* @__PURE__ */ n("span", { className: "ml-1 rounded bg-amber-200/70 px-1 py-px text-[10.5px] font-semibold uppercase tracking-wide text-amber-900 dark:bg-amber-500/30 dark:text-amber-100", children: "record changed since — review before restoring" })
50
55
  ] }),
51
56
  /* @__PURE__ */ n(
52
57
  "button",
53
58
  {
54
59
  type: "button",
55
- onClick: () => O((e) => !e),
60
+ onClick: () => _((e) => !e),
56
61
  className: "text-[11.5px] underline decoration-dotted underline-offset-2",
57
- children: f ? "Hide changes" : "Show changes"
62
+ children: g ? "Hide changes" : "Show changes"
58
63
  }
59
64
  ),
60
- h && s && x && /* @__PURE__ */ t(
65
+ h && s && x && /* @__PURE__ */ a(
61
66
  "a",
62
67
  {
63
- href: N.urlFor({ collection: x, itemId: s }),
68
+ href: v.urlFor({ collection: x, itemId: s }),
64
69
  onClick: (e) => {
65
- e.preventDefault(), N.open({ collection: x, itemId: s });
70
+ e.preventDefault(), v.open({ collection: x, itemId: s });
66
71
  },
67
72
  className: "inline-flex h-7 items-center gap-1 rounded-md bg-amber-600 px-2.5 text-[11.5px] font-semibold text-white hover:bg-amber-700",
68
73
  "data-nvr-draft-open-created": !0,
69
74
  children: [
70
- /* @__PURE__ */ n(C, { className: "h-3 w-3" }),
75
+ /* @__PURE__ */ n(S, { className: "h-3 w-3" }),
71
76
  " Open record ",
72
77
  s
73
78
  ]
74
79
  }
75
80
  ),
76
- /* @__PURE__ */ t(
81
+ /* @__PURE__ */ a(
77
82
  "button",
78
83
  {
79
84
  type: "button",
80
- onClick: $,
85
+ onClick: j,
81
86
  className: h ? "inline-flex h-7 items-center gap-1 rounded-md border border-amber-300 px-2.5 text-[11.5px] font-medium hover:bg-amber-100 dark:border-amber-500/40 dark:hover:bg-amber-500/15" : "inline-flex h-7 items-center gap-1 rounded-md bg-amber-600 px-2.5 text-[11.5px] font-semibold text-white hover:bg-amber-700",
82
87
  "data-nvr-draft-restore": !0,
83
88
  children: [
84
- /* @__PURE__ */ n(R, { className: "h-3 w-3" }),
89
+ /* @__PURE__ */ n(D, { className: "h-3 w-3" }),
85
90
  " ",
86
91
  h ? "Restore anyway" : "Restore"
87
92
  ]
88
93
  }
89
94
  ),
90
- /* @__PURE__ */ t(
95
+ /* @__PURE__ */ a(
91
96
  "button",
92
97
  {
93
98
  type: "button",
94
- onClick: j,
99
+ onClick: O,
95
100
  className: "inline-flex h-7 items-center gap-1 rounded-md border border-amber-300 px-2.5 text-[11.5px] font-medium hover:bg-amber-100 dark:border-amber-500/40 dark:hover:bg-amber-500/15",
96
101
  "data-nvr-draft-discard": !0,
97
102
  children: [
98
- /* @__PURE__ */ n(S, { className: "h-3 w-3" }),
103
+ /* @__PURE__ */ n(T, { className: "h-3 w-3" }),
99
104
  " Discard"
100
105
  ]
101
106
  }
102
107
  )
103
108
  ] }),
104
- f && /* @__PURE__ */ t("div", { className: "mt-2 max-h-[240px] space-y-1 overflow-y-auto border-t border-amber-200/70 pt-2 dark:border-amber-500/30", children: [
105
- b.map(([e, a]) => /* @__PURE__ */ t("div", { className: "text-[11.5px]", children: [
106
- /* @__PURE__ */ n("span", { className: "font-medium", children: c(e) || k(e.replace(/_/g, " ")) }),
107
- /* @__PURE__ */ t("p", { className: "break-words text-amber-800/80 dark:text-amber-200/80", children: [
108
- /* @__PURE__ */ n("span", { className: "line-through opacity-70", children: p ? p(e, g[e]) : w(g[e]) }),
109
+ g && /* @__PURE__ */ a("div", { className: "mt-2 max-h-[240px] space-y-1 overflow-y-auto border-t border-amber-200/70 pt-2 dark:border-amber-500/30", children: [
110
+ b.map(([e, r]) => /* @__PURE__ */ a("div", { className: "text-[11.5px]", children: [
111
+ /* @__PURE__ */ n("span", { className: "font-medium", children: c(e) || w(e.replace(/_/g, " ")) }),
112
+ /* @__PURE__ */ a("p", { className: "break-words text-amber-800/80 dark:text-amber-200/80", children: [
113
+ /* @__PURE__ */ n("span", { className: "line-through opacity-70", children: p ? p(e, f[e]) : y(f[e]) }),
109
114
  " ",
110
- /* @__PURE__ */ n("span", { className: "font-medium text-amber-900 dark:text-amber-100", children: p ? p(e, a) : w(a) })
115
+ /* @__PURE__ */ n("span", { className: "font-medium text-amber-900 dark:text-amber-100", children: p ? p(e, r) : y(r) })
111
116
  ] })
112
117
  ] }, e)),
113
- Object.entries(r.pending_rows ?? {}).filter(([, e]) => e.length > 0).map(([e, a]) => /* @__PURE__ */ t("p", { className: "text-[11.5px]", children: [
114
- a.length,
118
+ Object.entries(t.pending_rows ?? {}).filter(([, e]) => e.length > 0).map(([e, r]) => /* @__PURE__ */ a("p", { className: "text-[11.5px]", children: [
119
+ r.length,
115
120
  " new line",
116
- a.length === 1 ? "" : "s",
121
+ r.length === 1 ? "" : "s",
117
122
  " in",
118
123
  " ",
119
- k(e.split(".")[0].replace(/_/g, " "))
124
+ w(e.split(".")[0].replace(/_/g, " "))
120
125
  ] }, e)),
121
- l > 0 && /* @__PURE__ */ t("p", { className: "text-[11.5px]", children: [
126
+ l > 0 && /* @__PURE__ */ a("p", { className: "text-[11.5px]", children: [
122
127
  l,
123
128
  " edited line",
124
129
  l === 1 ? "" : "s"
125
130
  ] }),
126
- o > 0 && /* @__PURE__ */ t("p", { className: "text-[11.5px]", children: [
131
+ o > 0 && /* @__PURE__ */ a("p", { className: "text-[11.5px]", children: [
127
132
  o,
128
133
  " line removal",
129
134
  o === 1 ? "" : "s"
130
135
  ] }),
131
- m > 0 && /* @__PURE__ */ t("p", { className: "text-[11.5px]", children: [
136
+ m > 0 && /* @__PURE__ */ a("p", { className: "text-[11.5px]", children: [
132
137
  m,
133
138
  " relation link",
134
139
  m === 1 ? "" : "s"
135
140
  ] }),
136
- d > 0 && /* @__PURE__ */ t("p", { className: "text-[11.5px]", children: [
141
+ d > 0 && /* @__PURE__ */ a("p", { className: "text-[11.5px]", children: [
137
142
  d,
138
143
  " relation removal",
139
144
  d === 1 ? "" : "s"
@@ -144,5 +149,5 @@ function L({
144
149
  );
145
150
  }
146
151
  export {
147
- L as DraftRecoveryBanner
152
+ q as DraftRecoveryBanner
148
153
  };