@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.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([
@@ -4641,6 +4654,7 @@ define((function () { 'use strict';
4641
4654
  },
4642
4655
  content: {
4643
4656
  text: "",
4657
+ select: false,
4644
4658
  password: false,
4645
4659
  row: false,
4646
4660
  focus: true,
@@ -4816,7 +4830,11 @@ define((function () { 'use strict';
4816
4830
  }
4817
4831
  /* 设置自动获取焦点 */
4818
4832
  if (config.content.focus) {
4819
- $input?.focus();
4833
+ $input.focus();
4834
+ }
4835
+ /* 设置自动选中所有文字 */
4836
+ if (config.content.select) {
4837
+ $input.select();
4820
4838
  }
4821
4839
  return PopsHandler.handleResultDetails(eventDetails);
4822
4840
  }
@@ -6376,7 +6394,9 @@ define((function () { 'use strict';
6376
6394
  let linkElement = targetElement.querySelector("a");
6377
6395
  if (typeof _config_.clickEvent === "function") {
6378
6396
  let downloadInfo = await _config_.clickEvent(event, _config_);
6379
- if (typeof downloadInfo === "object" &&
6397
+ if (downloadInfo != null &&
6398
+ typeof downloadInfo === "object" &&
6399
+ !Array.isArray(downloadInfo) &&
6380
6400
  typeof downloadInfo.url === "string" &&
6381
6401
  downloadInfo.url.trim() !== "") {
6382
6402
  linkElement.setAttribute("href", downloadInfo.url);
@@ -6436,7 +6456,6 @@ define((function () { 'use strict';
6436
6456
  * @param isDesc 是否降序,默认false(升序)
6437
6457
  */
6438
6458
  function sortFolderConfig(folderDataConfigList, sortName = "fileName", isDesc = false) {
6439
- console.log(folderDataConfigList, sortName, isDesc);
6440
6459
  if (sortName === "fileName") {
6441
6460
  // 如果是以文件名排序,文件夹优先放前面
6442
6461
  let onlyFolderDataConfigList = folderDataConfigList.filter((value) => {
@@ -9105,10 +9124,24 @@ define((function () { 'use strict';
9105
9124
  if (config.preventDefault) {
9106
9125
  popsDOMUtils.preventEvent(event);
9107
9126
  }
9127
+ PopsHandler.handleOnly(PopsType, config);
9108
9128
  if (PopsContextMenu.rootElement) {
9109
9129
  PopsContextMenu.closeAllMenu(PopsContextMenu.rootElement);
9110
9130
  }
9111
- 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
+ }
9112
9145
  },
9113
9146
  /**
9114
9147
  * 添加contextmenu事件
@@ -9157,6 +9190,9 @@ define((function () { 'use strict';
9157
9190
  * @param rootElement
9158
9191
  */
9159
9192
  closeAllMenu(rootElement) {
9193
+ if (rootElement == null) {
9194
+ return;
9195
+ }
9160
9196
  if (rootElement?.["__menuData__"]?.root) {
9161
9197
  rootElement = rootElement?.["__menuData__"]?.root;
9162
9198
  }
@@ -9459,7 +9495,9 @@ define((function () { 'use strict';
9459
9495
  });
9460
9496
  },
9461
9497
  };
9498
+ // 添加右键菜单事件
9462
9499
  PopsContextMenu.addContextMenuEvent(config.target, config.targetSelector);
9500
+ // 添加全局点击检测
9463
9501
  PopsContextMenu.addWindowCheckClickListener();
9464
9502
  return {
9465
9503
  guid: guid,
@@ -10043,7 +10081,7 @@ define((function () { 'use strict';
10043
10081
  /** 配置 */
10044
10082
  config = {
10045
10083
  /** 版本号 */
10046
- version: "2024.9.11",
10084
+ version: "2024.9.16",
10047
10085
  cssText: {
10048
10086
  /** 主CSS */
10049
10087
  index: indexCSS,
@@ -10122,6 +10160,7 @@ define((function () { 'use strict';
10122
10160
  drawer: [],
10123
10161
  folder: [],
10124
10162
  panel: [],
10163
+ rightClickMenu: [],
10125
10164
  },
10126
10165
  /** 禁止滚动 */
10127
10166
  forbiddenScroll: {