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
package/components/icon/style.js
CHANGED
|
@@ -1,2 +1,30 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css
|
|
2
|
+
export const style = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
width: 1em;
|
|
6
|
+
height: 1em;
|
|
7
|
+
font-weight: normal;
|
|
8
|
+
font-family: 'Material Icons';
|
|
9
|
+
font-style: normal;
|
|
10
|
+
line-height: 1;
|
|
11
|
+
direction: ltr;
|
|
12
|
+
letter-spacing: normal;
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
text-transform: none;
|
|
15
|
+
word-wrap: normal;
|
|
16
|
+
/* Support for all WebKit browsers. */
|
|
17
|
+
-webkit-font-smoothing: antialiased;
|
|
18
|
+
/* Support for Safari and Chrome. */
|
|
19
|
+
text-rendering: optimizelegibility;
|
|
20
|
+
/* Support for Firefox. */
|
|
21
|
+
-moz-osx-font-smoothing: grayscale;
|
|
22
|
+
font-size: 1.5rem;
|
|
23
|
+
}
|
|
24
|
+
svg,
|
|
25
|
+
::slotted(svg) {
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
fill: currentcolor;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const layoutStyle = css
|
|
2
|
+
export const layoutStyle = css `
|
|
3
|
+
:host {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex: 1 1 auto;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
}
|
|
9
|
+
:host([full-height]) {
|
|
10
|
+
height: 100%;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
@@ -29,9 +29,13 @@ let LinearProgress = class LinearProgress extends MduiElement {
|
|
|
29
29
|
const isDeterminate = !isUndefined(this.value);
|
|
30
30
|
if (isDeterminate) {
|
|
31
31
|
const value = this.value;
|
|
32
|
-
return html `<div
|
|
32
|
+
return html `<div
|
|
33
|
+
part="indicator"
|
|
34
|
+
class="determinate"
|
|
35
|
+
style="${styleMap({
|
|
33
36
|
width: `${(value / Math.max(this.max ?? value, value)) * 100}%`,
|
|
34
|
-
})}"
|
|
37
|
+
})}"
|
|
38
|
+
></div>`;
|
|
35
39
|
}
|
|
36
40
|
return html `<div part="indicator" class="indeterminate"></div>`;
|
|
37
41
|
}
|
|
@@ -1,2 +1,74 @@
|
|
|
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-none);
|
|
5
|
+
position: relative;
|
|
6
|
+
display: inline-block;
|
|
7
|
+
width: 100%;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
border-radius: var(--shape-corner);
|
|
10
|
+
background-color: rgb(var(--mdui-color-surface-container-highest));
|
|
11
|
+
height: 0.25rem;
|
|
12
|
+
}
|
|
13
|
+
.determinate,
|
|
14
|
+
.indeterminate {
|
|
15
|
+
background-color: rgb(var(--mdui-color-primary));
|
|
16
|
+
}
|
|
17
|
+
.determinate {
|
|
18
|
+
height: 100%;
|
|
19
|
+
transition: width var(--mdui-motion-duration-long2)
|
|
20
|
+
var(--mdui-motion-easing-standard);
|
|
21
|
+
}
|
|
22
|
+
.indeterminate::before {
|
|
23
|
+
position: absolute;
|
|
24
|
+
top: 0;
|
|
25
|
+
bottom: 0;
|
|
26
|
+
left: 0;
|
|
27
|
+
background-color: inherit;
|
|
28
|
+
animation: mdui-comp-progress-indeterminate 2s
|
|
29
|
+
var(--mdui-motion-easing-linear) infinite;
|
|
30
|
+
content: ' ';
|
|
31
|
+
}
|
|
32
|
+
.indeterminate::after {
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 0;
|
|
35
|
+
bottom: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
background-color: inherit;
|
|
38
|
+
animation: mdui-comp-progress-indeterminate-short 2s
|
|
39
|
+
var(--mdui-motion-easing-linear) infinite;
|
|
40
|
+
content: ' ';
|
|
41
|
+
}
|
|
42
|
+
@keyframes mdui-comp-progress-indeterminate {
|
|
43
|
+
0% {
|
|
44
|
+
left: 0;
|
|
45
|
+
width: 0;
|
|
46
|
+
}
|
|
47
|
+
50% {
|
|
48
|
+
left: 30%;
|
|
49
|
+
width: 70%;
|
|
50
|
+
}
|
|
51
|
+
75% {
|
|
52
|
+
left: 100%;
|
|
53
|
+
width: 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
@keyframes mdui-comp-progress-indeterminate-short {
|
|
57
|
+
0% {
|
|
58
|
+
left: 0;
|
|
59
|
+
width: 0;
|
|
60
|
+
}
|
|
61
|
+
50% {
|
|
62
|
+
left: 0;
|
|
63
|
+
width: 0;
|
|
64
|
+
}
|
|
65
|
+
75% {
|
|
66
|
+
left: 0;
|
|
67
|
+
width: 25%;
|
|
68
|
+
}
|
|
69
|
+
100% {
|
|
70
|
+
left: 100%;
|
|
71
|
+
width: 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
@@ -1,4 +1,155 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const listItemStyle = css
|
|
2
|
+
export const listItemStyle = css `
|
|
3
|
+
:host {
|
|
4
|
+
--shape-corner: var(--mdui-shape-corner-none);
|
|
5
|
+
--shape-corner-rounded: var(--mdui-shape-corner-extra-large);
|
|
6
|
+
position: relative;
|
|
7
|
+
display: block;
|
|
8
|
+
border-radius: var(--shape-corner);
|
|
9
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
|
|
10
|
+
}
|
|
11
|
+
:host([rounded]),
|
|
12
|
+
:host([rounded]) mdui-ripple {
|
|
13
|
+
border-radius: var(--shape-corner-rounded);
|
|
14
|
+
}
|
|
15
|
+
:host([active]) {
|
|
16
|
+
background-color: rgb(var(--mdui-color-secondary-container));
|
|
17
|
+
--mdui-comp-ripple-state-layer-color: var(
|
|
3
18
|
--mdui-color-on-secondary-container
|
|
4
|
-
)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
:host([disabled]) {
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
}
|
|
24
|
+
.container {
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
-webkit-user-select: none;
|
|
27
|
+
user-select: none;
|
|
28
|
+
text-decoration: none;
|
|
29
|
+
color: inherit;
|
|
30
|
+
-webkit-tap-highlight-color: transparent;
|
|
31
|
+
}
|
|
32
|
+
:host([disabled]) .container {
|
|
33
|
+
cursor: default;
|
|
34
|
+
opacity: 0.38;
|
|
35
|
+
}
|
|
36
|
+
:host([nonclickable]:not([href])) .container {
|
|
37
|
+
cursor: auto;
|
|
38
|
+
-webkit-user-select: auto;
|
|
39
|
+
user-select: auto;
|
|
40
|
+
}
|
|
41
|
+
.preset {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
padding: 0.5rem 1.5rem 0.5rem 1rem;
|
|
45
|
+
min-height: 3.5rem;
|
|
46
|
+
}
|
|
47
|
+
:host([alignment='start']) .preset {
|
|
48
|
+
align-items: flex-start;
|
|
49
|
+
}
|
|
50
|
+
:host([alignment='end']) .preset {
|
|
51
|
+
align-items: flex-end;
|
|
52
|
+
}
|
|
53
|
+
.body {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex: 1 1 100%;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
justify-content: center;
|
|
58
|
+
min-width: 0;
|
|
59
|
+
}
|
|
60
|
+
.headline {
|
|
61
|
+
display: block;
|
|
62
|
+
color: rgb(var(--mdui-color-on-surface));
|
|
63
|
+
font-size: var(--mdui-typescale-body-large-size);
|
|
64
|
+
font-weight: var(--mdui-typescale-body-large-weight);
|
|
65
|
+
letter-spacing: var(--mdui-typescale-body-large-tracking);
|
|
66
|
+
line-height: var(--mdui-typescale-body-large-line-height);
|
|
67
|
+
}
|
|
68
|
+
:host([active]) .headline {
|
|
69
|
+
color: rgb(var(--mdui-color-on-secondary-container));
|
|
70
|
+
}
|
|
71
|
+
.description {
|
|
72
|
+
display: none;
|
|
73
|
+
color: rgb(var(--mdui-color-on-surface-variant));
|
|
74
|
+
font-size: var(--mdui-typescale-body-medium-size);
|
|
75
|
+
font-weight: var(--mdui-typescale-body-medium-weight);
|
|
76
|
+
letter-spacing: var(--mdui-typescale-body-medium-tracking);
|
|
77
|
+
line-height: var(--mdui-typescale-body-medium-line-height);
|
|
78
|
+
}
|
|
79
|
+
:host([disabled]) .description,
|
|
80
|
+
:host([hover]) .description,
|
|
81
|
+
:host([focused]) .description,
|
|
82
|
+
:host([pressed]) .description {
|
|
83
|
+
color: rgb(var(--mdui-color-on-surface));
|
|
84
|
+
}
|
|
85
|
+
.has-description .description {
|
|
86
|
+
display: block;
|
|
87
|
+
}
|
|
88
|
+
:host([headline-line='1']) .headline,
|
|
89
|
+
:host([description-line='1']) .description {
|
|
90
|
+
overflow: hidden;
|
|
91
|
+
white-space: nowrap;
|
|
92
|
+
text-overflow: ellipsis;
|
|
93
|
+
}
|
|
94
|
+
:host([headline-line='2']) .headline,
|
|
95
|
+
:host([description-line='2']) .description,
|
|
96
|
+
:host([headline-line='3']) .headline,
|
|
97
|
+
:host([description-line='3']) .description {
|
|
98
|
+
display: -webkit-box;
|
|
99
|
+
overflow: hidden;
|
|
100
|
+
text-overflow: ellipsis;
|
|
101
|
+
-webkit-box-orient: vertical;
|
|
102
|
+
}
|
|
103
|
+
:host([headline-line='2']) .headline,
|
|
104
|
+
:host([description-line='2']) .description {
|
|
105
|
+
-webkit-line-clamp: 2;
|
|
106
|
+
}
|
|
107
|
+
:host([headline-line='3']) .headline,
|
|
108
|
+
:host([description-line='3']) .description {
|
|
109
|
+
-webkit-line-clamp: 3;
|
|
110
|
+
}
|
|
111
|
+
.icon,
|
|
112
|
+
.end-icon {
|
|
113
|
+
display: flex;
|
|
114
|
+
flex: 0 0 auto;
|
|
115
|
+
font-size: var(--mdui-typescale-label-small-size);
|
|
116
|
+
font-weight: var(--mdui-typescale-label-small-weight);
|
|
117
|
+
letter-spacing: var(--mdui-typescale-label-small-tracking);
|
|
118
|
+
line-height: var(--mdui-typescale-label-small-line-height);
|
|
119
|
+
color: rgb(var(--mdui-color-on-surface-variant));
|
|
120
|
+
}
|
|
121
|
+
:host([disabled]) .icon,
|
|
122
|
+
:host([disabled]) .end-icon,
|
|
123
|
+
:host([hover]) .icon,
|
|
124
|
+
:host([hover]) .end-icon,
|
|
125
|
+
:host([focused]) .icon,
|
|
126
|
+
:host([focused]) .end-icon,
|
|
127
|
+
:host([pressed]) .icon,
|
|
128
|
+
:host([pressed]) .end-icon {
|
|
129
|
+
color: rgb(var(--mdui-color-on-surface));
|
|
130
|
+
}
|
|
131
|
+
:host([active]) .icon,
|
|
132
|
+
:host([active]) .end-icon {
|
|
133
|
+
color: rgb(var(--mdui-color-on-secondary-container));
|
|
134
|
+
}
|
|
135
|
+
.icon mdui-icon,
|
|
136
|
+
.end-icon mdui-icon,
|
|
137
|
+
.is-icon ::slotted([slot='icon']),
|
|
138
|
+
.is-end-icon ::slotted([slot='end-icon']) {
|
|
139
|
+
font-size: 1.5rem;
|
|
140
|
+
}
|
|
141
|
+
.has-icon .icon {
|
|
142
|
+
margin-right: 1rem;
|
|
143
|
+
}
|
|
144
|
+
.has-icon ::slotted(mdui-checkbox[slot='icon']),
|
|
145
|
+
.has-icon ::slotted(mdui-radio[slot='icon']) {
|
|
146
|
+
margin-left: -0.5rem;
|
|
147
|
+
}
|
|
148
|
+
.has-end-icon .end-icon {
|
|
149
|
+
margin-left: 1rem;
|
|
150
|
+
}
|
|
151
|
+
.has-end-icon ::slotted(mdui-checkbox[slot='end-icon']),
|
|
152
|
+
.has-end-icon ::slotted(mdui-radio[slot='end-icon']) {
|
|
153
|
+
margin-right: -0.5rem;
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
@@ -103,24 +103,43 @@ let ListItem = class ListItem extends AnchorMixin(RippleMixin(FocusableMixin(Mdu
|
|
|
103
103
|
// end-icon slot 中的元素是否为 mdui-icon 或 mdui-icon-* 组件
|
|
104
104
|
'is-end-icon': getNodeName(this.endIconElements[0]).startsWith('mdui-icon-'),
|
|
105
105
|
});
|
|
106
|
-
return html `<mdui-ripple
|
|
106
|
+
return html `<mdui-ripple
|
|
107
|
+
${ref(this.rippleRef)}
|
|
108
|
+
.noRipple=${this.noRipple}
|
|
109
|
+
></mdui-ripple>
|
|
110
|
+
${this.href && !this.disabled
|
|
107
111
|
? this.renderAnchor({
|
|
108
112
|
className,
|
|
109
113
|
content: this.renderInner(),
|
|
110
114
|
part: 'container',
|
|
111
115
|
refDirective: ref(this.itemRef),
|
|
112
116
|
})
|
|
113
|
-
: html `<div part="container" class="${className}" ${ref(this.itemRef)}
|
|
117
|
+
: html `<div part="container" class="${className}" ${ref(this.itemRef)}>
|
|
118
|
+
${this.renderInner()}
|
|
119
|
+
</div>`}`;
|
|
114
120
|
}
|
|
115
121
|
renderInner() {
|
|
116
122
|
const hasDefaultSlot = this.hasSlotController.test('[default]');
|
|
117
|
-
return html `<slot name="custom"
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
return html `<slot name="custom">
|
|
124
|
+
<slot name="icon" part="icon" class="icon">
|
|
125
|
+
${this.icon
|
|
126
|
+
? html `<mdui-icon name=${this.icon}></mdui-icon>`
|
|
127
|
+
: nothingTemplate}
|
|
128
|
+
</slot>
|
|
129
|
+
<div part="body" class="body">
|
|
130
|
+
${hasDefaultSlot
|
|
120
131
|
? html `<slot part="headline" class="headline"></slot>`
|
|
121
|
-
: html `<div part="headline" class="headline">${this.headline}</div>`}
|
|
122
|
-
|
|
123
|
-
|
|
132
|
+
: html `<div part="headline" class="headline">${this.headline}</div>`}
|
|
133
|
+
<slot name="description" part="description" class="description">
|
|
134
|
+
${this.description}
|
|
135
|
+
</slot>
|
|
136
|
+
</div>
|
|
137
|
+
<slot name="end-icon" part="end-icon" class="end-icon">
|
|
138
|
+
${this.endIcon
|
|
139
|
+
? html `<mdui-icon name=${this.endIcon}></mdui-icon>`
|
|
140
|
+
: nothingTemplate}
|
|
141
|
+
</slot>
|
|
142
|
+
</slot>`;
|
|
124
143
|
}
|
|
125
144
|
};
|
|
126
145
|
ListItem.styles = [
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const listStyle = css
|
|
2
|
+
export const listStyle = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
padding: 0.5rem 0rem;
|
|
6
|
+
}
|
|
7
|
+
::slotted(mdui-divider[middle]) {
|
|
8
|
+
margin-left: 1rem;
|
|
9
|
+
margin-right: 1.5rem;
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
@@ -1,2 +1,20 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const listSubheaderStyle = css
|
|
2
|
+
export const listSubheaderStyle = css `
|
|
3
|
+
/* 规范中没有该描述 */
|
|
4
|
+
:host {
|
|
5
|
+
display: block;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
white-space: nowrap;
|
|
8
|
+
text-overflow: ellipsis;
|
|
9
|
+
cursor: default;
|
|
10
|
+
color: rgb(var(--mdui-color-on-surface-variant));
|
|
11
|
+
font-size: var(--mdui-typescale-label-small-size);
|
|
12
|
+
font-weight: var(--mdui-typescale-label-small-weight);
|
|
13
|
+
letter-spacing: var(--mdui-typescale-label-small-tracking);
|
|
14
|
+
line-height: var(--mdui-typescale-label-small-line-height);
|
|
15
|
+
padding-left: 1rem;
|
|
16
|
+
padding-right: 1.5rem;
|
|
17
|
+
height: 3.5rem;
|
|
18
|
+
line-height: 3.5rem;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
@@ -1,2 +1,126 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const menuItemStyle = css
|
|
2
|
+
export const menuItemStyle = css `
|
|
3
|
+
:host {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: block;
|
|
6
|
+
}
|
|
7
|
+
:host([selected]) {
|
|
8
|
+
background-color: rgba(var(--mdui-color-primary), 12%);
|
|
9
|
+
}
|
|
10
|
+
:host([disabled]) {
|
|
11
|
+
pointer-events: none;
|
|
12
|
+
}
|
|
13
|
+
.container {
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
-webkit-user-select: none;
|
|
16
|
+
user-select: none;
|
|
17
|
+
-webkit-tap-highlight-color: transparent;
|
|
18
|
+
}
|
|
19
|
+
:host([disabled]) .container {
|
|
20
|
+
cursor: default;
|
|
21
|
+
opacity: 0.38;
|
|
22
|
+
}
|
|
23
|
+
.preset {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
text-decoration: none;
|
|
27
|
+
height: 3rem;
|
|
28
|
+
padding: 0rem 0.75rem;
|
|
29
|
+
}
|
|
30
|
+
.preset.dense {
|
|
31
|
+
height: 2rem;
|
|
32
|
+
}
|
|
33
|
+
.label-container {
|
|
34
|
+
flex: 1 1 100%;
|
|
35
|
+
min-width: 0;
|
|
36
|
+
}
|
|
37
|
+
.label {
|
|
38
|
+
display: block;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
white-space: nowrap;
|
|
41
|
+
text-overflow: ellipsis;
|
|
42
|
+
color: rgb(var(--mdui-color-on-surface));
|
|
43
|
+
font-size: var(--mdui-typescale-label-large-size);
|
|
44
|
+
font-weight: var(--mdui-typescale-label-large-weight);
|
|
45
|
+
letter-spacing: var(--mdui-typescale-label-large-tracking);
|
|
46
|
+
}
|
|
47
|
+
.icon,
|
|
48
|
+
.selected-icon,
|
|
49
|
+
.end-icon,
|
|
50
|
+
.end-text {
|
|
51
|
+
display: none;
|
|
52
|
+
flex: 0 0 auto;
|
|
53
|
+
color: rgb(var(--mdui-color-on-surface-variant));
|
|
54
|
+
}
|
|
55
|
+
.has-icon .icon,
|
|
56
|
+
.has-icon .selected-icon,
|
|
57
|
+
.has-end-icon .end-icon,
|
|
58
|
+
.has-end-text .end-text {
|
|
59
|
+
display: flex;
|
|
60
|
+
}
|
|
61
|
+
.icon,
|
|
62
|
+
.selected-icon,
|
|
63
|
+
.end-icon {
|
|
64
|
+
font-size: 1.5rem;
|
|
65
|
+
}
|
|
66
|
+
.icon::slotted(mdui-avatar),
|
|
67
|
+
.selected-icon::slotted(mdui-avatar),
|
|
68
|
+
.end-icon::slotted(mdui-avatar) {
|
|
69
|
+
width: 1.5rem;
|
|
70
|
+
height: 1.5rem;
|
|
71
|
+
}
|
|
72
|
+
.dense .icon,
|
|
73
|
+
.dense .selected-icon,
|
|
74
|
+
.dense .end-icon {
|
|
75
|
+
font-size: 1.125rem;
|
|
76
|
+
}
|
|
77
|
+
.dense .icon::slotted(mdui-avatar),
|
|
78
|
+
.dense .selected-icon::slotted(mdui-avatar),
|
|
79
|
+
.dense .end-icon::slotted(mdui-avatar) {
|
|
80
|
+
width: 1.125rem;
|
|
81
|
+
height: 1.125rem;
|
|
82
|
+
}
|
|
83
|
+
.icon .i,
|
|
84
|
+
.selected-icon .i,
|
|
85
|
+
.end-icon .i,
|
|
86
|
+
::slotted([slot='icon']),
|
|
87
|
+
::slotted([slot='selected-icon']),
|
|
88
|
+
::slotted([slot='end-icon']) {
|
|
89
|
+
font-size: inherit;
|
|
90
|
+
}
|
|
91
|
+
.end-text {
|
|
92
|
+
font-size: var(--mdui-typescale-label-large-size);
|
|
93
|
+
font-weight: var(--mdui-typescale-label-large-weight);
|
|
94
|
+
letter-spacing: var(--mdui-typescale-label-large-tracking);
|
|
95
|
+
line-height: var(--mdui-typescale-label-large-line-height);
|
|
96
|
+
}
|
|
97
|
+
.icon,
|
|
98
|
+
.selected-icon {
|
|
99
|
+
margin-right: 0.75rem;
|
|
100
|
+
}
|
|
101
|
+
.end-icon,
|
|
102
|
+
.end-text {
|
|
103
|
+
margin-left: 0.75rem;
|
|
104
|
+
}
|
|
105
|
+
.arrow-right {
|
|
106
|
+
color: rgb(var(--mdui-color-on-surface));
|
|
107
|
+
}
|
|
108
|
+
.submenu {
|
|
109
|
+
--shape-corner: var(--mdui-shape-corner-extra-small);
|
|
110
|
+
display: block;
|
|
111
|
+
position: absolute;
|
|
112
|
+
z-index: 1;
|
|
113
|
+
border-radius: var(--shape-corner);
|
|
114
|
+
background-color: rgb(var(--mdui-color-surface-container));
|
|
115
|
+
box-shadow: var(--mdui-elevation-level2);
|
|
116
|
+
min-width: 7rem;
|
|
117
|
+
max-width: 17.5rem;
|
|
118
|
+
padding-top: 0.5rem;
|
|
119
|
+
padding-bottom: 0.5rem;
|
|
120
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
|
|
121
|
+
}
|
|
122
|
+
.submenu::slotted(mdui-divider) {
|
|
123
|
+
margin-top: 0.5rem;
|
|
124
|
+
margin-bottom: 0.5rem;
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
@@ -208,7 +208,11 @@ let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMixin(Mdu
|
|
|
208
208
|
'has-end-text': hasEndText,
|
|
209
209
|
'has-end-icon': hasEndIcon,
|
|
210
210
|
});
|
|
211
|
-
return html `<mdui-ripple
|
|
211
|
+
return html `<mdui-ripple
|
|
212
|
+
${ref(this.rippleRef)}
|
|
213
|
+
.noRipple=${this.noRipple}
|
|
214
|
+
></mdui-ripple>
|
|
215
|
+
${this.href && !this.disabled
|
|
212
216
|
? this.renderAnchor({
|
|
213
217
|
part: 'container',
|
|
214
218
|
className,
|
|
@@ -216,7 +220,20 @@ let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMixin(Mdu
|
|
|
216
220
|
refDirective: ref(this.containerRef),
|
|
217
221
|
tabIndex: this.focusable ? 0 : -1,
|
|
218
222
|
})
|
|
219
|
-
: html `<div
|
|
223
|
+
: html `<div
|
|
224
|
+
part="container"
|
|
225
|
+
${ref(this.containerRef)}
|
|
226
|
+
class=${className}
|
|
227
|
+
>
|
|
228
|
+
${this.renderInner(useDefaultEndIcon, hasIcon)}
|
|
229
|
+
</div>`}
|
|
230
|
+
${when(hasSubmenu, () => html `<slot
|
|
231
|
+
name="submenu"
|
|
232
|
+
${ref(this.submenuRef)}
|
|
233
|
+
part="submenu"
|
|
234
|
+
class="submenu"
|
|
235
|
+
hidden
|
|
236
|
+
></slot>`)}`;
|
|
220
237
|
}
|
|
221
238
|
/**
|
|
222
239
|
* 点击子菜单外面的区域,关闭子菜单
|
|
@@ -344,17 +361,42 @@ let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMixin(Mdu
|
|
|
344
361
|
});
|
|
345
362
|
}
|
|
346
363
|
renderInner(useDefaultEndIcon, hasIcon) {
|
|
347
|
-
return html `<slot name="custom"
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
364
|
+
return html `<slot name="custom">
|
|
365
|
+
${this.selected
|
|
366
|
+
? html `<slot
|
|
367
|
+
name="selected-icon"
|
|
368
|
+
part="selected-icon"
|
|
369
|
+
class="selected-icon"
|
|
370
|
+
>
|
|
371
|
+
${this.selectedIcon
|
|
372
|
+
? html `<mdui-icon
|
|
373
|
+
name=${this.selectedIcon}
|
|
374
|
+
class="i"
|
|
375
|
+
></mdui-icon>`
|
|
376
|
+
: html `<mdui-icon-check class="i"></mdui-icon-check>`}
|
|
377
|
+
</slot>`
|
|
378
|
+
: html `<slot name="icon" part="icon" class="icon">
|
|
379
|
+
${hasIcon
|
|
380
|
+
? html `<mdui-icon name=${this.icon} class="i"></mdui-icon>`
|
|
381
|
+
: nothingTemplate}
|
|
382
|
+
</slot>`}
|
|
383
|
+
<div class="label-container">
|
|
384
|
+
<slot part="label" class="label"></slot>
|
|
385
|
+
</div>
|
|
386
|
+
<slot name="end-text" part="end-text" class="end-text">
|
|
387
|
+
${this.endText}
|
|
388
|
+
</slot>
|
|
389
|
+
${useDefaultEndIcon
|
|
390
|
+
? html `<mdui-icon-arrow-right
|
|
391
|
+
part="end-icon"
|
|
392
|
+
class="end-icon arrow-right"
|
|
393
|
+
></mdui-icon-arrow-right>`
|
|
394
|
+
: html `<slot name="end-icon" part="end-icon" class="end-icon">
|
|
395
|
+
${this.endIcon
|
|
396
|
+
? html `<mdui-icon name=${this.endIcon}></mdui-icon>`
|
|
397
|
+
: nothingTemplate}
|
|
398
|
+
</slot>`}
|
|
399
|
+
</slot>`;
|
|
358
400
|
}
|
|
359
401
|
};
|
|
360
402
|
MenuItem.styles = [
|
|
@@ -1,2 +1,20 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const menuStyle = css
|
|
2
|
+
export const menuStyle = css `
|
|
3
|
+
:host {
|
|
4
|
+
--shape-corner: var(--mdui-shape-corner-extra-small);
|
|
5
|
+
position: relative;
|
|
6
|
+
display: block;
|
|
7
|
+
border-radius: var(--shape-corner);
|
|
8
|
+
background-color: rgb(var(--mdui-color-surface-container));
|
|
9
|
+
box-shadow: var(--mdui-elevation-level2);
|
|
10
|
+
min-width: 7rem;
|
|
11
|
+
max-width: 17.5rem;
|
|
12
|
+
padding-top: 0.5rem;
|
|
13
|
+
padding-bottom: 0.5rem;
|
|
14
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
|
|
15
|
+
}
|
|
16
|
+
::slotted(mdui-divider) {
|
|
17
|
+
margin-top: 0.5rem;
|
|
18
|
+
margin-bottom: 0.5rem;
|
|
19
|
+
}
|
|
20
|
+
`;
|
package/components/menu/menu.js
CHANGED
|
@@ -226,7 +226,11 @@ let Menu = class Menu extends MduiElement {
|
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
228
|
render() {
|
|
229
|
-
return html `<slot
|
|
229
|
+
return html `<slot
|
|
230
|
+
@slotchange=${this.onSlotChange}
|
|
231
|
+
@click=${this.onClick}
|
|
232
|
+
@keydown=${this.onKeyDown}
|
|
233
|
+
></slot>`;
|
|
230
234
|
}
|
|
231
235
|
setSelectedKeys(selectedKeys) {
|
|
232
236
|
if (!arraysEqualIgnoreOrder(this.selectedKeys, selectedKeys)) {
|