@whitesev/pops 3.3.0 → 3.3.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 (65) hide show
  1. package/dist/index.amd.js +138 -46
  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 +138 -46
  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 +138 -46
  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 +138 -46
  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 +138 -46
  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 +138 -46
  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/src/Pops.d.ts +6 -0
  26. package/dist/types/src/PopsCore.d.ts +1 -1
  27. package/dist/types/src/components/panel/handlerComponents.d.ts +8 -4
  28. package/dist/types/src/components/panel/types/components-switch.d.ts +12 -2
  29. package/dist/types/src/components/rightClickMenu/types/index.d.ts +1 -1
  30. package/dist/types/src/components/searchSuggestion/index.d.ts +1 -1
  31. package/dist/types/src/components/searchSuggestion/types/index.d.ts +1 -1
  32. package/dist/types/src/components/tooltip/index.d.ts +2 -0
  33. package/dist/types/src/components/tooltip/types/index.d.ts +1 -1
  34. package/dist/types/src/config/GlobalConfig.d.ts +2 -0
  35. package/dist/types/src/handler/PopsElementHandler.d.ts +13 -1
  36. package/dist/types/src/types/components.d.ts +12 -0
  37. package/dist/types/src/utils/PopsUtils.d.ts +8 -0
  38. package/package.json +4 -3
  39. package/src/PopsCore.ts +1 -1
  40. package/src/components/alert/defaultConfig.ts +2 -0
  41. package/src/components/alert/index.ts +2 -2
  42. package/src/components/confirm/defaultConfig.ts +2 -0
  43. package/src/components/drawer/defaultConfig.ts +2 -0
  44. package/src/components/folder/defaultConfig.ts +2 -0
  45. package/src/components/iframe/defaultConfig.ts +2 -0
  46. package/src/components/loading/defaultConfig.ts +2 -0
  47. package/src/components/panel/defaultConfig.ts +2 -0
  48. package/src/components/panel/handlerComponents.ts +38 -21
  49. package/src/components/panel/index.css +1 -0
  50. package/src/components/panel/types/components-switch.ts +12 -2
  51. package/src/components/prompt/defaultConfig.ts +2 -0
  52. package/src/components/rightClickMenu/defaultConfig.ts +2 -0
  53. package/src/components/rightClickMenu/index.ts +7 -12
  54. package/src/components/rightClickMenu/types/index.ts +1 -1
  55. package/src/components/searchSuggestion/defaultConfig.ts +2 -0
  56. package/src/components/searchSuggestion/index.ts +13 -13
  57. package/src/components/searchSuggestion/types/index.ts +1 -1
  58. package/src/components/tooltip/defaultConfig.ts +2 -0
  59. package/src/components/tooltip/index.ts +7 -8
  60. package/src/components/tooltip/types/index.ts +1 -1
  61. package/src/css/index.css +1 -0
  62. package/src/handler/PopsElementHandler.ts +64 -12
  63. package/src/handler/PopsHandler.ts +2 -2
  64. package/src/types/components.d.ts +12 -0
  65. package/src/utils/PopsUtils.ts +11 -1
@@ -1,4 +1,5 @@
1
1
  import { GlobalConfig } from "../../config/GlobalConfig";
2
+ import { PopsElementHandler } from "../../handler/PopsElementHandler";
2
3
  import { PopsHandler } from "../../handler/PopsHandler";
3
4
  import { PopsCSS } from "../../PopsCSS";
4
5
  import type { PopsType } from "../../types/main";
@@ -85,14 +86,12 @@ export class ToolTip {
85
86
  popsDOMUtils.addClassName($toolTipContainer, this.$data.config.className);
86
87
  // 添加z-index
87
88
  $toolTipContainer.style.zIndex = PopsHandler.handleZIndex(this.$data.config.zIndex).toString();
88
- if (this.$data.config.style != null) {
89
- // 添加自定义style
90
- const cssNode = popsDOMUtils.createElement("style", {
91
- type: "text/css",
92
- innerHTML: this.$data.config.style,
93
- });
94
- $toolTipContainer.appendChild(cssNode);
95
- }
89
+ // 添加自定义style
90
+ PopsElementHandler.addStyle($toolTipContainer, this.$data.config.style);
91
+ // 添加自定义浅色style
92
+ PopsElementHandler.addLightStyle($toolTipContainer, this.$data.config.lightStyle);
93
+ // 添加自定义深色style
94
+ PopsElementHandler.addDarkStyle($toolTipContainer, this.$data.config.darkStyle);
96
95
  // 处理是否显示箭头元素
97
96
  if (!this.$data.config.showArrow) {
98
97
  $toolTipArrow.remove();
@@ -9,7 +9,7 @@ export type PopsTooltipPosition = "top" | "right" | "bottom" | "left" | "follow"
9
9
  */
10
10
  export interface PopsToolTipConfig extends Pick<
11
11
  PopsGeneralConfig,
12
- "useShadowRoot" | "only" | "zIndex" | "style" | "beforeAppendToPageCallBack"
12
+ "useShadowRoot" | "only" | "zIndex" | "style" | "lightStyle" | "darkStyle" | "beforeAppendToPageCallBack"
13
13
  > {
14
14
  /**
15
15
  * 目标元素
package/src/css/index.css CHANGED
@@ -28,6 +28,7 @@
28
28
  .pops {
29
29
  --pops-mask-bg-opacity: 0.8;
30
30
  --pops-color: #ffffff;
31
+ --pops-dark-color: #262626;
31
32
  --pops-bg-color: rgb(17, 17, 17, var(--pops-bg-opacity));
32
33
  --pops-bd-color: rgb(55, 55, 55, var(--pops-bd-opacity));
33
34
  --pops-box-shadow-color: rgba(81, 81, 81, 0.12);
@@ -1,18 +1,18 @@
1
1
  import type { PopsAlertConfig } from "../components/alert/types";
2
2
  import type { PopsConfirmConfig } from "../components/confirm/types";
3
3
  import type { PopsIframeConfig } from "../components/iframe/types";
4
+ import { PopsIcon } from "../PopsIcon";
4
5
  import type { PopsIconType } from "../types/icon";
5
6
  import type {
6
7
  PopsSupportAnimConfig,
7
- PopsSupportBottomButtonConfig,
8
- PopsSupportContentConfig,
9
- PopsSupportHeaderTitleConfig,
10
8
  PopsSupportAnimConfigType,
9
+ PopsSupportBottomButtonConfig,
11
10
  PopsSupportBottomButtonConfigType,
11
+ PopsSupportContentConfig,
12
12
  PopsSupportContentConfigType,
13
+ PopsSupportHeaderTitleConfig,
13
14
  PopsSupportHeaderTitleConfigType,
14
15
  } from "../types/main";
15
- import { PopsIcon } from "../PopsIcon";
16
16
  import { popsDOMUtils } from "../utils/PopsDOMUtils";
17
17
 
18
18
  export const PopsElementHandler = {
@@ -46,25 +46,27 @@ export const PopsElementHandler = {
46
46
  bottomBtnHTML = "",
47
47
  zIndex: number
48
48
  ) {
49
- const __config = config as PopsAlertConfig;
49
+ const __config__ = config as PopsAlertConfig;
50
50
  let popsAnimStyle = "";
51
51
  let popsStyle = "";
52
- const popsPosition = __config.position || "";
52
+ const popsPosition = __config__.position || "";
53
53
  if (config.zIndex != null) {
54
54
  popsAnimStyle += `z-index: ${zIndex};`;
55
55
  popsStyle += `z-index: ${zIndex};`;
56
56
  }
57
- if (__config.width != null) {
58
- popsStyle += `width: ${__config.width};`;
57
+ if (__config__.width != null) {
58
+ popsStyle += `width: ${__config__.width};`;
59
59
  }
60
- if (__config.height != null) {
61
- popsStyle += `height: ${__config.height};`;
60
+ if (__config__.height != null) {
61
+ popsStyle += `height: ${__config__.height};`;
62
62
  }
63
63
  const hasBottomBtn = bottomBtnHTML.trim() === "" ? false : true;
64
64
  return /*html*/ `
65
- <div class="pops-anim" anim="${__config.animation || ""}" style="${popsAnimStyle}" data-guid="${guid}">${
66
- config.style != null ? `<style tyle="text/css">${config.style}</style>` : ""
65
+ <div class="pops-anim" anim="${__config__.animation || ""}" style="${popsAnimStyle}" data-guid="${guid}">${
66
+ config.style != null ? /*html*/ `<style tyle="text/css" data-name="style">${config.style}</style>` : ""
67
67
  }
68
+ ${config.lightStyle != null ? /*html*/ `<style tyle="text/css" data-name="lightStyle">@media (prefers-color-scheme: light) {${config.lightStyle}}</style>` : ""}
69
+ ${config.darkStyle != null ? /*html*/ `<style tyle="text/css" data-name="darkStyle">@media (prefers-color-scheme: dark) {${config.darkStyle}}</style>` : ""}
68
70
  <div class="pops ${
69
71
  config.class || ""
70
72
  }" data-bottom-btn="${hasBottomBtn}" type-value="${type}" style="${popsStyle}" position="${popsPosition}" data-guid="${guid}">${html}</div>
@@ -300,4 +302,54 @@ export const PopsElementHandler = {
300
302
  parseElement<T extends HTMLElement>(html: string): T {
301
303
  return popsDOMUtils.parseTextToDOM(html);
302
304
  },
305
+ /**
306
+ * 添加样式元素
307
+ */
308
+ addStyle($parent: HTMLElement | ShadowRoot, style?: string | null) {
309
+ if (style == null) return;
310
+ const $css = popsDOMUtils.createElement(
311
+ "style",
312
+ {
313
+ innerHTML: style,
314
+ },
315
+ {
316
+ type: "text/css",
317
+ "data-name": "general",
318
+ }
319
+ );
320
+ $parent.appendChild($css);
321
+ return $css;
322
+ },
323
+ /**
324
+ * 添加在浅色模式下生效的style元素
325
+ */
326
+ addLightStyle($parent: HTMLElement | ShadowRoot, style?: string | null) {
327
+ const darkCSS = /*css*/ `
328
+ @media (prefers-color-scheme: light) {
329
+ ${style}
330
+ }
331
+ `;
332
+ const $css = this.addStyle($parent, darkCSS);
333
+ if (!$css) {
334
+ return;
335
+ }
336
+ $css.setAttribute("data-name", "light");
337
+ return $css;
338
+ },
339
+ /**
340
+ * 添加在深色模式下生效的style元素
341
+ */
342
+ addDarkStyle($parent: HTMLElement | ShadowRoot, style?: string | null) {
343
+ const darkCSS = /*css*/ `
344
+ @media (prefers-color-scheme: dark) {
345
+ ${style}
346
+ }
347
+ `;
348
+ const $css = this.addStyle($parent, darkCSS);
349
+ if (!$css) {
350
+ return;
351
+ }
352
+ $css.setAttribute("data-name", "dark");
353
+ return $css;
354
+ },
303
355
  };
@@ -171,14 +171,14 @@ export const PopsHandler = {
171
171
  );
172
172
  }
173
173
  // 判断按下的元素是否是pops-anim
174
- popsDOMUtils.on(config.animElement, ["touchstart", "mousedown"], (event) => {
174
+ popsDOMUtils.on(config.animElement, "pointerup", (event) => {
175
175
  const $click = event.composedPath()[0] as HTMLElement;
176
176
  isMaskClick = isAnimElement($click);
177
177
  });
178
178
  // 如果有动画层,在动画层上监听点击事件
179
179
  popsDOMUtils.on<MouseEvent | PointerEvent>(config.animElement, "click", (event) => {
180
180
  const $click = event.composedPath()[0] as HTMLElement;
181
- if (isAnimElement($click) && isMaskClick) {
181
+ if (isMaskClick && isAnimElement($click)) {
182
182
  return clickEvent(event);
183
183
  }
184
184
  });
@@ -202,6 +202,18 @@ export interface PopsGeneralConfig {
202
202
  * @default ""
203
203
  */
204
204
  style?: string | null;
205
+ /**
206
+ * (可选)自定义浅色模式的style
207
+ *
208
+ * 传入的css都在dark内
209
+ */
210
+ lightStyle?: string | null;
211
+ /**
212
+ * (可选)自定义深色模式的style
213
+ *
214
+ * 传入的css都在dark内
215
+ */
216
+ darkStyle?: string | null;
205
217
  /**
206
218
  * 在元素添加到页面前的事件
207
219
  * @param $shadowRoot 根元素
@@ -1,6 +1,7 @@
1
+ import AnyTouch from "any-touch";
2
+ import doubletap from "@any-touch/doubletap";
1
3
  import { PopsCore } from "../PopsCore";
2
4
  import type { PopsUtilsOwnObject } from "../types/main";
3
- import AnyTouch from "any-touch";
4
5
 
5
6
  class PopsUtils {
6
7
  /**
@@ -336,9 +337,18 @@ class PopsUtils {
336
337
  result = addType ? result + resultType.toString() : (parseFloat(result.toString()) as any);
337
338
  return result;
338
339
  }
340
+ /**
341
+ * https://github.com/any86/any-touch/blob/master/README.CN.md
342
+ */
339
343
  AnyTouch = () => {
340
344
  return AnyTouch;
341
345
  };
346
+ /**
347
+ * `any-touch`的`doubletap`事件插件
348
+ */
349
+ AnyTouchDoubleTapPlugin = () => {
350
+ return doubletap;
351
+ };
342
352
  /**
343
353
  * 通过navigator.userAgent判断是否是手机访问
344
354
  * @param userAgent