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