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