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
|
@@ -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,14 +27,14 @@ 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
39
|
let Radio = class Radio extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
40
40
|
constructor() {
|
|
@@ -91,11 +91,29 @@ let Radio = class Radio extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
91
91
|
invalid: this.invalid,
|
|
92
92
|
initial: this.isInitial,
|
|
93
93
|
});
|
|
94
|
-
return html `<i part="control" class
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
return html `<i part="control" class=${className}>
|
|
95
|
+
<mdui-ripple
|
|
96
|
+
${ref(this.rippleRef)}
|
|
97
|
+
.noRipple=${this.noRipple}
|
|
98
|
+
></mdui-ripple>
|
|
99
|
+
<slot
|
|
100
|
+
name="unchecked-icon"
|
|
101
|
+
part="unchecked-icon"
|
|
102
|
+
class="icon unchecked-icon"
|
|
103
|
+
>
|
|
104
|
+
${this.uncheckedIcon
|
|
105
|
+
? html `<mdui-icon name=${this.uncheckedIcon} class="i"></mdui-icon>`
|
|
106
|
+
: html `<mdui-icon-radio-button-unchecked
|
|
107
|
+
class="i"
|
|
108
|
+
></mdui-icon-radio-button-unchecked>`}
|
|
109
|
+
</slot>
|
|
110
|
+
<slot name="checked-icon" part="checked-icon" class="icon checked-icon">
|
|
111
|
+
${this.checkedIcon
|
|
112
|
+
? html `<mdui-icon name=${this.checkedIcon} class="i"></mdui-icon>`
|
|
113
|
+
: html `<mdui-icon-circle class="i"></mdui-icon-circle>`}
|
|
114
|
+
</slot>
|
|
115
|
+
</i>
|
|
116
|
+
<slot part="label" class="label ${className}"></slot>`;
|
|
99
117
|
}
|
|
100
118
|
isDisabled() {
|
|
101
119
|
return this.disabled || this.groupDisabled;
|
|
@@ -12,7 +12,7 @@ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
|
12
12
|
*
|
|
13
13
|
* @event focus - 获得焦点时触发
|
|
14
14
|
* @event blur - 失去焦点时触发
|
|
15
|
-
* @event change -
|
|
15
|
+
* @event change - 值发生变更,且失去焦点时,将触发该事件
|
|
16
16
|
* @event input - 值变更时触发
|
|
17
17
|
* @event invalid - 表单字段验证未通过时触发
|
|
18
18
|
*
|
|
@@ -25,7 +25,7 @@ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
|
25
25
|
export declare class RangeSlider extends SliderBase<RangeSliderEventMap> implements FormControl {
|
|
26
26
|
static styles: CSSResultGroup;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* 默认值。在重置表单时,将重置为该默认值。此属性只能通过 JavaScript 属性设置
|
|
29
29
|
*/
|
|
30
30
|
defaultValue: number[];
|
|
31
31
|
/**
|
|
@@ -40,10 +40,9 @@ export declare class RangeSlider extends SliderBase<RangeSliderEventMap> impleme
|
|
|
40
40
|
private readonly formController;
|
|
41
41
|
private _value;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* 滑块的值,为数组格式,将于表单数据一起提交。
|
|
44
44
|
*
|
|
45
|
-
* NOTE
|
|
46
|
-
* 该属性无法通过 HTML 属性设置初始值,如果要修改该值,只能通过修改 JavaScript 属性值实现。
|
|
45
|
+
* **NOTE**:该属性无法通过 HTML 属性设置初始值,如果要修改该值,只能通过修改 JavaScript 属性值实现。
|
|
47
46
|
*/
|
|
48
47
|
get value(): number[];
|
|
49
48
|
set value(_value: number[]);
|
|
@@ -55,7 +54,7 @@ export declare class RangeSlider extends SliderBase<RangeSliderEventMap> impleme
|
|
|
55
54
|
* <input class="invalid" /> 用于提供 html5 自带的表单错误提示
|
|
56
55
|
*/
|
|
57
56
|
protected render(): TemplateResult;
|
|
58
|
-
protected getRippleIndex: () =>
|
|
57
|
+
protected getRippleIndex: () => 1 | 0;
|
|
59
58
|
private updateStyle;
|
|
60
59
|
private onInput;
|
|
61
60
|
}
|
|
@@ -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,10 +55,9 @@ 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;
|
|
@@ -144,18 +143,66 @@ let RangeSlider = class RangeSlider extends SliderBase {
|
|
|
144
143
|
* <input class="invalid" /> 用于提供 html5 自带的表单错误提示
|
|
145
144
|
*/
|
|
146
145
|
render() {
|
|
147
|
-
return html `<label class
|
|
146
|
+
return html `<label class=${classMap({ invalid: this.invalid })}>
|
|
147
|
+
<input
|
|
148
|
+
${ref(this.inputRef)}
|
|
149
|
+
type="range"
|
|
150
|
+
step=${this.step}
|
|
151
|
+
min=${this.min}
|
|
152
|
+
max=${this.max}
|
|
153
|
+
?disabled=${this.disabled}
|
|
154
|
+
@input=${this.onInput}
|
|
155
|
+
@change=${this.onChange}
|
|
156
|
+
/>
|
|
157
|
+
<div part="track-inactive" class="track-inactive"></div>
|
|
158
|
+
<div
|
|
159
|
+
${ref(this.trackActiveRef)}
|
|
160
|
+
part="track-active"
|
|
161
|
+
class="track-active"
|
|
162
|
+
></div>
|
|
163
|
+
<div
|
|
164
|
+
${ref(this.handleStartRef)}
|
|
165
|
+
part="handle"
|
|
166
|
+
class="handle start"
|
|
167
|
+
style=${styleMap({
|
|
148
168
|
'z-index': this.currentHandle === 'start' ? '2' : '1',
|
|
149
|
-
})}
|
|
169
|
+
})}
|
|
170
|
+
>
|
|
171
|
+
<div class="elevation"></div>
|
|
172
|
+
<mdui-ripple
|
|
173
|
+
${ref(this.rippleStartRef)}
|
|
174
|
+
.noRipple=${this.noRipple}
|
|
175
|
+
></mdui-ripple>
|
|
176
|
+
${this.renderLabel(this.value[0])}
|
|
177
|
+
</div>
|
|
178
|
+
<div
|
|
179
|
+
${ref(this.handleEndRef)}
|
|
180
|
+
part="handle"
|
|
181
|
+
class="handle end"
|
|
182
|
+
style=${styleMap({
|
|
150
183
|
'z-index': this.currentHandle === 'end' ? '2' : '1',
|
|
151
|
-
})}
|
|
184
|
+
})}
|
|
185
|
+
>
|
|
186
|
+
<div class="elevation"></div>
|
|
187
|
+
<mdui-ripple
|
|
188
|
+
${ref(this.rippleEndRef)}
|
|
189
|
+
.noRipple=${this.noRipple}
|
|
190
|
+
></mdui-ripple>
|
|
191
|
+
${this.renderLabel(this.value[1])}
|
|
192
|
+
</div>
|
|
193
|
+
${when(this.tickmarks, () => map(this.getCandidateValues(), (value) => html `<div
|
|
194
|
+
part="tickmark"
|
|
195
|
+
class="tickmark ${classMap({
|
|
152
196
|
active: value > this.value[0] && value < this.value[1],
|
|
153
|
-
})}"
|
|
197
|
+
})}"
|
|
198
|
+
style="${styleMap({
|
|
154
199
|
left: `${((value - this.min) / this.max) * 100}%`,
|
|
155
200
|
display: value === this.value[0] || value === this.value[1]
|
|
156
201
|
? 'none'
|
|
157
202
|
: 'block',
|
|
158
|
-
})}"
|
|
203
|
+
})}"
|
|
204
|
+
></div>`))}
|
|
205
|
+
</label>`;
|
|
159
206
|
}
|
|
160
207
|
updateStyle() {
|
|
161
208
|
const getPercent = (value) => ((value - this.min) / (this.max - this.min)) * 100;
|
|
@@ -144,11 +144,14 @@ let Ripple = class Ripple extends MduiElement {
|
|
|
144
144
|
this.dragged = false;
|
|
145
145
|
}
|
|
146
146
|
render() {
|
|
147
|
-
return html `<div
|
|
147
|
+
return html `<div
|
|
148
|
+
${ref(this.surfaceRef)}
|
|
149
|
+
class="surface ${classMap({
|
|
148
150
|
hover: this.hover,
|
|
149
151
|
focused: this.focused,
|
|
150
152
|
dragged: this.dragged,
|
|
151
|
-
})}"
|
|
153
|
+
})}"
|
|
154
|
+
></div>`;
|
|
152
155
|
}
|
|
153
156
|
};
|
|
154
157
|
Ripple.styles = [componentStyle, style];
|
|
@@ -1,2 +1,97 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css
|
|
2
|
+
export const style = css `
|
|
3
|
+
:host {
|
|
4
|
+
position: absolute;
|
|
5
|
+
top: 0;
|
|
6
|
+
left: 0;
|
|
7
|
+
display: block;
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
pointer-events: none;
|
|
12
|
+
}
|
|
13
|
+
.surface {
|
|
14
|
+
position: absolute;
|
|
15
|
+
top: 0;
|
|
16
|
+
left: 0;
|
|
17
|
+
width: 100%;
|
|
18
|
+
height: 100%;
|
|
19
|
+
transition-duration: 280ms;
|
|
20
|
+
transition-property: background-color;
|
|
21
|
+
pointer-events: none;
|
|
22
|
+
transition-timing-function: var(--mdui-motion-easing-standard);
|
|
23
|
+
}
|
|
24
|
+
.hover {
|
|
25
|
+
background-color: rgba(
|
|
26
|
+
var(--mdui-comp-ripple-state-layer-color, var(--mdui-color-on-surface)),
|
|
27
|
+
var(--mdui-state-layer-hover)
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
:host-context([focus-visible]) .focused {
|
|
31
|
+
background-color: rgba(
|
|
32
|
+
var(--mdui-comp-ripple-state-layer-color, var(--mdui-color-on-surface)),
|
|
33
|
+
var(--mdui-state-layer-focus)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
.dragged {
|
|
37
|
+
background-color: rgba(
|
|
38
|
+
var(--mdui-comp-ripple-state-layer-color, var(--mdui-color-on-surface)),
|
|
39
|
+
var(--mdui-state-layer-dragged)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
.wave {
|
|
43
|
+
position: absolute;
|
|
44
|
+
z-index: 1;
|
|
45
|
+
background-color: rgb(
|
|
46
|
+
var(--mdui-comp-ripple-state-layer-color, var(--mdui-color-on-surface))
|
|
47
|
+
);
|
|
48
|
+
border-radius: 50%;
|
|
49
|
+
transform: translate3d(0, 0, 0) scale(0.4);
|
|
50
|
+
opacity: 0;
|
|
51
|
+
animation:
|
|
52
|
+
225ms ease 0s 1 normal forwards running mdui-comp-ripple-radius-in,
|
|
53
|
+
75ms ease 0s 1 normal forwards running mdui-comp-ripple-opacity-in;
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
}
|
|
56
|
+
.out {
|
|
57
|
+
transform: translate3d(
|
|
58
|
+
var(--mdui-comp-ripple-transition-x, 0),
|
|
59
|
+
var(--mdui-comp-ripple-transition-y, 0),
|
|
60
|
+
0
|
|
61
|
+
)
|
|
62
|
+
scale(1);
|
|
63
|
+
animation: 150ms ease 0s 1 normal none running mdui-comp-ripple-opacity-out;
|
|
64
|
+
}
|
|
65
|
+
@keyframes mdui-comp-ripple-radius-in {
|
|
66
|
+
from {
|
|
67
|
+
transform: translate3d(0, 0, 0) scale(0.4);
|
|
68
|
+
animation-timing-function: var(--mdui-motion-easing-standard);
|
|
69
|
+
}
|
|
70
|
+
to {
|
|
71
|
+
transform: translate3d(
|
|
72
|
+
var(--mdui-comp-ripple-transition-x, 0),
|
|
73
|
+
var(--mdui-comp-ripple-transition-y, 0),
|
|
74
|
+
0
|
|
75
|
+
)
|
|
76
|
+
scale(1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
@keyframes mdui-comp-ripple-opacity-in {
|
|
80
|
+
from {
|
|
81
|
+
opacity: 0;
|
|
82
|
+
animation-timing-function: linear;
|
|
83
|
+
}
|
|
84
|
+
to {
|
|
85
|
+
opacity: var(--mdui-state-layer-pressed);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
@keyframes mdui-comp-ripple-opacity-out {
|
|
89
|
+
from {
|
|
90
|
+
animation-timing-function: linear;
|
|
91
|
+
opacity: var(--mdui-state-layer-pressed);
|
|
92
|
+
}
|
|
93
|
+
to {
|
|
94
|
+
opacity: 0;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
`;
|
|
@@ -1,2 +1,29 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const segmentedButtonGroupStyle = css
|
|
2
|
+
export const segmentedButtonGroupStyle = css `
|
|
3
|
+
:host {
|
|
4
|
+
--shape-corner: var(--mdui-shape-corner-full);
|
|
5
|
+
position: relative;
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
vertical-align: middle;
|
|
8
|
+
height: 2.5rem;
|
|
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
|
+
color: rgb(var(--mdui-color-on-surface));
|
|
14
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
|
|
15
|
+
}
|
|
16
|
+
:host([full-width]) {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-wrap: nowrap;
|
|
19
|
+
}
|
|
20
|
+
input,
|
|
21
|
+
select {
|
|
22
|
+
position: absolute;
|
|
23
|
+
width: 100%;
|
|
24
|
+
height: 100%;
|
|
25
|
+
padding: 0;
|
|
26
|
+
opacity: 0;
|
|
27
|
+
pointer-events: none;
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
@@ -4,7 +4,7 @@ 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,7 +19,7 @@ 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
24
|
export declare class SegmentedButtonGroup extends MduiElement<SegmentedButtonGroupEventMap> implements FormControl {
|
|
25
25
|
static styles: CSSResultGroup;
|
|
@@ -28,12 +28,12 @@ export declare class SegmentedButtonGroup extends MduiElement<SegmentedButtonGro
|
|
|
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 MduiElement<SegmentedButtonGro
|
|
|
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 MduiElement<SegmentedButtonGro
|
|
|
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 MduiElement<SegmentedButtonGro
|
|
|
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 MduiElement<SegmentedButtonGro
|
|
|
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;
|
|
@@ -19,7 +19,7 @@ import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
|
19
19
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
20
20
|
import { segmentedButtonGroupStyle } from './segmented-button-group-style.js';
|
|
21
21
|
/**
|
|
22
|
-
* @summary
|
|
22
|
+
* @summary 分段按钮组件。需配合 `<mdui-segmented-button>` 组件使用
|
|
23
23
|
*
|
|
24
24
|
* ```html
|
|
25
25
|
* <mdui-segmented-button-group>
|
|
@@ -34,7 +34,7 @@ import { segmentedButtonGroupStyle } from './segmented-button-group-style.js';
|
|
|
34
34
|
*
|
|
35
35
|
* @slot - `<mdui-segmented-button>` 组件
|
|
36
36
|
*
|
|
37
|
-
* @cssprop --shape-corner -
|
|
37
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
38
38
|
*/
|
|
39
39
|
let SegmentedButtonGroup = class SegmentedButtonGroup extends MduiElement {
|
|
40
40
|
constructor() {
|
|
@@ -56,12 +56,9 @@ let SegmentedButtonGroup = class SegmentedButtonGroup extends MduiElement {
|
|
|
56
56
|
*/
|
|
57
57
|
this.name = '';
|
|
58
58
|
/**
|
|
59
|
-
* 当前选中的 `<mdui-segmented-button>`
|
|
59
|
+
* 当前选中的 `<mdui-segmented-button>` 的值。
|
|
60
60
|
*
|
|
61
|
-
* Note
|
|
62
|
-
* 该属性的 HTML 属性始终为字符串,且仅在 `selects="single"` 时可以通过 HTML 属性设置初始值
|
|
63
|
-
* 该属性的 JavaScript 属性值在 `selects="single"` 时为字符串,在 `selects="multiple"` 时为字符串数组。
|
|
64
|
-
* 所以,在 `selects="multiple"` 时,如果要修改该值,只能通过修改 JavaScript 属性值实现。
|
|
61
|
+
* **Note**:该属性的 HTML 属性始终为字符串,且仅在 `selects="single"` 时可以通过 HTML 属性设置初始值。该属性的 JavaScript 属性值在 `selects="single"` 时为字符串,在 `selects="multiple"` 时为字符串数组。所以,在 `selects="multiple"` 时,如果要修改该值,只能通过修改 JavaScript 属性值实现。
|
|
65
62
|
*/
|
|
66
63
|
this.value = '';
|
|
67
64
|
/**
|
|
@@ -83,13 +80,13 @@ let SegmentedButtonGroup = class SegmentedButtonGroup extends MduiElement {
|
|
|
83
80
|
});
|
|
84
81
|
}
|
|
85
82
|
/**
|
|
86
|
-
*
|
|
83
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
87
84
|
*/
|
|
88
85
|
get validity() {
|
|
89
86
|
return this.inputRef.value.validity;
|
|
90
87
|
}
|
|
91
88
|
/**
|
|
92
|
-
*
|
|
89
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
93
90
|
*/
|
|
94
91
|
get validationMessage() {
|
|
95
92
|
return this.inputRef.value.validationMessage;
|
|
@@ -195,7 +192,7 @@ let SegmentedButtonGroup = class SegmentedButtonGroup extends MduiElement {
|
|
|
195
192
|
this.defaultValue = this.selects === 'multiple' ? [] : '';
|
|
196
193
|
}
|
|
197
194
|
/**
|
|
198
|
-
*
|
|
195
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
199
196
|
*/
|
|
200
197
|
checkValidity() {
|
|
201
198
|
const valid = this.inputRef.value.checkValidity();
|
|
@@ -209,9 +206,9 @@ let SegmentedButtonGroup = class SegmentedButtonGroup extends MduiElement {
|
|
|
209
206
|
return valid;
|
|
210
207
|
}
|
|
211
208
|
/**
|
|
212
|
-
*
|
|
209
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
213
210
|
*
|
|
214
|
-
*
|
|
211
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
215
212
|
*/
|
|
216
213
|
reportValidity() {
|
|
217
214
|
this.invalid = !this.inputRef.value.reportValidity();
|
|
@@ -230,16 +227,36 @@ let SegmentedButtonGroup = class SegmentedButtonGroup extends MduiElement {
|
|
|
230
227
|
return !this.invalid;
|
|
231
228
|
}
|
|
232
229
|
/**
|
|
233
|
-
*
|
|
230
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
234
231
|
*
|
|
235
|
-
* @param message
|
|
232
|
+
* @param message 自定义的错误提示文本
|
|
236
233
|
*/
|
|
237
234
|
setCustomValidity(message) {
|
|
238
235
|
this.inputRef.value.setCustomValidity(message);
|
|
239
236
|
this.invalid = !this.inputRef.value.checkValidity();
|
|
240
237
|
}
|
|
241
238
|
render() {
|
|
242
|
-
return html `${when(this.isSelectable && this.isSingle, () => html `<input
|
|
239
|
+
return html `${when(this.isSelectable && this.isSingle, () => html `<input
|
|
240
|
+
${ref(this.inputRef)}
|
|
241
|
+
type="radio"
|
|
242
|
+
name=${ifDefined(this.name)}
|
|
243
|
+
value="1"
|
|
244
|
+
.disabled=${this.disabled}
|
|
245
|
+
.required=${this.required}
|
|
246
|
+
.checked=${!!this.value}
|
|
247
|
+
tabindex="-1"
|
|
248
|
+
@keydown=${this.onInputKeyDown}
|
|
249
|
+
/>`)}${when(this.isSelectable && this.isMultiple, () => html `<select
|
|
250
|
+
${ref(this.inputRef)}
|
|
251
|
+
name=${ifDefined(this.name)}
|
|
252
|
+
.disabled=${this.disabled}
|
|
253
|
+
.required=${this.required}
|
|
254
|
+
multiple
|
|
255
|
+
tabindex="-1"
|
|
256
|
+
@keydown=${this.onInputKeyDown}
|
|
257
|
+
>
|
|
258
|
+
${map(this.value, (value) => html `<option selected value=${value}></option>`)}
|
|
259
|
+
</select>`)}<slot @slotchange=${this.onSlotChange} @click=${this.onClick}></slot>`;
|
|
243
260
|
}
|
|
244
261
|
// 切换一个元素的选中状态
|
|
245
262
|
selectOne(item) {
|
|
@@ -1,4 +1,83 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const segmentedButtonStyle = css
|
|
2
|
+
export const segmentedButtonStyle = css `
|
|
3
|
+
:host {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
flex-grow: 1;
|
|
7
|
+
flex-shrink: 0;
|
|
8
|
+
float: left;
|
|
9
|
+
height: 100%;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
-webkit-tap-highlight-color: transparent;
|
|
13
|
+
border: 0.0625rem solid rgb(var(--mdui-color-outline));
|
|
14
|
+
}
|
|
15
|
+
.button {
|
|
16
|
+
width: 100%;
|
|
17
|
+
padding: 0rem 0.75rem;
|
|
18
|
+
}
|
|
19
|
+
:host([invalid]) {
|
|
20
|
+
color: rgb(var(--mdui-color-error));
|
|
21
|
+
border-color: rgb(var(--mdui-color-error));
|
|
22
|
+
}
|
|
23
|
+
:host([invalid]) .button {
|
|
24
|
+
background-color: rgb(var(--mdui-color-error-container));
|
|
25
|
+
}
|
|
26
|
+
:host([selected]) {
|
|
27
|
+
color: rgb(var(--mdui-color-on-secondary-container));
|
|
28
|
+
background-color: rgb(var(--mdui-color-secondary-container));
|
|
29
|
+
--mdui-comp-ripple-state-layer-color: var(
|
|
3
30
|
--mdui-color-on-secondary-container
|
|
4
|
-
)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
:host([disabled]),
|
|
34
|
+
:host([group-disabled]) {
|
|
35
|
+
cursor: default;
|
|
36
|
+
pointer-events: none;
|
|
37
|
+
color: rgba(var(--mdui-color-on-surface), 38%);
|
|
38
|
+
border-color: rgba(var(--mdui-color-on-surface), 12%);
|
|
39
|
+
}
|
|
40
|
+
:host([loading]) {
|
|
41
|
+
cursor: default;
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
}
|
|
44
|
+
:host(:not(.mdui-segmented-button-first)) {
|
|
45
|
+
margin-left: -0.0625rem;
|
|
46
|
+
}
|
|
47
|
+
:host(.mdui-segmented-button-first) {
|
|
48
|
+
border-radius: var(--shape-corner) 0 0 var(--shape-corner);
|
|
49
|
+
}
|
|
50
|
+
:host(.mdui-segmented-button-last) {
|
|
51
|
+
border-radius: 0 var(--shape-corner) var(--shape-corner) 0;
|
|
52
|
+
}
|
|
53
|
+
.icon,
|
|
54
|
+
.end-icon,
|
|
55
|
+
.selected-icon {
|
|
56
|
+
display: inline-flex;
|
|
57
|
+
font-size: 1.28571429em;
|
|
58
|
+
}
|
|
59
|
+
.icon .i,
|
|
60
|
+
.end-icon .i,
|
|
61
|
+
.selected-icon .i,
|
|
62
|
+
::slotted([slot='icon']),
|
|
63
|
+
::slotted([slot='end-icon']),
|
|
64
|
+
::slotted([slot='selected-icon']) {
|
|
65
|
+
font-size: inherit;
|
|
66
|
+
}
|
|
67
|
+
mdui-circular-progress {
|
|
68
|
+
width: 1.125rem;
|
|
69
|
+
height: 1.125rem;
|
|
70
|
+
}
|
|
71
|
+
:host([disabled]) mdui-circular-progress {
|
|
72
|
+
opacity: 0.38;
|
|
73
|
+
}
|
|
74
|
+
.label {
|
|
75
|
+
display: inline-flex;
|
|
76
|
+
}
|
|
77
|
+
.has-icon .label {
|
|
78
|
+
padding-left: 0.5rem;
|
|
79
|
+
}
|
|
80
|
+
.has-end-icon .label {
|
|
81
|
+
padding-right: 0.5rem;
|
|
82
|
+
}
|
|
83
|
+
`;
|