@whitesev/pops 3.3.0 → 3.3.1
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.
- package/dist/index.amd.js +127 -44
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +127 -44
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +127 -44
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +127 -44
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +127 -44
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +127 -44
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Pops.d.ts +5 -0
- package/dist/types/src/PopsCore.d.ts +1 -1
- package/dist/types/src/components/panel/handlerComponents.d.ts +8 -4
- package/dist/types/src/components/panel/types/components-switch.d.ts +12 -2
- package/dist/types/src/components/rightClickMenu/types/index.d.ts +1 -1
- package/dist/types/src/components/searchSuggestion/index.d.ts +1 -1
- package/dist/types/src/components/searchSuggestion/types/index.d.ts +1 -1
- package/dist/types/src/components/tooltip/index.d.ts +2 -0
- package/dist/types/src/components/tooltip/types/index.d.ts +1 -1
- package/dist/types/src/config/GlobalConfig.d.ts +2 -0
- package/dist/types/src/handler/PopsElementHandler.d.ts +13 -1
- package/dist/types/src/types/components.d.ts +12 -0
- package/package.json +3 -3
- package/src/PopsCore.ts +1 -1
- package/src/components/alert/defaultConfig.ts +2 -0
- package/src/components/alert/index.ts +2 -2
- package/src/components/confirm/defaultConfig.ts +2 -0
- package/src/components/drawer/defaultConfig.ts +2 -0
- package/src/components/folder/defaultConfig.ts +2 -0
- package/src/components/iframe/defaultConfig.ts +2 -0
- package/src/components/loading/defaultConfig.ts +2 -0
- package/src/components/panel/defaultConfig.ts +2 -0
- package/src/components/panel/handlerComponents.ts +38 -21
- package/src/components/panel/index.css +1 -0
- package/src/components/panel/types/components-switch.ts +12 -2
- package/src/components/prompt/defaultConfig.ts +2 -0
- package/src/components/rightClickMenu/defaultConfig.ts +2 -0
- package/src/components/rightClickMenu/index.ts +7 -12
- package/src/components/rightClickMenu/types/index.ts +1 -1
- package/src/components/searchSuggestion/defaultConfig.ts +2 -0
- package/src/components/searchSuggestion/index.ts +13 -13
- package/src/components/searchSuggestion/types/index.ts +1 -1
- package/src/components/tooltip/defaultConfig.ts +2 -0
- package/src/components/tooltip/index.ts +7 -8
- package/src/components/tooltip/types/index.ts +1 -1
- package/src/css/index.css +1 -0
- package/src/handler/PopsElementHandler.ts +64 -12
- package/src/types/components.d.ts +12 -0
- package/src/utils/PopsUtils.ts +1 -1
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
|
|
49
|
+
const __config__ = config as PopsAlertConfig;
|
|
50
50
|
let popsAnimStyle = "";
|
|
51
51
|
let popsStyle = "";
|
|
52
|
-
const popsPosition =
|
|
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 (
|
|
58
|
-
popsStyle += `width: ${
|
|
57
|
+
if (__config__.width != null) {
|
|
58
|
+
popsStyle += `width: ${__config__.width};`;
|
|
59
59
|
}
|
|
60
|
-
if (
|
|
61
|
-
popsStyle += `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="${
|
|
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
|
};
|
|
@@ -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 根元素
|