@parallelworks/tandem-web 0.192.1 → 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,32 +1,34 @@
1
1
  import { docQuery as e, docsQuery as t, teamsQuery as n } from "../api/queries.js";
2
2
  import { useConfirm as r } from "../lib/confirm.js";
3
3
  import { docRef as i, useDocActions as a, useDocMenu as o } from "../lib/docs.js";
4
- import { Link as s } from "../lib/router.js";
5
- import { DocIcon as c } from "./DocIcon.js";
6
- import { useParams as l } from "@tanstack/react-router";
7
- import { useState as u } from "react";
8
- import { useTranslations as d } from "use-intl";
9
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
10
- import { useQuery as m } from "@tanstack/react-query";
11
- import { MoreButton as h } from "@parallelworks/ui/list";
12
- import { Node as g, NodeViewWrapper as _, ReactNodeViewRenderer as v, mergeAttributes as y } from "@tiptap/react";
4
+ import { menuOpenerProps as s } from "../lib/menus.js";
5
+ import { Link as c } from "../lib/router.js";
6
+ import { DocIcon as l } from "./DocIcon.js";
7
+ import { useOpenMenu as u } from "@parallelworks/ui";
8
+ import { useParams as d } from "@tanstack/react-router";
9
+ import { useState as f } from "react";
10
+ import { useTranslations as p } from "use-intl";
11
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
+ import { useQuery as g } from "@tanstack/react-query";
13
+ import { MoreButton as _ } from "@parallelworks/ui/list";
14
+ import { Node as v, NodeViewWrapper as y, ReactNodeViewRenderer as b, mergeAttributes as x } from "@tiptap/react";
13
15
  // src/components/SubPages.tsx
14
- var b = /^:::subpages[ \t]*\n[ \t]*:::[ \t]*(?:\n|$)/, x = g.create({
16
+ var S = /^:::subpages[ \t]*\n[ \t]*:::[ \t]*(?:\n|$)/, C = v.create({
15
17
  name: "subPages",
16
18
  group: "block",
17
19
  atom: !0,
18
20
  draggable: !0,
19
21
  selectable: !0,
20
22
  parseHTML: () => [{ tag: "div[data-sub-pages]" }],
21
- renderHTML: ({ HTMLAttributes: e }) => ["div", y(e, { "data-sub-pages": "" })],
22
- addNodeView: () => v(S),
23
+ renderHTML: ({ HTMLAttributes: e }) => ["div", x(e, { "data-sub-pages": "" })],
24
+ addNodeView: () => b(w),
23
25
  markdownTokenName: "subPages",
24
26
  markdownTokenizer: {
25
27
  name: "subPages",
26
28
  level: "block",
27
29
  start: (e) => e.search(/^:::subpages/m),
28
30
  tokenize: (e) => {
29
- let t = b.exec(e);
31
+ let t = S.exec(e);
30
32
  return t ? {
31
33
  type: "subPages",
32
34
  raw: t[0]
@@ -36,93 +38,94 @@ var b = /^:::subpages[ \t]*\n[ \t]*:::[ \t]*(?:\n|$)/, x = g.create({
36
38
  parseMarkdown: (e, t) => t.createNode("subPages"),
37
39
  renderMarkdown: () => ":::subpages\n:::"
38
40
  });
39
- function S({ editor: g }) {
40
- let v = d("docs"), y = d("common"), { workspace: b = "", doc: x = "" } = l({ strict: !1 }), { data: S } = m({
41
- ...e(b, x),
42
- enabled: !!b && !!x
43
- }), { data: C = [] } = m({
44
- ...t(b, { parent: S?.key ?? "" }),
45
- enabled: !!b && !!S
46
- }), { data: w = [] } = m({
47
- ...n(b),
48
- enabled: !!b
49
- }), T = o(b), E = a(b), { confirm: D, dialog: O } = r(), [k, A] = u(), j = g.isEditable, M = (e) => T(e, { onRename: () => A(e.key) }).flatMap((t) => {
41
+ function w({ editor: v }) {
42
+ let b = p("docs"), x = p("common"), { workspace: S = "", doc: C = "" } = d({ strict: !1 }), { data: w } = g({
43
+ ...e(S, C),
44
+ enabled: !!S && !!C
45
+ }), { data: T = [] } = g({
46
+ ...t(S, { parent: w?.key ?? "" }),
47
+ enabled: !!S && !!w
48
+ }), { data: E = [] } = g({
49
+ ...n(S),
50
+ enabled: !!S
51
+ }), D = o(S), O = u(), k = a(S), { confirm: A, dialog: j } = r(), [M, N] = f(), P = v.isEditable, F = (e) => D(e, { onRename: () => N(e.key) }).flatMap((t) => {
50
52
  if (!("label" in t)) return [t];
51
- if (t.label === v("archive")) return [{
52
- label: v("archive"),
53
+ if (t.label === b("archive")) return [{
54
+ label: b("archive"),
53
55
  destructive: !0,
54
56
  onClick: () => {
55
- D({
56
- title: v("archiveConfirm", { title: e.title || v("untitled") }),
57
- description: v("archiveDetail"),
58
- confirmLabel: v("archive"),
59
- onConfirm: () => E.archive.mutateAsync(e)
57
+ A({
58
+ title: b("archiveConfirm", { title: e.title || b("untitled") }),
59
+ description: b("archiveDetail"),
60
+ confirmLabel: b("archive"),
61
+ onConfirm: () => k.archive.mutateAsync(e)
60
62
  });
61
63
  }
62
64
  }];
63
- if (t.label === v("moveTo")) {
64
- let n = w.find((t) => t.id === e.teamId)?.key ?? "workspace";
65
+ if (t.label === b("moveTo")) {
66
+ let n = E.find((t) => t.id === e.teamId)?.key ?? "workspace";
65
67
  return [{
66
- label: v("moveOut"),
67
- onClick: () => E.move.mutate({
68
+ label: b("moveOut"),
69
+ onClick: () => k.move.mutate({
68
70
  doc: e,
69
71
  space: n
70
72
  })
71
73
  }, t];
72
74
  }
73
75
  return [t];
74
- }), N = (e, t) => {
75
- A(void 0);
76
+ }), I = (e, t) => {
77
+ N(void 0);
76
78
  let n = t.trim();
77
- n && n !== e.title && E.rename.mutate({
79
+ n && n !== e.title && k.rename.mutate({
78
80
  doc: e,
79
81
  title: n
80
82
  });
81
83
  };
82
- return /* @__PURE__ */ p(_, {
84
+ return /* @__PURE__ */ h(y, {
83
85
  className: "sub-pages",
84
86
  contentEditable: !1,
85
87
  "data-drag-handle": !0,
86
88
  children: [
87
- /* @__PURE__ */ f("p", {
89
+ /* @__PURE__ */ m("p", {
88
90
  className: "sub-pages-title",
89
- children: v("subPages")
91
+ children: b("subPages")
90
92
  }),
91
- C.length === 0 ? /* @__PURE__ */ f("p", {
93
+ T.length === 0 ? /* @__PURE__ */ m("p", {
92
94
  className: "sub-pages-empty",
93
- children: v("noSubPages")
94
- }) : /* @__PURE__ */ f("ul", { children: C.map((e) => /* @__PURE__ */ p("li", {
95
+ children: b("noSubPages")
96
+ }) : /* @__PURE__ */ m("ul", { children: T.map((e) => /* @__PURE__ */ h("li", {
95
97
  className: "group flex items-center gap-1",
96
- children: [k === e.key ? /* @__PURE__ */ f("input", {
98
+ ...M !== e.key && s(O, () => P ? F(e) : D(e)),
99
+ children: [M === e.key ? /* @__PURE__ */ m("input", {
97
100
  autoFocus: !0,
98
101
  defaultValue: e.title,
99
- "aria-label": v("rename"),
102
+ "aria-label": b("rename"),
100
103
  className: "sub-pages-rename",
101
- onBlur: (t) => N(e, t.currentTarget.value),
104
+ onBlur: (t) => I(e, t.currentTarget.value),
102
105
  onKeyDown: (t) => {
103
- t.key === "Enter" && N(e, t.currentTarget.value), t.key === "Escape" && A(void 0);
106
+ t.key === "Enter" && I(e, t.currentTarget.value), t.key === "Escape" && N(void 0);
104
107
  }
105
- }) : /* @__PURE__ */ p(s, {
108
+ }) : /* @__PURE__ */ h(c, {
106
109
  to: "/$workspace/docs/$doc",
107
110
  params: {
108
- workspace: b,
111
+ workspace: S,
109
112
  doc: i(e)
110
113
  },
111
114
  className: "sub-pages-link",
112
- children: [/* @__PURE__ */ f(c, {
115
+ children: [/* @__PURE__ */ m(l, {
113
116
  icon: e.icon,
114
117
  className: "size-4"
115
- }), /* @__PURE__ */ f("span", {
118
+ }), /* @__PURE__ */ m("span", {
116
119
  className: "truncate",
117
120
  children: e.title
118
121
  })]
119
- }), j && /* @__PURE__ */ f(h, {
120
- items: () => M(e),
121
- label: y("moreActionsFor", { name: e.title || v("untitled") })
122
+ }), P && /* @__PURE__ */ m(_, {
123
+ items: () => F(e),
124
+ label: x("moreActionsFor", { name: e.title || b("untitled") })
122
125
  })]
123
126
  }, e.key)) }),
124
- O
127
+ j
125
128
  ]
126
129
  });
127
130
  }
128
- export { x as SubPages };
131
+ export { C as SubPages };