mdui 2.0.5 → 2.1.0

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 (249) hide show
  1. package/components/avatar/index.js +2 -7
  2. package/components/avatar/style.js +1 -31
  3. package/components/badge/style.js +1 -25
  4. package/components/bottom-app-bar/style.js +1 -92
  5. package/components/button/button-base-style.js +1 -28
  6. package/components/button/button-base.js +1 -8
  7. package/components/button/index.js +8 -18
  8. package/components/button/style.js +2 -111
  9. package/components/button-icon/index.js +5 -22
  10. package/components/button-icon/style.js +2 -103
  11. package/components/card/index.js +1 -5
  12. package/components/card/style.js +1 -72
  13. package/components/checkbox/index.js +7 -50
  14. package/components/checkbox/style.js +1 -131
  15. package/components/chip/index.js +9 -33
  16. package/components/chip/style.js +2 -205
  17. package/components/circular-progress/index.js +5 -39
  18. package/components/circular-progress/style.js +1 -136
  19. package/components/collapse/collapse-item-style.js +1 -21
  20. package/components/collapse/collapse-item.js +2 -10
  21. package/components/collapse/collapse-style.js +1 -5
  22. package/components/collapse/collapse.js +1 -4
  23. package/components/dialog/index.js +10 -35
  24. package/components/dialog/style.js +1 -116
  25. package/components/divider/style.js +1 -18
  26. package/components/dropdown/index.js +1 -8
  27. package/components/dropdown/style.js +1 -11
  28. package/components/fab/index.js +5 -13
  29. package/components/fab/style.js +4 -153
  30. package/components/icon/index.js +1 -5
  31. package/components/icon/style.js +1 -29
  32. package/components/layout/layout-item-style.js +1 -6
  33. package/components/layout/layout-main-style.js +1 -7
  34. package/components/layout/layout-style.js +1 -11
  35. package/components/linear-progress/index.js +2 -6
  36. package/components/linear-progress/style.js +1 -73
  37. package/components/list/list-item-style.js +2 -153
  38. package/components/list/list-item.js +8 -27
  39. package/components/list/list-style.js +1 -10
  40. package/components/list/list-subheader-style.js +1 -19
  41. package/components/menu/menu-item-style.js +1 -125
  42. package/components/menu/menu-item.js +13 -55
  43. package/components/menu/menu-style.js +1 -19
  44. package/components/menu/menu.js +1 -5
  45. package/components/navigation-bar/navigation-bar-item-style.js +1 -132
  46. package/components/navigation-bar/navigation-bar-item.js +7 -23
  47. package/components/navigation-bar/navigation-bar-style.js +1 -28
  48. package/components/navigation-bar/navigation-bar.js +1 -4
  49. package/components/navigation-drawer/index.js +1 -12
  50. package/components/navigation-drawer/style.js +1 -66
  51. package/components/navigation-rail/navigation-rail-item-style.js +1 -122
  52. package/components/navigation-rail/navigation-rail-item.js +7 -26
  53. package/components/navigation-rail/navigation-rail-style.js +1 -79
  54. package/components/navigation-rail/navigation-rail.js +1 -10
  55. package/components/radio/radio-group-style.js +1 -20
  56. package/components/radio/radio-group.js +1 -19
  57. package/components/radio/radio-style.js +1 -107
  58. package/components/radio/radio.js +5 -23
  59. package/components/range-slider/index.d.ts +1 -1
  60. package/components/range-slider/index.js +5 -53
  61. package/components/ripple/index.js +2 -5
  62. package/components/ripple/style.js +1 -96
  63. package/components/segmented-button/segmented-button-group-style.js +1 -28
  64. package/components/segmented-button/segmented-button-group.js +1 -21
  65. package/components/segmented-button/segmented-button-style.js +2 -81
  66. package/components/segmented-button/segmented-button.js +11 -27
  67. package/components/select/index.d.ts +18 -0
  68. package/components/select/index.js +42 -87
  69. package/components/select/style.js +1 -27
  70. package/components/slider/index.js +2 -33
  71. package/components/slider/slider-base-style.js +1 -173
  72. package/components/slider/slider-base.js +1 -6
  73. package/components/slider/style.js +1 -7
  74. package/components/snackbar/index.js +5 -32
  75. package/components/snackbar/style.js +1 -100
  76. package/components/switch/index.js +6 -40
  77. package/components/switch/style.js +1 -202
  78. package/components/tabs/tab-panel-style.js +1 -10
  79. package/components/tabs/tab-style.js +1 -85
  80. package/components/tabs/tab.js +4 -24
  81. package/components/tabs/tabs-style.js +1 -138
  82. package/components/tabs/tabs.js +1 -9
  83. package/components/text-field/index.d.ts +2 -0
  84. package/components/text-field/index.js +58 -163
  85. package/components/text-field/style.js +1 -362
  86. package/components/tooltip/index.js +1 -10
  87. package/components/tooltip/style.js +1 -57
  88. package/components/top-app-bar/top-app-bar-style.js +1 -78
  89. package/components/top-app-bar/top-app-bar-title-style.js +1 -81
  90. package/components/top-app-bar/top-app-bar-title.js +3 -17
  91. package/custom-elements.json +1194 -1099
  92. package/functions/alert.d.ts +2 -0
  93. package/functions/alert.js +19 -4
  94. package/functions/confirm.d.ts +4 -0
  95. package/functions/confirm.js +33 -6
  96. package/functions/getLocale.d.ts +6 -0
  97. package/functions/getLocale.js +11 -0
  98. package/functions/getTheme.d.ts +1 -1
  99. package/functions/loadLocale.d.ts +6 -0
  100. package/functions/loadLocale.js +8 -0
  101. package/functions/prompt.d.ts +4 -0
  102. package/functions/prompt.js +35 -8
  103. package/functions/removeColorScheme.js +1 -1
  104. package/functions/setColorScheme.d.ts +1 -1
  105. package/functions/setColorScheme.js +1 -1
  106. package/functions/setLocale.d.ts +6 -0
  107. package/functions/setLocale.js +11 -0
  108. package/functions/setTheme.d.ts +1 -1
  109. package/internal/localeCodes.d.ts +13 -0
  110. package/internal/localeCodes.js +144 -0
  111. package/internal/localize.d.ts +32 -0
  112. package/internal/localize.js +55 -0
  113. package/locales/ar-eg.d.ts +8 -0
  114. package/locales/ar-eg.js +12 -0
  115. package/locales/az-az.d.ts +8 -0
  116. package/locales/az-az.js +12 -0
  117. package/locales/be-by.d.ts +8 -0
  118. package/locales/be-by.js +12 -0
  119. package/locales/bg-bg.d.ts +8 -0
  120. package/locales/bg-bg.js +12 -0
  121. package/locales/bn-bd.d.ts +8 -0
  122. package/locales/bn-bd.js +12 -0
  123. package/locales/ca-es.d.ts +8 -0
  124. package/locales/ca-es.js +12 -0
  125. package/locales/cs-cz.d.ts +8 -0
  126. package/locales/cs-cz.js +12 -0
  127. package/locales/da-dk.d.ts +8 -0
  128. package/locales/da-dk.js +12 -0
  129. package/locales/de-de.d.ts +8 -0
  130. package/locales/de-de.js +12 -0
  131. package/locales/el-gr.d.ts +8 -0
  132. package/locales/el-gr.js +12 -0
  133. package/locales/en-gb.d.ts +8 -0
  134. package/locales/en-gb.js +12 -0
  135. package/locales/es-es.d.ts +8 -0
  136. package/locales/es-es.js +12 -0
  137. package/locales/et-ee.d.ts +8 -0
  138. package/locales/et-ee.js +12 -0
  139. package/locales/fa-ir.d.ts +8 -0
  140. package/locales/fa-ir.js +12 -0
  141. package/locales/fi-fi.d.ts +8 -0
  142. package/locales/fi-fi.js +12 -0
  143. package/locales/fr-be.d.ts +8 -0
  144. package/locales/fr-be.js +12 -0
  145. package/locales/fr-ca.d.ts +8 -0
  146. package/locales/fr-ca.js +12 -0
  147. package/locales/fr-fr.d.ts +8 -0
  148. package/locales/fr-fr.js +12 -0
  149. package/locales/ga-ie.d.ts +8 -0
  150. package/locales/ga-ie.js +12 -0
  151. package/locales/gl-es.d.ts +8 -0
  152. package/locales/gl-es.js +12 -0
  153. package/locales/he-il.d.ts +8 -0
  154. package/locales/he-il.js +12 -0
  155. package/locales/hi-in.d.ts +8 -0
  156. package/locales/hi-in.js +12 -0
  157. package/locales/hr-hr.d.ts +8 -0
  158. package/locales/hr-hr.js +12 -0
  159. package/locales/hu-hu.d.ts +8 -0
  160. package/locales/hu-hu.js +12 -0
  161. package/locales/hy-am.d.ts +8 -0
  162. package/locales/hy-am.js +12 -0
  163. package/locales/id-id.d.ts +8 -0
  164. package/locales/id-id.js +12 -0
  165. package/locales/is-is.d.ts +8 -0
  166. package/locales/is-is.js +12 -0
  167. package/locales/it-it.d.ts +8 -0
  168. package/locales/it-it.js +12 -0
  169. package/locales/ja-jp.d.ts +8 -0
  170. package/locales/ja-jp.js +12 -0
  171. package/locales/ka-ge.d.ts +8 -0
  172. package/locales/ka-ge.js +12 -0
  173. package/locales/kk-kz.d.ts +8 -0
  174. package/locales/kk-kz.js +12 -0
  175. package/locales/km-kh.d.ts +8 -0
  176. package/locales/km-kh.js +12 -0
  177. package/locales/kmr-iq.d.ts +8 -0
  178. package/locales/kmr-iq.js +12 -0
  179. package/locales/kn-in.d.ts +8 -0
  180. package/locales/kn-in.js +12 -0
  181. package/locales/ko-kr.d.ts +8 -0
  182. package/locales/ko-kr.js +12 -0
  183. package/locales/lt-lt.d.ts +8 -0
  184. package/locales/lt-lt.js +12 -0
  185. package/locales/lv-lv.d.ts +8 -0
  186. package/locales/lv-lv.js +12 -0
  187. package/locales/mk-mk.d.ts +8 -0
  188. package/locales/mk-mk.js +12 -0
  189. package/locales/ml-in.d.ts +8 -0
  190. package/locales/ml-in.js +12 -0
  191. package/locales/mn-mn.d.ts +8 -0
  192. package/locales/mn-mn.js +12 -0
  193. package/locales/ms-my.d.ts +8 -0
  194. package/locales/ms-my.js +12 -0
  195. package/locales/nb-no.d.ts +8 -0
  196. package/locales/nb-no.js +12 -0
  197. package/locales/ne-np.d.ts +8 -0
  198. package/locales/ne-np.js +12 -0
  199. package/locales/nl-be.d.ts +8 -0
  200. package/locales/nl-be.js +12 -0
  201. package/locales/nl-nl.d.ts +8 -0
  202. package/locales/nl-nl.js +12 -0
  203. package/locales/pl-pl.d.ts +8 -0
  204. package/locales/pl-pl.js +12 -0
  205. package/locales/pt-br.d.ts +8 -0
  206. package/locales/pt-br.js +12 -0
  207. package/locales/pt-pt.d.ts +8 -0
  208. package/locales/pt-pt.js +12 -0
  209. package/locales/ro-ro.d.ts +8 -0
  210. package/locales/ro-ro.js +12 -0
  211. package/locales/ru-ru.d.ts +8 -0
  212. package/locales/ru-ru.js +12 -0
  213. package/locales/sk-sk.d.ts +8 -0
  214. package/locales/sk-sk.js +12 -0
  215. package/locales/sl-si.d.ts +8 -0
  216. package/locales/sl-si.js +12 -0
  217. package/locales/sr-rs.d.ts +8 -0
  218. package/locales/sr-rs.js +12 -0
  219. package/locales/sv-se.d.ts +8 -0
  220. package/locales/sv-se.js +12 -0
  221. package/locales/ta-in.d.ts +8 -0
  222. package/locales/ta-in.js +12 -0
  223. package/locales/th-th.d.ts +8 -0
  224. package/locales/th-th.js +12 -0
  225. package/locales/tr-tr.d.ts +8 -0
  226. package/locales/tr-tr.js +12 -0
  227. package/locales/uk-ua.d.ts +8 -0
  228. package/locales/uk-ua.js +12 -0
  229. package/locales/ur-pk.d.ts +8 -0
  230. package/locales/ur-pk.js +12 -0
  231. package/locales/vi-vn.d.ts +8 -0
  232. package/locales/vi-vn.js +12 -0
  233. package/locales/zh-cn.d.ts +8 -0
  234. package/locales/zh-cn.js +12 -0
  235. package/locales/zh-hk.d.ts +8 -0
  236. package/locales/zh-hk.js +12 -0
  237. package/locales/zh-tw.d.ts +8 -0
  238. package/locales/zh-tw.js +12 -0
  239. package/mdui.d.ts +5 -0
  240. package/mdui.esm.js +22 -0
  241. package/mdui.global.js +22 -0
  242. package/mdui.js +3 -0
  243. package/package.json +9 -6
  244. package/web-types.en.json +91 -1
  245. package/web-types.zh-cn.json +91 -1
  246. /package/{functions/utils → internal}/colorScheme.d.ts +0 -0
  247. /package/{functions/utils → internal}/colorScheme.js +0 -0
  248. /package/{functions/utils → internal}/theme.d.ts +0 -0
  249. /package/{functions/utils → internal}/theme.js +0 -0
@@ -46,7 +46,25 @@ import { style } from './style.js';
46
46
  * @slot clear-icon - 清空按钮中的图标
47
47
  * @slot helper - 底部的帮助文本
48
48
  *
49
+ * @csspart chips - 多选时,放置选中值对应的 chip 的容器
50
+ * @csspart chip - 多选时,每一个选中的值对应的 chip
51
+ * @csspart chip__button - chip 内部的 `<button>` 元素
52
+ * @csspart chip__label - chip 内部的文本
53
+ * @csspart chip__delete-icon - chip 内部的删除图标
49
54
  * @csspart text-field - 文本框,即 [`<mdui-text-field>`](/docs/2/components/text-field) 元素
55
+ * @csspart text-field__container - text-field 内部的文本框容器
56
+ * @csspart text-field__icon - text-field 内部的左侧图标
57
+ * @csspart text-field__end-icon - text-field 内部的右侧图标
58
+ * @csspart text-field__error-icon - text-field 内部的验证失败状态的右侧图标
59
+ * @csspart text-field__prefix - text-field 内部的左侧文本
60
+ * @csspart text-field__suffix - text-field 内部的右侧文本
61
+ * @csspart text-field__label - text-field 内部的标签文本
62
+ * @csspart text-field__input - text-field 内部的 `<input>` 元素
63
+ * @csspart text-field__clear-button - text-field 内部的清空按钮
64
+ * @csspart text-field__clear-icon - text-field 内部的清空按钮中的图标
65
+ * @csspart text-field__supporting - text-field 内部的底部辅助信息容器,包括 helper 和 error
66
+ * @csspart text-field__helper - text-field 内部的底部帮助文本
67
+ * @csspart text-field__error - text-field 内部的底部错误描述文本
50
68
  * @csspart menu - 下拉菜单,即 [`<mdui-menu>`](/docs/2/components/menu) 元素
51
69
  */
52
70
  let Select = class Select extends FocusableMixin(MduiElement) {
@@ -204,75 +222,32 @@ let Select = class Select extends FocusableMixin(MduiElement) {
204
222
  render() {
205
223
  const hasSelection = this.multiple ? !!this.value.length : !!this.value;
206
224
  return html `${this.multiple
207
- ? html `<select
208
- ${ref(this.hiddenInputRef)}
209
- class="hidden-input"
210
- name=${ifDefined(this.name)}
211
- value=${ifDefined(this.value)}
212
- .required=${this.required}
213
- .disabled=${this.disabled}
214
- multiple
215
- tabindex="-1"
216
- >
217
- ${map(this.value, (value) => html `<option selected value=${value}></option>`)}
218
- </select>`
219
- : html `<input
220
- ${ref(this.hiddenInputRef)}
221
- type="radio"
222
- class="hidden-input"
223
- name=${ifDefined(this.name)}
224
- value=${ifDefined(this.value)}
225
- .required=${this.required}
226
- .disabled=${this.disabled}
227
- .checked=${hasSelection}
228
- tabindex="-1"
229
- />`}
230
- <mdui-dropdown
231
- .stayOpenOnClick=${this.multiple}
232
- .disabled=${this.readonly || this.disabled}
233
- .placement=${this.placement === 'top'
225
+ ? html `<select ${ref(this.hiddenInputRef)} class="hidden-input" name="${ifDefined(this.name)}" value="${ifDefined(this.value)}" .required="${this.required}" .disabled="${this.disabled}" multiple="multiple" tabindex="-1">${map(this.value, (value) => html `<option selected="selected" value="${value}"></option>`)}</select>`
226
+ : html `<input ${ref(this.hiddenInputRef)} type="radio" class="hidden-input" name="${ifDefined(this.name)}" value="${ifDefined(this.value)}" .required="${this.required}" .disabled="${this.disabled}" .checked="${hasSelection}" tabindex="-1">`}<mdui-dropdown .stayOpenOnClick="${this.multiple}" .disabled="${this.readonly || this.disabled}" .placement="${this.placement === 'top'
234
227
  ? 'top-start'
235
228
  : this.placement === 'bottom'
236
229
  ? 'bottom-start'
237
- : 'auto'}
238
- @open=${this.onDropdownOpen}
239
- @close=${this.onDropdownClose}
240
- >
241
- <mdui-text-field
242
- ${ref(this.textFieldRef)}
243
- slot="trigger"
244
- part="text-field"
245
- class="text-field"
246
- readonly
247
- .readonlyButClearable=${true}
248
- .variant=${this.variant}
249
- .name=${this.name}
250
- .value=${this.multiple
230
+ : 'auto'}" @open="${this.onDropdownOpen}" @close="${this.onDropdownClose}"><mdui-text-field ${ref(this.textFieldRef)} slot="trigger" part="text-field" class="text-field" exportparts="${[
231
+ 'container',
232
+ 'icon',
233
+ 'end-icon',
234
+ 'error-icon',
235
+ 'prefix',
236
+ 'suffix',
237
+ 'label',
238
+ 'input',
239
+ 'clear-button',
240
+ 'clear-icon',
241
+ 'supporting',
242
+ 'helper',
243
+ 'error',
244
+ ]
245
+ .map((v) => `${v}:text-field__${v}`)
246
+ .join(',')}" readonly="readonly" .readonlyButClearable="${true}" .variant="${this.variant}" .name="${this.name}" .value="${this.multiple
251
247
  ? this.value.length
252
248
  ? ' '
253
249
  : ''
254
- : this.getMenuItemLabelByValue(this.value)}
255
- .label=${this.label}
256
- .placeholder=${this.placeholder}
257
- .helper=${this.helper}
258
- .error=${this.hiddenInputRef.value?.validationMessage}
259
- .clearable=${this.clearable}
260
- .clearIcon=${this.clearIcon}
261
- .endAligned=${this.endAligned}
262
- .prefix=${this.prefix}
263
- .suffix=${this.suffix}
264
- .icon=${this.icon}
265
- .endIcon=${this.endIcon}
266
- .errorIcon=${this.errorIcon}
267
- .form=${this.form}
268
- .disabled=${this.disabled}
269
- .required=${this.required}
270
- .invalidStyle=${this.invalid}
271
- @clear=${this.onClear}
272
- @change=${(e) => e.stopPropagation()}
273
- @keydown=${this.onTextFieldKeyDown}
274
- >
275
- ${map([
250
+ : this.getMenuItemLabelByValue(this.value)}" .label="${this.label}" .placeholder="${this.placeholder}" .helper="${this.helper}" .error="${this.hiddenInputRef.value?.validationMessage}" .clearable="${this.clearable}" .clearIcon="${this.clearIcon}" .endAligned="${this.endAligned}" .prefix="${this.prefix}" .suffix="${this.suffix}" .icon="${this.icon}" .endIcon="${this.endIcon}" .errorIcon="${this.errorIcon}" .form="${this.form}" .disabled="${this.disabled}" .required="${this.required}" .invalidStyle="${this.invalid}" @clear="${this.onClear}" @change="${(e) => e.stopPropagation()}" @keydown="${this.onTextFieldKeyDown}">${map([
276
251
  'icon',
277
252
  'end-icon',
278
253
  'error-icon',
@@ -282,30 +257,10 @@ let Select = class Select extends FocusableMixin(MduiElement) {
282
257
  'clear-icon',
283
258
  'helper',
284
259
  ], (slotName) => this.hasSlotController.test(slotName)
285
- ? html `<slot name=${slotName} slot=${slotName}></slot>`
286
- : nothing)}
287
- ${when(this.multiple && this.value.length, () => html `<div slot="input" class="chips">
288
- ${map(this.value, (valueItem) => html `<mdui-chip
289
- class="chip"
290
- variant="input"
291
- deletable
292
- tabindex="-1"
293
- @delete=${() => this.onDeleteOneValue(valueItem)}
294
- >
295
- ${this.getMenuItemLabelByValue(valueItem)}
296
- </mdui-chip>`)}
297
- </div>`)}
298
- </mdui-text-field>
299
- <mdui-menu
300
- ${ref(this.menuRef)}
301
- part="menu"
302
- .selects=${this.multiple ? 'multiple' : 'single'}
303
- .value=${this.value}
304
- @change=${this.onValueChange}
305
- >
306
- <slot></slot>
307
- </mdui-menu>
308
- </mdui-dropdown>`;
260
+ ? html `<slot name="${slotName}" slot="${slotName}"></slot>`
261
+ : nothing)} ${when(this.multiple && this.value.length, () => html `<div slot="input" class="chips" part="chips">${map(this.value, (valueItem) => html `<mdui-chip class="chip" part="chip" exportparts="${['button', 'label', 'delete-icon']
262
+ .map((v) => `${v}:chip__${v}`)
263
+ .join(',')}" variant="input" deletable tabindex="-1" @delete="${() => this.onDeleteOneValue(valueItem)}">${this.getMenuItemLabelByValue(valueItem)}</mdui-chip>`)}</div>`)}</mdui-text-field><mdui-menu ${ref(this.menuRef)} part="menu" .selects="${this.multiple ? 'multiple' : 'single'}" .value="${this.value}" @change="${this.onValueChange}"><slot></slot></mdui-menu></mdui-dropdown>`;
309
264
  }
310
265
  getMenuItemLabelByValue(valueItem) {
311
266
  if (!this.menuItems.length) {
@@ -1,28 +1,2 @@
1
1
  import { css } from 'lit';
2
- export const style = css `
3
- :host {
4
- display: inline-block;
5
- width: 100%;
6
- }
7
- .hidden-input {
8
- display: none;
9
- }
10
- .text-field {
11
- cursor: pointer;
12
- }
13
- .chips {
14
- display: flex;
15
- flex-wrap: wrap;
16
- margin: -0.5rem -0.25rem;
17
- min-height: 2.5rem;
18
- }
19
- :host([variant='filled'][label]) .chips {
20
- margin: 0rem -0.25rem -1rem -0.25rem;
21
- }
22
- .chip {
23
- margin: 0.25rem;
24
- }
25
- mdui-menu {
26
- max-width: none;
27
- }
28
- `;
2
+ export const style = css `:host{display:inline-block;width:100%}.hidden-input{display:none}.text-field{cursor:pointer}.chips{display:flex;flex-wrap:wrap;margin:-.5rem -.25rem;min-height:2.5rem}:host([variant=filled][label]) .chips{margin:0 -.25rem -1rem -.25rem}.chip{margin:.25rem}mdui-menu{max-width:none}`;
@@ -90,41 +90,10 @@ let Slider = class Slider extends SliderBase {
90
90
  * <input class="invalid" /> 用于提供 html5 自带的表单错误提示
91
91
  */
92
92
  render() {
93
- return html `<label class=${classMap({ invalid: this.invalid })}>
94
- <input
95
- ${ref(this.inputRef)}
96
- type="range"
97
- step=${this.step}
98
- min=${this.min}
99
- max=${this.max}
100
- ?disabled=${this.disabled}
101
- .value=${live(this.value.toString())}
102
- @input=${this.onInput}
103
- @change=${this.onChange}
104
- />
105
- <div part="track-inactive" class="track-inactive"></div>
106
- <div
107
- ${ref(this.trackActiveRef)}
108
- part="track-active"
109
- class="track-active"
110
- ></div>
111
- <div ${ref(this.handleRef)} part="handle" class="handle">
112
- <div class="elevation"></div>
113
- <mdui-ripple
114
- ${ref(this.rippleRef)}
115
- .noRipple=${this.noRipple}
116
- ></mdui-ripple>
117
- ${this.renderLabel(this.value)}
118
- </div>
119
- ${when(this.tickmarks, () => map(this.getCandidateValues(), (value) => html `<div
120
- part="tickmark"
121
- class="tickmark ${classMap({ active: value < this.value })}"
122
- style="${styleMap({
93
+ return html `<label class="${classMap({ invalid: this.invalid })}"><input ${ref(this.inputRef)} type="range" step="${this.step}" min="${this.min}" max="${this.max}" ?disabled="${this.disabled}" .value="${live(this.value.toString())}" @input="${this.onInput}" @change="${this.onChange}"><div part="track-inactive" class="track-inactive"></div><div ${ref(this.trackActiveRef)} part="track-active" class="track-active"></div><div ${ref(this.handleRef)} part="handle" class="handle"><div class="elevation"></div><mdui-ripple ${ref(this.rippleRef)} .noRipple="${this.noRipple}"></mdui-ripple>${this.renderLabel(this.value)}</div>${when(this.tickmarks, () => map(this.getCandidateValues(), (value) => html `<div part="tickmark" class="tickmark ${classMap({ active: value < this.value })}" style="${styleMap({
123
94
  left: `${((value - this.min) / this.max) * 100}%`,
124
95
  display: value === this.value ? 'none' : 'block',
125
- })}"
126
- ></div>`))}
127
- </label>`;
96
+ })}"></div>`))}</label>`;
128
97
  }
129
98
  updateStyle() {
130
99
  const percent = ((this.value - this.min) / (this.max - this.min)) * 100;
@@ -1,174 +1,2 @@
1
1
  import { css } from 'lit';
2
- export const sliderBaseStyle = css `
3
- :host {
4
- position: relative;
5
- display: block;
6
- width: 100%;
7
- -webkit-tap-highlight-color: transparent;
8
- height: 2.5rem;
9
- padding: 0rem 1.25rem;
10
- }
11
- label {
12
- position: relative;
13
- display: block;
14
- width: 100%;
15
- height: 100%;
16
- }
17
- input[type='range'] {
18
- position: absolute;
19
- inset: 0;
20
- z-index: 4;
21
- height: 100%;
22
- cursor: pointer;
23
- opacity: 0;
24
- -webkit-appearance: none;
25
- appearance: none;
26
- width: calc(100% + 20rem * 2 / 16);
27
- margin: 0rem -1.25rem;
28
- padding: 0rem 0.75rem;
29
- }
30
- :host([disabled]) input[type='range'] {
31
- cursor: not-allowed;
32
- }
33
- .track-inactive,
34
- .track-active {
35
- position: absolute;
36
- top: 50%;
37
- height: 0.25rem;
38
- margin-top: -0.125rem;
39
- }
40
- .track-inactive {
41
- left: -0.125rem;
42
- right: -0.125rem;
43
- border-radius: var(--mdui-shape-corner-full);
44
- background-color: rgb(var(--mdui-color-surface-container-highest));
45
- }
46
- .invalid .track-inactive {
47
- background-color: rgba(var(--mdui-color-error), 0.12);
48
- }
49
- :host([disabled]) .track-inactive {
50
- background-color: rgba(var(--mdui-color-on-surface), 0.12);
51
- }
52
- .track-active {
53
- background-color: rgb(var(--mdui-color-primary));
54
- }
55
- .invalid .track-active {
56
- background-color: rgb(var(--mdui-color-error));
57
- }
58
- :host([disabled]) .track-active {
59
- background-color: rgba(var(--mdui-color-on-surface), 0.38);
60
- }
61
- .handle {
62
- position: absolute;
63
- top: 50%;
64
- transform: translate(-50%);
65
- cursor: pointer;
66
- z-index: 2;
67
- width: 2.5rem;
68
- height: 2.5rem;
69
- margin-top: -1.25rem;
70
- --mdui-comp-ripple-state-layer-color: var(--mdui-color-primary);
71
- }
72
- .invalid .handle {
73
- --mdui-comp-ripple-state-layer-color: var(--mdui-color-error);
74
- }
75
- .handle::before,
76
- .handle .elevation {
77
- position: absolute;
78
- display: block;
79
- content: ' ';
80
- left: 0.625rem;
81
- top: 0.625rem;
82
- width: 1.25rem;
83
- height: 1.25rem;
84
- border-radius: var(--mdui-shape-corner-full);
85
- }
86
- .handle .elevation {
87
- background-color: rgb(var(--mdui-color-primary));
88
- box-shadow: var(--mdui-elevation-level1);
89
- }
90
- .invalid .handle .elevation {
91
- background-color: rgb(var(--mdui-color-error));
92
- }
93
- :host([disabled]) .handle .elevation {
94
- background-color: rgba(var(--mdui-color-on-surface), 0.38);
95
- box-shadow: var(--mdui-elevation-level0);
96
- }
97
- .handle::before {
98
- background-color: rgb(var(--mdui-color-background));
99
- }
100
- .handle mdui-ripple {
101
- border-radius: var(--mdui-shape-corner-full);
102
- }
103
- .label {
104
- position: absolute;
105
- left: 50%;
106
- transform: translateX(-50%) scale(0);
107
- transform-origin: center bottom;
108
- display: flex;
109
- align-items: center;
110
- justify-content: center;
111
- cursor: default;
112
- white-space: nowrap;
113
- -webkit-user-select: none;
114
- user-select: none;
115
- pointer-events: none;
116
- transition: transform var(--mdui-motion-duration-short2)
117
- var(--mdui-motion-easing-standard);
118
- bottom: 2.5rem;
119
- min-width: 1.75rem;
120
- height: 1.75rem;
121
- padding: 0.375rem 0.5rem;
122
- border-radius: var(--mdui-shape-corner-full);
123
- color: rgb(var(--mdui-color-on-primary));
124
- font-size: var(--mdui-typescale-label-medium-size);
125
- font-weight: var(--mdui-typescale-label-medium-weight);
126
- letter-spacing: var(--mdui-typescale-label-medium-tracking);
127
- line-height: var(--mdui-typescale-label-medium-line-height);
128
- background-color: rgb(var(--mdui-color-primary));
129
- }
130
- .invalid .label {
131
- color: rgb(var(--mdui-color-on-error));
132
- background-color: rgb(var(--mdui-color-error));
133
- }
134
- .label::after {
135
- content: ' ';
136
- position: absolute;
137
- z-index: -1;
138
- transform: rotate(45deg);
139
- width: 0.875rem;
140
- height: 0.875rem;
141
- bottom: -0.125rem;
142
- background-color: rgb(var(--mdui-color-primary));
143
- }
144
- .invalid .label::after {
145
- background-color: rgb(var(--mdui-color-error));
146
- }
147
- .label-visible {
148
- transform: translateX(-50%) scale(1);
149
- transition: transform var(--mdui-motion-duration-short4)
150
- var(--mdui-motion-easing-standard);
151
- }
152
- .tickmark {
153
- position: absolute;
154
- top: 50%;
155
- transform: translate(-50%);
156
- width: 0.125rem;
157
- height: 0.125rem;
158
- margin-top: -0.0625rem;
159
- border-radius: var(--mdui-shape-corner-full);
160
- background-color: rgba(var(--mdui-color-on-surface-variant), 0.38);
161
- }
162
- .invalid .tickmark {
163
- background-color: rgba(var(--mdui-color-error), 0.38);
164
- }
165
- .tickmark.active {
166
- background-color: rgba(var(--mdui-color-on-primary), 0.38);
167
- }
168
- .invalid .tickmark.active {
169
- background-color: rgba(var(--mdui-color-on-error), 0.38);
170
- }
171
- :host([disabled]) .tickmark {
172
- background-color: rgba(var(--mdui-color-on-surface), 0.38);
173
- }
174
- `;
2
+ export const sliderBaseStyle = css `:host{position:relative;display:block;width:100%;-webkit-tap-highlight-color:transparent;height:2.5rem;padding:0 1.25rem}label{position:relative;display:block;width:100%;height:100%}input[type=range]{position:absolute;inset:0;z-index:4;height:100%;cursor:pointer;opacity:0;-webkit-appearance:none;appearance:none;width:calc(100% + 20rem * 2 / 16);margin:0 -1.25rem;padding:0 .75rem}:host([disabled]) input[type=range]{cursor:not-allowed}.track-active,.track-inactive{position:absolute;top:50%;height:.25rem;margin-top:-.125rem}.track-inactive{left:-.125rem;right:-.125rem;border-radius:var(--mdui-shape-corner-full);background-color:rgb(var(--mdui-color-surface-container-highest))}.invalid .track-inactive{background-color:rgba(var(--mdui-color-error),.12)}:host([disabled]) .track-inactive{background-color:rgba(var(--mdui-color-on-surface),.12)}.track-active{background-color:rgb(var(--mdui-color-primary))}.invalid .track-active{background-color:rgb(var(--mdui-color-error))}:host([disabled]) .track-active{background-color:rgba(var(--mdui-color-on-surface),.38)}.handle{position:absolute;top:50%;transform:translate(-50%);cursor:pointer;z-index:2;width:2.5rem;height:2.5rem;margin-top:-1.25rem;--mdui-comp-ripple-state-layer-color:var(--mdui-color-primary)}.invalid .handle{--mdui-comp-ripple-state-layer-color:var(--mdui-color-error)}.handle .elevation,.handle::before{position:absolute;display:block;content:' ';left:.625rem;top:.625rem;width:1.25rem;height:1.25rem;border-radius:var(--mdui-shape-corner-full)}.handle .elevation{background-color:rgb(var(--mdui-color-primary));box-shadow:var(--mdui-elevation-level1)}.invalid .handle .elevation{background-color:rgb(var(--mdui-color-error))}:host([disabled]) .handle .elevation{background-color:rgba(var(--mdui-color-on-surface),.38);box-shadow:var(--mdui-elevation-level0)}.handle::before{background-color:rgb(var(--mdui-color-background))}.handle mdui-ripple{border-radius:var(--mdui-shape-corner-full)}.label{position:absolute;left:50%;transform:translateX(-50%) scale(0);transform-origin:center bottom;display:flex;align-items:center;justify-content:center;cursor:default;white-space:nowrap;-webkit-user-select:none;user-select:none;pointer-events:none;transition:transform var(--mdui-motion-duration-short2) var(--mdui-motion-easing-standard);bottom:2.5rem;min-width:1.75rem;height:1.75rem;padding:.375rem .5rem;border-radius:var(--mdui-shape-corner-full);color:rgb(var(--mdui-color-on-primary));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);background-color:rgb(var(--mdui-color-primary))}.invalid .label{color:rgb(var(--mdui-color-on-error));background-color:rgb(var(--mdui-color-error))}.label::after{content:' ';position:absolute;z-index:-1;transform:rotate(45deg);width:.875rem;height:.875rem;bottom:-.125rem;background-color:rgb(var(--mdui-color-primary))}.invalid .label::after{background-color:rgb(var(--mdui-color-error))}.label-visible{transform:translateX(-50%) scale(1);transition:transform var(--mdui-motion-duration-short4) var(--mdui-motion-easing-standard)}.tickmark{position:absolute;top:50%;transform:translate(-50%);width:.125rem;height:.125rem;margin-top:-.0625rem;border-radius:var(--mdui-shape-corner-full);background-color:rgba(var(--mdui-color-on-surface-variant),.38)}.invalid .tickmark{background-color:rgba(var(--mdui-color-error),.38)}.tickmark.active{background-color:rgba(var(--mdui-color-on-primary),.38)}.invalid .tickmark.active{background-color:rgba(var(--mdui-color-on-error),.38)}:host([disabled]) .tickmark{background-color:rgba(var(--mdui-color-on-surface),.38)}`;
@@ -153,12 +153,7 @@ export class SliderBase extends RippleMixin(FocusableMixin(MduiElement)) {
153
153
  * 渲染浮动标签
154
154
  */
155
155
  renderLabel(value) {
156
- return when(!this.nolabel, () => html `<div
157
- part="label"
158
- class="label ${classMap({ 'label-visible': this.labelVisible })}"
159
- >
160
- ${this.labelFormatter(value)}
161
- </div>`);
156
+ return when(!this.nolabel, () => html `<div part="label" class="label ${classMap({ 'label-visible': this.labelVisible })}">${this.labelFormatter(value)}</div>`);
162
157
  }
163
158
  onChange() {
164
159
  // @ts-ignore
@@ -1,8 +1,2 @@
1
1
  import { css } from 'lit';
2
- export const style = css `
3
- .track-active {
4
- left: -0.125rem;
5
- border-radius: var(--mdui-shape-corner-full) 0 0
6
- var(--mdui-shape-corner-full);
7
- }
8
- `;
2
+ export const style = css `.track-active{left:-.125rem;border-radius:var(--mdui-shape-corner-full) 0 0 var(--mdui-shape-corner-full)}`;
@@ -204,38 +204,11 @@ let Snackbar = class Snackbar extends MduiElement {
204
204
  document.removeEventListener('pointerdown', this.onDocumentClick);
205
205
  }
206
206
  render() {
207
- return html `<slot part="message" class="message"></slot>
208
- <div class="action-group">
209
- <slot
210
- name="action"
211
- part="action"
212
- class="action"
213
- @click=${this.onActionClick}
214
- >
215
- ${this.action
216
- ? html `<mdui-button variant="text" loading=${this.actionLoading}>
217
- ${this.action}
218
- </mdui-button>`
219
- : nothingTemplate}
220
- </slot>
221
- ${when(this.closeable, () => html `<slot
222
- name="close-button"
223
- part="close-button"
224
- class="close-button"
225
- @click=${this.onCloseClick}
226
- >
227
- <mdui-button-icon>
228
- <slot name="close-icon" part="close-icon">
229
- ${this.closeIcon
230
- ? html `<mdui-icon
231
- name=${this.closeIcon}
232
- class="i"
233
- ></mdui-icon>`
234
- : html `<mdui-icon-clear class="i"></mdui-icon-clear>`}
235
- </slot>
236
- </mdui-button-icon>
237
- </slot>`)}
238
- </div>`;
207
+ return html `<slot part="message" class="message"></slot><div class="action-group"><slot name="action" part="action" class="action" @click="${this.onActionClick}">${this.action
208
+ ? html `<mdui-button variant="text" loading="${this.actionLoading}">${this.action}</mdui-button>`
209
+ : nothingTemplate}</slot>${when(this.closeable, () => html `<slot name="close-button" part="close-button" class="close-button" @click="${this.onCloseClick}"><mdui-button-icon><slot name="close-icon" part="close-icon">${this.closeIcon
210
+ ? html `<mdui-icon name="${this.closeIcon}" class="i"></mdui-icon>`
211
+ : html `<mdui-icon-clear class="i"></mdui-icon-clear>`}</slot></mdui-button-icon></slot>`)}</div>`;
239
212
  }
240
213
  /**
241
214
  * 在 document 上点击时,根据条件判断是否要关闭 snackbar
@@ -1,101 +1,2 @@
1
1
  import { css } from 'lit';
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
- `;
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}`;
@@ -167,50 +167,16 @@ let Switch = class Switch extends RippleMixin(FocusableMixin(MduiElement)) {
167
167
  this.invalid = !this.inputRef.value.checkValidity();
168
168
  }
169
169
  render() {
170
- return html `<label
171
- class=${classMap({
170
+ return html `<label class="${classMap({
172
171
  invalid: this.invalid,
173
172
  'has-unchecked-icon': this.uncheckedIcon || this.hasSlotController.test('unchecked-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>`
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>`
195
175
  : this.checkedIcon === ''
196
176
  ? nothingTemplate
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>`;
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>`;
214
180
  }
215
181
  /**
216
182
  * input[type="checkbox"] 的 change 事件无法冒泡越过 shadow dom