mdui 2.0.2 → 2.0.4
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 +17 -15
- package/components/avatar/index.js +7 -6
- package/components/badge/index.d.ts +11 -8
- package/components/badge/index.js +9 -7
- package/components/bottom-app-bar/index.d.ts +11 -4
- package/components/bottom-app-bar/index.js +8 -9
- package/components/button/button-base-style.js +1 -1
- package/components/button/button-base.d.ts +46 -47
- package/components/button/button-base.js +27 -25
- package/components/button/index.d.ts +19 -14
- package/components/button/index.js +12 -12
- package/components/button-icon/index.d.ts +15 -9
- package/components/button-icon/index.js +8 -9
- package/components/card/index.d.ts +15 -11
- package/components/card/index.js +10 -9
- package/components/checkbox/index.d.ts +30 -23
- package/components/checkbox/index.js +25 -25
- package/components/chip/index.d.ts +27 -20
- package/components/chip/index.js +19 -20
- package/components/circular-progress/index.d.ts +6 -4
- package/components/circular-progress/index.js +4 -3
- package/components/collapse/collapse-item.d.ts +17 -6
- package/components/collapse/collapse-item.js +7 -7
- package/components/collapse/collapse.d.ts +16 -11
- package/components/collapse/collapse.js +10 -10
- package/components/dialog/index.d.ts +22 -15
- package/components/dialog/index.js +23 -27
- package/components/divider/index.d.ts +7 -5
- package/components/divider/index.js +6 -5
- package/components/dropdown/index.d.ts +44 -37
- package/components/dropdown/index.js +50 -48
- package/components/fab/index.d.ts +12 -7
- package/components/fab/index.js +6 -6
- package/components/icon/index.d.ts +4 -2
- package/components/icon/index.js +3 -2
- package/components/layout/layout-item-base.d.ts +3 -2
- package/components/layout/layout-item-base.js +2 -2
- package/components/layout/layout-item.d.ts +11 -10
- package/components/layout/layout-item.js +6 -6
- package/components/layout/layout-main.d.ts +6 -4
- package/components/layout/layout-main.js +5 -4
- package/components/layout/layout.d.ts +6 -4
- package/components/layout/layout.js +5 -4
- package/components/linear-progress/index.d.ts +8 -6
- package/components/linear-progress/index.js +6 -5
- package/components/list/list-item-style.js +1 -1
- package/components/list/list-item.d.ts +24 -20
- package/components/list/list-item.js +10 -9
- package/components/list/list-subheader.d.ts +6 -4
- package/components/list/list-subheader.js +5 -4
- package/components/list/list.d.ts +5 -3
- package/components/list/list.js +4 -3
- package/components/menu/menu-item.d.ts +15 -7
- package/components/menu/menu-item.js +11 -15
- package/components/menu/menu.d.ts +20 -20
- package/components/menu/menu.js +13 -13
- package/components/navigation-bar/navigation-bar-item.d.ts +12 -8
- package/components/navigation-bar/navigation-bar-item.js +7 -6
- package/components/navigation-bar/navigation-bar.d.ts +17 -9
- package/components/navigation-bar/navigation-bar.js +15 -13
- package/components/navigation-drawer/index.d.ts +27 -21
- package/components/navigation-drawer/index.js +51 -38
- package/components/navigation-drawer/style.js +1 -1
- package/components/navigation-rail/navigation-rail-item.d.ts +13 -9
- package/components/navigation-rail/navigation-rail-item.js +7 -6
- package/components/navigation-rail/navigation-rail.d.ts +14 -12
- package/components/navigation-rail/navigation-rail.js +13 -12
- package/components/radio/radio-group.d.ts +20 -15
- package/components/radio/radio-group.js +21 -24
- package/components/radio/radio.d.ts +11 -6
- package/components/radio/radio.js +7 -7
- package/components/range-slider/index.d.ts +13 -8
- package/components/range-slider/index.js +10 -7
- package/components/ripple/index.d.ts +4 -2
- package/components/ripple/index.js +3 -2
- package/components/ripple/ripple-mixin.d.ts +1 -1
- package/components/ripple/ripple-mixin.js +0 -1
- package/components/segmented-button/segmented-button-group-style.js +1 -1
- package/components/segmented-button/segmented-button-group.d.ts +23 -22
- package/components/segmented-button/segmented-button-group.js +20 -23
- package/components/segmented-button/segmented-button.d.ts +9 -4
- package/components/segmented-button/segmented-button.js +3 -3
- package/components/select/index.d.ts +42 -35
- package/components/select/index.js +24 -25
- package/components/slider/index.d.ts +9 -2
- package/components/slider/index.js +5 -10
- package/components/slider/slider-base.d.ts +22 -18
- package/components/slider/slider-base.js +40 -21
- package/components/snackbar/index.d.ts +30 -23
- package/components/snackbar/index.js +25 -25
- package/components/switch/index.d.ts +24 -17
- package/components/switch/index.js +18 -18
- package/components/tabs/tab-panel.d.ts +7 -5
- package/components/tabs/tab-panel.js +5 -4
- package/components/tabs/tab.d.ts +13 -9
- package/components/tabs/tab.js +8 -7
- package/components/tabs/tabs.d.ts +24 -21
- package/components/tabs/tabs.js +24 -21
- package/components/text-field/index.d.ts +62 -54
- package/components/text-field/index.js +37 -37
- package/components/tooltip/index.d.ts +40 -33
- package/components/tooltip/index.js +45 -43
- package/components/top-app-bar/top-app-bar-title.d.ts +8 -6
- package/components/top-app-bar/top-app-bar-title.js +7 -6
- package/components/top-app-bar/top-app-bar.d.ts +12 -6
- package/components/top-app-bar/top-app-bar.js +9 -10
- package/css-data.en.json +2826 -0
- package/css-data.zh-cn.json +374 -367
- package/custom-elements.json +3844 -3824
- package/html-data.en.json +6551 -0
- package/html-data.zh-cn.json +1621 -1636
- package/jsx.en.d.ts +3303 -0
- package/jsx.zh-cn.d.ts +3351 -0
- package/mdui.esm.js +9 -9
- package/mdui.global.js +9 -9
- package/package.json +7 -5
- package/web-types.en.json +11718 -0
- package/web-types.zh-cn.json +3613 -3623
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
3
3
|
import type { Ref } from 'lit/directives/ref.js';
|
|
4
|
-
declare const SliderBase_base: import("@open-wc/dedupe-mixin").Constructor<import("../ripple/ripple-mixin.js").RippleMixinInterface> & import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof
|
|
5
|
-
export declare class SliderBase extends SliderBase_base {
|
|
4
|
+
declare const SliderBase_base: import("@open-wc/dedupe-mixin").Constructor<import("../ripple/ripple-mixin.js").RippleMixinInterface> & import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof MduiElement;
|
|
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 extends SliderBase_base {
|
|
|
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,37 +48,41 @@ export declare class SliderBase extends SliderBase_base {
|
|
|
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
|
+
/**
|
|
83
|
+
* value 不在 min、max 或 step 的限制范围内时,修正 value 的值
|
|
84
|
+
*/
|
|
85
|
+
protected fixValue(value: number): number;
|
|
82
86
|
/**
|
|
83
87
|
* 获取候选值组成的数组
|
|
84
88
|
*/
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { property, state } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { createRef } from 'lit/directives/ref.js';
|
|
6
6
|
import { when } from 'lit/directives/when.js';
|
|
7
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
7
8
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
8
9
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
9
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
10
10
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
11
11
|
import { FocusableMixin } from '@mdui/shared/mixins/focusable.js';
|
|
12
12
|
import { RippleMixin } from '../ripple/ripple-mixin.js';
|
|
13
13
|
import { sliderBaseStyle } from './slider-base-style.js';
|
|
14
|
-
export class SliderBase extends RippleMixin(FocusableMixin(
|
|
14
|
+
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(LitElement)) {
|
|
|
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(LitElement)) {
|
|
|
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,12 +82,13 @@ export class SliderBase extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
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();
|
|
89
89
|
if (!valid) {
|
|
90
|
-
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
this.emit('invalid', {
|
|
91
92
|
bubbles: false,
|
|
92
93
|
cancelable: true,
|
|
93
94
|
composed: false,
|
|
@@ -96,20 +97,21 @@ export class SliderBase extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
96
97
|
return valid;
|
|
97
98
|
}
|
|
98
99
|
/**
|
|
99
|
-
*
|
|
100
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
100
101
|
*
|
|
101
|
-
*
|
|
102
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
102
103
|
*/
|
|
103
104
|
reportValidity() {
|
|
104
105
|
this.invalid = !this.inputRef.value.reportValidity();
|
|
105
106
|
if (this.invalid) {
|
|
106
|
-
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
const eventProceeded = this.emit('invalid', {
|
|
107
109
|
bubbles: false,
|
|
108
110
|
cancelable: true,
|
|
109
111
|
composed: false,
|
|
110
112
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
if (!eventProceeded) {
|
|
114
|
+
// 调用了 preventDefault() 时,隐藏默认的表单错误提示
|
|
113
115
|
this.blur();
|
|
114
116
|
this.focus();
|
|
115
117
|
}
|
|
@@ -117,14 +119,30 @@ export class SliderBase extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
117
119
|
return !this.invalid;
|
|
118
120
|
}
|
|
119
121
|
/**
|
|
120
|
-
*
|
|
122
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
121
123
|
*
|
|
122
|
-
* @param message
|
|
124
|
+
* @param message 自定义的错误提示文本
|
|
123
125
|
*/
|
|
124
126
|
setCustomValidity(message) {
|
|
125
127
|
this.inputRef.value.setCustomValidity(message);
|
|
126
128
|
this.invalid = !this.inputRef.value.checkValidity();
|
|
127
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* value 不在 min、max 或 step 的限制范围内时,修正 value 的值
|
|
132
|
+
*/
|
|
133
|
+
fixValue(value) {
|
|
134
|
+
const { min, max, step } = this;
|
|
135
|
+
// 确保 value 在 min 和 max 范围内
|
|
136
|
+
value = Math.min(Math.max(value, min), max);
|
|
137
|
+
// 计算最接近 value 的 step 值
|
|
138
|
+
const steps = Math.round((value - min) / step);
|
|
139
|
+
let fixedValue = min + steps * step;
|
|
140
|
+
// 如果修正后的值超出最大值,则减去一个 step
|
|
141
|
+
if (fixedValue > max) {
|
|
142
|
+
fixedValue -= step;
|
|
143
|
+
}
|
|
144
|
+
return fixedValue;
|
|
145
|
+
}
|
|
128
146
|
/**
|
|
129
147
|
* 获取候选值组成的数组
|
|
130
148
|
*/
|
|
@@ -138,7 +156,8 @@ export class SliderBase extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
138
156
|
return when(!this.nolabel, () => html `<div part="label" class="label ${classMap({ 'label-visible': this.labelVisible })}">${this.labelFormatter(value)}</div>`);
|
|
139
157
|
}
|
|
140
158
|
onChange() {
|
|
141
|
-
|
|
159
|
+
// @ts-ignore
|
|
160
|
+
this.emit('change');
|
|
142
161
|
}
|
|
143
162
|
}
|
|
144
163
|
SliderBase.styles = [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import '@mdui/shared/icons/clear.js';
|
|
3
3
|
import '../button-icon.js';
|
|
4
4
|
import '../button.js';
|
|
@@ -17,42 +17,42 @@ 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
|
-
export declare class Snackbar extends
|
|
33
|
+
export declare class Snackbar extends MduiElement<SnackbarEventMap> {
|
|
34
34
|
static styles: CSSResultGroup;
|
|
35
35
|
/**
|
|
36
36
|
* 是否显示 Snackbar
|
|
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 LitElement {
|
|
|
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;
|
|
@@ -91,6 +91,13 @@ export declare class Snackbar extends LitElement {
|
|
|
91
91
|
private onActionClick;
|
|
92
92
|
private onCloseClick;
|
|
93
93
|
}
|
|
94
|
+
export interface SnackbarEventMap {
|
|
95
|
+
open: CustomEvent<void>;
|
|
96
|
+
opened: CustomEvent<void>;
|
|
97
|
+
close: CustomEvent<void>;
|
|
98
|
+
closed: CustomEvent<void>;
|
|
99
|
+
'action-click': CustomEvent<void>;
|
|
100
|
+
}
|
|
94
101
|
declare global {
|
|
95
102
|
interface HTMLElementTagNameMap {
|
|
96
103
|
'mdui-snackbar': Snackbar;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
4
|
import { when } from 'lit/directives/when.js';
|
|
5
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
5
6
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
6
7
|
import { animateTo, stopAnimations } from '@mdui/shared/helpers/animate.js';
|
|
7
8
|
import { breakpoint } from '@mdui/shared/helpers/breakpoint.js';
|
|
8
9
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
9
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
10
10
|
import { getDuration, getEasing } from '@mdui/shared/helpers/motion.js';
|
|
11
11
|
import { nothingTemplate } from '@mdui/shared/helpers/template.js';
|
|
12
12
|
import '@mdui/shared/icons/clear.js';
|
|
@@ -28,20 +28,20 @@ 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
|
-
let Snackbar = class Snackbar extends
|
|
44
|
+
let Snackbar = class Snackbar extends MduiElement {
|
|
45
45
|
constructor() {
|
|
46
46
|
super();
|
|
47
47
|
/**
|
|
@@ -49,18 +49,18 @@ let Snackbar = class Snackbar extends LitElement {
|
|
|
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 LitElement {
|
|
|
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);
|
|
@@ -97,8 +97,8 @@ let Snackbar = class Snackbar extends LitElement {
|
|
|
97
97
|
await this.updateComplete;
|
|
98
98
|
}
|
|
99
99
|
if (hasUpdated) {
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
100
|
+
const eventProceeded = this.emit('open', { cancelable: true });
|
|
101
|
+
if (!eventProceeded) {
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -155,14 +155,14 @@ let Snackbar = class Snackbar extends LitElement {
|
|
|
155
155
|
})),
|
|
156
156
|
]);
|
|
157
157
|
if (hasUpdated) {
|
|
158
|
-
emit(
|
|
158
|
+
this.emit('opened');
|
|
159
159
|
}
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
// 关闭
|
|
163
163
|
if (!this.open && this.hasUpdated) {
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
164
|
+
const eventProceeded = this.emit('close', { cancelable: true });
|
|
165
|
+
if (!eventProceeded) {
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
168
|
window.clearTimeout(this.closeTimeout);
|
|
@@ -191,7 +191,7 @@ let Snackbar = class Snackbar extends LitElement {
|
|
|
191
191
|
...children.map((child) => animateTo(child, [{ opacity: 1 }, { opacity: 0, offset: 0.75 }, { opacity: 0 }], { duration, easing: easingLinear })),
|
|
192
192
|
]);
|
|
193
193
|
this.style.display = 'none';
|
|
194
|
-
emit(
|
|
194
|
+
this.emit('closed');
|
|
195
195
|
return;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
@@ -224,7 +224,7 @@ let Snackbar = class Snackbar extends LitElement {
|
|
|
224
224
|
}
|
|
225
225
|
onActionClick(event) {
|
|
226
226
|
event.stopPropagation();
|
|
227
|
-
emit(
|
|
227
|
+
this.emit('action-click');
|
|
228
228
|
}
|
|
229
229
|
onCloseClick() {
|
|
230
230
|
this.open = false;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import '@mdui/shared/icons/check.js';
|
|
3
3
|
import '../icon.js';
|
|
4
4
|
import type { Ripple } from '../ripple/index.js';
|
|
5
5
|
import type { FormControl } from '@mdui/jq/shared/form.js';
|
|
6
6
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
7
|
-
declare const Switch_base: import("@open-wc/dedupe-mixin").Constructor<import("../ripple/ripple-mixin.js").RippleMixinInterface> & import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof
|
|
7
|
+
declare const Switch_base: import("@open-wc/dedupe-mixin").Constructor<import("../ripple/ripple-mixin.js").RippleMixinInterface> & import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof MduiElement;
|
|
8
8
|
/**
|
|
9
9
|
* @summary 开关切换组件
|
|
10
10
|
*
|
|
@@ -26,10 +26,10 @@ declare const Switch_base: import("@open-wc/dedupe-mixin").Constructor<import(".
|
|
|
26
26
|
* @csspart unchecked-icon - 未选中状态的图标
|
|
27
27
|
* @csspart checked-icon 选中状态的图标
|
|
28
28
|
*
|
|
29
|
-
* @cssprop --shape-corner -
|
|
30
|
-
* @cssprop --shape-corner-thumb -
|
|
29
|
+
* @cssprop --shape-corner - 组件轨道的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
30
|
+
* @cssprop --shape-corner-thumb - 组件图标容器的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
31
31
|
*/
|
|
32
|
-
export declare class Switch extends Switch_base implements FormControl {
|
|
32
|
+
export declare class Switch extends Switch_base<SwitchEventMap> implements FormControl {
|
|
33
33
|
static styles: CSSResultGroup;
|
|
34
34
|
/**
|
|
35
35
|
* 是否为禁用状态
|
|
@@ -40,7 +40,7 @@ export declare class Switch extends Switch_base implements FormControl {
|
|
|
40
40
|
*/
|
|
41
41
|
checked: boolean;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* 默认选中状态。在重置表单时,将重置为此状态。此属性只能通过 JavaScript 属性设置
|
|
44
44
|
*/
|
|
45
45
|
defaultChecked: boolean;
|
|
46
46
|
/**
|
|
@@ -50,17 +50,17 @@ export declare class Switch extends Switch_base implements FormControl {
|
|
|
50
50
|
/**
|
|
51
51
|
* 选中状态的 Material Icons 图标名。也可以通过 `slot="checked-icon"` 设置
|
|
52
52
|
*
|
|
53
|
-
* 默认为 check 图标,可传入空字符串移除默认图标
|
|
53
|
+
* 默认为 `check` 图标,可传入空字符串移除默认图标
|
|
54
54
|
*/
|
|
55
55
|
checkedIcon?: string;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* 提交表单时,是否必须选中此开关
|
|
58
58
|
*/
|
|
59
59
|
required: boolean;
|
|
60
60
|
/**
|
|
61
|
-
* 关联的
|
|
61
|
+
* 关联的 `<form>` 元素。此属性值应为同一页面中的一个 `<form>` 元素的 `id`。
|
|
62
62
|
*
|
|
63
|
-
*
|
|
63
|
+
* 如果未指定此属性,则该元素必须是 `<form>` 元素的子元素。通过此属性,你可以将元素放置在页面的任何位置,而不仅仅是 `<form>` 元素的子元素。
|
|
64
64
|
*/
|
|
65
65
|
form?: string;
|
|
66
66
|
/**
|
|
@@ -80,11 +80,11 @@ export declare class Switch extends Switch_base implements FormControl {
|
|
|
80
80
|
private readonly formController;
|
|
81
81
|
private readonly hasSlotController;
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
83
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
84
84
|
*/
|
|
85
85
|
get validity(): ValidityState;
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
87
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
88
88
|
*/
|
|
89
89
|
get validationMessage(): string;
|
|
90
90
|
protected get rippleElement(): Ripple;
|
|
@@ -94,19 +94,19 @@ export declare class Switch extends Switch_base implements FormControl {
|
|
|
94
94
|
private onDisabledChange;
|
|
95
95
|
private onCheckedChange;
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
97
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
98
98
|
*/
|
|
99
99
|
checkValidity(): boolean;
|
|
100
100
|
/**
|
|
101
|
-
*
|
|
101
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
102
102
|
*
|
|
103
|
-
*
|
|
103
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
104
104
|
*/
|
|
105
105
|
reportValidity(): boolean;
|
|
106
106
|
/**
|
|
107
|
-
*
|
|
107
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
108
108
|
*
|
|
109
|
-
* @param message
|
|
109
|
+
* @param message 自定义的错误提示文本
|
|
110
110
|
*/
|
|
111
111
|
setCustomValidity(message: string): void;
|
|
112
112
|
protected render(): TemplateResult;
|
|
@@ -115,6 +115,13 @@ export declare class Switch extends Switch_base implements FormControl {
|
|
|
115
115
|
*/
|
|
116
116
|
private onChange;
|
|
117
117
|
}
|
|
118
|
+
export interface SwitchEventMap {
|
|
119
|
+
focus: FocusEvent;
|
|
120
|
+
blur: FocusEvent;
|
|
121
|
+
change: CustomEvent<void>;
|
|
122
|
+
input: Event;
|
|
123
|
+
invalid: CustomEvent<void>;
|
|
124
|
+
}
|
|
118
125
|
declare global {
|
|
119
126
|
interface HTMLElementTagNameMap {
|
|
120
127
|
'mdui-switch': Switch;
|