@chaibuilder/sdk 4.0.0-beta.32 → 4.0.0-beta.34
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/{2SSKDMRQ-DfXKDvXk.cjs → 2SSKDMRQ-BM-tJzJS.cjs} +1 -1
- package/dist/{2SSKDMRQ-pPung-JB.js → 2SSKDMRQ-hkjhJNfh.js} +5 -5
- package/dist/{AP7HFJJL-PvPBwV6T.cjs → AP7HFJJL-MEqeM2Ns.cjs} +1 -1
- package/dist/{AP7HFJJL-CEJuc_Ox.js → AP7HFJJL-XRxLnRog.js} +1 -1
- package/dist/{IconPicker-BJHUCDn4.cjs → IconPicker-Bl4iY4Cu.cjs} +1 -1
- package/dist/{IconPicker-D_GRfhwS.js → IconPicker-D5wIkgWK.js} +1 -1
- package/dist/{WDYDFRGG-B3FrCE_j.js → WDYDFRGG-8UgG1Mx8.js} +4 -4
- package/dist/{WDYDFRGG-BPHlcLi5.cjs → WDYDFRGG-BitFxd1K.cjs} +1 -1
- package/dist/{actions-registery-Cy1lqUVI.cjs → actions-registery-Byid-s6S.cjs} +28 -28
- package/dist/{actions-registery-Bj-j1k5i.js → actions-registery-CKEzH855.js} +2245 -2067
- package/dist/actions.cjs +1 -1
- package/dist/actions.js +2 -2
- package/dist/{active-in-another-tab-C_Ma7oFU.js → active-in-another-tab-BBrqPDfn.js} +2 -2
- package/dist/{active-in-another-tab-WVYf-z5w.cjs → active-in-another-tab-BsdNjSxr.cjs} +1 -1
- package/dist/{add-new-language-page-CxW2Vuyr.cjs → add-new-language-page-BJUHnI7Z.cjs} +1 -1
- package/dist/{add-new-language-page-DtsBO739.js → add-new-language-page-DvSZenkC.js} +3 -3
- package/dist/{add-new-page-BfKt72NF.cjs → add-new-page-BI7qCsmh.cjs} +1 -1
- package/dist/add-new-page-Dd16d2mC.js +31 -0
- package/dist/{ai-panel-content-dktE9CIO.js → ai-panel-content-CLNgM3Td.js} +5 -5
- package/dist/{ai-panel-content-Dfo4jOVB.cjs → ai-panel-content-CcqF0I9F.cjs} +1 -1
- package/dist/{ai-panel-default-lang-BbUTXMbm.js → ai-panel-default-lang-BooHb2pz.js} +7 -7
- package/dist/{ai-panel-default-lang-GQCtwlPs.cjs → ai-panel-default-lang-XPtfrifL.cjs} +2 -2
- package/dist/{ai-panel-other-lang-nCUxwpLX.cjs → ai-panel-other-lang-BwnRUTSF.cjs} +1 -1
- package/dist/{ai-panel-other-lang-DIDS-mTi.js → ai-panel-other-lang-CcgIMR3N.js} +13 -13
- package/dist/{ai-prompt-input-B2q30bhR.js → ai-prompt-input-AUdUYGNa.js} +13 -13
- package/dist/{ai-prompt-input-Dws5BHhQ.cjs → ai-prompt-input-CQ5SJPkx.cjs} +1 -1
- package/dist/{ai-translation-prompt-CJVcuWrs.cjs → ai-translation-prompt-BTNGNtbf.cjs} +1 -1
- package/dist/{ai-translation-prompt-D87qk3C1.js → ai-translation-prompt-BYUh4Mnb.js} +1 -1
- package/dist/apply-binding-Bu5W9YFY.js +940 -0
- package/dist/apply-binding-C0xIYKCN.cjs +41 -0
- package/dist/{change-password-modal-CVUa60pC.cjs → change-password-modal-CYkUXUa5.cjs} +1 -1
- package/dist/{change-password-modal-PahNYs8x.js → change-password-modal-DCd1gdCm.js} +5 -5
- package/dist/{code-editor-Cim6jQVF.cjs → code-editor-BC6Z10dU.cjs} +1 -1
- package/dist/{code-editor-CWOmKcUc.js → code-editor-DWrVXxeA.js} +1 -1
- package/dist/{continue-editing-in-this-client-BYFOU3hH.js → continue-editing-in-this-client-Bdd5Ls6t.js} +2 -2
- package/dist/{continue-editing-in-this-client-CW0f2LRk.cjs → continue-editing-in-this-client-D6Wc8hEK.cjs} +1 -1
- package/dist/{core-BWQrViOY.cjs → core-czmLeR0h.cjs} +1 -1
- package/dist/{core-QlWEXm1d.js → core-nSRy3D7z.js} +16 -15
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +14 -2
- package/dist/core.js +19 -19
- package/dist/{css-import-modal-6bMTRlCg.js → css-import-modal-Cpwll5L-.js} +1 -1
- package/dist/{css-import-modal-CXulmaB4.cjs → css-import-modal-FHeYoxo2.cjs} +1 -1
- package/dist/default-theme-options-DN-3gIjM.cjs +22 -0
- package/dist/{plugin-BSjgGgwo.js → default-theme-options-saBIkWGT.js} +114 -114
- package/dist/{delete-page-BDViv7Xm.js → delete-page-DyP68v_N.js} +15 -15
- package/dist/delete-page-PQGa6Am5.cjs +1 -0
- package/dist/{design-token-usage-D-hrcKz1.cjs → design-token-usage-CoaLw6EJ.cjs} +1 -1
- package/dist/{design-token-usage-lf7N_uOk.js → design-token-usage-dR3UlfIC.js} +14 -14
- package/dist/{digital-asset-manager-PcYficIX.js → digital-asset-manager-BNj96Pnh.js} +3 -3
- package/dist/{digital-asset-manager-CxxhsToc.cjs → digital-asset-manager-Bxkm-jdI.cjs} +1 -1
- package/dist/{duplicate-page-DfEA148D.js → duplicate-page-Cg6WnFeY.js} +6 -6
- package/dist/{duplicate-page-D2f3HvWX.cjs → duplicate-page-DV_lZ8jF.cjs} +1 -1
- package/dist/{dynamic-page-selector-Dz7D1Wdr.cjs → dynamic-page-selector-C8ax7W_D.cjs} +1 -1
- package/dist/{dynamic-page-selector-DB__KD2y.js → dynamic-page-selector-DcQiWgiL.js} +12 -12
- package/dist/get-chai-builder-theme-C_qofMh_.cjs +1 -0
- package/dist/{get-chai-builder-theme-BpuwSLeS.js → get-chai-builder-theme-CyOkIlte.js} +1 -1
- package/dist/{image-editor-BdW476J8.cjs → image-editor-C5rYU8Ic.cjs} +1 -1
- package/dist/{image-editor-CilPMtAC.js → image-editor-DGp2-ImI.js} +1 -1
- package/dist/{index-DsQXiNA_.js → index-94oA-Cgl.js} +3994 -3943
- package/dist/index-Bg3Prrc_.cjs +5 -0
- package/dist/index-BsloTOgy.cjs +160 -0
- package/dist/{index-IQefjAA0.js → index-CDUCqK5V.js} +1912 -1931
- package/dist/{json-diff-viewer-BPqY25PU.cjs → json-diff-viewer-CdU-gKRr.cjs} +1 -1
- package/dist/{json-diff-viewer-Ci2IbgDn.js → json-diff-viewer-CniMcSHL.js} +34 -34
- package/dist/lang-panel-Dg7eZqIm.cjs +1 -0
- package/dist/{lang-panel-DlAQr-y9.js → lang-panel-YLNZisL2.js} +13 -13
- package/dist/manage-design-tokens-Bct88PT-.js +446 -0
- package/dist/manage-design-tokens-CMf-Vk72.cjs +1 -0
- package/dist/{manage-design-tokens-modal-9qpcb-EC.js → manage-design-tokens-modal-CeSW9VV_.js} +9 -9
- package/dist/manage-design-tokens-modal-YPEBybz3.cjs +1 -0
- package/dist/{mark-as-template-DS-tMllK.cjs → mark-as-template-C5rPp_PV.cjs} +1 -1
- package/dist/{mark-as-template-DOZL3umP.js → mark-as-template-WJ4kUyZK.js} +7 -7
- package/dist/{nested-path-selector-content-CWmPgU-L.cjs → nested-path-selector-content-COErdW8f.cjs} +1 -1
- package/dist/{nested-path-selector-content-Be-pbnVl.js → nested-path-selector-content-D0hfMLC6.js} +1 -1
- package/dist/{no-language-page-content-C8W0M_Fj.js → no-language-page-content-BLnpbzwT.js} +2 -2
- package/dist/{no-language-page-content-DWtEo657.cjs → no-language-page-content-CK_K6fh9.cjs} +1 -1
- package/dist/{no-language-page-dialog-FVXkSnfT.cjs → no-language-page-dialog-BI55QXS_.cjs} +1 -1
- package/dist/{no-language-page-dialog-cpCZ9vES.js → no-language-page-dialog-gZGw3Uzp.js} +2 -2
- package/dist/page-creator-C2ZwuF6M.cjs +1 -0
- package/dist/{page-creator-CFtxeW_t.js → page-creator-hHpEaVpS.js} +183 -183
- package/dist/{page-lock-BS_ErOIW.cjs → page-lock-BN8BI4J8.cjs} +1 -1
- package/dist/{page-lock-Cthbk6Pg.js → page-lock-DMzAREda.js} +2 -2
- package/dist/{page-locked-dialog-BWXifuQ8.cjs → page-locked-dialog-B_2Hy4PJ.cjs} +1 -1
- package/dist/{page-locked-dialog-D5hmaWqw.js → page-locked-dialog-CZiVFSGf.js} +13 -13
- package/dist/page-manager-new-74gQK_vK.js +408 -0
- package/dist/page-manager-new-DLVIuTY7.cjs +1 -0
- package/dist/{page-manager-search-and-filter-jDoLrCB7.cjs → page-manager-search-and-filter-C6XNDRT7.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-iFsFJhn4.js → page-manager-search-and-filter-DYXCod2G.js} +9 -9
- package/dist/page-revisions-content-44SecMak.cjs +1 -0
- package/dist/{page-revisions-content-C1IGUurW.js → page-revisions-content-BWLkqXrw.js} +40 -40
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +35 -4
- package/dist/pages.js +15 -14
- package/dist/{publish-pages-content-BpEoA1T6.js → publish-pages-content-COHFXR-v.js} +68 -75
- package/dist/publish-pages-content-msfUAXJy.cjs +1 -0
- package/dist/render.cjs +1 -1
- package/dist/render.js +5 -5
- package/dist/{rte-widget-modal-CC1KcrAT.cjs → rte-widget-modal-ck2hWBPv.cjs} +1 -1
- package/dist/{rte-widget-modal-c3T09VeO.js → rte-widget-modal-muaFxwH1.js} +1 -1
- package/dist/runtime.cjs +6 -6
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +36 -35
- package/dist/{save-to-lib-BERYhyxq.js → save-to-lib-JBs4ml12.js} +25 -25
- package/dist/{save-to-lib-Bk59qO1r.cjs → save-to-lib-NHLFZR6b.cjs} +1 -1
- package/dist/sdk.css +1 -1
- package/dist/{selected-block-display-C6NxfC0N.js → selected-block-display-0rlYn5jN.js} +20 -20
- package/dist/{selected-block-display-vFSCOnw8.cjs → selected-block-display-BhnCoV28.cjs} +1 -1
- package/dist/seo-panel-BLTekCWH.cjs +2 -0
- package/dist/{seo-panel-COrEJZLA.js → seo-panel-D8QdAKVh.js} +25 -25
- package/dist/shared-json-ld-CDYobqPW.cjs +1 -0
- package/dist/{shared-json-ld-DnTuCBc3.js → shared-json-ld-DclZXKU6.js} +33 -33
- package/dist/{slug-input-CAqkFZBq.js → slug-input-BOaNz0te.js} +1 -1
- package/dist/{slug-input-Curnt2n3.cjs → slug-input-D3pjtp5_.cjs} +1 -1
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.d.ts +6 -0
- package/dist/supabase-actions.js +223 -155
- package/dist/{take-over-request-6fliSr8w.cjs → take-over-request-CF3ubryV.cjs} +1 -1
- package/dist/{take-over-request-DvmM5qTu.js → take-over-request-CbQfdDOW.js} +13 -13
- package/dist/{translation-warning-modal-kRcfrPgo.js → translation-warning-modal-Bs5qTh3p.js} +9 -9
- package/dist/{translation-warning-modal-B876S5yp.cjs → translation-warning-modal-Bseflnj4.cjs} +1 -1
- package/dist/types.d.ts +14 -2
- package/dist/{unmark-as-template-q1GblG-u.cjs → unmark-as-template-CtiOyF4c.cjs} +1 -1
- package/dist/{unmark-as-template-Dn3klZKq.js → unmark-as-template-rGzNVgFR.js} +13 -13
- package/dist/{unpublish-page-DMbcHmUV.cjs → unpublish-page-CNR43LxM.cjs} +1 -1
- package/dist/unpublish-page-DhtGUDXp.js +28 -0
- package/dist/{unpublished-partials-modal-CEFXp1D1.cjs → unpublished-partials-modal-BmKRB4Tl.cjs} +1 -1
- package/dist/{unpublished-partials-modal-Ts5ZhAK9.js → unpublished-partials-modal-j0zuOxDo.js} +3 -3
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +1 -1
- package/dist/{web-preview-B2YGL26D.js → web-preview-BCWqRDBW.js} +1 -1
- package/dist/{web-preview-C6SLwtqv.cjs → web-preview-DYyGglxW.cjs} +1 -1
- package/package.json +2 -1
- package/dist/add-new-page-DG38rI6S.js +0 -31
- package/dist/apply-binding-9XSrYzAE.cjs +0 -1
- package/dist/apply-binding-chfbBKi2.js +0 -846
- package/dist/delete-page-CdByrw3j.cjs +0 -1
- package/dist/get-chai-builder-theme-B5RkBTsB.cjs +0 -1
- package/dist/index-Bzyv7mAh.cjs +0 -5
- package/dist/index-mPCp0j2h.cjs +0 -160
- package/dist/lang-panel-jebYHYGD.cjs +0 -1
- package/dist/manage-design-tokens-BknGNAKE.cjs +0 -1
- package/dist/manage-design-tokens-Co5677WS.js +0 -428
- package/dist/manage-design-tokens-modal-BcgdwEXE.cjs +0 -1
- package/dist/page-creator-o6yRzsVf.cjs +0 -1
- package/dist/page-manager-new-Dl5YwsMm.js +0 -418
- package/dist/page-manager-new-DpSqBzeh.cjs +0 -1
- package/dist/page-revisions-content-CeBepZEw.cjs +0 -1
- package/dist/plugin-DHpuZZXz.cjs +0 -22
- package/dist/publish-pages-content-PNsiaGI-.cjs +0 -1
- package/dist/seo-panel-0vlr_dBq.cjs +0 -2
- package/dist/shared-json-ld-C46hURIr.cjs +0 -1
- package/dist/theme-panel-footer-3ixmq107.cjs +0 -1
- package/dist/theme-panel-footer-BlsXRcEY.js +0 -26
- package/dist/unpublish-page-BbFZw0so.js +0 -28
|
@@ -1,418 +0,0 @@
|
|
|
1
|
-
import { jsxs as w, Fragment as F, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { d as ie } from "./index-DsQXiNA_.js";
|
|
3
|
-
import { aB as be, aC as ge, ap as ke, k as de, T as R, aR as Ne, L as ve, m as Se, g as Le, c as Te, av as Ae, aS as Ce, aT as Ee } from "./index-IQefjAA0.js";
|
|
4
|
-
import { u as J } from "./use-page-expand-manager-Cf4MUEJw.js";
|
|
5
|
-
import { compact as ue, filter as B, isEmpty as g, uniqBy as $e, keyBy as me, mapValues as Me, startCase as Ue, toLower as $, includes as q, get as W, find as H, map as Ie } from "lodash-es";
|
|
6
|
-
import { atom as ze, useAtom as Be, useSetAtom as Fe } from "jotai";
|
|
7
|
-
import { ExternalLink as Oe, Pencil as je, NotepadText as Ge, MoreHorizontal as De, Lock as Re, Edit as We, Plus as He, ChevronRight as _e, StarsIcon as qe, Hash as Ve, File as he } from "lucide-react";
|
|
8
|
-
import { useRef as Qe, useEffect as E, useMemo as _, useState as v, useCallback as le, startTransition as Xe, Suspense as C, lazy as M } from "react";
|
|
9
|
-
import { useTranslation as Ye } from "react-i18next";
|
|
10
|
-
import { B as Je } from "./register-chai-top-bar-D6GjnauV.js";
|
|
11
|
-
const ce = (e, s) => !e || !Array.isArray(e) ? [] : g(s) ? e : ue(
|
|
12
|
-
B(e, (a) => {
|
|
13
|
-
const n = $(s);
|
|
14
|
-
return q($((a == null ? void 0 : a.name) || ""), n) || q($((a == null ? void 0 : a.slug) || ""), n);
|
|
15
|
-
})
|
|
16
|
-
), Ke = (e, s) => {
|
|
17
|
-
const a = /* @__PURE__ */ new Set(), n = me(e, "id");
|
|
18
|
-
return s.forEach((i) => {
|
|
19
|
-
let o = i;
|
|
20
|
-
for (; o.parent && n[o.parent]; )
|
|
21
|
-
a.add(o.parent), o = n[o.parent];
|
|
22
|
-
}), Array.from(a).map((i) => n[i]);
|
|
23
|
-
}, Y = (e, s, a) => g(s) ? e : e.map((n) => {
|
|
24
|
-
if (!a(n.pageType))
|
|
25
|
-
return {
|
|
26
|
-
...n,
|
|
27
|
-
shouldExpandOnSearch: !0,
|
|
28
|
-
children: n.children ? Y(n.children, s, a) : []
|
|
29
|
-
};
|
|
30
|
-
const i = n.children && n.children.some(
|
|
31
|
-
(o) => q($(o.name || ""), $(s)) || q($(o.slug || ""), $(s))
|
|
32
|
-
);
|
|
33
|
-
return {
|
|
34
|
-
...n,
|
|
35
|
-
shouldExpandOnSearch: i,
|
|
36
|
-
children: n.children ? Y(n.children, s, a) : []
|
|
37
|
-
};
|
|
38
|
-
}), Ze = (e) => {
|
|
39
|
-
if (!e || !e.length) return [];
|
|
40
|
-
const s = {};
|
|
41
|
-
e.forEach((n) => {
|
|
42
|
-
s[n.id] = { ...n, children: [] };
|
|
43
|
-
});
|
|
44
|
-
const a = [];
|
|
45
|
-
return Object.values(s).forEach((n) => {
|
|
46
|
-
n.parent && s[n.parent] ? s[n.parent].children.push(n) : a.push(n);
|
|
47
|
-
}), a;
|
|
48
|
-
}, fe = (e) => !e || !e.length ? [] : [...e].sort((a, n) => (a.name || "").localeCompare(n.name || "")).map((a) => ({
|
|
49
|
-
...a,
|
|
50
|
-
children: a.children ? fe(a.children) : []
|
|
51
|
-
})), et = (e, s, a, n) => {
|
|
52
|
-
if (!e || !e.length) return [];
|
|
53
|
-
let i = e;
|
|
54
|
-
if (a !== "all" && (i = ue(B(e, { pageType: a }))), g(s))
|
|
55
|
-
i = ce(i, s);
|
|
56
|
-
else {
|
|
57
|
-
const h = ce(i, s), c = Ke(e, h);
|
|
58
|
-
i = $e([...h, ...c], "id");
|
|
59
|
-
}
|
|
60
|
-
const o = fe(Ze(i)), f = Y(o, s, n), P = B(f, (h) => n(h.pageType)).sort(
|
|
61
|
-
(h, c) => (h.name || "").localeCompare(c.name || "")
|
|
62
|
-
), d = B(f, (h) => !n(h.pageType));
|
|
63
|
-
let p = [];
|
|
64
|
-
if (a === "all") {
|
|
65
|
-
const h = me(d, "pageType");
|
|
66
|
-
p = Object.values(
|
|
67
|
-
Me(h, (c, x) => ({
|
|
68
|
-
...c,
|
|
69
|
-
id: x,
|
|
70
|
-
name: Ue(x),
|
|
71
|
-
isPartialGroup: !0,
|
|
72
|
-
children: f.filter((k) => k.pageType === x)
|
|
73
|
-
}))
|
|
74
|
-
);
|
|
75
|
-
} else
|
|
76
|
-
p = d.sort((h, c) => (h.name || "").localeCompare(c.name || ""));
|
|
77
|
-
return [...P, ...p];
|
|
78
|
-
}, tt = ze({
|
|
79
|
-
pageId: null,
|
|
80
|
-
position: { x: 0, y: 0 }
|
|
81
|
-
}), nt = ({ pageId: e, children: s }) => {
|
|
82
|
-
const [a, n] = Be(tt), i = Qe(null), o = a.pageId === e;
|
|
83
|
-
E(() => {
|
|
84
|
-
const d = () => n({ pageId: null, position: { x: 0, y: 0 } });
|
|
85
|
-
if (o)
|
|
86
|
-
return document.addEventListener("click", d), () => document.removeEventListener("click", d);
|
|
87
|
-
}, [o, n]);
|
|
88
|
-
const f = (d) => {
|
|
89
|
-
d.preventDefault(), d.stopPropagation(), n({ pageId: e, position: { x: d.clientX, y: d.clientY } });
|
|
90
|
-
}, P = () => {
|
|
91
|
-
const d = `${window.location.pathname}?page=${e}`;
|
|
92
|
-
window.open(d, "_blank"), n({ pageId: null, position: { x: 0, y: 0 } });
|
|
93
|
-
};
|
|
94
|
-
return /* @__PURE__ */ w(F, { children: [
|
|
95
|
-
/* @__PURE__ */ t("span", { onContextMenu: f, children: s }),
|
|
96
|
-
o && /* @__PURE__ */ t(
|
|
97
|
-
"div",
|
|
98
|
-
{
|
|
99
|
-
ref: i,
|
|
100
|
-
className: "fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",
|
|
101
|
-
style: { top: a.position.y, left: a.position.x },
|
|
102
|
-
children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ w(
|
|
103
|
-
Je,
|
|
104
|
-
{
|
|
105
|
-
variant: "ghost",
|
|
106
|
-
onClick: P,
|
|
107
|
-
className: "w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",
|
|
108
|
-
children: [
|
|
109
|
-
/* @__PURE__ */ t(Oe, { className: "h-4 w-4" }),
|
|
110
|
-
"Open in new tab"
|
|
111
|
-
]
|
|
112
|
-
}
|
|
113
|
-
) })
|
|
114
|
-
}
|
|
115
|
-
)
|
|
116
|
-
] });
|
|
117
|
-
}, st = ({ page: e }) => {
|
|
118
|
-
var n, i;
|
|
119
|
-
const { isExpanded: s, toggleExpanded: a } = J(e == null ? void 0 : e.id);
|
|
120
|
-
return /* @__PURE__ */ t(
|
|
121
|
-
"button",
|
|
122
|
-
{
|
|
123
|
-
onClick: (o) => {
|
|
124
|
-
o.stopPropagation(), a();
|
|
125
|
-
},
|
|
126
|
-
disabled: !((n = e == null ? void 0 : e.children) != null && n.length),
|
|
127
|
-
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 ${(i = e == null ? void 0 : e.children) != null && i.length ? "hover:text-blue-400" : "opacity-0"}`,
|
|
128
|
-
children: /* @__PURE__ */ t(
|
|
129
|
-
_e,
|
|
130
|
-
{
|
|
131
|
-
size: 12,
|
|
132
|
-
className: `stroke-[4] transition-transform duration-200 ${s ? "rotate-90" : ""}`
|
|
133
|
-
}
|
|
134
|
-
)
|
|
135
|
-
}
|
|
136
|
-
);
|
|
137
|
-
}, at = ({ page: e, pageType: s }) => /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center gap-x-1", children: e.dynamic ? /* @__PURE__ */ t(qe, { size: 12, className: "text-yellow-400" }) : s != null && s.icon ? /* @__PURE__ */ t(
|
|
138
|
-
"div",
|
|
139
|
-
{
|
|
140
|
-
className: "flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",
|
|
141
|
-
dangerouslySetInnerHTML: { __html: s.icon }
|
|
142
|
-
}
|
|
143
|
-
) : s != null && s.hasSlug ? /* @__PURE__ */ t(he, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(Ve, { size: 12, className: "stroke-[1] text-slate-500" }) }), rt = ({ isOnline: e }) => /* @__PURE__ */ t("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), ot = ({
|
|
144
|
-
page: e,
|
|
145
|
-
pageTypes: s,
|
|
146
|
-
currentPage: a,
|
|
147
|
-
onClickAction: n,
|
|
148
|
-
languagePages: i,
|
|
149
|
-
selectedLanguage: o,
|
|
150
|
-
showUntranslatedPages: f
|
|
151
|
-
}) => {
|
|
152
|
-
const P = be(), { pageToUser: d } = ge(), p = W(d, [e == null ? void 0 : e.id, "userId"]), { data: h } = ke(p), c = h && P !== p ? h == null ? void 0 : h.name : null, x = de(), k = a === e.id, V = !!e.isTemplate, y = _(() => H(s, { key: e.pageType }), [s, e.pageType]);
|
|
153
|
-
let u = W(i, e == null ? void 0 : e.id);
|
|
154
|
-
u = W(u, "lang") === o ? u : null;
|
|
155
|
-
const L = o === x || !!u, A = (u == null ? void 0 : u.name) || (e == null ? void 0 : e.name) || "No name";
|
|
156
|
-
let N = (u == null ? void 0 : u.slug) || (e == null ? void 0 : e.slug) || "";
|
|
157
|
-
const O = N + (e != null && e.dynamic ? `/${y == null ? void 0 : y.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
|
|
158
|
-
if (N.startsWith("/") && !f) {
|
|
159
|
-
const l = N.split("/").pop();
|
|
160
|
-
N = N.endsWith(l) && e.dynamic ? "" : `/${l}`;
|
|
161
|
-
}
|
|
162
|
-
const j = _(() => {
|
|
163
|
-
const l = "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]", U = `${k ? "border-primary/30 bg-primary/5" : "border-transparent hover:border-gray-200 hover:bg-gray-100"}`;
|
|
164
|
-
return L ? `${l} ${U} ${c ? "opacity-60" : ""}` : `${l} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`;
|
|
165
|
-
}, [L, k, c]), G = _(() => {
|
|
166
|
-
if (e.isPartialGroup) return !1;
|
|
167
|
-
if (u) {
|
|
168
|
-
if (!u.online || g(u.changes)) return !1;
|
|
169
|
-
} else if (e && (!e.online || g(e.changes)))
|
|
170
|
-
return !1;
|
|
171
|
-
return !0;
|
|
172
|
-
}, [u, e]);
|
|
173
|
-
return /* @__PURE__ */ w("div", { className: "group relative", children: [
|
|
174
|
-
/* @__PURE__ */ t(nt, { pageId: e.id, children: /* @__PURE__ */ w(
|
|
175
|
-
"div",
|
|
176
|
-
{
|
|
177
|
-
onClick: () => !e.isPartialGroup && L && n("select", e == null ? void 0 : e.id),
|
|
178
|
-
className: j,
|
|
179
|
-
children: [
|
|
180
|
-
/* @__PURE__ */ t(st, { page: e }),
|
|
181
|
-
!e.isPartialGroup && /* @__PURE__ */ t(rt, { isOnline: u ? u.online : e.online }),
|
|
182
|
-
!e.isPartialGroup && /* @__PURE__ */ t(at, { page: e, pageType: y }),
|
|
183
|
-
/* @__PURE__ */ t(R, { content: A, side: "top", showTooltip: A.length > 35, children: /* @__PURE__ */ t("span", { className: "max-w-[40%] truncate font-medium text-black", children: A }) }),
|
|
184
|
-
(N || e.dynamic) && /* @__PURE__ */ t(R, { content: O, side: "top", showTooltip: !0, children: /* @__PURE__ */ w("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
|
|
185
|
-
N,
|
|
186
|
-
e.dynamic && (y == null ? void 0 : y.dynamicSlug) && /* @__PURE__ */ w("span", { className: "text-xs text-gray-500", children: [
|
|
187
|
-
"/",
|
|
188
|
-
y == null ? void 0 : y.dynamicSlug,
|
|
189
|
-
e.dynamicSlugCustom
|
|
190
|
-
] })
|
|
191
|
-
] }) }),
|
|
192
|
-
G && /* @__PURE__ */ t(R, { content: "Has unpublished changes", side: "top", children: /* @__PURE__ */ t("span", { className: "text-amber-500", children: /* @__PURE__ */ t(je, { size: 12, className: "stroke-[2]" }) }) }),
|
|
193
|
-
V && /* @__PURE__ */ t(R, { content: "Template", side: "top", children: /* @__PURE__ */ t("span", { className: "text-blue-500", children: /* @__PURE__ */ t(Ge, { size: 16 }) }) }),
|
|
194
|
-
!e.isPartialGroup && L && !c ? /* @__PURE__ */ t("div", { className: "duration absolute right-0.5 top-[3px]", children: /* @__PURE__ */ t(
|
|
195
|
-
Ne,
|
|
196
|
-
{
|
|
197
|
-
isLanguagePage: !!u,
|
|
198
|
-
page: u || e,
|
|
199
|
-
setDuplicatePage: (l) => n("duplicate", l),
|
|
200
|
-
setAddEditPage: (l) => n("edit", u || l),
|
|
201
|
-
setUnpublishPage: (l) => n("unpublish", l),
|
|
202
|
-
setDeletePage: (l) => n("delete", u || l),
|
|
203
|
-
setMarkAsTemplate: (l) => n("markAsTemplate", l),
|
|
204
|
-
setUnmarkAsTemplate: (l) => n("unmarkAsTemplate", l),
|
|
205
|
-
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(De, { className: "h-4 w-4", onClick: (l) => l.stopPropagation() }) })
|
|
206
|
-
}
|
|
207
|
-
) }) : 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(Re, { className: "h-3.5 w-3.5 fill-red-200 text-red-500" }) }) : null
|
|
208
|
-
]
|
|
209
|
-
}
|
|
210
|
-
) }),
|
|
211
|
-
/* @__PURE__ */ t(F, { children: c && /* @__PURE__ */ w("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: [
|
|
212
|
-
/* @__PURE__ */ t(We, { size: 12, className: "stroke-[3]" }),
|
|
213
|
-
" ",
|
|
214
|
-
/* @__PURE__ */ t("span", { className: "font-medium", children: c }),
|
|
215
|
-
" is editing this page"
|
|
216
|
-
] }) }),
|
|
217
|
-
/* @__PURE__ */ t(F, { children: !L && !e.isPartialGroup && !c && /* @__PURE__ */ w(
|
|
218
|
-
"button",
|
|
219
|
-
{
|
|
220
|
-
onClick: (l) => {
|
|
221
|
-
l.stopPropagation(), n("addLanguagePage", { language: o, page: e });
|
|
222
|
-
},
|
|
223
|
-
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",
|
|
224
|
-
children: [
|
|
225
|
-
/* @__PURE__ */ t(He, { size: 12, className: "stroke-[3]" }),
|
|
226
|
-
" ",
|
|
227
|
-
/* @__PURE__ */ w("span", { className: "text-[10px]", children: [
|
|
228
|
-
"Add ",
|
|
229
|
-
W(ve, o),
|
|
230
|
-
" Page"
|
|
231
|
-
] })
|
|
232
|
-
]
|
|
233
|
-
}
|
|
234
|
-
) })
|
|
235
|
-
] });
|
|
236
|
-
}, pe = ({
|
|
237
|
-
pages: e,
|
|
238
|
-
tier: s,
|
|
239
|
-
pageTypes: a,
|
|
240
|
-
currentPage: n,
|
|
241
|
-
onClickAction: i,
|
|
242
|
-
languagePages: o,
|
|
243
|
-
selectedLanguage: f,
|
|
244
|
-
showUntranslatedPages: P
|
|
245
|
-
}) => {
|
|
246
|
-
const { expandedPages: d } = J();
|
|
247
|
-
return /* @__PURE__ */ t("div", { className: "space-y-0.5", style: { paddingLeft: `${s * 10}px` }, children: e.map((p) => /* @__PURE__ */ w(F, { children: [
|
|
248
|
-
/* @__PURE__ */ t(
|
|
249
|
-
ot,
|
|
250
|
-
{
|
|
251
|
-
page: p,
|
|
252
|
-
pageTypes: a,
|
|
253
|
-
currentPage: n,
|
|
254
|
-
onClickAction: i,
|
|
255
|
-
languagePages: o,
|
|
256
|
-
selectedLanguage: f,
|
|
257
|
-
showUntranslatedPages: P
|
|
258
|
-
}
|
|
259
|
-
),
|
|
260
|
-
p.children && p.children.length > 0 && (d == null ? void 0 : d.includes(p.id)) && /* @__PURE__ */ t(
|
|
261
|
-
pe,
|
|
262
|
-
{
|
|
263
|
-
pages: p.children,
|
|
264
|
-
tier: s + 1,
|
|
265
|
-
pageTypes: a,
|
|
266
|
-
currentPage: n,
|
|
267
|
-
onClickAction: i,
|
|
268
|
-
languagePages: o,
|
|
269
|
-
selectedLanguage: f,
|
|
270
|
-
showUntranslatedPages: P
|
|
271
|
-
}
|
|
272
|
-
)
|
|
273
|
-
] }, p.id)) });
|
|
274
|
-
}, it = M(() => import("./page-manager-search-and-filter-iFsFJhn4.js")), lt = M(() => import("./add-new-page-DG38rI6S.js")), ct = M(() => import("./delete-page-BDViv7Xm.js")), dt = M(() => import("./duplicate-page-DfEA148D.js")), ut = M(() => import("./mark-as-template-DOZL3umP.js")), mt = M(() => import("./unmark-as-template-Dn3klZKq.js")), ht = M(() => import("./unpublish-page-BbFZw0so.js")), vt = ({ close: e }) => {
|
|
275
|
-
const { t: s } = Ye(), { languages: a, setSelectedLang: n } = ie(), { data: i } = Se(), { data: o, isFetching: f } = Le(), [P, d] = Te(), { updateForSelectedPage: p, expandPagesOnSearch: h } = J(null), c = de(), x = P.get("page"), [k, V] = v(""), [y, u] = v(null), [L, A] = v(null), [N, O] = v(null), [j, G] = v(null), [l, U] = v(""), [K, Z] = v(null), [ee, te] = v(null), [b, Q] = v(c), [xe, ye] = v(!1), ne = Fe(Ae), D = xe && b !== c, { data: I, isFetching: we } = Ce(b), se = le(
|
|
276
|
-
(m) => {
|
|
277
|
-
var r;
|
|
278
|
-
return (r = H(i, { key: m })) == null ? void 0 : r.hasSlug;
|
|
279
|
-
},
|
|
280
|
-
[i]
|
|
281
|
-
), S = _(() => o ? D ? B(o, (m) => !(I != null && I[m.id])) : et(o, k, l, se) : [], [o, se, k, l, I, D]);
|
|
282
|
-
E(() => {
|
|
283
|
-
n(c);
|
|
284
|
-
}, [c, n]), E(() => {
|
|
285
|
-
const m = P.get("lang");
|
|
286
|
-
if (m) {
|
|
287
|
-
const r = a, T = a[0] ?? c, z = r.includes(m);
|
|
288
|
-
Xe(() => {
|
|
289
|
-
z && b !== m ? Q(m) : !z && b !== T && Q(T);
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
}, []), E(() => {
|
|
293
|
-
if (!g(l)) return;
|
|
294
|
-
const m = sessionStorage.getItem("pageTypeFilter") || "all";
|
|
295
|
-
!g(i) && m && (H(i, { key: m }) ? U(m) : U("all"));
|
|
296
|
-
}, [i, l]), E(() => {
|
|
297
|
-
if (x && !f && !H(o, { id: x })) {
|
|
298
|
-
const r = new URLSearchParams(P.toString());
|
|
299
|
-
if (r.delete("page"), [...r.keys()].length > 0) {
|
|
300
|
-
if (typeof window < "u" && window.history && window.location) {
|
|
301
|
-
const T = r.toString(), z = window.location.hash || "", oe = window.location.pathname, Pe = T ? `${oe}?${T}${z}` : `${oe}${z}`;
|
|
302
|
-
window.history.replaceState(window.history.state, "", Pe);
|
|
303
|
-
}
|
|
304
|
-
d(r);
|
|
305
|
-
} else
|
|
306
|
-
typeof window < "u" && window.history && window.location && (window.history.replaceState(
|
|
307
|
-
window.history.state,
|
|
308
|
-
"",
|
|
309
|
-
window.location.pathname + window.location.hash
|
|
310
|
-
), window.dispatchEvent(new PopStateEvent("popstate", { state: window.history.state }))), d(r);
|
|
311
|
-
}
|
|
312
|
-
}, [o, x, f, d]), E(() => {
|
|
313
|
-
x && !f && !g(S) && p(S, x);
|
|
314
|
-
}, [x, f, S, p]), E(() => {
|
|
315
|
-
!g(k) && !g(S) && h(S);
|
|
316
|
-
}, [k, S, h]);
|
|
317
|
-
const { setSelectedLang: X } = ie(), ae = le(
|
|
318
|
-
(m) => {
|
|
319
|
-
const r = new URLSearchParams({ page: m });
|
|
320
|
-
b !== c ? (r.set("lang", b), X(b)) : X(""), Ee(r, d), e();
|
|
321
|
-
},
|
|
322
|
-
[e, d, X, b, c]
|
|
323
|
-
), re = (m, r) => {
|
|
324
|
-
var T;
|
|
325
|
-
if (r)
|
|
326
|
-
switch (m) {
|
|
327
|
-
case "add":
|
|
328
|
-
A(r);
|
|
329
|
-
break;
|
|
330
|
-
case "select":
|
|
331
|
-
ae(r);
|
|
332
|
-
break;
|
|
333
|
-
case "edit":
|
|
334
|
-
b !== c ? ne({
|
|
335
|
-
edit: !0,
|
|
336
|
-
id: r == null ? void 0 : r.id,
|
|
337
|
-
primaryPage: r == null ? void 0 : r.primaryPage
|
|
338
|
-
}) : A(r);
|
|
339
|
-
break;
|
|
340
|
-
case "delete":
|
|
341
|
-
u(r);
|
|
342
|
-
break;
|
|
343
|
-
case "unpublish":
|
|
344
|
-
O(r);
|
|
345
|
-
break;
|
|
346
|
-
case "markAsTemplate":
|
|
347
|
-
G(r);
|
|
348
|
-
break;
|
|
349
|
-
case "unmarkAsTemplate":
|
|
350
|
-
te(r);
|
|
351
|
-
break;
|
|
352
|
-
case "duplicate":
|
|
353
|
-
Z(r);
|
|
354
|
-
break;
|
|
355
|
-
case "addLanguagePage":
|
|
356
|
-
ne({
|
|
357
|
-
edit: !1,
|
|
358
|
-
primaryPage: ((T = r == null ? void 0 : r.page) == null ? void 0 : T.id) || "",
|
|
359
|
-
preselectedLang: (r == null ? void 0 : r.language) || b
|
|
360
|
-
});
|
|
361
|
-
break;
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
return /* @__PURE__ */ w(F, { children: [
|
|
365
|
-
/* @__PURE__ */ w("div", { className: "flex h-full flex-col justify-between", children: [
|
|
366
|
-
/* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(
|
|
367
|
-
it,
|
|
368
|
-
{
|
|
369
|
-
pages: S,
|
|
370
|
-
search: k,
|
|
371
|
-
setSearch: V,
|
|
372
|
-
languages: [c, ...a],
|
|
373
|
-
selectedLanguage: b,
|
|
374
|
-
setSelectedLanguage: Q,
|
|
375
|
-
selectedPageType: l,
|
|
376
|
-
setSelectedPageType: U,
|
|
377
|
-
onAddPage: (m) => re("add", m),
|
|
378
|
-
showUntranslatedPages: D,
|
|
379
|
-
setShowUntranslatedPages: ye
|
|
380
|
-
}
|
|
381
|
-
) }),
|
|
382
|
-
/* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: f || we ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Ie([...Array(15).keys()], (m) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, m)) }) : g(S) ? /* @__PURE__ */ w("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
|
|
383
|
-
/* @__PURE__ */ t(he, { className: "h-6 w-6 stroke-[1]" }),
|
|
384
|
-
s("Empty List!"),
|
|
385
|
-
/* @__PURE__ */ t("span", { className: "font-light", children: s("Add new page to start") })
|
|
386
|
-
] }) : /* @__PURE__ */ t(
|
|
387
|
-
pe,
|
|
388
|
-
{
|
|
389
|
-
tier: 0,
|
|
390
|
-
pages: S,
|
|
391
|
-
pageTypes: i,
|
|
392
|
-
currentPage: x || "",
|
|
393
|
-
onClickAction: re,
|
|
394
|
-
languagePages: I,
|
|
395
|
-
selectedLanguage: b,
|
|
396
|
-
showUntranslatedPages: D
|
|
397
|
-
}
|
|
398
|
-
) })
|
|
399
|
-
] }),
|
|
400
|
-
L && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(
|
|
401
|
-
lt,
|
|
402
|
-
{
|
|
403
|
-
closePanel: e,
|
|
404
|
-
editPage: ae,
|
|
405
|
-
addEditPage: L,
|
|
406
|
-
setAddEditPage: A
|
|
407
|
-
}
|
|
408
|
-
) }),
|
|
409
|
-
y && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(ct, { page: y, onClose: () => u(null) }) }),
|
|
410
|
-
N && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(ht, { page: N, onClose: () => O(null) }) }),
|
|
411
|
-
j && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(ut, { page: j, onClose: () => G(null) }) }),
|
|
412
|
-
ee && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(mt, { page: ee, onClose: () => te(null) }) }),
|
|
413
|
-
K && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(dt, { page: K, onClose: () => Z(null), closePanel: e }) })
|
|
414
|
-
] });
|
|
415
|
-
};
|
|
416
|
-
export {
|
|
417
|
-
vt as default
|
|
418
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),K=require("./index-mPCp0j2h.cjs"),p=require("./index-Bzyv7mAh.cjs"),G=require("./use-page-expand-manager-B6XTvk0E.cjs"),n=require("lodash-es"),R=require("jotai"),S=require("lucide-react"),o=require("react"),oe=require("react-i18next"),ie=require("./register-chai-top-bar-DyW9GPzV.cjs"),Z=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const s=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),s)||n.includes(n.toLower((a==null?void 0:a.slug)||""),s)})),le=(e,r)=>{const a=new Set,s=n.keyBy(e,"id");return r.forEach(c=>{let l=c;for(;l.parent&&s[l.parent];)a.add(l.parent),l=s[l.parent]}),Array.from(a).map(c=>s[c])},O=(e,r,a)=>n.isEmpty(r)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?O(s.children,r,a):[]};const c=s.children&&s.children.some(l=>n.includes(n.toLower(l.name||""),n.toLower(r))||n.includes(n.toLower(l.slug||""),n.toLower(r)));return{...s,shouldExpandOnSearch:c,children:s.children?O(s.children,r,a):[]}}),ce=e=>{if(!e||!e.length)return[];const r={};e.forEach(s=>{r[s.id]={...s,children:[]}});const a=[];return Object.values(r).forEach(s=>{s.parent&&r[s.parent]?r[s.parent].children.push(s):a.push(s)}),a},ee=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?ee(a.children):[]})),de=(e,r,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))c=Z(c,r);else{const f=Z(c,r),u=le(e,f);c=n.uniqBy([...f,...u],"id")}const l=ee(ce(c)),y=O(l,r,s),j=n.filter(y,f=>s(f.pageType)).sort((f,u)=>(f.name||"").localeCompare(u.name||"")),m=n.filter(y,f=>!s(f.pageType));let P=[];if(a==="all"){const f=n.keyBy(m,"pageType");P=Object.values(n.mapValues(f,(u,w)=>({...u,id:w,name:n.startCase(w),isPartialGroup:!0,children:y.filter(k=>k.pageType===w)})))}else P=m.sort((f,u)=>(f.name||"").localeCompare(u.name||""));return[...j,...P]},ue=R.atom({pageId:null,position:{x:0,y:0}}),me=({pageId:e,children:r})=>{const[a,s]=R.useAtom(ue),c=o.useRef(null),l=a.pageId===e;o.useEffect(()=>{const m=()=>s({pageId:null,position:{x:0,y:0}});if(l)return document.addEventListener("click",m),()=>document.removeEventListener("click",m)},[l,s]);const y=m=>{m.preventDefault(),m.stopPropagation(),s({pageId:e,position:{x:m.clientX,y:m.clientY}})},j=()=>{const m=`${window.location.pathname}?page=${e}`;window.open(m,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:y,children:r}),l&&t.jsx("div",{ref:c,className:"fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",style:{top:a.position.y,left:a.position.x},children:t.jsx("div",{className:"",children:t.jsxs(ie.Button,{variant:"ghost",onClick:j,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(S.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},he=({page:e})=>{var s,c;const{isExpanded:r,toggleExpanded:a}=G.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:l=>{l.stopPropagation(),a()},disabled:!((s=e==null?void 0:e.children)!=null&&s.length),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 ${(c=e==null?void 0:e.children)!=null&&c.length?"hover:text-blue-400":"opacity-0"}`,children:t.jsx(S.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},xe=({page:e,pageType:r})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(S.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?t.jsx("div",{className:"flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",dangerouslySetInnerHTML:{__html:r.icon}}):r!=null&&r.hasSlug?t.jsx(S.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(S.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),fe=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),pe=({page:e,pageTypes:r,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:l,showUntranslatedPages:y})=>{const j=p.useUserId(),{pageToUser:m}=p.usePageToUser(),P=n.get(m,[e==null?void 0:e.id,"userId"]),{data:f}=p.useChaiUserInfo(P),u=f&&j!==P?f==null?void 0:f.name:null,w=p.useFallbackLang(),k=a===e.id,F=!!e.isTemplate,g=o.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]);let h=n.get(c,e==null?void 0:e.id);h=n.get(h,"lang")===l?h:null;const E=l===w||!!h,T=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let v=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const $=v+(e!=null&&e.dynamic?`/${g==null?void 0:g.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(v.startsWith("/")&&!y){const d=v.split("/").pop();v=v.endsWith(d)&&e.dynamic?"":`/${d}`}const q=o.useMemo(()=>{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]",C=`${k?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${d} ${C} ${u?"opacity-60":""}`:`${d} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,k,u]),z=o.useMemo(()=>{if(e.isPartialGroup)return!1;if(h){if(!h.online||n.isEmpty(h.changes))return!1}else if(e&&(!e.online||n.isEmpty(e.changes)))return!1;return!0},[h,e]);return t.jsxs("div",{className:"group relative",children:[t.jsx(me,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:q,children:[t.jsx(he,{page:e}),!e.isPartialGroup&&t.jsx(fe,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(xe,{page:e,pageType:g}),t.jsx(p.Tooltip,{content:T,side:"top",showTooltip:T.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:T})}),(v||e.dynamic)&&t.jsx(p.Tooltip,{content:$,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[v,e.dynamic&&(g==null?void 0:g.dynamicSlug)&&t.jsxs("span",{className:"text-xs text-gray-500",children:["/",g==null?void 0:g.dynamicSlug,e.dynamicSlugCustom]})]})}),z&&t.jsx(p.Tooltip,{content:"Has unpublished changes",side:"top",children:t.jsx("span",{className:"text-amber-500",children:t.jsx(S.Pencil,{size:12,className:"stroke-[2]"})})}),F&&t.jsx(p.Tooltip,{content:"Template",side:"top",children:t.jsx("span",{className:"text-blue-500",children:t.jsx(S.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!u?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(p.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:d=>s("duplicate",d),setAddEditPage:d=>s("edit",h||d),setUnpublishPage:d=>s("unpublish",d),setDeletePage:d=>s("delete",h||d),setMarkAsTemplate:d=>s("markAsTemplate",d),setUnmarkAsTemplate:d=>s("unmarkAsTemplate",d),children:t.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:t.jsx(S.MoreHorizontal,{className:"h-4 w-4",onClick:d=>d.stopPropagation()})})})}):u?t.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:t.jsx(S.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]})}),t.jsx(t.Fragment,{children:u&&t.jsxs("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:[t.jsx(S.Edit,{size:12,className:"stroke-[3]"})," ",t.jsx("span",{className:"font-medium",children:u})," is editing this page"]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!u&&t.jsxs("button",{onClick:d=>{d.stopPropagation(),s("addLanguagePage",{language:l,page:e})},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",children:[t.jsx(S.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(p.LANGUAGES,l)," Page"]})]})})]})},te=({pages:e,tier:r,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:y,showUntranslatedPages:j})=>{const{expandedPages:m}=G.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(P=>t.jsxs(t.Fragment,{children:[t.jsx(pe,{page:P,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:y,showUntranslatedPages:j}),P.children&&P.children.length>0&&(m==null?void 0:m.includes(P.id))&&t.jsx(te,{pages:P.children,tier:r+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:y,showUntranslatedPages:j})]},P.id))})},ye=o.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-jDoLrCB7.cjs"))),Pe=o.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-BfKt72NF.cjs"))),we=o.lazy(()=>Promise.resolve().then(()=>require("./delete-page-CdByrw3j.cjs"))),ge=o.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-D2f3HvWX.cjs"))),je=o.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-DS-tMllK.cjs"))),be=o.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-q1GblG-u.cjs"))),Se=o.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-DMbcHmUV.cjs"))),ke=({close:e})=>{const{t:r}=oe.useTranslation(),{languages:a,setSelectedLang:s}=K.useLanguages(),{data:c}=p.usePageTypes(),{data:l,isFetching:y}=p.useWebsitePages(),[j,m]=p.useSearchParams(),{updateForSelectedPage:P,expandPagesOnSearch:f}=G.usePageExpandManager(null),u=p.useFallbackLang(),w=j.get("page"),[k,F]=o.useState(""),[g,h]=o.useState(null),[E,T]=o.useState(null),[v,$]=o.useState(null),[q,z]=o.useState(null),[d,C]=o.useState(""),[D,W]=o.useState(null),[H,_]=o.useState(null),[b,I]=o.useState(u),[se,ne]=o.useState(!1),V=R.useSetAtom(p.addNewLangAtom),U=se&&b!==u,{data:A,isFetching:re}=p.useWebsiteLanguagePages(b),Q=o.useCallback(x=>{var i;return(i=n.find(c,{key:x}))==null?void 0:i.hasSlug},[c]),N=o.useMemo(()=>l?U?n.filter(l,x=>!(A!=null&&A[x.id])):de(l,k,d,Q):[],[l,Q,k,d,A,U]);o.useEffect(()=>{s(u)},[u,s]),o.useEffect(()=>{const x=j.get("lang");if(x){const i=a,L=a[0]??u,M=i.includes(x);o.startTransition(()=>{M&&b!==x?I(x):!M&&b!==L&&I(L)})}},[]),o.useEffect(()=>{if(!n.isEmpty(d))return;const x=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&x&&(n.find(c,{key:x})?C(x):C("all"))},[c,d]),o.useEffect(()=>{if(w&&!y&&!n.find(l,{id:w})){const i=new URLSearchParams(j.toString());if(i.delete("page"),[...i.keys()].length>0){if(typeof window<"u"&&window.history&&window.location){const L=i.toString(),M=window.location.hash||"",J=window.location.pathname,ae=L?`${J}?${L}${M}`:`${J}${M}`;window.history.replaceState(window.history.state,"",ae)}m(i)}else typeof window<"u"&&window.history&&window.location&&(window.history.replaceState(window.history.state,"",window.location.pathname+window.location.hash),window.dispatchEvent(new PopStateEvent("popstate",{state:window.history.state}))),m(i)}},[l,w,y,m]),o.useEffect(()=>{w&&!y&&!n.isEmpty(N)&&P(N,w)},[w,y,N,P]),o.useEffect(()=>{!n.isEmpty(k)&&!n.isEmpty(N)&&f(N)},[k,N,f]);const{setSelectedLang:B}=K.useLanguages(),X=o.useCallback(x=>{const i=new URLSearchParams({page:x});b!==u?(i.set("lang",b),B(b)):B(""),p.navigateToPage(i,m),e()},[e,m,B,b,u]),Y=(x,i)=>{var L;if(i)switch(x){case"add":T(i);break;case"select":X(i);break;case"edit":b!==u?V({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):T(i);break;case"delete":h(i);break;case"unpublish":$(i);break;case"markAsTemplate":z(i);break;case"unmarkAsTemplate":_(i);break;case"duplicate":W(i);break;case"addLanguagePage":V({edit:!1,primaryPage:((L=i==null?void 0:i.page)==null?void 0:L.id)||"",preselectedLang:(i==null?void 0:i.language)||b});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(o.Suspense,{children:t.jsx(ye,{pages:N,search:k,setSearch:F,languages:[u,...a],selectedLanguage:b,setSelectedLanguage:I,selectedPageType:d,setSelectedPageType:C,onAddPage:x=>Y("add",x),showUntranslatedPages:U,setShowUntranslatedPages:ne})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:y||re?t.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],x=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},x))}):n.isEmpty(N)?t.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[t.jsx(S.File,{className:"h-6 w-6 stroke-[1]"}),r("Empty List!"),t.jsx("span",{className:"font-light",children:r("Add new page to start")})]}):t.jsx(te,{tier:0,pages:N,pageTypes:c,currentPage:w||"",onClickAction:Y,languagePages:A,selectedLanguage:b,showUntranslatedPages:U})})]}),E&&t.jsx(o.Suspense,{children:t.jsx(Pe,{closePanel:e,editPage:X,addEditPage:E,setAddEditPage:T})}),g&&t.jsx(o.Suspense,{children:t.jsx(we,{page:g,onClose:()=>h(null)})}),v&&t.jsx(o.Suspense,{children:t.jsx(Se,{page:v,onClose:()=>$(null)})}),q&&t.jsx(o.Suspense,{children:t.jsx(je,{page:q,onClose:()=>z(null)})}),H&&t.jsx(o.Suspense,{children:t.jsx(be,{page:H,onClose:()=>_(null)})}),D&&t.jsx(o.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null),closePanel:e})})]})};exports.default=ke;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-DyW9GPzV.cjs"),i=require("./index-mPCp0j2h.cjs"),c=require("./index-Bzyv7mAh.cjs"),y=require("@tanstack/react-query"),S=require("date-fns"),B=require("lodash-es"),f=require("lucide-react"),g=require("react");function L(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const w=L(g);function Q(s){const n=c.useApiUrl(),t=c.useFetch();return y.useQuery({queryKey:[c.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:c.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const z=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async r=>await n(s,{action:c.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async({revisionId:r,discardCurrent:l,pageId:d})=>await n(s,{action:c.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:r,discardCurrent:l,...d&&{pageId:d}}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=g.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-BPqY25PU.cjs"))),b=({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(f.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(f.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}=c.useChaiCurrentPage(),{saveState:r}=i.useSavePage(),[l]=c.usePageEditInfo();if(!t)return null;const d=!!s.find(x=>{var a;return(a=x==null?void 0:x.uid)==null?void 0:a.startsWith("draft:")}),u=s.length>=2&&!d,m=r==="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(b,{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:!B.isEmpty(l.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",S.formatDistanceToNow(new Date(l.lastSaved),{addSuffix:!0})]})}),e.jsx("div",{className:"flex items-center gap-2 pt-0.5",children:m?e.jsx(b,{tag:"unsaved"}):null})]}),e.jsx(O,{checked:d,disabled:u,onChange:()=>{n(d?s.filter(x=>x.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(i.Skeleton,{className:"h-4 w-3/4"}),e.jsx(i.Skeleton,{className:"h-3 w-1/2"}),e.jsx(i.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(i.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function I({revision:s,isLatest:n,onRestore:t,onDelete:r,revisionNumber:l,compare:d,setCompare:u,pageId:m}){const{data:x}=c.useChaiUserInfo(s.currentEditor),a=(x==null?void 0:x.name)||"Unknown",p=!!d.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}),D=d.length>=2&&!p;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(b,{tag:n?"live":`#${l}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:a})]})}),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(b,{tag:"published"}):e.jsx(b,{tag:"draft"})}),e.jsx("div",{className:"flex items-center text-[10px] text-muted-foreground",children:e.jsx("span",{className:"leading-tight",children:S.format(s.createdAt,"MMM d, yyyy, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(c.PermissionChecker,{permissions:[c.PAGES_PERMISSIONS.RESTORE_REVISION,c.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:r})})}),e.jsx(O,{checked:p,disabled:D,onChange:()=>{u(p?d.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...d,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${l}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function A({tab:s,onRemove:n}){return e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(b,{tag:s.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.uid),"aria-label":"Remove selection",children:e.jsx(f.X,{className:"h-3 w-3"})})]})}function W({compare:s,setCompare:n,pageId:t}){const[r,l]=g.useState(!1),[d,u]=s;if(s.length===0)return null;const m=x=>n(s.filter(a=>a.uid!==x));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"}),d&&e.jsx(A,{tab:d,onRemove:m}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),u?e.jsx(A,{tab:u,onRemove:m}):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(N.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(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none",variant:"default",onClick:()=>l(!0),disabled:s.length<2,children:[e.jsx(f.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),r&&(s==null?void 0:s.length)>1&&t&&e.jsx(g.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:r,onOpenChange:l,compare:s})})]})}function O({checked:s,disabled:n,onChange:t,label:r="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:r})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(N.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(f.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(i.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(f.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(i.DropdownMenuSeparator,{}),e.jsxs(i.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(f.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function X({open:s,onOpenChange:n,revision:t,onRestore:r,isRestoring:l}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{l||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Restore Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",S.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),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(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>r(!1),disabled:l,children:l?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(f.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(N.Button,{variant:"default",className:"sm:flex-1",onClick:()=>r(!0),disabled:l,children:l?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(f.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Z({open:s,onOpenChange:n,revision:t,onDelete:r,isDeleting:l}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{l||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Delete Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",S.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),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(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>n(!1),disabled:l,children:"Cancel"}),e.jsx(N.Button,{variant:"destructive",className:"sm:flex-1",onClick:r,disabled:l,children:l?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(f.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function ee({isOpen:s}){var R;const[n,t]=w.useState([]),[r,l]=w.useState(null),[d,u]=w.useState(!1),[m,x]=w.useState(!1),{data:a}=c.useChaiCurrentPage(),{data:p,isFetching:D,error:h,refetch:j}=Q(a==null?void 0:a.id),{mutate:T,isPending:M}=z(),{mutate:k,isPending:F}=H(),_=y.useQueryClient(),{selectedLang:q,fallbackLang:P}=i.useLanguages(),U=q||P;g.useEffect(()=>{g.startTransition(()=>t([]))},[a==null?void 0:a.id]);const G=o=>{r&&k({revisionId:r.uid,discardCurrent:o,...r.uid==="current"&&(a==null?void 0:a.id)&&{pageId:a.id}},{onSuccess:()=>{u(!1),l(null),_.invalidateQueries({queryKey:[c.ACTIONS.GET_DRAFT_PAGE]})}})},C=o=>{l(o),u(!0)},E=o=>{l(o),x(!0)},V=()=>{r&&T(r.uid,{onSuccess:()=>{x(!1),l(null)}})};return g.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(i.SheetHeader,{children:[e.jsx(i.SheetTitle,{children:"Revision History"}),(a==null?void 0:a.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",S.format(new Date(a.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),D?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:a==null?void 0:a.id}),e.jsx(J,{compare:n,setCompare:t}),(R=p==null?void 0:p.filter(o=>o.uid==="current"))==null?void 0:R.map((o,v)=>e.jsx(I,{pageId:a==null?void 0:a.id,revision:o,isLatest:!0,onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:v,compare:n,setCompare:t},o.uid)),e.jsx(i.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:[...p??[]].filter(o=>o.uid!=="current").sort((o,v)=>new Date(v.createdAt).getTime()-new Date(o.createdAt).getTime()).map((o,v)=>e.jsx(I,{pageId:a==null?void 0:a.id,revision:o,isLatest:o.uid==="current",onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:v+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(X,{open:d,onOpenChange:u,revision:r,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:x,revision:r,onDelete:V,isDeleting:M})]})}exports.default=ee;
|
package/dist/plugin-DHpuZZXz.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";const a=require("lodash-es"),$=require("./fonts-D5fTqvSS.cjs"),b=require("./_commonjsHelpers-DwGv2jUC.cjs"),B={fontFamily:{"font-heading":"Arial","font-body":"Arial"},borderRadius:"10px",colors:[{group:"Body",items:{background:["#FFFFFF","#121212"],foreground:["#121212","#FFFFFF"]}},{group:"Primary",items:{primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"]}},{group:"Secondary",items:{secondary:["#F3F4F6","#374151"],"secondary-foreground":["#1F2937","#F9FAFB"]}},{group:"Border, Input & Ring",items:{border:["#E5E7EB","#374151"],input:["#E5E7EB","#374151"],ring:["#2563EB","#3B82F6"]}},{group:"Card",items:{card:["#FFFFFF","#1F2937"],"card-foreground":["#121212","#FFFFFF"]}},{group:"Popover",items:{popover:["#FFFFFF","#1F2937"],"popover-foreground":["#121212","#FFFFFF"]}},{group:"Muted",items:{muted:["#F3F4F6","#374151"],"muted-foreground":["#6B7280","#9CA3AF"]}},{group:"Accent",items:{accent:["#F3F4F6","#374151"],"accent-foreground":["#1F2937","#FFFFFF"]}},{group:"Destructive",items:{destructive:["#DC2626","#EF4444"],"destructive-foreground":["#FFFFFF","#FFFFFF"]}}]},v={fontFamily:{heading:"Arial",body:"Arial"},borderRadius:"6px",colors:{background:["#FFFFFF","#09090B"],foreground:["#09090B","#FFFFFF"],primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"],secondary:["#F4F4F5","#27272A"],"secondary-foreground":["#09090B","#FFFFFF"],muted:["#F4F4F5","#27272A"],"muted-foreground":["#71717A","#A1A1AA"],accent:["#F4F4F5","#27272A"],"accent-foreground":["#09090B","#FFFFFF"],destructive:["#EF4444","#7F1D1D"],"destructive-foreground":["#FFFFFF","#FFFFFF"],border:["#E4E4E7","#27272A"],input:["#E4E4E7","#27272A"],ring:["#2563EB","#3B82F6"],card:["#FFFFFF","#09090B"],"card-foreground":["#09090B","#FFFFFF"],popover:["#FFFFFF","#09090B"],"popover-foreground":["#09090B","#FFFFFF"]}},_=e=>({fontFamily:e.fontFamily?a.keys(e.fontFamily).reduce((r,t)=>({...r,[t.replace("font-","")]:`var(--${t})`}),{}):{},borderRadius:e.borderRadius?{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}:{},colors:e.colors?a.flatten(e.colors.map(r=>Object.entries(r.items))).reduce((r,[t])=>({...r,[t]:`hsl(var(--${t}))`}),{}):{}});function m(e){const n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=parseInt(n[1],16),t=parseInt(n[2],16),F=parseInt(n[3],16);r/=255,t/=255,F/=255;const o=Math.max(r,t,F),u=Math.min(r,t,F);let i=0,l=0;const g=(o+u)/2;if(o==u)i=l=0;else{const s=o-u;switch(l=g>.5?s/(2-o-u):s/(o+u),o){case r:i=(t-F)/s+(t<F?6:0);break;case t:i=(F-r)/s+2;break;case F:i=(r-t)/s+4;break}i/=6}return`${Math.round(i*360)} ${Math.round(l*100)}% ${Math.round(g*100)}%`}const E=e=>{const r=$.getAllRegisteredFonts().find(t=>t.family===e);return`"${e}", ${a.get(r,"fallback","")}`},A=({theme:e})=>{const n=e;return`:root {
|
|
2
|
-
${e.fontFamily?Object.entries(e.fontFamily).map(([r,t])=>`--font-${r}: ${E(t)};`).join(`
|
|
3
|
-
`):""}
|
|
4
|
-
${n.borderRadius?`--radius: ${n.borderRadius};`:""}
|
|
5
|
-
${n.colors?Object.entries(n.colors).map(([r,t])=>`--${r}: ${m(t[0])};`).join(`
|
|
6
|
-
`):""}
|
|
7
|
-
}
|
|
8
|
-
.dark {
|
|
9
|
-
${n.colors?Object.entries(n.colors).map(([r,t])=>`--${r}: ${m(t[1])};`).join(`
|
|
10
|
-
`):""}
|
|
11
|
-
}`},C=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(n=>`<link rel="stylesheet" href="${n.url}" />`).join(`
|
|
12
|
-
`),P=e=>!e||e.length===0?[]:a.uniqBy(e,"family").map(n=>n.url),j=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(n=>`@import url("${n.url}");`).join(`
|
|
13
|
-
`),q=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(n=>n.src.map(r=>`@font-face {
|
|
14
|
-
font-family: "${n.family}";
|
|
15
|
-
src: url("${r.url}") format("${r.format}");
|
|
16
|
-
font-display: swap;
|
|
17
|
-
${r.fontWeight?`font-weight: ${r.fontWeight};`:""}
|
|
18
|
-
${r.fontStyle?`font-style: ${r.fontStyle};`:""}
|
|
19
|
-
${r.fontStretch?`font-stretch: ${r.fontStretch};`:""}
|
|
20
|
-
}`).join(`
|
|
21
|
-
`)).join(`
|
|
22
|
-
`);var d={},c={},p;function T(){return p||(p=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});function n(t,F){return{handler:t,config:F}}n.withOptions=function(t,F=()=>({})){const o=function(u){return{__options:u,handler:t(u),config:F(u)}};return o.__isOptionsFunction=!0,o.__pluginFunction=t,o.__configFunction=F,o};const r=n})(c)),c}var h;function M(){return h||(h=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const n=r(T());function r(F){return F&&F.__esModule?F:{default:F}}const t=n.default})(d)),d}var f,y;function k(){if(y)return f;y=1;let e=M();return f=(e.__esModule?e:{default:e}).default,f}var R=k();const O=b.getDefaultExportFromCjs(R);exports.defaultThemeOptions=B;exports.defaultThemeValues=v;exports.getChaiThemeCssVariables=A;exports.getChaiThemeOptions=_;exports.getThemeCustomFontFace=q;exports.getThemeFontsCSSImport=j;exports.getThemeFontsLinkMarkup=C;exports.getThemeFontsUrls=P;exports.plugin=O;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),q=require("./register-chai-top-bar-DyW9GPzV.cjs"),f=require("./index-mPCp0j2h.cjs"),r=require("./index-Bzyv7mAh.cjs"),U=require("./page-manager-search-and-filter-jDoLrCB7.cjs"),F=require("@tanstack/react-query"),t=require("lodash-es"),b=require("lucide-react"),a=require("react"),M=()=>{const l=r.useApiUrl(),d=r.useFetch();return F.useQuery({queryKey:[r.ACTIONS.GET_CHANGES],queryFn:async()=>d(l,{action:r.ACTIONS.GET_CHANGES})})},G=({page:l,selectedPages:d,handleCheckboxChange:N,getPageType:y,hasSlug:h,currentOwnerId:c})=>{const x=r.useUserId(),{data:u}=r.useChaiUserInfo(c),o=c===x?null:u==null?void 0:u.name;return e.jsxs("tr",{className:"group relative border-b last:border-b-0 hover:bg-gray-50",children:[e.jsxs("td",{scope:"row",className:`flex items-center gap-x-1 whitespace-nowrap px-6 py-2 text-gray-900 dark:text-white ${o?"opacity-50":""}`,children:[o?e.jsx(b.Lock,{className:"h-4 w-4 fill-red-200 text-red-500"}):e.jsx("input",{checked:t.includes(d,l==null?void 0:l.id),onClick:p=>{p.stopPropagation(),N(l==null?void 0:l.id)},type:"checkbox",className:"cursor-pointer rounded focus:outline-none focus:ring-0"})," ",h(l.pageType)?e.jsx(b.File,{className:"h-4 w-4"}):e.jsx(b.GlobeIcon,{className:"h-4 w-4"}),e.jsx(r.Tooltip,{content:l.name,side:"top",showTooltip:l.name.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-medium text-black",children:l.name})}),l.slug&&e.jsx(r.Tooltip,{content:l.slug,side:"top",showTooltip:l.slug.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-mono text-xs text-muted-foreground",children:l.slug})})]}),e.jsx("td",{className:"px-2",children:y(l==null?void 0:l.pageType)}),e.jsx("td",{className:"px-4 text-right",children:t.first(l.changes)||""}),e.jsx(e.Fragment,{children:o&&e.jsxs("button",{className:"absolute right-0 top-0 flex h-full 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:[e.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",e.jsx("span",{className:"font-medium",children:o})," is editing this page"]})})]},l==null?void 0:l.id)},O=({onClose:l=()=>{},isPending:d,publishPage:N})=>{const y=r.useUserId(),{pageToUser:h}=r.usePageToUser(),[c,x]=a.useState([]),u=r.useFallbackLang(),[o,p]=a.useState(u),{data:T,isFetching:C}=M(),{data:m}=r.usePageTypes(),k=a.useCallback(s=>{var n;return(n=t.find(m,{key:s}))==null?void 0:n.hasSlug},[m]),j=a.useMemo(()=>t.filter(m,s=>!k(s.key)).map(s=>s.key),[k,m]),P=t.uniq(t.map(T,"lang")).filter(Boolean),i=a.useMemo(()=>t.filter(T,s=>s.pageType==="theme"?!1:o===u?s.lang===o||s.lang==="":s.lang===o),[T,o,u]),w=a.useMemo(()=>t.filter(i,s=>!j.includes(s.pageType)),[i,j]),S=a.useMemo(()=>t.filter(i,s=>j.includes(s.pageType)),[i,j]);a.useEffect(()=>{const s=t.map(t.filter(i,{online:!0}),"id");a.startTransition(()=>x(s))},[i]),a.useEffect(()=>{const s=t.filter(t.keys(h),n=>t.get(h,[n,"userId"])!==y);a.startTransition(()=>x(n=>t.filter(n,g=>!t.includes(s,g))))},[h,y]);const v=c.length===(i==null?void 0:i.length),E=s=>{x(n=>t.includes(n,s)?t.filter(n,g=>g!==s):t.concat(n,s))},B=()=>{x(v?[]:t.map(i,"id"))},I=()=>{N({ids:t.uniq(c)},{onSuccess:()=>{l(),r.throwConfetti("CENTER_CENTER"),p(u)}})},A=s=>{if(s==="theme")return"Theme";const n=t.find(m,{key:s});return n?n==null?void 0:n.name:s},L=a.useMemo(()=>{const s=[{label:"Updated",top:"pt-2"},...t.orderBy(t.filter(w,{online:!0}),"pageType"),...t.orderBy(t.filter(S,{online:!0}),"pageType")].filter(g=>g.pageType!=="theme"),n=[{label:"Offline",top:"pt-6"},...t.orderBy(t.filter(w,{online:!1}),"pageType"),...t.orderBy(t.filter(S,{online:!1}),"pageType")];return[...s,...n]},[w,S]);return e.jsxs(f.DialogContent,{className:"flex max-h-[80%] max-w-4xl flex-col",children:[e.jsxs(f.DialogHeader,{children:[e.jsx(f.DialogTitle,{children:"Publish changes"}),e.jsx(f.DialogDescription,{className:"text-xs",children:"Select the pages you want to publish. Click publish when you're done."})]}),P.length>0&&e.jsx("div",{className:"my-[2px] mt-0",children:e.jsx(U.LanguageSelector,{languages:[u,...P],selectedLanguage:o,setSelectedLanguage:p})}),e.jsx("div",{className:"no-scrollbar relative -mx-4 -mt-4 h-full max-h-full overflow-y-auto",children:C?e.jsxs("div",{className:"space-y-2 px-1",children:[e.jsx("div",{className:"mt-2 h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):e.jsxs("table",{className:"w-full text-left text-xs text-gray-500 dark:text-gray-400 rtl:text-right",children:[e.jsx("thead",{className:"sticky top-0 z-10 border-b bg-gray-50 text-gray-700 dark:bg-gray-700 dark:text-gray-400",children:e.jsxs("tr",{children:[e.jsxs("th",{scope:"col",className:"w-[1 50px] flex items-center gap-x-2 px-6 py-3",children:[e.jsx("input",{checked:v,onClick:s=>{s.stopPropagation(),B()},type:"checkbox",className:"mt-1 cursor-pointer rounded focus:outline-none focus:ring-0"}),"Name"]}),e.jsx("th",{scope:"col",className:"w-[150px] px-2 py-3",children:"Type"}),e.jsx("th",{scope:"col",className:"w-[150px] px-4 py-3 text-right",children:"Status"})]})}),e.jsx("tbody",{children:t.map(L,s=>s.label?e.jsx("tr",{children:e.jsxs("td",{colSpan:3,className:`relative px-6 py-2 text-xs font-medium text-gray-800 ${s.top}`,children:[e.jsx("div",{className:"absolute inset-0 left-6 flex items-center",children:e.jsx("div",{className:"order-gray-300 w-full"})}),e.jsx("div",{className:"relative flex justify-start",children:e.jsx("span",{className:"bg-gray-50 pr-2",children:s.label})})]})},"separator"):e.jsx(G,{page:s,selectedPages:c,handleCheckboxChange:E,getPageType:A,hasSlug:k,currentOwnerId:t.get(h,[(s==null?void 0:s.primaryPage)||(s==null?void 0:s.id),"userId"])}))})]})}),e.jsxs(f.DialogFooter,{className:"mt-10 flex items-center justify-center",children:[c.length>0&&e.jsxs("span",{className:"text-center text-sm text-muted-foreground",children:[c.length," Page",c.length!==1?"s":""," Selected"]}),e.jsx(q.Button,{disabled:d,variant:"outline",onClick:l,children:"Cancel"}),e.jsx(q.Button,{disabled:d||C||t.isEmpty(c),onClick:I,children:d?"Publishing...":"Publish Selected"})]})]})};exports.default=O;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-Bzyv7mAh.cjs"),r=require("./index-mPCp0j2h.cjs"),u=require("lodash-es"),w=require("react"),f=require("./register-chai-top-bar-DyW9GPzV.cjs"),ie=require("react-i18next"),O=require("sonner"),de=require("@tanstack/react-query"),K=require("lucide-react"),G=require("./get-seo-defaults-Cw7vFt-B.cjs"),ue=()=>{const{selectedLang:t}=r.useLanguages(),{data:p,isFetching:n}=i.useLanguagePages();return{data:w.useMemo(()=>u.find(p,{lang:t||""})||{},[p,t]),isFetching:n}},pe=()=>{var x;const p=(x=document.getElementById("canvas-iframe").contentDocument)==null?void 0:x.body.innerHTML;if(!p)return null;const d=new DOMParser().parseFromString(p,"text/html");d.querySelectorAll("style, script, link, svg, [data-block-type='PartialBlock']").forEach(h=>h.remove()),d.querySelectorAll("*").forEach(h=>{Array.from(h.attributes).forEach(g=>h.removeAttribute(g.name))});const l=d.querySelectorAll("h1, h2, h3, h4, h5, h6, p");return Array.from(l).map(h=>`<${h.tagName.toLowerCase()}>${h.innerHTML}</${h.tagName.toLowerCase()}>`).join(" ").replace(/<p>Partial block. Double click to edit.<\/p>/,"")},R=({keyword:t,onComplete:p,field:n})=>{const d=i.useFetch(),l=i.useApiUrl(),{selectedLang:N,fallbackLang:x}=r.useLanguages(),{mutate:h,isPending:g}=de.useMutation({mutationFn:async()=>{const I=pe();return await d(l,{action:i.ACTIONS.GENERATE_SEO_FIELD,data:{pageContext:"",dynamic:!1,field:n,lang:N||x,pageContent:I,keyword:t}})},onSuccess:I=>{p({fieldValue:I.field})},onError:I=>{p({fieldValue:null,error:I.message})}});return e.jsx(f.Button,{disabled:g,type:"button",className:"h-5 w-5",variant:"ghost",size:"sm",onClick:()=>h(),children:g?e.jsx(K.Loader,{className:"h-3 w-3 animate-spin text-yellow-500"}):e.jsx(K.Wand2Icon,{className:"text-yellow-500"})})},he=(t,p)=>{if(!t)return{success:!1,error:"Empty response from AI"};try{let n=t;if(typeof n=="string"&&(/^".*"$/.test(n)&&(n=n.replace(/^"(.*)"$/,"$1"),n=n.replace(/\\\\/g,"___DOUBLE_BACKSLASH___").replace(/\\n/g,`
|
|
2
|
-
`).replace(/\\"/g,'"').replace(/___DOUBLE_BACKSLASH___/g,"\\")),p==="jsonLD"||p==="metaOther")){n.includes("```")&&(n=n.replace(/^```json\s*/i,"").replace(/^```\s*/,"").replace(/\s*```$/m,"")),n=n.trim();try{JSON.parse(n)}catch{return{success:!1,error:"The AI response is not valid JSON. Please try again or edit manually."}}}return{success:!0,value:n}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},ge=({isOpen:t,onClose:p,onSave:n,onDiscard:d,isSaving:l=!1,fromLanguage:N,toLanguage:x})=>{const h=i.LANGUAGES[N]||N,g=i.LANGUAGES[x]||x;return e.jsx(r.Dialog,{open:t,onOpenChange:p,children:e.jsxs(r.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(r.DialogHeader,{children:[e.jsx(r.DialogTitle,{children:"Unsaved SEO Changes"}),e.jsxs(r.DialogDescription,{children:['You have unsaved changes in the SEO for "',h,'" version. Do you want to save these changes before switching to "',g,'" version?']})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(f.Button,{variant:"outline",onClick:d,disabled:l,children:"Discard Changes"}),e.jsx(f.Button,{onClick:n,disabled:l,children:l?"Saving...":"Save & Switch"})]})]})})},me=t=>{if(!t)return!0;try{return JSON.parse(t),!0}catch{return!1}},xe=(t,p)=>{const n=t.selectionStart||0,d=t.selectionEnd||0,l=t.value,N=l.substring(0,n),x=l.substring(d),h=`{{${p}}}`,g=N+""+h+x,I=n+0+h.length;return{value:g,newCursorPos:I}},Q=()=>{const{t}=ie.useTranslation(),[,p]=r.useSidebarActivePanel(),{data:n}=i.useChaiCurrentPage(),{data:d}=i.useBuilderPageData(),{data:l,isFetching:N}=ue(),x=l==null?void 0:l.seo,h=w.useRef(null),[g,I]=w.useState("seo"),F=n==null?void 0:n.id,Y=n==null?void 0:n.pageType,E=i.usePageType(Y),{selectedLang:M,fallbackLang:X}=r.useLanguages(),m=M||X,[H,P]=w.useState(!1),[Z,$]=w.useState(!1),[ee,q]=w.useState(!1),[b,B]=w.useState(null),[o,D]=w.useState({keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"{}",metaOther:"{}",...x}),A=w.useRef({}),{mutate:se,isPending:U}=i.useUpdatePage(),y=U||H||Z,{hasPermission:te}=r.usePermissions(),a=te(i.PAGES_PERMISSIONS.EDIT_SEO),[ne]=i.usePagesProps(),oe=u.get(ne,"flags.resetSeoToDefault",!1),W=!M||o.jsonLD!=="{}";w.useEffect(()=>{if(!N&&x&&F){const s={keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"",metaOther:"",...x};D(s),A.current[m]=s}},[N,x,m,F]),w.useEffect(()=>{const s=c=>{const{fromLang:j,toLang:J,switchHandler:v}=c.detail,_=A.current[m];(_?!u.isEqual(_,o):!1)?(B({fromLang:j,toLang:J,switchHandler:v}),q(!0)):v()};return window.addEventListener("seo-language-switch-check",s),()=>{window.removeEventListener("seo-language-switch-check",s)}},[F,o,m]);const ae=async()=>{if(!(!E||!m))try{P(!0);const s=G.getSeoDefaults(E,m),c={...o,keyword:u.get(s,"seo.keyword",""),title:u.get(s,"seo.title",""),description:u.get(s,"seo.description",""),cononicalUrl:u.get(s,"seo.canonicalUrl",""),noIndex:u.get(s,"seo.noIndex",!1),noFollow:u.get(s,"seo.noFollow",!1),ogTitle:u.get(s,"seo.ogTitle",""),ogDescription:u.get(s,"seo.ogDescription","")};D(c),O.toast.success(t("SEO fields reset to defaults"))}catch(s){O.toast.error(t("Failed to reset SEO fields")),console.error("Reset SEO error:",s)}finally{P(!1)}},re=async()=>{if(!(!E||!m))try{$(!0);const s=G.getSeoDefaults(E,m),c={...o,jsonLD:u.get(s,"seo.jsonLD","")};D(c),O.toast.success(t("JSON-LD reset to default"))}catch(s){O.toast.error(t("Failed to reset JSON-LD")),console.error("Reset JSON-LD error:",s)}finally{$(!1)}},le=async()=>{if(!(!E||!m))try{P(!0);const s=G.getSeoDefaults(E,m),c={...o,ogTitle:u.get(s,"seo.ogTitle",""),ogDescription:u.get(s,"seo.ogDescription",""),ogImage:u.get(s,"seo.ogImage",""),ogImageId:u.get(s,"seo.ogImageId",""),metaOther:u.get(s,"seo.metaOther","{}")};D(c),O.toast.success(t("Meta Tag fields reset to defaults"))}catch(s){O.toast.error(t("Failed to reset Meta Tag fields")),console.error("Reset Meta Tag error:",s)}finally{P(!1)}},z=async()=>{se({id:l==null?void 0:l.id,seo:o,primaryPage:F},{onSuccess:()=>{console.log("SEO & JSON-LD updated successfully",o),A.current[m]=o,O.toast.success("SEO & JSON-LD updated successfully")}})},L=(s,c)=>{const j=document.getElementById(c);if(j){const{value:J,newCursorPos:v}=xe(j,s);h.current={id:c,position:v},j.tagName.toLowerCase()==="input"?(j.value=J,D(k=>({...k,[j.name]:J})),j.focus(),j.setSelectionRange(v,v),[0,10,50,100,200].forEach(k=>{setTimeout(()=>{const V=document.getElementById(c);V&&(V.focus(),V.setSelectionRange(v,v))},k)})):(D(T=>({...T,[j.name]:J})),requestAnimationFrame(()=>{const T=document.getElementById(c);T&&(T.focus(),T.setSelectionRange(v,v),setTimeout(()=>{const k=document.getElementById(c);k&&(k.focus(),k.setSelectionRange(v,v))},50))}))}},S=s=>{const c={...o,[s.target.name]:s.target.name==="noIndex"||s.target.name==="noFollow"?s.target.checked:s.target.value};D(c)},C=s=>c=>{if(!u.isEmpty(c.fieldValue)){const j=he(c.fieldValue,s);j.success?S({target:{name:s,value:j.value}}):O.toast.error(e.jsxs("div",{children:[e.jsx("h2",{children:"Failed to process AI response:"}),e.jsx("p",{children:j.error})]}))}c.error&&O.toast.error(e.jsxs("div",{children:[e.jsx("h2",{children:"Failed to generate:"}),e.jsx("p",{children:c.error})]}))},ce=()=>{const s=u.get(n,"seo.jsonLD","{}");if((s==null?void 0:s.trim())==="{}"){O.toast.error("Default page JSON-LD is empty");return}S({target:{name:"jsonLD",value:s}})};return e.jsxs("div",{className:"relative flex h-full flex-col","data-panel-id":"seo",children:[!a&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center backdrop-blur-sm",children:e.jsx(f.Alert,{variant:"default",className:"w-[80%] max-w-md text-xs",children:e.jsx(f.AlertDescription,{children:t("You don't have permission to edit SEO settings. Contact your administrator for access.")})})}),e.jsxs("div",{className:"no-scrollbar flex-grow overflow-y-auto px-2 pb-20",children:[e.jsxs("div",{className:"mb-4 flex w-full items-center justify-between rounded-md bg-gray-100 px-2 py-1 text-left text-sm",children:[e.jsxs("span",{children:[e.jsx("div",{className:"font-medium",children:l==null?void 0:l.name}),e.jsx("span",{className:"font-mono text-xs leading-tight text-gray-500",children:l==null?void 0:l.slug})]}),e.jsx(i.LanguageSwitcher,{variant:"outline",showAdd:!1})]}),e.jsx("form",{className:"space-y-8",children:e.jsxs(r.Tabs,{value:g,onValueChange:I,className:"w-full",children:[e.jsxs(r.TabsList,{className:"mb-4 grid w-full grid-cols-3",children:[e.jsx(r.TabsTrigger,{value:"seo",children:t("SEO")}),e.jsx(r.TabsTrigger,{value:"opengraph",children:t("Meta Tags")}),e.jsx(r.TabsTrigger,{value:"jsonld",children:t("JSON-LD")})]}),e.jsx("div",{className:g==="seo"?"":"sr-only",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"keyword",children:t("Keyword")}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"keyword")})]}),e.jsx(f.Input,{type:"text",id:"keyword",name:"keyword",value:o.keyword,onChange:S,disabled:y||!a,placeholder:t("Enter keyword"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"title",children:t("SEO Title")}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(R,{keyword:o.keyword,onComplete:C("title"),field:"title"}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"title")})]})]}),e.jsx(f.Input,{type:"text",id:"title",name:"title",value:o.title,onChange:S,disabled:y||!a,placeholder:t("Enter SEO title"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"description",children:t("SEO Description")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{keyword:o.keyword,onComplete:C("description"),field:"description"}),a&&e.jsx(i.NestedPathSelector,{data:d??{},onSelect:s=>L(s,"description")})]})]}),e.jsx(r.Textarea,{id:"description",name:"description",rows:5,value:o.description,onChange:S,disabled:y||!a,placeholder:t("Enter SEO description"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"title",children:t("Canonical URL")}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"canonicalUrl")})]}),e.jsx(f.Input,{type:"text",id:"canonicalUrl",name:"canonicalUrl",value:o.canonicalUrl,onChange:S,disabled:y||!a,placeholder:t("Enter Canonical URL"),readOnly:!a})]}),e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(f.Input,{type:"checkbox",id:"noIndex",name:"noIndex",checked:o.noIndex,onChange:S,disabled:y||!a,className:"h-4 w-4"}),e.jsx(r.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:t("No Index")})]}),e.jsx("p",{className:"mt-0 text-[10px] font-light leading-4 text-gray-400",children:t("Check this if you don't want search engines to index this page.")})]}),e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(f.Input,{type:"checkbox",id:"noFollow",name:"noFollow",checked:o.noFollow,onChange:S,disabled:y||!a,className:"h-4 w-4"}),e.jsx(r.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:t("No Follow")})]}),e.jsx("p",{className:"text-[10px] font-light leading-4 text-gray-400",children:t("Check this if you don't want search engines to follow links on this page.")})]})]})}),e.jsx("div",{className:g==="opengraph"?"":"sr-only",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"mb-4 font-semibold text-slate-700",children:t("Open Graph")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"ogTitle",children:t("OG Title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{keyword:o.keyword,onComplete:C("ogTitle"),field:"ogTitle"}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"ogTitle")})]})]}),e.jsx(f.Input,{type:"text",id:"ogTitle",name:"ogTitle",value:o.ogTitle,onChange:S,disabled:y||!a,placeholder:t("Enter OG title"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"ogDescription",children:t("OG Description")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{keyword:o.keyword,onComplete:C("ogDescription"),field:"ogDescription"}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"ogDescription")})]})]}),e.jsx(r.Textarea,{id:"ogDescription",name:"ogDescription",rows:5,value:o.ogDescription,onChange:S,disabled:y||!a,placeholder:t("Enter OG description"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"ogImage",children:t("OG Image")}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>{D({...o,ogImage:`{{${s}}}`,ogImageId:""})}})]}),e.jsx(i.ImagePicker,{assetId:o.ogImageId,assetUrl:o.ogImage,onChange:s=>{D({...o,ogImage:s.url,ogImageId:s.id})},disabled:y||!a,placeholder:t("Select OG image"),className:"mb-2"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"metaOther",children:t("Meta Tags")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{keyword:o.keyword,onComplete:C("metaOther"),field:"metaOther"})})]}),e.jsx(i.SmartJsonInput,{id:"metaOther",value:o.metaOther,onChange:s=>{S({target:{name:"metaOther",value:s}})},placeholder:t("Enter Meta Tags JSON"),disabled:y||!a,readOnly:!a,pageData:d||{},rows:8,handleFieldInsert:L})]})]})]})})}),e.jsx("div",{className:g==="jsonld"?"":"sr-only",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"jsonLD",children:t("JSON-LD")}),W&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{keyword:o.keyword,onComplete:C("jsonLD"),field:"jsonLD"})})]}),e.jsx("div",{className:"hidden",children:JSON.stringify(d)}),e.jsx(i.SmartJsonInput,{id:"jsonLD",value:o.jsonLD,onChange:s=>{S({target:{name:"jsonLD",value:s}})},placeholder:t("Enter JSON-LD"),disabled:y||!a,readOnly:!a,pageData:d||{},rows:12,handleFieldInsert:L,hasJsonLdForSelectedLang:W,copyJsonLDFromDefaultPage:ce})]})})})]})})]}),a&&e.jsxs("div",{className:"fixed bottom-0 left-0 right-0 flex w-full flex-shrink-0 items-center justify-between border-t bg-background p-4",children:[oe?e.jsx(f.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>{g==="jsonld"?re():g==="opengraph"?le():ae()},disabled:y||!a||!E,children:t(H?"Resetting...":`Reset to ${g==="jsonld"?"Default JSON-LD":g==="opengraph"?"Default Open Graph":"Default SEO"}`)}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(f.Button,{onClick:z,disabled:!me(o==null?void 0:o.jsonLD)||(A.current[m]?u.isEqual(A.current[m],o):!1)||y||!a,children:t(U?"Saving...":"Save")}),e.jsx(f.Button,{variant:"link",className:"text-gray-500 hover:text-gray-700",onClick:()=>p("outline"),children:t("Cancel")})]})]}),e.jsx(ge,{isOpen:ee,onClose:()=>{q(!1),B(null)},onSave:async()=>{b&&(await z(),b.switchHandler(),q(!1),B(null))},onDiscard:()=>{if(b){const s=A.current[m];s&&D(s),b.switchHandler(),q(!1),B(null)}},isSaving:U,fromLanguage:(b==null?void 0:b.fromLang)||m,toLanguage:(b==null?void 0:b.toLang)||""})]})};Q.displayName="SeoPanel";exports.default=Q;
|