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
package/components/card/index.js
CHANGED
|
@@ -19,23 +19,23 @@ import { style } from './style.js';
|
|
|
19
19
|
* @event focus - 获得焦点时触发
|
|
20
20
|
* @event blur - 失去焦点时触发
|
|
21
21
|
*
|
|
22
|
-
* @slot -
|
|
22
|
+
* @slot - 卡片的内容
|
|
23
23
|
*
|
|
24
|
-
* @cssprop --shape-corner -
|
|
24
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
25
25
|
*/
|
|
26
26
|
let Card = class Card extends AnchorMixin(RippleMixin(FocusableMixin(MduiElement))) {
|
|
27
27
|
constructor() {
|
|
28
28
|
super(...arguments);
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* 卡片的形状。可选值包括:
|
|
31
31
|
*
|
|
32
|
-
* * `elevated
|
|
33
|
-
* * `filled
|
|
34
|
-
* * `outlined
|
|
32
|
+
* * `elevated`:带阴影的卡片,与背景的视觉分离度较高
|
|
33
|
+
* * `filled`:带填充色的卡片,与背景的视觉分离度较低
|
|
34
|
+
* * `outlined`:带边框的卡片,与背景的视觉分离度最高
|
|
35
35
|
*/
|
|
36
36
|
this.variant = 'elevated';
|
|
37
37
|
/**
|
|
38
|
-
* 是否可点击。为 `true`
|
|
38
|
+
* 是否可点击。为 `true` 时,卡片将具有鼠标悬浮效果和点击涟漪效果
|
|
39
39
|
*/
|
|
40
40
|
this.clickable = false;
|
|
41
41
|
/**
|
|
@@ -59,7 +59,11 @@ let Card = class Card extends AnchorMixin(RippleMixin(FocusableMixin(MduiElement
|
|
|
59
59
|
return this.rippleDisabled;
|
|
60
60
|
}
|
|
61
61
|
render() {
|
|
62
|
-
return html `<mdui-ripple
|
|
62
|
+
return html `<mdui-ripple
|
|
63
|
+
${ref(this.rippleRef)}
|
|
64
|
+
.noRipple=${this.noRipple}
|
|
65
|
+
></mdui-ripple
|
|
66
|
+
>${this.href && !this.disabled
|
|
63
67
|
? this.renderAnchor({
|
|
64
68
|
className: 'link',
|
|
65
69
|
content: html `<slot></slot>`,
|
package/components/card/style.js
CHANGED
|
@@ -1,2 +1,73 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css
|
|
2
|
+
export const style = css `
|
|
3
|
+
/**
|
|
4
|
+
* mdui-card 组件。默认为 variant="elevated"
|
|
5
|
+
*/
|
|
6
|
+
:host {
|
|
7
|
+
--shape-corner: var(--mdui-shape-corner-medium);
|
|
8
|
+
position: relative;
|
|
9
|
+
display: inline-block;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
border-radius: var(--shape-corner);
|
|
12
|
+
-webkit-tap-highlight-color: transparent;
|
|
13
|
+
transition: box-shadow var(--mdui-motion-duration-short4)
|
|
14
|
+
var(--mdui-motion-easing-linear);
|
|
15
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
|
|
16
|
+
}
|
|
17
|
+
:host([clickable]) {
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
}
|
|
20
|
+
:host([variant='elevated']) {
|
|
21
|
+
background-color: rgb(var(--mdui-color-surface-container-low));
|
|
22
|
+
box-shadow: var(--mdui-elevation-level1);
|
|
23
|
+
}
|
|
24
|
+
:host([variant='filled']) {
|
|
25
|
+
background-color: rgb(var(--mdui-color-surface-container-highest));
|
|
26
|
+
}
|
|
27
|
+
:host([variant='outlined']) {
|
|
28
|
+
background-color: rgb(var(--mdui-color-surface));
|
|
29
|
+
border: 0.0625rem solid rgb(var(--mdui-color-outline));
|
|
30
|
+
}
|
|
31
|
+
:host([variant='elevated'][hover]) {
|
|
32
|
+
box-shadow: var(--mdui-elevation-level2);
|
|
33
|
+
}
|
|
34
|
+
:host([variant='filled'][hover]),
|
|
35
|
+
:host([variant='outlined'][hover]) {
|
|
36
|
+
box-shadow: var(--mdui-elevation-level1);
|
|
37
|
+
}
|
|
38
|
+
:host([variant='elevated'][dragged]),
|
|
39
|
+
:host([variant='filled'][dragged]),
|
|
40
|
+
:host([variant='outlined'][dragged]) {
|
|
41
|
+
box-shadow: var(--mdui-elevation-level3);
|
|
42
|
+
}
|
|
43
|
+
:host([disabled]) {
|
|
44
|
+
opacity: 0.38;
|
|
45
|
+
cursor: default;
|
|
46
|
+
-webkit-user-select: none;
|
|
47
|
+
user-select: none;
|
|
48
|
+
}
|
|
49
|
+
:host([variant='elevated'][disabled]) {
|
|
50
|
+
background-color: rgb(var(--mdui-color-surface-variant));
|
|
51
|
+
box-shadow: var(--mdui-elevation-level0);
|
|
52
|
+
}
|
|
53
|
+
:host([variant='filled'][disabled]) {
|
|
54
|
+
background-color: rgb(var(--mdui-color-surface));
|
|
55
|
+
box-shadow: var(--mdui-elevation-level1);
|
|
56
|
+
}
|
|
57
|
+
:host([variant='outlined'][disabled]) {
|
|
58
|
+
box-shadow: var(--mdui-elevation-level0);
|
|
59
|
+
border-color: rgba(var(--mdui-color-outline), 0.32);
|
|
60
|
+
}
|
|
61
|
+
.link {
|
|
62
|
+
position: relative;
|
|
63
|
+
display: inline-block;
|
|
64
|
+
width: 100%;
|
|
65
|
+
height: 100%;
|
|
66
|
+
color: inherit;
|
|
67
|
+
font-size: inherit;
|
|
68
|
+
letter-spacing: inherit;
|
|
69
|
+
text-decoration: none;
|
|
70
|
+
touch-action: manipulation;
|
|
71
|
+
-webkit-user-drag: none;
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
@@ -20,16 +20,16 @@ declare const Checkbox_base: import("@open-wc/dedupe-mixin").Constructor<import(
|
|
|
20
20
|
* @event input - 选中状态变更时触发
|
|
21
21
|
* @event invalid - 表单字段验证未通过时触发
|
|
22
22
|
*
|
|
23
|
-
* @slot -
|
|
24
|
-
* @slot unchecked-icon -
|
|
25
|
-
* @slot checked-icon -
|
|
26
|
-
* @slot indeterminate-icon -
|
|
23
|
+
* @slot - 复选框文本
|
|
24
|
+
* @slot unchecked-icon - 未选中状态的图标
|
|
25
|
+
* @slot checked-icon - 选中状态的图标
|
|
26
|
+
* @slot indeterminate-icon - 不确定状态的图标
|
|
27
27
|
*
|
|
28
28
|
* @csspart control - 左侧图标容器
|
|
29
|
-
* @csspart unchecked-icon -
|
|
30
|
-
* @csspart checked-icon -
|
|
31
|
-
* @csspart indeterminate-icon -
|
|
32
|
-
* @csspart label -
|
|
29
|
+
* @csspart unchecked-icon - 未选中状态的图标
|
|
30
|
+
* @csspart checked-icon - 选中状态的图标
|
|
31
|
+
* @csspart indeterminate-icon - 不确定状态的图标
|
|
32
|
+
* @csspart label - 复选框文本
|
|
33
33
|
*/
|
|
34
34
|
export declare class Checkbox extends Checkbox_base<CheckboxEventMap> implements FormControl {
|
|
35
35
|
static styles: CSSResultGroup;
|
|
@@ -42,21 +42,21 @@ export declare class Checkbox extends Checkbox_base<CheckboxEventMap> implements
|
|
|
42
42
|
*/
|
|
43
43
|
checked: boolean;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* 默认选中状态。在重置表单时,将恢复为此状态。此属性只能通过 JavaScript 属性设置
|
|
46
46
|
*/
|
|
47
47
|
defaultChecked: boolean;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* 是否处于不确定状态
|
|
50
50
|
*/
|
|
51
51
|
indeterminate: boolean;
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* 提交表单时,是否必须选中此复选框
|
|
54
54
|
*/
|
|
55
55
|
required: boolean;
|
|
56
56
|
/**
|
|
57
|
-
* 关联的
|
|
57
|
+
* 关联的 `<form>` 元素。此属性值应为同一页面中的一个 `<form>` 元素的 `id`。
|
|
58
58
|
*
|
|
59
|
-
*
|
|
59
|
+
* 如果未指定此属性,则该元素必须是 `<form>` 元素的子元素。通过此属性,你可以将元素放置在页面的任何位置,而不仅仅是 `<form>` 元素的子元素。
|
|
60
60
|
*/
|
|
61
61
|
form?: string;
|
|
62
62
|
/**
|
|
@@ -87,11 +87,11 @@ export declare class Checkbox extends Checkbox_base<CheckboxEventMap> implements
|
|
|
87
87
|
private readonly rippleRef;
|
|
88
88
|
private readonly formController;
|
|
89
89
|
/**
|
|
90
|
-
*
|
|
90
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
91
91
|
*/
|
|
92
92
|
get validity(): ValidityState;
|
|
93
93
|
/**
|
|
94
|
-
*
|
|
94
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
95
95
|
*/
|
|
96
96
|
get validationMessage(): string;
|
|
97
97
|
protected get rippleElement(): Ripple;
|
|
@@ -101,19 +101,19 @@ export declare class Checkbox extends Checkbox_base<CheckboxEventMap> implements
|
|
|
101
101
|
private onDisabledChange;
|
|
102
102
|
private onCheckedChange;
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
104
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
105
105
|
*/
|
|
106
106
|
checkValidity(): boolean;
|
|
107
107
|
/**
|
|
108
|
-
*
|
|
108
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
109
109
|
*
|
|
110
|
-
*
|
|
110
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
111
111
|
*/
|
|
112
112
|
reportValidity(): boolean;
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
115
115
|
*
|
|
116
|
-
* @param message
|
|
116
|
+
* @param message 自定义的错误提示文本
|
|
117
117
|
*/
|
|
118
118
|
setCustomValidity(message: string): void;
|
|
119
119
|
protected render(): TemplateResult;
|
|
@@ -31,16 +31,16 @@ import { style } from './style.js';
|
|
|
31
31
|
* @event input - 选中状态变更时触发
|
|
32
32
|
* @event invalid - 表单字段验证未通过时触发
|
|
33
33
|
*
|
|
34
|
-
* @slot -
|
|
35
|
-
* @slot unchecked-icon -
|
|
36
|
-
* @slot checked-icon -
|
|
37
|
-
* @slot indeterminate-icon -
|
|
34
|
+
* @slot - 复选框文本
|
|
35
|
+
* @slot unchecked-icon - 未选中状态的图标
|
|
36
|
+
* @slot checked-icon - 选中状态的图标
|
|
37
|
+
* @slot indeterminate-icon - 不确定状态的图标
|
|
38
38
|
*
|
|
39
39
|
* @csspart control - 左侧图标容器
|
|
40
|
-
* @csspart unchecked-icon -
|
|
41
|
-
* @csspart checked-icon -
|
|
42
|
-
* @csspart indeterminate-icon -
|
|
43
|
-
* @csspart label -
|
|
40
|
+
* @csspart unchecked-icon - 未选中状态的图标
|
|
41
|
+
* @csspart checked-icon - 选中状态的图标
|
|
42
|
+
* @csspart indeterminate-icon - 不确定状态的图标
|
|
43
|
+
* @csspart label - 复选框文本
|
|
44
44
|
*/
|
|
45
45
|
let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
46
46
|
constructor() {
|
|
@@ -54,15 +54,15 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
54
54
|
*/
|
|
55
55
|
this.checked = false;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* 默认选中状态。在重置表单时,将恢复为此状态。此属性只能通过 JavaScript 属性设置
|
|
58
58
|
*/
|
|
59
59
|
this.defaultChecked = false;
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* 是否处于不确定状态
|
|
62
62
|
*/
|
|
63
63
|
this.indeterminate = false;
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* 提交表单时,是否必须选中此复选框
|
|
66
66
|
*/
|
|
67
67
|
this.required = false;
|
|
68
68
|
/**
|
|
@@ -86,13 +86,13 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
89
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
90
90
|
*/
|
|
91
91
|
get validity() {
|
|
92
92
|
return this.inputRef.value.validity;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
|
-
*
|
|
95
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
96
96
|
*/
|
|
97
97
|
get validationMessage() {
|
|
98
98
|
return this.inputRef.value.validationMessage;
|
|
@@ -126,7 +126,7 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
|
-
*
|
|
129
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
130
130
|
*/
|
|
131
131
|
checkValidity() {
|
|
132
132
|
const valid = this.inputRef.value.checkValidity();
|
|
@@ -140,9 +140,9 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
140
140
|
return valid;
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
|
-
*
|
|
143
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
144
144
|
*
|
|
145
|
-
*
|
|
145
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
146
146
|
*/
|
|
147
147
|
reportValidity() {
|
|
148
148
|
this.invalid = !this.inputRef.value.reportValidity();
|
|
@@ -161,22 +161,65 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
161
161
|
return !this.invalid;
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
|
-
*
|
|
164
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
165
165
|
*
|
|
166
|
-
* @param message
|
|
166
|
+
* @param message 自定义的错误提示文本
|
|
167
167
|
*/
|
|
168
168
|
setCustomValidity(message) {
|
|
169
169
|
this.inputRef.value.setCustomValidity(message);
|
|
170
170
|
this.invalid = !this.inputRef.value.checkValidity();
|
|
171
171
|
}
|
|
172
172
|
render() {
|
|
173
|
-
return html `<label class="${classMap({ invalid: this.invalid })}"
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
173
|
+
return html `<label class="${classMap({ invalid: this.invalid })}">
|
|
174
|
+
<input
|
|
175
|
+
${ref(this.inputRef)}
|
|
176
|
+
type="checkbox"
|
|
177
|
+
name=${ifDefined(this.name)}
|
|
178
|
+
value=${ifDefined(this.value)}
|
|
179
|
+
.indeterminate=${live(this.indeterminate)}
|
|
180
|
+
.disabled=${this.disabled}
|
|
181
|
+
.checked=${live(this.checked)}
|
|
182
|
+
.required=${this.required}
|
|
183
|
+
@change=${this.onChange}
|
|
184
|
+
/>
|
|
185
|
+
<i part="control">
|
|
186
|
+
<mdui-ripple
|
|
187
|
+
${ref(this.rippleRef)}
|
|
188
|
+
.noRipple=${this.noRipple}
|
|
189
|
+
></mdui-ripple>
|
|
190
|
+
<slot
|
|
191
|
+
name="unchecked-icon"
|
|
192
|
+
part="unchecked-icon"
|
|
193
|
+
class="icon unchecked-icon"
|
|
194
|
+
>
|
|
195
|
+
${this.uncheckedIcon
|
|
196
|
+
? html `<mdui-icon name=${this.uncheckedIcon} class="i"></mdui-icon>`
|
|
197
|
+
: html `<mdui-icon-check-box-outline-blank
|
|
198
|
+
class="i"
|
|
199
|
+
></mdui-icon-check-box-outline-blank>`}
|
|
200
|
+
</slot>
|
|
201
|
+
<slot name="checked-icon" part="checked-icon" class="icon checked-icon">
|
|
202
|
+
${this.checkedIcon
|
|
203
|
+
? html `<mdui-icon name=${this.checkedIcon} class="i"></mdui-icon>`
|
|
204
|
+
: html `<mdui-icon-check-box class="i"></mdui-icon-check-box>`}
|
|
205
|
+
</slot>
|
|
206
|
+
<slot
|
|
207
|
+
name="indeterminate-icon"
|
|
208
|
+
part="indeterminate-icon"
|
|
209
|
+
class="icon indeterminate-icon"
|
|
210
|
+
>
|
|
211
|
+
${this.indeterminateIcon
|
|
212
|
+
? html `<mdui-icon
|
|
213
|
+
name=${this.indeterminateIcon}
|
|
214
|
+
class="i"
|
|
215
|
+
></mdui-icon>`
|
|
216
|
+
: html `<mdui-icon-indeterminate-check-box
|
|
217
|
+
class="i"
|
|
218
|
+
></mdui-icon-indeterminate-check-box>`}
|
|
219
|
+
</slot>
|
|
220
|
+
</i>
|
|
221
|
+
<slot part="label" class="label"></slot>
|
|
222
|
+
</label>`;
|
|
180
223
|
}
|
|
181
224
|
/**
|
|
182
225
|
* input[type="checkbox"] 的 change 事件无法冒泡越过 shadow dom
|
|
@@ -1,2 +1,132 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css
|
|
2
|
+
export const style = css `
|
|
3
|
+
:host {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
-webkit-tap-highlight-color: transparent;
|
|
8
|
+
border-radius: 0.125rem;
|
|
9
|
+
font-size: var(--mdui-typescale-label-large-size);
|
|
10
|
+
font-weight: var(--mdui-typescale-label-large-weight);
|
|
11
|
+
letter-spacing: var(--mdui-typescale-label-large-tracking);
|
|
12
|
+
line-height: var(--mdui-typescale-label-large-line-height);
|
|
13
|
+
}
|
|
14
|
+
label {
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
width: 100%;
|
|
18
|
+
cursor: inherit;
|
|
19
|
+
-webkit-user-select: none;
|
|
20
|
+
user-select: none;
|
|
21
|
+
touch-action: manipulation;
|
|
22
|
+
zoom: 1;
|
|
23
|
+
-webkit-user-drag: none;
|
|
24
|
+
}
|
|
25
|
+
/* 隐藏系统 input 标签,用自定义的图标代替 */
|
|
26
|
+
input {
|
|
27
|
+
position: absolute;
|
|
28
|
+
padding: 0;
|
|
29
|
+
opacity: 0;
|
|
30
|
+
pointer-events: none;
|
|
31
|
+
width: 1.125rem;
|
|
32
|
+
height: 1.125rem;
|
|
33
|
+
margin: 0rem 0rem 0rem 0.6875rem;
|
|
34
|
+
}
|
|
35
|
+
.icon {
|
|
36
|
+
display: flex;
|
|
37
|
+
position: absolute;
|
|
38
|
+
opacity: 1;
|
|
39
|
+
transform: scale(1);
|
|
40
|
+
color: rgb(var(--mdui-color-on-surface));
|
|
41
|
+
font-size: 1.5rem;
|
|
42
|
+
transition: color var(--mdui-motion-duration-short4)
|
|
43
|
+
var(--mdui-motion-easing-standard);
|
|
44
|
+
}
|
|
45
|
+
.checked-icon,
|
|
46
|
+
.indeterminate-icon {
|
|
47
|
+
opacity: 0;
|
|
48
|
+
transform: scale(0.5);
|
|
49
|
+
transition-property: color, opacity, transform;
|
|
50
|
+
transition-duration: var(--mdui-motion-duration-short4);
|
|
51
|
+
transition-timing-function: var(--mdui-motion-easing-standard);
|
|
52
|
+
}
|
|
53
|
+
.icon .i,
|
|
54
|
+
::slotted([slot='unchecked-icon']),
|
|
55
|
+
::slotted([slot='checked-icon']),
|
|
56
|
+
::slotted([slot='indeterminate-icon']) {
|
|
57
|
+
color: inherit;
|
|
58
|
+
font-size: inherit;
|
|
59
|
+
}
|
|
60
|
+
i {
|
|
61
|
+
position: relative;
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
overflow: hidden;
|
|
66
|
+
border-radius: 50%;
|
|
67
|
+
width: 2.5rem;
|
|
68
|
+
min-width: 2.5rem;
|
|
69
|
+
height: 2.5rem;
|
|
70
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
|
|
71
|
+
}
|
|
72
|
+
.label {
|
|
73
|
+
display: flex;
|
|
74
|
+
width: 100%;
|
|
75
|
+
padding-top: 0.625rem;
|
|
76
|
+
padding-bottom: 0.625rem;
|
|
77
|
+
color: rgb(var(--mdui-color-on-surface));
|
|
78
|
+
transition: color var(--mdui-motion-duration-short4)
|
|
79
|
+
var(--mdui-motion-easing-standard);
|
|
80
|
+
}
|
|
81
|
+
:host([checked]) i {
|
|
82
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
|
|
83
|
+
}
|
|
84
|
+
:host([checked]) .icon {
|
|
85
|
+
color: rgb(var(--mdui-color-primary));
|
|
86
|
+
}
|
|
87
|
+
:host([checked]) .indeterminate-icon {
|
|
88
|
+
opacity: 0;
|
|
89
|
+
transform: scale(0.5);
|
|
90
|
+
}
|
|
91
|
+
:host([checked]) .checked-icon {
|
|
92
|
+
opacity: 1;
|
|
93
|
+
transform: scale(1);
|
|
94
|
+
}
|
|
95
|
+
:host([indeterminate]) i {
|
|
96
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
|
|
97
|
+
}
|
|
98
|
+
:host([indeterminate]) .icon {
|
|
99
|
+
color: rgb(var(--mdui-color-primary));
|
|
100
|
+
}
|
|
101
|
+
:host([indeterminate]) .checked-icon {
|
|
102
|
+
opacity: 0;
|
|
103
|
+
transform: scale(0.5);
|
|
104
|
+
}
|
|
105
|
+
:host([indeterminate]) .indeterminate-icon {
|
|
106
|
+
opacity: 1;
|
|
107
|
+
transform: scale(1);
|
|
108
|
+
}
|
|
109
|
+
.invalid i {
|
|
110
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-error);
|
|
111
|
+
}
|
|
112
|
+
.invalid .icon {
|
|
113
|
+
color: rgb(var(--mdui-color-error));
|
|
114
|
+
}
|
|
115
|
+
.invalid .label {
|
|
116
|
+
color: rgb(var(--mdui-color-error));
|
|
117
|
+
}
|
|
118
|
+
:host([disabled]) {
|
|
119
|
+
cursor: default;
|
|
120
|
+
pointer-events: none;
|
|
121
|
+
}
|
|
122
|
+
:host([disabled]) .icon {
|
|
123
|
+
color: rgba(var(--mdui-color-on-surface), 38%);
|
|
124
|
+
}
|
|
125
|
+
:host([disabled]) .label {
|
|
126
|
+
color: rgba(var(--mdui-color-on-surface), 38%);
|
|
127
|
+
}
|
|
128
|
+
:host([disabled][checked]) .unchecked-icon,
|
|
129
|
+
:host([disabled][indeterminate]) .unchecked-icon {
|
|
130
|
+
opacity: 0;
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
@@ -17,35 +17,35 @@ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
|
17
17
|
* @event change - 选中状态变更时触发
|
|
18
18
|
* @event delete - 点击删除图标时触发
|
|
19
19
|
*
|
|
20
|
-
* @slot -
|
|
20
|
+
* @slot - 纸片文本
|
|
21
21
|
* @slot icon - 左侧元素
|
|
22
22
|
* @slot end-icon - 右侧元素
|
|
23
|
-
* @slot selected-icon -
|
|
24
|
-
* @slot delete-icon -
|
|
23
|
+
* @slot selected-icon - 选中状态下的左侧元素
|
|
24
|
+
* @slot delete-icon - 可删除时的右侧删除元素
|
|
25
25
|
*
|
|
26
|
-
* @csspart button - 内部的
|
|
27
|
-
* @csspart label -
|
|
26
|
+
* @csspart button - 内部的 `<button>` 或 `<a>` 元素
|
|
27
|
+
* @csspart label - 纸片文本
|
|
28
28
|
* @csspart icon - 左侧图标
|
|
29
29
|
* @csspart end-icon - 右侧图标
|
|
30
|
-
* @csspart selected-icon -
|
|
31
|
-
* @csspart delete-icon -
|
|
30
|
+
* @csspart selected-icon - 选中状态下的左侧图标
|
|
31
|
+
* @csspart delete-icon - 可删除时的右侧删除图标
|
|
32
32
|
* @csspart loading - 加载中状态的 `<mdui-circular-progress>` 元素
|
|
33
33
|
*
|
|
34
|
-
* @cssprop --shape-corner -
|
|
34
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
35
35
|
*/
|
|
36
36
|
export declare class Chip extends ButtonBase<ChipEventMap> {
|
|
37
37
|
static styles: CSSResultGroup;
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* 纸片的形状。可选值包括:
|
|
40
40
|
*
|
|
41
|
-
* * `assist
|
|
42
|
-
* * `filter
|
|
43
|
-
* * `input
|
|
44
|
-
* * `suggestion
|
|
41
|
+
* * `assist`:用于显示与当前上下文相关的辅助操作,如在点餐页面提供分享、收藏等功能
|
|
42
|
+
* * `filter`:用于对内容进行筛选,如在搜索结果页过滤搜索结果
|
|
43
|
+
* * `input`:用于表示用户输入的信息片段,如在 Gmail 的“收件人”字段中的联系人
|
|
44
|
+
* * `suggestion`:用于提供动态生成的推荐信息,以简化用户操作,如在聊天应用中预测用户可能想发送的信息
|
|
45
45
|
*/
|
|
46
|
-
variant:
|
|
46
|
+
variant: /*用于显示与当前上下文相关的辅助操作,如在点餐页面提供分享、收藏等功能*/ 'assist' | /*用于对内容进行筛选,如在搜索结果页过滤搜索结果*/ 'filter' | /*用于表示用户输入的信息片段,如在 Gmail 的“收件人”字段中的联系人*/ 'input' | /*用于提供动态生成的推荐信息,以简化用户操作,如在聊天应用中预测用户可能想发送的信息*/ 'suggestion';
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* 是否显示阴影
|
|
49
49
|
*/
|
|
50
50
|
elevated: boolean;
|
|
51
51
|
/**
|
|
@@ -53,11 +53,11 @@ export declare class Chip extends ButtonBase<ChipEventMap> {
|
|
|
53
53
|
*/
|
|
54
54
|
selectable: boolean;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* 是否已选中
|
|
57
57
|
*/
|
|
58
58
|
selected: boolean;
|
|
59
59
|
/**
|
|
60
|
-
* 是否可删除。为 `true`
|
|
60
|
+
* 是否可删除。为 `true` 时,纸片右侧会显示删除图标
|
|
61
61
|
*/
|
|
62
62
|
deletable: boolean;
|
|
63
63
|
/**
|
|
@@ -65,7 +65,7 @@ export declare class Chip extends ButtonBase<ChipEventMap> {
|
|
|
65
65
|
*/
|
|
66
66
|
icon?: string;
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* 选中状态下左侧的 Material Icons 图标名。也可以通过 `slot="selected-icon"` 设置
|
|
69
69
|
*/
|
|
70
70
|
selectedIcon?: string;
|
|
71
71
|
/**
|
|
@@ -73,7 +73,7 @@ export declare class Chip extends ButtonBase<ChipEventMap> {
|
|
|
73
73
|
*/
|
|
74
74
|
endIcon?: string;
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
76
|
+
* 可删除时,右侧删除图标的 Material Icons 图标名。也可以通过 `slot="delete-icon"` 设置
|
|
77
77
|
*/
|
|
78
78
|
deleteIcon?: string;
|
|
79
79
|
private readonly rippleRef;
|