@parallelworks/tandem-web 0.151.0 → 0.152.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,57 +1,50 @@
1
1
  import { ApiError as e } from "../api/client.js";
2
2
  import { Link as t, useNavigate as n } from "../lib/router.js";
3
- import { sharedDocQuery as r, sharedQuery as i, siteDocQuery as a, siteQuery as o, siteSearchQuery as s } from "../api/queries.js";
4
- import { docKey as c } from "../lib/docs.js";
5
- import { DocIcon as l } from "./DocIcon.js";
6
- import { Editor as u } from "./Editor.js";
7
- import { Logo as d } from "./Logo.js";
8
- import { DocOutline as f } from "./DocOutline.js";
9
- import { Disclosure as p, SearchInput as m, buttonClasses as h, cx as g } from "@parallelworks/ui";
10
- import { useEffect as _, useMemo as v, useRef as y, useState as b } from "react";
11
- import { useTranslations as x } from "use-intl";
12
- import { jsx as S, jsxs as C } from "react/jsx-runtime";
13
- import { keepPreviousData as w, useQuery as T } from "@tanstack/react-query";
3
+ import { sharedDocQuery as r, sharedQuery as i } from "../api/queries.js";
4
+ import { docKey as a } from "../lib/docs.js";
5
+ import { DocIcon as o } from "./DocIcon.js";
6
+ import { Editor as s } from "./Editor.js";
7
+ import { Logo as c } from "./Logo.js";
8
+ import { DocOutline as l } from "./DocOutline.js";
9
+ import { Disclosure as u, buttonClasses as d, cx as f } from "@parallelworks/ui";
10
+ import { useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
11
+ import { useTranslations as _ } from "use-intl";
12
+ import { jsx as v, jsxs as y } from "react/jsx-runtime";
13
+ import { useQuery as b } from "@tanstack/react-query";
14
14
  // src/components/SharedViewer.tsx
15
- function E({ source: s, doc: m }) {
16
- let w = x("shared"), E = n(), D = T("secret" in s ? i(s.secret) : o(s.workspace, s.site)), A = D.data?.docs ?? [], j = m ?? D.data?.root ?? A[0]?.key, M = T({
17
- ..."secret" in s ? r(s.secret, j ?? "") : a(s.workspace, s.site, j ?? ""),
18
- enabled: !!j
19
- }), N = v(() => new Set(A.map((e) => e.key)), [A]), [P, F] = b(null), I = y(null);
20
- _(() => {
21
- j && I.current?.scrollTo({ top: 0 });
22
- }, [j]);
23
- let L = (e) => "secret" in s ? E({
15
+ function x({ source: x, doc: S }) {
16
+ let w = _("shared"), T = n(), E = b(i(x.secret)), D = E.data?.docs ?? [], O = S ?? E.data?.root ?? D[0]?.key, k = b({
17
+ ...r(x.secret, O ?? ""),
18
+ enabled: !!O
19
+ }), A = m(() => new Set(D.map((e) => e.key)), [D]), [j, M] = g(null), N = h(null);
20
+ p(() => {
21
+ O && N.current?.scrollTo({ top: 0 });
22
+ }, [O]);
23
+ let P = (e) => T({
24
24
  to: "/share/$secret",
25
- params: { secret: s.secret },
26
- search: { doc: e }
27
- }) : E({
28
- to: "/sites/$workspace/$site",
29
- params: {
30
- workspace: s.workspace,
31
- site: s.site
32
- },
25
+ params: { secret: x.secret },
33
26
  search: { doc: e }
34
27
  });
35
- if (D.error) {
36
- let n = D.error instanceof e && D.error.status === 401;
37
- return /* @__PURE__ */ S("main", {
28
+ if (E.error) {
29
+ let n = E.error instanceof e && E.error.status === 401;
30
+ return /* @__PURE__ */ v("main", {
38
31
  className: "flex min-h-screen items-center justify-center px-4",
39
- children: /* @__PURE__ */ C("div", {
32
+ children: /* @__PURE__ */ y("div", {
40
33
  className: "w-full max-w-sm",
41
34
  children: [
42
- /* @__PURE__ */ S(d, { className: "mb-10" }),
43
- /* @__PURE__ */ S("h1", {
35
+ /* @__PURE__ */ v(c, { className: "mb-10" }),
36
+ /* @__PURE__ */ v("h1", {
44
37
  className: "text-2xl font-semibold tracking-tight",
45
- children: w(n ? "signInTitle" : "site" in s ? "noSiteTitle" : "goneTitle")
38
+ children: w(n ? "signInTitle" : "goneTitle")
46
39
  }),
47
- /* @__PURE__ */ S("p", {
40
+ /* @__PURE__ */ v("p", {
48
41
  className: "mt-1 text-sm text-muted-foreground",
49
- children: w(n ? "signInDetail" : "site" in s ? "noSiteDetail" : "goneDetail")
42
+ children: w(n ? "signInDetail" : "goneDetail")
50
43
  }),
51
- n && /* @__PURE__ */ S(t, {
44
+ n && /* @__PURE__ */ v(t, {
52
45
  to: "/login",
53
46
  search: { next: window.location.href },
54
- className: g(h({
47
+ className: f(d({
55
48
  variant: "primary",
56
49
  size: "lg"
57
50
  }), "mt-6"),
@@ -61,88 +54,82 @@ function E({ source: s, doc: m }) {
61
54
  })
62
55
  });
63
56
  }
64
- return /* @__PURE__ */ C("div", {
57
+ return /* @__PURE__ */ y("div", {
65
58
  className: "flex h-screen flex-col",
66
59
  children: [
67
- /* @__PURE__ */ C("header", {
60
+ /* @__PURE__ */ y("header", {
68
61
  className: "flex h-12 shrink-0 items-center gap-3 border-b border-border px-4 md:px-5",
69
62
  children: [
70
- /* @__PURE__ */ S(d, { className: "h-5 max-sm:hidden" }),
71
- /* @__PURE__ */ S("span", {
63
+ /* @__PURE__ */ v(c, { className: "h-5 max-sm:hidden" }),
64
+ /* @__PURE__ */ v("span", {
72
65
  className: "truncate text-sm font-semibold",
73
- children: D.data?.title
66
+ children: E.data?.title
74
67
  }),
75
- /* @__PURE__ */ S("span", {
68
+ /* @__PURE__ */ v("span", {
76
69
  className: "truncate text-xs text-muted-foreground max-sm:hidden",
77
- children: D.data && D.data.title !== D.data.workspace && w("from", { workspace: D.data.workspace })
70
+ children: E.data && E.data.title !== E.data.workspace && w("from", { workspace: E.data.workspace })
78
71
  }),
79
- /* @__PURE__ */ C("span", {
80
- className: "ml-auto flex shrink-0 items-center gap-2",
81
- children: ["site" in s && /* @__PURE__ */ S(k, {
82
- source: s,
83
- onOpen: L
84
- }), /* @__PURE__ */ S("span", {
85
- className: "rounded border border-border px-1.5 py-0.5 text-[11px] text-muted-foreground",
86
- children: w("readOnly")
87
- })]
72
+ /* @__PURE__ */ v("span", {
73
+ className: "ml-auto shrink-0 rounded border border-border px-1.5 py-0.5 text-[11px] text-muted-foreground",
74
+ children: w("readOnly")
88
75
  })
89
76
  ]
90
77
  }),
91
- A.length > 1 && /* @__PURE__ */ S(p, {
78
+ D.length > 1 && /* @__PURE__ */ v(u, {
92
79
  className: "shrink-0 border-b border-border px-2 py-1 md:hidden",
93
80
  summaryClassName: "px-2 py-1 text-sm text-muted-foreground",
94
81
  summary: w("docs"),
95
- children: /* @__PURE__ */ S(O, {
96
- docs: A,
82
+ children: /* @__PURE__ */ v(C, {
83
+ docs: D,
97
84
  parent: "",
98
85
  depth: 0,
99
- current: j,
100
- source: s
86
+ current: O,
87
+ source: x
101
88
  })
102
89
  }),
103
- /* @__PURE__ */ C("div", {
90
+ /* @__PURE__ */ y("div", {
104
91
  className: "flex min-h-0 flex-1",
105
- children: [A.length > 1 && /* @__PURE__ */ S("nav", {
92
+ children: [D.length > 1 && /* @__PURE__ */ v("nav", {
106
93
  "aria-label": w("docs"),
107
94
  className: "w-64 shrink-0 overflow-y-auto border-r border-border p-2 max-md:hidden",
108
- children: /* @__PURE__ */ S(O, {
109
- docs: A,
95
+ children: /* @__PURE__ */ v(C, {
96
+ docs: D,
110
97
  parent: "",
111
98
  depth: 0,
112
- current: j,
113
- source: s
99
+ current: O,
100
+ source: x
114
101
  })
115
- }), /* @__PURE__ */ S("main", {
116
- ref: I,
102
+ }), /* @__PURE__ */ v("main", {
103
+ ref: N,
117
104
  className: "min-w-0 flex-1 overflow-y-auto",
118
- children: /* @__PURE__ */ C("div", {
105
+ children: /* @__PURE__ */ y("div", {
119
106
  className: "flex w-full gap-10 px-4 py-6 md:px-8",
120
- children: [/* @__PURE__ */ C("article", {
107
+ children: [/* @__PURE__ */ y("article", {
121
108
  onClickCapture: (e) => {
122
- let t = e.target.closest("a")?.getAttribute("href") ?? "", n = /\/docs\/([A-Za-z0-9-]+)/.exec(t)?.[1], r = n && c(n);
123
- r && N.has(r) && (e.preventDefault(), L(r));
109
+ let t = e.target.closest("a")?.getAttribute("href") ?? "", n = /\/docs\/([A-Za-z0-9-]+)/.exec(t)?.[1], r = n && a(n);
110
+ r && A.has(r) && (e.preventDefault(), P(r));
124
111
  },
125
112
  className: "mx-auto min-w-0 max-w-3xl flex-1 pb-24",
126
113
  children: [
127
- M.data?.icon && /* @__PURE__ */ S(l, {
128
- icon: M.data.icon,
114
+ k.data?.icon && /* @__PURE__ */ v(o, {
115
+ icon: k.data.icon,
129
116
  className: "mb-2 size-12",
130
117
  emojiClassName: "text-4xl"
131
118
  }),
132
- /* @__PURE__ */ S("h1", {
119
+ /* @__PURE__ */ v("h1", {
133
120
  className: "text-2xl font-semibold tracking-tight",
134
- children: M.data?.title
121
+ children: k.data?.title
135
122
  }),
136
- M.data && /* @__PURE__ */ S(u, {
137
- value: M.data.body ?? "",
123
+ k.data && /* @__PURE__ */ v(s, {
124
+ value: k.data.body ?? "",
138
125
  editable: !1,
139
- onEditor: F,
126
+ onEditor: M,
140
127
  className: "mt-4"
141
- }, M.data.key)
128
+ }, k.data.key)
142
129
  ]
143
- }), /* @__PURE__ */ S(f, {
144
- editor: P,
145
- scroller: I
130
+ }), /* @__PURE__ */ v(l, {
131
+ editor: j,
132
+ scroller: N
146
133
  })]
147
134
  })
148
135
  })]
@@ -150,48 +137,38 @@ function E({ source: s, doc: m }) {
150
137
  ]
151
138
  });
152
139
  }
153
- function D({ source: e, doc: n, current: r, children: i }) {
154
- let a = r ? "page" : void 0, o = "flex items-center gap-2 rounded-md py-1 pr-2 text-sm text-muted-foreground hover:bg-muted hover:text-foreground aria-[current=page]:bg-muted aria-[current=page]:font-medium aria-[current=page]:text-foreground";
155
- return "secret" in e ? /* @__PURE__ */ S(t, {
140
+ function S({ source: e, doc: n, current: r, children: i }) {
141
+ let a = r ? "page" : void 0;
142
+ return /* @__PURE__ */ v(t, {
156
143
  to: "/share/$secret",
157
144
  params: { secret: e.secret },
158
145
  search: { doc: n },
159
146
  "aria-current": a,
160
- className: o,
161
- children: i
162
- }) : /* @__PURE__ */ S(t, {
163
- to: "/sites/$workspace/$site",
164
- params: {
165
- workspace: e.workspace,
166
- site: e.site
167
- },
168
- search: { doc: n },
169
- "aria-current": a,
170
- className: o,
147
+ className: "flex items-center gap-2 rounded-md py-1 pr-2 text-sm text-muted-foreground hover:bg-muted hover:text-foreground aria-[current=page]:bg-muted aria-[current=page]:font-medium aria-[current=page]:text-foreground",
171
148
  children: i
172
149
  });
173
150
  }
174
- function O({ docs: e, parent: t, depth: n, current: r, source: i }) {
151
+ function C({ docs: e, parent: t, depth: n, current: r, source: i }) {
175
152
  let a = e.filter((e) => (e.parent ?? "") === t);
176
- return a.length === 0 ? null : /* @__PURE__ */ S("ul", {
153
+ return a.length === 0 ? null : /* @__PURE__ */ v("ul", {
177
154
  className: "space-y-px",
178
- children: a.map((t) => /* @__PURE__ */ C("li", { children: [/* @__PURE__ */ S(D, {
155
+ children: a.map((t) => /* @__PURE__ */ y("li", { children: [/* @__PURE__ */ v(S, {
179
156
  source: i,
180
157
  doc: t.key,
181
158
  current: t.key === r,
182
- children: /* @__PURE__ */ C("span", {
159
+ children: /* @__PURE__ */ y("span", {
183
160
  style: { paddingLeft: `${.5 + n * .75}rem` },
184
161
  className: "flex min-w-0 items-center gap-2",
185
- children: [/* @__PURE__ */ S(l, {
162
+ children: [/* @__PURE__ */ v(o, {
186
163
  icon: t.icon,
187
164
  className: "size-3.5",
188
165
  emojiClassName: "text-xs"
189
- }), /* @__PURE__ */ S("span", {
166
+ }), /* @__PURE__ */ v("span", {
190
167
  className: "truncate",
191
168
  children: t.title
192
169
  })]
193
170
  })
194
- }), /* @__PURE__ */ S(O, {
171
+ }), /* @__PURE__ */ v(C, {
195
172
  docs: e,
196
173
  parent: t.key,
197
174
  depth: n + 1,
@@ -200,54 +177,4 @@ function O({ docs: e, parent: t, depth: n, current: r, source: i }) {
200
177
  })] }, t.key))
201
178
  });
202
179
  }
203
- function k({ source: e, onOpen: t }) {
204
- let n = x("shared"), [r, i] = b(""), [a, o] = b("");
205
- _(() => {
206
- let e = setTimeout(() => o(r.trim()), 200);
207
- return () => clearTimeout(e);
208
- }, [r]);
209
- let { data: c } = T({
210
- ...s(e.workspace, e.site, a),
211
- enabled: a !== "",
212
- placeholderData: w
213
- }), l = a ? c?.docs ?? [] : [];
214
- return /* @__PURE__ */ C("div", {
215
- className: "relative",
216
- children: [/* @__PURE__ */ S(m, {
217
- value: r,
218
- onValueChange: i,
219
- placeholder: n("search"),
220
- label: n("search"),
221
- size: "sm",
222
- className: "w-56 max-sm:w-40"
223
- }), a && /* @__PURE__ */ S("ul", {
224
- "aria-label": n("results"),
225
- className: "absolute right-0 z-20 mt-1 max-h-96 w-96 overflow-y-auto rounded-md border border-border bg-background p-1 shadow-md max-sm:w-72",
226
- children: l.length === 0 ? /* @__PURE__ */ S("li", {
227
- className: "px-2 py-2 text-sm text-muted-foreground",
228
- children: n("noResults")
229
- }) : l.map((e) => /* @__PURE__ */ S("li", { children: /* @__PURE__ */ C("button", {
230
- type: "button",
231
- onClick: () => {
232
- i(""), t(e.key);
233
- },
234
- className: "block w-full rounded px-2 py-1.5 text-left hover:bg-muted",
235
- children: [/* @__PURE__ */ S("span", {
236
- className: "block text-sm font-medium",
237
- children: e.title
238
- }), /* @__PURE__ */ S(A, { text: e.snippet })]
239
- }) }, e.key))
240
- })]
241
- });
242
- }
243
- function A({ text: e }) {
244
- let t = e.split("**");
245
- return /* @__PURE__ */ S("span", {
246
- className: "mt-0.5 line-clamp-2 block text-xs text-muted-foreground",
247
- children: t.map((e, t) => t % 2 == 1 ? /* @__PURE__ */ S("mark", {
248
- className: "bg-transparent font-semibold text-foreground",
249
- children: e
250
- }, t) : /* @__PURE__ */ S("span", { children: e }, t))
251
- });
252
- }
253
- export { E as SharedViewer };
180
+ export { x as SharedViewer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parallelworks/tandem-web",
3
- "version": "0.151.0",
3
+ "version": "0.152.1",
4
4
  "description": "Tandem's pages, for a host app to render in its own",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",