bkui-vue 0.0.1-beta.74 → 0.0.1-beta.77

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.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 == null ? void 0 : slots.default) == null ? void 0 : _a.call(slots)]);
16389
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
16386
16390
  };
16387
16391
  }
16388
16392
  });
@@ -21085,8 +21089,19 @@ 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";
21093
+ NODE_ATTRIBUTES2["TREE_NODE_ATTR"] = "__attr__";
21088
21094
  return NODE_ATTRIBUTES2;
21089
21095
  })(NODE_ATTRIBUTES || {});
21096
+ const NODE_SOURCE_ATTRS = {
21097
+ ["__is_open"]: "isOpen",
21098
+ ["__is_selected"]: "selected",
21099
+ ["__is_match"]: "isMatch",
21100
+ ["__has_child"]: "hasChild",
21101
+ ["__is_checked"]: "checked",
21102
+ ["__is_async"]: "async",
21103
+ ["__is_loading"]: "loading"
21104
+ };
21090
21105
  const treeProps = {
21091
21106
  data: PropTypes.arrayOf(PropTypes.any).def([]),
21092
21107
  label: PropTypes.oneOfType([PropTypes.func.def(void 0), PropTypes.string.def("label")]),
@@ -21133,7 +21148,9 @@ const treeProps = {
21133
21148
  draggable: PropTypes.bool.def(false),
21134
21149
  dragSort: PropTypes.bool.def(false),
21135
21150
  selectable: PropTypes.bool.def(true),
21136
- selected: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).def(null)
21151
+ selected: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).def(null),
21152
+ autoCheckChildren: PropTypes.bool.def(true),
21153
+ syncAction: PropTypes.bool.def(false)
21137
21154
  };
21138
21155
  var useEmpty = (props, {
21139
21156
  slots
@@ -21148,79 +21165,6 @@ var useEmpty = (props, {
21148
21165
  }
21149
21166
  })
21150
21167
  });
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
21168
  const DEFAULT_LEVLE_LINE = "1px dashed #c3cdd7";
21225
21169
  const getPropsOneOfBoolValueWithDefault = (props, key, item = null, defaultTrueValue = null, defaultFalseValue = null, args = []) => {
21226
21170
  const prop = props[key];
@@ -21318,12 +21262,118 @@ const resolveNodeItem = (node) => {
21318
21262
  console.error("setNodeAction Error: node id cannot found");
21319
21263
  return node;
21320
21264
  };
21265
+ var useNodeAttribute = (flatData, props) => {
21266
+ const getSchemaVal2 = (key) => flatData.schema.get(key);
21267
+ const getNodeAttr2 = (node, attr) => {
21268
+ var _a;
21269
+ return (_a = getSchemaVal2(node[NODE_ATTRIBUTES.UUID])) == null ? void 0 : _a[attr];
21270
+ };
21271
+ const setNodeAttr = (node, attr, val) => {
21272
+ if (props.syncAction && NODE_SOURCE_ATTRS[attr] !== void 0) {
21273
+ updateTreeNode(getNodePath(node), props.data, props.children, NODE_SOURCE_ATTRS[attr], val);
21274
+ }
21275
+ flatData.schema.set(node[NODE_ATTRIBUTES.UUID], __spreadProps(__spreadValues({}, getSchemaVal2(node[NODE_ATTRIBUTES.UUID])), {
21276
+ [attr]: val
21277
+ }));
21278
+ };
21279
+ const getNodePath = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.PATH);
21280
+ const getNodeId = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.UUID);
21281
+ const isRootNode = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_ROOT);
21282
+ const isNodeOpened = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_OPENED);
21283
+ const hasChildNode = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.HAS_CHILD);
21284
+ const isNodeMatched = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_MATCH);
21285
+ const isNodeChecked = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_CHECKED);
21286
+ const getNodeParentId = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.PARENT_ID);
21287
+ const getNodeParentIdById = (id) => getNodeAttr2({
21288
+ [NODE_ATTRIBUTES.UUID]: id
21289
+ }, NODE_ATTRIBUTES.PARENT_ID);
21290
+ const isNodeLoading = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_LOADING);
21291
+ const setTreeNodeLoading = (node, value) => {
21292
+ setNodeAttr(node, NODE_ATTRIBUTES.IS_LOADING, value);
21293
+ if (!props.syncAction) {
21294
+ updateTreeNode(getNodePath(node), props.data, props.children, NODE_ATTRIBUTES.IS_LOADING, value);
21295
+ }
21296
+ };
21297
+ const deleteNodeSchema = (id) => flatData.schema.delete(id);
21298
+ const isItemOpen = (item) => {
21299
+ var _a;
21300
+ if (typeof item === "object") {
21301
+ return isNodeOpened(item);
21302
+ }
21303
+ if (typeof item === "string") {
21304
+ return (_a = getSchemaVal2(item)) == null ? void 0 : _a[NODE_ATTRIBUTES.IS_OPENED];
21305
+ }
21306
+ return false;
21307
+ };
21308
+ const checkNodeIsOpen = (node) => isRootNode(node) || isItemOpen(node) || isItemOpen(getNodeAttr2(node, NODE_ATTRIBUTES.PARENT_ID));
21309
+ const getSourceNodeByPath = (path) => {
21310
+ const paths = path.split("-");
21311
+ return paths.reduce((pre, nodeIndex) => {
21312
+ const index = Number(nodeIndex);
21313
+ return Array.isArray(pre) ? pre[index] : pre[props.children][index];
21314
+ }, props.data);
21315
+ };
21316
+ const getSourceNodeByUID = (uid) => getSourceNodeByPath(getNodePath({
21317
+ [NODE_ATTRIBUTES.UUID]: uid
21318
+ }));
21319
+ const getParentNodeData = (uid) => {
21320
+ if (isRootNode({
21321
+ [NODE_ATTRIBUTES.UUID]: uid
21322
+ })) {
21323
+ return {
21324
+ [props.children]: props.data
21325
+ };
21326
+ }
21327
+ return getSourceNodeByUID(getNodeParentIdById(uid));
21328
+ };
21329
+ const resolveScopedSlotParam = (item) => ({
21330
+ loading: getNodeAttr2(item, NODE_ATTRIBUTES.IS_LOADING),
21331
+ hasChildNode: hasChildNode(item),
21332
+ isMatched: isNodeMatched(item),
21333
+ isChecked: isNodeChecked(item),
21334
+ isOpened: isNodeOpened(item),
21335
+ isRoot: isRootNode(item),
21336
+ fullPath: getNodeAttr2(item, NODE_ATTRIBUTES.PATH),
21337
+ uuid: getNodeId(item),
21338
+ parentId: getNodeAttr2(item, NODE_ATTRIBUTES.PARENT_ID)
21339
+ });
21340
+ const extendNodeAttr = (item) => __spreadProps(__spreadValues({}, item), {
21341
+ [NODE_ATTRIBUTES.TREE_NODE_ATTR]: resolveScopedSlotParam(item)
21342
+ });
21343
+ return {
21344
+ getSchemaVal: getSchemaVal2,
21345
+ getNodeAttr: getNodeAttr2,
21346
+ getNodeId,
21347
+ getNodeParentId,
21348
+ getNodeParentIdById,
21349
+ getParentNodeData,
21350
+ setNodeAttr,
21351
+ getNodePath,
21352
+ isRootNode,
21353
+ isNodeOpened,
21354
+ hasChildNode,
21355
+ isItemOpen,
21356
+ isNodeChecked,
21357
+ isNodeMatched,
21358
+ isNodeLoading,
21359
+ checkNodeIsOpen,
21360
+ getSourceNodeByPath,
21361
+ getSourceNodeByUID,
21362
+ deleteNodeSchema,
21363
+ resolveScopedSlotParam,
21364
+ setTreeNodeLoading,
21365
+ extendNodeAttr
21366
+ };
21367
+ };
21321
21368
  var useNodeAsync = (props, flatData) => {
21322
21369
  const {
21323
21370
  setNodeAttr,
21324
21371
  getNodePath,
21325
- getNodeAttr: getNodeAttr2
21326
- } = useNodeAttribute(flatData);
21372
+ getNodeAttr: getNodeAttr2,
21373
+ isNodeOpened,
21374
+ resolveScopedSlotParam,
21375
+ setTreeNodeLoading
21376
+ } = useNodeAttribute(flatData, props);
21327
21377
  const setNodeRemoteLoad = (resp, item) => {
21328
21378
  if (typeof resp === "object" && resp !== null) {
21329
21379
  setNodeAttr(item, NODE_ATTRIBUTES.IS_OPENED, true);
@@ -21331,37 +21381,42 @@ var useNodeAsync = (props, flatData) => {
21331
21381
  updateTreeNode(getNodePath(item), props.data, props.children, props.children, nodeValue);
21332
21382
  return Promise.resolve(resp);
21333
21383
  }
21334
- return Promise.reject(resp);
21384
+ return Promise.resolve(resp);
21335
21385
  };
21336
21386
  const asyncNodeClick = (item) => {
21337
- if (getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC)) {
21338
- const {
21339
- callback = null,
21340
- cache = true
21341
- } = props.async || {};
21387
+ const {
21388
+ callback = null,
21389
+ cache = true
21390
+ } = props.async || {};
21391
+ if (typeof callback === "function" && getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC) !== false) {
21392
+ const isAsyncInit = getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC_INIT);
21342
21393
  setNodeAttr(item, NODE_ATTRIBUTES.IS_ASYNC_INIT, true);
21343
- if (typeof callback === "function") {
21344
- if (!getNodeAttr2(item, NODE_ATTRIBUTES.IS_CACHED)) {
21345
- setNodeAttr(item, NODE_ATTRIBUTES.IS_CACHED, cache);
21346
- Object.assign(item, {
21347
- loading: true
21348
- });
21349
- return Promise.resolve(callback(item, (resp) => setNodeRemoteLoad(resp, item)).then((resp) => setNodeRemoteLoad(resp, item)).catch((err) => console.error("load remote data error:", err)).finally(() => {
21350
- assignTreeNode(getNodePath(item), props.data, props.children, __spreadValues({
21351
- loading: false
21352
- }, cache ? {
21353
- cached: true
21354
- } : {}));
21355
- }));
21394
+ if (!getNodeAttr2(item, NODE_ATTRIBUTES.IS_CACHED)) {
21395
+ setNodeAttr(item, NODE_ATTRIBUTES.IS_CACHED, cache);
21396
+ if (isNodeOpened(item) && isAsyncInit) {
21397
+ return Promise.resolve(true);
21398
+ }
21399
+ const dataAttr = resolveScopedSlotParam(item);
21400
+ const callbackResult = callback(item, (resp) => setNodeRemoteLoad(resp, item), dataAttr);
21401
+ if (typeof callbackResult === "object" && callbackResult !== null) {
21402
+ setTreeNodeLoading(item, true);
21403
+ if (callbackResult instanceof Promise) {
21404
+ return Promise.resolve(callbackResult.then((resp) => setNodeRemoteLoad(resp, item)).catch((err) => console.error("load remote data error:", err)).finally(() => {
21405
+ setTreeNodeLoading(item, false);
21406
+ setNodeAttr(item, NODE_ATTRIBUTES.IS_CACHED, true);
21407
+ }));
21408
+ }
21409
+ setNodeRemoteLoad(callbackResult, item);
21410
+ setTreeNodeLoading(item, false);
21411
+ return Promise.resolve(true);
21356
21412
  }
21357
- return Promise.resolve(true);
21358
21413
  }
21359
- return Promise.reject("async need to set prop: asyncLoad with function wich will return promise object");
21414
+ return Promise.resolve(true);
21360
21415
  }
21361
21416
  return Promise.resolve(true);
21362
21417
  };
21363
21418
  const deepAutoOpen = () => {
21364
- const autoOpenNodes = flatData.data.filter((item) => item.async && item.isOpen && !getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC_INIT));
21419
+ const autoOpenNodes = flatData.data.filter((item) => getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC) && item.isOpen && !getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC_INIT));
21365
21420
  if (autoOpenNodes.length) {
21366
21421
  Promise.all(autoOpenNodes.map((item) => asyncNodeClick(item))).then(() => {
21367
21422
  deepAutoOpen();
@@ -21375,7 +21430,7 @@ var useNodeAsync = (props, flatData) => {
21375
21430
  deepAutoOpen
21376
21431
  };
21377
21432
  };
21378
- var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21433
+ var useNodeAction = (props, ctx, flatData, renderData, schemaValues, initOption) => {
21379
21434
  let selectedNodeId = null;
21380
21435
  const {
21381
21436
  setNodeAttr,
@@ -21387,9 +21442,13 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21387
21442
  hasChildNode,
21388
21443
  isItemOpen,
21389
21444
  isNodeOpened,
21390
- isNodeChecked,
21391
- isNodeMatched
21392
- } = useNodeAttribute(flatData);
21445
+ isNodeLoading,
21446
+ resolveScopedSlotParam,
21447
+ extendNodeAttr
21448
+ } = useNodeAttribute(flatData, props);
21449
+ const {
21450
+ registerNextLoop
21451
+ } = initOption;
21393
21452
  const {
21394
21453
  asyncNodeClick,
21395
21454
  deepAutoOpen
@@ -21420,19 +21479,26 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21420
21479
  }
21421
21480
  return null;
21422
21481
  };
21482
+ const getLoadingIcon = (item) => {
21483
+ var _a, _b, _c;
21484
+ return ((_c = (_b = (_a = ctx.slots).nodeLoading) == null ? void 0 : _b.call(_a, extendNodeAttr(item))) != null ? _c : isNodeLoading(item)) ? createVNode(spinner, null, null) : "";
21485
+ };
21423
21486
  const getActionIcon = (item) => {
21424
21487
  if (ctx.slots.nodeAction) {
21425
- return ctx.slots.nodeAction(resolveScopedSlotParam(item));
21488
+ return ctx.slots.nodeAction(extendNodeAttr(item));
21426
21489
  }
21427
21490
  let prefixFnVal = null;
21491
+ if (isNodeLoading(item)) {
21492
+ return getLoadingIcon(item);
21493
+ }
21428
21494
  if (typeof props.prefixIcon === "function") {
21429
- prefixFnVal = props.prefixIcon(resolveScopedSlotParam(item), "node_action");
21495
+ prefixFnVal = props.prefixIcon(extendNodeAttr(item), "node_action");
21430
21496
  if (prefixFnVal !== "default") {
21431
21497
  return renderPrefixVal(prefixFnVal);
21432
21498
  }
21433
21499
  }
21434
21500
  if (prefixFnVal === "default" || typeof props.prefixIcon === "boolean" && props.prefixIcon) {
21435
- if (hasChildNode(item) || item.async) {
21501
+ if (hasChildNode(item) || item.async || !props.autoCheckChildren) {
21436
21502
  return isItemOpen(item) ? createVNode(downShape, null, null) : createVNode(rightShape, null, null);
21437
21503
  }
21438
21504
  }
@@ -21440,11 +21506,11 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21440
21506
  };
21441
21507
  const getNodePrefixIcon = (item) => {
21442
21508
  if (ctx.slots.nodeType) {
21443
- return ctx.slots.nodeType(resolveScopedSlotParam(item));
21509
+ return ctx.slots.nodeType(extendNodeAttr(item));
21444
21510
  }
21445
21511
  let prefixFnVal = null;
21446
21512
  if (typeof props.prefixIcon === "function") {
21447
- prefixFnVal = props.prefixIcon(resolveScopedSlotParam(item), "node_type");
21513
+ prefixFnVal = props.prefixIcon(extendNodeAttr(item), "node_type");
21448
21514
  if (prefixFnVal !== "default") {
21449
21515
  return renderPrefixVal(prefixFnVal);
21450
21516
  }
@@ -21456,16 +21522,12 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21456
21522
  }
21457
21523
  return null;
21458
21524
  };
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
21525
  const setNodeOpened = (item, isOpen = null, e = null, fireEmit = true) => {
21464
21526
  const newVal = isOpen === null ? !isItemOpen(item) : !!isOpen;
21465
21527
  setNodeAttr(item, NODE_ATTRIBUTES.IS_OPENED, newVal);
21466
21528
  if (fireEmit) {
21467
21529
  const emitEvent = isItemOpen(item) ? EVENTS.NODE_EXPAND : EVENTS.NODE_COLLAPSE;
21468
- ctx.emit(emitEvent, resolveScopedSlotParam(item), getSchemaVal2(item[NODE_ATTRIBUTES.UUID]), e);
21530
+ ctx.emit(emitEvent, item, resolveScopedSlotParam(item), getSchemaVal2(item[NODE_ATTRIBUTES.UUID]), e);
21469
21531
  }
21470
21532
  if (newVal) {
21471
21533
  return;
@@ -21499,8 +21561,17 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21499
21561
  }
21500
21562
  };
21501
21563
  const hanldeTreeNodeClick = (item, e) => {
21502
- asyncNodeClick(item);
21503
- setNodeOpened(item, null, e);
21564
+ const isOpen = isNodeOpened(item);
21565
+ asyncNodeClick(item).finally(() => {
21566
+ if (getNodeAttr2(item, NODE_ATTRIBUTES.IS_LOADING)) {
21567
+ registerNextLoop("setNodeOpenedAfterLoading", {
21568
+ type: "once",
21569
+ fn: () => setNodeOpened(item, !isOpen, e)
21570
+ });
21571
+ } else {
21572
+ setNodeOpened(item, !isOpen, e);
21573
+ }
21574
+ });
21504
21575
  };
21505
21576
  const handleNodeActionClick = (e, node) => {
21506
21577
  e.stopImmediatePropagation();
@@ -21545,7 +21616,7 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21545
21616
  if (!isNodeOpened(item)) {
21546
21617
  hanldeTreeNodeClick(item, e);
21547
21618
  }
21548
- ctx.emit(EVENTS.NODE_CLICK, resolveScopedSlotParam(item), getSchemaVal2(item[NODE_ATTRIBUTES.UUID]), e);
21619
+ ctx.emit(EVENTS.NODE_CLICK, item, resolveScopedSlotParam(item), getSchemaVal2(item[NODE_ATTRIBUTES.UUID]), e);
21549
21620
  };
21550
21621
  const filterNextNode = (depth, node) => {
21551
21622
  if (isRootNode(node)) {
@@ -21576,13 +21647,6 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21576
21647
  "style": getNodeLineStyle(maxDeep - index)
21577
21648
  }, null));
21578
21649
  };
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
21650
  const renderTreeNode = (item) => {
21587
21651
  var _a, _b, _c, _d, _e;
21588
21652
  return createVNode("div", {
@@ -21597,9 +21661,9 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21597
21661
  "onClick": (e) => handleNodeActionClick(e, item)
21598
21662
  }, [getActionIcon(item)]), createVNode("span", {
21599
21663
  "class": resolveClassName("node-content")
21600
- }, [[getNodePrefixIcon(item), getLoadingIcon(item)], createVNode("span", {
21664
+ }, [[getNodePrefixIcon(item)], createVNode("span", {
21601
21665
  "class": resolveClassName("node-text")
21602
- }, [(_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)])]);
21666
+ }, [(_c = (_b = (_a = ctx.slots).node) == null ? void 0 : _b.call(_a, extendNodeAttr(item))) != null ? _c : [getLabel(item, props)]]), (_e = (_d = ctx.slots).nodeAppend) == null ? void 0 : _e.call(_d, extendNodeAttr(item))]), getVirtualLines(item)])]);
21603
21667
  };
21604
21668
  return {
21605
21669
  renderTreeNode,
@@ -21944,36 +22008,44 @@ var useTreeInit = (props) => {
21944
22008
  }
21945
22009
  return uid || item[NODE_ATTRIBUTES.UUID] || uuid_1.v4();
21946
22010
  }
21947
- function getCachedTreeNodeAttr(uuid2, node, attr, cachedAttr, defVal = void 0) {
22011
+ function getCachedTreeNodeAttr(uuid2, node, cachedAttr, defVal = void 0) {
22012
+ const sourceAttr = NODE_SOURCE_ATTRS[cachedAttr];
22013
+ if (Object.prototype.hasOwnProperty.call(node, sourceAttr)) {
22014
+ return node[sourceAttr];
22015
+ }
21948
22016
  const cached = (cachedSchema || []).find((item) => item[NODE_ATTRIBUTES.UUID] === uuid2);
21949
22017
  let result = void 0;
21950
22018
  if (cached) {
21951
22019
  result = cached[cachedAttr];
21952
- } else {
21953
- result = attr === null ? void 0 : node[attr];
21954
22020
  }
21955
- if (result === void 0) {
22021
+ if (result === void 0 || result === null) {
21956
22022
  result = defVal;
21957
22023
  }
21958
22024
  return result;
21959
22025
  }
21960
22026
  function isCachedTreeNodeOpened(uuid2, node) {
21961
- return getCachedTreeNodeAttr(uuid2, node, "isOpen", NODE_ATTRIBUTES.IS_OPENED, false);
22027
+ return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_OPENED, false);
21962
22028
  }
21963
22029
  function isCachedTreeNodeChecked(uuid2, node) {
21964
- return getCachedTreeNodeAttr(uuid2, node, "checked", NODE_ATTRIBUTES.IS_CHECKED, false);
22030
+ return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_CHECKED, false);
21965
22031
  }
21966
22032
  function isCachedTreeNodeMatch(uuid2, node) {
21967
- return getCachedTreeNodeAttr(uuid2, node, "isMatch", NODE_ATTRIBUTES.IS_MATCH, true);
22033
+ return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_MATCH, true);
21968
22034
  }
21969
22035
  function isCachedTreeNodeSelected(uuid2, node) {
21970
- return getCachedTreeNodeAttr(uuid2, node, null, NODE_ATTRIBUTES.IS_SELECTED, false);
22036
+ return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_SELECTED, false);
21971
22037
  }
21972
22038
  function isCachedTreeNodeHasCached(uuid2, node) {
21973
- return getCachedTreeNodeAttr(uuid2, node, "cached", NODE_ATTRIBUTES.IS_CACHED, false);
22039
+ return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_CACHED, false);
21974
22040
  }
21975
22041
  function isCachedTreeNodeAsync(uuid2, node) {
21976
- return getCachedTreeNodeAttr(uuid2, node, "async", NODE_ATTRIBUTES.IS_ASYNC, false);
22042
+ return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_ASYNC, null);
22043
+ }
22044
+ function isCachedTreeNodeLoading(uuid2, node) {
22045
+ if (Object.prototype.hasOwnProperty.call(node, NODE_ATTRIBUTES.IS_LOADING)) {
22046
+ return node[NODE_ATTRIBUTES.IS_LOADING];
22047
+ }
22048
+ return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_LOADING, false);
21977
22049
  }
21978
22050
  function validateIsOpenLoopFn(target) {
21979
22051
  return !target[NODE_ATTRIBUTES.IS_OPENED];
@@ -22004,6 +22076,7 @@ var useTreeInit = (props) => {
22004
22076
  [NODE_ATTRIBUTES.IS_CHECKED]: isCachedTreeNodeChecked(uuid2, item),
22005
22077
  [NODE_ATTRIBUTES.IS_CACHED]: isCachedTreeNodeHasCached(uuid2, item),
22006
22078
  [NODE_ATTRIBUTES.IS_ASYNC]: isCachedTreeNodeAsync(uuid2, item),
22079
+ [NODE_ATTRIBUTES.IS_LOADING]: isCachedTreeNodeLoading(uuid2, item),
22007
22080
  [children]: null
22008
22081
  };
22009
22082
  Object.assign(item, {
@@ -22050,13 +22123,49 @@ var useTreeInit = (props) => {
22050
22123
  }
22051
22124
  nextLoopEvents.set(key, event);
22052
22125
  };
22126
+ const resolveEventOption = (event) => {
22127
+ if (typeof event === "function") {
22128
+ return {
22129
+ type: "loop",
22130
+ fn: event
22131
+ };
22132
+ }
22133
+ if (typeof event === "object" && typeof event.type === "string" && typeof event.fn === "function") {
22134
+ return event;
22135
+ }
22136
+ console.error("loop event error", event);
22137
+ return null;
22138
+ };
22139
+ const executeFn = (event) => {
22140
+ var _a2;
22141
+ const resoveEvent = resolveEventOption(event);
22142
+ if (resoveEvent !== null) {
22143
+ Reflect.apply(resoveEvent.fn, globalThis, []);
22144
+ }
22145
+ return (_a2 = resoveEvent == null ? void 0 : resoveEvent.type) != null ? _a2 : "once";
22146
+ };
22053
22147
  const executeNextEvent = () => {
22054
22148
  Array.from(nextLoopEvents.keys()).forEach((key) => {
22055
22149
  const target = nextLoopEvents.get(key);
22056
22150
  if (Array.isArray(target)) {
22057
- target.forEach((event) => Reflect.apply(event, globalThis, []));
22151
+ const clearList = [];
22152
+ target.forEach((event, index) => {
22153
+ const result = executeFn(event);
22154
+ if (result === "once") {
22155
+ clearList.unshift(index);
22156
+ }
22157
+ });
22158
+ if (clearList.length) {
22159
+ clearList.forEach((index) => target.splice(index, 1));
22160
+ }
22161
+ if (target.length === 0) {
22162
+ nextLoopEvents.delete(key);
22163
+ }
22058
22164
  } else {
22059
- Reflect.apply(target, globalThis, []);
22165
+ const result = executeFn(target);
22166
+ if (result === "once") {
22167
+ nextLoopEvents.delete(key);
22168
+ }
22060
22169
  }
22061
22170
  });
22062
22171
  };
@@ -22096,6 +22205,7 @@ var useTreeInit = (props) => {
22096
22205
  asyncNodeClick,
22097
22206
  deepAutoOpen,
22098
22207
  afterDataUpdate,
22208
+ registerNextLoop,
22099
22209
  onSelected
22100
22210
  };
22101
22211
  };
@@ -22107,7 +22217,8 @@ var Component$2 = defineComponent({
22107
22217
  const {
22108
22218
  flatData,
22109
22219
  schemaValues,
22110
- onSelected
22220
+ onSelected,
22221
+ registerNextLoop
22111
22222
  } = useTreeInit(props);
22112
22223
  const {
22113
22224
  setNodeAttr,
@@ -22119,7 +22230,7 @@ var Component$2 = defineComponent({
22119
22230
  isNodeChecked,
22120
22231
  isNodeMatched,
22121
22232
  hasChildNode
22122
- } = useNodeAttribute(flatData);
22233
+ } = useNodeAttribute(flatData, props);
22123
22234
  const {
22124
22235
  searchFn,
22125
22236
  isSearchActive,
@@ -22155,7 +22266,9 @@ var Component$2 = defineComponent({
22155
22266
  setNodeAction,
22156
22267
  setSelect,
22157
22268
  asyncNodeClick
22158
- } = useNodeAction(props, ctx, flatData, renderData, schemaValues);
22269
+ } = useNodeAction(props, ctx, flatData, renderData, schemaValues, {
22270
+ registerNextLoop
22271
+ });
22159
22272
  const setChecked = (item, checked = true) => {
22160
22273
  setNodeAction(resolveNodeItem(item), NODE_ATTRIBUTES.IS_CHECKED, checked);
22161
22274
  };