@plurid/plurid-react 0.0.0-30 → 0.0.0-31

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.
@@ -534,7 +534,7 @@
534
534
  ::after {
535
535
  content: "${({devisible:e,suffix:t})=>e?"":t||"'"}";
536
536
  }
537
- `,Xn=o.connect((e=>({stateTree:Ot.space.getTree(e),stateLastClosedPlane:Ot.space.getLastClosedPlane(e),stateGeneralTheme:Ot.themes.getGeneralTheme(e),stateConfiguration:Ot.configuration.getConfiguration(e),stateViewSize:Ot.space.getViewSize(e)})),(e=>({dispatch:e,dispatchSetTree:t=>e(qe.space.setTree(t)),dispatchSetSpaceField:t=>e(qe.space.setSpaceField(t)),dispatchUpdateSpaceLinkCoordinates:t=>e(qe.space.updateSpaceLinkCoordinates(t))})),null,{context:Ge})((e=>{const n=r.useContext(He);if(!n)return x.default.createElement(x.default.Fragment,null,e.children);const{hostname:o,planesRegistrar:i,defaultPubSub:s}=n,c=ie(i);if(!c)return x.default.createElement(x.default.Fragment,null,e.children);const{children:d,route:f,devisible:p,suffix:m,atClick:g,style:h,className:T,preview:E,previewComponent:v,previewFadeIn:S,previewFadeOut:P,previewOffsetX:b,previewOffsetY:R,stateTree:I,stateLastClosedPlane:C,stateGeneralTheme:w,stateConfiguration:O,stateViewSize:y,dispatch:_,dispatchSetTree:L,dispatchSetSpaceField:A,dispatchUpdateSpaceLinkCoordinates:U}=e,D=O.elements.plane.controls.show,N=S||t.PLURID_DEFAULT_CONFIGURATION_LINK_PREVIEW_FADE_IN,M=P||t.PLURID_DEFAULT_CONFIGURATION_LINK_PREVIEW_FADE_OUT,k=me(f),F=pe(k,O.network.protocol,o||O.network.host),B=null!=m?m:t.PLURID_DEFAULT_CONFIGURATION_LINK_SUFFIX,Y=null!=p&&p,$=r.useRef(null),X=r.useRef(null),V=r.useRef(null),[z,K]=r.useState(!1),[Z,j]=r.useState(!1),[G,W]=r.useState(!1),[H,q]=r.useState(""),[J,Q]=r.useState(le($.current)),[ee,te]=r.useState(kn),ae=()=>{const e=$.current;if(!e)return Object.assign({},kn);let t=0,a=0,n=!1,r=e,o=!0,i=0,l=0;for(;o;)if("static"!==window.getComputedStyle(r).position||n||(t+=r.offsetTop,a+=r.offsetLeft,n=!0),"relative"===window.getComputedStyle(r).position&&(i+=t,l+=a,t=0,a=0,n=!1),r.scrollLeft&&(l+=-r.scrollLeft),r.scrollTop&&(i+=-r.scrollTop),r.parentElement){"PluridPlane"===r.parentElement.dataset.pluridEntity&&(o=!1),r=r.parentElement}else o=!1;const s=D?56:0;return{x:l+e.offsetWidth,y:i+s}},ne=u.useDebouncedCallback((()=>{(()=>{const e=ae();U({planeID:H,linkCoordinates:e});const t=a.space.tree.logic.updatePlaneLocation(l.objects.clone(I),J,H,l.objects.clone(e));L(t)})()}),t.PLURID_DEFAULT_RESIZE_DEBOUNCE_TIME),re=e=>{const{updatedTree:t,updatedPlane:n}=a.space.tree.logic.togglePlaneFromTree(l.objects.clone(I),H,e);return L(t),W((e=>!e)),j(!1),{updatedPlane:n}},oe=(e,t)=>{t&&(G||(A({field:"isolatePlane",value:""}),Et(_,t,e)))},se=e=>{if(e.altKey&&G&&H){const t=a.space.tree.logic.getTreePlaneByID(I,H);Et(_,t,e)}else G||H?(e=>{const{updatedPlane:t}=re();oe(e,t)})(e):(e=>{if(!J||!F)return;const{route:t}=F,n=ae(),{pluridPlaneID:r,updatedTree:i,updatedTreePlane:s}=a.space.tree.logic.updateTreeWithNewPlane(t,J,n,l.objects.clone(I),c.getAll(),O,o);r&&(oe(e,s),L(i),W(!0),q(r))})(e)},ce=()=>{$.current&&$.current.blur()},ue=r.useCallback((e=>{e.preventDefault(),void 0!==g&&g(e),se(e),ce()}),[J,JSON.stringify(I),$.current]);return r.useEffect((()=>{const e=le($.current);Q(e);const t=ae();te(t)}),[]),r.useEffect((()=>{G&&ne()}),[G,JSON.stringify(y),JSON.stringify(I)]),r.useEffect((()=>{if(E)return z&&V.current&&(X.current=setTimeout((()=>{j(!0)}),N),clearTimeout(V.current)),z||(V.current=setTimeout((()=>{j(!1),X.current&&clearTimeout(X.current)}),M)),()=>{V.current&&clearTimeout(V.current),X.current&&clearTimeout(X.current)}}),[E,z]),r.useEffect((()=>{}),[]),r.useEffect((()=>{const e=s.subscribe({topic:t.PLURID_PUBSUB_TOPIC.OPEN_CLOSED_PLANE,callback:()=>{C===H&&(re(),A({field:"lastClosedPlane",value:""}))}});return()=>{s.unsubscribe(e)}}),[G,H,JSON.stringify(I)]),r.useEffect((()=>{const e=s.subscribe({topic:t.PLURID_PUBSUB_TOPIC.CLOSE_PLANE,callback:e=>{const{id:t}=e;if(t===H&&G){re(!1),A({field:"lastClosedPlane",value:t})}}});return()=>{s.unsubscribe(e)}}),[G,H,JSON.stringify(I)]),r.useEffect((()=>()=>{G&&null===$.current&&(()=>{const e=a.space.tree.logic.removePlaneFromTree(l.objects.clone(I),H);L(e),W((e=>!e)),j(!1)})()}),[G,Z,H,J,JSON.stringify(I)]),x.default.createElement($n,{ref:$,onClick:e=>ue(e),onMouseEnter:()=>K(!0),onMouseLeave:()=>K(!1),onKeyUp:e=>(e=>{if("Enter"===e.code)return ue(e),void ce()})(e),theme:w,suffix:B,devisible:Y,style:Object.assign({},h),className:T,"data-plurid-entity":t.PLURID_ENTITY_LINK,tabIndex:0},d,Z&&!G&&x.default.createElement(Fn,{elementID:`preview-${J}`,rootID:J},x.default.createElement(Yn,{planeRoute:k,linkCoordinates:ee,previewComponent:v,previewOffsetX:b,previewOffsetY:R})))})),Vn=c.css`
537
+ `,Xn=o.connect((e=>({stateTree:Ot.space.getTree(e),stateLastClosedPlane:Ot.space.getLastClosedPlane(e),stateGeneralTheme:Ot.themes.getGeneralTheme(e),stateConfiguration:Ot.configuration.getConfiguration(e),stateViewSize:Ot.space.getViewSize(e)})),(e=>({dispatch:e,dispatchSetTree:t=>e(qe.space.setTree(t)),dispatchSetSpaceField:t=>e(qe.space.setSpaceField(t)),dispatchUpdateSpaceLinkCoordinates:t=>e(qe.space.updateSpaceLinkCoordinates(t))})),null,{context:Ge})((e=>{const n=r.useContext(He);if(!n)return x.default.createElement(x.default.Fragment,null,e.children);const{hostname:o,planesRegistrar:i,defaultPubSub:s}=n,c=ie(i);if(!c)return x.default.createElement(x.default.Fragment,null,e.children);const{children:d,route:f,devisible:p,suffix:m,atClick:g,style:h,className:T,preview:E,previewComponent:v,previewFadeIn:S,previewFadeOut:P,previewOffsetX:b,previewOffsetY:R,stateTree:I,stateLastClosedPlane:C,stateGeneralTheme:w,stateConfiguration:O,stateViewSize:y,dispatch:_,dispatchSetTree:L,dispatchSetSpaceField:A,dispatchUpdateSpaceLinkCoordinates:U}=e,D=O.elements.plane.controls.show,N=S||t.PLURID_DEFAULT_CONFIGURATION_LINK_PREVIEW_FADE_IN,M=P||t.PLURID_DEFAULT_CONFIGURATION_LINK_PREVIEW_FADE_OUT,k=me(f),F=pe(k,O.network.protocol,o||O.network.host),B=null!=m?m:t.PLURID_DEFAULT_CONFIGURATION_LINK_SUFFIX,Y=null!=p&&p,$=r.useRef(null),X=r.useRef(null),V=r.useRef(null),z=r.useRef(),[K,Z]=r.useState(!1),[j,G]=r.useState(!1),[W,H]=r.useState(!1),[q,J]=r.useState(""),[Q,ee]=r.useState(le($.current)),[te,ae]=r.useState(kn),ne=()=>{const e=$.current;if(!e)return Object.assign({},kn);let t=0,a=0,n=!1,r=e,o=!0,i=0,l=0;for(;o;)if("static"!==window.getComputedStyle(r).position||n||(t+=r.offsetTop,a+=r.offsetLeft,n=!0),"relative"===window.getComputedStyle(r).position&&(i+=t,l+=a,t=0,a=0,n=!1),r.scrollLeft&&(l+=-r.scrollLeft),r.scrollTop&&(i+=-r.scrollTop),r.parentElement){"PluridPlane"===r.parentElement.dataset.pluridEntity&&(o=!1),r=r.parentElement}else o=!1;const s=D?56:0;return{x:l+e.offsetWidth,y:i+s}},re=u.useDebouncedCallback((()=>{(()=>{const e=ne();U({planeID:q,linkCoordinates:e});const t=a.space.tree.logic.updatePlaneLocation(l.objects.clone(I),Q,q,l.objects.clone(e));L(t)})()}),t.PLURID_DEFAULT_RESIZE_DEBOUNCE_TIME),oe=e=>{const{updatedTree:t,updatedPlane:n}=a.space.tree.logic.togglePlaneFromTree(l.objects.clone(I),q,e);return L(t),H((e=>!e)),G(!1),{updatedPlane:n}},se=(e,t)=>{t&&(W||(A({field:"isolatePlane",value:""}),Et(_,t,e)))},ce=e=>{if(e.altKey&&W&&q){const t=a.space.tree.logic.getTreePlaneByID(I,q);Et(_,t,e)}else W||q?(e=>{const{updatedPlane:t}=oe();se(e,t)})(e):(e=>{if(!Q||!F)return;const{route:t}=F,n=ne(),{pluridPlaneID:r,updatedTree:i,updatedTreePlane:s}=a.space.tree.logic.updateTreeWithNewPlane(t,Q,n,l.objects.clone(I),c.getAll(),O,o);r&&(se(e,s),L(i),H(!0),J(r))})(e)},ue=()=>{$.current&&$.current.blur()},de=r.useCallback((e=>{e.preventDefault(),void 0!==g&&g(e),ce(e),ue()}),[Q,JSON.stringify(I),$.current]);return r.useEffect((()=>{const e=le($.current);ee(e);const t=ne();ae(t);((e,t)=>{if(e&&e.children)for(const a of e.children)a.linkCoordinates&&(a.linkCoordinates.x!==t.x&&a.linkCoordinates.y!==t.y||(H(!0),J(a.planeID)))})(a.space.tree.logic.getTreePlaneByID(I,e),t)}),[]),r.useEffect((()=>{W&&re()}),[W,JSON.stringify(y),JSON.stringify(I)]),r.useEffect((()=>{if(E)return K&&V.current&&(X.current=setTimeout((()=>{G(!0)}),N),clearTimeout(V.current)),K||(V.current=setTimeout((()=>{G(!1),X.current&&clearTimeout(X.current)}),M)),()=>{V.current&&clearTimeout(V.current),X.current&&clearTimeout(X.current)}}),[E,K]),r.useEffect((()=>{}),[]),r.useEffect((()=>{const e=s.subscribe({topic:t.PLURID_PUBSUB_TOPIC.OPEN_CLOSED_PLANE,callback:()=>{C===q&&(oe(),A({field:"lastClosedPlane",value:""}))}});return()=>{s.unsubscribe(e)}}),[W,q,JSON.stringify(I)]),r.useEffect((()=>{const e=s.subscribe({topic:t.PLURID_PUBSUB_TOPIC.CLOSE_PLANE,callback:e=>{const{id:t}=e;if(t===q&&W){oe(!1),A({field:"lastClosedPlane",value:t})}}});return()=>{s.unsubscribe(e)}}),[W,q,JSON.stringify(I)]),r.useEffect((()=>{const e=a.space.tree.logic.getTreePlaneByID(I,q);return z.current=e,()=>{setTimeout((()=>{var e;W&&null===$.current&&!1===(null===(e=z.current)||void 0===e?void 0:e.show)&&(()=>{const e=a.space.tree.logic.removePlaneFromTree(l.objects.clone(I),q);L(e),H((e=>!e)),G(!1)})()}),10)}}),[W,j,q,Q,JSON.stringify(I)]),x.default.createElement($n,{ref:$,onClick:e=>de(e),onMouseEnter:()=>Z(!0),onMouseLeave:()=>Z(!1),onKeyUp:e=>(e=>{if("Enter"===e.code)return de(e),void ue()})(e),theme:w,suffix:B,devisible:Y,style:Object.assign({},h),className:T,"data-plurid-entity":t.PLURID_ENTITY_LINK,tabIndex:0},d,j&&!W&&x.default.createElement(Fn,{elementID:`preview-${Q}`,rootID:Q},x.default.createElement(Yn,{planeRoute:k,linkCoordinates:te,previewComponent:v,previewOffsetX:b,previewOffsetY:R})))})),Vn=c.css`
538
538
  color: ${({theme:e})=>e.colorTertiary};
539
539
 
540
540
  @media (hover:hover) {