@pixelium/web-vue 0.0.2 → 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 -5852
- 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 -672
- 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
package/es/share/util/common.js
CHANGED
|
@@ -1,71 +1,133 @@
|
|
|
1
|
-
import { d } from "../../
|
|
2
|
-
import {
|
|
3
|
-
const clamp = (x, min, max) => Math.max(min, Math.min(max, x));
|
|
1
|
+
import { A as d, P as ke } from "../../vendor.js";
|
|
2
|
+
import { i as GROUP_OPTION_TYPE } from "../const/index.js";
|
|
4
3
|
const fillArr = (val, size) => Array(size).fill(val);
|
|
5
4
|
const defaultFilter = (keyword, list = []) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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;
|
|
5
|
+
if (!keyword) return [...list];
|
|
6
|
+
const keyword4Search = keyword.toLowerCase();
|
|
7
|
+
const len = list.length;
|
|
8
|
+
const ans = [];
|
|
9
|
+
for (let i = 0; i < len; i++) {
|
|
10
|
+
const currentElement = list[i];
|
|
11
|
+
if (d(currentElement)) {
|
|
12
|
+
if ("type" in currentElement && currentElement.type === "group") {
|
|
13
|
+
const children = defaultFilter(keyword, currentElement.children);
|
|
14
|
+
if (children.length) ans.push({
|
|
15
|
+
...currentElement,
|
|
16
|
+
children
|
|
17
|
+
});
|
|
18
|
+
} else if (currentElement.label.toLowerCase().includes(keyword4Search)) ans.push(currentElement);
|
|
19
|
+
} else if (currentElement.toLowerCase().includes(keyword4Search)) ans.push(currentElement);
|
|
20
|
+
}
|
|
21
|
+
return ans;
|
|
35
22
|
};
|
|
36
23
|
const findSameOption = (keyword, list, checkLabel = false) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
ans.push(currentElement);
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return ans;
|
|
24
|
+
if (!keyword) return [];
|
|
25
|
+
const len = list.length;
|
|
26
|
+
const ans = [];
|
|
27
|
+
for (let i = 0; i < len; i++) {
|
|
28
|
+
const currentElement = list[i];
|
|
29
|
+
if (d(currentElement)) {
|
|
30
|
+
if ("type" in currentElement && currentElement.type === "group") {
|
|
31
|
+
const options = findSameOption(keyword, currentElement.children, checkLabel);
|
|
32
|
+
if (options.length) {
|
|
33
|
+
ans.push(options[0], currentElement);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
} else if (checkLabel && currentElement.label === keyword || currentElement.value === keyword) {
|
|
37
|
+
ans.push(currentElement);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
} else if (currentElement === keyword) {
|
|
41
|
+
ans.push(currentElement);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return ans;
|
|
65
46
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
47
|
+
function offsetOutward(center, points, offset) {
|
|
48
|
+
const [cx, cy] = center;
|
|
49
|
+
return points.map(([x, y]) => {
|
|
50
|
+
const dx = x - cx;
|
|
51
|
+
const dy = y - cy;
|
|
52
|
+
const xOffset = dx > 0 ? offset : dx < 0 ? -offset : 0;
|
|
53
|
+
const yOffset = dy > 0 ? offset : dy < 0 ? -offset : 0;
|
|
54
|
+
return [x + xOffset, y + yOffset];
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function isUrl(url, options = {}) {
|
|
58
|
+
if (!url || typeof url !== "string") return false;
|
|
59
|
+
const { allowWithoutProtocol = true, allowIpv6 = true } = options;
|
|
60
|
+
if (url.includes(" ")) return false;
|
|
61
|
+
const [protocol, rest] = extractProtocol(url);
|
|
62
|
+
if (!protocol && !allowWithoutProtocol) return false;
|
|
63
|
+
const hostPortPart = rest.split(/[/?#]/)[0];
|
|
64
|
+
if (!hostPortPart) return false;
|
|
65
|
+
const { host, port } = parseHostAndPort(hostPortPart) || {};
|
|
66
|
+
if (!host) return false;
|
|
67
|
+
let isHostValid = false;
|
|
68
|
+
if (isIPv6Host(host)) {
|
|
69
|
+
if (!allowIpv6) return false;
|
|
70
|
+
isHostValid = isValidIPv6(host);
|
|
71
|
+
} else isHostValid = isValidIPv4(host) || isValidDomain(host);
|
|
72
|
+
if (!isHostValid) return false;
|
|
73
|
+
if (port && !isValidPort(port)) return false;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
function extractProtocol(url) {
|
|
77
|
+
const protocolMatch = url.match(/^([a-zA-Z0-9+.-]+):\/\//);
|
|
78
|
+
if (protocolMatch) return [protocolMatch[1], url.slice(protocolMatch[0].length)];
|
|
79
|
+
return [null, url];
|
|
80
|
+
}
|
|
81
|
+
function parseHostAndPort(hostPortPart) {
|
|
82
|
+
if (hostPortPart.startsWith("[")) {
|
|
83
|
+
const ipv6Match = hostPortPart.match(/^\[(.*?)\](?::(\d+))?$/);
|
|
84
|
+
if (!ipv6Match) return null;
|
|
85
|
+
return {
|
|
86
|
+
host: ipv6Match[1],
|
|
87
|
+
port: ipv6Match[2] || void 0
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const parts = hostPortPart.split(":");
|
|
91
|
+
if (parts.length > 2) return null;
|
|
92
|
+
return {
|
|
93
|
+
host: parts[0],
|
|
94
|
+
port: parts[1] || void 0
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function isIPv6Host(host) {
|
|
98
|
+
return host.includes(":");
|
|
99
|
+
}
|
|
100
|
+
function isValidIPv4(ip) {
|
|
101
|
+
const parts = ip.split(".");
|
|
102
|
+
if (parts.length !== 4) return false;
|
|
103
|
+
return parts.every((part) => {
|
|
104
|
+
if (!/^\d+$/.test(part) || part.length > 1 && part[0] === "0") return false;
|
|
105
|
+
const num = Number(part);
|
|
106
|
+
return num >= 0 && num <= 255;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function isValidIPv6(ip) {
|
|
110
|
+
if (!/^[0-9a-fA-F:]+$/.test(ip)) return false;
|
|
111
|
+
if ((ip.match(/::/g) || []).length > 1) return false;
|
|
112
|
+
let groups = ip.split(":").filter((g) => g !== "");
|
|
113
|
+
if (8 - groups.length < 0) return false;
|
|
114
|
+
return groups.every((group) => group.length >= 1 && group.length <= 4);
|
|
115
|
+
}
|
|
116
|
+
function isValidDomain(domain) {
|
|
117
|
+
if (domain === "localhost") return true;
|
|
118
|
+
if (domain.includes("..") || domain.startsWith(".") || domain.endsWith(".")) return false;
|
|
119
|
+
const parts = domain.split(".");
|
|
120
|
+
if (parts.length < 2) return false;
|
|
121
|
+
if (parts[parts.length - 1].length < 2) return false;
|
|
122
|
+
return parts.every((part) => {
|
|
123
|
+
return part.length > 0 && !part.startsWith("-") && !part.endsWith("-") && /^[a-zA-Z0-9-]+$/.test(part);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function isValidPort(port) {
|
|
127
|
+
const portNum = Number(port);
|
|
128
|
+
return !isNaN(portNum) && portNum >= 1 && portNum <= 65535;
|
|
129
|
+
}
|
|
130
|
+
const fixedNumber = (value, precision) => {
|
|
131
|
+
return parseFloat(value.toFixed(ke(Math.round(precision), 0, 100)));
|
|
71
132
|
};
|
|
133
|
+
export { isUrl as a, fixedNumber as i, fillArr as n, offsetOutward as o, findSameOption as r, defaultFilter as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare function logInfo(
|
|
2
|
-
export declare function logWarn(
|
|
3
|
-
export declare function logError(
|
|
1
|
+
export declare function logInfo(message: any, showInProd?: boolean): void;
|
|
2
|
+
export declare function logWarn(message: any, showInProd?: boolean): void;
|
|
3
|
+
export declare function logError(message: any, showInProd?: boolean): void;
|
|
4
4
|
export declare function throwError(message: string): void;
|
|
5
5
|
export declare function createError(message: string): Error;
|
package/es/share/util/console.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var isNotProdMode = typeof process !== "undefined" && process.env.NODE_ENV !== "production";
|
|
2
|
+
var projectName = "Pixelium";
|
|
3
|
+
function logWarn(message, showInProd = false) {
|
|
4
|
+
if (isNotProdMode || showInProd) console.warn(`[${projectName}]`, message);
|
|
5
|
+
}
|
|
4
6
|
function throwError(message) {
|
|
5
|
-
|
|
7
|
+
throw new Error(`[${projectName}] ${message}`);
|
|
8
|
+
}
|
|
9
|
+
function createError(message) {
|
|
10
|
+
return /* @__PURE__ */ new Error(`[${projectName}] ${message}`);
|
|
6
11
|
}
|
|
7
|
-
export {
|
|
8
|
-
throwError as t
|
|
9
|
-
};
|
|
12
|
+
export { logWarn as n, throwError as r, createError as t };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function checkIntersection(target: HTMLElement, root?: HTMLElement): {
|
|
2
|
+
hasIntersection: boolean;
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
};
|
|
6
|
+
interface ZoomOptions {
|
|
7
|
+
maxWidth?: number;
|
|
8
|
+
maxHeight?: number;
|
|
9
|
+
margin?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function calculateZoomedSize(originalImg: HTMLImageElement, options?: ZoomOptions): {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
left: number;
|
|
15
|
+
top: number;
|
|
16
|
+
};
|
|
17
|
+
export declare const checkMouseInsideElementFromEvent: (el: HTMLElement | SVGElement, e: MouseEvent | TouchEvent) => boolean;
|
|
18
|
+
export declare function imageDataToDataURL(imageData: ImageData): string;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { w as Qn } from "../../vendor.js";
|
|
2
|
+
import { t as createError } from "./console.js";
|
|
3
|
+
function checkIntersection(target, root) {
|
|
4
|
+
if (window.getComputedStyle(target).display === "none") return {
|
|
5
|
+
hasIntersection: false,
|
|
6
|
+
x: Infinity,
|
|
7
|
+
y: Infinity
|
|
8
|
+
};
|
|
9
|
+
let isViewport = false;
|
|
10
|
+
if (!root) isViewport = true;
|
|
11
|
+
const rootRect = isViewport ? {
|
|
12
|
+
left: 0,
|
|
13
|
+
top: 0,
|
|
14
|
+
right: window.innerWidth,
|
|
15
|
+
bottom: window.innerHeight
|
|
16
|
+
} : root.getBoundingClientRect();
|
|
17
|
+
const targetRect = target.getBoundingClientRect();
|
|
18
|
+
const hasXIntersection = targetRect.left <= rootRect.right && targetRect.right >= rootRect.left;
|
|
19
|
+
const hasYIntersection = targetRect.top <= rootRect.bottom && targetRect.bottom >= rootRect.top;
|
|
20
|
+
const hasIntersection = hasXIntersection && hasYIntersection;
|
|
21
|
+
let xDistance;
|
|
22
|
+
if (hasXIntersection) xDistance = 0;
|
|
23
|
+
else if (targetRect.right < rootRect.left) xDistance = rootRect.left - targetRect.right;
|
|
24
|
+
else xDistance = targetRect.left - rootRect.right;
|
|
25
|
+
let yDistance;
|
|
26
|
+
if (hasYIntersection) yDistance = 0;
|
|
27
|
+
else if (targetRect.bottom < rootRect.top) yDistance = rootRect.top - targetRect.bottom;
|
|
28
|
+
else yDistance = targetRect.top - rootRect.bottom;
|
|
29
|
+
xDistance = Math.max(0, xDistance);
|
|
30
|
+
yDistance = Math.max(0, yDistance);
|
|
31
|
+
return {
|
|
32
|
+
hasIntersection,
|
|
33
|
+
x: xDistance,
|
|
34
|
+
y: yDistance
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function calculateZoomedSize(originalImg, options) {
|
|
38
|
+
const currentOptions = Qn(options, {
|
|
39
|
+
margin: 32,
|
|
40
|
+
maxWidth: Infinity,
|
|
41
|
+
maxHeight: Infinity
|
|
42
|
+
});
|
|
43
|
+
const viewportWidth = window.innerWidth;
|
|
44
|
+
const viewportHeight = window.innerHeight;
|
|
45
|
+
const finalViewportWidth = Math.min(viewportWidth - currentOptions.margin * 2, currentOptions.maxWidth);
|
|
46
|
+
const finalViewportHeight = Math.min(viewportHeight - currentOptions.margin * 2, currentOptions.maxHeight);
|
|
47
|
+
if (!originalImg.complete) return {
|
|
48
|
+
width: 0,
|
|
49
|
+
height: 0,
|
|
50
|
+
left: finalViewportWidth / 2,
|
|
51
|
+
top: finalViewportHeight / 2
|
|
52
|
+
};
|
|
53
|
+
const naturalWidth = originalImg.naturalWidth || finalViewportWidth;
|
|
54
|
+
const naturalHeight = originalImg.naturalHeight || finalViewportHeight;
|
|
55
|
+
const aspectRatio = originalImg.naturalWidth / originalImg.naturalHeight;
|
|
56
|
+
const scaleX = Math.min(naturalWidth, finalViewportWidth) / naturalWidth;
|
|
57
|
+
const scaleY = Math.min(naturalHeight, finalViewportHeight) / naturalHeight;
|
|
58
|
+
const finalHeight = Math.min(scaleX, scaleY) * naturalHeight;
|
|
59
|
+
const finalWidth = finalHeight * aspectRatio;
|
|
60
|
+
return {
|
|
61
|
+
width: finalWidth,
|
|
62
|
+
height: finalHeight,
|
|
63
|
+
left: finalViewportWidth / 2 - finalWidth / 2 + currentOptions.margin,
|
|
64
|
+
top: finalViewportHeight / 2 - finalHeight / 2 + currentOptions.margin
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const checkMouseInsideElementFromEvent = (el, e) => {
|
|
68
|
+
const rect = el.getBoundingClientRect();
|
|
69
|
+
let clientX, clientY;
|
|
70
|
+
if (e instanceof MouseEvent) {
|
|
71
|
+
clientX = e.clientX;
|
|
72
|
+
clientY = e.clientY;
|
|
73
|
+
} else {
|
|
74
|
+
clientX = e.touches[0].clientX;
|
|
75
|
+
clientY = e.touches[0].clientY;
|
|
76
|
+
}
|
|
77
|
+
return clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom;
|
|
78
|
+
};
|
|
79
|
+
function imageDataToDataURL(imageData) {
|
|
80
|
+
const canvas = document.createElement("canvas");
|
|
81
|
+
const ctx = canvas.getContext("2d");
|
|
82
|
+
if (!ctx) throw createError("Cannot get Canvas context");
|
|
83
|
+
canvas.width = imageData.width;
|
|
84
|
+
canvas.height = imageData.height;
|
|
85
|
+
ctx.putImageData(imageData, 0, 0);
|
|
86
|
+
return canvas.toDataURL("image/png");
|
|
87
|
+
}
|
|
88
|
+
export { imageDataToDataURL as i, checkIntersection as n, checkMouseInsideElementFromEvent as r, calculateZoomedSize as t };
|
package/es/share/util/env.d.ts
CHANGED
package/es/share/util/env.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const inVitest = () => {
|
|
2
|
+
return typeof process === "object" && typeof process.env === "object" && process.env.VITEST === "true";
|
|
3
3
|
};
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const inBrowser = () => {
|
|
5
|
+
return typeof window !== "undefined";
|
|
6
6
|
};
|
|
7
|
+
export { inVitest as n, inBrowser as t };
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
};
|
|
1
|
+
import { m as mitt_default } from "../../vendor.js";
|
|
2
|
+
const EventBus = mitt_default();
|
|
3
|
+
export { EventBus as t };
|
|
@@ -1,35 +1,31 @@
|
|
|
1
1
|
function createLRU(max) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
};
|
|
2
|
+
if (!Number.isInteger(max) || max <= 0) throw new RangeError("max must be a positive integer");
|
|
3
|
+
const cache = /* @__PURE__ */ new Map();
|
|
4
|
+
return {
|
|
5
|
+
get(key) {
|
|
6
|
+
const val = cache.get(key);
|
|
7
|
+
if (val === void 0) return void 0;
|
|
8
|
+
cache.delete(key);
|
|
9
|
+
cache.set(key, val);
|
|
10
|
+
return val;
|
|
11
|
+
},
|
|
12
|
+
set(key, value) {
|
|
13
|
+
if (cache.has(key)) cache.delete(key);
|
|
14
|
+
else if (cache.size >= max) cache.delete(cache.keys().next().value);
|
|
15
|
+
cache.set(key, value);
|
|
16
|
+
},
|
|
17
|
+
delete(key) {
|
|
18
|
+
return cache.delete(key);
|
|
19
|
+
},
|
|
20
|
+
clear() {
|
|
21
|
+
cache.clear();
|
|
22
|
+
},
|
|
23
|
+
has(key) {
|
|
24
|
+
return cache.has(key);
|
|
25
|
+
},
|
|
26
|
+
get size() {
|
|
27
|
+
return cache.size;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
32
30
|
}
|
|
33
|
-
export {
|
|
34
|
-
createLRU as c
|
|
35
|
-
};
|
|
31
|
+
export { createLRU as t };
|
package/es/share/util/plot.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { NumberOrPercentage, RgbaColor } from '../type';
|
|
2
2
|
import type { ShallowRef } from 'vue';
|
|
3
|
+
export declare const roundToPixel: (coord: number, pixelSize: number) => number;
|
|
3
4
|
export declare function drawCircle(ctx: CanvasRenderingContext2D, centerX: number, centerY: number, radius: number, startRad: number | undefined, endRad: number | undefined, pixelSize: number): void;
|
|
5
|
+
export declare function drawSmoothCircle(ctx: CanvasRenderingContext2D, centerX: number, centerY: number, radius: number, startRad: number | undefined, endRad: number | undefined, pixelSize: number): void;
|
|
4
6
|
export type floodFillArgs = {
|
|
5
7
|
x: number;
|
|
6
8
|
y: number;
|
|
@@ -11,15 +13,18 @@ export type floodFillArgs = {
|
|
|
11
13
|
pixels: number[];
|
|
12
14
|
};
|
|
13
15
|
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: "
|
|
16
|
+
export declare const transformBorderRadiusSizeValue: (canvas: HTMLCanvasElement, value: NumberOrPercentage, pixelSize: number, direction?: "horizontal" | "vertical") => number;
|
|
17
|
+
export declare const getBorderRadius: (canvas: HTMLCanvasElement, pixelSize: number, borderRadius: NumberOrPercentage | NumberOrPercentage[] | undefined, shape: "rect" | "round" | "circle" | "square" | "default" | undefined, size?: "medium" | "small" | "large", inner?: boolean, first?: boolean, last?: boolean, direction?: "horizontal" | "vertical") => number[];
|
|
16
18
|
export declare function calcWhenLeaveBaseline(pixelSize: number, borderRadius: number): number;
|
|
17
19
|
export declare const calcPixelSize: () => number;
|
|
18
20
|
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
|
|
21
|
+
export declare const canvasPreprocess: (wrapperRef: ShallowRef<HTMLElement | null>, canvasRef: ShallowRef<HTMLCanvasElement | null>, paddingX?: number, paddingY?: number) => {
|
|
20
22
|
ctx: CanvasRenderingContext2D;
|
|
21
23
|
width: number;
|
|
22
24
|
height: number;
|
|
23
25
|
rect: DOMRect;
|
|
24
26
|
canvas: HTMLCanvasElement;
|
|
27
|
+
wrapper: HTMLElement;
|
|
25
28
|
} | undefined;
|
|
29
|
+
export declare function floodFillEdge(ctx: CanvasRenderingContext2D, startX: number, startY: number, fillColor: RgbaColor): [number, number][];
|
|
30
|
+
export declare function outerEdgePoints(ctx: CanvasRenderingContext2D): [number, number][];
|