@m3ui-vue/m3ui-vue 1.1.4 → 1.2.1

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 (200) hide show
  1. package/dist/API.md +511 -34
  2. package/dist/MMenuItem-DI351kIf.js +929 -0
  3. package/dist/MMenuItem-DI351kIf.js.map +1 -0
  4. package/dist/{MSlider-JflHJ70q.js → MSlider-BnEy5ieZ.js} +295 -320
  5. package/dist/MSlider-BnEy5ieZ.js.map +1 -0
  6. package/dist/MTextField-BBmkaIbO.js +633 -0
  7. package/dist/MTextField-BBmkaIbO.js.map +1 -0
  8. package/dist/api.json +1 -1
  9. package/dist/chart.js +83 -49
  10. package/dist/chart.js.map +1 -1
  11. package/dist/code-editor.js +1 -1
  12. package/dist/components/MButton.vue.d.ts +7 -1
  13. package/dist/components/MButtonGroup.vue.d.ts +40 -31
  14. package/dist/components/MCarousel.vue.d.ts +2 -0
  15. package/dist/components/MChart.vue.d.ts +6 -0
  16. package/dist/components/MCircleProgressBar.vue.d.ts +5 -3
  17. package/dist/components/MContextMenu.vue.d.ts +2 -2
  18. package/dist/components/MCopyButton.vue.d.ts +1 -1
  19. package/dist/components/MExportButton.vue.d.ts +1 -1
  20. package/dist/components/MFab.vue.d.ts +2 -2
  21. package/dist/components/MFabMenu.vue.d.ts +1 -1
  22. package/dist/components/MIconButton.vue.d.ts +13 -1
  23. package/dist/components/MInfiniteScroll.vue.d.ts +1 -1
  24. package/dist/components/MMap.vue.d.ts +20 -2
  25. package/dist/components/MMapBaseLayers.vue.d.ts +3 -0
  26. package/dist/components/MMapFilter.vue.d.ts +3 -0
  27. package/dist/components/MMapLayers.vue.d.ts +3 -0
  28. package/dist/components/MMenu.vue.d.ts +2 -2
  29. package/dist/components/MMenuItem.vue.d.ts +7 -3
  30. package/dist/components/MNavigationDrawer.vue.d.ts +13 -2
  31. package/dist/components/MOverlay.vue.d.ts +12 -1
  32. package/dist/components/MProgressBar.vue.d.ts +5 -3
  33. package/dist/components/MPullToRefresh.vue.d.ts +7 -2
  34. package/dist/components/MRichTextEditor.vue.d.ts +7 -1
  35. package/dist/components/MSearchField.vue.d.ts +58 -0
  36. package/dist/components/MSegmentedButton.vue.d.ts +31 -23
  37. package/dist/components/MSimpleCarousel.vue.d.ts +2 -0
  38. package/dist/components/MSkeleton.vue.d.ts +6 -3
  39. package/dist/components/MSwipeToDismiss.vue.d.ts +1 -1
  40. package/dist/components/MSwitch.vue.d.ts +1 -1
  41. package/dist/components/MTextField.vue.d.ts +5 -1
  42. package/dist/components/MTimeline.vue.d.ts +85 -22
  43. package/dist/components/MTooltip.vue.d.ts +1 -1
  44. package/dist/components/_MDrawerItemList.vue.d.ts +2 -0
  45. package/dist/composables/_mapStyle.d.ts +13 -0
  46. package/dist/composables/_themeTransition.d.ts +2 -0
  47. package/dist/composables/_tooltipTrigger.d.ts +22 -0
  48. package/dist/composables/_useMenuNav.d.ts +28 -0
  49. package/dist/composables/useAutoGrow.d.ts +21 -0
  50. package/dist/composables/useColorPalette.d.ts +1 -1
  51. package/dist/composables/useLocale.d.ts +3 -0
  52. package/dist/composables/useMap.d.ts +19 -3
  53. package/dist/composables/useMapFilter.d.ts +4 -1
  54. package/dist/composables/useMapLayers.d.ts +5 -2
  55. package/dist/composables/useScrollReveal.d.ts +44 -0
  56. package/dist/composables/useThemeTokens.d.ts +21 -0
  57. package/dist/composables/viewportHints.d.ts +27 -0
  58. package/dist/directives/vClickOutside.d.ts +25 -0
  59. package/dist/directives/vFocusRing.d.ts +22 -0
  60. package/dist/directives/vLongPress.d.ts +27 -0
  61. package/dist/directives/vReveal.d.ts +10 -0
  62. package/dist/directives/vScrollElevation.d.ts +31 -0
  63. package/dist/directives/vSkeleton.d.ts +19 -0
  64. package/dist/directives/vStateLayer.d.ts +20 -0
  65. package/dist/directives/vSwipe.d.ts +45 -0
  66. package/dist/directives/vTooltip.d.ts +23 -0
  67. package/dist/index.d.ts +28 -1
  68. package/dist/locales/index.js +21 -7
  69. package/dist/locales/index.js.map +1 -1
  70. package/dist/m3ui-vue.css +1 -1
  71. package/dist/m3ui.js +7132 -6217
  72. package/dist/m3ui.js.map +1 -1
  73. package/dist/map.d.ts +1 -1
  74. package/dist/map.js +821 -791
  75. package/dist/map.js.map +1 -1
  76. package/dist/motion-DZiXG09o.js +150 -0
  77. package/dist/motion-DZiXG09o.js.map +1 -0
  78. package/dist/plugin.d.ts +24 -0
  79. package/dist/rich-text-editor.js +13 -9
  80. package/dist/rich-text-editor.js.map +1 -1
  81. package/dist/styles/theme.css +63 -0
  82. package/dist/styles.css +1 -1
  83. package/dist/{useLocale-CXibICQA.js → useLocale-JYxDDeXC.js} +4 -2
  84. package/dist/useLocale-JYxDDeXC.js.map +1 -0
  85. package/dist/useThemeTokens-Bv-Uv8eX.js +135 -0
  86. package/dist/useThemeTokens-Bv-Uv8eX.js.map +1 -0
  87. package/package.json +1 -1
  88. package/src/__tests__/MButton.test.ts +22 -0
  89. package/src/__tests__/MCarousel.test.ts +9 -0
  90. package/src/__tests__/MChart.test.ts +77 -5
  91. package/src/__tests__/MIconButton.test.ts +33 -0
  92. package/src/__tests__/MMap.test.ts +53 -1
  93. package/src/__tests__/MMapLayers.test.ts +46 -2
  94. package/src/__tests__/MMenu.test.ts +104 -1
  95. package/src/__tests__/MMenuItem.test.ts +18 -0
  96. package/src/__tests__/MNavigationDrawer.test.ts +80 -0
  97. package/src/__tests__/MOverlay.test.ts +49 -0
  98. package/src/__tests__/MProgressBar.test.ts +41 -0
  99. package/src/__tests__/MPullToRefresh.test.ts +33 -0
  100. package/src/__tests__/MRichTextEditor.test.ts +22 -0
  101. package/src/__tests__/MSearchField.test.ts +71 -0
  102. package/src/__tests__/MSegmentedButton.test.ts +10 -0
  103. package/src/__tests__/MSkeleton.test.ts +38 -0
  104. package/src/__tests__/MTimeline.test.ts +238 -0
  105. package/src/__tests__/_fakeMaplibre.ts +3 -1
  106. package/src/__tests__/attrsFallthrough.test.ts +3 -0
  107. package/src/__tests__/escapeStack.test.ts +93 -0
  108. package/src/__tests__/ssr.test.ts +21 -2
  109. package/src/__tests__/useAutoGrow.test.ts +103 -0
  110. package/src/__tests__/useScrollReveal.test.ts +102 -0
  111. package/src/__tests__/useThemeTokens.test.ts +114 -0
  112. package/src/__tests__/vClickOutside.test.ts +82 -0
  113. package/src/__tests__/vFocusRing.test.ts +36 -0
  114. package/src/__tests__/vLongPress.test.ts +81 -0
  115. package/src/__tests__/vScrollElevation.test.ts +89 -0
  116. package/src/__tests__/vSkeleton.test.ts +48 -0
  117. package/src/__tests__/vStateLayer.test.ts +53 -0
  118. package/src/__tests__/vSwipe.test.ts +93 -0
  119. package/src/__tests__/vTooltip.test.ts +95 -0
  120. package/src/__tests__/viewportHints.test.ts +41 -0
  121. package/src/components/MAutocomplete.vue +5 -0
  122. package/src/components/MBottomSheet.vue +4 -1
  123. package/src/components/MButton.vue +15 -1
  124. package/src/components/MButtonGroup.vue +22 -17
  125. package/src/components/MCarousel.vue +7 -1
  126. package/src/components/MChart.vue +74 -34
  127. package/src/components/MCircleProgressBar.vue +14 -9
  128. package/src/components/MCommandPalette.vue +3 -2
  129. package/src/components/MContextMenu.vue +19 -60
  130. package/src/components/MDragDropList.vue +2 -0
  131. package/src/components/MIconButton.vue +40 -1
  132. package/src/components/MKanban.vue +2 -0
  133. package/src/components/MLightbox.vue +7 -2
  134. package/src/components/MMap.vue +38 -5
  135. package/src/components/MMapBaseLayers.vue +7 -3
  136. package/src/components/MMapFilter.vue +7 -4
  137. package/src/components/MMapGeoJson.vue +1 -1
  138. package/src/components/MMapLayers.vue +6 -2
  139. package/src/components/MMapMeasure.vue +5 -2
  140. package/src/components/MMenu.vue +18 -59
  141. package/src/components/MMenuItem.vue +11 -2
  142. package/src/components/MMultiAutocomplete.vue +5 -0
  143. package/src/components/MNavigationDrawer.vue +96 -11
  144. package/src/components/MNavigationRail.vue +4 -15
  145. package/src/components/MOverlay.vue +32 -13
  146. package/src/components/MProgressBar.vue +25 -27
  147. package/src/components/MPullToRefresh.vue +20 -1
  148. package/src/components/MRichTextEditor.vue +19 -5
  149. package/src/components/MSearchBar.vue +5 -0
  150. package/src/components/MSearchField.vue +142 -0
  151. package/src/components/MSegmentedButton.vue +20 -18
  152. package/src/components/MSelect.vue +10 -1
  153. package/src/components/MSideSheet.vue +5 -2
  154. package/src/components/MSimpleCarousel.vue +10 -1
  155. package/src/components/MSkeleton.vue +30 -8
  156. package/src/components/MSpotlightSearch.vue +3 -2
  157. package/src/components/MTextField.vue +15 -2
  158. package/src/components/MTimeline.vue +370 -81
  159. package/src/components/MTooltip.vue +20 -152
  160. package/src/components/_MDrawerItemList.vue +25 -6
  161. package/src/composables/_mapStyle.ts +45 -0
  162. package/src/composables/_themeTransition.ts +2 -0
  163. package/src/composables/_tooltipTrigger.ts +184 -0
  164. package/src/composables/_useMenuNav.ts +209 -0
  165. package/src/composables/useAutoGrow.ts +78 -0
  166. package/src/composables/useLocale.ts +5 -0
  167. package/src/composables/useMap.ts +43 -5
  168. package/src/composables/useMapFilter.ts +6 -5
  169. package/src/composables/useMapLayers.ts +7 -6
  170. package/src/composables/useScrollReveal.ts +151 -0
  171. package/src/composables/useThemeTokens.ts +116 -0
  172. package/src/composables/viewportHints.ts +80 -0
  173. package/src/directives/vClickOutside.ts +90 -0
  174. package/src/directives/vFocusRing.ts +60 -0
  175. package/src/directives/vLongPress.ts +134 -0
  176. package/src/directives/vReveal.ts +57 -0
  177. package/src/directives/vScrollElevation.ts +116 -0
  178. package/src/directives/vSkeleton.ts +87 -0
  179. package/src/directives/vStateLayer.ts +83 -0
  180. package/src/directives/vSwipe.ts +197 -0
  181. package/src/directives/vTooltip.ts +128 -0
  182. package/src/index.ts +28 -1
  183. package/src/locales/de.ts +2 -0
  184. package/src/locales/es.ts +2 -0
  185. package/src/locales/fr.ts +2 -0
  186. package/src/locales/ja.ts +2 -0
  187. package/src/locales/ko.ts +2 -0
  188. package/src/locales/pt.ts +2 -0
  189. package/src/locales/zh.ts +2 -0
  190. package/src/map.ts +1 -1
  191. package/src/plugin.ts +34 -0
  192. package/src/styles/theme.css +63 -0
  193. package/dist/MMenuItem-BfjqwcYP.js +0 -830
  194. package/dist/MMenuItem-BfjqwcYP.js.map +0 -1
  195. package/dist/MSlider-JflHJ70q.js.map +0 -1
  196. package/dist/MTextField-NaIB6RbM.js +0 -673
  197. package/dist/MTextField-NaIB6RbM.js.map +0 -1
  198. package/dist/composables/_useThemeTokens.d.ts +0 -7
  199. package/dist/useLocale-CXibICQA.js.map +0 -1
  200. package/src/composables/_useThemeTokens.ts +0 -42
@@ -0,0 +1,142 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * A pill-shaped search input that filters in place: a list, a table, a grid of products. Unlike MSearchBar, it never
4
+ * expands into a results view; it's just the field, in M3's search bar colors and shape.
5
+ *
6
+ * Your `class` and `style` go on the pill; every other attribute (`name`, `autocomplete`, `aria-*`, listeners like
7
+ * `@focus` or `@keydown`) goes on the `<input>`.
8
+ *
9
+ * @slot leading Replaces the search icon (an avatar, a back or menu button…). Spaced for a 40px icon button, as in
10
+ * M3's search bar: its icon lands 16px from the edge, like the default one, and the text at the same place
11
+ * @slot trailing Extra content after the clear button (a mic button, a filter menu…)
12
+ * @event update:modelValue The text, on every keystroke — powers v-model
13
+ * @event search Enter was pressed, with the text
14
+ * @event clear The clear button (or Escape) emptied the field
15
+ */
16
+ import { computed, ref, useAttrs } from 'vue'
17
+ import MIcon from './MIcon.vue'
18
+ import { useLocale } from '../composables/useLocale'
19
+
20
+ defineOptions({ inheritAttrs: false })
21
+
22
+ const props = withDefaults(
23
+ defineProps<{
24
+ /** The text (v-model) */
25
+ modelValue?: string
26
+ /** Placeholder. Defaults to the locale's `search` */
27
+ placeholder?: string
28
+ /** Accessible name when there's no visible label. Defaults to the placeholder */
29
+ label?: string
30
+ /** Leading icon, a Material Symbol. Set to '' for none */
31
+ icon?: string
32
+ /** Height: `sm` 40px (body-medium text), `md` 48px, `lg` 56px (M3's search bar) */
33
+ size?: 'sm' | 'md' | 'lg'
34
+ /** Shows a clear button while there's text */
35
+ clearable?: boolean
36
+ /**
37
+ * Escape empties the field (keeping the key from closing a dialog or menu around it); on an empty field it
38
+ * leaves it and lets the key through
39
+ */
40
+ clearOnEscape?: boolean
41
+ /** Disables the field */
42
+ disabled?: boolean
43
+ }>(),
44
+ { modelValue: '', icon: 'search', size: 'lg', clearable: true, clearOnEscape: true, disabled: false },
45
+ )
46
+
47
+ const emit = defineEmits<{ 'update:modelValue': [string]; search: [string]; clear: [] }>()
48
+
49
+ const locale = useLocale()
50
+ const attrs = useAttrs()
51
+ const rootAttrs = computed(() => ({ class: attrs.class, style: attrs.style }))
52
+ const inputAttrs = computed(() => {
53
+ const { class: _c, style: _s, ...rest } = attrs
54
+ return rest
55
+ })
56
+
57
+ const inputEl = ref<HTMLInputElement>()
58
+ const placeholderText = computed(() => props.placeholder ?? locale.search)
59
+ const iconSize = computed(() => (props.size === 'sm' ? 20 : props.size === 'md' ? 22 : 24))
60
+
61
+ function onInput(e: Event) {
62
+ emit('update:modelValue', (e.target as HTMLInputElement).value)
63
+ }
64
+ function clear() {
65
+ emit('update:modelValue', '')
66
+ emit('clear')
67
+ inputEl.value?.focus()
68
+ }
69
+ function onKeydown(e: KeyboardEvent) {
70
+ if (e.key === 'Enter') emit('search', props.modelValue)
71
+ else if (e.key === 'Escape' && props.clearOnEscape) {
72
+ if (props.modelValue) {
73
+ // Handled here: a dialog or overlay around the field keeps its Escape for the next press
74
+ e.stopPropagation()
75
+ e.preventDefault()
76
+ emit('update:modelValue', '')
77
+ emit('clear')
78
+ } else inputEl.value?.blur()
79
+ }
80
+ }
81
+
82
+ defineExpose({
83
+ /** The `<input>` element */
84
+ inputEl,
85
+ /** Focuses the input */
86
+ focus: (options?: FocusOptions) => inputEl.value?.focus(options),
87
+ /** Takes focus away from the input */
88
+ blur: () => inputEl.value?.blur(),
89
+ })
90
+ </script>
91
+
92
+ <template>
93
+ <label
94
+ class="m3-search-field flex min-w-0 items-center text-on-surface focus-within:ring-2 focus-within:ring-secondary"
95
+ :class="[`m3-search-field-${size}`, { 'm3-search-field-slotted': $slots.leading }, disabled ? 'cursor-not-allowed opacity-38' : 'cursor-text']"
96
+ v-bind="rootAttrs"
97
+ >
98
+ <!-- A slotted 40px button sits 8px in and 4px from the text: its icon then lines up with the default one -->
99
+ <span v-if="$slots.leading" class="-me-2 flex shrink-0 items-center"><slot name="leading" /></span>
100
+ <MIcon v-else-if="icon" :name="icon" :size="iconSize" class="shrink-0 text-on-surface-variant" />
101
+ <input
102
+ ref="inputEl"
103
+ :value="modelValue"
104
+ type="search"
105
+ :placeholder="placeholderText"
106
+ :aria-label="label ?? placeholderText"
107
+ :disabled="disabled"
108
+ enterkeyhint="search"
109
+ class="min-w-0 flex-1 bg-transparent text-on-surface outline-none placeholder:text-on-surface-variant disabled:cursor-not-allowed [&::-webkit-search-cancel-button]:hidden"
110
+ :class="size === 'sm' ? 'text-body-medium' : 'text-body-large'"
111
+ v-bind="inputAttrs"
112
+ @input="onInput"
113
+ @keydown="onKeydown"
114
+ />
115
+ <button
116
+ v-if="clearable && modelValue && !disabled"
117
+ type="button"
118
+ class="-mr-1 flex shrink-0 cursor-pointer rounded-full p-1 text-on-surface-variant hover:bg-on-surface/8"
119
+ :aria-label="locale.clearSearch"
120
+ @click="clear"
121
+ >
122
+ <MIcon name="close" :size="iconSize - 2" />
123
+ </button>
124
+ <slot name="trailing" />
125
+ </label>
126
+ </template>
127
+
128
+ <style>
129
+ /* Default color, shape, spacing and height in the base layer, so a consumer's bg-*, rounded-*, px-*, gap-* or h-* wins */
130
+ @layer base {
131
+ .m3-search-field {
132
+ gap: 12px;
133
+ padding-inline: 16px;
134
+ background-color: var(--color-surface-container-high);
135
+ border-radius: 9999px;
136
+ }
137
+ .m3-search-field-slotted { padding-inline-start: 8px; }
138
+ .m3-search-field-sm { height: 40px; }
139
+ .m3-search-field-md { height: 48px; }
140
+ .m3-search-field-lg { height: 56px; }
141
+ }
142
+ </style>
@@ -1,4 +1,13 @@
1
- <script setup lang="ts">
1
+ <script lang="ts">
2
+ export interface SegmentedOption<V extends string | number = string | number> {
3
+ value: V
4
+ label: string
5
+ icon?: string
6
+ disabled?: boolean
7
+ }
8
+ </script>
9
+
10
+ <script setup lang="ts" generic="V extends string | number, M extends V | V[] = V">
2
11
  /**
3
12
  * A row of joined segments for choosing between a small set of related options — single or multi select.
4
13
  *
@@ -6,18 +15,11 @@
6
15
  */
7
16
  import MIcon from './MIcon.vue'
8
17
 
9
- export interface SegmentedOption {
10
- value: string | number
11
- label: string
12
- icon?: string
13
- disabled?: boolean
14
- }
15
-
16
18
  withDefaults(defineProps<{
17
- /** Selected value(s) */
18
- modelValue: string | number | (string | number)[]
19
+ /** Selected value, or values with `multiSelect` (v-model); typed after the options' values */
20
+ modelValue: M
19
21
  /** The options to choose from; see `SegmentedOption`. */
20
- options: SegmentedOption[]
22
+ options: SegmentedOption<V>[]
21
23
  /** Allow multiple selections */
22
24
  multiSelect?: boolean
23
25
  /** Button density */
@@ -26,22 +28,22 @@ withDefaults(defineProps<{
26
28
  color?: 'primary' | 'secondary' | 'tertiary'
27
29
  }>(), { multiSelect: false, density: 'default', color: 'primary' })
28
30
 
29
- const emit = defineEmits<{ 'update:modelValue': [string | number | (string | number)[]] }>()
31
+ const emit = defineEmits<{ 'update:modelValue': [M] }>()
30
32
 
31
- function isSelected(value: string | number, modelValue: string | number | (string | number)[]) {
33
+ function isSelected(value: V, modelValue: M) {
32
34
  return Array.isArray(modelValue) ? modelValue.includes(value) : modelValue === value
33
35
  }
34
36
 
35
- function toggle(opt: SegmentedOption, modelValue: string | number | (string | number)[], multi: boolean) {
37
+ function toggle(opt: SegmentedOption<V>, modelValue: M, multi: boolean) {
36
38
  if (opt.disabled) return
37
39
  if (multi) {
38
- const arr = Array.isArray(modelValue) ? [...modelValue] : [modelValue]
40
+ const arr: V[] = Array.isArray(modelValue) ? [...modelValue] : [modelValue as V]
39
41
  const idx = arr.indexOf(opt.value)
40
42
  if (idx >= 0) arr.splice(idx, 1)
41
43
  else arr.push(opt.value)
42
- emit('update:modelValue', arr)
44
+ emit('update:modelValue', arr as M)
43
45
  } else {
44
- emit('update:modelValue', opt.value)
46
+ emit('update:modelValue', opt.value as M)
45
47
  }
46
48
  }
47
49
  </script>
@@ -55,7 +57,7 @@ function toggle(opt: SegmentedOption, modelValue: string | number | (string | nu
55
57
  v-for="(opt, i) in options"
56
58
  :key="opt.value"
57
59
  type="button"
58
- class="relative inline-flex items-center justify-center gap-2 text-label-large font-medium transition-[background-color,color] duration-150 outline-none before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:duration-150 enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.12]"
60
+ class="relative inline-flex grow items-center justify-center gap-2 text-label-large font-medium transition-[background-color,color] duration-150 outline-none before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:duration-150 enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.12]"
59
61
  :class="[
60
62
  density === 'compact' ? 'h-8 px-3' : density === 'comfortable' ? 'h-10 px-4' : 'h-10 px-6',
61
63
  i > 0 ? (opt.disabled ? 'border-l border-outline/12' : 'border-l border-outline') : '',
@@ -10,6 +10,7 @@ import MIconButton from './MIconButton.vue'
10
10
  import { useFieldBg } from '../composables/useFieldBg'
11
11
  import { useLocale } from '../composables/useLocale'
12
12
  import { useScrollLock } from '../composables/_useScrollLock'
13
+ import { useEscapeStack } from '../composables/_useEscapeStack'
13
14
 
14
15
  export interface SelectOption {
15
16
  label: string
@@ -140,7 +141,13 @@ function onScroll(e: Event) {
140
141
  }
141
142
 
142
143
  function onKeydown(e: KeyboardEvent) {
143
- if (e.key === 'Escape') { open.value = false; modalOpen.value = false; return }
144
+ if (e.key === 'Escape') {
145
+ // Used to close the list: keep it from also closing a dialog around the select (the escape stack)
146
+ if (open.value || modalOpen.value) e.stopPropagation()
147
+ open.value = false
148
+ modalOpen.value = false
149
+ return
150
+ }
144
151
  if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); toggle(); return }
145
152
  if (!open.value && !modalOpen.value) return
146
153
  const opts = props.options.filter((o) => !o.disabled)
@@ -158,6 +165,8 @@ function onKeydown(e: KeyboardEvent) {
158
165
  }
159
166
 
160
167
  useScrollLock(modalOpen)
168
+ // The modal list is a modal surface: Escape closes it first, before a dialog it was opened from
169
+ useEscapeStack(modalOpen, () => (modalOpen.value = false))
161
170
 
162
171
  function closeModal() { modalOpen.value = false }
163
172
 
@@ -6,15 +6,16 @@
6
6
  * @slot header Replaces the default title text entirely — the close button stays
7
7
  * @slot default Sheet body content (scrollable)
8
8
  * @slot actions Footer action buttons, shown in a bordered strip below the content
9
- * @event update:modelValue Emitted when the sheet closes (scrim click, drag-to-dismiss from the left edge, or
9
+ * @event update:modelValue Emitted when the sheet closes (scrim click, drag-to-dismiss from the left edge, Escape, or
10
10
  * the close button) — powers v-model
11
11
  */
12
12
  import MIcon from './MIcon.vue'
13
13
  import { useSheetMotion } from '../composables/_useSheetMotion'
14
+ import { useEscapeStack } from '../composables/_useEscapeStack'
14
15
  import { useLocale } from '../composables/useLocale'
15
16
 
16
17
  const locale = useLocale()
17
- withDefaults(defineProps<{
18
+ const props = withDefaults(defineProps<{
18
19
  /** Open/closed state (v-model) */
19
20
  modelValue: boolean
20
21
  /** Sheet header title, ignored if the header slot is used */
@@ -25,6 +26,8 @@ withDefaults(defineProps<{
25
26
 
26
27
  const emit = defineEmits<{ 'update:modelValue': [boolean] }>()
27
28
  const close = () => emit('update:modelValue', false)
29
+ // Modal: Escape closes it, through the library's stack (a dialog or menu over it takes it first)
30
+ useEscapeStack(() => props.modelValue, close)
28
31
 
29
32
  // Slide in/out and drag-to-dismiss, as springs (see _useSheetMotion).
30
33
  const motion = useSheetMotion('x', close)
@@ -58,6 +58,7 @@ const props = withDefaults(
58
58
 
59
59
  const emit = defineEmits<{ change: [index: number] }>()
60
60
 
61
+ const rootEl = ref<HTMLElement>()
61
62
  const trackEl = ref<HTMLElement>()
62
63
  const itemEls = ref<HTMLElement[]>([])
63
64
  const activeIndex = ref(0)
@@ -251,11 +252,19 @@ onBeforeUnmount(() => {
251
252
  if (rafId) cancelAnimationFrame(rafId)
252
253
  })
253
254
 
254
- defineExpose({ next, prev, scrollToItem, scrollToPage })
255
+ defineExpose({
256
+ next,
257
+ prev,
258
+ scrollToItem,
259
+ scrollToPage,
260
+ /** Moves keyboard focus to the carousel, so the arrow keys move it */
261
+ focus: (options?: FocusOptions) => rootEl.value?.focus(options),
262
+ })
255
263
  </script>
256
264
 
257
265
  <template>
258
266
  <div
267
+ ref="rootEl"
259
268
  class="group relative overflow-hidden"
260
269
  tabindex="0"
261
270
  @keydown="onKeydown"
@@ -2,7 +2,9 @@
2
2
  /**
3
3
  * A loading placeholder shape — text, circular, rectangular, or rounded — with pulse or wave animation.
4
4
  */
5
- withDefaults(defineProps<{
5
+ import { computed } from 'vue'
6
+
7
+ const props = withDefaults(defineProps<{
6
8
  /** Skeleton shape */
7
9
  variant?: 'text' | 'circular' | 'rectangular' | 'rounded'
8
10
  /** CSS width (defaults to 100%, or 40px for circular) */
@@ -13,11 +15,24 @@ withDefaults(defineProps<{
13
15
  lines?: number
14
16
  /** Animation style */
15
17
  animation?: 'pulse' | 'wave' | 'none'
18
+ /**
19
+ * Corner radius: an M3 shape step (`none`, `xs` 4px, `sm` 8px, `md` 12px, `lg` 16px, `xl` 28px, `full`) or any CSS
20
+ * length, to match the card or thumbnail it stands in for. Defaults to the variant's (a Tailwind `rounded-*` class
21
+ * works too)
22
+ */
23
+ radius?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full' | (string & {})
16
24
  }>(), {
17
25
  variant: 'text',
18
26
  animation: 'pulse',
19
27
  lines: 1,
20
28
  })
29
+
30
+ const STEPS: Record<string, string> = { none: '0', full: '9999px' }
31
+ const borderRadius = computed(() => {
32
+ const r = props.radius
33
+ if (!r) return undefined
34
+ return STEPS[r] ?? (/^(xs|sm|md|lg|xl)$/.test(r) ? `var(--radius-${r})` : r)
35
+ })
21
36
  </script>
22
37
 
23
38
  <template>
@@ -28,25 +43,32 @@ withDefaults(defineProps<{
28
43
  :key="i"
29
44
  class="h-3.5 rounded-full bg-on-surface/10"
30
45
  :class="animation === 'pulse' ? 'animate-pulse' : animation === 'wave' ? 'skeleton-wave' : ''"
31
- :style="{ width: i === lines ? '60%' : (width ?? '100%') }"
46
+ :style="{ width: i === lines ? '60%' : (width ?? '100%'), borderRadius }"
32
47
  />
33
48
  </div>
34
49
 
35
50
  <!-- Single element -->
36
51
  <div
37
52
  v-else
38
- class="bg-on-surface/10"
53
+ class="m3-skeleton bg-on-surface/10"
39
54
  :class="[
40
- variant === 'circular' ? 'rounded-full' : variant === 'rounded' ? 'rounded-lg' : variant === 'text' ? 'rounded-full' : 'rounded-sm',
55
+ `m3-skeleton-${variant}`,
41
56
  animation === 'pulse' ? 'animate-pulse' : animation === 'wave' ? 'skeleton-wave' : '',
42
57
  ]"
43
- :style="{
44
- width: width ?? (variant === 'circular' ? '40px' : '100%'),
45
- height: height ?? (variant === 'circular' ? '40px' : variant === 'text' ? '14px' : '100px'),
46
- }"
58
+ :style="{ width, height, borderRadius }"
47
59
  />
48
60
  </template>
49
61
 
62
+ <style>
63
+ /* Default size and corners in the base layer, so a consumer's w-40, aspect-video or rounded-xl wins */
64
+ @layer base {
65
+ .m3-skeleton { width: 100%; height: 100px; border-radius: var(--radius-sm); }
66
+ .m3-skeleton-rounded { border-radius: var(--radius-lg); }
67
+ .m3-skeleton-text { height: 14px; border-radius: 9999px; }
68
+ .m3-skeleton-circular { width: 40px; height: 40px; border-radius: 9999px; }
69
+ }
70
+ </style>
71
+
50
72
  <style scoped>
51
73
  @keyframes skeleton-wave-move {
52
74
  0% { transform: translateX(-100%); }
@@ -13,6 +13,7 @@ import MIcon from './MIcon.vue'
13
13
  import MSpinner from './MSpinner.vue'
14
14
  import { useLocale } from '../composables/useLocale'
15
15
  import { useScrollLock } from '../composables/_useScrollLock'
16
+ import { useEscapeStack } from '../composables/_useEscapeStack'
16
17
 
17
18
  const locale = useLocale()
18
19
 
@@ -119,8 +120,6 @@ function onKeydown(e: KeyboardEvent) {
119
120
  } else if (e.key === 'Enter' && len) {
120
121
  e.preventDefault()
121
122
  selectResult(props.results[activeIndex.value]!)
122
- } else if (e.key === 'Escape') {
123
- close()
124
123
  }
125
124
  }
126
125
 
@@ -154,6 +153,8 @@ watch(
154
153
  )
155
154
 
156
155
  useScrollLock(() => props.modelValue)
156
+ // Escape through the library's stack: opened over a dialog, it closes alone
157
+ useEscapeStack(() => props.modelValue, close)
157
158
 
158
159
  watch(query, () => {
159
160
  activeIndex.value = 0
@@ -9,6 +9,7 @@
9
9
  */
10
10
  import { computed, ref, useId, useSlots } from "vue";
11
11
  import MIcon from "./MIcon.vue";
12
+ import { useAutoGrow } from "../composables/useAutoGrow";
12
13
  import { useFieldBg } from "../composables/useFieldBg";
13
14
  import { useDebounce } from "../composables/useDebounce";
14
15
  import { useLocale } from '../composables/useLocale'
@@ -36,8 +37,12 @@ const props = withDefaults(
36
37
  required?: boolean;
37
38
  /** Renders a textarea instead of an input */
38
39
  multiline?: boolean;
39
- /** Textarea rows (when multiline) */
40
+ /** Textarea rows (when multiline); with autoGrow, the fewest it shrinks to */
40
41
  rows?: number;
42
+ /** Multiline only: grows with the text from `rows` up to `maxRows`, instead of a fixed height with a drag handle */
43
+ autoGrow?: boolean;
44
+ /** With autoGrow, the most rows it grows to before scrolling. Unset grows without limit */
45
+ maxRows?: number;
41
46
  /** Passed through to the native autocomplete attribute */
42
47
  autocomplete?: string;
43
48
  /** Material Symbol shown before the input */
@@ -70,13 +75,20 @@ const { resolvedFieldBg } = useFieldBg(fieldBgEl, () => props.fieldBg);
70
75
 
71
76
  const { debounced: emitDebounced, cancel: cancelDebounce } = useDebounce((v: string) => emit("debounced", v), props.debounce)
72
77
 
78
+ const textareaEl = ref<HTMLTextAreaElement | null>(null);
79
+ useAutoGrow(() => (props.multiline && props.autoGrow ? textareaEl.value : null), {
80
+ minRows: () => props.rows,
81
+ maxRows: () => props.maxRows,
82
+ value: () => props.modelValue,
83
+ });
84
+
73
85
  const showClear = computed(() => props.clearable && String(props.modelValue).length > 0 && !props.disabled)
74
86
 
75
87
  const inputClasses = computed(() => {
76
88
  const hasTrailing = !!slots.trailing || props.clearable;
77
89
  const pl = props.leadingIcon ? "pl-12" : "pl-4";
78
90
  const pr = hasTrailing ? "pr-12" : "pr-4";
79
- const size = props.multiline ? "resize-y min-h-[56px]" : "h-14";
91
+ const size = props.multiline ? (props.autoGrow ? "resize-none min-h-[56px]" : "resize-y min-h-[56px]") : "h-14";
80
92
  const base = [
81
93
  "peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent",
82
94
  "transition-[border-color,border-width] duration-150",
@@ -186,6 +198,7 @@ function onInput(event: Event) {
186
198
 
187
199
  <textarea
188
200
  v-if="multiline"
201
+ ref="textareaEl"
189
202
  :id="id"
190
203
  :value="String(modelValue)"
191
204
  :rows="rows"