@nivaro/react 0.3.55 → 0.3.57

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,126 +1,126 @@
1
- import { jsxs as n, jsx as r, Fragment as ee } from "react/jsx-runtime";
2
- import { useQueryClient as te, useQuery as Q, useMutation as $ } from "@tanstack/react-query";
3
- import { ExternalLink as re, ArrowRight as O } from "lucide-react";
4
- import { useState as q, useEffect as ae } from "react";
1
+ import { jsxs as n, jsx as r, Fragment as te } from "react/jsx-runtime";
2
+ import { useQueryClient as re, useQuery as j, useMutation as $ } from "@tanstack/react-query";
3
+ import { ExternalLink as ae, ArrowRight as H } from "lucide-react";
4
+ import { useState as q, useEffect as ne } from "react";
5
5
  import { toast as C } from "sonner";
6
- import { useNivaroClient as ne, useItemNavigation as oe } from "../../context.js";
7
- import { get as B, post as D } from "../../lib/commands.js";
6
+ import { useNivaroClient as oe, useItemNavigation as se } from "../../context.js";
7
+ import { get as O, post as B } from "../../lib/commands.js";
8
8
  import { formatMultiValue as de } from "../../lib/format-value.js";
9
- import { useLiveRecord as se, batchTouches as F, LIVE_ASPECTS as H } from "../../lib/live.js";
10
- import { userErrorMessage as ie } from "../../lib/safe-error.js";
11
- import { cn as V, formatRelative as le, humanHours as ce } from "../../lib/utils.js";
12
- import { transitionRequirementsFromError as me } from "../panels/PipelinePanel.js";
13
- import { TransitionRequirementsDialog as ue } from "../panels/TransitionRequirementsDialog.js";
14
- import { Badge as pe } from "../ui/badge.js";
15
- import { Sheet as be, SheetContent as xe, SheetHeader as he, SheetTitle as fe } from "../ui/sheet.js";
16
- import { OwnerAvatars as ge } from "./OwnerAvatars.js";
17
- import { useTransitionNote as ye, needsTransitionNote as ve } from "./transition-note.js";
18
- function ke(t) {
19
- return (t ?? []).filter((l) => l.in_row_menu !== !1);
20
- }
21
- function Ne(t) {
22
- return ce(t);
23
- }
9
+ import { useLiveRecord as ie, batchTouches as D, LIVE_ASPECTS as F } from "../../lib/live.js";
10
+ import { userErrorMessage as le } from "../../lib/safe-error.js";
11
+ import { cn as V, formatRelative as ce, humanHours as me } from "../../lib/utils.js";
12
+ import { transitionRequirementsFromError as ue } from "../panels/PipelinePanel.js";
13
+ import { TransitionRequirementsDialog as pe } from "../panels/TransitionRequirementsDialog.js";
14
+ import { Badge as be } from "../ui/badge.js";
15
+ import { Sheet as xe, SheetContent as he, SheetHeader as fe, SheetTitle as ge } from "../ui/sheet.js";
16
+ import { OwnerAvatars as ye } from "./OwnerAvatars.js";
17
+ import { pathHeader as ve } from "./path-label.js";
18
+ import { useTransitionNote as ke, needsTransitionNote as Ne } from "./transition-note.js";
24
19
  function we(t) {
25
- return t.split(".").map((l) => l.replace(/_/g, " ").replace(/\b\w/g, (g) => g.toUpperCase())).join(" → ");
20
+ return (t ?? []).filter((b) => b.in_row_menu !== !1);
21
+ }
22
+ function _e(t) {
23
+ return me(t);
26
24
  }
27
- function b({ label: t, children: l }) {
25
+ const qe = ve;
26
+ function p({ label: t, children: b }) {
28
27
  return /* @__PURE__ */ n("div", { className: "bg-white px-3 py-2.5 dark:bg-card", children: [
29
28
  /* @__PURE__ */ r("p", { className: "mb-0.5 text-[10px] font-medium uppercase tracking-wide text-slate-400 dark:text-muted-foreground", children: t }),
30
- /* @__PURE__ */ r("div", { className: "text-[12px] text-slate-700 dark:text-slate-200", children: l })
29
+ /* @__PURE__ */ r("div", { className: "text-[12px] text-slate-700 dark:text-slate-200", children: b })
31
30
  ] });
32
31
  }
33
- function De({
32
+ function Ve({
34
33
  item: t,
35
- onOpenChange: l,
36
- onClaim: g,
37
- onRelease: L,
38
- workNextActive: U,
34
+ onOpenChange: b,
35
+ onClaim: W,
36
+ onRelease: z,
37
+ workNextActive: G,
39
38
  onNext: S,
40
39
  refetchItems: I,
41
- stateLabels: y,
40
+ stateLabels: g,
42
41
  collectionLabel: T,
43
- claimsEnabled: W = !0,
42
+ claimsEnabled: J = !0,
44
43
  columnFormats: x,
45
- width: z,
46
- itemLayout: G
44
+ fieldLabel: y,
45
+ width: U,
46
+ itemLayout: X
47
47
  }) {
48
- var j;
49
- const h = te(), f = ne(), { open: J } = oe(), [v, M] = q(""), [c, k] = q(null), [N, m] = q(null), P = ye(), o = t == null ? void 0 : t.collection, d = t == null ? void 0 : t.item_id;
50
- ae(() => m(null), [o, d]);
51
- const { data: u } = Q({
52
- queryKey: ["queue-sheet-instance", o, d],
53
- queryFn: () => f.request(B(`/pipelines/instance/${o}/${d}`)).then((e) => e.data),
54
- enabled: !!o && !!d
55
- }), { data: p } = Q({
56
- queryKey: ["queue-sheet-comments", o, d],
57
- queryFn: () => f.request(B("/comments", { collection: o, item: d })).then((e) => ({ data: (e.data ?? []).filter((a) => !a.deleted) })).catch(() => ({ data: [] })),
58
- enabled: !!o && !!d
59
- }), s = $({
48
+ var K;
49
+ const h = re(), f = oe(), { open: Y } = se(), [v, M] = q(""), [l, k] = q(null), [N, c] = q(null), P = ke(), o = t == null ? void 0 : t.collection, s = t == null ? void 0 : t.item_id;
50
+ ne(() => c(null), [o, s]);
51
+ const { data: m } = j({
52
+ queryKey: ["queue-sheet-instance", o, s],
53
+ queryFn: () => f.request(O(`/pipelines/instance/${o}/${s}`)).then((e) => e.data),
54
+ enabled: !!o && !!s
55
+ }), { data: u } = j({
56
+ queryKey: ["queue-sheet-comments", o, s],
57
+ queryFn: () => f.request(O("/comments", { collection: o, item: s })).then((e) => ({ data: (e.data ?? []).filter((a) => !a.deleted) })).catch(() => ({ data: [] })),
58
+ enabled: !!o && !!s
59
+ }), d = $({
60
60
  mutationFn: ({ transitionId: e, comment: a }) => f.request(
61
- D(`/pipelines/instance/${o}/${d}/transition`, {
61
+ B(`/pipelines/instance/${o}/${s}/transition`, {
62
62
  transition_id: e,
63
63
  ...a ? { comment: a } : {}
64
64
  })
65
65
  ),
66
66
  onSuccess: () => {
67
- k(null), m(null), h.invalidateQueries({ queryKey: ["queue-sheet-instance", o, d] }), I(), C.success("Transitioned");
67
+ k(null), c(null), h.invalidateQueries({ queryKey: ["queue-sheet-instance", o, s] }), I(), C.success("Transitioned");
68
68
  },
69
- onError: (e, { transitionId: a, comment: Z }) => {
70
- m(null);
71
- const K = me(e);
72
- if (K) {
69
+ onError: (e, { transitionId: a, comment: ee }) => {
70
+ c(null);
71
+ const Q = ue(e);
72
+ if (Q) {
73
73
  k((_) => ({
74
- payload: K,
74
+ payload: Q,
75
75
  transitionId: a,
76
- comment: Z,
76
+ comment: ee,
77
77
  revision: ((_ == null ? void 0 : _.revision) ?? 0) + 1
78
78
  }));
79
79
  return;
80
80
  }
81
- C.error(ie(e, "Transition failed"));
81
+ C.error(le(e, "Transition failed"));
82
82
  }
83
83
  }), R = $({
84
- mutationFn: (e) => f.request(D("/comments", { collection: o, item: d, text: e })),
84
+ mutationFn: (e) => f.request(B("/comments", { collection: o, item: s, text: e })),
85
85
  onSuccess: () => {
86
- M(""), h.invalidateQueries({ queryKey: ["queue-sheet-comments", o, d] });
86
+ M(""), h.invalidateQueries({ queryKey: ["queue-sheet-comments", o, s] });
87
87
  },
88
88
  onError: () => C.error("Failed to post comment")
89
89
  });
90
- se(o, d, (e) => {
91
- F(e, H.state) && (h.invalidateQueries({ queryKey: ["queue-sheet-instance", o, d] }), e.own || I()), F(e, H.comments) && h.invalidateQueries({ queryKey: ["queue-sheet-comments", o, d] });
90
+ ie(o, s, (e) => {
91
+ D(e, F.state) && (h.invalidateQueries({ queryKey: ["queue-sheet-instance", o, s] }), e.own || I()), D(e, F.comments) && h.invalidateQueries({ queryKey: ["queue-sheet-comments", o, s] });
92
92
  });
93
- const w = ke(u == null ? void 0 : u.available_transitions), i = N && w.some((e) => e.id === N.id) ? N : null, A = new Map(((u == null ? void 0 : u.states) ?? []).map((e) => [e.id, e])), E = (e) => {
93
+ const w = we(m == null ? void 0 : m.available_transitions), i = N && w.some((e) => e.id === N.id) ? N : null, A = new Map(((m == null ? void 0 : m.states) ?? []).map((e) => [e.id, e])), E = (e) => {
94
94
  const a = A.get(e.to_state);
95
95
  return e.label || (a == null ? void 0 : a.label) || (a == null ? void 0 : a.key) || "Move";
96
- }, X = (e) => {
96
+ }, Z = (e) => {
97
97
  const a = A.get(e.to_state);
98
98
  return (a == null ? void 0 : a.label) || (a == null ? void 0 : a.key) || e.label || "the next step";
99
- }, Y = async (e) => {
100
- if (!s.isPending) {
101
- if (ve(e)) {
102
- m(null);
99
+ }, L = async (e) => {
100
+ if (!d.isPending) {
101
+ if (Ne(e)) {
102
+ c(null);
103
103
  const a = await P.ask(E(e));
104
104
  if (!a) return;
105
- s.mutate({ transitionId: e.id, comment: a });
105
+ d.mutate({ transitionId: e.id, comment: a });
106
106
  return;
107
107
  }
108
- m(e);
108
+ c(e);
109
109
  }
110
110
  };
111
- return /* @__PURE__ */ n(be, { open: !!t, onOpenChange: l, children: [
111
+ return /* @__PURE__ */ n(xe, { open: !!t, onOpenChange: b, children: [
112
112
  /* @__PURE__ */ r(
113
- xe,
113
+ he,
114
114
  {
115
115
  side: "right",
116
116
  className: "flex max-w-full flex-col gap-0 p-0",
117
- style: { width: z ?? 480, maxWidth: "96vw" },
118
- children: t && /* @__PURE__ */ n(ee, { children: [
119
- /* @__PURE__ */ r(he, { className: "shrink-0 border-b border-slate-200 px-5 py-4 dark:border-border", children: /* @__PURE__ */ n("div", { className: "flex items-start justify-between gap-3 pr-6", children: [
117
+ style: { width: U ?? 480, maxWidth: "96vw" },
118
+ children: t && /* @__PURE__ */ n(te, { children: [
119
+ /* @__PURE__ */ r(fe, { className: "shrink-0 border-b border-slate-200 px-5 py-4 dark:border-border", children: /* @__PURE__ */ n("div", { className: "flex items-start justify-between gap-3 pr-6", children: [
120
120
  /* @__PURE__ */ n("div", { className: "min-w-0", children: [
121
- /* @__PURE__ */ r(fe, { className: "truncate text-[15px] font-semibold", children: t.label }),
121
+ /* @__PURE__ */ r(ge, { className: "truncate text-[15px] font-semibold", children: t.label }),
122
122
  /* @__PURE__ */ n("div", { className: "mt-1.5 flex items-center gap-2", children: [
123
- /* @__PURE__ */ r(pe, { variant: "outline", children: T ? T(t.collection) : t.collection }),
123
+ /* @__PURE__ */ r(be, { variant: "outline", children: T ? T(t.collection) : t.collection }),
124
124
  t.state && /* @__PURE__ */ r(
125
125
  "span",
126
126
  {
@@ -129,7 +129,7 @@ function De({
129
129
  backgroundColor: t.state_color ? `${t.state_color}1a` : void 0,
130
130
  color: t.state_color ?? void 0
131
131
  },
132
- children: (y == null ? void 0 : y[t.state]) ?? t.state
132
+ children: (g == null ? void 0 : g[t.state]) ?? t.state
133
133
  }
134
134
  )
135
135
  ] })
@@ -138,24 +138,24 @@ function De({
138
138
  "button",
139
139
  {
140
140
  type: "button",
141
- onClick: () => J({
141
+ onClick: () => Y({
142
142
  collection: t.collection,
143
143
  itemId: t.item_id,
144
- layoutSlug: G ?? null
144
+ layoutSlug: X ?? null
145
145
  }),
146
146
  className: "flex shrink-0 items-center gap-1 text-[12px] font-medium text-nvr-navy hover:underline dark:text-nvr-cyan",
147
147
  children: [
148
148
  "Open ",
149
- /* @__PURE__ */ r(re, { className: "h-3 w-3" })
149
+ /* @__PURE__ */ r(ae, { className: "h-3 w-3" })
150
150
  ]
151
151
  }
152
152
  )
153
153
  ] }) }),
154
154
  /* @__PURE__ */ n("div", { className: "flex-1 overflow-y-auto px-5 py-4", children: [
155
155
  /* @__PURE__ */ n("div", { className: "mb-4 grid grid-cols-2 gap-px overflow-hidden rounded-lg border border-slate-200 bg-slate-200 dark:border-border dark:bg-border", children: [
156
- /* @__PURE__ */ r(b, { label: "Owners", children: /* @__PURE__ */ r(ge, { owners: t.owners, max: 6 }) }),
157
- /* @__PURE__ */ r(b, { label: "Claimed by", children: ((j = t.claimed_by) == null ? void 0 : j.name) ?? "—" }),
158
- /* @__PURE__ */ r(b, { label: "SLA", children: t.sla_status ? /* @__PURE__ */ r(
156
+ /* @__PURE__ */ r(p, { label: "Owners", children: /* @__PURE__ */ r(ye, { owners: t.owners, max: 6 }) }),
157
+ /* @__PURE__ */ r(p, { label: "Claimed by", children: ((K = t.claimed_by) == null ? void 0 : K.name) ?? "—" }),
158
+ /* @__PURE__ */ r(p, { label: "SLA", children: t.sla_status ? /* @__PURE__ */ r(
159
159
  "span",
160
160
  {
161
161
  className: V(
@@ -165,9 +165,9 @@ function De({
165
165
  children: t.sla_status
166
166
  }
167
167
  ) : "—" }),
168
- /* @__PURE__ */ r(b, { label: "Aging", children: Ne(t.aging_hours) }),
169
- t.at_risk && /* @__PURE__ */ r(b, { label: "Risk", children: /* @__PURE__ */ r("span", { className: "text-red-500", children: "⚑ At risk" }) }),
170
- Object.entries(t.extra ?? {}).map(([e, a]) => /* @__PURE__ */ r(b, { label: we(e), children: a == null || a === "" ? "—" : x != null && x[e] ? de(String(a), x[e]) : String(a) }, e))
168
+ /* @__PURE__ */ r(p, { label: "Aging", children: _e(t.aging_hours) }),
169
+ t.at_risk && /* @__PURE__ */ r(p, { label: "Risk", children: /* @__PURE__ */ r("span", { className: "text-red-500", children: "⚑ At risk" }) }),
170
+ Object.entries(t.extra ?? {}).map(([e, a]) => /* @__PURE__ */ r(p, { label: (y == null ? void 0 : y(e)) || qe(e), children: a == null || a === "" ? "—" : x != null && x[e] ? de(String(a), x[e]) : String(a) }, e))
171
171
  ] }),
172
172
  w.length > 0 && /* @__PURE__ */ n("div", { className: "mb-4", children: [
173
173
  /* @__PURE__ */ r("p", { className: "mb-1.5 text-[11px] font-medium uppercase tracking-wide text-slate-400 dark:text-muted-foreground", children: "Transitions" }),
@@ -175,16 +175,16 @@ function De({
175
175
  "button",
176
176
  {
177
177
  type: "button",
178
- disabled: s.isPending,
178
+ disabled: d.isPending,
179
179
  "aria-pressed": (i == null ? void 0 : i.id) === e.id,
180
- onClick: () => void Y(e),
180
+ onClick: () => void L(e),
181
181
  className: V(
182
182
  "flex items-center gap-1 rounded-md border border-slate-200 bg-white px-2.5 py-1.5 text-[12px] font-medium text-slate-700 hover:border-nvr-cyan hover:text-nvr-navy disabled:opacity-50 dark:border-border dark:bg-card dark:text-slate-200 dark:hover:text-nvr-cyan",
183
183
  (i == null ? void 0 : i.id) === e.id && "border-nvr-cyan"
184
184
  ),
185
185
  children: [
186
186
  E(e),
187
- /* @__PURE__ */ r(O, { className: "h-3 w-3 text-slate-400" })
187
+ /* @__PURE__ */ r(H, { className: "h-3 w-3 text-slate-400" })
188
188
  ]
189
189
  },
190
190
  e.id
@@ -202,7 +202,7 @@ function De({
202
202
  /* @__PURE__ */ r("span", { className: "font-semibold", children: t.label }),
203
203
  " to",
204
204
  " ",
205
- /* @__PURE__ */ r("span", { className: "font-semibold", children: X(i) }),
205
+ /* @__PURE__ */ r("span", { className: "font-semibold", children: Z(i) }),
206
206
  "?"
207
207
  ] }),
208
208
  /* @__PURE__ */ n("div", { className: "mt-2 flex gap-2", children: [
@@ -210,18 +210,18 @@ function De({
210
210
  "button",
211
211
  {
212
212
  type: "button",
213
- disabled: s.isPending,
214
- onClick: () => s.mutate({ transitionId: i.id }),
213
+ disabled: d.isPending,
214
+ onClick: () => d.mutate({ transitionId: i.id }),
215
215
  className: "h-7 rounded-md bg-nvr-cyan px-3 text-[12px] font-semibold text-white disabled:opacity-50",
216
- children: s.isPending ? "Moving…" : "Confirm"
216
+ children: d.isPending ? "Moving…" : "Confirm"
217
217
  }
218
218
  ),
219
219
  /* @__PURE__ */ r(
220
220
  "button",
221
221
  {
222
222
  type: "button",
223
- disabled: s.isPending,
224
- onClick: () => m(null),
223
+ disabled: d.isPending,
224
+ onClick: () => c(null),
225
225
  className: "h-7 rounded-md border border-slate-200 bg-white px-3 text-[12px] text-slate-600 hover:bg-muted disabled:opacity-50 dark:border-border dark:bg-card dark:text-slate-300",
226
226
  children: "Keep"
227
227
  }
@@ -231,11 +231,11 @@ function De({
231
231
  }
232
232
  )
233
233
  ] }),
234
- (W || t.claimed_by) && /* @__PURE__ */ r("div", { className: "mb-4", children: /* @__PURE__ */ r(
234
+ (J || t.claimed_by) && /* @__PURE__ */ r("div", { className: "mb-4", children: /* @__PURE__ */ r(
235
235
  "button",
236
236
  {
237
237
  type: "button",
238
- onClick: () => t.claimed_by ? L(t) : g(t),
238
+ onClick: () => t.claimed_by ? z(t) : W(t),
239
239
  className: "rounded-md bg-nvr-cyan px-3 py-1.5 text-[12px] font-medium text-white hover:bg-nvr-cyan/90",
240
240
  children: t.claimed_by ? "Release claim" : "Claim this item"
241
241
  }
@@ -243,14 +243,14 @@ function De({
243
243
  /* @__PURE__ */ n("div", { children: [
244
244
  /* @__PURE__ */ r("p", { className: "mb-1.5 text-[11px] font-medium uppercase tracking-wide text-slate-400 dark:text-muted-foreground", children: "Comments" }),
245
245
  /* @__PURE__ */ n("div", { className: "space-y-2.5", children: [
246
- ((p == null ? void 0 : p.data) ?? []).map((e) => /* @__PURE__ */ n("div", { className: "rounded-md bg-slate-50 px-3 py-2 dark:bg-muted/40", children: [
246
+ ((u == null ? void 0 : u.data) ?? []).map((e) => /* @__PURE__ */ n("div", { className: "rounded-md bg-slate-50 px-3 py-2 dark:bg-muted/40", children: [
247
247
  /* @__PURE__ */ n("p", { className: "text-[11px] font-medium text-slate-500 dark:text-muted-foreground", children: [
248
248
  [e.first_name, e.last_name].filter(Boolean).join(" ") || e.email || "—",
249
- /* @__PURE__ */ r("span", { className: "ml-1.5 font-normal text-slate-400", children: le(e.created_at) })
249
+ /* @__PURE__ */ r("span", { className: "ml-1.5 font-normal text-slate-400", children: ce(e.created_at) })
250
250
  ] }),
251
251
  /* @__PURE__ */ r("p", { className: "mt-0.5 whitespace-pre-wrap text-[12px] text-slate-700 dark:text-slate-200", children: e.text })
252
252
  ] }, e.id)),
253
- ((p == null ? void 0 : p.data) ?? []).length === 0 && /* @__PURE__ */ r("p", { className: "text-[12px] text-slate-400", children: "No comments yet." })
253
+ ((u == null ? void 0 : u.data) ?? []).length === 0 && /* @__PURE__ */ r("p", { className: "text-[12px] text-slate-400", children: "No comments yet." })
254
254
  ] }),
255
255
  /* @__PURE__ */ n("div", { className: "mt-2.5", children: [
256
256
  /* @__PURE__ */ r(
@@ -276,7 +276,7 @@ function De({
276
276
  ] })
277
277
  ] })
278
278
  ] }),
279
- U && S && /* @__PURE__ */ r("div", { className: "shrink-0 border-t border-slate-200 px-5 py-3 dark:border-border", children: /* @__PURE__ */ n(
279
+ G && S && /* @__PURE__ */ r("div", { className: "shrink-0 border-t border-slate-200 px-5 py-3 dark:border-border", children: /* @__PURE__ */ n(
280
280
  "button",
281
281
  {
282
282
  type: "button",
@@ -284,32 +284,32 @@ function De({
284
284
  className: "flex w-full items-center justify-center gap-1.5 rounded-md bg-nvr-cyan px-3 py-2 text-[13px] font-semibold text-white hover:bg-nvr-cyan/90",
285
285
  children: [
286
286
  "Next ",
287
- /* @__PURE__ */ r(O, { className: "h-3.5 w-3.5" })
287
+ /* @__PURE__ */ r(H, { className: "h-3.5 w-3.5" })
288
288
  ]
289
289
  }
290
290
  ) })
291
291
  ] })
292
292
  }
293
293
  ),
294
- c && /* @__PURE__ */ r(
295
- ue,
294
+ l && /* @__PURE__ */ r(
295
+ pe,
296
296
  {
297
- payload: c.payload,
298
- transitionId: c.transitionId,
299
- isRetry: c.revision > 1,
300
- onSubmitted: () => s.mutate({
301
- transitionId: c.transitionId,
302
- comment: c.comment
297
+ payload: l.payload,
298
+ transitionId: l.transitionId,
299
+ isRetry: l.revision > 1,
300
+ onSubmitted: () => d.mutate({
301
+ transitionId: l.transitionId,
302
+ comment: l.comment
303
303
  }),
304
- executing: s.isPending,
304
+ executing: d.isPending,
305
305
  onClose: () => k(null)
306
306
  },
307
- c.revision
307
+ l.revision
308
308
  ),
309
309
  P.dialog
310
310
  ] });
311
311
  }
312
312
  export {
313
- De as QueueItemSheet,
314
- ke as peekTransitions
313
+ Ve as QueueItemSheet,
314
+ we as peekTransitions
315
315
  };