@chaibuilder/pages 0.13.3 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{2AITGKQY-DpAgk_u8.cjs → 2AITGKQY-BLi5HVHf.cjs} +1 -1
- package/dist/{2AITGKQY-Dx_Cte-P.js → 2AITGKQY-iyhQ7kgG.js} +5 -5
- package/dist/{NCMVHL6D-B6lv7Umq.cjs → NCMVHL6D-CKYg8-AM.cjs} +1 -1
- package/dist/{NCMVHL6D-CT2qHOTS.js → NCMVHL6D-PLvSyK5P.js} +2 -2
- package/dist/{ZDWCUMSJ-C1vrgsti.cjs → ZDWCUMSJ-BJZ_Yi-4.cjs} +1 -1
- package/dist/{ZDWCUMSJ-W9xywtZH.js → ZDWCUMSJ-CuLkdxY-.js} +1 -1
- package/dist/add-new-language-page--ah9yzN3.cjs +1 -0
- package/dist/add-new-language-page-WM_Ve2vH.js +390 -0
- package/dist/add-new-page-Bs_NXM9x.js +30 -0
- package/dist/add-new-page-CnUo6xzd.cjs +1 -0
- package/dist/confetti.module-BuUnQuWk.cjs +2 -0
- package/dist/confetti.module-DCmCkDyV.js +409 -0
- package/dist/delete-page-Cf88UkqJ.cjs +1 -0
- package/dist/delete-page-D8xhYESu.js +38 -0
- package/dist/digital-asset-manager-BAFTqxsM.js +976 -0
- package/dist/digital-asset-manager-D_lcprwY.cjs +1 -0
- package/dist/duplicate-page-BX1gOez-.cjs +1 -0
- package/dist/duplicate-page-CqXTGmWt.js +120 -0
- package/dist/dynamic-page-selector-0TiUnfUg.js +86 -0
- package/dist/dynamic-page-selector-9JIQrcq5.cjs +1 -0
- package/dist/get-seo-defaults-9zHebckY.js +65 -0
- package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
- package/dist/image-compression-DZ9WMmyn.cjs +1 -0
- package/dist/image-compression-DsZ1oqpb.js +37 -0
- package/dist/index-D7kegQ3M.js +5153 -0
- package/dist/index-LU0FTfeN.cjs +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -22
- package/dist/index.js +20 -21
- package/dist/json-diff-viewer-Be-PVOZN.cjs +8 -0
- package/dist/json-diff-viewer-C2GK_BDh.js +258 -0
- package/dist/lang-panel-CPFS1ssC.js +218 -0
- package/dist/lang-panel-CePltxo2.cjs +1 -0
- package/dist/mark-as-template-DeB23sWR.cjs +1 -0
- package/dist/mark-as-template-jdwcgRIB.js +146 -0
- package/dist/nested-path-selector-content-D_iF9Sm3.cjs +1 -0
- package/dist/nested-path-selector-content-DvIL_EoN.js +87 -0
- package/dist/no-language-page-content-DUM4KxWu.js +35 -0
- package/dist/no-language-page-content-Dsm2H3pc.cjs +1 -0
- package/dist/page-creator-BjuYmKfc.js +796 -0
- package/dist/page-creator-DG0LwvL1.cjs +1 -0
- package/dist/page-lock-request-B9WPmFcd.cjs +1 -0
- package/dist/page-lock-request-BceB1S-X.js +64 -0
- package/dist/page-locked-by-dialog-2MULM3jh.cjs +1 -0
- package/dist/page-locked-by-dialog-BEWfFLSc.js +63 -0
- package/dist/page-manager-new-BONZN4c5.cjs +1 -0
- package/dist/page-manager-new-DV6A9WFv.js +354 -0
- package/dist/page-manager-search-and-filter-3h4URMP_.cjs +1 -0
- package/dist/page-manager-search-and-filter-DIiowi9F.js +197 -0
- package/dist/page-revisions-content-BIxeZeND.js +446 -0
- package/dist/page-revisions-content-CQbt25XX.cjs +1 -0
- package/dist/publish-pages-content-CdKHrfys.js +178 -0
- package/dist/publish-pages-content-im9dPOBM.cjs +1 -0
- package/dist/save-to-lib-DGII9CEP.js +476 -0
- package/dist/save-to-lib-DOh-850u.cjs +1 -0
- package/dist/seo-panel-2VdpoGSg.cjs +1 -0
- package/dist/seo-panel-Bxo4f-a_.js +667 -0
- package/dist/shared-json-ld-C1OewNgp.cjs +1 -0
- package/dist/shared-json-ld-gbnBFljN.js +337 -0
- package/dist/slug-input-BmcGmc_i.js +87 -0
- package/dist/slug-input-CfuQV97Z.cjs +1 -0
- package/dist/theme-panel-footer-D3SwHqGR.js +25 -0
- package/dist/theme-panel-footer-FrY4U8zn.cjs +1 -0
- package/dist/translation-warning-modal-DalBhNQy.js +26 -0
- package/dist/translation-warning-modal-Kctu12rQ.cjs +1 -0
- package/dist/unmark-as-template-CihtTMOb.cjs +1 -0
- package/dist/unmark-as-template-UwmCCn0u.js +38 -0
- package/dist/unpublish-page-CNwIU6AS.js +26 -0
- package/dist/unpublish-page-DzLtZcNw.cjs +1 -0
- package/dist/use-page-expand-manager-B7JtHdg5.cjs +1 -0
- package/dist/use-page-expand-manager-BCFQnVkT.js +85 -0
- package/package.json +3 -3
- package/dist/index-C4j31Yhz.js +0 -11471
- package/dist/index-DnjETHks.cjs +0 -6
- package/dist/page-revisions-content-Gx-Qf_91.cjs +0 -8
- package/dist/page-revisions-content-_-Nd4U11.js +0 -712
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("@chaibuilder/sdk/ui"),i=require("react"),$=require("./slug-input-CfuQV97Z.cjs"),Y=require("@chaibuilder/sdk"),b=require("lodash-es"),C=require("lucide-react"),w=require("./index-LU0FTfeN.cjs"),je=require("@tanstack/react-query"),J=require("sonner"),fe=require("./get-seo-defaults-Cw7vFt-B.cjs");function Ue({value:t,onChange:c,placeholder:j="Enter custom slug part",dynamicPattern:p,onValidationChange:o}){const[f,m]=i.useState(null),h=i.useRef(null),[g,L]=i.useState(p+t);i.useEffect(()=>{L(p+t)},[t,p]);const B=v=>{const S=v.target.value;if(!S.startsWith(p)){const O=S.replace(p,""),R=p+O;L(R),c(O);return}const l=S.substring(p.length).replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),a=(l.match(/\./g)||[]).length,x=a<=1;a>1?m("Invalid slug. Only one dot (.) is allowed in the slug"):m(null),o&&o(x);const y=p+l;L(y),c(l)},N=()=>{if(h.current){const v=h.current;setTimeout(()=>{const S=p.length;v.setSelectionRange(S,S)},0)}},W=v=>{const S=v.currentTarget;(S.selectionStart||0)<=p.length&&setTimeout(()=>{const l=p.length;S.setSelectionRange(l,l)},0)};return e.jsx("div",{children:e.jsxs("div",{className:"relative",children:[e.jsxs("p",{className:"text-gray-500 text-xs mb-2",children:[`${p}`," is a dynamic segment of slug"]}),e.jsx(n.Input,{ref:h,value:g,onChange:B,onFocus:N,onClick:W,placeholder:j,className:f?"border-red-500":""}),f&&e.jsx("div",{className:"text-red-500 text-xs mt-1",children:f})]})})}const X=({children:t,onWheel:c,...j})=>{const p=o=>{try{o.preventDefault();const f=o.currentTarget;f.scrollTop+=o.deltaY}catch{o.preventDefault()}c&&c(o)};return e.jsx(n.CommandList,{...j,onWheel:p,children:t})},te=(...t)=>t.filter(Boolean).join(" ");function $e({pages:t,selectedParentId:c,onChange:j,className:p,id:o="parentPage",currentPage:f}){const[m,h]=i.useState(!1),[g,L]=i.useState(""),B=Y.useChaiFeatureFlag("enable-add-page-dropdown");B||(p="w-full rounded-md border border-gray-300 px-3 py-2");const N=i.useMemo(()=>!t||t.length===0?[]:t.filter(x=>!b.isEmpty(x.slug)).filter(x=>x.slug!=="/").sort((x,y)=>x.slug.localeCompare(y.slug)),[t]),W=i.useMemo(()=>{if(!g.trim())return N;const a=g.toLowerCase();return N.filter(x=>x.name.toLowerCase().includes(a)||x.slug.toLowerCase().includes(a))},[N,g]),v=a=>Math.max(0,(a.match(/\//g)||[]).length-1),S=a=>" ".repeat(a),d=a=>{if(a==="/")return"/";const x=a.split("/").filter(Boolean);if(x.length<=1){const y=x[0]||"";return`/${$.removeSlugExtension(y)}`}return`/${$.removeSlugExtension(x[x.length-1])}`},l=()=>{if(!c||c==="none")return"None";const a=N.find(x=>x.id===c);return a?`${a.name} (${d(a.slug)})`:"None"};return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:o,className:"text-sm",children:"Parent"}),B?e.jsxs(n.Popover,{open:m,onOpenChange:h,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{id:o,variant:"outline",role:"combobox",className:te("w-full justify-between",p),"data-testid":"parent-page-selector",children:[l(),e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"relative border-none py-2",children:e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search pages...",className:"h-8 pl-8 text-xs",value:g,onChange:a=>L(a.target.value)})]})})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No pages found."}),e.jsxs(n.CommandGroup,{children:[e.jsxs(n.CommandItem,{value:"none",onSelect:()=>{j(""),h(!1),L("")},className:"flex cursor-pointer items-center justify-between",children:[e.jsx("span",{children:"None"}),e.jsx(C.Check,{className:te("mr-2 h-4 w-4",c?"opacity-0":"opacity-100")})]}),W.map(a=>{const x=S(v(a.slug)),y=d(a.slug),O=e.jsxs("span",{className:"flex items-center text-sm",children:[x,a.name,e.jsxs("span",{className:"text-xs text-gray-500",children:[" (",y,")"]})]});return e.jsxs(n.CommandItem,{value:a.id,onSelect:()=>{j(a.id),h(!1),L("")},className:"flex cursor-pointer items-center justify-between whitespace-pre-wrap",children:[e.jsx("span",{children:O}),e.jsx(C.Check,{className:te("mr-2 h-4 w-4 shrink-0",c===a.id?"opacity-100":"opacity-0")})]},a.id)})]})]})]})})]}):e.jsxs("select",{id:o,value:c||"none",onChange:a=>j(a.target.value),className:p,"data-testid":"parent-page-selector",children:[e.jsx("option",{value:"none",children:"None"}),N.map(a=>{const x=v(a.slug),y=x>0?S(x):"",O=d(a.slug);return(f==null?void 0:f.id)===a.id||a.slug.startsWith(f==null?void 0:f.slug)?null:e.jsxs("option",{value:a.id,children:[y,a.name," (",O,")"]},a.id)})]})]})}const ze=(...t)=>t.filter(Boolean).join(" "),_e=({templates:t,selectedTemplateId:c,onSelectTemplate:j,isLoading:p=!1})=>{const[o,f]=i.useState(""),[m,h]=i.useState(!1),[g,L]=i.useState(""),B=Y.useChaiFeatureFlag("enable-add-page-dropdown");if(i.useEffect(()=>{if(c){const d=t.find(l=>l.id===c);f((d==null?void 0:d.preview)||"")}else f("")},[c,t]),p)return e.jsx("div",{className:"flex h-fit items-center justify-center text-sm text-gray-500",children:"Loading templates..."});if(t.length===0)return null;const N={};t.forEach(d=>{const l=d.libraryName;N[l]||(N[l]=[]),N[l].push(d)});const W=Object.entries(N).reduce((d,[l,a])=>{const x=a.filter(y=>y.name.toLowerCase().includes(g.toLowerCase())||l.toLowerCase().includes(g.toLowerCase()));return x.length>0&&(d[l]=x),d},{}),v=t.find(d=>d.id===c),S=v?b.startCase(v.name):"No Template";return e.jsxs("div",{className:"space-y-4",children:[B?e.jsxs(n.Popover,{open:m,onOpenChange:h,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"outline",role:"combobox",className:"w-full justify-between",children:[S,e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search templates...",className:"h-8 pl-8 text-xs",value:g,onChange:d=>L(d.target.value)})]})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No templates found."}),Object.entries(W).map(([d,l])=>e.jsx(n.CommandGroup,{heading:d,children:l.map(a=>e.jsxs(n.CommandItem,{value:a.id,onSelect:()=>{j(a.id),h(!1),L("")},className:"flex cursor-pointer items-center justify-between",children:[b.startCase(a.name),e.jsx(C.Check,{className:ze("mr-2 h-4 w-4",c===a.id?"opacity-100":"opacity-0")})]},a.id))},d))]})]})})]}):e.jsxs("select",{className:"w-full rounded-md border border-gray-300 px-3 py-2",value:c,onChange:d=>j(d.target.value),children:[e.jsx("option",{value:"",children:"No Template"}),Object.entries(N).map(([d,l])=>e.jsx("optgroup",{label:d,children:l.map(a=>e.jsx("option",{value:a.id,children:b.startCase(a.name)},a.id))},d))]}),o&&e.jsxs("div",{className:"mt-3 overflow-hidden rounded border",children:[e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("img",{src:o,alt:"Template Preview",className:"w-full object-contain"})}),e.jsx("div",{className:"border-t bg-gray-50 p-2 text-xs text-gray-500",children:"Template preview"})]})]})},Ve=()=>{const t=w.useApiUrl(),c=w.useFetch();return je.useQuery({queryKey:[w.ACTIONS.GET_LIBRARIES],staleTime:"static",queryFn:async()=>await c(t,{action:w.ACTIONS.GET_LIBRARIES})||[]})},Qe=t=>{const c=w.useApiUrl(),j=w.useFetch();return je.useQuery({queryKey:[w.ACTIONS.GET_TEMPLATES_BY_TYPE,t],staleTime:"static",enabled:!!t,queryFn:async()=>{const p=await j(c,{action:w.ACTIONS.GET_TEMPLATES_BY_TYPE,data:{pageType:t}});return(t?b.filter(p,{pageType:t}):p)||[]}})},Ye=t=>{const{data:c=[],isLoading:j}=Qe(t),{data:p=[],isLoading:o}=Ve(),f=i.useMemo(()=>j||o?[]:c.map(h=>{const g=b.find(p,{id:h.library});return{...h,libraryName:(g==null?void 0:g.type)!=="shared"?"Site Library":(g==null?void 0:g.name)+" Library",libraryType:g==null?void 0:g.type}}),[c,p,j,o]),m=i.useMemo(()=>b.groupBy(f,"libraryName"),[f]);return{data:f,groupedData:m,isLoading:j||o}},U=(...t)=>t.filter(Boolean).join(" ");function He({addEditPage:t,close:c,closePanel:j}){var xe,ge;const{data:p}=w.usePageTypes(),o=i.useMemo(()=>p??[],[p]),f=w.useChangePage(),m=!!(t!=null&&t.id),{data:h}=w.useWebsitePages(),{mutate:g,isPending:L}=w.useCreatePage(),{mutate:B,isPending:N}=w.useUpdatePage(),[W,v]=i.useState(null),[S,d]=i.useState(!0),[l,a]=i.useState((t==null?void 0:t.pageType)??"page"),{hasPermission:x}=Y.usePermissions(),y=x(w.PAGES_PERMISSIONS.CHANGE_PAGE_TYPE),[O,R]=i.useState(!1),[ye,ve]=i.useState(""),{selectedLang:Se,fallbackLang:Ce}=Y.useLanguages(),ne=Se||Ce,[z,H]=i.useState(""),[ae,V]=i.useState(!1),le=i.useMemo(()=>{const s=o.find(u=>u.key===l);return(s==null?void 0:s.hasSlug)===!1},[l,o]),[T,Ne]=i.useState((t==null?void 0:t.parent)??""),[G,re]=i.useState((t==null?void 0:t.name)??""),[I,oe]=i.useState((t==null?void 0:t.dynamic)??!1),[F,Q]=i.useState(I?"":((t==null?void 0:t.slug)??"").split("/").pop()||""),[ie,ce]=i.useState((t==null?void 0:t.dynamicSlugCustom)??""),[ue,be]=i.useState(!0),[we,P]=i.useState(!1),[E,ke]=i.useState(""),{data:me,isLoading:Le}=Ye(l),_=L||N,he=Y.useChaiFeatureFlag("enable-add-page-dropdown"),ee=i.useMemo(()=>!m||!(t!=null&&t.id)||!h?null:h.find(s=>s.id===t.id),[m,t==null?void 0:t.id,h]),Te=(ee==null?void 0:ee.online)||!1,De=i.useMemo(()=>!m||!(t!=null&&t.id)||!h?!1:h.some(s=>s.parent===t.id),[m,t==null?void 0:t.id,h]),r=o.find(s=>s.key===l),M=s=>{if(m&&l!==s){ve(s),R(!0),H(""),V(!1);return}a(s),H(""),V(!1)},pe=()=>{a(ye),R(!1),oe(!1)},Ie=s=>{oe(s),s?Q(""):ce("")},Fe=s=>{if(Ne(s),s&&s!=="none"){const u=h==null?void 0:h.find(k=>k.id===s),q=(u==null?void 0:u.slug)||"";if(F.startsWith(q)){const k=F.slice(q.length).replace(/^\/+/,"");Q(k)}else Q(F.replace(/^\/+/,""))}else Q(F?`${F}`:"")},qe=s=>{ke(s)},Ae=()=>G.trim()?I&&!b.isEmpty(F)?(v("Slug must be empty when using dynamic slug"),!1):I&&!ue?(v("Dynamic slug is invalid"),!1):!0:(J.toast.error("Name is required"),!1),Be=()=>{const s={pageType:r==null?void 0:r.key,name:G,slug:"",hasSlug:!1};m?B({id:t==null?void 0:t.id,name:G},{onSuccess:()=>{J.toast.success((r==null?void 0:r.name)+" updated successfully"),c()}}):g(s,{onSuccess:u=>{c(),f(u.page.id,j)}})},Oe=(s,u)=>{if(!s.trim()&&!I)return v("Child page slug is required"),!1;const q=$.removeSlugExtension(u),k=$.combineParentChildSlugs(q,s);return Object.keys(w.LANGUAGES).some(Z=>k===`/${Z}`||(k==null?void 0:k.startsWith(`/${Z}/`)))?(v("Slugs cannot start with a language code for primary page"),!1):!0},We=(s,u)=>{const q=$.removeSlugExtension(u),k=$.combineParentChildSlugs(q,s),D={pageType:l,name:G,slug:k.replace(/\/$/,""),parent:T,dynamic:I,hasSlug:!0,template:E||void 0,tracking:{},seo:{},jsonLD:{}};if(I&&(D.dynamicSlugCustom=ie),m){const A=b.pick(D,["pageType","parent","name","slug","dynamic","dynamicSlugCustom"]);B({id:t==null?void 0:t.id,...A},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}})}else{const A=b.find(o,{key:l});A!=null&&A.trackingDefault&&(D.tracking=A.trackingDefault);const{seo:Z,jsonLD:Ge}=fe.getSeoDefaults(A,ne);b.set(D,"seo",Z),b.set(D,"jsonLD",Ge),g(D,{onSuccess:Me=>{c(),f(Me.page.id,j)}})}},Re=()=>{const s={pageType:l,name:G,slug:F===""?"/":`/${F.replace(/\/$/,"")}`,template:E||void 0,parent:null,tracking:{}};if(m)B({id:t==null?void 0:t.id,...s},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}});else{const u=b.find(o,{key:l});u!=null&&u.trackingDefault&&(s.tracking=u.trackingDefault);const{seo:q,jsonLD:k}=fe.getSeoDefaults(u,ne);b.set(s,"seo",q),b.set(s,"jsonLD",k),g(s,{onSuccess:D=>{var A;(A=D==null?void 0:D.page)!=null&&A.id&&f(D.page.id,j),c()}})}},de=s=>{if(s.preventDefault(),v(null),!!Ae()){if(!(r!=null&&r.hasSlug)){Be();return}if(T&&T!=="none"){const u=h==null?void 0:h.find(k=>k.id===T),q=(u==null?void 0:u.slug)||"";if(!Oe(F,q))return;We(F,q)}else Re()}},{pagesType:se,partialsType:K}=i.useMemo(()=>{const s=u=>z?u.name.toLowerCase().includes(z.toLowerCase())||u.key.toLowerCase().includes(z.toLowerCase()):!0;return{pagesType:o.filter(u=>u.hasSlug!==!1&&s(u)),partialsType:o.filter(u=>u.hasSlug===!1&&s(u))}},[o,z]);return r!=null&&r.hasSlug?e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(n.Popover,{open:ae,onOpenChange:V,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:U("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:z,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No page type found."}),m?le?e.jsx(n.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsx(n.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsxs(e.Fragment,{children:[se.length>0&&e.jsx(n.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}),K.length>0&&e.jsx(n.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>M(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:m?le?e.jsx("optgroup",{label:"Partials",children:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsx("optgroup",{label:"Pages",children:o.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsxs(e.Fragment,{children:[e.jsx("optgroup",{label:"Pages",children:o.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}),e.jsx("optgroup",{label:"Partials",children:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})]})}),O&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(n.Button,{variant:"outline",size:"sm",onClick:()=>R(!1),children:"Cancel"}),e.jsx(n.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]})]}),!m&&(r==null?void 0:r.hasSlug)&&me.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(n.Label,{className:"mb-1 block text-sm",children:"Template"}),e.jsx(_e,{templates:me,selectedTemplateId:E,onSelectTemplate:qe,isLoading:Le})]}),e.jsx($e,{pages:h,selectedParentId:T,onChange:Fe,currentPage:t}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(n.Input,{id:"name",value:G,onChange:s=>re(s.target.value),required:!0,"aria-required":"true",placeholder:"Enter page name"})]}),(r==null?void 0:r.dynamicSegments)&&T&&T!=="none"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"useDynamicSlug",checked:I,onChange:s=>Ie(s.target.checked),className:"rounded border-gray-300"}),e.jsx(n.Label,{htmlFor:"useDynamicSlug",className:"text-sm",children:"Use Dynamic Slug"})]}),I&&e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"space-y-0.5",children:e.jsx(Ue,{value:ie,onChange:ce,dynamicPattern:(r==null?void 0:r.dynamicSlug)||"{{id}}",placeholder:"Enter custom slug part (optional)",onValidationChange:be})})})]}),(!(r!=null&&r.dynamicSegments)||!I)&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx($.SlugInput,{value:F,onChange:s=>{var u;Q(s),m&&s!==(((u=t==null?void 0:t.slug)==null?void 0:u.split("/").pop())||"")?P(!!(Te||De)):P(!1)},placeholder:T&&T!=="none"?"Enter page slug":l==="page"?"Leave empty for home page":"Required - e.g. your-slug",parentSlug:T&&T!=="none"?(ge=h==null?void 0:h.find(s=>s.id===T))==null?void 0:ge.slug:void 0,onValidationChange:d}),W&&e.jsx("p",{className:"text-xs text-red-500",children:W}),we&&e.jsx("div",{className:"mt-4 rounded-md border border-amber-200 bg-amber-50 p-3",children:e.jsxs("div",{className:"flex items-start space-x-2",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-amber-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-amber-800",children:"Slug Change Warning"}),e.jsx("div",{className:"mt-1 text-sm text-amber-700",children:e.jsx("p",{children:"The previous URL and any child pages will become inaccessible. You may want to set up a redirect to avoid broken links."})})]})]})})]}),e.jsx(n.Button,{disabled:_||!S&&(!(r!=null&&r.dynamicSegments)||!I)||I&&!ue,type:"submit",className:"w-full",children:m?_?"Updating...":"Update page":_?"Creating...":"Create Page"})]}):e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(n.Popover,{open:ae,onOpenChange:V,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:U("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:z,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"max-h-[200px] overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No page type found."}),e.jsx(n.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>{M(s.key),V(!1)},className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>M(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:e.jsx("optgroup",{label:"Partials",children:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})}),O&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(n.Button,{variant:"outline",size:"sm",onClick:()=>R(!1),children:"Cancel"}),e.jsx(n.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:(xe=o.find(s=>s.key===l))==null?void 0:xe.helpText})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(n.Input,{id:"name",value:G,onChange:s=>re(s.target.value),required:!0,"aria-required":"true"})]}),e.jsx(n.Button,{disabled:_,type:"submit",className:"w-full",children:m?_?"Updating...":"Update "+(r==null?void 0:r.name):_?"Creating...":"Create "+(r==null?void 0:r.name)})]})}exports.default=He;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./index-LU0FTfeN.cjs"),a=require("@chaibuilder/sdk/ui"),t=require("lucide-react"),h=require("react"),g=({userId:l})=>{const{data:n}=c.useChaiUserInfo(l);return(n==null?void 0:n.name)||"Unknown"},C=({isChecking:l,lockingStatus:n,onContinue:x})=>{const[o,u]=h.useState(!1),i=n==="page_is_active_in_other_tab",r=(n==null?void 0:n.length)>0,{pageLock:s,acceptTakeOver:d,rejectTakeOver:j}=c.usePageLockRequestTakeOver(),m=()=>{u(!0),r||i?x():d(),setTimeout(()=>{u(!1)},3e3)};return h.useEffect(()=>{(s==null?void 0:s.requestedBy)==="ANOTHER_TAB"&&d()},[s,d]),(s==null?void 0:s.requestedBy)==="ANOTHER_TAB"?null:l?e.jsx(c.BlurContainer,{children:e.jsx(t.Loader,{className:"h-5 w-5 animate-spin text-primary"})}):e.jsx(c.BlurContainer,{children:e.jsxs(a.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(a.CardHeader,{className:"space-y-1",children:e.jsxs(a.CardTitle,{className:"flex items-center gap-2 text-xl font-medium",children:[o?e.jsx(t.Loader,{className:"h-6 w-6 animate-spin text-gray-500"}):i?e.jsx(t.TableIcon,{className:"h-6 w-6 text-green-500"}):r?e.jsx(t.CheckCircle,{className:"h-6 w-6 text-green-500"}):e.jsx(t.Target,{className:"h-6 w-6 text-green-500"}),i?"Page is active in other tab":r?"You can edit the page now.":"Page take over request"]})}),e.jsx(a.CardContent,{className:"grid gap-4",children:e.jsx("div",{children:i?e.jsx("p",{children:'You are already editing this page in another tab. To continue editing here, click on "Continue editing here".'}):r?e.jsx("p",{children:"This page is released by other user you can continue editing now."}):e.jsxs("p",{children:[e.jsxs("b",{children:[" ",e.jsx(g,{userId:s==null?void 0:s.requestedBy})]})," ","has requested to take over this page.",e.jsx("br",{})," If you accept, your unsaved changes will be saved."]})})}),e.jsxs(a.CardFooter,{className:"flex items-center justify-end gap-2",children:[e.jsx(a.Button,{disabled:o,onClick:m,className:r?"":"bg-green-500 hover:bg-green-600",children:i?e.jsxs(e.Fragment,{children:[e.jsx(t.Edit,{className:"h-5 w-5"})," Continue editing here"]}):r?e.jsxs(e.Fragment,{children:[e.jsx(t.Edit,{className:"h-5 w-5"})," Continue to edit"]}):e.jsxs(e.Fragment,{children:[e.jsx(t.Check,{className:"h-5 w-5"})," Accept"]})}),!r&&e.jsxs(a.Button,{variant:"outline",onClick:j,children:[e.jsx(t.X,{className:"h-5 w-5"})," Reject"]})]})]})})};exports.default=C;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsx as e, jsxs as a, Fragment as l } from "react/jsx-runtime";
|
|
2
|
+
import { ao as N, ap as w, B as h } from "./index-D7kegQ3M.js";
|
|
3
|
+
import { Card as x, CardHeader as T, CardTitle as b, CardContent as v, CardFooter as y, Button as m } from "@chaibuilder/sdk/ui";
|
|
4
|
+
import { Loader as u, TableIcon as B, CheckCircle as q, Target as _, Edit as f, Check as A, X as I } from "lucide-react";
|
|
5
|
+
import { useState as O, useEffect as j } from "react";
|
|
6
|
+
const E = ({ userId: i }) => {
|
|
7
|
+
const { data: r } = N(i);
|
|
8
|
+
return (r == null ? void 0 : r.name) || "Unknown";
|
|
9
|
+
}, F = ({
|
|
10
|
+
isChecking: i,
|
|
11
|
+
lockingStatus: r,
|
|
12
|
+
onContinue: g
|
|
13
|
+
}) => {
|
|
14
|
+
const [d, o] = O(!1), s = r === "page_is_active_in_other_tab", n = (r == null ? void 0 : r.length) > 0, { pageLock: t, acceptTakeOver: c, rejectTakeOver: p } = w(), C = () => {
|
|
15
|
+
o(!0), n || s ? g() : c(), setTimeout(() => {
|
|
16
|
+
o(!1);
|
|
17
|
+
}, 3e3);
|
|
18
|
+
};
|
|
19
|
+
return j(() => {
|
|
20
|
+
(t == null ? void 0 : t.requestedBy) === "ANOTHER_TAB" && c();
|
|
21
|
+
}, [t, c]), (t == null ? void 0 : t.requestedBy) === "ANOTHER_TAB" ? null : i ? /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(u, { className: "h-5 w-5 animate-spin text-primary" }) }) : /* @__PURE__ */ e(h, { children: /* @__PURE__ */ a(x, { className: "mx-auto w-full max-w-md", children: [
|
|
22
|
+
/* @__PURE__ */ e(T, { className: "space-y-1", children: /* @__PURE__ */ a(b, { className: "flex items-center gap-2 text-xl font-medium", children: [
|
|
23
|
+
d ? /* @__PURE__ */ e(u, { className: "h-6 w-6 animate-spin text-gray-500" }) : s ? /* @__PURE__ */ e(B, { className: "h-6 w-6 text-green-500" }) : n ? /* @__PURE__ */ e(q, { className: "h-6 w-6 text-green-500" }) : /* @__PURE__ */ e(_, { className: "h-6 w-6 text-green-500" }),
|
|
24
|
+
s ? "Page is active in other tab" : n ? "You can edit the page now." : "Page take over request"
|
|
25
|
+
] }) }),
|
|
26
|
+
/* @__PURE__ */ e(v, { className: "grid gap-4", children: /* @__PURE__ */ e("div", { children: s ? /* @__PURE__ */ e("p", { children: 'You are already editing this page in another tab. To continue editing here, click on "Continue editing here".' }) : n ? /* @__PURE__ */ e("p", { children: "This page is released by other user you can continue editing now." }) : /* @__PURE__ */ a("p", { children: [
|
|
27
|
+
/* @__PURE__ */ a("b", { children: [
|
|
28
|
+
" ",
|
|
29
|
+
/* @__PURE__ */ e(E, { userId: t == null ? void 0 : t.requestedBy })
|
|
30
|
+
] }),
|
|
31
|
+
" ",
|
|
32
|
+
"has requested to take over this page.",
|
|
33
|
+
/* @__PURE__ */ e("br", {}),
|
|
34
|
+
" If you accept, your unsaved changes will be saved."
|
|
35
|
+
] }) }) }),
|
|
36
|
+
/* @__PURE__ */ a(y, { className: "flex items-center justify-end gap-2", children: [
|
|
37
|
+
/* @__PURE__ */ e(
|
|
38
|
+
m,
|
|
39
|
+
{
|
|
40
|
+
disabled: d,
|
|
41
|
+
onClick: C,
|
|
42
|
+
className: n ? "" : "bg-green-500 hover:bg-green-600",
|
|
43
|
+
children: s ? /* @__PURE__ */ a(l, { children: [
|
|
44
|
+
/* @__PURE__ */ e(f, { className: "h-5 w-5" }),
|
|
45
|
+
" Continue editing here"
|
|
46
|
+
] }) : n ? /* @__PURE__ */ a(l, { children: [
|
|
47
|
+
/* @__PURE__ */ e(f, { className: "h-5 w-5" }),
|
|
48
|
+
" Continue to edit"
|
|
49
|
+
] }) : /* @__PURE__ */ a(l, { children: [
|
|
50
|
+
/* @__PURE__ */ e(A, { className: "h-5 w-5" }),
|
|
51
|
+
" Accept"
|
|
52
|
+
] })
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
!n && /* @__PURE__ */ a(m, { variant: "outline", onClick: p, children: [
|
|
56
|
+
/* @__PURE__ */ e(I, { className: "h-5 w-5" }),
|
|
57
|
+
" Reject"
|
|
58
|
+
] })
|
|
59
|
+
] })
|
|
60
|
+
] }) });
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
F as default
|
|
64
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("@chaibuilder/sdk/ui"),m=require("date-fns"),r=require("lucide-react"),h=require("react"),j=require("./index-LU0FTfeN.cjs");function p({avatar:d,name:a,email:l,lastSaved:n,onTakeOver:u,isRequestRejected:c,isFetchingUserInfo:t}){const[i,o]=h.useState(!1),x=()=>{o(!0),setTimeout(()=>{o(!1)},15e3),u()};return e.jsx(j.BlurContainer,{children:e.jsxs(s.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(s.CardHeader,{className:"space-y-1",children:e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(r.LockKeyhole,{className:"h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500"}),"Page is locked for editing"]})}),e.jsx(s.CardContent,{className:"w-md grid w-full pt-2",children:e.jsxs("div",{children:[e.jsxs("div",{className:"relative mx-auto flex w-96 items-center space-x-4 rounded-md border border-green-500 px-2 pb-2 pt-4",children:[e.jsx("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:"Locked By"}),d&&!t?e.jsx("img",{src:d,alt:a,className:"h-14 w-14 rounded-full border border-gray-300"}):e.jsx(r.UserIcon,{className:"h-14 w-14 flex-shrink-0 rounded-full bg-gradient-to-br from-purple-400 to-pink-500 p-2 text-white"}),e.jsxs("div",{className:t?"space-y-1.5":"space-y-0",children:[t?e.jsx(s.Skeleton,{className:"h-4 w-40 rounded"}):e.jsx("span",{className:"truncate font-medium text-black",children:a}),l&&!t?e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:l}):e.jsx(s.Skeleton,{className:"h-4 w-60 rounded"}),n&&!t?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Last saved:"," ",m.formatDistanceToNow(new Date(n),{addSuffix:!0})]}):e.jsx(s.Skeleton,{className:"h-4 w-40 rounded"})]})]}),e.jsx("div",{className:"mt-4 text-sm",children:e.jsxs("p",{className:"py-4 text-center text-gray-600",children:["This page is currently being edited by ",e.jsx("span",{className:"font-bold",children:a}),".",e.jsx("br",{}),e.jsx("br",{})," You can either wait until they finish editing or request to take over the page."]})}),c&&e.jsxs("div",{className:"mt-4 flex w-full items-center justify-center gap-x-2 rounded border border-red-500 bg-red-50 p-2 text-center font-medium text-red-500",children:[e.jsx(r.Info,{className:"h-5 w-5"})," Page take over request is rejected"]})]})}),e.jsx(s.CardFooter,{children:e.jsxs(s.Button,{disabled:i,onClick:x,className:"w-full",variant:"destructive",children:[e.jsx(r.KeyIcon,{className:"h-5 w-5"}),i?"Page take is requested.":c?"Request take over again":"Request take over"]})})]})})}exports.default=p;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
+
import { Card as p, CardHeader as x, CardTitle as f, CardContent as h, Skeleton as d, CardFooter as N, Button as g } from "@chaibuilder/sdk/ui";
|
|
3
|
+
import { formatDistanceToNow as b } from "date-fns";
|
|
4
|
+
import { LockKeyhole as w, UserIcon as k, Info as y, KeyIcon as v } from "lucide-react";
|
|
5
|
+
import { useState as C } from "react";
|
|
6
|
+
import { B } from "./index-D7kegQ3M.js";
|
|
7
|
+
function K({
|
|
8
|
+
avatar: s,
|
|
9
|
+
name: a,
|
|
10
|
+
email: l,
|
|
11
|
+
lastSaved: o,
|
|
12
|
+
onTakeOver: m,
|
|
13
|
+
isRequestRejected: i,
|
|
14
|
+
isFetchingUserInfo: r
|
|
15
|
+
}) {
|
|
16
|
+
const [n, c] = C(!1), u = () => {
|
|
17
|
+
c(!0), setTimeout(() => {
|
|
18
|
+
c(!1);
|
|
19
|
+
}, 15e3), m();
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ e(B, { children: /* @__PURE__ */ t(p, { className: "mx-auto w-full max-w-md", children: [
|
|
22
|
+
/* @__PURE__ */ e(x, { className: "space-y-1", children: /* @__PURE__ */ t(f, { className: "flex items-center gap-2 text-xl", children: [
|
|
23
|
+
/* @__PURE__ */ e(w, { className: "h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500" }),
|
|
24
|
+
"Page is locked for editing"
|
|
25
|
+
] }) }),
|
|
26
|
+
/* @__PURE__ */ e(h, { className: "w-md grid w-full pt-2", children: /* @__PURE__ */ t("div", { children: [
|
|
27
|
+
/* @__PURE__ */ t("div", { className: "relative mx-auto flex w-96 items-center space-x-4 rounded-md border border-green-500 px-2 pb-2 pt-4", children: [
|
|
28
|
+
/* @__PURE__ */ e("div", { className: "absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white", children: "Locked By" }),
|
|
29
|
+
s && !r ? /* @__PURE__ */ e("img", { src: s, alt: a, className: "h-14 w-14 rounded-full border border-gray-300" }) : /* @__PURE__ */ e(k, { className: "h-14 w-14 flex-shrink-0 rounded-full bg-gradient-to-br from-purple-400 to-pink-500 p-2 text-white" }),
|
|
30
|
+
/* @__PURE__ */ t("div", { className: r ? "space-y-1.5" : "space-y-0", children: [
|
|
31
|
+
r ? /* @__PURE__ */ e(d, { className: "h-4 w-40 rounded" }) : /* @__PURE__ */ e("span", { className: "truncate font-medium text-black", children: a }),
|
|
32
|
+
l && !r ? /* @__PURE__ */ e("p", { className: "truncate text-sm text-muted-foreground", children: l }) : /* @__PURE__ */ e(d, { className: "h-4 w-60 rounded" }),
|
|
33
|
+
o && !r ? /* @__PURE__ */ t("p", { className: "text-sm text-muted-foreground", children: [
|
|
34
|
+
"Last saved:",
|
|
35
|
+
" ",
|
|
36
|
+
b(new Date(o), {
|
|
37
|
+
addSuffix: !0
|
|
38
|
+
})
|
|
39
|
+
] }) : /* @__PURE__ */ e(d, { className: "h-4 w-40 rounded" })
|
|
40
|
+
] })
|
|
41
|
+
] }),
|
|
42
|
+
/* @__PURE__ */ e("div", { className: "mt-4 text-sm", children: /* @__PURE__ */ t("p", { className: "py-4 text-center text-gray-600", children: [
|
|
43
|
+
"This page is currently being edited by ",
|
|
44
|
+
/* @__PURE__ */ e("span", { className: "font-bold", children: a }),
|
|
45
|
+
".",
|
|
46
|
+
/* @__PURE__ */ e("br", {}),
|
|
47
|
+
/* @__PURE__ */ e("br", {}),
|
|
48
|
+
" You can either wait until they finish editing or request to take over the page."
|
|
49
|
+
] }) }),
|
|
50
|
+
i && /* @__PURE__ */ t("div", { className: "mt-4 flex w-full items-center justify-center gap-x-2 rounded border border-red-500 bg-red-50 p-2 text-center font-medium text-red-500", children: [
|
|
51
|
+
/* @__PURE__ */ e(y, { className: "h-5 w-5" }),
|
|
52
|
+
" Page take over request is rejected"
|
|
53
|
+
] })
|
|
54
|
+
] }) }),
|
|
55
|
+
/* @__PURE__ */ e(N, { children: /* @__PURE__ */ t(g, { disabled: n, onClick: u, className: "w-full", variant: "destructive", children: [
|
|
56
|
+
/* @__PURE__ */ e(v, { className: "h-5 w-5" }),
|
|
57
|
+
n ? "Page take is requested." : i ? "Request take over again" : "Request take over"
|
|
58
|
+
] }) })
|
|
59
|
+
] }) });
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
K as default
|
|
63
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),x=require("./index-LU0FTfeN.cjs"),B=require("./use-page-expand-manager-B7JtHdg5.cjs"),n=require("lodash-es"),Q=require("@chaibuilder/sdk"),se=require("jotai"),v=require("lucide-react"),l=require("react"),V=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const t=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),t)||n.includes(n.toLower((a==null?void 0:a.slug)||""),t)})),te=(e,r)=>{const a=new Set,t=n.keyBy(e,"id");return r.forEach(o=>{let c=o;for(;c.parent&&t[c.parent];)a.add(c.parent),c=t[c.parent]}),Array.from(a).map(o=>t[o])},$=(e,r,a)=>n.isEmpty(r)?e:e.map(t=>{if(!a(t.pageType))return{...t,shouldExpandOnSearch:!0,children:t.children?$(t.children,r,a):[]};const o=t.children&&t.children.some(c=>n.includes(n.toLower(c.name||""),n.toLower(r))||n.includes(n.toLower(c.slug||""),n.toLower(r)));return{...t,shouldExpandOnSearch:o,children:t.children?$(t.children,r,a):[]}}),ne=e=>{if(!e||!e.length)return[];const r={};e.forEach(t=>{r[t.id]={...t,children:[]}});const a=[];return Object.values(r).forEach(t=>{t.parent&&r[t.parent]?r[t.parent].children.push(t):a.push(t)}),a},J=e=>!e||!e.length?[]:[...e].sort((a,t)=>(a.name||"").localeCompare(t.name||"")).map(a=>({...a,children:a.children?J(a.children):[]})),re=(e,r,a,t)=>{if(!e||!e.length)return[];let o=e;if(a!=="all"&&(o=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))o=V(o,r);else{const m=V(o,r),d=te(e,m);o=n.uniqBy([...m,...d],"id")}const c=J(ne(o)),b=$(c,r,t),y=n.filter(b,m=>t(m.pageType)).sort((m,d)=>(m.name||"").localeCompare(d.name||"")),p=n.filter(b,m=>!t(m.pageType));let f=[];if(a==="all"){const m=n.keyBy(p,"pageType");f=Object.values(n.mapValues(m,(d,j)=>({...d,id:j,name:n.startCase(j),isPartialGroup:!0,children:b.filter(N=>N.pageType===j)})))}else f=p.sort((m,d)=>(m.name||"").localeCompare(d.name||""));return[...y,...f]},ae=({page:e})=>{var t,o;const{isExpanded:r,toggleExpanded:a}=B.usePageExpandManager(e==null?void 0:e.id);return s.jsx("button",{onClick:c=>{c.stopPropagation(),a()},disabled:!((t=e==null?void 0:e.children)!=null&&t.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 ${(o=e==null?void 0:e.children)!=null&&o.length?"hover:text-blue-400":"opacity-0"}`,children:s.jsx(v.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},le=({page:e,pageType:r})=>s.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?s.jsx(v.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?s.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?s.jsx(v.File,{size:12,className:"stroke-[1] text-slate-500"}):s.jsx(v.Globe,{size:12,className:"stroke-[1] text-slate-500"})}),ie=({isOnline:e})=>s.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),oe=({page:e,pageTypes:r,currentPage:a,onClickAction:t,languagePages:o,selectedLanguage:c,showUntranslatedPages:b})=>{const[y]=x.usePageUserMapping(),p=x.useFallbackLang(),f=a===e.id,m=!!e.isTemplate,d=l.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]),j=y==null?void 0:y[e.id],{data:N}=x.useChaiUserInfo(j),g=N?N==null?void 0:N.name:null;let h=n.get(o,e==null?void 0:e.id);h=n.get(h,"lang")===c?h:null;const E=c===p||!!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 C=S+(e!=null&&e.dynamic?`/${d==null?void 0:d.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!b){const u=S.split("/").pop();S=S.endsWith(u)&&e.dynamic?"":`/${u}`}const q=l.useMemo(()=>{const u="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]",T=`${f?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${u} ${T} ${g?"opacity-60":""}`:`${u} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,f,g]);return s.jsxs("div",{className:"group relative",children:[s.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&t("select",e==null?void 0:e.id),className:q,children:[s.jsx(ae,{page:e}),!e.isPartialGroup&&s.jsx(ie,{isOnline:h?h.online:e.online}),s.jsx(le,{page:e,pageType:d}),s.jsx(x.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:s.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(S||e.dynamic)&&s.jsx(x.Tooltip,{content:C,side:"top",showTooltip:!0,children:s.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[S,e.dynamic&&(d==null?void 0:d.dynamicSlug)&&s.jsxs("span",{className:"text-xs text-gray-500",children:["/",d==null?void 0:d.dynamicSlug,e.dynamicSlugCustom]})]})}),m&&s.jsx(x.Tooltip,{content:"Template",side:"top",children:s.jsx("span",{className:"text-blue-500",children:s.jsx(v.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!g?s.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:s.jsx(x.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:u=>t("duplicate",u),setAddEditPage:u=>t("edit",h||u),setUnpublishPage:u=>t("unpublish",u),setDeletePage:u=>t("delete",h||u),setMarkAsTemplate:u=>t("markAsTemplate",u),setUnmarkAsTemplate:u=>t("unmarkAsTemplate",u),children:s.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:s.jsx(v.MoreHorizontal,{className:"h-4 w-4",onClick:u=>u.stopPropagation()})})})}):g?s.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:s.jsx(v.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]}),s.jsx(s.Fragment,{children:g&&s.jsxs("button",{className:"absolute right-0 top-0 flex h-full 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:[s.jsx(v.Edit,{size:12,className:"stroke-[3]"})," ",s.jsx("span",{className:"font-medium",children:g})," is editing this page"]})}),s.jsx(s.Fragment,{children:!E&&!e.isPartialGroup&&!g&&s.jsxs("button",{onClick:u=>{u.stopPropagation(),t("addLanguagePage",{language:c,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:[s.jsx(v.Plus,{size:12,className:"stroke-[3]"})," ",s.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(x.LANGUAGES,c)," Page"]})]})})]})},K=({pages:e,tier:r,pageTypes:a,currentPage:t,onClickAction:o,languagePages:c,selectedLanguage:b,showUntranslatedPages:y})=>{const{expandedPages:p}=B.usePageExpandManager();return s.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(f=>s.jsxs(s.Fragment,{children:[s.jsx(oe,{page:f,pageTypes:a,currentPage:t,onClickAction:o,languagePages:c,selectedLanguage:b,showUntranslatedPages:y}),f.children&&f.children.length>0&&(p==null?void 0:p.includes(f.id))&&s.jsx(K,{pages:f.children,tier:r+1,pageTypes:a,currentPage:t,onClickAction:o,languagePages:c,selectedLanguage:b,showUntranslatedPages:y})]},f.id))})},ce=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-3h4URMP_.cjs"))),de=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-CnUo6xzd.cjs"))),ue=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-Cf88UkqJ.cjs"))),me=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-BX1gOez-.cjs"))),he=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-DeB23sWR.cjs"))),xe=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-CihtTMOb.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-DzLtZcNw.cjs"))),Pe=({close:e})=>{const{languages:r,setSelectedLang:a}=Q.useLanguages(),{data:t}=x.usePageTypes(),{data:o,isFetching:c}=x.useWebsitePages(),[b,y]=x.useSearchParams(),{updateForSelectedPage:p,expandPagesOnSearch:f}=B.usePageExpandManager(null),m=x.useFallbackLang(),d=b.get("page"),[j,N]=l.useState(""),[g,h]=l.useState(null),[E,L]=l.useState(null),[S,C]=l.useState(null),[q,u]=l.useState(null),[T,F]=l.useState(""),[I,G]=l.useState(null),[O,R]=l.useState(null),[k,X]=l.useState(m),[Y,Z]=l.useState(!1),[,D]=se.useAtom(x.addNewLangAtom),M=Y&&k!==m,{data:A,isFetching:ee}=x.useWebsiteLanguagePages(k),W=l.useCallback(P=>{var i;return(i=n.find(t,{key:P}))==null?void 0:i.hasSlug},[t]),w=l.useMemo(()=>o?M?n.filter(o,P=>!(A!=null&&A[P.id])):re(o,j,T,W):[],[o,W,j,T,A,M]);l.useEffect(()=>{a(m)},[m,a]),l.useEffect(()=>{if(!n.isEmpty(T))return;const P=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(t)&&P&&(n.find(t,{key:P})?F(P):F("all"))},[t,T]),l.useEffect(()=>{if(d&&!c&&!n.find(o,{id:d})){const i=n.find(o,{slug:"/"});if(i){const z=new URLSearchParams({page:i.id});x.navigateToPage(z,y)}else x.navigateToPage(new URLSearchParams({}),y,!0)}},[o,d,c,y]),l.useEffect(()=>{d&&!c&&!n.isEmpty(w)&&p(w,d)},[d,c,w,p]),l.useEffect(()=>{!n.isEmpty(j)&&!n.isEmpty(w)&&f(w)},[j,w,f]);const{setSelectedLang:U}=Q.useLanguages(),_=l.useCallback(P=>{const i=new URLSearchParams({page:P});k!==m?(i.set("lang",k),U(k)):U(""),x.navigateToPage(i,y),e()},[e,y,U,k,m]),H=(P,i)=>{var z;if(i)switch(P){case"add":L(i);break;case"select":_(i);break;case"edit":k!==m?D({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):L(i);break;case"delete":h(i);break;case"unpublish":C(i);break;case"markAsTemplate":u(i);break;case"unmarkAsTemplate":R(i);break;case"duplicate":G(i);break;case"addLanguagePage":D({edit:!1,primaryPage:((z=i==null?void 0:i.page)==null?void 0:z.id)||"",preselectedLang:(i==null?void 0:i.language)||k});break}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex h-full flex-col justify-between",children:[s.jsx(l.Suspense,{children:s.jsx(ce,{pages:w,search:j,setSearch:N,languages:[m,...r],selectedLanguage:k,setSelectedLanguage:X,selectedPageType:T,setSelectedPageType:F,onAddPage:P=>H("add",P),showUntranslatedPages:M,setShowUntranslatedPages:Z})}),s.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:c||ee?s.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],P=>s.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},P))}):n.isEmpty(w)?s.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[s.jsx(v.File,{className:"h-6 w-6 stroke-[1]"}),"Empty List!",s.jsx("span",{className:"font-light",children:"Add new page to start"})]}):s.jsx(K,{tier:0,pages:w,pageTypes:t,currentPage:d||"",onClickAction:H,languagePages:A,selectedLanguage:k,showUntranslatedPages:M})})]}),E&&s.jsx(l.Suspense,{children:s.jsx(de,{closePanel:e,editPage:_,addEditPage:E,setAddEditPage:L})}),g&&s.jsx(l.Suspense,{children:s.jsx(ue,{page:g,onClose:()=>h(null)})}),S&&s.jsx(l.Suspense,{children:s.jsx(fe,{page:S,onClose:()=>C(null)})}),q&&s.jsx(l.Suspense,{children:s.jsx(he,{page:q,onClose:()=>u(null)})}),O&&s.jsx(l.Suspense,{children:s.jsx(xe,{page:O,onClose:()=>R(null)})}),I&&s.jsx(l.Suspense,{children:s.jsx(me,{page:I,onClose:()=>G(null),closePanel:e})})]})};exports.default=Pe;
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { jsxs as p, jsx as s, Fragment as O } from "react/jsx-runtime";
|
|
2
|
+
import { aw as pe, f as oe, ao as be, ax as _, ay as ye, L as ge, h as ke, b as Ne, i as we, as as ve, az as Se, aA as q } from "./index-D7kegQ3M.js";
|
|
3
|
+
import { u as J } from "./use-page-expand-manager-BCFQnVkT.js";
|
|
4
|
+
import { compact as ie, filter as F, isEmpty as v, uniqBy as Ae, keyBy as ce, mapValues as Le, startCase as Te, toLower as E, includes as D, find as M, get as H, map as Ce } from "lodash-es";
|
|
5
|
+
import { useLanguages as re } from "@chaibuilder/sdk";
|
|
6
|
+
import { useAtom as Ee } from "jotai";
|
|
7
|
+
import { NotepadText as Ue, MoreHorizontal as $e, Lock as ze, Edit as Me, Plus as Fe, ChevronRight as je, StarsIcon as Be, Globe as Ie, File as de } from "lucide-react";
|
|
8
|
+
import { useMemo as Q, lazy as U, useState as N, useCallback as ae, useEffect as z, Suspense as C } from "react";
|
|
9
|
+
const le = (e, n) => !e || !Array.isArray(e) ? [] : v(n) ? e : ie(
|
|
10
|
+
F(e, (r) => {
|
|
11
|
+
const t = E(n);
|
|
12
|
+
return D(E((r == null ? void 0 : r.name) || ""), t) || D(E((r == null ? void 0 : r.slug) || ""), t);
|
|
13
|
+
})
|
|
14
|
+
), Ge = (e, n) => {
|
|
15
|
+
const r = /* @__PURE__ */ new Set(), t = ce(e, "id");
|
|
16
|
+
return n.forEach((l) => {
|
|
17
|
+
let o = l;
|
|
18
|
+
for (; o.parent && t[o.parent]; )
|
|
19
|
+
r.add(o.parent), o = t[o.parent];
|
|
20
|
+
}), Array.from(r).map((l) => t[l]);
|
|
21
|
+
}, V = (e, n, r) => v(n) ? e : e.map((t) => {
|
|
22
|
+
if (!r(t.pageType))
|
|
23
|
+
return {
|
|
24
|
+
...t,
|
|
25
|
+
shouldExpandOnSearch: !0,
|
|
26
|
+
children: t.children ? V(t.children, n, r) : []
|
|
27
|
+
};
|
|
28
|
+
const l = t.children && t.children.some(
|
|
29
|
+
(o) => D(E(o.name || ""), E(n)) || D(E(o.slug || ""), E(n))
|
|
30
|
+
);
|
|
31
|
+
return {
|
|
32
|
+
...t,
|
|
33
|
+
shouldExpandOnSearch: l,
|
|
34
|
+
children: t.children ? V(t.children, n, r) : []
|
|
35
|
+
};
|
|
36
|
+
}), Oe = (e) => {
|
|
37
|
+
if (!e || !e.length) return [];
|
|
38
|
+
const n = {};
|
|
39
|
+
e.forEach((t) => {
|
|
40
|
+
n[t.id] = { ...t, children: [] };
|
|
41
|
+
});
|
|
42
|
+
const r = [];
|
|
43
|
+
return Object.values(n).forEach((t) => {
|
|
44
|
+
t.parent && n[t.parent] ? n[t.parent].children.push(t) : r.push(t);
|
|
45
|
+
}), r;
|
|
46
|
+
}, ue = (e) => !e || !e.length ? [] : [...e].sort(
|
|
47
|
+
(r, t) => (r.name || "").localeCompare(t.name || "")
|
|
48
|
+
).map((r) => ({
|
|
49
|
+
...r,
|
|
50
|
+
children: r.children ? ue(r.children) : []
|
|
51
|
+
})), De = (e, n, r, t) => {
|
|
52
|
+
if (!e || !e.length) return [];
|
|
53
|
+
let l = e;
|
|
54
|
+
if (r !== "all" && (l = ie(F(e, { pageType: r }))), v(n))
|
|
55
|
+
l = le(l, n);
|
|
56
|
+
else {
|
|
57
|
+
const d = le(l, n), i = Ge(e, d);
|
|
58
|
+
l = Ae([...d, ...i], "id");
|
|
59
|
+
}
|
|
60
|
+
const o = ue(Oe(l)), b = V(o, n, t), f = F(b, (d) => t(d.pageType)).sort((d, i) => (d.name || "").localeCompare(i.name || "")), x = F(b, (d) => !t(d.pageType));
|
|
61
|
+
let m = [];
|
|
62
|
+
if (r === "all") {
|
|
63
|
+
const d = ce(x, "pageType");
|
|
64
|
+
m = Object.values(
|
|
65
|
+
Le(d, (i, P) => ({
|
|
66
|
+
...i,
|
|
67
|
+
id: P,
|
|
68
|
+
name: Te(P),
|
|
69
|
+
isPartialGroup: !0,
|
|
70
|
+
children: b.filter((S) => S.pageType === P)
|
|
71
|
+
}))
|
|
72
|
+
);
|
|
73
|
+
} else
|
|
74
|
+
m = x.sort((d, i) => (d.name || "").localeCompare(i.name || ""));
|
|
75
|
+
return [...f, ...m];
|
|
76
|
+
}, Re = ({ page: e }) => {
|
|
77
|
+
var t, l;
|
|
78
|
+
const { isExpanded: n, toggleExpanded: r } = J(e == null ? void 0 : e.id);
|
|
79
|
+
return /* @__PURE__ */ s(
|
|
80
|
+
"button",
|
|
81
|
+
{
|
|
82
|
+
onClick: (o) => {
|
|
83
|
+
o.stopPropagation(), r();
|
|
84
|
+
},
|
|
85
|
+
disabled: !((t = e == null ? void 0 : e.children) != null && t.length),
|
|
86
|
+
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 ${(l = e == null ? void 0 : e.children) != null && l.length ? "hover:text-blue-400" : "opacity-0"}`,
|
|
87
|
+
children: /* @__PURE__ */ s(
|
|
88
|
+
je,
|
|
89
|
+
{
|
|
90
|
+
size: 12,
|
|
91
|
+
className: `stroke-[4] transition-transform duration-200 ${n ? "rotate-90" : ""}`
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}, We = ({ page: e, pageType: n }) => /* @__PURE__ */ s("div", { className: "flex h-full items-center justify-center gap-x-1", children: e.dynamic ? /* @__PURE__ */ s(Be, { size: 12, className: "text-yellow-400" }) : n != null && n.icon ? /* @__PURE__ */ s(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
99
|
+
className: "flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",
|
|
100
|
+
dangerouslySetInnerHTML: { __html: n.icon }
|
|
101
|
+
}
|
|
102
|
+
) : n != null && n.hasSlug ? /* @__PURE__ */ s(de, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ s(Ie, { size: 12, className: "stroke-[1] text-slate-500" }) }), _e = ({ isOnline: e }) => /* @__PURE__ */ s("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), qe = ({
|
|
103
|
+
page: e,
|
|
104
|
+
pageTypes: n,
|
|
105
|
+
currentPage: r,
|
|
106
|
+
onClickAction: t,
|
|
107
|
+
languagePages: l,
|
|
108
|
+
selectedLanguage: o,
|
|
109
|
+
showUntranslatedPages: b
|
|
110
|
+
}) => {
|
|
111
|
+
const [f] = pe(), x = oe(), m = r === e.id, d = !!e.isTemplate, i = Q(() => M(n, { key: e.pageType }), [n, e.pageType]), P = f == null ? void 0 : f[e.id], { data: S } = be(P), y = S ? S == null ? void 0 : S.name : null;
|
|
112
|
+
let u = H(l, e == null ? void 0 : e.id);
|
|
113
|
+
u = H(u, "lang") === o ? u : null;
|
|
114
|
+
const A = o === x || !!u, L = (u == null ? void 0 : u.name) || (e == null ? void 0 : e.name) || "No name";
|
|
115
|
+
let g = (u == null ? void 0 : u.slug) || (e == null ? void 0 : e.slug) || "";
|
|
116
|
+
const j = g + (e != null && e.dynamic ? `/${i == null ? void 0 : i.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
|
|
117
|
+
if (g.startsWith("/") && !b) {
|
|
118
|
+
const c = g.split("/").pop();
|
|
119
|
+
g = g.endsWith(c) && e.dynamic ? "" : `/${c}`;
|
|
120
|
+
}
|
|
121
|
+
const B = Q(() => {
|
|
122
|
+
const c = "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]", T = `${m ? "border-primary/30 bg-primary/5" : "border-transparent hover:border-gray-200 hover:bg-gray-100"}`;
|
|
123
|
+
return A ? `${c} ${T} ${y ? "opacity-60" : ""}` : `${c} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`;
|
|
124
|
+
}, [A, m, y]);
|
|
125
|
+
return /* @__PURE__ */ p("div", { className: "group relative", children: [
|
|
126
|
+
/* @__PURE__ */ p(
|
|
127
|
+
"div",
|
|
128
|
+
{
|
|
129
|
+
onClick: () => !e.isPartialGroup && A && t("select", e == null ? void 0 : e.id),
|
|
130
|
+
className: B,
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ s(Re, { page: e }),
|
|
133
|
+
!e.isPartialGroup && /* @__PURE__ */ s(_e, { isOnline: u ? u.online : e.online }),
|
|
134
|
+
/* @__PURE__ */ s(We, { page: e, pageType: i }),
|
|
135
|
+
/* @__PURE__ */ s(_, { content: L, side: "top", showTooltip: L.length > 35, children: /* @__PURE__ */ s("span", { className: "max-w-[40%] truncate font-medium text-black", children: L }) }),
|
|
136
|
+
(g || e.dynamic) && /* @__PURE__ */ s(_, { content: j, side: "top", showTooltip: !0, children: /* @__PURE__ */ p("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
|
|
137
|
+
g,
|
|
138
|
+
e.dynamic && (i == null ? void 0 : i.dynamicSlug) && /* @__PURE__ */ p("span", { className: "text-xs text-gray-500", children: [
|
|
139
|
+
"/",
|
|
140
|
+
i == null ? void 0 : i.dynamicSlug,
|
|
141
|
+
e.dynamicSlugCustom
|
|
142
|
+
] })
|
|
143
|
+
] }) }),
|
|
144
|
+
d && /* @__PURE__ */ s(_, { content: "Template", side: "top", children: /* @__PURE__ */ s("span", { className: "text-blue-500", children: /* @__PURE__ */ s(Ue, { size: 16 }) }) }),
|
|
145
|
+
!e.isPartialGroup && A && !y ? /* @__PURE__ */ s("div", { className: "duration absolute right-0.5 top-[3px]", children: /* @__PURE__ */ s(
|
|
146
|
+
ye,
|
|
147
|
+
{
|
|
148
|
+
isLanguagePage: !!u,
|
|
149
|
+
page: u || e,
|
|
150
|
+
setDuplicatePage: (c) => t("duplicate", c),
|
|
151
|
+
setAddEditPage: (c) => t("edit", u || c),
|
|
152
|
+
setUnpublishPage: (c) => t("unpublish", c),
|
|
153
|
+
setDeletePage: (c) => t("delete", u || c),
|
|
154
|
+
setMarkAsTemplate: (c) => t("markAsTemplate", c),
|
|
155
|
+
setUnmarkAsTemplate: (c) => t("unmarkAsTemplate", c),
|
|
156
|
+
children: /* @__PURE__ */ s("div", { className: "m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white", children: /* @__PURE__ */ s($e, { className: "h-4 w-4", onClick: (c) => c.stopPropagation() }) })
|
|
157
|
+
}
|
|
158
|
+
) }) : y ? /* @__PURE__ */ s("span", { className: "duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500", children: /* @__PURE__ */ s(ze, { className: "h-3.5 w-3.5 fill-red-200 text-red-500" }) }) : null
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
/* @__PURE__ */ s(O, { children: y && /* @__PURE__ */ p("button", { className: "absolute right-0 top-0 flex h-full 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: [
|
|
163
|
+
/* @__PURE__ */ s(Me, { size: 12, className: "stroke-[3]" }),
|
|
164
|
+
" ",
|
|
165
|
+
/* @__PURE__ */ s("span", { className: "font-medium", children: y }),
|
|
166
|
+
" is editing this page"
|
|
167
|
+
] }) }),
|
|
168
|
+
/* @__PURE__ */ s(O, { children: !A && !e.isPartialGroup && !y && /* @__PURE__ */ p(
|
|
169
|
+
"button",
|
|
170
|
+
{
|
|
171
|
+
onClick: (c) => {
|
|
172
|
+
c.stopPropagation(), t("addLanguagePage", { language: o, page: e });
|
|
173
|
+
},
|
|
174
|
+
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",
|
|
175
|
+
children: [
|
|
176
|
+
/* @__PURE__ */ s(Fe, { size: 12, className: "stroke-[3]" }),
|
|
177
|
+
" ",
|
|
178
|
+
/* @__PURE__ */ p("span", { className: "text-[10px]", children: [
|
|
179
|
+
"Add ",
|
|
180
|
+
H(ge, o),
|
|
181
|
+
" Page"
|
|
182
|
+
] })
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
) })
|
|
186
|
+
] });
|
|
187
|
+
}, me = ({
|
|
188
|
+
pages: e,
|
|
189
|
+
tier: n,
|
|
190
|
+
pageTypes: r,
|
|
191
|
+
currentPage: t,
|
|
192
|
+
onClickAction: l,
|
|
193
|
+
languagePages: o,
|
|
194
|
+
selectedLanguage: b,
|
|
195
|
+
showUntranslatedPages: f
|
|
196
|
+
}) => {
|
|
197
|
+
const { expandedPages: x } = J();
|
|
198
|
+
return /* @__PURE__ */ s("div", { className: "space-y-0.5", style: { paddingLeft: `${n * 10}px` }, children: e.map((m) => /* @__PURE__ */ p(O, { children: [
|
|
199
|
+
/* @__PURE__ */ s(
|
|
200
|
+
qe,
|
|
201
|
+
{
|
|
202
|
+
page: m,
|
|
203
|
+
pageTypes: r,
|
|
204
|
+
currentPage: t,
|
|
205
|
+
onClickAction: l,
|
|
206
|
+
languagePages: o,
|
|
207
|
+
selectedLanguage: b,
|
|
208
|
+
showUntranslatedPages: f
|
|
209
|
+
}
|
|
210
|
+
),
|
|
211
|
+
m.children && m.children.length > 0 && (x == null ? void 0 : x.includes(m.id)) && /* @__PURE__ */ s(
|
|
212
|
+
me,
|
|
213
|
+
{
|
|
214
|
+
pages: m.children,
|
|
215
|
+
tier: n + 1,
|
|
216
|
+
pageTypes: r,
|
|
217
|
+
currentPage: t,
|
|
218
|
+
onClickAction: l,
|
|
219
|
+
languagePages: o,
|
|
220
|
+
selectedLanguage: b,
|
|
221
|
+
showUntranslatedPages: f
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
] }, m.id)) });
|
|
225
|
+
}, He = U(() => import("./page-manager-search-and-filter-DIiowi9F.js")), Qe = U(() => import("./add-new-page-Bs_NXM9x.js")), Ve = U(() => import("./delete-page-D8xhYESu.js")), Je = U(() => import("./duplicate-page-CqXTGmWt.js")), Ke = U(() => import("./mark-as-template-jdwcgRIB.js")), Xe = U(() => import("./unmark-as-template-UwmCCn0u.js")), Ye = U(() => import("./unpublish-page-CNwIU6AS.js")), ot = ({ close: e }) => {
|
|
226
|
+
const { languages: n, setSelectedLang: r } = re(), { data: t } = ke(), { data: l, isFetching: o } = Ne(), [b, f] = we(), { updateForSelectedPage: x, expandPagesOnSearch: m } = J(null), d = oe(), i = b.get("page"), [P, S] = N(""), [y, u] = N(null), [A, L] = N(null), [g, j] = N(null), [B, c] = N(null), [T, R] = N(""), [K, X] = N(null), [Y, Z] = N(null), [k, he] = N(d), [fe, xe] = N(!1), [, ee] = Ee(ve), I = fe && k !== d, { data: $, isFetching: Pe } = Se(k), te = ae(
|
|
227
|
+
(h) => {
|
|
228
|
+
var a;
|
|
229
|
+
return (a = M(t, { key: h })) == null ? void 0 : a.hasSlug;
|
|
230
|
+
},
|
|
231
|
+
[t]
|
|
232
|
+
), w = Q(() => l ? I ? F(l, (h) => !($ != null && $[h.id])) : De(l, P, T, te) : [], [l, te, P, T, $, I]);
|
|
233
|
+
z(() => {
|
|
234
|
+
r(d);
|
|
235
|
+
}, [d, r]), z(() => {
|
|
236
|
+
if (!v(T)) return;
|
|
237
|
+
const h = sessionStorage.getItem("pageTypeFilter") || "all";
|
|
238
|
+
!v(t) && h && (M(t, { key: h }) ? R(h) : R("all"));
|
|
239
|
+
}, [t, T]), z(() => {
|
|
240
|
+
if (i && !o && !M(l, { id: i })) {
|
|
241
|
+
const a = M(l, { slug: "/" });
|
|
242
|
+
if (a) {
|
|
243
|
+
const G = new URLSearchParams({ page: a.id });
|
|
244
|
+
q(G, f);
|
|
245
|
+
} else
|
|
246
|
+
q(new URLSearchParams({}), f, !0);
|
|
247
|
+
}
|
|
248
|
+
}, [l, i, o, f]), z(() => {
|
|
249
|
+
i && !o && !v(w) && x(w, i);
|
|
250
|
+
}, [i, o, w, x]), z(() => {
|
|
251
|
+
!v(P) && !v(w) && m(w);
|
|
252
|
+
}, [P, w, m]);
|
|
253
|
+
const { setSelectedLang: W } = re(), se = ae(
|
|
254
|
+
(h) => {
|
|
255
|
+
const a = new URLSearchParams({ page: h });
|
|
256
|
+
k !== d ? (a.set("lang", k), W(k)) : W(""), q(a, f), e();
|
|
257
|
+
},
|
|
258
|
+
[e, f, W, k, d]
|
|
259
|
+
), ne = (h, a) => {
|
|
260
|
+
var G;
|
|
261
|
+
if (a)
|
|
262
|
+
switch (h) {
|
|
263
|
+
case "add":
|
|
264
|
+
L(a);
|
|
265
|
+
break;
|
|
266
|
+
case "select":
|
|
267
|
+
se(a);
|
|
268
|
+
break;
|
|
269
|
+
case "edit":
|
|
270
|
+
k !== d ? ee({
|
|
271
|
+
edit: !0,
|
|
272
|
+
id: a == null ? void 0 : a.id,
|
|
273
|
+
primaryPage: a == null ? void 0 : a.primaryPage
|
|
274
|
+
}) : L(a);
|
|
275
|
+
break;
|
|
276
|
+
case "delete":
|
|
277
|
+
u(a);
|
|
278
|
+
break;
|
|
279
|
+
case "unpublish":
|
|
280
|
+
j(a);
|
|
281
|
+
break;
|
|
282
|
+
case "markAsTemplate":
|
|
283
|
+
c(a);
|
|
284
|
+
break;
|
|
285
|
+
case "unmarkAsTemplate":
|
|
286
|
+
Z(a);
|
|
287
|
+
break;
|
|
288
|
+
case "duplicate":
|
|
289
|
+
X(a);
|
|
290
|
+
break;
|
|
291
|
+
case "addLanguagePage":
|
|
292
|
+
ee({
|
|
293
|
+
edit: !1,
|
|
294
|
+
primaryPage: ((G = a == null ? void 0 : a.page) == null ? void 0 : G.id) || "",
|
|
295
|
+
preselectedLang: (a == null ? void 0 : a.language) || k
|
|
296
|
+
});
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
return /* @__PURE__ */ p(O, { children: [
|
|
301
|
+
/* @__PURE__ */ p("div", { className: "flex h-full flex-col justify-between", children: [
|
|
302
|
+
/* @__PURE__ */ s(C, { children: /* @__PURE__ */ s(
|
|
303
|
+
He,
|
|
304
|
+
{
|
|
305
|
+
pages: w,
|
|
306
|
+
search: P,
|
|
307
|
+
setSearch: S,
|
|
308
|
+
languages: [d, ...n],
|
|
309
|
+
selectedLanguage: k,
|
|
310
|
+
setSelectedLanguage: he,
|
|
311
|
+
selectedPageType: T,
|
|
312
|
+
setSelectedPageType: R,
|
|
313
|
+
onAddPage: (h) => ne("add", h),
|
|
314
|
+
showUntranslatedPages: I,
|
|
315
|
+
setShowUntranslatedPages: xe
|
|
316
|
+
}
|
|
317
|
+
) }),
|
|
318
|
+
/* @__PURE__ */ s("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: o || Pe ? /* @__PURE__ */ s("div", { className: "space-y-2", children: Ce([...Array(15).keys()], (h) => /* @__PURE__ */ s("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, h)) }) : v(w) ? /* @__PURE__ */ p("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
|
|
319
|
+
/* @__PURE__ */ s(de, { className: "h-6 w-6 stroke-[1]" }),
|
|
320
|
+
"Empty List!",
|
|
321
|
+
/* @__PURE__ */ s("span", { className: "font-light", children: "Add new page to start" })
|
|
322
|
+
] }) : /* @__PURE__ */ s(
|
|
323
|
+
me,
|
|
324
|
+
{
|
|
325
|
+
tier: 0,
|
|
326
|
+
pages: w,
|
|
327
|
+
pageTypes: t,
|
|
328
|
+
currentPage: i || "",
|
|
329
|
+
onClickAction: ne,
|
|
330
|
+
languagePages: $,
|
|
331
|
+
selectedLanguage: k,
|
|
332
|
+
showUntranslatedPages: I
|
|
333
|
+
}
|
|
334
|
+
) })
|
|
335
|
+
] }),
|
|
336
|
+
A && /* @__PURE__ */ s(C, { children: /* @__PURE__ */ s(
|
|
337
|
+
Qe,
|
|
338
|
+
{
|
|
339
|
+
closePanel: e,
|
|
340
|
+
editPage: se,
|
|
341
|
+
addEditPage: A,
|
|
342
|
+
setAddEditPage: L
|
|
343
|
+
}
|
|
344
|
+
) }),
|
|
345
|
+
y && /* @__PURE__ */ s(C, { children: /* @__PURE__ */ s(Ve, { page: y, onClose: () => u(null) }) }),
|
|
346
|
+
g && /* @__PURE__ */ s(C, { children: /* @__PURE__ */ s(Ye, { page: g, onClose: () => j(null) }) }),
|
|
347
|
+
B && /* @__PURE__ */ s(C, { children: /* @__PURE__ */ s(Ke, { page: B, onClose: () => c(null) }) }),
|
|
348
|
+
Y && /* @__PURE__ */ s(C, { children: /* @__PURE__ */ s(Xe, { page: Y, onClose: () => Z(null) }) }),
|
|
349
|
+
K && /* @__PURE__ */ s(C, { children: /* @__PURE__ */ s(Je, { page: K, onClose: () => X(null), closePanel: e }) })
|
|
350
|
+
] });
|
|
351
|
+
};
|
|
352
|
+
export {
|
|
353
|
+
ot as default
|
|
354
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("./index-LU0FTfeN.cjs"),y=require("./use-page-expand-manager-B7JtHdg5.cjs"),s=require("@chaibuilder/sdk/ui"),b=require("@tanstack/react-query"),r=require("lodash-es"),c=require("lucide-react"),N=require("react"),w=({selectedPageType:n,setSelectedPageType:a})=>{const[o,l]=N.useState(""),{data:i}=m.usePageTypes(),d=t=>{if(!o)return!0;const x=o.toLowerCase(),h=p=>String(r.get(t,p,"")).toLowerCase().includes(x);return h("name")||h("key")},u=i.find(t=>t.key===n);return e.jsxs(s.Select,{onValueChange:a,value:n,children:[e.jsx(s.SelectTrigger,{className:`${n==="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:(u==null?void 0:u.name)||"All"}),e.jsx(c.ListFilter,{className:`${n!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(s.SelectContent,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white pb-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(c.Search,{strokeWidth:2,className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400"}),e.jsx(s.Input,{placeholder:"Search page types...",className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:o,onChange:t=>l(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(s.SelectItem,{value:"all",children:"All"}),!r.isEmpty(r.filter(i,t=>t.hasSlug&&d(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:"Pages"}),r.map([...r.filter(i,t=>t.hasSlug&&d(t))].sort((t,x)=>r.get(t,"name","").localeCompare(r.get(x,"name",""))),t=>e.jsx(s.SelectItem,{value:r.get(t,"key"),children:r.get(t,"name")},r.get(t,"key")))]}),!r.isEmpty(r.filter(i,t=>!t.hasSlug&&d(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:"Partials"}),r.map([...r.filter(i,t=>!t.hasSlug&&d(t))].sort((t,x)=>r.get(t,"name","").localeCompare(r.get(x,"name",""))),t=>e.jsx(s.SelectItem,{value:r.get(t,"key"),children:r.get(t,"name")},r.get(t,"key")))]}),r.isEmpty(r.filter(i,d))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:"No matching page types found"})]})]})},C=({search:n,setSearch:a})=>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:"Search Pages"}),e.jsx(c.Search,{className:`${n?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(s.Input,{id:"page-search-input",placeholder:"Search pages",value:n,onChange:o=>a(o.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"})]}),S=({pages:n})=>{const{expandAll:a,collapseAll:o,expandedPages:l}=y.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"icon",onClick:()=>a(n),className:"rounded p-1 text-gray-500",children:e.jsx(c.ChevronsUpDown,{})})}),e.jsx(s.TooltipContent,{children:"Expand All"})]}),e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{disabled:l.length===0,variant:"outline",size:"icon",onClick:()=>o(),className:"rounded p-1 text-gray-500",children:e.jsx(c.ChevronsDownUp,{})})}),e.jsx(s.TooltipContent,{children:"Collapse All"})]})]})},f=({languages:n,selectedLanguage:a,setSelectedLanguage:o})=>{const l=m.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:n.map(i=>e.jsxs(s.Button,{variant:a===i?"default":"outline",size:"sm",className:`h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${a===i?"bg-black text-white hover:bg-black":"text-gray-500"}`,onClick:()=>o(i.toLowerCase()),children:[i===l&&e.jsx(c.Star,{size:4,className:`p-0.5 ${a===l?"fill-white":"fill-black"}`}),m.LANGUAGES[i]||""]},i))})},j=()=>{const n=b.useQueryClient();return e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{size:"sm",variant:"ghost",onClick:()=>n.invalidateQueries({queryKey:[m.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(c.RefreshCw,{})})}),e.jsx(s.TooltipContent,{side:"bottom",children:"Refresh pages list"})]})},k=({pages:n,search:a,setSearch:o,languages:l,onAddPage:i,selectedLanguage:d,setSelectedLanguage:u,selectedPageType:t,setSelectedPageType:x,showUntranslatedPages:h,setShowUntranslatedPages:p})=>{const g=l.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(w,{selectedPageType:t,setSelectedPageType:x}),e.jsx(C,{search:a,setSearch:o}),e.jsx(S,{pages:n}),e.jsxs(s.Button,{variant:"default",onClick:i,className:"rounded px-3 font-normal",children:[e.jsx(c.Plus,{strokeWidth:2,className:"stroke-white stroke-[3]"}),e.jsx("span",{className:"font-normal text-white",children:"Add Page"})]}),!g&&e.jsx(j,{})]}),g?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(f,{languages:l,selectedLanguage:d,setSelectedLanguage:v=>{u(v),p(h&&(l==null?void 0:l[0])!==d)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(l==null?void 0:l[0])!==d&&e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",onClick:()=>p(!h),className:"h-6 rounded px-3 py-1 text-xs font-normal",children:h?e.jsx(c.FilterXIcon,{}):e.jsx(c.Filter,{})})}),e.jsx(s.TooltipContent,{side:"bottom",children:"Toggle Untranslated Pages"})]}),e.jsx(j,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=f;exports.default=k;
|