@whitesev/pops 1.5.5 → 1.5.8

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
@@ -3011,17 +3011,27 @@ const PopsInstanceUtils = {
3011
3011
  * @param isAll 是否全部删除
3012
3012
  */
3013
3013
  removeInstance(moreLayerConfigList, guid, isAll = false) {
3014
- function removeItem(item) {
3015
- item?.animElement?.remove();
3016
- item?.popsElement?.remove();
3017
- item?.maskElement?.remove();
3018
- item?.$shadowContainer?.remove();
3014
+ /**
3015
+ * 移除元素实例
3016
+ * @param layerCommonConfig
3017
+ */
3018
+ function removeItem(layerCommonConfig) {
3019
+ if (typeof layerCommonConfig.beforeRemoveCallBack === "function") {
3020
+ // 调用移除签的回调
3021
+ layerCommonConfig.beforeRemoveCallBack(layerCommonConfig);
3022
+ }
3023
+ layerCommonConfig?.animElement?.remove();
3024
+ layerCommonConfig?.popsElement?.remove();
3025
+ layerCommonConfig?.maskElement?.remove();
3026
+ layerCommonConfig?.$shadowContainer?.remove();
3019
3027
  }
3020
3028
  // [ layer[], layer[],...]
3021
3029
  moreLayerConfigList.forEach((layerConfigList) => {
3022
3030
  // layer[]
3023
3031
  layerConfigList.forEach((layerConfigItem, index) => {
3032
+ // 移除全部或者guid相同
3024
3033
  if (isAll || layerConfigItem["guid"] === guid) {
3034
+ // 判断是否有动画
3025
3035
  if (pops.config.animation.hasOwnProperty(layerConfigItem.animElement.getAttribute("anim"))) {
3026
3036
  layerConfigItem.animElement.style.width = "100%";
3027
3037
  layerConfigItem.animElement.style.height = "100%";
@@ -4234,7 +4244,10 @@ const PopsHandler = {
4234
4244
  if (type === "loading" ||
4235
4245
  type === "tooltip" ||
4236
4246
  type === "rightClickMenu") {
4237
- PopsInstanceUtils.removeInstance([pops.config.layer[type]], "", true);
4247
+ let layer = pops.config.layer[type];
4248
+ if (layer) {
4249
+ PopsInstanceUtils.removeInstance([layer], "", true);
4250
+ }
4238
4251
  }
4239
4252
  else {
4240
4253
  PopsInstanceUtils.removeInstance([
@@ -4639,6 +4652,7 @@ class PopsPrompt {
4639
4652
  },
4640
4653
  content: {
4641
4654
  text: "",
4655
+ select: false,
4642
4656
  password: false,
4643
4657
  row: false,
4644
4658
  focus: true,
@@ -4814,7 +4828,11 @@ class PopsPrompt {
4814
4828
  }
4815
4829
  /* 设置自动获取焦点 */
4816
4830
  if (config.content.focus) {
4817
- $input?.focus();
4831
+ $input.focus();
4832
+ }
4833
+ /* 设置自动选中所有文字 */
4834
+ if (config.content.select) {
4835
+ $input.select();
4818
4836
  }
4819
4837
  return PopsHandler.handleResultDetails(eventDetails);
4820
4838
  }
@@ -6374,7 +6392,9 @@ class PopsFolder {
6374
6392
  let linkElement = targetElement.querySelector("a");
6375
6393
  if (typeof _config_.clickEvent === "function") {
6376
6394
  let downloadInfo = await _config_.clickEvent(event, _config_);
6377
- if (typeof downloadInfo === "object" &&
6395
+ if (downloadInfo != null &&
6396
+ typeof downloadInfo === "object" &&
6397
+ !Array.isArray(downloadInfo) &&
6378
6398
  typeof downloadInfo.url === "string" &&
6379
6399
  downloadInfo.url.trim() !== "") {
6380
6400
  linkElement.setAttribute("href", downloadInfo.url);
@@ -6434,7 +6454,6 @@ class PopsFolder {
6434
6454
  * @param isDesc 是否降序,默认false(升序)
6435
6455
  */
6436
6456
  function sortFolderConfig(folderDataConfigList, sortName = "fileName", isDesc = false) {
6437
- console.log(folderDataConfigList, sortName, isDesc);
6438
6457
  if (sortName === "fileName") {
6439
6458
  // 如果是以文件名排序,文件夹优先放前面
6440
6459
  let onlyFolderDataConfigList = folderDataConfigList.filter((value) => {
@@ -9103,10 +9122,24 @@ class PopsRightClickMenu {
9103
9122
  if (config.preventDefault) {
9104
9123
  popsDOMUtils.preventEvent(event);
9105
9124
  }
9125
+ PopsHandler.handleOnly(PopsType, config);
9106
9126
  if (PopsContextMenu.rootElement) {
9107
9127
  PopsContextMenu.closeAllMenu(PopsContextMenu.rootElement);
9108
9128
  }
9109
- PopsContextMenu.rootElement = PopsContextMenu.showMenu(event, config.data);
9129
+ let rootElement = PopsContextMenu.showMenu(event, config.data);
9130
+ PopsContextMenu.rootElement = rootElement;
9131
+ if (config.only) {
9132
+ PopsHandler.handlePush(PopsType, {
9133
+ $shadowRoot: $shadowRoot,
9134
+ $shadowContainer: $shadowContainer,
9135
+ guid: guid,
9136
+ animElement: rootElement,
9137
+ popsElement: rootElement,
9138
+ beforeRemoveCallBack(layerCommonConfig) {
9139
+ PopsContextMenu.closeAllMenu(layerCommonConfig.popsElement);
9140
+ },
9141
+ });
9142
+ }
9110
9143
  },
9111
9144
  /**
9112
9145
  * 添加contextmenu事件
@@ -9155,6 +9188,9 @@ class PopsRightClickMenu {
9155
9188
  * @param rootElement
9156
9189
  */
9157
9190
  closeAllMenu(rootElement) {
9191
+ if (rootElement == null) {
9192
+ return;
9193
+ }
9158
9194
  if (rootElement?.["__menuData__"]?.root) {
9159
9195
  rootElement = rootElement?.["__menuData__"]?.root;
9160
9196
  }
@@ -9457,7 +9493,9 @@ class PopsRightClickMenu {
9457
9493
  });
9458
9494
  },
9459
9495
  };
9496
+ // 添加右键菜单事件
9460
9497
  PopsContextMenu.addContextMenuEvent(config.target, config.targetSelector);
9498
+ // 添加全局点击检测
9461
9499
  PopsContextMenu.addWindowCheckClickListener();
9462
9500
  return {
9463
9501
  guid: guid,
@@ -10041,7 +10079,7 @@ class Pops {
10041
10079
  /** 配置 */
10042
10080
  config = {
10043
10081
  /** 版本号 */
10044
- version: "2024.9.11",
10082
+ version: "2024.9.16",
10045
10083
  cssText: {
10046
10084
  /** 主CSS */
10047
10085
  index: indexCSS,
@@ -10120,6 +10158,7 @@ class Pops {
10120
10158
  drawer: [],
10121
10159
  folder: [],
10122
10160
  panel: [],
10161
+ rightClickMenu: [],
10123
10162
  },
10124
10163
  /** 禁止滚动 */
10125
10164
  forbiddenScroll: {