@chaibuilder/sdk 4.0.0-beta.4 → 4.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -50
- package/dist/{2SSKDMRQ-CopJgtZb.cjs → 2SSKDMRQ-DDOgISWg.cjs} +1 -1
- package/dist/{2SSKDMRQ-Difo_1pg.js → 2SSKDMRQ-hL7THuKW.js} +2 -2
- package/dist/{AP7HFJJL-BPuPBqj4.js → AP7HFJJL-BsLQ13V_.js} +1 -1
- package/dist/{AP7HFJJL-DYxDgaOs.cjs → AP7HFJJL-tcAhVllC.cjs} +1 -1
- package/dist/{IconPicker-B2-oriq2.js → IconPicker-FLSVAZxx.js} +1 -1
- package/dist/{IconPicker-C0oycHbs.cjs → IconPicker-J1KLNrSB.cjs} +1 -1
- package/dist/{WDYDFRGG-DbejaRPK.cjs → WDYDFRGG-BTj8AXV6.cjs} +1 -1
- package/dist/{WDYDFRGG-KK8pkcW1.js → WDYDFRGG-Yi0eNS2V.js} +2 -2
- package/dist/{actions-registery-JdxhXhT6.cjs → actions-registery-CtQSSexG.cjs} +31 -31
- package/dist/{actions-registery-y_ENc8zj.js → actions-registery-DqrFhSMp.js} +2414 -2418
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.ts +0 -34
- package/dist/actions.js +3 -3
- package/dist/{active-in-another-tab-Cu_ASKtx.cjs → active-in-another-tab-BtAiatqq.cjs} +1 -1
- package/dist/{active-in-another-tab-DkR2HWI4.js → active-in-another-tab-Dozn833d.js} +2 -2
- package/dist/{add-new-language-page-BXuwluuU.cjs → add-new-language-page-9AMizlES.cjs} +1 -1
- package/dist/{add-new-language-page-CBY0RR6q.js → add-new-language-page-DD-CAoAQ.js} +3 -3
- package/dist/{add-new-page-C_PzKby8.cjs → add-new-page-BS9vPnFG.cjs} +1 -1
- package/dist/{add-new-page-DJLJFLAd.js → add-new-page-uZKCk9eB.js} +2 -2
- package/dist/{ai-panel-content--YM01Aly.js → ai-panel-content-CK4XOkEh.js} +3 -3
- package/dist/{ai-panel-content-rRmJdH7L.cjs → ai-panel-content-PovaKJaj.cjs} +1 -1
- package/dist/{ai-panel-default-lang-D2zhXvKP.cjs → ai-panel-default-lang-B37k5ADH.cjs} +2 -2
- package/dist/{ai-panel-default-lang-BZl0tPYo.js → ai-panel-default-lang-BtLjUl9d.js} +3 -3
- package/dist/{ai-panel-other-lang-Y4bEKHoG.cjs → ai-panel-other-lang-CdQmASqv.cjs} +1 -1
- package/dist/{ai-panel-other-lang-Bfjk2CYZ.js → ai-panel-other-lang-Dp1MNaLi.js} +3 -3
- package/dist/{ai-prompt-input-DueQYNf-.js → ai-prompt-input-BT-mEdTX.js} +1 -1
- package/dist/{ai-prompt-input-N9PcYCFa.cjs → ai-prompt-input-Dtym4w8J.cjs} +1 -1
- package/dist/{ai-translation-prompt-IAdWMNZb.cjs → ai-translation-prompt-B-lH7emI.cjs} +1 -1
- package/dist/{ai-translation-prompt-B36F3d7K.js → ai-translation-prompt-B17GK1QR.js} +1 -1
- package/dist/{code-editor-DQB8lAOk.cjs → code-editor-CUeNiMzA.cjs} +1 -1
- package/dist/{code-editor-Bb7JumZy.js → code-editor-EZT2pMsU.js} +1 -1
- package/dist/{continue-editing-in-this-client-Dm9cCj7K.js → continue-editing-in-this-client-CS7C6h9Q.js} +2 -2
- package/dist/{continue-editing-in-this-client-DmGFLHXw.cjs → continue-editing-in-this-client-DMZOc36k.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +41 -42
- package/dist/css-import-modal-kHB0ramf.cjs +13 -0
- package/dist/{css-import-modal-9P_0uNa4.js → css-import-modal-s7t5gZQo.js} +3 -4
- package/dist/{delete-design-token-COvR4G1S.js → delete-design-token-C1smbx4E.js} +1 -1
- package/dist/{delete-design-token-BG8yHcS5.cjs → delete-design-token-Mbw_6sYI.cjs} +1 -1
- package/dist/{delete-page-CNucxe4P.js → delete-page-2GfBi8Iv.js} +2 -2
- package/dist/{delete-page-DAvEjHwF.cjs → delete-page-B7J3t0FN.cjs} +1 -1
- package/dist/{design-token-usage-CXglXgcJ.cjs → design-token-usage-BoGOULG8.cjs} +1 -1
- package/dist/{design-token-usage-MNYsFlPG.js → design-token-usage-DyO3xM-F.js} +1 -1
- package/dist/{digital-asset-manager-CqCWBO0s.js → digital-asset-manager-Cz3Nlrzl.js} +3 -3
- package/dist/{digital-asset-manager-CB5MRBcW.cjs → digital-asset-manager-DDk2ucTE.cjs} +1 -1
- package/dist/{duplicate-page-BknLfqr0.js → duplicate-page-BwAY4Ssm.js} +3 -3
- package/dist/{duplicate-page-DzZByALW.cjs → duplicate-page-Dw3U4wTT.cjs} +1 -1
- package/dist/{dynamic-page-selector-WA007Sni.cjs → dynamic-page-selector-CvBFyX2F.cjs} +1 -1
- package/dist/{dynamic-page-selector-DoW7OyUB.js → dynamic-page-selector-sViJuQlU.js} +2 -2
- package/dist/{get-chai-builder-tailwind-config-BFePCEIS.cjs → get-chai-builder-tailwind-config-DNp8Vhme.cjs} +1 -1
- package/dist/{get-chai-builder-tailwind-config-BXf_xLHk.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +2 -2
- package/dist/{image-editor-CqwaVxO2.cjs → image-editor-AIsccrqC.cjs} +1 -1
- package/dist/{image-editor-CQnNtak2.js → image-editor-BgGQuESa.js} +1 -1
- package/dist/{index-Dno42B0a.js → index-B7eWP_hB.js} +539 -528
- package/dist/index-BwH1mRm_.cjs +5 -0
- package/dist/{index-rAcNbjk_.js → index-RYr8kQdI.js} +2132 -2130
- package/dist/{index-C99FhuF1.cjs → index-xYnNKovy.cjs} +15 -15
- package/dist/{json-diff-viewer-CLuUHiPU.cjs → json-diff-viewer-B2A78udz.cjs} +1 -1
- package/dist/{json-diff-viewer-CMvGUvJ2.js → json-diff-viewer-Svw-kbhe.js} +2 -2
- package/dist/{lang-panel-fDCYm5Jm.cjs → lang-panel-AmEkoWid.cjs} +1 -1
- package/dist/{lang-panel-CnwTb05j.js → lang-panel-Bnc-9wkM.js} +3 -3
- package/dist/{manage-design-tokens-BvH5KTJX.cjs → manage-design-tokens-B2fG80bi.cjs} +1 -1
- package/dist/{manage-design-tokens-BsSZE9Vs.js → manage-design-tokens-BBkh1t4w.js} +2 -2
- package/dist/{mark-as-template-DBLshWb5.js → mark-as-template-0CPzZnk-.js} +2 -2
- package/dist/{mark-as-template-CpWEBJGd.cjs → mark-as-template-CE6tRoQy.cjs} +1 -1
- package/dist/{nested-path-selector-content-C2sD9dkq.cjs → nested-path-selector-content-SmfjElr-.cjs} +1 -1
- package/dist/{nested-path-selector-content-6OBJ8LG8.js → nested-path-selector-content-kGznHufl.js} +1 -1
- package/dist/{no-language-page-content-BvPDdccK.cjs → no-language-page-content-B4bQLc4K.cjs} +1 -1
- package/dist/{no-language-page-content-CzENgtnu.js → no-language-page-content-DXsAPDZd.js} +2 -2
- package/dist/{no-language-page-dialog-CgW4yJBC.cjs → no-language-page-dialog-BC8NHzK2.cjs} +1 -1
- package/dist/{no-language-page-dialog-CbYI2cVg.js → no-language-page-dialog-BpPqmw9a.js} +2 -2
- package/dist/{page-creator-g8GqgcKH.cjs → page-creator-82qTbBj4.cjs} +1 -1
- package/dist/{page-creator-Cc83uQqw.js → page-creator-Bazn6yH4.js} +14 -14
- package/dist/{page-lock-BJUkyxdh.js → page-lock-CRFyqKZE.js} +2 -2
- package/dist/{page-lock-CT7SmQqp.cjs → page-lock-D2iFZDUK.cjs} +1 -1
- package/dist/{page-locked-dialog-DsEbWRed.js → page-locked-dialog-GKfQEOmk.js} +2 -2
- package/dist/{page-locked-dialog-Co5b9XIZ.cjs → page-locked-dialog-xLqvKzax.cjs} +1 -1
- package/dist/{page-manager-new-BOkJImo2.cjs → page-manager-new-Bn2QKjbf.cjs} +1 -1
- package/dist/{page-manager-new-5rFP5DyQ.js → page-manager-new-DItY2hjd.js} +3 -3
- package/dist/{page-manager-search-and-filter-zq-LfhQ1.js → page-manager-search-and-filter-CPa8IXdd.js} +2 -2
- package/dist/{page-manager-search-and-filter-Bfm0j1gg.cjs → page-manager-search-and-filter-Dc4ky-qV.cjs} +1 -1
- package/dist/{page-revisions-content-D38G2tJM.js → page-revisions-content-CH-PZK0O.js} +3 -3
- package/dist/{page-revisions-content-ag-MHBGr.cjs → page-revisions-content-CcLFI4YK.cjs} +1 -1
- package/dist/pages.cjs +1 -1
- package/dist/pages.js +1 -1
- package/dist/{publish-pages-content-BiX-GMLw.cjs → publish-pages-content-BzJDObqr.cjs} +1 -1
- package/dist/{publish-pages-content-CS7f41Ac.js → publish-pages-content-CSJCFElu.js} +3 -3
- package/dist/{rte-widget-modal-D6Zik0Ta.js → rte-widget-modal-5T81P_hg.js} +1 -1
- package/dist/{rte-widget-modal-BKNx2wln.cjs → rte-widget-modal-BfXcA7OP.cjs} +1 -1
- package/dist/{save-to-lib-ffjCZYJ5.cjs → save-to-lib-DGAdSa-0.cjs} +1 -1
- package/dist/{save-to-lib-WwOzbgiF.js → save-to-lib-MtWKSVeN.js} +2 -2
- package/dist/{selected-block-display-B1SG_UXw.js → selected-block-display-CB1-hVR5.js} +2 -2
- package/dist/{selected-block-display-BOgnQRLF.cjs → selected-block-display-DLt_nMn9.cjs} +1 -1
- package/dist/{seo-panel-BkOgRoWd.js → seo-panel-CRzzw4FW.js} +2 -2
- package/dist/{seo-panel-FjS1UF_y.cjs → seo-panel-_kGXE9MC.cjs} +1 -1
- package/dist/{shared-json-ld-uka9TOgA.js → shared-json-ld-CXukkDeS.js} +2 -2
- package/dist/{shared-json-ld-yJkXjENy.cjs → shared-json-ld-DoRgzDPC.cjs} +1 -1
- package/dist/{slug-input-DHLmUNrH.js → slug-input-CeEQ0zyv.js} +1 -1
- package/dist/{slug-input-Cyd6NR6J.cjs → slug-input-Dp187Tiy.cjs} +1 -1
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.d.ts +5 -0
- package/dist/supabase-actions.js +1 -1
- package/dist/{take-over-request-Ca0X-qyf.js → take-over-request-C9J3_rev.js} +2 -2
- package/dist/{take-over-request-CmpJVe9T.cjs → take-over-request-CXuakFBm.cjs} +1 -1
- package/dist/{theme-panel-footer-CKO9YYwZ.cjs → theme-panel-footer-CWZ0qs13.cjs} +1 -1
- package/dist/{theme-panel-footer-BUXIu252.js → theme-panel-footer-DvwsyHNQ.js} +2 -2
- package/dist/{translation-warning-modal-pSZVKcNW.cjs → translation-warning-modal-DEt_ExQp.cjs} +1 -1
- package/dist/{translation-warning-modal-DrpFeI83.js → translation-warning-modal-_aBp5ZZQ.js} +1 -1
- package/dist/{unmark-as-template-DF1Ms4VN.cjs → unmark-as-template-BYL5naYx.cjs} +1 -1
- package/dist/{unmark-as-template-BMqgelv-.js → unmark-as-template-JN-cDUV_.js} +2 -2
- package/dist/{unpublish-page-Bsq2yEqQ.cjs → unpublish-page-B06iZEIO.cjs} +1 -1
- package/dist/{unpublish-page-BJ0Bsvt2.js → unpublish-page-DqwBY2yI.js} +2 -2
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +42 -42
- package/dist/{web-preview-D6h1L2nV.js → web-preview-h39D3TUh.js} +1 -1
- package/dist/{web-preview-kres0aG7.cjs → web-preview-wRgRY3Tv.cjs} +1 -1
- package/package.json +22 -24
- package/dist/css-import-modal-Rh1QAVxo.cjs +0 -13
- package/dist/index-C0-pgg_p.cjs +0 -5
|
@@ -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-xYnNKovy.cjs"),L=require("./register-chai-top-bar-BqwKw4uy.cjs"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-BwH1mRm_.cjs"),H=require("@tanstack/react-query");function K(t,r){const o=O.useApiUrl(),n=O.useFetch(),f=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return H.useQuery({queryKey:["revision-comparison",t.uid,r.uid],queryFn:async()=>{if(!t.uid||!r.uid)throw new Error("Both revision IDs are required for comparison");const l=u=>u==="draft"||u==="live"?u:"revision",s=u=>p.replace(u.uid,`${u.label}:`,"");return await n(o,{action:O.ACTIONS.GET_COMPARE_DATA,data:{versions:{version1:{type:l(t.label),id:s(t)},version2:{type:l(r.label),id:s(r)}}}})},enabled:!!t.uid&&!!r.uid,staleTime:f?0:1/0})}const V=({version:t})=>{const r=t==null?void 0:t.item,{data:o}=O.useChaiUserInfo(r==null?void 0:r.currentEditor),n=t.label==="live",f=t.label==="draft";return e.jsxs("span",{className:`flex items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":f?"border-amber-500/30":"border-purple-500/30"}`,children:[e.jsx("div",{className:"h-full items-center rounded px-1.5 py-0.5 font-medium capitalize"+(n?" bg-green-500 text-green-50":f?" bg-amber-500 text-amber-50":" bg-purple-500 text-purple-50"),children:t.label}),e.jsxs("div",{className:"py-1 text-xs font-light leading-none text-gray-800",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-light opacity-90",children:f?"Currently editing":"Published by"}),!f&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),e.jsx("div",{className:"text-[10px] leading-tight",children:z.formatDate(r.createdAt,"dd MMM yyyy, h:mm a")})]})]})},F=({version:t})=>e.jsx(V,{version:t});function U(t,r,o="data.json"){const n=JSON.stringify(t,null,2),f=JSON.stringify(r,null,2),l=n.split(`
|
|
2
2
|
`),s=f.split(`
|
|
3
3
|
`);let d=`--- a/${o}
|
|
4
4
|
`;d+=`+++ b/${o}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as e, jsxs as h } from "react/jsx-runtime";
|
|
2
|
-
import { D as V, d as _, e as q, f as G, af as $, a2 as I, ag as P } from "./index-
|
|
2
|
+
import { D as V, d as _, e as q, f as G, af as $, a2 as I, ag as P } from "./index-RYr8kQdI.js";
|
|
3
3
|
import { B as z } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
4
4
|
import { formatDate as Q } from "date-fns";
|
|
5
5
|
import { startsWith as T, replace as W, isString as X, trim as Y, isArray as Z, map as ee, isPlainObject as te, mapValues as re } from "lodash-es";
|
|
6
6
|
import { FileJson as B, Loader as ne, Check as F, Copy as H } from "lucide-react";
|
|
7
7
|
import { useState as D, useMemo as A } from "react";
|
|
8
8
|
import { parseDiff as se, Diff as le, Hunk as ae } from "react-diff-view";
|
|
9
|
-
import { ar as ie, as as oe, A as ce, ap as de } from "./index-
|
|
9
|
+
import { ar as ie, as as oe, A as ce, ap as de } from "./index-B7eWP_hB.js";
|
|
10
10
|
import { useQuery as fe } from "@tanstack/react-query";
|
|
11
11
|
function me(t, n) {
|
|
12
12
|
const o = ie(), s = oe(), u = T(t.uid, "draft:") || T(n.uid, "live:");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-BqwKw4uy.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-BqwKw4uy.cjs"),a=require("./index-xYnNKovy.cjs"),n=require("./index-BwH1mRm_.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-B7J3t0FN.cjs"))),q=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-B06iZEIO.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,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-ESJHs5s-.js";
|
|
3
|
-
import { D as B, d as H, e as O, f as W, p as q, L as R, q as J, n as K, r as Q, s as V, t as X, v as w } from "./index-
|
|
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, d as H, e as O, f as W, p as q, L as R, q as J, n as K, r as Q, s as V, t as X, v as w } from "./index-RYr8kQdI.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-B7eWP_hB.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-2GfBi8Iv.js")), ye = z(() => import("./unpublish-page-DqwBY2yI.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"),c=require("./register-chai-top-bar-BqwKw4uy.cjs"),v=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./register-chai-top-bar-BqwKw4uy.cjs"),v=require("./index-xYnNKovy.cjs"),Z=require("./apply-binding-IsUf6UWJ.cjs"),u=require("@radix-ui/react-icons"),$=require("jotai"),U=require("nanoid"),a=require("react"),Q=require("react-i18next"),p=require("sonner"),_=require("tailwind-merge"),q=t=>{const n=t.trim();return n.length===0||n.length>25?!1:/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(n)},H=(t,n,o,m=!1,i)=>{const x=t.trim();return x.length===0?"":x.length>25?o("Token name must be 25 characters or less"):/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(x)?Object.entries(n).find(([l,N])=>N.name===x&&(!m||l!==i))?o("Token name already exists"):"":o("Only alphanumeric characters and hyphens allowed")},K=t=>t.replace(/\s+/g,"-"),X=a.lazy(()=>Promise.resolve().then(()=>require("./delete-design-token-Mbw_6sYI.cjs"))),J=a.lazy(()=>Promise.resolve().then(()=>require("./design-token-usage-BoGOULG8.cjs"))),Y=({tokenId:t,token:n,isDisabled:o,onEdit:m,onDelete:i})=>e.jsxs("div",{className:"group relative flex items-center justify-between overflow-hidden rounded border p-2 transition-all duration-150 hover:bg-muted/90",children:[e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:"text-xs font-semibold",children:n.name}),e.jsx("div",{className:"w-full max-w-52 truncate text-[10px] font-light",children:n.value})]}),e.jsxs("div",{className:"absolute right-1 top-1 flex flex-shrink-0 items-center opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:[e.jsx(a.Suspense,{fallback:null,children:e.jsx(J,{tokenId:t,tokenName:n.name,children:e.jsx(c.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 rounded-full p-0 hover:bg-primary/10 hover:text-primary",children:e.jsx(u.EyeOpenIcon,{className:"h-3 w-3"})})})}),e.jsx(c.Button,{variant:"ghost",size:"sm",onClick:()=>m(t),disabled:o,className:"h-6 w-6 rounded-full p-0 hover:bg-primary/10 hover:text-primary",children:e.jsx(u.Pencil1Icon,{className:"h-3 w-3"})}),e.jsx(a.Suspense,{fallback:null,children:e.jsx(X,{tokenName:n.name,tokenValue:n.value,onDelete:()=>i(t),children:e.jsx(c.Button,{variant:"ghost",size:"sm",disabled:o,className:"h-6 w-6 rounded-full p-0 hover:bg-destructive/10",children:e.jsx(u.TrashIcon,{className:"h-3 w-3 text-destructive"})})})})]})]}),ee=({})=>{const{t}=Q.useTranslation(),[n,o]=$.useAtom(v.chaiDesignTokensAtom),m=v.useIncrementActionsCount(),[i,x]=a.useState("view"),[j,k]=a.useState(null),[l,N]=a.useState(""),[h,b]=a.useState(""),[T,y]=a.useState(""),[w,E]=a.useState(""),[z,C]=a.useState(!1),f=a.useRef(null),I=a.useMemo(()=>Object.entries(n).filter(([,s])=>s.name.toLowerCase().includes(w.toLowerCase())||s.value.toLowerCase().includes(w.toLowerCase())),[n,w]);a.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const S=a.useCallback((s,r)=>{!j||i!=="edit"||!s.trim()||!r.trim()||!q(s)||Object.entries(n).find(([g,W])=>W.name===s.trim()&&g!==j)||(C(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{const g={...n,[j]:{name:s.trim(),value:r.trim()}};o(g),m(),C(!1)},250))},[j,i,n,o,m]),M=()=>{if(!l.trim()||!h.trim()){p.toast.error(t("Please fill in both token name and classes"));return}if(!q(l)){p.toast.error(t("Invalid design token name format"));return}if(Object.values(n).find(g=>g.name===l.trim())){p.toast.error(t("Token already exists"));return}const r=`${Z.DESIGN_TOKEN_PREFIX}${U.nanoid(12)}`,d={...n,[r]:{name:l.trim(),value:h.trim()}};o(d),m(),p.toast.success(t("Token added successfully")),A()},P=s=>{const r={...n};delete r[s],o(r),m(),p.toast.success(t("Token deleted successfully"))},R=s=>{const r=n[s];r&&(k(s),N(r.name),b(r.value),y(""),x("edit"))},B=()=>{k(null),N(""),b(""),y(""),x("add")},A=()=>{f.current&&clearTimeout(f.current),k(null),N(""),b(""),y(""),C(!1),x("view")},O=s=>{const r=K(s);N(r);const d=H(r,n,t,i==="edit",j||void 0);y(d),i==="edit"&&!d&&S(r,h)},D=s=>{b(s),i==="edit"&&!T&&l.trim()&&S(l,s)},L=s=>{const r=v.orderClassesByBreakpoint(v.removeDuplicateClasses(_.twMerge(h,s)));D(r)},F=s=>{const r=h.split(" ").filter(d=>d!==s).join(" ");D(r)},G=()=>{const s=i==="edit",r=t(s?"Edit Design Token":"Add Design Token"),d=t(s?"Update design token. Auto-saved.":"Create a reusable design token");return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-border/50 bg-muted p-1.5",children:[e.jsx(c.Button,{variant:"ghost",size:"sm",onClick:A,className:"h-6 w-6 rounded-full p-0 hover:bg-muted",children:e.jsx(u.ArrowLeftIcon,{className:"h-3 w-3"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:r}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:d})]}),s&&z&&e.jsx("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:e.jsx("div",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-primary"})})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v.Label,{htmlFor:"token-name",className:"text-xs font-medium",children:t("Token Name")}),e.jsx(c.Input,{id:"token-name",placeholder:"Button-Primary",value:l,onChange:g=>O(g.target.value),className:"h-7 text-xs"}),T?e.jsx("span",{className:"text-[10px] text-destructive",children:T}):e.jsx("span",{className:"text-[10px] font-light text-muted-foreground",children:t("Button-Primary, Card-Header, Text-Large etc.")})]}),e.jsx(v.ManualClasses,{from:"designToken",classFromProps:h,onAddNew:L,onRemove:F}),!s&&e.jsxs("div",{className:"mt-3 flex items-center justify-end gap-2 pt-3",children:[e.jsx(c.Button,{variant:"outline",onClick:A,className:"h-7 text-xs",children:t("Cancel")}),e.jsx(c.Button,{onClick:M,disabled:!l.trim()||!h.trim()||!!T,className:"h-7 text-xs",children:t("Add Token")})]})]})]})},V=()=>e.jsxs(e.Fragment,{children:[Object.entries(n).length>0&&e.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(u.MagnifyingGlassIcon,{className:"absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),e.jsx(c.Input,{placeholder:t("Search tokens"),value:w,onChange:s=>E(s.target.value),className:"h-6 pl-7 text-xs"})]}),e.jsxs(c.Button,{variant:"outline",onClick:B,size:"sm",className:"h-6 border-primary text-xs text-primary hover:bg-primary/10 hover:text-primary",children:[e.jsx(u.PlusIcon,{className:"h-3 w-3"}),t("Add")]})]}),e.jsx("div",{className:"no-scrollbar flex flex-1 flex-col overflow-hidden pt-2",children:e.jsx(v.ScrollArea,{className:"h-full flex-1",children:e.jsxs("div",{className:"space-y-1",children:[Object.entries(n).length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-muted bg-muted/20 py-8",children:[e.jsx("div",{className:"mb-2 text-3xl",children:e.jsx(u.TokensIcon,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:t("No design tokens yet")}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:t("Create reusable design tokens to streamline your styling")}),e.jsxs(c.Button,{variant:"default",onClick:B,size:"sm",className:"mt-4 h-7 text-xs leading-tight",children:[e.jsx(u.PlusIcon,{className:"mr-1 h-3 w-3"}),t("Add first design token")]})]}):I.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-muted bg-muted/20 py-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx(u.MagnifyingGlassIcon,{className:"h-10 w-10 text-muted-foreground"})}),e.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:t("No tokens found")}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:t("No design tokens match your search")})]}):I.map(([s,r])=>e.jsx(Y,{token:r,tokenId:s,onEdit:R,onDelete:P,isDisabled:!1},s)),e.jsx("div",{className:"h-44"})]})})})]});return e.jsx("div",{className:"flex h-full w-full flex-col",children:i==="view"?V():G()})};exports.default=ee;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e, jsxs as a, Fragment as Q } from "react/jsx-runtime";
|
|
2
2
|
import { z, B as u } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
3
|
-
import { a0 as _, a1 as H, a2 as K, L as X, a3 as q, a4 as J, a5 as Y } from "./index-
|
|
3
|
+
import { a0 as _, a1 as H, a2 as K, L as X, a3 as q, a4 as J, a5 as Y } from "./index-RYr8kQdI.js";
|
|
4
4
|
import { D as ee } from "./apply-binding-BvWfJCSZ.js";
|
|
5
5
|
import { MagnifyingGlassIcon as L, PlusIcon as O, TokensIcon as te, ArrowLeftIcon as ne, EyeOpenIcon as se, Pencil1Icon as re, TrashIcon as ae } from "@radix-ui/react-icons";
|
|
6
6
|
import { useAtom as oe } from "jotai";
|
|
@@ -17,7 +17,7 @@ const S = (n) => {
|
|
|
17
17
|
return m.length === 0 ? "" : m.length > 25 ? o("Token name must be 25 characters or less") : /^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(m) ? Object.entries(s).find(
|
|
18
18
|
([l, v]) => v.name === m && (!d || l !== i)
|
|
19
19
|
) ? o("Token name already exists") : "" : o("Only alphanumeric characters and hyphens allowed");
|
|
20
|
-
}, xe = (n) => n.replace(/\s+/g, "-"), ge = M(() => import("./delete-design-token-
|
|
20
|
+
}, xe = (n) => n.replace(/\s+/g, "-"), ge = M(() => import("./delete-design-token-C1smbx4E.js")), pe = M(() => import("./design-token-usage-DyO3xM-F.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,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-ESJHs5s-.js";
|
|
3
|
-
import { D as L, d as P, e as B, f as E, p as S, L as w, T as U, q as R } from "./index-
|
|
4
|
-
import { q as j, m as O } from "./index-
|
|
3
|
+
import { D as L, d as P, e as B, f as E, p as S, L as w, T as U, q as R } from "./index-RYr8kQdI.js";
|
|
4
|
+
import { q as j, m as O } from "./index-B7eWP_hB.js";
|
|
5
5
|
import { startCase as y } from "lodash-es";
|
|
6
6
|
import { Tag as q, File as X, ImageIcon as _, X as $ } from "lucide-react";
|
|
7
7
|
import { useState as m, useRef as H, useCallback as K } from "react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./register-chai-top-bar-BqwKw4uy.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-BqwKw4uy.cjs"),t=require("./index-xYnNKovy.cjs"),y=require("./index-BwH1mRm_.cjs"),w=require("lodash-es"),m=require("lucide-react"),l=require("react"),M=require("react-i18next"),k=require("sonner"),B=1*1024*1024,A=({page:r,onClose:u})=>{const{t:s}=M.useTranslation(),[f,p]=l.useState(!1),[j,T]=l.useState(""),[c,N]=l.useState(""),[v,x]=l.useState(!1),i=l.useRef(null),C=y.useMarkAsTemplate(),{data:h}=y.usePageTypes(),g=h==null?void 0:h.find(a=>a.key===r.pageType),I=(g==null?void 0:g.name)||w.startCase(r.pageType),D=l.useCallback(a=>{var b;const d=(b=a.target.files)==null?void 0:b[0];if(d){if(d.size>B){k.toast.error(s("File too large"),{description:`${s("Maximum file size is 1MB. Selected file is")} ${(d.size/1024).toFixed(2)}KB.`}),i.current&&(i.current.value="");return}try{x(!0);const n=new FileReader;n.onloadend=()=>{N(n.result),x(!1)},n.readAsDataURL(d)}catch(n){console.error("Error reading file:",n),x(!1),k.toast.error(s("Failed to process image"),{description:n instanceof Error?n.message:s("Unknown error")})}}},[s]),F=()=>{N(""),i.current&&(i.current.value="")},S=()=>{var a;(a=i.current)==null||a.click()},q=()=>{p(!0),C.mutate({page:r,name:r.name,description:j.trim()||void 0,pageType:r.pageType,...c?{previewImage:c}:{}},{onSuccess:()=>{p(!1),u()},onError:()=>{p(!1)}})};return e.jsx(t.Dialog,{open:!0,onOpenChange:u,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:s("Mark as template")}),e.jsxs(t.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:[s("Are you sure you want to mark this page as a template?"),e.jsx("br",{}),s("Templates can be used to create new pages with the same content.")]})]}),e.jsxs("div",{className:"mb-4 space-y-4 text-xs",children:[e.jsxs("div",{className:"space-y-3 rounded border bg-slate-50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m.Tag,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Page Name"),":"]}),e.jsx("span",{className:"font-semibold",children:w.startCase(r.name)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m.File,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Type"),":"]}),e.jsx("span",{className:"font-semibold",children:I})]})]}),e.jsxs("div",{children:[e.jsx(t.Label,{htmlFor:"description",className:"text-xs font-medium",children:s("Description (Optional)")}),e.jsx(t.Textarea,{id:"description",placeholder:s("Describe this template's purpose"),className:"mt-1 h-24 resize-none text-xs",value:j,onChange:a=>T(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"previewImage",className:"text-xs font-medium",children:s("Preview Image (Optional)")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o.Input,{type:"file",id:"previewImage",ref:i,onChange:D,accept:"image/*",className:"hidden"}),e.jsx(o.Button,{type:"button",variant:"outline",onClick:S,disabled:v,className:"w-full",children:v?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),s("Uploading...")]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(m.ImageIcon,{className:"h-4 w-4"}),s("Select image")]})}),c&&e.jsx(o.Button,{type:"button",variant:"outline",size:"icon",onClick:F,children:e.jsx(m.X,{className:"h-4 w-4"})})]}),c&&e.jsx("div",{className:"aspect-video overflow-hidden rounded-md border",children:e.jsx("img",{src:c,alt:s("Preview"),className:"h-full max-h-[200px] w-full object-contain"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("max 1mb")})]})]})]}),e.jsxs(t.DialogFooter,{className:f?"pointer-events-none opacity-75":"",children:[e.jsx(o.Button,{variant:"outline",onClick:a=>{a.stopPropagation(),u()},children:s("Cancel")}),e.jsx(o.Button,{variant:"default",disabled:f,onClick:q,children:s("Mark as template")})]})]})})};exports.default=A;
|
package/dist/{nested-path-selector-content-C2sD9dkq.cjs → nested-path-selector-content-SmfjElr-.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-BqwKw4uy.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-BqwKw4uy.cjs"),a=require("./index-xYnNKovy.cjs");function C(c){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const r in c)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(c,r);Object.defineProperty(l,r,i.get?i:{enumerable:!0,get:()=>c[r]})}}return l.default=c,Object.freeze(l)}const o=C(p);function N({data:c,onSelect:l,dataType:r="value",open:i,setOpen:m}){const[u,f]=o.useState([]),[h,j]=o.useState(c);o.useEffect(()=>{i||f([]),j(c)},[c,i]);const b=e=>Array.isArray(e)?"array":typeof e=="object"&&e!==null?"object":"value",y=o.useCallback(e=>{const n=s=>r==="value"?s==="value"||s==="object":r==="array"?s==="array":s===r;e.type==="object"?(f(s=>[...s,e.key]),j(e.value)):n(e.type)&&(l([...u,e.key].join(".")),m(!1))},[r,l,u,m]),x=o.useCallback(()=>{if(u.length>0){const e=u.slice(0,-1);f(e),j(e.reduce((n,s)=>n[s],c))}},[u,c]),g=o.useMemo(()=>Object.entries(h).map(([e,n])=>({key:e,value:n,type:b(n)})).filter(e=>r==="value"?e.type==="value"||e.type==="object":r==="array"?e.type==="array"||e.type==="object":r==="object"?e.type==="object":!0),[h,r]);return t.jsx(a.PopoverContent,{className:"z-[9999] w-[200px] p-0",children:t.jsxs(a.Command,{children:[t.jsx(a.CommandInput,{className:"border-none",placeholder:"Search..."}),t.jsxs(a.CommandList,{onWheel:e=>{try{e.preventDefault();const n=e.currentTarget;n.scrollTop+=e.deltaY}catch{e.preventDefault()}},children:[t.jsx(a.CommandEmpty,{children:"No option found."}),t.jsxs(a.CommandGroup,{children:[u.length>0&&t.jsxs(a.CommandItem,{onSelect:x,className:"flex items-center text-sm",children:[t.jsx(d.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),g.map(e=>t.jsxs(a.CommandItem,{onSelect:()=>y(e),className:"flex items-center justify-between",children:[t.jsx("span",{children:e.key}),t.jsxs("div",{className:"flex items-center gap-2",children:[r==="object"&&e.type==="object"&&t.jsx(v.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:n=>{n.stopPropagation(),l([...u,e.key].join(".")),m(!1)},children:"Select"}),(e.type==="object"||e.type==="array")&&t.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:t.jsx(d.ChevronRight,{className:"h-4 w-4 opacity-50"})})]})]},e.key))]})]})]})})}exports.default=N;
|
package/dist/{nested-path-selector-content-6OBJ8LG8.js → nested-path-selector-content-kGznHufl.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-ESJHs5s-.js";
|
|
5
|
-
import { P as N, C as x, i as P, j as S, k as w, l as B, m as d } from "./index-
|
|
5
|
+
import { P as N, C as x, i as P, j as S, k as w, l as B, m as d } from "./index-RYr8kQdI.js";
|
|
6
6
|
function I({
|
|
7
7
|
data: o,
|
|
8
8
|
onSelect: m,
|
package/dist/{no-language-page-content-BvPDdccK.cjs → no-language-page-content-B4bQLc4K.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-BqwKw4uy.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-BqwKw4uy.cjs"),t=require("./index-xYnNKovy.cjs"),n=require("./index-BwH1mRm_.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,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-ESJHs5s-.js";
|
|
3
|
-
import { n as u, R as w, U as p, V as f, W as P, X as C } from "./index-
|
|
4
|
-
import { c as S, d as L, L as x, B as N } from "./index-
|
|
3
|
+
import { n as u, R as w, U as p, V as f, W as P, X as C } from "./index-RYr8kQdI.js";
|
|
4
|
+
import { c as S, d as L, L as x, B as N } from "./index-B7eWP_hB.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";
|
|
@@ -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-BwH1mRm_.cjs"),n=require("react"),t=n.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content-B4bQLc4K.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-B7eWP_hB.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-DXsAPDZd.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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./register-chai-top-bar-BqwKw4uy.cjs"),a=require("./index-C99FhuF1.cjs"),w=require("lodash-es"),o=require("react"),_=require("./slug-input-Cyd6NR6J.cjs"),N=require("lucide-react"),k=require("./index-C0-pgg_p.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-BqwKw4uy.cjs"),a=require("./index-xYnNKovy.cjs"),o=require("react"),_=require("./slug-input-Dp187Tiy.cjs"),w=require("lodash-es"),N=require("lucide-react"),k=require("./index-BwH1mRm_.cjs"),je=require("@tanstack/react-query"),J=require("sonner"),fe=require("./get-seo-defaults-Cw7vFt-B.cjs");function Ue({value:t,onChange:c,placeholder:j="Enter custom slug part",dynamicPattern:p,onValidationChange:i}){const[f,m]=o.useState(null),h=o.useRef(null),[g,T]=o.useState(p+t);o.useEffect(()=>{T(p+t)},[t,p]);const O=S=>{const C=S.target.value;if(!C.startsWith(p)){const W=C.replace(p,""),G=p+W;T(G),c(W);return}const l=C.substring(p.length).replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),n=(l.match(/\./g)||[]).length,x=n<=1;n>1?m("Invalid slug. Only one dot (.) is allowed in the slug"):m(null),i&&i(x);const y=p+l;T(y),c(l)},b=()=>{if(h.current){const S=h.current;setTimeout(()=>{const C=p.length;S.setSelectionRange(C,C)},0)}},R=S=>{const C=S.currentTarget;(C.selectionStart||0)<=p.length&&setTimeout(()=>{const l=p.length;C.setSelectionRange(l,l)},0)};return e.jsx("div",{children:e.jsxs("div",{className:"relative",children:[e.jsxs("p",{className:"mb-2 text-xs text-gray-500",children:[`${p}`," is a dynamic segment of slug"]}),e.jsx(v.Input,{ref:h,value:g,onChange:O,onFocus:b,onClick:R,placeholder:j,className:f?"border-red-500":""}),f&&e.jsx("div",{className:"mt-1 text-xs text-red-500",children:f})]})})}const X=({children:t,onWheel:c,...j})=>{const p=i=>{try{i.preventDefault();const f=i.currentTarget;f.scrollTop+=i.deltaY}catch{i.preventDefault()}c&&c(i)};return e.jsx(a.CommandList,{...j,onWheel:p,children:t})},te=(...t)=>t.filter(Boolean).join(" ");function ze({pages:t,selectedParentId:c,onChange:j,className:p,id:i="parentPage",currentPage:f}){const[m,h]=o.useState(!1),[g,T]=o.useState(""),O=v.useChaiFeatureFlag("enable-add-page-dropdown");O||(p="w-full rounded-md border border-gray-300 px-3 py-2");const b=o.useMemo(()=>!t||t.length===0?[]:t.filter(x=>!w.isEmpty(x.slug)).filter(x=>x.slug!=="/").sort((x,y)=>x.slug.localeCompare(y.slug)),[t]),R=o.useMemo(()=>{if(!g.trim())return b;const n=g.toLowerCase();return b.filter(x=>x.name.toLowerCase().includes(n)||x.slug.toLowerCase().includes(n))},[b,g]),S=n=>Math.max(0,(n.match(/\//g)||[]).length-1),C=n=>" ".repeat(n),d=n=>{if(n==="/")return"/";const x=n.split("/").filter(Boolean);if(x.length<=1){const y=x[0]||"";return`/${_.removeSlugExtension(y)}`}return`/${_.removeSlugExtension(x[x.length-1])}`},l=()=>{if(!c||c==="none")return"None";const n=b.find(x=>x.id===c);return n?`${n.name} (${d(n.slug)})`:"None"};return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:i,className:"text-sm",children:"Parent"}),O?e.jsxs(a.Popover,{open:m,onOpenChange:h,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{id:i,variant:"outline",role:"combobox",className:te("w-full justify-between",p),"data-testid":"parent-page-selector",children:[l(),e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"relative border-none py-2",children:e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search pages...",className:"h-8 pl-8 text-xs",value:g,onChange:n=>T(n.target.value)})]})})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No pages found."}),e.jsxs(a.CommandGroup,{children:[e.jsxs(a.CommandItem,{value:"none",onSelect:()=>{j(""),h(!1),T("")},className:"flex cursor-pointer items-center justify-between",children:[e.jsx("span",{children:"None"}),e.jsx(N.Check,{className:te("mr-2 h-4 w-4",c?"opacity-0":"opacity-100")})]}),R.map(n=>{const x=C(S(n.slug)),y=d(n.slug),W=e.jsxs("span",{className:"flex items-center text-sm",children:[x,n.name,e.jsxs("span",{className:"text-xs text-gray-500",children:[" (",y,")"]})]});return e.jsxs(a.CommandItem,{value:n.id,onSelect:()=>{j(n.id),h(!1),T("")},className:"flex cursor-pointer items-center justify-between whitespace-pre-wrap",children:[e.jsx("span",{children:W}),e.jsx(N.Check,{className:te("mr-2 h-4 w-4 shrink-0",c===n.id?"opacity-100":"opacity-0")})]},n.id)})]})]})]})})]}):e.jsxs("select",{id:i,value:c||"none",onChange:n=>j(n.target.value),className:p,"data-testid":"parent-page-selector",children:[e.jsx("option",{value:"none",children:"None"}),b.map(n=>{const x=S(n.slug),y=x>0?C(x):"",W=d(n.slug);return(f==null?void 0:f.id)===n.id||n.slug.startsWith(f==null?void 0:f.slug)?null:e.jsxs("option",{value:n.id,children:[y,n.name," (",W,")"]},n.id)})]})]})}const _e=(...t)=>t.filter(Boolean).join(" "),Ve=({templates:t,selectedTemplateId:c,onSelectTemplate:j,isLoading:p=!1})=>{const[i,f]=o.useState(""),[m,h]=o.useState(!1),[g,T]=o.useState(""),O=v.useChaiFeatureFlag("enable-add-page-dropdown");if(o.useEffect(()=>{if(c){const d=t.find(l=>l.id===c);o.startTransition(()=>f((d==null?void 0:d.preview)||""))}else o.startTransition(()=>f(""))},[c,t]),p)return e.jsx("div",{className:"flex h-fit items-center justify-center text-sm text-gray-500",children:"Loading templates..."});if(t.length===0)return null;const b={};t.forEach(d=>{const l=d.libraryName;b[l]||(b[l]=[]),b[l].push(d)});const R=Object.entries(b).reduce((d,[l,n])=>{const x=n.filter(y=>y.name.toLowerCase().includes(g.toLowerCase())||l.toLowerCase().includes(g.toLowerCase()));return x.length>0&&(d[l]=x),d},{}),S=t.find(d=>d.id===c),C=S?w.startCase(S.name):"No Template";return e.jsxs("div",{className:"space-y-4",children:[O?e.jsxs(a.Popover,{open:m,onOpenChange:h,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",className:"w-full justify-between",children:[C,e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search templates...",className:"h-8 pl-8 text-xs",value:g,onChange:d=>T(d.target.value)})]})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No templates found."}),Object.entries(R).map(([d,l])=>e.jsx(a.CommandGroup,{heading:d,children:l.map(n=>e.jsxs(a.CommandItem,{value:n.id,onSelect:()=>{j(n.id),h(!1),T("")},className:"flex cursor-pointer items-center justify-between",children:[w.startCase(n.name),e.jsx(N.Check,{className:_e("mr-2 h-4 w-4",c===n.id?"opacity-100":"opacity-0")})]},n.id))},d))]})]})})]}):e.jsxs("select",{className:"w-full rounded-md border border-gray-300 px-3 py-2",value:c,onChange:d=>j(d.target.value),children:[e.jsx("option",{value:"",children:"No Template"}),Object.entries(b).map(([d,l])=>e.jsx("optgroup",{label:d,children:l.map(n=>e.jsx("option",{value:n.id,children:w.startCase(n.name)},n.id))},d))]}),i&&e.jsxs("div",{className:"mt-3 overflow-hidden rounded border",children:[e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("img",{src:i,alt:"Template Preview",className:"w-full object-contain"})}),e.jsx("div",{className:"border-t bg-gray-50 p-2 text-xs text-gray-500",children:"Template preview"})]})]})},$e=()=>{const t=k.useApiUrl(),c=k.useFetch();return je.useQuery({queryKey:[k.ACTIONS.GET_LIBRARIES],staleTime:"static",queryFn:async()=>await c(t,{action:k.ACTIONS.GET_LIBRARIES})||[]})},Qe=t=>{const c=k.useApiUrl(),j=k.useFetch();return je.useQuery({queryKey:[k.ACTIONS.GET_TEMPLATES_BY_TYPE,t],staleTime:"static",enabled:!!t,queryFn:async()=>{const p=await j(c,{action:k.ACTIONS.GET_TEMPLATES_BY_TYPE,data:{pageType:t}});return(t?w.filter(p,{pageType:t}):p)||[]}})},Ye=t=>{const{data:c=[],isLoading:j}=Qe(t),{data:p=[],isLoading:i}=$e(),f=o.useMemo(()=>j||i?[]:c.map(h=>{const g=w.find(p,{id:h.library});return{...h,libraryName:(g==null?void 0:g.type)!=="shared"?"Site Library":(g==null?void 0:g.name)+" Library",libraryType:g==null?void 0:g.type}}),[c,p,j,i]),m=o.useMemo(()=>w.groupBy(f,"libraryName"),[f]);return{data:f,groupedData:m,isLoading:j||i}},z=(...t)=>t.filter(Boolean).join(" ");function He({addEditPage:t,close:c,closePanel:j}){var xe,ge;const{data:p}=k.usePageTypes(),i=o.useMemo(()=>p??[],[p]),f=k.useChangePage(),m=!!(t!=null&&t.id),{data:h}=k.useWebsitePages(),{mutate:g,isPending:T}=k.useCreatePage(),{mutate:O,isPending:b}=k.useUpdatePage(),[R,S]=o.useState(null),[C,d]=o.useState(!0),[l,n]=o.useState((t==null?void 0:t.pageType)??"page"),{hasPermission:x}=a.usePermissions(),y=x(k.PAGES_PERMISSIONS.CHANGE_PAGE_TYPE),[W,G]=o.useState(!1),[ye,ve]=o.useState(""),{selectedLang:Se,fallbackLang:Ce}=a.useLanguages(),ne=Se||Ce,[V,H]=o.useState(""),[ae,Q]=o.useState(!1),le=o.useMemo(()=>{const s=i.find(u=>u.key===l);return(s==null?void 0:s.hasSlug)===!1},[l,i]),[D,Ne]=o.useState((t==null?void 0:t.parent)??""),[M,re]=o.useState((t==null?void 0:t.name)??""),[F,oe]=o.useState((t==null?void 0:t.dynamic)??!1),[B,Y]=o.useState(F?"":((t==null?void 0:t.slug)??"").split("/").pop()||""),[ie,ce]=o.useState((t==null?void 0:t.dynamicSlugCustom)??""),[ue,be]=o.useState(!0),[we,P]=o.useState(!1),[E,ke]=o.useState(""),{data:me,isLoading:Le}=Ye(l),$=T||b,he=v.useChaiFeatureFlag("enable-add-page-dropdown"),ee=o.useMemo(()=>!m||!(t!=null&&t.id)||!h?null:h.find(s=>s.id===t.id),[m,t==null?void 0:t.id,h]),Te=(ee==null?void 0:ee.online)||!1,De=o.useMemo(()=>!m||!(t!=null&&t.id)||!h?!1:h.some(s=>s.parent===t.id),[m,t==null?void 0:t.id,h]),r=i.find(s=>s.key===l),U=s=>{if(m&&l!==s){ve(s),G(!0),H(""),Q(!1);return}n(s),H(""),Q(!1)},pe=()=>{n(ye),G(!1),oe(!1)},Ie=s=>{oe(s),s?Y(""):ce("")},Fe=s=>{if(Ne(s),s&&s!=="none"){const u=h==null?void 0:h.find(L=>L.id===s),q=(u==null?void 0:u.slug)||"";if(B.startsWith(q)){const L=B.slice(q.length).replace(/^\/+/,"");Y(L)}else Y(B.replace(/^\/+/,""))}else Y(B?`${B}`:"")},Be=s=>{ke(s)},qe=()=>M.trim()?F&&!w.isEmpty(B)?(S("Slug must be empty when using dynamic slug"),!1):F&&!ue?(S("Dynamic slug is invalid"),!1):!0:(J.toast.error("Name is required"),!1),Ae=()=>{const s={pageType:r==null?void 0:r.key,name:M,slug:"",hasSlug:!1};m?O({id:t==null?void 0:t.id,name:M},{onSuccess:()=>{J.toast.success((r==null?void 0:r.name)+" updated successfully"),c()}}):g(s,{onSuccess:u=>{c(),f(u.page.id,j)}})},Oe=(s,u)=>{if(!s.trim()&&!F)return S("Child page slug is required"),!1;const q=_.removeSlugExtension(u),L=_.combineParentChildSlugs(q,s);return Object.keys(k.LANGUAGES).some(Z=>L===`/${Z}`||(L==null?void 0:L.startsWith(`/${Z}/`)))?(S("Slugs cannot start with a language code for primary page"),!1):!0},We=(s,u)=>{const q=_.removeSlugExtension(u),L=_.combineParentChildSlugs(q,s),I={pageType:l,name:M,slug:L.replace(/\/$/,""),parent:D,dynamic:F,hasSlug:!0,template:E||void 0,tracking:{},seo:{},jsonLD:{}};if(F&&(I.dynamicSlugCustom=ie),m){const A=w.pick(I,["pageType","parent","name","slug","dynamic","dynamicSlugCustom"]);O({id:t==null?void 0:t.id,...A},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}})}else{const A=w.find(i,{key:l});A!=null&&A.trackingDefault&&(I.tracking=A.trackingDefault);const{seo:Z,jsonLD:Ge}=fe.getSeoDefaults(A,ne);w.set(I,"seo",Z),w.set(I,"jsonLD",Ge),g(I,{onSuccess:Me=>{c(),f(Me.page.id,j)}})}},Re=()=>{const s={pageType:l,name:M,slug:B===""?"/":`/${B.replace(/\/$/,"")}`,template:E||void 0,parent:null,tracking:{}};if(m)O({id:t==null?void 0:t.id,...s},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}});else{const u=w.find(i,{key:l});u!=null&&u.trackingDefault&&(s.tracking=u.trackingDefault);const{seo:q,jsonLD:L}=fe.getSeoDefaults(u,ne);w.set(s,"seo",q),w.set(s,"jsonLD",L),g(s,{onSuccess:I=>{var A;(A=I==null?void 0:I.page)!=null&&A.id&&f(I.page.id,j),c()}})}},de=s=>{if(s.preventDefault(),S(null),!!qe()){if(!(r!=null&&r.hasSlug)){Ae();return}if(D&&D!=="none"){const u=h==null?void 0:h.find(L=>L.id===D),q=(u==null?void 0:u.slug)||"";if(!Oe(B,q))return;We(B,q)}else Re()}},{pagesType:se,partialsType:K}=o.useMemo(()=>{const s=u=>V?u.name.toLowerCase().includes(V.toLowerCase())||u.key.toLowerCase().includes(V.toLowerCase()):!0;return{pagesType:i.filter(u=>u.hasSlug!==!1&&s(u)),partialsType:i.filter(u=>u.hasSlug===!1&&s(u))}},[i,V]);return r!=null&&r.hasSlug?e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(a.Popover,{open:ae,onOpenChange:Q,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:z("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:V,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No page type found."}),m?le?e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsx(a.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsxs(e.Fragment,{children:[se.length>0&&e.jsx(a.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}),K.length>0&&e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>U(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:m?le?e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsx("optgroup",{label:"Pages",children:i.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsxs(e.Fragment,{children:[e.jsx("optgroup",{label:"Pages",children:i.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}),e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})]})}),W&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(v.Button,{variant:"outline",size:"sm",onClick:()=>G(!1),children:"Cancel"}),e.jsx(v.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]})]}),!m&&(r==null?void 0:r.hasSlug)&&me.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.Label,{className:"mb-1 block text-sm",children:"Template"}),e.jsx(Ve,{templates:me,selectedTemplateId:E,onSelectTemplate:Be,isLoading:Le})]}),e.jsx(ze,{pages:h,selectedParentId:D,onChange:Fe,currentPage:t}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(v.Input,{id:"name",value:M,onChange:s=>re(s.target.value),required:!0,"aria-required":"true",placeholder:"Enter page name"})]}),(r==null?void 0:r.dynamicSegments)&&D&&D!=="none"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"useDynamicSlug",checked:F,onChange:s=>Ie(s.target.checked),className:"rounded border-gray-300"}),e.jsx(a.Label,{htmlFor:"useDynamicSlug",className:"text-sm",children:"Use Dynamic Slug"})]}),F&&e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"space-y-0.5",children:e.jsx(Ue,{value:ie,onChange:ce,dynamicPattern:(r==null?void 0:r.dynamicSlug)||"{{id}}",placeholder:"Enter custom slug part (optional)",onValidationChange:be})})})]}),(!(r!=null&&r.dynamicSegments)||!F)&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx(_.SlugInput,{value:B,onChange:s=>{var u;Y(s),m&&s!==(((u=t==null?void 0:t.slug)==null?void 0:u.split("/").pop())||"")?P(!!(Te||De)):P(!1)},placeholder:D&&D!=="none"?"Enter page slug":l==="page"?"Leave empty for home page":"Required - e.g. your-slug",parentSlug:D&&D!=="none"?(ge=h==null?void 0:h.find(s=>s.id===D))==null?void 0:ge.slug:void 0,onValidationChange:d}),R&&e.jsx("p",{className:"text-xs text-red-500",children:R}),we&&e.jsx("div",{className:"mt-4 rounded-md border border-amber-200 bg-amber-50 p-3",children:e.jsxs("div",{className:"flex items-start space-x-2",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-amber-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-amber-800",children:"Slug Change Warning"}),e.jsx("div",{className:"mt-1 text-sm text-amber-700",children:e.jsx("p",{children:"The previous URL and any child pages will become inaccessible. You may want to set up a redirect to avoid broken links."})})]})]})})]}),e.jsx(v.Button,{disabled:$||!C&&(!(r!=null&&r.dynamicSegments)||!F)||F&&!ue,type:"submit",className:"w-full",children:m?$?"Updating...":"Update page":$?"Creating...":"Create Page"})]}):e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(a.Popover,{open:ae,onOpenChange:Q,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:z("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:V,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"max-h-[200px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No page type found."}),e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>{U(s.key),Q(!1)},className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>U(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})}),W&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(v.Button,{variant:"outline",size:"sm",onClick:()=>G(!1),children:"Cancel"}),e.jsx(v.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:(xe=i.find(s=>s.key===l))==null?void 0:xe.helpText})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(v.Input,{id:"name",value:M,onChange:s=>re(s.target.value),required:!0,"aria-required":"true"})]}),e.jsx(v.Button,{disabled:$,type:"submit",className:"w-full",children:m?$?"Updating...":"Update "+(r==null?void 0:r.name):$?"Creating...":"Create "+(r==null?void 0:r.name)})]})}exports.default=He;
|
|
@@ -1,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-ESJHs5s-.js";
|
|
3
|
-
import { j as os, L as z, a6 as ee, a7 as se, P as ae, C as le, k as ne, l as G, m as I, ai as cs, n as us } from "./index-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { j as os, L as z, a6 as ee, a7 as se, P as ae, C as le, k as ne, l as G, m as I, ai as cs, n as us } from "./index-RYr8kQdI.js";
|
|
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-CeEQ0zyv.js";
|
|
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-B7eWP_hB.js";
|
|
9
9
|
import { useQuery as _e } from "@tanstack/react-query";
|
|
10
10
|
import { toast as E } from "sonner";
|
|
11
11
|
import { g as $e } from "./get-seo-defaults-9zHebckY.js";
|
|
@@ -16,8 +16,8 @@ function xs({
|
|
|
16
16
|
dynamicPattern: p,
|
|
17
17
|
onValidationChange: i
|
|
18
18
|
}) {
|
|
19
|
-
const [g, u] = y(null), m =
|
|
20
|
-
|
|
19
|
+
const [g, u] = y(null), m = ms(null), [f, C] = y(p + a);
|
|
20
|
+
ze(() => {
|
|
21
21
|
C(p + a);
|
|
22
22
|
}, [a, p]);
|
|
23
23
|
const F = (S) => {
|
|
@@ -86,7 +86,7 @@ function Cs({
|
|
|
86
86
|
}) {
|
|
87
87
|
const [u, m] = y(!1), [f, C] = y(""), F = ye("enable-add-page-dropdown");
|
|
88
88
|
F || (p = "w-full rounded-md border border-gray-300 px-3 py-2");
|
|
89
|
-
const w = B(() => !a || a.length === 0 ? [] : a.filter((d) => !
|
|
89
|
+
const w = B(() => !a || a.length === 0 ? [] : a.filter((d) => !Ie(d.slug)).filter((d) => d.slug !== "/").sort((d, N) => d.slug.localeCompare(N.slug)), [a]), $ = B(() => {
|
|
90
90
|
if (!f.trim()) return w;
|
|
91
91
|
const n = f.toLowerCase();
|
|
92
92
|
return w.filter(
|
|
@@ -221,7 +221,7 @@ const ks = (...a) => a.filter(Boolean).join(" "), Ls = ({
|
|
|
221
221
|
isLoading: p = !1
|
|
222
222
|
}) => {
|
|
223
223
|
const [i, g] = y(""), [u, m] = y(!1), [f, C] = y(""), F = ye("enable-add-page-dropdown");
|
|
224
|
-
if (
|
|
224
|
+
if (ze(() => {
|
|
225
225
|
if (o) {
|
|
226
226
|
const h = a.find((t) => t.id === o);
|
|
227
227
|
Oe(() => g((h == null ? void 0 : h.preview) || ""));
|
|
@@ -326,7 +326,7 @@ const ks = (...a) => a.filter(Boolean).join(" "), Ls = ({
|
|
|
326
326
|
action: oe.GET_TEMPLATES_BY_TYPE,
|
|
327
327
|
data: { pageType: a }
|
|
328
328
|
});
|
|
329
|
-
return (a ?
|
|
329
|
+
return (a ? ps(p, { pageType: a }) : p) || [];
|
|
330
330
|
}
|
|
331
331
|
});
|
|
332
332
|
}, Ds = (a) => {
|
|
@@ -337,7 +337,7 @@ const ks = (...a) => a.filter(Boolean).join(" "), Ls = ({
|
|
|
337
337
|
libraryName: (f == null ? void 0 : f.type) !== "shared" ? "Site Library" : (f == null ? void 0 : f.name) + " Library",
|
|
338
338
|
libraryType: f == null ? void 0 : f.type
|
|
339
339
|
};
|
|
340
|
-
}), [o, p, v, i]), u = B(() =>
|
|
340
|
+
}), [o, p, v, i]), u = B(() => ds(g, "libraryName"), [g]);
|
|
341
341
|
return {
|
|
342
342
|
data: g,
|
|
343
343
|
groupedData: u,
|
|
@@ -371,7 +371,7 @@ function qs({ addEditPage: a, close: o, closePanel: v }) {
|
|
|
371
371
|
K(j ? `${j}` : "");
|
|
372
372
|
}, es = (e) => {
|
|
373
373
|
Ke(e);
|
|
374
|
-
}, ss = () => _.trim() ? T && !
|
|
374
|
+
}, ss = () => _.trim() ? T && !Ie(j) ? (S("Slug must be empty when using dynamic slug"), !1) : T && !ke ? (S("Dynamic slug is invalid"), !1) : !0 : (E.error("Name is required"), !1), as = () => {
|
|
375
375
|
const e = {
|
|
376
376
|
pageType: r == null ? void 0 : r.key,
|
|
377
377
|
name: _,
|
|
@@ -410,7 +410,7 @@ function qs({ addEditPage: a, close: o, closePanel: v }) {
|
|
|
410
410
|
jsonLD: {}
|
|
411
411
|
};
|
|
412
412
|
if (T && (L.dynamicSlugCustom = xe), u) {
|
|
413
|
-
const A =
|
|
413
|
+
const A = fs(L, ["pageType", "parent", "name", "slug", "dynamic", "dynamicSlugCustom"]);
|
|
414
414
|
F(
|
|
415
415
|
{ id: a == null ? void 0 : a.id, ...A },
|
|
416
416
|
{
|
|
@@ -673,7 +673,7 @@ function qs({ addEditPage: a, close: o, closePanel: v }) {
|
|
|
673
673
|
(!(r != null && r.dynamicSegments) || !T) && /* @__PURE__ */ l("div", { className: "space-y-0.5", children: [
|
|
674
674
|
/* @__PURE__ */ s(z, { htmlFor: "slug", className: "text-sm", children: "Slug" }),
|
|
675
675
|
/* @__PURE__ */ s(
|
|
676
|
-
|
|
676
|
+
hs,
|
|
677
677
|
{
|
|
678
678
|
value: j,
|
|
679
679
|
onChange: (e) => {
|
|
@@ -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-B7eWP_hB.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-C9J3_rev.js")), f = s(() => import("./page-locked-dialog-GKfQEOmk.js")), O = s(() => import("./active-in-another-tab-Dozn833d.js")), S = s(() => import("./continue-editing-in-this-client-CS7C6h9Q.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-BwH1mRm_.cjs"),E=require("@tanstack/react-query"),r=require("react"),c=r.lazy(()=>Promise.resolve().then(()=>require("./take-over-request-CXuakFBm.cjs"))),o=r.lazy(()=>Promise.resolve().then(()=>require("./page-locked-dialog-xLqvKzax.cjs"))),l=r.lazy(()=>Promise.resolve().then(()=>require("./active-in-another-tab-BtAiatqq.cjs"))),S=r.lazy(()=>Promise.resolve().then(()=>require("./continue-editing-in-this-client-DMZOc36k.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,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import { R as O, U as w, V as A, W as S, X as F, Y as K, Z as U, _ as V, $ as I } from "./index-
|
|
2
|
+
import { R as O, U as w, V as A, W as S, X as F, Y as K, Z as U, _ as V, $ as I } from "./index-RYr8kQdI.js";
|
|
3
3
|
import { B as p } from "./register-chai-top-bar-ESJHs5s-.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-B7eWP_hB.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 +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-xYnNKovy.cjs"),p=require("./register-chai-top-bar-BqwKw4uy.cjs"),t=require("./index-BwH1mRm_.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 p-3 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=_;
|