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 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: any, type: any): any;
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 l=require("vue"),v=require("@antv/x6"),S=require("@vue/runtime-core"),O=new Map;function E(e,n){return O.set(e,n),e}const{render:C,createApp:T}=S.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=O.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){}}),j=l.defineComponent({inheritAttrs:!1,name:"Graph",setup(e,{attrs:n,slots:o,expose:s}){const{container:r}=e,{width:a=800,height:t=600,...c}=n,u=l.ref(r),i=l.shallowReactive({graph:null}),d=l.ref(),h=l.ref(new Map);return s(i),l.onMounted(()=>{if(Object.keys(c).forEach(f=>c[f]===""&&(c[f]=!0)),u.value){i.graph=new v.Graph({container:u.value,width:a,height:t,...c});const f=l.h(()=>(d.value||[]).filter(p=>p.props).map(p=>{const{key:g,props:x={},type:y}=p,{id:m}=x;if(!g){const N=v.StringExt.hashcode(JSON.stringify(x));p.key=m||h.value.get(m)||h.value.get(N)||v.StringExt.uuid(),!m&&y!=="Edge"&&h.value.set(m||N,p.key)}return p}),i);C(f,i.graph)}}),l.onUnmounted(()=>{i.graph&&i.graph.dispose()}),()=>{const f=o.default&&o.default()||[];return l.nextTick(()=>d.value=f),l.createVNode("div",{style:{width:"100%",height:"100%",position:"relative"}},[!r&&l.createVNode("div",{ref:u},null)])}}}),_=e=>Object.entries(e).reduce((n,[o,s])=>(o.startsWith("on")?n.events[o.substr(2).toLowerCase()]=s:n.props[o]=s,n),{props:{},events:{}}),b=(e,n,o)=>{const s=Object.entries(n).map(([r,a])=>{const t=c=>{const{cell:u}=c;e&&u.id===e.id&&a(c)};return o.on(`cell:${r}`,t),()=>o.off(`cell:${r}`,t)});return()=>s.forEach(r=>r())},P=(e,n,o)=>{const{props:s={},events:r={}}=_(o);let a;const t=e(o);t._remove=()=>{t._removeEvent(),a.model.removeCell(t)},t._insert=i=>{if(a=i.addCell(t),t._removeEvent=b(t,r,a),t.parentNode=i,s.parent){const d=a.getCellById(s.parent);d&&d.addChild(t)}};let c,u={};return t._update=(i,d,h)=>{c&&clearTimeout(c),u[i]=h,c=setTimeout(()=>t._update_props(u),1)},t._update_props=i=>{const{props:d={},events:h={}}=_(i),p=e({shape:t.shape,...d,parent:void 0}).getProp();v.ObjectExt.isEqual(t.getProp(),p)||Object.keys(p).forEach(g=>{["id","parent","shape"].indexOf(g)===-1&&t.setProp(g,p[g])}),t._removeEvent(),t._removeEvent=b(t,h,a),i={}},t},w=(e,n)=>{const{props:o={},events:s={}}=_(n),r=new e({enabled:!0,...o});return r._insert=a=>{a.use(r),b(null,s,r)},r._remove=()=>r.dispose(),r._update=()=>null,r},M=E("Node",P.bind(null,v.Node.create,"rect")),G=E("Edge",P.bind(null,v.Edge.create,"edge"));function q(e,n){return E(e,w.bind(null,n))}exports.Edge=G;exports.ElementOf=E;exports.ElementOfPlugin=q;exports.Graph=j;exports.Node=M;exports.createApp=T;exports.render=C;
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 T, ref as m, shallowReactive as j, onMounted as y, h as G, onUnmounted as M, nextTick as $, createVNode as N } from "vue";
2
- import { Node as S, Edge as k, Graph as R, StringExt as C, ObjectExt as V } from "@antv/x6";
3
- import { createRenderer as A } from "@vue/runtime-core";
4
- const O = /* @__PURE__ */ new Map();
5
- function _(e, n) {
6
- return O.set(e, n), e;
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: B, createApp: L } = A({
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 = O.get(e);
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
- }), U = /* @__PURE__ */ T({
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
- width: p = 800,
43
- height: t = 600,
56
+ props: p = {},
57
+ events: t = {}
58
+ } = m(n), {
59
+ width: l = 800,
60
+ height: h = 600,
44
61
  ...i
45
- } = n, l = m(r), a = j({
62
+ } = p, c = _(r), a = M({
46
63
  graph: null
47
- }), d = m(), u = m(/* @__PURE__ */ new Map());
48
- return s(a), y(() => {
49
- if (Object.keys(i).forEach((h) => i[h] === "" && (i[h] = !0)), l.value) {
50
- a.graph = new R({
51
- container: l.value,
52
- width: p,
53
- height: t,
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 h = G(() => (d.value || []).filter((c) => c.props).map((c) => {
72
+ }), g(null, t, a.graph);
73
+ const u = j(() => (E.value || []).filter((f) => f.props).map((f) => {
57
74
  const {
58
- key: f,
59
- props: b = {},
60
- type: P
61
- } = c, {
75
+ key: T,
76
+ props: x = {},
77
+ type: y
78
+ } = f, {
62
79
  id: v
63
- } = b;
64
- if (!f) {
65
- const x = C.hashcode(JSON.stringify(b));
66
- c.key = v || u.value.get(v) || u.value.get(x) || C.uuid(), !v && P !== "Edge" && u.value.set(v || x, c.key);
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 c;
85
+ return f;
69
86
  }), a);
70
- B(h, a.graph);
87
+ q(u, a.graph);
71
88
  }
72
- }), M(() => {
89
+ }), S(() => {
73
90
  a.graph && a.graph.dispose();
74
91
  }), () => {
75
- const h = o.default && o.default() || [];
76
- return $(() => d.value = h), N("div", {
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 && N("div", {
83
- ref: l
99
+ }, [!r && C("div", {
100
+ ref: c
84
101
  }, null)]);
85
102
  };
86
103
  }
87
- }), g = (e) => Object.entries(e).reduce((n, [o, s]) => (o.startsWith("on") ? n.events[o.substr(2).toLowerCase()] = s : n.props[o] = s, n), {
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
- } = g(o);
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 = (a) => {
111
- if (p = a.addCell(t), t._removeEvent = E(t, r, p), t.parentNode = a, s.parent) {
112
- const d = p.getCellById(s.parent);
113
- d && d.addChild(t);
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 i, l = {};
117
- return t._update = (a, d, u) => {
118
- i && clearTimeout(i), l[a] = u, i = setTimeout(() => t._update_props(l), 1);
119
- }, t._update_props = (a) => {
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: d = {},
122
- events: u = {}
123
- } = g(a), c = e({
124
+ props: c = {},
125
+ events: a = {}
126
+ } = m(i), d = e({
124
127
  shape: t.shape,
125
- ...d,
128
+ ...c,
126
129
  parent: void 0
127
130
  }).getProp();
128
- V.isEqual(t.getProp(), c) || Object.keys(c).forEach((f) => {
129
- ["id", "parent", "shape"].indexOf(f) === -1 && t.setProp(f, c[f]);
130
- }), t._removeEvent(), t._removeEvent = E(t, u, p), a = {};
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
- }, I = (e, n) => {
135
+ }, z = (e, n) => {
133
136
  const {
134
137
  props: o = {},
135
138
  events: s = {}
136
- } = g(n), r = new e({
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), E(null, s, r);
144
+ p.use(r), g(null, s, r);
142
145
  }, r._remove = () => r.dispose(), r._update = () => null, r;
143
- }, W = _("Node", w.bind(null, S.create, "rect")), D = _("Edge", w.bind(null, k.create, "edge"));
144
- function F(e, n) {
145
- return _(e, I.bind(null, n));
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
- D as Edge,
149
- _ as ElementOf,
150
- F as ElementOfPlugin,
151
- U as Graph,
152
- W as Node,
153
- L as createApp,
154
- B as render
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.2",
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": [