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