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