@whitesev/pops 1.0.1 → 1.2.0

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.
@@ -1,6 +1,8 @@
1
1
  var pops = (function () {
2
2
  'use strict';
3
3
 
4
+ const SymbolEvents = Symbol("events_" + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1));
5
+
4
6
  const PopsCoreDefaultEnv = {
5
7
  document: document,
6
8
  window: window,
@@ -39,8 +41,6 @@ var pops = (function () {
39
41
  },
40
42
  };
41
43
 
42
- const SymbolEvents = Symbol("events_" + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1));
43
-
44
44
  // @ts-nocheck
45
45
 
46
46
  const AnyTouch = function () {
@@ -1492,6 +1492,12 @@ var pops = (function () {
1492
1492
  }
1493
1493
  assign(target = {}, source = {}, isAdd = false) {
1494
1494
  let UtilsContext = this;
1495
+ if (source == null) {
1496
+ return target;
1497
+ }
1498
+ if (target == null) {
1499
+ target = {};
1500
+ }
1495
1501
  if (Array.isArray(source)) {
1496
1502
  let canTraverse = source.filter((item) => {
1497
1503
  return typeof item === "object";
@@ -1505,8 +1511,9 @@ var pops = (function () {
1505
1511
  const targetKeyName = sourceKeyName;
1506
1512
  let targetValue = target[targetKeyName];
1507
1513
  let sourceValue = source[sourceKeyName];
1508
- if (sourceKeyName in target &&
1509
- typeof sourceValue === "object" &&
1514
+ if (typeof sourceValue === "object" &&
1515
+ sourceValue != null &&
1516
+ sourceKeyName in target &&
1510
1517
  !UtilsContext.isDOM(sourceValue)) {
1511
1518
  /* 源端的值是object类型,且不是元素节点 */
1512
1519
  target[sourceKeyName] = UtilsContext.assign(targetValue, sourceValue, isAdd);
@@ -1521,6 +1528,7 @@ var pops = (function () {
1521
1528
  let targetValue = target[targetKeyName];
1522
1529
  let sourceValue = source[targetKeyName];
1523
1530
  if (typeof sourceValue === "object" &&
1531
+ sourceValue != null &&
1524
1532
  !UtilsContext.isDOM(sourceValue) &&
1525
1533
  Object.keys(sourceValue).length) {
1526
1534
  /* 源端的值是object类型,且不是元素节点 */
@@ -2292,7 +2300,6 @@ var pops = (function () {
2292
2300
  }
2293
2301
  }
2294
2302
  }
2295
-
2296
2303
  class PopsDOMUtils extends PopsDOMUtilsEvent {
2297
2304
  /** 获取 animationend 在各个浏览器的兼容名 */
2298
2305
  getAnimationEndNameList() {
@@ -2942,7 +2949,7 @@ var pops = (function () {
2942
2949
  }
2943
2950
  const popsDOMUtils = new PopsDOMUtils();
2944
2951
 
2945
- const PopsUIUtils = {
2952
+ const PopsInstanceUtils = {
2946
2953
  /**
2947
2954
  * 获取所有弹窗中的最大的z-index
2948
2955
  * @param defaultValue
@@ -2981,10 +2988,9 @@ var pops = (function () {
2981
2988
  * 删除配置中对应的对象
2982
2989
  * @param moreLayerConfigList 配置实例列表
2983
2990
  * @param guid 唯一标识
2984
- * @param removeAll 是否全部删除
2991
+ * @param isAll 是否全部删除
2985
2992
  */
2986
- configRemove(moreLayerConfigList, guid, removeAll = false) {
2987
- /** @param item */
2993
+ removeInstance(moreLayerConfigList, guid, isAll = false) {
2988
2994
  function removeItem(item) {
2989
2995
  item?.animElement?.remove();
2990
2996
  item?.popsElement?.remove();
@@ -2995,7 +3001,7 @@ var pops = (function () {
2995
3001
  moreLayerConfigList.forEach((layerConfigList) => {
2996
3002
  // layer[]
2997
3003
  layerConfigList.forEach((layerConfigItem, index) => {
2998
- if (removeAll || layerConfigItem["guid"] === guid) {
3004
+ if (isAll || layerConfigItem["guid"] === guid) {
2999
3005
  if (pops.config.animation.hasOwnProperty(layerConfigItem.animElement.getAttribute("anim"))) {
3000
3006
  layerConfigItem.animElement.style.width = "100%";
3001
3007
  layerConfigItem.animElement.style.height = "100%";
@@ -3162,7 +3168,7 @@ var pops = (function () {
3162
3168
  return;
3163
3169
  }
3164
3170
  popsDOMUtils.off(popsElement, popsDOMUtils.getTransitionEndNameList(), void 0, closeCallBack);
3165
- PopsUIUtils.configRemove([layerConfigList], guid);
3171
+ PopsInstanceUtils.removeInstance([layerConfigList], guid);
3166
3172
  }
3167
3173
  /* 监听过渡结束 */
3168
3174
  popsDOMUtils.on(popsElement, popsDOMUtils.getTransitionEndNameList(), closeCallBack);
@@ -3193,7 +3199,7 @@ var pops = (function () {
3193
3199
  }, drawerConfig.closeDelay);
3194
3200
  }
3195
3201
  else {
3196
- PopsUIUtils.configRemove([layerConfigList], guid);
3202
+ PopsInstanceUtils.removeInstance([layerConfigList], guid);
3197
3203
  }
3198
3204
  },
3199
3205
  /**
@@ -3881,11 +3887,11 @@ var pops = (function () {
3881
3887
  function originalRun() {
3882
3888
  if (details.config.mask.clickEvent.toClose) {
3883
3889
  /* 关闭 */
3884
- PopsUIUtils.close(details.type, targetLayer, details.guid, details.config, details.animElement);
3890
+ PopsInstanceUtils.close(details.type, targetLayer, details.guid, details.config, details.animElement);
3885
3891
  }
3886
3892
  else if (details.config.mask.clickEvent.toHide) {
3887
3893
  /* 隐藏 */
3888
- PopsUIUtils.hide(details.type, targetLayer, details.guid, details.config, details.animElement, result.maskElement);
3894
+ PopsInstanceUtils.hide(details.type, targetLayer, details.guid, details.config, details.animElement, result.maskElement);
3889
3895
  }
3890
3896
  }
3891
3897
  if (typeof details.config.mask.clickCallBack === "function") {
@@ -4057,13 +4063,13 @@ var pops = (function () {
4057
4063
  mode: mode,
4058
4064
  guid: guid,
4059
4065
  close() {
4060
- PopsUIUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
4066
+ PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
4061
4067
  },
4062
4068
  hide() {
4063
- PopsUIUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4069
+ PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4064
4070
  },
4065
4071
  show() {
4066
- PopsUIUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4072
+ PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4067
4073
  },
4068
4074
  };
4069
4075
  },
@@ -4085,13 +4091,13 @@ var pops = (function () {
4085
4091
  mode: mode,
4086
4092
  guid: guid,
4087
4093
  close() {
4088
- PopsUIUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
4094
+ PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
4089
4095
  },
4090
4096
  hide() {
4091
- PopsUIUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4097
+ PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4092
4098
  },
4093
4099
  show() {
4094
- PopsUIUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4100
+ PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4095
4101
  },
4096
4102
  };
4097
4103
  },
@@ -4191,10 +4197,10 @@ var pops = (function () {
4191
4197
  if (type === "loading" ||
4192
4198
  type === "tooltip" ||
4193
4199
  type === "rightClickMenu") {
4194
- PopsUIUtils.configRemove([pops.config.layer[type]], "", true);
4200
+ PopsInstanceUtils.removeInstance([pops.config.layer[type]], "", true);
4195
4201
  }
4196
4202
  else {
4197
- PopsUIUtils.configRemove([
4203
+ PopsInstanceUtils.removeInstance([
4198
4204
  pops.config.layer.alert,
4199
4205
  pops.config.layer.confirm,
4200
4206
  pops.config.layer.prompt,
@@ -4207,7 +4213,7 @@ var pops = (function () {
4207
4213
  }
4208
4214
  else {
4209
4215
  config.zIndex =
4210
- PopsUIUtils.getPopsMaxZIndex(config.zIndex)["zIndex"] * 2;
4216
+ PopsInstanceUtils.getPopsMaxZIndex(config.zIndex)["zIndex"] * 2;
4211
4217
  }
4212
4218
  return config;
4213
4219
  },
@@ -4364,7 +4370,7 @@ var pops = (function () {
4364
4370
  });
4365
4371
  /* 拖拽 */
4366
4372
  if (config.drag) {
4367
- PopsUIUtils.drag($pops, {
4373
+ PopsInstanceUtils.drag($pops, {
4368
4374
  dragElement: $title,
4369
4375
  limit: config.dragLimit,
4370
4376
  extraDistance: config.dragExtraDistance,
@@ -4546,7 +4552,7 @@ var pops = (function () {
4546
4552
  });
4547
4553
  /* 拖拽 */
4548
4554
  if (config.drag) {
4549
- PopsUIUtils.drag($pops, {
4555
+ PopsInstanceUtils.drag($pops, {
4550
4556
  dragElement: $title,
4551
4557
  limit: config.dragLimit,
4552
4558
  extraDistance: config.dragExtraDistance,
@@ -4741,7 +4747,7 @@ var pops = (function () {
4741
4747
  });
4742
4748
  /* 拖拽 */
4743
4749
  if (config.drag) {
4744
- PopsUIUtils.drag($pops, {
4750
+ PopsInstanceUtils.drag($pops, {
4745
4751
  dragElement: $title,
4746
4752
  limit: config.dragLimit,
4747
4753
  extraDistance: config.dragExtraDistance,
@@ -5003,7 +5009,7 @@ var pops = (function () {
5003
5009
  }
5004
5010
  /* 拖拽 */
5005
5011
  if (config.drag) {
5006
- PopsUIUtils.drag($pops, {
5012
+ PopsInstanceUtils.drag($pops, {
5007
5013
  dragElement: $title,
5008
5014
  limit: config.dragLimit,
5009
5015
  extraDistance: config.dragExtraDistance,
@@ -5069,7 +5075,7 @@ var pops = (function () {
5069
5075
  allMinElementList.push(item.popsElement);
5070
5076
  }
5071
5077
  });
5072
- allMinElementList.sort(PopsUIUtils.sortElementListByProperty((obj) => {
5078
+ allMinElementList.sort(PopsInstanceUtils.sortElementListByProperty((obj) => {
5073
5079
  return parseInt(getComputedStyle(obj).left);
5074
5080
  }, (obj) => {
5075
5081
  return parseInt(getComputedStyle(obj).left);
@@ -5085,7 +5091,7 @@ var pops = (function () {
5085
5091
  });
5086
5092
  /* 关闭按钮点击事件 */
5087
5093
  popsDOMUtils.on(headerCloseBtnElement, "click", (event) => {
5088
- PopsUIUtils.configRemove([pops.config.layer.iframe], guid, false);
5094
+ PopsInstanceUtils.removeInstance([pops.config.layer.iframe], guid, false);
5089
5095
  setTimeout(() => {
5090
5096
  let allIsMinElementList = [];
5091
5097
  pops.config.layer.iframe.forEach((item) => {
@@ -5094,7 +5100,7 @@ var pops = (function () {
5094
5100
  allIsMinElementList.push(item.popsElement);
5095
5101
  }
5096
5102
  });
5097
- allIsMinElementList.sort(PopsUIUtils.sortElementListByProperty((obj) => {
5103
+ allIsMinElementList.sort(PopsInstanceUtils.sortElementListByProperty((obj) => {
5098
5104
  return parseInt(getComputedStyle(obj).left);
5099
5105
  }, (obj) => {
5100
5106
  return parseInt(getComputedStyle(obj).left);
@@ -6529,7 +6535,7 @@ var pops = (function () {
6529
6535
  }
6530
6536
  /* 拖拽 */
6531
6537
  if (config.drag) {
6532
- PopsUIUtils.drag($pops, {
6538
+ PopsInstanceUtils.drag($pops, {
6533
6539
  dragElement: $title,
6534
6540
  limit: config.dragLimit,
6535
6541
  extraDistance: config.dragExtraDistance,
@@ -8763,7 +8769,7 @@ var pops = (function () {
8763
8769
  });
8764
8770
  /* 拖拽 */
8765
8771
  if (config.drag) {
8766
- PopsUIUtils.drag($pops, {
8772
+ PopsInstanceUtils.drag($pops, {
8767
8773
  dragElement: $title,
8768
8774
  limit: config.dragLimit,
8769
8775
  extraDistance: config.dragExtraDistance,
@@ -9920,7 +9926,7 @@ var pops = (function () {
9920
9926
  /** 配置 */
9921
9927
  config = {
9922
9928
  /** 版本号 */
9923
- version: "2024.7.8",
9929
+ version: "2024.7.14",
9924
9930
  cssText: {
9925
9931
  /** 主CSS */
9926
9932
  index: indexCSS,
@@ -10010,6 +10016,10 @@ var pops = (function () {
10010
10016
  Utils: popsUtils,
10011
10017
  /** pops使用的DOM工具类 */
10012
10018
  DOMUtils: popsDOMUtils,
10019
+ /** pops创建的实例使用的工具类 */
10020
+ InstanceUtils: PopsInstanceUtils,
10021
+ /** pops处理float类型使用的工具类 */
10022
+ MathFloatUtils: PopsMathFloatUtils,
10013
10023
  };
10014
10024
  constructor() { }
10015
10025
  init() {
@@ -10020,7 +10030,7 @@ var pops = (function () {
10020
10030
  animationStyle.innerHTML = this.config.cssText.anim;
10021
10031
  popsDOMUtils.appendHead(animationStyle);
10022
10032
  this.config.animation = null;
10023
- this.config.animation = PopsUIUtils.getKeyFrames(animationStyle.sheet);
10033
+ this.config.animation = PopsInstanceUtils.getKeyFrames(animationStyle.sheet);
10024
10034
  setTimeout(() => {
10025
10035
  animationStyle.remove();
10026
10036
  }, 50);