@whitesev/pops 2.4.6 → 2.4.7

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 (142) hide show
  1. package/dist/index.amd.js +578 -571
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +578 -571
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +578 -571
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +578 -571
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +578 -571
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +578 -571
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +252 -252
  14. package/dist/types/src/types/animation.d.ts +19 -19
  15. package/dist/types/src/types/button.d.ts +187 -187
  16. package/dist/types/src/types/components.d.ts +210 -210
  17. package/dist/types/src/types/event.d.ts +63 -63
  18. package/dist/types/src/types/global.d.ts +25 -25
  19. package/dist/types/src/types/icon.d.ts +32 -32
  20. package/dist/types/src/types/inst.d.ts +24 -24
  21. package/dist/types/src/types/main.d.ts +111 -111
  22. package/dist/types/src/types/mask.d.ts +49 -49
  23. package/dist/types/src/types/position.d.ts +60 -60
  24. package/index.ts +3 -0
  25. package/package.json +4 -2
  26. package/src/Pops.ts +206 -0
  27. package/src/PopsAnimation.ts +32 -0
  28. package/src/PopsCSS.ts +51 -0
  29. package/src/PopsCore.ts +64 -0
  30. package/src/PopsIcon.ts +95 -0
  31. package/src/PopsInst.ts +21 -0
  32. package/src/components/alert/config.ts +62 -0
  33. package/src/components/alert/index.css +0 -0
  34. package/src/components/alert/index.ts +163 -0
  35. package/src/components/alert/types/index.ts +23 -0
  36. package/src/components/confirm/config.ts +90 -0
  37. package/src/components/confirm/index.css +0 -0
  38. package/src/components/confirm/index.ts +166 -0
  39. package/src/components/confirm/types/index.ts +17 -0
  40. package/src/components/drawer/config.ts +89 -0
  41. package/src/components/drawer/index.css +37 -0
  42. package/src/components/drawer/index.ts +237 -0
  43. package/src/components/drawer/types/index.ts +61 -0
  44. package/src/components/folder/config.ts +147 -0
  45. package/src/components/folder/folderIcon.ts +28 -0
  46. package/src/components/folder/index.css +303 -0
  47. package/src/components/folder/index.ts +929 -0
  48. package/src/components/folder/types/index.ts +97 -0
  49. package/src/components/iframe/config.ts +60 -0
  50. package/src/components/iframe/index.css +76 -0
  51. package/src/components/iframe/index.ts +334 -0
  52. package/src/components/iframe/types/index.ts +139 -0
  53. package/src/components/loading/config.ts +29 -0
  54. package/src/components/loading/index.css +66 -0
  55. package/src/components/loading/index.ts +99 -0
  56. package/src/components/loading/types/index.ts +34 -0
  57. package/src/components/panel/config.ts +519 -0
  58. package/src/components/panel/handlerComponents.ts +2900 -0
  59. package/src/components/panel/index.css +1222 -0
  60. package/src/components/panel/index.ts +207 -0
  61. package/src/components/panel/types/components-button.ts +68 -0
  62. package/src/components/panel/types/components-common.ts +50 -0
  63. package/src/components/panel/types/components-deepMenu.ts +84 -0
  64. package/src/components/panel/types/components-forms.ts +44 -0
  65. package/src/components/panel/types/components-input.ts +78 -0
  66. package/src/components/panel/types/components-own.ts +30 -0
  67. package/src/components/panel/types/components-select.ts +93 -0
  68. package/src/components/panel/types/components-selectMultiple.ts +130 -0
  69. package/src/components/panel/types/components-slider.ts +77 -0
  70. package/src/components/panel/types/components-switch.ts +56 -0
  71. package/src/components/panel/types/components-textarea.ts +68 -0
  72. package/src/components/panel/types/index.ts +177 -0
  73. package/src/components/prompt/config.ts +94 -0
  74. package/src/components/prompt/index.css +34 -0
  75. package/src/components/prompt/index.ts +216 -0
  76. package/src/components/prompt/types/index.ts +55 -0
  77. package/src/components/rightClickMenu/config.ts +98 -0
  78. package/src/components/rightClickMenu/index.css +112 -0
  79. package/src/components/rightClickMenu/index.ts +602 -0
  80. package/src/components/rightClickMenu/types/index.ts +97 -0
  81. package/src/components/searchSuggestion/config.ts +56 -0
  82. package/src/components/searchSuggestion/index.ts +856 -0
  83. package/src/components/searchSuggestion/types/index.ts +239 -0
  84. package/src/components/tooltip/config.ts +34 -0
  85. package/src/components/tooltip/index.css +199 -0
  86. package/src/components/tooltip/index.ts +604 -0
  87. package/src/components/tooltip/types/index.ts +117 -0
  88. package/src/config/CommonCSSClassName.ts +17 -0
  89. package/src/config/GlobalConfig.ts +63 -0
  90. package/src/css/animation.css +987 -0
  91. package/src/css/button.css +551 -0
  92. package/src/css/common.css +48 -0
  93. package/src/css/index.css +253 -0
  94. package/src/css/ninePalaceGridPosition.css +50 -0
  95. package/src/css/scrollbar.css +22 -0
  96. package/src/handler/PopsElementHandler.ts +304 -0
  97. package/src/handler/PopsHandler.ts +589 -0
  98. package/src/svg/arrowLeft.svg +4 -0
  99. package/src/svg/arrowRight.svg +4 -0
  100. package/src/svg/chromeFilled.svg +11 -0
  101. package/src/svg/circleClose.svg +8 -0
  102. package/src/svg/close.svg +5 -0
  103. package/src/svg/cpu.svg +8 -0
  104. package/src/svg/delete.svg +5 -0
  105. package/src/svg/documentCopy.svg +5 -0
  106. package/src/svg/edit.svg +8 -0
  107. package/src/svg/eleme.svg +5 -0
  108. package/src/svg/elemePlus.svg +5 -0
  109. package/src/svg/headset.svg +5 -0
  110. package/src/svg/hide.svg +8 -0
  111. package/src/svg/keyboard.svg +8 -0
  112. package/src/svg/loading.svg +5 -0
  113. package/src/svg/max.svg +5 -0
  114. package/src/svg/min.svg +5 -0
  115. package/src/svg/mise.svg +5 -0
  116. package/src/svg/monitor.svg +5 -0
  117. package/src/svg/next.svg +5 -0
  118. package/src/svg/picture.svg +8 -0
  119. package/src/svg/prev.svg +5 -0
  120. package/src/svg/search.svg +5 -0
  121. package/src/svg/share.svg +5 -0
  122. package/src/svg/upload.svg +5 -0
  123. package/src/svg/videoPause.svg +5 -0
  124. package/src/svg/videoPlay.svg +5 -0
  125. package/src/svg/view.svg +5 -0
  126. package/src/types/PopsDOMUtilsEventType.d.ts +252 -0
  127. package/src/types/animation.d.ts +19 -0
  128. package/src/types/button.d.ts +187 -0
  129. package/src/types/components.d.ts +210 -0
  130. package/src/types/event.d.ts +63 -0
  131. package/src/types/global.d.ts +25 -0
  132. package/src/types/icon.d.ts +32 -0
  133. package/src/types/inst.d.ts +24 -0
  134. package/src/types/main.d.ts +111 -0
  135. package/src/types/mask.d.ts +49 -0
  136. package/src/types/position.d.ts +60 -0
  137. package/src/utils/PopsDOMUtils.ts +2408 -0
  138. package/src/utils/PopsDOMUtilsEventsConfig.ts +4 -0
  139. package/src/utils/PopsInstanceUtils.ts +688 -0
  140. package/src/utils/PopsMathUtils.ts +71 -0
  141. package/src/utils/PopsSafeUtils.ts +22 -0
  142. package/src/utils/PopsUtils.ts +406 -0
package/src/Pops.ts ADDED
@@ -0,0 +1,206 @@
1
+ import { PopsAlert } from "./components/alert";
2
+ import type { PopsAlertDetails } from "./components/alert/types";
3
+ import { PopsConfirm } from "./components/confirm";
4
+ import type { PopsConfirmDetails } from "./components/confirm/types";
5
+ import { PopsDrawer } from "./components/drawer";
6
+ import type { PopsDrawerDetails } from "./components/drawer/types";
7
+ import { PopsFolder } from "./components/folder";
8
+ import type { PopsFolderDetails } from "./components/folder/types";
9
+ import { PopsIframe } from "./components/iframe";
10
+ import type { PopsIframeDetails } from "./components/iframe/types";
11
+ import { PopsLoading } from "./components/loading";
12
+ import type { PopsLoadingDetails } from "./components/loading/types";
13
+ import { PopsPanel } from "./components/panel";
14
+ import { PanelHandlerComponents } from "./components/panel/handlerComponents";
15
+ import type { PopsPanelDetails } from "./components/panel/types";
16
+ import { PopsPrompt } from "./components/prompt";
17
+ import type { PopsPromptDetails } from "./components/prompt/types/index";
18
+ import { PopsRightClickMenu } from "./components/rightClickMenu";
19
+ import type { PopsRightClickMenuDetails } from "./components/rightClickMenu/types";
20
+ import { PopsSearchSuggestion } from "./components/searchSuggestion";
21
+ import type { PopsSearchSuggestionDetails } from "./components/searchSuggestion/types/index";
22
+ import { PopsTooltip } from "./components/tooltip";
23
+ import type { PopsToolTipDetails } from "./components/tooltip/types/index";
24
+ import { GlobalConfig } from "./config/GlobalConfig";
25
+ import { PopsAnimation } from "./PopsAnimation";
26
+ import { PopsCore } from "./PopsCore";
27
+ import { PopsCSS } from "./PopsCSS";
28
+ import { PopsIcon } from "./PopsIcon";
29
+ import { PopsInstData } from "./PopsInst";
30
+ import { popsDOMUtils } from "./utils/PopsDOMUtils";
31
+ import { PopsInstanceUtils } from "./utils/PopsInstanceUtils";
32
+ import { PopsMathFloatUtils } from "./utils/PopsMathUtils";
33
+ import { popsUtils } from "./utils/PopsUtils";
34
+ import { version } from "../package.json";
35
+
36
+ class Pops {
37
+ /** 配置 */
38
+ config = {
39
+ /** 版本号 */
40
+ version: version,
41
+ cssText: PopsCSS,
42
+ /** icon图标的svg代码 */
43
+ iconSVG: PopsIcon.$data,
44
+ /** 当前已配置的动画@keyframes名字映射(初始化时生成) */
45
+ animation: PopsAnimation.$data,
46
+ /** 存储已创建的元素 */
47
+ instData: PopsInstData,
48
+ /** 禁止滚动 */
49
+ forbiddenScroll: {
50
+ event(event: Event) {
51
+ return popsDOMUtils.preventEvent(event);
52
+ },
53
+ },
54
+ /** pops使用的工具类 */
55
+ Utils: popsUtils,
56
+ /** pops使用的DOM工具类 */
57
+ DOMUtils: popsDOMUtils,
58
+ /** pops创建的实例使用的工具类 */
59
+ InstanceUtils: PopsInstanceUtils,
60
+ /** pops处理float类型使用的工具类 */
61
+ MathFloatUtils: PopsMathFloatUtils,
62
+ /** pops.panel中用于处理各个类型的工具 */
63
+ PanelHandlerComponents: PanelHandlerComponents,
64
+ };
65
+ init() {}
66
+ /**
67
+ * 释放原有的pops控制权
68
+ * @example
69
+ * let pops = window.pops.noConflict()
70
+ */
71
+ noConflict() {
72
+ if (typeof (PopsCore.globalThis as any).pops === "object") {
73
+ popsUtils.delete(PopsCore.globalThis, "pops");
74
+ }
75
+ if (typeof unsafeWindow === "object" && unsafeWindow != null && typeof (unsafeWindow as any).pops === "object") {
76
+ popsUtils.delete(unsafeWindow, "pops");
77
+ }
78
+ return new Pops();
79
+ }
80
+ /**
81
+ * 通过navigator.userAgent判断是否是手机访问
82
+ * @param userAgent
83
+ */
84
+ isPhone(userAgent?: string) {
85
+ return popsUtils.isPhone(userAgent);
86
+ }
87
+ /**
88
+ * 为所有弹窗设置全局属性
89
+ */
90
+ GlobalConfig = GlobalConfig;
91
+ /**
92
+ * 普通信息框
93
+ * @param details 配置
94
+ */
95
+ alert = (details: PopsAlertDetails) => {
96
+ const dialog = PopsAlert.init(details);
97
+ return dialog;
98
+ };
99
+
100
+ /**
101
+ * 询问框
102
+ * @param details 配置
103
+ */
104
+ confirm = (details: PopsConfirmDetails) => {
105
+ const dialog = PopsConfirm.init(details);
106
+ return dialog;
107
+ };
108
+
109
+ /**
110
+ * 输入框
111
+ * @param details 配置
112
+ */
113
+ prompt = (details: PopsPromptDetails) => {
114
+ const dialog = PopsPrompt.init(details);
115
+ return dialog;
116
+ };
117
+
118
+ /**
119
+ * 加载层
120
+ * @param details 配置
121
+ */
122
+ loading = (details: PopsLoadingDetails) => {
123
+ const popsLoading = PopsLoading.init(details);
124
+ return popsLoading;
125
+ };
126
+
127
+ /**
128
+ * iframe层
129
+ * @param details 配置
130
+ */
131
+ iframe = (details: PopsIframeDetails) => {
132
+ const dialog = PopsIframe.init(details);
133
+ return dialog;
134
+ };
135
+
136
+ /**
137
+ * 提示框
138
+ * @param details 配置
139
+ */
140
+ tooltip = (details: PopsToolTipDetails) => {
141
+ const popsTooltip = PopsTooltip.init(details);
142
+ return popsTooltip;
143
+ };
144
+
145
+ /**
146
+ * 抽屉
147
+ * @param details 配置
148
+ */
149
+ drawer = (details: PopsDrawerDetails) => {
150
+ const dialog = PopsDrawer.init(details);
151
+ return dialog;
152
+ };
153
+
154
+ /**
155
+ * 文件夹
156
+ * @param details 配置
157
+ */
158
+ folder = (details: PopsFolderDetails) => {
159
+ const dialog = PopsFolder.init(details);
160
+ return dialog;
161
+ };
162
+
163
+ /**
164
+ * 配置面板
165
+ * @param details 配置
166
+ */
167
+ panel = (details: PopsPanelDetails) => {
168
+ const dialog = PopsPanel.init(details);
169
+ return dialog;
170
+ };
171
+
172
+ /**
173
+ * 右键菜单
174
+ * @param details 配置
175
+ */
176
+ rightClickMenu = (details: PopsRightClickMenuDetails) => {
177
+ const popsRightClickMenu = PopsRightClickMenu.init(details);
178
+ return popsRightClickMenu;
179
+ };
180
+
181
+ /**
182
+ * 搜索建议
183
+ *
184
+ * 注意:调用后需要主动调用.init()和.setAllEvent()进行初始化
185
+ * @param details 配置
186
+ * @example
187
+ * let $input = document.querySelector("#input");
188
+ * let searchSuggestion = pops.searchSuggestion({
189
+ * target: $input,
190
+ * inputTarget: $input,
191
+ * getItemHTML: function (item) {
192
+ * return item.value;
193
+ * }
194
+ * });
195
+ * searchSuggestion.init();
196
+ * searchSuggestion.setAllEvent();
197
+ */
198
+ searchSuggestion = <T = any>(details: PopsSearchSuggestionDetails<T>) => {
199
+ const popsSearchSuggestion = PopsSearchSuggestion.init<T>(details);
200
+ return popsSearchSuggestion;
201
+ };
202
+ }
203
+
204
+ const pops = new Pops();
205
+
206
+ export { pops };
@@ -0,0 +1,32 @@
1
+ import { PopsCSS } from "./PopsCSS";
2
+ import { popsDOMUtils } from "./utils/PopsDOMUtils";
3
+ import { PopsSafeUtils } from "./utils/PopsSafeUtils";
4
+ import { popsUtils } from "./utils/PopsUtils";
5
+
6
+ export const PopsAnimation = {
7
+ $data: {} as { [key: string]: CSSKeyframesRule },
8
+ $flag: {
9
+ /** 是否初始化 */
10
+ isInit: false,
11
+ },
12
+ init() {
13
+ if (!this.$flag.isInit) {
14
+ this.$flag.isInit = true;
15
+ /* 处理获取当前所有的动画名 */
16
+ const animationStyle = document.createElement("style");
17
+ PopsSafeUtils.setSafeHTML(animationStyle, PopsCSS.anim);
18
+ popsDOMUtils.appendHead(animationStyle);
19
+ this.$data = null as any;
20
+ this.$data = popsDOMUtils.getKeyFrames(animationStyle.sheet!);
21
+ popsUtils.setTimeout(() => {
22
+ animationStyle.remove();
23
+ }, 50);
24
+ }
25
+ },
26
+ /**
27
+ * 判断是否存在某个动画名
28
+ */
29
+ hasAnim(name: string) {
30
+ return Object.prototype.hasOwnProperty.call(this.$data, name);
31
+ },
32
+ };
package/src/PopsCSS.ts ADDED
@@ -0,0 +1,51 @@
1
+ import indexCSS from "./css/index.css";
2
+ import ninePalaceGridPositionCSS from "./css/ninePalaceGridPosition.css";
3
+ import scrollbarCSS from "./css/scrollbar.css";
4
+ import buttonCSS from "./css/button.css";
5
+ import commonCSS from "./css/common.css";
6
+ import animCSS from "./css/animation.css";
7
+ import alertCSS from "./components/alert/index.css";
8
+ import confirmCSS from "./components/confirm/index.css";
9
+ import promptCSS from "./components/prompt/index.css";
10
+ import loadingCSS from "./components/loading/index.css";
11
+ import iframeCSS from "./components/iframe/index.css";
12
+ import tooltipCSS from "./components/tooltip/index.css";
13
+ import drawerCSS from "./components/drawer/index.css";
14
+ import folderCSS from "./components/folder/index.css";
15
+ import panelCSS from "./components/panel/index.css";
16
+ import rightClickMenuCSS from "./components/rightClickMenu/index.css";
17
+
18
+ export const PopsCSS = {
19
+ /** 主CSS */
20
+ index: indexCSS,
21
+ /** 九宫格位置CSS */
22
+ ninePalaceGridPosition: ninePalaceGridPositionCSS,
23
+ /** 滚动条CSS */
24
+ scrollbar: scrollbarCSS,
25
+ /** 按钮CSS */
26
+ button: buttonCSS,
27
+ /** 通用的CSS */
28
+ common: commonCSS,
29
+ /** 动画 */
30
+ anim: animCSS,
31
+ /** pops.alert */
32
+ alertCSS: alertCSS,
33
+ /** pops.cponfirm */
34
+ confirmCSS: confirmCSS,
35
+ /** pops.prompt */
36
+ promptCSS: promptCSS,
37
+ /** pops.loading */
38
+ loadingCSS: loadingCSS,
39
+ /** pops.iframe */
40
+ iframeCSS: iframeCSS,
41
+ /** pops.tooltip */
42
+ tooltipCSS: tooltipCSS,
43
+ /** pops.drawer */
44
+ drawerCSS: drawerCSS,
45
+ /** pops.folder */
46
+ folderCSS: folderCSS,
47
+ /** pops.folder */
48
+ panelCSS: panelCSS,
49
+ /** pops.rightClickMenu */
50
+ rightClickMenu: rightClickMenuCSS,
51
+ };
@@ -0,0 +1,64 @@
1
+ interface PopsCoreOption {
2
+ document: Document;
3
+ window: Window;
4
+ globalThis: typeof globalThis;
5
+ self: typeof globalThis;
6
+ setTimeout: Window["setTimeout"];
7
+ setInterval: Window["setInterval"];
8
+ clearTimeout: Window["clearTimeout"];
9
+ clearInterval: Window["clearInterval"];
10
+ }
11
+
12
+ const PopsCoreDefaultEnv: PopsCoreOption = {
13
+ document: document,
14
+ window: window,
15
+ globalThis: globalThis,
16
+ self: self,
17
+ setTimeout: globalThis.setTimeout.bind(globalThis),
18
+ setInterval: globalThis.setInterval.bind(globalThis),
19
+ clearTimeout: globalThis.clearTimeout.bind(globalThis),
20
+ clearInterval: globalThis.clearInterval.bind(globalThis),
21
+ };
22
+
23
+ const PopsCoreEnv: PopsCoreOption = Object.assign({}, PopsCoreDefaultEnv);
24
+
25
+ const PopsCore = {
26
+ init(option?: PopsCoreOption) {
27
+ if (!option) {
28
+ option = Object.assign({}, PopsCoreDefaultEnv);
29
+ }
30
+ Object.assign(PopsCoreEnv, option);
31
+ },
32
+ get document() {
33
+ return PopsCoreEnv.document;
34
+ },
35
+ get window() {
36
+ return PopsCoreEnv.window;
37
+ },
38
+ get globalThis() {
39
+ return PopsCoreEnv.globalThis;
40
+ },
41
+ get self() {
42
+ return PopsCoreEnv.self;
43
+ },
44
+ get setTimeout() {
45
+ return PopsCoreEnv.setTimeout;
46
+ },
47
+ get setInterval() {
48
+ return PopsCoreEnv.setInterval;
49
+ },
50
+ get clearTimeout() {
51
+ return PopsCoreEnv.clearTimeout;
52
+ },
53
+ get clearInterval() {
54
+ return PopsCoreEnv.clearInterval;
55
+ },
56
+ };
57
+
58
+ const OriginPrototype = {
59
+ Object: {
60
+ defineProperty: Object.defineProperty,
61
+ },
62
+ };
63
+
64
+ export { PopsCoreOption, PopsCore, OriginPrototype };
@@ -0,0 +1,95 @@
1
+ import type { PopsIconType } from "./types/icon";
2
+ import SVG_min from "./svg/min.svg";
3
+ import SVG_mise from "./svg/mise.svg";
4
+ import SVG_max from "./svg/max.svg";
5
+ import SVG_close from "./svg/close.svg";
6
+ import SVG_edit from "./svg/edit.svg";
7
+ import SVG_share from "./svg/share.svg";
8
+ import SVG_delete from "./svg/delete.svg";
9
+ import SVG_search from "./svg/search.svg";
10
+ import SVG_upload from "./svg/upload.svg";
11
+ import SVG_loading from "./svg/loading.svg";
12
+ import SVG_next from "./svg/next.svg";
13
+ import SVG_prev from "./svg/prev.svg";
14
+ import SVG_eleme from "./svg/eleme.svg";
15
+ import SVG_elemePlus from "./svg/elemePlus.svg";
16
+ import SVG_chromeFilled from "./svg/chromeFilled.svg";
17
+ import SVG_cpu from "./svg/cpu.svg";
18
+ import SVG_videoPlay from "./svg/videoPlay.svg";
19
+ import SVG_videoPause from "./svg/videoPause.svg";
20
+ import SVG_headset from "./svg/headset.svg";
21
+ import SVG_monitor from "./svg/monitor.svg";
22
+ import SVG_documentCopy from "./svg/documentCopy.svg";
23
+ import SVG_picture from "./svg/picture.svg";
24
+ import SVG_circleClose from "./svg/circleClose.svg";
25
+ import SVG_view from "./svg/view.svg";
26
+ import SVG_hide from "./svg/hide.svg";
27
+ import SVG_keyboard from "./svg/keyboard.svg";
28
+ import SVG_arrowRight from "./svg/arrowRight.svg";
29
+ import SVG_arrowLeft from "./svg/arrowLeft.svg";
30
+
31
+ const PopsIconData: {
32
+ [key in PopsIconType]: string;
33
+ } = {
34
+ min: SVG_min,
35
+ mise: SVG_mise,
36
+ max: SVG_max,
37
+ close: SVG_close,
38
+ edit: SVG_edit,
39
+ share: SVG_share,
40
+ delete: SVG_delete,
41
+ search: SVG_search,
42
+ upload: SVG_upload,
43
+ loading: SVG_loading,
44
+ next: SVG_next,
45
+ prev: SVG_prev,
46
+ eleme: SVG_eleme,
47
+ elemePlus: SVG_elemePlus,
48
+ chromeFilled: SVG_chromeFilled,
49
+ cpu: SVG_cpu,
50
+ videoPlay: SVG_videoPlay,
51
+ videoPause: SVG_videoPause,
52
+ headset: SVG_headset,
53
+ monitor: SVG_monitor,
54
+ documentCopy: SVG_documentCopy,
55
+ picture: SVG_picture,
56
+ circleClose: SVG_circleClose,
57
+ view: SVG_view,
58
+ hide: SVG_hide,
59
+ keyboard: SVG_keyboard,
60
+ arrowRight: SVG_arrowRight,
61
+ arrowLeft: SVG_arrowLeft,
62
+ };
63
+
64
+ export const PopsIcon = {
65
+ $data: PopsIconData,
66
+ /**
67
+ * 判断是否存在某个icon
68
+ * @param iconName 图标名
69
+ */
70
+ hasIcon(iconName: string) {
71
+ return Object.keys(PopsIcon.$data).includes(iconName);
72
+ },
73
+ /**
74
+ * 获取icon
75
+ * @param iconName 图标名
76
+ */
77
+ getIcon(iconName: string): string | null {
78
+ return PopsIcon.$data[iconName as keyof typeof this.$data];
79
+ },
80
+ /**
81
+ * 删除图标
82
+ * @param iconName 图标名
83
+ */
84
+ deleteIcon(iconName: string) {
85
+ return Reflect.deleteProperty(PopsIcon.$data, iconName);
86
+ },
87
+ /**
88
+ * 设置图标
89
+ * @param iconName 图标名
90
+ * @param iconHTML 图标html
91
+ */
92
+ setIcon(iconName: string, iconHTML: string) {
93
+ Reflect.set(PopsIcon.$data, iconName, iconHTML);
94
+ },
95
+ };
@@ -0,0 +1,21 @@
1
+ import type { PopsInstCommonConfig } from "./types/inst";
2
+ import type { PopsInstStoreType } from "./types/main";
3
+
4
+ /**
5
+ * 弹窗实例数据
6
+ */
7
+ export const PopsInstData: {
8
+ [key in PopsInstStoreType]: PopsInstCommonConfig[];
9
+ } = {
10
+ alert: [],
11
+ confirm: [],
12
+ drawer: [],
13
+ folder: [],
14
+ iframe: [],
15
+ loading: [],
16
+ panel: [],
17
+ prompt: [],
18
+ rightClickMenu: [],
19
+ // 没有 searchSuggestion
20
+ tooltip: [],
21
+ };
@@ -0,0 +1,62 @@
1
+ import type { PopsAlertDetails } from "./types";
2
+
3
+ export const PopsAlertConfig = (): DeepRequired<PopsAlertDetails> => {
4
+ return {
5
+ title: {
6
+ text: "默认标题",
7
+ position: "left",
8
+ html: false,
9
+ style: "",
10
+ },
11
+ content: {
12
+ text: "默认内容",
13
+ html: false,
14
+ style: "",
15
+ },
16
+ btn: {
17
+ position: "flex-end",
18
+ ok: {
19
+ size: void 0 as any,
20
+ enable: true,
21
+ icon: void 0 as any,
22
+ rightIcon: false,
23
+ iconIsLoading: false,
24
+ text: "确定",
25
+ type: "primary",
26
+ callback: function (details: any) {
27
+ details.close();
28
+ },
29
+ },
30
+ close: {
31
+ enable: true,
32
+ callback: function (details: any) {
33
+ details.close();
34
+ },
35
+ },
36
+ },
37
+ useShadowRoot: true,
38
+ class: "",
39
+ only: false,
40
+ width: window.innerWidth < 550 ? "88vw" : "350px",
41
+ height: window.innerHeight < 450 ? "70vh" : "200px",
42
+ position: "center",
43
+ animation: "pops-anim-fadein-zoom",
44
+ zIndex: 10000,
45
+ mask: {
46
+ enable: false,
47
+ clickEvent: {
48
+ toClose: false,
49
+ toHide: false,
50
+ },
51
+ clickCallBack: null,
52
+ },
53
+ drag: false,
54
+ dragLimit: true,
55
+ dragExtraDistance: 3,
56
+ dragMoveCallBack() {},
57
+ dragEndCallBack() {},
58
+ forbiddenScroll: false,
59
+ style: null,
60
+ beforeAppendToPageCallBack() {},
61
+ } as DeepRequired<PopsAlertDetails>;
62
+ };
File without changes
@@ -0,0 +1,163 @@
1
+ import { GlobalConfig } from "../../config/GlobalConfig";
2
+ import { PopsElementHandler } from "../../handler/PopsElementHandler";
3
+ import { PopsHandler } from "../../handler/PopsHandler";
4
+ import { popsDOMUtils } from "../../utils/PopsDOMUtils";
5
+ import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
6
+ import { popsUtils } from "../../utils/PopsUtils";
7
+ import { PopsAlertConfig } from "./config";
8
+ import type { PopsType } from "../../types/main";
9
+ import type { PopsAlertDetails } from "./types";
10
+ import { PopsCSS } from "../../PopsCSS";
11
+
12
+ export const PopsAlert = {
13
+ init(details: PopsAlertDetails) {
14
+ const guid = popsUtils.getRandomGUID();
15
+ // 设置当前类型
16
+ const popsType: PopsType = "alert";
17
+ let config = PopsAlertConfig();
18
+ config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
19
+ config = popsUtils.assign(config, details);
20
+ config = PopsHandler.handleOnly(popsType, config);
21
+
22
+ const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
23
+ PopsHandler.handleInit($shadowRoot, [
24
+ {
25
+ name: "index",
26
+ css: PopsCSS.index,
27
+ },
28
+ {
29
+ name: "ninePalaceGridPosition",
30
+ css: PopsCSS.ninePalaceGridPosition,
31
+ },
32
+ {
33
+ name: "scrollbar",
34
+ css: PopsCSS.scrollbar,
35
+ },
36
+ {
37
+ name: "button",
38
+ css: PopsCSS.button,
39
+ },
40
+ {
41
+ name: "anim",
42
+ css: PopsCSS.anim,
43
+ },
44
+ {
45
+ name: "common",
46
+ css: PopsCSS.common,
47
+ },
48
+ {
49
+ name: "alertCSS",
50
+ css: PopsCSS.alertCSS,
51
+ },
52
+ ]);
53
+
54
+ // 先把z-index提取出来
55
+ const zIndex = PopsHandler.handleZIndex(config.zIndex);
56
+ const maskHTML = PopsElementHandler.createMask(guid, zIndex);
57
+ const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
58
+ const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
59
+ const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
60
+ const { contentStyle, contentPStyle } = PopsElementHandler.createContentStyle(popsType, config);
61
+ const animHTML = PopsElementHandler.createAnim(
62
+ guid,
63
+ popsType,
64
+ config,
65
+ /*html*/ `
66
+ <div class="pops-title pops-${popsType}-title" style="text-align: ${config.title.position};${headerStyle}">${
67
+ config.title.html
68
+ ? config.title.text
69
+ : `<p pops class="pops-${popsType}-title-text" style="${headerPStyle}">${config.title.text}</p>`
70
+ }${headerBtnHTML}</div>
71
+ <div class="pops-content pops-${popsType}-content" style="${contentStyle}">${
72
+ config.content.html
73
+ ? config.content.text
74
+ : `<p pops class="pops-${popsType}-content-text" style="${contentPStyle}">${config.content.text}</p>`
75
+ }</div>${bottomBtnHTML}`,
76
+ bottomBtnHTML,
77
+ zIndex
78
+ );
79
+ /**
80
+ * 弹窗的主元素,包括动画层
81
+ */
82
+ const $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
83
+
84
+ const {
85
+ popsElement: $pops,
86
+ headerCloseBtnElement: $headerCloseBtn,
87
+ btnOkElement,
88
+ titleElement: $title,
89
+ } = PopsHandler.handleQueryElement($anim, popsType);
90
+
91
+ /** 遮罩层元素 */
92
+ let $mask: HTMLDivElement | null = null;
93
+ /** 已创建的元素列表 */
94
+ const elementList: HTMLElement[] = [$anim];
95
+
96
+ /* 遮罩层元素 */
97
+
98
+ if (config.mask.enable) {
99
+ const _handleMask_ = PopsHandler.handleMask({
100
+ type: popsType,
101
+ guid: guid,
102
+ config: config,
103
+ animElement: $anim,
104
+ maskHTML: maskHTML,
105
+ });
106
+ $mask = _handleMask_.maskElement;
107
+ elementList.push($mask);
108
+ }
109
+ /* 处理返回的配置 */
110
+ const eventDetails = PopsHandler.handleEventDetails(
111
+ guid,
112
+ $shadowContainer,
113
+ $shadowRoot,
114
+ popsType,
115
+ $anim,
116
+ $pops!,
117
+ $mask!,
118
+ config
119
+ );
120
+ /* 为顶部右边的关闭按钮添加点击事件 */
121
+ PopsHandler.handleClickEvent("close", $headerCloseBtn!, eventDetails, config.btn.close!.callback!);
122
+ /* 为底部ok按钮添加点击事件 */
123
+ PopsHandler.handleClickEvent("ok", btnOkElement!, eventDetails!, config.btn.ok!.callback!);
124
+
125
+ /* 创建到页面中 */
126
+
127
+ popsDOMUtils.append($shadowRoot, elementList);
128
+ if (typeof config.beforeAppendToPageCallBack === "function") {
129
+ config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
130
+ }
131
+
132
+ popsDOMUtils.appendBody($shadowContainer);
133
+ if ($mask != null) {
134
+ // 添加遮罩层
135
+ $anim.after($mask);
136
+ }
137
+ /* 保存 */
138
+ PopsHandler.handlePush(popsType, {
139
+ guid: guid,
140
+
141
+ animElement: $anim,
142
+
143
+ popsElement: $pops!,
144
+
145
+ maskElement: $mask!,
146
+ $shadowContainer: $shadowContainer,
147
+ $shadowRoot: $shadowRoot,
148
+ });
149
+ /* 拖拽 */
150
+ if (config.drag) {
151
+ PopsInstanceUtils.drag($pops!, {
152
+ dragElement: $title!,
153
+ limit: config.dragLimit,
154
+ extraDistance: config.dragExtraDistance!,
155
+ moveCallBack: config.dragMoveCallBack!,
156
+ endCallBack: config.dragEndCallBack!,
157
+ });
158
+ }
159
+
160
+ const result = PopsHandler.handleResultDetails(eventDetails);
161
+ return result;
162
+ },
163
+ };