@nivaro/react 0.3.111 → 0.3.112

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 (75) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +170 -2
  4. package/dist/index.js +745 -728
  5. package/dist/shared/components/CollectionBrowserView.js +3097 -2972
  6. package/dist/shared/components/CollectionImportBanner.js +135 -0
  7. package/dist/shared/components/ItemEditForm.js +2235 -2218
  8. package/dist/shared/components/JobsTray.js +54 -47
  9. package/dist/shared/components/ViewAsPersonButton.js +109 -0
  10. package/dist/shared/components/bulk/BulkFieldUpdate.js +228 -150
  11. package/dist/shared/components/bulk/BulkFieldUpdateButton.js +35 -41
  12. package/dist/shared/components/bulk/BulkLinksValue.js +91 -0
  13. package/dist/shared/components/bulk/bulk-field-options.js +20 -19
  14. package/dist/shared/components/bulk/bulk-update-preview.js +39 -0
  15. package/dist/shared/components/cbv/ColumnHeaderMenu.js +113 -0
  16. package/dist/shared/components/cbv/column-totals.js +66 -0
  17. package/dist/shared/components/collections-directory/CollectionHoverCard.js +108 -81
  18. package/dist/shared/components/collections-directory/CollectionRow.js +164 -148
  19. package/dist/shared/components/collections-directory/CollectionsDirectory.js +167 -166
  20. package/dist/shared/components/collections-directory/directory-data.js +70 -58
  21. package/dist/shared/components/imports/CollectionImportPanel.js +120 -118
  22. package/dist/shared/components/imports/DefinitionsPanel.js +24 -24
  23. package/dist/shared/components/imports/ImportDuplicatesNotice.js +65 -0
  24. package/dist/shared/components/item-edit/CatalogPickerField.js +631 -639
  25. package/dist/shared/components/item-edit/DuplicateNotice.js +168 -0
  26. package/dist/shared/components/item-edit/FieldRow.js +248 -246
  27. package/dist/shared/components/item-edit/InlineGridField.js +34 -33
  28. package/dist/shared/components/item-edit/InlineTableField.js +3064 -2882
  29. package/dist/shared/components/item-edit/MembershipSetField.js +165 -169
  30. package/dist/shared/components/item-edit/NestedRelationEditor.js +184 -189
  31. package/dist/shared/components/item-edit/PlanGrid.js +2 -1
  32. package/dist/shared/components/item-edit/QuickPickerDialog.js +35 -34
  33. package/dist/shared/components/item-edit/RecordLiveSync.js +32 -30
  34. package/dist/shared/components/item-edit/RelationCombobox.js +101 -100
  35. package/dist/shared/components/item-edit/RowHistorySheet.js +28 -27
  36. package/dist/shared/components/item-edit/SummaryPanel.js +133 -135
  37. package/dist/shared/components/item-edit/ViewAsRole.js +129 -52
  38. package/dist/shared/components/item-edit/grid-search.js +345 -0
  39. package/dist/shared/components/item-edit/render-stability.js +61 -54
  40. package/dist/shared/components/notifications/NotificationRulesEditor.js +25 -20
  41. package/dist/shared/components/ops-report/DigestSections.js +163 -144
  42. package/dist/shared/components/ops-report/drill.js +97 -97
  43. package/dist/shared/components/panels/AddendumLinesDiff.js +52 -51
  44. package/dist/shared/components/panels/AddendumPanel.js +92 -91
  45. package/dist/shared/components/panels/AsyncUserPicker.js +108 -0
  46. package/dist/shared/components/panels/CommentPanel.js +265 -252
  47. package/dist/shared/components/panels/OwnersSlot.js +47 -35
  48. package/dist/shared/components/panels/PipelineInsight.js +186 -0
  49. package/dist/shared/components/panels/PipelinePanel.js +1529 -1492
  50. package/dist/shared/components/panels/RecordIntegrityBanner.js +39 -38
  51. package/dist/shared/components/panels/RevisionsPanel.js +261 -260
  52. package/dist/shared/components/pipeline/FieldPicker.js +41 -40
  53. package/dist/shared/components/pipeline/OwnerMatrix.js +829 -700
  54. package/dist/shared/components/pipeline/OwnerRecordTrial.js +362 -0
  55. package/dist/shared/components/pipeline/PipelineEditorView.js +483 -467
  56. package/dist/shared/components/pipeline/PipelineStateOwners.js +65 -64
  57. package/dist/shared/components/pipeline/owner-matrix-draft.js +178 -0
  58. package/dist/shared/components/profile/MyDefaultsCard.js +36 -35
  59. package/dist/shared/components/profile/PersonHeader.js +29 -29
  60. package/dist/shared/components/profile/PersonProfile.js +30 -28
  61. package/dist/shared/components/profile/SlowScreensCard.js +286 -0
  62. package/dist/shared/components/queue/QueueWorklist.js +1090 -1071
  63. package/dist/shared/components/quick-filters/useQuickFilterEditing.js +45 -44
  64. package/dist/shared/components/support/TicketDetailSheet.js +25 -16
  65. package/dist/shared/components/support/TicketSlowScreens.js +32 -0
  66. package/dist/shared/lib/activity-sentence.js +224 -178
  67. package/dist/shared/lib/collection-import-banner.js +27 -0
  68. package/dist/shared/lib/crash-report.js +112 -0
  69. package/dist/shared/lib/export-runs.js +99 -0
  70. package/dist/shared/lib/jobs-tray.js +89 -67
  71. package/dist/shared/lib/list-link.js +76 -69
  72. package/dist/shared/lib/nav-trail.js +180 -76
  73. package/dist/shared/lib/query-keys.js +26 -0
  74. package/dist/shared/lib/view-as.js +16 -11
  75. package/package.json +1 -1
@@ -1,64 +1,72 @@
1
- import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
- import { useQuery as C } from "@tanstack/react-query";
3
- import { ArrowLeft as j, Lock as E } from "lucide-react";
4
- import { useState as F, useMemo as w } from "react";
5
- import { useNivaroClient as B } from "../../context.js";
6
- import { post as V, get as P } from "../../lib/commands.js";
7
- import { cn as U } from "../../lib/utils.js";
8
- import { FieldRenderer as D } from "../item-edit/FieldRenderer.js";
9
- import { Command as G, CommandInput as M, CommandList as Q, CommandEmpty as R, CommandGroup as Y, CommandItem as z } from "../ui/command.js";
10
- import { Popover as H, PopoverTrigger as I, PopoverContent as J } from "../ui/popover.js";
11
- import { Skeleton as f } from "../ui/skeleton.js";
12
- import { bulkFieldSections as W, bulkFieldNote as K } from "./bulk-field-options.js";
13
- function ce({
14
- collection: i,
15
- selectedIds: m,
16
- disabled: x,
17
- className: N,
18
- onApply: g,
19
- onSaveRecipe: p
1
+ import { jsxs as a, jsx as t, Fragment as ee } from "react/jsx-runtime";
2
+ import { useQuery as A } from "@tanstack/react-query";
3
+ import { ArrowLeft as te, Lock as re } from "lucide-react";
4
+ import { useState as g, useRef as W, useEffect as X, useMemo as j } from "react";
5
+ import { useNivaroClient as ae } from "../../context.js";
6
+ import { useDebounced as le } from "../../hooks/useDebounced.js";
7
+ import { post as Y, get as z } from "../../lib/commands.js";
8
+ import { cn as H } from "../../lib/utils.js";
9
+ import { FieldRenderer as ne } from "../item-edit/FieldRenderer.js";
10
+ import { Command as oe, CommandInput as de, CommandList as se, CommandEmpty as ie, CommandGroup as ue, CommandItem as ce } from "../ui/command.js";
11
+ import { Popover as me, PopoverTrigger as pe, PopoverContent as fe } from "../ui/popover.js";
12
+ import { Skeleton as x } from "../ui/skeleton.js";
13
+ import { BulkLinksValue as be } from "./BulkLinksValue.js";
14
+ import { bulkFieldSections as he, bulkFieldNote as R } from "./bulk-field-options.js";
15
+ import { bulkLinksValue as xe, bulkPreviewSentence as ge } from "./bulk-update-preview.js";
16
+ function Ee({
17
+ collection: d,
18
+ selectedIds: b,
19
+ disabled: i,
20
+ className: P,
21
+ onApply: T,
22
+ onSaveRecipe: w,
23
+ pointAt: u
20
24
  }) {
21
- const [y, a] = F(!1);
22
- return /* @__PURE__ */ t(
23
- H,
25
+ const [C, l] = g(!1), [y, L] = g(null), v = W(null);
26
+ return X(() => {
27
+ !u || i || u.nonce === v.current || (v.current = u.nonce, L(u.field), l(!0));
28
+ }, [u, i]), /* @__PURE__ */ a(
29
+ me,
24
30
  {
25
- open: y,
26
- onOpenChange: (n) => {
27
- (!x || !n) && a(n);
31
+ open: C,
32
+ onOpenChange: (o) => {
33
+ (!i || !o) && l(o), o || L(null);
28
34
  },
29
35
  children: [
30
- /* @__PURE__ */ e(I, { asChild: !0, children: /* @__PURE__ */ e(
36
+ /* @__PURE__ */ t(pe, { asChild: !0, children: /* @__PURE__ */ t(
31
37
  "button",
32
38
  {
33
39
  type: "button",
34
- disabled: x,
40
+ disabled: i,
35
41
  "data-bulk-update-field": !0,
36
- className: N,
42
+ className: P,
37
43
  "aria-haspopup": "dialog",
38
44
  children: "Update Field"
39
45
  }
40
46
  ) }),
41
- /* @__PURE__ */ e(
42
- J,
47
+ /* @__PURE__ */ t(
48
+ fe,
43
49
  {
44
50
  side: "top",
45
51
  align: "end",
46
52
  sideOffset: 8,
47
53
  className: "w-[380px] max-w-[calc(100vw-24px)] p-0",
48
- onOpenAutoFocus: (n) => n.preventDefault(),
49
- children: y && /* @__PURE__ */ e(
50
- X,
54
+ onOpenAutoFocus: (o) => o.preventDefault(),
55
+ children: C && /* @__PURE__ */ t(
56
+ ye,
51
57
  {
52
- collection: i,
53
- selectedIds: m,
54
- onCancel: () => a(!1),
55
- onApply: (n, b) => {
56
- a(!1), g(n, b);
58
+ collection: d,
59
+ selectedIds: b,
60
+ initialField: y,
61
+ onCancel: () => l(!1),
62
+ onApply: (o, e) => {
63
+ l(!1), T(o, e);
57
64
  },
58
- onSaveRecipe: p ? (n, b) => {
59
- a(!1), p(n, b);
65
+ onSaveRecipe: w ? (o, e) => {
66
+ l(!1), w(o, e);
60
67
  } : void 0
61
- }
68
+ },
69
+ y ?? ""
62
70
  )
63
71
  }
64
72
  )
@@ -66,128 +74,187 @@ function ce({
66
74
  }
67
75
  );
68
76
  }
69
- function X({
70
- collection: i,
71
- selectedIds: m,
72
- onCancel: x,
73
- onApply: N,
74
- onSaveRecipe: g
77
+ function ye({
78
+ collection: d,
79
+ selectedIds: b,
80
+ initialField: i,
81
+ onCancel: P,
82
+ onApply: T,
83
+ onSaveRecipe: w
75
84
  }) {
76
- var T, L, O;
77
- const p = B(), y = w(() => m.map(String).join(","), [m]), a = C({
78
- queryKey: ["bulk-fields", i, y],
79
- queryFn: () => p.request(
80
- V(`/items/${i}/bulk-fields`, { ids: m })
85
+ var J, D, G, Q;
86
+ const u = ae(), C = j(() => b.map(String).join(","), [b]), l = A({
87
+ queryKey: ["bulk-fields", d, C],
88
+ queryFn: () => u.request(
89
+ Y(`/items/${d}/bulk-fields`, { ids: b })
81
90
  ).then((r) => r.data),
82
91
  staleTime: 15e3,
83
92
  retry: !1
84
- }), n = C({
85
- queryKey: ["bulk-fields-config", i],
86
- queryFn: () => p.request(P(`/field-config/${i}`)).then((r) => Array.isArray(r.data) ? r.data : []),
93
+ }), y = A({
94
+ queryKey: ["bulk-fields-config", d],
95
+ queryFn: () => u.request(z(`/field-config/${d}`)).then((r) => Array.isArray(r.data) ? r.data : []),
87
96
  staleTime: 6e4
88
- }), b = C({
89
- queryKey: ["bulk-fields-relations", i],
90
- queryFn: () => p.request(P(`/data-model/relations/for/${i}`)).then((r) => Array.isArray(r.data) ? r.data : []),
97
+ }), L = A({
98
+ queryKey: ["bulk-fields-relations", d],
99
+ queryFn: () => u.request(z(`/data-model/relations/for/${d}`)).then((r) => Array.isArray(r.data) ? r.data : []),
91
100
  staleTime: 6e4
92
- }), A = w(() => {
101
+ }), v = j(() => {
93
102
  const r = {};
94
- for (const o of n.data ?? []) r[o.field] = o.label;
103
+ for (const n of y.data ?? []) r[n.field] = n.label;
95
104
  return r;
96
- }, [n.data]), $ = w(
97
- () => a.data ? W(a.data, A) : [],
98
- [a.data, A]
99
- ), [l, q] = F(null), [d, v] = F(null), s = ((T = a.data) == null ? void 0 : T.readable) ?? m.length, h = ((L = a.data) == null ? void 0 : L.forms) ?? [], S = a.data ? h.length === 0 ? "These records have no form, so every field you may change is listed." : h.length === 1 ? `Fields on their form, ${h[0].name}.` : `Fields on their ${h.length} forms, ${h[0].name} first.` : null;
100
- if (l) {
101
- const r = (n.data ?? []).find((k) => k.field === l.field), o = K(l, s), c = d == null || typeof d == "string" && d.trim() === "" || Array.isArray(d) && d.length === 0, u = l.required && c;
102
- return /* @__PURE__ */ t("div", { className: "flex flex-col", "data-bulk-field-value": !0, children: [
103
- /* @__PURE__ */ t("div", { className: "flex items-center gap-2 border-b border-border px-3 py-2.5", children: [
104
- /* @__PURE__ */ e(
105
+ }, [y.data]), o = j(
106
+ () => l.data ? he(l.data, v) : [],
107
+ [l.data, v]
108
+ ), [e, M] = g(null), [c, $] = g(null), [m, E] = g("append"), [F, V] = g([]), [S, Z] = g(null), _ = W(!1);
109
+ X(() => {
110
+ if (!i || _.current || !l.data) return;
111
+ _.current = !0;
112
+ const r = o.flatMap((n) => n.options).find((n) => n.field === i);
113
+ r && r.writable > 0 ? (M(r), $(null)) : Z(r ? R(r, l.data.readable) ?? null : "");
114
+ }, [i, l.data, o]);
115
+ const p = !!(e != null && e.m2m), K = p ? xe(m, F) : c, U = le(JSON.stringify(K ?? null), 300), B = !!e && (!p || m === "replace" || F.length > 0), k = A({
116
+ queryKey: ["bulk-update-preview", d, C, (e == null ? void 0 : e.field) ?? "", U],
117
+ queryFn: () => u.request(
118
+ Y(`/items/${d}/bulk-update?dry_run=1`, {
119
+ ids: b,
120
+ data: { [e == null ? void 0 : e.field]: JSON.parse(U) },
121
+ by_form: !0
122
+ })
123
+ ).then((r) => r.data),
124
+ enabled: B && U === JSON.stringify(K ?? null),
125
+ staleTime: 1e4,
126
+ retry: !1
127
+ }), h = ((J = l.data) == null ? void 0 : J.readable) ?? b.length, q = ((D = l.data) == null ? void 0 : D.forms) ?? [], I = l.data ? q.length === 0 ? "These records have no form, so every field you may change is listed." : q.length === 1 ? `Fields on their form, ${q[0].name}.` : `Fields on their ${q.length} forms, ${q[0].name} first.` : null;
128
+ if (e) {
129
+ const r = (y.data ?? []).find((N) => N.field === e.field), n = R(e, h), s = p ? F.length === 0 : c == null || typeof c == "string" && c.trim() === "" || Array.isArray(c) && c.length === 0, f = p ? s && (m !== "replace" || e.required) : e.required && s, O = k.data ? ge(k.data, { mode: p ? m : null }) : null;
130
+ return /* @__PURE__ */ a("div", { className: "flex flex-col", "data-bulk-field-value": !0, children: [
131
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-2 border-b border-border px-3 py-2.5", children: [
132
+ /* @__PURE__ */ t(
105
133
  "button",
106
134
  {
107
135
  type: "button",
108
136
  onClick: () => {
109
- q(null), v(null);
137
+ M(null), $(null), V([]), E("append");
110
138
  },
111
139
  "aria-label": "Choose another field",
112
140
  "data-tip": "Choose another field",
113
141
  className: "rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
114
- children: /* @__PURE__ */ e(j, { className: "h-3.5 w-3.5" })
142
+ children: /* @__PURE__ */ t(te, { className: "h-3.5 w-3.5" })
115
143
  }
116
144
  ),
117
- /* @__PURE__ */ t("div", { className: "min-w-0", children: [
118
- /* @__PURE__ */ t("p", { className: "truncate text-[13px] font-semibold text-foreground", children: [
145
+ /* @__PURE__ */ a("div", { className: "min-w-0", children: [
146
+ /* @__PURE__ */ a("p", { className: "truncate text-[13px] font-semibold text-foreground", children: [
119
147
  "Set ",
120
- l.label
148
+ e.label
121
149
  ] }),
122
- /* @__PURE__ */ t("p", { className: "text-[11.5px] text-muted-foreground", children: [
150
+ /* @__PURE__ */ a("p", { className: "text-[11.5px] text-muted-foreground", children: [
123
151
  "On ",
124
- l.writable,
152
+ e.writable,
125
153
  " of ",
126
- s,
154
+ h,
127
155
  " record",
128
- s === 1 ? "" : "s"
156
+ h === 1 ? "" : "s"
129
157
  ] })
130
158
  ] })
131
159
  ] }),
132
- /* @__PURE__ */ t("div", { className: "space-y-2 px-3 py-3", children: [
133
- r ? /* @__PURE__ */ e(
134
- D,
160
+ /* @__PURE__ */ a("div", { className: "space-y-2 px-3 py-3", children: [
161
+ e.m2m ? /* @__PURE__ */ t(
162
+ be,
163
+ {
164
+ related: e.m2m.related,
165
+ fieldLabel: e.label,
166
+ fieldOptions: r == null ? void 0 : r.options,
167
+ mode: m,
168
+ ids: F,
169
+ onMode: E,
170
+ onIds: V
171
+ }
172
+ ) : r ? /* @__PURE__ */ t(
173
+ ne,
135
174
  {
136
175
  field: { ...r, readonly: !1 },
137
- value: d,
138
- onChange: v,
139
- relations: b.data ?? [],
140
- collection: i,
176
+ value: c,
177
+ onChange: $,
178
+ relations: L.data ?? [],
179
+ collection: d,
141
180
  itemId: "new"
142
181
  }
143
- ) : /* @__PURE__ */ e(
182
+ ) : /* @__PURE__ */ t(
144
183
  "input",
145
184
  {
146
185
  autoFocus: !0,
147
- value: d == null ? "" : String(d),
148
- onChange: (k) => v(k.target.value),
149
- "aria-label": `New ${l.label}`,
186
+ value: c == null ? "" : String(c),
187
+ onChange: (N) => $(N.target.value),
188
+ "aria-label": `New ${e.label}`,
150
189
  className: "h-9 w-full rounded-md border border-input bg-background px-3 text-[13px] text-foreground focus-visible:border-nvr-cyan focus-visible:outline-none"
151
190
  }
152
191
  ),
153
- /* @__PURE__ */ e(
192
+ /* @__PURE__ */ t(
154
193
  "p",
155
194
  {
156
195
  className: "text-[11.5px] leading-4 text-muted-foreground",
157
196
  id: "bulk-field-hint",
158
197
  "data-bulk-field-hint": !0,
159
- children: u ? `${l.label} is required — choose a value to apply.` : c ? `Leave it empty to clear ${l.label} on every record.` : "Records that already hold this value are left as they are."
198
+ children: p ? m === "replace" ? s ? e.required ? `${e.label} is required — pick at least one.` : null : `Each record’s ${e.label} becomes exactly these.` : s ? `Pick the records to ${m === "append" ? "add" : "remove"}.` : m === "append" ? "Links a record already has are left as they are." : "Only these links come off; the rest stay." : f ? `${e.label} is required — choose a value to apply.` : s ? `Leave it empty to clear ${e.label} on every record.` : "Records that already hold this value are left as they are."
199
+ }
200
+ ),
201
+ p && m === "replace" && s && !e.required && /* @__PURE__ */ a(
202
+ "p",
203
+ {
204
+ role: "alert",
205
+ "data-bulk-links-clear-warning": !0,
206
+ className: "rounded-md border border-amber-300 bg-amber-50 px-2 py-1.5 text-[11.5px] leading-4 text-amber-800 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-200",
207
+ children: [
208
+ "Nothing picked: this removes every ",
209
+ e.label,
210
+ " link from the selected records."
211
+ ]
212
+ }
213
+ ),
214
+ !f && B && /* @__PURE__ */ t(
215
+ "div",
216
+ {
217
+ "aria-live": "polite",
218
+ "data-bulk-update-preview": !0,
219
+ className: "rounded-md bg-muted/60 px-2 py-1.5 text-[11.5px] leading-4",
220
+ children: k.isError ? /* @__PURE__ */ t("span", { className: "text-muted-foreground", children: "Could not count the changes — Apply still checks every record." }) : O ? /* @__PURE__ */ a(ee, { children: [
221
+ /* @__PURE__ */ t("span", { className: "font-medium text-foreground", "data-bulk-update-preview-headline": !0, children: O.headline }),
222
+ O.notes.length > 0 && /* @__PURE__ */ a("span", { className: "text-muted-foreground", children: [
223
+ " · ",
224
+ O.notes.join(" · ")
225
+ ] })
226
+ ] }) : /* @__PURE__ */ t(x, { className: "h-3 w-40" })
160
227
  }
161
228
  ),
162
- o && /* @__PURE__ */ t(
229
+ n && /* @__PURE__ */ a(
163
230
  "p",
164
231
  {
165
232
  className: "text-[11.5px] leading-4 text-amber-700 dark:text-amber-300",
166
233
  "data-bulk-field-note": !0,
167
234
  children: [
168
- o.charAt(0).toUpperCase() + o.slice(1),
235
+ n.charAt(0).toUpperCase() + n.slice(1),
169
236
  ". Those records are skipped."
170
237
  ]
171
238
  }
172
239
  )
173
240
  ] }),
174
- /* @__PURE__ */ t("div", { className: "flex items-center gap-1.5 border-t border-border px-3 py-2", children: [
175
- g && /* @__PURE__ */ e(
241
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-1.5 border-t border-border px-3 py-2", children: [
242
+ w && !p && /* @__PURE__ */ t(
176
243
  "button",
177
244
  {
178
245
  type: "button",
179
- onClick: () => g(l.field, d),
246
+ onClick: () => w(e.field, c),
180
247
  "data-tip": "Save this update as a reusable recipe",
181
248
  className: "h-8 rounded-md px-2.5 text-[12.5px] text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
182
249
  children: "Save recipe"
183
250
  }
184
251
  ),
185
- /* @__PURE__ */ e("span", { className: "flex-1" }),
186
- /* @__PURE__ */ e(
252
+ /* @__PURE__ */ t("span", { className: "flex-1" }),
253
+ /* @__PURE__ */ t(
187
254
  "button",
188
255
  {
189
256
  type: "button",
190
- onClick: x,
257
+ onClick: P,
191
258
  className: "h-8 rounded-md px-2.5 text-[12.5px] text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
192
259
  children: "Cancel"
193
260
  }
@@ -196,90 +263,101 @@ function X({
196
263
  "button",
197
264
  {
198
265
  type: "button",
199
- disabled: l.writable === 0 || u,
200
- "aria-describedby": u ? "bulk-field-hint" : void 0,
201
- onClick: () => N(l.field, d),
266
+ disabled: e.writable === 0 || f || ((G = k.data) == null ? void 0 : G.would_update) === 0,
267
+ "aria-describedby": f ? "bulk-field-hint" : void 0,
268
+ onClick: () => T(e.field, K),
202
269
  "data-bulk-field-apply": !0,
203
270
  className: "h-8 rounded-md bg-nvr-cyan px-3 text-[12.5px] font-semibold text-white transition-colors hover:bg-nvr-cyan/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan focus-visible:ring-offset-2 disabled:opacity-40",
204
- children: [
205
- "Apply to ",
206
- l.writable,
207
- " record",
208
- l.writable === 1 ? "" : "s"
209
- ]
271
+ children: (() => {
272
+ const N = k.data ? k.data.would_update : e.writable;
273
+ return `Apply to ${N.toLocaleString()} record${N === 1 ? "" : "s"}`;
274
+ })()
210
275
  }
211
276
  )
212
277
  ] })
213
278
  ] });
214
279
  }
215
- return /* @__PURE__ */ t("div", { className: "flex flex-col", "data-bulk-field-picker": !0, children: [
216
- /* @__PURE__ */ t("div", { className: "border-b border-border px-3 py-2.5", children: [
217
- /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-foreground", children: [
280
+ return /* @__PURE__ */ a("div", { className: "flex flex-col", "data-bulk-field-picker": !0, children: [
281
+ /* @__PURE__ */ a("div", { className: "border-b border-border px-3 py-2.5", children: [
282
+ /* @__PURE__ */ a("p", { className: "text-[13px] font-semibold text-foreground", children: [
218
283
  "Update a field on ",
219
- s,
284
+ h,
220
285
  " record",
221
- s === 1 ? "" : "s"
286
+ h === 1 ? "" : "s"
222
287
  ] }),
223
- S ? /* @__PURE__ */ e("p", { className: "text-[11.5px] text-muted-foreground", children: S }) : /* @__PURE__ */ e(f, { className: "mt-1 h-3 w-48" })
288
+ S != null && /* @__PURE__ */ a(
289
+ "p",
290
+ {
291
+ "data-bulk-field-point-missed": !0,
292
+ className: "mt-1 text-[11.5px] leading-4 text-amber-700 dark:text-amber-300",
293
+ children: [
294
+ v[i ?? ""] || i,
295
+ " can’t be changed in bulk here",
296
+ S ? ` — ${S.charAt(0).toLowerCase()}${S.slice(1)}` : "",
297
+ ". Pick another field."
298
+ ]
299
+ }
300
+ ),
301
+ I ? /* @__PURE__ */ t("p", { className: "text-[11.5px] text-muted-foreground", children: I }) : /* @__PURE__ */ t(x, { className: "mt-1 h-3 w-48" })
224
302
  ] }),
225
- a.isLoading ? /* @__PURE__ */ t("div", { className: "space-y-2 p-3", "aria-busy": "true", children: [
226
- /* @__PURE__ */ e(f, { className: "h-3 w-20" }),
227
- /* @__PURE__ */ e(f, { className: "h-7 w-full" }),
228
- /* @__PURE__ */ e(f, { className: "h-7 w-full" }),
229
- /* @__PURE__ */ e(f, { className: "h-3 w-24" }),
230
- /* @__PURE__ */ e(f, { className: "h-7 w-full" })
231
- ] }) : a.isError ? /* @__PURE__ */ t("div", { className: "space-y-2 px-3 py-4 text-[12.5px] text-muted-foreground", children: [
232
- /* @__PURE__ */ e("p", { children: "Could not read these records’ forms." }),
233
- /* @__PURE__ */ e(
303
+ l.isLoading ? /* @__PURE__ */ a("div", { className: "space-y-2 p-3", "aria-busy": "true", children: [
304
+ /* @__PURE__ */ t(x, { className: "h-3 w-20" }),
305
+ /* @__PURE__ */ t(x, { className: "h-7 w-full" }),
306
+ /* @__PURE__ */ t(x, { className: "h-7 w-full" }),
307
+ /* @__PURE__ */ t(x, { className: "h-3 w-24" }),
308
+ /* @__PURE__ */ t(x, { className: "h-7 w-full" })
309
+ ] }) : l.isError ? /* @__PURE__ */ a("div", { className: "space-y-2 px-3 py-4 text-[12.5px] text-muted-foreground", children: [
310
+ /* @__PURE__ */ t("p", { children: "Could not read these records’ forms." }),
311
+ /* @__PURE__ */ t(
234
312
  "button",
235
313
  {
236
314
  type: "button",
237
- onClick: () => void a.refetch(),
315
+ onClick: () => void l.refetch(),
238
316
  className: "h-7 rounded-md border border-border px-2.5 text-[12px] font-medium text-foreground hover:bg-muted",
239
317
  children: "Try again"
240
318
  }
241
319
  )
242
- ] }) : $.length === 0 ? /* @__PURE__ */ e("p", { className: "px-3 py-5 text-[12.5px] leading-5 text-muted-foreground", children: s === 0 ? "You cannot open any of the selected records." : "Their form has no field you can change in bulk. Open a record to edit it there." }) : /* @__PURE__ */ t(G, { className: "rounded-none bg-transparent", children: [
243
- /* @__PURE__ */ e(M, { placeholder: "Find a field…", className: "h-9 text-[13px]" }),
244
- /* @__PURE__ */ t(Q, { className: "max-h-[320px]", children: [
245
- /* @__PURE__ */ e(R, { className: "py-5 text-center text-[12.5px] text-muted-foreground", children: "No field on the form matches." }),
246
- $.map((r) => /* @__PURE__ */ e(Y, { heading: r.label, children: r.options.map((o) => {
247
- const c = o.writable === 0, u = K(o, s);
248
- return /* @__PURE__ */ t(
249
- z,
320
+ ] }) : o.length === 0 ? /* @__PURE__ */ t("p", { className: "px-3 py-5 text-[12.5px] leading-5 text-muted-foreground", children: h === 0 ? "You cannot open any of the selected records." : "Their form has no field you can change in bulk. Open a record to edit it there." }) : /* @__PURE__ */ a(oe, { className: "rounded-none bg-transparent", children: [
321
+ /* @__PURE__ */ t(de, { placeholder: "Find a field…", className: "h-9 text-[13px]" }),
322
+ /* @__PURE__ */ a(se, { className: "max-h-[320px]", children: [
323
+ /* @__PURE__ */ t(ie, { className: "py-5 text-center text-[12.5px] text-muted-foreground", children: "No field on the form matches." }),
324
+ o.map((r) => /* @__PURE__ */ t(ue, { heading: r.label, children: r.options.map((n) => {
325
+ const s = n.writable === 0, f = R(n, h);
326
+ return /* @__PURE__ */ a(
327
+ ce,
250
328
  {
251
- value: `${r.label} ${o.label} ${o.field}`,
252
- disabled: c,
329
+ value: `${r.label} ${n.label} ${n.field}`,
330
+ disabled: s,
253
331
  onSelect: () => {
254
- q(o), v(null);
332
+ M(n), $(null), V([]), E("append");
255
333
  },
256
- "data-bulk-field-option": o.field,
334
+ "data-bulk-field-option": n.field,
257
335
  className: "items-start py-1.5 text-[13px] data-[disabled=true]:opacity-100",
258
336
  children: [
259
- /* @__PURE__ */ t("span", { className: "min-w-0 flex-1", children: [
260
- /* @__PURE__ */ e(
337
+ /* @__PURE__ */ a("span", { className: "min-w-0 flex-1", children: [
338
+ /* @__PURE__ */ t(
261
339
  "span",
262
340
  {
263
- className: U(
341
+ className: H(
264
342
  "block truncate",
265
- c ? "text-muted-foreground" : "text-foreground"
343
+ s ? "text-muted-foreground" : "text-foreground"
266
344
  ),
267
- children: o.label
345
+ children: n.label
268
346
  }
269
347
  ),
270
- u && /* @__PURE__ */ e(
348
+ f && /* @__PURE__ */ t(
271
349
  "span",
272
350
  {
273
- className: U(
351
+ className: H(
274
352
  "block truncate text-[11px] leading-4",
275
- c ? "text-muted-foreground" : "text-amber-700 dark:text-amber-300"
353
+ s ? "text-muted-foreground" : "text-amber-700 dark:text-amber-300"
276
354
  ),
277
- children: u.charAt(0).toUpperCase() + u.slice(1)
355
+ children: f.charAt(0).toUpperCase() + f.slice(1)
278
356
  }
279
357
  )
280
358
  ] }),
281
- c && /* @__PURE__ */ e(
282
- E,
359
+ s && /* @__PURE__ */ t(
360
+ re,
283
361
  {
284
362
  className: "mt-0.5 h-3.5 w-3.5 text-muted-foreground",
285
363
  "aria-label": "Locked"
@@ -287,14 +365,14 @@ function X({
287
365
  )
288
366
  ]
289
367
  },
290
- o.field
368
+ n.field
291
369
  );
292
370
  }) }, r.key))
293
371
  ] })
294
372
  ] }),
295
- ((O = a.data) == null ? void 0 : O.capped) && /* @__PURE__ */ e("p", { className: "border-t border-border px-3 py-1.5 text-[11px] text-muted-foreground", children: "Checked the first 1,000 selected records." })
373
+ ((Q = l.data) == null ? void 0 : Q.capped) && /* @__PURE__ */ t("p", { className: "border-t border-border px-3 py-1.5 text-[11px] text-muted-foreground", children: "Checked the first 1,000 selected records." })
296
374
  ] });
297
375
  }
298
376
  export {
299
- ce as BulkFieldUpdate
377
+ Ee as BulkFieldUpdate
300
378
  };
@@ -1,73 +1,67 @@
1
- import { jsx as f } from "react/jsx-runtime";
2
- import { useQueryClient as b } from "@tanstack/react-query";
3
- import { useState as h } from "react";
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { useQueryClient as h } from "@tanstack/react-query";
3
+ import { useState as B } from "react";
4
4
  import { toast as n } from "sonner";
5
- import { useNivaroClient as $ } from "../../context.js";
6
- import { newBulkProgressId as U, startBulkProgress as v, endBulkProgress as w } from "../../lib/bulk-progress.js";
7
- import { post as F } from "../../lib/commands.js";
8
- import { errorToastOptions as P } from "../../lib/error-toast.js";
9
- import { userErrorMessage as j } from "../../lib/safe-error.js";
10
- import { invalidateRecordQueries as C } from "../item-edit/RecordLiveSync.js";
11
- import { BulkFieldUpdate as q } from "./BulkFieldUpdate.js";
12
- function z({
5
+ import { useNivaroClient as U } from "../../context.js";
6
+ import { newBulkProgressId as w, startBulkProgress as F, endBulkProgress as P } from "../../lib/bulk-progress.js";
7
+ import { post as v } from "../../lib/commands.js";
8
+ import { errorToastOptions as C } from "../../lib/error-toast.js";
9
+ import { userErrorMessage as q } from "../../lib/safe-error.js";
10
+ import { invalidateRecordQueries as x } from "../item-edit/RecordLiveSync.js";
11
+ import { BulkFieldUpdate as I } from "./BulkFieldUpdate.js";
12
+ import { bulkUpdateOutcome as O } from "./bulk-update-preview.js";
13
+ function H({
13
14
  targets: o,
14
- disabled: m,
15
- className: p,
15
+ disabled: f,
16
+ className: u,
16
17
  onDone: s
17
18
  }) {
18
- const y = $(), k = b(), [g, u] = h(!1), a = [...new Set(o.map((t) => t.collection))];
19
+ const y = U(), k = h(), [b, a] = B(!1), p = [...new Set(o.map((t) => t.collection))];
19
20
  if (o.length === 0) return null;
20
- if (a.length !== 1)
21
- return /* @__PURE__ */ f(
21
+ if (p.length !== 1)
22
+ return /* @__PURE__ */ m(
22
23
  "button",
23
24
  {
24
25
  type: "button",
25
26
  disabled: !0,
26
27
  "data-tip": "Pick records of one kind to update a field on them together",
27
- className: p,
28
+ className: u,
28
29
  children: "Update Field"
29
30
  }
30
31
  );
31
- const i = a[0], r = o.map((t) => t.id), B = async (t, d) => {
32
- u(!0);
33
- const l = U();
34
- v(l, r);
32
+ const i = p[0], r = o.map((t) => t.id), g = async (t, l) => {
33
+ a(!0);
34
+ const d = w();
35
+ F(d, r);
35
36
  try {
36
37
  const e = await y.request(
37
- F(`/items/${i}/bulk-update?progress=${l}`, {
38
+ v(`/items/${i}/bulk-update?progress=${d}`, {
38
39
  ids: r,
39
- data: { [t]: d ?? null },
40
+ data: { [t]: l ?? null },
40
41
  by_form: !0
41
42
  })
42
- ), c = [
43
- `Updated ${e.updated} record${e.updated === 1 ? "" : "s"}`,
44
- e.skipped ? `${e.skipped} already set` : "",
45
- e.refused ? `${e.refused} refused` : ""
46
- ].filter(Boolean);
47
- e.refused ? n.warning(c.join(" · "), {
48
- description: e.refused_reason ?? void 0,
49
- duration: 8e3
50
- }) : n.success(c.join(" · ")), C(k, i, r), s == null || s();
43
+ ), c = O(e);
44
+ e.refused || e.failed ? n.warning(c, { duration: 8e3 }) : n.success(c), x(k, i, r), s == null || s();
51
45
  } catch (e) {
52
46
  n.error(
53
- j(e, "Could not update the field"),
54
- P(e, { action: "Update Field" })
47
+ q(e, "Could not update the field"),
48
+ C(e, { action: "Update Field" })
55
49
  );
56
50
  } finally {
57
- w(l), u(!1);
51
+ P(d), a(!1);
58
52
  }
59
53
  };
60
- return /* @__PURE__ */ f(
61
- q,
54
+ return /* @__PURE__ */ m(
55
+ I,
62
56
  {
63
57
  collection: i,
64
58
  selectedIds: r,
65
- disabled: m || g,
66
- onApply: (t, d) => void B(t, d),
67
- className: p
59
+ disabled: f || b,
60
+ onApply: (t, l) => void g(t, l),
61
+ className: u
68
62
  }
69
63
  );
70
64
  }
71
65
  export {
72
- z as BulkFieldUpdateButton
66
+ H as BulkFieldUpdateButton
73
67
  };