@chaibuilder/pages 0.16.13 → 0.16.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{2AITGKQY-D1mM4eEh.js → 2AITGKQY-B7xwscsX.js} +2 -2
- package/dist/{2AITGKQY-AK2WgbeT.cjs → 2AITGKQY-B9AnRLq_.cjs} +1 -1
- package/dist/{NCMVHL6D-BeRsWdGV.js → NCMVHL6D-B1mwht0Q.js} +4 -4
- package/dist/{NCMVHL6D-DItDf9IY.cjs → NCMVHL6D-CRMC-wXy.cjs} +1 -1
- package/dist/{ZDWCUMSJ-COSBY-at.cjs → ZDWCUMSJ-BqqPEOij.cjs} +1 -1
- package/dist/{ZDWCUMSJ-D6caRaY7.js → ZDWCUMSJ-CxKNtXtp.js} +1 -1
- package/dist/{add-new-language-page-CQcFi0Tp.cjs → add-new-language-page-D2a6GK-7.cjs} +1 -1
- package/dist/{add-new-language-page-nnaUe-qk.js → add-new-language-page-DD0qvJJs.js} +2 -2
- package/dist/{add-new-page-DxObnvo_.cjs → add-new-page-01GDCaa4.cjs} +1 -1
- package/dist/{add-new-page-Ba1fq6LH.js → add-new-page-CYtuChN1.js} +1 -1
- package/dist/ai-panel-content-DfdnvlS8.js +123 -0
- package/dist/ai-panel-content-Ouz6pu_0.cjs +1 -0
- package/dist/ai-panel-default-lang-Bi2fH1so.js +317 -0
- package/dist/ai-panel-default-lang-N1pb8rzQ.cjs +3 -0
- package/dist/{ai-panel-other-lang-B4euTuod.js → ai-panel-other-lang-2JPRSyO1.js} +10 -9
- package/dist/ai-panel-other-lang-BysU1464.cjs +1 -0
- package/dist/ai-prompt-input-DadL_cng.js +1071 -0
- package/dist/ai-prompt-input-JeIqWZco.cjs +1 -0
- package/dist/{ai-translation-prompt-CVuPbgXw.js → ai-translation-prompt-B0si-R0R.js} +1 -1
- package/dist/{ai-translation-prompt-Ip7w2_Ey.cjs → ai-translation-prompt-CQb1L7NM.cjs} +1 -1
- package/dist/{delete-page-CbY8q5M3.cjs → delete-page-C8Nt7IYF.cjs} +1 -1
- package/dist/{delete-page-SX9X35nA.js → delete-page-_96Di9yN.js} +1 -1
- package/dist/{digital-asset-manager-CIMo79Di.cjs → digital-asset-manager-B5FQGtGY.cjs} +1 -1
- package/dist/{digital-asset-manager-SAFNO_mx.js → digital-asset-manager-jfnmWRJj.js} +1 -1
- package/dist/{duplicate-page-CXK2HcxD.cjs → duplicate-page-BNjfZ7Wd.cjs} +1 -1
- package/dist/{duplicate-page-5SwLvmkX.js → duplicate-page-CERjaPIW.js} +9 -9
- package/dist/{dynamic-page-selector-Crd3y4Hk.cjs → dynamic-page-selector-Bpz_bvRu.cjs} +1 -1
- package/dist/{dynamic-page-selector-DfcuTqRN.js → dynamic-page-selector-XEWV4iCf.js} +1 -1
- package/dist/{index-Bz7smSC0.cjs → index-Pdb5tSRL.cjs} +2 -2
- package/dist/{index-EnM7J19_.js → index-e9WlBH0R.js} +70 -70
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/{json-diff-viewer-CDwpbuag.js → json-diff-viewer-DyvKomxd.js} +1 -1
- package/dist/{json-diff-viewer-D34kDA_c.cjs → json-diff-viewer-H-2DkGza.cjs} +1 -1
- package/dist/{lang-panel-CUIeO5bb.js → lang-panel-BWP5A-FD.js} +2 -2
- package/dist/{lang-panel-CaFrYllL.cjs → lang-panel-DcZ7u4em.cjs} +1 -1
- package/dist/{mark-as-template-D0dLQaIB.js → mark-as-template-1oVraE1x.js} +1 -1
- package/dist/{mark-as-template-v182tmN6.cjs → mark-as-template-B_FyVRRO.cjs} +1 -1
- package/dist/{no-language-page-content-ByRFD_qA.js → no-language-page-content-CEci_4j7.js} +1 -1
- package/dist/{no-language-page-content-Bk4fEx_p.cjs → no-language-page-content-JO4YYUx7.cjs} +1 -1
- package/dist/{page-creator-BnvaGZVI.cjs → page-creator-BGgoOA92.cjs} +1 -1
- package/dist/{page-creator-Bh0IUGR3.js → page-creator-DJJFl7px.js} +2 -2
- package/dist/{page-lock-request-C2b1kqyA.cjs → page-lock-request-BoYzkcyt.cjs} +1 -1
- package/dist/{page-lock-request-CaNqxfD6.js → page-lock-request-WzpcD2ZN.js} +6 -6
- package/dist/{page-locked-by-dialog--WLDdkw9.js → page-locked-by-dialog-Djvjp2Hx.js} +1 -1
- package/dist/{page-locked-by-dialog-90ElC8aG.cjs → page-locked-by-dialog-bvI27OZ6.cjs} +1 -1
- package/dist/{page-manager-new-SNRQn7Az.cjs → page-manager-new-CMfGorRQ.cjs} +1 -1
- package/dist/{page-manager-new-Bo4-zwfW.js → page-manager-new-DmVX0qLk.js} +14 -14
- package/dist/{page-manager-search-and-filter-BETHSa3y.js → page-manager-search-and-filter-DbUoW8Di.js} +1 -1
- package/dist/{page-manager-search-and-filter-hyUIHOD_.cjs → page-manager-search-and-filter-Dgh8iyGp.cjs} +1 -1
- package/dist/{page-revisions-content-BCMjvZRZ.cjs → page-revisions-content-CwoXXE53.cjs} +1 -1
- package/dist/{page-revisions-content-VWthKL7O.js → page-revisions-content-CxEJGxLY.js} +18 -18
- package/dist/pages.css +1 -1
- package/dist/{publish-pages-content-CaBwfekc.cjs → publish-pages-content-BRu7qwAo.cjs} +1 -1
- package/dist/{publish-pages-content-6N7aEcM1.js → publish-pages-content-CfAlmivf.js} +6 -6
- package/dist/{save-to-lib-YYBxY7MV.js → save-to-lib-BCaBfh0I.js} +1 -1
- package/dist/{save-to-lib-CtGpDkC6.cjs → save-to-lib-DpyJA0y1.cjs} +1 -1
- package/dist/{selected-block-display-DdW-DWF1.js → selected-block-display-BmNhvYKu.js} +1 -1
- package/dist/{selected-block-display-BEbuJn0l.cjs → selected-block-display-CqnwyGRp.cjs} +1 -1
- package/dist/{seo-panel-CqJDhbj-.js → seo-panel-BH8fcGqr.js} +1 -1
- package/dist/{seo-panel-B9P7fXjo.cjs → seo-panel-D-nKfsRJ.cjs} +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +39 -39
- package/dist/{shared-json-ld-CyxmC9y5.cjs → shared-json-ld-m_OsVv8h.cjs} +1 -1
- package/dist/{shared-json-ld-DxEPILj_.js → shared-json-ld-zTDoJzUv.js} +1 -1
- package/dist/{slug-input-j5z5ZQn9.js → slug-input-CumDDlCk.js} +1 -1
- package/dist/{slug-input-RNiSrU3p.cjs → slug-input-vzNtu37S.cjs} +1 -1
- package/dist/{theme-panel-footer-CCsiDIVl.cjs → theme-panel-footer-CKccBcd9.cjs} +1 -1
- package/dist/{theme-panel-footer-DD2yalfG.js → theme-panel-footer-CdUmjB-e.js} +1 -1
- package/dist/{unmark-as-template-B2hKhAHn.js → unmark-as-template-6ew-7bf8.js} +1 -1
- package/dist/{unmark-as-template-DXjLbqOM.cjs → unmark-as-template-BNFOsxIg.cjs} +1 -1
- package/dist/{unpublish-page-BdJScWMX.cjs → unpublish-page-BZQpTpU3.cjs} +1 -1
- package/dist/{unpublish-page-BvB1PGSz.js → unpublish-page-BomE76Wg.js} +1 -1
- package/dist/{web-preview-BI4jd0O7.cjs → web-preview-C5QTX7bS.cjs} +1 -1
- package/dist/{web-preview-CwVpkcwU.js → web-preview-jo8lnpEx.js} +1 -1
- package/package.json +1 -1
- package/dist/ai-panel-content-B2AgBWqo.cjs +0 -1
- package/dist/ai-panel-content-M1UnzG_f.js +0 -54
- package/dist/ai-panel-default-lang-CHOFEwmV.js +0 -313
- package/dist/ai-panel-default-lang-sy6vkQJh.cjs +0 -3
- package/dist/ai-panel-other-lang-BwjSDD3L.cjs +0 -1
- package/dist/ai-prompt-input-B_NRADBT.js +0 -988
- package/dist/ai-prompt-input-DcyVXcLG.cjs +0 -1
|
@@ -540,7 +540,7 @@ const ri = ({ query: e, uuid: t }) => {
|
|
|
540
540
|
rejectTakeOver: u,
|
|
541
541
|
requestTakeOver: o
|
|
542
542
|
};
|
|
543
|
-
}, Ei = F(() => import("./no-language-page-content-
|
|
543
|
+
}, Ei = F(() => import("./no-language-page-content-CEci_4j7.js")), pi = F(() => import("./page-locked-by-dialog-Djvjp2Hx.js")), rn = F(() => import("./page-lock-request-WzpcD2ZN.js")), yi = ({ isFetchingPage: e }) => {
|
|
544
544
|
const { pageLock: t, requestTakeOver: n } = mi(), { currentEditor: s, lockingStatus: r, setLockingStatus: a, realtimePageLockEnabled: i } = Ie(), { data: o, isFetching: c } = ui(s), [u] = le(), d = u.get("page"), [f] = Nn(), h = W(), g = z(() => {
|
|
545
545
|
n();
|
|
546
546
|
}, [n]);
|
|
@@ -801,7 +801,7 @@ const On = Ee(null), Dn = () => {
|
|
|
801
801
|
},
|
|
802
802
|
placeholderData: (r) => r || {}
|
|
803
803
|
});
|
|
804
|
-
}, Ti = F(() => import("./page-manager-new-
|
|
804
|
+
}, Ti = F(() => import("./page-manager-new-DmVX0qLk.js")), Ls = ({ children: e }) => {
|
|
805
805
|
const { t } = _e(), [n, s] = le(), r = n.get("page"), { data: a, isFetching: i } = ie(), { data: o, isFetching: c } = Is(), [u, d] = K(!1), [f, h] = K(!0), { savePage: g } = xe(), p = !!r && !he(a), S = Q(() => {
|
|
806
806
|
if (!o || c) return !1;
|
|
807
807
|
const A = o.find((b) => b.slug === "/");
|
|
@@ -849,7 +849,7 @@ const On = Ee(null), Dn = () => {
|
|
|
849
849
|
}
|
|
850
850
|
) })
|
|
851
851
|
] });
|
|
852
|
-
}, Si = F(() => import("./add-new-language-page-
|
|
852
|
+
}, Si = F(() => import("./add-new-language-page-DD0qvJJs.js")), _i = () => {
|
|
853
853
|
const e = oe("topLeftCorner", null);
|
|
854
854
|
return e ? /* @__PURE__ */ l("div", { className: "max-h-9 w-full overflow-hidden pr-2", children: Fr.createElement(e, {}) }) : null;
|
|
855
855
|
}, Pi = ({
|
|
@@ -992,7 +992,7 @@ function wi() {
|
|
|
992
992
|
/* @__PURE__ */ l(Ct, { className: "h-8 w-8 rounded-full" })
|
|
993
993
|
] }, t)) });
|
|
994
994
|
}
|
|
995
|
-
const bi = j.lazy(() => import("./page-revisions-content-
|
|
995
|
+
const bi = j.lazy(() => import("./page-revisions-content-CxEJGxLY.js"));
|
|
996
996
|
function Ii() {
|
|
997
997
|
const [e, t] = j.useState(!1);
|
|
998
998
|
return /* @__PURE__ */ l(As, { children: /* @__PURE__ */ m(jt, { delayDuration: 0, children: [
|
|
@@ -1231,7 +1231,7 @@ const an = ({
|
|
|
1231
1231
|
R.error("Failed to change slug");
|
|
1232
1232
|
}
|
|
1233
1233
|
});
|
|
1234
|
-
}, ki = F(() => import("./publish-pages-content-
|
|
1234
|
+
}, ki = F(() => import("./publish-pages-content-CfAlmivf.js"));
|
|
1235
1235
|
function Oi({
|
|
1236
1236
|
showModal: e = !1,
|
|
1237
1237
|
onClose: t = () => console.log("Cancelled")
|
|
@@ -1312,7 +1312,7 @@ function xn({
|
|
|
1312
1312
|
/* @__PURE__ */ l(Yt, { side: n, sideOffset: 10, children: /* @__PURE__ */ l("p", { children: t }) })
|
|
1313
1313
|
] }) }) : e;
|
|
1314
1314
|
}
|
|
1315
|
-
const Ri = F(() => import("./unpublish-page-
|
|
1315
|
+
const Ri = F(() => import("./unpublish-page-BomE76Wg.js")), Ui = F(() => import("./translation-warning-modal-DalBhNQy.js")), Mi = () => {
|
|
1316
1316
|
const { t: e } = _e(), { selectedLang: t, fallbackLang: n } = Se(), s = oe("getPreviewUrl", async (h) => h), [r, a] = K(""), { data: i } = ie(), { data: o } = Ge(), { data: c } = Le(), u = Q(
|
|
1317
1317
|
() => {
|
|
1318
1318
|
var h;
|
|
@@ -1608,7 +1608,7 @@ const Vi = ({
|
|
|
1608
1608
|
) })
|
|
1609
1609
|
] })
|
|
1610
1610
|
] });
|
|
1611
|
-
}, Hi = F(() => import("./add-new-page-
|
|
1611
|
+
}, Hi = F(() => import("./add-new-page-CYtuChN1.js")), Qi = F(() => import("./delete-page-_96Di9yN.js")), $i = F(() => import("./duplicate-page-CERjaPIW.js")), zi = F(() => import("./mark-as-template-1oVraE1x.js")), ji = F(() => import("./unmark-as-template-6ew-7bf8.js")), Wi = F(() => import("./unpublish-page-BomE76Wg.js")), Yi = () => {
|
|
1612
1612
|
const [e, t] = K(null), [n, s] = K(null), [r, a] = K(null), [i, o] = K(null), [c, u] = K(null), [d, f] = K(null), { data: h, isFetching: g } = be(), { selectedLang: p, fallbackLang: S } = Se(), { data: P } = Ge(), T = P == null ? void 0 : P.find((k) => k.lang === p), { isLocked: y } = Ie(), A = !(h != null && h.slug), [, b] = te(On);
|
|
1613
1613
|
if (!h) return null;
|
|
1614
1614
|
const B = (k) => {
|
|
@@ -1689,7 +1689,7 @@ const Vi = ({
|
|
|
1689
1689
|
), Ji = ({ hasDynamicPage: e }) => /* @__PURE__ */ l(Ns, { children: /* @__PURE__ */ m("div", { className: "flex min-w-[300px] max-w-[400px] flex-col items-center justify-center rounded-lg border bg-white p-4 shadow-lg", children: [
|
|
1690
1690
|
/* @__PURE__ */ l("h1", { className: "text-lg font-medium", children: e ? "Select a page" : "No pages found" }),
|
|
1691
1691
|
/* @__PURE__ */ l("p", { className: "pt-2 text-center text-sm font-light text-gray-600", children: e ? "Please select a page from the list in the top header. This will enable you to edit the page." : "Please add a new page" })
|
|
1692
|
-
] }) }), Zi = F(() => import("./dynamic-page-selector-
|
|
1692
|
+
] }) }), Zi = F(() => import("./dynamic-page-selector-XEWV4iCf.js")), Xi = () => {
|
|
1693
1693
|
const { dynamicPage: e, allLangPages: t, isFetching: n } = ai(), s = t.length > 0;
|
|
1694
1694
|
return n ? null : /* @__PURE__ */ m("div", { className: "relative", children: [
|
|
1695
1695
|
!e && /* @__PURE__ */ l(Ji, { hasDynamicPage: s }),
|
|
@@ -2034,7 +2034,7 @@ const Vi = ({
|
|
|
2034
2034
|
[n, t]
|
|
2035
2035
|
)
|
|
2036
2036
|
};
|
|
2037
|
-
}, ho = F(() => import("./ai-panel-content-
|
|
2037
|
+
}, ho = F(() => import("./ai-panel-content-DfdnvlS8.js").then((e) => e.b)), Os = "chai-chat-panel", go = ({ 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: [
|
|
2038
2038
|
/* @__PURE__ */ l("title", { children: "ai" }),
|
|
2039
2039
|
/* @__PURE__ */ l("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ l("g", { id: "icon", fill: "currentColor", transform: "translate(64.000000, 64.000000)", children: /* @__PURE__ */ l(
|
|
2040
2040
|
"path",
|
|
@@ -2049,7 +2049,7 @@ const Vi = ({
|
|
|
2049
2049
|
button: mo,
|
|
2050
2050
|
panel: ho,
|
|
2051
2051
|
position: "top"
|
|
2052
|
-
}, po = F(() => import("./lang-panel-
|
|
2052
|
+
}, po = F(() => import("./lang-panel-BWP5A-FD.js")), yo = ({ isActive: e, show: t }) => {
|
|
2053
2053
|
const { data: n } = Re();
|
|
2054
2054
|
return !zt(n, "languages") || !V(n, "languages", []).length ? null : /* @__PURE__ */ l(U, { size: "sm", onClick: t, variant: e ? "default" : "ghost", children: /* @__PURE__ */ l(Ka, { className: "h-4 w-4" }) });
|
|
2055
2055
|
}, Ds = "lang", Ao = {
|
|
@@ -2060,7 +2060,7 @@ const Vi = ({
|
|
|
2060
2060
|
button: yo,
|
|
2061
2061
|
view: "modal",
|
|
2062
2062
|
width: 400
|
|
2063
|
-
}, To = F(() => import("./seo-panel-
|
|
2063
|
+
}, To = F(() => import("./seo-panel-BH8fcGqr.js")), xs = "seo", So = ({ isActive: e, show: t }) => {
|
|
2064
2064
|
const { data: n } = ie(), s = Ci(n == null ? void 0 : n.pageType);
|
|
2065
2065
|
return !zt(s, "hasSlug") || !s.hasSlug ? null : /* @__PURE__ */ l(U, { size: "icon", className: "my-1 p-0", onClick: t, variant: e ? "default" : "ghost", children: /* @__PURE__ */ m(
|
|
2066
2066
|
"svg",
|
|
@@ -3961,7 +3961,7 @@ var yu = (e, t = !1) => {
|
|
|
3961
3961
|
const t = Zs(() => {
|
|
3962
3962
|
const n = this, [s] = _(this, He), [r] = _(this, Qe), [a] = _(this, $e), [i] = _(this, ze), [o] = _(this, yt), [c] = _(this, Ke);
|
|
3963
3963
|
let u;
|
|
3964
|
-
return _(this, je) ? u = _(this, je) : (u = Ys(() => import("./NCMVHL6D-
|
|
3964
|
+
return _(this, je) ? u = _(this, je) : (u = Ys(() => import("./NCMVHL6D-B1mwht0Q.js")), O(this, je, u)), pr(_(this, pt), _(this, Ve)), js(u, Ws({
|
|
3965
3965
|
get queryFlavor() {
|
|
3966
3966
|
return _(n, mt);
|
|
3967
3967
|
},
|
|
@@ -4060,7 +4060,7 @@ var yu = (e, t = !1) => {
|
|
|
4060
4060
|
const t = Zs(() => {
|
|
4061
4061
|
const n = this, [s] = _(this, Je), [r] = _(this, Ze), [a] = _(this, Xe), [i] = _(this, et), [o] = _(this, vt), [c] = _(this, We), [u] = _(this, tt);
|
|
4062
4062
|
let d;
|
|
4063
|
-
return _(this, nt) ? d = _(this, nt) : (d = Ys(() => import("./2AITGKQY-
|
|
4063
|
+
return _(this, nt) ? d = _(this, nt) : (d = Ys(() => import("./2AITGKQY-B7xwscsX.js")), O(this, nt, d)), pr(_(this, Pt), _(this, Ye)), js(d, Ws({
|
|
4064
4064
|
get queryFlavor() {
|
|
4065
4065
|
return _(n, St);
|
|
4066
4066
|
},
|
|
@@ -4246,7 +4246,7 @@ const Zl = Ee(""), Xl = () => {
|
|
|
4246
4246
|
},
|
|
4247
4247
|
[e]
|
|
4248
4248
|
);
|
|
4249
|
-
}, rc = F(() => import("./digital-asset-manager-
|
|
4249
|
+
}, rc = F(() => import("./digital-asset-manager-jfnmWRJj.js")), ac = F(() => import("./save-to-lib-BCaBfh0I.js")), ic = F(() => import("./theme-panel-footer-CdUmjB-e.js")), oc = F(() => import("./web-preview-jo8lnpEx.js"));
|
|
4250
4250
|
Xl();
|
|
4251
4251
|
Za();
|
|
4252
4252
|
Jr(to);
|
|
@@ -4437,7 +4437,7 @@ const vu = () => {
|
|
|
4437
4437
|
console.error("Failed to update metadata");
|
|
4438
4438
|
}
|
|
4439
4439
|
});
|
|
4440
|
-
}, fc = F(() => import("./digital-asset-manager-
|
|
4440
|
+
}, fc = F(() => import("./digital-asset-manager-jfnmWRJj.js")), Iu = ({
|
|
4441
4441
|
assetId: e,
|
|
4442
4442
|
assetUrl: t,
|
|
4443
4443
|
onChange: n,
|
|
@@ -4664,7 +4664,7 @@ const Ec = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), cs = (e) => {
|
|
|
4664
4664
|
n = n.replace(r[0], i);
|
|
4665
4665
|
}
|
|
4666
4666
|
return n;
|
|
4667
|
-
}, Ac = F(() => import("./shared-json-ld-
|
|
4667
|
+
}, Ac = F(() => import("./shared-json-ld-zTDoJzUv.js")), Lu = ({
|
|
4668
4668
|
value: e,
|
|
4669
4669
|
onChange: t,
|
|
4670
4670
|
disabled: n = !1,
|
|
@@ -4844,45 +4844,45 @@ const Ec = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), cs = (e) => {
|
|
|
4844
4844
|
if (typeof window > "u")
|
|
4845
4845
|
throw new Error("@chaibuilder/pages is not available on the server");
|
|
4846
4846
|
export {
|
|
4847
|
-
|
|
4847
|
+
nu as $,
|
|
4848
4848
|
E as A,
|
|
4849
4849
|
Ns as B,
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4850
|
+
Ws as C,
|
|
4851
|
+
Ko as D,
|
|
4852
|
+
Xc as E,
|
|
4853
|
+
eu as F,
|
|
4854
|
+
De as G,
|
|
4855
|
+
pn as H,
|
|
4856
|
+
tu as I,
|
|
4857
|
+
Yc as J,
|
|
4858
|
+
ou as K,
|
|
4859
4859
|
Nt as L,
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4860
|
+
lt as M,
|
|
4861
|
+
du as N,
|
|
4862
|
+
lu as O,
|
|
4863
4863
|
uu as P,
|
|
4864
|
-
|
|
4865
|
-
|
|
4864
|
+
ko as Q,
|
|
4865
|
+
ll as R,
|
|
4866
4866
|
ru as S,
|
|
4867
4867
|
xn as T,
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4868
|
+
yn as U,
|
|
4869
|
+
sl as V,
|
|
4870
|
+
mu as W,
|
|
4871
|
+
Eu as X,
|
|
4872
|
+
ol as Y,
|
|
4873
|
+
pu as Z,
|
|
4874
|
+
yu as _,
|
|
4875
4875
|
oo as a,
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4876
|
+
Wc as a0,
|
|
4877
|
+
cu as a1,
|
|
4878
|
+
X as a2,
|
|
4879
|
+
Lo as a3,
|
|
4880
|
+
Hl as a4,
|
|
4881
|
+
su as a5,
|
|
4882
|
+
xt as a6,
|
|
4883
|
+
Su as a7,
|
|
4884
|
+
gu as a8,
|
|
4885
|
+
hu as a9,
|
|
4886
4886
|
zc as aA,
|
|
4887
4887
|
jc as aB,
|
|
4888
4888
|
Qc as aC,
|
|
@@ -4906,20 +4906,20 @@ export {
|
|
|
4906
4906
|
Jt as aU,
|
|
4907
4907
|
co as aV,
|
|
4908
4908
|
ti as aW,
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4909
|
+
Ms as aa,
|
|
4910
|
+
Oe as ab,
|
|
4911
|
+
rl as ac,
|
|
4912
|
+
fu as ad,
|
|
4913
|
+
iu as ae,
|
|
4914
|
+
au as af,
|
|
4915
|
+
Gt as ag,
|
|
4916
|
+
Zc as ah,
|
|
4917
|
+
ui as ai,
|
|
4918
|
+
mi as aj,
|
|
4919
|
+
N as ak,
|
|
4920
|
+
L as al,
|
|
4921
|
+
nc as am,
|
|
4922
|
+
Dc as an,
|
|
4923
4923
|
Kc as ao,
|
|
4924
4924
|
On as ap,
|
|
4925
4925
|
ie as aq,
|
|
@@ -4947,14 +4947,14 @@ export {
|
|
|
4947
4947
|
Fc as n,
|
|
4948
4948
|
qc as o,
|
|
4949
4949
|
Zl as p,
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4950
|
+
_u as q,
|
|
4951
|
+
J as r,
|
|
4952
|
+
js as s,
|
|
4953
4953
|
on as t,
|
|
4954
4954
|
Cs as u,
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4955
|
+
Au as v,
|
|
4956
|
+
Tu as w,
|
|
4957
|
+
q as x,
|
|
4958
|
+
el as y,
|
|
4959
|
+
qs as z
|
|
4960
4960
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-Pdb5tSRL.cjs"),s=require("@chaibuilder/sdk");exports.ChaiBuilderPagesRealtime=e.ChaiBuilderPagesRealtime;exports.ChaiJsonInput=e.SmartJsonInput;exports.ImagePicker=e.ImagePicker;exports.LanguageSwitcher=e.LanguageSwitcher;exports.NestedPathSelector=e.NestedPathSelector;exports.PermissionChecker=e.PermissionChecker;exports.default=e.ChaiBuilderPages;exports.useActivePage=e.useActivePage;exports.useApiUrl=e.useApiUrl;exports.useBuilderFetch=e.useBuilderFetch;exports.useBuilderPageData=e.useBuilderPageData;exports.useChaiAuth=e.useChaiAuth;exports.useChaiCurrentPage=e.useCurrentPage;exports.useChaiUserInfo=e.useChaiUserInfo;exports.useClearAll=e.useClearAll;exports.useFallbackLang=e.useFallbackLang;exports.useFetch=e.useFetch;exports.useGotoPage=e.useGotoPage;exports.useLanguagePages=e.useLanguagePages;exports.usePageTypes=e.usePageTypes;exports.useReloadPage=e.useReloadPage;exports.useUpdateActivePageMetadata=e.useUpdateActivePageMetadata;exports.useUserPermissions=e.useUserRoleAndPermissions;exports.useWebsitePages=e.useWebsitePages;exports.useWebsiteSetting=e.useWebsiteSetting;Object.keys(s).forEach(a=>{a!=="default"&&!Object.prototype.hasOwnProperty.call(exports,a)&&Object.defineProperty(exports,a,{enumerable:!0,get:()=>s[a]})});
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aW as s, ax as u, aL as t, aJ as i, aK as r, ar as g, aO as P, aP as l,
|
|
1
|
+
import { aW as s, ax as u, aL as t, aJ as i, aK as r, ar as g, aO as P, aP as l, ak as h, an as o, aG as n, aU as c, aq as d, ai as C, aQ as m, f as p, al as f, aR as A, g as U, h as b, aS as k, aT as L, aV as S, b as x, e as B } from "./index-e9WlBH0R.js";
|
|
2
2
|
export * from "@chaibuilder/sdk";
|
|
3
3
|
export {
|
|
4
4
|
s as ChaiBuilderPagesRealtime,
|
|
@@ -21,9 +21,9 @@ export {
|
|
|
21
21
|
A as useGotoPage,
|
|
22
22
|
U as useLanguagePages,
|
|
23
23
|
b as usePageTypes,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
k as useReloadPage,
|
|
25
|
+
L as useUpdateActivePageMetadata,
|
|
26
|
+
S as useUserPermissions,
|
|
27
27
|
x as useWebsitePages,
|
|
28
28
|
B as useWebsiteSetting
|
|
29
29
|
};
|
|
@@ -5,7 +5,7 @@ import { startsWith as T, replace as W, isString as X, trim as Y, isArray as Z,
|
|
|
5
5
|
import { FileJson as F, Loader as ne, Check as B, Copy as H } from "lucide-react";
|
|
6
6
|
import { useState as D, useMemo as A } from "react";
|
|
7
7
|
import { parseDiff as se, Diff as le, Hunk as ae } from "react-diff-view";
|
|
8
|
-
import {
|
|
8
|
+
import { ak as ie, al as oe, A as ce, ai as de } from "./index-e9WlBH0R.js";
|
|
9
9
|
import { useQuery as fe } from "@tanstack/react-query";
|
|
10
10
|
function me(t, n) {
|
|
11
11
|
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"),x=require("@chaibuilder/sdk/ui"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk/ui"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-Pdb5tSRL.cjs"),B=require("@tanstack/react-query");function H(t,r){const o=O.useApiUrl(),n=O.useFetch(),f=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return B.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 K=({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")})]})]})},L=({version:t})=>e.jsx(K,{version:t});function V(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,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as s, Fragment as M } from "react/jsx-runtime";
|
|
2
|
-
import { ao as j, h as T, L as I, ap as F, g as H, aq as O, e as W, ar as f, as as o } from "./index-
|
|
2
|
+
import { ao as j, h as T, L as I, ap as F, g as H, aq as O, e as W, ar as f, as as o } from "./index-e9WlBH0R.js";
|
|
3
3
|
import { useTranslation as G, useLanguages as q } from "@chaibuilder/sdk";
|
|
4
4
|
import { Dialog as B, DialogContent as R, DialogHeader as J, DialogTitle as K, DialogDescription as Q, Alert as V, Label as X, Input as Y, DialogFooter as Z, Button as A, DropdownMenu as ee, DropdownMenuTrigger as se, DropdownMenuContent as ne, DropdownMenuItem as w } from "@chaibuilder/sdk/ui";
|
|
5
5
|
import { find as z, startsWith as E, isEqual as ae, filter as le, get as D, map as te, isEmpty as ie } from "lodash-es";
|
|
@@ -90,7 +90,7 @@ const fe = ({
|
|
|
90
90
|
) })
|
|
91
91
|
] })
|
|
92
92
|
] }) });
|
|
93
|
-
}, Ne = U(() => import("./delete-page-
|
|
93
|
+
}, Ne = U(() => import("./delete-page-_96Di9yN.js")), ye = U(() => import("./unpublish-page-BomE76Wg.js")), Pe = () => {
|
|
94
94
|
const { t: n } = G(), [, g] = pe(F), { selectedLang: t, fallbackLang: i, setSelectedLang: v } = q(), { data: N, isFetching: y } = H(), { data: l } = O(), { data: r } = T(), x = he(() => {
|
|
95
95
|
const a = r == null ? void 0 : r.find((h) => h.key === (l == null ? void 0 : l.pageType));
|
|
96
96
|
return l != null && l.dynamic ? a == null ? void 0 : a.dynamicSlug : "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-Pdb5tSRL.cjs"),C=require("@chaibuilder/sdk"),i=require("@chaibuilder/sdk/ui"),r=require("lodash-es"),j=require("lucide-react"),c=require("react"),k=require("sonner"),G=require("jotai"),L=({page:s,onClose:S})=>{const{t:a}=C.useTranslation(),[o,E]=c.useState(s.slug||""),{mutate:N,isPending:y}=n.useChangeSlug(),{data:l}=n.usePageTypes(),d=r.find(l,{key:s==null?void 0:s.pageType}),f=h=>{if(h.preventDefault(),!(s!=null&&s.primaryPage)&&Object.keys(n.LANGUAGES).some(p=>o===`/${p}`||r.startsWith(o,`/${p}/`))){k.toast.error(a("Error"),{description:a("Slugs cannot start with a language code for primary page")});return}N({...s,slug:o},{onSuccess:S})},m=(s==null?void 0:s.lang)||"";return e.jsx(i.Dialog,{open:!!s,onOpenChange:S,children:e.jsxs(i.DialogContent,{children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:a("Change Slug")}),e.jsx(i.DialogDescription,{className:"text-xs",children:e.jsxs(i.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(j.AlertCircle,{className:"h-4 w-4"}),a("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),e.jsxs("form",{onSubmit:f,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:[a("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:[a("Name"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",s.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(i.Label,{htmlFor:"slug",className:"text-right",children:[a("Slug")," ",e.jsxs("small",{className:"font-light text-gray-500",children:[a("Slug should start with")," /",m]})]}),e.jsx(i.Input,{id:"slug",value:o,onChange:h=>{const x=h.target.value;r.startsWith(x,`/${m}`)&&E(x)},className:"col-span-3",required:!0,pattern:"^/.*",title:a("Slug must start with /"),placeholder:a("Enter page slug")})]})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{type:"submit",disabled:y||!r.startsWith(o,`/${m}`)||r.isEqual(s==null?void 0:s.slug,o),children:a(y?"Changing...":"Change Slug")})})]})]})})},M=c.lazy(()=>Promise.resolve().then(()=>require("./delete-page-C8Nt7IYF.cjs"))),T=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BZQpTpU3.cjs"))),_=()=>{const{t:s}=C.useTranslation(),[,S]=G.useAtom(n.addNewLangAtom),{selectedLang:a,fallbackLang:o,setSelectedLang:E}=C.useLanguages(),{data:N,isFetching:y}=n.useLanguagePages(),{data:l}=n.useCurrentPage(),{data:d}=n.usePageTypes(),f=c.useMemo(()=>{const t=d==null?void 0:d.find(g=>g.key===(l==null?void 0:l.pageType));return l!=null&&l.dynamic?t==null?void 0:t.dynamicSlug:""},[d,l==null?void 0:l.pageType,l==null?void 0:l.dynamic]),[m,h]=c.useState(null),[x,P]=c.useState(null),[p,A]=c.useState(null),{data:b}=n.useWebsiteSetting(),I=r.filter(r.get(b,"languages")||["en"],t=>!r.find(N,{lang:t})&&t!==r.get(b,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:y?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(N,t=>{const g=t.lang,v=t.slug,w=!t.primaryPage,D=g===a;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 ${D?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>E(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:f?`${v}/${f}`: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(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:e.jsx(i.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(j.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),S({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(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),P(t)},children:[e.jsx(j.Power,{className:"size-3"}),s("Unpublish")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(i.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(i.Button,{variant:"default",size:"sm",disabled:r.isEmpty(I),onClick:()=>{S({primaryPage:l==null?void 0:l.id,edit:!1})},children:s("Add new language page")})})}),m&&e.jsx(c.Suspense,{children:e.jsx(M,{page:m,onClose:()=>h(null)})}),x&&e.jsx(c.Suspense,{children:e.jsx(T,{page:x,onClose:()=>P(null)})}),p&&e.jsx(c.Suspense,{children:e.jsx(L,{page:p,onClose:()=>A(null)})})]})};exports.default=_;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import { n as P, h as z } from "./index-
|
|
2
|
+
import { n as P, h as z } from "./index-e9WlBH0R.js";
|
|
3
3
|
import { useTranslation as E } from "@chaibuilder/sdk";
|
|
4
4
|
import { Dialog as L, DialogContent as S, DialogHeader as U, DialogTitle as B, DialogDescription as R, Label as w, Textarea as j, Input as O, Button as c, DialogFooter as X } from "@chaibuilder/sdk/ui";
|
|
5
5
|
import { startCase as y } from "lodash-es";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./index-Pdb5tSRL.cjs"),M=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),y=require("lodash-es"),d=require("lucide-react"),l=require("react"),w=require("sonner"),q=1*1024*1024,A=({page:r,onClose:m})=>{const{t:s}=M.useTranslation(),[g,u]=l.useState(!1),[f,k]=l.useState(""),[c,j]=l.useState(""),[N,p]=l.useState(!1),i=l.useRef(null),T=b.useMarkAsTemplate(),{data:x}=b.usePageTypes(),h=x==null?void 0:x.find(t=>t.key===r.pageType),C=(h==null?void 0:h.name)||y.startCase(r.pageType),I=l.useCallback(t=>{var v;const o=(v=t.target.files)==null?void 0:v[0];if(o){if(o.size>q){w.toast.error(s("File too large"),{description:`${s("Maximum file size is 1MB. Selected file is")} ${(o.size/1024).toFixed(2)}KB.`}),i.current&&(i.current.value="");return}try{p(!0);const n=new FileReader;n.onloadend=()=>{j(n.result),p(!1)},n.readAsDataURL(o)}catch(n){console.error("Error reading file:",n),p(!1),w.toast.error(s("Failed to process image"),{description:n instanceof Error?n.message:s("Unknown error")})}}},[s]),D=()=>{j(""),i.current&&(i.current.value="")},F=()=>{var t;(t=i.current)==null||t.click()},S=()=>{u(!0),T.mutate({page:r,name:r.name,description:f.trim()||void 0,pageType:r.pageType,...c?{previewImage:c}:{}},{onSuccess:()=>{u(!1),m()},onError:()=>{u(!1)}})};return e.jsx(a.Dialog,{open:!0,onOpenChange:m,children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:s("Mark as template")}),e.jsxs(a.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(d.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:y.startCase(r.name)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.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:C})]})]}),e.jsxs("div",{children:[e.jsx(a.Label,{htmlFor:"description",className:"text-xs font-medium",children:s("Description (Optional)")}),e.jsx(a.Textarea,{id:"description",placeholder:s("Describe this template's purpose"),className:"mt-1 h-24 resize-none text-xs",value:f,onChange:t=>k(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.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(a.Input,{type:"file",id:"previewImage",ref:i,onChange:I,accept:"image/*",className:"hidden"}),e.jsx(a.Button,{type:"button",variant:"outline",onClick:F,disabled:N,className:"w-full",children:N?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(d.ImageIcon,{className:"h-4 w-4"}),s("Select image")]})}),c&&e.jsx(a.Button,{type:"button",variant:"outline",size:"icon",onClick:D,children:e.jsx(d.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(a.DialogFooter,{className:g?"pointer-events-none opacity-75":"",children:[e.jsx(a.Button,{variant:"outline",onClick:t=>{t.stopPropagation(),m()},children:s("Cancel")}),e.jsx(a.Button,{variant:"default",disabled:g,onClick:S,children:s("Mark as template")})]})]})})};exports.default=A;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
-
import { i as h, j as u, L as w, B as p } from "./index-
|
|
2
|
+
import { i as h, j as u, L as w, B as p } from "./index-e9WlBH0R.js";
|
|
3
3
|
import { useTranslation as f, useLanguages as P } from "@chaibuilder/sdk";
|
|
4
4
|
import { Card as C, CardHeader as S, CardTitle as L, CardContent as x, CardFooter as N, Button as v } from "@chaibuilder/sdk/ui";
|
|
5
5
|
import { get as B } from "lodash-es";
|
package/dist/{no-language-page-content-Bk4fEx_p.cjs → no-language-page-content-JO4YYUx7.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-Pdb5tSRL.cjs"),i=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),w=require("lodash-es"),x=require("lucide-react"),P=()=>{const{t:a}=i.useTranslation(),[l,g]=n.useSearchParams(),c=l.get("lang"),u=n.useIsLanguagePageCreated(c),{setSelectedLang:d}=i.useLanguages(),h=()=>{const r=new URLSearchParams(window.location.search);r.delete("lang");const o=r.toString(),m=`${window.location.pathname}${o?`?${o}`:""}`;window.history.pushState({},"",m),g(r),d(""),window.dispatchEvent(new PopStateEvent("popstate"))};if(u)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(t.Button,{onClick:h,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"),n=require("@chaibuilder/sdk/ui"),i=require("react"),$=require("./slug-input-RNiSrU3p.cjs"),Y=require("@chaibuilder/sdk"),b=require("lodash-es"),C=require("lucide-react"),w=require("./index-Bz7smSC0.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:o}){const[f,m]=i.useState(null),h=i.useRef(null),[g,L]=i.useState(p+t);i.useEffect(()=>{L(p+t)},[t,p]);const B=v=>{const S=v.target.value;if(!S.startsWith(p)){const O=S.replace(p,""),R=p+O;L(R),c(O);return}const l=S.substring(p.length).replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),a=(l.match(/\./g)||[]).length,x=a<=1;a>1?m("Invalid slug. Only one dot (.) is allowed in the slug"):m(null),o&&o(x);const y=p+l;L(y),c(l)},N=()=>{if(h.current){const v=h.current;setTimeout(()=>{const S=p.length;v.setSelectionRange(S,S)},0)}},W=v=>{const S=v.currentTarget;(S.selectionStart||0)<=p.length&&setTimeout(()=>{const l=p.length;S.setSelectionRange(l,l)},0)};return e.jsx("div",{children:e.jsxs("div",{className:"relative",children:[e.jsxs("p",{className:"text-gray-500 text-xs mb-2",children:[`${p}`," is a dynamic segment of slug"]}),e.jsx(n.Input,{ref:h,value:g,onChange:B,onFocus:N,onClick:W,placeholder:j,className:f?"border-red-500":""}),f&&e.jsx("div",{className:"text-red-500 text-xs mt-1",children:f})]})})}const X=({children:t,onWheel:c,...j})=>{const p=o=>{try{o.preventDefault();const f=o.currentTarget;f.scrollTop+=o.deltaY}catch{o.preventDefault()}c&&c(o)};return e.jsx(n.CommandList,{...j,onWheel:p,children:t})},te=(...t)=>t.filter(Boolean).join(" ");function $e({pages:t,selectedParentId:c,onChange:j,className:p,id:o="parentPage",currentPage:f}){const[m,h]=i.useState(!1),[g,L]=i.useState(""),B=Y.useChaiFeatureFlag("enable-add-page-dropdown");B||(p="w-full rounded-md border border-gray-300 px-3 py-2");const N=i.useMemo(()=>!t||t.length===0?[]:t.filter(x=>!b.isEmpty(x.slug)).filter(x=>x.slug!=="/").sort((x,y)=>x.slug.localeCompare(y.slug)),[t]),W=i.useMemo(()=>{if(!g.trim())return N;const a=g.toLowerCase();return N.filter(x=>x.name.toLowerCase().includes(a)||x.slug.toLowerCase().includes(a))},[N,g]),v=a=>Math.max(0,(a.match(/\//g)||[]).length-1),S=a=>" ".repeat(a),d=a=>{if(a==="/")return"/";const x=a.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 a=N.find(x=>x.id===c);return a?`${a.name} (${d(a.slug)})`:"None"};return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:o,className:"text-sm",children:"Parent"}),B?e.jsxs(n.Popover,{open:m,onOpenChange:h,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{id:o,variant:"outline",role:"combobox",className:te("w-full justify-between",p),"data-testid":"parent-page-selector",children:[l(),e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.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(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search pages...",className:"h-8 pl-8 text-xs",value:g,onChange:a=>L(a.target.value)})]})})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No pages found."}),e.jsxs(n.CommandGroup,{children:[e.jsxs(n.CommandItem,{value:"none",onSelect:()=>{j(""),h(!1),L("")},className:"flex cursor-pointer items-center justify-between",children:[e.jsx("span",{children:"None"}),e.jsx(C.Check,{className:te("mr-2 h-4 w-4",c?"opacity-0":"opacity-100")})]}),W.map(a=>{const x=S(v(a.slug)),y=d(a.slug),O=e.jsxs("span",{className:"flex items-center text-sm",children:[x,a.name,e.jsxs("span",{className:"text-xs text-gray-500",children:[" (",y,")"]})]});return e.jsxs(n.CommandItem,{value:a.id,onSelect:()=>{j(a.id),h(!1),L("")},className:"flex cursor-pointer items-center justify-between whitespace-pre-wrap",children:[e.jsx("span",{children:O}),e.jsx(C.Check,{className:te("mr-2 h-4 w-4 shrink-0",c===a.id?"opacity-100":"opacity-0")})]},a.id)})]})]})]})})]}):e.jsxs("select",{id:o,value:c||"none",onChange:a=>j(a.target.value),className:p,"data-testid":"parent-page-selector",children:[e.jsx("option",{value:"none",children:"None"}),N.map(a=>{const x=v(a.slug),y=x>0?S(x):"",O=d(a.slug);return(f==null?void 0:f.id)===a.id||a.slug.startsWith(f==null?void 0:f.slug)?null:e.jsxs("option",{value:a.id,children:[y,a.name," (",O,")"]},a.id)})]})]})}const ze=(...t)=>t.filter(Boolean).join(" "),_e=({templates:t,selectedTemplateId:c,onSelectTemplate:j,isLoading:p=!1})=>{const[o,f]=i.useState(""),[m,h]=i.useState(!1),[g,L]=i.useState(""),B=Y.useChaiFeatureFlag("enable-add-page-dropdown");if(i.useEffect(()=>{if(c){const d=t.find(l=>l.id===c);f((d==null?void 0:d.preview)||"")}else 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 N={};t.forEach(d=>{const l=d.libraryName;N[l]||(N[l]=[]),N[l].push(d)});const W=Object.entries(N).reduce((d,[l,a])=>{const x=a.filter(y=>y.name.toLowerCase().includes(g.toLowerCase())||l.toLowerCase().includes(g.toLowerCase()));return x.length>0&&(d[l]=x),d},{}),v=t.find(d=>d.id===c),S=v?b.startCase(v.name):"No Template";return e.jsxs("div",{className:"space-y-4",children:[B?e.jsxs(n.Popover,{open:m,onOpenChange:h,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"outline",role:"combobox",className:"w-full justify-between",children:[S,e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.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(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search templates...",className:"h-8 pl-8 text-xs",value:g,onChange:d=>L(d.target.value)})]})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No templates found."}),Object.entries(W).map(([d,l])=>e.jsx(n.CommandGroup,{heading:d,children:l.map(a=>e.jsxs(n.CommandItem,{value:a.id,onSelect:()=>{j(a.id),h(!1),L("")},className:"flex cursor-pointer items-center justify-between",children:[b.startCase(a.name),e.jsx(C.Check,{className:ze("mr-2 h-4 w-4",c===a.id?"opacity-100":"opacity-0")})]},a.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(N).map(([d,l])=>e.jsx("optgroup",{label:d,children:l.map(a=>e.jsx("option",{value:a.id,children:b.startCase(a.name)},a.id))},d))]}),o&&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:o,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"})]})]})},Ve=()=>{const t=w.useApiUrl(),c=w.useFetch();return je.useQuery({queryKey:[w.ACTIONS.GET_LIBRARIES],staleTime:"static",queryFn:async()=>await c(t,{action:w.ACTIONS.GET_LIBRARIES})||[]})},Qe=t=>{const c=w.useApiUrl(),j=w.useFetch();return je.useQuery({queryKey:[w.ACTIONS.GET_TEMPLATES_BY_TYPE,t],staleTime:"static",enabled:!!t,queryFn:async()=>{const p=await j(c,{action:w.ACTIONS.GET_TEMPLATES_BY_TYPE,data:{pageType:t}});return(t?b.filter(p,{pageType:t}):p)||[]}})},Ye=t=>{const{data:c=[],isLoading:j}=Qe(t),{data:p=[],isLoading:o}=Ve(),f=i.useMemo(()=>j||o?[]:c.map(h=>{const g=b.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,o]),m=i.useMemo(()=>b.groupBy(f,"libraryName"),[f]);return{data:f,groupedData:m,isLoading:j||o}},U=(...t)=>t.filter(Boolean).join(" ");function He({addEditPage:t,close:c,closePanel:j}){var xe,ge;const{data:p}=w.usePageTypes(),o=i.useMemo(()=>p??[],[p]),f=w.useChangePage(),m=!!(t!=null&&t.id),{data:h}=w.useWebsitePages(),{mutate:g,isPending:L}=w.useCreatePage(),{mutate:B,isPending:N}=w.useUpdatePage(),[W,v]=i.useState(null),[S,d]=i.useState(!0),[l,a]=i.useState((t==null?void 0:t.pageType)??"page"),{hasPermission:x}=Y.usePermissions(),y=x(w.PAGES_PERMISSIONS.CHANGE_PAGE_TYPE),[O,R]=i.useState(!1),[ye,ve]=i.useState(""),{selectedLang:Se,fallbackLang:Ce}=Y.useLanguages(),ne=Se||Ce,[z,H]=i.useState(""),[ae,V]=i.useState(!1),le=i.useMemo(()=>{const s=o.find(u=>u.key===l);return(s==null?void 0:s.hasSlug)===!1},[l,o]),[T,Ne]=i.useState((t==null?void 0:t.parent)??""),[G,re]=i.useState((t==null?void 0:t.name)??""),[I,oe]=i.useState((t==null?void 0:t.dynamic)??!1),[F,Q]=i.useState(I?"":((t==null?void 0:t.slug)??"").split("/").pop()||""),[ie,ce]=i.useState((t==null?void 0:t.dynamicSlugCustom)??""),[ue,be]=i.useState(!0),[we,P]=i.useState(!1),[E,ke]=i.useState(""),{data:me,isLoading:Le}=Ye(l),_=L||N,he=Y.useChaiFeatureFlag("enable-add-page-dropdown"),ee=i.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=i.useMemo(()=>!m||!(t!=null&&t.id)||!h?!1:h.some(s=>s.parent===t.id),[m,t==null?void 0:t.id,h]),r=o.find(s=>s.key===l),M=s=>{if(m&&l!==s){ve(s),R(!0),H(""),V(!1);return}a(s),H(""),V(!1)},pe=()=>{a(ye),R(!1),oe(!1)},Ie=s=>{oe(s),s?Q(""):ce("")},Fe=s=>{if(Ne(s),s&&s!=="none"){const u=h==null?void 0:h.find(k=>k.id===s),q=(u==null?void 0:u.slug)||"";if(F.startsWith(q)){const k=F.slice(q.length).replace(/^\/+/,"");Q(k)}else Q(F.replace(/^\/+/,""))}else Q(F?`${F}`:"")},qe=s=>{ke(s)},Ae=()=>G.trim()?I&&!b.isEmpty(F)?(v("Slug must be empty when using dynamic slug"),!1):I&&!ue?(v("Dynamic slug is invalid"),!1):!0:(J.toast.error("Name is required"),!1),Be=()=>{const s={pageType:r==null?void 0:r.key,name:G,slug:"",hasSlug:!1};m?B({id:t==null?void 0:t.id,name:G},{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()&&!I)return v("Child page slug is required"),!1;const q=$.removeSlugExtension(u),k=$.combineParentChildSlugs(q,s);return Object.keys(w.LANGUAGES).some(Z=>k===`/${Z}`||(k==null?void 0:k.startsWith(`/${Z}/`)))?(v("Slugs cannot start with a language code for primary page"),!1):!0},We=(s,u)=>{const q=$.removeSlugExtension(u),k=$.combineParentChildSlugs(q,s),D={pageType:l,name:G,slug:k.replace(/\/$/,""),parent:T,dynamic:I,hasSlug:!0,template:E||void 0,tracking:{},seo:{},jsonLD:{}};if(I&&(D.dynamicSlugCustom=ie),m){const A=b.pick(D,["pageType","parent","name","slug","dynamic","dynamicSlugCustom"]);B({id:t==null?void 0:t.id,...A},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}})}else{const A=b.find(o,{key:l});A!=null&&A.trackingDefault&&(D.tracking=A.trackingDefault);const{seo:Z,jsonLD:Ge}=fe.getSeoDefaults(A,ne);b.set(D,"seo",Z),b.set(D,"jsonLD",Ge),g(D,{onSuccess:Me=>{c(),f(Me.page.id,j)}})}},Re=()=>{const s={pageType:l,name:G,slug:F===""?"/":`/${F.replace(/\/$/,"")}`,template:E||void 0,parent:null,tracking:{}};if(m)B({id:t==null?void 0:t.id,...s},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}});else{const u=b.find(o,{key:l});u!=null&&u.trackingDefault&&(s.tracking=u.trackingDefault);const{seo:q,jsonLD:k}=fe.getSeoDefaults(u,ne);b.set(s,"seo",q),b.set(s,"jsonLD",k),g(s,{onSuccess:D=>{var A;(A=D==null?void 0:D.page)!=null&&A.id&&f(D.page.id,j),c()}})}},de=s=>{if(s.preventDefault(),v(null),!!Ae()){if(!(r!=null&&r.hasSlug)){Be();return}if(T&&T!=="none"){const u=h==null?void 0:h.find(k=>k.id===T),q=(u==null?void 0:u.slug)||"";if(!Oe(F,q))return;We(F,q)}else Re()}},{pagesType:se,partialsType:K}=i.useMemo(()=>{const s=u=>z?u.name.toLowerCase().includes(z.toLowerCase())||u.key.toLowerCase().includes(z.toLowerCase()):!0;return{pagesType:o.filter(u=>u.hasSlug!==!1&&s(u)),partialsType:o.filter(u=>u.hasSlug===!1&&s(u))}},[o,z]);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(n.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(n.Popover,{open:ae,onOpenChange:V,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:U("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.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(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:z,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No page type found."}),m?le?e.jsx(n.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsx(n.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("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(n.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}),K.length>0&&e.jsx(n.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("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=>M(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:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsx("optgroup",{label:"Pages",children:o.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:o.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}),e.jsx("optgroup",{label:"Partials",children:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})]})}),O&&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(n.Button,{variant:"outline",size:"sm",onClick:()=>R(!1),children:"Cancel"}),e.jsx(n.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(n.Label,{className:"mb-1 block text-sm",children:"Template"}),e.jsx(_e,{templates:me,selectedTemplateId:E,onSelectTemplate:qe,isLoading:Le})]}),e.jsx($e,{pages:h,selectedParentId:T,onChange:Fe,currentPage:t}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(n.Input,{id:"name",value:G,onChange:s=>re(s.target.value),required:!0,"aria-required":"true",placeholder:"Enter page name"})]}),(r==null?void 0:r.dynamicSegments)&&T&&T!=="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:I,onChange:s=>Ie(s.target.checked),className:"rounded border-gray-300"}),e.jsx(n.Label,{htmlFor:"useDynamicSlug",className:"text-sm",children:"Use Dynamic Slug"})]}),I&&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)||!I)&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx($.SlugInput,{value:F,onChange:s=>{var u;Q(s),m&&s!==(((u=t==null?void 0:t.slug)==null?void 0:u.split("/").pop())||"")?P(!!(Te||De)):P(!1)},placeholder:T&&T!=="none"?"Enter page slug":l==="page"?"Leave empty for home page":"Required - e.g. your-slug",parentSlug:T&&T!=="none"?(ge=h==null?void 0:h.find(s=>s.id===T))==null?void 0:ge.slug:void 0,onValidationChange:d}),W&&e.jsx("p",{className:"text-xs text-red-500",children:W}),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(n.Button,{disabled:_||!S&&(!(r!=null&&r.dynamicSegments)||!I)||I&&!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(n.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(n.Popover,{open:ae,onOpenChange:V,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:U("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.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(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:z,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"max-h-[200px] overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No page type found."}),e.jsx(n.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>{M(s.key),V(!1)},className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("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=>M(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:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})}),O&&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(n.Button,{variant:"outline",size:"sm",onClick:()=>R(!1),children:"Cancel"}),e.jsx(n.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:(xe=o.find(s=>s.key===l))==null?void 0:xe.helpText})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(n.Input,{id:"name",value:G,onChange:s=>re(s.target.value),required:!0,"aria-required":"true"})]}),e.jsx(n.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"),n=require("@chaibuilder/sdk/ui"),i=require("react"),$=require("./slug-input-vzNtu37S.cjs"),Y=require("@chaibuilder/sdk"),b=require("lodash-es"),C=require("lucide-react"),w=require("./index-Pdb5tSRL.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:o}){const[f,m]=i.useState(null),h=i.useRef(null),[g,L]=i.useState(p+t);i.useEffect(()=>{L(p+t)},[t,p]);const B=v=>{const S=v.target.value;if(!S.startsWith(p)){const O=S.replace(p,""),R=p+O;L(R),c(O);return}const l=S.substring(p.length).replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),a=(l.match(/\./g)||[]).length,x=a<=1;a>1?m("Invalid slug. Only one dot (.) is allowed in the slug"):m(null),o&&o(x);const y=p+l;L(y),c(l)},N=()=>{if(h.current){const v=h.current;setTimeout(()=>{const S=p.length;v.setSelectionRange(S,S)},0)}},W=v=>{const S=v.currentTarget;(S.selectionStart||0)<=p.length&&setTimeout(()=>{const l=p.length;S.setSelectionRange(l,l)},0)};return e.jsx("div",{children:e.jsxs("div",{className:"relative",children:[e.jsxs("p",{className:"text-gray-500 text-xs mb-2",children:[`${p}`," is a dynamic segment of slug"]}),e.jsx(n.Input,{ref:h,value:g,onChange:B,onFocus:N,onClick:W,placeholder:j,className:f?"border-red-500":""}),f&&e.jsx("div",{className:"text-red-500 text-xs mt-1",children:f})]})})}const X=({children:t,onWheel:c,...j})=>{const p=o=>{try{o.preventDefault();const f=o.currentTarget;f.scrollTop+=o.deltaY}catch{o.preventDefault()}c&&c(o)};return e.jsx(n.CommandList,{...j,onWheel:p,children:t})},te=(...t)=>t.filter(Boolean).join(" ");function $e({pages:t,selectedParentId:c,onChange:j,className:p,id:o="parentPage",currentPage:f}){const[m,h]=i.useState(!1),[g,L]=i.useState(""),B=Y.useChaiFeatureFlag("enable-add-page-dropdown");B||(p="w-full rounded-md border border-gray-300 px-3 py-2");const N=i.useMemo(()=>!t||t.length===0?[]:t.filter(x=>!b.isEmpty(x.slug)).filter(x=>x.slug!=="/").sort((x,y)=>x.slug.localeCompare(y.slug)),[t]),W=i.useMemo(()=>{if(!g.trim())return N;const a=g.toLowerCase();return N.filter(x=>x.name.toLowerCase().includes(a)||x.slug.toLowerCase().includes(a))},[N,g]),v=a=>Math.max(0,(a.match(/\//g)||[]).length-1),S=a=>" ".repeat(a),d=a=>{if(a==="/")return"/";const x=a.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 a=N.find(x=>x.id===c);return a?`${a.name} (${d(a.slug)})`:"None"};return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:o,className:"text-sm",children:"Parent"}),B?e.jsxs(n.Popover,{open:m,onOpenChange:h,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{id:o,variant:"outline",role:"combobox",className:te("w-full justify-between",p),"data-testid":"parent-page-selector",children:[l(),e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.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(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search pages...",className:"h-8 pl-8 text-xs",value:g,onChange:a=>L(a.target.value)})]})})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No pages found."}),e.jsxs(n.CommandGroup,{children:[e.jsxs(n.CommandItem,{value:"none",onSelect:()=>{j(""),h(!1),L("")},className:"flex cursor-pointer items-center justify-between",children:[e.jsx("span",{children:"None"}),e.jsx(C.Check,{className:te("mr-2 h-4 w-4",c?"opacity-0":"opacity-100")})]}),W.map(a=>{const x=S(v(a.slug)),y=d(a.slug),O=e.jsxs("span",{className:"flex items-center text-sm",children:[x,a.name,e.jsxs("span",{className:"text-xs text-gray-500",children:[" (",y,")"]})]});return e.jsxs(n.CommandItem,{value:a.id,onSelect:()=>{j(a.id),h(!1),L("")},className:"flex cursor-pointer items-center justify-between whitespace-pre-wrap",children:[e.jsx("span",{children:O}),e.jsx(C.Check,{className:te("mr-2 h-4 w-4 shrink-0",c===a.id?"opacity-100":"opacity-0")})]},a.id)})]})]})]})})]}):e.jsxs("select",{id:o,value:c||"none",onChange:a=>j(a.target.value),className:p,"data-testid":"parent-page-selector",children:[e.jsx("option",{value:"none",children:"None"}),N.map(a=>{const x=v(a.slug),y=x>0?S(x):"",O=d(a.slug);return(f==null?void 0:f.id)===a.id||a.slug.startsWith(f==null?void 0:f.slug)?null:e.jsxs("option",{value:a.id,children:[y,a.name," (",O,")"]},a.id)})]})]})}const ze=(...t)=>t.filter(Boolean).join(" "),_e=({templates:t,selectedTemplateId:c,onSelectTemplate:j,isLoading:p=!1})=>{const[o,f]=i.useState(""),[m,h]=i.useState(!1),[g,L]=i.useState(""),B=Y.useChaiFeatureFlag("enable-add-page-dropdown");if(i.useEffect(()=>{if(c){const d=t.find(l=>l.id===c);f((d==null?void 0:d.preview)||"")}else 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 N={};t.forEach(d=>{const l=d.libraryName;N[l]||(N[l]=[]),N[l].push(d)});const W=Object.entries(N).reduce((d,[l,a])=>{const x=a.filter(y=>y.name.toLowerCase().includes(g.toLowerCase())||l.toLowerCase().includes(g.toLowerCase()));return x.length>0&&(d[l]=x),d},{}),v=t.find(d=>d.id===c),S=v?b.startCase(v.name):"No Template";return e.jsxs("div",{className:"space-y-4",children:[B?e.jsxs(n.Popover,{open:m,onOpenChange:h,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"outline",role:"combobox",className:"w-full justify-between",children:[S,e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.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(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search templates...",className:"h-8 pl-8 text-xs",value:g,onChange:d=>L(d.target.value)})]})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No templates found."}),Object.entries(W).map(([d,l])=>e.jsx(n.CommandGroup,{heading:d,children:l.map(a=>e.jsxs(n.CommandItem,{value:a.id,onSelect:()=>{j(a.id),h(!1),L("")},className:"flex cursor-pointer items-center justify-between",children:[b.startCase(a.name),e.jsx(C.Check,{className:ze("mr-2 h-4 w-4",c===a.id?"opacity-100":"opacity-0")})]},a.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(N).map(([d,l])=>e.jsx("optgroup",{label:d,children:l.map(a=>e.jsx("option",{value:a.id,children:b.startCase(a.name)},a.id))},d))]}),o&&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:o,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"})]})]})},Ve=()=>{const t=w.useApiUrl(),c=w.useFetch();return je.useQuery({queryKey:[w.ACTIONS.GET_LIBRARIES],staleTime:"static",queryFn:async()=>await c(t,{action:w.ACTIONS.GET_LIBRARIES})||[]})},Qe=t=>{const c=w.useApiUrl(),j=w.useFetch();return je.useQuery({queryKey:[w.ACTIONS.GET_TEMPLATES_BY_TYPE,t],staleTime:"static",enabled:!!t,queryFn:async()=>{const p=await j(c,{action:w.ACTIONS.GET_TEMPLATES_BY_TYPE,data:{pageType:t}});return(t?b.filter(p,{pageType:t}):p)||[]}})},Ye=t=>{const{data:c=[],isLoading:j}=Qe(t),{data:p=[],isLoading:o}=Ve(),f=i.useMemo(()=>j||o?[]:c.map(h=>{const g=b.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,o]),m=i.useMemo(()=>b.groupBy(f,"libraryName"),[f]);return{data:f,groupedData:m,isLoading:j||o}},U=(...t)=>t.filter(Boolean).join(" ");function He({addEditPage:t,close:c,closePanel:j}){var xe,ge;const{data:p}=w.usePageTypes(),o=i.useMemo(()=>p??[],[p]),f=w.useChangePage(),m=!!(t!=null&&t.id),{data:h}=w.useWebsitePages(),{mutate:g,isPending:L}=w.useCreatePage(),{mutate:B,isPending:N}=w.useUpdatePage(),[W,v]=i.useState(null),[S,d]=i.useState(!0),[l,a]=i.useState((t==null?void 0:t.pageType)??"page"),{hasPermission:x}=Y.usePermissions(),y=x(w.PAGES_PERMISSIONS.CHANGE_PAGE_TYPE),[O,R]=i.useState(!1),[ye,ve]=i.useState(""),{selectedLang:Se,fallbackLang:Ce}=Y.useLanguages(),ne=Se||Ce,[z,H]=i.useState(""),[ae,V]=i.useState(!1),le=i.useMemo(()=>{const s=o.find(u=>u.key===l);return(s==null?void 0:s.hasSlug)===!1},[l,o]),[T,Ne]=i.useState((t==null?void 0:t.parent)??""),[G,re]=i.useState((t==null?void 0:t.name)??""),[I,oe]=i.useState((t==null?void 0:t.dynamic)??!1),[F,Q]=i.useState(I?"":((t==null?void 0:t.slug)??"").split("/").pop()||""),[ie,ce]=i.useState((t==null?void 0:t.dynamicSlugCustom)??""),[ue,be]=i.useState(!0),[we,P]=i.useState(!1),[E,ke]=i.useState(""),{data:me,isLoading:Le}=Ye(l),_=L||N,he=Y.useChaiFeatureFlag("enable-add-page-dropdown"),ee=i.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=i.useMemo(()=>!m||!(t!=null&&t.id)||!h?!1:h.some(s=>s.parent===t.id),[m,t==null?void 0:t.id,h]),r=o.find(s=>s.key===l),M=s=>{if(m&&l!==s){ve(s),R(!0),H(""),V(!1);return}a(s),H(""),V(!1)},pe=()=>{a(ye),R(!1),oe(!1)},Ie=s=>{oe(s),s?Q(""):ce("")},Fe=s=>{if(Ne(s),s&&s!=="none"){const u=h==null?void 0:h.find(k=>k.id===s),q=(u==null?void 0:u.slug)||"";if(F.startsWith(q)){const k=F.slice(q.length).replace(/^\/+/,"");Q(k)}else Q(F.replace(/^\/+/,""))}else Q(F?`${F}`:"")},qe=s=>{ke(s)},Ae=()=>G.trim()?I&&!b.isEmpty(F)?(v("Slug must be empty when using dynamic slug"),!1):I&&!ue?(v("Dynamic slug is invalid"),!1):!0:(J.toast.error("Name is required"),!1),Be=()=>{const s={pageType:r==null?void 0:r.key,name:G,slug:"",hasSlug:!1};m?B({id:t==null?void 0:t.id,name:G},{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()&&!I)return v("Child page slug is required"),!1;const q=$.removeSlugExtension(u),k=$.combineParentChildSlugs(q,s);return Object.keys(w.LANGUAGES).some(Z=>k===`/${Z}`||(k==null?void 0:k.startsWith(`/${Z}/`)))?(v("Slugs cannot start with a language code for primary page"),!1):!0},We=(s,u)=>{const q=$.removeSlugExtension(u),k=$.combineParentChildSlugs(q,s),D={pageType:l,name:G,slug:k.replace(/\/$/,""),parent:T,dynamic:I,hasSlug:!0,template:E||void 0,tracking:{},seo:{},jsonLD:{}};if(I&&(D.dynamicSlugCustom=ie),m){const A=b.pick(D,["pageType","parent","name","slug","dynamic","dynamicSlugCustom"]);B({id:t==null?void 0:t.id,...A},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}})}else{const A=b.find(o,{key:l});A!=null&&A.trackingDefault&&(D.tracking=A.trackingDefault);const{seo:Z,jsonLD:Ge}=fe.getSeoDefaults(A,ne);b.set(D,"seo",Z),b.set(D,"jsonLD",Ge),g(D,{onSuccess:Me=>{c(),f(Me.page.id,j)}})}},Re=()=>{const s={pageType:l,name:G,slug:F===""?"/":`/${F.replace(/\/$/,"")}`,template:E||void 0,parent:null,tracking:{}};if(m)B({id:t==null?void 0:t.id,...s},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}});else{const u=b.find(o,{key:l});u!=null&&u.trackingDefault&&(s.tracking=u.trackingDefault);const{seo:q,jsonLD:k}=fe.getSeoDefaults(u,ne);b.set(s,"seo",q),b.set(s,"jsonLD",k),g(s,{onSuccess:D=>{var A;(A=D==null?void 0:D.page)!=null&&A.id&&f(D.page.id,j),c()}})}},de=s=>{if(s.preventDefault(),v(null),!!Ae()){if(!(r!=null&&r.hasSlug)){Be();return}if(T&&T!=="none"){const u=h==null?void 0:h.find(k=>k.id===T),q=(u==null?void 0:u.slug)||"";if(!Oe(F,q))return;We(F,q)}else Re()}},{pagesType:se,partialsType:K}=i.useMemo(()=>{const s=u=>z?u.name.toLowerCase().includes(z.toLowerCase())||u.key.toLowerCase().includes(z.toLowerCase()):!0;return{pagesType:o.filter(u=>u.hasSlug!==!1&&s(u)),partialsType:o.filter(u=>u.hasSlug===!1&&s(u))}},[o,z]);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(n.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(n.Popover,{open:ae,onOpenChange:V,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:U("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.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(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:z,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No page type found."}),m?le?e.jsx(n.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsx(n.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("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(n.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}),K.length>0&&e.jsx(n.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("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=>M(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:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsx("optgroup",{label:"Pages",children:o.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:o.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}),e.jsx("optgroup",{label:"Partials",children:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})]})}),O&&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(n.Button,{variant:"outline",size:"sm",onClick:()=>R(!1),children:"Cancel"}),e.jsx(n.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(n.Label,{className:"mb-1 block text-sm",children:"Template"}),e.jsx(_e,{templates:me,selectedTemplateId:E,onSelectTemplate:qe,isLoading:Le})]}),e.jsx($e,{pages:h,selectedParentId:T,onChange:Fe,currentPage:t}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(n.Input,{id:"name",value:G,onChange:s=>re(s.target.value),required:!0,"aria-required":"true",placeholder:"Enter page name"})]}),(r==null?void 0:r.dynamicSegments)&&T&&T!=="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:I,onChange:s=>Ie(s.target.checked),className:"rounded border-gray-300"}),e.jsx(n.Label,{htmlFor:"useDynamicSlug",className:"text-sm",children:"Use Dynamic Slug"})]}),I&&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)||!I)&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx($.SlugInput,{value:F,onChange:s=>{var u;Q(s),m&&s!==(((u=t==null?void 0:t.slug)==null?void 0:u.split("/").pop())||"")?P(!!(Te||De)):P(!1)},placeholder:T&&T!=="none"?"Enter page slug":l==="page"?"Leave empty for home page":"Required - e.g. your-slug",parentSlug:T&&T!=="none"?(ge=h==null?void 0:h.find(s=>s.id===T))==null?void 0:ge.slug:void 0,onValidationChange:d}),W&&e.jsx("p",{className:"text-xs text-red-500",children:W}),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(n.Button,{disabled:_||!S&&(!(r!=null&&r.dynamicSegments)||!I)||I&&!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(n.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(n.Popover,{open:ae,onOpenChange:V,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:U("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.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(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:z,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"max-h-[200px] overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No page type found."}),e.jsx(n.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>{M(s.key),V(!1)},className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("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=>M(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:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})}),O&&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(n.Button,{variant:"outline",size:"sm",onClick:()=>R(!1),children:"Cancel"}),e.jsx(n.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:(xe=o.find(s=>s.key===l))==null?void 0:xe.helpText})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(n.Input,{id:"name",value:G,onChange:s=>re(s.target.value),required:!0,"aria-required":"true"})]}),e.jsx(n.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,11 +1,11 @@
|
|
|
1
1
|
import { jsx as s, jsxs as n, Fragment as We } from "react/jsx-runtime";
|
|
2
2
|
import { Input as M, CommandList as is, Label as I, Popover as ee, PopoverTrigger as se, Button as W, PopoverContent as le, Command as ne, CommandEmpty as ae, CommandGroup as G, CommandItem as R } from "@chaibuilder/sdk/ui";
|
|
3
3
|
import { useState as y, useRef as os, useEffect as Be, useMemo as $ } from "react";
|
|
4
|
-
import { r as te, S as cs, c as Oe } from "./slug-input-
|
|
4
|
+
import { r as te, S as cs, c as Oe } from "./slug-input-CumDDlCk.js";
|
|
5
5
|
import { useChaiFeatureFlag as ye, usePermissions as us, useLanguages as ms } from "@chaibuilder/sdk";
|
|
6
6
|
import { isEmpty as Ie, startCase as de, filter as hs, find as ge, groupBy as ps, pick as ds, set as P } from "lodash-es";
|
|
7
7
|
import { ChevronDown as re, Search as ie, Check as U } from "lucide-react";
|
|
8
|
-
import {
|
|
8
|
+
import { ak as Re, al as Ue, A as oe, h as fs, am as gs, b as ys, c as vs, d as Ns, as as bs, L as Ss } from "./index-e9WlBH0R.js";
|
|
9
9
|
import { useQuery as ze } 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"),l=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("./index-Pdb5tSRL.cjs"),C=require("@chaibuilder/sdk"),i=require("@chaibuilder/sdk/ui"),n=require("lucide-react"),x=require("react"),N=({userId:d})=>{const{data:r}=l.useChaiUserInfo(d);return(r==null?void 0:r.name)||"Unknown"},f=({isChecking:d,lockingStatus:r,onContinue:j})=>{const{t:s}=C.useTranslation(),[u,h]=x.useState(!1),c=r==="page_is_active_in_other_tab",a=(r==null?void 0:r.length)>0,{pageLock:t,acceptTakeOver:o,rejectTakeOver:m}=l.usePageLockRequestTakeOver(),g=()=>{h(!0),a||c?j():o(),setTimeout(()=>{h(!1)},3e3)};return x.useEffect(()=>{(t==null?void 0:t.requestedBy)==="ANOTHER_TAB"&&o()},[t,o]),(t==null?void 0:t.requestedBy)==="ANOTHER_TAB"?null:d?e.jsx(l.BlurContainer,{children:e.jsx(n.Loader,{className:"h-5 w-5 animate-spin text-primary"})}):e.jsx(l.BlurContainer,{children:e.jsxs(i.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(i.CardHeader,{className:"space-y-1",children:e.jsxs(i.CardTitle,{className:"flex items-center gap-2 text-xl font-medium",children:[u?e.jsx(n.Loader,{className:"h-6 w-6 animate-spin text-gray-500"}):c?e.jsx(n.TableIcon,{className:"h-6 w-6 text-green-500"}):a?e.jsx(n.CheckCircle,{className:"h-6 w-6 text-green-500"}):e.jsx(n.Target,{className:"h-6 w-6 text-green-500"}),s(c?"Page is active in other tab":a?"You can edit the page now.":"Page take over request")]})}),e.jsx(i.CardContent,{className:"grid gap-4",children:e.jsx("div",{children:c?e.jsxs("p",{children:[s("You are already editing this page in another tab. To continue editing here, click on"),' "',s("Continue editing here"),'".']}):a?e.jsx("p",{children:s("This page is released by other user you can continue editing now.")}):e.jsxs("p",{children:[e.jsxs("b",{children:[" ",e.jsx(N,{userId:t==null?void 0:t.requestedBy})]})," ",s("has requested to take over this page."),e.jsx("br",{})," ",s("If you accept, your unsaved changes will be saved.")]})})}),e.jsxs(i.CardFooter,{className:"flex items-center justify-end gap-2",children:[e.jsx(i.Button,{disabled:u,onClick:g,className:a?"":"bg-green-500 hover:bg-green-600",children:c?e.jsxs(e.Fragment,{children:[e.jsx(n.Edit,{className:"h-5 w-5"})," ",s("Continue editing here")]}):a?e.jsxs(e.Fragment,{children:[e.jsx(n.Edit,{className:"h-5 w-5"})," ",s("Continue to edit")]}):e.jsxs(e.Fragment,{children:[e.jsx(n.Check,{className:"h-5 w-5"})," ",s("Accept")]})}),!a&&e.jsxs(i.Button,{variant:"outline",onClick:m,children:[e.jsx(n.X,{className:"h-5 w-5"})," ",s("Reject")]})]})]})})};exports.default=f;
|