bkui-vue 0.0.1-beta.72 → 0.0.1-beta.73

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
@@ -22018,7 +22018,9 @@ var useTreeInit = (props) => {
22018
22018
  return [outputData, schema];
22019
22019
  };
22020
22020
  const formatData = getFlatdata(props);
22021
- const loopEvents = [];
22021
+ const nextLoopEvents = /* @__PURE__ */ new Map();
22022
+ const afterSelectEvents = [];
22023
+ const afterSelectWatch = [];
22022
22024
  const flatData = reactive({
22023
22025
  data: formatData[0],
22024
22026
  schema: formatData[1],
@@ -22029,6 +22031,25 @@ var useTreeInit = (props) => {
22029
22031
  asyncNodeClick,
22030
22032
  deepAutoOpen
22031
22033
  } = useNodeAsync(props, flatData);
22034
+ const onSelected = (event) => {
22035
+ afterSelectEvents.push(event);
22036
+ };
22037
+ const registerNextLoop = (key, event, reset2 = true) => {
22038
+ if (reset2 && nextLoopEvents.has(key)) {
22039
+ nextLoopEvents.delete(key);
22040
+ }
22041
+ nextLoopEvents.set(key, event);
22042
+ };
22043
+ const executeNextEvent = () => {
22044
+ Array.from(nextLoopEvents.keys()).forEach((key) => {
22045
+ const target = nextLoopEvents.get(key);
22046
+ if (Array.isArray(target)) {
22047
+ target.forEach((event) => Reflect.apply(event, globalThis, []));
22048
+ } else {
22049
+ Reflect.apply(target, globalThis, []);
22050
+ }
22051
+ });
22052
+ };
22032
22053
  watch(() => [props.data], (newData) => {
22033
22054
  var _a2, _b;
22034
22055
  const formatData2 = getFlatdata(props, newData, schemaValues.value);
@@ -22037,16 +22058,24 @@ var useTreeInit = (props) => {
22037
22058
  if (((_a2 = props.async) == null ? void 0 : _a2.callback) && ((_b = props.async) == null ? void 0 : _b.deepAutoOpen) === "every") {
22038
22059
  deepAutoOpen();
22039
22060
  }
22040
- nextTick(() => {
22041
- loopEvents.forEach((event) => {
22042
- Reflect.apply(event, globalThis, []);
22043
- });
22044
- });
22061
+ executeNextEvent();
22045
22062
  }, {
22046
22063
  deep: true
22047
22064
  });
22065
+ if (props.selectable) {
22066
+ watch(() => props.selected, (newData) => {
22067
+ afterSelectWatch.length = 0;
22068
+ afterSelectEvents.forEach((event) => {
22069
+ Reflect.apply(event, globalThis, [newData]);
22070
+ afterSelectWatch.push(() => Reflect.apply(event, globalThis, [newData]));
22071
+ });
22072
+ registerNextLoop("afterSelectWatch", afterSelectWatch);
22073
+ }, {
22074
+ immediate: true
22075
+ });
22076
+ }
22048
22077
  const afterDataUpdate = (callFn) => {
22049
- loopEvents.push(callFn);
22078
+ registerNextLoop("afterDataUpdate", callFn);
22050
22079
  };
22051
22080
  if ((_a = props.async) == null ? void 0 : _a.callback) {
22052
22081
  deepAutoOpen();
@@ -22056,7 +22085,8 @@ var useTreeInit = (props) => {
22056
22085
  schemaValues,
22057
22086
  asyncNodeClick,
22058
22087
  deepAutoOpen,
22059
- afterDataUpdate
22088
+ afterDataUpdate,
22089
+ onSelected
22060
22090
  };
22061
22091
  };
22062
22092
  var Component$2 = defineComponent({
@@ -22067,7 +22097,7 @@ var Component$2 = defineComponent({
22067
22097
  const {
22068
22098
  flatData,
22069
22099
  schemaValues,
22070
- afterDataUpdate
22100
+ onSelected
22071
22101
  } = useTreeInit(props);
22072
22102
  const {
22073
22103
  setNodeAttr,
@@ -22119,13 +22149,9 @@ var Component$2 = defineComponent({
22119
22149
  const setChecked = (item, checked = true) => {
22120
22150
  setNodeAction(resolveNodeItem(item), NODE_ATTRIBUTES.IS_CHECKED, checked);
22121
22151
  };
22122
- if (props.selectable) {
22123
- watch(() => props.selected, (newData) => {
22124
- afterDataUpdate(() => setSelect(newData, true, true));
22125
- }, {
22126
- immediate: true
22127
- });
22128
- }
22152
+ onSelected((newData) => {
22153
+ setSelect(newData, true, true);
22154
+ });
22129
22155
  const getData = () => flatData;
22130
22156
  ctx.expose({
22131
22157
  hanldeTreeNodeClick,