bkui-vue 0.0.1-beta.72 → 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.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
  };
@@ -9618,8 +9618,8 @@ var Component$q = defineComponent({
9618
9618
  const BkCollapse = withInstall(Component$q);
9619
9619
  const propsMixin$1 = {
9620
9620
  isShow: PropTypes.bool.def(false),
9621
- width: PropTypes.string.def("50%") || PropTypes.number,
9622
- height: PropTypes.string.def("50%") || PropTypes.number,
9621
+ width: PropTypes.oneOfType([String, Number]).def("50%"),
9622
+ height: PropTypes.oneOfType([String, Number]).def("50%"),
9623
9623
  customClass: PropTypes.string || PropTypes.array,
9624
9624
  scrollable: PropTypes.bool.def(true),
9625
9625
  showMask: PropTypes.bool.def(true),
@@ -9632,12 +9632,13 @@ const propsMixin$1 = {
9632
9632
  draggable: PropTypes.bool.def(true),
9633
9633
  quickClose: PropTypes.bool.def(true),
9634
9634
  transfer: PropTypes.bool.def(false),
9635
- title: PropTypes.string.def("Header"),
9636
9635
  maxHeight: PropTypes.string,
9637
9636
  direction: PropTypes.string,
9638
9637
  animateType: PropTypes.string.def("slide"),
9639
9638
  renderDirective: PropTypes.commonType(["show", "if"], "renderDirective").def("show"),
9640
- beforeClose: PropTypes.custom(() => true)
9639
+ beforeClose: PropTypes.custom(() => true),
9640
+ dialogType: PropTypes.commonType(["show", "operation", "confirm", "process"], "dialogType").def("operation"),
9641
+ multiInstance: PropTypes.bool.def(true)
9641
9642
  };
9642
9643
  var Component$p = defineComponent({
9643
9644
  name: "Modal",
@@ -9706,7 +9707,7 @@ var Component$p = defineComponent({
9706
9707
  } : {};
9707
9708
  const bodyClass = `bk-modal-body ${this.animateType === "slide" ? this.direction : ""}`;
9708
9709
  return createVNode("div", {
9709
- "class": ["bk-modal-wrapper", this.size, this.customClass, this.fullscreen ? "bk-model-fullscreen" : ""],
9710
+ "class": ["bk-modal-wrapper", this.customClass],
9710
9711
  "style": this.compStyle
9711
9712
  }, [withDirectives(createVNode("div", {
9712
9713
  "class": "bk-modal-outside",
@@ -9722,8 +9723,8 @@ var Component$p = defineComponent({
9722
9723
  "class": "bk-modal-header"
9723
9724
  }, [(_c = (_b = (_a = this.$slots).header) == null ? void 0 : _b.call(_a)) != null ? _c : ""]), createVNode("div", {
9724
9725
  "class": "bk-modal-content",
9725
- "style": __spreadValues({}, maxHeight)
9726
- }, [(_f = (_e = (_d = this.$slots).default) == null ? void 0 : _e.call(_d)) != null ? _f : ""]), createVNode("div", {
9726
+ "style": [this.dialogType === "show" ? "height: calc(100% - 74px);margin-bottom: 0px" : "", __spreadValues({}, maxHeight)]
9727
+ }, [(_f = (_e = (_d = this.$slots).default) == null ? void 0 : _e.call(_d)) != null ? _f : ""]), this.dialogType === "show" ? "" : createVNode("div", {
9727
9728
  "class": "bk-modal-footer"
9728
9729
  }, [(_i = (_h = (_g = this.$slots).footer) == null ? void 0 : _h.call(_g)) != null ? _i : ""])]) : ""];
9729
9730
  }
@@ -9780,12 +9781,14 @@ var Component$o = defineComponent({
9780
9781
  });
9781
9782
  watch(() => props.isShow, (val) => {
9782
9783
  if (!val) {
9783
- data2.moveStyle = {
9784
- top: "50%",
9785
- left: "50%"
9786
- };
9787
- data2.positionX = 0;
9788
- data2.positionY = 0;
9784
+ setTimeout(() => {
9785
+ data2.moveStyle = {
9786
+ top: "50%",
9787
+ left: "50%"
9788
+ };
9789
+ data2.positionX = 0;
9790
+ data2.positionY = 0;
9791
+ }, 1e3);
9789
9792
  }
9790
9793
  });
9791
9794
  const handleClose = () => {
@@ -9813,6 +9816,9 @@ var Component$o = defineComponent({
9813
9816
  if (props.fullscreen) {
9814
9817
  return false;
9815
9818
  }
9819
+ if (!props.draggable) {
9820
+ return false;
9821
+ }
9816
9822
  const odiv = e.target;
9817
9823
  const parentHeight = e.currentTarget.parentNode.parentNode.offsetHeight;
9818
9824
  const parentWidth = e.currentTarget.parentNode.parentNode.offsetWidth;
@@ -9863,11 +9869,11 @@ var Component$o = defineComponent({
9863
9869
  render() {
9864
9870
  const dialogSlot = {
9865
9871
  header: () => {
9866
- var _a, _b, _c;
9872
+ var _a, _b, _c, _d, _e, _f;
9867
9873
  return [createVNode("div", {
9868
9874
  "class": ["bk-dialog-tool", this.fullscreen || !this.draggable ? "" : "move", this.draggable ? "content-dragging" : ""],
9869
9875
  "onMousedown": this.moveHandler
9870
- }, [createVNode("span", {
9876
+ }, [(_c = (_b = (_a = this.$slots).tools) == null ? void 0 : _b.call(_a)) != null ? _c : "", createVNode("span", {
9871
9877
  "class": ["bk-dialog-close", this.closeIcon ? "" : "close-icon"],
9872
9878
  "onClick": this.handleClose
9873
9879
  }, [createTextVNode("+")])]), createVNode("div", {
@@ -9875,7 +9881,7 @@ var Component$o = defineComponent({
9875
9881
  }, [createVNode("span", {
9876
9882
  "class": "bk-dialog-title",
9877
9883
  "style": `text-align: ${this.headerAlign}`
9878
- }, [(_c = (_b = (_a = this.$slots).header) == null ? void 0 : _b.call(_a)) != null ? _c : this.title])])];
9884
+ }, [(_f = (_e = (_d = this.$slots).header) == null ? void 0 : _e.call(_d)) != null ? _f : this.title])])];
9879
9885
  },
9880
9886
  default: () => {
9881
9887
  var _a, _b, _c;
@@ -9927,7 +9933,7 @@ var Component$o = defineComponent({
9927
9933
  })]) : ""]);
9928
9934
  }
9929
9935
  };
9930
- const className = `bk-dialog-wrapper ${this.scrollable ? "scroll-able" : ""}`;
9936
+ const className = `bk-dialog-wrapper ${this.scrollable ? "scroll-able" : ""} ${this.multiInstance ? "multi-instance" : ""}`;
9931
9937
  return createVNode(BkModal, mergeProps(this.$props, {
9932
9938
  "class": [className, this.fullscreen ? "bk-model-fullscreen" : this.size],
9933
9939
  "style": this.data.moveStyle
@@ -12110,6 +12116,10 @@ var Component$d = defineComponent({
12110
12116
  BkButton
12111
12117
  },
12112
12118
  props: __spreadProps(__spreadValues({}, sliderPops), {
12119
+ title: {
12120
+ type: String,
12121
+ default: ""
12122
+ },
12113
12123
  direction: {
12114
12124
  type: String,
12115
12125
  default: "right",
@@ -16279,11 +16289,8 @@ const collapseMotion = () => ({
16279
16289
  });
16280
16290
  const menuProps = {
16281
16291
  activeKey: String,
16282
- collapse: {
16283
- type: Boolean,
16284
- default: false
16285
- },
16286
- OpenedKeys: {
16292
+ collapse: Boolean,
16293
+ openedKeys: {
16287
16294
  type: Array
16288
16295
  },
16289
16296
  mode: {
@@ -16301,7 +16308,8 @@ var Component$6 = defineComponent({
16301
16308
  emits: ["update:activeKey", "update:openKeys", "click", "openChange"],
16302
16309
  setup(props, {
16303
16310
  slots,
16304
- emit
16311
+ emit,
16312
+ expose
16305
16313
  }) {
16306
16314
  const activeKey = ref("");
16307
16315
  const openedKeys = ref([]);
@@ -16309,11 +16317,6 @@ var Component$6 = defineComponent({
16309
16317
  const mode = computed(() => props.mode);
16310
16318
  const collapse2 = ref(props.collapse);
16311
16319
  const oldOpenKeys = ref([]);
16312
- watch(() => props.OpenedKeys, (keys = openedKeys.value) => {
16313
- openedKeys.value = keys;
16314
- }, {
16315
- immediate: true
16316
- });
16317
16320
  watchEffect(() => {
16318
16321
  if (props.activeKey !== void 0) {
16319
16322
  activeKey.value = props.activeKey;
@@ -16321,6 +16324,7 @@ var Component$6 = defineComponent({
16321
16324
  });
16322
16325
  watch(() => props.collapse, () => {
16323
16326
  collapse2.value = props.collapse;
16327
+ console.info(props.collapse);
16324
16328
  const oldKeys = [...oldOpenKeys.value];
16325
16329
  const openKeys = [...openedKeys.value];
16326
16330
  openedKeys.value = collapse2.value ? [] : oldKeys;
@@ -16328,6 +16332,11 @@ var Component$6 = defineComponent({
16328
16332
  }, {
16329
16333
  immediate: true
16330
16334
  });
16335
+ watch(() => props.openedKeys, (keys = openedKeys.value) => {
16336
+ openedKeys.value = keys;
16337
+ }, {
16338
+ immediate: true
16339
+ });
16331
16340
  const registerMenuInfo = (key, info2) => {
16332
16341
  menuStore.value = __spreadProps(__spreadValues({}, menuStore.value), {
16333
16342
  [key]: info2
@@ -16365,6 +16374,11 @@ var Component$6 = defineComponent({
16365
16374
  handleOpenChange,
16366
16375
  handleActiveChange
16367
16376
  });
16377
+ expose({
16378
+ activeKey,
16379
+ openedKeys,
16380
+ menuStore
16381
+ });
16368
16382
  return () => {
16369
16383
  var _a;
16370
16384
  return createVNode("div", {
@@ -16372,7 +16386,7 @@ var Component$6 = defineComponent({
16372
16386
  "bk-menu": true,
16373
16387
  "is-collapse": collapse2.value
16374
16388
  }
16375
- }, [(_a = slots == null ? void 0 : slots.default) == null ? void 0 : _a.call(slots)]);
16389
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
16376
16390
  };
16377
16391
  }
16378
16392
  });
@@ -21075,8 +21089,18 @@ var NODE_ATTRIBUTES = /* @__PURE__ */ ((NODE_ATTRIBUTES2) => {
21075
21089
  NODE_ATTRIBUTES2["IS_NULL"] = "__IS_NULL";
21076
21090
  NODE_ATTRIBUTES2["IS_CACHED"] = "__is_cached";
21077
21091
  NODE_ATTRIBUTES2["IS_ASYNC"] = "__is_async";
21092
+ NODE_ATTRIBUTES2["IS_LOADING"] = "__is_loading";
21078
21093
  return NODE_ATTRIBUTES2;
21079
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
+ };
21080
21104
  const treeProps = {
21081
21105
  data: PropTypes.arrayOf(PropTypes.any).def([]),
21082
21106
  label: PropTypes.oneOfType([PropTypes.func.def(void 0), PropTypes.string.def("label")]),
@@ -21123,7 +21147,9 @@ const treeProps = {
21123
21147
  draggable: PropTypes.bool.def(false),
21124
21148
  dragSort: PropTypes.bool.def(false),
21125
21149
  selectable: PropTypes.bool.def(true),
21126
- 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)
21127
21153
  };
21128
21154
  var useEmpty = (props, {
21129
21155
  slots
@@ -21138,79 +21164,6 @@ var useEmpty = (props, {
21138
21164
  }
21139
21165
  })
21140
21166
  });
21141
- var useNodeAttribute = (flatData, props) => {
21142
- const getSchemaVal2 = (key) => flatData.schema.get(key);
21143
- const getNodeAttr2 = (node, attr) => {
21144
- var _a;
21145
- return (_a = getSchemaVal2(node[NODE_ATTRIBUTES.UUID])) == null ? void 0 : _a[attr];
21146
- };
21147
- const setNodeAttr = (node, attr, val) => flatData.schema.set(node[NODE_ATTRIBUTES.UUID], __spreadProps(__spreadValues({}, getSchemaVal2(node[NODE_ATTRIBUTES.UUID])), {
21148
- [attr]: val
21149
- }));
21150
- const getNodePath = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.PATH);
21151
- const getNodeId = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.UUID);
21152
- const isRootNode = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_ROOT);
21153
- const isNodeOpened = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_OPENED);
21154
- const hasChildNode = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.HAS_CHILD);
21155
- const isNodeMatched = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_MATCH);
21156
- const isNodeChecked = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_CHECKED);
21157
- const getNodeParentId = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.PARENT_ID);
21158
- const getNodeParentIdById = (id) => getNodeAttr2({
21159
- [NODE_ATTRIBUTES.UUID]: id
21160
- }, NODE_ATTRIBUTES.PARENT_ID);
21161
- const deleteNodeSchema = (id) => flatData.schema.delete(id);
21162
- const isItemOpen = (item) => {
21163
- var _a;
21164
- if (typeof item === "object") {
21165
- return isNodeOpened(item);
21166
- }
21167
- if (typeof item === "string") {
21168
- return (_a = getSchemaVal2(item)) == null ? void 0 : _a[NODE_ATTRIBUTES.IS_OPENED];
21169
- }
21170
- return false;
21171
- };
21172
- const checkNodeIsOpen = (node) => isRootNode(node) || isItemOpen(node) || isItemOpen(getNodeAttr2(node, NODE_ATTRIBUTES.PARENT_ID));
21173
- const getSourceNodeByPath = (path) => {
21174
- const paths = path.split("-");
21175
- return paths.reduce((pre, nodeIndex) => {
21176
- const index = Number(nodeIndex);
21177
- return Array.isArray(pre) ? pre[index] : pre[props.children][index];
21178
- }, props.data);
21179
- };
21180
- const getSourceNodeByUID = (uid) => getSourceNodeByPath(getNodePath({
21181
- [NODE_ATTRIBUTES.UUID]: uid
21182
- }));
21183
- const getParentNodeData = (uid) => {
21184
- if (isRootNode({
21185
- [NODE_ATTRIBUTES.UUID]: uid
21186
- })) {
21187
- return {
21188
- [props.children]: props.data
21189
- };
21190
- }
21191
- return getSourceNodeByUID(getNodeParentIdById(uid));
21192
- };
21193
- return {
21194
- getSchemaVal: getSchemaVal2,
21195
- getNodeAttr: getNodeAttr2,
21196
- getNodeId,
21197
- getNodeParentId,
21198
- getNodeParentIdById,
21199
- getParentNodeData,
21200
- setNodeAttr,
21201
- getNodePath,
21202
- isRootNode,
21203
- isNodeOpened,
21204
- hasChildNode,
21205
- isItemOpen,
21206
- isNodeChecked,
21207
- isNodeMatched,
21208
- checkNodeIsOpen,
21209
- getSourceNodeByPath,
21210
- getSourceNodeByUID,
21211
- deleteNodeSchema
21212
- };
21213
- };
21214
21167
  const DEFAULT_LEVLE_LINE = "1px dashed #c3cdd7";
21215
21168
  const getPropsOneOfBoolValueWithDefault = (props, key, item = null, defaultTrueValue = null, defaultFalseValue = null, args = []) => {
21216
21169
  const prop = props[key];
@@ -21308,12 +21261,114 @@ const resolveNodeItem = (node) => {
21308
21261
  console.error("setNodeAction Error: node id cannot found");
21309
21262
  return node;
21310
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
+ };
21311
21363
  var useNodeAsync = (props, flatData) => {
21312
21364
  const {
21313
21365
  setNodeAttr,
21314
21366
  getNodePath,
21315
- getNodeAttr: getNodeAttr2
21316
- } = useNodeAttribute(flatData);
21367
+ getNodeAttr: getNodeAttr2,
21368
+ isNodeOpened,
21369
+ resolveScopedSlotParam,
21370
+ setTreeNodeLoading
21371
+ } = useNodeAttribute(flatData, props);
21317
21372
  const setNodeRemoteLoad = (resp, item) => {
21318
21373
  if (typeof resp === "object" && resp !== null) {
21319
21374
  setNodeAttr(item, NODE_ATTRIBUTES.IS_OPENED, true);
@@ -21324,34 +21379,39 @@ var useNodeAsync = (props, flatData) => {
21324
21379
  return Promise.reject(resp);
21325
21380
  };
21326
21381
  const asyncNodeClick = (item) => {
21327
- if (getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC)) {
21328
- const {
21329
- callback = null,
21330
- cache = true
21331
- } = props.async || {};
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);
21332
21388
  setNodeAttr(item, NODE_ATTRIBUTES.IS_ASYNC_INIT, true);
21333
- if (typeof callback === "function") {
21334
- if (!getNodeAttr2(item, NODE_ATTRIBUTES.IS_CACHED)) {
21335
- setNodeAttr(item, NODE_ATTRIBUTES.IS_CACHED, cache);
21336
- Object.assign(item, {
21337
- loading: true
21338
- });
21339
- return Promise.resolve(callback(item, (resp) => setNodeRemoteLoad(resp, item)).then((resp) => setNodeRemoteLoad(resp, item)).catch((err) => console.error("load remote data error:", err)).finally(() => {
21340
- assignTreeNode(getNodePath(item), props.data, props.children, __spreadValues({
21341
- loading: false
21342
- }, cache ? {
21343
- cached: true
21344
- } : {}));
21345
- }));
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);
21346
21407
  }
21347
- return Promise.resolve(true);
21348
21408
  }
21349
- return Promise.reject("async need to set prop: asyncLoad with function wich will return promise object");
21409
+ return Promise.resolve(true);
21350
21410
  }
21351
21411
  return Promise.resolve(true);
21352
21412
  };
21353
21413
  const deepAutoOpen = () => {
21354
- const autoOpenNodes = flatData.data.filter((item) => item.async && item.isOpen && !getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC_INIT));
21414
+ const autoOpenNodes = flatData.data.filter((item) => getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC) && item.isOpen && !getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC_INIT));
21355
21415
  if (autoOpenNodes.length) {
21356
21416
  Promise.all(autoOpenNodes.map((item) => asyncNodeClick(item))).then(() => {
21357
21417
  deepAutoOpen();
@@ -21365,7 +21425,7 @@ var useNodeAsync = (props, flatData) => {
21365
21425
  deepAutoOpen
21366
21426
  };
21367
21427
  };
21368
- var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21428
+ var useNodeAction = (props, ctx, flatData, renderData, schemaValues, initOption) => {
21369
21429
  let selectedNodeId = null;
21370
21430
  const {
21371
21431
  setNodeAttr,
@@ -21377,9 +21437,12 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21377
21437
  hasChildNode,
21378
21438
  isItemOpen,
21379
21439
  isNodeOpened,
21380
- isNodeChecked,
21381
- isNodeMatched
21382
- } = useNodeAttribute(flatData);
21440
+ isNodeLoading,
21441
+ resolveScopedSlotParam
21442
+ } = useNodeAttribute(flatData, props);
21443
+ const {
21444
+ registerNextLoop
21445
+ } = initOption;
21383
21446
  const {
21384
21447
  asyncNodeClick,
21385
21448
  deepAutoOpen
@@ -21410,11 +21473,18 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21410
21473
  }
21411
21474
  return null;
21412
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
+ };
21413
21480
  const getActionIcon = (item) => {
21414
21481
  if (ctx.slots.nodeAction) {
21415
21482
  return ctx.slots.nodeAction(resolveScopedSlotParam(item));
21416
21483
  }
21417
21484
  let prefixFnVal = null;
21485
+ if (isNodeLoading(item)) {
21486
+ return getLoadingIcon(item);
21487
+ }
21418
21488
  if (typeof props.prefixIcon === "function") {
21419
21489
  prefixFnVal = props.prefixIcon(resolveScopedSlotParam(item), "node_action");
21420
21490
  if (prefixFnVal !== "default") {
@@ -21422,7 +21492,7 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21422
21492
  }
21423
21493
  }
21424
21494
  if (prefixFnVal === "default" || typeof props.prefixIcon === "boolean" && props.prefixIcon) {
21425
- if (hasChildNode(item) || item.async) {
21495
+ if (hasChildNode(item) || item.async || !props.autoCheckChildren) {
21426
21496
  return isItemOpen(item) ? createVNode(downShape, null, null) : createVNode(rightShape, null, null);
21427
21497
  }
21428
21498
  }
@@ -21446,10 +21516,6 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21446
21516
  }
21447
21517
  return null;
21448
21518
  };
21449
- const getLoadingIcon = (item) => {
21450
- var _a, _b, _c;
21451
- return ((_c = (_b = (_a = ctx.slots).nodeLoading) == null ? void 0 : _b.call(_a, resolveScopedSlotParam(item))) != null ? _c : item.loading) ? createVNode(spinner, null, null) : "";
21452
- };
21453
21519
  const setNodeOpened = (item, isOpen = null, e = null, fireEmit = true) => {
21454
21520
  const newVal = isOpen === null ? !isItemOpen(item) : !!isOpen;
21455
21521
  setNodeAttr(item, NODE_ATTRIBUTES.IS_OPENED, newVal);
@@ -21489,8 +21555,17 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21489
21555
  }
21490
21556
  };
21491
21557
  const hanldeTreeNodeClick = (item, e) => {
21492
- asyncNodeClick(item);
21493
- setNodeOpened(item, null, e);
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
+ });
21494
21569
  };
21495
21570
  const handleNodeActionClick = (e, node) => {
21496
21571
  e.stopImmediatePropagation();
@@ -21566,13 +21641,6 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21566
21641
  "style": getNodeLineStyle(maxDeep - index)
21567
21642
  }, null));
21568
21643
  };
21569
- const resolveScopedSlotParam = (item) => __spreadProps(__spreadValues({}, item), {
21570
- hasChildNode: hasChildNode(item),
21571
- isMatched: isNodeMatched(item),
21572
- isChecked: isNodeChecked(item),
21573
- isOpened: isNodeOpened(item),
21574
- isRoot: isRootNode(item)
21575
- });
21576
21644
  const renderTreeNode = (item) => {
21577
21645
  var _a, _b, _c, _d, _e;
21578
21646
  return createVNode("div", {
@@ -21587,7 +21655,7 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21587
21655
  "onClick": (e) => handleNodeActionClick(e, item)
21588
21656
  }, [getActionIcon(item)]), createVNode("span", {
21589
21657
  "class": resolveClassName("node-content")
21590
- }, [[getNodePrefixIcon(item), getLoadingIcon(item)], createVNode("span", {
21658
+ }, [[getNodePrefixIcon(item)], createVNode("span", {
21591
21659
  "class": resolveClassName("node-text")
21592
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)])]);
21593
21661
  };
@@ -21934,36 +22002,44 @@ var useTreeInit = (props) => {
21934
22002
  }
21935
22003
  return uid || item[NODE_ATTRIBUTES.UUID] || uuid_1.v4();
21936
22004
  }
21937
- function getCachedTreeNodeAttr(uuid2, node, attr, cachedAttr, defVal = void 0) {
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
+ }
21938
22010
  const cached = (cachedSchema || []).find((item) => item[NODE_ATTRIBUTES.UUID] === uuid2);
21939
22011
  let result = void 0;
21940
22012
  if (cached) {
21941
22013
  result = cached[cachedAttr];
21942
- } else {
21943
- result = attr === null ? void 0 : node[attr];
21944
22014
  }
21945
- if (result === void 0) {
22015
+ if (result === void 0 || result === null) {
21946
22016
  result = defVal;
21947
22017
  }
21948
22018
  return result;
21949
22019
  }
21950
22020
  function isCachedTreeNodeOpened(uuid2, node) {
21951
- return getCachedTreeNodeAttr(uuid2, node, "isOpen", NODE_ATTRIBUTES.IS_OPENED, false);
22021
+ return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_OPENED, false);
21952
22022
  }
21953
22023
  function isCachedTreeNodeChecked(uuid2, node) {
21954
- return getCachedTreeNodeAttr(uuid2, node, "checked", NODE_ATTRIBUTES.IS_CHECKED, false);
22024
+ return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_CHECKED, false);
21955
22025
  }
21956
22026
  function isCachedTreeNodeMatch(uuid2, node) {
21957
- return getCachedTreeNodeAttr(uuid2, node, "isMatch", NODE_ATTRIBUTES.IS_MATCH, true);
22027
+ return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_MATCH, true);
21958
22028
  }
21959
22029
  function isCachedTreeNodeSelected(uuid2, node) {
21960
- return getCachedTreeNodeAttr(uuid2, node, null, NODE_ATTRIBUTES.IS_SELECTED, false);
22030
+ return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_SELECTED, false);
21961
22031
  }
21962
22032
  function isCachedTreeNodeHasCached(uuid2, node) {
21963
- return getCachedTreeNodeAttr(uuid2, node, "cached", NODE_ATTRIBUTES.IS_CACHED, false);
22033
+ return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_CACHED, false);
21964
22034
  }
21965
22035
  function isCachedTreeNodeAsync(uuid2, node) {
21966
- return getCachedTreeNodeAttr(uuid2, node, "async", NODE_ATTRIBUTES.IS_ASYNC, false);
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);
21967
22043
  }
21968
22044
  function validateIsOpenLoopFn(target) {
21969
22045
  return !target[NODE_ATTRIBUTES.IS_OPENED];
@@ -21994,6 +22070,7 @@ var useTreeInit = (props) => {
21994
22070
  [NODE_ATTRIBUTES.IS_CHECKED]: isCachedTreeNodeChecked(uuid2, item),
21995
22071
  [NODE_ATTRIBUTES.IS_CACHED]: isCachedTreeNodeHasCached(uuid2, item),
21996
22072
  [NODE_ATTRIBUTES.IS_ASYNC]: isCachedTreeNodeAsync(uuid2, item),
22073
+ [NODE_ATTRIBUTES.IS_LOADING]: isCachedTreeNodeLoading(uuid2, item),
21997
22074
  [children]: null
21998
22075
  };
21999
22076
  Object.assign(item, {
@@ -22018,7 +22095,9 @@ var useTreeInit = (props) => {
22018
22095
  return [outputData, schema];
22019
22096
  };
22020
22097
  const formatData = getFlatdata(props);
22021
- const loopEvents = [];
22098
+ const nextLoopEvents = /* @__PURE__ */ new Map();
22099
+ const afterSelectEvents = [];
22100
+ const afterSelectWatch = [];
22022
22101
  const flatData = reactive({
22023
22102
  data: formatData[0],
22024
22103
  schema: formatData[1],
@@ -22029,6 +22108,61 @@ var useTreeInit = (props) => {
22029
22108
  asyncNodeClick,
22030
22109
  deepAutoOpen
22031
22110
  } = useNodeAsync(props, flatData);
22111
+ const onSelected = (event) => {
22112
+ afterSelectEvents.push(event);
22113
+ };
22114
+ const registerNextLoop = (key, event, reset2 = true) => {
22115
+ if (reset2 && nextLoopEvents.has(key)) {
22116
+ nextLoopEvents.delete(key);
22117
+ }
22118
+ nextLoopEvents.set(key, event);
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
+ };
22141
+ const executeNextEvent = () => {
22142
+ Array.from(nextLoopEvents.keys()).forEach((key) => {
22143
+ const target = nextLoopEvents.get(key);
22144
+ if (Array.isArray(target)) {
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
+ }
22158
+ } else {
22159
+ const result = executeFn(target);
22160
+ if (result === "once") {
22161
+ nextLoopEvents.delete(key);
22162
+ }
22163
+ }
22164
+ });
22165
+ };
22032
22166
  watch(() => [props.data], (newData) => {
22033
22167
  var _a2, _b;
22034
22168
  const formatData2 = getFlatdata(props, newData, schemaValues.value);
@@ -22037,16 +22171,24 @@ var useTreeInit = (props) => {
22037
22171
  if (((_a2 = props.async) == null ? void 0 : _a2.callback) && ((_b = props.async) == null ? void 0 : _b.deepAutoOpen) === "every") {
22038
22172
  deepAutoOpen();
22039
22173
  }
22040
- nextTick(() => {
22041
- loopEvents.forEach((event) => {
22042
- Reflect.apply(event, globalThis, []);
22043
- });
22044
- });
22174
+ executeNextEvent();
22045
22175
  }, {
22046
22176
  deep: true
22047
22177
  });
22178
+ if (props.selectable) {
22179
+ watch(() => props.selected, (newData) => {
22180
+ afterSelectWatch.length = 0;
22181
+ afterSelectEvents.forEach((event) => {
22182
+ Reflect.apply(event, globalThis, [newData]);
22183
+ afterSelectWatch.push(() => Reflect.apply(event, globalThis, [newData]));
22184
+ });
22185
+ registerNextLoop("afterSelectWatch", afterSelectWatch);
22186
+ }, {
22187
+ immediate: true
22188
+ });
22189
+ }
22048
22190
  const afterDataUpdate = (callFn) => {
22049
- loopEvents.push(callFn);
22191
+ registerNextLoop("afterDataUpdate", callFn);
22050
22192
  };
22051
22193
  if ((_a = props.async) == null ? void 0 : _a.callback) {
22052
22194
  deepAutoOpen();
@@ -22056,7 +22198,9 @@ var useTreeInit = (props) => {
22056
22198
  schemaValues,
22057
22199
  asyncNodeClick,
22058
22200
  deepAutoOpen,
22059
- afterDataUpdate
22201
+ afterDataUpdate,
22202
+ registerNextLoop,
22203
+ onSelected
22060
22204
  };
22061
22205
  };
22062
22206
  var Component$2 = defineComponent({
@@ -22067,7 +22211,8 @@ var Component$2 = defineComponent({
22067
22211
  const {
22068
22212
  flatData,
22069
22213
  schemaValues,
22070
- afterDataUpdate
22214
+ onSelected,
22215
+ registerNextLoop
22071
22216
  } = useTreeInit(props);
22072
22217
  const {
22073
22218
  setNodeAttr,
@@ -22079,7 +22224,7 @@ var Component$2 = defineComponent({
22079
22224
  isNodeChecked,
22080
22225
  isNodeMatched,
22081
22226
  hasChildNode
22082
- } = useNodeAttribute(flatData);
22227
+ } = useNodeAttribute(flatData, props);
22083
22228
  const {
22084
22229
  searchFn,
22085
22230
  isSearchActive,
@@ -22115,17 +22260,15 @@ var Component$2 = defineComponent({
22115
22260
  setNodeAction,
22116
22261
  setSelect,
22117
22262
  asyncNodeClick
22118
- } = useNodeAction(props, ctx, flatData, renderData, schemaValues);
22263
+ } = useNodeAction(props, ctx, flatData, renderData, schemaValues, {
22264
+ registerNextLoop
22265
+ });
22119
22266
  const setChecked = (item, checked = true) => {
22120
22267
  setNodeAction(resolveNodeItem(item), NODE_ATTRIBUTES.IS_CHECKED, checked);
22121
22268
  };
22122
- if (props.selectable) {
22123
- watch(() => props.selected, (newData) => {
22124
- afterDataUpdate(() => setSelect(newData, true, true));
22125
- }, {
22126
- immediate: true
22127
- });
22128
- }
22269
+ onSelected((newData) => {
22270
+ setSelect(newData, true, true);
22271
+ });
22129
22272
  const getData = () => flatData;
22130
22273
  ctx.expose({
22131
22274
  hanldeTreeNodeClick,