@pixelium/web-vue 0.0.2-fix → 0.0.3-alpha
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/README.md +42 -0
- package/README.zh.md +6 -3
- package/dist/font.css +1 -1
- package/dist/index.d.ts +1602 -248
- package/dist/normalize.css +2 -0
- package/dist/pixelium-vue-icon-hn.cjs +1 -1
- package/dist/pixelium-vue-icon-hn.css +2 -1
- package/dist/pixelium-vue-icon-hn.js +8533 -8154
- package/dist/pixelium-vue-icon-hn.umd.cjs +1 -1
- package/dist/pixelium-vue-icon-pa.cjs +1 -1
- package/dist/pixelium-vue-icon-pa.css +2 -1
- package/dist/pixelium-vue-icon-pa.js +10625 -10143
- package/dist/pixelium-vue-icon-pa.umd.cjs +1 -1
- package/dist/pixelium-vue.cjs +2 -2
- package/dist/pixelium-vue.css +2 -1
- package/dist/pixelium-vue.js +7407 -5854
- package/dist/pixelium-vue.umd.cjs +2 -2
- package/es/aside/index.css +1 -0
- package/es/aside/index.js +46 -151
- package/es/auto-complete/draw.d.ts +1 -1
- package/es/auto-complete/draw.js +26 -51
- package/es/auto-complete/index.css +92 -32
- package/es/auto-complete/index.d.ts +12 -15
- package/es/auto-complete/index.js +338 -400
- package/es/auto-complete/type.d.ts +25 -13
- package/es/avatar/css.js +2 -0
- package/es/avatar/draw.d.ts +2 -0
- package/es/avatar/draw.js +11 -0
- package/es/avatar/index.css +49 -0
- package/es/avatar/index.d.ts +15 -0
- package/es/avatar/index.js +110 -0
- package/es/avatar/type.d.ts +34 -0
- package/es/button/draw.d.ts +4 -4
- package/es/button/draw.js +213 -297
- package/es/button/index.css +40 -30
- package/es/button/index.d.ts +0 -4
- package/es/button/index.js +230 -256
- package/es/button/type.d.ts +3 -3
- package/es/button-group/index.css +0 -3
- package/es/button-group/index.d.ts +1 -2
- package/es/button-group/index.js +59 -31
- package/es/button-group/type.d.ts +21 -4
- package/es/checkbox/css.js +2 -0
- package/es/checkbox/draw.d.ts +4 -0
- package/es/checkbox/draw.js +46 -0
- package/es/checkbox/index.css +85 -0
- package/es/checkbox/index.d.ts +31 -0
- package/es/checkbox/index.js +206 -0
- package/es/checkbox/type.d.ts +88 -0
- package/es/checkbox-group/css.js +2 -0
- package/es/checkbox-group/index.css +20 -0
- package/es/checkbox-group/index.d.ts +23 -0
- package/es/checkbox-group/index.js +84 -0
- package/es/checkbox-group/type.d.ts +78 -0
- package/es/col/index.d.ts +2 -2
- package/es/col/index.js +43 -58
- package/es/container/index.css +1 -0
- package/es/container/index.js +18 -31
- package/es/divider/index.js +39 -53
- package/es/empty/index.css +4 -4
- package/es/empty/index.js +16 -71
- package/es/entry.js +102 -0
- package/es/footer/index.css +1 -0
- package/es/footer/index.js +31 -40
- package/es/form/css.js +1 -0
- package/es/form/index.d.ts +27 -0
- package/es/form/index.js +125 -0
- package/es/form/type.d.ts +238 -0
- package/es/form/use-form.d.ts +4 -0
- package/es/form/use-form.js +48 -0
- package/es/form-item/css.js +2 -0
- package/es/form-item/index.css +77 -0
- package/es/form-item/index.d.ts +37 -0
- package/es/form-item/index.js +318 -0
- package/es/form-item/type.d.ts +96 -0
- package/es/grid/index.js +56 -75
- package/es/grid-item/css.js +0 -1
- package/es/grid-item/index.d.ts +1 -1
- package/es/grid-item/index.js +85 -121
- package/es/header/index.css +1 -0
- package/es/header/index.js +31 -40
- package/es/icon/index.js +44 -55
- package/es/icons/css-hn.js +0 -1
- package/es/icons/css-pa.js +0 -1
- package/es/icons/icon-hn.js +10337 -15986
- package/es/icons/icon-pa.js +12573 -17447
- package/es/image/css.js +2 -0
- package/es/image/index.css +69 -0
- package/es/image/index.d.ts +35 -0
- package/es/image/index.js +199 -0
- package/es/image/type.d.ts +126 -0
- package/es/index.css +1 -515
- package/es/index.d.ts +22 -2
- package/es/index.js +144 -123
- package/es/input/draw.d.ts +1 -1
- package/es/input/draw.js +26 -51
- package/es/input/index.css +85 -33
- package/es/input/index.d.ts +9 -16
- package/es/input/index.js +319 -423
- package/es/input/type.d.ts +3 -3
- package/es/input-group/index.css +0 -1
- package/es/input-group/index.d.ts +2 -2
- package/es/input-group/index.js +66 -37
- package/es/input-group/type.d.ts +16 -4
- package/es/input-group-label/draw.d.ts +1 -1
- package/es/input-group-label/draw.js +26 -51
- package/es/input-group-label/index.css +33 -22
- package/es/input-group-label/index.d.ts +1 -4
- package/es/input-group-label/index.js +104 -127
- package/es/input-group-label/type.d.ts +3 -3
- package/es/input-number/draw.d.ts +1 -1
- package/es/input-number/draw.js +26 -51
- package/es/input-number/index.css +90 -35
- package/es/input-number/index.d.ts +9 -16
- package/es/input-number/index.js +428 -536
- package/es/input-number/type.d.ts +3 -3
- package/es/input-tag/draw.d.ts +1 -1
- package/es/input-tag/draw.js +26 -48
- package/es/input-tag/index.css +100 -33
- package/es/input-tag/index.d.ts +7 -13
- package/es/input-tag/index.js +442 -467
- package/es/input-tag/type.d.ts +24 -13
- package/es/link/index.js +75 -106
- package/es/main/index.css +4 -0
- package/es/main/index.d.ts +4 -1
- package/es/main/index.js +15 -15
- package/es/main/type.d.ts +7 -0
- package/es/mask/index.js +94 -115
- package/es/message/index.css +1 -1
- package/es/message/index.js +168 -346
- package/es/message-box/css.js +1 -1
- package/es/message-box/index.js +98 -114
- package/es/message-box/message-box-wrapped.js +33 -46
- package/es/message-box/message-box.js +79 -111
- package/es/option-list/index.css +13 -13
- package/es/option-list/index.d.ts +4 -31
- package/es/option-list/index.js +99 -167
- package/es/option-list/type.d.ts +5 -1
- package/es/pixelate/pixel.d.ts +5 -0
- package/es/pixelate/pixel.js +70 -0
- package/es/pixelate/pixelate.worker.d.ts +1 -0
- package/es/popover/index.d.ts +13 -99
- package/es/popover/index.js +75 -238
- package/es/popover/type.d.ts +7 -2
- package/es/popup/css.js +1 -0
- package/es/popup/index.d.ts +210 -0
- package/es/popup/index.js +203 -0
- package/es/popup/type.d.ts +105 -0
- package/es/popup-content/draw.d.ts +2 -2
- package/es/popup-content/draw.js +98 -143
- package/es/popup-content/index.css +11 -11
- package/es/popup-content/index.d.ts +1 -0
- package/es/popup-content/index.js +253 -1576
- package/es/popup-content/type.d.ts +1 -0
- package/es/popup-trigger/index.d.ts +8 -2
- package/es/popup-trigger/index.js +122 -95
- package/es/popup-trigger/type.d.ts +4 -1
- package/es/popup-wrapper/css.js +2 -0
- package/es/popup-wrapper/index.css +14 -0
- package/es/popup-wrapper/index.d.ts +18 -0
- package/es/popup-wrapper/index.js +67 -0
- package/es/popup-wrapper/type.d.ts +9 -0
- package/es/radio/css.js +1 -0
- package/es/radio/draw.d.ts +4 -0
- package/es/radio/draw.js +47 -0
- package/es/radio/index.d.ts +30 -0
- package/es/radio/index.js +190 -0
- package/es/radio/style.css +73 -0
- package/es/radio/type.d.ts +76 -0
- package/es/radio-group/css.js +2 -0
- package/es/radio-group/index.css +20 -0
- package/es/radio-group/index.d.ts +23 -0
- package/es/radio-group/index.js +77 -0
- package/es/radio-group/type.d.ts +77 -0
- package/es/row/index.js +56 -70
- package/es/select/draw.d.ts +1 -1
- package/es/select/draw.js +26 -51
- package/es/select/index.css +118 -36
- package/es/select/index.d.ts +14 -16
- package/es/select/index.js +625 -675
- package/es/select/type.d.ts +60 -25
- package/es/share/const/event-bus-key.js +1 -6
- package/es/share/const/index.d.ts +4 -0
- package/es/share/const/index.js +22 -24
- package/es/share/const/provide-key.d.ts +5 -0
- package/es/share/const/provide-key.js +6 -5
- package/es/share/const/style.d.ts +6 -0
- package/es/share/const/style.js +7 -0
- package/es/share/hook/use-cancelable-delay.d.ts +1 -0
- package/es/share/hook/use-cancelable-delay.js +42 -0
- package/es/share/hook/use-click-outside-listener.d.ts +1 -1
- package/es/share/hook/use-click-outside-listener.js +28 -41
- package/es/share/hook/use-composition.js +17 -15
- package/es/share/hook/use-controlled-mode.d.ts +3 -3
- package/es/share/hook/use-controlled-mode.js +20 -23
- package/es/share/hook/use-dark-mode.js +51 -65
- package/es/share/hook/use-index-of-children.d.ts +2 -1
- package/es/share/hook/use-index-of-children.js +47 -45
- package/es/share/hook/use-lazy-load.d.ts +10 -0
- package/es/share/hook/use-lazy-load.js +133 -0
- package/es/share/hook/use-props-detect.d.ts +2 -0
- package/es/share/hook/use-resize-observer.d.ts +1 -2
- package/es/share/hook/use-resize-observer.js +28 -20
- package/es/share/hook/use-screen-width.js +27 -36
- package/es/share/hook/use-smooth-transition.d.ts +2 -0
- package/es/share/hook/use-smooth-transition.js +65 -0
- package/es/share/hook/use-textarea-height.js +86 -92
- package/es/share/hook/use-theme-mode.js +41 -42
- package/es/share/hook/use-transition-end.d.ts +2 -0
- package/es/share/hook/use-transition-end.js +12 -0
- package/es/share/hook/use-watch-global-css-var.js +12 -16
- package/es/share/hook/use-window-resize-listener.d.ts +1 -0
- package/es/share/hook/use-window-resize-listener.js +15 -0
- package/es/share/hook/use-z-index.js +30 -27
- package/es/share/style/index.css +5 -0
- package/es/share/type/index.d.ts +18 -3
- package/es/share/util/color.d.ts +5 -3
- package/es/share/util/color.js +156 -149
- package/es/share/util/common.d.ts +7 -2
- package/es/share/util/common.js +127 -65
- package/es/share/util/console.d.ts +3 -3
- package/es/share/util/console.js +10 -7
- package/es/share/util/dom.d.ts +19 -0
- package/es/share/util/dom.js +88 -0
- package/es/share/util/env.d.ts +1 -0
- package/es/share/util/env.js +5 -4
- package/es/share/util/event-bus.js +3 -20
- package/es/share/util/lru-cache.js +29 -33
- package/es/share/util/pixel.d.ts +4 -0
- package/es/share/util/plot.d.ts +8 -3
- package/es/share/util/plot.js +457 -229
- package/es/share/util/reactivity.d.ts +8 -0
- package/es/share/util/reactivity.js +23 -0
- package/es/share/util/render.js +31 -41
- package/es/share/util/theme.d.ts +3 -0
- package/es/share/util/theme.js +77 -57
- package/es/slider/css.js +2 -0
- package/es/slider/draw.d.ts +25 -0
- package/es/slider/draw.js +113 -0
- package/es/slider/index.css +119 -0
- package/es/slider/index.d.ts +66 -0
- package/es/slider/index.js +503 -0
- package/es/slider/type.d.ts +162 -0
- package/es/slider/util.d.ts +37 -0
- package/es/slider/util.js +130 -0
- package/es/space/index.css +24 -29
- package/es/space/index.js +73 -97
- package/es/spin/index.css +18 -17
- package/es/spin/index.js +72 -102
- package/es/spin/type.d.ts +11 -5
- package/es/switch/css.js +2 -0
- package/es/switch/draw.d.ts +2 -0
- package/es/switch/draw.js +18 -0
- package/es/switch/index.css +121 -0
- package/es/switch/index.d.ts +42 -0
- package/es/switch/index.js +259 -0
- package/es/switch/type.d.ts +133 -0
- package/es/tag/draw.d.ts +2 -2
- package/es/tag/draw.js +80 -127
- package/es/tag/index.css +38 -22
- package/es/tag/index.d.ts +2 -2
- package/es/tag/index.js +121 -190
- package/es/tag/type.d.ts +3 -3
- package/es/text-outline/css.js +2 -0
- package/es/text-outline/index.css +4 -0
- package/es/text-outline/index.d.ts +17 -0
- package/es/text-outline/index.js +33 -0
- package/es/text-outline/type.d.ts +23 -0
- package/es/textarea/draw.js +9 -11
- package/es/textarea/index.css +37 -23
- package/es/textarea/index.d.ts +8 -14
- package/es/textarea/index.js +274 -262
- package/es/tooltip/index.d.ts +100 -4
- package/es/tooltip/index.js +70 -226
- package/es/tooltip/type.d.ts +7 -2
- package/es/vendor.js +504 -0
- package/es/virtual-list/css.js +2 -0
- package/es/virtual-list/index.css +25 -0
- package/es/virtual-list/index.d.ts +11 -0
- package/es/virtual-list/index.js +313 -0
- package/es/virtual-list/type.d.ts +26 -0
- package/package.json +10 -16
- package/es/grid-item/index.css +0 -0
- /package/es/message-box/{message-box.css → index.css} +0 -0
|
@@ -1,45 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
html.classList.remove("light", "dark");
|
|
9
|
-
if (t !== "unset") html.classList.add(t);
|
|
1
|
+
import { t as inBrowser } from "../util/env.js";
|
|
2
|
+
import { onBeforeUnmount, onScopeDispose, ref, watch } from "vue";
|
|
3
|
+
var apply = (t) => {
|
|
4
|
+
if (!inBrowser()) return;
|
|
5
|
+
const html = document.documentElement;
|
|
6
|
+
html.classList.remove("light", "dark");
|
|
7
|
+
if (t !== "unset") html.classList.add(t);
|
|
10
8
|
};
|
|
11
9
|
function useThemeMode(defaultTheme) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
10
|
+
const queryDarkMode = ref(false);
|
|
11
|
+
if (inBrowser()) {
|
|
12
|
+
const darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
13
|
+
function handleDarkModeChange(e) {
|
|
14
|
+
queryDarkMode.value = e.matches;
|
|
15
|
+
}
|
|
16
|
+
handleDarkModeChange(darkModeQuery);
|
|
17
|
+
darkModeQuery.addEventListener("change", handleDarkModeChange);
|
|
18
|
+
onBeforeUnmount(() => {
|
|
19
|
+
darkModeQuery.removeEventListener("change", handleDarkModeChange);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const theme = ref(defaultTheme || queryDarkMode.value ? "dark" : "light");
|
|
23
|
+
if (defaultTheme) apply(theme.value);
|
|
24
|
+
const toggle = () => {
|
|
25
|
+
theme.value = theme.value === "unset" ? queryDarkMode.value ? "light" : "dark" : theme.value === "light" ? "dark" : "light";
|
|
26
|
+
};
|
|
27
|
+
const clear = () => {
|
|
28
|
+
theme.value = "unset";
|
|
29
|
+
};
|
|
30
|
+
const followMedia = () => {
|
|
31
|
+
theme.value = queryDarkMode.value ? "dark" : "light";
|
|
32
|
+
};
|
|
33
|
+
const stopWatch = watch(theme, apply, { flush: "post" });
|
|
34
|
+
onScopeDispose(() => {
|
|
35
|
+
stopWatch();
|
|
36
|
+
});
|
|
37
|
+
return [
|
|
38
|
+
theme,
|
|
39
|
+
toggle,
|
|
40
|
+
clear,
|
|
41
|
+
followMedia
|
|
42
|
+
];
|
|
42
43
|
}
|
|
43
|
-
export {
|
|
44
|
-
useThemeMode as u
|
|
45
|
-
};
|
|
44
|
+
export { useThemeMode as t };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { onMounted, onUnmounted } from "vue";
|
|
2
|
+
function useTransitionEnd(elementRef, callback) {
|
|
3
|
+
onMounted(() => {
|
|
4
|
+
if (!elementRef.value) return;
|
|
5
|
+
elementRef.value.addEventListener("transitionend", callback);
|
|
6
|
+
});
|
|
7
|
+
onUnmounted(() => {
|
|
8
|
+
if (!elementRef.value) return;
|
|
9
|
+
elementRef.value.removeEventListener("transitionend", callback);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export { useTransitionEnd as t };
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
+
import { n as inVitest, t as inBrowser } from "../util/env.js";
|
|
2
|
+
import { t as EventBus } from "../util/event-bus.js";
|
|
3
|
+
import { n as GLOBAL_CSS_VAR_CHANGE } from "../const/event-bus-key.js";
|
|
1
4
|
import { onBeforeUnmount } from "vue";
|
|
2
|
-
import { i as inBrowser } from "../util/env.js";
|
|
3
|
-
import { E as EventBus } from "../util/event-bus.js";
|
|
4
|
-
import { a as GLOBAL_CSS_VAR_CHANGE } from "../const/event-bus-key.js";
|
|
5
5
|
const useWatchGlobalCssVal = (callback) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
EventBus.off(GLOBAL_CSS_VAR_CHANGE, cb);
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
export {
|
|
18
|
-
useWatchGlobalCssVal as u
|
|
6
|
+
if (!inBrowser() || inVitest()) return;
|
|
7
|
+
const cb = () => {
|
|
8
|
+
callback();
|
|
9
|
+
};
|
|
10
|
+
EventBus.on(GLOBAL_CSS_VAR_CHANGE, cb);
|
|
11
|
+
onBeforeUnmount(() => {
|
|
12
|
+
EventBus.off(GLOBAL_CSS_VAR_CHANGE, cb);
|
|
13
|
+
});
|
|
19
14
|
};
|
|
15
|
+
export { useWatchGlobalCssVal as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useWindowResizeListener: (callback: (event?: UIEvent) => any, leading?: boolean) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { t as inBrowser } from "../util/env.js";
|
|
2
|
+
import { nextTick, onBeforeUnmount, onMounted } from "vue";
|
|
3
|
+
const useWindowResizeListener = (callback, leading) => {
|
|
4
|
+
if (!inBrowser()) return;
|
|
5
|
+
onMounted(() => {
|
|
6
|
+
nextTick(() => {
|
|
7
|
+
leading && callback();
|
|
8
|
+
window.addEventListener("resize", callback);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
onBeforeUnmount(() => {
|
|
12
|
+
window.removeEventListener("resize", callback);
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
export { useWindowResizeListener as t };
|
|
@@ -1,32 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { onUnmounted, ref } from "vue";
|
|
2
|
+
var DEFAULT_CONFIG = {
|
|
3
|
+
message: { start: 3e3 },
|
|
4
|
+
popup: { start: 1e3 }
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
var stateMap = {};
|
|
7
7
|
function ensureNamespace(ns, cfg) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
return stateMap[ns];
|
|
8
|
+
if (!stateMap[ns]) stateMap[ns] = { initial: cfg.start };
|
|
9
|
+
return stateMap[ns];
|
|
12
10
|
}
|
|
11
|
+
var usedZIndex = /* @__PURE__ */ new Set();
|
|
12
|
+
var allocate = (ns) => {
|
|
13
|
+
const nextZIndex = (usedZIndex.size > 0 ? Math.max(...usedZIndex) : ns.initial) + 1;
|
|
14
|
+
usedZIndex.add(nextZIndex);
|
|
15
|
+
return nextZIndex;
|
|
16
|
+
};
|
|
13
17
|
function useZIndex(namespace = "popup") {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
const cfg = DEFAULT_CONFIG[namespace];
|
|
19
|
+
const ns = ensureNamespace(namespace, cfg);
|
|
20
|
+
const localZIndex = ref(allocate(ns));
|
|
21
|
+
const next = () => {
|
|
22
|
+
localZIndex.value = allocate(ns);
|
|
23
|
+
return localZIndex.value;
|
|
24
|
+
};
|
|
25
|
+
const release = () => {
|
|
26
|
+
usedZIndex.delete(localZIndex.value);
|
|
27
|
+
};
|
|
28
|
+
onUnmounted(release);
|
|
29
|
+
return [
|
|
30
|
+
localZIndex,
|
|
31
|
+
next,
|
|
32
|
+
release
|
|
33
|
+
];
|
|
29
34
|
}
|
|
30
|
-
export {
|
|
31
|
-
useZIndex as u
|
|
32
|
-
};
|
|
35
|
+
export { useZIndex as t };
|
package/es/share/type/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VNode } from 'vue';
|
|
1
|
+
import type { DefineComponent, VNode } from 'vue';
|
|
2
2
|
import type { JSX } from 'vue/jsx-runtime';
|
|
3
3
|
import type { GROUP_OPTION_TYPE, SCREEN_SIZE_TYPE } from '../const';
|
|
4
4
|
export type NumberOrPercentage = number | `${number}%`;
|
|
@@ -8,8 +8,13 @@ export type RgbaColor = {
|
|
|
8
8
|
b: number;
|
|
9
9
|
a: number;
|
|
10
10
|
};
|
|
11
|
-
export type
|
|
12
|
-
|
|
11
|
+
export type RgbColor = {
|
|
12
|
+
r: number;
|
|
13
|
+
g: number;
|
|
14
|
+
b: number;
|
|
15
|
+
};
|
|
16
|
+
export type ValidContent = string | ((...args: any[]) => VNode | string | JSX.Element);
|
|
17
|
+
export type ValidVNodeContent = (...args: any[]) => VNode | JSX.Element;
|
|
13
18
|
export type ValueWithDeviceWidth<T> = Record<SCREEN_SIZE_TYPE, T>;
|
|
14
19
|
export interface Option<T = any> {
|
|
15
20
|
value: T;
|
|
@@ -19,3 +24,13 @@ export interface GroupOption<T = any> {
|
|
|
19
24
|
children: (Option<T> | string)[];
|
|
20
25
|
type: typeof GROUP_OPTION_TYPE;
|
|
21
26
|
}
|
|
27
|
+
export type LooseRequired<T> = {
|
|
28
|
+
[P in keyof (T & Required<T>)]: T[P];
|
|
29
|
+
};
|
|
30
|
+
export type RemoveUndefinedFromFields<T, K extends keyof T> = {
|
|
31
|
+
[P in keyof T]: P extends K ? Exclude<T[P], undefined> : T[P];
|
|
32
|
+
};
|
|
33
|
+
export type VueComponent = DefineComponent<Record<string, never>, Record<string, never>, any>;
|
|
34
|
+
export type EmitEvent<T extends Record<string, any>> = {
|
|
35
|
+
[K in keyof T as `on${Capitalize<K & string>}`]?: (...args: T[K]) => void;
|
|
36
|
+
};
|
package/es/share/util/color.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { RgbaColor } from '../type';
|
|
2
|
-
export declare function parseColor(color: string): RgbaColor;
|
|
3
|
-
export declare const getGlobalThemeColor: (theme: string, level: number) => RgbaColor;
|
|
1
|
+
import type { RgbaColor, RgbColor } from '../type';
|
|
2
|
+
export declare function parseColor(color: string): RgbaColor | null;
|
|
3
|
+
export declare const getGlobalThemeColor: (theme: string, level: number) => RgbaColor | null;
|
|
4
|
+
export declare const getGlobalThemeColorString: (theme: string, level: number) => string;
|
|
4
5
|
export declare function generatePalette(r: number, g: number, b: number, a?: number, darkMode?: boolean): RgbaColor[];
|
|
5
6
|
export declare const rgbaColor2string: (color: RgbaColor) => string;
|
|
7
|
+
export declare function rgbaEuclideanDistance(color1: RgbaColor, color2: RgbaColor, background?: RgbColor): number;
|
package/es/share/util/color.js
CHANGED
|
@@ -1,169 +1,176 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { l as TRANSPARENT_RGBA_COLOR_OBJECT } from "../const/index.js";
|
|
2
|
+
import { t as inBrowser } from "./env.js";
|
|
3
|
+
import { t as createLRU } from "./lru-cache.js";
|
|
4
|
+
var colorCache = createLRU(120);
|
|
5
5
|
function parseColor(color) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
6
|
+
const cached = colorCache.get(color);
|
|
7
|
+
if (cached) return { ...cached };
|
|
8
|
+
if (color.startsWith("rgb(") || color.startsWith("rgba(")) {
|
|
9
|
+
let result = {
|
|
10
|
+
r: 0,
|
|
11
|
+
g: 0,
|
|
12
|
+
b: 0,
|
|
13
|
+
a: 255
|
|
14
|
+
};
|
|
15
|
+
const matches = color.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/i);
|
|
16
|
+
if (matches) {
|
|
17
|
+
result.r = parseInt(matches[1], 10);
|
|
18
|
+
result.g = parseInt(matches[2], 10);
|
|
19
|
+
result.b = parseInt(matches[3], 10);
|
|
20
|
+
if (matches[4]) result.a = Math.round(parseFloat(matches[4]) * 255);
|
|
21
|
+
}
|
|
22
|
+
colorCache.set(color, result);
|
|
23
|
+
return { ...result };
|
|
24
|
+
} else if (color.startsWith("#")) {
|
|
25
|
+
let result = {
|
|
26
|
+
r: 0,
|
|
27
|
+
g: 0,
|
|
28
|
+
b: 0,
|
|
29
|
+
a: 255
|
|
30
|
+
};
|
|
31
|
+
color = color.slice(1);
|
|
32
|
+
if (color.length === 3) {
|
|
33
|
+
result.r = parseInt(color[0] + color[0], 16);
|
|
34
|
+
result.g = parseInt(color[1] + color[1], 16);
|
|
35
|
+
result.b = parseInt(color[2] + color[2], 16);
|
|
36
|
+
} else if (color.length === 4) {
|
|
37
|
+
result.r = parseInt(color[0] + color[0], 16);
|
|
38
|
+
result.g = parseInt(color[1] + color[1], 16);
|
|
39
|
+
result.b = parseInt(color[2] + color[2], 16);
|
|
40
|
+
result.a = parseInt(color[3] + color[3], 16);
|
|
41
|
+
} else if (color.length === 6) {
|
|
42
|
+
result.r = parseInt(color.slice(0, 2), 16);
|
|
43
|
+
result.g = parseInt(color.slice(2, 4), 16);
|
|
44
|
+
result.b = parseInt(color.slice(4, 6), 16);
|
|
45
|
+
} else if (color.length === 8) {
|
|
46
|
+
result.r = parseInt(color.slice(0, 2), 16);
|
|
47
|
+
result.g = parseInt(color.slice(2, 4), 16);
|
|
48
|
+
result.b = parseInt(color.slice(4, 6), 16);
|
|
49
|
+
result.a = parseInt(color.slice(6, 8), 16);
|
|
50
|
+
}
|
|
51
|
+
colorCache.set(color, result);
|
|
52
|
+
return { ...result };
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
43
55
|
}
|
|
44
56
|
const getGlobalThemeColor = (theme, level) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
if (!inBrowser()) return TRANSPARENT_RGBA_COLOR_OBJECT;
|
|
58
|
+
return parseColor(getComputedStyle(document.documentElement).getPropertyValue(`--px-${theme}-${level}`));
|
|
59
|
+
};
|
|
60
|
+
const getGlobalThemeColorString = (theme, level) => {
|
|
61
|
+
if (!inBrowser()) return "rgba(0,0,0,0)";
|
|
62
|
+
return getComputedStyle(document.documentElement).getPropertyValue(`--px-${theme}-${level}`);
|
|
51
63
|
};
|
|
52
64
|
function toLinear(c) {
|
|
53
|
-
|
|
65
|
+
return c <= .04045 ? c / 12.92 : Math.pow((c + .055) / 1.055, 2.4);
|
|
54
66
|
}
|
|
55
67
|
function rgbaToOklch(r, g, b, a = 255) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
68
|
+
const rn = r / 255;
|
|
69
|
+
const gn = g / 255;
|
|
70
|
+
const bn = b / 255;
|
|
71
|
+
const lr = toLinear(rn);
|
|
72
|
+
const lg = toLinear(gn);
|
|
73
|
+
const lb = toLinear(bn);
|
|
74
|
+
let x = lr * .41239079926595934 + lg * .357584339383878 + lb * .1804807884018343;
|
|
75
|
+
let y = lr * .21263900587151027 + lg * .715168678767756 + lb * .07219231536073371;
|
|
76
|
+
let z = lr * .01933081871559182 + lg * .11919477979462598 + lb * .9505321522496607;
|
|
77
|
+
let l_ = .819022437996703 * x + .3619062600528904 * y - .1288737815209879 * z;
|
|
78
|
+
let m = .0329836539323885 * x + .9292868615863434 * y + .0361446663506424 * z;
|
|
79
|
+
let s = .0481771893596242 * x + .2642395317527308 * y + .6335478284694309 * z;
|
|
80
|
+
l_ = Math.cbrt(l_);
|
|
81
|
+
m = Math.cbrt(m);
|
|
82
|
+
s = Math.cbrt(s);
|
|
83
|
+
const l = .210454268309314 * l_ + .7936177747023054 * m - .0040720430116193 * s;
|
|
84
|
+
const aLab = 1.9779985324311684 * l_ - 2.42859224204858 * m + .450593709617411 * s;
|
|
85
|
+
const bLab = .0259040424655478 * l_ + .7827717124575296 * m - .8086757549230774 * s;
|
|
86
|
+
const c = Math.sqrt(aLab * aLab + bLab * bLab);
|
|
87
|
+
let h = Math.atan2(bLab, aLab) * 180 / Math.PI;
|
|
88
|
+
if (h < 0) h += 360;
|
|
89
|
+
return {
|
|
90
|
+
l,
|
|
91
|
+
c,
|
|
92
|
+
h,
|
|
93
|
+
a
|
|
94
|
+
};
|
|
83
95
|
}
|
|
84
96
|
function toGamma(cLin) {
|
|
85
|
-
|
|
97
|
+
return cLin <= .0031308 ? 12.92 * cLin : 1.055 * Math.pow(cLin, 1 / 2.4) - .055;
|
|
86
98
|
}
|
|
87
99
|
function oklchToRgba(l, c, h, a = 255) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
100
|
+
const hRad = h * Math.PI / 180;
|
|
101
|
+
const aLab = c * Math.cos(hRad);
|
|
102
|
+
const bLab = c * Math.sin(hRad);
|
|
103
|
+
let l_ = l + .3963377773761749 * aLab + .2158037573099136 * bLab;
|
|
104
|
+
let m = l - .1055613458156586 * aLab - .0638541728258133 * bLab;
|
|
105
|
+
let s = l - .0894841775298119 * aLab - 1.2914855480194092 * bLab;
|
|
106
|
+
l_ = l_ * l_ * l_;
|
|
107
|
+
m = m * m * m;
|
|
108
|
+
s = s * s * s;
|
|
109
|
+
const x = 1.2268798758459243 * l_ - .5578149944602171 * m + .2813910456659647 * s;
|
|
110
|
+
const y = -.0405757452148008 * l_ + 1.112286803280317 * m - .0717110580655164 * s;
|
|
111
|
+
const z = -.0763729366746601 * l_ - .4214933324022432 * m + 1.5869240198367816 * s;
|
|
112
|
+
const lr = 3.2409699419045226 * x - 1.537383177570094 * y - .4986107602930034 * z;
|
|
113
|
+
const lg = -.9692436362808796 * x + 1.8759675015077202 * y + .04155505740717559 * z;
|
|
114
|
+
const lb = .05563007969699366 * x - .20397695888897652 * y + 1.0569715142428786 * z;
|
|
115
|
+
const r = toGamma(lr);
|
|
116
|
+
const g = toGamma(lg);
|
|
117
|
+
const b = toGamma(lb);
|
|
118
|
+
return {
|
|
119
|
+
r: Math.round(r * 255),
|
|
120
|
+
g: Math.round(g * 255),
|
|
121
|
+
b: Math.round(b * 255),
|
|
122
|
+
a
|
|
123
|
+
};
|
|
112
124
|
}
|
|
113
125
|
function inGamut(c, l, h) {
|
|
114
|
-
|
|
115
|
-
|
|
126
|
+
const { r, g, b } = oklchToRgba(l, c, h);
|
|
127
|
+
return r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255;
|
|
116
128
|
}
|
|
117
129
|
function maxChromaForOklch(l, h) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
130
|
+
const tol = 1e-6;
|
|
131
|
+
let lo = 0, hi = 2;
|
|
132
|
+
while (hi - lo > tol) {
|
|
133
|
+
const mid = (lo + hi) / 2;
|
|
134
|
+
if (inGamut(mid, l, h)) lo = mid;
|
|
135
|
+
else hi = mid;
|
|
136
|
+
}
|
|
137
|
+
return lo;
|
|
126
138
|
}
|
|
127
|
-
|
|
139
|
+
var paletteCache = createLRU(60);
|
|
128
140
|
function generatePalette(r, g, b, a = 255, darkMode = false) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
141
|
+
const key = `${r},${g},${b},${a},${darkMode}`;
|
|
142
|
+
const cached = paletteCache.get(key);
|
|
143
|
+
if (cached) return cached;
|
|
144
|
+
const oklch = rgbaToOklch(r, g, b, a);
|
|
145
|
+
let palette = [];
|
|
146
|
+
const minC = oklch.c < .049 ? 0 : .049;
|
|
147
|
+
const startL = darkMode ? Math.min(Math.max(oklch.l, .05), .85) : Math.min(Math.max(oklch.l, .15), .95);
|
|
148
|
+
const startC = Math.min(Math.max(oklch.c, minC), maxChromaForOklch(startL, oklch.h));
|
|
149
|
+
const maxL = Math.min(startL + .35, darkMode ? .85 : .9);
|
|
150
|
+
const minL = Math.max(startL - .35, darkMode ? .1 : .15);
|
|
151
|
+
const stepSizeDown4L = darkMode ? (startL - minL) / 4 : (maxL - startL) / 4;
|
|
152
|
+
const stepSizeDown4C = (startC - minC) / 4;
|
|
153
|
+
const stepSizeUp4L = darkMode ? (maxL - startL) / 3 : (startL - minL) / 3;
|
|
154
|
+
const stepSizeUp4C = (startC - minC) / 3;
|
|
155
|
+
for (let i = 0; i < 5; i++) {
|
|
156
|
+
const L = startL + (darkMode ? -1 : 1) * stepSizeDown4L * (5 - i);
|
|
157
|
+
const C = Math.min(startC - stepSizeDown4C * (5 - i), maxChromaForOklch(L, oklch.h));
|
|
158
|
+
const h = oklch.h;
|
|
159
|
+
const color = oklchToRgba(L, C, h, a);
|
|
160
|
+
palette.push(color);
|
|
161
|
+
}
|
|
162
|
+
palette.push(oklchToRgba(startL, startC, oklch.h, a));
|
|
163
|
+
for (let i = 0; i < 4; i++) {
|
|
164
|
+
const L = startL - (darkMode ? -1 : 1) * stepSizeUp4L * (i + 1);
|
|
165
|
+
const C = Math.min(startC - stepSizeUp4C * (i + 1), maxChromaForOklch(L, oklch.h));
|
|
166
|
+
const h = oklch.h;
|
|
167
|
+
const color = oklchToRgba(L, C, h, a);
|
|
168
|
+
palette.push(color);
|
|
169
|
+
}
|
|
170
|
+
paletteCache.set(key, palette);
|
|
171
|
+
return palette;
|
|
160
172
|
}
|
|
161
173
|
const rgbaColor2string = (color) => {
|
|
162
|
-
|
|
163
|
-
};
|
|
164
|
-
export {
|
|
165
|
-
generatePalette as a,
|
|
166
|
-
getGlobalThemeColor as g,
|
|
167
|
-
parseColor as p,
|
|
168
|
-
rgbaColor2string as r
|
|
174
|
+
return `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a / 255})`;
|
|
169
175
|
};
|
|
176
|
+
export { rgbaColor2string as a, parseColor as i, getGlobalThemeColor as n, getGlobalThemeColorString as r, generatePalette as t };
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { GroupOption, Option } from '../type';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const fillArr: (val: number, size: number) => any[];
|
|
2
|
+
export declare const fillArr: (val: number, size: number) => number[];
|
|
4
3
|
export declare const defaultFilter: <T extends string | Option | GroupOption>(keyword: string, list?: T[]) => T[];
|
|
5
4
|
export declare const findSameOption: <T extends string | Option | GroupOption>(keyword: string, list: T[], checkLabel?: boolean) => T[];
|
|
5
|
+
export declare function offsetOutward(center: [number, number], points: [number, number][], offset: number): [number, number][];
|
|
6
|
+
export declare function isUrl(url: any, options?: {
|
|
7
|
+
allowWithoutProtocol?: boolean;
|
|
8
|
+
allowIpv6?: boolean;
|
|
9
|
+
}): boolean;
|
|
10
|
+
export declare const fixedNumber: (value: number, precision: number) => number;
|