@chaibuilder/sdk 4.0.0-beta.22 → 4.0.0-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{2SSKDMRQ-DVWVGtU8.cjs → 2SSKDMRQ-C6XmPkPR.cjs} +1 -1
- package/dist/{2SSKDMRQ-SUA5eA2S.js → 2SSKDMRQ-DTcPSOGn.js} +2 -2
- package/dist/{AP7HFJJL-CUN5zddU.cjs → AP7HFJJL-6aBLUYOi.cjs} +1 -1
- package/dist/{AP7HFJJL-Co5bLh3I.js → AP7HFJJL-CVazlaEj.js} +1 -1
- package/dist/{IconPicker-BZvFj3cg.js → IconPicker-CcBoA1K0.js} +1 -1
- package/dist/{IconPicker-Bmz6vXB8.cjs → IconPicker-sbWeQ9M9.cjs} +1 -1
- package/dist/{WDYDFRGG-BpSteEEf.cjs → WDYDFRGG-BtzyRDmj.cjs} +1 -1
- package/dist/{WDYDFRGG-DjCIT9L-.js → WDYDFRGG-CwiYliX0.js} +2 -2
- package/dist/{active-in-another-tab-DfRJcvAz.js → active-in-another-tab-B4O3FEEg.js} +2 -2
- package/dist/{active-in-another-tab-C8-vpt8f.cjs → active-in-another-tab-DRJY0QqU.cjs} +1 -1
- package/dist/{add-new-language-page-jZ7Pg0Fv.js → add-new-language-page-BfYL9jXF.js} +3 -3
- package/dist/{add-new-language-page-B2BEmfil.cjs → add-new-language-page-CKIRTFjr.cjs} +1 -1
- package/dist/{add-new-page-YZF_XF8X.js → add-new-page-DVgxz4fs.js} +2 -2
- package/dist/{add-new-page-DbEBB3w7.cjs → add-new-page-dzN_CD2c.cjs} +1 -1
- package/dist/{ai-panel-content-C8ecaQnv.js → ai-panel-content-D5eFLI_B.js} +3 -3
- package/dist/{ai-panel-content-Bf_ojKwt.cjs → ai-panel-content-Dyw4RHCV.cjs} +1 -1
- package/dist/{ai-panel-default-lang-BC8Gq_jl.js → ai-panel-default-lang-Cj7meZBD.js} +3 -3
- package/dist/{ai-panel-default-lang-DokOmE_Q.cjs → ai-panel-default-lang-DEj9Qx2M.cjs} +2 -2
- package/dist/{ai-panel-other-lang-BJ30SL7z.js → ai-panel-other-lang-Cbi6HKzd.js} +3 -3
- package/dist/{ai-panel-other-lang-Ccx1t8pp.cjs → ai-panel-other-lang-Da2XLEcm.cjs} +1 -1
- package/dist/{ai-prompt-input-SfeB6a2j.js → ai-prompt-input-B6QoqT9B.js} +1 -1
- package/dist/{ai-prompt-input-ED14e6NE.cjs → ai-prompt-input-DXS8gzex.cjs} +1 -1
- package/dist/{ai-translation-prompt-BRRzei71.js → ai-translation-prompt-Dmq_Ahjf.js} +1 -1
- package/dist/{ai-translation-prompt-spS-OC6L.cjs → ai-translation-prompt-Uswft8iz.cjs} +1 -1
- package/dist/{code-editor-CIqswl5j.cjs → code-editor-DbSBrsUA.cjs} +1 -1
- package/dist/{code-editor-CYiIxUKp.js → code-editor-wQWmwFKW.js} +1 -1
- package/dist/{continue-editing-in-this-client-vICoETHN.js → continue-editing-in-this-client-BV0OrgEU.js} +2 -2
- package/dist/{continue-editing-in-this-client-B3CnmiZ2.cjs → continue-editing-in-this-client-Dkkzk8YZ.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +1 -0
- package/dist/core.js +1 -1
- package/dist/{css-import-modal-CHFZPXXQ.cjs → css-import-modal-C3f5sphx.cjs} +1 -1
- package/dist/{css-import-modal-DautOct0.js → css-import-modal-Co_YLkLB.js} +1 -1
- package/dist/{delete-design-token-BmWHk_Ap.js → delete-design-token-CJPAcsWp.js} +1 -1
- package/dist/{delete-design-token-D-wGR5qS.cjs → delete-design-token-zzNmNYLR.cjs} +1 -1
- package/dist/{delete-page-D5mzl-ET.cjs → delete-page-6lInxYM_.cjs} +1 -1
- package/dist/{delete-page-Dlv8srng.js → delete-page-CQTjB7ZZ.js} +2 -2
- package/dist/{design-token-usage-hl29qR_q.js → design-token-usage-BQY6eqzE.js} +1 -1
- package/dist/{design-token-usage-DIszlgJK.cjs → design-token-usage-blwlGuEE.cjs} +1 -1
- package/dist/{digital-asset-manager-v2LfDXwR.cjs → digital-asset-manager-cGUpTcu3.cjs} +1 -1
- package/dist/{digital-asset-manager-o_bNl9qj.js → digital-asset-manager-lPKoJ4FH.js} +3 -3
- package/dist/{duplicate-page-BjqgghN0.js → duplicate-page-Dmgqp93w.js} +3 -3
- package/dist/{duplicate-page-CEuF8dll.cjs → duplicate-page-rYeBMwHR.cjs} +1 -1
- package/dist/{dynamic-page-selector-BWC7kHJ1.js → dynamic-page-selector-CVyA9Zp0.js} +2 -2
- package/dist/{dynamic-page-selector-D4EWs4Qd.cjs → dynamic-page-selector-zqGqpcww.cjs} +1 -1
- package/dist/{get-chai-builder-theme-DDVRJQ6Z.js → get-chai-builder-theme-CfJkQYZc.js} +1 -1
- package/dist/{get-chai-builder-theme-BApShjRz.cjs → get-chai-builder-theme-Dm1z70lQ.cjs} +1 -1
- package/dist/{image-editor-2h5axNuk.cjs → image-editor-Cn1DgrNp.cjs} +1 -1
- package/dist/{image-editor-B1-bjvPd.js → image-editor-mVBb0VD_.js} +1 -1
- package/dist/{index-BJVYKKJq.cjs → index-B5qvHqN5.cjs} +2 -2
- package/dist/{index-DWGTiEak.cjs → index-EFWvSWoi.cjs} +11 -11
- package/dist/{index-BvluH-oT.js → index-GfOB5KV1.js} +20 -20
- package/dist/{index-BN6yEl-H.js → index-lm46VtIP.js} +889 -887
- package/dist/{json-diff-viewer-BjCIlzd7.cjs → json-diff-viewer-BeSMdSd5.cjs} +1 -1
- package/dist/{json-diff-viewer-WX0GIjq-.js → json-diff-viewer-D5yJoFh1.js} +2 -2
- package/dist/{lang-panel-C4x7bcyb.js → lang-panel-7qTejsLm.js} +3 -3
- package/dist/{lang-panel--yfjRDE2.cjs → lang-panel-B-QUotOn.cjs} +1 -1
- package/dist/{manage-design-tokens-CRwsErkx.js → manage-design-tokens-DeH-yNJN.js} +2 -2
- package/dist/{manage-design-tokens-DhdwhzQu.cjs → manage-design-tokens-TeWNZekH.cjs} +1 -1
- package/dist/{mark-as-template-BH0W9p2G.cjs → mark-as-template-Co00KkhA.cjs} +1 -1
- package/dist/{mark-as-template-DpZSFrLK.js → mark-as-template-RkfNETRW.js} +2 -2
- package/dist/{nested-path-selector-content-BDQmZzlf.js → nested-path-selector-content-Dimjyy8J.js} +1 -1
- package/dist/{nested-path-selector-content-CHYz7cdB.cjs → nested-path-selector-content-hBvmT_2A.cjs} +1 -1
- package/dist/{no-language-page-content-D0lcCseQ.js → no-language-page-content-Bk3sTsdM.js} +2 -2
- package/dist/{no-language-page-content-D7btm8zX.cjs → no-language-page-content-CLovr1bL.cjs} +1 -1
- package/dist/{no-language-page-dialog-sYOmLnpY.cjs → no-language-page-dialog-C21Fq-UD.cjs} +1 -1
- package/dist/{no-language-page-dialog-BdW7oXvt.js → no-language-page-dialog-Cx-YOrAd.js} +2 -2
- package/dist/{page-creator-O_QpbMlB.js → page-creator-BBuYY84G.js} +3 -3
- package/dist/{page-creator-B-jBAGZl.cjs → page-creator-BDmospqO.cjs} +1 -1
- package/dist/{page-lock-CmQKpw1U.js → page-lock-BrGWj326.js} +2 -2
- package/dist/{page-lock-BrVqfmVm.cjs → page-lock-DG5IvZaG.cjs} +1 -1
- package/dist/{page-locked-dialog-ChHVSk7X.cjs → page-locked-dialog-DKnQpIMB.cjs} +1 -1
- package/dist/{page-locked-dialog-BjeJOXuN.js → page-locked-dialog-DUktYJzU.js} +2 -2
- package/dist/{page-manager-new-wcsdorbd.js → page-manager-new-BfKYDWs7.js} +3 -3
- package/dist/{page-manager-new-B90zLpRY.cjs → page-manager-new-iYsDkUzG.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-Bb_Zfpsj.cjs → page-manager-search-and-filter-CIspvIW2.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-DY_NsetM.js → page-manager-search-and-filter-DVAGxnlw.js} +2 -2
- package/dist/{page-revisions-content-CVpi-467.cjs → page-revisions-content-B84UtAxm.cjs} +1 -1
- package/dist/{page-revisions-content-5h39VYXj.js → page-revisions-content-DB4mj_Cw.js} +3 -3
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +1 -0
- package/dist/pages.js +1 -1
- package/dist/{plugin-BGlQf0iy.cjs → plugin-BfC_qpW2.cjs} +10 -10
- package/dist/{plugin-C-ht41UZ.js → plugin-DVNaUexn.js} +86 -80
- package/dist/{publish-pages-content-rrfvXks4.js → publish-pages-content-BRKsIr9W.js} +3 -3
- package/dist/{publish-pages-content-BG1GIuIz.cjs → publish-pages-content-ysv37LxZ.cjs} +1 -1
- package/dist/render.cjs +1 -1
- package/dist/render.d.ts +4 -1
- package/dist/render.js +2 -2
- package/dist/{rte-widget-modal-JRoPPuju.cjs → rte-widget-modal-BS040t_9.cjs} +1 -1
- package/dist/{rte-widget-modal-29WtCMJs.js → rte-widget-modal-Dj5BvA-1.js} +1 -1
- package/dist/{save-to-lib-YvzDV5ee.cjs → save-to-lib-ClCCNy6W.cjs} +1 -1
- package/dist/{save-to-lib-Bm7R2K7j.js → save-to-lib-D3kp0ovZ.js} +2 -2
- package/dist/{selected-block-display-BAulh0Nz.js → selected-block-display-BtlTAkei.js} +2 -2
- package/dist/{selected-block-display-bdClAekS.cjs → selected-block-display-BvRoOMt9.cjs} +1 -1
- package/dist/{seo-panel-D9wnaLG-.cjs → seo-panel-CHGdB8_7.cjs} +1 -1
- package/dist/{seo-panel-CT0D3I44.js → seo-panel-C_Cnwj1-.js} +2 -2
- package/dist/{shared-json-ld-ON6LaybZ.cjs → shared-json-ld-DA0wz-k3.cjs} +1 -1
- package/dist/{shared-json-ld-CuhqVL8H.js → shared-json-ld-DPr0Douk.js} +2 -2
- package/dist/{slug-input-DNeh6LBv.js → slug-input-CqhlfgAe.js} +1 -1
- package/dist/{slug-input-CxmcQbTR.cjs → slug-input-DltqfQ3y.cjs} +1 -1
- package/dist/{take-over-request-CrILj_3q.cjs → take-over-request-Bq7OF5Gp.cjs} +1 -1
- package/dist/{take-over-request-BmeR6t3b.js → take-over-request-ByUlm_HK.js} +2 -2
- package/dist/{theme-panel-footer-D4oCAY2G.js → theme-panel-footer-DG7Z5YjD.js} +2 -2
- package/dist/{theme-panel-footer-BMx5lGB4.cjs → theme-panel-footer-XYoM6sn5.cjs} +1 -1
- package/dist/{translation-warning-modal-ChL7oDO1.cjs → translation-warning-modal-DTxxfo0H.cjs} +1 -1
- package/dist/{translation-warning-modal-BNG9m-FC.js → translation-warning-modal-DaBUipEY.js} +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/{unmark-as-template-CEEMIY1A.js → unmark-as-template-BOFHOO0_.js} +2 -2
- package/dist/{unmark-as-template-BYiyJloZ.cjs → unmark-as-template-C9EXTj0X.cjs} +1 -1
- package/dist/{unpublish-page-B0aY1JnO.cjs → unpublish-page-B5rev9W3.cjs} +1 -1
- package/dist/{unpublish-page-Bm20P3TB.js → unpublish-page-KDM7kEEV.js} +2 -2
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{web-preview-BtEn4Vc-.js → web-preview-BDgUTTr8.js} +1 -1
- package/dist/{web-preview-iQgiotU6.cjs → web-preview-CvpevNzM.cjs} +1 -1
- package/package.json +1 -1
|
@@ -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-EFWvSWoi.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-B5qvHqN5.cjs"),H=require("@tanstack/react-query");function K(t,r){const o=O.useApiUrl(),n=O.useFetch(),d=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=h=>h==="draft"||h==="live"?h:"revision",s=h=>p.replace(h.uid,`${h.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:d?0:1/0,refetchOnMount:d?"always":!1,gcTime:d?0:void 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",d=t.label==="draft";return e.jsxs("span",{className:`flex min-h-8 items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":d?"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":d?" 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:d?"Currently editing":"Published by"}),!d&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),(r==null?void 0:r.createdAt)&&e.jsx("div",{className:"pt-0.5 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),d=JSON.stringify(r,null,2),l=n.split(`
|
|
2
2
|
`),s=d.split(`
|
|
3
3
|
`);let u=`--- a/${o}
|
|
4
4
|
`;u+=`+++ b/${o}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as e, jsxs as u } from "react/jsx-runtime";
|
|
2
|
-
import { D as V, e as _, f as q, g as G, a9 as $, a3 as A, aa as P } from "./index-
|
|
2
|
+
import { D as V, e as _, f as q, g as G, a9 as $, a3 as A, aa as P } from "./index-lm46VtIP.js";
|
|
3
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 I } from "react";
|
|
8
8
|
import { parseDiff as se, Diff as ae, Hunk as le } 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-GfOB5KV1.js";
|
|
10
10
|
import { useQuery as fe } from "@tanstack/react-query";
|
|
11
11
|
function me(t, n) {
|
|
12
12
|
const o = ie(), s = oe(), d = T(t.uid, "draft:") || T(n.uid, "live:");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as s, Fragment as M } from "react/jsx-runtime";
|
|
2
2
|
import { D as j, z as F, B as A } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
-
import { D as B, e as H, f as O, g as W, p as q, q as R, r as J, d as K, s as Q, t as V, v as X, 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-
|
|
3
|
+
import { D as B, e as H, f as O, g as W, p as q, q as R, r as J, d as K, s as Q, t as V, v as X, w } from "./index-lm46VtIP.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-GfOB5KV1.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-CQTjB7ZZ.js")), ye = z(() => import("./unpublish-page-KDM7kEEV.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-DWTuRU53.cjs"),a=require("./index-
|
|
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-EFWvSWoi.cjs"),n=require("./index-B5qvHqN5.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-6lInxYM_.cjs"))),q=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-B5rev9W3.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,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as a, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
-
import { a1 as _, a2 as q, a3 as H, q as K, a4 as X, a5 as J, a6 as Y } from "./index-
|
|
2
|
+
import { a1 as _, a2 as q, a3 as H, q as K, a4 as X, a5 as J, a6 as Y } from "./index-lm46VtIP.js";
|
|
3
3
|
import { z, B as u } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
4
4
|
import { D as ee } from "./STRINGS-BExFecZW.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";
|
|
@@ -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-CJPAcsWp.js")), pe = M(() => import("./design-token-usage-BQY6eqzE.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"),v=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./index-EFWvSWoi.cjs"),c=require("./register-chai-top-bar-DWTuRU53.cjs"),Z=require("./STRINGS-FNnfjF5H.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"),B=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-zzNmNYLR.cjs"))),J=a.lazy(()=>Promise.resolve().then(()=>require("./design-token-usage-blwlGuEE.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),S=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 I=a.useCallback((s,r)=>{!j||i!=="edit"||!s.trim()||!r.trim()||!B(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]),R=()=>{if(!l.trim()||!h.trim()){p.toast.error(t("Please fill in both token name and classes"));return}if(!B(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()},M=s=>{const r={...n};delete r[s],o(r),m(),p.toast.success(t("Token deleted successfully"))},P=s=>{const r=n[s];r&&(k(s),N(r.name),b(r.value),y(""),x("edit"))},D=()=>{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&&I(r,h)},q=s=>{b(s),i==="edit"&&!T&&l.trim()&&I(l,s)},L=s=>{const r=v.orderClassesByBreakpoint(v.removeDuplicateClasses(_.twMerge(h,s)));q(r)},F=s=>{const r=h.split(" ").filter(d=>d!==s).join(" ");q(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:R,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:D,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:D,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")]})]}):S.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")})]}):S.map(([s,r])=>e.jsx(Y,{token:r,tokenId:s,onEdit:P,onDelete:M,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 +1 @@
|
|
|
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-
|
|
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-EFWvSWoi.cjs"),y=require("./index-B5qvHqN5.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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
2
|
import { z, B as c } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
-
import { D as P, e as B, f as E, g as L, p as S, q as w, T as U, r as R } from "./index-
|
|
4
|
-
import { q as j, m as O } from "./index-
|
|
3
|
+
import { D as P, e as B, f as E, g as L, p as S, q as w, T as U, r as R } from "./index-lm46VtIP.js";
|
|
4
|
+
import { q as j, m as O } from "./index-GfOB5KV1.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";
|
package/dist/{nested-path-selector-content-BDQmZzlf.js → nested-path-selector-content-Dimjyy8J.js}
RENAMED
|
@@ -2,7 +2,7 @@ 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
4
|
import { B as k } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
5
|
-
import { P as N, C as x, j as P, k as S, l as w, m as B, n as d } from "./index-
|
|
5
|
+
import { P as N, C as x, j as P, k as S, l as w, m as B, n as d } from "./index-lm46VtIP.js";
|
|
6
6
|
function I({
|
|
7
7
|
data: o,
|
|
8
8
|
onSelect: m,
|
package/dist/{nested-path-selector-content-CHYz7cdB.cjs → nested-path-selector-content-hBvmT_2A.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-DWTuRU53.cjs"),a=require("./index-
|
|
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-EFWvSWoi.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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
2
|
import { B as h } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
-
import { d as u, U as w, V as p, W as f, X as P, Y as C } from "./index-
|
|
4
|
-
import { c as S, d as L, L as x, B as N } from "./index-
|
|
3
|
+
import { d as u, U as w, V as p, W as f, X as P, Y as C } from "./index-lm46VtIP.js";
|
|
4
|
+
import { c as S, d as L, L as x, B as N } from "./index-GfOB5KV1.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-D7btm8zX.cjs → no-language-page-content-CLovr1bL.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-DWTuRU53.cjs"),t=require("./index-
|
|
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-EFWvSWoi.cjs"),n=require("./index-B5qvHqN5.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-B5qvHqN5.cjs"),n=require("react"),t=n.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content-CLovr1bL.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-GfOB5KV1.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-Bk3sTsdM.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
2
|
import { z as M, h as ye, B as W } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
-
import { k as os, q as z, a7 as ee, a8 as se, P as ae, C as le, l as ne, m as G, n as I, ai as cs, d as us } from "./index-
|
|
3
|
+
import { k as os, q as z, a7 as ee, a8 as se, P as ae, C as le, l as ne, m as G, n as I, ai as cs, d as us } from "./index-lm46VtIP.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-CqhlfgAe.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-GfOB5KV1.js";
|
|
9
9
|
import { useQuery as qe } 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-DWTuRU53.cjs"),a=require("./index-DWGTiEak.cjs"),o=require("react"),_=require("./slug-input-CxmcQbTR.cjs"),w=require("lodash-es"),N=require("lucide-react"),k=require("./index-BJVYKKJq.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-EFWvSWoi.cjs"),o=require("react"),_=require("./slug-input-DltqfQ3y.cjs"),w=require("lodash-es"),N=require("lucide-react"),k=require("./index-B5qvHqN5.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,8 +1,8 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { u as E, a as c, b as T, P as e, A as l, B as I, E as _ } from "./index-
|
|
2
|
+
import { u as E, a as c, b as T, P as e, A as l, B as I, E as _ } from "./index-GfOB5KV1.js";
|
|
3
3
|
import { useQueryClient as C } from "@tanstack/react-query";
|
|
4
4
|
import { useRef as p, useEffect as N, Suspense as A, lazy as s } from "react";
|
|
5
|
-
const m = s(() => import("./take-over-request-
|
|
5
|
+
const m = s(() => import("./take-over-request-ByUlm_HK.js")), f = s(() => import("./page-locked-dialog-DUktYJzU.js")), O = s(() => import("./active-in-another-tab-B4O3FEEg.js")), S = s(() => import("./continue-editing-in-this-client-BV0OrgEU.js")), r = (a) => /* @__PURE__ */ n(A, { children: /* @__PURE__ */ n(a, {}) }), L = ({ isFetchingPageData: a }) => {
|
|
6
6
|
E();
|
|
7
7
|
const { pageStatus: t } = c(), { pageLockMeta: o } = T(), u = C(), i = p(t);
|
|
8
8
|
if (N(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),e=require("./index-B5qvHqN5.cjs"),E=require("@tanstack/react-query"),r=require("react"),c=r.lazy(()=>Promise.resolve().then(()=>require("./take-over-request-Bq7OF5Gp.cjs"))),o=r.lazy(()=>Promise.resolve().then(()=>require("./page-locked-dialog-DKnQpIMB.cjs"))),l=r.lazy(()=>Promise.resolve().then(()=>require("./active-in-another-tab-DRJY0QqU.cjs"))),S=r.lazy(()=>Promise.resolve().then(()=>require("./continue-editing-in-this-client-Dkkzk8YZ.cjs"))),s=n=>u.jsx(r.Suspense,{children:u.jsx(n,{})}),A=({isFetchingPageData:n})=>{e.useChaibuilderRealtime();const{pageStatus:t}=e.usePageLockStatus(),{pageLockMeta:a}=e.usePageLockMeta(),T=E.useQueryClient(),i=r.useRef(t);if(r.useEffect(()=>{t===e.PAGE_STATUS.EDITING&&i.current!==e.PAGE_STATUS.TAKE_OVER_REQUESTED&&T.invalidateQueries({queryKey:[e.ACTIONS.GET_DRAFT_PAGE]}),i.current=t},[t,T]),n)return null;switch(t){case e.PAGE_STATUS.EDITING:case e.PAGE_STATUS.CHECKING:case e.PAGE_STATUS.FORCE_TAKE_OVER:return a.type===e.EVENT.CONTINUE_EDITING_IN_THIS_CLIENT?s(S):null;case e.PAGE_STATUS.LOCKED:return s(o);case e.PAGE_STATUS.TAKE_OVER_REQUESTED:return s(c);case e.PAGE_STATUS.ACTIVE_IN_ANOTHER_TAB:return s(l);case e.PAGE_STATUS.CONNECTION_LOST:return u.jsx(e.BlurContainer,{children:null});default:return null}};exports.default=A;
|
|
@@ -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-EFWvSWoi.cjs"),p=require("./register-chai-top-bar-DWTuRU53.cjs"),t=require("./index-B5qvHqN5.cjs"),c=require("lucide-react"),d=require("react"),O=require("react-i18next"),_=()=>{const m=t.useCurrentPageOwner(),f=t.useSendRealtimeEvent(),{setPageStatus:j}=t.usePageLockStatus(),{data:s,isFetching:v}=t.useChaiUserInfo((m==null?void 0:m.userId)||""),{pageLockMeta:o,setPageLockMeta:g}=t.usePageLockMeta(),{t:r}=O.useTranslation(),[u,i]=d.useState(""),[a,N]=d.useState({}),[T,k]=d.useState(!1),l=d.useRef(null);d.useEffect(()=>{o!=null&&o.type&&(l.current&&clearTimeout(l.current),d.startTransition(()=>{N(o),g({}),i("")}))},[o,g]);const b=()=>{u!==t.EVENT.TAKE_OVER_REQUEST&&(i(t.EVENT.TAKE_OVER_REQUEST),f(t.EVENT.TAKE_OVER_REQUEST),l.current=setTimeout(()=>i(""),2e4))},R=()=>{u!==t.EVENT.FORCE_TAKE_OVER_REQUEST&&(i(t.EVENT.FORCE_TAKE_OVER_REQUEST),f(t.EVENT.FORCE_TAKE_OVER_REQUEST),j(t.PAGE_STATUS.CHECKING),l.current=setTimeout(()=>i(""),2e4))},y=()=>{N({}),l.current&&clearTimeout(l.current),i("")},x=v?"Loading...":(s==null?void 0:s.name)||"Current editor",h=u===t.EVENT.TAKE_OVER_REQUEST,E=u===t.EVENT.FORCE_TAKE_OVER_REQUEST;return e.jsx(t.BlurContainer,{children:e.jsxs(n.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(n.CardHeader,{className:"space-y-1 border-b pb-3",children:e.jsxs(n.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(c.LockKeyhole,{className:"h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500"}),e.jsx("span",{children:r("Page Locked for Editing")})]})}),e.jsxs(n.CardContent,{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"relative rounded-md border border-green-500 px-2 pb-2 pt-4",children:[e.jsx("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:"Current Editor"}),e.jsxs("div",{className:"flex items-center space-x-4 p-1",children:[s!=null&&s.avatar?e.jsx("img",{src:s.avatar,alt:s.name,className:"h-12 w-12 flex-shrink-0 rounded-full bg-black text-white"}):e.jsx(c.UserIcon,{className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}),e.jsxs("div",{className:"flex-1 space-y-0",children:[e.jsx("div",{className:"truncate font-medium leading-tight text-black",children:x}),(s==null?void 0:s.email)&&e.jsx("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:s.email})]})]})]}),((a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED||(a==null?void 0:a.type)===t.EVENT.FORCE_TAKE_OVER_REQUEST)&&e.jsx("section",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-x-2 rounded border border-red-500 bg-red-500/10 py-2 pl-3 pr-2 text-sm font-medium text-red-500",children:[e.jsxs("div",{className:"flex items-start gap-x-2",children:[e.jsx(c.AlertCircleIcon,{className:"mt-px flex h-4 w-4 shrink-0"}),e.jsxs("div",{className:"font-light leading-tight",children:[e.jsx("span",{className:"font-medium",children:(s==null?void 0:s.name)||"The current editor"}),(a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED?" rejected your take over request.":" forcefully took over this page."]})]}),e.jsx(p.Button,{size:"icon",variant:"ghost",onClick:y,className:"flex-shrink-0",children:e.jsx(c.X,{className:"h-4 w-4"})})]})})]}),e.jsx(n.CardFooter,{className:"flex flex-col gap-3 border-t pt-3",children:e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:r("Take Over Options")}),e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"text-sm font-medium",children:r("Take Over Request:")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r("Send a request to {{currentEditorName}} asking them to release the page. They can accept or decline your request.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:h,variant:"default",onClick:b,className:"mt-3 w-full gap-2",children:[e.jsx(c.Edit,{className:"h-4 w-4"}),h?"Take over request sent":"Send Take Over Request"]}),h&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:r("Request sent. If no response, try again or use force take over.")})]}),e.jsx(n.Accordion,{type:"single",collapsible:!0,className:"w-full",children:e.jsxs(n.AccordionItem,{value:"force-takeover",className:"rounded-md border border-destructive/40 bg-destructive/5",children:[e.jsx(n.AccordionTrigger,{className:"px-3 py-2 hover:no-underline",children:e.jsx("div",{className:"flex items-center gap-2 text-left",children:e.jsxs("div",{children:[e.jsxs("p",{className:"flex items-center gap-x-2 text-sm font-medium text-destructive",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4 text-destructive"}),r("Force Take Over")]}),e.jsx("p",{className:"pl-6 text-xs font-normal leading-tight text-muted-foreground",children:r("Immediately take control (use with caution)")})]})})}),e.jsx(n.AccordionContent,{className:"px-3 pb-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-background p-2",children:[e.jsx("input",{type:"checkbox",id:"force-takeover",checked:T,onChange:C=>k(C.target.checked),className:"mt-0.5 h-4 w-4 rounded border-gray-300"}),e.jsx("label",{htmlFor:"force-takeover",className:"flex-1 text-xs text-muted-foreground",children:r("I understand this will immediately close the editor for {{currentEditorName}}. I am using this option with caution.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:!T||E,variant:"destructive",onClick:R,className:"w-full gap-2",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4"}),r(E?"Take over page...":"Force Take Over")]}),E&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r("Attempting to forcefully take over this page. Please wait while we update the editing session.")})]})})]})})]})})]})})};exports.default=_;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import { U as O, V as w, W as A, X as S, Y as F, Z as K, _ as U, $ as V, a0 as I } from "./index-
|
|
2
|
+
import { U as O, V as w, W as A, X as S, Y as F, Z as K, _ as U, $ as V, a0 as I } from "./index-lm46VtIP.js";
|
|
3
3
|
import { B as p } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
4
|
-
import { aq as q, ao as Q, a as P, ap as j, b as B, B as D, E as a, P as L } from "./index-
|
|
4
|
+
import { aq as q, ao as Q, a as P, ap as j, b as B, B as D, E as a, P as L } from "./index-GfOB5KV1.js";
|
|
5
5
|
import { LockKeyhole as G, UserIcon as H, AlertCircleIcon as J, X, Edit as z, ShieldAlert as v } from "lucide-react";
|
|
6
6
|
import { useState as f, useRef as W, useEffect as Y, startTransition as Z } from "react";
|
|
7
7
|
import { useTranslation as $ } from "react-i18next";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as b, Fragment as F, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { d as oe } from "./index-
|
|
3
|
-
import { aA as ye, aB as ge, ap as ke, k as de, T as D, aQ as Ne, L as we, m as ve, g as Se, c as Le, av as Ae, aR as Te, aS as X } from "./index-
|
|
2
|
+
import { d as oe } from "./index-lm46VtIP.js";
|
|
3
|
+
import { aA as ye, aB as ge, ap as ke, k as de, T as D, aQ as Ne, L as we, m as ve, g as Se, c as Le, av as Ae, aR as Te, aS as X } from "./index-GfOB5KV1.js";
|
|
4
4
|
import { u as J } from "./use-page-expand-manager-Cf4MUEJw.js";
|
|
5
5
|
import { compact as ue, filter as B, isEmpty as k, uniqBy as Ce, keyBy as me, mapValues as Ee, startCase as Me, toLower as M, includes as _, get as W, find as z, map as Ue } from "lodash-es";
|
|
6
6
|
import { atom as Ie, useAtom as $e, useSetAtom as ze } from "jotai";
|
|
@@ -271,7 +271,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
271
271
|
}
|
|
272
272
|
)
|
|
273
273
|
] }, x.id)) });
|
|
274
|
-
}, at = U(() => import("./page-manager-search-and-filter-
|
|
274
|
+
}, at = U(() => import("./page-manager-search-and-filter-DVAGxnlw.js")), lt = U(() => import("./add-new-page-DVgxz4fs.js")), ot = U(() => import("./delete-page-CQTjB7ZZ.js")), it = U(() => import("./duplicate-page-Dmgqp93w.js")), ct = U(() => import("./mark-as-template-RkfNETRW.js")), dt = U(() => import("./unmark-as-template-BOFHOO0_.js")), ut = U(() => import("./unpublish-page-KDM7kEEV.js")), Nt = ({ close: e }) => {
|
|
275
275
|
const { t: s } = Ve(), { languages: r, setSelectedLang: n } = oe(), { data: o } = ve(), { data: a, isFetching: f } = Se(), [g, d] = Le(), { updateForSelectedPage: x, expandPagesOnSearch: h } = J(null), c = de(), p = g.get("page"), [N, q] = v(""), [P, u] = v(null), [L, A] = v(null), [w, O] = v(null), [j, G] = v(null), [i, I] = v(""), [K, Z] = v(null), [ee, te] = v(null), [y, Q] = v(c), [pe, Pe] = v(!1), ne = ze(Ae), R = pe && y !== c, { data: $, isFetching: be } = Te(y), se = ie(
|
|
276
276
|
(m) => {
|
|
277
277
|
var l;
|