@v-c/tree 0.0.2 → 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/dist/MotionTreeNode.cjs +8 -2
- package/dist/MotionTreeNode.d.ts +1 -0
- package/dist/MotionTreeNode.js +8 -2
- package/dist/NodeList.cjs +66 -100
- package/dist/NodeList.d.ts +0 -1
- package/dist/NodeList.js +66 -101
- package/dist/Tree.cjs +0 -1
- package/dist/Tree.js +0 -1
- package/dist/TreeNode.cjs +13 -6
- package/dist/TreeNode.js +14 -7
- package/dist/index.cjs +0 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/interface.d.ts +1 -0
- package/dist/utils/treeUtil.cjs +9 -0
- package/dist/utils/treeUtil.d.ts +2 -0
- package/dist/utils/treeUtil.js +8 -1
- package/package.json +2 -2
package/dist/MotionTreeNode.cjs
CHANGED
|
@@ -70,7 +70,7 @@ var MotionTreeNode = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
|
70
70
|
if (targetVisible.value === newVisible) triggerMotionEnd();
|
|
71
71
|
};
|
|
72
72
|
return () => {
|
|
73
|
-
const { motionNodes, treeNodeRequiredProps, active, motion, motionType } = props;
|
|
73
|
+
const { motionNodes, treeNodeRequiredProps, active, motion, motionType, treeId } = props;
|
|
74
74
|
if (motionNodes) {
|
|
75
75
|
const _motionNodes = motionNodes ?? [];
|
|
76
76
|
const requiredProps = treeNodeRequiredProps;
|
|
@@ -95,7 +95,8 @@ var MotionTreeNode = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
|
95
95
|
"data": nodeData,
|
|
96
96
|
"key": key,
|
|
97
97
|
"isStart": isStart,
|
|
98
|
-
"isEnd": isEnd
|
|
98
|
+
"isEnd": isEnd,
|
|
99
|
+
"treeId": treeId
|
|
99
100
|
}), null);
|
|
100
101
|
})])] });
|
|
101
102
|
}
|
|
@@ -145,6 +146,11 @@ var MotionTreeNode = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
|
145
146
|
required: true,
|
|
146
147
|
default: void 0
|
|
147
148
|
},
|
|
149
|
+
treeId: {
|
|
150
|
+
type: String,
|
|
151
|
+
required: false,
|
|
152
|
+
default: void 0
|
|
153
|
+
},
|
|
148
154
|
eventKey: {
|
|
149
155
|
type: [String, Number],
|
|
150
156
|
required: false,
|
package/dist/MotionTreeNode.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface MotionTreeNodeProps extends Omit<TreeNodeProps, 'domRef'> {
|
|
|
9
9
|
onMotionStart?: () => void;
|
|
10
10
|
onMotionEnd?: () => void;
|
|
11
11
|
treeNodeRequiredProps: TreeNodeRequiredProps;
|
|
12
|
+
treeId?: string;
|
|
12
13
|
}
|
|
13
14
|
declare const MotionTreeNode: import('vue').DefineSetupFnComponent<MotionTreeNodeProps, {}, {}, MotionTreeNodeProps & {}, import('vue').PublicProps>;
|
|
14
15
|
export default MotionTreeNode;
|
package/dist/MotionTreeNode.js
CHANGED
|
@@ -64,7 +64,7 @@ var MotionTreeNode_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
64
64
|
if (targetVisible.value === newVisible) triggerMotionEnd();
|
|
65
65
|
};
|
|
66
66
|
return () => {
|
|
67
|
-
const { motionNodes, treeNodeRequiredProps, active, motion, motionType } = props;
|
|
67
|
+
const { motionNodes, treeNodeRequiredProps, active, motion, motionType, treeId } = props;
|
|
68
68
|
if (motionNodes) {
|
|
69
69
|
const _motionNodes = motionNodes ?? [];
|
|
70
70
|
const requiredProps = treeNodeRequiredProps;
|
|
@@ -89,7 +89,8 @@ var MotionTreeNode_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
89
89
|
"data": nodeData,
|
|
90
90
|
"key": key,
|
|
91
91
|
"isStart": isStart,
|
|
92
|
-
"isEnd": isEnd
|
|
92
|
+
"isEnd": isEnd,
|
|
93
|
+
"treeId": treeId
|
|
93
94
|
}), null);
|
|
94
95
|
})])] });
|
|
95
96
|
}
|
|
@@ -139,6 +140,11 @@ var MotionTreeNode_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
139
140
|
required: true,
|
|
140
141
|
default: void 0
|
|
141
142
|
},
|
|
143
|
+
treeId: {
|
|
144
|
+
type: String,
|
|
145
|
+
required: false,
|
|
146
|
+
default: void 0
|
|
147
|
+
},
|
|
142
148
|
eventKey: {
|
|
143
149
|
type: [String, Number],
|
|
144
150
|
required: false,
|
package/dist/NodeList.cjs
CHANGED
|
@@ -8,32 +8,14 @@ const require_MotionTreeNode = require("./MotionTreeNode.cjs");
|
|
|
8
8
|
const require_diffUtil = require("./utils/diffUtil.cjs");
|
|
9
9
|
let vue = require("vue");
|
|
10
10
|
let _v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
|
|
11
|
+
let _v_c_util_dist_hooks_useId = require("@v-c/util/dist/hooks/useId");
|
|
12
|
+
_v_c_util_dist_hooks_useId = require_rolldown_runtime.__toESM(_v_c_util_dist_hooks_useId);
|
|
11
13
|
let _v_c_virtual_list = require("@v-c/virtual-list");
|
|
12
14
|
_v_c_virtual_list = require_rolldown_runtime.__toESM(_v_c_virtual_list);
|
|
13
|
-
var HIDDEN_STYLE = {
|
|
14
|
-
width: 0,
|
|
15
|
-
height: 0,
|
|
16
|
-
display: "flex",
|
|
17
|
-
overflow: "hidden",
|
|
18
|
-
opacity: 0,
|
|
19
|
-
border: 0,
|
|
20
|
-
padding: 0,
|
|
21
|
-
margin: 0
|
|
22
|
-
};
|
|
23
|
-
function noop() {}
|
|
24
15
|
function itemKey(item) {
|
|
25
16
|
const { key, pos } = item;
|
|
26
17
|
return String(require_treeUtil.getKey(key, pos));
|
|
27
18
|
}
|
|
28
|
-
function getAccessibilityPath(item) {
|
|
29
|
-
let path = String(item.data.key);
|
|
30
|
-
let current = item;
|
|
31
|
-
while (current.parent) {
|
|
32
|
-
current = current.parent;
|
|
33
|
-
path = `${current.data.key} > ${path}`;
|
|
34
|
-
}
|
|
35
|
-
return path;
|
|
36
|
-
}
|
|
37
19
|
const MOTION_KEY = `VC_TREE_MOTION_${Math.random()}`;
|
|
38
20
|
var MotionNode = { key: MOTION_KEY };
|
|
39
21
|
const MotionEntity = {
|
|
@@ -59,6 +41,7 @@ function getMinimumRangeTransitionRange(list, virtual, height, itemHeight) {
|
|
|
59
41
|
return list.slice(0, Math.ceil(height / itemHeight) + 1);
|
|
60
42
|
}
|
|
61
43
|
var NodeList = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, expose }) => {
|
|
44
|
+
const treeId = (0, _v_c_util_dist_hooks_useId.default)();
|
|
62
45
|
const listRef = (0, vue.ref)();
|
|
63
46
|
const indentMeasurerRef = (0, vue.ref)();
|
|
64
47
|
const { expandedKeys, data } = (0, _v_c_util_dist_props_util.toPropsRefs)(props, "expandedKeys", "data");
|
|
@@ -130,81 +113,69 @@ var NodeList = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, expose
|
|
|
130
113
|
});
|
|
131
114
|
const mergedData = (0, vue.computed)(() => props.motion ? transitionData.value : props.data || []);
|
|
132
115
|
return () => {
|
|
133
|
-
const { motion,
|
|
134
|
-
return (0, vue.createVNode)(vue.Fragment, null, [
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
"
|
|
141
|
-
|
|
142
|
-
"
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
"
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
"isStart": isStart,
|
|
197
|
-
"isEnd": isEnd,
|
|
198
|
-
"motion": motion,
|
|
199
|
-
"motionNodes": key === MOTION_KEY ? transitionRange.value : null,
|
|
200
|
-
"motionType": motionType.value,
|
|
201
|
-
"onMotionStart": onListChangeStart,
|
|
202
|
-
"onMotionEnd": onMotionEnd,
|
|
203
|
-
"treeNodeRequiredProps": treeNodeRequiredProps.value,
|
|
204
|
-
"onMouseMove": () => onActiveChange?.(null)
|
|
205
|
-
}), null);
|
|
206
|
-
} })
|
|
207
|
-
]);
|
|
116
|
+
const { motion, activeItem, focusable, disabled, tabIndex, prefixCls, virtual, itemHeight, height, scrollWidth, onScroll, onContextmenu, onKeyDown, onFocus, onBlur, onListChangeStart, onActiveChange } = props;
|
|
117
|
+
return (0, vue.createVNode)(vue.Fragment, null, [(0, vue.createVNode)("div", {
|
|
118
|
+
"class": `${prefixCls}-treenode`,
|
|
119
|
+
"aria-hidden": true,
|
|
120
|
+
"style": {
|
|
121
|
+
position: "absolute",
|
|
122
|
+
pointerEvents: "none",
|
|
123
|
+
visibility: "hidden",
|
|
124
|
+
height: 0,
|
|
125
|
+
overflow: "hidden",
|
|
126
|
+
border: 0,
|
|
127
|
+
padding: 0
|
|
128
|
+
}
|
|
129
|
+
}, [(0, vue.createVNode)("div", { "class": `${prefixCls}-indent` }, [(0, vue.createVNode)("div", {
|
|
130
|
+
"ref": indentMeasurerRef,
|
|
131
|
+
"class": `${prefixCls}-indent-unit`
|
|
132
|
+
}, null)])]), (0, vue.createVNode)(VirtualListAny, (0, vue.mergeProps)(attrs, {
|
|
133
|
+
"data": mergedData.value,
|
|
134
|
+
"itemKey": itemKey,
|
|
135
|
+
"height": height,
|
|
136
|
+
"fullHeight": false,
|
|
137
|
+
"virtual": virtual,
|
|
138
|
+
"itemHeight": itemHeight,
|
|
139
|
+
"scrollWidth": scrollWidth,
|
|
140
|
+
"prefixCls": `${prefixCls}-list`,
|
|
141
|
+
"ref": listRef,
|
|
142
|
+
"role": "tree",
|
|
143
|
+
"tabindex": focusable !== false && !disabled ? tabIndex : void 0,
|
|
144
|
+
"aria-activedescendant": activeItem ? require_treeUtil.getTreeNodeId(treeId, activeItem.key) : void 0,
|
|
145
|
+
"style": props.style,
|
|
146
|
+
"onContextmenu": onContextmenu,
|
|
147
|
+
"onScroll": onScroll,
|
|
148
|
+
"onKeydown": onKeyDown,
|
|
149
|
+
"onFocus": onFocus,
|
|
150
|
+
"onBlur": onBlur,
|
|
151
|
+
"onVisibleChange": (originList) => {
|
|
152
|
+
if (motionType.value && originList.every((item) => itemKey(item) !== MOTION_KEY)) onMotionEnd();
|
|
153
|
+
}
|
|
154
|
+
}), { default: ({ item: treeNode }) => {
|
|
155
|
+
const { pos, data: nodeData, title, key, isStart, isEnd } = treeNode;
|
|
156
|
+
const mergedKey = require_treeUtil.getKey(key, pos);
|
|
157
|
+
const treeNodeProps = require_treeUtil.getTreeNodeProps(mergedKey, treeNodeRequiredProps.value);
|
|
158
|
+
const active = !!props.activeItem && mergedKey === props.activeItem.key;
|
|
159
|
+
const restProps = { ...nodeData || {} };
|
|
160
|
+
delete restProps.key;
|
|
161
|
+
delete restProps.children;
|
|
162
|
+
return (0, vue.createVNode)(require_MotionTreeNode.default, (0, vue.mergeProps)(restProps, treeNodeProps, {
|
|
163
|
+
"title": title,
|
|
164
|
+
"active": active,
|
|
165
|
+
"pos": pos,
|
|
166
|
+
"data": nodeData,
|
|
167
|
+
"isStart": isStart,
|
|
168
|
+
"isEnd": isEnd,
|
|
169
|
+
"motion": motion,
|
|
170
|
+
"motionNodes": key === MOTION_KEY ? transitionRange.value : null,
|
|
171
|
+
"motionType": motionType.value,
|
|
172
|
+
"onMotionStart": onListChangeStart,
|
|
173
|
+
"onMotionEnd": onMotionEnd,
|
|
174
|
+
"treeNodeRequiredProps": treeNodeRequiredProps.value,
|
|
175
|
+
"treeId": treeId,
|
|
176
|
+
"onMouseMove": () => onActiveChange?.(null)
|
|
177
|
+
}), null);
|
|
178
|
+
} })]);
|
|
208
179
|
};
|
|
209
180
|
}, {
|
|
210
181
|
props: {
|
|
@@ -227,11 +198,6 @@ var NodeList = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, expose
|
|
|
227
198
|
required: false,
|
|
228
199
|
default: void 0
|
|
229
200
|
},
|
|
230
|
-
focused: {
|
|
231
|
-
type: Boolean,
|
|
232
|
-
required: false,
|
|
233
|
-
default: void 0
|
|
234
|
-
},
|
|
235
201
|
tabIndex: {
|
|
236
202
|
type: Number,
|
|
237
203
|
required: false,
|
package/dist/NodeList.d.ts
CHANGED
package/dist/NodeList.js
CHANGED
|
@@ -1,33 +1,14 @@
|
|
|
1
|
-
import { getKey, getTreeNodeProps } from "./utils/treeUtil.js";
|
|
1
|
+
import { getKey, getTreeNodeId, getTreeNodeProps } from "./utils/treeUtil.js";
|
|
2
2
|
import MotionTreeNode_default from "./MotionTreeNode.js";
|
|
3
3
|
import { findExpandedKeys, getExpandRange } from "./utils/diffUtil.js";
|
|
4
4
|
import { Fragment, computed, createVNode, defineComponent, mergeProps, ref, shallowRef, watch } from "vue";
|
|
5
5
|
import { toPropsRefs } from "@v-c/util/dist/props-util";
|
|
6
|
+
import useId from "@v-c/util/dist/hooks/useId";
|
|
6
7
|
import VirtualList from "@v-c/virtual-list";
|
|
7
|
-
var HIDDEN_STYLE = {
|
|
8
|
-
width: 0,
|
|
9
|
-
height: 0,
|
|
10
|
-
display: "flex",
|
|
11
|
-
overflow: "hidden",
|
|
12
|
-
opacity: 0,
|
|
13
|
-
border: 0,
|
|
14
|
-
padding: 0,
|
|
15
|
-
margin: 0
|
|
16
|
-
};
|
|
17
|
-
function noop() {}
|
|
18
8
|
function itemKey(item) {
|
|
19
9
|
const { key, pos } = item;
|
|
20
10
|
return String(getKey(key, pos));
|
|
21
11
|
}
|
|
22
|
-
function getAccessibilityPath(item) {
|
|
23
|
-
let path = String(item.data.key);
|
|
24
|
-
let current = item;
|
|
25
|
-
while (current.parent) {
|
|
26
|
-
current = current.parent;
|
|
27
|
-
path = `${current.data.key} > ${path}`;
|
|
28
|
-
}
|
|
29
|
-
return path;
|
|
30
|
-
}
|
|
31
12
|
const MOTION_KEY = `VC_TREE_MOTION_${Math.random()}`;
|
|
32
13
|
var MotionNode = { key: MOTION_KEY };
|
|
33
14
|
const MotionEntity = {
|
|
@@ -53,6 +34,7 @@ function getMinimumRangeTransitionRange(list, virtual, height, itemHeight) {
|
|
|
53
34
|
return list.slice(0, Math.ceil(height / itemHeight) + 1);
|
|
54
35
|
}
|
|
55
36
|
var NodeList_default = /* @__PURE__ */ defineComponent((props, { attrs, expose }) => {
|
|
37
|
+
const treeId = useId();
|
|
56
38
|
const listRef = ref();
|
|
57
39
|
const indentMeasurerRef = ref();
|
|
58
40
|
const { expandedKeys, data } = toPropsRefs(props, "expandedKeys", "data");
|
|
@@ -124,81 +106,69 @@ var NodeList_default = /* @__PURE__ */ defineComponent((props, { attrs, expose }
|
|
|
124
106
|
});
|
|
125
107
|
const mergedData = computed(() => props.motion ? transitionData.value : props.data || []);
|
|
126
108
|
return () => {
|
|
127
|
-
const { motion,
|
|
128
|
-
return createVNode(Fragment, null, [
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"
|
|
135
|
-
|
|
136
|
-
"
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
"
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
"isStart": isStart,
|
|
191
|
-
"isEnd": isEnd,
|
|
192
|
-
"motion": motion,
|
|
193
|
-
"motionNodes": key === MOTION_KEY ? transitionRange.value : null,
|
|
194
|
-
"motionType": motionType.value,
|
|
195
|
-
"onMotionStart": onListChangeStart,
|
|
196
|
-
"onMotionEnd": onMotionEnd,
|
|
197
|
-
"treeNodeRequiredProps": treeNodeRequiredProps.value,
|
|
198
|
-
"onMouseMove": () => onActiveChange?.(null)
|
|
199
|
-
}), null);
|
|
200
|
-
} })
|
|
201
|
-
]);
|
|
109
|
+
const { motion, activeItem, focusable, disabled, tabIndex, prefixCls, virtual, itemHeight, height, scrollWidth, onScroll, onContextmenu, onKeyDown, onFocus, onBlur, onListChangeStart, onActiveChange } = props;
|
|
110
|
+
return createVNode(Fragment, null, [createVNode("div", {
|
|
111
|
+
"class": `${prefixCls}-treenode`,
|
|
112
|
+
"aria-hidden": true,
|
|
113
|
+
"style": {
|
|
114
|
+
position: "absolute",
|
|
115
|
+
pointerEvents: "none",
|
|
116
|
+
visibility: "hidden",
|
|
117
|
+
height: 0,
|
|
118
|
+
overflow: "hidden",
|
|
119
|
+
border: 0,
|
|
120
|
+
padding: 0
|
|
121
|
+
}
|
|
122
|
+
}, [createVNode("div", { "class": `${prefixCls}-indent` }, [createVNode("div", {
|
|
123
|
+
"ref": indentMeasurerRef,
|
|
124
|
+
"class": `${prefixCls}-indent-unit`
|
|
125
|
+
}, null)])]), createVNode(VirtualListAny, mergeProps(attrs, {
|
|
126
|
+
"data": mergedData.value,
|
|
127
|
+
"itemKey": itemKey,
|
|
128
|
+
"height": height,
|
|
129
|
+
"fullHeight": false,
|
|
130
|
+
"virtual": virtual,
|
|
131
|
+
"itemHeight": itemHeight,
|
|
132
|
+
"scrollWidth": scrollWidth,
|
|
133
|
+
"prefixCls": `${prefixCls}-list`,
|
|
134
|
+
"ref": listRef,
|
|
135
|
+
"role": "tree",
|
|
136
|
+
"tabindex": focusable !== false && !disabled ? tabIndex : void 0,
|
|
137
|
+
"aria-activedescendant": activeItem ? getTreeNodeId(treeId, activeItem.key) : void 0,
|
|
138
|
+
"style": props.style,
|
|
139
|
+
"onContextmenu": onContextmenu,
|
|
140
|
+
"onScroll": onScroll,
|
|
141
|
+
"onKeydown": onKeyDown,
|
|
142
|
+
"onFocus": onFocus,
|
|
143
|
+
"onBlur": onBlur,
|
|
144
|
+
"onVisibleChange": (originList) => {
|
|
145
|
+
if (motionType.value && originList.every((item) => itemKey(item) !== MOTION_KEY)) onMotionEnd();
|
|
146
|
+
}
|
|
147
|
+
}), { default: ({ item: treeNode }) => {
|
|
148
|
+
const { pos, data: nodeData, title, key, isStart, isEnd } = treeNode;
|
|
149
|
+
const mergedKey = getKey(key, pos);
|
|
150
|
+
const treeNodeProps = getTreeNodeProps(mergedKey, treeNodeRequiredProps.value);
|
|
151
|
+
const active = !!props.activeItem && mergedKey === props.activeItem.key;
|
|
152
|
+
const restProps = { ...nodeData || {} };
|
|
153
|
+
delete restProps.key;
|
|
154
|
+
delete restProps.children;
|
|
155
|
+
return createVNode(MotionTreeNode_default, mergeProps(restProps, treeNodeProps, {
|
|
156
|
+
"title": title,
|
|
157
|
+
"active": active,
|
|
158
|
+
"pos": pos,
|
|
159
|
+
"data": nodeData,
|
|
160
|
+
"isStart": isStart,
|
|
161
|
+
"isEnd": isEnd,
|
|
162
|
+
"motion": motion,
|
|
163
|
+
"motionNodes": key === MOTION_KEY ? transitionRange.value : null,
|
|
164
|
+
"motionType": motionType.value,
|
|
165
|
+
"onMotionStart": onListChangeStart,
|
|
166
|
+
"onMotionEnd": onMotionEnd,
|
|
167
|
+
"treeNodeRequiredProps": treeNodeRequiredProps.value,
|
|
168
|
+
"treeId": treeId,
|
|
169
|
+
"onMouseMove": () => onActiveChange?.(null)
|
|
170
|
+
}), null);
|
|
171
|
+
} })]);
|
|
202
172
|
};
|
|
203
173
|
}, {
|
|
204
174
|
props: {
|
|
@@ -221,11 +191,6 @@ var NodeList_default = /* @__PURE__ */ defineComponent((props, { attrs, expose }
|
|
|
221
191
|
required: false,
|
|
222
192
|
default: void 0
|
|
223
193
|
},
|
|
224
|
-
focused: {
|
|
225
|
-
type: Boolean,
|
|
226
|
-
required: false,
|
|
227
|
-
default: void 0
|
|
228
|
-
},
|
|
229
194
|
tabIndex: {
|
|
230
195
|
type: Number,
|
|
231
196
|
required: false,
|
package/dist/Tree.cjs
CHANGED
|
@@ -724,7 +724,6 @@ var Tree = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots, attrs, expo
|
|
|
724
724
|
"itemHeight": props.itemHeight,
|
|
725
725
|
"virtual": mergedVirtual.value,
|
|
726
726
|
"focusable": mergedFocusable.value,
|
|
727
|
-
"focused": focused.value,
|
|
728
727
|
"tabIndex": mergedTabIndex.value,
|
|
729
728
|
"activeItem": getActiveItem.value,
|
|
730
729
|
"onFocus": onFocus,
|
package/dist/Tree.js
CHANGED
|
@@ -715,7 +715,6 @@ var Tree_default = /* @__PURE__ */ defineComponent((props, { slots, attrs, expos
|
|
|
715
715
|
"itemHeight": props.itemHeight,
|
|
716
716
|
"virtual": mergedVirtual.value,
|
|
717
717
|
"focusable": mergedFocusable.value,
|
|
718
|
-
"focused": focused.value,
|
|
719
718
|
"tabIndex": mergedTabIndex.value,
|
|
720
719
|
"activeItem": getActiveItem.value,
|
|
721
720
|
"onFocus": onFocus,
|
package/dist/TreeNode.cjs
CHANGED
|
@@ -18,6 +18,7 @@ var defaultTitle = "---";
|
|
|
18
18
|
var TreeNode = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs }) => {
|
|
19
19
|
const context = (0, vue.inject)(require_contextTypes.TreeContextKey, null);
|
|
20
20
|
const unstableContext = (0, vue.inject)(require_contextTypes.UnstableContextKey, {});
|
|
21
|
+
const nodeId = (0, vue.computed)(() => require_treeUtil.getTreeNodeId(props.treeId || "", props.eventKey));
|
|
21
22
|
const dragNodeHighlight = (0, vue.ref)(false);
|
|
22
23
|
const isDisabled = (0, vue.computed)(() => {
|
|
23
24
|
return !!(context.disabled || props.disabled || unstableContext.nodeDisabled?.(props.data));
|
|
@@ -35,8 +36,7 @@ var TreeNode = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs }) => {
|
|
|
35
36
|
return Boolean((children || []).length);
|
|
36
37
|
});
|
|
37
38
|
const memoizedIsLeaf = (0, vue.computed)(() => {
|
|
38
|
-
|
|
39
|
-
return props.isLeaf || !context.loadData && !hasChildren.value || context.loadData && props.loaded && !hasChildren.value;
|
|
39
|
+
return require_treeUtil.isLeafNode(props.isLeaf, context.loadData, hasChildren.value, props.loaded);
|
|
40
40
|
});
|
|
41
41
|
(0, vue.watchEffect)(() => {
|
|
42
42
|
if (props.loading) return;
|
|
@@ -151,7 +151,7 @@ var TreeNode = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs }) => {
|
|
|
151
151
|
});
|
|
152
152
|
const checkboxNode = (0, vue.computed)(() => {
|
|
153
153
|
if (!isCheckable.value) return null;
|
|
154
|
-
const { checked, halfChecked, disableCheckbox
|
|
154
|
+
const { checked, halfChecked, disableCheckbox } = props;
|
|
155
155
|
const prefixCls = context.prefixCls;
|
|
156
156
|
const custom = typeof isCheckable.value !== "boolean" ? isCheckable.value : null;
|
|
157
157
|
return (0, vue.createVNode)("span", {
|
|
@@ -164,7 +164,7 @@ var TreeNode = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs }) => {
|
|
|
164
164
|
"role": "checkbox",
|
|
165
165
|
"aria-checked": halfChecked ? "mixed" : checked,
|
|
166
166
|
"aria-disabled": isDisabled.value || disableCheckbox,
|
|
167
|
-
"aria-
|
|
167
|
+
"aria-labelledby": nodeId.value
|
|
168
168
|
}, [custom]);
|
|
169
169
|
});
|
|
170
170
|
const selectorNode = (0, vue.computed)(() => {
|
|
@@ -218,9 +218,11 @@ var TreeNode = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs }) => {
|
|
|
218
218
|
const filterNode = context.filterTreeNode?.(require_treeUtil.convertNodePropsToEventData(props));
|
|
219
219
|
return (0, vue.createVNode)("div", (0, vue.mergeProps)({
|
|
220
220
|
"role": "treeitem",
|
|
221
|
+
"id": nodeId.value,
|
|
221
222
|
"aria-expanded": memoizedIsLeaf.value ? void 0 : props.expanded,
|
|
222
|
-
"aria-selected":
|
|
223
|
-
"
|
|
223
|
+
"aria-selected": isSelectable.value && !isDisabled.value ? props.selected : void 0,
|
|
224
|
+
"aria-checked": isCheckable.value && !isDisabled.value ? props.halfChecked ? "mixed" : props.checked : void 0,
|
|
225
|
+
"aria-disabled": isDisabled.value,
|
|
224
226
|
"class": (0, _v_c_util.clsx)(props.className, `${context.prefixCls}-treenode`, context.classNames?.item, {
|
|
225
227
|
[`${context.prefixCls}-treenode-disabled`]: isDisabled.value,
|
|
226
228
|
[`${context.prefixCls}-treenode-switcher-${props.expanded ? "open" : "close"}`]: !memoizedIsLeaf.value,
|
|
@@ -292,6 +294,11 @@ var TreeNode = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs }) => {
|
|
|
292
294
|
required: false,
|
|
293
295
|
default: void 0
|
|
294
296
|
},
|
|
297
|
+
treeId: {
|
|
298
|
+
type: String,
|
|
299
|
+
required: false,
|
|
300
|
+
default: void 0
|
|
301
|
+
},
|
|
295
302
|
expanded: {
|
|
296
303
|
type: Boolean,
|
|
297
304
|
required: false,
|
package/dist/TreeNode.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Indent_default from "./Indent.js";
|
|
2
2
|
import { TreeContextKey, UnstableContextKey } from "./contextTypes.js";
|
|
3
3
|
import getEntity from "./utils/keyUtil.js";
|
|
4
|
-
import { convertNodePropsToEventData } from "./utils/treeUtil.js";
|
|
4
|
+
import { convertNodePropsToEventData, getTreeNodeId, isLeafNode } from "./utils/treeUtil.js";
|
|
5
5
|
import { computed, createVNode, defineComponent, inject, mergeProps, ref, watchEffect } from "vue";
|
|
6
6
|
import { clsx } from "@v-c/util";
|
|
7
7
|
import pickAttrs from "@v-c/util/dist/pickAttrs";
|
|
@@ -12,6 +12,7 @@ var defaultTitle = "---";
|
|
|
12
12
|
var TreeNode = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
13
13
|
const context = inject(TreeContextKey, null);
|
|
14
14
|
const unstableContext = inject(UnstableContextKey, {});
|
|
15
|
+
const nodeId = computed(() => getTreeNodeId(props.treeId || "", props.eventKey));
|
|
15
16
|
const dragNodeHighlight = ref(false);
|
|
16
17
|
const isDisabled = computed(() => {
|
|
17
18
|
return !!(context.disabled || props.disabled || unstableContext.nodeDisabled?.(props.data));
|
|
@@ -29,8 +30,7 @@ var TreeNode = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
29
30
|
return Boolean((children || []).length);
|
|
30
31
|
});
|
|
31
32
|
const memoizedIsLeaf = computed(() => {
|
|
32
|
-
|
|
33
|
-
return props.isLeaf || !context.loadData && !hasChildren.value || context.loadData && props.loaded && !hasChildren.value;
|
|
33
|
+
return isLeafNode(props.isLeaf, context.loadData, hasChildren.value, props.loaded);
|
|
34
34
|
});
|
|
35
35
|
watchEffect(() => {
|
|
36
36
|
if (props.loading) return;
|
|
@@ -145,7 +145,7 @@ var TreeNode = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
145
145
|
});
|
|
146
146
|
const checkboxNode = computed(() => {
|
|
147
147
|
if (!isCheckable.value) return null;
|
|
148
|
-
const { checked, halfChecked, disableCheckbox
|
|
148
|
+
const { checked, halfChecked, disableCheckbox } = props;
|
|
149
149
|
const prefixCls = context.prefixCls;
|
|
150
150
|
const custom = typeof isCheckable.value !== "boolean" ? isCheckable.value : null;
|
|
151
151
|
return createVNode("span", {
|
|
@@ -158,7 +158,7 @@ var TreeNode = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
158
158
|
"role": "checkbox",
|
|
159
159
|
"aria-checked": halfChecked ? "mixed" : checked,
|
|
160
160
|
"aria-disabled": isDisabled.value || disableCheckbox,
|
|
161
|
-
"aria-
|
|
161
|
+
"aria-labelledby": nodeId.value
|
|
162
162
|
}, [custom]);
|
|
163
163
|
});
|
|
164
164
|
const selectorNode = computed(() => {
|
|
@@ -212,9 +212,11 @@ var TreeNode = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
212
212
|
const filterNode = context.filterTreeNode?.(convertNodePropsToEventData(props));
|
|
213
213
|
return createVNode("div", mergeProps({
|
|
214
214
|
"role": "treeitem",
|
|
215
|
+
"id": nodeId.value,
|
|
215
216
|
"aria-expanded": memoizedIsLeaf.value ? void 0 : props.expanded,
|
|
216
|
-
"aria-selected":
|
|
217
|
-
"
|
|
217
|
+
"aria-selected": isSelectable.value && !isDisabled.value ? props.selected : void 0,
|
|
218
|
+
"aria-checked": isCheckable.value && !isDisabled.value ? props.halfChecked ? "mixed" : props.checked : void 0,
|
|
219
|
+
"aria-disabled": isDisabled.value,
|
|
218
220
|
"class": clsx(props.className, `${context.prefixCls}-treenode`, context.classNames?.item, {
|
|
219
221
|
[`${context.prefixCls}-treenode-disabled`]: isDisabled.value,
|
|
220
222
|
[`${context.prefixCls}-treenode-switcher-${props.expanded ? "open" : "close"}`]: !memoizedIsLeaf.value,
|
|
@@ -286,6 +288,11 @@ var TreeNode = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
286
288
|
required: false,
|
|
287
289
|
default: void 0
|
|
288
290
|
},
|
|
291
|
+
treeId: {
|
|
292
|
+
type: String,
|
|
293
|
+
required: false,
|
|
294
|
+
default: void 0
|
|
295
|
+
},
|
|
289
296
|
expanded: {
|
|
290
297
|
type: Boolean,
|
|
291
298
|
required: false,
|
package/dist/index.cjs
CHANGED
|
@@ -13,8 +13,6 @@ ExportTree.TreeNode = require_TreeNode.default;
|
|
|
13
13
|
var src_default = ExportTree;
|
|
14
14
|
exports.TreeNode = require_TreeNode.default;
|
|
15
15
|
exports.UnstableContextKey = require_contextTypes.UnstableContextKey;
|
|
16
|
-
exports.arrAdd = require_util.arrAdd;
|
|
17
|
-
exports.arrDel = require_util.arrDel;
|
|
18
16
|
exports.conductCheck = require_conductUtil.conductCheck;
|
|
19
17
|
exports.conductExpandParent = require_util.conductExpandParent;
|
|
20
18
|
exports.convertDataToEntities = require_treeUtil.convertDataToEntities;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ExpandAction, TreeProps, TreeRef, default as Tree } from './Tree';
|
|
|
3
3
|
import { default as TreeNode } from './TreeNode';
|
|
4
4
|
export { UnstableContextKey } from './contextTypes';
|
|
5
5
|
export { TreeNode };
|
|
6
|
-
export {
|
|
6
|
+
export { conductExpandParent } from './util.ts';
|
|
7
7
|
export { conductCheck } from './utils/conductUtil';
|
|
8
8
|
export { convertDataToEntities, convertTreeToData, fillFieldNames, flattenTreeData } from './utils/treeUtil';
|
|
9
9
|
export type { BasicDataNode, DataEntity, DataNode, EventDataNode, ExpandAction, FieldNames, FlattenNode, IconType, Key, KeyEntities, ScrollTo, TreeNodeProps, TreeProps, TreeRef, };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { UnstableContextKey } from "./contextTypes.js";
|
|
2
2
|
import { convertDataToEntities, convertTreeToData, fillFieldNames, flattenTreeData } from "./utils/treeUtil.js";
|
|
3
3
|
import TreeNode_default from "./TreeNode.js";
|
|
4
|
-
import {
|
|
4
|
+
import { conductExpandParent } from "./util.js";
|
|
5
5
|
import { conductCheck } from "./utils/conductUtil.js";
|
|
6
6
|
import Tree_default from "./Tree.js";
|
|
7
7
|
var ExportTree = Tree_default;
|
|
8
8
|
ExportTree.TreeNode = TreeNode_default;
|
|
9
9
|
var src_default = ExportTree;
|
|
10
|
-
export { TreeNode_default as TreeNode, UnstableContextKey,
|
|
10
|
+
export { TreeNode_default as TreeNode, UnstableContextKey, conductCheck, conductExpandParent, convertDataToEntities, convertTreeToData, src_default as default, fillFieldNames, flattenTreeData };
|
package/dist/interface.d.ts
CHANGED
package/dist/utils/treeUtil.cjs
CHANGED
|
@@ -213,6 +213,13 @@ function convertNodePropsToEventData(props) {
|
|
|
213
213
|
} });
|
|
214
214
|
return eventData;
|
|
215
215
|
}
|
|
216
|
+
function isLeafNode(isLeaf, loadData, hasChildren, loaded) {
|
|
217
|
+
if (isLeaf === false) return false;
|
|
218
|
+
return !!isLeaf || !loadData && !hasChildren || !!(loadData && loaded && !hasChildren);
|
|
219
|
+
}
|
|
220
|
+
function getTreeNodeId(treeId, key) {
|
|
221
|
+
return `${treeId}-${key}`;
|
|
222
|
+
}
|
|
216
223
|
exports.convertDataToEntities = convertDataToEntities;
|
|
217
224
|
exports.convertNodePropsToEventData = convertNodePropsToEventData;
|
|
218
225
|
exports.convertTreeToData = convertTreeToData;
|
|
@@ -220,7 +227,9 @@ exports.fillFieldNames = fillFieldNames;
|
|
|
220
227
|
exports.flattenTreeData = flattenTreeData;
|
|
221
228
|
exports.getKey = getKey;
|
|
222
229
|
exports.getPosition = getPosition;
|
|
230
|
+
exports.getTreeNodeId = getTreeNodeId;
|
|
223
231
|
exports.getTreeNodeProps = getTreeNodeProps;
|
|
232
|
+
exports.isLeafNode = isLeafNode;
|
|
224
233
|
exports.isTreeNode = isTreeNode;
|
|
225
234
|
exports.traverseDataNodes = traverseDataNodes;
|
|
226
235
|
exports.warningWithoutKey = warningWithoutKey;
|
package/dist/utils/treeUtil.d.ts
CHANGED
|
@@ -58,4 +58,6 @@ export declare function getTreeNodeProps<TreeDataType extends BasicDataNode = Da
|
|
|
58
58
|
dragOverGapBottom: boolean;
|
|
59
59
|
};
|
|
60
60
|
export declare function convertNodePropsToEventData<TreeDataType extends BasicDataNode = DataNode>(props: TreeNodeProps<TreeDataType>): EventDataNode<TreeDataType>;
|
|
61
|
+
export declare function isLeafNode<TreeDataType extends BasicDataNode = DataNode>(isLeaf: boolean | undefined, loadData: ((node: EventDataNode<TreeDataType>) => Promise<any>) | undefined, hasChildren: boolean, loaded: boolean | undefined): boolean;
|
|
62
|
+
export declare function getTreeNodeId(treeId: string, key: Key): string;
|
|
61
63
|
export {};
|
package/dist/utils/treeUtil.js
CHANGED
|
@@ -210,4 +210,11 @@ function convertNodePropsToEventData(props) {
|
|
|
210
210
|
} });
|
|
211
211
|
return eventData;
|
|
212
212
|
}
|
|
213
|
-
|
|
213
|
+
function isLeafNode(isLeaf, loadData, hasChildren, loaded) {
|
|
214
|
+
if (isLeaf === false) return false;
|
|
215
|
+
return !!isLeaf || !loadData && !hasChildren || !!(loadData && loaded && !hasChildren);
|
|
216
|
+
}
|
|
217
|
+
function getTreeNodeId(treeId, key) {
|
|
218
|
+
return `${treeId}-${key}`;
|
|
219
|
+
}
|
|
220
|
+
export { convertDataToEntities, convertNodePropsToEventData, convertTreeToData, fillFieldNames, flattenTreeData, getKey, getPosition, getTreeNodeId, getTreeNodeProps, isLeafNode, isTreeNode, traverseDataNodes, warningWithoutKey };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/tree",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"vue": "^3.0.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@v-c/util": "^1.0.
|
|
32
|
+
"@v-c/util": "^1.0.9",
|
|
33
33
|
"@v-c/virtual-list": "^1.0.5"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|