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
@@ -1,2 +1,101 @@
1
1
  import { css } from 'lit';
2
- export const style = css `:host{--shape-corner:var(--mdui-shape-corner-extra-small);--z-index:2400;position:fixed;z-index:var(--z-index);display:none;align-items:center;flex-wrap:wrap;border-radius:var(--shape-corner);min-width:20rem;max-width:36rem;padding:.25rem 0;box-shadow:var(--mdui-elevation-level3);background-color:rgb(var(--mdui-color-inverse-surface));color:rgb(var(--mdui-color-inverse-on-surface));font-size:var(--mdui-typescale-body-medium-size);font-weight:var(--mdui-typescale-body-medium-weight);letter-spacing:var(--mdui-typescale-body-medium-tracking);line-height:var(--mdui-typescale-body-medium-line-height)}:host([placement^=top]){transform-origin:top;top:1rem}:host([placement^=bottom]){transform-origin:bottom;bottom:1rem}:host([placement=bottom-start]),:host([placement=top-start]){left:1rem}:host([placement=bottom-end]),:host([placement=top-end]){right:1rem}.message{display:block;margin:.625rem 1rem}:host([message-line='1']) .message{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([message-line='2']) .message{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical;-webkit-line-clamp:2}.action-group{display:flex;align-items:center;margin-left:auto;padding-right:.5rem}.action,.close-button{display:inline-flex;align-items:center;justify-content:center}.action{color:rgb(var(--mdui-color-inverse-primary));font-size:var(--mdui-typescale-label-large-size);font-weight:var(--mdui-typescale-label-large-weight);letter-spacing:var(--mdui-typescale-label-large-tracking)}.action mdui-button,::slotted(mdui-button[slot=action][variant=outlined]),::slotted(mdui-button[slot=action][variant=text]){color:inherit;font-size:inherit;font-weight:inherit;letter-spacing:inherit;--mdui-comp-ripple-state-layer-color:var(--mdui-color-inverse-primary)}.action mdui-button::part(button){padding:0 .5rem}.close-button{margin:0 -.25rem 0 .25rem;font-size:1.5rem;color:rgb(var(--mdui-color-inverse-on-surface))}.close-button mdui-button-icon,::slotted(mdui-button-icon[slot=close-button][variant=outlined]),::slotted(mdui-button-icon[slot=close-button][variant=standard]){font-size:inherit;color:inherit;--mdui-comp-ripple-state-layer-color:var(--mdui-color-inverse-on-surface)}.close-button .i,::slotted([slot=close-icon]){font-size:inherit}`;
2
+ export const style = css `
3
+ :host {
4
+ --shape-corner: var(--mdui-shape-corner-extra-small);
5
+ --z-index: 2400;
6
+ position: fixed;
7
+ z-index: var(--z-index);
8
+ display: none;
9
+ align-items: center;
10
+ flex-wrap: wrap;
11
+ border-radius: var(--shape-corner);
12
+ min-width: 20rem;
13
+ max-width: 36rem;
14
+ padding: 0.25rem 0rem;
15
+ box-shadow: var(--mdui-elevation-level3);
16
+ background-color: rgb(var(--mdui-color-inverse-surface));
17
+ color: rgb(var(--mdui-color-inverse-on-surface));
18
+ font-size: var(--mdui-typescale-body-medium-size);
19
+ font-weight: var(--mdui-typescale-body-medium-weight);
20
+ letter-spacing: var(--mdui-typescale-body-medium-tracking);
21
+ line-height: var(--mdui-typescale-body-medium-line-height);
22
+ }
23
+ :host([placement^='top']) {
24
+ transform-origin: top;
25
+ top: 1rem;
26
+ }
27
+ :host([placement^='bottom']) {
28
+ transform-origin: bottom;
29
+ bottom: 1rem;
30
+ }
31
+ :host([placement='top-start']),
32
+ :host([placement='bottom-start']) {
33
+ left: 1rem;
34
+ }
35
+ :host([placement='top-end']),
36
+ :host([placement='bottom-end']) {
37
+ right: 1rem;
38
+ }
39
+ .message {
40
+ display: block;
41
+ margin: 0.625rem 1rem;
42
+ }
43
+ :host([message-line='1']) .message {
44
+ overflow: hidden;
45
+ white-space: nowrap;
46
+ text-overflow: ellipsis;
47
+ }
48
+ :host([message-line='2']) .message {
49
+ display: -webkit-box;
50
+ overflow: hidden;
51
+ text-overflow: ellipsis;
52
+ -webkit-box-orient: vertical;
53
+ -webkit-line-clamp: 2;
54
+ }
55
+ .action-group {
56
+ display: flex;
57
+ align-items: center;
58
+ margin-left: auto;
59
+ padding-right: 0.5rem;
60
+ }
61
+ .action,
62
+ .close-button {
63
+ display: inline-flex;
64
+ align-items: center;
65
+ justify-content: center;
66
+ }
67
+ .action {
68
+ color: rgb(var(--mdui-color-inverse-primary));
69
+ font-size: var(--mdui-typescale-label-large-size);
70
+ font-weight: var(--mdui-typescale-label-large-weight);
71
+ letter-spacing: var(--mdui-typescale-label-large-tracking);
72
+ }
73
+ .action mdui-button,
74
+ ::slotted(mdui-button[slot='action'][variant='text']),
75
+ ::slotted(mdui-button[slot='action'][variant='outlined']) {
76
+ color: inherit;
77
+ font-size: inherit;
78
+ font-weight: inherit;
79
+ letter-spacing: inherit;
80
+ --mdui-comp-ripple-state-layer-color: var(--mdui-color-inverse-primary);
81
+ }
82
+ .action mdui-button::part(button) {
83
+ padding: 0rem 0.5rem;
84
+ }
85
+ .close-button {
86
+ margin: 0rem -0.25rem 0rem 0.25rem;
87
+ font-size: 1.5rem;
88
+ color: rgb(var(--mdui-color-inverse-on-surface));
89
+ }
90
+ .close-button mdui-button-icon,
91
+ ::slotted(mdui-button-icon[slot='close-button'][variant='standard']),
92
+ ::slotted(mdui-button-icon[slot='close-button'][variant='outlined']) {
93
+ font-size: inherit;
94
+ color: inherit;
95
+ --mdui-comp-ripple-state-layer-color: var(--mdui-color-inverse-on-surface);
96
+ }
97
+ .close-button .i,
98
+ ::slotted([slot='close-icon']) {
99
+ font-size: inherit;
100
+ }
101
+ `;
@@ -26,8 +26,8 @@ declare const Switch_base: import("@open-wc/dedupe-mixin").Constructor<import(".
26
26
  * @csspart unchecked-icon - 未选中状态的图标
27
27
  * @csspart checked-icon 选中状态的图标
28
28
  *
29
- * @cssprop --shape-corner - 组件的轨道的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
30
- * @cssprop --shape-corner-thumb - 组件的图标容器的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
29
+ * @cssprop --shape-corner - 组件轨道的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
30
+ * @cssprop --shape-corner-thumb - 组件图标容器的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
31
31
  */
32
32
  export declare class Switch extends Switch_base<SwitchEventMap> implements FormControl {
33
33
  static styles: CSSResultGroup;
@@ -40,7 +40,7 @@ export declare class Switch extends Switch_base<SwitchEventMap> implements FormC
40
40
  */
41
41
  checked: boolean;
42
42
  /**
43
- * 默认选中状态。在重置表单时,将重置为该默认状态。该属性只能通过 JavaScript 属性设置
43
+ * 默认选中状态。在重置表单时,将重置为此状态。此属性只能通过 JavaScript 属性设置
44
44
  */
45
45
  defaultChecked: boolean;
46
46
  /**
@@ -50,17 +50,17 @@ export declare class Switch extends Switch_base<SwitchEventMap> implements FormC
50
50
  /**
51
51
  * 选中状态的 Material Icons 图标名。也可以通过 `slot="checked-icon"` 设置
52
52
  *
53
- * 默认为 check 图标,可传入空字符串移除默认图标
53
+ * 默认为 `check` 图标,可传入空字符串移除默认图标
54
54
  */
55
55
  checkedIcon?: string;
56
56
  /**
57
- * 提交表单时,是否必须选中该开关
57
+ * 提交表单时,是否必须选中此开关
58
58
  */
59
59
  required: boolean;
60
60
  /**
61
- * 关联的 `form` 元素。此属性值必须为同一页面中的一个 `<form>` 元素的 `id` 属性。
61
+ * 关联的 `<form>` 元素。此属性值应为同一页面中的一个 `<form>` 元素的 `id`。
62
62
  *
63
- * 如果此属性未指定,则元素必须是 `form` 元素的后代。利用此属性,你可以将元素放置在页面中的任何位置,而不仅仅是作为 `form` 元素的后代。
63
+ * 如果未指定此属性,则该元素必须是 `<form>` 元素的子元素。通过此属性,你可以将元素放置在页面的任何位置,而不仅仅是 `<form>` 元素的子元素。
64
64
  */
65
65
  form?: string;
66
66
  /**
@@ -80,11 +80,11 @@ export declare class Switch extends Switch_base<SwitchEventMap> implements FormC
80
80
  private readonly formController;
81
81
  private readonly hasSlotController;
82
82
  /**
83
- * 表单验证状态对象
83
+ * 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
84
84
  */
85
85
  get validity(): ValidityState;
86
86
  /**
87
- * 表单验证的错误提示信息
87
+ * 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
88
88
  */
89
89
  get validationMessage(): string;
90
90
  protected get rippleElement(): Ripple;
@@ -94,19 +94,19 @@ export declare class Switch extends Switch_base<SwitchEventMap> implements FormC
94
94
  private onDisabledChange;
95
95
  private onCheckedChange;
96
96
  /**
97
- * 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`
97
+ * 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
98
98
  */
99
99
  checkValidity(): boolean;
100
100
  /**
101
- * 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`。
101
+ * 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
102
102
  *
103
- * 验证未通过时,还将在组件上显示未通过的提示。
103
+ * 如果验证未通过,还会在组件上显示验证失败的提示。
104
104
  */
105
105
  reportValidity(): boolean;
106
106
  /**
107
- * 设置自定义的错误提示文本。只要文本不为空,则表示字段验证未通过
107
+ * 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
108
108
  *
109
- * @param message 自定义的提示文本
109
+ * @param message 自定义的错误提示文本
110
110
  */
111
111
  setCustomValidity(message: string): void;
112
112
  protected render(): TemplateResult;
@@ -39,8 +39,8 @@ 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
45
  let Switch = class Switch extends RippleMixin(FocusableMixin(MduiElement)) {
46
46
  constructor() {
@@ -54,11 +54,11 @@ let Switch = class Switch extends RippleMixin(FocusableMixin(MduiElement)) {
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(MduiElement)) {
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,7 +123,7 @@ let Switch = class Switch extends RippleMixin(FocusableMixin(MduiElement)) {
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();
@@ -137,9 +137,9 @@ let Switch = class Switch extends RippleMixin(FocusableMixin(MduiElement)) {
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();
@@ -158,25 +158,59 @@ let Switch = class Switch extends RippleMixin(FocusableMixin(MduiElement)) {
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);
167
167
  this.invalid = !this.inputRef.value.checkValidity();
168
168
  }
169
169
  render() {
170
- return html `<label class="${classMap({
170
+ return html `<label
171
+ class=${classMap({
171
172
  invalid: this.invalid,
172
173
  'has-unchecked-icon': this.uncheckedIcon || this.hasSlotController.test('unchecked-icon'),
173
- })}"><input ${ref(this.inputRef)} type="checkbox" name="${ifDefined(this.name)}" value="${ifDefined(this.value)}" .disabled="${this.disabled}" .checked="${live(this.checked)}" .required="${this.required}" @change="${this.onChange}"><div part="track" class="track"><div part="thumb" class="thumb"><mdui-ripple ${ref(this.rippleRef)} .noRipple="${this.noRipple}"></mdui-ripple><slot name="checked-icon" part="checked-icon" class="checked-icon">${this.checkedIcon
174
- ? html `<mdui-icon name="${this.checkedIcon}" class="i"></mdui-icon>`
174
+ })}
175
+ >
176
+ <input
177
+ ${ref(this.inputRef)}
178
+ type="checkbox"
179
+ name=${ifDefined(this.name)}
180
+ value=${ifDefined(this.value)}
181
+ .disabled=${this.disabled}
182
+ .checked=${live(this.checked)}
183
+ .required=${this.required}
184
+ @change=${this.onChange}
185
+ />
186
+ <div part="track" class="track">
187
+ <div part="thumb" class="thumb">
188
+ <mdui-ripple
189
+ ${ref(this.rippleRef)}
190
+ .noRipple=${this.noRipple}
191
+ ></mdui-ripple>
192
+ <slot name="checked-icon" part="checked-icon" class="checked-icon">
193
+ ${this.checkedIcon
194
+ ? html `<mdui-icon name=${this.checkedIcon} class="i"></mdui-icon>`
175
195
  : this.checkedIcon === ''
176
196
  ? nothingTemplate
177
- : html `<mdui-icon-check class="i"></mdui-icon-check>`}</slot><slot name="unchecked-icon" part="unchecked-icon" class="unchecked-icon">${this.uncheckedIcon
178
- ? html `<mdui-icon name="${this.uncheckedIcon}" class="i"></mdui-icon>`
179
- : nothingTemplate}</slot></div></div></label>`;
197
+ : html `<mdui-icon-check class="i"></mdui-icon-check>`}
198
+ </slot>
199
+ <slot
200
+ name="unchecked-icon"
201
+ part="unchecked-icon"
202
+ class="unchecked-icon"
203
+ >
204
+ ${this.uncheckedIcon
205
+ ? html `<mdui-icon
206
+ name=${this.uncheckedIcon}
207
+ class="i"
208
+ ></mdui-icon>`
209
+ : nothingTemplate}
210
+ </slot>
211
+ </div>
212
+ </div>
213
+ </label>`;
180
214
  }
181
215
  /**
182
216
  * input[type="checkbox"] 的 change 事件无法冒泡越过 shadow dom
@@ -1,2 +1,203 @@
1
1
  import { css } from 'lit';
2
- export const style = css `:host{--shape-corner:var(--mdui-shape-corner-full);--shape-corner-thumb:var(--mdui-shape-corner-full);position:relative;display:inline-block;cursor:pointer;-webkit-tap-highlight-color:transparent;height:2.5rem}:host([disabled]){cursor:default;pointer-events:none}label{display:inline-flex;align-items:center;width:100%;height:100%;white-space:nowrap;cursor:inherit;-webkit-user-select:none;user-select:none;touch-action:manipulation;zoom:1;-webkit-user-drag:none}.track{position:relative;display:flex;align-items:center;border-radius:var(--shape-corner);transition-property:background-color,border-width;transition-duration:var(--mdui-motion-duration-short4);transition-timing-function:var(--mdui-motion-easing-standard);height:2rem;width:3.25rem;border:.125rem solid rgb(var(--mdui-color-outline));background-color:rgb(var(--mdui-color-surface-container-highest))}:host([checked]) .track{background-color:rgb(var(--mdui-color-primary));border-width:0}.invalid .track{background-color:rgb(var(--mdui-color-error-container));border-color:rgb(var(--mdui-color-error))}:host([disabled]) .track{background-color:rgba(var(--mdui-color-surface-container-highest),.12);border-color:rgba(var(--mdui-color-on-surface),.12)}:host([disabled][checked]) .track{background-color:rgba(var(--mdui-color-on-surface),.12)}input{position:absolute;padding:0;opacity:0;pointer-events:none;width:1.25rem;height:1.25rem;margin:0 0 0 .625rem}mdui-ripple{border-radius:50%;transition-property:left,top;transition-duration:var(--mdui-motion-duration-short4);transition-timing-function:var(--mdui-motion-easing-standard);width:2.5rem;height:2.5rem}.thumb{position:absolute;display:flex;align-items:center;justify-content:center;border-radius:var(--shape-corner-thumb);transition-property:width,height,left,background-color;transition-duration:var(--mdui-motion-duration-short4);transition-timing-function:var(--mdui-motion-easing-standard);height:1rem;width:1rem;left:.375rem;background-color:rgb(var(--mdui-color-outline));--mdui-comp-ripple-state-layer-color:var(--mdui-color-on-surface)}.thumb mdui-ripple{left:-.75rem;top:-.75rem}.has-unchecked-icon .thumb{height:1.5rem;width:1.5rem;left:.125rem}.has-unchecked-icon .thumb mdui-ripple{left:-.5rem;top:-.5rem}:host([focus-visible]) .thumb,:host([hover]) .thumb,:host([pressed]) .thumb{background-color:rgb(var(--mdui-color-on-surface-variant))}:host([checked]) .thumb{height:1.5rem;width:1.5rem;left:1.5rem;background-color:rgb(var(--mdui-color-on-primary));--mdui-comp-ripple-state-layer-color:var(--mdui-color-primary)}:host([checked]) .thumb mdui-ripple{left:-.5rem;top:-.5rem}:host([pressed]) .thumb{height:1.75rem;width:1.75rem;left:0}:host([pressed]) .thumb mdui-ripple{left:-.375rem;top:-.375rem}:host([pressed][checked]) .thumb{left:1.375rem}:host([focus-visible][checked]) .thumb,:host([hover][checked]) .thumb,:host([pressed][checked]) .thumb{background-color:rgb(var(--mdui-color-primary-container))}.invalid .thumb{background-color:rgb(var(--mdui-color-error));--mdui-comp-ripple-state-layer-color:var(--mdui-color-error)}:host([focus-visible]) .invalid .thumb,:host([hover]) .invalid .thumb,:host([pressed]) .invalid .thumb{background-color:rgb(var(--mdui-color-error))}:host([disabled]) .thumb{background-color:rgba(var(--mdui-color-on-surface),.38)}:host([disabled][checked]) .thumb{background-color:rgb(var(--mdui-color-surface))}.checked-icon,.unchecked-icon{display:flex;position:absolute;transition-property:opacity,transform;font-size:1rem}.unchecked-icon{opacity:1;transform:scale(1);transition-delay:var(--mdui-motion-duration-short1);transition-duration:var(--mdui-motion-duration-short3);transition-timing-function:var(--mdui-motion-easing-linear);color:rgb(var(--mdui-color-surface-container-highest))}:host([checked]) .unchecked-icon{opacity:0;transform:scale(.92);transition-delay:0s;transition-duration:var(--mdui-motion-duration-short1)}:host([disabled]) .unchecked-icon{color:rgba(var(--mdui-color-surface-container-highest),.38)}.checked-icon{opacity:0;transform:scale(.92);transition-delay:0s;transition-duration:var(--mdui-motion-duration-short1);transition-timing-function:var(--mdui-motion-easing-linear);color:rgb(var(--mdui-color-on-primary-container))}:host([checked]) .checked-icon{opacity:1;transform:scale(1);transition-delay:var(--mdui-motion-duration-short1);transition-duration:var(--mdui-motion-duration-short3)}.invalid .checked-icon{color:rgb(var(--mdui-color-error-container))}:host([disabled]) .checked-icon{color:rgba(var(--mdui-color-on-surface),.38)}.checked-icon .i,.unchecked-icon .i,::slotted([slot=checked-icon]),::slotted([slot=unchecked-icon]){font-size:inherit;color:inherit}`;
2
+ export const style = css `
3
+ :host {
4
+ --shape-corner: var(--mdui-shape-corner-full);
5
+ --shape-corner-thumb: var(--mdui-shape-corner-full);
6
+ position: relative;
7
+ display: inline-block;
8
+ cursor: pointer;
9
+ -webkit-tap-highlight-color: transparent;
10
+ height: 2.5rem;
11
+ }
12
+ :host([disabled]) {
13
+ cursor: default;
14
+ pointer-events: none;
15
+ }
16
+ label {
17
+ display: inline-flex;
18
+ align-items: center;
19
+ width: 100%;
20
+ height: 100%;
21
+ white-space: nowrap;
22
+ cursor: inherit;
23
+ -webkit-user-select: none;
24
+ user-select: none;
25
+ touch-action: manipulation;
26
+ zoom: 1;
27
+ -webkit-user-drag: none;
28
+ }
29
+ /* 轨道 */
30
+ .track {
31
+ position: relative;
32
+ display: flex;
33
+ align-items: center;
34
+ border-radius: var(--shape-corner);
35
+ transition-property: background-color, border-width;
36
+ transition-duration: var(--mdui-motion-duration-short4);
37
+ transition-timing-function: var(--mdui-motion-easing-standard);
38
+ height: 2rem;
39
+ width: 3.25rem;
40
+ border: 0.125rem solid rgb(var(--mdui-color-outline));
41
+ background-color: rgb(var(--mdui-color-surface-container-highest));
42
+ }
43
+ :host([checked]) .track {
44
+ background-color: rgb(var(--mdui-color-primary));
45
+ border-width: 0rem;
46
+ }
47
+ .invalid .track {
48
+ background-color: rgb(var(--mdui-color-error-container));
49
+ border-color: rgb(var(--mdui-color-error));
50
+ }
51
+ :host([disabled]) .track {
52
+ background-color: rgba(var(--mdui-color-surface-container-highest), 0.12);
53
+ border-color: rgba(var(--mdui-color-on-surface), 0.12);
54
+ }
55
+ :host([disabled][checked]) .track {
56
+ background-color: rgba(var(--mdui-color-on-surface), 0.12);
57
+ }
58
+ /* 隐藏系统 input 标签,用自定义的图标代替 */
59
+ input {
60
+ position: absolute;
61
+ padding: 0;
62
+ opacity: 0;
63
+ pointer-events: none;
64
+ width: 1.25rem;
65
+ height: 1.25rem;
66
+ margin: 0rem 0rem 0rem 0.625rem;
67
+ }
68
+ mdui-ripple {
69
+ border-radius: 50%;
70
+ transition-property: left, top;
71
+ transition-duration: var(--mdui-motion-duration-short4);
72
+ transition-timing-function: var(--mdui-motion-easing-standard);
73
+ width: 2.5rem;
74
+ height: 2.5rem;
75
+ }
76
+ .thumb {
77
+ position: absolute;
78
+ display: flex;
79
+ align-items: center;
80
+ justify-content: center;
81
+ border-radius: var(--shape-corner-thumb);
82
+ transition-property: width, height, left, background-color;
83
+ transition-duration: var(--mdui-motion-duration-short4);
84
+ transition-timing-function: var(--mdui-motion-easing-standard);
85
+ height: 1rem;
86
+ width: 1rem;
87
+ left: 0.375rem;
88
+ background-color: rgb(var(--mdui-color-outline));
89
+ --mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
90
+ }
91
+ .thumb mdui-ripple {
92
+ left: -0.75rem;
93
+ top: -0.75rem;
94
+ }
95
+ .has-unchecked-icon .thumb {
96
+ height: 1.5rem;
97
+ width: 1.5rem;
98
+ left: 0.125rem;
99
+ }
100
+ .has-unchecked-icon .thumb mdui-ripple {
101
+ left: -0.5rem;
102
+ top: -0.5rem;
103
+ }
104
+ :host([hover]) .thumb,
105
+ :host([focus-visible]) .thumb,
106
+ :host([pressed]) .thumb {
107
+ background-color: rgb(var(--mdui-color-on-surface-variant));
108
+ }
109
+ :host([checked]) .thumb {
110
+ height: 1.5rem;
111
+ width: 1.5rem;
112
+ left: 1.5rem;
113
+ background-color: rgb(var(--mdui-color-on-primary));
114
+ --mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
115
+ }
116
+ :host([checked]) .thumb mdui-ripple {
117
+ left: -0.5rem;
118
+ top: -0.5rem;
119
+ }
120
+ :host([pressed]) .thumb {
121
+ height: 1.75rem;
122
+ width: 1.75rem;
123
+ left: 0rem;
124
+ }
125
+ :host([pressed]) .thumb mdui-ripple {
126
+ left: -0.375rem;
127
+ top: -0.375rem;
128
+ }
129
+ :host([pressed][checked]) .thumb {
130
+ left: 1.375rem;
131
+ }
132
+ :host([hover][checked]) .thumb,
133
+ :host([focus-visible][checked]) .thumb,
134
+ :host([pressed][checked]) .thumb {
135
+ background-color: rgb(var(--mdui-color-primary-container));
136
+ }
137
+ .invalid .thumb {
138
+ background-color: rgb(var(--mdui-color-error));
139
+ --mdui-comp-ripple-state-layer-color: var(--mdui-color-error);
140
+ }
141
+ :host([hover]) .invalid .thumb,
142
+ :host([focus-visible]) .invalid .thumb,
143
+ :host([pressed]) .invalid .thumb {
144
+ background-color: rgb(var(--mdui-color-error));
145
+ }
146
+ :host([disabled]) .thumb {
147
+ background-color: rgba(var(--mdui-color-on-surface), 0.38);
148
+ }
149
+ :host([disabled][checked]) .thumb {
150
+ background-color: rgb(var(--mdui-color-surface));
151
+ }
152
+ .unchecked-icon,
153
+ .checked-icon {
154
+ display: flex;
155
+ position: absolute;
156
+ transition-property: opacity, transform;
157
+ font-size: 1rem;
158
+ }
159
+ .unchecked-icon {
160
+ opacity: 1;
161
+ transform: scale(1);
162
+ transition-delay: var(--mdui-motion-duration-short1);
163
+ transition-duration: var(--mdui-motion-duration-short3);
164
+ transition-timing-function: var(--mdui-motion-easing-linear);
165
+ color: rgb(var(--mdui-color-surface-container-highest));
166
+ }
167
+ :host([checked]) .unchecked-icon {
168
+ opacity: 0;
169
+ transform: scale(0.92);
170
+ transition-delay: 0ms;
171
+ transition-duration: var(--mdui-motion-duration-short1);
172
+ }
173
+ :host([disabled]) .unchecked-icon {
174
+ color: rgba(var(--mdui-color-surface-container-highest), 0.38);
175
+ }
176
+ .checked-icon {
177
+ opacity: 0;
178
+ transform: scale(0.92);
179
+ transition-delay: 0ms;
180
+ transition-duration: var(--mdui-motion-duration-short1);
181
+ transition-timing-function: var(--mdui-motion-easing-linear);
182
+ color: rgb(var(--mdui-color-on-primary-container));
183
+ }
184
+ :host([checked]) .checked-icon {
185
+ opacity: 1;
186
+ transform: scale(1);
187
+ transition-delay: var(--mdui-motion-duration-short1);
188
+ transition-duration: var(--mdui-motion-duration-short3);
189
+ }
190
+ .invalid .checked-icon {
191
+ color: rgb(var(--mdui-color-error-container));
192
+ }
193
+ :host([disabled]) .checked-icon {
194
+ color: rgba(var(--mdui-color-on-surface), 0.38);
195
+ }
196
+ .unchecked-icon .i,
197
+ .checked-icon .i,
198
+ ::slotted([slot='unchecked-icon']),
199
+ ::slotted([slot='checked-icon']) {
200
+ font-size: inherit;
201
+ color: inherit;
202
+ }
203
+ `;
@@ -1,2 +1,11 @@
1
1
  import { css } from 'lit';
2
- export const tabPanelStyle = css `:host{display:block;overflow-y:auto;flex:1 1 auto}:host(:not([active])){display:none}`;
2
+ export const tabPanelStyle = css `
3
+ :host {
4
+ display: block;
5
+ overflow-y: auto;
6
+ flex: 1 1 auto;
7
+ }
8
+ :host(:not([active])) {
9
+ display: none;
10
+ }
11
+ `;
@@ -1,7 +1,7 @@
1
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
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
  /**
@@ -6,7 +6,7 @@ import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
6
6
  import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
7
7
  import { tabPanelStyle } from './tab-panel-style.js';
8
8
  /**
9
- * @summary 选项卡面板项组件。需与 `<mdui-tabs>` 和 `<mdui-tab>` 组件配合使用
9
+ * @summary 选项卡面板项组件。需配合 `<mdui-tabs>` 和 `<mdui-tab>` 组件使用
10
10
  *
11
11
  * ```html
12
12
  * <mdui-tabs value="tab-1">
@@ -20,7 +20,7 @@ import { tabPanelStyle } from './tab-panel-style.js';
20
20
  * </mdui-tabs>
21
21
  * ```
22
22
  *
23
- * @slot - 选项卡面板内容
23
+ * @slot - 选项卡面板项内容
24
24
  */
25
25
  let TabPanel = class TabPanel extends MduiElement {
26
26
  constructor() {
@@ -1,2 +1,86 @@
1
1
  import { css } from 'lit';
2
- export const tabStyle = css `:host{position:relative;--mdui-comp-ripple-state-layer-color:var(--mdui-color-on-surface)}:host([active]){--mdui-comp-ripple-state-layer-color:var(--mdui-color-primary)}.container{display:flex;justify-content:center;align-items:center;cursor:pointer;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;height:100%}.preset{flex-direction:column;min-height:3rem;padding:.625rem 1rem}:host([inline]) .preset{flex-direction:row}.icon-container,.label-container{position:relative;display:flex;align-items:center;justify-content:center}.icon-container ::slotted([slot=badge]){position:absolute;transform:translate(50%,-50%)}.icon-container ::slotted([slot=badge][variant=small]){transform:translate(.5625rem,-.5625rem)}.label-container ::slotted([slot=badge]){position:absolute;left:100%;bottom:100%;transform:translate(-.75rem,.625rem)}.label-container ::slotted([slot=badge][variant=small]){transform:translate(-.375rem,.375rem)}.icon,.label{display:flex;color:rgb(var(--mdui-color-on-surface-variant))}:host([focused]) .icon,:host([focused]) .label,:host([hover]) .icon,:host([hover]) .label,:host([pressed]) .icon,:host([pressed]) .label{color:rgb(var(--mdui-color-on-surface))}:host([active]) .icon,:host([active]) .label{color:rgb(var(--mdui-color-primary))}:host([active]) .variant-secondary .icon,:host([active]) .variant-secondary .label{color:rgb(var(--mdui-color-on-surface))}.icon{font-size:1.5rem}.label{font-size:var(--mdui-typescale-title-small-size);font-weight:var(--mdui-typescale-title-small-weight);letter-spacing:var(--mdui-typescale-title-small-tracking);line-height:var(--mdui-typescale-title-small-line-height)}.icon mdui-icon,::slotted([slot=icon]){font-size:inherit;color:inherit}`;
2
+ export const tabStyle = css `
3
+ :host {
4
+ position: relative;
5
+ --mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
6
+ }
7
+ :host([active]) {
8
+ --mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
9
+ }
10
+ .container {
11
+ display: flex;
12
+ justify-content: center;
13
+ align-items: center;
14
+ cursor: pointer;
15
+ -webkit-user-select: none;
16
+ user-select: none;
17
+ -webkit-tap-highlight-color: transparent;
18
+ height: 100%;
19
+ }
20
+ .preset {
21
+ flex-direction: column;
22
+ min-height: 3rem;
23
+ padding: 0.625rem 1rem;
24
+ }
25
+ :host([inline]) .preset {
26
+ flex-direction: row;
27
+ }
28
+ .icon-container,
29
+ .label-container {
30
+ position: relative;
31
+ display: flex;
32
+ align-items: center;
33
+ justify-content: center;
34
+ }
35
+ .icon-container ::slotted([slot='badge']) {
36
+ position: absolute;
37
+ transform: translate(50%, -50%);
38
+ }
39
+ .icon-container ::slotted([slot='badge'][variant='small']) {
40
+ transform: translate(0.5625rem, -0.5625rem);
41
+ }
42
+ .label-container ::slotted([slot='badge']) {
43
+ position: absolute;
44
+ left: 100%;
45
+ bottom: 100%;
46
+ transform: translate(-0.75rem, 0.625rem);
47
+ }
48
+ .label-container ::slotted([slot='badge'][variant='small']) {
49
+ transform: translate(-0.375rem, 0.375rem);
50
+ }
51
+ .icon,
52
+ .label {
53
+ display: flex;
54
+ color: rgb(var(--mdui-color-on-surface-variant));
55
+ }
56
+ :host([hover]) .icon,
57
+ :host([hover]) .label,
58
+ :host([focused]) .icon,
59
+ :host([focused]) .label,
60
+ :host([pressed]) .icon,
61
+ :host([pressed]) .label {
62
+ color: rgb(var(--mdui-color-on-surface));
63
+ }
64
+ :host([active]) .icon,
65
+ :host([active]) .label {
66
+ color: rgb(var(--mdui-color-primary));
67
+ }
68
+ :host([active]) .variant-secondary .icon,
69
+ :host([active]) .variant-secondary .label {
70
+ color: rgb(var(--mdui-color-on-surface));
71
+ }
72
+ .icon {
73
+ font-size: 1.5rem;
74
+ }
75
+ .label {
76
+ font-size: var(--mdui-typescale-title-small-size);
77
+ font-weight: var(--mdui-typescale-title-small-weight);
78
+ letter-spacing: var(--mdui-typescale-title-small-tracking);
79
+ line-height: var(--mdui-typescale-title-small-line-height);
80
+ }
81
+ .icon mdui-icon,
82
+ ::slotted([slot='icon']) {
83
+ font-size: inherit;
84
+ color: inherit;
85
+ }
86
+ `;