ode-explorer 1.0.0-develop-pedago.202308291154 → 1.0.0-develop-b2school.202308311723

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/AppAction.js CHANGED
@@ -1 +1 @@
1
- import{c as r,d as l,u as c,j as e,B as i,S as p,r as a,L as u,_ as d}from"./index.js";import"/assets/js/edifice-ts-client/index.js";const x=a.lazy(async()=>await d(()=>import("./EditResourceModal.js"),["EditResourceModal.js","index.js","Heading.js","index.esm.js","ImagePicker.js"]));function _(){const[t,s]=r(),{appCode:o}=l(),{t:n}=c(o);return e.jsxs(e.Fragment,{children:[e.jsx(i,{type:"button",color:"primary",variant:"filled",leftIcon:e.jsx(p,{}),className:"ms-auto",onClick:s,children:n("explorer.create.title")}),e.jsx(a.Suspense,{fallback:e.jsx(u,{}),children:t&&e.jsx(x,{edit:!1,isOpen:t,onSuccess:s,onCancel:s})})]})}export{_ as default};
1
+ import{u as a,a as n,c as r,j as t,B as c,S as i}from"./index.js";function u(){const{appCode:e}=a(),{t:s}=n(e),{createResource:o}=r();return t.jsx(c,{type:"button",color:"primary",variant:"filled",leftIcon:t.jsx(i,{}),className:"ms-auto",onClick:o,children:s("explorer.create.title")})}export{u as default};
package/dist/Card.js CHANGED
@@ -1 +1 @@
1
- import{r as E,g as a,j as s,s as F,ae as U,af as G,ag as q,ah as D,ai as H,p as J,aj as K,I as M,a6 as Q}from"./index.js";import{T as i}from"./Tooltip.js";const d=E.forwardRef(({app:t,className:h,creatorName:r="tom.mate",isAnimated:x=!1,isFolder:l=!1,isLoading:e=!1,isSelected:m=!1,isShared:p=!1,isPublic:j=!1,name:g="Resource",resourceSrc:o="",updatedAt:f="2 days ago",userSrc:n="",onOpen:u,onSelect:c,messagePublic:v,messageShared:N,...$},b)=>{const{getIconCode:w}=D(),C=a("card",{"placeholder-glow":e,"is-selected":m,"is-animated":x},h),y=a("card-title body text-break text-truncate text-truncate-2 pe-32",{placeholder:e}),I=a("card-text small",{placeholder:e}),O=a("small text-truncate",{placeholder:e}),R=a("d-inline-flex align-items-center gap-8 text-truncate",{placeholder:e}),T=t?w(t):"placeholder",z=a(`color-app-${T}`,{placeholder:e});function P(B){B.stopPropagation(),c==null||c()}const k=l?s.jsx(H,{width:"48",height:"48",className:z}):o?s.jsx("div",{className:"card-image",children:s.jsx(M,{alt:"",src:o,width:"80",height:"80",objectFit:"cover",className:"h-full"})}):s.jsx(Q,{app:t,iconFit:"ratio",size:"80",variant:"rounded"}),A=n?s.jsx(J,{alt:r,size:"xs",src:n,variant:"circle",width:"24",height:"24"}):s.jsx(K,{});return s.jsxs("div",{ref:b,className:C,...$,children:[!e&&s.jsx(F,{"aria-label":"Open Action Bar",className:"z-3",color:"secondary",icon:s.jsx(U,{}),onClick:P,variant:"ghost"}),s.jsx("button",{onClick:u,className:"position-absolute bottom-0 end-0 top-0 start-0 opacity-0 z-1 w-100","aria-label":"Open resource"}),s.jsxs("div",{className:"card-body",children:[k,s.jsxs("div",{children:[s.jsx("h3",{className:y,children:s.jsx("strong",{children:g})}),l?null:s.jsx("p",{className:"card-text small",children:s.jsx("em",{className:I,children:f})})]})]}),l?null:s.jsxs("div",{className:"card-footer gap-16",children:[s.jsxs("div",{className:R,children:[A,s.jsx("p",{className:O,children:r})]}),s.jsxs("div",{className:"d-inline-flex align-items-center gap-8",children:[j&&s.jsx(i,{message:v,placement:"top",children:s.jsx(G,{width:16,height:16})}),p&&s.jsx(i,{message:N,placement:"top",children:s.jsx(q,{width:16,height:16})})]})]})]})});d.displayName="Card";const X=d;export{X as C};
1
+ import{r as R,f as a,j as s,t as B,ae as E,af as F,I as q,a8 as G,q as U,ag as D,ah as H,ai as J,aj as K}from"./index.js";import{T as n}from"./Tooltip.js";const d=R.forwardRef(({app:l,className:h,creatorName:r="tom.mate",isAnimated:x=!1,isFolder:t=!1,isLoading:e=!1,isSelected:m=!1,isShared:p=!1,isPublic:j=!1,name:g="Resource",resourceSrc:i="",updatedAt:v="2 days ago",userSrc:o="",onOpen:u,onSelect:c,messagePublic:N,messageShared:f,...$},b)=>{const{getIconCode:w}=K(),C=a("card",{"placeholder-glow":e,"is-selected":m,"is-animated":x},h),y=a("card-title body text-break text-truncate text-truncate--2 pe-32",{placeholder:e}),I=a("card-text small",{placeholder:e}),O=a("small text-truncate",{placeholder:e}),z=a("d-inline-flex align-items-center gap-8 text-truncate",{placeholder:e}),T=l?w(l):"placeholder",k=a(`color-app-${T}`,{placeholder:e});function A(P){P.stopPropagation(),c==null||c()}return s.jsxs("div",{ref:b,className:C,...$,children:[!e&&s.jsx(B,{"aria-label":"Open Action Bar",className:"z-3",color:"secondary",icon:s.jsx(E,{}),onClick:A,variant:"ghost"}),s.jsx("button",{onClick:u,className:"position-absolute bottom-0 end-0 top-0 start-0 opacity-0 z-1 w-100","aria-label":"Open resource"}),s.jsxs("div",{className:"card-body",children:[t?s.jsx(F,{width:"48",height:"48",className:k}):i?s.jsx("div",{className:"card-image",children:s.jsx(q,{alt:"",src:i,width:"80",height:"80",objectFit:"cover",className:"h-full"})}):s.jsx(G,{app:l,iconFit:"ratio",size:"80",variant:"rounded"}),s.jsxs("div",{children:[s.jsx("h3",{className:y,children:s.jsx("strong",{children:g})}),t?null:s.jsx("p",{className:"card-text small",children:s.jsx("em",{className:I,children:v})})]})]}),t?null:s.jsxs("div",{className:"card-footer gap-16",children:[s.jsxs("div",{className:z,children:[o?s.jsx(U,{alt:r,size:"xs",src:o,variant:"circle",width:"24",height:"24"}):s.jsx(D,{}),s.jsx("p",{className:O,children:r})]}),s.jsxs("div",{className:"d-inline-flex align-items-center gap-8",children:[j&&s.jsx(n,{message:N,placement:"top",children:s.jsx(H,{width:16,height:16})}),p&&s.jsx(n,{message:f,placement:"top",children:s.jsx(J,{width:16,height:16})})]})]})]})});d.displayName="Card";const S=d;export{S as C};
@@ -1 +1 @@
1
- import{u as d,z as u,C as x,D as p,n as m,A as j,a as f,j as e,M as n,B as i}from"./index.js";import"/assets/js/edifice-ts-client/index.js";function y({onSuccess:o}){const{t:l}=d(),s=u(),t=x(),r=p(),{hotToast:a}=m(j);async function c(){try{r?(await s.mutate(),a.success(l("explorer.removed.from.trash"))):(await t.mutate(),a.success(l("explorer.trash.title"))),o==null||o()}catch(h){console.error(h)}}return{isTrashFolder:r,onDelete:c}}function T({isOpen:o,onSuccess:l=()=>({}),onCancel:s=()=>({})}){const{t}=d(),{isTrashFolder:r,onDelete:a}=y({onSuccess:l});return f.createPortal(e.jsxs(n,{isOpen:o,onModalClose:s,id:"deleteModal",children:[e.jsx(n.Header,{onModalClose:s,children:t(r?"explorer.delete.title":"explorer.trash.title")}),e.jsx(n.Body,{children:e.jsx("p",{className:"body",children:t(r?"explorer.delete.subtitle":"explorer.trash.subtitle")})}),e.jsxs(n.Footer,{children:[e.jsx(i,{color:"tertiary",onClick:s,type:"button",variant:"ghost",children:t("explorer.cancel")}),e.jsx(i,{color:"danger",onClick:a,type:"button",variant:"filled",children:t(r?"explorer.delete":"explorer.trash")})]})]}),document.getElementById("portal"))}export{T as default};
1
+ import{a as d,z as x,C as p,D as u,m,p as j,b as y,j as e,M as n,B as i}from"./index.js";function f({onSuccess:o}){const{t:l}=d(),s=x(),t=p(),r=u(),{hotToast:a}=m(j);async function c(){try{r?(await s.mutate(),a.success(l("explorer.removed.from.trash"))):(await t.mutate(),a.success(l("explorer.trash.title"))),o==null||o()}catch(h){console.error(h)}}return{isTrashFolder:r,onDelete:c}}function M({isOpen:o,onSuccess:l=()=>({}),onCancel:s=()=>({})}){const{t}=d(),{isTrashFolder:r,onDelete:a}=f({onSuccess:l});return y.createPortal(e.jsxs(n,{isOpen:o,onModalClose:s,id:"deleteModal",children:[e.jsx(n.Header,{onModalClose:s,children:t(r?"explorer.delete.title":"explorer.trash.title")}),e.jsx(n.Body,{children:e.jsx("p",{className:"body",children:t(r?"explorer.delete.subtitle":"explorer.trash.subtitle")})}),e.jsxs(n.Footer,{children:[e.jsx(i,{color:"tertiary",onClick:s,type:"button",variant:"ghost",children:t("explorer.cancel")}),e.jsx(i,{color:"primary",onClick:a,type:"button",variant:"filled",children:t(r?"explorer.delete":"explorer.trash")})]})]}),document.getElementById("portal"))}export{M as default};
@@ -1 +1 @@
1
- import{G as D,N as B,O as q,P as L,r as C,u as R,a as w,j as r,M as s,F as P,Q as T,x as U,B as y}from"./index.js";import{FOLDER as V}from"/assets/js/edifice-ts-client/index.js";import{u as _}from"./index.esm.js";function k({edit:a,onSuccess:e,onClose:i}){var F;const l=D(),t=B(),m=q(),c=L(),u=a?(F=l[0])==null?void 0:F.name:void 0,{reset:o,register:f,handleSubmit:n,setFocus:p,formState:{errors:x,isSubmitting:h,isDirty:I,isValid:E}}=_({mode:"onChange",values:{name:u||""}}),g=C.useId(),M=async function({name:j}){var b;try{if(a){const d=(b=l[0])==null?void 0:b.parentId,$=l[0].id;await c.mutate({folderId:$,parentId:d,name:j}),o(),e==null||e()}else{const d=(t==null?void 0:t.id)||V.DEFAULT;await m.mutate({name:j,parentId:d}),o(),e==null||e()}}catch(d){console.error(d)}};function v(){o(),i()}return{formId:`createModal_${g}`,errors:x,isSubmitting:h,isDirty:I,isValid:E,register:f,setFocus:p,handleSubmit:n,onCancel:v,onSubmit:M}}function Q({isOpen:a,edit:e,onSuccess:i,onCancel:l}){const{t}=R(),{isDirty:m,isValid:c,isSubmitting:u,formId:o,onSubmit:f,onCancel:n,handleSubmit:p,register:x,setFocus:h}=k({edit:e,onSuccess:i,onClose:l});return C.useEffect(()=>{a&&h("name")},[a]),w.createPortal(r.jsxs(s,{isOpen:a,onModalClose:n,id:"modal_"+o,children:[r.jsx(s.Header,{onModalClose:n,children:t(e?"explorer.rename.folder":"explorer.create.folder")}),r.jsx(s.Body,{children:r.jsx("form",{id:o,onSubmit:p(f),children:r.jsxs(P,{id:"nameFolder",isRequired:!0,children:[r.jsx(T,{children:t("explorer.create.folder.name")}),r.jsx(U,{type:"text",...x("name",{required:!0,pattern:{value:/[^ ]/,message:"invalid title"}}),placeholder:t("explorer.create.folder.name"),size:"md","aria-required":!0})]})})}),r.jsxs(s.Footer,{children:[r.jsx(y,{color:"tertiary",onClick:n,type:"button",variant:"ghost",children:t("explorer.cancel")}),r.jsx(y,{form:o,type:"submit",color:"primary",variant:"filled",disabled:!m||!c||u,children:t(e?"explorer.rename":"explorer.create")})]})]}),document.getElementById("portal"))}export{Q as default};
1
+ import{G as D,N as B,O as q,P as L,r as C,Q as R,a as U,b as w,j as r,M as s,F as P,U as T,y as V,B as y}from"./index.js";import{u as _}from"./index.esm.js";function k({edit:a,onSuccess:e,onClose:i}){var F;const l=D(),t=B(),m=q(),c=L(),u=a?(F=l[0])==null?void 0:F.name:void 0,{reset:o,register:f,handleSubmit:n,setFocus:p,formState:{errors:x,isSubmitting:h,isDirty:I,isValid:E}}=_({mode:"onChange",values:{name:u||""}}),g=C.useId(),M=async function({name:b}){var j;try{if(a){const d=(j=l[0])==null?void 0:j.parentId,$=l[0].id;await c.mutate({folderId:$,parentId:d,name:b}),o(),e==null||e()}else{const d=(t==null?void 0:t.id)||R.DEFAULT;await m.mutate({name:b,parentId:d}),o(),e==null||e()}}catch(d){console.error(d)}};function v(){o(),i()}return{formId:`createModal_${g}`,errors:x,isSubmitting:h,isDirty:I,isValid:E,register:f,setFocus:p,handleSubmit:n,onCancel:v,onSubmit:M}}function N({isOpen:a,edit:e,onSuccess:i,onCancel:l}){const{t}=U(),{isDirty:m,isValid:c,isSubmitting:u,formId:o,onSubmit:f,onCancel:n,handleSubmit:p,register:x,setFocus:h}=k({edit:e,onSuccess:i,onClose:l});return C.useEffect(()=>{a&&h("name")},[a]),w.createPortal(r.jsxs(s,{isOpen:a,onModalClose:n,id:"modal_"+o,children:[r.jsx(s.Header,{onModalClose:n,children:t(e?"explorer.rename.folder":"explorer.create.folder")}),r.jsx(s.Body,{children:r.jsx("form",{id:o,onSubmit:p(f),children:r.jsxs(P,{id:"nameFolder",isRequired:!0,children:[r.jsx(T,{children:t("explorer.create.folder.name")}),r.jsx(V,{type:"text",...x("name",{required:!0,pattern:{value:/[^ ]/,message:"invalid title"}}),placeholder:t("explorer.create.folder.name"),size:"md","aria-required":!0})]})})}),r.jsxs(s.Footer,{children:[r.jsx(y,{color:"tertiary",onClick:n,type:"button",variant:"ghost",children:t("explorer.cancel")}),r.jsx(y,{form:o,type:"submit",color:"primary",variant:"filled",disabled:!m||!c||u,children:t(e?"explorer.rename":"explorer.create")})]})]}),document.getElementById("portal"))}export{N as default};
@@ -1 +1 @@
1
- import{u as B,j as e,A as U,F as g,x as V,U as le,B as A,W as ae,d as q,l as ie,X as re,k as H,r as x,N as oe,n as ne,Y as ce,a as de,M as C,Q as O,Z as ue}from"./index.js";import{APP as G}from"/assets/js/edifice-ts-client/index.js";import{H as Q}from"./Heading.js";import{u as pe}from"./index.esm.js";import{I as me,T as he}from"./ImagePicker.js";const xe=({appCode:r,correctSlug:a,disableSlug:o,onPublicChange:c,onSlugChange:p,refPublic:d,refSlug:v,register:t,resource:m,slug:h,onCopyToClipBoard:b})=>{const{t:i}=B();return e.jsxs(e.Fragment,{children:[e.jsxs(Q,{headingStyle:"h4",level:"h3",className:"mb-16",children:[i("explorer.resource.editModal.heading.access"),r]}),e.jsx(U,{type:"info",children:i("explorer.resource.editModal.access.alert")}),e.jsxs(g,{id:"flexSwitchCheckDefault",className:"form-switch d-flex gap-8 mt-16 mb-8",children:[e.jsx(g.Input,{type:"checkbox",role:"switch",...t("enablePublic",{value:m.public,onChange:n=>c(n.target.checked)}),className:"form-check-input mt-0",size:"md"},d),e.jsx(g.Label,{className:"form-check-label mb-0",children:i("explorer.resource.editModal.access.flexSwitchCheckDefault.label")})]}),e.jsx(g,{id:"slug",status:a?"invalid":void 0,children:e.jsxs("div",{className:"d-flex flex-wrap align-items-center gap-4",children:[e.jsxs("div",{children:[window.location.origin,window.location.pathname,"/pub/"]}),e.jsxs("div",{className:"flex-fill",children:[e.jsx(V,{type:"text",...t("safeSlug",{validate:{required:n=>!n&&!o?i("explorer.slug.name.mandatory"):!0},disabled:o,value:h,onChange:n=>p(n.target.value)}),size:"md",placeholder:i("explorer.resource.editModal.access.url.extension")},v),a&&e.jsx("div",{className:"position-absolute",children:e.jsx(le,{children:i("explorer.slug.name.error")})})]}),e.jsx(A,{color:"primary",disabled:o,onClick:()=>{b()},type:"button",leftIcon:e.jsx(ae,{}),variant:"ghost",className:"text-nowrap",children:i("explorer.resource.editModal.access.url.button")})]})})]})};function ge({resource:r,edit:a,onSuccess:o,onCancel:c}){var _;const{appCode:p}=q(),{t:d}=B(),v=ie(),t=re(),m=H(),{reset:h,register:b,handleSubmit:i,setFocus:n,formState:{errors:I,isSubmitting:M,isValid:j}}=pe({mode:"onChange"}),$=x.useId(),u=oe(),[k,N]=x.useState(new Date().getTime()),[P,R]=x.useState(!(r!=null&&r.public)),[S,w]=x.useState((r==null?void 0:r.slug)||""),[l,E]=x.useState(!1),{hotToast:F}=ne(U),[L,z]=x.useState({name:"",image:(_=m[0])==null?void 0:_.thumbnail}),W=s=>{z(s)},X=()=>{z({name:"",image:""})};function Y(s){R(!s),s||(w(""),N(new Date().getTime()))}function Z(s){if(!s)return"";const f="àáäâãåăæçèéëêǵḧìíïîḿńǹñòóöôœøṕŕßśșțùúüûǘẃẍÿź·/_,:;",y="aaaaaaaaceeeeghiiiimnnnooooooprssstuuuuuwxyz------",T=new RegExp(f.split("").join("|"),"g"),se=s.toString().toLowerCase().replace(/\s+/g,"-").replace(T,te=>y.charAt(f.indexOf(te))).replace(/&/g,"-and-").replace(/[^\w\\-]+/g,"").replace(/\\-\\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");w(se)}const D=async function(s){var f,y;try{a?await v.mutateAsync({description:s.description,entId:(f=m[0])==null?void 0:f.assetId,name:s.title,public:s.enablePublic,slug:s.safeSlug,trashed:(y=m[0])==null?void 0:y.trashed,thumbnail:L.image}):await t.mutateAsync({name:s.title,description:s.description,thumbnail:L.image,folder:(u==null?void 0:u.id)==="default"?void 0:parseInt((u==null?void 0:u.id)||""),public:s.enablePublic,slug:s.safeSlug,app:p}),a&&E(!1),F.success(e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:d("explorer.resource.updated")}),e.jsxs("p",{children:["Titre: ",s.title]}),e.jsxs("p",{children:["Description: ",s.description]}),a&&p===G.BLOG&&e.jsxs("p",{children:["Public:"," ",s.enablePublic?d("explorer.enable.public.yes"):d("explorer.enable.public.no")]})]})),o==null||o()}catch(T){E(!0),console.error(T)}};function J(){navigator.clipboard.writeText(`${window.location.origin}${window.location.pathname}/pub/${S}`),F.success(d("explorer.copy.clipboard"))}function K(){h(),c()}const ee=`resource_edit_modal_${$}`;return{slug:S,disableSlug:P,formId:ee,errors:I,isSubmitting:M,isValid:j,versionSlug:k,correctSlug:l,onPublicChange:Y,onSlugChange:Z,register:b,setFocus:n,handleSubmit:i,onFormCancel:K,onSubmit:D,handleUploadImage:W,handleDeleteImage:X,onCopyToClipBoard:J}}function we({isOpen:r,edit:a,onSuccess:o,onCancel:c}){const{appCode:p,currentApp:d}=q(),t=H()[0],{slug:m,formId:h,isValid:b,isSubmitting:i,disableSlug:n,versionSlug:I,correctSlug:M,register:j,handleSubmit:$,onSubmit:u,handleUploadImage:k,handleDeleteImage:N,onCopyToClipBoard:P,onSlugChange:R,onPublicChange:S}=ge({resource:t,edit:a,onSuccess:o,onCancel:c}),{data:w}=ce(),{t:l}=B();return de.createPortal(e.jsxs(C,{id:"resource_edit_modal",size:"lg",isOpen:r,onModalClose:c,children:[e.jsx(C.Header,{onModalClose:c,children:l(a?"explorer.resource.editModal.header.edit":"explorer.resource.editModal.header.create")}),e.jsxs(C.Body,{children:[e.jsx(Q,{headingStyle:"h4",level:"h3",className:"mb-16",children:l("explorer.resource.editModal.heading.general")}),e.jsxs("form",{id:h,onSubmit:$(u),children:[e.jsxs("div",{className:"d-flex gap-16 mb-24",children:[e.jsx("div",{children:e.jsx(me,{app:d,src:t==null?void 0:t.thumbnail,label:l("explorer.imagepicker.label"),addButtonLabel:l("explorer.imagepicker.button.add"),deleteButtonLabel:l("explorer.imagepicker.button.delete"),onUploadImage:k,onDeleteImage:N,className:"align-self-center mt-8"})}),e.jsxs("div",{className:"col",children:[e.jsxs(g,{id:"title",className:"mb-16",isRequired:!0,children:[e.jsx(O,{children:l("title")}),e.jsx(V,{type:"text",defaultValue:a?t==null?void 0:t.name:"",...j("title",{required:!0,pattern:{value:/[^ ]/,message:"invalid title"}}),placeholder:l("explorer.resource.editModal.title.placeholder"),size:"md","aria-required":!0})]}),e.jsxs(g,{id:"description",isOptional:!0,children:[e.jsx(O,{children:l("description")}),e.jsx(he,{defaultValue:a?t==null?void 0:t.description:"",...j("description"),placeholder:l("explorer.resource.editModal.description.placeholder"),size:"md"})]})]})]}),p===G.BLOG&&ue({workflow:"createPublic",actions:w})&&e.jsx(xe,{appCode:p,correctSlug:M,disableSlug:n,onCopyToClipBoard:P,onPublicChange:S,onSlugChange:R,resource:t,slug:m,versionSlug:I,register:j})]})]}),e.jsxs(C.Footer,{children:[e.jsx(A,{color:"tertiary",onClick:c,type:"button",variant:"ghost",children:l("explorer.cancel")}),e.jsx(A,{form:h,type:"submit",color:"primary",variant:"filled",disabled:!b||i,children:l(a?"save":"explorer.create")})]})]}),document.getElementById("portal"))}export{we as default};
1
+ import{a as B,j as e,H as A,p as E,F as m,y as P,W as G,B as T,X as J,k as K,i as z,r as p,m as Q,u as ee,Y as se,b as te,M as C,U as F,Z as le}from"./index.js";import{I as ae}from"./ImagePicker.js";import{u as re}from"./index.esm.js";const oe=({appCode:d,correctSlug:a,disableSlug:n,onPublicChange:r,onSlugChange:x,refPublic:c,refSlug:j,register:s,resource:h,slug:u,onCopyToClipBoard:g})=>{const{t:o}=B();return e.jsxs(e.Fragment,{children:[e.jsxs(A,{headingStyle:"h4",level:"h3",className:"mb-16",children:[o("explorer.resource.editModal.heading.access"),d]}),e.jsx(E,{type:"info",children:o("explorer.resource.editModal.access.alert")}),e.jsxs(m,{id:"flexSwitchCheckDefault",className:"form-switch d-flex gap-8 mt-16 mb-8",children:[e.jsx(m.Input,{type:"checkbox",role:"switch",...s("enablePublic",{value:h.public,onChange:i=>r(i.target.checked)}),className:"form-check-input mt-0",size:"md"},c),e.jsx(m.Label,{className:"form-check-label mb-0",children:o("explorer.resource.editModal.access.flexSwitchCheckDefault.label")})]}),e.jsx(m,{id:"slug",status:a?"invalid":void 0,children:e.jsxs("div",{className:"d-flex flex-wrap align-items-center gap-4",children:[e.jsxs("div",{children:[window.location.origin,window.location.pathname,"/pub/"]}),e.jsxs("div",{className:"flex-fill",children:[e.jsx(P,{type:"text",...s("safeSlug",{validate:{required:i=>!i&&!n?o("explorer.slug.name.mandatory"):!0},disabled:n,value:u,onChange:i=>x(i.target.value)}),size:"md",placeholder:o("explorer.resource.editModal.access.url.extension")},j),a&&e.jsx("div",{className:"position-absolute",children:e.jsx(G,{children:o("explorer.slug.name.error")})})]}),e.jsx(T,{color:"primary",disabled:n,onClick:()=>{g()},type:"button",leftIcon:e.jsx(J,{}),variant:"ghost",className:"text-nowrap",children:o("explorer.resource.editModal.access.url.button")})]})})]})};function ie({resource:d,onSuccess:a,onCancel:n}){const{t:r}=B(),x=K(),c=z(),{reset:j,register:s,handleSubmit:h,setFocus:u,formState:{errors:g,isSubmitting:o,isValid:i}}=re({mode:"onChange"}),I=p.useId(),[M,b]=p.useState(new Date().getTime()),[$,k]=p.useState(!d.public),[f,v]=p.useState(d.slug||""),[N,S]=p.useState(!1),{hotToast:y}=Q(E),[R,l]=p.useState({name:"",image:c[0].thumbnail}),_=t=>{l(t)},L=()=>{l({name:"",image:""})};function U(t){k(!t),t||(v(""),b(new Date().getTime()))}function V(t){if(!t)return"";const w="àáäâãåăæçèéëêǵḧìíïîḿńǹñòóöôœøṕŕßśșțùúüûǘẃẍÿź·/_,:;",W="aaaaaaaaceeeeghiiiimnnnooooooprssstuuuuuwxyz------",X=new RegExp(w.split("").join("|"),"g"),Y=t.toString().toLowerCase().replace(/\s+/g,"-").replace(X,Z=>W.charAt(w.indexOf(Z))).replace(/&/g,"-and-").replace(/[^\w\\-]+/g,"").replace(/\\-\\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");v(Y)}const q=async function(t){try{await x.mutateAsync({description:t.description,entId:c[0].assetId,name:t.title,public:t.enablePublic,slug:t.safeSlug,trashed:c[0].trashed,thumbnail:R.image}),S(!1),y.success(e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:r("explorer.resource.updated")}),e.jsxs("p",{children:["Titre: ",t.title]}),e.jsxs("p",{children:["Description: ",t.description]}),e.jsxs("p",{children:["Public:"," ",t.enablePublic?r("explorer.enable.public.yes"):r("explorer.enable.public.no")]})]})),a==null||a()}catch(w){S(!0),console.error(w)}};function D(){navigator.clipboard.writeText(`${window.location.origin}${window.location.pathname}/pub/${f}`),y.success(r("explorer.copy.clipboard"))}function H(){j(),n()}const O=`resource_edit_modal_${I}`;return{slug:f,disableSlug:$,formId:O,errors:g,isSubmitting:o,isValid:i,versionSlug:M,correctSlug:N,onPublicChange:U,onSlugChange:V,register:s,setFocus:u,handleSubmit:h,onFormCancel:H,onSubmit:q,handleUploadImage:_,handleDeleteImage:L,onCopyToClipBoard:D}}function ue({isOpen:d,edit:a,onSuccess:n,onCancel:r}){const{appCode:x,currentApp:c}=ee(),s=z()[0],{slug:h,formId:u,isValid:g,isSubmitting:o,disableSlug:i,versionSlug:I,correctSlug:M,register:b,handleSubmit:$,onSubmit:k,handleUploadImage:f,handleDeleteImage:v,onCopyToClipBoard:N,onSlugChange:S,onPublicChange:y}=ie({resource:s,onSuccess:n,onCancel:r}),{data:R}=se(),{t:l}=B();return te.createPortal(e.jsxs(C,{id:"resource_edit_modal",size:"lg",isOpen:d,onModalClose:r,children:[e.jsx(C.Header,{onModalClose:r,children:l(a?"explorer.resource.editModal.header.edit":"explorer.resource.editModal.header.create")}),e.jsxs(C.Body,{children:[e.jsx(A,{headingStyle:"h4",level:"h3",className:"mb-16",children:l("explorer.resource.editModal.heading.general")}),e.jsxs("form",{id:u,onSubmit:$(k),children:[e.jsxs("div",{className:"d-flex flex-column flex-md-row gap-16 mb-24",children:[e.jsx(ae,{app:c,src:s==null?void 0:s.thumbnail,label:l("explorer.imagepicker.label"),addButtonLabel:l("explorer.imagepicker.button.add"),deleteButtonLabel:l("explorer.imagepicker.button.delete"),onUploadImage:f,onDeleteImage:v,className:"align-self-center"}),e.jsxs("div",{className:"col",children:[e.jsxs(m,{id:"title",className:"mb-16",isRequired:!0,children:[e.jsx(F,{children:l("title")}),e.jsx(P,{type:"text",defaultValue:a?s==null?void 0:s.name:"",...b("title",{required:!0,pattern:{value:/[^ ]/,message:"invalid title"}}),placeholder:l("explorer.resource.editModal.title.placeholder"),size:"md","aria-required":!0})]}),e.jsxs(m,{id:"description",isOptional:!0,children:[e.jsx(F,{children:l("description")}),e.jsx(P,{type:"text",defaultValue:a?s==null?void 0:s.description:"",...b("description"),placeholder:l("explorer.resource.editModal.description.placeholder"),size:"md"})]})]})]}),le({workflow:"createPublic",actions:R})&&e.jsx(oe,{appCode:x,correctSlug:M,disableSlug:i,onCopyToClipBoard:N,onPublicChange:y,onSlugChange:S,resource:s,slug:h,versionSlug:I,register:b})]})]}),e.jsxs(C.Footer,{children:[e.jsx(T,{color:"tertiary",onClick:r,type:"button",variant:"ghost",children:l("explorer.cancel")}),e.jsx(T,{form:u,type:"submit",color:"primary",variant:"filled",disabled:!g||o,children:l(a?"save":"explorer.create")})]})]}),document.getElementById("portal"))}export{ue as default};
@@ -1 +1 @@
1
- import{j as e}from"./index.js";import{H as c}from"./Heading.js";const r=({imageSrc:s,imageAlt:t="",title:a,text:m})=>e.jsxs("div",{className:"emptyscreen",children:[s&&e.jsx("div",{className:"emptyscreen-image mb-12",children:e.jsx("img",{className:"mx-auto",src:s,alt:t,width:"250",height:"250"})}),a&&e.jsx(c,{level:"h2",headingStyle:"h2",className:"text-secondary mb-8",children:a}),m&&e.jsx("div",{className:"text",children:m})]});r.displayName="EmptyScreen";const l=r;export{l as E};
1
+ import{j as e,H as n}from"./index.js";const c=({imageSrc:s,imageAlt:t="",title:a,text:m})=>e.jsxs("div",{className:"emptyscreen",children:[s&&e.jsx("div",{className:"emptyscreen-image mb-12",children:e.jsx("img",{className:"mx-auto",src:s,alt:t,width:"250",height:"250"})}),a&&e.jsx(n,{level:"h2",headingStyle:"h2",className:"text-secondary mb-8",children:a}),m&&e.jsx("div",{className:"text",children:m})]});c.displayName="EmptyScreen";const r=c;export{r as E};
@@ -1 +1 @@
1
- import{d as i,f as a,u as c,Y as u,j as m,b as x}from"./index.js";import{E as d}from"./EmptyScreen.js";import"/assets/js/edifice-ts-client/index.js";import"./Heading.js";function v(){const{appCode:r}=i(),{theme:t}=a(),[l]=x(),{t:s}=c(),{data:n}=u(),e=n==null?void 0:n.find(o=>o.id==="create"),p=()=>e!=null&&e.available&&(t!=null&&t.is1d)?s("explorer.emptyScreen.txt1d.create",{ns:r}):e!=null&&e.available&&!(t!=null&&t.is1d)?s("explorer.emptyScreen.txt2d.create",{ns:r}):!(e!=null&&e.available)&&(t!=null&&t.is1d)?s("explorer.emptyScreen.txt1d.consultation",{ns:r}):s("explorer.emptyScreen.txt2d.consultation",{ns:r});return m.jsx(d,{imageSrc:`${l}/emptyscreen/illu-${r}.svg`,imageAlt:s("explorer.emptyScreen.app.alt",{ns:r}),title:`${e!=null&&e.available?s("explorer.emptyScreen.title.create",{ns:r}):s("explorer.emptyScreen.title.consultation")}`,text:p()})}export{v as default};
1
+ import{u as i,a as n,Y as a,j as c}from"./index.js";import{E as u}from"./EmptyScreen.js";function b(){const{appCode:o,theme:e}=i(),{t:r}=n(),{data:l}=a(),t=l==null?void 0:l.find(s=>s.id==="create"),p=()=>t!=null&&t.available&&(e!=null&&e.is1d)?r("explorer.emptyScreen.blog.txt1d.create"):t!=null&&t.available&&!(e!=null&&e.is1d)?r("explorer.emptyScreen.blog.txt2d.create"):!(t!=null&&t.available)&&(e!=null&&e.is1d)?r("explorer.emptyScreen.blog.txt1d.consultation"):r("explorer.emptyScreen.blog.txt2d.consultation");return c.jsx(u,{imageSrc:`${e==null?void 0:e.bootstrapPath}/images/emptyscreen/illu-${o}.svg`,imageAlt:r("explorer.emptyScreen.app.alt"),title:`${t!=null&&t.available?r("explorer.emptyScreen.blog.title.create"):r("explorer.emptyScreen.blog.title.consultation")}`,text:p()})}export{b as default};
@@ -1 +1 @@
1
- import{u as r,j as o,b as n}from"./index.js";import{E as m}from"./EmptyScreen.js";import"/assets/js/edifice-ts-client/index.js";import"./Heading.js";function i(){const[t]=n(),{t:e}=r();return o.jsx(m,{imageSrc:`${t}/emptyscreen/illu-no-content-in-folder.svg`,imageAlt:e("explorer.emptyScreen.folder.empty.alt"),text:e("explorer.emptyScreen.label")})}export{i as default};
1
+ import{u as r,a as n,j as o}from"./index.js";import{E as s}from"./EmptyScreen.js";function m(){const{theme:e}=r(),{t}=n();return o.jsx(s,{imageSrc:`${e==null?void 0:e.bootstrapPath}/images/emptyscreen/illu-no-content-in-folder.svg`,imageAlt:t("explorer.emptyScreen.folder.empty.alt"),text:t("explorer.emptyScreen.label")})}export{m as default};
@@ -1 +1 @@
1
- import{d as s,u as a,j as p,b as m}from"./index.js";import{E as n}from"./EmptyScreen.js";import"/assets/js/edifice-ts-client/index.js";import"./Heading.js";function u(){const{appCode:t}=s(),[r]=m(),{t:e}=a();return p.jsx(n,{imageSrc:`${r}/emptyscreen/illu-trash.svg`,imageAlt:e("explorer.emptyScreen.trash.alt"),title:e("explorer.emptyScreen.trash.title"),text:e("explorer.emptyScreen.trash.empty",{ns:t})})}export{u as default};
1
+ import{u as r,a,j as n}from"./index.js";import{E as o}from"./EmptyScreen.js";function i(){const{appCode:s}=r(),{theme:e}=r(),{t}=a();return n.jsx(o,{imageSrc:`${e==null?void 0:e.bootstrapPath}/images/emptyscreen/illu-trash.svg`,imageAlt:t("explorer.emptyScreen.trash.alt"),title:t("explorer.emptyScreen.trash.title"),text:t("explorer.emptyScreen.trash.empty",{ns:s})})}export{i as default};
@@ -1 +1 @@
1
- import{d as h,a7 as j,G as f,a8 as y,H as C,a9 as I,aa as T,j as i,a0 as a}from"./index.js";import{C as A}from"./Card.js";import"/assets/js/edifice-ts-client/index.js";import"./Tooltip.js";import"./usePopper.js";const G=()=>{var c,d;const{currentApp:p}=h(),{data:e,isFetching:u}=j(),l=f(),o=y(),{setSelectedFolders:n,setFolderIds:r,openFolder:m}=C();function g(s){o.includes(s.id)?(r(o.filter(t=>t!==s.id)),n(l.filter(t=>t.id!==s.id))):(r([...o,s.id]),n([...l,s]))}const F=I({from:{opacity:0},to:{opacity:1}}),S=T();return(c=e==null?void 0:e.pages[0])!=null&&c.folders.length?i.jsx(a.ul,{className:"grid ps-0 list-unstyled mb-24",children:(d=e==null?void 0:e.pages[0])==null?void 0:d.folders.map(s=>{const{id:t,name:x}=s;return i.jsx(a.li,{className:"g-col-4",style:{...F},children:i.jsx(A,{app:p,name:x,isFolder:!0,isLoading:u,isSelected:o.includes(s.id),onOpen:()=>{S(),m({folder:s,folderId:s.id})},onSelect:()=>g(s)})},t)})}):null};export{G as default};
1
+ import{u as h,a9 as j,G as f,aa as y,c as C,ab as I,ac as T,j as i,$ as a}from"./index.js";import{C as b}from"./Card.js";import"./Tooltip.js";import"./usePopper.js";const $=()=>{var r,d;const{currentApp:p}=h(),{data:e,isFetching:u}=j(),l=f(),o=y(),{setSelectedFolders:n,setFolderIds:c,openFolder:m}=C();function g(s){o.includes(s.id)?(c(o.filter(t=>t!==s.id)),n(l.filter(t=>t.id!==s.id))):(c([...o,s.id]),n([...l,s]))}const F=I({from:{opacity:0},to:{opacity:1}}),S=T();return(r=e==null?void 0:e.pages[0])!=null&&r.folders.length?i.jsx(a.ul,{className:"grid ps-0 list-unstyled mb-24",children:(d=e==null?void 0:e.pages[0])==null?void 0:d.folders.map(s=>{const{id:t,name:x}=s;return i.jsx(a.li,{className:"g-col-4",style:{...F},children:i.jsx(b,{app:p,name:x,isFolder:!0,isLoading:u,isSelected:o.includes(s.id),onOpen:()=>{S(),m({folder:s,folderId:s.id})},onSelect:()=>g(s)})},t)})}):null};export{$ as default};
@@ -1 +1 @@
1
- import{r as g,a2 as A,g as C,j as a,F as f,s as j,a4 as L,a5 as N,x as T,p as z,a6 as E}from"./index.js";const $=g.forwardRef(({noValidationIcon:r,placeholder:m,size:o="md",height:i="md",className:c,...p},e)=>{const{id:l,isRequired:d,isReadOnly:s,status:n}=A(),u=C({"form-control":!s,"form-control-lg":o==="lg","form-control-sm":o==="sm","textarea-height-lg":i==="lg","textarea-height-md":i==="md","textarea-height-sm":i==="sm","is-invalid":n==="invalid","is-valid":n==="valid","form-control-plaintext":s,"no-validation-icon":r},c);return a.jsx("textarea",{ref:e,id:l,className:u,placeholder:m,required:d,readOnly:s,...p})});$.displayName="TextArea";const q=$,F=(r,m)=>{const[,o]=g.useState(!1),i=g.useCallback(e=>{e.preventDefault(),e.stopPropagation(),o(!0)},[]),c=e=>{e.preventDefault(),e.stopPropagation(),o(!1)};return{handleDragging:i,handleDragLeave:c,handleDrop:e=>{var d;c(e);const l=(d=e.dataTransfer)==null?void 0:d.files;m(l),r!=null&&r.current&&l&&(r.current.files=l)}}},O=F,y=g.forwardRef(({label:r,addButtonLabel:m="Add image",deleteButtonLabel:o="Delete image",src:i,className:c,app:p,onUploadImage:e,onDeleteImage:l},d)=>{const s=g.useRef(null),[n,u]=g.useState({name:"",image:i||""}),x=t=>{u({...n,name:"",image:""});const h=t==null?void 0:t[0];if(!h)return;const D={...n,name:h.name,image:URL.createObjectURL(h)};u(D),e(D)},R=()=>{var t;(t=s.current)==null||t.click()},b=()=>{s.current&&(s.current.value="");const t={...n,name:"",image:""};u(t),l()},k=t=>{x(t.target.files)},w=C("image-input",c),{handleDragging:v,handleDragLeave:I,handleDrop:P}=O(s,x);return a.jsxs(f,{id:"image-input",className:w,onDragEnter:v,onDragOver:v,onDragLeave:I,onDrop:P,ref:d,children:[a.jsxs("div",{className:"image-input-actions gap-8",children:[a.jsx(j,{"aria-label":m,color:"tertiary",icon:a.jsx(L,{}),onClick:R,type:"button",variant:"ghost"}),a.jsx(j,{"aria-label":o,color:"danger",disabled:!n.image,icon:a.jsx(N,{width:"20",height:"20"}),onClick:b,type:"button",variant:"ghost"})]}),a.jsxs(f.Label,{children:[a.jsx("span",{className:"visually-hidden",children:r}),a.jsx(T,{accept:"image/*",hidden:!0,onChange:k,ref:s,size:"sm",type:"file"}),n.image?a.jsx(z,{alt:n.name,src:n.image,size:"xl"}):a.jsx(E,{app:p,iconFit:"ratio",size:"160",variant:"rounded"})]})]})});y.displayName="ImagePicker";const U=y;export{U as I,q as T};
1
+ import{r as o,f as y,j as e,F as v,t as j,a6 as L,a7 as R,y as z,q as E,a8 as N}from"./index.js";const S=(r,d)=>{const[,l]=o.useState(!1),m=o.useCallback(a=>{a.preventDefault(),a.stopPropagation(),l(!0)},[]),c=a=>{a.preventDefault(),a.stopPropagation(),l(!1)};return{handleDragging:m,handleDragLeave:c,handleDrop:a=>{var g;c(a);const s=(g=a.dataTransfer)==null?void 0:g.files;d(s),r!=null&&r.current&&s&&(r.current.files=s)}}},A=S,C=o.forwardRef(({label:r,addButtonLabel:d="Add image",deleteButtonLabel:l="Delete image",src:m,className:c,app:a,onUploadImage:s,onDeleteImage:g},$)=>{const i=o.useRef(null),[t,p]=o.useState({name:"",image:m||""}),h=n=>{p({...t,name:"",image:""});const u=n==null?void 0:n[0];if(!u)return;const D={...t,name:u.name,image:URL.createObjectURL(u)};p(D),s(D)},b=()=>{var n;(n=i.current)==null||n.click()},f=()=>{i.current&&(i.current.value="");const n={...t,name:"",image:""};p(n),g()},k=n=>{h(n.target.files)},I=y("image-input",c),{handleDragging:x,handleDragLeave:P,handleDrop:w}=A(i,h);return e.jsxs(v,{id:"image-input",className:I,onDragEnter:x,onDragOver:x,onDragLeave:P,onDrop:w,ref:$,children:[e.jsxs("div",{className:"image-input-actions gap-8",children:[e.jsx(j,{"aria-label":d,color:"tertiary",icon:e.jsx(L,{}),onClick:b,type:"button",variant:"ghost"}),e.jsx(j,{"aria-label":l,color:"danger",disabled:!t.image,icon:e.jsx(R,{width:"20",height:"20"}),onClick:f,type:"button",variant:"ghost"})]}),e.jsxs(v.Label,{children:[e.jsx("span",{className:"visually-hidden",children:r}),e.jsx(z,{accept:"image/*",hidden:!0,onChange:k,ref:i,size:"sm",type:"file"}),t.image?e.jsx(E,{alt:t.name,src:t.image,size:"xl"}):e.jsx(N,{app:a,iconFit:"ratio",size:"160",variant:"rounded"})]})]})});C.displayName="ImagePicker";const O=C;export{O as I};
package/dist/Library.js CHANGED
@@ -1 +1 @@
1
- import{r as n,j as r,I as c,B as x,e as m,u as p,f as d,b as h}from"./index.js";import"/assets/js/edifice-ts-client/index.js";const i=n.forwardRef(({text:e,textButton:a,src:s,alt:t,url:o},l)=>r.jsx(r.Fragment,{children:r.jsxs("div",{ref:l,className:"p-16",children:[r.jsx(c,{width:"270",height:"140",loading:"lazy",className:"rounded",src:s,alt:t}),r.jsx("p",{className:"m-8",children:e}),r.jsx("a",{href:o,target:"_blank",rel:"noreferrer",children:r.jsx(x,{rightIcon:r.jsx(m,{}),className:"py-0 px-8",variant:"ghost",color:"primary",children:a})})]})}));i.displayName="Library";const g=i,u=({url:e})=>{const{t:a}=p(),{theme:s}=d(),[t]=h();return r.jsx(g,{src:`${t}/${s==null?void 0:s.bootstrapVersion}/image-library.svg`,url:e,alt:a("explorer.libray.img.alt"),text:a("explorer.libray.title"),textButton:a("explorer.libray.btn")})};export{u as default};
1
+ import{r as n,j as r,I as c,B as x,d as m,a as d,e as p}from"./index.js";const t=n.forwardRef(({text:e,textButton:a,src:s,alt:i,url:l},o)=>r.jsx(r.Fragment,{children:r.jsxs("div",{ref:o,className:"p-16",children:[r.jsx(c,{width:"270",height:"140",loading:"lazy",className:"rounded",src:s,alt:i}),r.jsx("p",{className:"m-8",children:e}),r.jsx("a",{href:l,target:"_blank",rel:"noreferrer",children:r.jsx(x,{rightIcon:r.jsx(m,{}),className:"py-0 px-8",variant:"ghost",color:"primary",children:a})})]})}));t.displayName="Library";const g=t,y=({url:e})=>{const{t:a}=d(),{theme:s}=p();return r.jsx(g,{src:`${s==null?void 0:s.bootstrapPath}/images/image-library.svg`,url:e,alt:a("explorer.libray.img.alt"),text:a("explorer.libray.title"),textButton:a("explorer.libray.btn")})};export{y as default};
package/dist/MoveModal.js CHANGED
@@ -1 +1 @@
1
- import{r as I,E as v,G as T,k as M,H as y,J as j,u as b,K as F,a as S,j as o,M as n,T as w,B as h}from"./index.js";import"/assets/js/edifice-ts-client/index.js";function E({onSuccess:a}){const[s,r]=I.useState(),l=v(),d=T(),i=M(),{foldTreeItem:c,unfoldTreeItem:m}=y(),u=j();async function f(){try{if(!s)throw new Error("explorer.move.selection.empty");await l.mutate(s),await(a==null?void 0:a())}catch(e){console.error(e)}}const p=e=>{var x;for(const t of d)if(e===t.id||e===t.parentId)return!1;for(const t of i)if(e===((t==null?void 0:t.folderIds)&&t.folderIds[0])||((x=t==null?void 0:t.folderIds)==null?void 0:x.length)===0&&e==="default")return!1;return!0};return{disableSubmit:!s,handleTreeItemSelect:e=>{p(e)?r(e):r(void 0)},handleTreeItemFold:c,handleTreeItemUnfold:async e=>await m(e,u),onMove:()=>{f()}}}function k({isOpen:a,onSuccess:s,onCancel:r}){const{t:l}=b(),{handleTreeItemFold:d,handleTreeItemSelect:i,handleTreeItemUnfold:c,onMove:m,disableSubmit:u}=E({onSuccess:s}),f=F();return S.createPortal(o.jsxs(n,{isOpen:a,onModalClose:r,id:"moveModal",children:[o.jsx(n.Header,{onModalClose:r,children:l("explorer.move.title")}),o.jsx(n.Subtitle,{children:l("explorer.move.subtitle")}),o.jsx(n.Body,{children:o.jsx(w,{data:f,onTreeItemSelect:i,onTreeItemFold:d,onTreeItemUnfold:c})}),o.jsxs(n.Footer,{children:[o.jsx(h,{color:"tertiary",onClick:r,type:"button",variant:"ghost",children:l("explorer.cancel")}),o.jsx(h,{color:"primary",onClick:m,type:"button",variant:"filled",disabled:u,children:l("explorer.move")})]})]}),document.getElementById("portal"))}export{k as default};
1
+ import{r as p,E as v,G as T,i as M,c as y,J as b,a as j,K as F,b as S,j as o,M as n,T as w,B as h}from"./index.js";function E({onSuccess:a}){const[s,r]=p.useState(),l=v(),d=T(),c=M(),{foldTreeItem:i,unfoldTreeItem:m}=y(),u=b();async function f(){try{if(!s)throw new Error("explorer.move.selection.empty");await l.mutate(s),await(a==null?void 0:a())}catch(e){console.error(e)}}const I=e=>{var x;for(const t of d)if(e===t.id||e===t.parentId)return!1;for(const t of c)if(e===((t==null?void 0:t.folderIds)&&t.folderIds[0])||((x=t==null?void 0:t.folderIds)==null?void 0:x.length)===0&&e==="default")return!1;return!0};return{disableSubmit:!s,handleTreeItemSelect:e=>{I(e)?r(e):r(void 0)},handleTreeItemFold:i,handleTreeItemUnfold:async e=>await m(e,u),onMove:()=>{f()}}}function g({isOpen:a,onSuccess:s,onCancel:r}){const{t:l}=j(),{handleTreeItemFold:d,handleTreeItemSelect:c,handleTreeItemUnfold:i,onMove:m,disableSubmit:u}=E({onSuccess:s}),f=F();return S.createPortal(o.jsxs(n,{isOpen:a,onModalClose:r,id:"moveModal",children:[o.jsx(n.Header,{onModalClose:r,children:l("explorer.move.title")}),o.jsx(n.Subtitle,{children:l("explorer.move.subtitle")}),o.jsx(n.Body,{children:o.jsx(w,{data:f,onTreeItemSelect:c,onTreeItemFold:d,onTreeItemUnfold:i})}),o.jsxs(n.Footer,{children:[o.jsx(h,{color:"tertiary",onClick:r,type:"button",variant:"ghost",children:l("explorer.cancel")}),o.jsx(h,{color:"primary",onClick:m,type:"button",variant:"filled",disabled:u,children:l("explorer.move")})]})]}),document.getElementById("portal"))}export{g as default};