@chaibuilder/pages 0.15.5 → 0.15.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{2AITGKQY-D4uLyw6-.cjs → 2AITGKQY-BnzAO102.cjs} +1 -1
- package/dist/{2AITGKQY-DYwNjBFe.js → 2AITGKQY-tXLat8E2.js} +2 -2
- package/dist/{NCMVHL6D-DVB60g_2.js → NCMVHL6D-BwDANa-N.js} +2 -2
- package/dist/{NCMVHL6D-C-L7-X3f.cjs → NCMVHL6D-DooF4Fqf.cjs} +1 -1
- package/dist/{ZDWCUMSJ-Dp6ML_tn.js → ZDWCUMSJ-DWeYRRkj.js} +1 -1
- package/dist/{ZDWCUMSJ-BORULBXb.cjs → ZDWCUMSJ-DiH9kc7o.cjs} +1 -1
- package/dist/add-new-language-page-BCUrfgTy.cjs +1 -0
- package/dist/add-new-language-page-DZhjVBBf.js +401 -0
- package/dist/add-new-page-DWHANcUx.cjs +1 -0
- package/dist/add-new-page-DYuuentN.js +31 -0
- package/dist/delete-page-1dSWwUBg.js +40 -0
- package/dist/delete-page-m-Cuz7rG.cjs +1 -0
- package/dist/digital-asset-manager-BWZlrwFf.js +913 -0
- package/dist/digital-asset-manager-By_JTIbb.cjs +1 -0
- package/dist/duplicate-page-Dzs8ya8l.cjs +1 -0
- package/dist/duplicate-page-fUuBTAs7.js +133 -0
- package/dist/{dynamic-page-selector-Cz6zWaKo.cjs → dynamic-page-selector-CwhL4z6F.cjs} +1 -1
- package/dist/{dynamic-page-selector-8g1-84iW.js → dynamic-page-selector-X2qgdiNQ.js} +1 -1
- package/dist/image-editor-CeSSNbFY.js +108 -0
- package/dist/image-editor-CnDnY97s.cjs +1 -0
- package/dist/index-0cMGDekp.cjs +5 -0
- package/dist/{index-zaGKeGBW.js → index-Bk8tPO5R.js} +1168 -1219
- package/dist/index.cjs +1 -1
- package/dist/index.js +10 -10
- package/dist/{json-diff-viewer-c3ft4c4A.cjs → json-diff-viewer-Cfa9BjZ6.cjs} +1 -1
- package/dist/{json-diff-viewer-BF0qFBif.js → json-diff-viewer-Cm84g19X.js} +1 -1
- package/dist/lang-panel-CaSKOJ8G.js +225 -0
- package/dist/lang-panel-CkSfJqr8.cjs +1 -0
- package/dist/mark-as-template-Ci82hbOm.cjs +1 -0
- package/dist/mark-as-template-CwsW86Zv.js +153 -0
- package/dist/no-language-page-content-CPt4aPy9.cjs +1 -0
- package/dist/no-language-page-content-DDz81nqg.js +42 -0
- package/dist/{page-creator-CsZpQ7Gy.cjs → page-creator-Cd2LrG4u.cjs} +1 -1
- package/dist/{page-creator-Crc5BzeB.js → page-creator-Dr566_Yf.js} +2 -2
- package/dist/page-lock-request-Bw_Wye1t.cjs +1 -0
- package/dist/page-lock-request-ECxkQMdS.js +75 -0
- package/dist/page-locked-by-dialog-AbutJT_V.cjs +1 -0
- package/dist/page-locked-by-dialog-CnkVUpjt.js +68 -0
- package/dist/page-manager-new-DLMvOata.cjs +1 -0
- package/dist/page-manager-new-DkqNLZ5C.js +354 -0
- package/dist/page-manager-search-and-filter-B98nz9xS.js +201 -0
- package/dist/page-manager-search-and-filter-CfEfWFeo.cjs +1 -0
- package/dist/{page-revisions-content-PRgwV04S.js → page-revisions-content-CBQPYFZI.js} +18 -18
- package/dist/{page-revisions-content-dSFvGFEO.cjs → page-revisions-content-D12GEp8C.cjs} +1 -1
- package/dist/{publish-pages-content-C24iBibw.js → publish-pages-content-BF5yMo_L.js} +6 -6
- package/dist/{publish-pages-content-akIgltlm.cjs → publish-pages-content-LNCr9tKv.cjs} +1 -1
- package/dist/{save-to-lib-C3H1ZPb-.cjs → save-to-lib-C1B6tWEF.cjs} +1 -1
- package/dist/{save-to-lib-DSPvtFSd.js → save-to-lib-SpilaoOL.js} +1 -1
- package/dist/{seo-panel-Ce6aTIyt.cjs → seo-panel-DkgkJUT6.cjs} +1 -1
- package/dist/{seo-panel-rZ8s88c0.js → seo-panel-sbYoo746.js} +17 -17
- package/dist/{shared-json-ld-hCiviuBf.cjs → shared-json-ld-CEUgLAev.cjs} +1 -1
- package/dist/{shared-json-ld-DMYOwp6B.js → shared-json-ld-D_YyVPk3.js} +27 -27
- package/dist/{slug-input-BN8eQgxP.cjs → slug-input-Cqj9EBju.cjs} +1 -1
- package/dist/{slug-input-Dhzaobv6.js → slug-input-Df-BG6xl.js} +1 -1
- package/dist/theme-panel-footer-B6leVWSV.js +25 -0
- package/dist/theme-panel-footer-Ca1UF5DA.cjs +1 -0
- package/dist/unmark-as-template-BOE-nKOb.cjs +1 -0
- package/dist/unmark-as-template-Cho9B4RN.js +39 -0
- package/dist/unpublish-page-BcxxZ8pr.cjs +1 -0
- package/dist/unpublish-page-Dr4qbwUx.js +27 -0
- package/dist/{web-preview-BEyjKFDL.js → web-preview-Cq82TNaS.js} +1 -1
- package/dist/{web-preview-TTKtpSUi.cjs → web-preview-ued-fdxs.cjs} +1 -1
- package/package.json +3 -3
- package/dist/add-new-language-page-D4VPifNs.cjs +0 -1
- package/dist/add-new-language-page-DENCjC_f.js +0 -390
- package/dist/add-new-page-BuK6We-q.cjs +0 -1
- package/dist/add-new-page-CD-9ppdS.js +0 -30
- package/dist/delete-page-B-TP6nJ7.cjs +0 -1
- package/dist/delete-page-CatRlDfx.js +0 -38
- package/dist/digital-asset-manager-DL2nAqUC.cjs +0 -1
- package/dist/digital-asset-manager-KakxBkBC.js +0 -917
- package/dist/duplicate-page-D4Oiy71Q.cjs +0 -1
- package/dist/duplicate-page-DEmh0df0.js +0 -120
- package/dist/image-editor-D9MPdtxC.js +0 -107
- package/dist/image-editor-Da6lrqkL.cjs +0 -1
- package/dist/index-Blg1T7nL.cjs +0 -5
- package/dist/lang-panel-D1FKTNui.js +0 -218
- package/dist/lang-panel-ExS97Zgk.cjs +0 -1
- package/dist/mark-as-template-CcnkROAU.cjs +0 -1
- package/dist/mark-as-template-v-I05xcZ.js +0 -146
- package/dist/no-language-page-content-Bm5CcsUo.js +0 -35
- package/dist/no-language-page-content-Ddz2hnYs.cjs +0 -1
- package/dist/page-lock-request-Dx6OrOwM.cjs +0 -1
- package/dist/page-lock-request-WKfG7Sd3.js +0 -64
- package/dist/page-locked-by-dialog-BvdAXZPw.cjs +0 -1
- package/dist/page-locked-by-dialog-jy3lYV3l.js +0 -63
- package/dist/page-manager-new-CNHlSwfe.js +0 -354
- package/dist/page-manager-new-CUlpwqpH.cjs +0 -1
- package/dist/page-manager-search-and-filter-CuAn82Db.js +0 -197
- package/dist/page-manager-search-and-filter-eFsGtm5W.cjs +0 -1
- package/dist/theme-panel-footer-0GrdOHO_.cjs +0 -1
- package/dist/theme-panel-footer-BzEy5bsg.js +0 -25
- package/dist/unmark-as-template-DXEs6foh.cjs +0 -1
- package/dist/unmark-as-template-Dsiyocm9.js +0 -38
- package/dist/unpublish-page-c1mqQEa_.cjs +0 -1
- package/dist/unpublish-page-yGyz2jiw.js +0 -26
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),V=require("./slug-input-Cqj9EBju.cjs"),f=require("./index-0cMGDekp.cjs"),w=require("@chaibuilder/sdk"),S=require("@chaibuilder/sdk/ui"),Y=require("lodash-es"),is=require("lucide-react"),N=require("react"),X=({edit:c,lang:h,languages:a,name:u,setLang:t,setName:i,primaryPageObject:o})=>{const{t:s}=w.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(S.Label,{htmlFor:"lang",children:s("Language")}),e.jsxs("select",{value:c?"":h,disabled:c||!a.length,onChange:l=>{const x=l.target.value;t(x),!c&&(Y.startsWith(u,o==null?void 0:o.name)||u.length===0)&&i(`${o==null?void 0:o.name} - ${f.LANGUAGES[x]}`)},className:"col-span-3 flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("option",{value:"",disabled:!0,children:c?f.LANGUAGES[h]||h:a.length?s("Choose language"):s("All available language page is created.")}),a.map(l=>e.jsx("option",{value:l,children:f.LANGUAGES[l]||l},l))]})]})},Z=({lang:c,name:h,setName:a,parentHasSelectedLanguagePage:u})=>{const{t}=w.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(S.Label,{htmlFor:"name",children:t("Page Name")}),e.jsx(S.Input,{id:"name",value:c?h:"",onChange:i=>a(i.target.value),required:!0,placeholder:t(c?"Enter page name":"Choose language to add slug"),disabled:!u||!c})]})},ds=({dynamic:c,isNonSlugPageType:h,isRootPage:a,lang:u,useLanguagePrefix:t,setUseLanguagePrefix:i,isHomePage:o,parentSlug:s,parentHasSelectedLanguagePage:l,slug:x,setSlug:d,setIsSlugValid:m,getSlug:g})=>{const{t:r}=w.useTranslation();return h?null:e.jsxs("div",{className:"space-y-1",children:[a&&u&&e.jsxs("div",{className:"flex items-center space-x-2 pb-1",children:[e.jsx("input",{type:"checkbox",id:"useLanguagePrefix",checked:t,onChange:A=>i(A.target.checked),className:"rounded border-gray-300"}),e.jsxs(S.Label,{htmlFor:"useLanguagePrefix",className:"text-sm font-normal leading-tight",children:["Add language code (",e.jsxs("span",{className:"font-mono text-gray-900",children:["/",u]}),") as slug prefix"]})]}),e.jsx(S.Label,{htmlFor:"slug",children:r("Slug")}),c?e.jsx(S.Alert,{variant:"default",className:"p-2 text-xs font-medium italic text-muted-foreground",children:r("This page will use dynamic slug as defined in primary page")}):e.jsx(V.SlugInput,{disabled:!u||!l,value:x,onChange:d,placeholder:r(u?o&&t?"Leave empty for home page":"Enter page slug":"Choose language to add slug"),parentSlug:s,onValidationChange:m,fullSlug:g()})]})},_=({parentHasSelectedLanguagePage:c,name:h,lang:a,slug:u,edit:t,id:i,primaryPageObject:o,pages:s,isNonSlugPageType:l,isHomePage:x,useLanguagePrefix:d,isSlugValid:m,isPending:g})=>{const{t:r}=w.useTranslation(),A=g||!h||!a||s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)||!l&&!(x&&d)&&(!m||!u);return e.jsx(S.DialogFooter,{children:c?e.jsxs(e.Fragment,{children:[e.jsx(S.Button,{type:"submit",disabled:A&&!o.dynamic,children:g?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"loader mr-2"}),r(t?"Updating...":"Adding...")]}):r(t?"Update":"Add new language page")}),s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)&&e.jsx("p",{className:"mt-2 text-xs text-red-500",children:r("A page for this language already exists.")})]}):a&&e.jsx(S.Alert,{variant:"destructive",children:e.jsxs("p",{className:"mx-auto w-5/6 text-center",children:[r("You need to create the")," ",e.jsx("span",{className:"font-medium",children:f.LANGUAGES[a]})," ",r("page in the parent to add here.")]})})})},cs=({onSubmit:c,edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s,parentHasSelectedLanguagePage:l,id:x,pages:d,isNonSlugPageType:m,isHomePage:g,useLanguagePrefix:r,slug:A,isSlugValid:v,isPending:E})=>e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s}),e.jsx(Z,{lang:a,name:t,setName:o,parentHasSelectedLanguagePage:l})]}),e.jsx(_,{parentHasSelectedLanguagePage:l,name:t,lang:a,slug:A,edit:h,id:x,primaryPageObject:s,pages:d,isNonSlugPageType:m,isHomePage:g,useLanguagePrefix:r,isSlugValid:v,isPending:E})]}),rs=({loading:c,onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,isNonSlugPageType:d,isRootPage:m,useLanguagePrefix:g,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,slug:E,setSlug:C,isSlugValid:T,setIsSlugValid:R,getSlug:M,isPending:$,id:D,pages:L})=>c?e.jsx("div",{className:"flex h-80 items-center justify-center",children:e.jsx(is.Loader,{className:"animate-spin"})}):d?e.jsx(cs,{onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,id:D,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:g,slug:E,isSlugValid:T,isPending:$}):e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l}),e.jsx(Z,{lang:u,name:i,setName:s,parentHasSelectedLanguagePage:x}),e.jsx(ds,{dynamic:l==null?void 0:l.dynamic,isNonSlugPageType:d,isRootPage:m,lang:u,useLanguagePrefix:g,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,parentHasSelectedLanguagePage:x,slug:E,setSlug:C,isSlugValid:T,setIsSlugValid:R,getSlug:M})]}),e.jsx(_,{parentHasSelectedLanguagePage:x,name:i,lang:u,slug:E,edit:a,id:D,primaryPageObject:l,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:g,isSlugValid:T,isPending:$})]}),hs=({id:c,isOpen:h,onClose:a,primaryPage:u,edit:t=!1,preselectedLang:i})=>{const{data:o=[]}=f.useWebsitePages(),s=N.useMemo(()=>o.find(n=>n.id===u),[o,u]),[l,x]=N.useState(""),[d,m]=N.useState(""),[g,r]=N.useState(""),[A,v]=N.useState(!0),[E,C]=N.useState(!0),{mutate:T,isPending:R}=f.useCreatePage(),{mutate:M,isPending:$}=f.useUpdatePage(),D=R||$,{data:L,isFetching:H}=f.useWebsiteSetting(),j=f.useFallbackLang(),{data:G,isFetching:b}=f.useLanguagePages(u),{data:F=[],isFetching:y}=f.useLanguagePages(s==null?void 0:s.parent),{data:z=[],isFetching:P}=f.usePageTypes(),{setSelectedLang:O}=w.useLanguages(),{t:I}=w.useTranslation(),[,ss]=f.useSearchParams(),[,es]=w.useSidebarActivePanel(),ns=H||b||y||P,U=N.useMemo(()=>Y.filter(L==null?void 0:L.languages,n=>!Y.find(G,{lang:n})),[L,G]),W=N.useMemo(()=>z.find(n=>n.key===(s==null?void 0:s.pageType)),[z,s==null?void 0:s.pageType]),J=!(W!=null&&W.hasSlug),B=(s==null?void 0:s.slug)==="/";N.useEffect(()=>{if(!t&&s&&i&&(m(i),x(`${s.name} - ${f.LANGUAGES[i]}`)),!t||!s)return;const n=G==null?void 0:G.find(us=>us.id===c);if(!n)return;x(n.name),m(n.lang);const p=n.slug||"",{initSlug:k,prefix:as}=V.parseSlugForEdit(p,s);r(k),C(as)},[t,c,G,s,i]),N.useEffect(()=>{if(i)m(i);else if((U==null?void 0:U.length)===1&&!t){const n=U[0];if(!n||!f.LANGUAGES[n])return;m(n),(!l||l===(s==null?void 0:s.name))&&x(`${s==null?void 0:s.name} - ${f.LANGUAGES[n]}`)}},[i,U,t,l,s]);const{parentSlug:K,isRootPage:q}=N.useMemo(()=>{if(B||!d)return{parentSlug:void 0,isRootPage:!(s!=null&&s.parent)};if(!(s!=null&&s.parent))return{parentSlug:E?`/${d}`:void 0,isRootPage:!0};const n=F==null?void 0:F.find(p=>p.lang===d);return{parentSlug:n==null?void 0:n.slug,isRootPage:!1}},[s==null?void 0:s.parent,F,E,d,B]),ts=N.useMemo(()=>q?!0:!!(F!=null&&F.some(n=>(n==null?void 0:n.lang)===d)),[d,F,q]),Q=()=>{let n="";return q?n=`/${E?[d,g].filter(Boolean).join("/"):g}`:n=`${V.removeSlugExtension(K)}/${g}`,n.replace(/\/{2,}/g,"/").replace(/\/$/,"")},os=n=>{const p=new URLSearchParams(window.location.search);j&&n===j?p.delete("lang"):p.set("lang",n),ss(p),window.dispatchEvent(new PopStateEvent("popstate"))},ls=n=>{n.preventDefault();const p={name:l,lang:d,primaryPage:s==null?void 0:s.id,slug:J?"":Q(),pageType:s==null?void 0:s.pageType,...t&&{id:c}},k=()=>{!t&&d&&(O(d),os(d)),es("outline"),a()};t?M(p,{onSuccess:k}):T(p,{onSuccess:k})};return e.jsx(S.Dialog,{open:h,onOpenChange:a,children:h&&e.jsxs(S.DialogContent,{className:"text-slate-600 sm:max-w-[425px]",children:[e.jsxs(S.DialogHeader,{children:[e.jsx(S.DialogTitle,{children:I(t?"Edit language":"Add new language page")}),e.jsx(S.DialogDescription,{className:"font-light",children:I("Enter the details for the language")})]}),e.jsx(rs,{id:c,pages:o,loading:ns,onSubmit:ls,edit:t,lang:d,languages:U,name:l,setLang:m,setName:x,primaryPageObject:s,parentHasSelectedLanguagePage:ts,isNonSlugPageType:J,isRootPage:q,useLanguagePrefix:E,setUseLanguagePrefix:C,isHomePage:B,parentSlug:K,slug:g,setSlug:r,isSlugValid:A,setIsSlugValid:v,getSlug:Q,isPending:D})]})})};exports.default=hs;
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import { jsx as t, jsxs as g, Fragment as hn } from "react/jsx-runtime";
|
|
2
|
+
import { p as fn, r as gn, S as mn } from "./slug-input-Df-BG6xl.js";
|
|
3
|
+
import { b as xn, c as vn, d as Sn, e as pn, f as Nn, g as Z, h as Fn, i as wn, L as A } from "./index-Bk8tPO5R.js";
|
|
4
|
+
import { useLanguages as An, useTranslation as T, useSidebarActivePanel as Cn } from "@chaibuilder/sdk";
|
|
5
|
+
import { Dialog as En, DialogContent as $n, DialogHeader as Dn, DialogTitle as Ln, DialogDescription as Tn, Label as I, Input as Un, Alert as H, DialogFooter as kn, Button as Rn } from "@chaibuilder/sdk/ui";
|
|
6
|
+
import { filter as Wn, find as Bn, startsWith as In } from "lodash-es";
|
|
7
|
+
import { Loader as Gn } from "lucide-react";
|
|
8
|
+
import { useMemo as D, useState as L, useEffect as _ } from "react";
|
|
9
|
+
const b = ({
|
|
10
|
+
edit: c,
|
|
11
|
+
lang: h,
|
|
12
|
+
languages: a,
|
|
13
|
+
name: i,
|
|
14
|
+
setLang: s,
|
|
15
|
+
setName: d,
|
|
16
|
+
primaryPageObject: o
|
|
17
|
+
}) => {
|
|
18
|
+
const { t: n } = T();
|
|
19
|
+
return /* @__PURE__ */ g("div", { className: "space-y-1", children: [
|
|
20
|
+
/* @__PURE__ */ t(I, { htmlFor: "lang", children: n("Language") }),
|
|
21
|
+
/* @__PURE__ */ g(
|
|
22
|
+
"select",
|
|
23
|
+
{
|
|
24
|
+
value: c ? "" : h,
|
|
25
|
+
disabled: c || !a.length,
|
|
26
|
+
onChange: (l) => {
|
|
27
|
+
const f = l.target.value;
|
|
28
|
+
s(f), !c && (In(i, o == null ? void 0 : o.name) || i.length === 0) && d(`${o == null ? void 0 : o.name} - ${A[f]}`);
|
|
29
|
+
},
|
|
30
|
+
className: "col-span-3 flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ t("option", { value: "", disabled: !0, children: c ? A[h] || h : a.length ? n("Choose language") : n("All available language page is created.") }),
|
|
33
|
+
a.map((l) => /* @__PURE__ */ t("option", { value: l, children: A[l] || l }, l))
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
] });
|
|
38
|
+
}, y = ({ lang: c, name: h, setName: a, parentHasSelectedLanguagePage: i }) => {
|
|
39
|
+
const { t: s } = T();
|
|
40
|
+
return /* @__PURE__ */ g("div", { className: "space-y-1", children: [
|
|
41
|
+
/* @__PURE__ */ t(I, { htmlFor: "name", children: s("Page Name") }),
|
|
42
|
+
/* @__PURE__ */ t(
|
|
43
|
+
Un,
|
|
44
|
+
{
|
|
45
|
+
id: "name",
|
|
46
|
+
value: c ? h : "",
|
|
47
|
+
onChange: (d) => a(d.target.value),
|
|
48
|
+
required: !0,
|
|
49
|
+
placeholder: s(c ? "Enter page name" : "Choose language to add slug"),
|
|
50
|
+
disabled: !i || !c
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
] });
|
|
54
|
+
}, qn = ({
|
|
55
|
+
dynamic: c,
|
|
56
|
+
isNonSlugPageType: h,
|
|
57
|
+
isRootPage: a,
|
|
58
|
+
lang: i,
|
|
59
|
+
useLanguagePrefix: s,
|
|
60
|
+
setUseLanguagePrefix: d,
|
|
61
|
+
isHomePage: o,
|
|
62
|
+
parentSlug: n,
|
|
63
|
+
parentHasSelectedLanguagePage: l,
|
|
64
|
+
slug: f,
|
|
65
|
+
setSlug: u,
|
|
66
|
+
setIsSlugValid: x,
|
|
67
|
+
getSlug: m
|
|
68
|
+
}) => {
|
|
69
|
+
const { t: r } = T();
|
|
70
|
+
return h ? null : /* @__PURE__ */ g("div", { className: "space-y-1", children: [
|
|
71
|
+
a && i && /* @__PURE__ */ g("div", { className: "flex items-center space-x-2 pb-1", children: [
|
|
72
|
+
/* @__PURE__ */ t(
|
|
73
|
+
"input",
|
|
74
|
+
{
|
|
75
|
+
type: "checkbox",
|
|
76
|
+
id: "useLanguagePrefix",
|
|
77
|
+
checked: s,
|
|
78
|
+
onChange: (S) => d(S.target.checked),
|
|
79
|
+
className: "rounded border-gray-300"
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
/* @__PURE__ */ g(I, { htmlFor: "useLanguagePrefix", className: "text-sm font-normal leading-tight", children: [
|
|
83
|
+
"Add language code (",
|
|
84
|
+
/* @__PURE__ */ g("span", { className: "font-mono text-gray-900", children: [
|
|
85
|
+
"/",
|
|
86
|
+
i
|
|
87
|
+
] }),
|
|
88
|
+
") as slug prefix"
|
|
89
|
+
] })
|
|
90
|
+
] }),
|
|
91
|
+
/* @__PURE__ */ t(I, { htmlFor: "slug", children: r("Slug") }),
|
|
92
|
+
c ? /* @__PURE__ */ t(H, { variant: "default", className: "p-2 text-xs font-medium italic text-muted-foreground", children: r("This page will use dynamic slug as defined in primary page") }) : /* @__PURE__ */ t(
|
|
93
|
+
mn,
|
|
94
|
+
{
|
|
95
|
+
disabled: !i || !l,
|
|
96
|
+
value: f,
|
|
97
|
+
onChange: u,
|
|
98
|
+
placeholder: r(i ? o && s ? "Leave empty for home page" : "Enter page slug" : "Choose language to add slug"),
|
|
99
|
+
parentSlug: n,
|
|
100
|
+
onValidationChange: x,
|
|
101
|
+
fullSlug: m()
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
] });
|
|
105
|
+
}, P = ({
|
|
106
|
+
parentHasSelectedLanguagePage: c,
|
|
107
|
+
name: h,
|
|
108
|
+
lang: a,
|
|
109
|
+
slug: i,
|
|
110
|
+
edit: s,
|
|
111
|
+
id: d,
|
|
112
|
+
primaryPageObject: o,
|
|
113
|
+
pages: n,
|
|
114
|
+
isNonSlugPageType: l,
|
|
115
|
+
isHomePage: f,
|
|
116
|
+
useLanguagePrefix: u,
|
|
117
|
+
isSlugValid: x,
|
|
118
|
+
isPending: m
|
|
119
|
+
}) => {
|
|
120
|
+
const { t: r } = T(), S = m || !h || !a || n.some((v) => (s ? v.id !== d : !0) && v.parent === (o == null ? void 0 : o.id) && v.lang === a) || !l && !(f && u) && (!x || !i);
|
|
121
|
+
return /* @__PURE__ */ t(kn, { children: c ? /* @__PURE__ */ g(hn, { children: [
|
|
122
|
+
/* @__PURE__ */ t(Rn, { type: "submit", disabled: S && !o.dynamic, children: m ? /* @__PURE__ */ g("span", { className: "flex items-center gap-2", children: [
|
|
123
|
+
/* @__PURE__ */ t("span", { className: "loader mr-2" }),
|
|
124
|
+
r(s ? "Updating..." : "Adding...")
|
|
125
|
+
] }) : r(s ? "Update" : "Add new language page") }),
|
|
126
|
+
n.some(
|
|
127
|
+
(v) => (s ? v.id !== d : !0) && v.parent === (o == null ? void 0 : o.id) && v.lang === a
|
|
128
|
+
) && /* @__PURE__ */ t("p", { className: "mt-2 text-xs text-red-500", children: r("A page for this language already exists.") })
|
|
129
|
+
] }) : a && /* @__PURE__ */ t(H, { variant: "destructive", children: /* @__PURE__ */ g("p", { className: "mx-auto w-5/6 text-center", children: [
|
|
130
|
+
r("You need to create the"),
|
|
131
|
+
" ",
|
|
132
|
+
/* @__PURE__ */ t("span", { className: "font-medium", children: A[a] }),
|
|
133
|
+
" ",
|
|
134
|
+
r("page in the parent to add here.")
|
|
135
|
+
] }) }) });
|
|
136
|
+
}, Mn = ({
|
|
137
|
+
onSubmit: c,
|
|
138
|
+
edit: h,
|
|
139
|
+
lang: a,
|
|
140
|
+
languages: i,
|
|
141
|
+
name: s,
|
|
142
|
+
setLang: d,
|
|
143
|
+
setName: o,
|
|
144
|
+
primaryPageObject: n,
|
|
145
|
+
parentHasSelectedLanguagePage: l,
|
|
146
|
+
id: f,
|
|
147
|
+
pages: u,
|
|
148
|
+
isNonSlugPageType: x,
|
|
149
|
+
isHomePage: m,
|
|
150
|
+
useLanguagePrefix: r,
|
|
151
|
+
slug: S,
|
|
152
|
+
isSlugValid: v,
|
|
153
|
+
isPending: p
|
|
154
|
+
}) => /* @__PURE__ */ g("form", { onSubmit: c, children: [
|
|
155
|
+
/* @__PURE__ */ g("div", { className: "grid gap-4 py-4", children: [
|
|
156
|
+
/* @__PURE__ */ t(
|
|
157
|
+
b,
|
|
158
|
+
{
|
|
159
|
+
edit: h,
|
|
160
|
+
lang: a,
|
|
161
|
+
languages: i,
|
|
162
|
+
name: s,
|
|
163
|
+
setLang: d,
|
|
164
|
+
setName: o,
|
|
165
|
+
primaryPageObject: n
|
|
166
|
+
}
|
|
167
|
+
),
|
|
168
|
+
/* @__PURE__ */ t(
|
|
169
|
+
y,
|
|
170
|
+
{
|
|
171
|
+
lang: a,
|
|
172
|
+
name: s,
|
|
173
|
+
setName: o,
|
|
174
|
+
parentHasSelectedLanguagePage: l
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
] }),
|
|
178
|
+
/* @__PURE__ */ t(
|
|
179
|
+
P,
|
|
180
|
+
{
|
|
181
|
+
parentHasSelectedLanguagePage: l,
|
|
182
|
+
name: s,
|
|
183
|
+
lang: a,
|
|
184
|
+
slug: S,
|
|
185
|
+
edit: h,
|
|
186
|
+
id: f,
|
|
187
|
+
primaryPageObject: n,
|
|
188
|
+
pages: u,
|
|
189
|
+
isNonSlugPageType: x,
|
|
190
|
+
isHomePage: m,
|
|
191
|
+
useLanguagePrefix: r,
|
|
192
|
+
isSlugValid: v,
|
|
193
|
+
isPending: p
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
] }), Vn = ({
|
|
197
|
+
loading: c,
|
|
198
|
+
onSubmit: h,
|
|
199
|
+
edit: a,
|
|
200
|
+
lang: i,
|
|
201
|
+
languages: s,
|
|
202
|
+
name: d,
|
|
203
|
+
setLang: o,
|
|
204
|
+
setName: n,
|
|
205
|
+
primaryPageObject: l,
|
|
206
|
+
parentHasSelectedLanguagePage: f,
|
|
207
|
+
isNonSlugPageType: u,
|
|
208
|
+
isRootPage: x,
|
|
209
|
+
useLanguagePrefix: m,
|
|
210
|
+
setUseLanguagePrefix: r,
|
|
211
|
+
isHomePage: S,
|
|
212
|
+
parentSlug: v,
|
|
213
|
+
slug: p,
|
|
214
|
+
setSlug: U,
|
|
215
|
+
isSlugValid: $,
|
|
216
|
+
setIsSlugValid: G,
|
|
217
|
+
getSlug: q,
|
|
218
|
+
isPending: k,
|
|
219
|
+
id: R,
|
|
220
|
+
pages: w
|
|
221
|
+
}) => c ? /* @__PURE__ */ t("div", { className: "flex h-80 items-center justify-center", children: /* @__PURE__ */ t(Gn, { className: "animate-spin" }) }) : u ? /* @__PURE__ */ t(
|
|
222
|
+
Mn,
|
|
223
|
+
{
|
|
224
|
+
onSubmit: h,
|
|
225
|
+
edit: a,
|
|
226
|
+
lang: i,
|
|
227
|
+
languages: s,
|
|
228
|
+
name: d,
|
|
229
|
+
setLang: o,
|
|
230
|
+
setName: n,
|
|
231
|
+
primaryPageObject: l,
|
|
232
|
+
parentHasSelectedLanguagePage: f,
|
|
233
|
+
id: R,
|
|
234
|
+
pages: w,
|
|
235
|
+
isNonSlugPageType: u,
|
|
236
|
+
isHomePage: S,
|
|
237
|
+
useLanguagePrefix: m,
|
|
238
|
+
slug: p,
|
|
239
|
+
isSlugValid: $,
|
|
240
|
+
isPending: k
|
|
241
|
+
}
|
|
242
|
+
) : /* @__PURE__ */ g("form", { onSubmit: h, children: [
|
|
243
|
+
/* @__PURE__ */ g("div", { className: "grid gap-4 py-4", children: [
|
|
244
|
+
/* @__PURE__ */ t(
|
|
245
|
+
b,
|
|
246
|
+
{
|
|
247
|
+
edit: a,
|
|
248
|
+
lang: i,
|
|
249
|
+
languages: s,
|
|
250
|
+
name: d,
|
|
251
|
+
setLang: o,
|
|
252
|
+
setName: n,
|
|
253
|
+
primaryPageObject: l
|
|
254
|
+
}
|
|
255
|
+
),
|
|
256
|
+
/* @__PURE__ */ t(
|
|
257
|
+
y,
|
|
258
|
+
{
|
|
259
|
+
lang: i,
|
|
260
|
+
name: d,
|
|
261
|
+
setName: n,
|
|
262
|
+
parentHasSelectedLanguagePage: f
|
|
263
|
+
}
|
|
264
|
+
),
|
|
265
|
+
/* @__PURE__ */ t(
|
|
266
|
+
qn,
|
|
267
|
+
{
|
|
268
|
+
dynamic: l == null ? void 0 : l.dynamic,
|
|
269
|
+
isNonSlugPageType: u,
|
|
270
|
+
isRootPage: x,
|
|
271
|
+
lang: i,
|
|
272
|
+
useLanguagePrefix: m,
|
|
273
|
+
setUseLanguagePrefix: r,
|
|
274
|
+
isHomePage: S,
|
|
275
|
+
parentSlug: v,
|
|
276
|
+
parentHasSelectedLanguagePage: f,
|
|
277
|
+
slug: p,
|
|
278
|
+
setSlug: U,
|
|
279
|
+
isSlugValid: $,
|
|
280
|
+
setIsSlugValid: G,
|
|
281
|
+
getSlug: q
|
|
282
|
+
}
|
|
283
|
+
)
|
|
284
|
+
] }),
|
|
285
|
+
/* @__PURE__ */ t(
|
|
286
|
+
P,
|
|
287
|
+
{
|
|
288
|
+
parentHasSelectedLanguagePage: f,
|
|
289
|
+
name: d,
|
|
290
|
+
lang: i,
|
|
291
|
+
slug: p,
|
|
292
|
+
edit: a,
|
|
293
|
+
id: R,
|
|
294
|
+
primaryPageObject: l,
|
|
295
|
+
pages: w,
|
|
296
|
+
isNonSlugPageType: u,
|
|
297
|
+
isHomePage: S,
|
|
298
|
+
useLanguagePrefix: m,
|
|
299
|
+
isSlugValid: $,
|
|
300
|
+
isPending: k
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
] }), Hn = ({
|
|
304
|
+
id: c,
|
|
305
|
+
isOpen: h,
|
|
306
|
+
onClose: a,
|
|
307
|
+
primaryPage: i,
|
|
308
|
+
edit: s = !1,
|
|
309
|
+
preselectedLang: d
|
|
310
|
+
}) => {
|
|
311
|
+
const { data: o = [] } = xn(), n = D(() => o.find((e) => e.id === i), [o, i]), [l, f] = L(""), [u, x] = L(""), [m, r] = L(""), [S, v] = L(!0), [p, U] = L(!0), { mutate: $, isPending: G } = vn(), { mutate: q, isPending: k } = Sn(), R = G || k, { data: w, isFetching: j } = pn(), z = Nn(), { data: C, isFetching: O } = Z(i), { data: F = [], isFetching: nn } = Z(
|
|
312
|
+
n == null ? void 0 : n.parent
|
|
313
|
+
), { data: J = [], isFetching: en } = Fn(), { setSelectedLang: sn } = An(), { t: M } = T(), [, tn] = wn(), [, on] = Cn(), ln = j || O || nn || en, E = D(() => Wn(w == null ? void 0 : w.languages, (e) => !Bn(C, { lang: e })), [w, C]), V = D(
|
|
314
|
+
() => J.find((e) => e.key === (n == null ? void 0 : n.pageType)),
|
|
315
|
+
[J, n == null ? void 0 : n.pageType]
|
|
316
|
+
), K = !(V != null && V.hasSlug), Y = (n == null ? void 0 : n.slug) === "/";
|
|
317
|
+
_(() => {
|
|
318
|
+
if (!s && n && d && (x(d), f(`${n.name} - ${A[d]}`)), !s || !n) return;
|
|
319
|
+
const e = C == null ? void 0 : C.find((rn) => rn.id === c);
|
|
320
|
+
if (!e) return;
|
|
321
|
+
f(e.name), x(e.lang);
|
|
322
|
+
const N = e.slug || "", { initSlug: B, prefix: cn } = fn(N, n);
|
|
323
|
+
r(B), U(cn);
|
|
324
|
+
}, [s, c, C, n, d]), _(() => {
|
|
325
|
+
if (d)
|
|
326
|
+
x(d);
|
|
327
|
+
else if ((E == null ? void 0 : E.length) === 1 && !s) {
|
|
328
|
+
const e = E[0];
|
|
329
|
+
if (!e || !A[e]) return;
|
|
330
|
+
x(e), (!l || l === (n == null ? void 0 : n.name)) && f(`${n == null ? void 0 : n.name} - ${A[e]}`);
|
|
331
|
+
}
|
|
332
|
+
}, [d, E, s, l, n]);
|
|
333
|
+
const { parentSlug: Q, isRootPage: W } = D(() => {
|
|
334
|
+
if (Y || !u)
|
|
335
|
+
return { parentSlug: void 0, isRootPage: !(n != null && n.parent) };
|
|
336
|
+
if (!(n != null && n.parent))
|
|
337
|
+
return {
|
|
338
|
+
parentSlug: p ? `/${u}` : void 0,
|
|
339
|
+
isRootPage: !0
|
|
340
|
+
};
|
|
341
|
+
const e = F == null ? void 0 : F.find((N) => N.lang === u);
|
|
342
|
+
return { parentSlug: e == null ? void 0 : e.slug, isRootPage: !1 };
|
|
343
|
+
}, [n == null ? void 0 : n.parent, F, p, u, Y]), an = D(() => W ? !0 : !!(F != null && F.some((e) => (e == null ? void 0 : e.lang) === u)), [u, F, W]), X = () => {
|
|
344
|
+
let e = "";
|
|
345
|
+
return W ? e = `/${p ? [u, m].filter(Boolean).join("/") : m}` : e = `${gn(Q)}/${m}`, e.replace(/\/{2,}/g, "/").replace(/\/$/, "");
|
|
346
|
+
}, dn = (e) => {
|
|
347
|
+
const N = new URLSearchParams(window.location.search);
|
|
348
|
+
z && e === z ? N.delete("lang") : N.set("lang", e), tn(N), window.dispatchEvent(new PopStateEvent("popstate"));
|
|
349
|
+
}, un = (e) => {
|
|
350
|
+
e.preventDefault();
|
|
351
|
+
const N = {
|
|
352
|
+
name: l,
|
|
353
|
+
lang: u,
|
|
354
|
+
primaryPage: n == null ? void 0 : n.id,
|
|
355
|
+
slug: K ? "" : X(),
|
|
356
|
+
pageType: n == null ? void 0 : n.pageType,
|
|
357
|
+
...s && { id: c }
|
|
358
|
+
}, B = () => {
|
|
359
|
+
!s && u && (sn(u), dn(u)), on("outline"), a();
|
|
360
|
+
};
|
|
361
|
+
s ? q(N, { onSuccess: B }) : $(N, { onSuccess: B });
|
|
362
|
+
};
|
|
363
|
+
return /* @__PURE__ */ t(En, { open: h, onOpenChange: a, children: h && /* @__PURE__ */ g($n, { className: "text-slate-600 sm:max-w-[425px]", children: [
|
|
364
|
+
/* @__PURE__ */ g(Dn, { children: [
|
|
365
|
+
/* @__PURE__ */ t(Ln, { children: M(s ? "Edit language" : "Add new language page") }),
|
|
366
|
+
/* @__PURE__ */ t(Tn, { className: "font-light", children: M("Enter the details for the language") })
|
|
367
|
+
] }),
|
|
368
|
+
/* @__PURE__ */ t(
|
|
369
|
+
Vn,
|
|
370
|
+
{
|
|
371
|
+
id: c,
|
|
372
|
+
pages: o,
|
|
373
|
+
loading: ln,
|
|
374
|
+
onSubmit: un,
|
|
375
|
+
edit: s,
|
|
376
|
+
lang: u,
|
|
377
|
+
languages: E,
|
|
378
|
+
name: l,
|
|
379
|
+
setLang: x,
|
|
380
|
+
setName: f,
|
|
381
|
+
primaryPageObject: n,
|
|
382
|
+
parentHasSelectedLanguagePage: an,
|
|
383
|
+
isNonSlugPageType: K,
|
|
384
|
+
isRootPage: W,
|
|
385
|
+
useLanguagePrefix: p,
|
|
386
|
+
setUseLanguagePrefix: U,
|
|
387
|
+
isHomePage: Y,
|
|
388
|
+
parentSlug: Q,
|
|
389
|
+
slug: m,
|
|
390
|
+
setSlug: r,
|
|
391
|
+
isSlugValid: S,
|
|
392
|
+
setIsSlugValid: v,
|
|
393
|
+
getSlug: X,
|
|
394
|
+
isPending: R
|
|
395
|
+
}
|
|
396
|
+
)
|
|
397
|
+
] }) });
|
|
398
|
+
};
|
|
399
|
+
export {
|
|
400
|
+
Hn as default
|
|
401
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk"),n=require("@chaibuilder/sdk/ui"),t=require("react"),u=t.lazy(()=>Promise.resolve().then(()=>require("./page-creator-Cd2LrG4u.cjs"))),x=({addEditPage:s,setAddEditPage:r,closePanel:c})=>{const{t:o}=a.useTranslation(),i=!!(s!=null&&s.id),l=!!s;return e.jsx(n.Dialog,{open:l,onOpenChange:()=>r(void 0),children:l&&e.jsxs(n.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(n.DialogHeader,{children:[e.jsxs(n.DialogTitle,{children:[o(i?"Edit":"Add New")," "]}),e.jsx(n.DialogDescription,{children:o(i?"Update your page name":"Enter details to create a new page")})]}),e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"min-h-40"}),children:e.jsx(u,{closePanel:c,addEditPage:s,close:()=>r(void 0)})})]})})};exports.default=x;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as e, jsxs as r } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation as a } from "@chaibuilder/sdk";
|
|
3
|
+
import { Dialog as c, DialogContent as m, DialogHeader as p, DialogTitle as h, DialogDescription as f } from "@chaibuilder/sdk/ui";
|
|
4
|
+
import { lazy as D, Suspense as u } from "react";
|
|
5
|
+
const x = D(() => import("./page-creator-Dr566_Yf.js")), C = ({
|
|
6
|
+
addEditPage: o,
|
|
7
|
+
setAddEditPage: i,
|
|
8
|
+
closePanel: t
|
|
9
|
+
}) => {
|
|
10
|
+
const { t: n } = a(), l = !!(o != null && o.id), s = !!o;
|
|
11
|
+
return /* @__PURE__ */ e(c, { open: s, onOpenChange: () => i(void 0), children: s && /* @__PURE__ */ r(m, { className: "sm:max-w-[425px]", children: [
|
|
12
|
+
/* @__PURE__ */ r(p, { children: [
|
|
13
|
+
/* @__PURE__ */ r(h, { children: [
|
|
14
|
+
n(l ? "Edit" : "Add New"),
|
|
15
|
+
" "
|
|
16
|
+
] }),
|
|
17
|
+
/* @__PURE__ */ e(f, { children: n(l ? "Update your page name" : "Enter details to create a new page") })
|
|
18
|
+
] }),
|
|
19
|
+
/* @__PURE__ */ e(u, { fallback: /* @__PURE__ */ e("div", { className: "min-h-40" }), children: /* @__PURE__ */ e(
|
|
20
|
+
x,
|
|
21
|
+
{
|
|
22
|
+
closePanel: t,
|
|
23
|
+
addEditPage: o,
|
|
24
|
+
close: () => i(void 0)
|
|
25
|
+
}
|
|
26
|
+
) })
|
|
27
|
+
] }) });
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
C as default
|
|
31
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as i, jsxs as r } from "react/jsx-runtime";
|
|
2
|
+
import { i as f, m as w, h as y, L as S } from "./index-Bk8tPO5R.js";
|
|
3
|
+
import { useTranslation as v, useLanguages as L, useSidebarActivePanel as x } from "@chaibuilder/sdk";
|
|
4
|
+
import { Dialog as A, DialogContent as k, DialogHeader as C, DialogTitle as N, DialogDescription as g, DialogFooter as E, Button as c } from "@chaibuilder/sdk/ui";
|
|
5
|
+
import { get as U } from "lodash-es";
|
|
6
|
+
function F({ page: e, onClose: a }) {
|
|
7
|
+
const { t } = v(), [, o] = f(), { mutate: d, isPending: l } = w(), { data: s } = y(), { setSelectedLang: m, fallbackLang: u } = L(), [, h] = x(), P = () => {
|
|
8
|
+
l || d(e, {
|
|
9
|
+
onSuccess: () => {
|
|
10
|
+
e != null && e.primaryPage ? (window.history.replaceState({}, "", `/?page=${e.primaryPage}`), o(new URLSearchParams({ page: e.primaryPage }))) : (window.history.replaceState({}, "", "/"), o(new URLSearchParams())), window.dispatchEvent(new PopStateEvent("popstate")), m(u), h("outline"), a();
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}, n = s == null ? void 0 : s.find((D) => D.key === (e == null ? void 0 : e.pageType));
|
|
14
|
+
return /* @__PURE__ */ i(A, { open: !!e, onOpenChange: a, children: /* @__PURE__ */ r(k, { children: [
|
|
15
|
+
/* @__PURE__ */ r(C, { children: [
|
|
16
|
+
/* @__PURE__ */ i(N, { children: t("Confirm Deletion") }),
|
|
17
|
+
/* @__PURE__ */ r(g, { className: "py-4 text-slate-500", children: [
|
|
18
|
+
/* @__PURE__ */ r("div", { children: [
|
|
19
|
+
t("Are you sure you want to remove"),
|
|
20
|
+
" ",
|
|
21
|
+
/* @__PURE__ */ i("b", { children: (e == null ? void 0 : e.name) ?? (e == null ? void 0 : e.slug) }),
|
|
22
|
+
" ",
|
|
23
|
+
n != null && n.hasSlug ? (n == null ? void 0 : n.name) + "?" : `${t("page?")} ${e != null && e.primaryPage ? "" : t("This will also delete all associated language pages.")}`
|
|
24
|
+
] }),
|
|
25
|
+
e.lang && /* @__PURE__ */ r("div", { className: "py-2 text-sm", children: [
|
|
26
|
+
t("Language"),
|
|
27
|
+
": ",
|
|
28
|
+
/* @__PURE__ */ i("span", { className: "font-medium text-gray-500", children: U(S, e.lang, e.lang) })
|
|
29
|
+
] })
|
|
30
|
+
] })
|
|
31
|
+
] }),
|
|
32
|
+
/* @__PURE__ */ r(E, { children: [
|
|
33
|
+
/* @__PURE__ */ i(c, { variant: "outline", onClick: a, children: t("Cancel") }),
|
|
34
|
+
/* @__PURE__ */ i(c, { variant: "destructive", disabled: l, onClick: P, children: t(l ? "Deleting..." : "Delete") })
|
|
35
|
+
] })
|
|
36
|
+
] }) });
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
F as default
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),r=require("./index-0cMGDekp.cjs"),c=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),y=require("lodash-es");function S({page:e,onClose:l}){const{t}=c.useTranslation(),[,d]=r.useSearchParams(),{mutate:u,isPending:a}=r.useDeletePage(),{data:o}=r.usePageTypes(),{setSelectedLang:h,fallbackLang:m}=c.useLanguages(),[,x]=c.useSidebarActivePanel(),P=()=>{a||u(e,{onSuccess:()=>{e!=null&&e.primaryPage?(window.history.replaceState({},"",`/?page=${e.primaryPage}`),d(new URLSearchParams({page:e.primaryPage}))):(window.history.replaceState({},"","/"),d(new URLSearchParams)),window.dispatchEvent(new PopStateEvent("popstate")),h(m),x("outline"),l()}})},i=o==null?void 0:o.find(D=>D.key===(e==null?void 0:e.pageType));return n.jsx(s.Dialog,{open:!!e,onOpenChange:l,children:n.jsxs(s.DialogContent,{children:[n.jsxs(s.DialogHeader,{children:[n.jsx(s.DialogTitle,{children:t("Confirm Deletion")}),n.jsxs(s.DialogDescription,{className:"py-4 text-slate-500",children:[n.jsxs("div",{children:[t("Are you sure you want to remove")," ",n.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)})," ",i!=null&&i.hasSlug?(i==null?void 0:i.name)+"?":`${t("page?")} ${e!=null&&e.primaryPage?"":t("This will also delete all associated language pages.")}`]}),e.lang&&n.jsxs("div",{className:"py-2 text-sm",children:[t("Language"),": ",n.jsx("span",{className:"font-medium text-gray-500",children:y.get(r.LANGUAGES,e.lang,e.lang)})]})]})]}),n.jsxs(s.DialogFooter,{children:[n.jsx(s.Button,{variant:"outline",onClick:l,children:t("Cancel")}),n.jsx(s.Button,{variant:"destructive",disabled:a,onClick:P,children:t(a?"Deleting...":"Delete")})]})]})})}exports.default=S;
|