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
|
@@ -15,7 +15,7 @@ import '../icon.js';
|
|
|
15
15
|
import { RippleMixin } from '../ripple/ripple-mixin.js';
|
|
16
16
|
import { navigationBarItemStyle } from './navigation-bar-item-style.js';
|
|
17
17
|
/**
|
|
18
|
-
* @summary
|
|
18
|
+
* @summary 底部导航栏项组件。需配合 `<mdui-navigation-bar>` 组件使用
|
|
19
19
|
*
|
|
20
20
|
* ```html
|
|
21
21
|
* <mdui-navigation-bar>
|
|
@@ -25,7 +25,7 @@ import { navigationBarItemStyle } from './navigation-bar-item-style.js';
|
|
|
25
25
|
* </mdui-navigation-bar>
|
|
26
26
|
* ```
|
|
27
27
|
*
|
|
28
|
-
* @slot -
|
|
28
|
+
* @slot - 导航项文本
|
|
29
29
|
* @slot icon - 图标
|
|
30
30
|
* @slot active-icon - 激活状态的图标元素
|
|
31
31
|
* @slot badge - 徽标
|
|
@@ -38,9 +38,9 @@ import { navigationBarItemStyle } from './navigation-bar-item-style.js';
|
|
|
38
38
|
* @csspart badge - 徽标
|
|
39
39
|
* @csspart icon - 图标
|
|
40
40
|
* @csspart active-icon - 激活状态的图标
|
|
41
|
-
* @csspart label -
|
|
41
|
+
* @csspart label - 导航项文本
|
|
42
42
|
*
|
|
43
|
-
* @cssprop --shape-corner-indicator -
|
|
43
|
+
* @cssprop --shape-corner-indicator - 指示器的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
44
44
|
*/
|
|
45
45
|
let NavigationBarItem = class NavigationBarItem extends AnchorMixin(RippleMixin(FocusableMixin(MduiElement))) {
|
|
46
46
|
constructor() {
|
|
@@ -86,20 +86,36 @@ let NavigationBarItem = class NavigationBarItem extends AnchorMixin(RippleMixin(
|
|
|
86
86
|
},
|
|
87
87
|
labelVisibilityClassName,
|
|
88
88
|
]);
|
|
89
|
-
return html `<mdui-ripple
|
|
89
|
+
return html `<mdui-ripple
|
|
90
|
+
.noRipple=${!this.active || this.noRipple}
|
|
91
|
+
class=${labelVisibilityClassName}
|
|
92
|
+
${ref(this.rippleRef)}
|
|
93
|
+
></mdui-ripple>
|
|
94
|
+
${this.href
|
|
90
95
|
? this.renderAnchor({
|
|
91
96
|
part: 'container',
|
|
92
97
|
className,
|
|
93
98
|
content: this.renderInner(),
|
|
94
99
|
})
|
|
95
|
-
: html `<div part="container" class
|
|
100
|
+
: html `<div part="container" class=${className}>
|
|
101
|
+
${this.renderInner()}
|
|
102
|
+
</div>`} `;
|
|
96
103
|
}
|
|
97
104
|
renderInner() {
|
|
98
|
-
return html `<div part="indicator" class="indicator"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
return html `<div part="indicator" class="indicator">
|
|
106
|
+
<slot name="badge" part="badge" class="badge"></slot>
|
|
107
|
+
<slot name="active-icon" part="active-icon" class="active-icon">
|
|
108
|
+
${this.activeIcon
|
|
109
|
+
? html `<mdui-icon name=${this.activeIcon}></mdui-icon>`
|
|
110
|
+
: nothingTemplate}
|
|
111
|
+
</slot>
|
|
112
|
+
<slot name="icon" part="icon" class="icon">
|
|
113
|
+
${this.icon
|
|
114
|
+
? html `<mdui-icon name=${this.icon}></mdui-icon>`
|
|
115
|
+
: nothingTemplate}
|
|
116
|
+
</slot>
|
|
117
|
+
</div>
|
|
118
|
+
<slot part="label" class="label"></slot>`;
|
|
103
119
|
}
|
|
104
120
|
};
|
|
105
121
|
NavigationBarItem.styles = [
|
|
@@ -1,2 +1,29 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const navigationBarStyle = css
|
|
2
|
+
export const navigationBarStyle = css `
|
|
3
|
+
:host {
|
|
4
|
+
--shape-corner: var(--mdui-shape-corner-none);
|
|
5
|
+
--z-index: 2000;
|
|
6
|
+
position: fixed;
|
|
7
|
+
right: 0;
|
|
8
|
+
bottom: 0;
|
|
9
|
+
left: 0;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex: 0 0 auto;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
border-radius: var(--shape-corner) var(--shape-corner) 0 0;
|
|
14
|
+
z-index: var(--z-index);
|
|
15
|
+
transition-property: transform;
|
|
16
|
+
transition-duration: var(--mdui-motion-duration-long2);
|
|
17
|
+
transition-timing-function: var(--mdui-motion-easing-emphasized);
|
|
18
|
+
height: 5rem;
|
|
19
|
+
background-color: rgb(var(--mdui-color-surface));
|
|
20
|
+
box-shadow: var(--mdui-elevation-level2);
|
|
21
|
+
}
|
|
22
|
+
:host([scroll-target]:not([scroll-target=''])) {
|
|
23
|
+
position: absolute;
|
|
24
|
+
}
|
|
25
|
+
:host([hide]) {
|
|
26
|
+
transform: translateY(5.625rem);
|
|
27
|
+
transition-duration: var(--mdui-motion-duration-short4);
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
@@ -5,7 +5,7 @@ import type { ScrollPaddingPosition } from '@mdui/shared/mixins/scrollBehavior.j
|
|
|
5
5
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
6
6
|
declare const NavigationBar_base: import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/scrollBehavior.js").ScrollBehaviorMixinInterface> & typeof LayoutItemBase;
|
|
7
7
|
/**
|
|
8
|
-
* @summary
|
|
8
|
+
* @summary 底部导航栏组件。需配合 `<mdui-navigation-bar-item>` 组件使用
|
|
9
9
|
*
|
|
10
10
|
* ```html
|
|
11
11
|
* <mdui-navigation-bar>
|
|
@@ -23,8 +23,8 @@ declare const NavigationBar_base: import("@open-wc/dedupe-mixin").Constructor<im
|
|
|
23
23
|
*
|
|
24
24
|
* @slot - `<mdui-navigation-bar-item>` 组件
|
|
25
25
|
*
|
|
26
|
-
* @cssprop --shape-corner -
|
|
27
|
-
* @cssprop --z-index - 组件的 CSS
|
|
26
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
27
|
+
* @cssprop --z-index - 组件的 CSS `z-index` 值
|
|
28
28
|
*/
|
|
29
29
|
export declare class NavigationBar extends NavigationBar_base<NavigationBarEventMap> {
|
|
30
30
|
static styles: CSSResultGroup;
|
|
@@ -33,20 +33,21 @@ export declare class NavigationBar extends NavigationBar_base<NavigationBarEvent
|
|
|
33
33
|
*/
|
|
34
34
|
hide: boolean;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* 文本的可视状态。可选值包括:
|
|
37
37
|
*
|
|
38
|
-
* * `auto
|
|
39
|
-
* * `selected
|
|
38
|
+
* * `auto`:当选项小于等于3个时,始终显示文本;当选项大于3个时,仅显示选中状态的文本
|
|
39
|
+
* * `selected`:仅在选中状态显示文本
|
|
40
40
|
* * `labeled`:始终显示文本
|
|
41
41
|
* * `unlabeled`:始终不显示文本
|
|
42
42
|
*/
|
|
43
|
-
labelVisibility:
|
|
43
|
+
labelVisibility: /*当选项小于等于3个时,始终显示文本;当选项大于3个时,仅显示选中状态的文本*/ 'auto' | /*仅在选中状态显示文本*/ 'selected' | /*始终显示文本*/ 'labeled' | /*始终不显示文本*/ 'unlabeled';
|
|
44
44
|
/**
|
|
45
45
|
* 当前选中的 `<mdui-navigation-bar-item>` 的值
|
|
46
46
|
*/
|
|
47
47
|
value?: string;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* 滚动行为。可选值包括:
|
|
50
|
+
*
|
|
50
51
|
* * `hide`:滚动时隐藏
|
|
51
52
|
*/
|
|
52
53
|
scrollBehavior?: 'hide';
|
|
@@ -9,7 +9,7 @@ import { ScrollBehaviorMixin } from '@mdui/shared/mixins/scrollBehavior.js';
|
|
|
9
9
|
import { LayoutItemBase } from '../layout/layout-item-base.js';
|
|
10
10
|
import { navigationBarStyle } from './navigation-bar-style.js';
|
|
11
11
|
/**
|
|
12
|
-
* @summary
|
|
12
|
+
* @summary 底部导航栏组件。需配合 `<mdui-navigation-bar-item>` 组件使用
|
|
13
13
|
*
|
|
14
14
|
* ```html
|
|
15
15
|
* <mdui-navigation-bar>
|
|
@@ -27,8 +27,8 @@ import { navigationBarStyle } from './navigation-bar-style.js';
|
|
|
27
27
|
*
|
|
28
28
|
* @slot - `<mdui-navigation-bar-item>` 组件
|
|
29
29
|
*
|
|
30
|
-
* @cssprop --shape-corner -
|
|
31
|
-
* @cssprop --z-index - 组件的 CSS
|
|
30
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
31
|
+
* @cssprop --z-index - 组件的 CSS `z-index` 值
|
|
32
32
|
*/
|
|
33
33
|
let NavigationBar = class NavigationBar extends ScrollBehaviorMixin(LayoutItemBase) {
|
|
34
34
|
constructor() {
|
|
@@ -38,10 +38,10 @@ let NavigationBar = class NavigationBar extends ScrollBehaviorMixin(LayoutItemBa
|
|
|
38
38
|
*/
|
|
39
39
|
this.hide = false;
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* 文本的可视状态。可选值包括:
|
|
42
42
|
*
|
|
43
|
-
* * `auto
|
|
44
|
-
* * `selected
|
|
43
|
+
* * `auto`:当选项小于等于3个时,始终显示文本;当选项大于3个时,仅显示选中状态的文本
|
|
44
|
+
* * `selected`:仅在选中状态显示文本
|
|
45
45
|
* * `labeled`:始终显示文本
|
|
46
46
|
* * `unlabeled`:始终不显示文本
|
|
47
47
|
*/
|
|
@@ -89,7 +89,10 @@ let NavigationBar = class NavigationBar extends ScrollBehaviorMixin(LayoutItemBa
|
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
render() {
|
|
92
|
-
return html `<slot
|
|
92
|
+
return html `<slot
|
|
93
|
+
@slotchange=${this.onSlotChange}
|
|
94
|
+
@click=${this.onClick}
|
|
95
|
+
></slot>`;
|
|
93
96
|
}
|
|
94
97
|
/**
|
|
95
98
|
* 滚动行为
|
|
@@ -12,52 +12,51 @@ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
|
12
12
|
* <mdui-navigation-drawer>content</mdui-navigation-drawer>
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
* @event open -
|
|
16
|
-
* @event opened -
|
|
17
|
-
* @event close -
|
|
18
|
-
* @event closed -
|
|
15
|
+
* @event open - 抽屉栏打开之前触发。可以通过调用 `event.preventDefault()` 阻止抽屉栏打开
|
|
16
|
+
* @event opened - 抽屉栏打开动画完成之后触发
|
|
17
|
+
* @event close - 抽屉栏关闭之前触发。可以通过调用 `event.preventDefault()` 阻止抽屉栏关闭
|
|
18
|
+
* @event closed - 抽屉栏关闭动画完成之后触发
|
|
19
19
|
* @event overlay-click - 点击遮罩层时触发
|
|
20
20
|
*
|
|
21
|
-
* @slot -
|
|
21
|
+
* @slot - 抽屉栏中的内容
|
|
22
22
|
*
|
|
23
23
|
* @csspart overlay - 遮罩层
|
|
24
|
-
* @csspart panel -
|
|
24
|
+
* @csspart panel - 抽屉栏容器
|
|
25
25
|
*
|
|
26
|
-
* @cssprop --shape-corner -
|
|
27
|
-
* @cssprop --z-index - 组件的 CSS
|
|
26
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
27
|
+
* @cssprop --z-index - 组件的 CSS `z-index` 值
|
|
28
28
|
*/
|
|
29
29
|
export declare class NavigationDrawer extends LayoutItemBase<NavigationDrawerEventMap> {
|
|
30
30
|
static styles: CSSResultGroup;
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* 是否打开抽屉栏
|
|
33
33
|
*/
|
|
34
34
|
open: boolean;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* 抽屉栏打开时,是否显示遮罩层
|
|
37
37
|
*
|
|
38
|
-
*
|
|
38
|
+
* 在窄屏设备上(屏幕宽度小于 [`--mdui-breakpoint-md`](/docs/2/styles/design-tokens#breakpoint)),会始终显示遮罩层,无视该参数
|
|
39
39
|
*/
|
|
40
40
|
modal: boolean;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* 在有遮罩层的情况下,按下 ESC 键是否关闭抽屉栏
|
|
43
43
|
*/
|
|
44
44
|
closeOnEsc: boolean;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* 点击遮罩层时,是否关闭抽屉栏
|
|
47
47
|
*/
|
|
48
48
|
closeOnOverlayClick: boolean;
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* 抽屉栏的位置。可选值包括:
|
|
51
51
|
*
|
|
52
|
-
* * `left
|
|
53
|
-
* * `right
|
|
52
|
+
* * `left`:左侧
|
|
53
|
+
* * `right`:右侧
|
|
54
54
|
*/
|
|
55
|
-
placement:
|
|
55
|
+
placement: /*左侧*/ 'left' | /*右侧*/ 'right';
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* 默认情况下,抽屉栏相对于 `body` 元素显示。当该参数设置为 `true` 时,抽屉栏将相对于其父元素显示。
|
|
58
58
|
*
|
|
59
|
-
* Note:
|
|
60
|
-
* 设置了该属性时,必须手动在父元素上设置样式 `position: relative; overflow: hidden;`
|
|
59
|
+
* **Note**:设置该属性时,必须在父元素上手动设置样式 `position: relative; overflow: hidden;`。
|
|
61
60
|
*/
|
|
62
61
|
contained: boolean;
|
|
63
62
|
private mobile;
|
|
@@ -28,53 +28,52 @@ import { style } from './style.js';
|
|
|
28
28
|
* <mdui-navigation-drawer>content</mdui-navigation-drawer>
|
|
29
29
|
* ```
|
|
30
30
|
*
|
|
31
|
-
* @event open -
|
|
32
|
-
* @event opened -
|
|
33
|
-
* @event close -
|
|
34
|
-
* @event closed -
|
|
31
|
+
* @event open - 抽屉栏打开之前触发。可以通过调用 `event.preventDefault()` 阻止抽屉栏打开
|
|
32
|
+
* @event opened - 抽屉栏打开动画完成之后触发
|
|
33
|
+
* @event close - 抽屉栏关闭之前触发。可以通过调用 `event.preventDefault()` 阻止抽屉栏关闭
|
|
34
|
+
* @event closed - 抽屉栏关闭动画完成之后触发
|
|
35
35
|
* @event overlay-click - 点击遮罩层时触发
|
|
36
36
|
*
|
|
37
|
-
* @slot -
|
|
37
|
+
* @slot - 抽屉栏中的内容
|
|
38
38
|
*
|
|
39
39
|
* @csspart overlay - 遮罩层
|
|
40
|
-
* @csspart panel -
|
|
40
|
+
* @csspart panel - 抽屉栏容器
|
|
41
41
|
*
|
|
42
|
-
* @cssprop --shape-corner -
|
|
43
|
-
* @cssprop --z-index - 组件的 CSS
|
|
42
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
43
|
+
* @cssprop --z-index - 组件的 CSS `z-index` 值
|
|
44
44
|
*/
|
|
45
45
|
let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
46
46
|
constructor() {
|
|
47
47
|
super(...arguments);
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* 是否打开抽屉栏
|
|
50
50
|
*/
|
|
51
51
|
this.open = false;
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* 抽屉栏打开时,是否显示遮罩层
|
|
54
54
|
*
|
|
55
|
-
*
|
|
55
|
+
* 在窄屏设备上(屏幕宽度小于 [`--mdui-breakpoint-md`](/docs/2/styles/design-tokens#breakpoint)),会始终显示遮罩层,无视该参数
|
|
56
56
|
*/
|
|
57
57
|
this.modal = false;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* 在有遮罩层的情况下,按下 ESC 键是否关闭抽屉栏
|
|
60
60
|
*/
|
|
61
61
|
this.closeOnEsc = false;
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* 点击遮罩层时,是否关闭抽屉栏
|
|
64
64
|
*/
|
|
65
65
|
this.closeOnOverlayClick = false;
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* 抽屉栏的位置。可选值包括:
|
|
68
68
|
*
|
|
69
|
-
* * `left
|
|
70
|
-
* * `right
|
|
69
|
+
* * `left`:左侧
|
|
70
|
+
* * `right`:右侧
|
|
71
71
|
*/
|
|
72
72
|
this.placement = 'left';
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
74
|
+
* 默认情况下,抽屉栏相对于 `body` 元素显示。当该参数设置为 `true` 时,抽屉栏将相对于其父元素显示。
|
|
75
75
|
*
|
|
76
|
-
* Note:
|
|
77
|
-
* 设置了该属性时,必须手动在父元素上设置样式 `position: relative; overflow: hidden;`
|
|
76
|
+
* **Note**:设置该属性时,必须在父元素上手动设置样式 `position: relative; overflow: hidden;`。
|
|
78
77
|
*/
|
|
79
78
|
this.contained = false;
|
|
80
79
|
// 断点为 mobile 时为 `true` 时,强制使用遮罩层
|
|
@@ -91,7 +90,7 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
91
90
|
get lockTarget() {
|
|
92
91
|
return this.contained || this.isParentLayout
|
|
93
92
|
? this.parentElement
|
|
94
|
-
: document.
|
|
93
|
+
: document.documentElement;
|
|
95
94
|
}
|
|
96
95
|
get isModal() {
|
|
97
96
|
return this.mobile || this.modal;
|
|
@@ -100,7 +99,7 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
100
99
|
async onContainedChange() {
|
|
101
100
|
await this.definedController.whenDefined();
|
|
102
101
|
this.observeResize?.unobserve();
|
|
103
|
-
this.observeResize = observeResize(this.contained ? this.parentElement : document.
|
|
102
|
+
this.observeResize = observeResize(this.contained ? this.parentElement : document.documentElement, () => {
|
|
104
103
|
const target = this.contained ? this.parentElement : undefined;
|
|
105
104
|
this.mobile = breakpoint(target).down('md');
|
|
106
105
|
// 若位于 layout 中,且为模态化,则重新布局时,占据的宽度为 0
|
|
@@ -142,14 +141,22 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
142
141
|
};
|
|
143
142
|
// 停止原有动画
|
|
144
143
|
const stopOldAnimations = async () => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
144
|
+
const elements = [];
|
|
145
|
+
if (this.isModal) {
|
|
146
|
+
elements.push(overlay, panel);
|
|
147
|
+
}
|
|
148
|
+
else if (!this.isParentLayout) {
|
|
149
|
+
elements.push(this.lockTarget);
|
|
150
|
+
}
|
|
151
|
+
if (this.isParentLayout) {
|
|
152
|
+
const layoutItems = this.layoutManager.getItemsAndMain();
|
|
153
|
+
const layoutIndex = layoutItems.indexOf(this);
|
|
154
|
+
elements.push(...layoutItems.slice(layoutIndex));
|
|
155
|
+
}
|
|
156
|
+
if (!this.isModal && !elements.includes(this)) {
|
|
157
|
+
elements.push(this);
|
|
158
|
+
}
|
|
159
|
+
await Promise.all(elements.map((element) => stopAnimations(element)));
|
|
153
160
|
};
|
|
154
161
|
// 打开
|
|
155
162
|
// 要区分是否首次渲染,首次渲染时不触发事件,不执行动画;非首次渲染,触发事件,执行动画
|
|
@@ -203,6 +210,7 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
203
210
|
// 但首次渲染不执行动画
|
|
204
211
|
if (this.isParentLayout && hasUpdated) {
|
|
205
212
|
setLayoutTransition(duration, easingEmphasized);
|
|
213
|
+
this.layoutManager.updateLayout(this);
|
|
206
214
|
}
|
|
207
215
|
// drawer 显示动画
|
|
208
216
|
animations.push(animateTo(this.isModal ? panel : this, [
|
|
@@ -213,6 +221,9 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
213
221
|
easing: easingEmphasized,
|
|
214
222
|
}));
|
|
215
223
|
await Promise.all(animations);
|
|
224
|
+
if (!this.open) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
216
227
|
// 若位于 layout 中,则 drawer 动画完成后,移除 layout-main 的动画
|
|
217
228
|
if (this.isParentLayout && hasUpdated) {
|
|
218
229
|
setLayoutTransition(null);
|
|
@@ -258,6 +269,9 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
258
269
|
{ transform: `translateX(${isRight ? '' : '-'}100%)` },
|
|
259
270
|
], { duration, easing: easingEmphasized }));
|
|
260
271
|
await Promise.all(animations);
|
|
272
|
+
if (this.open) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
261
275
|
// 若位于 layout 中,则 drawer 动画结束后,移除 layout-main 的动画
|
|
262
276
|
if (this.isParentLayout) {
|
|
263
277
|
setLayoutTransition(null);
|
|
@@ -266,7 +280,7 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
266
280
|
if (this.isModal && !this.contained) {
|
|
267
281
|
unlockScreen(this, this.lockTarget);
|
|
268
282
|
}
|
|
269
|
-
//
|
|
283
|
+
// 抽屉栏关闭后,恢复焦点到原有的元素上
|
|
270
284
|
const trigger = this.originalTrigger;
|
|
271
285
|
if (isFunction(trigger?.focus)) {
|
|
272
286
|
setTimeout(() => trigger.focus());
|
|
@@ -296,7 +310,18 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
296
310
|
});
|
|
297
311
|
}
|
|
298
312
|
render() {
|
|
299
|
-
return html `${when(this.isModal, () => html `<div
|
|
313
|
+
return html `${when(this.isModal, () => html `<div
|
|
314
|
+
${ref(this.overlayRef)}
|
|
315
|
+
part="overlay"
|
|
316
|
+
class="overlay"
|
|
317
|
+
@click=${this.onOverlayClick}
|
|
318
|
+
></div>`)}
|
|
319
|
+
<slot
|
|
320
|
+
${ref(this.panelRef)}
|
|
321
|
+
part="panel"
|
|
322
|
+
class="panel"
|
|
323
|
+
tabindex="0"
|
|
324
|
+
></slot>`;
|
|
300
325
|
}
|
|
301
326
|
onOverlayClick() {
|
|
302
327
|
this.emit('overlay-click');
|
|
@@ -1,2 +1,67 @@
|
|
|
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-large);
|
|
5
|
+
--z-index: 2200;
|
|
6
|
+
display: none;
|
|
7
|
+
position: fixed;
|
|
8
|
+
top: 0;
|
|
9
|
+
bottom: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
z-index: 1;
|
|
12
|
+
width: 22.5rem;
|
|
13
|
+
}
|
|
14
|
+
:host([placement='right']) {
|
|
15
|
+
left: initial;
|
|
16
|
+
right: 0;
|
|
17
|
+
}
|
|
18
|
+
:host([modal]),
|
|
19
|
+
:host([mobile]) {
|
|
20
|
+
top: 0 !important;
|
|
21
|
+
right: 0;
|
|
22
|
+
bottom: 0 !important;
|
|
23
|
+
width: initial;
|
|
24
|
+
z-index: var(--z-index);
|
|
25
|
+
}
|
|
26
|
+
:host([placement='right'][modal]),
|
|
27
|
+
:host([placement='right'][mobile]) {
|
|
28
|
+
left: 0;
|
|
29
|
+
}
|
|
30
|
+
:host([contained]) {
|
|
31
|
+
position: absolute;
|
|
32
|
+
}
|
|
33
|
+
.overlay {
|
|
34
|
+
position: absolute;
|
|
35
|
+
inset: 0;
|
|
36
|
+
z-index: inherit;
|
|
37
|
+
background-color: rgba(var(--mdui-color-scrim), 0.4);
|
|
38
|
+
}
|
|
39
|
+
.panel {
|
|
40
|
+
display: block;
|
|
41
|
+
position: absolute;
|
|
42
|
+
top: 0;
|
|
43
|
+
bottom: 0;
|
|
44
|
+
left: 0;
|
|
45
|
+
width: 100%;
|
|
46
|
+
overflow: auto;
|
|
47
|
+
z-index: inherit;
|
|
48
|
+
background-color: rgb(var(--mdui-color-surface));
|
|
49
|
+
box-shadow: var(--mdui-elevation-level0);
|
|
50
|
+
}
|
|
51
|
+
:host([modal]) .panel,
|
|
52
|
+
:host([mobile]) .panel {
|
|
53
|
+
border-radius: 0 var(--shape-corner) var(--shape-corner) 0;
|
|
54
|
+
max-width: 80%;
|
|
55
|
+
width: 22.5rem;
|
|
56
|
+
background-color: rgb(var(--mdui-color-surface-container-low));
|
|
57
|
+
box-shadow: var(--mdui-elevation-level1);
|
|
58
|
+
}
|
|
59
|
+
:host([placement='right']) .panel {
|
|
60
|
+
left: initial;
|
|
61
|
+
right: 0;
|
|
62
|
+
}
|
|
63
|
+
:host([placement='right'][modal]) .panel,
|
|
64
|
+
:host([placement='right'][mobile]) .panel {
|
|
65
|
+
border-radius: var(--shape-corner) 0 0 var(--shape-corner);
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
@@ -1,2 +1,123 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const navigationRailItemStyle = css
|
|
2
|
+
export const navigationRailItemStyle = css `
|
|
3
|
+
:host {
|
|
4
|
+
--shape-corner-indicator: var(--mdui-shape-corner-full);
|
|
5
|
+
position: relative;
|
|
6
|
+
z-index: 0;
|
|
7
|
+
width: 100%;
|
|
8
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface-variant);
|
|
9
|
+
}
|
|
10
|
+
.container {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
text-decoration: none;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
-webkit-user-select: none;
|
|
18
|
+
user-select: none;
|
|
19
|
+
-webkit-tap-highlight-color: transparent;
|
|
20
|
+
height: 3.5rem;
|
|
21
|
+
}
|
|
22
|
+
.container:not(.initial) {
|
|
23
|
+
transition: padding var(--mdui-motion-duration-short4)
|
|
24
|
+
var(--mdui-motion-easing-standard);
|
|
25
|
+
}
|
|
26
|
+
mdui-ripple {
|
|
27
|
+
z-index: 1;
|
|
28
|
+
width: 3.5rem;
|
|
29
|
+
height: 2rem;
|
|
30
|
+
border-radius: var(--mdui-shape-corner-full);
|
|
31
|
+
}
|
|
32
|
+
.container:not(.has-label) + mdui-ripple {
|
|
33
|
+
height: 3.5rem;
|
|
34
|
+
}
|
|
35
|
+
.indicator {
|
|
36
|
+
position: relative;
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
background-color: transparent;
|
|
41
|
+
border-radius: var(--shape-corner-indicator);
|
|
42
|
+
height: 2rem;
|
|
43
|
+
width: 2rem;
|
|
44
|
+
}
|
|
45
|
+
:not(.initial) .indicator {
|
|
46
|
+
transition:
|
|
47
|
+
background-color var(--mdui-motion-duration-short1)
|
|
48
|
+
var(--mdui-motion-easing-standard),
|
|
49
|
+
width var(--mdui-motion-duration-short4)
|
|
50
|
+
var(--mdui-motion-easing-standard),
|
|
51
|
+
height var(--mdui-motion-duration-short4)
|
|
52
|
+
var(--mdui-motion-easing-standard);
|
|
53
|
+
}
|
|
54
|
+
::slotted([slot='badge']) {
|
|
55
|
+
position: absolute;
|
|
56
|
+
transform: translate(50%, -50%);
|
|
57
|
+
}
|
|
58
|
+
.placement-right::slotted([slot='badge']) {
|
|
59
|
+
transform: translate(-50%, -50%);
|
|
60
|
+
}
|
|
61
|
+
::slotted([slot='badge'][variant='small']) {
|
|
62
|
+
transform: translate(0.5625rem, -0.5625rem);
|
|
63
|
+
}
|
|
64
|
+
.placement-right::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-icon']) {
|
|
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
|
+
:host([active]) {
|
|
101
|
+
--mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
|
|
102
|
+
}
|
|
103
|
+
:host([active]) .indicator {
|
|
104
|
+
width: 3.5rem;
|
|
105
|
+
background-color: rgb(var(--mdui-color-secondary-container));
|
|
106
|
+
}
|
|
107
|
+
:host([active]) :not(.has-label) .indicator {
|
|
108
|
+
height: 3.5rem;
|
|
109
|
+
}
|
|
110
|
+
:host([active]) .icon,
|
|
111
|
+
:host([active]) .active-icon {
|
|
112
|
+
color: rgb(var(--mdui-color-on-secondary-container));
|
|
113
|
+
}
|
|
114
|
+
:host([active]) .has-active-icon .active-icon {
|
|
115
|
+
display: flex;
|
|
116
|
+
}
|
|
117
|
+
:host([active]) .has-active-icon .icon {
|
|
118
|
+
display: none;
|
|
119
|
+
}
|
|
120
|
+
:host([active]) .label {
|
|
121
|
+
color: rgb(var(--mdui-color-on-surface));
|
|
122
|
+
}
|
|
123
|
+
`;
|