@whitesev/pops 2.5.4 → 2.6.0

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 (59) hide show
  1. package/dist/index.amd.js +195 -161
  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 +195 -161
  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 +195 -161
  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 +195 -161
  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 +195 -161
  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 +195 -161
  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 +60 -20968
  26. package/dist/types/src/components/alert/index.d.ts +1 -1
  27. package/dist/types/src/components/confirm/index.d.ts +1 -1
  28. package/dist/types/src/components/drawer/index.d.ts +1 -1
  29. package/dist/types/src/components/folder/index.d.ts +1 -1
  30. package/dist/types/src/components/iframe/index.d.ts +2 -2
  31. package/dist/types/src/components/iframe/types/index.d.ts +6 -6
  32. package/dist/types/src/components/loading/index.d.ts +1 -1
  33. package/dist/types/src/components/panel/index.d.ts +4 -4
  34. package/dist/types/src/components/prompt/index.d.ts +1 -1
  35. package/dist/types/src/components/rightClickMenu/index.d.ts +134 -20954
  36. package/dist/types/src/components/rightClickMenu/types/index.d.ts +17 -1
  37. package/dist/types/src/handler/PopsHandler.d.ts +18 -17
  38. package/dist/types/src/types/button.d.ts +4 -4
  39. package/dist/types/src/types/event.d.ts +7 -7
  40. package/dist/types/src/utils/PopsInstanceUtils.d.ts +8 -8
  41. package/package.json +12 -12
  42. package/src/components/alert/index.ts +13 -13
  43. package/src/components/confirm/index.ts +15 -16
  44. package/src/components/drawer/index.ts +22 -22
  45. package/src/components/folder/index.ts +14 -14
  46. package/src/components/iframe/index.ts +19 -20
  47. package/src/components/iframe/types/index.ts +6 -6
  48. package/src/components/loading/index.ts +8 -8
  49. package/src/components/panel/index.css +12 -1
  50. package/src/components/panel/index.ts +11 -11
  51. package/src/components/prompt/index.ts +28 -29
  52. package/src/components/rightClickMenu/config.ts +3 -0
  53. package/src/components/rightClickMenu/index.css +3 -0
  54. package/src/components/rightClickMenu/index.ts +51 -19
  55. package/src/components/rightClickMenu/types/index.ts +17 -1
  56. package/src/handler/PopsHandler.ts +70 -68
  57. package/src/types/button.d.ts +4 -4
  58. package/src/types/event.d.ts +7 -7
  59. package/src/utils/PopsInstanceUtils.ts +28 -24
@@ -30,7 +30,7 @@ export interface PopsRightClickMenuDataDetails {
30
30
  * + false 不关闭菜单
31
31
  *
32
32
  */
33
- callback?: (clickEvent: PointerEvent, contextMenuEvent: PointerEvent, liElement: HTMLLIElement, menuListenerRootNode: HTMLElement) => boolean | void | Promise<boolean | void>;
33
+ callback?: (clickEvent: PointerEvent, contextMenuEvent: PointerEvent, liElement: HTMLLIElement, menuListenerRootNode: NonNullable<PopsRightClickMenuDetails["target"]>) => boolean | void | Promise<boolean | void>;
34
34
  /**
35
35
  * 子项配置
36
36
  */
@@ -47,8 +47,14 @@ export interface PopsRightClickMenuDetails extends Pick<PopsCommonConfig, "useSh
47
47
  target?: HTMLElement | Window | EventTarget | Node;
48
48
  /**
49
49
  * 目标的子元素选择器,默认为空
50
+ * @default null
50
51
  */
51
52
  targetSelector?: string | null;
53
+ /**
54
+ * 位置
55
+ * @default "fixed"
56
+ */
57
+ position?: "absolute" | "fixed";
52
58
  /**
53
59
  * 右键菜单数据
54
60
  */
@@ -87,4 +93,14 @@ export interface PopsRightClickMenuDetails extends Pick<PopsCommonConfig, "useSh
87
93
  * @default false
88
94
  */
89
95
  preventDefault?: boolean;
96
+ /**
97
+ * 限制x位置在当前视窗内
98
+ * @default true
99
+ */
100
+ limitPositionXInView?: boolean;
101
+ /**
102
+ * 限制y位置在当前视窗内
103
+ * @default true
104
+ */
105
+ limitPositionYInView?: boolean;
90
106
  }
@@ -7,7 +7,7 @@ import type { PopsLoadingDetails } from "../components/loading/types";
7
7
  import type { PopsPanelDetails } from "../components/panel/types";
8
8
  import type { PopsPromptDetails } from "../components/prompt/types/index";
9
9
  import type { PopsCommonConfig } from "../types/components";
10
- import type { PopsEventDetails, PopsHandlerEventDetails } from "../types/event";
10
+ import type { PopsEventConfig, PopsHandlerEventConfig } from "../types/event";
11
11
  import type { PopsInstCommonConfig } from "../types/inst";
12
12
  import type { PopsInstStoreType, PopsType, PopsSupportAnimDetailsType, PopsSupportOnlyDetails } from "../types/main";
13
13
  export declare const PopsHandler: {
@@ -34,9 +34,9 @@ export declare const PopsHandler: {
34
34
  * 处理遮罩层
35
35
  *
36
36
  * + 设置遮罩层的点击事件
37
- * @param details 传递的配置
37
+ * @param config 传递的配置
38
38
  */
39
- handleMask(details?: {
39
+ handleMask(config?: {
40
40
  type: "alert" | "confirm" | "prompt" | "loading" | "iframe" | "drawer" | "folder" | "panel";
41
41
  guid: string;
42
42
  config: Required<PopsAlertDetails> | Required<PopsLoadingDetails> | Required<PopsIframeDetails> | Required<PopsDrawerDetails> | Required<PopsPanelDetails> | Required<PopsFolderDetails>;
@@ -178,34 +178,35 @@ export declare const PopsHandler: {
178
178
  * @param $shadowContainer
179
179
  * @param $shadowRoot
180
180
  * @param mode 当前弹窗类型
181
- * @param animElement 动画层
182
- * @param popsElement 主元素
183
- * @param maskElement 遮罩层
181
+ * @param $anim 动画层
182
+ * @param $pops 主元素
183
+ * @param $mask 遮罩层
184
184
  * @param config 当前配置
185
185
  */
186
- handleEventDetails(guid: string, $shadowContainer: HTMLDivElement, $shadowRoot: ShadowRoot | HTMLElement, mode: PopsInstStoreType, animElement: HTMLDivElement, popsElement: HTMLDivElement, maskElement: HTMLDivElement, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails): PopsEventDetails;
186
+ handleEventConfig(config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, guid: string, $shadowContainer: HTMLDivElement, $shadowRoot: ShadowRoot | HTMLElement, mode: PopsInstStoreType, $anim: HTMLDivElement, $pops: HTMLDivElement, $mask?: HTMLDivElement): PopsEventConfig;
187
187
  /**
188
188
  * 获取loading的事件配置
189
189
  * @param guid
190
190
  * @param mode 当前弹窗类型
191
- * @param animElement 动画层
192
- * @param popsElement 主元素
193
- * @param maskElement 遮罩层
191
+ * @param $anim 动画层
192
+ * @param $pops 主元素
193
+ * @param $mask 遮罩层
194
194
  * @param config 当前配置
195
195
  */
196
- handleLoadingEventDetails(guid: string, mode: "loading", animElement: HTMLDivElement, popsElement: HTMLDivElement, maskElement: HTMLDivElement, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails): Omit<PopsEventDetails, "$shadowContainer" | "$shadowRoot">;
196
+ handleLoadingEventConfig(config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, guid: string, mode: "loading", $anim: HTMLDivElement, $pops: HTMLDivElement, $mask?: HTMLDivElement): Omit<PopsEventConfig, "$shadowContainer" | "$shadowRoot">;
197
197
  /**
198
- * 处理返回的配置,针对popsHandler.handleEventDetails
198
+ * 处理返回的配置,针对popsHandler.handleEventConfig
199
+ * @param config 配置
199
200
  */
200
- handleResultDetails<T>(details: T): Omit<T, "type" | "function">;
201
+ handleResultConfig<T>(config: T): Omit<T, "type" | "function">;
201
202
  /**
202
203
  * 处理点击事件
203
204
  * @param type 当前按钮类型
204
205
  * @param $btn 按钮元素
205
- * @param eventDetails 事件配置,由popsHandler.handleEventDetails创建的
206
+ * @param eventConfig 事件配置,由popsHandler.handleEventConfig创建的
206
207
  * @param callback 点击回调
207
208
  */
208
- handleClickEvent(type: "cancel" | "close" | "ok" | "other", $btn: HTMLElement, eventDetails: PopsEventDetails, callback: (details: PopsHandlerEventDetails, event: PointerEvent | MouseEvent) => void): void;
209
+ handleClickEvent(type: PopsHandlerEventConfig["type"], $btn: HTMLElement, eventConfig: PopsEventConfig, callback?: (details: PopsHandlerEventConfig, event: PointerEvent | MouseEvent) => void): void;
209
210
  /**
210
211
  * 全局监听键盘事件
211
212
  * @param keyName 键名|键值
@@ -220,10 +221,10 @@ export declare const PopsHandler: {
220
221
  * @param type 触发事件类型
221
222
  * @param inputElement 输入框
222
223
  * @param $btn 按钮元素
223
- * @param eventDetails 事件配置,由popsHandler.handleEventDetails创建的
224
+ * @param eventConfig 事件配置,由popsHandler.handleEventConfig创建的
224
225
  * @param callback 点击回调
225
226
  */
226
- handlePromptClickEvent(type: "ok" | "close" | "cancel" | "other", inputElement: HTMLInputElement | HTMLTextAreaElement, $btn: HTMLElement, eventDetails: PopsEventDetails, callback: (details: PopsEventDetails & {
227
+ handlePromptClickEvent(type: PopsHandlerEventConfig["type"], inputElement: HTMLInputElement | HTMLTextAreaElement, $btn: HTMLElement, eventConfig: PopsEventConfig, callback: (details: PopsEventConfig & {
227
228
  type: any;
228
229
  text: string;
229
230
  }, event: MouseEvent | PointerEvent) => void): void;
@@ -1,4 +1,4 @@
1
- import type { PopsEventDetails, PopsHandlerEventDetails } from "./event";
1
+ import type { PopsEventConfig, PopsHandlerEventConfig } from "./event";
2
2
  import type { PopsIconType } from "./icon";
3
3
  import type { PopsType } from "./main";
4
4
 
@@ -110,7 +110,7 @@ export interface PopsButtonDetails<T = object> {
110
110
  *
111
111
  * 如果传入该值,那么将不会自动关闭弹窗
112
112
  */
113
- callback(eventDetails: PopsHandlerEventDetails & T, event: PointerEvent | MouseEvent): void;
113
+ callback(eventConfig: PopsHandlerEventConfig & T, event: PointerEvent | MouseEvent): void;
114
114
  }
115
115
 
116
116
  /**
@@ -127,7 +127,7 @@ export type PopsButtonDetailsAnyType<T = object> = Omit<PopsButtonDetails<T>, "t
127
127
  /** prompt的点击回调 */
128
128
  export interface PopsPromptButtonDetails extends PopsButtonDetails {
129
129
  callback(
130
- eventDetails: PopsHandlerEventDetails & {
130
+ eventConfig: PopsHandlerEventConfig & {
131
131
  text: string;
132
132
  },
133
133
  event: PointerEvent | MouseEvent
@@ -183,5 +183,5 @@ export interface PopsHeaderCloseButtonDetails {
183
183
  *
184
184
  * 如果传入该值,那么将不会自动关闭弹窗
185
185
  */
186
- callback?: (details: PopsEventDetails, event: PointerEvent | MouseEvent) => void;
186
+ callback?: (details: PopsEventConfig, event: PointerEvent | MouseEvent) => void;
187
187
  }
@@ -4,7 +4,7 @@ import type { PopsType } from "./main";
4
4
  /**
5
5
  * 事件配置
6
6
  */
7
- export interface PopsIframeEventDetails {
7
+ export interface PopsIframeEventConfig {
8
8
  /**
9
9
  * 唯一id
10
10
  */
@@ -33,19 +33,19 @@ export interface PopsIframeEventDetails {
33
33
  /**
34
34
  * 事件配置
35
35
  */
36
- export interface PopsEventDetails {
36
+ export interface PopsEventConfig {
37
37
  /** 最外层包裹的元素 */
38
38
  $shadowContainer: HTMLDivElement;
39
39
  /** ShadowRoot */
40
40
  $shadowRoot: ShadowRoot | HTMLElement;
41
41
  /** -> 动画层 */
42
- element: HTMLDivElement;
42
+ $el: HTMLDivElement;
43
43
  /** 动画层 */
44
- animElement: HTMLDivElement;
44
+ $anim: HTMLDivElement;
45
45
  /** 主元素 */
46
- popsElement: HTMLDivElement;
46
+ $pops: HTMLDivElement;
47
47
  /** 遮罩层 */
48
- maskElement?: HTMLDivElement;
48
+ $mask?: HTMLDivElement;
49
49
  /** 当前弹窗类型 */
50
50
  mode: PopsType;
51
51
  guid: string;
@@ -57,7 +57,7 @@ export interface PopsEventDetails {
57
57
  /**
58
58
  * 处理过的事件配置
59
59
  */
60
- export interface PopsHandlerEventDetails extends PopsEventDetails {
60
+ export interface PopsHandlerEventConfig extends PopsEventConfig {
61
61
  /** 当前按钮类型 */
62
62
  type: "cancel" | "close" | "ok" | "other";
63
63
  }
@@ -55,29 +55,29 @@ export declare const PopsInstanceUtils: {
55
55
  * @param instConfigList
56
56
  * @param guid
57
57
  * @param config
58
- * @param animElement
59
- * @param maskElement
58
+ * @param $anim
59
+ * @param $mask
60
60
  */
61
- hide(popsType: PopsInstStoreType, instConfigList: PopsInstCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement, maskElement: HTMLElement): Promise<void>;
61
+ hide(config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, popsType: PopsInstStoreType, instConfigList: PopsInstCommonConfig[], guid: string, $anim: HTMLElement, $mask?: HTMLElement): Promise<void>;
62
62
  /**
63
63
  * 显示
64
64
  * @param popsType
65
65
  * @param instConfigList
66
66
  * @param guid
67
67
  * @param config
68
- * @param animElement
69
- * @param maskElement
68
+ * @param $anim
69
+ * @param $mask
70
70
  */
71
- show(popsType: PopsInstStoreType, instConfigList: PopsInstCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement, maskElement?: HTMLElement): Promise<void>;
71
+ show(config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, popsType: PopsInstStoreType, instConfigList: PopsInstCommonConfig[], guid: string, $anim: HTMLElement, $mask?: HTMLElement): Promise<void>;
72
72
  /**
73
73
  * 关闭
74
74
  * @param popsType
75
75
  * @param instConfigList
76
76
  * @param guid
77
77
  * @param config
78
- * @param animElement
78
+ * @param $anim
79
79
  */
80
- close(popsType: string, instConfigList: PopsInstCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement): Promise<void>;
80
+ close(config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, popsType: string, instConfigList: PopsInstCommonConfig[], guid: string, $anim: HTMLElement): Promise<void>;
81
81
  /**
82
82
  * 拖拽元素
83
83
  * 说明:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/pops",
3
- "version": "2.5.4",
3
+ "version": "2.6.0",
4
4
  "description": "弹窗库",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/WhiteSevs/TamperMonkeyScript/tree/master/lib/pops#readme",
@@ -41,28 +41,28 @@
41
41
  "license": "MIT",
42
42
  "dependencies": {
43
43
  "any-touch": "^2.2.0",
44
- "worker-timers": "^8.0.23"
44
+ "worker-timers": "^8.0.25"
45
45
  },
46
46
  "devDependencies": {
47
- "@eslint/js": "^9.36.0",
48
- "@rollup/plugin-commonjs": "^28.0.6",
47
+ "@eslint/js": "^9.38.0",
48
+ "@rollup/plugin-commonjs": "^28.0.8",
49
49
  "@rollup/plugin-json": "^6.1.0",
50
- "@rollup/plugin-node-resolve": "^16.0.1",
50
+ "@rollup/plugin-node-resolve": "^16.0.3",
51
51
  "@rollup/plugin-terser": "^0.4.4",
52
52
  "@rollup/plugin-typescript": "12.1.4",
53
- "browserslist": "^4.26.2",
54
- "caniuse-lite": "^1.0.30001743",
55
- "eslint": "^9.36.0",
53
+ "browserslist": "^4.26.3",
54
+ "caniuse-lite": "^1.0.30001751",
55
+ "eslint": "^9.38.0",
56
56
  "eslint-config-prettier": "^10.1.8",
57
57
  "eslint-plugin-compat": "^6.0.2",
58
58
  "eslint-plugin-prettier": "^5.5.4",
59
59
  "globals": "^16.4.0",
60
- "rollup": "^4.45.0",
60
+ "rollup": "^4.52.5",
61
61
  "rollup-plugin-clear": "^2.0.7",
62
- "rollup-plugin-import-css": "^4.0.1",
62
+ "rollup-plugin-import-css": "^4.0.2",
63
63
  "tslib": "^2.8.1",
64
- "typescript": "^5.8.3",
65
- "typescript-eslint": "^8.44.0"
64
+ "typescript": "^5.9.3",
65
+ "typescript-eslint": "^8.46.2"
66
66
  },
67
67
  "scripts": {
68
68
  "lint": "eslint .",
@@ -89,42 +89,42 @@ export const PopsAlert = {
89
89
  } = PopsHandler.handleQueryElement($anim, popsType);
90
90
 
91
91
  /** 遮罩层元素 */
92
- let $mask: HTMLDivElement | null = null;
92
+ let $mask: HTMLDivElement | undefined = void 0;
93
93
  /** 已创建的元素列表 */
94
- const elementList: HTMLElement[] = [$anim];
94
+ const $elList: HTMLElement[] = [$anim];
95
95
 
96
96
  /* 遮罩层元素 */
97
97
 
98
98
  if (config.mask.enable) {
99
- const _handleMask_ = PopsHandler.handleMask({
99
+ const handleMask = PopsHandler.handleMask({
100
100
  type: popsType,
101
101
  guid: guid,
102
102
  config: config,
103
103
  animElement: $anim,
104
104
  maskHTML: maskHTML,
105
105
  });
106
- $mask = _handleMask_.maskElement;
107
- elementList.push($mask);
106
+ $mask = handleMask.maskElement;
107
+ $elList.push($mask);
108
108
  }
109
109
  /* 处理返回的配置 */
110
- const eventDetails = PopsHandler.handleEventDetails(
110
+ const evtConfig = PopsHandler.handleEventConfig(
111
+ config,
111
112
  guid,
112
113
  $shadowContainer,
113
114
  $shadowRoot,
114
115
  popsType,
115
116
  $anim,
116
- $pops!,
117
- $mask!,
118
- config
117
+ $pops,
118
+ $mask
119
119
  );
120
120
  /* 为顶部右边的关闭按钮添加点击事件 */
121
- PopsHandler.handleClickEvent("close", $headerCloseBtn!, eventDetails, config.btn.close!.callback!);
121
+ PopsHandler.handleClickEvent("close", $headerCloseBtn, evtConfig, config.btn.close?.callback);
122
122
  /* 为底部ok按钮添加点击事件 */
123
- PopsHandler.handleClickEvent("ok", btnOkElement!, eventDetails!, config.btn.ok!.callback!);
123
+ PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok?.callback);
124
124
 
125
125
  /* 创建到页面中 */
126
126
 
127
- popsDOMUtils.append($shadowRoot, elementList);
127
+ popsDOMUtils.append($shadowRoot, $elList);
128
128
  if (typeof config.beforeAppendToPageCallBack === "function") {
129
129
  config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
130
130
  }
@@ -157,7 +157,7 @@ export const PopsAlert = {
157
157
  });
158
158
  }
159
159
 
160
- const result = PopsHandler.handleResultDetails(eventDetails);
160
+ const result = PopsHandler.handleResultConfig(evtConfig);
161
161
  return result;
162
162
  },
163
163
  };
@@ -94,43 +94,42 @@ export const PopsConfirm = {
94
94
  /**
95
95
  * 遮罩层元素
96
96
  */
97
- let $mask: HTMLDivElement | null = null;
97
+ let $mask: HTMLDivElement | undefined = void 0;
98
98
  /**
99
99
  * 已创建的元素列表
100
100
  */
101
- const elementList: HTMLElement[] = [$anim];
101
+ const $elList: HTMLElement[] = [$anim];
102
102
 
103
103
  if (config.mask.enable) {
104
104
  // 启用遮罩层
105
- const _handleMask_ = PopsHandler.handleMask({
105
+ const handleMask = PopsHandler.handleMask({
106
106
  type: popsType,
107
107
  guid: guid,
108
108
  config: config,
109
109
  animElement: $anim,
110
110
  maskHTML: maskHTML,
111
111
  });
112
- $mask = _handleMask_.maskElement;
113
- elementList.push($mask);
112
+ $mask = handleMask.maskElement;
113
+ $elList.push($mask);
114
114
  }
115
- const eventDetails = PopsHandler.handleEventDetails(
115
+ const evtConfig = PopsHandler.handleEventConfig(
116
+ config,
116
117
  guid,
117
118
  $shadowContainer,
118
119
  $shadowRoot,
119
120
  popsType,
120
-
121
121
  $anim,
122
- $pops!,
123
- $mask!,
124
- config
122
+ $pops,
123
+ $mask
125
124
  );
126
- PopsHandler.handleClickEvent("close", $btnClose!, eventDetails, config.btn.close!.callback!);
127
- PopsHandler.handleClickEvent("ok", $btnOk!, eventDetails!, config.btn.ok!.callback!);
128
- PopsHandler.handleClickEvent("cancel", $btnCancel!, eventDetails, config.btn.cancel!.callback!);
129
- PopsHandler.handleClickEvent("other", $btnOther!, eventDetails, config.btn.other!.callback!);
125
+ PopsHandler.handleClickEvent("close", $btnClose, evtConfig, config.btn.close.callback);
126
+ PopsHandler.handleClickEvent("ok", $btnOk, evtConfig, config.btn.ok.callback);
127
+ PopsHandler.handleClickEvent("cancel", $btnCancel, evtConfig, config.btn.cancel.callback);
128
+ PopsHandler.handleClickEvent("other", $btnOther, evtConfig, config.btn.other.callback);
130
129
 
131
130
  /* 创建到页面中 */
132
131
 
133
- popsDOMUtils.append($shadowRoot, elementList);
132
+ popsDOMUtils.append($shadowRoot, $elList);
134
133
  if (typeof config.beforeAppendToPageCallBack === "function") {
135
134
  config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
136
135
  }
@@ -160,7 +159,7 @@ export const PopsConfirm = {
160
159
  endCallBack: config.dragEndCallBack,
161
160
  });
162
161
  }
163
- const result = PopsHandler.handleResultDetails(eventDetails);
162
+ const result = PopsHandler.handleResultConfig(evtConfig);
164
163
  return result;
165
164
  },
166
165
  };
@@ -2,6 +2,7 @@ import { GlobalConfig } from "../../config/GlobalConfig";
2
2
  import { PopsElementHandler } from "../../handler/PopsElementHandler";
3
3
  import { PopsHandler } from "../../handler/PopsHandler";
4
4
  import { PopsCSS } from "../../PopsCSS";
5
+ import type { PopsHandlerEventConfig } from "../../types/event";
5
6
  import type { PopsType } from "../../types/main";
6
7
  import { popsDOMUtils } from "../../utils/PopsDOMUtils";
7
8
  import { popsUtils } from "../../utils/PopsUtils";
@@ -99,32 +100,32 @@ export const PopsDrawer = {
99
100
  /**
100
101
  * 遮罩层元素
101
102
  */
102
- let $mask: HTMLDivElement | null = null;
103
+ let $mask: HTMLDivElement | undefined = void 0;
103
104
  /**
104
105
  * 已创建的元素列表
105
106
  */
106
- const elementList: HTMLElement[] = [$anim];
107
+ const $elList: HTMLElement[] = [$anim];
107
108
 
108
109
  if (config.mask.enable) {
109
- const _handleMask_ = PopsHandler.handleMask({
110
+ const handleMask = PopsHandler.handleMask({
110
111
  type: popsType,
111
112
  guid: guid,
112
113
  config: config,
113
114
  animElement: $anim,
114
115
  maskHTML: maskHTML,
115
116
  });
116
- $mask = _handleMask_.maskElement;
117
- elementList.push($mask);
117
+ $mask = handleMask.maskElement;
118
+ $elList.push($mask);
118
119
  }
119
- const eventDetails = PopsHandler.handleEventDetails(
120
+ const evtConfig = PopsHandler.handleEventConfig(
121
+ config,
120
122
  guid,
121
123
  $shadowContainer,
122
124
  $shadowRoot,
123
125
  popsType,
124
126
  $anim,
125
127
  $pops,
126
- $mask!,
127
- config
128
+ $mask
128
129
  );
129
130
  /* 处理方向 */
130
131
 
@@ -153,11 +154,14 @@ export const PopsDrawer = {
153
154
  /* 按下Esc键触发关闭 */
154
155
  if (config.closeOnPressEscape) {
155
156
  PopsHandler.handleKeyboardEvent("Escape", [], function () {
156
- eventDetails.close();
157
+ evtConfig.close();
157
158
  });
158
159
  }
159
160
  /* 待处理的点击事件列表 */
160
- const needHandleClickEventList = [
161
+ const needHandleClickEventList: {
162
+ type: PopsHandlerEventConfig["type"];
163
+ ele: HTMLElement;
164
+ }[] = [
161
165
  {
162
166
  type: "close",
163
167
  ele: $headerCloseBtn,
@@ -176,20 +180,16 @@ export const PopsDrawer = {
176
180
  },
177
181
  ];
178
182
  needHandleClickEventList.forEach((item) => {
179
- PopsHandler.handleClickEvent(
180
- item.type as "close" | "cancel" | "ok" | "other",
181
- item.ele,
182
- eventDetails,
183
- (_eventDetails_) => {
184
- if (typeof (config.btn as any)[item.type].callback === "function") {
185
- (config.btn as any)[item.type].callback(_eventDetails_);
186
- }
183
+ PopsHandler.handleClickEvent(item.type, item.ele, evtConfig, (details, event) => {
184
+ const callback = config.btn[item.type].callback;
185
+ if (typeof callback === "function") {
186
+ callback(details, event);
187
187
  }
188
- );
188
+ });
189
189
  });
190
190
 
191
191
  /* 先隐藏,然后根据config.openDelay来显示 */
192
- elementList.forEach((element) => {
192
+ $elList.forEach((element) => {
193
193
  element.style.setProperty("display", "none");
194
194
  if (["top"].includes(config.direction)) {
195
195
  $pops.style.setProperty("height", config.size.toString());
@@ -212,7 +212,7 @@ export const PopsDrawer = {
212
212
  });
213
213
  /* 创建到页面中 */
214
214
 
215
- popsDOMUtils.append($shadowRoot, elementList);
215
+ popsDOMUtils.append($shadowRoot, $elList);
216
216
  if (typeof config.beforeAppendToPageCallBack === "function") {
217
217
  config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
218
218
  }
@@ -236,7 +236,7 @@ export const PopsDrawer = {
236
236
  $shadowContainer: $shadowContainer,
237
237
  $shadowRoot: $shadowRoot,
238
238
  });
239
- const result = PopsHandler.handleResultDetails(eventDetails);
239
+ const result = PopsHandler.handleResultConfig(evtConfig);
240
240
  return result;
241
241
  },
242
242
  };
@@ -252,41 +252,41 @@ export const PopsFolder = {
252
252
  /**
253
253
  * 遮罩层元素
254
254
  */
255
- let $mask: HTMLDivElement | null = null;
255
+ let $mask: HTMLDivElement | undefined = void 0;
256
256
  /**
257
257
  * 已创建的元素列表
258
258
  */
259
- const elementList: HTMLElement[] = [$anim];
259
+ const $elList: HTMLElement[] = [$anim];
260
260
 
261
261
  if (config.mask.enable) {
262
- const _handleMask_ = PopsHandler.handleMask({
262
+ const handleMask = PopsHandler.handleMask({
263
263
  type: popsType,
264
264
  guid: guid,
265
265
  config: config,
266
266
  animElement: $anim,
267
267
  maskHTML: maskHTML,
268
268
  });
269
- $mask = _handleMask_.maskElement;
270
- elementList.push($mask);
269
+ $mask = handleMask.maskElement;
270
+ $elList.push($mask);
271
271
  }
272
272
  /* 事件 */
273
- const eventDetails = PopsHandler.handleEventDetails(
273
+ const evtConfig = PopsHandler.handleEventConfig(
274
+ config,
274
275
  guid,
275
276
  $shadowContainer,
276
277
  $shadowRoot,
277
278
  popsType,
278
279
  $anim,
279
280
  $pops,
280
- $mask!,
281
- config
281
+ $mask
282
282
  );
283
- PopsHandler.handleClickEvent("close", $btnCloseBtn, eventDetails, config.btn.close!.callback!);
284
- PopsHandler.handleClickEvent("ok", btnOkElement, eventDetails, config.btn.ok!.callback!);
285
- PopsHandler.handleClickEvent("cancel", btnCancelElement, eventDetails, config.btn.cancel!.callback!);
286
- PopsHandler.handleClickEvent("other", btnOtherElement, eventDetails, config.btn.other!.callback!);
283
+ PopsHandler.handleClickEvent("close", $btnCloseBtn, evtConfig, config.btn.close.callback);
284
+ PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok.callback);
285
+ PopsHandler.handleClickEvent("cancel", btnCancelElement, evtConfig, config.btn.cancel.callback);
286
+ PopsHandler.handleClickEvent("other", btnOtherElement, evtConfig, config.btn.other.callback);
287
287
  /* 创建到页面中 */
288
288
 
289
- popsDOMUtils.append($shadowRoot, elementList);
289
+ popsDOMUtils.append($shadowRoot, $elList);
290
290
  if (typeof config.beforeAppendToPageCallBack === "function") {
291
291
  config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
292
292
  }
@@ -923,7 +923,7 @@ export const PopsFolder = {
923
923
  $shadowContainer: $shadowContainer,
924
924
  $shadowRoot: $shadowRoot,
925
925
  });
926
- const result = PopsHandler.handleResultDetails(eventDetails);
926
+ const result = PopsHandler.handleResultConfig(evtConfig);
927
927
  return result;
928
928
  },
929
929
  };