@whitesev/pops 2.2.0 → 2.2.2

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 (48) hide show
  1. package/dist/index.amd.js +364 -357
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +364 -357
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +364 -357
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +364 -357
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +364 -357
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +364 -357
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/Pops.d.ts +17 -17
  14. package/dist/types/src/PopsInst.d.ts +8 -0
  15. package/dist/types/src/components/panel/index.d.ts +2 -1
  16. package/dist/types/src/components/searchSuggestion/index.d.ts +1 -1
  17. package/dist/types/src/handler/PopsElementHandler.d.ts +6 -6
  18. package/dist/types/src/handler/PopsHandler.d.ts +6 -6
  19. package/dist/types/src/types/button.d.ts +2 -2
  20. package/dist/types/src/types/components.d.ts +5 -5
  21. package/dist/types/src/types/event.d.ts +3 -3
  22. package/dist/types/src/types/{layer.d.ts → inst.d.ts} +7 -5
  23. package/dist/types/src/types/main.d.ts +36 -58
  24. package/dist/types/src/utils/PopsInstanceUtils.d.ts +10 -10
  25. package/package.json +1 -1
  26. package/src/Pops.ts +2 -2
  27. package/src/PopsInst.ts +21 -0
  28. package/src/components/alert/index.ts +16 -16
  29. package/src/components/confirm/index.ts +16 -15
  30. package/src/components/drawer/index.ts +16 -15
  31. package/src/components/folder/index.ts +141 -152
  32. package/src/components/iframe/index.ts +16 -15
  33. package/src/components/panel/index.ts +19 -18
  34. package/src/components/prompt/index.ts +15 -14
  35. package/src/components/rightClickMenu/index.ts +19 -18
  36. package/src/components/searchSuggestion/index.ts +21 -20
  37. package/src/components/tooltip/index.ts +3 -2
  38. package/src/css/scrollbar.css +9 -5
  39. package/src/handler/PopsElementHandler.ts +18 -18
  40. package/src/handler/PopsHandler.ts +38 -32
  41. package/src/types/button.d.ts +2 -2
  42. package/src/types/components.d.ts +5 -5
  43. package/src/types/event.d.ts +3 -3
  44. package/src/types/{layer.d.ts → inst.d.ts} +7 -5
  45. package/src/types/main.d.ts +36 -58
  46. package/src/utils/PopsInstanceUtils.ts +84 -81
  47. package/dist/types/src/PopsLayer.d.ts +0 -5
  48. package/src/PopsLayer.ts +0 -18
@@ -6,12 +6,12 @@ import type { PopsIframeDetails } from "../components/iframe/types";
6
6
  import type { PopsLoadingDetails } from "../components/loading/types";
7
7
  import type { PopsPanelDetails } from "../components/panel/types";
8
8
  import type { PopsPromptDetails } from "../components/prompt/types/index";
9
- import type { PopsLayerCommonConfig } from "../types/layer";
10
- import type { PopsLayerMode } from "../types/main";
9
+ import type { PopsInstCommonConfig } from "../types/inst";
10
+ import type { PopsInstStoreType } from "../types/main";
11
11
  import { popsDOMUtils } from "./PopsDOMUtils";
12
12
  import { popsUtils } from "./PopsUtils";
13
13
  import { PopsCore } from "../PopsCore";
14
- import { PopsLayerData } from "../PopsLayer";
14
+ import { PopsInstData } from "../PopsInst";
15
15
  import { PopsAnimation } from "../PopsAnimation";
16
16
 
17
17
  export const PopsInstanceUtils = {
@@ -121,18 +121,18 @@ export const PopsInstanceUtils = {
121
121
  function isVisibleNode($css: CSSStyleDeclaration): boolean {
122
122
  return $css.position !== "static" && $css.display !== "none";
123
123
  }
124
- Object.keys(PopsLayerData).forEach((layerName) => {
125
- let layerList = PopsLayerData[layerName as PopsLayerMode];
126
- for (let index = 0; index < layerList.length; index++) {
127
- const layer = layerList[index];
128
- let nodeStyle = window.getComputedStyle(layer.animElement);
124
+ Object.keys(PopsInstData).forEach((instKeyName) => {
125
+ let instData = PopsInstData[instKeyName as PopsInstStoreType];
126
+ for (let index = 0; index < instData.length; index++) {
127
+ const inst = instData[index];
128
+ let nodeStyle = window.getComputedStyle(inst.animElement);
129
129
  /* 不对position为static和display为none的元素进行获取它们的z-index */
130
130
  if (isVisibleNode(nodeStyle)) {
131
131
  let nodeZIndex = parseInt(nodeStyle.zIndex);
132
132
  if (!isNaN(nodeZIndex)) {
133
133
  if (nodeZIndex > zIndex) {
134
134
  zIndex = nodeZIndex;
135
- maxZIndexNode = layer.animElement;
135
+ maxZIndexNode = inst.animElement;
136
136
  }
137
137
  }
138
138
  }
@@ -158,85 +158,85 @@ export const PopsInstanceUtils = {
158
158
  },
159
159
  /**
160
160
  * 删除配置中对应的对象
161
- * @param moreLayerConfigList 配置实例列表
161
+ * @param instConfigList 配置实例列表
162
162
  * @param guid 唯一标识
163
163
  * @param isAll 是否全部删除
164
164
  */
165
165
  removeInstance(
166
- moreLayerConfigList: PopsLayerCommonConfig[][],
166
+ instConfigList: PopsInstCommonConfig[][],
167
167
  guid: string,
168
168
  isAll = false
169
169
  ) {
170
170
  /**
171
171
  * 移除元素实例
172
- * @param layerCommonConfig
172
+ * @param instCommonConfig
173
173
  */
174
- function removeItem(layerCommonConfig: PopsLayerCommonConfig) {
175
- if (typeof layerCommonConfig.beforeRemoveCallBack === "function") {
174
+ function removeItem(instCommonConfig: PopsInstCommonConfig) {
175
+ if (typeof instCommonConfig.beforeRemoveCallBack === "function") {
176
176
  // 调用移除签的回调
177
- layerCommonConfig.beforeRemoveCallBack(layerCommonConfig);
177
+ instCommonConfig.beforeRemoveCallBack(instCommonConfig);
178
178
  }
179
- layerCommonConfig?.animElement?.remove();
180
- layerCommonConfig?.popsElement?.remove();
181
- layerCommonConfig?.maskElement?.remove();
182
- layerCommonConfig?.$shadowContainer?.remove();
179
+ instCommonConfig?.animElement?.remove();
180
+ instCommonConfig?.popsElement?.remove();
181
+ instCommonConfig?.maskElement?.remove();
182
+ instCommonConfig?.$shadowContainer?.remove();
183
183
  }
184
- // [ layer[], layer[],...]
185
- moreLayerConfigList.forEach((layerConfigList) => {
186
- // layer[]
187
- layerConfigList.forEach((layerConfigItem, index) => {
184
+ // [ inst[], inst[],...]
185
+ instConfigList.forEach((instConfigList) => {
186
+ // inst[]
187
+ instConfigList.forEach((instConfigItem, index) => {
188
188
  // 移除全部或者guid相同
189
- if (isAll || layerConfigItem["guid"] === guid) {
189
+ if (isAll || instConfigItem["guid"] === guid) {
190
190
  // 判断是否有动画
191
- let animName = layerConfigItem.animElement.getAttribute(
191
+ let animName = instConfigItem.animElement.getAttribute(
192
192
  "anim"
193
193
  ) as string;
194
194
  if (PopsAnimation.hasAnim(animName)) {
195
195
  let reverseAnimName = animName + "-reverse";
196
- layerConfigItem.animElement.style.width = "100%";
197
- layerConfigItem.animElement.style.height = "100%";
198
- (layerConfigItem.animElement.style as any)["animation-name"] =
196
+ instConfigItem.animElement.style.width = "100%";
197
+ instConfigItem.animElement.style.height = "100%";
198
+ (instConfigItem.animElement.style as any)["animation-name"] =
199
199
  reverseAnimName;
200
200
  if (
201
201
  PopsAnimation.hasAnim(
202
- (layerConfigItem.animElement.style as any)["animation-name"]
202
+ (instConfigItem.animElement.style as any)["animation-name"]
203
203
  )
204
204
  ) {
205
205
  popsDOMUtils.on(
206
- layerConfigItem.animElement,
206
+ instConfigItem.animElement,
207
207
  popsDOMUtils.getAnimationEndNameList(),
208
208
  function () {
209
- removeItem(layerConfigItem);
209
+ removeItem(instConfigItem);
210
210
  },
211
211
  {
212
212
  capture: true,
213
213
  }
214
214
  );
215
215
  } else {
216
- removeItem(layerConfigItem);
216
+ removeItem(instConfigItem);
217
217
  }
218
218
  } else {
219
- removeItem(layerConfigItem);
219
+ removeItem(instConfigItem);
220
220
  }
221
- layerConfigList.splice(index, 1);
221
+ instConfigList.splice(index, 1);
222
222
  }
223
223
  });
224
224
  });
225
225
 
226
- return moreLayerConfigList;
226
+ return instConfigList;
227
227
  },
228
228
  /**
229
229
  * 隐藏
230
230
  * @param popsType
231
- * @param layerConfigList
231
+ * @param instConfigList
232
232
  * @param guid
233
233
  * @param config
234
234
  * @param animElement
235
235
  * @param maskElement
236
236
  */
237
237
  hide(
238
- popsType: PopsLayerMode,
239
- layerConfigList: PopsLayerCommonConfig[],
238
+ popsType: PopsInstStoreType,
239
+ instConfigList: PopsInstCommonConfig[],
240
240
  guid: string,
241
241
  config:
242
242
  | PopsAlertDetails
@@ -267,31 +267,33 @@ export const PopsInstanceUtils = {
267
267
  resolve();
268
268
  }, drawerConfig.closeDelay);
269
269
  } else {
270
- let findLayerIns = layerConfigList.find(
271
- (layerConfigItem) => layerConfigItem.guid === guid
270
+ let fintInst = instConfigList.find(
271
+ (instConfigItem) => instConfigItem.guid === guid
272
272
  );
273
- if (findLayerIns) {
273
+ if (fintInst) {
274
274
  /* 存在动画 */
275
- let layerConfigItem = findLayerIns;
276
- layerConfigItem.animElement.style.width = "100%";
277
- layerConfigItem.animElement.style.height = "100%";
278
- (layerConfigItem.animElement.style as any)["animation-name"] =
279
- layerConfigItem.animElement.getAttribute("anim") + "-reverse";
275
+ let instConfigItem = fintInst;
276
+ instConfigItem.animElement.style.width = "100%";
277
+ instConfigItem.animElement.style.height = "100%";
278
+ // @ts-ignore
279
+ instConfigItem.animElement.style["animation-name"] =
280
+ instConfigItem.animElement.getAttribute("anim") + "-reverse";
280
281
  if (
281
282
  PopsAnimation.hasAnim(
282
- (layerConfigItem.animElement.style as any)["animation-name"]
283
+ // @ts-ignore
284
+ instConfigItem.animElement.style["animation-name"]
283
285
  )
284
286
  ) {
285
287
  /**
286
288
  * 动画结束的回调
287
289
  */
288
290
  function animationendCallBack() {
289
- layerConfigItem.animElement.style.display = "none";
290
- if (layerConfigItem.maskElement) {
291
- layerConfigItem.maskElement.style.display = "none";
291
+ instConfigItem.animElement.style.display = "none";
292
+ if (instConfigItem.maskElement) {
293
+ instConfigItem.maskElement.style.display = "none";
292
294
  }
293
295
  popsDOMUtils.off(
294
- layerConfigItem.animElement,
296
+ instConfigItem.animElement,
295
297
  popsDOMUtils.getAnimationEndNameList(),
296
298
  animationendCallBack,
297
299
  {
@@ -301,7 +303,7 @@ export const PopsInstanceUtils = {
301
303
  resolve();
302
304
  }
303
305
  popsDOMUtils.on(
304
- layerConfigItem.animElement,
306
+ instConfigItem.animElement,
305
307
  popsDOMUtils.getAnimationEndNameList(),
306
308
  animationendCallBack,
307
309
  {
@@ -309,9 +311,9 @@ export const PopsInstanceUtils = {
309
311
  }
310
312
  );
311
313
  } else {
312
- layerConfigItem.animElement.style.display = "none";
313
- if (layerConfigItem.maskElement) {
314
- layerConfigItem.maskElement.style.display = "none";
314
+ instConfigItem.animElement.style.display = "none";
315
+ if (instConfigItem.maskElement) {
316
+ instConfigItem.maskElement.style.display = "none";
315
317
  }
316
318
 
317
319
  resolve();
@@ -323,15 +325,15 @@ export const PopsInstanceUtils = {
323
325
  /**
324
326
  * 显示
325
327
  * @param popsType
326
- * @param layerConfigList
328
+ * @param instConfigList
327
329
  * @param guid
328
330
  * @param config
329
331
  * @param animElement
330
332
  * @param maskElement
331
333
  */
332
334
  show(
333
- popsType: PopsLayerMode,
334
- layerConfigList: PopsLayerCommonConfig[],
335
+ popsType: PopsInstStoreType,
336
+ instConfigList: PopsInstCommonConfig[],
335
337
  guid: string,
336
338
  config:
337
339
  | PopsAlertDetails
@@ -364,20 +366,21 @@ export const PopsInstanceUtils = {
364
366
  resolve();
365
367
  }, drawerConfig.openDelay ?? 0);
366
368
  } else {
367
- let findLayerIns = layerConfigList.find(
368
- (layerConfigItem) => layerConfigItem.guid === guid
369
+ let fintInst = instConfigList.find(
370
+ (instConfigItem) => instConfigItem.guid === guid
369
371
  );
370
- if (findLayerIns) {
371
- let layerConfigItem = findLayerIns;
372
- layerConfigItem.animElement.style.width = "";
373
- layerConfigItem.animElement.style.height = "";
374
- (layerConfigItem.animElement.style as any)["animation-name"] =
375
- layerConfigItem
376
- .animElement!.getAttribute("anim")!
377
- .replace("-reverse", "");
372
+ if (fintInst) {
373
+ let instConfigItem = fintInst;
374
+ instConfigItem.animElement.style.width = "";
375
+ instConfigItem.animElement.style.height = "";
376
+ // @ts-ignore
377
+ instConfigItem.animElement.style["animation-name"] = instConfigItem
378
+ .animElement!.getAttribute("anim")!
379
+ .replace("-reverse", "");
378
380
  if (
379
381
  PopsAnimation.hasAnim(
380
- (layerConfigItem.animElement.style as any)["animation-name"]
382
+ // @ts-ignore
383
+ instConfigItem.animElement.style["animation-name"]
381
384
  )
382
385
  ) {
383
386
  /**
@@ -385,7 +388,7 @@ export const PopsInstanceUtils = {
385
388
  */
386
389
  function animationendCallBack() {
387
390
  popsDOMUtils.off(
388
- layerConfigItem.animElement,
391
+ instConfigItem.animElement,
389
392
  popsDOMUtils.getAnimationEndNameList(),
390
393
  animationendCallBack,
391
394
  {
@@ -394,12 +397,12 @@ export const PopsInstanceUtils = {
394
397
  );
395
398
  resolve();
396
399
  }
397
- layerConfigItem.animElement.style.display = "";
398
- if (layerConfigItem.maskElement) {
399
- layerConfigItem.maskElement.style.display = "";
400
+ instConfigItem.animElement.style.display = "";
401
+ if (instConfigItem.maskElement) {
402
+ instConfigItem.maskElement.style.display = "";
400
403
  }
401
404
  popsDOMUtils.on(
402
- layerConfigItem.animElement,
405
+ instConfigItem.animElement,
403
406
  popsDOMUtils.getAnimationEndNameList(),
404
407
  animationendCallBack,
405
408
  {
@@ -407,9 +410,9 @@ export const PopsInstanceUtils = {
407
410
  }
408
411
  );
409
412
  } else {
410
- layerConfigItem.animElement.style.display = "";
411
- if (layerConfigItem.maskElement) {
412
- layerConfigItem.maskElement.style.display = "";
413
+ instConfigItem.animElement.style.display = "";
414
+ if (instConfigItem.maskElement) {
415
+ instConfigItem.maskElement.style.display = "";
413
416
  }
414
417
  resolve();
415
418
  }
@@ -420,14 +423,14 @@ export const PopsInstanceUtils = {
420
423
  /**
421
424
  * 关闭
422
425
  * @param popsType
423
- * @param layerConfigList
426
+ * @param instConfigList
424
427
  * @param guid
425
428
  * @param config
426
429
  * @param animElement
427
430
  */
428
431
  close(
429
432
  popsType: string,
430
- layerConfigList: PopsLayerCommonConfig[],
433
+ instConfigList: PopsInstCommonConfig[],
431
434
  guid: string,
432
435
  config:
433
436
  | PopsAlertDetails
@@ -461,7 +464,7 @@ export const PopsInstanceUtils = {
461
464
  void 0,
462
465
  closeCallBack
463
466
  );
464
- PopsInstanceUtils.removeInstance([layerConfigList], guid);
467
+ PopsInstanceUtils.removeInstance([instConfigList], guid);
465
468
  resolve();
466
469
  }
467
470
  /* 监听过渡结束 */
@@ -498,7 +501,7 @@ export const PopsInstanceUtils = {
498
501
  transitionendEvent();
499
502
  }, drawerConfig.closeDelay);
500
503
  } else {
501
- PopsInstanceUtils.removeInstance([layerConfigList], guid);
504
+ PopsInstanceUtils.removeInstance([instConfigList], guid);
502
505
  resolve();
503
506
  }
504
507
  });
@@ -1,5 +0,0 @@
1
- import type { PopsLayerCommonConfig } from "./types/layer";
2
- import type { PopsLayerMode } from "./types/main";
3
- export declare const PopsLayerData: {
4
- [key in PopsLayerMode]: PopsLayerCommonConfig[];
5
- };
package/src/PopsLayer.ts DELETED
@@ -1,18 +0,0 @@
1
- import type { PopsLayerCommonConfig } from "./types/layer";
2
- import type { PopsLayerMode } from "./types/main";
3
-
4
- export const PopsLayerData: {
5
- [key in PopsLayerMode]: PopsLayerCommonConfig[];
6
- } = {
7
- alert: [],
8
- confirm: [],
9
- drawer: [],
10
- folder: [],
11
- iframe: [],
12
- loading: [],
13
- panel: [],
14
- prompt: [],
15
- rightClickMenu: [],
16
- // 没有 searchSuggestion
17
- tooltip: [],
18
- };