@whitesev/pops 2.2.5 → 2.2.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.
@@ -22,7 +22,7 @@ export const PopsElementHandler = {
22
22
  * @param zIndex z-index
23
23
  * @param style
24
24
  */
25
- getMaskHTML(guid: string, zIndex: number = 101, style = ""): string {
25
+ createMask(guid: string, zIndex: number = 101, style = ""): string {
26
26
  zIndex = zIndex - 100;
27
27
  if (style.startsWith(";")) {
28
28
  style = style.replace(";", "");
@@ -38,7 +38,7 @@ export const PopsElementHandler = {
38
38
  * @param bottomBtnHTML
39
39
  * @param zIndex
40
40
  */
41
- getAnimHTML(
41
+ createAnim(
42
42
  guid: string,
43
43
  type: PopsSupportAnimDetailsType,
44
44
  config: PopsSupportAnimDetails[keyof PopsSupportAnimDetails],
@@ -79,38 +79,40 @@ export const PopsElementHandler = {
79
79
  * @param type
80
80
  * @param config
81
81
  */
82
- getHeaderBtnHTML(
82
+ createHeader(
83
83
  type: PopsSupportHeaderTitleDetailsType,
84
84
  config: PopsSupportHeaderTitleDetails[keyof PopsSupportHeaderTitleDetails]
85
85
  ): string {
86
86
  if (!config.btn) {
87
87
  return "";
88
88
  }
89
- let __config_confirm = config as PopsConfirmDetails;
90
- if (type !== "iframe" && !__config_confirm.btn?.close?.enable) {
89
+ let confirm_config = config as PopsConfirmDetails;
90
+ if (type !== "iframe" && !confirm_config.btn?.close?.enable) {
91
91
  return "";
92
92
  }
93
93
  let resultHTML = "";
94
94
  // let btnStyle = "";
95
95
  let closeHTML = "";
96
- let __config_iframe = config as PopsIframeDetails;
97
- if (type === "iframe" && __config_iframe.topRightButton?.trim() !== "") {
96
+ let iframe_config = config as PopsIframeDetails;
97
+ if (type === "iframe" && iframe_config.topRightButton?.trim() !== "") {
98
98
  /* iframe的 */
99
99
  let topRightButtonHTML = "";
100
- __config_iframe.topRightButton.split("|").forEach((item: string) => {
100
+ iframe_config.topRightButton.split("|").forEach((item: string) => {
101
+ // 最小化、最大化、窗口化、关闭按钮
101
102
  item = item.toLowerCase();
102
103
  topRightButtonHTML += /*html*/ `
103
- <button class="pops-header-control" type="${item}">
104
+ <button class="pops-header-control" type="button" data-type="${item}">
104
105
  <i class="pops-icon">${PopsIcon.getIcon(item)}</i>
105
106
  </button>`;
106
107
  });
107
108
  resultHTML = /*html*/ `
108
109
  <div class="pops-header-controls" data-margin>${topRightButtonHTML}</div>`;
109
110
  } else {
110
- if (__config_confirm.btn?.close?.enable) {
111
+ if (confirm_config.btn?.close?.enable) {
112
+ // 关闭按钮
111
113
  closeHTML = /*html*/ `
112
114
  <div class="pops-header-controls">
113
- <button class="pops-header-control" type="close" data-header>
115
+ <button class="pops-header-control" type="button" data-type="close" data-header>
114
116
  <i class="pops-icon">${PopsIcon.getIcon("close")}</i>
115
117
  </button>
116
118
  </div>`;
@@ -120,25 +122,42 @@ export const PopsElementHandler = {
120
122
 
121
123
  return resultHTML;
122
124
  },
125
+ /**
126
+ * 获取标题style
127
+ * @param type 弹窗类型
128
+ * @param config 弹窗配置
129
+ */
130
+ createHeaderStyle(
131
+ type: PopsSupportHeaderTitleDetailsType,
132
+ config: PopsSupportHeaderTitleDetails[keyof PopsSupportHeaderTitleDetails]
133
+ ) {
134
+ return {
135
+ headerStyle: config?.title?.html ? config?.title?.style || "" : "",
136
+ headerPStyle: config?.title?.html ? "" : config?.title?.style || "",
137
+ };
138
+ },
123
139
  /**
124
140
  * 获取底部按钮层HTML
125
141
  * @param type
126
142
  * @param config
127
143
  */
128
- getBottomBtnHTML(
144
+ createBottom(
129
145
  type: PopsSupportBottomBtnDetailsType,
130
- config: Omit<PopsSupportBottomBtnDetails[keyof PopsSupportBottomBtnDetails], "content">
146
+ config: Omit<
147
+ PopsSupportBottomBtnDetails[keyof PopsSupportBottomBtnDetails],
148
+ "content"
149
+ >
131
150
  ): string {
132
- if (!config.btn) {
151
+ if (config.btn == null) {
133
152
  // 未设置btn参数
134
153
  return "";
135
154
  }
136
- let __config_confirm = config as Required<PopsConfirmDetails>;
155
+ let confirm_config = config as Required<PopsConfirmDetails>;
137
156
  if (
138
157
  !(
139
158
  config.btn?.ok?.enable ||
140
- __config_confirm.btn?.cancel?.enable ||
141
- __config_confirm.btn?.other?.enable
159
+ confirm_config.btn?.cancel?.enable ||
160
+ confirm_config.btn?.other?.enable
142
161
  )
143
162
  ) {
144
163
  // 确定、取消、其它按钮都未启用直接返回
@@ -154,7 +173,7 @@ export const PopsElementHandler = {
154
173
  btnStyle += `justify-content: ${config.btn.position};`;
155
174
  }
156
175
 
157
- if (__config_confirm.btn.reverse) {
176
+ if (confirm_config.btn.reverse) {
158
177
  btnStyle += "flex-direction: row-reverse;";
159
178
  }
160
179
  if (config.btn?.ok?.enable) {
@@ -166,7 +185,7 @@ export const PopsElementHandler = {
166
185
  okButtonSizeClassName = "pops-button-" + config.btn.ok.size;
167
186
  }
168
187
  let okIconHTML = "";
169
- let okIcon = __config_confirm.btn.ok!.icon! as PopsIconType | string;
188
+ let okIcon = confirm_config.btn.ok!.icon! as PopsIconType | string;
170
189
  if (okIcon !== "") {
171
190
  // 判断图标是否是svg库内的
172
191
  let iconHTML = "";
@@ -180,29 +199,28 @@ export const PopsElementHandler = {
180
199
  }
181
200
  okHTML = /*html*/ `
182
201
  <button
183
- class="pops-${type}-btn-ok ${okButtonSizeClassName}"
184
- type="${__config_confirm.btn.ok?.type}"
185
- data-has-icon="${(__config_confirm.btn.ok!.icon || "") !== ""}"
186
- data-rightIcon="${__config_confirm.btn.ok?.rightIcon}"
202
+ class="pops-${type}-btn-ok ${okButtonSizeClassName}"
203
+ type="button"
204
+ data-type="${confirm_config.btn.ok?.type}"
205
+ data-has-icon="${(confirm_config.btn.ok!.icon || "") !== ""}"
206
+ data-rightIcon="${confirm_config.btn.ok?.rightIcon}"
187
207
  >${okIconHTML}<span>${config.btn.ok.text}</span>
188
208
  </button>`;
189
209
  }
190
210
 
191
- if (__config_confirm.btn?.cancel?.enable) {
211
+ if (confirm_config.btn?.cancel?.enable) {
192
212
  /* 处理取消按钮的尺寸问题 */
193
213
  let cancelButtonSizeClassName = "";
194
214
 
195
- if (__config_confirm.btn.cancel.size === "large") {
215
+ if (confirm_config.btn.cancel.size === "large") {
196
216
  cancelButtonSizeClassName =
197
- "pops-button-" + __config_confirm.btn.cancel.size;
198
- } else if (__config_confirm.btn.cancel.size === "small") {
217
+ "pops-button-" + confirm_config.btn.cancel.size;
218
+ } else if (confirm_config.btn.cancel.size === "small") {
199
219
  cancelButtonSizeClassName =
200
- "pops-button-" + __config_confirm.btn.cancel.size;
220
+ "pops-button-" + confirm_config.btn.cancel.size;
201
221
  }
202
222
  let cancelIconHTML = "";
203
- let cancelIcon = __config_confirm.btn.cancel!.icon as
204
- | PopsIconType
205
- | string;
223
+ let cancelIcon = confirm_config.btn.cancel!.icon as PopsIconType | string;
206
224
  if (cancelIcon !== "") {
207
225
  let iconHTML = "";
208
226
  // 判断图标是否是svg库内的
@@ -212,31 +230,32 @@ export const PopsElementHandler = {
212
230
  iconHTML = cancelIcon;
213
231
  }
214
232
  iconHTML = iconHTML || "";
215
- cancelIconHTML = /*html*/ `<i class="pops-bottom-icon" is-loading="${__config_confirm.btn.cancel.iconIsLoading}">${iconHTML}</i>`;
233
+ cancelIconHTML = /*html*/ `<i class="pops-bottom-icon" is-loading="${confirm_config.btn.cancel.iconIsLoading}">${iconHTML}</i>`;
216
234
  }
217
235
  cancelHTML = /*html*/ `
218
236
  <button
219
- class="pops-${type}-btn-cancel ${cancelButtonSizeClassName}"
220
- type="${__config_confirm.btn.cancel.type}"
221
- data-has-icon="${(__config_confirm.btn.cancel.icon || "") !== ""}"
222
- data-rightIcon="${__config_confirm.btn.cancel.rightIcon}"
223
- >${cancelIconHTML}<span>${__config_confirm.btn.cancel.text}</span>
237
+ class="pops-${type}-btn-cancel ${cancelButtonSizeClassName}"
238
+ type="button"
239
+ data-type="${confirm_config.btn.cancel.type}"
240
+ data-has-icon="${(confirm_config.btn.cancel.icon || "") !== ""}"
241
+ data-rightIcon="${confirm_config.btn.cancel.rightIcon}"
242
+ >${cancelIconHTML}<span>${confirm_config.btn.cancel.text}</span>
224
243
  </button>`;
225
244
  }
226
245
 
227
- if (__config_confirm.btn?.other?.enable) {
246
+ if (confirm_config.btn?.other?.enable) {
228
247
  /* 处理其它按钮的尺寸问题 */
229
248
  let otherButtonSizeClassName = "";
230
249
 
231
- if (__config_confirm.btn.other.size === "large") {
250
+ if (confirm_config.btn.other.size === "large") {
232
251
  otherButtonSizeClassName =
233
- "pops-button-" + __config_confirm.btn.other.size;
234
- } else if (__config_confirm.btn.other.size === "small") {
252
+ "pops-button-" + confirm_config.btn.other.size;
253
+ } else if (confirm_config.btn.other.size === "small") {
235
254
  otherButtonSizeClassName =
236
- "pops-button-" + __config_confirm.btn.other.size;
255
+ "pops-button-" + confirm_config.btn.other.size;
237
256
  }
238
257
  let otherIconHTML = "";
239
- let otherIcon = __config_confirm.btn.other!.icon as PopsIconType | string;
258
+ let otherIcon = confirm_config.btn.other!.icon as PopsIconType | string;
240
259
  if (otherIcon !== "") {
241
260
  let iconHTML = "";
242
261
  // 判断图标是否是svg库内的
@@ -246,21 +265,22 @@ export const PopsElementHandler = {
246
265
  otherIcon;
247
266
  }
248
267
  iconHTML = iconHTML || "";
249
- otherIconHTML = /*html*/ `<i class="pops-bottom-icon" is-loading="${__config_confirm.btn.other.iconIsLoading}">${iconHTML}</i>`;
268
+ otherIconHTML = /*html*/ `<i class="pops-bottom-icon" is-loading="${confirm_config.btn.other.iconIsLoading}">${iconHTML}</i>`;
250
269
  }
251
270
  ohterHTML = /*html*/ `
252
271
  <button
253
- class="pops-${type}-btn-other ${otherButtonSizeClassName}"
254
- type="${__config_confirm.btn.other.type}"
255
- data-has-icon="${(__config_confirm.btn.other.icon || "") !== ""}"
256
- data-rightIcon="${__config_confirm.btn.other.rightIcon}"
257
- >${otherIconHTML}<span>${__config_confirm.btn.other.text}</span>
272
+ class="pops-${type}-btn-other ${otherButtonSizeClassName}"
273
+ type="button"
274
+ data-type="${confirm_config.btn.other.type}"
275
+ data-has-icon="${(confirm_config.btn.other.icon || "") !== ""}"
276
+ data-rightIcon="${confirm_config.btn.other.rightIcon}"
277
+ >${otherIconHTML}<span>${confirm_config.btn.other.text}</span>
258
278
  </button>`;
259
279
  }
260
280
 
261
- if (__config_confirm.btn.merge) {
281
+ if (confirm_config.btn.merge) {
262
282
  let flexStyle = "display: flex;";
263
- if (__config_confirm.btn.mergeReverse) {
283
+ if (confirm_config.btn.mergeReverse) {
264
284
  flexStyle += "flex-direction: row-reverse;";
265
285
  } else {
266
286
  flexStyle += "flex-direction: row;";
@@ -276,27 +296,12 @@ export const PopsElementHandler = {
276
296
  }
277
297
  return resultHTML;
278
298
  },
279
- /**
280
- * 获取标题style
281
- * @param type 弹窗类型
282
- * @param config 弹窗配置
283
- */
284
- getHeaderStyle(
285
- type: PopsSupportHeaderTitleDetailsType,
286
- config: PopsSupportHeaderTitleDetails[keyof PopsSupportHeaderTitleDetails]
287
- ) {
288
- return {
289
- headerStyle: config?.title?.html ? config?.title?.style || "" : "",
290
-
291
- headerPStyle: config?.title?.html ? "" : config?.title?.style || "",
292
- };
293
- },
294
299
  /**
295
300
  * 获取内容style
296
301
  * @param type 弹窗类型
297
302
  * @param config 弹窗配置
298
303
  */
299
- getContentStyle(
304
+ createContentStyle(
300
305
  type: PopsSupportContentDetailsType,
301
306
  config: PopsSupportContentDetails[keyof PopsSupportContentDetails]
302
307
  ) {
@@ -324,25 +324,25 @@ export const PopsHandler = {
324
324
  * 顶部缩小按钮
325
325
  */
326
326
  headerMinBtnElement: animElement.querySelector<HTMLDivElement>(
327
- ".pops-header-control[type='min']"
327
+ ".pops-header-control[data-type='min']"
328
328
  )!,
329
329
  /**
330
330
  * 顶部放大按钮
331
331
  */
332
332
  headerMaxBtnElement: animElement.querySelector<HTMLDivElement>(
333
- ".pops-header-control[type='max']"
333
+ ".pops-header-control[data-type='max']"
334
334
  )!,
335
335
  /**
336
336
  * 顶部恢复原样按钮
337
337
  */
338
338
  headerMiseBtnElement: animElement.querySelector<HTMLDivElement>(
339
- ".pops-header-control[type='mise']"
339
+ ".pops-header-control[data-type='mise']"
340
340
  )!,
341
341
  /**
342
342
  * 顶部关闭按钮
343
343
  */
344
344
  headerCloseBtnElement: animElement.querySelector<HTMLDivElement>(
345
- ".pops-header-control[type='close']"
345
+ ".pops-header-control[data-type='close']"
346
346
  )!,
347
347
  /**
348
348
  * 文件夹列表元素