@nivaro/react 0.3.91 → 0.3.93

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.
@@ -1,94 +1,109 @@
1
- import { jsx as l, Fragment as ie, jsxs as c } from "react/jsx-runtime";
2
- import { useQueryClient as oe, useQueries as le } from "@tanstack/react-query";
3
- import { Loader2 as I, Send as ce, CheckCircle2 as de, AlertCircle as ue, MinusCircle as me } from "lucide-react";
4
- import { useMemo as K, useState as x } from "react";
5
- import { toast as q } from "sonner";
6
- import { useNivaroClient as pe } from "../../context.js";
7
- import { get as he, post as U } from "../../lib/commands.js";
8
- import { userErrorMessage as fe } from "../../lib/safe-error.js";
9
- import { cn as G } from "../../lib/utils.js";
10
- import { Popover as be, PopoverTrigger as ke, PopoverContent as xe } from "../ui/popover.js";
11
- import { useAvailableBulkActions as ge, bulkActionEnabled as ye } from "./BulkActionButtons.js";
12
- function H(i, r, t, d) {
13
- return ((i == null ? void 0 : i[t]) ?? []).some((m) => m.source === "builtin" && m.key === d) && ye(r, t, d);
1
+ import { jsx as l, Fragment as oe, jsxs as c } from "react/jsx-runtime";
2
+ import { useQueryClient as le, useQueries as ce } from "@tanstack/react-query";
3
+ import { Loader2 as K, Send as de, CheckCircle2 as ue, AlertCircle as me, MinusCircle as pe } from "lucide-react";
4
+ import { useMemo as U, useState as y } from "react";
5
+ import { toast as N } from "sonner";
6
+ import { useNivaroClient as he } from "../../context.js";
7
+ import { newBulkProgressId as fe, startBulkProgress as be, endBulkProgress as ke } from "../../lib/bulk-progress.js";
8
+ import { get as xe, post as G } from "../../lib/commands.js";
9
+ import { userErrorMessage as ge } from "../../lib/safe-error.js";
10
+ import { cn as H } from "../../lib/utils.js";
11
+ import { Popover as ye, PopoverTrigger as we, PopoverContent as ve } from "../ui/popover.js";
12
+ import { useAvailableBulkActions as Ne, bulkActionEnabled as $e } from "./BulkActionButtons.js";
13
+ function J(a, r, n, d) {
14
+ return ((a == null ? void 0 : a[n]) ?? []).some((f) => f.source === "builtin" && f.key === d) && $e(r, n, d);
14
15
  }
15
- function ve(i) {
16
+ function Ce(a) {
16
17
  const r = { succeeded: 0, failed: 0, skipped: 0, errors: [], outcomes: [] };
17
- for (const { collection: t, data: d } of i) {
18
+ for (const { collection: n, data: d } of a) {
18
19
  r.succeeded += d.succeeded ?? 0, r.failed += d.failed ?? 0, r.skipped += d.skipped ?? 0, r.errors.push(...d.errors ?? []);
19
- for (const m of d.outcomes ?? [])
20
- r.outcomes.push({ ...m, item: `${t}:${m.item}` });
20
+ for (const f of d.outcomes ?? [])
21
+ r.outcomes.push({ ...f, item: `${n}:${f.item}` });
21
22
  }
22
23
  return r;
23
24
  }
24
- function we(i, r) {
25
- const t = [`${r.succeeded} done`];
26
- return r.skipped && t.push(`${r.skipped} skipped`), r.failed && t.push(`${r.failed} failed`), `${i}: ${t.join(" · ")}`;
25
+ function Re(a, r) {
26
+ const n = [`${r.succeeded} done`];
27
+ return r.skipped && n.push(`${r.skipped} skipped`), r.failed && n.push(`${r.failed} failed`), `${a}: ${n.join(" · ")}`;
27
28
  }
28
- function Qe({
29
- targets: i,
29
+ function Ie({
30
+ targets: a,
30
31
  enabledKeys: r,
31
- tone: t = "light",
32
+ tone: n = "light",
32
33
  disabled: d,
33
- onDone: m
34
+ onDone: f
34
35
  }) {
35
- const v = pe(), J = oe(), w = K(() => [...new Set(i.map((e) => e.collection))], [i]), { data: j } = ge(w), N = w.filter((e) => H(j, r, e, "push")), O = w.filter(
36
- (e) => H(j, r, e, "retry-push")
37
- ), P = le({
38
- queries: N.map((e) => ({
36
+ const $ = he(), V = le(), C = U(() => [...new Set(a.map((e) => e.collection))], [a]), { data: j } = Ne(C), R = C.filter((e) => J(j, r, e, "push")), O = C.filter(
37
+ (e) => J(j, r, e, "retry-push")
38
+ ), S = ce({
39
+ queries: R.map((e) => ({
39
40
  queryKey: ["bulk-push-actions", e],
40
- queryFn: () => v.request(he("/item-actions/registered", { collection: e })).then((s) => s.data ?? []).catch(() => []),
41
+ queryFn: () => $.request(xe("/item-actions/registered", { collection: e })).then((t) => t.data ?? []).catch(() => []),
41
42
  staleTime: 5 * 6e4
42
43
  }))
43
- }), V = P.map((e) => e.dataUpdatedAt).join(","), W = K(() => {
44
+ }), W = S.map((e) => e.dataUpdatedAt).join(","), X = U(() => {
44
45
  const e = /* @__PURE__ */ new Map();
45
- return N.forEach((s, a) => {
46
- var o;
47
- for (const n of (((o = P[a]) == null ? void 0 : o.data) ?? []).filter((u) => u.bulk !== !1)) {
48
- const u = e.get(n.id);
49
- u ? u.collections.push(s) : e.set(n.id, { ...n, collections: [s] });
46
+ return R.forEach((t, s) => {
47
+ var i;
48
+ for (const o of (((i = S[s]) == null ? void 0 : i.data) ?? []).filter((u) => u.bulk !== !1)) {
49
+ const u = e.get(o.id);
50
+ u ? u.collections.push(t) : e.set(o.id, { ...o, collections: [t] });
50
51
  }
51
52
  }), [...e.values()];
52
- }, [V, N.join(",")]), [X, S] = x(null), [g, A] = x(""), [M, _] = x(null), [Y, $] = x({}), [Z, E] = x({}), D = (e) => {
53
- const [s, ...a] = e.split(":"), o = a.join(":"), n = i.find((u) => u.collection === s && String(u.id) === o);
54
- return n != null && n.label ? String(n.label) : `#${o}`;
55
- }, Q = async (e, s) => {
56
- const a = e.kind === "push" ? e.action.collections : e.collections, o = [];
57
- for (const n of a) {
58
- const u = i.filter((p) => p.collection === n).map((p) => p.id);
59
- if (u.length === 0) continue;
60
- const k = e.kind === "push" ? await v.request(
61
- U("/bulk-actions/push", {
62
- collection: n,
53
+ }, [W, R.join(",")]), [Y, A] = y(null), [w, B] = y(""), [M, _] = y(null), [Z, q] = y({}), [D, E] = y({}), ee = (e) => {
54
+ const [t, ...s] = e.split(":"), i = s.join(":"), o = a.find((u) => u.collection === t && String(u.id) === i);
55
+ return o != null && o.label ? String(o.label) : `#${i}`;
56
+ };
57
+ let k = 0;
58
+ const Q = async (e, t) => {
59
+ var o;
60
+ const s = e.kind === "push" ? e.action.collections : e.collections, i = [];
61
+ for (const u of s) {
62
+ const b = a.filter((x) => x.collection === u).map((x) => x.id);
63
+ if (b.length === 0) continue;
64
+ const m = !t && e.kind === "push" ? fe() : null;
65
+ m && be(m, b);
66
+ const p = e.kind === "push" ? await $.request(
67
+ G(`/bulk-actions/push${m ? `?progress=${m}` : ""}`, {
68
+ collection: u,
63
69
  action_id: e.action.id,
64
- ids: u,
65
- dry_run: s,
66
- ...g.trim() ? { payload: { message: g.trim() } } : {}
70
+ ids: b,
71
+ dry_run: t,
72
+ ...w.trim() ? { payload: { message: w.trim() } } : {}
67
73
  })
68
- ) : await v.request(
69
- U("/bulk-actions/retry-push", { collection: n, ids: u, dry_run: s })
70
- );
71
- o.push({ collection: n, data: k.data });
74
+ ) : await $.request(
75
+ G("/bulk-actions/retry-push", { collection: u, ids: b, dry_run: t })
76
+ ), h = ((o = p.data) == null ? void 0 : o.background) === !0;
77
+ if (m && !h && ke(m), h) {
78
+ k += b.length;
79
+ continue;
80
+ }
81
+ i.push({ collection: u, data: p.data });
72
82
  }
73
- return ve(o);
74
- }, C = (e) => e.kind === "push" ? `push:${e.action.id}` : "retry-push", R = (e) => e.kind === "push" ? e.action.label : "Retry failed pushes", ee = async (e) => {
75
- const s = C(e);
76
- $((a) => ({ ...a, [s]: "loading" }));
83
+ return Ce(i);
84
+ }, P = (e) => e.kind === "push" ? `push:${e.action.id}` : "retry-push", v = (e) => e.kind === "push" ? e.action.label : "Retry failed pushes", te = async (e) => {
85
+ const t = P(e);
86
+ q((s) => ({ ...s, [t]: "loading" }));
77
87
  try {
78
- const a = await Q(e, !0);
79
- $((o) => ({ ...o, [s]: a }));
88
+ const s = await Q(e, !0);
89
+ q((i) => ({ ...i, [t]: s }));
80
90
  } catch {
81
- $((a) => ({ ...a, [s]: null }));
91
+ q((s) => ({ ...s, [t]: null }));
82
92
  }
83
- }, te = async (e) => {
84
- const s = C(e);
85
- _(s);
93
+ }, se = async (e) => {
94
+ const t = P(e);
95
+ _(t);
86
96
  try {
87
- const a = await Q(e, !1);
88
- E((n) => ({ ...n, [s]: a }));
89
- const o = we(R(e), a);
90
- a.failed > 0 ? q.warning(o, { duration: 8e3 }) : q.success(o, { duration: 4e3 });
91
- for (const n of [
97
+ k = 0;
98
+ const s = await Q(e, !1);
99
+ if (k === 0 && E((i) => ({ ...i, [t]: s })), k > 0 && N.info(
100
+ `${v(e)}: running on ${k} record${k === 1 ? "" : "s"} — each row updates as it finishes, and a notification tells you how it ended.`,
101
+ { duration: 8e3 }
102
+ ), k === 0 || s.succeeded + s.failed + s.skipped > 0) {
103
+ const i = Re(v(e), s);
104
+ s.failed > 0 ? N.warning(i, { duration: 8e3 }) : k === 0 && N.success(i, { duration: 4e3 });
105
+ }
106
+ for (const i of [
92
107
  "erp-submissions",
93
108
  "row-push-state",
94
109
  "cbv-integrations-summary",
@@ -96,37 +111,37 @@ function Qe({
96
111
  "integration-obligations",
97
112
  "item-actions"
98
113
  ])
99
- J.invalidateQueries({ queryKey: [n] });
100
- } catch (a) {
101
- const o = a.response;
102
- q.error((o == null ? void 0 : o.error) ?? fe(a, `${R(e)} failed`));
114
+ V.invalidateQueries({ queryKey: [i] });
115
+ } catch (s) {
116
+ const i = s.response;
117
+ N.error((i == null ? void 0 : i.error) ?? ge(s, `${v(e)} failed`));
103
118
  } finally {
104
119
  _(null);
105
120
  }
106
- }, B = [
107
- ...W.map((e) => ({ kind: "push", action: e })),
121
+ }, F = [
122
+ ...X.map((e) => ({ kind: "push", action: e })),
108
123
  ...O.length > 0 ? [{ kind: "retry", collections: O }] : []
109
124
  ];
110
- if (B.length === 0) return null;
111
- const se = (e) => t === "dark" ? G(
125
+ if (F.length === 0) return null;
126
+ const ne = (e) => n === "dark" ? H(
112
127
  "inline-flex h-8 items-center gap-1.5 rounded-md border border-white/20 px-3 text-[12.5px] font-medium transition-colors hover:bg-white/10 disabled:opacity-50 dark:border-border dark:hover:bg-muted",
113
128
  e && "bg-white/10"
114
- ) : G(
129
+ ) : H(
115
130
  "inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[12px] font-medium text-slate-600 transition-colors hover:bg-slate-100 disabled:opacity-50 dark:text-slate-300 dark:hover:bg-muted",
116
131
  e && "bg-slate-100 dark:bg-muted"
117
132
  );
118
- return /* @__PURE__ */ l(ie, { children: B.map((e) => {
119
- var F, L, z, T;
120
- const s = C(e), a = R(e), o = e.kind === "push" ? e.action.collections : e.collections, n = i.filter((b) => o.includes(b.collection)).length, u = X === s, k = M === s, p = e.kind === "push" ? (F = e.action.confirm) == null ? void 0 : F.input : void 0, h = Y[s], f = Z[s] ?? null, y = h && h !== "loading" ? h.succeeded : null, ne = n > 0 && !k && y !== 0 && (!(p != null && p.required) || g.trim().length > 0), re = e.kind === "push" ? ((L = e.action.confirm) == null ? void 0 : L.body) ?? `Runs "${e.action.label}" on each selected record, one at a time. Every record is a real request to the partner.` : "Re-sends the latest failed push of each selected record, partner by partner — the same stored request the record’s own Retry button sends.";
133
+ return /* @__PURE__ */ l(oe, { children: F.map((e) => {
134
+ var L, z, I, T;
135
+ const t = P(e), s = v(e), i = e.kind === "push" ? e.action.collections : e.collections, o = a.filter((g) => i.includes(g.collection)).length, u = Y === t, b = M === t, m = e.kind === "push" ? (L = e.action.confirm) == null ? void 0 : L.input : void 0, p = Z[t], h = D[t] ?? null, x = p && p !== "loading" ? p.succeeded : null, re = o > 0 && !b && x !== 0 && (!(m != null && m.required) || w.trim().length > 0), ie = e.kind === "push" ? ((z = e.action.confirm) == null ? void 0 : z.body) ?? `Runs "${e.action.label}" on each selected record, one at a time. Every record is a real request to the partner.` : "Re-sends the latest failed push of each selected record, partner by partner — the same stored request the record’s own Retry button sends.";
121
136
  return /* @__PURE__ */ c(
122
- be,
137
+ ye,
123
138
  {
124
139
  open: u,
125
- onOpenChange: (b) => {
126
- S(b ? s : null), b ? (A(""), E((ae) => ({ ...ae, [s]: null })), ee(e)) : f && (m == null || m(f));
140
+ onOpenChange: (g) => {
141
+ A(g ? t : null), g ? (B(""), E((ae) => ({ ...ae, [t]: null })), te(e)) : h && (f == null || f(h));
127
142
  },
128
143
  children: [
129
- /* @__PURE__ */ l(ke, { asChild: !0, children: /* @__PURE__ */ c(
144
+ /* @__PURE__ */ l(we, { asChild: !0, children: /* @__PURE__ */ c(
130
145
  "button",
131
146
  {
132
147
  type: "button",
@@ -134,88 +149,88 @@ function Qe({
134
149
  "data-bulk-push-action": e.kind === "push" ? e.action.id : void 0,
135
150
  "data-bulk-retry-push": e.kind === "retry" ? "" : void 0,
136
151
  title: e.kind === "push" ? `Run ${e.action.label} on the selected records` : "Re-send each selected record’s latest failed push",
137
- className: se(u),
152
+ className: ne(u),
138
153
  children: [
139
- k ? /* @__PURE__ */ l(I, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ l(ce, { className: "h-3.5 w-3.5" }),
140
- a
154
+ b ? /* @__PURE__ */ l(K, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ l(de, { className: "h-3.5 w-3.5" }),
155
+ s
141
156
  ]
142
157
  }
143
158
  ) }),
144
159
  /* @__PURE__ */ c(
145
- xe,
160
+ ve,
146
161
  {
147
162
  align: "center",
148
163
  side: "top",
149
164
  sideOffset: 8,
150
165
  className: "w-[340px] p-3",
151
- "data-bulk-push-popover": s,
166
+ "data-bulk-push-popover": t,
152
167
  children: [
153
168
  /* @__PURE__ */ c("p", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: [
154
- a,
169
+ s,
155
170
  /* @__PURE__ */ c("span", { className: "ml-1.5 font-normal text-slate-500 dark:text-slate-400", children: [
156
171
  "· ",
157
- n,
172
+ o,
158
173
  " record",
159
- n === 1 ? "" : "s"
174
+ o === 1 ? "" : "s"
160
175
  ] })
161
176
  ] }),
162
- /* @__PURE__ */ l("p", { className: "mt-1 text-[12px] leading-snug text-slate-600 dark:text-slate-400", children: re }),
163
- !f && (h === "loading" ? /* @__PURE__ */ l("p", { className: "mt-2 text-[11.5px] text-slate-400", "data-bulk-push-preview": "loading", children: "Checking which records this applies to…" }) : h ? /* @__PURE__ */ c(
177
+ /* @__PURE__ */ l("p", { className: "mt-1 text-[12px] leading-snug text-slate-600 dark:text-slate-400", children: ie }),
178
+ !h && (p === "loading" ? /* @__PURE__ */ l("p", { className: "mt-2 text-[11.5px] text-slate-400", "data-bulk-push-preview": "loading", children: "Checking which records this applies to…" }) : p ? /* @__PURE__ */ c(
164
179
  "p",
165
180
  {
166
181
  className: "mt-2 rounded-md border border-slate-200 bg-slate-50 px-2 py-1.5 text-[11.5px] font-medium text-slate-700 dark:border-border dark:bg-muted/40 dark:text-slate-200",
167
- "data-bulk-push-preview": h.succeeded,
182
+ "data-bulk-push-preview": p.succeeded,
168
183
  children: [
169
- h.succeeded,
184
+ p.succeeded,
170
185
  " of ",
171
- n,
186
+ o,
172
187
  " would ",
173
188
  e.kind === "push" ? "run" : "be retried",
174
- h.skipped + h.failed > 0 && /* @__PURE__ */ c("span", { className: "font-normal text-slate-500 dark:text-slate-400", children: [
189
+ p.skipped + p.failed > 0 && /* @__PURE__ */ c("span", { className: "font-normal text-slate-500 dark:text-slate-400", children: [
175
190
  " · ",
176
- Ne(h)
191
+ qe(p)
177
192
  ] })
178
193
  ]
179
194
  }
180
195
  ) : null),
181
- !f && p && /* @__PURE__ */ c("label", { className: "mt-2.5 block", children: [
196
+ !h && m && /* @__PURE__ */ c("label", { className: "mt-2.5 block", children: [
182
197
  /* @__PURE__ */ c("span", { className: "text-[11px] font-medium text-slate-600 dark:text-slate-400", children: [
183
- p.label,
184
- p.required && /* @__PURE__ */ l("span", { className: "text-destructive", children: " *" })
198
+ m.label,
199
+ m.required && /* @__PURE__ */ l("span", { className: "text-destructive", children: " *" })
185
200
  ] }),
186
201
  /* @__PURE__ */ l(
187
202
  "textarea",
188
203
  {
189
- value: g,
190
- onChange: (b) => A(b.target.value),
191
- placeholder: p.placeholder ?? "Sent with every record",
204
+ value: w,
205
+ onChange: (g) => B(g.target.value),
206
+ placeholder: m.placeholder ?? "Sent with every record",
192
207
  rows: 2,
193
208
  className: "mt-1 w-full resize-none rounded-md border border-slate-200 bg-white px-2 py-1.5 text-[12.5px] focus:border-nvr-cyan focus:outline-none dark:border-border dark:bg-card dark:text-slate-100"
194
209
  }
195
210
  )
196
211
  ] }),
197
- f && /* @__PURE__ */ l($e, { result: f, labelFor: D }),
212
+ h && /* @__PURE__ */ l(Pe, { result: h, labelFor: ee }),
198
213
  /* @__PURE__ */ c("div", { className: "mt-3 flex items-center justify-end gap-2", children: [
199
214
  /* @__PURE__ */ l(
200
215
  "button",
201
216
  {
202
217
  type: "button",
203
218
  onClick: () => {
204
- S(null), f && (m == null || m(f));
219
+ A(null), h && (f == null || f(h));
205
220
  },
206
221
  className: "h-8 rounded-md px-2.5 text-[12.5px] font-medium text-slate-600 hover:bg-muted dark:text-slate-300",
207
- children: f ? "Done" : "Close"
222
+ children: h ? "Done" : "Close"
208
223
  }
209
224
  ),
210
- !f && /* @__PURE__ */ l(
225
+ !h && /* @__PURE__ */ l(
211
226
  "button",
212
227
  {
213
228
  type: "button",
214
- onClick: () => void te(e),
215
- disabled: !ne,
229
+ onClick: () => void se(e),
230
+ disabled: !re,
216
231
  "data-bulk-push-run": !0,
217
232
  className: "h-8 rounded-md bg-nvr-cyan px-3 text-[12.5px] font-semibold text-[#172940] hover:bg-nvr-cyan-dark disabled:opacity-40",
218
- children: k ? /* @__PURE__ */ l(I, { className: "h-3.5 w-3.5 animate-spin" }) : y != null && y !== n ? `${e.kind === "push" ? ((z = e.action.confirm) == null ? void 0 : z.confirm_label) ?? a : "Retry"} · ${y} of ${n}` : `${e.kind === "push" ? ((T = e.action.confirm) == null ? void 0 : T.confirm_label) ?? a : "Retry"} ${n}`
233
+ children: b ? /* @__PURE__ */ l(K, { className: "h-3.5 w-3.5 animate-spin" }) : x != null && x !== o ? `${e.kind === "push" ? ((I = e.action.confirm) == null ? void 0 : I.confirm_label) ?? s : "Retry"} · ${x} of ${o}` : `${e.kind === "push" ? ((T = e.action.confirm) == null ? void 0 : T.confirm_label) ?? s : "Retry"} ${o}`
219
234
  }
220
235
  )
221
236
  ] })
@@ -224,58 +239,58 @@ function Qe({
224
239
  )
225
240
  ]
226
241
  },
227
- s
242
+ t
228
243
  );
229
244
  }) });
230
245
  }
231
- function Ne(i) {
246
+ function qe(a) {
232
247
  const r = /* @__PURE__ */ new Map();
233
- for (const t of i.outcomes) {
234
- if (t.outcome === "change") continue;
235
- const d = t.reason ?? t.outcome;
248
+ for (const n of a.outcomes) {
249
+ if (n.outcome === "change") continue;
250
+ const d = n.reason ?? n.outcome;
236
251
  r.set(d, (r.get(d) ?? 0) + 1);
237
252
  }
238
- return [...r.entries()].map(([t, d]) => `${d} ${t}`).join(" · ");
253
+ return [...r.entries()].map(([n, d]) => `${d} ${n}`).join(" · ");
239
254
  }
240
- function $e({
241
- result: i,
255
+ function Pe({
256
+ result: a,
242
257
  labelFor: r
243
258
  }) {
244
259
  return /* @__PURE__ */ c("div", { className: "mt-2", "data-bulk-push-results": !0, children: [
245
260
  /* @__PURE__ */ c("p", { className: "text-[11.5px] font-medium text-slate-700 dark:text-slate-200", children: [
246
- i.succeeded,
261
+ a.succeeded,
247
262
  " done",
248
- i.skipped > 0 && ` · ${i.skipped} skipped`,
249
- i.failed > 0 && /* @__PURE__ */ c("span", { className: "text-red-600 dark:text-red-400", children: [
263
+ a.skipped > 0 && ` · ${a.skipped} skipped`,
264
+ a.failed > 0 && /* @__PURE__ */ c("span", { className: "text-red-600 dark:text-red-400", children: [
250
265
  " · ",
251
- i.failed,
266
+ a.failed,
252
267
  " failed"
253
268
  ] })
254
269
  ] }),
255
- /* @__PURE__ */ l("ul", { className: "mt-1 max-h-48 space-y-1 overflow-auto", children: i.outcomes.map((t) => /* @__PURE__ */ c(
270
+ /* @__PURE__ */ l("ul", { className: "mt-1 max-h-48 space-y-1 overflow-auto", children: a.outcomes.map((n) => /* @__PURE__ */ c(
256
271
  "li",
257
272
  {
258
- "data-bulk-push-result": t.item,
259
- "data-outcome": t.outcome,
273
+ "data-bulk-push-result": n.item,
274
+ "data-outcome": n.outcome,
260
275
  className: "flex items-start gap-1.5 text-[11.5px] leading-snug",
261
276
  children: [
262
- t.outcome === "change" ? /* @__PURE__ */ l(de, { className: "mt-px h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400" }) : t.outcome === "fail" ? /* @__PURE__ */ l(ue, { className: "mt-px h-3.5 w-3.5 shrink-0 text-red-600 dark:text-red-400" }) : /* @__PURE__ */ l(me, { className: "mt-px h-3.5 w-3.5 shrink-0 text-slate-400" }),
277
+ n.outcome === "change" ? /* @__PURE__ */ l(ue, { className: "mt-px h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400" }) : n.outcome === "fail" ? /* @__PURE__ */ l(me, { className: "mt-px h-3.5 w-3.5 shrink-0 text-red-600 dark:text-red-400" }) : /* @__PURE__ */ l(pe, { className: "mt-px h-3.5 w-3.5 shrink-0 text-slate-400" }),
263
278
  /* @__PURE__ */ c("span", { className: "min-w-0", children: [
264
- /* @__PURE__ */ l("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: r(t.item) }),
265
- t.reason && /* @__PURE__ */ c("span", { className: "break-words text-slate-500 dark:text-slate-400", children: [
279
+ /* @__PURE__ */ l("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: r(n.item) }),
280
+ n.reason && /* @__PURE__ */ c("span", { className: "break-words text-slate-500 dark:text-slate-400", children: [
266
281
  " ",
267
282
  "— ",
268
- t.reason
283
+ n.reason
269
284
  ] })
270
285
  ] })
271
286
  ]
272
287
  },
273
- t.item
288
+ n.item
274
289
  )) })
275
290
  ] });
276
291
  }
277
292
  export {
278
- Qe as PushBulkButtons,
279
- $e as PushResultList,
280
- H as builtinListed
293
+ Ie as PushBulkButtons,
294
+ Pe as PushResultList,
295
+ J as builtinListed
281
296
  };
@@ -1,27 +1,27 @@
1
- import { useSyncExternalStore as a } from "react";
2
- import { useLiveEvent as f } from "./live.js";
1
+ import { useSyncExternalStore as f } from "react";
2
+ import { useLiveEvent as a } from "./live.js";
3
3
  let t = null, l = 0;
4
- const u = /* @__PURE__ */ new Set();
4
+ const i = /* @__PURE__ */ new Set();
5
5
  let r = null;
6
6
  function s() {
7
7
  l++;
8
- for (const e of u) e();
8
+ for (const e of i) e();
9
9
  }
10
- function w() {
10
+ function m() {
11
11
  return `bp${typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID().replace(/-/g, "") : `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 12)}`}`.slice(0, 40);
12
12
  }
13
- function m(e, n) {
13
+ function S(e, n) {
14
14
  r && clearTimeout(r), t = {
15
15
  id: e,
16
16
  rows: new Map(n.map((o) => [String(o), { status: "queued" }])),
17
17
  finished: !1
18
18
  }, s();
19
19
  }
20
- function S(e, n = 6e3) {
20
+ function d(e, n = 6e3) {
21
21
  if (!(!t || t.id !== e)) {
22
22
  t.finished = !0;
23
- for (const [o, i] of t.rows)
24
- (i.status === "queued" || i.status === "running") && t.rows.set(o, { status: "done" });
23
+ for (const [o, u] of t.rows)
24
+ (u.status === "queued" || u.status === "running") && t.rows.set(o, { status: "done" });
25
25
  s(), r && clearTimeout(r), r = setTimeout(() => {
26
26
  (t == null ? void 0 : t.id) === e && (t = null, s());
27
27
  }, n);
@@ -34,23 +34,27 @@ function c(e) {
34
34
  const n = t.rows.get(String(e.running));
35
35
  (!n || n.status === "queued") && t.rows.set(String(e.running), { status: "running" });
36
36
  }
37
+ if (e.finished && !t.finished) {
38
+ d(t.id);
39
+ return;
40
+ }
37
41
  s();
38
42
  }
39
43
  }
40
44
  function k() {
41
- f("bulk:rows", c, { includeOwn: !0 });
45
+ a("bulk:rows", c, { includeOwn: !0 });
42
46
  }
43
- function p(e) {
44
- return a(
45
- (n) => (u.add(n), () => u.delete(n)),
47
+ function y(e) {
48
+ return f(
49
+ (n) => (i.add(n), () => i.delete(n)),
46
50
  () => l,
47
51
  () => 0
48
52
  ), (t == null ? void 0 : t.rows.get(String(e))) ?? null;
49
53
  }
50
54
  export {
51
- S as endBulkProgress,
52
- w as newBulkProgressId,
53
- m as startBulkProgress,
55
+ d as endBulkProgress,
56
+ m as newBulkProgressId,
57
+ S as startBulkProgress,
54
58
  k as useBulkProgressFeed,
55
- p as useBulkRowState
59
+ y as useBulkRowState
56
60
  };
@@ -0,0 +1,8 @@
1
+ const t = "The form is still loading. Wait a moment for its fields to appear, then try again.";
2
+ function a(r) {
3
+ return Array.isArray(r) && r.length > 0;
4
+ }
5
+ export {
6
+ t as FORM_NOT_READY_MESSAGE,
7
+ a as formReadyToSave
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.91",
3
+ "version": "0.3.93",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",