@whitesev/pops 2.2.0 → 2.2.2

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 (48) hide show
  1. package/dist/index.amd.js +364 -357
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +364 -357
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +364 -357
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +364 -357
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +364 -357
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +364 -357
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/Pops.d.ts +17 -17
  14. package/dist/types/src/PopsInst.d.ts +8 -0
  15. package/dist/types/src/components/panel/index.d.ts +2 -1
  16. package/dist/types/src/components/searchSuggestion/index.d.ts +1 -1
  17. package/dist/types/src/handler/PopsElementHandler.d.ts +6 -6
  18. package/dist/types/src/handler/PopsHandler.d.ts +6 -6
  19. package/dist/types/src/types/button.d.ts +2 -2
  20. package/dist/types/src/types/components.d.ts +5 -5
  21. package/dist/types/src/types/event.d.ts +3 -3
  22. package/dist/types/src/types/{layer.d.ts → inst.d.ts} +7 -5
  23. package/dist/types/src/types/main.d.ts +36 -58
  24. package/dist/types/src/utils/PopsInstanceUtils.d.ts +10 -10
  25. package/package.json +1 -1
  26. package/src/Pops.ts +2 -2
  27. package/src/PopsInst.ts +21 -0
  28. package/src/components/alert/index.ts +16 -16
  29. package/src/components/confirm/index.ts +16 -15
  30. package/src/components/drawer/index.ts +16 -15
  31. package/src/components/folder/index.ts +141 -152
  32. package/src/components/iframe/index.ts +16 -15
  33. package/src/components/panel/index.ts +19 -18
  34. package/src/components/prompt/index.ts +15 -14
  35. package/src/components/rightClickMenu/index.ts +19 -18
  36. package/src/components/searchSuggestion/index.ts +21 -20
  37. package/src/components/tooltip/index.ts +3 -2
  38. package/src/css/scrollbar.css +9 -5
  39. package/src/handler/PopsElementHandler.ts +18 -18
  40. package/src/handler/PopsHandler.ts +38 -32
  41. package/src/types/button.d.ts +2 -2
  42. package/src/types/components.d.ts +5 -5
  43. package/src/types/event.d.ts +3 -3
  44. package/src/types/{layer.d.ts → inst.d.ts} +7 -5
  45. package/src/types/main.d.ts +36 -58
  46. package/src/utils/PopsInstanceUtils.ts +84 -81
  47. package/dist/types/src/PopsLayer.d.ts +0 -5
  48. package/src/PopsLayer.ts +0 -18
@@ -8,15 +8,15 @@ import type { PopsPanelDetails } from "../components/panel/types";
8
8
  import type { PopsPromptDetails } from "../components/prompt/types/index";
9
9
  import { PopsCore } from "../PopsCore";
10
10
  import { PopsAnimation } from "../PopsAnimation";
11
- import { PopsLayerData } from "../PopsLayer";
11
+ import { PopsInstData } from "../PopsInst";
12
12
  import type { PopsCommonConfig } from "../types/components";
13
13
  import { PopsEventDetails, PopsHandlerEventDetails } from "../types/event";
14
- import { PopsLayerCommonConfig } from "../types/layer";
14
+ import { PopsInstCommonConfig } from "../types/inst";
15
15
  import type {
16
- PopsAllDetails,
17
- PopsLayerMode,
18
- PopsMode,
16
+ PopsInstStoreType,
19
17
  PopsType,
18
+ PopsSupportAnimDetailsType,
19
+ PopsSupportOnlyDetails,
20
20
  } from "../types/main";
21
21
  import { popsDOMUtils } from "../utils/PopsDOMUtils";
22
22
  import { PopsInstanceUtils } from "../utils/PopsInstanceUtils";
@@ -145,13 +145,13 @@ export const PopsHandler = {
145
145
  function clickEvent(event: MouseEvent | PointerEvent) {
146
146
  popsDOMUtils.preventEvent(event);
147
147
  // 获取该类型实例存储列表
148
- let targetLayer = PopsLayerData[details.type];
148
+ let targetInst = PopsInstData[details.type];
149
149
  function originalRun() {
150
150
  if (details.config.mask!.clickEvent!.toClose) {
151
151
  /* 关闭 */
152
152
  return PopsInstanceUtils.close(
153
153
  details.type,
154
- targetLayer,
154
+ targetInst,
155
155
  details.guid,
156
156
  details.config,
157
157
  details.animElement
@@ -160,7 +160,7 @@ export const PopsHandler = {
160
160
  /* 隐藏 */
161
161
  return PopsInstanceUtils.hide(
162
162
  details.type,
163
- targetLayer,
163
+ targetInst,
164
164
  details.guid,
165
165
  details.config,
166
166
  details.animElement,
@@ -234,7 +234,10 @@ export const PopsHandler = {
234
234
  * @param animElement
235
235
  * @param type
236
236
  */
237
- handleQueryElement(animElement: HTMLDivElement, type: PopsType) {
237
+ handleQueryElement(
238
+ animElement: HTMLDivElement,
239
+ type: PopsSupportAnimDetailsType
240
+ ) {
238
241
  return {
239
242
  /**
240
243
  * 主元素
@@ -408,7 +411,7 @@ export const PopsHandler = {
408
411
  guid: string,
409
412
  $shadowContainer: HTMLDivElement,
410
413
  $shadowRoot: ShadowRoot | HTMLElement,
411
- mode: PopsLayerMode,
414
+ mode: PopsInstStoreType,
412
415
  animElement: HTMLDivElement,
413
416
  popsElement: HTMLDivElement,
414
417
  maskElement: HTMLDivElement,
@@ -434,7 +437,7 @@ export const PopsHandler = {
434
437
  close() {
435
438
  return PopsInstanceUtils.close(
436
439
  mode,
437
- PopsLayerData[mode],
440
+ PopsInstData[mode],
438
441
  guid,
439
442
  config,
440
443
  animElement
@@ -443,7 +446,7 @@ export const PopsHandler = {
443
446
  hide() {
444
447
  return PopsInstanceUtils.hide(
445
448
  mode,
446
- PopsLayerData[mode],
449
+ PopsInstData[mode],
447
450
  guid,
448
451
  config,
449
452
  animElement,
@@ -453,7 +456,7 @@ export const PopsHandler = {
453
456
  show() {
454
457
  return PopsInstanceUtils.show(
455
458
  mode,
456
- PopsLayerData[mode],
459
+ PopsInstData[mode],
457
460
  guid,
458
461
  config,
459
462
  animElement,
@@ -497,7 +500,7 @@ export const PopsHandler = {
497
500
  close() {
498
501
  return PopsInstanceUtils.close(
499
502
  mode,
500
- PopsLayerData[mode],
503
+ PopsInstData[mode],
501
504
  guid,
502
505
  config,
503
506
  animElement
@@ -506,7 +509,7 @@ export const PopsHandler = {
506
509
  hide() {
507
510
  return PopsInstanceUtils.hide(
508
511
  mode,
509
- PopsLayerData[mode],
512
+ PopsInstData[mode],
510
513
  guid,
511
514
  config,
512
515
  animElement,
@@ -516,7 +519,7 @@ export const PopsHandler = {
516
519
  show() {
517
520
  return PopsInstanceUtils.show(
518
521
  mode,
519
- PopsLayerData[mode],
522
+ PopsInstData[mode],
520
523
  guid,
521
524
  config,
522
525
  animElement,
@@ -660,30 +663,33 @@ export const PopsHandler = {
660
663
  * @param type 当前弹窗类型
661
664
  * @param config 配置
662
665
  */
663
- handleOnly<T extends Required<PopsAllDetails[keyof PopsAllDetails]>>(
664
- type: PopsMode,
665
- config: T
666
- ): T {
666
+ handleOnly<
667
+ T extends Required<PopsSupportOnlyDetails[keyof PopsSupportOnlyDetails]>
668
+ >(type: PopsType, config: T): T {
667
669
  if (config.only) {
670
+ // .loading
671
+ // .tooltip
672
+ // .rightClickMenu
673
+ // 单独处理
668
674
  if (
669
675
  type === "loading" ||
670
676
  type === "tooltip" ||
671
677
  type === "rightClickMenu"
672
678
  ) {
673
- let layer = PopsLayerData[type as keyof typeof PopsLayerData];
674
- if (layer) {
675
- PopsInstanceUtils.removeInstance([layer], "", true);
679
+ let inst = PopsInstData[type as keyof typeof PopsInstData];
680
+ if (inst) {
681
+ PopsInstanceUtils.removeInstance([inst], "", true);
676
682
  }
677
683
  } else {
678
684
  PopsInstanceUtils.removeInstance(
679
685
  [
680
- PopsLayerData.alert,
681
- PopsLayerData.confirm,
682
- PopsLayerData.prompt,
683
- PopsLayerData.iframe,
684
- PopsLayerData.drawer,
685
- PopsLayerData.folder,
686
- PopsLayerData.panel,
686
+ PopsInstData.alert,
687
+ PopsInstData.confirm,
688
+ PopsInstData.prompt,
689
+ PopsInstData.iframe,
690
+ PopsInstData.drawer,
691
+ PopsInstData.folder,
692
+ PopsInstData.panel,
687
693
  ],
688
694
  "",
689
695
  true
@@ -707,7 +713,7 @@ export const PopsHandler = {
707
713
  * @param type 当前弹窗类型
708
714
  * @param value
709
715
  */
710
- handlePush(type: PopsLayerMode, value: PopsLayerCommonConfig) {
711
- PopsLayerData[type].push(value);
716
+ handlePush(type: PopsInstStoreType, value: PopsInstCommonConfig) {
717
+ PopsInstData[type].push(value);
712
718
  },
713
719
  };
@@ -1,6 +1,6 @@
1
1
  import { PopsEventDetails, PopsHandlerEventDetails } from "./event";
2
2
  import type { PopsIconType } from "./icon";
3
- import type { PopsMode } from "./main";
3
+ import type { PopsType } from "./main";
4
4
 
5
5
  /**
6
6
  * 按钮类型
@@ -51,7 +51,7 @@ export interface PopsBtnCallBackEvent {
51
51
  /**
52
52
  * 调用的方法
53
53
  */
54
- mode: PopsMode;
54
+ mode: PopsType;
55
55
  /**
56
56
  * 唯一id
57
57
  */
@@ -21,17 +21,17 @@ export interface PopsTitleConfig {
21
21
  */
22
22
  text?: string;
23
23
  /**
24
- * 文字的位置
24
+ * 标题文字的位置
25
25
  * @default "left"
26
26
  */
27
27
  position?: PopsTextAlign;
28
28
  /**
29
- * 文字是否是html
29
+ * 标题文字是否是html
30
30
  * @default false
31
31
  */
32
32
  html?: boolean;
33
33
  /**
34
- * 文字的自定义CSS
34
+ * 自定义CSS
35
35
  */
36
36
  style?: string;
37
37
  };
@@ -47,12 +47,12 @@ export interface PopsContentConfig {
47
47
  */
48
48
  text?: string;
49
49
  /**
50
- * 文字是否是html
50
+ * 内容文字是否是html
51
51
  * @default false
52
52
  */
53
53
  html?: boolean;
54
54
  /**
55
- * 文字的自定义CSS
55
+ * 自定义CSS
56
56
  */
57
57
  style?: string;
58
58
  };
@@ -1,5 +1,5 @@
1
1
  import type { PopsIframeDetails } from "../components/iframe/types";
2
- import type { PopsMode } from "./main";
2
+ import type { PopsType } from "./main";
3
3
 
4
4
  /**
5
5
  * 事件配置
@@ -12,7 +12,7 @@ export interface PopsIframeEventDetails {
12
12
  /**
13
13
  * 当前弹窗类型
14
14
  */
15
- mode: PopsMode;
15
+ mode: PopsType;
16
16
  /**
17
17
  * 动画层
18
18
  */
@@ -47,7 +47,7 @@ export interface PopsEventDetails {
47
47
  /** 遮罩层 */
48
48
  maskElement?: HTMLDivElement;
49
49
  /** 当前弹窗类型 */
50
- mode: PopsMode;
50
+ mode: PopsType;
51
51
  guid: string;
52
52
  close: () => Promise<void>;
53
53
  hide: () => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * config内存储饿实例配置
2
+ * config实例配置
3
3
  */
4
- export interface PopsLayerConfig {
4
+ export interface PopsInstConfig {
5
5
  /** 固定id */
6
6
  guid: string;
7
7
  /** 动画元素 */
@@ -11,12 +11,14 @@ export interface PopsLayerConfig {
11
11
  /** 遮罩层元素 */
12
12
  maskElement?: HTMLDivElement;
13
13
  }
14
-
15
- export interface PopsLayerCommonConfig extends PopsLayerConfig {
14
+ /**
15
+ * config实例通用配置
16
+ */
17
+ export interface PopsInstCommonConfig extends PopsInstConfig {
16
18
  /** shadow容器 */
17
19
  $shadowContainer: HTMLDivElement;
18
20
  /** shadow容器的shandowRoot */
19
21
  $shadowRoot: ShadowRoot | HTMLElement;
20
22
  /** 移除实例前的回调函数 */
21
- beforeRemoveCallBack?: (layerCommonConfig: PopsLayerCommonConfig) => void;
23
+ beforeRemoveCallBack?: (instCommonConfig: PopsInstCommonConfig) => void;
22
24
  }
@@ -16,13 +16,14 @@ import type { PopsPanelTextAreaDetails } from "../components/panel/types/compone
16
16
  import type { PopsPromptDetails } from "../components/prompt/types/index";
17
17
  import { PopsRightClickMenuDetails } from "../components/rightClickMenu/types";
18
18
  import { PopsToolTipDetails } from "../components/tooltip/types/index";
19
+ import type { PopsSearchSuggestionDetails } from "../components/searchSuggestion/types";
19
20
 
20
21
  export interface PopsUtilsOwnObject<V extends any> {
21
22
  [key: string]: V | PopsUtilsOwnObject<V>;
22
23
  }
23
24
 
24
- /** pops的所有类型配置 10个 */
25
- export interface PopsAllDetails {
25
+ /** pops所有的类型配置 11个*/
26
+ export interface PopsDetails {
26
27
  alert: PopsAlertDetails;
27
28
  confirm: PopsConfirmDetails;
28
29
  prompt: PopsPromptDetails;
@@ -33,78 +34,55 @@ export interface PopsAllDetails {
33
34
  folder: PopsFolderDetails;
34
35
  panel: PopsPanelDetails;
35
36
  rightClickMenu: PopsRightClickMenuDetails;
37
+ searchSuggestion: PopsSearchSuggestionDetails;
36
38
  }
37
39
 
38
- /** pops的类型配置 8个 */
39
- export interface PopsTypeDetails {
40
- alert: PopsAlertDetails;
41
- confirm: PopsConfirmDetails;
42
- prompt: PopsPromptDetails;
43
- loading: PopsLoadingDetails;
44
- iframe: PopsIframeDetails;
45
- // tooltip: PopsToolTipDetails;
46
- drawer: PopsDrawerDetails;
47
- folder: PopsFolderDetails;
48
- panel: PopsPanelDetails;
49
- // rightClickMenu: PopsRightClickMenuDetails;
50
- }
40
+ /** pops的类型 */
41
+ export type PopsType = keyof PopsDetails;
51
42
 
52
- /** pops的类型 8个 */
53
- export type PopsType = keyof PopsTypeDetails;
43
+ /** pops中支持only的配置 */
44
+ export type PopsSupportOnlyDetails = Omit<PopsDetails, "searchSuggestion">;
54
45
 
55
- /** pops所有的类型 10个 */
56
- export type PopsMode = PopsType | "tooltip" | "rightClickMenu";
46
+ /** 存储实例的类型 */
47
+ export type PopsInstStoreType = keyof Omit<PopsDetails, "searchSuggestion">;
57
48
 
58
- /** 存储实例的类型 9个 */
59
- export type PopsLayerMode = PopsType | "tooltip" | "rightClickMenu";
49
+ /** pops弹窗支持动画元素的配置 8个 */
50
+ export type PopsSupportAnimDetails = Omit<
51
+ PopsDetails,
52
+ "tooltip" | "rightClickMenu" | "searchSuggestion"
53
+ >;
60
54
 
61
- /** pops弹窗支持动画元素的配置 */
62
- export interface PopsSupportAnim {
63
- alert: PopsAlertDetails;
64
- confirm: PopsConfirmDetails;
65
- prompt: PopsPromptDetails;
66
- loading: PopsLoadingDetails;
67
- iframe: PopsIframeDetails;
68
- drawer: PopsDrawerDetails;
69
- folder: PopsFolderDetails;
70
- panel: PopsPanelDetails;
71
- }
72
55
  /** pops弹窗支持动画元素的类型 */
73
- export type PopsTypeSupportAnim = keyof PopsSupportAnim;
56
+ export type PopsSupportAnimDetailsType = keyof PopsSupportAnimDetails;
74
57
 
75
58
  /** pops弹窗支持标题栏的配置 */
76
- export interface PopsSupportHeaderTitle {
77
- alert: PopsAlertDetails;
78
- confirm: PopsConfirmDetails;
79
- prompt: PopsPromptDetails;
80
- iframe: PopsIframeDetails;
81
- drawer: PopsDrawerDetails;
82
- folder: PopsFolderDetails;
83
- panel: PopsPanelDetails;
84
- }
59
+ export type PopsSupportHeaderTitleDetails = Pick<
60
+ PopsDetails,
61
+ "alert" | "confirm" | "prompt" | "iframe" | "drawer" | "folder" | "panel"
62
+ >;
63
+
85
64
  /** pops弹窗支持标题栏的类型 */
86
- export type PopsTypeSupportHeaderTitle = keyof PopsSupportHeaderTitle;
65
+ export type PopsSupportHeaderTitleDetailsType =
66
+ keyof PopsSupportHeaderTitleDetails;
87
67
 
88
68
  /** pops支持底部按钮的配置 */
89
- export interface PopsSupportBottomBtn {
90
- alert: PopsAlertDetails;
91
- confirm: PopsConfirmDetails;
92
- prompt: PopsPromptDetails;
93
- drawer: PopsDrawerDetails;
94
- }
69
+ export type PopsSupportBottomBtnDetails = Pick<
70
+ PopsDetails,
71
+ "alert" | "confirm" | "prompt" | "drawer"
72
+ >;
73
+
95
74
  /** pops支持底部按钮的类型 */
96
- export type PopsTypeSupportBottomBtn = keyof PopsSupportHeaderTitle;
75
+ export type PopsSupportBottomBtnDetailsType =
76
+ keyof PopsSupportHeaderTitleDetails;
97
77
 
98
78
  /** pops支持中间内容的配置 */
99
- export interface PopsSupportContent {
100
- alert: PopsAlertDetails;
101
- confirm: PopsConfirmDetails;
102
- prompt: PopsPromptDetails;
103
- drawer: PopsDrawerDetails;
104
- loading: PopsLoadingDetails;
105
- }
79
+ export type PopsSupportContentDetails = Pick<
80
+ PopsDetails,
81
+ "alert" | "confirm" | "prompt" | "drawer" | "loading"
82
+ >;
83
+
106
84
  /** pops支持中间内容的类型 */
107
- export type PopsTypeSupportContent = keyof PopsSupportContent;
85
+ export type PopsSupportContentDetailsType = keyof PopsSupportContentDetails;
108
86
 
109
87
  /** panel的各种类型的配置项 */
110
88
  export type PopsPanelFormsTotalDetails =