@parallelworks/tandem-web 0.194.0 → 0.194.1

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.
@@ -15,100 +15,100 @@ import { useCan as S } from "../../../lib/roles.js";
15
15
  import { Link as C, useNavigate as w } from "../../../lib/router.js";
16
16
  import { useTime as T } from "../../../lib/time.js";
17
17
  import { Route as E } from "./_term.js";
18
- import { Button as D, ErrorText as O, Loader as k, PageHeader as re, Section as A, TitleInput as j, Tooltip as M, useOpenMenu as N } from "@parallelworks/ui";
19
- import { Suspense as P, useCallback as F, useMemo as I, useRef as L, useState as R } from "react";
20
- import { useErrorMessage as z } from "@parallelworks/problem/react";
21
- import { useTranslations as B } from "use-intl";
22
- import { Fragment as V, jsx as H, jsxs as U } from "react/jsx-runtime";
23
- import { useQuery as W, useSuspenseQuery as G } from "@tanstack/react-query";
24
- import { MoreButton as K } from "@parallelworks/ui/list";
18
+ import { Button as D, ErrorText as O, Loader as k, PageHeader as re, Section as A, TitleInput as j, Tooltip as M, useOpenMenu as ie } from "@parallelworks/ui";
19
+ import { Suspense as N, useCallback as P, useMemo as F, useRef as I, useState as L } from "react";
20
+ import { useErrorMessage as R } from "@parallelworks/problem/react";
21
+ import { useTranslations as z } from "use-intl";
22
+ import { Fragment as B, jsx as V, jsxs as H } from "react/jsx-runtime";
23
+ import { useQuery as U, useSuspenseQuery as W } from "@tanstack/react-query";
24
+ import { MoreButton as G } from "@parallelworks/ui/list";
25
25
  // src/routes/$workspace/knowledge/$term.tsx?tsr-split=component
26
- function q() {
27
- let { workspace: e, term: n } = E.useParams(), r = B("knowledge"), a = B("common"), o = w(), s = N(), p = z(), { data: m } = G(t(e, n)), { data: h } = G(i(e)), g = v(e), x = S(e, "edit_docs"), T = x && !m.archivedAt, [A, M] = R(null), W = F((e) => M(e), []), q = y(e, W), X = L(null), Z = u((t) => te(e, m.id, t));
26
+ function K() {
27
+ let { workspace: e, term: n } = E.useParams(), r = z("knowledge"), a = z("common"), o = w(), s = ie(), p = R(), { data: m } = W(t(e, n)), { data: h } = W(i(e)), g = v(e), x = S(e, "edit_docs"), T = x && !m.archivedAt, [A, M] = L(null), U = P((e) => M(e), []), K = y(e, U), Y = I(null), X = u((t) => te(e, m.id, t));
28
28
  ne(m.name);
29
- let Q = I(() => h.filter((e) => e.supersededBy === m.id), [h, m.id]), $ = (e) => g.update.mutate({
29
+ let Z = F(() => h.filter((e) => e.supersededBy === m.id), [h, m.id]), Q = (e) => g.update.mutate({
30
30
  id: m.id,
31
31
  ...e,
32
32
  ifVersion: m.version
33
- }), ae = m.status === "superseded";
34
- return /* @__PURE__ */ U("div", {
33
+ }), oe = m.status === "superseded", $ = m.status === "added" ? m.replacesName : void 0;
34
+ return /* @__PURE__ */ H("div", {
35
35
  className: "flex h-full min-h-0 flex-col",
36
36
  children: [
37
- /* @__PURE__ */ H(re, {
37
+ /* @__PURE__ */ V(re, {
38
38
  heading: !1,
39
39
  breadcrumbs: [{
40
40
  label: r("title"),
41
41
  href: `/${e}/knowledge`
42
42
  }, {
43
43
  label: m.name,
44
- icon: /* @__PURE__ */ H(ee, { className: "size-4 text-muted-foreground" })
44
+ icon: /* @__PURE__ */ V(ee, { className: "size-4 text-muted-foreground" })
45
45
  }],
46
- titleActions: /* @__PURE__ */ U(V, { children: [/* @__PURE__ */ H(f, {
46
+ titleActions: /* @__PURE__ */ H(B, { children: [/* @__PURE__ */ V(f, {
47
47
  workspace: e,
48
48
  kind: "term",
49
49
  target: m.id
50
- }), /* @__PURE__ */ H(K, {
51
- items: () => q(m),
50
+ }), /* @__PURE__ */ V(G, {
51
+ items: () => K(m),
52
52
  label: a("moreActionsFor", { name: m.name }),
53
53
  visible: !0
54
54
  })] }),
55
- actions: /* @__PURE__ */ U(V, { children: [g.update.isPending && /* @__PURE__ */ H("span", {
55
+ actions: /* @__PURE__ */ H(B, { children: [g.update.isPending && /* @__PURE__ */ V("span", {
56
56
  className: "text-xs text-muted-foreground",
57
57
  role: "status",
58
58
  children: a("saving")
59
- }), T && /* @__PURE__ */ H(D, {
59
+ }), T && /* @__PURE__ */ V(D, {
60
60
  type: "button",
61
61
  size: "sm",
62
- onClick: () => W({
62
+ onClick: () => U({
63
63
  kind: "edit",
64
64
  entry: m
65
65
  }),
66
66
  children: r("editDetails")
67
67
  })] })
68
68
  }),
69
- /* @__PURE__ */ H("div", {
69
+ /* @__PURE__ */ V("div", {
70
70
  className: "min-h-0 flex-1 overflow-y-auto",
71
- children: /* @__PURE__ */ U("article", {
71
+ children: /* @__PURE__ */ H("article", {
72
72
  className: "mx-auto w-full max-w-3xl px-4 pt-6 pb-20 md:px-8 md:pt-10",
73
73
  onContextMenu: (e) => {
74
- e.target instanceof Element && e.target.closest("textarea, .ProseMirror") || s(e, q(m));
74
+ e.target instanceof Element && e.target.closest("textarea, .ProseMirror") || s(e, K(m));
75
75
  },
76
76
  children: [
77
- m.archivedAt && /* @__PURE__ */ U("div", {
77
+ m.archivedAt && /* @__PURE__ */ H("div", {
78
78
  className: "mb-6 flex items-center gap-3 rounded-xl border border-border bg-muted px-3 py-2 text-sm",
79
- children: [/* @__PURE__ */ H("span", {
79
+ children: [/* @__PURE__ */ V("span", {
80
80
  className: "min-w-0 flex-1",
81
81
  children: r("archivedNotice")
82
- }), x && /* @__PURE__ */ H(D, {
82
+ }), x && /* @__PURE__ */ V(D, {
83
83
  type: "button",
84
84
  size: "sm",
85
85
  onClick: () => g.restore.mutate(m.id),
86
86
  children: r("restore")
87
87
  })]
88
88
  }),
89
- /* @__PURE__ */ H(J, {
89
+ /* @__PURE__ */ V(q, {
90
90
  workspace: e,
91
91
  entry: m
92
92
  }),
93
- /* @__PURE__ */ H("h1", {
93
+ /* @__PURE__ */ V("h1", {
94
94
  className: "sr-only",
95
95
  children: m.name
96
96
  }),
97
- /* @__PURE__ */ H(j, {
97
+ /* @__PURE__ */ V(j, {
98
98
  value: m.name,
99
- onCommit: (e) => $({ name: e }),
99
+ onCommit: (e) => Q({ name: e }),
100
100
  readOnly: !T,
101
101
  "aria-label": r("name"),
102
102
  maxLength: 100,
103
- className: ae ? "mt-2 text-muted-foreground line-through" : "mt-2"
103
+ className: oe ? "mt-2 text-muted-foreground line-through" : "mt-2"
104
104
  }),
105
- m.aliases.length > 0 && /* @__PURE__ */ H("p", {
105
+ m.aliases.length > 0 && /* @__PURE__ */ V("p", {
106
106
  className: "mt-1 text-sm text-muted-foreground",
107
107
  children: r("alsoCalled", { names: m.aliases.join(", ") })
108
108
  }),
109
- /* @__PURE__ */ H(j, {
109
+ /* @__PURE__ */ V(j, {
110
110
  value: m.definition,
111
- onCommit: (e) => $({ definition: e }),
111
+ onCommit: (e) => Q({ definition: e }),
112
112
  readOnly: !T,
113
113
  "aria-label": r("definition"),
114
114
  placeholder: r("definitionPlaceholder"),
@@ -116,78 +116,90 @@ function q() {
116
116
  size: "lg",
117
117
  className: "mt-3 text-base leading-relaxed font-normal tracking-normal text-muted-foreground"
118
118
  }),
119
- (m.supersededBy || Q.length > 0) && /* @__PURE__ */ U("div", {
119
+ (m.supersededBy || Z.length > 0 || $) && /* @__PURE__ */ H("div", {
120
120
  className: "mt-3 space-y-1 text-sm",
121
- children: [m.supersededBy && /* @__PURE__ */ H(C, {
122
- to: "/$workspace/knowledge/$term",
123
- params: {
124
- workspace: e,
125
- term: b(h.find((e) => e.id === m.supersededBy) ?? { id: m.supersededBy })
126
- },
127
- className: "block text-primary hover:underline",
128
- children: r("supersededBy", { name: m.supersededByName ?? "" })
129
- }), Q.map((t) => /* @__PURE__ */ H(C, {
130
- to: "/$workspace/knowledge/$term",
131
- params: {
132
- workspace: e,
133
- term: b(t)
134
- },
135
- className: "block text-muted-foreground hover:text-foreground",
136
- children: r("replaces", { name: t.name })
137
- }, t.id))]
121
+ children: [
122
+ $ && m.replaces && /* @__PURE__ */ V(C, {
123
+ to: "/$workspace/knowledge/$term",
124
+ params: {
125
+ workspace: e,
126
+ term: b(h.find((e) => e.id === m.replaces) ?? { id: m.replaces })
127
+ },
128
+ className: "block text-primary hover:underline",
129
+ children: r("suggestsChange", { name: $ })
130
+ }),
131
+ m.supersededBy && /* @__PURE__ */ V(C, {
132
+ to: "/$workspace/knowledge/$term",
133
+ params: {
134
+ workspace: e,
135
+ term: b(h.find((e) => e.id === m.supersededBy) ?? { id: m.supersededBy })
136
+ },
137
+ className: "block text-primary hover:underline",
138
+ children: r("supersededBy", { name: m.supersededByName ?? "" })
139
+ }),
140
+ Z.map((t) => /* @__PURE__ */ V(C, {
141
+ to: "/$workspace/knowledge/$term",
142
+ params: {
143
+ workspace: e,
144
+ term: b(t)
145
+ },
146
+ className: "block text-muted-foreground hover:text-foreground",
147
+ children: r("replaces", { name: t.name })
148
+ }, t.id))
149
+ ]
138
150
  }),
139
- /* @__PURE__ */ U("section", {
151
+ /* @__PURE__ */ H("section", {
140
152
  "aria-label": r("page"),
141
153
  className: "mt-8 border-t border-border pt-6",
142
154
  children: [
143
- T || m.body ? /* @__PURE__ */ H(d, {
155
+ T || m.body ? /* @__PURE__ */ V(d, {
144
156
  value: m.body ?? "",
145
157
  editable: T,
146
158
  placeholder: r("pagePlaceholder"),
147
159
  label: r("page"),
148
- onBlur: (e) => e !== (m.body ?? "") && $({ body: e }),
149
- onFiles: (e, t) => Z.upload(X.current, e, t),
160
+ onBlur: (e) => e !== (m.body ?? "") && Q({ body: e }),
161
+ onFiles: (e, t) => X.upload(Y.current, e, t),
150
162
  onEditor: (e) => {
151
- X.current = e;
163
+ Y.current = e;
152
164
  },
153
165
  className: "min-h-32 [&>:first-child]:mt-0"
154
- }) : /* @__PURE__ */ H("p", {
166
+ }) : /* @__PURE__ */ V("p", {
155
167
  className: "text-sm text-muted-foreground",
156
168
  children: r("noPage")
157
169
  }),
158
- T && /* @__PURE__ */ U("div", {
170
+ T && /* @__PURE__ */ H("div", {
159
171
  className: "mt-3 flex items-center gap-2",
160
172
  children: [
161
- /* @__PURE__ */ H(c, { onFiles: (e) => Z.upload(X.current, e) }),
162
- /* @__PURE__ */ H("span", {
173
+ /* @__PURE__ */ V(c, { onFiles: (e) => X.upload(Y.current, e) }),
174
+ /* @__PURE__ */ V("span", {
163
175
  className: "text-xs text-muted-foreground",
164
176
  children: r("attachHint")
165
177
  }),
166
- /* @__PURE__ */ H("span", {
178
+ /* @__PURE__ */ V("span", {
167
179
  className: "ml-auto",
168
- children: /* @__PURE__ */ H(l, {
169
- pending: Z.pending,
170
- error: Z.error
180
+ children: /* @__PURE__ */ V(l, {
181
+ pending: X.pending,
182
+ error: X.error
171
183
  })
172
184
  })
173
185
  ]
174
186
  }),
175
- g.update.isError && /* @__PURE__ */ H(O, {
187
+ g.update.isError && /* @__PURE__ */ V(O, {
176
188
  className: "mt-2",
177
189
  children: p(g.update.error)
178
190
  })
179
191
  ]
180
192
  }),
181
- /* @__PURE__ */ H(P, {
182
- fallback: /* @__PURE__ */ H(k, { fill: "section" }),
183
- children: /* @__PURE__ */ H(Y, {
193
+ /* @__PURE__ */ V(N, {
194
+ fallback: /* @__PURE__ */ V(k, { fill: "section" }),
195
+ children: /* @__PURE__ */ V(J, {
184
196
  workspace: e,
185
197
  entryId: m.id
186
198
  })
187
199
  }),
188
- /* @__PURE__ */ H(P, {
189
- fallback: /* @__PURE__ */ H(k, { fill: "section" }),
190
- children: /* @__PURE__ */ H(ie, {
200
+ /* @__PURE__ */ V(N, {
201
+ fallback: /* @__PURE__ */ V(k, { fill: "section" }),
202
+ children: /* @__PURE__ */ V(ae, {
191
203
  workspace: e,
192
204
  entryId: m.id
193
205
  })
@@ -195,7 +207,7 @@ function q() {
195
207
  ]
196
208
  })
197
209
  }),
198
- A && /* @__PURE__ */ H(P, { children: /* @__PURE__ */ H(_, {
210
+ A && /* @__PURE__ */ V(N, { children: /* @__PURE__ */ V(_, {
199
211
  workspace: e,
200
212
  mode: A,
201
213
  onClose: () => M(null),
@@ -211,34 +223,34 @@ function q() {
211
223
  ]
212
224
  });
213
225
  }
214
- function J({ workspace: t, entry: n }) {
215
- let r = B("knowledge"), { actorName: i } = x(t), a = T(), { data: o = [] } = W(e(t)), s = o.find((e) => e.id === n.areaId), c = n.source.doc, l = [
226
+ function q({ workspace: t, entry: n }) {
227
+ let r = z("knowledge"), { actorName: i } = x(t), a = T(), { data: o = [] } = U(e(t)), s = o.find((e) => e.id === n.areaId), c = n.source.doc, l = [
216
228
  ...n.kind === "term" ? [] : [r(`kind.${n.kind}`)],
217
229
  ...s ? [s.title] : [],
218
230
  r("writtenBy", { name: i(n.creator) }),
219
- /* @__PURE__ */ H(M, {
231
+ /* @__PURE__ */ V(M, {
220
232
  content: a.full(n.updatedAt),
221
- children: /* @__PURE__ */ H("time", {
233
+ children: /* @__PURE__ */ V("time", {
222
234
  dateTime: n.updatedAt,
223
235
  children: r("updated", { when: a.relative(n.updatedAt) })
224
236
  })
225
237
  }, "updated")
226
238
  ];
227
- return /* @__PURE__ */ U("div", {
239
+ return /* @__PURE__ */ H("div", {
228
240
  className: "space-y-1 text-xs text-muted-foreground",
229
- children: [/* @__PURE__ */ H("p", {
241
+ children: [/* @__PURE__ */ V("p", {
230
242
  className: "flex flex-wrap items-center gap-x-1.5 gap-y-1",
231
- children: l.map((e, t) => /* @__PURE__ */ U("span", {
243
+ children: l.map((e, t) => /* @__PURE__ */ H("span", {
232
244
  className: "inline-flex items-center gap-1.5",
233
- children: [t > 0 && /* @__PURE__ */ H("span", {
245
+ children: [t > 0 && /* @__PURE__ */ V("span", {
234
246
  "aria-hidden": "true",
235
247
  children: "·"
236
248
  }), e]
237
249
  }, t))
238
- }), (c || n.source.identifier) && /* @__PURE__ */ U("p", {
250
+ }), (c || n.source.identifier) && /* @__PURE__ */ H("p", {
239
251
  className: "flex flex-wrap items-center gap-x-3 gap-y-1",
240
252
  children: [
241
- c && /* @__PURE__ */ U(C, {
253
+ c && /* @__PURE__ */ H(C, {
242
254
  to: "/$workspace/docs/$doc",
243
255
  params: {
244
256
  workspace: t,
@@ -246,16 +258,16 @@ function J({ workspace: t, entry: n }) {
246
258
  },
247
259
  ...n.source.section && { hash: g(n.source.section) },
248
260
  className: "inline-flex items-center gap-1 hover:text-foreground",
249
- children: [/* @__PURE__ */ H(p, { className: "size-3" }), n.source.section ? r("sourceSection", {
261
+ children: [/* @__PURE__ */ V(p, { className: "size-3" }), n.source.section ? r("sourceSection", {
250
262
  doc: c.title,
251
263
  section: n.source.section
252
264
  }) : c.title]
253
265
  }),
254
- n.source.missing && /* @__PURE__ */ H("span", {
266
+ n.source.missing && /* @__PURE__ */ V("span", {
255
267
  className: "text-warning",
256
268
  children: r("sourceMissing", { section: n.source.section ?? "" })
257
269
  }),
258
- n.source.identifier && /* @__PURE__ */ U(C, {
270
+ n.source.identifier && /* @__PURE__ */ H(C, {
259
271
  to: "/$workspace/issues/$identifier",
260
272
  params: {
261
273
  workspace: t,
@@ -272,25 +284,25 @@ function J({ workspace: t, entry: n }) {
272
284
  })]
273
285
  });
274
286
  }
275
- function Y({ workspace: e, entryId: t }) {
276
- let n = B("knowledge"), { data: i } = W(r(e, t));
287
+ function J({ workspace: e, entryId: t }) {
288
+ let n = z("knowledge"), { data: i } = U(r(e, t));
277
289
  if (!i) return null;
278
290
  let a = i.issues.length + i.docs.length, o = "flex min-h-10 items-center gap-2.5 px-3 py-2 text-sm hover:bg-muted focus-visible:outline-offset-[-2px]";
279
- return /* @__PURE__ */ U("section", {
291
+ return /* @__PURE__ */ H("section", {
280
292
  "aria-label": n("mentionedIn"),
281
293
  className: "mt-12",
282
- children: [/* @__PURE__ */ U("h2", {
294
+ children: [/* @__PURE__ */ H("h2", {
283
295
  className: "mb-3 flex items-baseline gap-2 text-base font-semibold",
284
- children: [n("mentionedIn"), a > 0 && /* @__PURE__ */ H("span", {
296
+ children: [n("mentionedIn"), a > 0 && /* @__PURE__ */ V("span", {
285
297
  className: "text-xs font-normal text-muted-foreground tabular-nums",
286
298
  children: a
287
299
  })]
288
- }), a === 0 ? /* @__PURE__ */ H("p", {
300
+ }), a === 0 ? /* @__PURE__ */ V("p", {
289
301
  className: "text-sm text-muted-foreground",
290
302
  children: n("mentionedNone")
291
- }) : /* @__PURE__ */ U("ul", {
303
+ }) : /* @__PURE__ */ H("ul", {
292
304
  className: "divide-y divide-border overflow-hidden rounded-xl border border-border bg-card",
293
- children: [i.issues.map((t) => /* @__PURE__ */ H("li", { children: /* @__PURE__ */ U(C, {
305
+ children: [i.issues.map((t) => /* @__PURE__ */ V("li", { children: /* @__PURE__ */ H(C, {
294
306
  to: "/$workspace/issues/$identifier",
295
307
  params: {
296
308
  workspace: e,
@@ -298,20 +310,20 @@ function Y({ workspace: e, entryId: t }) {
298
310
  },
299
311
  className: o,
300
312
  children: [
301
- /* @__PURE__ */ H(m, {
313
+ /* @__PURE__ */ V(m, {
302
314
  category: t.statusCategory,
303
315
  className: "size-3.5 shrink-0"
304
316
  }),
305
- /* @__PURE__ */ H("span", {
317
+ /* @__PURE__ */ V("span", {
306
318
  className: "min-w-24 shrink-0 text-xs whitespace-nowrap text-muted-foreground tabular-nums",
307
319
  children: t.identifier
308
320
  }),
309
- /* @__PURE__ */ H("span", {
321
+ /* @__PURE__ */ V("span", {
310
322
  className: "min-w-0 truncate",
311
323
  children: t.title
312
324
  })
313
325
  ]
314
- }) }, t.identifier)), i.docs.map((t) => /* @__PURE__ */ H("li", { children: /* @__PURE__ */ U(C, {
326
+ }) }, t.identifier)), i.docs.map((t) => /* @__PURE__ */ V("li", { children: /* @__PURE__ */ H(C, {
315
327
  to: "/$workspace/docs/$doc",
316
328
  params: {
317
329
  workspace: e,
@@ -319,12 +331,12 @@ function Y({ workspace: e, entryId: t }) {
319
331
  },
320
332
  className: o,
321
333
  children: [
322
- /* @__PURE__ */ H(p, { className: "size-3.5 shrink-0 text-muted-foreground" }),
323
- /* @__PURE__ */ H("span", {
334
+ /* @__PURE__ */ V(p, { className: "size-3.5 shrink-0 text-muted-foreground" }),
335
+ /* @__PURE__ */ V("span", {
324
336
  className: "w-16 shrink-0 text-xs text-muted-foreground",
325
337
  children: n("doc")
326
338
  }),
327
- /* @__PURE__ */ H("span", {
339
+ /* @__PURE__ */ V("span", {
328
340
  className: "min-w-0 truncate",
329
341
  children: t.title
330
342
  })
@@ -333,27 +345,27 @@ function Y({ workspace: e, entryId: t }) {
333
345
  })]
334
346
  });
335
347
  }
336
- function ie({ workspace: e, entryId: t }) {
337
- let r = B("knowledge.history"), { data: i = [] } = W(n(e, t)), { actorName: c } = x(e);
338
- return i.length === 0 ? null : /* @__PURE__ */ H(A, {
348
+ function ae({ workspace: e, entryId: t }) {
349
+ let r = z("knowledge.history"), { data: i = [] } = U(n(e, t)), { actorName: c } = x(e);
350
+ return i.length === 0 ? null : /* @__PURE__ */ V(A, {
339
351
  title: r("title"),
340
352
  variant: "bare",
341
353
  defaultOpen: !1,
342
354
  headingLevel: 2,
343
355
  className: "mt-10",
344
- children: /* @__PURE__ */ H(a, { children: i.map((t) => /* @__PURE__ */ H(o, {
356
+ children: /* @__PURE__ */ V(a, { children: i.map((t) => /* @__PURE__ */ V(o, {
345
357
  workspace: e,
346
358
  icon: s(t.type, t.data),
347
359
  actor: t.actor,
348
360
  at: t.createdAt,
349
- children: X(r, t, c(t.actor))
361
+ children: Y(r, t, c(t.actor))
350
362
  }, t.id)) })
351
363
  });
352
364
  }
353
- function X(e, t, n) {
365
+ function Y(e, t, n) {
354
366
  let r = t.data ?? {}, i = {
355
367
  name: n,
356
- actor: (e) => /* @__PURE__ */ H("span", {
368
+ actor: (e) => /* @__PURE__ */ V("span", {
357
369
  className: "font-medium text-foreground",
358
370
  children: e
359
371
  })
@@ -372,4 +384,4 @@ function X(e, t, n) {
372
384
  });
373
385
  }
374
386
  }
375
- export { q as component };
387
+ export { K as component };