@parallelworks/tandem-web 0.178.1 → 0.179.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.
@@ -1,236 +1,231 @@
1
1
  import { areasQuery as e, knowledgeQuery as t } from "../../../api/queries.js";
2
2
  import { FavoriteStar as n } from "../../../components/FavoriteStar.js";
3
- import { KnowledgeStatus as r } from "../../../components/HoverCards.js";
4
- import { AddIcon as i, LibraryIcon as a } from "../../../components/icons.js";
5
- import { EntryDialog as o, useKnowledgeMenu as s } from "../../../lib/knowledge.js";
6
- import { kinds as c, termRef as l } from "../../../lib/knowledgeKinds.js";
7
- import { usePageTitle as u } from "../../../lib/pageTitle.js";
8
- import { Link as d, useNavigate as f } from "../../../lib/router.js";
9
- import { useTime as p } from "../../../lib/time.js";
10
- import { Route as m } from "./index.js";
11
- import { Button as h, EmptyState as g, SearchInput as _, SegmentedControl as v, Tooltip as y, buttonClasses as b, useOpenMenu as x } from "@parallelworks/ui";
12
- import { Suspense as S, useCallback as C, useEffect as w, useMemo as T, useState as E } from "react";
13
- import { useLocale as D, useTranslations as O } from "use-intl";
14
- import { Fragment as k, jsx as A, jsxs as j } from "react/jsx-runtime";
15
- import { useQuery as M, useSuspenseQuery as N } from "@tanstack/react-query";
3
+ import { AddIcon as r, LibraryIcon as i } from "../../../components/icons.js";
4
+ import { EntryDialog as a, useKnowledgeMenu as o } from "../../../lib/knowledge.js";
5
+ import { kinds as s, termRef as c } from "../../../lib/knowledgeKinds.js";
6
+ import { usePageTitle as l } from "../../../lib/pageTitle.js";
7
+ import { Link as u, useNavigate as d } from "../../../lib/router.js";
8
+ import { useTime as f } from "../../../lib/time.js";
9
+ import { Route as p } from "./index.js";
10
+ import { Button as m, EmptyState as h, SearchInput as g, SegmentedControl as _, Tooltip as v, buttonClasses as y, useOpenMenu as b } from "@parallelworks/ui";
11
+ import { Suspense as x, useCallback as S, useEffect as C, useMemo as w, useState as T } from "react";
12
+ import { useLocale as E, useTranslations as D } from "use-intl";
13
+ import { Fragment as ee, jsx as O, jsxs as k } from "react/jsx-runtime";
14
+ import { useQuery as A, useSuspenseQuery as j } from "@tanstack/react-query";
16
15
  // src/routes/$workspace/knowledge/index.tsx?tsr-split=component
17
- var P = 5, F = 8;
18
- function I() {
19
- let { workspace: r } = m.useParams(), { archived: s, kind: p = "all" } = m.useSearch(), y = O("knowledge"), x = D();
20
- u(y("title"));
21
- let I = f(), [R, z] = E(""), [B, V] = E(""), [H, U] = E(null);
22
- w(() => {
23
- let e = setTimeout(() => V(R.trim()), 200);
16
+ var M = 5, N = 8;
17
+ function P() {
18
+ let { workspace: o } = p.useParams(), { archived: f, kind: v = "all" } = p.useSearch(), b = D("knowledge"), P = E();
19
+ l(b("title"));
20
+ let I = d(), [L, R] = T(""), [z, B] = T(""), [V, H] = T(null);
21
+ C(() => {
22
+ let e = setTimeout(() => B(L.trim()), 200);
24
23
  return () => clearTimeout(e);
25
- }, [R]);
26
- let { data: W } = N(t(r)), { data: G = [] } = M(e(r)), K = {
27
- ...B && { q: B },
28
- ...s && { archived: !0 }
29
- }, { data: q } = M({
30
- ...t(r, K),
31
- enabled: !!B || !!s
32
- }), J = !!B || !!s, Y = J ? q ?? [] : W, X = p === "all" ? Y : Y.filter((e) => e.kind === p), Z = C((e) => U(e), []), Q = T(() => {
24
+ }, [L]);
25
+ let { data: U } = j(t(o)), { data: W = [] } = A(e(o)), G = {
26
+ ...z && { q: z },
27
+ ...f && { archived: !0 }
28
+ }, { data: K } = A({
29
+ ...t(o, G),
30
+ enabled: !!z || !!f
31
+ }), q = !!z || !!f, J = q ? K ?? [] : U, Y = v === "all" ? J : J.filter((e) => e.kind === v), X = S((e) => H(e), []), Z = w(() => {
33
32
  let e = /* @__PURE__ */ new Map();
34
- for (let t of Y) e.set(t.kind, (e.get(t.kind) ?? 0) + 1);
33
+ for (let t of J) e.set(t.kind, (e.get(t.kind) ?? 0) + 1);
35
34
  return e;
36
- }, [Y]), ee = T(() => [...X].sort((e, t) => t.updatedAt.localeCompare(e.updatedAt)).slice(0, P), [X]), te = T(() => {
37
- let e = new Intl.Collator(x, { sensitivity: "base" }), t = /* @__PURE__ */ new Map();
38
- for (let e of X) {
39
- let n = G.some((t) => t.id === e.areaId) ? e.areaId : "";
35
+ }, [J]), Q = w(() => [...Y].sort((e, t) => t.updatedAt.localeCompare(e.updatedAt)).slice(0, M), [Y]), te = w(() => {
36
+ let e = new Intl.Collator(P, { sensitivity: "base" }), t = /* @__PURE__ */ new Map();
37
+ for (let e of Y) {
38
+ let n = W.some((t) => t.id === e.areaId) ? e.areaId : "";
40
39
  t.set(n, [...t.get(n) ?? [], e]);
41
40
  }
42
41
  return [...t].map(([t, n]) => ({
43
42
  id: t,
44
- title: G.find((e) => e.id === t)?.title ?? y("general"),
43
+ title: W.find((e) => e.id === t)?.title ?? b("general"),
45
44
  entries: n.sort((t, n) => e.compare(t.name, n.name))
46
45
  })).sort((t, n) => t.id ? n.id ? e.compare(t.title, n.title) : -1 : 1);
47
46
  }, [
48
- X,
49
- G,
50
- x,
51
- y
47
+ Y,
48
+ W,
49
+ P,
50
+ b
52
51
  ]), ne = (e) => I({
53
52
  to: "/$workspace/knowledge",
54
- params: { workspace: r },
53
+ params: { workspace: o },
55
54
  search: {
56
- ...s && { archived: s },
55
+ ...f && { archived: f },
57
56
  ...e !== "all" && { kind: e }
58
57
  },
59
58
  replace: !0
60
- }), $ = c.filter((e) => Q.has(e) || e === p);
61
- return /* @__PURE__ */ j("div", {
59
+ }), $ = s.filter((e) => Z.has(e) || e === v);
60
+ return /* @__PURE__ */ k("div", {
62
61
  className: "flex h-full flex-col",
63
62
  children: [
64
- /* @__PURE__ */ j("header", {
63
+ /* @__PURE__ */ k("header", {
65
64
  className: "flex h-12 shrink-0 items-center gap-3 border-b border-border px-4 md:px-5",
66
65
  children: [
67
- /* @__PURE__ */ A("h1", {
66
+ /* @__PURE__ */ O("h1", {
68
67
  className: "min-w-0 truncate text-sm font-semibold",
69
- children: y("title")
68
+ children: b("title")
70
69
  }),
71
- /* @__PURE__ */ A(n, {
72
- workspace: r,
70
+ /* @__PURE__ */ O(n, {
71
+ workspace: o,
73
72
  kind: "page",
74
73
  target: "knowledge"
75
74
  }),
76
- /* @__PURE__ */ A("span", {
75
+ /* @__PURE__ */ O("span", {
77
76
  className: "whitespace-nowrap text-xs text-muted-foreground tabular-nums",
78
- children: y("count", { count: W.length })
77
+ children: b("count", { count: U.length })
79
78
  }),
80
- /* @__PURE__ */ A(d, {
79
+ /* @__PURE__ */ O(u, {
81
80
  to: "/$workspace/graph",
82
- params: { workspace: r },
83
- className: `${b({ size: "sm" })} ml-auto`,
84
- children: y("graph")
81
+ params: { workspace: o },
82
+ className: `${y({ size: "sm" })} ml-auto`,
83
+ children: b("graph")
85
84
  }),
86
- /* @__PURE__ */ j(h, {
85
+ /* @__PURE__ */ k(m, {
87
86
  type: "button",
88
87
  variant: "primary",
89
88
  size: "sm",
90
- onClick: () => Z({ kind: "create" }),
91
- children: [/* @__PURE__ */ A(i, { className: "size-3.5" }), /* @__PURE__ */ A("span", {
89
+ onClick: () => X({ kind: "create" }),
90
+ children: [/* @__PURE__ */ O(r, { className: "size-3.5" }), /* @__PURE__ */ O("span", {
92
91
  className: "max-md:sr-only",
93
- children: y("new")
92
+ children: b("new")
94
93
  })]
95
94
  })
96
95
  ]
97
96
  }),
98
- /* @__PURE__ */ A("div", {
97
+ /* @__PURE__ */ O("div", {
99
98
  className: "min-h-0 flex-1 overflow-y-auto",
100
- children: /* @__PURE__ */ j("div", {
99
+ children: /* @__PURE__ */ k("div", {
101
100
  className: "mx-auto w-full max-w-3xl px-4 pt-8 pb-16 md:px-8",
102
101
  children: [
103
- /* @__PURE__ */ A(_, {
104
- value: R,
105
- onValueChange: z,
106
- label: y("search"),
102
+ /* @__PURE__ */ O(g, {
103
+ value: L,
104
+ onValueChange: R,
105
+ label: b("search"),
107
106
  size: "lg",
108
107
  className: "w-full"
109
108
  }),
110
- /* @__PURE__ */ j("div", {
109
+ /* @__PURE__ */ k("div", {
111
110
  className: "mt-4 flex flex-wrap items-center gap-2",
112
- children: [$.length > 1 && /* @__PURE__ */ A(v, {
113
- label: y("kindLabel"),
111
+ children: [$.length > 1 && /* @__PURE__ */ O(_, {
112
+ label: b("kindLabel"),
114
113
  size: "sm",
115
- value: p,
114
+ value: v,
116
115
  onValueChange: ne,
117
116
  options: [{
118
117
  value: "all",
119
- label: y("allKinds"),
120
- count: Y.length
118
+ label: b("allKinds"),
119
+ count: J.length
121
120
  }, ...$.map((e) => ({
122
121
  value: e,
123
- label: y(`kinds.${e}`),
124
- count: Q.get(e) ?? 0
122
+ label: b(`kinds.${e}`),
123
+ count: Z.get(e) ?? 0
125
124
  }))]
126
- }), /* @__PURE__ */ A(d, {
125
+ }), /* @__PURE__ */ O(u, {
127
126
  to: "/$workspace/knowledge",
128
- params: { workspace: r },
127
+ params: { workspace: o },
129
128
  search: {
130
- ...!s && { archived: !0 },
131
- ...p !== "all" && { kind: p }
129
+ ...!f && { archived: !0 },
130
+ ...v !== "all" && { kind: v }
132
131
  },
133
- "aria-current": s || void 0,
134
- className: `${b({
132
+ "aria-current": f || void 0,
133
+ className: `${y({
135
134
  size: "sm",
136
- variant: s ? "secondary" : "ghost"
135
+ variant: f ? "secondary" : "ghost"
137
136
  })} ml-auto`,
138
- children: y("archived")
137
+ children: b("archived")
139
138
  })]
140
139
  }),
141
- X.length === 0 ? /* @__PURE__ */ A(g, {
142
- icon: /* @__PURE__ */ A(a, {}),
143
- title: y(J || p !== "all" ? "noMatches" : "emptyTitle"),
144
- description: J || p !== "all" ? void 0 : y("empty"),
145
- action: !J && p === "all" ? /* @__PURE__ */ A(h, {
140
+ Y.length === 0 ? /* @__PURE__ */ O(h, {
141
+ icon: /* @__PURE__ */ O(i, {}),
142
+ title: b(q || v !== "all" ? "noMatches" : "emptyTitle"),
143
+ description: q || v !== "all" ? void 0 : b("empty"),
144
+ action: !q && v === "all" ? /* @__PURE__ */ O(m, {
146
145
  type: "button",
147
146
  variant: "primary",
148
- onClick: () => Z({ kind: "create" }),
149
- children: y("new")
147
+ onClick: () => X({ kind: "create" }),
148
+ children: b("new")
150
149
  }) : void 0,
151
150
  className: "mt-16"
152
- }) : J ? /* @__PURE__ */ A(L, {
153
- workspace: r,
154
- title: y("results"),
155
- entries: X,
156
- onOpen: Z
157
- }) : /* @__PURE__ */ j(k, { children: [X.length >= F && /* @__PURE__ */ A(L, {
158
- workspace: r,
159
- title: y("recent"),
160
- entries: ee,
161
- onOpen: Z,
151
+ }) : q ? /* @__PURE__ */ O(F, {
152
+ workspace: o,
153
+ title: b("results"),
154
+ entries: Y,
155
+ onOpen: X
156
+ }) : /* @__PURE__ */ k(ee, { children: [Y.length >= N && /* @__PURE__ */ O(F, {
157
+ workspace: o,
158
+ title: b("recent"),
159
+ entries: Q,
160
+ onOpen: X,
162
161
  showTime: !0
163
- }), te.map((e) => /* @__PURE__ */ A(L, {
164
- workspace: r,
162
+ }), te.map((e) => /* @__PURE__ */ O(F, {
163
+ workspace: o,
165
164
  title: e.title,
166
165
  entries: e.entries,
167
- onOpen: Z
166
+ onOpen: X
168
167
  }, e.id || "general"))] })
169
168
  ]
170
169
  })
171
170
  }),
172
- H && /* @__PURE__ */ A(S, { children: /* @__PURE__ */ A(o, {
173
- workspace: r,
174
- mode: H,
175
- onClose: () => U(null),
171
+ V && /* @__PURE__ */ O(x, { children: /* @__PURE__ */ O(a, {
172
+ workspace: o,
173
+ mode: V,
174
+ onClose: () => H(null),
176
175
  onSaved: (e) => I({
177
176
  to: "/$workspace/knowledge/$term",
178
177
  params: {
179
- workspace: r,
180
- term: l(e)
178
+ workspace: o,
179
+ term: c(e)
181
180
  }
182
181
  })
183
182
  }) })
184
183
  ]
185
184
  });
186
185
  }
187
- function L({ workspace: e, title: t, entries: n, onOpen: i, showTime: a = !1 }) {
188
- let o = O("knowledge"), c = x(), u = s(e, i), f = p();
189
- return /* @__PURE__ */ j("section", {
186
+ function F({ workspace: e, title: t, entries: n, onOpen: r, showTime: i = !1 }) {
187
+ let a = D("knowledge"), s = b(), l = o(e, r), d = f();
188
+ return /* @__PURE__ */ k("section", {
190
189
  "aria-label": t,
191
190
  className: "mt-10",
192
- children: [/* @__PURE__ */ j("h2", {
191
+ children: [/* @__PURE__ */ k("h2", {
193
192
  className: "flex items-baseline gap-2 text-base font-semibold",
194
- children: [t, /* @__PURE__ */ A("span", {
193
+ children: [t, /* @__PURE__ */ O("span", {
195
194
  className: "text-xs font-normal text-muted-foreground tabular-nums",
196
195
  children: n.length
197
196
  })]
198
- }), /* @__PURE__ */ A("ul", {
197
+ }), /* @__PURE__ */ O("ul", {
199
198
  className: "mt-3 divide-y divide-border overflow-hidden rounded-xl border border-border bg-card",
200
- children: n.map((t) => /* @__PURE__ */ A("li", { children: /* @__PURE__ */ j(d, {
199
+ children: n.map((t) => /* @__PURE__ */ O("li", { children: /* @__PURE__ */ k(u, {
201
200
  to: "/$workspace/knowledge/$term",
202
201
  params: {
203
202
  workspace: e,
204
- term: l(t)
203
+ term: c(t)
205
204
  },
206
- onContextMenu: (e) => c(e, u(t)),
205
+ onContextMenu: (e) => s(e, l(t)),
207
206
  className: "group flex flex-col gap-1 px-4 py-3 sm:flex-row sm:items-start sm:gap-3 transition-colors duration-150 hover:bg-muted focus-visible:outline-offset-[-2px]",
208
- children: [/* @__PURE__ */ j("span", {
207
+ children: [/* @__PURE__ */ k("span", {
209
208
  className: "min-w-0 flex-1",
210
- children: [/* @__PURE__ */ A("span", {
209
+ children: [/* @__PURE__ */ O("span", {
211
210
  className: `block truncate text-sm font-medium ${t.status === "superseded" ? "text-muted-foreground line-through" : ""}`,
212
211
  children: t.name
213
- }), /* @__PURE__ */ A("span", {
212
+ }), /* @__PURE__ */ O("span", {
214
213
  className: "mt-0.5 line-clamp-2 text-xs leading-5 text-muted-foreground",
215
214
  children: t.definition
216
215
  })]
217
- }), (t.kind !== "term" || t.status === "added" || a) && /* @__PURE__ */ j("span", {
216
+ }), (t.kind !== "term" || i) && /* @__PURE__ */ k("span", {
218
217
  className: "flex items-center gap-2 text-xs text-muted-foreground sm:shrink-0 sm:pt-0.5",
219
- children: [
220
- t.kind !== "term" && /* @__PURE__ */ A("span", { children: o(`kind.${t.kind}`) }),
221
- t.status === "added" && /* @__PURE__ */ A(r, { status: t.status }),
222
- a && /* @__PURE__ */ A(y, {
223
- content: f.full(t.updatedAt),
224
- children: /* @__PURE__ */ A("time", {
225
- dateTime: t.updatedAt,
226
- className: "tabular-nums",
227
- children: f.relative(t.updatedAt)
228
- })
218
+ children: [t.kind !== "term" && /* @__PURE__ */ O("span", { children: a(`kind.${t.kind}`) }), i && /* @__PURE__ */ O(v, {
219
+ content: d.full(t.updatedAt),
220
+ children: /* @__PURE__ */ O("time", {
221
+ dateTime: t.updatedAt,
222
+ className: "tabular-nums",
223
+ children: d.relative(t.updatedAt)
229
224
  })
230
- ]
225
+ })]
231
226
  })]
232
227
  }) }, t.id))
233
228
  })]
234
229
  });
235
230
  }
236
- export { I as component };
231
+ export { P as component };
package/styles.css CHANGED
@@ -777,9 +777,17 @@ body[data-tandem] > :not(:has(.tandem)) {
777
777
  .issue-mention-key {
778
778
  white-space: nowrap;
779
779
  }
780
+ /* A bare key is a link (IssueMentions): it keeps the text's color, not a link's. */
781
+ a.issue-mention {
782
+ color: inherit;
783
+ text-decoration: none;
784
+ }
780
785
  [contenteditable="false"] .issue-mention {
781
786
  cursor: pointer;
782
787
  }
788
+ [contenteditable="false"] a.issue-mention:hover {
789
+ color: var(--color-primary);
790
+ }
783
791
  .issue-mention-title {
784
792
  margin-inline-start: 0.25rem;
785
793
  color: var(--color-muted-foreground);