bkui-vue 0.0.1-beta.74 → 0.0.1-beta.75
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/index.cjs.js +29 -29
- package/dist/index.esm.js +250 -143
- package/dist/index.umd.js +26 -26
- package/dist/style.css +1 -1
- package/lib/button/button.css +0 -2
- package/lib/button/button.less +1 -2
- package/lib/button/button.variable.css +0 -2
- package/lib/button/index.js +1 -1
- package/lib/dialog/dialog.less +1 -0
- package/lib/menu/index.d.ts +4 -16
- package/lib/menu/index.js +1 -1
- package/lib/menu/menu.d.ts +3 -12
- package/lib/tree/constant.d.ts +11 -1
- package/lib/tree/index.d.ts +47 -1
- package/lib/tree/index.js +1 -1
- package/lib/tree/props.d.ts +19 -0
- package/lib/tree/tree.d.ts +22 -0
- package/lib/tree/use-node-action.d.ts +1 -1
- package/lib/tree/use-node-attribute.d.ts +4 -1
- package/lib/tree/use-tree-init.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -8888,7 +8888,7 @@ var Component$u = defineComponent({
|
|
8888
8888
|
"mode": props.loadingMode,
|
8889
8889
|
"theme": loadingTheme.value,
|
8890
8890
|
"size": loadingSize.value
|
8891
|
-
}, null), slots.default && createVNode("span", {
|
8891
|
+
}, null), slots.default && !props.loading && createVNode("span", {
|
8892
8892
|
"class": `${btnClsPrefix}-text`
|
8893
8893
|
}, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])]);
|
8894
8894
|
};
|
@@ -16289,10 +16289,7 @@ const collapseMotion = () => ({
|
|
16289
16289
|
});
|
16290
16290
|
const menuProps = {
|
16291
16291
|
activeKey: String,
|
16292
|
-
collapse:
|
16293
|
-
type: Boolean,
|
16294
|
-
default: false
|
16295
|
-
},
|
16292
|
+
collapse: Boolean,
|
16296
16293
|
openedKeys: {
|
16297
16294
|
type: Array
|
16298
16295
|
},
|
@@ -16311,7 +16308,8 @@ var Component$6 = defineComponent({
|
|
16311
16308
|
emits: ["update:activeKey", "update:openKeys", "click", "openChange"],
|
16312
16309
|
setup(props, {
|
16313
16310
|
slots,
|
16314
|
-
emit
|
16311
|
+
emit,
|
16312
|
+
expose
|
16315
16313
|
}) {
|
16316
16314
|
const activeKey = ref("");
|
16317
16315
|
const openedKeys = ref([]);
|
@@ -16319,11 +16317,6 @@ var Component$6 = defineComponent({
|
|
16319
16317
|
const mode = computed(() => props.mode);
|
16320
16318
|
const collapse2 = ref(props.collapse);
|
16321
16319
|
const oldOpenKeys = ref([]);
|
16322
|
-
watch(() => props.openedKeys, (keys = openedKeys.value) => {
|
16323
|
-
openedKeys.value = keys;
|
16324
|
-
}, {
|
16325
|
-
immediate: true
|
16326
|
-
});
|
16327
16320
|
watchEffect(() => {
|
16328
16321
|
if (props.activeKey !== void 0) {
|
16329
16322
|
activeKey.value = props.activeKey;
|
@@ -16331,6 +16324,7 @@ var Component$6 = defineComponent({
|
|
16331
16324
|
});
|
16332
16325
|
watch(() => props.collapse, () => {
|
16333
16326
|
collapse2.value = props.collapse;
|
16327
|
+
console.info(props.collapse);
|
16334
16328
|
const oldKeys = [...oldOpenKeys.value];
|
16335
16329
|
const openKeys = [...openedKeys.value];
|
16336
16330
|
openedKeys.value = collapse2.value ? [] : oldKeys;
|
@@ -16338,6 +16332,11 @@ var Component$6 = defineComponent({
|
|
16338
16332
|
}, {
|
16339
16333
|
immediate: true
|
16340
16334
|
});
|
16335
|
+
watch(() => props.openedKeys, (keys = openedKeys.value) => {
|
16336
|
+
openedKeys.value = keys;
|
16337
|
+
}, {
|
16338
|
+
immediate: true
|
16339
|
+
});
|
16341
16340
|
const registerMenuInfo = (key, info2) => {
|
16342
16341
|
menuStore.value = __spreadProps(__spreadValues({}, menuStore.value), {
|
16343
16342
|
[key]: info2
|
@@ -16375,6 +16374,11 @@ var Component$6 = defineComponent({
|
|
16375
16374
|
handleOpenChange,
|
16376
16375
|
handleActiveChange
|
16377
16376
|
});
|
16377
|
+
expose({
|
16378
|
+
activeKey,
|
16379
|
+
openedKeys,
|
16380
|
+
menuStore
|
16381
|
+
});
|
16378
16382
|
return () => {
|
16379
16383
|
var _a;
|
16380
16384
|
return createVNode("div", {
|
@@ -16382,7 +16386,7 @@ var Component$6 = defineComponent({
|
|
16382
16386
|
"bk-menu": true,
|
16383
16387
|
"is-collapse": collapse2.value
|
16384
16388
|
}
|
16385
|
-
}, [(_a = slots
|
16389
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
16386
16390
|
};
|
16387
16391
|
}
|
16388
16392
|
});
|
@@ -21085,8 +21089,18 @@ var NODE_ATTRIBUTES = /* @__PURE__ */ ((NODE_ATTRIBUTES2) => {
|
|
21085
21089
|
NODE_ATTRIBUTES2["IS_NULL"] = "__IS_NULL";
|
21086
21090
|
NODE_ATTRIBUTES2["IS_CACHED"] = "__is_cached";
|
21087
21091
|
NODE_ATTRIBUTES2["IS_ASYNC"] = "__is_async";
|
21092
|
+
NODE_ATTRIBUTES2["IS_LOADING"] = "__is_loading";
|
21088
21093
|
return NODE_ATTRIBUTES2;
|
21089
21094
|
})(NODE_ATTRIBUTES || {});
|
21095
|
+
const NODE_SOURCE_ATTRS = {
|
21096
|
+
["__is_open"]: "isOpen",
|
21097
|
+
["__is_selected"]: "selected",
|
21098
|
+
["__is_match"]: "isMatch",
|
21099
|
+
["__has_child"]: "hasChild",
|
21100
|
+
["__is_checked"]: "checked",
|
21101
|
+
["__is_async"]: "async",
|
21102
|
+
["__is_loading"]: "loading"
|
21103
|
+
};
|
21090
21104
|
const treeProps = {
|
21091
21105
|
data: PropTypes.arrayOf(PropTypes.any).def([]),
|
21092
21106
|
label: PropTypes.oneOfType([PropTypes.func.def(void 0), PropTypes.string.def("label")]),
|
@@ -21133,7 +21147,9 @@ const treeProps = {
|
|
21133
21147
|
draggable: PropTypes.bool.def(false),
|
21134
21148
|
dragSort: PropTypes.bool.def(false),
|
21135
21149
|
selectable: PropTypes.bool.def(true),
|
21136
|
-
selected: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).def(null)
|
21150
|
+
selected: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).def(null),
|
21151
|
+
autoCheckChildren: PropTypes.bool.def(true),
|
21152
|
+
syncAction: PropTypes.bool.def(false)
|
21137
21153
|
};
|
21138
21154
|
var useEmpty = (props, {
|
21139
21155
|
slots
|
@@ -21148,79 +21164,6 @@ var useEmpty = (props, {
|
|
21148
21164
|
}
|
21149
21165
|
})
|
21150
21166
|
});
|
21151
|
-
var useNodeAttribute = (flatData, props) => {
|
21152
|
-
const getSchemaVal2 = (key) => flatData.schema.get(key);
|
21153
|
-
const getNodeAttr2 = (node, attr) => {
|
21154
|
-
var _a;
|
21155
|
-
return (_a = getSchemaVal2(node[NODE_ATTRIBUTES.UUID])) == null ? void 0 : _a[attr];
|
21156
|
-
};
|
21157
|
-
const setNodeAttr = (node, attr, val) => flatData.schema.set(node[NODE_ATTRIBUTES.UUID], __spreadProps(__spreadValues({}, getSchemaVal2(node[NODE_ATTRIBUTES.UUID])), {
|
21158
|
-
[attr]: val
|
21159
|
-
}));
|
21160
|
-
const getNodePath = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.PATH);
|
21161
|
-
const getNodeId = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.UUID);
|
21162
|
-
const isRootNode = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_ROOT);
|
21163
|
-
const isNodeOpened = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_OPENED);
|
21164
|
-
const hasChildNode = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.HAS_CHILD);
|
21165
|
-
const isNodeMatched = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_MATCH);
|
21166
|
-
const isNodeChecked = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_CHECKED);
|
21167
|
-
const getNodeParentId = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.PARENT_ID);
|
21168
|
-
const getNodeParentIdById = (id) => getNodeAttr2({
|
21169
|
-
[NODE_ATTRIBUTES.UUID]: id
|
21170
|
-
}, NODE_ATTRIBUTES.PARENT_ID);
|
21171
|
-
const deleteNodeSchema = (id) => flatData.schema.delete(id);
|
21172
|
-
const isItemOpen = (item) => {
|
21173
|
-
var _a;
|
21174
|
-
if (typeof item === "object") {
|
21175
|
-
return isNodeOpened(item);
|
21176
|
-
}
|
21177
|
-
if (typeof item === "string") {
|
21178
|
-
return (_a = getSchemaVal2(item)) == null ? void 0 : _a[NODE_ATTRIBUTES.IS_OPENED];
|
21179
|
-
}
|
21180
|
-
return false;
|
21181
|
-
};
|
21182
|
-
const checkNodeIsOpen = (node) => isRootNode(node) || isItemOpen(node) || isItemOpen(getNodeAttr2(node, NODE_ATTRIBUTES.PARENT_ID));
|
21183
|
-
const getSourceNodeByPath = (path) => {
|
21184
|
-
const paths = path.split("-");
|
21185
|
-
return paths.reduce((pre, nodeIndex) => {
|
21186
|
-
const index = Number(nodeIndex);
|
21187
|
-
return Array.isArray(pre) ? pre[index] : pre[props.children][index];
|
21188
|
-
}, props.data);
|
21189
|
-
};
|
21190
|
-
const getSourceNodeByUID = (uid) => getSourceNodeByPath(getNodePath({
|
21191
|
-
[NODE_ATTRIBUTES.UUID]: uid
|
21192
|
-
}));
|
21193
|
-
const getParentNodeData = (uid) => {
|
21194
|
-
if (isRootNode({
|
21195
|
-
[NODE_ATTRIBUTES.UUID]: uid
|
21196
|
-
})) {
|
21197
|
-
return {
|
21198
|
-
[props.children]: props.data
|
21199
|
-
};
|
21200
|
-
}
|
21201
|
-
return getSourceNodeByUID(getNodeParentIdById(uid));
|
21202
|
-
};
|
21203
|
-
return {
|
21204
|
-
getSchemaVal: getSchemaVal2,
|
21205
|
-
getNodeAttr: getNodeAttr2,
|
21206
|
-
getNodeId,
|
21207
|
-
getNodeParentId,
|
21208
|
-
getNodeParentIdById,
|
21209
|
-
getParentNodeData,
|
21210
|
-
setNodeAttr,
|
21211
|
-
getNodePath,
|
21212
|
-
isRootNode,
|
21213
|
-
isNodeOpened,
|
21214
|
-
hasChildNode,
|
21215
|
-
isItemOpen,
|
21216
|
-
isNodeChecked,
|
21217
|
-
isNodeMatched,
|
21218
|
-
checkNodeIsOpen,
|
21219
|
-
getSourceNodeByPath,
|
21220
|
-
getSourceNodeByUID,
|
21221
|
-
deleteNodeSchema
|
21222
|
-
};
|
21223
|
-
};
|
21224
21167
|
const DEFAULT_LEVLE_LINE = "1px dashed #c3cdd7";
|
21225
21168
|
const getPropsOneOfBoolValueWithDefault = (props, key, item = null, defaultTrueValue = null, defaultFalseValue = null, args = []) => {
|
21226
21169
|
const prop = props[key];
|
@@ -21318,12 +21261,114 @@ const resolveNodeItem = (node) => {
|
|
21318
21261
|
console.error("setNodeAction Error: node id cannot found");
|
21319
21262
|
return node;
|
21320
21263
|
};
|
21264
|
+
var useNodeAttribute = (flatData, props) => {
|
21265
|
+
const getSchemaVal2 = (key) => flatData.schema.get(key);
|
21266
|
+
const getNodeAttr2 = (node, attr) => {
|
21267
|
+
var _a;
|
21268
|
+
return (_a = getSchemaVal2(node[NODE_ATTRIBUTES.UUID])) == null ? void 0 : _a[attr];
|
21269
|
+
};
|
21270
|
+
const setNodeAttr = (node, attr, val) => {
|
21271
|
+
if (props.syncAction && NODE_SOURCE_ATTRS[attr] !== void 0) {
|
21272
|
+
updateTreeNode(getNodePath(node), props.data, props.children, NODE_SOURCE_ATTRS[attr], val);
|
21273
|
+
}
|
21274
|
+
flatData.schema.set(node[NODE_ATTRIBUTES.UUID], __spreadProps(__spreadValues({}, getSchemaVal2(node[NODE_ATTRIBUTES.UUID])), {
|
21275
|
+
[attr]: val
|
21276
|
+
}));
|
21277
|
+
};
|
21278
|
+
const getNodePath = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.PATH);
|
21279
|
+
const getNodeId = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.UUID);
|
21280
|
+
const isRootNode = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_ROOT);
|
21281
|
+
const isNodeOpened = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_OPENED);
|
21282
|
+
const hasChildNode = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.HAS_CHILD);
|
21283
|
+
const isNodeMatched = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_MATCH);
|
21284
|
+
const isNodeChecked = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_CHECKED);
|
21285
|
+
const getNodeParentId = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.PARENT_ID);
|
21286
|
+
const getNodeParentIdById = (id) => getNodeAttr2({
|
21287
|
+
[NODE_ATTRIBUTES.UUID]: id
|
21288
|
+
}, NODE_ATTRIBUTES.PARENT_ID);
|
21289
|
+
const isNodeLoading = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_LOADING);
|
21290
|
+
const setTreeNodeLoading = (node, value) => {
|
21291
|
+
setNodeAttr(node, NODE_ATTRIBUTES.IS_LOADING, value);
|
21292
|
+
if (!props.syncAction) {
|
21293
|
+
updateTreeNode(getNodePath(node), props.data, props.children, NODE_ATTRIBUTES.IS_LOADING, value);
|
21294
|
+
}
|
21295
|
+
};
|
21296
|
+
const deleteNodeSchema = (id) => flatData.schema.delete(id);
|
21297
|
+
const isItemOpen = (item) => {
|
21298
|
+
var _a;
|
21299
|
+
if (typeof item === "object") {
|
21300
|
+
return isNodeOpened(item);
|
21301
|
+
}
|
21302
|
+
if (typeof item === "string") {
|
21303
|
+
return (_a = getSchemaVal2(item)) == null ? void 0 : _a[NODE_ATTRIBUTES.IS_OPENED];
|
21304
|
+
}
|
21305
|
+
return false;
|
21306
|
+
};
|
21307
|
+
const checkNodeIsOpen = (node) => isRootNode(node) || isItemOpen(node) || isItemOpen(getNodeAttr2(node, NODE_ATTRIBUTES.PARENT_ID));
|
21308
|
+
const getSourceNodeByPath = (path) => {
|
21309
|
+
const paths = path.split("-");
|
21310
|
+
return paths.reduce((pre, nodeIndex) => {
|
21311
|
+
const index = Number(nodeIndex);
|
21312
|
+
return Array.isArray(pre) ? pre[index] : pre[props.children][index];
|
21313
|
+
}, props.data);
|
21314
|
+
};
|
21315
|
+
const getSourceNodeByUID = (uid) => getSourceNodeByPath(getNodePath({
|
21316
|
+
[NODE_ATTRIBUTES.UUID]: uid
|
21317
|
+
}));
|
21318
|
+
const getParentNodeData = (uid) => {
|
21319
|
+
if (isRootNode({
|
21320
|
+
[NODE_ATTRIBUTES.UUID]: uid
|
21321
|
+
})) {
|
21322
|
+
return {
|
21323
|
+
[props.children]: props.data
|
21324
|
+
};
|
21325
|
+
}
|
21326
|
+
return getSourceNodeByUID(getNodeParentIdById(uid));
|
21327
|
+
};
|
21328
|
+
const resolveScopedSlotParam = (item) => __spreadProps(__spreadValues({}, item), {
|
21329
|
+
loading: getNodeAttr2(item, NODE_ATTRIBUTES.IS_LOADING),
|
21330
|
+
hasChildNode: hasChildNode(item),
|
21331
|
+
isMatched: isNodeMatched(item),
|
21332
|
+
isChecked: isNodeChecked(item),
|
21333
|
+
isOpened: isNodeOpened(item),
|
21334
|
+
isRoot: isRootNode(item),
|
21335
|
+
fullPath: getNodeAttr2(item, NODE_ATTRIBUTES.PATH),
|
21336
|
+
uuid: getNodeId(item),
|
21337
|
+
parentId: getNodeAttr2(item, NODE_ATTRIBUTES.PARENT_ID)
|
21338
|
+
});
|
21339
|
+
return {
|
21340
|
+
getSchemaVal: getSchemaVal2,
|
21341
|
+
getNodeAttr: getNodeAttr2,
|
21342
|
+
getNodeId,
|
21343
|
+
getNodeParentId,
|
21344
|
+
getNodeParentIdById,
|
21345
|
+
getParentNodeData,
|
21346
|
+
setNodeAttr,
|
21347
|
+
getNodePath,
|
21348
|
+
isRootNode,
|
21349
|
+
isNodeOpened,
|
21350
|
+
hasChildNode,
|
21351
|
+
isItemOpen,
|
21352
|
+
isNodeChecked,
|
21353
|
+
isNodeMatched,
|
21354
|
+
isNodeLoading,
|
21355
|
+
checkNodeIsOpen,
|
21356
|
+
getSourceNodeByPath,
|
21357
|
+
getSourceNodeByUID,
|
21358
|
+
deleteNodeSchema,
|
21359
|
+
resolveScopedSlotParam,
|
21360
|
+
setTreeNodeLoading
|
21361
|
+
};
|
21362
|
+
};
|
21321
21363
|
var useNodeAsync = (props, flatData) => {
|
21322
21364
|
const {
|
21323
21365
|
setNodeAttr,
|
21324
21366
|
getNodePath,
|
21325
|
-
getNodeAttr: getNodeAttr2
|
21326
|
-
|
21367
|
+
getNodeAttr: getNodeAttr2,
|
21368
|
+
isNodeOpened,
|
21369
|
+
resolveScopedSlotParam,
|
21370
|
+
setTreeNodeLoading
|
21371
|
+
} = useNodeAttribute(flatData, props);
|
21327
21372
|
const setNodeRemoteLoad = (resp, item) => {
|
21328
21373
|
if (typeof resp === "object" && resp !== null) {
|
21329
21374
|
setNodeAttr(item, NODE_ATTRIBUTES.IS_OPENED, true);
|
@@ -21334,34 +21379,39 @@ var useNodeAsync = (props, flatData) => {
|
|
21334
21379
|
return Promise.reject(resp);
|
21335
21380
|
};
|
21336
21381
|
const asyncNodeClick = (item) => {
|
21337
|
-
|
21338
|
-
|
21339
|
-
|
21340
|
-
|
21341
|
-
|
21382
|
+
const {
|
21383
|
+
callback = null,
|
21384
|
+
cache = true
|
21385
|
+
} = props.async || {};
|
21386
|
+
if (typeof callback === "function" && getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC) !== false) {
|
21387
|
+
const isAsyncInit = getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC_INIT);
|
21342
21388
|
setNodeAttr(item, NODE_ATTRIBUTES.IS_ASYNC_INIT, true);
|
21343
|
-
if (
|
21344
|
-
|
21345
|
-
|
21346
|
-
|
21347
|
-
|
21348
|
-
|
21349
|
-
|
21350
|
-
|
21351
|
-
|
21352
|
-
|
21353
|
-
|
21354
|
-
|
21355
|
-
|
21389
|
+
if (!getNodeAttr2(item, NODE_ATTRIBUTES.IS_CACHED)) {
|
21390
|
+
setNodeAttr(item, NODE_ATTRIBUTES.IS_CACHED, cache);
|
21391
|
+
if (isNodeOpened(item) && isAsyncInit) {
|
21392
|
+
return Promise.resolve(true);
|
21393
|
+
}
|
21394
|
+
const dataAttr = resolveScopedSlotParam(item);
|
21395
|
+
const callbackResult = callback(item, (resp) => setNodeRemoteLoad(resp, item), dataAttr);
|
21396
|
+
if (typeof callbackResult === "object" && callbackResult !== null) {
|
21397
|
+
setTreeNodeLoading(item, true);
|
21398
|
+
if (callbackResult instanceof Promise) {
|
21399
|
+
return Promise.resolve(callbackResult.then((resp) => setNodeRemoteLoad(resp, item)).catch((err) => console.error("load remote data error:", err)).finally(() => {
|
21400
|
+
setTreeNodeLoading(item, false);
|
21401
|
+
setNodeAttr(item, NODE_ATTRIBUTES.IS_CACHED, true);
|
21402
|
+
}));
|
21403
|
+
}
|
21404
|
+
setNodeRemoteLoad(callbackResult, item);
|
21405
|
+
setTreeNodeLoading(item, false);
|
21406
|
+
return Promise.resolve(true);
|
21356
21407
|
}
|
21357
|
-
return Promise.resolve(true);
|
21358
21408
|
}
|
21359
|
-
return Promise.
|
21409
|
+
return Promise.resolve(true);
|
21360
21410
|
}
|
21361
21411
|
return Promise.resolve(true);
|
21362
21412
|
};
|
21363
21413
|
const deepAutoOpen = () => {
|
21364
|
-
const autoOpenNodes = flatData.data.filter((item) => item.
|
21414
|
+
const autoOpenNodes = flatData.data.filter((item) => getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC) && item.isOpen && !getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC_INIT));
|
21365
21415
|
if (autoOpenNodes.length) {
|
21366
21416
|
Promise.all(autoOpenNodes.map((item) => asyncNodeClick(item))).then(() => {
|
21367
21417
|
deepAutoOpen();
|
@@ -21375,7 +21425,7 @@ var useNodeAsync = (props, flatData) => {
|
|
21375
21425
|
deepAutoOpen
|
21376
21426
|
};
|
21377
21427
|
};
|
21378
|
-
var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
|
21428
|
+
var useNodeAction = (props, ctx, flatData, renderData, schemaValues, initOption) => {
|
21379
21429
|
let selectedNodeId = null;
|
21380
21430
|
const {
|
21381
21431
|
setNodeAttr,
|
@@ -21387,9 +21437,12 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
|
|
21387
21437
|
hasChildNode,
|
21388
21438
|
isItemOpen,
|
21389
21439
|
isNodeOpened,
|
21390
|
-
|
21391
|
-
|
21392
|
-
} = useNodeAttribute(flatData);
|
21440
|
+
isNodeLoading,
|
21441
|
+
resolveScopedSlotParam
|
21442
|
+
} = useNodeAttribute(flatData, props);
|
21443
|
+
const {
|
21444
|
+
registerNextLoop
|
21445
|
+
} = initOption;
|
21393
21446
|
const {
|
21394
21447
|
asyncNodeClick,
|
21395
21448
|
deepAutoOpen
|
@@ -21420,11 +21473,18 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
|
|
21420
21473
|
}
|
21421
21474
|
return null;
|
21422
21475
|
};
|
21476
|
+
const getLoadingIcon = (item) => {
|
21477
|
+
var _a, _b, _c;
|
21478
|
+
return ((_c = (_b = (_a = ctx.slots).nodeLoading) == null ? void 0 : _b.call(_a, resolveScopedSlotParam(item))) != null ? _c : isNodeLoading(item)) ? createVNode(spinner, null, null) : "";
|
21479
|
+
};
|
21423
21480
|
const getActionIcon = (item) => {
|
21424
21481
|
if (ctx.slots.nodeAction) {
|
21425
21482
|
return ctx.slots.nodeAction(resolveScopedSlotParam(item));
|
21426
21483
|
}
|
21427
21484
|
let prefixFnVal = null;
|
21485
|
+
if (isNodeLoading(item)) {
|
21486
|
+
return getLoadingIcon(item);
|
21487
|
+
}
|
21428
21488
|
if (typeof props.prefixIcon === "function") {
|
21429
21489
|
prefixFnVal = props.prefixIcon(resolveScopedSlotParam(item), "node_action");
|
21430
21490
|
if (prefixFnVal !== "default") {
|
@@ -21432,7 +21492,7 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
|
|
21432
21492
|
}
|
21433
21493
|
}
|
21434
21494
|
if (prefixFnVal === "default" || typeof props.prefixIcon === "boolean" && props.prefixIcon) {
|
21435
|
-
if (hasChildNode(item) || item.async) {
|
21495
|
+
if (hasChildNode(item) || item.async || !props.autoCheckChildren) {
|
21436
21496
|
return isItemOpen(item) ? createVNode(downShape, null, null) : createVNode(rightShape, null, null);
|
21437
21497
|
}
|
21438
21498
|
}
|
@@ -21456,10 +21516,6 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
|
|
21456
21516
|
}
|
21457
21517
|
return null;
|
21458
21518
|
};
|
21459
|
-
const getLoadingIcon = (item) => {
|
21460
|
-
var _a, _b, _c;
|
21461
|
-
return ((_c = (_b = (_a = ctx.slots).nodeLoading) == null ? void 0 : _b.call(_a, resolveScopedSlotParam(item))) != null ? _c : item.loading) ? createVNode(spinner, null, null) : "";
|
21462
|
-
};
|
21463
21519
|
const setNodeOpened = (item, isOpen = null, e = null, fireEmit = true) => {
|
21464
21520
|
const newVal = isOpen === null ? !isItemOpen(item) : !!isOpen;
|
21465
21521
|
setNodeAttr(item, NODE_ATTRIBUTES.IS_OPENED, newVal);
|
@@ -21499,8 +21555,17 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
|
|
21499
21555
|
}
|
21500
21556
|
};
|
21501
21557
|
const hanldeTreeNodeClick = (item, e) => {
|
21502
|
-
|
21503
|
-
|
21558
|
+
const isOpen = isNodeOpened(item);
|
21559
|
+
asyncNodeClick(item).finally(() => {
|
21560
|
+
if (getNodeAttr2(item, NODE_ATTRIBUTES.IS_LOADING)) {
|
21561
|
+
registerNextLoop("setNodeOpenedAfterLoading", {
|
21562
|
+
type: "once",
|
21563
|
+
fn: () => setNodeOpened(item, !isOpen, e)
|
21564
|
+
});
|
21565
|
+
} else {
|
21566
|
+
setNodeOpened(item, !isOpen, e);
|
21567
|
+
}
|
21568
|
+
});
|
21504
21569
|
};
|
21505
21570
|
const handleNodeActionClick = (e, node) => {
|
21506
21571
|
e.stopImmediatePropagation();
|
@@ -21576,13 +21641,6 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
|
|
21576
21641
|
"style": getNodeLineStyle(maxDeep - index)
|
21577
21642
|
}, null));
|
21578
21643
|
};
|
21579
|
-
const resolveScopedSlotParam = (item) => __spreadProps(__spreadValues({}, item), {
|
21580
|
-
hasChildNode: hasChildNode(item),
|
21581
|
-
isMatched: isNodeMatched(item),
|
21582
|
-
isChecked: isNodeChecked(item),
|
21583
|
-
isOpened: isNodeOpened(item),
|
21584
|
-
isRoot: isRootNode(item)
|
21585
|
-
});
|
21586
21644
|
const renderTreeNode = (item) => {
|
21587
21645
|
var _a, _b, _c, _d, _e;
|
21588
21646
|
return createVNode("div", {
|
@@ -21597,7 +21655,7 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
|
|
21597
21655
|
"onClick": (e) => handleNodeActionClick(e, item)
|
21598
21656
|
}, [getActionIcon(item)]), createVNode("span", {
|
21599
21657
|
"class": resolveClassName("node-content")
|
21600
|
-
}, [[getNodePrefixIcon(item)
|
21658
|
+
}, [[getNodePrefixIcon(item)], createVNode("span", {
|
21601
21659
|
"class": resolveClassName("node-text")
|
21602
21660
|
}, [(_c = (_b = (_a = ctx.slots).node) == null ? void 0 : _b.call(_a, resolveScopedSlotParam(item))) != null ? _c : [getLabel(item, props)]]), (_e = (_d = ctx.slots).nodeAppend) == null ? void 0 : _e.call(_d, resolveScopedSlotParam(item))]), getVirtualLines(item)])]);
|
21603
21661
|
};
|
@@ -21944,36 +22002,44 @@ var useTreeInit = (props) => {
|
|
21944
22002
|
}
|
21945
22003
|
return uid || item[NODE_ATTRIBUTES.UUID] || uuid_1.v4();
|
21946
22004
|
}
|
21947
|
-
function getCachedTreeNodeAttr(uuid2, node,
|
22005
|
+
function getCachedTreeNodeAttr(uuid2, node, cachedAttr, defVal = void 0) {
|
22006
|
+
const sourceAttr = NODE_SOURCE_ATTRS[cachedAttr];
|
22007
|
+
if (Object.prototype.hasOwnProperty.call(node, sourceAttr)) {
|
22008
|
+
return node[sourceAttr];
|
22009
|
+
}
|
21948
22010
|
const cached = (cachedSchema || []).find((item) => item[NODE_ATTRIBUTES.UUID] === uuid2);
|
21949
22011
|
let result = void 0;
|
21950
22012
|
if (cached) {
|
21951
22013
|
result = cached[cachedAttr];
|
21952
|
-
} else {
|
21953
|
-
result = attr === null ? void 0 : node[attr];
|
21954
22014
|
}
|
21955
|
-
if (result === void 0) {
|
22015
|
+
if (result === void 0 || result === null) {
|
21956
22016
|
result = defVal;
|
21957
22017
|
}
|
21958
22018
|
return result;
|
21959
22019
|
}
|
21960
22020
|
function isCachedTreeNodeOpened(uuid2, node) {
|
21961
|
-
return getCachedTreeNodeAttr(uuid2, node,
|
22021
|
+
return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_OPENED, false);
|
21962
22022
|
}
|
21963
22023
|
function isCachedTreeNodeChecked(uuid2, node) {
|
21964
|
-
return getCachedTreeNodeAttr(uuid2, node,
|
22024
|
+
return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_CHECKED, false);
|
21965
22025
|
}
|
21966
22026
|
function isCachedTreeNodeMatch(uuid2, node) {
|
21967
|
-
return getCachedTreeNodeAttr(uuid2, node,
|
22027
|
+
return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_MATCH, true);
|
21968
22028
|
}
|
21969
22029
|
function isCachedTreeNodeSelected(uuid2, node) {
|
21970
|
-
return getCachedTreeNodeAttr(uuid2, node,
|
22030
|
+
return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_SELECTED, false);
|
21971
22031
|
}
|
21972
22032
|
function isCachedTreeNodeHasCached(uuid2, node) {
|
21973
|
-
return getCachedTreeNodeAttr(uuid2, node,
|
22033
|
+
return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_CACHED, false);
|
21974
22034
|
}
|
21975
22035
|
function isCachedTreeNodeAsync(uuid2, node) {
|
21976
|
-
return getCachedTreeNodeAttr(uuid2, node,
|
22036
|
+
return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_ASYNC, null);
|
22037
|
+
}
|
22038
|
+
function isCachedTreeNodeLoading(uuid2, node) {
|
22039
|
+
if (Object.prototype.hasOwnProperty.call(node, NODE_ATTRIBUTES.IS_LOADING)) {
|
22040
|
+
return node[NODE_ATTRIBUTES.IS_LOADING];
|
22041
|
+
}
|
22042
|
+
return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_LOADING, false);
|
21977
22043
|
}
|
21978
22044
|
function validateIsOpenLoopFn(target) {
|
21979
22045
|
return !target[NODE_ATTRIBUTES.IS_OPENED];
|
@@ -22004,6 +22070,7 @@ var useTreeInit = (props) => {
|
|
22004
22070
|
[NODE_ATTRIBUTES.IS_CHECKED]: isCachedTreeNodeChecked(uuid2, item),
|
22005
22071
|
[NODE_ATTRIBUTES.IS_CACHED]: isCachedTreeNodeHasCached(uuid2, item),
|
22006
22072
|
[NODE_ATTRIBUTES.IS_ASYNC]: isCachedTreeNodeAsync(uuid2, item),
|
22073
|
+
[NODE_ATTRIBUTES.IS_LOADING]: isCachedTreeNodeLoading(uuid2, item),
|
22007
22074
|
[children]: null
|
22008
22075
|
};
|
22009
22076
|
Object.assign(item, {
|
@@ -22050,13 +22117,49 @@ var useTreeInit = (props) => {
|
|
22050
22117
|
}
|
22051
22118
|
nextLoopEvents.set(key, event);
|
22052
22119
|
};
|
22120
|
+
const resolveEventOption = (event) => {
|
22121
|
+
if (typeof event === "function") {
|
22122
|
+
return {
|
22123
|
+
type: "loop",
|
22124
|
+
fn: event
|
22125
|
+
};
|
22126
|
+
}
|
22127
|
+
if (typeof event === "object" && typeof event.type === "string" && typeof event.fn === "function") {
|
22128
|
+
return event;
|
22129
|
+
}
|
22130
|
+
console.error("loop event error", event);
|
22131
|
+
return null;
|
22132
|
+
};
|
22133
|
+
const executeFn = (event) => {
|
22134
|
+
var _a2;
|
22135
|
+
const resoveEvent = resolveEventOption(event);
|
22136
|
+
if (resoveEvent !== null) {
|
22137
|
+
Reflect.apply(resoveEvent.fn, globalThis, []);
|
22138
|
+
}
|
22139
|
+
return (_a2 = resoveEvent == null ? void 0 : resoveEvent.type) != null ? _a2 : "once";
|
22140
|
+
};
|
22053
22141
|
const executeNextEvent = () => {
|
22054
22142
|
Array.from(nextLoopEvents.keys()).forEach((key) => {
|
22055
22143
|
const target = nextLoopEvents.get(key);
|
22056
22144
|
if (Array.isArray(target)) {
|
22057
|
-
|
22145
|
+
const clearList = [];
|
22146
|
+
target.forEach((event, index) => {
|
22147
|
+
const result = executeFn(event);
|
22148
|
+
if (result === "once") {
|
22149
|
+
clearList.unshift(index);
|
22150
|
+
}
|
22151
|
+
});
|
22152
|
+
if (clearList.length) {
|
22153
|
+
clearList.forEach((index) => target.splice(index, 1));
|
22154
|
+
}
|
22155
|
+
if (target.length === 0) {
|
22156
|
+
nextLoopEvents.delete(key);
|
22157
|
+
}
|
22058
22158
|
} else {
|
22059
|
-
|
22159
|
+
const result = executeFn(target);
|
22160
|
+
if (result === "once") {
|
22161
|
+
nextLoopEvents.delete(key);
|
22162
|
+
}
|
22060
22163
|
}
|
22061
22164
|
});
|
22062
22165
|
};
|
@@ -22096,6 +22199,7 @@ var useTreeInit = (props) => {
|
|
22096
22199
|
asyncNodeClick,
|
22097
22200
|
deepAutoOpen,
|
22098
22201
|
afterDataUpdate,
|
22202
|
+
registerNextLoop,
|
22099
22203
|
onSelected
|
22100
22204
|
};
|
22101
22205
|
};
|
@@ -22107,7 +22211,8 @@ var Component$2 = defineComponent({
|
|
22107
22211
|
const {
|
22108
22212
|
flatData,
|
22109
22213
|
schemaValues,
|
22110
|
-
onSelected
|
22214
|
+
onSelected,
|
22215
|
+
registerNextLoop
|
22111
22216
|
} = useTreeInit(props);
|
22112
22217
|
const {
|
22113
22218
|
setNodeAttr,
|
@@ -22119,7 +22224,7 @@ var Component$2 = defineComponent({
|
|
22119
22224
|
isNodeChecked,
|
22120
22225
|
isNodeMatched,
|
22121
22226
|
hasChildNode
|
22122
|
-
} = useNodeAttribute(flatData);
|
22227
|
+
} = useNodeAttribute(flatData, props);
|
22123
22228
|
const {
|
22124
22229
|
searchFn,
|
22125
22230
|
isSearchActive,
|
@@ -22155,7 +22260,9 @@ var Component$2 = defineComponent({
|
|
22155
22260
|
setNodeAction,
|
22156
22261
|
setSelect,
|
22157
22262
|
asyncNodeClick
|
22158
|
-
} = useNodeAction(props, ctx, flatData, renderData, schemaValues
|
22263
|
+
} = useNodeAction(props, ctx, flatData, renderData, schemaValues, {
|
22264
|
+
registerNextLoop
|
22265
|
+
});
|
22159
22266
|
const setChecked = (item, checked = true) => {
|
22160
22267
|
setNodeAction(resolveNodeItem(item), NODE_ATTRIBUTES.IS_CHECKED, checked);
|
22161
22268
|
};
|