@whitesev/pops 3.3.3 → 3.3.5

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.
Files changed (43) hide show
  1. package/dist/index.amd.js +93 -34
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.amd.min.js +1 -1
  4. package/dist/index.amd.min.js.map +1 -1
  5. package/dist/index.cjs.js +93 -34
  6. package/dist/index.cjs.js.map +1 -1
  7. package/dist/index.cjs.min.js +1 -1
  8. package/dist/index.cjs.min.js.map +1 -1
  9. package/dist/index.esm.js +93 -34
  10. package/dist/index.esm.js.map +1 -1
  11. package/dist/index.esm.min.js +1 -1
  12. package/dist/index.esm.min.js.map +1 -1
  13. package/dist/index.iife.js +93 -34
  14. package/dist/index.iife.js.map +1 -1
  15. package/dist/index.iife.min.js +1 -1
  16. package/dist/index.iife.min.js.map +1 -1
  17. package/dist/index.system.js +93 -34
  18. package/dist/index.system.js.map +1 -1
  19. package/dist/index.system.min.js +1 -1
  20. package/dist/index.system.min.js.map +1 -1
  21. package/dist/index.umd.js +93 -34
  22. package/dist/index.umd.js.map +1 -1
  23. package/dist/index.umd.min.js +1 -1
  24. package/dist/index.umd.min.js.map +1 -1
  25. package/dist/types/src/Pops.d.ts +11 -10
  26. package/dist/types/src/components/folder/types/index.d.ts +18 -13
  27. package/dist/types/src/components/tooltip/index.d.ts +1 -1
  28. package/dist/types/src/config/GlobalConfig.d.ts +1 -0
  29. package/dist/types/src/handler/PopsHandler.d.ts +2 -5
  30. package/dist/types/src/types/components.d.ts +7 -0
  31. package/package.json +1 -1
  32. package/src/components/alert/defaultConfig.ts +1 -0
  33. package/src/components/confirm/defaultConfig.ts +1 -0
  34. package/src/components/drawer/defaultConfig.ts +1 -0
  35. package/src/components/folder/defaultConfig.ts +1 -0
  36. package/src/components/folder/index.ts +58 -33
  37. package/src/components/folder/types/index.ts +29 -19
  38. package/src/components/iframe/defaultConfig.ts +1 -0
  39. package/src/components/loading/defaultConfig.ts +1 -0
  40. package/src/components/panel/defaultConfig.ts +1 -0
  41. package/src/components/prompt/defaultConfig.ts +1 -0
  42. package/src/handler/PopsHandler.ts +34 -10
  43. package/src/types/components.d.ts +7 -0
package/dist/index.umd.js CHANGED
@@ -3494,19 +3494,37 @@
3494
3494
  const $shadowContainer = popsDOMUtils.createElement("div", {
3495
3495
  className: "pops-shadow-container",
3496
3496
  });
3497
+ let $shadowRoot;
3497
3498
  if (config.useShadowRoot) {
3498
- const $shadowRoot = $shadowContainer.attachShadow({ mode: "open" });
3499
- return {
3500
- $shadowContainer,
3501
- $shadowRoot,
3502
- };
3499
+ $shadowRoot = $shadowContainer.attachShadow({ mode: "open" });
3503
3500
  }
3504
3501
  else {
3505
- return {
3506
- $shadowContainer,
3507
- $shadowRoot: $shadowContainer,
3508
- };
3502
+ $shadowRoot = $shadowContainer;
3503
+ }
3504
+ // 添加键盘监听
3505
+ // rightClickMenu
3506
+ // searchSuggestion
3507
+ // tooltip
3508
+ // 以上都不需要添加该事件监听
3509
+ if (config.stopKeyDownEventPropagation) {
3510
+ popsDOMUtils.on($shadowRoot, "keydown", [
3511
+ 'input[type="text"]',
3512
+ 'input[type="password"]',
3513
+ 'input[type="number"]',
3514
+ 'input[type="email"]',
3515
+ 'input[type="url"]',
3516
+ 'input[type="search"]',
3517
+ "input:not([type])",
3518
+ "textarea",
3519
+ ], (evt) => {
3520
+ evt.stopImmediatePropagation();
3521
+ evt.stopPropagation();
3522
+ }, { capture: true });
3509
3523
  }
3524
+ return {
3525
+ $shadowContainer,
3526
+ $shadowRoot,
3527
+ };
3510
3528
  },
3511
3529
  /**
3512
3530
  * 处理初始化
@@ -4033,6 +4051,7 @@
4033
4051
  lightStyle: null,
4034
4052
  darkStyle: null,
4035
4053
  beforeAppendToPageCallBack() { },
4054
+ stopKeyDownEventPropagation: true,
4036
4055
  };
4037
4056
  };
4038
4057
 
@@ -4241,6 +4260,7 @@
4241
4260
  lightStyle: null,
4242
4261
  darkStyle: null,
4243
4262
  beforeAppendToPageCallBack() { },
4263
+ stopKeyDownEventPropagation: true,
4244
4264
  };
4245
4265
  };
4246
4266
 
@@ -4449,6 +4469,7 @@
4449
4469
  darkStyle: null,
4450
4470
  beforeAppendToPageCallBack() { },
4451
4471
  forbiddenScroll: false,
4472
+ stopKeyDownEventPropagation: true,
4452
4473
  };
4453
4474
  };
4454
4475
 
@@ -4669,6 +4690,7 @@
4669
4690
  lightStyle: null,
4670
4691
  darkStyle: null,
4671
4692
  addIndexCSS: true,
4693
+ stopKeyDownEventPropagation: true,
4672
4694
  };
4673
4695
  };
4674
4696
 
@@ -4897,6 +4919,7 @@
4897
4919
  lightStyle: null,
4898
4920
  darkStyle: null,
4899
4921
  beforeAppendToPageCallBack() { },
4922
+ stopKeyDownEventPropagation: true,
4900
4923
  };
4901
4924
  };
4902
4925
 
@@ -5354,10 +5377,13 @@
5354
5377
  </div>`);
5355
5378
  // 存储原来的值
5356
5379
  Reflect.set($fileName, "__value__", folderData);
5357
- Reflect.set($folder, "folderData", folderData);
5380
+ Reflect.set($folder, "__value__", folderData);
5358
5381
  $folder.appendChild($fileName);
5359
5382
  return {
5360
5383
  folderElement: $folder,
5384
+ /**
5385
+ * 超链接标签的容器
5386
+ */
5361
5387
  fileNameElement: $fileName,
5362
5388
  };
5363
5389
  }
@@ -5446,8 +5472,17 @@
5446
5472
  },
5447
5473
  addIndexCSS: false,
5448
5474
  });
5475
+ let childConfig;
5449
5476
  if (typeof dataConfig.clickEvent === "function") {
5450
- const childConfig = await dataConfig.clickEvent(clickEvent, dataConfig);
5477
+ const result = await dataConfig.clickEvent(clickEvent, dataConfig);
5478
+ if (Array.isArray(result)) {
5479
+ childConfig = result;
5480
+ }
5481
+ }
5482
+ else if (Array.isArray(dataConfig.clickEvent)) {
5483
+ childConfig = dataConfig.clickEvent;
5484
+ }
5485
+ if (childConfig) {
5451
5486
  // 添加顶部导航的箭头
5452
5487
  folderFileListBreadcrumbPrimaryElement.appendChild(this.createHeaderArrowIcon());
5453
5488
  // 添加顶部导航的链接文字
@@ -5461,50 +5496,65 @@
5461
5496
  }
5462
5497
  loadingMask.close();
5463
5498
  }
5499
+ /**
5500
+ * 更新文件的显示的链接信息
5501
+ *
5502
+ * 这里主要用于鼠标中键或者右键触发,左键触发方式会根据mode进行处理
5503
+ * @returns 更新的文件的下载链接
5504
+ */
5505
+ updateFileLink($row, downloadInfo) {
5506
+ const downloadUrl = typeof downloadInfo?.url === "string" ? downloadInfo.url.trim() : "";
5507
+ if (downloadUrl !== "" && downloadUrl !== "null" && downloadUrl !== "undefined") {
5508
+ const $link = $row.querySelector("a");
5509
+ $link.setAttribute("href", downloadUrl);
5510
+ return downloadUrl;
5511
+ }
5512
+ }
5464
5513
  /**
5465
5514
  * 文件的点击事件 - 下载文件
5466
- * @param $target
5515
+ * @param evt 点击事件
5516
+ * @param $row 列表项
5467
5517
  * @param dataConfig
5468
5518
  */
5469
- async downloadFile(clickEvent, $row, dataConfig) {
5470
- popsDOMUtils.preventEvent(clickEvent);
5471
- const $link = $row.querySelector("a");
5519
+ async onFileClick(evt, $row, dataConfig) {
5520
+ let downloadInfo;
5472
5521
  if (typeof dataConfig.clickEvent === "function") {
5473
- const downloadInfo = await dataConfig.clickEvent(clickEvent, dataConfig);
5474
- if (downloadInfo != null &&
5475
- typeof downloadInfo === "object" &&
5476
- !Array.isArray(downloadInfo) &&
5477
- typeof downloadInfo.url === "string" &&
5478
- downloadInfo.url.trim() !== "") {
5479
- $link.setAttribute("href", downloadInfo.url);
5480
- $link.setAttribute("target", "_blank");
5481
- if (downloadInfo.autoDownload) {
5482
- if (downloadInfo.mode == null || String(downloadInfo.mode) === "") {
5483
- // 未设置mode的话默认为aBlank
5484
- downloadInfo.mode = "aBlank";
5485
- }
5522
+ const result = await dataConfig.clickEvent(evt, dataConfig);
5523
+ if (typeof result === "object" && result != null && !Array.isArray(result)) {
5524
+ downloadInfo = result;
5525
+ }
5526
+ }
5527
+ else if (typeof dataConfig.clickEvent === "object" &&
5528
+ dataConfig.clickEvent != null &&
5529
+ !Array.isArray(dataConfig.clickEvent)) {
5530
+ downloadInfo = dataConfig.clickEvent;
5531
+ }
5532
+ if (downloadInfo) {
5533
+ const downloadUrl = this.updateFileLink($row, downloadInfo);
5534
+ if (downloadUrl) {
5535
+ if (typeof downloadInfo.mode === "string") {
5486
5536
  if (downloadInfo.mode === "a" || downloadInfo.mode === "aBlank") {
5487
5537
  // a标签下载
5488
5538
  const $anchor = popsDOMUtils.createElement("a");
5489
5539
  if (downloadInfo.mode === "aBlank") {
5490
5540
  $anchor.setAttribute("target", "_blank");
5491
5541
  }
5492
- $anchor.href = downloadInfo.url;
5542
+ $anchor.href = downloadUrl;
5493
5543
  $anchor.click();
5494
5544
  }
5495
5545
  else if (downloadInfo.mode === "open" || downloadInfo.mode === "openBlank") {
5496
5546
  // window.open下载
5497
5547
  if (downloadInfo.mode === "openBlank") {
5498
- globalThis.open(downloadInfo.url, "_blank");
5548
+ globalThis.open(downloadUrl, "_blank");
5499
5549
  }
5500
5550
  else {
5501
- globalThis.open(downloadInfo.url);
5551
+ globalThis.open(downloadUrl);
5502
5552
  }
5503
5553
  }
5504
5554
  else if (downloadInfo.mode === "iframe") {
5505
5555
  // iframe下载
5506
5556
  const $downloadIframe = popsDOMUtils.createElement("iframe");
5507
- $downloadIframe.src = downloadInfo.url;
5557
+ $downloadIframe.src = downloadUrl;
5508
5558
  $downloadIframe.onload = function () {
5509
5559
  popsUtils.setTimeout(() => {
5510
5560
  $downloadIframe.remove();
@@ -5686,8 +5736,14 @@
5686
5736
  // 文件 - 点击事件
5687
5737
  popsDOMUtils.on(fileNameElement, "click", (event) => {
5688
5738
  // 下载文件
5689
- this.downloadFile(event, fileNameElement, item);
5739
+ popsDOMUtils.preventEvent(event);
5740
+ this.onFileClick(event, fileNameElement, item);
5690
5741
  });
5742
+ // 如果clickEvent不是函数,那么现在就可以进行配置
5743
+ if (typeof item.clickEvent === "object" && item.clickEvent !== null && !Array.isArray(item.clickEvent)) {
5744
+ // {} 单文件配置
5745
+ this.updateFileLink(fileNameElement, item.clickEvent);
5746
+ }
5691
5747
  folderListBodyElement.appendChild(folderElement);
5692
5748
  }
5693
5749
  });
@@ -5829,6 +5885,7 @@
5829
5885
  lightStyle: null,
5830
5886
  darkStyle: null,
5831
5887
  beforeAppendToPageCallBack() { },
5888
+ stopKeyDownEventPropagation: true,
5832
5889
  };
5833
5890
  };
5834
5891
 
@@ -6952,6 +7009,7 @@
6952
7009
  lightStyle: null,
6953
7010
  darkStyle: null,
6954
7011
  beforeAppendToPageCallBack() { },
7012
+ stopKeyDownEventPropagation: true,
6955
7013
  };
6956
7014
  };
6957
7015
 
@@ -11719,6 +11777,7 @@
11719
11777
  lightStyle: null,
11720
11778
  darkStyle: null,
11721
11779
  beforeAppendToPageCallBack() { },
11780
+ stopKeyDownEventPropagation: true,
11722
11781
  };
11723
11782
  };
11724
11783
 
@@ -13372,7 +13431,7 @@
13372
13431
  },
13373
13432
  };
13374
13433
 
13375
- const version = "3.3.3";
13434
+ const version = "3.3.5";
13376
13435
 
13377
13436
  class Pops {
13378
13437
  /** 配置 */