vue-apextree 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 +80 -0
- package/README.md +329 -0
- package/dist/index.d.ts +160 -0
- package/dist/vue-apextree.js +151 -0
- package/dist/vue-apextree.umd.cjs +1 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
## 📄 License Options for vue-apextree
|
|
2
|
+
|
|
3
|
+
vue-apextree is offered under a **dual-license model** to support individuals, startups, and commercial products of all sizes.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### 🔓 Community License (Free)
|
|
8
|
+
|
|
9
|
+
For individuals, non-profits, educators, and small businesses with **less than $2 million USD in annual revenue**.
|
|
10
|
+
|
|
11
|
+
✅ What's allowed:
|
|
12
|
+
|
|
13
|
+
- Personal, educational, or non-profit use
|
|
14
|
+
- Commercial use by small orgs (< $2M annual revenue)
|
|
15
|
+
- Modifications and redistribution (with attribution)
|
|
16
|
+
|
|
17
|
+
🚫 Not allowed:
|
|
18
|
+
|
|
19
|
+
- Use by companies or entities over $2M/year revenue
|
|
20
|
+
- Use in competing charting products
|
|
21
|
+
- Sublicensing under different terms
|
|
22
|
+
|
|
23
|
+
➡ By using vue-apextree under this license, you confirm that **you qualify as a Small Organization**.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### 💼 Commercial License (Paid)
|
|
28
|
+
|
|
29
|
+
Required if **you or your affiliated organization earns $2 million USD or more per year**.
|
|
30
|
+
|
|
31
|
+
✅ What's included:
|
|
32
|
+
|
|
33
|
+
- Use in internal tools and commercial applications
|
|
34
|
+
- Modifications and app-level distribution
|
|
35
|
+
- 12-month subscription with updates & support
|
|
36
|
+
|
|
37
|
+
🚫 Not allowed:
|
|
38
|
+
|
|
39
|
+
- Redistribution in toolkits, SDKs, or platforms
|
|
40
|
+
- Use by unlicensed developers
|
|
41
|
+
- Competing charting products
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### 🔄 OEM / Redistribution License (Paid)
|
|
46
|
+
|
|
47
|
+
Required if you are **embedding vue-apextree into a product or platform used by other people**, such as:
|
|
48
|
+
|
|
49
|
+
- No-code dashboards
|
|
50
|
+
- Developer platforms
|
|
51
|
+
- Embedded BI tools
|
|
52
|
+
- White-labeled apps or SDKs
|
|
53
|
+
|
|
54
|
+
✅ What's included:
|
|
55
|
+
|
|
56
|
+
- Redistribution rights for 1 application or product
|
|
57
|
+
- 12-month subscription with updates & support
|
|
58
|
+
|
|
59
|
+
✅ OEM **not required** if your app simply renders static charts and users **cannot** configure or interact with them.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
### ⚠️ License Acceptance
|
|
64
|
+
|
|
65
|
+
By installing vue-apextree (e.g., via `npm install vue-apextree`), you are agreeing to the applicable license based on your usage:
|
|
66
|
+
|
|
67
|
+
- Community License (if under $2M revenue)
|
|
68
|
+
- Commercial License (if over $2M revenue)
|
|
69
|
+
- OEM License (if redistributing to third-party users)
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
### 🛠 Need a License or Have Questions?
|
|
74
|
+
|
|
75
|
+
📧 Contact us at [sales@apexcharts.com](mailto:sales@apexcharts.com)
|
|
76
|
+
📚 Read full license agreements here: [https://apexcharts.com/license](https://apexcharts.com/license)
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
Thank you for supporting ApexCharts!
|
package/README.md
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
# vue-apextree
|
|
2
|
+
|
|
3
|
+
Vue 3 wrapper for [ApexTree](https://github.com/apexcharts/apextree) - a JavaScript library for creating organizational and hierarchical charts.
|
|
4
|
+
|
|
5
|
+
<img width="811" alt="ApexTree Example" src="https://github.com/apexcharts/tree/assets/17950663/e09212ec-6322-4c68-ac12-9afc524d2abd">
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install vue-apextree apextree
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
> **Note:** `apextree` is a peer dependency and must be installed alongside `vue-apextree`.
|
|
14
|
+
|
|
15
|
+
## Basic Usage
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import { ApexTreeChart, type NodeData } from 'vue-apextree';
|
|
20
|
+
|
|
21
|
+
const data: NodeData = {
|
|
22
|
+
id: '1',
|
|
23
|
+
name: 'CEO',
|
|
24
|
+
children: [
|
|
25
|
+
{
|
|
26
|
+
id: '2',
|
|
27
|
+
name: 'CTO',
|
|
28
|
+
children: [
|
|
29
|
+
{ id: '3', name: 'Dev Lead' },
|
|
30
|
+
{ id: '4', name: 'QA Lead' },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: '5',
|
|
35
|
+
name: 'CFO',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<ApexTreeChart
|
|
43
|
+
:data="data"
|
|
44
|
+
:width="800"
|
|
45
|
+
:height="600"
|
|
46
|
+
direction="top"
|
|
47
|
+
:node-width="120"
|
|
48
|
+
:node-height="80"
|
|
49
|
+
/>
|
|
50
|
+
</template>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Setting License Key
|
|
54
|
+
|
|
55
|
+
If you have a commercial license, set it once at app initialization:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
// main.ts
|
|
59
|
+
import { setApexTreeLicense } from 'vue-apextree';
|
|
60
|
+
|
|
61
|
+
setApexTreeLicense('your-license-key');
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Using Template Ref Methods
|
|
65
|
+
|
|
66
|
+
Access methods like `changeLayout`, `collapse`, `expand`, and `fitScreen` via template ref:
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<script setup lang="ts">
|
|
70
|
+
import { ref } from 'vue';
|
|
71
|
+
import { ApexTreeChart, type ApexTreeExpose } from 'vue-apextree';
|
|
72
|
+
|
|
73
|
+
const treeRef = ref<ApexTreeExpose | null>(null);
|
|
74
|
+
|
|
75
|
+
const handleChangeLayout = () => {
|
|
76
|
+
treeRef.value?.changeLayout('left');
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const handleCollapse = (nodeId: string) => {
|
|
80
|
+
treeRef.value?.collapse(nodeId);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const handleExpand = (nodeId: string) => {
|
|
84
|
+
treeRef.value?.expand(nodeId);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const handleFitScreen = () => {
|
|
88
|
+
treeRef.value?.fitScreen();
|
|
89
|
+
};
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<template>
|
|
93
|
+
<div>
|
|
94
|
+
<button @click="handleChangeLayout">Change Layout</button>
|
|
95
|
+
<button @click="handleFitScreen">Fit Screen</button>
|
|
96
|
+
|
|
97
|
+
<ApexTreeChart
|
|
98
|
+
ref="treeRef"
|
|
99
|
+
:data="data"
|
|
100
|
+
:width="800"
|
|
101
|
+
:height="600"
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
</template>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Custom Node Templates
|
|
108
|
+
|
|
109
|
+
```vue
|
|
110
|
+
<script setup lang="ts">
|
|
111
|
+
import { ApexTreeChart } from 'vue-apextree';
|
|
112
|
+
|
|
113
|
+
interface PersonData {
|
|
114
|
+
name: string;
|
|
115
|
+
imageURL: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const nodeTemplate = (content: unknown): string => {
|
|
119
|
+
const person = content as PersonData;
|
|
120
|
+
return `
|
|
121
|
+
<div style="display: flex; flex-direction: column; align-items: center; height: 100%;">
|
|
122
|
+
<img
|
|
123
|
+
src="${person.imageURL}"
|
|
124
|
+
style="width: 50px; height: 50px; border-radius: 50%;"
|
|
125
|
+
/>
|
|
126
|
+
<div style="font-weight: bold;">${person.name}</div>
|
|
127
|
+
</div>
|
|
128
|
+
`;
|
|
129
|
+
};
|
|
130
|
+
</script>
|
|
131
|
+
|
|
132
|
+
<template>
|
|
133
|
+
<ApexTreeChart
|
|
134
|
+
:data="data"
|
|
135
|
+
:width="800"
|
|
136
|
+
:height="600"
|
|
137
|
+
content-key="data"
|
|
138
|
+
:node-width="150"
|
|
139
|
+
:node-height="100"
|
|
140
|
+
:node-template="nodeTemplate"
|
|
141
|
+
/>
|
|
142
|
+
</template>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Reactivity
|
|
146
|
+
|
|
147
|
+
The component automatically re-renders when props change, including deep changes to the `data` object:
|
|
148
|
+
|
|
149
|
+
```vue
|
|
150
|
+
<script setup lang="ts">
|
|
151
|
+
import { ref } from 'vue';
|
|
152
|
+
import { ApexTreeChart, type NodeData } from 'vue-apextree';
|
|
153
|
+
|
|
154
|
+
const data = ref<NodeData>({
|
|
155
|
+
id: '1',
|
|
156
|
+
name: 'Root',
|
|
157
|
+
children: [],
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// this will trigger a re-render
|
|
161
|
+
const addChild = () => {
|
|
162
|
+
data.value.children?.push({
|
|
163
|
+
id: String(Date.now()),
|
|
164
|
+
name: 'New Node',
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
</script>
|
|
168
|
+
|
|
169
|
+
<template>
|
|
170
|
+
<button @click="addChild">Add Child</button>
|
|
171
|
+
<ApexTreeChart :data="data" :width="800" :height="600" />
|
|
172
|
+
</template>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Events
|
|
176
|
+
|
|
177
|
+
```vue
|
|
178
|
+
<script setup lang="ts">
|
|
179
|
+
import { ApexTreeChart, type NodeData } from 'vue-apextree';
|
|
180
|
+
|
|
181
|
+
const handleNodeClick = (node: NodeData) => {
|
|
182
|
+
console.log('Node clicked:', node);
|
|
183
|
+
};
|
|
184
|
+
</script>
|
|
185
|
+
|
|
186
|
+
<template>
|
|
187
|
+
<ApexTreeChart
|
|
188
|
+
:data="data"
|
|
189
|
+
:width="800"
|
|
190
|
+
:height="600"
|
|
191
|
+
@node-click="handleNodeClick"
|
|
192
|
+
/>
|
|
193
|
+
</template>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Props
|
|
197
|
+
|
|
198
|
+
| Prop | Type | Default | Description |
|
|
199
|
+
|------|------|---------|-------------|
|
|
200
|
+
| `data` | `NodeData` | **required** | Tree data structure |
|
|
201
|
+
| `width` | `number \| string` | `400` | Width of the container |
|
|
202
|
+
| `height` | `number \| string` | `400` | Height of the container |
|
|
203
|
+
| `direction` | `'top' \| 'bottom' \| 'left' \| 'right'` | `'top'` | Direction of tree growth |
|
|
204
|
+
| `contentKey` | `string` | `'name'` | Key for node content |
|
|
205
|
+
| `siblingSpacing` | `number` | `50` | Spacing between siblings |
|
|
206
|
+
| `childrenSpacing` | `number` | `50` | Spacing between parent and children |
|
|
207
|
+
| `nodeWidth` | `number` | `50` | Width of nodes |
|
|
208
|
+
| `nodeHeight` | `number` | `30` | Height of nodes |
|
|
209
|
+
| `nodeTemplate` | `(content: unknown) => string` | - | Custom HTML template for nodes |
|
|
210
|
+
| `nodeStyle` | `string` | - | CSS styles for nodes |
|
|
211
|
+
| `nodeBGColor` | `string` | `'#FFFFFF'` | Node background color |
|
|
212
|
+
| `nodeBGColorHover` | `string` | `'#FFFFFF'` | Node background color on hover |
|
|
213
|
+
| `borderWidth` | `number` | `1` | Node border width |
|
|
214
|
+
| `borderStyle` | `string` | `'solid'` | Node border style |
|
|
215
|
+
| `borderRadius` | `string` | `'5px'` | Node border radius |
|
|
216
|
+
| `borderColor` | `string` | `'#BCBCBC'` | Node border color |
|
|
217
|
+
| `borderColorHover` | `string` | `'#5C6BC0'` | Node border color on hover |
|
|
218
|
+
| `edgeWidth` | `number` | `1` | Edge line width |
|
|
219
|
+
| `edgeColor` | `string` | `'#BCBCBC'` | Edge line color |
|
|
220
|
+
| `edgeColorHover` | `string` | `'#5C6BC0'` | Edge line color on hover |
|
|
221
|
+
| `fontSize` | `string` | `'14px'` | Font size |
|
|
222
|
+
| `fontFamily` | `string` | - | Font family |
|
|
223
|
+
| `fontWeight` | `string` | `'400'` | Font weight |
|
|
224
|
+
| `fontColor` | `string` | `'#000000'` | Font color |
|
|
225
|
+
| `highlightOnHover` | `boolean` | `true` | Enable highlight on hover |
|
|
226
|
+
| `enableToolbar` | `boolean` | `false` | Show toolbar |
|
|
227
|
+
| `enableExpandCollapse` | `boolean` | `false` | Enable expand/collapse buttons |
|
|
228
|
+
| `enableTooltip` | `boolean` | `false` | Enable tooltips |
|
|
229
|
+
| `tooltipTemplate` | `(content: unknown) => string` | - | Custom tooltip template |
|
|
230
|
+
| `groupLeafNodes` | `boolean` | `false` | Stack leaf nodes |
|
|
231
|
+
|
|
232
|
+
## Events
|
|
233
|
+
|
|
234
|
+
| Event | Payload | Description |
|
|
235
|
+
|-------|---------|-------------|
|
|
236
|
+
| `node-click` | `NodeData` | Emitted when a node is clicked |
|
|
237
|
+
|
|
238
|
+
## Exposed Methods
|
|
239
|
+
|
|
240
|
+
| Method | Description |
|
|
241
|
+
|--------|-------------|
|
|
242
|
+
| `changeLayout(direction?)` | Change tree direction |
|
|
243
|
+
| `collapse(nodeId)` | Collapse a node |
|
|
244
|
+
| `expand(nodeId)` | Expand a node |
|
|
245
|
+
| `fitScreen()` | Fit tree to screen |
|
|
246
|
+
| `getGraph()` | Get the underlying graph instance |
|
|
247
|
+
|
|
248
|
+
## Data Structure
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
interface NodeData<T = unknown> {
|
|
252
|
+
id: string; // unique identifier
|
|
253
|
+
name?: string; // display name (or use contentKey)
|
|
254
|
+
data?: T; // custom data for templates
|
|
255
|
+
options?: NodeOptions; // per-node styling
|
|
256
|
+
children?: NodeData<T>[];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
interface NodeOptions {
|
|
260
|
+
nodeBGColor?: string;
|
|
261
|
+
nodeBGColorHover?: string;
|
|
262
|
+
borderColor?: string;
|
|
263
|
+
borderColorHover?: string;
|
|
264
|
+
fontSize?: string;
|
|
265
|
+
fontFamily?: string;
|
|
266
|
+
fontWeight?: string | number;
|
|
267
|
+
fontColor?: string;
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## TypeScript Support
|
|
272
|
+
|
|
273
|
+
Full TypeScript support with exported types:
|
|
274
|
+
|
|
275
|
+
```ts
|
|
276
|
+
import type {
|
|
277
|
+
ApexTreeProps,
|
|
278
|
+
ApexTreeExpose,
|
|
279
|
+
NodeData,
|
|
280
|
+
NodeOptions,
|
|
281
|
+
TreeDirection,
|
|
282
|
+
GraphInstance,
|
|
283
|
+
} from 'vue-apextree';
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## License
|
|
287
|
+
|
|
288
|
+
vue-apextree uses the same dual-license model as ApexCharts. See [LICENSE](./LICENSE) for details.
|
|
289
|
+
|
|
290
|
+
- **Free** for individuals, non-profits, and small businesses (< $2M revenue)
|
|
291
|
+
- **Commercial license** required for larger organizations
|
|
292
|
+
|
|
293
|
+
## Links
|
|
294
|
+
|
|
295
|
+
- [ApexTree Documentation](https://github.com/apexcharts/apextree)
|
|
296
|
+
- [ApexCharts](https://apexcharts.com)
|
|
297
|
+
- [License Information](https://apexcharts.com/license)
|
|
298
|
+
|
|
299
|
+
## Development
|
|
300
|
+
|
|
301
|
+
### Running the Demo
|
|
302
|
+
|
|
303
|
+
The package includes a demo app showcasing various features:
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
# clone the repo
|
|
307
|
+
git clone https://github.com/apexcharts/vue-apextree.git
|
|
308
|
+
cd vue-apextree
|
|
309
|
+
|
|
310
|
+
# install dependencies
|
|
311
|
+
npm install
|
|
312
|
+
cd demo && npm install && cd ..
|
|
313
|
+
|
|
314
|
+
# build the library
|
|
315
|
+
npm run build
|
|
316
|
+
|
|
317
|
+
# run the demo
|
|
318
|
+
npm run demo
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Then open http://localhost:5173 to see the examples.
|
|
322
|
+
|
|
323
|
+
### Available Scripts
|
|
324
|
+
|
|
325
|
+
- `npm run build` - Build the library
|
|
326
|
+
- `npm run dev` - Build in watch mode
|
|
327
|
+
- `npm run typecheck` - Run TypeScript type checking
|
|
328
|
+
- `npm run demo` - Run the demo app
|
|
329
|
+
- `npm run demo:build` - Build the demo app
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
2
|
+
import { ComponentProvideOptions } from 'vue';
|
|
3
|
+
import { CSSProperties } from 'vue';
|
|
4
|
+
import { DefineComponent } from 'vue';
|
|
5
|
+
import { PublicProps } from 'vue';
|
|
6
|
+
import { Ref } from 'vue';
|
|
7
|
+
import { ShallowRef } from 'vue';
|
|
8
|
+
|
|
9
|
+
declare type __VLS_Props = ApexTreeProps;
|
|
10
|
+
|
|
11
|
+
export declare const ApexTreeChart: DefineComponent<__VLS_Props, {
|
|
12
|
+
changeLayout: (direction?: TreeDirection) => void;
|
|
13
|
+
collapse: (nodeId: string) => void;
|
|
14
|
+
expand: (nodeId: string) => void;
|
|
15
|
+
fitScreen: () => void;
|
|
16
|
+
getGraph: () => GraphInstance | null;
|
|
17
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
18
|
+
width: number | string;
|
|
19
|
+
height: number | string;
|
|
20
|
+
direction: TreeDirection;
|
|
21
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
22
|
+
containerRef: HTMLDivElement;
|
|
23
|
+
}, HTMLDivElement>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* methods exposed via defineExpose
|
|
27
|
+
*/
|
|
28
|
+
declare interface ApexTreeExposed {
|
|
29
|
+
changeLayout: (direction?: TreeDirection) => void;
|
|
30
|
+
collapse: (nodeId: string) => void;
|
|
31
|
+
expand: (nodeId: string) => void;
|
|
32
|
+
fitScreen: () => void;
|
|
33
|
+
getGraph: () => GraphInstance | null;
|
|
34
|
+
}
|
|
35
|
+
export { ApexTreeExposed as ApexTreeExpose }
|
|
36
|
+
export { ApexTreeExposed }
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* props for the ApexTreeChart Vue component
|
|
40
|
+
*/
|
|
41
|
+
export declare interface ApexTreeProps<T = unknown> {
|
|
42
|
+
data: NodeData<T>;
|
|
43
|
+
class?: string;
|
|
44
|
+
style?: CSSProperties;
|
|
45
|
+
width?: number | string;
|
|
46
|
+
height?: number | string;
|
|
47
|
+
direction?: TreeDirection;
|
|
48
|
+
siblingSpacing?: number;
|
|
49
|
+
childrenSpacing?: number;
|
|
50
|
+
containerClassName?: string;
|
|
51
|
+
canvasStyle?: string;
|
|
52
|
+
contentKey?: string;
|
|
53
|
+
nodeWidth?: number;
|
|
54
|
+
nodeHeight?: number;
|
|
55
|
+
nodeTemplate?: (content: unknown) => string;
|
|
56
|
+
nodeStyle?: string;
|
|
57
|
+
nodeClassName?: string;
|
|
58
|
+
nodeBGColor?: string;
|
|
59
|
+
nodeBGColorHover?: string;
|
|
60
|
+
borderWidth?: number;
|
|
61
|
+
borderStyle?: string;
|
|
62
|
+
borderRadius?: string;
|
|
63
|
+
borderColor?: string;
|
|
64
|
+
borderColorHover?: string;
|
|
65
|
+
edgeWidth?: number;
|
|
66
|
+
edgeColor?: string;
|
|
67
|
+
edgeColorHover?: string;
|
|
68
|
+
fontSize?: string;
|
|
69
|
+
fontFamily?: string;
|
|
70
|
+
fontWeight?: string;
|
|
71
|
+
fontColor?: string;
|
|
72
|
+
enableTooltip?: boolean;
|
|
73
|
+
tooltipId?: string;
|
|
74
|
+
tooltipTemplate?: (content: unknown) => string;
|
|
75
|
+
tooltipMaxWidth?: number;
|
|
76
|
+
tooltipMinWidth?: number;
|
|
77
|
+
tooltipBorderColor?: string;
|
|
78
|
+
tooltipBGColor?: string;
|
|
79
|
+
tooltipFontColor?: string;
|
|
80
|
+
tooltipFontSize?: string;
|
|
81
|
+
tooltipPadding?: number;
|
|
82
|
+
tooltipOffset?: number;
|
|
83
|
+
highlightOnHover?: boolean;
|
|
84
|
+
enableToolbar?: boolean;
|
|
85
|
+
enableExpandCollapse?: boolean;
|
|
86
|
+
expandCollapseButtonBGColor?: string;
|
|
87
|
+
expandCollapseButtonBorderColor?: string;
|
|
88
|
+
groupLeafNodes?: boolean;
|
|
89
|
+
groupLeafNodesSpacing?: number;
|
|
90
|
+
onNodeClick?: (node: NodeData<T>) => void;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* graph instance returned by ApexTree.render()
|
|
95
|
+
*/
|
|
96
|
+
export declare interface GraphInstance {
|
|
97
|
+
changeLayout: (direction?: TreeDirection) => void;
|
|
98
|
+
collapse: (nodeId: string) => void;
|
|
99
|
+
expand: (nodeId: string) => void;
|
|
100
|
+
fitScreen: () => void;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* node data structure expected by ApexTree
|
|
105
|
+
*/
|
|
106
|
+
export declare interface NodeData<T = unknown> {
|
|
107
|
+
id: string;
|
|
108
|
+
name?: string;
|
|
109
|
+
data?: T;
|
|
110
|
+
options?: NodeOptions;
|
|
111
|
+
children?: Array<NodeData<T>>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* per-node styling options
|
|
116
|
+
*/
|
|
117
|
+
export declare interface NodeOptions {
|
|
118
|
+
nodeBGColor?: string;
|
|
119
|
+
nodeBGColorHover?: string;
|
|
120
|
+
borderColor?: string;
|
|
121
|
+
borderColorHover?: string;
|
|
122
|
+
fontSize?: string;
|
|
123
|
+
fontFamily?: string;
|
|
124
|
+
fontWeight?: string | number;
|
|
125
|
+
fontColor?: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* sets the license key for ApexTree
|
|
130
|
+
* call this at app initialization before rendering any trees
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* import { setApexTreeLicense } from 'vue-apextree';
|
|
135
|
+
*
|
|
136
|
+
* // in main.ts or app entry
|
|
137
|
+
* setApexTreeLicense('your-license-key');
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export declare function setApexTreeLicense(key: string): void;
|
|
141
|
+
|
|
142
|
+
export declare type TreeDirection = 'top' | 'bottom' | 'left' | 'right';
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* composable for managing ApexTree instance
|
|
146
|
+
* provides reactive tree management with imperative methods
|
|
147
|
+
*/
|
|
148
|
+
export declare function useApexTree(): {
|
|
149
|
+
graphRef: ShallowRef<GraphInstance | null, GraphInstance | null>;
|
|
150
|
+
containerRef: Ref<HTMLElement | null, HTMLElement | null>;
|
|
151
|
+
render: (container: HTMLElement, data: NodeData, options: Record<string, unknown>) => GraphInstance | null;
|
|
152
|
+
changeLayout: (direction?: TreeDirection) => void;
|
|
153
|
+
collapse: (nodeId: string) => void;
|
|
154
|
+
expand: (nodeId: string) => void;
|
|
155
|
+
fitScreen: () => void;
|
|
156
|
+
getGraph: () => GraphInstance | null;
|
|
157
|
+
cleanup: () => void;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export { }
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { shallowRef as v, ref as g, onUnmounted as y, defineComponent as m, computed as x, onMounted as B, watch as h, createElementBlock as S, openBlock as b, normalizeStyle as T, normalizeClass as L } from "vue";
|
|
2
|
+
import C from "apextree";
|
|
3
|
+
const _ = ["data", "class", "style"];
|
|
4
|
+
function G(e) {
|
|
5
|
+
const l = {};
|
|
6
|
+
for (const [n, a] of Object.entries(e))
|
|
7
|
+
_.includes(n) || a !== void 0 && (l[n] = a);
|
|
8
|
+
return l;
|
|
9
|
+
}
|
|
10
|
+
function H() {
|
|
11
|
+
const e = v(null), l = g(null);
|
|
12
|
+
function n(o, t, i) {
|
|
13
|
+
o.innerHTML = "";
|
|
14
|
+
const f = new C(o, i).render(t);
|
|
15
|
+
return e.value = f, l.value = o, f;
|
|
16
|
+
}
|
|
17
|
+
function a(o) {
|
|
18
|
+
var t;
|
|
19
|
+
(t = e.value) == null || t.changeLayout(o);
|
|
20
|
+
}
|
|
21
|
+
function c(o) {
|
|
22
|
+
var t;
|
|
23
|
+
(t = e.value) == null || t.collapse(o);
|
|
24
|
+
}
|
|
25
|
+
function d(o) {
|
|
26
|
+
var t;
|
|
27
|
+
(t = e.value) == null || t.expand(o);
|
|
28
|
+
}
|
|
29
|
+
function s() {
|
|
30
|
+
var o;
|
|
31
|
+
(o = e.value) == null || o.fitScreen();
|
|
32
|
+
}
|
|
33
|
+
function u() {
|
|
34
|
+
return e.value;
|
|
35
|
+
}
|
|
36
|
+
function p() {
|
|
37
|
+
l.value && (l.value.innerHTML = ""), e.value = null;
|
|
38
|
+
}
|
|
39
|
+
return y(p), {
|
|
40
|
+
graphRef: e,
|
|
41
|
+
containerRef: l,
|
|
42
|
+
render: n,
|
|
43
|
+
changeLayout: a,
|
|
44
|
+
collapse: c,
|
|
45
|
+
expand: d,
|
|
46
|
+
fitScreen: s,
|
|
47
|
+
getGraph: u,
|
|
48
|
+
cleanup: p
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const W = /* @__PURE__ */ m({
|
|
52
|
+
__name: "ApexTreeChart",
|
|
53
|
+
props: {
|
|
54
|
+
data: {},
|
|
55
|
+
class: {},
|
|
56
|
+
style: {},
|
|
57
|
+
width: { default: 400 },
|
|
58
|
+
height: { default: 400 },
|
|
59
|
+
direction: { default: "top" },
|
|
60
|
+
siblingSpacing: {},
|
|
61
|
+
childrenSpacing: {},
|
|
62
|
+
containerClassName: {},
|
|
63
|
+
canvasStyle: {},
|
|
64
|
+
contentKey: {},
|
|
65
|
+
nodeWidth: {},
|
|
66
|
+
nodeHeight: {},
|
|
67
|
+
nodeTemplate: {},
|
|
68
|
+
nodeStyle: {},
|
|
69
|
+
nodeClassName: {},
|
|
70
|
+
nodeBGColor: {},
|
|
71
|
+
nodeBGColorHover: {},
|
|
72
|
+
borderWidth: {},
|
|
73
|
+
borderStyle: {},
|
|
74
|
+
borderRadius: {},
|
|
75
|
+
borderColor: {},
|
|
76
|
+
borderColorHover: {},
|
|
77
|
+
edgeWidth: {},
|
|
78
|
+
edgeColor: {},
|
|
79
|
+
edgeColorHover: {},
|
|
80
|
+
fontSize: {},
|
|
81
|
+
fontFamily: {},
|
|
82
|
+
fontWeight: {},
|
|
83
|
+
fontColor: {},
|
|
84
|
+
enableTooltip: { type: Boolean },
|
|
85
|
+
tooltipId: {},
|
|
86
|
+
tooltipTemplate: {},
|
|
87
|
+
tooltipMaxWidth: {},
|
|
88
|
+
tooltipMinWidth: {},
|
|
89
|
+
tooltipBorderColor: {},
|
|
90
|
+
tooltipBGColor: {},
|
|
91
|
+
tooltipFontColor: {},
|
|
92
|
+
tooltipFontSize: {},
|
|
93
|
+
tooltipPadding: {},
|
|
94
|
+
tooltipOffset: {},
|
|
95
|
+
highlightOnHover: { type: Boolean },
|
|
96
|
+
enableToolbar: { type: Boolean },
|
|
97
|
+
enableExpandCollapse: { type: Boolean },
|
|
98
|
+
expandCollapseButtonBGColor: {},
|
|
99
|
+
expandCollapseButtonBorderColor: {},
|
|
100
|
+
groupLeafNodes: { type: Boolean },
|
|
101
|
+
groupLeafNodesSpacing: {},
|
|
102
|
+
onNodeClick: {}
|
|
103
|
+
},
|
|
104
|
+
setup(e, { expose: l }) {
|
|
105
|
+
const n = e, a = g(null), {
|
|
106
|
+
render: c,
|
|
107
|
+
changeLayout: d,
|
|
108
|
+
collapse: s,
|
|
109
|
+
expand: u,
|
|
110
|
+
fitScreen: p,
|
|
111
|
+
getGraph: o
|
|
112
|
+
} = H(), t = x(() => G(n));
|
|
113
|
+
function i() {
|
|
114
|
+
!a.value || !n.data || c(a.value, n.data, t.value);
|
|
115
|
+
}
|
|
116
|
+
return B(() => {
|
|
117
|
+
i();
|
|
118
|
+
}), h(
|
|
119
|
+
() => n.data,
|
|
120
|
+
() => {
|
|
121
|
+
i();
|
|
122
|
+
},
|
|
123
|
+
{ deep: !0 }
|
|
124
|
+
), h(
|
|
125
|
+
t,
|
|
126
|
+
() => {
|
|
127
|
+
i();
|
|
128
|
+
},
|
|
129
|
+
{ deep: !0 }
|
|
130
|
+
), l({
|
|
131
|
+
changeLayout: (r) => d(r),
|
|
132
|
+
collapse: (r) => s(r),
|
|
133
|
+
expand: (r) => u(r),
|
|
134
|
+
fitScreen: () => p(),
|
|
135
|
+
getGraph: () => o()
|
|
136
|
+
}), (r, f) => (b(), S("div", {
|
|
137
|
+
ref_key: "containerRef",
|
|
138
|
+
ref: a,
|
|
139
|
+
class: L(n.class),
|
|
140
|
+
style: T(n.style)
|
|
141
|
+
}, null, 6));
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
function k(e) {
|
|
145
|
+
C.setLicense(e);
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
W as ApexTreeChart,
|
|
149
|
+
k as setApexTreeLicense,
|
|
150
|
+
H as useApexTree
|
|
151
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(r,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("apextree")):typeof define=="function"&&define.amd?define(["exports","vue","apextree"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r.VueApexTree={},r.Vue,r.ApexTree))})(this,(function(r,e,g){"use strict";const x=["data","class","style"];function T(o){const a={};for(const[l,i]of Object.entries(o))x.includes(l)||i!==void 0&&(a[l]=i);return a}function C(){const o=e.shallowRef(null),a=e.ref(null);function l(t,n,p){t.innerHTML="";const y=new g(t,p).render(n);return o.value=y,a.value=t,y}function i(t){var n;(n=o.value)==null||n.changeLayout(t)}function s(t){var n;(n=o.value)==null||n.collapse(t)}function u(t){var n;(n=o.value)==null||n.expand(t)}function f(){var t;(t=o.value)==null||t.fitScreen()}function h(){return o.value}function c(){a.value&&(a.value.innerHTML=""),o.value=null}return e.onUnmounted(c),{graphRef:o,containerRef:a,render:l,changeLayout:i,collapse:s,expand:u,fitScreen:f,getGraph:h,cleanup:c}}const m=e.defineComponent({__name:"ApexTreeChart",props:{data:{},class:{},style:{},width:{default:400},height:{default:400},direction:{default:"top"},siblingSpacing:{},childrenSpacing:{},containerClassName:{},canvasStyle:{},contentKey:{},nodeWidth:{},nodeHeight:{},nodeTemplate:{},nodeStyle:{},nodeClassName:{},nodeBGColor:{},nodeBGColorHover:{},borderWidth:{},borderStyle:{},borderRadius:{},borderColor:{},borderColorHover:{},edgeWidth:{},edgeColor:{},edgeColorHover:{},fontSize:{},fontFamily:{},fontWeight:{},fontColor:{},enableTooltip:{type:Boolean},tooltipId:{},tooltipTemplate:{},tooltipMaxWidth:{},tooltipMinWidth:{},tooltipBorderColor:{},tooltipBGColor:{},tooltipFontColor:{},tooltipFontSize:{},tooltipPadding:{},tooltipOffset:{},highlightOnHover:{type:Boolean},enableToolbar:{type:Boolean},enableExpandCollapse:{type:Boolean},expandCollapseButtonBGColor:{},expandCollapseButtonBorderColor:{},groupLeafNodes:{type:Boolean},groupLeafNodesSpacing:{},onNodeClick:{}},setup(o,{expose:a}){const l=o,i=e.ref(null),{render:s,changeLayout:u,collapse:f,expand:h,fitScreen:c,getGraph:t}=C(),n=e.computed(()=>T(l));function p(){!i.value||!l.data||s(i.value,l.data,n.value)}return e.onMounted(()=>{p()}),e.watch(()=>l.data,()=>{p()},{deep:!0}),e.watch(n,()=>{p()},{deep:!0}),a({changeLayout:d=>u(d),collapse:d=>f(d),expand:d=>h(d),fitScreen:()=>c(),getGraph:()=>t()}),(d,y)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:e.normalizeClass(l.class),style:e.normalizeStyle(l.style)},null,6))}});function S(o){g.setLicense(o)}r.ApexTreeChart=m,r.setApexTreeLicense=S,r.useApexTree=C,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vue-apextree",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Vue wrapper for ApexTree - a JavaScript library for creating organizational and hierarchical charts",
|
|
5
|
+
"author": "ApexCharts <info@apexcharts.com>",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/vue-apextree.umd.cjs",
|
|
9
|
+
"module": "./dist/vue-apextree.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/vue-apextree.js",
|
|
15
|
+
"require": "./dist/vue-apextree.umd.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"vue",
|
|
24
|
+
"vue3",
|
|
25
|
+
"apextree",
|
|
26
|
+
"tree",
|
|
27
|
+
"chart",
|
|
28
|
+
"organizational-chart",
|
|
29
|
+
"org-chart",
|
|
30
|
+
"hierarchy",
|
|
31
|
+
"flowchart",
|
|
32
|
+
"diagram"
|
|
33
|
+
],
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/apexcharts/vue-apextree.git"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/apexcharts/vue-apextree/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/apexcharts/vue-apextree#readme",
|
|
42
|
+
"scripts": {
|
|
43
|
+
"dev": "vite build --watch",
|
|
44
|
+
"build": "vue-tsc --noEmit && vite build",
|
|
45
|
+
"typecheck": "vue-tsc --noEmit",
|
|
46
|
+
"demo": "npm run --prefix demo dev",
|
|
47
|
+
"demo:build": "npm run --prefix demo build"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"apextree": ">=1.0.0",
|
|
51
|
+
"vue": ">=3.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
55
|
+
"apextree": "^1.0.2",
|
|
56
|
+
"typescript": "^5.7.2",
|
|
57
|
+
"vite": "^6.0.6",
|
|
58
|
+
"vite-plugin-dts": "^4.4.0",
|
|
59
|
+
"vue": "^3.5.13",
|
|
60
|
+
"vue-tsc": "^2.2.0"
|
|
61
|
+
}
|
|
62
|
+
}
|