@whitesev/pops 2.0.9 → 2.0.11

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 (57) hide show
  1. package/dist/index.amd.js +1904 -1733
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +1904 -1733
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +1904 -1733
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +1904 -1733
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +1904 -1733
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +1904 -1733
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/Pops.d.ts +50 -30
  14. package/dist/types/src/PopsAnimation.d.ts +14 -0
  15. package/dist/types/src/PopsCSS.d.ts +34 -0
  16. package/dist/types/src/PopsIcon.d.ts +25 -0
  17. package/dist/types/src/PopsLayer.d.ts +3 -0
  18. package/dist/types/src/components/panel/buttonType.d.ts +2 -2
  19. package/dist/types/src/components/panel/selectMultipleType.d.ts +12 -15
  20. package/dist/types/src/components/rightClickMenu/index.d.ts +1 -2
  21. package/dist/types/src/components/rightClickMenu/indexType.d.ts +2 -2
  22. package/dist/types/src/types/button.d.ts +3 -3
  23. package/dist/types/src/types/icon.d.ts +1 -1
  24. package/dist/types/src/utils/PopsDOMUtils.d.ts +12 -0
  25. package/dist/types/src/utils/PopsInstanceUtils.d.ts +0 -6
  26. package/dist/types/src/utils/PopsUtils.d.ts +5 -6
  27. package/package.json +3 -2
  28. package/src/Pops.ts +12 -152
  29. package/src/PopsAnimation.ts +32 -0
  30. package/src/PopsCSS.ts +51 -0
  31. package/src/PopsIcon.ts +93 -0
  32. package/src/PopsLayer.ts +17 -0
  33. package/src/components/alert/index.ts +8 -8
  34. package/src/components/confirm/index.ts +8 -8
  35. package/src/components/drawer/index.ts +8 -8
  36. package/src/components/folder/index.ts +15 -15
  37. package/src/components/iframe/index.ts +9 -12
  38. package/src/components/loading/index.ts +5 -5
  39. package/src/components/panel/PanelHandleContentDetails.ts +338 -220
  40. package/src/components/panel/buttonType.ts +2 -2
  41. package/src/components/panel/config.ts +41 -11
  42. package/src/components/panel/index.css +33 -0
  43. package/src/components/panel/index.ts +9 -9
  44. package/src/components/panel/selectMultipleType.ts +18 -15
  45. package/src/components/prompt/index.ts +8 -8
  46. package/src/components/rightClickMenu/config.ts +7 -7
  47. package/src/components/rightClickMenu/index.ts +9 -10
  48. package/src/components/rightClickMenu/indexType.ts +2 -2
  49. package/src/components/searchSuggestion/index.ts +5 -5
  50. package/src/components/tooltip/index.ts +5 -5
  51. package/src/handler/PopsElementHandler.ts +17 -17
  52. package/src/handler/PopsHandler.ts +22 -19
  53. package/src/types/button.d.ts +3 -3
  54. package/src/types/icon.d.ts +1 -1
  55. package/src/utils/PopsDOMUtils.ts +34 -1
  56. package/src/utils/PopsInstanceUtils.ts +13 -31
  57. package/src/utils/PopsUtils.ts +7 -16
@@ -7,7 +7,8 @@ import type { PopsLoadingDetails } from "../components/loading/indexType";
7
7
  import type { PopsPanelDetails } from "../components/panel/indexType";
8
8
  import type { PopsPromptDetails } from "../components/prompt/indexType";
9
9
  import { PopsCore } from "../Core";
10
- import { pops } from "../Pops";
10
+ import { PopsAnimation } from "../PopsAnimation";
11
+ import { PopsLayer } from "../PopsLayer";
11
12
  import type { PopsCommonConfig } from "../types/components";
12
13
  import { PopsEventDetails, PopsHandlerEventDetails } from "../types/event";
13
14
  import { PopsLayerCommonConfig } from "../types/layer";
@@ -50,7 +51,7 @@ export const PopsHandler = {
50
51
  $shadowRoot?: ShadowRoot | HTMLElement,
51
52
  cssText?: string | string[]
52
53
  ) {
53
- pops.init();
54
+ PopsAnimation.init();
54
55
  if (!arguments.length) {
55
56
  return;
56
57
  }
@@ -101,7 +102,9 @@ export const PopsHandler = {
101
102
  }
102
103
  ) {
103
104
  let result = {
104
- maskElement: popsUtils.parseTextToDOM<HTMLDivElement>(details.maskHTML),
105
+ maskElement: popsDOMUtils.parseTextToDOM<HTMLDivElement>(
106
+ details.maskHTML
107
+ ),
105
108
  };
106
109
  let isMaskClick = false;
107
110
  /**
@@ -111,7 +114,7 @@ export const PopsHandler = {
111
114
  function clickEvent(event: MouseEvent | PointerEvent) {
112
115
  popsDOMUtils.preventEvent(event);
113
116
  // 获取该类型实例存储列表
114
- let targetLayer = pops.config.layer[details.type];
117
+ let targetLayer = PopsLayer[details.type];
115
118
  function originalRun() {
116
119
  if (details.config.mask!.clickEvent!.toClose) {
117
120
  /* 关闭 */
@@ -400,7 +403,7 @@ export const PopsHandler = {
400
403
  close() {
401
404
  return PopsInstanceUtils.close(
402
405
  mode,
403
- pops.config.layer[mode],
406
+ PopsLayer[mode],
404
407
  guid,
405
408
  config,
406
409
  animElement
@@ -409,7 +412,7 @@ export const PopsHandler = {
409
412
  hide() {
410
413
  return PopsInstanceUtils.hide(
411
414
  mode,
412
- pops.config.layer[mode],
415
+ PopsLayer[mode],
413
416
  guid,
414
417
  config,
415
418
  animElement,
@@ -419,7 +422,7 @@ export const PopsHandler = {
419
422
  show() {
420
423
  return PopsInstanceUtils.show(
421
424
  mode,
422
- pops.config.layer[mode],
425
+ PopsLayer[mode],
423
426
  guid,
424
427
  config,
425
428
  animElement,
@@ -463,7 +466,7 @@ export const PopsHandler = {
463
466
  close() {
464
467
  return PopsInstanceUtils.close(
465
468
  mode,
466
- pops.config.layer[mode],
469
+ PopsLayer[mode],
467
470
  guid,
468
471
  config,
469
472
  animElement
@@ -472,7 +475,7 @@ export const PopsHandler = {
472
475
  hide() {
473
476
  return PopsInstanceUtils.hide(
474
477
  mode,
475
- pops.config.layer[mode],
478
+ PopsLayer[mode],
476
479
  guid,
477
480
  config,
478
481
  animElement,
@@ -482,7 +485,7 @@ export const PopsHandler = {
482
485
  show() {
483
486
  return PopsInstanceUtils.show(
484
487
  mode,
485
- pops.config.layer[mode],
488
+ PopsLayer[mode],
486
489
  guid,
487
490
  config,
488
491
  animElement,
@@ -636,20 +639,20 @@ export const PopsHandler = {
636
639
  type === "tooltip" ||
637
640
  type === "rightClickMenu"
638
641
  ) {
639
- let layer = pops.config.layer[type as keyof typeof pops.config.layer];
642
+ let layer = PopsLayer[type as keyof typeof PopsLayer];
640
643
  if (layer) {
641
644
  PopsInstanceUtils.removeInstance([layer], "", true);
642
645
  }
643
646
  } else {
644
647
  PopsInstanceUtils.removeInstance(
645
648
  [
646
- pops.config.layer.alert,
647
- pops.config.layer.confirm,
648
- pops.config.layer.prompt,
649
- pops.config.layer.iframe,
650
- pops.config.layer.drawer,
651
- pops.config.layer.folder,
652
- pops.config.layer.panel,
649
+ PopsLayer.alert,
650
+ PopsLayer.confirm,
651
+ PopsLayer.prompt,
652
+ PopsLayer.iframe,
653
+ PopsLayer.drawer,
654
+ PopsLayer.folder,
655
+ PopsLayer.panel,
653
656
  ],
654
657
  "",
655
658
  true
@@ -674,6 +677,6 @@ export const PopsHandler = {
674
677
  * @param value
675
678
  */
676
679
  handlePush(type: PopsLayerMode, value: PopsLayerCommonConfig) {
677
- pops.config.layer[type].push(value);
680
+ PopsLayer[type].push(value);
678
681
  },
679
682
  };
@@ -1,5 +1,5 @@
1
1
  import { PopsEventDetails, PopsHandlerEventDetails } from "./event";
2
- import type { PopsIcon } from "./icon";
2
+ import type { PopsIconType } from "./icon";
3
3
 
4
4
  /**
5
5
  * 按钮类型
@@ -79,7 +79,7 @@ export interface PopsButtonDetails<T = {}> {
79
79
  /**
80
80
  * 图标按钮,如果名字为内置的,则使用内置的,否则为自定义的svg
81
81
  */
82
- icon: PopsIcon;
82
+ icon: PopsIconType;
83
83
  /**
84
84
  * 图标按钮是否放在右边
85
85
  */
@@ -125,7 +125,7 @@ export interface PopsButtonDetailsAnyType<T = {}> {
125
125
  /**
126
126
  * 图标按钮,如果名字为内置的,则使用内置的,否则为自定义的svg
127
127
  */
128
- icon: PopsIcon;
128
+ icon: PopsIconType;
129
129
  /**
130
130
  * 图标按钮是否放在右边
131
131
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 按钮svg图标
3
3
  */
4
- export type PopsIcon =
4
+ export type PopsIconType =
5
5
  | "min"
6
6
  | "mise"
7
7
  | "max"
@@ -1670,7 +1670,21 @@ class PopsDOMUtils extends PopsDOMUtilsEvent {
1670
1670
  });
1671
1671
  return tempElement;
1672
1672
  }
1673
-
1673
+ /**
1674
+ * 字符串转HTMLElement
1675
+ * @param elementString
1676
+ * @returns
1677
+ */
1678
+ parseTextToDOM<R extends HTMLElement>(elementString: string): R {
1679
+ /* 去除前后的换行和空格 */
1680
+ elementString = elementString
1681
+ .replace(/^[\n|\s]*/g, "")
1682
+ .replace(/[\n|\s]*$/g, "");
1683
+ let targetElement = this.createElement("div", {
1684
+ innerHTML: elementString,
1685
+ });
1686
+ return targetElement.firstChild as any as R;
1687
+ }
1674
1688
  /**
1675
1689
  * 获取文字的位置信息
1676
1690
  * @param input 输入框
@@ -2119,6 +2133,25 @@ class PopsDOMUtils extends PopsDOMUtilsEvent {
2119
2133
  element!.parentElement!.insertBefore(content, element.nextSibling);
2120
2134
  }
2121
2135
  }
2136
+ /**
2137
+ * 获取CSS Rule
2138
+ * @param sheet
2139
+ * @returns
2140
+ */
2141
+ getKeyFrames(sheet: CSSStyleSheet) {
2142
+ let result = {};
2143
+ Object.keys(sheet.cssRules).forEach((key) => {
2144
+ if (
2145
+ (sheet.cssRules as any)[key].type === 7 &&
2146
+ (sheet.cssRules as any)[key].name.startsWith("pops-anim-")
2147
+ ) {
2148
+ (result as any)[(sheet.cssRules as any)[key].name] = (
2149
+ sheet.cssRules as any
2150
+ )[key];
2151
+ }
2152
+ });
2153
+ return result;
2154
+ }
2122
2155
  }
2123
2156
 
2124
2157
  const popsDOMUtils = new PopsDOMUtils();
@@ -11,7 +11,8 @@ import type { PopsLayerMode } from "../types/main";
11
11
  import { popsDOMUtils } from "./PopsDOMUtils";
12
12
  import { popsUtils } from "./PopsUtils";
13
13
  import { PopsCore } from "../Core";
14
- import { pops } from "../Pops";
14
+ import { PopsLayer } from "../PopsLayer";
15
+ import { PopsAnimation } from "../PopsAnimation";
15
16
 
16
17
  export const PopsInstanceUtils = {
17
18
  /**
@@ -120,8 +121,8 @@ export const PopsInstanceUtils = {
120
121
  function isVisibleNode($css: CSSStyleDeclaration): boolean {
121
122
  return $css.position !== "static" && $css.display !== "none";
122
123
  }
123
- Object.keys(pops.config.layer).forEach((layerName) => {
124
- let layerList = pops.config.layer[layerName as PopsLayerMode];
124
+ Object.keys(PopsLayer).forEach((layerName) => {
125
+ let layerList = PopsLayer[layerName as PopsLayerMode];
125
126
  for (let index = 0; index < layerList.length; index++) {
126
127
  const layer = layerList[index];
127
128
  let nodeStyle = window.getComputedStyle(layer.animElement);
@@ -155,25 +156,6 @@ export const PopsInstanceUtils = {
155
156
  getMaxZIndex(deviation = 1): number {
156
157
  return this.getMaxZIndexNodeInfo(deviation).zIndex;
157
158
  },
158
- /**
159
- * 获取CSS Rule
160
- * @param sheet
161
- * @returns
162
- */
163
- getKeyFrames(sheet: CSSStyleSheet) {
164
- let result = {};
165
- Object.keys(sheet.cssRules).forEach((key) => {
166
- if (
167
- (sheet.cssRules as any)[key].type === 7 &&
168
- (sheet.cssRules as any)[key].name.startsWith("pops-anim-")
169
- ) {
170
- (result as any)[(sheet.cssRules as any)[key].name] = (
171
- sheet.cssRules as any
172
- )[key];
173
- }
174
- });
175
- return result;
176
- },
177
159
  /**
178
160
  * 删除配置中对应的对象
179
161
  * @param moreLayerConfigList 配置实例列表
@@ -206,17 +188,17 @@ export const PopsInstanceUtils = {
206
188
  // 移除全部或者guid相同
207
189
  if (isAll || layerConfigItem["guid"] === guid) {
208
190
  // 判断是否有动画
209
- if (
210
- pops.config.animation.hasOwnProperty(
211
- layerConfigItem.animElement.getAttribute("anim") as string
212
- )
213
- ) {
191
+ let animName = layerConfigItem.animElement.getAttribute(
192
+ "anim"
193
+ ) as string;
194
+ if (PopsAnimation.hasAnim(animName)) {
195
+ let reverseAnimName = animName + "-reverse";
214
196
  layerConfigItem.animElement.style.width = "100%";
215
197
  layerConfigItem.animElement.style.height = "100%";
216
198
  (layerConfigItem.animElement.style as any)["animation-name"] =
217
- layerConfigItem.animElement.getAttribute("anim") + "-reverse";
199
+ reverseAnimName;
218
200
  if (
219
- pops.config.animation.hasOwnProperty(
201
+ PopsAnimation.hasAnim(
220
202
  (layerConfigItem.animElement.style as any)["animation-name"]
221
203
  )
222
204
  ) {
@@ -296,7 +278,7 @@ export const PopsInstanceUtils = {
296
278
  (layerConfigItem.animElement.style as any)["animation-name"] =
297
279
  layerConfigItem.animElement.getAttribute("anim") + "-reverse";
298
280
  if (
299
- pops.config.animation.hasOwnProperty(
281
+ PopsAnimation.hasAnim(
300
282
  (layerConfigItem.animElement.style as any)["animation-name"]
301
283
  )
302
284
  ) {
@@ -394,7 +376,7 @@ export const PopsInstanceUtils = {
394
376
  .animElement!.getAttribute("anim")!
395
377
  .replace("-reverse", "");
396
378
  if (
397
- pops.config.animation.hasOwnProperty(
379
+ PopsAnimation.hasAnim(
398
380
  (layerConfigItem.animElement.style as any)["animation-name"]
399
381
  )
400
382
  ) {
@@ -1,6 +1,5 @@
1
1
  import { PopsCore } from "../Core";
2
2
  import type { PopsUtilsOwnObject } from "../types/main";
3
- import { popsDOMUtils } from "./PopsDOMUtils";
4
3
  import {
5
4
  clearInterval as WorkerClearInterval,
6
5
  clearTimeout as WorkerClearTimeout,
@@ -182,21 +181,6 @@ class PopsUtils {
182
181
  );
183
182
  }
184
183
  }
185
- /**
186
- * 字符串转HTMLElement
187
- * @param elementString
188
- * @returns
189
- */
190
- parseTextToDOM<R extends HTMLElement>(elementString: string): R {
191
- /* 去除前后的换行和空格 */
192
- elementString = elementString
193
- .replace(/^[\n|\s]*/g, "")
194
- .replace(/[\n|\s]*$/g, "");
195
- let targetElement = popsDOMUtils.createElement("div", {
196
- innerHTML: elementString,
197
- });
198
- return targetElement.firstChild as any as R;
199
- }
200
184
  /**
201
185
  * 判断元素/页面中是否包含该元素
202
186
  * @param target 需要判断的元素
@@ -389,6 +373,13 @@ class PopsUtils {
389
373
  AnyTouch = () => {
390
374
  return AnyTouch;
391
375
  };
376
+ /**
377
+ * 通过navigator.userAgent判断是否是手机访问
378
+ * @param userAgent
379
+ */
380
+ isPhone(userAgent = PopsCore.globalThis.navigator.userAgent): boolean {
381
+ return Boolean(/(iPhone|iPad|iPod|iOS|Android)/i.test(userAgent));
382
+ }
392
383
  /**
393
384
  * 自动使用 Worker 执行 setTimeout
394
385
  */