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
@@ -19,23 +19,23 @@ import { style } from './style.js';
19
19
  * @event focus - 获得焦点时触发
20
20
  * @event blur - 失去焦点时触发
21
21
  *
22
- * @slot - 卡片内容
22
+ * @slot - 卡片的内容
23
23
  *
24
- * @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
24
+ * @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
25
25
  */
26
26
  let Card = class Card extends AnchorMixin(RippleMixin(FocusableMixin(MduiElement))) {
27
27
  constructor() {
28
28
  super(...arguments);
29
29
  /**
30
- * 卡片形状。可选值为:
30
+ * 卡片的形状。可选值包括:
31
31
  *
32
- * * `elevated`:具有阴影,与背景的分离度比 `filled` 更高,但小于 `outlined`
33
- * * `filled`:与背景的分离度最小
34
- * * `outlined`:具有边框,与背景的分离度最大
32
+ * * `elevated`:带阴影的卡片,与背景的视觉分离度较高
33
+ * * `filled`:带填充色的卡片,与背景的视觉分离度较低
34
+ * * `outlined`:带边框的卡片,与背景的视觉分离度最高
35
35
  */
36
36
  this.variant = 'elevated';
37
37
  /**
38
- * 是否可点击。为 `true` 时,会添加鼠标悬浮效果、及点击涟漪效果
38
+ * 是否可点击。为 `true` 时,卡片将具有鼠标悬浮效果和点击涟漪效果
39
39
  */
40
40
  this.clickable = false;
41
41
  /**
@@ -59,7 +59,11 @@ let Card = class Card extends AnchorMixin(RippleMixin(FocusableMixin(MduiElement
59
59
  return this.rippleDisabled;
60
60
  }
61
61
  render() {
62
- return html `<mdui-ripple ${ref(this.rippleRef)} .noRipple="${this.noRipple}"></mdui-ripple>${this.href && !this.disabled
62
+ return html `<mdui-ripple
63
+ ${ref(this.rippleRef)}
64
+ .noRipple=${this.noRipple}
65
+ ></mdui-ripple
66
+ >${this.href && !this.disabled
63
67
  ? this.renderAnchor({
64
68
  className: 'link',
65
69
  content: html `<slot></slot>`,
@@ -1,2 +1,73 @@
1
1
  import { css } from 'lit';
2
- export const style = css `:host{--shape-corner:var(--mdui-shape-corner-medium);position:relative;display:inline-block;overflow:hidden;border-radius:var(--shape-corner);-webkit-tap-highlight-color:transparent;transition:box-shadow var(--mdui-motion-duration-short4) var(--mdui-motion-easing-linear);--mdui-comp-ripple-state-layer-color:var(--mdui-color-on-surface)}:host([clickable]){cursor:pointer}:host([variant=elevated]){background-color:rgb(var(--mdui-color-surface-container-low));box-shadow:var(--mdui-elevation-level1)}:host([variant=filled]){background-color:rgb(var(--mdui-color-surface-container-highest))}:host([variant=outlined]){background-color:rgb(var(--mdui-color-surface));border:.0625rem solid rgb(var(--mdui-color-outline))}:host([variant=elevated][hover]){box-shadow:var(--mdui-elevation-level2)}:host([variant=filled][hover]),:host([variant=outlined][hover]){box-shadow:var(--mdui-elevation-level1)}:host([variant=elevated][dragged]),:host([variant=filled][dragged]),:host([variant=outlined][dragged]){box-shadow:var(--mdui-elevation-level3)}:host([disabled]){opacity:.38;cursor:default;-webkit-user-select:none;user-select:none}:host([variant=elevated][disabled]){background-color:rgb(var(--mdui-color-surface-variant));box-shadow:var(--mdui-elevation-level0)}:host([variant=filled][disabled]){background-color:rgb(var(--mdui-color-surface));box-shadow:var(--mdui-elevation-level1)}:host([variant=outlined][disabled]){box-shadow:var(--mdui-elevation-level0);border-color:rgba(var(--mdui-color-outline),.32)}.link{position:relative;display:inline-block;width:100%;height:100%;color:inherit;font-size:inherit;letter-spacing:inherit;text-decoration:none;touch-action:manipulation;-webkit-user-drag:none}`;
2
+ export const style = css `
3
+ /**
4
+ * mdui-card 组件。默认为 variant="elevated"
5
+ */
6
+ :host {
7
+ --shape-corner: var(--mdui-shape-corner-medium);
8
+ position: relative;
9
+ display: inline-block;
10
+ overflow: hidden;
11
+ border-radius: var(--shape-corner);
12
+ -webkit-tap-highlight-color: transparent;
13
+ transition: box-shadow var(--mdui-motion-duration-short4)
14
+ var(--mdui-motion-easing-linear);
15
+ --mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
16
+ }
17
+ :host([clickable]) {
18
+ cursor: pointer;
19
+ }
20
+ :host([variant='elevated']) {
21
+ background-color: rgb(var(--mdui-color-surface-container-low));
22
+ box-shadow: var(--mdui-elevation-level1);
23
+ }
24
+ :host([variant='filled']) {
25
+ background-color: rgb(var(--mdui-color-surface-container-highest));
26
+ }
27
+ :host([variant='outlined']) {
28
+ background-color: rgb(var(--mdui-color-surface));
29
+ border: 0.0625rem solid rgb(var(--mdui-color-outline));
30
+ }
31
+ :host([variant='elevated'][hover]) {
32
+ box-shadow: var(--mdui-elevation-level2);
33
+ }
34
+ :host([variant='filled'][hover]),
35
+ :host([variant='outlined'][hover]) {
36
+ box-shadow: var(--mdui-elevation-level1);
37
+ }
38
+ :host([variant='elevated'][dragged]),
39
+ :host([variant='filled'][dragged]),
40
+ :host([variant='outlined'][dragged]) {
41
+ box-shadow: var(--mdui-elevation-level3);
42
+ }
43
+ :host([disabled]) {
44
+ opacity: 0.38;
45
+ cursor: default;
46
+ -webkit-user-select: none;
47
+ user-select: none;
48
+ }
49
+ :host([variant='elevated'][disabled]) {
50
+ background-color: rgb(var(--mdui-color-surface-variant));
51
+ box-shadow: var(--mdui-elevation-level0);
52
+ }
53
+ :host([variant='filled'][disabled]) {
54
+ background-color: rgb(var(--mdui-color-surface));
55
+ box-shadow: var(--mdui-elevation-level1);
56
+ }
57
+ :host([variant='outlined'][disabled]) {
58
+ box-shadow: var(--mdui-elevation-level0);
59
+ border-color: rgba(var(--mdui-color-outline), 0.32);
60
+ }
61
+ .link {
62
+ position: relative;
63
+ display: inline-block;
64
+ width: 100%;
65
+ height: 100%;
66
+ color: inherit;
67
+ font-size: inherit;
68
+ letter-spacing: inherit;
69
+ text-decoration: none;
70
+ touch-action: manipulation;
71
+ -webkit-user-drag: none;
72
+ }
73
+ `;
@@ -20,16 +20,16 @@ declare const Checkbox_base: import("@open-wc/dedupe-mixin").Constructor<import(
20
20
  * @event input - 选中状态变更时触发
21
21
  * @event invalid - 表单字段验证未通过时触发
22
22
  *
23
- * @slot - 文本
24
- * @slot unchecked-icon - 未选中状态图标
25
- * @slot checked-icon - 选中状态图标
26
- * @slot indeterminate-icon - 不确定状态图标
23
+ * @slot - 复选框文本
24
+ * @slot unchecked-icon - 未选中状态的图标
25
+ * @slot checked-icon - 选中状态的图标
26
+ * @slot indeterminate-icon - 不确定状态的图标
27
27
  *
28
28
  * @csspart control - 左侧图标容器
29
- * @csspart unchecked-icon - 未选中状态图标
30
- * @csspart checked-icon - 选中状态图标
31
- * @csspart indeterminate-icon - 不确定状态图标
32
- * @csspart label - 文本
29
+ * @csspart unchecked-icon - 未选中状态的图标
30
+ * @csspart checked-icon - 选中状态的图标
31
+ * @csspart indeterminate-icon - 不确定状态的图标
32
+ * @csspart label - 复选框文本
33
33
  */
34
34
  export declare class Checkbox extends Checkbox_base<CheckboxEventMap> implements FormControl {
35
35
  static styles: CSSResultGroup;
@@ -42,21 +42,21 @@ export declare class Checkbox extends Checkbox_base<CheckboxEventMap> implements
42
42
  */
43
43
  checked: boolean;
44
44
  /**
45
- * 默认选中状态。在重置表单时,将重置为该默认状态。该属性只能通过 JavaScript 属性设置
45
+ * 默认选中状态。在重置表单时,将恢复为此状态。此属性只能通过 JavaScript 属性设置
46
46
  */
47
47
  defaultChecked: boolean;
48
48
  /**
49
- * 是否为不确定状态
49
+ * 是否处于不确定状态
50
50
  */
51
51
  indeterminate: boolean;
52
52
  /**
53
- * 提交表单时,是否必须选中该复选框
53
+ * 提交表单时,是否必须选中此复选框
54
54
  */
55
55
  required: boolean;
56
56
  /**
57
- * 关联的 `form` 元素。此属性值必须为同一页面中的一个 `<form>` 元素的 `id` 属性。
57
+ * 关联的 `<form>` 元素。此属性值应为同一页面中的一个 `<form>` 元素的 `id`。
58
58
  *
59
- * 如果此属性未指定,则元素必须是 `form` 元素的后代。利用此属性,你可以将元素放置在页面中的任何位置,而不仅仅是作为 `form` 元素的后代。
59
+ * 如果未指定此属性,则该元素必须是 `<form>` 元素的子元素。通过此属性,你可以将元素放置在页面的任何位置,而不仅仅是 `<form>` 元素的子元素。
60
60
  */
61
61
  form?: string;
62
62
  /**
@@ -87,11 +87,11 @@ export declare class Checkbox extends Checkbox_base<CheckboxEventMap> implements
87
87
  private readonly rippleRef;
88
88
  private readonly formController;
89
89
  /**
90
- * 表单验证状态对象
90
+ * 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
91
91
  */
92
92
  get validity(): ValidityState;
93
93
  /**
94
- * 表单验证的错误提示信息
94
+ * 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
95
95
  */
96
96
  get validationMessage(): string;
97
97
  protected get rippleElement(): Ripple;
@@ -101,19 +101,19 @@ export declare class Checkbox extends Checkbox_base<CheckboxEventMap> implements
101
101
  private onDisabledChange;
102
102
  private onCheckedChange;
103
103
  /**
104
- * 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`
104
+ * 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
105
105
  */
106
106
  checkValidity(): boolean;
107
107
  /**
108
- * 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`。
108
+ * 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
109
109
  *
110
- * 验证未通过时,还将在组件上显示未通过的提示。
110
+ * 如果验证未通过,还会在组件上显示验证失败的提示。
111
111
  */
112
112
  reportValidity(): boolean;
113
113
  /**
114
- * 设置自定义的错误提示文本。只要文本不为空,则表示字段验证未通过
114
+ * 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
115
115
  *
116
- * @param message 自定义的提示文本
116
+ * @param message 自定义的错误提示文本
117
117
  */
118
118
  setCustomValidity(message: string): void;
119
119
  protected render(): TemplateResult;
@@ -31,16 +31,16 @@ import { style } from './style.js';
31
31
  * @event input - 选中状态变更时触发
32
32
  * @event invalid - 表单字段验证未通过时触发
33
33
  *
34
- * @slot - 文本
35
- * @slot unchecked-icon - 未选中状态图标
36
- * @slot checked-icon - 选中状态图标
37
- * @slot indeterminate-icon - 不确定状态图标
34
+ * @slot - 复选框文本
35
+ * @slot unchecked-icon - 未选中状态的图标
36
+ * @slot checked-icon - 选中状态的图标
37
+ * @slot indeterminate-icon - 不确定状态的图标
38
38
  *
39
39
  * @csspart control - 左侧图标容器
40
- * @csspart unchecked-icon - 未选中状态图标
41
- * @csspart checked-icon - 选中状态图标
42
- * @csspart indeterminate-icon - 不确定状态图标
43
- * @csspart label - 文本
40
+ * @csspart unchecked-icon - 未选中状态的图标
41
+ * @csspart checked-icon - 选中状态的图标
42
+ * @csspart indeterminate-icon - 不确定状态的图标
43
+ * @csspart label - 复选框文本
44
44
  */
45
45
  let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(MduiElement)) {
46
46
  constructor() {
@@ -54,15 +54,15 @@ let Checkbox = class Checkbox 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.indeterminate = false;
64
64
  /**
65
- * 提交表单时,是否必须选中该复选框
65
+ * 提交表单时,是否必须选中此复选框
66
66
  */
67
67
  this.required = false;
68
68
  /**
@@ -86,13 +86,13 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(MduiElement)) {
86
86
  });
87
87
  }
88
88
  /**
89
- * 表单验证状态对象
89
+ * 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
90
90
  */
91
91
  get validity() {
92
92
  return this.inputRef.value.validity;
93
93
  }
94
94
  /**
95
- * 表单验证的错误提示信息
95
+ * 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
96
96
  */
97
97
  get validationMessage() {
98
98
  return this.inputRef.value.validationMessage;
@@ -126,7 +126,7 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(MduiElement)) {
126
126
  }
127
127
  }
128
128
  /**
129
- * 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`
129
+ * 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
130
130
  */
131
131
  checkValidity() {
132
132
  const valid = this.inputRef.value.checkValidity();
@@ -140,9 +140,9 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(MduiElement)) {
140
140
  return valid;
141
141
  }
142
142
  /**
143
- * 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`。
143
+ * 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
144
144
  *
145
- * 验证未通过时,还将在组件上显示未通过的提示。
145
+ * 如果验证未通过,还会在组件上显示验证失败的提示。
146
146
  */
147
147
  reportValidity() {
148
148
  this.invalid = !this.inputRef.value.reportValidity();
@@ -161,22 +161,65 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(MduiElement)) {
161
161
  return !this.invalid;
162
162
  }
163
163
  /**
164
- * 设置自定义的错误提示文本。只要文本不为空,则表示字段验证未通过
164
+ * 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
165
165
  *
166
- * @param message 自定义的提示文本
166
+ * @param message 自定义的错误提示文本
167
167
  */
168
168
  setCustomValidity(message) {
169
169
  this.inputRef.value.setCustomValidity(message);
170
170
  this.invalid = !this.inputRef.value.checkValidity();
171
171
  }
172
172
  render() {
173
- return html `<label class="${classMap({ invalid: this.invalid })}"><input ${ref(this.inputRef)} type="checkbox" name="${ifDefined(this.name)}" value="${ifDefined(this.value)}" .indeterminate="${live(this.indeterminate)}" .disabled="${this.disabled}" .checked="${live(this.checked)}" .required="${this.required}" @change="${this.onChange}"> <i part="control"><mdui-ripple ${ref(this.rippleRef)} .noRipple="${this.noRipple}"></mdui-ripple><slot name="unchecked-icon" part="unchecked-icon" class="icon unchecked-icon">${this.uncheckedIcon
174
- ? html `<mdui-icon name="${this.uncheckedIcon}" class="i"></mdui-icon>`
175
- : html `<mdui-icon-check-box-outline-blank class="i"></mdui-icon-check-box-outline-blank>`}</slot><slot name="checked-icon" part="checked-icon" class="icon checked-icon">${this.checkedIcon
176
- ? html `<mdui-icon name="${this.checkedIcon}" class="i"></mdui-icon>`
177
- : html `<mdui-icon-check-box class="i"></mdui-icon-check-box>`}</slot><slot name="indeterminate-icon" part="indeterminate-icon" class="icon indeterminate-icon">${this.indeterminateIcon
178
- ? html `<mdui-icon name="${this.indeterminateIcon}" class="i"></mdui-icon>`
179
- : html `<mdui-icon-indeterminate-check-box class="i"></mdui-icon-indeterminate-check-box>`}</slot></i><slot part="label" class="label"></slot></label>`;
173
+ return html `<label class="${classMap({ invalid: this.invalid })}">
174
+ <input
175
+ ${ref(this.inputRef)}
176
+ type="checkbox"
177
+ name=${ifDefined(this.name)}
178
+ value=${ifDefined(this.value)}
179
+ .indeterminate=${live(this.indeterminate)}
180
+ .disabled=${this.disabled}
181
+ .checked=${live(this.checked)}
182
+ .required=${this.required}
183
+ @change=${this.onChange}
184
+ />
185
+ <i part="control">
186
+ <mdui-ripple
187
+ ${ref(this.rippleRef)}
188
+ .noRipple=${this.noRipple}
189
+ ></mdui-ripple>
190
+ <slot
191
+ name="unchecked-icon"
192
+ part="unchecked-icon"
193
+ class="icon unchecked-icon"
194
+ >
195
+ ${this.uncheckedIcon
196
+ ? html `<mdui-icon name=${this.uncheckedIcon} class="i"></mdui-icon>`
197
+ : html `<mdui-icon-check-box-outline-blank
198
+ class="i"
199
+ ></mdui-icon-check-box-outline-blank>`}
200
+ </slot>
201
+ <slot name="checked-icon" part="checked-icon" class="icon checked-icon">
202
+ ${this.checkedIcon
203
+ ? html `<mdui-icon name=${this.checkedIcon} class="i"></mdui-icon>`
204
+ : html `<mdui-icon-check-box class="i"></mdui-icon-check-box>`}
205
+ </slot>
206
+ <slot
207
+ name="indeterminate-icon"
208
+ part="indeterminate-icon"
209
+ class="icon indeterminate-icon"
210
+ >
211
+ ${this.indeterminateIcon
212
+ ? html `<mdui-icon
213
+ name=${this.indeterminateIcon}
214
+ class="i"
215
+ ></mdui-icon>`
216
+ : html `<mdui-icon-indeterminate-check-box
217
+ class="i"
218
+ ></mdui-icon-indeterminate-check-box>`}
219
+ </slot>
220
+ </i>
221
+ <slot part="label" class="label"></slot>
222
+ </label>`;
180
223
  }
181
224
  /**
182
225
  * input[type="checkbox"] 的 change 事件无法冒泡越过 shadow dom
@@ -1,2 +1,132 @@
1
1
  import { css } from 'lit';
2
- export const style = css `:host{position:relative;display:inline-flex;cursor:pointer;-webkit-tap-highlight-color:transparent;border-radius:.125rem;font-size:var(--mdui-typescale-label-large-size);font-weight:var(--mdui-typescale-label-large-weight);letter-spacing:var(--mdui-typescale-label-large-tracking);line-height:var(--mdui-typescale-label-large-line-height)}label{display:inline-flex;align-items:center;width:100%;cursor:inherit;-webkit-user-select:none;user-select:none;touch-action:manipulation;zoom:1;-webkit-user-drag:none}input{position:absolute;padding:0;opacity:0;pointer-events:none;width:1.125rem;height:1.125rem;margin:0 0 0 .6875rem}.icon{display:flex;position:absolute;opacity:1;transform:scale(1);color:rgb(var(--mdui-color-on-surface));font-size:1.5rem;transition:color var(--mdui-motion-duration-short4) var(--mdui-motion-easing-standard)}.checked-icon,.indeterminate-icon{opacity:0;transform:scale(.5);transition-property:color,opacity,transform;transition-duration:var(--mdui-motion-duration-short4);transition-timing-function:var(--mdui-motion-easing-standard)}.icon .i,::slotted([slot=checked-icon]),::slotted([slot=indeterminate-icon]),::slotted([slot=unchecked-icon]){color:inherit;font-size:inherit}i{position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden;border-radius:50%;width:2.5rem;min-width:2.5rem;height:2.5rem;--mdui-comp-ripple-state-layer-color:var(--mdui-color-on-surface)}.label{display:flex;width:100%;padding-top:.625rem;padding-bottom:.625rem;color:rgb(var(--mdui-color-on-surface));transition:color var(--mdui-motion-duration-short4) var(--mdui-motion-easing-standard)}:host([checked]) i{--mdui-comp-ripple-state-layer-color:var(--mdui-color-primary)}:host([checked]) .icon{color:rgb(var(--mdui-color-primary))}:host([checked]) .indeterminate-icon{opacity:0;transform:scale(.5)}:host([checked]) .checked-icon{opacity:1;transform:scale(1)}:host([indeterminate]) i{--mdui-comp-ripple-state-layer-color:var(--mdui-color-primary)}:host([indeterminate]) .icon{color:rgb(var(--mdui-color-primary))}:host([indeterminate]) .checked-icon{opacity:0;transform:scale(.5)}:host([indeterminate]) .indeterminate-icon{opacity:1;transform:scale(1)}.invalid i{--mdui-comp-ripple-state-layer-color:var(--mdui-color-error)}.invalid .icon{color:rgb(var(--mdui-color-error))}.invalid .label{color:rgb(var(--mdui-color-error))}:host([disabled]){cursor:default;pointer-events:none}:host([disabled]) .icon{color:rgba(var(--mdui-color-on-surface),38%)}:host([disabled]) .label{color:rgba(var(--mdui-color-on-surface),38%)}:host([disabled][checked]) .unchecked-icon,:host([disabled][indeterminate]) .unchecked-icon{opacity:0}`;
2
+ export const style = css `
3
+ :host {
4
+ position: relative;
5
+ display: inline-flex;
6
+ cursor: pointer;
7
+ -webkit-tap-highlight-color: transparent;
8
+ border-radius: 0.125rem;
9
+ font-size: var(--mdui-typescale-label-large-size);
10
+ font-weight: var(--mdui-typescale-label-large-weight);
11
+ letter-spacing: var(--mdui-typescale-label-large-tracking);
12
+ line-height: var(--mdui-typescale-label-large-line-height);
13
+ }
14
+ label {
15
+ display: inline-flex;
16
+ align-items: center;
17
+ width: 100%;
18
+ cursor: inherit;
19
+ -webkit-user-select: none;
20
+ user-select: none;
21
+ touch-action: manipulation;
22
+ zoom: 1;
23
+ -webkit-user-drag: none;
24
+ }
25
+ /* 隐藏系统 input 标签,用自定义的图标代替 */
26
+ input {
27
+ position: absolute;
28
+ padding: 0;
29
+ opacity: 0;
30
+ pointer-events: none;
31
+ width: 1.125rem;
32
+ height: 1.125rem;
33
+ margin: 0rem 0rem 0rem 0.6875rem;
34
+ }
35
+ .icon {
36
+ display: flex;
37
+ position: absolute;
38
+ opacity: 1;
39
+ transform: scale(1);
40
+ color: rgb(var(--mdui-color-on-surface));
41
+ font-size: 1.5rem;
42
+ transition: color var(--mdui-motion-duration-short4)
43
+ var(--mdui-motion-easing-standard);
44
+ }
45
+ .checked-icon,
46
+ .indeterminate-icon {
47
+ opacity: 0;
48
+ transform: scale(0.5);
49
+ transition-property: color, opacity, transform;
50
+ transition-duration: var(--mdui-motion-duration-short4);
51
+ transition-timing-function: var(--mdui-motion-easing-standard);
52
+ }
53
+ .icon .i,
54
+ ::slotted([slot='unchecked-icon']),
55
+ ::slotted([slot='checked-icon']),
56
+ ::slotted([slot='indeterminate-icon']) {
57
+ color: inherit;
58
+ font-size: inherit;
59
+ }
60
+ i {
61
+ position: relative;
62
+ display: flex;
63
+ align-items: center;
64
+ justify-content: center;
65
+ overflow: hidden;
66
+ border-radius: 50%;
67
+ width: 2.5rem;
68
+ min-width: 2.5rem;
69
+ height: 2.5rem;
70
+ --mdui-comp-ripple-state-layer-color: var(--mdui-color-on-surface);
71
+ }
72
+ .label {
73
+ display: flex;
74
+ width: 100%;
75
+ padding-top: 0.625rem;
76
+ padding-bottom: 0.625rem;
77
+ color: rgb(var(--mdui-color-on-surface));
78
+ transition: color var(--mdui-motion-duration-short4)
79
+ var(--mdui-motion-easing-standard);
80
+ }
81
+ :host([checked]) i {
82
+ --mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
83
+ }
84
+ :host([checked]) .icon {
85
+ color: rgb(var(--mdui-color-primary));
86
+ }
87
+ :host([checked]) .indeterminate-icon {
88
+ opacity: 0;
89
+ transform: scale(0.5);
90
+ }
91
+ :host([checked]) .checked-icon {
92
+ opacity: 1;
93
+ transform: scale(1);
94
+ }
95
+ :host([indeterminate]) i {
96
+ --mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
97
+ }
98
+ :host([indeterminate]) .icon {
99
+ color: rgb(var(--mdui-color-primary));
100
+ }
101
+ :host([indeterminate]) .checked-icon {
102
+ opacity: 0;
103
+ transform: scale(0.5);
104
+ }
105
+ :host([indeterminate]) .indeterminate-icon {
106
+ opacity: 1;
107
+ transform: scale(1);
108
+ }
109
+ .invalid i {
110
+ --mdui-comp-ripple-state-layer-color: var(--mdui-color-error);
111
+ }
112
+ .invalid .icon {
113
+ color: rgb(var(--mdui-color-error));
114
+ }
115
+ .invalid .label {
116
+ color: rgb(var(--mdui-color-error));
117
+ }
118
+ :host([disabled]) {
119
+ cursor: default;
120
+ pointer-events: none;
121
+ }
122
+ :host([disabled]) .icon {
123
+ color: rgba(var(--mdui-color-on-surface), 38%);
124
+ }
125
+ :host([disabled]) .label {
126
+ color: rgba(var(--mdui-color-on-surface), 38%);
127
+ }
128
+ :host([disabled][checked]) .unchecked-icon,
129
+ :host([disabled][indeterminate]) .unchecked-icon {
130
+ opacity: 0;
131
+ }
132
+ `;
@@ -17,35 +17,35 @@ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
17
17
  * @event change - 选中状态变更时触发
18
18
  * @event delete - 点击删除图标时触发
19
19
  *
20
- * @slot - 文本
20
+ * @slot - 纸片文本
21
21
  * @slot icon - 左侧元素
22
22
  * @slot end-icon - 右侧元素
23
- * @slot selected-icon - 选中状态的左侧元素
24
- * @slot delete-icon - 可删除时,右侧的删除元素
23
+ * @slot selected-icon - 选中状态下的左侧元素
24
+ * @slot delete-icon - 可删除时的右侧删除元素
25
25
  *
26
- * @csspart button - 内部的 `button``a` 元素
27
- * @csspart label - 文本
26
+ * @csspart button - 内部的 `<button>``<a>` 元素
27
+ * @csspart label - 纸片文本
28
28
  * @csspart icon - 左侧图标
29
29
  * @csspart end-icon - 右侧图标
30
- * @csspart selected-icon - 选中状态的左侧图标
31
- * @csspart delete-icon - 可删除时,右侧的删除图标
30
+ * @csspart selected-icon - 选中状态下的左侧图标
31
+ * @csspart delete-icon - 可删除时的右侧删除图标
32
32
  * @csspart loading - 加载中状态的 `<mdui-circular-progress>` 元素
33
33
  *
34
- * @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
34
+ * @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
35
35
  */
36
36
  export declare class Chip extends ButtonBase<ChipEventMap> {
37
37
  static styles: CSSResultGroup;
38
38
  /**
39
- * 纸片形状。可选值为:
39
+ * 纸片的形状。可选值包括:
40
40
  *
41
- * * `assist`:用于显示和当前上下文相关的辅助操作。例如在点餐页面,提供分享,收藏等功能
42
- * * `filter`:用于对内容进行筛选。例如在搜索结果页,对搜索结果进行过滤
43
- * * `input`:用于表示用户输入的信息片段。例如 Gmail 中“收件人”字段中的联系人
44
- * * `suggestion`:用于提供动态生成的推荐信息,以简化用户操作。例如在聊天应用中猜测用户可能想发送的信息,供用户选择
41
+ * * `assist`:用于显示与当前上下文相关的辅助操作,如在点餐页面提供分享、收藏等功能
42
+ * * `filter`:用于对内容进行筛选,如在搜索结果页过滤搜索结果
43
+ * * `input`:用于表示用户输入的信息片段,如在 Gmail 的“收件人”字段中的联系人
44
+ * * `suggestion`:用于提供动态生成的推荐信息,以简化用户操作,如在聊天应用中预测用户可能想发送的信息
45
45
  */
46
- variant: /*用于显示和当前上下文相关的辅助操作。例如在点餐页面,提供分享,收藏等功能*/ 'assist' | /*用于对内容进行筛选。例如在搜索结果页,对搜索结果进行过滤*/ 'filter' | /*用于表示用户输入的信息片段。例如 Gmail 中“收件人”字段中的联系人*/ 'input' | /*用于提供动态生成的推荐信息,以简化用户操作。例如在聊天应用中猜测用户可能想发送的信息,供用户选择*/ 'suggestion';
46
+ variant: /*用于显示与当前上下文相关的辅助操作,如在点餐页面提供分享、收藏等功能*/ 'assist' | /*用于对内容进行筛选,如在搜索结果页过滤搜索结果*/ 'filter' | /*用于表示用户输入的信息片段,如在 Gmail 的“收件人”字段中的联系人*/ 'input' | /*用于提供动态生成的推荐信息,以简化用户操作,如在聊天应用中预测用户可能想发送的信息*/ 'suggestion';
47
47
  /**
48
- * 是否包含阴影
48
+ * 是否显示阴影
49
49
  */
50
50
  elevated: boolean;
51
51
  /**
@@ -53,11 +53,11 @@ export declare class Chip extends ButtonBase<ChipEventMap> {
53
53
  */
54
54
  selectable: boolean;
55
55
  /**
56
- * 是否为选中状态
56
+ * 是否已选中
57
57
  */
58
58
  selected: boolean;
59
59
  /**
60
- * 是否可删除。为 `true` 时,在右侧会显示删除图标图标
60
+ * 是否可删除。为 `true` 时,纸片右侧会显示删除图标
61
61
  */
62
62
  deletable: boolean;
63
63
  /**
@@ -65,7 +65,7 @@ export declare class Chip extends ButtonBase<ChipEventMap> {
65
65
  */
66
66
  icon?: string;
67
67
  /**
68
- * 选中状态,左侧的 Material Icons 图标名。也可以通过 `slot="selected-icon"` 设置
68
+ * 选中状态下左侧的 Material Icons 图标名。也可以通过 `slot="selected-icon"` 设置
69
69
  */
70
70
  selectedIcon?: string;
71
71
  /**
@@ -73,7 +73,7 @@ export declare class Chip extends ButtonBase<ChipEventMap> {
73
73
  */
74
74
  endIcon?: string;
75
75
  /**
76
- * 右侧的 Material Icons 图标名。也可以通过 `slot="delete-icon"` 设置
76
+ * 可删除时,右侧删除图标的 Material Icons 图标名。也可以通过 `slot="delete-icon"` 设置
77
77
  */
78
78
  deleteIcon?: string;
79
79
  private readonly rippleRef;