Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@keboola/flow-builder

Package Overview
Dependencies
Maintainers
7
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keboola/flow-builder - npm Package Compare versions

Comparing version 0.5.5 to 0.5.6

2

dist/index.cjs.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);class l{constructor(e,t){this.x=e,this.y=t}subtract(e){return new l(this.x-e.x,this.y-e.y)}dist(e){return Math.hypot(e.x-this.x,e.y-this.y)}css(){return{left:`${this.x}px`,top:`${this.y}px`}}array(){return[this.x,this.y]}}const r=(e=0,t=0)=>new l(e,t);r.from=e=>e instanceof MouseEvent?new l(e.clientX,e.clientY):new l(e[0],e[1]),r.offsetOf=e=>new l(e.left,e.top);const o=(...e)=>e.map((e=>"string"==typeof e?e:e[1]?e[0]:null)).filter((e=>null!==e)).join(" "),a=(e,t)=>{let n=[];for(let l=0,r=e.length;l<r;++l){const r=e[l];t(r,l,e)?n.push(r):e[l-n.length]=r}return e.length-=n.length,n};function s(...e){return t=>{for(let n=0;n<e.length;++n){const l=e[n];l&&("function"==typeof l?l(t):l.current=t)}}}const u=t=>{const n=e.Children.toArray(t);return{remainder:n,inputs:a(n,(e=>{var t;return null===(t=null==e?void 0:e.type)||void 0===t?void 0:t._$isInput})).map((e=>e.props)),outputs:a(n,(e=>{var t;return null===(t=null==e?void 0:e.type)||void 0===t?void 0:t._$isOutput})).map((e=>e.props))}},i=e=>null,c=e=>null;i._$isInput=!0,c._$isOutput=!0;const d=e.createContext({parent:null});const f=n.default.forwardRef(((t,l)=>{if(!t.children)return null;const a=e.useContext(d),{inputs:i,outputs:c,remainder:f}=u(t.children);"Group"===a.parent&&(i.length>0||c.length>0)&&console.warn("flow-builder: Inputs/Outputs on Nodes within Groups are ignored");const[m,p]=function({onDragStart:t,onDragMove:n,onDragEnd:l,onSelect:o}){const a=[t,n,l,o],[s]=e.useState({start:null,current:null,node:null,container:null}),u=()=>s.container?r.offsetOf(s.container.getBoundingClientRect()):r();return e.useEffect((()=>{const e=e=>{if(!s.start)return;e.preventDefault();const l=r.from(e),o=l.subtract(u());s.current?(s.current=o,null==n||n(o.array(),[e.clientY,e.clientX])):s.start.dist(l)>20&&(s.current=o,null==t||t(o.array()))},a=e=>{const t=r.from(e).subtract(u());(s.current||s.start)&&e.preventDefault(),s.current?null==l||l(t.array()):s.start&&(null==o||o()),s.start=null,s.current=null};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",a),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",a)}}),a),[e.useCallback((e=>{e&&s.node!==e&&(s.node=e,s.container=function(e,t){for(const n of function*(e){let t=e.parentElement;for(;t;)yield t,t=t.parentElement}(e))if(t(n))return n;return null}(e,(e=>"div"===e.tagName.toLowerCase()&&"graph"===e.dataset.type&&e.classList.contains("flow-builder"))))}),a),e.useCallback((e=>{s.start=r(e.clientX,e.clientY)}),a)]}(t.draggable?t:{onSelect:t.onSelect});return n.default.createElement("div",{ref:s(m,l),"data-type":"node","data-name":t.name,className:o("flow-builder--node",[t.className,!!t.className]),style:Object.assign(Object.assign({},t.style),t.position?r.from(t.position).css():{}),onMouseDown:p,tabIndex:t.onSelect&&0,onKeyDown:e=>{var n;return"Enter"===e.key&&(null===(n=t.onSelect)||void 0===n?void 0:n.call(t))},role:t.onSelect&&"button"},n.default.createElement("div",{className:"flow-builder--content"},f),n.default.createElement("div",{className:"flow-builder--io flow-builder--io-top"},"Group"!==a.parent&&i.map((({name:e,children:l,style:r})=>n.default.createElement("div",{className:"flow-builder--io-port",key:e,"data-name":`${t.name}.${e}`,style:r},l)))),n.default.createElement("div",{className:"flow-builder--io flow-builder--io-bottom"},"Group"!==a.parent&&c.map((({name:e,children:l,style:r})=>n.default.createElement("div",{className:"flow-builder--io-port",key:e,"data-name":`${t.name}.${e}`,style:r},l)))))}));exports.Graph=({children:e})=>e?n.default.createElement("div",{"data-type":"graph",className:"flow-builder"},e):null,exports.Group=t=>{if(!t.children)return null;const{inputs:l,outputs:a,remainder:s}=u(t.children),i=[t.onMouseEnter,t.onMouseLeave],c=e.useRef(null),[f]=e.useState({value:!1}),m=e.useCallback((e=>{var n,l,r;const o=null===(n=c.current)||void 0===n?void 0:n.getBoundingClientRect();if(!o)return!1;const a=e.clientX,s=e.clientY,u=o.x<a&&o.y<s&&o.x+o.width>a&&o.y+o.height>s;u!==f.value&&(f.value=u,f.value?null===(l=t.onMouseEnter)||void 0===l||l.call(t):null===(r=t.onMouseLeave)||void 0===r||r.call(t))}),i);return e.useEffect((()=>(window.addEventListener("mousemove",m,{passive:!0}),()=>window.removeEventListener("mousemove",m))),i),n.default.createElement(d.Provider,{value:{parent:"Group"}},n.default.createElement("div",{ref:c,"data-type":"group","data-name":t.name,className:o("flow-builder--group",[t.className,!!t.className]),style:Object.assign(Object.assign({},t.style),t.position?r.from(t.position).css():{})},n.default.createElement("div",{className:"flow-builder--content"},s),n.default.createElement("div",{className:"flow-builder--io flow-builder--io-top"},l.map((({name:e,children:l,style:r})=>n.default.createElement("div",{className:"flow-builder--io-port",key:e,"data-name":`${t.name}.${e}`,style:r},l)))),n.default.createElement("div",{className:"flow-builder--io flow-builder--io-bottom"},a.map((({name:e,children:l,style:r})=>n.default.createElement("div",{className:"flow-builder--io-port",key:e,"data-name":`${t.name}.${e}`,style:r},l))))))},exports.Input=i,exports.Node=f,exports.Output=c;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);class l{constructor(e,t){this.x=e,this.y=t}subtract(e){return new l(this.x-e.x,this.y-e.y)}dist(e){return Math.hypot(e.x-this.x,e.y-this.y)}css(){return{left:`${this.x}px`,top:`${this.y}px`}}array(){return[this.x,this.y]}}const r=(e=0,t=0)=>new l(e,t);r.from=e=>e instanceof MouseEvent?new l(e.clientX,e.clientY):new l(e[0],e[1]),r.offsetOf=e=>new l(e.left,e.top);const a=(...e)=>e.map((e=>"string"==typeof e?e:e[1]?e[0]:null)).filter((e=>null!==e)).join(" "),o=(e,t)=>{let n=[];for(let l=0,r=e.length;l<r;++l){const r=e[l];t(r,l,e)?n.push(r):e[l-n.length]=r}return e.length-=n.length,n};function s(...e){return t=>{for(let n=0;n<e.length;++n){const l=e[n];l&&("function"==typeof l?l(t):l.current=t)}}}const u=t=>{const n=e.Children.toArray(t);return{remainder:n,inputs:o(n,(e=>{var t;return null===(t=null==e?void 0:e.type)||void 0===t?void 0:t._$isInput})).map((e=>e.props)),outputs:o(n,(e=>{var t;return null===(t=null==e?void 0:e.type)||void 0===t?void 0:t._$isOutput})).map((e=>e.props))}},i=e=>null,c=e=>null;i._$isInput=!0,c._$isOutput=!0;const d=e.createContext({parent:null});const f=n.default.forwardRef(((t,l)=>{if(!t.children)return null;const o=e.useContext(d),{inputs:i,outputs:c,remainder:f}=u(t.children);"Group"===o.parent&&(i.length>0||c.length>0)&&console.warn("flow-builder: Inputs/Outputs on Nodes within Groups are ignored");const[m,p]=function({onDragStart:t,onDragMove:n,onDragEnd:l,onSelect:a}){const o=[t,n,l,a],[s]=e.useState({start:null,current:null,node:null,container:null}),u=()=>s.container?r.offsetOf(s.container.getBoundingClientRect()):r();return e.useEffect((()=>{const e=e=>{if(!s.start)return;e.preventDefault();const l=r.from(e),a=l.subtract(u());s.current?(s.current=a,null==n||n(a.array(),l.array())):s.start.dist(l)>20&&(s.current=a,null==t||t(a.array()))},o=e=>{const t=r.from(e).subtract(u());(s.current||s.start)&&e.preventDefault(),s.current?null==l||l(t.array()):s.start&&(null==a||a()),s.start=null,s.current=null};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",o),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",o)}}),o),[e.useCallback((e=>{e&&s.node!==e&&(s.node=e,s.container=function(e,t){for(const n of function*(e){let t=e.parentElement;for(;t;)yield t,t=t.parentElement}(e))if(t(n))return n;return null}(e,(e=>"div"===e.tagName.toLowerCase()&&"graph"===e.dataset.type&&e.classList.contains("flow-builder"))))}),o),e.useCallback((e=>{s.start=r(e.clientX,e.clientY)}),o)]}(t.draggable?t:{onSelect:t.onSelect});return n.default.createElement("div",{ref:s(m,l),"data-type":"node","data-name":t.name,className:a("flow-builder--node",[t.className,!!t.className]),style:Object.assign(Object.assign({},t.style),t.position?r.from(t.position).css():{}),onMouseDown:p,tabIndex:t.onSelect&&0,onKeyDown:e=>{var n;return"Enter"===e.key&&(null===(n=t.onSelect)||void 0===n?void 0:n.call(t))},role:t.onSelect&&"button"},n.default.createElement("div",{className:"flow-builder--content"},f),n.default.createElement("div",{className:"flow-builder--io flow-builder--io-top"},"Group"!==o.parent&&i.map((({name:e,children:l,style:r})=>n.default.createElement("div",{className:"flow-builder--io-port",key:e,"data-name":`${t.name}.${e}`,style:r},l)))),n.default.createElement("div",{className:"flow-builder--io flow-builder--io-bottom"},"Group"!==o.parent&&c.map((({name:e,children:l,style:r})=>n.default.createElement("div",{className:"flow-builder--io-port",key:e,"data-name":`${t.name}.${e}`,style:r},l)))))}));exports.Graph=({children:e})=>e?n.default.createElement("div",{"data-type":"graph",className:"flow-builder"},e):null,exports.Group=t=>{if(!t.children)return null;const{inputs:l,outputs:o,remainder:s}=u(t.children),i=[t.onMouseEnter,t.onMouseLeave],c=e.useRef(null),[f]=e.useState({value:!1}),m=e.useCallback((e=>{var n,l,r;const a=null===(n=c.current)||void 0===n?void 0:n.getBoundingClientRect();if(!a)return!1;const o=e.clientX,s=e.clientY,u=a.x<o&&a.y<s&&a.x+a.width>o&&a.y+a.height>s;u!==f.value&&(f.value=u,f.value?null===(l=t.onMouseEnter)||void 0===l||l.call(t):null===(r=t.onMouseLeave)||void 0===r||r.call(t))}),i);return e.useEffect((()=>(window.addEventListener("mousemove",m,{passive:!0}),()=>window.removeEventListener("mousemove",m))),i),n.default.createElement(d.Provider,{value:{parent:"Group"}},n.default.createElement("div",{ref:c,"data-type":"group","data-name":t.name,className:a("flow-builder--group",[t.className,!!t.className]),style:Object.assign(Object.assign({},t.style),t.position?r.from(t.position).css():{})},n.default.createElement("div",{className:"flow-builder--content"},s),n.default.createElement("div",{className:"flow-builder--io flow-builder--io-top"},l.map((({name:e,children:l,style:r})=>n.default.createElement("div",{className:"flow-builder--io-port",key:e,"data-name":`${t.name}.${e}`,style:r},l)))),n.default.createElement("div",{className:"flow-builder--io flow-builder--io-bottom"},o.map((({name:e,children:l,style:r})=>n.default.createElement("div",{className:"flow-builder--io-port",key:e,"data-name":`${t.name}.${e}`,style:r},l))))))},exports.Input=i,exports.Node=f,exports.Output=c;
//# sourceMappingURL=index.cjs.js.map

@@ -1,2 +0,2 @@

import e,{Children as t,createContext as n,useCallback as r,useState as l,useEffect as o,useContext as a,useRef as s}from"react";class i{constructor(e,t){this.x=e,this.y=t}subtract(e){return new i(this.x-e.x,this.y-e.y)}dist(e){return Math.hypot(e.x-this.x,e.y-this.y)}css(){return{left:`${this.x}px`,top:`${this.y}px`}}array(){return[this.x,this.y]}}const u=(e=0,t=0)=>new i(e,t);u.from=e=>e instanceof MouseEvent?new i(e.clientX,e.clientY):new i(e[0],e[1]),u.offsetOf=e=>new i(e.left,e.top);const c=(...e)=>e.map((e=>"string"==typeof e?e:e[1]?e[0]:null)).filter((e=>null!==e)).join(" "),d=(e,t)=>{let n=[];for(let r=0,l=e.length;r<l;++r){const l=e[r];t(l,r,e)?n.push(l):e[r-n.length]=l}return e.length-=n.length,n};function m(...e){return t=>{for(let n=0;n<e.length;++n){const r=e[n];r&&("function"==typeof r?r(t):r.current=t)}}}const p=e=>{const n=t.toArray(e);return{remainder:n,inputs:d(n,(e=>{var t;return null===(t=null==e?void 0:e.type)||void 0===t?void 0:t._$isInput})).map((e=>e.props)),outputs:d(n,(e=>{var t;return null===(t=null==e?void 0:e.type)||void 0===t?void 0:t._$isOutput})).map((e=>e.props))}},f=e=>null,v=e=>null;f._$isInput=!0,v._$isOutput=!0;const w=n({parent:null});const y=e.forwardRef(((t,n)=>{if(!t.children)return null;const s=a(w),{inputs:i,outputs:d,remainder:f}=p(t.children);"Group"===s.parent&&(i.length>0||d.length>0)&&console.warn("flow-builder: Inputs/Outputs on Nodes within Groups are ignored");const[v,y]=function({onDragStart:e,onDragMove:t,onDragEnd:n,onSelect:a}){const s=[e,t,n,a],[i]=l({start:null,current:null,node:null,container:null}),c=()=>i.container?u.offsetOf(i.container.getBoundingClientRect()):u();return o((()=>{const r=n=>{if(!i.start)return;n.preventDefault();const r=u.from(n),l=r.subtract(c());i.current?(i.current=l,null==t||t(l.array(),[n.clientY,n.clientX])):i.start.dist(r)>20&&(i.current=l,null==e||e(l.array()))},l=e=>{const t=u.from(e).subtract(c());(i.current||i.start)&&e.preventDefault(),i.current?null==n||n(t.array()):i.start&&(null==a||a()),i.start=null,i.current=null};return window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),()=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l)}}),s),[r((e=>{e&&i.node!==e&&(i.node=e,i.container=function(e,t){for(const n of function*(e){let t=e.parentElement;for(;t;)yield t,t=t.parentElement}(e))if(t(n))return n;return null}(e,(e=>"div"===e.tagName.toLowerCase()&&"graph"===e.dataset.type&&e.classList.contains("flow-builder"))))}),s),r((e=>{i.start=u(e.clientX,e.clientY)}),s)]}(t.draggable?t:{onSelect:t.onSelect});return e.createElement("div",{ref:m(v,n),"data-type":"node","data-name":t.name,className:c("flow-builder--node",[t.className,!!t.className]),style:Object.assign(Object.assign({},t.style),t.position?u.from(t.position).css():{}),onMouseDown:y,tabIndex:t.onSelect&&0,onKeyDown:e=>{var n;return"Enter"===e.key&&(null===(n=t.onSelect)||void 0===n?void 0:n.call(t))},role:t.onSelect&&"button"},e.createElement("div",{className:"flow-builder--content"},f),e.createElement("div",{className:"flow-builder--io flow-builder--io-top"},"Group"!==s.parent&&i.map((({name:n,children:r,style:l})=>e.createElement("div",{className:"flow-builder--io-port",key:n,"data-name":`${t.name}.${n}`,style:l},r)))),e.createElement("div",{className:"flow-builder--io flow-builder--io-bottom"},"Group"!==s.parent&&d.map((({name:n,children:r,style:l})=>e.createElement("div",{className:"flow-builder--io-port",key:n,"data-name":`${t.name}.${n}`,style:l},r)))))})),h=t=>{if(!t.children)return null;const{inputs:n,outputs:a,remainder:i}=p(t.children),d=[t.onMouseEnter,t.onMouseLeave],m=s(null),[f]=l({value:!1}),v=r((e=>{var n,r,l;const o=null===(n=m.current)||void 0===n?void 0:n.getBoundingClientRect();if(!o)return!1;const a=e.clientX,s=e.clientY,i=o.x<a&&o.y<s&&o.x+o.width>a&&o.y+o.height>s;i!==f.value&&(f.value=i,f.value?null===(r=t.onMouseEnter)||void 0===r||r.call(t):null===(l=t.onMouseLeave)||void 0===l||l.call(t))}),d);return o((()=>(window.addEventListener("mousemove",v,{passive:!0}),()=>window.removeEventListener("mousemove",v))),d),e.createElement(w.Provider,{value:{parent:"Group"}},e.createElement("div",{ref:m,"data-type":"group","data-name":t.name,className:c("flow-builder--group",[t.className,!!t.className]),style:Object.assign(Object.assign({},t.style),t.position?u.from(t.position).css():{})},e.createElement("div",{className:"flow-builder--content"},i),e.createElement("div",{className:"flow-builder--io flow-builder--io-top"},n.map((({name:n,children:r,style:l})=>e.createElement("div",{className:"flow-builder--io-port",key:n,"data-name":`${t.name}.${n}`,style:l},r)))),e.createElement("div",{className:"flow-builder--io flow-builder--io-bottom"},a.map((({name:n,children:r,style:l})=>e.createElement("div",{className:"flow-builder--io-port",key:n,"data-name":`${t.name}.${n}`,style:l},r))))))},b=({children:t})=>t?e.createElement("div",{"data-type":"graph",className:"flow-builder"},t):null;export{b as Graph,h as Group,f as Input,y as Node,v as Output};
import e,{Children as t,createContext as n,useCallback as r,useState as l,useEffect as o,useContext as a,useRef as s}from"react";class i{constructor(e,t){this.x=e,this.y=t}subtract(e){return new i(this.x-e.x,this.y-e.y)}dist(e){return Math.hypot(e.x-this.x,e.y-this.y)}css(){return{left:`${this.x}px`,top:`${this.y}px`}}array(){return[this.x,this.y]}}const u=(e=0,t=0)=>new i(e,t);u.from=e=>e instanceof MouseEvent?new i(e.clientX,e.clientY):new i(e[0],e[1]),u.offsetOf=e=>new i(e.left,e.top);const c=(...e)=>e.map((e=>"string"==typeof e?e:e[1]?e[0]:null)).filter((e=>null!==e)).join(" "),d=(e,t)=>{let n=[];for(let r=0,l=e.length;r<l;++r){const l=e[r];t(l,r,e)?n.push(l):e[r-n.length]=l}return e.length-=n.length,n};function m(...e){return t=>{for(let n=0;n<e.length;++n){const r=e[n];r&&("function"==typeof r?r(t):r.current=t)}}}const p=e=>{const n=t.toArray(e);return{remainder:n,inputs:d(n,(e=>{var t;return null===(t=null==e?void 0:e.type)||void 0===t?void 0:t._$isInput})).map((e=>e.props)),outputs:d(n,(e=>{var t;return null===(t=null==e?void 0:e.type)||void 0===t?void 0:t._$isOutput})).map((e=>e.props))}},f=e=>null,v=e=>null;f._$isInput=!0,v._$isOutput=!0;const w=n({parent:null});const y=e.forwardRef(((t,n)=>{if(!t.children)return null;const s=a(w),{inputs:i,outputs:d,remainder:f}=p(t.children);"Group"===s.parent&&(i.length>0||d.length>0)&&console.warn("flow-builder: Inputs/Outputs on Nodes within Groups are ignored");const[v,y]=function({onDragStart:e,onDragMove:t,onDragEnd:n,onSelect:a}){const s=[e,t,n,a],[i]=l({start:null,current:null,node:null,container:null}),c=()=>i.container?u.offsetOf(i.container.getBoundingClientRect()):u();return o((()=>{const r=n=>{if(!i.start)return;n.preventDefault();const r=u.from(n),l=r.subtract(c());i.current?(i.current=l,null==t||t(l.array(),r.array())):i.start.dist(r)>20&&(i.current=l,null==e||e(l.array()))},l=e=>{const t=u.from(e).subtract(c());(i.current||i.start)&&e.preventDefault(),i.current?null==n||n(t.array()):i.start&&(null==a||a()),i.start=null,i.current=null};return window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),()=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l)}}),s),[r((e=>{e&&i.node!==e&&(i.node=e,i.container=function(e,t){for(const n of function*(e){let t=e.parentElement;for(;t;)yield t,t=t.parentElement}(e))if(t(n))return n;return null}(e,(e=>"div"===e.tagName.toLowerCase()&&"graph"===e.dataset.type&&e.classList.contains("flow-builder"))))}),s),r((e=>{i.start=u(e.clientX,e.clientY)}),s)]}(t.draggable?t:{onSelect:t.onSelect});return e.createElement("div",{ref:m(v,n),"data-type":"node","data-name":t.name,className:c("flow-builder--node",[t.className,!!t.className]),style:Object.assign(Object.assign({},t.style),t.position?u.from(t.position).css():{}),onMouseDown:y,tabIndex:t.onSelect&&0,onKeyDown:e=>{var n;return"Enter"===e.key&&(null===(n=t.onSelect)||void 0===n?void 0:n.call(t))},role:t.onSelect&&"button"},e.createElement("div",{className:"flow-builder--content"},f),e.createElement("div",{className:"flow-builder--io flow-builder--io-top"},"Group"!==s.parent&&i.map((({name:n,children:r,style:l})=>e.createElement("div",{className:"flow-builder--io-port",key:n,"data-name":`${t.name}.${n}`,style:l},r)))),e.createElement("div",{className:"flow-builder--io flow-builder--io-bottom"},"Group"!==s.parent&&d.map((({name:n,children:r,style:l})=>e.createElement("div",{className:"flow-builder--io-port",key:n,"data-name":`${t.name}.${n}`,style:l},r)))))})),h=t=>{if(!t.children)return null;const{inputs:n,outputs:a,remainder:i}=p(t.children),d=[t.onMouseEnter,t.onMouseLeave],m=s(null),[f]=l({value:!1}),v=r((e=>{var n,r,l;const o=null===(n=m.current)||void 0===n?void 0:n.getBoundingClientRect();if(!o)return!1;const a=e.clientX,s=e.clientY,i=o.x<a&&o.y<s&&o.x+o.width>a&&o.y+o.height>s;i!==f.value&&(f.value=i,f.value?null===(r=t.onMouseEnter)||void 0===r||r.call(t):null===(l=t.onMouseLeave)||void 0===l||l.call(t))}),d);return o((()=>(window.addEventListener("mousemove",v,{passive:!0}),()=>window.removeEventListener("mousemove",v))),d),e.createElement(w.Provider,{value:{parent:"Group"}},e.createElement("div",{ref:m,"data-type":"group","data-name":t.name,className:c("flow-builder--group",[t.className,!!t.className]),style:Object.assign(Object.assign({},t.style),t.position?u.from(t.position).css():{})},e.createElement("div",{className:"flow-builder--content"},i),e.createElement("div",{className:"flow-builder--io flow-builder--io-top"},n.map((({name:n,children:r,style:l})=>e.createElement("div",{className:"flow-builder--io-port",key:n,"data-name":`${t.name}.${n}`,style:l},r)))),e.createElement("div",{className:"flow-builder--io flow-builder--io-bottom"},a.map((({name:n,children:r,style:l})=>e.createElement("div",{className:"flow-builder--io-port",key:n,"data-name":`${t.name}.${n}`,style:l},r))))))},b=({children:t})=>t?e.createElement("div",{"data-type":"graph",className:"flow-builder"},t):null;export{b as Graph,h as Group,f as Input,y as Node,v as Output};
//# sourceMappingURL=index.esm.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Flow={},e.React)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=n(t);class r{constructor(e,t){this.x=e,this.y=t}subtract(e){return new r(this.x-e.x,this.y-e.y)}dist(e){return Math.hypot(e.x-this.x,e.y-this.y)}css(){return{left:`${this.x}px`,top:`${this.y}px`}}array(){return[this.x,this.y]}}const o=(e=0,t=0)=>new r(e,t);o.from=e=>e instanceof MouseEvent?new r(e.clientX,e.clientY):new r(e[0],e[1]),o.offsetOf=e=>new r(e.left,e.top);const a=(...e)=>e.map((e=>"string"==typeof e?e:e[1]?e[0]:null)).filter((e=>null!==e)).join(" "),u=(e,t)=>{let n=[];for(let l=0,r=e.length;l<r;++l){const r=e[l];t(r,l,e)?n.push(r):e[l-n.length]=r}return e.length-=n.length,n};function s(...e){return t=>{for(let n=0;n<e.length;++n){const l=e[n];l&&("function"==typeof l?l(t):l.current=t)}}}const i=e=>{const n=t.Children.toArray(e);return{remainder:n,inputs:u(n,(e=>{var t;return null===(t=null==e?void 0:e.type)||void 0===t?void 0:t._$isInput})).map((e=>e.props)),outputs:u(n,(e=>{var t;return null===(t=null==e?void 0:e.type)||void 0===t?void 0:t._$isOutput})).map((e=>e.props))}},c=e=>null,d=e=>null;c._$isInput=!0,d._$isOutput=!0;const f=t.createContext({parent:null});const m=l.default.forwardRef(((e,n)=>{if(!e.children)return null;const r=t.useContext(f),{inputs:u,outputs:c,remainder:d}=i(e.children);"Group"===r.parent&&(u.length>0||c.length>0)&&console.warn("flow-builder: Inputs/Outputs on Nodes within Groups are ignored");const[m,p]=function({onDragStart:e,onDragMove:n,onDragEnd:l,onSelect:r}){const a=[e,n,l,r],[u]=t.useState({start:null,current:null,node:null,container:null}),s=()=>u.container?o.offsetOf(u.container.getBoundingClientRect()):o();return t.useEffect((()=>{const t=t=>{if(!u.start)return;t.preventDefault();const l=o.from(t),r=l.subtract(s());u.current?(u.current=r,null==n||n(r.array(),[t.clientY,t.clientX])):u.start.dist(l)>20&&(u.current=r,null==e||e(r.array()))},a=e=>{const t=o.from(e).subtract(s());(u.current||u.start)&&e.preventDefault(),u.current?null==l||l(t.array()):u.start&&(null==r||r()),u.start=null,u.current=null};return window.addEventListener("mousemove",t),window.addEventListener("mouseup",a),()=>{window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",a)}}),a),[t.useCallback((e=>{e&&u.node!==e&&(u.node=e,u.container=function(e,t){for(const n of function*(e){let t=e.parentElement;for(;t;)yield t,t=t.parentElement}(e))if(t(n))return n;return null}(e,(e=>"div"===e.tagName.toLowerCase()&&"graph"===e.dataset.type&&e.classList.contains("flow-builder"))))}),a),t.useCallback((e=>{u.start=o(e.clientX,e.clientY)}),a)]}(e.draggable?e:{onSelect:e.onSelect});return l.default.createElement("div",{ref:s(m,n),"data-type":"node","data-name":e.name,className:a("flow-builder--node",[e.className,!!e.className]),style:Object.assign(Object.assign({},e.style),e.position?o.from(e.position).css():{}),onMouseDown:p,tabIndex:e.onSelect&&0,onKeyDown:t=>{var n;return"Enter"===t.key&&(null===(n=e.onSelect)||void 0===n?void 0:n.call(e))},role:e.onSelect&&"button"},l.default.createElement("div",{className:"flow-builder--content"},d),l.default.createElement("div",{className:"flow-builder--io flow-builder--io-top"},"Group"!==r.parent&&u.map((({name:t,children:n,style:r})=>l.default.createElement("div",{className:"flow-builder--io-port",key:t,"data-name":`${e.name}.${t}`,style:r},n)))),l.default.createElement("div",{className:"flow-builder--io flow-builder--io-bottom"},"Group"!==r.parent&&c.map((({name:t,children:n,style:r})=>l.default.createElement("div",{className:"flow-builder--io-port",key:t,"data-name":`${e.name}.${t}`,style:r},n)))))}));e.Graph=({children:e})=>e?l.default.createElement("div",{"data-type":"graph",className:"flow-builder"},e):null,e.Group=e=>{if(!e.children)return null;const{inputs:n,outputs:r,remainder:u}=i(e.children),s=[e.onMouseEnter,e.onMouseLeave],c=t.useRef(null),[d]=t.useState({value:!1}),m=t.useCallback((t=>{var n,l,r;const o=null===(n=c.current)||void 0===n?void 0:n.getBoundingClientRect();if(!o)return!1;const a=t.clientX,u=t.clientY,s=o.x<a&&o.y<u&&o.x+o.width>a&&o.y+o.height>u;s!==d.value&&(d.value=s,d.value?null===(l=e.onMouseEnter)||void 0===l||l.call(e):null===(r=e.onMouseLeave)||void 0===r||r.call(e))}),s);return t.useEffect((()=>(window.addEventListener("mousemove",m,{passive:!0}),()=>window.removeEventListener("mousemove",m))),s),l.default.createElement(f.Provider,{value:{parent:"Group"}},l.default.createElement("div",{ref:c,"data-type":"group","data-name":e.name,className:a("flow-builder--group",[e.className,!!e.className]),style:Object.assign(Object.assign({},e.style),e.position?o.from(e.position).css():{})},l.default.createElement("div",{className:"flow-builder--content"},u),l.default.createElement("div",{className:"flow-builder--io flow-builder--io-top"},n.map((({name:t,children:n,style:r})=>l.default.createElement("div",{className:"flow-builder--io-port",key:t,"data-name":`${e.name}.${t}`,style:r},n)))),l.default.createElement("div",{className:"flow-builder--io flow-builder--io-bottom"},r.map((({name:t,children:n,style:r})=>l.default.createElement("div",{className:"flow-builder--io-port",key:t,"data-name":`${e.name}.${t}`,style:r},n))))))},e.Input=c,e.Node=m,e.Output=d,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Flow={},e.React)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=n(t);class r{constructor(e,t){this.x=e,this.y=t}subtract(e){return new r(this.x-e.x,this.y-e.y)}dist(e){return Math.hypot(e.x-this.x,e.y-this.y)}css(){return{left:`${this.x}px`,top:`${this.y}px`}}array(){return[this.x,this.y]}}const o=(e=0,t=0)=>new r(e,t);o.from=e=>e instanceof MouseEvent?new r(e.clientX,e.clientY):new r(e[0],e[1]),o.offsetOf=e=>new r(e.left,e.top);const a=(...e)=>e.map((e=>"string"==typeof e?e:e[1]?e[0]:null)).filter((e=>null!==e)).join(" "),u=(e,t)=>{let n=[];for(let l=0,r=e.length;l<r;++l){const r=e[l];t(r,l,e)?n.push(r):e[l-n.length]=r}return e.length-=n.length,n};function s(...e){return t=>{for(let n=0;n<e.length;++n){const l=e[n];l&&("function"==typeof l?l(t):l.current=t)}}}const i=e=>{const n=t.Children.toArray(e);return{remainder:n,inputs:u(n,(e=>{var t;return null===(t=null==e?void 0:e.type)||void 0===t?void 0:t._$isInput})).map((e=>e.props)),outputs:u(n,(e=>{var t;return null===(t=null==e?void 0:e.type)||void 0===t?void 0:t._$isOutput})).map((e=>e.props))}},c=e=>null,d=e=>null;c._$isInput=!0,d._$isOutput=!0;const f=t.createContext({parent:null});const m=l.default.forwardRef(((e,n)=>{if(!e.children)return null;const r=t.useContext(f),{inputs:u,outputs:c,remainder:d}=i(e.children);"Group"===r.parent&&(u.length>0||c.length>0)&&console.warn("flow-builder: Inputs/Outputs on Nodes within Groups are ignored");const[m,p]=function({onDragStart:e,onDragMove:n,onDragEnd:l,onSelect:r}){const a=[e,n,l,r],[u]=t.useState({start:null,current:null,node:null,container:null}),s=()=>u.container?o.offsetOf(u.container.getBoundingClientRect()):o();return t.useEffect((()=>{const t=t=>{if(!u.start)return;t.preventDefault();const l=o.from(t),r=l.subtract(s());u.current?(u.current=r,null==n||n(r.array(),l.array())):u.start.dist(l)>20&&(u.current=r,null==e||e(r.array()))},a=e=>{const t=o.from(e).subtract(s());(u.current||u.start)&&e.preventDefault(),u.current?null==l||l(t.array()):u.start&&(null==r||r()),u.start=null,u.current=null};return window.addEventListener("mousemove",t),window.addEventListener("mouseup",a),()=>{window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",a)}}),a),[t.useCallback((e=>{e&&u.node!==e&&(u.node=e,u.container=function(e,t){for(const n of function*(e){let t=e.parentElement;for(;t;)yield t,t=t.parentElement}(e))if(t(n))return n;return null}(e,(e=>"div"===e.tagName.toLowerCase()&&"graph"===e.dataset.type&&e.classList.contains("flow-builder"))))}),a),t.useCallback((e=>{u.start=o(e.clientX,e.clientY)}),a)]}(e.draggable?e:{onSelect:e.onSelect});return l.default.createElement("div",{ref:s(m,n),"data-type":"node","data-name":e.name,className:a("flow-builder--node",[e.className,!!e.className]),style:Object.assign(Object.assign({},e.style),e.position?o.from(e.position).css():{}),onMouseDown:p,tabIndex:e.onSelect&&0,onKeyDown:t=>{var n;return"Enter"===t.key&&(null===(n=e.onSelect)||void 0===n?void 0:n.call(e))},role:e.onSelect&&"button"},l.default.createElement("div",{className:"flow-builder--content"},d),l.default.createElement("div",{className:"flow-builder--io flow-builder--io-top"},"Group"!==r.parent&&u.map((({name:t,children:n,style:r})=>l.default.createElement("div",{className:"flow-builder--io-port",key:t,"data-name":`${e.name}.${t}`,style:r},n)))),l.default.createElement("div",{className:"flow-builder--io flow-builder--io-bottom"},"Group"!==r.parent&&c.map((({name:t,children:n,style:r})=>l.default.createElement("div",{className:"flow-builder--io-port",key:t,"data-name":`${e.name}.${t}`,style:r},n)))))}));e.Graph=({children:e})=>e?l.default.createElement("div",{"data-type":"graph",className:"flow-builder"},e):null,e.Group=e=>{if(!e.children)return null;const{inputs:n,outputs:r,remainder:u}=i(e.children),s=[e.onMouseEnter,e.onMouseLeave],c=t.useRef(null),[d]=t.useState({value:!1}),m=t.useCallback((t=>{var n,l,r;const o=null===(n=c.current)||void 0===n?void 0:n.getBoundingClientRect();if(!o)return!1;const a=t.clientX,u=t.clientY,s=o.x<a&&o.y<u&&o.x+o.width>a&&o.y+o.height>u;s!==d.value&&(d.value=s,d.value?null===(l=e.onMouseEnter)||void 0===l||l.call(e):null===(r=e.onMouseLeave)||void 0===r||r.call(e))}),s);return t.useEffect((()=>(window.addEventListener("mousemove",m,{passive:!0}),()=>window.removeEventListener("mousemove",m))),s),l.default.createElement(f.Provider,{value:{parent:"Group"}},l.default.createElement("div",{ref:c,"data-type":"group","data-name":e.name,className:a("flow-builder--group",[e.className,!!e.className]),style:Object.assign(Object.assign({},e.style),e.position?o.from(e.position).css():{})},l.default.createElement("div",{className:"flow-builder--content"},u),l.default.createElement("div",{className:"flow-builder--io flow-builder--io-top"},n.map((({name:t,children:n,style:r})=>l.default.createElement("div",{className:"flow-builder--io-port",key:t,"data-name":`${e.name}.${t}`,style:r},n)))),l.default.createElement("div",{className:"flow-builder--io flow-builder--io-bottom"},r.map((({name:t,children:n,style:r})=>l.default.createElement("div",{className:"flow-builder--io-port",key:t,"data-name":`${e.name}.${t}`,style:r},n))))))},e.Input=c,e.Node=m,e.Output=d,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.js.map
{
"name": "@keboola/flow-builder",
"description": "Flow graph rendering",
"version": "0.5.5",
"version": "0.5.6",
"license": "MIT",

@@ -6,0 +6,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc