@ebay/nice-dag-react 1.0.19 → 1.0.21
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/lib/index.cjs +1 -1
- package/lib/index.js +50 -50
- package/lib/index.umd.cjs +1 -1
- package/package.json +2 -2
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({node:this.props.node,niceDag:this.props.niceDag})}),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({edge:this.props.edge,niceDag:this.props.niceDag})}),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]),T=m.useCallback((E,y=40)=>{i.insertNodes(E,y)},[i]);return{onEdgeRemove:l,onNodeInsert:T}}function Rr({node:i,niceDag:l}){const T=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:T,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:T,renderRootView:E,renderEdge:y,scrollPosition:O,initNodes:C,minimapConfig:P,...p}=i,w=m.useRef(null),g=m.useRef(null),s=m.useRef(null),D=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(D.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),D.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:T,node:x,niceDag:s.current,patchVersion:R},x.id)):
|
|
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({node:this.props.node,niceDag:this.props.niceDag})}),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({edge:this.props.edge,niceDag:this.props.niceDag})}),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]),T=m.useCallback((E,y=40)=>{i.insertNodes(E,y)},[i]);return{onEdgeRemove:l,onNodeInsert:T}}function Rr({node:i,niceDag:l}){const T=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:T,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:T,renderRootView:E,renderEdge:y,scrollPosition:O,initNodes:C,minimapConfig:P,...p}=i,w=m.useRef(null),g=m.useRef(null),s=m.useRef(null),D=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(D.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),D.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:T,node:x,niceDag:s.current,patchVersion:R},x.id)):[];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,7 +16,7 @@ function gr() {
|
|
|
16
16
|
if (Fe)
|
|
17
17
|
return V;
|
|
18
18
|
Fe = 1;
|
|
19
|
-
var s = M,
|
|
19
|
+
var s = M, f = 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, D = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
20
20
|
function _(w, p, P) {
|
|
21
21
|
var g, u = {}, C = null, R = null;
|
|
22
22
|
P !== void 0 && (C = "" + P), p.key !== void 0 && (C = "" + p.key), p.ref !== void 0 && (R = p.ref);
|
|
@@ -25,7 +25,7 @@ function gr() {
|
|
|
25
25
|
if (w && w.defaultProps)
|
|
26
26
|
for (g in p = w.defaultProps, p)
|
|
27
27
|
u[g] === void 0 && (u[g] = p[g]);
|
|
28
|
-
return { $$typeof:
|
|
28
|
+
return { $$typeof: f, type: w, 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,
|
|
45
|
+
var s = M, f = Symbol.for("react.element"), T = Symbol.for("react.portal"), m = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), D = Symbol.for("react.profiler"), _ = Symbol.for("react.provider"), w = Symbol.for("react.context"), p = Symbol.for("react.forward_ref"), P = 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"), O = Symbol.iterator, H = "@@iterator";
|
|
46
46
|
function U(e) {
|
|
47
47
|
if (e === null || typeof e != "object")
|
|
48
48
|
return null;
|
|
@@ -50,7 +50,7 @@ function hr() {
|
|
|
50
50
|
return typeof r == "function" ? r : null;
|
|
51
51
|
}
|
|
52
52
|
var E = s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
53
|
-
function
|
|
53
|
+
function l(e) {
|
|
54
54
|
{
|
|
55
55
|
for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
|
|
56
56
|
t[n - 1] = arguments[n];
|
|
@@ -79,13 +79,13 @@ function hr() {
|
|
|
79
79
|
var i = r.displayName || r.name || "";
|
|
80
80
|
return i !== "" ? t + "(" + i + ")" : t;
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function fe(e) {
|
|
83
83
|
return e.displayName || "Context";
|
|
84
84
|
}
|
|
85
85
|
function x(e) {
|
|
86
86
|
if (e == null)
|
|
87
87
|
return null;
|
|
88
|
-
if (typeof e.tag == "number" &&
|
|
88
|
+
if (typeof e.tag == "number" && l("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
|
|
89
89
|
return e.displayName || e.name || null;
|
|
90
90
|
if (typeof e == "string")
|
|
91
91
|
return e;
|
|
@@ -107,10 +107,10 @@ function hr() {
|
|
|
107
107
|
switch (e.$$typeof) {
|
|
108
108
|
case w:
|
|
109
109
|
var r = e;
|
|
110
|
-
return
|
|
110
|
+
return fe(r) + ".Consumer";
|
|
111
111
|
case _:
|
|
112
112
|
var t = e;
|
|
113
|
-
return
|
|
113
|
+
return fe(t._context) + ".Provider";
|
|
114
114
|
case p:
|
|
115
115
|
return Ve(e, e.render, "ForwardRef");
|
|
116
116
|
case u:
|
|
@@ -127,14 +127,14 @@ function hr() {
|
|
|
127
127
|
}
|
|
128
128
|
return null;
|
|
129
129
|
}
|
|
130
|
-
var k = Object.assign, W = 0,
|
|
130
|
+
var k = Object.assign, W = 0, le, de, ve, pe, ge, he, me;
|
|
131
131
|
function Ee() {
|
|
132
132
|
}
|
|
133
133
|
Ee.__reactDisabledLog = !0;
|
|
134
134
|
function Le() {
|
|
135
135
|
{
|
|
136
136
|
if (W === 0) {
|
|
137
|
-
|
|
137
|
+
le = console.log, de = console.info, ve = console.warn, pe = console.error, ge = console.group, he = console.groupCollapsed, me = console.groupEnd;
|
|
138
138
|
var e = {
|
|
139
139
|
configurable: !0,
|
|
140
140
|
enumerable: !0,
|
|
@@ -164,7 +164,7 @@ function hr() {
|
|
|
164
164
|
};
|
|
165
165
|
Object.defineProperties(console, {
|
|
166
166
|
log: k({}, e, {
|
|
167
|
-
value:
|
|
167
|
+
value: le
|
|
168
168
|
}),
|
|
169
169
|
info: k({}, e, {
|
|
170
170
|
value: de
|
|
@@ -186,7 +186,7 @@ function hr() {
|
|
|
186
186
|
})
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
|
-
W < 0 &&
|
|
189
|
+
W < 0 && l("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
var Z = E.ReactCurrentDispatcher, Q;
|
|
@@ -338,7 +338,7 @@ function hr() {
|
|
|
338
338
|
} catch (d) {
|
|
339
339
|
a = d;
|
|
340
340
|
}
|
|
341
|
-
a && !(a instanceof Error) && (z(i),
|
|
341
|
+
a && !(a instanceof Error) && (z(i), l("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, o, typeof a), z(null)), a instanceof Error && !(a.message in be) && (be[a.message] = !0, z(i), l("Failed %s type: %s", t, a.message), z(null));
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
}
|
|
@@ -364,7 +364,7 @@ function hr() {
|
|
|
364
364
|
}
|
|
365
365
|
function Ce(e) {
|
|
366
366
|
if (Ke(e))
|
|
367
|
-
return
|
|
367
|
+
return l("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", ze(e)), _e(e);
|
|
368
368
|
}
|
|
369
369
|
var Y = E.ReactCurrentOwner, He = {
|
|
370
370
|
key: !0,
|
|
@@ -392,13 +392,13 @@ function hr() {
|
|
|
392
392
|
function Qe(e, r) {
|
|
393
393
|
if (typeof e.ref == "string" && Y.current && r && Y.current.stateNode !== r) {
|
|
394
394
|
var t = x(Y.current.type);
|
|
395
|
-
te[t] || (
|
|
395
|
+
te[t] || (l('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', x(Y.current.type), e.ref), te[t] = !0);
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
function er(e, r) {
|
|
399
399
|
{
|
|
400
400
|
var t = function() {
|
|
401
|
-
Te || (Te = !0,
|
|
401
|
+
Te || (Te = !0, l("%s: `key` 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));
|
|
402
402
|
};
|
|
403
403
|
t.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
404
404
|
get: t,
|
|
@@ -409,7 +409,7 @@ function hr() {
|
|
|
409
409
|
function rr(e, r) {
|
|
410
410
|
{
|
|
411
411
|
var t = function() {
|
|
412
|
-
De || (De = !0,
|
|
412
|
+
De || (De = !0, l("%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,
|
|
@@ -419,7 +419,7 @@ function hr() {
|
|
|
419
419
|
}
|
|
420
420
|
var tr = function(e, r, t, n, i, c, o) {
|
|
421
421
|
var a = {
|
|
422
|
-
$$typeof:
|
|
422
|
+
$$typeof: f,
|
|
423
423
|
type: e,
|
|
424
424
|
key: r,
|
|
425
425
|
ref: t,
|
|
@@ -472,7 +472,7 @@ function hr() {
|
|
|
472
472
|
var ae;
|
|
473
473
|
ae = !1;
|
|
474
474
|
function oe(e) {
|
|
475
|
-
return typeof e == "object" && e !== null && e.$$typeof ===
|
|
475
|
+
return typeof e == "object" && e !== null && e.$$typeof === f;
|
|
476
476
|
}
|
|
477
477
|
function Pe() {
|
|
478
478
|
{
|
|
@@ -520,7 +520,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
520
520
|
return;
|
|
521
521
|
Oe[t] = !0;
|
|
522
522
|
var n = "";
|
|
523
|
-
e && e._owner && e._owner !== ne.current && (n = " It was passed a child from " + x(e._owner.type) + "."), N(e),
|
|
523
|
+
e && e._owner && e._owner !== ne.current && (n = " It was passed a child from " + x(e._owner.type) + "."), N(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), N(null);
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
526
|
function xe(e, r) {
|
|
@@ -560,9 +560,9 @@ Check the top-level render call using <` + t + ">.");
|
|
|
560
560
|
} else if (r.PropTypes !== void 0 && !ae) {
|
|
561
561
|
ae = !0;
|
|
562
562
|
var i = x(r);
|
|
563
|
-
|
|
563
|
+
l("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", i || "Unknown");
|
|
564
564
|
}
|
|
565
|
-
typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved &&
|
|
565
|
+
typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && l("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
function ur(e) {
|
|
@@ -570,11 +570,11 @@ Check the top-level render call using <` + t + ">.");
|
|
|
570
570
|
for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
|
|
571
571
|
var n = r[t];
|
|
572
572
|
if (n !== "children" && n !== "key") {
|
|
573
|
-
N(e),
|
|
573
|
+
N(e), l("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), N(null);
|
|
574
574
|
break;
|
|
575
575
|
}
|
|
576
576
|
}
|
|
577
|
-
e.ref !== null && (N(e),
|
|
577
|
+
e.ref !== null && (N(e), l("Invalid attribute `ref` supplied to `React.Fragment`."), N(null));
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
580
|
function je(e, r, t, n, i, c) {
|
|
@@ -586,7 +586,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
586
586
|
var h = ar(i);
|
|
587
587
|
h ? a += h : a += Pe();
|
|
588
588
|
var d;
|
|
589
|
-
e === null ? d = "null" : re(e) ? d = "array" : e !== void 0 && e.$$typeof ===
|
|
589
|
+
e === null ? d = "null" : re(e) ? d = "array" : e !== void 0 && e.$$typeof === f ? (d = "<" + (x(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);
|
|
590
590
|
}
|
|
591
591
|
var v = nr(e, r, t, i, c);
|
|
592
592
|
if (v == null)
|
|
@@ -600,7 +600,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
600
600
|
xe(b[F], e);
|
|
601
601
|
Object.freeze && Object.freeze(b);
|
|
602
602
|
} else
|
|
603
|
-
|
|
603
|
+
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.");
|
|
604
604
|
else
|
|
605
605
|
xe(b, e);
|
|
606
606
|
}
|
|
@@ -613,8 +613,8 @@ Check the top-level render call using <` + t + ">.");
|
|
|
613
613
|
function cr(e, r, t) {
|
|
614
614
|
return je(e, r, t, !1);
|
|
615
615
|
}
|
|
616
|
-
var
|
|
617
|
-
L.Fragment = m, L.jsx =
|
|
616
|
+
var fr = cr, lr = sr;
|
|
617
|
+
L.Fragment = m, L.jsx = fr, L.jsxs = lr;
|
|
618
618
|
}()), L;
|
|
619
619
|
}
|
|
620
620
|
(function(s) {
|
|
@@ -624,14 +624,14 @@ const se = ue.exports.Fragment, I = ue.exports.jsx;
|
|
|
624
624
|
class mr extends M.Component {
|
|
625
625
|
render() {
|
|
626
626
|
if (this.props.niceDag && this.props.node.ref) {
|
|
627
|
-
const
|
|
628
|
-
if (
|
|
627
|
+
const f = this.props.niceDag.getElementByNodeId(this.props.node.id);
|
|
628
|
+
if (f)
|
|
629
629
|
return ie.createPortal(/* @__PURE__ */ I(se, {
|
|
630
630
|
children: this.props.render({
|
|
631
631
|
node: this.props.node,
|
|
632
632
|
niceDag: this.props.niceDag
|
|
633
633
|
})
|
|
634
|
-
}),
|
|
634
|
+
}), f);
|
|
635
635
|
}
|
|
636
636
|
return null;
|
|
637
637
|
}
|
|
@@ -649,36 +649,36 @@ class Er extends M.Component {
|
|
|
649
649
|
class Rr extends M.Component {
|
|
650
650
|
render() {
|
|
651
651
|
if (this.props.niceDag) {
|
|
652
|
-
const
|
|
652
|
+
const f = this.props.niceDag.getRootContentElement();
|
|
653
653
|
return ie.createPortal(/* @__PURE__ */ I(se, {
|
|
654
654
|
children: this.props.render(this.props.niceDag)
|
|
655
|
-
}),
|
|
655
|
+
}), f);
|
|
656
656
|
}
|
|
657
657
|
return null;
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
660
|
function Tr(s) {
|
|
661
|
-
const
|
|
661
|
+
const f = A(() => {
|
|
662
662
|
s.remove();
|
|
663
663
|
}, [s]), T = A((m, y = 40) => {
|
|
664
664
|
s.insertNodes(m, y);
|
|
665
665
|
}, [s]);
|
|
666
666
|
return {
|
|
667
|
-
onEdgeRemove:
|
|
667
|
+
onEdgeRemove: f,
|
|
668
668
|
onNodeInsert: T
|
|
669
669
|
};
|
|
670
670
|
}
|
|
671
671
|
function Dr({
|
|
672
672
|
node: s,
|
|
673
|
-
niceDag:
|
|
673
|
+
niceDag: f
|
|
674
674
|
}) {
|
|
675
675
|
const T = A(() => {
|
|
676
676
|
s.remove();
|
|
677
677
|
}, [s]), m = A((D) => {
|
|
678
|
-
|
|
679
|
-
}, [
|
|
680
|
-
|
|
681
|
-
}, [
|
|
678
|
+
f.startEdgeDragging(s, D);
|
|
679
|
+
}, [f, s]), y = A((D) => {
|
|
680
|
+
f.startNodeDragging(s, D);
|
|
681
|
+
}, [f, s]);
|
|
682
682
|
return {
|
|
683
683
|
onNodeRemove: T,
|
|
684
684
|
startEdgeDragging: m,
|
|
@@ -687,15 +687,15 @@ function Dr({
|
|
|
687
687
|
}
|
|
688
688
|
function br(s) {
|
|
689
689
|
const {
|
|
690
|
-
initNodes:
|
|
690
|
+
initNodes: f
|
|
691
691
|
} = s;
|
|
692
|
-
if (!
|
|
692
|
+
if (!f)
|
|
693
693
|
throw new Error("initNodes can't be undefined!");
|
|
694
694
|
}
|
|
695
695
|
function wr(s) {
|
|
696
696
|
br(s);
|
|
697
697
|
const {
|
|
698
|
-
onMount:
|
|
698
|
+
onMount: f,
|
|
699
699
|
renderNode: T,
|
|
700
700
|
renderRootView: m,
|
|
701
701
|
renderEdge: y,
|
|
@@ -721,12 +721,12 @@ function wr(s) {
|
|
|
721
721
|
}, s.editable);
|
|
722
722
|
u.current = E;
|
|
723
723
|
}
|
|
724
|
-
u.current.withNodes(_).render(), O(R + 1), C.current = _,
|
|
724
|
+
u.current.withNodes(_).render(), O(R + 1), C.current = _, f && f();
|
|
725
725
|
}
|
|
726
726
|
return u.current.addNiceDagChangeListener(U), () => {
|
|
727
727
|
u.current.removeNiceDagChangeListener(U);
|
|
728
728
|
};
|
|
729
|
-
}, [_, O, R,
|
|
729
|
+
}, [_, O, R, f]), Ne(() => (u.current && u.current.isDestoried && (u.current.withNodes(_).render(), O(R + 1)), () => {
|
|
730
730
|
u.current && u.current.destory();
|
|
731
731
|
}), []), {
|
|
732
732
|
niceDag: u.current,
|
|
@@ -735,13 +735,13 @@ function wr(s) {
|
|
|
735
735
|
render: () => {
|
|
736
736
|
if (u.current) {
|
|
737
737
|
const E = u.current.getAllNodes();
|
|
738
|
-
let
|
|
738
|
+
let l = (E == null ? void 0 : E.length) > 0 ? E.map((S) => /* @__PURE__ */ I(mr, {
|
|
739
739
|
render: T,
|
|
740
740
|
node: S,
|
|
741
741
|
niceDag: u.current,
|
|
742
742
|
patchVersion: R
|
|
743
|
-
}, S.id)) :
|
|
744
|
-
if (m && (
|
|
743
|
+
}, S.id)) : [];
|
|
744
|
+
if (m && (l = [...l, /* @__PURE__ */ I(Rr, {
|
|
745
745
|
niceDag: u.current,
|
|
746
746
|
render: m
|
|
747
747
|
}, "root-view")]), y) {
|
|
@@ -751,9 +751,9 @@ function wr(s) {
|
|
|
751
751
|
patchVersion: R,
|
|
752
752
|
niceDag: u.current
|
|
753
753
|
}, `edge-${$.source.id}-${$.target.id}`)) : [];
|
|
754
|
-
|
|
754
|
+
l = [...l, ...X];
|
|
755
755
|
}
|
|
756
|
-
return
|
|
756
|
+
return l;
|
|
757
757
|
}
|
|
758
758
|
return null;
|
|
759
759
|
},
|
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({node:this.props.node,niceDag:this.props.niceDag})}),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({edge:this.props.edge,niceDag:this.props.niceDag})}),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:D,minimapConfig:w,...g}=o,S=p.useRef(null),h=p.useRef(null),s=p.useRef(null),T=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(T.current!==D){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(D).render(),j(_+1),T.current=D,f&&f()}return s.current.addNiceDagChangeListener(q),()=>{s.current.removeNiceDagChangeListener(q)}},[D,j,_,f]),p.useEffect(()=>(s.current&&s.current.isDestoried&&(s.current.withNodes(D).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)):
|
|
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({node:this.props.node,niceDag:this.props.niceDag})}),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({edge:this.props.edge,niceDag:this.props.niceDag})}),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:D,minimapConfig:w,...g}=o,S=p.useRef(null),h=p.useRef(null),s=p.useRef(null),T=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(T.current!==D){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(D).render(),j(_+1),T.current=D,f&&f()}return s.current.addNiceDagChangeListener(q),()=>{s.current.removeNiceDagChangeListener(q)}},[D,j,_,f]),p.useEffect(()=>(s.current&&s.current.isDestoried&&(s.current.withNodes(D).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)):[];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.21",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.cjs",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"vite-plugin-dts": "^1.6.6"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@ebay/nice-dag-core": "^1.0.
|
|
91
|
+
"@ebay/nice-dag-core": "^1.0.20"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"react": ">16.8.0",
|