apextree 1.1.0 → 1.3.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/README.md +60 -62
- package/apextree.es.min.js +7127 -0
- package/apextree.min.js +1 -0
- package/demo/bottom_to_top_view.html +9 -7
- package/demo/custom_font_options.html +3 -6
- package/demo/dynamic_view_change.html +3 -6
- package/demo/expand_collapse_nodes.html +2 -2
- package/demo/left_to_right_view.html +2 -2
- package/demo/per_node_options.html +3 -6
- package/demo/right_to_left_view.html +2 -2
- package/demo/top_to_bottom_view.html +2 -2
- package/index.d.ts +1 -0
- package/lib/ApexTree.d.ts +9 -0
- package/lib/models/Export.d.ts +9 -0
- package/lib/models/Graph.d.ts +35 -0
- package/lib/models/Paper.d.ts +32 -0
- package/lib/models/Toolbar.d.ts +15 -0
- package/lib/models/index.d.ts +2 -0
- package/lib/settings/DirectionConfig.d.ts +47 -0
- package/lib/settings/Options.d.ts +49 -0
- package/lib/utils/EdgeUtils.d.ts +2 -0
- package/lib/utils/GraphUtils.d.ts +10 -0
- package/package.json +19 -27
- package/.editorconfig +0 -7
- package/.eslintignore +0 -2
- package/.eslintrc +0 -9
- package/.prettierrc +0 -5
- package/.vscode/settings.json +0 -5
- package/LICENSE +0 -674
- package/dist/ApexTree.js +0 -608
- package/dist/ApexTree.min.js +0 -2
- package/dist/ApexTree.min.js.LICENSE.txt +0 -10
- package/globals.d.ts +0 -4
- package/src/ApexTree.ts +0 -34
- package/src/icons/add-circle.svg +0 -3
- package/src/icons/export-icon.svg +0 -2
- package/src/icons/fit-screen-icon.svg +0 -9
- package/src/icons/minus-circle.svg +0 -3
- package/src/icons/zoom-in-icon.svg +0 -8
- package/src/icons/zoom-out-icon.svg +0 -8
- package/src/models/Export.ts +0 -39
- package/src/models/Graph.ts +0 -284
- package/src/models/Paper.ts +0 -117
- package/src/models/Toolbar.ts +0 -71
- package/src/models/index.ts +0 -2
- package/src/settings/DirectionConfig.ts +0 -227
- package/src/settings/Options.ts +0 -98
- package/src/utils/EdgeUtils.ts +0 -30
- package/src/utils/GraphUtils.ts +0 -135
- package/tsconfig.json +0 -28
- package/webpack.common.ts +0 -68
- package/webpack.config.ts +0 -7
- package/webpack.dev.ts +0 -12
- package/webpack.prod.ts +0 -9
- /package/{src/utils/index.ts → lib/utils/index.d.ts} +0 -0
package/src/settings/Options.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
export type TreeDirection = 'left' | 'top' | 'right' | 'bottom';
|
|
2
|
-
|
|
3
|
-
export interface NodeOptions {
|
|
4
|
-
readonly nodeWidth: number;
|
|
5
|
-
readonly nodeHeight: number;
|
|
6
|
-
readonly nodeBGColor: string;
|
|
7
|
-
readonly nodeBGColorHover: string;
|
|
8
|
-
readonly nodeStyle: string;
|
|
9
|
-
readonly nodeClassName: string;
|
|
10
|
-
readonly nodeTemplate: (content: any) => any;
|
|
11
|
-
readonly borderRadius: string;
|
|
12
|
-
readonly borderWidth: number;
|
|
13
|
-
readonly borderColor: string;
|
|
14
|
-
readonly borderStyle: string;
|
|
15
|
-
readonly borderColorHover: string;
|
|
16
|
-
readonly enableExpandCollapse: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface TooltipOptions {
|
|
20
|
-
readonly enableTooltip: boolean;
|
|
21
|
-
readonly tooltipId: string;
|
|
22
|
-
readonly tooltipTemplate?: (content: any) => any;
|
|
23
|
-
readonly tooltipMaxWidth: number;
|
|
24
|
-
readonly tooltipBorderColor: string;
|
|
25
|
-
readonly tooltipBGColor: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface FontOptions {
|
|
29
|
-
readonly fontSize: string;
|
|
30
|
-
readonly fontFamily: string;
|
|
31
|
-
readonly fontWeight: number;
|
|
32
|
-
readonly fontColor: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface EdgeOptions {
|
|
36
|
-
readonly edgeColor: string;
|
|
37
|
-
readonly edgeColorHover: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface CommonOptions {
|
|
41
|
-
readonly width: number;
|
|
42
|
-
readonly height: number;
|
|
43
|
-
readonly direction: TreeDirection;
|
|
44
|
-
readonly contentKey: string;
|
|
45
|
-
readonly siblingSpacing: number;
|
|
46
|
-
readonly childrenSpacing: number;
|
|
47
|
-
readonly highlightOnHover: boolean;
|
|
48
|
-
readonly containerClassName: string;
|
|
49
|
-
readonly canvasStyle: string;
|
|
50
|
-
readonly enableToolbar: boolean;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type TreeOptions = CommonOptions &
|
|
54
|
-
NodeOptions &
|
|
55
|
-
TooltipOptions &
|
|
56
|
-
FontOptions &
|
|
57
|
-
EdgeOptions;
|
|
58
|
-
|
|
59
|
-
const defaultNodeTemplate = (content: string) => {
|
|
60
|
-
return `<div style='display: flex;justify-content: center;align-items: center; text-align: center; height: 100%;'>${content}</div>`;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const DefaultOptions: TreeOptions = {
|
|
64
|
-
width: 400,
|
|
65
|
-
height: 400,
|
|
66
|
-
contentKey: 'name',
|
|
67
|
-
nodeWidth: 50,
|
|
68
|
-
nodeHeight: 30,
|
|
69
|
-
nodeTemplate: defaultNodeTemplate,
|
|
70
|
-
nodeBGColor: '#FFFFFF',
|
|
71
|
-
nodeBGColorHover: '#FFFFFF',
|
|
72
|
-
nodeStyle: '',
|
|
73
|
-
nodeClassName: 'apextree-node',
|
|
74
|
-
borderWidth: 2,
|
|
75
|
-
borderStyle: 'solid',
|
|
76
|
-
borderRadius: '5px',
|
|
77
|
-
borderColor: '#BCBCBC',
|
|
78
|
-
borderColorHover: '#5C6BC0',
|
|
79
|
-
enableExpandCollapse: false,
|
|
80
|
-
siblingSpacing: 50,
|
|
81
|
-
childrenSpacing: 50,
|
|
82
|
-
direction: 'top',
|
|
83
|
-
highlightOnHover: true,
|
|
84
|
-
containerClassName: 'root',
|
|
85
|
-
enableTooltip: false,
|
|
86
|
-
tooltipId: 'apextree-tooltip-container',
|
|
87
|
-
tooltipMaxWidth: 100,
|
|
88
|
-
tooltipBorderColor: '#BCBCBC',
|
|
89
|
-
tooltipBGColor: '#FFFFFF',
|
|
90
|
-
fontSize: '14px',
|
|
91
|
-
fontFamily: '',
|
|
92
|
-
fontWeight: 400,
|
|
93
|
-
fontColor: '#000000',
|
|
94
|
-
canvasStyle: '',
|
|
95
|
-
enableToolbar: false,
|
|
96
|
-
edgeColor: '#BCBCBC',
|
|
97
|
-
edgeColorHover: '#5C6BC0',
|
|
98
|
-
};
|
package/src/utils/EdgeUtils.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {Node, TreeNode} from 'src/models/Graph';
|
|
2
|
-
import {DirectionConfig} from 'src/settings/DirectionConfig';
|
|
3
|
-
|
|
4
|
-
export const getEdge = (
|
|
5
|
-
node: TreeNode<Node>,
|
|
6
|
-
nodeWidth: number,
|
|
7
|
-
nodeHeight: number,
|
|
8
|
-
graphDirection: string,
|
|
9
|
-
): string | null => {
|
|
10
|
-
if (!node || !node.parent) return null;
|
|
11
|
-
const {edgeX, edgeY, edgeParentX, edgeParentY, edgeMidX, edgeMidY, calculateEdge, swap} =
|
|
12
|
-
DirectionConfig[graphDirection];
|
|
13
|
-
const newNode = swap(node);
|
|
14
|
-
const newParent = swap(node.parent);
|
|
15
|
-
const child = {
|
|
16
|
-
x: edgeX({node: newNode, nodeWidth, nodeHeight}),
|
|
17
|
-
y: edgeY({node: newNode, nodeWidth, nodeHeight}),
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const parent = {
|
|
21
|
-
x: edgeParentX({parent: newParent, nodeWidth, nodeHeight}),
|
|
22
|
-
y: edgeParentY({parent: newParent, nodeWidth, nodeHeight}),
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const mid = {
|
|
26
|
-
x: edgeMidX({node: newNode, nodeWidth, nodeHeight}),
|
|
27
|
-
y: edgeMidY({node: newNode, nodeWidth, nodeHeight}),
|
|
28
|
-
};
|
|
29
|
-
return calculateEdge(child, parent, mid, {sy: 0});
|
|
30
|
-
};
|
package/src/utils/GraphUtils.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { Node, TreeNode } from 'src/models/Graph';
|
|
2
|
-
import { FontOptions, TreeOptions } from 'src/settings/Options';
|
|
3
|
-
|
|
4
|
-
export const setAttributes = (
|
|
5
|
-
element: Element | null,
|
|
6
|
-
attrs: Record<string, any> = {},
|
|
7
|
-
) => {
|
|
8
|
-
for (const key in attrs) {
|
|
9
|
-
element?.setAttribute(key, attrs[key]);
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const ExpandCollapseButtonSize = 14;
|
|
14
|
-
|
|
15
|
-
export const highlightToPath = (
|
|
16
|
-
nodes: ReadonlyArray<TreeNode<Node>>,
|
|
17
|
-
selfNode: TreeNode<Node>,
|
|
18
|
-
isHighlighted: boolean,
|
|
19
|
-
options: TreeOptions,
|
|
20
|
-
): void => {
|
|
21
|
-
const nodeOptions = selfNode?.data.options;
|
|
22
|
-
let borderWidth = nodeOptions?.borderWidth || options.borderWidth;
|
|
23
|
-
let borderColor = nodeOptions?.borderColor || options.borderColor;
|
|
24
|
-
let backgroundColor = nodeOptions?.nodeBGColor || options.nodeBGColor;
|
|
25
|
-
|
|
26
|
-
if (isHighlighted) {
|
|
27
|
-
// borderWidth = borderWidth + 1;
|
|
28
|
-
borderColor = nodeOptions?.borderColorHover || options.borderColorHover;
|
|
29
|
-
backgroundColor = nodeOptions?.nodeBGColorHover || options.nodeBGColorHover;
|
|
30
|
-
}
|
|
31
|
-
const selfContentElement: HTMLElement | null = document.querySelector(
|
|
32
|
-
`[data-self='${selfNode.data.id}'] foreignObject`,
|
|
33
|
-
);
|
|
34
|
-
if (selfContentElement) {
|
|
35
|
-
selfContentElement.style.borderWidth = `${borderWidth}px`;
|
|
36
|
-
selfContentElement.style.borderColor = borderColor;
|
|
37
|
-
selfContentElement.style.backgroundColor = backgroundColor;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (selfNode.parent) {
|
|
41
|
-
const edge = document.getElementById(
|
|
42
|
-
`${selfNode.data.id}-${selfNode.parent?.data.id}`,
|
|
43
|
-
);
|
|
44
|
-
if (isHighlighted) {
|
|
45
|
-
setAttributes(edge, {
|
|
46
|
-
'stroke-width': borderWidth + 1,
|
|
47
|
-
stroke: options.edgeColorHover,
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
setAttributes(edge, {
|
|
51
|
-
'stroke-width': borderWidth,
|
|
52
|
-
stroke: options.edgeColor,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
selfNode.parent &&
|
|
57
|
-
highlightToPath(nodes, selfNode.parent, isHighlighted, options);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export const getTooltipStyles = (
|
|
62
|
-
x: number,
|
|
63
|
-
y: number,
|
|
64
|
-
maxWidth: number,
|
|
65
|
-
borderColor: string,
|
|
66
|
-
bgColor: string,
|
|
67
|
-
addPadding: boolean,
|
|
68
|
-
): ReadonlyArray<string> => {
|
|
69
|
-
const styles = [
|
|
70
|
-
'position: absolute;',
|
|
71
|
-
`left: ${x + 20}px;`,
|
|
72
|
-
`top: ${y + 20}px;`,
|
|
73
|
-
`border: 1px solid ${borderColor};`,
|
|
74
|
-
`border-radius: 5px;`,
|
|
75
|
-
`max-width: ${maxWidth}px;`,
|
|
76
|
-
`background-color: ${bgColor};`,
|
|
77
|
-
];
|
|
78
|
-
if (addPadding) {
|
|
79
|
-
styles.push('padding: 10px;');
|
|
80
|
-
}
|
|
81
|
-
return styles;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const generateStyles = (
|
|
85
|
-
styleObject: Record<string, number | string> = {},
|
|
86
|
-
): string => {
|
|
87
|
-
const styles = [];
|
|
88
|
-
for (const styleKey in styleObject) {
|
|
89
|
-
let key = styleKey;
|
|
90
|
-
if (styleKey === 'fontColor') {
|
|
91
|
-
key = 'color';
|
|
92
|
-
}
|
|
93
|
-
const styleString = `${camelToKebabCase(key)}: ${
|
|
94
|
-
styleObject[styleKey as keyof FontOptions]
|
|
95
|
-
};`;
|
|
96
|
-
styles.push(styleString);
|
|
97
|
-
}
|
|
98
|
-
return styles.join(' ');
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export const getTooltip = (
|
|
102
|
-
tooltipId: string = 'apextree-tooltip-container',
|
|
103
|
-
) => {
|
|
104
|
-
const tooltipElement =
|
|
105
|
-
document.getElementById(tooltipId) || document.createElement('div');
|
|
106
|
-
tooltipElement.id = tooltipId;
|
|
107
|
-
return tooltipElement;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export const updateTooltip = (
|
|
111
|
-
id: string = '',
|
|
112
|
-
styles?: string | undefined,
|
|
113
|
-
content: string = '',
|
|
114
|
-
) => {
|
|
115
|
-
const tooltipElement = document.getElementById(id);
|
|
116
|
-
if (styles) {
|
|
117
|
-
tooltipElement?.setAttribute('style', styles);
|
|
118
|
-
} else {
|
|
119
|
-
tooltipElement?.removeAttribute('style');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (
|
|
123
|
-
tooltipElement?.innerHTML.replaceAll("'", '"') !==
|
|
124
|
-
content.replaceAll("'", '"')
|
|
125
|
-
) {
|
|
126
|
-
tooltipElement && (tooltipElement.innerHTML = content);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export const camelToKebabCase = (str: string): string => {
|
|
131
|
-
return str.replace(
|
|
132
|
-
/[A-Z]+(?![a-z])|[A-Z]/g,
|
|
133
|
-
($, ofs) => (ofs ? '-' : '') + $.toLowerCase(),
|
|
134
|
-
);
|
|
135
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"allowSyntheticDefaultImports": true,
|
|
4
|
-
"baseUrl": ".",
|
|
5
|
-
"rootDir": ".",
|
|
6
|
-
"module": "commonjs",
|
|
7
|
-
"moduleResolution": "Node",
|
|
8
|
-
"resolveJsonModule": true,
|
|
9
|
-
"target": "es6",
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"noImplicitAny": true,
|
|
12
|
-
"strictNullChecks": true,
|
|
13
|
-
"lib": [
|
|
14
|
-
"es2021",
|
|
15
|
-
"dom"
|
|
16
|
-
]
|
|
17
|
-
},
|
|
18
|
-
"include": ["src/**/*"],
|
|
19
|
-
"exclude": [
|
|
20
|
-
"node_modules",
|
|
21
|
-
"dist",
|
|
22
|
-
],
|
|
23
|
-
"ts-node": {
|
|
24
|
-
"esm": true,
|
|
25
|
-
"experimentalSpecifierResolution": "node"
|
|
26
|
-
},
|
|
27
|
-
"files": ["globals.d.ts"]
|
|
28
|
-
}
|
package/webpack.common.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import {Compiler, Configuration, WebpackPluginInstance} from 'webpack';
|
|
3
|
-
|
|
4
|
-
export const ROOT = path.resolve(__dirname, '.');
|
|
5
|
-
|
|
6
|
-
interface CommonConfig extends Configuration {
|
|
7
|
-
plugins: (((this: Compiler, compiler: Compiler) => void) | WebpackPluginInstance)[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const commonConfig: CommonConfig = {
|
|
11
|
-
entry: [path.resolve(__dirname, 'src/ApexTree.ts')],
|
|
12
|
-
output: {
|
|
13
|
-
clean: true,
|
|
14
|
-
filename: 'ApexTree.js',
|
|
15
|
-
path: path.resolve(__dirname, 'dist'),
|
|
16
|
-
library: 'ApexTree',
|
|
17
|
-
libraryTarget: 'umd',
|
|
18
|
-
libraryExport: 'ApexTree',
|
|
19
|
-
},
|
|
20
|
-
module: {
|
|
21
|
-
rules: [
|
|
22
|
-
{
|
|
23
|
-
// Include ts, tsx, js, and jsx files.
|
|
24
|
-
test: /\.(ts|js)?$/,
|
|
25
|
-
include: [ROOT],
|
|
26
|
-
exclude: [/node_modules/],
|
|
27
|
-
use: [
|
|
28
|
-
{
|
|
29
|
-
loader: 'babel-loader',
|
|
30
|
-
options: {
|
|
31
|
-
// Rely on babel loading it's `babel.config.js` file. If we need to edit it for
|
|
32
|
-
// Hot Module Reloading support so be it.
|
|
33
|
-
// https://gist.github.com/rmoorman/94eeed830942758e218d92f15ce58d88
|
|
34
|
-
presets: [['@babel/preset-env', {targets: 'defaults'}]],
|
|
35
|
-
plugins: ['@babel/plugin-proposal-class-properties', '@babel/plugin-transform-runtime'],
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
test: /\.ts?$/,
|
|
42
|
-
include: [ROOT],
|
|
43
|
-
exclude: [/node_modules/],
|
|
44
|
-
use: [
|
|
45
|
-
'babel-loader',
|
|
46
|
-
{
|
|
47
|
-
loader: 'ts-loader',
|
|
48
|
-
options: {
|
|
49
|
-
configFile: 'tsconfig.json',
|
|
50
|
-
transpileOnly: true,
|
|
51
|
-
experimentalWatchApi: true,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
{test: /\.(less)$/, loader: 'asset/resource'},
|
|
57
|
-
{
|
|
58
|
-
test: /\.svg$/,
|
|
59
|
-
loader: 'raw-loader',
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
|
-
resolve: {
|
|
64
|
-
modules: [__dirname, 'src', 'node_modules'],
|
|
65
|
-
extensions: ['.ts', '.js'],
|
|
66
|
-
},
|
|
67
|
-
plugins: [],
|
|
68
|
-
};
|
package/webpack.config.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import {Configuration} from 'webpack';
|
|
2
|
-
|
|
3
|
-
export default (argv: any, env: any = {mode: 'production'}): Configuration => {
|
|
4
|
-
const mode = argv?.mode || env.mode;
|
|
5
|
-
const config: Configuration = require(`./webpack.${mode === 'development' ? 'dev' : 'prod'}`).default;
|
|
6
|
-
return config;
|
|
7
|
-
};
|
package/webpack.dev.ts
DELETED
package/webpack.prod.ts
DELETED
|
File without changes
|