@ebay/nice-dag-react 1.0.10 → 1.0.11
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/README.md +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.js +27 -27
- package/lib/index.umd.cjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# nice-dag-react
|
|
2
2
|
[](https://www.npmjs.com/package/@ebay/nice-dag-react)
|
|
3
3
|
[](https://www.npmjs.com/package/@ebay/nice-dag-react)
|
|
4
|
-
[](https://opensource.ebay.com/nice-dag/examples/index.html)
|
|
4
|
+
[](https://opensource.ebay.com/nice-dag/examples/react/index.html)
|
|
5
5
|
[](https://github.com/eBay/nice-dag/blob/main/LICENSE.md)
|
|
6
6
|
|
|
7
7
|
## What is nice-dag-react?
|
package/lib/index.cjs
CHANGED
|
@@ -24,4 +24,4 @@ Check the render method of \``+e+"`."}return""}}function or(e){{if(e!==void 0){v
|
|
|
24
24
|
|
|
25
25
|
Check your code at `+r+":"+t+"."}return""}}var we={};function ir(e){{var r=Pe();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+t+">.")}return r}}function Se(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=ir(r);if(we[t])return;we[t]=!0;var n="";e&&e._owner&&e._owner!==te.current&&(n=" It was passed a child from "+j(e._owner.type)+"."),F(e),f('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),F(null)}}function xe(e,r){{if(typeof e!="object")return;if(ee(e))for(var t=0;t<e.length;t++){var n=e[t];ae(n)&&Se(n,r)}else if(ae(e))e._store&&(e._store.validated=!0);else if(e){var u=U(e);if(typeof u=="function"&&u!==e.entries)for(var c=u.call(e),o;!(o=c.next()).done;)ae(o.value)&&Se(o.value,r)}}}function ur(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===p||r.$$typeof===s))t=r.propTypes;else return;if(t){var n=j(r);Ge(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!ne){ne=!0;var u=j(r);f("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",u||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&f("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function sr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){F(e),f("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),F(null);break}}e.ref!==null&&(F(e),f("Invalid attribute `ref` supplied to `React.Fragment`."),F(null))}}function je(e,r,t,n,u,c){{var o=Me(e);if(!o){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var h=or(u);h?a+=h:a+=Pe();var d;e===null?d="null":ee(e)?d="array":e!==void 0&&e.$$typeof===l?(d="<"+(j(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):d=typeof e,f("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",d,a)}var v=ar(e,r,t,u,c);if(v==null)return v;if(o){var _=r.children;if(_!==void 0)if(n)if(ee(_)){for(var A=0;A<_.length;A++)xe(_[A],e);Object.freeze&&Object.freeze(_)}else f("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else xe(_,e)}return e===E?sr(v):ur(v),v}}function cr(e,r,t){return je(e,r,t,!0)}function lr(e,r,t){return je(e,r,t,!1)}var fr=lr,dr=cr;L.Fragment=E,L.jsx=fr,L.jsxs=dr}()),L}(function(i){process.env.NODE_ENV==="production"?i.exports=hr():i.exports=mr()})(ue);const se=ue.exports.Fragment,I=ue.exports.jsx;class Ae extends V.default.Component{render(){if(this.props.niceDag&&this.props.node.ref){const l=this.props.niceDag.getElementByNodeId(this.props.node.id);if(l)return ie.default.createPortal(I(se,{children:this.props.render(this.props)}),l)}return null}}class Ie extends V.default.Component{render(){return this.props.niceDag&&this.props.edge.ref?ie.default.createPortal(I(se,{children:this.props.render(this.props)}),this.props.edge.ref):null}}class Er extends V.default.Component{render(){if(this.props.niceDag){const l=this.props.niceDag.getRootContentElement();return ie.default.createPortal(I(se,{children:this.props.render(this.props.niceDag)}),l)}return null}}function br(i){const l=m.useCallback(()=>{i.remove()},[i]),D=m.useCallback((E,y=40)=>{i.insertNodes(E,y)},[i]);return{onEdgeRemove:l,onNodeInsert:D}}function Rr({node:i,niceDag:l}){const D=m.useCallback(()=>{i.remove()},[i]),E=m.useCallback(O=>{l.startEdgeDragging(i,O)},[l,i]),y=m.useCallback(O=>{l.startNodeDragging(i,O)},[l,i]);return{onNodeRemove:D,startEdgeDragging:E,startNodeDragging:y}}function _r(i){const{initNodes:l}=i;if(!l)throw new Error("initNodes can't be undefined!")}function yr(i){_r(i);const{onMount:l,renderNode:D,renderRootView:E,renderEdge:y,scrollPosition:O,initNodes:C,minimapConfig:P,...p}=i,w=m.useRef(null),g=m.useRef(null),s=m.useRef(null),T=m.useRef(),[R,S]=m.useState(0),K=m.useCallback(()=>{s.current&&s.current.destory()},[S]),U=m.useMemo(()=>({onChange:()=>{S(R+1)}}),[S,R]);return m.useEffect(()=>{if(T.current!==C){if(!s.current){const b=gr.default.init({container:w.current,minimapContainer:g.current,minimapConfig:P,...p},i.editable);s.current=b}s.current.withNodes(C).render(),S(R+1),T.current=C,l&&l()}return s.current.addNiceDagChangeListener(U),()=>{s.current.removeNiceDagChangeListener(U)}},[C,S,R,l]),m.useEffect(()=>(s.current&&s.current.isDestoried&&(s.current.withNodes(C).render(),S(R+1)),()=>{s.current&&s.current.destory()}),[]),{niceDag:s.current,niceDagEl:w,minimapEl:g,render:()=>{if(s.current){const b=s.current.getAllNodes();let f=(b==null?void 0:b.length)>0?b.map(x=>I(Ae,{render:D,node:x,niceDag:s.current,patchVersion:R},x.id)):null;if(E&&(f=[...f,I(Er,{niceDag:s.current,render:E})]),y){const x=s.current.getAllEdges(),H=(x==null?void 0:x.length)>0?x.map($=>I(Ie,{render:y,edge:$,patchVersion:R,niceDag:s.current},`edge-${$.source.id}-${$.target.id}`)):[];f=[...f,...H]}return f}return null},reset:K}}exports.NiceDagEdge=Ie;exports.NiceDagNode=Ae;exports.useNiceDag=yr;exports.useNiceDagEdge=br;exports.useNiceDagNode=Rr;
|
|
27
|
+
Check the top-level render call using <`+t+">.")}return r}}function Se(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=ir(r);if(we[t])return;we[t]=!0;var n="";e&&e._owner&&e._owner!==te.current&&(n=" It was passed a child from "+j(e._owner.type)+"."),F(e),f('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),F(null)}}function xe(e,r){{if(typeof e!="object")return;if(ee(e))for(var t=0;t<e.length;t++){var n=e[t];ae(n)&&Se(n,r)}else if(ae(e))e._store&&(e._store.validated=!0);else if(e){var u=U(e);if(typeof u=="function"&&u!==e.entries)for(var c=u.call(e),o;!(o=c.next()).done;)ae(o.value)&&Se(o.value,r)}}}function ur(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===p||r.$$typeof===s))t=r.propTypes;else return;if(t){var n=j(r);Ge(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!ne){ne=!0;var u=j(r);f("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",u||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&f("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function sr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){F(e),f("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),F(null);break}}e.ref!==null&&(F(e),f("Invalid attribute `ref` supplied to `React.Fragment`."),F(null))}}function je(e,r,t,n,u,c){{var o=Me(e);if(!o){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var h=or(u);h?a+=h:a+=Pe();var d;e===null?d="null":ee(e)?d="array":e!==void 0&&e.$$typeof===l?(d="<"+(j(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):d=typeof e,f("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",d,a)}var v=ar(e,r,t,u,c);if(v==null)return v;if(o){var _=r.children;if(_!==void 0)if(n)if(ee(_)){for(var A=0;A<_.length;A++)xe(_[A],e);Object.freeze&&Object.freeze(_)}else f("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else xe(_,e)}return e===E?sr(v):ur(v),v}}function cr(e,r,t){return je(e,r,t,!0)}function lr(e,r,t){return je(e,r,t,!1)}var fr=lr,dr=cr;L.Fragment=E,L.jsx=fr,L.jsxs=dr}()),L}(function(i){process.env.NODE_ENV==="production"?i.exports=hr():i.exports=mr()})(ue);const se=ue.exports.Fragment,I=ue.exports.jsx;class Ae extends V.default.Component{render(){if(this.props.niceDag&&this.props.node.ref){const l=this.props.niceDag.getElementByNodeId(this.props.node.id);if(l)return ie.default.createPortal(I(se,{children:this.props.render(this.props)}),l)}return null}}class Ie extends V.default.Component{render(){return this.props.niceDag&&this.props.edge.ref?ie.default.createPortal(I(se,{children:this.props.render(this.props)}),this.props.edge.ref):null}}class Er extends V.default.Component{render(){if(this.props.niceDag){const l=this.props.niceDag.getRootContentElement();return ie.default.createPortal(I(se,{children:this.props.render(this.props.niceDag)}),l)}return null}}function br(i){const l=m.useCallback(()=>{i.remove()},[i]),D=m.useCallback((E,y=40)=>{i.insertNodes(E,y)},[i]);return{onEdgeRemove:l,onNodeInsert:D}}function Rr({node:i,niceDag:l}){const D=m.useCallback(()=>{i.remove()},[i]),E=m.useCallback(O=>{l.startEdgeDragging(i,O)},[l,i]),y=m.useCallback(O=>{l.startNodeDragging(i,O)},[l,i]);return{onNodeRemove:D,startEdgeDragging:E,startNodeDragging:y}}function _r(i){const{initNodes:l}=i;if(!l)throw new Error("initNodes can't be undefined!")}function yr(i){_r(i);const{onMount:l,renderNode:D,renderRootView:E,renderEdge:y,scrollPosition:O,initNodes:C,minimapConfig:P,...p}=i,w=m.useRef(null),g=m.useRef(null),s=m.useRef(null),T=m.useRef(),[R,S]=m.useState(0),K=m.useCallback(()=>{s.current&&s.current.destory()},[S]),U=m.useMemo(()=>({onChange:()=>{S(R+1)}}),[S,R]);return m.useEffect(()=>{if(T.current!==C){if(!s.current){const b=gr.default.init({container:w.current,minimapContainer:g.current,minimapConfig:P,...p},i.editable);s.current=b}s.current.withNodes(C).render(),S(R+1),T.current=C,l&&l()}return s.current.addNiceDagChangeListener(U),()=>{s.current.removeNiceDagChangeListener(U)}},[C,S,R,l]),m.useEffect(()=>(s.current&&s.current.isDestoried&&(s.current.withNodes(C).render(),S(R+1)),()=>{s.current&&s.current.destory()}),[]),{niceDag:s.current,niceDagEl:w,minimapEl:g,render:()=>{if(s.current){const b=s.current.getAllNodes();let f=(b==null?void 0:b.length)>0?b.map(x=>I(Ae,{render:D,node:x,niceDag:s.current,patchVersion:R},x.id)):null;if(E&&(f=[...f,I(Er,{niceDag:s.current,render:E},"root-view")]),y){const x=s.current.getAllEdges(),H=(x==null?void 0:x.length)>0?x.map($=>I(Ie,{render:y,edge:$,patchVersion:R,niceDag:s.current},`edge-${$.source.id}-${$.target.id}`)):[];f=[...f,...H]}return f}return null},reset:K}}exports.NiceDagEdge=Ie;exports.NiceDagNode=Ae;exports.useNiceDag=yr;exports.useNiceDagEdge=br;exports.useNiceDagNode=Rr;
|
package/lib/index.js
CHANGED
|
@@ -16,16 +16,16 @@ function gr() {
|
|
|
16
16
|
if (Fe)
|
|
17
17
|
return V;
|
|
18
18
|
Fe = 1;
|
|
19
|
-
var s = M, l = Symbol.for("react.element"), T = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, y = s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
|
|
20
|
-
function _(
|
|
19
|
+
var s = M, l = Symbol.for("react.element"), T = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, y = s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, w = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
20
|
+
function _(P, p, O) {
|
|
21
21
|
var g, u = {}, C = null, R = null;
|
|
22
22
|
O !== void 0 && (C = "" + O), p.key !== void 0 && (C = "" + p.key), p.ref !== void 0 && (R = p.ref);
|
|
23
23
|
for (g in p)
|
|
24
|
-
m.call(p, g) && !
|
|
25
|
-
if (
|
|
26
|
-
for (g in p =
|
|
24
|
+
m.call(p, g) && !w.hasOwnProperty(g) && (u[g] = p[g]);
|
|
25
|
+
if (P && P.defaultProps)
|
|
26
|
+
for (g in p = P.defaultProps, p)
|
|
27
27
|
u[g] === void 0 && (u[g] = p[g]);
|
|
28
|
-
return { $$typeof: l, type:
|
|
28
|
+
return { $$typeof: l, type: P, key: C, ref: R, props: u, _owner: y.current };
|
|
29
29
|
}
|
|
30
30
|
return V.Fragment = T, V.jsx = _, V.jsxs = _, V;
|
|
31
31
|
}
|
|
@@ -42,7 +42,7 @@ var L = {};
|
|
|
42
42
|
var Ae;
|
|
43
43
|
function hr() {
|
|
44
44
|
return Ae || (Ae = 1, process.env.NODE_ENV !== "production" && function() {
|
|
45
|
-
var s = M, l = Symbol.for("react.element"), T = Symbol.for("react.portal"), m = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"),
|
|
45
|
+
var s = M, l = Symbol.for("react.element"), T = Symbol.for("react.portal"), m = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), w = Symbol.for("react.profiler"), _ = Symbol.for("react.provider"), P = Symbol.for("react.context"), p = Symbol.for("react.forward_ref"), O = Symbol.for("react.suspense"), g = Symbol.for("react.suspense_list"), u = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), R = Symbol.for("react.offscreen"), D = Symbol.iterator, H = "@@iterator";
|
|
46
46
|
function U(e) {
|
|
47
47
|
if (e === null || typeof e != "object")
|
|
48
48
|
return null;
|
|
@@ -70,7 +70,7 @@ function hr() {
|
|
|
70
70
|
var X = !1, $ = !1, Ie = !1, $e = !1, We = !1, ce;
|
|
71
71
|
ce = Symbol.for("react.module.reference");
|
|
72
72
|
function Ye(e) {
|
|
73
|
-
return !!(typeof e == "string" || typeof e == "function" || e === m || e ===
|
|
73
|
+
return !!(typeof e == "string" || typeof e == "function" || e === m || e === w || We || e === y || e === O || e === g || $e || e === R || X || $ || Ie || typeof e == "object" && e !== null && (e.$$typeof === C || e.$$typeof === u || e.$$typeof === _ || e.$$typeof === P || e.$$typeof === p || e.$$typeof === ce || e.getModuleId !== void 0));
|
|
74
74
|
}
|
|
75
75
|
function Ve(e, r, t) {
|
|
76
76
|
var n = e.displayName;
|
|
@@ -94,7 +94,7 @@ function hr() {
|
|
|
94
94
|
return "Fragment";
|
|
95
95
|
case T:
|
|
96
96
|
return "Portal";
|
|
97
|
-
case
|
|
97
|
+
case w:
|
|
98
98
|
return "Profiler";
|
|
99
99
|
case y:
|
|
100
100
|
return "StrictMode";
|
|
@@ -105,7 +105,7 @@ function hr() {
|
|
|
105
105
|
}
|
|
106
106
|
if (typeof e == "object")
|
|
107
107
|
switch (e.$$typeof) {
|
|
108
|
-
case
|
|
108
|
+
case P:
|
|
109
109
|
var r = e;
|
|
110
110
|
return le(r) + ".Consumer";
|
|
111
111
|
case _:
|
|
@@ -371,7 +371,7 @@ function hr() {
|
|
|
371
371
|
ref: !0,
|
|
372
372
|
__self: !0,
|
|
373
373
|
__source: !0
|
|
374
|
-
}, Te,
|
|
374
|
+
}, Te, we, te;
|
|
375
375
|
te = {};
|
|
376
376
|
function Xe(e) {
|
|
377
377
|
if (G.call(e, "ref")) {
|
|
@@ -409,7 +409,7 @@ function hr() {
|
|
|
409
409
|
function rr(e, r) {
|
|
410
410
|
{
|
|
411
411
|
var t = function() {
|
|
412
|
-
|
|
412
|
+
we || (we = !0, f("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
|
|
413
413
|
};
|
|
414
414
|
t.isReactWarning = !0, Object.defineProperty(e, "ref", {
|
|
415
415
|
get: t,
|
|
@@ -461,13 +461,13 @@ function hr() {
|
|
|
461
461
|
return tr(e, a, h, i, n, Y.current, o);
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
-
var ne = E.ReactCurrentOwner,
|
|
464
|
+
var ne = E.ReactCurrentOwner, Pe = E.ReactDebugCurrentFrame;
|
|
465
465
|
function N(e) {
|
|
466
466
|
if (e) {
|
|
467
467
|
var r = e._owner, t = J(e.type, e._source, r ? r.type : null);
|
|
468
|
-
|
|
468
|
+
Pe.setExtraStackFrame(t);
|
|
469
469
|
} else
|
|
470
|
-
|
|
470
|
+
Pe.setExtraStackFrame(null);
|
|
471
471
|
}
|
|
472
472
|
var ae;
|
|
473
473
|
ae = !1;
|
|
@@ -662,16 +662,16 @@ function Tr(s) {
|
|
|
662
662
|
onNodeInsert: T
|
|
663
663
|
};
|
|
664
664
|
}
|
|
665
|
-
function
|
|
665
|
+
function wr({
|
|
666
666
|
node: s,
|
|
667
667
|
niceDag: l
|
|
668
668
|
}) {
|
|
669
669
|
const T = A(() => {
|
|
670
670
|
s.remove();
|
|
671
|
-
}, [s]), m = A((
|
|
672
|
-
l.startEdgeDragging(s,
|
|
673
|
-
}, [l, s]), y = A((
|
|
674
|
-
l.startNodeDragging(s,
|
|
671
|
+
}, [s]), m = A((w) => {
|
|
672
|
+
l.startEdgeDragging(s, w);
|
|
673
|
+
}, [l, s]), y = A((w) => {
|
|
674
|
+
l.startNodeDragging(s, w);
|
|
675
675
|
}, [l, s]);
|
|
676
676
|
return {
|
|
677
677
|
onNodeRemove: T,
|
|
@@ -686,16 +686,16 @@ function br(s) {
|
|
|
686
686
|
if (!l)
|
|
687
687
|
throw new Error("initNodes can't be undefined!");
|
|
688
688
|
}
|
|
689
|
-
function
|
|
689
|
+
function Pr(s) {
|
|
690
690
|
br(s);
|
|
691
691
|
const {
|
|
692
692
|
onMount: l,
|
|
693
693
|
renderNode: T,
|
|
694
694
|
renderRootView: m,
|
|
695
695
|
renderEdge: y,
|
|
696
|
-
scrollPosition:
|
|
696
|
+
scrollPosition: w,
|
|
697
697
|
initNodes: _,
|
|
698
|
-
minimapConfig:
|
|
698
|
+
minimapConfig: P,
|
|
699
699
|
...p
|
|
700
700
|
} = s, O = K(null), g = K(null), u = K(null), C = K(), [R, D] = dr(0), H = A(() => {
|
|
701
701
|
u.current && u.current.destory();
|
|
@@ -710,7 +710,7 @@ function wr(s) {
|
|
|
710
710
|
const E = pr.init({
|
|
711
711
|
container: O.current,
|
|
712
712
|
minimapContainer: g.current,
|
|
713
|
-
minimapConfig:
|
|
713
|
+
minimapConfig: P,
|
|
714
714
|
...p
|
|
715
715
|
}, s.editable);
|
|
716
716
|
u.current = E;
|
|
@@ -738,7 +738,7 @@ function wr(s) {
|
|
|
738
738
|
if (m && (f = [...f, /* @__PURE__ */ I(Rr, {
|
|
739
739
|
niceDag: u.current,
|
|
740
740
|
render: m
|
|
741
|
-
})]), y) {
|
|
741
|
+
}, "root-view")]), y) {
|
|
742
742
|
const S = u.current.getAllEdges(), X = (S == null ? void 0 : S.length) > 0 ? S.map(($) => /* @__PURE__ */ I(Er, {
|
|
743
743
|
render: y,
|
|
744
744
|
edge: $,
|
|
@@ -757,7 +757,7 @@ function wr(s) {
|
|
|
757
757
|
export {
|
|
758
758
|
Er as NiceDagEdge,
|
|
759
759
|
mr as NiceDagNode,
|
|
760
|
-
|
|
760
|
+
Pr as useNiceDag,
|
|
761
761
|
Tr as useNiceDagEdge,
|
|
762
|
-
|
|
762
|
+
wr as useNiceDagNode
|
|
763
763
|
};
|
package/lib/index.umd.cjs
CHANGED
|
@@ -24,4 +24,4 @@ Check the render method of \``+e+"`."}return""}}function hr(e){{if(e!==void 0){v
|
|
|
24
24
|
|
|
25
25
|
Check your code at `+r+":"+t+"."}return""}}var ke={};function mr(e){{var r=Ne();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+t+">.")}return r}}function Fe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=mr(r);if(ke[t])return;ke[t]=!0;var n="";e&&e._owner&&e._owner!==ue.current&&(n=" It was passed a child from "+N(e._owner.type)+"."),I(e),l('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),I(null)}}function Ae(e,r){{if(typeof e!="object")return;if(ie(e))for(var t=0;t<e.length;t++){var n=e[t];ce(n)&&Fe(n,r)}else if(ce(e))e._store&&(e._store.validated=!0);else if(e){var u=q(e);if(typeof u=="function"&&u!==e.entries)for(var c=u.call(e),i;!(i=c.next()).done;)ce(i.value)&&Fe(i.value,r)}}}function Er(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===g||r.$$typeof===s))t=r.propTypes;else return;if(t){var n=N(r);ar(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!se){se=!0;var u=N(r);l("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",u||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&l("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function br(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){I(e),l("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),I(null);break}}e.ref!==null&&(I(e),l("Invalid attribute `ref` supplied to `React.Fragment`."),I(null))}}function Ie(e,r,t,n,u,c){{var i=Xe(e);if(!i){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var m=hr(u);m?a+=m:a+=Ne();var d;e===null?d="null":ie(e)?d="array":e!==void 0&&e.$$typeof===f?(d="<"+(N(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):d=typeof e,l("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",d,a)}var v=gr(e,r,t,u,c);if(v==null)return v;if(i){var R=r.children;if(R!==void 0)if(n)if(ie(R)){for(var $=0;$<R.length;$++)Ae(R[$],e);Object.freeze&&Object.freeze(R)}else l("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ae(R,e)}return e===b?br(v):Er(v),v}}function yr(e,r,t){return Ie(e,r,t,!0)}function _r(e,r,t){return Ie(e,r,t,!1)}var Rr=_r,Cr=yr;M.Fragment=b,M.jsx=Rr,M.jsxs=Cr}()),M}(function(o){process.env.NODE_ENV==="production"?o.exports=Le():o.exports=Ve()})(Z);const Q=Z.exports.Fragment,A=Z.exports.jsx;class de extends W.default.Component{render(){if(this.props.niceDag&&this.props.node.ref){const f=this.props.niceDag.getElementByNodeId(this.props.node.id);if(f)return X.default.createPortal(A(Q,{children:this.props.render(this.props)}),f)}return null}}class ve extends W.default.Component{render(){return this.props.niceDag&&this.props.edge.ref?X.default.createPortal(A(Q,{children:this.props.render(this.props)}),this.props.edge.ref):null}}class Ue extends W.default.Component{render(){if(this.props.niceDag){const f=this.props.niceDag.getRootContentElement();return X.default.createPortal(A(Q,{children:this.props.render(this.props.niceDag)}),f)}return null}}function qe(o){const f=p.useCallback(()=>{o.remove()},[o]),O=p.useCallback((b,C=40)=>{o.insertNodes(b,C)},[o]);return{onEdgeRemove:f,onNodeInsert:O}}function Be({node:o,niceDag:f}){const O=p.useCallback(()=>{o.remove()},[o]),b=p.useCallback(P=>{f.startEdgeDragging(o,P)},[f,o]),C=p.useCallback(P=>{f.startNodeDragging(o,P)},[f,o]);return{onNodeRemove:O,startEdgeDragging:b,startNodeDragging:C}}function Je(o){const{initNodes:f}=o;if(!f)throw new Error("initNodes can't be undefined!")}function Ge(o){Je(o);const{onMount:f,renderNode:O,renderRootView:b,renderEdge:C,scrollPosition:P,initNodes:T,minimapConfig:w,...g}=o,S=p.useRef(null),h=p.useRef(null),s=p.useRef(null),D=p.useRef(),[_,j]=p.useState(0),ee=p.useCallback(()=>{s.current&&s.current.destory()},[j]),q=p.useMemo(()=>({onChange:()=>{j(_+1)}}),[j,_]);return p.useEffect(()=>{if(D.current!==T){if(!s.current){const y=Me.default.init({container:S.current,minimapContainer:h.current,minimapConfig:w,...g},o.editable);s.current=y}s.current.withNodes(T).render(),j(_+1),D.current=T,f&&f()}return s.current.addNiceDagChangeListener(q),()=>{s.current.removeNiceDagChangeListener(q)}},[T,j,_,f]),p.useEffect(()=>(s.current&&s.current.isDestoried&&(s.current.withNodes(T).render(),j(_+1)),()=>{s.current&&s.current.destory()}),[]),{niceDag:s.current,niceDagEl:S,minimapEl:h,render:()=>{if(s.current){const y=s.current.getAllNodes();let l=(y==null?void 0:y.length)>0?y.map(x=>A(de,{render:O,node:x,niceDag:s.current,patchVersion:_},x.id)):null;if(b&&(l=[...l,A(Ue,{niceDag:s.current,render:b})]),C){const x=s.current.getAllEdges(),re=(x==null?void 0:x.length)>0?x.map(L=>A(ve,{render:C,edge:L,patchVersion:_,niceDag:s.current},`edge-${L.source.id}-${L.target.id}`)):[];l=[...l,...re]}return l}return null},reset:ee}}E.NiceDagEdge=ve,E.NiceDagNode=de,E.useNiceDag=Ge,E.useNiceDagEdge=qe,E.useNiceDagNode=Be,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
27
|
+
Check the top-level render call using <`+t+">.")}return r}}function Fe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=mr(r);if(ke[t])return;ke[t]=!0;var n="";e&&e._owner&&e._owner!==ue.current&&(n=" It was passed a child from "+N(e._owner.type)+"."),I(e),l('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),I(null)}}function Ae(e,r){{if(typeof e!="object")return;if(ie(e))for(var t=0;t<e.length;t++){var n=e[t];ce(n)&&Fe(n,r)}else if(ce(e))e._store&&(e._store.validated=!0);else if(e){var u=q(e);if(typeof u=="function"&&u!==e.entries)for(var c=u.call(e),i;!(i=c.next()).done;)ce(i.value)&&Fe(i.value,r)}}}function Er(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===g||r.$$typeof===s))t=r.propTypes;else return;if(t){var n=N(r);ar(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!se){se=!0;var u=N(r);l("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",u||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&l("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function br(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){I(e),l("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),I(null);break}}e.ref!==null&&(I(e),l("Invalid attribute `ref` supplied to `React.Fragment`."),I(null))}}function Ie(e,r,t,n,u,c){{var i=Xe(e);if(!i){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var m=hr(u);m?a+=m:a+=Ne();var d;e===null?d="null":ie(e)?d="array":e!==void 0&&e.$$typeof===f?(d="<"+(N(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):d=typeof e,l("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",d,a)}var v=gr(e,r,t,u,c);if(v==null)return v;if(i){var R=r.children;if(R!==void 0)if(n)if(ie(R)){for(var $=0;$<R.length;$++)Ae(R[$],e);Object.freeze&&Object.freeze(R)}else l("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ae(R,e)}return e===b?br(v):Er(v),v}}function yr(e,r,t){return Ie(e,r,t,!0)}function _r(e,r,t){return Ie(e,r,t,!1)}var Rr=_r,Cr=yr;M.Fragment=b,M.jsx=Rr,M.jsxs=Cr}()),M}(function(o){process.env.NODE_ENV==="production"?o.exports=Le():o.exports=Ve()})(Z);const Q=Z.exports.Fragment,A=Z.exports.jsx;class de extends W.default.Component{render(){if(this.props.niceDag&&this.props.node.ref){const f=this.props.niceDag.getElementByNodeId(this.props.node.id);if(f)return X.default.createPortal(A(Q,{children:this.props.render(this.props)}),f)}return null}}class ve extends W.default.Component{render(){return this.props.niceDag&&this.props.edge.ref?X.default.createPortal(A(Q,{children:this.props.render(this.props)}),this.props.edge.ref):null}}class Ue extends W.default.Component{render(){if(this.props.niceDag){const f=this.props.niceDag.getRootContentElement();return X.default.createPortal(A(Q,{children:this.props.render(this.props.niceDag)}),f)}return null}}function qe(o){const f=p.useCallback(()=>{o.remove()},[o]),O=p.useCallback((b,C=40)=>{o.insertNodes(b,C)},[o]);return{onEdgeRemove:f,onNodeInsert:O}}function Be({node:o,niceDag:f}){const O=p.useCallback(()=>{o.remove()},[o]),b=p.useCallback(P=>{f.startEdgeDragging(o,P)},[f,o]),C=p.useCallback(P=>{f.startNodeDragging(o,P)},[f,o]);return{onNodeRemove:O,startEdgeDragging:b,startNodeDragging:C}}function Je(o){const{initNodes:f}=o;if(!f)throw new Error("initNodes can't be undefined!")}function Ge(o){Je(o);const{onMount:f,renderNode:O,renderRootView:b,renderEdge:C,scrollPosition:P,initNodes:T,minimapConfig:w,...g}=o,S=p.useRef(null),h=p.useRef(null),s=p.useRef(null),D=p.useRef(),[_,j]=p.useState(0),ee=p.useCallback(()=>{s.current&&s.current.destory()},[j]),q=p.useMemo(()=>({onChange:()=>{j(_+1)}}),[j,_]);return p.useEffect(()=>{if(D.current!==T){if(!s.current){const y=Me.default.init({container:S.current,minimapContainer:h.current,minimapConfig:w,...g},o.editable);s.current=y}s.current.withNodes(T).render(),j(_+1),D.current=T,f&&f()}return s.current.addNiceDagChangeListener(q),()=>{s.current.removeNiceDagChangeListener(q)}},[T,j,_,f]),p.useEffect(()=>(s.current&&s.current.isDestoried&&(s.current.withNodes(T).render(),j(_+1)),()=>{s.current&&s.current.destory()}),[]),{niceDag:s.current,niceDagEl:S,minimapEl:h,render:()=>{if(s.current){const y=s.current.getAllNodes();let l=(y==null?void 0:y.length)>0?y.map(x=>A(de,{render:O,node:x,niceDag:s.current,patchVersion:_},x.id)):null;if(b&&(l=[...l,A(Ue,{niceDag:s.current,render:b},"root-view")]),C){const x=s.current.getAllEdges(),re=(x==null?void 0:x.length)>0?x.map(L=>A(ve,{render:C,edge:L,patchVersion:_,niceDag:s.current},`edge-${L.source.id}-${L.target.id}`)):[];l=[...l,...re]}return l}return null},reset:ee}}E.NiceDagEdge=ve,E.NiceDagNode=de,E.useNiceDag=Ge,E.useNiceDagEdge=qe,E.useNiceDagNode=Be,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ebay/nice-dag-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.cjs",
|
|
@@ -122,5 +122,5 @@
|
|
|
122
122
|
"test": "jest",
|
|
123
123
|
"release": "pnpm build && pnpm version patch && yarn publish"
|
|
124
124
|
},
|
|
125
|
-
"readme": "# nice-dag-react\n[](https://www.npmjs.com/package/@ebay/nice-dag-react)\n[](https://www.npmjs.com/package/@ebay/nice-dag-react)\n[](https://opensource.ebay.com/nice-dag/examples/index.html)\n[](https://github.com/eBay/nice-dag/blob/main/LICENSE.md)\n\n## What is nice-dag-react?\n\n`nice-dag-react` is a wrapper of DOM operations given by `nice-dag-core`. In terms of **React** based **DAG Diagram** or **Flow Editor**, you can simply use this customized **react hook** which is given by `nice-dag-react` module. \n\nFor more details, please you can visit [Doc Portal](https://opensource.ebay.com/nice-dag/docs/api-ref/useNiceDag).\n"
|
|
125
|
+
"readme": "# nice-dag-react\n[](https://www.npmjs.com/package/@ebay/nice-dag-react)\n[](https://www.npmjs.com/package/@ebay/nice-dag-react)\n[](https://opensource.ebay.com/nice-dag/examples/react/index.html)\n[](https://github.com/eBay/nice-dag/blob/main/LICENSE.md)\n\n## What is nice-dag-react?\n\n`nice-dag-react` is a wrapper of DOM operations given by `nice-dag-core`. In terms of **React** based **DAG Diagram** or **Flow Editor**, you can simply use this customized **react hook** which is given by `nice-dag-react` module. \n\nFor more details, please you can visit [Doc Portal](https://opensource.ebay.com/nice-dag/docs/api-ref/useNiceDag).\n"
|
|
126
126
|
}
|