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,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
5
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
@@ -7,17 +7,16 @@ import { $ } from '@mdui/jq/$.js';
|
|
|
7
7
|
import '@mdui/jq/methods/closest.js';
|
|
8
8
|
import '@mdui/jq/methods/find.js';
|
|
9
9
|
import '@mdui/jq/methods/get.js';
|
|
10
|
-
import {
|
|
10
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
11
11
|
import { DefinedController } from '@mdui/shared/controllers/defined.js';
|
|
12
12
|
import { FormController, formResets } from '@mdui/shared/controllers/form.js';
|
|
13
13
|
import { defaultValue } from '@mdui/shared/decorators/default-value.js';
|
|
14
14
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
15
15
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
16
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
17
16
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
18
17
|
import { radioGroupStyle } from './radio-group-style.js';
|
|
19
18
|
/**
|
|
20
|
-
* @summary
|
|
19
|
+
* @summary 单选框组组件。需配合 `<mdui-radio>` 组件使用
|
|
21
20
|
*
|
|
22
21
|
* ```html
|
|
23
22
|
* <mdui-radio-group value="chinese">
|
|
@@ -32,19 +31,19 @@ import { radioGroupStyle } from './radio-group-style.js';
|
|
|
32
31
|
*
|
|
33
32
|
* @slot - `<mdui-radio>` 元素
|
|
34
33
|
*/
|
|
35
|
-
let RadioGroup = class RadioGroup extends
|
|
34
|
+
let RadioGroup = class RadioGroup extends MduiElement {
|
|
36
35
|
constructor() {
|
|
37
36
|
super(...arguments);
|
|
38
37
|
/**
|
|
39
|
-
*
|
|
38
|
+
* 是否禁用此组件
|
|
40
39
|
*/
|
|
41
40
|
this.disabled = false;
|
|
42
41
|
/**
|
|
43
|
-
*
|
|
42
|
+
* 单选框组的名称,将与表单数据一起提交
|
|
44
43
|
*/
|
|
45
44
|
this.name = '';
|
|
46
45
|
/**
|
|
47
|
-
*
|
|
46
|
+
* 单选框组的名称,将于表单数据一起提交
|
|
48
47
|
*/
|
|
49
48
|
this.value = '';
|
|
50
49
|
/**
|
|
@@ -68,13 +67,13 @@ let RadioGroup = class RadioGroup extends LitElement {
|
|
|
68
67
|
});
|
|
69
68
|
}
|
|
70
69
|
/**
|
|
71
|
-
*
|
|
70
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
72
71
|
*/
|
|
73
72
|
get validity() {
|
|
74
73
|
return this.inputRef.value.validity;
|
|
75
74
|
}
|
|
76
75
|
/**
|
|
77
|
-
*
|
|
76
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
78
77
|
*/
|
|
79
78
|
get validationMessage() {
|
|
80
79
|
return this.inputRef.value.validationMessage;
|
|
@@ -91,8 +90,8 @@ let RadioGroup = class RadioGroup extends LitElement {
|
|
|
91
90
|
async onValueChange() {
|
|
92
91
|
this.isInitial = false;
|
|
93
92
|
await this.definedController.whenDefined();
|
|
94
|
-
emit(
|
|
95
|
-
emit(
|
|
93
|
+
this.emit('input');
|
|
94
|
+
this.emit('change');
|
|
96
95
|
this.updateItems();
|
|
97
96
|
this.updateRadioFocusable();
|
|
98
97
|
await this.updateComplete;
|
|
@@ -111,12 +110,12 @@ let RadioGroup = class RadioGroup extends LitElement {
|
|
|
111
110
|
this.updateItems();
|
|
112
111
|
}
|
|
113
112
|
/**
|
|
114
|
-
*
|
|
113
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
115
114
|
*/
|
|
116
115
|
checkValidity() {
|
|
117
116
|
const valid = this.inputRef.value.checkValidity();
|
|
118
117
|
if (!valid) {
|
|
119
|
-
emit(
|
|
118
|
+
this.emit('invalid', {
|
|
120
119
|
bubbles: false,
|
|
121
120
|
cancelable: true,
|
|
122
121
|
composed: false,
|
|
@@ -125,20 +124,20 @@ let RadioGroup = class RadioGroup extends LitElement {
|
|
|
125
124
|
return valid;
|
|
126
125
|
}
|
|
127
126
|
/**
|
|
128
|
-
*
|
|
127
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
129
128
|
*
|
|
130
|
-
*
|
|
129
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
131
130
|
*/
|
|
132
131
|
reportValidity() {
|
|
133
132
|
this.invalid = !this.inputRef.value.reportValidity();
|
|
134
133
|
if (this.invalid) {
|
|
135
|
-
const
|
|
134
|
+
const eventProceeded = this.emit('invalid', {
|
|
136
135
|
bubbles: false,
|
|
137
136
|
cancelable: true,
|
|
138
137
|
composed: false,
|
|
139
138
|
});
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
if (!eventProceeded) {
|
|
140
|
+
// 调用了 preventDefault() 时,隐藏默认的表单错误提示
|
|
142
141
|
this.inputRef.value.blur();
|
|
143
142
|
this.inputRef.value.focus();
|
|
144
143
|
}
|
|
@@ -146,9 +145,9 @@ let RadioGroup = class RadioGroup extends LitElement {
|
|
|
146
145
|
return !this.invalid;
|
|
147
146
|
}
|
|
148
147
|
/**
|
|
149
|
-
*
|
|
148
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
150
149
|
*
|
|
151
|
-
* @param message
|
|
150
|
+
* @param message 自定义的错误提示文本
|
|
152
151
|
*/
|
|
153
152
|
setCustomValidity(message) {
|
|
154
153
|
this.inputRef.value.setCustomValidity(message);
|
|
@@ -177,9 +176,7 @@ let RadioGroup = class RadioGroup extends LitElement {
|
|
|
177
176
|
async onClick(event) {
|
|
178
177
|
await this.definedController.whenDefined();
|
|
179
178
|
const target = event.target;
|
|
180
|
-
const item =
|
|
181
|
-
? target
|
|
182
|
-
: $(target).closest('mdui-radio')[0];
|
|
179
|
+
const item = target.closest('mdui-radio');
|
|
183
180
|
if (!item || item.disabled) {
|
|
184
181
|
return;
|
|
185
182
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import '@mdui/shared/icons/circle.js';
|
|
3
3
|
import '@mdui/shared/icons/radio-button-unchecked.js';
|
|
4
4
|
import '../icon.js';
|
|
5
5
|
import type { Ripple } from '../ripple/index.js';
|
|
6
6
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
7
|
-
declare const Radio_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 Radio_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
|
-
* @summary
|
|
9
|
+
* @summary 单选框组件。需配合 `<mdui-radio-group>` 组件使用
|
|
10
10
|
*
|
|
11
11
|
* ```html
|
|
12
12
|
* <mdui-radio-group value="chinese">
|
|
@@ -19,16 +19,16 @@ declare const Radio_base: import("@open-wc/dedupe-mixin").Constructor<import("..
|
|
|
19
19
|
* @event blur - 失去焦点时触发
|
|
20
20
|
* @event change - 选中该单选项时触发
|
|
21
21
|
*
|
|
22
|
-
* @slot -
|
|
22
|
+
* @slot - 文本内容
|
|
23
23
|
* @slot unchecked-icon - 未选中状态的图标
|
|
24
24
|
* @slot checked-icon - 选中状态的图标
|
|
25
25
|
*
|
|
26
26
|
* @csspart control - 左侧图标容器
|
|
27
27
|
* @csspart unchecked-icon 未选中状态的图标
|
|
28
28
|
* @csspart checked-icon 选中状态的图标
|
|
29
|
-
* @csspart label -
|
|
29
|
+
* @csspart label - 文本内容
|
|
30
30
|
*/
|
|
31
|
-
export declare class Radio extends Radio_base {
|
|
31
|
+
export declare class Radio extends Radio_base<RadioEventMap> {
|
|
32
32
|
static styles: CSSResultGroup;
|
|
33
33
|
/**
|
|
34
34
|
* 当前单选项的值
|
|
@@ -64,6 +64,11 @@ export declare class Radio extends Radio_base {
|
|
|
64
64
|
protected render(): TemplateResult;
|
|
65
65
|
private isDisabled;
|
|
66
66
|
}
|
|
67
|
+
export interface RadioEventMap {
|
|
68
|
+
focus: FocusEvent;
|
|
69
|
+
blur: FocusEvent;
|
|
70
|
+
change: CustomEvent<void>;
|
|
71
|
+
}
|
|
67
72
|
declare global {
|
|
68
73
|
interface HTMLElementTagNameMap {
|
|
69
74
|
'mdui-radio': Radio;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
6
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
6
7
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
7
8
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
8
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
9
9
|
import '@mdui/shared/icons/circle.js';
|
|
10
10
|
import '@mdui/shared/icons/radio-button-unchecked.js';
|
|
11
11
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
@@ -14,7 +14,7 @@ import '../icon.js';
|
|
|
14
14
|
import { RippleMixin } from '../ripple/ripple-mixin.js';
|
|
15
15
|
import { radioStyle } from './radio-style.js';
|
|
16
16
|
/**
|
|
17
|
-
* @summary
|
|
17
|
+
* @summary 单选框组件。需配合 `<mdui-radio-group>` 组件使用
|
|
18
18
|
*
|
|
19
19
|
* ```html
|
|
20
20
|
* <mdui-radio-group value="chinese">
|
|
@@ -27,16 +27,16 @@ import { radioStyle } from './radio-style.js';
|
|
|
27
27
|
* @event blur - 失去焦点时触发
|
|
28
28
|
* @event change - 选中该单选项时触发
|
|
29
29
|
*
|
|
30
|
-
* @slot -
|
|
30
|
+
* @slot - 文本内容
|
|
31
31
|
* @slot unchecked-icon - 未选中状态的图标
|
|
32
32
|
* @slot checked-icon - 选中状态的图标
|
|
33
33
|
*
|
|
34
34
|
* @csspart control - 左侧图标容器
|
|
35
35
|
* @csspart unchecked-icon 未选中状态的图标
|
|
36
36
|
* @csspart checked-icon 选中状态的图标
|
|
37
|
-
* @csspart label -
|
|
37
|
+
* @csspart label - 文本内容
|
|
38
38
|
*/
|
|
39
|
-
let Radio = class Radio extends RippleMixin(FocusableMixin(
|
|
39
|
+
let Radio = class Radio extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
40
40
|
constructor() {
|
|
41
41
|
super(...arguments);
|
|
42
42
|
/**
|
|
@@ -76,7 +76,7 @@ let Radio = class Radio extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
76
76
|
return this.isDisabled() || !this.focusable;
|
|
77
77
|
}
|
|
78
78
|
onCheckedChange() {
|
|
79
|
-
emit(
|
|
79
|
+
this.emit('change');
|
|
80
80
|
}
|
|
81
81
|
firstUpdated(_changedProperties) {
|
|
82
82
|
super.firstUpdated(_changedProperties);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { PropertyValues } from 'lit';
|
|
2
1
|
import '@mdui/jq/methods/css.js';
|
|
3
2
|
import { SliderBase } from '../slider/slider-base.js';
|
|
4
3
|
import type { Ripple } from '../ripple/index.js';
|
|
5
4
|
import type { FormControl } from '@mdui/jq/shared/form.js';
|
|
6
|
-
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
5
|
+
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
7
6
|
/**
|
|
8
7
|
* @summary 范围滑块组件
|
|
9
8
|
*
|
|
@@ -13,7 +12,7 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
13
12
|
*
|
|
14
13
|
* @event focus - 获得焦点时触发
|
|
15
14
|
* @event blur - 失去焦点时触发
|
|
16
|
-
* @event change -
|
|
15
|
+
* @event change - 值发生变更,且失去焦点时,将触发该事件
|
|
17
16
|
* @event input - 值变更时触发
|
|
18
17
|
* @event invalid - 表单字段验证未通过时触发
|
|
19
18
|
*
|
|
@@ -23,10 +22,10 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
23
22
|
* @csspart label - 提示文本
|
|
24
23
|
* @csspart tickmark - 刻度标记
|
|
25
24
|
*/
|
|
26
|
-
export declare class RangeSlider extends SliderBase implements FormControl {
|
|
25
|
+
export declare class RangeSlider extends SliderBase<RangeSliderEventMap> implements FormControl {
|
|
27
26
|
static styles: CSSResultGroup;
|
|
28
27
|
/**
|
|
29
|
-
*
|
|
28
|
+
* 默认值。在重置表单时,将重置为该默认值。此属性只能通过 JavaScript 属性设置
|
|
30
29
|
*/
|
|
31
30
|
defaultValue: number[];
|
|
32
31
|
/**
|
|
@@ -41,10 +40,9 @@ export declare class RangeSlider extends SliderBase implements FormControl {
|
|
|
41
40
|
private readonly formController;
|
|
42
41
|
private _value;
|
|
43
42
|
/**
|
|
44
|
-
*
|
|
43
|
+
* 滑块的值,为数组格式,将于表单数据一起提交。
|
|
45
44
|
*
|
|
46
|
-
* NOTE
|
|
47
|
-
* 该属性无法通过 HTML 属性设置初始值,如果要修改该值,只能通过修改 JavaScript 属性值实现。
|
|
45
|
+
* **NOTE**:该属性无法通过 HTML 属性设置初始值,如果要修改该值,只能通过修改 JavaScript 属性值实现。
|
|
48
46
|
*/
|
|
49
47
|
get value(): number[];
|
|
50
48
|
set value(_value: number[]);
|
|
@@ -60,6 +58,13 @@ export declare class RangeSlider extends SliderBase implements FormControl {
|
|
|
60
58
|
private updateStyle;
|
|
61
59
|
private onInput;
|
|
62
60
|
}
|
|
61
|
+
export interface RangeSliderEventMap {
|
|
62
|
+
focus: FocusEvent;
|
|
63
|
+
blur: FocusEvent;
|
|
64
|
+
change: CustomEvent<void>;
|
|
65
|
+
input: Event;
|
|
66
|
+
invalid: CustomEvent<void>;
|
|
67
|
+
}
|
|
63
68
|
declare global {
|
|
64
69
|
interface HTMLElementTagNameMap {
|
|
65
70
|
'mdui-range-slider': RangeSlider;
|
|
@@ -20,7 +20,7 @@ import { SliderBase } from '../slider/slider-base.js';
|
|
|
20
20
|
*
|
|
21
21
|
* @event focus - 获得焦点时触发
|
|
22
22
|
* @event blur - 失去焦点时触发
|
|
23
|
-
* @event change -
|
|
23
|
+
* @event change - 值发生变更,且失去焦点时,将触发该事件
|
|
24
24
|
* @event input - 值变更时触发
|
|
25
25
|
* @event invalid - 表单字段验证未通过时触发
|
|
26
26
|
*
|
|
@@ -34,7 +34,7 @@ let RangeSlider = class RangeSlider extends SliderBase {
|
|
|
34
34
|
constructor() {
|
|
35
35
|
super(...arguments);
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* 默认值。在重置表单时,将重置为该默认值。此属性只能通过 JavaScript 属性设置
|
|
38
38
|
*/
|
|
39
39
|
this.defaultValue = [];
|
|
40
40
|
/**
|
|
@@ -55,17 +55,16 @@ let RangeSlider = class RangeSlider extends SliderBase {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
58
|
+
* 滑块的值,为数组格式,将于表单数据一起提交。
|
|
59
59
|
*
|
|
60
|
-
* NOTE
|
|
61
|
-
* 该属性无法通过 HTML 属性设置初始值,如果要修改该值,只能通过修改 JavaScript 属性值实现。
|
|
60
|
+
* **NOTE**:该属性无法通过 HTML 属性设置初始值,如果要修改该值,只能通过修改 JavaScript 属性值实现。
|
|
62
61
|
*/
|
|
63
62
|
get value() {
|
|
64
63
|
return this._value;
|
|
65
64
|
}
|
|
66
65
|
set value(_value) {
|
|
67
66
|
const oldValue = [...this._value];
|
|
68
|
-
this._value = _value;
|
|
67
|
+
this._value = [this.fixValue(_value[0]), this.fixValue(_value[1])];
|
|
69
68
|
this.requestUpdate('value', oldValue);
|
|
70
69
|
this.updateComplete.then(() => {
|
|
71
70
|
this.updateStyle();
|
|
@@ -85,7 +84,11 @@ let RangeSlider = class RangeSlider extends SliderBase {
|
|
|
85
84
|
}
|
|
86
85
|
connectedCallback() {
|
|
87
86
|
super.connectedCallback();
|
|
88
|
-
this.value
|
|
87
|
+
if (!this.value.length) {
|
|
88
|
+
this.value = [this.min, this.max];
|
|
89
|
+
}
|
|
90
|
+
this.value[0] = this.fixValue(this.value[0]);
|
|
91
|
+
this.value[1] = this.fixValue(this.value[1]);
|
|
89
92
|
if (!this.defaultValue.length) {
|
|
90
93
|
this.defaultValue = [...this.value];
|
|
91
94
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
1
|
import '@mdui/jq/methods/addClass.js';
|
|
3
2
|
import '@mdui/jq/methods/children.js';
|
|
4
3
|
import '@mdui/jq/methods/css.js';
|
|
@@ -11,13 +10,14 @@ import '@mdui/jq/methods/offset.js';
|
|
|
11
10
|
import '@mdui/jq/methods/on.js';
|
|
12
11
|
import '@mdui/jq/methods/prependTo.js';
|
|
13
12
|
import '@mdui/jq/methods/remove.js';
|
|
13
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
14
14
|
import type { TemplateResult, CSSResultGroup } from 'lit';
|
|
15
15
|
/**
|
|
16
16
|
* 处理点击时的涟漪动画;及添加 hover、focused、dragged 的背景色
|
|
17
17
|
* 背景色通过在 .surface 元素上添加对应的 class 实现
|
|
18
18
|
* 阴影在 ripple-mixin 中处理,通过在 :host 元素上添加 attribute 供 CSS 选择器添加样式
|
|
19
19
|
*/
|
|
20
|
-
export declare class Ripple extends
|
|
20
|
+
export declare class Ripple extends MduiElement<RippleEventMap> {
|
|
21
21
|
static styles: CSSResultGroup;
|
|
22
22
|
/**
|
|
23
23
|
* 是否禁用涟漪动画
|
|
@@ -37,6 +37,8 @@ export declare class Ripple extends LitElement {
|
|
|
37
37
|
endDrag(): void;
|
|
38
38
|
protected render(): TemplateResult;
|
|
39
39
|
}
|
|
40
|
+
export interface RippleEventMap {
|
|
41
|
+
}
|
|
40
42
|
declare global {
|
|
41
43
|
interface HTMLElementTagNameMap {
|
|
42
44
|
'mdui-ripple': Ripple;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
@@ -16,6 +16,7 @@ import '@mdui/jq/methods/offset.js';
|
|
|
16
16
|
import '@mdui/jq/methods/on.js';
|
|
17
17
|
import '@mdui/jq/methods/prependTo.js';
|
|
18
18
|
import '@mdui/jq/methods/remove.js';
|
|
19
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
19
20
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
20
21
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
21
22
|
import { style } from './style.js';
|
|
@@ -24,7 +25,7 @@ import { style } from './style.js';
|
|
|
24
25
|
* 背景色通过在 .surface 元素上添加对应的 class 实现
|
|
25
26
|
* 阴影在 ripple-mixin 中处理,通过在 :host 元素上添加 attribute 供 CSS 选择器添加样式
|
|
26
27
|
*/
|
|
27
|
-
let Ripple = class Ripple extends
|
|
28
|
+
let Ripple = class Ripple extends MduiElement {
|
|
28
29
|
constructor() {
|
|
29
30
|
super(...arguments);
|
|
30
31
|
/**
|
|
@@ -3,7 +3,7 @@ import './index.js';
|
|
|
3
3
|
import type { Ripple } from './index.js';
|
|
4
4
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
5
5
|
import type { LitElement } from 'lit';
|
|
6
|
-
export declare class RippleMixinInterface
|
|
6
|
+
export declare class RippleMixinInterface {
|
|
7
7
|
noRipple: boolean;
|
|
8
8
|
protected getRippleIndex: () => number | undefined;
|
|
9
9
|
protected get rippleElement(): Ripple | Ripple[] | NodeListOf<Ripple>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const segmentedButtonGroupStyle = css `:host{--shape-corner:var(--mdui-shape-corner-full);position:relative;display:inline-flex;height:2.5rem;font-size:var(--mdui-typescale-label-large-size);font-weight:var(--mdui-typescale-label-large-weight);letter-spacing:var(--mdui-typescale-label-large-tracking);line-height:var(--mdui-typescale-label-large-line-height);color:rgb(var(--mdui-color-on-surface));--mdui-comp-ripple-state-layer-color:var(--mdui-color-on-surface)}:host([full-width]){display:flex;flex-wrap:nowrap}input,select{position:absolute;width:100%;height:100%;padding:0;opacity:0;pointer-events:none}`;
|
|
2
|
+
export const segmentedButtonGroupStyle = css `:host{--shape-corner:var(--mdui-shape-corner-full);position:relative;display:inline-flex;vertical-align:middle;height:2.5rem;font-size:var(--mdui-typescale-label-large-size);font-weight:var(--mdui-typescale-label-large-weight);letter-spacing:var(--mdui-typescale-label-large-tracking);line-height:var(--mdui-typescale-label-large-line-height);color:rgb(var(--mdui-color-on-surface));--mdui-comp-ripple-state-layer-color:var(--mdui-color-on-surface)}:host([full-width]){display:flex;flex-wrap:nowrap}input,select{position:absolute;width:100%;height:100%;padding:0;opacity:0;pointer-events:none}`;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
1
|
import '@mdui/jq/methods/find.js';
|
|
3
2
|
import '@mdui/jq/methods/get.js';
|
|
3
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
4
4
|
import type { FormControl } from '@mdui/jq/shared/form.js';
|
|
5
5
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
6
6
|
/**
|
|
7
|
-
* @summary
|
|
7
|
+
* @summary 分段按钮组件。需配合 `<mdui-segmented-button>` 组件使用
|
|
8
8
|
*
|
|
9
9
|
* ```html
|
|
10
10
|
* <mdui-segmented-button-group>
|
|
@@ -19,21 +19,21 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
19
19
|
*
|
|
20
20
|
* @slot - `<mdui-segmented-button>` 组件
|
|
21
21
|
*
|
|
22
|
-
* @cssprop --shape-corner -
|
|
22
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
23
23
|
*/
|
|
24
|
-
export declare class SegmentedButtonGroup extends
|
|
24
|
+
export declare class SegmentedButtonGroup extends MduiElement<SegmentedButtonGroupEventMap> implements FormControl {
|
|
25
25
|
static styles: CSSResultGroup;
|
|
26
26
|
/**
|
|
27
27
|
* 是否填满父元素宽度
|
|
28
28
|
*/
|
|
29
29
|
fullWidth: boolean;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* 分段按钮的可选中状态,默认为不可选中。可选值包括:
|
|
32
32
|
*
|
|
33
|
-
* * `single
|
|
34
|
-
* * `multiple
|
|
33
|
+
* * `single`:单选
|
|
34
|
+
* * `multiple`:多选
|
|
35
35
|
*/
|
|
36
|
-
selects?:
|
|
36
|
+
selects?: /*单选*/ 'single' | /*多选*/ 'multiple';
|
|
37
37
|
/**
|
|
38
38
|
* 是否为禁用状态
|
|
39
39
|
*/
|
|
@@ -43,9 +43,9 @@ export declare class SegmentedButtonGroup extends LitElement implements FormCont
|
|
|
43
43
|
*/
|
|
44
44
|
required: boolean;
|
|
45
45
|
/**
|
|
46
|
-
* 关联的
|
|
46
|
+
* 关联的 `<form>` 元素。此属性值应为同一页面中的一个 `<form>` 元素的 `id`。
|
|
47
47
|
*
|
|
48
|
-
*
|
|
48
|
+
* 如果未指定此属性,则该元素必须是 `<form>` 元素的子元素。通过此属性,你可以将元素放置在页面的任何位置,而不仅仅是 `<form>` 元素的子元素。
|
|
49
49
|
*/
|
|
50
50
|
form?: string;
|
|
51
51
|
/**
|
|
@@ -53,12 +53,9 @@ export declare class SegmentedButtonGroup extends LitElement implements FormCont
|
|
|
53
53
|
*/
|
|
54
54
|
name: string;
|
|
55
55
|
/**
|
|
56
|
-
* 当前选中的 `<mdui-segmented-button>`
|
|
56
|
+
* 当前选中的 `<mdui-segmented-button>` 的值。
|
|
57
57
|
*
|
|
58
|
-
* Note
|
|
59
|
-
* 该属性的 HTML 属性始终为字符串,且仅在 `selects="single"` 时可以通过 HTML 属性设置初始值
|
|
60
|
-
* 该属性的 JavaScript 属性值在 `selects="single"` 时为字符串,在 `selects="multiple"` 时为字符串数组。
|
|
61
|
-
* 所以,在 `selects="multiple"` 时,如果要修改该值,只能通过修改 JavaScript 属性值实现。
|
|
58
|
+
* **Note**:该属性的 HTML 属性始终为字符串,且仅在 `selects="single"` 时可以通过 HTML 属性设置初始值。该属性的 JavaScript 属性值在 `selects="single"` 时为字符串,在 `selects="multiple"` 时为字符串数组。所以,在 `selects="multiple"` 时,如果要修改该值,只能通过修改 JavaScript 属性值实现。
|
|
62
59
|
*/
|
|
63
60
|
value: string | string[];
|
|
64
61
|
/**
|
|
@@ -75,11 +72,11 @@ export declare class SegmentedButtonGroup extends LitElement implements FormCont
|
|
|
75
72
|
private readonly formController;
|
|
76
73
|
private readonly definedController;
|
|
77
74
|
/**
|
|
78
|
-
*
|
|
75
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
79
76
|
*/
|
|
80
77
|
get validity(): ValidityState;
|
|
81
78
|
/**
|
|
82
|
-
*
|
|
79
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
83
80
|
*/
|
|
84
81
|
get validationMessage(): string;
|
|
85
82
|
private get items();
|
|
@@ -93,19 +90,19 @@ export declare class SegmentedButtonGroup extends LitElement implements FormCont
|
|
|
93
90
|
private onInvalidChange;
|
|
94
91
|
connectedCallback(): void;
|
|
95
92
|
/**
|
|
96
|
-
*
|
|
93
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
97
94
|
*/
|
|
98
95
|
checkValidity(): boolean;
|
|
99
96
|
/**
|
|
100
|
-
*
|
|
97
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
101
98
|
*
|
|
102
|
-
*
|
|
99
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
103
100
|
*/
|
|
104
101
|
reportValidity(): boolean;
|
|
105
102
|
/**
|
|
106
|
-
*
|
|
103
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
107
104
|
*
|
|
108
|
-
* @param message
|
|
105
|
+
* @param message 自定义的错误提示文本
|
|
109
106
|
*/
|
|
110
107
|
setCustomValidity(message: string): void;
|
|
111
108
|
protected render(): TemplateResult;
|
|
@@ -121,6 +118,10 @@ export declare class SegmentedButtonGroup extends LitElement implements FormCont
|
|
|
121
118
|
private setValue;
|
|
122
119
|
private updateItems;
|
|
123
120
|
}
|
|
121
|
+
export interface SegmentedButtonGroupEventMap {
|
|
122
|
+
change: CustomEvent<void>;
|
|
123
|
+
invalid: CustomEvent<void>;
|
|
124
|
+
}
|
|
124
125
|
declare global {
|
|
125
126
|
interface HTMLElementTagNameMap {
|
|
126
127
|
'mdui-segmented-button-group': SegmentedButtonGroup;
|