@chaibuilder/pages 0.15.1 → 0.15.3
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-a-BJOrVj.js → 2AITGKQY-DhC0sF1x.js} +2 -2
- package/dist/{2AITGKQY-GcbF_G3s.cjs → 2AITGKQY-o6FgGSqg.cjs} +1 -1
- package/dist/{NCMVHL6D-fz7uxKMS.cjs → NCMVHL6D-BPM6RHYa.cjs} +1 -1
- package/dist/{NCMVHL6D-CCFQEIik.js → NCMVHL6D-D7HU3akD.js} +2 -2
- package/dist/{ZDWCUMSJ-B87y4E-s.js → ZDWCUMSJ-Cr1v3giV.js} +1 -1
- package/dist/{ZDWCUMSJ-D40Aht5l.cjs → ZDWCUMSJ-NVCxv9uE.cjs} +1 -1
- package/dist/{add-new-language-page-CxNpkd0L.js → add-new-language-page-8q4Ku3eg.js} +2 -2
- package/dist/{add-new-language-page-Dyh26P7i.cjs → add-new-language-page-D3PSLiUv.cjs} +1 -1
- package/dist/{add-new-page-DGQqN1GO.js → add-new-page-BpvpSM4X.js} +1 -1
- package/dist/{add-new-page-jWn3_pZ4.cjs → add-new-page-YpzILOYq.cjs} +1 -1
- package/dist/{delete-page-WnsCggnJ.js → delete-page-CXRJjJ4o.js} +1 -1
- package/dist/{delete-page-Bxl1t_Ue.cjs → delete-page-w64MO7db.cjs} +1 -1
- package/dist/digital-asset-manager-B2m5T22s.js +1001 -0
- package/dist/digital-asset-manager-BGyKKd_6.cjs +1 -0
- package/dist/{duplicate-page-DOloolXy.js → duplicate-page-CSQs2MOp.js} +2 -2
- package/dist/{duplicate-page-CDtfdgyJ.cjs → duplicate-page-DB_c7V2t.cjs} +1 -1
- package/dist/{dynamic-page-selector-CcYIfKlO.cjs → dynamic-page-selector-CF9nb6i_.cjs} +1 -1
- package/dist/{dynamic-page-selector-B-8TUdTG.js → dynamic-page-selector-DTk4oull.js} +1 -1
- package/dist/image-editor-D9MPdtxC.js +107 -0
- package/dist/image-editor-Da6lrqkL.cjs +1 -0
- package/dist/{index-CguzNa4U.js → index-BuXZJnGo.js} +15 -15
- package/dist/{index-CffopOpP.cjs → index-Cds1vIhw.cjs} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{json-diff-viewer-CxFGgqa_.js → json-diff-viewer-oyxMD3Hc.js} +1 -1
- package/dist/{json-diff-viewer-DcR1gbkd.cjs → json-diff-viewer-zBoPBSd3.cjs} +1 -1
- package/dist/{lang-panel-Bi427DLp.js → lang-panel-B_HcsPPo.js} +2 -2
- package/dist/{lang-panel-XonHaLBn.cjs → lang-panel-D2YUMeJZ.cjs} +1 -1
- package/dist/{mark-as-template-BtI1QfuI.cjs → mark-as-template-C4wH4UKf.cjs} +1 -1
- package/dist/{mark-as-template-CS68JVP8.js → mark-as-template-CPEPYXg7.js} +1 -1
- package/dist/{no-language-page-content-C5t9cDI4.js → no-language-page-content-CVyOpT9h.js} +1 -1
- package/dist/{no-language-page-content-DMqw1cTK.cjs → no-language-page-content-ECt0SxFX.cjs} +1 -1
- package/dist/{page-creator-BkKT_Xy1.cjs → page-creator-BG2hc82u.cjs} +1 -1
- package/dist/{page-creator-BY2w99Ez.js → page-creator-y6kl3nw5.js} +2 -2
- package/dist/{page-lock-request-Z1sTGi6N.js → page-lock-request-DC62b588.js} +1 -1
- package/dist/{page-lock-request-CIRTswpw.cjs → page-lock-request-fGZbOFTp.cjs} +1 -1
- package/dist/{page-locked-by-dialog-DpBpQ0oI.cjs → page-locked-by-dialog-BIC-c0Jl.cjs} +1 -1
- package/dist/{page-locked-by-dialog-B2C1M_bK.js → page-locked-by-dialog-D-vXaoga.js} +1 -1
- package/dist/{page-manager-new-tWV46glN.cjs → page-manager-new-CUfjlMed.cjs} +1 -1
- package/dist/{page-manager-new-CSqFLJBd.js → page-manager-new-Cto2r7Va.js} +2 -2
- package/dist/{page-manager-search-and-filter-B9VZzJQd.js → page-manager-search-and-filter-sVnGlF46.js} +1 -1
- package/dist/{page-manager-search-and-filter-CwuukvKn.cjs → page-manager-search-and-filter-z2b4sgvb.cjs} +1 -1
- package/dist/{page-revisions-content-WoIu0uan.js → page-revisions-content-BaTqBnko.js} +2 -2
- package/dist/{page-revisions-content-BWhJz0_7.cjs → page-revisions-content-Tb3T6zvU.cjs} +1 -1
- package/dist/{publish-pages-content-BHDTLdGv.cjs → publish-pages-content-BGkEZ3GK.cjs} +1 -1
- package/dist/{publish-pages-content-CkWvQGbm.js → publish-pages-content-C9CgEWo0.js} +2 -2
- package/dist/{save-to-lib-AkbnWUxR.js → save-to-lib-DGtyTG6H.js} +1 -1
- package/dist/{save-to-lib-C0ZfwiAE.cjs → save-to-lib-DNK4GPNw.cjs} +1 -1
- package/dist/{seo-panel-CiKkn5Jp.cjs → seo-panel-CrK7z4bR.cjs} +1 -1
- package/dist/{seo-panel-Gu3HZveQ.js → seo-panel-DESVAQM5.js} +1 -1
- package/dist/shared-json-ld-BMfQzOWc.js +650 -0
- package/dist/shared-json-ld-_ozYsSHn.cjs +1 -0
- package/dist/{slug-input-B4w0Ihxn.cjs → slug-input-DMYhARDW.cjs} +1 -1
- package/dist/{slug-input-BXNj3cZf.js → slug-input-DfAsMPg8.js} +1 -1
- package/dist/{theme-panel-footer-DnZs9SzB.cjs → theme-panel-footer-Bj2yHtxO.cjs} +1 -1
- package/dist/{theme-panel-footer-68bQaQeh.js → theme-panel-footer-RrxiDGoD.js} +1 -1
- package/dist/{unmark-as-template-MpXMyb0Q.js → unmark-as-template-BjetSrYF.js} +1 -1
- package/dist/{unmark-as-template-DFxmzyx4.cjs → unmark-as-template-C8hTjRVk.cjs} +1 -1
- package/dist/{unpublish-page-Bzouoco9.js → unpublish-page-BTPEVAkv.js} +1 -1
- package/dist/{unpublish-page-CCPyMoaC.cjs → unpublish-page-gtGfNOAq.cjs} +1 -1
- package/dist/{web-preview-B3-o8BoT.cjs → web-preview-BcULgiw_.cjs} +1 -1
- package/dist/{web-preview-D9PcexXy.js → web-preview-DNgPjdgZ.js} +1 -1
- package/package.json +1 -1
- package/dist/digital-asset-manager-ClyooOJY.js +0 -976
- package/dist/digital-asset-manager-DrXotZ_n.cjs +0 -1
- package/dist/image-editor-BWLJT1mr.cjs +0 -1
- package/dist/image-editor-CzFST20j.js +0 -104
- package/dist/shared-json-ld-BPaeG1gf.cjs +0 -1
- package/dist/shared-json-ld-CsyZjZdT.js +0 -557
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),J=require("@chaibuilder/sdk"),l=require("@chaibuilder/sdk/ui"),D=require("lodash-es"),p=require("lucide-react"),u=require("react"),fe=require("react-dropzone"),A=require("sonner"),Y=require("./image-compression-DZ9WMmyn.cjs"),k=require("@tanstack/react-query"),v=require("./index-Cds1vIhw.cjs"),pe=u.createContext(null),Q={didCatch:!1,error:null};class ge extends u.Component{constructor(r){super(r),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Q}static getDerivedStateFromError(r){return{didCatch:!0,error:r}}resetErrorBoundary(){const{error:r}=this.state;if(r!==null){for(var o,t,d=arguments.length,i=new Array(d),m=0;m<d;m++)i[m]=arguments[m];(o=(t=this.props).onReset)===null||o===void 0||o.call(t,{args:i,reason:"imperative-api"}),this.setState(Q)}}componentDidCatch(r,o){var t,d;(t=(d=this.props).onError)===null||t===void 0||t.call(d,r,o)}componentDidUpdate(r,o){const{didCatch:t}=this.state,{resetKeys:d}=this.props;if(t&&o.error!==null&&je(r.resetKeys,d)){var i,m;(i=(m=this.props).onReset)===null||i===void 0||i.call(m,{next:d,prev:r.resetKeys,reason:"keys"}),this.setState(Q)}}render(){const{children:r,fallbackRender:o,FallbackComponent:t,fallback:d}=this.props,{didCatch:i,error:m}=this.state;let y=r;if(i){const N={error:m,resetErrorBoundary:this.resetErrorBoundary};if(typeof o=="function")y=o(N);else if(t)y=u.createElement(t,N);else if(d!==void 0)y=d;else throw m}return u.createElement(pe.Provider,{value:{didCatch:i,error:m,resetErrorBoundary:this.resetErrorBoundary}},y)}}function je(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return a.length!==r.length||a.some((o,t)=>!Object.is(o,r[t]))}const ve=()=>{const a=v.useAssetsApiUrl(),r=k.useQueryClient(),o=v.useFetch();return k.useMutation({mutationFn:async t=>{const d=t.map(async m=>o(a,{action:v.ACTIONS.UPLOAD_ASSET,data:m}));return await Promise.all(d)},onSuccess:t=>{var d;if(t!=null&&t.some(i=>i.error))throw new Error(((d=t==null?void 0:t.find(i=>i.error))==null?void 0:d.error)||"Failed to upload asset");{r.invalidateQueries({queryKey:[v.ACTIONS.GET_ASSETS]});const i=t==null?void 0:t.length;A.toast.success(`${i===1?"Asset":i+" Assets"} uploaded successfully`)}},onError:()=>{A.toast.error("Failed to upload asset")}})},ye=()=>{const a=v.useAssetsApiUrl(),r=k.useQueryClient(),o=v.useFetch();return k.useMutation({mutationFn:async t=>o(a,{action:v.ACTIONS.DELETE_ASSET,data:{id:t}}),onSuccess:t=>{if(t!=null&&t.error)throw new Error(t==null?void 0:t.error);r.invalidateQueries({queryKey:[v.ACTIONS.GET_ASSETS]}),A.toast.success("Asset deleted successfully")},onError:()=>{A.toast.error("Failed to delete asset")}})},Ne=()=>{const a=v.useAssetsApiUrl(),r=k.useQueryClient(),o=v.useFetch();return k.useMutation({mutationFn:async t=>o(a,{action:v.ACTIONS.UPDATE_ASSET,data:t}),onSuccess:t=>{if(t!=null&&t.error)throw new Error(t==null?void 0:t.error);r.invalidateQueries({queryKey:[v.ACTIONS.GET_ASSETS]}),t!=null&&t.id&&r.invalidateQueries({queryKey:[v.ACTIONS.GET_ASSET,t.id]}),A.toast.success("Asset updated successfully")},onError:()=>{A.toast.error("Failed to update asset")}})};function be({currentPage:a,totalPages:r,onPageChange:o,pageRangeDisplayed:t=3,showPageInput:d=!0,className:i=""}){const[m,y]=u.useState(String(a)),N=u.useMemo(()=>{const c=Math.floor(t/2);let n=Math.max(1,a-c),h=Math.min(r,a+c);h-n+1<t&&(n===1?h=Math.min(r,n+t-1):h===r&&(n=Math.max(1,h-t+1)));const j=[];n>1&&(j.push(1),n>2&&j.push("..."));for(let b=n;b<=h;b++)j.push(b);return h<r&&(h<r-1&&j.push("..."),j.push(r)),j},[a,r,t]),g=c=>{c!==a&&c>=1&&c<=r&&(o(c),y(String(c)))},w=()=>{a>1&&g(a-1)},S=()=>{a<r&&g(a+1)},C=()=>{const c=Number(m);!isNaN(c)&&c>=1&&c<=r&&g(c)},f=c=>{c.key==="Enter"&&C()};return r<=1?null:e.jsxs("div",{className:`flex flex-wrap items-center justify-center gap-3 ${i}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(l.Button,{variant:"outline",size:"sm",onClick:w,disabled:a===1,className:"px-2 py-1 text-sm hover:bg-gray-50",children:[e.jsx(p.ChevronLeft,{className:" h-4 w-4"}),"Previous"]}),e.jsx("div",{className:"flex items-center gap-2",children:N.map((c,n)=>{if(c==="...")return e.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${n}`);const h=c,j=h===a;return e.jsx(l.Button,{variant:j?"default":"outline",size:"sm",onClick:()=>g(h),className:j?"border-blue-600 bg-blue-600 px-3 py-1 text-sm text-white":"border px-3 py-1 text-sm hover:bg-gray-50 hover:text-black",children:h},h)})}),e.jsxs(l.Button,{variant:"outline",size:"sm",onClick:S,disabled:a===r,className:"px-2 py-1 text-sm hover:bg-gray-50",children:["Next",e.jsx(p.ChevronRight,{className:" h-4 w-4"})]})]}),d&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Go to"}),e.jsx(l.Input,{type:"number",min:1,max:r,value:m,onChange:c=>{const n=c.target.value.replace(/[^\d]/g,"");y(n)},onKeyDown:f,className:"h-8 w-16 px-2 py-1"}),e.jsx(l.Button,{variant:"outline",size:"sm",onClick:C,disabled:m===""||Number(m)<1||Number(m)>r,children:"Go"})]})]})}const we=(a={})=>{const r=v.useAssetsApiUrl(),o=v.useFetch(),{search:t,page:d=1,limit:i=30}=a;return k.useQuery({queryKey:[v.ACTIONS.GET_ASSETS,t,d,i],queryFn:async()=>{const m=await o(r,{action:v.ACTIONS.GET_ASSETS,data:{search:t,page:d,limit:i}});return m.page=d,m.limit=i,m},staleTime:1/0,retry:1})},Ce=a=>{const r=v.useAssetsApiUrl(),o=v.useFetch();return k.useQuery({queryKey:[v.ACTIONS.GET_ASSET,a],queryFn:async()=>a?await o(r,{action:v.ACTIONS.GET_ASSET,data:{id:a}}):null,staleTime:1/0,retry:1})};function Ae(a){const r=isNaN(a)?0:typeof a=="number"?a:parseInt(a);return r?r<1024?`${r.toFixed(2)} B`:r<1024*1024?`${(r/1024).toFixed(2)} KB`:`${(r/(1024*1024)).toFixed(2)} MB`:"0 B"}function X(a){if(!a)return"N/A";const r=new Date(a);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}function Z(a,r){let o=a,t=r==null?void 0:r.description;return(!t||typeof t!="string")&&(t=""),(!o||typeof o!="string")&&(o=""),o!==t}const Se=({assetId:a,onBack:r,onEdit:o,onSave:t,isSaving:d})=>{var f,c;const{data:i,isLoading:m,isError:y}=Ce(a||""),[N,g]=u.useState(""),[w,S]=u.useState(!1);u.useEffect(()=>{const n=new Image;return n.src=(i==null?void 0:i.url)||"",n.onload=()=>S(!0),()=>{n.onload=null}},[i]);const C=async(n,h)=>{try{await navigator.clipboard.writeText(n),A.toast.success(`${h} copied to clipboard`)}catch(j){A.toast.error(`Failed to copy ${h}`,{description:j==null?void 0:j.message})}};return u.useEffect(()=>{i!=null&&i.description&&g(i.description)},[i]),m||!w?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(p.Loader,{className:"h-8 w-8 animate-spin"})}):y||!(i!=null&&i.id)?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto p-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(p.AlertCircle,{className:"h-12 w-12 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No Asset Found"}),e.jsx("p",{className:"text-sm text-gray-500 mb-6",children:y?"There was an error loading the asset. Please try again later.":"The asset you're looking for doesn't exist or has been removed."}),e.jsxs("div",{className:"flex justify-center gap-4",children:[e.jsx(l.Button,{variant:"outline",onClick:r,children:"Back to Assets"}),y&&e.jsx(l.Button,{variant:"default",onClick:()=>window.location.reload(),children:"Try Again"})]})]})}):e.jsxs("div",{className:"flex-1 flex flex-col gap-y-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(l.Button,{variant:"outline",size:"sm",onClick:r,disabled:d,children:[e.jsx(p.ChevronLeft,{className:"h-4 w-4"}),"Back to Assets"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l.Button,{variant:"outline",onClick:r,disabled:d,children:"Cancel"}),e.jsxs(l.Button,{variant:"outline",onClick:()=>C(i.url,"Asset URL"),disabled:d,children:[e.jsx(p.Copy,{className:"h-4 w-4 mr-2"}),"Copy URL"]}),e.jsxs(l.Button,{variant:"default",onClick:()=>o(i),disabled:d,children:[e.jsx(p.Pencil,{className:"h-4 w-4"}),"Edit Image"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 items-start gap-6 flex-1 overflow-hidden",children:[e.jsx("div",{className:"relative h-[calc(80vh-200px)] w-full flex items-start justify-center",children:e.jsx("img",{src:i.url,alt:i.name,className:"w-full h-full object-contain rounded-lg max-h-max max-w-max"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100",children:[e.jsx(l.Label,{className:"w-full text-center",children:"Details"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2 bg-white",children:[{label:"File Name",value:i.name},{label:"Type",value:i.type,capitalize:!0},{label:"Format",value:((f=i.metadata)==null?void 0:f.format)||i.type,capitalize:!0},{label:"Size",value:Ae(i.size)},{label:"Dimensions",value:`${i.width||0} × ${i.height||0}`},{label:"Created",value:X(i.createdAt)},{label:"Updated",value:X(((c=i.metadata)==null?void 0:c.updatedAt)||(i==null?void 0:i.updatedAt)||i.createdAt)},{label:"URL",value:i.url,copyable:!0}].map(n=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:n.label}),":",e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900"+(n.capitalize?" capitalize":""),children:n.value}),n.copyable&&e.jsx(l.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>C(n.value,n.label),children:e.jsx(p.Link,{className:"h-3 w-3"})})]})]},n.label))})]}),i.usedOn&&i.usedOn.length>0&&e.jsxs("div",{className:"grid gap-3",children:[e.jsx(l.Label,{children:"Used On"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:i.usedOn.map((n,h)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900",children:n.name}),e.jsxs("div",{className:"text-gray-500",children:["(",n.slug,")"]})]},h))})]}),e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100 relative",children:[e.jsx(l.Label,{className:"w-full text-center",children:"Description"}),e.jsx(l.Textarea,{id:"description",value:N,placeholder:"Enter a description for the asset",onChange:n=>g(n.target.value),rows:3,disabled:d,className:"hover:border-black/40 bg-white"}),e.jsx("div",{className:"flex justify-end items-start absolute top-1.5 right-2",children:e.jsx("button",{type:"button",onClick:()=>t(N),disabled:d||!Z(N,i),className:`py-0 bg-blue-500 text-white px-3 py-0.5 rounded-md text-sm ${d||!Z(N,i)?"opacity-50 cursor-not-allowed":""}`,children:d?e.jsxs(e.Fragment,{children:[e.jsx(p.Loader,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):"Save"})})]})]})]})]})},Te=u.lazy(()=>Promise.resolve().then(()=>require("./image-editor-Da6lrqkL.cjs"))),Ee=25*1024*1024,Ie=({isUpdatingAsset:a,allowedTypes:r,uploadAssets:o,isUploadingAsset:t,onUploaded:d})=>{const[i,m]=u.useState(()=>{const f=localStorage.getItem("chai_optimize_images");return f!==null?f==="true":!0});u.useEffect(()=>{localStorage.setItem("chai_optimize_images",i.toString())},[i]);const y=a||t,N=u.useCallback(async f=>{try{const c=f;if(!c.every(b=>b.type.startsWith("image/")))return A.toast.error("Invalid file type. Please upload a valid file."),Promise.reject(new Error("Invalid file type"));const n=c.map(async b=>{let F=b;return b.type.startsWith("image/")&&(F=await Y.compressImageIfNeeded(b)),new Promise((P,B)=>{const U=new FileReader;U.readAsDataURL(F),U.onload=async()=>{P({file:U.result,folderId:void 0,name:b.name,optimize:i})},U.onerror=()=>B(null)})}),h=await Promise.all(n),j=await o(h);return(j==null?void 0:j.length)===1&&d(j[0]),j}catch(c){return Promise.reject(c)}},[o,i,d]),g=f=>{const c=[];let n=0;return f.forEach(h=>{h.size>Ee?n++:c.push(h)}),n>0&&A.toast.error(`${n===1&&f.length===1?"File":n+(n===1?" file":" files")} exceed the maximum size limit of 10MB.`),D.isEmpty(c)?[]:N(c)},{getRootProps:w,getInputProps:S,isDragActive:C}=fe.useDropzone({onDrop:g,accept:{"image/*":r.includes("image")?[]:[]},disabled:a||t,multiple:!0});return e.jsx("div",{className:`flex h-[60px] w-full flex-col items-center justify-center rounded-lg border-2 border-dashed border-slate-300 p-0 py-2 hover:border-black/50 ${y?"pointer-events-none bg-gray-100 opacity-90":"bg-gray-100 hover:border-black/50 hover:bg-gray-100"}`,children:e.jsxs("div",{...w(),className:J.mergeClasses("flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",y?"items-start":"items-center",C?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...S()}),y?e.jsx("div",{className:"flex flex-col items-center px-6",children:e.jsxs("div",{className:"flex items-center justify-center gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full bg-indigo-100 p-2",children:e.jsx(p.Loader,{className:"h-4 w-4 animate-spin text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:a?"Updating file...":"Uploading file..."}),e.jsxs("div",{className:"text-xs font-light text-muted-foreground",children:["Please wait while we ",a?"update":"upload"," your file..."]})]})]})}):e.jsxs("div",{className:"flex w-full items-center justify-between px-6",children:[e.jsx("div",{className:"flex flex-col items-center",children:e.jsxs("div",{className:"flex items-center justify-between gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full border border-indigo-500 bg-indigo-100 p-2",children:e.jsx(p.Upload,{className:"h-4 w-4 text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsxs("div",{className:"font-medium",children:["Drop your file here or"," ",e.jsx("span",{className:"cursor-pointer text-indigo-500 hover:underline",children:"browse"})]}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:e.jsxs("span",{className:"",children:["Accepted file types: ",e.jsx("span",{className:"capitalize text-indigo-400",children:r.join(", ")})]})})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs",children:["Optimization:"," ",e.jsx("span",{className:i?"text-indigo-600":"text-gray-400",children:i?"On":"Off"})]}),e.jsx(l.Switch,{checked:i,onCheckedChange:f=>{m(f)},onClick:f=>{f.stopPropagation()},className:"data-[state=checked]:bg-indigo-500"})]}),e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:`flex cursor-help items-center text-amber-500 ${i?"invisible":""}`,children:e.jsx(p.AlertTriangle,{className:"mr-1 h-4 w-4"})})}),e.jsx(l.TooltipContent,{side:"top",children:e.jsxs("p",{className:"text-xs text-white",children:["Warning: Unoptimized images may affect ",e.jsx("br",{})," performance and page load times"]})})]})})]})]})]})})};function ke({close:a,onSelect:r,mode:o="image",assetId:t}){const m=u.useMemo(()=>[o],[o]),[y,N]=u.useState(null),[g,w]=u.useState(null),[S,C]=u.useState(null),[f,c]=u.useState({show:!1,file:""}),[n,h]=u.useState(!1),[j,b]=u.useState(t?"details":"grid"),[F,P]=u.useState(""),[B,U]=u.useState(""),[O,$]=u.useState(1),[G]=u.useState(30),[T,K]=u.useState([]);u.useEffect(()=>{t&&(N(t),b("details"))},[t]),u.useEffect(()=>{const s=setTimeout(()=>{P(B),$(1)},300);return()=>clearTimeout(s)},[B]);const{data:L,isLoading:M,refetch:ee}=we({search:F.toLowerCase().trim(),page:O,limit:G}),z=(L==null?void 0:L.assets)||[],te=(L==null?void 0:L.total)||0,E=Math.ceil(te/G);u.useEffect(()=>{M||E<=0||$(s=>s>E?E:s<1?1:s)},[M,E]);const se=(z==null?void 0:z.length)>0,{mutate:ie}=ye(),{mutateAsync:R,isPending:re}=ve(),{mutateAsync:_,isPending:le}=Ne(),W=u.useCallback(s=>{const x=Math.min(Math.max(1,s),Math.max(1,E));x!==O&&$(x)},[E,O]),ae=s=>{U(s.target.value)},ne=u.useCallback(s=>{K(x=>D.find(x,{id:s.id})?[]:[s])},[!1]),oe=u.useCallback(()=>{K([])},[]),V=s=>{(s==null?void 0:s.length)!==0&&(r(D.pick(D.first(s||T),["id","url","width","height","description"])),a())},ce=async s=>{w(s)},de=async()=>{g&&(C(g==null?void 0:g.id),await ie(g.id,{onSuccess:()=>{C(null),w(null)},onError:()=>{C(null)}}),w(null))},ue=s=>{N(s.id),b("details")},me=async(s,x)=>{try{const q=localStorage.getItem("chai_optimize_images")!=="false";if(x){const I=await R([{file:s,folderId:void 0,name:f.name||"",optimize:q}]);if((I==null?void 0:I.length)>0){const H=I[0];r({...D.pick(H,["id","width","height","description"]),url:H.url})}}else{const I=await _({id:f.id||"",file:s});I&&r({...D.pick(I,["id","width","height","description"]),url:I.url})}c({show:!1,file:""}),a()}catch(q){console.error("Error saving edited image:",q)}},he=u.useCallback(s=>{K([s])},[]),xe=u.useCallback(s=>{W(s)},[W]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4",children:[e.jsx("h1",{className:"text-lg font-medium",children:"Digital Asset Manager"}),j==="grid"?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{maxFileSize:10,allowedTypes:m,uploadAssets:R,isUpdatingAsset:le,isUploadingAsset:re,onUploaded:he}),e.jsxs("div",{className:"relative flex flex-1 flex-col gap-y-3 overflow-hidden rounded-lg border p-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"relative w-1/2",children:[e.jsx(p.Search,{strokeWidth:3,className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground ${B.length>0?"text-indigo-800":""}`}),e.jsx(l.Input,{placeholder:"Search assets...",onChange:ae,value:B,className:"pl-8"})]}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[T.length>0?e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[T.length>0&&e.jsx(e.Fragment,{children:e.jsx(l.Button,{variant:"outline",size:"sm",onClick:()=>oe(),title:"Clear selection",children:"Clear"})}),e.jsx(l.Button,{size:"sm",onClick:()=>V(T),disabled:T.length===0,children:"Select Asset"})]})}):null,e.jsx(l.Button,{variant:"ghost",size:"icon",onClick:()=>ee(),children:e.jsx(p.RefreshCwIcon,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pb-[66px]",children:M?e.jsxs("div",{className:"columns-1 gap-3 space-y-3 sm:columns-3 md:columns-5",children:[e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"})]}):!M&&!se?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center rounded-lg border",children:[e.jsx("div",{className:"text-muted-foreground",children:e.jsx(p.Archive,{className:"h-9 w-9 text-indigo-500"})}),e.jsx("div",{className:"text-lg text-muted-foreground",children:"No assets found"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:F.length>0?"No assets found for your search: "+F:"Start uploading assets to get started"}),e.jsx("br",{})]}):e.jsx("div",{className:"flex flex-wrap gap-3 p-1",children:z==null?void 0:z.map(s=>e.jsxs("div",{className:J.mergeClasses("group relative flex max-h-[180px] max-w-[180px] cursor-pointer flex-col justify-between overflow-hidden rounded-lg border-2 transition-all",T.some(x=>x.id===s.id)?"border-blue-500":"hover:border-black/90",S&&(g==null?void 0:g.id)===s.id?"pointer-events-none opacity-50":"",S===s.id?"pointer-events-none opacity-50":""),onClick:()=>ne(s),onDoubleClick:()=>V([s]),children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden",children:[S===s.id?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:e.jsx(p.Loader,{className:"h-8 w-8 animate-spin text-white"})}):null,s.type==="image"?e.jsx("img",{src:`${s.thumbnailUrl||"/placeholder.svg"}?v=${(s==null?void 0:s.updatedAt)||s.createdAt}`,alt:s.name,className:`h-full min-h-[80px] w-full object-contain ${T.some(x=>x.id===s.id)?"":"group-hover:blur group-hover:contrast-50"}`}):e.jsxs("div",{className:"flex h-full items-center justify-center",children:[e.jsx(p.Film,{className:"h-12 w-12 text-muted-foreground"}),s.thumbnailUrl&&e.jsx("img",{src:`${s.thumbnailUrl||"/placeholder.svg"}?v=${(s==null?void 0:s.updatedAt)||s.createdAt}`,alt:s.name,className:"absolute inset-0 h-full w-full object-cover"})]})]}),e.jsxs("div",{className:"flex items-end justify-between border-t-[1px] border-black/10 bg-white px-2 py-1",children:[e.jsx("div",{className:"truncate text-xs leading-tight",title:s.name,children:s.name}),e.jsx("div",{className:"flex items-center justify-between whitespace-nowrap text-[9px] font-light text-muted-foreground",children:e.jsx("span",{children:Y.formatFileSize((s==null?void 0:s.size)||0)})})]}),!T.some(x=>x.id===s.id)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100",children:e.jsxs("div",{className:"grid grid-cols-4 gap-2 p-2",children:[e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx(l.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:x=>{x.stopPropagation(),ue(s)},children:e.jsx(p.ImageIcon,{className:"h-4 w-4"})})}),e.jsx(l.TooltipContent,{children:e.jsx("p",{children:"View Details"})})]})}),e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx(l.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:x=>{x.stopPropagation(),navigator.clipboard.writeText(s.url),A.toast.success("Asset URL copied to clipboard")},children:e.jsx(p.Copy,{className:"h-4 w-4"})})}),e.jsx(l.TooltipContent,{children:e.jsx("p",{children:"Copy URL"})})]})}),e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx(l.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:x=>{x.stopPropagation(),c({id:s.id,show:!0,file:s.url,name:s.name})},children:e.jsx(p.Edit,{className:"h-4 w-4"})})}),e.jsx(l.TooltipContent,{children:e.jsx("p",{children:"Edit Image"})})]})}),e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx(l.Button,{variant:"destructive",size:"icon",className:"h-8 w-8 rounded-full",onClick:x=>{x.stopPropagation(),ce(s)},children:e.jsx(p.Trash2,{className:"h-4 w-4"})})}),e.jsx(l.TooltipContent,{children:e.jsx("p",{children:"Delete Asset"})})]})})]})}),T.some(x=>x.id===s.id)&&e.jsx("div",{className:"absolute right-1 top-1 h-max rounded-full border border-white bg-blue-500 p-1",children:e.jsx(p.Check,{className:"h-3 w-3 text-white",strokeWidth:5})})]},s.id))})}),E>1&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 border-t bg-white p-4",children:e.jsx(ge,{fallback:e.jsx("div",{className:"text-red-500",children:"Error loading pagination"}),children:e.jsx(be,{currentPage:O,totalPages:E,onPageChange:xe,pageRangeDisplayed:3,showPageInput:!0})})})]})]}):e.jsx(Se,{assetId:y||t||"",onBack:()=>{b("grid"),N(null)},onEdit:s=>{c({id:s.id,show:!0,file:s.url,name:s.name})},onSave:async s=>{if(y){h(!0);try{const x=z.find(q=>q.id===y);x&&await _(D.merge(x,{description:s}))}finally{h(!1)}}},isSaving:n})]}),f.show&&e.jsx(u.Suspense,{fallback:e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(p.Loader,{className:"h-8 w-8 animate-spin"})}),children:e.jsx(Te,{imageUrl:f.file,onSave:me,onClose:()=>c({show:!1,file:""}),defaultSavedImageName:f.name,isEditing:!!f.id})}),g&&e.jsx(l.Dialog,{open:!!g,onOpenChange:()=>w(null),children:e.jsxs(l.DialogContent,{children:[e.jsxs(l.DialogHeader,{children:[e.jsx(l.DialogTitle,{children:"Delete Asset"}),e.jsxs(l.DialogDescription,{children:['Are you sure you want to delete "',g.name,'"? This action cannot be undone.']})]}),e.jsxs(l.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(l.Button,{variant:"outline",onClick:()=>w(null),children:"Cancel"}),e.jsx(l.Button,{variant:"destructive",onClick:de,children:"Delete"})]})]})})]})}exports.default=ke;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
-
import { al as b, am as C, A, an as T } from "./index-
|
|
2
|
+
import { al as b, am as C, A, an as T } from "./index-BuXZJnGo.js";
|
|
3
3
|
import { useQueryClient as w, useMutation as F } from "@tanstack/react-query";
|
|
4
4
|
import { toast as S } from "sonner";
|
|
5
5
|
import { Dialog as _, DialogContent as q, DialogHeader as G, DialogTitle as L, DialogDescription as U, Label as v, Input as j, Alert as $, Button as D } from "@chaibuilder/sdk/ui";
|
|
6
6
|
import { isEmpty as O, initial as B } from "lodash-es";
|
|
7
7
|
import { AlertCircle as M } from "lucide-react";
|
|
8
8
|
import { useState as p } from "react";
|
|
9
|
-
import { S as Q } from "./slug-input-
|
|
9
|
+
import { S as Q } from "./slug-input-DfAsMPg8.js";
|
|
10
10
|
const V = () => {
|
|
11
11
|
const t = b(), r = w(), g = C();
|
|
12
12
|
return F({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./index-Cds1vIhw.cjs"),S=require("@tanstack/react-query"),N=require("sonner"),a=require("@chaibuilder/sdk/ui"),v=require("lodash-es"),E=require("lucide-react"),g=require("react"),q=require("./slug-input-DMYhARDW.cjs"),C=()=>{const t=p.useApiUrl(),r=S.useQueryClient(),h=p.useFetch();return S.useMutation({mutationFn:async({pageId:c,name:u,slug:o})=>{const s={pageId:c,name:u};return o&&(s.slug=o),await h(t,{action:"DUPLICATE_PAGE",data:s})},onSuccess:()=>{r.invalidateQueries({queryKey:[p.ACTIONS.GET_WEBSITE_PAGES]}),N.toast.success("Page duplicated successfully")},onError:c=>{N.toast.error("Failed to duplicate page",{description:c.message||"An error occurred while duplicating the page"})}})},A=({page:t,onClose:r,closePanel:h=()=>{}})=>{const{mutate:c,isPending:u}=C(),[o,s]=g.useState(null),[d,P]=g.useState(`${t.name} (Copy)`),D=p.useChangePage(),i=v.isEmpty(t.slug),[m,b]=g.useState(i?"":`${t.slug.split("/").pop()}-copy`),j=i?"":v.initial(t.slug.split("/")).join("/"),[f,x]=g.useState(!1),I=n=>{if(n.preventDefault(),!d.trim()){s("Name is required");return}if(!i&&!m.trim()){s("Slug is required");return}s(null),x(!0);const y={pageId:t.id,name:d};i||(y.slug=`${j}/${m}`),c(y,{onSuccess:l=>{x(!1),r(),D(l.id,h)},onError:l=>{x(!1),l.code==="SLUG_EXISTS"?s("A page with this slug already exists. Please choose a different slug."):l.code==="INVALID_SLUG"?s("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens."):l.code==="PERMISSION_DENIED"?s("You don't have permission to duplicate this page."):s(l.message||"Failed to duplicate page. Please try again later.")}})};return e.jsx(a.Dialog,{open:!!t,onOpenChange:r,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Duplicate Page"}),e.jsx(a.DialogDescription,{children:"Create a copy of the page with a new name and slug"})]}),e.jsxs("div",{className:"mb-4 rounded-md bg-gray-50 p-3",children:[e.jsx("h3",{className:"mb-1 text-sm font-medium",children:"Duplicating:"}),e.jsxs("div",{className:"flex flex-col gap-1 text-sm text-gray-700",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Name:"})," ",t.name]}),!i&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Slug:"})," ",t.slug]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Type:"})," ",t.pageType]})]})]}),e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(a.Input,{id:"name",value:d,onChange:n=>P(n.target.value),required:!0})]}),!i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx(q.SlugInput,{value:m,onChange:n=>b(n),parentSlug:j,onValidationChange:n=>{s(n?null:"Invalid slug")}})]}),o&&e.jsxs(a.Alert,{variant:"destructive",className:"py-2",children:[e.jsx(E.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(a.Button,{type:"button",variant:"outline",onClick:r,disabled:u,children:"Cancel"}),e.jsx(a.Button,{type:"submit",disabled:!d.trim()||!i&&!m.trim()||u||f,children:u||f?"Duplicating...":"Duplicate"})]})]})]})})};exports.default=A;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),h=require("lodash-es"),p=require("lucide-react"),d=require("react"),g=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),h=require("lodash-es"),p=require("lucide-react"),d=require("react"),g=require("./index-Cds1vIhw.cjs"),f=({isDefaultLang:r,searchQuery:l,setSearchQuery:c})=>e.jsx(a.Input,{type:"text",autoFocus:!0,value:r?l:"",onChange:t=>c(t.target.value),placeholder:r?"Search pages...":"To search select default language",disabled:!r,onKeyDown:t=>t.stopPropagation()}),m=({dynamicPage:r,setDynamicPage:l,searchQuery:c,setSearchQuery:t,dynamicPages:n})=>{const{selectedLang:o,fallbackLang:i}=x.useLanguages(),u=(o==null?void 0:o.length)===0;return e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"ghost",className:"w-max focus:outline-none focus:ring-0 border-[0px] rounded-md py-1 text-sm h-max border border-gray-200 hover:bg-gray-100 pl-4",children:[r?h.get(r,"name"):"Select Page",e.jsx(p.ChevronDown,{className:"ml-2 h-4 w-4"})]})}),e.jsxs(a.DropdownMenuContent,{className:"w-96 divide-y shadow-xl p-0 max-h-[75vh]",children:[e.jsx("div",{className:"p-1.5 bg-gray-50/30",children:e.jsx(f,{isDefaultLang:u,searchQuery:c,setSearchQuery:t})}),(n==null?void 0:n.length)===0?e.jsx("div",{className:"h-24 text-xs flex items-center justify-center",children:"No pages found"}):n==null?void 0:n.map(s=>e.jsx(a.DropdownMenuItem,{onClick:()=>l(s),disabled:u?i!==s.lang:o!==s.lang,className:`flex flex-col justify-start cursor-pointer overflow-x-auto whitespace-nowrap no-scrollbar ${s.id===(r==null?void 0:r.id)?"bg-blue-50":"hover:bg-gray-50"}`,children:e.jsx("div",{className:"w-full text-xs whitespace-nowrap px-2 py-[2px]",children:e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsx("span",{className:"font-mono font-medium text-gray-500 text-xs rounded-full px-2 py-[1px] border border-gray-300 truncate",children:s.slug})]})})},s.id))]})]})},j=()=>{const{dynamicPage:r,dynamicPages:l,allLangPages:c,selectedLang:t,searchQuery:n,updateDynamicPage:o,updateSearchQuery:i,onChangeLanguage:u}=g.useDynamicPageSelector(),s=d.useRef(void 0);return d.useEffect(()=>{s.current!==t&&r&&(u(),s.current=t)},[t,l]),e.jsx("div",{className:"relative",children:e.jsx(m,{dynamicPage:r,setDynamicPage:o,searchQuery:n,setSearchQuery:i,dynamicPages:c})})};exports.default=j;
|
|
@@ -4,7 +4,7 @@ import { DropdownMenu as h, DropdownMenuTrigger as p, Button as m, DropdownMenuC
|
|
|
4
4
|
import { get as v } from "lodash-es";
|
|
5
5
|
import { ChevronDown as w } from "lucide-react";
|
|
6
6
|
import { useRef as b, useEffect as N } from "react";
|
|
7
|
-
import { k as y } from "./index-
|
|
7
|
+
import { k as y } from "./index-BuXZJnGo.js";
|
|
8
8
|
const D = ({
|
|
9
9
|
isDefaultLang: e,
|
|
10
10
|
searchQuery: l,
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { jsx as n, jsxs as E } from "react/jsx-runtime";
|
|
2
|
+
import { Dialog as T, DialogContent as L } from "@chaibuilder/sdk/ui";
|
|
3
|
+
import { debounce as R } from "lodash-es";
|
|
4
|
+
import { Save as S, Copy as j, Loader as O } from "lucide-react";
|
|
5
|
+
import { memo as P, useState as l, useEffect as h, useMemo as i, useCallback as x } from "react";
|
|
6
|
+
import A from "react-filerobot-image-editor";
|
|
7
|
+
const D = P(
|
|
8
|
+
({ imageUrl: r, onSave: c, onClose: m, defaultSavedImageName: b, isEditing: u = !1 }) => {
|
|
9
|
+
const [y, o] = l(!1), [f, p] = l(!0), [v, w] = l(!1);
|
|
10
|
+
h(() => {
|
|
11
|
+
const e = new Image();
|
|
12
|
+
return e.src = r, e.onload = () => w(!0), () => {
|
|
13
|
+
e.onload = null;
|
|
14
|
+
};
|
|
15
|
+
}, [r]), h(() => {
|
|
16
|
+
const e = (t) => {
|
|
17
|
+
t.key === "Escape" && f && (t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation());
|
|
18
|
+
};
|
|
19
|
+
return document.addEventListener("keydown", e, !0), () => {
|
|
20
|
+
document.removeEventListener("keydown", e, !0);
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
23
|
+
const I = i(
|
|
24
|
+
() => R(async (e, t = !1) => {
|
|
25
|
+
o(!0);
|
|
26
|
+
const a = e.imageBase64;
|
|
27
|
+
await c(a, t), p(!1), o(!1);
|
|
28
|
+
}, 300),
|
|
29
|
+
[c]
|
|
30
|
+
), s = x(
|
|
31
|
+
(e, t = !1) => {
|
|
32
|
+
I(e, t);
|
|
33
|
+
},
|
|
34
|
+
[I]
|
|
35
|
+
), g = x(() => {
|
|
36
|
+
p(!1), m();
|
|
37
|
+
}, [m]), d = i(
|
|
38
|
+
() => ({
|
|
39
|
+
tabsIds: ["Adjust", "Annotate", "Watermark", "Finetune", "Resize", "Filters"],
|
|
40
|
+
toolsIds: ["Rotate"],
|
|
41
|
+
defaultTabId: "Adjust",
|
|
42
|
+
defaultToolId: "Rotate"
|
|
43
|
+
}),
|
|
44
|
+
[]
|
|
45
|
+
), C = i(
|
|
46
|
+
() => ({
|
|
47
|
+
colors: {
|
|
48
|
+
primary: "#000000",
|
|
49
|
+
secondary: "#000000",
|
|
50
|
+
tertiary: "#000000"
|
|
51
|
+
}
|
|
52
|
+
}),
|
|
53
|
+
[]
|
|
54
|
+
), k = i(
|
|
55
|
+
() => u ? [
|
|
56
|
+
{
|
|
57
|
+
label: "Update this file",
|
|
58
|
+
onClick: (e, t) => t((...a) => {
|
|
59
|
+
o(!0), s(a[0], !1);
|
|
60
|
+
}),
|
|
61
|
+
icon: S
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
label: "Save as new file",
|
|
65
|
+
onClick: (e, t) => t((...a) => {
|
|
66
|
+
o(!0), s(a[0], !0);
|
|
67
|
+
}),
|
|
68
|
+
icon: j
|
|
69
|
+
}
|
|
70
|
+
] : [],
|
|
71
|
+
[u, s]
|
|
72
|
+
);
|
|
73
|
+
return /* @__PURE__ */ n(T, { open: !0, onOpenChange: (e) => !e && g(), children: /* @__PURE__ */ E(
|
|
74
|
+
L,
|
|
75
|
+
{
|
|
76
|
+
id: "chai-image-editor-container",
|
|
77
|
+
className: "flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4 p-0",
|
|
78
|
+
children: [
|
|
79
|
+
y && /* @__PURE__ */ n("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 text-white", children: /* @__PURE__ */ n(O, { className: "h-4 w-4 animate-spin" }) }),
|
|
80
|
+
f && v && /* @__PURE__ */ n(
|
|
81
|
+
A,
|
|
82
|
+
{
|
|
83
|
+
theme: C,
|
|
84
|
+
source: r,
|
|
85
|
+
onSave: s,
|
|
86
|
+
onClose: g,
|
|
87
|
+
Text: { text: "Add text here" },
|
|
88
|
+
Rotate: { angle: 90, componentType: "slider" },
|
|
89
|
+
tabsIds: d.tabsIds,
|
|
90
|
+
defaultTabId: d.defaultTabId,
|
|
91
|
+
defaultToolId: d.defaultToolId,
|
|
92
|
+
savingPixelRatio: 20,
|
|
93
|
+
previewPixelRatio: 6,
|
|
94
|
+
defaultSavedImageName: b,
|
|
95
|
+
moreSaveOptions: k,
|
|
96
|
+
useZoomPresetsMenu: !0
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
) });
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
D.displayName = "ImageEditor";
|
|
105
|
+
export {
|
|
106
|
+
D as default
|
|
107
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),x=require("@chaibuilder/sdk/ui"),E=require("lodash-es"),d=require("lucide-react"),a=require("react"),S=require("react-filerobot-image-editor"),b=a.memo(({imageUrl:r,onSave:c,onClose:u,defaultSavedImageName:h,isEditing:m=!1})=>{const[y,n]=a.useState(!1),[f,p]=a.useState(!0),[v,w]=a.useState(!1);a.useEffect(()=>{const e=new Image;return e.src=r,e.onload=()=>w(!0),()=>{e.onload=null}},[r]),a.useEffect(()=>{const e=t=>{t.key==="Escape"&&f&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}},[]);const g=a.useMemo(()=>E.debounce(async(e,t=!1)=>{n(!0);const s=e.imageBase64;await c(s,t),p(!1),n(!1)},300),[c]),i=a.useCallback((e,t=!1)=>{g(e,t)},[g]),I=a.useCallback(()=>{p(!1),u()},[u]),l=a.useMemo(()=>({tabsIds:["Adjust","Annotate","Watermark","Finetune","Resize","Filters"],toolsIds:["Rotate"],defaultTabId:"Adjust",defaultToolId:"Rotate"}),[]),j=a.useMemo(()=>({colors:{primary:"#000000",secondary:"#000000",tertiary:"#000000"}}),[]),C=a.useMemo(()=>m?[{label:"Update this file",onClick:(e,t)=>t((...s)=>{n(!0),i(s[0],!1)}),icon:d.Save},{label:"Save as new file",onClick:(e,t)=>t((...s)=>{n(!0),i(s[0],!0)}),icon:d.Copy}]:[],[m,i]);return o.jsx(x.Dialog,{open:!0,onOpenChange:e=>!e&&I(),children:o.jsxs(x.DialogContent,{id:"chai-image-editor-container",className:"flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4 p-0",children:[y&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 text-white",children:o.jsx(d.Loader,{className:"h-4 w-4 animate-spin"})}),f&&v&&o.jsx(S,{theme:j,source:r,onSave:i,onClose:I,Text:{text:"Add text here"},Rotate:{angle:90,componentType:"slider"},tabsIds:l.tabsIds,defaultTabId:l.defaultTabId,defaultToolId:l.defaultToolId,savingPixelRatio:20,previewPixelRatio:6,defaultSavedImageName:h,moreSaveOptions:C,useZoomPresetsMenu:!0})]})})});b.displayName="ImageEditor";exports.default=b;
|
|
@@ -527,7 +527,7 @@ const Ja = ({ query: e, uuid: t }) => {
|
|
|
527
527
|
rejectTakeOver: d,
|
|
528
528
|
requestTakeOver: o
|
|
529
529
|
};
|
|
530
|
-
}, ci = K(() => import("./no-language-page-content-
|
|
530
|
+
}, ci = K(() => import("./no-language-page-content-CVyOpT9h.js")), ui = K(() => import("./page-locked-by-dialog-D-vXaoga.js")), sn = K(() => import("./page-lock-request-DC62b588.js")), di = ({ isFetchingPage: e }) => {
|
|
531
531
|
const { pageLock: t, requestTakeOver: n } = li(), { currentEditor: s, lockingStatus: r, setLockingStatus: a, realtimePageLockEnabled: i } = Ie(), { data: o, isFetching: l } = si(s), [d] = le(), f = d.get("page"), [u] = Cn(), h = z(), E = $(() => {
|
|
532
532
|
n();
|
|
533
533
|
}, [n]);
|
|
@@ -788,7 +788,7 @@ const Ln = pe(null), Gn = () => {
|
|
|
788
788
|
},
|
|
789
789
|
placeholderData: (r) => r || {}
|
|
790
790
|
});
|
|
791
|
-
}, hi = K(() => import("./page-manager-new-
|
|
791
|
+
}, hi = K(() => import("./page-manager-new-Cto2r7Va.js")), vs = ({ children: e }) => {
|
|
792
792
|
const [t, n] = le(), s = t.get("page"), { data: r, isFetching: a } = oe(), { data: i, isFetching: o } = ws(), [l, d] = q(!1), [f, u] = q(!0), { savePage: h } = ke(), E = !!s && !ge(r), A = j(() => {
|
|
793
793
|
if (!i || o) return !1;
|
|
794
794
|
const S = i.find((C) => C.slug === "/");
|
|
@@ -836,7 +836,7 @@ const Ln = pe(null), Gn = () => {
|
|
|
836
836
|
}
|
|
837
837
|
) })
|
|
838
838
|
] });
|
|
839
|
-
}, gi = K(() => import("./add-new-language-page-
|
|
839
|
+
}, gi = K(() => import("./add-new-language-page-8q4Ku3eg.js")), Ei = () => {
|
|
840
840
|
const e = ae("topLeftCorner", null);
|
|
841
841
|
return e ? /* @__PURE__ */ c("div", { className: "max-h-9 w-full overflow-hidden pr-2", children: xr.createElement(e, {}) }) : null;
|
|
842
842
|
}, mi = ({
|
|
@@ -978,7 +978,7 @@ function Ai() {
|
|
|
978
978
|
/* @__PURE__ */ c(Nt, { className: "h-8 w-8 rounded-full" })
|
|
979
979
|
] }, t)) });
|
|
980
980
|
}
|
|
981
|
-
const yi = W.lazy(() => import("./page-revisions-content-
|
|
981
|
+
const yi = W.lazy(() => import("./page-revisions-content-BaTqBnko.js"));
|
|
982
982
|
function Ti() {
|
|
983
983
|
const [e, t] = W.useState(!1);
|
|
984
984
|
return /* @__PURE__ */ c(ms, { children: /* @__PURE__ */ g(Wt, { delayDuration: 0, children: [
|
|
@@ -1267,7 +1267,7 @@ const rn = ({
|
|
|
1267
1267
|
R.error("Failed to change slug");
|
|
1268
1268
|
}
|
|
1269
1269
|
});
|
|
1270
|
-
}, wi = K(() => import("./publish-pages-content-
|
|
1270
|
+
}, wi = K(() => import("./publish-pages-content-C9CgEWo0.js"));
|
|
1271
1271
|
function vi({
|
|
1272
1272
|
showModal: e = !1,
|
|
1273
1273
|
onClose: t = () => console.log("Cancelled")
|
|
@@ -1348,7 +1348,7 @@ function Dn({
|
|
|
1348
1348
|
/* @__PURE__ */ c(Yt, { side: n, sideOffset: 10, children: /* @__PURE__ */ c("p", { children: t }) })
|
|
1349
1349
|
] }) }) : e;
|
|
1350
1350
|
}
|
|
1351
|
-
const Ni = K(() => import("./unpublish-page-
|
|
1351
|
+
const Ni = K(() => import("./unpublish-page-BTPEVAkv.js")), Li = K(() => import("./translation-warning-modal-DalBhNQy.js")), Gi = () => {
|
|
1352
1352
|
const { selectedLang: e, fallbackLang: t } = Se(), n = ae("getPreviewUrl", async (u) => u), [s, r] = q(""), { data: a } = oe(), { data: i } = xe(), { data: o } = Ce(), l = j(
|
|
1353
1353
|
() => {
|
|
1354
1354
|
var u;
|
|
@@ -1644,7 +1644,7 @@ const Ri = ({
|
|
|
1644
1644
|
) })
|
|
1645
1645
|
] })
|
|
1646
1646
|
] });
|
|
1647
|
-
}, Ui = K(() => import("./add-new-page-
|
|
1647
|
+
}, Ui = K(() => import("./add-new-page-BpvpSM4X.js")), Bi = K(() => import("./delete-page-CXRJjJ4o.js")), Mi = K(() => import("./duplicate-page-CSQs2MOp.js")), Fi = K(() => import("./mark-as-template-CPEPYXg7.js")), qi = K(() => import("./unmark-as-template-BjetSrYF.js")), Ki = K(() => import("./unpublish-page-BTPEVAkv.js")), Hi = () => {
|
|
1648
1648
|
const [e, t] = q(null), [n, s] = q(null), [r, a] = q(null), [i, o] = q(null), [l, d] = q(null), [f, u] = q(null), { data: h, isFetching: E } = be(), { selectedLang: A, fallbackLang: y } = Se(), { data: T } = xe(), p = T == null ? void 0 : T.find((L) => L.lang === A), { isLocked: S } = Ie(), C = !(h != null && h.slug), [, U] = ne(Ln);
|
|
1649
1649
|
if (!h) return null;
|
|
1650
1650
|
const M = (L) => {
|
|
@@ -1725,7 +1725,7 @@ const Ri = ({
|
|
|
1725
1725
|
), Vi = ({ hasDynamicPage: e }) => /* @__PURE__ */ c(Is, { children: /* @__PURE__ */ g("div", { className: "flex min-w-[300px] max-w-[400px] flex-col items-center justify-center rounded-lg border bg-white p-4 shadow-lg", children: [
|
|
1726
1726
|
/* @__PURE__ */ c("h1", { className: "text-lg font-medium", children: e ? "Select a page" : "No pages found" }),
|
|
1727
1727
|
/* @__PURE__ */ c("p", { className: "pt-2 text-center text-sm font-light text-gray-600", children: e ? "Please select a page from the list in the top header. This will enable you to edit the page." : "Please add a new page" })
|
|
1728
|
-
] }) }), $i = K(() => import("./dynamic-page-selector-
|
|
1728
|
+
] }) }), $i = K(() => import("./dynamic-page-selector-DTk4oull.js")), Qi = () => {
|
|
1729
1729
|
const { dynamicPage: e, allLangPages: t, isFetching: n } = Xa(), s = t.length > 0;
|
|
1730
1730
|
return n ? null : /* @__PURE__ */ g("div", { className: "relative", children: [
|
|
1731
1731
|
!e && /* @__PURE__ */ c(Vi, { hasDynamicPage: s }),
|
|
@@ -2070,7 +2070,7 @@ const Ri = ({
|
|
|
2070
2070
|
[n, t]
|
|
2071
2071
|
)
|
|
2072
2072
|
};
|
|
2073
|
-
}, ao = K(() => import("./lang-panel-
|
|
2073
|
+
}, ao = K(() => import("./lang-panel-B_HcsPPo.js")), io = ({ isActive: e, show: t }) => {
|
|
2074
2074
|
const { data: n } = Re();
|
|
2075
2075
|
return !jt(n, "languages") || !H(n, "languages", []).length ? null : /* @__PURE__ */ c(B, { size: "sm", onClick: t, variant: e ? "default" : "ghost", children: /* @__PURE__ */ c(xa, { className: "h-4 w-4" }) });
|
|
2076
2076
|
}, Ns = "lang", oo = {
|
|
@@ -2081,7 +2081,7 @@ const Ri = ({
|
|
|
2081
2081
|
button: io,
|
|
2082
2082
|
view: "modal",
|
|
2083
2083
|
width: 400
|
|
2084
|
-
}, lo = K(() => import("./seo-panel-
|
|
2084
|
+
}, lo = K(() => import("./seo-panel-DESVAQM5.js")), Ls = "seo", co = ({ isActive: e, show: t }) => {
|
|
2085
2085
|
const { data: n } = oe(), s = _i(n == null ? void 0 : n.pageType);
|
|
2086
2086
|
return !jt(s, "hasSlug") || !s.hasSlug ? null : /* @__PURE__ */ c(B, { size: "icon", className: "my-1 p-0", onClick: t, variant: e ? "default" : "ghost", children: /* @__PURE__ */ g(
|
|
2087
2087
|
"svg",
|
|
@@ -3982,7 +3982,7 @@ var ru = (e, t = !1) => {
|
|
|
3982
3982
|
const t = Ws(() => {
|
|
3983
3983
|
const n = this, [s] = _(this, Ke), [r] = _(this, He), [a] = _(this, Ve), [i] = _(this, $e), [o] = _(this, yt), [l] = _(this, Fe);
|
|
3984
3984
|
let d;
|
|
3985
|
-
return _(this, Qe) ? d = _(this, Qe) : (d = Qs(() => import("./NCMVHL6D-
|
|
3985
|
+
return _(this, Qe) ? d = _(this, Qe) : (d = Qs(() => import("./NCMVHL6D-D7HU3akD.js")), N(this, Qe, d)), hr(_(this, At), _(this, qe)), Vs(d, $s({
|
|
3986
3986
|
get queryFlavor() {
|
|
3987
3987
|
return _(n, mt);
|
|
3988
3988
|
},
|
|
@@ -4081,7 +4081,7 @@ var ru = (e, t = !1) => {
|
|
|
4081
4081
|
const t = Ws(() => {
|
|
4082
4082
|
const n = this, [s] = _(this, ze), [r] = _(this, Ye), [a] = _(this, Je), [i] = _(this, Xe), [o] = _(this, vt), [l] = _(this, je), [d] = _(this, Ze);
|
|
4083
4083
|
let f;
|
|
4084
|
-
return _(this, et) ? f = _(this, et) : (f = Qs(() => import("./2AITGKQY-
|
|
4084
|
+
return _(this, et) ? f = _(this, et) : (f = Qs(() => import("./2AITGKQY-DhC0sF1x.js")), N(this, et, f)), hr(_(this, wt), _(this, We)), Vs(f, $s({
|
|
4085
4085
|
get queryFlavor() {
|
|
4086
4086
|
return _(n, _t);
|
|
4087
4087
|
},
|
|
@@ -4258,7 +4258,7 @@ const ql = pe(""), Kl = () => {
|
|
|
4258
4258
|
},
|
|
4259
4259
|
[e]
|
|
4260
4260
|
);
|
|
4261
|
-
}, jl = K(() => import("./digital-asset-manager-
|
|
4261
|
+
}, jl = K(() => import("./digital-asset-manager-B2m5T22s.js")), Wl = K(() => import("./save-to-lib-DGtyTG6H.js")), zl = K(() => import("./theme-panel-footer-RrxiDGoD.js")), Yl = K(() => import("./web-preview-DNgPjdgZ.js"));
|
|
4262
4262
|
Kl();
|
|
4263
4263
|
$a();
|
|
4264
4264
|
Vr(Wi);
|
|
@@ -4447,7 +4447,7 @@ const uu = () => {
|
|
|
4447
4447
|
console.error("Failed to update metadata");
|
|
4448
4448
|
}
|
|
4449
4449
|
});
|
|
4450
|
-
}, tc = K(() => import("./digital-asset-manager-
|
|
4450
|
+
}, tc = K(() => import("./digital-asset-manager-B2m5T22s.js")), hu = ({
|
|
4451
4451
|
assetId: e,
|
|
4452
4452
|
assetUrl: t,
|
|
4453
4453
|
onChange: n,
|
|
@@ -4590,7 +4590,7 @@ const uu = () => {
|
|
|
4590
4590
|
n = n.replace(r[0], i);
|
|
4591
4591
|
}
|
|
4592
4592
|
return n;
|
|
4593
|
-
}, ac = K(() => import("./shared-json-ld-
|
|
4593
|
+
}, ac = K(() => import("./shared-json-ld-BMfQzOWc.js")), gu = ({
|
|
4594
4594
|
value: e,
|
|
4595
4595
|
onChange: t,
|
|
4596
4596
|
disabled: n = !1,
|