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
|
@@ -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
|
+
`;
|
|
@@ -12,7 +12,7 @@ import type { Ripple } from '../ripple/index.js';
|
|
|
12
12
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
13
13
|
declare const MenuItem_base: import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/anchor.js").AnchorMixinInterface> & import("@open-wc/dedupe-mixin").Constructor<import("../ripple/ripple-mixin.js").RippleMixinInterface> & import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof MduiElement;
|
|
14
14
|
/**
|
|
15
|
-
* @summary
|
|
15
|
+
* @summary 菜单项组件。需配合 `<mdui-menu>` 组件使用
|
|
16
16
|
*
|
|
17
17
|
* ```html
|
|
18
18
|
* <mdui-menu>
|
|
@@ -47,17 +47,17 @@ declare const MenuItem_base: import("@open-wc/dedupe-mixin").Constructor<import(
|
|
|
47
47
|
export declare class MenuItem extends MenuItem_base<MenuItemEventMap> {
|
|
48
48
|
static styles: CSSResultGroup;
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* 菜单项的值
|
|
51
51
|
*/
|
|
52
52
|
value?: string;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* 是否禁用菜单项
|
|
55
55
|
*/
|
|
56
56
|
disabled: boolean;
|
|
57
57
|
/**
|
|
58
58
|
* 左侧的 Material Icons 图标名。也可以通过 `slot="icon"` 设置
|
|
59
59
|
*
|
|
60
|
-
*
|
|
60
|
+
* 如果左侧不需要显示图标,但需要预留一个图标的位置,可传入空字符串进行占位
|
|
61
61
|
*/
|
|
62
62
|
icon?: string;
|
|
63
63
|
/**
|
|
@@ -30,7 +30,7 @@ import '../icon.js';
|
|
|
30
30
|
import { RippleMixin } from '../ripple/ripple-mixin.js';
|
|
31
31
|
import { menuItemStyle } from './menu-item-style.js';
|
|
32
32
|
/**
|
|
33
|
-
* @summary
|
|
33
|
+
* @summary 菜单项组件。需配合 `<mdui-menu>` 组件使用
|
|
34
34
|
*
|
|
35
35
|
* ```html
|
|
36
36
|
* <mdui-menu>
|
|
@@ -66,7 +66,7 @@ let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMixin(Mdu
|
|
|
66
66
|
constructor() {
|
|
67
67
|
super();
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* 是否禁用菜单项
|
|
70
70
|
*/
|
|
71
71
|
this.disabled = false;
|
|
72
72
|
/**
|
|
@@ -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
|
+
`;
|
|
@@ -15,7 +15,7 @@ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
|
15
15
|
* * `Enter` - 包含子菜单时,打开子菜单;为链接时,跳转链接
|
|
16
16
|
* * `Escape` - 子菜单已打开时,关闭子菜单
|
|
17
17
|
*
|
|
18
|
-
* @summary
|
|
18
|
+
* @summary 菜单组件。需配合 `<mdui-menu-item>` 组件使用
|
|
19
19
|
*
|
|
20
20
|
* ```html
|
|
21
21
|
* <mdui-menu>
|
|
@@ -24,49 +24,46 @@ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
|
24
24
|
* </mdui-menu>
|
|
25
25
|
* ```
|
|
26
26
|
*
|
|
27
|
-
* @event change -
|
|
27
|
+
* @event change - 菜单项选中状态变化时触发
|
|
28
28
|
*
|
|
29
29
|
* @slot - 子菜单项(`<mdui-menu-item>`)、分割线([`<mdui-divider>`](/docs/2/components/divider))等元素
|
|
30
30
|
*
|
|
31
|
-
* @cssprop --shape-corner -
|
|
31
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
32
32
|
*/
|
|
33
33
|
export declare class Menu extends MduiElement<MenuEventMap> {
|
|
34
34
|
static styles: CSSResultGroup;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* 菜单项的可选状态。默认不可选。可选值包括:
|
|
37
37
|
*
|
|
38
|
-
* * `single
|
|
39
|
-
* * `multiple
|
|
38
|
+
* * `single`:单选
|
|
39
|
+
* * `multiple`:多选
|
|
40
40
|
*/
|
|
41
|
-
selects?:
|
|
41
|
+
selects?: /*单选*/ 'single' | /*多选*/ 'multiple';
|
|
42
42
|
/**
|
|
43
|
-
* 当前选中的 `<mdui-menu-item>`
|
|
43
|
+
* 当前选中的 `<mdui-menu-item>` 的值。
|
|
44
44
|
*
|
|
45
|
-
* Note
|
|
46
|
-
* 该属性的 HTML 属性始终为字符串,且仅在 `selects="single"` 时可以通过 HTML 属性设置初始值;
|
|
47
|
-
* 该属性的 JavaScript 属性值在 `selects="single"` 时为字符串、在 `selects="multiple"` 时为字符串数组。
|
|
48
|
-
* 所以,在 `selects="multiple"` 时,如果要修改该值,只能通过修改 JavaScript 属性值实现。
|
|
45
|
+
* **Note**:该属性的 HTML 属性始终为字符串,仅在 `selects="single"` 时可通过 HTML 属性设置初始值;该属性的 JavaScript 属性值在 `selects="single"` 时为字符串,在 `selects="multiple"` 时为字符串数组。因此,在 `selects="multiple"` 时,若要修改该值,只能通过修改 JavaScript 属性值实现。
|
|
49
46
|
*/
|
|
50
47
|
value?: string | string[];
|
|
51
48
|
/**
|
|
52
|
-
*
|
|
49
|
+
* 菜单项是否使用紧凑布局
|
|
53
50
|
*/
|
|
54
51
|
dense: boolean;
|
|
55
52
|
/**
|
|
56
|
-
*
|
|
53
|
+
* 子菜单的触发方式,支持多个值,用空格分隔。可选值包括:
|
|
57
54
|
*
|
|
58
55
|
* * `click`:点击菜单项时打开子菜单
|
|
59
56
|
* * `hover`:鼠标悬浮到菜单项上时打开子菜单
|
|
60
57
|
* * `focus`:聚焦到菜单项上时打开子菜单
|
|
61
|
-
* * `manual
|
|
58
|
+
* * `manual`:仅能通过编程方式打开和关闭子菜单,不能再指定其他触发方式
|
|
62
59
|
*/
|
|
63
|
-
submenuTrigger: /*点击菜单项时打开子菜单*/ 'click' | /*鼠标悬浮到菜单项上时打开子菜单*/ 'hover' | /*聚焦到菜单项上时打开子菜单*/ 'focus' |
|
|
60
|
+
submenuTrigger: /*点击菜单项时打开子菜单*/ 'click' | /*鼠标悬浮到菜单项上时打开子菜单*/ 'hover' | /*聚焦到菜单项上时打开子菜单*/ 'focus' | /*仅能通过编程方式打开和关闭子菜单,不能再指定其他触发方式*/ 'manual' | string;
|
|
64
61
|
/**
|
|
65
|
-
*
|
|
62
|
+
* 鼠标悬浮触发子菜单打开的延时,单位毫秒
|
|
66
63
|
*/
|
|
67
64
|
submenuOpenDelay: number;
|
|
68
65
|
/**
|
|
69
|
-
*
|
|
66
|
+
* 鼠标悬浮触发子菜单关闭的延时,单位毫秒
|
|
70
67
|
*/
|
|
71
68
|
submenuCloseDelay: number;
|
|
72
69
|
private selectedKeys;
|
package/components/menu/menu.js
CHANGED
|
@@ -26,7 +26,7 @@ import { menuStyle } from './menu-style.js';
|
|
|
26
26
|
* * `Enter` - 包含子菜单时,打开子菜单;为链接时,跳转链接
|
|
27
27
|
* * `Escape` - 子菜单已打开时,关闭子菜单
|
|
28
28
|
*
|
|
29
|
-
* @summary
|
|
29
|
+
* @summary 菜单组件。需配合 `<mdui-menu-item>` 组件使用
|
|
30
30
|
*
|
|
31
31
|
* ```html
|
|
32
32
|
* <mdui-menu>
|
|
@@ -35,34 +35,34 @@ import { menuStyle } from './menu-style.js';
|
|
|
35
35
|
* </mdui-menu>
|
|
36
36
|
* ```
|
|
37
37
|
*
|
|
38
|
-
* @event change -
|
|
38
|
+
* @event change - 菜单项选中状态变化时触发
|
|
39
39
|
*
|
|
40
40
|
* @slot - 子菜单项(`<mdui-menu-item>`)、分割线([`<mdui-divider>`](/docs/2/components/divider))等元素
|
|
41
41
|
*
|
|
42
|
-
* @cssprop --shape-corner -
|
|
42
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
43
43
|
*/
|
|
44
44
|
let Menu = class Menu extends MduiElement {
|
|
45
45
|
constructor() {
|
|
46
46
|
super(...arguments);
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* 菜单项是否使用紧凑布局
|
|
49
49
|
*/
|
|
50
50
|
this.dense = false;
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* 子菜单的触发方式,支持多个值,用空格分隔。可选值包括:
|
|
53
53
|
*
|
|
54
54
|
* * `click`:点击菜单项时打开子菜单
|
|
55
55
|
* * `hover`:鼠标悬浮到菜单项上时打开子菜单
|
|
56
56
|
* * `focus`:聚焦到菜单项上时打开子菜单
|
|
57
|
-
* * `manual
|
|
57
|
+
* * `manual`:仅能通过编程方式打开和关闭子菜单,不能再指定其他触发方式
|
|
58
58
|
*/
|
|
59
59
|
this.submenuTrigger = 'click hover';
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* 鼠标悬浮触发子菜单打开的延时,单位毫秒
|
|
62
62
|
*/
|
|
63
63
|
this.submenuOpenDelay = 200;
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* 鼠标悬浮触发子菜单关闭的延时,单位毫秒
|
|
66
66
|
*/
|
|
67
67
|
this.submenuCloseDelay = 200;
|
|
68
68
|
// 因为 menu-item 的 value 可能会重复,所有在每一个 menu-item 元素上都加了一个唯一的 key 属性,通过 selectedKeys 来记录选中状态的 key
|
|
@@ -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)) {
|
|
@@ -1,2 +1,133 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const navigationBarItemStyle = css
|
|
2
|
+
export const navigationBarItemStyle = css `
|
|
3
|
+
:host {
|
|
4
|
+
--shape-corner-indicator: var(--mdui-shape-corner-full);
|
|
5
|
+
position: relative;
|
|
6
|
+
z-index: 0;
|
|
7
|
+
flex: 1;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
min-width: 3rem;
|
|
10
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface-variant);
|
|
11
|
+
}
|
|
12
|
+
.container {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
height: 100%;
|
|
18
|
+
text-decoration: none;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
-webkit-user-select: none;
|
|
21
|
+
user-select: none;
|
|
22
|
+
-webkit-tap-highlight-color: transparent;
|
|
23
|
+
padding-top: 0.75rem;
|
|
24
|
+
padding-bottom: 0.75rem;
|
|
25
|
+
}
|
|
26
|
+
.container:not(.initial) {
|
|
27
|
+
transition: padding var(--mdui-motion-duration-short4)
|
|
28
|
+
var(--mdui-motion-easing-standard);
|
|
29
|
+
}
|
|
30
|
+
mdui-ripple {
|
|
31
|
+
z-index: 1;
|
|
32
|
+
left: 50%;
|
|
33
|
+
transform: translateX(-50%);
|
|
34
|
+
width: 4rem;
|
|
35
|
+
height: 2rem;
|
|
36
|
+
margin-top: 0.75rem;
|
|
37
|
+
border-radius: var(--mdui-shape-corner-full);
|
|
38
|
+
}
|
|
39
|
+
mdui-ripple:not(.initial) {
|
|
40
|
+
transition: margin-top var(--mdui-motion-duration-short4)
|
|
41
|
+
var(--mdui-motion-easing-standard);
|
|
42
|
+
}
|
|
43
|
+
.indicator {
|
|
44
|
+
position: relative;
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
background-color: transparent;
|
|
49
|
+
border-radius: var(--shape-corner-indicator);
|
|
50
|
+
height: 2rem;
|
|
51
|
+
width: 2rem;
|
|
52
|
+
}
|
|
53
|
+
:not(.initial) .indicator {
|
|
54
|
+
transition:
|
|
55
|
+
background-color var(--mdui-motion-duration-short1)
|
|
56
|
+
var(--mdui-motion-easing-standard),
|
|
57
|
+
width var(--mdui-motion-duration-short4)
|
|
58
|
+
var(--mdui-motion-easing-standard);
|
|
59
|
+
}
|
|
60
|
+
::slotted([slot='badge']) {
|
|
61
|
+
position: absolute;
|
|
62
|
+
transform: translate(50%, -50%);
|
|
63
|
+
}
|
|
64
|
+
::slotted([slot='badge'][variant='small']) {
|
|
65
|
+
transform: translate(0.5625rem, -0.5625rem);
|
|
66
|
+
}
|
|
67
|
+
.icon,
|
|
68
|
+
.active-icon {
|
|
69
|
+
color: rgb(var(--mdui-color-on-surface-variant));
|
|
70
|
+
font-size: 1.5rem;
|
|
71
|
+
}
|
|
72
|
+
.icon mdui-icon,
|
|
73
|
+
.active-icon mdui-icon,
|
|
74
|
+
::slotted([slot='icon']),
|
|
75
|
+
::slotted([slot='active']) {
|
|
76
|
+
font-size: inherit;
|
|
77
|
+
}
|
|
78
|
+
.icon {
|
|
79
|
+
display: flex;
|
|
80
|
+
}
|
|
81
|
+
.active-icon {
|
|
82
|
+
display: none;
|
|
83
|
+
}
|
|
84
|
+
.label {
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
height: 1rem;
|
|
88
|
+
color: rgb(var(--mdui-color-on-surface-variant));
|
|
89
|
+
margin-top: 0.25rem;
|
|
90
|
+
margin-bottom: 0.25rem;
|
|
91
|
+
font-size: var(--mdui-typescale-label-medium-size);
|
|
92
|
+
font-weight: var(--mdui-typescale-label-medium-weight);
|
|
93
|
+
letter-spacing: var(--mdui-typescale-label-medium-tracking);
|
|
94
|
+
line-height: var(--mdui-typescale-label-medium-line-height);
|
|
95
|
+
}
|
|
96
|
+
:not(.initial) .label {
|
|
97
|
+
transition: opacity var(--mdui-motion-duration-short4)
|
|
98
|
+
var(--mdui-motion-easing-linear);
|
|
99
|
+
}
|
|
100
|
+
mdui-ripple.label-visibility-unlabeled,
|
|
101
|
+
:host(:not([active])) mdui-ripple.label-visibility-selected {
|
|
102
|
+
margin-top: 1.5rem;
|
|
103
|
+
}
|
|
104
|
+
.container.label-visibility-unlabeled,
|
|
105
|
+
:host(:not([active])) .container.label-visibility-selected {
|
|
106
|
+
padding-top: 1.5rem;
|
|
107
|
+
padding-bottom: 0rem;
|
|
108
|
+
}
|
|
109
|
+
.container.label-visibility-unlabeled .label,
|
|
110
|
+
:host(:not([active])) .container.label-visibility-selected .label {
|
|
111
|
+
opacity: 0;
|
|
112
|
+
}
|
|
113
|
+
:host([active]) {
|
|
114
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
|
|
115
|
+
}
|
|
116
|
+
:host([active]) .indicator {
|
|
117
|
+
width: 4rem;
|
|
118
|
+
background-color: rgb(var(--mdui-color-secondary-container));
|
|
119
|
+
}
|
|
120
|
+
:host([active]) .icon,
|
|
121
|
+
:host([active]) .active-icon {
|
|
122
|
+
color: rgb(var(--mdui-color-on-secondary-container));
|
|
123
|
+
}
|
|
124
|
+
:host([active]) .has-active-icon .active-icon {
|
|
125
|
+
display: flex;
|
|
126
|
+
}
|
|
127
|
+
:host([active]) .has-active-icon .icon {
|
|
128
|
+
display: none;
|
|
129
|
+
}
|
|
130
|
+
:host([active]) .label {
|
|
131
|
+
color: rgb(var(--mdui-color-on-surface));
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
@@ -4,7 +4,7 @@ import type { Ripple } from '../ripple/index.js';
|
|
|
4
4
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
5
5
|
declare const NavigationBarItem_base: import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/anchor.js").AnchorMixinInterface> & import("@open-wc/dedupe-mixin").Constructor<import("../ripple/ripple-mixin.js").RippleMixinInterface> & import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof MduiElement;
|
|
6
6
|
/**
|
|
7
|
-
* @summary
|
|
7
|
+
* @summary 底部导航栏项组件。需配合 `<mdui-navigation-bar>` 组件使用
|
|
8
8
|
*
|
|
9
9
|
* ```html
|
|
10
10
|
* <mdui-navigation-bar>
|
|
@@ -14,7 +14,7 @@ declare const NavigationBarItem_base: import("@open-wc/dedupe-mixin").Constructo
|
|
|
14
14
|
* </mdui-navigation-bar>
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* @slot -
|
|
17
|
+
* @slot - 导航项文本
|
|
18
18
|
* @slot icon - 图标
|
|
19
19
|
* @slot active-icon - 激活状态的图标元素
|
|
20
20
|
* @slot badge - 徽标
|
|
@@ -27,9 +27,9 @@ declare const NavigationBarItem_base: import("@open-wc/dedupe-mixin").Constructo
|
|
|
27
27
|
* @csspart badge - 徽标
|
|
28
28
|
* @csspart icon - 图标
|
|
29
29
|
* @csspart active-icon - 激活状态的图标
|
|
30
|
-
* @csspart label -
|
|
30
|
+
* @csspart label - 导航项文本
|
|
31
31
|
*
|
|
32
|
-
* @cssprop --shape-corner-indicator -
|
|
32
|
+
* @cssprop --shape-corner-indicator - 指示器的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
33
33
|
*/
|
|
34
34
|
export declare class NavigationBarItem extends NavigationBarItem_base<NavigationBarItemEventMap> {
|
|
35
35
|
static styles: CSSResultGroup;
|
|
@@ -42,7 +42,7 @@ export declare class NavigationBarItem extends NavigationBarItem_base<Navigation
|
|
|
42
42
|
*/
|
|
43
43
|
activeIcon?: string;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* 导航项的值
|
|
46
46
|
*/
|
|
47
47
|
value?: string;
|
|
48
48
|
/**
|