@whitesev/pops 3.3.5 → 4.0.1

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 (84) hide show
  1. package/dist/index.amd.js +13099 -12934
  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 +752 -587
  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 +752 -587
  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 +13100 -12935
  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 +13103 -12938
  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 +13102 -12937
  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 +131 -77
  26. package/dist/types/src/PopsAnimation.d.ts +33 -0
  27. package/dist/types/src/PopsIcon.d.ts +1 -1
  28. package/dist/types/src/components/alert/index.d.ts +3 -1
  29. package/dist/types/src/components/confirm/index.d.ts +3 -1
  30. package/dist/types/src/components/drawer/index.d.ts +3 -1
  31. package/dist/types/src/components/folder/index.d.ts +3 -1
  32. package/dist/types/src/components/iframe/index.d.ts +6 -1
  33. package/dist/types/src/components/iframe/types/index.d.ts +4 -2
  34. package/dist/types/src/components/loading/index.d.ts +3 -1
  35. package/dist/types/src/components/panel/handlerComponents.d.ts +4 -1
  36. package/dist/types/src/components/panel/index.d.ts +2 -16
  37. package/dist/types/src/components/panel/types/index.d.ts +7 -2
  38. package/dist/types/src/components/prompt/index.d.ts +3 -1
  39. package/dist/types/src/components/searchSuggestion/index.d.ts +4 -1
  40. package/dist/types/src/components/tooltip/index.d.ts +5 -1
  41. package/dist/types/src/config/GlobalConfig.d.ts +63 -23
  42. package/dist/types/src/event/EventEmiter.d.ts +33 -0
  43. package/dist/types/src/handler/PopsHandler.d.ts +16 -11
  44. package/dist/types/src/handler/PopsInstHandler.d.ts +67 -0
  45. package/dist/types/src/types/EventEmitter.d.ts +18 -0
  46. package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +4 -0
  47. package/dist/types/src/types/button.d.ts +2 -1
  48. package/dist/types/src/types/event.d.ts +6 -2
  49. package/dist/types/src/types/inst.d.ts +4 -4
  50. package/dist/types/src/utils/PopsDOMUtils.d.ts +0 -16
  51. package/dist/types/src/utils/PopsInstanceUtils.d.ts +1 -89
  52. package/dist/types/src/utils/PopsUtils.d.ts +57 -0
  53. package/package.json +3 -3
  54. package/src/Pops.ts +7 -2
  55. package/src/PopsAnimation.ts +126 -0
  56. package/src/components/alert/index.ts +9 -9
  57. package/src/components/confirm/index.ts +9 -9
  58. package/src/components/drawer/index.ts +12 -9
  59. package/src/components/folder/index.ts +9 -8
  60. package/src/components/iframe/index.ts +18 -12
  61. package/src/components/iframe/types/index.ts +10 -8
  62. package/src/components/loading/index.ts +12 -6
  63. package/src/components/panel/defaultConfig.ts +1 -0
  64. package/src/components/panel/handlerComponents.ts +41 -111
  65. package/src/components/panel/index.ts +34 -28
  66. package/src/components/panel/types/index.ts +7 -2
  67. package/src/components/prompt/index.ts +9 -8
  68. package/src/components/rightClickMenu/index.ts +17 -14
  69. package/src/components/searchSuggestion/index.ts +5 -1
  70. package/src/components/tooltip/index.ts +20 -10
  71. package/src/config/GlobalConfig.ts +21 -14
  72. package/src/css/index.css +2 -0
  73. package/src/event/EventEmiter.ts +95 -0
  74. package/src/handler/PopsElementHandler.ts +8 -6
  75. package/src/handler/PopsHandler.ts +65 -48
  76. package/src/handler/PopsInstHandler.ts +557 -0
  77. package/src/types/EventEmitter.d.ts +18 -0
  78. package/src/types/PopsDOMUtilsEventType.d.ts +4 -0
  79. package/src/types/button.d.ts +2 -1
  80. package/src/types/event.d.ts +6 -2
  81. package/src/types/inst.d.ts +4 -4
  82. package/src/utils/PopsDOMUtils.ts +1 -40
  83. package/src/utils/PopsInstanceUtils.ts +10 -639
  84. package/src/utils/PopsUtils.ts +194 -0
@@ -29,4 +29,130 @@ export const PopsAnimation = {
29
29
  hasAnim(name: string) {
30
30
  return Object.prototype.hasOwnProperty.call(this.$data, name);
31
31
  },
32
+ /**
33
+ * 带动画的进入元素
34
+ * @param $el 当前元素
35
+ * @param $next 切换的元素
36
+ * @param option 配置
37
+ */
38
+ createSwitchElementWithAnimation(
39
+ $el: HTMLElement,
40
+ $next: HTMLElement,
41
+ option: {
42
+ /**
43
+ * 是否使用动画
44
+ * @default true
45
+ */
46
+ useAnimation?: boolean;
47
+ /**
48
+ * 动画配置
49
+ *
50
+ * + `duration`: 默认`220`
51
+ * + `easing`: 默认`"ease-in-out"`
52
+ */
53
+ animOptions?: KeyframeAnimationOptions;
54
+ /** 为$next内部添加元素 */
55
+ enterToAddElementCallback: () => IPromise<void>;
56
+ /** 退出时移除$next元素 */
57
+ exitToRemoveElementCallback?: () => IPromise<void>;
58
+ }
59
+ ) {
60
+ const animOptions: KeyframeAnimationOptions = {
61
+ // 150 220 300
62
+ duration: 220,
63
+ easing: "ease-in-out",
64
+ ...(option.animOptions ?? {}),
65
+ };
66
+ if (option.useAnimation == null) {
67
+ option.useAnimation = true;
68
+ }
69
+ return {
70
+ /**
71
+ * 进入
72
+ */
73
+ async enter() {
74
+ const transitionEndCallback = async () => {
75
+ // 先直接隐藏旧的容器
76
+ popsDOMUtils.cssHide($el, true);
77
+ // 添加元素
78
+ await option.enterToAddElementCallback();
79
+ };
80
+ // 进入下一层
81
+ if (option.useAnimation && typeof document.startViewTransition == "function") {
82
+ // 处理添加的元素的动画
83
+ const transition = document.startViewTransition(transitionEndCallback);
84
+ await transition.ready;
85
+ await $next.animate(
86
+ // 从右向左移入(进入动画)
87
+ [
88
+ {
89
+ // from
90
+ transform: "translateX(100%)",
91
+ },
92
+ {
93
+ // to
94
+ transform: "translateX(0)",
95
+ },
96
+ ],
97
+ animOptions
98
+ ).finished;
99
+ await transition.finished;
100
+ } else {
101
+ await transitionEndCallback();
102
+ }
103
+ },
104
+ /**
105
+ * 退出
106
+ */
107
+ async exit() {
108
+ // 返回上一层菜单
109
+ const transitionEndCallback = async () => {
110
+ // 显示上层菜单
111
+ popsDOMUtils.cssShow($el);
112
+ // 移除下一层的菜单
113
+ $next.remove();
114
+ if (typeof option.exitToRemoveElementCallback === "function") {
115
+ await option.exitToRemoveElementCallback();
116
+ }
117
+ };
118
+ if (option.useAnimation && typeof document.startViewTransition == "function") {
119
+ const leaveTransition = document.startViewTransition(transitionEndCallback);
120
+ await leaveTransition.ready;
121
+ await Promise.all([
122
+ // 从原位置向右移出
123
+ $next.animate(
124
+ [
125
+ {
126
+ // from
127
+ transform: "translateX(0)",
128
+ },
129
+ {
130
+ // to
131
+ transform: "translateX(100%)",
132
+ },
133
+ ],
134
+ animOptions
135
+ ).finished,
136
+ // 从最左边向右移入
137
+ $el.animate(
138
+ [
139
+ {
140
+ // from
141
+ transform: "translateX(-100%)",
142
+ },
143
+ {
144
+ // to
145
+ transform: "translateX(0)",
146
+ },
147
+ ],
148
+ animOptions
149
+ ).finished,
150
+ ]);
151
+ await leaveTransition.finished;
152
+ } else {
153
+ await transitionEndCallback();
154
+ }
155
+ },
156
+ };
157
+ },
32
158
  };
@@ -1,10 +1,12 @@
1
1
  import { GlobalConfig } from "../../config/GlobalConfig";
2
+ import { EventEmiter } from "../../event/EventEmiter";
2
3
  import { PopsElementHandler } from "../../handler/PopsElementHandler";
3
4
  import { PopsHandler } from "../../handler/PopsHandler";
5
+ import { PopsInstHandler } from "../../handler/PopsInstHandler";
4
6
  import { PopsCSS } from "../../PopsCSS";
7
+ import type { EventMap } from "../../types/EventEmitter";
5
8
  import type { PopsType } from "../../types/main";
6
9
  import { popsDOMUtils } from "../../utils/PopsDOMUtils";
7
- import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
8
10
  import { popsUtils } from "../../utils/PopsUtils";
9
11
  import { PopsAlertDefaultConfig } from "./defaultConfig";
10
12
  import type { PopsAlertConfig } from "./types";
@@ -14,6 +16,7 @@ export const PopsAlert = {
14
16
  const guid = popsUtils.getRandomGUID();
15
17
  // 设置当前类型
16
18
  const popsType: PopsType = "alert";
19
+ const emitter = new EventEmiter<EventMap>(popsType);
17
20
 
18
21
  let config = PopsAlertDefaultConfig();
19
22
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
@@ -53,7 +56,7 @@ export const PopsAlert = {
53
56
  ]);
54
57
 
55
58
  // 先把z-index提取出来
56
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
59
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
57
60
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
58
61
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
59
62
  const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
@@ -116,6 +119,7 @@ export const PopsAlert = {
116
119
  popsType,
117
120
  $anim,
118
121
  $pops,
122
+ emitter,
119
123
  $mask
120
124
  );
121
125
  const result = PopsHandler.handleResultConfig(evtConfig);
@@ -125,12 +129,8 @@ export const PopsAlert = {
125
129
  PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok?.callback);
126
130
 
127
131
  // 创建到页面中
128
-
129
132
  popsDOMUtils.append($shadowRoot, $elList);
130
- if (typeof config.beforeAppendToPageCallBack === "function") {
131
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
132
- }
133
-
133
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
134
134
  popsDOMUtils.appendBody($shadowContainer);
135
135
  if ($mask != null) {
136
136
  // 添加遮罩层
@@ -145,11 +145,11 @@ export const PopsAlert = {
145
145
  $shadowContainer: $shadowContainer,
146
146
  $shadowRoot: $shadowRoot,
147
147
  config: config,
148
- destory: result.close,
148
+ emitter,
149
149
  });
150
150
  // 拖拽
151
151
  if (config.drag) {
152
- PopsInstanceUtils.drag($pops!, {
152
+ PopsInstHandler.drag($pops!, {
153
153
  dragElement: $title!,
154
154
  limit: config.dragLimit,
155
155
  extraDistance: config.dragExtraDistance!,
@@ -1,10 +1,12 @@
1
1
  import { GlobalConfig } from "../../config/GlobalConfig";
2
+ import { EventEmiter } from "../../event/EventEmiter";
2
3
  import { PopsElementHandler } from "../../handler/PopsElementHandler";
3
4
  import { PopsHandler } from "../../handler/PopsHandler";
5
+ import { PopsInstHandler } from "../../handler/PopsInstHandler";
4
6
  import { PopsCSS } from "../../PopsCSS";
7
+ import type { EventMap } from "../../types/EventEmitter";
5
8
  import type { PopsType } from "../../types/main";
6
9
  import { popsDOMUtils } from "../../utils/PopsDOMUtils";
7
- import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
8
10
  import { popsUtils } from "../../utils/PopsUtils";
9
11
  import { PopsConfirmDefaultConfig } from "./defaultConfig";
10
12
  import type { PopsConfirmConfig } from "./types";
@@ -14,6 +16,7 @@ export const PopsConfirm = {
14
16
  const guid = popsUtils.getRandomGUID();
15
17
  // 设置当前类型
16
18
  const popsType: PopsType = "confirm";
19
+ const emitter = new EventEmiter<EventMap>(popsType);
17
20
 
18
21
  let config = PopsConfirmDefaultConfig();
19
22
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
@@ -53,7 +56,7 @@ export const PopsConfirm = {
53
56
  ]);
54
57
 
55
58
  // 先把z-index提取出来
56
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
59
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
57
60
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
58
61
 
59
62
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
@@ -121,6 +124,7 @@ export const PopsConfirm = {
121
124
  popsType,
122
125
  $anim,
123
126
  $pops,
127
+ emitter,
124
128
  $mask
125
129
  );
126
130
  const result = PopsHandler.handleResultConfig(evtConfig);
@@ -130,12 +134,8 @@ export const PopsConfirm = {
130
134
  PopsHandler.handleClickEvent("other", $btnOther, evtConfig, config.btn.other.callback);
131
135
 
132
136
  // 创建到页面中
133
-
134
137
  popsDOMUtils.append($shadowRoot, $elList);
135
- if (typeof config.beforeAppendToPageCallBack === "function") {
136
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
137
- }
138
-
138
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
139
139
  popsDOMUtils.appendBody($shadowContainer);
140
140
  if ($mask != null) {
141
141
  $anim.after($mask);
@@ -148,11 +148,11 @@ export const PopsConfirm = {
148
148
  $shadowContainer: $shadowContainer,
149
149
  $shadowRoot: $shadowRoot,
150
150
  config: config,
151
- destory: result.close,
151
+ emitter,
152
152
  });
153
153
  // 拖拽
154
154
  if (config.drag) {
155
- PopsInstanceUtils.drag($pops!, {
155
+ PopsInstHandler.drag($pops!, {
156
156
  dragElement: $title!,
157
157
  limit: config.dragLimit,
158
158
  extraDistance: config.dragExtraDistance,
@@ -1,8 +1,10 @@
1
1
  import { GlobalConfig } from "../../config/GlobalConfig";
2
+ import { EventEmiter } from "../../event/EventEmiter";
2
3
  import { PopsElementHandler } from "../../handler/PopsElementHandler";
3
4
  import { PopsHandler } from "../../handler/PopsHandler";
4
5
  import { PopsCSS } from "../../PopsCSS";
5
6
  import type { PopsHandlerEventConfig } from "../../types/event";
7
+ import type { EventMap } from "../../types/EventEmitter";
6
8
  import type { PopsType } from "../../types/main";
7
9
  import { popsDOMUtils } from "../../utils/PopsDOMUtils";
8
10
  import { popsUtils } from "../../utils/PopsUtils";
@@ -14,12 +16,12 @@ export const PopsDrawer = {
14
16
  const guid = popsUtils.getRandomGUID();
15
17
  // 设置当前类型
16
18
  const popsType: PopsType = "drawer";
19
+ const emitter = new EventEmiter<EventMap>(popsType);
17
20
 
18
21
  let config = PopsDrawerDefaultConfig();
19
22
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
20
23
  config = popsUtils.assign(config, __config__);
21
24
  config = PopsHandler.handleOnly(popsType, config);
22
-
23
25
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
24
26
  PopsHandler.handleInit($shadowRoot, [
25
27
  {
@@ -53,7 +55,7 @@ export const PopsDrawer = {
53
55
  ]);
54
56
 
55
57
  // 先把z-index提取出来
56
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
58
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
57
59
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
58
60
 
59
61
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
@@ -126,6 +128,7 @@ export const PopsDrawer = {
126
128
  popsType,
127
129
  $anim,
128
130
  $pops,
131
+ emitter,
129
132
  $mask
130
133
  );
131
134
  const result = PopsHandler.handleResultConfig(evtConfig);
@@ -155,13 +158,16 @@ export const PopsDrawer = {
155
158
 
156
159
  // 按下Esc键触发关闭
157
160
  if (config.closeOnPressEscape) {
158
- PopsHandler.handleKeyboardEvent("Escape", [], function () {
161
+ const listener = PopsHandler.handleKeyboardEvent("Escape", [], function () {
159
162
  evtConfig.close();
160
163
  });
164
+ emitter.on("pops:destory", () => {
165
+ listener.off();
166
+ });
161
167
  }
162
168
  // 待处理的点击事件列表
163
169
  const needHandleClickEventList: {
164
- type: PopsHandlerEventConfig["type"];
170
+ type: PopsHandlerEventConfig<typeof emitter>["type"];
165
171
  ele: HTMLElement;
166
172
  }[] = [
167
173
  {
@@ -215,10 +221,7 @@ export const PopsDrawer = {
215
221
  // 创建到页面中
216
222
 
217
223
  popsDOMUtils.append($shadowRoot, $elList);
218
- if (typeof config.beforeAppendToPageCallBack === "function") {
219
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
220
- }
221
-
224
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
222
225
  popsDOMUtils.appendBody($shadowContainer);
223
226
  popsUtils.setTimeout(() => {
224
227
  popsUtils.setTimeout(() => {
@@ -238,7 +241,7 @@ export const PopsDrawer = {
238
241
  $shadowContainer: $shadowContainer,
239
242
  $shadowRoot: $shadowRoot,
240
243
  config: config,
241
- destory: result.close,
244
+ emitter: emitter,
242
245
  });
243
246
  return result;
244
247
  },
@@ -1,10 +1,12 @@
1
1
  import { GlobalConfig } from "../../config/GlobalConfig";
2
+ import { EventEmiter } from "../../event/EventEmiter";
2
3
  import { PopsElementHandler } from "../../handler/PopsElementHandler";
3
4
  import { PopsHandler } from "../../handler/PopsHandler";
5
+ import { PopsInstHandler } from "../../handler/PopsInstHandler";
4
6
  import { PopsCSS } from "../../PopsCSS";
7
+ import type { EventMap } from "../../types/EventEmitter";
5
8
  import type { PopsType } from "../../types/main";
6
9
  import { popsDOMUtils } from "../../utils/PopsDOMUtils";
7
- import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
8
10
  import { PopsSafeUtils } from "../../utils/PopsSafeUtils";
9
11
  import { popsUtils } from "../../utils/PopsUtils";
10
12
  import { PopsLoading } from "../loading";
@@ -17,6 +19,7 @@ export const PopsFolder = {
17
19
  const guid = popsUtils.getRandomGUID();
18
20
  // 设置当前类型
19
21
  const popsType: PopsType = "folder";
22
+ const emitter = new EventEmiter<EventMap>(popsType);
20
23
 
21
24
  let config = PopsFolderDefaultConfig();
22
25
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
@@ -110,7 +113,7 @@ export const PopsFolder = {
110
113
  }
111
114
 
112
115
  // 先把z-index提取出来
113
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
116
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
114
117
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
115
118
 
116
119
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
@@ -278,6 +281,7 @@ export const PopsFolder = {
278
281
  popsType,
279
282
  $anim,
280
283
  $pops,
284
+ emitter,
281
285
  $mask
282
286
  );
283
287
  const result = PopsHandler.handleResultConfig(evtConfig);
@@ -288,10 +292,7 @@ export const PopsFolder = {
288
292
  // 创建到页面中
289
293
 
290
294
  popsDOMUtils.append($shadowRoot, $elList);
291
- if (typeof config.beforeAppendToPageCallBack === "function") {
292
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
293
- }
294
-
295
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
295
296
  popsDOMUtils.appendBody($shadowContainer);
296
297
  if ($mask != null) {
297
298
  $anim.after($mask);
@@ -955,7 +956,7 @@ export const PopsFolder = {
955
956
  Reflect.set($pops, "data-pops-folder", popsFolder);
956
957
  // 拖拽
957
958
  if (config.drag) {
958
- PopsInstanceUtils.drag($pops, {
959
+ PopsInstHandler.drag($pops, {
959
960
  dragElement: $title,
960
961
  limit: config.dragLimit,
961
962
  extraDistance: config.dragExtraDistance,
@@ -971,7 +972,7 @@ export const PopsFolder = {
971
972
  $shadowContainer: $shadowContainer,
972
973
  $shadowRoot: $shadowRoot,
973
974
  config: config,
974
- destory: result.close,
975
+ emitter,
975
976
  });
976
977
  return result;
977
978
  },
@@ -1,11 +1,12 @@
1
1
  import { GlobalConfig } from "../../config/GlobalConfig";
2
+ import { EventEmiter } from "../../event/EventEmiter";
2
3
  import { PopsElementHandler } from "../../handler/PopsElementHandler";
3
4
  import { PopsHandler } from "../../handler/PopsHandler";
5
+ import { PopsInstHandler } from "../../handler/PopsInstHandler";
4
6
  import { PopsCSS } from "../../PopsCSS";
5
7
  import { PopsInstData } from "../../PopsInst";
6
8
  import type { PopsType } from "../../types/main";
7
9
  import { popsDOMUtils } from "../../utils/PopsDOMUtils";
8
- import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
9
10
  import { popsUtils } from "../../utils/PopsUtils";
10
11
  import { PopsIframeDefaultConfig } from "./defaultConfig";
11
12
  import type { PopsIframeClickEventConfig, PopsIframeConfig } from "./types";
@@ -15,7 +16,11 @@ export const PopsIframe = {
15
16
  const guid = popsUtils.getRandomGUID();
16
17
  // 设置当前类型
17
18
  const popsType: PopsType = "iframe";
18
-
19
+ const emitter = new EventEmiter<{
20
+ "pops:iframe-min": (eventConfig: PopsIframeClickEventConfig, event: MouseEvent | PointerEvent) => void;
21
+ "pops:iframe-mise": (eventConfig: PopsIframeClickEventConfig, event: MouseEvent | PointerEvent) => void;
22
+ "pops:iframe-max": (eventConfig: PopsIframeClickEventConfig, event: MouseEvent | PointerEvent) => void;
23
+ }>(popsType);
19
24
  let config = PopsIframeDefaultConfig();
20
25
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
21
26
  config = popsUtils.assign(config, __config__);
@@ -55,7 +60,7 @@ export const PopsIframe = {
55
60
  const maskExtraStyle = config.animation != null && <string>config.animation != "" ? "position:absolute;" : "";
56
61
 
57
62
  // 先把z-index提取出来
58
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
63
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
59
64
  const maskHTML = PopsElementHandler.createMask(guid, zIndex, maskExtraStyle);
60
65
 
61
66
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
@@ -140,10 +145,11 @@ export const PopsIframe = {
140
145
  popsType,
141
146
  $anim,
142
147
  $pops,
148
+ emitter,
143
149
  $mask
144
- ) as PopsIframeClickEventConfig;
150
+ ) as PopsIframeClickEventConfig<typeof emitter>;
145
151
  // 赋值额外的$iframe参数
146
- evtConfig.$iframe = $iframe!;
152
+ evtConfig.$iframe = $iframe;
147
153
 
148
154
  const result = PopsHandler.handleResultConfig(evtConfig);
149
155
 
@@ -172,17 +178,14 @@ export const PopsIframe = {
172
178
  // 创建到页面中
173
179
 
174
180
  popsDOMUtils.append($shadowRoot, $elList);
175
- if (typeof config.beforeAppendToPageCallBack === "function") {
176
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
177
- }
178
-
181
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
179
182
  $iframeContainer.appendChild($shadowContainer);
180
183
  if ($mask != null) {
181
184
  $anim.after($mask);
182
185
  }
183
186
  // 拖拽
184
187
  if (config.drag) {
185
- PopsInstanceUtils.drag($pops!, {
188
+ PopsInstHandler.drag($pops!, {
186
189
  dragElement: $title!,
187
190
  limit: config.dragLimit,
188
191
  extraDistance: config.dragExtraDistance,
@@ -217,6 +220,7 @@ export const PopsIframe = {
217
220
  if (typeof config?.btn?.min?.callback === "function") {
218
221
  config.btn.min.callback(evtConfig, event);
219
222
  }
223
+ emitter.emit("pops:iframe-min", evtConfig, event);
220
224
  },
221
225
  {
222
226
  capture: true,
@@ -251,6 +255,7 @@ export const PopsIframe = {
251
255
  if (typeof config?.btn?.max?.callback === "function") {
252
256
  config.btn.max.callback(evtConfig, event);
253
257
  }
258
+ emitter.emit("pops:iframe-max", evtConfig, event);
254
259
  },
255
260
  {
256
261
  capture: true,
@@ -293,6 +298,7 @@ export const PopsIframe = {
293
298
  if (typeof config?.btn?.mise?.callback === "function") {
294
299
  config.btn.mise.callback(evtConfig, event);
295
300
  }
301
+ emitter.emit("pops:iframe-mise", evtConfig, event);
296
302
  },
297
303
  {
298
304
  capture: true,
@@ -305,7 +311,7 @@ export const PopsIframe = {
305
311
  async (event) => {
306
312
  event.preventDefault();
307
313
  event.stopPropagation();
308
- await PopsInstanceUtils.removeInstance([PopsInstData.iframe], guid, false);
314
+ await PopsInstHandler.removeInstance([PopsInstData.iframe], guid, false);
309
315
  if (typeof config?.btn?.close?.callback === "function") {
310
316
  config.btn.close.callback(evtConfig, event);
311
317
  }
@@ -323,7 +329,7 @@ export const PopsIframe = {
323
329
  $shadowContainer: $shadowContainer,
324
330
  $shadowRoot: $shadowRoot,
325
331
  config: config,
326
- destory: result.close,
332
+ emitter,
327
333
  });
328
334
  return result;
329
335
  },
@@ -1,16 +1,18 @@
1
- import type { PopsTitleConfig, PopsDragConfig, PopsGeneralConfig } from "../../../types/components";
2
-
1
+ import type { EventEmiter } from "../../../event/EventEmiter";
2
+ import type { PopsDragConfig, PopsGeneralConfig, PopsTitleConfig } from "../../../types/components";
3
3
  import type { PopsEventConfig } from "../../../types/event";
4
+ import type { CustomEventMap } from "../../../types/EventEmitter";
4
5
 
5
6
  /**
6
7
  * pops.iframe的按钮点击事件回调的配置参数
7
8
  */
8
- export type PopsIframeClickEventConfig = PopsEventConfig & {
9
- /**
10
- * iframe元素
11
- */
12
- $iframe: HTMLIFrameElement;
13
- };
9
+ export type PopsIframeClickEventConfig<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>> =
10
+ PopsEventConfig<E> & {
11
+ /**
12
+ * iframe元素
13
+ */
14
+ $iframe: HTMLIFrameElement;
15
+ };
14
16
 
15
17
  /**
16
18
  * pops.iframe
@@ -1,7 +1,9 @@
1
1
  import { GlobalConfig } from "../../config/GlobalConfig";
2
+ import { EventEmiter } from "../../event/EventEmiter";
2
3
  import { PopsElementHandler } from "../../handler/PopsElementHandler";
3
4
  import { PopsHandler } from "../../handler/PopsHandler";
4
5
  import { PopsCSS } from "../../PopsCSS";
6
+ import type { EventMap } from "../../types/EventEmitter";
5
7
  import { popsDOMUtils } from "../../utils/PopsDOMUtils";
6
8
  import { popsUtils } from "../../utils/PopsUtils";
7
9
  import { PopsLoadingDefaultConfig } from "./defaultConfig";
@@ -12,14 +14,15 @@ export const PopsLoading = {
12
14
  const guid = popsUtils.getRandomGUID();
13
15
  // 设置当前类型
14
16
  const PopsType = "loading";
17
+ const emitter = new EventEmiter<EventMap>(PopsType);
18
+
15
19
  let config = PopsLoadingDefaultConfig();
16
20
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
17
21
  config = popsUtils.assign(config, __config__);
18
-
19
22
  config = PopsHandler.handleOnly(PopsType, config);
20
23
 
21
24
  // 先把z-index提取出来
22
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
25
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
23
26
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
24
27
 
25
28
  const { contentPStyle } = PopsElementHandler.createContentStyle("loading", config);
@@ -76,17 +79,20 @@ export const PopsLoading = {
76
79
  $mask = handleMask.maskElement;
77
80
  $elList.push($mask);
78
81
  }
79
- const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, $mask);
82
+ const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, emitter, $mask);
80
83
  popsDOMUtils.append(config.$parent, $elList);
81
84
  if ($mask != null) {
82
85
  $anim.after($mask);
83
86
  }
84
- // @ts-ignore
85
87
  PopsHandler.handlePush(PopsType, {
88
+ $shadowContainer: $pops,
89
+ $shadowRoot: $pops,
86
90
  guid: guid,
87
91
  $anim: $anim,
88
- $pops: $pops!,
89
- $mask: $mask!,
92
+ $pops: $pops,
93
+ $mask: $mask,
94
+ emitter: emitter,
95
+ config: config,
90
96
  });
91
97
 
92
98
  if (config.isAbsolute) {
@@ -867,5 +867,6 @@ export const PopsPanelDefaultConfig = (): DeepRequired<PopsPanelConfig> => {
867
867
  darkStyle: null,
868
868
  beforeAppendToPageCallBack() {},
869
869
  stopKeyDownEventPropagation: true,
870
+ listenEscapeKeyUpToExitDeepMenu: true,
870
871
  };
871
872
  };