@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.
@@ -3014,17 +3014,27 @@ var pops = (function () {
3014
3014
  * @param isAll 是否全部删除
3015
3015
  */
3016
3016
  removeInstance(moreLayerConfigList, guid, isAll = false) {
3017
- function removeItem(item) {
3018
- item?.animElement?.remove();
3019
- item?.popsElement?.remove();
3020
- item?.maskElement?.remove();
3021
- item?.$shadowContainer?.remove();
3017
+ /**
3018
+ * 移除元素实例
3019
+ * @param layerCommonConfig
3020
+ */
3021
+ function removeItem(layerCommonConfig) {
3022
+ if (typeof layerCommonConfig.beforeRemoveCallBack === "function") {
3023
+ // 调用移除签的回调
3024
+ layerCommonConfig.beforeRemoveCallBack(layerCommonConfig);
3025
+ }
3026
+ layerCommonConfig?.animElement?.remove();
3027
+ layerCommonConfig?.popsElement?.remove();
3028
+ layerCommonConfig?.maskElement?.remove();
3029
+ layerCommonConfig?.$shadowContainer?.remove();
3022
3030
  }
3023
3031
  // [ layer[], layer[],...]
3024
3032
  moreLayerConfigList.forEach((layerConfigList) => {
3025
3033
  // layer[]
3026
3034
  layerConfigList.forEach((layerConfigItem, index) => {
3035
+ // 移除全部或者guid相同
3027
3036
  if (isAll || layerConfigItem["guid"] === guid) {
3037
+ // 判断是否有动画
3028
3038
  if (pops.config.animation.hasOwnProperty(layerConfigItem.animElement.getAttribute("anim"))) {
3029
3039
  layerConfigItem.animElement.style.width = "100%";
3030
3040
  layerConfigItem.animElement.style.height = "100%";
@@ -4237,7 +4247,10 @@ var pops = (function () {
4237
4247
  if (type === "loading" ||
4238
4248
  type === "tooltip" ||
4239
4249
  type === "rightClickMenu") {
4240
- PopsInstanceUtils.removeInstance([pops.config.layer[type]], "", true);
4250
+ let layer = pops.config.layer[type];
4251
+ if (layer) {
4252
+ PopsInstanceUtils.removeInstance([layer], "", true);
4253
+ }
4241
4254
  }
4242
4255
  else {
4243
4256
  PopsInstanceUtils.removeInstance([
@@ -4642,6 +4655,7 @@ var pops = (function () {
4642
4655
  },
4643
4656
  content: {
4644
4657
  text: "",
4658
+ select: false,
4645
4659
  password: false,
4646
4660
  row: false,
4647
4661
  focus: true,
@@ -4817,7 +4831,11 @@ var pops = (function () {
4817
4831
  }
4818
4832
  /* 设置自动获取焦点 */
4819
4833
  if (config.content.focus) {
4820
- $input?.focus();
4834
+ $input.focus();
4835
+ }
4836
+ /* 设置自动选中所有文字 */
4837
+ if (config.content.select) {
4838
+ $input.select();
4821
4839
  }
4822
4840
  return PopsHandler.handleResultDetails(eventDetails);
4823
4841
  }
@@ -6377,7 +6395,9 @@ var pops = (function () {
6377
6395
  let linkElement = targetElement.querySelector("a");
6378
6396
  if (typeof _config_.clickEvent === "function") {
6379
6397
  let downloadInfo = await _config_.clickEvent(event, _config_);
6380
- if (typeof downloadInfo === "object" &&
6398
+ if (downloadInfo != null &&
6399
+ typeof downloadInfo === "object" &&
6400
+ !Array.isArray(downloadInfo) &&
6381
6401
  typeof downloadInfo.url === "string" &&
6382
6402
  downloadInfo.url.trim() !== "") {
6383
6403
  linkElement.setAttribute("href", downloadInfo.url);
@@ -6437,7 +6457,6 @@ var pops = (function () {
6437
6457
  * @param isDesc 是否降序,默认false(升序)
6438
6458
  */
6439
6459
  function sortFolderConfig(folderDataConfigList, sortName = "fileName", isDesc = false) {
6440
- console.log(folderDataConfigList, sortName, isDesc);
6441
6460
  if (sortName === "fileName") {
6442
6461
  // 如果是以文件名排序,文件夹优先放前面
6443
6462
  let onlyFolderDataConfigList = folderDataConfigList.filter((value) => {
@@ -9106,10 +9125,24 @@ var pops = (function () {
9106
9125
  if (config.preventDefault) {
9107
9126
  popsDOMUtils.preventEvent(event);
9108
9127
  }
9128
+ PopsHandler.handleOnly(PopsType, config);
9109
9129
  if (PopsContextMenu.rootElement) {
9110
9130
  PopsContextMenu.closeAllMenu(PopsContextMenu.rootElement);
9111
9131
  }
9112
- PopsContextMenu.rootElement = PopsContextMenu.showMenu(event, config.data);
9132
+ let rootElement = PopsContextMenu.showMenu(event, config.data);
9133
+ PopsContextMenu.rootElement = rootElement;
9134
+ if (config.only) {
9135
+ PopsHandler.handlePush(PopsType, {
9136
+ $shadowRoot: $shadowRoot,
9137
+ $shadowContainer: $shadowContainer,
9138
+ guid: guid,
9139
+ animElement: rootElement,
9140
+ popsElement: rootElement,
9141
+ beforeRemoveCallBack(layerCommonConfig) {
9142
+ PopsContextMenu.closeAllMenu(layerCommonConfig.popsElement);
9143
+ },
9144
+ });
9145
+ }
9113
9146
  },
9114
9147
  /**
9115
9148
  * 添加contextmenu事件
@@ -9158,6 +9191,9 @@ var pops = (function () {
9158
9191
  * @param rootElement
9159
9192
  */
9160
9193
  closeAllMenu(rootElement) {
9194
+ if (rootElement == null) {
9195
+ return;
9196
+ }
9161
9197
  if (rootElement?.["__menuData__"]?.root) {
9162
9198
  rootElement = rootElement?.["__menuData__"]?.root;
9163
9199
  }
@@ -9460,7 +9496,9 @@ var pops = (function () {
9460
9496
  });
9461
9497
  },
9462
9498
  };
9499
+ // 添加右键菜单事件
9463
9500
  PopsContextMenu.addContextMenuEvent(config.target, config.targetSelector);
9501
+ // 添加全局点击检测
9464
9502
  PopsContextMenu.addWindowCheckClickListener();
9465
9503
  return {
9466
9504
  guid: guid,
@@ -10044,7 +10082,7 @@ var pops = (function () {
10044
10082
  /** 配置 */
10045
10083
  config = {
10046
10084
  /** 版本号 */
10047
- version: "2024.9.11",
10085
+ version: "2024.9.16",
10048
10086
  cssText: {
10049
10087
  /** 主CSS */
10050
10088
  index: indexCSS,
@@ -10123,6 +10161,7 @@ var pops = (function () {
10123
10161
  drawer: [],
10124
10162
  folder: [],
10125
10163
  panel: [],
10164
+ rightClickMenu: [],
10126
10165
  },
10127
10166
  /** 禁止滚动 */
10128
10167
  forbiddenScroll: {