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