mdui 2.0.1 → 2.0.3
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/LICENSE +21 -21
- package/components/avatar/index.d.ts +4 -2
- package/components/avatar/index.js +4 -2
- package/components/badge/index.d.ts +4 -2
- package/components/badge/index.js +4 -2
- package/components/bottom-app-bar/index.d.ts +9 -3
- package/components/bottom-app-bar/index.js +9 -9
- package/components/button/button-base.d.ts +5 -5
- package/components/button/button-base.js +22 -19
- package/components/button/index.d.ts +6 -1
- package/components/button/index.js +2 -1
- package/components/button-icon/index.d.ts +7 -1
- package/components/button-icon/index.js +3 -3
- package/components/card/index.d.ts +8 -4
- package/components/card/index.js +7 -3
- package/components/checkbox/index.d.ts +10 -3
- package/components/checkbox/index.js +13 -16
- package/components/checkbox/style.js +1 -1
- package/components/chip/index.d.ts +8 -1
- package/components/chip/index.js +5 -5
- package/components/circular-progress/index.d.ts +4 -2
- package/components/circular-progress/index.js +5 -4
- package/components/collapse/collapse-item-style.js +1 -1
- package/components/collapse/collapse-item.d.ts +15 -3
- package/components/collapse/collapse-item.js +26 -23
- package/components/collapse/collapse.d.ts +16 -8
- package/components/collapse/collapse.js +61 -38
- package/components/dialog/index.d.ts +12 -4
- package/components/dialog/index.js +36 -36
- package/components/divider/index.d.ts +4 -2
- package/components/divider/index.js +4 -2
- package/components/dropdown/index.d.ts +13 -7
- package/components/dropdown/index.js +70 -63
- package/components/fab/index.d.ts +7 -1
- package/components/fab/index.js +10 -5
- package/components/icon/index.d.ts +4 -2
- package/components/icon/index.js +4 -2
- package/components/layout/helper.d.ts +5 -6
- package/components/layout/helper.js +42 -48
- package/components/layout/layout-item-base.d.ts +3 -2
- package/components/layout/layout-item-base.js +3 -4
- package/components/layout/layout-item.d.ts +4 -3
- package/components/layout/layout-item.js +3 -3
- package/components/layout/layout-main.d.ts +4 -2
- package/components/layout/layout-main.js +4 -2
- package/components/layout/layout.d.ts +4 -2
- package/components/layout/layout.js +4 -2
- package/components/linear-progress/index.d.ts +4 -2
- package/components/linear-progress/index.js +5 -4
- package/components/list/list-item-style.js +1 -1
- package/components/list/list-item.d.ts +7 -3
- package/components/list/list-item.js +5 -3
- package/components/list/list-subheader.d.ts +4 -2
- package/components/list/list-subheader.js +4 -2
- package/components/list/list.d.ts +4 -2
- package/components/list/list.js +4 -2
- package/components/menu/menu-item.d.ts +12 -3
- package/components/menu/menu-item.js +53 -40
- package/components/menu/menu.d.ts +9 -3
- package/components/menu/menu.js +85 -59
- package/components/navigation-bar/navigation-bar-item-style.js +1 -1
- package/components/navigation-bar/navigation-bar-item.d.ts +13 -5
- package/components/navigation-bar/navigation-bar-item.js +28 -11
- package/components/navigation-bar/navigation-bar.d.ts +14 -7
- package/components/navigation-bar/navigation-bar.js +58 -49
- package/components/navigation-drawer/index.d.ts +13 -2
- package/components/navigation-drawer/index.js +69 -49
- package/components/navigation-drawer/style.js +1 -1
- package/components/navigation-rail/navigation-rail-item-style.js +1 -1
- package/components/navigation-rail/navigation-rail-item.d.ts +13 -5
- package/components/navigation-rail/navigation-rail-item.js +22 -9
- package/components/navigation-rail/navigation-rail.d.ts +8 -6
- package/components/navigation-rail/navigation-rail.js +55 -46
- package/components/radio/radio-group.d.ts +13 -6
- package/components/radio/radio-group.js +69 -59
- package/components/radio/radio-style.js +1 -1
- package/components/radio/radio.d.ts +11 -5
- package/components/radio/radio.js +26 -19
- package/components/range-slider/index.d.ts +9 -3
- package/components/range-slider/index.js +13 -11
- package/components/ripple/index.d.ts +4 -2
- package/components/ripple/index.js +4 -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 +12 -5
- package/components/segmented-button/segmented-button-group.js +92 -77
- package/components/segmented-button/segmented-button.d.ts +8 -3
- package/components/segmented-button/segmented-button.js +5 -4
- package/components/select/index.d.ts +13 -5
- package/components/select/index.js +30 -28
- package/components/slider/index.d.ts +8 -1
- package/components/slider/index.js +11 -18
- package/components/slider/slider-base-style.js +1 -1
- package/components/slider/slider-base.d.ts +7 -3
- package/components/slider/slider-base.js +28 -13
- package/components/snackbar/index.d.ts +9 -2
- package/components/snackbar/index.js +11 -10
- package/components/switch/index.d.ts +10 -3
- package/components/switch/index.js +12 -15
- package/components/switch/style.js +1 -1
- package/components/tabs/tab-panel.d.ts +4 -2
- package/components/tabs/tab-panel.js +4 -2
- package/components/tabs/tab-style.js +1 -1
- package/components/tabs/tab.d.ts +7 -3
- package/components/tabs/tab.js +12 -6
- package/components/tabs/tabs-style.js +1 -1
- package/components/tabs/tabs.d.ts +11 -7
- package/components/tabs/tabs.js +57 -40
- package/components/text-field/index.d.ts +13 -5
- package/components/text-field/index.js +43 -65
- package/components/text-field/style.js +1 -1
- package/components/tooltip/index.d.ts +14 -7
- package/components/tooltip/index.js +45 -38
- package/components/top-app-bar/top-app-bar-title-style.js +1 -1
- package/components/top-app-bar/top-app-bar-title.d.ts +4 -2
- package/components/top-app-bar/top-app-bar-title.js +18 -13
- package/components/top-app-bar/top-app-bar.d.ts +9 -3
- package/components/top-app-bar/top-app-bar.js +11 -10
- package/custom-elements.json +904 -546
- package/functions/getTheme.js +3 -3
- package/functions/snackbar.js +1 -2
- package/functions/utils/colorScheme.js +2 -2
- package/mdui.esm.js +8 -8
- package/mdui.global.js +8 -8
- package/package.json +8 -7
- package/web-types.zh-cn.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
3
3
|
/**
|
|
4
4
|
* @summary 列表标题组件。需与 `<mdui-list>` 组件配合使用
|
|
@@ -13,10 +13,12 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
13
13
|
*
|
|
14
14
|
* @slot - 文本
|
|
15
15
|
*/
|
|
16
|
-
export declare class ListSubheader extends
|
|
16
|
+
export declare class ListSubheader extends MduiElement<ListSubheaderEventMap> {
|
|
17
17
|
static styles: CSSResultGroup;
|
|
18
18
|
protected render(): TemplateResult;
|
|
19
19
|
}
|
|
20
|
+
export interface ListSubheaderEventMap {
|
|
21
|
+
}
|
|
20
22
|
declare global {
|
|
21
23
|
interface HTMLElementTagNameMap {
|
|
22
24
|
'mdui-list-subheader': ListSubheader;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement } from 'lit/decorators.js';
|
|
4
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
4
5
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
5
6
|
import { listSubheaderStyle } from './list-subheader-style.js';
|
|
6
7
|
/**
|
|
@@ -16,7 +17,7 @@ import { listSubheaderStyle } from './list-subheader-style.js';
|
|
|
16
17
|
*
|
|
17
18
|
* @slot - 文本
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
let ListSubheader = class ListSubheader extends MduiElement {
|
|
20
21
|
render() {
|
|
21
22
|
return html `<slot></slot>`;
|
|
22
23
|
}
|
|
@@ -28,3 +29,4 @@ ListSubheader.styles = [
|
|
|
28
29
|
ListSubheader = __decorate([
|
|
29
30
|
customElement('mdui-list-subheader')
|
|
30
31
|
], ListSubheader);
|
|
32
|
+
export { ListSubheader };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
3
3
|
/**
|
|
4
4
|
* @summary 列表组件。需与 `<mdui-list-item>` 组件配合使用
|
|
@@ -13,10 +13,12 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
13
13
|
*
|
|
14
14
|
* @slot - `<mdui-list-item>` 元素
|
|
15
15
|
*/
|
|
16
|
-
export declare class List extends
|
|
16
|
+
export declare class List extends MduiElement<ListEventMap> {
|
|
17
17
|
static styles: CSSResultGroup;
|
|
18
18
|
protected render(): TemplateResult;
|
|
19
19
|
}
|
|
20
|
+
export interface ListEventMap {
|
|
21
|
+
}
|
|
20
22
|
declare global {
|
|
21
23
|
interface HTMLElementTagNameMap {
|
|
22
24
|
'mdui-list': List;
|
package/components/list/list.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement } from 'lit/decorators.js';
|
|
4
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
4
5
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
5
6
|
import { listStyle } from './list-style.js';
|
|
6
7
|
/**
|
|
@@ -16,7 +17,7 @@ import { listStyle } from './list-style.js';
|
|
|
16
17
|
*
|
|
17
18
|
* @slot - `<mdui-list-item>` 元素
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
let List = class List extends MduiElement {
|
|
20
21
|
render() {
|
|
21
22
|
return html `<slot></slot>`;
|
|
22
23
|
}
|
|
@@ -25,3 +26,4 @@ List.styles = [componentStyle, listStyle];
|
|
|
25
26
|
List = __decorate([
|
|
26
27
|
customElement('mdui-list')
|
|
27
28
|
], List);
|
|
29
|
+
export { List };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
1
|
import '@mdui/jq/methods/css.js';
|
|
3
2
|
import '@mdui/jq/methods/height.js';
|
|
4
3
|
import '@mdui/jq/methods/innerHeight.js';
|
|
5
4
|
import '@mdui/jq/methods/innerWidth.js';
|
|
6
5
|
import '@mdui/jq/methods/width.js';
|
|
7
6
|
import '@mdui/jq/static/contains.js';
|
|
7
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
8
8
|
import '@mdui/shared/icons/arrow-right.js';
|
|
9
9
|
import '@mdui/shared/icons/check.js';
|
|
10
10
|
import '../icon.js';
|
|
11
11
|
import type { Ripple } from '../ripple/index.js';
|
|
12
12
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
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
|
|
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
15
|
* @summary 菜单项组件
|
|
16
16
|
*
|
|
@@ -44,7 +44,7 @@ declare const MenuItem_base: import("@open-wc/dedupe-mixin").Constructor<import(
|
|
|
44
44
|
* @csspart selected-icon - 选中状态的图标
|
|
45
45
|
* @csspart submenu - 子菜单元素
|
|
46
46
|
*/
|
|
47
|
-
export declare class MenuItem extends MenuItem_base {
|
|
47
|
+
export declare class MenuItem extends MenuItem_base<MenuItemEventMap> {
|
|
48
48
|
static styles: CSSResultGroup;
|
|
49
49
|
/**
|
|
50
50
|
* 该菜单项的值
|
|
@@ -90,6 +90,7 @@ export declare class MenuItem extends MenuItem_base {
|
|
|
90
90
|
private readonly containerRef;
|
|
91
91
|
private readonly submenuRef;
|
|
92
92
|
private readonly hasSlotController;
|
|
93
|
+
private readonly definedController;
|
|
93
94
|
constructor();
|
|
94
95
|
protected get focusDisabled(): boolean;
|
|
95
96
|
protected get focusElement(): HTMLElement;
|
|
@@ -115,6 +116,14 @@ export declare class MenuItem extends MenuItem_base {
|
|
|
115
116
|
private updateSubmenuPositioner;
|
|
116
117
|
private renderInner;
|
|
117
118
|
}
|
|
119
|
+
export interface MenuItemEventMap {
|
|
120
|
+
focus: FocusEvent;
|
|
121
|
+
blur: FocusEvent;
|
|
122
|
+
'submenu-open': CustomEvent<void>;
|
|
123
|
+
'submenu-opened': CustomEvent<void>;
|
|
124
|
+
'submenu-close': CustomEvent<void>;
|
|
125
|
+
'submenu-closed': CustomEvent<void>;
|
|
126
|
+
}
|
|
118
127
|
declare global {
|
|
119
128
|
interface HTMLElementTagNameMap {
|
|
120
129
|
'mdui-menu-item': MenuItem;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
4
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
5
5
|
import { when } from 'lit/directives/when.js';
|
|
@@ -12,11 +12,12 @@ import '@mdui/jq/methods/innerWidth.js';
|
|
|
12
12
|
import '@mdui/jq/methods/width.js';
|
|
13
13
|
import { isUndefined } from '@mdui/jq/shared/helper.js';
|
|
14
14
|
import '@mdui/jq/static/contains.js';
|
|
15
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
16
|
+
import { DefinedController } from '@mdui/shared/controllers/defined.js';
|
|
15
17
|
import { HasSlotController } from '@mdui/shared/controllers/has-slot.js';
|
|
16
18
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
17
19
|
import { animateTo, stopAnimations } from '@mdui/shared/helpers/animate.js';
|
|
18
20
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
19
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
20
21
|
import { getDuration, getEasing } from '@mdui/shared/helpers/motion.js';
|
|
21
22
|
import { nothingTemplate } from '@mdui/shared/helpers/template.js';
|
|
22
23
|
import { uniqueId } from '@mdui/shared/helpers/uniqueId.js';
|
|
@@ -61,7 +62,7 @@ import { menuItemStyle } from './menu-item-style.js';
|
|
|
61
62
|
* @csspart selected-icon - 选中状态的图标
|
|
62
63
|
* @csspart submenu - 子菜单元素
|
|
63
64
|
*/
|
|
64
|
-
|
|
65
|
+
let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMixin(MduiElement))) {
|
|
65
66
|
constructor() {
|
|
66
67
|
super();
|
|
67
68
|
/**
|
|
@@ -72,11 +73,11 @@ export let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMi
|
|
|
72
73
|
* 是否打开子菜单
|
|
73
74
|
*/
|
|
74
75
|
this.submenuOpen = false;
|
|
75
|
-
//
|
|
76
|
+
// 是否已选中该菜单项。由 <mdui-menu> 控制该参数
|
|
76
77
|
this.selected = false;
|
|
77
|
-
//
|
|
78
|
+
// 是否使用更紧凑的布局。由 <mdui-menu> 控制该参数
|
|
78
79
|
this.dense = false;
|
|
79
|
-
// 是否可聚焦。由 mdui-menu 控制该参数
|
|
80
|
+
// 是否可聚焦。由 <mdui-menu> 控制该参数
|
|
80
81
|
this.focusable = false;
|
|
81
82
|
// 每一个 menu-item 元素都添加一个唯一的 key
|
|
82
83
|
this.key = uniqueId();
|
|
@@ -84,6 +85,9 @@ export let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMi
|
|
|
84
85
|
this.containerRef = createRef();
|
|
85
86
|
this.submenuRef = createRef();
|
|
86
87
|
this.hasSlotController = new HasSlotController(this, '[default]', 'icon', 'end-icon', 'end-text', 'submenu', 'custom');
|
|
88
|
+
this.definedController = new DefinedController(this, {
|
|
89
|
+
relatedElements: [''],
|
|
90
|
+
});
|
|
87
91
|
this.onOuterClick = this.onOuterClick.bind(this);
|
|
88
92
|
this.onFocus = this.onFocus.bind(this);
|
|
89
93
|
this.onBlur = this.onBlur.bind(this);
|
|
@@ -96,7 +100,7 @@ export let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMi
|
|
|
96
100
|
return this.disabled || !this.focusable;
|
|
97
101
|
}
|
|
98
102
|
get focusElement() {
|
|
99
|
-
return this.href ? this.containerRef.value : this;
|
|
103
|
+
return this.href && !this.disabled ? this.containerRef.value : this;
|
|
100
104
|
}
|
|
101
105
|
get rippleDisabled() {
|
|
102
106
|
return this.disabled;
|
|
@@ -109,20 +113,23 @@ export let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMi
|
|
|
109
113
|
}
|
|
110
114
|
async onOpenChange() {
|
|
111
115
|
const hasUpdated = this.hasUpdated;
|
|
116
|
+
// 默认为关闭状态。因此首次渲染时,且为关闭状态,不执行
|
|
117
|
+
if (!this.submenuOpen && !hasUpdated) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
await this.definedController.whenDefined();
|
|
121
|
+
if (!hasUpdated) {
|
|
122
|
+
await this.updateComplete;
|
|
123
|
+
}
|
|
112
124
|
const easingLinear = getEasing(this, 'linear');
|
|
113
125
|
const easingEmphasizedDecelerate = getEasing(this, 'emphasized-decelerate');
|
|
114
126
|
const easingEmphasizedAccelerate = getEasing(this, 'emphasized-accelerate');
|
|
115
127
|
// 打开
|
|
116
128
|
// 要区分是否首次渲染,首次渲染时不触发事件,不执行动画;非首次渲染,触发事件,执行动画
|
|
117
129
|
if (this.submenuOpen) {
|
|
118
|
-
if (!hasUpdated) {
|
|
119
|
-
await this.updateComplete;
|
|
120
|
-
}
|
|
121
130
|
if (hasUpdated) {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
});
|
|
125
|
-
if (requestOpen.defaultPrevented) {
|
|
131
|
+
const eventProceeded = this.emit('submenu-open', { cancelable: true });
|
|
132
|
+
if (!eventProceeded) {
|
|
126
133
|
return;
|
|
127
134
|
}
|
|
128
135
|
}
|
|
@@ -141,16 +148,12 @@ export let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMi
|
|
|
141
148
|
}),
|
|
142
149
|
]);
|
|
143
150
|
if (hasUpdated) {
|
|
144
|
-
emit(
|
|
151
|
+
this.emit('submenu-opened');
|
|
145
152
|
}
|
|
146
|
-
return;
|
|
147
153
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
cancelable: true,
|
|
152
|
-
});
|
|
153
|
-
if (requestClose.defaultPrevented) {
|
|
154
|
+
else {
|
|
155
|
+
const eventProceeded = this.emit('submenu-close', { cancelable: true });
|
|
156
|
+
if (!eventProceeded) {
|
|
154
157
|
return;
|
|
155
158
|
}
|
|
156
159
|
const duration = getDuration(this, 'short4');
|
|
@@ -159,13 +162,17 @@ export let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMi
|
|
|
159
162
|
animateTo(this.submenuRef.value, [{ transform: 'scaleY(1)' }, { transform: 'scaleY(0.45)' }], { duration, easing: easingEmphasizedAccelerate }),
|
|
160
163
|
animateTo(this.submenuRef.value, [{ opacity: 1 }, { opacity: 1, offset: 0.875 }, { opacity: 0 }], { duration, easing: easingLinear }),
|
|
161
164
|
]);
|
|
162
|
-
this.submenuRef.value
|
|
163
|
-
|
|
165
|
+
if (this.submenuRef.value) {
|
|
166
|
+
this.submenuRef.value.hidden = true;
|
|
167
|
+
}
|
|
168
|
+
this.emit('submenu-closed');
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
171
|
connectedCallback() {
|
|
167
172
|
super.connectedCallback();
|
|
168
|
-
|
|
173
|
+
this.definedController.whenDefined().then(() => {
|
|
174
|
+
document.addEventListener('pointerdown', this.onOuterClick);
|
|
175
|
+
});
|
|
169
176
|
}
|
|
170
177
|
disconnectedCallback() {
|
|
171
178
|
super.disconnectedCallback();
|
|
@@ -173,12 +180,14 @@ export let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMi
|
|
|
173
180
|
}
|
|
174
181
|
firstUpdated(changedProperties) {
|
|
175
182
|
super.firstUpdated(changedProperties);
|
|
176
|
-
this.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
183
|
+
this.definedController.whenDefined().then(() => {
|
|
184
|
+
this.addEventListener('focus', this.onFocus);
|
|
185
|
+
this.addEventListener('blur', this.onBlur);
|
|
186
|
+
this.addEventListener('click', this.onClick);
|
|
187
|
+
this.addEventListener('keydown', this.onKeydown);
|
|
188
|
+
this.addEventListener('mouseenter', this.onMouseEnter);
|
|
189
|
+
this.addEventListener('mouseleave', this.onMouseLeave);
|
|
190
|
+
});
|
|
182
191
|
}
|
|
183
192
|
render() {
|
|
184
193
|
const hasSubmenu = this.hasSubmenu;
|
|
@@ -205,6 +214,7 @@ export let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMi
|
|
|
205
214
|
className,
|
|
206
215
|
content: this.renderInner(useDefaultEndIcon, hasIcon),
|
|
207
216
|
refDirective: ref(this.containerRef),
|
|
217
|
+
tabIndex: this.focusable ? 0 : -1,
|
|
208
218
|
})
|
|
209
219
|
: html `<div part="container" ${ref(this.containerRef)} class="${className}">${this.renderInner(useDefaultEndIcon, hasIcon)}</div>`} ${when(hasSubmenu, () => html `<slot name="submenu" ${ref(this.submenuRef)} part="submenu" class="submenu" hidden></slot>`)}`;
|
|
210
220
|
}
|
|
@@ -262,15 +272,16 @@ export let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMi
|
|
|
262
272
|
}
|
|
263
273
|
onKeydown(event) {
|
|
264
274
|
// 切换子菜单打开状态
|
|
265
|
-
if (
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
275
|
+
if (this.disabled || !this.hasSubmenu) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (!this.submenuOpen && event.key === 'Enter') {
|
|
279
|
+
event.stopPropagation();
|
|
280
|
+
this.submenuOpen = true;
|
|
281
|
+
}
|
|
282
|
+
if (this.submenuOpen && event.key === 'Escape') {
|
|
283
|
+
event.stopPropagation();
|
|
284
|
+
this.submenuOpen = false;
|
|
274
285
|
}
|
|
275
286
|
}
|
|
276
287
|
onMouseEnter() {
|
|
@@ -298,6 +309,7 @@ export let MenuItem = class MenuItem extends AnchorMixin(RippleMixin(FocusableMi
|
|
|
298
309
|
this.submenuOpen = false;
|
|
299
310
|
}, this.submenuCloseDelay || 50);
|
|
300
311
|
}
|
|
312
|
+
// 更新子菜单的位置
|
|
301
313
|
updateSubmenuPositioner() {
|
|
302
314
|
const $window = $(window);
|
|
303
315
|
const $submenu = $(this.submenuRef.value);
|
|
@@ -410,3 +422,4 @@ __decorate([
|
|
|
410
422
|
MenuItem = __decorate([
|
|
411
423
|
customElement('mdui-menu-item')
|
|
412
424
|
], MenuItem);
|
|
425
|
+
export { MenuItem };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
1
|
import '@mdui/jq/methods/add.js';
|
|
3
2
|
import '@mdui/jq/methods/children.js';
|
|
4
3
|
import '@mdui/jq/methods/find.js';
|
|
@@ -6,6 +5,7 @@ import '@mdui/jq/methods/get.js';
|
|
|
6
5
|
import '@mdui/jq/methods/is.js';
|
|
7
6
|
import '@mdui/jq/methods/parent.js';
|
|
8
7
|
import '@mdui/jq/methods/parents.js';
|
|
8
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
9
9
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
10
10
|
/**
|
|
11
11
|
* 键盘快捷键:
|
|
@@ -30,7 +30,7 @@ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
|
30
30
|
*
|
|
31
31
|
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
32
32
|
*/
|
|
33
|
-
export declare class Menu extends
|
|
33
|
+
export declare class Menu extends MduiElement<MenuEventMap> {
|
|
34
34
|
static styles: CSSResultGroup;
|
|
35
35
|
/**
|
|
36
36
|
* 菜单项的可选中状态。默认为不可选中。可选值为:
|
|
@@ -71,8 +71,9 @@ export declare class Menu extends LitElement {
|
|
|
71
71
|
submenuCloseDelay: number;
|
|
72
72
|
private selectedKeys;
|
|
73
73
|
private readonly childrenItems;
|
|
74
|
-
private
|
|
74
|
+
private isInitial;
|
|
75
75
|
private lastActiveItems;
|
|
76
|
+
private readonly definedController;
|
|
76
77
|
private get items();
|
|
77
78
|
private get itemsEnabled();
|
|
78
79
|
private get isSingle();
|
|
@@ -95,6 +96,8 @@ export declare class Menu extends LitElement {
|
|
|
95
96
|
blur(): void;
|
|
96
97
|
protected firstUpdated(changedProperties: PropertyValues): void;
|
|
97
98
|
protected render(): TemplateResult;
|
|
99
|
+
private setSelectedKeys;
|
|
100
|
+
private setValue;
|
|
98
101
|
private getSiblingsItems;
|
|
99
102
|
private updateFocusable;
|
|
100
103
|
private updateSelected;
|
|
@@ -104,6 +107,9 @@ export declare class Menu extends LitElement {
|
|
|
104
107
|
private onClick;
|
|
105
108
|
private onKeyDown;
|
|
106
109
|
}
|
|
110
|
+
export interface MenuEventMap {
|
|
111
|
+
change: CustomEvent<void>;
|
|
112
|
+
}
|
|
107
113
|
declare global {
|
|
108
114
|
interface HTMLElementTagNameMap {
|
|
109
115
|
'mdui-menu': Menu;
|