@pixelium/web-vue 0.0.1-beta → 0.0.2-fix
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 +21 -10
- package/README.zh.md +21 -10
- package/dist/icon-pa.d.ts +490 -0
- package/dist/index.d.ts +1586 -10
- package/dist/pixelium-vue-icon-pa.cjs +1 -0
- package/dist/pixelium-vue-icon-pa.css +1 -0
- package/dist/pixelium-vue-icon-pa.js +10143 -0
- package/dist/pixelium-vue-icon-pa.umd.cjs +1 -0
- package/dist/pixelium-vue.cjs +12 -1
- package/dist/pixelium-vue.css +1 -1
- package/dist/pixelium-vue.js +5370 -1093
- package/dist/pixelium-vue.umd.cjs +12 -1
- package/es/aside/css.js +1 -1
- package/es/aside/index.js +60 -13
- package/es/auto-complete/css.js +2 -0
- package/es/auto-complete/draw.d.ts +2 -0
- package/es/auto-complete/draw.js +52 -0
- package/es/auto-complete/index.css +123 -0
- package/es/auto-complete/index.d.ts +35 -0
- package/es/auto-complete/index.js +402 -0
- package/es/auto-complete/type.d.ts +192 -0
- package/es/button/css.js +1 -1
- package/es/button/draw.d.ts +1 -2
- package/es/button/draw.js +105 -123
- package/es/button/index.css +24 -14
- package/es/button/index.js +70 -121
- package/es/button-group/css.js +1 -1
- package/es/button-group/index.d.ts +0 -1
- package/es/button-group/index.js +11 -37
- package/es/button-group/type.d.ts +1 -1
- package/es/col/css.js +1 -1
- package/es/col/index.d.ts +2 -2
- package/es/container/css.js +1 -1
- package/es/divider/css.js +1 -1
- package/es/empty/css.js +2 -0
- package/es/empty/index.css +19 -0
- package/es/empty/index.d.ts +17 -0
- package/es/empty/index.js +73 -0
- package/es/empty/type.d.ts +19 -0
- package/es/footer/css.js +1 -1
- package/es/grid/css.js +1 -1
- package/es/grid/index.js +5 -1
- package/es/grid-item/css.js +1 -1
- package/es/grid-item/index.d.ts +1 -1
- package/es/grid-item/index.js +7 -3
- package/es/header/css.js +1 -1
- package/es/icon/css.js +1 -1
- package/es/icon/index.css +0 -3
- package/es/icon/index.js +1 -1
- package/es/icons/css-pa.js +2 -0
- package/es/icons/icon-hn.js +1 -1
- package/es/icons/icon-pa.css +9 -0
- package/es/icons/icon-pa.d.ts +490 -0
- package/es/icons/icon-pa.js +17449 -0
- package/es/index.css +22 -8
- package/es/index.d.ts +18 -1
- package/es/index.js +63 -2
- package/es/input/css.js +2 -0
- package/es/input/draw.d.ts +2 -0
- package/es/input/draw.js +52 -0
- package/es/input/index.css +138 -0
- package/es/input/index.d.ts +50 -0
- package/es/input/index.js +432 -0
- package/es/input/type.d.ts +175 -0
- package/es/input-group/css.js +2 -0
- package/es/input-group/index.css +24 -0
- package/es/input-group/index.d.ts +17 -0
- package/es/input-group/index.js +40 -0
- package/es/input-group/type.d.ts +30 -0
- package/es/input-group-label/css.js +2 -0
- package/es/input-group-label/draw.d.ts +2 -0
- package/es/input-group-label/draw.js +52 -0
- package/es/input-group-label/index.css +50 -0
- package/es/input-group-label/index.d.ts +16 -0
- package/es/input-group-label/index.js +129 -0
- package/es/input-group-label/type.d.ts +30 -0
- package/es/input-number/css.js +2 -0
- package/es/input-number/draw.d.ts +2 -0
- package/es/input-number/draw.js +52 -0
- package/es/input-number/index.css +161 -0
- package/es/input-number/index.d.ts +47 -0
- package/es/input-number/index.js +543 -0
- package/es/input-number/type.d.ts +183 -0
- package/es/input-tag/css.js +2 -0
- package/es/input-tag/draw.d.ts +2 -0
- package/es/input-tag/draw.js +49 -0
- package/es/input-tag/index.css +133 -0
- package/es/input-tag/index.d.ts +73 -0
- package/es/input-tag/index.js +474 -0
- package/es/input-tag/type.d.ts +212 -0
- package/es/link/css.js +1 -1
- package/es/link/index.css +2 -5
- package/es/link/index.js +10 -6
- package/es/main/css.js +1 -1
- package/es/mask/css.js +2 -0
- package/es/mask/index.css +17 -0
- package/es/mask/index.d.ts +8 -0
- package/es/mask/index.js +117 -0
- package/es/mask/type.d.ts +27 -0
- package/es/message/css.js +1 -1
- package/es/message/index.css +26 -26
- package/es/message/index.d.ts +1 -1
- package/es/message/index.js +22 -50
- package/es/message-box/css.js +1 -1
- package/es/message-box/index.js +40 -30
- package/es/message-box/message-box-wrapped.d.ts +0 -1
- package/es/message-box/message-box-wrapped.js +2 -2
- package/es/message-box/message-box.d.ts +2 -1
- package/es/message-box/message-box.js +10 -8
- package/es/message-box/type.d.ts +14 -4
- package/es/option-list/css.js +2 -0
- package/es/option-list/index.css +57 -0
- package/es/option-list/index.d.ts +38 -0
- package/es/option-list/index.js +169 -0
- package/es/option-list/type.d.ts +16 -0
- package/es/popover/css.js +1 -0
- package/es/popover/index.d.ts +203 -0
- package/es/popover/index.js +240 -0
- package/es/popover/type.d.ts +100 -0
- package/es/popup-content/css.js +2 -0
- package/es/popup-content/draw.d.ts +6 -0
- package/es/popup-content/draw.js +151 -0
- package/es/popup-content/index.css +99 -0
- package/es/popup-content/index.d.ts +30 -0
- package/es/popup-content/index.js +1578 -0
- package/es/popup-content/type.d.ts +20 -0
- package/es/popup-trigger/css.js +1 -0
- package/es/popup-trigger/index.d.ts +22 -0
- package/es/popup-trigger/index.js +97 -0
- package/es/popup-trigger/type.d.ts +9 -0
- package/es/row/css.js +1 -1
- package/es/select/css.js +2 -0
- package/es/select/draw.d.ts +2 -0
- package/es/select/draw.js +52 -0
- package/es/select/index.css +152 -0
- package/es/select/index.d.ts +44 -0
- package/es/select/index.js +677 -0
- package/es/select/type.d.ts +252 -0
- package/es/share/const/event-bus-key.d.ts +4 -0
- package/es/share/const/event-bus-key.js +10 -0
- package/es/share/const/index.d.ts +4 -0
- package/es/share/const/index.js +11 -2
- package/es/share/const/provide-key.d.ts +3 -0
- package/es/share/const/provide-key.js +8 -0
- package/es/share/hook/use-click-outside-listener.d.ts +4 -0
- package/es/share/hook/use-click-outside-listener.js +44 -0
- package/es/share/hook/use-composition.d.ts +5 -0
- package/es/share/hook/use-composition.js +17 -0
- package/es/share/hook/use-controlled-mode.d.ts +6 -0
- package/es/share/hook/use-controlled-mode.js +25 -0
- package/es/share/hook/use-dark-mode.js +11 -3
- package/es/share/hook/use-index-of-children.d.ts +2 -1
- package/es/share/hook/use-index-of-children.js +25 -35
- package/es/share/hook/use-resize-observer.js +1 -1
- package/es/share/hook/use-textarea-height.d.ts +5 -0
- package/es/share/hook/use-textarea-height.js +116 -0
- package/es/share/hook/use-watch-global-css-var.d.ts +1 -0
- package/es/share/hook/use-watch-global-css-var.js +19 -0
- package/es/share/hook/use-z-index.d.ts +6 -0
- package/es/share/hook/use-z-index.js +32 -0
- package/es/share/type/index.d.ts +9 -1
- package/es/share/util/color.js +4 -2
- package/es/share/util/common.d.ts +5 -0
- package/es/share/util/common.js +71 -0
- package/es/share/util/event-bus.d.ts +1 -0
- package/es/share/util/event-bus.js +20 -0
- package/es/share/util/plot.d.ts +15 -2
- package/es/share/util/plot.js +200 -30
- package/es/share/util/render.d.ts +1 -0
- package/es/share/util/render.js +10 -2
- package/es/share/util/theme.js +23 -4
- package/es/space/css.js +1 -1
- package/es/space/index.css +5 -0
- package/es/space/index.js +2 -2
- package/es/spin/css.js +2 -0
- package/es/spin/index.css +66 -0
- package/es/spin/index.d.ts +24 -0
- package/es/spin/index.js +104 -0
- package/es/spin/type.d.ts +54 -0
- package/es/tag/css.js +2 -0
- package/es/tag/draw.d.ts +6 -0
- package/es/tag/draw.js +135 -0
- package/es/tag/index.css +372 -0
- package/es/tag/index.d.ts +23 -0
- package/es/tag/index.js +193 -0
- package/es/tag/type.d.ts +58 -0
- package/es/textarea/css.js +2 -0
- package/es/textarea/draw.d.ts +2 -0
- package/es/textarea/draw.js +13 -0
- package/es/textarea/index.css +108 -0
- package/es/textarea/index.d.ts +49 -0
- package/es/textarea/index.js +267 -0
- package/es/textarea/type.d.ts +169 -0
- package/es/tooltip/css.js +1 -0
- package/es/tooltip/index.d.ts +20 -0
- package/es/tooltip/index.js +228 -0
- package/es/tooltip/type.d.ts +77 -0
- package/package.json +17 -3
- package/es/icons/{css.js → css-hn.js} +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useWatchGlobalCssVal: (callback: Function) => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
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
|
+
const useWatchGlobalCssVal = (callback) => {
|
|
6
|
+
if (!inBrowser()) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const cb = () => {
|
|
10
|
+
callback();
|
|
11
|
+
};
|
|
12
|
+
EventBus.on(GLOBAL_CSS_VAR_CHANGE, cb);
|
|
13
|
+
onBeforeUnmount(() => {
|
|
14
|
+
EventBus.off(GLOBAL_CSS_VAR_CHANGE, cb);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
useWatchGlobalCssVal as u
|
|
19
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface NamespaceConfig {
|
|
2
|
+
start: number;
|
|
3
|
+
}
|
|
4
|
+
declare const DEFAULT_CONFIG: Record<string, NamespaceConfig>;
|
|
5
|
+
export declare function useZIndex(namespace?: keyof typeof DEFAULT_CONFIG): readonly [import("vue").Ref<number, number>, () => number, () => void];
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ref, onUnmounted } from "vue";
|
|
2
|
+
const DEFAULT_CONFIG = {
|
|
3
|
+
message: { start: 3e3 },
|
|
4
|
+
popup: { start: 1e3 }
|
|
5
|
+
};
|
|
6
|
+
const stateMap = {};
|
|
7
|
+
function ensureNamespace(ns, cfg) {
|
|
8
|
+
if (!stateMap[ns]) {
|
|
9
|
+
stateMap[ns] = { max: cfg.start, count: 0, initial: cfg.start };
|
|
10
|
+
}
|
|
11
|
+
return stateMap[ns];
|
|
12
|
+
}
|
|
13
|
+
function useZIndex(namespace = "popup") {
|
|
14
|
+
const cfg = DEFAULT_CONFIG[namespace];
|
|
15
|
+
const ns = ensureNamespace(namespace, cfg);
|
|
16
|
+
const localZIndex = ref(++ns.max);
|
|
17
|
+
ns.count++;
|
|
18
|
+
const next = () => {
|
|
19
|
+
localZIndex.value = ++ns.max;
|
|
20
|
+
return localZIndex.value;
|
|
21
|
+
};
|
|
22
|
+
const release = () => {
|
|
23
|
+
if (--ns.count === 0) {
|
|
24
|
+
ns.max = ns.initial;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
onUnmounted(release);
|
|
28
|
+
return [localZIndex, next, release];
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
useZIndex as u
|
|
32
|
+
};
|
package/es/share/type/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { VNode } from 'vue';
|
|
2
2
|
import type { JSX } from 'vue/jsx-runtime';
|
|
3
|
-
import type { SCREEN_SIZE_TYPE } from '../const';
|
|
3
|
+
import type { GROUP_OPTION_TYPE, SCREEN_SIZE_TYPE } from '../const';
|
|
4
4
|
export type NumberOrPercentage = number | `${number}%`;
|
|
5
5
|
export type RgbaColor = {
|
|
6
6
|
r: number;
|
|
@@ -11,3 +11,11 @@ export type RgbaColor = {
|
|
|
11
11
|
export type ValidContent = string | (() => VNode | string | JSX.Element);
|
|
12
12
|
export type ValidVNodeContent = () => VNode | JSX.Element;
|
|
13
13
|
export type ValueWithDeviceWidth<T> = Record<SCREEN_SIZE_TYPE, T>;
|
|
14
|
+
export interface Option<T = any> {
|
|
15
|
+
value: T;
|
|
16
|
+
label: string;
|
|
17
|
+
}
|
|
18
|
+
export interface GroupOption<T = any> {
|
|
19
|
+
children: (Option<T> | string)[];
|
|
20
|
+
type: typeof GROUP_OPTION_TYPE;
|
|
21
|
+
}
|
package/es/share/util/color.js
CHANGED
|
@@ -45,7 +45,9 @@ const getGlobalThemeColor = (theme, level) => {
|
|
|
45
45
|
if (!inBrowser()) {
|
|
46
46
|
return TRANSPARENT_RGBA_COLOR_OBJECT;
|
|
47
47
|
}
|
|
48
|
-
return parseColor(
|
|
48
|
+
return parseColor(
|
|
49
|
+
getComputedStyle(document.documentElement).getPropertyValue(`--px-${theme}-${level}`)
|
|
50
|
+
);
|
|
49
51
|
};
|
|
50
52
|
function toLinear(c) {
|
|
51
53
|
return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
@@ -157,7 +159,7 @@ function generatePalette(r, g, b, a = 255, darkMode = false) {
|
|
|
157
159
|
return palette;
|
|
158
160
|
}
|
|
159
161
|
const rgbaColor2string = (color) => {
|
|
160
|
-
return `rgba(${color.r}, ${color.g}, ${color.b}, ${
|
|
162
|
+
return `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a / 255})`;
|
|
161
163
|
};
|
|
162
164
|
export {
|
|
163
165
|
generatePalette as a,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { GroupOption, Option } from '../type';
|
|
2
|
+
export declare const clamp: (x: number, min: number, max: number) => number;
|
|
3
|
+
export declare const fillArr: (val: number, size: number) => any[];
|
|
4
|
+
export declare const defaultFilter: <T extends string | Option | GroupOption>(keyword: string, list?: T[]) => T[];
|
|
5
|
+
export declare const findSameOption: <T extends string | Option | GroupOption>(keyword: string, list: T[], checkLabel?: boolean) => T[];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { d } from "../../aside/index.js";
|
|
2
|
+
import { G as GROUP_OPTION_TYPE } from "../const/index.js";
|
|
3
|
+
const clamp = (x, min, max) => Math.max(min, Math.min(max, x));
|
|
4
|
+
const fillArr = (val, size) => Array(size).fill(val);
|
|
5
|
+
const defaultFilter = (keyword, list = []) => {
|
|
6
|
+
if (!keyword) {
|
|
7
|
+
return [...list];
|
|
8
|
+
}
|
|
9
|
+
const keyword4Search = keyword.toLowerCase();
|
|
10
|
+
const len = list.length;
|
|
11
|
+
const ans = [];
|
|
12
|
+
for (let i = 0; i < len; i++) {
|
|
13
|
+
const currentElement = list[i];
|
|
14
|
+
if (d(currentElement)) {
|
|
15
|
+
if ("type" in currentElement && currentElement.type === GROUP_OPTION_TYPE) {
|
|
16
|
+
const children = defaultFilter(keyword, currentElement.children);
|
|
17
|
+
if (children.length) {
|
|
18
|
+
ans.push({
|
|
19
|
+
...currentElement,
|
|
20
|
+
children
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
if (currentElement.label.toLowerCase().includes(keyword4Search)) {
|
|
25
|
+
ans.push(currentElement);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
if (currentElement.toLowerCase().includes(keyword4Search)) {
|
|
30
|
+
ans.push(currentElement);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return ans;
|
|
35
|
+
};
|
|
36
|
+
const findSameOption = (keyword, list, checkLabel = false) => {
|
|
37
|
+
if (!keyword) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
const len = list.length;
|
|
41
|
+
const ans = [];
|
|
42
|
+
for (let i = 0; i < len; i++) {
|
|
43
|
+
const currentElement = list[i];
|
|
44
|
+
if (d(currentElement)) {
|
|
45
|
+
if ("type" in currentElement && currentElement.type === GROUP_OPTION_TYPE) {
|
|
46
|
+
const options = findSameOption(keyword, currentElement.children, checkLabel);
|
|
47
|
+
if (options.length) {
|
|
48
|
+
ans.push(options[0], currentElement);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
if (checkLabel && currentElement.label === keyword || currentElement.value === keyword) {
|
|
53
|
+
ans.push(currentElement);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
if (currentElement === keyword) {
|
|
59
|
+
ans.push(currentElement);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return ans;
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
findSameOption as a,
|
|
68
|
+
clamp as c,
|
|
69
|
+
defaultFilter as d,
|
|
70
|
+
fillArr as f
|
|
71
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EventBus: import("mitt").Emitter<Record<import("mitt").EventType, unknown>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function mitt(n) {
|
|
2
|
+
return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
|
|
3
|
+
var i = n.get(t);
|
|
4
|
+
i ? i.push(e) : n.set(t, [e]);
|
|
5
|
+
}, off: function(t, e) {
|
|
6
|
+
var i = n.get(t);
|
|
7
|
+
i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
|
|
8
|
+
}, emit: function(t, e) {
|
|
9
|
+
var i = n.get(t);
|
|
10
|
+
i && i.slice().map(function(n2) {
|
|
11
|
+
n2(e);
|
|
12
|
+
}), (i = n.get("*")) && i.slice().map(function(n2) {
|
|
13
|
+
n2(t, e);
|
|
14
|
+
});
|
|
15
|
+
} };
|
|
16
|
+
}
|
|
17
|
+
const EventBus = mitt();
|
|
18
|
+
export {
|
|
19
|
+
EventBus as E
|
|
20
|
+
};
|
package/es/share/util/plot.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { RgbaColor } from '../type';
|
|
1
|
+
import type { NumberOrPercentage, RgbaColor } from '../type';
|
|
2
|
+
import type { ShallowRef } from 'vue';
|
|
2
3
|
export declare function drawCircle(ctx: CanvasRenderingContext2D, centerX: number, centerY: number, radius: number, startRad: number | undefined, endRad: number | undefined, pixelSize: number): void;
|
|
3
4
|
export type floodFillArgs = {
|
|
4
5
|
x: number;
|
|
@@ -9,4 +10,16 @@ export type floodFillArgs = {
|
|
|
9
10
|
targetColor: RgbaColor;
|
|
10
11
|
pixels: number[];
|
|
11
12
|
};
|
|
12
|
-
export declare function floodFill(ctx: CanvasRenderingContext2D,
|
|
13
|
+
export declare function floodFill(ctx: CanvasRenderingContext2D, startX: number, startY: number, fillColor: RgbaColor): void;
|
|
14
|
+
export declare const transformBorderRadiusSizeValue: (canvas: HTMLCanvasElement, value: NumberOrPercentage, pixelSize: number) => number;
|
|
15
|
+
export declare const getBorderRadius: (canvas: HTMLCanvasElement, pixelSize: number, borderRadius: NumberOrPercentage | NumberOrPercentage[] | undefined, shape: "default" | "round" | "circle" | "square" | undefined, size?: "medium" | "small" | "large", inner?: boolean, first?: boolean, last?: boolean) => number[];
|
|
16
|
+
export declare function calcWhenLeaveBaseline(pixelSize: number, borderRadius: number): number;
|
|
17
|
+
export declare const calcPixelSize: () => number;
|
|
18
|
+
export declare const calcBorderCornerCenter: (borderRadius: number[], width: number, height: number, pixelSize: number, paddingX?: number, paddingY?: number) => [number, number][];
|
|
19
|
+
export declare const canvasPreprocess: (wrapperRef: ShallowRef<HTMLElement | null>, canvasRef: ShallowRef<HTMLCanvasElement | null>) => {
|
|
20
|
+
ctx: CanvasRenderingContext2D;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
rect: DOMRect;
|
|
24
|
+
canvas: HTMLCanvasElement;
|
|
25
|
+
} | undefined;
|
package/es/share/util/plot.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { $, k } from "../../aside/index.js";
|
|
2
|
+
import { f as fillArr, c as clamp } from "./common.js";
|
|
3
|
+
import { i as inBrowser } from "./env.js";
|
|
1
4
|
function shouldPlot(x, y, startRad, endRad) {
|
|
2
5
|
let currentAngle = Math.atan2(y, x);
|
|
3
6
|
if (currentAngle < 0) {
|
|
@@ -37,43 +40,210 @@ function drawCircle(ctx, centerX, centerY, radius, startRad = 0, endRad = Math.P
|
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
|
-
function floodFill(ctx,
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const targetR = pixels[targetPos];
|
|
45
|
-
const targetG = pixels[targetPos + 1];
|
|
46
|
-
const targetB = pixels[targetPos + 2];
|
|
47
|
-
const targetA = pixels[targetPos + 3];
|
|
48
|
-
if (!(0 === targetR && 0 === targetG && 0 === targetB && 0 === targetA)) {
|
|
43
|
+
function floodFill(ctx, startX, startY, fillColor) {
|
|
44
|
+
const w = ctx.canvas.width;
|
|
45
|
+
const h = ctx.canvas.height;
|
|
46
|
+
if (w <= 0 || h <= 0) {
|
|
49
47
|
return;
|
|
50
48
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
49
|
+
const img = ctx.getImageData(0, 0, w, h);
|
|
50
|
+
const data32 = new Uint32Array(img.data.buffer);
|
|
51
|
+
const uint32Color = fillColor.a << 24 | fillColor.b << 16 | fillColor.g << 8 | fillColor.r;
|
|
52
|
+
const startPos = startY * w + startX;
|
|
53
|
+
const targetColor = data32[startPos];
|
|
54
|
+
if (targetColor === uint32Color) return;
|
|
55
|
+
const stack = [];
|
|
56
|
+
const firstSpan = fillLine(startX, startY, 1);
|
|
57
|
+
if (firstSpan) stack.push({ ...firstSpan, dy: 1 });
|
|
58
|
+
const secondSpan = fillLine(startX, startY - 1, -1);
|
|
59
|
+
if (secondSpan) stack.push({ ...secondSpan, dy: -1 });
|
|
55
60
|
while (stack.length) {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
const { y, left, right, dy } = stack.pop();
|
|
62
|
+
const ny = y + dy;
|
|
63
|
+
if (ny < 0 || ny >= h) continue;
|
|
64
|
+
let x = left;
|
|
65
|
+
while (x <= right) {
|
|
66
|
+
while (x <= right && data32[ny * w + x] !== targetColor) x++;
|
|
67
|
+
if (x > right) break;
|
|
68
|
+
const spanLeft = x;
|
|
69
|
+
const newSpan = fillLine(spanLeft, ny, dy);
|
|
70
|
+
if (newSpan) stack.push(newSpan);
|
|
71
|
+
x = newSpan ? newSpan.right + 1 : spanLeft + 1;
|
|
59
72
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
73
|
+
}
|
|
74
|
+
ctx.putImageData(img, 0, 0);
|
|
75
|
+
function fillLine(x, y, dy) {
|
|
76
|
+
let left = x;
|
|
77
|
+
while (left > 0 && data32[y * w + left - 1] === targetColor) left--;
|
|
78
|
+
let right = x;
|
|
79
|
+
while (right < w - 1 && data32[y * w + right + 1] === targetColor) right++;
|
|
80
|
+
for (let i = left; i <= right; i++) data32[y * w + i] = uint32Color;
|
|
81
|
+
return { y, left, right, dy };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const transformBorderRadiusSizeValue = (canvas, value, pixelSize) => {
|
|
85
|
+
if (k(value)) {
|
|
86
|
+
return Math.max(value, pixelSize);
|
|
87
|
+
} else {
|
|
88
|
+
return Math.max(canvas.height * parseFloat(value) / 100, pixelSize);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const getRadiusFromValue = (canvas, value, pixelSize) => {
|
|
92
|
+
if (!value) return fillArr(pixelSize, 4);
|
|
93
|
+
if (!$(value)) {
|
|
94
|
+
return fillArr(transformBorderRadiusSizeValue(canvas, value, pixelSize), 4);
|
|
95
|
+
}
|
|
96
|
+
switch (value.length) {
|
|
97
|
+
case 1:
|
|
98
|
+
return fillArr(transformBorderRadiusSizeValue(canvas, value[0], pixelSize), 4);
|
|
99
|
+
case 2: {
|
|
100
|
+
const tl = transformBorderRadiusSizeValue(canvas, value[0], pixelSize);
|
|
101
|
+
const tr = transformBorderRadiusSizeValue(canvas, value[1], pixelSize);
|
|
102
|
+
return [tl, tr, tl, tr];
|
|
64
103
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
104
|
+
case 3: {
|
|
105
|
+
const tl = transformBorderRadiusSizeValue(canvas, value[0], pixelSize);
|
|
106
|
+
const br = transformBorderRadiusSizeValue(canvas, value[2], pixelSize);
|
|
107
|
+
const rest = transformBorderRadiusSizeValue(canvas, value[1], pixelSize);
|
|
108
|
+
return [tl, rest, br, rest];
|
|
109
|
+
}
|
|
110
|
+
default:
|
|
111
|
+
return value.map((e) => transformBorderRadiusSizeValue(canvas, e, pixelSize));
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const getInnerRadius = (canvas, value, pixelSize, first, last) => {
|
|
115
|
+
if (!value) return fillArr(pixelSize, 4);
|
|
116
|
+
if (!$(value)) {
|
|
117
|
+
const v = transformBorderRadiusSizeValue(canvas, value, pixelSize);
|
|
118
|
+
if (last) return [pixelSize, v, v, pixelSize];
|
|
119
|
+
if (first) return [v, pixelSize, pixelSize, v];
|
|
120
|
+
return fillArr(pixelSize, 4);
|
|
73
121
|
}
|
|
74
|
-
|
|
122
|
+
switch (value.length) {
|
|
123
|
+
case 1:
|
|
124
|
+
const v = transformBorderRadiusSizeValue(canvas, value[0], pixelSize);
|
|
125
|
+
if (last) return [pixelSize, v, v, pixelSize];
|
|
126
|
+
if (first) return [v, pixelSize, pixelSize, v];
|
|
127
|
+
return fillArr(pixelSize, 4);
|
|
128
|
+
case 2: {
|
|
129
|
+
const tl = transformBorderRadiusSizeValue(canvas, value[0], pixelSize);
|
|
130
|
+
const tr = transformBorderRadiusSizeValue(canvas, value[1], pixelSize);
|
|
131
|
+
if (last) return [pixelSize, tr, tr, pixelSize];
|
|
132
|
+
if (first) return [tl, pixelSize, pixelSize, tl];
|
|
133
|
+
return fillArr(pixelSize, 4);
|
|
134
|
+
}
|
|
135
|
+
case 3: {
|
|
136
|
+
const tl = transformBorderRadiusSizeValue(canvas, value[0], pixelSize);
|
|
137
|
+
const br = transformBorderRadiusSizeValue(canvas, value[2], pixelSize);
|
|
138
|
+
const rest = transformBorderRadiusSizeValue(canvas, value[1], pixelSize);
|
|
139
|
+
if (last) return [pixelSize, rest, br, pixelSize];
|
|
140
|
+
if (first) return [tl, pixelSize, pixelSize, rest];
|
|
141
|
+
return fillArr(pixelSize, 4);
|
|
142
|
+
}
|
|
143
|
+
default:
|
|
144
|
+
if (last)
|
|
145
|
+
return [
|
|
146
|
+
pixelSize,
|
|
147
|
+
transformBorderRadiusSizeValue(canvas, value[1], pixelSize),
|
|
148
|
+
transformBorderRadiusSizeValue(canvas, value[2], pixelSize),
|
|
149
|
+
pixelSize
|
|
150
|
+
];
|
|
151
|
+
if (first)
|
|
152
|
+
return [
|
|
153
|
+
transformBorderRadiusSizeValue(canvas, value[0], pixelSize),
|
|
154
|
+
pixelSize,
|
|
155
|
+
pixelSize,
|
|
156
|
+
transformBorderRadiusSizeValue(canvas, value[3], pixelSize)
|
|
157
|
+
];
|
|
158
|
+
return fillArr(pixelSize, 4);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const getBorderRadius = (canvas, pixelSize, borderRadius, shape, size = "medium", inner = false, first = false, last = false) => {
|
|
162
|
+
if (!inBrowser()) {
|
|
163
|
+
return fillArr(pixelSize, 4);
|
|
164
|
+
}
|
|
165
|
+
if (!inner) {
|
|
166
|
+
if (borderRadius) {
|
|
167
|
+
return getRadiusFromValue(canvas, borderRadius, pixelSize);
|
|
168
|
+
}
|
|
169
|
+
switch (shape) {
|
|
170
|
+
case "round":
|
|
171
|
+
case "circle":
|
|
172
|
+
let radius = transformBorderRadiusSizeValue(canvas, "50%", pixelSize);
|
|
173
|
+
radius = Math.max(Math.round(radius / pixelSize) * pixelSize, pixelSize);
|
|
174
|
+
return fillArr(radius, 4);
|
|
175
|
+
default:
|
|
176
|
+
return fillArr(pixelSize, 4);
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
if (borderRadius) {
|
|
180
|
+
return getInnerRadius(canvas, borderRadius, pixelSize, first, last);
|
|
181
|
+
}
|
|
182
|
+
const globalComputedStyle = getComputedStyle(document.documentElement);
|
|
183
|
+
const height = parseInt(globalComputedStyle.getPropertyValue(`--px-${size}-base-size`)) + 2 * pixelSize;
|
|
184
|
+
switch (shape) {
|
|
185
|
+
case "round":
|
|
186
|
+
let radius = transformBorderRadiusSizeValue(canvas, "50%", pixelSize);
|
|
187
|
+
radius = clamp(radius, pixelSize, height / 2);
|
|
188
|
+
radius = Math.max(Math.round(radius / pixelSize) * pixelSize, pixelSize);
|
|
189
|
+
const roundArr = fillArr(radius, 4);
|
|
190
|
+
if (last) return roundArr.map((e, i) => i < 1 || i > 2 ? pixelSize : e);
|
|
191
|
+
if (first) return roundArr.map((e, i) => i > 0 && i < 3 ? pixelSize : e);
|
|
192
|
+
return fillArr(pixelSize, 4);
|
|
193
|
+
default:
|
|
194
|
+
return fillArr(pixelSize, 4);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
function calcWhenLeaveBaseline(pixelSize, borderRadius) {
|
|
199
|
+
return Math.ceil(
|
|
200
|
+
(-6 + Math.sqrt(36 - 48 * pixelSize + 32 * pixelSize * borderRadius)) / (8 * pixelSize)
|
|
201
|
+
) * pixelSize;
|
|
75
202
|
}
|
|
203
|
+
const calcPixelSize = () => {
|
|
204
|
+
if (!inBrowser()) {
|
|
205
|
+
return 4;
|
|
206
|
+
}
|
|
207
|
+
const globalComputedStyle = getComputedStyle(document.documentElement);
|
|
208
|
+
const pixelSize = parseInt(globalComputedStyle.getPropertyValue("--px-bit"));
|
|
209
|
+
return pixelSize;
|
|
210
|
+
};
|
|
211
|
+
const calcBorderCornerCenter = (borderRadius, width, height, pixelSize, paddingX = 0, paddingY = 0) => {
|
|
212
|
+
return [
|
|
213
|
+
[borderRadius[0], borderRadius[0]],
|
|
214
|
+
[width - paddingX - borderRadius[1] - pixelSize, borderRadius[1]],
|
|
215
|
+
[
|
|
216
|
+
width - paddingX - borderRadius[2] - pixelSize,
|
|
217
|
+
height - paddingY - borderRadius[2] - pixelSize
|
|
218
|
+
],
|
|
219
|
+
[borderRadius[3], height - paddingY - borderRadius[3] - pixelSize]
|
|
220
|
+
];
|
|
221
|
+
};
|
|
222
|
+
const canvasPreprocess = (wrapperRef, canvasRef) => {
|
|
223
|
+
if (!canvasRef.value || !wrapperRef.value) return;
|
|
224
|
+
const ctx = canvasRef.value.getContext("2d", { willReadFrequently: true });
|
|
225
|
+
if (!ctx) return;
|
|
226
|
+
ctx.imageSmoothingEnabled = false;
|
|
227
|
+
const rect = wrapperRef.value.getBoundingClientRect();
|
|
228
|
+
if (rect.width <= 0 || rect.height <= 0) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
canvasRef.value.width = rect.width;
|
|
232
|
+
canvasRef.value.height = rect.height;
|
|
233
|
+
return {
|
|
234
|
+
ctx,
|
|
235
|
+
width: canvasRef.value.width,
|
|
236
|
+
height: canvasRef.value.height,
|
|
237
|
+
rect,
|
|
238
|
+
canvas: canvasRef.value
|
|
239
|
+
};
|
|
240
|
+
};
|
|
76
241
|
export {
|
|
242
|
+
canvasPreprocess as a,
|
|
243
|
+
calcBorderCornerCenter as b,
|
|
244
|
+
calcPixelSize as c,
|
|
77
245
|
drawCircle as d,
|
|
78
|
-
|
|
246
|
+
calcWhenLeaveBaseline as e,
|
|
247
|
+
floodFill as f,
|
|
248
|
+
getBorderRadius as g
|
|
79
249
|
};
|
|
@@ -17,6 +17,7 @@ export declare const isComponentVNode: (vn: VNode, _?: VNodeTypes) => _ is Compo
|
|
|
17
17
|
export declare const hasTextChildren: (child: VNode, _?: VNode["children"]) => _ is string;
|
|
18
18
|
export declare const hasArrayChildren: (vn: VNode, _?: VNode["children"]) => _ is VNode[];
|
|
19
19
|
export declare const hasSlotsChildren: (vn: VNode, _: VNode["children"]) => _ is Slots;
|
|
20
|
+
export declare const isTextVNode: (vn: VNode) => boolean;
|
|
20
21
|
export declare const flattenVNodes: (children: VNode[] | undefined) => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
21
22
|
[key: string]: any;
|
|
22
23
|
}>[];
|
package/es/share/util/render.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { $ } from "../../aside/index.js";
|
|
2
|
+
import { Text } from "vue";
|
|
2
3
|
const isHtmlElementVNode = (vn, _) => {
|
|
3
4
|
return Boolean(
|
|
4
5
|
vn && vn.shapeFlag & 1
|
|
@@ -12,7 +13,10 @@ const isComponentVNode = (vn, _) => {
|
|
|
12
13
|
);
|
|
13
14
|
};
|
|
14
15
|
const hasTextChildren = (child, _) => {
|
|
15
|
-
return Boolean(
|
|
16
|
+
return Boolean(
|
|
17
|
+
child && child.shapeFlag & 8
|
|
18
|
+
/* TEXT_CHILDREN */
|
|
19
|
+
);
|
|
16
20
|
};
|
|
17
21
|
const hasArrayChildren = (vn, _) => {
|
|
18
22
|
return Boolean(
|
|
@@ -26,6 +30,9 @@ const hasSlotsChildren = (vn, _) => {
|
|
|
26
30
|
/* SLOTS_CHILDREN */
|
|
27
31
|
);
|
|
28
32
|
};
|
|
33
|
+
const isTextVNode = (vn) => {
|
|
34
|
+
return Boolean(vn.type === Text);
|
|
35
|
+
};
|
|
29
36
|
const flattenVNodes = (children) => {
|
|
30
37
|
var _a, _b;
|
|
31
38
|
const results = [];
|
|
@@ -43,5 +50,6 @@ const flattenVNodes = (children) => {
|
|
|
43
50
|
return results;
|
|
44
51
|
};
|
|
45
52
|
export {
|
|
46
|
-
flattenVNodes as f
|
|
53
|
+
flattenVNodes as f,
|
|
54
|
+
isTextVNode as i
|
|
47
55
|
};
|
package/es/share/util/theme.js
CHANGED
|
@@ -2,6 +2,8 @@ import { p } from "../../aside/index.js";
|
|
|
2
2
|
import { p as parseColor, a as generatePalette, r as rgbaColor2string } from "./color.js";
|
|
3
3
|
import { t as throwError } from "./console.js";
|
|
4
4
|
import { i as inBrowser } from "./env.js";
|
|
5
|
+
import { E as EventBus } from "./event-bus.js";
|
|
6
|
+
import { a as GLOBAL_CSS_VAR_CHANGE } from "../const/event-bus-key.js";
|
|
5
7
|
const setThemeColor = (theme, color) => {
|
|
6
8
|
var _a, _b;
|
|
7
9
|
if (!inBrowser()) {
|
|
@@ -13,18 +15,34 @@ const setThemeColor = (theme, color) => {
|
|
|
13
15
|
};
|
|
14
16
|
if (p(color)) {
|
|
15
17
|
const rgbaColor = parseColor(color);
|
|
16
|
-
colorList.light = generatePalette(
|
|
18
|
+
colorList.light = generatePalette(
|
|
19
|
+
rgbaColor.r,
|
|
20
|
+
rgbaColor.g,
|
|
21
|
+
rgbaColor.b,
|
|
22
|
+
rgbaColor.a,
|
|
23
|
+
false
|
|
24
|
+
).map((color2) => {
|
|
17
25
|
return rgbaColor2string(color2);
|
|
18
26
|
});
|
|
19
|
-
colorList.dark = generatePalette(
|
|
27
|
+
colorList.dark = generatePalette(
|
|
28
|
+
rgbaColor.r,
|
|
29
|
+
rgbaColor.g,
|
|
30
|
+
rgbaColor.b,
|
|
31
|
+
rgbaColor.a,
|
|
32
|
+
true
|
|
33
|
+
).map((color2) => {
|
|
20
34
|
return rgbaColor2string(color2);
|
|
21
35
|
});
|
|
22
36
|
} else {
|
|
23
37
|
if (((_a = color.light) == null ? void 0 : _a.length) && color.light.length !== 10) {
|
|
24
|
-
throwError(
|
|
38
|
+
return throwError(
|
|
39
|
+
`The length of color.light does not match the required number of CSS color palette (10).`
|
|
40
|
+
);
|
|
25
41
|
}
|
|
26
42
|
if (((_b = color.dark) == null ? void 0 : _b.length) && color.dark.length !== 10) {
|
|
27
|
-
throwError(
|
|
43
|
+
return throwError(
|
|
44
|
+
`The length of color.dark does not match the required number of CSS color palette (10).`
|
|
45
|
+
);
|
|
28
46
|
}
|
|
29
47
|
colorList.light = color.light || [];
|
|
30
48
|
colorList.dark = color.dark || [];
|
|
@@ -35,6 +53,7 @@ const setThemeColor = (theme, color) => {
|
|
|
35
53
|
colorList.dark.forEach((item, index) => {
|
|
36
54
|
document.documentElement.style.setProperty(`--px-${theme}-dark-custom-${index + 1}`, item);
|
|
37
55
|
});
|
|
56
|
+
EventBus.emit(GLOBAL_CSS_VAR_CHANGE);
|
|
38
57
|
};
|
|
39
58
|
export {
|
|
40
59
|
setThemeColor as s
|
package/es/space/css.js
CHANGED
package/es/space/index.css
CHANGED
package/es/space/index.js
CHANGED
|
@@ -28,7 +28,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
setup(__props) {
|
|
31
|
-
var _a;
|
|
32
31
|
const props = __props;
|
|
33
32
|
const alignComputed = computed(() => {
|
|
34
33
|
if (props.align) {
|
|
@@ -37,7 +36,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
37
36
|
return props.direction === "horizontal" ? "center" : "stretch";
|
|
38
37
|
});
|
|
39
38
|
const slots = useSlots();
|
|
40
|
-
const children = flattenVNodes(((_a = slots.default) == null ? void 0 : _a.call(slots)) || []);
|
|
41
39
|
const marginComputed = computed(() => {
|
|
42
40
|
if (!props.margin || props.margin === "small" || props.margin === "medium" || props.margin === "large") {
|
|
43
41
|
return;
|
|
@@ -58,6 +56,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
58
56
|
}
|
|
59
57
|
});
|
|
60
58
|
return () => {
|
|
59
|
+
var _a;
|
|
60
|
+
const children = flattenVNodes(((_a = slots.default) == null ? void 0 : _a.call(slots)) || []);
|
|
61
61
|
return createVNode("div", {
|
|
62
62
|
"class": {
|
|
63
63
|
pixelium: true,
|
package/es/spin/css.js
ADDED