ode-explorer 1.0.0-dev.202306091239 → 1.0.0-dev.202306141028

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/Card.js CHANGED
@@ -1 +1 @@
1
- import{r as E,f as a,c as s,w as F,ad as U,ae as G,af as q,ag as D,ah as H,I as J,a7 as K,s as M,ai as Q}from"./index.js";import{T as n}from"./Tooltip.js";const d=E.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}=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-16",{placeholder:e}),I=a("card-text small",{placeholder:e}),O=a("small text-truncate",{placeholder:e}),T=a("d-inline-flex align-items-center gap-8 text-truncate",{placeholder:e}),z=l?w(l):"placeholder",P=a(`color-app-${z}`,{placeholder:e});function k(B){B.stopPropagation(),c==null||c()}const A=t?s.jsx(H,{width:"48",height:"48",className:P}):i?s.jsx("div",{className:"card-image",children:s.jsx(J,{alt:"",src:i,width:"80",height:"80",objectFit:"cover",className:"h-full"})}):s.jsx(K,{app:l,iconFit:"ratio",size:"80",variant:"rounded"}),R=o?s.jsx(M,{alt:r,size:"xs",src:o,variant:"circle",width:"24",height:"24"}):s.jsx(Q,{});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:k,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:[A,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:T,children:[R,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(G,{width:16,height:16})}),p&&s.jsx(n,{message:f,placement:"top",children:s.jsx(q,{width:16,height:16})})]})]})]})});d.displayName="Card";const W=d;export{W as C};
1
+ import{r as E,e as a,c as e,v as F,ac as U,ad as G,ae as q,af as D,ag as H,I as J,a6 as K,s as M,ah as Q}from"./index.js";import{T as n}from"./Tooltip.js";const d=E.forwardRef(({app:l,className:h,creatorName:r="tom.mate",isAnimated:x=!1,isFolder:t=!1,isLoading:s=!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}=D(),C=a("card",{"placeholder-glow":s,"is-selected":m,"is-animated":x},h),y=a("card-title body text-break text-truncate text-truncate--2 pe-16",{placeholder:s}),I=a("card-text small",{placeholder:s}),O=a("small text-truncate",{placeholder:s}),T=a("d-inline-flex align-items-center gap-8 text-truncate",{placeholder:s}),z=l?w(l):"placeholder",P=a(`color-app-${z}`,{placeholder:s});function k(B){B.stopPropagation(),c==null||c()}const A=t?e.jsx(H,{width:"48",height:"48",className:P}):i?e.jsx("div",{className:"card-image",children:e.jsx(J,{alt:"",src:i,width:"80",height:"80",objectFit:"cover",className:"h-full"})}):e.jsx(K,{app:l,iconFit:"ratio",size:"80",variant:"rounded"}),R=o?e.jsx(M,{alt:r,size:"xs",src:o,variant:"circle",width:"24",height:"24"}):e.jsx(Q,{});return e.jsxs("div",{ref:b,className:C,...$,children:[!s&&e.jsx(F,{"aria-label":"Open Action Bar",className:"z-3",color:"secondary",icon:e.jsx(U,{}),onClick:k,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"}),e.jsxs("div",{className:"card-body",children:[A,e.jsxs("div",{children:[e.jsx("h3",{className:y,children:e.jsx("strong",{children:g})}),t?null:e.jsx("p",{className:"card-text small",children:e.jsx("em",{className:I,children:v})})]})]}),t?null:e.jsxs("div",{className:"card-footer gap-16",children:[e.jsxs("div",{className:T,children:[R,e.jsx("p",{className:O,children:r})]}),e.jsxs("div",{className:"d-inline-flex align-items-center gap-8",children:[j&&e.jsx(n,{message:N,placement:"top",children:e.jsx(G,{width:16,height:16})}),p&&e.jsx(n,{message:f,placement:"top",children:e.jsx(q,{width:16,height:16})})]})]})]})});d.displayName="Card";const W=d;export{W as C};
@@ -1 +1 @@
1
- import{h,D as u,E as x,G as p,p as m,A as j,u as y,a as f,j as e,M as n,B as i}from"./index.js";function D({onSuccess:s}){const{i18n:l}=h(),o=u(),t=x(),r=p(),{hotToast:a}=m(j);async function d(){try{r?(await o.mutate(),a.success(l("explorer.removed.from.trash"))):(await t.mutate(),a.success(l("explorer.trash.title"))),s==null||s()}catch(c){console.error(c)}}return{isTrashFolder:r,onDelete:d}}function T({isOpen:s,onSuccess:l=()=>({}),onCancel:o=()=>({})}){const{i18n:t}=y(),{isTrashFolder:r,onDelete:a}=D({onSuccess:l});return f.createPortal(e.jsxs(n,{isOpen:s,onModalClose:o,id:"deleteModal",children:[e.jsx(n.Header,{onModalClose:o,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:o,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{T as default};
1
+ import{f as u,C as h,D as x,E as p,n as m,q as f,u as j,a as y,j as e,M as n,B as i}from"./index.js";function D({onSuccess:s}){const{i18n:l}=u(),o=h(),t=x(),r=p(),{hotToast:a}=m(f);async function d(){try{r?(await o.mutate(),a.success(l("explorer.removed.from.trash"))):(await t.mutate(),a.success(l("explorer.trash.title"))),s==null||s()}catch(c){console.error(c)}}return{isTrashFolder:r,onDelete:d}}function T({isOpen:s,onSuccess:l=()=>({}),onCancel:o=()=>({})}){const{i18n:t}=j(),{isTrashFolder:r,onDelete:a}=D({onSuccess:l});return y.createPortal(e.jsxs(n,{isOpen:s,onModalClose:o,id:"deleteModal",children:[e.jsx(n.Header,{onModalClose:o,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:o,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{T as default};
@@ -1 +1 @@
1
- import{K as B,P as D,Q as q,U,r as C,W as w,h as L,a as P,j as r,M as s,F as R,X as V,C as _,B as y}from"./index.js";import{u as k}from"./index.esm.js";function z({edit:a,onSuccess:e,onClose:i}){var F;const n=B(),t=D(),m=q(),c=U(),u=a?(F=n[0])==null?void 0:F.name:void 0,{reset:o,register:f,handleSubmit:d,setFocus:p,formState:{errors:x,isSubmitting:h,isDirty:I,isValid:E}}=k({mode:"onChange",values:{name:u||""}}),g=C.useId(),M=async function({name:j}){var b;try{if(a){const l=(b=n[0])==null?void 0:b.parentId,v=n[0].id;await c.mutate({folderId:v,parentId:l,name:j}),o(),e==null||e()}else{const l=(t==null?void 0:t.id)||w.DEFAULT;await m.mutate({name:j,parentId:l}),o(),e==null||e()}}catch(l){console.error(l)}};function $(){o(),i()}return{formId:`createModal_${g}`,errors:x,isSubmitting:h,isDirty:I,isValid:E,register:f,setFocus:p,handleSubmit:d,onCancel:$,onSubmit:M}}function T({isOpen:a,edit:e,onSuccess:i,onCancel:n}){const{i18n:t}=L(),{isDirty:m,isValid:c,isSubmitting:u,formId:o,onSubmit:f,onCancel:d,handleSubmit:p,register:x,setFocus:h}=z({edit:e,onSuccess:i,onClose:n});return C.useEffect(()=>{a&&h("name")},[a]),P.createPortal(r.jsxs(s,{isOpen:a,onModalClose:d,id:"modal_"+o,children:[r.jsx(s.Header,{onModalClose:d,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(R,{id:"nameFolder",isRequired:!0,children:[r.jsx(V,{children:t("explorer.create.folder.name")}),r.jsx(_,{type:"text",...x("name",{required:!0}),placeholder:t("explorer.create.folder.name"),size:"md","aria-required":!0})]})})}),r.jsxs(s.Footer,{children:[r.jsx(y,{color:"tertiary",onClick:d,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{T as default};
1
+ import{J as v,O as B,P as q,Q as L,r as I,U as R,f as U,a as w,j as r,M as s,F as z,W as P,z 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 n=v(),t=B(),m=q(),c=L(),u=a?(F=n[0])==null?void 0:F.name:void 0,{reset:o,register:f,handleSubmit:d,setFocus:p,formState:{errors:x,isSubmitting:h,isDirty:C,isValid:E}}=_({mode:"onChange",values:{name:u||""}}),g=I.useId(),M=async function({name:j}){var b;try{if(a){const l=(b=n[0])==null?void 0:b.parentId,D=n[0].id;await c.mutate({folderId:D,parentId:l,name:j}),o(),e==null||e()}else{const l=(t==null?void 0:t.id)||R.DEFAULT;await m.mutate({name:j,parentId:l}),o(),e==null||e()}}catch(l){console.error(l)}};function $(){o(),i()}return{formId:`createModal_${g}`,errors:x,isSubmitting:h,isDirty:C,isValid:E,register:f,setFocus:p,handleSubmit:d,onCancel:$,onSubmit:M}}function T({isOpen:a,edit:e,onSuccess:i,onCancel:n}){const{i18n:t}=U(),{isDirty:m,isValid:c,isSubmitting:u,formId:o,onSubmit:f,onCancel:d,handleSubmit:p,register:x,setFocus:h}=k({edit:e,onSuccess:i,onClose:n});return I.useEffect(()=>{a&&h("name")},[a]),w.createPortal(r.jsxs(s,{isOpen:a,onModalClose:d,id:"modal_"+o,children:[r.jsx(s.Header,{onModalClose:d,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(z,{id:"nameFolder",isRequired:!0,children:[r.jsx(P,{children:t("explorer.create.folder.name")}),r.jsx(V,{type:"text",...x("name",{required:!0}),placeholder:t("explorer.create.folder.name"),size:"md","aria-required":!0})]})})}),r.jsxs(s.Footer,{children:[r.jsx(y,{color:"tertiary",onClick:d,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{T as default};
@@ -1 +1 @@
1
- import{h as G,n as J,m as z,r as c,p as K,j as e,A,u as Q,a as W,M as y,H as _,F as d,X as E,C as P,Y as ee,B,Z as se}from"./index.js";import{I as le}from"./ImagePicker.js";import{u as te}from"./index.esm.js";function re({resource:p,onSuccess:a,onCancel:v}){const{i18n:r}=G(),s=J(),u=z(),{reset:C,register:F,handleSubmit:t,setFocus:w,formState:{errors:m,isSubmitting:I,isValid:$}}=te({mode:"onChange"}),i=c.useId(),[M,x]=c.useState(new Date().getTime()),[n,N]=c.useState(!p.public),[g,h]=c.useState(p.slug||""),[k,b]=c.useState(!1),{hotToast:f}=K(A),[R,j]=c.useState({name:"",image:u[0].thumbnail}),T=l=>{j(l)},o=()=>{j({name:"",image:""})};function D(l){N(!l),l||(h(""),x(new Date().getTime()))}function L(l){if(!l)return"";const S="àáäâãåăæçèéëêǵḧìíïîḿńǹñòóöôœøṕŕßśșțùúüûǘẃẍÿź·/_,:;",O="aaaaaaaaceeeeghiiiimnnnooooooprssstuuuuuwxyz------",X=new RegExp(S.split("").join("|"),"g"),Y=l.toString().toLowerCase().replace(/\s+/g,"-").replace(X,Z=>O.charAt(S.indexOf(Z))).replace(/&/g,"-and-").replace(/[^\w\\-]+/g,"").replace(/\\-\\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");h(Y)}const V=async function(l){try{await s.mutateAsync({description:l.description,entId:u[0].assetId,name:l.title,public:l.enablePublic,slug:l.safeSlug,trashed:u[0].trashed,thumbnail:R.image}),b(!1),f.success(e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:r("explorer.resource.updated")}),e.jsxs("p",{children:["Titre: ",l.title]}),e.jsxs("p",{children:["Description: ",l.description]}),e.jsxs("p",{children:["Public:"," ",l.enablePublic?r("explorer.enable.public.yes"):r("explorer.enable.public.no")]})]})),a==null||a()}catch(S){b(!0),console.error(S)}};function q(){navigator.clipboard.writeText(`${window.location.origin}/${g}`),f.success(r("explorer.copy.clipboard"))}function H(){C(),v()}const U=`resource_edit_modal_${i}`;return{slug:g,disableSlug:n,formId:U,errors:m,isSubmitting:I,isValid:$,versionSlug:M,correctSlug:k,onPublicChange:D,onSlugChange:L,register:F,setFocus:w,handleSubmit:t,onFormCancel:H,onSubmit:V,handleUploadImage:T,handleDeleteImage:o,onCopyToClipBoard:q}}function ne({isOpen:p,edit:a,onSuccess:v,onCancel:r}){const{i18n:s,appCode:u,currentApp:C}=Q(),t=z()[0],{slug:w,formId:m,isValid:I,isSubmitting:$,disableSlug:i,versionSlug:M,correctSlug:x,register:n,handleSubmit:N,onSubmit:g,handleUploadImage:h,handleDeleteImage:k,onCopyToClipBoard:b,onSlugChange:f,onPublicChange:R}=re({resource:t,onSuccess:v,onCancel:r}),j=`${new Date().getTime()}_${i}`,T=`${M}_slug`;return W.createPortal(e.jsxs(y,{id:"resource_edit_modal",size:"lg",isOpen:p,onModalClose:r,children:[e.jsx(y.Header,{onModalClose:r,children:s(a?"explorer.resource.editModal.header.edit":"explorer.resource.editModal.header.create")}),e.jsxs(y.Body,{children:[e.jsx(_,{headingStyle:"h4",level:"h3",className:"mb-16",children:s("explorer.resource.editModal.heading.general")}),e.jsxs("form",{id:m,onSubmit:N(g),children:[e.jsxs("div",{className:"d-flex flex-column flex-md-row gap-16 mb-24",children:[e.jsx(le,{app:C,src:t==null?void 0:t.thumbnail,label:s("explorer.imagepicker.label"),addButtonLabel:s("explorer.imagepicker.button.add"),deleteButtonLabel:s("explorer.imagepicker.button.delete"),onUploadImage:h,onDeleteImage:k,className:"align-self-center"}),e.jsxs("div",{className:"col",children:[e.jsxs(d,{id:"title",className:"mb-16",isRequired:!0,children:[e.jsx(E,{children:s("title")}),e.jsx(P,{type:"text",defaultValue:a?t==null?void 0:t.name:"",...n("title",{required:!0}),placeholder:s("explorer.resource.editModal.title.placeholder"),size:"md","aria-required":!0})]}),e.jsxs(d,{id:"description",isOptional:!0,children:[e.jsx(E,{children:s("description")}),e.jsx(P,{type:"text",defaultValue:a?t==null?void 0:t.description:"",...n("description"),placeholder:s("explorer.resource.editModal.description.placeholder"),size:"md"})]})]})]}),e.jsxs(_,{headingStyle:"h4",level:"h3",className:"mb-16",children:[s("explorer.resource.editModal.heading.access"),u]}),e.jsx(A,{type:"info",children:s("explorer.resource.editModal.access.alert")}),e.jsxs(d,{id:"flexSwitchCheckDefault",className:"form-switch d-flex gap-8 mt-16 mb-8",children:[e.jsx(d.Input,{type:"checkbox",role:"switch",...n("enablePublic",{value:t.public,onChange:o=>R(o.target.checked)}),className:"form-check-input mt-0",size:"md"},j),e.jsx(d.Label,{className:"form-check-label mb-0",children:s("explorer.resource.editModal.access.flexSwitchCheckDefault.label")})]}),e.jsx(d,{id:"slug",status:x?"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,"/"]}),e.jsxs("div",{className:"flex-fill",children:[e.jsx(P,{type:"text",...n("safeSlug",{validate:{required:o=>!o&&!i?s("explorer.slug.name.mandatory"):!0},disabled:i,value:w,onChange:o=>f(o.target.value)}),size:"md",placeholder:s("explorer.resource.editModal.access.url.extension")},T),x&&e.jsx("div",{className:"position-absolute",children:e.jsx(ee,{children:s("explorer.slug.name.error")})})]}),e.jsx(B,{color:"primary",disabled:i,onClick:()=>{b(t.slug)},type:"button",leftIcon:e.jsx(se,{}),variant:"ghost",className:"text-nowrap",children:s("explorer.resource.editModal.access.url.button")})]})})]})]}),e.jsxs(y.Footer,{children:[e.jsx(B,{color:"tertiary",onClick:r,type:"button",variant:"ghost",children:s("explorer.cancel")}),e.jsx(B,{form:m,type:"submit",color:"primary",variant:"filled",disabled:!I||$,children:s(a?"save":"explorer.create")})]})]}),document.getElementById("portal"))}export{ne as default};
1
+ import{f as G,l as J,k as E,r as c,n as K,j as e,q,u as Q,a as Z,M as y,H as _,F as d,W as z,z as P,X as ee,B,Y as se}from"./index.js";import{I as le}from"./ImagePicker.js";import{u as te}from"./index.esm.js";function re({resource:p,onSuccess:a,onCancel:v}){const{i18n:r}=G(),s=J(),u=E(),{reset:C,register:F,handleSubmit:t,setFocus:w,formState:{errors:m,isSubmitting:I,isValid:$}}=te({mode:"onChange"}),i=c.useId(),[M,x]=c.useState(new Date().getTime()),[n,k]=c.useState(!p.public),[g,h]=c.useState(p.slug||""),[N,b]=c.useState(!1),{hotToast:f}=K(q),[R,j]=c.useState({name:"",image:u[0].thumbnail}),T=l=>{j(l)},o=()=>{j({name:"",image:""})};function D(l){k(!l),l||(h(""),x(new Date().getTime()))}function L(l){if(!l)return"";const S="àáäâãåăæçèéëêǵḧìíïîḿńǹñòóöôœøṕŕßśșțùúüûǘẃẍÿź·/_,:;",O="aaaaaaaaceeeeghiiiimnnnooooooprssstuuuuuwxyz------",W=new RegExp(S.split("").join("|"),"g"),X=l.toString().toLowerCase().replace(/\s+/g,"-").replace(W,Y=>O.charAt(S.indexOf(Y))).replace(/&/g,"-and-").replace(/[^\w\\-]+/g,"").replace(/\\-\\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");h(X)}const V=async function(l){try{await s.mutateAsync({description:l.description,entId:u[0].assetId,name:l.title,public:l.enablePublic,slug:l.safeSlug,trashed:u[0].trashed,thumbnail:R.image}),b(!1),f.success(e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:r("explorer.resource.updated")}),e.jsxs("p",{children:["Titre: ",l.title]}),e.jsxs("p",{children:["Description: ",l.description]}),e.jsxs("p",{children:["Public:"," ",l.enablePublic?r("explorer.enable.public.yes"):r("explorer.enable.public.no")]})]})),a==null||a()}catch(S){b(!0),console.error(S)}};function A(){navigator.clipboard.writeText(`${window.location.origin}/${g}`),f.success(r("explorer.copy.clipboard"))}function H(){C(),v()}const U=`resource_edit_modal_${i}`;return{slug:g,disableSlug:n,formId:U,errors:m,isSubmitting:I,isValid:$,versionSlug:M,correctSlug:N,onPublicChange:D,onSlugChange:L,register:F,setFocus:w,handleSubmit:t,onFormCancel:H,onSubmit:V,handleUploadImage:T,handleDeleteImage:o,onCopyToClipBoard:A}}function ne({isOpen:p,edit:a,onSuccess:v,onCancel:r}){const{i18n:s,appCode:u,currentApp:C}=Q(),t=E()[0],{slug:w,formId:m,isValid:I,isSubmitting:$,disableSlug:i,versionSlug:M,correctSlug:x,register:n,handleSubmit:k,onSubmit:g,handleUploadImage:h,handleDeleteImage:N,onCopyToClipBoard:b,onSlugChange:f,onPublicChange:R}=re({resource:t,onSuccess:v,onCancel:r}),j=`${new Date().getTime()}_${i}`,T=`${M}_slug`;return Z.createPortal(e.jsxs(y,{id:"resource_edit_modal",size:"lg",isOpen:p,onModalClose:r,children:[e.jsx(y.Header,{onModalClose:r,children:s(a?"explorer.resource.editModal.header.edit":"explorer.resource.editModal.header.create")}),e.jsxs(y.Body,{children:[e.jsx(_,{headingStyle:"h4",level:"h3",className:"mb-16",children:s("explorer.resource.editModal.heading.general")}),e.jsxs("form",{id:m,onSubmit:k(g),children:[e.jsxs("div",{className:"d-flex flex-column flex-md-row gap-16 mb-24",children:[e.jsx(le,{app:C,src:t==null?void 0:t.thumbnail,label:s("explorer.imagepicker.label"),addButtonLabel:s("explorer.imagepicker.button.add"),deleteButtonLabel:s("explorer.imagepicker.button.delete"),onUploadImage:h,onDeleteImage:N,className:"align-self-center"}),e.jsxs("div",{className:"col",children:[e.jsxs(d,{id:"title",className:"mb-16",isRequired:!0,children:[e.jsx(z,{children:s("title")}),e.jsx(P,{type:"text",defaultValue:a?t==null?void 0:t.name:"",...n("title",{required:!0}),placeholder:s("explorer.resource.editModal.title.placeholder"),size:"md","aria-required":!0})]}),e.jsxs(d,{id:"description",isOptional:!0,children:[e.jsx(z,{children:s("description")}),e.jsx(P,{type:"text",defaultValue:a?t==null?void 0:t.description:"",...n("description"),placeholder:s("explorer.resource.editModal.description.placeholder"),size:"md"})]})]})]}),e.jsxs(_,{headingStyle:"h4",level:"h3",className:"mb-16",children:[s("explorer.resource.editModal.heading.access"),u]}),e.jsx(q,{type:"info",children:s("explorer.resource.editModal.access.alert")}),e.jsxs(d,{id:"flexSwitchCheckDefault",className:"form-switch d-flex gap-8 mt-16 mb-8",children:[e.jsx(d.Input,{type:"checkbox",role:"switch",...n("enablePublic",{value:t.public,onChange:o=>R(o.target.checked)}),className:"form-check-input mt-0",size:"md"},j),e.jsx(d.Label,{className:"form-check-label mb-0",children:s("explorer.resource.editModal.access.flexSwitchCheckDefault.label")})]}),e.jsx(d,{id:"slug",status:x?"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,"/"]}),e.jsxs("div",{className:"flex-fill",children:[e.jsx(P,{type:"text",...n("safeSlug",{validate:{required:o=>!o&&!i?s("explorer.slug.name.mandatory"):!0},disabled:i,value:w,onChange:o=>f(o.target.value)}),size:"md",placeholder:s("explorer.resource.editModal.access.url.extension")},T),x&&e.jsx("div",{className:"position-absolute",children:e.jsx(ee,{children:s("explorer.slug.name.error")})})]}),e.jsx(B,{color:"primary",disabled:i,onClick:()=>{b(t.slug)},type:"button",leftIcon:e.jsx(se,{}),variant:"ghost",className:"text-nowrap",children:s("explorer.resource.editModal.access.url.button")})]})})]})]}),e.jsxs(y.Footer,{children:[e.jsx(B,{color:"tertiary",onClick:r,type:"button",variant:"ghost",children:s("explorer.cancel")}),e.jsx(B,{form:m,type:"submit",color:"primary",variant:"filled",disabled:!I||$,children:s(a?"save":"explorer.create")})]})]}),document.getElementById("portal"))}export{ne as default};
@@ -1 +1 @@
1
- import{u as s,a8 as n,j as a}from"./index.js";import{E as c}from"./EmptyScreen.js";function d(){const{i18n:r,appCode:o,theme:e}=s(),{data:l}=n(),t=l==null?void 0:l.find(i=>i.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 a.jsx(c,{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{d as default};
1
+ import{u as s,a7 as n,j as a}from"./index.js";import{E as c}from"./EmptyScreen.js";function d(){const{i18n:r,appCode:o,theme:e}=s(),{data:l}=n(),t=l==null?void 0:l.find(i=>i.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 a.jsx(c,{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{d as default};
@@ -1 +1 @@
1
- import{u as S,a9 as h,K as j,aa as f,b as y,ab as C,j as o,$ as a}from"./index.js";import{C as I}from"./Card.js";import"./Tooltip.js";import"./usePopper.js";const O=()=>{var c,d;const{currentApp:p}=S(),{data:e,isFetching:u}=h(),n=j(),i=f(),{setSelectedFolders:l,setFolderIds:r,openFolder:m}=y();function g(s){i.includes(s.id)?(r(i.filter(t=>t!==s.id)),l(n.filter(t=>t.id!==s.id))):(r([...i,s.id]),l([...n,s]))}const F=C({from:{opacity:0},to:{opacity:1}});return(c=e==null?void 0:e.pages[0])!=null&&c.folders.length?o.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 o.jsx(a.li,{className:"g-col-4",style:{...F},children:o.jsx(I,{app:p,name:x,isFolder:!0,isLoading:u,isSelected:i.includes(s.id),onOpen:()=>m({folder:s,folderId:s.id}),onSelect:()=>g(s)})},t)})}):null};export{O as default};
1
+ import{u as S,a8 as h,J as j,a9 as f,b as y,aa as C,j as o,_ as a}from"./index.js";import{C as I}from"./Card.js";import"./Tooltip.js";import"./usePopper.js";const N=()=>{var c,d;const{currentApp:p}=S(),{data:e,isFetching:u}=h(),n=j(),i=f(),{setSelectedFolders:l,setFolderIds:r,openFolder:m}=y();function g(s){i.includes(s.id)?(r(i.filter(t=>t!==s.id)),l(n.filter(t=>t.id!==s.id))):(r([...i,s.id]),l([...n,s]))}const F=C({from:{opacity:0},to:{opacity:1}});return(c=e==null?void 0:e.pages[0])!=null&&c.folders.length?o.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 o.jsx(a.li,{className:"g-col-4",style:{...F},children:o.jsx(I,{app:p,name:x,isFolder:!0,isLoading:u,isSelected:i.includes(s.id),onOpen:()=>m({folder:s,folderId:s.id}),onSelect:()=>g(s)})},t)})}):null};export{N as default};
@@ -1 +1 @@
1
- import{r as s,f as R,c as a,F as d,w as p,a5 as L,a6 as E,C as N,s as S,a7 as z}from"./index.js";const u=s.forwardRef(({label:h,addButtonLabel:x="Add image",deleteButtonLabel:v="Delete image",src:f,className:j,app:D,onUploadImage:C,onDeleteImage:w},I)=>{const r=s.useRef(null),[n,o]=s.useState({name:"",image:f||""}),[,c]=s.useState(!1),l=e=>{o({...n,name:"",image:""});const t=e==null?void 0:e[0];if(!t)return;const i={...n,name:t.name,image:URL.createObjectURL(t)};o(i),C(i)},P=()=>{var e;(e=r.current)==null||e.click()},$=()=>{r.current&&(r.current.value="");const e={...n,name:"",image:""};o(e),w()},b=e=>{l(e.target.files)},g=e=>{e.preventDefault(),e.stopPropagation(),c(!0)},m=e=>{e.preventDefault(),e.stopPropagation(),c(!1)},k=e=>{var i;m(e);const t=(i=e.dataTransfer)==null?void 0:i.files;l(t),r.current&&t&&(r.current.files=t)},y=R("image-input",j);return a.jsxs(d,{id:"image-input",className:y,onDragEnter:g,onDragOver:g,onDragLeave:m,onDrop:k,ref:I,children:[a.jsxs("div",{className:"image-input-actions gap-8",children:[a.jsx(p,{"aria-label":x,color:"tertiary",icon:a.jsx(L,{}),onClick:P,type:"button",variant:"ghost"}),a.jsx(p,{"aria-label":v,color:"danger",disabled:!n.image,icon:a.jsx(E,{width:"20",height:"20"}),onClick:$,type:"button",variant:"ghost"})]}),a.jsxs(d.Label,{children:[a.jsx("span",{className:"visually-hidden",children:h}),a.jsx(N,{accept:"image/*",hidden:!0,onChange:b,ref:r,size:"sm",type:"file"}),n.image?a.jsx(S,{alt:n.name,src:n.image,size:"xl"}):a.jsx(z,{app:D,iconFit:"ratio",size:"160",variant:"rounded"})]})]})});u.displayName="ImagePicker";const F=u;export{F as I};
1
+ import{r as s,e as R,c as a,F as d,v as p,a4 as L,a5 as z,z as E,s as N,a6 as S}from"./index.js";const u=s.forwardRef(({label:h,addButtonLabel:x="Add image",deleteButtonLabel:v="Delete image",src:j,className:f,app:D,onUploadImage:C,onDeleteImage:I},P)=>{const r=s.useRef(null),[n,o]=s.useState({name:"",image:j||""}),[,c]=s.useState(!1),l=e=>{o({...n,name:"",image:""});const t=e==null?void 0:e[0];if(!t)return;const i={...n,name:t.name,image:URL.createObjectURL(t)};o(i),C(i)},$=()=>{var e;(e=r.current)==null||e.click()},b=()=>{r.current&&(r.current.value="");const e={...n,name:"",image:""};o(e),I()},k=e=>{l(e.target.files)},g=e=>{e.preventDefault(),e.stopPropagation(),c(!0)},m=e=>{e.preventDefault(),e.stopPropagation(),c(!1)},w=e=>{var i;m(e);const t=(i=e.dataTransfer)==null?void 0:i.files;l(t),r.current&&t&&(r.current.files=t)},y=R("image-input",f);return a.jsxs(d,{id:"image-input",className:y,onDragEnter:g,onDragOver:g,onDragLeave:m,onDrop:w,ref:P,children:[a.jsxs("div",{className:"image-input-actions gap-8",children:[a.jsx(p,{"aria-label":x,color:"tertiary",icon:a.jsx(L,{}),onClick:$,type:"button",variant:"ghost"}),a.jsx(p,{"aria-label":v,color:"danger",disabled:!n.image,icon:a.jsx(z,{width:"20",height:"20"}),onClick:b,type:"button",variant:"ghost"})]}),a.jsxs(d.Label,{children:[a.jsx("span",{className:"visually-hidden",children:h}),a.jsx(E,{accept:"image/*",hidden:!0,onChange:k,ref:r,size:"sm",type:"file"}),n.image?a.jsx(N,{alt:n.name,src:n.image,size:"xl"}):a.jsx(S,{app:D,iconFit:"ratio",size:"160",variant:"rounded"})]})]})});u.displayName="ImagePicker";const F=u;export{F as I};
package/dist/MoveModal.js CHANGED
@@ -1 +1 @@
1
- import{r as p,J as v,K as I,m as M,b as T,N as y,u as b,O as j,a as F,j as t,M as n,T as S,B as x}from"./index.js";function w({onSuccess:s}){const[a,r]=p.useState(),l=v(),d=I(),c=M(),{foldTreeItem:i,unfoldTreeItem:m}=T(),u=y();async function f(){try{if(!a)throw new Error("explorer.move.selection.empty");await l.mutate(a),await(s==null?void 0:s())}catch(e){console.error(e)}}const h=e=>{for(const o of d)if(e===o.id||e===o.parentId)return!1;for(const o of c)if(e===((o==null?void 0:o.folderIds)&&o.folderIds[0]))return!1;return!0};return{disableSubmit:!a,handleTreeItemSelect:e=>{h(e)?r(e):r(void 0)},handleTreeItemFold:i,handleTreeItemUnfold:async e=>await m(e,u),onMove:()=>{f()}}}function B({isOpen:s,onSuccess:a,onCancel:r}){const{i18n:l}=b(),{handleTreeItemFold:d,handleTreeItemSelect:c,handleTreeItemUnfold:i,onMove:m,disableSubmit:u}=w({onSuccess:a}),f=j();return F.createPortal(t.jsxs(n,{isOpen:s,onModalClose:r,id:"moveModal",children:[t.jsx(n.Header,{onModalClose:r,children:l("explorer.move.title")}),t.jsx(n.Subtitle,{children:l("explorer.move.subtitle")}),t.jsx(n.Body,{children:t.jsx(S,{data:f,onTreeItemSelect:c,onTreeItemFold:d,onTreeItemUnfold:i})}),t.jsxs(n.Footer,{children:[t.jsx(x,{color:"tertiary",onClick:r,type:"button",variant:"ghost",children:l("explorer.cancel")}),t.jsx(x,{color:"primary",onClick:m,type:"button",variant:"filled",disabled:u,children:l("explorer.move")})]})]}),document.getElementById("portal"))}export{B as default};
1
+ import{r as p,G as v,J as I,k as M,b as T,K as y,u as b,N as j,a as F,j as t,M as n,T as S,B as x}from"./index.js";function w({onSuccess:s}){const[a,r]=p.useState(),l=v(),d=I(),c=M(),{foldTreeItem:i,unfoldTreeItem:m}=T(),u=y();async function f(){try{if(!a)throw new Error("explorer.move.selection.empty");await l.mutate(a),await(s==null?void 0:s())}catch(e){console.error(e)}}const h=e=>{for(const o of d)if(e===o.id||e===o.parentId)return!1;for(const o of c)if(e===((o==null?void 0:o.folderIds)&&o.folderIds[0]))return!1;return!0};return{disableSubmit:!a,handleTreeItemSelect:e=>{h(e)?r(e):r(void 0)},handleTreeItemFold:i,handleTreeItemUnfold:async e=>await m(e,u),onMove:()=>{f()}}}function B({isOpen:s,onSuccess:a,onCancel:r}){const{i18n:l}=b(),{handleTreeItemFold:d,handleTreeItemSelect:c,handleTreeItemUnfold:i,onMove:m,disableSubmit:u}=w({onSuccess:a}),f=j();return F.createPortal(t.jsxs(n,{isOpen:s,onModalClose:r,id:"moveModal",children:[t.jsx(n.Header,{onModalClose:r,children:l("explorer.move.title")}),t.jsx(n.Subtitle,{children:l("explorer.move.subtitle")}),t.jsx(n.Body,{children:t.jsx(S,{data:f,onTreeItemSelect:c,onTreeItemFold:d,onTreeItemUnfold:i})}),t.jsxs(n.Footer,{children:[t.jsx(x,{color:"tertiary",onClick:r,type:"button",variant:"ghost",children:l("explorer.cancel")}),t.jsx(x,{color:"primary",onClick:m,type:"button",variant:"filled",disabled:u,children:l("explorer.move")})]})]}),document.getElementById("portal"))}export{B as default};
@@ -1,2 +1,2 @@
1
- import{r as g,_ as K,R as Q,c as l,$ as ee,f as D,a0 as re,a1 as ae,a2 as te,u as R,p as se,m as W,a3 as le,b as ie,a4 as ce,j as r,A as P,h as oe,a as ne,M as w,H as k,F as A,X as $,C as F,B}from"./index.js";import{u as ue}from"./usePopper.js";import{S as V}from"./SelectList.js";import{I as be}from"./ImagePicker.js";import{u as pe}from"./index.esm.js";const J=({trigger:e,content:t})=>{const[s,a]=g.useState(null),[c,i]=g.useState(null),{styles:n,attributes:m}=ue(s,c,{placement:"bottom-start",modifiers:[{name:"offset",options:{offset:[0,12]}}]}),[h,j]=g.useState(!1),u=K(h,{from:{opacity:0,y:10},enter:{opacity:1,y:0},leave:{opacity:0,y:10}}),b=()=>{j(o=>!o)},y=Q.cloneElement(e,{ref:a,onClick:b,state:h?"selected":"default"});return g.useEffect(()=>{const o=v=>{c&&!c.contains(v.target)&&s&&!s.contains(v.target)&&j(!1)};return document.addEventListener("mousedown",o,!0),document.addEventListener("touchstart",o,!0),()=>{document.removeEventListener("mousedown",o,!0),document.removeEventListener("touchstart",o,!0)}},[c,s]),l.jsxs(l.Fragment,{children:[y,u((o,v)=>l.jsx(l.Fragment,{children:v&&l.jsx(ee.div,{className:D("bg-white shadow rounded-4 d-block show py-12 px-8","bs-tooltip-auto"),ref:i,style:{...n.popper,...o},...m.popper,children:t})}))]})};J.displayName="Dropdown";const H=J,Z=g.forwardRef(({title:e="",state:t,variant:s,icon:a,size:c="lg",grow:i=!1,badgeContent:n,...m},h)=>{const j=D("dropdown-trigger",t,c,s,i&&"flex-grow-1 justify-content-between");return l.jsxs("button",{ref:h,className:j,...m,type:"button",children:[a&&l.jsx("div",{className:"dropdown-trigger-icon",children:a}),l.jsx("div",{children:e}),n?l.jsx("div",{children:l.jsx("span",{className:"badge text-bg-secondary rounded-pill",children:n})}):l.jsx("div",{className:"dropdown-trigger-carret-icon",children:l.jsx(re,{width:16,height:16})})]})});Z.displayName="DropdownTrigger";const U=Z,X=g.forwardRef(({options:e,model:t,disabled:s=!1,placeholderOption:a=!1,...c},i)=>{const{isRequired:n,status:m}=ae(),h=g.useId(),j={...c,id:h,disabled:s,ref:i,className:D(c.className,"form-select c-pointer",{"is-invalid":m==="invalid","is-valid":m==="valid"})};return l.jsx(l.Fragment,{children:l.jsxs("select",{...j,required:n,children:[a&&l.jsx("option",{disabled:!0,selected:t===void 0,children:a}),e==null?void 0:e.map(u=>{const b=typeof u=="object"?u.value:u,y=typeof u=="object"?u.label:u;return l.jsx("option",{value:b,selected:t===b,children:y},b)})]})})});X.displayName="Select";const L=X,{http:M}=te.instance();function de({onSuccess:e}){const{user:t,currentApp:s}=R(),[a,c]=g.useState({name:"",image:""}),{hotToast:i}=se(P),n=W(),m=le(),{publishApi:h}=ie(),{register:j,handleSubmit:u,formState:{errors:b,isSubmitting:y,isDirty:o,isValid:v}}=pe({mode:"onChange"}),[S,T]=g.useState([]),[E,q]=g.useState([]);function C(p){c(p)}const f=t?t==null?void 0:t.userId:"";return{selectedResources:n,register:j,handleSubmit:u,formState:{errors:b,isSubmitting:y,isDirty:o,isValid:v},publish:async p=>{try{let x=new Blob;a.image?x=await M.get(a.image,{responseType:"blob"}):n[0].thumbnail&&(x=await M.get(n[0].thumbnail,{responseType:"blob"}));const _=await M.get(`/userbook/avatar/${f}?thumbnail=48x48`,{responseType:"blob"}),d=await M.get(`/directory/user/${f}/attachment-school`,{responseType:"json"}),N={activityType:S,age:[p.ageMin,p.ageMax],application:(s==null?void 0:s.displayName)||"",cover:x,description:p.description,keyWords:p.keyWords,language:p.language,licence:"CC-BY",resourceId:m[0],subjectArea:E,teacherAvatar:_,title:p.title,userId:f,userStructureName:d.name||(t==null?void 0:t.structureNames[0])},Y=[ce.BLOG][0],z=await h(Y,N);z.success?i.success(r.jsx(he,{result:z}),{duration:1/0}):i.error(r.jsx(G,{}),{duration:1/0}),e==null||e()}catch{i.error(r.jsx(G,{}),{duration:1/0})}},handleDeleteImage:()=>{c({name:"",image:""})},handleUploadImage:C,selectedActivities:S,setSelectedActivities:T,selectedSubjectAreas:E,setSelectedSubjectAreas:q}}function me(){const{i18n:e}=oe(),t=[{value:"bpr.activityType.classroomActivity",label:e("bpr.activityType.classroomActivity")},{value:"bpr.activityType.groupActivity",label:e("bpr.activityType.groupActivity")},{value:"bpr.activityType.personalActivity",label:e("bpr.activityType.personalActivity")},{value:"bpr.activityType.homework",label:e("bpr.activityType.homework")},{value:"bpr.activityType.exercize",label:e("bpr.activityType.exercize")},{value:"bpr.activityType.learningPath",label:e("bpr.activityType.learningPath")},{value:"bpr.activityType.courseElement",label:e("bpr.activityType.courseElement")},{value:"bpr.other",label:e("bpr.other")}],s=[{value:"bpr.subjectArea.artActivity",label:e("bpr.subjectArea.artActivity")},{value:"bpr.subjectArea.readLearning",label:e("bpr.subjectArea.readLearning")},{value:"bpr.subjectArea.chemistry",label:e("bpr.subjectArea.chemistry")},{value:"bpr.subjectArea.law",label:e("bpr.subjectArea.law")},{value:"bpr.subjectArea.worldDiscovery",label:e("bpr.subjectArea.worldDiscovery")},{value:"bpr.subjectArea.economy",label:e("bpr.subjectArea.economy")},{value:"bpr.subjectArea.mediaEducation",label:e("bpr.subjectArea.mediaEducation")},{value:"bpr.subjectArea.musicEducation",label:e("bpr.subjectArea.musicEducation")},{value:"bpr.subjectArea.sportEducation",label:e("bpr.subjectArea.sportEducation")},{value:"bpr.subjectArea.citizenshipEducation",label:e("bpr.subjectArea.citizenshipEducation")},{value:"bpr.subjectArea.geography",label:e("bpr.subjectArea.geography")},{value:"bpr.subjectArea.history",label:e("bpr.subjectArea.history")},{value:"bpr.subjectArea.artHistory",label:e("bpr.subjectArea.artHistory")},{value:"bpr.subjectArea.ComputerScience",label:e("bpr.subjectArea.ComputerScience")},{value:"bpr.subjectArea.languages",label:e("bpr.subjectArea.languages")},{value:"bpr.subjectArea.italian",label:e("bpr.subjectArea.italian")},{value:"bpr.subjectArea.spanish",label:e("bpr.subjectArea.spanish")},{value:"bpr.subjectArea.french",label:e("bpr.subjectArea.french")},{value:"bpr.subjectArea.german",label:e("bpr.subjectArea.german")},{value:"bpr.subjectArea.english",label:e("bpr.subjectArea.english")},{value:"bpr.subjectArea.ancientLanguages",label:e("bpr.subjectArea.ancientLanguages")},{value:"bpr.subjectArea.literature",label:e("bpr.subjectArea.literature")},{value:"bpr.subjectArea.mathematics",label:e("bpr.subjectArea.mathematics")},{value:"bpr.subjectArea.vocationalGuidance",label:e("bpr.subjectArea.vocationalGuidance")},{value:"bpr.subjectArea.philosohppy",label:e("bpr.subjectArea.philosohppy")},{value:"bpr.subjectArea.physics",label:e("bpr.subjectArea.physics")},{value:"bpr.subjectArea.politicalSscience",label:e("bpr.subjectArea.politicalSscience")},{value:"bpr.subjectArea.sociology",label:e("bpr.subjectArea.sociology")},{value:"bpr.subjectArea.biology",label:e("bpr.subjectArea.biology")},{value:"bpr.subjectArea.geology",label:e("bpr.subjectArea.geology")},{value:"bpr.subjectArea.technology",label:e("bpr.subjectArea.technology")},{value:"bpr.other",label:e("bpr.other")}],a=[{value:"de_DE",label:e("de_DE")},{value:"en_EN",label:e("en_EN")},{value:"ar_DZ",label:e("ar_DZ")},{value:"es_ES",label:e("es_ES")},{value:"fr_FR",label:e("fr_FR")},{value:"it_IT",label:e("it_IT")},{value:"ja_JP",label:e("ja_JP")},{value:"zh_CN",label:e("zh_CN")},{value:"pt_PT",label:e("pt_PT")},{value:"ru_RU",label:e("ru_RU")},{value:"bpr.other",label:e("bpr.other")}];return{activityTypeOptions:t,subjectAreaOptions:s,languageOptions:a,ageOptions:["3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18"]}}function fe({isOpen:e,onSuccess:t,onCancel:s}){var x,_;const{i18n:a,currentApp:c}=R(),{register:i,handleSubmit:n,publish:m,formState:{isDirty:h,isValid:j},handleUploadImage:u,selectedActivities:b,setSelectedActivities:y,selectedSubjectAreas:o,setSelectedSubjectAreas:v,handleDeleteImage:S}=de({onSuccess:t}),T=W(),{activityTypeOptions:E,subjectAreaOptions:q,languageOptions:C,ageOptions:f}=me(),I=a("bpr.form.publication.language"),O=a("bpr.form.publication.age.min"),p=a("bpr.form.publication.age.max");return ne.createPortal(r.jsxs(w,{isOpen:e,onModalClose:s,id:"libraryModal",size:"lg",children:[r.jsx(w.Header,{onModalClose:s,children:a("bpr.publish")}),r.jsx(w.Subtitle,{children:a("bpr.form.tip")}),r.jsxs(w.Body,{children:[r.jsx(k,{headingStyle:"h4",level:"h3",className:"mb-16",children:a("bpr.form.publication.heading.general")}),r.jsxs("form",{id:"libraryModalForm",onSubmit:n(m),children:[r.jsxs(A,{id:"title",className:"mb-16",isRequired:!0,children:[r.jsx($,{requiredText:"",children:a("bpr.form.publication.title")}),r.jsx(F,{type:"text",defaultValue:(x=T[0])==null?void 0:x.name,...i("title",{required:!0}),placeholder:a("bpr.form.publication.title.placeholder"),size:"md","aria-required":!0})]}),r.jsxs("div",{className:"mb-24",children:[r.jsx("div",{className:"form-label",children:a("bpr.form.publication.cover.title")}),r.jsx(be,{app:c,src:(_=T[0])==null?void 0:_.thumbnail,label:a("bpr.form.publication.cover.upload.label"),addButtonLabel:a("bpr.form.publication.cover.upload.add"),deleteButtonLabel:a("bpr.form.publication.cover.upload.remove"),onUploadImage:u,onDeleteImage:S,className:"align-self-center"})]}),r.jsxs(A,{id:"description",isRequired:!0,children:[r.jsx($,{requiredText:"",children:a("bpr.form.publication.description")}),r.jsx(F,{type:"text",...i("description",{required:!0}),placeholder:a("bpr.form.publication.description.placeholder"),size:"md","aria-required":!0})]}),r.jsx("hr",{}),r.jsx(k,{headingStyle:"h4",level:"h3",className:"mb-16",children:a("bpr.form.publication.heading.infos")}),r.jsxs("div",{className:"d-flex flex-column flex-md-row gap-16 row mb-24",children:[r.jsx("div",{className:"col d-flex",children:r.jsx(H,{trigger:r.jsx(U,{title:a("bpr.form.publication.type"),size:"md",grow:!0}),content:r.jsx(V,{options:E,model:b,onChange:d=>y(d)})})}),r.jsx("div",{className:"col d-flex",children:r.jsx(H,{trigger:r.jsx(U,{title:a("bpr.form.publication.discipline"),size:"md",grow:!0}),content:r.jsx(V,{options:q,model:o,onChange:d=>v(d)})})}),r.jsx("div",{className:"col",children:r.jsx(A,{id:"language",isRequired:!0,children:r.jsx(L,{...i("language",{required:!0,validate:d=>d!==I}),options:C,placeholderOption:I,defaultValue:I,"aria-required":!0})})})]}),r.jsxs("div",{className:"mb-24",children:[r.jsx("label",{htmlFor:"",className:"form-label",children:a("bpr.form.publication.age")}),r.jsxs("div",{className:"d-flex",children:[r.jsx("div",{className:"me-16",children:r.jsx(A,{id:"ageMin",isRequired:!0,children:r.jsx(L,{...i("ageMin",{required:!0,validate:(d,N)=>parseInt(d)<=parseInt(N.ageMax)}),options:f,placeholderOption:O,defaultValue:O,"aria-required":!0})})}),r.jsx("div",{children:r.jsx(A,{id:"ageMax",isRequired:!0,children:r.jsx(L,{...i("ageMax",{required:!0,validate:(d,N)=>parseInt(d)>=parseInt(N.ageMin)}),options:f,placeholderOption:p,defaultValue:p,"aria-required":!0})})})]})]}),r.jsx("div",{className:"mb-24",children:r.jsxs(A,{id:"keywords",isOptional:!0,children:[r.jsx($,{children:a("bpr.form.publication.keywords")}),r.jsx(F,{type:"text",...i("keyWords"),size:"md",placeholder:a("bpr.form.publication.keywords.placeholder")})]})}),r.jsx("hr",{}),r.jsx(k,{headingStyle:"h4",level:"h3",className:"mb-16",children:a("bpr.form.publication.licence.text")}),r.jsxs("ul",{className:"mb-12",children:[r.jsxs("li",{children:[a("bpr.form.publication.licence.text.1"),r.jsx("img",{className:"ms-8 d-inline-block",src:"/assets/themes/entcore-css-lib/images/cc-by-nc-sa.svg",alt:`Icone licence Creative
2
- Commons`})]}),r.jsx("li",{children:a("bpr.form.publication.licence.text.2")})]}),r.jsx(P,{type:"info",className:"mb-12",children:a("bpr.form.publication.licence.text.3")}),r.jsx(P,{type:"warning",children:a("bpr.form.publication.licence.text.4")})]})]}),r.jsxs(w.Footer,{children:[r.jsx(B,{color:"tertiary",onClick:s,type:"button",variant:"ghost",children:a("cancel")}),r.jsx(B,{form:"libraryModalForm",type:"submit",color:"primary",variant:"filled",disabled:!h||!j||(b==null?void 0:b.length)===0||(o==null?void 0:o.length)===0,children:a("bpr.form.submit")})]})]}),document.getElementById("portal"))}function he({result:e}){const{i18n:t}=R();return r.jsxs(r.Fragment,{children:[r.jsx("h3",{className:"pt-24",children:t("bpr.form.publication.response.success.title")}),r.jsx("p",{className:"pt-24",children:t("bpr.form.publication.response.success.content.1")}),r.jsx("p",{className:"pt-24",children:t("bpr.form.publication.response.success.content.2")}),e.details.front_url&&r.jsx("p",{className:"pt-24 pb-24",children:r.jsx("a",{className:"button right-magnet",href:e.details.front_url,target:"_blank",rel:"noreferrer",children:t("bpr.form.publication.response.success.button")})})]})}function G(){const{i18n:e}=R();return r.jsxs(r.Fragment,{children:[r.jsx("h3",{className:"pt-24",children:e("bpr.form.publication.response.error.title")}),r.jsx("p",{className:"pt-24 pb-24",children:r.jsx("strong",{children:e("bpr.form.publication.response.error.content")})})]})}export{G as PublishModalError,he as PublishModalSuccess,fe as default};
1
+ import{r as g,Z as Q,R as X,c as l,_ as ee,e as D,$ as re,a0 as ae,a1 as te,u as M,n as se,k as W,a2 as le,b as ie,a3 as ce,j as r,q as P,f as oe,a as ne,M as w,H as C,F as A,W as F,z as $,B}from"./index.js";import{u as ue}from"./usePopper.js";import{S as U}from"./SelectList.js";import{I as be}from"./ImagePicker.js";import{u as pe}from"./index.esm.js";const Z=({trigger:e,content:t})=>{const[s,a]=g.useState(null),[c,i]=g.useState(null),{styles:n,attributes:m}=ue(s,c,{placement:"bottom-start",modifiers:[{name:"offset",options:{offset:[0,12]}}]}),[h,j]=g.useState(!1),u=Q(h,{from:{opacity:0,y:10},enter:{opacity:1,y:0},leave:{opacity:0,y:10}}),b=()=>{j(o=>!o)},y=X.cloneElement(e,{ref:a,onClick:b,state:h?"selected":"default"});return g.useEffect(()=>{const o=v=>{c&&!c.contains(v.target)&&s&&!s.contains(v.target)&&j(!1)};return document.addEventListener("mousedown",o,!0),document.addEventListener("touchstart",o,!0),()=>{document.removeEventListener("mousedown",o,!0),document.removeEventListener("touchstart",o,!0)}},[c,s]),l.jsxs(l.Fragment,{children:[y,u((o,v)=>l.jsx(l.Fragment,{children:v&&l.jsx(ee.div,{className:D("bg-white shadow rounded-4 d-block show py-12 px-8","bs-tooltip-auto"),ref:i,style:{...n.popper,...o},...m.popper,children:t})}))]})};Z.displayName="Dropdown";const V=Z,J=g.forwardRef(({title:e="",state:t,variant:s,icon:a,size:c="lg",grow:i=!1,badgeContent:n,...m},h)=>{const j=D("dropdown-trigger",t,c,s,i&&"flex-grow-1 justify-content-between");return l.jsxs("button",{ref:h,className:j,...m,type:"button",children:[a&&l.jsx("div",{className:"dropdown-trigger-icon",children:a}),l.jsx("div",{children:e}),n?l.jsx("div",{children:l.jsx("span",{className:"badge text-bg-secondary rounded-pill",children:n})}):l.jsx("div",{className:"dropdown-trigger-carret-icon",children:l.jsx(re,{width:16,height:16})})]})});J.displayName="DropdownTrigger";const H=J,Y=g.forwardRef(({options:e,model:t,disabled:s=!1,placeholderOption:a=!1,...c},i)=>{const{isRequired:n,status:m}=ae(),h=g.useId(),j={...c,id:h,disabled:s,ref:i,className:D(c.className,"form-select c-pointer",{"is-invalid":m==="invalid","is-valid":m==="valid"})};return l.jsx(l.Fragment,{children:l.jsxs("select",{...j,required:n,children:[a&&l.jsx("option",{disabled:!0,selected:t===void 0,children:a}),e==null?void 0:e.map(u=>{const b=typeof u=="object"?u.value:u,y=typeof u=="object"?u.label:u;return l.jsx("option",{value:b,selected:t===b,children:y},b)})]})})});Y.displayName="Select";const L=Y,{http:_}=te.instance();function de({onSuccess:e}){const{user:t,currentApp:s}=M(),[a,c]=g.useState({name:"",image:""}),{hotToast:i}=se(P),n=W(),m=le(),{publishApi:h}=ie(),{register:j,handleSubmit:u,formState:{errors:b,isSubmitting:y,isDirty:o,isValid:v}}=pe({mode:"onChange"}),[S,T]=g.useState([]),[E,q]=g.useState([]);function O(p){c(p)}const f=t?t==null?void 0:t.userId:"";return{selectedResources:n,register:j,handleSubmit:u,formState:{errors:b,isSubmitting:y,isDirty:o,isValid:v},publish:async p=>{try{let x=new Blob;a.image?x=await _.get(a.image,{responseType:"blob"}):n[0].thumbnail&&(x=await _.get(n[0].thumbnail,{responseType:"blob"}));const R=await _.get(`/userbook/avatar/${f}?thumbnail=48x48`,{responseType:"blob"}),d=await _.get(`/directory/user/${f}/attachment-school`,{responseType:"json"}),N={activityType:S,age:[p.ageMin,p.ageMax],application:(s==null?void 0:s.displayName)||"",cover:x,description:p.description,keyWords:p.keyWords,language:p.language,licence:"CC-BY",resourceId:m[0],subjectArea:E,teacherAvatar:R,title:p.title,userId:f,userStructureName:d.name||(t==null?void 0:t.structureNames[0])},K=[ce.BLOG][0],z=await h(K,N);z.success?i.success(r.jsx(he,{result:z}),{duration:1/0}):i.error(r.jsx(G,{}),{duration:1/0}),e==null||e()}catch{i.error(r.jsx(G,{}),{duration:1/0})}},handleDeleteImage:()=>{c({name:"",image:""})},handleUploadImage:O,selectedActivities:S,setSelectedActivities:T,selectedSubjectAreas:E,setSelectedSubjectAreas:q}}function me(){const{i18n:e}=oe(),t=[{value:"bpr.activityType.classroomActivity",label:e("bpr.activityType.classroomActivity")},{value:"bpr.activityType.groupActivity",label:e("bpr.activityType.groupActivity")},{value:"bpr.activityType.personalActivity",label:e("bpr.activityType.personalActivity")},{value:"bpr.activityType.homework",label:e("bpr.activityType.homework")},{value:"bpr.activityType.exercize",label:e("bpr.activityType.exercize")},{value:"bpr.activityType.learningPath",label:e("bpr.activityType.learningPath")},{value:"bpr.activityType.courseElement",label:e("bpr.activityType.courseElement")},{value:"bpr.other",label:e("bpr.other")}],s=[{value:"bpr.subjectArea.artActivity",label:e("bpr.subjectArea.artActivity")},{value:"bpr.subjectArea.readLearning",label:e("bpr.subjectArea.readLearning")},{value:"bpr.subjectArea.chemistry",label:e("bpr.subjectArea.chemistry")},{value:"bpr.subjectArea.law",label:e("bpr.subjectArea.law")},{value:"bpr.subjectArea.worldDiscovery",label:e("bpr.subjectArea.worldDiscovery")},{value:"bpr.subjectArea.economy",label:e("bpr.subjectArea.economy")},{value:"bpr.subjectArea.mediaEducation",label:e("bpr.subjectArea.mediaEducation")},{value:"bpr.subjectArea.musicEducation",label:e("bpr.subjectArea.musicEducation")},{value:"bpr.subjectArea.sportEducation",label:e("bpr.subjectArea.sportEducation")},{value:"bpr.subjectArea.citizenshipEducation",label:e("bpr.subjectArea.citizenshipEducation")},{value:"bpr.subjectArea.geography",label:e("bpr.subjectArea.geography")},{value:"bpr.subjectArea.history",label:e("bpr.subjectArea.history")},{value:"bpr.subjectArea.artHistory",label:e("bpr.subjectArea.artHistory")},{value:"bpr.subjectArea.ComputerScience",label:e("bpr.subjectArea.ComputerScience")},{value:"bpr.subjectArea.languages",label:e("bpr.subjectArea.languages")},{value:"bpr.subjectArea.italian",label:e("bpr.subjectArea.italian")},{value:"bpr.subjectArea.spanish",label:e("bpr.subjectArea.spanish")},{value:"bpr.subjectArea.french",label:e("bpr.subjectArea.french")},{value:"bpr.subjectArea.german",label:e("bpr.subjectArea.german")},{value:"bpr.subjectArea.english",label:e("bpr.subjectArea.english")},{value:"bpr.subjectArea.ancientLanguages",label:e("bpr.subjectArea.ancientLanguages")},{value:"bpr.subjectArea.literature",label:e("bpr.subjectArea.literature")},{value:"bpr.subjectArea.mathematics",label:e("bpr.subjectArea.mathematics")},{value:"bpr.subjectArea.vocationalGuidance",label:e("bpr.subjectArea.vocationalGuidance")},{value:"bpr.subjectArea.philosohppy",label:e("bpr.subjectArea.philosohppy")},{value:"bpr.subjectArea.physics",label:e("bpr.subjectArea.physics")},{value:"bpr.subjectArea.politicalSscience",label:e("bpr.subjectArea.politicalSscience")},{value:"bpr.subjectArea.sociology",label:e("bpr.subjectArea.sociology")},{value:"bpr.subjectArea.biology",label:e("bpr.subjectArea.biology")},{value:"bpr.subjectArea.geology",label:e("bpr.subjectArea.geology")},{value:"bpr.subjectArea.technology",label:e("bpr.subjectArea.technology")},{value:"bpr.other",label:e("bpr.other")}],a=[{value:"de_DE",label:e("de_DE")},{value:"en_EN",label:e("en_EN")},{value:"ar_DZ",label:e("ar_DZ")},{value:"es_ES",label:e("es_ES")},{value:"fr_FR",label:e("fr_FR")},{value:"it_IT",label:e("it_IT")},{value:"ja_JP",label:e("ja_JP")},{value:"zh_CN",label:e("zh_CN")},{value:"pt_PT",label:e("pt_PT")},{value:"ru_RU",label:e("ru_RU")},{value:"bpr.other",label:e("bpr.other")}];return{activityTypeOptions:t,subjectAreaOptions:s,languageOptions:a,ageOptions:["3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18"]}}function fe({isOpen:e,onSuccess:t,onCancel:s}){var x,R;const{i18n:a,currentApp:c}=M(),{register:i,handleSubmit:n,publish:m,formState:{isDirty:h,isValid:j},handleUploadImage:u,selectedActivities:b,setSelectedActivities:y,selectedSubjectAreas:o,setSelectedSubjectAreas:v,handleDeleteImage:S}=de({onSuccess:t}),T=W(),{activityTypeOptions:E,subjectAreaOptions:q,languageOptions:O,ageOptions:f}=me(),I=a("bpr.form.publication.language"),k=a("bpr.form.publication.age.min"),p=a("bpr.form.publication.age.max");return ne.createPortal(r.jsxs(w,{isOpen:e,onModalClose:s,id:"libraryModal",size:"lg",children:[r.jsx(w.Header,{onModalClose:s,children:a("bpr.publish")}),r.jsx(w.Subtitle,{children:a("bpr.form.tip")}),r.jsxs(w.Body,{children:[r.jsx(C,{headingStyle:"h4",level:"h3",className:"mb-16",children:a("bpr.form.publication.heading.general")}),r.jsxs("form",{id:"libraryModalForm",onSubmit:n(m),children:[r.jsxs(A,{id:"title",className:"mb-16",isRequired:!0,children:[r.jsx(F,{requiredText:"",children:a("bpr.form.publication.title")}),r.jsx($,{type:"text",defaultValue:(x=T[0])==null?void 0:x.name,...i("title",{required:!0}),placeholder:a("bpr.form.publication.title.placeholder"),size:"md","aria-required":!0})]}),r.jsxs("div",{className:"mb-24",children:[r.jsx("div",{className:"form-label",children:a("bpr.form.publication.cover.title")}),r.jsx(be,{app:c,src:(R=T[0])==null?void 0:R.thumbnail,label:a("bpr.form.publication.cover.upload.label"),addButtonLabel:a("bpr.form.publication.cover.upload.add"),deleteButtonLabel:a("bpr.form.publication.cover.upload.remove"),onUploadImage:u,onDeleteImage:S,className:"align-self-center"})]}),r.jsxs(A,{id:"description",isRequired:!0,children:[r.jsx(F,{requiredText:"",children:a("bpr.form.publication.description")}),r.jsx($,{type:"text",...i("description",{required:!0}),placeholder:a("bpr.form.publication.description.placeholder"),size:"md","aria-required":!0})]}),r.jsx("hr",{}),r.jsx(C,{headingStyle:"h4",level:"h3",className:"mb-16",children:a("bpr.form.publication.heading.infos")}),r.jsxs("div",{className:"d-flex flex-column flex-md-row gap-16 row mb-24",children:[r.jsx("div",{className:"col d-flex",children:r.jsx(V,{trigger:r.jsx(H,{title:a("bpr.form.publication.type"),size:"md",grow:!0}),content:r.jsx(U,{options:E,model:b,onChange:d=>y(d)})})}),r.jsx("div",{className:"col d-flex",children:r.jsx(V,{trigger:r.jsx(H,{title:a("bpr.form.publication.discipline"),size:"md",grow:!0}),content:r.jsx(U,{options:q,model:o,onChange:d=>v(d)})})}),r.jsx("div",{className:"col",children:r.jsx(A,{id:"language",isRequired:!0,children:r.jsx(L,{...i("language",{required:!0,validate:d=>d!==I}),options:O,placeholderOption:I,defaultValue:I,"aria-required":!0})})})]}),r.jsxs("div",{className:"mb-24",children:[r.jsx("label",{htmlFor:"",className:"form-label",children:a("bpr.form.publication.age")}),r.jsxs("div",{className:"d-flex",children:[r.jsx("div",{className:"me-16",children:r.jsx(A,{id:"ageMin",isRequired:!0,children:r.jsx(L,{...i("ageMin",{required:!0,validate:(d,N)=>parseInt(d)<=parseInt(N.ageMax)}),options:f,placeholderOption:k,defaultValue:k,"aria-required":!0})})}),r.jsx("div",{children:r.jsx(A,{id:"ageMax",isRequired:!0,children:r.jsx(L,{...i("ageMax",{required:!0,validate:(d,N)=>parseInt(d)>=parseInt(N.ageMin)}),options:f,placeholderOption:p,defaultValue:p,"aria-required":!0})})})]})]}),r.jsx("div",{className:"mb-24",children:r.jsxs(A,{id:"keywords",isOptional:!0,children:[r.jsx(F,{children:a("bpr.form.publication.keywords")}),r.jsx($,{type:"text",...i("keyWords"),size:"md",placeholder:a("bpr.form.publication.keywords.placeholder")})]})}),r.jsx("hr",{}),r.jsx(C,{headingStyle:"h4",level:"h3",className:"mb-16",children:a("bpr.form.publication.licence.text")}),r.jsxs("ul",{className:"mb-12",children:[r.jsxs("li",{children:[a("bpr.form.publication.licence.text.1"),r.jsx("img",{className:"ms-8 d-inline-block",src:"/assets/themes/entcore-css-lib/images/cc-by-nc-sa.svg",alt:`Icone licence Creative
2
+ Commons`})]}),r.jsx("li",{children:a("bpr.form.publication.licence.text.2")})]}),r.jsx(P,{type:"info",className:"mb-12",children:a("bpr.form.publication.licence.text.3")}),r.jsx(P,{type:"warning",children:a("bpr.form.publication.licence.text.4")})]})]}),r.jsxs(w.Footer,{children:[r.jsx(B,{color:"tertiary",onClick:s,type:"button",variant:"ghost",children:a("cancel")}),r.jsx(B,{form:"libraryModalForm",type:"submit",color:"primary",variant:"filled",disabled:!h||!j||(b==null?void 0:b.length)===0||(o==null?void 0:o.length)===0,children:a("bpr.form.submit")})]})]}),document.getElementById("portal"))}function he({result:e}){const{i18n:t}=M();return r.jsxs(r.Fragment,{children:[r.jsx("h3",{className:"pt-24",children:t("bpr.form.publication.response.success.title")}),r.jsx("p",{className:"pt-24",children:t("bpr.form.publication.response.success.content.1")}),r.jsx("p",{className:"pt-24",children:t("bpr.form.publication.response.success.content.2")}),e.details.front_url&&r.jsx("p",{className:"pt-24 pb-24",children:r.jsx("a",{className:"button right-magnet",href:e.details.front_url,target:"_blank",rel:"noreferrer",children:t("bpr.form.publication.response.success.button")})})]})}function G(){const{i18n:e}=M();return r.jsxs(r.Fragment,{children:[r.jsx("h3",{className:"pt-24",children:e("bpr.form.publication.response.error.title")}),r.jsx("p",{className:"pt-24 pb-24",children:r.jsx("strong",{children:e("bpr.form.publication.response.error.content")})})]})}export{G as PublishModalError,he as PublishModalSuccess,fe as default};
@@ -1 +1 @@
1
- import{u as O,l as $,a9 as B,i as E,a3 as w,m as z,b as J,ab as T,r as U,f as q,j as s,R as h,$ as x,ac as D,B as G}from"./index.js";import{C as H}from"./Card.js";import"./Tooltip.js";import"./usePopper.js";function K(o){const{rights:l,creatorId:t}=o,i=l.filter(d=>!d.includes(t));return i.length>=1&&!i.includes(t)}const Z=()=>{const{currentApp:o,currentLanguage:l,i18n:t}=O(),{avatar:i}=$(),{data:n,isFetching:d,fetchNextPage:f}=B(),u=E(),r=w(),m=z(),{setSelectedResources:g,setResourceIds:p,openResource:S,setResourceIsTrash:R}=J(),j=T({from:{opacity:0},to:{opacity:1}}),b=u.pagination.startIdx+u.pagination.pageSize-1<(u.pagination.maxIdx||0),I=U.useCallback(()=>{f()},[]),y=e=>{e.trashed?(R(!0),p([e.id])):S(e)};function N(e){r.includes(e.id)?(p(r.filter(c=>c!==e.id)),g(m.filter(c=>c.id!==e.id))):(p([...r,e.id]),g([...m,e]))}const C=q("grid ps-0 list-unstyled");return s.jsxs(h.Fragment,{children:[s.jsx(x.ul,{className:C,children:n==null?void 0:n.pages.map((e,c)=>s.jsx(h.Fragment,{children:e.resources.map(a=>{const{id:P,creatorName:A,name:k,thumbnail:v,updatedAt:F}=a,L=K(a),M=D(F).locale(l).fromNow();return s.jsx(x.li,{className:"g-col-4",style:{...j},children:s.jsx(H,{app:o,className:"c-pointer",creatorName:A,isPublic:a.public,isSelected:r.includes(a.id),isLoading:d,isShared:L,messagePublic:t("tooltip.public"),messageShared:t("tooltip.shared"),name:k,onOpen:()=>y(a),onSelect:()=>N(a),resourceSrc:v,updatedAt:M,userSrc:i})},P)})},c))}),b&&s.jsx("div",{className:"d-grid gap-2 col-4 mx-auto my-24",children:s.jsx(G,{type:"button",color:"secondary",variant:"filled",onClick:I,children:t("explorer.see.more")})})]})};export{Z as default};
1
+ import{u as O,i as T,a8 as B,h as $,a2 as w,k as z,b as J,E as U,aa as _,r as q,e as D,j as e,R as g,_ as h,ab as G,B as H}from"./index.js";import{C as K}from"./Card.js";import"./Tooltip.js";import"./usePopper.js";function Q(r){const{rights:o,creatorId:a}=r;return o.filter(c=>!c.includes(a)).length>=1}const ss=()=>{const{currentApp:r,currentLanguage:o,i18n:a}=O(),{avatar:p}=T(),{data:c,isFetching:x,fetchNextPage:f}=B(),l=$(),n=w(),m=z(),{setSelectedResources:d,setResourceIds:u,openResource:R,setResourceIsTrash:S}=J(),j=U(),I=_({from:{opacity:0},to:{opacity:1}}),b=l.pagination.startIdx+l.pagination.pageSize-1<(l.pagination.maxIdx||0),y=q.useCallback(()=>{f()},[]),N=s=>{j?(S(!0),u([s.id]),d([s])):R(s)};function C(s){n.includes(s.id)?(u(n.filter(i=>i!==s.id)),d(m.filter(i=>i.id!==s.id))):(u([...n,s.id]),d([...m,s]))}const P=D("grid ps-0 list-unstyled");return e.jsxs(g.Fragment,{children:[e.jsx(h.ul,{className:P,children:c==null?void 0:c.pages.map((s,i)=>e.jsx(g.Fragment,{children:s.resources.map(t=>{const{id:k,creatorName:A,name:F,thumbnail:v,updatedAt:E}=t,L=Q(t),M=G(E).locale(o).fromNow();return e.jsx(h.li,{className:"g-col-4",style:{...I},children:e.jsx(K,{app:r,className:"c-pointer",creatorName:A,isPublic:t.public,isSelected:n.includes(t.id),isLoading:x,isShared:L,messagePublic:a("tooltip.public"),messageShared:a("tooltip.shared"),name:F,onOpen:()=>N(t),onSelect:()=>C(t),resourceSrc:v,updatedAt:M,userSrc:p})},k)})},i))}),b&&e.jsx("div",{className:"d-grid gap-2 col-4 mx-auto my-24",children:e.jsx(H,{type:"button",color:"secondary",variant:"filled",onClick:y,children:a("explorer.see.more")})})]})};export{ss as default};
@@ -1 +1 @@
1
- import{r as n,c,f as o,R as j}from"./index.js";const x=({options:a,hideCheckbox:d,isMonoSelection:u,onChange:i,model:m=[]})=>{const[s,h]=n.useState(m),r=e=>{h(u?[e]:l=>{const t=[...l];return l.includes(e)?t.splice(t.indexOf(e),1):t.push(e),t})};return n.useEffect(()=>{i==null||i(s)},[s]),c.jsx(c.Fragment,{children:c.jsx("div",{className:"select-list",children:a==null?void 0:a.map(e=>c.jsxs("div",{className:o("select-list-option",d&&s.includes(e.value)&&"text-secondary fw-bold"),role:"checkbox","aria-checked":s.includes(e.value),onMouseUp:()=>{r(e.value)},tabIndex:0,onKeyDown:l=>{l.key==="Enter"&&r(e.value)},children:[c.jsx("div",{className:"select-list-option-icon",children:e.icon&&j.createElement(e.icon,{width:"20px",height:"20px"})}),c.jsx("div",{className:"select-list-option-label",children:e.label}),!d&&c.jsx("div",{className:"select-list-option-checkbox",children:c.jsx("input",{readOnly:!0,type:"checkbox",tabIndex:-1,checked:s.includes(e.value),className:"form-check-input c-pointer",id:"option.value"})})]},e.value))})})};x.displayName="SelectList";const v=x;export{v as S};
1
+ import{r as n,c,e as o,R as j}from"./index.js";const x=({options:a,hideCheckbox:d,isMonoSelection:u,onChange:i,model:m=[]})=>{const[s,h]=n.useState(m),r=e=>{h(u?[e]:l=>{const t=[...l];return l.includes(e)?t.splice(t.indexOf(e),1):t.push(e),t})};return n.useEffect(()=>{i==null||i(s)},[s]),c.jsx(c.Fragment,{children:c.jsx("div",{className:"select-list",children:a==null?void 0:a.map(e=>c.jsxs("div",{className:o("select-list-option",d&&s.includes(e.value)&&"text-secondary fw-bold"),role:"checkbox","aria-checked":s.includes(e.value),onMouseUp:()=>{r(e.value)},tabIndex:0,onKeyDown:l=>{l.key==="Enter"&&r(e.value)},children:[c.jsx("div",{className:"select-list-option-icon",children:e.icon&&j.createElement(e.icon,{width:"20px",height:"20px"})}),c.jsx("div",{className:"select-list-option-label",children:e.label}),!d&&c.jsx("div",{className:"select-list-option-checkbox",children:c.jsx("input",{readOnly:!0,type:"checkbox",tabIndex:-1,checked:s.includes(e.value),className:"form-check-input c-pointer",id:"option.value"})})]},e.value))})})};x.displayName="SelectList";const v=x;export{v as S};
@@ -1 +1 @@
1
- import{r,f as W,c as C,h as fe,j as e,H as se,i as ye,k as je,v as T,u as ce,l as ve,m as de,n as Se,o as Ne,p as we,q as ae,A as Ie,a as Be,M as G,V as Z,s as oe,B as P,t as ie,w as Ae,x as Ce,F as ee,y as Me,z as Re,C as Ee,L as $e}from"./index.js";import{S as Te}from"./SelectList.js";import{T as Fe}from"./Tooltip.js";import"./usePopper.js";function Ue(l,d){const[n,u]=r.useState(l);return r.useEffect(()=>{const h=setTimeout(()=>{u(l)},d||500);return()=>{clearTimeout(h)}},[l,d]),n}const he=r.forwardRef(({label:l,disabled:d=!1,checked:n=!1,indeterminate:u=!1,...h},S)=>{const b=r.useRef(null);r.useImperativeHandle(S,()=>({...b.current})),r.useEffect(()=>{b.current.indeterminate=u},[b,u]);const y=r.useMemo(()=>h.id?h.id:(Math.floor(Math.random()*999999999999)+1e12).toString(),[h.id]),m={...h,type:"checkbox",checked:n,disabled:d,ref:b,className:W(h.className,"form-check-input c-pointer"),id:y};return C.jsxs("div",{className:"position-relative d-inline-block",children:[C.jsx("input",{...m}),l&&C.jsx("label",{className:"ms-8 form-check-label",htmlFor:m.id,children:l})]})});he.displayName="Checkbox";const ne=he,ue=r.forwardRef(({model:l,icon:d,label:n=!1,disabled:u=!1,...h},S)=>{const b=r.useMemo(()=>h.id?h.id:(Math.floor(Math.random()*999999999999)+1e12).toString(),[h.id]),y={...h,type:"radio",checked:l===h.value,disabled:u,ref:S,className:W(h.className,"form-check-input c-pointer",d&&"d-none"),id:b};return C.jsxs("div",{className:W("position-relative form-check",d&&"ps-0"),children:[C.jsx("input",{...y}),d&&C.jsx("label",{htmlFor:y.id,className:W("c-pointer",l!==h.value&&"text-muted"),children:d}),!d&&n&&C.jsx("label",{className:"form-check-label",htmlFor:y.id,children:n})]})});ue.displayName="Radio";const le=ue;function De({radioPublicationValue:l,onRadioPublicationChange:d}){const{i18n:n}=fe();return e.jsxs(e.Fragment,{children:[e.jsx("hr",{}),e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:n("explorer.publication.steps")}),e.jsx(le,{label:n("explorer.immediat.publication"),id:"publication-now",name:"publication",value:"IMMEDIATE",model:l,onChange:u=>d(u.target.value)}),e.jsx(le,{label:n("explorer.validate.publication"),id:"publication-validate",name:"publication",value:"RESTRAINT",model:l,onChange:u=>d(u.target.value)})]})}function Le({radioPublicationValue:l,onRadioPublicationChange:d}){const{app:n}=ye();return n===je.BLOG?e.jsx(De,{radioPublicationValue:l,onRadioPublicationChange:d}):e.jsx(e.Fragment,{})}const ze=()=>{const[l,d]=r.useState(!1);r.useEffect(()=>{n()},[]);const n=r.useCallback(async()=>{const u=await T.session().isAdml();d(u)},[]);return{isAdml:l}};function Pe({onSuccess:l,payloadUpdatePublishType:d}){const{appCode:n,i18n:u}=ce(),{user:h,avatar:S}=ve(),[b,y]=r.useState(r.useId()),[m,k]=r.useState({rights:[],visibleBookmarks:[],visibleGroups:[],visibleUsers:[]}),[j,N]=r.useState([]),[F,V]=r.useState(""),[w,H]=r.useState(!1),[M,_]=r.useState(""),I=Ue(M,500),[J,K]=r.useState([]),[R,U]=r.useState([]),[D,Q]=r.useState(!1),[E,q]=r.useState(!1),{isAdml:B}=ze(),A=de(),X=Se();r.useEffect(()=>{Y()},[]),r.useEffect(()=>{be(I)},[I]);const Y=r.useCallback(async()=>{var a;const t=await T.share().getActionsForApp(n);N(t);const c=await T.share().getRightsForResource(n,(a=A[0])==null?void 0:a.assetId);k(c)},[]),p=(t,c)=>{k(({rights:a,...g})=>{var te,re;const s=[...a],i=s.findIndex(x=>x.id===t.id),$=j.filter(x=>x.id===c)[0];if(s[i].actions.findIndex(x=>x.id===c)>-1){let x=s[i].actions.filter(f=>f.id!==c);const v=j.filter(f=>{var O;return(O=f.requires)==null?void 0:O.includes(c)});x=x.filter(f=>!v.includes(f)),s[i]={...s[i],actions:x}}else{const x=j.filter(v=>{var f;return((f=$.requires)==null?void 0:f.includes(v.id))&&!s[i].actions.find(O=>O.id===v.id)});s[i]={...s[i],actions:[...s[i].actions,$,...x]}}return t.type==="sharebookmark"&&((te=s[i].users)==null||te.forEach(x=>{const v=s.findIndex(f=>f.id===x.id);s[v]={...s[v],actions:s[i].actions}}),(re=s[i].groups)==null||re.forEach(x=>{const v=s.findIndex(f=>f.id===x.id);s[v]={...s[v],actions:s[i].actions}})),{rights:s,...g}})},L=Ne(),{hotToast:o}=we(Ie),z=async()=>{var t;try{await L.mutate({entId:(t=A[0])==null?void 0:t.assetId,shares:m.rights}),await X.mutate(d),o.success(u("explorer.shared.status.saved")),l==null||l()}catch(c){console.error("Failed to save share",c),o.error(u("explorer.shared.status.error"))}},me=t=>{k(c=>({...c,rights:m.rights.filter(a=>{var g,s;return a.id!==t.id&&!((g=t.users)!=null&&g.find(i=>i.id===a.id))&&!((s=t.groups)!=null&&s.find(i=>i.id===a.id))})}))},pe=t=>{_(t.target.value)},xe=()=>!E&&!B&&I.length>0&&R.length===0||!E&&B&&I.length>3&&R.length===0,ke=()=>B&&M.length<3,ge=()=>E&&M.length>0,be=async t=>{var c;if(q(!0),!B&&t.length>=1||B&&t.length>=3){const a=await T.share().searchShareSubjects(n,(c=A[0])==null?void 0:c.assetId,t);K(a);const g=a.filter(s=>!m.rights.find(i=>i.id===s.id)).filter(s=>!(s.type==="user"&&s.id===A[0].creatorId)).map(s=>({value:s.id,label:s.displayName,icon:s.type==="sharebookmark"?ae:null}));U(g)}else U([]),Promise.resolve();q(!1)};return{currentIsAuthor:()=>{for(const t of A)if(t.creatorId!==(h==null?void 0:h.userId))return!1;return!0},idBookmark:b,myAvatar:S,shareRights:m,shareRightActions:j,showBookmarkInput:w,searchInputValue:M,searchResults:R,bookmarkName:F,showBookmarkMembers:D,debouncedSearchInputValue:I,searchPending:E,setBookmarkName:V,saveBookmark:async t=>{try{const c=await T.directory().saveBookmarks(t,{users:m.rights.filter(a=>a.type==="user").map(a=>a.id),groups:m.rights.filter(a=>a.type==="group").map(a=>a.id),bookmarks:m.rights.filter(a=>a.type==="sharebookmark").map(a=>a.id)});o.success(u("explorer.bookmarked.status.saved")),k(a=>({...a,visibleBookmarks:[...a.visibleBookmarks,{displayName:t,id:c.id}]})),y(b+new Date().getTime().toString()),H(!1)}catch(c){console.error("Failed to save bookmark",c),o.error(u("explorer.bookmarked.status.error"))}},canSave:()=>!0,toggleBookmarkInput:H,handleActionCheckbox:p,handleShare:z,handleDeleteRow:me,handleSearchInputChange:pe,handleSearchResultsChange:async t=>{const c=J.find(g=>g.id===t[0]),a=[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}];if(c){let g=[];if(c.type==="sharebookmark"){const s=await T.directory().getBookMarkById(c.id);g.push({...s,type:"sharebookmark",avatarUrl:"",directoryUrl:"",actions:a}),s==null||s.users.filter(i=>!m.rights.find($=>$.id===i.id)).forEach(i=>{g.push({...i,type:"user",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})}),s.groups.filter(i=>!m.rights.find($=>$.id===i.id)).forEach(i=>{g.push({...i,type:"group",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})})}else g=[{...c,actions:[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}]}];k({...m,rights:[...m.rights,...g]}),U(R.filter(s=>s.value!==t[0]))}},showSearchNoResults:xe,showSearchAdmlHint:ke,showSearchLoading:ge,handleBookmarkMembersToggle:()=>{Q(!D)},hasRight:(t,c)=>t.actions.filter(a=>c.id===a.id).length>0,showShareRightLine:t=>t.isBookmarkMember&&D||!t.isBookmarkMember}}function Ve(){const l=de(),{assetId:d,description:n,thumbnail:u,name:h,public:S,trashed:b,slug:y,"publish-type":m}=l[0],[k,j]=r.useState(m||"IMMEDIATE"),[N,F]=r.useState({description:n,entId:d,name:h,public:!!S,slug:y||"",thumbnail:u,trashed:b,"publish-type":m});return r.useEffect(()=>{k&&F(w=>({...w,"publish-type":k}))},[k]),{radioPublicationValue:k,payloadUpdatePublishType:N,handleRadioPublicationChange:async w=>{j(w)}}}function es({isOpen:l,onSuccess:d,onCancel:n}){const{payloadUpdatePublishType:u,radioPublicationValue:h,handleRadioPublicationChange:S}=Ve(),{myAvatar:b,idBookmark:y,shareRights:m,shareRightActions:k,showBookmarkInput:j,searchResults:N,bookmarkName:F,showBookmarkMembers:V,searchPending:w,currentIsAuthor:H,setBookmarkName:M,saveBookmark:_,canSave:I,toggleBookmarkInput:J,handleActionCheckbox:K,handleShare:R,handleDeleteRow:U,handleSearchInputChange:D,handleSearchResultsChange:Q,showSearchNoResults:E,showSearchAdmlHint:q,showSearchLoading:B,handleBookmarkMembersToggle:A,hasRight:X,showShareRightLine:Y}=Pe({payloadUpdatePublishType:u,onSuccess:d,onCancel:n}),{i18n:p}=ce(),L=r.useRef(null);return Be.createPortal(e.jsxs(G,{id:"share_modal",size:"lg",isOpen:l,onModalClose:n,children:[e.jsx(G.Header,{onModalClose:n,children:p("share.title")}),e.jsxs(G.Body,{children:[e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:p("explorer.modal.share.usersWithAccess")}),e.jsx("div",{className:"table-responsive",children:e.jsxs("table",{className:"table border align-middle mb-0",children:[e.jsx("thead",{className:"bg-secondary text-white",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"w-32",children:e.jsx(Z,{children:p("explorer.modal.share.avatar.shared.alt")})}),e.jsx("th",{scope:"col",children:e.jsx(Z,{children:p("explorer.modal.share.search.placeholder")})}),k.map(o=>e.jsx("th",{scope:"col",className:"text-center",children:p(o.displayName)},o.displayName)),e.jsx("th",{scope:"col",children:e.jsx(Z,{children:p("close")})})]})}),e.jsxs("tbody",{children:[H()&&e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:e.jsx(oe,{alt:p("explorer.modal.share.avatar.me.alt"),size:"xs",src:b,variant:"circle"})}),e.jsx("td",{children:p("share.me")}),k.map(o=>e.jsx("td",{style:{width:"80px"},className:"text-center",children:e.jsx(ne,{checked:!0,disabled:!0})},o.displayName)),e.jsx("td",{})]}),m==null?void 0:m.rights.map(o=>Y(o)&&e.jsxs("tr",{className:o.isBookmarkMember?"bg-light":"",children:[e.jsxs("td",{children:[o.type!=="sharebookmark"&&e.jsx(oe,{alt:p("explorer.modal.share.avatar.shared.alt"),size:"xs",src:o.avatarUrl,variant:"circle"}),o.type==="sharebookmark"&&e.jsx(ae,{})]}),e.jsx("td",{children:e.jsxs("div",{className:"d-flex",children:[o.type==="sharebookmark"&&e.jsx(P,{color:"tertiary",rightIcon:e.jsx(ie,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:V?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal ps-0",onClick:A,children:o.displayName}),o.type!=="sharebookmark"&&o.displayName]})}),k.map(z=>e.jsx("td",{style:{width:"80px"},className:"text-center",children:e.jsx(ne,{checked:X(o,z),onChange:()=>K(o,z.id)})},z.displayName)),e.jsx("td",{children:!o.isBookmarkMember&&e.jsx(Ae,{"aria-label":"Delete",color:"tertiary",icon:e.jsx(Ce,{}),type:"button",variant:"ghost",title:"Delete",onClick:()=>U(o)})})]},o.id))]})]})}),e.jsxs("div",{className:"mt-16",children:[e.jsx(P,{color:"tertiary",leftIcon:e.jsx(ae,{}),rightIcon:e.jsx(ie,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:j?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal",onClick:()=>J(!j),children:p("share.save.sharebookmark")}),j&&e.jsx("div",{className:"mt-16",children:e.jsxs(ee,{id:"bookmarkName",className:"d-flex flex-wrap align-items-center gap-16",children:[e.jsx("div",{className:"flex-fill",children:e.jsx(ee.Input,{ref:L,onChange:()=>{M(()=>{var o;return((o=L.current)==null?void 0:o.value)||""})},placeholder:p("explorer.modal.share.sharebookmark.placeholder"),size:"sm",type:"text"},y)}),e.jsx(P,{type:"button",color:"primary",variant:"ghost",disabled:F.length===0,leftIcon:e.jsx(Me,{}),onClick:()=>{_(L.current.value)},className:"text-nowrap",children:p("explorer.modal.share.sharebookmark.save")})]})})]}),e.jsx("hr",{}),e.jsxs(se,{headingStyle:"h4",level:"h3",className:"mb-16 d-flex align-items-center",children:[p("explorer.modal.share.search"),e.jsx(Fe,{message:"Vos favoris de partage s’affichent en priorité dans votre liste lorsque vous recherchez un groupe ou une personne, vous pouvez les retrouver dans l’annuaire.",placement:"top",children:e.jsx(Re,{className:"ms-8 c-pointer",height:"18"})})]}),e.jsxs(ee,{className:"d-flex align-items-center",id:"search",children:[e.jsx(Ee,{className:"max-w-512",noValidationIcon:!0,placeholder:q()?p("explorer.search.adml.hint"):p("explorer.modal.share.search.placeholder"),size:"md",type:"search",onChange:D}),B()&&e.jsxs("div",{className:"d-flex align-items-center p-4",children:[e.jsx($e,{isLoading:w}),e.jsx("span",{className:"ps-4",children:p("explorer.search.pending")})]}),E()&&e.jsx("div",{className:"p-4",children:p("portal.no.result")})]}),(N==null?void 0:N.length)>0&&e.jsx("div",{className:"position-absolute w-100 max-w-512 z-1 bg-white shadow rounded-4 d-block show py-12 px-8",children:e.jsx(Te,{options:N,hideCheckbox:!0,isMonoSelection:!0,onChange:Q})}),e.jsx(Le,{radioPublicationValue:h,onRadioPublicationChange:S})]}),e.jsxs(G.Footer,{children:[e.jsx(P,{type:"button",color:"tertiary",variant:"ghost",onClick:n,children:p("explorer.cancel")}),e.jsx(P,{type:"button",color:"primary",variant:"filled",onClick:R,disabled:!I(),children:p("share")})]})]}),document.getElementById("portal"))}export{es as default};
1
+ import{r,o as T,e as W,c as C,f as fe,j as e,H as se,h as ye,A as je,u as ce,i as ve,k as de,l as Se,m as Ne,n as we,p as ae,q as Ie,a as Be,M as G,V as Z,s as oe,B as z,t as ie,v as Ae,w as Ce,F as ee,x as Me,y as Re,z as Ee,L as $e}from"./index.js";import{S as Te}from"./SelectList.js";import{T as Fe}from"./Tooltip.js";import"./usePopper.js";function Ue(l,d){const[n,u]=r.useState(l);return r.useEffect(()=>{const h=setTimeout(()=>{u(l)},d||500);return()=>{clearTimeout(h)}},[l,d]),n}function De(){const[l,d]=r.useState(!1);r.useEffect(()=>{n()},[]);const n=r.useCallback(async()=>{const u=await T.session().isAdml();d(u)},[]);return{isAdml:l}}const he=r.forwardRef(({label:l,disabled:d=!1,checked:n=!1,indeterminate:u=!1,...h},S)=>{const b=r.useRef(null);r.useImperativeHandle(S,()=>({...b.current})),r.useEffect(()=>{b.current.indeterminate=u},[b,u]);const y=r.useMemo(()=>h.id?h.id:(Math.floor(Math.random()*999999999999)+1e12).toString(),[h.id]),m={...h,type:"checkbox",checked:n,disabled:d,ref:b,className:W(h.className,"form-check-input c-pointer"),id:y};return C.jsxs("div",{className:"position-relative d-inline-block",children:[C.jsx("input",{...m}),l&&C.jsx("label",{className:"ms-8 form-check-label",htmlFor:m.id,children:l})]})});he.displayName="Checkbox";const ne=he,ue=r.forwardRef(({model:l,icon:d,label:n=!1,disabled:u=!1,...h},S)=>{const b=r.useMemo(()=>h.id?h.id:(Math.floor(Math.random()*999999999999)+1e12).toString(),[h.id]),y={...h,type:"radio",checked:l===h.value,disabled:u,ref:S,className:W(h.className,"form-check-input c-pointer",d&&"d-none"),id:b};return C.jsxs("div",{className:W("position-relative form-check",d&&"ps-0"),children:[C.jsx("input",{...y}),d&&C.jsx("label",{htmlFor:y.id,className:W("c-pointer",l!==h.value&&"text-muted"),children:d}),!d&&n&&C.jsx("label",{className:"form-check-label",htmlFor:y.id,children:n})]})});ue.displayName="Radio";const le=ue;function Pe({radioPublicationValue:l,onRadioPublicationChange:d}){const{i18n:n}=fe();return e.jsxs(e.Fragment,{children:[e.jsx("hr",{}),e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:n("explorer.publication.steps")}),e.jsx(le,{label:n("explorer.immediat.publication"),id:"publication-now",name:"publication",value:"IMMEDIATE",model:l,onChange:u=>d(u.target.value)}),e.jsx(le,{label:n("explorer.validate.publication"),id:"publication-validate",name:"publication",value:"RESTRAINT",model:l,onChange:u=>d(u.target.value)})]})}function Le({radioPublicationValue:l,onRadioPublicationChange:d}){const{app:n}=ye();return n===je.BLOG?e.jsx(Pe,{radioPublicationValue:l,onRadioPublicationChange:d}):e.jsx(e.Fragment,{})}function ze({onSuccess:l,payloadUpdatePublishType:d}){const{appCode:n,i18n:u}=ce(),{user:h,avatar:S}=ve(),[b,y]=r.useState(r.useId()),[m,k]=r.useState({rights:[],visibleBookmarks:[],visibleGroups:[],visibleUsers:[]}),[j,N]=r.useState([]),[F,V]=r.useState(""),[w,H]=r.useState(!1),[M,_]=r.useState(""),I=Ue(M,500),[J,K]=r.useState([]),[R,U]=r.useState([]),[D,Q]=r.useState(!1),[E,q]=r.useState(!1),{isAdml:B}=De(),A=de(),X=Se();r.useEffect(()=>{Y()},[]),r.useEffect(()=>{be(I)},[I]);const Y=r.useCallback(async()=>{var a;const t=await T.share().getActionsForApp(n);N(t);const c=await T.share().getRightsForResource(n,(a=A[0])==null?void 0:a.assetId);k(c)},[]),p=(t,c)=>{k(({rights:a,...g})=>{var te,re;const s=[...a],i=s.findIndex(x=>x.id===t.id),$=j.filter(x=>x.id===c)[0];if(s[i].actions.findIndex(x=>x.id===c)>-1){let x=s[i].actions.filter(f=>f.id!==c);const v=j.filter(f=>{var O;return(O=f.requires)==null?void 0:O.includes(c)});x=x.filter(f=>!v.includes(f)),s[i]={...s[i],actions:x}}else{const x=j.filter(v=>{var f;return((f=$.requires)==null?void 0:f.includes(v.id))&&!s[i].actions.find(O=>O.id===v.id)});s[i]={...s[i],actions:[...s[i].actions,$,...x]}}return t.type==="sharebookmark"&&((te=s[i].users)==null||te.forEach(x=>{const v=s.findIndex(f=>f.id===x.id);s[v]={...s[v],actions:s[i].actions}}),(re=s[i].groups)==null||re.forEach(x=>{const v=s.findIndex(f=>f.id===x.id);s[v]={...s[v],actions:s[i].actions}})),{rights:s,...g}})},P=Ne(),{hotToast:o}=we(Ie),L=async()=>{var t;try{await P.mutate({entId:(t=A[0])==null?void 0:t.assetId,shares:m.rights}),await X.mutate(d),o.success(u("explorer.shared.status.saved")),l==null||l()}catch(c){console.error("Failed to save share",c),o.error(u("explorer.shared.status.error"))}},me=t=>{k(c=>({...c,rights:m.rights.filter(a=>{var g,s;return a.id!==t.id&&!((g=t.users)!=null&&g.find(i=>i.id===a.id))&&!((s=t.groups)!=null&&s.find(i=>i.id===a.id))})}))},pe=t=>{_(t.target.value)},xe=()=>!E&&!B&&I.length>0&&R.length===0||!E&&B&&I.length>3&&R.length===0,ke=()=>B&&M.length<3,ge=()=>E&&M.length>0,be=async t=>{var c;if(q(!0),!B&&t.length>=1||B&&t.length>=3){const a=await T.share().searchShareSubjects(n,(c=A[0])==null?void 0:c.assetId,t);K(a);const g=a.filter(s=>!m.rights.find(i=>i.id===s.id)).filter(s=>!(s.type==="user"&&s.id===A[0].creatorId)).map(s=>({value:s.id,label:s.displayName,icon:s.type==="sharebookmark"?ae:null}));U(g)}else U([]),Promise.resolve();q(!1)};return{currentIsAuthor:()=>{for(const t of A)if(t.creatorId!==(h==null?void 0:h.userId))return!1;return!0},idBookmark:b,myAvatar:S,shareRights:m,shareRightActions:j,showBookmarkInput:w,searchInputValue:M,searchResults:R,bookmarkName:F,showBookmarkMembers:D,debouncedSearchInputValue:I,searchPending:E,setBookmarkName:V,saveBookmark:async t=>{try{const c=await T.directory().saveBookmarks(t,{users:m.rights.filter(a=>a.type==="user").map(a=>a.id),groups:m.rights.filter(a=>a.type==="group").map(a=>a.id),bookmarks:m.rights.filter(a=>a.type==="sharebookmark").map(a=>a.id)});o.success(u("explorer.bookmarked.status.saved")),k(a=>({...a,visibleBookmarks:[...a.visibleBookmarks,{displayName:t,id:c.id}]})),y(b+new Date().getTime().toString()),H(!1)}catch(c){console.error("Failed to save bookmark",c),o.error(u("explorer.bookmarked.status.error"))}},canSave:()=>!0,toggleBookmarkInput:H,handleActionCheckbox:p,handleShare:L,handleDeleteRow:me,handleSearchInputChange:pe,handleSearchResultsChange:async t=>{const c=J.find(g=>g.id===t[0]),a=[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}];if(c){let g=[];if(c.type==="sharebookmark"){const s=await T.directory().getBookMarkById(c.id);g.push({...s,type:"sharebookmark",avatarUrl:"",directoryUrl:"",actions:a}),s==null||s.users.filter(i=>!m.rights.find($=>$.id===i.id)).forEach(i=>{g.push({...i,type:"user",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})}),s.groups.filter(i=>!m.rights.find($=>$.id===i.id)).forEach(i=>{g.push({...i,type:"group",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})})}else g=[{...c,actions:[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}]}];k({...m,rights:[...m.rights,...g]}),U(R.filter(s=>s.value!==t[0]))}},showSearchNoResults:xe,showSearchAdmlHint:ke,showSearchLoading:ge,handleBookmarkMembersToggle:()=>{Q(!D)},hasRight:(t,c)=>t.actions.filter(a=>c.id===a.id).length>0,showShareRightLine:t=>t.isBookmarkMember&&D||!t.isBookmarkMember}}function Ve(){const l=de(),{assetId:d,description:n,thumbnail:u,name:h,public:S,trashed:b,slug:y,"publish-type":m}=l[0],[k,j]=r.useState(m||"IMMEDIATE"),[N,F]=r.useState({description:n,entId:d,name:h,public:!!S,slug:y||"",thumbnail:u,trashed:b,"publish-type":m});return r.useEffect(()=>{k&&F(w=>({...w,"publish-type":k}))},[k]),{radioPublicationValue:k,payloadUpdatePublishType:N,handleRadioPublicationChange:async w=>{j(w)}}}function es({isOpen:l,onSuccess:d,onCancel:n}){const{payloadUpdatePublishType:u,radioPublicationValue:h,handleRadioPublicationChange:S}=Ve(),{myAvatar:b,idBookmark:y,shareRights:m,shareRightActions:k,showBookmarkInput:j,searchResults:N,bookmarkName:F,showBookmarkMembers:V,searchPending:w,currentIsAuthor:H,setBookmarkName:M,saveBookmark:_,canSave:I,toggleBookmarkInput:J,handleActionCheckbox:K,handleShare:R,handleDeleteRow:U,handleSearchInputChange:D,handleSearchResultsChange:Q,showSearchNoResults:E,showSearchAdmlHint:q,showSearchLoading:B,handleBookmarkMembersToggle:A,hasRight:X,showShareRightLine:Y}=ze({payloadUpdatePublishType:u,onSuccess:d,onCancel:n}),{i18n:p}=ce(),P=r.useRef(null);return Be.createPortal(e.jsxs(G,{id:"share_modal",size:"lg",isOpen:l,onModalClose:n,children:[e.jsx(G.Header,{onModalClose:n,children:p("share.title")}),e.jsxs(G.Body,{children:[e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:p("explorer.modal.share.usersWithAccess")}),e.jsx("div",{className:"table-responsive",children:e.jsxs("table",{className:"table border align-middle mb-0",children:[e.jsx("thead",{className:"bg-secondary text-white",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"w-32",children:e.jsx(Z,{children:p("explorer.modal.share.avatar.shared.alt")})}),e.jsx("th",{scope:"col",children:e.jsx(Z,{children:p("explorer.modal.share.search.placeholder")})}),k.map(o=>e.jsx("th",{scope:"col",className:"text-center",children:p(o.displayName)},o.displayName)),e.jsx("th",{scope:"col",children:e.jsx(Z,{children:p("close")})})]})}),e.jsxs("tbody",{children:[H()&&e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:e.jsx(oe,{alt:p("explorer.modal.share.avatar.me.alt"),size:"xs",src:b,variant:"circle"})}),e.jsx("td",{children:p("share.me")}),k.map(o=>e.jsx("td",{style:{width:"80px"},className:"text-center",children:e.jsx(ne,{checked:!0,disabled:!0})},o.displayName)),e.jsx("td",{})]}),m==null?void 0:m.rights.map(o=>Y(o)&&e.jsxs("tr",{className:o.isBookmarkMember?"bg-light":"",children:[e.jsxs("td",{children:[o.type!=="sharebookmark"&&e.jsx(oe,{alt:p("explorer.modal.share.avatar.shared.alt"),size:"xs",src:o.avatarUrl,variant:"circle"}),o.type==="sharebookmark"&&e.jsx(ae,{})]}),e.jsx("td",{children:e.jsxs("div",{className:"d-flex",children:[o.type==="sharebookmark"&&e.jsx(z,{color:"tertiary",rightIcon:e.jsx(ie,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:V?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal ps-0",onClick:A,children:o.displayName}),o.type!=="sharebookmark"&&o.displayName]})}),k.map(L=>e.jsx("td",{style:{width:"80px"},className:"text-center",children:e.jsx(ne,{checked:X(o,L),onChange:()=>K(o,L.id)})},L.displayName)),e.jsx("td",{children:!o.isBookmarkMember&&e.jsx(Ae,{"aria-label":"Delete",color:"tertiary",icon:e.jsx(Ce,{}),type:"button",variant:"ghost",title:"Delete",onClick:()=>U(o)})})]},o.id))]})]})}),e.jsxs("div",{className:"mt-16",children:[e.jsx(z,{color:"tertiary",leftIcon:e.jsx(ae,{}),rightIcon:e.jsx(ie,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:j?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal",onClick:()=>J(!j),children:p("share.save.sharebookmark")}),j&&e.jsx("div",{className:"mt-16",children:e.jsxs(ee,{id:"bookmarkName",className:"d-flex flex-wrap align-items-center gap-16",children:[e.jsx("div",{className:"flex-fill",children:e.jsx(ee.Input,{ref:P,onChange:()=>{M(()=>{var o;return((o=P.current)==null?void 0:o.value)||""})},placeholder:p("explorer.modal.share.sharebookmark.placeholder"),size:"sm",type:"text"},y)}),e.jsx(z,{type:"button",color:"primary",variant:"ghost",disabled:F.length===0,leftIcon:e.jsx(Me,{}),onClick:()=>{_(P.current.value)},className:"text-nowrap",children:p("explorer.modal.share.sharebookmark.save")})]})})]}),e.jsx("hr",{}),e.jsxs(se,{headingStyle:"h4",level:"h3",className:"mb-16 d-flex align-items-center",children:[p("explorer.modal.share.search"),e.jsx(Fe,{message:"Vos favoris de partage s’affichent en priorité dans votre liste lorsque vous recherchez un groupe ou une personne, vous pouvez les retrouver dans l’annuaire.",placement:"top",children:e.jsx(Re,{className:"ms-8 c-pointer",height:"18"})})]}),e.jsxs(ee,{className:"d-flex align-items-center",id:"search",children:[e.jsx(Ee,{className:"max-w-512",noValidationIcon:!0,placeholder:q()?p("explorer.search.adml.hint"):p("explorer.modal.share.search.placeholder"),size:"md",type:"search",onChange:D}),B()&&e.jsxs("div",{className:"d-flex align-items-center p-4",children:[e.jsx($e,{isLoading:w}),e.jsx("span",{className:"ps-4",children:p("explorer.search.pending")})]}),E()&&e.jsx("div",{className:"p-4",children:p("portal.no.result")})]}),(N==null?void 0:N.length)>0&&e.jsx("div",{className:"position-absolute w-100 max-w-512 z-1 bg-white shadow rounded-4 d-block show py-12 px-8",children:e.jsx(Te,{options:N,hideCheckbox:!0,isMonoSelection:!0,onChange:Q})}),e.jsx(Le,{radioPublicationValue:h,onRadioPublicationChange:S})]}),e.jsxs(G.Footer,{children:[e.jsx(z,{type:"button",color:"tertiary",variant:"ghost",onClick:n,children:p("explorer.cancel")}),e.jsx(z,{type:"button",color:"primary",variant:"filled",onClick:R,disabled:!I(),children:p("share")})]})]}),document.getElementById("portal"))}export{es as default};
package/dist/Tooltip.js CHANGED
@@ -1 +1 @@
1
- import{r as t,c as e,f as v}from"./index.js";import{u as E}from"./usePopper.js";const h=({children:l,message:i,icon:s=null,placement:n="auto"})=>{const[a,p]=t.useState(null),[m,c]=t.useState(null),[u,d]=t.useState(null),{styles:o,attributes:x}=E(a,m,{placement:n,modifiers:[{name:"arrow",options:{element:u}}]}),[f,r]=t.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"d-inline-block position-relative z-2",ref:p,onMouseEnter:()=>{r(!0)},onMouseLeave:()=>{r(!1)},children:l}),f&&e.jsxs("div",{className:v("tooltip d-block show","bs-tooltip-auto"),ref:c,style:o.popper,...x.popper,children:[e.jsxs("div",{className:"tooltip-inner shadow-hover d-flex gap-8 align-items-center",children:[s&&s,e.jsx("div",{children:i})]}),e.jsx("div",{className:"tooltip-arrow",ref:d,style:o.arrow})]})]})},b=h;export{b as T};
1
+ import{r as t,c as e,e as v}from"./index.js";import{u as E}from"./usePopper.js";const h=({children:l,message:i,icon:s=null,placement:n="auto"})=>{const[a,p]=t.useState(null),[m,c]=t.useState(null),[u,d]=t.useState(null),{styles:o,attributes:x}=E(a,m,{placement:n,modifiers:[{name:"arrow",options:{element:u}}]}),[f,r]=t.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"d-inline-block position-relative z-2",ref:p,onMouseEnter:()=>{r(!0)},onMouseLeave:()=>{r(!1)},children:l}),f&&e.jsxs("div",{className:v("tooltip d-block show","bs-tooltip-auto"),ref:c,style:o.popper,...x.popper,children:[e.jsxs("div",{className:"tooltip-inner shadow-hover d-flex gap-8 align-items-center",children:[s&&s,e.jsx("div",{children:i})]}),e.jsx("div",{className:"tooltip-arrow",ref:d,style:o.arrow})]})]})},b=h;export{b as T};
@@ -1 +1 @@
1
- import{u as h,e as x,b as m,a as p,j as e,M as r,B as a}from"./index.js";function y({isOpen:l,onCancel:s=()=>({})}){const{i18n:o}=h(),{onRestore:n,actions:t}=x(),{setResourceIsTrash:i}=m();async function c(){await n(),i(!1)}const d=t==null?void 0:t.some(u=>u.id==="restore");return p.createPortal(e.jsxs(r,{isOpen:l,onModalClose:s,id:"trash_resource",children:[e.jsx(r.Header,{onModalClose:()=>s(),children:o("explorer.trash.modal.title")}),e.jsx(r.Body,{children:e.jsx("p",{className:"body",children:o("explorer.trash.modal.text")})}),e.jsxs(r.Footer,{children:[e.jsx(a,{color:"primary",onClick:s,type:"button",variant:"outline",children:o("close")}),d&&e.jsx(a,{color:"primary",onClick:async()=>await c(),type:"button",variant:"filled",children:o("restore")})]})]}),document.getElementById("portal"))}export{y as default};
1
+ import{u as a,a as l,j as e,M as o,B as d}from"./index.js";function i({isOpen:s,onCancel:r=()=>({})}){const{i18n:t}=a();return l.createPortal(e.jsxs(o,{isOpen:s,onModalClose:r,id:"trash_resource",children:[e.jsx(o.Header,{onModalClose:()=>r(),children:t("explorer.trash.modal.title")}),e.jsx(o.Body,{children:e.jsx("p",{className:"body",children:t("explorer.trash.modal.text")})}),e.jsx(o.Footer,{children:e.jsx(d,{color:"primary",onClick:r,type:"button",variant:"outline",children:t("close")})})]}),document.getElementById("portal"))}export{i as default};
package/dist/index.html CHANGED
@@ -97,12 +97,14 @@
97
97
  available: true,
98
98
  target: "actionbar",
99
99
  workflow: "",
100
+ right: "manager",
100
101
  },
101
102
  {
102
103
  id: "delete",
103
104
  available: true,
104
105
  target: "actionbar",
105
106
  workflow: "",
107
+ right: "manager",
106
108
  },
107
109
  ],
108
110
  };