@nivaro/react 0.3.64 → 0.3.66

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 (74) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +62 -8
  4. package/dist/shared/components/CollectionBrowserView.js +3127 -3204
  5. package/dist/shared/components/ConformanceView.js +235 -221
  6. package/dist/shared/components/DataTable.js +478 -459
  7. package/dist/shared/components/ItemEditForm.js +4842 -4500
  8. package/dist/shared/components/MyWorkView.js +124 -113
  9. package/dist/shared/components/PageRenderer.js +146 -138
  10. package/dist/shared/components/ProfileView.js +483 -472
  11. package/dist/shared/components/RecordDrilldownSheet.js +73 -65
  12. package/dist/shared/components/ReportView.js +1100 -1094
  13. package/dist/shared/components/bulk/BulkActionButtons.js +72 -72
  14. package/dist/shared/components/bulk/BulkCompareButton.js +62 -0
  15. package/dist/shared/components/bulk/BulkFieldUpdate.js +114 -103
  16. package/dist/shared/components/bulk/BulkFieldUpdateButton.js +73 -0
  17. package/dist/shared/components/bulk/MessageStakeholders.js +235 -0
  18. package/dist/shared/components/bulk/bulk-field-options.js +29 -23
  19. package/dist/shared/components/integrations/IntegrationObligationsView.js +191 -173
  20. package/dist/shared/components/integrations/IntegrationStatusLines.js +101 -85
  21. package/dist/shared/components/integrations/RecordIntegrationPreview.js +11 -9
  22. package/dist/shared/components/integrations/SendCurrentData.js +126 -0
  23. package/dist/shared/components/item-edit/CatalogPickerField.js +1535 -1440
  24. package/dist/shared/components/item-edit/FieldRenderer.js +49 -45
  25. package/dist/shared/components/item-edit/FieldRow.js +413 -403
  26. package/dist/shared/components/item-edit/GroupSection.js +555 -538
  27. package/dist/shared/components/item-edit/InlineTableField.js +2903 -2816
  28. package/dist/shared/components/item-edit/M2MCombobox.js +407 -338
  29. package/dist/shared/components/item-edit/MidairCollisionDialog.js +367 -116
  30. package/dist/shared/components/item-edit/NestedRelationEditor.js +171 -163
  31. package/dist/shared/components/item-edit/PlanGrid.js +783 -724
  32. package/dist/shared/components/item-edit/QuickCreateButton.js +291 -224
  33. package/dist/shared/components/item-edit/RecordInsights.js +113 -111
  34. package/dist/shared/components/item-edit/RecordLiveSync.js +4 -1
  35. package/dist/shared/components/item-edit/RelationCombobox.js +398 -364
  36. package/dist/shared/components/item-edit/SummaryPanel.js +146 -144
  37. package/dist/shared/components/item-edit/UserChip.js +264 -229
  38. package/dist/shared/components/item-edit/cascade-clear-notice.js +56 -0
  39. package/dist/shared/components/item-edit/collision-format.js +37 -0
  40. package/dist/shared/components/item-edit/field-a11y.js +25 -0
  41. package/dist/shared/components/item-edit/header-path-preview.js +52 -0
  42. package/dist/shared/components/item-edit/line-merge.js +84 -0
  43. package/dist/shared/components/item-edit/line-midair.js +94 -87
  44. package/dist/shared/components/item-edit/move-guard.js +17 -0
  45. package/dist/shared/components/item-edit/picker-search.js +27 -16
  46. package/dist/shared/components/item-edit/rail-width.js +8 -0
  47. package/dist/shared/components/monitoring/InactiveUserLinksView.js +126 -124
  48. package/dist/shared/components/panels/AccessDeniedPanel.js +96 -55
  49. package/dist/shared/components/panels/CommentPanel.js +142 -136
  50. package/dist/shared/components/panels/ItemLockBanner.js +246 -240
  51. package/dist/shared/components/panels/PipelinePanel.js +1366 -1194
  52. package/dist/shared/components/panels/RevisionsPanel.js +106 -102
  53. package/dist/shared/components/panels/SlaBreachBanner.js +16 -20
  54. package/dist/shared/components/panels/SlaClock.js +90 -68
  55. package/dist/shared/components/queue/QueueItemSheet.js +94 -87
  56. package/dist/shared/components/queue/QueueWorklist.js +1522 -1347
  57. package/dist/shared/components/queue/worklist-csv.js +75 -0
  58. package/dist/shared/components/queue/worklist-helpers.js +20 -0
  59. package/dist/shared/components/widgets/ReviewListWidget.js +226 -207
  60. package/dist/shared/lib/bulk-copy.js +17 -0
  61. package/dist/shared/lib/cbv-export.js +122 -0
  62. package/dist/shared/lib/delete-offer.js +13 -0
  63. package/dist/shared/lib/error-hints.js +1 -0
  64. package/dist/shared/lib/leave-guard.js +41 -26
  65. package/dist/shared/lib/list-link.js +72 -56
  66. package/dist/shared/lib/live-queries.js +32 -30
  67. package/dist/shared/lib/moved-notice.js +25 -0
  68. package/dist/shared/lib/notification-target.js +56 -54
  69. package/dist/shared/lib/obligation-banner.js +11 -8
  70. package/dist/shared/lib/obligation-reason-text.js +6 -6
  71. package/dist/shared/lib/quick-filter-cascade.js +29 -19
  72. package/dist/shared/lib/sort-cycle.js +6 -0
  73. package/dist/shared/lib/summary-mode.js +59 -41
  74. package/package.json +1 -1
@@ -1,62 +1,62 @@
1
1
  import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
- import { useQuery as k } from "@tanstack/react-query";
3
- import { ArrowLeft as K, Lock as j } from "lucide-react";
4
- import { useState as w, useMemo as C } from "react";
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
5
  import { useNivaroClient as B } from "../../context.js";
6
- import { post as E, get as O } from "../../lib/commands.js";
7
- import { cn as P } from "../../lib/utils.js";
6
+ import { post as V, get as P } from "../../lib/commands.js";
7
+ import { cn as U } from "../../lib/utils.js";
8
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 V, CommandItem as Y } from "../ui/command.js";
10
- import { Popover as z, PopoverTrigger as H, PopoverContent as I } from "../ui/popover.js";
11
- import { Skeleton as p } from "../ui/skeleton.js";
12
- import { bulkFieldSections as J, bulkFieldNote as U } from "./bulk-field-options.js";
13
- function se({
14
- collection: d,
15
- selectedIds: u,
16
- disabled: h,
17
- className: v,
18
- onApply: x,
19
- onSaveRecipe: m
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
20
20
  }) {
21
- const [g, a] = w(!1);
21
+ const [y, a] = F(!1);
22
22
  return /* @__PURE__ */ t(
23
- z,
23
+ H,
24
24
  {
25
- open: g,
26
- onOpenChange: (l) => {
27
- (!h || !l) && a(l);
25
+ open: y,
26
+ onOpenChange: (n) => {
27
+ (!x || !n) && a(n);
28
28
  },
29
29
  children: [
30
- /* @__PURE__ */ e(H, { asChild: !0, children: /* @__PURE__ */ e(
30
+ /* @__PURE__ */ e(I, { asChild: !0, children: /* @__PURE__ */ e(
31
31
  "button",
32
32
  {
33
33
  type: "button",
34
- disabled: h,
34
+ disabled: x,
35
35
  "data-bulk-update-field": !0,
36
- className: v,
36
+ className: N,
37
37
  "aria-haspopup": "dialog",
38
38
  children: "Update Field"
39
39
  }
40
40
  ) }),
41
41
  /* @__PURE__ */ e(
42
- I,
42
+ J,
43
43
  {
44
44
  side: "top",
45
45
  align: "end",
46
46
  sideOffset: 8,
47
47
  className: "w-[380px] max-w-[calc(100vw-24px)] p-0",
48
- onOpenAutoFocus: (l) => l.preventDefault(),
49
- children: g && /* @__PURE__ */ e(
50
- W,
48
+ onOpenAutoFocus: (n) => n.preventDefault(),
49
+ children: y && /* @__PURE__ */ e(
50
+ X,
51
51
  {
52
- collection: d,
53
- selectedIds: u,
52
+ collection: i,
53
+ selectedIds: m,
54
54
  onCancel: () => a(!1),
55
- onApply: (l, f) => {
56
- a(!1), x(l, f);
55
+ onApply: (n, b) => {
56
+ a(!1), g(n, b);
57
57
  },
58
- onSaveRecipe: m ? (l, f) => {
59
- a(!1), m(l, f);
58
+ onSaveRecipe: p ? (n, b) => {
59
+ a(!1), p(n, b);
60
60
  } : void 0
61
61
  }
62
62
  )
@@ -66,39 +66,39 @@ function se({
66
66
  }
67
67
  );
68
68
  }
69
- function W({
70
- collection: d,
71
- selectedIds: u,
72
- onCancel: h,
73
- onApply: v,
74
- onSaveRecipe: x
69
+ function X({
70
+ collection: i,
71
+ selectedIds: m,
72
+ onCancel: x,
73
+ onApply: N,
74
+ onSaveRecipe: g
75
75
  }) {
76
- var S, T, L;
77
- const m = B(), g = C(() => u.map(String).join(","), [u]), a = k({
78
- queryKey: ["bulk-fields", d, g],
79
- queryFn: () => m.request(
80
- E(`/items/${d}/bulk-fields`, { ids: u })
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 })
81
81
  ).then((r) => r.data),
82
82
  staleTime: 15e3,
83
83
  retry: !1
84
- }), l = k({
85
- queryKey: ["bulk-fields-config", d],
86
- queryFn: () => m.request(O(`/field-config/${d}`)).then((r) => Array.isArray(r.data) ? r.data : []),
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 : []),
87
87
  staleTime: 6e4
88
- }), f = k({
89
- queryKey: ["bulk-fields-relations", d],
90
- queryFn: () => m.request(O(`/data-model/relations/for/${d}`)).then((r) => Array.isArray(r.data) ? r.data : []),
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 : []),
91
91
  staleTime: 6e4
92
- }), F = C(() => {
92
+ }), A = w(() => {
93
93
  const r = {};
94
- for (const o of l.data ?? []) r[o.field] = o.label;
94
+ for (const o of n.data ?? []) r[o.field] = o.label;
95
95
  return r;
96
- }, [l.data]), $ = C(
97
- () => a.data ? J(a.data, F) : [],
98
- [a.data, F]
99
- ), [n, A] = w(null), [s, y] = w(null), c = ((S = a.data) == null ? void 0 : S.readable) ?? u.length, b = ((T = a.data) == null ? void 0 : T.forms) ?? [], q = a.data ? b.length === 0 ? "These records have no form, so every field you may change is listed." : b.length === 1 ? `Fields on their form, ${b[0].name}.` : `Fields on their ${b.length} forms, ${b[0].name} first.` : null;
100
- if (n) {
101
- const r = (l.data ?? []).find((i) => i.field === n.field), o = U(n, c);
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
102
  return /* @__PURE__ */ t("div", { className: "flex flex-col", "data-bulk-field-value": !0, children: [
103
103
  /* @__PURE__ */ t("div", { className: "flex items-center gap-2 border-b border-border px-3 py-2.5", children: [
104
104
  /* @__PURE__ */ e(
@@ -106,26 +106,26 @@ function W({
106
106
  {
107
107
  type: "button",
108
108
  onClick: () => {
109
- A(null), y(null);
109
+ q(null), v(null);
110
110
  },
111
111
  "aria-label": "Choose another field",
112
112
  "data-tip": "Choose another field",
113
113
  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(K, { className: "h-3.5 w-3.5" })
114
+ children: /* @__PURE__ */ e(j, { className: "h-3.5 w-3.5" })
115
115
  }
116
116
  ),
117
117
  /* @__PURE__ */ t("div", { className: "min-w-0", children: [
118
118
  /* @__PURE__ */ t("p", { className: "truncate text-[13px] font-semibold text-foreground", children: [
119
119
  "Set ",
120
- n.label
120
+ l.label
121
121
  ] }),
122
122
  /* @__PURE__ */ t("p", { className: "text-[11.5px] text-muted-foreground", children: [
123
123
  "On ",
124
- n.writable,
124
+ l.writable,
125
125
  " of ",
126
- c,
126
+ s,
127
127
  " record",
128
- c === 1 ? "" : "s"
128
+ s === 1 ? "" : "s"
129
129
  ] })
130
130
  ] })
131
131
  ] }),
@@ -134,23 +134,31 @@ function W({
134
134
  D,
135
135
  {
136
136
  field: { ...r, readonly: !1 },
137
- value: s,
138
- onChange: y,
139
- relations: f.data ?? [],
140
- collection: d,
137
+ value: d,
138
+ onChange: v,
139
+ relations: b.data ?? [],
140
+ collection: i,
141
141
  itemId: "new"
142
142
  }
143
143
  ) : /* @__PURE__ */ e(
144
144
  "input",
145
145
  {
146
146
  autoFocus: !0,
147
- value: s == null ? "" : String(s),
148
- onChange: (i) => y(i.target.value),
149
- "aria-label": `New ${n.label}`,
147
+ value: d == null ? "" : String(d),
148
+ onChange: (k) => v(k.target.value),
149
+ "aria-label": `New ${l.label}`,
150
150
  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
151
  }
152
152
  ),
153
- /* @__PURE__ */ e("p", { className: "text-[11.5px] leading-4 text-muted-foreground", children: s == null || s === "" ? `Leave it empty to clear ${n.label} on every record.` : "Records that already hold this value are left as they are." }),
153
+ /* @__PURE__ */ e(
154
+ "p",
155
+ {
156
+ className: "text-[11.5px] leading-4 text-muted-foreground",
157
+ id: "bulk-field-hint",
158
+ "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."
160
+ }
161
+ ),
154
162
  o && /* @__PURE__ */ t(
155
163
  "p",
156
164
  {
@@ -164,11 +172,11 @@ function W({
164
172
  )
165
173
  ] }),
166
174
  /* @__PURE__ */ t("div", { className: "flex items-center gap-1.5 border-t border-border px-3 py-2", children: [
167
- x && /* @__PURE__ */ e(
175
+ g && /* @__PURE__ */ e(
168
176
  "button",
169
177
  {
170
178
  type: "button",
171
- onClick: () => x(n.field, s),
179
+ onClick: () => g(l.field, d),
172
180
  "data-tip": "Save this update as a reusable recipe",
173
181
  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",
174
182
  children: "Save recipe"
@@ -179,7 +187,7 @@ function W({
179
187
  "button",
180
188
  {
181
189
  type: "button",
182
- onClick: h,
190
+ onClick: x,
183
191
  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",
184
192
  children: "Cancel"
185
193
  }
@@ -188,13 +196,16 @@ function W({
188
196
  "button",
189
197
  {
190
198
  type: "button",
191
- disabled: n.writable === 0,
192
- onClick: () => v(n.field, s),
199
+ disabled: l.writable === 0 || u,
200
+ "aria-describedby": u ? "bulk-field-hint" : void 0,
201
+ onClick: () => N(l.field, d),
193
202
  "data-bulk-field-apply": !0,
194
203
  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",
195
204
  children: [
196
205
  "Apply to ",
197
- n.writable
206
+ l.writable,
207
+ " record",
208
+ l.writable === 1 ? "" : "s"
198
209
  ]
199
210
  }
200
211
  )
@@ -205,18 +216,18 @@ function W({
205
216
  /* @__PURE__ */ t("div", { className: "border-b border-border px-3 py-2.5", children: [
206
217
  /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-foreground", children: [
207
218
  "Update a field on ",
208
- c,
219
+ s,
209
220
  " record",
210
- c === 1 ? "" : "s"
221
+ s === 1 ? "" : "s"
211
222
  ] }),
212
- q ? /* @__PURE__ */ e("p", { className: "text-[11.5px] text-muted-foreground", children: q }) : /* @__PURE__ */ e(p, { className: "mt-1 h-3 w-48" })
223
+ S ? /* @__PURE__ */ e("p", { className: "text-[11.5px] text-muted-foreground", children: S }) : /* @__PURE__ */ e(f, { className: "mt-1 h-3 w-48" })
213
224
  ] }),
214
225
  a.isLoading ? /* @__PURE__ */ t("div", { className: "space-y-2 p-3", "aria-busy": "true", children: [
215
- /* @__PURE__ */ e(p, { className: "h-3 w-20" }),
216
- /* @__PURE__ */ e(p, { className: "h-7 w-full" }),
217
- /* @__PURE__ */ e(p, { className: "h-7 w-full" }),
218
- /* @__PURE__ */ e(p, { className: "h-3 w-24" }),
219
- /* @__PURE__ */ e(p, { className: "h-7 w-full" })
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" })
220
231
  ] }) : a.isError ? /* @__PURE__ */ t("div", { className: "space-y-2 px-3 py-4 text-[12.5px] text-muted-foreground", children: [
221
232
  /* @__PURE__ */ e("p", { children: "Could not read these records’ forms." }),
222
233
  /* @__PURE__ */ e(
@@ -228,19 +239,19 @@ function W({
228
239
  children: "Try again"
229
240
  }
230
241
  )
231
- ] }) : $.length === 0 ? /* @__PURE__ */ e("p", { className: "px-3 py-5 text-[12.5px] leading-5 text-muted-foreground", children: c === 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: [
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: [
232
243
  /* @__PURE__ */ e(M, { placeholder: "Find a field…", className: "h-9 text-[13px]" }),
233
244
  /* @__PURE__ */ t(Q, { className: "max-h-[320px]", children: [
234
245
  /* @__PURE__ */ e(R, { className: "py-5 text-center text-[12.5px] text-muted-foreground", children: "No field on the form matches." }),
235
- $.map((r) => /* @__PURE__ */ e(V, { heading: r.label, children: r.options.map((o) => {
236
- const i = o.writable === 0, N = U(o, c);
246
+ $.map((r) => /* @__PURE__ */ e(Y, { heading: r.label, children: r.options.map((o) => {
247
+ const c = o.writable === 0, u = K(o, s);
237
248
  return /* @__PURE__ */ t(
238
- Y,
249
+ z,
239
250
  {
240
251
  value: `${r.label} ${o.label} ${o.field}`,
241
- disabled: i,
252
+ disabled: c,
242
253
  onSelect: () => {
243
- A(o), y(null);
254
+ q(o), v(null);
244
255
  },
245
256
  "data-bulk-field-option": o.field,
246
257
  className: "items-start py-1.5 text-[13px] data-[disabled=true]:opacity-100",
@@ -249,26 +260,26 @@ function W({
249
260
  /* @__PURE__ */ e(
250
261
  "span",
251
262
  {
252
- className: P(
263
+ className: U(
253
264
  "block truncate",
254
- i ? "text-muted-foreground" : "text-foreground"
265
+ c ? "text-muted-foreground" : "text-foreground"
255
266
  ),
256
267
  children: o.label
257
268
  }
258
269
  ),
259
- N && /* @__PURE__ */ e(
270
+ u && /* @__PURE__ */ e(
260
271
  "span",
261
272
  {
262
- className: P(
273
+ className: U(
263
274
  "block truncate text-[11px] leading-4",
264
- i ? "text-muted-foreground" : "text-amber-700 dark:text-amber-300"
275
+ c ? "text-muted-foreground" : "text-amber-700 dark:text-amber-300"
265
276
  ),
266
- children: N.charAt(0).toUpperCase() + N.slice(1)
277
+ children: u.charAt(0).toUpperCase() + u.slice(1)
267
278
  }
268
279
  )
269
280
  ] }),
270
- i && /* @__PURE__ */ e(
271
- j,
281
+ c && /* @__PURE__ */ e(
282
+ E,
272
283
  {
273
284
  className: "mt-0.5 h-3.5 w-3.5 text-muted-foreground",
274
285
  "aria-label": "Locked"
@@ -281,9 +292,9 @@ function W({
281
292
  }) }, r.key))
282
293
  ] })
283
294
  ] }),
284
- ((L = a.data) == null ? void 0 : L.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." })
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." })
285
296
  ] });
286
297
  }
287
298
  export {
288
- se as BulkFieldUpdate
299
+ ce as BulkFieldUpdate
289
300
  };
@@ -0,0 +1,73 @@
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";
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({
13
+ targets: o,
14
+ disabled: m,
15
+ className: p,
16
+ onDone: s
17
+ }) {
18
+ const y = $(), k = b(), [g, u] = h(!1), a = [...new Set(o.map((t) => t.collection))];
19
+ if (o.length === 0) return null;
20
+ if (a.length !== 1)
21
+ return /* @__PURE__ */ f(
22
+ "button",
23
+ {
24
+ type: "button",
25
+ disabled: !0,
26
+ "data-tip": "Pick records of one kind to update a field on them together",
27
+ className: p,
28
+ children: "Update Field"
29
+ }
30
+ );
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);
35
+ try {
36
+ const e = await y.request(
37
+ F(`/items/${i}/bulk-update?progress=${l}`, {
38
+ ids: r,
39
+ data: { [t]: d ?? null },
40
+ by_form: !0
41
+ })
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();
51
+ } catch (e) {
52
+ n.error(
53
+ j(e, "Could not update the field"),
54
+ P(e, { action: "Update Field" })
55
+ );
56
+ } finally {
57
+ w(l), u(!1);
58
+ }
59
+ };
60
+ return /* @__PURE__ */ f(
61
+ q,
62
+ {
63
+ collection: i,
64
+ selectedIds: r,
65
+ disabled: m || g,
66
+ onApply: (t, d) => void B(t, d),
67
+ className: p
68
+ }
69
+ );
70
+ }
71
+ export {
72
+ z as BulkFieldUpdateButton
73
+ };