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.
Files changed (118) hide show
  1. package/components/avatar/index.d.ts +17 -15
  2. package/components/avatar/index.js +7 -6
  3. package/components/badge/index.d.ts +11 -8
  4. package/components/badge/index.js +9 -7
  5. package/components/bottom-app-bar/index.d.ts +11 -4
  6. package/components/bottom-app-bar/index.js +8 -9
  7. package/components/button/button-base-style.js +1 -1
  8. package/components/button/button-base.d.ts +46 -47
  9. package/components/button/button-base.js +27 -25
  10. package/components/button/index.d.ts +19 -14
  11. package/components/button/index.js +12 -12
  12. package/components/button-icon/index.d.ts +15 -9
  13. package/components/button-icon/index.js +8 -9
  14. package/components/card/index.d.ts +15 -11
  15. package/components/card/index.js +10 -9
  16. package/components/checkbox/index.d.ts +30 -23
  17. package/components/checkbox/index.js +25 -25
  18. package/components/chip/index.d.ts +27 -20
  19. package/components/chip/index.js +19 -20
  20. package/components/circular-progress/index.d.ts +6 -4
  21. package/components/circular-progress/index.js +4 -3
  22. package/components/collapse/collapse-item.d.ts +17 -6
  23. package/components/collapse/collapse-item.js +7 -7
  24. package/components/collapse/collapse.d.ts +16 -11
  25. package/components/collapse/collapse.js +10 -10
  26. package/components/dialog/index.d.ts +22 -15
  27. package/components/dialog/index.js +23 -27
  28. package/components/divider/index.d.ts +7 -5
  29. package/components/divider/index.js +6 -5
  30. package/components/dropdown/index.d.ts +44 -37
  31. package/components/dropdown/index.js +50 -48
  32. package/components/fab/index.d.ts +12 -7
  33. package/components/fab/index.js +6 -6
  34. package/components/icon/index.d.ts +4 -2
  35. package/components/icon/index.js +3 -2
  36. package/components/layout/layout-item-base.d.ts +3 -2
  37. package/components/layout/layout-item-base.js +2 -2
  38. package/components/layout/layout-item.d.ts +11 -10
  39. package/components/layout/layout-item.js +6 -6
  40. package/components/layout/layout-main.d.ts +6 -4
  41. package/components/layout/layout-main.js +5 -4
  42. package/components/layout/layout.d.ts +6 -4
  43. package/components/layout/layout.js +5 -4
  44. package/components/linear-progress/index.d.ts +8 -6
  45. package/components/linear-progress/index.js +6 -5
  46. package/components/list/list-item-style.js +1 -1
  47. package/components/list/list-item.d.ts +24 -20
  48. package/components/list/list-item.js +10 -9
  49. package/components/list/list-subheader.d.ts +6 -4
  50. package/components/list/list-subheader.js +5 -4
  51. package/components/list/list.d.ts +5 -3
  52. package/components/list/list.js +4 -3
  53. package/components/menu/menu-item.d.ts +15 -7
  54. package/components/menu/menu-item.js +11 -15
  55. package/components/menu/menu.d.ts +20 -20
  56. package/components/menu/menu.js +13 -13
  57. package/components/navigation-bar/navigation-bar-item.d.ts +12 -8
  58. package/components/navigation-bar/navigation-bar-item.js +7 -6
  59. package/components/navigation-bar/navigation-bar.d.ts +17 -9
  60. package/components/navigation-bar/navigation-bar.js +15 -13
  61. package/components/navigation-drawer/index.d.ts +27 -21
  62. package/components/navigation-drawer/index.js +51 -38
  63. package/components/navigation-drawer/style.js +1 -1
  64. package/components/navigation-rail/navigation-rail-item.d.ts +13 -9
  65. package/components/navigation-rail/navigation-rail-item.js +7 -6
  66. package/components/navigation-rail/navigation-rail.d.ts +14 -12
  67. package/components/navigation-rail/navigation-rail.js +13 -12
  68. package/components/radio/radio-group.d.ts +20 -15
  69. package/components/radio/radio-group.js +21 -24
  70. package/components/radio/radio.d.ts +11 -6
  71. package/components/radio/radio.js +7 -7
  72. package/components/range-slider/index.d.ts +13 -8
  73. package/components/range-slider/index.js +10 -7
  74. package/components/ripple/index.d.ts +4 -2
  75. package/components/ripple/index.js +3 -2
  76. package/components/ripple/ripple-mixin.d.ts +1 -1
  77. package/components/ripple/ripple-mixin.js +0 -1
  78. package/components/segmented-button/segmented-button-group-style.js +1 -1
  79. package/components/segmented-button/segmented-button-group.d.ts +23 -22
  80. package/components/segmented-button/segmented-button-group.js +20 -23
  81. package/components/segmented-button/segmented-button.d.ts +9 -4
  82. package/components/segmented-button/segmented-button.js +3 -3
  83. package/components/select/index.d.ts +42 -35
  84. package/components/select/index.js +24 -25
  85. package/components/slider/index.d.ts +9 -2
  86. package/components/slider/index.js +5 -10
  87. package/components/slider/slider-base.d.ts +22 -18
  88. package/components/slider/slider-base.js +40 -21
  89. package/components/snackbar/index.d.ts +30 -23
  90. package/components/snackbar/index.js +25 -25
  91. package/components/switch/index.d.ts +24 -17
  92. package/components/switch/index.js +18 -18
  93. package/components/tabs/tab-panel.d.ts +7 -5
  94. package/components/tabs/tab-panel.js +5 -4
  95. package/components/tabs/tab.d.ts +13 -9
  96. package/components/tabs/tab.js +8 -7
  97. package/components/tabs/tabs.d.ts +24 -21
  98. package/components/tabs/tabs.js +24 -21
  99. package/components/text-field/index.d.ts +62 -54
  100. package/components/text-field/index.js +37 -37
  101. package/components/tooltip/index.d.ts +40 -33
  102. package/components/tooltip/index.js +45 -43
  103. package/components/top-app-bar/top-app-bar-title.d.ts +8 -6
  104. package/components/top-app-bar/top-app-bar-title.js +7 -6
  105. package/components/top-app-bar/top-app-bar.d.ts +12 -6
  106. package/components/top-app-bar/top-app-bar.js +9 -10
  107. package/css-data.en.json +2826 -0
  108. package/css-data.zh-cn.json +374 -367
  109. package/custom-elements.json +3844 -3824
  110. package/html-data.en.json +6551 -0
  111. package/html-data.zh-cn.json +1621 -1636
  112. package/jsx.en.d.ts +3303 -0
  113. package/jsx.zh-cn.d.ts +3351 -0
  114. package/mdui.esm.js +9 -9
  115. package/mdui.global.js +9 -9
  116. package/package.json +7 -5
  117. package/web-types.en.json +11718 -0
  118. package/web-types.zh-cn.json +3613 -3623
@@ -1,16 +1,16 @@
1
1
  import { __decorate } from "tslib";
2
- import { html, LitElement } from 'lit';
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 - 组件的轨道的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
43
- * @cssprop --shape-corner-thumb - 组件的图标容器的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
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(LitElement)) {
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
- * 默认选中状态。在重置表单时,将重置为该默认状态。该属性只能通过 JavaScript 属性设置
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
- * 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`
126
+ * 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
127
127
  */
128
128
  checkValidity() {
129
129
  const valid = this.inputRef.value.checkValidity();
130
130
  if (!valid) {
131
- emit(this, 'invalid', {
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
- * 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`。
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 requestInvalid = emit(this, 'invalid', {
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 (requestInvalid.defaultPrevented) {
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(this, 'change');
186
+ this.emit('change');
187
187
  }
188
188
  };
189
189
  Switch.styles = [componentStyle, style];
@@ -1,7 +1,7 @@
1
- import { LitElement } from 'lit';
1
+ import { MduiElement } from '@mdui/shared/base/mdui-element.js';
2
2
  import type { CSSResultGroup, TemplateResult } from 'lit';
3
3
  /**
4
- * @summary 选项卡面板项组件。需与 `<mdui-tabs>` 和 `<mdui-tab>` 组件配合使用
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 LitElement {
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, LitElement } from 'lit';
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 选项卡面板项组件。需与 `<mdui-tabs>` 和 `<mdui-tab>` 组件配合使用
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 LitElement {
25
+ let TabPanel = class TabPanel extends MduiElement {
25
26
  constructor() {
26
27
  super(...arguments);
27
28
  /**
@@ -1,10 +1,10 @@
1
- import { LitElement } from 'lit';
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 LitElement;
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 选项卡项组件。需与 `<mdui-tabs>` 和 `<mdui-tab-panel>` 组件配合使用
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;
@@ -1,9 +1,10 @@
1
1
  import { __decorate } from "tslib";
2
- import { html, LitElement } from 'lit';
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 选项卡项组件。需与 `<mdui-tabs>` 和 `<mdui-tab-panel>` 组件配合使用
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(LitElement)) {
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 选项卡组件。需与 `<mdui-tab>` 和 `<mdui-tab-panel>` 组件配合使用
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 LitElement {
30
+ export declare class Tabs extends MduiElement<TabsEventMap> {
31
31
  static styles: CSSResultGroup;
32
32
  /**
33
- * 选项卡形状。可选值为:
33
+ * 选项卡形状。可选值包括:
34
34
  *
35
- * * `primary`:位于 `<mdui-top-app-bar>` 下方,用于切换应用的主页面时,可使用该形状的选项卡
36
- * * `secondary`:位于页面中,用于切换一组相关内容时,可使用该形状的选项卡
35
+ * * `primary`:适用于位于 `<mdui-top-app-bar>` 下方,用于切换应用的主页面的场景
36
+ * * `secondary`:适用于位于页面中,用于切换一组相关内容的场景
37
37
  */
38
- variant: /*位于 `<mdui-top-app-bar>` 下方,用于切换应用的主页面时,可使用该形状的选项卡*/ 'primary' | /*位于页面中,用于切换一组相关内容时,可使用该形状的选项卡*/ 'secondary';
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: /*位于上方,且左对齐*/ 'top-start' | /*位于上方,且居中对齐*/ 'top' | /*位于上方,且右对齐*/ 'top-end' | /*位于下方,且左对齐*/ 'bottom-start' | /*位于下方,且居中对齐*/ 'bottom' | /*位于下方,且右对齐*/ 'bottom-end' | /*位于左侧,且顶部对齐*/ 'left-start' | /*位于左侧,且居中对齐*/ 'left' | /*位于左侧,且底部对齐*/ 'left-end' | /*位于右侧,且顶部对齐*/ 'right-start' | /*位于右侧,且居中对齐*/ 'right' | /*位于右侧,且底部对齐*/ 'right-end';
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;
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { html, LitElement } from 'lit';
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 选项卡组件。需与 `<mdui-tab>` 和 `<mdui-tab-panel>` 组件配合使用
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 LitElement {
41
+ let Tabs = class Tabs extends MduiElement {
42
42
  constructor() {
43
43
  super(...arguments);
44
44
  /**
45
- * 选项卡形状。可选值为:
45
+ * 选项卡形状。可选值包括:
46
46
  *
47
- * * `primary`:位于 `<mdui-top-app-bar>` 下方,用于切换应用的主页面时,可使用该形状的选项卡
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(this, 'change');
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();