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
|
@@ -1,2 +1,174 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const sliderBaseStyle = css
|
|
2
|
+
export const sliderBaseStyle = css `
|
|
3
|
+
:host {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: block;
|
|
6
|
+
width: 100%;
|
|
7
|
+
-webkit-tap-highlight-color: transparent;
|
|
8
|
+
height: 2.5rem;
|
|
9
|
+
padding: 0rem 1.25rem;
|
|
10
|
+
}
|
|
11
|
+
label {
|
|
12
|
+
position: relative;
|
|
13
|
+
display: block;
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100%;
|
|
16
|
+
}
|
|
17
|
+
input[type='range'] {
|
|
18
|
+
position: absolute;
|
|
19
|
+
inset: 0;
|
|
20
|
+
z-index: 4;
|
|
21
|
+
height: 100%;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
opacity: 0;
|
|
24
|
+
-webkit-appearance: none;
|
|
25
|
+
appearance: none;
|
|
26
|
+
width: calc(100% + 20rem * 2 / 16);
|
|
27
|
+
margin: 0rem -1.25rem;
|
|
28
|
+
padding: 0rem 0.75rem;
|
|
29
|
+
}
|
|
30
|
+
:host([disabled]) input[type='range'] {
|
|
31
|
+
cursor: not-allowed;
|
|
32
|
+
}
|
|
33
|
+
.track-inactive,
|
|
34
|
+
.track-active {
|
|
35
|
+
position: absolute;
|
|
36
|
+
top: 50%;
|
|
37
|
+
height: 0.25rem;
|
|
38
|
+
margin-top: -0.125rem;
|
|
39
|
+
}
|
|
40
|
+
.track-inactive {
|
|
41
|
+
left: -0.125rem;
|
|
42
|
+
right: -0.125rem;
|
|
43
|
+
border-radius: var(--mdui-shape-corner-full);
|
|
44
|
+
background-color: rgb(var(--mdui-color-surface-container-highest));
|
|
45
|
+
}
|
|
46
|
+
.invalid .track-inactive {
|
|
47
|
+
background-color: rgba(var(--mdui-color-error), 0.12);
|
|
48
|
+
}
|
|
49
|
+
:host([disabled]) .track-inactive {
|
|
50
|
+
background-color: rgba(var(--mdui-color-on-surface), 0.12);
|
|
51
|
+
}
|
|
52
|
+
.track-active {
|
|
53
|
+
background-color: rgb(var(--mdui-color-primary));
|
|
54
|
+
}
|
|
55
|
+
.invalid .track-active {
|
|
56
|
+
background-color: rgb(var(--mdui-color-error));
|
|
57
|
+
}
|
|
58
|
+
:host([disabled]) .track-active {
|
|
59
|
+
background-color: rgba(var(--mdui-color-on-surface), 0.38);
|
|
60
|
+
}
|
|
61
|
+
.handle {
|
|
62
|
+
position: absolute;
|
|
63
|
+
top: 50%;
|
|
64
|
+
transform: translate(-50%);
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
z-index: 2;
|
|
67
|
+
width: 2.5rem;
|
|
68
|
+
height: 2.5rem;
|
|
69
|
+
margin-top: -1.25rem;
|
|
70
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
|
|
71
|
+
}
|
|
72
|
+
.invalid .handle {
|
|
73
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-error);
|
|
74
|
+
}
|
|
75
|
+
.handle::before,
|
|
76
|
+
.handle .elevation {
|
|
77
|
+
position: absolute;
|
|
78
|
+
display: block;
|
|
79
|
+
content: ' ';
|
|
80
|
+
left: 0.625rem;
|
|
81
|
+
top: 0.625rem;
|
|
82
|
+
width: 1.25rem;
|
|
83
|
+
height: 1.25rem;
|
|
84
|
+
border-radius: var(--mdui-shape-corner-full);
|
|
85
|
+
}
|
|
86
|
+
.handle .elevation {
|
|
87
|
+
background-color: rgb(var(--mdui-color-primary));
|
|
88
|
+
box-shadow: var(--mdui-elevation-level1);
|
|
89
|
+
}
|
|
90
|
+
.invalid .handle .elevation {
|
|
91
|
+
background-color: rgb(var(--mdui-color-error));
|
|
92
|
+
}
|
|
93
|
+
:host([disabled]) .handle .elevation {
|
|
94
|
+
background-color: rgba(var(--mdui-color-on-surface), 0.38);
|
|
95
|
+
box-shadow: var(--mdui-elevation-level0);
|
|
96
|
+
}
|
|
97
|
+
.handle::before {
|
|
98
|
+
background-color: rgb(var(--mdui-color-background));
|
|
99
|
+
}
|
|
100
|
+
.handle mdui-ripple {
|
|
101
|
+
border-radius: var(--mdui-shape-corner-full);
|
|
102
|
+
}
|
|
103
|
+
.label {
|
|
104
|
+
position: absolute;
|
|
105
|
+
left: 50%;
|
|
106
|
+
transform: translateX(-50%) scale(0);
|
|
107
|
+
transform-origin: center bottom;
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
cursor: default;
|
|
112
|
+
white-space: nowrap;
|
|
113
|
+
-webkit-user-select: none;
|
|
114
|
+
user-select: none;
|
|
115
|
+
pointer-events: none;
|
|
116
|
+
transition: transform var(--mdui-motion-duration-short2)
|
|
117
|
+
var(--mdui-motion-easing-standard);
|
|
118
|
+
bottom: 2.5rem;
|
|
119
|
+
min-width: 1.75rem;
|
|
120
|
+
height: 1.75rem;
|
|
121
|
+
padding: 0.375rem 0.5rem;
|
|
122
|
+
border-radius: var(--mdui-shape-corner-full);
|
|
123
|
+
color: rgb(var(--mdui-color-on-primary));
|
|
124
|
+
font-size: var(--mdui-typescale-label-medium-size);
|
|
125
|
+
font-weight: var(--mdui-typescale-label-medium-weight);
|
|
126
|
+
letter-spacing: var(--mdui-typescale-label-medium-tracking);
|
|
127
|
+
line-height: var(--mdui-typescale-label-medium-line-height);
|
|
128
|
+
background-color: rgb(var(--mdui-color-primary));
|
|
129
|
+
}
|
|
130
|
+
.invalid .label {
|
|
131
|
+
color: rgb(var(--mdui-color-on-error));
|
|
132
|
+
background-color: rgb(var(--mdui-color-error));
|
|
133
|
+
}
|
|
134
|
+
.label::after {
|
|
135
|
+
content: ' ';
|
|
136
|
+
position: absolute;
|
|
137
|
+
z-index: -1;
|
|
138
|
+
transform: rotate(45deg);
|
|
139
|
+
width: 0.875rem;
|
|
140
|
+
height: 0.875rem;
|
|
141
|
+
bottom: -0.125rem;
|
|
142
|
+
background-color: rgb(var(--mdui-color-primary));
|
|
143
|
+
}
|
|
144
|
+
.invalid .label::after {
|
|
145
|
+
background-color: rgb(var(--mdui-color-error));
|
|
146
|
+
}
|
|
147
|
+
.label-visible {
|
|
148
|
+
transform: translateX(-50%) scale(1);
|
|
149
|
+
transition: transform var(--mdui-motion-duration-short4)
|
|
150
|
+
var(--mdui-motion-easing-standard);
|
|
151
|
+
}
|
|
152
|
+
.tickmark {
|
|
153
|
+
position: absolute;
|
|
154
|
+
top: 50%;
|
|
155
|
+
transform: translate(-50%);
|
|
156
|
+
width: 0.125rem;
|
|
157
|
+
height: 0.125rem;
|
|
158
|
+
margin-top: -0.0625rem;
|
|
159
|
+
border-radius: var(--mdui-shape-corner-full);
|
|
160
|
+
background-color: rgba(var(--mdui-color-on-surface-variant), 0.38);
|
|
161
|
+
}
|
|
162
|
+
.invalid .tickmark {
|
|
163
|
+
background-color: rgba(var(--mdui-color-error), 0.38);
|
|
164
|
+
}
|
|
165
|
+
.tickmark.active {
|
|
166
|
+
background-color: rgba(var(--mdui-color-on-primary), 0.38);
|
|
167
|
+
}
|
|
168
|
+
.invalid .tickmark.active {
|
|
169
|
+
background-color: rgba(var(--mdui-color-on-error), 0.38);
|
|
170
|
+
}
|
|
171
|
+
:host([disabled]) .tickmark {
|
|
172
|
+
background-color: rgba(var(--mdui-color-on-surface), 0.38);
|
|
173
|
+
}
|
|
174
|
+
`;
|
|
@@ -5,11 +5,11 @@ declare const SliderBase_base: import("@open-wc/dedupe-mixin").Constructor<impor
|
|
|
5
5
|
export declare class SliderBase<E> extends SliderBase_base<E> {
|
|
6
6
|
static styles: CSSResultGroup;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* 滑块的最小值,默认为 `0`
|
|
9
9
|
*/
|
|
10
10
|
min: number;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* 滑块的最大值,默认为 `100`
|
|
13
13
|
*/
|
|
14
14
|
max: number;
|
|
15
15
|
/**
|
|
@@ -21,21 +21,21 @@ export declare class SliderBase<E> extends SliderBase_base<E> {
|
|
|
21
21
|
*/
|
|
22
22
|
tickmarks: boolean;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* 是否隐藏文本提示
|
|
25
25
|
*/
|
|
26
26
|
nolabel: boolean;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* 是否被禁用
|
|
29
29
|
*/
|
|
30
30
|
disabled: boolean;
|
|
31
31
|
/**
|
|
32
|
-
* 关联的
|
|
32
|
+
* 关联的 `<form>` 元素。此属性值应为同一页面中的一个 `<form>` 元素的 `id`。
|
|
33
33
|
*
|
|
34
|
-
*
|
|
34
|
+
* 如果未指定此属性,则该元素必须是 `<form>` 元素的子元素。通过此属性,你可以将元素放置在页面的任何位置,而不仅仅是 `<form>` 元素的子元素。
|
|
35
35
|
*/
|
|
36
36
|
form?: string;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* 滑块的名称,该名称将与表单数据一起提交
|
|
39
39
|
*/
|
|
40
40
|
name: string;
|
|
41
41
|
/**
|
|
@@ -48,35 +48,35 @@ export declare class SliderBase<E> extends SliderBase_base<E> {
|
|
|
48
48
|
protected readonly inputRef: Ref<HTMLInputElement>;
|
|
49
49
|
protected readonly trackActiveRef: Ref<HTMLElement>;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
52
52
|
*/
|
|
53
53
|
get validity(): ValidityState;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
56
56
|
*/
|
|
57
57
|
get validationMessage(): string;
|
|
58
58
|
protected get rippleDisabled(): boolean;
|
|
59
59
|
protected get focusElement(): HTMLElement;
|
|
60
60
|
protected get focusDisabled(): boolean;
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* 用于自定义标签的显示格式的函数。函数参数为滑块的当前值,返回值为期望显示的文本。
|
|
63
63
|
*/
|
|
64
64
|
labelFormatter: (value: number) => string;
|
|
65
65
|
private onDisabledChange;
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
68
68
|
*/
|
|
69
69
|
checkValidity(): boolean;
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
71
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
72
72
|
*
|
|
73
|
-
*
|
|
73
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
74
74
|
*/
|
|
75
75
|
reportValidity(): boolean;
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
77
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
78
78
|
*
|
|
79
|
-
* @param message
|
|
79
|
+
* @param message 自定义的错误提示文本
|
|
80
80
|
*/
|
|
81
81
|
setCustomValidity(message: string): void;
|
|
82
82
|
/**
|
|
@@ -15,11 +15,11 @@ export class SliderBase extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments);
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* 滑块的最小值,默认为 `0`
|
|
19
19
|
*/
|
|
20
20
|
this.min = 0;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* 滑块的最大值,默认为 `100`
|
|
23
23
|
*/
|
|
24
24
|
this.max = 100;
|
|
25
25
|
/**
|
|
@@ -31,15 +31,15 @@ export class SliderBase extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
31
31
|
*/
|
|
32
32
|
this.tickmarks = false;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* 是否隐藏文本提示
|
|
35
35
|
*/
|
|
36
36
|
this.nolabel = false;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* 是否被禁用
|
|
39
39
|
*/
|
|
40
40
|
this.disabled = false;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* 滑块的名称,该名称将与表单数据一起提交
|
|
43
43
|
*/
|
|
44
44
|
this.name = '';
|
|
45
45
|
/**
|
|
@@ -53,18 +53,18 @@ export class SliderBase extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
53
53
|
this.inputRef = createRef();
|
|
54
54
|
this.trackActiveRef = createRef();
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* 用于自定义标签的显示格式的函数。函数参数为滑块的当前值,返回值为期望显示的文本。
|
|
57
57
|
*/
|
|
58
58
|
this.labelFormatter = (value) => value.toString();
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
62
62
|
*/
|
|
63
63
|
get validity() {
|
|
64
64
|
return this.inputRef.value.validity;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
68
68
|
*/
|
|
69
69
|
get validationMessage() {
|
|
70
70
|
return this.inputRef.value.validationMessage;
|
|
@@ -82,7 +82,7 @@ export class SliderBase extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
82
82
|
this.invalid = !this.inputRef.value.checkValidity();
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
85
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
86
86
|
*/
|
|
87
87
|
checkValidity() {
|
|
88
88
|
const valid = this.inputRef.value.checkValidity();
|
|
@@ -97,9 +97,9 @@ export class SliderBase extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
97
97
|
return valid;
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
100
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
101
101
|
*
|
|
102
|
-
*
|
|
102
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
103
103
|
*/
|
|
104
104
|
reportValidity() {
|
|
105
105
|
this.invalid = !this.inputRef.value.reportValidity();
|
|
@@ -119,9 +119,9 @@ export class SliderBase extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
119
119
|
return !this.invalid;
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
|
-
*
|
|
122
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
123
123
|
*
|
|
124
|
-
* @param message
|
|
124
|
+
* @param message 自定义的错误提示文本
|
|
125
125
|
*/
|
|
126
126
|
setCustomValidity(message) {
|
|
127
127
|
this.inputRef.value.setCustomValidity(message);
|
|
@@ -153,7 +153,12 @@ export class SliderBase extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
153
153
|
* 渲染浮动标签
|
|
154
154
|
*/
|
|
155
155
|
renderLabel(value) {
|
|
156
|
-
return when(!this.nolabel, () => html `<div
|
|
156
|
+
return when(!this.nolabel, () => html `<div
|
|
157
|
+
part="label"
|
|
158
|
+
class="label ${classMap({ 'label-visible': this.labelVisible })}"
|
|
159
|
+
>
|
|
160
|
+
${this.labelFormatter(value)}
|
|
161
|
+
</div>`);
|
|
157
162
|
}
|
|
158
163
|
onChange() {
|
|
159
164
|
// @ts-ignore
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css
|
|
2
|
+
export const style = css `
|
|
3
|
+
.track-active {
|
|
4
|
+
left: -0.125rem;
|
|
5
|
+
border-radius: var(--mdui-shape-corner-full) 0 0
|
|
6
|
+
var(--mdui-shape-corner-full);
|
|
7
|
+
}
|
|
8
|
+
`;
|
|
@@ -17,18 +17,18 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
17
17
|
* @event closed - Snackbar 隐藏动画完成时,事件被触发
|
|
18
18
|
* @event action-click - 点击操作按钮时触发
|
|
19
19
|
*
|
|
20
|
-
* @slot - Snackbar
|
|
20
|
+
* @slot - Snackbar 的消息文本内容
|
|
21
21
|
* @slot action - 右侧的操作按钮
|
|
22
|
-
* @slot close-button - 右侧的关闭按钮。必须设置 `closeable` 属性为 `true`
|
|
23
|
-
* @slot close-icon -
|
|
22
|
+
* @slot close-button - 右侧的关闭按钮。必须设置 `closeable` 属性为 `true` 才会显示
|
|
23
|
+
* @slot close-icon - 关闭按钮中的图标
|
|
24
24
|
*
|
|
25
25
|
* @csspart message - 消息文本
|
|
26
26
|
* @csspart action - 操作按钮
|
|
27
27
|
* @csspart close-button - 关闭按钮
|
|
28
28
|
* @csspart close-icon - 关闭按钮中的图标
|
|
29
29
|
*
|
|
30
|
-
* @cssprop --shape-corner -
|
|
31
|
-
* @cssprop --z-index - 组件的 CSS
|
|
30
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
31
|
+
* @cssprop --z-index - 组件的 CSS `z-index` 值
|
|
32
32
|
*/
|
|
33
33
|
export declare class Snackbar extends MduiElement<SnackbarEventMap> {
|
|
34
34
|
static styles: CSSResultGroup;
|
|
@@ -37,22 +37,22 @@ export declare class Snackbar extends MduiElement<SnackbarEventMap> {
|
|
|
37
37
|
*/
|
|
38
38
|
open: boolean;
|
|
39
39
|
/**
|
|
40
|
-
* Snackbar
|
|
40
|
+
* Snackbar 的显示位置。默认为 `bottom`。可选值包括:
|
|
41
41
|
*
|
|
42
|
-
* * `top
|
|
43
|
-
* * `top-start
|
|
44
|
-
* * `top-end
|
|
45
|
-
* * `bottom
|
|
46
|
-
* * `bottom-start
|
|
47
|
-
* * `bottom-end
|
|
42
|
+
* * `top`:顶部居中
|
|
43
|
+
* * `top-start`:顶部左对齐
|
|
44
|
+
* * `top-end`:顶部右对齐
|
|
45
|
+
* * `bottom`:底部居中
|
|
46
|
+
* * `bottom-start`:底部左对齐
|
|
47
|
+
* * `bottom-end`:底部右对齐
|
|
48
48
|
*/
|
|
49
|
-
placement:
|
|
49
|
+
placement: /*顶部居中*/ 'top' | /*顶部左对齐*/ 'top-start' | /*顶部右对齐*/ 'top-end' | /*底部居中*/ 'bottom' | /*底部左对齐*/ 'bottom-start' | /*底部右对齐*/ 'bottom-end';
|
|
50
50
|
/**
|
|
51
51
|
* 操作按钮的文本。也可以通过 `slot="action"` 设置操作按钮
|
|
52
52
|
*/
|
|
53
53
|
action?: string;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* 操作按钮是否处于加载中状态
|
|
56
56
|
*/
|
|
57
57
|
actionLoading: boolean;
|
|
58
58
|
/**
|
|
@@ -60,22 +60,22 @@ export declare class Snackbar extends MduiElement<SnackbarEventMap> {
|
|
|
60
60
|
*/
|
|
61
61
|
closeable: boolean;
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* 关闭按钮的 Material Icons 图标名。也可以通过 `slot="close-icon"` 设置
|
|
64
64
|
*/
|
|
65
65
|
closeIcon?: string;
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* 消息文本的最大显示行数。默认不限制。可选值包括:
|
|
68
68
|
*
|
|
69
|
-
* * `1
|
|
70
|
-
* * `2
|
|
69
|
+
* * `1`:最多显示一行
|
|
70
|
+
* * `2`:最多显示两行
|
|
71
71
|
*/
|
|
72
|
-
messageLine?:
|
|
72
|
+
messageLine?: /*最多显示一行*/ 1 | /*最多显示两行*/ 2;
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
74
|
+
* 自动关闭的延迟时间(单位:毫秒)。设置为 `0` 则不自动关闭。默认为 5000 毫秒
|
|
75
75
|
*/
|
|
76
76
|
autoCloseDelay: number;
|
|
77
77
|
/**
|
|
78
|
-
* 点击或触摸 Snackbar
|
|
78
|
+
* 点击或触摸 Snackbar 以外的区域时,是否关闭 Snackbar
|
|
79
79
|
*/
|
|
80
80
|
closeOnOutsideClick: boolean;
|
|
81
81
|
private closeTimeout;
|
|
@@ -28,18 +28,18 @@ import { style } from './style.js';
|
|
|
28
28
|
* @event closed - Snackbar 隐藏动画完成时,事件被触发
|
|
29
29
|
* @event action-click - 点击操作按钮时触发
|
|
30
30
|
*
|
|
31
|
-
* @slot - Snackbar
|
|
31
|
+
* @slot - Snackbar 的消息文本内容
|
|
32
32
|
* @slot action - 右侧的操作按钮
|
|
33
|
-
* @slot close-button - 右侧的关闭按钮。必须设置 `closeable` 属性为 `true`
|
|
34
|
-
* @slot close-icon -
|
|
33
|
+
* @slot close-button - 右侧的关闭按钮。必须设置 `closeable` 属性为 `true` 才会显示
|
|
34
|
+
* @slot close-icon - 关闭按钮中的图标
|
|
35
35
|
*
|
|
36
36
|
* @csspart message - 消息文本
|
|
37
37
|
* @csspart action - 操作按钮
|
|
38
38
|
* @csspart close-button - 关闭按钮
|
|
39
39
|
* @csspart close-icon - 关闭按钮中的图标
|
|
40
40
|
*
|
|
41
|
-
* @cssprop --shape-corner -
|
|
42
|
-
* @cssprop --z-index - 组件的 CSS
|
|
41
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
42
|
+
* @cssprop --z-index - 组件的 CSS `z-index` 值
|
|
43
43
|
*/
|
|
44
44
|
let Snackbar = class Snackbar extends MduiElement {
|
|
45
45
|
constructor() {
|
|
@@ -49,18 +49,18 @@ let Snackbar = class Snackbar extends MduiElement {
|
|
|
49
49
|
*/
|
|
50
50
|
this.open = false;
|
|
51
51
|
/**
|
|
52
|
-
* Snackbar
|
|
52
|
+
* Snackbar 的显示位置。默认为 `bottom`。可选值包括:
|
|
53
53
|
*
|
|
54
|
-
* * `top
|
|
55
|
-
* * `top-start
|
|
56
|
-
* * `top-end
|
|
57
|
-
* * `bottom
|
|
58
|
-
* * `bottom-start
|
|
59
|
-
* * `bottom-end
|
|
54
|
+
* * `top`:顶部居中
|
|
55
|
+
* * `top-start`:顶部左对齐
|
|
56
|
+
* * `top-end`:顶部右对齐
|
|
57
|
+
* * `bottom`:底部居中
|
|
58
|
+
* * `bottom-start`:底部左对齐
|
|
59
|
+
* * `bottom-end`:底部右对齐
|
|
60
60
|
*/
|
|
61
61
|
this.placement = 'bottom';
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* 操作按钮是否处于加载中状态
|
|
64
64
|
*/
|
|
65
65
|
this.actionLoading = false;
|
|
66
66
|
/**
|
|
@@ -68,11 +68,11 @@ let Snackbar = class Snackbar extends MduiElement {
|
|
|
68
68
|
*/
|
|
69
69
|
this.closeable = false;
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
71
|
+
* 自动关闭的延迟时间(单位:毫秒)。设置为 `0` 则不自动关闭。默认为 5000 毫秒
|
|
72
72
|
*/
|
|
73
73
|
this.autoCloseDelay = 5000;
|
|
74
74
|
/**
|
|
75
|
-
* 点击或触摸 Snackbar
|
|
75
|
+
* 点击或触摸 Snackbar 以外的区域时,是否关闭 Snackbar
|
|
76
76
|
*/
|
|
77
77
|
this.closeOnOutsideClick = false;
|
|
78
78
|
this.onDocumentClick = this.onDocumentClick.bind(this);
|
|
@@ -204,11 +204,38 @@ let Snackbar = class Snackbar extends MduiElement {
|
|
|
204
204
|
document.removeEventListener('pointerdown', this.onDocumentClick);
|
|
205
205
|
}
|
|
206
206
|
render() {
|
|
207
|
-
return html `<slot part="message" class="message"></slot
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
207
|
+
return html `<slot part="message" class="message"></slot>
|
|
208
|
+
<div class="action-group">
|
|
209
|
+
<slot
|
|
210
|
+
name="action"
|
|
211
|
+
part="action"
|
|
212
|
+
class="action"
|
|
213
|
+
@click=${this.onActionClick}
|
|
214
|
+
>
|
|
215
|
+
${this.action
|
|
216
|
+
? html `<mdui-button variant="text" loading=${this.actionLoading}>
|
|
217
|
+
${this.action}
|
|
218
|
+
</mdui-button>`
|
|
219
|
+
: nothingTemplate}
|
|
220
|
+
</slot>
|
|
221
|
+
${when(this.closeable, () => html `<slot
|
|
222
|
+
name="close-button"
|
|
223
|
+
part="close-button"
|
|
224
|
+
class="close-button"
|
|
225
|
+
@click=${this.onCloseClick}
|
|
226
|
+
>
|
|
227
|
+
<mdui-button-icon>
|
|
228
|
+
<slot name="close-icon" part="close-icon">
|
|
229
|
+
${this.closeIcon
|
|
230
|
+
? html `<mdui-icon
|
|
231
|
+
name=${this.closeIcon}
|
|
232
|
+
class="i"
|
|
233
|
+
></mdui-icon>`
|
|
234
|
+
: html `<mdui-icon-clear class="i"></mdui-icon-clear>`}
|
|
235
|
+
</slot>
|
|
236
|
+
</mdui-button-icon>
|
|
237
|
+
</slot>`)}
|
|
238
|
+
</div>`;
|
|
212
239
|
}
|
|
213
240
|
/**
|
|
214
241
|
* 在 document 上点击时,根据条件判断是否要关闭 snackbar
|