mdui 2.0.4 → 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.js +7 -2
- package/components/avatar/style.js +31 -1
- package/components/badge/style.js +25 -1
- package/components/bottom-app-bar/style.js +92 -1
- package/components/button/button-base-style.js +28 -1
- package/components/button/button-base.js +8 -1
- package/components/button/index.js +18 -8
- package/components/button/style.js +111 -2
- package/components/button-icon/index.js +22 -5
- package/components/button-icon/style.js +103 -2
- package/components/card/index.js +5 -1
- package/components/card/style.js +72 -1
- package/components/checkbox/index.js +50 -7
- package/components/checkbox/style.js +131 -1
- package/components/chip/index.js +33 -9
- package/components/chip/style.js +205 -2
- package/components/circular-progress/index.js +39 -5
- package/components/circular-progress/style.js +136 -1
- package/components/collapse/collapse-item-style.js +21 -1
- package/components/collapse/collapse-item.js +10 -2
- package/components/collapse/collapse-style.js +5 -1
- package/components/collapse/collapse.js +4 -1
- package/components/dialog/index.js +35 -7
- package/components/dialog/style.js +116 -1
- package/components/divider/style.js +18 -1
- package/components/dropdown/index.js +8 -1
- package/components/dropdown/style.js +11 -1
- package/components/fab/index.js +13 -5
- 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-main-style.js +7 -1
- package/components/layout/layout-style.js +11 -1
- package/components/linear-progress/index.js +6 -2
- package/components/linear-progress/style.js +73 -1
- package/components/list/list-item-style.js +153 -2
- package/components/list/list-item.js +27 -8
- package/components/list/list-style.js +10 -1
- package/components/list/list-subheader-style.js +19 -1
- package/components/menu/menu-item-style.js +125 -1
- package/components/menu/menu-item.js +55 -13
- package/components/menu/menu-style.js +19 -1
- package/components/menu/menu.js +5 -1
- package/components/navigation-bar/navigation-bar-item-style.js +132 -1
- package/components/navigation-bar/navigation-bar-item.js +23 -7
- package/components/navigation-bar/navigation-bar-style.js +28 -1
- package/components/navigation-bar/navigation-bar.js +4 -1
- package/components/navigation-drawer/index.js +12 -1
- 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.js +26 -7
- package/components/navigation-rail/navigation-rail-style.js +79 -1
- package/components/navigation-rail/navigation-rail.js +10 -1
- package/components/radio/radio-group-style.js +20 -1
- package/components/radio/radio-group.js +19 -1
- package/components/radio/radio-style.js +107 -1
- package/components/radio/radio.js +23 -5
- package/components/range-slider/index.d.ts +1 -1
- package/components/range-slider/index.js +53 -5
- 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.js +21 -1
- package/components/segmented-button/segmented-button-style.js +81 -2
- package/components/segmented-button/segmented-button.js +27 -11
- package/components/select/index.js +87 -6
- package/components/select/style.js +27 -1
- package/components/slider/index.js +33 -2
- package/components/slider/slider-base-style.js +173 -1
- package/components/slider/slider-base.js +6 -1
- package/components/slider/style.js +7 -1
- package/components/snackbar/index.js +32 -5
- package/components/snackbar/style.js +100 -1
- package/components/switch/index.js +40 -6
- package/components/switch/style.js +202 -1
- package/components/tabs/tab-panel-style.js +10 -1
- package/components/tabs/tab-style.js +85 -1
- package/components/tabs/tab.js +24 -4
- package/components/tabs/tabs-style.js +138 -1
- package/components/tabs/tabs.js +9 -1
- package/components/text-field/index.js +160 -32
- package/components/text-field/style.js +362 -1
- package/components/tooltip/index.js +10 -1
- 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.js +17 -3
- package/custom-elements.json +1144 -1101
- package/html-data.en.json +15 -6
- package/html-data.zh-cn.json +15 -6
- package/jsx.en.d.ts +2 -2
- package/jsx.zh-cn.d.ts +2 -2
- package/package.json +2 -2
- package/web-types.en.json +20 -4
- package/web-types.zh-cn.json +20 -4
- package/mdui.esm.js +0 -22
- package/mdui.global.js +0 -22
|
@@ -1,2 +1,108 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const radioStyle = css
|
|
2
|
+
export const radioStyle = css `
|
|
3
|
+
:host {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
-webkit-tap-highlight-color: transparent;
|
|
9
|
+
-webkit-user-select: none;
|
|
10
|
+
user-select: none;
|
|
11
|
+
touch-action: manipulation;
|
|
12
|
+
zoom: 1;
|
|
13
|
+
-webkit-user-drag: none;
|
|
14
|
+
border-radius: 0.125rem;
|
|
15
|
+
font-size: var(--mdui-typescale-label-large-size);
|
|
16
|
+
font-weight: var(--mdui-typescale-label-large-weight);
|
|
17
|
+
letter-spacing: var(--mdui-typescale-label-large-tracking);
|
|
18
|
+
line-height: var(--mdui-typescale-label-large-line-height);
|
|
19
|
+
}
|
|
20
|
+
.icon {
|
|
21
|
+
display: flex;
|
|
22
|
+
position: absolute;
|
|
23
|
+
font-size: 1.5rem;
|
|
24
|
+
}
|
|
25
|
+
:not(.initial) .icon {
|
|
26
|
+
transition-duration: var(--mdui-motion-duration-short4);
|
|
27
|
+
transition-timing-function: var(--mdui-motion-easing-standard);
|
|
28
|
+
}
|
|
29
|
+
.unchecked-icon {
|
|
30
|
+
transition-property: color;
|
|
31
|
+
color: rgb(var(--mdui-color-on-surface-variant));
|
|
32
|
+
}
|
|
33
|
+
:host([hover]) .unchecked-icon,
|
|
34
|
+
:host([focused]) .unchecked-icon,
|
|
35
|
+
:host([pressed]) .unchecked-icon {
|
|
36
|
+
color: rgb(var(--mdui-color-on-surface));
|
|
37
|
+
}
|
|
38
|
+
.checked-icon {
|
|
39
|
+
opacity: 0;
|
|
40
|
+
transform: scale(0.2);
|
|
41
|
+
transition-property: color, opacity, transform;
|
|
42
|
+
color: rgb(var(--mdui-color-primary));
|
|
43
|
+
}
|
|
44
|
+
.icon .i,
|
|
45
|
+
::slotted([slot='unchecked-icon']),
|
|
46
|
+
::slotted([slot='checked-icon']) {
|
|
47
|
+
color: inherit;
|
|
48
|
+
font-size: inherit;
|
|
49
|
+
}
|
|
50
|
+
i {
|
|
51
|
+
position: relative;
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
overflow: hidden;
|
|
56
|
+
border-radius: 50%;
|
|
57
|
+
width: 2.5rem;
|
|
58
|
+
min-width: 2.5rem;
|
|
59
|
+
height: 2.5rem;
|
|
60
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
|
|
61
|
+
}
|
|
62
|
+
.label {
|
|
63
|
+
display: flex;
|
|
64
|
+
width: 100%;
|
|
65
|
+
padding-top: 0.625rem;
|
|
66
|
+
padding-bottom: 0.625rem;
|
|
67
|
+
color: rgb(var(--mdui-color-on-surface));
|
|
68
|
+
}
|
|
69
|
+
.label:not(.initial) {
|
|
70
|
+
transition: color var(--mdui-motion-duration-short4)
|
|
71
|
+
var(--mdui-motion-easing-standard);
|
|
72
|
+
}
|
|
73
|
+
/* 选中状态的图标 */
|
|
74
|
+
:host([checked]) i {
|
|
75
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
|
|
76
|
+
}
|
|
77
|
+
:host([checked]) .icon {
|
|
78
|
+
color: rgb(var(--mdui-color-primary));
|
|
79
|
+
}
|
|
80
|
+
:host([checked]) .checked-icon {
|
|
81
|
+
opacity: 1;
|
|
82
|
+
transform: scale(0.5);
|
|
83
|
+
}
|
|
84
|
+
/* 验证不通过状态 */
|
|
85
|
+
i.invalid {
|
|
86
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-error);
|
|
87
|
+
}
|
|
88
|
+
i.invalid .icon {
|
|
89
|
+
color: rgb(var(--mdui-color-error));
|
|
90
|
+
}
|
|
91
|
+
.label.invalid {
|
|
92
|
+
color: rgb(var(--mdui-color-error));
|
|
93
|
+
}
|
|
94
|
+
/* 禁用状态的图标 */
|
|
95
|
+
:host([disabled]),
|
|
96
|
+
:host([group-disabled]) {
|
|
97
|
+
cursor: default;
|
|
98
|
+
pointer-events: none;
|
|
99
|
+
}
|
|
100
|
+
:host([disabled]) .icon,
|
|
101
|
+
:host([group-disabled]) .icon {
|
|
102
|
+
color: rgba(var(--mdui-color-on-surface), 38%);
|
|
103
|
+
}
|
|
104
|
+
:host([disabled]) .label,
|
|
105
|
+
:host([group-disabled]) .label {
|
|
106
|
+
color: rgba(var(--mdui-color-on-surface), 38%);
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
@@ -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;
|
|
@@ -54,7 +54,7 @@ export declare class RangeSlider extends SliderBase<RangeSliderEventMap> impleme
|
|
|
54
54
|
* <input class="invalid" /> 用于提供 html5 自带的表单错误提示
|
|
55
55
|
*/
|
|
56
56
|
protected render(): TemplateResult;
|
|
57
|
-
protected getRippleIndex: () =>
|
|
57
|
+
protected getRippleIndex: () => 1 | 0;
|
|
58
58
|
private updateStyle;
|
|
59
59
|
private onInput;
|
|
60
60
|
}
|
|
@@ -143,18 +143,66 @@ let RangeSlider = class RangeSlider extends SliderBase {
|
|
|
143
143
|
* <input class="invalid" /> 用于提供 html5 自带的表单错误提示
|
|
144
144
|
*/
|
|
145
145
|
render() {
|
|
146
|
-
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({
|
|
147
168
|
'z-index': this.currentHandle === 'start' ? '2' : '1',
|
|
148
|
-
})}
|
|
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({
|
|
149
183
|
'z-index': this.currentHandle === 'end' ? '2' : '1',
|
|
150
|
-
})}
|
|
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({
|
|
151
196
|
active: value > this.value[0] && value < this.value[1],
|
|
152
|
-
})}"
|
|
197
|
+
})}"
|
|
198
|
+
style="${styleMap({
|
|
153
199
|
left: `${((value - this.min) / this.max) * 100}%`,
|
|
154
200
|
display: value === this.value[0] || value === this.value[1]
|
|
155
201
|
? 'none'
|
|
156
202
|
: 'block',
|
|
157
|
-
})}"
|
|
203
|
+
})}"
|
|
204
|
+
></div>`))}
|
|
205
|
+
</label>`;
|
|
158
206
|
}
|
|
159
207
|
updateStyle() {
|
|
160
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
|
+
`;
|
|
@@ -236,7 +236,27 @@ let SegmentedButtonGroup = class SegmentedButtonGroup extends MduiElement {
|
|
|
236
236
|
this.invalid = !this.inputRef.value.checkValidity();
|
|
237
237
|
}
|
|
238
238
|
render() {
|
|
239
|
-
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>`;
|
|
240
260
|
}
|
|
241
261
|
// 切换一个元素的选中状态
|
|
242
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
|
+
`;
|
|
@@ -74,14 +74,20 @@ let SegmentedButton = class SegmentedButton extends ButtonBase {
|
|
|
74
74
|
this.hasSlotController.test('icon'),
|
|
75
75
|
'has-end-icon': this.endIcon || this.hasSlotController.test('end-icon'),
|
|
76
76
|
});
|
|
77
|
-
return html `<mdui-ripple
|
|
77
|
+
return html `<mdui-ripple
|
|
78
|
+
${ref(this.rippleRef)}
|
|
79
|
+
.noRipple=${this.noRipple}
|
|
80
|
+
></mdui-ripple>
|
|
81
|
+
${this.isButton()
|
|
78
82
|
? this.renderButton({
|
|
79
83
|
className,
|
|
80
84
|
part: 'button',
|
|
81
85
|
content: this.renderInner(),
|
|
82
86
|
})
|
|
83
87
|
: this.isDisabled() || this.loading
|
|
84
|
-
? html `<span part="button" class="_a ${className}"
|
|
88
|
+
? html `<span part="button" class="_a ${className}">
|
|
89
|
+
${this.renderInner()}
|
|
90
|
+
</span>`
|
|
85
91
|
: this.renderAnchor({
|
|
86
92
|
className,
|
|
87
93
|
part: 'button',
|
|
@@ -96,13 +102,21 @@ let SegmentedButton = class SegmentedButton extends ButtonBase {
|
|
|
96
102
|
return this.renderLoading();
|
|
97
103
|
}
|
|
98
104
|
if (this.selected) {
|
|
99
|
-
return html `<slot
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
return html `<slot
|
|
106
|
+
name="selected-icon"
|
|
107
|
+
part="selected-icon"
|
|
108
|
+
class="selected-icon"
|
|
109
|
+
>
|
|
110
|
+
${this.selectedIcon
|
|
111
|
+
? html `<mdui-icon name=${this.selectedIcon} class="i"></mdui-icon>`
|
|
112
|
+
: html `<mdui-icon-check class="i"></mdui-icon-check>`}
|
|
113
|
+
</slot>`;
|
|
102
114
|
}
|
|
103
|
-
return html `<slot name="icon" part="icon" class="icon"
|
|
104
|
-
|
|
105
|
-
|
|
115
|
+
return html `<slot name="icon" part="icon" class="icon">
|
|
116
|
+
${this.icon
|
|
117
|
+
? html `<mdui-icon name=${this.icon} class="i"></mdui-icon>`
|
|
118
|
+
: nothingTemplate}
|
|
119
|
+
</slot>`;
|
|
106
120
|
}
|
|
107
121
|
renderLabel() {
|
|
108
122
|
const hasLabel = this.hasSlotController.test('[default]');
|
|
@@ -112,9 +126,11 @@ let SegmentedButton = class SegmentedButton extends ButtonBase {
|
|
|
112
126
|
return html `<slot part="label" class="label"></slot>`;
|
|
113
127
|
}
|
|
114
128
|
renderEndIcon() {
|
|
115
|
-
return html `<slot name="end-icon" part="end-icon" class="end-icon"
|
|
116
|
-
|
|
117
|
-
|
|
129
|
+
return html `<slot name="end-icon" part="end-icon" class="end-icon">
|
|
130
|
+
${this.endIcon
|
|
131
|
+
? html `<mdui-icon name=${this.endIcon} class="i"></mdui-icon>`
|
|
132
|
+
: nothingTemplate}
|
|
133
|
+
</slot>`;
|
|
118
134
|
}
|
|
119
135
|
renderInner() {
|
|
120
136
|
return [this.renderIcon(), this.renderLabel(), this.renderEndIcon()];
|