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