@chaibuilder/pages 0.15.5 → 0.15.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/dist/{2AITGKQY-D4uLyw6-.cjs → 2AITGKQY-BGvx_OEz.cjs} +1 -1
- package/dist/{2AITGKQY-DYwNjBFe.js → 2AITGKQY-CCad8XK8.js} +2 -2
- package/dist/{NCMVHL6D-C-L7-X3f.cjs → NCMVHL6D-C_u5lHQe.cjs} +1 -1
- package/dist/{NCMVHL6D-DVB60g_2.js → NCMVHL6D-Iv9ufIUy.js} +2 -2
- package/dist/{ZDWCUMSJ-BORULBXb.cjs → ZDWCUMSJ-BqZPKNlU.cjs} +1 -1
- package/dist/{ZDWCUMSJ-Dp6ML_tn.js → ZDWCUMSJ-DT4dg62a.js} +1 -1
- package/dist/add-new-language-page-CfH8Ernl.js +401 -0
- package/dist/add-new-language-page-DlQjzp--.cjs +1 -0
- package/dist/add-new-page-DH-nv7ae.cjs +1 -0
- package/dist/add-new-page-DX1aQA56.js +31 -0
- package/dist/delete-page-DE-nabXs.js +40 -0
- package/dist/delete-page-WPGzECyJ.cjs +1 -0
- package/dist/digital-asset-manager-CGLE6VEW.cjs +1 -0
- package/dist/digital-asset-manager-DtWIJGhf.js +913 -0
- package/dist/duplicate-page-C1r3iBDY.js +133 -0
- package/dist/duplicate-page-CByLwz0z.cjs +1 -0
- package/dist/{dynamic-page-selector-8g1-84iW.js → dynamic-page-selector-Bk8_xgFx.js} +1 -1
- package/dist/{dynamic-page-selector-Cz6zWaKo.cjs → dynamic-page-selector-GwGV0Q6Z.cjs} +1 -1
- package/dist/image-editor-CeSSNbFY.js +108 -0
- package/dist/image-editor-CnDnY97s.cjs +1 -0
- package/dist/index-BELYt0c9.cjs +5 -0
- package/dist/{index-zaGKeGBW.js → index-Djepisz3.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-BUhKwjf9.cjs} +1 -1
- package/dist/{json-diff-viewer-BF0qFBif.js → json-diff-viewer-zKpzQFxw.js} +1 -1
- package/dist/lang-panel-BYF6aLAt.cjs +1 -0
- package/dist/lang-panel-CtpuO-KH.js +225 -0
- package/dist/mark-as-template-0kikl0oL.js +153 -0
- package/dist/mark-as-template-wRAGJGtp.cjs +1 -0
- package/dist/no-language-page-content-B1M_x_U7.js +42 -0
- package/dist/no-language-page-content-DX9WXKXs.cjs +1 -0
- package/dist/{page-creator-Crc5BzeB.js → page-creator-BDJ6iDX9.js} +2 -2
- package/dist/{page-creator-CsZpQ7Gy.cjs → page-creator-DuN5JD41.cjs} +1 -1
- package/dist/page-lock-request-Bc_vwJhy.js +75 -0
- package/dist/page-lock-request-PRQo0DDm.cjs +1 -0
- package/dist/page-locked-by-dialog-DiKNpVwH.js +68 -0
- package/dist/page-locked-by-dialog-Dk0G2l7a.cjs +1 -0
- package/dist/page-manager-new-CUHqC9Og.js +354 -0
- package/dist/page-manager-new-KBhn93Yd.cjs +1 -0
- package/dist/page-manager-search-and-filter-CJ4AK1_7.js +201 -0
- package/dist/page-manager-search-and-filter-Ck5_TfNx.cjs +1 -0
- package/dist/{page-revisions-content-dSFvGFEO.cjs → page-revisions-content-Cw2cumYS.cjs} +1 -1
- package/dist/{page-revisions-content-PRgwV04S.js → page-revisions-content-q1Ch2-IQ.js} +18 -18
- package/dist/{publish-pages-content-akIgltlm.cjs → publish-pages-content-B8Uuw29Q.cjs} +1 -1
- package/dist/{publish-pages-content-C24iBibw.js → publish-pages-content-DEHD8qkl.js} +6 -6
- package/dist/{save-to-lib-C3H1ZPb-.cjs → save-to-lib-B83ZH4XX.cjs} +1 -1
- package/dist/{save-to-lib-DSPvtFSd.js → save-to-lib-QEOpf_Bd.js} +1 -1
- package/dist/{seo-panel-rZ8s88c0.js → seo-panel-DEQfOfZs.js} +17 -17
- package/dist/{seo-panel-Ce6aTIyt.cjs → seo-panel-DvDEatlO.cjs} +1 -1
- package/dist/{shared-json-ld-DMYOwp6B.js → shared-json-ld-Cyv9JitF.js} +26 -25
- package/dist/{shared-json-ld-hCiviuBf.cjs → shared-json-ld-D5F8RuF2.cjs} +1 -1
- package/dist/{slug-input-BN8eQgxP.cjs → slug-input-3vWL9FPC.cjs} +1 -1
- package/dist/{slug-input-Dhzaobv6.js → slug-input-D4e2anEs.js} +1 -1
- package/dist/theme-panel-footer-4dbLfEph.cjs +1 -0
- package/dist/theme-panel-footer-D3Gub87c.js +25 -0
- package/dist/unmark-as-template-BENGNo7g.js +39 -0
- package/dist/unmark-as-template-Dkc7zLZr.cjs +1 -0
- package/dist/unpublish-page-Cui0tgvd.cjs +1 -0
- package/dist/unpublish-page-D5tWKVLY.js +27 -0
- package/dist/{web-preview-BEyjKFDL.js → web-preview-CHNZZcqH.js} +1 -1
- package/dist/{web-preview-TTKtpSUi.cjs → web-preview-CcPTcMio.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
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-BELYt0c9.cjs"),s=require("@chaibuilder/sdk");exports.ChaiBuilderPagesRealtime=e.ChaiBuilderPagesRealtime;exports.ChaiJsonInput=e.SmartJsonInput;exports.ImagePicker=e.ImagePicker;exports.LanguageSwitcher=e.LanguageSwitcher;exports.NestedPathSelector=e.NestedPathSelector;exports.PermissionChecker=e.PermissionChecker;exports.default=e.ChaiBuilderPages;exports.useActivePage=e.useActivePage;exports.useBuilderPageData=e.useBuilderPageData;exports.useChaiAuth=e.useChaiAuth;exports.useChaiCurrentPage=e.useCurrentPage;exports.useChaiFetch=e.useChaiFetch;exports.useChaiUserInfo=e.useChaiUserInfo;exports.useClearAll=e.useClearAll;exports.useFallbackLang=e.useFallbackLang;exports.useFetch=e.useFetch;exports.useGotoPage=e.useGotoPage;exports.useLanguagePages=e.useLanguagePages;exports.usePageTypes=e.usePageTypes;exports.useReloadPage=e.useReloadPage;exports.useUpdateActivePageMetadata=e.useUpdateActivePageMetadata;exports.useUserPermissions=e.useUserRoleAndPermissions;exports.useWebsitePages=e.useWebsitePages;exports.useWebsiteSetting=e.useWebsiteSetting;Object.keys(s).forEach(a=>{a!=="default"&&!Object.prototype.hasOwnProperty.call(exports,a)&&Object.defineProperty(exports,a,{enumerable:!0,get:()=>s[a]})});
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aW as s, aw as u, aK as t, aI as i, aJ as g, aq as r, aN as P, aO as h, aF as l, aT as o, ap as n, aV as c, ai as C, aP as d, f as m, al as p, aQ as f, g as b, h as A, aR as F, aS as I, aU as S, b as U, e as k } from "./index-Djepisz3.js";
|
|
2
2
|
export * from "@chaibuilder/sdk";
|
|
3
3
|
export {
|
|
4
4
|
s as ChaiBuilderPagesRealtime,
|
|
@@ -9,20 +9,20 @@ export {
|
|
|
9
9
|
r as PermissionChecker,
|
|
10
10
|
P as default,
|
|
11
11
|
h as useActivePage,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
l as useBuilderPageData,
|
|
13
|
+
o as useChaiAuth,
|
|
14
14
|
n as useChaiCurrentPage,
|
|
15
15
|
c as useChaiFetch,
|
|
16
16
|
C as useChaiUserInfo,
|
|
17
17
|
d as useClearAll,
|
|
18
18
|
m as useFallbackLang,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
p as useFetch,
|
|
20
|
+
f as useGotoPage,
|
|
21
21
|
b as useLanguagePages,
|
|
22
22
|
A as usePageTypes,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
F as useReloadPage,
|
|
24
|
+
I as useUpdateActivePageMetadata,
|
|
25
|
+
S as useUserPermissions,
|
|
26
|
+
U as useWebsitePages,
|
|
27
|
+
k as useWebsiteSetting
|
|
28
28
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk/ui"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk/ui"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-BELYt0c9.cjs"),B=require("@tanstack/react-query");function H(t,r){const o=O.useApiUrl(),n=O.useFetch(),f=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return B.useQuery({queryKey:["revision-comparison",t.uid,r.uid],queryFn:async()=>{if(!t.uid||!r.uid)throw new Error("Both revision IDs are required for comparison");const l=u=>u==="draft"||u==="live"?u:"revision",s=u=>p.replace(u.uid,`${u.label}:`,"");return await n(o,{action:O.ACTIONS.GET_COMPARE_DATA,data:{versions:{version1:{type:l(t.label),id:s(t)},version2:{type:l(r.label),id:s(r)}}}})},enabled:!!t.uid&&!!r.uid,staleTime:f?0:1/0})}const K=({version:t})=>{const r=t==null?void 0:t.item,{data:o}=O.useChaiUserInfo(r==null?void 0:r.currentEditor),n=t.label==="live",f=t.label==="draft";return e.jsxs("span",{className:`flex items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":f?"border-amber-500/30":"border-purple-500/30"}`,children:[e.jsx("div",{className:"h-full items-center rounded px-1.5 py-0.5 font-medium capitalize"+(n?" bg-green-500 text-green-50":f?" bg-amber-500 text-amber-50":" bg-purple-500 text-purple-50"),children:t.label}),e.jsxs("div",{className:"py-1 text-xs font-light leading-none text-gray-800",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-light opacity-90",children:f?"Currently editing":"Published by"}),!f&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),e.jsx("div",{className:"text-[10px] leading-tight",children:z.formatDate(r.createdAt,"dd MMM yyyy, h:mm a")})]})]})},L=({version:t})=>e.jsx(K,{version:t});function V(t,r,o="data.json"){const n=JSON.stringify(t,null,2),f=JSON.stringify(r,null,2),l=n.split(`
|
|
2
2
|
`),s=f.split(`
|
|
3
3
|
`);let d=`--- a/${o}
|
|
4
4
|
`;d+=`+++ b/${o}
|
|
@@ -5,7 +5,7 @@ import { startsWith as T, replace as W, isString as X, trim as Y, isArray as Z,
|
|
|
5
5
|
import { FileJson as F, Loader as ne, Check as B, Copy as H } from "lucide-react";
|
|
6
6
|
import { useState as D, useMemo as A } from "react";
|
|
7
7
|
import { parseDiff as se, Diff as le, Hunk as ae } from "react-diff-view";
|
|
8
|
-
import {
|
|
8
|
+
import { ak as ie, al as oe, A as ce, ai as de } from "./index-Djepisz3.js";
|
|
9
9
|
import { useQuery as fe } from "@tanstack/react-query";
|
|
10
10
|
function me(t, n) {
|
|
11
11
|
const o = ie(), s = oe(), u = T(t.uid, "draft:") || T(n.uid, "live:");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-BELYt0c9.cjs"),C=require("@chaibuilder/sdk"),i=require("@chaibuilder/sdk/ui"),r=require("lodash-es"),j=require("lucide-react"),c=require("react"),k=require("sonner"),G=require("jotai"),L=({page:s,onClose:S})=>{const{t:a}=C.useTranslation(),[o,E]=c.useState(s.slug||""),{mutate:N,isPending:y}=n.useChangeSlug(),{data:l}=n.usePageTypes(),d=r.find(l,{key:s==null?void 0:s.pageType}),f=h=>{if(h.preventDefault(),!(s!=null&&s.primaryPage)&&Object.keys(n.LANGUAGES).some(p=>o===`/${p}`||r.startsWith(o,`/${p}/`))){k.toast.error(a("Error"),{description:a("Slugs cannot start with a language code for primary page")});return}N({...s,slug:o},{onSuccess:S})},m=(s==null?void 0:s.lang)||"";return e.jsx(i.Dialog,{open:!!s,onOpenChange:S,children:e.jsxs(i.DialogContent,{children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:a("Change Slug")}),e.jsx(i.DialogDescription,{className:"text-xs",children:e.jsxs(i.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(j.AlertCircle,{className:"h-4 w-4"}),a("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"space-y-4 py-4 text-sm ",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsxs("span",{children:[a("Type"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(d==null?void 0:d.name)||(s==null?void 0:s.pageType)]})]}),e.jsxs("div",{children:[e.jsxs("span",{children:[a("Name"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",s.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(i.Label,{htmlFor:"slug",className:"text-right",children:[a("Slug")," ",e.jsxs("small",{className:"font-light text-gray-500",children:[a("Slug should start with")," /",m]})]}),e.jsx(i.Input,{id:"slug",value:o,onChange:h=>{const x=h.target.value;r.startsWith(x,`/${m}`)&&E(x)},className:"col-span-3",required:!0,pattern:"^/.*",title:a("Slug must start with /"),placeholder:a("Enter page slug")})]})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{type:"submit",disabled:y||!r.startsWith(o,`/${m}`)||r.isEqual(s==null?void 0:s.slug,o),children:a(y?"Changing...":"Change Slug")})})]})]})})},M=c.lazy(()=>Promise.resolve().then(()=>require("./delete-page-WPGzECyJ.cjs"))),T=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-Cui0tgvd.cjs"))),_=()=>{const{t:s}=C.useTranslation(),[,S]=G.useAtom(n.addNewLangAtom),{selectedLang:a,fallbackLang:o,setSelectedLang:E}=C.useLanguages(),{data:N,isFetching:y}=n.useLanguagePages(),{data:l}=n.useCurrentPage(),{data:d}=n.usePageTypes(),f=c.useMemo(()=>{const t=d==null?void 0:d.find(g=>g.key===(l==null?void 0:l.pageType));return l!=null&&l.dynamic?t==null?void 0:t.dynamicSlug:""},[d,l==null?void 0:l.pageType,l==null?void 0:l.dynamic]),[m,h]=c.useState(null),[x,P]=c.useState(null),[p,A]=c.useState(null),{data:b}=n.useWebsiteSetting(),I=r.filter(r.get(b,"languages")||["en"],t=>!r.find(N,{lang:t})&&t!==r.get(b,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:y?e.jsxs("div",{className:"w-full space-y-3 py-4",children:[e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"})]}):r.map(N,t=>{const g=t.lang,v=t.slug,w=!t.primaryPage,D=g===a;return e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${D?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>E(g),children:[e.jsxs("div",{className:"flex-1 gap-x-3",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-[13px] text-slate-800",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.get(n.LANGUAGES,w?o:g,g)]}),e.jsxs("div",{children:[v&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:f?`${v}/${f}`:v})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),w?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(j.StarIcon,{fill:"orange",className:"h-3 w-3"}),e.jsx("b",{children:" Primary"})]}):e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE,n.PAGES_PERMISSIONS.DELETE_PAGE,n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:e.jsx(i.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(j.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),S({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(j.PencilIcon,{className:"size-3"}),s("Edit")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),P(t)},children:[e.jsx(j.Power,{className:"size-3"}),s("Unpublish")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),h(t)},children:[e.jsx(j.TrashIcon,{className:"size-3"}),s("Delete")]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(i.Button,{variant:"default",size:"sm",disabled:r.isEmpty(I),onClick:()=>{S({primaryPage:l==null?void 0:l.id,edit:!1})},children:s("Add new language page")})})}),m&&e.jsx(c.Suspense,{children:e.jsx(M,{page:m,onClose:()=>h(null)})}),x&&e.jsx(c.Suspense,{children:e.jsx(T,{page:x,onClose:()=>P(null)})}),p&&e.jsx(c.Suspense,{children:e.jsx(L,{page:p,onClose:()=>A(null)})})]})};exports.default=_;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { jsx as e, jsxs as s, Fragment as M } from "react/jsx-runtime";
|
|
2
|
+
import { an as j, h as T, L as I, ao as F, g as H, ap as O, e as W, aq as f, ar as o } from "./index-Djepisz3.js";
|
|
3
|
+
import { useTranslation as G, useLanguages as q } from "@chaibuilder/sdk";
|
|
4
|
+
import { Dialog as B, DialogContent as R, DialogHeader as J, DialogTitle as K, DialogDescription as Q, Alert as V, Label as X, Input as Y, DialogFooter as Z, Button as A, DropdownMenu as ee, DropdownMenuTrigger as se, DropdownMenuContent as ne, DropdownMenuItem as w } from "@chaibuilder/sdk/ui";
|
|
5
|
+
import { find as z, startsWith as E, isEqual as ae, filter as le, get as D, map as te, isEmpty as ie } from "lodash-es";
|
|
6
|
+
import { AlertCircle as re, StarIcon as ce, MoreHorizontal as oe, PencilIcon as de, Power as me, TrashIcon as ue } from "lucide-react";
|
|
7
|
+
import { useState as S, lazy as U, useMemo as he, Suspense as L } from "react";
|
|
8
|
+
import { toast as ge } from "sonner";
|
|
9
|
+
import { useAtom as pe } from "jotai";
|
|
10
|
+
const fe = ({
|
|
11
|
+
page: n,
|
|
12
|
+
onClose: g
|
|
13
|
+
}) => {
|
|
14
|
+
const { t } = G(), [i, v] = S(n.slug || ""), { mutate: N, isPending: y } = j(), { data: l } = T(), r = z(l, { key: n == null ? void 0 : n.pageType }), x = (m) => {
|
|
15
|
+
if (m.preventDefault(), !(n != null && n.primaryPage) && Object.keys(I).some((p) => i === `/${p}` || E(i, `/${p}/`))) {
|
|
16
|
+
ge.error(t("Error"), {
|
|
17
|
+
description: t("Slugs cannot start with a language code for primary page")
|
|
18
|
+
});
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
N({ ...n, slug: i }, { onSuccess: g });
|
|
22
|
+
}, d = (n == null ? void 0 : n.lang) || "";
|
|
23
|
+
return /* @__PURE__ */ e(B, { open: !!n, onOpenChange: g, children: /* @__PURE__ */ s(R, { children: [
|
|
24
|
+
/* @__PURE__ */ s(J, { children: [
|
|
25
|
+
/* @__PURE__ */ e(K, { children: t("Change Slug") }),
|
|
26
|
+
/* @__PURE__ */ e(Q, { className: "text-xs", children: /* @__PURE__ */ s(V, { variant: "destructive", className: "mt-2", children: [
|
|
27
|
+
/* @__PURE__ */ e(re, { className: "h-4 w-4" }),
|
|
28
|
+
t("Changing the slug may have impact on your SEO. Please proceed with caution.")
|
|
29
|
+
] }) })
|
|
30
|
+
] }),
|
|
31
|
+
/* @__PURE__ */ s("form", { onSubmit: x, children: [
|
|
32
|
+
/* @__PURE__ */ s("div", { className: "space-y-4 py-4 text-sm ", children: [
|
|
33
|
+
/* @__PURE__ */ s("div", { className: "space-y-1", children: [
|
|
34
|
+
/* @__PURE__ */ s("div", { children: [
|
|
35
|
+
/* @__PURE__ */ s("span", { children: [
|
|
36
|
+
t("Type"),
|
|
37
|
+
":"
|
|
38
|
+
] }),
|
|
39
|
+
/* @__PURE__ */ s("span", { className: "font-medium text-gray-600", children: [
|
|
40
|
+
" ",
|
|
41
|
+
(r == null ? void 0 : r.name) || (n == null ? void 0 : n.pageType)
|
|
42
|
+
] })
|
|
43
|
+
] }),
|
|
44
|
+
/* @__PURE__ */ s("div", { children: [
|
|
45
|
+
/* @__PURE__ */ s("span", { children: [
|
|
46
|
+
t("Name"),
|
|
47
|
+
":"
|
|
48
|
+
] }),
|
|
49
|
+
/* @__PURE__ */ s("span", { className: "font-medium text-gray-600", children: [
|
|
50
|
+
" ",
|
|
51
|
+
n.name
|
|
52
|
+
] })
|
|
53
|
+
] })
|
|
54
|
+
] }),
|
|
55
|
+
/* @__PURE__ */ s("div", { className: "space-y-1", children: [
|
|
56
|
+
/* @__PURE__ */ s(X, { htmlFor: "slug", className: "text-right", children: [
|
|
57
|
+
t("Slug"),
|
|
58
|
+
" ",
|
|
59
|
+
/* @__PURE__ */ s("small", { className: "font-light text-gray-500", children: [
|
|
60
|
+
t("Slug should start with"),
|
|
61
|
+
" /",
|
|
62
|
+
d
|
|
63
|
+
] })
|
|
64
|
+
] }),
|
|
65
|
+
/* @__PURE__ */ e(
|
|
66
|
+
Y,
|
|
67
|
+
{
|
|
68
|
+
id: "slug",
|
|
69
|
+
value: i,
|
|
70
|
+
onChange: (m) => {
|
|
71
|
+
const u = m.target.value;
|
|
72
|
+
E(u, `/${d}`) && v(u);
|
|
73
|
+
},
|
|
74
|
+
className: "col-span-3",
|
|
75
|
+
required: !0,
|
|
76
|
+
pattern: "^/.*",
|
|
77
|
+
title: t("Slug must start with /"),
|
|
78
|
+
placeholder: t("Enter page slug")
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
] })
|
|
82
|
+
] }),
|
|
83
|
+
/* @__PURE__ */ e(Z, { children: /* @__PURE__ */ e(
|
|
84
|
+
A,
|
|
85
|
+
{
|
|
86
|
+
type: "submit",
|
|
87
|
+
disabled: y || !E(i, `/${d}`) || ae(n == null ? void 0 : n.slug, i),
|
|
88
|
+
children: t(y ? "Changing..." : "Change Slug")
|
|
89
|
+
}
|
|
90
|
+
) })
|
|
91
|
+
] })
|
|
92
|
+
] }) });
|
|
93
|
+
}, Ne = U(() => import("./delete-page-DE-nabXs.js")), ye = U(() => import("./unpublish-page-D5tWKVLY.js")), Pe = () => {
|
|
94
|
+
const { t: n } = G(), [, g] = pe(F), { selectedLang: t, fallbackLang: i, setSelectedLang: v } = q(), { data: N, isFetching: y } = H(), { data: l } = O(), { data: r } = T(), x = he(() => {
|
|
95
|
+
const a = r == null ? void 0 : r.find((h) => h.key === (l == null ? void 0 : l.pageType));
|
|
96
|
+
return l != null && l.dynamic ? a == null ? void 0 : a.dynamicSlug : "";
|
|
97
|
+
}, [r, l == null ? void 0 : l.pageType, l == null ? void 0 : l.dynamic]), [d, m] = S(null), [u, C] = S(null), [p, _] = S(null), { data: P } = W(), $ = le(
|
|
98
|
+
D(P, "languages") || ["en"],
|
|
99
|
+
(a) => !z(N, { lang: a }) && a !== D(P, "fallbackLang")
|
|
100
|
+
);
|
|
101
|
+
return /* @__PURE__ */ s("div", { className: "space-y-4", children: [
|
|
102
|
+
/* @__PURE__ */ e("ul", { className: "space-y-2", children: y ? /* @__PURE__ */ s("div", { className: "w-full space-y-3 py-4", children: [
|
|
103
|
+
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
|
|
104
|
+
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
|
|
105
|
+
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" })
|
|
106
|
+
] }) : te(N, (a) => {
|
|
107
|
+
const h = a.lang, b = a.slug, k = !a.primaryPage;
|
|
108
|
+
return /* @__PURE__ */ s(M, { children: [
|
|
109
|
+
/* @__PURE__ */ s(
|
|
110
|
+
"li",
|
|
111
|
+
{
|
|
112
|
+
className: `flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${h === t ? "bg-gray-200" : "hover:bg-gray-100"}`,
|
|
113
|
+
onClick: () => v(h),
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ s("div", { className: "flex-1 gap-x-3", children: [
|
|
116
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-x-2 text-[13px] text-slate-800", children: [
|
|
117
|
+
/* @__PURE__ */ e("div", { className: `h-2.5 w-2.5 rounded-full ${a.online ? "bg-green-300" : "bg-gray-300"}` }),
|
|
118
|
+
D(I, k ? i : h, h)
|
|
119
|
+
] }),
|
|
120
|
+
/* @__PURE__ */ s("div", { children: [
|
|
121
|
+
b && /* @__PURE__ */ s("div", { className: "text-[11px] font-light text-slate-600", children: [
|
|
122
|
+
"Slug: ",
|
|
123
|
+
/* @__PURE__ */ e("b", { className: "font-mono font-medium", children: x ? `${b}/${x}` : b })
|
|
124
|
+
] }),
|
|
125
|
+
/* @__PURE__ */ s("div", { className: "text-[11px] font-light text-slate-600", children: [
|
|
126
|
+
"Name:",
|
|
127
|
+
/* @__PURE__ */ s("b", { className: "font-medium", children: [
|
|
128
|
+
" ",
|
|
129
|
+
a.name,
|
|
130
|
+
" "
|
|
131
|
+
] })
|
|
132
|
+
] })
|
|
133
|
+
] })
|
|
134
|
+
] }),
|
|
135
|
+
k ? /* @__PURE__ */ s("div", { className: "flex items-center gap-x-1 text-[11px] text-orange-500", children: [
|
|
136
|
+
/* @__PURE__ */ e(ce, { fill: "orange", className: "h-3 w-3" }),
|
|
137
|
+
/* @__PURE__ */ e("b", { children: " Primary" })
|
|
138
|
+
] }) : /* @__PURE__ */ e("div", { className: "flex items-center gap-x-3", children: /* @__PURE__ */ e(
|
|
139
|
+
f,
|
|
140
|
+
{
|
|
141
|
+
permissions: [
|
|
142
|
+
o.EDIT_PAGE,
|
|
143
|
+
o.DELETE_PAGE,
|
|
144
|
+
o.UNPUBLISH_PAGE
|
|
145
|
+
],
|
|
146
|
+
children: /* @__PURE__ */ s(ee, { children: [
|
|
147
|
+
/* @__PURE__ */ e(se, { asChild: !0, onClick: (c) => c.stopPropagation(), children: /* @__PURE__ */ e(A, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", children: /* @__PURE__ */ e(oe, { className: "h-4 w-4" }) }) }),
|
|
148
|
+
/* @__PURE__ */ s(ne, { align: "end", className: "z-[9999] text-sm", children: [
|
|
149
|
+
/* @__PURE__ */ e(f, { permissions: [o.EDIT_PAGE], children: /* @__PURE__ */ s(
|
|
150
|
+
w,
|
|
151
|
+
{
|
|
152
|
+
className: "flex cursor-pointer items-center gap-2",
|
|
153
|
+
onClick: (c) => {
|
|
154
|
+
c.stopPropagation(), g({
|
|
155
|
+
edit: !0,
|
|
156
|
+
id: a.id,
|
|
157
|
+
primaryPage: a.primaryPage
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
children: [
|
|
161
|
+
/* @__PURE__ */ e(de, { className: "size-3" }),
|
|
162
|
+
n("Edit")
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
) }),
|
|
166
|
+
/* @__PURE__ */ e(f, { permissions: [o.UNPUBLISH_PAGE], children: (a == null ? void 0 : a.online) && /* @__PURE__ */ s(
|
|
167
|
+
w,
|
|
168
|
+
{
|
|
169
|
+
className: "flex cursor-pointer items-center gap-2",
|
|
170
|
+
onClick: (c) => {
|
|
171
|
+
c.stopPropagation(), C(a);
|
|
172
|
+
},
|
|
173
|
+
children: [
|
|
174
|
+
/* @__PURE__ */ e(me, { className: "size-3" }),
|
|
175
|
+
n("Unpublish")
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
) }),
|
|
179
|
+
/* @__PURE__ */ e(f, { permissions: [o.DELETE_PAGE], children: /* @__PURE__ */ s(
|
|
180
|
+
w,
|
|
181
|
+
{
|
|
182
|
+
className: "flex cursor-pointer items-center gap-2",
|
|
183
|
+
onClick: (c) => {
|
|
184
|
+
c.stopPropagation(), m(a);
|
|
185
|
+
},
|
|
186
|
+
children: [
|
|
187
|
+
/* @__PURE__ */ e(ue, { className: "size-3" }),
|
|
188
|
+
n("Delete")
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
) })
|
|
192
|
+
] })
|
|
193
|
+
] })
|
|
194
|
+
}
|
|
195
|
+
) })
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
a.id
|
|
199
|
+
),
|
|
200
|
+
/* @__PURE__ */ e("div", { className: "h-1 w-full border-b" })
|
|
201
|
+
] });
|
|
202
|
+
}) }),
|
|
203
|
+
/* @__PURE__ */ e(f, { permissions: [o.ADD_PAGE], children: /* @__PURE__ */ e("div", { className: "flex w-full justify-center", children: /* @__PURE__ */ e(
|
|
204
|
+
A,
|
|
205
|
+
{
|
|
206
|
+
variant: "default",
|
|
207
|
+
size: "sm",
|
|
208
|
+
disabled: ie($),
|
|
209
|
+
onClick: () => {
|
|
210
|
+
g({
|
|
211
|
+
primaryPage: l == null ? void 0 : l.id,
|
|
212
|
+
edit: !1
|
|
213
|
+
});
|
|
214
|
+
},
|
|
215
|
+
children: n("Add new language page")
|
|
216
|
+
}
|
|
217
|
+
) }) }),
|
|
218
|
+
d && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(Ne, { page: d, onClose: () => m(null) }) }),
|
|
219
|
+
u && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(ye, { page: u, onClose: () => C(null) }) }),
|
|
220
|
+
p && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(fe, { page: p, onClose: () => _(null) }) })
|
|
221
|
+
] });
|
|
222
|
+
};
|
|
223
|
+
export {
|
|
224
|
+
Pe as default
|
|
225
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
+
import { n as P, h as z } from "./index-Djepisz3.js";
|
|
3
|
+
import { useTranslation as E } from "@chaibuilder/sdk";
|
|
4
|
+
import { Dialog as L, DialogContent as S, DialogHeader as U, DialogTitle as B, DialogDescription as R, Label as w, Textarea as j, Input as O, Button as c, DialogFooter as X } from "@chaibuilder/sdk/ui";
|
|
5
|
+
import { startCase as y } from "lodash-es";
|
|
6
|
+
import { Tag as _, File as $, ImageIcon as H, X as K } from "lucide-react";
|
|
7
|
+
import { useState as d, useRef as Z, useCallback as q } from "react";
|
|
8
|
+
import { toast as k } from "sonner";
|
|
9
|
+
const G = 1 * 1024 * 1024, se = ({ page: n, onClose: m }) => {
|
|
10
|
+
const { t: a } = E(), [g, p] = d(!1), [x, I] = d(""), [l, N] = d(""), [v, u] = d(!1), i = Z(null), T = P(), { data: h } = z(), f = h == null ? void 0 : h.find((s) => s.key === n.pageType), C = (f == null ? void 0 : f.name) || y(n.pageType), D = q((s) => {
|
|
11
|
+
var b;
|
|
12
|
+
const o = (b = s.target.files) == null ? void 0 : b[0];
|
|
13
|
+
if (o) {
|
|
14
|
+
if (o.size > G) {
|
|
15
|
+
k.error(a("File too large"), {
|
|
16
|
+
description: `${a("Maximum file size is 1MB. Selected file is")} ${(o.size / 1024).toFixed(2)}KB.`
|
|
17
|
+
}), i.current && (i.current.value = "");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
u(!0);
|
|
22
|
+
const r = new FileReader();
|
|
23
|
+
r.onloadend = () => {
|
|
24
|
+
N(r.result), u(!1);
|
|
25
|
+
}, r.readAsDataURL(o);
|
|
26
|
+
} catch (r) {
|
|
27
|
+
console.error("Error reading file:", r), u(!1), k.error(a("Failed to process image"), {
|
|
28
|
+
description: r instanceof Error ? r.message : a("Unknown error")
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}, [a]), F = () => {
|
|
33
|
+
N(""), i.current && (i.current.value = "");
|
|
34
|
+
}, M = () => {
|
|
35
|
+
var s;
|
|
36
|
+
(s = i.current) == null || s.click();
|
|
37
|
+
}, A = () => {
|
|
38
|
+
p(!0), T.mutate(
|
|
39
|
+
{
|
|
40
|
+
page: n,
|
|
41
|
+
name: n.name,
|
|
42
|
+
description: x.trim() || void 0,
|
|
43
|
+
pageType: n.pageType,
|
|
44
|
+
...l ? { previewImage: l } : {}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
onSuccess: () => {
|
|
48
|
+
p(!1), m();
|
|
49
|
+
},
|
|
50
|
+
onError: () => {
|
|
51
|
+
p(!1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ e(L, { open: !0, onOpenChange: m, children: /* @__PURE__ */ t(S, { children: [
|
|
57
|
+
/* @__PURE__ */ t(U, { children: [
|
|
58
|
+
/* @__PURE__ */ e(B, { children: a("Mark as template") }),
|
|
59
|
+
/* @__PURE__ */ t(R, { className: "space-y-1 py-4 text-xs text-slate-500", children: [
|
|
60
|
+
a("Are you sure you want to mark this page as a template?"),
|
|
61
|
+
/* @__PURE__ */ e("br", {}),
|
|
62
|
+
a("Templates can be used to create new pages with the same content.")
|
|
63
|
+
] })
|
|
64
|
+
] }),
|
|
65
|
+
/* @__PURE__ */ t("div", { className: "mb-4 space-y-4 text-xs", children: [
|
|
66
|
+
/* @__PURE__ */ t("div", { className: "space-y-3 rounded border bg-slate-50 p-4", children: [
|
|
67
|
+
/* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
|
|
68
|
+
/* @__PURE__ */ e(_, { className: "h-4 w-4 text-slate-500" }),
|
|
69
|
+
/* @__PURE__ */ t("span", { className: "font-medium text-slate-500", children: [
|
|
70
|
+
a("Page Name"),
|
|
71
|
+
":"
|
|
72
|
+
] }),
|
|
73
|
+
/* @__PURE__ */ e("span", { className: "font-semibold", children: y(n.name) })
|
|
74
|
+
] }),
|
|
75
|
+
/* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
|
|
76
|
+
/* @__PURE__ */ e($, { className: "h-4 w-4 text-slate-500" }),
|
|
77
|
+
/* @__PURE__ */ t("span", { className: "font-medium text-slate-500", children: [
|
|
78
|
+
a("Type"),
|
|
79
|
+
":"
|
|
80
|
+
] }),
|
|
81
|
+
/* @__PURE__ */ e("span", { className: "font-semibold", children: C })
|
|
82
|
+
] })
|
|
83
|
+
] }),
|
|
84
|
+
/* @__PURE__ */ t("div", { children: [
|
|
85
|
+
/* @__PURE__ */ e(w, { htmlFor: "description", className: "text-xs font-medium", children: a("Description (Optional)") }),
|
|
86
|
+
/* @__PURE__ */ e(
|
|
87
|
+
j,
|
|
88
|
+
{
|
|
89
|
+
id: "description",
|
|
90
|
+
placeholder: a("Describe this template's purpose"),
|
|
91
|
+
className: "mt-1 h-24 resize-none text-xs",
|
|
92
|
+
value: x,
|
|
93
|
+
onChange: (s) => I(s.target.value)
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
] }),
|
|
97
|
+
/* @__PURE__ */ t("div", { className: "space-y-2", children: [
|
|
98
|
+
/* @__PURE__ */ e(w, { htmlFor: "previewImage", className: "text-xs font-medium", children: a("Preview Image (Optional)") }),
|
|
99
|
+
/* @__PURE__ */ t("div", { className: "space-y-2", children: [
|
|
100
|
+
/* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
|
|
101
|
+
/* @__PURE__ */ e(
|
|
102
|
+
O,
|
|
103
|
+
{
|
|
104
|
+
type: "file",
|
|
105
|
+
id: "previewImage",
|
|
106
|
+
ref: i,
|
|
107
|
+
onChange: D,
|
|
108
|
+
accept: "image/*",
|
|
109
|
+
className: "hidden"
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ e(
|
|
113
|
+
c,
|
|
114
|
+
{
|
|
115
|
+
type: "button",
|
|
116
|
+
variant: "outline",
|
|
117
|
+
onClick: M,
|
|
118
|
+
disabled: v,
|
|
119
|
+
className: "w-full",
|
|
120
|
+
children: v ? /* @__PURE__ */ t("span", { className: "flex items-center gap-2", children: [
|
|
121
|
+
/* @__PURE__ */ e("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
|
|
122
|
+
a("Uploading...")
|
|
123
|
+
] }) : /* @__PURE__ */ t("span", { className: "flex items-center gap-2", children: [
|
|
124
|
+
/* @__PURE__ */ e(H, { className: "h-4 w-4" }),
|
|
125
|
+
a("Select image")
|
|
126
|
+
] })
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
l && /* @__PURE__ */ e(c, { type: "button", variant: "outline", size: "icon", onClick: F, children: /* @__PURE__ */ e(K, { className: "h-4 w-4" }) })
|
|
130
|
+
] }),
|
|
131
|
+
l && /* @__PURE__ */ e("div", { className: "aspect-video overflow-hidden rounded-md border", children: /* @__PURE__ */ e("img", { src: l, alt: a("Preview"), className: "h-full max-h-[200px] w-full object-contain" }) }),
|
|
132
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: a("max 1mb") })
|
|
133
|
+
] })
|
|
134
|
+
] })
|
|
135
|
+
] }),
|
|
136
|
+
/* @__PURE__ */ t(X, { className: g ? "pointer-events-none opacity-75" : "", children: [
|
|
137
|
+
/* @__PURE__ */ e(
|
|
138
|
+
c,
|
|
139
|
+
{
|
|
140
|
+
variant: "outline",
|
|
141
|
+
onClick: (s) => {
|
|
142
|
+
s.stopPropagation(), m();
|
|
143
|
+
},
|
|
144
|
+
children: a("Cancel")
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
/* @__PURE__ */ e(c, { variant: "default", disabled: g, onClick: A, children: a("Mark as template") })
|
|
148
|
+
] })
|
|
149
|
+
] }) });
|
|
150
|
+
};
|
|
151
|
+
export {
|
|
152
|
+
se as default
|
|
153
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./index-BELYt0c9.cjs"),M=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),y=require("lodash-es"),d=require("lucide-react"),l=require("react"),w=require("sonner"),q=1*1024*1024,A=({page:r,onClose:m})=>{const{t:s}=M.useTranslation(),[g,u]=l.useState(!1),[f,k]=l.useState(""),[c,j]=l.useState(""),[N,p]=l.useState(!1),i=l.useRef(null),T=b.useMarkAsTemplate(),{data:x}=b.usePageTypes(),h=x==null?void 0:x.find(t=>t.key===r.pageType),C=(h==null?void 0:h.name)||y.startCase(r.pageType),I=l.useCallback(t=>{var v;const o=(v=t.target.files)==null?void 0:v[0];if(o){if(o.size>q){w.toast.error(s("File too large"),{description:`${s("Maximum file size is 1MB. Selected file is")} ${(o.size/1024).toFixed(2)}KB.`}),i.current&&(i.current.value="");return}try{p(!0);const n=new FileReader;n.onloadend=()=>{j(n.result),p(!1)},n.readAsDataURL(o)}catch(n){console.error("Error reading file:",n),p(!1),w.toast.error(s("Failed to process image"),{description:n instanceof Error?n.message:s("Unknown error")})}}},[s]),D=()=>{j(""),i.current&&(i.current.value="")},F=()=>{var t;(t=i.current)==null||t.click()},S=()=>{u(!0),T.mutate({page:r,name:r.name,description:f.trim()||void 0,pageType:r.pageType,...c?{previewImage:c}:{}},{onSuccess:()=>{u(!1),m()},onError:()=>{u(!1)}})};return e.jsx(a.Dialog,{open:!0,onOpenChange:m,children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:s("Mark as template")}),e.jsxs(a.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:[s("Are you sure you want to mark this page as a template?"),e.jsx("br",{}),s("Templates can be used to create new pages with the same content.")]})]}),e.jsxs("div",{className:"mb-4 space-y-4 text-xs",children:[e.jsxs("div",{className:"space-y-3 rounded border bg-slate-50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.Tag,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Page Name"),":"]}),e.jsx("span",{className:"font-semibold",children:y.startCase(r.name)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.File,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Type"),":"]}),e.jsx("span",{className:"font-semibold",children:C})]})]}),e.jsxs("div",{children:[e.jsx(a.Label,{htmlFor:"description",className:"text-xs font-medium",children:s("Description (Optional)")}),e.jsx(a.Textarea,{id:"description",placeholder:s("Describe this template's purpose"),className:"mt-1 h-24 resize-none text-xs",value:f,onChange:t=>k(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"previewImage",className:"text-xs font-medium",children:s("Preview Image (Optional)")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Input,{type:"file",id:"previewImage",ref:i,onChange:I,accept:"image/*",className:"hidden"}),e.jsx(a.Button,{type:"button",variant:"outline",onClick:F,disabled:N,className:"w-full",children:N?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),s("Uploading...")]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(d.ImageIcon,{className:"h-4 w-4"}),s("Select image")]})}),c&&e.jsx(a.Button,{type:"button",variant:"outline",size:"icon",onClick:D,children:e.jsx(d.X,{className:"h-4 w-4"})})]}),c&&e.jsx("div",{className:"aspect-video overflow-hidden rounded-md border",children:e.jsx("img",{src:c,alt:s("Preview"),className:"h-full max-h-[200px] w-full object-contain"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("max 1mb")})]})]})]}),e.jsxs(a.DialogFooter,{className:g?"pointer-events-none opacity-75":"",children:[e.jsx(a.Button,{variant:"outline",onClick:t=>{t.stopPropagation(),m()},children:s("Cancel")}),e.jsx(a.Button,{variant:"default",disabled:g,onClick:S,children:s("Mark as template")})]})]})})};exports.default=A;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import { i as h, j as u, L as w, B as p } from "./index-Djepisz3.js";
|
|
3
|
+
import { useTranslation as f, useLanguages as P } from "@chaibuilder/sdk";
|
|
4
|
+
import { Card as C, CardHeader as S, CardTitle as L, CardContent as x, CardFooter as N, Button as v } from "@chaibuilder/sdk/ui";
|
|
5
|
+
import { get as B } from "lodash-es";
|
|
6
|
+
import { LockIcon as E } from "lucide-react";
|
|
7
|
+
const A = () => {
|
|
8
|
+
const { t: a } = f(), [c, l] = h(), r = c.get("lang"), i = u(r), { setSelectedLang: g } = P(), d = () => {
|
|
9
|
+
const n = new URLSearchParams(window.location.search);
|
|
10
|
+
n.delete("lang");
|
|
11
|
+
const o = n.toString(), m = `${window.location.pathname}${o ? `?${o}` : ""}`;
|
|
12
|
+
window.history.pushState({}, "", m), l(n), g(""), window.dispatchEvent(new PopStateEvent("popstate"));
|
|
13
|
+
};
|
|
14
|
+
if (i) return null;
|
|
15
|
+
const t = B(w, r);
|
|
16
|
+
return /* @__PURE__ */ e(p, { children: /* @__PURE__ */ s(C, { className: "mx-auto w-full max-w-md", children: [
|
|
17
|
+
/* @__PURE__ */ e(S, { className: "space-y-1", children: /* @__PURE__ */ s(L, { className: "flex items-center gap-2 text-2xl", children: [
|
|
18
|
+
/* @__PURE__ */ e(E, { className: "h-6 w-6 text-yellow-500" }),
|
|
19
|
+
a("Page missing for"),
|
|
20
|
+
' "',
|
|
21
|
+
t,
|
|
22
|
+
'" ',
|
|
23
|
+
a("language"),
|
|
24
|
+
"."
|
|
25
|
+
] }) }),
|
|
26
|
+
/* @__PURE__ */ e(x, { className: "grid gap-4", children: /* @__PURE__ */ s("div", { children: [
|
|
27
|
+
a("Page is not available in the"),
|
|
28
|
+
' "',
|
|
29
|
+
t,
|
|
30
|
+
'" ',
|
|
31
|
+
a("language. Either create the page in the"),
|
|
32
|
+
' "',
|
|
33
|
+
t,
|
|
34
|
+
'"',
|
|
35
|
+
a("language or switch to the base language.")
|
|
36
|
+
] }) }),
|
|
37
|
+
/* @__PURE__ */ e(N, { children: /* @__PURE__ */ e(v, { onClick: d, className: "w-full", variant: "destructive", children: a("Switch to default language") }) })
|
|
38
|
+
] }) });
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
A as default
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-BELYt0c9.cjs"),i=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),w=require("lodash-es"),x=require("lucide-react"),P=()=>{const{t:a}=i.useTranslation(),[l,g]=n.useSearchParams(),c=l.get("lang"),u=n.useIsLanguagePageCreated(c),{setSelectedLang:d}=i.useLanguages(),h=()=>{const r=new URLSearchParams(window.location.search);r.delete("lang");const o=r.toString(),m=`${window.location.pathname}${o?`?${o}`:""}`;window.history.pushState({},"",m),g(r),d(""),window.dispatchEvent(new PopStateEvent("popstate"))};if(u)return null;const s=w.get(n.LANGUAGES,c);return e.jsx(n.BlurContainer,{children:e.jsxs(t.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(t.CardHeader,{className:"space-y-1",children:e.jsxs(t.CardTitle,{className:"flex items-center gap-2 text-2xl",children:[e.jsx(x.LockIcon,{className:"h-6 w-6 text-yellow-500"}),a("Page missing for"),' "',s,'" ',a("language"),"."]})}),e.jsx(t.CardContent,{className:"grid gap-4",children:e.jsxs("div",{children:[a("Page is not available in the"),' "',s,'" ',a("language. Either create the page in the"),' "',s,'"',a("language or switch to the base language.")]})}),e.jsx(t.CardFooter,{children:e.jsx(t.Button,{onClick:h,className:"w-full",variant:"destructive",children:a("Switch to default language")})})]})})};exports.default=P;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as s, jsxs as n, Fragment as We } from "react/jsx-runtime";
|
|
2
2
|
import { Input as M, CommandList as is, Label as I, Popover as ee, PopoverTrigger as se, Button as W, PopoverContent as le, Command as ne, CommandEmpty as ae, CommandGroup as G, CommandItem as R } from "@chaibuilder/sdk/ui";
|
|
3
3
|
import { useState as y, useRef as os, useEffect as Be, useMemo as $ } from "react";
|
|
4
|
-
import { r as te, S as cs, c as Oe } from "./slug-input-
|
|
4
|
+
import { r as te, S as cs, c as Oe } from "./slug-input-D4e2anEs.js";
|
|
5
5
|
import { useChaiFeatureFlag as ye, usePermissions as us, useLanguages as ms } from "@chaibuilder/sdk";
|
|
6
6
|
import { isEmpty as Ie, startCase as de, filter as hs, find as ge, groupBy as ps, pick as ds, set as P } from "lodash-es";
|
|
7
7
|
import { ChevronDown as re, Search as ie, Check as U } from "lucide-react";
|
|
8
|
-
import {
|
|
8
|
+
import { ak as Re, al as Ue, A as oe, h as fs, am as gs, b as ys, c as vs, d as Ns, ar as bs, L as Ss } from "./index-Djepisz3.js";
|
|
9
9
|
import { useQuery as ze } from "@tanstack/react-query";
|
|
10
10
|
import { toast as E } from "sonner";
|
|
11
11
|
import { g as $e } from "./get-seo-defaults-9zHebckY.js";
|