bkui-vue 0.0.2-beta.17 → 0.0.2-beta.18

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.
@@ -5855,6 +5855,21 @@ class BKZIndexManager {
5855
5855
  }
5856
5856
  const bkZIndexManager = new BKZIndexManager();
5857
5857
  `__bk_mask_${random(16)}`;
5858
+ const MaskEventMap = /* @__PURE__ */ new WeakMap();
5859
+ const getMaskEvent = (mask) => {
5860
+ if (MaskEventMap.has(mask)) {
5861
+ return MaskEventMap.get(mask);
5862
+ }
5863
+ return [];
5864
+ };
5865
+ const setMaskEvent = (mask, event, args, content, instanceId) => {
5866
+ const maskEvent = getMaskEvent(mask);
5867
+ if (maskEvent.some((evet) => evet.instanceId === instanceId)) {
5868
+ return;
5869
+ }
5870
+ maskEvent.push({ event, args, content, instanceId });
5871
+ MaskEventMap.set(mask, maskEvent);
5872
+ };
5858
5873
  class MaskQueueMaker {
5859
5874
  constructor() {
5860
5875
  __publicField(this, "timer", null);
@@ -5938,26 +5953,30 @@ class BkMaskManager {
5938
5953
  display: "none",
5939
5954
  "background-color": "rgba(0,0,0,.6)"
5940
5955
  });
5941
- __publicField(this, "onClick");
5942
5956
  // 用于判定是否已经初始化过当前实例
5943
5957
  __publicField(this, "isInit", false);
5944
5958
  __publicField(this, "maskAttrTag", "auto");
5945
- __publicField(this, "popInstance");
5946
- const { multiInstance = false, maskAttrTag = "auto", parentNode = document.body, maskStyle = {}, onClick = null, popInstance = null } = config || {};
5959
+ const {
5960
+ multiInstance = false,
5961
+ maskAttrTag = "auto",
5962
+ parentNode = document.body,
5963
+ maskStyle = {}
5964
+ } = config || {};
5947
5965
  this.parentNode = parentNode || document;
5948
5966
  this.maskAttrTag = maskAttrTag;
5949
- this.onClick = onClick;
5950
5967
  this.activeInstance = void 0;
5951
5968
  this.multiInstance = multiInstance;
5952
- this.popInstance = popInstance;
5953
5969
  this.uniqueMaskAttrTag = this.getMaskAttrTag(maskAttrTag);
5954
5970
  bkMaskMaker.appendMaker(() => {
5955
5971
  this.initInstance(maskStyle);
5956
5972
  });
5957
5973
  }
5958
5974
  setOption(option) {
5959
- const { parentNode = document.body, maskStyle = {}, onClick = null, maskAttrTag = this.maskAttrTag } = option || {};
5960
- this.onClick = onClick;
5975
+ const {
5976
+ parentNode = document.body,
5977
+ maskStyle = {},
5978
+ maskAttrTag = this.maskAttrTag
5979
+ } = option || {};
5961
5980
  this.parentNode = parentNode || document;
5962
5981
  this.setMaskStyle(Object.assign({}, this.maskStyle, maskStyle));
5963
5982
  this.uniqueMaskAttrTag = this.getMaskAttrTag(maskAttrTag);
@@ -5970,7 +5989,7 @@ class BkMaskManager {
5970
5989
  * @param appendStyle 追加样式
5971
5990
  * @param transfer 是否显示将内容加入遮罩下
5972
5991
  */
5973
- show(content, zIndex, showMask = true, appendStyle = {}, uuid2 = null, transfer2 = false) {
5992
+ show(content, zIndex, showMask = true, appendStyle = {}, uuid2 = null, transfer2 = false, onMaskClick, instanceId) {
5974
5993
  const uid = uuid2 ?? random(16);
5975
5994
  const localZIndex = /-?\d+/.test(`${zIndex}`) ? zIndex : bkZIndexManager.getModalNextIndex();
5976
5995
  let style2 = Object.assign({}, this.maskStyle, appendStyle || {});
@@ -5994,7 +6013,9 @@ class BkMaskManager {
5994
6013
  "pointer-events": "all"
5995
6014
  });
5996
6015
  this.initInstance(style2);
5997
- this.catchClickEvent();
6016
+ if (onMaskClick) {
6017
+ this.catchClickEvent(content, onMaskClick, instanceId);
6018
+ }
5998
6019
  this.setMaskStyle(style2);
5999
6020
  bkMaskMaker.pushMaskStyle(this.parentNode, { ...style2 });
6000
6021
  this.backupMask.style.setProperty("z-index", `${localZIndex - 1}`);
@@ -6051,11 +6072,14 @@ class BkMaskManager {
6051
6072
  }
6052
6073
  }
6053
6074
  backupContentElement(content) {
6054
- content && this.backupMask.append(content);
6075
+ var _a;
6076
+ content && ((_a = this.backupMask) == null ? void 0 : _a.append(content));
6055
6077
  }
6056
6078
  getActiveContentInstance() {
6057
6079
  return this.activeInstance;
6058
6080
  }
6081
+ removeClickEvent() {
6082
+ }
6059
6083
  initInstance(maskStyle) {
6060
6084
  if (!this.isInit) {
6061
6085
  this.isInit = true;
@@ -6078,26 +6102,31 @@ class BkMaskManager {
6078
6102
  if (!div) {
6079
6103
  isExist = false;
6080
6104
  div = this.createMask();
6105
+ div.addEventListener(
6106
+ "click",
6107
+ (e3) => this.handleMaskClick(e3),
6108
+ true
6109
+ );
6081
6110
  }
6082
6111
  return {
6083
6112
  instance: div,
6084
6113
  isExist
6085
6114
  };
6086
6115
  }
6087
- catchClickEvent() {
6116
+ catchClickEvent(content, onMaskClick, instanceId) {
6088
6117
  if (this.mask) {
6089
- this.mask.addEventListener("click", (e3) => this.handleMaskClick(e3), true);
6090
- }
6091
- }
6092
- removeClickEvent() {
6093
- if (this.mask) {
6094
- this.mask.removeEventListener("click", this.handleMaskClick);
6118
+ setMaskEvent(this.mask, onMaskClick, [], content, instanceId);
6095
6119
  }
6096
6120
  }
6097
6121
  handleMaskClick(e3) {
6098
- if (e3.target === this.mask) {
6099
- if (typeof this.onClick === "function") {
6100
- Reflect.apply(this.onClick, this.popInstance || this, [e3]);
6122
+ if (e3.target !== this.mask) {
6123
+ return;
6124
+ }
6125
+ const events = getMaskEvent(this.mask);
6126
+ if (events.length) {
6127
+ const { event } = events.pop();
6128
+ if (typeof event === "function") {
6129
+ event(e3);
6101
6130
  }
6102
6131
  }
6103
6132
  }
@@ -6151,8 +6180,10 @@ class BKPopIndexManager {
6151
6180
  __publicField(this, "clickFn");
6152
6181
  __publicField(this, "bKMaskManagerInstance");
6153
6182
  __publicField(this, "transfer");
6183
+ __publicField(this, "uniqId");
6154
6184
  this.clickFn = void 0;
6155
6185
  this.uuidAttrName = "data-bk-pop-uuid";
6186
+ this.uniqId = random(16);
6156
6187
  this.transfer = this.getParentNode(options == null ? void 0 : options.transfer);
6157
6188
  this.bKMaskManagerInstance = new BkMaskManager({
6158
6189
  parentNode: this.getParentNode(options == null ? void 0 : options.transfer),
@@ -6192,7 +6223,7 @@ class BKPopIndexManager {
6192
6223
  * @param transfer 是否显示在body内(即是否显示在div#app内,默认为false)
6193
6224
  * @returns
6194
6225
  */
6195
- show(content, showMask = true, appendStyle = {}, transfer2 = false, zindex = void 0) {
6226
+ show(content, showMask = true, appendStyle = {}, transfer2 = false, zindex = void 0, onMaskClick) {
6196
6227
  if (!content) {
6197
6228
  console.warn("pop show error: content is null or undefined");
6198
6229
  return;
@@ -6204,7 +6235,16 @@ class BKPopIndexManager {
6204
6235
  showMask && this.bKMaskManagerInstance.backupContentElement(this.popInstanceList.slice(-1)[0].content);
6205
6236
  }
6206
6237
  this.popInstanceList.push({ uuid: uuid2, zIndex, content, showMask, appendStyle });
6207
- this.bKMaskManagerInstance.show(content, zIndex, showMask, appendStyle, uuid2, transfer2);
6238
+ this.bKMaskManagerInstance.show(
6239
+ content,
6240
+ zIndex,
6241
+ showMask,
6242
+ appendStyle,
6243
+ uuid2,
6244
+ transfer2,
6245
+ onMaskClick,
6246
+ this.uniqId
6247
+ );
6208
6248
  }
6209
6249
  /**
6210
6250
  * 销毁指定实例
@@ -6229,7 +6269,13 @@ class BKPopIndexManager {
6229
6269
  if (this.popInstanceList.length) {
6230
6270
  const activeItem = this.popInstanceList.slice(-1)[0];
6231
6271
  const { zIndex, content, showMask, appendStyle, uuid: uuid2 } = activeItem;
6232
- this.bKMaskManagerInstance.show(content, zIndex, showMask, appendStyle, uuid2);
6272
+ this.bKMaskManagerInstance.show(
6273
+ content,
6274
+ zIndex,
6275
+ showMask,
6276
+ appendStyle,
6277
+ uuid2
6278
+ );
6233
6279
  } else {
6234
6280
  this.bKMaskManagerInstance.hide();
6235
6281
  }
@@ -6257,6 +6303,7 @@ class BKPopIndexManager {
6257
6303
  } else {
6258
6304
  content == null ? void 0 : content.remove();
6259
6305
  }
6306
+ this.bKMaskManagerInstance.removeClickEvent();
6260
6307
  }
6261
6308
  onMaskClickFn(e3) {
6262
6309
  if (this.clickFn) {
@@ -15495,14 +15542,13 @@ const Component$t = /* @__PURE__ */ defineComponent({
15495
15542
  var _a, _b;
15496
15543
  if (val) {
15497
15544
  this.$nextTick(() => {
15498
- this.bkPopIndexManager.onMaskClick((_e) => {
15499
- this.handleClickOutSide();
15500
- }, this.$el);
15501
15545
  const hideMaskStyle = {
15502
15546
  "background-color": "rgba(0,0,0,0)"
15503
15547
  };
15504
15548
  const appendStyle = this.showMask ? {} : hideMaskStyle;
15505
- this.bkPopIndexManager.show(this.$el, this.showMask, appendStyle, !!this.transfer, this.zIndex);
15549
+ this.bkPopIndexManager.show(this.$el, this.showMask, appendStyle, !!this.transfer, this.zIndex, (_e) => {
15550
+ this.handleClickOutSide();
15551
+ });
15506
15552
  this.$emit("shown");
15507
15553
  });
15508
15554
  } else {
@@ -18644,6 +18690,7 @@ const Component$j = /* @__PURE__ */ defineComponent({
18644
18690
  emit
18645
18691
  }) {
18646
18692
  const handleClose = async () => {
18693
+ console.log("slider handleClose");
18647
18694
  let shouldClose = true;
18648
18695
  if (typeof props2.beforeClose === "function") {
18649
18696
  shouldClose = await props2.beforeClose();