@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.
package/dist/index.esm.js CHANGED
@@ -1,3 +1,5 @@
1
+ const SymbolEvents = Symbol("events_" + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1));
2
+
1
3
  const PopsCoreDefaultEnv = {
2
4
  document: document,
3
5
  window: window,
@@ -36,8 +38,6 @@ const OriginPrototype$1 = {
36
38
  },
37
39
  };
38
40
 
39
- const SymbolEvents = Symbol("events_" + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1));
40
-
41
41
  // @ts-nocheck
42
42
 
43
43
  const AnyTouch = function () {
@@ -1489,6 +1489,12 @@ class PopsUtils {
1489
1489
  }
1490
1490
  assign(target = {}, source = {}, isAdd = false) {
1491
1491
  let UtilsContext = this;
1492
+ if (source == null) {
1493
+ return target;
1494
+ }
1495
+ if (target == null) {
1496
+ target = {};
1497
+ }
1492
1498
  if (Array.isArray(source)) {
1493
1499
  let canTraverse = source.filter((item) => {
1494
1500
  return typeof item === "object";
@@ -1502,8 +1508,9 @@ class PopsUtils {
1502
1508
  const targetKeyName = sourceKeyName;
1503
1509
  let targetValue = target[targetKeyName];
1504
1510
  let sourceValue = source[sourceKeyName];
1505
- if (sourceKeyName in target &&
1506
- typeof sourceValue === "object" &&
1511
+ if (typeof sourceValue === "object" &&
1512
+ sourceValue != null &&
1513
+ sourceKeyName in target &&
1507
1514
  !UtilsContext.isDOM(sourceValue)) {
1508
1515
  /* 源端的值是object类型,且不是元素节点 */
1509
1516
  target[sourceKeyName] = UtilsContext.assign(targetValue, sourceValue, isAdd);
@@ -1518,6 +1525,7 @@ class PopsUtils {
1518
1525
  let targetValue = target[targetKeyName];
1519
1526
  let sourceValue = source[targetKeyName];
1520
1527
  if (typeof sourceValue === "object" &&
1528
+ sourceValue != null &&
1521
1529
  !UtilsContext.isDOM(sourceValue) &&
1522
1530
  Object.keys(sourceValue).length) {
1523
1531
  /* 源端的值是object类型,且不是元素节点 */
@@ -2289,7 +2297,6 @@ class PopsDOMUtilsEvent {
2289
2297
  }
2290
2298
  }
2291
2299
  }
2292
-
2293
2300
  class PopsDOMUtils extends PopsDOMUtilsEvent {
2294
2301
  /** 获取 animationend 在各个浏览器的兼容名 */
2295
2302
  getAnimationEndNameList() {
@@ -2939,7 +2946,7 @@ class PopsDOMUtils extends PopsDOMUtilsEvent {
2939
2946
  }
2940
2947
  const popsDOMUtils = new PopsDOMUtils();
2941
2948
 
2942
- const PopsUIUtils = {
2949
+ const PopsInstanceUtils = {
2943
2950
  /**
2944
2951
  * 获取所有弹窗中的最大的z-index
2945
2952
  * @param defaultValue
@@ -2978,10 +2985,9 @@ const PopsUIUtils = {
2978
2985
  * 删除配置中对应的对象
2979
2986
  * @param moreLayerConfigList 配置实例列表
2980
2987
  * @param guid 唯一标识
2981
- * @param removeAll 是否全部删除
2988
+ * @param isAll 是否全部删除
2982
2989
  */
2983
- configRemove(moreLayerConfigList, guid, removeAll = false) {
2984
- /** @param item */
2990
+ removeInstance(moreLayerConfigList, guid, isAll = false) {
2985
2991
  function removeItem(item) {
2986
2992
  item?.animElement?.remove();
2987
2993
  item?.popsElement?.remove();
@@ -2992,7 +2998,7 @@ const PopsUIUtils = {
2992
2998
  moreLayerConfigList.forEach((layerConfigList) => {
2993
2999
  // layer[]
2994
3000
  layerConfigList.forEach((layerConfigItem, index) => {
2995
- if (removeAll || layerConfigItem["guid"] === guid) {
3001
+ if (isAll || layerConfigItem["guid"] === guid) {
2996
3002
  if (pops.config.animation.hasOwnProperty(layerConfigItem.animElement.getAttribute("anim"))) {
2997
3003
  layerConfigItem.animElement.style.width = "100%";
2998
3004
  layerConfigItem.animElement.style.height = "100%";
@@ -3159,7 +3165,7 @@ const PopsUIUtils = {
3159
3165
  return;
3160
3166
  }
3161
3167
  popsDOMUtils.off(popsElement, popsDOMUtils.getTransitionEndNameList(), void 0, closeCallBack);
3162
- PopsUIUtils.configRemove([layerConfigList], guid);
3168
+ PopsInstanceUtils.removeInstance([layerConfigList], guid);
3163
3169
  }
3164
3170
  /* 监听过渡结束 */
3165
3171
  popsDOMUtils.on(popsElement, popsDOMUtils.getTransitionEndNameList(), closeCallBack);
@@ -3190,7 +3196,7 @@ const PopsUIUtils = {
3190
3196
  }, drawerConfig.closeDelay);
3191
3197
  }
3192
3198
  else {
3193
- PopsUIUtils.configRemove([layerConfigList], guid);
3199
+ PopsInstanceUtils.removeInstance([layerConfigList], guid);
3194
3200
  }
3195
3201
  },
3196
3202
  /**
@@ -3878,11 +3884,11 @@ const PopsHandler = {
3878
3884
  function originalRun() {
3879
3885
  if (details.config.mask.clickEvent.toClose) {
3880
3886
  /* 关闭 */
3881
- PopsUIUtils.close(details.type, targetLayer, details.guid, details.config, details.animElement);
3887
+ PopsInstanceUtils.close(details.type, targetLayer, details.guid, details.config, details.animElement);
3882
3888
  }
3883
3889
  else if (details.config.mask.clickEvent.toHide) {
3884
3890
  /* 隐藏 */
3885
- PopsUIUtils.hide(details.type, targetLayer, details.guid, details.config, details.animElement, result.maskElement);
3891
+ PopsInstanceUtils.hide(details.type, targetLayer, details.guid, details.config, details.animElement, result.maskElement);
3886
3892
  }
3887
3893
  }
3888
3894
  if (typeof details.config.mask.clickCallBack === "function") {
@@ -4054,13 +4060,13 @@ const PopsHandler = {
4054
4060
  mode: mode,
4055
4061
  guid: guid,
4056
4062
  close() {
4057
- PopsUIUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
4063
+ PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
4058
4064
  },
4059
4065
  hide() {
4060
- PopsUIUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4066
+ PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4061
4067
  },
4062
4068
  show() {
4063
- PopsUIUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4069
+ PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4064
4070
  },
4065
4071
  };
4066
4072
  },
@@ -4082,13 +4088,13 @@ const PopsHandler = {
4082
4088
  mode: mode,
4083
4089
  guid: guid,
4084
4090
  close() {
4085
- PopsUIUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
4091
+ PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
4086
4092
  },
4087
4093
  hide() {
4088
- PopsUIUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4094
+ PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4089
4095
  },
4090
4096
  show() {
4091
- PopsUIUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4097
+ PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
4092
4098
  },
4093
4099
  };
4094
4100
  },
@@ -4188,10 +4194,10 @@ const PopsHandler = {
4188
4194
  if (type === "loading" ||
4189
4195
  type === "tooltip" ||
4190
4196
  type === "rightClickMenu") {
4191
- PopsUIUtils.configRemove([pops.config.layer[type]], "", true);
4197
+ PopsInstanceUtils.removeInstance([pops.config.layer[type]], "", true);
4192
4198
  }
4193
4199
  else {
4194
- PopsUIUtils.configRemove([
4200
+ PopsInstanceUtils.removeInstance([
4195
4201
  pops.config.layer.alert,
4196
4202
  pops.config.layer.confirm,
4197
4203
  pops.config.layer.prompt,
@@ -4204,7 +4210,7 @@ const PopsHandler = {
4204
4210
  }
4205
4211
  else {
4206
4212
  config.zIndex =
4207
- PopsUIUtils.getPopsMaxZIndex(config.zIndex)["zIndex"] * 2;
4213
+ PopsInstanceUtils.getPopsMaxZIndex(config.zIndex)["zIndex"] * 2;
4208
4214
  }
4209
4215
  return config;
4210
4216
  },
@@ -4361,7 +4367,7 @@ class PopsAlert {
4361
4367
  });
4362
4368
  /* 拖拽 */
4363
4369
  if (config.drag) {
4364
- PopsUIUtils.drag($pops, {
4370
+ PopsInstanceUtils.drag($pops, {
4365
4371
  dragElement: $title,
4366
4372
  limit: config.dragLimit,
4367
4373
  extraDistance: config.dragExtraDistance,
@@ -4543,7 +4549,7 @@ class PopsConfirm {
4543
4549
  });
4544
4550
  /* 拖拽 */
4545
4551
  if (config.drag) {
4546
- PopsUIUtils.drag($pops, {
4552
+ PopsInstanceUtils.drag($pops, {
4547
4553
  dragElement: $title,
4548
4554
  limit: config.dragLimit,
4549
4555
  extraDistance: config.dragExtraDistance,
@@ -4738,7 +4744,7 @@ class PopsPrompt {
4738
4744
  });
4739
4745
  /* 拖拽 */
4740
4746
  if (config.drag) {
4741
- PopsUIUtils.drag($pops, {
4747
+ PopsInstanceUtils.drag($pops, {
4742
4748
  dragElement: $title,
4743
4749
  limit: config.dragLimit,
4744
4750
  extraDistance: config.dragExtraDistance,
@@ -5000,7 +5006,7 @@ class PopsIframe {
5000
5006
  }
5001
5007
  /* 拖拽 */
5002
5008
  if (config.drag) {
5003
- PopsUIUtils.drag($pops, {
5009
+ PopsInstanceUtils.drag($pops, {
5004
5010
  dragElement: $title,
5005
5011
  limit: config.dragLimit,
5006
5012
  extraDistance: config.dragExtraDistance,
@@ -5066,7 +5072,7 @@ class PopsIframe {
5066
5072
  allMinElementList.push(item.popsElement);
5067
5073
  }
5068
5074
  });
5069
- allMinElementList.sort(PopsUIUtils.sortElementListByProperty((obj) => {
5075
+ allMinElementList.sort(PopsInstanceUtils.sortElementListByProperty((obj) => {
5070
5076
  return parseInt(getComputedStyle(obj).left);
5071
5077
  }, (obj) => {
5072
5078
  return parseInt(getComputedStyle(obj).left);
@@ -5082,7 +5088,7 @@ class PopsIframe {
5082
5088
  });
5083
5089
  /* 关闭按钮点击事件 */
5084
5090
  popsDOMUtils.on(headerCloseBtnElement, "click", (event) => {
5085
- PopsUIUtils.configRemove([pops.config.layer.iframe], guid, false);
5091
+ PopsInstanceUtils.removeInstance([pops.config.layer.iframe], guid, false);
5086
5092
  setTimeout(() => {
5087
5093
  let allIsMinElementList = [];
5088
5094
  pops.config.layer.iframe.forEach((item) => {
@@ -5091,7 +5097,7 @@ class PopsIframe {
5091
5097
  allIsMinElementList.push(item.popsElement);
5092
5098
  }
5093
5099
  });
5094
- allIsMinElementList.sort(PopsUIUtils.sortElementListByProperty((obj) => {
5100
+ allIsMinElementList.sort(PopsInstanceUtils.sortElementListByProperty((obj) => {
5095
5101
  return parseInt(getComputedStyle(obj).left);
5096
5102
  }, (obj) => {
5097
5103
  return parseInt(getComputedStyle(obj).left);
@@ -6526,7 +6532,7 @@ class PopsFolder {
6526
6532
  }
6527
6533
  /* 拖拽 */
6528
6534
  if (config.drag) {
6529
- PopsUIUtils.drag($pops, {
6535
+ PopsInstanceUtils.drag($pops, {
6530
6536
  dragElement: $title,
6531
6537
  limit: config.dragLimit,
6532
6538
  extraDistance: config.dragExtraDistance,
@@ -8760,7 +8766,7 @@ class PopsPanel {
8760
8766
  });
8761
8767
  /* 拖拽 */
8762
8768
  if (config.drag) {
8763
- PopsUIUtils.drag($pops, {
8769
+ PopsInstanceUtils.drag($pops, {
8764
8770
  dragElement: $title,
8765
8771
  limit: config.dragLimit,
8766
8772
  extraDistance: config.dragExtraDistance,
@@ -9917,7 +9923,7 @@ class Pops {
9917
9923
  /** 配置 */
9918
9924
  config = {
9919
9925
  /** 版本号 */
9920
- version: "2024.7.8",
9926
+ version: "2024.7.14",
9921
9927
  cssText: {
9922
9928
  /** 主CSS */
9923
9929
  index: indexCSS,
@@ -10007,6 +10013,10 @@ class Pops {
10007
10013
  Utils: popsUtils,
10008
10014
  /** pops使用的DOM工具类 */
10009
10015
  DOMUtils: popsDOMUtils,
10016
+ /** pops创建的实例使用的工具类 */
10017
+ InstanceUtils: PopsInstanceUtils,
10018
+ /** pops处理float类型使用的工具类 */
10019
+ MathFloatUtils: PopsMathFloatUtils,
10010
10020
  };
10011
10021
  constructor() { }
10012
10022
  init() {
@@ -10017,7 +10027,7 @@ class Pops {
10017
10027
  animationStyle.innerHTML = this.config.cssText.anim;
10018
10028
  popsDOMUtils.appendHead(animationStyle);
10019
10029
  this.config.animation = null;
10020
- this.config.animation = PopsUIUtils.getKeyFrames(animationStyle.sheet);
10030
+ this.config.animation = PopsInstanceUtils.getKeyFrames(animationStyle.sheet);
10021
10031
  setTimeout(() => {
10022
10032
  animationStyle.remove();
10023
10033
  }, 50);