@whitesev/pops 1.5.3 → 1.5.4

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.
Files changed (38) hide show
  1. package/dist/index.amd.js +111 -50
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +111 -50
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +111 -50
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +111 -50
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +111 -50
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +111 -50
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/components/rightClickMenu/indexType.d.ts +1 -1
  14. package/dist/types/src/components/searchSuggestion/indexType.d.ts +1 -1
  15. package/dist/types/src/components/tooltip/indexType.d.ts +1 -1
  16. package/dist/types/src/handler/PopsElementHandler.d.ts +2 -1
  17. package/dist/types/src/handler/PopsHandler.d.ts +5 -0
  18. package/dist/types/src/types/components.d.ts +1 -1
  19. package/package.json +3 -2
  20. package/src/Pops.ts +1 -1
  21. package/src/components/alert/index.ts +6 -3
  22. package/src/components/confirm/index.ts +6 -3
  23. package/src/components/drawer/index.ts +6 -3
  24. package/src/components/folder/index.ts +6 -2
  25. package/src/components/iframe/index.ts +12 -8
  26. package/src/components/loading/index.ts +8 -3
  27. package/src/components/panel/index.ts +8 -3
  28. package/src/components/prompt/index.ts +7 -4
  29. package/src/components/rightClickMenu/index.ts +15 -3
  30. package/src/components/rightClickMenu/indexType.ts +1 -1
  31. package/src/components/searchSuggestion/index.ts +1 -1
  32. package/src/components/searchSuggestion/indexType.ts +1 -1
  33. package/src/components/tooltip/index.ts +3 -1
  34. package/src/components/tooltip/indexType.ts +1 -1
  35. package/src/handler/PopsElementHandler.ts +24 -18
  36. package/src/handler/PopsHandler.ts +27 -4
  37. package/src/types/components.d.ts +1 -1
  38. package/src/utils/PopsUtils.ts +8 -4
package/dist/index.umd.js CHANGED
@@ -1528,17 +1528,21 @@
1528
1528
  else {
1529
1529
  for (const targetKeyName in target) {
1530
1530
  if (targetKeyName in source) {
1531
+ // @ts-ignore
1531
1532
  let targetValue = target[targetKeyName];
1533
+ // @ts-ignore
1532
1534
  let sourceValue = source[targetKeyName];
1533
1535
  if (typeof sourceValue === "object" &&
1534
1536
  sourceValue != null &&
1535
1537
  !UtilsContext.isDOM(sourceValue) &&
1536
1538
  Object.keys(sourceValue).length) {
1537
1539
  /* 源端的值是object类型,且不是元素节点 */
1540
+ // @ts-ignore
1538
1541
  target[targetKeyName] = UtilsContext.assign(targetValue, sourceValue, isAdd);
1539
1542
  continue;
1540
1543
  }
1541
1544
  /* 直接赋值 */
1545
+ // @ts-ignore
1542
1546
  target[targetKeyName] = sourceValue;
1543
1547
  }
1544
1548
  }
@@ -3556,6 +3560,9 @@
3556
3560
  */
3557
3561
  getMaskHTML(guid, zIndex = 101, style = "") {
3558
3562
  zIndex = zIndex - 100;
3563
+ if (style.startsWith(";")) {
3564
+ style = style.replace(";", "");
3565
+ }
3559
3566
  return `<div class="pops-mask" data-guid="${guid}" style="z-index:${zIndex};${style}"></div>`;
3560
3567
  },
3561
3568
  /**
@@ -3565,15 +3572,16 @@
3565
3572
  * @param config
3566
3573
  * @param html
3567
3574
  * @param bottomBtnHTML
3575
+ * @param zIndex
3568
3576
  */
3569
- getAnimHTML(guid, type, config, html = "", bottomBtnHTML = "") {
3577
+ getAnimHTML(guid, type, config, html = "", bottomBtnHTML = "", zIndex) {
3570
3578
  let __config = config;
3571
3579
  let popsAnimStyle = "";
3572
3580
  let popsStyle = "";
3573
3581
  let popsPosition = __config.position || "";
3574
3582
  if (config.zIndex != null) {
3575
- popsAnimStyle += `z-index: ${config.zIndex};`;
3576
- popsStyle += `z-index: ${config.zIndex};`;
3583
+ popsAnimStyle += `z-index: ${zIndex};`;
3584
+ popsStyle += `z-index: ${zIndex};`;
3577
3585
  }
3578
3586
  if (__config.width != null) {
3579
3587
  popsStyle += `width: ${__config.width};`;
@@ -3582,24 +3590,25 @@
3582
3590
  popsStyle += `height: ${__config.height};`;
3583
3591
  }
3584
3592
  let hasBottomBtn = bottomBtnHTML.trim() === "" ? false : true;
3585
- return `<div
3586
- class="pops-anim"
3587
- anim="${__config.animation || ""}"
3588
- style="${popsAnimStyle};"
3589
- data-guid="${guid}">
3593
+ return /*html*/ `
3594
+ <div
3595
+ class="pops-anim"
3596
+ anim="${__config.animation || ""}"
3597
+ style="${popsAnimStyle};"
3598
+ data-guid="${guid}">
3590
3599
  ${config.style != null
3591
3600
  ? `<style tyle="text/css">${config.style}</style>`
3592
3601
  : ""}
3593
- <div
3594
- class="pops ${config.class || ""}"
3595
- data-bottom-btn="${hasBottomBtn}"
3596
- type-value="${type}"
3597
- style="${popsStyle}"
3598
- position="${popsPosition}"
3599
- data-guid="${guid}">
3600
- ${html}
3601
- </div>
3602
- </div>`;
3602
+ <div
3603
+ class="pops ${config.class || ""}"
3604
+ data-bottom-btn="${hasBottomBtn}"
3605
+ type-value="${type}"
3606
+ style="${popsStyle}"
3607
+ position="${popsPosition}"
3608
+ data-guid="${guid}">
3609
+ ${html}
3610
+ </div>
3611
+ </div>`;
3603
3612
  },
3604
3613
  /**
3605
3614
  * 获取顶部按钮层HTML
@@ -4209,6 +4218,18 @@
4209
4218
  capture: true,
4210
4219
  });
4211
4220
  },
4221
+ /**
4222
+ * 把配置的z-index配置转为数字
4223
+ * @param zIndex
4224
+ */
4225
+ handleZIndex(zIndex) {
4226
+ if (typeof zIndex === "function") {
4227
+ return zIndex();
4228
+ }
4229
+ else {
4230
+ return zIndex;
4231
+ }
4232
+ },
4212
4233
  /**
4213
4234
  * 处理config.only
4214
4235
  * @param type 当前弹窗类型
@@ -4234,8 +4255,19 @@
4234
4255
  }
4235
4256
  }
4236
4257
  else {
4237
- const { zIndex: maxZIndex } = PopsInstanceUtils.getPopsMaxZIndex(config.zIndex + 100);
4238
- config.zIndex = maxZIndex;
4258
+ // 对配置进行处理
4259
+ // 选择配置的z-index和已有的pops实例的最大z-index值
4260
+ if (typeof config.zIndex === "function") {
4261
+ let originZIndexFn = config.zIndex;
4262
+ config.zIndex = () => {
4263
+ const { zIndex: maxZIndex } = PopsInstanceUtils.getPopsMaxZIndex(PopsHandler.handleZIndex(originZIndexFn) + 100);
4264
+ return maxZIndex;
4265
+ };
4266
+ }
4267
+ else {
4268
+ const { zIndex: maxZIndex } = PopsInstanceUtils.getPopsMaxZIndex(PopsHandler.handleZIndex(config.zIndex) + 100);
4269
+ config.zIndex = maxZIndex;
4270
+ }
4239
4271
  }
4240
4272
  return config;
4241
4273
  },
@@ -4323,12 +4355,15 @@
4323
4355
  // 设置当前类型
4324
4356
  const PopsType = "alert";
4325
4357
  config = PopsHandler.handleOnly(PopsType, config);
4326
- let maskHTML = PopsElementHandler.getMaskHTML(guid, config.zIndex);
4358
+ // 先把z-index提取出来
4359
+ let zIndex = PopsHandler.handleZIndex(config.zIndex);
4360
+ let maskHTML = PopsElementHandler.getMaskHTML(guid, zIndex);
4327
4361
  let headerBtnHTML = PopsElementHandler.getHeaderBtnHTML(PopsType, config);
4328
4362
  let bottomBtnHTML = PopsElementHandler.getBottomBtnHTML(PopsType, config);
4329
4363
  let { headerStyle, headerPStyle } = PopsElementHandler.getHeaderStyle(PopsType, config);
4330
4364
  let { contentStyle, contentPStyle } = PopsElementHandler.getContentStyle(PopsType, config);
4331
- let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config, `
4365
+ let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config,
4366
+ /*html*/ `
4332
4367
  <div
4333
4368
  class="pops-alert-title"
4334
4369
  style="text-align: ${config.title.position};
@@ -4343,7 +4378,7 @@
4343
4378
  ? config.content.text
4344
4379
  : `<p pops style="${contentPStyle}">${config.content.text}</p>`}
4345
4380
  </div>
4346
- ${bottomBtnHTML}`, bottomBtnHTML);
4381
+ ${bottomBtnHTML}`, bottomBtnHTML, zIndex);
4347
4382
  /**
4348
4383
  * 弹窗的主元素,包括动画层
4349
4384
  */
@@ -4505,12 +4540,15 @@
4505
4540
  // 设置当前类型
4506
4541
  const PopsType = "confirm";
4507
4542
  config = PopsHandler.handleOnly(PopsType, config);
4508
- let maskHTML = PopsElementHandler.getMaskHTML(guid, config.zIndex);
4543
+ // 先把z-index提取出来
4544
+ let zIndex = PopsHandler.handleZIndex(config.zIndex);
4545
+ let maskHTML = PopsElementHandler.getMaskHTML(guid, zIndex);
4509
4546
  let headerBtnHTML = PopsElementHandler.getHeaderBtnHTML(PopsType, config);
4510
4547
  let bottomBtnHTML = PopsElementHandler.getBottomBtnHTML(PopsType, config);
4511
4548
  let { headerStyle, headerPStyle } = PopsElementHandler.getHeaderStyle(PopsType, config);
4512
4549
  let { contentStyle, contentPStyle } = PopsElementHandler.getContentStyle(PopsType, config);
4513
- let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config, `
4550
+ let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config,
4551
+ /*html*/ `
4514
4552
  <div class="pops-confirm-title" style="text-align: ${config.title.position};${headerStyle}">
4515
4553
  ${config.title.html
4516
4554
  ? config.title.text
@@ -4524,7 +4562,7 @@
4524
4562
 
4525
4563
  </div>
4526
4564
  ${bottomBtnHTML}
4527
- `, bottomBtnHTML);
4565
+ `, bottomBtnHTML, zIndex);
4528
4566
  /**
4529
4567
  * 弹窗的主元素,包括动画层
4530
4568
  */
@@ -4693,12 +4731,15 @@
4693
4731
  let guid = popsUtils.getRandomGUID();
4694
4732
  const PopsType = "prompt";
4695
4733
  config = PopsHandler.handleOnly(PopsType, config);
4696
- let maskHTML = PopsElementHandler.getMaskHTML(guid, config.zIndex);
4734
+ // 先把z-index提取出来
4735
+ let zIndex = PopsHandler.handleZIndex(config.zIndex);
4736
+ let maskHTML = PopsElementHandler.getMaskHTML(guid, zIndex);
4697
4737
  let headerBtnHTML = PopsElementHandler.getHeaderBtnHTML(PopsType, config);
4698
4738
  let bottomBtnHTML = PopsElementHandler.getBottomBtnHTML(PopsType, config);
4699
4739
  let { headerStyle, headerPStyle } = PopsElementHandler.getHeaderStyle(PopsType, config);
4700
4740
  let { contentPStyle } = PopsElementHandler.getContentStyle(PopsType, config);
4701
- let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config, `
4741
+ let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config,
4742
+ /*html*/ `
4702
4743
  <div class="pops-prompt-title" style="text-align: ${config.title.position};${headerStyle}">
4703
4744
  ${config.title.html
4704
4745
  ? config.title.text
@@ -4716,8 +4757,8 @@
4716
4757
  (config.content.password ? "password" : "text") +
4717
4758
  '">'}
4718
4759
  </div>
4719
- ${bottomBtnHTML}
4720
- `, bottomBtnHTML);
4760
+ ${bottomBtnHTML}
4761
+ `, bottomBtnHTML, zIndex);
4721
4762
  /**
4722
4763
  * 弹窗的主元素,包括动画层
4723
4764
  */
@@ -4814,9 +4855,12 @@
4814
4855
  let guid = popsUtils.getRandomGUID();
4815
4856
  const PopsType = "loading";
4816
4857
  config = PopsHandler.handleOnly(PopsType, config);
4817
- let maskHTML = PopsElementHandler.getMaskHTML(guid, config.zIndex);
4858
+ // 先把z-index提取出来
4859
+ let zIndex = PopsHandler.handleZIndex(config.zIndex);
4860
+ let maskHTML = PopsElementHandler.getMaskHTML(guid, zIndex);
4818
4861
  let { contentPStyle } = PopsElementHandler.getContentStyle("loading", config);
4819
- let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config, `
4862
+ let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config,
4863
+ /*html*/ `
4820
4864
  <div class="pops-loading-content">
4821
4865
  ${config.addIndexCSS
4822
4866
  ? `
@@ -4831,7 +4875,7 @@
4831
4875
  ${config.style != null ? `<style>${config.style}</style>` : ""}
4832
4876
  <p pops style="${contentPStyle}">${config.content.text}</p>
4833
4877
  </div>
4834
- `, "");
4878
+ `, "", zIndex);
4835
4879
  /**
4836
4880
  * 弹窗的主元素,包括动画层
4837
4881
  */
@@ -4947,12 +4991,15 @@
4947
4991
  let maskExtraStyle = config.animation != null && config.animation != ""
4948
4992
  ? "position:absolute;"
4949
4993
  : "";
4950
- let maskHTML = PopsElementHandler.getMaskHTML(guid, config.zIndex, maskExtraStyle);
4994
+ // 先把z-index提取出来
4995
+ let zIndex = PopsHandler.handleZIndex(config.zIndex);
4996
+ let maskHTML = PopsElementHandler.getMaskHTML(guid, zIndex, maskExtraStyle);
4951
4997
  let headerBtnHTML = PopsElementHandler.getHeaderBtnHTML(PopsType, config);
4952
4998
  let iframeLoadingHTML = '<div class="pops-loading"></div>';
4953
4999
  let titleText = config.title.text.trim() !== "" ? config.title.text : config.url;
4954
5000
  let { headerStyle, headerPStyle } = PopsElementHandler.getHeaderStyle(PopsType, config);
4955
- let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config, `
5001
+ let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config,
5002
+ /*html*/ `
4956
5003
  <div
4957
5004
  class="pops-iframe-title"
4958
5005
  style="text-align: ${config.title.position};${headerStyle}"
@@ -4973,7 +5020,7 @@
4973
5020
  </iframe>
4974
5021
  </div>
4975
5022
  ${config.loading.enable ? iframeLoadingHTML : ""}
4976
- `, "");
5023
+ `, "", zIndex);
4977
5024
  /**
4978
5025
  * 弹窗的主元素,包括动画层
4979
5026
  */
@@ -5205,7 +5252,7 @@
5205
5252
  popsDOMUtils.addClassName(_toolTipElement_, config.className);
5206
5253
  }
5207
5254
  _toolTipElement_.setAttribute("data-guid", guid);
5208
- _toolTipElement_.style.zIndex = config.zIndex.toString();
5255
+ _toolTipElement_.style.zIndex = PopsHandler.handleZIndex(config.zIndex).toString();
5209
5256
  _toolTipElement_.innerHTML = `<div style="text-align: center;">${getContent()}</div>`;
5210
5257
  /* 箭头元素 */
5211
5258
  let _toolTipArrowHTML_ = '<div class="pops-tip-arrow"></div>';
@@ -5522,12 +5569,15 @@
5522
5569
  let guid = popsUtils.getRandomGUID();
5523
5570
  const PopsType = "drawer";
5524
5571
  config = PopsHandler.handleOnly(PopsType, config);
5525
- let maskHTML = PopsElementHandler.getMaskHTML(guid, config.zIndex);
5572
+ // 先把z-index提取出来
5573
+ let zIndex = PopsHandler.handleZIndex(config.zIndex);
5574
+ let maskHTML = PopsElementHandler.getMaskHTML(guid, zIndex);
5526
5575
  let headerBtnHTML = PopsElementHandler.getHeaderBtnHTML(PopsType, config);
5527
5576
  let bottomBtnHTML = PopsElementHandler.getBottomBtnHTML(PopsType, config);
5528
5577
  let { headerStyle, headerPStyle } = PopsElementHandler.getHeaderStyle(PopsType, config);
5529
5578
  let { contentStyle, contentPStyle } = PopsElementHandler.getContentStyle(PopsType, config);
5530
- let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config, `
5579
+ let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config,
5580
+ /*html*/ `
5531
5581
  ${config.title.enable
5532
5582
  ? `
5533
5583
  <div class="pops-${PopsType}-title" style="${headerStyle}">
@@ -5551,7 +5601,7 @@
5551
5601
  </div>
5552
5602
 
5553
5603
  ${bottomBtnHTML}
5554
- `, bottomBtnHTML);
5604
+ `, bottomBtnHTML, zIndex);
5555
5605
  /**
5556
5606
  * 弹窗的主元素,包括动画层
5557
5607
  */
@@ -5909,7 +5959,9 @@
5909
5959
  let guid = popsUtils.getRandomGUID();
5910
5960
  const PopsType = "folder";
5911
5961
  config = PopsHandler.handleOnly(PopsType, config);
5912
- let maskHTML = PopsElementHandler.getMaskHTML(guid, config.zIndex);
5962
+ // 先把z-index提取出来
5963
+ let zIndex = PopsHandler.handleZIndex(config.zIndex);
5964
+ let maskHTML = PopsElementHandler.getMaskHTML(guid, zIndex);
5913
5965
  let headerBtnHTML = PopsElementHandler.getHeaderBtnHTML(PopsType, config);
5914
5966
  let bottomBtnHTML = PopsElementHandler.getBottomBtnHTML(PopsType, config);
5915
5967
  let { headerStyle, headerPStyle } = PopsElementHandler.getHeaderStyle(PopsType, config);
@@ -6020,7 +6072,7 @@
6020
6072
  </div>
6021
6073
  </div>
6022
6074
  ${bottomBtnHTML}
6023
- `, bottomBtnHTML);
6075
+ `, bottomBtnHTML, zIndex);
6024
6076
  /**
6025
6077
  * 弹窗的主元素,包括动画层
6026
6078
  */
@@ -7011,10 +7063,13 @@
7011
7063
  let guid = popsUtils.getRandomGUID();
7012
7064
  const PopsType = "panel";
7013
7065
  config = PopsHandler.handleOnly(PopsType, config);
7014
- let maskHTML = PopsElementHandler.getMaskHTML(guid, config.zIndex);
7066
+ // 先把z-index提取出来
7067
+ let zIndex = PopsHandler.handleZIndex(config.zIndex);
7068
+ let maskHTML = PopsElementHandler.getMaskHTML(guid, zIndex);
7015
7069
  let headerBtnHTML = PopsElementHandler.getHeaderBtnHTML(PopsType, config);
7016
7070
  let { headerStyle, headerPStyle } = PopsElementHandler.getHeaderStyle(PopsType, config);
7017
- let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config, `
7071
+ let animHTML = PopsElementHandler.getAnimHTML(guid, PopsType, config,
7072
+ /*html*/ `
7018
7073
  <div
7019
7074
  class="pops-${PopsType}-title"
7020
7075
  style="text-align: ${config.title.position};
@@ -7032,7 +7087,7 @@
7032
7087
  <ul class="pops-panel-container-header-ul"></ul>
7033
7088
  <ul></ul>
7034
7089
  </section>
7035
- </div>`, "");
7090
+ </div>`, "", zIndex);
7036
7091
  /**
7037
7092
  * 弹窗的主元素,包括动画层
7038
7093
  */
@@ -9123,7 +9178,7 @@
9123
9178
  * @param isChildren 是否是rightClickMenu的某一项的子菜单
9124
9179
  */
9125
9180
  getMenuContainerElement(zIndex, isChildren) {
9126
- let menuElement = popsUtils.parseTextToDOM(`
9181
+ let menuElement = popsUtils.parseTextToDOM(/*html*/ `
9127
9182
  <div class="pops-${PopsType}" ${isChildren ? 'is-children="true"' : ""}>
9128
9183
  <style type="text/css" data-from="pops-${PopsType}">
9129
9184
  .pops-${PopsType} *{
@@ -9211,6 +9266,12 @@
9211
9266
  }
9212
9267
  return menuElement;
9213
9268
  },
9269
+ /**
9270
+ * 动态获取配的z-index
9271
+ */
9272
+ getMenuZIndex() {
9273
+ return PopsHandler.handleZIndex(config.zIndex);
9274
+ },
9214
9275
  /**
9215
9276
  * 获取left、top偏移
9216
9277
  * @param menuElement 菜单元素
@@ -9245,7 +9306,7 @@
9245
9306
  * @param _config_
9246
9307
  */
9247
9308
  showMenu(menuEvent, _config_) {
9248
- let menuElement = this.getMenuContainerElement(config.zIndex, false);
9309
+ let menuElement = this.getMenuContainerElement(this.getMenuZIndex(), false);
9249
9310
  menuElement["__menuData__"] = {
9250
9311
  child: [],
9251
9312
  };
@@ -9283,7 +9344,7 @@
9283
9344
  * @param targetLiElement 父li项元素
9284
9345
  */
9285
9346
  showClildMenu(menuEvent, posInfo, _config_, rootElement, targetLiElement) {
9286
- let menuElement = this.getMenuContainerElement(config.zIndex, true);
9347
+ let menuElement = this.getMenuContainerElement(this.getMenuZIndex(), true);
9287
9348
  menuElement["__menuData__"] = {
9288
9349
  parent: targetLiElement,
9289
9350
  root: rootElement,
@@ -9549,7 +9610,7 @@
9549
9610
  }
9550
9611
  ul.pops-${PopsType}-search-suggestion-hint{
9551
9612
  position: ${config.isAbsolute ? "absolute" : "fixed"};
9552
- z-index: ${config.zIndex};
9613
+ z-index: ${PopsHandler.handleZIndex(config.zIndex)};
9553
9614
  width: 0;
9554
9615
  left: 0;
9555
9616
  max-height: ${config.maxHeight};
@@ -9986,7 +10047,7 @@
9986
10047
  /** 配置 */
9987
10048
  config = {
9988
10049
  /** 版本号 */
9989
- version: "2024.9.9",
10050
+ version: "2024.9.10",
9990
10051
  cssText: {
9991
10052
  /** 主CSS */
9992
10053
  index: indexCSS,