@m3ui-vue/m3ui-vue 1.10.2 → 1.11.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 (292) hide show
  1. package/README.md +19 -4
  2. package/dist/API.md +195 -56
  3. package/dist/MButton-gWoOzFWf.js +284 -0
  4. package/dist/MButton-gWoOzFWf.js.map +1 -0
  5. package/dist/MColorPickerModal-CJYMvlgK.js +466 -0
  6. package/dist/MColorPickerModal-CJYMvlgK.js.map +1 -0
  7. package/dist/MDialog-CU8EYgCC.js +226 -0
  8. package/dist/MDialog-CU8EYgCC.js.map +1 -0
  9. package/dist/{MIcon-BSsJZhK7.js → MIcon-CkUc9kuQ.js} +10 -4
  10. package/dist/MIcon-CkUc9kuQ.js.map +1 -0
  11. package/dist/MIconButton-DTFOfsTy.js +317 -0
  12. package/dist/MIconButton-DTFOfsTy.js.map +1 -0
  13. package/dist/MListItem-Cdw2FqCT.js +1306 -0
  14. package/dist/MListItem-Cdw2FqCT.js.map +1 -0
  15. package/dist/MLoadingIndicator-BxAy2x7P.js +115 -0
  16. package/dist/MLoadingIndicator-BxAy2x7P.js.map +1 -0
  17. package/dist/{MMenuItem-US0Zbglq.js → MMenuItem-CEIKYvaX.js} +216 -214
  18. package/dist/MMenuItem-CEIKYvaX.js.map +1 -0
  19. package/dist/{MPdfViewer-DL9mRsd2.js → MPdfViewer-CEfyXGq2.js} +674 -671
  20. package/dist/MPdfViewer-CEfyXGq2.js.map +1 -0
  21. package/dist/MProgressBar-BzZMxq7M.js.map +1 -1
  22. package/dist/MSeekBar-B3_D-PwH.js +435 -0
  23. package/dist/MSeekBar-B3_D-PwH.js.map +1 -0
  24. package/dist/{MSegmentedButton-DMou-8sG.js → MSegmentedButton-Dg07j-4r.js} +4 -4
  25. package/dist/{MSegmentedButton-DMou-8sG.js.map → MSegmentedButton-Dg07j-4r.js.map} +1 -1
  26. package/dist/{MSignaturePad-WuvE_Cyl.js → MSignaturePad-3nddtLKI.js} +2 -2
  27. package/dist/{MSignaturePad-WuvE_Cyl.js.map → MSignaturePad-3nddtLKI.js.map} +1 -1
  28. package/dist/{MSlider-7TzhFHKS.js → MSlider-BrpLbqwt.js} +4 -4
  29. package/dist/{MSlider-7TzhFHKS.js.map → MSlider-BrpLbqwt.js.map} +1 -1
  30. package/dist/{MSpinner-CkIVBuGE.js → MSpinner-CLwzDH33.js} +2 -2
  31. package/dist/{MSpinner-CkIVBuGE.js.map → MSpinner-CLwzDH33.js.map} +1 -1
  32. package/dist/{MTextField-B6_iOczK.js → MTextField-CZRizAwA.js} +136 -134
  33. package/dist/MTextField-CZRizAwA.js.map +1 -0
  34. package/dist/{_useFieldValidation-COBJ1tWr.js → _useFieldValidation-DVcqyy9g.js} +2 -2
  35. package/dist/{_useFieldValidation-COBJ1tWr.js.map → _useFieldValidation-DVcqyy9g.js.map} +1 -1
  36. package/dist/api.json +1 -1
  37. package/dist/chart.js +1 -1
  38. package/dist/code-editor.js +3 -3
  39. package/dist/code-editor.js.map +1 -1
  40. package/dist/components/MAlert.vue.d.ts +1 -1
  41. package/dist/components/MAudioPlayer.vue.d.ts +3 -3
  42. package/dist/components/MAvatar.vue.d.ts +19 -1
  43. package/dist/components/MButton.vue.d.ts +2 -1
  44. package/dist/components/MChatBubble.vue.d.ts +2 -0
  45. package/dist/components/MCheckbox.vue.d.ts +2 -0
  46. package/dist/components/MDataTable.vue.d.ts +31 -3
  47. package/dist/components/MFlow.vue.d.ts +1 -1
  48. package/dist/components/MHotkeys.vue.d.ts +1 -0
  49. package/dist/components/MIcon.vue.d.ts +6 -0
  50. package/dist/components/MIconButton.vue.d.ts +5 -0
  51. package/dist/components/MKanban.vue.d.ts +1 -1
  52. package/dist/components/MLink.vue.d.ts +59 -0
  53. package/dist/components/MListItem.vue.d.ts +3 -1
  54. package/dist/components/MMapControl.vue.d.ts +1 -1
  55. package/dist/components/MNotificationCenter.vue.d.ts +1 -1
  56. package/dist/components/MNumberField.vue.d.ts +1 -1
  57. package/dist/components/MPagination.vue.d.ts +14 -1
  58. package/dist/components/MPdfSigner.vue.d.ts +2 -2
  59. package/dist/components/MRadio.vue.d.ts +2 -0
  60. package/dist/components/MRadioGroup.vue.d.ts +2 -0
  61. package/dist/components/MStatCard.vue.d.ts +2 -2
  62. package/dist/components/MSwitch.vue.d.ts +2 -0
  63. package/dist/components/MText.vue.d.ts +4 -2
  64. package/dist/components/MTextField.vue.d.ts +2 -0
  65. package/dist/components/_MDrawerItemList.vue.d.ts +6 -0
  66. package/dist/composables/_menuGroups.d.ts +10 -1
  67. package/dist/composables/_splitAttrs.d.ts +6 -0
  68. package/dist/composables/_springAnimation.d.ts +2 -2
  69. package/dist/composables/_useFocusTrap.d.ts +15 -0
  70. package/dist/composables/_usePaneResize.d.ts +1 -1
  71. package/dist/composables/_useSpring.d.ts +4 -4
  72. package/dist/composables/dynamicColor.d.ts +9 -1
  73. package/dist/composables/motion.d.ts +63 -0
  74. package/dist/composables/useConfirm.d.ts +28 -0
  75. package/dist/composables/useDevice.d.ts +8 -1
  76. package/dist/composables/useLocale.d.ts +14 -0
  77. package/dist/composables/useScrollReveal.d.ts +1 -1
  78. package/dist/composables/useTheme.d.ts +1 -0
  79. package/dist/composables/useToast.d.ts +7 -0
  80. package/dist/draw.js +556 -556
  81. package/dist/draw.js.map +1 -1
  82. package/dist/flow.js +854 -851
  83. package/dist/flow.js.map +1 -1
  84. package/dist/gantt.js +1118 -1096
  85. package/dist/gantt.js.map +1 -1
  86. package/dist/index.d.ts +8 -5
  87. package/dist/locales/index.d.ts +1 -0
  88. package/dist/locales/index.js +833 -1
  89. package/dist/locales/index.js.map +1 -1
  90. package/dist/locales/pl.d.ts +2 -0
  91. package/dist/m3ui-vue.css +1 -1
  92. package/dist/m3ui.js +10327 -9796
  93. package/dist/m3ui.js.map +1 -1
  94. package/dist/map.js +860 -860
  95. package/dist/map.js.map +1 -1
  96. package/dist/{material-color-utilities-CEFytLsr.js → material-color-utilities-BZsBNIhi.js} +276 -217
  97. package/dist/material-color-utilities-BZsBNIhi.js.map +1 -0
  98. package/dist/media.js +7 -7
  99. package/dist/{motion-BcejVTeX.js → motion-BqYcqcim.js} +15 -5
  100. package/dist/motion-BqYcqcim.js.map +1 -0
  101. package/dist/pdf-sign.js +140 -137
  102. package/dist/pdf-sign.js.map +1 -1
  103. package/dist/pdf.js +1 -1
  104. package/dist/plugin.d.ts +11 -0
  105. package/dist/rich-text-editor.js +7 -7
  106. package/dist/styles/theme.css +40 -0
  107. package/dist/styles.css +1 -1
  108. package/dist/terminal.js +1 -1
  109. package/dist/{useLocale-YRaOT12S.js → useLocale-BjcYauXr.js} +60 -4
  110. package/dist/useLocale-BjcYauXr.js.map +1 -0
  111. package/dist/{useThemeTokens-DyAdPQB0.js → useThemeTokens-D5nr5KHf.js} +28 -27
  112. package/dist/useThemeTokens-D5nr5KHf.js.map +1 -0
  113. package/package.json +17 -2
  114. package/src/__tests__/MAvatarImage.test.ts +37 -0
  115. package/src/__tests__/MDataTableControlled.test.ts +68 -0
  116. package/src/__tests__/MHotkeysSequence.test.ts +53 -0
  117. package/src/__tests__/MIconAxes.test.ts +16 -0
  118. package/src/__tests__/MIconButtonWidth.test.ts +22 -0
  119. package/src/__tests__/MLink.test.ts +46 -0
  120. package/src/__tests__/MPaginationPages.test.ts +43 -0
  121. package/src/__tests__/MTextEmphasized.test.ts +14 -0
  122. package/src/__tests__/controlDescription.test.ts +34 -0
  123. package/src/__tests__/customColor.test.ts +27 -0
  124. package/src/__tests__/dynamicColor.test.ts +3 -2
  125. package/src/__tests__/focusTrap.test.ts +124 -0
  126. package/src/__tests__/formatMessage.test.ts +20 -0
  127. package/src/__tests__/inputAttrs.test.ts +103 -0
  128. package/src/__tests__/localePresets.test.ts +2 -0
  129. package/src/__tests__/menuGroupsRemount.test.ts +40 -0
  130. package/src/__tests__/menuHydration.test.ts +41 -0
  131. package/src/__tests__/motionPrefs.test.ts +28 -0
  132. package/src/__tests__/ssr.test.ts +11 -0
  133. package/src/__tests__/ssrToast.test.ts +20 -0
  134. package/src/__tests__/toastDetails.test.ts +39 -0
  135. package/src/__tests__/useConfirm.test.ts +47 -0
  136. package/src/__tests__/useTheme.test.ts +14 -0
  137. package/src/__tests__/warningRole.test.ts +22 -0
  138. package/src/components/MAlert.vue +2 -2
  139. package/src/components/MAnimatedNumber.vue +9 -3
  140. package/src/components/MAutocomplete.vue +16 -4
  141. package/src/components/MAvailabilityCalendar.vue +3 -3
  142. package/src/components/MAvatar.vue +32 -5
  143. package/src/components/MAvatarGroup.vue +7 -2
  144. package/src/components/MBottomSheet.vue +18 -2
  145. package/src/components/MButton.vue +18 -5
  146. package/src/components/MCarousel.vue +3 -3
  147. package/src/components/MChatBubble.vue +14 -1
  148. package/src/components/MCheckbox.vue +21 -4
  149. package/src/components/MChip.vue +4 -2
  150. package/src/components/MCollapse.vue +7 -1
  151. package/src/components/MCommandPalette.vue +6 -2
  152. package/src/components/MContextMenu.vue +4 -4
  153. package/src/components/MCreditCardInput.vue +5 -0
  154. package/src/components/MDashboardGrid.vue +2 -1
  155. package/src/components/MDataTable.vue +63 -16
  156. package/src/components/MDialog.vue +21 -3
  157. package/src/components/MDiffViewer.vue +3 -3
  158. package/src/components/MDrawLayers.vue +3 -3
  159. package/src/components/MFabMenu.vue +7 -0
  160. package/src/components/MFloorPlan.vue +3 -3
  161. package/src/components/MFloorPlanInspector.vue +3 -3
  162. package/src/components/MFlow.vue +9 -5
  163. package/src/components/MFlowControls.vue +6 -0
  164. package/src/components/MFormBuilder.vue +1 -1
  165. package/src/components/MGantt.vue +10 -10
  166. package/src/components/MHotkeys.vue +61 -16
  167. package/src/components/MIcon.vue +17 -1
  168. package/src/components/MIconButton.vue +29 -6
  169. package/src/components/MImageCropper.vue +1 -1
  170. package/src/components/MKanban.vue +2 -1
  171. package/src/components/MLightbox.vue +5 -4
  172. package/src/components/MLink.vue +136 -0
  173. package/src/components/MListDetail.vue +7 -0
  174. package/src/components/MListItem.vue +7 -4
  175. package/src/components/MLoadingIndicator.vue +2 -1
  176. package/src/components/MMap.vue +3 -0
  177. package/src/components/MMapCluster.vue +2 -2
  178. package/src/components/MMapControl.vue +2 -2
  179. package/src/components/MMapMeasure.vue +1 -1
  180. package/src/components/MMaskField.vue +16 -3
  181. package/src/components/MMenu.vue +4 -4
  182. package/src/components/MMenuItem.vue +2 -2
  183. package/src/components/MMeterGroup.vue +3 -2
  184. package/src/components/MMortgageCalculator.vue +3 -3
  185. package/src/components/MMultiAutocomplete.vue +19 -7
  186. package/src/components/MMultiSelect.vue +19 -7
  187. package/src/components/MNavigationDrawer.vue +10 -3
  188. package/src/components/MNavigationRail.vue +5 -1
  189. package/src/components/MNotificationCenter.vue +2 -1
  190. package/src/components/MNotificationHost.vue +3 -3
  191. package/src/components/MNumberField.vue +23 -6
  192. package/src/components/MOdontogram.vue +4 -4
  193. package/src/components/MOrderBook.vue +4 -0
  194. package/src/components/MPagination.vue +91 -12
  195. package/src/components/MPdfSigner.vue +3 -3
  196. package/src/components/MPdfViewer.vue +7 -7
  197. package/src/components/MPhoneInput.vue +17 -4
  198. package/src/components/MProductConfigurator.vue +4 -4
  199. package/src/components/MProgressBar.vue +5 -0
  200. package/src/components/MQuiz.vue +8 -5
  201. package/src/components/MRadio.vue +24 -5
  202. package/src/components/MRadioGroup.vue +3 -0
  203. package/src/components/MReactions.vue +2 -2
  204. package/src/components/MResourceTimeline.vue +3 -3
  205. package/src/components/MResult.vue +1 -1
  206. package/src/components/MScrollField.vue +1 -1
  207. package/src/components/MSearchField.vue +6 -5
  208. package/src/components/MSeatMap.vue +5 -0
  209. package/src/components/MSeekBar.vue +3 -2
  210. package/src/components/MSelect.vue +16 -4
  211. package/src/components/MSideSheet.vue +25 -3
  212. package/src/components/MSimpleCarousel.vue +2 -2
  213. package/src/components/MSnackbar.vue +16 -13
  214. package/src/components/MSparkline.vue +2 -1
  215. package/src/components/MSpinner.vue +8 -0
  216. package/src/components/MSplitter.vue +1 -1
  217. package/src/components/MSpotlightSearch.vue +6 -2
  218. package/src/components/MSpreadsheet.vue +1 -1
  219. package/src/components/MStatCard.vue +2 -1
  220. package/src/components/MSwitch.vue +21 -4
  221. package/src/components/MTabs.vue +2 -1
  222. package/src/components/MTagInput.vue +19 -6
  223. package/src/components/MText.vue +23 -4
  224. package/src/components/MTextField.vue +25 -6
  225. package/src/components/MTimeline.vue +5 -5
  226. package/src/components/MToolbar.vue +2 -2
  227. package/src/components/MTour.vue +3 -0
  228. package/src/components/MTrackingTimeline.vue +6 -0
  229. package/src/components/MTypewriter.vue +7 -1
  230. package/src/components/MWindow.vue +10 -1
  231. package/src/components/_MColorPanel.vue +4 -4
  232. package/src/components/_MComment.vue +3 -2
  233. package/src/components/_MFlowNodeShell.vue +1 -1
  234. package/src/components/_MPdfPage.vue +1 -1
  235. package/src/components/_MTransferPane.vue +10 -0
  236. package/src/composables/_effectCanvas.ts +2 -1
  237. package/src/composables/_menuGroups.ts +10 -1
  238. package/src/composables/_splitAttrs.ts +29 -0
  239. package/src/composables/_springAnimation.ts +3 -3
  240. package/src/composables/_themeTransition.ts +3 -2
  241. package/src/composables/_useFocusTrap.ts +142 -0
  242. package/src/composables/_useMenuNav.ts +3 -3
  243. package/src/composables/_usePaneResize.ts +2 -1
  244. package/src/composables/_useSheetMotion.ts +3 -4
  245. package/src/composables/_useSpring.ts +16 -10
  246. package/src/composables/cron.ts +7 -6
  247. package/src/composables/dynamicColor.ts +21 -2
  248. package/src/composables/motion.ts +27 -0
  249. package/src/composables/useConfirm.ts +116 -0
  250. package/src/composables/useDevice.ts +23 -3
  251. package/src/composables/useFieldBg.ts +4 -0
  252. package/src/composables/useLocale.ts +74 -0
  253. package/src/composables/useNotification.ts +3 -0
  254. package/src/composables/useScrollReveal.ts +3 -3
  255. package/src/composables/useTheme.ts +8 -2
  256. package/src/composables/useToast.ts +27 -4
  257. package/src/directives/vSparkle.ts +2 -1
  258. package/src/index.ts +8 -5
  259. package/src/locales/ar.ts +7 -0
  260. package/src/locales/de.ts +7 -0
  261. package/src/locales/es.ts +7 -0
  262. package/src/locales/fr.ts +7 -0
  263. package/src/locales/index.ts +1 -0
  264. package/src/locales/ja.ts +7 -0
  265. package/src/locales/ko.ts +7 -0
  266. package/src/locales/pl.ts +807 -0
  267. package/src/locales/pt.ts +7 -0
  268. package/src/locales/zh.ts +7 -0
  269. package/src/plugin.ts +16 -0
  270. package/src/styles/theme.css +40 -0
  271. package/dist/MButton-B9RCM06i.js +0 -171
  272. package/dist/MButton-B9RCM06i.js.map +0 -1
  273. package/dist/MColorPickerModal-ChRtcZOo.js +0 -577
  274. package/dist/MColorPickerModal-ChRtcZOo.js.map +0 -1
  275. package/dist/MDialog-dk07tify.js +0 -167
  276. package/dist/MDialog-dk07tify.js.map +0 -1
  277. package/dist/MIcon-BSsJZhK7.js.map +0 -1
  278. package/dist/MIconButton-CrBPZidd.js +0 -288
  279. package/dist/MIconButton-CrBPZidd.js.map +0 -1
  280. package/dist/MListItem-h9H223vx.js +0 -1239
  281. package/dist/MListItem-h9H223vx.js.map +0 -1
  282. package/dist/MLoadingIndicator-YTV1Ov5w.js +0 -114
  283. package/dist/MLoadingIndicator-YTV1Ov5w.js.map +0 -1
  284. package/dist/MMenuItem-US0Zbglq.js.map +0 -1
  285. package/dist/MPdfViewer-DL9mRsd2.js.map +0 -1
  286. package/dist/MSeekBar-JFZcoJ8y.js +0 -434
  287. package/dist/MSeekBar-JFZcoJ8y.js.map +0 -1
  288. package/dist/MTextField-B6_iOczK.js.map +0 -1
  289. package/dist/material-color-utilities-CEFytLsr.js.map +0 -1
  290. package/dist/motion-BcejVTeX.js.map +0 -1
  291. package/dist/useLocale-YRaOT12S.js.map +0 -1
  292. package/dist/useThemeTokens-DyAdPQB0.js.map +0 -1
@@ -2,12 +2,16 @@
2
2
  /**
3
3
  * A single-value dropdown select, docked or as a modal dialog on smaller screens.
4
4
  *
5
+ * Your `class`, `style` and `data-*` go on the field's box; every other attribute (`id`, `aria-*`, native
6
+ * listeners like `@keydown`) goes on the `role="combobox"` trigger.
7
+ *
5
8
  * @event update:modelValue Emitted with the selected option's value (`null` when the clear button empties it).
6
9
  */
7
10
  import { computed, ref, useId, onMounted, onUnmounted, watch } from 'vue'
8
11
  import { useFieldValidation, useFocusLeave } from '../composables/_useFieldValidation'
9
12
  import type { ValidateOn, ValidationRule } from '../composables/validation'
10
13
  import MIcon from './MIcon.vue'
14
+ import { useSplitAttrs } from '../composables/_splitAttrs'
11
15
  import MIconButton from './MIconButton.vue'
12
16
  import { useFieldBg } from '../composables/useFieldBg'
13
17
  import { useLocale } from '../composables/useLocale'
@@ -105,6 +109,13 @@ const { hasError, message: errorMessage, messageId } = validation
105
109
 
106
110
  const locale = useLocale()
107
111
  const id = useId()
112
+ const { rootAttrs, inputAttrs, attrId } = useSplitAttrs()
113
+ /** The trigger's id: the consumer's `id` if given (so `<label for>` works), else the generated one */
114
+ const controlId = () => attrId() ?? id
115
+ // Ours (the message below the field) plus any the consumer passed
116
+ function describedBy() {
117
+ return [errorMessage.value || props.hint ? messageId : '', inputAttrs()['aria-describedby']].filter(Boolean).join(' ') || undefined
118
+ }
108
119
  // ARIA combobox + listbox: the trigger names itself by the label and points at the open list and its selected option
109
120
  const labelId = `${id}-label`
110
121
  const listId = `${id}-list`
@@ -271,7 +282,7 @@ const onFocusOut = useFocusLeave(() => rootEl.value, () => {
271
282
  </script>
272
283
 
273
284
  <template>
274
- <div ref="rootEl" class="flex flex-col gap-1" v-bind="$attrs" @focusout="onFocusOut">
285
+ <div ref="rootEl" class="flex flex-col gap-1" v-bind="rootAttrs()" @focusout="onFocusOut">
275
286
  <div
276
287
  ref="fieldEl"
277
288
  class="relative"
@@ -292,9 +303,10 @@ const onFocusOut = useFocusLeave(() => rootEl.value, () => {
292
303
 
293
304
  <!-- Custom trigger -->
294
305
  <div
295
- :id="id"
306
+ v-bind="inputAttrs()"
307
+ :id="controlId()"
296
308
  :tabindex="isDisabled ? -1 : 0"
297
- :aria-describedby="errorMessage || hint ? messageId : undefined"
309
+ :aria-describedby="describedBy()"
298
310
  role="combobox"
299
311
  aria-haspopup="listbox"
300
312
  :aria-expanded="open || modalOpen"
@@ -314,7 +326,7 @@ const onFocusOut = useFocusLeave(() => rootEl.value, () => {
314
326
  </div>
315
327
 
316
328
  <!-- Floating label -->
317
- <label :id="labelId" :for="id" :class="labelClasses">
329
+ <label :id="labelId" :for="controlId()" :class="labelClasses">
318
330
  {{ label }}<span v-if="required" class="text-error">&nbsp;*</span>
319
331
  </label>
320
332
 
@@ -14,6 +14,8 @@ import MIcon from './MIcon.vue'
14
14
  import { useSheetMotion } from '../composables/_useSheetMotion'
15
15
  import { useEscapeStack } from '../composables/_useEscapeStack'
16
16
  import { useLocale } from '../composables/useLocale'
17
+ import { focusableIn, useFocusTrap } from '../composables/_useFocusTrap'
18
+ import { ref, useId } from 'vue'
17
19
 
18
20
  const locale = useLocale()
19
21
  const props = withDefaults(defineProps<{
@@ -32,6 +34,19 @@ useEscapeStack(() => props.modelValue, close)
32
34
 
33
35
  // Slide in/out and drag-to-dismiss, as springs (see _useSheetMotion).
34
36
  const motion = useSheetMotion('x', close)
37
+ const titleId = `m3-side-sheet-${useId()}`
38
+
39
+ // Modal: focus moves in on open (an `autofocus` element, else the first control past the handle and close
40
+ // button), Tab stays inside, and closing returns focus to the opener
41
+ const sheetPanelEl = ref<HTMLElement>()
42
+ useFocusTrap(() => sheetPanelEl.value, () => props.modelValue, {
43
+ initialFocus: () => {
44
+ const root = sheetPanelEl.value
45
+ if (!root) return null
46
+ return root.querySelector<HTMLElement>('[autofocus], [data-autofocus]') ?? focusableIn(root).find((el) => !el.closest('[data-sheet-handle], [data-sheet-close]'))
47
+ },
48
+ })
49
+
35
50
  </script>
36
51
 
37
52
  <template>
@@ -43,7 +58,11 @@ const motion = useSheetMotion('x', close)
43
58
 
44
59
  <!-- Panel -->
45
60
  <aside
61
+ ref="sheetPanelEl"
46
62
  data-sheet-panel
63
+ role="dialog"
64
+ aria-modal="true"
65
+ :aria-labelledby="title || $slots.header ? titleId : undefined"
47
66
  class="relative flex h-full flex-col bg-surface-container-low shadow-elevation-3"
48
67
  :class="[width, 'max-w-[90vw]']"
49
68
  >
@@ -58,10 +77,13 @@ const motion = useSheetMotion('x', close)
58
77
 
59
78
  <!-- Header -->
60
79
  <div v-if="title || $slots.header" class="flex shrink-0 items-center justify-between border-b border-outline-variant px-6 py-4">
61
- <slot name="header">
62
- <h2 class="text-title-large text-on-surface">{{ title }}</h2>
63
- </slot>
80
+ <div :id="titleId" class="min-w-0">
81
+ <slot name="header">
82
+ <h2 class="text-title-large text-on-surface">{{ title }}</h2>
83
+ </slot>
84
+ </div>
64
85
  <button
86
+ data-sheet-close
65
87
  :aria-label="locale.close"
66
88
  type="button"
67
89
  class="flex h-9 w-9 cursor-pointer items-center justify-center rounded-full text-on-surface-variant transition-colors hover:bg-on-surface/8"
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { ref, computed, onMounted, onBeforeUnmount, watch, nextTick } from 'vue'
11
11
  import MIcon from './MIcon.vue'
12
- import { useLocale } from '../composables/useLocale'
12
+ import { useLocale, formatMessage } from '../composables/useLocale'
13
13
  import { isRtl, logicalKey } from '../composables/_rtl'
14
14
 
15
15
  export interface SimpleCarouselItem {
@@ -340,7 +340,7 @@ defineExpose({
340
340
  v-for="p in totalPages"
341
341
  :key="p"
342
342
  type="button"
343
- :aria-label="locale.carouselItem.replace('{index}', String(p)).replace('{count}', String(totalPages))"
343
+ :aria-label="formatMessage(locale.carouselItem, { index: String(p), count: String(totalPages) }, locale.lang)"
344
344
  :aria-current="(p - 1) === activePage || undefined"
345
345
  class="h-2 cursor-pointer rounded-full transition-all duration-300"
346
346
  :class="(p - 1) === activePage ? 'w-5 bg-on-surface' : 'w-2 bg-on-surface/30 hover:bg-on-surface/50'"
@@ -60,27 +60,26 @@ const variantStyles: Record<string, VariantStyle> = {
60
60
  },
61
61
  success: {
62
62
  container:
63
- "bg-[#dcfce7] text-[#14532d] ring-1 ring-inset ring-[#14532d]/10 dark:bg-[#052e16] dark:text-[#bbf7d0] dark:ring-white/8",
64
- icon: "text-[#16a34a] dark:text-[#4ade80]",
63
+ "bg-success-container text-on-success-container ring-1 ring-inset ring-on-success-container/8",
64
+ icon: "text-success",
65
65
  iconName: "check_circle",
66
- action: "text-[#166534] hover:bg-[#14532d]/10 dark:text-[#86efac] dark:hover:bg-white/10",
67
- close: "text-[#14532d]/50 hover:bg-[#14532d]/10 dark:text-[#bbf7d0]/50 dark:hover:bg-white/10",
68
- progress: "bg-[#16a34a]/35 dark:bg-[#4ade80]/30",
66
+ action: "text-on-success-container hover:bg-on-success-container/10",
67
+ close: "text-on-success-container/60 hover:bg-on-success-container/10",
68
+ progress: "bg-on-success-container/25",
69
69
  },
70
70
  warning: {
71
71
  container:
72
- "bg-[#fefce8] text-[#713f12] ring-1 ring-inset ring-[#713f12]/10 dark:bg-[#2d1a00] dark:text-[#fde68a] dark:ring-white/8",
73
- icon: "text-[#d97706] dark:text-[#fcd34d]",
72
+ "bg-warning-container text-on-warning-container ring-1 ring-inset ring-on-warning-container/8",
73
+ icon: "text-warning",
74
74
  iconName: "warning",
75
- action: "text-[#92400e] hover:bg-[#713f12]/10 dark:text-[#fcd34d] dark:hover:bg-white/10",
76
- close: "text-[#713f12]/50 hover:bg-[#713f12]/10 dark:text-[#fde68a]/50 dark:hover:bg-white/10",
77
- progress: "bg-[#d97706]/35 dark:bg-[#fcd34d]/30",
75
+ action: "text-on-warning-container hover:bg-on-warning-container/10",
76
+ close: "text-on-warning-container/60 hover:bg-on-warning-container/10",
77
+ progress: "bg-on-warning-container/25",
78
78
  },
79
79
  error: {
80
- // error-container tokens are adaptive light/dark out of the box
81
80
  container:
82
81
  "bg-error-container text-on-error-container ring-1 ring-inset ring-on-error-container/8",
83
- icon: "text-error dark:text-[#fca5a5]",
82
+ icon: "text-error",
84
83
  iconName: "error",
85
84
  action: "text-on-error-container hover:bg-on-error-container/10",
86
85
  close: "text-on-error-container/60 hover:bg-on-error-container/10",
@@ -121,7 +120,11 @@ const getVariantStyle = (variant: string): VariantStyle =>
121
120
  :class="t.color ? '' : getVariantStyle(t.variant).icon"
122
121
  />
123
122
 
124
- <p class="flex-1 text-body-medium leading-snug">{{ t.message }}</p>
123
+ <div v-if="t.description" class="min-w-0 flex-1">
124
+ <p class="text-label-large leading-snug">{{ t.message }}</p>
125
+ <p class="mt-0.5 text-body-small leading-snug opacity-80">{{ t.description }}</p>
126
+ </div>
127
+ <p v-else class="flex-1 text-body-medium leading-snug">{{ t.message }}</p>
125
128
 
126
129
  <div class="flex shrink-0 items-center gap-0.5">
127
130
  <button
@@ -8,6 +8,7 @@
8
8
  * @event hover With `interactive`: the index of the point under the pointer, or null when it leaves
9
9
  */
10
10
  import { computed, onMounted, onUnmounted, ref, useId, watch } from 'vue'
11
+ import { shouldReduceMotion } from '../composables/motion'
11
12
  import { useLocale } from '../composables/useLocale'
12
13
  import { useSpring, DEFAULT_SPATIAL } from '../composables/_useSpring'
13
14
 
@@ -77,7 +78,7 @@ const domain = computed(() => {
77
78
  // Values as 0..1 of the scale; these are what spring when the data changes
78
79
  const targets = computed(() => props.data.map((v) => (v - domain.value.lo) / (domain.value.hi - domain.value.lo)))
79
80
  const shown = ref<number[]>([...targets.value])
80
- const reduceMotion = () => typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches
81
+ const reduceMotion = () => shouldReduceMotion()
81
82
  // In thousandths: useSpring settles within 0.05 of the target, which on a 0..1 scale would cut the last 5% short
82
83
  const { snap } = useSpring(() => targets.value.map((v) => v * 1000), (v) => (shown.value = v.map((n) => n / 1000)), DEFAULT_SPATIAL)
83
84
  watch(targets, () => {
@@ -133,4 +133,12 @@ const wavyData = computed(() => {
133
133
  animation: none !important;
134
134
  }
135
135
  }
136
+ /* createM3UI({ reducedMotion: 'always' }) */
137
+ :root[data-m3-motion='reduce'] .animate-\[m3-wavy-spin_2\.8s_linear_infinite\] {
138
+ animation: m3-wavy-spin 2.8s linear infinite;
139
+ }
140
+ :root[data-m3-motion='reduce'] .animate-\[m3-wavy-travel_2s_linear_infinite\] {
141
+ animation: none !important;
142
+ }
143
+
136
144
  </style>
@@ -124,7 +124,7 @@ onBeforeUnmount(() => {
124
124
  <MDragHandle
125
125
  :orientation="isHorizontal ? 'vertical' : 'horizontal'"
126
126
  :dragging="dragging"
127
- class="rounded-md group-focus-visible:outline-2 group-focus-visible:outline-offset-2 group-focus-visible:outline-primary"
127
+ class="rounded-md group-focus-visible:outline-2 group-focus-visible:outline-offset-2 group-focus-visible:outline-secondary"
128
128
  />
129
129
  </div>
130
130
 
@@ -14,6 +14,7 @@ import MSpinner from './MSpinner.vue'
14
14
  import { useLocale } from '../composables/useLocale'
15
15
  import { useScrollLock } from '../composables/_useScrollLock'
16
16
  import { useEscapeStack } from '../composables/_useEscapeStack'
17
+ import { useFocusTrap } from '../composables/_useFocusTrap'
17
18
 
18
19
  const locale = useLocale()
19
20
 
@@ -148,11 +149,14 @@ function onGlobalKeydown(e: KeyboardEvent) {
148
149
  watch(
149
150
  () => props.modelValue,
150
151
  (open) => {
151
- if (open) nextTick(() => inputRef.value?.focus())
152
+ if (open) nextTick(() => inputRef.value?.focus({ preventScroll: true }))
152
153
  },
153
154
  )
154
155
 
155
156
  useScrollLock(() => props.modelValue)
157
+ // Tab stays inside while open, and closing returns focus to whatever opened it
158
+ const boxEl = ref<HTMLElement>()
159
+ useFocusTrap(() => boxEl.value, () => props.modelValue, { initialFocus: () => inputRef.value })
156
160
  // Escape through the library's stack: opened over a dialog, it closes alone
157
161
  useEscapeStack(() => props.modelValue, close)
158
162
 
@@ -176,7 +180,7 @@ onBeforeUnmount(() => {
176
180
  class="fixed inset-0 z-50 flex items-start justify-center bg-scrim/32 pt-[12vh]"
177
181
  @click.self="close"
178
182
  >
179
- <div class="spot-box flex w-full max-w-xl flex-col overflow-hidden rounded-2xl bg-surface-container-high shadow-elevation-3">
183
+ <div ref="boxEl" role="dialog" aria-modal="true" :aria-label="placeholder || locale.search" class="spot-box flex w-full max-w-xl flex-col overflow-hidden rounded-2xl bg-surface-container-high shadow-elevation-3">
180
184
  <!-- Search bar -->
181
185
  <div class="flex items-center gap-3 px-5 py-1">
182
186
  <MIcon name="search" :size="24" class="shrink-0 text-primary" />
@@ -822,7 +822,7 @@ defineExpose({
822
822
 
823
823
  <div
824
824
  ref="scroller"
825
- class="m3-spreadsheet-scroller relative min-h-0 flex-1 select-none overflow-auto overscroll-contain outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary"
825
+ class="m3-spreadsheet-scroller relative min-h-0 flex-1 select-none overflow-auto overscroll-contain outline-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-secondary"
826
826
  tabindex="0"
827
827
  role="grid"
828
828
  :aria-label="label ?? locale.spreadsheet"
@@ -20,7 +20,7 @@ const props = withDefaults(defineProps<{
20
20
  /** Text next to the trend indicator (e.g. "vs last month") */
21
21
  trendLabel?: string
22
22
  /** Icon container color */
23
- color?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'success'
23
+ color?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'success' | 'warning'
24
24
  /** Show a skeleton placeholder instead of the value */
25
25
  loading?: boolean
26
26
  }>(), { color: 'primary' })
@@ -31,6 +31,7 @@ const iconBg: Record<string, string> = {
31
31
  tertiary: 'bg-tertiary-container text-on-tertiary-container',
32
32
  error: 'bg-error-container text-on-error-container',
33
33
  success: 'bg-success-container text-on-success-container',
34
+ warning: 'bg-warning-container text-on-warning-container',
34
35
  }
35
36
 
36
37
  const trendColor = computed(() => {
@@ -3,16 +3,22 @@
3
3
  * A toggle switch with an optional label, 4 semantic colors, and both M3 icon variants. Click it, or drag the
4
4
  * thumb across: on release it settles to the side it's closer to (or the side it was flung toward).
5
5
  *
6
+ * Your `class`, `style` and `data-*` go on the root `<label>`; every other attribute (`id`, `name`, `aria-*`, native
7
+ * listeners) goes on the native `<input>`.
8
+ *
6
9
  * @event update:modelValue Emitted with the new on/off state.
7
10
  * @event blur Emitted when the switch loses focus
8
11
  */
9
12
  import { computed, ref } from 'vue'
13
+ import { useSplitAttrs } from '../composables/_splitAttrs'
10
14
  import { isRtl } from '../composables/_rtl'
11
15
  import { vRipple } from '../directives/vRipple'
12
16
  import MIcon from './MIcon.vue'
13
17
  import { useFieldValidation } from '../composables/_useFieldValidation'
14
18
  import type { ValidateOn, ValidationRule } from '../composables/validation'
15
19
 
20
+ defineOptions({ inheritAttrs: false })
21
+
16
22
  const props = withDefaults(
17
23
  defineProps<{
18
24
  /** Toggle state (v-model) */
@@ -21,6 +27,8 @@ const props = withDefaults(
21
27
  disabled?: boolean
22
28
  /** Label text */
23
29
  label?: string
30
+ /** Supporting text under the label (M3 list-style two-line control); screen readers read it as the description */
31
+ description?: string
24
32
  /** Track/thumb color when on */
25
33
  color?: 'primary' | 'secondary' | 'tertiary' | 'error'
26
34
  /** Shows a check icon in the thumb while on. Set to `false` for M3's plain switch without an icon. */
@@ -70,6 +78,13 @@ const validation = useFieldValidation({
70
78
  /** Its own `disabled` or its MForm's */
71
79
  const isDisabled = validation.disabled
72
80
  const { hasError, message: errorMessage, messageId } = validation
81
+ const descId = `${messageId}-desc`
82
+
83
+ const { rootAttrs, inputAttrs, attrId } = useSplitAttrs()
84
+ // Ours (the error message) plus any the consumer passed
85
+ function describedBy() {
86
+ return [props.description ? descId : '', errorMessage.value ? messageId : '', inputAttrs()['aria-describedby']].filter(Boolean).join(' ') || undefined
87
+ }
73
88
 
74
89
  // Same 4 named colors as MRadio/MCheckbox's color prop.
75
90
  const trackClasses: Record<string, string> = {
@@ -231,10 +246,10 @@ defineExpose({
231
246
  </script>
232
247
 
233
248
  <template>
234
- <label
249
+ <label v-bind="rootAttrs()"
235
250
  v-ripple="{ disabled: isDisabled, layer: () => rippleEl, centered: true }"
236
251
  class="group inline-flex gap-3 select-none"
237
- :class="[isDisabled ? 'cursor-not-allowed opacity-[0.38]' : 'cursor-pointer', errorMessage ? 'items-start' : 'items-center']"
252
+ :class="[isDisabled ? 'cursor-not-allowed opacity-[0.38]' : 'cursor-pointer', errorMessage || description ? 'items-start' : 'items-center']"
238
253
  @pointerdown="onPointerDown"
239
254
  @pointerup="onPointerEnd"
240
255
  @pointerleave="onPointerEnd"
@@ -251,6 +266,7 @@ defineExpose({
251
266
  @pointercancel="onTrackPointerCancel"
252
267
  >
253
268
  <input
269
+ v-bind="inputAttrs()"
254
270
  type="checkbox"
255
271
  class="peer sr-only"
256
272
  :checked="modelValue"
@@ -260,7 +276,7 @@ defineExpose({
260
276
  :name="name"
261
277
  :required="required"
262
278
  :aria-invalid="hasError || undefined"
263
- :aria-describedby="errorMessage ? messageId : undefined"
279
+ :aria-describedby="describedBy()"
264
280
  @change="emit('update:modelValue', !modelValue)"
265
281
  @blur="validation.onBlur(); emit('blur', $event)"
266
282
  />
@@ -305,8 +321,9 @@ defineExpose({
305
321
  </span>
306
322
  </span>
307
323
  </span>
308
- <span v-if="label || errorMessage" class="flex flex-col" :class="errorMessage && 'pt-1'">
324
+ <span v-if="label || description || errorMessage" class="flex flex-col" :class="(errorMessage || description) && 'pt-1'">
309
325
  <span v-if="label" class="text-body-large text-on-surface">{{ label }}<span v-if="required" class="text-error">&nbsp;*</span></span>
326
+ <span v-if="description" :id="descId" class="text-body-medium text-on-surface-variant">{{ description }}</span>
310
327
  <!-- M3's switch has no error state: only the message says so -->
311
328
  <span v-if="errorMessage" :id="messageId" role="alert" class="text-body-small text-error">{{ errorMessage }}</span>
312
329
  </span>
@@ -6,6 +6,7 @@
6
6
  * @event update:modelValue Emitted with the value of the tab you picked.
7
7
  */
8
8
  import { computed, nextTick, onMounted, onUnmounted, onUpdated, ref, watch } from 'vue'
9
+ import { shouldReduceMotion } from '../composables/motion'
9
10
  import MIcon from './MIcon.vue'
10
11
  import { isRtl } from '../composables/_rtl'
11
12
 
@@ -114,7 +115,7 @@ function scrollToTab(rect: { left: number; width: number }, smooth: boolean) {
114
115
  // Right to left, scrollLeft runs from 0 (scrolled to the right end, where the row starts) down to -max
115
116
  const left = isRtl(row) ? fromLeft - max : fromLeft
116
117
  if (Math.abs(left - row.scrollLeft) < 1) return
117
- const reduce = typeof window !== 'undefined' && window.matchMedia?.('(prefers-reduced-motion: reduce)').matches
118
+ const reduce = shouldReduceMotion()
118
119
  const behavior: ScrollBehavior = smooth && !reduce ? 'smooth' : 'auto'
119
120
  if (typeof row.scrollTo === 'function') row.scrollTo({ left, behavior })
120
121
  else row.scrollLeft = left
@@ -2,6 +2,9 @@
2
2
  /**
3
3
  * Type and press Enter or comma to add a free-form tag. Backspace on an empty input removes the last tag.
4
4
  *
5
+ * Your `class`, `style` and `data-*` go on the field's box; every other attribute (`id`, `inputmode`, `enterkeyhint`,
6
+ * `maxlength`, `readonly`, `aria-*`, native listeners like `@keydown`) goes on the `<input>`.
7
+ *
5
8
  * @event update:modelValue Emitted whenever a tag is added or removed — powers v-model
6
9
  * @event debounced Emitted debounce ms after the tag list stops changing (only when debounce > 0)
7
10
  */
@@ -9,12 +12,15 @@ import { computed, ref, useId } from 'vue'
9
12
  import { useFieldValidation, useFocusLeave } from '../composables/_useFieldValidation'
10
13
  import type { ValidateOn, ValidationRule } from '../composables/validation'
11
14
  import MIcon from './MIcon.vue'
15
+ import { useSplitAttrs } from '../composables/_splitAttrs'
12
16
  import { useFieldBg } from '../composables/useFieldBg'
13
17
  import { useDebounce } from '../composables/useDebounce'
14
18
  import { useLocale } from '../composables/useLocale'
15
19
  import { FIELD_PADDING_END, fieldLabelClasses, vOverflowTitle, type FieldEndInset } from '../composables/_fieldLayout'
16
20
 
17
21
  const locale = useLocale()
22
+ defineOptions({ inheritAttrs: false })
23
+
18
24
  const props = withDefaults(
19
25
  defineProps<{
20
26
  /** Array of tags (v-model) */
@@ -97,7 +103,13 @@ const onFocusOut = useFocusLeave(() => rootEl.value, () => {
97
103
  emit('blur')
98
104
  })
99
105
 
100
- const id = useId()
106
+ const { rootAttrs, inputAttrs, attrId } = useSplitAttrs()
107
+ const autoId = useId()
108
+ const id = computed(() => attrId() ?? autoId)
109
+ // Ours (the message below the field) plus any the consumer passed
110
+ function describedBy() {
111
+ return [errorMessage.value || props.hint ? messageId : '', inputAttrs()['aria-describedby']].filter(Boolean).join(' ') || undefined
112
+ }
101
113
  const focused = ref(false)
102
114
  const inputValue = ref('')
103
115
  const fieldEl = ref<HTMLElement | null>(null)
@@ -241,7 +253,7 @@ defineExpose({
241
253
  </script>
242
254
 
243
255
  <template>
244
- <div ref="rootEl" class="flex flex-col gap-1" @focusout="onFocusOut">
256
+ <div ref="rootEl" class="flex flex-col gap-1" @focusout="onFocusOut" v-bind="rootAttrs()">
245
257
  <div
246
258
  ref="fieldEl"
247
259
  class="relative"
@@ -261,7 +273,6 @@ defineExpose({
261
273
 
262
274
  <!-- Trigger field -->
263
275
  <div
264
- :id="id"
265
276
  :class="triggerClasses"
266
277
  @click="focusInput"
267
278
  >
@@ -276,7 +287,7 @@ defineExpose({
276
287
  :aria-label="`${locale.remove} ${tag}`"
277
288
  v-if="!isDisabled"
278
289
  type="button"
279
- class="flex h-4 w-4 shrink-0 items-center justify-center rounded-full hover:bg-on-secondary-container/20"
290
+ class="flex h-4 w-4 shrink-0 items-center justify-center rounded-full hover:bg-on-secondary-container/8"
280
291
  @click="removeTag(i, $event)"
281
292
  >
282
293
  <MIcon name="close" :size="12" />
@@ -285,8 +296,10 @@ defineExpose({
285
296
 
286
297
  <input
287
298
  ref="inputEl"
299
+ v-bind="inputAttrs()"
300
+ :id="id"
288
301
  :aria-invalid="hasError || undefined"
289
- :aria-describedby="errorMessage || hint ? messageId : undefined"
302
+ :aria-describedby="describedBy()"
290
303
  :value="inputValue"
291
304
  type="text"
292
305
  enterkeyhint="done"
@@ -307,7 +320,7 @@ defineExpose({
307
320
  />
308
321
  </div>
309
322
 
310
- <label :class="labelClasses">
323
+ <label :for="id" :class="labelClasses">
311
324
  {{ label }}<span v-if="required" class="text-error">&nbsp;*</span>
312
325
  </label>
313
326
 
@@ -1,21 +1,24 @@
1
1
  <script setup lang="ts">
2
2
  /**
3
- * Renders any of the 15 Material 3 typography variants, with an auto-selected semantic HTML tag.
3
+ * Renders any of the 15 Material 3 typography variants (or their 15 M3 Expressive `-emphasized` twins), with an
4
+ * auto-selected semantic HTML tag.
4
5
  *
5
6
  * @slot default The text.
6
7
  */
7
8
  import { computed } from 'vue'
8
9
 
9
- export type TextVariant =
10
+ type BaseTextVariant =
10
11
  | 'display-large' | 'display-medium' | 'display-small'
11
12
  | 'headline-large' | 'headline-medium' | 'headline-small'
12
13
  | 'title-large' | 'title-medium' | 'title-small'
13
14
  | 'body-large' | 'body-medium' | 'body-small'
14
15
  | 'label-large' | 'label-medium' | 'label-small'
16
+ /** A type-scale style, or its M3 Expressive emphasized twin (same size and tracking, heavier) */
17
+ export type TextVariant = BaseTextVariant | `${BaseTextVariant}-emphasized`
15
18
 
16
19
  const props = withDefaults(
17
20
  defineProps<{
18
- /** Typography variant from the Material 3 type scale */
21
+ /** Typography variant from the Material 3 type scale; add `-emphasized` for the M3 Expressive heavier twin */
19
22
  variant?: TextVariant
20
23
  /**
21
24
  * HTML tag to render (auto-selected based on variant — h1/h2/h3 for display/headline, p for title/body,
@@ -70,6 +73,22 @@ const variantClasses: Record<string, string> = {
70
73
  'label-large': 'text-label-large',
71
74
  'label-medium': 'text-label-medium',
72
75
  'label-small': 'text-label-small',
76
+ // Written out (not built from the name) so Tailwind finds every class when it scans the library
77
+ 'display-large-emphasized': 'text-display-large-emphasized',
78
+ 'display-medium-emphasized': 'text-display-medium-emphasized',
79
+ 'display-small-emphasized': 'text-display-small-emphasized',
80
+ 'headline-large-emphasized': 'text-headline-large-emphasized',
81
+ 'headline-medium-emphasized': 'text-headline-medium-emphasized',
82
+ 'headline-small-emphasized': 'text-headline-small-emphasized',
83
+ 'title-large-emphasized': 'text-title-large-emphasized',
84
+ 'title-medium-emphasized': 'text-title-medium-emphasized',
85
+ 'title-small-emphasized': 'text-title-small-emphasized',
86
+ 'body-large-emphasized': 'text-body-large-emphasized',
87
+ 'body-medium-emphasized': 'text-body-medium-emphasized',
88
+ 'body-small-emphasized': 'text-body-small-emphasized',
89
+ 'label-large-emphasized': 'text-label-large-emphasized',
90
+ 'label-medium-emphasized': 'text-label-medium-emphasized',
91
+ 'label-small-emphasized': 'text-label-small-emphasized',
73
92
  }
74
93
 
75
94
  const colorClasses: Record<string, string> = {
@@ -103,7 +122,7 @@ const lineClasses: Record<number, string> = {
103
122
  6: 'line-clamp-6',
104
123
  }
105
124
 
106
- const resolvedTag = computed(() => props.tag || defaultTags[props.variant])
125
+ const resolvedTag = computed(() => props.tag || defaultTags[props.variant.replace(/-emphasized$/, '')])
107
126
 
108
127
  const classes = computed(() => [
109
128
  variantClasses[props.variant],
@@ -2,6 +2,10 @@
2
2
  /**
3
3
  * The standard single- or multi-line text input, filled or outlined, with floating label.
4
4
  *
5
+ * Your `class`, `style` and `data-*` go on the field's box; every other attribute (`id`, `inputmode`, `enterkeyhint`,
6
+ * `maxlength`, `pattern`, `readonly`, `aria-*`, native listeners like `@keydown`) goes on the `<input>` (or
7
+ * `<textarea>`).
8
+ *
5
9
  * @slot trailing Custom trailing content (e.g. an icon button) — replaces the built-in clear button when
6
10
  * present
7
11
  * @event update:modelValue Emitted on every keystroke — powers v-model
@@ -17,8 +21,11 @@ import { useDebounce } from "../composables/useDebounce";
17
21
  import { useLocale } from '../composables/useLocale'
18
22
  import { useFieldValidation } from '../composables/_useFieldValidation'
19
23
  import type { ValidateOn, ValidationRule } from '../composables/validation'
24
+ import { useSplitAttrs } from '../composables/_splitAttrs'
20
25
  import { FIELD_PADDING_END, fieldLabelClasses, vOverflowTitle, type FieldEndInset } from '../composables/_fieldLayout'
21
26
 
27
+ defineOptions({ inheritAttrs: false })
28
+
22
29
  const locale = useLocale()
23
30
  const props = withDefaults(
24
31
  defineProps<{
@@ -26,6 +33,8 @@ const props = withDefaults(
26
33
  modelValue: string | number;
27
34
  /** Field label */
28
35
  label: string;
36
+ /** Placeholder, shown while the field is focused and empty (the label sits above it then, as in M3) */
37
+ placeholder?: string;
29
38
  /** HTML input type */
30
39
  type?: string;
31
40
  /** Visual style */
@@ -86,7 +95,9 @@ const props = withDefaults(
86
95
 
87
96
  const emit = defineEmits<{ "update:modelValue": [string]; debounced: [string]; blur: [FocusEvent]; focus: [FocusEvent] }>();
88
97
 
89
- const id = useId();
98
+ const { rootAttrs, inputAttrs, attrId } = useSplitAttrs();
99
+ const autoId = useId();
100
+ const id = computed(() => attrId() ?? autoId);
90
101
  const slots = useSlots();
91
102
 
92
103
  const fieldBgEl = ref<HTMLElement | null>(null);
@@ -136,6 +147,7 @@ const inputClasses = computed(() => {
136
147
  const size = props.multiline ? (props.autoGrow ? "resize-none min-h-[56px]" : "resize-y min-h-[56px]") : "h-14";
137
148
  const base = [
138
149
  "peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent",
150
+ props.placeholder ? "focus:placeholder:text-on-surface-variant" : "",
139
151
  "transition-[border-color,border-width] duration-150",
140
152
  "disabled:cursor-not-allowed disabled:text-on-surface/38",
141
153
  hasError.value ? "caret-error" : "caret-primary",
@@ -182,6 +194,11 @@ const labelClasses = computed(() =>
182
194
  }),
183
195
  );
184
196
 
197
+ // Ours (the message below the field) plus any the consumer passed
198
+ function describedBy() {
199
+ return [errorMessage.value || props.hint ? messageId : '', inputAttrs()['aria-describedby']].filter(Boolean).join(' ') || undefined;
200
+ }
201
+
185
202
  function onInput(event: Event) {
186
203
  const target = event.target as HTMLInputElement | HTMLTextAreaElement;
187
204
  emit("update:modelValue", target.value);
@@ -207,7 +224,7 @@ defineExpose({
207
224
  </script>
208
225
 
209
226
  <template>
210
- <div class="flex flex-col gap-1">
227
+ <div class="flex flex-col gap-1" v-bind="rootAttrs()">
211
228
  <!--
212
229
  --field-bg: background behind the floating label in outlined mode, so it
213
230
  "cuts through" the border. Auto-detected from the nearest opaque ancestor
@@ -233,6 +250,7 @@ defineExpose({
233
250
  <textarea
234
251
  v-if="multiline"
235
252
  ref="textareaEl"
253
+ v-bind="inputAttrs()"
236
254
  :id="id"
237
255
  :value="String(modelValue)"
238
256
  :rows="rows"
@@ -240,8 +258,8 @@ defineExpose({
240
258
  :disabled="isDisabled"
241
259
  :required="required"
242
260
  :aria-invalid="hasError || undefined"
243
- :aria-describedby="errorMessage || hint ? messageId : undefined"
244
- placeholder=" "
261
+ :aria-describedby="describedBy()"
262
+ :placeholder="placeholder || ' '"
245
263
  :class="inputClasses"
246
264
  @input="onInput"
247
265
  @blur="onBlur"
@@ -250,6 +268,7 @@ defineExpose({
250
268
  <input
251
269
  v-else
252
270
  ref="inputOnlyEl"
271
+ v-bind="inputAttrs()"
253
272
  :id="id"
254
273
  :type="type"
255
274
  :value="modelValue"
@@ -257,9 +276,9 @@ defineExpose({
257
276
  :disabled="isDisabled"
258
277
  :required="required"
259
278
  :aria-invalid="hasError || undefined"
260
- :aria-describedby="errorMessage || hint ? messageId : undefined"
279
+ :aria-describedby="describedBy()"
261
280
  :autocomplete="autocomplete"
262
- placeholder=" "
281
+ :placeholder="placeholder || ' '"
263
282
  :class="inputClasses"
264
283
  v-overflow-title
265
284
  @input="onInput"