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
|
@@ -1,16 +1,16 @@
|
|
|
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 { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
6
|
import { live } from 'lit/directives/live.js';
|
|
7
7
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
8
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
8
9
|
import { FormController, formResets } from '@mdui/shared/controllers/form.js';
|
|
9
10
|
import { HasSlotController } from '@mdui/shared/controllers/has-slot.js';
|
|
10
11
|
import { defaultValue } from '@mdui/shared/decorators/default-value.js';
|
|
11
12
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
12
13
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
13
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
14
14
|
import { nothingTemplate } from '@mdui/shared/helpers/template.js';
|
|
15
15
|
import '@mdui/shared/icons/check.js';
|
|
16
16
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
@@ -39,10 +39,10 @@ import { style } from './style.js';
|
|
|
39
39
|
* @csspart unchecked-icon - 未选中状态的图标
|
|
40
40
|
* @csspart checked-icon 选中状态的图标
|
|
41
41
|
*
|
|
42
|
-
* @cssprop --shape-corner -
|
|
43
|
-
* @cssprop --shape-corner-thumb -
|
|
42
|
+
* @cssprop --shape-corner - 组件轨道的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
43
|
+
* @cssprop --shape-corner-thumb - 组件图标容器的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
44
44
|
*/
|
|
45
|
-
let Switch = class Switch extends RippleMixin(FocusableMixin(
|
|
45
|
+
let Switch = class Switch extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
46
46
|
constructor() {
|
|
47
47
|
super(...arguments);
|
|
48
48
|
/**
|
|
@@ -54,11 +54,11 @@ let Switch = class Switch extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
54
54
|
*/
|
|
55
55
|
this.checked = false;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* 默认选中状态。在重置表单时,将重置为此状态。此属性只能通过 JavaScript 属性设置
|
|
58
58
|
*/
|
|
59
59
|
this.defaultChecked = false;
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* 提交表单时,是否必须选中此开关
|
|
62
62
|
*/
|
|
63
63
|
this.required = false;
|
|
64
64
|
/**
|
|
@@ -83,13 +83,13 @@ let Switch = class Switch extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
83
83
|
this.hasSlotController = new HasSlotController(this, 'unchecked-icon');
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
86
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
87
87
|
*/
|
|
88
88
|
get validity() {
|
|
89
89
|
return this.inputRef.value.validity;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
93
93
|
*/
|
|
94
94
|
get validationMessage() {
|
|
95
95
|
return this.inputRef.value.validationMessage;
|
|
@@ -123,12 +123,12 @@ let Switch = class Switch extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
|
-
*
|
|
126
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
127
127
|
*/
|
|
128
128
|
checkValidity() {
|
|
129
129
|
const valid = this.inputRef.value.checkValidity();
|
|
130
130
|
if (!valid) {
|
|
131
|
-
emit(
|
|
131
|
+
this.emit('invalid', {
|
|
132
132
|
bubbles: false,
|
|
133
133
|
cancelable: true,
|
|
134
134
|
composed: false,
|
|
@@ -137,20 +137,20 @@ let Switch = class Switch extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
137
137
|
return valid;
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
|
-
*
|
|
140
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
141
141
|
*
|
|
142
|
-
*
|
|
142
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
143
143
|
*/
|
|
144
144
|
reportValidity() {
|
|
145
145
|
this.invalid = !this.inputRef.value.reportValidity();
|
|
146
146
|
if (this.invalid) {
|
|
147
|
-
const
|
|
147
|
+
const eventProceeded = this.emit('invalid', {
|
|
148
148
|
bubbles: false,
|
|
149
149
|
cancelable: true,
|
|
150
150
|
composed: false,
|
|
151
151
|
});
|
|
152
152
|
// 调用了 preventDefault() 时,隐藏默认的表单错误提示
|
|
153
|
-
if (
|
|
153
|
+
if (!eventProceeded) {
|
|
154
154
|
this.blur();
|
|
155
155
|
this.focus();
|
|
156
156
|
}
|
|
@@ -158,9 +158,9 @@ let Switch = class Switch extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
158
158
|
return !this.invalid;
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
|
-
*
|
|
161
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
162
162
|
*
|
|
163
|
-
* @param message
|
|
163
|
+
* @param message 自定义的错误提示文本
|
|
164
164
|
*/
|
|
165
165
|
setCustomValidity(message) {
|
|
166
166
|
this.inputRef.value.setCustomValidity(message);
|
|
@@ -183,7 +183,7 @@ let Switch = class Switch extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
183
183
|
*/
|
|
184
184
|
onChange() {
|
|
185
185
|
this.checked = this.inputRef.value.checked;
|
|
186
|
-
emit(
|
|
186
|
+
this.emit('change');
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
189
|
Switch.styles = [componentStyle, style];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
3
3
|
/**
|
|
4
|
-
* @summary
|
|
4
|
+
* @summary 选项卡面板项组件。需配合 `<mdui-tabs>` 和 `<mdui-tab>` 组件使用
|
|
5
5
|
*
|
|
6
6
|
* ```html
|
|
7
7
|
* <mdui-tabs value="tab-1">
|
|
@@ -15,12 +15,12 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
15
15
|
* </mdui-tabs>
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
|
-
* @slot -
|
|
18
|
+
* @slot - 选项卡面板项内容
|
|
19
19
|
*/
|
|
20
|
-
export declare class TabPanel extends
|
|
20
|
+
export declare class TabPanel extends MduiElement<TabPanelEventMap> {
|
|
21
21
|
static styles: CSSResultGroup;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* 选项卡面板项的值
|
|
24
24
|
*/
|
|
25
25
|
value?: string;
|
|
26
26
|
/**
|
|
@@ -29,6 +29,8 @@ export declare class TabPanel extends LitElement {
|
|
|
29
29
|
protected active: boolean;
|
|
30
30
|
protected render(): TemplateResult;
|
|
31
31
|
}
|
|
32
|
+
export interface TabPanelEventMap {
|
|
33
|
+
}
|
|
32
34
|
declare global {
|
|
33
35
|
interface HTMLElementTagNameMap {
|
|
34
36
|
'mdui-tab-panel': TabPanel;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
4
5
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
5
6
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
6
7
|
import { tabPanelStyle } from './tab-panel-style.js';
|
|
7
8
|
/**
|
|
8
|
-
* @summary
|
|
9
|
+
* @summary 选项卡面板项组件。需配合 `<mdui-tabs>` 和 `<mdui-tab>` 组件使用
|
|
9
10
|
*
|
|
10
11
|
* ```html
|
|
11
12
|
* <mdui-tabs value="tab-1">
|
|
@@ -19,9 +20,9 @@ import { tabPanelStyle } from './tab-panel-style.js';
|
|
|
19
20
|
* </mdui-tabs>
|
|
20
21
|
* ```
|
|
21
22
|
*
|
|
22
|
-
* @slot -
|
|
23
|
+
* @slot - 选项卡面板项内容
|
|
23
24
|
*/
|
|
24
|
-
let TabPanel = class TabPanel extends
|
|
25
|
+
let TabPanel = class TabPanel extends MduiElement {
|
|
25
26
|
constructor() {
|
|
26
27
|
super(...arguments);
|
|
27
28
|
/**
|
package/components/tabs/tab.d.ts
CHANGED
|
@@ -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 Tab_base: 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 Tab_base: 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-tabs>` 和 `<mdui-tab-panel>` 组件使用
|
|
8
8
|
*
|
|
9
9
|
* ```html
|
|
10
10
|
* <mdui-tabs value="tab-1">
|
|
@@ -21,19 +21,19 @@ declare const Tab_base: import("@open-wc/dedupe-mixin").Constructor<import("../r
|
|
|
21
21
|
* @event focus - 获得焦点时触发
|
|
22
22
|
* @event blur - 失去焦点时触发
|
|
23
23
|
*
|
|
24
|
-
* @slot -
|
|
24
|
+
* @slot - 选项卡导航项的文本内容
|
|
25
25
|
* @slot icon - 选项卡导航项中的图标
|
|
26
26
|
* @slot badge - 徽标
|
|
27
27
|
* @slot custom - 自定义整个选项卡导航项中的内容
|
|
28
28
|
*
|
|
29
|
-
* @csspart container -
|
|
30
|
-
* @csspart icon -
|
|
31
|
-
* @csspart label -
|
|
29
|
+
* @csspart container - 选项卡导航项容器
|
|
30
|
+
* @csspart icon - 选项卡导航项中的图标
|
|
31
|
+
* @csspart label - 选项卡导航项的文本
|
|
32
32
|
*/
|
|
33
|
-
export declare class Tab extends Tab_base {
|
|
33
|
+
export declare class Tab extends Tab_base<TabEventMap> {
|
|
34
34
|
static styles: CSSResultGroup;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* 选项卡导航项的值
|
|
37
37
|
*/
|
|
38
38
|
value?: string;
|
|
39
39
|
/**
|
|
@@ -61,6 +61,10 @@ export declare class Tab extends Tab_base {
|
|
|
61
61
|
protected get focusDisabled(): boolean;
|
|
62
62
|
protected render(): TemplateResult;
|
|
63
63
|
}
|
|
64
|
+
export interface TabEventMap {
|
|
65
|
+
focus: FocusEvent;
|
|
66
|
+
blur: FocusEvent;
|
|
67
|
+
}
|
|
64
68
|
declare global {
|
|
65
69
|
interface HTMLElementTagNameMap {
|
|
66
70
|
'mdui-tab': Tab;
|
package/components/tabs/tab.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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 { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
6
6
|
import { when } from 'lit/directives/when.js';
|
|
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';
|
|
@@ -14,7 +15,7 @@ import '../icon.js';
|
|
|
14
15
|
import { RippleMixin } from '../ripple/ripple-mixin.js';
|
|
15
16
|
import { tabStyle } from './tab-style.js';
|
|
16
17
|
/**
|
|
17
|
-
* @summary
|
|
18
|
+
* @summary 选项卡导航项组件。需配合 `<mdui-tabs>` 和 `<mdui-tab-panel>` 组件使用
|
|
18
19
|
*
|
|
19
20
|
* ```html
|
|
20
21
|
* <mdui-tabs value="tab-1">
|
|
@@ -31,16 +32,16 @@ import { tabStyle } from './tab-style.js';
|
|
|
31
32
|
* @event focus - 获得焦点时触发
|
|
32
33
|
* @event blur - 失去焦点时触发
|
|
33
34
|
*
|
|
34
|
-
* @slot -
|
|
35
|
+
* @slot - 选项卡导航项的文本内容
|
|
35
36
|
* @slot icon - 选项卡导航项中的图标
|
|
36
37
|
* @slot badge - 徽标
|
|
37
38
|
* @slot custom - 自定义整个选项卡导航项中的内容
|
|
38
39
|
*
|
|
39
|
-
* @csspart container -
|
|
40
|
-
* @csspart icon -
|
|
41
|
-
* @csspart label -
|
|
40
|
+
* @csspart container - 选项卡导航项容器
|
|
41
|
+
* @csspart icon - 选项卡导航项中的图标
|
|
42
|
+
* @csspart label - 选项卡导航项的文本
|
|
42
43
|
*/
|
|
43
|
-
let Tab = class Tab extends RippleMixin(FocusableMixin(
|
|
44
|
+
let Tab = class Tab extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
44
45
|
constructor() {
|
|
45
46
|
super(...arguments);
|
|
46
47
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
1
|
import '@mdui/jq/methods/children.js';
|
|
3
2
|
import '@mdui/jq/methods/css.js';
|
|
4
3
|
import '@mdui/jq/methods/find.js';
|
|
5
4
|
import '@mdui/jq/methods/get.js';
|
|
5
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
6
6
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
7
7
|
/**
|
|
8
|
-
* @summary
|
|
8
|
+
* @summary 选项卡组件。需配合 `<mdui-tab>` 和 `<mdui-tab-panel>` 组件使用
|
|
9
9
|
*
|
|
10
10
|
* ```html
|
|
11
11
|
* <mdui-tabs value="tab-1">
|
|
@@ -27,36 +27,36 @@ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
|
27
27
|
* @csspart container - `<mdui-tab>` 元素的容器
|
|
28
28
|
* @csspart indicator - 激活状态指示器
|
|
29
29
|
*/
|
|
30
|
-
export declare class Tabs extends
|
|
30
|
+
export declare class Tabs extends MduiElement<TabsEventMap> {
|
|
31
31
|
static styles: CSSResultGroup;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* 选项卡形状。可选值包括:
|
|
34
34
|
*
|
|
35
|
-
* * `primary
|
|
36
|
-
* * `secondary
|
|
35
|
+
* * `primary`:适用于位于 `<mdui-top-app-bar>` 下方,用于切换应用的主页面的场景
|
|
36
|
+
* * `secondary`:适用于位于页面中,用于切换一组相关内容的场景
|
|
37
37
|
*/
|
|
38
|
-
variant:
|
|
38
|
+
variant: /*适用于位于 `<mdui-top-app-bar>` 下方,用于切换应用的主页面的场景*/ 'primary' | /*适用于位于页面中,用于切换一组相关内容的场景*/ 'secondary';
|
|
39
39
|
/**
|
|
40
40
|
* 当前激活的 `<mdui-tab>` 的值
|
|
41
41
|
*/
|
|
42
42
|
value?: string;
|
|
43
43
|
/**
|
|
44
|
-
* 选项卡位置。默认为 `top-start
|
|
44
|
+
* 选项卡位置。默认为 `top-start`。可选值包括:
|
|
45
45
|
*
|
|
46
|
-
* * `top-start
|
|
47
|
-
* * `top
|
|
48
|
-
* * `top-end
|
|
49
|
-
* * `bottom-start
|
|
50
|
-
* * `bottom
|
|
51
|
-
* * `bottom-end
|
|
52
|
-
* * `left-start
|
|
53
|
-
* * `left
|
|
54
|
-
* * `left-end
|
|
55
|
-
* * `right-start
|
|
56
|
-
* * `right
|
|
57
|
-
* * `right-end
|
|
46
|
+
* * `top-start`:位于上方,左对齐
|
|
47
|
+
* * `top`:位于上方,居中对齐
|
|
48
|
+
* * `top-end`:位于上方,右对齐
|
|
49
|
+
* * `bottom-start`:位于下方,左对齐
|
|
50
|
+
* * `bottom`:位于下方,居中对齐
|
|
51
|
+
* * `bottom-end`:位于下方,右对齐
|
|
52
|
+
* * `left-start`:位于左侧,顶部对齐
|
|
53
|
+
* * `left`:位于左侧,居中对齐
|
|
54
|
+
* * `left-end`:位于左侧,底部对齐
|
|
55
|
+
* * `right-start`:位于右侧,顶部对齐
|
|
56
|
+
* * `right`:位于右侧,居中对齐
|
|
57
|
+
* * `right-end`:位于右侧,底部对齐
|
|
58
58
|
*/
|
|
59
|
-
placement:
|
|
59
|
+
placement: /*位于上方,左对齐*/ 'top-start' | /*位于上方,居中对齐*/ 'top' | /*位于上方,右对齐*/ 'top-end' | /*位于下方,左对齐*/ 'bottom-start' | /*位于下方,居中对齐*/ 'bottom' | /*位于下方,右对齐*/ 'bottom-end' | /*位于左侧,顶部对齐*/ 'left-start' | /*位于左侧,居中对齐*/ 'left' | /*位于左侧,底部对齐*/ 'left-end' | /*位于右侧,顶部对齐*/ 'right-start' | /*位于右侧,居中对齐*/ 'right' | /*位于右侧,底部对齐*/ 'right-end';
|
|
60
60
|
/**
|
|
61
61
|
* 是否填满父元素宽度
|
|
62
62
|
*/
|
|
@@ -81,6 +81,9 @@ export declare class Tabs extends LitElement {
|
|
|
81
81
|
private updateActive;
|
|
82
82
|
private updateIndicator;
|
|
83
83
|
}
|
|
84
|
+
export interface TabsEventMap {
|
|
85
|
+
change: CustomEvent<void>;
|
|
86
|
+
}
|
|
84
87
|
declare global {
|
|
85
88
|
interface HTMLElementTagNameMap {
|
|
86
89
|
'mdui-tabs': Tabs;
|
package/components/tabs/tabs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property, queryAssignedElements, 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';
|
|
@@ -8,15 +8,15 @@ import '@mdui/jq/methods/children.js';
|
|
|
8
8
|
import '@mdui/jq/methods/css.js';
|
|
9
9
|
import '@mdui/jq/methods/find.js';
|
|
10
10
|
import '@mdui/jq/methods/get.js';
|
|
11
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
11
12
|
import { DefinedController } from '@mdui/shared/controllers/defined.js';
|
|
12
13
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
13
14
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
14
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
15
15
|
import { observeResize } from '@mdui/shared/helpers/observeResize.js';
|
|
16
16
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
17
17
|
import { tabsStyle } from './tabs-style.js';
|
|
18
18
|
/**
|
|
19
|
-
* @summary
|
|
19
|
+
* @summary 选项卡组件。需配合 `<mdui-tab>` 和 `<mdui-tab-panel>` 组件使用
|
|
20
20
|
*
|
|
21
21
|
* ```html
|
|
22
22
|
* <mdui-tabs value="tab-1">
|
|
@@ -38,31 +38,31 @@ import { tabsStyle } from './tabs-style.js';
|
|
|
38
38
|
* @csspart container - `<mdui-tab>` 元素的容器
|
|
39
39
|
* @csspart indicator - 激活状态指示器
|
|
40
40
|
*/
|
|
41
|
-
let Tabs = class Tabs extends
|
|
41
|
+
let Tabs = class Tabs extends MduiElement {
|
|
42
42
|
constructor() {
|
|
43
43
|
super(...arguments);
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* 选项卡形状。可选值包括:
|
|
46
46
|
*
|
|
47
|
-
* * `primary
|
|
48
|
-
* * `secondary
|
|
47
|
+
* * `primary`:适用于位于 `<mdui-top-app-bar>` 下方,用于切换应用的主页面的场景
|
|
48
|
+
* * `secondary`:适用于位于页面中,用于切换一组相关内容的场景
|
|
49
49
|
*/
|
|
50
50
|
this.variant = 'primary';
|
|
51
51
|
/**
|
|
52
|
-
* 选项卡位置。默认为 `top-start
|
|
52
|
+
* 选项卡位置。默认为 `top-start`。可选值包括:
|
|
53
53
|
*
|
|
54
|
-
* * `top-start
|
|
55
|
-
* * `top
|
|
56
|
-
* * `top-end
|
|
57
|
-
* * `bottom-start
|
|
58
|
-
* * `bottom
|
|
59
|
-
* * `bottom-end
|
|
60
|
-
* * `left-start
|
|
61
|
-
* * `left
|
|
62
|
-
* * `left-end
|
|
63
|
-
* * `right-start
|
|
64
|
-
* * `right
|
|
65
|
-
* * `right-end
|
|
54
|
+
* * `top-start`:位于上方,左对齐
|
|
55
|
+
* * `top`:位于上方,居中对齐
|
|
56
|
+
* * `top-end`:位于上方,右对齐
|
|
57
|
+
* * `bottom-start`:位于下方,左对齐
|
|
58
|
+
* * `bottom`:位于下方,居中对齐
|
|
59
|
+
* * `bottom-end`:位于下方,右对齐
|
|
60
|
+
* * `left-start`:位于左侧,顶部对齐
|
|
61
|
+
* * `left`:位于左侧,居中对齐
|
|
62
|
+
* * `left-end`:位于左侧,底部对齐
|
|
63
|
+
* * `right-start`:位于右侧,顶部对齐
|
|
64
|
+
* * `right`:位于右侧,居中对齐
|
|
65
|
+
* * `right-end`:位于右侧,底部对齐
|
|
66
66
|
*/
|
|
67
67
|
this.placement = 'top-start';
|
|
68
68
|
/**
|
|
@@ -85,7 +85,7 @@ let Tabs = class Tabs extends LitElement {
|
|
|
85
85
|
this.value = this.tabs.find((tab) => tab.key === this.activeKey)?.value;
|
|
86
86
|
this.updateActive();
|
|
87
87
|
if (!this.isInitial) {
|
|
88
|
-
emit(
|
|
88
|
+
this.emit('change');
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
async onValueChange() {
|
|
@@ -121,6 +121,9 @@ let Tabs = class Tabs extends LitElement {
|
|
|
121
121
|
await this.definedController.whenDefined();
|
|
122
122
|
const target = event.target;
|
|
123
123
|
const tab = target.closest('mdui-tab');
|
|
124
|
+
if (!tab) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
124
127
|
this.activeKey = tab.key;
|
|
125
128
|
this.isInitial = false;
|
|
126
129
|
this.updateActive();
|