@whitesev/pops 1.5.6 → 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.amd.js CHANGED
@@ -3013,17 +3013,27 @@ define((function () { 'use strict';
3013
3013
  * @param isAll 是否全部删除
3014
3014
  */
3015
3015
  removeInstance(moreLayerConfigList, guid, isAll = false) {
3016
- function removeItem(item) {
3017
- item?.animElement?.remove();
3018
- item?.popsElement?.remove();
3019
- item?.maskElement?.remove();
3020
- item?.$shadowContainer?.remove();
3016
+ /**
3017
+ * 移除元素实例
3018
+ * @param layerCommonConfig
3019
+ */
3020
+ function removeItem(layerCommonConfig) {
3021
+ if (typeof layerCommonConfig.beforeRemoveCallBack === "function") {
3022
+ // 调用移除签的回调
3023
+ layerCommonConfig.beforeRemoveCallBack(layerCommonConfig);
3024
+ }
3025
+ layerCommonConfig?.animElement?.remove();
3026
+ layerCommonConfig?.popsElement?.remove();
3027
+ layerCommonConfig?.maskElement?.remove();
3028
+ layerCommonConfig?.$shadowContainer?.remove();
3021
3029
  }
3022
3030
  // [ layer[], layer[],...]
3023
3031
  moreLayerConfigList.forEach((layerConfigList) => {
3024
3032
  // layer[]
3025
3033
  layerConfigList.forEach((layerConfigItem, index) => {
3034
+ // 移除全部或者guid相同
3026
3035
  if (isAll || layerConfigItem["guid"] === guid) {
3036
+ // 判断是否有动画
3027
3037
  if (pops.config.animation.hasOwnProperty(layerConfigItem.animElement.getAttribute("anim"))) {
3028
3038
  layerConfigItem.animElement.style.width = "100%";
3029
3039
  layerConfigItem.animElement.style.height = "100%";
@@ -4236,7 +4246,10 @@ define((function () { 'use strict';
4236
4246
  if (type === "loading" ||
4237
4247
  type === "tooltip" ||
4238
4248
  type === "rightClickMenu") {
4239
- PopsInstanceUtils.removeInstance([pops.config.layer[type]], "", true);
4249
+ let layer = pops.config.layer[type];
4250
+ if (layer) {
4251
+ PopsInstanceUtils.removeInstance([layer], "", true);
4252
+ }
4240
4253
  }
4241
4254
  else {
4242
4255
  PopsInstanceUtils.removeInstance([
@@ -6381,7 +6394,9 @@ define((function () { 'use strict';
6381
6394
  let linkElement = targetElement.querySelector("a");
6382
6395
  if (typeof _config_.clickEvent === "function") {
6383
6396
  let downloadInfo = await _config_.clickEvent(event, _config_);
6384
- if (typeof downloadInfo === "object" &&
6397
+ if (downloadInfo != null &&
6398
+ typeof downloadInfo === "object" &&
6399
+ !Array.isArray(downloadInfo) &&
6385
6400
  typeof downloadInfo.url === "string" &&
6386
6401
  downloadInfo.url.trim() !== "") {
6387
6402
  linkElement.setAttribute("href", downloadInfo.url);
@@ -6441,7 +6456,6 @@ define((function () { 'use strict';
6441
6456
  * @param isDesc 是否降序,默认false(升序)
6442
6457
  */
6443
6458
  function sortFolderConfig(folderDataConfigList, sortName = "fileName", isDesc = false) {
6444
- console.log(folderDataConfigList, sortName, isDesc);
6445
6459
  if (sortName === "fileName") {
6446
6460
  // 如果是以文件名排序,文件夹优先放前面
6447
6461
  let onlyFolderDataConfigList = folderDataConfigList.filter((value) => {
@@ -9110,10 +9124,24 @@ define((function () { 'use strict';
9110
9124
  if (config.preventDefault) {
9111
9125
  popsDOMUtils.preventEvent(event);
9112
9126
  }
9127
+ PopsHandler.handleOnly(PopsType, config);
9113
9128
  if (PopsContextMenu.rootElement) {
9114
9129
  PopsContextMenu.closeAllMenu(PopsContextMenu.rootElement);
9115
9130
  }
9116
- PopsContextMenu.rootElement = PopsContextMenu.showMenu(event, config.data);
9131
+ let rootElement = PopsContextMenu.showMenu(event, config.data);
9132
+ PopsContextMenu.rootElement = rootElement;
9133
+ if (config.only) {
9134
+ PopsHandler.handlePush(PopsType, {
9135
+ $shadowRoot: $shadowRoot,
9136
+ $shadowContainer: $shadowContainer,
9137
+ guid: guid,
9138
+ animElement: rootElement,
9139
+ popsElement: rootElement,
9140
+ beforeRemoveCallBack(layerCommonConfig) {
9141
+ PopsContextMenu.closeAllMenu(layerCommonConfig.popsElement);
9142
+ },
9143
+ });
9144
+ }
9117
9145
  },
9118
9146
  /**
9119
9147
  * 添加contextmenu事件
@@ -9162,6 +9190,9 @@ define((function () { 'use strict';
9162
9190
  * @param rootElement
9163
9191
  */
9164
9192
  closeAllMenu(rootElement) {
9193
+ if (rootElement == null) {
9194
+ return;
9195
+ }
9165
9196
  if (rootElement?.["__menuData__"]?.root) {
9166
9197
  rootElement = rootElement?.["__menuData__"]?.root;
9167
9198
  }
@@ -9464,7 +9495,9 @@ define((function () { 'use strict';
9464
9495
  });
9465
9496
  },
9466
9497
  };
9498
+ // 添加右键菜单事件
9467
9499
  PopsContextMenu.addContextMenuEvent(config.target, config.targetSelector);
9500
+ // 添加全局点击检测
9468
9501
  PopsContextMenu.addWindowCheckClickListener();
9469
9502
  return {
9470
9503
  guid: guid,
@@ -10048,7 +10081,7 @@ define((function () { 'use strict';
10048
10081
  /** 配置 */
10049
10082
  config = {
10050
10083
  /** 版本号 */
10051
- version: "2024.9.14",
10084
+ version: "2024.9.16",
10052
10085
  cssText: {
10053
10086
  /** 主CSS */
10054
10087
  index: indexCSS,
@@ -10127,6 +10160,7 @@ define((function () { 'use strict';
10127
10160
  drawer: [],
10128
10161
  folder: [],
10129
10162
  panel: [],
10163
+ rightClickMenu: [],
10130
10164
  },
10131
10165
  /** 禁止滚动 */
10132
10166
  forbiddenScroll: {