@nivaro/react 0.3.10 → 0.3.11

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 (43) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useNivaroForm.js +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +34 -3
  5. package/dist/shared/components/CollectionBrowserView.js +1546 -1477
  6. package/dist/shared/components/ItemEditForm.js +4332 -4195
  7. package/dist/shared/components/PageRenderer.js +512 -465
  8. package/dist/shared/components/QueryStatStrip.js +74 -70
  9. package/dist/shared/components/ReportView.js +818 -827
  10. package/dist/shared/components/SheetHeaderBody.js +16 -14
  11. package/dist/shared/components/item-edit/CatalogPickerField.js +1029 -933
  12. package/dist/shared/components/item-edit/FieldRenderer.js +161 -156
  13. package/dist/shared/components/item-edit/FieldRow.js +20 -19
  14. package/dist/shared/components/item-edit/FilePickerField.js +52 -40
  15. package/dist/shared/components/item-edit/GroupSection.js +221 -221
  16. package/dist/shared/components/item-edit/InlineGridField.js +41 -41
  17. package/dist/shared/components/item-edit/InlineTableField.js +2249 -2238
  18. package/dist/shared/components/item-edit/M2MCombobox.js +46 -44
  19. package/dist/shared/components/item-edit/NestedRelationEditor.js +11 -11
  20. package/dist/shared/components/item-edit/QuickPicker.js +263 -216
  21. package/dist/shared/components/item-edit/RelationCombobox.js +285 -245
  22. package/dist/shared/components/item-edit/RichTextEditorImpl.js +42 -32
  23. package/dist/shared/components/item-edit/RowHistorySheet.js +130 -134
  24. package/dist/shared/components/item-edit/SummaryPanel.js +305 -279
  25. package/dist/shared/components/item-edit/helpers.js +133 -134
  26. package/dist/shared/components/item-edit/line-qty.js +57 -0
  27. package/dist/shared/components/item-edit/option-disambiguate.js +53 -0
  28. package/dist/shared/components/panels/AddendumLinesDiff.js +87 -90
  29. package/dist/shared/components/panels/CommentPanel.js +350 -315
  30. package/dist/shared/components/panels/ItemLockBanner.js +297 -230
  31. package/dist/shared/components/panels/PipelinePanel.js +719 -701
  32. package/dist/shared/components/queue/QueueQuickFilters.js +43 -41
  33. package/dist/shared/components/queue/QueueWorklist.js +1005 -935
  34. package/dist/shared/components/widgets/ReviewListWidget.js +99 -93
  35. package/dist/shared/lib/obligation-banner.js +14 -13
  36. package/dist/shared/lib/obligation-reason-text.js +13 -0
  37. package/dist/shared/lib/query-filter-seed.js +34 -11
  38. package/dist/shared/lib/sanitize-html.js +24 -15
  39. package/dist/shared/lib/sheet-def.js +38 -22
  40. package/dist/shared/lib/unique-options.js +10 -0
  41. package/dist/shared/lib/utils.js +57 -43
  42. package/dist/shared/lib/validation-rules.js +58 -34
  43. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
- import { jsx as s, jsxs as m } from "react/jsx-runtime";
1
+ import { jsx as s, jsxs as b } from "react/jsx-runtime";
2
2
  import { useQuery as Z } from "@tanstack/react-query";
3
3
  import { ChevronRight as ee, AlertCircle as te } from "lucide-react";
4
4
  import { useState as S, useMemo as L } from "react";
5
5
  import { useNivaroClient as re, useItemEditAuth as le } from "../../context.js";
6
6
  import { post as R, patch as se } from "../../lib/commands.js";
7
- import { formatDateTime as H, cn as ae, formatDate as ne } from "../../lib/utils.js";
7
+ import { formatDateTime as H, cn as ne, formatDate as ae } from "../../lib/utils.js";
8
8
  import { TooltipProvider as oe, Tooltip as de, TooltipTrigger as ie, TooltipContent as ue } from "../ui/tooltip.js";
9
9
  function W(t) {
10
10
  return t === !0 || t === 1 || t === "1" || t === "true";
@@ -17,11 +17,11 @@ function O(t, r) {
17
17
  }
18
18
  if (r === "date" || r === "datetime") {
19
19
  const d = new Date(t);
20
- return Number.isNaN(d.getTime()) ? String(t) : r === "date" ? ne(d) : H(d);
20
+ return Number.isNaN(d.getTime()) ? String(t) : r === "date" ? ae(d) : H(d);
21
21
  }
22
22
  return String(t);
23
23
  }
24
- const M = {
24
+ const G = {
25
25
  green: "#16a34a",
26
26
  red: "#dc2626",
27
27
  amber: "#d97706",
@@ -36,8 +36,8 @@ function ce(t) {
36
36
  border: `1px solid ${t ? `${t}44` : "#e2e8f0"}`
37
37
  };
38
38
  }
39
- function G({ label: t, color: r }) {
40
- const d = r ? M[r] ?? null : null;
39
+ function E({ label: t, color: r }) {
40
+ const d = r ? G[r] ?? null : null;
41
41
  return /* @__PURE__ */ s(
42
42
  "span",
43
43
  {
@@ -85,27 +85,27 @@ function we({
85
85
  hostRecordId: o,
86
86
  emptyLabel: y
87
87
  }) {
88
- const x = re(), { userId: C } = le(), [g, T] = S(() => /* @__PURE__ */ new Set()), [w, $] = S(null), [P, K] = S({}), [A, D] = S(null), [F, E] = S(""), I = L(() => {
89
- const e = t ? be(t, r.aggregate_sum) : [], n = r.group_sort;
90
- if (!(n != null && n.field)) return e;
91
- const c = n.direction === "desc";
92
- return [...e].sort((k, b) => {
93
- const u = B(k.rows, n.field, c), h = B(b.rows, n.field, c);
94
- return u == null && h == null ? 0 : u == null ? 1 : h == null ? -1 : c ? h - u : u - h;
88
+ const x = re(), { userId: C } = le(), [g, T] = S(() => /* @__PURE__ */ new Set()), [w, $] = S(null), [M, K] = S({}), [A, D] = S(null), [F, P] = S(""), I = L(() => {
89
+ const e = t ? be(t, r.aggregate_sum) : [], a = r.group_sort;
90
+ if (!(a != null && a.field)) return e;
91
+ const m = a.direction === "desc";
92
+ return [...e].sort((k, i) => {
93
+ const c = B(k.rows, a.field, m), h = B(i.rows, a.field, m);
94
+ return c == null && h == null ? 0 : c == null ? 1 : h == null ? -1 : m ? h - c : c - h;
95
95
  });
96
- }, [t, r.aggregate_sum, r.group_sort]), q = L(() => ((t == null ? void 0 : t.rows) ?? []).map((e) => String(e.id)), [t]), { data: v } = Z({
97
- queryKey: ["review-list-enrich", r.enrich_endpoint ?? "", q.join(",")],
96
+ }, [t, r.aggregate_sum, r.group_sort]), j = L(() => ((t == null ? void 0 : t.rows) ?? []).map((e) => String(e.id)), [t]), { data: v } = Z({
97
+ queryKey: ["review-list-enrich", r.enrich_endpoint ?? "", j.join(",")],
98
98
  queryFn: () => x.request(
99
- R(r.enrich_endpoint, { ids: q })
99
+ R(r.enrich_endpoint, { ids: j })
100
100
  ).then((e) => {
101
- var n;
102
- return ((n = e == null ? void 0 : e.data) == null ? void 0 : n.rows) ?? {};
101
+ var a;
102
+ return ((a = e == null ? void 0 : e.data) == null ? void 0 : a.rows) ?? {};
103
103
  }).catch(() => ({})),
104
- enabled: !!r.enrich_endpoint && q.length > 0,
104
+ enabled: !!r.enrich_endpoint && j.length > 0,
105
105
  staleTime: 3e4
106
- }), j = (e) => v == null ? void 0 : v[String(e)], U = !!v && Object.values(v).some((e) => {
107
- var n;
108
- return (((n = e.chips) == null ? void 0 : n.length) ?? 0) > 0;
106
+ }), q = (e) => v == null ? void 0 : v[String(e)], U = !!v && Object.values(v).some((e) => {
107
+ var a;
108
+ return (((a = e.chips) == null ? void 0 : a.length) ?? 0) > 0;
109
109
  }), Q = I.length === 1;
110
110
  if (d)
111
111
  return /* @__PURE__ */ s("div", { className: "space-y-2", children: [0, 1].map((e) => /* @__PURE__ */ s(
@@ -120,79 +120,85 @@ function we({
120
120
  if (!t || t.rows.length === 0)
121
121
  return /* @__PURE__ */ s("p", { className: "text-[12px] italic text-slate-400", children: y ? `No ${y.toLowerCase()} yet` : "Nothing here yet" });
122
122
  const X = (e) => {
123
- T((n) => {
124
- const c = new Set(n);
125
- return c.has(e) ? c.delete(e) : c.add(e), c;
123
+ T((a) => {
124
+ const m = new Set(a);
125
+ return m.has(e) ? m.delete(e) : m.add(e), m;
126
126
  });
127
- }, J = (e, n) => {
128
- if (n.require_note) {
129
- E(""), D({ group: e, option: n });
127
+ }, J = (e, a) => {
128
+ if (a.require_note) {
129
+ P(""), D({ group: e, option: a });
130
130
  return;
131
131
  }
132
- V(e, n, null);
133
- }, V = async (e, n, c) => {
132
+ V(e, a, null);
133
+ }, V = async (e, a, m) => {
134
134
  $(e.key);
135
135
  let k = null;
136
136
  if (r.status.action_endpoint)
137
137
  try {
138
138
  await x.request(
139
139
  R(r.status.action_endpoint, {
140
- ids: e.rows.map((b) => b.id),
141
- status: n.value,
142
- ...c ? { note: c } : {},
140
+ ids: e.rows.map((i) => i.id),
141
+ status: a.value,
142
+ // The status each row showed: the endpoint may refuse (409) rows
143
+ // someone changed since this list loaded instead of overwriting
144
+ // them. The refetch below shows what they are now.
145
+ expected: Object.fromEntries(
146
+ e.rows.map((i) => [String(i.id), i.status == null ? null : String(i.status)])
147
+ ),
148
+ ...m ? { note: m } : {},
143
149
  ...o != null && o !== "" ? { workflow_id: Number(o) } : {}
144
150
  })
145
151
  );
146
- } catch (b) {
147
- const u = b == null ? void 0 : b.response;
148
- k = (u == null ? void 0 : u.error) ?? "Failed to update";
152
+ } catch (i) {
153
+ const c = i == null ? void 0 : i.response;
154
+ k = (c == null ? void 0 : c.error) ?? "Failed to update";
149
155
  }
150
156
  else {
151
- const b = r.status.stamp_date_field ? (/* @__PURE__ */ new Date()).toISOString() : void 0, h = (await Promise.all(
157
+ const i = r.status.stamp_date_field ? (/* @__PURE__ */ new Date()).toISOString() : void 0, h = (await Promise.all(
152
158
  e.rows.map(async (N) => {
153
- const l = { [r.status.field]: n.value };
154
- r.status.stamp_user_field && C && (l[r.status.stamp_user_field] = C), r.status.stamp_date_field && (l[r.status.stamp_date_field] = b), c && (l._change_reason = c);
159
+ const l = { [r.status.field]: a.value };
160
+ r.status.stamp_user_field && C && (l[r.status.stamp_user_field] = C), r.status.stamp_date_field && (l[r.status.stamp_date_field] = i), m && (l._change_reason = m);
155
161
  try {
156
162
  return await x.request(se(`/items/${r.collection}/${N.id}`, l)), { ok: !0 };
157
- } catch (i) {
158
- const a = i == null ? void 0 : i.response;
159
- return { ok: !1, error: (a == null ? void 0 : a.error) ?? "Failed to update" };
163
+ } catch (u) {
164
+ const n = u == null ? void 0 : u.response;
165
+ return { ok: !1, error: (n == null ? void 0 : n.error) ?? "Failed to update" };
160
166
  }
161
167
  })
162
168
  )).filter((N) => !N.ok);
163
169
  h.length > 0 && (k = `${h.length} of ${e.rows.length} row(s) failed to update`);
164
170
  }
165
- $(null), K((b) => {
166
- const u = { ...b };
167
- return k ? u[e.key] = k : delete u[e.key], u;
171
+ $(null), K((i) => {
172
+ const c = { ...i };
173
+ return k ? c[e.key] = k : delete c[e.key], c;
168
174
  }), f();
169
175
  }, z = t.columns.line_columns, Y = t.columns.group_meta;
170
- return /* @__PURE__ */ s(oe, { delayDuration: 200, children: /* @__PURE__ */ m("div", { className: "space-y-2", children: [
176
+ return /* @__PURE__ */ s(oe, { delayDuration: 200, children: /* @__PURE__ */ b("div", { className: "space-y-2", children: [
171
177
  t.truncated && /* @__PURE__ */ s("p", { className: "text-[11px] text-amber-600 dark:text-amber-400", children: "Showing first 2000 rows — some rows may be missing." }),
172
178
  I.map((e) => {
173
- const n = Q ? !g.has(e.key) : g.has(e.key), c = e.rows.every((l) => {
174
- var i;
175
- return ((i = j(l.id)) == null ? void 0 : i.can_act) !== !1;
176
- }), k = e.mixedStatus ? { label: "Mixed", color: null } : me(e.uniformStatus, r.status), b = e.rows[0], u = b.stamp_user, h = b.stamp_date, N = e.rows.reduce((l, i) => {
177
- var a;
178
- for (const _ of ((a = j(i.id)) == null ? void 0 : a.chips) ?? []) {
179
+ const a = Q ? !g.has(e.key) : g.has(e.key), m = e.rows.every((l) => {
180
+ var u;
181
+ return ((u = q(l.id)) == null ? void 0 : u.can_act) !== !1;
182
+ }), k = e.mixedStatus ? { label: "Mixed", color: null } : me(e.uniformStatus, r.status), i = e.rows[0], c = i.stamp_user, h = i.stamp_date, N = e.rows.reduce((l, u) => {
183
+ var n;
184
+ for (const _ of ((n = q(u.id)) == null ? void 0 : n.chips) ?? []) {
179
185
  if (_.tone === "danger") return "danger";
180
186
  _.tone === "warn" && l == null && (l = "warn");
181
187
  }
182
188
  return l;
183
189
  }, null);
184
- return /* @__PURE__ */ m(
190
+ return /* @__PURE__ */ b(
185
191
  "div",
186
192
  {
187
193
  "data-review-group": e.key,
188
194
  "data-review-tone": N ?? void 0,
189
- className: ae(
195
+ className: ne(
190
196
  "rounded-md border",
191
197
  N === "danger" ? "border-l-2 border-l-red-500 border-red-200 bg-red-50/40 dark:border-red-500/40 dark:bg-red-500/5" : N === "warn" ? "border-l-2 border-l-amber-500 border-amber-200 bg-amber-50/40 dark:border-amber-500/40 dark:bg-amber-500/5" : "border-slate-200 dark:border-border"
192
198
  ),
193
199
  children: [
194
- /* @__PURE__ */ m("div", { className: "flex w-full flex-wrap items-center gap-2 px-3 py-2", children: [
195
- /* @__PURE__ */ m(
200
+ /* @__PURE__ */ b("div", { className: "flex w-full flex-wrap items-center gap-2 px-3 py-2", children: [
201
+ /* @__PURE__ */ b(
196
202
  "button",
197
203
  {
198
204
  type: "button",
@@ -202,44 +208,44 @@ function we({
202
208
  /* @__PURE__ */ s(
203
209
  ee,
204
210
  {
205
- className: `h-3.5 w-3.5 shrink-0 text-slate-400 transition-transform ${n ? "rotate-90" : ""}`
211
+ className: `h-3.5 w-3.5 shrink-0 text-slate-400 transition-transform ${a ? "rotate-90" : ""}`
206
212
  }
207
213
  ),
208
214
  /* @__PURE__ */ s("span", { className: "text-[12px] font-medium text-slate-700 dark:text-slate-200", children: e.key || "—" }),
209
- /* @__PURE__ */ m("span", { className: "text-[11px] text-slate-400", children: [
215
+ /* @__PURE__ */ b("span", { className: "text-[11px] text-slate-400", children: [
210
216
  e.count,
211
217
  " row",
212
218
  e.count === 1 ? "" : "s",
213
219
  e.sum != null ? ` · ${O(e.sum, r.aggregate_sum_format ?? "number")}` : ""
214
220
  ] }),
215
221
  Y.map((l) => {
216
- const i = b.values[l.field];
217
- return l.format === "flag" ? W(i) ? /* @__PURE__ */ s(G, { label: l.label, color: l.color ?? "amber" }, l.field) : null : i == null || i === "" ? null : /* @__PURE__ */ m(
222
+ const u = i.values[l.field];
223
+ return l.format === "flag" ? W(u) ? /* @__PURE__ */ s(E, { label: l.label, color: l.color ?? "amber" }, l.field) : null : u == null || u === "" ? null : /* @__PURE__ */ b(
218
224
  "span",
219
225
  {
220
226
  className: "rounded-full bg-slate-100 px-2 py-0.5 text-[10px] font-medium text-slate-500 dark:bg-slate-800 dark:text-slate-400",
221
227
  children: [
222
228
  l.label,
223
229
  ": ",
224
- O(i, l.format)
230
+ O(u, l.format)
225
231
  ]
226
232
  },
227
233
  l.field
228
234
  );
229
235
  }),
230
- /* @__PURE__ */ s(G, { label: k.label, color: k.color }),
231
- u && /* @__PURE__ */ m(de, { children: [
232
- /* @__PURE__ */ s(ie, { asChild: !0, children: /* @__PURE__ */ s("span", { className: "cursor-default text-[11px] text-slate-400 underline decoration-dotted", children: u.label }) }),
233
- /* @__PURE__ */ m(ue, { side: "top", className: "text-[12px]", children: [
234
- /* @__PURE__ */ s("p", { className: "font-medium", children: u.label }),
236
+ /* @__PURE__ */ s(E, { label: k.label, color: k.color }),
237
+ c && /* @__PURE__ */ b(de, { children: [
238
+ /* @__PURE__ */ s(ie, { asChild: !0, children: /* @__PURE__ */ s("span", { className: "cursor-default text-[11px] text-slate-400 underline decoration-dotted", children: c.label }) }),
239
+ /* @__PURE__ */ b(ue, { side: "top", className: "text-[12px]", children: [
240
+ /* @__PURE__ */ s("p", { className: "font-medium", children: c.label }),
235
241
  h && /* @__PURE__ */ s("p", { className: "text-muted-foreground", children: H(h) })
236
242
  ] })
237
243
  ] })
238
244
  ]
239
245
  }
240
246
  ),
241
- /* @__PURE__ */ m("span", { className: "flex flex-wrap items-center gap-1.5", children: [
242
- !c && /* @__PURE__ */ s(
247
+ /* @__PURE__ */ b("span", { className: "flex flex-wrap items-center gap-1.5", children: [
248
+ !m && /* @__PURE__ */ s(
243
249
  "span",
244
250
  {
245
251
  className: "text-[11px] text-slate-400",
@@ -247,19 +253,19 @@ function we({
247
253
  children: "View only"
248
254
  }
249
255
  ),
250
- c && r.status.options.map((l) => {
251
- const i = !e.mixedStatus && String(e.uniformStatus) === l.value, a = M[l.color] ?? M.slate, _ = w === e.key;
256
+ m && r.status.options.map((l) => {
257
+ const u = !e.mixedStatus && String(e.uniformStatus) === l.value, n = G[l.color] ?? G.slate, _ = w === e.key;
252
258
  return /* @__PURE__ */ s(
253
259
  "button",
254
260
  {
255
261
  type: "button",
256
- disabled: _ || i,
262
+ disabled: _ || u,
257
263
  onClick: () => J(e, l),
258
264
  className: "rounded-md border px-2.5 py-1 text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",
259
265
  style: {
260
- backgroundColor: i ? `${a}22` : "transparent",
261
- borderColor: `${a}55`,
262
- color: a
266
+ backgroundColor: u ? `${n}22` : "transparent",
267
+ borderColor: `${n}55`,
268
+ color: n
263
269
  },
264
270
  children: _ ? "…" : l.label
265
271
  },
@@ -268,38 +274,38 @@ function we({
268
274
  })
269
275
  ] })
270
276
  ] }),
271
- P[e.key] && /* @__PURE__ */ m("p", { className: "flex items-center gap-1 px-3 pb-2 text-[11px] text-red-600", children: [
277
+ M[e.key] && /* @__PURE__ */ b("p", { className: "flex items-center gap-1 px-3 pb-2 text-[11px] text-red-600", children: [
272
278
  /* @__PURE__ */ s(te, { className: "h-3 w-3 shrink-0" }),
273
- P[e.key]
279
+ M[e.key]
274
280
  ] }),
275
- n && /* @__PURE__ */ s("div", { className: "overflow-x-auto border-t border-slate-100 dark:border-border/50", children: /* @__PURE__ */ m("table", { className: "w-full border-collapse text-[12px]", children: [
276
- /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ m("tr", { className: "border-b border-slate-200 bg-slate-50/60 text-left text-[11px] font-medium text-slate-400 dark:border-border dark:bg-white/[0.02]", children: [
281
+ a && /* @__PURE__ */ s("div", { className: "overflow-x-auto border-t border-slate-100 dark:border-border/50", children: /* @__PURE__ */ b("table", { className: "w-full border-collapse text-[12px]", children: [
282
+ /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ b("tr", { className: "border-b border-slate-200 bg-slate-50/60 text-left text-[11px] font-medium text-slate-400 dark:border-border dark:bg-white/[0.02]", children: [
277
283
  z.map((l) => /* @__PURE__ */ s("th", { className: "px-2.5 py-1.5 font-medium", children: l.label }, l.field)),
278
284
  U && /* @__PURE__ */ s("th", { className: "px-2.5 py-1.5 font-medium", children: "Match" })
279
285
  ] }) }),
280
286
  /* @__PURE__ */ s("tbody", { children: e.rows.map((l) => {
281
- var i;
282
- return /* @__PURE__ */ m(
287
+ var u;
288
+ return /* @__PURE__ */ b(
283
289
  "tr",
284
290
  {
285
291
  className: "border-b border-slate-100 last:border-b-0 dark:border-border/50",
286
292
  children: [
287
- z.map((a) => /* @__PURE__ */ s(
293
+ z.map((n) => /* @__PURE__ */ s(
288
294
  "td",
289
295
  {
290
296
  className: "px-2.5 py-1.5 text-slate-600 dark:text-slate-300",
291
- children: a.format === "flag" ? W(l.values[a.field]) ? /* @__PURE__ */ s(G, { label: a.label, color: a.color ?? "amber" }) : "—" : O(l.values[a.field], a.format)
297
+ children: n.format === "flag" ? W(l.values[n.field]) ? /* @__PURE__ */ s(E, { label: n.label, color: n.color ?? "amber" }) : "—" : O(l.values[n.field], n.format)
292
298
  },
293
- a.field
299
+ n.field
294
300
  )),
295
- U && /* @__PURE__ */ s("td", { className: "px-2.5 py-1.5", children: /* @__PURE__ */ s("span", { className: "flex flex-wrap gap-1", children: (((i = j(l.id)) == null ? void 0 : i.chips) ?? []).map((a) => /* @__PURE__ */ s(
301
+ U && /* @__PURE__ */ s("td", { className: "px-2.5 py-1.5", children: /* @__PURE__ */ s("span", { className: "flex flex-wrap gap-1", children: (((u = q(l.id)) == null ? void 0 : u.chips) ?? []).map((n) => /* @__PURE__ */ s(
296
302
  "span",
297
303
  {
298
- title: a.title,
299
- className: a.tone === "ok" ? "rounded-full bg-emerald-50 px-2 py-0.5 text-[10.5px] font-medium text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400" : a.tone === "danger" ? "rounded-full bg-red-50 px-2 py-0.5 text-[10.5px] font-medium text-red-700 dark:bg-red-500/10 dark:text-red-400" : a.tone === "warn" ? "rounded-full bg-amber-50 px-2 py-0.5 text-[10.5px] font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-400" : "rounded-full bg-slate-100 px-2 py-0.5 text-[10.5px] font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300",
300
- children: a.label
304
+ title: n.title,
305
+ className: n.tone === "ok" ? "rounded-full bg-emerald-50 px-2 py-0.5 text-[10.5px] font-medium text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400" : n.tone === "danger" ? "rounded-full bg-red-50 px-2 py-0.5 text-[10.5px] font-medium text-red-700 dark:bg-red-500/10 dark:text-red-400" : n.tone === "warn" ? "rounded-full bg-amber-50 px-2 py-0.5 text-[10.5px] font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-400" : "rounded-full bg-slate-100 px-2 py-0.5 text-[10.5px] font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300",
306
+ children: n.label
301
307
  },
302
- a.label
308
+ n.label
303
309
  )) }) })
304
310
  ]
305
311
  },
@@ -317,13 +323,13 @@ function we({
317
323
  {
318
324
  className: "fixed inset-0 z-[130] flex items-center justify-center bg-black/40 p-4",
319
325
  onClick: () => D(null),
320
- children: /* @__PURE__ */ m(
326
+ children: /* @__PURE__ */ b(
321
327
  "div",
322
328
  {
323
329
  className: "w-full max-w-md rounded-lg border border-slate-200 bg-white p-4 shadow-xl dark:border-border dark:bg-card",
324
330
  onClick: (e) => e.stopPropagation(),
325
331
  children: [
326
- /* @__PURE__ */ m("p", { className: "text-[13px] font-medium text-slate-700 dark:text-slate-200", children: [
332
+ /* @__PURE__ */ b("p", { className: "text-[13px] font-medium text-slate-700 dark:text-slate-200", children: [
327
333
  A.option.label,
328
334
  " — add a note"
329
335
  ] }),
@@ -332,14 +338,14 @@ function we({
332
338
  "textarea",
333
339
  {
334
340
  value: F,
335
- onChange: (e) => E(e.target.value),
341
+ onChange: (e) => P(e.target.value),
336
342
  rows: 3,
337
343
  autoFocus: !0,
338
344
  className: "mt-2 w-full rounded-md border border-slate-200 bg-white px-2.5 py-1.5 text-[12px] text-slate-700 outline-none focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-slate-200",
339
345
  placeholder: "Why is this being rejected?"
340
346
  }
341
347
  ),
342
- /* @__PURE__ */ m("div", { className: "mt-3 flex items-center justify-end gap-1.5", children: [
348
+ /* @__PURE__ */ b("div", { className: "mt-3 flex items-center justify-end gap-1.5", children: [
343
349
  /* @__PURE__ */ s(
344
350
  "button",
345
351
  {
@@ -372,6 +378,6 @@ function we({
372
378
  }
373
379
  export {
374
380
  we as ReviewListWidget,
375
- M as STATUS_COLOR_HEX,
381
+ G as STATUS_COLOR_HEX,
376
382
  O as formatValue
377
383
  };
@@ -1,26 +1,27 @@
1
1
  import { toneForOutcome as d } from "./obligation-filters.js";
2
- import { formatDate as f, getDisplayTimezone as $ } from "./utils.js";
3
- const p = (o) => {
4
- const t = $();
2
+ import { plainObligationReason as f } from "./obligation-reason-text.js";
3
+ import { formatDate as $, getDisplayTimezone as p } from "./utils.js";
4
+ const g = (o) => {
5
+ const t = p();
5
6
  return new Intl.DateTimeFormat("en-US", {
6
7
  hour: "numeric",
7
8
  minute: "2-digit",
8
9
  ...t ? { timeZone: t } : {}
9
10
  }).format(new Date(o));
10
11
  };
11
- function g(o, t) {
12
+ function h(o, t) {
12
13
  const l = t.getTime() - new Date(o).getTime(), e = Math.floor(l / 6e4);
13
14
  if (e < 1) return "just now";
14
15
  if (e < 60) return `${e}m ago`;
15
16
  const n = Math.floor(e / 60);
16
17
  if (n < 24) return `${n}h ago`;
17
18
  const i = Math.floor(n / 24);
18
- return i < 7 ? `${i}d ago` : f(o);
19
+ return i < 7 ? `${i}d ago` : $(o);
19
20
  }
20
- function h(o) {
21
+ function w(o) {
21
22
  return o.split(/[._-]+/).filter(Boolean).map((t) => t[0].toUpperCase() + t.slice(1)).join(" ");
22
23
  }
23
- function b(o, t = /* @__PURE__ */ new Date()) {
24
+ function T(o, t = /* @__PURE__ */ new Date()) {
24
25
  const l = /* @__PURE__ */ new Map();
25
26
  for (const e of o) {
26
27
  if (e.outcome === "superseded") continue;
@@ -28,14 +29,14 @@ function b(o, t = /* @__PURE__ */ new Date()) {
28
29
  (!n || e.id > n.id) && l.set(e.api, e);
29
30
  }
30
31
  return [...l.values()].map((e) => {
31
- var c;
32
- const n = e.resolved_at ?? e.due_at, i = `${g(n, t)} (${p(n)})`, u = e.reason ? ` — ${e.reason}` : "", m = ((c = e.label) == null ? void 0 : c.trim()) || (e.trigger === "transition" ? h(e.kind) : ""), a = m ? ` · ${m}` : "";
32
+ var r;
33
+ const n = e.resolved_at ?? e.due_at, i = `${h(n, t)} (${g(n)})`, m = e.reason ? ` — ${f(e.reason)}` : "", u = ((r = e.label) == null ? void 0 : r.trim()) || (e.trigger === "transition" ? w(e.kind) : ""), a = u ? ` · ${u}` : "";
33
34
  let s;
34
35
  if (e.outcome === "sent") s = `told ${i}${a}`;
35
36
  else if (e.outcome === "pending") {
36
- const r = Math.round((t.getTime() - new Date(e.due_at).getTime()) / 6e4);
37
- s = `sent ${i}${a}, awaiting acknowledgement (${r} min)`;
38
- } else e.outcome === "skipped" ? s = `should have been told ${i}${a}${u}` : e.outcome === "failed" ? s = `send failed ${i}${a}${u}` : e.outcome === "missing" ? s = `never told${a}${u}` : s = `still not told${a}${u}`;
37
+ const c = Math.round((t.getTime() - new Date(e.due_at).getTime()) / 6e4);
38
+ s = `sent ${i}${a}, awaiting acknowledgement (${c} min)`;
39
+ } else e.outcome === "skipped" ? s = `should have been told ${i}${a}${m}` : e.outcome === "failed" ? s = `send failed ${i}${a}${m}` : e.outcome === "missing" ? s = `never told${a}${m}` : s = `still not told${a}${m}`;
39
40
  return {
40
41
  api: e.api,
41
42
  tone: d(e.outcome),
@@ -49,5 +50,5 @@ function b(o, t = /* @__PURE__ */ new Date()) {
49
50
  });
50
51
  }
51
52
  export {
52
- b as bannerLines
53
+ T as bannerLines
53
54
  };
@@ -0,0 +1,13 @@
1
+ const o = /* @__PURE__ */ new Set(["id", "po", "req", "url", "sku", "uom", "erp", "api", "ids"]);
2
+ function i(n) {
3
+ const t = n.trim().replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[_\s.-]+/).filter(Boolean).map((e) => e.toLowerCase());
4
+ return t.length === 0 ? n : t.map((e, r) => o.has(e) ? e === "ids" ? "IDs" : e.toUpperCase() : r === 0 ? e.charAt(0).toUpperCase() + e.slice(1) : e).join(" ");
5
+ }
6
+ function s(n) {
7
+ const t = String(n ?? "").trim();
8
+ let e = /^skip_when_empty: (.+) empty$/.exec(t);
9
+ return e ? `this record has no ${i(e[1])} yet` : (e = /^skip_unless_any: none of (.+) is set$/.exec(t), e ? `this record has none of ${e[1].split(/,\s*/).filter(Boolean).map(i).join(", ")} yet` : (e = /^guard unmet: (.+)$/.exec(t), e ? `its send condition was not met (${e[1]})` : (e = /^not configured: (.+) missing on the action$/.exec(t), e ? `the send is not set up yet (${e[1]} is missing)` : (e = /^payload template error: (.+)$/.exec(t), e ? `the message could not be built (${e[1]})` : (e = /^flow condition rejected at "(.+)"$/.exec(t), e ? `a flow step ("${e[1]}") stopped it` : t)))));
10
+ }
11
+ export {
12
+ s as plainObligationReason
13
+ };
@@ -1,18 +1,41 @@
1
- function c(o, i, u = /* @__PURE__ */ new Date()) {
2
- var l;
3
- const t = {}, f = new URLSearchParams(i);
4
- for (const a of o ?? []) {
5
- const r = a.value_field ?? "id", n = a.url_param ? f.getAll(a.url_param).flatMap((e) => e.split(",")).map((e) => e.trim()).filter(Boolean) : [];
6
- if (n.length) {
7
- t[a.param] = n.map((e) => ({ [r]: e }));
1
+ function f(n, l) {
2
+ return n.getAll(l).flatMap((e) => e.split(",")).map((e) => e.trim()).filter(Boolean);
3
+ }
4
+ function p(n, l) {
5
+ const e = new URLSearchParams(l), t = /* @__PURE__ */ new Set();
6
+ for (const r of n ?? [])
7
+ r.url_param && e.has(r.url_param) && f(e, r.url_param).length === 0 && t.add(r.param);
8
+ return t;
9
+ }
10
+ function _(n, l, e) {
11
+ const t = new URLSearchParams(e);
12
+ for (const o of n ?? []) {
13
+ if (!o.url_param) continue;
14
+ const u = o.value_field ?? "id", a = (l[o.param] ?? []).map((i) => String(i[u] ?? "")).filter(Boolean);
15
+ t.set(o.url_param, a.join(","));
16
+ }
17
+ const r = t.toString();
18
+ return r ? `?${r}` : "";
19
+ }
20
+ function d(n, l, e = /* @__PURE__ */ new Date()) {
21
+ var u;
22
+ const t = {}, r = new URLSearchParams(l), o = p(n, l);
23
+ for (const a of n ?? []) {
24
+ const i = a.value_field ?? "id", s = a.url_param ? f(r, a.url_param) : [];
25
+ if (s.length) {
26
+ t[a.param] = (a.single ? s.slice(0, 1) : s).map((c) => ({ [i]: c }));
8
27
  continue;
9
28
  }
10
- (l = a.default_values) != null && l.length && (t[a.param] = a.default_values.map((e) => ({
11
- [r]: e === "$current_year" ? u.getFullYear() : e
12
- })));
29
+ if (o.has(a.param) || !((u = a.default_values) != null && u.length)) continue;
30
+ const m = a.single ? a.default_values.slice(0, 1) : a.default_values;
31
+ t[a.param] = m.map((c) => ({
32
+ [i]: c === "$current_year" ? e.getFullYear() : c
33
+ }));
13
34
  }
14
35
  return t;
15
36
  }
16
37
  export {
17
- c as initialFilterSelection
38
+ p as explicitAllUrlParams,
39
+ _ as filterSelectionToSearch,
40
+ d as initialFilterSelection
18
41
  };
@@ -38,7 +38,7 @@ const l = /* @__PURE__ */ new Set([
38
38
  "th",
39
39
  "td",
40
40
  "caption"
41
- ]), f = /* @__PURE__ */ new Set([
41
+ ]), c = /* @__PURE__ */ new Set([
42
42
  "script",
43
43
  "style",
44
44
  "iframe",
@@ -52,37 +52,46 @@ const l = /* @__PURE__ */ new Set([
52
52
  "template",
53
53
  "base",
54
54
  "noscript"
55
- ]), c = /* @__PURE__ */ new Set(["href", "title", "colspan", "rowspan", "start", "type"]), h = /^(https?:|mailto:|tel:)/i, u = (n) => {
55
+ ]), f = /* @__PURE__ */ new Set(["href", "title", "colspan", "rowspan", "start", "type"]), p = /^(https?:|mailto:|tel:)/i, u = (n) => {
56
56
  let e = "";
57
- for (const o of n) o.charCodeAt(0) > 32 && (e += o);
58
- return e = e.toLowerCase(), !e || h.test(e) ? !0 : !/^[a-z][a-z0-9+.-]*:/.test(e);
57
+ for (const r of n) r.charCodeAt(0) > 32 && (e += r);
58
+ return e = e.toLowerCase(), !e || p.test(e) ? !0 : !/^[a-z][a-z0-9+.-]*:/.test(e);
59
59
  };
60
+ function h(n) {
61
+ if (typeof DOMParser < "u") {
62
+ const e = new DOMParser().parseFromString(n, "text/html");
63
+ for (const r of e.body.querySelectorAll("script,style,template,noscript")) r.remove();
64
+ return (e.body.textContent || "").replace(/\s+/g, " ");
65
+ }
66
+ return n.replace(/<(script|style|template|noscript)\b[\s\S]*?<\/\1>/gi, " ").replace(/<[^>]+>/g, " ").replace(/&nbsp;/g, " ").replace(/\s+/g, " ");
67
+ }
60
68
  function m(n) {
61
69
  if (typeof DOMParser > "u") return "";
62
- const e = new DOMParser().parseFromString(n, "text/html"), o = (i) => {
70
+ const e = new DOMParser().parseFromString(n, "text/html"), r = (i) => {
63
71
  for (const t of [...i.children]) {
64
72
  const s = t.tagName.toLowerCase();
65
73
  if (!l.has(s)) {
66
- if (f.has(s)) {
74
+ if (c.has(s)) {
67
75
  t.remove();
68
76
  continue;
69
77
  }
70
- const r = t.parentNode;
71
- if (r) {
72
- for (; t.firstChild; ) r.insertBefore(t.firstChild, t);
73
- r.removeChild(t);
78
+ const o = t.parentNode;
79
+ if (o) {
80
+ for (; t.firstChild; ) o.insertBefore(t.firstChild, t);
81
+ o.removeChild(t);
74
82
  }
75
83
  continue;
76
84
  }
77
- for (const r of [...t.attributes]) {
78
- const a = r.name.toLowerCase();
79
- (!c.has(a) || a === "href" && !u(r.value)) && t.removeAttribute(r.name);
85
+ for (const o of [...t.attributes]) {
86
+ const a = o.name.toLowerCase();
87
+ (!f.has(a) || a === "href" && !u(o.value)) && t.removeAttribute(o.name);
80
88
  }
81
- s === "a" && (t.setAttribute("rel", "noopener noreferrer"), t.setAttribute("target", "_blank")), o(t);
89
+ s === "a" && (t.setAttribute("rel", "noopener noreferrer"), t.setAttribute("target", "_blank")), r(t);
82
90
  }
83
91
  };
84
- return o(e.body), e.body.innerHTML;
92
+ return r(e.body), e.body.innerHTML;
85
93
  }
86
94
  export {
95
+ h as htmlToText,
87
96
  m as sanitizeHtml
88
97
  };