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