@parallelworks/tandem-web 0.190.1 → 0.191.0

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