@parallelworks/tandem-web 0.194.0 → 0.194.2

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,13 +1,15 @@
1
- import { actorAvatar as e } from "../lib/avatar.js";
2
- import { usePeople as t } from "../lib/people.js";
3
- import { CycleIcon as n, PriorityIcon as r, ProjectIcon as i, StatusIcon as a, UserIcon as o, usePriorityNames as s } from "./icons.js";
4
- import { Avatar as c, Tabs as l } from "@parallelworks/ui";
5
- import { useLocale as u, useTranslations as d } from "use-intl";
6
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
7
- import { ListFilterBar as h, useListFilters as g } from "@parallelworks/ui/list";
1
+ import { labelsQuery as e, projectsQuery as t } from "../api/queries.js";
2
+ import { actorAvatar as n } from "../lib/avatar.js";
3
+ import { usePeople as r } from "../lib/people.js";
4
+ import { CycleIcon as i, PriorityIcon as a, ProjectIcon as o, StatusIcon as s, UserIcon as c, usePriorityNames as l } from "./icons.js";
5
+ import { Avatar as u, Tabs as d } from "@parallelworks/ui";
6
+ import { useLocale as f, useTranslations as p } from "use-intl";
7
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
8
+ import { useQuery as _ } from "@tanstack/react-query";
9
+ import { ListFilterBar as v, useListFilters as y } from "@parallelworks/ui/list";
8
10
  // src/components/IssueBreakdown.tsx
9
- var _ = "";
10
- function v(e, t) {
11
+ var b = "";
12
+ function x(e, t) {
11
13
  let n;
12
14
  switch (t) {
13
15
  case "statuses": return [e.status.id];
@@ -23,15 +25,15 @@ function v(e, t) {
23
25
  break;
24
26
  case "cycles": n = e.cycle ? [e.cycle.id] : [];
25
27
  }
26
- return n.length > 0 ? n : [_];
28
+ return n.length > 0 ? n : [b];
27
29
  }
28
- var y = [
30
+ var S = [
29
31
  1,
30
32
  2,
31
33
  3,
32
34
  4,
33
35
  0
34
- ], b = [
36
+ ], C = [
35
37
  "triage",
36
38
  "backlog",
37
39
  "unstarted",
@@ -39,11 +41,11 @@ var y = [
39
41
  "completed",
40
42
  "canceled"
41
43
  ];
42
- function x(e, t, n) {
43
- for (let [r, i] of Object.entries(t)) if (r !== n && i.length !== 0 && !v(e, r).some((e) => i.includes(e))) return !1;
44
+ function w(e, t, n) {
45
+ for (let [r, i] of Object.entries(t)) if (r !== n && i.length !== 0 && !x(e, r).some((e) => i.includes(e))) return !1;
44
46
  return !0;
45
47
  }
46
- var S = [
48
+ var T = [
47
49
  "statuses",
48
50
  "assignees",
49
51
  "labels",
@@ -51,123 +53,123 @@ var S = [
51
53
  "projects",
52
54
  "cycles"
53
55
  ];
54
- function C(e) {
56
+ function E(e) {
55
57
  let t = {};
56
58
  if (typeof e != "string") return t;
57
59
  for (let n of e.split(",")) {
58
60
  let e = n.indexOf(":"), r = n.slice(0, e);
59
- if (e < 0 || !S.includes(r)) continue;
61
+ if (e < 0 || !T.includes(r)) continue;
60
62
  let i = n.slice(e + 1), a = t[r] ?? [];
61
63
  a.includes(i) || (t[r] = [...a, i]);
62
64
  }
63
65
  return t;
64
66
  }
65
- function w(e) {
66
- let t = S.flatMap((t) => (e[t] ?? []).map((e) => `${t}:${e}`));
67
+ function D(e) {
68
+ let t = T.flatMap((t) => (e[t] ?? []).map((e) => `${t}:${e}`));
67
69
  return t.length > 0 ? t.join(",") : void 0;
68
70
  }
69
- var T = (e) => Object.values(e).reduce((e, t) => e + t.length, 0), E = (e) => e !== "cycles";
70
- function D(e, t, n) {
71
- let r = e[t] ?? [], i = r.includes(n) ? r.filter((e) => e !== n) : E(t) ? [...r, n] : [n], { [t]: a, ...o } = e;
71
+ var O = (e) => Object.values(e).reduce((e, t) => e + t.length, 0), k = (e) => e !== "cycles";
72
+ function A(e, t, n) {
73
+ let r = e[t] ?? [], i = r.includes(n) ? r.filter((e) => e !== n) : k(t) ? [...r, n] : [n], { [t]: a, ...o } = e;
72
74
  return i.length > 0 ? {
73
75
  ...o,
74
76
  [t]: i
75
77
  } : o;
76
78
  }
77
- function O(l) {
78
- let u = d("planning.issueBreakdown"), f = s(), { nameOf: m, avatarOf: h } = t(l);
79
- return (t, s, l) => {
80
- switch (t) {
79
+ function j(e) {
80
+ let t = p("planning.issueBreakdown"), d = l(), { nameOf: f, avatarOf: m } = r(e);
81
+ return (e, r, l) => {
82
+ switch (e) {
81
83
  case "statuses": return {
82
- name: s.status.name,
83
- icon: /* @__PURE__ */ p(a, {
84
- category: s.status.category,
85
- review: s.status.review,
86
- step: s.status.step
84
+ name: r.status.name,
85
+ icon: /* @__PURE__ */ h(s, {
86
+ category: r.status.category,
87
+ review: r.status.review,
88
+ step: r.status.step
87
89
  })
88
90
  };
89
91
  case "assignees": {
90
- if (l === _) return {
91
- name: u("noAssignee"),
92
- icon: /* @__PURE__ */ p(o, { className: "size-5 text-muted-foreground" })
92
+ if (l === b) return {
93
+ name: t("noAssignee"),
94
+ icon: /* @__PURE__ */ h(c, { className: "size-5 text-muted-foreground" })
93
95
  };
94
- let t = s.assignees.find((e) => `${e.kind}:${e.handle}` === l), n = t ? m(t.kind, t.handle) : l;
96
+ let e = r.assignees.find((e) => `${e.kind}:${e.handle}` === l), i = e ? f(e.kind, e.handle) : l;
95
97
  return {
96
- name: n,
97
- icon: t && /* @__PURE__ */ p(c, {
98
+ name: i,
99
+ icon: e && /* @__PURE__ */ h(u, {
98
100
  size: "xs",
99
- ...e(t.kind),
100
- name: n,
101
- src: h(t.kind, t.handle)
101
+ ...n(e.kind),
102
+ name: i,
103
+ src: m(e.kind, e.handle)
102
104
  })
103
105
  };
104
106
  }
105
107
  case "labels": {
106
- if (l === _) return {
107
- name: u("noLabel"),
108
- icon: /* @__PURE__ */ p(F, { color: "" })
108
+ if (l === b) return {
109
+ name: t("noLabel"),
110
+ icon: /* @__PURE__ */ h(R, { color: "" })
109
111
  };
110
- let e = s.labels.find((e) => e.id === l);
112
+ let e = r.labels.find((e) => e.id === l);
111
113
  return {
112
114
  name: e?.name ?? l,
113
- icon: /* @__PURE__ */ p(F, { color: e?.color ?? "" })
115
+ icon: /* @__PURE__ */ h(R, { color: e?.color ?? "" })
114
116
  };
115
117
  }
116
118
  case "priority": return {
117
- name: f[Number(l)] ?? l,
118
- icon: /* @__PURE__ */ p(r, {
119
+ name: d[Number(l)] ?? l,
120
+ icon: /* @__PURE__ */ h(a, {
119
121
  priority: Number(l),
120
122
  className: "text-muted-foreground"
121
123
  })
122
124
  };
123
- case "projects": return l === _ ? {
124
- name: u("noProject"),
125
- icon: /* @__PURE__ */ p(i, { className: "text-muted-foreground" })
125
+ case "projects": return l === b ? {
126
+ name: t("noProject"),
127
+ icon: /* @__PURE__ */ h(o, { className: "text-muted-foreground" })
126
128
  } : {
127
- name: s.project?.name ?? l,
128
- icon: /* @__PURE__ */ p(i, { className: "text-muted-foreground" })
129
+ name: r.project?.name ?? l,
130
+ icon: /* @__PURE__ */ h(o, { className: "text-muted-foreground" })
129
131
  };
130
132
  case "cycles": {
131
- let e = /* @__PURE__ */ p(n, { className: "text-muted-foreground" }), t = s.cycle;
132
- return l === _ || !t ? {
133
- name: u("noCycle"),
133
+ let e = /* @__PURE__ */ h(i, { className: "text-muted-foreground" }), n = r.cycle;
134
+ return l === b || !n ? {
135
+ name: t("noCycle"),
134
136
  icon: e
135
137
  } : {
136
- name: t.name ? u("cycleNamed", {
137
- number: t.number,
138
- name: t.name
139
- }) : u("cycle", { number: t.number }),
138
+ name: n.name ? t("cycleNamed", {
139
+ number: n.number,
140
+ name: n.name
141
+ }) : t("cycle", { number: n.number }),
140
142
  icon: e
141
143
  };
142
144
  }
143
145
  }
144
146
  };
145
147
  }
146
- function k({ workspace: e, issues: t, tabs: n, tab: r, onTabChange: i, focus: a, onFocus: o }) {
147
- let s = d("planning.issueBreakdown"), c = u(), h = O(e), g = new Intl.NumberFormat(c, {
148
+ function M({ workspace: e, issues: t, tabs: n, tab: r, onTabChange: i, focus: a, onFocus: o }) {
149
+ let s = p("planning.issueBreakdown"), c = f(), l = j(e), u = new Intl.NumberFormat(c, {
148
150
  style: "percent",
149
151
  maximumFractionDigits: 0
150
- }), S = a?.[r] ?? [], C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Map();
151
- for (let e of t) w.set(e.status.id, b.indexOf(e.status.category) * 1e3 + e.status.position);
152
+ }), _ = a?.[r] ?? [], v = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map();
153
+ for (let e of t) y.set(e.status.id, C.indexOf(e.status.category) * 1e3 + e.status.position);
152
154
  for (let e of t) {
153
155
  if (e.status.category === "canceled") continue;
154
- let t = v(e, r), n = !a || x(e, a, r);
156
+ let t = x(e, r), n = !a || w(e, a, r);
155
157
  for (let i of t) {
156
- if (!n && !S.includes(i)) continue;
157
- let t = C.get(i);
158
+ if (!n && !_.includes(i)) continue;
159
+ let t = v.get(i);
158
160
  t || (t = {
159
161
  key: i,
160
- ...h(r, e, i),
162
+ ...l(r, e, i),
161
163
  done: 0,
162
164
  total: 0
163
- }, C.set(i, t)), n && (t.done += +(e.status.category === "completed"), t.total++);
165
+ }, v.set(i, t)), n && (t.done += +(e.status.category === "completed"), t.total++);
164
166
  }
165
167
  }
166
- let E = [...C.values()].sort((e, t) => r === "statuses" ? (w.get(e.key) ?? 0) - (w.get(t.key) ?? 0) : r === "priority" ? y.indexOf(Number(e.key)) - y.indexOf(Number(t.key)) : r === "cycles" && e.key !== _ && t.key !== _ ? e.name.localeCompare(t.name, c, { numeric: !0 }) : e.key === _ == (t.key === _) ? t.total - e.total || e.name.localeCompare(t.name, c) : e.key === _ ? -1 : 1);
167
- return E.length === 0 && (!a || T(a) === 0) ? /* @__PURE__ */ p("p", {
168
+ let T = [...v.values()].sort((e, t) => r === "statuses" ? (y.get(e.key) ?? 0) - (y.get(t.key) ?? 0) : r === "priority" ? S.indexOf(Number(e.key)) - S.indexOf(Number(t.key)) : r === "cycles" && e.key !== b && t.key !== b ? e.name.localeCompare(t.name, c, { numeric: !0 }) : e.key === b == (t.key === b) ? t.total - e.total || e.name.localeCompare(t.name, c) : e.key === b ? -1 : 1);
169
+ return T.length === 0 && (!a || O(a) === 0) ? /* @__PURE__ */ h("p", {
168
170
  className: "rounded-lg border border-border px-4 py-5 text-sm text-muted-foreground",
169
171
  children: s("empty")
170
- }) : /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p(l, {
172
+ }) : /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h(d, {
171
173
  label: s("label"),
172
174
  variant: "line",
173
175
  size: "sm",
@@ -177,97 +179,107 @@ function k({ workspace: e, issues: t, tabs: n, tab: r, onTabChange: i, focus: a,
177
179
  })),
178
180
  value: r,
179
181
  onValueChange: i
180
- }), /* @__PURE__ */ p("ul", {
182
+ }), /* @__PURE__ */ h("ul", {
181
183
  className: "mt-3 space-y-0.5",
182
- children: E.map((e) => {
183
- let t = e.total ? e.done / e.total : 0, n = S.includes(e.key), i = /* @__PURE__ */ m(f, { children: [
184
- /* @__PURE__ */ p("span", {
184
+ children: T.map((e) => {
185
+ let t = e.total ? e.done / e.total : 0, n = _.includes(e.key), i = /* @__PURE__ */ g(m, { children: [
186
+ /* @__PURE__ */ h("span", {
185
187
  className: "flex size-5 shrink-0 items-center justify-center",
186
188
  children: e.icon
187
189
  }),
188
- /* @__PURE__ */ p("span", {
190
+ /* @__PURE__ */ h("span", {
189
191
  className: "min-w-0 flex-1 truncate",
190
192
  children: e.name
191
193
  }),
192
- /* @__PURE__ */ p(I, { share: t }),
193
- /* @__PURE__ */ p("span", {
194
+ /* @__PURE__ */ h(z, { share: t }),
195
+ /* @__PURE__ */ h("span", {
194
196
  className: "min-w-16 shrink-0 text-right text-xs whitespace-nowrap text-muted-foreground tabular-nums",
195
197
  title: s("doneOf", {
196
198
  done: e.done,
197
199
  total: e.total
198
200
  }),
199
201
  children: s("share", {
200
- percent: g.format(t),
202
+ percent: u.format(t),
201
203
  count: e.total
202
204
  })
203
205
  })
204
206
  ] }), c = "flex h-9 w-full items-center gap-2.5 rounded-md px-2 text-left text-sm";
205
- return /* @__PURE__ */ p("li", { children: o ? /* @__PURE__ */ p("button", {
207
+ return /* @__PURE__ */ h("li", { children: o ? /* @__PURE__ */ h("button", {
206
208
  type: "button",
207
209
  "aria-pressed": n,
208
- onClick: () => o(D(a ?? {}, r, e.key)),
210
+ onClick: () => o(A(a ?? {}, r, e.key)),
209
211
  className: `${c} transition-colors hover:bg-muted ${n ? "bg-muted" : ""}`,
210
212
  children: i
211
- }) : /* @__PURE__ */ p("div", {
213
+ }) : /* @__PURE__ */ h("div", {
212
214
  className: c,
213
215
  children: i
214
216
  }) }, e.key);
215
217
  })
216
218
  })] });
217
219
  }
218
- var A = {
220
+ var N = {
219
221
  statuses: "status",
220
222
  assignees: "assignee",
221
223
  labels: "label",
222
224
  priority: "priority",
223
225
  projects: "project",
224
226
  cycles: "cycle"
225
- }, j = ":none", M = (e) => e === _ ? j : e, N = (e) => e === j ? _ : e;
226
- function P({ workspace: e, issues: t, tabs: n, focus: r, onFocus: i, className: a }) {
227
- let o = d("planning.issueBreakdown"), s = d("issueFilters"), c = O(e), l = n.map((e) => {
228
- let n = /* @__PURE__ */ new Map();
229
- for (let r of t) for (let t of v(r, e)) if (!n.has(t)) {
230
- let { name: i, icon: a } = c(e, r, t);
231
- n.set(t, {
232
- value: M(t),
227
+ }, P = ":none", F = (e) => e === b ? P : e, I = (e) => e === P ? b : e;
228
+ function L({ workspace: n, issues: r, tabs: i, focus: a, onFocus: s, className: c }) {
229
+ let l = p("planning.issueBreakdown"), u = p("issueFilters"), d = j(n), { data: f = [] } = _(e(n)), { data: m = [] } = _(t(n)), g = i.map((e) => {
230
+ let t = /* @__PURE__ */ new Map();
231
+ for (let n of r) for (let r of x(n, e)) if (!t.has(r)) {
232
+ let { name: i, icon: a } = d(e, n, r);
233
+ t.set(r, {
234
+ value: F(r),
233
235
  label: i,
234
236
  icon: a
235
237
  });
236
238
  }
239
+ if (e === "labels") for (let e of f) t.has(e.id) || t.set(e.id, {
240
+ value: e.id,
241
+ label: e.name,
242
+ icon: /* @__PURE__ */ h(R, { color: e.color })
243
+ });
244
+ if (e === "projects") for (let e of m) t.has(e.id) || t.set(e.id, {
245
+ value: e.id,
246
+ label: e.name,
247
+ icon: /* @__PURE__ */ h(o, { className: "text-muted-foreground" })
248
+ });
237
249
  return {
238
250
  key: e,
239
- label: s(A[e]),
251
+ label: u(N[e]),
240
252
  kind: "enum",
241
253
  operators: ["is"],
242
- multiple: E(e),
243
- options: [...n.values()]
254
+ multiple: k(e),
255
+ options: [...t.values()]
244
256
  };
245
- }), u = g({
257
+ }), b = y({
246
258
  storageKey: "tandem:issueBreakdown",
247
- fields: l,
259
+ fields: g,
248
260
  remember: !1,
249
261
  store: {
250
- value: Object.entries(r).map(([e, t]) => ({
262
+ value: Object.entries(a).map(([e, t]) => ({
251
263
  field: e,
252
264
  op: "is",
253
- values: t.map(M)
265
+ values: t.map(F)
254
266
  })),
255
- onChange: (e) => i(Object.fromEntries(e.filter((e) => e.values.length > 0).map((e) => [e.field, e.values.map(N)])))
267
+ onChange: (e) => s(Object.fromEntries(e.filter((e) => e.values.length > 0).map((e) => [e.field, e.values.map(I)])))
256
268
  }
257
- }), f = t.filter((e) => x(e, r)).length;
258
- return T(r) === 0 ? null : /* @__PURE__ */ p(h, {
259
- filters: u,
260
- label: o("label"),
261
- className: a,
262
- trailing: /* @__PURE__ */ p("span", {
269
+ }), S = r.filter((e) => w(e, a)).length;
270
+ return O(a) === 0 ? null : /* @__PURE__ */ h(v, {
271
+ filters: b,
272
+ label: l("label"),
273
+ className: c,
274
+ trailing: /* @__PURE__ */ h("span", {
263
275
  className: "text-xs whitespace-nowrap text-muted-foreground",
264
276
  role: "status",
265
- children: o("showing", { count: f })
277
+ children: l("showing", { count: S })
266
278
  })
267
279
  });
268
280
  }
269
- function F({ color: e }) {
270
- return /* @__PURE__ */ p("span", {
281
+ function R({ color: e }) {
282
+ return /* @__PURE__ */ h("span", {
271
283
  className: "size-2.5 rounded-full border border-border",
272
284
  style: e ? {
273
285
  backgroundColor: e,
@@ -275,18 +287,18 @@ function F({ color: e }) {
275
287
  } : void 0
276
288
  });
277
289
  }
278
- function I({ share: e }) {
290
+ function z({ share: e }) {
279
291
  let t = 2 * Math.PI * 6;
280
- return e >= 1 ? /* @__PURE__ */ m("svg", {
292
+ return e >= 1 ? /* @__PURE__ */ g("svg", {
281
293
  viewBox: "0 0 16 16",
282
294
  className: "size-4 shrink-0 text-status-completed",
283
295
  "aria-hidden": "true",
284
- children: [/* @__PURE__ */ p("circle", {
296
+ children: [/* @__PURE__ */ h("circle", {
285
297
  cx: "8",
286
298
  cy: "8",
287
299
  r: "7",
288
300
  fill: "currentColor"
289
- }), /* @__PURE__ */ p("path", {
301
+ }), /* @__PURE__ */ h("path", {
290
302
  d: "M5 8.2 7 10l4-4.2",
291
303
  fill: "none",
292
304
  stroke: "var(--color-card)",
@@ -294,18 +306,18 @@ function I({ share: e }) {
294
306
  strokeLinecap: "round",
295
307
  strokeLinejoin: "round"
296
308
  })]
297
- }) : /* @__PURE__ */ m("svg", {
309
+ }) : /* @__PURE__ */ g("svg", {
298
310
  viewBox: "0 0 16 16",
299
311
  className: "size-4 shrink-0 -rotate-90",
300
312
  "aria-hidden": "true",
301
- children: [/* @__PURE__ */ p("circle", {
313
+ children: [/* @__PURE__ */ h("circle", {
302
314
  cx: "8",
303
315
  cy: "8",
304
316
  r: 6,
305
317
  fill: "none",
306
318
  strokeWidth: "2",
307
319
  className: "stroke-border"
308
- }), e > 0 && /* @__PURE__ */ p("circle", {
320
+ }), e > 0 && /* @__PURE__ */ h("circle", {
309
321
  cx: "8",
310
322
  cy: "8",
311
323
  r: 6,
@@ -317,4 +329,4 @@ function I({ share: e }) {
317
329
  })]
318
330
  });
319
331
  }
320
- export { P as BreakdownFilterBar, k as IssueBreakdown, T as breakdownCount, v as breakdownKeys, w as formatBreakdown, x as inBreakdown, C as parseBreakdown };
332
+ export { L as BreakdownFilterBar, M as IssueBreakdown, O as breakdownCount, x as breakdownKeys, D as formatBreakdown, w as inBreakdown, E as parseBreakdown };