@chaibuilder/pages 0.16.24 → 0.16.26
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.
- package/dist/{2AITGKQY-UndKMj-X.cjs → 2AITGKQY-Be359164.cjs} +1 -1
- package/dist/{2AITGKQY-Ir_ZXu1s.js → 2AITGKQY-CoZaZMrf.js} +2 -2
- package/dist/{NCMVHL6D-B3xcD0Vz.js → NCMVHL6D-C2p_bwgN.js} +2 -2
- package/dist/{NCMVHL6D-taGMv4he.cjs → NCMVHL6D-CmKLw38-.cjs} +1 -1
- package/dist/{ZDWCUMSJ-Cot4ixKZ.cjs → ZDWCUMSJ-DDHOTUX8.cjs} +1 -1
- package/dist/{ZDWCUMSJ-B1vApR00.js → ZDWCUMSJ-DmZy2MGb.js} +1 -1
- package/dist/{active-in-another-tab-Kp8LaYW5.js → active-in-another-tab-At1yEu4g.js} +1 -1
- package/dist/{active-in-another-tab-DYU7aCUa.cjs → active-in-another-tab-B1PAoWFL.cjs} +1 -1
- package/dist/{add-new-language-page-CkyPkpzC.cjs → add-new-language-page-B7fKZbYT.cjs} +1 -1
- package/dist/{add-new-language-page-0J2KTKg6.js → add-new-language-page-BfPVFqO4.js} +2 -2
- package/dist/{add-new-page-DPtVHa8m.cjs → add-new-page-DBVt7xSO.cjs} +1 -1
- package/dist/{add-new-page-BjxHUGIo.js → add-new-page-GZdKxwCY.js} +1 -1
- package/dist/{ai-panel-content-CMfopU0G.js → ai-panel-content-CWw-2gPV.js} +2 -2
- package/dist/{ai-panel-content-nmbQV7rT.cjs → ai-panel-content-Cv67WLJd.cjs} +1 -1
- package/dist/{ai-panel-default-lang-7L9rURdC.js → ai-panel-default-lang-B1WScOB4.js} +3 -3
- package/dist/{ai-panel-default-lang-B5eNybL4.cjs → ai-panel-default-lang-BBk6sSyh.cjs} +2 -2
- package/dist/{ai-panel-other-lang-DLn89TFE.cjs → ai-panel-other-lang-BrVV9nKv.cjs} +1 -1
- package/dist/{ai-panel-other-lang-U5XRqxbF.js → ai-panel-other-lang-DgNon2GH.js} +3 -3
- package/dist/{ai-prompt-input-B24vn-LG.js → ai-prompt-input-B6KsNLgP.js} +2 -2
- package/dist/ai-prompt-input-DSmIbsS_.cjs +1 -0
- package/dist/{ai-translation-prompt-CB67Sqo9.cjs → ai-translation-prompt-BYTviKVU.cjs} +1 -1
- package/dist/{ai-translation-prompt-cym054ja.js → ai-translation-prompt-CfnXqyai.js} +1 -1
- package/dist/button-CMMN5Cp4.cjs +1 -0
- package/dist/button-CggatMM3.js +48 -0
- package/dist/{continue-editing-in-this-client-BYJaymOL.cjs → continue-editing-in-this-client--Fzos10u.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-BDYiQrbE.js → continue-editing-in-this-client--RRixZUo.js} +1 -1
- package/dist/{delete-page-BXEQB0Si.cjs → delete-page-BOuq3v6x.cjs} +1 -1
- package/dist/{delete-page-CvSN4E4V.js → delete-page-CeJdK5hc.js} +1 -1
- package/dist/{digital-asset-manager-CF1Lyc5K.cjs → digital-asset-manager-BUEa7fSG.cjs} +1 -1
- package/dist/{digital-asset-manager-BxbX7ji1.js → digital-asset-manager-D6GbpYDo.js} +1 -1
- package/dist/{duplicate-page-BFnuk1nL.js → duplicate-page-C7FjAbqP.js} +2 -2
- package/dist/{duplicate-page-C32_9H41.cjs → duplicate-page-Ch9Fn-Gu.cjs} +1 -1
- package/dist/{dynamic-page-selector-CLxpglyO.cjs → dynamic-page-selector-CZNYCxbJ.cjs} +1 -1
- package/dist/{dynamic-page-selector-CSTuQhej.js → dynamic-page-selector-C_-ihnB7.js} +1 -1
- package/dist/{index-Bre43r-W.cjs → index-CJcS3b8n.cjs} +5 -5
- package/dist/{index-tgsBai_8.js → index-CtRx3Y3K.js} +1039 -1028
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/{json-diff-viewer-2gVCV5T-.js → json-diff-viewer-DX4sQltt.js} +1 -1
- package/dist/{json-diff-viewer-34Sqd4il.cjs → json-diff-viewer-DluaC8tY.cjs} +1 -1
- package/dist/{lang-panel-CXIcTGVk.cjs → lang-panel-DFe4DfU4.cjs} +1 -1
- package/dist/{lang-panel-Cj0axCpE.js → lang-panel-p7OYw-2c.js} +2 -2
- package/dist/{mark-as-template-DKBwTiMJ.cjs → mark-as-template-Biqpp8uM.cjs} +1 -1
- package/dist/{mark-as-template-1TuznHtx.js → mark-as-template-CuPKgc5N.js} +1 -1
- package/dist/{no-language-page-content-C265--no.js → no-language-page-content-B_zNVuVO.js} +1 -1
- package/dist/{no-language-page-content-B8udZsi2.cjs → no-language-page-content-oy4ZcH34.cjs} +1 -1
- package/dist/{no-language-page-dialog-CctilPnb.cjs → no-language-page-dialog-CTRG81hU.cjs} +1 -1
- package/dist/{no-language-page-dialog-DgaP74-Y.js → no-language-page-dialog-Q2rvsEP6.js} +2 -2
- package/dist/{page-creator-NkF29o0S.cjs → page-creator-CVrbjJa-.cjs} +1 -1
- package/dist/{page-creator-Cer7L7dg.js → page-creator-b6UTCFeu.js} +2 -2
- package/dist/{page-lock-0qEG4sLX.cjs → page-lock-DUwWdppB.cjs} +1 -1
- package/dist/{page-lock-DNrP3AhL.js → page-lock-Dl5CmUgk.js} +2 -2
- package/dist/{page-locked-dialog-B9p5gIGE.cjs → page-locked-dialog-DeUMR-pV.cjs} +1 -1
- package/dist/{page-locked-dialog-U5eDKeBc.js → page-locked-dialog-MJ3kA-oQ.js} +1 -1
- package/dist/page-manager-new-C3XuiDiM.cjs +1 -0
- package/dist/page-manager-new-C8PGR_4a.js +394 -0
- package/dist/{page-manager-search-and-filter-DKrQdcb0.cjs → page-manager-search-and-filter-BdfXZwwH.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-DDdYtDF7.js → page-manager-search-and-filter-DIz68YHL.js} +1 -1
- package/dist/{page-revisions-content-CoVYI0hI.js → page-revisions-content-BvYTXKgT.js} +2 -2
- package/dist/{page-revisions-content-NE8Y5DrC.cjs → page-revisions-content-CwrPL9kp.cjs} +1 -1
- package/dist/pages.css +1 -1
- package/dist/{publish-pages-content-KgbEbRVV.js → publish-pages-content-9VBFj6LH.js} +2 -2
- package/dist/{publish-pages-content-CCUKnVTH.cjs → publish-pages-content-DTPjR33T.cjs} +1 -1
- package/dist/{save-to-lib-CQmcDI5w.js → save-to-lib-Bkou78G6.js} +1 -1
- package/dist/{save-to-lib-C06RQn4k.cjs → save-to-lib-ByoB0FW5.cjs} +1 -1
- package/dist/selected-block-display-Auur5nl7.cjs +16 -0
- package/dist/selected-block-display-D1L4e4Cb.js +355 -0
- package/dist/{seo-panel-C-dqg-1A.js → seo-panel-KjxjFcdp.js} +16 -16
- package/dist/{seo-panel-hwJUoGfJ.cjs → seo-panel-Mjkh_Urn.cjs} +1 -1
- package/dist/{shared-json-ld-BP2l89h2.cjs → shared-json-ld-DYD7q8ST.cjs} +1 -1
- package/dist/{shared-json-ld-BUPafGh_.js → shared-json-ld-S9OIaOTA.js} +1 -1
- package/dist/{slug-input-91_G-ww1.cjs → slug-input-C0BtQs2w.cjs} +1 -1
- package/dist/{slug-input-hcJHNszn.js → slug-input-CUTtvZQ9.js} +1 -1
- package/dist/{take-over-request-Dw2P9U_Q.js → take-over-request-CXED2804.js} +1 -1
- package/dist/{take-over-request-kRGwkXvv.cjs → take-over-request-Dh9HVZPO.cjs} +1 -1
- package/dist/{theme-panel-footer-2qsvp4AM.js → theme-panel-footer-CftO53LS.js} +1 -1
- package/dist/{theme-panel-footer-DmO4-lci.cjs → theme-panel-footer-tdNtbqZs.cjs} +1 -1
- package/dist/{unmark-as-template-DbXx3l6p.js → unmark-as-template-Dp6S9dY3.js} +1 -1
- package/dist/{unmark-as-template-BBzZqNJt.cjs → unmark-as-template-DyUqAa9Z.cjs} +1 -1
- package/dist/{unpublish-page-BKQqPk_e.js → unpublish-page-c382vh74.js} +1 -1
- package/dist/{unpublish-page-CHYNjTFU.cjs → unpublish-page-ch791au1.cjs} +1 -1
- package/dist/{web-preview-BKoPv6AO.js → web-preview-DiOChE4E.js} +1 -1
- package/dist/{web-preview-D4KdtUYp.cjs → web-preview-cls5-Dlv.cjs} +1 -1
- package/package.json +3 -3
- package/dist/ai-prompt-input-6LzuYu5L.cjs +0 -1
- package/dist/page-manager-new-BL5S9ccS.cjs +0 -1
- package/dist/page-manager-new-DGaBkeJp.js +0 -354
- package/dist/selected-block-display-7n8S3vf1.js +0 -394
- package/dist/selected-block-display-DDC1_UC8.cjs +0 -16
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { jsxs as y, Fragment as z, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { aA as be, aB as ge, ao as ke, k as ie, T as q, aS as we, L as Ne, m as ve, g as Se, c as Le, av as Ae, aT as Te, aU as Q } from "./index-CtRx3Y3K.js";
|
|
3
|
+
import { u as Y } from "./use-page-expand-manager-D6T75I11.js";
|
|
4
|
+
import { compact as ce, filter as B, isEmpty as S, uniqBy as Ce, keyBy as de, mapValues as Ee, startCase as Me, toLower as E, includes as R, get as D, find as $, map as Ue } from "lodash-es";
|
|
5
|
+
import { useTranslation as Ie, useLanguages as ae } from "@chaibuilder/sdk";
|
|
6
|
+
import { atom as $e, useAtom as ue } from "jotai";
|
|
7
|
+
import { ExternalLink as Be, NotepadText as ze, MoreHorizontal as Fe, Lock as Oe, Edit as je, Plus as Ge, ChevronRight as De, StarsIcon as Re, Hash as We, File as me } from "lucide-react";
|
|
8
|
+
import { useRef as _e, useEffect as U, useMemo as V, lazy as M, useState as N, useCallback as oe, Suspense as C } from "react";
|
|
9
|
+
import { B as He } from "./button-CggatMM3.js";
|
|
10
|
+
const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
|
|
11
|
+
B(e, (r) => {
|
|
12
|
+
const n = E(s);
|
|
13
|
+
return R(E((r == null ? void 0 : r.name) || ""), n) || R(E((r == null ? void 0 : r.slug) || ""), n);
|
|
14
|
+
})
|
|
15
|
+
), qe = (e, s) => {
|
|
16
|
+
const r = /* @__PURE__ */ new Set(), n = de(e, "id");
|
|
17
|
+
return s.forEach((l) => {
|
|
18
|
+
let a = l;
|
|
19
|
+
for (; a.parent && n[a.parent]; )
|
|
20
|
+
r.add(a.parent), a = n[a.parent];
|
|
21
|
+
}), Array.from(r).map((l) => n[l]);
|
|
22
|
+
}, X = (e, s, r) => S(s) ? e : e.map((n) => {
|
|
23
|
+
if (!r(n.pageType))
|
|
24
|
+
return {
|
|
25
|
+
...n,
|
|
26
|
+
shouldExpandOnSearch: !0,
|
|
27
|
+
children: n.children ? X(n.children, s, r) : []
|
|
28
|
+
};
|
|
29
|
+
const l = n.children && n.children.some(
|
|
30
|
+
(a) => R(E(a.name || ""), E(s)) || R(E(a.slug || ""), E(s))
|
|
31
|
+
);
|
|
32
|
+
return {
|
|
33
|
+
...n,
|
|
34
|
+
shouldExpandOnSearch: l,
|
|
35
|
+
children: n.children ? X(n.children, s, r) : []
|
|
36
|
+
};
|
|
37
|
+
}), Qe = (e) => {
|
|
38
|
+
if (!e || !e.length) return [];
|
|
39
|
+
const s = {};
|
|
40
|
+
e.forEach((n) => {
|
|
41
|
+
s[n.id] = { ...n, children: [] };
|
|
42
|
+
});
|
|
43
|
+
const r = [];
|
|
44
|
+
return Object.values(s).forEach((n) => {
|
|
45
|
+
n.parent && s[n.parent] ? s[n.parent].children.push(n) : r.push(n);
|
|
46
|
+
}), r;
|
|
47
|
+
}, he = (e) => !e || !e.length ? [] : [...e].sort(
|
|
48
|
+
(r, n) => (r.name || "").localeCompare(n.name || "")
|
|
49
|
+
).map((r) => ({
|
|
50
|
+
...r,
|
|
51
|
+
children: r.children ? he(r.children) : []
|
|
52
|
+
})), Ve = (e, s, r, n) => {
|
|
53
|
+
if (!e || !e.length) return [];
|
|
54
|
+
let l = e;
|
|
55
|
+
if (r !== "all" && (l = ce(B(e, { pageType: r }))), S(s))
|
|
56
|
+
l = le(l, s);
|
|
57
|
+
else {
|
|
58
|
+
const u = le(l, s), c = qe(e, u);
|
|
59
|
+
l = Ce([...u, ...c], "id");
|
|
60
|
+
}
|
|
61
|
+
const a = he(Qe(l)), h = X(a, s, n), b = B(h, (u) => n(u.pageType)).sort((u, c) => (u.name || "").localeCompare(c.name || "")), i = B(h, (u) => !n(u.pageType));
|
|
62
|
+
let f = [];
|
|
63
|
+
if (r === "all") {
|
|
64
|
+
const u = de(i, "pageType");
|
|
65
|
+
f = Object.values(
|
|
66
|
+
Ee(u, (c, p) => ({
|
|
67
|
+
...c,
|
|
68
|
+
id: p,
|
|
69
|
+
name: Me(p),
|
|
70
|
+
isPartialGroup: !0,
|
|
71
|
+
children: h.filter((g) => g.pageType === p)
|
|
72
|
+
}))
|
|
73
|
+
);
|
|
74
|
+
} else
|
|
75
|
+
f = i.sort((u, c) => (u.name || "").localeCompare(c.name || ""));
|
|
76
|
+
return [...b, ...f];
|
|
77
|
+
}, Xe = $e({
|
|
78
|
+
pageId: null,
|
|
79
|
+
position: { x: 0, y: 0 }
|
|
80
|
+
}), Ye = ({ pageId: e, children: s }) => {
|
|
81
|
+
const [r, n] = ue(Xe), l = _e(null), a = r.pageId === e;
|
|
82
|
+
U(() => {
|
|
83
|
+
const i = () => n({ pageId: null, position: { x: 0, y: 0 } });
|
|
84
|
+
if (a)
|
|
85
|
+
return document.addEventListener("click", i), () => document.removeEventListener("click", i);
|
|
86
|
+
}, [a, n]);
|
|
87
|
+
const h = (i) => {
|
|
88
|
+
i.preventDefault(), i.stopPropagation(), n({ pageId: e, position: { x: i.clientX, y: i.clientY } });
|
|
89
|
+
}, b = () => {
|
|
90
|
+
const i = `${window.location.pathname}?page=${e}`;
|
|
91
|
+
window.open(i, "_blank"), n({ pageId: null, position: { x: 0, y: 0 } });
|
|
92
|
+
};
|
|
93
|
+
return /* @__PURE__ */ y(z, { children: [
|
|
94
|
+
/* @__PURE__ */ t("span", { onContextMenu: h, children: s }),
|
|
95
|
+
a && /* @__PURE__ */ t(
|
|
96
|
+
"div",
|
|
97
|
+
{
|
|
98
|
+
ref: l,
|
|
99
|
+
className: "fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",
|
|
100
|
+
style: { top: r.position.y, left: r.position.x },
|
|
101
|
+
children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ y(
|
|
102
|
+
He,
|
|
103
|
+
{
|
|
104
|
+
variant: "ghost",
|
|
105
|
+
onClick: b,
|
|
106
|
+
className: "w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ t(Be, { className: "h-4 w-4" }),
|
|
109
|
+
"Open in new tab"
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
) })
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
] });
|
|
116
|
+
}, Je = ({ page: e }) => {
|
|
117
|
+
var n, l;
|
|
118
|
+
const { isExpanded: s, toggleExpanded: r } = Y(e == null ? void 0 : e.id);
|
|
119
|
+
return /* @__PURE__ */ t(
|
|
120
|
+
"button",
|
|
121
|
+
{
|
|
122
|
+
onClick: (a) => {
|
|
123
|
+
a.stopPropagation(), r();
|
|
124
|
+
},
|
|
125
|
+
disabled: !((n = e == null ? void 0 : e.children) != null && n.length),
|
|
126
|
+
className: `flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(l = e == null ? void 0 : e.children) != null && l.length ? "hover:text-blue-400" : "opacity-0"}`,
|
|
127
|
+
children: /* @__PURE__ */ t(
|
|
128
|
+
De,
|
|
129
|
+
{
|
|
130
|
+
size: 12,
|
|
131
|
+
className: `stroke-[4] transition-transform duration-200 ${s ? "rotate-90" : ""}`
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}, Ke = ({ page: e, pageType: s }) => /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center gap-x-1", children: e.dynamic ? /* @__PURE__ */ t(Re, { size: 12, className: "text-yellow-400" }) : s != null && s.icon ? /* @__PURE__ */ t(
|
|
137
|
+
"div",
|
|
138
|
+
{
|
|
139
|
+
className: "flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",
|
|
140
|
+
dangerouslySetInnerHTML: { __html: s.icon }
|
|
141
|
+
}
|
|
142
|
+
) : s != null && s.hasSlug ? /* @__PURE__ */ t(me, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(We, { size: 12, className: "stroke-[1] text-slate-500" }) }), Ze = ({ isOnline: e }) => /* @__PURE__ */ t("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), et = ({
|
|
143
|
+
page: e,
|
|
144
|
+
pageTypes: s,
|
|
145
|
+
currentPage: r,
|
|
146
|
+
onClickAction: n,
|
|
147
|
+
languagePages: l,
|
|
148
|
+
selectedLanguage: a,
|
|
149
|
+
showUntranslatedPages: h
|
|
150
|
+
}) => {
|
|
151
|
+
const b = be(), { pageToUser: i } = ge(), f = D(i, [e == null ? void 0 : e.id, "userId"]), { data: u } = ke(f), c = u && b !== f ? u == null ? void 0 : u.name : null, p = ie(), g = r === e.id, W = !!e.isTemplate, P = V(() => $(s, { key: e.pageType }), [s, e.pageType]);
|
|
152
|
+
let m = D(l, e == null ? void 0 : e.id);
|
|
153
|
+
m = D(m, "lang") === a ? m : null;
|
|
154
|
+
const L = a === p || !!m, A = (m == null ? void 0 : m.name) || (e == null ? void 0 : e.name) || "No name";
|
|
155
|
+
let k = (m == null ? void 0 : m.slug) || (e == null ? void 0 : e.slug) || "";
|
|
156
|
+
const F = k + (e != null && e.dynamic ? `/${P == null ? void 0 : P.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
|
|
157
|
+
if (k.startsWith("/") && !h) {
|
|
158
|
+
const d = k.split("/").pop();
|
|
159
|
+
k = k.endsWith(d) && e.dynamic ? "" : `/${d}`;
|
|
160
|
+
}
|
|
161
|
+
const O = V(() => {
|
|
162
|
+
const d = "flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]", T = `${g ? "border-primary/30 bg-primary/5" : "border-transparent hover:border-gray-200 hover:bg-gray-100"}`;
|
|
163
|
+
return L ? `${d} ${T} ${c ? "opacity-60" : ""}` : `${d} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`;
|
|
164
|
+
}, [L, g, c]);
|
|
165
|
+
return /* @__PURE__ */ y("div", { className: "group relative", children: [
|
|
166
|
+
/* @__PURE__ */ t(Ye, { pageId: e.id, children: /* @__PURE__ */ y(
|
|
167
|
+
"div",
|
|
168
|
+
{
|
|
169
|
+
onClick: () => !e.isPartialGroup && L && n("select", e == null ? void 0 : e.id),
|
|
170
|
+
className: O,
|
|
171
|
+
children: [
|
|
172
|
+
/* @__PURE__ */ t(Je, { page: e }),
|
|
173
|
+
!e.isPartialGroup && /* @__PURE__ */ t(Ze, { isOnline: m ? m.online : e.online }),
|
|
174
|
+
!e.isPartialGroup && /* @__PURE__ */ t(Ke, { page: e, pageType: P }),
|
|
175
|
+
/* @__PURE__ */ t(q, { content: A, side: "top", showTooltip: A.length > 35, children: /* @__PURE__ */ t("span", { className: "max-w-[40%] truncate font-medium text-black", children: A }) }),
|
|
176
|
+
(k || e.dynamic) && /* @__PURE__ */ t(q, { content: F, side: "top", showTooltip: !0, children: /* @__PURE__ */ y("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
|
|
177
|
+
k,
|
|
178
|
+
e.dynamic && (P == null ? void 0 : P.dynamicSlug) && /* @__PURE__ */ y("span", { className: "text-xs text-gray-500", children: [
|
|
179
|
+
"/",
|
|
180
|
+
P == null ? void 0 : P.dynamicSlug,
|
|
181
|
+
e.dynamicSlugCustom
|
|
182
|
+
] })
|
|
183
|
+
] }) }),
|
|
184
|
+
W && /* @__PURE__ */ t(q, { content: "Template", side: "top", children: /* @__PURE__ */ t("span", { className: "text-blue-500", children: /* @__PURE__ */ t(ze, { size: 16 }) }) }),
|
|
185
|
+
!e.isPartialGroup && L && !c ? /* @__PURE__ */ t("div", { className: "duration absolute right-0.5 top-[3px]", children: /* @__PURE__ */ t(
|
|
186
|
+
we,
|
|
187
|
+
{
|
|
188
|
+
isLanguagePage: !!m,
|
|
189
|
+
page: m || e,
|
|
190
|
+
setDuplicatePage: (d) => n("duplicate", d),
|
|
191
|
+
setAddEditPage: (d) => n("edit", m || d),
|
|
192
|
+
setUnpublishPage: (d) => n("unpublish", d),
|
|
193
|
+
setDeletePage: (d) => n("delete", m || d),
|
|
194
|
+
setMarkAsTemplate: (d) => n("markAsTemplate", d),
|
|
195
|
+
setUnmarkAsTemplate: (d) => n("unmarkAsTemplate", d),
|
|
196
|
+
children: /* @__PURE__ */ t("div", { className: "m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white", children: /* @__PURE__ */ t(Fe, { className: "h-4 w-4", onClick: (d) => d.stopPropagation() }) })
|
|
197
|
+
}
|
|
198
|
+
) }) : c ? /* @__PURE__ */ t("span", { className: "duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500", children: /* @__PURE__ */ t(Oe, { className: "h-3.5 w-3.5 fill-red-200 text-red-500" }) }) : null
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
) }),
|
|
202
|
+
/* @__PURE__ */ t(z, { children: c && /* @__PURE__ */ y("button", { className: "absolute right-px top-1/2 flex h-6 -translate-y-1/2 items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100", children: [
|
|
203
|
+
/* @__PURE__ */ t(je, { size: 12, className: "stroke-[3]" }),
|
|
204
|
+
" ",
|
|
205
|
+
/* @__PURE__ */ t("span", { className: "font-medium", children: c }),
|
|
206
|
+
" is editing this page"
|
|
207
|
+
] }) }),
|
|
208
|
+
/* @__PURE__ */ t(z, { children: !L && !e.isPartialGroup && !c && /* @__PURE__ */ y(
|
|
209
|
+
"button",
|
|
210
|
+
{
|
|
211
|
+
onClick: (d) => {
|
|
212
|
+
d.stopPropagation(), n("addLanguagePage", { language: a, page: e });
|
|
213
|
+
},
|
|
214
|
+
className: "absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",
|
|
215
|
+
children: [
|
|
216
|
+
/* @__PURE__ */ t(Ge, { size: 12, className: "stroke-[3]" }),
|
|
217
|
+
" ",
|
|
218
|
+
/* @__PURE__ */ y("span", { className: "text-[10px]", children: [
|
|
219
|
+
"Add ",
|
|
220
|
+
D(Ne, a),
|
|
221
|
+
" Page"
|
|
222
|
+
] })
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
) })
|
|
226
|
+
] });
|
|
227
|
+
}, fe = ({
|
|
228
|
+
pages: e,
|
|
229
|
+
tier: s,
|
|
230
|
+
pageTypes: r,
|
|
231
|
+
currentPage: n,
|
|
232
|
+
onClickAction: l,
|
|
233
|
+
languagePages: a,
|
|
234
|
+
selectedLanguage: h,
|
|
235
|
+
showUntranslatedPages: b
|
|
236
|
+
}) => {
|
|
237
|
+
const { expandedPages: i } = Y();
|
|
238
|
+
return /* @__PURE__ */ t("div", { className: "space-y-0.5", style: { paddingLeft: `${s * 10}px` }, children: e.map((f) => /* @__PURE__ */ y(z, { children: [
|
|
239
|
+
/* @__PURE__ */ t(
|
|
240
|
+
et,
|
|
241
|
+
{
|
|
242
|
+
page: f,
|
|
243
|
+
pageTypes: r,
|
|
244
|
+
currentPage: n,
|
|
245
|
+
onClickAction: l,
|
|
246
|
+
languagePages: a,
|
|
247
|
+
selectedLanguage: h,
|
|
248
|
+
showUntranslatedPages: b
|
|
249
|
+
}
|
|
250
|
+
),
|
|
251
|
+
f.children && f.children.length > 0 && (i == null ? void 0 : i.includes(f.id)) && /* @__PURE__ */ t(
|
|
252
|
+
fe,
|
|
253
|
+
{
|
|
254
|
+
pages: f.children,
|
|
255
|
+
tier: s + 1,
|
|
256
|
+
pageTypes: r,
|
|
257
|
+
currentPage: n,
|
|
258
|
+
onClickAction: l,
|
|
259
|
+
languagePages: a,
|
|
260
|
+
selectedLanguage: h,
|
|
261
|
+
showUntranslatedPages: b
|
|
262
|
+
}
|
|
263
|
+
)
|
|
264
|
+
] }, f.id)) });
|
|
265
|
+
}, tt = M(() => import("./page-manager-search-and-filter-DIz68YHL.js")), nt = M(() => import("./add-new-page-GZdKxwCY.js")), st = M(() => import("./delete-page-CeJdK5hc.js")), rt = M(() => import("./duplicate-page-C7FjAbqP.js")), at = M(() => import("./mark-as-template-CuPKgc5N.js")), ot = M(() => import("./unmark-as-template-Dp6S9dY3.js")), lt = M(() => import("./unpublish-page-c382vh74.js")), Pt = ({ close: e }) => {
|
|
266
|
+
const { t: s } = Ie(), { languages: r, setSelectedLang: n } = ae(), { data: l } = ve(), { data: a, isFetching: h } = Se(), [b, i] = Le(), { updateForSelectedPage: f, expandPagesOnSearch: u } = Y(null), c = ie(), p = b.get("page"), [g, W] = N(""), [P, m] = N(null), [L, A] = N(null), [k, F] = N(null), [O, d] = N(null), [T, _] = N(""), [J, K] = N(null), [Z, ee] = N(null), [w, xe] = N(c), [pe, Pe] = N(!1), [, te] = ue(Ae), j = pe && w !== c, { data: I, isFetching: ye } = Te(w), ne = oe(
|
|
267
|
+
(x) => {
|
|
268
|
+
var o;
|
|
269
|
+
return (o = $(l, { key: x })) == null ? void 0 : o.hasSlug;
|
|
270
|
+
},
|
|
271
|
+
[l]
|
|
272
|
+
), v = V(() => a ? j ? B(a, (x) => !(I != null && I[x.id])) : Ve(a, g, T, ne) : [], [a, ne, g, T, I, j]);
|
|
273
|
+
U(() => {
|
|
274
|
+
n(c);
|
|
275
|
+
}, [c, n]), U(() => {
|
|
276
|
+
if (!S(T)) return;
|
|
277
|
+
const x = sessionStorage.getItem("pageTypeFilter") || "all";
|
|
278
|
+
!S(l) && x && ($(l, { key: x }) ? _(x) : _("all"));
|
|
279
|
+
}, [l, T]), U(() => {
|
|
280
|
+
if (p && !h && !$(a, { id: p })) {
|
|
281
|
+
const o = $(a, { slug: "/" });
|
|
282
|
+
if (o) {
|
|
283
|
+
const G = new URLSearchParams({ page: o.id });
|
|
284
|
+
Q(G, i);
|
|
285
|
+
} else
|
|
286
|
+
Q(new URLSearchParams({}), i, !0);
|
|
287
|
+
}
|
|
288
|
+
}, [a, p, h, i]), U(() => {
|
|
289
|
+
p && !h && !S(v) && f(v, p);
|
|
290
|
+
}, [p, h, v, f]), U(() => {
|
|
291
|
+
!S(g) && !S(v) && u(v);
|
|
292
|
+
}, [g, v, u]);
|
|
293
|
+
const { setSelectedLang: H } = ae(), se = oe(
|
|
294
|
+
(x) => {
|
|
295
|
+
const o = new URLSearchParams({ page: x });
|
|
296
|
+
w !== c ? (o.set("lang", w), H(w)) : H(""), Q(o, i), e();
|
|
297
|
+
},
|
|
298
|
+
[e, i, H, w, c]
|
|
299
|
+
), re = (x, o) => {
|
|
300
|
+
var G;
|
|
301
|
+
if (o)
|
|
302
|
+
switch (x) {
|
|
303
|
+
case "add":
|
|
304
|
+
A(o);
|
|
305
|
+
break;
|
|
306
|
+
case "select":
|
|
307
|
+
se(o);
|
|
308
|
+
break;
|
|
309
|
+
case "edit":
|
|
310
|
+
w !== c ? te({
|
|
311
|
+
edit: !0,
|
|
312
|
+
id: o == null ? void 0 : o.id,
|
|
313
|
+
primaryPage: o == null ? void 0 : o.primaryPage
|
|
314
|
+
}) : A(o);
|
|
315
|
+
break;
|
|
316
|
+
case "delete":
|
|
317
|
+
m(o);
|
|
318
|
+
break;
|
|
319
|
+
case "unpublish":
|
|
320
|
+
F(o);
|
|
321
|
+
break;
|
|
322
|
+
case "markAsTemplate":
|
|
323
|
+
d(o);
|
|
324
|
+
break;
|
|
325
|
+
case "unmarkAsTemplate":
|
|
326
|
+
ee(o);
|
|
327
|
+
break;
|
|
328
|
+
case "duplicate":
|
|
329
|
+
K(o);
|
|
330
|
+
break;
|
|
331
|
+
case "addLanguagePage":
|
|
332
|
+
te({
|
|
333
|
+
edit: !1,
|
|
334
|
+
primaryPage: ((G = o == null ? void 0 : o.page) == null ? void 0 : G.id) || "",
|
|
335
|
+
preselectedLang: (o == null ? void 0 : o.language) || w
|
|
336
|
+
});
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
return /* @__PURE__ */ y(z, { children: [
|
|
341
|
+
/* @__PURE__ */ y("div", { className: "flex h-full flex-col justify-between", children: [
|
|
342
|
+
/* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(
|
|
343
|
+
tt,
|
|
344
|
+
{
|
|
345
|
+
pages: v,
|
|
346
|
+
search: g,
|
|
347
|
+
setSearch: W,
|
|
348
|
+
languages: [c, ...r],
|
|
349
|
+
selectedLanguage: w,
|
|
350
|
+
setSelectedLanguage: xe,
|
|
351
|
+
selectedPageType: T,
|
|
352
|
+
setSelectedPageType: _,
|
|
353
|
+
onAddPage: (x) => re("add", x),
|
|
354
|
+
showUntranslatedPages: j,
|
|
355
|
+
setShowUntranslatedPages: Pe
|
|
356
|
+
}
|
|
357
|
+
) }),
|
|
358
|
+
/* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: h || ye ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Ue([...Array(15).keys()], (x) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, x)) }) : S(v) ? /* @__PURE__ */ y("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
|
|
359
|
+
/* @__PURE__ */ t(me, { className: "h-6 w-6 stroke-[1]" }),
|
|
360
|
+
s("Empty List!"),
|
|
361
|
+
/* @__PURE__ */ t("span", { className: "font-light", children: s("Add new page to start") })
|
|
362
|
+
] }) : /* @__PURE__ */ t(
|
|
363
|
+
fe,
|
|
364
|
+
{
|
|
365
|
+
tier: 0,
|
|
366
|
+
pages: v,
|
|
367
|
+
pageTypes: l,
|
|
368
|
+
currentPage: p || "",
|
|
369
|
+
onClickAction: re,
|
|
370
|
+
languagePages: I,
|
|
371
|
+
selectedLanguage: w,
|
|
372
|
+
showUntranslatedPages: j
|
|
373
|
+
}
|
|
374
|
+
) })
|
|
375
|
+
] }),
|
|
376
|
+
L && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(
|
|
377
|
+
nt,
|
|
378
|
+
{
|
|
379
|
+
closePanel: e,
|
|
380
|
+
editPage: se,
|
|
381
|
+
addEditPage: L,
|
|
382
|
+
setAddEditPage: A
|
|
383
|
+
}
|
|
384
|
+
) }),
|
|
385
|
+
P && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(st, { page: P, onClose: () => m(null) }) }),
|
|
386
|
+
k && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(lt, { page: k, onClose: () => F(null) }) }),
|
|
387
|
+
O && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(at, { page: O, onClose: () => d(null) }) }),
|
|
388
|
+
Z && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(ot, { page: Z, onClose: () => ee(null) }) }),
|
|
389
|
+
J && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(rt, { page: J, onClose: () => K(null), closePanel: e }) })
|
|
390
|
+
] });
|
|
391
|
+
};
|
|
392
|
+
export {
|
|
393
|
+
Pt as default
|
|
394
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("./index-CJcS3b8n.cjs"),N=require("./use-page-expand-manager-2KjeYfVS.cjs"),m=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),w=require("@tanstack/react-query"),r=require("lodash-es"),d=require("lucide-react"),C=require("react"),S=({selectedPageType:l,setSelectedPageType:i})=>{const{t:a}=m.useTranslation(),[n,o]=C.useState(""),{data:c}=j.usePageTypes(),h=t=>{if(!n)return!0;const x=n.toLowerCase(),p=g=>String(r.get(t,g,"")).toLowerCase().includes(x);return p("name")||p("key")},u=c.find(t=>t.key===l);return e.jsxs(s.Select,{onValueChange:i,value:l,children:[e.jsx(s.SelectTrigger,{className:`${l==="all"?"bg-gray-100/30 hover:bg-gray-100":"gap-x-1 border bg-gray-100/30 hover:bg-gray-100"} h-9 w-max min-w-[150px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-gray-600 shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-1.5",children:[e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight",children:(u==null?void 0:u.name)||a("All")}),e.jsx(d.ListFilter,{className:`${l!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(s.SelectContent,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white pb-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(d.Search,{strokeWidth:2,className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400"}),e.jsx(s.Input,{placeholder:a("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:n,onChange:t=>o(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(s.SelectItem,{value:"all",children:a("All")}),!r.isEmpty(r.filter(c,t=>t.hasSlug&&h(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Pages")}),r.map([...r.filter(c,t=>t.hasSlug&&h(t))].sort((t,x)=>r.get(t,"name","").localeCompare(r.get(x,"name",""))),t=>e.jsx(s.SelectItem,{value:r.get(t,"key"),children:r.get(t,"name")},r.get(t,"key")))]}),!r.isEmpty(r.filter(c,t=>!t.hasSlug&&h(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Partials")}),r.map([...r.filter(c,t=>!t.hasSlug&&h(t))].sort((t,x)=>r.get(t,"name","").localeCompare(r.get(x,"name",""))),t=>e.jsx(s.SelectItem,{value:r.get(t,"key"),children:r.get(t,"name")},r.get(t,"key")))]}),r.isEmpty(r.filter(c,h))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:a("No matching page types found")})]})]})},k=({search:l,setSearch:i})=>{const{t:a}=m.useTranslation();return e.jsxs("div",{className:"relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5",children:[e.jsx("label",{htmlFor:"page-search-input",className:"sr-only",children:a("Search Pages")}),e.jsx(d.Search,{className:`${l?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(s.Input,{id:"page-search-input",placeholder:a("Search pages"),value:l,onChange:n=>i(n.target.value),className:"border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",autoComplete:"off"})]})},T=({pages:l})=>{const{t:i}=m.useTranslation(),{expandAll:a,collapseAll:n,expandedPages:o}=N.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"icon",onClick:()=>a(l),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsUpDown,{})})}),e.jsx(s.TooltipContent,{children:i("Expand All")})]}),e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{disabled:o.length===0,variant:"outline",size:"icon",onClick:()=>n(),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsDownUp,{})})}),e.jsx(s.TooltipContent,{children:i("Collapse All")})]})]})},y=({languages:l,selectedLanguage:i,setSelectedLanguage:a})=>{const n=j.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:l.map(o=>e.jsxs(s.Button,{variant:i===o?"default":"outline",size:"sm",className:`h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${i===o?"bg-black text-white hover:bg-black":"text-gray-500"}`,onClick:()=>a(o.toLowerCase()),children:[o===n&&e.jsx(d.Star,{size:4,className:`p-0.5 ${i===n?"fill-white":"fill-black"}`}),j.LANGUAGES[o]||""]},o))})},v=()=>{const{t:l}=m.useTranslation(),i=w.useQueryClient();return e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{size:"sm",variant:"ghost",onClick:()=>i.invalidateQueries({queryKey:[j.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(d.RefreshCw,{})})}),e.jsx(s.TooltipContent,{side:"bottom",children:l("Refresh pages list")})]})},E=({pages:l,search:i,setSearch:a,languages:n,onAddPage:o,selectedLanguage:c,setSelectedLanguage:h,selectedPageType:u,setSelectedPageType:t,showUntranslatedPages:x,setShowUntranslatedPages:p})=>{const{t:g}=m.useTranslation(),f=n.length>1;return e.jsxs("div",{className:"space-y-3 border-b border-b-gray-200 px-4 pb-1",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(S,{selectedPageType:u,setSelectedPageType:t}),e.jsx(k,{search:i,setSearch:a}),e.jsx(T,{pages:l}),e.jsxs(s.Button,{variant:"default",onClick:o,className:"rounded px-3 font-normal",children:[e.jsx(d.Plus,{strokeWidth:2,className:"stroke-white stroke-[3]"}),e.jsx("span",{className:"font-normal text-white",children:g("Add Page")})]}),!f&&e.jsx(v,{})]}),f?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(y,{languages:n,selectedLanguage:c,setSelectedLanguage:b=>{h(b),p(x&&(n==null?void 0:n[0])!==c)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(n==null?void 0:n[0])!==c&&e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",onClick:()=>p(!x),className:"h-6 rounded px-3 py-1 text-xs font-normal",children:x?e.jsx(d.FilterXIcon,{}):e.jsx(d.Filter,{})})}),e.jsx(s.TooltipContent,{side:"bottom",children:g("Toggle Untranslated Pages")})]}),e.jsx(v,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=y;exports.default=E;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as n, Fragment as k } from "react/jsx-runtime";
|
|
2
|
-
import { k as F, L as I, m as z, A as j } from "./index-
|
|
2
|
+
import { k as F, L as I, m as z, A as j } from "./index-CtRx3Y3K.js";
|
|
3
3
|
import { u as T } from "./use-page-expand-manager-D6T75I11.js";
|
|
4
4
|
import { useTranslation as f } from "@chaibuilder/sdk";
|
|
5
5
|
import { Button as m, Tooltip as g, TooltipTrigger as b, TooltipContent as y, Select as $, SelectTrigger as G, SelectContent as D, Input as E, SelectItem as N } from "@chaibuilder/sdk/ui";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as n, Fragment as p, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { aq as C, ar as A, A as b, aw as q, az as le, ao as I, ax as R, ay as w } from "./index-
|
|
2
|
+
import { aq as C, ar as A, A as b, aw as q, az as le, ao as I, ax as R, ay as w } from "./index-CtRx3Y3K.js";
|
|
3
3
|
import { useQuery as re, useQueryClient as O, useMutation as G } from "@tanstack/react-query";
|
|
4
4
|
import { useLanguages as ie, useSavePage as de } from "@chaibuilder/sdk";
|
|
5
5
|
import { SheetHeader as ce, SheetTitle as oe, ScrollArea as ue, Skeleton as y, Button as g, DropdownMenu as me, DropdownMenuTrigger as he, DropdownMenuContent as fe, DropdownMenuItem as U, DropdownMenuSeparator as pe, Dialog as j, DialogContent as L, DialogHeader as z, DialogTitle as P, DialogDescription as $, DialogFooter as H } from "@chaibuilder/sdk/ui";
|
|
@@ -46,7 +46,7 @@ const Ae = () => {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
|
-
}, Oe = Se(() => import("./json-diff-viewer-
|
|
49
|
+
}, Oe = Se(() => import("./json-diff-viewer-DX4sQltt.js")), N = ({ tag: t }) => t === "draft" ? /* @__PURE__ */ n("div", { className: "flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600", children: [
|
|
50
50
|
/* @__PURE__ */ n("span", { className: "relative flex h-2 w-2", children: [
|
|
51
51
|
/* @__PURE__ */ e("span", { className: "absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75" }),
|
|
52
52
|
/* @__PURE__ */ e("span", { className: "relative inline-flex h-2 w-2 rounded-full bg-amber-500" })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("./index-Bre43r-W.cjs"),N=require("@tanstack/react-query"),O=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),y=require("date-fns"),L=require("lodash-es"),p=require("lucide-react"),b=require("react");function Q(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const l=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,l.get?l:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const v=Q(b);function z(s){const n=d.useApiUrl(),t=d.useFetch();return N.useQuery({queryKey:[d.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:d.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const B=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=N.useQueryClient();return N.useMutation({mutationFn:async l=>await n(s,{action:d.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:l}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=N.useQueryClient();return N.useMutation({mutationFn:async({revisionId:l,discardCurrent:r})=>await n(s,{action:d.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:l,discardCurrent:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=b.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-34Sqd4il.cjs"))),g=({tag:s})=>s==="draft"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Draft"})]}):s==="live"?e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Live"})]}):s==="published"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-green-500/10 px-1.5 py-0.5 text-xs text-green-600",children:[e.jsx(p.Rocket,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Published"})]}):s==="unsaved"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[e.jsx(p.Save,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Unsaved changes"})]}):e.jsx("span",{className:"rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600",children:s});function J({compare:s,setCompare:n}){const{data:t}=d.useCurrentPage(),{saveState:l}=O.useSavePage(),[r]=d.usePageEditInfo();if(!t)return null;const c=!!s.find(u=>{var i;return(i=u==null?void 0:u.uid)==null?void 0:i.startsWith("draft:")}),x=s.length>=2&&!c,m=l==="UNSAVED";return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border bg-primary/5 p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium leading-none",children:[e.jsx(g,{tag:"draft"}),e.jsx("span",{className:"text-xs font-bold",children:"Currently editing"})]})}),e.jsx("div",{className:"flex items-center pl-2 text-[11px] text-muted-foreground",children:!L.isEmpty(r.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",y.formatDistanceToNow(new Date(r.lastSaved),{addSuffix:!0})]})}),e.jsx("div",{className:"flex items-center gap-2 pt-0.5",children:m?e.jsx(g,{tag:"unsaved"}):null})]}),e.jsx(A,{checked:c,disabled:x,onChange:()=>{n(c?s.filter(u=>u.uid!==`draft:${t==null?void 0:t.id}`):[...s,{uid:`draft:${t==null?void 0:t.id}`,label:"draft",item:{createdAt:Date.now()}}])}})]})}function K(){return e.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((s,n)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(a.Skeleton,{className:"h-4 w-3/4"}),e.jsx(a.Skeleton,{className:"h-3 w-1/2"}),e.jsx(a.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(a.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function I({revision:s,isLatest:n,onRestore:t,onDelete:l,revisionNumber:r,compare:c,setCompare:x,pageId:m}){const{data:u}=d.useChaiUserInfo(s.currentEditor),i=(u==null?void 0:u.name)||"Unknown",f=!!c.find(h=>{var j;return n?(j=h==null?void 0:h.uid)==null?void 0:j.startsWith("live"):(h==null?void 0:h.uid)===s.uid}),S=c.length>=2&&!f;return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"flex items-center gap-1 text-xs leading-none",children:[e.jsx(g,{tag:n?"live":`#${r}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:i})]})}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s.type==="published"?e.jsx(g,{tag:"published"}):e.jsx(g,{tag:"draft"})}),e.jsx("div",{className:"flex items-center text-[10px] text-muted-foreground",children:e.jsx("span",{className:"leading-tight",children:y.format(s.createdAt,"MMM d, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(d.PermissionChecker,{permissions:[d.PAGES_PERMISSIONS.RESTORE_REVISION,d.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:l})})}),e.jsx(A,{checked:f,disabled:S,onChange:()=>{x(f?c.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...c,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${r}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function W({compare:s,setCompare:n,pageId:t}){const[l,r]=b.useState(!1),[c,x]=s;if(s.length===0)return null;const m=({tab:u})=>e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(g,{tag:u.label}),e.jsx("button",{className:"z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",style:{lineHeight:1},onClick:()=>n(s.filter(i=>i.uid!==u.uid)),"aria-label":"Remove selection 1",children:e.jsx(p.X,{className:"h-3 w-3"})})]});return e.jsxs("div",{className:"mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-xs",children:[e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"Compare"}),c&&e.jsx(m,{tab:c}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),x?e.jsx(m,{tab:x}):e.jsx("span",{className:"rounded border px-1 text-xs text-muted-foreground",children:"Choose another"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-0.5 pt-2",children:[e.jsx(a.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none text-gray-500",variant:"outline",onClick:()=>n([]),children:e.jsx("span",{children:" Clear"})}),e.jsxs(a.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none",variant:"default",onClick:()=>r(!0),disabled:s.length<2,children:[e.jsx(p.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),l&&(s==null?void 0:s.length)>1&&t&&e.jsx(b.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx("span",{className:"text-sm",children:"Loading diff viewer..."})}),children:e.jsx($,{open:l,onOpenChange:r,compare:s})})]})}function A({checked:s,disabled:n,onChange:t,label:l="Compare"}){return e.jsx("div",{className:"absolute bottom-2 right-2",children:e.jsxs("label",{className:`flex cursor-pointer items-center gap-x-1 text-[11px] ${n?"opacity-50":""}`,children:[e.jsx("input",{type:"checkbox",className:"h-3 w-3 cursor-pointer rounded focus:ring-0 focus:ring-offset-0",checked:s,disabled:n,onChange:t}),e.jsx("span",{className:"select-none leading-tight",children:l})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(p.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(a.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(a.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(a.DropdownMenuSeparator,{}),e.jsxs(a.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function X({open:s,onOpenChange:n,revision:t,onRestore:l,isRestoring:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(a.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(a.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Restore Revision"}),e.jsxs(a.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",y.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",x]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),e.jsxs(a.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(a.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>l(!1),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(a.Button,{variant:"default",className:"sm:flex-1",onClick:()=>l(!0),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Z({open:s,onOpenChange:n,revision:t,onDelete:l,isDeleting:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(a.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(a.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Delete Revision"}),e.jsxs(a.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",y.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",x]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),e.jsxs(a.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(a.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>n(!1),disabled:r,children:"Cancel"}),e.jsx(a.Button,{variant:"destructive",className:"sm:flex-1",onClick:l,disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function ee({isOpen:s}){var E,R;const[n,t]=v.useState([]),[l,r]=v.useState(null),[c,x]=v.useState(!1),[m,u]=v.useState(!1),{data:i}=d.useCurrentPage(),{data:f,isFetching:S,error:h,refetch:j}=z(i==null?void 0:i.id),{mutate:k,isPending:M}=B(),{mutate:T,isPending:F}=H(),_=N.useQueryClient(),{selectedLang:P,fallbackLang:q}=O.useLanguages(),U=P||q;b.useEffect(()=>t([]),[i==null?void 0:i.id]);const G=o=>{l&&T({revisionId:l.uid,discardCurrent:o},{onSuccess:()=>{x(!1),r(null),_.invalidateQueries({queryKey:[d.ACTIONS.GET_DRAFT_PAGE]})}})},D=o=>{r(o),x(!0)},C=o=>{r(o),u(!0)},V=()=>{l&&k(l.uid,{onSuccess:()=>{u(!1),r(null)}})};return b.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(a.SheetHeader,{children:[e.jsx(a.SheetTitle,{children:"Revision History"}),(i==null?void 0:i.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",y.format(new Date(i.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),S?e.jsx(K,{}):h?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Failed to load revisions. Please try again."}):e.jsxs("div",{className:"mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2",children:[e.jsx(W,{lang:U,compare:n,setCompare:t,pageId:i==null?void 0:i.id}),e.jsx(J,{compare:n,setCompare:t}),(E=f==null?void 0:f.filter(o=>o.uid==="current"))==null?void 0:E.map((o,w)=>e.jsx(I,{pageId:i==null?void 0:i.id,revision:o,isLatest:!0,onRestore:()=>D(o),onDelete:()=>C(o),revisionNumber:w,compare:n,setCompare:t},o.uid)),e.jsx(a.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:(R=f==null?void 0:f.filter(o=>o.uid!=="current"))==null?void 0:R.map((o,w)=>e.jsx(I,{pageId:i==null?void 0:i.id,revision:o,isLatest:o.uid==="current",onRestore:()=>D(o),onDelete:()=>C(o),revisionNumber:w+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(X,{open:c,onOpenChange:x,revision:l,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:u,revision:l,onDelete:V,isDeleting:M})]})}exports.default=ee;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("./index-CJcS3b8n.cjs"),N=require("@tanstack/react-query"),O=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),y=require("date-fns"),L=require("lodash-es"),p=require("lucide-react"),b=require("react");function Q(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const l=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,l.get?l:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const v=Q(b);function z(s){const n=d.useApiUrl(),t=d.useFetch();return N.useQuery({queryKey:[d.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:d.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const B=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=N.useQueryClient();return N.useMutation({mutationFn:async l=>await n(s,{action:d.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:l}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=N.useQueryClient();return N.useMutation({mutationFn:async({revisionId:l,discardCurrent:r})=>await n(s,{action:d.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:l,discardCurrent:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=b.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-DluaC8tY.cjs"))),g=({tag:s})=>s==="draft"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Draft"})]}):s==="live"?e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Live"})]}):s==="published"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-green-500/10 px-1.5 py-0.5 text-xs text-green-600",children:[e.jsx(p.Rocket,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Published"})]}):s==="unsaved"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[e.jsx(p.Save,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Unsaved changes"})]}):e.jsx("span",{className:"rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600",children:s});function J({compare:s,setCompare:n}){const{data:t}=d.useCurrentPage(),{saveState:l}=O.useSavePage(),[r]=d.usePageEditInfo();if(!t)return null;const c=!!s.find(u=>{var i;return(i=u==null?void 0:u.uid)==null?void 0:i.startsWith("draft:")}),x=s.length>=2&&!c,m=l==="UNSAVED";return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border bg-primary/5 p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium leading-none",children:[e.jsx(g,{tag:"draft"}),e.jsx("span",{className:"text-xs font-bold",children:"Currently editing"})]})}),e.jsx("div",{className:"flex items-center pl-2 text-[11px] text-muted-foreground",children:!L.isEmpty(r.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",y.formatDistanceToNow(new Date(r.lastSaved),{addSuffix:!0})]})}),e.jsx("div",{className:"flex items-center gap-2 pt-0.5",children:m?e.jsx(g,{tag:"unsaved"}):null})]}),e.jsx(A,{checked:c,disabled:x,onChange:()=>{n(c?s.filter(u=>u.uid!==`draft:${t==null?void 0:t.id}`):[...s,{uid:`draft:${t==null?void 0:t.id}`,label:"draft",item:{createdAt:Date.now()}}])}})]})}function K(){return e.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((s,n)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(a.Skeleton,{className:"h-4 w-3/4"}),e.jsx(a.Skeleton,{className:"h-3 w-1/2"}),e.jsx(a.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(a.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function I({revision:s,isLatest:n,onRestore:t,onDelete:l,revisionNumber:r,compare:c,setCompare:x,pageId:m}){const{data:u}=d.useChaiUserInfo(s.currentEditor),i=(u==null?void 0:u.name)||"Unknown",f=!!c.find(h=>{var j;return n?(j=h==null?void 0:h.uid)==null?void 0:j.startsWith("live"):(h==null?void 0:h.uid)===s.uid}),S=c.length>=2&&!f;return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"flex items-center gap-1 text-xs leading-none",children:[e.jsx(g,{tag:n?"live":`#${r}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:i})]})}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s.type==="published"?e.jsx(g,{tag:"published"}):e.jsx(g,{tag:"draft"})}),e.jsx("div",{className:"flex items-center text-[10px] text-muted-foreground",children:e.jsx("span",{className:"leading-tight",children:y.format(s.createdAt,"MMM d, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(d.PermissionChecker,{permissions:[d.PAGES_PERMISSIONS.RESTORE_REVISION,d.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:l})})}),e.jsx(A,{checked:f,disabled:S,onChange:()=>{x(f?c.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...c,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${r}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function W({compare:s,setCompare:n,pageId:t}){const[l,r]=b.useState(!1),[c,x]=s;if(s.length===0)return null;const m=({tab:u})=>e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(g,{tag:u.label}),e.jsx("button",{className:"z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",style:{lineHeight:1},onClick:()=>n(s.filter(i=>i.uid!==u.uid)),"aria-label":"Remove selection 1",children:e.jsx(p.X,{className:"h-3 w-3"})})]});return e.jsxs("div",{className:"mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-xs",children:[e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"Compare"}),c&&e.jsx(m,{tab:c}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),x?e.jsx(m,{tab:x}):e.jsx("span",{className:"rounded border px-1 text-xs text-muted-foreground",children:"Choose another"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-0.5 pt-2",children:[e.jsx(a.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none text-gray-500",variant:"outline",onClick:()=>n([]),children:e.jsx("span",{children:" Clear"})}),e.jsxs(a.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none",variant:"default",onClick:()=>r(!0),disabled:s.length<2,children:[e.jsx(p.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),l&&(s==null?void 0:s.length)>1&&t&&e.jsx(b.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx("span",{className:"text-sm",children:"Loading diff viewer..."})}),children:e.jsx($,{open:l,onOpenChange:r,compare:s})})]})}function A({checked:s,disabled:n,onChange:t,label:l="Compare"}){return e.jsx("div",{className:"absolute bottom-2 right-2",children:e.jsxs("label",{className:`flex cursor-pointer items-center gap-x-1 text-[11px] ${n?"opacity-50":""}`,children:[e.jsx("input",{type:"checkbox",className:"h-3 w-3 cursor-pointer rounded focus:ring-0 focus:ring-offset-0",checked:s,disabled:n,onChange:t}),e.jsx("span",{className:"select-none leading-tight",children:l})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(p.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(a.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(a.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(a.DropdownMenuSeparator,{}),e.jsxs(a.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function X({open:s,onOpenChange:n,revision:t,onRestore:l,isRestoring:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(a.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(a.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Restore Revision"}),e.jsxs(a.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",y.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",x]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),e.jsxs(a.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(a.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>l(!1),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(a.Button,{variant:"default",className:"sm:flex-1",onClick:()=>l(!0),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Z({open:s,onOpenChange:n,revision:t,onDelete:l,isDeleting:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(a.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(a.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Delete Revision"}),e.jsxs(a.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",y.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",x]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),e.jsxs(a.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(a.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>n(!1),disabled:r,children:"Cancel"}),e.jsx(a.Button,{variant:"destructive",className:"sm:flex-1",onClick:l,disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function ee({isOpen:s}){var E,R;const[n,t]=v.useState([]),[l,r]=v.useState(null),[c,x]=v.useState(!1),[m,u]=v.useState(!1),{data:i}=d.useCurrentPage(),{data:f,isFetching:S,error:h,refetch:j}=z(i==null?void 0:i.id),{mutate:k,isPending:M}=B(),{mutate:T,isPending:F}=H(),_=N.useQueryClient(),{selectedLang:P,fallbackLang:q}=O.useLanguages(),U=P||q;b.useEffect(()=>t([]),[i==null?void 0:i.id]);const G=o=>{l&&T({revisionId:l.uid,discardCurrent:o},{onSuccess:()=>{x(!1),r(null),_.invalidateQueries({queryKey:[d.ACTIONS.GET_DRAFT_PAGE]})}})},D=o=>{r(o),x(!0)},C=o=>{r(o),u(!0)},V=()=>{l&&k(l.uid,{onSuccess:()=>{u(!1),r(null)}})};return b.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(a.SheetHeader,{children:[e.jsx(a.SheetTitle,{children:"Revision History"}),(i==null?void 0:i.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",y.format(new Date(i.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),S?e.jsx(K,{}):h?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Failed to load revisions. Please try again."}):e.jsxs("div",{className:"mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2",children:[e.jsx(W,{lang:U,compare:n,setCompare:t,pageId:i==null?void 0:i.id}),e.jsx(J,{compare:n,setCompare:t}),(E=f==null?void 0:f.filter(o=>o.uid==="current"))==null?void 0:E.map((o,w)=>e.jsx(I,{pageId:i==null?void 0:i.id,revision:o,isLatest:!0,onRestore:()=>D(o),onDelete:()=>C(o),revisionNumber:w,compare:n,setCompare:t},o.uid)),e.jsx(a.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:(R=f==null?void 0:f.filter(o=>o.uid!=="current"))==null?void 0:R.map((o,w)=>e.jsx(I,{pageId:i==null?void 0:i.id,revision:o,isLatest:o.uid==="current",onRestore:()=>D(o),onDelete:()=>C(o),revisionNumber:w+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(X,{open:c,onOpenChange:x,revision:l,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:u,revision:l,onDelete:V,isDeleting:M})]})}exports.default=ee;
|