jamespot-react-components 1.0.208 → 1.0.209

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.
@@ -582,7 +582,7 @@
582
582
  `,JI=Bx.div`
583
583
  display: flex;
584
584
  gap: ${({theme:e})=>e.space.xs}px;
585
- `,KI=({accounts:e,activeAccount:t,onLogout:n,onLogin:r,onSetDefaultAccount:o,requests:i,isLogged:a,onLoginError:l})=>{const s=bl(),c=Lx(),[u,d]=(0,_.useState)(!1),p=(0,_.useCallback)((()=>{t&&(d(!0),i.logout({id:t.id,service:WT}).then((()=>{d(!1),n()})))}),[t,n,i]),f=(0,_.useCallback)((()=>{const e=window.open("/?action=drive_connect&name="+WT,"","menubar=no,status=no,scrollbars=no,menubar=no,width=500,height=700"),t=setInterval((()=>{var n,o;const a=null===(n=null==e?void 0:e.document.body.querySelector("div"))||void 0===n?void 0:n.getAttribute("data-drive-account-id"),c="true"===(null===(o=null==e?void 0:e.document.body.querySelector("div"))||void 0===o?void 0:o.getAttribute("data-drive-is-personal"));e&&a&&(c?l(s.formatMessage({id:"DRIVE_MS_Error_Personal_Account"})):i.getAccount({service:WT,id:a}).then((e=>{r(e.result.account)})),clearInterval(t),e.close())}),1e3);return()=>clearInterval(t)}),[s,r,l,i]),m=(0,_.useCallback)((e=>{i.setDefaultAccount&&(d(!0),i.setDefaultAccount({account:e.id,service:WT}).then((()=>{d(!1),o(e)})))}),[o,i]);return _.createElement(GI,null,_.createElement(WI,null,_.createElement(qI,null,t&&e?_.createElement(_.Fragment,null,_.createElement("div",null,_.createElement(YI,null,_.createElement(VR,null,t.title),t.default&&_.createElement(VR,{size:"s",color:"grey4"},"(",s.formatMessage({id:"DRIVE_MS_Default"}),")")),_.createElement(VR,{size:"s"},t.mail)),u?_.createElement("div",null,_.createElement(gE,null)):_.createElement(JI,null,!a&&_.createElement($R,{label:s.formatMessage({id:"GLOBAL_Login"}),onClick:f}),_.createElement(gI,{variant:"outlined",color:"cancel",options:[...t.default?[]:[{icon:{name:"icon-check",color:c.color.grey4},label:s.formatMessage({id:"DRIVE_MS_Set_Default_Account"}),onClick:()=>m(t)}],...e.filter((e=>e.id!==t.id)).map((e=>({icon:{name:"icon-arrows-rotate",color:c.color.grey4},label:e.mail,onClick:()=>r(e)}))),{icon:{name:"icon-times",color:c.color.grey4},label:s.formatMessage({id:"DRIVE_MS_Logout"}),onClick:p},{icon:{name:"icon-plus",color:c.color.grey4},label:s.formatMessage({id:"DRIVE_MS_Other_Account"}),onClick:f}],label:s.formatMessage({id:"DRIVE_MS_Accounts"}),icon:"icon-gear",small:!0,smallOpenDirection:"left"}))):_.createElement(_.Fragment,null,_.createElement(VR,null,s.formatMessage({id:"DRIVE_MS_Need_Login"})),_.createElement($R,{label:s.formatMessage({id:"GLOBAL_Login"}),onClick:f})))))},ZI={msTenant:void 0,msId:void 0,idFolder:"root",page:1,limit:20},XI=({initialParams:e,initialFolder:t,initialFolderColor:n,useDocumentFilters:r=[],useFilter:o=!0,useNavigation:i=!0,onSelect:a,onSelectDocument:l,onSelectMultiDocument:s,onError:c,driveRequests:u,handleLogin:d,onLogin:p})=>{const f=bl(),[m,h]=(0,_.useState)([]),[g,v]=(0,_.useState)(),[y,b]=(0,_.useState)(),[w,x]=(0,_.useState)(),[E,C]=(0,_.useState)([]),[S,k]=(0,_.useState)(),[A,O]=(0,_.useState)(),[R,T]=(0,_.useState)(!1),[I,j]=(0,_.useState)(!0);(0,_.useEffect)((()=>{const t=void 0===e?Object.assign({},ZI):Object.assign({},e);m.forEach((e=>{switch(e.name){case"groups":t.msTenant="groups";break;case"group":t.msId=e.id,t.idFolder="root";break;case"documents":t.idFolder=e.id;break;case"me":t.msTenant="me",t.idFolder="root"}})),b(t)}),[m,e]),(0,_.useEffect)((()=>{s&&y&&s(E,y)}),[E,y,s]),(0,_.useEffect)((()=>{void 0!==e&&b(e)}),[e]),(0,_.useEffect)((()=>{void 0!==t&&h([{name:"group"===t.type?"group":"documents",title:t.title,id:t.id}])}),[t]),(0,_.useEffect)((()=>{v(m.at(-1))}),[m]);const{listAccount:P,checkAccountToken:D,isAccountLogged:L}=u,M=(0,_.useCallback)((e=>{P&&D&&L&&(j(!0),T(!1),h([]),C([]),d&&u&&P(WT).then((t=>{var n;if(O(t.result),t.result.length>0){const r=null!==(n=e?t.result.find((t=>t.id===e.id)):t.result.find((e=>e.default)))&&void 0!==n?n:t.result[0];k(r),D(WT).then((e=>{e.result?L(WT,r.id).then((e=>{e.result&&(T(e.result),p&&p(r))})).catch((()=>T(!1))).finally((()=>{j(!1)})):(T(!1),j(!1))}))}else k(void 0),T(!1),j(!1)})).catch((e=>{c&&c(e.errorMsg)})))}),[D,u,d,L,P,c,p]),B=(0,_.useCallback)((e=>{j(!1),c&&c(e)}),[c]);return(0,_.useEffect)((()=>{M()}),[M]),d&&I?_.createElement(gE,{size:"l"}):_.createElement($I,null,d&&u.logout&&u.getAccount&&u.setDefaultAccount&&_.createElement(KI,{activeAccount:S,accounts:A,onLogout:M,onLogin:M,isLogged:R,onSetDefaultAccount:e=>{k((e=>e?Object.assign(Object.assign({},e),{default:!0}):e)),O((t=>t?t.map((t=>t.id===e.id?Object.assign(Object.assign({},t),{default:!0}):Object.assign(Object.assign({},t),{default:!1}))):t))},requests:{logout:u.logout,getAccount:u.getAccount,setDefaultAccount:u.setDefaultAccount},onLoginError:B}),(!d||R)&&S&&_.createElement(_.Fragment,null,_.createElement(FI,null,i&&m.length>0?_.createElement(NI,{onClick:()=>h([])},_.createElement("div",null,f.formatMessage({id:"DRIVE_Root"})),_.createElement(nE,{name:"icon-angle-right",size:12})):_.createElement(_.Fragment,null),m.map(((e,t)=>_.createElement(NI,{key:t,onClick:()=>h((e=>e.filter(((e,n)=>n<=t))))},e.title,t<m.length-1&&_.createElement(nE,{name:"icon-angle-right",size:12}))))),void 0===g?_.createElement(LI,{id:S.id,initialFolderColor:n,onClick:e=>{var t;h([...m,{name:null!==(t=e.name)&&void 0!==t?t:"groups",title:e.title,id:void 0}])},request:u.tenants}):_.createElement(_.Fragment,null),"groups"===(null==g?void 0:g.name)&&y?_.createElement(PI,{id:S.id,initialFolderColor:n,useFilter:o,onSelect:"function"==typeof a?e=>{a(e,Object.assign(Object.assign({},y),{msId:e.id,idFolder:"root"}))}:void 0,useNavigation:i,onClick:e=>{x(e),h([...m,{name:"group",title:e.title,id:e.id}])},onError:c,driveRequests:{groups:u.groups}}):_.createElement(_.Fragment,null),"group"!==(null==g?void 0:g.name)&&"documents"!==(null==g?void 0:g.name)&&"me"!==(null==g?void 0:g.name)||void 0===y?_.createElement(_.Fragment,null):_.createElement(BI,{initialFolderColor:n,useFilter:o,useNavigation:i,driveDocumentParams:y,useDocumentFilters:r,onSelect:"function"==typeof a?e=>{a(e,Object.assign(Object.assign({},y),{idFolder:e.id}))}:void 0,onSelectMultiDocument:s?e=>{const t=E.find((t=>t.id===e.id));C(t?E.filter((t=>t.id!==e.id)):[...E,e])}:void 0,onSelectDocument:l?e=>{l&&y&&l(e,w,y)}:void 0,onClick:e=>{x(e),h([...m,{name:"documents",title:e.title,id:e.id}])},onError:c,driveRequests:{documents:u.documents},id:S.id})))},QI=fx`
585
+ `,KI=({accounts:e,activeAccount:t,onLogout:n,onLogin:r,onSetDefaultAccount:o,requests:i,isLogged:a,onLoginError:l})=>{const s=bl(),c=Lx(),[u,d]=(0,_.useState)(!1),p=(0,_.useCallback)((()=>{t&&(d(!0),i.logout({id:t.id,service:WT}).then((()=>{d(!1),n()})))}),[t,n,i]),f=(0,_.useCallback)((()=>{const e=window.open("/?action=drive_connect&name="+WT,"","menubar=no,status=no,scrollbars=no,menubar=no,width=500,height=700"),t=setInterval((()=>{var n,o;const a=null===(n=null==e?void 0:e.document.body.querySelector("div"))||void 0===n?void 0:n.getAttribute("data-drive-account-id"),c="true"===(null===(o=null==e?void 0:e.document.body.querySelector("div"))||void 0===o?void 0:o.getAttribute("data-drive-is-personal"));e&&a&&(c?l(s.formatMessage({id:"DRIVE_MS_Error_Personal_Account"})):i.getAccount({service:WT,id:a}).then((e=>{r(e.result.account)})),clearInterval(t),e.close())}),1e3);return()=>clearInterval(t)}),[s,r,l,i]),m=(0,_.useCallback)((e=>{i.setDefaultAccount&&(d(!0),i.setDefaultAccount({account:e.id,service:WT}).then((()=>{d(!1),o(e)})))}),[o,i]);return _.createElement(GI,null,_.createElement(WI,null,_.createElement(qI,null,t&&e?_.createElement(_.Fragment,null,_.createElement("div",null,_.createElement(YI,null,_.createElement(VR,null,t.title),t.default&&_.createElement(VR,{size:"s",color:"grey4"},"(",s.formatMessage({id:"DRIVE_MS_Default"}),")")),_.createElement(VR,{size:"s"},t.mail)),u?_.createElement("div",null,_.createElement(gE,null)):_.createElement(JI,null,!a&&_.createElement($R,{label:s.formatMessage({id:"GLOBAL_Login"}),onClick:f}),_.createElement(gI,{variant:"outlined",color:"cancel",options:[...t.default?[]:[{icon:{name:"icon-check",color:c.color.grey4},label:s.formatMessage({id:"DRIVE_MS_Set_Default_Account"}),onClick:()=>m(t)}],...e.filter((e=>e.id!==t.id)).map((e=>({icon:{name:"icon-arrows-rotate",color:c.color.grey4},label:e.mail,onClick:()=>r(e)}))),{icon:{name:"icon-times",color:c.color.grey4},label:s.formatMessage({id:"DRIVE_MS_Logout"}),onClick:p},{icon:{name:"icon-plus",color:c.color.grey4},label:s.formatMessage({id:"DRIVE_MS_Other_Account"}),onClick:f}],label:s.formatMessage({id:"DRIVE_MS_Accounts"}),icon:"icon-gear",small:!0,smallOpenDirection:"left"}))):_.createElement(_.Fragment,null,_.createElement(VR,null,s.formatMessage({id:"DRIVE_MS_Need_Login"})),_.createElement($R,{label:s.formatMessage({id:"GLOBAL_Login"}),onClick:f})))))},ZI={msTenant:void 0,msId:void 0,idFolder:"root",page:1,limit:20},XI=({initialParams:e,initialFolder:t,initialFolderColor:n,useDocumentFilters:r=[],useFilter:o=!0,useNavigation:i=!0,onSelect:a,onSelectDocument:l,onSelectMultiDocument:s,onError:c,driveRequests:u,handleLogin:d,onLogin:p,currentAccount:f})=>{const m=bl(),[h,g]=(0,_.useState)([]),[v,y]=(0,_.useState)(),[b,w]=(0,_.useState)(),[x,E]=(0,_.useState)(),[C,S]=(0,_.useState)([]),[k,A]=(0,_.useState)(f),[O,R]=(0,_.useState)(),[T,I]=(0,_.useState)(!1),[j,P]=(0,_.useState)(!0);(0,_.useEffect)((()=>{const t=void 0===e?Object.assign({},ZI):Object.assign({},e);h.forEach((e=>{switch(e.name){case"groups":t.msTenant="groups";break;case"group":t.msId=e.id,t.idFolder="root";break;case"documents":t.idFolder=e.id;break;case"me":t.msTenant="me",t.idFolder="root"}})),w(t)}),[h,e]),(0,_.useEffect)((()=>{s&&b&&s(C,b)}),[C,b,s]),(0,_.useEffect)((()=>{void 0!==e&&w(e)}),[e]),(0,_.useEffect)((()=>{void 0!==t&&g([{name:"group"===t.type?"group":"documents",title:t.title,id:t.id}])}),[t]),(0,_.useEffect)((()=>{y(h.at(-1))}),[h]);const{listAccount:D,checkAccountToken:L,isAccountLogged:M}=u,B=(0,_.useCallback)((e=>{D&&L&&M&&(P(!0),I(!1),g([]),S([]),d&&u&&D(WT).then((t=>{var n;if(R(t.result),t.result.length>0){const r=null!==(n=e?t.result.find((t=>t.id===e.id)):t.result.find((e=>e.default)))&&void 0!==n?n:t.result[0];A(r),L(WT).then((e=>{e.result?M(WT,r.id).then((e=>{e.result&&(I(e.result),p&&p(r))})).catch((()=>I(!1))).finally((()=>{P(!1)})):(I(!1),P(!1))}))}else A(void 0),I(!1),P(!1)})).catch((e=>{c&&c(e.errorMsg)})))}),[L,u,d,M,D,c,p]),F=(0,_.useCallback)((e=>{P(!1),c&&c(e)}),[c]);return(0,_.useEffect)((()=>{B()}),[B]),d&&j?_.createElement(gE,{size:"l"}):_.createElement($I,null,d&&u.logout&&u.getAccount&&u.setDefaultAccount&&_.createElement(KI,{activeAccount:k,accounts:O,onLogout:B,onLogin:B,isLogged:T,onSetDefaultAccount:e=>{A((e=>e?Object.assign(Object.assign({},e),{default:!0}):e)),R((t=>t?t.map((t=>t.id===e.id?Object.assign(Object.assign({},t),{default:!0}):Object.assign(Object.assign({},t),{default:!1}))):t))},requests:{logout:u.logout,getAccount:u.getAccount,setDefaultAccount:u.setDefaultAccount},onLoginError:F}),(!d||T)&&k&&_.createElement(_.Fragment,null,_.createElement(FI,null,i&&h.length>0?_.createElement(NI,{onClick:()=>g([])},_.createElement("div",null,m.formatMessage({id:"DRIVE_Root"})),_.createElement(nE,{name:"icon-angle-right",size:12})):_.createElement(_.Fragment,null),h.map(((e,t)=>_.createElement(NI,{key:t,onClick:()=>g((e=>e.filter(((e,n)=>n<=t))))},e.title,t<h.length-1&&_.createElement(nE,{name:"icon-angle-right",size:12}))))),void 0===v?_.createElement(LI,{id:k.id,initialFolderColor:n,onClick:e=>{var t;g([...h,{name:null!==(t=e.name)&&void 0!==t?t:"groups",title:e.title,id:void 0}])},request:u.tenants}):_.createElement(_.Fragment,null),"groups"===(null==v?void 0:v.name)&&b?_.createElement(PI,{id:k.id,initialFolderColor:n,useFilter:o,onSelect:"function"==typeof a?e=>{a(e,Object.assign(Object.assign({},b),{msId:e.id,idFolder:"root"}))}:void 0,useNavigation:i,onClick:e=>{E(e),g([...h,{name:"group",title:e.title,id:e.id}])},onError:c,driveRequests:{groups:u.groups}}):_.createElement(_.Fragment,null),"group"!==(null==v?void 0:v.name)&&"documents"!==(null==v?void 0:v.name)&&"me"!==(null==v?void 0:v.name)||void 0===b?_.createElement(_.Fragment,null):_.createElement(BI,{initialFolderColor:n,useFilter:o,useNavigation:i,driveDocumentParams:b,useDocumentFilters:r,onSelect:"function"==typeof a?e=>{a(e,Object.assign(Object.assign({},b),{idFolder:e.id}))}:void 0,onSelectMultiDocument:s?e=>{const t=C.find((t=>t.id===e.id));S(t?C.filter((t=>t.id!==e.id)):[...C,e])}:void 0,onSelectDocument:l?e=>{l&&b&&l(e,x,b)}:void 0,onClick:e=>{E(e),g([...h,{name:"documents",title:e.title,id:e.id}])},onError:c,driveRequests:{documents:u.documents},id:k.id})))},QI=fx`
586
586
  opacity: 0.5;
587
587
  position: relative;
588
588
  background-color: ${e=>e.theme.color.grey1};