@chaibuilder/sdk 4.0.0-beta.6 → 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-BIryEtW-.cjs → 2SSKDMRQ-DDOgISWg.cjs} +1 -1
- package/dist/{2SSKDMRQ-trME0kvt.js → 2SSKDMRQ-hL7THuKW.js} +2 -2
- package/dist/{AP7HFJJL-CAGB9iMp.js → AP7HFJJL-BsLQ13V_.js} +1 -1
- package/dist/{AP7HFJJL-5ZR38Hyh.cjs → AP7HFJJL-tcAhVllC.cjs} +1 -1
- package/dist/{IconPicker-Mu75ni5T.js → IconPicker-FLSVAZxx.js} +1 -1
- package/dist/{IconPicker-CQ-BgNNU.cjs → IconPicker-J1KLNrSB.cjs} +1 -1
- package/dist/{WDYDFRGG-n8sBZVFG.cjs → WDYDFRGG-BTj8AXV6.cjs} +1 -1
- package/dist/{WDYDFRGG-Cd4hRWj-.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-CZLV-uAW.cjs → active-in-another-tab-BtAiatqq.cjs} +1 -1
- package/dist/{active-in-another-tab-Cb6tnX9u.js → active-in-another-tab-Dozn833d.js} +2 -2
- package/dist/{add-new-language-page-C3UzNV7W.cjs → add-new-language-page-9AMizlES.cjs} +1 -1
- package/dist/{add-new-language-page-BKcBaqZu.js → add-new-language-page-DD-CAoAQ.js} +3 -3
- package/dist/{add-new-page-mULv9r3z.cjs → add-new-page-BS9vPnFG.cjs} +1 -1
- package/dist/{add-new-page-pH3PwqJe.js → add-new-page-uZKCk9eB.js} +2 -2
- package/dist/{ai-panel-content-CNxN84pv.js → ai-panel-content-CK4XOkEh.js} +3 -3
- package/dist/{ai-panel-content-BPgRdgye.cjs → ai-panel-content-PovaKJaj.cjs} +1 -1
- package/dist/{ai-panel-default-lang-DhTPtPgD.cjs → ai-panel-default-lang-B37k5ADH.cjs} +2 -2
- package/dist/{ai-panel-default-lang-CYcHjk8U.js → ai-panel-default-lang-BtLjUl9d.js} +3 -3
- package/dist/{ai-panel-other-lang-CGNU3-FI.cjs → ai-panel-other-lang-CdQmASqv.cjs} +1 -1
- package/dist/{ai-panel-other-lang-D8Ofvj8F.js → ai-panel-other-lang-Dp1MNaLi.js} +3 -3
- package/dist/{ai-prompt-input-Ceuy5bs3.js → ai-prompt-input-BT-mEdTX.js} +1 -1
- package/dist/{ai-prompt-input-CUutJjlf.cjs → ai-prompt-input-Dtym4w8J.cjs} +1 -1
- package/dist/{ai-translation-prompt-CoCPLEed.cjs → ai-translation-prompt-B-lH7emI.cjs} +1 -1
- package/dist/{ai-translation-prompt-BiepZRcN.js → ai-translation-prompt-B17GK1QR.js} +1 -1
- package/dist/{code-editor-C1ewJzDJ.cjs → code-editor-CUeNiMzA.cjs} +1 -1
- package/dist/{code-editor-Z14ByBIv.js → code-editor-EZT2pMsU.js} +1 -1
- package/dist/{continue-editing-in-this-client-Byi6ER3L.js → continue-editing-in-this-client-CS7C6h9Q.js} +2 -2
- package/dist/{continue-editing-in-this-client-k9Ab5E63.cjs → continue-editing-in-this-client-DMZOc36k.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{css-import-modal--bSJR-_y.cjs → css-import-modal-kHB0ramf.cjs} +1 -1
- package/dist/{css-import-modal-De7Kvg5C.js → css-import-modal-s7t5gZQo.js} +1 -1
- package/dist/{delete-design-token-B97CnFDU.js → delete-design-token-C1smbx4E.js} +1 -1
- package/dist/{delete-design-token-C6s-ESB_.cjs → delete-design-token-Mbw_6sYI.cjs} +1 -1
- package/dist/{delete-page-Dnf97ZHP.js → delete-page-2GfBi8Iv.js} +2 -2
- package/dist/{delete-page-Djn97HiP.cjs → delete-page-B7J3t0FN.cjs} +1 -1
- package/dist/{design-token-usage-OTd93kS8.cjs → design-token-usage-BoGOULG8.cjs} +1 -1
- package/dist/{design-token-usage-B-SykAjD.js → design-token-usage-DyO3xM-F.js} +1 -1
- package/dist/{digital-asset-manager-b8gDuLnI.js → digital-asset-manager-Cz3Nlrzl.js} +3 -3
- package/dist/{digital-asset-manager-DHYRXaaq.cjs → digital-asset-manager-DDk2ucTE.cjs} +1 -1
- package/dist/{duplicate-page-Bdtpl7_R.js → duplicate-page-BwAY4Ssm.js} +3 -3
- package/dist/{duplicate-page-C4Ovp8Ff.cjs → duplicate-page-Dw3U4wTT.cjs} +1 -1
- package/dist/{dynamic-page-selector-B8DdnfrF.cjs → dynamic-page-selector-CvBFyX2F.cjs} +1 -1
- package/dist/{dynamic-page-selector-BVnIM1Rq.js → dynamic-page-selector-sViJuQlU.js} +2 -2
- package/dist/{image-editor-C2zOHeKv.cjs → image-editor-AIsccrqC.cjs} +1 -1
- package/dist/{image-editor-cckqPmk5.js → image-editor-BgGQuESa.js} +1 -1
- package/dist/{index-Bn0fFN58.js → index-B7eWP_hB.js} +522 -511
- package/dist/index-BwH1mRm_.cjs +5 -0
- package/dist/{index-CAhEmHYP.js → index-RYr8kQdI.js} +2132 -2130
- package/dist/{index-B0e71wJ1.cjs → index-xYnNKovy.cjs} +15 -15
- package/dist/{json-diff-viewer-D9DVIBz4.cjs → json-diff-viewer-B2A78udz.cjs} +1 -1
- package/dist/{json-diff-viewer-DNizzMnu.js → json-diff-viewer-Svw-kbhe.js} +2 -2
- package/dist/{lang-panel-C1dbn163.cjs → lang-panel-AmEkoWid.cjs} +1 -1
- package/dist/{lang-panel-DL_BtSRD.js → lang-panel-Bnc-9wkM.js} +3 -3
- package/dist/{manage-design-tokens-CXjYkarE.cjs → manage-design-tokens-B2fG80bi.cjs} +1 -1
- package/dist/{manage-design-tokens-xxMO_RYg.js → manage-design-tokens-BBkh1t4w.js} +2 -2
- package/dist/{mark-as-template-Ba2bmVd9.js → mark-as-template-0CPzZnk-.js} +2 -2
- package/dist/{mark-as-template-DF1KIMr0.cjs → mark-as-template-CE6tRoQy.cjs} +1 -1
- package/dist/{nested-path-selector-content-Cuk7NB-u.cjs → nested-path-selector-content-SmfjElr-.cjs} +1 -1
- package/dist/{nested-path-selector-content-Br1IWhK5.js → nested-path-selector-content-kGznHufl.js} +1 -1
- package/dist/{no-language-page-content-CxTp-LIM.cjs → no-language-page-content-B4bQLc4K.cjs} +1 -1
- package/dist/{no-language-page-content-9B2Fm-on.js → no-language-page-content-DXsAPDZd.js} +2 -2
- package/dist/{no-language-page-dialog-DynACvgV.cjs → no-language-page-dialog-BC8NHzK2.cjs} +1 -1
- package/dist/{no-language-page-dialog-CPlKMyb8.js → no-language-page-dialog-BpPqmw9a.js} +2 -2
- package/dist/{page-creator-Cbfv9N0P.cjs → page-creator-82qTbBj4.cjs} +1 -1
- package/dist/{page-creator-BtyJz2sx.js → page-creator-Bazn6yH4.js} +3 -3
- package/dist/{page-lock-CzsxrmN5.js → page-lock-CRFyqKZE.js} +2 -2
- package/dist/{page-lock-fRos9wRU.cjs → page-lock-D2iFZDUK.cjs} +1 -1
- package/dist/{page-locked-dialog-D2q9qkPk.js → page-locked-dialog-GKfQEOmk.js} +2 -2
- package/dist/{page-locked-dialog-D57d2gvn.cjs → page-locked-dialog-xLqvKzax.cjs} +1 -1
- package/dist/{page-manager-new-aE198gKS.cjs → page-manager-new-Bn2QKjbf.cjs} +1 -1
- package/dist/{page-manager-new-D6DVIx2S.js → page-manager-new-DItY2hjd.js} +3 -3
- package/dist/{page-manager-search-and-filter-CuZkQaZg.js → page-manager-search-and-filter-CPa8IXdd.js} +2 -2
- package/dist/{page-manager-search-and-filter-DGQEgKzy.cjs → page-manager-search-and-filter-Dc4ky-qV.cjs} +1 -1
- package/dist/{page-revisions-content-5rbicFbD.js → page-revisions-content-CH-PZK0O.js} +3 -3
- package/dist/{page-revisions-content-CefqOvKX.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-DBb8M3TG.cjs → publish-pages-content-BzJDObqr.cjs} +1 -1
- package/dist/{publish-pages-content-WeGk-YLC.js → publish-pages-content-CSJCFElu.js} +3 -3
- package/dist/{rte-widget-modal-J-_AytmK.js → rte-widget-modal-5T81P_hg.js} +1 -1
- package/dist/{rte-widget-modal-DBoPRXq-.cjs → rte-widget-modal-BfXcA7OP.cjs} +1 -1
- package/dist/{save-to-lib-0ysmXVbI.cjs → save-to-lib-DGAdSa-0.cjs} +1 -1
- package/dist/{save-to-lib-CQQxoovF.js → save-to-lib-MtWKSVeN.js} +2 -2
- package/dist/{selected-block-display-CgoXS8Hr.js → selected-block-display-CB1-hVR5.js} +2 -2
- package/dist/{selected-block-display-BWupQFoQ.cjs → selected-block-display-DLt_nMn9.cjs} +1 -1
- package/dist/{seo-panel-B798Myp_.js → seo-panel-CRzzw4FW.js} +2 -2
- package/dist/{seo-panel-BkFbXIL0.cjs → seo-panel-_kGXE9MC.cjs} +1 -1
- package/dist/{shared-json-ld-Clg_UEhd.js → shared-json-ld-CXukkDeS.js} +2 -2
- package/dist/{shared-json-ld-Cn3MCW6I.cjs → shared-json-ld-DoRgzDPC.cjs} +1 -1
- package/dist/{slug-input-hX5VaZpj.js → slug-input-CeEQ0zyv.js} +1 -1
- package/dist/{slug-input-BHyD8cxk.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-s1L5Yofb.js → take-over-request-C9J3_rev.js} +2 -2
- package/dist/{take-over-request-Dzczo20q.cjs → take-over-request-CXuakFBm.cjs} +1 -1
- package/dist/{theme-panel-footer-NTNCL0SW.cjs → theme-panel-footer-CWZ0qs13.cjs} +1 -1
- package/dist/{theme-panel-footer-sK6bYhEb.js → theme-panel-footer-DvwsyHNQ.js} +2 -2
- package/dist/{translation-warning-modal-BfM4HGck.cjs → translation-warning-modal-DEt_ExQp.cjs} +1 -1
- package/dist/{translation-warning-modal-Jadkcver.js → translation-warning-modal-_aBp5ZZQ.js} +1 -1
- package/dist/{unmark-as-template-CqkHI3gR.cjs → unmark-as-template-BYL5naYx.cjs} +1 -1
- package/dist/{unmark-as-template-D5b775eR.js → unmark-as-template-JN-cDUV_.js} +2 -2
- package/dist/{unpublish-page-BT5bCfs6.cjs → unpublish-page-B06iZEIO.cjs} +1 -1
- package/dist/{unpublish-page-DLLLgY43.js → unpublish-page-DqwBY2yI.js} +2 -2
- package/dist/{web-preview-C_yFwxEe.js → web-preview-h39D3TUh.js} +1 -1
- package/dist/{web-preview-DU1MgppY.cjs → web-preview-wRgRY3Tv.cjs} +1 -1
- package/package.json +22 -24
- package/dist/index-DKuwxj1x.cjs +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-B0e71wJ1.cjs"),m=require("./register-chai-top-bar-BqwKw4uy.cjs"),c=require("./index-DKuwxj1x.cjs"),q=require("@tanstack/react-query"),I=require("lodash-es"),N=require("lucide-react"),x=require("react"),F=require("sonner"),z=()=>{const t=c.useApiUrl(),d=c.useFetch();return q.useQuery({queryKey:[c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS],queryFn:async()=>d(t,{action:c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS})})},U=({show:t,onClose:d,initialData:n})=>e.jsx(s.Dialog,{open:t,onOpenChange:()=>d(),children:t&&e.jsx(_,{show:t,onClose:d,initialData:n})}),_=({show:t,onClose:d,initialData:n})=>{const[r,j]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[b,C]=x.useState(!1),{data:p}=c.useChaiCurrentPage(),{mutateAsync:S,isPending:f}=c.useAddGlobalSchema(),{mutateAsync:u}=c.useTogglePageGlobalSchema(),w=q.useQueryClient();x.useEffect(()=>{j(n?{name:n.name,description:n.description,content:JSON.stringify(n.jsonld,null,2),enabledByDefaultForNewPages:!1}:{name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),C(!1)},[t,n]);const i=async()=>{if(!r.name||!r.content){F.toast.error("Please enter a name and content");return}const l=c.parseJSONWithPlaceholders(r.content);if(!l.isValid){F.toast.error("Invalid JSON-LD content");return}const y={name:r.name,jsonld:l.parsed,addToExistingPages:b,addToNewPages:r.enabledByDefaultForNewPages,description:r.description};n!=null&&n.primaryPageId&&(y.primaryPage=n.primaryPageId);const A=await S(y);p!=null&&p.id&&(A!=null&&A.id)&&!(n!=null&&n.primaryPageId)&&(await u({schemaId:A.id,pageId:p.id,enabled:!0}),w.invalidateQueries({queryKey:[c.ACTIONS.GET_LANGUAGE_PAGES,p.id]})),d()};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Add New Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[(n==null?void 0:n.languageCode)&&e.jsxs(m.Alert,{className:"border-blue-200 bg-blue-50",children:[e.jsx(N.Info,{className:"h-4 w-4 text-blue-600"}),e.jsxs(m.AlertDescription,{className:"text-sm text-blue-800",children:["You are creating a ",e.jsx("span",{className:"font-semibold",children:n.languageCode})," language version of this schema. This will be linked to the default language schema."]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(m.Input,{id:"new-name",value:r.name,onChange:l=>j({...r,name:l.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-description",children:"Description"}),e.jsx(m.Input,{id:"new-description",value:r.description||"",onChange:l=>j({...r,description:l.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"new-content",value:r.content||"{}",onChange:l=>j({...r,content:l}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!(n!=null&&n.primaryPageId)&&e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"add-to-all-existing",checked:b,onChange:l=>C(l.target.checked),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"add-to-all-existing",children:[e.jsx("div",{children:"Add to all existing pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"This schema will be added to all existing pages on your site"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-enabled",checked:r.enabledByDefaultForNewPages,onChange:l=>j({...r,enabledByDefaultForNewPages:l.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"new-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(m.Button,{disabled:f,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(m.Button,{disabled:f,type:"button",size:"sm",onClick:i,children:f?e.jsxs(e.Fragment,{children:[e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"})," Adding"]}):e.jsxs(e.Fragment,{children:["Add Schema",(n==null?void 0:n.languageCode)&&` (${n.languageCode})`]})})]})})]})]})},H=({id:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:()=>d(),children:t&&e.jsx(Q,{id:t,onClose:d})}),Q=({id:t,onClose:d})=>{const[n,r]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[j,b]=x.useState(!1),[C,p]=x.useState(!1),[S,f]=x.useState(!1),{data:u}=z(),{mutateAsync:w,isPending:i}=c.useUpdateGlobalSchema(),{mutateAsync:l}=c.useApplySchemaToAllPages(),{mutateAsync:y}=c.useRemoveSchemaFromAllPages();x.useEffect(()=>{var h,D;if(t&&u){const v=u.find(L=>L.id===t);v&&(r({name:v.name,description:((h=v.metadata)==null?void 0:h.description)||"",content:JSON.stringify(v.jsonld,null,2),enabledByDefaultForNewPages:((D=v.metadata)==null?void 0:D.addToNewPages)||!1}),f(!!v.primaryPage))}},[t,u]);const A=async()=>{if(!n.name||!n.content){F.toast.error("Please enter a name and content");return}const h=c.parseJSONWithPlaceholders(n.content);if(!h.isValid){F.toast.error("Invalid JSON-LD content");return}const D={id:t,name:n.name,jsonld:h.parsed,addToNewPages:n.enabledByDefaultForNewPages,description:n.description};await w(D),d()},O=async()=>{try{await l(t)}finally{b(!1)}},T=async()=>{try{await y(t)}finally{p(!1)}};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Edit Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[!S&&e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-blue-900",children:"Manage Existing Pages"}),e.jsx("div",{className:"text-xs text-blue-700",children:"Add or remove this schema from all existing pages on your site"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m.Button,{size:"sm",className:"text-xs",variant:"outline",onClick:()=>b(!0),children:"Add to all existing"}),e.jsx(m.Button,{size:"sm",variant:"ghost",className:"text-xs",onClick:()=>p(!0),children:"Remove from all"})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-name",children:"Schema Name"}),e.jsx(m.Input,{id:"edit-name",value:n.name,onChange:h=>r({...n,name:h.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-description",children:"Description"}),e.jsx(m.Input,{id:"edit-description",value:n.description||"",onChange:h=>r({...n,description:h.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"edit-content",value:n.content||"{}",onChange:h=>r({...n,content:h}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!S&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"edit-enabled",checked:n.enabledByDefaultForNewPages,onChange:h=>r({...n,enabledByDefaultForNewPages:h.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"edit-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(m.Button,{disabled:i,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(m.Button,{disabled:i,type:"button",size:"sm",onClick:A,children:i?e.jsxs(e.Fragment,{children:[e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"})," Updating"]}):"Update Schema"})]})})]}),e.jsx(s.AlertDialog,{open:j,onOpenChange:b,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Add to All Existing Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will add the schema ",e.jsx("span",{className:"font-medium",children:n.name})," to all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:O,children:"Add to All"})]})]})}),e.jsx(s.AlertDialog,{open:C,onOpenChange:p,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Remove from All Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will remove the schema ",e.jsx("span",{className:"font-medium",children:n.name})," from all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:T,className:"bg-red-500 hover:bg-red-600",children:"Remove from All"})]})]})})]})};function V(){const[t,d]=x.useState(!1),[n,r]=x.useState(void 0),[j,b]=x.useState(null),[C,p]=x.useState(null),[S,f]=x.useState(null),{data:u,isLoading:w}=z(),{selectedLang:i}=s.useLanguages(),{data:l}=c.useChaiCurrentPage(),{data:y}=c.useLanguagePages(),{mutateAsync:A}=c.useDeleteGlobalSchema(),{mutateAsync:O}=c.useTogglePageGlobalSchema(),T=x.useMemo(()=>y==null?void 0:y.find(a=>!a.primaryPage&&a.lang===""),[y]),h=x.useMemo(()=>(T==null?void 0:T.globalJsonLds)||[],[T]),D=x.useMemo(()=>u?I.filter(u,o=>o.primaryPage===null&&o.lang==="").map(o=>{const g=i?I.find(u,P=>P.primaryPage===o.id&&P.lang===i):null;return{defaultSchema:o,languageVersion:g,displayItem:g||o,hasLanguageVersion:!!g}}):[],[u,i]),[v,L]=x.useState([]),E=v.length>0?v:(l==null?void 0:l.globalJsonLds)||[];x.useEffect(()=>{l!=null&&l.globalJsonLds&&L(l.globalJsonLds)},[l==null?void 0:l.globalJsonLds]);const R=async a=>{if(!(l!=null&&l.id))return;f(a);const o=E.includes(a),g=o?E.filter(P=>P!==a):[...E,a];L(g);try{await O({schemaId:a,pageId:l.id,enabled:!o})}catch{L(l.globalJsonLds)}finally{f(null)}},M=async a=>{f(a);try{await A(a)}finally{f(null)}};return e.jsxs("div",{className:"rounded border bg-muted p-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:"Shared JSON-LD Templates"}),e.jsx("div",{className:"w-full text-xs text-gray-500",children:"Manage reusable JSON-LD schemas that can be applied across multiple pages"})]}),!i&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:w,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:a=>{a.stopPropagation(),d(!0)},children:w?e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(N.Plus,{className:"h-4 w-4"})}),e.jsx(s.TooltipContent,{children:"Add new schema"})]})]}),e.jsxs(s.ScrollArea,{className:"max-h-96 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[(!u||(u==null?void 0:u.length)===0)&&!w&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),D.map(({defaultSchema:a,displayItem:o,hasLanguageVersion:g})=>{var B,G;const P=E.includes(o.id),J=h.includes(a.id),k=g&&i?J:P;return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${S===o.id?"pointer-events-none":""}`,children:[S===o.id&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80",children:e.jsx(N.Loader,{className:"h-5 w-5 animate-spin text-primary"})}),e.jsx(s.CardHeader,{className:"p-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(g||!i)&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("input",{type:"checkbox",checked:k,onChange:()=>R(a.id),disabled:!!(g&&i),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"})}),g&&i&&e.jsx(s.TooltipContent,{children:"Using the default language state"})]}),e.jsxs("div",{children:[e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:[o.name,g&&i&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(",i,")"]}),k&&e.jsx("span",{className:"sr-only text-xs font-normal text-muted-foreground",children:"Enabled"})]}),((B=o==null?void 0:o.metadata)==null?void 0:B.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:(G=o==null?void 0:o.metadata)==null?void 0:G.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"mx-2 h-6 w-px bg-border"}),e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>p(o.id),children:e.jsx(N.Eye,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"View schema"})]}),(g||!i)&&e.jsxs(e.Fragment,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>b(o.id),children:e.jsx(N.Edit,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Edit schema"})]}),e.jsxs(s.AlertDialog,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.AlertDialogTrigger,{className:"flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800",children:e.jsx(N.Trash,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Delete schema"})]}),e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Schema"}),e.jsxs(s.AlertDialogDescription,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium",children:o.name}),"? This action cannot be undone."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{type:"button",children:"Cancel"}),e.jsx(s.AlertDialogAction,{type:"button",onClick:()=>M(o.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})]})}),!g&&i&&e.jsx(s.CardContent,{className:"px-2 pb-2",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"max-w-xl text-center text-xs text-gray-500",children:["Not available in '",i,"' language. Default language JSONLD will be used."]}),J&&e.jsx("span",{className:"rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700",children:"Enabled in default"})]}),e.jsx(m.Button,{type:"button",size:"sm",variant:"outline",className:"mt-2",onClick:()=>{r({name:a.name,description:a.description||"",jsonld:a.jsonld,languageCode:i,primaryPageId:a.id}),d(!0)},children:"Copy & Edit from default language"})]})})]},a.id)})]}),w&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(N.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(U,{show:t,onClose:()=>{d(!1),r(void 0)},initialData:n}),e.jsx(H,{id:j,onClose:()=>b(null)}),e.jsx(K,{schema:u==null?void 0:u.find(a=>a.id===C),onClose:()=>p(null)})]})}const K=({schema:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:d,children:e.jsxs(s.DialogContent,{className:"max-w-2xl",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[t==null?void 0:t.name,(t==null?void 0:t.lang)&&e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",t.lang,")"]})]})}),e.jsxs("div",{className:"space-y-3",children:[(t==null?void 0:t.description)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Description"}),e.jsx("div",{className:"text-sm",children:t.description})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"JSON-LD Schema"}),e.jsx(s.Textarea,{value:JSON.stringify(t==null?void 0:t.jsonld,null,2),readOnly:!0,className:"font-mono text-xs",rows:15})]})]})]})});exports.default=V;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-xYnNKovy.cjs"),m=require("./register-chai-top-bar-BqwKw4uy.cjs"),c=require("./index-BwH1mRm_.cjs"),q=require("@tanstack/react-query"),I=require("lodash-es"),N=require("lucide-react"),x=require("react"),F=require("sonner"),z=()=>{const t=c.useApiUrl(),d=c.useFetch();return q.useQuery({queryKey:[c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS],queryFn:async()=>d(t,{action:c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS})})},U=({show:t,onClose:d,initialData:n})=>e.jsx(s.Dialog,{open:t,onOpenChange:()=>d(),children:t&&e.jsx(_,{show:t,onClose:d,initialData:n})}),_=({show:t,onClose:d,initialData:n})=>{const[r,j]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[b,C]=x.useState(!1),{data:p}=c.useChaiCurrentPage(),{mutateAsync:S,isPending:f}=c.useAddGlobalSchema(),{mutateAsync:u}=c.useTogglePageGlobalSchema(),w=q.useQueryClient();x.useEffect(()=>{j(n?{name:n.name,description:n.description,content:JSON.stringify(n.jsonld,null,2),enabledByDefaultForNewPages:!1}:{name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),C(!1)},[t,n]);const i=async()=>{if(!r.name||!r.content){F.toast.error("Please enter a name and content");return}const l=c.parseJSONWithPlaceholders(r.content);if(!l.isValid){F.toast.error("Invalid JSON-LD content");return}const y={name:r.name,jsonld:l.parsed,addToExistingPages:b,addToNewPages:r.enabledByDefaultForNewPages,description:r.description};n!=null&&n.primaryPageId&&(y.primaryPage=n.primaryPageId);const A=await S(y);p!=null&&p.id&&(A!=null&&A.id)&&!(n!=null&&n.primaryPageId)&&(await u({schemaId:A.id,pageId:p.id,enabled:!0}),w.invalidateQueries({queryKey:[c.ACTIONS.GET_LANGUAGE_PAGES,p.id]})),d()};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Add New Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[(n==null?void 0:n.languageCode)&&e.jsxs(m.Alert,{className:"border-blue-200 bg-blue-50",children:[e.jsx(N.Info,{className:"h-4 w-4 text-blue-600"}),e.jsxs(m.AlertDescription,{className:"text-sm text-blue-800",children:["You are creating a ",e.jsx("span",{className:"font-semibold",children:n.languageCode})," language version of this schema. This will be linked to the default language schema."]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(m.Input,{id:"new-name",value:r.name,onChange:l=>j({...r,name:l.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-description",children:"Description"}),e.jsx(m.Input,{id:"new-description",value:r.description||"",onChange:l=>j({...r,description:l.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"new-content",value:r.content||"{}",onChange:l=>j({...r,content:l}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!(n!=null&&n.primaryPageId)&&e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"add-to-all-existing",checked:b,onChange:l=>C(l.target.checked),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"add-to-all-existing",children:[e.jsx("div",{children:"Add to all existing pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"This schema will be added to all existing pages on your site"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-enabled",checked:r.enabledByDefaultForNewPages,onChange:l=>j({...r,enabledByDefaultForNewPages:l.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"new-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(m.Button,{disabled:f,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(m.Button,{disabled:f,type:"button",size:"sm",onClick:i,children:f?e.jsxs(e.Fragment,{children:[e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"})," Adding"]}):e.jsxs(e.Fragment,{children:["Add Schema",(n==null?void 0:n.languageCode)&&` (${n.languageCode})`]})})]})})]})]})},H=({id:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:()=>d(),children:t&&e.jsx(Q,{id:t,onClose:d})}),Q=({id:t,onClose:d})=>{const[n,r]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[j,b]=x.useState(!1),[C,p]=x.useState(!1),[S,f]=x.useState(!1),{data:u}=z(),{mutateAsync:w,isPending:i}=c.useUpdateGlobalSchema(),{mutateAsync:l}=c.useApplySchemaToAllPages(),{mutateAsync:y}=c.useRemoveSchemaFromAllPages();x.useEffect(()=>{var h,D;if(t&&u){const v=u.find(L=>L.id===t);v&&(r({name:v.name,description:((h=v.metadata)==null?void 0:h.description)||"",content:JSON.stringify(v.jsonld,null,2),enabledByDefaultForNewPages:((D=v.metadata)==null?void 0:D.addToNewPages)||!1}),f(!!v.primaryPage))}},[t,u]);const A=async()=>{if(!n.name||!n.content){F.toast.error("Please enter a name and content");return}const h=c.parseJSONWithPlaceholders(n.content);if(!h.isValid){F.toast.error("Invalid JSON-LD content");return}const D={id:t,name:n.name,jsonld:h.parsed,addToNewPages:n.enabledByDefaultForNewPages,description:n.description};await w(D),d()},O=async()=>{try{await l(t)}finally{b(!1)}},T=async()=>{try{await y(t)}finally{p(!1)}};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Edit Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[!S&&e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-blue-900",children:"Manage Existing Pages"}),e.jsx("div",{className:"text-xs text-blue-700",children:"Add or remove this schema from all existing pages on your site"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m.Button,{size:"sm",className:"text-xs",variant:"outline",onClick:()=>b(!0),children:"Add to all existing"}),e.jsx(m.Button,{size:"sm",variant:"ghost",className:"text-xs",onClick:()=>p(!0),children:"Remove from all"})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-name",children:"Schema Name"}),e.jsx(m.Input,{id:"edit-name",value:n.name,onChange:h=>r({...n,name:h.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-description",children:"Description"}),e.jsx(m.Input,{id:"edit-description",value:n.description||"",onChange:h=>r({...n,description:h.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"edit-content",value:n.content||"{}",onChange:h=>r({...n,content:h}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!S&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"edit-enabled",checked:n.enabledByDefaultForNewPages,onChange:h=>r({...n,enabledByDefaultForNewPages:h.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"edit-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(m.Button,{disabled:i,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(m.Button,{disabled:i,type:"button",size:"sm",onClick:A,children:i?e.jsxs(e.Fragment,{children:[e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"})," Updating"]}):"Update Schema"})]})})]}),e.jsx(s.AlertDialog,{open:j,onOpenChange:b,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Add to All Existing Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will add the schema ",e.jsx("span",{className:"font-medium",children:n.name})," to all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:O,children:"Add to All"})]})]})}),e.jsx(s.AlertDialog,{open:C,onOpenChange:p,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Remove from All Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will remove the schema ",e.jsx("span",{className:"font-medium",children:n.name})," from all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:T,className:"bg-red-500 hover:bg-red-600",children:"Remove from All"})]})]})})]})};function V(){const[t,d]=x.useState(!1),[n,r]=x.useState(void 0),[j,b]=x.useState(null),[C,p]=x.useState(null),[S,f]=x.useState(null),{data:u,isLoading:w}=z(),{selectedLang:i}=s.useLanguages(),{data:l}=c.useChaiCurrentPage(),{data:y}=c.useLanguagePages(),{mutateAsync:A}=c.useDeleteGlobalSchema(),{mutateAsync:O}=c.useTogglePageGlobalSchema(),T=x.useMemo(()=>y==null?void 0:y.find(a=>!a.primaryPage&&a.lang===""),[y]),h=x.useMemo(()=>(T==null?void 0:T.globalJsonLds)||[],[T]),D=x.useMemo(()=>u?I.filter(u,o=>o.primaryPage===null&&o.lang==="").map(o=>{const g=i?I.find(u,P=>P.primaryPage===o.id&&P.lang===i):null;return{defaultSchema:o,languageVersion:g,displayItem:g||o,hasLanguageVersion:!!g}}):[],[u,i]),[v,L]=x.useState([]),E=v.length>0?v:(l==null?void 0:l.globalJsonLds)||[];x.useEffect(()=>{l!=null&&l.globalJsonLds&&L(l.globalJsonLds)},[l==null?void 0:l.globalJsonLds]);const R=async a=>{if(!(l!=null&&l.id))return;f(a);const o=E.includes(a),g=o?E.filter(P=>P!==a):[...E,a];L(g);try{await O({schemaId:a,pageId:l.id,enabled:!o})}catch{L(l.globalJsonLds)}finally{f(null)}},M=async a=>{f(a);try{await A(a)}finally{f(null)}};return e.jsxs("div",{className:"rounded border bg-muted p-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:"Shared JSON-LD Templates"}),e.jsx("div",{className:"w-full text-xs text-gray-500",children:"Manage reusable JSON-LD schemas that can be applied across multiple pages"})]}),!i&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:w,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:a=>{a.stopPropagation(),d(!0)},children:w?e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(N.Plus,{className:"h-4 w-4"})}),e.jsx(s.TooltipContent,{children:"Add new schema"})]})]}),e.jsxs(s.ScrollArea,{className:"max-h-96 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[(!u||(u==null?void 0:u.length)===0)&&!w&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),D.map(({defaultSchema:a,displayItem:o,hasLanguageVersion:g})=>{var B,G;const P=E.includes(o.id),J=h.includes(a.id),k=g&&i?J:P;return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${S===o.id?"pointer-events-none":""}`,children:[S===o.id&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80",children:e.jsx(N.Loader,{className:"h-5 w-5 animate-spin text-primary"})}),e.jsx(s.CardHeader,{className:"p-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(g||!i)&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("input",{type:"checkbox",checked:k,onChange:()=>R(a.id),disabled:!!(g&&i),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"})}),g&&i&&e.jsx(s.TooltipContent,{children:"Using the default language state"})]}),e.jsxs("div",{children:[e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:[o.name,g&&i&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(",i,")"]}),k&&e.jsx("span",{className:"sr-only text-xs font-normal text-muted-foreground",children:"Enabled"})]}),((B=o==null?void 0:o.metadata)==null?void 0:B.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:(G=o==null?void 0:o.metadata)==null?void 0:G.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"mx-2 h-6 w-px bg-border"}),e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>p(o.id),children:e.jsx(N.Eye,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"View schema"})]}),(g||!i)&&e.jsxs(e.Fragment,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>b(o.id),children:e.jsx(N.Edit,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Edit schema"})]}),e.jsxs(s.AlertDialog,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.AlertDialogTrigger,{className:"flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800",children:e.jsx(N.Trash,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Delete schema"})]}),e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Schema"}),e.jsxs(s.AlertDialogDescription,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium",children:o.name}),"? This action cannot be undone."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{type:"button",children:"Cancel"}),e.jsx(s.AlertDialogAction,{type:"button",onClick:()=>M(o.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})]})}),!g&&i&&e.jsx(s.CardContent,{className:"px-2 pb-2",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"max-w-xl text-center text-xs text-gray-500",children:["Not available in '",i,"' language. Default language JSONLD will be used."]}),J&&e.jsx("span",{className:"rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700",children:"Enabled in default"})]}),e.jsx(m.Button,{type:"button",size:"sm",variant:"outline",className:"mt-2",onClick:()=>{r({name:a.name,description:a.description||"",jsonld:a.jsonld,languageCode:i,primaryPageId:a.id}),d(!0)},children:"Copy & Edit from default language"})]})})]},a.id)})]}),w&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(N.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(U,{show:t,onClose:()=>{d(!1),r(void 0)},initialData:n}),e.jsx(H,{id:j,onClose:()=>b(null)}),e.jsx(K,{schema:u==null?void 0:u.find(a=>a.id===C),onClose:()=>p(null)})]})}const K=({schema:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:d,children:e.jsxs(s.DialogContent,{className:"max-w-2xl",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[t==null?void 0:t.name,(t==null?void 0:t.lang)&&e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",t.lang,")"]})]})}),e.jsxs("div",{className:"space-y-3",children:[(t==null?void 0:t.description)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Description"}),e.jsx("div",{className:"text-sm",children:t.description})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"JSON-LD Schema"}),e.jsx(s.Textarea,{value:JSON.stringify(t==null?void 0:t.jsonld,null,2),readOnly:!0,className:"font-mono text-xs",rows:15})]})]})]})});exports.default=V;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as i, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { z as v } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
3
|
-
import { a8 as d } from "./index-
|
|
3
|
+
import { a8 as d } from "./index-RYr8kQdI.js";
|
|
4
4
|
import { useState as x, useEffect as C } from "react";
|
|
5
5
|
const y = (e) => {
|
|
6
6
|
if (!e) return { base: e, extension: null };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const s=require("react/jsx-runtime"),b=require("./register-chai-top-bar-BqwKw4uy.cjs"),u=require("./index-
|
|
1
|
+
"use strict";const s=require("react/jsx-runtime"),b=require("./register-chai-top-bar-BqwKw4uy.cjs"),u=require("./index-xYnNKovy.cjs"),d=require("react"),j=e=>{if(!e)return{base:e,extension:null};const n=e.lastIndexOf(".");if(n<=0)return{base:e,extension:null};const t=e.substring(n);return{base:e.substring(0,n),extension:t}},x=e=>{if(!e)return e;const{base:n}=j(e);return n};function E(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const i=t.pop()||"";if(u.LANGUAGES[i])a=!0;else{r=i;const o=t.pop()||"";a=!!u.LANGUAGES[o]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const i=t.pop()||"";a=!!u.LANGUAGES[i]}return{initSlug:r,prefix:a}}const v=e=>e&&x(e),C=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function A({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:i=!1,fullSlug:o}){const[g,p]=d.useState(e),[l,f]=d.useState(null);d.useEffect(()=>{p(e)},[e]);const h=S=>{const c=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(c.match(/\./g)||[]).length,N=m<=1;m>1?f("Invalid slug. Only one dot (.) is allowed in the slug"):f(null),a&&a(N),p(c),n(c)};return s.jsxs("div",{children:[r&&s.jsx("div",{className:"mb-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Parent: ",s.jsx("span",{className:"font-mono text-gray-900",children:v(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(b.Input,{disabled:i,value:g,onChange:h,placeholder:t,className:l?"border-red-500":""}),l&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:l})]}),o&&o!=="undefined"&&s.jsx("div",{className:"mt-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Complete Slug: ",s.jsx("span",{className:"font-mono text-gray-900",children:o})]})})]})}exports.SlugInput=A;exports.combineParentChildSlugs=C;exports.parseSlugForEdit=E;exports.removeSlugExtension=x;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var O=Object.defineProperty;var D=(l,r,e)=>r in l?O(l,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[r]=e;var y=(l,r,e)=>D(l,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./actions-registery-JdxhXhT6.cjs"),f=require("lodash-es"),b=require("sharp"),c=require("zod");class A{constructor(r,e,t){this.appId=r,this.userId=e,this.supabase=t}appendUpdatedAtToUrl(r,e){if(f.isEmpty(r))return"";const t=new URL(r),o=new Date(e).getTime();return t.searchParams.set("t",o.toString()),`${t.origin}${t.pathname}${t.search}${t.hash}`}getBufferFromBase64(r){try{const e=r.split(",")[1]||r;return Buffer.from(e,"base64")}catch{throw new Error("Invalid base64 string format")}}async uploadImageFile(r,e,t,o){try{const s=this.getBufferFromBase64(r),n=await b(s).metadata(),i=["jpeg","jpg","png","webp","gif","svg","tiff"];if(!n.format||!i.includes(n.format.toLowerCase()))throw new Error(`Invalid image format: ${n.format||"unknown"}`);const u=o?await b(s).webp({quality:100}).resize({width:Math.min(n.width||2e3,2e3)}).toBuffer():await b(s).webp({quality:100}).toBuffer();let a=u;if(o&&u.length>120*1024){const _=Math.floor(90*(122880/u.length));a=await b(s).webp({quality:_}).resize({width:Math.min(n.width||2e3,2e3)}).toBuffer()}const d=await b(a).metadata(),g=await b(s).webp({quality:70}).resize({width:300}).toBuffer(),p=t.split("."),m=p.length>1?p.slice(0,-1).join("."):t,w=`${f.kebabCase(m)}.webp`,z=`${w}_thumbnail.webp`,T=this.appId,I=e?`${T}/${e}`:T,S=h.getChaiAction("UPLOAD_TO_STORAGE");if(!S)throw new Error("UPLOAD_TO_STORAGE action not found");S.setContext({appId:this.appId,userId:this.userId});const U=await S.execute({file:a.toString("base64"),fileName:w,contentType:"image/webp",folder:I});if(U.error)throw new Error(U.error);const E=await S.execute({file:g.toString("base64"),fileName:z,contentType:"image/webp",folder:I});if(E.error)throw new Error(E.error);return{url:U.data.url,thumbnailUrl:E.data.url,size:d.size||a.length,width:d.width||0,height:d.height||0,mimeType:"image/webp"}}catch(s){return console.error("Upload image error:",s),{error:s instanceof Error?s.message:"Unknown error"}}}async uploadSvgFile(r,e,t){try{const o=this.getBufferFromBase64(r);let s,n;try{const w=await b(o).metadata();s=w.width,n=w.height}catch{}const i=t.split("."),u=i.length>1?i.slice(0,-1).join("."):t,a=`${f.kebabCase(u)}.svg`,d=this.appId,g=e?`${d}/${e}`:d,p=h.getChaiAction("UPLOAD_TO_STORAGE");if(!p)throw new Error("UPLOAD_TO_STORAGE action not found");p.setContext({appId:this.appId,userId:this.userId});const m=await p.execute({file:o.toString("base64"),fileName:a,contentType:"image/svg+xml",folder:g});if(m.error)throw new Error(m.error);return{url:m.data.url,thumbnailUrl:m.data.url,size:o.length,width:s,height:n,mimeType:"image/svg+xml"}}catch(o){return console.error("SVG upload error:",o),{error:o instanceof Error?o.message:"Unknown error"}}}async upload({file:r,folderId:e,name:t,optimize:o=!0}){var s;try{const i=t.toLowerCase().endsWith(".svg")||r.includes("data:image/svg+xml")?await this.uploadSvgFile(r,e,t):await this.uploadImageFile(r,e,t,o??!0);if("error"in i)return i;const u={name:t,app:this.appId,url:i.url,thumbnailUrl:i.thumbnailUrl,size:(s=i.size)==null?void 0:s.toString(),width:i.width,height:i.height,format:i.mimeType.split("/")[1],folderId:e,type:i.mimeType.startsWith("image/")?"image":"file",createdBy:this.userId,updatedAt:new Date().toISOString()},{data:a,error:d}=await this.supabase.from("app_assets").insert(u).select("*").single();if(d)throw new Error(`Failed to store asset in database: ${d.message}`);return{id:a.id,name:a.name,type:a.type,url:this.appendUpdatedAtToUrl(a.url,a.updatedAt),size:a.size,thumbnailUrl:this.appendUpdatedAtToUrl(a.thumbnailUrl||"",a.updatedAt),width:a.width,height:a.height,format:a.format,folderId:a.folderId,createdBy:a.createdBy||"",createdAt:a.createdAt,updatedAt:a.updatedAt}}catch(n){return{error:n instanceof Error?n.message:"Unknown error occurred"}}}async getAsset({id:r}){try{const{data:e,error:t}=await this.supabase.from("app_assets").select("*").eq("id",r).eq("app",this.appId).single();if(t)throw new Error(`Failed to fetch asset: ${t.message}`);return f.set(e,"url",this.appendUpdatedAtToUrl(e.url,e.updatedAt)),f.set(e,"thumbnailUrl",this.appendUpdatedAtToUrl(e.thumbnailUrl||"",e.updatedAt)),e}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async getAssets({search:r="",page:e=1,limit:t=20}={}){try{const o=(e-1)*t;let s=this.supabase.from("app_assets").select("*",{count:"exact"}).eq("app",this.appId).order("updatedAt",{ascending:!1});r&&(s=s.or(`name.ilike.%${r}%,description.ilike.%${r}%`));const{data:n,error:i,count:u}=await s.range(o,o+t-1);if(i)throw new Error(i.message);return{assets:n.map(d=>(f.set(d,"url",this.appendUpdatedAtToUrl(d.url,d.updatedAt)),f.set(d,"thsupabaseumbnailUrl",this.appendUpdatedAtToUrl(d.thumbnailUrl||"",d.updatedAt)),d)),total:u||0,page:e,pageSize:t}}catch(o){throw console.error("Error fetching assets:",o),o}}async deleteAsset({id:r}){try{const{data:e,error:t}=await this.supabase.from("app_assets").select("*").eq("id",r).eq("app",this.appId).single();if(t)throw new Error(`Failed to fetch asset: ${t.message}`);if(e.url)try{const n=new URL(e.url).pathname.split("/"),i=n.indexOf("dam-assets");if(i!==-1){const u=n.slice(i+1).join("/"),a=h.getChaiAction("DELETE_FROM_STORAGE");if(a&&(a.setContext({appId:this.appId,userId:this.userId}),await a.execute({key:u})),e.thumbnailUrl&&e.thumbnailUrl!==e.url){const g=new URL(e.thumbnailUrl).pathname.split("/"),p=g.indexOf("dam-assets");if(p!==-1){const m=g.slice(p+1).join("/");a&&await a.execute({key:m})}}}}catch(s){console.warn("Failed to delete from storage, continuing with database deletion:",s)}const{error:o}=await this.supabase.from("app_assets").delete().eq("id",r);if(o)throw new Error(`Failed to delete asset: ${o.message}`);return{success:!0}}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async updateAsset({id:r,file:e,description:t}){var o,s;try{const{data:n,error:i}=await this.supabase.from("app_assets").select("*").eq("id",r).single();if(i)throw new Error(`Failed to fetch asset: ${i.message}`);const u={};if(t!==void 0&&(u.description=t,u.updatedAt=new Date().toISOString()),e){const p=((o=n.format)==null?void 0:o.toLowerCase())==="svg"||e.includes("data:image/svg+xml")?await this.uploadSvgFile(e,n.folderId,n.name):await this.uploadImageFile(e,n.folderId,n.name,!0);if("error"in p)return p;u.url=p.url,u.thumbnailUrl=p.thumbnailUrl,u.size=(s=p.size)==null?void 0:s.toString(),u.width=p.width,u.height=p.height,u.format=p.mimeType.split("/")[1],u.updatedAt=new Date().toISOString()}const{data:a,error:d}=await this.supabase.from("app_assets").update(u).eq("id",r).select().single();if(d)throw new Error(`Failed to update asset: ${d.message}`);return f.set(a,"url",this.appendUpdatedAtToUrl(a.url,a.updatedAt)),f.set(a,"thumbnailUrl",this.appendUpdatedAtToUrl(a.thumbnailUrl||"",a.updatedAt)),a}catch(n){return{error:n instanceof Error?n.message:"Unknown error occurred"}}}}const C=c.z.object({name:c.z.string(),file:c.z.string(),folderId:c.z.string().optional().nullable(),optimize:c.z.boolean().optional()});class F extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return C}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).upload(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPLOAD_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const B=c.z.object({id:c.z.string()});class v extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return B}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).getAsset(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const $=c.z.object({search:c.z.string().optional(),page:c.z.number().optional(),limit:c.z.number().optional()});class q extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return $}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).getAssets(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSETS error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const G=c.z.object({id:c.z.string()});class j extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return G}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).deleteAsset(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("DELETE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const L=c.z.object({id:c.z.string(),file:c.z.string().optional(),description:c.z.string().optional()});class P extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return L}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).updateAsset(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPDATE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const R=c.z.object({userId:c.z.string()});class M extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return R}async execute(r){var e,t,o,s,n,i;try{const{userId:u}=r,{data:a,error:d}=await this.supabase.auth.admin.getUserById(u);return d?{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}:{data:{id:((e=a.user)==null?void 0:e.id)||"unknown",email:((t=a.user)==null?void 0:t.email)||"unknown@chaibuilder.com",name:((s=(o=a.user)==null?void 0:o.user_metadata)==null?void 0:s.name)||"Unknown",avatar:((i=(n=a.user)==null?void 0:n.user_metadata)==null?void 0:i.avatar)||""},status:200}}catch{return{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}}}}const N=c.z.object({key:c.z.string()});class x extends h.ChaiBaseAction{constructor(e){super();y(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return N}async execute(e){try{const{key:t}=e,{error:o}=await this.supabase.storage.from(this.bucketName).remove([t]);return o?{error:`Failed to delete from Supabase Storage: ${o.message}`,status:500}:{data:{success:!0},status:200}}catch(t){return console.error("DELETE_FROM_STORAGE error:",t),{error:t instanceof Error?t.message:"Unknown error",status:500}}}}const V=c.z.object({file:c.z.string(),fileName:c.z.string(),contentType:c.z.string().optional(),folder:c.z.string().optional(),metadata:c.z.record(c.z.string(),c.z.any()).optional()});class k extends h.ChaiBaseAction{constructor(e){super();y(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return V}async execute(e){try{if(!this.context)return{error:"Context not set",status:400};const{appId:t}=this.context,{file:o,fileName:s,contentType:n,folder:i,metadata:u}=e;let a;if(typeof o=="string"){const w=o.split(",")[1]||o;a=Buffer.from(w,"base64")}else a=o;const d=i?`${i}/${s}`:`${t}/${s}`,{data:g,error:p}=await this.supabase.storage.from(this.bucketName).upload(d,a,{contentType:n||"application/octet-stream",upsert:!0,...u&&{metadata:u}});if(p)return{error:`Failed to upload to Supabase Storage: ${p.message}`,status:500};const{data:{publicUrl:m}}=this.supabase.storage.from(this.bucketName).getPublicUrl(d);return{data:{url:m,key:g.path,size:a.length,metadata:u},status:200}}catch(t){return console.error("UPLOAD_TO_STORAGE error:",t),{error:t instanceof Error?t.message:"Unknown error",status:500}}}}const W=l=>({GET_CHAI_USER:new M(l)}),H=l=>({UPLOAD_ASSET:new F(l),GET_ASSET:new v(l),GET_ASSETS:new q(l),DELETE_ASSET:new j(l),UPDATE_ASSET:new P(l),UPLOAD_TO_STORAGE:new k(l),DELETE_FROM_STORAGE:new x(l)});exports.DeleteFromStorageAction=x;exports.SupabaseAuthActions=W;exports.SupabaseStorageActions=H;exports.UploadToStorageAction=k;
|
|
1
|
+
"use strict";var O=Object.defineProperty;var D=(l,r,e)=>r in l?O(l,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[r]=e;var y=(l,r,e)=>D(l,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./actions-registery-CtQSSexG.cjs"),f=require("lodash-es"),b=require("sharp"),c=require("zod");class A{constructor(r,e,t){this.appId=r,this.userId=e,this.supabase=t}appendUpdatedAtToUrl(r,e){if(f.isEmpty(r))return"";const t=new URL(r),o=new Date(e).getTime();return t.searchParams.set("t",o.toString()),`${t.origin}${t.pathname}${t.search}${t.hash}`}getBufferFromBase64(r){try{const e=r.split(",")[1]||r;return Buffer.from(e,"base64")}catch{throw new Error("Invalid base64 string format")}}async uploadImageFile(r,e,t,o){try{const s=this.getBufferFromBase64(r),n=await b(s).metadata(),i=["jpeg","jpg","png","webp","gif","svg","tiff"];if(!n.format||!i.includes(n.format.toLowerCase()))throw new Error(`Invalid image format: ${n.format||"unknown"}`);const u=o?await b(s).webp({quality:100}).resize({width:Math.min(n.width||2e3,2e3)}).toBuffer():await b(s).webp({quality:100}).toBuffer();let a=u;if(o&&u.length>120*1024){const _=Math.floor(90*(122880/u.length));a=await b(s).webp({quality:_}).resize({width:Math.min(n.width||2e3,2e3)}).toBuffer()}const d=await b(a).metadata(),g=await b(s).webp({quality:70}).resize({width:300}).toBuffer(),p=t.split("."),m=p.length>1?p.slice(0,-1).join("."):t,w=`${f.kebabCase(m)}.webp`,z=`${w}_thumbnail.webp`,T=this.appId,I=e?`${T}/${e}`:T,S=h.getChaiAction("UPLOAD_TO_STORAGE");if(!S)throw new Error("UPLOAD_TO_STORAGE action not found");S.setContext({appId:this.appId,userId:this.userId});const U=await S.execute({file:a.toString("base64"),fileName:w,contentType:"image/webp",folder:I});if(U.error)throw new Error(U.error);const E=await S.execute({file:g.toString("base64"),fileName:z,contentType:"image/webp",folder:I});if(E.error)throw new Error(E.error);return{url:U.data.url,thumbnailUrl:E.data.url,size:d.size||a.length,width:d.width||0,height:d.height||0,mimeType:"image/webp"}}catch(s){return console.error("Upload image error:",s),{error:s instanceof Error?s.message:"Unknown error"}}}async uploadSvgFile(r,e,t){try{const o=this.getBufferFromBase64(r);let s,n;try{const w=await b(o).metadata();s=w.width,n=w.height}catch{}const i=t.split("."),u=i.length>1?i.slice(0,-1).join("."):t,a=`${f.kebabCase(u)}.svg`,d=this.appId,g=e?`${d}/${e}`:d,p=h.getChaiAction("UPLOAD_TO_STORAGE");if(!p)throw new Error("UPLOAD_TO_STORAGE action not found");p.setContext({appId:this.appId,userId:this.userId});const m=await p.execute({file:o.toString("base64"),fileName:a,contentType:"image/svg+xml",folder:g});if(m.error)throw new Error(m.error);return{url:m.data.url,thumbnailUrl:m.data.url,size:o.length,width:s,height:n,mimeType:"image/svg+xml"}}catch(o){return console.error("SVG upload error:",o),{error:o instanceof Error?o.message:"Unknown error"}}}async upload({file:r,folderId:e,name:t,optimize:o=!0}){var s;try{const i=t.toLowerCase().endsWith(".svg")||r.includes("data:image/svg+xml")?await this.uploadSvgFile(r,e,t):await this.uploadImageFile(r,e,t,o??!0);if("error"in i)return i;const u={name:t,app:this.appId,url:i.url,thumbnailUrl:i.thumbnailUrl,size:(s=i.size)==null?void 0:s.toString(),width:i.width,height:i.height,format:i.mimeType.split("/")[1],folderId:e,type:i.mimeType.startsWith("image/")?"image":"file",createdBy:this.userId,updatedAt:new Date().toISOString()},{data:a,error:d}=await this.supabase.from("app_assets").insert(u).select("*").single();if(d)throw new Error(`Failed to store asset in database: ${d.message}`);return{id:a.id,name:a.name,type:a.type,url:this.appendUpdatedAtToUrl(a.url,a.updatedAt),size:a.size,thumbnailUrl:this.appendUpdatedAtToUrl(a.thumbnailUrl||"",a.updatedAt),width:a.width,height:a.height,format:a.format,folderId:a.folderId,createdBy:a.createdBy||"",createdAt:a.createdAt,updatedAt:a.updatedAt}}catch(n){return{error:n instanceof Error?n.message:"Unknown error occurred"}}}async getAsset({id:r}){try{const{data:e,error:t}=await this.supabase.from("app_assets").select("*").eq("id",r).eq("app",this.appId).single();if(t)throw new Error(`Failed to fetch asset: ${t.message}`);return f.set(e,"url",this.appendUpdatedAtToUrl(e.url,e.updatedAt)),f.set(e,"thumbnailUrl",this.appendUpdatedAtToUrl(e.thumbnailUrl||"",e.updatedAt)),e}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async getAssets({search:r="",page:e=1,limit:t=20}={}){try{const o=(e-1)*t;let s=this.supabase.from("app_assets").select("*",{count:"exact"}).eq("app",this.appId).order("updatedAt",{ascending:!1});r&&(s=s.or(`name.ilike.%${r}%,description.ilike.%${r}%`));const{data:n,error:i,count:u}=await s.range(o,o+t-1);if(i)throw new Error(i.message);return{assets:n.map(d=>(f.set(d,"url",this.appendUpdatedAtToUrl(d.url,d.updatedAt)),f.set(d,"thsupabaseumbnailUrl",this.appendUpdatedAtToUrl(d.thumbnailUrl||"",d.updatedAt)),d)),total:u||0,page:e,pageSize:t}}catch(o){throw console.error("Error fetching assets:",o),o}}async deleteAsset({id:r}){try{const{data:e,error:t}=await this.supabase.from("app_assets").select("*").eq("id",r).eq("app",this.appId).single();if(t)throw new Error(`Failed to fetch asset: ${t.message}`);if(e.url)try{const n=new URL(e.url).pathname.split("/"),i=n.indexOf("dam-assets");if(i!==-1){const u=n.slice(i+1).join("/"),a=h.getChaiAction("DELETE_FROM_STORAGE");if(a&&(a.setContext({appId:this.appId,userId:this.userId}),await a.execute({key:u})),e.thumbnailUrl&&e.thumbnailUrl!==e.url){const g=new URL(e.thumbnailUrl).pathname.split("/"),p=g.indexOf("dam-assets");if(p!==-1){const m=g.slice(p+1).join("/");a&&await a.execute({key:m})}}}}catch(s){console.warn("Failed to delete from storage, continuing with database deletion:",s)}const{error:o}=await this.supabase.from("app_assets").delete().eq("id",r);if(o)throw new Error(`Failed to delete asset: ${o.message}`);return{success:!0}}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async updateAsset({id:r,file:e,description:t}){var o,s;try{const{data:n,error:i}=await this.supabase.from("app_assets").select("*").eq("id",r).single();if(i)throw new Error(`Failed to fetch asset: ${i.message}`);const u={};if(t!==void 0&&(u.description=t,u.updatedAt=new Date().toISOString()),e){const p=((o=n.format)==null?void 0:o.toLowerCase())==="svg"||e.includes("data:image/svg+xml")?await this.uploadSvgFile(e,n.folderId,n.name):await this.uploadImageFile(e,n.folderId,n.name,!0);if("error"in p)return p;u.url=p.url,u.thumbnailUrl=p.thumbnailUrl,u.size=(s=p.size)==null?void 0:s.toString(),u.width=p.width,u.height=p.height,u.format=p.mimeType.split("/")[1],u.updatedAt=new Date().toISOString()}const{data:a,error:d}=await this.supabase.from("app_assets").update(u).eq("id",r).select().single();if(d)throw new Error(`Failed to update asset: ${d.message}`);return f.set(a,"url",this.appendUpdatedAtToUrl(a.url,a.updatedAt)),f.set(a,"thumbnailUrl",this.appendUpdatedAtToUrl(a.thumbnailUrl||"",a.updatedAt)),a}catch(n){return{error:n instanceof Error?n.message:"Unknown error occurred"}}}}const C=c.z.object({name:c.z.string(),file:c.z.string(),folderId:c.z.string().optional().nullable(),optimize:c.z.boolean().optional()});class F extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return C}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).upload(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPLOAD_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const B=c.z.object({id:c.z.string()});class v extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return B}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).getAsset(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const $=c.z.object({search:c.z.string().optional(),page:c.z.number().optional(),limit:c.z.number().optional()});class q extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return $}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).getAssets(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSETS error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const G=c.z.object({id:c.z.string()});class j extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return G}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).deleteAsset(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("DELETE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const L=c.z.object({id:c.z.string(),file:c.z.string().optional(),description:c.z.string().optional()});class P extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return L}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).updateAsset(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPDATE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const R=c.z.object({userId:c.z.string()});class M extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return R}async execute(r){var e,t,o,s,n,i;try{const{userId:u}=r,{data:a,error:d}=await this.supabase.auth.admin.getUserById(u);return d?{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}:{data:{id:((e=a.user)==null?void 0:e.id)||"unknown",email:((t=a.user)==null?void 0:t.email)||"unknown@chaibuilder.com",name:((s=(o=a.user)==null?void 0:o.user_metadata)==null?void 0:s.name)||"Unknown",avatar:((i=(n=a.user)==null?void 0:n.user_metadata)==null?void 0:i.avatar)||""},status:200}}catch{return{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}}}}const N=c.z.object({key:c.z.string()});class x extends h.ChaiBaseAction{constructor(e){super();y(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return N}async execute(e){try{const{key:t}=e,{error:o}=await this.supabase.storage.from(this.bucketName).remove([t]);return o?{error:`Failed to delete from Supabase Storage: ${o.message}`,status:500}:{data:{success:!0},status:200}}catch(t){return console.error("DELETE_FROM_STORAGE error:",t),{error:t instanceof Error?t.message:"Unknown error",status:500}}}}const V=c.z.object({file:c.z.string(),fileName:c.z.string(),contentType:c.z.string().optional(),folder:c.z.string().optional(),metadata:c.z.record(c.z.string(),c.z.any()).optional()});class k extends h.ChaiBaseAction{constructor(e){super();y(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return V}async execute(e){try{if(!this.context)return{error:"Context not set",status:400};const{appId:t}=this.context,{file:o,fileName:s,contentType:n,folder:i,metadata:u}=e;let a;if(typeof o=="string"){const w=o.split(",")[1]||o;a=Buffer.from(w,"base64")}else a=o;const d=i?`${i}/${s}`:`${t}/${s}`,{data:g,error:p}=await this.supabase.storage.from(this.bucketName).upload(d,a,{contentType:n||"application/octet-stream",upsert:!0,...u&&{metadata:u}});if(p)return{error:`Failed to upload to Supabase Storage: ${p.message}`,status:500};const{data:{publicUrl:m}}=this.supabase.storage.from(this.bucketName).getPublicUrl(d);return{data:{url:m,key:g.path,size:a.length,metadata:u},status:200}}catch(t){return console.error("UPLOAD_TO_STORAGE error:",t),{error:t instanceof Error?t.message:"Unknown error",status:500}}}}const W=l=>({GET_CHAI_USER:new M(l)}),H=l=>({UPLOAD_ASSET:new F(l),GET_ASSET:new v(l),GET_ASSETS:new q(l),DELETE_ASSET:new j(l),UPDATE_ASSET:new P(l),UPLOAD_TO_STORAGE:new k(l),DELETE_FROM_STORAGE:new x(l)});exports.DeleteFromStorageAction=x;exports.SupabaseAuthActions=W;exports.SupabaseStorageActions=H;exports.UploadToStorageAction=k;
|
|
@@ -54,6 +54,11 @@ declare abstract class ChaiBaseAction<T = any, K = any> implements ChaiAction<T,
|
|
|
54
54
|
* Each action must implement this to define its own business logic
|
|
55
55
|
*/
|
|
56
56
|
abstract execute(data: T): Promise<any>;
|
|
57
|
+
/**
|
|
58
|
+
* Verify if the user has access to the app
|
|
59
|
+
* @throws ActionError if the user does not have access
|
|
60
|
+
*/
|
|
61
|
+
protected verifyAccess(): Promise<void>;
|
|
57
62
|
/**
|
|
58
63
|
* Helper method to handle common errors in actions
|
|
59
64
|
* @param error The error to handle
|
package/dist/supabase-actions.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var D = Object.defineProperty;
|
|
2
2
|
var F = (l, r, e) => r in l ? D(l, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[r] = e;
|
|
3
3
|
var y = (l, r, e) => F(l, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
-
import { g as T, C as f } from "./actions-registery-
|
|
4
|
+
import { g as T, C as f } from "./actions-registery-DqrFhSMp.js";
|
|
5
5
|
import { isEmpty as $, kebabCase as k, set as b } from "lodash-es";
|
|
6
6
|
import w from "sharp";
|
|
7
7
|
import { z as c } from "zod";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as a, jsxs as t } from "react/jsx-runtime";
|
|
2
2
|
import { B as m } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
3
|
-
import { Q as N, R as C, U as b, V as v, W as E, X as T } from "./index-
|
|
4
|
-
import { ao as w, b as I, a as k, ap as y, B as R, E as d, P as u } from "./index-
|
|
3
|
+
import { Q as N, R as C, U as b, V as v, W as E, X as T } from "./index-RYr8kQdI.js";
|
|
4
|
+
import { ao as w, b as I, a as k, ap as y, B as R, E as d, P as u } from "./index-B7eWP_hB.js";
|
|
5
5
|
import { AlertCircle as S, UserIcon as A, Check as P, X as U } from "lucide-react";
|
|
6
6
|
import { useState as _ } from "react";
|
|
7
7
|
import { useTranslation as q } from "react-i18next";
|
|
@@ -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"),r=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"),r=require("./index-xYnNKovy.cjs"),t=require("./index-BwH1mRm_.cjs"),l=require("lucide-react"),f=require("react"),j=require("react-i18next"),T=()=>{const i=t.useSendRealtimeEvent(),{pageLockMeta:n}=t.usePageLockMeta(),{setPageStatus:d}=t.usePageLockStatus(),{savePageAsync:x}=r.useSavePage(),h=n==null?void 0:n.requestingUserId,{data:s,isFetching:g}=t.useChaiUserInfo(h||""),o=g?"Fetching user...":(s==null?void 0:s.name)||"Current editor",[u,c]=f.useState(!1),N=async()=>{c(!0),await x(),i(t.EVENT.CONTINUE_EDITING_IN_THIS_CLIENT,n),d(t.PAGE_STATUS.CHECKING),setTimeout(()=>c(!1),2e3)},p=()=>{c(!0),i(t.EVENT.TAKE_OVER_REJECTED,n),d(t.PAGE_STATUS.EDITING),setTimeout(()=>c(!1),2e3)},{t:a}=j.useTranslation();return e.jsx(t.BlurContainer,{children:e.jsxs(r.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(r.CardHeader,{className:"space-y-1",children:e.jsxs(r.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(l.AlertCircle,{className:"h-8 w-8 rounded-md bg-amber-500/20 p-1.5 text-amber-500"}),a("Take Over Requested")]})}),e.jsxs(r.CardContent,{className:"space-y-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:"Requested by"}),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(l.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:o}),(s==null?void 0:s.email)&&e.jsx("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:s.email})]})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-gray-700",children:o})," ",a("has requested to")," ",e.jsx("span",{className:"font-medium text-gray-500",children:"take over"})," ",a("editing this page."),"."," ",a("Do you want to allow them to continue?")]})]}),e.jsxs(r.CardFooter,{className:"flex gap-2",children:[e.jsxs(m.Button,{disabled:u,variant:"default",onClick:N,className:"flex-1 gap-2",children:[e.jsx(l.Check,{className:"h-4 w-4"}),a("Accept")]}),e.jsxs(m.Button,{disabled:u,variant:"outline",onClick:p,className:"flex-1 gap-2",children:[e.jsx(l.X,{className:"h-4 w-4"}),a("Reject")]})]})]})})};exports.default=T;
|
|
@@ -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"),d=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"),d=require("./index-xYnNKovy.cjs"),t=require("./index-BwH1mRm_.cjs"),h=require("react-i18next"),g=()=>{const[s]=d.useTheme(),{mutate:c,isPending:i}=t.usePublishPages(),{mutateAsync:n,isPending:r}=t.useUpdateWebsiteSettings(),{t:a}=h.useTranslation(),u=()=>{n({settings:{theme:s}})},l=async()=>{await n({settings:{theme:s}}),c({ids:["THEME"]},{onSuccess:()=>{t.throwConfetti("BOTTOM_RIGHT")}})};return e.jsxs("div",{className:"flex items-center justify-center gap-x-3 border-t bg-white py-3",children:[e.jsx(o.Button,{size:"sm",variant:"outline",disabled:i||r,onClick:u,children:a("Save draft")}),e.jsx(o.Button,{size:"sm",disabled:i||r,onClick:l,children:a("Publish")})]})};exports.default=g;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as c, jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import { B as o } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
3
|
-
import { h } from "./index-
|
|
4
|
-
import { e as d, f as u, t as f } from "./index-
|
|
3
|
+
import { h } from "./index-RYr8kQdI.js";
|
|
4
|
+
import { e as d, f as u, t as f } from "./index-B7eWP_hB.js";
|
|
5
5
|
import { useTranslation as p } from "react-i18next";
|
|
6
6
|
const v = () => {
|
|
7
7
|
const [e] = h(), { mutate: r, isPending: s } = d(), { mutateAsync: t, isPending: i } = u(), { t: n } = p(), m = () => {
|
package/dist/{translation-warning-modal-BfM4HGck.cjs → translation-warning-modal-DEt_ExQp.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("./register-chai-top-bar-BqwKw4uy.cjs"),n=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("./register-chai-top-bar-BqwKw4uy.cjs"),n=require("./index-xYnNKovy.cjs"),u=({isOpen:o,onClose:i,onContinue:t,isPending:a=!1,title:r="Translation Warning",description:s="Some blocks need translations before publishing. Do you want to continue anyway?"})=>{const c=()=>{i()},d=()=>{t()};return e.jsx(n.Dialog,{open:o,onOpenChange:i,children:o&&e.jsxs(n.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(n.DialogHeader,{children:[e.jsx(n.DialogTitle,{children:r}),e.jsx(n.DialogDescription,{children:s})]}),e.jsxs(n.DialogFooter,{className:"flex gap-2",children:[e.jsx(l.Button,{variant:"outline",onClick:c,disabled:a,children:"Cancel"}),e.jsx(l.Button,{onClick:d,disabled:a,children:a?"Publishing...":"Continue Anyway"})]})]})})};exports.default=u;
|
package/dist/{translation-warning-modal-Jadkcver.js → translation-warning-modal-_aBp5ZZQ.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as n, jsxs as e } from "react/jsx-runtime";
|
|
2
2
|
import { B as i } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
3
|
-
import { D as c, d, e as h, f as m, p as u, q as g } from "./index-
|
|
3
|
+
import { D as c, d, e as h, f as m, p as u, q as g } from "./index-RYr8kQdI.js";
|
|
4
4
|
const x = ({
|
|
5
5
|
isOpen: l,
|
|
6
6
|
onClose: o,
|
|
@@ -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"),p=require("./index-BwH1mRm_.cjs"),d=require("react"),m=require("react-i18next"),g=({page:i,onClose:n})=>{const{t:a}=m.useTranslation(),[r,s]=d.useState(!1),l=p.useUnmarkAsTemplate(),c=()=>{s(!0),l.mutate(i,{onSuccess:()=>{s(!1),n()},onError:()=>{s(!1)}})};return e.jsx(t.Dialog,{open:!0,onOpenChange:n,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:a("Unmark as template")}),e.jsx(t.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:a("Are you sure you want to unmark this page as a template?")})]}),e.jsxs(t.DialogFooter,{className:r?"pointer-events-none opacity-75":"",children:[e.jsx(o.Button,{variant:"outline",onClick:u=>{u.stopPropagation(),n()},children:a("Cancel")}),e.jsx(o.Button,{variant:"default",disabled:r,onClick:c,children:a("Unmark as template")})]})]})})};exports.default=g;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
2
2
|
import { B as r } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
3
|
-
import { D as p, d as u, e as d, f, p as g, q as h } from "./index-
|
|
4
|
-
import { r as k } from "./index-
|
|
3
|
+
import { D as p, d as u, e as d, f, p as g, q as h } from "./index-RYr8kQdI.js";
|
|
4
|
+
import { r as k } from "./index-B7eWP_hB.js";
|
|
5
5
|
import { useState as D } from "react";
|
|
6
6
|
import { useTranslation as x } from "react-i18next";
|
|
7
7
|
const j = ({ page: i, onClose: t }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("./register-chai-top-bar-BqwKw4uy.cjs"),e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("./register-chai-top-bar-BqwKw4uy.cjs"),e=require("./index-xYnNKovy.cjs"),c=require("./index-BwH1mRm_.cjs"),a=require("react-i18next"),d=({page:i,onClose:t})=>{const{t:s}=a.useTranslation(),{mutate:l,isPending:r}=c.useUnpublishPage(),u=async()=>{l(i,{onSuccess:t})};return n.jsx(e.Dialog,{open:!!i,onOpenChange:t,children:n.jsxs(e.DialogContent,{children:[n.jsxs(e.DialogHeader,{children:[n.jsx(e.DialogTitle,{children:s("Confirm action")}),n.jsxs(e.DialogDescription,{children:[s("Are you sure you want to unpublish")," ",n.jsx("b",{children:(i==null?void 0:i.name)??(i==null?void 0:i.slug)}),"?"]})]}),n.jsxs(e.DialogFooter,{children:[n.jsx(o.Button,{variant:"outline",onClick:t,children:s("Cancel")}),n.jsx(o.Button,{variant:"destructive",disabled:r,onClick:u,children:s(r?"Updating...":"Unpublish")})]})]})})};exports.default=d;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as s, jsxs as o } from "react/jsx-runtime";
|
|
2
2
|
import { B as l } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
3
|
-
import { D as c, d as u, e as d, f as h, p as m, q as b } from "./index-
|
|
4
|
-
import { s as f } from "./index-
|
|
3
|
+
import { D as c, d as u, e as d, f as h, p as m, q as b } from "./index-RYr8kQdI.js";
|
|
4
|
+
import { s as f } from "./index-B7eWP_hB.js";
|
|
5
5
|
import { useTranslation as D } from "react-i18next";
|
|
6
6
|
const v = ({ page: n, onClose: r }) => {
|
|
7
7
|
const { t: i } = D(), { mutate: e, isPending: t } = f(), a = async () => {
|
|
@@ -4,7 +4,7 @@ import { B as s } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
|
4
4
|
import { useAtom as h } from "jotai";
|
|
5
5
|
import { map as p } from "lodash-es";
|
|
6
6
|
import { Smartphone as w, Tablet as f, Laptop as u, LaptopMinimal as x } from "lucide-react";
|
|
7
|
-
import { p as v, T as _ } from "./index-
|
|
7
|
+
import { p as v, T as _ } from "./index-B7eWP_hB.js";
|
|
8
8
|
const b = [
|
|
9
9
|
{
|
|
10
10
|
title: "mobile_xs_title",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),a=require("./register-chai-top-bar-BqwKw4uy.cjs"),u=require("jotai"),x=require("lodash-es"),n=require("lucide-react"),c=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),a=require("./register-chai-top-bar-BqwKw4uy.cjs"),u=require("jotai"),x=require("lodash-es"),n=require("lucide-react"),c=require("./index-BwH1mRm_.cjs"),m=[{title:"mobile_xs_title",content:"mobile_xs_content",icon:e.jsx(n.Smartphone,{className:"h-4 w-4"}),width:400},{title:"tablet_md_title",content:"tablet_md_content",icon:e.jsx(n.Tablet,{className:"h-4 w-4"}),width:800},{title:"desktop_xl_title",content:"desktop_xl_content",icon:e.jsx(n.Laptop,{className:"h-4 w-4"}),width:1200},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",icon:e.jsx(n.LaptopMinimal,{className:"h-4 w-4"}),width:1600}],w=({currentWidth:t,width:s,icon:o,setIframeWidth:r})=>e.jsx(a.Button,{className:"px-3 py-3",onClick:()=>r(s),variant:s===t?"default":"ghost",children:o}),p=()=>{const[t,s]=l.useState(1200),o=i=>s(i),[r,d]=u.useAtom(c.previewUrlAtom);if(!r)return null;const h=()=>{d("")};return e.jsxs("div",{className:"absolute inset-0 z-[999999] flex h-screen w-screen flex-col overflow-hidden bg-gray-100",children:[e.jsxs("div",{className:"flex h-[50px] items-center justify-center border-b border-gray-200 px-4 shadow-sm",children:[e.jsx("div",{className:"flex items-center justify-center rounded-md border border-gray-300",children:x.map(m,i=>l.createElement(w,{...i,setIframeWidth:o,key:i.title,currentWidth:t}))})," ",e.jsx(c.Tooltip,{content:"Exit Preview",delayDuration:0,children:e.jsx(a.Button,{variant:"destructive",size:"sm",onClick:h,children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M2 3C2 2.44772 2.44772 2 3 2H12C12.5523 2 13 2.44772 13 3V12C13 12.5523 12.5523 13 12 13H3C2.44772 13 2 12.5523 2 12V3ZM12 3H3V12H12V3Z",fill:"currentColor",fillRule:"evenodd","clip-rule":"evenodd"})})})})]}),e.jsx("iframe",{style:{width:`${t}px`,transition:"width 0.3s ease-in-out"},className:"no-scrollbar mx-auto h-full overflow-y-auto border bg-white",src:r})]})};exports.default=p;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"author": "Suraj Air",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"homepage": "https://chaibuilder.com",
|
|
8
|
-
"version": "4.0.0-beta.
|
|
8
|
+
"version": "4.0.0-beta.7",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -16,25 +16,6 @@
|
|
|
16
16
|
],
|
|
17
17
|
"main": "dist/core.js",
|
|
18
18
|
"sideEffects": false,
|
|
19
|
-
"scripts": {
|
|
20
|
-
"dev": "vite",
|
|
21
|
-
"build": "tsc && vite build",
|
|
22
|
-
"live": "tsc && vite build --config vite.config.live.ts",
|
|
23
|
-
"live:serve": "cd live && npx http-server -p 8080",
|
|
24
|
-
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
25
|
-
"lint:errors": "eslint . --ext ts,tsx --quiet --max-warnings 0",
|
|
26
|
-
"lint:warnings": "eslint . --ext ts,tsx --min-warnings 1",
|
|
27
|
-
"preview": "vite preview",
|
|
28
|
-
"test": "vitest --run",
|
|
29
|
-
"test:watch": "vitest --watch",
|
|
30
|
-
"test:coverage": "vitest --coverage",
|
|
31
|
-
"e2e": "playwright test",
|
|
32
|
-
"e2e:report": "playwright show-report",
|
|
33
|
-
"e2e:ui": "playwright test --ui",
|
|
34
|
-
"docs:api": "typedoc",
|
|
35
|
-
"docs:serve": "docsify serve docs",
|
|
36
|
-
"prepare": "husky"
|
|
37
|
-
},
|
|
38
19
|
"exports": {
|
|
39
20
|
".": {
|
|
40
21
|
"types": "./dist/core.d.ts",
|
|
@@ -82,12 +63,11 @@
|
|
|
82
63
|
}
|
|
83
64
|
},
|
|
84
65
|
"peerDependencies": {
|
|
85
|
-
"@supabase/supabase-js": "^2.
|
|
66
|
+
"@supabase/supabase-js": "^2.90.1",
|
|
86
67
|
"@types/react": "*",
|
|
87
68
|
"@types/react-dom": "*",
|
|
88
69
|
"ai": "^6.0.11",
|
|
89
70
|
"drizzle-orm": "^0.45.1",
|
|
90
|
-
"next": "16.1.1",
|
|
91
71
|
"postgres": "^3.4.8",
|
|
92
72
|
"react": "^18.0 || ^19.0 || ^19.1 || ^19.2",
|
|
93
73
|
"react-dom": "^18.0 || ^19.0 || ^19.1 || ^19.2",
|
|
@@ -221,7 +201,7 @@
|
|
|
221
201
|
"@faker-js/faker": "^9.9.0",
|
|
222
202
|
"@microsoft/clarity": "^1.0.2",
|
|
223
203
|
"@playwright/test": "^1.57.0",
|
|
224
|
-
"@supabase/supabase-js": "^2.
|
|
204
|
+
"@supabase/supabase-js": "^2.90.1",
|
|
225
205
|
"@tanstack/eslint-plugin-query": "^5.91.2",
|
|
226
206
|
"@tanstack/react-query-devtools": "^5.91.2",
|
|
227
207
|
"@testing-library/react": "^16.3.1",
|
|
@@ -282,5 +262,23 @@
|
|
|
282
262
|
},
|
|
283
263
|
"engines": {
|
|
284
264
|
"node": ">=21.0.0"
|
|
265
|
+
},
|
|
266
|
+
"scripts": {
|
|
267
|
+
"dev": "vite",
|
|
268
|
+
"build": "tsc && vite build",
|
|
269
|
+
"live": "tsc && vite build --config vite.config.live.ts",
|
|
270
|
+
"live:serve": "cd live && npx http-server -p 8080",
|
|
271
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
272
|
+
"lint:errors": "eslint . --ext ts,tsx --quiet --max-warnings 0",
|
|
273
|
+
"lint:warnings": "eslint . --ext ts,tsx --min-warnings 1",
|
|
274
|
+
"preview": "vite preview",
|
|
275
|
+
"test": "vitest --run",
|
|
276
|
+
"test:watch": "vitest --watch",
|
|
277
|
+
"test:coverage": "vitest --coverage",
|
|
278
|
+
"e2e": "playwright test",
|
|
279
|
+
"e2e:report": "playwright show-report",
|
|
280
|
+
"e2e:ui": "playwright test --ui",
|
|
281
|
+
"docs:api": "typedoc",
|
|
282
|
+
"docs:serve": "docsify serve docs"
|
|
285
283
|
}
|
|
286
|
-
}
|
|
284
|
+
}
|