@whitesev/pops 2.6.1 → 3.0.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 (160) hide show
  1. package/dist/index.amd.js +1208 -1067
  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 +1208 -1067
  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 +1208 -1067
  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 +1208 -1067
  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 +1208 -1067
  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 +1208 -1067
  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/eslint.config.d.mts +2 -0
  26. package/dist/types/src/Pops.d.ts +98 -103
  27. package/dist/types/src/PopsInst.d.ts +2 -2
  28. package/dist/types/src/components/alert/defaultConfig.d.ts +2 -0
  29. package/dist/types/src/components/alert/index.d.ts +2 -2
  30. package/dist/types/src/components/alert/types/index.d.ts +4 -4
  31. package/dist/types/src/components/confirm/defaultConfig.d.ts +2 -0
  32. package/dist/types/src/components/confirm/index.d.ts +2 -2
  33. package/dist/types/src/components/confirm/types/index.d.ts +2 -2
  34. package/dist/types/src/components/drawer/defaultConfig.d.ts +2 -0
  35. package/dist/types/src/components/drawer/index.d.ts +2 -2
  36. package/dist/types/src/components/drawer/types/index.d.ts +2 -2
  37. package/dist/types/src/components/folder/defaultConfig.d.ts +2 -0
  38. package/dist/types/src/components/folder/index.d.ts +2 -2
  39. package/dist/types/src/components/folder/types/index.d.ts +31 -7
  40. package/dist/types/src/components/iframe/defaultConfig.d.ts +2 -0
  41. package/dist/types/src/components/iframe/index.d.ts +2 -5
  42. package/dist/types/src/components/iframe/types/index.d.ts +13 -42
  43. package/dist/types/src/components/loading/defaultConfig.d.ts +2 -0
  44. package/dist/types/src/components/loading/index.d.ts +2 -2
  45. package/dist/types/src/components/loading/types/index.d.ts +4 -4
  46. package/dist/types/src/components/panel/defaultConfig.d.ts +2 -0
  47. package/dist/types/src/components/panel/handlerComponents.d.ts +47 -43
  48. package/dist/types/src/components/panel/index.d.ts +3 -3
  49. package/dist/types/src/components/panel/types/components-button.d.ts +7 -6
  50. package/dist/types/src/components/panel/types/components-common.d.ts +7 -7
  51. package/dist/types/src/components/panel/types/components-container.d.ts +24 -0
  52. package/dist/types/src/components/panel/types/components-deepMenu.d.ts +13 -13
  53. package/dist/types/src/components/panel/types/components-input.d.ts +6 -6
  54. package/dist/types/src/components/panel/types/components-own.d.ts +2 -2
  55. package/dist/types/src/components/panel/types/components-select.d.ts +9 -9
  56. package/dist/types/src/components/panel/types/components-selectMultiple.d.ts +8 -8
  57. package/dist/types/src/components/panel/types/components-slider.d.ts +7 -7
  58. package/dist/types/src/components/panel/types/components-switch.d.ts +6 -6
  59. package/dist/types/src/components/panel/types/components-textarea.d.ts +6 -6
  60. package/dist/types/src/components/panel/types/index.d.ts +36 -28
  61. package/dist/types/src/components/prompt/defaultConfig.d.ts +2 -0
  62. package/dist/types/src/components/prompt/index.d.ts +2 -2
  63. package/dist/types/src/components/prompt/types/index.d.ts +4 -3
  64. package/dist/types/src/components/rightClickMenu/defaultConfig.d.ts +2 -0
  65. package/dist/types/src/components/rightClickMenu/index.d.ts +29 -27
  66. package/dist/types/src/components/rightClickMenu/types/index.d.ts +32 -11
  67. package/dist/types/src/components/searchSuggestion/defaultConfig.d.ts +2 -0
  68. package/dist/types/src/components/searchSuggestion/index.d.ts +21 -6
  69. package/dist/types/src/components/searchSuggestion/types/index.d.ts +15 -13
  70. package/dist/types/src/components/tooltip/defaultConfig.d.ts +2 -0
  71. package/dist/types/src/components/tooltip/index.d.ts +6 -21
  72. package/dist/types/src/components/tooltip/types/index.d.ts +8 -6
  73. package/dist/types/src/config/GlobalConfig.d.ts +3 -3
  74. package/dist/types/src/handler/PopsElementHandler.d.ts +6 -6
  75. package/dist/types/src/handler/PopsHandler.d.ts +18 -18
  76. package/dist/types/src/types/button.d.ts +4 -97
  77. package/dist/types/src/types/components.d.ts +8 -8
  78. package/dist/types/src/types/event.d.ts +0 -30
  79. package/dist/types/src/types/global.d.ts +2 -0
  80. package/dist/types/src/types/inst.d.ts +5 -5
  81. package/dist/types/src/types/main.d.ts +35 -80
  82. package/dist/types/src/types/mask.d.ts +18 -15
  83. package/dist/types/src/utils/PopsInstanceUtils.d.ts +15 -15
  84. package/dist/types/src/utils/PopsUtils.d.ts +4 -0
  85. package/package.json +10 -10
  86. package/src/Pops.ts +44 -44
  87. package/src/PopsAnimation.ts +1 -1
  88. package/src/PopsInst.ts +2 -2
  89. package/src/components/alert/{config.ts → defaultConfig.ts} +7 -7
  90. package/src/components/alert/index.ts +16 -18
  91. package/src/components/alert/types/index.ts +4 -4
  92. package/src/components/confirm/{config.ts → defaultConfig.ts} +11 -11
  93. package/src/components/confirm/index.ts +11 -13
  94. package/src/components/confirm/types/index.ts +3 -3
  95. package/src/components/drawer/{config.ts → defaultConfig.ts} +10 -10
  96. package/src/components/drawer/index.ts +18 -17
  97. package/src/components/drawer/types/index.ts +3 -3
  98. package/src/components/folder/{config.ts → defaultConfig.ts} +22 -18
  99. package/src/components/folder/index.ts +61 -60
  100. package/src/components/folder/types/index.ts +31 -18
  101. package/src/components/iframe/{config.ts → defaultConfig.ts} +2 -2
  102. package/src/components/iframe/index.ts +24 -29
  103. package/src/components/iframe/types/index.ts +13 -56
  104. package/src/components/loading/{config.ts → defaultConfig.ts} +3 -3
  105. package/src/components/loading/index.ts +13 -11
  106. package/src/components/loading/types/index.ts +5 -5
  107. package/src/components/panel/{config.ts → defaultConfig.ts} +115 -37
  108. package/src/components/panel/handlerComponents.ts +445 -427
  109. package/src/components/panel/index.css +5 -1
  110. package/src/components/panel/index.ts +15 -28
  111. package/src/components/panel/types/components-button.ts +7 -6
  112. package/src/components/panel/types/components-common.ts +7 -7
  113. package/src/components/panel/types/components-container.ts +25 -0
  114. package/src/components/panel/types/components-deepMenu.ts +13 -13
  115. package/src/components/panel/types/components-input.ts +6 -6
  116. package/src/components/panel/types/components-own.ts +2 -2
  117. package/src/components/panel/types/components-select.ts +11 -11
  118. package/src/components/panel/types/components-selectMultiple.ts +8 -9
  119. package/src/components/panel/types/components-slider.ts +7 -7
  120. package/src/components/panel/types/components-switch.ts +6 -6
  121. package/src/components/panel/types/components-textarea.ts +6 -6
  122. package/src/components/panel/types/index.ts +45 -38
  123. package/src/components/prompt/{config.ts → defaultConfig.ts} +10 -10
  124. package/src/components/prompt/index.ts +13 -15
  125. package/src/components/prompt/types/index.ts +4 -3
  126. package/src/components/rightClickMenu/{config.ts → defaultConfig.ts} +20 -19
  127. package/src/components/rightClickMenu/index.ts +125 -108
  128. package/src/components/rightClickMenu/types/index.ts +36 -14
  129. package/src/components/searchSuggestion/{config.ts → defaultConfig.ts} +18 -11
  130. package/src/components/searchSuggestion/index.ts +116 -96
  131. package/src/components/searchSuggestion/types/index.ts +17 -15
  132. package/src/components/tooltip/{config.ts → defaultConfig.ts} +5 -6
  133. package/src/components/tooltip/index.ts +21 -21
  134. package/src/components/tooltip/types/index.ts +9 -7
  135. package/src/config/GlobalConfig.ts +2 -2
  136. package/src/handler/PopsElementHandler.ts +29 -30
  137. package/src/handler/PopsHandler.ts +43 -43
  138. package/src/types/button.d.ts +4 -97
  139. package/src/types/components.d.ts +8 -8
  140. package/src/types/event.d.ts +0 -30
  141. package/src/types/global.d.ts +2 -0
  142. package/src/types/inst.d.ts +5 -5
  143. package/src/types/main.d.ts +35 -80
  144. package/src/types/mask.d.ts +18 -15
  145. package/src/utils/PopsDOMUtils.ts +34 -34
  146. package/src/utils/PopsInstanceUtils.ts +129 -139
  147. package/src/utils/PopsUtils.ts +60 -45
  148. package/dist/types/src/components/alert/config.d.ts +0 -2
  149. package/dist/types/src/components/confirm/config.d.ts +0 -2
  150. package/dist/types/src/components/drawer/config.d.ts +0 -2
  151. package/dist/types/src/components/folder/config.d.ts +0 -2
  152. package/dist/types/src/components/iframe/config.d.ts +0 -2
  153. package/dist/types/src/components/loading/config.d.ts +0 -2
  154. package/dist/types/src/components/panel/config.d.ts +0 -2
  155. package/dist/types/src/components/panel/types/components-forms.d.ts +0 -23
  156. package/dist/types/src/components/prompt/config.d.ts +0 -2
  157. package/dist/types/src/components/rightClickMenu/config.d.ts +0 -2
  158. package/dist/types/src/components/searchSuggestion/config.d.ts +0 -2
  159. package/dist/types/src/components/tooltip/config.d.ts +0 -2
  160. package/src/components/panel/types/components-forms.ts +0 -24
@@ -1,12 +1,12 @@
1
- import type { PopsAlertDetails } from "../components/alert/types";
2
- import type { PopsConfirmDetails } from "../components/confirm/types";
3
- import type { PopsDrawerDetails } from "../components/drawer/types";
4
- import type { PopsFolderDetails } from "../components/folder/types";
5
- import type { PopsIframeDetails } from "../components/iframe/types";
6
- import type { PopsLoadingDetails } from "../components/loading/types";
7
- import type { PopsPanelDetails } from "../components/panel/types";
8
- import type { PopsPromptDetails } from "../components/prompt/types/index";
9
- import type { PopsInstCommonConfig } from "../types/inst";
1
+ import type { PopsAlertConfig } from "../components/alert/types";
2
+ import type { PopsConfirmConfig } from "../components/confirm/types";
3
+ import type { PopsDrawerConfig } from "../components/drawer/types";
4
+ import type { PopsFolderConfig } from "../components/folder/types";
5
+ import type { PopsIframeConfig } from "../components/iframe/types";
6
+ import type { PopsLoadingConfig } from "../components/loading/types";
7
+ import type { PopsPanelConfig } from "../components/panel/types";
8
+ import type { PopsPromptConfig } from "../components/prompt/types/index";
9
+ import type { PopsInstGeneralConfig } from "../types/inst";
10
10
  import type { PopsInstStoreType } from "../types/main";
11
11
  import { popsDOMUtils } from "./PopsDOMUtils";
12
12
  import { popsUtils } from "./PopsUtils";
@@ -65,7 +65,7 @@ export const PopsInstanceUtils = {
65
65
  }
66
66
  /** 元素的样式 */
67
67
  const nodeStyle = PopsCore.window.getComputedStyle($ele);
68
- /* 不对position为static和display为none的元素进行获取它们的z-index */
68
+ // 不对position为static和display为none的元素进行获取它们的z-index
69
69
  if (isVisibleNode(nodeStyle)) {
70
70
  const nodeZIndex = parseInt(nodeStyle.zIndex);
71
71
  if (!isNaN(nodeZIndex)) {
@@ -122,14 +122,14 @@ export const PopsInstanceUtils = {
122
122
  const instData = PopsInstData[instKeyName as PopsInstStoreType];
123
123
  for (let index = 0; index < instData.length; index++) {
124
124
  const inst = instData[index];
125
- const nodeStyle = window.getComputedStyle(inst.animElement);
126
- /* 不对position为static和display为none的元素进行获取它们的z-index */
125
+ const nodeStyle = window.getComputedStyle(inst.$anim);
126
+ // 不对position为static和display为none的元素进行获取它们的z-index
127
127
  if (isVisibleNode(nodeStyle)) {
128
128
  const nodeZIndex = parseInt(nodeStyle.zIndex);
129
129
  if (!isNaN(nodeZIndex)) {
130
130
  if (nodeZIndex > zIndex) {
131
131
  zIndex = nodeZIndex;
132
- maxZIndexNode = inst.animElement;
132
+ maxZIndexNode = inst.$anim;
133
133
  }
134
134
  }
135
135
  }
@@ -159,19 +159,19 @@ export const PopsInstanceUtils = {
159
159
  * @param guid 唯一标识
160
160
  * @param isAll 是否全部删除
161
161
  */
162
- removeInstance(instConfigList: PopsInstCommonConfig[][], guid: string, isAll = false) {
162
+ removeInstance(instConfigList: PopsInstGeneralConfig[][], guid: string, isAll = false) {
163
163
  /**
164
164
  * 移除元素实例
165
165
  * @param instCommonConfig
166
166
  */
167
- function removeItem(instCommonConfig: PopsInstCommonConfig) {
167
+ function removeItem(instCommonConfig: PopsInstGeneralConfig) {
168
168
  if (typeof instCommonConfig.beforeRemoveCallBack === "function") {
169
169
  // 调用移除签的回调
170
170
  instCommonConfig.beforeRemoveCallBack(instCommonConfig);
171
171
  }
172
- instCommonConfig?.animElement?.remove();
173
- instCommonConfig?.popsElement?.remove();
174
- instCommonConfig?.maskElement?.remove();
172
+ instCommonConfig?.$anim?.remove();
173
+ instCommonConfig?.$pops?.remove();
174
+ instCommonConfig?.$mask?.remove();
175
175
  instCommonConfig?.$shadowContainer?.remove();
176
176
  }
177
177
  // [ inst[], inst[],...]
@@ -181,15 +181,15 @@ export const PopsInstanceUtils = {
181
181
  // 移除全部或者guid相同
182
182
  if (isAll || instConfigItem["guid"] === guid) {
183
183
  // 判断是否有动画
184
- const animName = instConfigItem.animElement.getAttribute("anim") as string;
184
+ const animName = instConfigItem.$anim.getAttribute("anim")!;
185
185
  if (PopsAnimation.hasAnim(animName)) {
186
186
  const reverseAnimName = animName + "-reverse";
187
- instConfigItem.animElement.style.width = "100%";
188
- instConfigItem.animElement.style.height = "100%";
189
- (instConfigItem.animElement.style as any)["animation-name"] = reverseAnimName;
190
- if (PopsAnimation.hasAnim((instConfigItem.animElement.style as any)["animation-name"])) {
187
+ instConfigItem.$anim.style.width = "100%";
188
+ instConfigItem.$anim.style.height = "100%";
189
+ (instConfigItem.$anim.style as any)["animation-name"] = reverseAnimName;
190
+ if (PopsAnimation.hasAnim((instConfigItem.$anim.style as any)["animation-name"])) {
191
191
  popsDOMUtils.on(
192
- instConfigItem.animElement,
192
+ instConfigItem.$anim,
193
193
  popsDOMUtils.getAnimationEndNameList(),
194
194
  function () {
195
195
  removeItem(instConfigItem);
@@ -222,32 +222,32 @@ export const PopsInstanceUtils = {
222
222
  */
223
223
  hide(
224
224
  config:
225
- | PopsAlertDetails
226
- | PopsDrawerDetails
227
- | PopsPromptDetails
228
- | PopsConfirmDetails
229
- | PopsIframeDetails
230
- | PopsLoadingDetails
231
- | PopsPanelDetails
232
- | PopsFolderDetails,
225
+ | PopsAlertConfig
226
+ | PopsDrawerConfig
227
+ | PopsPromptConfig
228
+ | PopsConfirmConfig
229
+ | PopsIframeConfig
230
+ | PopsLoadingConfig
231
+ | PopsPanelConfig
232
+ | PopsFolderConfig,
233
233
  popsType: PopsInstStoreType,
234
- instConfigList: PopsInstCommonConfig[],
234
+ instConfigList: PopsInstGeneralConfig[],
235
235
  guid: string,
236
236
  $anim: HTMLElement,
237
237
  $mask?: HTMLElement
238
238
  ) {
239
239
  return new Promise<void>((resolve) => {
240
- const popsElement = $anim.querySelector<HTMLDivElement>(".pops[type-value]")!;
240
+ const $pops = $anim.querySelector<HTMLDivElement>(".pops[type-value]")!;
241
241
  if (popsType === "drawer") {
242
- const drawerConfig = config as Required<PopsDrawerDetails>;
242
+ const drawerConfig = config as Required<PopsDrawerConfig>;
243
243
  popsUtils.setTimeout(() => {
244
244
  if ($mask) {
245
245
  popsDOMUtils.css($mask, "display", "none");
246
246
  }
247
247
  if (["top", "bottom"].includes(drawerConfig.direction)) {
248
- popsElement.style.setProperty("height", "0");
248
+ $pops.style.setProperty("height", "0");
249
249
  } else if (["left", "right"].includes(drawerConfig.direction)) {
250
- popsElement.style.setProperty("width", "0");
250
+ $pops.style.setProperty("width", "0");
251
251
  } else {
252
252
  console.error("未知direction:", drawerConfig.direction);
253
253
  }
@@ -256,41 +256,36 @@ export const PopsInstanceUtils = {
256
256
  } else {
257
257
  const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
258
258
  if (fintInst) {
259
- /* 存在动画 */
259
+ // 存在动画
260
260
  const instConfigItem = fintInst;
261
- instConfigItem.animElement.style.width = "100%";
262
- instConfigItem.animElement.style.height = "100%";
261
+ instConfigItem.$anim.style.width = "100%";
262
+ instConfigItem.$anim.style.height = "100%";
263
263
  Reflect.set(
264
- instConfigItem.animElement.style,
264
+ instConfigItem.$anim.style,
265
265
  "animation-name",
266
- instConfigItem.animElement.getAttribute("anim") + "-reverse"
266
+ instConfigItem.$anim.getAttribute("anim") + "-reverse"
267
267
  );
268
- if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.animElement.style, "animation-name"))) {
268
+ if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
269
269
  /**
270
270
  * 动画结束的回调
271
271
  */
272
272
  function animationendCallBack() {
273
- instConfigItem.animElement.style.display = "none";
274
- if (instConfigItem.maskElement) {
275
- instConfigItem.maskElement.style.display = "none";
273
+ instConfigItem.$anim.style.display = "none";
274
+ if (instConfigItem.$mask) {
275
+ instConfigItem.$mask.style.display = "none";
276
276
  }
277
- popsDOMUtils.off(
278
- instConfigItem.animElement,
279
- popsDOMUtils.getAnimationEndNameList(),
280
- animationendCallBack,
281
- {
282
- capture: true,
283
- }
284
- );
277
+ popsDOMUtils.off(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
278
+ capture: true,
279
+ });
285
280
  resolve();
286
281
  }
287
- popsDOMUtils.on(instConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
282
+ popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
288
283
  capture: true,
289
284
  });
290
285
  } else {
291
- instConfigItem.animElement.style.display = "none";
292
- if (instConfigItem.maskElement) {
293
- instConfigItem.maskElement.style.display = "none";
286
+ instConfigItem.$anim.style.display = "none";
287
+ if (instConfigItem.$mask) {
288
+ instConfigItem.$mask.style.display = "none";
294
289
  }
295
290
 
296
291
  resolve();
@@ -310,24 +305,24 @@ export const PopsInstanceUtils = {
310
305
  */
311
306
  show(
312
307
  config:
313
- | PopsAlertDetails
314
- | PopsDrawerDetails
315
- | PopsPromptDetails
316
- | PopsConfirmDetails
317
- | PopsIframeDetails
318
- | PopsLoadingDetails
319
- | PopsPanelDetails
320
- | PopsFolderDetails,
308
+ | PopsAlertConfig
309
+ | PopsDrawerConfig
310
+ | PopsPromptConfig
311
+ | PopsConfirmConfig
312
+ | PopsIframeConfig
313
+ | PopsLoadingConfig
314
+ | PopsPanelConfig
315
+ | PopsFolderConfig,
321
316
  popsType: PopsInstStoreType,
322
- instConfigList: PopsInstCommonConfig[],
317
+ instConfigList: PopsInstGeneralConfig[],
323
318
  guid: string,
324
319
  $anim: HTMLElement,
325
320
  $mask?: HTMLElement
326
321
  ) {
327
322
  return new Promise<void>((resolve) => {
328
- const popsElement = $anim.querySelector<HTMLDivElement>(".pops[type-value]")!;
323
+ const $pops = $anim.querySelector<HTMLDivElement>(".pops[type-value]")!;
329
324
  if (popsType === "drawer") {
330
- const drawerConfig = config as PopsDrawerDetails;
325
+ const drawerConfig = config as PopsDrawerConfig;
331
326
  popsUtils.setTimeout(() => {
332
327
  if ($mask) {
333
328
  popsDOMUtils.css($mask, "display", "");
@@ -335,9 +330,9 @@ export const PopsInstanceUtils = {
335
330
  const direction = drawerConfig.direction!;
336
331
  const size = drawerConfig.size!.toString();
337
332
  if (["top", "bottom"].includes(direction)) {
338
- popsElement.style.setProperty("height", size);
333
+ $pops.style.setProperty("height", size);
339
334
  } else if (["left", "right"].includes(direction)) {
340
- popsElement.style.setProperty("width", size);
335
+ $pops.style.setProperty("width", size);
341
336
  } else {
342
337
  console.error("未知direction:", direction);
343
338
  }
@@ -347,39 +342,34 @@ export const PopsInstanceUtils = {
347
342
  const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
348
343
  if (fintInst) {
349
344
  const instConfigItem = fintInst;
350
- instConfigItem.animElement.style.width = "";
351
- instConfigItem.animElement.style.height = "";
345
+ instConfigItem.$anim.style.width = "";
346
+ instConfigItem.$anim.style.height = "";
352
347
  Reflect.set(
353
- instConfigItem.animElement.style,
348
+ instConfigItem.$anim.style,
354
349
  "animation-name",
355
- instConfigItem.animElement!.getAttribute("anim")!.replace("-reverse", "")
350
+ instConfigItem.$anim!.getAttribute("anim")!.replace("-reverse", "")
356
351
  );
357
- if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.animElement.style, "animation-name"))) {
352
+ if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
358
353
  /**
359
354
  * 动画结束的回调
360
355
  */
361
356
  function animationendCallBack() {
362
- popsDOMUtils.off(
363
- instConfigItem.animElement,
364
- popsDOMUtils.getAnimationEndNameList(),
365
- animationendCallBack,
366
- {
367
- capture: true,
368
- }
369
- );
357
+ popsDOMUtils.off(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
358
+ capture: true,
359
+ });
370
360
  resolve();
371
361
  }
372
- instConfigItem.animElement.style.display = "";
373
- if (instConfigItem.maskElement) {
374
- instConfigItem.maskElement.style.display = "";
362
+ instConfigItem.$anim.style.display = "";
363
+ if (instConfigItem.$mask) {
364
+ instConfigItem.$mask.style.display = "";
375
365
  }
376
- popsDOMUtils.on(instConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
366
+ popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
377
367
  capture: true,
378
368
  });
379
369
  } else {
380
- instConfigItem.animElement.style.display = "";
381
- if (instConfigItem.maskElement) {
382
- instConfigItem.maskElement.style.display = "";
370
+ instConfigItem.$anim.style.display = "";
371
+ if (instConfigItem.$mask) {
372
+ instConfigItem.$mask.style.display = "";
383
373
  }
384
374
  resolve();
385
375
  }
@@ -397,22 +387,22 @@ export const PopsInstanceUtils = {
397
387
  */
398
388
  close(
399
389
  config:
400
- | PopsAlertDetails
401
- | PopsDrawerDetails
402
- | PopsPromptDetails
403
- | PopsConfirmDetails
404
- | PopsIframeDetails
405
- | PopsLoadingDetails
406
- | PopsPanelDetails
407
- | PopsFolderDetails,
390
+ | PopsAlertConfig
391
+ | PopsDrawerConfig
392
+ | PopsPromptConfig
393
+ | PopsConfirmConfig
394
+ | PopsIframeConfig
395
+ | PopsLoadingConfig
396
+ | PopsPanelConfig
397
+ | PopsFolderConfig,
408
398
  popsType: string,
409
- instConfigList: PopsInstCommonConfig[],
399
+ instConfigList: PopsInstGeneralConfig[],
410
400
  guid: string,
411
401
  $anim: HTMLElement
412
402
  ) {
413
403
  return new Promise<void>((resolve) => {
414
- const popsElement = $anim.querySelector<HTMLDivElement>(".pops[type-value]")!;
415
- const drawerConfig = config as Required<PopsDrawerDetails>;
404
+ const $pops = $anim.querySelector<HTMLDivElement>(".pops[type-value]")!;
405
+ const drawerConfig = config as Required<PopsDrawerConfig>;
416
406
  /**
417
407
  * 动画结束事件
418
408
  */
@@ -424,25 +414,25 @@ export const PopsInstanceUtils = {
424
414
  if ((event as TransitionEvent).propertyName !== "transform") {
425
415
  return;
426
416
  }
427
- popsDOMUtils.off(popsElement, popsDOMUtils.getTransitionEndNameList(), void 0, closeCallBack);
417
+ popsDOMUtils.off($pops, popsDOMUtils.getTransitionEndNameList(), void 0, closeCallBack);
428
418
  PopsInstanceUtils.removeInstance([instConfigList], guid);
429
419
  resolve();
430
420
  }
431
- /* 监听过渡结束 */
432
- popsDOMUtils.on(popsElement, popsDOMUtils.getTransitionEndNameList(), closeCallBack);
433
- const popsTransForm = getComputedStyle(popsElement).transform;
421
+ // 监听过渡结束
422
+ popsDOMUtils.on($pops, popsDOMUtils.getTransitionEndNameList(), closeCallBack);
423
+ const popsTransForm = getComputedStyle($pops).transform;
434
424
  if (popsTransForm !== "none") {
435
- popsDOMUtils.trigger(popsElement, popsDOMUtils.getTransitionEndNameList(), void 0, true);
425
+ popsDOMUtils.trigger($pops, popsDOMUtils.getTransitionEndNameList(), void 0, true);
436
426
  return;
437
427
  }
438
428
  if (["top"].includes(drawerConfig.direction)) {
439
- popsElement.style.setProperty("transform", "translateY(-100%)");
429
+ $pops.style.setProperty("transform", "translateY(-100%)");
440
430
  } else if (["bottom"].includes(drawerConfig.direction)) {
441
- popsElement.style.setProperty("transform", "translateY(100%)");
431
+ $pops.style.setProperty("transform", "translateY(100%)");
442
432
  } else if (["left"].includes(drawerConfig.direction)) {
443
- popsElement.style.setProperty("transform", "translateX(-100%)");
433
+ $pops.style.setProperty("transform", "translateX(-100%)");
444
434
  } else if (["right"].includes(drawerConfig.direction)) {
445
- popsElement.style.setProperty("transform", "translateX(100%)");
435
+ $pops.style.setProperty("transform", "translateX(100%)");
446
436
  } else {
447
437
  console.error("未知direction:", drawerConfig.direction);
448
438
  }
@@ -463,11 +453,11 @@ export const PopsInstanceUtils = {
463
453
  * 说明:
464
454
  * + 元素的position为absolute或者fixed
465
455
  * + 会为元素的
466
- * @param moveElement 需要拖拽的元素
456
+ * @param $move 需要拖拽的元素
467
457
  * @param options 配置
468
458
  */
469
459
  drag(
470
- moveElement: HTMLElement,
460
+ $move: HTMLElement,
471
461
  options: {
472
462
  dragElement: HTMLElement;
473
463
  limit: boolean;
@@ -489,9 +479,9 @@ export const PopsInstanceUtils = {
489
479
  options
490
480
  );
491
481
  let isMove = false;
492
- /* 点击元素,left偏移 */
482
+ // 点击元素,left偏移
493
483
  let clickElementLeftOffset = 0;
494
- /* 点击元素,top偏移 */
484
+ // 点击元素,top偏移
495
485
  let clickElementTopOffset = 0;
496
486
  const AnyTouch = popsUtils.AnyTouch();
497
487
  const anyTouchElement = new AnyTouch(options.dragElement, {
@@ -549,7 +539,7 @@ export const PopsInstanceUtils = {
549
539
  }
550
540
  }
551
541
  // 获取transform偏移
552
- let transformInfo = popsDOMUtils.getTransform(moveElement);
542
+ let transformInfo = popsDOMUtils.getTransform($move);
553
543
 
554
544
  let resumeMoveElementStyle: ((...args: any[]) => any) | null = null;
555
545
 
@@ -559,7 +549,7 @@ export const PopsInstanceUtils = {
559
549
  const rect = options.dragElement.getBoundingClientRect();
560
550
  clickElementLeftOffset = event.x - rect.left;
561
551
  clickElementTopOffset = event.y - rect.top;
562
- transformInfo = popsDOMUtils.getTransform(moveElement);
552
+ transformInfo = popsDOMUtils.getTransform($move);
563
553
  //if (event.nativeEvent.offsetX) {
564
554
  // clickElementLeftOffset = parseInt(event.nativeEvent.offsetX);
565
555
  //} else {
@@ -570,66 +560,66 @@ export const PopsInstanceUtils = {
570
560
  //} else {
571
561
  // clickElementTopOffset = parseInt(event.getOffset().y);
572
562
  //}
573
- resumeMoveElementStyle = changeMoveElementStyle(moveElement);
563
+ resumeMoveElementStyle = changeMoveElementStyle($move);
574
564
  }
575
565
 
576
566
  /** 当前移动的left偏移 */
577
567
  let currentMoveLeftOffset = event.x - clickElementLeftOffset + transformInfo.transformLeft;
578
568
  /** 当前移动的top偏移 */
579
569
  let currentMoveTopOffset = event.y - clickElementTopOffset + transformInfo.transformTop;
580
- /* 拖拽移动 */
570
+ // 拖拽移动
581
571
  if (event.phase === "move") {
582
572
  if (options.limit) {
583
- /* 限制在容器内移动 */
584
- /* left偏移最大值 */
573
+ // 限制在容器内移动
574
+ // left偏移最大值
585
575
  const maxLeftOffset =
586
576
  getContainerWidthOrHeight(options.container!).width -
587
- popsDOMUtils.width(moveElement) +
577
+ popsDOMUtils.width($move) +
588
578
  transformInfo.transformLeft;
589
579
  const { left: minLeftOffset, top: minTopOffset } = getContainerTopOrLeft(options.container!);
590
- /* top偏移的最大值 */
580
+ // top偏移的最大值
591
581
  const maxTopOffset =
592
582
  getContainerWidthOrHeight(options.container!).height -
593
- popsDOMUtils.height(moveElement) +
583
+ popsDOMUtils.height($move) +
594
584
  transformInfo.transformTop;
595
585
  if (currentMoveLeftOffset > maxLeftOffset) {
596
- /* 不允许超过容器的最大宽度 */
586
+ // 不允许超过容器的最大宽度
597
587
  currentMoveLeftOffset = maxLeftOffset;
598
588
  }
599
589
  if (currentMoveTopOffset > maxTopOffset) {
600
- /* 不允许超过容器的最大高度 */
590
+ // 不允许超过容器的最大高度
601
591
  currentMoveTopOffset = maxTopOffset;
602
592
  }
603
593
  if (currentMoveLeftOffset - options.extraDistance * 2 < minLeftOffset + transformInfo.transformLeft) {
604
- /* 不允许left偏移小于容器最小值 */
594
+ // 不允许left偏移小于容器最小值
605
595
  currentMoveLeftOffset = minLeftOffset + transformInfo.transformLeft;
606
- /* 最左边 +额外距离 */
596
+ // 最左边 +额外距离
607
597
  currentMoveLeftOffset += options.extraDistance;
608
598
  } else {
609
- /* 最右边 -额外距离 */
599
+ // 最右边 -额外距离
610
600
  currentMoveLeftOffset -= options.extraDistance;
611
601
  }
612
602
  if (currentMoveTopOffset - options.extraDistance * 2 < minTopOffset + transformInfo.transformTop) {
613
- /* 不允许top偏移小于容器最小值 */
603
+ // 不允许top偏移小于容器最小值
614
604
  currentMoveTopOffset = minTopOffset + transformInfo.transformTop;
615
- /* 最上面 +额外距离 */
605
+ // 最上面 +额外距离
616
606
  currentMoveTopOffset += options.extraDistance;
617
607
  } else {
618
- /* 最下面 -额外距离 */
608
+ // 最下面 -额外距离
619
609
  currentMoveTopOffset -= options.extraDistance;
620
610
  }
621
611
  }
622
612
  if (typeof options.moveCallBack === "function") {
623
- options.moveCallBack(moveElement, currentMoveLeftOffset, currentMoveTopOffset);
613
+ options.moveCallBack($move, currentMoveLeftOffset, currentMoveTopOffset);
624
614
  }
625
615
 
626
- popsDOMUtils.css(moveElement, {
616
+ popsDOMUtils.css($move, {
627
617
  left: currentMoveLeftOffset + "px",
628
618
  top: currentMoveTopOffset + "px",
629
619
  });
630
620
  }
631
621
 
632
- /* 停止拖拽 */
622
+ // 停止拖拽
633
623
  if (event.phase === "end") {
634
624
  isMove = false;
635
625
  if (typeof resumeMoveElementStyle === "function") {
@@ -637,12 +627,12 @@ export const PopsInstanceUtils = {
637
627
  resumeMoveElementStyle = null;
638
628
  }
639
629
  if (typeof options.endCallBack === "function") {
640
- options.endCallBack(moveElement, currentMoveLeftOffset, currentMoveTopOffset);
630
+ options.endCallBack($move, currentMoveLeftOffset, currentMoveTopOffset);
641
631
  }
642
632
  }
643
633
  });
644
634
  if (options.triggerClick) {
645
- /* 因为会覆盖上面的点击事件,主动触发一下 */
635
+ // 因为会覆盖上面的点击事件,主动触发一下
646
636
  anyTouchElement.on(["tap"], function (event) {
647
637
  event.changedPoints.forEach((item) => {
648
638
  popsDOMUtils.trigger(item.target! as HTMLElement, "click", void 0, true);
@@ -668,8 +658,8 @@ export const PopsInstanceUtils = {
668
658
  throw new Error("获取前面的值或后面的值的方法不能为空");
669
659
  }
670
660
  return function (after_obj: T, before_obj: T) {
671
- const beforeValue = getBeforeValueFun(before_obj); /* */
672
- const afterValue = getAfterValueFun(after_obj); /* */
661
+ const beforeValue = getBeforeValueFun(before_obj); //
662
+ const afterValue = getAfterValueFun(after_obj); //
673
663
  if (sortByDesc) {
674
664
  if (afterValue > beforeValue) {
675
665
  return -1;
@@ -90,12 +90,6 @@ class PopsUtils {
90
90
  assign<T1, T2 extends object, T3 extends boolean>(target: T1, source: T2, isAdd?: T3): T3 extends true ? T1 & T2 : T1;
91
91
  assign(target = {}, source = {}, isAdd = false) {
92
92
  const UtilsContext = this;
93
- if (source == null) {
94
- return target;
95
- }
96
- if (target == null) {
97
- target = {};
98
- }
99
93
  if (Array.isArray(source)) {
100
94
  const canTraverse = source.filter((item) => {
101
95
  return typeof item === "object";
@@ -104,42 +98,49 @@ class PopsUtils {
104
98
  return source;
105
99
  }
106
100
  }
101
+ if (source == null) {
102
+ return target;
103
+ }
104
+ if (target == null) {
105
+ target = {};
106
+ }
107
+ // 当前遍历的目标对象
108
+ let iteratorTarget;
107
109
  if (isAdd) {
108
- for (const sourceKeyName in source) {
109
- const targetKeyName = sourceKeyName;
110
- const targetValue = (target as any)[targetKeyName];
111
- const sourceValue = (source as any)[sourceKeyName];
112
- if (
113
- typeof sourceValue === "object" &&
114
- sourceValue != null &&
115
- sourceKeyName in target &&
116
- !UtilsContext.isDOM(sourceValue)
117
- ) {
118
- /* 源端的值是object类型,且不是元素节点 */
119
- (target as any)[sourceKeyName] = UtilsContext.assign(targetValue, sourceValue, isAdd);
120
- continue;
121
- }
122
- (target as any)[sourceKeyName] = sourceValue;
123
- }
110
+ // 追加并覆盖是以source为准
111
+ iteratorTarget = source;
124
112
  } else {
125
- for (const targetKeyName in target) {
126
- if (targetKeyName in source) {
127
- const targetValue = Reflect.get(target, targetKeyName);
128
- const sourceValue = Reflect.get(source, targetKeyName);
129
- if (
130
- typeof sourceValue === "object" &&
131
- sourceValue != null &&
132
- !UtilsContext.isDOM(sourceValue) &&
133
- Object.keys(sourceValue).length
134
- ) {
135
- /* 源端的值是object类型,且不是元素节点 */
136
- const childObjectValue = UtilsContext.assign(targetValue, sourceValue, isAdd);
137
- Reflect.set(target, targetKeyName, childObjectValue);
138
- continue;
113
+ // 覆盖以target为准
114
+ iteratorTarget = target;
115
+ }
116
+ for (const keyName in iteratorTarget) {
117
+ if (!isAdd && !(keyName in source)) {
118
+ // 仅替换 但是源端没有此键
119
+ continue;
120
+ }
121
+ const targetValue = Reflect.get(target, keyName);
122
+ const sourceValue = Reflect.get(source, keyName);
123
+ if (
124
+ typeof sourceValue === "object" &&
125
+ sourceValue != null &&
126
+ keyName in target &&
127
+ !UtilsContext.isDOM(sourceValue)
128
+ ) {
129
+ // 源端的值是object类型,且不是元素节点
130
+ // 如果是数组,那此数组中有值,清空旧的数组再赋值
131
+ let childObjectValue;
132
+ if (Array.isArray(sourceValue)) {
133
+ if (Array.isArray(targetValue)) {
134
+ targetValue.length = 0;
139
135
  }
140
- /* 直接赋值 */
141
- Reflect.set(target, targetKeyName, sourceValue);
136
+ childObjectValue = sourceValue;
137
+ } else {
138
+ childObjectValue = UtilsContext.assign(targetValue, sourceValue, isAdd);
142
139
  }
140
+ Reflect.set(target, keyName, childObjectValue);
141
+ } else {
142
+ /* 直接赋值 */
143
+ Reflect.set(target, keyName, sourceValue);
143
144
  }
144
145
  }
145
146
 
@@ -272,19 +273,19 @@ class PopsUtils {
272
273
 
273
274
  const timeRegexp = {
274
275
  yyyy: time.getFullYear(),
275
- /* */
276
+ //
276
277
  MM: checkTime(time.getMonth() + 1),
277
- /* */
278
+ //
278
279
  dd: checkTime(time.getDate()),
279
- /* */
280
+ //
280
281
  HH: checkTime(time.getHours()),
281
- /* 时 (24小时制) */
282
+ // 时 (24小时制)
282
283
  hh: checkTime(timeSystemChange(time.getHours())),
283
- /* 时 (12小时制) */
284
+ // 时 (12小时制)
284
285
  mm: checkTime(time.getMinutes()),
285
- /* */
286
+ //
286
287
  ss: checkTime(time.getSeconds()),
287
- /* */
288
+ //
288
289
  };
289
290
  Object.keys(timeRegexp).forEach(function (key) {
290
291
  const replaecRegexp = new RegExp(key, "g");
@@ -399,6 +400,20 @@ class PopsUtils {
399
400
  PopsCore.clearInterval(timeId);
400
401
  }
401
402
  }
403
+ /**
404
+ * 覆盖对象中的数组新值
405
+ */
406
+ setArray<T>(target: T, key: keyof T, newArr: any[]) {
407
+ if (target == null) return;
408
+ if (!Array.isArray(newArr)) return;
409
+ const arr: any = target[key];
410
+ if (Array.isArray(target[key])) {
411
+ arr.length = 0;
412
+ } else {
413
+ (<any>target)[key] = [];
414
+ }
415
+ (<any>target)[key] = newArr;
416
+ }
402
417
  }
403
418
 
404
419
  const popsUtils = new PopsUtils();