@whitesev/pops 2.4.6 → 2.5.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 (154) hide show
  1. package/dist/index.amd.js +578 -571
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.amd.min.js +2 -0
  4. package/dist/index.amd.min.js.map +1 -0
  5. package/dist/index.cjs.js +578 -571
  6. package/dist/index.cjs.js.map +1 -1
  7. package/dist/index.cjs.min.js +2 -0
  8. package/dist/index.cjs.min.js.map +1 -0
  9. package/dist/index.esm.js +578 -571
  10. package/dist/index.esm.js.map +1 -1
  11. package/dist/index.esm.min.js +2 -0
  12. package/dist/index.esm.min.js.map +1 -0
  13. package/dist/index.iife.js +578 -571
  14. package/dist/index.iife.js.map +1 -1
  15. package/dist/index.iife.min.js +2 -0
  16. package/dist/index.iife.min.js.map +1 -0
  17. package/dist/index.system.js +578 -571
  18. package/dist/index.system.js.map +1 -1
  19. package/dist/index.system.min.js +2 -0
  20. package/dist/index.system.min.js.map +1 -0
  21. package/dist/index.umd.js +578 -571
  22. package/dist/index.umd.js.map +1 -1
  23. package/dist/index.umd.min.js +2 -0
  24. package/dist/index.umd.min.js.map +1 -0
  25. package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +252 -252
  26. package/dist/types/src/types/animation.d.ts +19 -19
  27. package/dist/types/src/types/button.d.ts +187 -187
  28. package/dist/types/src/types/components.d.ts +210 -210
  29. package/dist/types/src/types/event.d.ts +63 -63
  30. package/dist/types/src/types/global.d.ts +25 -25
  31. package/dist/types/src/types/icon.d.ts +32 -32
  32. package/dist/types/src/types/inst.d.ts +24 -24
  33. package/dist/types/src/types/main.d.ts +111 -111
  34. package/dist/types/src/types/mask.d.ts +49 -49
  35. package/dist/types/src/types/position.d.ts +60 -60
  36. package/index.ts +3 -0
  37. package/package.json +5 -2
  38. package/src/Pops.ts +206 -0
  39. package/src/PopsAnimation.ts +32 -0
  40. package/src/PopsCSS.ts +51 -0
  41. package/src/PopsCore.ts +64 -0
  42. package/src/PopsIcon.ts +95 -0
  43. package/src/PopsInst.ts +21 -0
  44. package/src/components/alert/config.ts +62 -0
  45. package/src/components/alert/index.css +0 -0
  46. package/src/components/alert/index.ts +163 -0
  47. package/src/components/alert/types/index.ts +23 -0
  48. package/src/components/confirm/config.ts +90 -0
  49. package/src/components/confirm/index.css +0 -0
  50. package/src/components/confirm/index.ts +166 -0
  51. package/src/components/confirm/types/index.ts +17 -0
  52. package/src/components/drawer/config.ts +89 -0
  53. package/src/components/drawer/index.css +37 -0
  54. package/src/components/drawer/index.ts +237 -0
  55. package/src/components/drawer/types/index.ts +61 -0
  56. package/src/components/folder/config.ts +147 -0
  57. package/src/components/folder/folderIcon.ts +28 -0
  58. package/src/components/folder/index.css +303 -0
  59. package/src/components/folder/index.ts +929 -0
  60. package/src/components/folder/types/index.ts +97 -0
  61. package/src/components/iframe/config.ts +60 -0
  62. package/src/components/iframe/index.css +76 -0
  63. package/src/components/iframe/index.ts +334 -0
  64. package/src/components/iframe/types/index.ts +139 -0
  65. package/src/components/loading/config.ts +29 -0
  66. package/src/components/loading/index.css +66 -0
  67. package/src/components/loading/index.ts +99 -0
  68. package/src/components/loading/types/index.ts +34 -0
  69. package/src/components/panel/config.ts +519 -0
  70. package/src/components/panel/handlerComponents.ts +2900 -0
  71. package/src/components/panel/index.css +1222 -0
  72. package/src/components/panel/index.ts +207 -0
  73. package/src/components/panel/types/components-button.ts +68 -0
  74. package/src/components/panel/types/components-common.ts +50 -0
  75. package/src/components/panel/types/components-deepMenu.ts +84 -0
  76. package/src/components/panel/types/components-forms.ts +44 -0
  77. package/src/components/panel/types/components-input.ts +78 -0
  78. package/src/components/panel/types/components-own.ts +30 -0
  79. package/src/components/panel/types/components-select.ts +93 -0
  80. package/src/components/panel/types/components-selectMultiple.ts +130 -0
  81. package/src/components/panel/types/components-slider.ts +77 -0
  82. package/src/components/panel/types/components-switch.ts +56 -0
  83. package/src/components/panel/types/components-textarea.ts +68 -0
  84. package/src/components/panel/types/index.ts +177 -0
  85. package/src/components/prompt/config.ts +94 -0
  86. package/src/components/prompt/index.css +34 -0
  87. package/src/components/prompt/index.ts +216 -0
  88. package/src/components/prompt/types/index.ts +55 -0
  89. package/src/components/rightClickMenu/config.ts +98 -0
  90. package/src/components/rightClickMenu/index.css +112 -0
  91. package/src/components/rightClickMenu/index.ts +602 -0
  92. package/src/components/rightClickMenu/types/index.ts +97 -0
  93. package/src/components/searchSuggestion/config.ts +56 -0
  94. package/src/components/searchSuggestion/index.ts +856 -0
  95. package/src/components/searchSuggestion/types/index.ts +239 -0
  96. package/src/components/tooltip/config.ts +34 -0
  97. package/src/components/tooltip/index.css +199 -0
  98. package/src/components/tooltip/index.ts +604 -0
  99. package/src/components/tooltip/types/index.ts +117 -0
  100. package/src/config/CommonCSSClassName.ts +17 -0
  101. package/src/config/GlobalConfig.ts +63 -0
  102. package/src/css/animation.css +987 -0
  103. package/src/css/button.css +551 -0
  104. package/src/css/common.css +48 -0
  105. package/src/css/index.css +253 -0
  106. package/src/css/ninePalaceGridPosition.css +50 -0
  107. package/src/css/scrollbar.css +22 -0
  108. package/src/handler/PopsElementHandler.ts +304 -0
  109. package/src/handler/PopsHandler.ts +589 -0
  110. package/src/svg/arrowLeft.svg +4 -0
  111. package/src/svg/arrowRight.svg +4 -0
  112. package/src/svg/chromeFilled.svg +11 -0
  113. package/src/svg/circleClose.svg +8 -0
  114. package/src/svg/close.svg +5 -0
  115. package/src/svg/cpu.svg +8 -0
  116. package/src/svg/delete.svg +5 -0
  117. package/src/svg/documentCopy.svg +5 -0
  118. package/src/svg/edit.svg +8 -0
  119. package/src/svg/eleme.svg +5 -0
  120. package/src/svg/elemePlus.svg +5 -0
  121. package/src/svg/headset.svg +5 -0
  122. package/src/svg/hide.svg +8 -0
  123. package/src/svg/keyboard.svg +8 -0
  124. package/src/svg/loading.svg +5 -0
  125. package/src/svg/max.svg +5 -0
  126. package/src/svg/min.svg +5 -0
  127. package/src/svg/mise.svg +5 -0
  128. package/src/svg/monitor.svg +5 -0
  129. package/src/svg/next.svg +5 -0
  130. package/src/svg/picture.svg +8 -0
  131. package/src/svg/prev.svg +5 -0
  132. package/src/svg/search.svg +5 -0
  133. package/src/svg/share.svg +5 -0
  134. package/src/svg/upload.svg +5 -0
  135. package/src/svg/videoPause.svg +5 -0
  136. package/src/svg/videoPlay.svg +5 -0
  137. package/src/svg/view.svg +5 -0
  138. package/src/types/PopsDOMUtilsEventType.d.ts +252 -0
  139. package/src/types/animation.d.ts +19 -0
  140. package/src/types/button.d.ts +187 -0
  141. package/src/types/components.d.ts +210 -0
  142. package/src/types/event.d.ts +63 -0
  143. package/src/types/global.d.ts +25 -0
  144. package/src/types/icon.d.ts +32 -0
  145. package/src/types/inst.d.ts +24 -0
  146. package/src/types/main.d.ts +111 -0
  147. package/src/types/mask.d.ts +49 -0
  148. package/src/types/position.d.ts +60 -0
  149. package/src/utils/PopsDOMUtils.ts +2408 -0
  150. package/src/utils/PopsDOMUtilsEventsConfig.ts +4 -0
  151. package/src/utils/PopsInstanceUtils.ts +688 -0
  152. package/src/utils/PopsMathUtils.ts +71 -0
  153. package/src/utils/PopsSafeUtils.ts +22 -0
  154. package/src/utils/PopsUtils.ts +406 -0
@@ -0,0 +1,97 @@
1
+ import type {
2
+ PopsTitleConfig,
3
+ PopsDragConfig,
4
+ PopsCommonConfig,
5
+ PopsMoreButtonConfig,
6
+ } from "../../../types/components";
7
+
8
+ /**
9
+ * pops.folder的folder配置信息
10
+ */
11
+ export interface PopsFolderDataConfig {
12
+ /**
13
+ * 文件/文件夹名
14
+ */
15
+ fileName: string;
16
+ /**
17
+ * 文件大小,如果是文件夹的话,为0
18
+ */
19
+ fileSize: number | string;
20
+ /**
21
+ * 文件类型,如果是文件夹,填入空字符串
22
+ */
23
+ fileType: string;
24
+ /**
25
+ * 创建时间
26
+ */
27
+ createTime: number;
28
+ /**
29
+ * 修改时间(最新时间)
30
+ */
31
+ latestTime: number;
32
+ /**
33
+ * 是否是文件夹
34
+ */
35
+ isFolder: boolean;
36
+ /**
37
+ * 层级
38
+ */
39
+ index: number;
40
+ /**
41
+ * 点击事件
42
+ */
43
+ clickEvent?: (
44
+ event: MouseEvent | PointerEvent,
45
+ config: PopsFolderDataConfig
46
+ ) =>
47
+ | Promise<
48
+ | {
49
+ autoDownload: boolean;
50
+ url: string;
51
+ mode: "a" | "aBlank" | "iframe" | "open" | "openBlank";
52
+ }
53
+ | null
54
+ | undefined
55
+ | void
56
+ | PopsFolderDataConfig[]
57
+ >
58
+ | null
59
+ | undefined
60
+ | void
61
+ | PopsFolderDataConfig[];
62
+ }
63
+
64
+ /**
65
+ * pops.folder
66
+ */
67
+ export interface PopsFolderDetails extends PopsTitleConfig, PopsDragConfig, PopsMoreButtonConfig, PopsCommonConfig {
68
+ /**
69
+ * 排序
70
+ */
71
+ sort: {
72
+ /**
73
+ * 比较的名字,默认为fileName
74
+ */
75
+ name: "fileName" | "fileSize" | "latestTime";
76
+ /**
77
+ * 是否降序,默认false(升序)
78
+ * @default false
79
+ */
80
+ isDesc: boolean;
81
+ /**
82
+ * 触发排序的回调
83
+ * @returns
84
+ * + true 中止内部的排序
85
+ */
86
+ callback?: (
87
+ targert: HTMLElement,
88
+ event: PointerEvent | MouseEvent,
89
+ sortName: "fileName" | "fileSize" | "latestTime",
90
+ sortDesc: boolean
91
+ ) => boolean | undefined | void;
92
+ };
93
+ /**
94
+ * 文件夹信息
95
+ */
96
+ folder: PopsFolderDataConfig[];
97
+ }
@@ -0,0 +1,60 @@
1
+ import type { PopsIframeDetails } from "./types";
2
+
3
+ export const PopsIframeConfig = (): DeepRequired<PopsIframeDetails> => {
4
+ return {
5
+ title: {
6
+ position: "center",
7
+ text: "",
8
+ html: false,
9
+ style: "",
10
+ },
11
+ loading: {
12
+ enable: true,
13
+ icon: true,
14
+ text: "",
15
+ },
16
+ useShadowRoot: true,
17
+ class: "",
18
+ url: window.location.href,
19
+ only: false,
20
+ zIndex: 10000,
21
+ mask: {
22
+ enable: false,
23
+ clickEvent: {
24
+ toClose: false,
25
+ toHide: false,
26
+ },
27
+ clickCallBack: null,
28
+ },
29
+ animation: "pops-anim-fadein-zoom",
30
+ position: "center",
31
+ drag: true,
32
+ dragLimit: true,
33
+ dragExtraDistance: 3,
34
+ dragMoveCallBack() {},
35
+ dragEndCallBack() {},
36
+ width: window.innerWidth < 550 ? "88vw" : "350px",
37
+ height: window.innerHeight < 450 ? "70vh" : "200px",
38
+ topRightButton: "min|max|mise|close",
39
+ sandbox: false,
40
+ forbiddenScroll: false,
41
+ loadEndCallBack() {},
42
+ btn: {
43
+ min: {
44
+ callback() {},
45
+ },
46
+ max: {
47
+ callback() {},
48
+ },
49
+ mise: {
50
+ callback() {},
51
+ },
52
+ close: {
53
+ callback() {},
54
+ },
55
+ },
56
+
57
+ style: null,
58
+ beforeAppendToPageCallBack() {},
59
+ };
60
+ };
@@ -0,0 +1,76 @@
1
+ .pops[type-value="iframe"] {
2
+ --container-title-height: 55px;
3
+ transition:
4
+ width 0.35s ease,
5
+ height 0.35s ease;
6
+ }
7
+ .pops[type-value="iframe"] .pops-content {
8
+ overflow: hidden;
9
+ }
10
+ .pops-loading {
11
+ position: absolute;
12
+ top: 40px;
13
+ right: 0;
14
+ bottom: 0;
15
+ left: 0;
16
+ z-index: 5;
17
+ background-color: rgb(255, 255, 255, var(--pops-bg-opacity));
18
+ }
19
+ .pops-loading:before {
20
+ position: absolute;
21
+ top: 50%;
22
+ left: 50%;
23
+ z-index: 3;
24
+ display: block;
25
+ margin: -20px 0 0 -20px;
26
+ padding: 20px;
27
+ border: 4px solid rgb(221, 221, 221, var(--pops-bd-opacity));
28
+ border-radius: 50%;
29
+ content: "";
30
+ border-top-color: transparent;
31
+ animation: pops-anim-wait-rotate 1.2s linear infinite;
32
+ }
33
+ .pops[type-value="iframe"].pops[type-module="min"] {
34
+ bottom: 0;
35
+ max-width: 200px;
36
+ max-height: 53px;
37
+ position: unset;
38
+ }
39
+ .pops[type-value="iframe"].pops[type-module="min"] .pops-header-control[data-type="min"] {
40
+ display: none;
41
+ }
42
+ .pops[type-value="iframe"].pops-iframe-unset-top {
43
+ top: unset !important;
44
+ }
45
+ .pops[type-value="iframe"].pops-iframe-unset-left {
46
+ left: unset !important;
47
+ }
48
+ .pops[type-value="iframe"].pops-iframe-unset-transform {
49
+ transform: none !important;
50
+ }
51
+ .pops[type-value="iframe"].pops-iframe-unset-transition {
52
+ transition: none !important;
53
+ }
54
+ .pops[type-value="iframe"].pops[type-module="max"] {
55
+ width: 100% !important;
56
+ height: 100% !important;
57
+ }
58
+ .pops[type-value="iframe"] iframe[pops] {
59
+ width: 100%;
60
+ height: 100%;
61
+ border: 0;
62
+ }
63
+ .pops-iframe-content-global-loading {
64
+ position: absolute;
65
+ top: 0;
66
+ left: 0;
67
+ z-index: 999999;
68
+ width: 0;
69
+ height: 4px;
70
+ background: linear-gradient(to right, #4995dd, #fff, rgb(202 224 246));
71
+ animation: iframeLoadingChange 2s forwards;
72
+ }
73
+
74
+ .pops-anim:has(.pops[type-value="iframe"].pops[type-module="min"]) {
75
+ position: unset;
76
+ }
@@ -0,0 +1,334 @@
1
+ import { PopsCore } from "../../PopsCore";
2
+ import { GlobalConfig } from "../../config/GlobalConfig";
3
+ import { PopsElementHandler } from "../../handler/PopsElementHandler";
4
+ import { PopsHandler } from "../../handler/PopsHandler";
5
+ import { PopsCSS } from "../../PopsCSS";
6
+ import { PopsInstData } from "../../PopsInst";
7
+ import type { PopsEventDetails } from "../../types/event";
8
+ import { popsDOMUtils } from "../../utils/PopsDOMUtils";
9
+ import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
10
+ import { popsUtils } from "../../utils/PopsUtils";
11
+ import { PopsIframeConfig } from "./config";
12
+ import type { PopsIframeDetails } from "./types";
13
+ import type { PopsType } from "../../types/main";
14
+
15
+ export const PopsIframe = {
16
+ init(details: PopsIframeDetails) {
17
+ const guid = popsUtils.getRandomGUID();
18
+ // 设置当前类型
19
+ const popsType: PopsType = "iframe";
20
+
21
+ let config = PopsIframeConfig();
22
+ config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
23
+ config = popsUtils.assign(config, details);
24
+ if (config.url == null) {
25
+ throw new Error("config.url不能为空");
26
+ }
27
+ config = PopsHandler.handleOnly(popsType, config);
28
+
29
+ const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
30
+ PopsHandler.handleInit($shadowRoot, [
31
+ {
32
+ name: "index",
33
+ css: PopsCSS.index,
34
+ },
35
+ {
36
+ name: "ninePalaceGridPosition",
37
+ css: PopsCSS.ninePalaceGridPosition,
38
+ },
39
+ {
40
+ name: "scrollbar",
41
+ css: PopsCSS.scrollbar,
42
+ },
43
+ {
44
+ name: "anim",
45
+ css: PopsCSS.anim,
46
+ },
47
+ {
48
+ name: "common",
49
+ css: PopsCSS.common,
50
+ },
51
+ {
52
+ name: "iframeCSS",
53
+ css: PopsCSS.iframeCSS,
54
+ },
55
+ ]);
56
+
57
+ const maskExtraStyle = config.animation != null && <string>config.animation != "" ? "position:absolute;" : "";
58
+
59
+ // 先把z-index提取出来
60
+ const zIndex = PopsHandler.handleZIndex(config.zIndex);
61
+ const maskHTML = PopsElementHandler.createMask(guid, zIndex, maskExtraStyle);
62
+
63
+ const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
64
+ const iframeLoadingHTML = '<div class="pops-loading"></div>';
65
+ const titleText = config.title!.text!.trim() !== "" ? config.title.text : config.url;
66
+ const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
67
+ const animHTML = PopsElementHandler.createAnim(
68
+ guid,
69
+ popsType,
70
+ config,
71
+ /*html*/ `
72
+ <div class="pops-title pops-${popsType}-title" style="text-align: ${
73
+ config.title.position
74
+ };${headerStyle}">${
75
+ config.title.html
76
+ ? titleText
77
+ : `<p pops class="pops-${popsType}-title-text" style="${headerPStyle}">${titleText}</p>`
78
+ }${headerBtnHTML}</div>
79
+ <div class="pops-content pops-${popsType}-content">
80
+ <div class="pops-${popsType}-content-global-loading"></div>
81
+ <iframe src="${config.url}" pops ${
82
+ config.sandbox ? "sandbox='allow-forms allow-same-origin allow-scripts'" : ""
83
+ }>
84
+ </iframe>
85
+ </div>${config.loading.enable ? iframeLoadingHTML : ""}`,
86
+ "",
87
+ zIndex
88
+ );
89
+ /**
90
+ * 弹窗的主元素,包括动画层
91
+ */
92
+
93
+ const $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
94
+ const {
95
+ popsElement: $pops,
96
+ headerCloseBtnElement,
97
+ headerControlsElement,
98
+ titleElement: $title,
99
+ iframeElement: $iframe,
100
+ loadingElement,
101
+ contentLoadingElement: $contentLoading,
102
+ headerMinBtnElement,
103
+ headerMaxBtnElement,
104
+ headerMiseBtnElement,
105
+ } = PopsHandler.handleQueryElement($anim, popsType);
106
+ let $iframeContainer = PopsCore.document.querySelector<HTMLDivElement>(".pops-iframe-container");
107
+ if (!$iframeContainer) {
108
+ $iframeContainer = PopsCore.document.createElement("div");
109
+ $iframeContainer.className = "pops-iframe-container";
110
+ $iframeContainer.style.cssText =
111
+ "display: flex;position: fixed;bottom: 0px;flex-flow: wrap-reverse;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;";
112
+ popsDOMUtils.appendBody($iframeContainer);
113
+ }
114
+ /**
115
+ * 遮罩层元素
116
+ */
117
+ let $mask: HTMLDivElement | null = null;
118
+ /**
119
+ * 已创建的元素列表
120
+ */
121
+ const elementList: HTMLElement[] = [$anim];
122
+
123
+ if (config.mask.enable) {
124
+ const _handleMask_ = PopsHandler.handleMask({
125
+ type: popsType,
126
+ guid: guid,
127
+
128
+ config: config,
129
+ animElement: $anim,
130
+ maskHTML: maskHTML,
131
+ });
132
+ $mask = _handleMask_.maskElement;
133
+ elementList.push($mask);
134
+ }
135
+
136
+ const eventDetails = PopsHandler.handleEventDetails(
137
+ guid,
138
+ $shadowContainer,
139
+ $shadowRoot,
140
+ popsType,
141
+ $anim,
142
+
143
+ $pops!,
144
+ $mask!,
145
+ config
146
+ ) as any as PopsEventDetails & {
147
+ iframeElement: HTMLIFrameElement;
148
+ };
149
+
150
+ eventDetails["iframeElement"] = $iframe!;
151
+
152
+ popsDOMUtils.on($anim, popsDOMUtils.getAnimationEndNameList(), function () {
153
+ /* 动画加载完毕 */
154
+ $anim.style.width = "0%";
155
+ $anim.style.height = "0%";
156
+ });
157
+
158
+ popsDOMUtils.on($iframe, "load", () => {
159
+ /* iframe加载中... */
160
+ loadingElement?.remove();
161
+ $contentLoading!.style.animation = "iframeLoadingChange_85 0.3s forwards";
162
+ popsDOMUtils.on($contentLoading, popsDOMUtils.getAnimationEndNameList(), () => {
163
+ /* 动画加载完毕就移除 */
164
+ $contentLoading!.remove();
165
+ });
166
+
167
+ if (config.title!.text!.trim() === "" && $iframe!.contentDocument) {
168
+ /* 同域名下的才可以获取网页标题 */
169
+ $title!.querySelector<HTMLElement>("p")!.innerText = $iframe!.contentDocument.title;
170
+ }
171
+
172
+ config.loadEndCallBack(eventDetails);
173
+ });
174
+ /* 创建到页面中 */
175
+
176
+ popsDOMUtils.append($shadowRoot, elementList);
177
+ if (typeof config.beforeAppendToPageCallBack === "function") {
178
+ config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
179
+ }
180
+
181
+ $iframeContainer.appendChild($shadowContainer);
182
+ if ($mask != null) {
183
+ $anim.after($mask);
184
+ }
185
+ /* 拖拽 */
186
+ if (config.drag) {
187
+ PopsInstanceUtils.drag($pops!, {
188
+ dragElement: $title!,
189
+ limit: config.dragLimit,
190
+ extraDistance: config.dragExtraDistance,
191
+ moveCallBack: config.dragMoveCallBack,
192
+ endCallBack: config.dragEndCallBack,
193
+ });
194
+ }
195
+ const TYPE_MODULE = "type-module";
196
+ /* 最小化按钮点击事件 */
197
+ let origin_left = "";
198
+ let origin_top = "";
199
+ let origin_is_max = false;
200
+ popsDOMUtils.on<PointerEvent | MouseEvent>(
201
+ headerMinBtnElement,
202
+ "click",
203
+ (event) => {
204
+ event.preventDefault();
205
+ event.stopPropagation();
206
+ origin_left = $pops.style.left;
207
+ origin_top = $pops.style.top;
208
+ $pops.classList.add("pops-iframe-unset-top");
209
+ $pops.classList.add("pops-iframe-unset-left");
210
+ $pops.classList.add("pops-iframe-unset-transform");
211
+ $pops.style.transitionDuration = "";
212
+
213
+ $pops.setAttribute(TYPE_MODULE, "min");
214
+ headerControlsElement.setAttribute("type", "min");
215
+ // 隐藏放大图标
216
+ headerMaxBtnElement.style.setProperty("display", "none");
217
+ // 显示复位图标
218
+ headerMiseBtnElement.style.setProperty("display", "");
219
+ if (typeof config?.btn?.min?.callback === "function") {
220
+ config.btn.min.callback(eventDetails, event);
221
+ }
222
+ },
223
+ {
224
+ capture: true,
225
+ }
226
+ );
227
+ /* 最大化按钮点击事件 */
228
+ popsDOMUtils.on<MouseEvent | PointerEvent>(
229
+ headerMaxBtnElement,
230
+ "click",
231
+ (event) => {
232
+ event.preventDefault();
233
+ event.stopPropagation();
234
+ if ($pops.getAttribute(TYPE_MODULE) !== "min") {
235
+ origin_left = $pops.style.left;
236
+ origin_top = $pops.style.top;
237
+ }
238
+ origin_is_max = true;
239
+ $pops.style.transitionDuration = "";
240
+ $pops.style.transform = "";
241
+ $pops.removeAttribute(TYPE_MODULE);
242
+ $pops.classList.add("pops-iframe-unset-transition");
243
+ $pops.classList.add("pops-iframe-unset-left");
244
+ $pops.classList.add("pops-iframe-unset-top");
245
+ $pops.classList.add("pops-iframe-unset-transform");
246
+ $pops.classList.remove("pops-iframe-unset-transition");
247
+ $pops.setAttribute(TYPE_MODULE, "max");
248
+ headerControlsElement.setAttribute("type", "max");
249
+ // 隐藏放大图标
250
+ headerMaxBtnElement.style.setProperty("display", "none");
251
+ // 显示复位图标
252
+ headerMiseBtnElement.style.setProperty("display", "");
253
+ if (typeof config?.btn?.max?.callback === "function") {
254
+ config.btn.max.callback(eventDetails, event);
255
+ }
256
+ },
257
+ {
258
+ capture: true,
259
+ }
260
+ );
261
+ /* 先隐藏窗口化按钮 */
262
+ headerMiseBtnElement?.style?.setProperty("display", "none");
263
+ /* 复位按钮点击事件 */
264
+ popsDOMUtils.on<MouseEvent | PointerEvent>(
265
+ headerMiseBtnElement,
266
+ "click",
267
+ (event) => {
268
+ event.preventDefault();
269
+ event.stopPropagation();
270
+ if (origin_is_max && $pops.getAttribute(TYPE_MODULE) === "min") {
271
+ $pops.classList.add("pops-iframe-unset-transition");
272
+ $pops.classList.add("pops-iframe-unset-left");
273
+ $pops.classList.add("pops-iframe-unset-top");
274
+ $pops.classList.add("pops-iframe-unset-transform");
275
+ $pops.classList.remove("pops-iframe-unset-transition");
276
+ $pops.setAttribute(TYPE_MODULE, "max");
277
+ headerControlsElement.setAttribute("type", "max");
278
+ } else {
279
+ origin_is_max = false;
280
+ $pops.style.left = origin_left;
281
+ $pops.style.top = origin_top;
282
+ $pops.style.transitionDuration = "";
283
+ $pops.style.transform = "";
284
+ headerControlsElement.removeAttribute("type");
285
+ $pops.removeAttribute(TYPE_MODULE);
286
+ $pops.classList.remove("pops-iframe-unset-top");
287
+ $pops.classList.remove("pops-iframe-unset-left");
288
+ $pops.classList.remove("pops-iframe-unset-transform");
289
+
290
+ // 显示放大图标
291
+ headerMaxBtnElement.style.setProperty("display", "");
292
+ // 隐藏复位图标
293
+ headerMiseBtnElement.style.setProperty("display", "none");
294
+ }
295
+ if (typeof config?.btn?.mise?.callback === "function") {
296
+ config.btn.mise.callback(eventDetails, event);
297
+ }
298
+ },
299
+ {
300
+ capture: true,
301
+ }
302
+ );
303
+ /* 关闭按钮点击事件 */
304
+ popsDOMUtils.on<MouseEvent | PointerEvent>(
305
+ headerCloseBtnElement,
306
+ "click",
307
+ (event) => {
308
+ event.preventDefault();
309
+ event.stopPropagation();
310
+ PopsInstanceUtils.removeInstance([PopsInstData.iframe], guid, false);
311
+ if (typeof config?.btn?.close?.callback === "function") {
312
+ config.btn.close.callback(eventDetails, event);
313
+ }
314
+ },
315
+ {
316
+ capture: true,
317
+ }
318
+ );
319
+
320
+ PopsHandler.handlePush(popsType, {
321
+ guid: guid,
322
+ animElement: $anim,
323
+
324
+ popsElement: $pops!,
325
+
326
+ maskElement: $mask!,
327
+ $shadowContainer: $shadowContainer,
328
+ $shadowRoot: $shadowRoot,
329
+ });
330
+
331
+ const result = PopsHandler.handleResultDetails(eventDetails);
332
+ return result;
333
+ },
334
+ };
@@ -0,0 +1,139 @@
1
+ import type { PopsTitleConfig, PopsDragConfig, PopsCommonConfig } from "../../../types/components";
2
+
3
+ import type { PopsEventDetails } from "../../../types/event";
4
+
5
+ /**
6
+ * pops.iframe的按钮的点击回调参数event
7
+ */
8
+ export interface PopsBtnIframeCallBackEvent {
9
+ /**
10
+ * 动画元素(包裹着弹窗元素)
11
+ */
12
+ animElement: HTMLElement;
13
+ /**
14
+ * 弹窗元素
15
+ */
16
+ popsElement: HTMLElement;
17
+ /**
18
+ * 遮罩层元素,如果未设置,那么不存在
19
+ */
20
+ maskElement?: HTMLElement;
21
+ /**
22
+ * iframe元素
23
+ */
24
+ iframePopsElement: HTMLIFrameElement;
25
+ /**
26
+ * 使用的方法名
27
+ */
28
+ function: "iframe";
29
+ /**
30
+ * 唯一id
31
+ */
32
+ guid: string;
33
+ }
34
+
35
+ /**
36
+ * pops.iframe
37
+ */
38
+ export interface PopsIframeDetails extends PopsTitleConfig, PopsDragConfig, PopsCommonConfig {
39
+ /**
40
+ * 加载配置
41
+ */
42
+ loading: {
43
+ /**
44
+ * 是否启用加载中的loading
45
+ */
46
+ enable: boolean;
47
+ /**
48
+ * 是否启用loading图标
49
+ */
50
+ icon: boolean;
51
+ /**
52
+ * 文字
53
+ */
54
+ text: string;
55
+ };
56
+ /**
57
+ * 按钮配置
58
+ */
59
+ btn: {
60
+ /**
61
+ * 最小化
62
+ */
63
+ min: {
64
+ /**
65
+ * 点击的回调函数
66
+ */
67
+ callback: (
68
+ eventDetails: PopsEventDetails & {
69
+ iframeElement: HTMLIFrameElement;
70
+ },
71
+ event: MouseEvent | PointerEvent
72
+ ) => void;
73
+ };
74
+ /**
75
+ * 最大化
76
+ */
77
+ max: {
78
+ /**
79
+ * 点击的回调函数
80
+ */
81
+ callback: (
82
+ eventDetails: PopsEventDetails & {
83
+ iframeElement: HTMLIFrameElement;
84
+ },
85
+ event: MouseEvent | PointerEvent
86
+ ) => void;
87
+ };
88
+ /**
89
+ * 窗口化
90
+ */
91
+ mise: {
92
+ /**
93
+ * 点击的回调函数
94
+ */
95
+ callback: (
96
+ eventDetails: PopsEventDetails & {
97
+ iframeElement: HTMLIFrameElement;
98
+ },
99
+ event: MouseEvent | PointerEvent
100
+ ) => void;
101
+ };
102
+ /**
103
+ * 关闭
104
+ */
105
+ close: {
106
+ /**
107
+ * 点击的回调函数
108
+ */
109
+ callback: (
110
+ eventDetails: PopsEventDetails & {
111
+ iframeElement: HTMLIFrameElement;
112
+ },
113
+ event: MouseEvent | PointerEvent
114
+ ) => void;
115
+ };
116
+ };
117
+ /**
118
+ * 加载的地址,默认为window.location.href
119
+ * @default window.location.href
120
+ */
121
+ url?: string;
122
+ /**
123
+ * 右上角按钮顺序:最小化、最大化、窗口化、关闭
124
+ */
125
+ topRightButton: "min|max|mise|close";
126
+ /**
127
+ * 是否启用沙箱,默认false
128
+ * @default false
129
+ */
130
+ sandbox?: boolean;
131
+ /**
132
+ * 加载完毕的回调
133
+ */
134
+ loadEndCallBack?: (
135
+ details: PopsEventDetails & {
136
+ iframeElement: HTMLIFrameElement;
137
+ }
138
+ ) => void;
139
+ }