mdui 2.0.3 → 2.0.5

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