mdui 2.0.2 → 2.0.4
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 +17 -15
- package/components/avatar/index.js +7 -6
- package/components/badge/index.d.ts +11 -8
- package/components/badge/index.js +9 -7
- package/components/bottom-app-bar/index.d.ts +11 -4
- package/components/bottom-app-bar/index.js +8 -9
- package/components/button/button-base-style.js +1 -1
- package/components/button/button-base.d.ts +46 -47
- package/components/button/button-base.js +27 -25
- package/components/button/index.d.ts +19 -14
- package/components/button/index.js +12 -12
- package/components/button-icon/index.d.ts +15 -9
- package/components/button-icon/index.js +8 -9
- package/components/card/index.d.ts +15 -11
- package/components/card/index.js +10 -9
- package/components/checkbox/index.d.ts +30 -23
- package/components/checkbox/index.js +25 -25
- package/components/chip/index.d.ts +27 -20
- package/components/chip/index.js +19 -20
- package/components/circular-progress/index.d.ts +6 -4
- package/components/circular-progress/index.js +4 -3
- package/components/collapse/collapse-item.d.ts +17 -6
- package/components/collapse/collapse-item.js +7 -7
- package/components/collapse/collapse.d.ts +16 -11
- package/components/collapse/collapse.js +10 -10
- package/components/dialog/index.d.ts +22 -15
- package/components/dialog/index.js +23 -27
- package/components/divider/index.d.ts +7 -5
- package/components/divider/index.js +6 -5
- package/components/dropdown/index.d.ts +44 -37
- package/components/dropdown/index.js +50 -48
- package/components/fab/index.d.ts +12 -7
- package/components/fab/index.js +6 -6
- package/components/icon/index.d.ts +4 -2
- package/components/icon/index.js +3 -2
- package/components/layout/layout-item-base.d.ts +3 -2
- package/components/layout/layout-item-base.js +2 -2
- package/components/layout/layout-item.d.ts +11 -10
- package/components/layout/layout-item.js +6 -6
- package/components/layout/layout-main.d.ts +6 -4
- package/components/layout/layout-main.js +5 -4
- package/components/layout/layout.d.ts +6 -4
- package/components/layout/layout.js +5 -4
- package/components/linear-progress/index.d.ts +8 -6
- package/components/linear-progress/index.js +6 -5
- package/components/list/list-item-style.js +1 -1
- package/components/list/list-item.d.ts +24 -20
- package/components/list/list-item.js +10 -9
- package/components/list/list-subheader.d.ts +6 -4
- package/components/list/list-subheader.js +5 -4
- package/components/list/list.d.ts +5 -3
- package/components/list/list.js +4 -3
- package/components/menu/menu-item.d.ts +15 -7
- package/components/menu/menu-item.js +11 -15
- package/components/menu/menu.d.ts +20 -20
- package/components/menu/menu.js +13 -13
- package/components/navigation-bar/navigation-bar-item.d.ts +12 -8
- package/components/navigation-bar/navigation-bar-item.js +7 -6
- package/components/navigation-bar/navigation-bar.d.ts +17 -9
- package/components/navigation-bar/navigation-bar.js +15 -13
- package/components/navigation-drawer/index.d.ts +27 -21
- package/components/navigation-drawer/index.js +51 -38
- package/components/navigation-drawer/style.js +1 -1
- package/components/navigation-rail/navigation-rail-item.d.ts +13 -9
- package/components/navigation-rail/navigation-rail-item.js +7 -6
- package/components/navigation-rail/navigation-rail.d.ts +14 -12
- package/components/navigation-rail/navigation-rail.js +13 -12
- package/components/radio/radio-group.d.ts +20 -15
- package/components/radio/radio-group.js +21 -24
- package/components/radio/radio.d.ts +11 -6
- package/components/radio/radio.js +7 -7
- package/components/range-slider/index.d.ts +13 -8
- package/components/range-slider/index.js +10 -7
- package/components/ripple/index.d.ts +4 -2
- package/components/ripple/index.js +3 -2
- package/components/ripple/ripple-mixin.d.ts +1 -1
- package/components/ripple/ripple-mixin.js +0 -1
- package/components/segmented-button/segmented-button-group-style.js +1 -1
- package/components/segmented-button/segmented-button-group.d.ts +23 -22
- package/components/segmented-button/segmented-button-group.js +20 -23
- package/components/segmented-button/segmented-button.d.ts +9 -4
- package/components/segmented-button/segmented-button.js +3 -3
- package/components/select/index.d.ts +42 -35
- package/components/select/index.js +24 -25
- package/components/slider/index.d.ts +9 -2
- package/components/slider/index.js +5 -10
- package/components/slider/slider-base.d.ts +22 -18
- package/components/slider/slider-base.js +40 -21
- package/components/snackbar/index.d.ts +30 -23
- package/components/snackbar/index.js +25 -25
- package/components/switch/index.d.ts +24 -17
- package/components/switch/index.js +18 -18
- package/components/tabs/tab-panel.d.ts +7 -5
- package/components/tabs/tab-panel.js +5 -4
- package/components/tabs/tab.d.ts +13 -9
- package/components/tabs/tab.js +8 -7
- package/components/tabs/tabs.d.ts +24 -21
- package/components/tabs/tabs.js +24 -21
- package/components/text-field/index.d.ts +62 -54
- package/components/text-field/index.js +37 -37
- package/components/tooltip/index.d.ts +40 -33
- package/components/tooltip/index.js +45 -43
- package/components/top-app-bar/top-app-bar-title.d.ts +8 -6
- package/components/top-app-bar/top-app-bar-title.js +7 -6
- package/components/top-app-bar/top-app-bar.d.ts +12 -6
- package/components/top-app-bar/top-app-bar.js +9 -10
- package/css-data.en.json +2826 -0
- package/css-data.zh-cn.json +374 -367
- package/custom-elements.json +3844 -3824
- package/html-data.en.json +6551 -0
- package/html-data.zh-cn.json +1621 -1636
- package/jsx.en.d.ts +3303 -0
- package/jsx.zh-cn.d.ts +3351 -0
- package/mdui.esm.js +9 -9
- package/mdui.global.js +9 -9
- package/package.json +7 -5
- package/web-types.en.json +11718 -0
- package/web-types.zh-cn.json +3613 -3623
|
@@ -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
|
-
export declare class NavigationDrawer extends LayoutItemBase {
|
|
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;
|
|
@@ -81,6 +80,13 @@ export declare class NavigationDrawer extends LayoutItemBase {
|
|
|
81
80
|
private onOverlayClick;
|
|
82
81
|
private getLockTargetAnimate;
|
|
83
82
|
}
|
|
83
|
+
export interface NavigationDrawerEventMap {
|
|
84
|
+
open: CustomEvent<void>;
|
|
85
|
+
opened: CustomEvent<void>;
|
|
86
|
+
close: CustomEvent<void>;
|
|
87
|
+
closed: CustomEvent<void>;
|
|
88
|
+
'overlay-click': CustomEvent<void>;
|
|
89
|
+
}
|
|
84
90
|
declare global {
|
|
85
91
|
interface HTMLElementTagNameMap {
|
|
86
92
|
'mdui-navigation-drawer': NavigationDrawer;
|
|
@@ -12,7 +12,6 @@ import { watch } from '@mdui/shared/decorators/watch.js';
|
|
|
12
12
|
import { animateTo, stopAnimations } from '@mdui/shared/helpers/animate.js';
|
|
13
13
|
import { breakpoint } from '@mdui/shared/helpers/breakpoint.js';
|
|
14
14
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
15
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
16
15
|
import { Modal } from '@mdui/shared/helpers/modal.js';
|
|
17
16
|
import { getDuration, getEasing } from '@mdui/shared/helpers/motion.js';
|
|
18
17
|
import { observeResize } from '@mdui/shared/helpers/observeResize.js';
|
|
@@ -29,53 +28,52 @@ import { style } from './style.js';
|
|
|
29
28
|
* <mdui-navigation-drawer>content</mdui-navigation-drawer>
|
|
30
29
|
* ```
|
|
31
30
|
*
|
|
32
|
-
* @event open -
|
|
33
|
-
* @event opened -
|
|
34
|
-
* @event close -
|
|
35
|
-
* @event closed -
|
|
31
|
+
* @event open - 抽屉栏打开之前触发。可以通过调用 `event.preventDefault()` 阻止抽屉栏打开
|
|
32
|
+
* @event opened - 抽屉栏打开动画完成之后触发
|
|
33
|
+
* @event close - 抽屉栏关闭之前触发。可以通过调用 `event.preventDefault()` 阻止抽屉栏关闭
|
|
34
|
+
* @event closed - 抽屉栏关闭动画完成之后触发
|
|
36
35
|
* @event overlay-click - 点击遮罩层时触发
|
|
37
36
|
*
|
|
38
|
-
* @slot -
|
|
37
|
+
* @slot - 抽屉栏中的内容
|
|
39
38
|
*
|
|
40
39
|
* @csspart overlay - 遮罩层
|
|
41
|
-
* @csspart panel -
|
|
40
|
+
* @csspart panel - 抽屉栏容器
|
|
42
41
|
*
|
|
43
|
-
* @cssprop --shape-corner -
|
|
44
|
-
* @cssprop --z-index - 组件的 CSS
|
|
42
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
43
|
+
* @cssprop --z-index - 组件的 CSS `z-index` 值
|
|
45
44
|
*/
|
|
46
45
|
let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
47
46
|
constructor() {
|
|
48
47
|
super(...arguments);
|
|
49
48
|
/**
|
|
50
|
-
*
|
|
49
|
+
* 是否打开抽屉栏
|
|
51
50
|
*/
|
|
52
51
|
this.open = false;
|
|
53
52
|
/**
|
|
54
|
-
*
|
|
53
|
+
* 抽屉栏打开时,是否显示遮罩层
|
|
55
54
|
*
|
|
56
|
-
*
|
|
55
|
+
* 在窄屏设备上(屏幕宽度小于 [`--mdui-breakpoint-md`](/docs/2/styles/design-tokens#breakpoint)),会始终显示遮罩层,无视该参数
|
|
57
56
|
*/
|
|
58
57
|
this.modal = false;
|
|
59
58
|
/**
|
|
60
|
-
*
|
|
59
|
+
* 在有遮罩层的情况下,按下 ESC 键是否关闭抽屉栏
|
|
61
60
|
*/
|
|
62
61
|
this.closeOnEsc = false;
|
|
63
62
|
/**
|
|
64
|
-
*
|
|
63
|
+
* 点击遮罩层时,是否关闭抽屉栏
|
|
65
64
|
*/
|
|
66
65
|
this.closeOnOverlayClick = false;
|
|
67
66
|
/**
|
|
68
|
-
*
|
|
67
|
+
* 抽屉栏的位置。可选值包括:
|
|
69
68
|
*
|
|
70
|
-
* * `left
|
|
71
|
-
* * `right
|
|
69
|
+
* * `left`:左侧
|
|
70
|
+
* * `right`:右侧
|
|
72
71
|
*/
|
|
73
72
|
this.placement = 'left';
|
|
74
73
|
/**
|
|
75
|
-
*
|
|
74
|
+
* 默认情况下,抽屉栏相对于 `body` 元素显示。当该参数设置为 `true` 时,抽屉栏将相对于其父元素显示。
|
|
76
75
|
*
|
|
77
|
-
* Note:
|
|
78
|
-
* 设置了该属性时,必须手动在父元素上设置样式 `position: relative; overflow: hidden;`
|
|
76
|
+
* **Note**:设置该属性时,必须在父元素上手动设置样式 `position: relative; overflow: hidden;`。
|
|
79
77
|
*/
|
|
80
78
|
this.contained = false;
|
|
81
79
|
// 断点为 mobile 时为 `true` 时,强制使用遮罩层
|
|
@@ -92,7 +90,7 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
92
90
|
get lockTarget() {
|
|
93
91
|
return this.contained || this.isParentLayout
|
|
94
92
|
? this.parentElement
|
|
95
|
-
: document.
|
|
93
|
+
: document.documentElement;
|
|
96
94
|
}
|
|
97
95
|
get isModal() {
|
|
98
96
|
return this.mobile || this.modal;
|
|
@@ -101,7 +99,7 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
101
99
|
async onContainedChange() {
|
|
102
100
|
await this.definedController.whenDefined();
|
|
103
101
|
this.observeResize?.unobserve();
|
|
104
|
-
this.observeResize = observeResize(this.contained ? this.parentElement : document.
|
|
102
|
+
this.observeResize = observeResize(this.contained ? this.parentElement : document.documentElement, () => {
|
|
105
103
|
const target = this.contained ? this.parentElement : undefined;
|
|
106
104
|
this.mobile = breakpoint(target).down('md');
|
|
107
105
|
// 若位于 layout 中,且为模态化,则重新布局时,占据的宽度为 0
|
|
@@ -143,14 +141,22 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
143
141
|
};
|
|
144
142
|
// 停止原有动画
|
|
145
143
|
const stopOldAnimations = async () => {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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)));
|
|
154
160
|
};
|
|
155
161
|
// 打开
|
|
156
162
|
// 要区分是否首次渲染,首次渲染时不触发事件,不执行动画;非首次渲染,触发事件,执行动画
|
|
@@ -162,8 +168,8 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
162
168
|
overlay = this.overlayRef.value;
|
|
163
169
|
}
|
|
164
170
|
if (hasUpdated) {
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
171
|
+
const eventProceeded = this.emit('open', { cancelable: true });
|
|
172
|
+
if (!eventProceeded) {
|
|
167
173
|
return;
|
|
168
174
|
}
|
|
169
175
|
}
|
|
@@ -204,6 +210,7 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
204
210
|
// 但首次渲染不执行动画
|
|
205
211
|
if (this.isParentLayout && hasUpdated) {
|
|
206
212
|
setLayoutTransition(duration, easingEmphasized);
|
|
213
|
+
this.layoutManager.updateLayout(this);
|
|
207
214
|
}
|
|
208
215
|
// drawer 显示动画
|
|
209
216
|
animations.push(animateTo(this.isModal ? panel : this, [
|
|
@@ -214,18 +221,21 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
214
221
|
easing: easingEmphasized,
|
|
215
222
|
}));
|
|
216
223
|
await Promise.all(animations);
|
|
224
|
+
if (!this.open) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
217
227
|
// 若位于 layout 中,则 drawer 动画完成后,移除 layout-main 的动画
|
|
218
228
|
if (this.isParentLayout && hasUpdated) {
|
|
219
229
|
setLayoutTransition(null);
|
|
220
230
|
}
|
|
221
231
|
if (hasUpdated) {
|
|
222
|
-
emit(
|
|
232
|
+
this.emit('opened');
|
|
223
233
|
}
|
|
224
234
|
}
|
|
225
235
|
else if (this.hasUpdated) {
|
|
226
236
|
// 关闭
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
237
|
+
const eventProceeded = this.emit('close', { cancelable: true });
|
|
238
|
+
if (!eventProceeded) {
|
|
229
239
|
return;
|
|
230
240
|
}
|
|
231
241
|
await this.definedController.whenDefined();
|
|
@@ -259,6 +269,9 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
259
269
|
{ transform: `translateX(${isRight ? '' : '-'}100%)` },
|
|
260
270
|
], { duration, easing: easingEmphasized }));
|
|
261
271
|
await Promise.all(animations);
|
|
272
|
+
if (this.open) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
262
275
|
// 若位于 layout 中,则 drawer 动画结束后,移除 layout-main 的动画
|
|
263
276
|
if (this.isParentLayout) {
|
|
264
277
|
setLayoutTransition(null);
|
|
@@ -267,12 +280,12 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
267
280
|
if (this.isModal && !this.contained) {
|
|
268
281
|
unlockScreen(this, this.lockTarget);
|
|
269
282
|
}
|
|
270
|
-
//
|
|
283
|
+
// 抽屉栏关闭后,恢复焦点到原有的元素上
|
|
271
284
|
const trigger = this.originalTrigger;
|
|
272
285
|
if (isFunction(trigger?.focus)) {
|
|
273
286
|
setTimeout(() => trigger.focus());
|
|
274
287
|
}
|
|
275
|
-
emit(
|
|
288
|
+
this.emit('closed');
|
|
276
289
|
}
|
|
277
290
|
}
|
|
278
291
|
connectedCallback() {
|
|
@@ -300,7 +313,7 @@ let NavigationDrawer = class NavigationDrawer extends LayoutItemBase {
|
|
|
300
313
|
return html `${when(this.isModal, () => html `<div ${ref(this.overlayRef)} part="overlay" class="overlay" @click="${this.onOverlayClick}"></div>`)}<slot ${ref(this.panelRef)} part="panel" class="panel" tabindex="0"></slot>`;
|
|
301
314
|
}
|
|
302
315
|
onOverlayClick() {
|
|
303
|
-
emit(
|
|
316
|
+
this.emit('overlay-click');
|
|
304
317
|
if (this.closeOnOverlayClick) {
|
|
305
318
|
this.open = false;
|
|
306
319
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css `:host{--shape-corner:var(--mdui-shape-corner-large);--z-index:2200;display:none;position:fixed;top:0;bottom:0;left:0;z-index:1;width:22.5rem}:host([placement=right]){left:initial;right:0}:host([mobile]),:host([modal]){top:0!important;right:0;bottom:0!important;width:initial;z-index:var(--z-index)}:host([placement=right][mobile]),:host([placement=right][modal]){left:0}:host([contained]){position:absolute}.overlay{position:absolute;inset:0;z-index:inherit;background-color:rgba(var(--mdui-color-scrim),.4)}.panel{display:block;position:absolute;top:0;bottom:0;left:0;width:100%;overflow:auto;z-index:inherit;background-color:rgb(var(--mdui-color-surface));box-shadow:var(--mdui-elevation-level0)}:host([mobile]) .panel,:host([modal]) .panel{border-radius:0 var(--shape-corner) var(--shape-corner) 0;width:22.5rem;background-color:rgb(var(--mdui-color-surface-container-low));box-shadow:var(--mdui-elevation-level1)}:host([placement=right]) .panel{left:initial;right:0}:host([placement=right][mobile]) .panel,:host([placement=right][modal]) .panel{border-radius:var(--shape-corner) 0 0 var(--shape-corner)}`;
|
|
2
|
+
export const style = css `:host{--shape-corner:var(--mdui-shape-corner-large);--z-index:2200;display:none;position:fixed;top:0;bottom:0;left:0;z-index:1;width:22.5rem}:host([placement=right]){left:initial;right:0}:host([mobile]),:host([modal]){top:0!important;right:0;bottom:0!important;width:initial;z-index:var(--z-index)}:host([placement=right][mobile]),:host([placement=right][modal]){left:0}:host([contained]){position:absolute}.overlay{position:absolute;inset:0;z-index:inherit;background-color:rgba(var(--mdui-color-scrim),.4)}.panel{display:block;position:absolute;top:0;bottom:0;left:0;width:100%;overflow:auto;z-index:inherit;background-color:rgb(var(--mdui-color-surface));box-shadow:var(--mdui-elevation-level0)}:host([mobile]) .panel,:host([modal]) .panel{border-radius:0 var(--shape-corner) var(--shape-corner) 0;max-width:80%;width:22.5rem;background-color:rgb(var(--mdui-color-surface-container-low));box-shadow:var(--mdui-elevation-level1)}:host([placement=right]) .panel{left:initial;right:0}:host([placement=right][mobile]) .panel,:host([placement=right][modal]) .panel{border-radius:var(--shape-corner) 0 0 var(--shape-corner)}`;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import '../icon.js';
|
|
3
3
|
import type { Ripple } from '../ripple/index.js';
|
|
4
4
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
5
|
-
declare const NavigationRailItem_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
|
|
5
|
+
declare const NavigationRailItem_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-rail>` 组件使用
|
|
8
8
|
*
|
|
9
9
|
* ```html
|
|
10
10
|
* <mdui-navigation-rail>
|
|
@@ -14,7 +14,7 @@ declare const NavigationRailItem_base: import("@open-wc/dedupe-mixin").Construct
|
|
|
14
14
|
* </mdui-navigation-rail>
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* @slot -
|
|
17
|
+
* @slot - 文本内容
|
|
18
18
|
* @slot icon - 图标
|
|
19
19
|
* @slot active-icon - 激活状态的图标
|
|
20
20
|
* @slot badge - 徽标
|
|
@@ -27,18 +27,18 @@ declare const NavigationRailItem_base: import("@open-wc/dedupe-mixin").Construct
|
|
|
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
|
-
export declare class NavigationRailItem extends NavigationRailItem_base {
|
|
34
|
+
export declare class NavigationRailItem extends NavigationRailItem_base<NavigationRailItemEventMap> {
|
|
35
35
|
static styles: CSSResultGroup;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* 未激活状态下的 Material Icons 图标名。也可以通过 `slot="icon"` 设置
|
|
38
38
|
*/
|
|
39
39
|
icon?: string;
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* 激活状态下的 Material Icons 图标名。也可以通过 `slot="active-icon"` 设置
|
|
42
42
|
*/
|
|
43
43
|
activeIcon?: string;
|
|
44
44
|
/**
|
|
@@ -68,6 +68,10 @@ export declare class NavigationRailItem extends NavigationRailItem_base {
|
|
|
68
68
|
protected render(): TemplateResult;
|
|
69
69
|
private renderInner;
|
|
70
70
|
}
|
|
71
|
+
export interface NavigationRailItemEventMap {
|
|
72
|
+
focus: FocusEvent;
|
|
73
|
+
blur: FocusEvent;
|
|
74
|
+
}
|
|
71
75
|
declare global {
|
|
72
76
|
interface HTMLElementTagNameMap {
|
|
73
77
|
'mdui-navigation-rail-item': NavigationRailItem;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html,
|
|
2
|
+
import { html, nothing } from 'lit';
|
|
3
3
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
6
6
|
import cc from 'classcat';
|
|
7
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
7
8
|
import { HasSlotController } from '@mdui/shared/controllers/has-slot.js';
|
|
8
9
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
9
10
|
import { nothingTemplate } from '@mdui/shared/helpers/template.js';
|
|
@@ -15,7 +16,7 @@ import '../icon.js';
|
|
|
15
16
|
import { RippleMixin } from '../ripple/ripple-mixin.js';
|
|
16
17
|
import { navigationRailItemStyle } from './navigation-rail-item-style.js';
|
|
17
18
|
/**
|
|
18
|
-
* @summary
|
|
19
|
+
* @summary 侧边导航项组件。需配合 `<mdui-navigation-rail>` 组件使用
|
|
19
20
|
*
|
|
20
21
|
* ```html
|
|
21
22
|
* <mdui-navigation-rail>
|
|
@@ -25,7 +26,7 @@ import { navigationRailItemStyle } from './navigation-rail-item-style.js';
|
|
|
25
26
|
* </mdui-navigation-rail>
|
|
26
27
|
* ```
|
|
27
28
|
*
|
|
28
|
-
* @slot -
|
|
29
|
+
* @slot - 文本内容
|
|
29
30
|
* @slot icon - 图标
|
|
30
31
|
* @slot active-icon - 激活状态的图标
|
|
31
32
|
* @slot badge - 徽标
|
|
@@ -38,11 +39,11 @@ import { navigationRailItemStyle } from './navigation-rail-item-style.js';
|
|
|
38
39
|
* @csspart badge - 徽标
|
|
39
40
|
* @csspart icon - 图标
|
|
40
41
|
* @csspart active-icon - 激活状态的图标
|
|
41
|
-
* @csspart label -
|
|
42
|
+
* @csspart label - 文本内容
|
|
42
43
|
*
|
|
43
|
-
* @cssprop --shape-corner-indicator -
|
|
44
|
+
* @cssprop --shape-corner-indicator - 指示器的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
44
45
|
*/
|
|
45
|
-
let NavigationRailItem = class NavigationRailItem extends AnchorMixin(RippleMixin(FocusableMixin(
|
|
46
|
+
let NavigationRailItem = class NavigationRailItem extends AnchorMixin(RippleMixin(FocusableMixin(MduiElement))) {
|
|
46
47
|
constructor() {
|
|
47
48
|
super(...arguments);
|
|
48
49
|
/**
|
|
@@ -4,7 +4,7 @@ import { LayoutItemBase } from '../layout/layout-item-base.js';
|
|
|
4
4
|
import type { LayoutPlacement } from '../layout/helper.js';
|
|
5
5
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
6
6
|
/**
|
|
7
|
-
* @summary
|
|
7
|
+
* @summary 侧边导航栏组件。需配合 `<mdui-navigation-rail-item>` 组件使用
|
|
8
8
|
*
|
|
9
9
|
* ```html
|
|
10
10
|
* <mdui-navigation-rail>
|
|
@@ -24,24 +24,24 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
24
24
|
* @csspart bottom - 底部元素的容器
|
|
25
25
|
* @csspart items - `<mdui-navigation-rail-item>` 组件的容器
|
|
26
26
|
*
|
|
27
|
-
* @cssprop --shape-corner -
|
|
28
|
-
* @cssprop --z-index - 组件的 CSS
|
|
27
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
28
|
+
* @cssprop --z-index - 组件的 CSS `z-index` 值
|
|
29
29
|
*/
|
|
30
|
-
export declare class NavigationRail extends LayoutItemBase {
|
|
30
|
+
export declare class NavigationRail extends LayoutItemBase<NavigationRailEventMap> {
|
|
31
31
|
static styles: CSSResultGroup;
|
|
32
32
|
/**
|
|
33
33
|
* 当前选中的 `<mdui-navigation-rail-item>` 的值
|
|
34
34
|
*/
|
|
35
35
|
value?: string;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* 导航栏的位置。可选值包括:
|
|
38
38
|
*
|
|
39
|
-
* * `left
|
|
40
|
-
* * `right
|
|
39
|
+
* * `left`:左侧
|
|
40
|
+
* * `right`:右侧
|
|
41
41
|
*/
|
|
42
|
-
placement:
|
|
42
|
+
placement: /*左侧*/ 'left' | /*右侧*/ 'right';
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* `<mdui-navigation-rail-item>` 元素的对齐方式。可选值包括:
|
|
45
45
|
*
|
|
46
46
|
* * `start`:顶部对齐
|
|
47
47
|
* * `center`:居中对齐
|
|
@@ -49,10 +49,9 @@ export declare class NavigationRail extends LayoutItemBase {
|
|
|
49
49
|
*/
|
|
50
50
|
alignment: /*顶部对齐*/ 'start' | /*居中对齐*/ 'center' | /*底部对齐*/ 'end';
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* 默认情况下,导航栏相对于 `body` 元素显示。当该参数设置为 `true` 时,导航栏将相对于其父元素显示。
|
|
53
53
|
*
|
|
54
|
-
* Note:
|
|
55
|
-
* 设置了该属性时,必须手动在父元素上设置样式 `position: relative;`
|
|
54
|
+
* **Note**:设置该属性时,必须在父元素上手动设置样式 `position: relative;`。
|
|
56
55
|
*/
|
|
57
56
|
contained: boolean;
|
|
58
57
|
/**
|
|
@@ -79,6 +78,9 @@ export declare class NavigationRail extends LayoutItemBase {
|
|
|
79
78
|
private updateItems;
|
|
80
79
|
private onSlotChange;
|
|
81
80
|
}
|
|
81
|
+
export interface NavigationRailEventMap {
|
|
82
|
+
change: CustomEvent<void>;
|
|
83
|
+
}
|
|
82
84
|
declare global {
|
|
83
85
|
interface HTMLElementTagNameMap {
|
|
84
86
|
'mdui-navigation-rail': NavigationRail;
|
|
@@ -9,12 +9,11 @@ import { DefinedController } from '@mdui/shared/controllers/defined.js';
|
|
|
9
9
|
import { HasSlotController } from '@mdui/shared/controllers/has-slot.js';
|
|
10
10
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
11
11
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
12
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
13
12
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
14
13
|
import { LayoutItemBase } from '../layout/layout-item-base.js';
|
|
15
14
|
import { navigationRailStyle } from './navigation-rail-style.js';
|
|
16
15
|
/**
|
|
17
|
-
* @summary
|
|
16
|
+
* @summary 侧边导航栏组件。需配合 `<mdui-navigation-rail-item>` 组件使用
|
|
18
17
|
*
|
|
19
18
|
* ```html
|
|
20
19
|
* <mdui-navigation-rail>
|
|
@@ -34,21 +33,21 @@ import { navigationRailStyle } from './navigation-rail-style.js';
|
|
|
34
33
|
* @csspart bottom - 底部元素的容器
|
|
35
34
|
* @csspart items - `<mdui-navigation-rail-item>` 组件的容器
|
|
36
35
|
*
|
|
37
|
-
* @cssprop --shape-corner -
|
|
38
|
-
* @cssprop --z-index - 组件的 CSS
|
|
36
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
37
|
+
* @cssprop --z-index - 组件的 CSS `z-index` 值
|
|
39
38
|
*/
|
|
40
39
|
let NavigationRail = class NavigationRail extends LayoutItemBase {
|
|
41
40
|
constructor() {
|
|
42
41
|
super(...arguments);
|
|
43
42
|
/**
|
|
44
|
-
*
|
|
43
|
+
* 导航栏的位置。可选值包括:
|
|
45
44
|
*
|
|
46
|
-
* * `left
|
|
47
|
-
* * `right
|
|
45
|
+
* * `left`:左侧
|
|
46
|
+
* * `right`:右侧
|
|
48
47
|
*/
|
|
49
48
|
this.placement = 'left';
|
|
50
49
|
/**
|
|
51
|
-
*
|
|
50
|
+
* `<mdui-navigation-rail-item>` 元素的对齐方式。可选值包括:
|
|
52
51
|
*
|
|
53
52
|
* * `start`:顶部对齐
|
|
54
53
|
* * `center`:居中对齐
|
|
@@ -56,10 +55,9 @@ let NavigationRail = class NavigationRail extends LayoutItemBase {
|
|
|
56
55
|
*/
|
|
57
56
|
this.alignment = 'start';
|
|
58
57
|
/**
|
|
59
|
-
*
|
|
58
|
+
* 默认情况下,导航栏相对于 `body` 元素显示。当该参数设置为 `true` 时,导航栏将相对于其父元素显示。
|
|
60
59
|
*
|
|
61
|
-
* Note:
|
|
62
|
-
* 设置了该属性时,必须手动在父元素上设置样式 `position: relative;`
|
|
60
|
+
* **Note**:设置该属性时,必须在父元素上手动设置样式 `position: relative;`。
|
|
63
61
|
*/
|
|
64
62
|
this.contained = false;
|
|
65
63
|
/**
|
|
@@ -97,7 +95,7 @@ let NavigationRail = class NavigationRail extends LayoutItemBase {
|
|
|
97
95
|
const item = this.items.find((item) => item.key === this.activeKey);
|
|
98
96
|
this.value = item?.value;
|
|
99
97
|
if (!this.isInitial) {
|
|
100
|
-
emit(
|
|
98
|
+
this.emit('change');
|
|
101
99
|
}
|
|
102
100
|
}
|
|
103
101
|
async onValueChange() {
|
|
@@ -166,6 +164,9 @@ let NavigationRail = class NavigationRail extends LayoutItemBase {
|
|
|
166
164
|
}
|
|
167
165
|
const target = event.target;
|
|
168
166
|
const item = target.closest('mdui-navigation-rail-item');
|
|
167
|
+
if (!item) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
169
170
|
this.activeKey = item.key;
|
|
170
171
|
this.isInitial = false;
|
|
171
172
|
this.updateItems();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
1
|
import '@mdui/jq/methods/closest.js';
|
|
3
2
|
import '@mdui/jq/methods/find.js';
|
|
4
3
|
import '@mdui/jq/methods/get.js';
|
|
4
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
5
5
|
import type { FormControl } from '@mdui/jq/shared/form.js';
|
|
6
6
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
7
7
|
/**
|
|
8
|
-
* @summary
|
|
8
|
+
* @summary 单选框组组件。需配合 `<mdui-radio>` 组件使用
|
|
9
9
|
*
|
|
10
10
|
* ```html
|
|
11
11
|
* <mdui-radio-group value="chinese">
|
|
@@ -20,24 +20,24 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
20
20
|
*
|
|
21
21
|
* @slot - `<mdui-radio>` 元素
|
|
22
22
|
*/
|
|
23
|
-
export declare class RadioGroup extends
|
|
23
|
+
export declare class RadioGroup extends MduiElement<RadioGroupEventMap> implements FormControl {
|
|
24
24
|
static styles: CSSResultGroup;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* 是否禁用此组件
|
|
27
27
|
*/
|
|
28
28
|
disabled: boolean;
|
|
29
29
|
/**
|
|
30
|
-
* 关联的
|
|
30
|
+
* 关联的 `<form>` 元素。此属性值应为同一页面中的一个 `<form>` 元素的 `id`。
|
|
31
31
|
*
|
|
32
|
-
*
|
|
32
|
+
* 如果未指定此属性,则该元素必须是 `<form>` 元素的子元素。通过此属性,你可以将元素放置在页面的任何位置,而不仅仅是 `<form>` 元素的子元素。
|
|
33
33
|
*/
|
|
34
34
|
form?: string;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* 单选框组的名称,将与表单数据一起提交
|
|
37
37
|
*/
|
|
38
38
|
name: string;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* 单选框组的名称,将于表单数据一起提交
|
|
41
41
|
*/
|
|
42
42
|
value: string;
|
|
43
43
|
/**
|
|
@@ -57,11 +57,11 @@ export declare class RadioGroup extends LitElement implements FormControl {
|
|
|
57
57
|
private readonly formController;
|
|
58
58
|
private readonly definedController;
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
61
61
|
*/
|
|
62
62
|
get validity(): ValidityState;
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
64
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
65
65
|
*/
|
|
66
66
|
get validationMessage(): string;
|
|
67
67
|
private get items();
|
|
@@ -69,19 +69,19 @@ export declare class RadioGroup extends LitElement implements FormControl {
|
|
|
69
69
|
private onValueChange;
|
|
70
70
|
private onInvalidChange;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
73
73
|
*/
|
|
74
74
|
checkValidity(): boolean;
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
76
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
77
77
|
*
|
|
78
|
-
*
|
|
78
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
79
79
|
*/
|
|
80
80
|
reportValidity(): boolean;
|
|
81
81
|
/**
|
|
82
|
-
*
|
|
82
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
83
83
|
*
|
|
84
|
-
* @param message
|
|
84
|
+
* @param message 自定义的错误提示文本
|
|
85
85
|
*/
|
|
86
86
|
setCustomValidity(message: string): void;
|
|
87
87
|
protected render(): TemplateResult;
|
|
@@ -98,6 +98,11 @@ export declare class RadioGroup extends LitElement implements FormControl {
|
|
|
98
98
|
private onCheckedChange;
|
|
99
99
|
private updateItems;
|
|
100
100
|
}
|
|
101
|
+
export interface RadioGroupEventMap {
|
|
102
|
+
change: CustomEvent<void>;
|
|
103
|
+
input: CustomEvent<void>;
|
|
104
|
+
invalid: CustomEvent<void>;
|
|
105
|
+
}
|
|
101
106
|
declare global {
|
|
102
107
|
interface HTMLElementTagNameMap {
|
|
103
108
|
'mdui-radio-group': RadioGroup;
|