vue3-dnd-tree 0.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,56 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). While the
6
+ version stays below 1.0.0, breaking changes ship in minor releases — see D-9 in
7
+ [docs/SPEC.md](./docs/SPEC.md).
8
+
9
+ ## [0.2.0] - 2026-09-22
10
+
11
+ ### Changed
12
+
13
+ - The package is published to npm as `vue3-dnd-tree`. The name `vue3-tree` belongs to
14
+ an unrelated project on npm, so imports and the UMD global (`Vue3DndTree`) use the
15
+ new name.
16
+
17
+ - **Breaking.** The plugin registers its components as `Vue3Tree` and `Vue3Treenode`
18
+ instead of `tree` and `treenode`. `V*` is Vuetify's namespace, so a package-derived
19
+ prefix keeps the two apart.
20
+
21
+ ```diff
22
+ - <tree :node="root" :version="version" />
23
+ + <Vue3Tree :node="root" :version="version" />
24
+ ```
25
+
26
+ To choose your own names, pass
27
+ `createVue3Tree({ components: { tree: "MyTree", treenode: "MyTreenode" } })`.
28
+
29
+ - **Breaking.** Removed the legacy `tree` export. The component is exported as `VTree`.
30
+
31
+ ```diff
32
+ - import { tree } from "vue3-dnd-tree";
33
+ + import { VTree } from "vue3-dnd-tree";
34
+ ```
35
+
36
+ ### Fixed
37
+
38
+ - The default slot is now typed. Using `#default` from TypeScript failed with
39
+ `Property 'default' does not exist on type '{}'`: `useSlots()` does not surface a
40
+ slot type, and vue-tsc does not infer one from the template.
41
+ - The `GlobalComponents` augmentation is now actually published. It lived in a
42
+ standalone `.d.ts`, which vue-tsc does not re-emit, so it never reached
43
+ `dist/types`. Consumers got no types for the globally registered components — they
44
+ could omit required props with no error — and `dist/types/index.d.ts` carried an
45
+ unresolvable `import "./global.d.ts"`.
46
+
47
+ ### Removed
48
+
49
+ - The `modification has not reflected.` marker shown on the root subtree until
50
+ `version` was incremented. It was a development aid, not something to render in a
51
+ consuming app.
52
+ - Debug `console.log` calls in `tree.vue` and `treenode.ts`.
53
+
54
+ ## [0.1.0]
55
+
56
+ Initial release. Not published to npm.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2023 Yusuke SAITO
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,241 @@
1
+ vue3-dnd-tree
2
+ =============
3
+
4
+ A tree component for Vue 3 and Vuetify 3 with drag and drop support.
5
+
6
+ - Rearrange nodes by dragging: reorder among siblings, or move under another node.
7
+ - Fold / unfold, with auto-expand while hovering a folded node during a drag.
8
+ - Inline renaming on double click.
9
+ - Bring your own domain model: extend `BaseTreenode<T>` instead of converting your data.
10
+
11
+ # Install
12
+
13
+ ```bash
14
+ npm install vue3-dnd-tree
15
+ # or
16
+ yarn add vue3-dnd-tree
17
+ ```
18
+
19
+ `vue`, `vuetify` and `@mdi/font` are peer dependencies. `vuetify` and `@mdi/font` are
20
+ optional, but the caret icons are rendered with Material Design Icons, and hover styles
21
+ read Vuetify theme variables, so a Vuetify app is the intended host.
22
+
23
+ # Setup
24
+
25
+ ## As a plugin
26
+
27
+ ```ts
28
+ import { createApp } from "vue";
29
+ import { createVue3Tree } from "vue3-dnd-tree";
30
+ import "vue3-dnd-tree/style.css";
31
+ import "@mdi/font/css/materialdesignicons.css";
32
+
33
+ const app = createApp(App);
34
+ app.use(createVue3Tree());
35
+ app.mount("#app");
36
+ ```
37
+
38
+ This registers two global components, `Vue3Tree` and `Vue3Treenode`. You only use
39
+ `Vue3Tree`; `Vue3Treenode` is the recursive child it renders. Pass options to rename
40
+ them:
41
+
42
+ ```ts
43
+ app.use(createVue3Tree({ components: { tree: "MyTree", treenode: "MyTreenode" } }));
44
+ ```
45
+
46
+ The default export is the same plugin with the default names, so `app.use(Vue3Tree)`
47
+ also works:
48
+
49
+ ```ts
50
+ import Vue3Tree from "vue3-dnd-tree";
51
+ ```
52
+
53
+ ## Direct import
54
+
55
+ ```vue
56
+ <script setup lang="ts">
57
+ import { VTree } from "vue3-dnd-tree";
58
+ import "vue3-dnd-tree/style.css";
59
+ </script>
60
+
61
+ <template>
62
+ <VTree :node="state.root" :version="state.version" />
63
+ </template>
64
+ ```
65
+
66
+ # Defining a node
67
+
68
+ Extend `BaseTreenode<T>`, where `T` is your own content type. The component never
69
+ mutates your objects, so the class is just an adapter over the data you already have.
70
+
71
+ ```ts
72
+ import { BaseTreenode } from "vue3-dnd-tree";
73
+
74
+ export type Task = {
75
+ id: string;
76
+ title: string;
77
+ type: string;
78
+ children: Task[];
79
+ };
80
+
81
+ export class TaskNode extends BaseTreenode<Task> {
82
+ private _content: Task;
83
+ private _subtrees: this[];
84
+
85
+ constructor(content: Task) {
86
+ super();
87
+ this._content = content;
88
+ this._subtrees = content.children.map(c => new (this.constructor as any)(c));
89
+ this.isFolding = false; // start expanded
90
+ }
91
+
92
+ get id(): string { return this._content.id; }
93
+ get name(): string { return this._content.title; }
94
+ get content(): Task { return this._content; }
95
+ get subtrees(): this[] { return this._subtrees; }
96
+ get styleClass(): object | null { return { [this._content.type]: true }; }
97
+ get isDraggable(): boolean { return true; }
98
+
99
+ update(newContent: Task) { this._content = newContent; }
100
+ }
101
+ ```
102
+
103
+ | Member | Meaning |
104
+ |---|---|
105
+ | `id` | Unique within the tree. Every event identifies nodes by this. |
106
+ | `name` | Text shown when no slot is given, and the value edited on double click. |
107
+ | `content` | Your own object. Handed back to you through the slot. |
108
+ | `subtrees` | Child nodes, same class. |
109
+ | `styleClass` | Bound to `:class` on the `li` element, or `null`. |
110
+ | `isDraggable` | `false` renders the node greyed out (`.freeze`) and not draggable. |
111
+ | `isFolding` | Provided by the base class. `true` hides the children. |
112
+
113
+ `BaseTreenode` also gives you `findNodeById(id)` and `onToggleFolding(id)`, and the
114
+ standalone `findNodeById(id, node)` is exported as well.
115
+
116
+ # Using the component
117
+
118
+ ```vue
119
+ <script setup lang="ts">
120
+ import { reactive } from "vue";
121
+ import type { TreeEventHandlers } from "vue3-dnd-tree";
122
+ import { TaskNode, type Task } from "./task-node";
123
+
124
+ type State = { root: TaskNode; version: number };
125
+
126
+ // the `as State` keeps TaskNode from being unwrapped into UnwrapRef<TaskNode>
127
+ const state = reactive<State>({ root: new TaskNode(source), version: 0 }) as State;
128
+
129
+ const handlers: TreeEventHandlers<Task, TaskNode> = {
130
+ "rearrange": (targetId, from, to, index) => {
131
+ state.root.rearrange(targetId, from, to, index); // your own move logic
132
+ state.version += 1;
133
+ },
134
+ "toggle-folding": (id) => {
135
+ state.root.onToggleFolding(id);
136
+ },
137
+ "toggle-editing": (id, isEditing) => {},
138
+ "update-name": (id, newValue) => {
139
+ const node = state.root.findNodeById(id);
140
+ if (node === null) return;
141
+ node.content.title = newValue;
142
+ state.version += 1;
143
+ },
144
+ "select": (node) => {
145
+ console.log(node ? `${node.name} is selected` : "nothing is selected");
146
+ }
147
+ };
148
+ </script>
149
+
150
+ <template>
151
+ <Vue3Tree
152
+ :node="state.root"
153
+ :version="state.version"
154
+ @rearrange="handlers['rearrange']"
155
+ @toggle-folding="handlers['toggle-folding']"
156
+ @toggle-editing="handlers['toggle-editing']"
157
+ @update-name="handlers['update-name']"
158
+ @select="handlers['select']"
159
+ />
160
+ </template>
161
+ ```
162
+
163
+ ## Props
164
+
165
+ | Prop | Type | Required | Meaning |
166
+ |---|---|---|---|
167
+ | `node` | `T extends BaseTreenode<U>` | yes | The root node. |
168
+ | `version` | `number` | yes | Bump it to rebuild the tree from `node`. See below. |
169
+
170
+ ## Events
171
+
172
+ ```ts
173
+ {
174
+ "rearrange" : (targetId: string, from: string, to: string, index: number) => void
175
+ "toggle-folding" : (id: string) => void
176
+ "toggle-editing" : (id: string, isEditing: boolean) => void
177
+ "update-name" : (id: string, newValue: string) => void
178
+ "select" : (node: T | undefined) => void
179
+ }
180
+ ```
181
+
182
+ - `rearrange` fires once a drop is committed. `targetId` is the moved node, `from` and
183
+ `to` are the ids of the old and new parent, and `index` is the position among the new
184
+ parent's children.
185
+ - `toggle-folding` also fires when a folded node is auto-expanded during a drag.
186
+ - `select` fires with the clicked node, and with `undefined` when a click lands outside
187
+ any node.
188
+
189
+ `TreeEventHandlers<U, T>` is exported so you can type the whole handler set at once, as
190
+ in the example above.
191
+
192
+ ## Slot
193
+
194
+ The default slot replaces the label of every node, at every depth.
195
+
196
+ ```ts
197
+ type SlotProps = {
198
+ node: T;
199
+ parent: T | undefined; // undefined for the root
200
+ depth: number; // 0 for the root
201
+ isHovering: boolean;
202
+ isEditing: boolean;
203
+ endEditing: (shouldCommit: boolean) => void;
204
+ };
205
+ ```
206
+
207
+ ```vue
208
+ <Vue3Tree :node="state.root" :version="state.version">
209
+ <template v-slot="slotProps">
210
+ <input
211
+ v-if="slotProps.isEditing"
212
+ v-model="slotProps.node.name"
213
+ @blur="slotProps.endEditing(true)"
214
+ />
215
+ <span v-else>{{ slotProps.node.name }}</span>
216
+ </template>
217
+ </Vue3Tree>
218
+ ```
219
+
220
+ `endEditing(true)` commits the edited name and emits `update-name`; `endEditing(false)`
221
+ discards it. Without a slot, the component renders `name (id)` and its own `input`.
222
+
223
+ # Reflecting external changes
224
+
225
+ The component deep-copies `node` into its own state on mount, so that your model is not
226
+ touched while a drag is still in flight, and so that display-only flags (`isEditing`,
227
+ `isHovering`) never leak into your objects. That copy is what you must keep in sync:
228
+
229
+ 1. Handle `rearrange` / `update-name` by updating your own model.
230
+ 2. Increment `version`.
231
+
232
+ Watching `version` is what rebuilds the internal tree. Until you do, the component keeps
233
+ showing its own copy, which no longer matches your model.
234
+
235
+ Nodes handed to event handlers and to the slot are nodes of that internal copy, not your
236
+ own instances — their `content` is the same object reference, but methods you defined on
237
+ your class are not available there. Look your own node up by `id` when you need it.
238
+
239
+ # License
240
+
241
+ Apache-2.0
@@ -0,0 +1,13 @@
1
+ import VTree from "./tree.vue";
2
+ import VTreenode from "./treenode.vue";
3
+ export type { TreeEventHandlers } from "./tree";
4
+ export { findNodeById, BaseUpdatableTreenode as BaseTreenode } from "./treenode";
5
+ export { VTree, VTreenode };
6
+ export { createVue3Tree, Vue3TreePlugin, type Vue3TreePluginOptions } from "./plugin";
7
+ export { Vue3TreePlugin as default } from "./plugin";
8
+ declare module "vue" {
9
+ interface GlobalComponents {
10
+ Vue3Tree: typeof VTree;
11
+ Vue3Treenode: typeof VTreenode;
12
+ }
13
+ }
@@ -0,0 +1,49 @@
1
+ import type { Plugin } from "vue";
2
+ /**
3
+ * Plugin options for Vue3 Tree
4
+ */
5
+ export interface Vue3TreePluginOptions {
6
+ /**
7
+ * Custom component names
8
+ * @default { tree: 'Vue3Tree', treenode: 'Vue3Treenode' }
9
+ */
10
+ components?: {
11
+ tree?: string;
12
+ treenode?: string;
13
+ };
14
+ }
15
+ /**
16
+ * Creates the Vue3 Tree plugin for Vuetify 3
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { createApp } from 'vue'
21
+ * import { createVuetify } from 'vuetify'
22
+ * import { createVue3Tree } from 'vue3-dnd-tree'
23
+ * import 'vue3-dnd-tree/style.css'
24
+ *
25
+ * const app = createApp(App)
26
+ * const vuetify = createVuetify()
27
+ * const vue3Tree = createVue3Tree()
28
+ *
29
+ * app.use(vuetify)
30
+ * app.use(vue3Tree)
31
+ * app.mount('#app')
32
+ * ```
33
+ */
34
+ export declare function createVue3Tree(options?: Vue3TreePluginOptions): Plugin<[]>;
35
+ /**
36
+ * Default plugin instance
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { createApp } from 'vue'
41
+ * import Vue3Tree from 'vue3-dnd-tree'
42
+ * import 'vue3-dnd-tree/style.css'
43
+ *
44
+ * const app = createApp(App)
45
+ * app.use(Vue3Tree)
46
+ * app.mount('#app')
47
+ * ```
48
+ */
49
+ export declare const Vue3TreePlugin: Plugin<[]>;
@@ -0,0 +1,16 @@
1
+ import type { BaseTreenode } from "./treenode";
2
+ export type EventHandlersFromEvents<E extends Record<PropertyKey, readonly unknown[]>> = {
3
+ [K in keyof E]: (...args: E[K]) => void;
4
+ };
5
+ export type TreeProps<U, T extends BaseTreenode<U>> = {
6
+ node: T;
7
+ version: number;
8
+ };
9
+ export type TreeEvents<U, T extends BaseTreenode<U>> = {
10
+ "rearrange": [targetId: T["id"], from: T["id"], to: T["id"], index: number];
11
+ "toggle-folding": [id: T["id"]];
12
+ "toggle-editing": [id: T["id"], isEditing: boolean];
13
+ "update-name": [id: T["id"], newValue: T["name"]];
14
+ "select": [node: T | undefined];
15
+ };
16
+ export type TreeEventHandlers<U, T extends BaseTreenode<U>> = EventHandlersFromEvents<TreeEvents<U, T>>;