@uzum-tech/ui 2.3.8 → 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +631 -35
- package/dist/index.mjs +627 -36
- package/dist/index.prod.js +3 -3
- package/dist/index.prod.mjs +3 -3
- package/es/_internal/button-v3/index.d.ts +5 -0
- package/es/_internal/button-v3/index.mjs +3 -0
- package/es/_internal/button-v3/src/ButtonV3.d.ts +533 -0
- package/es/_internal/button-v3/src/ButtonV3.mjs +200 -0
- package/es/_internal/button-v3/src/interface.d.ts +281 -0
- package/es/_internal/button-v3/src/interface.mjs +29 -0
- package/es/_internal/button-v3/src/styles/index.cssr.d.ts +2 -0
- package/es/_internal/button-v3/src/styles/index.cssr.mjs +119 -0
- package/es/_internal/button-v3/src/utils.d.ts +10 -0
- package/es/_internal/button-v3/src/utils.mjs +52 -0
- package/es/_internal/button-v3/styles/_common.d.ts +19 -0
- package/es/_internal/button-v3/styles/_common.mjs +18 -0
- package/es/_internal/button-v3/styles/dark.d.ts +3 -0
- package/es/_internal/button-v3/styles/dark.mjs +8 -0
- package/es/_internal/button-v3/styles/index.d.ts +3 -0
- package/es/_internal/button-v3/styles/index.mjs +2 -0
- package/es/_internal/button-v3/styles/light.d.ts +81 -0
- package/es/_internal/button-v3/styles/light.mjs +91 -0
- package/es/_internal/index.d.ts +2 -0
- package/es/_internal/index.mjs +1 -0
- package/es/_styles/common/dark.mjs +12 -0
- package/es/_styles/common/light.d.ts +12 -0
- package/es/_styles/common/light.mjs +12 -0
- package/es/button-v3/index.d.ts +4 -0
- package/es/button-v3/index.mjs +2 -0
- package/es/button-v3/src/ButtonV3.d.ts +525 -0
- package/es/button-v3/src/ButtonV3.mjs +17 -0
- package/es/components.d.ts +524 -2
- package/es/components.mjs +4 -0
- package/es/config-provider/src/internal-interface.d.ts +4 -0
- package/es/dialog/src/DialogProvider.d.ts +48 -0
- package/es/styles.d.ts +1 -0
- package/es/styles.mjs +1 -0
- package/es/theme-editor/src/ThemeEditor.d.ts +12 -0
- package/es/themes/dark.mjs +2 -0
- package/es/themes/light.mjs +2 -0
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/lib/_internal/button-v3/index.d.ts +5 -0
- package/lib/_internal/button-v3/index.js +13 -0
- package/lib/_internal/button-v3/src/ButtonV3.d.ts +533 -0
- package/lib/_internal/button-v3/src/ButtonV3.js +170 -0
- package/lib/_internal/button-v3/src/interface.d.ts +281 -0
- package/lib/_internal/button-v3/src/interface.js +20 -0
- package/lib/_internal/button-v3/src/styles/index.cssr.d.ts +2 -0
- package/lib/_internal/button-v3/src/styles/index.cssr.js +124 -0
- package/lib/_internal/button-v3/src/utils.d.ts +10 -0
- package/lib/_internal/button-v3/src/utils.js +56 -0
- package/lib/_internal/button-v3/styles/_common.d.ts +19 -0
- package/lib/_internal/button-v3/styles/_common.js +20 -0
- package/lib/_internal/button-v3/styles/dark.d.ts +3 -0
- package/lib/_internal/button-v3/styles/dark.js +10 -0
- package/lib/_internal/button-v3/styles/index.d.ts +3 -0
- package/lib/_internal/button-v3/styles/index.js +10 -0
- package/lib/_internal/button-v3/styles/light.d.ts +81 -0
- package/lib/_internal/button-v3/styles/light.js +19 -0
- package/lib/_internal/index.d.ts +2 -0
- package/lib/_internal/index.js +4 -1
- package/lib/_styles/common/dark.js +1 -1
- package/lib/_styles/common/light.d.ts +12 -0
- package/lib/_styles/common/light.js +1 -1
- package/lib/button-v3/index.d.ts +4 -0
- package/lib/button-v3/index.js +13 -0
- package/lib/button-v3/src/ButtonV3.d.ts +525 -0
- package/lib/button-v3/src/ButtonV3.js +17 -0
- package/lib/components.d.ts +524 -2
- package/lib/components.js +15 -8
- package/lib/config-provider/src/internal-interface.d.ts +4 -0
- package/lib/dialog/src/DialogProvider.d.ts +48 -0
- package/lib/styles.d.ts +1 -0
- package/lib/styles.js +195 -193
- package/lib/theme-editor/src/ThemeEditor.d.ts +12 -0
- package/lib/themes/dark.js +202 -200
- package/lib/themes/light.js +202 -200
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/volar.d.ts +2 -0
- package/web-types.json +14 -1
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { computed, defineComponent, h, ref, watchEffect } from 'vue';
|
|
2
|
+
import { useConfig, useFormItem, useTheme, useThemeClass } from "../../../_mixins/index.mjs";
|
|
3
|
+
import { call, createKey, warnOnce } from "../../../_utils/index.mjs";
|
|
4
|
+
import { buttonV3Light } from "../styles/index.mjs";
|
|
5
|
+
import { buttonV3Props } from "./interface.mjs";
|
|
6
|
+
import style from "./styles/index.cssr.mjs";
|
|
7
|
+
import { renderIconSlot, renderSpinner, resolveSpinnerStrokeWidth, resolveVariantKey, upperFirst } from "./utils.mjs";
|
|
8
|
+
const ButtonV3 = defineComponent({
|
|
9
|
+
name: 'ButtonV3',
|
|
10
|
+
props: buttonV3Props,
|
|
11
|
+
slots: Object,
|
|
12
|
+
setup(props, {
|
|
13
|
+
attrs
|
|
14
|
+
}) {
|
|
15
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
16
|
+
watchEffect(() => {
|
|
17
|
+
if (props.type === 'secondary' && props.tone === 'negative') {
|
|
18
|
+
warnOnce('button-v3', 'У типа `secondary` нет тона `negative` — используется тон `default`.');
|
|
19
|
+
}
|
|
20
|
+
if (props.iconOnly && !attrs['aria-label'] && !attrs['aria-labelledby'] && !attrs.title) {
|
|
21
|
+
warnOnce('button-v3', 'Кнопке с `icon-only` нужен `aria-label` (или `title`) — иначе действие непонятно.');
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const selfElRef = ref(null);
|
|
26
|
+
const {
|
|
27
|
+
inlineThemeDisabled,
|
|
28
|
+
mergedClsPrefixRef
|
|
29
|
+
} = useConfig(props);
|
|
30
|
+
const themeRef = useTheme('ButtonV3', '-button-v3', style, buttonV3Light, props, mergedClsPrefixRef);
|
|
31
|
+
const {
|
|
32
|
+
mergedSizeRef
|
|
33
|
+
} = useFormItem({}, {
|
|
34
|
+
defaultSize: 'medium',
|
|
35
|
+
mergedSize: UFormItem => {
|
|
36
|
+
const {
|
|
37
|
+
size
|
|
38
|
+
} = props;
|
|
39
|
+
if (size) return size;
|
|
40
|
+
const {
|
|
41
|
+
mergedSize: formItemSize
|
|
42
|
+
} = UFormItem || {};
|
|
43
|
+
if (formItemSize) return formItemSize.value;
|
|
44
|
+
return 'medium';
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const variantKeyRef = computed(() => resolveVariantKey(props.type, props.tone));
|
|
48
|
+
const mergedDisabledRef = computed(() => props.disabled);
|
|
49
|
+
const inertRef = computed(() => props.disabled || props.loading);
|
|
50
|
+
const mergedFocusableRef = computed(() => props.focusable && !props.disabled);
|
|
51
|
+
const spinnerStrokeWidthRef = computed(() => {
|
|
52
|
+
const {
|
|
53
|
+
self
|
|
54
|
+
} = themeRef.value;
|
|
55
|
+
return resolveSpinnerStrokeWidth(self[createKey('iconSize', mergedSizeRef.value)], self.spinnerStrokeWidth);
|
|
56
|
+
});
|
|
57
|
+
const handleClick = e => {
|
|
58
|
+
if (inertRef.value) {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
e.stopPropagation();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const {
|
|
64
|
+
onClick
|
|
65
|
+
} = props;
|
|
66
|
+
if (onClick) call(onClick, e);
|
|
67
|
+
};
|
|
68
|
+
const cssVarsRef = computed(() => {
|
|
69
|
+
const {
|
|
70
|
+
common: {
|
|
71
|
+
cubicBezierEaseInOut
|
|
72
|
+
},
|
|
73
|
+
self
|
|
74
|
+
} = themeRef.value;
|
|
75
|
+
const {
|
|
76
|
+
fontFamily,
|
|
77
|
+
fontSize,
|
|
78
|
+
lineHeight,
|
|
79
|
+
fontWeight,
|
|
80
|
+
letterSpacing,
|
|
81
|
+
iconMargin,
|
|
82
|
+
borderWidth,
|
|
83
|
+
focusRingWidth,
|
|
84
|
+
focusRingColor,
|
|
85
|
+
pressedOverlayColor,
|
|
86
|
+
textColorDisabled
|
|
87
|
+
} = self;
|
|
88
|
+
const size = mergedSizeRef.value;
|
|
89
|
+
const variant = upperFirst(variantKeyRef.value);
|
|
90
|
+
const colors = self;
|
|
91
|
+
return {
|
|
92
|
+
'--u-bezier': cubicBezierEaseInOut,
|
|
93
|
+
'--u-height': self[createKey('height', size)],
|
|
94
|
+
'--u-padding': self[createKey('padding', size)],
|
|
95
|
+
'--u-border-radius': self[createKey('borderRadius', size)],
|
|
96
|
+
'--u-icon-size': self[createKey('iconSize', size)],
|
|
97
|
+
'--u-icon-margin': iconMargin,
|
|
98
|
+
'--u-font-family': fontFamily,
|
|
99
|
+
'--u-font-size': fontSize,
|
|
100
|
+
'--u-line-height': lineHeight,
|
|
101
|
+
'--u-font-weight': fontWeight,
|
|
102
|
+
'--u-letter-spacing': letterSpacing,
|
|
103
|
+
'--u-border-width': borderWidth,
|
|
104
|
+
'--u-focus-ring-width': focusRingWidth,
|
|
105
|
+
'--u-focus-ring-color': focusRingColor,
|
|
106
|
+
'--u-pressed-overlay-color': pressedOverlayColor,
|
|
107
|
+
'--u-color': colors[`color${variant}`],
|
|
108
|
+
'--u-color-hover': colors[`color${variant}Hover`],
|
|
109
|
+
'--u-color-disabled': colors[`color${variant}Disabled`],
|
|
110
|
+
'--u-text-color': colors[`textColor${variant}`],
|
|
111
|
+
'--u-text-color-hover': colors[`textColor${variant}Hover`],
|
|
112
|
+
'--u-text-color-disabled': textColorDisabled,
|
|
113
|
+
'--u-border-color': colors[`borderColor${variant}`],
|
|
114
|
+
'--u-border-color-disabled': colors[`borderColor${variant}Disabled`]
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
const themeClassHashRef = computed(() => `${variantKeyRef.value}-${mergedSizeRef.value}`);
|
|
118
|
+
const themeClassHandle = inlineThemeDisabled ? useThemeClass('button-v3', themeClassHashRef, cssVarsRef, props) : undefined;
|
|
119
|
+
return {
|
|
120
|
+
selfElRef,
|
|
121
|
+
mergedClsPrefix: mergedClsPrefixRef,
|
|
122
|
+
mergedSize: mergedSizeRef,
|
|
123
|
+
mergedDisabled: mergedDisabledRef,
|
|
124
|
+
mergedFocusable: mergedFocusableRef,
|
|
125
|
+
inert: inertRef,
|
|
126
|
+
spinnerStrokeWidth: spinnerStrokeWidthRef,
|
|
127
|
+
handleClick,
|
|
128
|
+
cssVars: inlineThemeDisabled ? undefined : cssVarsRef,
|
|
129
|
+
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
130
|
+
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
render() {
|
|
134
|
+
const {
|
|
135
|
+
$slots,
|
|
136
|
+
mergedClsPrefix: clsPrefix,
|
|
137
|
+
tag: Component,
|
|
138
|
+
iconOnly,
|
|
139
|
+
loading,
|
|
140
|
+
mergedDisabled,
|
|
141
|
+
inert,
|
|
142
|
+
spinnerStrokeWidth: strokeWidth,
|
|
143
|
+
onRender
|
|
144
|
+
} = this;
|
|
145
|
+
onRender === null || onRender === void 0 ? void 0 : onRender();
|
|
146
|
+
const iconStartSlot = $slots['icon-start'];
|
|
147
|
+
const iconEndSlot = $slots['icon-end'];
|
|
148
|
+
const hasIconStart = !!iconStartSlot;
|
|
149
|
+
const hasIconEnd = !!iconEndSlot;
|
|
150
|
+
const centeredSpinner = loading && !iconOnly && !hasIconStart && !hasIconEnd;
|
|
151
|
+
const children = [];
|
|
152
|
+
if (iconOnly) {
|
|
153
|
+
children.push(renderIconSlot({
|
|
154
|
+
clsPrefix,
|
|
155
|
+
slot: iconStartSlot || $slots.default,
|
|
156
|
+
showSpinner: loading,
|
|
157
|
+
strokeWidth,
|
|
158
|
+
key: 'icon'
|
|
159
|
+
}));
|
|
160
|
+
} else {
|
|
161
|
+
children.push(renderIconSlot({
|
|
162
|
+
clsPrefix,
|
|
163
|
+
slot: iconStartSlot,
|
|
164
|
+
showSpinner: loading && hasIconStart,
|
|
165
|
+
strokeWidth,
|
|
166
|
+
key: 'icon-start'
|
|
167
|
+
}));
|
|
168
|
+
if ($slots.default) {
|
|
169
|
+
children.push(h("span", {
|
|
170
|
+
class: `${clsPrefix}-button-v3__label`
|
|
171
|
+
}, $slots.default()));
|
|
172
|
+
}
|
|
173
|
+
children.push(renderIconSlot({
|
|
174
|
+
clsPrefix,
|
|
175
|
+
slot: iconEndSlot,
|
|
176
|
+
showSpinner: loading && !hasIconStart && hasIconEnd,
|
|
177
|
+
strokeWidth,
|
|
178
|
+
key: 'icon-end'
|
|
179
|
+
}));
|
|
180
|
+
if (centeredSpinner) {
|
|
181
|
+
children.push(h("span", {
|
|
182
|
+
class: `${clsPrefix}-button-v3__spinner`
|
|
183
|
+
}, renderSpinner(clsPrefix, strokeWidth)));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return h(Component, {
|
|
187
|
+
ref: "selfElRef",
|
|
188
|
+
class: [`${clsPrefix}-button-v3`, this.themeClass, `${clsPrefix}-button-v3--${this.type}-type`, `${clsPrefix}-button-v3--${this.tone}-tone`, `${clsPrefix}-button-v3--${this.mergedSize}-size`, iconOnly && `${clsPrefix}-button-v3--icon-only`, this.block && `${clsPrefix}-button-v3--block`, mergedDisabled && `${clsPrefix}-button-v3--disabled`, loading && `${clsPrefix}-button-v3--loading`, centeredSpinner && `${clsPrefix}-button-v3--loading-text-only`],
|
|
189
|
+
style: this.cssVars,
|
|
190
|
+
type: Component === 'button' ? this.attrType : undefined,
|
|
191
|
+
disabled: Component === 'button' ? mergedDisabled : undefined,
|
|
192
|
+
tabindex: this.mergedFocusable ? 0 : -1,
|
|
193
|
+
"aria-disabled": inert ? 'true' : undefined,
|
|
194
|
+
"aria-busy": loading ? 'true' : undefined,
|
|
195
|
+
onClick: this.handleClick
|
|
196
|
+
}, children);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
export default ButtonV3;
|
|
200
|
+
export const XButtonV3 = ButtonV3;
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ExtractPropTypes, PropType, VNode } from 'vue';
|
|
2
|
+
import type { ExtractPublicPropTypes, MaybeArray } from '../../../_utils';
|
|
3
|
+
export declare const buttonV3Props: {
|
|
4
|
+
readonly type: {
|
|
5
|
+
readonly type: PropType<ButtonV3Type>;
|
|
6
|
+
readonly default: "primary";
|
|
7
|
+
};
|
|
8
|
+
readonly tone: {
|
|
9
|
+
readonly type: PropType<ButtonV3Tone>;
|
|
10
|
+
readonly default: "default";
|
|
11
|
+
};
|
|
12
|
+
readonly size: PropType<ButtonV3Size>;
|
|
13
|
+
readonly iconOnly: BooleanConstructor;
|
|
14
|
+
readonly block: BooleanConstructor;
|
|
15
|
+
readonly disabled: BooleanConstructor;
|
|
16
|
+
readonly loading: BooleanConstructor;
|
|
17
|
+
readonly focusable: {
|
|
18
|
+
readonly type: BooleanConstructor;
|
|
19
|
+
readonly default: true;
|
|
20
|
+
};
|
|
21
|
+
readonly tag: {
|
|
22
|
+
readonly type: PropType<ButtonV3Tag>;
|
|
23
|
+
readonly default: "button";
|
|
24
|
+
};
|
|
25
|
+
readonly attrType: {
|
|
26
|
+
readonly type: PropType<ButtonV3AttrType>;
|
|
27
|
+
readonly default: "button";
|
|
28
|
+
};
|
|
29
|
+
readonly onClick: PropType<ButtonV3ClickHandler>;
|
|
30
|
+
readonly theme: PropType<import("../../../_mixins").Theme<"ButtonV3", {
|
|
31
|
+
fontFamily: string;
|
|
32
|
+
fontSize: string;
|
|
33
|
+
lineHeight: string;
|
|
34
|
+
fontWeight: string;
|
|
35
|
+
letterSpacing: string;
|
|
36
|
+
pressedOverlayColor: string;
|
|
37
|
+
focusRingColor: string;
|
|
38
|
+
textColorDisabled: string;
|
|
39
|
+
colorPrimary: string;
|
|
40
|
+
colorPrimaryHover: string;
|
|
41
|
+
textColorPrimary: string;
|
|
42
|
+
textColorPrimaryHover: string;
|
|
43
|
+
borderColorPrimary: string;
|
|
44
|
+
colorPrimaryDisabled: string;
|
|
45
|
+
borderColorPrimaryDisabled: string;
|
|
46
|
+
colorPrimaryNegative: string;
|
|
47
|
+
colorPrimaryNegativeHover: string;
|
|
48
|
+
textColorPrimaryNegative: string;
|
|
49
|
+
textColorPrimaryNegativeHover: string;
|
|
50
|
+
borderColorPrimaryNegative: string;
|
|
51
|
+
colorPrimaryNegativeDisabled: string;
|
|
52
|
+
borderColorPrimaryNegativeDisabled: string;
|
|
53
|
+
colorSecondary: string;
|
|
54
|
+
colorSecondaryHover: string;
|
|
55
|
+
textColorSecondary: string;
|
|
56
|
+
textColorSecondaryHover: string;
|
|
57
|
+
borderColorSecondary: string;
|
|
58
|
+
colorSecondaryDisabled: string;
|
|
59
|
+
borderColorSecondaryDisabled: string;
|
|
60
|
+
colorTertiary: string;
|
|
61
|
+
colorTertiaryHover: string;
|
|
62
|
+
textColorTertiary: string;
|
|
63
|
+
textColorTertiaryHover: string;
|
|
64
|
+
borderColorTertiary: string;
|
|
65
|
+
colorTertiaryDisabled: string;
|
|
66
|
+
borderColorTertiaryDisabled: string;
|
|
67
|
+
colorTertiaryNegative: string;
|
|
68
|
+
colorTertiaryNegativeHover: string;
|
|
69
|
+
textColorTertiaryNegative: string;
|
|
70
|
+
textColorTertiaryNegativeHover: string;
|
|
71
|
+
borderColorTertiaryNegative: string;
|
|
72
|
+
colorTertiaryNegativeDisabled: string;
|
|
73
|
+
borderColorTertiaryNegativeDisabled: string;
|
|
74
|
+
colorGhost: string;
|
|
75
|
+
colorGhostHover: string;
|
|
76
|
+
textColorGhost: string;
|
|
77
|
+
textColorGhostHover: string;
|
|
78
|
+
borderColorGhost: string;
|
|
79
|
+
colorGhostDisabled: string;
|
|
80
|
+
borderColorGhostDisabled: string;
|
|
81
|
+
colorGhostNegative: string;
|
|
82
|
+
colorGhostNegativeHover: string;
|
|
83
|
+
textColorGhostNegative: string;
|
|
84
|
+
textColorGhostNegativeHover: string;
|
|
85
|
+
borderColorGhostNegative: string;
|
|
86
|
+
colorGhostNegativeDisabled: string;
|
|
87
|
+
borderColorGhostNegativeDisabled: string;
|
|
88
|
+
heightSmall: string;
|
|
89
|
+
heightMedium: string;
|
|
90
|
+
heightLarge: string;
|
|
91
|
+
paddingSmall: string;
|
|
92
|
+
paddingMedium: string;
|
|
93
|
+
paddingLarge: string;
|
|
94
|
+
borderRadiusSmall: string;
|
|
95
|
+
borderRadiusMedium: string;
|
|
96
|
+
borderRadiusLarge: string;
|
|
97
|
+
iconSizeSmall: string;
|
|
98
|
+
iconSizeMedium: string;
|
|
99
|
+
iconSizeLarge: string;
|
|
100
|
+
iconMargin: string;
|
|
101
|
+
borderWidth: string;
|
|
102
|
+
focusRingWidth: string;
|
|
103
|
+
spinnerStrokeWidth: string;
|
|
104
|
+
}, any>>;
|
|
105
|
+
readonly themeOverrides: PropType<import("../../../_mixins/use-theme").ExtractThemeOverrides<import("../../../_mixins").Theme<"ButtonV3", {
|
|
106
|
+
fontFamily: string;
|
|
107
|
+
fontSize: string;
|
|
108
|
+
lineHeight: string;
|
|
109
|
+
fontWeight: string;
|
|
110
|
+
letterSpacing: string;
|
|
111
|
+
pressedOverlayColor: string;
|
|
112
|
+
focusRingColor: string;
|
|
113
|
+
textColorDisabled: string;
|
|
114
|
+
colorPrimary: string;
|
|
115
|
+
colorPrimaryHover: string;
|
|
116
|
+
textColorPrimary: string;
|
|
117
|
+
textColorPrimaryHover: string;
|
|
118
|
+
borderColorPrimary: string;
|
|
119
|
+
colorPrimaryDisabled: string;
|
|
120
|
+
borderColorPrimaryDisabled: string;
|
|
121
|
+
colorPrimaryNegative: string;
|
|
122
|
+
colorPrimaryNegativeHover: string;
|
|
123
|
+
textColorPrimaryNegative: string;
|
|
124
|
+
textColorPrimaryNegativeHover: string;
|
|
125
|
+
borderColorPrimaryNegative: string;
|
|
126
|
+
colorPrimaryNegativeDisabled: string;
|
|
127
|
+
borderColorPrimaryNegativeDisabled: string;
|
|
128
|
+
colorSecondary: string;
|
|
129
|
+
colorSecondaryHover: string;
|
|
130
|
+
textColorSecondary: string;
|
|
131
|
+
textColorSecondaryHover: string;
|
|
132
|
+
borderColorSecondary: string;
|
|
133
|
+
colorSecondaryDisabled: string;
|
|
134
|
+
borderColorSecondaryDisabled: string;
|
|
135
|
+
colorTertiary: string;
|
|
136
|
+
colorTertiaryHover: string;
|
|
137
|
+
textColorTertiary: string;
|
|
138
|
+
textColorTertiaryHover: string;
|
|
139
|
+
borderColorTertiary: string;
|
|
140
|
+
colorTertiaryDisabled: string;
|
|
141
|
+
borderColorTertiaryDisabled: string;
|
|
142
|
+
colorTertiaryNegative: string;
|
|
143
|
+
colorTertiaryNegativeHover: string;
|
|
144
|
+
textColorTertiaryNegative: string;
|
|
145
|
+
textColorTertiaryNegativeHover: string;
|
|
146
|
+
borderColorTertiaryNegative: string;
|
|
147
|
+
colorTertiaryNegativeDisabled: string;
|
|
148
|
+
borderColorTertiaryNegativeDisabled: string;
|
|
149
|
+
colorGhost: string;
|
|
150
|
+
colorGhostHover: string;
|
|
151
|
+
textColorGhost: string;
|
|
152
|
+
textColorGhostHover: string;
|
|
153
|
+
borderColorGhost: string;
|
|
154
|
+
colorGhostDisabled: string;
|
|
155
|
+
borderColorGhostDisabled: string;
|
|
156
|
+
colorGhostNegative: string;
|
|
157
|
+
colorGhostNegativeHover: string;
|
|
158
|
+
textColorGhostNegative: string;
|
|
159
|
+
textColorGhostNegativeHover: string;
|
|
160
|
+
borderColorGhostNegative: string;
|
|
161
|
+
colorGhostNegativeDisabled: string;
|
|
162
|
+
borderColorGhostNegativeDisabled: string;
|
|
163
|
+
heightSmall: string;
|
|
164
|
+
heightMedium: string;
|
|
165
|
+
heightLarge: string;
|
|
166
|
+
paddingSmall: string;
|
|
167
|
+
paddingMedium: string;
|
|
168
|
+
paddingLarge: string;
|
|
169
|
+
borderRadiusSmall: string;
|
|
170
|
+
borderRadiusMedium: string;
|
|
171
|
+
borderRadiusLarge: string;
|
|
172
|
+
iconSizeSmall: string;
|
|
173
|
+
iconSizeMedium: string;
|
|
174
|
+
iconSizeLarge: string;
|
|
175
|
+
iconMargin: string;
|
|
176
|
+
borderWidth: string;
|
|
177
|
+
focusRingWidth: string;
|
|
178
|
+
spinnerStrokeWidth: string;
|
|
179
|
+
}, any>>>;
|
|
180
|
+
readonly builtinThemeOverrides: PropType<import("../../../_mixins/use-theme").ExtractThemeOverrides<import("../../../_mixins").Theme<"ButtonV3", {
|
|
181
|
+
fontFamily: string;
|
|
182
|
+
fontSize: string;
|
|
183
|
+
lineHeight: string;
|
|
184
|
+
fontWeight: string;
|
|
185
|
+
letterSpacing: string;
|
|
186
|
+
pressedOverlayColor: string;
|
|
187
|
+
focusRingColor: string;
|
|
188
|
+
textColorDisabled: string;
|
|
189
|
+
colorPrimary: string;
|
|
190
|
+
colorPrimaryHover: string;
|
|
191
|
+
textColorPrimary: string;
|
|
192
|
+
textColorPrimaryHover: string;
|
|
193
|
+
borderColorPrimary: string;
|
|
194
|
+
colorPrimaryDisabled: string;
|
|
195
|
+
borderColorPrimaryDisabled: string;
|
|
196
|
+
colorPrimaryNegative: string;
|
|
197
|
+
colorPrimaryNegativeHover: string;
|
|
198
|
+
textColorPrimaryNegative: string;
|
|
199
|
+
textColorPrimaryNegativeHover: string;
|
|
200
|
+
borderColorPrimaryNegative: string;
|
|
201
|
+
colorPrimaryNegativeDisabled: string;
|
|
202
|
+
borderColorPrimaryNegativeDisabled: string;
|
|
203
|
+
colorSecondary: string;
|
|
204
|
+
colorSecondaryHover: string;
|
|
205
|
+
textColorSecondary: string;
|
|
206
|
+
textColorSecondaryHover: string;
|
|
207
|
+
borderColorSecondary: string;
|
|
208
|
+
colorSecondaryDisabled: string;
|
|
209
|
+
borderColorSecondaryDisabled: string;
|
|
210
|
+
colorTertiary: string;
|
|
211
|
+
colorTertiaryHover: string;
|
|
212
|
+
textColorTertiary: string;
|
|
213
|
+
textColorTertiaryHover: string;
|
|
214
|
+
borderColorTertiary: string;
|
|
215
|
+
colorTertiaryDisabled: string;
|
|
216
|
+
borderColorTertiaryDisabled: string;
|
|
217
|
+
colorTertiaryNegative: string;
|
|
218
|
+
colorTertiaryNegativeHover: string;
|
|
219
|
+
textColorTertiaryNegative: string;
|
|
220
|
+
textColorTertiaryNegativeHover: string;
|
|
221
|
+
borderColorTertiaryNegative: string;
|
|
222
|
+
colorTertiaryNegativeDisabled: string;
|
|
223
|
+
borderColorTertiaryNegativeDisabled: string;
|
|
224
|
+
colorGhost: string;
|
|
225
|
+
colorGhostHover: string;
|
|
226
|
+
textColorGhost: string;
|
|
227
|
+
textColorGhostHover: string;
|
|
228
|
+
borderColorGhost: string;
|
|
229
|
+
colorGhostDisabled: string;
|
|
230
|
+
borderColorGhostDisabled: string;
|
|
231
|
+
colorGhostNegative: string;
|
|
232
|
+
colorGhostNegativeHover: string;
|
|
233
|
+
textColorGhostNegative: string;
|
|
234
|
+
textColorGhostNegativeHover: string;
|
|
235
|
+
borderColorGhostNegative: string;
|
|
236
|
+
colorGhostNegativeDisabled: string;
|
|
237
|
+
borderColorGhostNegativeDisabled: string;
|
|
238
|
+
heightSmall: string;
|
|
239
|
+
heightMedium: string;
|
|
240
|
+
heightLarge: string;
|
|
241
|
+
paddingSmall: string;
|
|
242
|
+
paddingMedium: string;
|
|
243
|
+
paddingLarge: string;
|
|
244
|
+
borderRadiusSmall: string;
|
|
245
|
+
borderRadiusMedium: string;
|
|
246
|
+
borderRadiusLarge: string;
|
|
247
|
+
iconSizeSmall: string;
|
|
248
|
+
iconSizeMedium: string;
|
|
249
|
+
iconSizeLarge: string;
|
|
250
|
+
iconMargin: string;
|
|
251
|
+
borderWidth: string;
|
|
252
|
+
focusRingWidth: string;
|
|
253
|
+
spinnerStrokeWidth: string;
|
|
254
|
+
}, any>>>;
|
|
255
|
+
};
|
|
256
|
+
export interface ButtonV3Slots {
|
|
257
|
+
default?: () => VNode[];
|
|
258
|
+
'icon-start'?: () => VNode[];
|
|
259
|
+
'icon-end'?: () => VNode[];
|
|
260
|
+
}
|
|
261
|
+
export interface ButtonV3ThemeSelfVars {
|
|
262
|
+
[key: string]: string;
|
|
263
|
+
}
|
|
264
|
+
export interface ButtonV3IconSlotOptions {
|
|
265
|
+
clsPrefix: string;
|
|
266
|
+
slot: (() => VNode[]) | undefined;
|
|
267
|
+
showSpinner: boolean;
|
|
268
|
+
strokeWidth: number;
|
|
269
|
+
key: string;
|
|
270
|
+
}
|
|
271
|
+
export type ButtonV3Type = 'primary' | 'secondary' | 'tertiary' | 'ghost';
|
|
272
|
+
export type ButtonV3Tone = 'default' | 'negative';
|
|
273
|
+
export type ButtonV3Size = 'small' | 'medium' | 'large';
|
|
274
|
+
export type ButtonV3Tag = keyof HTMLElementTagNameMap;
|
|
275
|
+
export type ButtonV3AttrType = 'button' | 'submit' | 'reset';
|
|
276
|
+
export type ButtonV3VariantKey = 'primary' | 'primaryNegative' | 'secondary' | 'tertiary' | 'tertiaryNegative' | 'ghost' | 'ghostNegative';
|
|
277
|
+
export type ButtonV3ClickHandler = MaybeArray<(e: MouseEvent) => void>;
|
|
278
|
+
export type ButtonV3Props = ExtractPublicPropTypes<typeof buttonV3Props>;
|
|
279
|
+
export type InternalButtonV3Props = ExtractPropTypes<typeof buttonV3Props>;
|
|
280
|
+
export type ButtonV3NativeProps = Omit<ButtonHTMLAttributes, keyof InternalButtonV3Props>;
|
|
281
|
+
export type ButtonV3MergedProps = Partial<InternalButtonV3Props & ButtonV3NativeProps>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useTheme } from "../../../_mixins/index.mjs";
|
|
2
|
+
export const buttonV3Props = Object.assign(Object.assign({}, useTheme.props), {
|
|
3
|
+
type: {
|
|
4
|
+
type: String,
|
|
5
|
+
default: 'primary'
|
|
6
|
+
},
|
|
7
|
+
tone: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: 'default'
|
|
10
|
+
},
|
|
11
|
+
size: String,
|
|
12
|
+
iconOnly: Boolean,
|
|
13
|
+
block: Boolean,
|
|
14
|
+
disabled: Boolean,
|
|
15
|
+
loading: Boolean,
|
|
16
|
+
focusable: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: true
|
|
19
|
+
},
|
|
20
|
+
tag: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: 'button'
|
|
23
|
+
},
|
|
24
|
+
attrType: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: 'button'
|
|
27
|
+
},
|
|
28
|
+
onClick: [Function, Array]
|
|
29
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { c, cB, cE, cM, cNotM } from "../../../../_utils/cssr/index.mjs";
|
|
2
|
+
export default c([c('@keyframes u-button-v3-spin', `
|
|
3
|
+
from {
|
|
4
|
+
transform: rotate(0deg);
|
|
5
|
+
}
|
|
6
|
+
to {
|
|
7
|
+
transform: rotate(360deg);
|
|
8
|
+
}
|
|
9
|
+
`), cB('button-v3', `
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
position: relative;
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
flex-wrap: nowrap;
|
|
14
|
+
flex-shrink: 0;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
gap: var(--u-icon-margin);
|
|
18
|
+
margin: 0;
|
|
19
|
+
max-width: 100%;
|
|
20
|
+
height: var(--u-height);
|
|
21
|
+
padding: var(--u-padding);
|
|
22
|
+
border: var(--u-border-width) solid var(--u-border-color);
|
|
23
|
+
border-radius: var(--u-border-radius);
|
|
24
|
+
background-color: var(--u-color);
|
|
25
|
+
color: var(--u-text-color);
|
|
26
|
+
font-family: var(--u-font-family);
|
|
27
|
+
font-size: var(--u-font-size);
|
|
28
|
+
line-height: var(--u-line-height);
|
|
29
|
+
font-weight: var(--u-font-weight);
|
|
30
|
+
letter-spacing: var(--u-letter-spacing);
|
|
31
|
+
text-align: center;
|
|
32
|
+
text-decoration: none;
|
|
33
|
+
white-space: nowrap;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
outline: none;
|
|
36
|
+
user-select: none;
|
|
37
|
+
-webkit-user-select: none;
|
|
38
|
+
-webkit-tap-highlight-color: transparent;
|
|
39
|
+
transition:
|
|
40
|
+
color .3s var(--u-bezier),
|
|
41
|
+
background-color .3s var(--u-bezier),
|
|
42
|
+
border-color .3s var(--u-bezier);
|
|
43
|
+
`, [c('&::after', `
|
|
44
|
+
content: "";
|
|
45
|
+
position: absolute;
|
|
46
|
+
inset: calc(var(--u-border-width) * -1);
|
|
47
|
+
z-index: 0;
|
|
48
|
+
border-radius: inherit;
|
|
49
|
+
background-color: var(--u-pressed-overlay-color);
|
|
50
|
+
opacity: 0;
|
|
51
|
+
pointer-events: none;
|
|
52
|
+
transition: opacity .2s var(--u-bezier);
|
|
53
|
+
`), cE('label', `
|
|
54
|
+
position: relative;
|
|
55
|
+
z-index: 1;
|
|
56
|
+
min-width: 0;
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
text-overflow: ellipsis;
|
|
59
|
+
white-space: nowrap;
|
|
60
|
+
`), cE('icon', `
|
|
61
|
+
position: relative;
|
|
62
|
+
z-index: 1;
|
|
63
|
+
display: inline-flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
flex: none;
|
|
67
|
+
width: var(--u-icon-size);
|
|
68
|
+
height: var(--u-icon-size);
|
|
69
|
+
font-size: var(--u-icon-size);
|
|
70
|
+
line-height: 1;
|
|
71
|
+
`, [c('svg', `
|
|
72
|
+
width: 1em;
|
|
73
|
+
height: 1em;
|
|
74
|
+
`)]), cE('spinner', `
|
|
75
|
+
position: absolute;
|
|
76
|
+
z-index: 1;
|
|
77
|
+
top: 50%;
|
|
78
|
+
left: 50%;
|
|
79
|
+
transform: translate(-50%, -50%);
|
|
80
|
+
width: var(--u-icon-size);
|
|
81
|
+
height: var(--u-icon-size);
|
|
82
|
+
font-size: var(--u-icon-size);
|
|
83
|
+
line-height: 1;
|
|
84
|
+
`), cE('spinner-icon', `
|
|
85
|
+
display: block;
|
|
86
|
+
width: 100%;
|
|
87
|
+
height: 100%;
|
|
88
|
+
color: currentColor;
|
|
89
|
+
animation: u-button-v3-spin 1s linear infinite;
|
|
90
|
+
`), cM('block', `
|
|
91
|
+
display: flex;
|
|
92
|
+
width: 100%;
|
|
93
|
+
`), cM('icon-only', `
|
|
94
|
+
padding: 0;
|
|
95
|
+
width: var(--u-height);
|
|
96
|
+
`), cNotM('disabled', [c('&:hover', `
|
|
97
|
+
background-color: var(--u-color-hover);
|
|
98
|
+
color: var(--u-text-color-hover);
|
|
99
|
+
`), c('&:focus-visible', `
|
|
100
|
+
outline: var(--u-focus-ring-width) solid var(--u-focus-ring-color);
|
|
101
|
+
outline-offset: 0;
|
|
102
|
+
`), cNotM('loading', [c('&:active', `
|
|
103
|
+
background-color: var(--u-color);
|
|
104
|
+
`, [c('&::after', `
|
|
105
|
+
opacity: 1;
|
|
106
|
+
`)])])]), cM('ghost-type', [c('&::after', `
|
|
107
|
+
display: none;
|
|
108
|
+
`), cNotM('disabled', [c('&:focus-visible', `
|
|
109
|
+
color: var(--u-text-color-hover);
|
|
110
|
+
`)])]), cM('disabled', `
|
|
111
|
+
cursor: not-allowed;
|
|
112
|
+
background-color: var(--u-color-disabled);
|
|
113
|
+
border-color: var(--u-border-color-disabled);
|
|
114
|
+
color: var(--u-text-color-disabled);
|
|
115
|
+
`), cM('loading', `
|
|
116
|
+
cursor: default;
|
|
117
|
+
`), cM('loading-text-only', [cE('label', `
|
|
118
|
+
visibility: hidden;
|
|
119
|
+
`)])])]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { VNode } from 'vue';
|
|
2
|
+
import type { ButtonV3IconSlotOptions, ButtonV3Tone, ButtonV3Type, ButtonV3VariantKey } from './interface';
|
|
3
|
+
export declare const SPINNER_VIEWBOX = 100;
|
|
4
|
+
export declare const SPINNER_ARC = 0.75;
|
|
5
|
+
export declare const DEFAULT_SPINNER_STROKE_WIDTH = 18.5;
|
|
6
|
+
export declare function resolveVariantKey(type: ButtonV3Type, tone: ButtonV3Tone): ButtonV3VariantKey;
|
|
7
|
+
export declare function upperFirst(value: string): string;
|
|
8
|
+
export declare function resolveSpinnerStrokeWidth(iconSize: string, strokeWidth: string): number;
|
|
9
|
+
export declare function renderSpinner(clsPrefix: string, strokeWidth: number): VNode;
|
|
10
|
+
export declare function renderIconSlot(options: ButtonV3IconSlotOptions): VNode | null;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { h } from 'vue';
|
|
2
|
+
export const SPINNER_VIEWBOX = 100;
|
|
3
|
+
export const SPINNER_ARC = 0.75;
|
|
4
|
+
export const DEFAULT_SPINNER_STROKE_WIDTH = 18.5;
|
|
5
|
+
export function resolveVariantKey(type, tone) {
|
|
6
|
+
if (tone !== 'negative' || type === 'secondary') return type;
|
|
7
|
+
return `${type}Negative`;
|
|
8
|
+
}
|
|
9
|
+
export function upperFirst(value) {
|
|
10
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
11
|
+
}
|
|
12
|
+
export function resolveSpinnerStrokeWidth(iconSize, strokeWidth) {
|
|
13
|
+
const size = Number.parseFloat(iconSize);
|
|
14
|
+
const stroke = Number.parseFloat(strokeWidth);
|
|
15
|
+
if (!size || !stroke) return DEFAULT_SPINNER_STROKE_WIDTH;
|
|
16
|
+
return stroke / size * SPINNER_VIEWBOX;
|
|
17
|
+
}
|
|
18
|
+
export function renderSpinner(clsPrefix, strokeWidth) {
|
|
19
|
+
const radius = (SPINNER_VIEWBOX - strokeWidth) / 2;
|
|
20
|
+
const circumference = 2 * Math.PI * radius;
|
|
21
|
+
const arc = SPINNER_ARC * circumference;
|
|
22
|
+
return h('svg', {
|
|
23
|
+
class: `${clsPrefix}-button-v3__spinner-icon`,
|
|
24
|
+
viewBox: `0 0 ${SPINNER_VIEWBOX} ${SPINNER_VIEWBOX}`,
|
|
25
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
26
|
+
role: 'img',
|
|
27
|
+
'aria-label': 'loading'
|
|
28
|
+
}, [h('circle', {
|
|
29
|
+
cx: SPINNER_VIEWBOX / 2,
|
|
30
|
+
cy: SPINNER_VIEWBOX / 2,
|
|
31
|
+
r: radius,
|
|
32
|
+
fill: 'none',
|
|
33
|
+
stroke: 'currentColor',
|
|
34
|
+
'stroke-width': strokeWidth,
|
|
35
|
+
'stroke-linecap': 'round',
|
|
36
|
+
'stroke-dasharray': `${arc} ${circumference - arc}`
|
|
37
|
+
})]);
|
|
38
|
+
}
|
|
39
|
+
export function renderIconSlot(options) {
|
|
40
|
+
const {
|
|
41
|
+
clsPrefix,
|
|
42
|
+
slot,
|
|
43
|
+
showSpinner,
|
|
44
|
+
strokeWidth,
|
|
45
|
+
key
|
|
46
|
+
} = options;
|
|
47
|
+
if (!showSpinner && !slot) return null;
|
|
48
|
+
return h('span', {
|
|
49
|
+
key,
|
|
50
|
+
class: `${clsPrefix}-button-v3__icon`
|
|
51
|
+
}, showSpinner ? [renderSpinner(clsPrefix, strokeWidth)] : slot === null || slot === void 0 ? void 0 : slot());
|
|
52
|
+
}
|