@parallelworks/tandem-web 0.192.2 → 0.193.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,20 +1,20 @@
1
1
  import { docsQuery as e } from "../api/queries.js";
2
2
  import { docPropertiesQuery as t, spaceScope as n, useDocPropertyActions as r, usedProperties as i } from "../lib/docProperties.js";
3
- import { docRef as a, useDocMenu as o } from "../lib/docs.js";
4
- import { usePeople as s } from "../lib/people.js";
5
- import { useCan as c } from "../lib/roles.js";
6
- import { DocIcon as l } from "./DocIcon.js";
7
- import { usePropertyText as u } from "./DocProperties.js";
8
- import { cx as d, useOpenMenu as f } from "@parallelworks/ui";
3
+ import { docRef as a, useDocContextMenu as o, useDocMenu as s } from "../lib/docs.js";
4
+ import { usePeople as c } from "../lib/people.js";
5
+ import { useCan as l } from "../lib/roles.js";
6
+ import { DocIcon as u } from "./DocIcon.js";
7
+ import { usePropertyText as d } from "./DocProperties.js";
8
+ import { cx as f } from "@parallelworks/ui";
9
9
  import { Link as p } from "@tanstack/react-router";
10
10
  import { useState as m } from "react";
11
11
  import { useFormatter as h, useTranslations as g } from "use-intl";
12
12
  import { jsx as _, jsxs as v } from "react/jsx-runtime";
13
13
  import { keepPreviousData as y, useQuery as b } from "@tanstack/react-query";
14
- import { MoreButton as x, rowContextMenuProps as S } from "@parallelworks/ui/list";
14
+ import { MoreButton as x } from "@parallelworks/ui/list";
15
15
  // src/components/DocTable.tsx
16
- var C = (e) => e.kind === "select" || e.kind === "person";
17
- function w(n, r, a, o = !1) {
16
+ var S = (e) => e.kind === "select" || e.kind === "person";
17
+ function C(n, r, a, o = !1) {
18
18
  let s = Object.entries(a.filters ?? {}).map(([e, t]) => `${e}=${t}`), { data: c = [], isPending: l } = b({
19
19
  ...e(n, {
20
20
  ...r === "workspace" ? { workspace: !0 } : { team: r },
@@ -22,7 +22,7 @@ function w(n, r, a, o = !1) {
22
22
  ...o && { top: !0 }
23
23
  }),
24
24
  placeholderData: y
25
- }), { data: d = [] } = b(t(n, r)), f = u(n), p = a.sort ?? "title", m = d.find((e) => e.id === p), h = (e) => {
25
+ }), { data: u = [] } = b(t(n, r)), f = d(n), p = a.sort ?? "title", m = u.find((e) => e.id === p), h = (e) => {
26
26
  if (p === "updated") return e.updatedAt;
27
27
  if (!m) return e.title.toLowerCase();
28
28
  let t = e.properties?.[m.id];
@@ -33,39 +33,39 @@ function w(n, r, a, o = !1) {
33
33
  });
34
34
  return {
35
35
  docs: g,
36
- props: d,
37
- used: i(d, g),
36
+ props: u,
37
+ used: i(u, g),
38
38
  isPending: l
39
39
  };
40
40
  }
41
- var T = (e, t, n) => e === "table" && !t.trim() && Object.keys(n.filters ?? {}).length === 0;
42
- function E({ workspace: e, space: t, layout: n, config: r, query: i = "" }) {
43
- let c = g("docViews"), d = g("common"), m = g("docs"), y = h(), { actorName: b } = s(e), E = f(), O = o(e), k = i.trim().toLowerCase(), A = T(n, i, r), { docs: j, props: M, used: N, isPending: P } = w(e, t, r, A), F = k ? j.filter((e) => e.title.toLowerCase().includes(k)) : j, I = new Map(j.map((e) => [e.id, e])), L = (e) => {
41
+ var w = (e, t, n) => e === "table" && !t.trim() && Object.keys(n.filters ?? {}).length === 0;
42
+ function T({ workspace: e, space: t, layout: n, config: r, query: i = "" }) {
43
+ let l = g("docViews"), f = g("common"), m = g("docs"), y = h(), { actorName: b } = c(e), T = s(e), D = o(e), O = i.trim().toLowerCase(), k = w(n, i, r), { docs: A, props: j, used: M, isPending: N } = C(e, t, r, k), P = O ? A.filter((e) => e.title.toLowerCase().includes(O)) : A, F = new Map(A.map((e) => [e.id, e])), I = (e) => {
44
44
  let t = [];
45
- for (let n = I.get(e.parentId ?? ""); n && !(t.length > 20); n = I.get(n.parentId ?? "")) t.unshift(n.title);
45
+ for (let n = F.get(e.parentId ?? ""); n && !(t.length > 20); n = F.get(n.parentId ?? "")) t.unshift(n.title);
46
46
  return t.join(" / ");
47
- }, R = u(e), z = (e, t) => e.properties?.[t.id];
48
- if (P) return /* @__PURE__ */ _("p", {
47
+ }, L = d(e), R = (e, t) => e.properties?.[t.id];
48
+ if (N) return /* @__PURE__ */ _("p", {
49
49
  className: "p-4 text-sm text-muted-foreground",
50
- children: c("loading")
50
+ children: l("loading")
51
51
  });
52
52
  if (n === "board") {
53
- let n = M.find((e) => e.id === r.groupBy && C(e));
54
- return n ? /* @__PURE__ */ _(D, {
53
+ let n = j.find((e) => e.id === r.groupBy && S(e));
54
+ return n ? /* @__PURE__ */ _(E, {
55
55
  workspace: e,
56
56
  space: t,
57
- docs: F,
58
- props: M,
57
+ docs: P,
58
+ props: j,
59
59
  by: n
60
60
  }) : /* @__PURE__ */ _("p", {
61
61
  className: "p-4 text-sm text-muted-foreground",
62
- children: c("pickGroup")
62
+ children: l("pickGroup")
63
63
  });
64
64
  }
65
- let B = r.columns ? r.columns.flatMap((e) => M.filter((t) => t.id === e)) : N;
66
- return F.length === 0 ? /* @__PURE__ */ _("p", {
65
+ let z = r.columns ? r.columns.flatMap((e) => j.filter((t) => t.id === e)) : M;
66
+ return P.length === 0 ? /* @__PURE__ */ _("p", {
67
67
  className: "p-4 text-sm text-muted-foreground",
68
- children: c("none")
68
+ children: l("none")
69
69
  }) : /* @__PURE__ */ _("div", {
70
70
  className: "overflow-x-auto",
71
71
  children: /* @__PURE__ */ v("table", {
@@ -73,33 +73,33 @@ function E({ workspace: e, space: t, layout: n, config: r, query: i = "" }) {
73
73
  children: [/* @__PURE__ */ _("thead", { children: /* @__PURE__ */ v("tr", { children: [
74
74
  /* @__PURE__ */ _("th", {
75
75
  scope: "col",
76
- children: c("docTitle")
76
+ children: l("docTitle")
77
77
  }),
78
- B.map((e) => /* @__PURE__ */ _("th", {
78
+ z.map((e) => /* @__PURE__ */ _("th", {
79
79
  scope: "col",
80
80
  children: e.name
81
81
  }, e.id)),
82
82
  /* @__PURE__ */ _("th", {
83
83
  scope: "col",
84
- children: c("author")
84
+ children: l("author")
85
85
  }),
86
86
  /* @__PURE__ */ _("th", {
87
87
  scope: "col",
88
- children: c("updated")
88
+ children: l("updated")
89
89
  }),
90
90
  /* @__PURE__ */ _("th", {
91
91
  scope: "col",
92
92
  className: "max-md:sticky max-md:right-0 max-md:bg-card",
93
93
  children: /* @__PURE__ */ _("span", {
94
94
  className: "sr-only",
95
- children: d("moreActions")
95
+ children: f("moreActions")
96
96
  })
97
97
  })
98
- ] }) }), /* @__PURE__ */ _("tbody", { children: F.map((t) => {
99
- let n = A ? "" : L(t);
98
+ ] }) }), /* @__PURE__ */ _("tbody", { children: P.map((t) => {
99
+ let n = k ? "" : I(t);
100
100
  return /* @__PURE__ */ v("tr", {
101
101
  className: "group",
102
- ...S(E, () => O(t)),
102
+ ...D(t),
103
103
  children: [
104
104
  /* @__PURE__ */ v("td", { children: [/* @__PURE__ */ v("div", {
105
105
  className: "flex items-center gap-2",
@@ -110,19 +110,19 @@ function E({ workspace: e, space: t, layout: n, config: r, query: i = "" }) {
110
110
  doc: a(t)
111
111
  },
112
112
  className: "flex min-w-0 items-center gap-2 font-medium hover:underline",
113
- children: [/* @__PURE__ */ _(l, { icon: t.icon }), /* @__PURE__ */ _("span", {
113
+ children: [/* @__PURE__ */ _(u, { icon: t.icon }), /* @__PURE__ */ _("span", {
114
114
  className: "truncate",
115
115
  children: t.title
116
116
  })]
117
- }), A && (t.children ?? 0) > 0 && /* @__PURE__ */ _("span", {
117
+ }), k && (t.children ?? 0) > 0 && /* @__PURE__ */ _("span", {
118
118
  className: "shrink-0 text-xs tabular-nums text-muted-foreground",
119
- children: c("childCount", { count: t.children ?? 0 })
119
+ children: l("childCount", { count: t.children ?? 0 })
120
120
  })]
121
121
  }), n && /* @__PURE__ */ _("span", {
122
122
  className: "ml-6 block truncate text-xs text-muted-foreground",
123
- children: c("inParent", { parent: n })
123
+ children: l("inParent", { parent: n })
124
124
  })] }),
125
- B.map((e) => /* @__PURE__ */ _("td", { children: R(e, z(t, e)) }, e.id)),
125
+ z.map((e) => /* @__PURE__ */ _("td", { children: L(e, R(t, e)) }, e.id)),
126
126
  /* @__PURE__ */ _("td", {
127
127
  className: "text-muted-foreground",
128
128
  children: b(t.creator)
@@ -134,8 +134,8 @@ function E({ workspace: e, space: t, layout: n, config: r, query: i = "" }) {
134
134
  /* @__PURE__ */ _("td", {
135
135
  className: "w-0 max-md:sticky max-md:right-0 max-md:bg-card",
136
136
  children: /* @__PURE__ */ _(x, {
137
- items: () => O(t),
138
- label: d("moreActionsFor", { name: t.title || m("untitled") })
137
+ items: () => T(t),
138
+ label: f("moreActionsFor", { name: t.title || m("untitled") })
139
139
  })
140
140
  })
141
141
  ]
@@ -144,38 +144,38 @@ function E({ workspace: e, space: t, layout: n, config: r, query: i = "" }) {
144
144
  })
145
145
  });
146
146
  }
147
- function D({ workspace: e, space: t, docs: i, props: o, by: f }) {
148
- let h = g("docViews"), { members: y } = s(e), b = u(e), x = c(e, "edit_docs", n(t)), S = r(e), [C, w] = m(null), [T, E] = m(null), D = [...f.kind === "select" ? f.options.map((e) => ({
147
+ function E({ workspace: e, space: t, docs: i, props: s, by: h }) {
148
+ let y = g("docViews"), b = o(e), { members: x } = c(e), S = d(e), C = l(e, "edit_docs", n(t)), w = r(e), [T, E] = m(null), [D, O] = m(null), k = [...h.kind === "select" ? h.options.map((e) => ({
149
149
  key: e.id ?? "",
150
150
  label: e.name
151
- })) : y.map((e) => ({
151
+ })) : x.map((e) => ({
152
152
  key: e.user.username,
153
153
  label: e.user.name
154
154
  })), {
155
155
  key: "",
156
- label: h("noValue", { property: f.name })
157
- }], O = (e) => {
158
- let t = e.properties?.[f.id];
156
+ label: y("noValue", { property: h.name })
157
+ }], A = (e) => {
158
+ let t = e.properties?.[h.id];
159
159
  return typeof t == "string" ? t : "";
160
- }, k = D.filter((e) => f.kind === "select" || e.key === "" || i.some((t) => O(t) === e.key)), A = o.filter((e) => e.id !== f.id).slice(0, 2);
160
+ }, j = k.filter((e) => h.kind === "select" || e.key === "" || i.some((t) => A(t) === e.key)), M = s.filter((e) => e.id !== h.id).slice(0, 2);
161
161
  return /* @__PURE__ */ _("ul", {
162
162
  className: "flex gap-3 overflow-x-auto p-3",
163
- "aria-label": h("board"),
164
- children: k.map((t) => {
165
- let n = i.filter((e) => O(e) === t.key);
163
+ "aria-label": y("board"),
164
+ children: j.map((t) => {
165
+ let n = i.filter((e) => A(e) === t.key);
166
166
  return /* @__PURE__ */ v("li", {
167
167
  "aria-label": t.label,
168
168
  onDragOver: (e) => {
169
- C && (e.preventDefault(), E(t.key));
169
+ T && (e.preventDefault(), O(t.key));
170
170
  },
171
- onDragLeave: () => E((e) => e === t.key ? null : e),
171
+ onDragLeave: () => O((e) => e === t.key ? null : e),
172
172
  onDrop: (e) => {
173
- e.preventDefault(), C && S.setValues.mutate({
174
- doc: C,
175
- values: { [f.id]: t.key || null }
176
- }), w(null), E(null);
173
+ e.preventDefault(), T && w.setValues.mutate({
174
+ doc: T,
175
+ values: { [h.id]: t.key || null }
176
+ }), E(null), O(null);
177
177
  },
178
- className: d("flex w-64 shrink-0 flex-col rounded-lg border bg-muted/30", T === t.key ? "border-primary" : "border-border"),
178
+ className: f("flex w-64 shrink-0 flex-col rounded-lg border bg-muted/30", D === t.key ? "border-primary" : "border-border"),
179
179
  children: [/* @__PURE__ */ v("p", {
180
180
  className: "flex items-center gap-2 px-3 py-2 text-xs font-medium",
181
181
  children: [/* @__PURE__ */ _("span", {
@@ -188,9 +188,10 @@ function D({ workspace: e, space: t, docs: i, props: o, by: f }) {
188
188
  }), /* @__PURE__ */ _("ul", {
189
189
  className: "flex flex-col gap-2 px-2 pb-2",
190
190
  children: n.map((t) => /* @__PURE__ */ v("li", {
191
- draggable: x,
192
- onDragStart: () => w(t.key),
193
- onDragEnd: () => w(null),
191
+ draggable: C,
192
+ onDragStart: () => E(t.key),
193
+ onDragEnd: () => E(null),
194
+ ...b(t),
194
195
  className: "rounded-md border border-border bg-card p-2.5 text-sm shadow-xs",
195
196
  children: [/* @__PURE__ */ v(p, {
196
197
  to: "/$workspace/docs/$doc",
@@ -199,12 +200,12 @@ function D({ workspace: e, space: t, docs: i, props: o, by: f }) {
199
200
  doc: a(t)
200
201
  },
201
202
  className: "flex items-center gap-2 font-medium hover:underline",
202
- children: [/* @__PURE__ */ _(l, { icon: t.icon }), /* @__PURE__ */ _("span", {
203
+ children: [/* @__PURE__ */ _(u, { icon: t.icon }), /* @__PURE__ */ _("span", {
203
204
  className: "truncate",
204
205
  children: t.title
205
206
  })]
206
- }), A.map((e) => {
207
- let n = b(e, t.properties?.[e.id]);
207
+ }), M.map((e) => {
208
+ let n = S(e, t.properties?.[e.id]);
208
209
  return n ? /* @__PURE__ */ v("p", {
209
210
  className: "mt-1 truncate text-xs text-muted-foreground",
210
211
  children: [
@@ -220,4 +221,4 @@ function D({ workspace: e, space: t, docs: i, props: o, by: f }) {
220
221
  })
221
222
  });
222
223
  }
223
- export { D as Board, E as DocTable, C as groupable, T as listsTop, w as useSpaceDocs };
224
+ export { E as Board, T as DocTable, S as groupable, w as listsTop, C as useSpaceDocs };