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
|
@@ -204,16 +204,75 @@ let Select = class Select extends FocusableMixin(MduiElement) {
|
|
|
204
204
|
render() {
|
|
205
205
|
const hasSelection = this.multiple ? !!this.value.length : !!this.value;
|
|
206
206
|
return html `${this.multiple
|
|
207
|
-
? html `<select
|
|
208
|
-
|
|
207
|
+
? html `<select
|
|
208
|
+
${ref(this.hiddenInputRef)}
|
|
209
|
+
class="hidden-input"
|
|
210
|
+
name=${ifDefined(this.name)}
|
|
211
|
+
value=${ifDefined(this.value)}
|
|
212
|
+
.required=${this.required}
|
|
213
|
+
.disabled=${this.disabled}
|
|
214
|
+
multiple
|
|
215
|
+
tabindex="-1"
|
|
216
|
+
>
|
|
217
|
+
${map(this.value, (value) => html `<option selected value=${value}></option>`)}
|
|
218
|
+
</select>`
|
|
219
|
+
: html `<input
|
|
220
|
+
${ref(this.hiddenInputRef)}
|
|
221
|
+
type="radio"
|
|
222
|
+
class="hidden-input"
|
|
223
|
+
name=${ifDefined(this.name)}
|
|
224
|
+
value=${ifDefined(this.value)}
|
|
225
|
+
.required=${this.required}
|
|
226
|
+
.disabled=${this.disabled}
|
|
227
|
+
.checked=${hasSelection}
|
|
228
|
+
tabindex="-1"
|
|
229
|
+
/>`}
|
|
230
|
+
<mdui-dropdown
|
|
231
|
+
.stayOpenOnClick=${this.multiple}
|
|
232
|
+
.disabled=${this.readonly || this.disabled}
|
|
233
|
+
.placement=${this.placement === 'top'
|
|
209
234
|
? 'top-start'
|
|
210
235
|
: this.placement === 'bottom'
|
|
211
236
|
? 'bottom-start'
|
|
212
|
-
: 'auto'}
|
|
237
|
+
: 'auto'}
|
|
238
|
+
@open=${this.onDropdownOpen}
|
|
239
|
+
@close=${this.onDropdownClose}
|
|
240
|
+
>
|
|
241
|
+
<mdui-text-field
|
|
242
|
+
${ref(this.textFieldRef)}
|
|
243
|
+
slot="trigger"
|
|
244
|
+
part="text-field"
|
|
245
|
+
class="text-field"
|
|
246
|
+
readonly
|
|
247
|
+
.readonlyButClearable=${true}
|
|
248
|
+
.variant=${this.variant}
|
|
249
|
+
.name=${this.name}
|
|
250
|
+
.value=${this.multiple
|
|
213
251
|
? this.value.length
|
|
214
252
|
? ' '
|
|
215
253
|
: ''
|
|
216
|
-
: this.getMenuItemLabelByValue(this.value)}
|
|
254
|
+
: this.getMenuItemLabelByValue(this.value)}
|
|
255
|
+
.label=${this.label}
|
|
256
|
+
.placeholder=${this.placeholder}
|
|
257
|
+
.helper=${this.helper}
|
|
258
|
+
.error=${this.hiddenInputRef.value?.validationMessage}
|
|
259
|
+
.clearable=${this.clearable}
|
|
260
|
+
.clearIcon=${this.clearIcon}
|
|
261
|
+
.endAligned=${this.endAligned}
|
|
262
|
+
.prefix=${this.prefix}
|
|
263
|
+
.suffix=${this.suffix}
|
|
264
|
+
.icon=${this.icon}
|
|
265
|
+
.endIcon=${this.endIcon}
|
|
266
|
+
.errorIcon=${this.errorIcon}
|
|
267
|
+
.form=${this.form}
|
|
268
|
+
.disabled=${this.disabled}
|
|
269
|
+
.required=${this.required}
|
|
270
|
+
.invalidStyle=${this.invalid}
|
|
271
|
+
@clear=${this.onClear}
|
|
272
|
+
@change=${(e) => e.stopPropagation()}
|
|
273
|
+
@keydown=${this.onTextFieldKeyDown}
|
|
274
|
+
>
|
|
275
|
+
${map([
|
|
217
276
|
'icon',
|
|
218
277
|
'end-icon',
|
|
219
278
|
'error-icon',
|
|
@@ -223,8 +282,30 @@ let Select = class Select extends FocusableMixin(MduiElement) {
|
|
|
223
282
|
'clear-icon',
|
|
224
283
|
'helper',
|
|
225
284
|
], (slotName) => this.hasSlotController.test(slotName)
|
|
226
|
-
? html `<slot name
|
|
227
|
-
: nothing)}
|
|
285
|
+
? html `<slot name=${slotName} slot=${slotName}></slot>`
|
|
286
|
+
: nothing)}
|
|
287
|
+
${when(this.multiple && this.value.length, () => html `<div slot="input" class="chips">
|
|
288
|
+
${map(this.value, (valueItem) => html `<mdui-chip
|
|
289
|
+
class="chip"
|
|
290
|
+
variant="input"
|
|
291
|
+
deletable
|
|
292
|
+
tabindex="-1"
|
|
293
|
+
@delete=${() => this.onDeleteOneValue(valueItem)}
|
|
294
|
+
>
|
|
295
|
+
${this.getMenuItemLabelByValue(valueItem)}
|
|
296
|
+
</mdui-chip>`)}
|
|
297
|
+
</div>`)}
|
|
298
|
+
</mdui-text-field>
|
|
299
|
+
<mdui-menu
|
|
300
|
+
${ref(this.menuRef)}
|
|
301
|
+
part="menu"
|
|
302
|
+
.selects=${this.multiple ? 'multiple' : 'single'}
|
|
303
|
+
.value=${this.value}
|
|
304
|
+
@change=${this.onValueChange}
|
|
305
|
+
>
|
|
306
|
+
<slot></slot>
|
|
307
|
+
</mdui-menu>
|
|
308
|
+
</mdui-dropdown>`;
|
|
228
309
|
}
|
|
229
310
|
getMenuItemLabelByValue(valueItem) {
|
|
230
311
|
if (!this.menuItems.length) {
|
|
@@ -1,2 +1,28 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css
|
|
2
|
+
export const style = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
.hidden-input {
|
|
8
|
+
display: none;
|
|
9
|
+
}
|
|
10
|
+
.text-field {
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
}
|
|
13
|
+
.chips {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-wrap: wrap;
|
|
16
|
+
margin: -0.5rem -0.25rem;
|
|
17
|
+
min-height: 2.5rem;
|
|
18
|
+
}
|
|
19
|
+
:host([variant='filled'][label]) .chips {
|
|
20
|
+
margin: 0rem -0.25rem -1rem -0.25rem;
|
|
21
|
+
}
|
|
22
|
+
.chip {
|
|
23
|
+
margin: 0.25rem;
|
|
24
|
+
}
|
|
25
|
+
mdui-menu {
|
|
26
|
+
max-width: none;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
@@ -90,10 +90,41 @@ let Slider = class Slider extends SliderBase {
|
|
|
90
90
|
* <input class="invalid" /> 用于提供 html5 自带的表单错误提示
|
|
91
91
|
*/
|
|
92
92
|
render() {
|
|
93
|
-
return html `<label class
|
|
93
|
+
return html `<label class=${classMap({ invalid: this.invalid })}>
|
|
94
|
+
<input
|
|
95
|
+
${ref(this.inputRef)}
|
|
96
|
+
type="range"
|
|
97
|
+
step=${this.step}
|
|
98
|
+
min=${this.min}
|
|
99
|
+
max=${this.max}
|
|
100
|
+
?disabled=${this.disabled}
|
|
101
|
+
.value=${live(this.value.toString())}
|
|
102
|
+
@input=${this.onInput}
|
|
103
|
+
@change=${this.onChange}
|
|
104
|
+
/>
|
|
105
|
+
<div part="track-inactive" class="track-inactive"></div>
|
|
106
|
+
<div
|
|
107
|
+
${ref(this.trackActiveRef)}
|
|
108
|
+
part="track-active"
|
|
109
|
+
class="track-active"
|
|
110
|
+
></div>
|
|
111
|
+
<div ${ref(this.handleRef)} part="handle" class="handle">
|
|
112
|
+
<div class="elevation"></div>
|
|
113
|
+
<mdui-ripple
|
|
114
|
+
${ref(this.rippleRef)}
|
|
115
|
+
.noRipple=${this.noRipple}
|
|
116
|
+
></mdui-ripple>
|
|
117
|
+
${this.renderLabel(this.value)}
|
|
118
|
+
</div>
|
|
119
|
+
${when(this.tickmarks, () => map(this.getCandidateValues(), (value) => html `<div
|
|
120
|
+
part="tickmark"
|
|
121
|
+
class="tickmark ${classMap({ active: value < this.value })}"
|
|
122
|
+
style="${styleMap({
|
|
94
123
|
left: `${((value - this.min) / this.max) * 100}%`,
|
|
95
124
|
display: value === this.value ? 'none' : 'block',
|
|
96
|
-
})}"
|
|
125
|
+
})}"
|
|
126
|
+
></div>`))}
|
|
127
|
+
</label>`;
|
|
97
128
|
}
|
|
98
129
|
updateStyle() {
|
|
99
130
|
const percent = ((this.value - this.min) / (this.max - this.min)) * 100;
|
|
@@ -1,2 +1,174 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const sliderBaseStyle = css
|
|
2
|
+
export const sliderBaseStyle = css `
|
|
3
|
+
:host {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: block;
|
|
6
|
+
width: 100%;
|
|
7
|
+
-webkit-tap-highlight-color: transparent;
|
|
8
|
+
height: 2.5rem;
|
|
9
|
+
padding: 0rem 1.25rem;
|
|
10
|
+
}
|
|
11
|
+
label {
|
|
12
|
+
position: relative;
|
|
13
|
+
display: block;
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100%;
|
|
16
|
+
}
|
|
17
|
+
input[type='range'] {
|
|
18
|
+
position: absolute;
|
|
19
|
+
inset: 0;
|
|
20
|
+
z-index: 4;
|
|
21
|
+
height: 100%;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
opacity: 0;
|
|
24
|
+
-webkit-appearance: none;
|
|
25
|
+
appearance: none;
|
|
26
|
+
width: calc(100% + 20rem * 2 / 16);
|
|
27
|
+
margin: 0rem -1.25rem;
|
|
28
|
+
padding: 0rem 0.75rem;
|
|
29
|
+
}
|
|
30
|
+
:host([disabled]) input[type='range'] {
|
|
31
|
+
cursor: not-allowed;
|
|
32
|
+
}
|
|
33
|
+
.track-inactive,
|
|
34
|
+
.track-active {
|
|
35
|
+
position: absolute;
|
|
36
|
+
top: 50%;
|
|
37
|
+
height: 0.25rem;
|
|
38
|
+
margin-top: -0.125rem;
|
|
39
|
+
}
|
|
40
|
+
.track-inactive {
|
|
41
|
+
left: -0.125rem;
|
|
42
|
+
right: -0.125rem;
|
|
43
|
+
border-radius: var(--mdui-shape-corner-full);
|
|
44
|
+
background-color: rgb(var(--mdui-color-surface-container-highest));
|
|
45
|
+
}
|
|
46
|
+
.invalid .track-inactive {
|
|
47
|
+
background-color: rgba(var(--mdui-color-error), 0.12);
|
|
48
|
+
}
|
|
49
|
+
:host([disabled]) .track-inactive {
|
|
50
|
+
background-color: rgba(var(--mdui-color-on-surface), 0.12);
|
|
51
|
+
}
|
|
52
|
+
.track-active {
|
|
53
|
+
background-color: rgb(var(--mdui-color-primary));
|
|
54
|
+
}
|
|
55
|
+
.invalid .track-active {
|
|
56
|
+
background-color: rgb(var(--mdui-color-error));
|
|
57
|
+
}
|
|
58
|
+
:host([disabled]) .track-active {
|
|
59
|
+
background-color: rgba(var(--mdui-color-on-surface), 0.38);
|
|
60
|
+
}
|
|
61
|
+
.handle {
|
|
62
|
+
position: absolute;
|
|
63
|
+
top: 50%;
|
|
64
|
+
transform: translate(-50%);
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
z-index: 2;
|
|
67
|
+
width: 2.5rem;
|
|
68
|
+
height: 2.5rem;
|
|
69
|
+
margin-top: -1.25rem;
|
|
70
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
|
|
71
|
+
}
|
|
72
|
+
.invalid .handle {
|
|
73
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-error);
|
|
74
|
+
}
|
|
75
|
+
.handle::before,
|
|
76
|
+
.handle .elevation {
|
|
77
|
+
position: absolute;
|
|
78
|
+
display: block;
|
|
79
|
+
content: ' ';
|
|
80
|
+
left: 0.625rem;
|
|
81
|
+
top: 0.625rem;
|
|
82
|
+
width: 1.25rem;
|
|
83
|
+
height: 1.25rem;
|
|
84
|
+
border-radius: var(--mdui-shape-corner-full);
|
|
85
|
+
}
|
|
86
|
+
.handle .elevation {
|
|
87
|
+
background-color: rgb(var(--mdui-color-primary));
|
|
88
|
+
box-shadow: var(--mdui-elevation-level1);
|
|
89
|
+
}
|
|
90
|
+
.invalid .handle .elevation {
|
|
91
|
+
background-color: rgb(var(--mdui-color-error));
|
|
92
|
+
}
|
|
93
|
+
:host([disabled]) .handle .elevation {
|
|
94
|
+
background-color: rgba(var(--mdui-color-on-surface), 0.38);
|
|
95
|
+
box-shadow: var(--mdui-elevation-level0);
|
|
96
|
+
}
|
|
97
|
+
.handle::before {
|
|
98
|
+
background-color: rgb(var(--mdui-color-background));
|
|
99
|
+
}
|
|
100
|
+
.handle mdui-ripple {
|
|
101
|
+
border-radius: var(--mdui-shape-corner-full);
|
|
102
|
+
}
|
|
103
|
+
.label {
|
|
104
|
+
position: absolute;
|
|
105
|
+
left: 50%;
|
|
106
|
+
transform: translateX(-50%) scale(0);
|
|
107
|
+
transform-origin: center bottom;
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
cursor: default;
|
|
112
|
+
white-space: nowrap;
|
|
113
|
+
-webkit-user-select: none;
|
|
114
|
+
user-select: none;
|
|
115
|
+
pointer-events: none;
|
|
116
|
+
transition: transform var(--mdui-motion-duration-short2)
|
|
117
|
+
var(--mdui-motion-easing-standard);
|
|
118
|
+
bottom: 2.5rem;
|
|
119
|
+
min-width: 1.75rem;
|
|
120
|
+
height: 1.75rem;
|
|
121
|
+
padding: 0.375rem 0.5rem;
|
|
122
|
+
border-radius: var(--mdui-shape-corner-full);
|
|
123
|
+
color: rgb(var(--mdui-color-on-primary));
|
|
124
|
+
font-size: var(--mdui-typescale-label-medium-size);
|
|
125
|
+
font-weight: var(--mdui-typescale-label-medium-weight);
|
|
126
|
+
letter-spacing: var(--mdui-typescale-label-medium-tracking);
|
|
127
|
+
line-height: var(--mdui-typescale-label-medium-line-height);
|
|
128
|
+
background-color: rgb(var(--mdui-color-primary));
|
|
129
|
+
}
|
|
130
|
+
.invalid .label {
|
|
131
|
+
color: rgb(var(--mdui-color-on-error));
|
|
132
|
+
background-color: rgb(var(--mdui-color-error));
|
|
133
|
+
}
|
|
134
|
+
.label::after {
|
|
135
|
+
content: ' ';
|
|
136
|
+
position: absolute;
|
|
137
|
+
z-index: -1;
|
|
138
|
+
transform: rotate(45deg);
|
|
139
|
+
width: 0.875rem;
|
|
140
|
+
height: 0.875rem;
|
|
141
|
+
bottom: -0.125rem;
|
|
142
|
+
background-color: rgb(var(--mdui-color-primary));
|
|
143
|
+
}
|
|
144
|
+
.invalid .label::after {
|
|
145
|
+
background-color: rgb(var(--mdui-color-error));
|
|
146
|
+
}
|
|
147
|
+
.label-visible {
|
|
148
|
+
transform: translateX(-50%) scale(1);
|
|
149
|
+
transition: transform var(--mdui-motion-duration-short4)
|
|
150
|
+
var(--mdui-motion-easing-standard);
|
|
151
|
+
}
|
|
152
|
+
.tickmark {
|
|
153
|
+
position: absolute;
|
|
154
|
+
top: 50%;
|
|
155
|
+
transform: translate(-50%);
|
|
156
|
+
width: 0.125rem;
|
|
157
|
+
height: 0.125rem;
|
|
158
|
+
margin-top: -0.0625rem;
|
|
159
|
+
border-radius: var(--mdui-shape-corner-full);
|
|
160
|
+
background-color: rgba(var(--mdui-color-on-surface-variant), 0.38);
|
|
161
|
+
}
|
|
162
|
+
.invalid .tickmark {
|
|
163
|
+
background-color: rgba(var(--mdui-color-error), 0.38);
|
|
164
|
+
}
|
|
165
|
+
.tickmark.active {
|
|
166
|
+
background-color: rgba(var(--mdui-color-on-primary), 0.38);
|
|
167
|
+
}
|
|
168
|
+
.invalid .tickmark.active {
|
|
169
|
+
background-color: rgba(var(--mdui-color-on-error), 0.38);
|
|
170
|
+
}
|
|
171
|
+
:host([disabled]) .tickmark {
|
|
172
|
+
background-color: rgba(var(--mdui-color-on-surface), 0.38);
|
|
173
|
+
}
|
|
174
|
+
`;
|
|
@@ -153,7 +153,12 @@ export class SliderBase extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
153
153
|
* 渲染浮动标签
|
|
154
154
|
*/
|
|
155
155
|
renderLabel(value) {
|
|
156
|
-
return when(!this.nolabel, () => html `<div
|
|
156
|
+
return when(!this.nolabel, () => html `<div
|
|
157
|
+
part="label"
|
|
158
|
+
class="label ${classMap({ 'label-visible': this.labelVisible })}"
|
|
159
|
+
>
|
|
160
|
+
${this.labelFormatter(value)}
|
|
161
|
+
</div>`);
|
|
157
162
|
}
|
|
158
163
|
onChange() {
|
|
159
164
|
// @ts-ignore
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css
|
|
2
|
+
export const style = css `
|
|
3
|
+
.track-active {
|
|
4
|
+
left: -0.125rem;
|
|
5
|
+
border-radius: var(--mdui-shape-corner-full) 0 0
|
|
6
|
+
var(--mdui-shape-corner-full);
|
|
7
|
+
}
|
|
8
|
+
`;
|
|
@@ -204,11 +204,38 @@ let Snackbar = class Snackbar extends MduiElement {
|
|
|
204
204
|
document.removeEventListener('pointerdown', this.onDocumentClick);
|
|
205
205
|
}
|
|
206
206
|
render() {
|
|
207
|
-
return html `<slot part="message" class="message"></slot
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
207
|
+
return html `<slot part="message" class="message"></slot>
|
|
208
|
+
<div class="action-group">
|
|
209
|
+
<slot
|
|
210
|
+
name="action"
|
|
211
|
+
part="action"
|
|
212
|
+
class="action"
|
|
213
|
+
@click=${this.onActionClick}
|
|
214
|
+
>
|
|
215
|
+
${this.action
|
|
216
|
+
? html `<mdui-button variant="text" loading=${this.actionLoading}>
|
|
217
|
+
${this.action}
|
|
218
|
+
</mdui-button>`
|
|
219
|
+
: nothingTemplate}
|
|
220
|
+
</slot>
|
|
221
|
+
${when(this.closeable, () => html `<slot
|
|
222
|
+
name="close-button"
|
|
223
|
+
part="close-button"
|
|
224
|
+
class="close-button"
|
|
225
|
+
@click=${this.onCloseClick}
|
|
226
|
+
>
|
|
227
|
+
<mdui-button-icon>
|
|
228
|
+
<slot name="close-icon" part="close-icon">
|
|
229
|
+
${this.closeIcon
|
|
230
|
+
? html `<mdui-icon
|
|
231
|
+
name=${this.closeIcon}
|
|
232
|
+
class="i"
|
|
233
|
+
></mdui-icon>`
|
|
234
|
+
: html `<mdui-icon-clear class="i"></mdui-icon-clear>`}
|
|
235
|
+
</slot>
|
|
236
|
+
</mdui-button-icon>
|
|
237
|
+
</slot>`)}
|
|
238
|
+
</div>`;
|
|
212
239
|
}
|
|
213
240
|
/**
|
|
214
241
|
* 在 document 上点击时,根据条件判断是否要关闭 snackbar
|
|
@@ -1,2 +1,101 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css
|
|
2
|
+
export const style = css `
|
|
3
|
+
:host {
|
|
4
|
+
--shape-corner: var(--mdui-shape-corner-extra-small);
|
|
5
|
+
--z-index: 2400;
|
|
6
|
+
position: fixed;
|
|
7
|
+
z-index: var(--z-index);
|
|
8
|
+
display: none;
|
|
9
|
+
align-items: center;
|
|
10
|
+
flex-wrap: wrap;
|
|
11
|
+
border-radius: var(--shape-corner);
|
|
12
|
+
min-width: 20rem;
|
|
13
|
+
max-width: 36rem;
|
|
14
|
+
padding: 0.25rem 0rem;
|
|
15
|
+
box-shadow: var(--mdui-elevation-level3);
|
|
16
|
+
background-color: rgb(var(--mdui-color-inverse-surface));
|
|
17
|
+
color: rgb(var(--mdui-color-inverse-on-surface));
|
|
18
|
+
font-size: var(--mdui-typescale-body-medium-size);
|
|
19
|
+
font-weight: var(--mdui-typescale-body-medium-weight);
|
|
20
|
+
letter-spacing: var(--mdui-typescale-body-medium-tracking);
|
|
21
|
+
line-height: var(--mdui-typescale-body-medium-line-height);
|
|
22
|
+
}
|
|
23
|
+
:host([placement^='top']) {
|
|
24
|
+
transform-origin: top;
|
|
25
|
+
top: 1rem;
|
|
26
|
+
}
|
|
27
|
+
:host([placement^='bottom']) {
|
|
28
|
+
transform-origin: bottom;
|
|
29
|
+
bottom: 1rem;
|
|
30
|
+
}
|
|
31
|
+
:host([placement='top-start']),
|
|
32
|
+
:host([placement='bottom-start']) {
|
|
33
|
+
left: 1rem;
|
|
34
|
+
}
|
|
35
|
+
:host([placement='top-end']),
|
|
36
|
+
:host([placement='bottom-end']) {
|
|
37
|
+
right: 1rem;
|
|
38
|
+
}
|
|
39
|
+
.message {
|
|
40
|
+
display: block;
|
|
41
|
+
margin: 0.625rem 1rem;
|
|
42
|
+
}
|
|
43
|
+
:host([message-line='1']) .message {
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
white-space: nowrap;
|
|
46
|
+
text-overflow: ellipsis;
|
|
47
|
+
}
|
|
48
|
+
:host([message-line='2']) .message {
|
|
49
|
+
display: -webkit-box;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
text-overflow: ellipsis;
|
|
52
|
+
-webkit-box-orient: vertical;
|
|
53
|
+
-webkit-line-clamp: 2;
|
|
54
|
+
}
|
|
55
|
+
.action-group {
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
margin-left: auto;
|
|
59
|
+
padding-right: 0.5rem;
|
|
60
|
+
}
|
|
61
|
+
.action,
|
|
62
|
+
.close-button {
|
|
63
|
+
display: inline-flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
}
|
|
67
|
+
.action {
|
|
68
|
+
color: rgb(var(--mdui-color-inverse-primary));
|
|
69
|
+
font-size: var(--mdui-typescale-label-large-size);
|
|
70
|
+
font-weight: var(--mdui-typescale-label-large-weight);
|
|
71
|
+
letter-spacing: var(--mdui-typescale-label-large-tracking);
|
|
72
|
+
}
|
|
73
|
+
.action mdui-button,
|
|
74
|
+
::slotted(mdui-button[slot='action'][variant='text']),
|
|
75
|
+
::slotted(mdui-button[slot='action'][variant='outlined']) {
|
|
76
|
+
color: inherit;
|
|
77
|
+
font-size: inherit;
|
|
78
|
+
font-weight: inherit;
|
|
79
|
+
letter-spacing: inherit;
|
|
80
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-inverse-primary);
|
|
81
|
+
}
|
|
82
|
+
.action mdui-button::part(button) {
|
|
83
|
+
padding: 0rem 0.5rem;
|
|
84
|
+
}
|
|
85
|
+
.close-button {
|
|
86
|
+
margin: 0rem -0.25rem 0rem 0.25rem;
|
|
87
|
+
font-size: 1.5rem;
|
|
88
|
+
color: rgb(var(--mdui-color-inverse-on-surface));
|
|
89
|
+
}
|
|
90
|
+
.close-button mdui-button-icon,
|
|
91
|
+
::slotted(mdui-button-icon[slot='close-button'][variant='standard']),
|
|
92
|
+
::slotted(mdui-button-icon[slot='close-button'][variant='outlined']) {
|
|
93
|
+
font-size: inherit;
|
|
94
|
+
color: inherit;
|
|
95
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-inverse-on-surface);
|
|
96
|
+
}
|
|
97
|
+
.close-button .i,
|
|
98
|
+
::slotted([slot='close-icon']) {
|
|
99
|
+
font-size: inherit;
|
|
100
|
+
}
|
|
101
|
+
`;
|
|
@@ -167,16 +167,50 @@ let Switch = class Switch extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
|
167
167
|
this.invalid = !this.inputRef.value.checkValidity();
|
|
168
168
|
}
|
|
169
169
|
render() {
|
|
170
|
-
return html `<label
|
|
170
|
+
return html `<label
|
|
171
|
+
class=${classMap({
|
|
171
172
|
invalid: this.invalid,
|
|
172
173
|
'has-unchecked-icon': this.uncheckedIcon || this.hasSlotController.test('unchecked-icon'),
|
|
173
|
-
})}
|
|
174
|
-
|
|
174
|
+
})}
|
|
175
|
+
>
|
|
176
|
+
<input
|
|
177
|
+
${ref(this.inputRef)}
|
|
178
|
+
type="checkbox"
|
|
179
|
+
name=${ifDefined(this.name)}
|
|
180
|
+
value=${ifDefined(this.value)}
|
|
181
|
+
.disabled=${this.disabled}
|
|
182
|
+
.checked=${live(this.checked)}
|
|
183
|
+
.required=${this.required}
|
|
184
|
+
@change=${this.onChange}
|
|
185
|
+
/>
|
|
186
|
+
<div part="track" class="track">
|
|
187
|
+
<div part="thumb" class="thumb">
|
|
188
|
+
<mdui-ripple
|
|
189
|
+
${ref(this.rippleRef)}
|
|
190
|
+
.noRipple=${this.noRipple}
|
|
191
|
+
></mdui-ripple>
|
|
192
|
+
<slot name="checked-icon" part="checked-icon" class="checked-icon">
|
|
193
|
+
${this.checkedIcon
|
|
194
|
+
? html `<mdui-icon name=${this.checkedIcon} class="i"></mdui-icon>`
|
|
175
195
|
: this.checkedIcon === ''
|
|
176
196
|
? nothingTemplate
|
|
177
|
-
: html `<mdui-icon-check class="i"></mdui-icon-check>`}
|
|
178
|
-
|
|
179
|
-
|
|
197
|
+
: html `<mdui-icon-check class="i"></mdui-icon-check>`}
|
|
198
|
+
</slot>
|
|
199
|
+
<slot
|
|
200
|
+
name="unchecked-icon"
|
|
201
|
+
part="unchecked-icon"
|
|
202
|
+
class="unchecked-icon"
|
|
203
|
+
>
|
|
204
|
+
${this.uncheckedIcon
|
|
205
|
+
? html `<mdui-icon
|
|
206
|
+
name=${this.uncheckedIcon}
|
|
207
|
+
class="i"
|
|
208
|
+
></mdui-icon>`
|
|
209
|
+
: nothingTemplate}
|
|
210
|
+
</slot>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
</label>`;
|
|
180
214
|
}
|
|
181
215
|
/**
|
|
182
216
|
* input[type="checkbox"] 的 change 事件无法冒泡越过 shadow dom
|