@pixelium/web-vue 0.0.1-beta → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +5368 -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 +674 -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,192 @@
|
|
|
1
|
+
import type { NumberOrPercentage } from '../share/type';
|
|
2
|
+
import type { GroupOption, Option } from '../share/type';
|
|
3
|
+
export interface AutoCompleteOption extends Option<string> {
|
|
4
|
+
value: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface AutoCompleteGroupOption extends GroupOption {
|
|
8
|
+
label: string;
|
|
9
|
+
key: string | number | symbol;
|
|
10
|
+
children: (AutoCompleteOption | string)[];
|
|
11
|
+
}
|
|
12
|
+
export type AutoCompleteProps = {
|
|
13
|
+
/**
|
|
14
|
+
* @property {string | null} [modelValue]
|
|
15
|
+
* @version 0.0.2
|
|
16
|
+
*/
|
|
17
|
+
modelValue?: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* @property {string | null} [defaultValue]
|
|
20
|
+
* @version 0.0.2
|
|
21
|
+
*/
|
|
22
|
+
defaultValue?: string | null;
|
|
23
|
+
/**
|
|
24
|
+
* @property {string} [options]
|
|
25
|
+
* @version 0.0.2
|
|
26
|
+
*/
|
|
27
|
+
options?: (string | AutoCompleteOption | AutoCompleteGroupOption)[];
|
|
28
|
+
/**
|
|
29
|
+
* @property {string} [placeholder]
|
|
30
|
+
* @version 0.0.2
|
|
31
|
+
*/
|
|
32
|
+
placeholder?: string;
|
|
33
|
+
/**
|
|
34
|
+
* @property {boolean} [disabled=false]
|
|
35
|
+
* @version 0.0.2
|
|
36
|
+
*/
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* @property {boolean} [readonly=false]
|
|
40
|
+
* @version 0.0.2
|
|
41
|
+
*/
|
|
42
|
+
readonly?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* @property {boolean} [clearable=false]
|
|
45
|
+
* @version 0.0.2
|
|
46
|
+
*/
|
|
47
|
+
clearable?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* @property {boolean} [loading=false]
|
|
50
|
+
* @version 0.0.2
|
|
51
|
+
*/
|
|
52
|
+
loading?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* @property {boolean} [showPopoverEmpty=false]
|
|
55
|
+
* @version 0.0.2
|
|
56
|
+
*/
|
|
57
|
+
showPopoverEmpty?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* @property {(value: string, optionsFiltered: (string | AutoCompleteOption | AutoCompleteGroupOption)[]) => boolean} [shouldShowPopover]
|
|
60
|
+
* @version 0.0.2
|
|
61
|
+
*/
|
|
62
|
+
shouldShowPopover?: (value: string, optionsFiltered: (string | AutoCompleteOption | AutoCompleteGroupOption)[]) => boolean;
|
|
63
|
+
/**
|
|
64
|
+
* @property {(keyword: string, options: (string | AutoCompleteOption | AutoCompleteGroupOption)[]) => (string | AutoCompleteOption | AutoCompleteGroupOption)[]} [filter]
|
|
65
|
+
* @version 0.0.2
|
|
66
|
+
*/
|
|
67
|
+
filter?: (keyword: string, options: (string | AutoCompleteOption | AutoCompleteGroupOption)[]) => (string | AutoCompleteOption | AutoCompleteGroupOption)[];
|
|
68
|
+
/**
|
|
69
|
+
* @property {boolean} [append=false]
|
|
70
|
+
* @version 0.0.2
|
|
71
|
+
*/
|
|
72
|
+
append?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* @property {'medium' | 'large' | 'small'} [size='medium']
|
|
75
|
+
* @version 0.0.2
|
|
76
|
+
*/
|
|
77
|
+
size?: 'medium' | 'large' | 'small';
|
|
78
|
+
/**
|
|
79
|
+
* @property {'default' | 'round'} [shape='default']
|
|
80
|
+
* @version 0.0.2
|
|
81
|
+
*/
|
|
82
|
+
shape?: 'default' | 'round';
|
|
83
|
+
/**
|
|
84
|
+
* @property {NumberOrPercentage | NumberOrPercentage[]} [borderRadius]
|
|
85
|
+
* @version 0.0.2
|
|
86
|
+
*/
|
|
87
|
+
borderRadius?: NumberOrPercentage | NumberOrPercentage[];
|
|
88
|
+
/**
|
|
89
|
+
* @property {'success' | 'warning' | 'error' | 'normal'} [status='normal']
|
|
90
|
+
* @version 0.0.2
|
|
91
|
+
*/
|
|
92
|
+
status?: 'success' | 'warning' | 'error' | 'normal';
|
|
93
|
+
/**
|
|
94
|
+
* @property {boolean} [autofocus=false]
|
|
95
|
+
* @version 0.0.2
|
|
96
|
+
*/
|
|
97
|
+
autofocus?: boolean;
|
|
98
|
+
};
|
|
99
|
+
export type AutoCompleteEvents = {
|
|
100
|
+
/**
|
|
101
|
+
* @event input
|
|
102
|
+
* @param {string} value
|
|
103
|
+
* @param {Event} e
|
|
104
|
+
* @version 0.0.2
|
|
105
|
+
*/
|
|
106
|
+
input: [value: string, e: Event];
|
|
107
|
+
/**
|
|
108
|
+
* @event update:modelValue
|
|
109
|
+
* @param {string} value
|
|
110
|
+
* @version 0.0.2
|
|
111
|
+
*/
|
|
112
|
+
'update:modelValue': [value: string];
|
|
113
|
+
/**
|
|
114
|
+
* @event change
|
|
115
|
+
* @param {string} value
|
|
116
|
+
* @param {Event | undefined} e
|
|
117
|
+
* @version 0.0.2
|
|
118
|
+
*/
|
|
119
|
+
change: [value: string, e?: Event];
|
|
120
|
+
/**
|
|
121
|
+
* @event clear
|
|
122
|
+
* @param {string} value
|
|
123
|
+
* @version 0.0.2
|
|
124
|
+
*/
|
|
125
|
+
clear: [value: string];
|
|
126
|
+
/**
|
|
127
|
+
* @event blur
|
|
128
|
+
* @param {FocusEvent} e
|
|
129
|
+
* @version 0.0.2
|
|
130
|
+
*/
|
|
131
|
+
blur: [e: FocusEvent];
|
|
132
|
+
/**
|
|
133
|
+
* @event focus
|
|
134
|
+
* @param {FocusEvent} e
|
|
135
|
+
* @version 0.0.2
|
|
136
|
+
*/
|
|
137
|
+
focus: [e: FocusEvent];
|
|
138
|
+
/**
|
|
139
|
+
* @event select
|
|
140
|
+
* @param {string} value
|
|
141
|
+
* @param {string | AutoCompleteOption} option
|
|
142
|
+
* @param {MouseEvent} e
|
|
143
|
+
* @version 0.0.2
|
|
144
|
+
*/
|
|
145
|
+
select: [value: string, option: string | AutoCompleteOption, e: MouseEvent];
|
|
146
|
+
};
|
|
147
|
+
export type AutoCompleteSlots = {
|
|
148
|
+
/**
|
|
149
|
+
* @slot prefix
|
|
150
|
+
* @version 0.0.2
|
|
151
|
+
*/
|
|
152
|
+
prefix: {};
|
|
153
|
+
/**
|
|
154
|
+
* @slot suffix
|
|
155
|
+
* @version 0.0.2
|
|
156
|
+
*/
|
|
157
|
+
suffix: {};
|
|
158
|
+
/**
|
|
159
|
+
* @slot option
|
|
160
|
+
* @param {string | AutoCompleteOption} option
|
|
161
|
+
* @version 0.0.2
|
|
162
|
+
*/
|
|
163
|
+
option: {};
|
|
164
|
+
/**
|
|
165
|
+
* @slot group-label
|
|
166
|
+
* @param {AutoCompleteGroupOption} option
|
|
167
|
+
* @version 0.0.2
|
|
168
|
+
*/
|
|
169
|
+
'group-label': {};
|
|
170
|
+
};
|
|
171
|
+
export type AutoCompleteExpose = {
|
|
172
|
+
/**
|
|
173
|
+
* @property {() => void} focus
|
|
174
|
+
* @version 0.0.2
|
|
175
|
+
*/
|
|
176
|
+
focus: () => void;
|
|
177
|
+
/**
|
|
178
|
+
* @property {() => void} blur
|
|
179
|
+
* @version 0.0.2
|
|
180
|
+
*/
|
|
181
|
+
blur: () => void;
|
|
182
|
+
/**
|
|
183
|
+
* @property {() => void} clear
|
|
184
|
+
* @version 0.0.2
|
|
185
|
+
*/
|
|
186
|
+
clear: () => void;
|
|
187
|
+
/**
|
|
188
|
+
* @property {() => void} select
|
|
189
|
+
* @version 0.0.2
|
|
190
|
+
*/
|
|
191
|
+
select: () => void;
|
|
192
|
+
};
|
package/es/button/css.js
CHANGED
package/es/button/draw.d.ts
CHANGED
|
@@ -4,6 +4,5 @@ export declare function getBackgroundColor(disabled: boolean, loading: boolean,
|
|
|
4
4
|
export declare function getBorderColor(disabled: boolean, loading: boolean, type: ButtonProps['variant'], theme: ButtonProps['theme'], palette: RgbaColor[] | null, hoverFlag: boolean, activeFlag: boolean): RgbaColor;
|
|
5
5
|
export declare const drawBorder: (ctx: CanvasRenderingContext2D, width: number, height: number, center: [number, number][], borderRadius: number[], rad: [number, number][], borderColor: RgbaColor, pixelSize: number, type: ButtonProps["variant"], inner: boolean, first: boolean, last: boolean) => void;
|
|
6
6
|
export declare function getGradientColor(disabled: boolean, loading: boolean, theme: ButtonProps['theme'], palette: RgbaColor[] | null, hoverFlag: boolean, activeFlag: boolean): RgbaColor;
|
|
7
|
-
export declare const drawGradient: (ctx: CanvasRenderingContext2D, width: number, height: number, center: [number, number][], borderRadius: number[], rad: [number, number][], pixelSize: number, disabled: boolean, loading: boolean,
|
|
8
|
-
export declare const getBorderRadius: (canvas: HTMLCanvasElement, pixelSize: number, borderRadius: ButtonProps["borderRadius"], shape: ButtonProps["shape"], inner: boolean, first: boolean, last: boolean) => number[];
|
|
7
|
+
export declare const drawGradient: (ctx: CanvasRenderingContext2D, width: number, height: number, center: [number, number][], borderRadius: number[], rad: [number, number][], pixelSize: number, disabled: boolean, loading: boolean, theme: ButtonProps["theme"], palette: RgbaColor[] | null, inner: boolean, first: boolean, last: boolean, hoverFlag: boolean, activeFlag: boolean) => void;
|
|
9
8
|
export declare const getTextColorWithPalette: (palette: RgbaColor[] | null, type: ButtonProps["variant"], disabled: boolean, loading: boolean, hoverFlag: boolean, activeFlag: boolean) => string | undefined;
|
package/es/button/draw.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { $, k } from "../aside/index.js";
|
|
2
1
|
import { T as TRANSPARENT_RGBA_COLOR_OBJECT } from "../share/const/index.js";
|
|
3
2
|
import { r as rgbaColor2string, g as getGlobalThemeColor } from "../share/util/color.js";
|
|
4
|
-
import { d as drawCircle } from "../share/util/plot.js";
|
|
3
|
+
import { e as calcWhenLeaveBaseline, d as drawCircle } from "../share/util/plot.js";
|
|
5
4
|
function getBackgroundColor(disabled, loading, type, theme = "primary", palette, hoverFlag, activeFlag) {
|
|
6
5
|
if (palette) {
|
|
7
6
|
switch (type) {
|
|
@@ -79,7 +78,7 @@ function getBorderColor(disabled, loading, type, theme = "primary", palette, hov
|
|
|
79
78
|
if (hoverFlag && !loading) return palette[2];
|
|
80
79
|
return palette[1];
|
|
81
80
|
case "outline":
|
|
82
|
-
if (disabled) return palette[
|
|
81
|
+
if (disabled) return palette[0];
|
|
83
82
|
if (activeFlag) return palette[6];
|
|
84
83
|
if (hoverFlag && !loading) return palette[4];
|
|
85
84
|
return palette[5];
|
|
@@ -128,11 +127,19 @@ function getBorderColor(disabled, loading, type, theme = "primary", palette, hov
|
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
129
|
const drawBorder = (ctx, width, height, center, borderRadius, rad, borderColor, pixelSize, type, inner, first, last) => {
|
|
131
|
-
ctx.fillStyle =
|
|
130
|
+
ctx.fillStyle = rgbaColor2string(borderColor);
|
|
132
131
|
for (let i = 0; i < 4; i++) {
|
|
133
132
|
if (borderRadius[i] > pixelSize) {
|
|
134
133
|
if (i === 1 || i === 2 ? inner && (last || type === "text") || !inner : true) {
|
|
135
|
-
drawCircle(
|
|
134
|
+
drawCircle(
|
|
135
|
+
ctx,
|
|
136
|
+
center[i][0],
|
|
137
|
+
center[i][1],
|
|
138
|
+
borderRadius[i],
|
|
139
|
+
rad[i][0],
|
|
140
|
+
rad[i][1],
|
|
141
|
+
pixelSize
|
|
142
|
+
);
|
|
136
143
|
}
|
|
137
144
|
}
|
|
138
145
|
}
|
|
@@ -140,10 +147,20 @@ const drawBorder = (ctx, width, height, center, borderRadius, rad, borderColor,
|
|
|
140
147
|
ctx.fillRect(center[0][0], 0, center[1][0] - center[0][0] + pixelSize, pixelSize);
|
|
141
148
|
}
|
|
142
149
|
if (center[2][1] + pixelSize > center[1][1] && (inner && (last || type === "text") || !inner)) {
|
|
143
|
-
ctx.fillRect(
|
|
150
|
+
ctx.fillRect(
|
|
151
|
+
width - pixelSize,
|
|
152
|
+
center[1][1],
|
|
153
|
+
pixelSize,
|
|
154
|
+
center[2][1] - center[1][1] + pixelSize
|
|
155
|
+
);
|
|
144
156
|
}
|
|
145
157
|
if (center[3][0] < center[2][0] + pixelSize) {
|
|
146
|
-
ctx.fillRect(
|
|
158
|
+
ctx.fillRect(
|
|
159
|
+
center[3][0],
|
|
160
|
+
height - pixelSize,
|
|
161
|
+
center[2][0] - center[3][0] + pixelSize,
|
|
162
|
+
pixelSize
|
|
163
|
+
);
|
|
147
164
|
}
|
|
148
165
|
const flag = inner && !first && type !== "text";
|
|
149
166
|
if (!flag && center[3][1] + pixelSize > center[0][1]) {
|
|
@@ -174,129 +191,95 @@ function getGradientColor(disabled, loading, theme = "primary", palette, hoverFl
|
|
|
174
191
|
if (hoverFlag && !loading) return getGlobalThemeColor("neutral", 4);
|
|
175
192
|
return getGlobalThemeColor("neutral", 3);
|
|
176
193
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
const dxTopLeft = calcDx(pixelSize, borderRadius[0]);
|
|
185
|
-
const innerFlag = +!(inner && !first && type !== "text");
|
|
194
|
+
const drawGradient = (ctx, width, height, center, borderRadius, rad, pixelSize, disabled, loading, theme = "primary", palette, inner, first, last, hoverFlag, activeFlag) => {
|
|
195
|
+
const dxBottomRight = calcWhenLeaveBaseline(pixelSize, borderRadius[2]);
|
|
196
|
+
const dxBottomLeft = calcWhenLeaveBaseline(pixelSize, borderRadius[3]);
|
|
197
|
+
const dxTopRight = calcWhenLeaveBaseline(pixelSize, borderRadius[1]);
|
|
198
|
+
const dxTopLeft = calcWhenLeaveBaseline(pixelSize, borderRadius[0]);
|
|
199
|
+
const innerFlag = +!(inner && !first);
|
|
200
|
+
const innerAndLastOrNotInner = +!inner || inner && last;
|
|
186
201
|
if (!activeFlag || disabled) {
|
|
187
202
|
const barColor = getGradientColor(disabled, loading, theme, palette, hoverFlag, activeFlag);
|
|
188
|
-
ctx.fillStyle =
|
|
189
|
-
|
|
190
|
-
|
|
203
|
+
ctx.fillStyle = rgbaColor2string(barColor);
|
|
204
|
+
if (borderRadius[1] > pixelSize) {
|
|
205
|
+
drawCircle(
|
|
206
|
+
ctx,
|
|
207
|
+
center[1][0] - pixelSize,
|
|
208
|
+
center[1][1],
|
|
209
|
+
borderRadius[1],
|
|
210
|
+
rad[1][0],
|
|
211
|
+
rad[1][1],
|
|
212
|
+
pixelSize
|
|
213
|
+
);
|
|
214
|
+
ctx.globalCompositeOperation = "destination-out";
|
|
215
|
+
ctx.fillRect(center[1][0] - pixelSize, 0, dxTopLeft, pixelSize);
|
|
216
|
+
ctx.globalCompositeOperation = "source-over";
|
|
217
|
+
}
|
|
218
|
+
if (borderRadius[2] > pixelSize) {
|
|
219
|
+
drawCircle(
|
|
220
|
+
ctx,
|
|
221
|
+
center[2][0] - pixelSize,
|
|
222
|
+
center[2][1],
|
|
223
|
+
borderRadius[2],
|
|
224
|
+
rad[2][0],
|
|
225
|
+
rad[2][1],
|
|
226
|
+
pixelSize
|
|
227
|
+
);
|
|
228
|
+
ctx.globalCompositeOperation = "destination-out";
|
|
229
|
+
ctx.fillRect(center[2][0] - pixelSize, height - pixelSize, dxBottomLeft, pixelSize);
|
|
230
|
+
ctx.globalCompositeOperation = "source-over";
|
|
191
231
|
}
|
|
192
|
-
const barLenX = center[2][0] + pixelSize - center[3][0] + dxBottomLeft * innerFlag + dxBottomRight;
|
|
193
|
-
barLenX > 0 && ctx.fillRect(
|
|
232
|
+
const barLenX = center[2][0] + pixelSize - center[3][0] + dxBottomLeft * innerFlag + dxBottomRight * +innerAndLastOrNotInner - 1 * +!innerAndLastOrNotInner;
|
|
233
|
+
barLenX > 0 && ctx.fillRect(
|
|
234
|
+
center[3][0] - dxBottomLeft * innerFlag,
|
|
235
|
+
height - pixelSize * 2,
|
|
236
|
+
barLenX,
|
|
237
|
+
pixelSize
|
|
238
|
+
);
|
|
194
239
|
const barLenY = center[2][1] + pixelSize - center[1][1] + dxTopRight + dxBottomRight;
|
|
195
|
-
barLenY > 0 && ctx.fillRect(
|
|
240
|
+
barLenY > 0 && ctx.fillRect(
|
|
241
|
+
width - pixelSize * 2 - (!last ? +inner * pixelSize * 1 : 0),
|
|
242
|
+
center[1][1] - dxTopRight,
|
|
243
|
+
pixelSize,
|
|
244
|
+
barLenY
|
|
245
|
+
);
|
|
196
246
|
} else {
|
|
197
247
|
const barColor = getGradientColor(disabled, loading, theme, palette, hoverFlag, activeFlag);
|
|
198
|
-
ctx.fillStyle =
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
248
|
+
ctx.fillStyle = rgbaColor2string(barColor);
|
|
249
|
+
if (borderRadius[0] > pixelSize) {
|
|
250
|
+
drawCircle(
|
|
251
|
+
ctx,
|
|
252
|
+
center[0][0] + pixelSize,
|
|
253
|
+
center[0][1],
|
|
254
|
+
borderRadius[0],
|
|
255
|
+
rad[0][0],
|
|
256
|
+
rad[0][1],
|
|
257
|
+
pixelSize
|
|
258
|
+
);
|
|
259
|
+
ctx.globalCompositeOperation = "destination-out";
|
|
260
|
+
ctx.fillRect(center[0][0] + pixelSize, 0, dxTopRight, pixelSize);
|
|
261
|
+
ctx.globalCompositeOperation = "source-over";
|
|
262
|
+
}
|
|
263
|
+
if (borderRadius[3] > pixelSize) {
|
|
264
|
+
drawCircle(
|
|
265
|
+
ctx,
|
|
266
|
+
center[3][0] + pixelSize,
|
|
267
|
+
center[3][1],
|
|
268
|
+
borderRadius[3],
|
|
269
|
+
rad[3][0],
|
|
270
|
+
rad[3][1],
|
|
271
|
+
pixelSize
|
|
272
|
+
);
|
|
273
|
+
ctx.globalCompositeOperation = "destination-out";
|
|
274
|
+
ctx.fillRect(center[3][0] + pixelSize, height - pixelSize, dxBottomRight, pixelSize);
|
|
275
|
+
ctx.globalCompositeOperation = "source-over";
|
|
276
|
+
}
|
|
277
|
+
const barLenX = center[1][0] + pixelSize - center[0][0] + dxTopRight * +innerAndLastOrNotInner + dxTopLeft * innerFlag - 1 * +!innerAndLastOrNotInner;
|
|
202
278
|
barLenX > 0 && ctx.fillRect(center[0][0] - dxTopLeft * innerFlag, pixelSize, barLenX, pixelSize);
|
|
203
279
|
const barLenY = pixelSize + center[3][1] - center[0][1] + dxBottomLeft + dxTopLeft;
|
|
204
280
|
barLenY > 0 && ctx.fillRect(pixelSize, center[0][1] - dxTopLeft, pixelSize, barLenY);
|
|
205
281
|
}
|
|
206
282
|
};
|
|
207
|
-
const transformSizeValue = (canvas, value, pixelSize) => {
|
|
208
|
-
if (k(value)) {
|
|
209
|
-
return Math.max(value, pixelSize);
|
|
210
|
-
} else {
|
|
211
|
-
return Math.max(canvas.height * parseFloat(value) / 100, pixelSize);
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
const fillArr = (val) => Array(4).fill(val);
|
|
215
|
-
const getRadiusFromValue = (canvas, value, pixelSize) => {
|
|
216
|
-
if (!value) return fillArr(pixelSize);
|
|
217
|
-
if (!$(value)) {
|
|
218
|
-
return fillArr(transformSizeValue(canvas, value, pixelSize));
|
|
219
|
-
}
|
|
220
|
-
switch (value.length) {
|
|
221
|
-
case 1:
|
|
222
|
-
return fillArr(transformSizeValue(canvas, value[0], pixelSize));
|
|
223
|
-
case 2: {
|
|
224
|
-
const tl = transformSizeValue(canvas, value[0], pixelSize);
|
|
225
|
-
const tr = transformSizeValue(canvas, value[1], pixelSize);
|
|
226
|
-
return [tl, tr, tl, tr];
|
|
227
|
-
}
|
|
228
|
-
case 3: {
|
|
229
|
-
const tl = transformSizeValue(canvas, value[0], pixelSize);
|
|
230
|
-
const br = transformSizeValue(canvas, value[2], pixelSize);
|
|
231
|
-
const rest = transformSizeValue(canvas, value[1], pixelSize);
|
|
232
|
-
return [tl, rest, br, rest];
|
|
233
|
-
}
|
|
234
|
-
default:
|
|
235
|
-
return value.map((e) => transformSizeValue(canvas, e, pixelSize));
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
const getInnerRadius = (canvas, value, pixelSize, first, last) => {
|
|
239
|
-
if (!value) return fillArr(pixelSize);
|
|
240
|
-
if (!$(value)) {
|
|
241
|
-
const v = transformSizeValue(canvas, value, pixelSize);
|
|
242
|
-
if (last) return [pixelSize, v, v, pixelSize];
|
|
243
|
-
if (first) return [v, pixelSize, pixelSize, v];
|
|
244
|
-
return fillArr(pixelSize);
|
|
245
|
-
}
|
|
246
|
-
switch (value.length) {
|
|
247
|
-
case 1:
|
|
248
|
-
const v = transformSizeValue(canvas, value[0], pixelSize);
|
|
249
|
-
if (last) return [pixelSize, v, v, pixelSize];
|
|
250
|
-
if (first) return [v, pixelSize, pixelSize, v];
|
|
251
|
-
return fillArr(pixelSize);
|
|
252
|
-
case 2: {
|
|
253
|
-
const tl = transformSizeValue(canvas, value[0], pixelSize);
|
|
254
|
-
const tr = transformSizeValue(canvas, value[1], pixelSize);
|
|
255
|
-
if (last) return [pixelSize, tr, tr, pixelSize];
|
|
256
|
-
if (first) return [tl, pixelSize, pixelSize, tl];
|
|
257
|
-
return fillArr(pixelSize);
|
|
258
|
-
}
|
|
259
|
-
case 3: {
|
|
260
|
-
const tl = transformSizeValue(canvas, value[0], pixelSize);
|
|
261
|
-
const br = transformSizeValue(canvas, value[2], pixelSize);
|
|
262
|
-
const rest = transformSizeValue(canvas, value[1], pixelSize);
|
|
263
|
-
if (last) return [pixelSize, rest, br, pixelSize];
|
|
264
|
-
if (first) return [tl, pixelSize, pixelSize, rest];
|
|
265
|
-
return fillArr(pixelSize);
|
|
266
|
-
}
|
|
267
|
-
default:
|
|
268
|
-
if (last) return [pixelSize, transformSizeValue(canvas, value[1], pixelSize), transformSizeValue(canvas, value[2], pixelSize), pixelSize];
|
|
269
|
-
if (first) return [transformSizeValue(canvas, value[0], pixelSize), pixelSize, pixelSize, transformSizeValue(canvas, value[3], pixelSize)];
|
|
270
|
-
return fillArr(pixelSize);
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
const getBorderRadius = (canvas, pixelSize, borderRadius, shape, inner, first, last) => {
|
|
274
|
-
if (!inner) {
|
|
275
|
-
if (borderRadius) {
|
|
276
|
-
return getRadiusFromValue(canvas, borderRadius, pixelSize);
|
|
277
|
-
}
|
|
278
|
-
switch (shape) {
|
|
279
|
-
case "round":
|
|
280
|
-
case "circle":
|
|
281
|
-
return fillArr(transformSizeValue(canvas, "50%", pixelSize));
|
|
282
|
-
default:
|
|
283
|
-
return fillArr(pixelSize);
|
|
284
|
-
}
|
|
285
|
-
} else {
|
|
286
|
-
if (borderRadius) {
|
|
287
|
-
return getInnerRadius(canvas, borderRadius, pixelSize, first, last);
|
|
288
|
-
}
|
|
289
|
-
switch (shape) {
|
|
290
|
-
case "round":
|
|
291
|
-
const roundArr = fillArr(transformSizeValue(canvas, "50%", pixelSize));
|
|
292
|
-
if (last) return roundArr.map((e, i) => i < 1 || i > 2 ? pixelSize : e);
|
|
293
|
-
if (first) return roundArr.map((e, i) => i > 0 && i < 3 ? pixelSize : e);
|
|
294
|
-
return fillArr(pixelSize);
|
|
295
|
-
default:
|
|
296
|
-
return fillArr(pixelSize);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
283
|
const getTextColorWithPalette = (palette, type, disabled, loading, hoverFlag, activeFlag) => {
|
|
301
284
|
if (!palette || type === "primary") return void 0;
|
|
302
285
|
if (disabled) {
|
|
@@ -317,10 +300,9 @@ const getTextColorWithPalette = (palette, type, disabled, loading, hoverFlag, ac
|
|
|
317
300
|
}
|
|
318
301
|
};
|
|
319
302
|
export {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
303
|
+
getBorderColor as a,
|
|
304
|
+
drawBorder as b,
|
|
305
|
+
getBackgroundColor as c,
|
|
323
306
|
drawGradient as d,
|
|
324
|
-
getBackgroundColor as e,
|
|
325
307
|
getTextColorWithPalette as g
|
|
326
308
|
};
|
package/es/button/index.css
CHANGED
|
@@ -6,16 +6,24 @@
|
|
|
6
6
|
z-index: -1;
|
|
7
7
|
pointer-events: none;
|
|
8
8
|
}
|
|
9
|
+
button.px-button {
|
|
10
|
+
font-size: var(--text-size);
|
|
11
|
+
}
|
|
9
12
|
.px-button {
|
|
10
13
|
--button-size: var(--px-medium-size);
|
|
11
|
-
--padding-x
|
|
14
|
+
--px-medium-padding-x: var(--px-interval-4);
|
|
15
|
+
--px-large-padding-x: var(--px-interval-5);
|
|
16
|
+
--px-small-padding-x: var(--px-interval-3);
|
|
17
|
+
--padding-x-size: var(--px-medium-padding-x);
|
|
12
18
|
--text-color: var(--px-neutral-1);
|
|
19
|
+
--text-size: var(--px-medium-font-size);
|
|
13
20
|
height: var(--button-size);
|
|
14
21
|
padding-left: var(--padding-x-size);
|
|
15
22
|
padding-right: var(--padding-x-size);
|
|
16
23
|
background-color: transparent;
|
|
17
24
|
border-color: transparent;
|
|
18
25
|
border-width: var(--px-bit);
|
|
26
|
+
border-style: solid;
|
|
19
27
|
display: inline-flex;
|
|
20
28
|
align-items: center;
|
|
21
29
|
position: relative;
|
|
@@ -24,18 +32,21 @@
|
|
|
24
32
|
user-select: none;
|
|
25
33
|
transition: 0.25s;
|
|
26
34
|
z-index: 0;
|
|
35
|
+
font-size: var(--text-size);
|
|
36
|
+
box-sizing: border-box;
|
|
27
37
|
}
|
|
28
38
|
.px-button__inner {
|
|
39
|
+
transition: color 0.25s;
|
|
29
40
|
padding-right: calc(var(--padding-x-size) + 1px + 1 * var(--px-bit));
|
|
30
41
|
}
|
|
31
|
-
.px-button__inner:last-
|
|
42
|
+
.px-button__inner:last-child {
|
|
32
43
|
padding-right: var(--padding-x-size);
|
|
33
44
|
}
|
|
34
45
|
.px-button__inner.px-button__text {
|
|
35
46
|
padding-right: var(--padding-x-size);
|
|
36
47
|
margin-right: calc(1px + 1 * var(--px-bit));
|
|
37
48
|
}
|
|
38
|
-
.px-button__inner.px-button__text:last-
|
|
49
|
+
.px-button__inner.px-button__text:last-child {
|
|
39
50
|
margin-right: 0;
|
|
40
51
|
}
|
|
41
52
|
.px-button__circle,
|
|
@@ -45,12 +56,14 @@
|
|
|
45
56
|
justify-content: center;
|
|
46
57
|
}
|
|
47
58
|
.px-button__large {
|
|
48
|
-
--padding-x-size:
|
|
59
|
+
--padding-x-size: var(--px-large-padding-x);
|
|
49
60
|
--button-size: var(--px-large-size);
|
|
61
|
+
--text-size: var(--px-large-font-size);
|
|
50
62
|
}
|
|
51
63
|
.px-button__small {
|
|
52
|
-
--padding-x-size:
|
|
64
|
+
--padding-x-size: var(--px-small-padding-x);
|
|
53
65
|
--button-size: var(--px-small-size);
|
|
66
|
+
--text-size: var(--px-small-font-size);
|
|
54
67
|
}
|
|
55
68
|
.px-button__loading {
|
|
56
69
|
cursor: auto;
|
|
@@ -64,7 +77,7 @@
|
|
|
64
77
|
cursor: not-allowed;
|
|
65
78
|
}
|
|
66
79
|
.px-button-icon-wrapper {
|
|
67
|
-
margin-right:
|
|
80
|
+
margin-right: var(--px-interval-2);
|
|
68
81
|
display: flex;
|
|
69
82
|
align-items: center;
|
|
70
83
|
}
|
|
@@ -72,13 +85,10 @@
|
|
|
72
85
|
margin-right: 0;
|
|
73
86
|
}
|
|
74
87
|
.px-button-icon {
|
|
75
|
-
height:
|
|
76
|
-
width:
|
|
88
|
+
height: var(--text-size);
|
|
89
|
+
width: var(--text-size);
|
|
77
90
|
fill: var(--text-color);
|
|
78
91
|
}
|
|
79
|
-
.px-button-icon__loading {
|
|
80
|
-
animation: px-icon-spin 1s linear infinite;
|
|
81
|
-
}
|
|
82
92
|
.px-button.px-button__primary:focus-visible {
|
|
83
93
|
outline-color: var(--px-primary-6);
|
|
84
94
|
outline-offset: var(--px-bit);
|
|
@@ -337,7 +347,7 @@
|
|
|
337
347
|
outline-offset: var(--px-bit);
|
|
338
348
|
}
|
|
339
349
|
.px-button.px-button__info.px-button__disabled {
|
|
340
|
-
--text-color: var(--px-neutral-
|
|
350
|
+
--text-color: var(--px-neutral-7);
|
|
341
351
|
}
|
|
342
352
|
.px-button.px-button__info.px-button__text,
|
|
343
353
|
.px-button.px-button__info.px-button__plain,
|
|
@@ -347,7 +357,7 @@
|
|
|
347
357
|
.px-button.px-button__info.px-button__text.px-button__disabled,
|
|
348
358
|
.px-button.px-button__info.px-button__plain.px-button__disabled,
|
|
349
359
|
.px-button.px-button__info.px-button__outline.px-button__disabled {
|
|
350
|
-
--text-color: var(--px-neutral-
|
|
360
|
+
--text-color: var(--px-neutral-7);
|
|
351
361
|
}
|
|
352
362
|
.px-button.px-button__info.px-button__text:active.px-button__disabled,
|
|
353
363
|
.px-button.px-button__info.px-button__plain:active.px-button__disabled,
|
|
@@ -355,7 +365,7 @@
|
|
|
355
365
|
.px-button.px-button__info.px-button__text:hover.px-button__disabled,
|
|
356
366
|
.px-button.px-button__info.px-button__plain:hover.px-button__disabled,
|
|
357
367
|
.px-button.px-button__info.px-button__outline:hover.px-button__disabled {
|
|
358
|
-
--text-color: var(--px-neutral-
|
|
368
|
+
--text-color: var(--px-neutral-7);
|
|
359
369
|
}
|
|
360
370
|
.px-button.px-button__info.px-button__text:active.px-button__loading,
|
|
361
371
|
.px-button.px-button__info.px-button__plain:active.px-button__loading,
|