mdui 2.0.3 → 2.0.5
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/components/avatar/index.d.ts +13 -13
- package/components/avatar/index.js +11 -6
- package/components/avatar/style.js +31 -1
- package/components/badge/index.d.ts +7 -6
- package/components/badge/index.js +6 -5
- package/components/badge/style.js +25 -1
- package/components/bottom-app-bar/index.d.ts +4 -3
- package/components/bottom-app-bar/index.js +3 -3
- package/components/bottom-app-bar/style.js +92 -1
- package/components/button/button-base-style.js +28 -1
- package/components/button/button-base.d.ts +43 -44
- package/components/button/button-base.js +28 -21
- package/components/button/index.d.ts +13 -13
- package/components/button/index.js +30 -20
- package/components/button/style.js +111 -2
- package/components/button-icon/index.d.ts +8 -8
- package/components/button-icon/index.js +29 -12
- package/components/button-icon/style.js +103 -2
- package/components/card/index.d.ts +8 -8
- package/components/card/index.js +12 -8
- package/components/card/style.js +72 -1
- package/components/checkbox/index.d.ts +20 -20
- package/components/checkbox/index.js +68 -25
- package/components/checkbox/style.js +131 -1
- package/components/chip/index.d.ts +19 -19
- package/components/chip/index.js +49 -25
- package/components/chip/style.js +205 -2
- package/components/circular-progress/index.d.ts +2 -2
- package/components/circular-progress/index.js +40 -6
- package/components/circular-progress/style.js +136 -1
- package/components/collapse/collapse-item-style.js +21 -1
- package/components/collapse/collapse-item.d.ts +4 -4
- package/components/collapse/collapse-item.js +12 -4
- package/components/collapse/collapse-style.js +5 -1
- package/components/collapse/collapse.d.ts +6 -9
- package/components/collapse/collapse.js +8 -5
- package/components/dialog/index.d.ts +13 -13
- package/components/dialog/index.js +48 -20
- package/components/dialog/style.js +116 -1
- package/components/divider/index.d.ts +3 -3
- package/components/divider/index.js +3 -3
- package/components/divider/style.js +18 -1
- package/components/dropdown/index.d.ts +35 -35
- package/components/dropdown/index.js +41 -34
- package/components/dropdown/style.js +11 -1
- package/components/fab/index.d.ts +6 -6
- package/components/fab/index.js +19 -11
- package/components/fab/style.js +153 -4
- package/components/icon/index.js +5 -1
- package/components/icon/style.js +29 -1
- package/components/layout/layout-item-style.js +6 -1
- package/components/layout/layout-item.d.ts +7 -7
- package/components/layout/layout-item.js +6 -6
- package/components/layout/layout-main-style.js +7 -1
- package/components/layout/layout-main.d.ts +2 -2
- package/components/layout/layout-main.js +2 -2
- package/components/layout/layout-style.js +11 -1
- package/components/layout/layout.d.ts +2 -2
- package/components/layout/layout.js +2 -2
- package/components/linear-progress/index.d.ts +4 -4
- package/components/linear-progress/index.js +9 -5
- package/components/linear-progress/style.js +73 -1
- package/components/list/list-item-style.js +153 -2
- package/components/list/list-item.d.ts +17 -17
- package/components/list/list-item.js +34 -15
- package/components/list/list-style.js +10 -1
- package/components/list/list-subheader-style.js +19 -1
- package/components/list/list-subheader.d.ts +2 -2
- package/components/list/list-subheader.js +2 -2
- package/components/list/list.d.ts +1 -1
- package/components/list/list.js +1 -1
- package/components/menu/menu-item-style.js +125 -1
- package/components/menu/menu-item.d.ts +4 -4
- package/components/menu/menu-item.js +57 -15
- package/components/menu/menu-style.js +19 -1
- package/components/menu/menu.d.ts +15 -18
- package/components/menu/menu.js +13 -9
- package/components/navigation-bar/navigation-bar-item-style.js +132 -1
- package/components/navigation-bar/navigation-bar-item.d.ts +5 -5
- package/components/navigation-bar/navigation-bar-item.js +27 -11
- package/components/navigation-bar/navigation-bar-style.js +28 -1
- package/components/navigation-bar/navigation-bar.d.ts +9 -8
- package/components/navigation-bar/navigation-bar.js +10 -7
- package/components/navigation-drawer/index.d.ts +19 -20
- package/components/navigation-drawer/index.js +56 -31
- package/components/navigation-drawer/style.js +66 -1
- package/components/navigation-rail/navigation-rail-item-style.js +122 -1
- package/components/navigation-rail/navigation-rail-item.d.ts +6 -6
- package/components/navigation-rail/navigation-rail-item.js +30 -11
- package/components/navigation-rail/navigation-rail-style.js +79 -1
- package/components/navigation-rail/navigation-rail.d.ts +10 -11
- package/components/navigation-rail/navigation-rail.js +19 -11
- package/components/radio/radio-group-style.js +20 -1
- package/components/radio/radio-group.d.ts +13 -13
- package/components/radio/radio-group.js +30 -12
- package/components/radio/radio-style.js +107 -1
- package/components/radio/radio.d.ts +3 -3
- package/components/radio/radio.js +26 -8
- package/components/range-slider/index.d.ts +5 -6
- package/components/range-slider/index.js +57 -10
- package/components/ripple/index.js +5 -2
- package/components/ripple/style.js +96 -1
- package/components/segmented-button/segmented-button-group-style.js +28 -1
- package/components/segmented-button/segmented-button-group.d.ts +17 -20
- package/components/segmented-button/segmented-button-group.js +32 -15
- package/components/segmented-button/segmented-button-style.js +81 -2
- package/components/segmented-button/segmented-button.d.ts +3 -3
- package/components/segmented-button/segmented-button.js +30 -14
- package/components/select/index.d.ts +31 -32
- package/components/select/index.js +106 -26
- package/components/select/style.js +27 -1
- package/components/slider/index.d.ts +1 -1
- package/components/slider/index.js +34 -3
- package/components/slider/slider-base-style.js +173 -1
- package/components/slider/slider-base.d.ts +15 -15
- package/components/slider/slider-base.js +19 -14
- package/components/slider/style.js +7 -1
- package/components/snackbar/index.d.ts +21 -21
- package/components/snackbar/index.js +47 -20
- package/components/snackbar/style.js +100 -1
- package/components/switch/index.d.ts +14 -14
- package/components/switch/index.js +51 -17
- package/components/switch/style.js +202 -1
- package/components/tabs/tab-panel-style.js +10 -1
- package/components/tabs/tab-panel.d.ts +3 -3
- package/components/tabs/tab-panel.js +2 -2
- package/components/tabs/tab-style.js +85 -1
- package/components/tabs/tab.d.ts +6 -6
- package/components/tabs/tab.js +29 -9
- package/components/tabs/tabs-style.js +138 -1
- package/components/tabs/tabs.d.ts +19 -19
- package/components/tabs/tabs.js +26 -18
- package/components/text-field/index.d.ts +51 -51
- package/components/text-field/index.js +185 -57
- package/components/text-field/style.js +362 -1
- package/components/tooltip/index.d.ts +31 -31
- package/components/tooltip/index.js +38 -29
- package/components/tooltip/style.js +57 -1
- package/components/top-app-bar/top-app-bar-style.js +78 -1
- package/components/top-app-bar/top-app-bar-title-style.js +81 -1
- package/components/top-app-bar/top-app-bar-title.d.ts +4 -4
- package/components/top-app-bar/top-app-bar-title.js +21 -7
- package/components/top-app-bar/top-app-bar.d.ts +5 -5
- package/components/top-app-bar/top-app-bar.js +4 -4
- package/css-data.en.json +2826 -0
- package/css-data.zh-cn.json +374 -367
- package/custom-elements.json +2049 -2049
- package/html-data.en.json +6560 -0
- package/html-data.zh-cn.json +1427 -1433
- package/jsx.en.d.ts +3303 -0
- package/jsx.zh-cn.d.ts +3351 -0
- package/package.json +6 -5
- package/web-types.en.json +11734 -0
- package/web-types.zh-cn.json +3227 -3221
- package/mdui.esm.js +0 -22
- package/mdui.global.js +0 -22
|
@@ -21,43 +21,43 @@ export class ButtonBase extends AnchorMixin(RippleMixin(FocusableMixin(MduiEleme
|
|
|
21
21
|
*/
|
|
22
22
|
this.disabled = false;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* 是否处于加载中状态
|
|
25
25
|
*/
|
|
26
26
|
this.loading = false;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* 按钮的名称,将与表单数据一起提交。
|
|
29
29
|
*
|
|
30
|
-
* **Note
|
|
30
|
+
* **Note**:仅在未设置 `href` 属性时,此属性才有效。
|
|
31
31
|
*/
|
|
32
32
|
this.name = '';
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* 按钮的初始值,将与表单数据一起提交。
|
|
35
35
|
*
|
|
36
|
-
* **Note
|
|
36
|
+
* **Note**:仅在未设置 `href` 属性时,此属性才有效。
|
|
37
37
|
*/
|
|
38
38
|
this.value = '';
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* 按钮的类型。默认类型为 `button`。可选类型包括:
|
|
41
41
|
*
|
|
42
|
-
* * `submit
|
|
43
|
-
* * `reset
|
|
44
|
-
* * `button
|
|
42
|
+
* * `submit`:点击按钮会提交表单数据到服务器
|
|
43
|
+
* * `reset`:点击按钮会将表单中的所有字段重置为初始值
|
|
44
|
+
* * `button`:此类型的按钮没有默认行为
|
|
45
45
|
*
|
|
46
|
-
* **Note**:仅在未指定 `href`
|
|
46
|
+
* **Note**:仅在未指定 `href` 属性时,此属性才有效。
|
|
47
47
|
*/
|
|
48
48
|
this.type = 'button';
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* 如果设置了此属性,表单提交时将不执行表单验证。
|
|
51
51
|
*
|
|
52
|
-
*
|
|
52
|
+
* 如果设置了此属性,将覆盖 `<form>` 元素的 `novalidate` 属性。
|
|
53
53
|
*
|
|
54
|
-
* **Note
|
|
54
|
+
* **Note**:仅在未设置 `href` 属性且 `type="submit"` 时,此属性才有效。
|
|
55
55
|
*/
|
|
56
56
|
this.formNoValidate = false;
|
|
57
57
|
this.formController = new FormController(this);
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
61
61
|
*/
|
|
62
62
|
get validity() {
|
|
63
63
|
if (this.isButton()) {
|
|
@@ -65,7 +65,7 @@ export class ButtonBase extends AnchorMixin(RippleMixin(FocusableMixin(MduiEleme
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
69
69
|
*/
|
|
70
70
|
get validationMessage() {
|
|
71
71
|
if (this.isButton()) {
|
|
@@ -86,7 +86,7 @@ export class ButtonBase extends AnchorMixin(RippleMixin(FocusableMixin(MduiEleme
|
|
|
86
86
|
return this.disabled || this.loading;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
89
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
90
90
|
*/
|
|
91
91
|
checkValidity() {
|
|
92
92
|
if (this.isButton()) {
|
|
@@ -104,9 +104,9 @@ export class ButtonBase extends AnchorMixin(RippleMixin(FocusableMixin(MduiEleme
|
|
|
104
104
|
return true;
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
|
-
*
|
|
107
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
108
108
|
*
|
|
109
|
-
*
|
|
109
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
110
110
|
*/
|
|
111
111
|
reportValidity() {
|
|
112
112
|
if (this.isButton()) {
|
|
@@ -125,9 +125,9 @@ export class ButtonBase extends AnchorMixin(RippleMixin(FocusableMixin(MduiEleme
|
|
|
125
125
|
return true;
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
|
-
*
|
|
128
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
129
129
|
*
|
|
130
|
-
* @param message
|
|
130
|
+
* @param message 自定义的错误提示文本
|
|
131
131
|
*/
|
|
132
132
|
setCustomValidity(message) {
|
|
133
133
|
if (this.isButton()) {
|
|
@@ -151,7 +151,14 @@ export class ButtonBase extends AnchorMixin(RippleMixin(FocusableMixin(MduiEleme
|
|
|
151
151
|
: nothingTemplate;
|
|
152
152
|
}
|
|
153
153
|
renderButton({ id, className, part, content = html `<slot></slot>`, }) {
|
|
154
|
-
return html `<button
|
|
154
|
+
return html `<button
|
|
155
|
+
id=${ifDefined(id)}
|
|
156
|
+
class=${cc(['_button', className])}
|
|
157
|
+
part=${ifDefined(part)}
|
|
158
|
+
?disabled=${this.rippleDisabled || this.focusDisabled}
|
|
159
|
+
>
|
|
160
|
+
${content}
|
|
161
|
+
</button>`;
|
|
155
162
|
}
|
|
156
163
|
isButton() {
|
|
157
164
|
return !this.href;
|
|
@@ -14,29 +14,29 @@ import type { TemplateResult, CSSResultGroup } from 'lit';
|
|
|
14
14
|
* @event invalid - 表单字段验证未通过时触发
|
|
15
15
|
*
|
|
16
16
|
* @slot - 按钮的文本
|
|
17
|
-
* @slot icon -
|
|
18
|
-
* @slot end-icon -
|
|
17
|
+
* @slot icon - 按钮左侧的元素
|
|
18
|
+
* @slot end-icon - 按钮右侧的元素
|
|
19
19
|
*
|
|
20
20
|
* @csspart button - 内部的 `<button>` 或 `<a>` 元素
|
|
21
|
-
* @csspart label -
|
|
22
|
-
* @csspart icon -
|
|
23
|
-
* @csspart end-icon -
|
|
21
|
+
* @csspart label - 按钮的文本
|
|
22
|
+
* @csspart icon - 按钮左侧的图标
|
|
23
|
+
* @csspart end-icon - 按钮右侧的图标
|
|
24
24
|
* @csspart loading - 加载中状态的 `<mdui-circular-progress>` 元素
|
|
25
25
|
*
|
|
26
|
-
* @cssprop --shape-corner -
|
|
26
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
27
27
|
*/
|
|
28
28
|
export declare class Button extends ButtonBase<ButtonEventMap> {
|
|
29
29
|
static styles: CSSResultGroup;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* 按钮的形状。可选值包括:
|
|
32
32
|
*
|
|
33
|
-
* * `elevated
|
|
34
|
-
* * `filled
|
|
35
|
-
* * `tonal`:视觉效果介于 `filled` 和 `outlined`
|
|
36
|
-
* * `outlined
|
|
37
|
-
* * `text
|
|
33
|
+
* * `elevated`:带阴影的按钮,适用于需要将按钮与背景视觉分离的场景
|
|
34
|
+
* * `filled`:视觉效果强烈,适用于重要流程的最终操作,如“保存”、“确认”等
|
|
35
|
+
* * `tonal`:视觉效果介于 `filled` 和 `outlined` 之间,适用于中高优先级的操作,如流程中的“下一步”
|
|
36
|
+
* * `outlined`:带边框的按钮,适用于中等优先级,且次要的操作,如“返回”
|
|
37
|
+
* * `text`:文本按钮,适用于最低优先级的操作
|
|
38
38
|
*/
|
|
39
|
-
variant:
|
|
39
|
+
variant: /*带阴影的按钮,适用于需要将按钮与背景视觉分离的场景*/ 'elevated' | /*视觉效果强烈,适用于重要流程的最终操作,如“保存”、“确认”等*/ 'filled' | /*视觉效果介于 `filled` 和 `outlined` 之间,适用于中高优先级的操作,如流程中的“下一步”*/ 'tonal' | /*带边框的按钮,适用于中等优先级,且次要的操作,如“返回”*/ 'outlined' | /*文本按钮,适用于最低优先级的操作*/ 'text';
|
|
40
40
|
/**
|
|
41
41
|
* 是否填满父元素宽度
|
|
42
42
|
*/
|
|
@@ -19,28 +19,28 @@ import { style } from './style.js';
|
|
|
19
19
|
* @event invalid - 表单字段验证未通过时触发
|
|
20
20
|
*
|
|
21
21
|
* @slot - 按钮的文本
|
|
22
|
-
* @slot icon -
|
|
23
|
-
* @slot end-icon -
|
|
22
|
+
* @slot icon - 按钮左侧的元素
|
|
23
|
+
* @slot end-icon - 按钮右侧的元素
|
|
24
24
|
*
|
|
25
25
|
* @csspart button - 内部的 `<button>` 或 `<a>` 元素
|
|
26
|
-
* @csspart label -
|
|
27
|
-
* @csspart icon -
|
|
28
|
-
* @csspart end-icon -
|
|
26
|
+
* @csspart label - 按钮的文本
|
|
27
|
+
* @csspart icon - 按钮左侧的图标
|
|
28
|
+
* @csspart end-icon - 按钮右侧的图标
|
|
29
29
|
* @csspart loading - 加载中状态的 `<mdui-circular-progress>` 元素
|
|
30
30
|
*
|
|
31
|
-
* @cssprop --shape-corner -
|
|
31
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
32
32
|
*/
|
|
33
33
|
let Button = class Button extends ButtonBase {
|
|
34
34
|
constructor() {
|
|
35
35
|
super(...arguments);
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* 按钮的形状。可选值包括:
|
|
38
38
|
*
|
|
39
|
-
* * `elevated
|
|
40
|
-
* * `filled
|
|
41
|
-
* * `tonal`:视觉效果介于 `filled` 和 `outlined`
|
|
42
|
-
* * `outlined
|
|
43
|
-
* * `text
|
|
39
|
+
* * `elevated`:带阴影的按钮,适用于需要将按钮与背景视觉分离的场景
|
|
40
|
+
* * `filled`:视觉效果强烈,适用于重要流程的最终操作,如“保存”、“确认”等
|
|
41
|
+
* * `tonal`:视觉效果介于 `filled` 和 `outlined` 之间,适用于中高优先级的操作,如流程中的“下一步”
|
|
42
|
+
* * `outlined`:带边框的按钮,适用于中等优先级,且次要的操作,如“返回”
|
|
43
|
+
* * `text`:文本按钮,适用于最低优先级的操作
|
|
44
44
|
*/
|
|
45
45
|
this.variant = 'filled';
|
|
46
46
|
/**
|
|
@@ -53,14 +53,20 @@ let Button = class Button extends ButtonBase {
|
|
|
53
53
|
return this.rippleRef.value;
|
|
54
54
|
}
|
|
55
55
|
render() {
|
|
56
|
-
return html `<mdui-ripple
|
|
56
|
+
return html `<mdui-ripple
|
|
57
|
+
${ref(this.rippleRef)}
|
|
58
|
+
.noRipple=${this.noRipple}
|
|
59
|
+
></mdui-ripple>
|
|
60
|
+
${this.isButton()
|
|
57
61
|
? this.renderButton({
|
|
58
62
|
className: 'button',
|
|
59
63
|
part: 'button',
|
|
60
64
|
content: this.renderInner(),
|
|
61
65
|
})
|
|
62
66
|
: this.disabled || this.loading
|
|
63
|
-
? html `<span part="button" class="button _a"
|
|
67
|
+
? html `<span part="button" class="button _a">
|
|
68
|
+
${this.renderInner()}
|
|
69
|
+
</span>`
|
|
64
70
|
: this.renderAnchor({
|
|
65
71
|
className: 'button',
|
|
66
72
|
part: 'button',
|
|
@@ -71,17 +77,21 @@ let Button = class Button extends ButtonBase {
|
|
|
71
77
|
if (this.loading) {
|
|
72
78
|
return this.renderLoading();
|
|
73
79
|
}
|
|
74
|
-
return html `<slot name="icon" part="icon" class="icon"
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
return html `<slot name="icon" part="icon" class="icon">
|
|
81
|
+
${this.icon
|
|
82
|
+
? html `<mdui-icon name=${this.icon}></mdui-icon>`
|
|
83
|
+
: nothingTemplate}
|
|
84
|
+
</slot>`;
|
|
77
85
|
}
|
|
78
86
|
renderLabel() {
|
|
79
87
|
return html `<slot part="label" class="label"></slot>`;
|
|
80
88
|
}
|
|
81
89
|
renderEndIcon() {
|
|
82
|
-
return html `<slot name="end-icon" part="end-icon" class="end-icon"
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
return html `<slot name="end-icon" part="end-icon" class="end-icon">
|
|
91
|
+
${this.endIcon
|
|
92
|
+
? html `<mdui-icon name=${this.endIcon}></mdui-icon>`
|
|
93
|
+
: nothingTemplate}
|
|
94
|
+
</slot>`;
|
|
85
95
|
}
|
|
86
96
|
renderInner() {
|
|
87
97
|
return [this.renderIcon(), this.renderLabel(), this.renderEndIcon()];
|
|
@@ -1,4 +1,113 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css
|
|
2
|
+
export const style = css `
|
|
3
|
+
/**
|
|
4
|
+
* mdui-button 组件。默认为 variant="text"
|
|
5
|
+
*/
|
|
6
|
+
:host {
|
|
7
|
+
--shape-corner: var(--mdui-shape-corner-full);
|
|
8
|
+
position: relative;
|
|
9
|
+
display: inline-block;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
text-align: center;
|
|
12
|
+
border-radius: var(--shape-corner);
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
-webkit-tap-highlight-color: transparent;
|
|
15
|
+
transition: box-shadow var(--mdui-motion-duration-short4)
|
|
16
|
+
var(--mdui-motion-easing-linear);
|
|
17
|
+
min-width: 3rem;
|
|
18
|
+
height: 2.5rem;
|
|
19
|
+
color: rgb(var(--mdui-color-primary));
|
|
20
|
+
font-size: var(--mdui-typescale-label-large-size);
|
|
21
|
+
font-weight: var(--mdui-typescale-label-large-weight);
|
|
22
|
+
letter-spacing: var(--mdui-typescale-label-large-tracking);
|
|
23
|
+
line-height: var(--mdui-typescale-label-large-line-height);
|
|
24
|
+
}
|
|
25
|
+
.button {
|
|
26
|
+
width: 100%;
|
|
27
|
+
padding: 0rem 1rem;
|
|
28
|
+
}
|
|
29
|
+
:host([full-width]) {
|
|
30
|
+
display: block;
|
|
31
|
+
}
|
|
32
|
+
:host([variant='elevated']) {
|
|
33
|
+
box-shadow: var(--mdui-elevation-level1);
|
|
34
|
+
background-color: rgb(var(--mdui-color-surface-container-low));
|
|
35
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
|
|
36
|
+
}
|
|
37
|
+
:host([variant='filled']) {
|
|
38
|
+
color: rgb(var(--mdui-color-on-primary));
|
|
39
|
+
background-color: rgb(var(--mdui-color-primary));
|
|
40
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-primary);
|
|
41
|
+
}
|
|
42
|
+
:host([variant='tonal']) {
|
|
43
|
+
color: rgb(var(--mdui-color-on-secondary-container));
|
|
44
|
+
background-color: rgb(var(--mdui-color-secondary-container));
|
|
45
|
+
--mdui-comp-ripple-state-layer-color: var(
|
|
3
46
|
--mdui-color-on-secondary-container
|
|
4
|
-
)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
:host([variant='outlined']) {
|
|
50
|
+
border: 0.0625rem solid rgb(var(--mdui-color-outline));
|
|
51
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
|
|
52
|
+
}
|
|
53
|
+
:host([variant='text']) {
|
|
54
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
|
|
55
|
+
}
|
|
56
|
+
:host([variant='outlined'][focus-visible]) {
|
|
57
|
+
border-color: rgb(var(--mdui-color-primary));
|
|
58
|
+
}
|
|
59
|
+
:host([variant='elevated'][hover]) {
|
|
60
|
+
box-shadow: var(--mdui-elevation-level2);
|
|
61
|
+
}
|
|
62
|
+
:host([variant='filled'][hover]),
|
|
63
|
+
:host([variant='tonal'][hover]) {
|
|
64
|
+
box-shadow: var(--mdui-elevation-level1);
|
|
65
|
+
}
|
|
66
|
+
:host([disabled]),
|
|
67
|
+
:host([loading]) {
|
|
68
|
+
cursor: default;
|
|
69
|
+
pointer-events: none;
|
|
70
|
+
}
|
|
71
|
+
:host([disabled]) {
|
|
72
|
+
color: rgba(var(--mdui-color-on-surface), 38%);
|
|
73
|
+
box-shadow: var(--mdui-elevation-level0);
|
|
74
|
+
}
|
|
75
|
+
:host([variant='elevated'][disabled]),
|
|
76
|
+
:host([variant='filled'][disabled]),
|
|
77
|
+
:host([variant='tonal'][disabled]) {
|
|
78
|
+
background-color: rgba(var(--mdui-color-on-surface), 12%);
|
|
79
|
+
}
|
|
80
|
+
:host([variant='outlined'][disabled]) {
|
|
81
|
+
border-color: rgba(var(--mdui-color-on-surface), 12%);
|
|
82
|
+
}
|
|
83
|
+
.label {
|
|
84
|
+
display: inline-flex;
|
|
85
|
+
padding-right: 0.5rem;
|
|
86
|
+
padding-left: 0.5rem;
|
|
87
|
+
}
|
|
88
|
+
.icon,
|
|
89
|
+
.end-icon {
|
|
90
|
+
display: inline-flex;
|
|
91
|
+
font-size: 1.28571429em;
|
|
92
|
+
}
|
|
93
|
+
.icon mdui-icon,
|
|
94
|
+
.end-icon mdui-icon,
|
|
95
|
+
::slotted([slot='icon']),
|
|
96
|
+
::slotted([slot='end-icon']) {
|
|
97
|
+
font-size: inherit;
|
|
98
|
+
}
|
|
99
|
+
mdui-circular-progress {
|
|
100
|
+
display: inline-flex;
|
|
101
|
+
width: 1.125rem;
|
|
102
|
+
height: 1.125rem;
|
|
103
|
+
}
|
|
104
|
+
:host([variant='filled']) mdui-circular-progress {
|
|
105
|
+
stroke: rgb(var(--mdui-color-on-primary));
|
|
106
|
+
}
|
|
107
|
+
:host([variant='tonal']) mdui-circular-progress {
|
|
108
|
+
stroke: rgb(var(--mdui-color-on-secondary-container));
|
|
109
|
+
}
|
|
110
|
+
:host([disabled]) mdui-circular-progress {
|
|
111
|
+
stroke: rgba(var(--mdui-color-on-surface), 38%);
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
@@ -22,19 +22,19 @@ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
|
22
22
|
* @csspart selected-icon 选中状态的图标
|
|
23
23
|
* @csspart loading - 加载中状态的 `<mdui-circular-progress>` 元素
|
|
24
24
|
*
|
|
25
|
-
* @cssprop --shape-corner -
|
|
25
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
26
26
|
*/
|
|
27
27
|
export declare class ButtonIcon extends ButtonBase<ButtonIconEventMap> {
|
|
28
28
|
static styles: CSSResultGroup;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* 图标按钮的形状。可选值包括:
|
|
31
31
|
*
|
|
32
|
-
* * `standard
|
|
33
|
-
* * `filled
|
|
34
|
-
* * `tonal`:视觉效果介于 `filled` 和 `outlined`
|
|
35
|
-
* * `outlined
|
|
32
|
+
* * `standard`:适用于最低优先级的操作
|
|
33
|
+
* * `filled`:视觉效果强烈,适用于高优先级的操作
|
|
34
|
+
* * `tonal`:视觉效果介于 `filled` 和 `outlined` 之间,适用于中高优先级的操作
|
|
35
|
+
* * `outlined`:适用于中等优先级的操作
|
|
36
36
|
*/
|
|
37
|
-
variant:
|
|
37
|
+
variant: /*适用于最低优先级的操作*/ 'standard' | /*视觉效果强烈,适用于高优先级的操作*/ 'filled' | /*视觉效果介于 `filled` 和 `outlined` 之间,适用于中高优先级的操作*/ 'tonal' | /*适用于中等优先级的操作*/ 'outlined';
|
|
38
38
|
/**
|
|
39
39
|
* Material Icons 图标名。也可以通过 default slot 设置
|
|
40
40
|
*/
|
|
@@ -48,7 +48,7 @@ export declare class ButtonIcon extends ButtonBase<ButtonIconEventMap> {
|
|
|
48
48
|
*/
|
|
49
49
|
selectable: boolean;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* 是否已被选中
|
|
52
52
|
*/
|
|
53
53
|
selected: boolean;
|
|
54
54
|
private readonly rippleRef;
|
|
@@ -29,18 +29,18 @@ import { style } from './style.js';
|
|
|
29
29
|
* @csspart selected-icon 选中状态的图标
|
|
30
30
|
* @csspart loading - 加载中状态的 `<mdui-circular-progress>` 元素
|
|
31
31
|
*
|
|
32
|
-
* @cssprop --shape-corner -
|
|
32
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
33
33
|
*/
|
|
34
34
|
let ButtonIcon = class ButtonIcon extends ButtonBase {
|
|
35
35
|
constructor() {
|
|
36
36
|
super(...arguments);
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* 图标按钮的形状。可选值包括:
|
|
39
39
|
*
|
|
40
|
-
* * `standard
|
|
41
|
-
* * `filled
|
|
42
|
-
* * `tonal`:视觉效果介于 `filled` 和 `outlined`
|
|
43
|
-
* * `outlined
|
|
40
|
+
* * `standard`:适用于最低优先级的操作
|
|
41
|
+
* * `filled`:视觉效果强烈,适用于高优先级的操作
|
|
42
|
+
* * `tonal`:视觉效果介于 `filled` 和 `outlined` 之间,适用于中高优先级的操作
|
|
43
|
+
* * `outlined`:适用于中等优先级的操作
|
|
44
44
|
*/
|
|
45
45
|
this.variant = 'standard';
|
|
46
46
|
/**
|
|
@@ -48,7 +48,7 @@ let ButtonIcon = class ButtonIcon extends ButtonBase {
|
|
|
48
48
|
*/
|
|
49
49
|
this.selectable = false;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* 是否已被选中
|
|
52
52
|
*/
|
|
53
53
|
this.selected = false;
|
|
54
54
|
this.rippleRef = createRef();
|
|
@@ -70,28 +70,45 @@ let ButtonIcon = class ButtonIcon extends ButtonBase {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
render() {
|
|
73
|
-
return html `<mdui-ripple
|
|
73
|
+
return html `<mdui-ripple
|
|
74
|
+
${ref(this.rippleRef)}
|
|
75
|
+
.noRipple=${this.noRipple}
|
|
76
|
+
></mdui-ripple>
|
|
77
|
+
${this.isButton()
|
|
74
78
|
? this.renderButton({
|
|
75
79
|
className: 'button',
|
|
76
80
|
part: 'button',
|
|
77
81
|
content: this.renderIcon(),
|
|
78
82
|
})
|
|
79
83
|
: this.disabled || this.loading
|
|
80
|
-
? html `<span part="button" class="button _a"
|
|
84
|
+
? html `<span part="button" class="button _a">
|
|
85
|
+
${this.renderIcon()}
|
|
86
|
+
</span>`
|
|
81
87
|
: this.renderAnchor({
|
|
82
88
|
className: 'button',
|
|
83
89
|
part: 'button',
|
|
84
90
|
content: this.renderIcon(),
|
|
85
|
-
})}
|
|
91
|
+
})}
|
|
92
|
+
${this.renderLoading()}`;
|
|
86
93
|
}
|
|
87
94
|
renderIcon() {
|
|
88
95
|
const icon = () => this.hasSlotController.test('[default]')
|
|
89
96
|
? html `<slot></slot>`
|
|
90
97
|
: this.icon
|
|
91
|
-
? html `<mdui-icon
|
|
98
|
+
? html `<mdui-icon
|
|
99
|
+
part="icon"
|
|
100
|
+
class="icon"
|
|
101
|
+
name=${this.icon}
|
|
102
|
+
></mdui-icon>`
|
|
92
103
|
: nothingTemplate;
|
|
93
104
|
const selectedIcon = () => this.hasSlotController.test('selected-icon') || this.selectedIcon
|
|
94
|
-
? html `<slot
|
|
105
|
+
? html `<slot
|
|
106
|
+
name="selected-icon"
|
|
107
|
+
part="selected-icon"
|
|
108
|
+
class="selected-icon"
|
|
109
|
+
>
|
|
110
|
+
<mdui-icon name=${this.selectedIcon}></mdui-icon>
|
|
111
|
+
</slot>`
|
|
95
112
|
: icon();
|
|
96
113
|
return this.selected ? selectedIcon() : icon();
|
|
97
114
|
}
|
|
@@ -1,4 +1,105 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css
|
|
2
|
+
export const style = css `
|
|
3
|
+
:host {
|
|
4
|
+
--shape-corner: var(--mdui-shape-corner-full);
|
|
5
|
+
position: relative;
|
|
6
|
+
display: inline-block;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
text-align: center;
|
|
9
|
+
border-radius: var(--shape-corner);
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
-webkit-tap-highlight-color: transparent;
|
|
12
|
+
font-size: 1.5rem;
|
|
13
|
+
width: 2.5rem;
|
|
14
|
+
min-width: 2.5rem;
|
|
15
|
+
height: 2.5rem;
|
|
16
|
+
}
|
|
17
|
+
:host([variant='standard']) {
|
|
18
|
+
color: rgb(var(--mdui-color-on-surface-variant));
|
|
19
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface-variant);
|
|
20
|
+
}
|
|
21
|
+
:host([variant='filled']) {
|
|
22
|
+
color: rgb(var(--mdui-color-primary));
|
|
23
|
+
background-color: rgb(var(--mdui-color-surface-container-highest));
|
|
24
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
|
|
25
|
+
}
|
|
26
|
+
:host([variant='tonal']) {
|
|
27
|
+
color: rgb(var(--mdui-color-on-surface-variant));
|
|
28
|
+
background-color: rgb(var(--mdui-color-surface-container-highest));
|
|
29
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface-variant);
|
|
30
|
+
}
|
|
31
|
+
:host([variant='outlined']) {
|
|
32
|
+
border: 0.0625rem solid rgb(var(--mdui-color-outline));
|
|
33
|
+
color: rgb(var(--mdui-color-on-surface-variant));
|
|
34
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface-variant);
|
|
35
|
+
}
|
|
36
|
+
:host([variant='outlined'][pressed]) {
|
|
37
|
+
color: rgb(var(--mdui-color-on-surface));
|
|
38
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
|
|
39
|
+
}
|
|
40
|
+
:host([variant='standard'][selected]) {
|
|
41
|
+
color: rgb(var(--mdui-color-primary));
|
|
42
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
|
|
43
|
+
}
|
|
44
|
+
:host([variant='filled'][selected]),
|
|
45
|
+
:host([variant='filled']:not([selectable])) {
|
|
46
|
+
color: rgb(var(--mdui-color-on-primary));
|
|
47
|
+
background-color: rgb(var(--mdui-color-primary));
|
|
48
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-primary);
|
|
49
|
+
}
|
|
50
|
+
:host([variant='tonal'][selected]),
|
|
51
|
+
:host([variant='tonal']:not([selectable])) {
|
|
52
|
+
color: rgb(var(--mdui-color-on-secondary-container));
|
|
53
|
+
background-color: rgb(var(--mdui-color-secondary-container));
|
|
54
|
+
--mdui-comp-ripple-state-layer-color: var(
|
|
3
55
|
--mdui-color-on-secondary-container
|
|
4
|
-
)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
:host([variant='outlined'][selected]) {
|
|
59
|
+
border: none;
|
|
60
|
+
color: rgb(var(--mdui-color-inverse-on-surface));
|
|
61
|
+
background-color: rgb(var(--mdui-color-inverse-surface));
|
|
62
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-inverse-on-surface);
|
|
63
|
+
}
|
|
64
|
+
:host([variant='filled'][disabled]),
|
|
65
|
+
:host([variant='tonal'][disabled]),
|
|
66
|
+
:host([variant='outlined'][disabled]) {
|
|
67
|
+
background-color: rgba(var(--mdui-color-on-surface), 0.12);
|
|
68
|
+
border-color: rgba(var(--mdui-color-on-surface), 0.12);
|
|
69
|
+
}
|
|
70
|
+
:host([disabled]),
|
|
71
|
+
:host([loading]) {
|
|
72
|
+
cursor: default;
|
|
73
|
+
pointer-events: none;
|
|
74
|
+
}
|
|
75
|
+
:host([disabled]) {
|
|
76
|
+
color: rgba(var(--mdui-color-on-surface), 0.38) !important;
|
|
77
|
+
}
|
|
78
|
+
:host([loading]) mdui-ripple,
|
|
79
|
+
:host([loading]) .button {
|
|
80
|
+
opacity: 0;
|
|
81
|
+
}
|
|
82
|
+
.button {
|
|
83
|
+
float: left;
|
|
84
|
+
width: 100%;
|
|
85
|
+
}
|
|
86
|
+
.icon,
|
|
87
|
+
.selected-icon mdui-icon,
|
|
88
|
+
::slotted(*) {
|
|
89
|
+
font-size: inherit;
|
|
90
|
+
}
|
|
91
|
+
mdui-circular-progress {
|
|
92
|
+
display: flex;
|
|
93
|
+
position: absolute;
|
|
94
|
+
top: calc(50% - 1.5rem / 2);
|
|
95
|
+
left: calc(50% - 1.5rem / 2);
|
|
96
|
+
width: 1.5rem;
|
|
97
|
+
height: 1.5rem;
|
|
98
|
+
}
|
|
99
|
+
:host([variant='filled']:not([disabled])) mdui-circular-progress {
|
|
100
|
+
stroke: rgb(var(--mdui-color-on-primary));
|
|
101
|
+
}
|
|
102
|
+
:host([disabled]) mdui-circular-progress {
|
|
103
|
+
stroke: rgba(var(--mdui-color-on-surface), 38%);
|
|
104
|
+
}
|
|
105
|
+
`;
|
|
@@ -12,22 +12,22 @@ declare const Card_base: import("@open-wc/dedupe-mixin").Constructor<import("@md
|
|
|
12
12
|
* @event focus - 获得焦点时触发
|
|
13
13
|
* @event blur - 失去焦点时触发
|
|
14
14
|
*
|
|
15
|
-
* @slot -
|
|
15
|
+
* @slot - 卡片的内容
|
|
16
16
|
*
|
|
17
|
-
* @cssprop --shape-corner -
|
|
17
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
18
18
|
*/
|
|
19
19
|
export declare class Card extends Card_base<CardEventMap> {
|
|
20
20
|
static styles: CSSResultGroup;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* 卡片的形状。可选值包括:
|
|
23
23
|
*
|
|
24
|
-
* * `elevated
|
|
25
|
-
* * `filled
|
|
26
|
-
* * `outlined
|
|
24
|
+
* * `elevated`:带阴影的卡片,与背景的视觉分离度较高
|
|
25
|
+
* * `filled`:带填充色的卡片,与背景的视觉分离度较低
|
|
26
|
+
* * `outlined`:带边框的卡片,与背景的视觉分离度最高
|
|
27
27
|
*/
|
|
28
|
-
variant:
|
|
28
|
+
variant: /*带阴影的卡片,与背景的视觉分离度较高*/ 'elevated' | /*带填充色的卡片,与背景的视觉分离度较低*/ 'filled' | /*带边框的卡片,与背景的视觉分离度最高*/ 'outlined';
|
|
29
29
|
/**
|
|
30
|
-
* 是否可点击。为 `true`
|
|
30
|
+
* 是否可点击。为 `true` 时,卡片将具有鼠标悬浮效果和点击涟漪效果
|
|
31
31
|
*/
|
|
32
32
|
clickable: boolean;
|
|
33
33
|
/**
|