@parallelworks/tandem-web 0.179.1 → 0.180.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.
@@ -1,9 +1,9 @@
1
- import { headingAnchor as e } from "../lib/glossary.js";
2
- import { useEffect as t, useRef as n, useState as r } from "react";
3
- import { useTranslations as i } from "use-intl";
4
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
1
+ import { headingAnchor as e, headings as t } from "../lib/glossary.js";
2
+ import { useEffect as n, useRef as r, useState as i } from "react";
3
+ import { useTranslations as a } from "use-intl";
4
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
5
5
  // src/components/DocOutline.tsx
6
- var s = [
6
+ var c = [
7
7
  "",
8
8
  "pl-3",
9
9
  "pl-6",
@@ -11,58 +11,61 @@ var s = [
11
11
  "pl-9",
12
12
  "pl-9"
13
13
  ];
14
- function c(e) {
14
+ function l(e) {
15
15
  return [...e.view.dom.querySelectorAll("h1, h2, h3, h4, h5, h6")].map((e) => ({
16
16
  level: Number(e.tagName[1]),
17
17
  text: e.textContent?.trim() ?? "",
18
18
  el: e
19
19
  })).filter((e) => e.text);
20
20
  }
21
- function l({ editor: l, scroller: u }) {
22
- let d = i("docs"), [f, p] = r([]), [m, h] = r(0), g = n(0);
23
- if (t(() => {
24
- if (!l) return;
25
- let e = () => p(c(l));
26
- return e(), l.on("update", e), () => {
27
- l.off("update", e);
21
+ function u({ body: u, editor: d, scroller: f }) {
22
+ let p = a("docs"), [m, h] = i(() => t(u)), [g, _] = i(0), v = r(0);
23
+ if (n(() => {
24
+ if (!d) {
25
+ h(t(u));
26
+ return;
27
+ }
28
+ let e = () => h(l(d));
29
+ return e(), d.on("update", e), () => {
30
+ d.off("update", e);
28
31
  };
29
- }, [l]), t(() => {
30
- let e = u.current;
31
- if (!e || f.length === 0) return;
32
+ }, [d, u]), n(() => {
33
+ let e = f.current;
34
+ if (!e || m.length === 0) return;
32
35
  let t = () => {
33
- if (Date.now() - g.current < 1e3) return;
36
+ if (Date.now() - v.current < 1e3) return;
34
37
  let t = e.getBoundingClientRect().top + 96, n = 0;
35
- f.forEach((e, r) => {
36
- e.el.getBoundingClientRect().top <= t && (n = r);
37
- }), h(n);
38
+ m.forEach((e, r) => {
39
+ e.el && e.el.getBoundingClientRect().top <= t && (n = r);
40
+ }), _(n);
38
41
  };
39
42
  return t(), e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
40
- }, [f, u]), f.length < 2) return null;
41
- let _ = Math.min(...f.map((e) => e.level));
42
- return /* @__PURE__ */ o("nav", {
43
- "aria-label": d("outline"),
43
+ }, [m, f]), m.length < 2) return null;
44
+ let y = Math.min(...m.map((e) => e.level));
45
+ return /* @__PURE__ */ s("nav", {
46
+ "aria-label": p("outline"),
44
47
  className: "sticky top-8 hidden w-56 shrink-0 self-start xl:block",
45
- children: [/* @__PURE__ */ a("p", {
48
+ children: [/* @__PURE__ */ o("p", {
46
49
  className: "mb-2 text-xs font-medium text-muted-foreground",
47
- children: d("outline")
48
- }), /* @__PURE__ */ a("ul", {
50
+ children: p("outline")
51
+ }), /* @__PURE__ */ o("ul", {
49
52
  className: "space-y-0.5 border-l border-border",
50
- children: f.map((t, n) => /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a("a", {
53
+ children: m.map((t, n) => /* @__PURE__ */ o("li", { children: /* @__PURE__ */ o("a", {
51
54
  href: `#${e(t.text)}`,
52
- "aria-current": n === m ? "location" : void 0,
55
+ "aria-current": n === g ? "location" : void 0,
53
56
  onClick: (e) => {
54
- e.preventDefault(), g.current = Date.now(), h(n), t.el.scrollIntoView({
57
+ t.el && (e.preventDefault(), v.current = Date.now(), _(n), t.el.scrollIntoView({
55
58
  block: "start",
56
59
  behavior: "smooth"
57
- });
60
+ }));
58
61
  },
59
- className: `-ml-px block border-l py-0.5 pr-2 pl-3 text-xs leading-5 ${n === m ? "border-foreground font-medium text-foreground" : "border-transparent text-muted-foreground hover:text-foreground"}`,
60
- children: /* @__PURE__ */ a("span", {
61
- className: `line-clamp-2 ${s[t.level - _] ?? ""}`,
62
+ className: `-ml-px block border-l py-0.5 pr-2 pl-3 text-xs leading-5 ${n === g ? "border-foreground font-medium text-foreground" : "border-transparent text-muted-foreground hover:text-foreground"}`,
63
+ children: /* @__PURE__ */ o("span", {
64
+ className: `line-clamp-2 ${c[t.level - y] ?? ""}`,
62
65
  children: t.text
63
66
  })
64
67
  }) }, `${n}-${t.text}`))
65
68
  })]
66
69
  });
67
70
  }
68
- export { l as DocOutline };
71
+ export { u as DocOutline };
@@ -18,39 +18,41 @@ function O() {
18
18
  let e = S("docSeries"), t = D();
19
19
  return (n) => n.repeat === "weekly" || n.repeat === "biweekly" ? e(`summary.${n.repeat}`, { days: n.weekdays.map((e) => t[e]).join(", ") }) : e(`summary.${n.repeat}`);
20
20
  }
21
- function k({ workspace: e, space: t, dateProperty: n }) {
22
- let r = S("docSeries"), [i, a] = y(null);
21
+ function k({ workspace: e, space: t, dateProperty: n, parent: r }) {
22
+ let i = S("docSeries"), [a, o] = y(null);
23
23
  return /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(m, {
24
24
  trigger: /* @__PURE__ */ T(c, {
25
25
  size: "xs",
26
- children: [/* @__PURE__ */ w(s, {}), r("series")]
26
+ children: [/* @__PURE__ */ w(s, {}), i("series")]
27
27
  }),
28
28
  align: "start",
29
29
  className: "w-80",
30
- "aria-label": r("series"),
30
+ "aria-label": i("series"),
31
31
  children: /* @__PURE__ */ w(A, {
32
32
  workspace: e,
33
33
  space: t,
34
- onEdit: a
34
+ parent: r,
35
+ onEdit: o
35
36
  })
36
- }), i && /* @__PURE__ */ w(j, {
37
+ }), a && /* @__PURE__ */ w(j, {
37
38
  workspace: e,
38
39
  space: t,
39
- series: i === "new" ? void 0 : i,
40
+ series: a === "new" ? void 0 : a,
40
41
  dateProperty: n,
41
- onClose: () => a(null)
42
+ parent: r,
43
+ onClose: () => o(null)
42
44
  })] });
43
45
  }
44
- function A({ workspace: e, space: t, onEdit: n }) {
45
- let i = S("docSeries"), a = _(), o = O(), { data: s = [] } = E(r(e, t));
46
+ function A({ workspace: e, space: t, parent: n, onEdit: i }) {
47
+ let a = S("docSeries"), o = _(), s = O(), { data: l = [] } = E(r(e, t)), u = n ? l.filter((e) => e.parentId === n.id) : l;
46
48
  return /* @__PURE__ */ T("div", {
47
49
  className: "space-y-2",
48
- children: [s.length === 0 ? /* @__PURE__ */ w("p", {
50
+ children: [u.length === 0 ? /* @__PURE__ */ w("p", {
49
51
  className: "text-sm text-muted-foreground",
50
- children: i("none")
52
+ children: a("none")
51
53
  }) : /* @__PURE__ */ w("ul", {
52
54
  className: "divide-y divide-border",
53
- children: s.map((e) => /* @__PURE__ */ T("li", {
55
+ children: u.map((e) => /* @__PURE__ */ T("li", {
54
56
  className: "flex items-center gap-2 py-1.5",
55
57
  children: [/* @__PURE__ */ T("span", {
56
58
  className: "min-w-0 flex-1",
@@ -59,29 +61,29 @@ function A({ workspace: e, space: t, onEdit: n }) {
59
61
  children: e.title
60
62
  }), /* @__PURE__ */ w("span", {
61
63
  className: "block truncate text-xs text-muted-foreground",
62
- children: e.stoppedAt ? i("stopped") : o(e)
64
+ children: e.stoppedAt ? a("stopped") : s(e)
63
65
  })]
64
66
  }), !e.stoppedAt && /* @__PURE__ */ w(c, {
65
67
  size: "xs",
66
68
  variant: "ghost",
67
69
  onClick: () => {
68
- a(), n(e);
70
+ o(), i(e);
69
71
  },
70
- children: i("edit")
72
+ children: a("edit")
71
73
  })]
72
74
  }, e.id))
73
75
  }), /* @__PURE__ */ w(c, {
74
76
  size: "xs",
75
77
  variant: "primary",
76
78
  onClick: () => {
77
- a(), n("new");
79
+ o(), i("new");
78
80
  },
79
- children: i("new")
81
+ children: a("new")
80
82
  })]
81
83
  });
82
84
  }
83
- function j({ workspace: r, space: s, series: m, dateProperty: _, onClose: x }) {
84
- let O = S("docSeries"), k = S("common"), A = b(), j = D(), M = v(), N = a(r), { members: P } = o(r), { data: F = [] } = E(e(r)), [I, L] = y(() => m ? {
85
+ function j({ workspace: r, space: s, series: m, dateProperty: _, parent: x, onClose: O }) {
86
+ let k = S("docSeries"), A = S("common"), j = b(), M = D(), N = v(), P = a(r), { members: F } = o(r), { data: I = [] } = E(e(r)), [L, R] = y(() => m ? {
85
87
  title: m.title,
86
88
  repeat: m.repeat,
87
89
  weekdays: m.weekdays,
@@ -90,7 +92,8 @@ function j({ workspace: r, space: s, series: m, dateProperty: _, onClose: x }) {
90
92
  attendees: m.attendees,
91
93
  leadDays: m.leadDays,
92
94
  timeZone: m.timeZone,
93
- ...m.dateProperty && { dateProperty: m.dateProperty }
95
+ ...m.dateProperty && { dateProperty: m.dateProperty },
96
+ ...m.parentKey && { parent: m.parentKey }
94
97
  } : {
95
98
  space: s,
96
99
  title: "",
@@ -101,57 +104,58 @@ function j({ workspace: r, space: s, series: m, dateProperty: _, onClose: x }) {
101
104
  attendees: [],
102
105
  leadDays: 1,
103
106
  timeZone: n(),
104
- ..._ && { dateProperty: _ }
105
- }), R = (e) => L((t) => ({
107
+ ..._ && { dateProperty: _ },
108
+ ...x && { parent: x.key }
109
+ }), z = (e) => R((t) => ({
106
110
  ...t,
107
111
  ...e
108
- })), [z, B] = y(!1), V = m ? () => N.update.mutateAsync({
112
+ })), [B, V] = y(!1), H = m ? () => P.update.mutateAsync({
109
113
  id: m.id,
110
- ...I
111
- }).then(x) : () => N.create.mutateAsync(I).then(x), H = N.create.isPending || N.update.isPending, U = N.create.error ?? N.update.error ?? N.stop.error, W = I.repeat === "weekly" || I.repeat === "biweekly", G = "block text-xs font-medium text-muted-foreground";
114
+ ...L
115
+ }).then(O) : () => P.create.mutateAsync(L).then(O), U = P.create.isPending || P.update.isPending, W = P.create.error ?? P.update.error ?? P.stop.error, G = L.repeat === "weekly" || L.repeat === "biweekly", K = "block text-xs font-medium text-muted-foreground";
112
116
  return /* @__PURE__ */ w(p, {
113
117
  open: !0,
114
- onClose: x,
118
+ onClose: O,
115
119
  size: "lg",
116
- title: O(m ? "editTitle" : "newTitle"),
117
- description: O("description"),
120
+ title: k(m ? "editTitle" : "newTitle"),
121
+ description: k("description"),
118
122
  footer: /* @__PURE__ */ T(C, { children: [
119
123
  m && /* @__PURE__ */ w(c, {
120
124
  variant: "danger",
121
125
  className: "mr-auto",
122
- loading: N.stop.isPending,
123
- onClick: () => N.stop.mutateAsync(m.id).then(x),
124
- children: O("stop")
126
+ loading: P.stop.isPending,
127
+ onClick: () => P.stop.mutateAsync(m.id).then(O),
128
+ children: k("stop")
125
129
  }),
126
130
  /* @__PURE__ */ w(c, {
127
131
  variant: "secondary",
128
- onClick: x,
129
- children: k("cancel")
132
+ onClick: O,
133
+ children: A("cancel")
130
134
  }),
131
135
  /* @__PURE__ */ w(c, {
132
136
  variant: "primary",
133
- loading: H,
134
- disabled: !I.title.trim() || W && (I.weekdays ?? []).length === 0,
135
- onClick: () => V().catch(() => {}),
136
- children: m ? k("save") : O("create")
137
+ loading: U,
138
+ disabled: !L.title.trim() || G && (L.weekdays ?? []).length === 0,
139
+ onClick: () => H().catch(() => {}),
140
+ children: m ? A("save") : k("create")
137
141
  })
138
142
  ] }),
139
143
  children: /* @__PURE__ */ T("form", {
140
144
  className: "space-y-3",
141
145
  onSubmit: (e) => {
142
- e.preventDefault(), V().catch(() => {});
146
+ e.preventDefault(), H().catch(() => {});
143
147
  },
144
148
  children: [
145
149
  /* @__PURE__ */ w("label", {
146
- htmlFor: M,
147
- className: G,
148
- children: O("title")
150
+ htmlFor: N,
151
+ className: K,
152
+ children: k("title")
149
153
  }),
150
154
  /* @__PURE__ */ w(f, {
151
- id: M,
152
- value: I.title,
153
- onChange: (e) => R({ title: e.target.value }),
154
- placeholder: O("titlePlaceholder"),
155
+ id: N,
156
+ value: L.title,
157
+ onChange: (e) => z({ title: e.target.value }),
158
+ placeholder: k("titlePlaceholder"),
155
159
  maxLength: 200,
156
160
  className: "-mt-2",
157
161
  autoFocus: !0
@@ -159,73 +163,73 @@ function j({ workspace: r, space: s, series: m, dateProperty: _, onClose: x }) {
159
163
  /* @__PURE__ */ T("div", {
160
164
  className: "flex flex-wrap items-end gap-3",
161
165
  children: [/* @__PURE__ */ T("div", {
162
- className: G,
163
- children: [O("repeat"), /* @__PURE__ */ w("div", {
166
+ className: K,
167
+ children: [k("repeat"), /* @__PURE__ */ w("div", {
164
168
  className: "mt-1",
165
169
  children: /* @__PURE__ */ w(h, {
166
- value: I.repeat,
170
+ value: L.repeat,
167
171
  items: i.map((e) => ({
168
172
  value: e,
169
- label: O(`repeats.${e}`)
173
+ label: k(`repeats.${e}`)
170
174
  })),
171
- onValueChange: (e) => e && R({ repeat: e }),
172
- "aria-label": O("repeat")
175
+ onValueChange: (e) => e && z({ repeat: e }),
176
+ "aria-label": k("repeat")
173
177
  })
174
178
  })]
175
179
  }), /* @__PURE__ */ T("div", {
176
- className: G,
177
- children: [O("startsOn"), /* @__PURE__ */ w("div", {
180
+ className: K,
181
+ children: [k("startsOn"), /* @__PURE__ */ w("div", {
178
182
  className: "mt-1",
179
183
  children: /* @__PURE__ */ w(u, {
180
- value: I.startsOn,
181
- onValueChange: (e) => e && R({ startsOn: e }),
184
+ value: L.startsOn,
185
+ onValueChange: (e) => e && z({ startsOn: e }),
182
186
  required: !0,
183
- "aria-label": O("startsOn")
187
+ "aria-label": k("startsOn")
184
188
  })
185
189
  })]
186
190
  })]
187
191
  }),
188
- W && /* @__PURE__ */ T("div", {
189
- className: G,
190
- children: [O("weekdays"), /* @__PURE__ */ w("div", {
192
+ G && /* @__PURE__ */ T("div", {
193
+ className: K,
194
+ children: [k("weekdays"), /* @__PURE__ */ w("div", {
191
195
  className: "mt-1",
192
196
  children: /* @__PURE__ */ w(g, {
193
197
  multiple: !0,
194
- label: O("weekdays"),
195
- value: (I.weekdays ?? []).map(String),
196
- options: j.map((e, t) => ({
198
+ label: k("weekdays"),
199
+ value: (L.weekdays ?? []).map(String),
200
+ options: M.map((e, t) => ({
197
201
  value: String(t),
198
202
  label: e
199
203
  })),
200
- onValueChange: (e) => R({ weekdays: e.map(Number).sort() })
204
+ onValueChange: (e) => z({ weekdays: e.map(Number).sort() })
201
205
  })
202
206
  })]
203
207
  }),
204
208
  /* @__PURE__ */ T("div", {
205
209
  className: "flex flex-wrap items-end gap-3",
206
210
  children: [/* @__PURE__ */ T("div", {
207
- className: G,
208
- children: [O("template"), /* @__PURE__ */ w("div", {
211
+ className: K,
212
+ children: [k("template"), /* @__PURE__ */ w("div", {
209
213
  className: "mt-1",
210
214
  children: /* @__PURE__ */ w(h, {
211
- value: I.template ?? "",
215
+ value: L.template ?? "",
212
216
  items: [{
213
217
  value: "",
214
- label: O("spaceDefault")
215
- }, ...F.map((e) => ({
218
+ label: k("spaceDefault")
219
+ }, ...I.map((e) => ({
216
220
  value: e.id,
217
221
  label: e.title
218
222
  }))],
219
- onValueChange: (e) => R({ template: e ?? "" }),
220
- "aria-label": O("template")
223
+ onValueChange: (e) => z({ template: e ?? "" }),
224
+ "aria-label": k("template")
221
225
  })
222
226
  })]
223
227
  }), /* @__PURE__ */ T("div", {
224
- className: G,
225
- children: [O("lead"), /* @__PURE__ */ w("div", {
228
+ className: K,
229
+ children: [k("lead"), /* @__PURE__ */ w("div", {
226
230
  className: "mt-1",
227
231
  children: /* @__PURE__ */ w(h, {
228
- value: String(I.leadDays ?? 0),
232
+ value: String(L.leadDays ?? 0),
229
233
  items: [
230
234
  0,
231
235
  1,
@@ -234,42 +238,42 @@ function j({ workspace: r, space: s, series: m, dateProperty: _, onClose: x }) {
234
238
  7
235
239
  ].map((e) => ({
236
240
  value: String(e),
237
- label: O("leadDays", { days: e })
241
+ label: k("leadDays", { days: e })
238
242
  })),
239
- onValueChange: (e) => e !== null && R({ leadDays: Number(e) }),
240
- "aria-label": O("lead")
243
+ onValueChange: (e) => e !== null && z({ leadDays: Number(e) }),
244
+ "aria-label": k("lead")
241
245
  })
242
246
  })]
243
247
  })]
244
248
  }),
245
249
  /* @__PURE__ */ T("div", {
246
- className: G,
247
- children: [O("attendees"), /* @__PURE__ */ w("div", {
250
+ className: K,
251
+ children: [k("attendees"), /* @__PURE__ */ w("div", {
248
252
  className: "mt-1",
249
253
  children: /* @__PURE__ */ w(l, {
250
- open: z,
251
- onOpenChange: B,
254
+ open: B,
255
+ onOpenChange: V,
252
256
  multiple: !0,
253
- items: P.map((e) => ({
257
+ items: F.map((e) => ({
254
258
  value: e.user.username,
255
259
  label: e.user.name || e.user.username
256
260
  })),
257
- value: I.attendees ?? [],
258
- onValueChange: (e) => R({ attendees: e }),
259
- placeholder: O("attendees"),
261
+ value: L.attendees ?? [],
262
+ onValueChange: (e) => z({ attendees: e }),
263
+ placeholder: k("attendees"),
260
264
  trigger: /* @__PURE__ */ w(c, {
261
265
  type: "button",
262
266
  className: "font-normal",
263
- children: (I.attendees ?? []).length ? (I.attendees ?? []).map((e) => P.find((t) => t.user.username === e)?.user.name || e).join(", ") : O("noAttendees")
267
+ children: (L.attendees ?? []).length ? (L.attendees ?? []).map((e) => F.find((t) => t.user.username === e)?.user.name || e).join(", ") : k("noAttendees")
264
268
  })
265
269
  })
266
270
  })]
267
271
  }),
268
272
  /* @__PURE__ */ w("p", {
269
273
  className: "text-xs text-muted-foreground",
270
- children: O("zone", { zone: I.timeZone ?? "UTC" })
274
+ children: k("zone", { zone: L.timeZone ?? "UTC" })
271
275
  }),
272
- U && /* @__PURE__ */ w(d, { children: A(U) })
276
+ W && /* @__PURE__ */ w(d, { children: j(W) })
273
277
  ]
274
278
  })
275
279
  });