bkui-vue 0.0.1-beta.450 → 0.0.1-beta.452

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
@@ -5811,12 +5811,13 @@ class BkMaskManager {
5811
5811
  };
5812
5812
  this.isInit = false;
5813
5813
  this.maskAttrTag = "auto";
5814
- const { multiInstance = false, maskAttrTag = "auto", parentNode = document.body, maskStyle = {}, onClick = null } = config || {};
5814
+ const { multiInstance = false, maskAttrTag = "auto", parentNode = document.body, maskStyle = {}, onClick = null, popInstance = null } = config || {};
5815
5815
  this.parentNode = parentNode || document;
5816
5816
  this.maskAttrTag = maskAttrTag;
5817
5817
  this.onClick = onClick;
5818
5818
  this.activeInstance = void 0;
5819
5819
  this.multiInstance = multiInstance;
5820
+ this.popInstance = popInstance;
5820
5821
  this.uniqueMaskAttrTag = this.getMaskAttrTag(maskAttrTag);
5821
5822
  bkMaskMaker.appendMaker(() => {
5822
5823
  this.initInstance(maskStyle);
@@ -5853,6 +5854,7 @@ class BkMaskManager {
5853
5854
  "pointer-events": "all"
5854
5855
  });
5855
5856
  this.initInstance(style2);
5857
+ this.catchClickEvent();
5856
5858
  this.setMaskStyle(style2);
5857
5859
  bkMaskMaker.pushMaskStyle(this.parentNode, __spreadValues({}, style2));
5858
5860
  this.backupMask.style.setProperty("z-index", `${localZIndex - 1}`);
@@ -5874,6 +5876,7 @@ class BkMaskManager {
5874
5876
  content == null ? void 0 : content.remove();
5875
5877
  (_a = this.activeInstance) == null ? void 0 : _a.remove();
5876
5878
  }
5879
+ this.removeClickEvent();
5877
5880
  this.activeInstance = void 0;
5878
5881
  this.popIndexStore(uid);
5879
5882
  const maskList = bkMaskMaker.getMaskStyles(this.parentNode);
@@ -5928,19 +5931,29 @@ class BkMaskManager {
5928
5931
  if (!div) {
5929
5932
  isExist = false;
5930
5933
  div = this.createMask();
5931
- div.addEventListener("click", (e) => {
5932
- if (e.target === div) {
5933
- if (typeof this.onClick === "function") {
5934
- Reflect.apply(this.onClick, this, [e]);
5935
- }
5936
- }
5937
- }, true);
5938
5934
  }
5939
5935
  return {
5940
5936
  instance: div,
5941
5937
  isExist
5942
5938
  };
5943
5939
  }
5940
+ catchClickEvent() {
5941
+ if (this.mask) {
5942
+ this.mask.addEventListener("click", (e) => this.handleMaskClick(e), true);
5943
+ }
5944
+ }
5945
+ removeClickEvent() {
5946
+ if (this.mask) {
5947
+ this.mask.removeEventListener("click", this.handleMaskClick);
5948
+ }
5949
+ }
5950
+ handleMaskClick(e) {
5951
+ if (e.target === this.mask) {
5952
+ if (typeof this.onClick === "function") {
5953
+ Reflect.apply(this.onClick, this.popInstance || this, [e]);
5954
+ }
5955
+ }
5956
+ }
5944
5957
  getBackupMask() {
5945
5958
  const attrName = "data-bk-backup-uid";
5946
5959
  let div = this.parentNode.querySelector(`[${attrName}]`);
@@ -5976,21 +5989,13 @@ class BkMaskManager {
5976
5989
  new BkMaskManager({});
5977
5990
  class BKPopIndexManager {
5978
5991
  constructor(options) {
5979
- this.getActiveClickFnIndex = (match2) => {
5980
- const filterFn = (target) => typeof match2 === "string" ? target.getAttribute(this.uuidAttrName) === match2 : target === match2;
5981
- return this.clickFn.findIndex(({ target }) => filterFn(target));
5982
- };
5983
- this.getActiveClickFn = (match2) => {
5984
- var _a;
5985
- return (_a = this.clickFn[this.getActiveClickFnIndex(match2)]) == null ? void 0 : _a.fn;
5986
- };
5987
5992
  this.popInstanceList = [];
5988
- this.clickFn = [];
5993
+ this.clickFn = void 0;
5989
5994
  this.uuidAttrName = "data-bk-pop-uuid";
5990
- this.activePopId = null;
5991
5995
  this.bKMaskManagerInstance = new BkMaskManager({
5992
5996
  parentNode: this.getParentNode(options == null ? void 0 : options.transfer),
5993
- onClick: this.onMaskClickFn.bind(this)
5997
+ popInstance: this,
5998
+ onClick: this.onMaskClickFn
5994
5999
  });
5995
6000
  }
5996
6001
  getParentNode(transfer2) {
@@ -6006,7 +6011,7 @@ class BKPopIndexManager {
6006
6011
  return document.body;
6007
6012
  }
6008
6013
  onMaskClick(callFn, target) {
6009
- this.clickFn.push({ fn: callFn, target });
6014
+ this.clickFn = { fn: callFn, target };
6010
6015
  }
6011
6016
  show(content, showMask = true, appendStyle = {}, transfer2 = false, zindex = void 0) {
6012
6017
  if (!content) {
@@ -6019,14 +6024,9 @@ class BKPopIndexManager {
6019
6024
  this.popInstanceList.push({ uuid: uuid2, zIndex, content, showMask, appendStyle });
6020
6025
  showMask && this.bKMaskManagerInstance.backupActiveInstance();
6021
6026
  this.bKMaskManagerInstance.show(content, zIndex, showMask, appendStyle, uuid2, transfer2);
6022
- this.activePopId = uuid2;
6023
6027
  }
6024
6028
  destroy(content, transfer2 = false) {
6025
- var _a;
6026
- const index2 = this.getActiveClickFnIndex(content);
6027
- if (index2 >= 0) {
6028
- (_a = this.clickFn) == null ? void 0 : _a.splice(index2, 1);
6029
- }
6029
+ this.clickFn = void 0;
6030
6030
  this.hide(content, transfer2);
6031
6031
  }
6032
6032
  popHide(removeLastContent = true) {
@@ -6035,17 +6035,13 @@ class BKPopIndexManager {
6035
6035
  const lastItem = this.popInstanceList.pop();
6036
6036
  this.bKMaskManagerInstance.popIndexStore(lastItem.uuid);
6037
6037
  lastItem.remove();
6038
- this.activePopId = null;
6039
6038
  }
6040
6039
  if (this.popInstanceList.length) {
6041
6040
  const activeItem = this.popInstanceList.slice(-1)[0];
6042
6041
  const { zIndex, content, showMask, appendStyle, uuid: uuid2 } = activeItem;
6043
6042
  this.bKMaskManagerInstance.show(content, zIndex, showMask, appendStyle, uuid2);
6044
- this.activePopId = uuid2;
6045
6043
  } else {
6046
6044
  this.bKMaskManagerInstance.hide();
6047
- this.activePopId = null;
6048
- this.clickFn.length = 0;
6049
6045
  }
6050
6046
  }
6051
6047
  }
@@ -6060,8 +6056,6 @@ class BKPopIndexManager {
6060
6056
  this.bKMaskManagerInstance.popIndexStore(uuid2);
6061
6057
  if (!this.popInstanceList.length) {
6062
6058
  this.bKMaskManagerInstance.hide(transfer2);
6063
- this.activePopId = null;
6064
- this.clickFn.length = 0;
6065
6059
  } else {
6066
6060
  this.popHide(false);
6067
6061
  }
@@ -6071,7 +6065,7 @@ class BKPopIndexManager {
6071
6065
  }
6072
6066
  }
6073
6067
  onMaskClickFn(e) {
6074
- const fn2 = this.getActiveClickFn(this.activePopId);
6068
+ const { fn: fn2 } = this.clickFn;
6075
6069
  if (fn2) {
6076
6070
  Reflect.apply(fn2, this, [e]);
6077
6071
  }
@@ -11157,7 +11151,7 @@ var Component$u = defineComponent({
11157
11151
  return {
11158
11152
  visible: false,
11159
11153
  closeTimer: null,
11160
- bkPopIndexManager: new BKPopIndexManager(__spreadValues({}, this.$props))
11154
+ bkPopIndexManager: null
11161
11155
  };
11162
11156
  },
11163
11157
  computed: {
@@ -11224,6 +11218,13 @@ var Component$u = defineComponent({
11224
11218
  },
11225
11219
  created() {
11226
11220
  },
11221
+ mounted() {
11222
+ var _a;
11223
+ const popConfig = __spreadValues(__spreadValues({}, this.$props), {
11224
+ transfer: this.transfer === "parent" ? (_a = this.$el) == null ? void 0 : _a.parentElement : this.transfer
11225
+ });
11226
+ this.bkPopIndexManager = new BKPopIndexManager(popConfig);
11227
+ },
11227
11228
  beforeUnmount() {
11228
11229
  var _a, _b;
11229
11230
  if (this.visible) {