ode-explorer 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/AppAction.js CHANGED
@@ -1 +1 @@
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};
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","TextArea.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};
package/dist/Card.js CHANGED
@@ -1 +1 @@
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
+ import{r as l,j as e,ag as P,g as c,I,a8 as S,ah as T,ai as k,q as z,aj as A,t as E,ak as B,al as U}from"./index.js";import{T as w}from"./Tooltip.js";const $=l.createContext(null);$.displayName="CardContext";const y=()=>{const s=l.useContext($);if(!s)throw new Error("Cannot be rendered outside the Card component");return s},R=l.forwardRef(()=>{const{options:{name:s},isLoading:a,appCode:t,classesTitle:r}=y();return e.jsxs("div",{className:"card-body",children:[e.jsx(P,{width:"48",height:"48",className:c(`color-app-${t}`,{placeholder:a})}),e.jsx("div",{children:e.jsx("h3",{className:r,children:e.jsx("strong",{children:s})})})]})});R.displayName="Card.Folder";const q=R,F=l.forwardRef(()=>{const{options:s,isLoading:a,tooltips:t,classesTitle:r,app:o}=y(),{type:u,imageSrc:n,name:j,creatorName:d,userSrc:i,updatedAt:g,isShared:v,isPublic:N}=s,{messagePublic:C,messageShared:h}=t||{},x=c("d-inline-flex align-items-center gap-8 text-truncate",{placeholder:a}),f=c("card-text small",{placeholder:a}),m=c("small text-truncate",{placeholder:a}),b=i?e.jsx(z,{alt:d||"",size:"xs",src:i,variant:"circle",width:"24",height:"24"}):e.jsx(A,{});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"card-body",children:[n?e.jsx("div",{className:"card-image",children:e.jsx(I,{alt:"",src:n,width:"80",height:"80",objectFit:"cover",className:c("h-full",{placeholder:a})})}):e.jsx(S,{app:o,iconFit:"ratio",size:"80",variant:"rounded"}),e.jsxs("div",{children:[e.jsx("h3",{className:r,children:e.jsx("strong",{children:j})}),e.jsx("p",{className:"card-text small",children:e.jsx("em",{className:f,children:g})})]})]}),u==="resource"?e.jsxs("div",{className:"card-footer gap-16",children:[e.jsxs("div",{className:x,children:[b,e.jsx("p",{className:m,children:d})]}),e.jsxs("div",{className:"d-inline-flex align-items-center gap-8",children:[N&&e.jsx(w,{message:C,placement:"top",children:e.jsx(T,{width:16,height:16})}),v&&e.jsx(w,{message:h,placement:"top",children:e.jsx(k,{width:16,height:16})})]})]}):null]})});F.displayName="Card.Resource";const G=F,O=l.forwardRef(({options:s,tooltips:a,isLoading:t,app:r,onSelect:o,onOpen:u,isSelected:n,isAnimated:j,className:d,...i},g)=>{const{getIconCode:v}=U();function N(b){b.stopPropagation(),o==null||o()}const{type:C}=s,h=r?v(r):"placeholder",x=c("card-title body text-break text-truncate text-truncate-2 pe-32",{placeholder:t}),f=l.useMemo(()=>({options:s,isLoading:t,classesTitle:x,app:r,appCode:h,tooltips:a}),[r,h,x,t,s,a]),m={folder:e.jsx(p.Folder,{}),resource:e.jsx(p.Resource,{}),undefined:e.jsx(p.Resource,{}),default:null};return e.jsx($.Provider,{value:f,children:e.jsxs("div",{ref:g,className:c("card",{"placeholder-glow":t,"is-selected":n,"is-animated":j},d),...i,children:[e.jsxs("div",{className:"card-header",children:[!t&&e.jsx(E,{"aria-label":"Open Action Bar",className:"z-3",color:"secondary",icon:e.jsx(B,{}),onClick:N,variant:"ghost"}),e.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"})]}),m[C]||m.default]})})});O.displayName="Card";const p=Object.assign(O,{Resource:G,Folder:q}),H=p;export{H as C};
@@ -1 +1 @@
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
+ import{u as d,D as u,E as x,G as p,o 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 +1 @@
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
+ import{J as D,P as B,Q as q,U as L,r as C,u as R,a as U,j as r,M as s,F as w,W as P,y as T,B as b}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 y;try{if(a){const d=(y=l[0])==null?void 0:y.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 W({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]),U.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(w,{id:"nameFolder",isRequired:!0,children:[r.jsx(P,{children:t("explorer.create.folder.name")}),r.jsx(T,{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(b,{color:"tertiary",onClick:n,type:"button",variant:"ghost",children:t("explorer.cancel")}),r.jsx(b,{form:o,type:"submit",color:"primary",variant:"filled",disabled:!m||!c||u,children:t(e?"explorer.rename":"explorer.create")})]})]}),document.getElementById("portal"))}export{W as default};
@@ -1 +1 @@
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
+ import{u as B,j as e,A as V,F as g,y as H,X as ne,B as A,Y as ce,d as U,m as de,Z as ue,l as G,h as pe,r as x,P as me,o as he,N as xe,$ as ge,a as be,M as C,W as O,a0 as fe}from"./index.js";import{APP as Q}from"/assets/js/edifice-ts-client/index.js";import{H as K}from"./Heading.js";import{u as je}from"./index.esm.js";import{I as ve,T as ye}from"./TextArea.js";const Se=({appCode:r,correctSlug:l,disableSlug:o,onPublicChange:c,onSlugChange:m,refPublic:d,refSlug:v,register:t,resource:u,slug:h,onCopyToClipBoard:b})=>{const{t:i}=B();return e.jsxs(e.Fragment,{children:[e.jsxs(K,{headingStyle:"h4",level:"h3",className:"mb-16",children:[i("explorer.resource.editModal.heading.access"),r]}),e.jsx(V,{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:u&&u.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:l?"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(H,{type:"text",...t("safeSlug",{validate:{required:n=>!n&&!o?i("explorer.slug.name.mandatory"):!0},disabled:o,value:h,onChange:n=>m(n.target.value)}),size:"md",placeholder:i("explorer.resource.editModal.access.url.extension")},v),l&&e.jsx("div",{className:"position-absolute",children:e.jsx(ne,{children:i("explorer.slug.name.error")})})]}),e.jsx(A,{color:"primary",disabled:o,onClick:()=>{b()},type:"button",leftIcon:e.jsx(ce,{}),variant:"ghost",className:"text-nowrap",children:i("explorer.resource.editModal.access.url.button")})]})})]})};function Ce({resource:r,edit:l,onSuccess:o,onCancel:c}){var _;const{appCode:m}=U(),{t:d}=B(),v=de(),t=ue(),u=G(),h=pe(),{reset:b,register:i,handleSubmit:n,setFocus:w,formState:{errors:I,isSubmitting:f,isValid:$}}=je({mode:"onChange"}),M=x.useId(),p=me(),[P,N]=x.useState(new Date().getTime()),[k,R]=x.useState(!(r!=null&&r.public)),[y,a]=x.useState((r==null?void 0:r.slug)||""),[W,E]=x.useState(!1),{hotToast:F}=he(V),[L,q]=x.useState({name:"",image:(_=u[0])==null?void 0:_.thumbnail}),X=s=>{q(s)},Y=()=>{q({name:"",image:""})};function Z(s){R(!s),s||(a(""),N(new Date().getTime()))}function D(s){if(!s)return"";const j="àáäâãåăæçèéëêǵḧìíïîḿńǹñòóöôœøṕŕßśșțùúüûǘẃẍÿź·/_,:;",S="aaaaaaaaceeeeghiiiimnnnooooooprssstuuuuuwxyz------",T=new RegExp(j.split("").join("|"),"g"),re=s.toString().toLowerCase().replace(/\s+/g,"-").replace(T,oe=>S.charAt(j.indexOf(oe))).replace(/&/g,"-and-").replace(/[^\w\\-]+/g,"").replace(/\\-\\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");a(re)}const J=xe(),{filters:z,trashed:ee}=h,se=["context",{folderId:z.folder,filters:z,trashed:ee}],te=async function(s){var j,S;try{l?(await v.mutateAsync({description:s.description||"",entId:(j=u[0])==null?void 0:j.assetId,name:s.title,public:s.enablePublic,slug:s.safeSlug,trashed:(S=u[0])==null?void 0:S.trashed,thumbnail:L.image}),E(!1)):(J.invalidateQueries(se),t.mutateAsync({name:s.title,description:s.description||"",thumbnail:L.image,folder:(p==null?void 0:p.id)==="default"?void 0:parseInt((p==null?void 0:p.id)||""),public:s.enablePublic,slug:s.safeSlug,app:m})),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]}),l&&m===Q.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 ae(){navigator.clipboard.writeText(`${window.location.origin}${window.location.pathname}/pub/${y}`),F.success(d("explorer.copy.clipboard"))}function le(){b(),c()}const ie=`resource_edit_modal_${M}`;return{slug:y,disableSlug:k,formId:ie,errors:I,isSubmitting:f,isValid:$,versionSlug:P,correctSlug:W,onPublicChange:Z,onSlugChange:D,register:i,setFocus:w,handleSubmit:n,onFormCancel:le,onSubmit:te,handleUploadImage:X,handleDeleteImage:Y,onCopyToClipBoard:ae}}function Ne({isOpen:r,edit:l,onSuccess:o,onCancel:c}){const{appCode:m,currentApp:d}=U(),t=G()[0],{slug:u,formId:h,isValid:b,isSubmitting:i,disableSlug:n,versionSlug:w,correctSlug:I,register:f,handleSubmit:$,onSubmit:M,handleUploadImage:p,handleDeleteImage:P,onCopyToClipBoard:N,onSlugChange:k,onPublicChange:R}=Ce({resource:t,edit:l,onSuccess:o,onCancel:c}),{data:y}=ge(),{t:a}=B();return be.createPortal(e.jsxs(C,{id:"resource_edit_modal",size:"lg",isOpen:r,onModalClose:c,children:[e.jsx(C.Header,{onModalClose:c,children:a(l?"explorer.resource.editModal.header.edit":"explorer.resource.editModal.header.create")}),e.jsxs(C.Body,{children:[e.jsx(K,{headingStyle:"h4",level:"h3",className:"mb-16",children:a("explorer.resource.editModal.heading.general")}),e.jsxs("form",{id:h,onSubmit:$(M),children:[e.jsxs("div",{className:"d-flex gap-16 mb-24",children:[e.jsx("div",{children:e.jsx(ve,{app:d,src:t==null?void 0:t.thumbnail,label:a("explorer.imagepicker.label"),addButtonLabel:a("explorer.imagepicker.button.add"),deleteButtonLabel:a("explorer.imagepicker.button.delete"),onUploadImage:p,onDeleteImage:P,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:a("title")}),e.jsx(H,{type:"text",defaultValue:l?t==null?void 0:t.name:"",...f("title",{required:!0,pattern:{value:/[^ ]/,message:"invalid title"}}),placeholder:a("explorer.resource.editModal.title.placeholder"),size:"md","aria-required":!0})]}),e.jsxs(g,{id:"description",isOptional:!0,children:[e.jsx(O,{children:a("description")}),e.jsx(ye,{defaultValue:l?t==null?void 0:t.description:"",...f("description"),placeholder:a("explorer.resource.editModal.description.placeholder"),size:"md"})]})]})]}),m===Q.BLOG&&fe({workflow:"createPublic",actions:y})&&e.jsx(Se,{appCode:m,correctSlug:I,disableSlug:n,onCopyToClipBoard:N,onPublicChange:R,onSlugChange:k,resource:t,slug:u,versionSlug:w,register:f})]})]}),e.jsxs(C.Footer,{children:[e.jsx(A,{color:"tertiary",onClick:c,type:"button",variant:"ghost",children:a("explorer.cancel")}),e.jsx(A,{form:h,type:"submit",color:"primary",variant:"filled",disabled:!b||i,children:a(l?"save":"explorer.create")})]})]}),document.getElementById("portal"))}export{Ne as default};
@@ -1 +1 @@
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
+ 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 +1 @@
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
+ import{d as i,f as a,u as c,$ 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};
@@ -0,0 +1 @@
1
+ import{u as t,j as o,b as s}from"./index.js";import{E as m}from"./EmptyScreen.js";import"/assets/js/edifice-ts-client/index.js";import"./Heading.js";function c(){const[r]=s(),{t:e}=t();return o.jsx(m,{imageSrc:`${r}/emptyscreen/illu-error.svg`,imageAlt:e("explorer.emptyScreen.error.alt"),text:"explorer.emptyScreen.error.text"})}export{c as default};
@@ -1 +1 @@
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
+ import{d as r,u as o,j as s,b as a}from"./index.js";import{E as m}from"./EmptyScreen.js";import"/assets/js/edifice-ts-client/index.js";import"./Heading.js";function u(){const[n]=a(),{appCode:e}=r(),{t}=o();return s.jsx(m,{imageSrc:`${n}/emptyscreen/illu-no-content-in-folder.svg`,imageAlt:t("explorer.emptyScreen.folder.empty.alt",{ns:e}),text:t("explorer.emptyScreen.label",{ns:e})})}export{u as default};
@@ -0,0 +1 @@
1
+ import{d as s,u as a,j as n,b as o}from"./index.js";import{E as m}from"./EmptyScreen.js";import"/assets/js/edifice-ts-client/index.js";import"./Heading.js";function u(){const{appCode:e}=s(),[r]=o(),{t}=a();return n.jsx(m,{imageSrc:`${r}/emptyscreen/illu-search.svg`,imageAlt:t("explorer.emptyScreen.search.alt",{ns:e}),text:t("explorer.emptyScreen.search.text",{ns:e})})}export{u as default};
@@ -1 +1 @@
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
+ 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 +1 @@
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:c,setFolderIds:n,openFolder:m}=C();function g(s){o.includes(s.id)?(n(o.filter(t=>t!==s.id)),c(l.filter(t=>t.id!==s.id))):(n([...o,s.id]),c([...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
+ import{d as f,J as j,a9 as y,K as I,aa as T,ab as h,j as t,ac as d}from"./index.js";import{C}from"./Card.js";import"/assets/js/edifice-ts-client/index.js";import"./Tooltip.js";const O=({data:e,isFetching:u})=>{var c,p;const{currentApp:a}=f(),l=j(),i=y(),{setSelectedFolders:n,setFolderIds:r,openFolder:m}=I();function g(s){i.includes(s.id)?(r(i.filter(o=>o!==s.id)),n(l.filter(o=>o.id!==s.id))):(r([...i,s.id]),n([...l,s]))}const S=T({from:{opacity:0},to:{opacity:1}}),F=h();return(c=e==null?void 0:e.pages[0])!=null&&c.folders.length?t.jsx(d.ul,{className:"grid ps-0 list-unstyled mb-24",children:(p=e==null?void 0:e.pages[0])==null?void 0:p.folders.map(s=>{const{id:o,name:x}=s;return t.jsx(d.li,{className:"g-col-4 z-1",style:{position:"relative",...S},children:t.jsx(C,{app:a,options:{type:"folder",name:x},isLoading:u,isSelected:i.includes(s.id),onOpen:()=>{F(),m({folder:s,folderId:s.id})},onSelect:()=>g(s)})},o)})}):null};export{O as default};
@@ -0,0 +1 @@
1
+ import{r as i,g as l,j as x}from"./index.js";const s=i.forwardRef(({level:a="h1",headingStyle:e="h1",children:r,className:t,...o},n)=>{const c=l(e,t);return x.jsx(a,{ref:n,className:c,...o,children:r})});s.displayName="Heading";const m=s;export{m as H};
package/dist/Library.js CHANGED
@@ -1 +1 @@
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};
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};
package/dist/MoveModal.js CHANGED
@@ -1 +1 @@
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};
1
+ import{r as I,H as v,J as T,l as M,K as y,N as j,u as b,O 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 C({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{C as default};