@chaibuilder/sdk 4.0.0-beta.24 → 4.0.0-beta.25
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/{2SSKDMRQ-DTcPSOGn.js → 2SSKDMRQ-Bk_4y8lw.js} +2 -2
- package/dist/{2SSKDMRQ-C6XmPkPR.cjs → 2SSKDMRQ-vWeQ_IyI.cjs} +1 -1
- package/dist/{AP7HFJJL-6aBLUYOi.cjs → AP7HFJJL-CMPLeI6t.cjs} +1 -1
- package/dist/{AP7HFJJL-CVazlaEj.js → AP7HFJJL-D_mI2XSw.js} +1 -1
- package/dist/{IconPicker-sbWeQ9M9.cjs → IconPicker-DB_PpKvH.cjs} +1 -1
- package/dist/{IconPicker-CcBoA1K0.js → IconPicker-jc6_JzXf.js} +1 -1
- package/dist/{WDYDFRGG-CwiYliX0.js → WDYDFRGG-B4H3RPcp.js} +2 -2
- package/dist/{WDYDFRGG-BtzyRDmj.cjs → WDYDFRGG-D7vzbPjk.cjs} +1 -1
- package/dist/{active-in-another-tab-B4O3FEEg.js → active-in-another-tab-CDhFxBU7.js} +2 -2
- package/dist/{active-in-another-tab-DRJY0QqU.cjs → active-in-another-tab-CMPHyyHE.cjs} +1 -1
- package/dist/{add-new-language-page-BfYL9jXF.js → add-new-language-page-BliZ46WW.js} +3 -3
- package/dist/{add-new-language-page-CKIRTFjr.cjs → add-new-language-page-IbMzbf4v.cjs} +1 -1
- package/dist/{add-new-page-dzN_CD2c.cjs → add-new-page-BJJqSKp0.cjs} +1 -1
- package/dist/{add-new-page-DVgxz4fs.js → add-new-page-DUCKfyWo.js} +2 -2
- package/dist/{ai-panel-content-Dyw4RHCV.cjs → ai-panel-content-DWOqjq3Z.cjs} +1 -1
- package/dist/{ai-panel-content-D5eFLI_B.js → ai-panel-content-GeQIaXy8.js} +3 -3
- package/dist/{ai-panel-default-lang-DEj9Qx2M.cjs → ai-panel-default-lang-DGNDrfam.cjs} +2 -2
- package/dist/{ai-panel-default-lang-Cj7meZBD.js → ai-panel-default-lang-VQsV6KB3.js} +3 -3
- package/dist/{ai-panel-other-lang-Da2XLEcm.cjs → ai-panel-other-lang-DvXF0Nn5.cjs} +1 -1
- package/dist/{ai-panel-other-lang-Cbi6HKzd.js → ai-panel-other-lang-SuC8jyfr.js} +3 -3
- package/dist/{ai-prompt-input-B6QoqT9B.js → ai-prompt-input-CB6iQAmE.js} +1 -1
- package/dist/{ai-prompt-input-DXS8gzex.cjs → ai-prompt-input-a8s-JrZb.cjs} +1 -1
- package/dist/{ai-translation-prompt-Dmq_Ahjf.js → ai-translation-prompt-CoNVDclG.js} +1 -1
- package/dist/{ai-translation-prompt-Uswft8iz.cjs → ai-translation-prompt-Qn1Sz4BI.cjs} +1 -1
- package/dist/change-password-modal-BtdsU0mm.cjs +1 -0
- package/dist/change-password-modal-CMEo8lEm.js +137 -0
- package/dist/{code-editor-wQWmwFKW.js → code-editor-CTMQr0aU.js} +1 -1
- package/dist/{code-editor-DbSBrsUA.cjs → code-editor-CjatfjZe.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-Dkkzk8YZ.cjs → continue-editing-in-this-client-7swLl0kq.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-BV0OrgEU.js → continue-editing-in-this-client-CNVJZvXQ.js} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{css-import-modal-Co_YLkLB.js → css-import-modal-B3XY8Hzw.js} +1 -1
- package/dist/{css-import-modal-C3f5sphx.cjs → css-import-modal-D2RqE-V0.cjs} +1 -1
- package/dist/{delete-design-token-CJPAcsWp.js → delete-design-token-DEyYFVHU.js} +1 -1
- package/dist/{delete-design-token-zzNmNYLR.cjs → delete-design-token-Dd3b86G7.cjs} +1 -1
- package/dist/{delete-page-CQTjB7ZZ.js → delete-page-BSn5mRvk.js} +2 -2
- package/dist/{delete-page-6lInxYM_.cjs → delete-page-BfsmsTek.cjs} +1 -1
- package/dist/{design-token-usage-blwlGuEE.cjs → design-token-usage-BY8meqAt.cjs} +1 -1
- package/dist/{design-token-usage-BQY6eqzE.js → design-token-usage-f20BdlHE.js} +1 -1
- package/dist/{digital-asset-manager-cGUpTcu3.cjs → digital-asset-manager-Pi0YiB35.cjs} +1 -1
- package/dist/{digital-asset-manager-lPKoJ4FH.js → digital-asset-manager-iXt27NlP.js} +3 -3
- package/dist/{duplicate-page-Dmgqp93w.js → duplicate-page-BuVub6uY.js} +3 -3
- package/dist/{duplicate-page-rYeBMwHR.cjs → duplicate-page-g5hiQkrZ.cjs} +1 -1
- package/dist/{dynamic-page-selector-CVyA9Zp0.js → dynamic-page-selector-NZ-rKLo3.js} +2 -2
- package/dist/{dynamic-page-selector-zqGqpcww.cjs → dynamic-page-selector-z6UGEjk1.cjs} +1 -1
- package/dist/{get-chai-builder-theme-CfJkQYZc.js → get-chai-builder-theme-CHXhAcdV.js} +1 -1
- package/dist/{get-chai-builder-theme-Dm1z70lQ.cjs → get-chai-builder-theme-CMypjJk8.cjs} +1 -1
- package/dist/{image-editor-mVBb0VD_.js → image-editor--WT9183_.js} +1 -1
- package/dist/{image-editor-Cn1DgrNp.cjs → image-editor-C6cZZNbB.cjs} +1 -1
- package/dist/index-BGGNVIKx.cjs +5 -0
- package/dist/{index-EFWvSWoi.cjs → index-CfsIhbT2.cjs} +3 -3
- package/dist/{index-GfOB5KV1.js → index-ckjNCVor.js} +990 -978
- package/dist/{index-lm46VtIP.js → index-iRqgNs2O.js} +14 -10
- package/dist/{json-diff-viewer-D5yJoFh1.js → json-diff-viewer-DAQ-qSHk.js} +2 -2
- package/dist/{json-diff-viewer-BeSMdSd5.cjs → json-diff-viewer-DheqS084.cjs} +1 -1
- package/dist/{lang-panel-7qTejsLm.js → lang-panel-DRDPvY1i.js} +3 -3
- package/dist/{lang-panel-B-QUotOn.cjs → lang-panel-oLc-QyU4.cjs} +1 -1
- package/dist/{manage-design-tokens-TeWNZekH.cjs → manage-design-tokens-Hu25ejcC.cjs} +1 -1
- package/dist/{manage-design-tokens-DeH-yNJN.js → manage-design-tokens-rEzXQJRW.js} +2 -2
- package/dist/{mark-as-template-RkfNETRW.js → mark-as-template-BNbn5zQG.js} +2 -2
- package/dist/{mark-as-template-Co00KkhA.cjs → mark-as-template-DEThYoS6.cjs} +1 -1
- package/dist/{nested-path-selector-content-Dimjyy8J.js → nested-path-selector-content-BERhs6_L.js} +1 -1
- package/dist/{nested-path-selector-content-hBvmT_2A.cjs → nested-path-selector-content-Dz3-bNqT.cjs} +1 -1
- package/dist/{no-language-page-content-Bk3sTsdM.js → no-language-page-content-CPVIz5rC.js} +2 -2
- package/dist/{no-language-page-content-CLovr1bL.cjs → no-language-page-content-CrUkIrUJ.cjs} +1 -1
- package/dist/{no-language-page-dialog-C21Fq-UD.cjs → no-language-page-dialog-964r8feg.cjs} +1 -1
- package/dist/{no-language-page-dialog-Cx-YOrAd.js → no-language-page-dialog-DPDJ6gkQ.js} +2 -2
- package/dist/{page-creator-BBuYY84G.js → page-creator-CDcfL4al.js} +3 -3
- package/dist/{page-creator-BDmospqO.cjs → page-creator-kvymje2i.cjs} +1 -1
- package/dist/{page-lock-BrGWj326.js → page-lock-BpUGSiCT.js} +2 -2
- package/dist/{page-lock-DG5IvZaG.cjs → page-lock-gOE-Tt7g.cjs} +1 -1
- package/dist/{page-locked-dialog-DUktYJzU.js → page-locked-dialog-UQeYxWz1.js} +2 -2
- package/dist/{page-locked-dialog-DKnQpIMB.cjs → page-locked-dialog-aJFtoEzq.cjs} +1 -1
- package/dist/{page-manager-new-iYsDkUzG.cjs → page-manager-new-DBomYOFT.cjs} +1 -1
- package/dist/{page-manager-new-BfKYDWs7.js → page-manager-new-Dg02OZtc.js} +22 -22
- package/dist/{page-manager-search-and-filter-DVAGxnlw.js → page-manager-search-and-filter-CCTh5gkC.js} +2 -2
- package/dist/{page-manager-search-and-filter-CIspvIW2.cjs → page-manager-search-and-filter-pWHXOgMJ.cjs} +1 -1
- package/dist/{page-revisions-content-B84UtAxm.cjs → page-revisions-content-BDY8RXJW.cjs} +1 -1
- package/dist/{page-revisions-content-DB4mj_Cw.js → page-revisions-content-C6YjUAx9.js} +7 -7
- package/dist/pages.cjs +1 -1
- package/dist/pages.js +12 -12
- package/dist/{plugin-DVNaUexn.js → plugin-DH3BDqys.js} +7 -7
- package/dist/{plugin-BfC_qpW2.cjs → plugin-DO5QAuc1.cjs} +7 -7
- package/dist/{publish-pages-content-BRKsIr9W.js → publish-pages-content-8MQN9iLc.js} +17 -17
- package/dist/{publish-pages-content-ysv37LxZ.cjs → publish-pages-content-DjUd9oWi.cjs} +1 -1
- package/dist/render.cjs +1 -1
- package/dist/render.js +2 -2
- package/dist/{rte-widget-modal-Dj5BvA-1.js → rte-widget-modal-Bj7lxFEs.js} +1 -1
- package/dist/{rte-widget-modal-BS040t_9.cjs → rte-widget-modal-O31cHitM.cjs} +1 -1
- package/dist/{save-to-lib-D3kp0ovZ.js → save-to-lib-BMlowHNl.js} +2 -2
- package/dist/{save-to-lib-ClCCNy6W.cjs → save-to-lib-vxpiXsok.cjs} +1 -1
- package/dist/sdk.css +1 -1
- package/dist/{selected-block-display-BvRoOMt9.cjs → selected-block-display-BjhZTfSL.cjs} +1 -1
- package/dist/{selected-block-display-BtlTAkei.js → selected-block-display-BxHTDLna.js} +2 -2
- package/dist/{seo-panel-C_Cnwj1-.js → seo-panel-197ULlty.js} +2 -2
- package/dist/{seo-panel-CHGdB8_7.cjs → seo-panel-MrGhioya.cjs} +1 -1
- package/dist/{shared-json-ld-DA0wz-k3.cjs → shared-json-ld-6ovlKZ7L.cjs} +1 -1
- package/dist/{shared-json-ld-DPr0Douk.js → shared-json-ld-B2kfIim8.js} +24 -24
- package/dist/{slug-input-CqhlfgAe.js → slug-input-CSqTWSv8.js} +1 -1
- package/dist/{slug-input-DltqfQ3y.cjs → slug-input-CV-Dvosn.cjs} +1 -1
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.d.ts +34 -0
- package/dist/supabase-actions.js +231 -192
- package/dist/{take-over-request-Bq7OF5Gp.cjs → take-over-request-BFZbLBOK.cjs} +1 -1
- package/dist/{take-over-request-ByUlm_HK.js → take-over-request-Ds_-1dOv.js} +2 -2
- package/dist/{theme-panel-footer-DG7Z5YjD.js → theme-panel-footer-C1f2KMBq.js} +2 -2
- package/dist/{theme-panel-footer-XYoM6sn5.cjs → theme-panel-footer-dHh8VGgj.cjs} +1 -1
- package/dist/{translation-warning-modal-DaBUipEY.js → translation-warning-modal-DPdVK3CD.js} +1 -1
- package/dist/{translation-warning-modal-DTxxfo0H.cjs → translation-warning-modal-HD8Mlj1e.cjs} +1 -1
- package/dist/{unmark-as-template-C9EXTj0X.cjs → unmark-as-template-D8wEsu9z.cjs} +1 -1
- package/dist/{unmark-as-template-BOFHOO0_.js → unmark-as-template-DLVNotM_.js} +2 -2
- package/dist/{unpublish-page-B5rev9W3.cjs → unpublish-page-Cl2R_dfN.cjs} +1 -1
- package/dist/{unpublish-page-KDM7kEEV.js → unpublish-page-ik9a66Rz.js} +2 -2
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +23 -22
- package/dist/{web-preview-CvpevNzM.cjs → web-preview-CE39XTw0.cjs} +1 -1
- package/dist/{web-preview-BDgUTTr8.js → web-preview-ztlGD_Xm.js} +1 -1
- package/package.json +1 -1
- package/dist/index-B5qvHqN5.cjs +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),J=require("./index-EFWvSWoi.cjs"),p=require("./index-B5qvHqN5.cjs"),O=require("./use-page-expand-manager-B6XTvk0E.cjs"),n=require("lodash-es"),R=require("jotai"),v=require("lucide-react"),l=require("react"),re=require("react-i18next"),ae=require("./register-chai-top-bar-DWTuRU53.cjs"),K=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const s=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),s)||n.includes(n.toLower((a==null?void 0:a.slug)||""),s)})),le=(e,r)=>{const a=new Set,s=n.keyBy(e,"id");return r.forEach(c=>{let i=c;for(;i.parent&&s[i.parent];)a.add(i.parent),i=s[i.parent]}),Array.from(a).map(c=>s[c])},B=(e,r,a)=>n.isEmpty(r)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?B(s.children,r,a):[]};const c=s.children&&s.children.some(i=>n.includes(n.toLower(i.name||""),n.toLower(r))||n.includes(n.toLower(i.slug||""),n.toLower(r)));return{...s,shouldExpandOnSearch:c,children:s.children?B(s.children,r,a):[]}}),ie=e=>{if(!e||!e.length)return[];const r={};e.forEach(s=>{r[s.id]={...s,children:[]}});const a=[];return Object.values(r).forEach(s=>{s.parent&&r[s.parent]?r[s.parent].children.push(s):a.push(s)}),a},Z=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?Z(a.children):[]})),oe=(e,r,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))c=K(c,r);else{const f=K(c,r),u=le(e,f);c=n.uniqBy([...f,...u],"id")}const i=Z(ie(c)),y=B(i,r,s),k=n.filter(y,f=>s(f.pageType)).sort((f,u)=>(f.name||"").localeCompare(u.name||"")),m=n.filter(y,f=>!s(f.pageType));let P=[];if(a==="all"){const f=n.keyBy(m,"pageType");P=Object.values(n.mapValues(f,(u,g)=>({...u,id:g,name:n.startCase(g),isPartialGroup:!0,children:y.filter(w=>w.pageType===g)})))}else P=m.sort((f,u)=>(f.name||"").localeCompare(u.name||""));return[...k,...P]},ce=R.atom({pageId:null,position:{x:0,y:0}}),de=({pageId:e,children:r})=>{const[a,s]=R.useAtom(ce),c=l.useRef(null),i=a.pageId===e;l.useEffect(()=>{const m=()=>s({pageId:null,position:{x:0,y:0}});if(i)return document.addEventListener("click",m),()=>document.removeEventListener("click",m)},[i,s]);const y=m=>{m.preventDefault(),m.stopPropagation(),s({pageId:e,position:{x:m.clientX,y:m.clientY}})},k=()=>{const m=`${window.location.pathname}?page=${e}`;window.open(m,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:y,children:r}),i&&t.jsx("div",{ref:c,className:"fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",style:{top:a.position.y,left:a.position.x},children:t.jsx("div",{className:"",children:t.jsxs(ae.Button,{variant:"ghost",onClick:k,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(v.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},ue=({page:e})=>{var s,c;const{isExpanded:r,toggleExpanded:a}=O.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:i=>{i.stopPropagation(),a()},disabled:!((s=e==null?void 0:e.children)!=null&&s.length),className:`flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(c=e==null?void 0:e.children)!=null&&c.length?"hover:text-blue-400":"opacity-0"}`,children:t.jsx(v.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},me=({page:e,pageType:r})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(v.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?t.jsx("div",{className:"flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",dangerouslySetInnerHTML:{__html:r.icon}}):r!=null&&r.hasSlug?t.jsx(v.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(v.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),he=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),xe=({page:e,pageTypes:r,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:i,showUntranslatedPages:y})=>{const k=p.useUserId(),{pageToUser:m}=p.usePageToUser(),P=n.get(m,[e==null?void 0:e.id,"userId"]),{data:f}=p.useChaiUserInfo(P),u=f&&k!==P?f==null?void 0:f.name:null,g=p.useFallbackLang(),w=a===e.id,F=!!e.isTemplate,j=l.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]);let h=n.get(c,e==null?void 0:e.id);h=n.get(h,"lang")===i?h:null;const E=i===g||!!h,L=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let S=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const M=S+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!y){const d=S.split("/").pop();S=S.endsWith(d)&&e.dynamic?"":`/${d}`}const q=l.useMemo(()=>{const d="flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]",C=`${w?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${d} ${C} ${u?"opacity-60":""}`:`${d} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,w,u]),z=l.useMemo(()=>{if(e.isPartialGroup)return!1;if(h){if(!h.online||n.isEmpty(h.changes))return!1}else if(e&&(!e.online||n.isEmpty(e.changes)))return!1;return!0},[h,e]);return t.jsxs("div",{className:"group relative",children:[t.jsx(de,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:q,children:[t.jsx(ue,{page:e}),!e.isPartialGroup&&t.jsx(he,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(me,{page:e,pageType:j}),t.jsx(p.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(S||e.dynamic)&&t.jsx(p.Tooltip,{content:M,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[S,e.dynamic&&(j==null?void 0:j.dynamicSlug)&&t.jsxs("span",{className:"text-xs text-gray-500",children:["/",j==null?void 0:j.dynamicSlug,e.dynamicSlugCustom]})]})}),z&&t.jsx(p.Tooltip,{content:"Has unpublished changes",side:"top",children:t.jsx("span",{className:"text-amber-500",children:t.jsx(v.Pencil,{size:12,className:"stroke-[2]"})})}),F&&t.jsx(p.Tooltip,{content:"Template",side:"top",children:t.jsx("span",{className:"text-blue-500",children:t.jsx(v.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!u?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(p.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:d=>s("duplicate",d),setAddEditPage:d=>s("edit",h||d),setUnpublishPage:d=>s("unpublish",d),setDeletePage:d=>s("delete",h||d),setMarkAsTemplate:d=>s("markAsTemplate",d),setUnmarkAsTemplate:d=>s("unmarkAsTemplate",d),children:t.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:t.jsx(v.MoreHorizontal,{className:"h-4 w-4",onClick:d=>d.stopPropagation()})})})}):u?t.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:t.jsx(v.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]})}),t.jsx(t.Fragment,{children:u&&t.jsxs("button",{className:"absolute right-px top-1/2 flex h-6 -translate-y-1/2 items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100",children:[t.jsx(v.Edit,{size:12,className:"stroke-[3]"})," ",t.jsx("span",{className:"font-medium",children:u})," is editing this page"]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!u&&t.jsxs("button",{onClick:d=>{d.stopPropagation(),s("addLanguagePage",{language:i,page:e})},className:"absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",children:[t.jsx(v.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(p.LANGUAGES,i)," Page"]})]})})]})},ee=({pages:e,tier:r,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k})=>{const{expandedPages:m}=O.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(P=>t.jsxs(t.Fragment,{children:[t.jsx(xe,{page:P,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k}),P.children&&P.children.length>0&&(m==null?void 0:m.includes(P.id))&&t.jsx(ee,{pages:P.children,tier:r+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k})]},P.id))})},fe=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-CIspvIW2.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-dzN_CD2c.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-6lInxYM_.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-rYeBMwHR.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-Co00KkhA.cjs"))),je=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-C9EXTj0X.cjs"))),be=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-B5rev9W3.cjs"))),ve=({close:e})=>{const{t:r}=re.useTranslation(),{languages:a,setSelectedLang:s}=J.useLanguages(),{data:c}=p.usePageTypes(),{data:i,isFetching:y}=p.useWebsitePages(),[k,m]=p.useSearchParams(),{updateForSelectedPage:P,expandPagesOnSearch:f}=O.usePageExpandManager(null),u=p.useFallbackLang(),g=k.get("page"),[w,F]=l.useState(""),[j,h]=l.useState(null),[E,L]=l.useState(null),[S,M]=l.useState(null),[q,z]=l.useState(null),[d,C]=l.useState(""),[G,D]=l.useState(null),[W,H]=l.useState(null),[b,I]=l.useState(u),[te,se]=l.useState(!1),_=R.useSetAtom(p.addNewLangAtom),U=te&&b!==u,{data:A,isFetching:ne}=p.useWebsiteLanguagePages(b),V=l.useCallback(x=>{var o;return(o=n.find(c,{key:x}))==null?void 0:o.hasSlug},[c]),N=l.useMemo(()=>i?U?n.filter(i,x=>!(A!=null&&A[x.id])):oe(i,w,d,V):[],[i,V,w,d,A,U]);l.useEffect(()=>{s(u)},[u,s]),l.useEffect(()=>{const x=k.get("lang");if(x){const o=a,T=a[0]??u,Y=o.includes(x);l.startTransition(()=>{Y&&b!==x?I(x):!Y&&b!==T&&I(T)})}},[]),l.useEffect(()=>{if(!n.isEmpty(d))return;const x=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&x&&(n.find(c,{key:x})?C(x):C("all"))},[c,d]),l.useEffect(()=>{if(g&&!y&&!n.find(i,{id:g})){const o=n.find(i,{slug:"/"});if(o){const T=new URLSearchParams({page:o.id});p.navigateToPage(T,m)}else p.navigateToPage(new URLSearchParams({}),m,!0)}},[i,g,y,m]),l.useEffect(()=>{g&&!y&&!n.isEmpty(N)&&P(N,g)},[g,y,N,P]),l.useEffect(()=>{!n.isEmpty(w)&&!n.isEmpty(N)&&f(N)},[w,N,f]);const{setSelectedLang:$}=J.useLanguages(),Q=l.useCallback(x=>{const o=new URLSearchParams({page:x});b!==u?(o.set("lang",b),$(b)):$(""),p.navigateToPage(o,m),e()},[e,m,$,b,u]),X=(x,o)=>{var T;if(o)switch(x){case"add":L(o);break;case"select":Q(o);break;case"edit":b!==u?_({edit:!0,id:o==null?void 0:o.id,primaryPage:o==null?void 0:o.primaryPage}):L(o);break;case"delete":h(o);break;case"unpublish":M(o);break;case"markAsTemplate":z(o);break;case"unmarkAsTemplate":H(o);break;case"duplicate":D(o);break;case"addLanguagePage":_({edit:!1,primaryPage:((T=o==null?void 0:o.page)==null?void 0:T.id)||"",preselectedLang:(o==null?void 0:o.language)||b});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(l.Suspense,{children:t.jsx(fe,{pages:N,search:w,setSearch:F,languages:[u,...a],selectedLanguage:b,setSelectedLanguage:I,selectedPageType:d,setSelectedPageType:C,onAddPage:x=>X("add",x),showUntranslatedPages:U,setShowUntranslatedPages:se})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:y||ne?t.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],x=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},x))}):n.isEmpty(N)?t.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[t.jsx(v.File,{className:"h-6 w-6 stroke-[1]"}),r("Empty List!"),t.jsx("span",{className:"font-light",children:r("Add new page to start")})]}):t.jsx(ee,{tier:0,pages:N,pageTypes:c,currentPage:g||"",onClickAction:X,languagePages:A,selectedLanguage:b,showUntranslatedPages:U})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(pe,{closePanel:e,editPage:Q,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:j,onClose:()=>h(null)})}),S&&t.jsx(l.Suspense,{children:t.jsx(be,{page:S,onClose:()=>M(null)})}),q&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:q,onClose:()=>z(null)})}),W&&t.jsx(l.Suspense,{children:t.jsx(je,{page:W,onClose:()=>H(null)})}),G&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:G,onClose:()=>D(null),closePanel:e})})]})};exports.default=ve;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),J=require("./index-CfsIhbT2.cjs"),p=require("./index-BGGNVIKx.cjs"),O=require("./use-page-expand-manager-B6XTvk0E.cjs"),n=require("lodash-es"),R=require("jotai"),v=require("lucide-react"),l=require("react"),re=require("react-i18next"),ae=require("./register-chai-top-bar-DWTuRU53.cjs"),K=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const s=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),s)||n.includes(n.toLower((a==null?void 0:a.slug)||""),s)})),le=(e,r)=>{const a=new Set,s=n.keyBy(e,"id");return r.forEach(c=>{let i=c;for(;i.parent&&s[i.parent];)a.add(i.parent),i=s[i.parent]}),Array.from(a).map(c=>s[c])},B=(e,r,a)=>n.isEmpty(r)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?B(s.children,r,a):[]};const c=s.children&&s.children.some(i=>n.includes(n.toLower(i.name||""),n.toLower(r))||n.includes(n.toLower(i.slug||""),n.toLower(r)));return{...s,shouldExpandOnSearch:c,children:s.children?B(s.children,r,a):[]}}),ie=e=>{if(!e||!e.length)return[];const r={};e.forEach(s=>{r[s.id]={...s,children:[]}});const a=[];return Object.values(r).forEach(s=>{s.parent&&r[s.parent]?r[s.parent].children.push(s):a.push(s)}),a},Z=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?Z(a.children):[]})),oe=(e,r,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))c=K(c,r);else{const f=K(c,r),u=le(e,f);c=n.uniqBy([...f,...u],"id")}const i=Z(ie(c)),y=B(i,r,s),k=n.filter(y,f=>s(f.pageType)).sort((f,u)=>(f.name||"").localeCompare(u.name||"")),m=n.filter(y,f=>!s(f.pageType));let P=[];if(a==="all"){const f=n.keyBy(m,"pageType");P=Object.values(n.mapValues(f,(u,g)=>({...u,id:g,name:n.startCase(g),isPartialGroup:!0,children:y.filter(w=>w.pageType===g)})))}else P=m.sort((f,u)=>(f.name||"").localeCompare(u.name||""));return[...k,...P]},ce=R.atom({pageId:null,position:{x:0,y:0}}),de=({pageId:e,children:r})=>{const[a,s]=R.useAtom(ce),c=l.useRef(null),i=a.pageId===e;l.useEffect(()=>{const m=()=>s({pageId:null,position:{x:0,y:0}});if(i)return document.addEventListener("click",m),()=>document.removeEventListener("click",m)},[i,s]);const y=m=>{m.preventDefault(),m.stopPropagation(),s({pageId:e,position:{x:m.clientX,y:m.clientY}})},k=()=>{const m=`${window.location.pathname}?page=${e}`;window.open(m,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:y,children:r}),i&&t.jsx("div",{ref:c,className:"fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",style:{top:a.position.y,left:a.position.x},children:t.jsx("div",{className:"",children:t.jsxs(ae.Button,{variant:"ghost",onClick:k,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(v.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},ue=({page:e})=>{var s,c;const{isExpanded:r,toggleExpanded:a}=O.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:i=>{i.stopPropagation(),a()},disabled:!((s=e==null?void 0:e.children)!=null&&s.length),className:`flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(c=e==null?void 0:e.children)!=null&&c.length?"hover:text-blue-400":"opacity-0"}`,children:t.jsx(v.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},me=({page:e,pageType:r})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(v.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?t.jsx("div",{className:"flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",dangerouslySetInnerHTML:{__html:r.icon}}):r!=null&&r.hasSlug?t.jsx(v.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(v.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),he=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),xe=({page:e,pageTypes:r,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:i,showUntranslatedPages:y})=>{const k=p.useUserId(),{pageToUser:m}=p.usePageToUser(),P=n.get(m,[e==null?void 0:e.id,"userId"]),{data:f}=p.useChaiUserInfo(P),u=f&&k!==P?f==null?void 0:f.name:null,g=p.useFallbackLang(),w=a===e.id,F=!!e.isTemplate,j=l.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]);let h=n.get(c,e==null?void 0:e.id);h=n.get(h,"lang")===i?h:null;const E=i===g||!!h,L=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let S=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const M=S+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!y){const d=S.split("/").pop();S=S.endsWith(d)&&e.dynamic?"":`/${d}`}const q=l.useMemo(()=>{const d="flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]",C=`${w?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${d} ${C} ${u?"opacity-60":""}`:`${d} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,w,u]),z=l.useMemo(()=>{if(e.isPartialGroup)return!1;if(h){if(!h.online||n.isEmpty(h.changes))return!1}else if(e&&(!e.online||n.isEmpty(e.changes)))return!1;return!0},[h,e]);return t.jsxs("div",{className:"group relative",children:[t.jsx(de,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:q,children:[t.jsx(ue,{page:e}),!e.isPartialGroup&&t.jsx(he,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(me,{page:e,pageType:j}),t.jsx(p.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(S||e.dynamic)&&t.jsx(p.Tooltip,{content:M,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[S,e.dynamic&&(j==null?void 0:j.dynamicSlug)&&t.jsxs("span",{className:"text-xs text-gray-500",children:["/",j==null?void 0:j.dynamicSlug,e.dynamicSlugCustom]})]})}),z&&t.jsx(p.Tooltip,{content:"Has unpublished changes",side:"top",children:t.jsx("span",{className:"text-amber-500",children:t.jsx(v.Pencil,{size:12,className:"stroke-[2]"})})}),F&&t.jsx(p.Tooltip,{content:"Template",side:"top",children:t.jsx("span",{className:"text-blue-500",children:t.jsx(v.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!u?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(p.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:d=>s("duplicate",d),setAddEditPage:d=>s("edit",h||d),setUnpublishPage:d=>s("unpublish",d),setDeletePage:d=>s("delete",h||d),setMarkAsTemplate:d=>s("markAsTemplate",d),setUnmarkAsTemplate:d=>s("unmarkAsTemplate",d),children:t.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:t.jsx(v.MoreHorizontal,{className:"h-4 w-4",onClick:d=>d.stopPropagation()})})})}):u?t.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:t.jsx(v.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]})}),t.jsx(t.Fragment,{children:u&&t.jsxs("button",{className:"absolute right-px top-1/2 flex h-6 -translate-y-1/2 items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100",children:[t.jsx(v.Edit,{size:12,className:"stroke-[3]"})," ",t.jsx("span",{className:"font-medium",children:u})," is editing this page"]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!u&&t.jsxs("button",{onClick:d=>{d.stopPropagation(),s("addLanguagePage",{language:i,page:e})},className:"absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",children:[t.jsx(v.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(p.LANGUAGES,i)," Page"]})]})})]})},ee=({pages:e,tier:r,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k})=>{const{expandedPages:m}=O.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(P=>t.jsxs(t.Fragment,{children:[t.jsx(xe,{page:P,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k}),P.children&&P.children.length>0&&(m==null?void 0:m.includes(P.id))&&t.jsx(ee,{pages:P.children,tier:r+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k})]},P.id))})},fe=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-pWHXOgMJ.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-BJJqSKp0.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-BfsmsTek.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-g5hiQkrZ.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-DEThYoS6.cjs"))),je=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-D8wEsu9z.cjs"))),be=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-Cl2R_dfN.cjs"))),ve=({close:e})=>{const{t:r}=re.useTranslation(),{languages:a,setSelectedLang:s}=J.useLanguages(),{data:c}=p.usePageTypes(),{data:i,isFetching:y}=p.useWebsitePages(),[k,m]=p.useSearchParams(),{updateForSelectedPage:P,expandPagesOnSearch:f}=O.usePageExpandManager(null),u=p.useFallbackLang(),g=k.get("page"),[w,F]=l.useState(""),[j,h]=l.useState(null),[E,L]=l.useState(null),[S,M]=l.useState(null),[q,z]=l.useState(null),[d,C]=l.useState(""),[G,D]=l.useState(null),[W,H]=l.useState(null),[b,I]=l.useState(u),[te,se]=l.useState(!1),_=R.useSetAtom(p.addNewLangAtom),U=te&&b!==u,{data:A,isFetching:ne}=p.useWebsiteLanguagePages(b),V=l.useCallback(x=>{var o;return(o=n.find(c,{key:x}))==null?void 0:o.hasSlug},[c]),N=l.useMemo(()=>i?U?n.filter(i,x=>!(A!=null&&A[x.id])):oe(i,w,d,V):[],[i,V,w,d,A,U]);l.useEffect(()=>{s(u)},[u,s]),l.useEffect(()=>{const x=k.get("lang");if(x){const o=a,T=a[0]??u,Y=o.includes(x);l.startTransition(()=>{Y&&b!==x?I(x):!Y&&b!==T&&I(T)})}},[]),l.useEffect(()=>{if(!n.isEmpty(d))return;const x=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&x&&(n.find(c,{key:x})?C(x):C("all"))},[c,d]),l.useEffect(()=>{if(g&&!y&&!n.find(i,{id:g})){const o=n.find(i,{slug:"/"});if(o){const T=new URLSearchParams({page:o.id});p.navigateToPage(T,m)}else p.navigateToPage(new URLSearchParams({}),m,!0)}},[i,g,y,m]),l.useEffect(()=>{g&&!y&&!n.isEmpty(N)&&P(N,g)},[g,y,N,P]),l.useEffect(()=>{!n.isEmpty(w)&&!n.isEmpty(N)&&f(N)},[w,N,f]);const{setSelectedLang:$}=J.useLanguages(),Q=l.useCallback(x=>{const o=new URLSearchParams({page:x});b!==u?(o.set("lang",b),$(b)):$(""),p.navigateToPage(o,m),e()},[e,m,$,b,u]),X=(x,o)=>{var T;if(o)switch(x){case"add":L(o);break;case"select":Q(o);break;case"edit":b!==u?_({edit:!0,id:o==null?void 0:o.id,primaryPage:o==null?void 0:o.primaryPage}):L(o);break;case"delete":h(o);break;case"unpublish":M(o);break;case"markAsTemplate":z(o);break;case"unmarkAsTemplate":H(o);break;case"duplicate":D(o);break;case"addLanguagePage":_({edit:!1,primaryPage:((T=o==null?void 0:o.page)==null?void 0:T.id)||"",preselectedLang:(o==null?void 0:o.language)||b});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(l.Suspense,{children:t.jsx(fe,{pages:N,search:w,setSearch:F,languages:[u,...a],selectedLanguage:b,setSelectedLanguage:I,selectedPageType:d,setSelectedPageType:C,onAddPage:x=>X("add",x),showUntranslatedPages:U,setShowUntranslatedPages:se})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:y||ne?t.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],x=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},x))}):n.isEmpty(N)?t.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[t.jsx(v.File,{className:"h-6 w-6 stroke-[1]"}),r("Empty List!"),t.jsx("span",{className:"font-light",children:r("Add new page to start")})]}):t.jsx(ee,{tier:0,pages:N,pageTypes:c,currentPage:g||"",onClickAction:X,languagePages:A,selectedLanguage:b,showUntranslatedPages:U})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(pe,{closePanel:e,editPage:Q,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:j,onClose:()=>h(null)})}),S&&t.jsx(l.Suspense,{children:t.jsx(be,{page:S,onClose:()=>M(null)})}),q&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:q,onClose:()=>z(null)})}),W&&t.jsx(l.Suspense,{children:t.jsx(je,{page:W,onClose:()=>H(null)})}),G&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:G,onClose:()=>D(null),closePanel:e})})]})};exports.default=ve;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs as b, Fragment as F, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { d as oe } from "./index-
|
|
3
|
-
import {
|
|
2
|
+
import { d as oe } from "./index-iRqgNs2O.js";
|
|
3
|
+
import { aB as ye, aC as ge, ap as ke, k as de, T as D, aR as Ne, L as we, m as ve, g as Se, c as Le, av as Te, aS as Ae, aT as X } from "./index-ckjNCVor.js";
|
|
4
4
|
import { u as J } from "./use-page-expand-manager-Cf4MUEJw.js";
|
|
5
5
|
import { compact as ue, filter as B, isEmpty as k, uniqBy as Ce, keyBy as me, mapValues as Ee, startCase as Me, toLower as M, includes as _, get as W, find as z, map as Ue } from "lodash-es";
|
|
6
6
|
import { atom as Ie, useAtom as $e, useSetAtom as ze } from "jotai";
|
|
7
7
|
import { ExternalLink as Be, Pencil as Fe, NotepadText as Oe, MoreHorizontal as je, Lock as Ge, Edit as Re, Plus as De, ChevronRight as We, StarsIcon as He, Hash as _e, File as he } from "lucide-react";
|
|
8
|
-
import { useRef as qe, useEffect as E, useMemo as H, useState as v, useCallback as ie, startTransition as
|
|
9
|
-
import { useTranslation as
|
|
8
|
+
import { useRef as qe, useEffect as E, useMemo as H, useState as v, useCallback as ie, startTransition as Ve, Suspense as C, lazy as U } from "react";
|
|
9
|
+
import { useTranslation as Qe } from "react-i18next";
|
|
10
10
|
import { B as Xe } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
11
11
|
const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
12
12
|
B(e, (r) => {
|
|
@@ -152,7 +152,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
152
152
|
const g = ye(), { pageToUser: d } = ge(), x = W(d, [e == null ? void 0 : e.id, "userId"]), { data: h } = ke(x), c = h && g !== x ? h == null ? void 0 : h.name : null, p = de(), N = r === e.id, q = !!e.isTemplate, P = H(() => z(s, { key: e.pageType }), [s, e.pageType]);
|
|
153
153
|
let u = W(o, e == null ? void 0 : e.id);
|
|
154
154
|
u = W(u, "lang") === a ? u : null;
|
|
155
|
-
const L = a === p || !!u,
|
|
155
|
+
const L = a === p || !!u, T = (u == null ? void 0 : u.name) || (e == null ? void 0 : e.name) || "No name";
|
|
156
156
|
let w = (u == null ? void 0 : u.slug) || (e == null ? void 0 : e.slug) || "";
|
|
157
157
|
const O = w + (e != null && e.dynamic ? `/${P == null ? void 0 : P.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
|
|
158
158
|
if (w.startsWith("/") && !f) {
|
|
@@ -180,7 +180,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
180
180
|
/* @__PURE__ */ t(tt, { page: e }),
|
|
181
181
|
!e.isPartialGroup && /* @__PURE__ */ t(st, { isOnline: u ? u.online : e.online }),
|
|
182
182
|
!e.isPartialGroup && /* @__PURE__ */ t(nt, { page: e, pageType: P }),
|
|
183
|
-
/* @__PURE__ */ t(D, { content:
|
|
183
|
+
/* @__PURE__ */ t(D, { content: T, side: "top", showTooltip: T.length > 35, children: /* @__PURE__ */ t("span", { className: "max-w-[40%] truncate font-medium text-black", children: T }) }),
|
|
184
184
|
(w || e.dynamic) && /* @__PURE__ */ t(D, { content: O, side: "top", showTooltip: !0, children: /* @__PURE__ */ b("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
|
|
185
185
|
w,
|
|
186
186
|
e.dynamic && (P == null ? void 0 : P.dynamicSlug) && /* @__PURE__ */ b("span", { className: "text-xs text-gray-500", children: [
|
|
@@ -271,8 +271,8 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
271
271
|
}
|
|
272
272
|
)
|
|
273
273
|
] }, x.id)) });
|
|
274
|
-
}, at = U(() => import("./page-manager-search-and-filter-
|
|
275
|
-
const { t: s } =
|
|
274
|
+
}, at = U(() => import("./page-manager-search-and-filter-CCTh5gkC.js")), lt = U(() => import("./add-new-page-DUCKfyWo.js")), ot = U(() => import("./delete-page-BSn5mRvk.js")), it = U(() => import("./duplicate-page-BuVub6uY.js")), ct = U(() => import("./mark-as-template-BNbn5zQG.js")), dt = U(() => import("./unmark-as-template-DLVNotM_.js")), ut = U(() => import("./unpublish-page-ik9a66Rz.js")), Nt = ({ close: e }) => {
|
|
275
|
+
const { t: s } = Qe(), { languages: r, setSelectedLang: n } = oe(), { data: o } = ve(), { data: a, isFetching: f } = Se(), [g, d] = Le(), { updateForSelectedPage: x, expandPagesOnSearch: h } = J(null), c = de(), p = g.get("page"), [N, q] = v(""), [P, u] = v(null), [L, T] = v(null), [w, O] = v(null), [j, G] = v(null), [i, I] = v(""), [K, Z] = v(null), [ee, te] = v(null), [y, V] = v(c), [pe, Pe] = v(!1), ne = ze(Te), R = pe && y !== c, { data: $, isFetching: be } = Ae(y), se = ie(
|
|
276
276
|
(m) => {
|
|
277
277
|
var l;
|
|
278
278
|
return (l = z(o, { key: m })) == null ? void 0 : l.hasSlug;
|
|
@@ -284,9 +284,9 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
284
284
|
}, [c, n]), E(() => {
|
|
285
285
|
const m = g.get("lang");
|
|
286
286
|
if (m) {
|
|
287
|
-
const l = r,
|
|
288
|
-
|
|
289
|
-
le && y !== m ?
|
|
287
|
+
const l = r, A = r[0] ?? c, le = l.includes(m);
|
|
288
|
+
Ve(() => {
|
|
289
|
+
le && y !== m ? V(m) : !le && y !== A && V(A);
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
292
|
}, []), E(() => {
|
|
@@ -297,8 +297,8 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
297
297
|
if (p && !f && !z(a, { id: p })) {
|
|
298
298
|
const l = z(a, { slug: "/" });
|
|
299
299
|
if (l) {
|
|
300
|
-
const
|
|
301
|
-
X(
|
|
300
|
+
const A = new URLSearchParams({ page: l.id });
|
|
301
|
+
X(A, d);
|
|
302
302
|
} else
|
|
303
303
|
X(new URLSearchParams({}), d, !0);
|
|
304
304
|
}
|
|
@@ -307,18 +307,18 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
307
307
|
}, [p, f, S, x]), E(() => {
|
|
308
308
|
!k(N) && !k(S) && h(S);
|
|
309
309
|
}, [N, S, h]);
|
|
310
|
-
const { setSelectedLang:
|
|
310
|
+
const { setSelectedLang: Q } = oe(), re = ie(
|
|
311
311
|
(m) => {
|
|
312
312
|
const l = new URLSearchParams({ page: m });
|
|
313
|
-
y !== c ? (l.set("lang", y),
|
|
313
|
+
y !== c ? (l.set("lang", y), Q(y)) : Q(""), X(l, d), e();
|
|
314
314
|
},
|
|
315
|
-
[e, d,
|
|
315
|
+
[e, d, Q, y, c]
|
|
316
316
|
), ae = (m, l) => {
|
|
317
|
-
var
|
|
317
|
+
var A;
|
|
318
318
|
if (l)
|
|
319
319
|
switch (m) {
|
|
320
320
|
case "add":
|
|
321
|
-
|
|
321
|
+
T(l);
|
|
322
322
|
break;
|
|
323
323
|
case "select":
|
|
324
324
|
re(l);
|
|
@@ -328,7 +328,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
328
328
|
edit: !0,
|
|
329
329
|
id: l == null ? void 0 : l.id,
|
|
330
330
|
primaryPage: l == null ? void 0 : l.primaryPage
|
|
331
|
-
}) :
|
|
331
|
+
}) : T(l);
|
|
332
332
|
break;
|
|
333
333
|
case "delete":
|
|
334
334
|
u(l);
|
|
@@ -348,7 +348,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
348
348
|
case "addLanguagePage":
|
|
349
349
|
ne({
|
|
350
350
|
edit: !1,
|
|
351
|
-
primaryPage: ((
|
|
351
|
+
primaryPage: ((A = l == null ? void 0 : l.page) == null ? void 0 : A.id) || "",
|
|
352
352
|
preselectedLang: (l == null ? void 0 : l.language) || y
|
|
353
353
|
});
|
|
354
354
|
break;
|
|
@@ -364,7 +364,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
364
364
|
setSearch: q,
|
|
365
365
|
languages: [c, ...r],
|
|
366
366
|
selectedLanguage: y,
|
|
367
|
-
setSelectedLanguage:
|
|
367
|
+
setSelectedLanguage: V,
|
|
368
368
|
selectedPageType: i,
|
|
369
369
|
setSelectedPageType: I,
|
|
370
370
|
onAddPage: (m) => ae("add", m),
|
|
@@ -396,7 +396,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
396
396
|
closePanel: e,
|
|
397
397
|
editPage: re,
|
|
398
398
|
addEditPage: L,
|
|
399
|
-
setAddEditPage:
|
|
399
|
+
setAddEditPage: T
|
|
400
400
|
}
|
|
401
401
|
) }),
|
|
402
402
|
P && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(ot, { page: P, onClose: () => u(null) }) }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as a, Fragment as k } from "react/jsx-runtime";
|
|
2
2
|
import { B as m, z as E } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
-
import { x as g, y as b, z as y, S as L, A as F, B as I, E as N } from "./index-
|
|
4
|
-
import { k as j, L as T, m as $, A as B } from "./index-
|
|
3
|
+
import { x as g, y as b, z as y, S as L, A as F, B as I, E as N } from "./index-iRqgNs2O.js";
|
|
4
|
+
import { k as j, L as T, m as $, A as B } from "./index-ckjNCVor.js";
|
|
5
5
|
import { u as G } from "./use-page-expand-manager-Cf4MUEJw.js";
|
|
6
6
|
import { useQueryClient as D } from "@tanstack/react-query";
|
|
7
7
|
import { isEmpty as w, filter as x, map as S, get as o } from "lodash-es";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-DWTuRU53.cjs"),n=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-DWTuRU53.cjs"),n=require("./index-CfsIhbT2.cjs"),f=require("./index-BGGNVIKx.cjs"),w=require("./use-page-expand-manager-B6XTvk0E.cjs"),C=require("@tanstack/react-query"),s=require("lodash-es"),d=require("lucide-react"),S=require("react"),g=require("react-i18next"),k=({selectedPageType:l,setSelectedPageType:i})=>{const{t:a}=g.useTranslation(),[r,o]=S.useState(""),{data:c}=f.usePageTypes(),u=t=>{if(!r)return!0;const x=r.toLowerCase(),m=j=>String(s.get(t,j,"")).toLowerCase().includes(x);return m("name")||m("key")},p=c.find(t=>t.key===l);return e.jsxs(n.Select,{onValueChange:i,value:l,children:[e.jsx(n.SelectTrigger,{className:`${l==="all"?"bg-gray-100/30 hover:bg-gray-100":"gap-x-1 border bg-gray-100/30 hover:bg-gray-100"} h-9 w-max min-w-[150px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-gray-600 shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-1.5",children:[e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight",children:(p==null?void 0:p.name)||a("All")}),e.jsx(d.ListFilter,{className:`${l!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(n.SelectContent,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white pb-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(d.Search,{strokeWidth:2,className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400"}),e.jsx(h.Input,{placeholder:a("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:r,onChange:t=>o(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(n.SelectItem,{value:"all",children:a("All")}),!s.isEmpty(s.filter(c,t=>t.hasSlug&&u(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Pages")}),s.map([...s.filter(c,t=>t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),!s.isEmpty(s.filter(c,t=>!t.hasSlug&&u(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Partials")}),s.map([...s.filter(c,t=>!t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),s.isEmpty(s.filter(c,u))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:a("No matching page types found")})]})]})},T=({search:l,setSearch:i})=>{const{t:a}=g.useTranslation();return e.jsxs("div",{className:"relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5",children:[e.jsx("label",{htmlFor:"page-search-input",className:"sr-only",children:a("Search Pages")}),e.jsx(d.Search,{className:`${l?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(h.Input,{id:"page-search-input",placeholder:a("Search pages"),value:l,onChange:r=>i(r.target.value),className:"border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",autoComplete:"off"})]})},E=({pages:l})=>{const{t:i}=g.useTranslation(),{expandAll:a,collapseAll:r,expandedPages:o}=w.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"outline",size:"icon",onClick:()=>a(l),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsUpDown,{})})}),e.jsx(n.TooltipContent,{children:i("Expand All")})]}),e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{disabled:o.length===0,variant:"outline",size:"icon",onClick:()=>r(),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsDownUp,{})})}),e.jsx(n.TooltipContent,{children:i("Collapse All")})]})]})},b=({languages:l,selectedLanguage:i,setSelectedLanguage:a})=>{const r=f.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:l.map(o=>e.jsxs(h.Button,{variant:i===o?"default":"outline",size:"sm",className:`h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${i===o?"bg-black text-white hover:bg-black":"text-gray-500"}`,onClick:()=>a(o.toLowerCase()),children:[o===r&&e.jsx(d.Star,{size:4,className:`p-0.5 ${i===r?"fill-white":"fill-black"}`}),f.LANGUAGES[o]||""]},o))})},y=()=>{const{t:l}=g.useTranslation(),i=C.useQueryClient();return e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{size:"sm",variant:"ghost",onClick:()=>i.invalidateQueries({queryKey:[f.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(d.RefreshCw,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:l("Refresh pages list")})]})},q=({pages:l,search:i,setSearch:a,languages:r,onAddPage:o,selectedLanguage:c,setSelectedLanguage:u,selectedPageType:p,setSelectedPageType:t,showUntranslatedPages:x,setShowUntranslatedPages:m})=>{const{t:j}=g.useTranslation(),v=r.length>1;return e.jsxs("div",{className:"space-y-3 border-b border-b-gray-200 px-4 pb-1",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(k,{selectedPageType:p,setSelectedPageType:t}),e.jsx(T,{search:i,setSearch:a}),e.jsx(E,{pages:l}),e.jsxs(h.Button,{variant:"default",onClick:o,className:"rounded px-3 font-normal",children:[e.jsx(d.Plus,{strokeWidth:2,className:"stroke-white stroke-[3]"}),e.jsx("span",{className:"font-normal text-white",children:j("Add Page")})]}),!v&&e.jsx(y,{})]}),v?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(b,{languages:r,selectedLanguage:c,setSelectedLanguage:N=>{u(N),m(x&&(r==null?void 0:r[0])!==c)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(r==null?void 0:r[0])!==c&&e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"ghost",onClick:()=>m(!x),className:"h-6 rounded px-3 py-1 text-xs font-normal",children:x?e.jsx(d.FilterXIcon,{}):e.jsx(d.Filter,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:j("Toggle Untranslated Pages")})]}),e.jsx(y,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=b;exports.default=q;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-DWTuRU53.cjs"),i=require("./index-EFWvSWoi.cjs"),c=require("./index-B5qvHqN5.cjs"),y=require("@tanstack/react-query"),S=require("date-fns"),B=require("lodash-es"),f=require("lucide-react"),g=require("react");function L(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const w=L(g);function Q(s){const n=c.useApiUrl(),t=c.useFetch();return y.useQuery({queryKey:[c.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:c.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const z=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async r=>await n(s,{action:c.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async({revisionId:r,discardCurrent:l,pageId:d})=>await n(s,{action:c.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:r,discardCurrent:l,...d&&{pageId:d}}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=g.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-BeSMdSd5.cjs"))),b=({tag:s})=>s==="draft"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Draft"})]}):s==="live"?e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Live"})]}):s==="published"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-green-500/10 px-1.5 py-0.5 text-xs text-green-600",children:[e.jsx(f.Rocket,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Published"})]}):s==="unsaved"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[e.jsx(f.Save,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Unsaved changes"})]}):e.jsx("span",{className:"rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600",children:s});function J({compare:s,setCompare:n}){const{data:t}=c.useChaiCurrentPage(),{saveState:r}=i.useSavePage(),[l]=c.usePageEditInfo();if(!t)return null;const d=!!s.find(x=>{var a;return(a=x==null?void 0:x.uid)==null?void 0:a.startsWith("draft:")}),u=s.length>=2&&!d,m=r==="UNSAVED";return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border bg-primary/5 p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium leading-none",children:[e.jsx(b,{tag:"draft"}),e.jsx("span",{className:"text-xs font-bold",children:"Currently editing"})]})}),e.jsx("div",{className:"flex items-center pl-2 text-[11px] text-muted-foreground",children:!B.isEmpty(l.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",S.formatDistanceToNow(new Date(l.lastSaved),{addSuffix:!0})]})}),e.jsx("div",{className:"flex items-center gap-2 pt-0.5",children:m?e.jsx(b,{tag:"unsaved"}):null})]}),e.jsx(O,{checked:d,disabled:u,onChange:()=>{n(d?s.filter(x=>x.uid!==`draft:${t==null?void 0:t.id}`):[...s,{uid:`draft:${t==null?void 0:t.id}`,label:"draft",item:{createdAt:Date.now()}}])}})]})}function K(){return e.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((s,n)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(i.Skeleton,{className:"h-4 w-3/4"}),e.jsx(i.Skeleton,{className:"h-3 w-1/2"}),e.jsx(i.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(i.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function I({revision:s,isLatest:n,onRestore:t,onDelete:r,revisionNumber:l,compare:d,setCompare:u,pageId:m}){const{data:x}=c.useChaiUserInfo(s.currentEditor),a=(x==null?void 0:x.name)||"Unknown",p=!!d.find(h=>{var j;return n?(j=h==null?void 0:h.uid)==null?void 0:j.startsWith("live"):(h==null?void 0:h.uid)===s.uid}),D=d.length>=2&&!p;return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"flex items-center gap-1 text-xs leading-none",children:[e.jsx(b,{tag:n?"live":`#${l}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:a})]})}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s.type==="published"?e.jsx(b,{tag:"published"}):e.jsx(b,{tag:"draft"})}),e.jsx("div",{className:"flex items-center text-[10px] text-muted-foreground",children:e.jsx("span",{className:"leading-tight",children:S.format(s.createdAt,"MMM d, yyyy, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(c.PermissionChecker,{permissions:[c.PAGES_PERMISSIONS.RESTORE_REVISION,c.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:r})})}),e.jsx(O,{checked:p,disabled:D,onChange:()=>{u(p?d.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...d,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${l}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function A({tab:s,onRemove:n}){return e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(b,{tag:s.label}),e.jsx("button",{className:"z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",style:{lineHeight:1},onClick:()=>n(s.uid),"aria-label":"Remove selection",children:e.jsx(f.X,{className:"h-3 w-3"})})]})}function W({compare:s,setCompare:n,pageId:t}){const[r,l]=g.useState(!1),[d,u]=s;if(s.length===0)return null;const m=x=>n(s.filter(a=>a.uid!==x));return e.jsxs("div",{className:"mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-xs",children:[e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"Compare"}),d&&e.jsx(A,{tab:d,onRemove:m}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),u?e.jsx(A,{tab:u,onRemove:m}):e.jsx("span",{className:"rounded border px-1 text-xs text-muted-foreground",children:"Choose another"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-0.5 pt-2",children:[e.jsx(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none text-gray-500",variant:"outline",onClick:()=>n([]),children:e.jsx("span",{children:" Clear"})}),e.jsxs(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none",variant:"default",onClick:()=>l(!0),disabled:s.length<2,children:[e.jsx(f.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),r&&(s==null?void 0:s.length)>1&&t&&e.jsx(g.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx("span",{className:"text-sm",children:"Loading diff viewer..."})}),children:e.jsx($,{open:r,onOpenChange:l,compare:s})})]})}function O({checked:s,disabled:n,onChange:t,label:r="Compare"}){return e.jsx("div",{className:"absolute bottom-2 right-2",children:e.jsxs("label",{className:`flex cursor-pointer items-center gap-x-1 text-[11px] ${n?"opacity-50":""}`,children:[e.jsx("input",{type:"checkbox",className:"h-3 w-3 cursor-pointer rounded focus:ring-0 focus:ring-offset-0",checked:s,disabled:n,onChange:t}),e.jsx("span",{className:"select-none leading-tight",children:r})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(N.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(f.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(i.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(f.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(i.DropdownMenuSeparator,{}),e.jsxs(i.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(f.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function X({open:s,onOpenChange:n,revision:t,onRestore:r,isRestoring:l}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{l||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Restore Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",S.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>r(!1),disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(N.Button,{variant:"default",className:"sm:flex-1",onClick:()=>r(!0),disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Z({open:s,onOpenChange:n,revision:t,onDelete:r,isDeleting:l}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{l||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Delete Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",S.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>n(!1),disabled:l,children:"Cancel"}),e.jsx(N.Button,{variant:"destructive",className:"sm:flex-1",onClick:r,disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function ee({isOpen:s}){var R;const[n,t]=w.useState([]),[r,l]=w.useState(null),[d,u]=w.useState(!1),[m,x]=w.useState(!1),{data:a}=c.useChaiCurrentPage(),{data:p,isFetching:D,error:h,refetch:j}=Q(a==null?void 0:a.id),{mutate:T,isPending:M}=z(),{mutate:k,isPending:F}=H(),_=y.useQueryClient(),{selectedLang:q,fallbackLang:P}=i.useLanguages(),U=q||P;g.useEffect(()=>{g.startTransition(()=>t([]))},[a==null?void 0:a.id]);const G=o=>{r&&k({revisionId:r.uid,discardCurrent:o,...r.uid==="current"&&(a==null?void 0:a.id)&&{pageId:a.id}},{onSuccess:()=>{u(!1),l(null),_.invalidateQueries({queryKey:[c.ACTIONS.GET_DRAFT_PAGE]})}})},C=o=>{l(o),u(!0)},E=o=>{l(o),x(!0)},V=()=>{r&&T(r.uid,{onSuccess:()=>{x(!1),l(null)}})};return g.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(i.SheetHeader,{children:[e.jsx(i.SheetTitle,{children:"Revision History"}),(a==null?void 0:a.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",S.format(new Date(a.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),D?e.jsx(K,{}):h?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Failed to load revisions. Please try again."}):e.jsxs("div",{className:"mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2",children:[e.jsx(W,{lang:U,compare:n,setCompare:t,pageId:a==null?void 0:a.id}),e.jsx(J,{compare:n,setCompare:t}),(R=p==null?void 0:p.filter(o=>o.uid==="current"))==null?void 0:R.map((o,v)=>e.jsx(I,{pageId:a==null?void 0:a.id,revision:o,isLatest:!0,onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:v,compare:n,setCompare:t},o.uid)),e.jsx(i.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:[...p??[]].filter(o=>o.uid!=="current").sort((o,v)=>new Date(v.createdAt).getTime()-new Date(o.createdAt).getTime()).map((o,v)=>e.jsx(I,{pageId:a==null?void 0:a.id,revision:o,isLatest:o.uid==="current",onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:v+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(X,{open:d,onOpenChange:u,revision:r,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:x,revision:r,onDelete:V,isDeleting:M})]})}exports.default=ee;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-DWTuRU53.cjs"),i=require("./index-CfsIhbT2.cjs"),c=require("./index-BGGNVIKx.cjs"),y=require("@tanstack/react-query"),S=require("date-fns"),B=require("lodash-es"),f=require("lucide-react"),g=require("react");function L(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const w=L(g);function Q(s){const n=c.useApiUrl(),t=c.useFetch();return y.useQuery({queryKey:[c.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:c.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const z=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async r=>await n(s,{action:c.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async({revisionId:r,discardCurrent:l,pageId:d})=>await n(s,{action:c.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:r,discardCurrent:l,...d&&{pageId:d}}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=g.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-DheqS084.cjs"))),b=({tag:s})=>s==="draft"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Draft"})]}):s==="live"?e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Live"})]}):s==="published"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-green-500/10 px-1.5 py-0.5 text-xs text-green-600",children:[e.jsx(f.Rocket,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Published"})]}):s==="unsaved"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[e.jsx(f.Save,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Unsaved changes"})]}):e.jsx("span",{className:"rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600",children:s});function J({compare:s,setCompare:n}){const{data:t}=c.useChaiCurrentPage(),{saveState:r}=i.useSavePage(),[l]=c.usePageEditInfo();if(!t)return null;const d=!!s.find(x=>{var a;return(a=x==null?void 0:x.uid)==null?void 0:a.startsWith("draft:")}),u=s.length>=2&&!d,m=r==="UNSAVED";return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border bg-primary/5 p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium leading-none",children:[e.jsx(b,{tag:"draft"}),e.jsx("span",{className:"text-xs font-bold",children:"Currently editing"})]})}),e.jsx("div",{className:"flex items-center pl-2 text-[11px] text-muted-foreground",children:!B.isEmpty(l.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",S.formatDistanceToNow(new Date(l.lastSaved),{addSuffix:!0})]})}),e.jsx("div",{className:"flex items-center gap-2 pt-0.5",children:m?e.jsx(b,{tag:"unsaved"}):null})]}),e.jsx(O,{checked:d,disabled:u,onChange:()=>{n(d?s.filter(x=>x.uid!==`draft:${t==null?void 0:t.id}`):[...s,{uid:`draft:${t==null?void 0:t.id}`,label:"draft",item:{createdAt:Date.now()}}])}})]})}function K(){return e.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((s,n)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(i.Skeleton,{className:"h-4 w-3/4"}),e.jsx(i.Skeleton,{className:"h-3 w-1/2"}),e.jsx(i.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(i.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function I({revision:s,isLatest:n,onRestore:t,onDelete:r,revisionNumber:l,compare:d,setCompare:u,pageId:m}){const{data:x}=c.useChaiUserInfo(s.currentEditor),a=(x==null?void 0:x.name)||"Unknown",p=!!d.find(h=>{var j;return n?(j=h==null?void 0:h.uid)==null?void 0:j.startsWith("live"):(h==null?void 0:h.uid)===s.uid}),D=d.length>=2&&!p;return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"flex items-center gap-1 text-xs leading-none",children:[e.jsx(b,{tag:n?"live":`#${l}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:a})]})}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s.type==="published"?e.jsx(b,{tag:"published"}):e.jsx(b,{tag:"draft"})}),e.jsx("div",{className:"flex items-center text-[10px] text-muted-foreground",children:e.jsx("span",{className:"leading-tight",children:S.format(s.createdAt,"MMM d, yyyy, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(c.PermissionChecker,{permissions:[c.PAGES_PERMISSIONS.RESTORE_REVISION,c.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:r})})}),e.jsx(O,{checked:p,disabled:D,onChange:()=>{u(p?d.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...d,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${l}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function A({tab:s,onRemove:n}){return e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(b,{tag:s.label}),e.jsx("button",{className:"z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",style:{lineHeight:1},onClick:()=>n(s.uid),"aria-label":"Remove selection",children:e.jsx(f.X,{className:"h-3 w-3"})})]})}function W({compare:s,setCompare:n,pageId:t}){const[r,l]=g.useState(!1),[d,u]=s;if(s.length===0)return null;const m=x=>n(s.filter(a=>a.uid!==x));return e.jsxs("div",{className:"mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-xs",children:[e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"Compare"}),d&&e.jsx(A,{tab:d,onRemove:m}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),u?e.jsx(A,{tab:u,onRemove:m}):e.jsx("span",{className:"rounded border px-1 text-xs text-muted-foreground",children:"Choose another"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-0.5 pt-2",children:[e.jsx(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none text-gray-500",variant:"outline",onClick:()=>n([]),children:e.jsx("span",{children:" Clear"})}),e.jsxs(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none",variant:"default",onClick:()=>l(!0),disabled:s.length<2,children:[e.jsx(f.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),r&&(s==null?void 0:s.length)>1&&t&&e.jsx(g.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx("span",{className:"text-sm",children:"Loading diff viewer..."})}),children:e.jsx($,{open:r,onOpenChange:l,compare:s})})]})}function O({checked:s,disabled:n,onChange:t,label:r="Compare"}){return e.jsx("div",{className:"absolute bottom-2 right-2",children:e.jsxs("label",{className:`flex cursor-pointer items-center gap-x-1 text-[11px] ${n?"opacity-50":""}`,children:[e.jsx("input",{type:"checkbox",className:"h-3 w-3 cursor-pointer rounded focus:ring-0 focus:ring-offset-0",checked:s,disabled:n,onChange:t}),e.jsx("span",{className:"select-none leading-tight",children:r})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(N.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(f.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(i.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(f.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(i.DropdownMenuSeparator,{}),e.jsxs(i.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(f.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function X({open:s,onOpenChange:n,revision:t,onRestore:r,isRestoring:l}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{l||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Restore Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",S.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>r(!1),disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(N.Button,{variant:"default",className:"sm:flex-1",onClick:()=>r(!0),disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Z({open:s,onOpenChange:n,revision:t,onDelete:r,isDeleting:l}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{l||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Delete Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",S.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>n(!1),disabled:l,children:"Cancel"}),e.jsx(N.Button,{variant:"destructive",className:"sm:flex-1",onClick:r,disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function ee({isOpen:s}){var R;const[n,t]=w.useState([]),[r,l]=w.useState(null),[d,u]=w.useState(!1),[m,x]=w.useState(!1),{data:a}=c.useChaiCurrentPage(),{data:p,isFetching:D,error:h,refetch:j}=Q(a==null?void 0:a.id),{mutate:T,isPending:M}=z(),{mutate:k,isPending:F}=H(),_=y.useQueryClient(),{selectedLang:q,fallbackLang:P}=i.useLanguages(),U=q||P;g.useEffect(()=>{g.startTransition(()=>t([]))},[a==null?void 0:a.id]);const G=o=>{r&&k({revisionId:r.uid,discardCurrent:o,...r.uid==="current"&&(a==null?void 0:a.id)&&{pageId:a.id}},{onSuccess:()=>{u(!1),l(null),_.invalidateQueries({queryKey:[c.ACTIONS.GET_DRAFT_PAGE]})}})},C=o=>{l(o),u(!0)},E=o=>{l(o),x(!0)},V=()=>{r&&T(r.uid,{onSuccess:()=>{x(!1),l(null)}})};return g.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(i.SheetHeader,{children:[e.jsx(i.SheetTitle,{children:"Revision History"}),(a==null?void 0:a.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",S.format(new Date(a.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),D?e.jsx(K,{}):h?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Failed to load revisions. Please try again."}):e.jsxs("div",{className:"mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2",children:[e.jsx(W,{lang:U,compare:n,setCompare:t,pageId:a==null?void 0:a.id}),e.jsx(J,{compare:n,setCompare:t}),(R=p==null?void 0:p.filter(o=>o.uid==="current"))==null?void 0:R.map((o,v)=>e.jsx(I,{pageId:a==null?void 0:a.id,revision:o,isLatest:!0,onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:v,compare:n,setCompare:t},o.uid)),e.jsx(i.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:[...p??[]].filter(o=>o.uid!=="current").sort((o,v)=>new Date(v.createdAt).getTime()-new Date(o.createdAt).getTime()).map((o,v)=>e.jsx(I,{pageId:a==null?void 0:a.id,revision:o,isLatest:o.uid==="current",onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:v+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(X,{open:d,onOpenChange:u,revision:r,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:x,revision:r,onDelete:V,isDeleting:M})]})}exports.default=ee;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as a, Fragment as p, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { B as g } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
-
import { d as le, ab as re, ac as ie, a3 as de, ad as v, R as ce, D as G, e as j, f as q, g as L, p as
|
|
4
|
-
import { ar as C, as as A, A as y, aw as H,
|
|
3
|
+
import { d as le, ab as re, ac as ie, a3 as de, ad as v, R as ce, D as G, e as j, f as q, g as L, p as $, r as z, s as oe, t as ue, v as me, w as _, ae as he } from "./index-iRqgNs2O.js";
|
|
4
|
+
import { ar as C, as as A, A as y, aw as H, aA as fe, ap as I, ax as E, ay as D } from "./index-ckjNCVor.js";
|
|
5
5
|
import { useQuery as pe, useQueryClient as O, useMutation as J } from "@tanstack/react-query";
|
|
6
6
|
import { format as S, formatDistanceToNow as xe } from "date-fns";
|
|
7
7
|
import { isEmpty as ge } from "lodash-es";
|
|
@@ -50,7 +50,7 @@ const Ie = () => {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
|
-
}, Te = Ce(() => import("./json-diff-viewer-
|
|
53
|
+
}, Te = Ce(() => import("./json-diff-viewer-DAQ-qSHk.js")), N = ({ tag: t }) => t === "draft" ? /* @__PURE__ */ a("div", { className: "flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600", children: [
|
|
54
54
|
/* @__PURE__ */ a("span", { className: "relative flex h-2 w-2", children: [
|
|
55
55
|
/* @__PURE__ */ e("span", { className: "absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75" }),
|
|
56
56
|
/* @__PURE__ */ e("span", { className: "relative inline-flex h-2 w-2 rounded-full bg-amber-500" })
|
|
@@ -280,7 +280,7 @@ function Fe({
|
|
|
280
280
|
children: /* @__PURE__ */ a(j, { className: "sm:max-w-md", children: [
|
|
281
281
|
/* @__PURE__ */ a(q, { children: [
|
|
282
282
|
/* @__PURE__ */ e(L, { children: "Restore Revision" }),
|
|
283
|
-
/* @__PURE__ */ a(
|
|
283
|
+
/* @__PURE__ */ a($, { children: [
|
|
284
284
|
"You are about to restore to revision ",
|
|
285
285
|
n.uid.substring(0, 8),
|
|
286
286
|
" from",
|
|
@@ -291,7 +291,7 @@ function Fe({
|
|
|
291
291
|
] })
|
|
292
292
|
] }),
|
|
293
293
|
/* @__PURE__ */ e("div", { className: "py-2", children: /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "How would you like to handle your current edits?" }) }),
|
|
294
|
-
/* @__PURE__ */ a(
|
|
294
|
+
/* @__PURE__ */ a(z, { className: "flex flex-col gap-2 sm:flex-row", children: [
|
|
295
295
|
/* @__PURE__ */ e(g, { variant: "outline", className: "sm:flex-1", onClick: () => i(!1), disabled: r, children: r ? /* @__PURE__ */ a(p, { children: [
|
|
296
296
|
/* @__PURE__ */ e("span", { className: "mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
|
|
297
297
|
"Saving as draft..."
|
|
@@ -329,7 +329,7 @@ function Ve({
|
|
|
329
329
|
children: /* @__PURE__ */ a(j, { className: "sm:max-w-md", children: [
|
|
330
330
|
/* @__PURE__ */ a(q, { children: [
|
|
331
331
|
/* @__PURE__ */ e(L, { children: "Delete Revision" }),
|
|
332
|
-
/* @__PURE__ */ a(
|
|
332
|
+
/* @__PURE__ */ a($, { children: [
|
|
333
333
|
"You are about to delete revision ",
|
|
334
334
|
n.uid.substring(0, 8),
|
|
335
335
|
" from",
|
|
@@ -340,7 +340,7 @@ function Ve({
|
|
|
340
340
|
] })
|
|
341
341
|
] }),
|
|
342
342
|
/* @__PURE__ */ e("div", { className: "py-2", children: /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "This action cannot be undone. Are you sure you want to proceed?" }) }),
|
|
343
|
-
/* @__PURE__ */ a(
|
|
343
|
+
/* @__PURE__ */ a(z, { className: "flex flex-col gap-2 sm:flex-row", children: [
|
|
344
344
|
/* @__PURE__ */ e(g, { variant: "outline", className: "sm:flex-1", onClick: () => s(!1), disabled: r, children: "Cancel" }),
|
|
345
345
|
/* @__PURE__ */ e(g, { variant: "destructive", className: "sm:flex-1", onClick: i, disabled: r, children: r ? /* @__PURE__ */ a(p, { children: [
|
|
346
346
|
/* @__PURE__ */ e("span", { className: "mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
|
package/dist/pages.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BGGNVIKx.cjs");exports.ChaiJsonInput=e.SmartJsonInput;exports.ChaiWebsiteBuilder=e.ChaiWebsiteBuilder;exports.ImagePicker=e.ImagePicker;exports.LanguageSwitcher=e.LanguageSwitcher;exports.NestedPathSelector=e.NestedPathSelector;exports.PermissionChecker=e.PermissionChecker;exports.SupabaseRealtimeAdapter=e.SupabaseRealtimeAdapter;exports.createRealtimeAdapter=e.createRealtimeAdapter;exports.useActivePage=e.useActivePage;exports.useApiUrl=e.useApiUrl;exports.useBuilderFetch=e.useBuilderFetch;exports.useBuilderPageData=e.useBuilderPageData;exports.useChaiAuth=e.useChaiAuth;exports.useChaiCurrentPage=e.useChaiCurrentPage;exports.useChaiUserInfo=e.useChaiUserInfo;exports.useClearAll=e.useClearAll;exports.useFallbackLang=e.useFallbackLang;exports.useFetch=e.useFetch;exports.useGotoPage=e.useGotoPage;exports.useLanguagePages=e.useLanguagePages;exports.usePageTypes=e.usePageTypes;exports.useRealtimeAdapter=e.useRealtimeAdapter;exports.useReloadPage=e.useReloadPage;exports.useUpdateActivePageMetadata=e.useUpdateActivePageMetadata;exports.useUserPermissions=e.useUserRoleAndPermissions;exports.useWebsitePages=e.useWebsitePages;exports.useWebsiteSetting=e.useWebsiteSetting;
|
package/dist/pages.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aF as s, aU as t, aQ as u, aO as i, aP as r, ax as g, b1 as l, b2 as P, aV as h, ar as c, v as d, aL as n, a$ as o, aw as p, ap as b, aW as m, k as A, as as C, aX as U, l as k, m as F, a_ as L, aY as R, aZ as S, b0 as W, g as v, j as B } from "./index-ckjNCVor.js";
|
|
2
2
|
export {
|
|
3
3
|
s as ChaiJsonInput,
|
|
4
4
|
t as ChaiWebsiteBuilder,
|
|
@@ -14,17 +14,17 @@ export {
|
|
|
14
14
|
n as useBuilderPageData,
|
|
15
15
|
o as useChaiAuth,
|
|
16
16
|
p as useChaiCurrentPage,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
b as useChaiUserInfo,
|
|
18
|
+
m as useClearAll,
|
|
19
|
+
A as useFallbackLang,
|
|
20
|
+
C as useFetch,
|
|
21
21
|
U as useGotoPage,
|
|
22
22
|
k as useLanguagePages,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
F as usePageTypes,
|
|
24
|
+
L as useRealtimeAdapter,
|
|
25
|
+
R as useReloadPage,
|
|
26
|
+
S as useUpdateActivePageMetadata,
|
|
27
|
+
W as useUserPermissions,
|
|
28
|
+
v as useWebsitePages,
|
|
29
|
+
B as useWebsiteSetting
|
|
30
30
|
};
|
|
@@ -153,15 +153,15 @@ const E = (e) => {
|
|
|
153
153
|
}) => {
|
|
154
154
|
const r = e;
|
|
155
155
|
return `:root {
|
|
156
|
-
${F && e.fontFamily
|
|
157
|
-
`)}
|
|
158
|
-
${r.borderRadius
|
|
159
|
-
${r.colors
|
|
160
|
-
`)}
|
|
156
|
+
${F && e.fontFamily ? Object.entries(e.fontFamily).map(([t, n]) => `--font-${t}: ${E(n)};`).join(`
|
|
157
|
+
`) : ""}
|
|
158
|
+
${r.borderRadius ? `--radius: ${r.borderRadius};` : ""}
|
|
159
|
+
${r.colors ? Object.entries(r.colors).map(([t, n]) => `--${t}: ${m(n[0])};`).join(`
|
|
160
|
+
`) : ""}
|
|
161
161
|
}
|
|
162
162
|
.dark {
|
|
163
|
-
${r.colors
|
|
164
|
-
`)}
|
|
163
|
+
${r.colors ? Object.entries(r.colors).map(([t, n]) => `--${t}: ${m(n[1])};`).join(`
|
|
164
|
+
`) : ""}
|
|
165
165
|
}`;
|
|
166
166
|
}, S = (e) => !e || e.length === 0 ? "" : s(e, "family").map((F) => `<link rel="stylesheet" href="${F.url}" />`).join(`
|
|
167
167
|
`), T = (e) => !e || e.length === 0 ? [] : s(e, "family").map((F) => F.url), D = (e) => !e || e.length === 0 ? "" : s(e, "family").map((F) => `@import url("${F.url}");`).join(`
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";const a=require("lodash-es"),$=require("./fonts-B-Xt29pe.cjs"),b=require("./_commonjsHelpers-DwGv2jUC.cjs"),B={fontFamily:{"font-heading":"Inter","font-body":"Inter"},borderRadius:"10px",colors:[{group:"Body",items:{background:["#FFFFFF","#121212"],foreground:["#121212","#FFFFFF"]}},{group:"Primary",items:{primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"]}},{group:"Secondary",items:{secondary:["#F3F4F6","#374151"],"secondary-foreground":["#1F2937","#F9FAFB"]}},{group:"Border, Input & Ring",items:{border:["#E5E7EB","#374151"],input:["#E5E7EB","#374151"],ring:["#2563EB","#3B82F6"]}},{group:"Card",items:{card:["#FFFFFF","#1F2937"],"card-foreground":["#121212","#FFFFFF"]}},{group:"Popover",items:{popover:["#FFFFFF","#1F2937"],"popover-foreground":["#121212","#FFFFFF"]}},{group:"Muted",items:{muted:["#F3F4F6","#374151"],"muted-foreground":["#6B7280","#9CA3AF"]}},{group:"Accent",items:{accent:["#F3F4F6","#374151"],"accent-foreground":["#1F2937","#FFFFFF"]}},{group:"Destructive",items:{destructive:["#DC2626","#EF4444"],"destructive-foreground":["#FFFFFF","#FFFFFF"]}}]},v={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"6px",colors:{background:["#FFFFFF","#09090B"],foreground:["#09090B","#FFFFFF"],primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"],secondary:["#F4F4F5","#27272A"],"secondary-foreground":["#09090B","#FFFFFF"],muted:["#F4F4F5","#27272A"],"muted-foreground":["#71717A","#A1A1AA"],accent:["#F4F4F5","#27272A"],"accent-foreground":["#09090B","#FFFFFF"],destructive:["#EF4444","#7F1D1D"],"destructive-foreground":["#FFFFFF","#FFFFFF"],border:["#E4E4E7","#27272A"],input:["#E4E4E7","#27272A"],ring:["#2563EB","#3B82F6"],card:["#FFFFFF","#09090B"],"card-foreground":["#09090B","#FFFFFF"],popover:["#FFFFFF","#09090B"],"popover-foreground":["#09090B","#FFFFFF"]}},_=e=>({fontFamily:e.fontFamily?a.keys(e.fontFamily).reduce((r,t)=>({...r,[t.replace("font-","")]:`var(--${t})`}),{}):{},borderRadius:e.borderRadius?{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}:{},colors:e.colors?a.flatten(e.colors.map(r=>Object.entries(r.items))).reduce((r,[t])=>({...r,[t]:`hsl(var(--${t}))`}),{}):{}});function m(e){const F=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=parseInt(F[1],16),t=parseInt(F[2],16),n=parseInt(F[3],16);r/=255,t/=255,n/=255;const o=Math.max(r,t,n),u=Math.min(r,t,n);let i=0,l=0;const g=(o+u)/2;if(o==u)i=l=0;else{const s=o-u;switch(l=g>.5?s/(2-o-u):s/(o+u),o){case r:i=(t-n)/s+(t<n?6:0);break;case t:i=(n-r)/s+2;break;case n:i=(r-t)/s+4;break}i/=6}return`${Math.round(i*360)} ${Math.round(l*100)}% ${Math.round(g*100)}%`}const E=e=>{const r=$.getAllRegisteredFonts().find(t=>t.family===e);return`"${e}", ${a.get(r,"fallback","")}`},C=({theme:e,fontVariables:F=!1})=>{const r=e;return`:root {
|
|
2
|
-
${F&&e.fontFamily
|
|
3
|
-
`)}
|
|
4
|
-
${r.borderRadius
|
|
5
|
-
${r.colors
|
|
6
|
-
`)}
|
|
2
|
+
${F&&e.fontFamily?Object.entries(e.fontFamily).map(([t,n])=>`--font-${t}: ${E(n)};`).join(`
|
|
3
|
+
`):""}
|
|
4
|
+
${r.borderRadius?`--radius: ${r.borderRadius};`:""}
|
|
5
|
+
${r.colors?Object.entries(r.colors).map(([t,n])=>`--${t}: ${m(n[0])};`).join(`
|
|
6
|
+
`):""}
|
|
7
7
|
}
|
|
8
8
|
.dark {
|
|
9
|
-
${r.colors
|
|
10
|
-
`)}
|
|
9
|
+
${r.colors?Object.entries(r.colors).map(([t,n])=>`--${t}: ${m(n[1])};`).join(`
|
|
10
|
+
`):""}
|
|
11
11
|
}`},P=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(F=>`<link rel="stylesheet" href="${F.url}" />`).join(`
|
|
12
12
|
`),A=e=>!e||e.length===0?[]:a.uniqBy(e,"family").map(F=>F.url),j=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(F=>`@import url("${F.url}");`).join(`
|
|
13
13
|
`),q=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(F=>F.src.map(r=>`@font-face {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsxs as n, jsx as t, Fragment as $ } from "react/jsx-runtime";
|
|
2
|
-
import { B as
|
|
3
|
-
import { e as K, f as Q, g as J, p as V, r as W } from "./index-
|
|
4
|
-
import { ar as X, as as Y, A as I,
|
|
5
|
-
import { LanguageSelector as ae } from "./page-manager-search-and-filter-
|
|
2
|
+
import { B as A } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
+
import { e as K, f as Q, g as J, p as V, r as W } from "./index-iRqgNs2O.js";
|
|
4
|
+
import { ar as X, as as Y, A as I, aB as q, aC as Z, k as ee, m as te, ap as se, T as U, t as le } from "./index-ckjNCVor.js";
|
|
5
|
+
import { LanguageSelector as ae } from "./page-manager-search-and-filter-CCTh5gkC.js";
|
|
6
6
|
import { useQuery as ne } from "@tanstack/react-query";
|
|
7
|
-
import { find as B, filter as a, map as b, keys as re, get as F, includes as
|
|
7
|
+
import { find as B, filter as a, map as b, keys as re, get as F, includes as P, orderBy as N, isEmpty as oe, uniq as G, first as ce, concat as ie } from "lodash-es";
|
|
8
8
|
import { Lock as de, GlobeIcon as ue, File as me, Edit as he } from "lucide-react";
|
|
9
9
|
import { useState as D, useCallback as ge, useMemo as p, useEffect as j, startTransition as O } from "react";
|
|
10
10
|
const pe = () => {
|
|
@@ -25,7 +25,7 @@ const pe = () => {
|
|
|
25
25
|
o ? /* @__PURE__ */ t(de, { className: "h-4 w-4 fill-red-200 text-red-500" }) : /* @__PURE__ */ t(
|
|
26
26
|
"input",
|
|
27
27
|
{
|
|
28
|
-
checked:
|
|
28
|
+
checked: P(d, s == null ? void 0 : s.id),
|
|
29
29
|
onClick: (x) => {
|
|
30
30
|
x.stopPropagation(), k(s == null ? void 0 : s.id);
|
|
31
31
|
},
|
|
@@ -67,7 +67,7 @@ const pe = () => {
|
|
|
67
67
|
), S = p(
|
|
68
68
|
() => a(c, (e) => !y.includes(e.pageType)),
|
|
69
69
|
[c, y]
|
|
70
|
-
),
|
|
70
|
+
), C = p(
|
|
71
71
|
() => a(c, (e) => y.includes(e.pageType)),
|
|
72
72
|
[c, y]
|
|
73
73
|
);
|
|
@@ -76,12 +76,12 @@ const pe = () => {
|
|
|
76
76
|
O(() => u(e));
|
|
77
77
|
}, [c]), j(() => {
|
|
78
78
|
const e = a(re(m), (l) => F(m, [l, "userId"]) !== f);
|
|
79
|
-
O(() => u((l) => a(l, (g) => !
|
|
79
|
+
O(() => u((l) => a(l, (g) => !P(e, g))));
|
|
80
80
|
}, [m, f]);
|
|
81
|
-
const
|
|
82
|
-
u((l) =>
|
|
81
|
+
const L = r.length === (c == null ? void 0 : c.length), H = (e) => {
|
|
82
|
+
u((l) => P(l, e) ? a(l, (g) => g !== e) : ie(l, e));
|
|
83
83
|
}, z = () => {
|
|
84
|
-
u(
|
|
84
|
+
u(L ? [] : b(c, "id"));
|
|
85
85
|
}, M = () => {
|
|
86
86
|
k(
|
|
87
87
|
{ ids: G(r) },
|
|
@@ -99,14 +99,14 @@ const pe = () => {
|
|
|
99
99
|
const e = [
|
|
100
100
|
{ label: "Updated", top: "pt-2" },
|
|
101
101
|
...N(a(S, { online: !0 }), "pageType"),
|
|
102
|
-
...N(a(
|
|
102
|
+
...N(a(C, { online: !0 }), "pageType")
|
|
103
103
|
].filter((g) => g.pageType !== "theme"), l = [
|
|
104
104
|
{ label: "Offline", top: "pt-6" },
|
|
105
105
|
...N(a(S, { online: !1 }), "pageType"),
|
|
106
|
-
...N(a(
|
|
106
|
+
...N(a(C, { online: !1 }), "pageType")
|
|
107
107
|
];
|
|
108
108
|
return [...e, ...l];
|
|
109
|
-
}, [S,
|
|
109
|
+
}, [S, C]);
|
|
110
110
|
return /* @__PURE__ */ n(K, { className: "flex max-h-[80%] max-w-4xl flex-col", children: [
|
|
111
111
|
/* @__PURE__ */ n(Q, { children: [
|
|
112
112
|
/* @__PURE__ */ t(J, { children: "Publish changes" }),
|
|
@@ -131,7 +131,7 @@ const pe = () => {
|
|
|
131
131
|
/* @__PURE__ */ t(
|
|
132
132
|
"input",
|
|
133
133
|
{
|
|
134
|
-
checked:
|
|
134
|
+
checked: L,
|
|
135
135
|
onClick: (e) => {
|
|
136
136
|
e.stopPropagation(), z();
|
|
137
137
|
},
|
|
@@ -169,8 +169,8 @@ const pe = () => {
|
|
|
169
169
|
r.length !== 1 ? "s" : "",
|
|
170
170
|
" Selected"
|
|
171
171
|
] }),
|
|
172
|
-
/* @__PURE__ */ t(
|
|
173
|
-
/* @__PURE__ */ t(
|
|
172
|
+
/* @__PURE__ */ t(A, { disabled: d, variant: "outline", onClick: s, children: "Cancel" }),
|
|
173
|
+
/* @__PURE__ */ t(A, { disabled: d || v || oe(r), onClick: M, children: d ? "Publishing..." : "Publish Selected" })
|
|
174
174
|
] })
|
|
175
175
|
] });
|
|
176
176
|
};
|