@parallelworks/tandem-web 0.189.8 → 0.189.10

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,207 +1,152 @@
1
1
  import { api as e, unwrap as t } from "../api/client.js";
2
- import { meQuery as n, statusesQuery as r, teamsQuery as i } from "../api/queries.js";
3
- import { useIssuePicker as a } from "../lib/issuePicker.js";
4
- import { useCanTriage as o } from "../lib/roles.js";
2
+ import { statusesQuery as n, teamsQuery as r } from "../api/queries.js";
3
+ import { useIssuePicker as i } from "../lib/issuePicker.js";
4
+ import { useCanTriage as a } from "../lib/roles.js";
5
+ import { useShortcuts as o } from "../lib/shortcuts.js";
5
6
  import { TriageIcon as s } from "./icons.js";
6
- import { Button as c, Checkbox as l, Combobox as u, Popover as d, Select as f, Textarea as p } from "@parallelworks/ui";
7
- import { useId as m, useState as h } from "react";
8
- import { useErrorMessage as g } from "@parallelworks/problem/react";
9
- import { useTranslations as _ } from "use-intl";
10
- import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
11
- import { useMutation as x, useQuery as S, useQueryClient as C } from "@tanstack/react-query";
12
- import { CheckIcon as w, CloseIcon as T, DuplicateIcon as E } from "@parallelworks/ui/icons";
7
+ import { Button as c, Checkbox as l, Combobox as u, Select as d, Textarea as f } from "@parallelworks/ui";
8
+ import { useId as p, useState as m } from "react";
9
+ import { useErrorMessage as h } from "@parallelworks/problem/react";
10
+ import { useTranslations as g } from "use-intl";
11
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
12
+ import { useMutation as y, useQuery as b, useQueryClient as x } from "@tanstack/react-query";
13
+ import { CheckIcon as S, CloseIcon as C, DuplicateIcon as w } from "@parallelworks/ui/icons";
13
14
  // src/components/TriageBanner.tsx
14
- function D({ workspace: e, issue: t }) {
15
- let n = _("triage");
16
- return /* @__PURE__ */ b("div", {
17
- className: "mb-5 flex flex-wrap items-center gap-3 rounded-xl border border-border bg-muted/40 px-4 py-3",
18
- children: [
19
- /* @__PURE__ */ y(s, { className: "size-4 shrink-0 text-muted-foreground" }),
20
- /* @__PURE__ */ y("p", {
21
- className: "min-w-48 flex-1 text-sm",
22
- children: n("waiting")
23
- }),
24
- /* @__PURE__ */ y(O, {
25
- workspace: e,
26
- issue: t
27
- })
28
- ]
15
+ function T({ workspace: e, issue: t, shortcuts: n = !1 }) {
16
+ let r = g("triage");
17
+ return /* @__PURE__ */ v("div", {
18
+ className: "mb-5 flex flex-col gap-3 rounded-xl border border-border bg-muted/40 px-4 py-3",
19
+ children: [/* @__PURE__ */ v("p", {
20
+ className: "flex items-center gap-2 text-sm",
21
+ children: [/* @__PURE__ */ _(s, { className: "size-4 shrink-0 text-muted-foreground" }), r("waiting")]
22
+ }), /* @__PURE__ */ _(D, {
23
+ workspace: e,
24
+ issue: t,
25
+ shortcuts: n
26
+ })]
29
27
  });
30
28
  }
31
- function O({ workspace: s, issue: D, compact: O = !1 }) {
32
- let k = _("triage"), A = g(), j = C(), M = o(s, D.teamId), { data: N = [] } = S(i(s)), P = N.find((e) => e.id === D.teamId)?.key ?? "", { data: F = [] } = S({
33
- ...r(s, P),
34
- enabled: !!P
35
- }), { data: I } = S(n), L = { params: { path: {
36
- workspace: s,
37
- identifier: D.identifier
38
- } } }, R = (t) => e.POST("/api/v1/workspaces/{workspace}/issues/{identifier}/triage", {
39
- ...L,
40
- body: { decision: t }
41
- }), z = () => j.invalidateQueries({ queryKey: [
42
- "workspace",
43
- s,
44
- "issues"
45
- ] }), [B, V] = h(""), [H, U] = h(!1), W = x({
46
- mutationFn: async () => {
47
- let n = I?.user.username, r = H && n ? [{
48
- kind: "user",
49
- handle: n
50
- }] : void 0;
51
- B ? t(await e.PATCH("/api/v1/workspaces/{workspace}/issues/{identifier}", {
52
- ...L,
53
- body: {
54
- statusId: B,
55
- ...r && { addAssignees: r }
56
- }
57
- })) : (t(await R("accept")), r && t(await e.PATCH("/api/v1/workspaces/{workspace}/issues/{identifier}", {
58
- ...L,
59
- body: { addAssignees: r }
60
- })));
61
- },
62
- onSuccess: z
63
- }), [G, K] = h(""), q = x({
64
- mutationFn: async () => {
65
- G.trim() && t(await e.POST("/api/v1/workspaces/{workspace}/issues/{identifier}/comments", {
66
- ...L,
67
- body: { body: G.trim() }
68
- })), t(await R("decline"));
69
- },
70
- onSuccess: z
71
- }), J = x({
72
- mutationFn: async (n) => {
73
- t(await e.POST("/api/v1/workspaces/{workspace}/issues/{identifier}/relations", {
74
- ...L,
75
- body: {
76
- type: "duplicate",
77
- issue: n
78
- }
79
- })), t(await R("decline"));
80
- },
81
- onSuccess: z
82
- }), Y = a(s, (e) => e.identifier !== D.identifier), X = m(), Z = W.error ?? q.error ?? J.error, Q = W.isPending || q.isPending || J.isPending, $ = F.filter((e) => e.category !== "triage" && e.category !== "canceled");
83
- return M ? /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ b("span", {
84
- className: O ? "flex items-center gap-0.5" : "flex flex-wrap gap-2",
29
+ function E(e) {
30
+ let t = e.filter((e) => e.category !== "triage" && e.category !== "completed" && e.category !== "canceled");
31
+ return t.find((e) => e.category === "unstarted") ?? t[0];
32
+ }
33
+ function D({ workspace: s, issue: T, shortcuts: D = !1 }) {
34
+ let O = g("triage"), k = h(), A = x(), j = a(s, T.teamId), { data: M = [] } = b(r(s)), N = M.find((e) => e.id === T.teamId)?.key ?? "", { data: P = [] } = b({
35
+ ...n(s, N),
36
+ enabled: !!N
37
+ }), F = y({
38
+ mutationFn: async (n) => t(await e.POST("/api/v1/workspaces/{workspace}/issues/{identifier}/triage", {
39
+ params: { path: {
40
+ workspace: s,
41
+ identifier: T.identifier
42
+ } },
43
+ body: n
44
+ })),
45
+ onSuccess: () => A.invalidateQueries({ queryKey: [
46
+ "workspace",
47
+ s,
48
+ "issues"
49
+ ] })
50
+ }), I = P.filter((e) => e.category !== "triage" && e.category !== "completed" && e.category !== "canceled"), [L, R] = m(null), z = L ?? E(P)?.id ?? "", [B, V] = m(T.assignees.length === 0), [H, U] = m(!1), [W, G] = m(""), K = i(s, (e) => e.identifier !== T.identifier), q = p(), J = () => F.mutate({
51
+ decision: "accept",
52
+ ...z && { statusId: z },
53
+ assignToMe: B
54
+ }), Y = () => F.mutate({
55
+ decision: "decline",
56
+ reason: W.trim()
57
+ });
58
+ if (o({
59
+ 1: J,
60
+ 2: Y
61
+ }, D && j && !F.isPending), !j) return null;
62
+ let X = F.isPending;
63
+ return /* @__PURE__ */ v("div", {
64
+ className: "flex flex-col gap-2",
85
65
  children: [
86
- /* @__PURE__ */ y(u, {
87
- "aria-label": k("markDuplicate"),
88
- ...Y,
89
- value: null,
90
- onValueChange: (e) => e && J.mutate(e),
91
- placeholder: k("findIssue"),
92
- trigger: O ? /* @__PURE__ */ y(c, {
93
- variant: "ghost",
94
- size: "sm",
95
- "aria-label": k("markDuplicate"),
96
- title: k("markDuplicate"),
97
- disabled: Q,
98
- children: /* @__PURE__ */ y(E, {})
99
- }) : /* @__PURE__ */ y(c, {
100
- variant: "ghost",
101
- size: "sm",
102
- disabled: Q,
103
- children: k("markDuplicate")
104
- })
105
- }),
106
- /* @__PURE__ */ y(d, {
107
- trigger: O ? /* @__PURE__ */ y(c, {
108
- variant: "ghost",
109
- size: "sm",
110
- "aria-label": k("decline"),
111
- title: k("decline"),
112
- disabled: Q,
113
- children: /* @__PURE__ */ y(T, {})
114
- }) : /* @__PURE__ */ y(c, {
115
- variant: "outline",
116
- size: "sm",
117
- disabled: Q,
118
- children: k("decline")
119
- }),
120
- align: "end",
121
- className: "w-80",
122
- "aria-label": k("decline"),
123
- children: /* @__PURE__ */ b("form", {
124
- className: "flex flex-col gap-2",
125
- onSubmit: (e) => {
126
- e.preventDefault(), q.mutate();
127
- },
128
- children: [/* @__PURE__ */ y(p, {
129
- value: G,
130
- onChange: (e) => K(e.target.value),
131
- placeholder: k("declineReason"),
132
- "aria-label": k("declineReason"),
133
- rows: 3
134
- }), /* @__PURE__ */ y(c, {
135
- type: "submit",
66
+ /* @__PURE__ */ v("div", {
67
+ className: "flex flex-wrap items-center gap-2",
68
+ children: [
69
+ /* @__PURE__ */ _(d, {
70
+ "aria-label": O("acceptInto"),
71
+ value: z,
72
+ items: I.map((e) => ({
73
+ value: e.id,
74
+ label: e.name
75
+ })),
76
+ onValueChange: (e) => e && R(e),
77
+ className: "w-36"
78
+ }),
79
+ /* @__PURE__ */ v("span", {
80
+ className: "flex items-center gap-1.5 text-sm",
81
+ children: [/* @__PURE__ */ _(l, {
82
+ id: q,
83
+ checked: B,
84
+ onCheckedChange: (e) => V(e === !0)
85
+ }), /* @__PURE__ */ _("label", {
86
+ htmlFor: q,
87
+ children: O("assignToMe")
88
+ })]
89
+ }),
90
+ /* @__PURE__ */ v(c, {
136
91
  variant: "primary",
137
92
  size: "sm",
138
- loading: q.isPending,
139
- className: "self-end",
140
- children: k("decline")
141
- })]
142
- })
93
+ onClick: J,
94
+ disabled: X,
95
+ title: O("acceptKey"),
96
+ children: [/* @__PURE__ */ _(S, {}), O("accept")]
97
+ })
98
+ ]
143
99
  }),
144
- /* @__PURE__ */ y(d, {
145
- trigger: O ? /* @__PURE__ */ y(c, {
146
- variant: "ghost",
147
- size: "sm",
148
- "aria-label": k("accept"),
149
- title: k("accept"),
150
- disabled: Q,
151
- children: /* @__PURE__ */ y(w, {})
152
- }) : /* @__PURE__ */ y(c, {
153
- variant: "primary",
154
- size: "sm",
155
- disabled: Q,
156
- children: k("accept")
157
- }),
158
- align: "end",
159
- className: "w-72",
160
- "aria-label": k("accept"),
161
- children: /* @__PURE__ */ b("form", {
162
- className: "flex flex-col gap-3",
163
- onSubmit: (e) => {
164
- e.preventDefault(), W.mutate();
165
- },
166
- children: [
167
- /* @__PURE__ */ y(f, {
168
- "aria-label": k("acceptInto"),
169
- value: B,
170
- items: [{
171
- value: "",
172
- label: k("acceptWhereItIs")
173
- }, ...$.map((e) => ({
174
- value: e.id,
175
- label: e.name
176
- }))],
177
- onValueChange: (e) => V(e ?? "")
178
- }),
179
- /* @__PURE__ */ b("span", {
180
- className: "flex items-center gap-2 text-sm",
181
- children: [/* @__PURE__ */ y(l, {
182
- id: X,
183
- checked: H,
184
- onCheckedChange: (e) => U(e === !0)
185
- }), /* @__PURE__ */ y("label", {
186
- htmlFor: X,
187
- children: k("assignToMe")
188
- })]
100
+ /* @__PURE__ */ v("div", {
101
+ className: "flex flex-wrap items-center gap-2",
102
+ children: [
103
+ /* @__PURE__ */ v(c, {
104
+ variant: "outline",
105
+ size: "sm",
106
+ onClick: Y,
107
+ disabled: X,
108
+ title: O("declineKey"),
109
+ children: [/* @__PURE__ */ _(C, {}), O("decline")]
110
+ }),
111
+ !H && /* @__PURE__ */ _(c, {
112
+ variant: "ghost",
113
+ size: "sm",
114
+ onClick: () => U(!0),
115
+ disabled: X,
116
+ children: O("addReason")
117
+ }),
118
+ /* @__PURE__ */ _(u, {
119
+ "aria-label": O("markDuplicate"),
120
+ ...K,
121
+ value: null,
122
+ onValueChange: (e) => e && F.mutate({
123
+ decision: "duplicate",
124
+ duplicateOf: e,
125
+ reason: W.trim()
189
126
  }),
190
- /* @__PURE__ */ y(c, {
191
- type: "submit",
192
- variant: "primary",
127
+ placeholder: O("findIssue"),
128
+ trigger: /* @__PURE__ */ v(c, {
129
+ variant: "ghost",
193
130
  size: "sm",
194
- loading: W.isPending,
195
- className: "self-end",
196
- children: k("accept")
131
+ disabled: X,
132
+ children: [/* @__PURE__ */ _(w, {}), O("markDuplicate")]
197
133
  })
198
- ]
199
- })
134
+ })
135
+ ]
136
+ }),
137
+ H && /* @__PURE__ */ _(f, {
138
+ value: W,
139
+ onChange: (e) => G(e.target.value),
140
+ placeholder: O("declineReason"),
141
+ "aria-label": O("declineReason"),
142
+ rows: 2,
143
+ autoFocus: !0
144
+ }),
145
+ F.error && /* @__PURE__ */ _("p", {
146
+ className: "text-xs text-danger",
147
+ children: k(F.error)
200
148
  })
201
149
  ]
202
- }), Z && /* @__PURE__ */ y("p", {
203
- className: "basis-full text-xs text-danger",
204
- children: A(Z)
205
- })] }) : null;
150
+ });
206
151
  }
207
- export { O as TriageActions, D as TriageBanner };
152
+ export { D as TriageActions, T as TriageBanner, E as acceptStatus };
package/lib/glossary.js CHANGED
@@ -31,37 +31,50 @@ function c(e) {
31
31
  }
32
32
  return t;
33
33
  }
34
- function l(e, n, r = !1) {
35
- let a = [], s = /* @__PURE__ */ new Set(), l = c(n), u = 0;
36
- for (; u < e.length;) {
37
- if (u > 0 && t(e[u - 1]) || !t(e[u])) {
38
- u++;
34
+ var l = /\s/;
35
+ function u(e, t, n) {
36
+ let r = t, i = n;
37
+ for (; r > 0 && !l.test(e[r - 1] ?? "");) r--;
38
+ for (; i < e.length && !l.test(e[i] ?? "");) i++;
39
+ let a = (e.slice(r, t) + e.slice(n, i)).replace(/[.,;:!?)\]}"'’”]+$/u, "");
40
+ return /[/<>=?]/.test(a);
41
+ }
42
+ function d(e, n, r = !1) {
43
+ let a = [], s = /* @__PURE__ */ new Set(), l = c(n), d = 0;
44
+ for (; d < e.length;) {
45
+ if (d > 0 && t(e[d - 1]) || !t(e[d])) {
46
+ d++;
47
+ continue;
48
+ }
49
+ let n = o(e, d), c = l.get(n.toLowerCase());
50
+ if (!c) {
51
+ d += n.length;
39
52
  continue;
40
53
  }
41
- let n = o(e, u), c = 0;
42
- for (let t of l.get(n.toLowerCase()) ?? []) {
43
- let n = i(e, u, t.text);
44
- if (n !== 0) {
54
+ let f = 0;
55
+ for (let t of c) {
56
+ let n = i(e, d, t.text);
57
+ if (!(n === 0 || u(e, d, d + n))) {
45
58
  (r || !s.has(t.id)) && (s.add(t.id), a.push({
46
- from: u,
47
- to: u + n,
59
+ from: d,
60
+ to: d + n,
48
61
  id: t.id
49
- })), c = n;
62
+ })), f = n;
50
63
  break;
51
64
  }
52
65
  }
53
- u += c > 0 ? c : n.length;
66
+ d += f > 0 ? f : n.length;
54
67
  }
55
68
  return a;
56
69
  }
57
- var u = 4;
58
- function d(e, t) {
59
- return e.filter((e) => e.key !== t && !e.template && e.title.trim().length >= u).map((e) => ({
70
+ var f = 4;
71
+ function p(e, t) {
72
+ return e.filter((e) => e.key !== t && !e.template && e.title.trim().length >= f).map((e) => ({
60
73
  text: e.title.trim(),
61
74
  id: `doc:${e.key}`
62
75
  })).sort((e, t) => t.text.length - e.text.length);
63
76
  }
64
- var f = (() => {
77
+ var m = (() => {
65
78
  let e = [], t = /* @__PURE__ */ new Set();
66
79
  return {
67
80
  forms: () => e,
@@ -76,18 +89,18 @@ var f = (() => {
76
89
  }
77
90
  };
78
91
  })();
79
- function p(e) {
92
+ function h(e) {
80
93
  return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu, "").replace(/\s+/g, "-");
81
94
  }
82
- function m(e) {
95
+ function g(e) {
83
96
  return e.replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/(\*\*|__|~~|`)(.+?)\1/g, "$2").replace(/(^|[^\w*])[*_]([^*_]+)[*_](?=[^\w*]|$)/g, "$1$2").trim();
84
97
  }
85
- function h(e) {
98
+ function _(e) {
86
99
  let t = [], n = "";
87
100
  for (let r of e.split("\n")) {
88
101
  let e = /^(`{3,}|~{3,})/.exec(r)?.[1];
89
102
  e && (!n || e.startsWith(n)) && (n = n ? "" : e);
90
- let i = n ? null : /^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(r), a = i?.[2] ? m(i[2]) : "";
103
+ let i = n ? null : /^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(r), a = i?.[2] ? g(i[2]) : "";
91
104
  i?.[1] && a && t.push({
92
105
  level: i[1].length,
93
106
  text: a
@@ -95,4 +108,4 @@ function h(e) {
95
108
  }
96
109
  return t;
97
110
  }
98
- export { d as docForms, a as formsOf, f as glossary, p as headingAnchor, h as headings, l as mentions, m as plainHeading };
111
+ export { p as docForms, a as formsOf, m as glossary, h as headingAnchor, _ as headings, d as mentions, g as plainHeading };
package/lib/issueList.js CHANGED
@@ -42,7 +42,8 @@ function v(e) {
42
42
  "type",
43
43
  "fields",
44
44
  "q",
45
- "saved"
45
+ "saved",
46
+ "breakdown"
46
47
  ]) {
47
48
  let r = _(e[n]);
48
49
  r && (t[n] = r);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parallelworks/tandem-web",
3
- "version": "0.189.8",
3
+ "version": "0.189.10",
4
4
  "description": "Tandem's pages, for a host app to render in its own",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",