vue-x6 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Graph.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +83 -80
- package/package.json +2 -2
package/dist/Graph.d.ts
CHANGED
@@ -13,5 +13,5 @@ export declare const Node: DefineComponent<unknown, {
|
|
13
13
|
export declare const Edge: DefineComponent<unknown, {
|
14
14
|
[key: string]: any;
|
15
15
|
}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<unknown>, {}>;
|
16
|
-
export declare function ElementOfPlugin(name:
|
16
|
+
export declare function ElementOfPlugin(name: string, type: any): any;
|
17
17
|
export {};
|
package/dist/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),g=require("@antv/x6"),w=require("@vue/runtime-core"),C=new Map;function b(e,n){return C.set(e,n),e}const{render:P,createApp:M}=w.createRenderer({patchProp:(e,n,o,s)=>e._update(n,o,s),insert:(e,n)=>e&&e._insert(n),remove:e=>e&&e._remove(),createElement:(e,n,o,s)=>{const r=C.get(e);return r&&r(s)},createText:e=>{const n={text:e,_insert:o=>n.parentNode=o};return n},createComment:()=>null,setText:()=>null,setElementText:()=>null,parentNode:e=>e.parentNode,nextSibling(e){}}),E=e=>Object.entries(e).reduce((n,[o,s])=>(o.startsWith("on")?n.events[o.substr(2).toLowerCase()]=s:n.props[o]=s===""?!0:s,n),{props:{},events:{}}),_=(e,n,o)=>{const s=Object.entries(n).map(([r,i])=>{const t=u=>{const{cell:f}=u;e&&f.id===e.id&&i(u)};return o.on(`cell:${r}`,t),()=>o.off(`cell:${r}`,t)});return()=>s.forEach(r=>r())},j=a.defineComponent({inheritAttrs:!1,name:"Graph",setup(e,{attrs:n,slots:o,expose:s}){const{container:r}=e,{props:i={},events:t={}}=E(n),{width:u=800,height:f=600,...c}=i,l=a.ref(r),p=a.shallowReactive({graph:null}),x=a.ref(),d=a.ref(new Map);return s(p),a.onMounted(()=>{if(l.value){p.graph=new g.Graph({container:l.value,width:u,height:f,...c}),_(null,t,p.graph);const h=a.h(()=>(x.value||[]).filter(v=>v.props).map(v=>{const{key:S,props:N={},type:T}=v,{id:m}=N;if(!S){const O=g.StringExt.hashcode(JSON.stringify(N));v.key=m||d.value.get(m)||d.value.get(O)||g.StringExt.uuid(),!m&&T!=="Edge"&&d.value.set(m||O,v.key)}return v}),p);P(h,p.graph)}}),a.onUnmounted(()=>{p.graph&&p.graph.dispose()}),()=>{const h=o.default&&o.default()||[];return a.nextTick(()=>x.value=h),a.createVNode("div",{style:{width:"100%",height:"100%",position:"relative"}},[!r&&a.createVNode("div",{ref:l},null)])}}}),y=(e,n,o)=>{const{props:s={},events:r={}}=E(o);let i;const t=e(o);t._remove=()=>{t._removeEvent(),i.model.removeCell(t)},t._insert=c=>{if(i=c.addCell(t),t._removeEvent=_(t,r,i),t.parentNode=c,s.parent){const l=i.getCellById(s.parent);l&&l.addChild(t)}};let u,f={};return t._update=(c,l,p)=>{u&&clearTimeout(u),f[c]=p,u=setTimeout(()=>t._update_props(f),1)},t._update_props=c=>{const{props:l={},events:p={}}=E(c),d=e({shape:t.shape,...l,parent:void 0}).getProp();g.ObjectExt.isEqual(t.getProp(),d)||Object.keys(d).forEach(h=>{["id","parent","shape"].indexOf(h)===-1&&t.setProp(h,d[h])}),t._removeEvent(),t._removeEvent=_(t,p,i),c={}},t},G=(e,n)=>{const{props:o={},events:s={}}=E(n),r=new e({enabled:!0,...o});return r._insert=i=>{i.use(r),_(null,s,r)},r._remove=()=>r.dispose(),r._update=()=>null,r},q=b("Node",y.bind(null,g.Node.create,"rect")),V=b("Edge",y.bind(null,g.Edge.create,"edge"));function k(e,n){return b(e,G.bind(null,n))}exports.Edge=V;exports.ElementOf=b;exports.ElementOfPlugin=k;exports.Graph=j;exports.Node=q;exports.createApp=M;exports.render=P;
|
package/dist/index.js
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
import { defineComponent as
|
2
|
-
import { Node as
|
3
|
-
import { createRenderer as
|
4
|
-
const
|
5
|
-
function
|
6
|
-
return
|
1
|
+
import { defineComponent as G, ref as _, shallowReactive as M, onMounted as $, h as j, onUnmounted as S, nextTick as k, createVNode as C } from "vue";
|
2
|
+
import { Node as R, Edge as V, Graph as A, StringExt as O, ObjectExt as B } from "@antv/x6";
|
3
|
+
import { createRenderer as I } from "@vue/runtime-core";
|
4
|
+
const w = /* @__PURE__ */ new Map();
|
5
|
+
function b(e, n) {
|
6
|
+
return w.set(e, n), e;
|
7
7
|
}
|
8
|
-
const { render:
|
8
|
+
const { render: q, createApp: W } = I({
|
9
9
|
patchProp: (e, n, o, s) => e._update(n, o, s),
|
10
10
|
insert: (e, n) => e && e._insert(n),
|
11
11
|
remove: (e) => e && e._remove(),
|
12
12
|
createElement: (e, n, o, s) => {
|
13
|
-
const r =
|
13
|
+
const r = w.get(e);
|
14
14
|
return r && r(s);
|
15
15
|
},
|
16
16
|
createText: (e) => {
|
@@ -28,7 +28,21 @@ const { render: B, createApp: L } = A({
|
|
28
28
|
// setScopeId,
|
29
29
|
// cloneNode,
|
30
30
|
// insertStaticContent,
|
31
|
-
}),
|
31
|
+
}), m = (e) => Object.entries(e).reduce((n, [o, s]) => (o.startsWith("on") ? n.events[o.substr(2).toLowerCase()] = s : n.props[o] = s === "" ? !0 : s, n), {
|
32
|
+
props: {},
|
33
|
+
events: {}
|
34
|
+
}), g = (e, n, o) => {
|
35
|
+
const s = Object.entries(n).map(([r, p]) => {
|
36
|
+
const t = (l) => {
|
37
|
+
const {
|
38
|
+
cell: h
|
39
|
+
} = l;
|
40
|
+
e && h.id === e.id && p(l);
|
41
|
+
};
|
42
|
+
return o.on(`cell:${r}`, t), () => o.off(`cell:${r}`, t);
|
43
|
+
});
|
44
|
+
return () => s.forEach((r) => r());
|
45
|
+
}, D = /* @__PURE__ */ G({
|
32
46
|
inheritAttrs: !1,
|
33
47
|
name: "Graph",
|
34
48
|
setup(e, {
|
@@ -39,117 +53,106 @@ const { render: B, createApp: L } = A({
|
|
39
53
|
const {
|
40
54
|
container: r
|
41
55
|
} = e, {
|
42
|
-
|
43
|
-
|
56
|
+
props: p = {},
|
57
|
+
events: t = {}
|
58
|
+
} = m(n), {
|
59
|
+
width: l = 800,
|
60
|
+
height: h = 600,
|
44
61
|
...i
|
45
|
-
} =
|
62
|
+
} = p, c = _(r), a = M({
|
46
63
|
graph: null
|
47
|
-
}),
|
48
|
-
return s(a),
|
49
|
-
if (
|
50
|
-
a.graph = new
|
51
|
-
container:
|
52
|
-
width:
|
53
|
-
height:
|
64
|
+
}), E = _(), d = _(/* @__PURE__ */ new Map());
|
65
|
+
return s(a), $(() => {
|
66
|
+
if (c.value) {
|
67
|
+
a.graph = new A({
|
68
|
+
container: c.value,
|
69
|
+
width: l,
|
70
|
+
height: h,
|
54
71
|
...i
|
55
|
-
});
|
56
|
-
const
|
72
|
+
}), g(null, t, a.graph);
|
73
|
+
const u = j(() => (E.value || []).filter((f) => f.props).map((f) => {
|
57
74
|
const {
|
58
|
-
key:
|
59
|
-
props:
|
60
|
-
type:
|
61
|
-
} =
|
75
|
+
key: T,
|
76
|
+
props: x = {},
|
77
|
+
type: y
|
78
|
+
} = f, {
|
62
79
|
id: v
|
63
|
-
} =
|
64
|
-
if (!
|
65
|
-
const
|
66
|
-
|
80
|
+
} = x;
|
81
|
+
if (!T) {
|
82
|
+
const N = O.hashcode(JSON.stringify(x));
|
83
|
+
f.key = v || d.value.get(v) || d.value.get(N) || O.uuid(), !v && y !== "Edge" && d.value.set(v || N, f.key);
|
67
84
|
}
|
68
|
-
return
|
85
|
+
return f;
|
69
86
|
}), a);
|
70
|
-
|
87
|
+
q(u, a.graph);
|
71
88
|
}
|
72
|
-
}),
|
89
|
+
}), S(() => {
|
73
90
|
a.graph && a.graph.dispose();
|
74
91
|
}), () => {
|
75
|
-
const
|
76
|
-
return
|
92
|
+
const u = o.default && o.default() || [];
|
93
|
+
return k(() => E.value = u), C("div", {
|
77
94
|
style: {
|
78
95
|
width: "100%",
|
79
96
|
height: "100%",
|
80
97
|
position: "relative"
|
81
98
|
}
|
82
|
-
}, [!r &&
|
83
|
-
ref:
|
99
|
+
}, [!r && C("div", {
|
100
|
+
ref: c
|
84
101
|
}, null)]);
|
85
102
|
};
|
86
103
|
}
|
87
|
-
}),
|
88
|
-
props: {},
|
89
|
-
events: {}
|
90
|
-
}), E = (e, n, o) => {
|
91
|
-
const s = Object.entries(n).map(([r, p]) => {
|
92
|
-
const t = (i) => {
|
93
|
-
const {
|
94
|
-
cell: l
|
95
|
-
} = i;
|
96
|
-
e && l.id === e.id && p(i);
|
97
|
-
};
|
98
|
-
return o.on(`cell:${r}`, t), () => o.off(`cell:${r}`, t);
|
99
|
-
});
|
100
|
-
return () => s.forEach((r) => r());
|
101
|
-
}, w = (e, n, o) => {
|
104
|
+
}), P = (e, n, o) => {
|
102
105
|
const {
|
103
106
|
props: s = {},
|
104
107
|
events: r = {}
|
105
|
-
} =
|
108
|
+
} = m(o);
|
106
109
|
let p;
|
107
110
|
const t = e(o);
|
108
111
|
t._remove = () => {
|
109
112
|
t._removeEvent(), p.model.removeCell(t);
|
110
|
-
}, t._insert = (
|
111
|
-
if (p =
|
112
|
-
const
|
113
|
-
|
113
|
+
}, t._insert = (i) => {
|
114
|
+
if (p = i.addCell(t), t._removeEvent = g(t, r, p), t.parentNode = i, s.parent) {
|
115
|
+
const c = p.getCellById(s.parent);
|
116
|
+
c && c.addChild(t);
|
114
117
|
}
|
115
118
|
};
|
116
|
-
let
|
117
|
-
return t._update = (
|
118
|
-
|
119
|
-
}, t._update_props = (
|
119
|
+
let l, h = {};
|
120
|
+
return t._update = (i, c, a) => {
|
121
|
+
l && clearTimeout(l), h[i] = a, l = setTimeout(() => t._update_props(h), 1);
|
122
|
+
}, t._update_props = (i) => {
|
120
123
|
const {
|
121
|
-
props:
|
122
|
-
events:
|
123
|
-
} =
|
124
|
+
props: c = {},
|
125
|
+
events: a = {}
|
126
|
+
} = m(i), d = e({
|
124
127
|
shape: t.shape,
|
125
|
-
...
|
128
|
+
...c,
|
126
129
|
parent: void 0
|
127
130
|
}).getProp();
|
128
|
-
|
129
|
-
["id", "parent", "shape"].indexOf(
|
130
|
-
}), t._removeEvent(), t._removeEvent =
|
131
|
+
B.isEqual(t.getProp(), d) || Object.keys(d).forEach((u) => {
|
132
|
+
["id", "parent", "shape"].indexOf(u) === -1 && t.setProp(u, d[u]);
|
133
|
+
}), t._removeEvent(), t._removeEvent = g(t, a, p), i = {};
|
131
134
|
}, t;
|
132
|
-
},
|
135
|
+
}, z = (e, n) => {
|
133
136
|
const {
|
134
137
|
props: o = {},
|
135
138
|
events: s = {}
|
136
|
-
} =
|
139
|
+
} = m(n), r = new e({
|
137
140
|
enabled: !0,
|
138
141
|
...o
|
139
142
|
});
|
140
143
|
return r._insert = (p) => {
|
141
|
-
p.use(r),
|
144
|
+
p.use(r), g(null, s, r);
|
142
145
|
}, r._remove = () => r.dispose(), r._update = () => null, r;
|
143
|
-
},
|
144
|
-
function
|
145
|
-
return
|
146
|
+
}, F = b("Node", P.bind(null, R.create, "rect")), H = b("Edge", P.bind(null, V.create, "edge"));
|
147
|
+
function K(e, n) {
|
148
|
+
return b(e, z.bind(null, n));
|
146
149
|
}
|
147
150
|
export {
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
151
|
+
H as Edge,
|
152
|
+
b as ElementOf,
|
153
|
+
K as ElementOfPlugin,
|
154
|
+
D as Graph,
|
155
|
+
F as Node,
|
156
|
+
W as createApp,
|
157
|
+
q as render
|
155
158
|
};
|
package/package.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "vue-x6",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.3",
|
4
4
|
"type": "module",
|
5
5
|
"scripts": {
|
6
6
|
"dev": "vite",
|
7
7
|
"build": "run-p type-check build-only tsd",
|
8
8
|
"build-only": "vite build",
|
9
9
|
"type-check": "vue-tsc --noEmit",
|
10
|
-
"tsd": "tsc -d --skipLibCheck --emitDeclarationOnly --jsx preserve --esModuleInterop --declarationDir dist src/lib/index.ts",
|
10
|
+
"tsd": "tsc -d --skipLibCheck --emitDeclarationOnly --jsx preserve --esModuleInterop --lib es2017,DOM --declarationDir dist src/lib/index.ts",
|
11
11
|
"preview": "vite preview"
|
12
12
|
},
|
13
13
|
"files": [
|