@nivaro/react 0.3.132 → 0.3.133

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.
@@ -10,7 +10,7 @@ import { noteReplayIdle as Me, createReplayIdleState as Ne, REPLAY_IDLE_RESTART_
10
10
  import { noteReplayEvent as Ue, createReplayCheckoutState as We } from "../shared/lib/replay-checkout.js";
11
11
  import { instrumentConsole as He, instrumentRequests as Ke, redactSecrets as $e } from "../shared/lib/replay-context.js";
12
12
  import { instrumentSocket as Be } from "../shared/lib/replay-socket.js";
13
- const ze = "nivaro-react@0.3.132", V = 1e4, Ye = 150, xe = 3e3, je = 600, Ge = (o) => `nvr_replay_resume${o ? `:${o}` : ""}`, X = () => typeof navigator > "u" || navigator.onLine !== !1;
13
+ const ze = "nivaro-react@0.3.133", V = 1e4, Ye = 150, xe = 3e3, je = 600, Ge = (o) => `nvr_replay_resume${o ? `:${o}` : ""}`, X = () => typeof navigator > "u" || navigator.onLine !== !1;
14
14
  function Je(o) {
15
15
  return typeof o.url != "string" || typeof fetch != "function" ? null : (f, u) => {
16
16
  const l = typeof o.getToken == "function" ? o.getToken() : void 0, d = { "Content-Type": "application/json" };
@@ -1,247 +1,247 @@
1
- import { jsxs as o, jsx as n, Fragment as w } from "react/jsx-runtime";
2
- import { useQuery as p } from "@tanstack/react-query";
3
- import { Info as N } from "lucide-react";
4
- import { useState as y, useRef as k, useEffect as _ } from "react";
5
- import { useNivaroClient as h } from "../../context.js";
6
- import { get as u } from "../../lib/commands.js";
7
- import { toLocalDateString as f, formatDateTime as v } from "../../lib/utils.js";
8
- function P(a, t, r) {
9
- for (const s of [
10
- ["record-audience", t, r],
11
- ["erp-submissions", t, String(r)],
12
- ["integration-obligations", "record", t, String(r)],
13
- ["record-integrations", t, r],
14
- ["record-external-ids", t, r],
15
- ["record-owner-history", t, r],
16
- ["record-mail-log", t, r],
17
- ["record-chat-mentions", t, r]
1
+ import { jsxs as l, jsx as d, Fragment as N } from "react/jsx-runtime";
2
+ import { useQuery as x } from "@tanstack/react-query";
3
+ import { Info as k } from "lucide-react";
4
+ import { useState as v, useRef as _, useEffect as $ } from "react";
5
+ import { useNivaroClient as m } from "../../context.js";
6
+ import { get as h } from "../../lib/commands.js";
7
+ import { toLocalDateString as g, formatDateTime as y } from "../../lib/utils.js";
8
+ function P(a, t, i) {
9
+ for (const n of [
10
+ ["record-audience", t, i],
11
+ ["erp-submissions", t, String(i)],
12
+ ["integration-obligations", "record", t, String(i)],
13
+ ["record-integrations", t, i],
14
+ ["record-external-ids", t, i],
15
+ ["record-owner-history", t, i],
16
+ ["record-mail-log", t, i],
17
+ ["record-chat-mentions", t, i]
18
18
  ])
19
- a.invalidateQueries({ queryKey: s });
19
+ a.invalidateQueries({ queryKey: n });
20
20
  }
21
- function U(a, t, r) {
22
- a.invalidateQueries({ queryKey: ["item", t, r] }), a.invalidateQueries({ queryKey: ["resolve-paths", t, r] }), a.invalidateQueries({
23
- predicate: (s) => s.queryKey[0] === "o2m-rows" && String(s.queryKey[3]) === r
24
- }), a.invalidateQueries({ queryKey: ["child-summary", t, r] }), a.invalidateQueries({ queryKey: ["last-touch", t, r] }), a.invalidateQueries({ queryKey: ["sla-breach", t, r] }), a.invalidateQueries({
25
- predicate: (s) => (s.queryKey[0] === "item-actions" || s.queryKey[0] === "ext-item-actions") && s.queryKey[1] === t && String(s.queryKey[2]) === r
26
- }), q(a, t, r);
21
+ function U(a, t, i) {
22
+ a.invalidateQueries({ queryKey: ["item", t, i] }), a.invalidateQueries({ queryKey: ["resolve-paths", t, i] }), a.invalidateQueries({
23
+ predicate: (n) => n.queryKey[0] === "o2m-rows" && String(n.queryKey[3]) === i
24
+ }), a.invalidateQueries({ queryKey: ["child-summary", t, i] }), a.invalidateQueries({ queryKey: ["last-touch", t, i] }), a.invalidateQueries({ queryKey: ["sla-breach", t, i] }), a.invalidateQueries({
25
+ predicate: (n) => (n.queryKey[0] === "item-actions" || n.queryKey[0] === "ext-item-actions") && n.queryKey[1] === t && String(n.queryKey[2]) === i
26
+ }), T(a, t, i);
27
27
  }
28
- const $ = 4e3;
29
- function q(a, t, r) {
30
- var e;
31
- const s = () => {
32
- a.invalidateQueries({ queryKey: ["comments", t, r] }), a.invalidateQueries({ queryKey: ["comments-related", t, r] });
28
+ const q = 4e3;
29
+ function T(a, t, i) {
30
+ var r;
31
+ const n = () => {
32
+ a.invalidateQueries({ queryKey: ["comments", t, i] }), a.invalidateQueries({ queryKey: ["comments-related", t, i] });
33
33
  };
34
- s();
35
- const l = setTimeout(s, $);
36
- (e = l.unref) == null || e.call(l);
34
+ n();
35
+ const c = setTimeout(n, q);
36
+ (r = c.unref) == null || r.call(c);
37
37
  }
38
38
  function W({
39
39
  collection: a,
40
40
  itemId: t,
41
- compact: r
41
+ compact: i
42
42
  }) {
43
- const [s, l] = y(!1), [e, i] = y("audience"), c = k(null);
44
- return _(() => {
45
- if (!s) return;
46
- const d = (x) => {
47
- var m;
48
- (m = c.current) != null && m.contains(x.target) || l(!1);
43
+ const [n, c] = v(!1), [r, e] = v("audience"), o = _(null);
44
+ return $(() => {
45
+ if (!n) return;
46
+ const s = (p) => {
47
+ var u;
48
+ (u = o.current) != null && u.contains(p.target) || c(!1);
49
49
  };
50
- return document.addEventListener("mousedown", d), () => document.removeEventListener("mousedown", d);
51
- }, [s]), /* @__PURE__ */ o("div", { ref: c, className: "relative", children: [
52
- /* @__PURE__ */ n(
50
+ return document.addEventListener("mousedown", s), () => document.removeEventListener("mousedown", s);
51
+ }, [n]), /* @__PURE__ */ l("div", { ref: o, className: "relative", children: [
52
+ /* @__PURE__ */ d(
53
53
  "button",
54
54
  {
55
55
  type: "button",
56
- onClick: () => l((d) => !d),
56
+ onClick: () => c((s) => !s),
57
57
  "data-tip": "Record insights — audience, integrations, owner history",
58
58
  title: "Record insights",
59
59
  "aria-label": "Record insights",
60
- className: r ? "inline-flex h-8 w-8 items-center justify-center transition-colors hover:bg-accent hover:text-accent-foreground" : "inline-flex h-9 items-center gap-1.5 rounded-md border border-input bg-background px-3 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground",
61
- children: /* @__PURE__ */ n(N, { className: r ? "h-4 w-4" : "h-3.5 w-3.5" })
60
+ className: i ? "inline-flex h-8 w-8 items-center justify-center transition-colors hover:bg-accent hover:text-accent-foreground" : "inline-flex h-9 items-center gap-1.5 rounded-md border border-input bg-background px-3 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground",
61
+ children: /* @__PURE__ */ d(k, { className: i ? "h-4 w-4" : "h-3.5 w-3.5" })
62
62
  }
63
63
  ),
64
- s && /* @__PURE__ */ o("div", { className: "absolute right-0 top-full z-[60] mt-1 w-[480px] max-w-[92vw] rounded-lg border border-slate-200 bg-white p-3 shadow-xl dark:border-border dark:bg-card", children: [
65
- /* @__PURE__ */ n("div", { className: "mb-2 flex gap-1", children: [
64
+ n && /* @__PURE__ */ l("div", { className: "absolute right-0 top-full z-[60] mt-1 w-[480px] max-w-[92vw] rounded-lg border border-slate-200 bg-white p-3 shadow-xl dark:border-border dark:bg-card", children: [
65
+ /* @__PURE__ */ d("div", { className: "mb-2 flex gap-1", children: [
66
66
  ["audience", "Audience"],
67
67
  ["integrations", "Integrations"],
68
68
  ["owners", "Owner history"],
69
69
  ["mail", "Mail"],
70
70
  ["chat", "Chat"]
71
- ].map(([d, x]) => /* @__PURE__ */ n(
71
+ ].map(([s, p]) => /* @__PURE__ */ d(
72
72
  "button",
73
73
  {
74
74
  type: "button",
75
- onClick: () => i(d),
76
- className: e === d ? "whitespace-nowrap rounded-md bg-nvr-cyan/10 px-2 py-1 text-[11.5px] font-medium text-nvr-navy dark:text-nvr-cyan" : "whitespace-nowrap rounded-md px-2 py-1 text-[11.5px] text-slate-500 hover:bg-muted",
77
- children: x
75
+ onClick: () => e(s),
76
+ className: r === s ? "whitespace-nowrap rounded-md bg-nvr-cyan/10 px-2 py-1 text-[11.5px] font-medium text-nvr-navy dark:text-nvr-cyan" : "whitespace-nowrap rounded-md px-2 py-1 text-[11.5px] text-slate-500 hover:bg-muted",
77
+ children: p
78
78
  },
79
- d
79
+ s
80
80
  )) }),
81
- e === "audience" && /* @__PURE__ */ n(K, { collection: a, itemId: t }),
82
- e === "integrations" && /* @__PURE__ */ n(L, { collection: a, itemId: t }),
83
- e === "owners" && /* @__PURE__ */ n(S, { collection: a, itemId: t }),
84
- e === "mail" && /* @__PURE__ */ n(E, { collection: a, itemId: t }),
85
- e === "chat" && /* @__PURE__ */ n(Q, { collection: a, itemId: t })
81
+ r === "audience" && /* @__PURE__ */ d(L, { collection: a, itemId: t }),
82
+ r === "integrations" && /* @__PURE__ */ d(S, { collection: a, itemId: t }),
83
+ r === "owners" && /* @__PURE__ */ d(R, { collection: a, itemId: t }),
84
+ r === "mail" && /* @__PURE__ */ d(E, { collection: a, itemId: t }),
85
+ r === "chat" && /* @__PURE__ */ d(Q, { collection: a, itemId: t })
86
86
  ] })
87
87
  ] });
88
88
  }
89
- const T = {
89
+ const K = {
90
90
  all: "all changes",
91
91
  create: "new records",
92
92
  update: "updates",
93
93
  delete: "deletions",
94
94
  workflow_transition: "state changes"
95
95
  };
96
- function K({ collection: a, itemId: t }) {
97
- const r = h(), { data: s, isLoading: l } = p({
96
+ function L({ collection: a, itemId: t }) {
97
+ const i = m(), { data: n, isLoading: c } = x({
98
98
  queryKey: ["record-audience", a, t],
99
- queryFn: () => r.request(u(`/audience/${a}/${t}`)).then((i) => i.data),
99
+ queryFn: () => i.request(h(`/audience/${a}/${t}`)).then((e) => e.data),
100
100
  staleTime: 3e4
101
101
  });
102
- if (l) return /* @__PURE__ */ n("p", { className: "text-[12px] text-slate-400", children: "Loading…" });
103
- const e = (s == null ? void 0 : s.people) ?? [];
104
- return e.length === 0 ? /* @__PURE__ */ n("p", { className: "text-[12px] text-slate-400", children: "Nobody hears about changes here automatically — no owners, watchers, or subscribers." }) : /* @__PURE__ */ o("div", { className: "max-h-72 overflow-y-auto", children: [
105
- /* @__PURE__ */ o("p", { className: "pb-1.5 text-[10.5px] text-slate-400", children: [
106
- e.length,
102
+ if (c) return /* @__PURE__ */ d("p", { className: "text-[12px] text-slate-400", children: "Loading…" });
103
+ const r = (n == null ? void 0 : n.people) ?? [];
104
+ return r.length === 0 ? /* @__PURE__ */ d("p", { className: "text-[12px] text-slate-400", children: "Nobody hears about changes here automatically — no owners, watchers, or subscribers." }) : /* @__PURE__ */ l("div", { className: "max-h-72 overflow-y-auto", children: [
105
+ /* @__PURE__ */ l("p", { className: "pb-1.5 text-[10.5px] text-slate-400", children: [
106
+ r.length,
107
107
  " ",
108
- e.length === 1 ? "person hears" : "people hear",
108
+ r.length === 1 ? "person hears" : "people hear",
109
109
  " about changes to this record"
110
110
  ] }),
111
- e.map((i) => /* @__PURE__ */ o(
111
+ r.map((e) => /* @__PURE__ */ l(
112
112
  "div",
113
113
  {
114
114
  className: "border-t border-slate-100 py-1.5 first:border-t-0 dark:border-border/50",
115
115
  children: [
116
- /* @__PURE__ */ n("p", { className: "text-[12px] font-medium text-slate-700 dark:text-slate-200", children: i.name }),
117
- /* @__PURE__ */ o("div", { className: "mt-0.5 flex flex-wrap gap-1", children: [
118
- i.owner && /* @__PURE__ */ n("span", { className: "rounded-full bg-nvr-cyan/10 px-1.5 py-px text-[10.5px] font-medium text-nvr-navy dark:text-nvr-cyan", children: "Owner — notified on transitions" }),
119
- i.watch_fields.length > 0 && /* @__PURE__ */ o(
116
+ /* @__PURE__ */ d("p", { className: "text-[12px] font-medium text-slate-700 dark:text-slate-200", children: e.name }),
117
+ /* @__PURE__ */ l("div", { className: "mt-0.5 flex flex-wrap gap-1", children: [
118
+ e.owner && /* @__PURE__ */ d("span", { className: "rounded-full bg-nvr-cyan/10 px-1.5 py-px text-[10.5px] font-medium text-nvr-navy dark:text-nvr-cyan", children: "Owner — notified on transitions" }),
119
+ e.watch_fields.length > 0 && /* @__PURE__ */ l(
120
120
  "span",
121
121
  {
122
122
  className: "rounded-full bg-slate-100 px-1.5 py-px text-[10.5px] text-slate-600 dark:bg-muted dark:text-slate-300",
123
- "data-tip": i.watch_fields.join(", "),
123
+ "data-tip": e.watch_fields.join(", "),
124
124
  children: [
125
125
  "Chose to watch ",
126
- i.watch_fields.length,
126
+ e.watch_fields.length,
127
127
  " ",
128
- i.watch_fields.length === 1 ? "field" : "fields"
128
+ e.watch_fields.length === 1 ? "field" : "fields"
129
129
  ]
130
130
  }
131
131
  ),
132
- i.subscriptions.map((c) => /* @__PURE__ */ o(
132
+ e.subscriptions.map((o) => /* @__PURE__ */ l(
133
133
  "span",
134
134
  {
135
135
  className: "rounded-full bg-slate-100 px-1.5 py-px text-[10.5px] text-slate-600 dark:bg-muted dark:text-slate-300",
136
136
  children: [
137
- c.reason ?? `Subscribed to ${T[c.event_type] ?? c.event_type}`,
137
+ o.reason ?? `Subscribed to ${K[o.event_type] ?? o.event_type}`,
138
138
  " ·",
139
139
  " ",
140
- c.cadence
140
+ o.cadence
141
141
  ]
142
142
  },
143
- `${c.event_type}:${c.cadence}:${c.reason ?? ""}`
143
+ `${o.event_type}:${o.cadence}:${o.reason ?? ""}`
144
144
  ))
145
145
  ] })
146
146
  ]
147
147
  },
148
- i.id
148
+ e.id
149
149
  ))
150
150
  ] });
151
151
  }
152
- function L({ collection: a, itemId: t }) {
153
- const r = h(), { data: s = [], isLoading: l } = p({
152
+ function S({ collection: a, itemId: t }) {
153
+ const i = m(), { data: n = [], isLoading: c } = x({
154
154
  queryKey: ["erp-submissions", a, String(t)],
155
- queryFn: () => r.request(
156
- u(`/erp-submissions/${a}/${encodeURIComponent(t)}`)
157
- ).then((d) => d.data ?? []).catch(() => []),
155
+ queryFn: () => i.request(
156
+ h(`/erp-submissions/${a}/${encodeURIComponent(t)}`)
157
+ ).then((s) => s.data ?? []).catch(() => []),
158
158
  staleTime: 3e4
159
- }), { data: e, isLoading: i } = p({
159
+ }), { data: r, isLoading: e } = x({
160
160
  queryKey: ["record-integrations", a, t],
161
- queryFn: () => r.request(u(`/record-integrations/${a}/${t}`)).then((d) => d.data),
161
+ queryFn: () => i.request(h(`/record-integrations/${a}/${t}`)).then((s) => s.data),
162
162
  staleTime: 3e4
163
- }), { data: c = [] } = p({
163
+ }), { data: o = [] } = x({
164
164
  queryKey: ["record-external-ids", a, t],
165
- queryFn: () => r.request(u(`/items/${a}/${t}`)).then((d) => {
166
- const x = d.data ?? {}, m = /(external|nuvolo|mwf|oracle|sap|erp|legacy|fusion|mdsi).*(id|number|ref)|^(order_number|requisition_id|sales_order_id)$/i;
167
- return Object.entries(x).filter(([b, g]) => b !== "id" && g != null && g !== "" && m.test(b)).map(([b, g]) => ({ field: b, value: String(g).slice(0, 60) })).slice(0, 12);
165
+ queryFn: () => i.request(h(`/items/${a}/${t}`)).then((s) => {
166
+ const p = s.data ?? {}, u = /(external|nuvolo|mwf|oracle|sap|erp|legacy|fusion|mdsi).*(id|number|ref)|^(order_number|requisition_id|sales_order_id)$/i;
167
+ return Object.entries(p).filter(([b, f]) => b !== "id" && f != null && f !== "" && u.test(b)).map(([b, f]) => ({ field: b, value: String(f).slice(0, 60) })).slice(0, 12);
168
168
  }).catch(() => []),
169
169
  staleTime: 6e4
170
170
  });
171
- return i || l ? /* @__PURE__ */ n("p", { className: "text-[12px] text-slate-400", children: "Loading…" }) : s.length + ((e == null ? void 0 : e.webhooks.length) ?? 0) === 0 ? /* @__PURE__ */ n("p", { className: "text-[12px] text-slate-400", children: "No integration activity for this record." }) : /* @__PURE__ */ o(w, { children: [
172
- c.length > 0 && /* @__PURE__ */ o("div", { className: "border-b border-slate-100 px-3 py-2 dark:border-border/50", children: [
173
- /* @__PURE__ */ n("p", { className: "text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "External identifiers" }),
174
- /* @__PURE__ */ n("div", { className: "mt-1 flex flex-wrap gap-1.5", children: c.map((d) => /* @__PURE__ */ o(
171
+ return e || c ? /* @__PURE__ */ d("p", { className: "text-[12px] text-slate-400", children: "Loading…" }) : n.length + ((r == null ? void 0 : r.webhooks.length) ?? 0) === 0 ? /* @__PURE__ */ d("p", { className: "text-[12px] text-slate-400", children: "No integration activity for this record." }) : /* @__PURE__ */ l(N, { children: [
172
+ o.length > 0 && /* @__PURE__ */ l("div", { className: "border-b border-slate-100 px-3 py-2 dark:border-border/50", children: [
173
+ /* @__PURE__ */ d("p", { className: "text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "External identifiers" }),
174
+ /* @__PURE__ */ d("div", { className: "mt-1 flex flex-wrap gap-1.5", children: o.map((s) => /* @__PURE__ */ l(
175
175
  "span",
176
176
  {
177
177
  className: "inline-flex items-center gap-1 rounded border border-slate-200 bg-slate-50 px-1.5 py-0.5 text-[11px] dark:border-border dark:bg-muted/40",
178
178
  children: [
179
- /* @__PURE__ */ o("span", { className: "text-slate-400", children: [
180
- d.field,
179
+ /* @__PURE__ */ l("span", { className: "text-slate-400", children: [
180
+ s.field,
181
181
  ":"
182
182
  ] }),
183
- /* @__PURE__ */ n("span", { className: "font-mono text-slate-700 dark:text-slate-200", children: d.value })
183
+ /* @__PURE__ */ d("span", { className: "font-mono text-slate-700 dark:text-slate-200", children: s.value })
184
184
  ]
185
185
  },
186
- d.field
186
+ s.field
187
187
  )) })
188
188
  ] }),
189
- /* @__PURE__ */ o("div", { className: "max-h-72 space-y-1 overflow-y-auto text-[12px]", children: [
190
- s.map((d) => /* @__PURE__ */ o("p", { className: "flex items-baseline justify-between gap-2", children: [
191
- /* @__PURE__ */ n("span", { className: "min-w-0 truncate text-slate-700 dark:text-slate-200", children: d.external_api_name ?? d.target ?? d.endpoint_path ?? "ERP push" }),
192
- /* @__PURE__ */ o(
189
+ /* @__PURE__ */ l("div", { className: "max-h-72 space-y-1 overflow-y-auto text-[12px]", children: [
190
+ n.map((s) => /* @__PURE__ */ l("p", { className: "flex items-baseline justify-between gap-2", children: [
191
+ /* @__PURE__ */ d("span", { className: "min-w-0 truncate text-slate-700 dark:text-slate-200", children: s.external_api_name ?? s.target ?? s.endpoint_path ?? "ERP push" }),
192
+ /* @__PURE__ */ l(
193
193
  "span",
194
194
  {
195
- className: d.status === "failed" ? "shrink-0 text-red-500" : d.status === "accepted" ? "shrink-0 text-emerald-600" : "shrink-0 text-slate-400",
195
+ className: s.status === "failed" ? "shrink-0 text-red-500" : s.status === "accepted" ? "shrink-0 text-emerald-600" : "shrink-0 text-slate-400",
196
196
  children: [
197
- d.status,
197
+ s.status,
198
198
  " · ",
199
- f(d.created_at)
199
+ g(s.created_at)
200
200
  ]
201
201
  }
202
202
  )
203
- ] }, `e${d.id}`)),
204
- e == null ? void 0 : e.webhooks.map((d) => /* @__PURE__ */ o("p", { className: "flex items-baseline justify-between gap-2", children: [
205
- /* @__PURE__ */ o("span", { className: "min-w-0 truncate text-slate-700 dark:text-slate-200", children: [
203
+ ] }, `e${s.id}`)),
204
+ r == null ? void 0 : r.webhooks.map((s) => /* @__PURE__ */ l("p", { className: "flex items-baseline justify-between gap-2", children: [
205
+ /* @__PURE__ */ l("span", { className: "min-w-0 truncate text-slate-700 dark:text-slate-200", children: [
206
206
  "webhook: ",
207
- d.webhook
207
+ s.webhook
208
208
  ] }),
209
- /* @__PURE__ */ o("span", { className: "shrink-0 text-slate-400", children: [
210
- d.response_status,
209
+ /* @__PURE__ */ l("span", { className: "shrink-0 text-slate-400", children: [
210
+ s.response_status,
211
211
  " · ",
212
- f(d.created_at)
212
+ g(s.created_at)
213
213
  ] })
214
- ] }, `w${d.id}`))
214
+ ] }, `w${s.id}`))
215
215
  ] })
216
216
  ] });
217
217
  }
218
- function S({ collection: a, itemId: t }) {
219
- const r = h(), { data: s = [], isLoading: l } = p({
218
+ function R({ collection: a, itemId: t }) {
219
+ const i = m(), { data: n = [], isLoading: c } = x({
220
220
  queryKey: ["record-owner-history", a, t],
221
- queryFn: () => r.request(u(`/owner-history/${a}/${t}`)).then((e) => e.data),
221
+ queryFn: () => i.request(h(`/owner-history/${a}/${t}`)).then((r) => r.data),
222
222
  staleTime: 3e4
223
223
  });
224
- return l ? /* @__PURE__ */ n("p", { className: "text-[12px] text-slate-400", children: "Loading…" }) : s.length === 0 ? /* @__PURE__ */ n("p", { className: "text-[12px] text-slate-400", children: "No workflow history on this record." }) : /* @__PURE__ */ o("div", { className: "max-h-72 space-y-2 overflow-y-auto text-[12px]", children: [
225
- /* @__PURE__ */ n("p", { className: "text-[10.5px] text-amber-600 dark:text-amber-400", children: "Owners shown are resolved with TODAY's matrix config — membership changes since then aren't snapshotted." }),
226
- s.map((e, i) => (
224
+ return c ? /* @__PURE__ */ d("p", { className: "text-[12px] text-slate-400", children: "Loading…" }) : n.length === 0 ? /* @__PURE__ */ d("p", { className: "text-[12px] text-slate-400", children: "No workflow history on this record." }) : /* @__PURE__ */ l("div", { className: "max-h-72 space-y-2 overflow-y-auto text-[12px]", children: [
225
+ /* @__PURE__ */ d("p", { className: "text-[10.5px] text-amber-600 dark:text-amber-400", children: "Owners shown are resolved with TODAY's matrix config — membership changes since then aren't snapshotted." }),
226
+ n.map((r, e) => (
227
227
  // biome-ignore lint/suspicious/noArrayIndexKey: ordered stays
228
- /* @__PURE__ */ o("div", { children: [
229
- /* @__PURE__ */ o("p", { className: "font-medium text-slate-700 dark:text-slate-200", children: [
230
- e.state_label ?? "—",
228
+ /* @__PURE__ */ l("div", { children: [
229
+ /* @__PURE__ */ l("p", { className: "font-medium text-slate-700 dark:text-slate-200", children: [
230
+ r.state_label ?? "—",
231
231
  " ",
232
- /* @__PURE__ */ o("span", { className: "font-normal text-[10.5px] text-slate-400", children: [
233
- f(e.entered_at),
232
+ /* @__PURE__ */ l("span", { className: "font-normal text-[10.5px] text-slate-400", children: [
233
+ g(r.entered_at),
234
234
  " → ",
235
- e.left_at ? f(e.left_at) : "now",
236
- e.moved_by ? ` · moved by ${e.moved_by}` : ""
235
+ r.left_at ? g(r.left_at) : "now",
236
+ r.moved_by ? ` · moved by ${r.moved_by}` : ""
237
237
  ] })
238
238
  ] }),
239
- /* @__PURE__ */ n("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: e.owners.length > 0 ? e.owners.map((c) => c.name).join(", ") : "no resolved owners" })
240
- ] }, i)
239
+ /* @__PURE__ */ d("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: r.owners.length > 0 ? r.owners.map((o) => o.name).join(", ") : "no resolved owners" })
240
+ ] }, e)
241
241
  ))
242
242
  ] });
243
243
  }
244
- const R = {
244
+ const w = {
245
245
  sent: { label: "Sent", cls: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400" },
246
246
  failed: { label: "Failed", cls: "bg-red-500/10 text-red-600 dark:text-red-400" },
247
247
  deferred: { label: "In daily digest", cls: "bg-amber-500/10 text-amber-600 dark:text-amber-400" },
@@ -251,27 +251,36 @@ const R = {
251
251
  }
252
252
  };
253
253
  function j(a) {
254
- const t = a.split(/[,;]/).map((s) => s.trim()).filter(Boolean);
255
- return t.slice(0, 2).map((s) => s.split("@")[0]).join(", ") + (t.length > 2 ? ` +${t.length - 2}` : "");
254
+ const t = a.split(/[,;]/).map((n) => n.trim()).filter(Boolean);
255
+ return t.slice(0, 2).map((n) => n.split("@")[0]).join(", ") + (t.length > 2 ? ` +${t.length - 2}` : "");
256
256
  }
257
257
  function E({ collection: a, itemId: t }) {
258
- const r = h(), { data: s = [], isLoading: l } = p({
258
+ const i = m(), { data: n = [], isLoading: c } = x({
259
259
  queryKey: ["record-mail-log", a, t],
260
- queryFn: () => r.request(u(`/mail-log/record/${a}/${t}`)).then((e) => e.data ?? []).catch(() => []),
260
+ queryFn: () => i.request(h(`/mail-log/record/${a}/${t}`)).then((e) => e.data ?? []).catch(() => []),
261
261
  staleTime: 3e4
262
262
  });
263
- return l ? /* @__PURE__ */ n("p", { className: "p-3 text-[12px] text-slate-400", children: "Loading…" }) : s.length === 0 ? /* @__PURE__ */ n("p", { className: "p-3 text-[12px] text-slate-400", children: "No emails have been sent about this record." }) : /* @__PURE__ */ n("div", { className: "max-h-80 overflow-y-auto", children: s.map((e) => {
264
- const i = R[e.status] ?? {
263
+ if (c) return /* @__PURE__ */ d("p", { className: "p-3 text-[12px] text-slate-400", children: "Loading…" });
264
+ if (n.length === 0)
265
+ return /* @__PURE__ */ d("p", { className: "p-3 text-[12px] text-slate-400", children: "No emails have been sent about this record." });
266
+ const r = /* @__PURE__ */ new Map();
267
+ for (const e of n) {
268
+ if (e.resend_of == null) continue;
269
+ const o = r.get(Number(e.resend_of)) ?? [];
270
+ o.push(e), r.set(Number(e.resend_of), o);
271
+ }
272
+ return /* @__PURE__ */ d("div", { className: "max-h-80 overflow-y-auto", children: n.map((e) => {
273
+ const o = w[e.status] ?? {
265
274
  label: e.status,
266
275
  cls: "bg-slate-500/10 text-slate-500"
267
- };
268
- return /* @__PURE__ */ o(
276
+ }, s = r.get(e.id) ?? [], p = s[0], u = p ? w[p.status] ?? { label: p.status, cls: o.cls } : null;
277
+ return /* @__PURE__ */ l(
269
278
  "div",
270
279
  {
271
280
  className: "border-t border-slate-100 py-2 first:border-t-0 dark:border-border/50",
272
281
  children: [
273
- /* @__PURE__ */ o("div", { className: "flex items-start justify-between gap-2", children: [
274
- /* @__PURE__ */ n(
282
+ /* @__PURE__ */ l("div", { className: "flex items-start justify-between gap-2", children: [
283
+ /* @__PURE__ */ d(
275
284
  "p",
276
285
  {
277
286
  className: "min-w-0 text-[12px] leading-snug text-slate-700 [display:-webkit-box] [-webkit-box-orient:vertical] [-webkit-line-clamp:2] overflow-hidden dark:text-slate-200",
@@ -279,26 +288,36 @@ function E({ collection: a, itemId: t }) {
279
288
  children: e.subject
280
289
  }
281
290
  ),
282
- /* @__PURE__ */ n(
283
- "span",
284
- {
285
- className: `shrink-0 rounded-full px-1.5 py-px text-[10px] font-medium ${i.cls}`,
286
- children: i.label
287
- }
288
- )
291
+ /* @__PURE__ */ l("span", { className: "flex shrink-0 flex-col items-end gap-0.5", children: [
292
+ /* @__PURE__ */ d("span", { className: `rounded-full px-1.5 py-px text-[10px] font-medium ${o.cls}`, children: e.resend_of != null ? `Resend · ${o.label}` : o.label }),
293
+ p && u && /* @__PURE__ */ l(
294
+ "span",
295
+ {
296
+ "data-mail-resend-chip": p.status,
297
+ "data-tip": `Resent ${s.length === 1 ? "once" : `${s.length} times`} · last ${y(p.created_at)}`,
298
+ className: `whitespace-nowrap rounded-full px-1.5 py-px text-[10px] font-medium ${u.cls}`,
299
+ children: [
300
+ "Resent",
301
+ s.length > 1 ? ` ×${s.length}` : "",
302
+ " · ",
303
+ u.label
304
+ ]
305
+ }
306
+ )
307
+ ] })
289
308
  ] }),
290
- /* @__PURE__ */ o("p", { className: "mt-0.5 text-[10.5px] text-slate-400", children: [
291
- /* @__PURE__ */ o("span", { "data-tip": e.to, children: [
309
+ /* @__PURE__ */ l("p", { className: "mt-0.5 text-[10.5px] text-slate-400", children: [
310
+ /* @__PURE__ */ l("span", { "data-tip": e.to, children: [
292
311
  "to ",
293
312
  j(e.to)
294
313
  ] }),
295
314
  " · ",
296
- /* @__PURE__ */ n("span", { "data-tip": v(e.created_at), children: new Date(e.created_at).toLocaleDateString(void 0, {
315
+ /* @__PURE__ */ d("span", { "data-tip": y(e.created_at), children: new Date(e.created_at).toLocaleDateString(void 0, {
297
316
  month: "short",
298
317
  day: "numeric"
299
318
  }) })
300
319
  ] }),
301
- e.status === "failed" && e.error && /* @__PURE__ */ n(
320
+ e.status === "failed" && e.error && /* @__PURE__ */ d(
302
321
  "p",
303
322
  {
304
323
  className: "mt-0.5 truncate rounded bg-red-500/5 px-1.5 py-0.5 text-[10.5px] text-red-600 dark:text-red-400",
@@ -313,39 +332,39 @@ function E({ collection: a, itemId: t }) {
313
332
  }) });
314
333
  }
315
334
  function Q({ collection: a, itemId: t }) {
316
- const r = h(), { data: s = [], isLoading: l } = p({
335
+ const i = m(), { data: n = [], isLoading: c } = x({
317
336
  queryKey: ["record-chat-mentions", a, t],
318
- queryFn: () => r.request(u(`/chat/record-mentions/${a}/${t}`)).then((i) => i.data ?? []).catch(() => []),
337
+ queryFn: () => i.request(h(`/chat/record-mentions/${a}/${t}`)).then((e) => e.data ?? []).catch(() => []),
319
338
  staleTime: 6e4
320
339
  });
321
- if (l) return /* @__PURE__ */ n("p", { className: "p-3 text-[12px] text-slate-400", children: "Loading…" });
322
- if (s.length === 0)
323
- return /* @__PURE__ */ n("p", { className: "p-3 text-[12px] text-slate-400", children: "No chat messages mention this record outside its own room." });
324
- const e = (i) => i === "global" ? "#global" : i.startsWith("ch:") ? `#${i.slice(3)}` : i.startsWith("dm:") ? "a direct message" : i;
325
- return /* @__PURE__ */ n("div", { className: "max-h-72 overflow-y-auto", children: s.map((i) => /* @__PURE__ */ o(
340
+ if (c) return /* @__PURE__ */ d("p", { className: "p-3 text-[12px] text-slate-400", children: "Loading…" });
341
+ if (n.length === 0)
342
+ return /* @__PURE__ */ d("p", { className: "p-3 text-[12px] text-slate-400", children: "No chat messages mention this record outside its own room." });
343
+ const r = (e) => e === "global" ? "#global" : e.startsWith("ch:") ? `#${e.slice(3)}` : e.startsWith("dm:") ? "a direct message" : e;
344
+ return /* @__PURE__ */ d("div", { className: "max-h-72 overflow-y-auto", children: n.map((e) => /* @__PURE__ */ l(
326
345
  "div",
327
346
  {
328
347
  className: "border-b border-slate-100 px-3 py-1.5 last:border-b-0 dark:border-border/50",
329
348
  children: [
330
- /* @__PURE__ */ o("p", { className: "text-[12px] text-slate-700 dark:text-slate-200", children: [
331
- /* @__PURE__ */ n("span", { className: "font-medium", children: i.sender_name ?? "Someone" }),
349
+ /* @__PURE__ */ l("p", { className: "text-[12px] text-slate-700 dark:text-slate-200", children: [
350
+ /* @__PURE__ */ d("span", { className: "font-medium", children: e.sender_name ?? "Someone" }),
332
351
  " ",
333
- /* @__PURE__ */ o("span", { className: "text-slate-400", children: [
352
+ /* @__PURE__ */ l("span", { className: "text-slate-400", children: [
334
353
  "in ",
335
- e(i.room)
354
+ r(e.room)
336
355
  ] })
337
356
  ] }),
338
- /* @__PURE__ */ n("p", { className: "truncate text-[11.5px] text-slate-500", children: i.message.slice(0, 160) }),
339
- /* @__PURE__ */ n("p", { className: "text-[10px] text-slate-400", children: v(i.date_created) })
357
+ /* @__PURE__ */ d("p", { className: "truncate text-[11.5px] text-slate-500", children: e.message.slice(0, 160) }),
358
+ /* @__PURE__ */ d("p", { className: "text-[10px] text-slate-400", children: y(e.date_created) })
340
359
  ]
341
360
  },
342
- i.id
361
+ e.id
343
362
  )) });
344
363
  }
345
364
  export {
346
- $ as NOTES_SETTLE_MS,
365
+ q as NOTES_SETTLE_MS,
347
366
  W as RecordInsightsButton,
348
367
  U as invalidateRecordData,
349
368
  P as invalidateRecordInsights,
350
- q as invalidateRecordNotes
369
+ T as invalidateRecordNotes
351
370
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.132",
3
+ "version": "0.3.133",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",