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