@whitesev/pops 1.4.0 → 1.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 (105) hide show
  1. package/dist/index.amd.js.map +1 -1
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.iife.js.map +1 -1
  5. package/dist/index.system.js.map +1 -1
  6. package/dist/index.umd.js.map +1 -1
  7. package/package.json +50 -48
  8. package/src/Config.ts +3 -0
  9. package/src/Core.ts +45 -0
  10. package/src/Pops.ts +340 -0
  11. package/src/components/alert/index.css +45 -0
  12. package/src/components/alert/index.ts +216 -0
  13. package/src/components/alert/indexType.ts +30 -0
  14. package/src/components/confirm/index.css +45 -0
  15. package/src/components/confirm/index.ts +264 -0
  16. package/src/components/confirm/indexType.ts +17 -0
  17. package/src/components/drawer/index.css +47 -0
  18. package/src/components/drawer/index.ts +338 -0
  19. package/src/components/drawer/indexType.ts +53 -0
  20. package/src/components/folder/folderIcon.ts +28 -0
  21. package/src/components/folder/index.css +291 -0
  22. package/src/components/folder/index.ts +1111 -0
  23. package/src/components/folder/indexType.ts +87 -0
  24. package/src/components/iframe/index.css +90 -0
  25. package/src/components/iframe/index.ts +415 -0
  26. package/src/components/iframe/indexType.ts +144 -0
  27. package/src/components/loading/index.css +60 -0
  28. package/src/components/loading/index.ts +123 -0
  29. package/src/components/loading/indexType.ts +31 -0
  30. package/src/components/panel/buttonType.ts +60 -0
  31. package/src/components/panel/commonType.ts +50 -0
  32. package/src/components/panel/deepMenuType.ts +59 -0
  33. package/src/components/panel/formsType.ts +32 -0
  34. package/src/components/panel/index.css +754 -0
  35. package/src/components/panel/index.ts +2435 -0
  36. package/src/components/panel/indexType.ts +107 -0
  37. package/src/components/panel/inputType.ts +65 -0
  38. package/src/components/panel/ownType.ts +28 -0
  39. package/src/components/panel/selectType.ts +80 -0
  40. package/src/components/panel/sliderType.ts +59 -0
  41. package/src/components/panel/switchType.ts +43 -0
  42. package/src/components/panel/textareaType.ts +54 -0
  43. package/src/components/prompt/index.css +60 -0
  44. package/src/components/prompt/index.ts +293 -0
  45. package/src/components/prompt/indexType.ts +47 -0
  46. package/src/components/rightClickMenu/index.ts +729 -0
  47. package/src/components/rightClickMenu/indexType.ts +89 -0
  48. package/src/components/searchSuggestion/index.css +0 -0
  49. package/src/components/searchSuggestion/index.ts +656 -0
  50. package/src/components/searchSuggestion/indexType.ts +238 -0
  51. package/src/components/tooltip/index.css +171 -0
  52. package/src/components/tooltip/index.ts +358 -0
  53. package/src/components/tooltip/indexType.ts +95 -0
  54. package/src/css/animation.css +2240 -0
  55. package/src/css/button.css +290 -0
  56. package/src/css/common.css +24 -0
  57. package/src/css/index.css +135 -0
  58. package/src/css/ninePalaceGridPosition.css +50 -0
  59. package/src/css/scrollbar.css +18 -0
  60. package/src/handler/PopsElementHandler.ts +353 -0
  61. package/src/handler/PopsHandler.ts +659 -0
  62. package/src/svg/arrowLeft.svg +4 -0
  63. package/src/svg/arrowRight.svg +4 -0
  64. package/src/svg/chromeFilled.svg +14 -0
  65. package/src/svg/circleClose.svg +8 -0
  66. package/src/svg/close.svg +5 -0
  67. package/src/svg/cpu.svg +8 -0
  68. package/src/svg/delete.svg +5 -0
  69. package/src/svg/documentCopy.svg +5 -0
  70. package/src/svg/edit.svg +8 -0
  71. package/src/svg/eleme.svg +5 -0
  72. package/src/svg/elemePlus.svg +5 -0
  73. package/src/svg/headset.svg +5 -0
  74. package/src/svg/hide.svg +8 -0
  75. package/src/svg/keyboard.svg +8 -0
  76. package/src/svg/loading.svg +5 -0
  77. package/src/svg/max.svg +5 -0
  78. package/src/svg/min.svg +5 -0
  79. package/src/svg/mise.svg +5 -0
  80. package/src/svg/monitor.svg +5 -0
  81. package/src/svg/next.svg +5 -0
  82. package/src/svg/picture.svg +8 -0
  83. package/src/svg/prev.svg +5 -0
  84. package/src/svg/search.svg +5 -0
  85. package/src/svg/share.svg +5 -0
  86. package/src/svg/upload.svg +5 -0
  87. package/src/svg/videoPause.svg +5 -0
  88. package/src/svg/videoPlay.svg +5 -0
  89. package/src/svg/view.svg +5 -0
  90. package/src/types/PopsDOMUtilsEventType.d.ts +246 -0
  91. package/src/types/animation.d.ts +19 -0
  92. package/src/types/button.d.ts +226 -0
  93. package/src/types/components.d.ts +197 -0
  94. package/src/types/event.d.ts +62 -0
  95. package/src/types/global.d.ts +11 -0
  96. package/src/types/icon.d.ts +32 -0
  97. package/src/types/layer.d.ts +20 -0
  98. package/src/types/main.d.ts +136 -0
  99. package/src/types/mask.d.ts +35 -0
  100. package/src/types/position.d.ts +60 -0
  101. package/src/utils/AnyTouch.js +1394 -0
  102. package/src/utils/PopsDOMUtils.ts +2013 -0
  103. package/src/utils/PopsInstanceUtils.ts +685 -0
  104. package/src/utils/PopsMathUtils.ts +77 -0
  105. package/src/utils/PopsUtils.ts +380 -0
@@ -0,0 +1,293 @@
1
+ import { PopsElementHandler } from "../../handler/PopsElementHandler";
2
+ import { PopsHandler } from "../../handler/PopsHandler";
3
+ import { pops } from "../../Pops";
4
+ import { popsDOMUtils } from "../../utils/PopsDOMUtils";
5
+ import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
6
+ import { popsUtils } from "../../utils/PopsUtils";
7
+ import type { PopsPromptDetails } from "./indexType";
8
+
9
+ export class PopsPrompt {
10
+ constructor(details: PopsPromptDetails) {
11
+ const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow();
12
+ PopsHandler.handleInit($shadowRoot, [
13
+ pops.config.cssText.index,
14
+ pops.config.cssText.ninePalaceGridPosition,
15
+ pops.config.cssText.scrollbar,
16
+ pops.config.cssText.button,
17
+ pops.config.cssText.anim,
18
+ pops.config.cssText.common,
19
+ pops.config.cssText.promptCSS,
20
+ ]);
21
+ let config: Required<PopsPromptDetails> = {
22
+ title: {
23
+ text: "默认标题",
24
+ position: "left",
25
+ html: false,
26
+ style: "",
27
+ },
28
+ content: {
29
+ text: "",
30
+ password: false,
31
+ row: false,
32
+ focus: true,
33
+ placeholder: "默认提示",
34
+ style: "",
35
+ },
36
+ btn: {
37
+ merge: false,
38
+ mergeReverse: false,
39
+ reverse: false,
40
+ position: "flex-end",
41
+ ok: {
42
+ enable: true,
43
+
44
+ size: void 0,
45
+
46
+ icon: void 0,
47
+ rightIcon: false,
48
+ iconIsLoading: false,
49
+ text: "确定",
50
+ type: "success",
51
+ callback(event) {
52
+ console.log(event);
53
+ event.close();
54
+ },
55
+ },
56
+ cancel: {
57
+ enable: true,
58
+
59
+ size: void 0,
60
+
61
+ icon: void 0,
62
+ rightIcon: false,
63
+ iconIsLoading: false,
64
+ text: "关闭",
65
+ type: "default",
66
+ callback(event) {
67
+ console.log(event);
68
+ event.close();
69
+ },
70
+ },
71
+ other: {
72
+ enable: false,
73
+
74
+ size: void 0,
75
+
76
+ icon: void 0,
77
+ rightIcon: false,
78
+ iconIsLoading: false,
79
+ text: "其它按钮",
80
+ type: "default",
81
+ callback(event) {
82
+ console.log(event);
83
+ event.close();
84
+ },
85
+ },
86
+ close: {
87
+ enable: true,
88
+ callback(event) {
89
+ console.log(event);
90
+ event.close();
91
+ },
92
+ },
93
+ },
94
+ class: "",
95
+ only: false,
96
+ width: "350px",
97
+ height: "200px",
98
+ position: "center",
99
+ animation: "pops-anim-fadein-zoom",
100
+ zIndex: 10000,
101
+ mask: {
102
+ enable: false,
103
+ clickEvent: {
104
+ toClose: false,
105
+ toHide: false,
106
+ },
107
+
108
+ clickCallBack: void 0,
109
+ },
110
+ drag: false,
111
+ dragLimit: true,
112
+ dragExtraDistance: 3,
113
+ dragMoveCallBack() {},
114
+ dragEndCallBack() {},
115
+ forbiddenScroll: false,
116
+
117
+ style: null,
118
+ beforeAppendToPageCallBack() {},
119
+ };
120
+ config = popsUtils.assign(config, details);
121
+ let guid = popsUtils.getRandomGUID();
122
+ const PopsType = "prompt";
123
+
124
+ config = PopsHandler.handleOnly(PopsType, config);
125
+
126
+ let maskHTML = PopsElementHandler.getMaskHTML(guid, config.zIndex);
127
+
128
+ let headerBtnHTML = PopsElementHandler.getHeaderBtnHTML(PopsType, config);
129
+ let bottomBtnHTML = PopsElementHandler.getBottomBtnHTML(PopsType, config);
130
+ let { headerStyle, headerPStyle } = PopsElementHandler.getHeaderStyle(
131
+ PopsType,
132
+ config
133
+ );
134
+ let { contentPStyle } = PopsElementHandler.getContentStyle(
135
+ PopsType,
136
+ config
137
+ );
138
+ let animHTML = PopsElementHandler.getAnimHTML(
139
+ guid,
140
+ PopsType,
141
+ config,
142
+ `
143
+ <div class="pops-prompt-title" style="text-align: ${
144
+ config.title.position
145
+ };${headerStyle}">
146
+ ${
147
+ config.title.html
148
+ ? config.title.text
149
+ : `<p pops style="${headerPStyle}">${config.title.text}</p>`
150
+ }
151
+ ${headerBtnHTML}
152
+ </div>
153
+ <div class="pops-prompt-content" style="${contentPStyle}">
154
+ ${
155
+ config.content.row
156
+ ? '<textarea pops="" placeholder="' +
157
+ config.content.placeholder +
158
+ '"></textarea>'
159
+ : '<input pops="" placeholder="' +
160
+ config.content.placeholder +
161
+ '" type="' +
162
+ (config.content.password ? "password" : "text") +
163
+ '">'
164
+ }
165
+ </div>
166
+ ${bottomBtnHTML}
167
+ `,
168
+ bottomBtnHTML
169
+ );
170
+ /**
171
+ * 弹窗的主元素,包括动画层
172
+ */
173
+
174
+ let $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
175
+
176
+ let {
177
+ popsElement: $pops,
178
+ inputElement: $input,
179
+ headerCloseBtnElement: $btnClose,
180
+ btnOkElement: $btnOk,
181
+ btnCancelElement: $btnCancel,
182
+ btnOtherElement: $btnOther,
183
+ titleElement: $title,
184
+ } = PopsHandler.handleQueryElement($anim, PopsType);
185
+ /**
186
+ * 遮罩层元素
187
+ */
188
+ let $mask: HTMLDivElement | null = null;
189
+
190
+ /**
191
+ * 已创建的元素列表
192
+ */
193
+ let elementList: HTMLElement[] = [$anim];
194
+
195
+ if (config.mask.enable) {
196
+ // 启用遮罩层
197
+ let _handleMask_ = PopsHandler.handleMask({
198
+ type: PopsType,
199
+ guid: guid,
200
+ config: config,
201
+ animElement: $anim,
202
+ maskHTML: maskHTML,
203
+ });
204
+ $mask = _handleMask_.maskElement;
205
+ elementList.push($mask);
206
+ }
207
+ let eventDetails = PopsHandler.handleEventDetails(
208
+ guid,
209
+ $shadowContainer,
210
+ $shadowRoot,
211
+ PopsType,
212
+ $anim,
213
+
214
+ $pops!,
215
+ $mask!,
216
+ config
217
+ );
218
+ /* 输入框赋值初始值 */
219
+
220
+ $input!.value = config.content.text;
221
+ PopsHandler.handlePromptClickEvent(
222
+ "close",
223
+ $input!,
224
+ $btnClose!,
225
+ eventDetails,
226
+
227
+ config.btn.close!.callback!
228
+ );
229
+
230
+ PopsHandler.handlePromptClickEvent(
231
+ "ok",
232
+ $input!,
233
+ $btnOk!,
234
+ eventDetails,
235
+
236
+ config.btn.ok!.callback!
237
+ );
238
+ PopsHandler.handlePromptClickEvent(
239
+ "cancel",
240
+ $input!,
241
+ $btnCancel!,
242
+ eventDetails,
243
+
244
+ config.btn.cancel!.callback!
245
+ );
246
+
247
+ PopsHandler.handlePromptClickEvent(
248
+ "other",
249
+ $input!,
250
+ $btnOther!,
251
+ eventDetails,
252
+
253
+ config.btn.other!.callback!
254
+ );
255
+ /* 创建到页面中 */
256
+
257
+ popsDOMUtils.append($shadowRoot, elementList);
258
+ if (typeof config.beforeAppendToPageCallBack === "function") {
259
+ config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
260
+ }
261
+
262
+ popsDOMUtils.appendBody($shadowContainer);
263
+ if ($mask != null) {
264
+ $anim.after($mask);
265
+ }
266
+ PopsHandler.handlePush(PopsType, {
267
+ guid: guid,
268
+ animElement: $anim,
269
+
270
+ popsElement: $pops!,
271
+
272
+ maskElement: $mask!,
273
+ $shadowContainer: $shadowContainer,
274
+ $shadowRoot: $shadowRoot,
275
+ });
276
+ /* 拖拽 */
277
+ if (config.drag) {
278
+ PopsInstanceUtils.drag($pops!, {
279
+ dragElement: $title!,
280
+ limit: config.dragLimit,
281
+ extraDistance: config.dragExtraDistance,
282
+ moveCallBack: config.dragMoveCallBack,
283
+ endCallBack: config.dragEndCallBack,
284
+ });
285
+ }
286
+ /* 设置自动获取焦点 */
287
+ if (config.content.focus) {
288
+ $input?.focus();
289
+ }
290
+
291
+ return PopsHandler.handleResultDetails(eventDetails);
292
+ }
293
+ }
@@ -0,0 +1,47 @@
1
+ import type {
2
+ PopsTitleConfig,
3
+ PopsDragConfig,
4
+ PopsCommonConfig,
5
+ PopsMoreButtonConfig,
6
+ } from "../../types/components";
7
+
8
+ /**
9
+ * pops.prompt
10
+ */
11
+ export interface PopsPromptDetails
12
+ extends PopsTitleConfig,
13
+ PopsDragConfig,
14
+ PopsMoreButtonConfig<{
15
+ text: string;
16
+ }>,
17
+ PopsCommonConfig {
18
+ /**
19
+ * 内容配置
20
+ */
21
+ content: {
22
+ /**
23
+ * 内容文字
24
+ */
25
+ text: string;
26
+ /**
27
+ * 是否是密码
28
+ */
29
+ password?: boolean;
30
+ /**
31
+ * 是否支持多行输入
32
+ */
33
+ row?: boolean;
34
+ /**
35
+ * 是否自动获取焦点
36
+ */
37
+ focus?: boolean;
38
+ /**
39
+ * 输入框内的提示文字
40
+ */
41
+ placeholder?: string;
42
+ /**
43
+ * (可选)文字的自定义CSS
44
+ */
45
+ style?: string;
46
+ };
47
+ }