@chaibuilder/sdk 4.0.0-beta.7 → 4.0.0-beta.8
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/README.md +1 -3
- package/dist/{2SSKDMRQ-DDOgISWg.cjs → 2SSKDMRQ-DHv4u_0i.cjs} +1 -1
- package/dist/{2SSKDMRQ-hL7THuKW.js → 2SSKDMRQ-DewwiCoQ.js} +2 -2
- package/dist/{AP7HFJJL-BsLQ13V_.js → AP7HFJJL-ComnZw7J.js} +1 -1
- package/dist/{AP7HFJJL-tcAhVllC.cjs → AP7HFJJL-cz754qhG.cjs} +1 -1
- package/dist/{IconPicker-FLSVAZxx.js → IconPicker-2H9IGKMS.js} +2 -2
- package/dist/{IconPicker-J1KLNrSB.cjs → IconPicker-U0Z2dWeR.cjs} +1 -1
- package/dist/{WDYDFRGG-BTj8AXV6.cjs → WDYDFRGG-BfRX3M58.cjs} +1 -1
- package/dist/{WDYDFRGG-Yi0eNS2V.js → WDYDFRGG-vy7nMYD4.js} +2 -2
- package/dist/{active-in-another-tab-Dozn833d.js → active-in-another-tab-5hn17Jeq.js} +3 -3
- package/dist/{active-in-another-tab-BtAiatqq.cjs → active-in-another-tab-ijahI5qu.cjs} +1 -1
- package/dist/{add-new-language-page-DD-CAoAQ.js → add-new-language-page-DmOyPy0u.js} +4 -4
- package/dist/{add-new-language-page-9AMizlES.cjs → add-new-language-page-vmNKNx-e.cjs} +1 -1
- package/dist/{add-new-page-uZKCk9eB.js → add-new-page-NHScAQn8.js} +2 -2
- package/dist/{add-new-page-BS9vPnFG.cjs → add-new-page-XDuCkOyb.cjs} +1 -1
- package/dist/{ai-panel-content-PovaKJaj.cjs → ai-panel-content-BDqW16AW.cjs} +1 -1
- package/dist/{ai-panel-content-CK4XOkEh.js → ai-panel-content-CHJ0JcQI.js} +4 -4
- package/dist/{ai-panel-default-lang-BtLjUl9d.js → ai-panel-default-lang-BIomgsN0.js} +4 -4
- package/dist/{ai-panel-default-lang-B37k5ADH.cjs → ai-panel-default-lang-HeYWpbMu.cjs} +2 -2
- package/dist/{ai-panel-other-lang-CdQmASqv.cjs → ai-panel-other-lang-BMelEs3p.cjs} +1 -1
- package/dist/{ai-panel-other-lang-Dp1MNaLi.js → ai-panel-other-lang-CbAgG-qX.js} +3 -3
- package/dist/{ai-prompt-input-BT-mEdTX.js → ai-prompt-input-BH8LOVT4.js} +2 -2
- package/dist/{ai-prompt-input-Dtym4w8J.cjs → ai-prompt-input-C_GG6nwq.cjs} +1 -1
- package/dist/{ai-translation-prompt-B-lH7emI.cjs → ai-translation-prompt-CkHaFv5I.cjs} +1 -1
- package/dist/{ai-translation-prompt-B17GK1QR.js → ai-translation-prompt-DxsNw8YR.js} +2 -2
- package/dist/{code-display-DloSPyPr.cjs → code-display-9Onx6RCq.cjs} +1 -1
- package/dist/{code-display-Ck81Id9K.js → code-display-oa1j0ri7.js} +1 -1
- package/dist/{code-editor-EZT2pMsU.js → code-editor-CGBAc-A6.js} +1 -1
- package/dist/{code-editor-CUeNiMzA.cjs → code-editor-GV8ibQ4h.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-DMZOc36k.cjs → continue-editing-in-this-client-DKHP0pq8.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-CS7C6h9Q.js → continue-editing-in-this-client-Da8ab_9d.js} +3 -3
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +1 -90
- package/dist/core.js +22 -34
- package/dist/css-import-modal-B4j26_cO.cjs +13 -0
- package/dist/{css-import-modal-s7t5gZQo.js → css-import-modal-CcZVLsF9.js} +5 -4
- package/dist/{delete-design-token-Mbw_6sYI.cjs → delete-design-token-3-WwqXMO.cjs} +1 -1
- package/dist/{delete-design-token-C1smbx4E.js → delete-design-token-DzINIVtO.js} +1 -1
- package/dist/{delete-page-B7J3t0FN.cjs → delete-page-B7ODELqM.cjs} +1 -1
- package/dist/{delete-page-2GfBi8Iv.js → delete-page-DwZDMwfI.js} +3 -3
- package/dist/{design-token-usage-DyO3xM-F.js → design-token-usage-DQf180Lg.js} +2 -2
- package/dist/{design-token-usage-BoGOULG8.cjs → design-token-usage-Dy08kcIc.cjs} +1 -1
- package/dist/{digital-asset-manager-DDk2ucTE.cjs → digital-asset-manager-C7subULa.cjs} +1 -1
- package/dist/{digital-asset-manager-Cz3Nlrzl.js → digital-asset-manager-CDy9kHZO.js} +4 -4
- package/dist/{duplicate-page-Dw3U4wTT.cjs → duplicate-page-CWQ9aMd9.cjs} +1 -1
- package/dist/{duplicate-page-BwAY4Ssm.js → duplicate-page-DTnSztlr.js} +4 -4
- package/dist/{dynamic-page-selector-CvBFyX2F.cjs → dynamic-page-selector-DJuxLcsM.cjs} +1 -1
- package/dist/{dynamic-page-selector-sViJuQlU.js → dynamic-page-selector-DYW3ov_u.js} +3 -3
- package/dist/{image-editor-AIsccrqC.cjs → image-editor-C4H3AkZK.cjs} +1 -1
- package/dist/{image-editor-BgGQuESa.js → image-editor-DLeSST0K.js} +1 -1
- package/dist/{index-RYr8kQdI.js → index-BK0xWO1z.js} +5132 -5602
- package/dist/{index-BwH1mRm_.cjs → index-BRJCj7c_.cjs} +2 -2
- package/dist/index-Bm8iS2OH.cjs +160 -0
- package/dist/{index-B7eWP_hB.js → index-D5d4QDq7.js} +19 -21
- package/dist/{json-diff-viewer-Svw-kbhe.js → json-diff-viewer-BYHieVod.js} +3 -3
- package/dist/{json-diff-viewer-B2A78udz.cjs → json-diff-viewer-g6SY62bl.cjs} +1 -1
- package/dist/{lang-panel-Bnc-9wkM.js → lang-panel-BG1GMn-1.js} +4 -4
- package/dist/{lang-panel-AmEkoWid.cjs → lang-panel-Dm1eOO2J.cjs} +1 -1
- package/dist/{manage-design-tokens-BBkh1t4w.js → manage-design-tokens-BdWQUHhw.js} +3 -3
- package/dist/{manage-design-tokens-B2fG80bi.cjs → manage-design-tokens-XWs_B6jo.cjs} +1 -1
- package/dist/{mark-as-template-0CPzZnk-.js → mark-as-template-D2XxagVO.js} +3 -3
- package/dist/{mark-as-template-CE6tRoQy.cjs → mark-as-template-DUFnfVM3.cjs} +1 -1
- package/dist/{nested-path-selector-content-SmfjElr-.cjs → nested-path-selector-content-CQOx2L9C.cjs} +1 -1
- package/dist/{nested-path-selector-content-kGznHufl.js → nested-path-selector-content-Wd6-Eql0.js} +2 -2
- package/dist/{no-language-page-content-DXsAPDZd.js → no-language-page-content-BOv6TZIk.js} +3 -3
- package/dist/{no-language-page-content-B4bQLc4K.cjs → no-language-page-content-C11uF6hs.cjs} +1 -1
- package/dist/{no-language-page-dialog-BC8NHzK2.cjs → no-language-page-dialog-CY5XhXsC.cjs} +1 -1
- package/dist/{no-language-page-dialog-BpPqmw9a.js → no-language-page-dialog-DIXyKRJq.js} +2 -2
- package/dist/{page-creator-Bazn6yH4.js → page-creator-WX9lMrJY.js} +4 -4
- package/dist/{page-creator-82qTbBj4.cjs → page-creator-zSUFF4eT.cjs} +1 -1
- package/dist/{page-lock-CRFyqKZE.js → page-lock-D9miLZjm.js} +2 -2
- package/dist/{page-lock-D2iFZDUK.cjs → page-lock-DGhR_url.cjs} +1 -1
- package/dist/{page-locked-dialog-GKfQEOmk.js → page-locked-dialog-CNCUCcvH.js} +3 -3
- package/dist/{page-locked-dialog-xLqvKzax.cjs → page-locked-dialog-DTLnbfuP.cjs} +1 -1
- package/dist/{page-manager-new-DItY2hjd.js → page-manager-new-BFFOLh-l.js} +4 -4
- package/dist/{page-manager-new-Bn2QKjbf.cjs → page-manager-new-Dd2c-Q_O.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-Dc4ky-qV.cjs → page-manager-search-and-filter-BKdQUJ2W.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-CPa8IXdd.js → page-manager-search-and-filter-C1IWF_4d.js} +3 -3
- package/dist/page-revisions-content-D0cflnj1.cjs +1 -0
- package/dist/{page-revisions-content-CH-PZK0O.js → page-revisions-content-DHapiLck.js} +75 -67
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +2 -1
- package/dist/pages.js +1 -1
- package/dist/{publish-pages-content-CSJCFElu.js → publish-pages-content-Bd2zJHtK.js} +4 -4
- package/dist/{publish-pages-content-BzJDObqr.cjs → publish-pages-content-BqLcnKry.cjs} +1 -1
- package/dist/{register-chai-top-bar-ESJHs5s-.js → register-chai-top-bar-CX_JkRJn.js} +78 -78
- package/dist/register-chai-top-bar-DWTuRU53.cjs +1 -0
- package/dist/render.d.ts +2 -1
- package/dist/{rte-widget-modal-BfXcA7OP.cjs → rte-widget-modal-DiB5BjH1.cjs} +1 -1
- package/dist/{rte-widget-modal-5T81P_hg.js → rte-widget-modal-RS8PMKOn.js} +7 -7
- package/dist/runtime-client.cjs +1 -0
- package/dist/runtime-client.d.ts +158 -0
- package/dist/runtime-client.js +32 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +1 -163
- package/dist/runtime.js +71 -72
- package/dist/{save-to-lib-MtWKSVeN.js → save-to-lib--6ZXHEbC.js} +3 -3
- package/dist/{save-to-lib-DGAdSa-0.cjs → save-to-lib-BXJvaC1N.cjs} +1 -1
- package/dist/{selected-block-display-DLt_nMn9.cjs → selected-block-display-BfpJda4h.cjs} +1 -1
- package/dist/{selected-block-display-CB1-hVR5.js → selected-block-display-CUnCqXQw.js} +3 -3
- package/dist/{seo-panel-CRzzw4FW.js → seo-panel-Bs-FcY1A.js} +3 -3
- package/dist/{seo-panel-_kGXE9MC.cjs → seo-panel-CQITMfZ6.cjs} +1 -1
- package/dist/{shared-json-ld-CXukkDeS.js → shared-json-ld-7EujD341.js} +3 -3
- package/dist/{shared-json-ld-DoRgzDPC.cjs → shared-json-ld-DDXXi-Mj.cjs} +1 -1
- package/dist/{slug-input-Dp187Tiy.cjs → slug-input-CsVJAr7r.cjs} +1 -1
- package/dist/{slug-input-CeEQ0zyv.js → slug-input-DoEIq5rs.js} +2 -2
- package/dist/{take-over-request-C9J3_rev.js → take-over-request-C14kJ356.js} +3 -3
- package/dist/{take-over-request-CXuakFBm.cjs → take-over-request-D5Oo3MPo.cjs} +1 -1
- package/dist/{theme-panel-footer-DvwsyHNQ.js → theme-panel-footer-Dvknelm8.js} +3 -3
- package/dist/{theme-panel-footer-CWZ0qs13.cjs → theme-panel-footer-Eeibz2JA.cjs} +1 -1
- package/dist/{translation-warning-modal-DEt_ExQp.cjs → translation-warning-modal-CPzdHzqq.cjs} +1 -1
- package/dist/{translation-warning-modal-_aBp5ZZQ.js → translation-warning-modal-YlzP2XoO.js} +2 -2
- package/dist/{unmark-as-template-BYL5naYx.cjs → unmark-as-template-BGDwuCnv.cjs} +1 -1
- package/dist/{unmark-as-template-JN-cDUV_.js → unmark-as-template-CPJvQk7L.js} +3 -3
- package/dist/{unpublish-page-B06iZEIO.cjs → unpublish-page-BMowW5wT.cjs} +1 -1
- package/dist/{unpublish-page-DqwBY2yI.js → unpublish-page-DlFHLlmI.js} +3 -3
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +43 -43
- package/dist/{web-preview-h39D3TUh.js → web-preview-BUnv3jIc.js} +2 -2
- package/dist/{web-preview-wRgRY3Tv.cjs → web-preview-D8GQHCjs.cjs} +1 -1
- package/package.json +8 -7
- package/dist/css-import-modal-kHB0ramf.cjs +0 -13
- package/dist/index-B-rSiAp_.cjs +0 -1
- package/dist/index-Dxfyt4d4.js +0 -39
- package/dist/index-xYnNKovy.cjs +0 -160
- package/dist/page-revisions-content-CcLFI4YK.cjs +0 -1
- package/dist/register-chai-top-bar-BqwKw4uy.cjs +0 -1
|
@@ -4,8 +4,8 @@ var zn = (e) => {
|
|
|
4
4
|
var Wn = (e, t, n) => t.has(e) || zn("Cannot " + n);
|
|
5
5
|
var A = (e, t, n) => (Wn(e, t, "read from private field"), n ? n.call(e) : t.get(e)), O = (e, t, n) => t.has(e) ? zn("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), C = (e, t, n, s) => (Wn(e, t, "write to private field"), s ? s.call(e, n) : t.set(e, n), n);
|
|
6
6
|
import { jsxs as m, jsx as c, Fragment as he } from "react/jsx-runtime";
|
|
7
|
-
import { n as Pe, aj as Ur, ai as _s, r as Ln, s as Cn, t as Gn, v as ce, Q as Re, w as en, x as tn, y as nn, aB as Ps, aC as ws, a9 as Mr, aa as Br, aD as Fr, aE as Kr, ar as vs, aF as Vr, ab as Dt, D as Is, aG as Hr, aH as qr, aw as $r, av as Qr, ax as zr, E as Wr, F as jr, G as Yr, H as Jr, I as Zr, J as Xr, K as ea, M as ta, O as na, aI as sa, a6 as ra, a7 as aa, d as ia, e as oa, f as la, as as ca, at as ua, au as cn, aJ as un, T as jn } from "./index-
|
|
8
|
-
import { B as M, h as da, j as fa, v as kt, e as Yn, m as ha, q as ga, x as ma, D as Ea, F as pa } from "./register-chai-top-bar-
|
|
7
|
+
import { n as Pe, aj as Ur, ai as _s, r as Ln, s as Cn, t as Gn, v as ce, Q as Re, w as en, x as tn, y as nn, aB as Ps, aC as ws, a9 as Mr, aa as Br, aD as Fr, aE as Kr, ar as vs, aF as Vr, ab as Dt, D as Is, aG as Hr, aH as qr, aw as $r, av as Qr, ax as zr, E as Wr, F as jr, G as Yr, H as Jr, I as Zr, J as Xr, K as ea, M as ta, O as na, aI as sa, a6 as ra, a7 as aa, d as ia, e as oa, f as la, as as ca, at as ua, au as cn, aJ as un, T as jn } from "./index-BK0xWO1z.js";
|
|
8
|
+
import { B as M, h as da, j as fa, v as kt, e as Yn, m as ha, q as ga, x as ma, D as Ea, F as pa } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
9
9
|
import { atom as Ee, useAtom as pe, useSetAtom as On, useAtomValue as ya } from "jotai";
|
|
10
10
|
import { get as H, noop as xn, reverse as Aa, sortBy as Ta, find as ie, minBy as bs, values as Ns, first as Ls, groupBy as Sa, keyBy as _a, map as qt, isEmpty as fe, compact as Cs, each as Pa, upperCase as Jn, filter as Gs, includes as wa, has as sn, pickBy as va, pick as Dn, endsWith as Ia, keys as ba, isArray as Na, startCase as La, isFunction as Ca, cloneDeep as Ga, isEqual as Zn } from "lodash-es";
|
|
11
11
|
import * as $ from "react";
|
|
@@ -573,7 +573,7 @@ function Ks(e, t, n = !1) {
|
|
|
573
573
|
const s = e.toString() ? `?${e.toString()}` : "/";
|
|
574
574
|
n ? window.history.replaceState(null, "", s) : window.history.pushState({}, "", s), t(e), window.dispatchEvent(new PopStateEvent("popstate"));
|
|
575
575
|
}
|
|
576
|
-
const Di = V(() => import("./page-manager-new-
|
|
576
|
+
const Di = V(() => import("./page-manager-new-BFFOLh-l.js")), Vs = ({ children: e }) => {
|
|
577
577
|
const { t } = we(), [n, s] = ve(), r = n.get("page"), { data: a, isFetching: i } = oe(), { data: o, isFetching: l } = Fs(), [f, d] = K(!1), [u, g] = K(!0), { savePage: h } = Re(), p = !!r && !fe(a), { isLocked: T } = ye(), S = q(() => {
|
|
578
578
|
if (!o || l) return !1;
|
|
579
579
|
const v = o.find((U) => U.slug === "/");
|
|
@@ -621,7 +621,7 @@ const Di = V(() => import("./page-manager-new-DItY2hjd.js")), Vs = ({ children:
|
|
|
621
621
|
}
|
|
622
622
|
) })
|
|
623
623
|
] });
|
|
624
|
-
}, ki = V(() => import("./add-new-page-
|
|
624
|
+
}, ki = V(() => import("./add-new-page-NHScAQn8.js")), Ri = V(() => import("./delete-page-DwZDMwfI.js")), Ui = V(() => import("./duplicate-page-DTnSztlr.js")), Mi = V(() => import("./mark-as-template-D2XxagVO.js")), Bi = V(() => import("./unmark-as-template-CPJvQk7L.js")), Fi = V(() => import("./unpublish-page-DlFHLlmI.js")), Ki = () => {
|
|
625
625
|
const [e, t] = K(null), [n, s] = K(null), [r, a] = K(null), [i, o] = K(null), [l, f] = K(null), [d, u] = K(null), { data: g, isFetching: h } = Le(), { selectedLang: p, fallbackLang: T } = Pe(), { data: S } = Me(), x = S == null ? void 0 : S.find((N) => N.lang === p), { isLocked: y } = ye(), w = !(g != null && g.slug), v = On(zt);
|
|
626
626
|
if (!g) return null;
|
|
627
627
|
const U = (N) => {
|
|
@@ -890,7 +890,7 @@ const Di = V(() => import("./page-manager-new-DItY2hjd.js")), Vs = ({ children:
|
|
|
890
890
|
yo: "Yoruba",
|
|
891
891
|
za: "Zhuang, Chuang",
|
|
892
892
|
zu: "Zulu"
|
|
893
|
-
}, Hi = V(() => import("./add-new-language-page-
|
|
893
|
+
}, Hi = V(() => import("./add-new-language-page-DmOyPy0u.js")), qi = () => {
|
|
894
894
|
const e = ge("topLeftCorner", null);
|
|
895
895
|
return e ? /* @__PURE__ */ c("div", { className: "max-h-9 w-full overflow-hidden pr-2", children: Oa.createElement(e, {}) }) : null;
|
|
896
896
|
}, $i = ({
|
|
@@ -1033,7 +1033,7 @@ function zi() {
|
|
|
1033
1033
|
/* @__PURE__ */ c(Dt, { className: "h-8 w-8 rounded-full" })
|
|
1034
1034
|
] }, t)) });
|
|
1035
1035
|
}
|
|
1036
|
-
const Wi = $.lazy(() => import("./page-revisions-content-
|
|
1036
|
+
const Wi = $.lazy(() => import("./page-revisions-content-DHapiLck.js"));
|
|
1037
1037
|
function ji() {
|
|
1038
1038
|
const [e, t] = $.useState(!1);
|
|
1039
1039
|
return /* @__PURE__ */ c(vs, { children: /* @__PURE__ */ m(en, { delayDuration: 0, children: [
|
|
@@ -1244,7 +1244,7 @@ const fn = ({
|
|
|
1244
1244
|
R.error("Failed to change slug");
|
|
1245
1245
|
}
|
|
1246
1246
|
});
|
|
1247
|
-
}, Ji = V(() => import("./publish-pages-content-
|
|
1247
|
+
}, Ji = V(() => import("./publish-pages-content-Bd2zJHtK.js"));
|
|
1248
1248
|
function Zi({
|
|
1249
1249
|
showModal: e = !1,
|
|
1250
1250
|
onClose: t = () => console.log("Cancelled")
|
|
@@ -1297,8 +1297,8 @@ function Fn({
|
|
|
1297
1297
|
/* @__PURE__ */ c(nn, { side: n, sideOffset: 10, children: /* @__PURE__ */ c("p", { children: t }) })
|
|
1298
1298
|
] }) }) : e;
|
|
1299
1299
|
}
|
|
1300
|
-
const so = V(() => import("./unpublish-page-
|
|
1301
|
-
() => import("./translation-warning-modal-
|
|
1300
|
+
const so = V(() => import("./unpublish-page-DlFHLlmI.js")), ro = V(
|
|
1301
|
+
() => import("./translation-warning-modal-YlzP2XoO.js")
|
|
1302
1302
|
), ao = () => {
|
|
1303
1303
|
const { t: e } = we(), { selectedLang: t, fallbackLang: n } = Pe(), s = ge("getPreviewUrl", async (g) => g), [r, a] = K(""), { data: i } = oe(), { data: o } = Me(), { data: l } = Ce(), f = q(
|
|
1304
1304
|
() => {
|
|
@@ -1498,7 +1498,7 @@ function co() {
|
|
|
1498
1498
|
/* @__PURE__ */ c(fn, { permission: le.PUBLISH_PAGE, children: /* @__PURE__ */ c(lo, {}) })
|
|
1499
1499
|
] });
|
|
1500
1500
|
}
|
|
1501
|
-
const uo = V(() => import("./dynamic-page-selector-
|
|
1501
|
+
const uo = V(() => import("./dynamic-page-selector-DYW3ov_u.js")), fo = () => {
|
|
1502
1502
|
const { dynamicPage: e, allLangPages: t, isFetching: n } = gi(), s = t.length > 0;
|
|
1503
1503
|
return n ? null : /* @__PURE__ */ m("div", { className: "relative", children: [
|
|
1504
1504
|
!e && /* @__PURE__ */ c(Vi, { hasDynamicPage: s }),
|
|
@@ -1843,7 +1843,7 @@ const uo = V(() => import("./dynamic-page-selector-sViJuQlU.js")), fo = () => {
|
|
|
1843
1843
|
[n, t]
|
|
1844
1844
|
)
|
|
1845
1845
|
};
|
|
1846
|
-
}, Io = V(() => import("./ai-panel-content-
|
|
1846
|
+
}, Io = V(() => import("./ai-panel-content-CHJ0JcQI.js")), Qs = "chai-chat-panel", bo = ({ className: e = "h-full w-full" }) => /* @__PURE__ */ m("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", version: "1.1", className: e, children: [
|
|
1847
1847
|
/* @__PURE__ */ c("title", { children: "ai" }),
|
|
1848
1848
|
/* @__PURE__ */ c("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ c("g", { id: "icon", fill: "currentColor", transform: "translate(64.000000, 64.000000)", children: /* @__PURE__ */ c(
|
|
1849
1849
|
"path",
|
|
@@ -1858,7 +1858,7 @@ const uo = V(() => import("./dynamic-page-selector-sViJuQlU.js")), fo = () => {
|
|
|
1858
1858
|
button: No,
|
|
1859
1859
|
panel: Io,
|
|
1860
1860
|
position: "top"
|
|
1861
|
-
}, Co = V(() => import("./lang-panel-
|
|
1861
|
+
}, Co = V(() => import("./lang-panel-BG1GMn-1.js")), Go = ({ isActive: e, show: t }) => {
|
|
1862
1862
|
const { data: n } = Be();
|
|
1863
1863
|
return !sn(n, "languages") || !H(n, "languages", []).length ? null : /* @__PURE__ */ c(M, { size: "sm", onClick: t, variant: e ? "default" : "ghost", children: /* @__PURE__ */ c(Ya, { className: "h-4 w-4" }) });
|
|
1864
1864
|
}, zs = "lang", Oo = {
|
|
@@ -1869,7 +1869,7 @@ const uo = V(() => import("./dynamic-page-selector-sViJuQlU.js")), fo = () => {
|
|
|
1869
1869
|
button: Go,
|
|
1870
1870
|
view: "modal",
|
|
1871
1871
|
width: 400
|
|
1872
|
-
}, xo = V(() => import("./seo-panel-
|
|
1872
|
+
}, xo = V(() => import("./seo-panel-Bs-FcY1A.js")), Ws = "seo", Do = ({ isActive: e, show: t }) => {
|
|
1873
1873
|
const { data: n } = oe(), s = Ai(n == null ? void 0 : n.pageType);
|
|
1874
1874
|
return !sn(s, "hasSlug") || !s.hasSlug ? null : /* @__PURE__ */ c(M, { size: "icon", className: "my-1 p-0", onClick: t, variant: e ? "default" : "ghost", children: /* @__PURE__ */ m(
|
|
1875
1875
|
"svg",
|
|
@@ -3775,7 +3775,7 @@ var ku = (e, t = !1) => {
|
|
|
3775
3775
|
const t = fr(() => {
|
|
3776
3776
|
const n = this, [s] = A(this, Qe), [r] = A(this, ze), [a] = A(this, We), [i] = A(this, je), [o] = A(this, _t), [l] = A(this, qe), [f] = A(this, Je);
|
|
3777
3777
|
let d;
|
|
3778
|
-
return A(this, Ye) ? d = A(this, Ye) : (d = ur(() => import("./WDYDFRGG-
|
|
3778
|
+
return A(this, Ye) ? d = A(this, Ye) : (d = ur(() => import("./WDYDFRGG-vy7nMYD4.js")), C(this, Ye, d)), Gr(A(this, St), A(this, $e)), lr(d, cr({
|
|
3779
3779
|
get queryFlavor() {
|
|
3780
3780
|
return A(n, At);
|
|
3781
3781
|
},
|
|
@@ -3882,7 +3882,7 @@ var ku = (e, t = !1) => {
|
|
|
3882
3882
|
const t = fr(() => {
|
|
3883
3883
|
const n = this, [s] = A(this, et), [r] = A(this, tt), [a] = A(this, nt), [i] = A(this, st), [o] = A(this, Nt), [l] = A(this, Ze), [f] = A(this, rt), [d] = A(this, it);
|
|
3884
3884
|
let u;
|
|
3885
|
-
return A(this, at) ? u = A(this, at) : (u = ur(() => import("./2SSKDMRQ-
|
|
3885
|
+
return A(this, at) ? u = A(this, at) : (u = ur(() => import("./2SSKDMRQ-DewwiCoQ.js")), C(this, at, u)), Gr(A(this, bt), A(this, Xe)), lr(u, cr({
|
|
3886
3886
|
get queryFlavor() {
|
|
3887
3887
|
return A(n, vt);
|
|
3888
3888
|
},
|
|
@@ -4091,9 +4091,7 @@ const dc = Ee(""), fc = () => {
|
|
|
4091
4091
|
queryFn: async () => e ? t(n, { action: "GET_SITE_WIDE_USAGE" }) : {},
|
|
4092
4092
|
retry: !1
|
|
4093
4093
|
});
|
|
4094
|
-
}, Ac = V(() => import("./page-lock-
|
|
4095
|
-
() => import("./no-language-page-dialog-BpPqmw9a.js")
|
|
4096
|
-
), Sc = V(() => import("./digital-asset-manager-Cz3Nlrzl.js")), _c = V(() => import("./save-to-lib-MtWKSVeN.js")), Pc = V(() => import("./theme-panel-footer-DvwsyHNQ.js")), wc = V(() => import("./web-preview-h39D3TUh.js"));
|
|
4094
|
+
}, Ac = V(() => import("./page-lock-D9miLZjm.js")), Tc = V(() => import("./no-language-page-dialog-DIXyKRJq.js")), Sc = V(() => import("./digital-asset-manager-CDy9kHZO.js")), _c = V(() => import("./save-to-lib--6ZXHEbC.js")), Pc = V(() => import("./theme-panel-footer-Dvknelm8.js")), wc = V(() => import("./web-preview-BUnv3jIc.js"));
|
|
4097
4095
|
fc();
|
|
4098
4096
|
oi();
|
|
4099
4097
|
ma(go);
|
|
@@ -4212,7 +4210,7 @@ const vc = {
|
|
|
4212
4210
|
/* @__PURE__ */ c(ys, { ...e }),
|
|
4213
4211
|
/* @__PURE__ */ c(ps, {})
|
|
4214
4212
|
] }) : /* @__PURE__ */ c("div", {});
|
|
4215
|
-
}, bc = $.lazy(() => import("./nested-path-selector-content-
|
|
4213
|
+
}, bc = $.lazy(() => import("./nested-path-selector-content-Wd6-Eql0.js"));
|
|
4216
4214
|
function Nc({ data: e, onSelect: t, dataType: n = "value", disabled: s = !1 }) {
|
|
4217
4215
|
const [r, a] = $.useState(!1);
|
|
4218
4216
|
return /* @__PURE__ */ m(ra, { open: r, onOpenChange: a, children: [
|
|
@@ -4287,7 +4285,7 @@ const Ku = () => {
|
|
|
4287
4285
|
console.error("Failed to update metadata");
|
|
4288
4286
|
}
|
|
4289
4287
|
});
|
|
4290
|
-
}, Lc = V(() => import("./digital-asset-manager-
|
|
4288
|
+
}, Lc = V(() => import("./digital-asset-manager-CDy9kHZO.js")), qu = ({
|
|
4291
4289
|
assetId: e,
|
|
4292
4290
|
assetUrl: t,
|
|
4293
4291
|
onChange: n,
|
|
@@ -4430,7 +4428,7 @@ const Ku = () => {
|
|
|
4430
4428
|
n = n.replace(r[0], i);
|
|
4431
4429
|
}
|
|
4432
4430
|
return n;
|
|
4433
|
-
}, xc = V(() => import("./shared-json-ld-
|
|
4431
|
+
}, xc = V(() => import("./shared-json-ld-7EujD341.js")), $u = ({
|
|
4434
4432
|
value: e,
|
|
4435
4433
|
onChange: t,
|
|
4436
4434
|
disabled: n = !1,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as e, jsxs as h } from "react/jsx-runtime";
|
|
2
|
-
import { D as V, d as _, e as q, f as G, af as $, a2 as I, ag as P } from "./index-
|
|
3
|
-
import { B as z } from "./register-chai-top-bar-
|
|
2
|
+
import { D as V, d as _, e as q, f as G, af as $, a2 as I, ag as P } from "./index-BK0xWO1z.js";
|
|
3
|
+
import { B as z } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
4
4
|
import { formatDate as Q } from "date-fns";
|
|
5
5
|
import { startsWith as T, replace as W, isString as X, trim as Y, isArray as Z, map as ee, isPlainObject as te, mapValues as re } from "lodash-es";
|
|
6
6
|
import { FileJson as B, Loader as ne, Check as F, Copy as H } from "lucide-react";
|
|
7
7
|
import { useState as D, useMemo as A } from "react";
|
|
8
8
|
import { parseDiff as se, Diff as le, Hunk as ae } from "react-diff-view";
|
|
9
|
-
import { ar as ie, as as oe, A as ce, ap as de } from "./index-
|
|
9
|
+
import { ar as ie, as as oe, A as ce, ap as de } from "./index-D5d4QDq7.js";
|
|
10
10
|
import { useQuery as fe } from "@tanstack/react-query";
|
|
11
11
|
function me(t, n) {
|
|
12
12
|
const o = ie(), s = oe(), u = T(t.uid, "draft:") || T(n.uid, "live:");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("./index-Bm8iS2OH.cjs"),L=require("./register-chai-top-bar-DWTuRU53.cjs"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-BRJCj7c_.cjs"),H=require("@tanstack/react-query");function K(t,r){const o=O.useApiUrl(),n=O.useFetch(),f=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return H.useQuery({queryKey:["revision-comparison",t.uid,r.uid],queryFn:async()=>{if(!t.uid||!r.uid)throw new Error("Both revision IDs are required for comparison");const l=u=>u==="draft"||u==="live"?u:"revision",s=u=>p.replace(u.uid,`${u.label}:`,"");return await n(o,{action:O.ACTIONS.GET_COMPARE_DATA,data:{versions:{version1:{type:l(t.label),id:s(t)},version2:{type:l(r.label),id:s(r)}}}})},enabled:!!t.uid&&!!r.uid,staleTime:f?0:1/0})}const V=({version:t})=>{const r=t==null?void 0:t.item,{data:o}=O.useChaiUserInfo(r==null?void 0:r.currentEditor),n=t.label==="live",f=t.label==="draft";return e.jsxs("span",{className:`flex items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":f?"border-amber-500/30":"border-purple-500/30"}`,children:[e.jsx("div",{className:"h-full items-center rounded px-1.5 py-0.5 font-medium capitalize"+(n?" bg-green-500 text-green-50":f?" bg-amber-500 text-amber-50":" bg-purple-500 text-purple-50"),children:t.label}),e.jsxs("div",{className:"py-1 text-xs font-light leading-none text-gray-800",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-light opacity-90",children:f?"Currently editing":"Published by"}),!f&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),e.jsx("div",{className:"text-[10px] leading-tight",children:z.formatDate(r.createdAt,"dd MMM yyyy, h:mm a")})]})]})},F=({version:t})=>e.jsx(V,{version:t});function U(t,r,o="data.json"){const n=JSON.stringify(t,null,2),f=JSON.stringify(r,null,2),l=n.split(`
|
|
2
2
|
`),s=f.split(`
|
|
3
3
|
`);let d=`--- a/${o}
|
|
4
4
|
`;d+=`+++ b/${o}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as s, Fragment as M } from "react/jsx-runtime";
|
|
2
|
-
import { D as j, z as F, B as A } from "./register-chai-top-bar-
|
|
3
|
-
import { D as B, d as H, e as O, f as W, p as q, L as R, q as J, n as K, r as Q, s as V, t as X, v as w } from "./index-
|
|
4
|
-
import { au as Y, m as T, L as I, av as Z, l as ee, aw as se, j as ae, ax as f, ay as o } from "./index-
|
|
2
|
+
import { D as j, z as F, B as A } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
+
import { D as B, d as H, e as O, f as W, p as q, L as R, q as J, n as K, r as Q, s as V, t as X, v as w } from "./index-BK0xWO1z.js";
|
|
4
|
+
import { au as Y, m as T, L as I, av as Z, l as ee, aw as se, j as ae, ax as f, ay as o } from "./index-D5d4QDq7.js";
|
|
5
5
|
import { find as G, startsWith as E, isEqual as ne, filter as te, get as D, map as le, isEmpty as ie } from "lodash-es";
|
|
6
6
|
import { AlertCircle as re, StarIcon as ce, MoreHorizontal as oe, PencilIcon as de, Power as me, TrashIcon as ue } from "lucide-react";
|
|
7
7
|
import { useState as S, useMemo as he, Suspense as L, lazy as z } from "react";
|
|
@@ -81,7 +81,7 @@ const fe = ({ page: a, onClose: g }) => {
|
|
|
81
81
|
/* @__PURE__ */ e(J, { children: /* @__PURE__ */ e(A, { type: "submit", disabled: y || !E(i, `/${d}`) || ne(a == null ? void 0 : a.slug, i), children: l(y ? "Changing..." : "Change Slug") }) })
|
|
82
82
|
] })
|
|
83
83
|
] }) });
|
|
84
|
-
}, Ne = z(() => import("./delete-page-
|
|
84
|
+
}, Ne = z(() => import("./delete-page-DwZDMwfI.js")), ye = z(() => import("./unpublish-page-DlFHLlmI.js")), ke = () => {
|
|
85
85
|
const { t: a } = U(), g = pe(Z), { selectedLang: l, fallbackLang: i, setSelectedLang: v } = K(), { data: N, isFetching: y } = ee(), { data: t } = se(), { data: r } = T(), x = he(() => {
|
|
86
86
|
const n = r == null ? void 0 : r.find((h) => h.key === (t == null ? void 0 : t.pageType));
|
|
87
87
|
return t != null && t.dynamic ? n == null ? void 0 : n.dynamicSlug : "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-DWTuRU53.cjs"),a=require("./index-Bm8iS2OH.cjs"),n=require("./index-BRJCj7c_.cjs"),r=require("lodash-es"),j=require("lucide-react"),c=require("react"),I=require("react-i18next"),L=require("sonner"),k=require("jotai"),M=({page:s,onClose:p})=>{const{t:l}=I.useTranslation(),[o,P]=c.useState(s.slug||""),{mutate:y,isPending:f}=n.useChangeSlug(),{data:i}=n.usePageTypes(),d=r.find(i,{key:s==null?void 0:s.pageType}),E=h=>{if(h.preventDefault(),!(s!=null&&s.primaryPage)&&Object.keys(n.LANGUAGES).some(S=>o===`/${S}`||r.startsWith(o,`/${S}/`))){L.toast.error(l("Error"),{description:l("Slugs cannot start with a language code for primary page")});return}y({...s,slug:o},{onSuccess:p})},m=(s==null?void 0:s.lang)||"";return e.jsx(a.Dialog,{open:!!s,onOpenChange:p,children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:l("Change Slug")}),e.jsx(a.DialogDescription,{className:"text-xs",children:e.jsxs(N.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(j.AlertCircle,{className:"h-4 w-4"}),l("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),e.jsxs("form",{onSubmit:E,children:[e.jsxs("div",{className:"space-y-4 py-4 text-sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsxs("span",{children:[l("Type"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(d==null?void 0:d.name)||(s==null?void 0:s.pageType)]})]}),e.jsxs("div",{children:[e.jsxs("span",{children:[l("Name"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",s.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(a.Label,{htmlFor:"slug",className:"text-right",children:[l("Slug")," ",e.jsxs("small",{className:"font-light text-gray-500",children:[l("Slug should start with")," /",m]})]}),e.jsx(N.Input,{id:"slug",value:o,onChange:h=>{const x=h.target.value;r.startsWith(x,`/${m}`)&&P(x)},className:"col-span-3",required:!0,pattern:"^/.*",title:l("Slug must start with /"),placeholder:l("Enter page slug")})]})]}),e.jsx(a.DialogFooter,{children:e.jsx(N.Button,{type:"submit",disabled:f||!r.startsWith(o,`/${m}`)||r.isEqual(s==null?void 0:s.slug,o),children:l(f?"Changing...":"Change Slug")})})]})]})})},T=c.lazy(()=>Promise.resolve().then(()=>require("./delete-page-B7ODELqM.cjs"))),q=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BMowW5wT.cjs"))),_=()=>{const{t:s}=I.useTranslation(),p=k.useSetAtom(n.addNewLangAtom),{selectedLang:l,fallbackLang:o,setSelectedLang:P}=a.useLanguages(),{data:y,isFetching:f}=n.useLanguagePages(),{data:i}=n.useChaiCurrentPage(),{data:d}=n.usePageTypes(),E=c.useMemo(()=>{const t=d==null?void 0:d.find(g=>g.key===(i==null?void 0:i.pageType));return i!=null&&i.dynamic?t==null?void 0:t.dynamicSlug:""},[d,i==null?void 0:i.pageType,i==null?void 0:i.dynamic]),[m,h]=c.useState(null),[x,C]=c.useState(null),[S,A]=c.useState(null),{data:b}=n.useWebsiteSetting(),D=r.filter(r.get(b,"languages")||["en"],t=>!r.find(y,{lang:t})&&t!==r.get(b,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:f?e.jsxs("div",{className:"w-full space-y-3 py-4",children:[e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"})]}):r.map(y,t=>{const g=t.lang,v=t.slug,w=!t.primaryPage,G=g===l;return e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${G?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>P(g),children:[e.jsxs("div",{className:"flex-1 gap-x-3",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-[13px] text-slate-800",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.get(n.LANGUAGES,w?o:g,g)]}),e.jsxs("div",{children:[v&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:E?`${v}/${E}`:v})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),w?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(j.StarIcon,{fill:"orange",className:"h-3 w-3"}),e.jsx("b",{children:" Primary"})]}):e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE,n.PAGES_PERMISSIONS.DELETE_PAGE,n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:e.jsx(N.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(j.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(a.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(a.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),p({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(j.PencilIcon,{className:"size-3"}),s("Edit")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(a.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),C(t)},children:[e.jsx(j.Power,{className:"size-3"}),s("Unpublish")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(a.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),h(t)},children:[e.jsx(j.TrashIcon,{className:"size-3"}),s("Delete")]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(N.Button,{variant:"default",size:"sm",disabled:r.isEmpty(D),onClick:()=>{p({primaryPage:i==null?void 0:i.id,edit:!1})},children:s("Add new language page")})})}),m&&e.jsx(c.Suspense,{children:e.jsx(T,{page:m,onClose:()=>h(null)})}),x&&e.jsx(c.Suspense,{children:e.jsx(q,{page:x,onClose:()=>C(null)})}),S&&e.jsx(c.Suspense,{children:e.jsx(M,{page:S,onClose:()=>A(null)})})]})};exports.default=_;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e, jsxs as a, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { a0 as _, a1 as H, a2 as K, L as X, a3 as q, a4 as J, a5 as Y } from "./index-BK0xWO1z.js";
|
|
3
|
+
import { z, B as u } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
4
4
|
import { D as ee } from "./apply-binding-BvWfJCSZ.js";
|
|
5
5
|
import { MagnifyingGlassIcon as L, PlusIcon as O, TokensIcon as te, ArrowLeftIcon as ne, EyeOpenIcon as se, Pencil1Icon as re, TrashIcon as ae } from "@radix-ui/react-icons";
|
|
6
6
|
import { useAtom as oe } from "jotai";
|
|
@@ -17,7 +17,7 @@ const S = (n) => {
|
|
|
17
17
|
return m.length === 0 ? "" : m.length > 25 ? o("Token name must be 25 characters or less") : /^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(m) ? Object.entries(s).find(
|
|
18
18
|
([l, v]) => v.name === m && (!d || l !== i)
|
|
19
19
|
) ? o("Token name already exists") : "" : o("Only alphanumeric characters and hyphens allowed");
|
|
20
|
-
}, xe = (n) => n.replace(/\s+/g, "-"), ge = M(() => import("./delete-design-token-
|
|
20
|
+
}, xe = (n) => n.replace(/\s+/g, "-"), ge = M(() => import("./delete-design-token-DzINIVtO.js")), pe = M(() => import("./design-token-usage-DQf180Lg.js")), ve = ({ tokenId: n, token: s, isDisabled: o, onEdit: d, onDelete: i }) => /* @__PURE__ */ a("div", { className: "group relative flex items-center justify-between overflow-hidden rounded border p-2 transition-all duration-150 hover:bg-muted/90", children: [
|
|
21
21
|
/* @__PURE__ */ a("div", { className: "min-w-0 flex-1 overflow-hidden", children: [
|
|
22
22
|
/* @__PURE__ */ e("div", { className: "text-xs font-semibold", children: s.name }),
|
|
23
23
|
/* @__PURE__ */ e("div", { className: "w-full max-w-52 truncate text-[10px] font-light", children: s.value })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./index-Bm8iS2OH.cjs"),c=require("./register-chai-top-bar-DWTuRU53.cjs"),Z=require("./apply-binding-IsUf6UWJ.cjs"),u=require("@radix-ui/react-icons"),$=require("jotai"),U=require("nanoid"),a=require("react"),Q=require("react-i18next"),p=require("sonner"),_=require("tailwind-merge"),q=t=>{const n=t.trim();return n.length===0||n.length>25?!1:/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(n)},H=(t,n,o,m=!1,i)=>{const x=t.trim();return x.length===0?"":x.length>25?o("Token name must be 25 characters or less"):/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(x)?Object.entries(n).find(([l,N])=>N.name===x&&(!m||l!==i))?o("Token name already exists"):"":o("Only alphanumeric characters and hyphens allowed")},K=t=>t.replace(/\s+/g,"-"),X=a.lazy(()=>Promise.resolve().then(()=>require("./delete-design-token-3-WwqXMO.cjs"))),J=a.lazy(()=>Promise.resolve().then(()=>require("./design-token-usage-Dy08kcIc.cjs"))),Y=({tokenId:t,token:n,isDisabled:o,onEdit:m,onDelete:i})=>e.jsxs("div",{className:"group relative flex items-center justify-between overflow-hidden rounded border p-2 transition-all duration-150 hover:bg-muted/90",children:[e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:"text-xs font-semibold",children:n.name}),e.jsx("div",{className:"w-full max-w-52 truncate text-[10px] font-light",children:n.value})]}),e.jsxs("div",{className:"absolute right-1 top-1 flex flex-shrink-0 items-center opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:[e.jsx(a.Suspense,{fallback:null,children:e.jsx(J,{tokenId:t,tokenName:n.name,children:e.jsx(c.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 rounded-full p-0 hover:bg-primary/10 hover:text-primary",children:e.jsx(u.EyeOpenIcon,{className:"h-3 w-3"})})})}),e.jsx(c.Button,{variant:"ghost",size:"sm",onClick:()=>m(t),disabled:o,className:"h-6 w-6 rounded-full p-0 hover:bg-primary/10 hover:text-primary",children:e.jsx(u.Pencil1Icon,{className:"h-3 w-3"})}),e.jsx(a.Suspense,{fallback:null,children:e.jsx(X,{tokenName:n.name,tokenValue:n.value,onDelete:()=>i(t),children:e.jsx(c.Button,{variant:"ghost",size:"sm",disabled:o,className:"h-6 w-6 rounded-full p-0 hover:bg-destructive/10",children:e.jsx(u.TrashIcon,{className:"h-3 w-3 text-destructive"})})})})]})]}),ee=({})=>{const{t}=Q.useTranslation(),[n,o]=$.useAtom(v.chaiDesignTokensAtom),m=v.useIncrementActionsCount(),[i,x]=a.useState("view"),[j,k]=a.useState(null),[l,N]=a.useState(""),[h,b]=a.useState(""),[T,y]=a.useState(""),[w,E]=a.useState(""),[z,C]=a.useState(!1),f=a.useRef(null),I=a.useMemo(()=>Object.entries(n).filter(([,s])=>s.name.toLowerCase().includes(w.toLowerCase())||s.value.toLowerCase().includes(w.toLowerCase())),[n,w]);a.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const S=a.useCallback((s,r)=>{!j||i!=="edit"||!s.trim()||!r.trim()||!q(s)||Object.entries(n).find(([g,W])=>W.name===s.trim()&&g!==j)||(C(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{const g={...n,[j]:{name:s.trim(),value:r.trim()}};o(g),m(),C(!1)},250))},[j,i,n,o,m]),M=()=>{if(!l.trim()||!h.trim()){p.toast.error(t("Please fill in both token name and classes"));return}if(!q(l)){p.toast.error(t("Invalid design token name format"));return}if(Object.values(n).find(g=>g.name===l.trim())){p.toast.error(t("Token already exists"));return}const r=`${Z.DESIGN_TOKEN_PREFIX}${U.nanoid(12)}`,d={...n,[r]:{name:l.trim(),value:h.trim()}};o(d),m(),p.toast.success(t("Token added successfully")),A()},P=s=>{const r={...n};delete r[s],o(r),m(),p.toast.success(t("Token deleted successfully"))},R=s=>{const r=n[s];r&&(k(s),N(r.name),b(r.value),y(""),x("edit"))},B=()=>{k(null),N(""),b(""),y(""),x("add")},A=()=>{f.current&&clearTimeout(f.current),k(null),N(""),b(""),y(""),C(!1),x("view")},O=s=>{const r=K(s);N(r);const d=H(r,n,t,i==="edit",j||void 0);y(d),i==="edit"&&!d&&S(r,h)},D=s=>{b(s),i==="edit"&&!T&&l.trim()&&S(l,s)},L=s=>{const r=v.orderClassesByBreakpoint(v.removeDuplicateClasses(_.twMerge(h,s)));D(r)},F=s=>{const r=h.split(" ").filter(d=>d!==s).join(" ");D(r)},G=()=>{const s=i==="edit",r=t(s?"Edit Design Token":"Add Design Token"),d=t(s?"Update design token. Auto-saved.":"Create a reusable design token");return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-border/50 bg-muted p-1.5",children:[e.jsx(c.Button,{variant:"ghost",size:"sm",onClick:A,className:"h-6 w-6 rounded-full p-0 hover:bg-muted",children:e.jsx(u.ArrowLeftIcon,{className:"h-3 w-3"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:r}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:d})]}),s&&z&&e.jsx("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:e.jsx("div",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-primary"})})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v.Label,{htmlFor:"token-name",className:"text-xs font-medium",children:t("Token Name")}),e.jsx(c.Input,{id:"token-name",placeholder:"Button-Primary",value:l,onChange:g=>O(g.target.value),className:"h-7 text-xs"}),T?e.jsx("span",{className:"text-[10px] text-destructive",children:T}):e.jsx("span",{className:"text-[10px] font-light text-muted-foreground",children:t("Button-Primary, Card-Header, Text-Large etc.")})]}),e.jsx(v.ManualClasses,{from:"designToken",classFromProps:h,onAddNew:L,onRemove:F}),!s&&e.jsxs("div",{className:"mt-3 flex items-center justify-end gap-2 pt-3",children:[e.jsx(c.Button,{variant:"outline",onClick:A,className:"h-7 text-xs",children:t("Cancel")}),e.jsx(c.Button,{onClick:M,disabled:!l.trim()||!h.trim()||!!T,className:"h-7 text-xs",children:t("Add Token")})]})]})]})},V=()=>e.jsxs(e.Fragment,{children:[Object.entries(n).length>0&&e.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(u.MagnifyingGlassIcon,{className:"absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),e.jsx(c.Input,{placeholder:t("Search tokens"),value:w,onChange:s=>E(s.target.value),className:"h-6 pl-7 text-xs"})]}),e.jsxs(c.Button,{variant:"outline",onClick:B,size:"sm",className:"h-6 border-primary text-xs text-primary hover:bg-primary/10 hover:text-primary",children:[e.jsx(u.PlusIcon,{className:"h-3 w-3"}),t("Add")]})]}),e.jsx("div",{className:"no-scrollbar flex flex-1 flex-col overflow-hidden pt-2",children:e.jsx(v.ScrollArea,{className:"h-full flex-1",children:e.jsxs("div",{className:"space-y-1",children:[Object.entries(n).length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-muted bg-muted/20 py-8",children:[e.jsx("div",{className:"mb-2 text-3xl",children:e.jsx(u.TokensIcon,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:t("No design tokens yet")}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:t("Create reusable design tokens to streamline your styling")}),e.jsxs(c.Button,{variant:"default",onClick:B,size:"sm",className:"mt-4 h-7 text-xs leading-tight",children:[e.jsx(u.PlusIcon,{className:"mr-1 h-3 w-3"}),t("Add first design token")]})]}):I.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-muted bg-muted/20 py-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx(u.MagnifyingGlassIcon,{className:"h-10 w-10 text-muted-foreground"})}),e.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:t("No tokens found")}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:t("No design tokens match your search")})]}):I.map(([s,r])=>e.jsx(Y,{token:r,tokenId:s,onEdit:R,onDelete:P,isDisabled:!1},s)),e.jsx("div",{className:"h-44"})]})})})]});return e.jsx("div",{className:"flex h-full w-full flex-col",children:i==="view"?V():G()})};exports.default=ee;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import { z, B as c } from "./register-chai-top-bar-
|
|
3
|
-
import { D as L, d as P, e as B, f as E, p as S, L as w, T as U, q as R } from "./index-
|
|
4
|
-
import { q as j, m as O } from "./index-
|
|
2
|
+
import { z, B as c } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
+
import { D as L, d as P, e as B, f as E, p as S, L as w, T as U, q as R } from "./index-BK0xWO1z.js";
|
|
4
|
+
import { q as j, m as O } from "./index-D5d4QDq7.js";
|
|
5
5
|
import { startCase as y } from "lodash-es";
|
|
6
6
|
import { Tag as q, File as X, ImageIcon as _, X as $ } from "lucide-react";
|
|
7
7
|
import { useState as m, useRef as H, useCallback as K } from "react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./register-chai-top-bar-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./register-chai-top-bar-DWTuRU53.cjs"),t=require("./index-Bm8iS2OH.cjs"),y=require("./index-BRJCj7c_.cjs"),w=require("lodash-es"),m=require("lucide-react"),l=require("react"),M=require("react-i18next"),k=require("sonner"),B=1*1024*1024,A=({page:r,onClose:u})=>{const{t:s}=M.useTranslation(),[f,p]=l.useState(!1),[j,T]=l.useState(""),[c,N]=l.useState(""),[v,x]=l.useState(!1),i=l.useRef(null),C=y.useMarkAsTemplate(),{data:h}=y.usePageTypes(),g=h==null?void 0:h.find(a=>a.key===r.pageType),I=(g==null?void 0:g.name)||w.startCase(r.pageType),D=l.useCallback(a=>{var b;const d=(b=a.target.files)==null?void 0:b[0];if(d){if(d.size>B){k.toast.error(s("File too large"),{description:`${s("Maximum file size is 1MB. Selected file is")} ${(d.size/1024).toFixed(2)}KB.`}),i.current&&(i.current.value="");return}try{x(!0);const n=new FileReader;n.onloadend=()=>{N(n.result),x(!1)},n.readAsDataURL(d)}catch(n){console.error("Error reading file:",n),x(!1),k.toast.error(s("Failed to process image"),{description:n instanceof Error?n.message:s("Unknown error")})}}},[s]),F=()=>{N(""),i.current&&(i.current.value="")},S=()=>{var a;(a=i.current)==null||a.click()},q=()=>{p(!0),C.mutate({page:r,name:r.name,description:j.trim()||void 0,pageType:r.pageType,...c?{previewImage:c}:{}},{onSuccess:()=>{p(!1),u()},onError:()=>{p(!1)}})};return e.jsx(t.Dialog,{open:!0,onOpenChange:u,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:s("Mark as template")}),e.jsxs(t.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:[s("Are you sure you want to mark this page as a template?"),e.jsx("br",{}),s("Templates can be used to create new pages with the same content.")]})]}),e.jsxs("div",{className:"mb-4 space-y-4 text-xs",children:[e.jsxs("div",{className:"space-y-3 rounded border bg-slate-50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m.Tag,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Page Name"),":"]}),e.jsx("span",{className:"font-semibold",children:w.startCase(r.name)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m.File,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Type"),":"]}),e.jsx("span",{className:"font-semibold",children:I})]})]}),e.jsxs("div",{children:[e.jsx(t.Label,{htmlFor:"description",className:"text-xs font-medium",children:s("Description (Optional)")}),e.jsx(t.Textarea,{id:"description",placeholder:s("Describe this template's purpose"),className:"mt-1 h-24 resize-none text-xs",value:j,onChange:a=>T(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"previewImage",className:"text-xs font-medium",children:s("Preview Image (Optional)")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o.Input,{type:"file",id:"previewImage",ref:i,onChange:D,accept:"image/*",className:"hidden"}),e.jsx(o.Button,{type:"button",variant:"outline",onClick:S,disabled:v,className:"w-full",children:v?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),s("Uploading...")]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(m.ImageIcon,{className:"h-4 w-4"}),s("Select image")]})}),c&&e.jsx(o.Button,{type:"button",variant:"outline",size:"icon",onClick:F,children:e.jsx(m.X,{className:"h-4 w-4"})})]}),c&&e.jsx("div",{className:"aspect-video overflow-hidden rounded-md border",children:e.jsx("img",{src:c,alt:s("Preview"),className:"h-full max-h-[200px] w-full object-contain"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("max 1mb")})]})]})]}),e.jsxs(t.DialogFooter,{className:f?"pointer-events-none opacity-75":"",children:[e.jsx(o.Button,{variant:"outline",onClick:a=>{a.stopPropagation(),u()},children:s("Cancel")}),e.jsx(o.Button,{variant:"default",disabled:f,onClick:q,children:s("Mark as template")})]})]})})};exports.default=A;
|
package/dist/{nested-path-selector-content-SmfjElr-.cjs → nested-path-selector-content-CQOx2L9C.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),d=require("lucide-react"),p=require("react"),v=require("./register-chai-top-bar-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),d=require("lucide-react"),p=require("react"),v=require("./register-chai-top-bar-DWTuRU53.cjs"),a=require("./index-Bm8iS2OH.cjs");function C(c){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const r in c)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(c,r);Object.defineProperty(l,r,i.get?i:{enumerable:!0,get:()=>c[r]})}}return l.default=c,Object.freeze(l)}const o=C(p);function N({data:c,onSelect:l,dataType:r="value",open:i,setOpen:m}){const[u,f]=o.useState([]),[h,j]=o.useState(c);o.useEffect(()=>{i||f([]),j(c)},[c,i]);const b=e=>Array.isArray(e)?"array":typeof e=="object"&&e!==null?"object":"value",y=o.useCallback(e=>{const n=s=>r==="value"?s==="value"||s==="object":r==="array"?s==="array":s===r;e.type==="object"?(f(s=>[...s,e.key]),j(e.value)):n(e.type)&&(l([...u,e.key].join(".")),m(!1))},[r,l,u,m]),x=o.useCallback(()=>{if(u.length>0){const e=u.slice(0,-1);f(e),j(e.reduce((n,s)=>n[s],c))}},[u,c]),g=o.useMemo(()=>Object.entries(h).map(([e,n])=>({key:e,value:n,type:b(n)})).filter(e=>r==="value"?e.type==="value"||e.type==="object":r==="array"?e.type==="array"||e.type==="object":r==="object"?e.type==="object":!0),[h,r]);return t.jsx(a.PopoverContent,{className:"z-[9999] w-[200px] p-0",children:t.jsxs(a.Command,{children:[t.jsx(a.CommandInput,{className:"border-none",placeholder:"Search..."}),t.jsxs(a.CommandList,{onWheel:e=>{try{e.preventDefault();const n=e.currentTarget;n.scrollTop+=e.deltaY}catch{e.preventDefault()}},children:[t.jsx(a.CommandEmpty,{children:"No option found."}),t.jsxs(a.CommandGroup,{children:[u.length>0&&t.jsxs(a.CommandItem,{onSelect:x,className:"flex items-center text-sm",children:[t.jsx(d.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),g.map(e=>t.jsxs(a.CommandItem,{onSelect:()=>y(e),className:"flex items-center justify-between",children:[t.jsx("span",{children:e.key}),t.jsxs("div",{className:"flex items-center gap-2",children:[r==="object"&&e.type==="object"&&t.jsx(v.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:n=>{n.stopPropagation(),l([...u,e.key].join(".")),m(!1)},children:"Select"}),(e.type==="object"||e.type==="array")&&t.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:t.jsx(d.ChevronRight,{className:"h-4 w-4 opacity-50"})})]})]},e.key))]})]})]})})}exports.default=N;
|
package/dist/{nested-path-selector-content-kGznHufl.js → nested-path-selector-content-Wd6-Eql0.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as c, jsxs as n } from "react/jsx-runtime";
|
|
2
2
|
import { ChevronLeft as v, ChevronRight as g } from "lucide-react";
|
|
3
3
|
import * as l from "react";
|
|
4
|
-
import { B as k } from "./register-chai-top-bar-
|
|
5
|
-
import { P as N, C as x, i as P, j as S, k as w, l as B, m as d } from "./index-
|
|
4
|
+
import { B as k } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
5
|
+
import { P as N, C as x, i as P, j as S, k as w, l as B, m as d } from "./index-BK0xWO1z.js";
|
|
6
6
|
function I({
|
|
7
7
|
data: o,
|
|
8
8
|
onSelect: m,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
-
import { B as h } from "./register-chai-top-bar-
|
|
3
|
-
import { n as u, R as w, U as p, V as f, W as P, X as C } from "./index-
|
|
4
|
-
import { c as S, d as L, L as x, B as N } from "./index-
|
|
2
|
+
import { B as h } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
+
import { n as u, R as w, U as p, V as f, W as P, X as C } from "./index-BK0xWO1z.js";
|
|
4
|
+
import { c as S, d as L, L as x, B as N } from "./index-D5d4QDq7.js";
|
|
5
5
|
import { get as v } from "lodash-es";
|
|
6
6
|
import { LockIcon as B } from "lucide-react";
|
|
7
7
|
import { useTranslation as E } from "react-i18next";
|
package/dist/{no-language-page-content-B4bQLc4K.cjs → no-language-page-content-C11uF6hs.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("./register-chai-top-bar-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("./register-chai-top-bar-DWTuRU53.cjs"),t=require("./index-Bm8iS2OH.cjs"),n=require("./index-BRJCj7c_.cjs"),w=require("lodash-es"),x=require("lucide-react"),p=require("react-i18next"),P=()=>{const{t:a}=p.useTranslation(),[i,l]=n.useSearchParams(),c=i.get("lang"),g=n.useIsLanguagePageCreated(c),{setSelectedLang:u}=t.useLanguages(),d=()=>{const r=new URLSearchParams(window.location.search);r.delete("lang");const o=r.toString(),h=`${window.location.pathname}${o?`?${o}`:""}`;window.history.pushState({},"",h),l(r),u(""),window.dispatchEvent(new PopStateEvent("popstate"))};if(g)return null;const s=w.get(n.LANGUAGES,c);return e.jsx(n.BlurContainer,{children:e.jsxs(t.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(t.CardHeader,{className:"space-y-1",children:e.jsxs(t.CardTitle,{className:"flex items-center gap-2 text-2xl",children:[e.jsx(x.LockIcon,{className:"h-6 w-6 text-yellow-500"}),a("Page missing for"),' "',s,'" ',a("language"),"."]})}),e.jsx(t.CardContent,{className:"grid gap-4",children:e.jsxs("div",{children:[a("Page is not available in the"),' "',s,'" ',a("language. Either create the page in the"),' "',s,'"',a("language or switch to the base language.")]})}),e.jsx(t.CardFooter,{children:e.jsx(m.Button,{onClick:d,className:"w-full",variant:"destructive",children:a("Switch to default language")})})]})})};exports.default=P;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-BRJCj7c_.cjs"),n=require("react"),t=n.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content-C11uF6hs.cjs"))),g=()=>{const[r]=a.useSearchParams(),s=r.get("lang");return a.useIsLanguagePageCreated(s)?null:e.jsx(n.Suspense,{children:e.jsx(t,{})})};exports.default=g;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { c as g, d as n } from "./index-
|
|
2
|
+
import { c as g, d as n } from "./index-D5d4QDq7.js";
|
|
3
3
|
import { Suspense as s, lazy as t } from "react";
|
|
4
|
-
const o = t(() => import("./no-language-page-content-
|
|
4
|
+
const o = t(() => import("./no-language-page-content-BOv6TZIk.js")), l = () => {
|
|
5
5
|
const [e] = g(), r = e.get("lang");
|
|
6
6
|
return n(r) ? null : /* @__PURE__ */ a(s, { children: /* @__PURE__ */ a(o, {}) });
|
|
7
7
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as s, jsxs as l, Fragment as We } from "react/jsx-runtime";
|
|
2
|
-
import { z as M, h as ye, B as W } from "./register-chai-top-bar-
|
|
3
|
-
import { j as os, L as z, a6 as ee, a7 as se, P as ae, C as le, k as ne, l as G, m as I, ai as cs, n as us } from "./index-
|
|
2
|
+
import { z as M, h as ye, B as W } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
+
import { j as os, L as z, a6 as ee, a7 as se, P as ae, C as le, k as ne, l as G, m as I, ai as cs, n as us } from "./index-BK0xWO1z.js";
|
|
4
4
|
import { useState as y, useRef as ms, useEffect as ze, useMemo as B, startTransition as Oe } from "react";
|
|
5
|
-
import { r as te, S as hs, c as Be } from "./slug-input-
|
|
5
|
+
import { r as te, S as hs, c as Be } from "./slug-input-DoEIq5rs.js";
|
|
6
6
|
import { isEmpty as Ie, startCase as de, filter as ps, find as ge, groupBy as ds, pick as fs, set as P } from "lodash-es";
|
|
7
7
|
import { ChevronDown as re, Search as ie, Check as R } from "lucide-react";
|
|
8
|
-
import { ar as Re, as as Ue, A as oe, m as gs, at as ys, g as vs, h as Ns, i as Ss, ay as bs, L as ws } from "./index-
|
|
8
|
+
import { ar as Re, as as Ue, A as oe, m as gs, at as ys, g as vs, h as Ns, i as Ss, ay as bs, L as ws } from "./index-D5d4QDq7.js";
|
|
9
9
|
import { useQuery as _e } from "@tanstack/react-query";
|
|
10
10
|
import { toast as E } from "sonner";
|
|
11
11
|
import { g as $e } from "./get-seo-defaults-9zHebckY.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./register-chai-top-bar-BqwKw4uy.cjs"),a=require("./index-xYnNKovy.cjs"),o=require("react"),_=require("./slug-input-Dp187Tiy.cjs"),w=require("lodash-es"),N=require("lucide-react"),k=require("./index-BwH1mRm_.cjs"),je=require("@tanstack/react-query"),J=require("sonner"),fe=require("./get-seo-defaults-Cw7vFt-B.cjs");function Ue({value:t,onChange:c,placeholder:j="Enter custom slug part",dynamicPattern:p,onValidationChange:i}){const[f,m]=o.useState(null),h=o.useRef(null),[g,T]=o.useState(p+t);o.useEffect(()=>{T(p+t)},[t,p]);const O=S=>{const C=S.target.value;if(!C.startsWith(p)){const W=C.replace(p,""),G=p+W;T(G),c(W);return}const l=C.substring(p.length).replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),n=(l.match(/\./g)||[]).length,x=n<=1;n>1?m("Invalid slug. Only one dot (.) is allowed in the slug"):m(null),i&&i(x);const y=p+l;T(y),c(l)},b=()=>{if(h.current){const S=h.current;setTimeout(()=>{const C=p.length;S.setSelectionRange(C,C)},0)}},R=S=>{const C=S.currentTarget;(C.selectionStart||0)<=p.length&&setTimeout(()=>{const l=p.length;C.setSelectionRange(l,l)},0)};return e.jsx("div",{children:e.jsxs("div",{className:"relative",children:[e.jsxs("p",{className:"mb-2 text-xs text-gray-500",children:[`${p}`," is a dynamic segment of slug"]}),e.jsx(v.Input,{ref:h,value:g,onChange:O,onFocus:b,onClick:R,placeholder:j,className:f?"border-red-500":""}),f&&e.jsx("div",{className:"mt-1 text-xs text-red-500",children:f})]})})}const X=({children:t,onWheel:c,...j})=>{const p=i=>{try{i.preventDefault();const f=i.currentTarget;f.scrollTop+=i.deltaY}catch{i.preventDefault()}c&&c(i)};return e.jsx(a.CommandList,{...j,onWheel:p,children:t})},te=(...t)=>t.filter(Boolean).join(" ");function ze({pages:t,selectedParentId:c,onChange:j,className:p,id:i="parentPage",currentPage:f}){const[m,h]=o.useState(!1),[g,T]=o.useState(""),O=v.useChaiFeatureFlag("enable-add-page-dropdown");O||(p="w-full rounded-md border border-gray-300 px-3 py-2");const b=o.useMemo(()=>!t||t.length===0?[]:t.filter(x=>!w.isEmpty(x.slug)).filter(x=>x.slug!=="/").sort((x,y)=>x.slug.localeCompare(y.slug)),[t]),R=o.useMemo(()=>{if(!g.trim())return b;const n=g.toLowerCase();return b.filter(x=>x.name.toLowerCase().includes(n)||x.slug.toLowerCase().includes(n))},[b,g]),S=n=>Math.max(0,(n.match(/\//g)||[]).length-1),C=n=>" ".repeat(n),d=n=>{if(n==="/")return"/";const x=n.split("/").filter(Boolean);if(x.length<=1){const y=x[0]||"";return`/${_.removeSlugExtension(y)}`}return`/${_.removeSlugExtension(x[x.length-1])}`},l=()=>{if(!c||c==="none")return"None";const n=b.find(x=>x.id===c);return n?`${n.name} (${d(n.slug)})`:"None"};return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:i,className:"text-sm",children:"Parent"}),O?e.jsxs(a.Popover,{open:m,onOpenChange:h,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{id:i,variant:"outline",role:"combobox",className:te("w-full justify-between",p),"data-testid":"parent-page-selector",children:[l(),e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"relative border-none py-2",children:e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search pages...",className:"h-8 pl-8 text-xs",value:g,onChange:n=>T(n.target.value)})]})})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No pages found."}),e.jsxs(a.CommandGroup,{children:[e.jsxs(a.CommandItem,{value:"none",onSelect:()=>{j(""),h(!1),T("")},className:"flex cursor-pointer items-center justify-between",children:[e.jsx("span",{children:"None"}),e.jsx(N.Check,{className:te("mr-2 h-4 w-4",c?"opacity-0":"opacity-100")})]}),R.map(n=>{const x=C(S(n.slug)),y=d(n.slug),W=e.jsxs("span",{className:"flex items-center text-sm",children:[x,n.name,e.jsxs("span",{className:"text-xs text-gray-500",children:[" (",y,")"]})]});return e.jsxs(a.CommandItem,{value:n.id,onSelect:()=>{j(n.id),h(!1),T("")},className:"flex cursor-pointer items-center justify-between whitespace-pre-wrap",children:[e.jsx("span",{children:W}),e.jsx(N.Check,{className:te("mr-2 h-4 w-4 shrink-0",c===n.id?"opacity-100":"opacity-0")})]},n.id)})]})]})]})})]}):e.jsxs("select",{id:i,value:c||"none",onChange:n=>j(n.target.value),className:p,"data-testid":"parent-page-selector",children:[e.jsx("option",{value:"none",children:"None"}),b.map(n=>{const x=S(n.slug),y=x>0?C(x):"",W=d(n.slug);return(f==null?void 0:f.id)===n.id||n.slug.startsWith(f==null?void 0:f.slug)?null:e.jsxs("option",{value:n.id,children:[y,n.name," (",W,")"]},n.id)})]})]})}const _e=(...t)=>t.filter(Boolean).join(" "),Ve=({templates:t,selectedTemplateId:c,onSelectTemplate:j,isLoading:p=!1})=>{const[i,f]=o.useState(""),[m,h]=o.useState(!1),[g,T]=o.useState(""),O=v.useChaiFeatureFlag("enable-add-page-dropdown");if(o.useEffect(()=>{if(c){const d=t.find(l=>l.id===c);o.startTransition(()=>f((d==null?void 0:d.preview)||""))}else o.startTransition(()=>f(""))},[c,t]),p)return e.jsx("div",{className:"flex h-fit items-center justify-center text-sm text-gray-500",children:"Loading templates..."});if(t.length===0)return null;const b={};t.forEach(d=>{const l=d.libraryName;b[l]||(b[l]=[]),b[l].push(d)});const R=Object.entries(b).reduce((d,[l,n])=>{const x=n.filter(y=>y.name.toLowerCase().includes(g.toLowerCase())||l.toLowerCase().includes(g.toLowerCase()));return x.length>0&&(d[l]=x),d},{}),S=t.find(d=>d.id===c),C=S?w.startCase(S.name):"No Template";return e.jsxs("div",{className:"space-y-4",children:[O?e.jsxs(a.Popover,{open:m,onOpenChange:h,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",className:"w-full justify-between",children:[C,e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search templates...",className:"h-8 pl-8 text-xs",value:g,onChange:d=>T(d.target.value)})]})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No templates found."}),Object.entries(R).map(([d,l])=>e.jsx(a.CommandGroup,{heading:d,children:l.map(n=>e.jsxs(a.CommandItem,{value:n.id,onSelect:()=>{j(n.id),h(!1),T("")},className:"flex cursor-pointer items-center justify-between",children:[w.startCase(n.name),e.jsx(N.Check,{className:_e("mr-2 h-4 w-4",c===n.id?"opacity-100":"opacity-0")})]},n.id))},d))]})]})})]}):e.jsxs("select",{className:"w-full rounded-md border border-gray-300 px-3 py-2",value:c,onChange:d=>j(d.target.value),children:[e.jsx("option",{value:"",children:"No Template"}),Object.entries(b).map(([d,l])=>e.jsx("optgroup",{label:d,children:l.map(n=>e.jsx("option",{value:n.id,children:w.startCase(n.name)},n.id))},d))]}),i&&e.jsxs("div",{className:"mt-3 overflow-hidden rounded border",children:[e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("img",{src:i,alt:"Template Preview",className:"w-full object-contain"})}),e.jsx("div",{className:"border-t bg-gray-50 p-2 text-xs text-gray-500",children:"Template preview"})]})]})},$e=()=>{const t=k.useApiUrl(),c=k.useFetch();return je.useQuery({queryKey:[k.ACTIONS.GET_LIBRARIES],staleTime:"static",queryFn:async()=>await c(t,{action:k.ACTIONS.GET_LIBRARIES})||[]})},Qe=t=>{const c=k.useApiUrl(),j=k.useFetch();return je.useQuery({queryKey:[k.ACTIONS.GET_TEMPLATES_BY_TYPE,t],staleTime:"static",enabled:!!t,queryFn:async()=>{const p=await j(c,{action:k.ACTIONS.GET_TEMPLATES_BY_TYPE,data:{pageType:t}});return(t?w.filter(p,{pageType:t}):p)||[]}})},Ye=t=>{const{data:c=[],isLoading:j}=Qe(t),{data:p=[],isLoading:i}=$e(),f=o.useMemo(()=>j||i?[]:c.map(h=>{const g=w.find(p,{id:h.library});return{...h,libraryName:(g==null?void 0:g.type)!=="shared"?"Site Library":(g==null?void 0:g.name)+" Library",libraryType:g==null?void 0:g.type}}),[c,p,j,i]),m=o.useMemo(()=>w.groupBy(f,"libraryName"),[f]);return{data:f,groupedData:m,isLoading:j||i}},z=(...t)=>t.filter(Boolean).join(" ");function He({addEditPage:t,close:c,closePanel:j}){var xe,ge;const{data:p}=k.usePageTypes(),i=o.useMemo(()=>p??[],[p]),f=k.useChangePage(),m=!!(t!=null&&t.id),{data:h}=k.useWebsitePages(),{mutate:g,isPending:T}=k.useCreatePage(),{mutate:O,isPending:b}=k.useUpdatePage(),[R,S]=o.useState(null),[C,d]=o.useState(!0),[l,n]=o.useState((t==null?void 0:t.pageType)??"page"),{hasPermission:x}=a.usePermissions(),y=x(k.PAGES_PERMISSIONS.CHANGE_PAGE_TYPE),[W,G]=o.useState(!1),[ye,ve]=o.useState(""),{selectedLang:Se,fallbackLang:Ce}=a.useLanguages(),ne=Se||Ce,[V,H]=o.useState(""),[ae,Q]=o.useState(!1),le=o.useMemo(()=>{const s=i.find(u=>u.key===l);return(s==null?void 0:s.hasSlug)===!1},[l,i]),[D,Ne]=o.useState((t==null?void 0:t.parent)??""),[M,re]=o.useState((t==null?void 0:t.name)??""),[F,oe]=o.useState((t==null?void 0:t.dynamic)??!1),[B,Y]=o.useState(F?"":((t==null?void 0:t.slug)??"").split("/").pop()||""),[ie,ce]=o.useState((t==null?void 0:t.dynamicSlugCustom)??""),[ue,be]=o.useState(!0),[we,P]=o.useState(!1),[E,ke]=o.useState(""),{data:me,isLoading:Le}=Ye(l),$=T||b,he=v.useChaiFeatureFlag("enable-add-page-dropdown"),ee=o.useMemo(()=>!m||!(t!=null&&t.id)||!h?null:h.find(s=>s.id===t.id),[m,t==null?void 0:t.id,h]),Te=(ee==null?void 0:ee.online)||!1,De=o.useMemo(()=>!m||!(t!=null&&t.id)||!h?!1:h.some(s=>s.parent===t.id),[m,t==null?void 0:t.id,h]),r=i.find(s=>s.key===l),U=s=>{if(m&&l!==s){ve(s),G(!0),H(""),Q(!1);return}n(s),H(""),Q(!1)},pe=()=>{n(ye),G(!1),oe(!1)},Ie=s=>{oe(s),s?Y(""):ce("")},Fe=s=>{if(Ne(s),s&&s!=="none"){const u=h==null?void 0:h.find(L=>L.id===s),q=(u==null?void 0:u.slug)||"";if(B.startsWith(q)){const L=B.slice(q.length).replace(/^\/+/,"");Y(L)}else Y(B.replace(/^\/+/,""))}else Y(B?`${B}`:"")},Be=s=>{ke(s)},qe=()=>M.trim()?F&&!w.isEmpty(B)?(S("Slug must be empty when using dynamic slug"),!1):F&&!ue?(S("Dynamic slug is invalid"),!1):!0:(J.toast.error("Name is required"),!1),Ae=()=>{const s={pageType:r==null?void 0:r.key,name:M,slug:"",hasSlug:!1};m?O({id:t==null?void 0:t.id,name:M},{onSuccess:()=>{J.toast.success((r==null?void 0:r.name)+" updated successfully"),c()}}):g(s,{onSuccess:u=>{c(),f(u.page.id,j)}})},Oe=(s,u)=>{if(!s.trim()&&!F)return S("Child page slug is required"),!1;const q=_.removeSlugExtension(u),L=_.combineParentChildSlugs(q,s);return Object.keys(k.LANGUAGES).some(Z=>L===`/${Z}`||(L==null?void 0:L.startsWith(`/${Z}/`)))?(S("Slugs cannot start with a language code for primary page"),!1):!0},We=(s,u)=>{const q=_.removeSlugExtension(u),L=_.combineParentChildSlugs(q,s),I={pageType:l,name:M,slug:L.replace(/\/$/,""),parent:D,dynamic:F,hasSlug:!0,template:E||void 0,tracking:{},seo:{},jsonLD:{}};if(F&&(I.dynamicSlugCustom=ie),m){const A=w.pick(I,["pageType","parent","name","slug","dynamic","dynamicSlugCustom"]);O({id:t==null?void 0:t.id,...A},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}})}else{const A=w.find(i,{key:l});A!=null&&A.trackingDefault&&(I.tracking=A.trackingDefault);const{seo:Z,jsonLD:Ge}=fe.getSeoDefaults(A,ne);w.set(I,"seo",Z),w.set(I,"jsonLD",Ge),g(I,{onSuccess:Me=>{c(),f(Me.page.id,j)}})}},Re=()=>{const s={pageType:l,name:M,slug:B===""?"/":`/${B.replace(/\/$/,"")}`,template:E||void 0,parent:null,tracking:{}};if(m)O({id:t==null?void 0:t.id,...s},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}});else{const u=w.find(i,{key:l});u!=null&&u.trackingDefault&&(s.tracking=u.trackingDefault);const{seo:q,jsonLD:L}=fe.getSeoDefaults(u,ne);w.set(s,"seo",q),w.set(s,"jsonLD",L),g(s,{onSuccess:I=>{var A;(A=I==null?void 0:I.page)!=null&&A.id&&f(I.page.id,j),c()}})}},de=s=>{if(s.preventDefault(),S(null),!!qe()){if(!(r!=null&&r.hasSlug)){Ae();return}if(D&&D!=="none"){const u=h==null?void 0:h.find(L=>L.id===D),q=(u==null?void 0:u.slug)||"";if(!Oe(B,q))return;We(B,q)}else Re()}},{pagesType:se,partialsType:K}=o.useMemo(()=>{const s=u=>V?u.name.toLowerCase().includes(V.toLowerCase())||u.key.toLowerCase().includes(V.toLowerCase()):!0;return{pagesType:i.filter(u=>u.hasSlug!==!1&&s(u)),partialsType:i.filter(u=>u.hasSlug===!1&&s(u))}},[i,V]);return r!=null&&r.hasSlug?e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(a.Popover,{open:ae,onOpenChange:Q,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:z("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:V,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No page type found."}),m?le?e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsx(a.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsxs(e.Fragment,{children:[se.length>0&&e.jsx(a.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}),K.length>0&&e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>U(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:m?le?e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsx("optgroup",{label:"Pages",children:i.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsxs(e.Fragment,{children:[e.jsx("optgroup",{label:"Pages",children:i.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}),e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})]})}),W&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(v.Button,{variant:"outline",size:"sm",onClick:()=>G(!1),children:"Cancel"}),e.jsx(v.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]})]}),!m&&(r==null?void 0:r.hasSlug)&&me.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.Label,{className:"mb-1 block text-sm",children:"Template"}),e.jsx(Ve,{templates:me,selectedTemplateId:E,onSelectTemplate:Be,isLoading:Le})]}),e.jsx(ze,{pages:h,selectedParentId:D,onChange:Fe,currentPage:t}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(v.Input,{id:"name",value:M,onChange:s=>re(s.target.value),required:!0,"aria-required":"true",placeholder:"Enter page name"})]}),(r==null?void 0:r.dynamicSegments)&&D&&D!=="none"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"useDynamicSlug",checked:F,onChange:s=>Ie(s.target.checked),className:"rounded border-gray-300"}),e.jsx(a.Label,{htmlFor:"useDynamicSlug",className:"text-sm",children:"Use Dynamic Slug"})]}),F&&e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"space-y-0.5",children:e.jsx(Ue,{value:ie,onChange:ce,dynamicPattern:(r==null?void 0:r.dynamicSlug)||"{{id}}",placeholder:"Enter custom slug part (optional)",onValidationChange:be})})})]}),(!(r!=null&&r.dynamicSegments)||!F)&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx(_.SlugInput,{value:B,onChange:s=>{var u;Y(s),m&&s!==(((u=t==null?void 0:t.slug)==null?void 0:u.split("/").pop())||"")?P(!!(Te||De)):P(!1)},placeholder:D&&D!=="none"?"Enter page slug":l==="page"?"Leave empty for home page":"Required - e.g. your-slug",parentSlug:D&&D!=="none"?(ge=h==null?void 0:h.find(s=>s.id===D))==null?void 0:ge.slug:void 0,onValidationChange:d}),R&&e.jsx("p",{className:"text-xs text-red-500",children:R}),we&&e.jsx("div",{className:"mt-4 rounded-md border border-amber-200 bg-amber-50 p-3",children:e.jsxs("div",{className:"flex items-start space-x-2",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-amber-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-amber-800",children:"Slug Change Warning"}),e.jsx("div",{className:"mt-1 text-sm text-amber-700",children:e.jsx("p",{children:"The previous URL and any child pages will become inaccessible. You may want to set up a redirect to avoid broken links."})})]})]})})]}),e.jsx(v.Button,{disabled:$||!C&&(!(r!=null&&r.dynamicSegments)||!F)||F&&!ue,type:"submit",className:"w-full",children:m?$?"Updating...":"Update page":$?"Creating...":"Create Page"})]}):e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(a.Popover,{open:ae,onOpenChange:Q,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:z("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:V,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"max-h-[200px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No page type found."}),e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>{U(s.key),Q(!1)},className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>U(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})}),W&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(v.Button,{variant:"outline",size:"sm",onClick:()=>G(!1),children:"Cancel"}),e.jsx(v.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:(xe=i.find(s=>s.key===l))==null?void 0:xe.helpText})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(v.Input,{id:"name",value:M,onChange:s=>re(s.target.value),required:!0,"aria-required":"true"})]}),e.jsx(v.Button,{disabled:$,type:"submit",className:"w-full",children:m?$?"Updating...":"Update "+(r==null?void 0:r.name):$?"Creating...":"Create "+(r==null?void 0:r.name)})]})}exports.default=He;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./register-chai-top-bar-DWTuRU53.cjs"),a=require("./index-Bm8iS2OH.cjs"),o=require("react"),_=require("./slug-input-CsVJAr7r.cjs"),w=require("lodash-es"),N=require("lucide-react"),k=require("./index-BRJCj7c_.cjs"),je=require("@tanstack/react-query"),J=require("sonner"),fe=require("./get-seo-defaults-Cw7vFt-B.cjs");function Ue({value:t,onChange:c,placeholder:j="Enter custom slug part",dynamicPattern:p,onValidationChange:i}){const[f,m]=o.useState(null),h=o.useRef(null),[g,T]=o.useState(p+t);o.useEffect(()=>{T(p+t)},[t,p]);const O=S=>{const C=S.target.value;if(!C.startsWith(p)){const W=C.replace(p,""),G=p+W;T(G),c(W);return}const l=C.substring(p.length).replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),n=(l.match(/\./g)||[]).length,x=n<=1;n>1?m("Invalid slug. Only one dot (.) is allowed in the slug"):m(null),i&&i(x);const y=p+l;T(y),c(l)},b=()=>{if(h.current){const S=h.current;setTimeout(()=>{const C=p.length;S.setSelectionRange(C,C)},0)}},R=S=>{const C=S.currentTarget;(C.selectionStart||0)<=p.length&&setTimeout(()=>{const l=p.length;C.setSelectionRange(l,l)},0)};return e.jsx("div",{children:e.jsxs("div",{className:"relative",children:[e.jsxs("p",{className:"mb-2 text-xs text-gray-500",children:[`${p}`," is a dynamic segment of slug"]}),e.jsx(v.Input,{ref:h,value:g,onChange:O,onFocus:b,onClick:R,placeholder:j,className:f?"border-red-500":""}),f&&e.jsx("div",{className:"mt-1 text-xs text-red-500",children:f})]})})}const X=({children:t,onWheel:c,...j})=>{const p=i=>{try{i.preventDefault();const f=i.currentTarget;f.scrollTop+=i.deltaY}catch{i.preventDefault()}c&&c(i)};return e.jsx(a.CommandList,{...j,onWheel:p,children:t})},te=(...t)=>t.filter(Boolean).join(" ");function ze({pages:t,selectedParentId:c,onChange:j,className:p,id:i="parentPage",currentPage:f}){const[m,h]=o.useState(!1),[g,T]=o.useState(""),O=v.useChaiFeatureFlag("enable-add-page-dropdown");O||(p="w-full rounded-md border border-gray-300 px-3 py-2");const b=o.useMemo(()=>!t||t.length===0?[]:t.filter(x=>!w.isEmpty(x.slug)).filter(x=>x.slug!=="/").sort((x,y)=>x.slug.localeCompare(y.slug)),[t]),R=o.useMemo(()=>{if(!g.trim())return b;const n=g.toLowerCase();return b.filter(x=>x.name.toLowerCase().includes(n)||x.slug.toLowerCase().includes(n))},[b,g]),S=n=>Math.max(0,(n.match(/\//g)||[]).length-1),C=n=>" ".repeat(n),d=n=>{if(n==="/")return"/";const x=n.split("/").filter(Boolean);if(x.length<=1){const y=x[0]||"";return`/${_.removeSlugExtension(y)}`}return`/${_.removeSlugExtension(x[x.length-1])}`},l=()=>{if(!c||c==="none")return"None";const n=b.find(x=>x.id===c);return n?`${n.name} (${d(n.slug)})`:"None"};return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:i,className:"text-sm",children:"Parent"}),O?e.jsxs(a.Popover,{open:m,onOpenChange:h,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{id:i,variant:"outline",role:"combobox",className:te("w-full justify-between",p),"data-testid":"parent-page-selector",children:[l(),e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"relative border-none py-2",children:e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search pages...",className:"h-8 pl-8 text-xs",value:g,onChange:n=>T(n.target.value)})]})})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No pages found."}),e.jsxs(a.CommandGroup,{children:[e.jsxs(a.CommandItem,{value:"none",onSelect:()=>{j(""),h(!1),T("")},className:"flex cursor-pointer items-center justify-between",children:[e.jsx("span",{children:"None"}),e.jsx(N.Check,{className:te("mr-2 h-4 w-4",c?"opacity-0":"opacity-100")})]}),R.map(n=>{const x=C(S(n.slug)),y=d(n.slug),W=e.jsxs("span",{className:"flex items-center text-sm",children:[x,n.name,e.jsxs("span",{className:"text-xs text-gray-500",children:[" (",y,")"]})]});return e.jsxs(a.CommandItem,{value:n.id,onSelect:()=>{j(n.id),h(!1),T("")},className:"flex cursor-pointer items-center justify-between whitespace-pre-wrap",children:[e.jsx("span",{children:W}),e.jsx(N.Check,{className:te("mr-2 h-4 w-4 shrink-0",c===n.id?"opacity-100":"opacity-0")})]},n.id)})]})]})]})})]}):e.jsxs("select",{id:i,value:c||"none",onChange:n=>j(n.target.value),className:p,"data-testid":"parent-page-selector",children:[e.jsx("option",{value:"none",children:"None"}),b.map(n=>{const x=S(n.slug),y=x>0?C(x):"",W=d(n.slug);return(f==null?void 0:f.id)===n.id||n.slug.startsWith(f==null?void 0:f.slug)?null:e.jsxs("option",{value:n.id,children:[y,n.name," (",W,")"]},n.id)})]})]})}const _e=(...t)=>t.filter(Boolean).join(" "),Ve=({templates:t,selectedTemplateId:c,onSelectTemplate:j,isLoading:p=!1})=>{const[i,f]=o.useState(""),[m,h]=o.useState(!1),[g,T]=o.useState(""),O=v.useChaiFeatureFlag("enable-add-page-dropdown");if(o.useEffect(()=>{if(c){const d=t.find(l=>l.id===c);o.startTransition(()=>f((d==null?void 0:d.preview)||""))}else o.startTransition(()=>f(""))},[c,t]),p)return e.jsx("div",{className:"flex h-fit items-center justify-center text-sm text-gray-500",children:"Loading templates..."});if(t.length===0)return null;const b={};t.forEach(d=>{const l=d.libraryName;b[l]||(b[l]=[]),b[l].push(d)});const R=Object.entries(b).reduce((d,[l,n])=>{const x=n.filter(y=>y.name.toLowerCase().includes(g.toLowerCase())||l.toLowerCase().includes(g.toLowerCase()));return x.length>0&&(d[l]=x),d},{}),S=t.find(d=>d.id===c),C=S?w.startCase(S.name):"No Template";return e.jsxs("div",{className:"space-y-4",children:[O?e.jsxs(a.Popover,{open:m,onOpenChange:h,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",className:"w-full justify-between",children:[C,e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search templates...",className:"h-8 pl-8 text-xs",value:g,onChange:d=>T(d.target.value)})]})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No templates found."}),Object.entries(R).map(([d,l])=>e.jsx(a.CommandGroup,{heading:d,children:l.map(n=>e.jsxs(a.CommandItem,{value:n.id,onSelect:()=>{j(n.id),h(!1),T("")},className:"flex cursor-pointer items-center justify-between",children:[w.startCase(n.name),e.jsx(N.Check,{className:_e("mr-2 h-4 w-4",c===n.id?"opacity-100":"opacity-0")})]},n.id))},d))]})]})})]}):e.jsxs("select",{className:"w-full rounded-md border border-gray-300 px-3 py-2",value:c,onChange:d=>j(d.target.value),children:[e.jsx("option",{value:"",children:"No Template"}),Object.entries(b).map(([d,l])=>e.jsx("optgroup",{label:d,children:l.map(n=>e.jsx("option",{value:n.id,children:w.startCase(n.name)},n.id))},d))]}),i&&e.jsxs("div",{className:"mt-3 overflow-hidden rounded border",children:[e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("img",{src:i,alt:"Template Preview",className:"w-full object-contain"})}),e.jsx("div",{className:"border-t bg-gray-50 p-2 text-xs text-gray-500",children:"Template preview"})]})]})},$e=()=>{const t=k.useApiUrl(),c=k.useFetch();return je.useQuery({queryKey:[k.ACTIONS.GET_LIBRARIES],staleTime:"static",queryFn:async()=>await c(t,{action:k.ACTIONS.GET_LIBRARIES})||[]})},Qe=t=>{const c=k.useApiUrl(),j=k.useFetch();return je.useQuery({queryKey:[k.ACTIONS.GET_TEMPLATES_BY_TYPE,t],staleTime:"static",enabled:!!t,queryFn:async()=>{const p=await j(c,{action:k.ACTIONS.GET_TEMPLATES_BY_TYPE,data:{pageType:t}});return(t?w.filter(p,{pageType:t}):p)||[]}})},Ye=t=>{const{data:c=[],isLoading:j}=Qe(t),{data:p=[],isLoading:i}=$e(),f=o.useMemo(()=>j||i?[]:c.map(h=>{const g=w.find(p,{id:h.library});return{...h,libraryName:(g==null?void 0:g.type)!=="shared"?"Site Library":(g==null?void 0:g.name)+" Library",libraryType:g==null?void 0:g.type}}),[c,p,j,i]),m=o.useMemo(()=>w.groupBy(f,"libraryName"),[f]);return{data:f,groupedData:m,isLoading:j||i}},z=(...t)=>t.filter(Boolean).join(" ");function He({addEditPage:t,close:c,closePanel:j}){var xe,ge;const{data:p}=k.usePageTypes(),i=o.useMemo(()=>p??[],[p]),f=k.useChangePage(),m=!!(t!=null&&t.id),{data:h}=k.useWebsitePages(),{mutate:g,isPending:T}=k.useCreatePage(),{mutate:O,isPending:b}=k.useUpdatePage(),[R,S]=o.useState(null),[C,d]=o.useState(!0),[l,n]=o.useState((t==null?void 0:t.pageType)??"page"),{hasPermission:x}=a.usePermissions(),y=x(k.PAGES_PERMISSIONS.CHANGE_PAGE_TYPE),[W,G]=o.useState(!1),[ye,ve]=o.useState(""),{selectedLang:Se,fallbackLang:Ce}=a.useLanguages(),ne=Se||Ce,[V,H]=o.useState(""),[ae,Q]=o.useState(!1),le=o.useMemo(()=>{const s=i.find(u=>u.key===l);return(s==null?void 0:s.hasSlug)===!1},[l,i]),[D,Ne]=o.useState((t==null?void 0:t.parent)??""),[M,re]=o.useState((t==null?void 0:t.name)??""),[F,oe]=o.useState((t==null?void 0:t.dynamic)??!1),[B,Y]=o.useState(F?"":((t==null?void 0:t.slug)??"").split("/").pop()||""),[ie,ce]=o.useState((t==null?void 0:t.dynamicSlugCustom)??""),[ue,be]=o.useState(!0),[we,P]=o.useState(!1),[E,ke]=o.useState(""),{data:me,isLoading:Le}=Ye(l),$=T||b,he=v.useChaiFeatureFlag("enable-add-page-dropdown"),ee=o.useMemo(()=>!m||!(t!=null&&t.id)||!h?null:h.find(s=>s.id===t.id),[m,t==null?void 0:t.id,h]),Te=(ee==null?void 0:ee.online)||!1,De=o.useMemo(()=>!m||!(t!=null&&t.id)||!h?!1:h.some(s=>s.parent===t.id),[m,t==null?void 0:t.id,h]),r=i.find(s=>s.key===l),U=s=>{if(m&&l!==s){ve(s),G(!0),H(""),Q(!1);return}n(s),H(""),Q(!1)},pe=()=>{n(ye),G(!1),oe(!1)},Ie=s=>{oe(s),s?Y(""):ce("")},Fe=s=>{if(Ne(s),s&&s!=="none"){const u=h==null?void 0:h.find(L=>L.id===s),q=(u==null?void 0:u.slug)||"";if(B.startsWith(q)){const L=B.slice(q.length).replace(/^\/+/,"");Y(L)}else Y(B.replace(/^\/+/,""))}else Y(B?`${B}`:"")},Be=s=>{ke(s)},qe=()=>M.trim()?F&&!w.isEmpty(B)?(S("Slug must be empty when using dynamic slug"),!1):F&&!ue?(S("Dynamic slug is invalid"),!1):!0:(J.toast.error("Name is required"),!1),Ae=()=>{const s={pageType:r==null?void 0:r.key,name:M,slug:"",hasSlug:!1};m?O({id:t==null?void 0:t.id,name:M},{onSuccess:()=>{J.toast.success((r==null?void 0:r.name)+" updated successfully"),c()}}):g(s,{onSuccess:u=>{c(),f(u.page.id,j)}})},Oe=(s,u)=>{if(!s.trim()&&!F)return S("Child page slug is required"),!1;const q=_.removeSlugExtension(u),L=_.combineParentChildSlugs(q,s);return Object.keys(k.LANGUAGES).some(Z=>L===`/${Z}`||(L==null?void 0:L.startsWith(`/${Z}/`)))?(S("Slugs cannot start with a language code for primary page"),!1):!0},We=(s,u)=>{const q=_.removeSlugExtension(u),L=_.combineParentChildSlugs(q,s),I={pageType:l,name:M,slug:L.replace(/\/$/,""),parent:D,dynamic:F,hasSlug:!0,template:E||void 0,tracking:{},seo:{},jsonLD:{}};if(F&&(I.dynamicSlugCustom=ie),m){const A=w.pick(I,["pageType","parent","name","slug","dynamic","dynamicSlugCustom"]);O({id:t==null?void 0:t.id,...A},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}})}else{const A=w.find(i,{key:l});A!=null&&A.trackingDefault&&(I.tracking=A.trackingDefault);const{seo:Z,jsonLD:Ge}=fe.getSeoDefaults(A,ne);w.set(I,"seo",Z),w.set(I,"jsonLD",Ge),g(I,{onSuccess:Me=>{c(),f(Me.page.id,j)}})}},Re=()=>{const s={pageType:l,name:M,slug:B===""?"/":`/${B.replace(/\/$/,"")}`,template:E||void 0,parent:null,tracking:{}};if(m)O({id:t==null?void 0:t.id,...s},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}});else{const u=w.find(i,{key:l});u!=null&&u.trackingDefault&&(s.tracking=u.trackingDefault);const{seo:q,jsonLD:L}=fe.getSeoDefaults(u,ne);w.set(s,"seo",q),w.set(s,"jsonLD",L),g(s,{onSuccess:I=>{var A;(A=I==null?void 0:I.page)!=null&&A.id&&f(I.page.id,j),c()}})}},de=s=>{if(s.preventDefault(),S(null),!!qe()){if(!(r!=null&&r.hasSlug)){Ae();return}if(D&&D!=="none"){const u=h==null?void 0:h.find(L=>L.id===D),q=(u==null?void 0:u.slug)||"";if(!Oe(B,q))return;We(B,q)}else Re()}},{pagesType:se,partialsType:K}=o.useMemo(()=>{const s=u=>V?u.name.toLowerCase().includes(V.toLowerCase())||u.key.toLowerCase().includes(V.toLowerCase()):!0;return{pagesType:i.filter(u=>u.hasSlug!==!1&&s(u)),partialsType:i.filter(u=>u.hasSlug===!1&&s(u))}},[i,V]);return r!=null&&r.hasSlug?e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(a.Popover,{open:ae,onOpenChange:Q,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:z("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:V,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No page type found."}),m?le?e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsx(a.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsxs(e.Fragment,{children:[se.length>0&&e.jsx(a.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}),K.length>0&&e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>U(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:m?le?e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsx("optgroup",{label:"Pages",children:i.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsxs(e.Fragment,{children:[e.jsx("optgroup",{label:"Pages",children:i.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}),e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})]})}),W&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(v.Button,{variant:"outline",size:"sm",onClick:()=>G(!1),children:"Cancel"}),e.jsx(v.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]})]}),!m&&(r==null?void 0:r.hasSlug)&&me.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.Label,{className:"mb-1 block text-sm",children:"Template"}),e.jsx(Ve,{templates:me,selectedTemplateId:E,onSelectTemplate:Be,isLoading:Le})]}),e.jsx(ze,{pages:h,selectedParentId:D,onChange:Fe,currentPage:t}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(v.Input,{id:"name",value:M,onChange:s=>re(s.target.value),required:!0,"aria-required":"true",placeholder:"Enter page name"})]}),(r==null?void 0:r.dynamicSegments)&&D&&D!=="none"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"useDynamicSlug",checked:F,onChange:s=>Ie(s.target.checked),className:"rounded border-gray-300"}),e.jsx(a.Label,{htmlFor:"useDynamicSlug",className:"text-sm",children:"Use Dynamic Slug"})]}),F&&e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"space-y-0.5",children:e.jsx(Ue,{value:ie,onChange:ce,dynamicPattern:(r==null?void 0:r.dynamicSlug)||"{{id}}",placeholder:"Enter custom slug part (optional)",onValidationChange:be})})})]}),(!(r!=null&&r.dynamicSegments)||!F)&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx(_.SlugInput,{value:B,onChange:s=>{var u;Y(s),m&&s!==(((u=t==null?void 0:t.slug)==null?void 0:u.split("/").pop())||"")?P(!!(Te||De)):P(!1)},placeholder:D&&D!=="none"?"Enter page slug":l==="page"?"Leave empty for home page":"Required - e.g. your-slug",parentSlug:D&&D!=="none"?(ge=h==null?void 0:h.find(s=>s.id===D))==null?void 0:ge.slug:void 0,onValidationChange:d}),R&&e.jsx("p",{className:"text-xs text-red-500",children:R}),we&&e.jsx("div",{className:"mt-4 rounded-md border border-amber-200 bg-amber-50 p-3",children:e.jsxs("div",{className:"flex items-start space-x-2",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-amber-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-amber-800",children:"Slug Change Warning"}),e.jsx("div",{className:"mt-1 text-sm text-amber-700",children:e.jsx("p",{children:"The previous URL and any child pages will become inaccessible. You may want to set up a redirect to avoid broken links."})})]})]})})]}),e.jsx(v.Button,{disabled:$||!C&&(!(r!=null&&r.dynamicSegments)||!F)||F&&!ue,type:"submit",className:"w-full",children:m?$?"Updating...":"Update page":$?"Creating...":"Create Page"})]}):e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(a.Popover,{open:ae,onOpenChange:Q,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:z("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:V,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"max-h-[200px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No page type found."}),e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>{U(s.key),Q(!1)},className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>U(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})}),W&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(v.Button,{variant:"outline",size:"sm",onClick:()=>G(!1),children:"Cancel"}),e.jsx(v.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:(xe=i.find(s=>s.key===l))==null?void 0:xe.helpText})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(v.Input,{id:"name",value:M,onChange:s=>re(s.target.value),required:!0,"aria-required":"true"})]}),e.jsx(v.Button,{disabled:$,type:"submit",className:"w-full",children:m?$?"Updating...":"Update "+(r==null?void 0:r.name):$?"Creating...":"Create "+(r==null?void 0:r.name)})]})}exports.default=He;
|