@ebay/nice-dag-vue3 1.0.0

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/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2021 eBay Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # nice-dag-react
2
+ [![NPM](https://img.shields.io/npm/v/@ebay/nice-dag-react.svg)](https://www.npmjs.com/package/@ebay/nice-dag-vue3)
3
+ [![Downloads](https://img.shields.io/npm/dm/@ebay/nice-dag-react.svg)](https://www.npmjs.com/package/@ebay/nice-dag-vue3)
4
+ [![Demo](https://img.shields.io/badge/demo-link-orange.svg)](https://opensource.ebay.com/nice-dag/examples/vue/index.html)
5
+ [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/eBay/nice-dag/blob/main/LICENSE.md)
6
+
7
+ ## What is nice-dag-vue3?
8
+
9
+ `nice-dag-vue3` is a wrapper of DOM operations given by `nice-dag-core`. In terms of **Vue (3.0)** based **DAG Diagram** or **Flow Editor**, you can simply use this customized **vue hook** which is given by `nice-dag-vue` module.
10
+
11
+ For more details, please you can visit [Doc Portal](https://opensource.ebay.com/nice-dag/docs/tutorial-vue3/read-only-dag).
package/lib/env.d.ts ADDED
File without changes
Binary file
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './src/index'
package/lib/index.html ADDED
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html lang="">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
7
+ <link rel="icon" href="<%= BASE_URL %>favicon.ico">
8
+ <title><%= htmlWebpackPlugin.options.title %></title>
9
+ </head>
10
+ <body>
11
+ <noscript>
12
+ <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
13
+ </noscript>
14
+ <div id="app"></div>
15
+ <!-- built files will be auto injected -->
16
+ </body>
17
+ </html>
package/lib/index.js ADDED
@@ -0,0 +1,127 @@
1
+ import v from "@ebay/nice-dag-core";
2
+ import { defineComponent as f, openBlock as s, createElementBlock as d, Fragment as h, renderList as y, createBlock as D, Teleport as m, renderSlot as $, createCommentVNode as R, reactive as k, ref as _, onMounted as C, onUnmounted as E } from "vue";
3
+ const B = f({
4
+ props: { niceDagReactive: Object }
5
+ }), N = (e, n) => {
6
+ const o = e.__vccOpts || e;
7
+ for (const [i, u] of n)
8
+ o[i] = u;
9
+ return o;
10
+ }, M = { key: 0 };
11
+ function O(e, n, o, i, u, l) {
12
+ var r, c;
13
+ return e.niceDagReactive && e.niceDagReactive.observor > 0 ? (s(), d("div", M, [
14
+ (s(!0), d(h, null, y(((c = (r = e.niceDagReactive) == null ? void 0 : r.use()) == null ? void 0 : c.getAllEdges()) || [], (t) => (s(), D(m, {
15
+ key: `edge-${t.source.id}-${t.target.id}`,
16
+ to: t.ref
17
+ }, [
18
+ $(e.$slots, "default", { edge: t })
19
+ ], 8, ["to"]))), 128))
20
+ ])) : R("", !0);
21
+ }
22
+ const G = /* @__PURE__ */ N(B, [["render", O]]), j = f({
23
+ props: { niceDagReactive: Object },
24
+ setup(e) {
25
+ return {
26
+ getDomRef(n) {
27
+ var o, i;
28
+ return (i = (o = e.niceDagReactive) == null ? void 0 : o.use()) == null ? void 0 : i.getElementByNodeId(n.id);
29
+ }
30
+ };
31
+ }
32
+ }), w = { key: 0 };
33
+ function S(e, n, o, i, u, l) {
34
+ var r, c;
35
+ return e.niceDagReactive && e.niceDagReactive.observor > 0 ? (s(), d("div", w, [
36
+ (s(!0), d(h, null, y(((c = (r = e.niceDagReactive) == null ? void 0 : r.use()) == null ? void 0 : c.getAllNodes()) || [], (t) => (s(), D(m, {
37
+ key: t.id,
38
+ to: e.getDomRef(t)
39
+ }, [
40
+ $(e.$slots, "default", { node: t })
41
+ ], 8, ["to"]))), 128))
42
+ ])) : R("", !0);
43
+ }
44
+ const H = /* @__PURE__ */ N(j, [["render", S]]), T = f({
45
+ props: { niceDagReactive: Object },
46
+ setup(e) {
47
+ return {
48
+ getDomRef() {
49
+ var n, o;
50
+ return (o = (n = e.niceDagReactive) == null ? void 0 : n.use()) == null ? void 0 : o.getRootContentElement();
51
+ }
52
+ };
53
+ }
54
+ }), A = { key: 0 };
55
+ function L(e, n, o, i, u, l) {
56
+ return e.niceDagReactive && e.niceDagReactive.observor > 0 ? (s(), d("div", A, [
57
+ (s(), D(m, {
58
+ to: e.getDomRef()
59
+ }, [
60
+ $(e.$slots, "default")
61
+ ], 8, ["to"]))
62
+ ])) : R("", !0);
63
+ }
64
+ const J = /* @__PURE__ */ N(T, [["render", L]]), g = {};
65
+ function V(e) {
66
+ const n = k({
67
+ id: e,
68
+ observor: 0,
69
+ use: () => v.use(e)
70
+ });
71
+ return g[e] = n, n;
72
+ }
73
+ function z(e) {
74
+ return g[e];
75
+ }
76
+ function F(e) {
77
+ delete g[e];
78
+ }
79
+ function I(e) {
80
+ g[e] ? g[e].observor += 1 : console.error(`Can't find observor with dag id:${e}`);
81
+ }
82
+ const p = {
83
+ create: V,
84
+ get: z,
85
+ inc: I,
86
+ remove: F
87
+ };
88
+ function P() {
89
+ return Math.random().toString(16).slice(2);
90
+ }
91
+ function K(e) {
92
+ const { onMount: n, scrollPosition: o, initNodes: i, getNodeSize: u, ...l } = e, r = _(), c = _(), t = p.create(P()), b = {
93
+ onChange: () => {
94
+ p.inc(t.id);
95
+ }
96
+ };
97
+ return C(() => {
98
+ const a = v.init(
99
+ {
100
+ id: t.id,
101
+ container: r.value,
102
+ getNodeSize: u,
103
+ ...l,
104
+ minimapContainer: c.value
105
+ },
106
+ e.editable
107
+ );
108
+ a.withNodes(i).render(), n && n(), a.addNiceDagChangeListener(b), p.inc(t.id);
109
+ }), E(() => {
110
+ var a;
111
+ (a = v.use(t.id)) == null || a.destory(), p.remove(t.id);
112
+ }), {
113
+ niceDagReactive: t,
114
+ niceDagEl: r,
115
+ minimapEl: c,
116
+ reset: () => {
117
+ var a;
118
+ (a = v.use(t.id)) == null || a.destory();
119
+ }
120
+ };
121
+ }
122
+ export {
123
+ G as NiceDagEdges,
124
+ H as NiceDagNodes,
125
+ J as NiceDagRootView,
126
+ K as useNiceDag
127
+ };
@@ -0,0 +1,8 @@
1
+ import type { NiceDagReactiveType } from "../niceDagReactive";
2
+ import type { PropType } from "vue";
3
+ declare const _sfc_main: import("vue").DefineComponent<{
4
+ niceDagReactive: PropType<NiceDagReactiveType>;
5
+ }, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
6
+ niceDagReactive: PropType<NiceDagReactiveType>;
7
+ }>>, {}>;
8
+ export default _sfc_main;
@@ -0,0 +1,11 @@
1
+ import NiceDagTypes from "@ebay/nice-dag-core/lib/types";
2
+ import type { NiceDagReactiveType } from "../niceDagReactive";
3
+ import type { PropType } from "vue";
4
+ declare const _sfc_main: import("vue").DefineComponent<{
5
+ niceDagReactive: PropType<NiceDagReactiveType>;
6
+ }, {
7
+ getDomRef(node: NiceDagTypes.Node): HTMLElement | undefined;
8
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
9
+ niceDagReactive: PropType<NiceDagReactiveType>;
10
+ }>>, {}>;
11
+ export default _sfc_main;
@@ -0,0 +1,10 @@
1
+ import type { NiceDagReactiveType } from "../niceDagReactive";
2
+ import type { PropType } from "vue";
3
+ declare const _sfc_main: import("vue").DefineComponent<{
4
+ niceDagReactive: PropType<NiceDagReactiveType>;
5
+ }, {
6
+ getDomRef(): HTMLElement | undefined;
7
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
8
+ niceDagReactive: PropType<NiceDagReactiveType>;
9
+ }>>, {}>;
10
+ export default _sfc_main;
@@ -0,0 +1,22 @@
1
+ import NiceDagEdges from './components/NiceDagEdges.vue';
2
+ import NiceDagNodes from './components/NiceDagNodes.vue';
3
+ import NiceDagRootView from './components/NiceDagRootView.vue';
4
+ import NiceDagTypes from '@ebay/nice-dag-core/lib/types';
5
+ import type { NiceDagReactiveType } from './niceDagReactive';
6
+ import type { Ref } from 'vue';
7
+ import type { MinimapConfig } from '@ebay/nice-dag-core/lib/types';
8
+ export declare type UseNiceDagArgs = Omit<NiceDagTypes.NiceDagInitArgs, 'container'> & {
9
+ scrollPosition?: NiceDagTypes.Point;
10
+ initNodes: NiceDagTypes.Node[];
11
+ onMount?: () => void;
12
+ editable?: boolean;
13
+ minimapConfig?: MinimapConfig;
14
+ };
15
+ export declare type UseNiceDagType = {
16
+ niceDagEl: Ref<HTMLElement | undefined>;
17
+ minimapEl: Ref<HTMLElement | undefined>;
18
+ niceDagReactive: NiceDagReactiveType;
19
+ reset: () => void;
20
+ };
21
+ declare function useNiceDag(args: UseNiceDagArgs): UseNiceDagType;
22
+ export { useNiceDag, NiceDagEdges, NiceDagNodes, NiceDagRootView, };
@@ -0,0 +1,21 @@
1
+ import NiceDagTypes from '@ebay/nice-dag-core/lib/types';
2
+ export interface NiceDagReactiveType {
3
+ id: string;
4
+ observor: number;
5
+ use: () => NiceDagTypes.NiceDag | undefined;
6
+ }
7
+ declare function create(id: string): {
8
+ id: string;
9
+ observor: number;
10
+ use: () => NiceDagTypes.NiceDag | undefined;
11
+ };
12
+ declare function get(id: string): NiceDagReactiveType;
13
+ declare function remove(id: string): void;
14
+ declare function inc(id: string): void;
15
+ declare const _default: {
16
+ create: typeof create;
17
+ get: typeof get;
18
+ inc: typeof inc;
19
+ remove: typeof remove;
20
+ };
21
+ export default _default;
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@ebay/nice-dag-vue3",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "./lib/index.cjs",
6
+ "module": "./lib/index.js",
7
+ "types": "./lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./lib/index.js",
11
+ "require": "./lib/index.cjs"
12
+ }
13
+ },
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "registry": "https://registry.npmjs.org/"
17
+ },
18
+ "files": [
19
+ "lib"
20
+ ],
21
+ "dependencies": {
22
+ "vite-plugin-dts": "^1.6.6",
23
+ "vue": "^3.2.38",
24
+ "@ebay/nice-dag-core": "^1.0.10"
25
+ },
26
+ "devDependencies": {
27
+ "@rushstack/eslint-patch": "^1.1.4",
28
+ "@types/node": "^16.11.56",
29
+ "@vitejs/plugin-vue": "^3.0.3",
30
+ "@vitejs/plugin-vue-jsx": "^2.0.1",
31
+ "@vue/eslint-config-prettier": "^7.0.0",
32
+ "@vue/eslint-config-typescript": "^11.0.0",
33
+ "@vue/tsconfig": "^0.1.3",
34
+ "eslint": "^8.22.0",
35
+ "eslint-plugin-vue": "^9.3.0",
36
+ "npm-run-all": "^4.1.5",
37
+ "prettier": "^2.7.1",
38
+ "typescript": "~4.7.4",
39
+ "vite": "^3.0.9",
40
+ "vue-tsc": "^0.40.7"
41
+ },
42
+ "scripts": {
43
+ "dev": "vite",
44
+ "build": "run-p type-check build-only",
45
+ "preview": "vite preview --port 4173",
46
+ "build-only": "vite build",
47
+ "type-check": "vue-tsc --noEmit",
48
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
49
+ },
50
+ "readme": "# nice-dag-react\n[![NPM](https://img.shields.io/npm/v/@ebay/nice-dag-react.svg)](https://www.npmjs.com/package/@ebay/nice-dag-vue3)\n[![Downloads](https://img.shields.io/npm/dm/@ebay/nice-dag-react.svg)](https://www.npmjs.com/package/@ebay/nice-dag-vue3)\n[![Demo](https://img.shields.io/badge/demo-link-orange.svg)](https://opensource.ebay.com/nice-dag/examples/vue/index.html)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/eBay/nice-dag/blob/main/LICENSE.md)\n\n## What is nice-dag-vue3?\n\n`nice-dag-vue3` is a wrapper of DOM operations given by `nice-dag-core`. In terms of **Vue (3.0)** based **DAG Diagram** or **Flow Editor**, you can simply use this customized **vue hook** which is given by `nice-dag-vue` module. \n\nFor more details, please you can visit [Doc Portal](https://opensource.ebay.com/nice-dag/docs/tutorial-vue3/read-only-dag)."
51
+ }