@m3ui-vue/m3ui-vue 1.1.2 → 1.1.4

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 (128) hide show
  1. package/README.md +1 -1
  2. package/dist/API.md +202 -10
  3. package/dist/{MIcon-DLOkQduI.js → MIcon-Bxh9j135.js} +15 -8
  4. package/dist/MIcon-Bxh9j135.js.map +1 -0
  5. package/dist/{MMenuItem-DVxKEv1W.js → MMenuItem-BfjqwcYP.js} +85 -64
  6. package/dist/MMenuItem-BfjqwcYP.js.map +1 -0
  7. package/dist/MSlider-JflHJ70q.js +1525 -0
  8. package/dist/MSlider-JflHJ70q.js.map +1 -0
  9. package/dist/{MTextField-rML9jnXs.js → MTextField-NaIB6RbM.js} +68 -66
  10. package/dist/MTextField-NaIB6RbM.js.map +1 -0
  11. package/dist/api.json +1 -1
  12. package/dist/code-editor.js +2 -2
  13. package/dist/components/MAnimatedNumber.vue.d.ts +29 -0
  14. package/dist/components/MButton.vue.d.ts +2 -0
  15. package/dist/components/MContainerTransform.vue.d.ts +59 -0
  16. package/dist/components/MDialog.vue.d.ts +8 -5
  17. package/dist/components/MFlex.vue.d.ts +1 -1
  18. package/dist/components/MIcon.vue.d.ts +2 -0
  19. package/dist/components/MIconButton.vue.d.ts +2 -0
  20. package/dist/components/MListGroup.vue.d.ts +23 -0
  21. package/dist/components/MListItem.vue.d.ts +5 -5
  22. package/dist/components/MNavigationRail.vue.d.ts +1 -1
  23. package/dist/components/MScheduler.vue.d.ts +2 -2
  24. package/dist/components/MScheme.vue.d.ts +60 -0
  25. package/dist/components/MSparkline.vue.d.ts +41 -0
  26. package/dist/components/MSplitter.vue.d.ts +1 -1
  27. package/dist/components/MStack.vue.d.ts +1 -1
  28. package/dist/components/MToolbar.vue.d.ts +32 -5
  29. package/dist/components/MWindow.vue.d.ts +2 -2
  30. package/dist/components/_MDrawerItemList.vue.d.ts +2 -0
  31. package/dist/components/_MToolbarFab.vue.d.ts +16 -0
  32. package/dist/composables/_containerTransform.d.ts +48 -0
  33. package/dist/composables/_useSegmentRuns.d.ts +8 -0
  34. package/dist/composables/dynamicColor.d.ts +11 -0
  35. package/dist/composables/useColorPalette.d.ts +3 -1
  36. package/dist/composables/useConfetti.d.ts +32 -0
  37. package/dist/composables/useContainerTransform.d.ts +30 -0
  38. package/dist/composables/useLocale.d.ts +9 -0
  39. package/dist/index.d.ts +10 -1
  40. package/dist/locales/index.js +35 -0
  41. package/dist/locales/index.js.map +1 -1
  42. package/dist/m3ui-vue.css +1 -1
  43. package/dist/m3ui.js +16844 -15530
  44. package/dist/m3ui.js.map +1 -1
  45. package/dist/map.js +55 -55
  46. package/dist/{material-color-utilities-Cktu8DBU.js → material-color-utilities-C_iikgRm.js} +928 -603
  47. package/dist/material-color-utilities-C_iikgRm.js.map +1 -0
  48. package/dist/rich-text-editor.js +11 -11
  49. package/dist/styles.css +1 -1
  50. package/dist/terminal.js +1 -1
  51. package/dist/{useLocale-CqQrhWFl.js → useLocale-CXibICQA.js} +6 -1
  52. package/dist/useLocale-CXibICQA.js.map +1 -0
  53. package/package.json +2 -1
  54. package/src/__tests__/MAnimatedNumber.test.ts +128 -0
  55. package/src/__tests__/MContainerTransform.test.ts +279 -0
  56. package/src/__tests__/MDialog.test.ts +27 -0
  57. package/src/__tests__/MIcon.test.ts +19 -0
  58. package/src/__tests__/MListItemExpandable.test.ts +48 -0
  59. package/src/__tests__/MListItemShape.test.ts +42 -5
  60. package/src/__tests__/MListKeyboard.test.ts +90 -0
  61. package/src/__tests__/MMapTools.test.ts +2 -1
  62. package/src/__tests__/MNavigationRail.test.ts +33 -0
  63. package/src/__tests__/MScheme.test.ts +107 -0
  64. package/src/__tests__/MSlider.test.ts +161 -0
  65. package/src/__tests__/MSparkline.test.ts +96 -0
  66. package/src/__tests__/MToolbar.test.ts +157 -0
  67. package/src/__tests__/attrsFallthrough.test.ts +6 -0
  68. package/src/__tests__/hydration.test.ts +25 -0
  69. package/src/__tests__/iconButtonNames.test.ts +124 -0
  70. package/src/__tests__/ssr.test.ts +1 -0
  71. package/src/__tests__/useConfetti.test.ts +81 -0
  72. package/src/components/MAnimatedNumber.vue +327 -0
  73. package/src/components/MAutocomplete.vue +34 -4
  74. package/src/components/MBottomSheet.vue +1 -0
  75. package/src/components/MButton.vue +4 -2
  76. package/src/components/MContainerTransform.vue +321 -0
  77. package/src/components/MDataTable.vue +1 -1
  78. package/src/components/MDialog.vue +31 -6
  79. package/src/components/MFab.vue +10 -5
  80. package/src/components/MIcon.vue +11 -4
  81. package/src/components/MIconButton.vue +3 -1
  82. package/src/components/MList.vue +33 -31
  83. package/src/components/MListGroup.vue +66 -0
  84. package/src/components/MListItem.vue +138 -84
  85. package/src/components/MMaskField.vue +3 -0
  86. package/src/components/MMultiAutocomplete.vue +5 -1
  87. package/src/components/MMultiSelect.vue +19 -9
  88. package/src/components/MNavigationRail.vue +40 -10
  89. package/src/components/MScheme.vue +162 -0
  90. package/src/components/MSearchBar.vue +2 -0
  91. package/src/components/MSelect.vue +44 -10
  92. package/src/components/MSideSheet.vue +3 -0
  93. package/src/components/MSimpleCarousel.vue +6 -0
  94. package/src/components/MSlider.vue +161 -42
  95. package/src/components/MSparkline.vue +250 -0
  96. package/src/components/MSplitButton.vue +3 -0
  97. package/src/components/MSpotlightSearch.vue +1 -0
  98. package/src/components/MTable.vue +1 -0
  99. package/src/components/MTagInput.vue +4 -0
  100. package/src/components/MTextField.vue +3 -0
  101. package/src/components/MToolbar.vue +256 -15
  102. package/src/components/MTour.vue +1 -0
  103. package/src/components/MTreeTable.vue +1 -0
  104. package/src/components/_MToolbarFab.vue +14 -0
  105. package/src/components/_MTreeNode.vue +3 -0
  106. package/src/composables/_containerTransform.ts +179 -0
  107. package/src/composables/_useEscapeStack.ts +2 -0
  108. package/src/composables/_useSegmentRuns.ts +39 -0
  109. package/src/composables/dynamicColor.ts +66 -0
  110. package/src/composables/useColorPalette.ts +2 -2
  111. package/src/composables/useConfetti.ts +204 -0
  112. package/src/composables/useContainerTransform.ts +59 -0
  113. package/src/composables/useLocale.ts +14 -0
  114. package/src/index.ts +10 -1
  115. package/src/locales/de.ts +5 -0
  116. package/src/locales/es.ts +5 -0
  117. package/src/locales/fr.ts +5 -0
  118. package/src/locales/ja.ts +5 -0
  119. package/src/locales/ko.ts +5 -0
  120. package/src/locales/pt.ts +5 -0
  121. package/src/locales/zh.ts +5 -0
  122. package/dist/MIcon-DLOkQduI.js.map +0 -1
  123. package/dist/MMenuItem-DVxKEv1W.js.map +0 -1
  124. package/dist/MSlider-BXsBv0ox.js +0 -1402
  125. package/dist/MSlider-BXsBv0ox.js.map +0 -1
  126. package/dist/MTextField-rML9jnXs.js.map +0 -1
  127. package/dist/material-color-utilities-Cktu8DBU.js.map +0 -1
  128. package/dist/useLocale-CqQrhWFl.js.map +0 -1
@@ -0,0 +1,162 @@
1
+ <script lang="ts">
2
+ import { ref } from 'vue'
3
+ import type { GeneratedScheme } from '../composables/dynamicColor'
4
+
5
+ // Shared by every MScheme: the app's light/dark state (the `dark` class on <html>, whoever sets it), one observer
6
+ // for all of them, and the schemes and image seeds already built.
7
+ const isDark = ref(false)
8
+ let observer: MutationObserver | undefined
9
+ let users = 0
10
+ function watchDark() {
11
+ if (users++ > 0) return
12
+ const html = document.documentElement
13
+ isDark.value = html.classList.contains('dark')
14
+ observer = new MutationObserver(() => (isDark.value = html.classList.contains('dark')))
15
+ observer.observe(html, { attributes: true, attributeFilter: ['class'] })
16
+ }
17
+ function unwatchDark() {
18
+ if (--users > 0) return
19
+ observer?.disconnect()
20
+ observer = undefined
21
+ }
22
+
23
+ const schemes = new Map<string, Promise<GeneratedScheme>>()
24
+ const imageSeeds = new Map<string, Promise<string>>()
25
+ </script>
26
+
27
+ <script setup lang="ts">
28
+ /**
29
+ * Paints its content with a color scheme of its own, built from a seed color or from an image's dominant color
30
+ * (Material You's content color: an album, a dish or a profile photo coloring its own page), or one of the
31
+ * palettes (a theme picker's previews). Every `bg-*`/`text-*`
32
+ * M3 utility and every component inside it uses the scheme, in light or dark like the rest of the app, while the
33
+ * rest of the app keeps its palette. Its text color is the scheme's `on-surface`; it sets no background.
34
+ *
35
+ * @slot default The content. Receives `{ seed, ready }`: the seed in use (the image's once it's read) and whether
36
+ * the scheme is applied yet
37
+ * @event seed Emitted with the seed color read from `image`
38
+ */
39
+ import { computed, onMounted, onUnmounted, shallowRef, watch } from 'vue'
40
+ import { generateScheme, seedFromImage, type SchemeVariant } from '../composables/dynamicColor'
41
+ import { hasPaletteCss, palettes } from '../composables/useColorPalette'
42
+
43
+ const props = withDefaults(
44
+ defineProps<{
45
+ /** Seed color (`#rrggbb`) the scheme is built from */
46
+ seed?: string
47
+ /**
48
+ * An image (URL) whose dominant color becomes the seed, picked as Android picks a wallpaper's. Cross-origin
49
+ * images need CORS headers. `seed` wins while both are set
50
+ */
51
+ image?: string
52
+ /**
53
+ * One of the palettes (`useColorPalette().palettes`, custom ones included), applied to this element only with
54
+ * its own CSS, in its standard contrast. `seed` and `image` win while set
55
+ */
56
+ palette?: string
57
+ /** How the seed spreads into the scheme; `content` and `fidelity` keep the seed's own color most visible */
58
+ variant?: SchemeVariant
59
+ /** Contrast level: 0 standard, 0.5 medium, 1 high (-1 reduced) */
60
+ contrast?: number
61
+ /** Element to render */
62
+ as?: string
63
+ }>(),
64
+ { variant: 'tonal-spot', contrast: 0, as: 'div' },
65
+ )
66
+
67
+ const emit = defineEmits<{ seed: [color: string] }>()
68
+
69
+ const imageSeed = shallowRef<string>()
70
+ const scheme = shallowRef<GeneratedScheme>()
71
+
72
+ // A palette with CSS (palettes.css, or a custom one with its own) is just its attribute on this element. 'purple'
73
+ // lives in :root with no [data-palette] block, and a custom palette may have none: those are built from their seed.
74
+ const paletteSeed = shallowRef<string>()
75
+ watch(
76
+ () => props.palette,
77
+ (id) => {
78
+ paletteSeed.value = undefined
79
+ if (!id || typeof document === 'undefined' || (id !== 'purple' && hasPaletteCss(id))) return
80
+ paletteSeed.value = palettes.find((p) => p.id === id)?.seed
81
+ },
82
+ { immediate: true },
83
+ )
84
+ const paletteAttr = computed(() => (!props.seed && !props.image && props.palette && !paletteSeed.value ? props.palette : undefined))
85
+
86
+ const activeSeed = computed(() => props.seed ?? (props.image ? imageSeed.value : paletteSeed.value))
87
+
88
+ watch(
89
+ () => props.image,
90
+ async (src) => {
91
+ imageSeed.value = undefined
92
+ if (!src || typeof window === 'undefined') return
93
+ let pending = imageSeeds.get(src)
94
+ if (!pending) {
95
+ pending = seedFromImage(src)
96
+ imageSeeds.set(src, pending)
97
+ pending.catch(() => imageSeeds.delete(src))
98
+ }
99
+ try {
100
+ const color = await pending
101
+ if (props.image !== src) return
102
+ imageSeed.value = color
103
+ emit('seed', color)
104
+ } catch {
105
+ // Unreadable image (failed to load, or cross-origin without CORS): keep the app's colors
106
+ }
107
+ },
108
+ { immediate: true },
109
+ )
110
+
111
+ watch(
112
+ () => [activeSeed.value, props.variant, props.contrast] as const,
113
+ async ([seed, variant, contrast]) => {
114
+ if (!seed) {
115
+ scheme.value = undefined
116
+ return
117
+ }
118
+ const key = `${seed}|${variant}|${contrast}`
119
+ let pending = schemes.get(key)
120
+ if (!pending) {
121
+ pending = generateScheme(seed, { variant, contrast })
122
+ schemes.set(key, pending)
123
+ }
124
+ const result = await pending
125
+ if (activeSeed.value === seed && props.variant === variant && props.contrast === contrast) scheme.value = result
126
+ },
127
+ { immediate: true },
128
+ )
129
+
130
+ onMounted(watchDark)
131
+ onUnmounted(unwatchDark)
132
+
133
+ const style = computed(() => {
134
+ if (!scheme.value || paletteAttr.value) return undefined
135
+ const dark = isDark.value
136
+ const out: Record<string, string> = { colorScheme: dark ? 'dark' : 'light' }
137
+ for (const [role, value] of Object.entries(dark ? scheme.value.dark : scheme.value.light)) out[`--color-${role}`] = value
138
+ return out
139
+ })
140
+ </script>
141
+
142
+ <template>
143
+ <component
144
+ :is="as"
145
+ class="m3-scheme"
146
+ :class="paletteAttr && isDark && 'dark'"
147
+ :data-palette="paletteAttr"
148
+ :style="style"
149
+ >
150
+ <slot :seed="activeSeed" :ready="!!style || !!paletteAttr" />
151
+ </component>
152
+ </template>
153
+
154
+ <style>
155
+ /* Plain text inherits a color computed outside, with the app's palette: use the scheme's. In the base layer so a
156
+ text-* class on the component wins. */
157
+ @layer base {
158
+ .m3-scheme {
159
+ color: var(--color-on-surface);
160
+ }
161
+ }
162
+ </style>
@@ -185,6 +185,7 @@ useScrollLock(() => expanded.value && fullscreen.value)
185
185
  @keydown="onKeydown"
186
186
  />
187
187
  <button
188
+ :aria-label="locale.clearSearch"
188
189
  v-if="clearable && modelValue && !disabled"
189
190
  type="button"
190
191
  class="flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-on-surface-variant transition-colors hover:bg-on-surface/8 hover:text-on-surface"
@@ -234,6 +235,7 @@ useScrollLock(() => expanded.value && fullscreen.value)
234
235
  />
235
236
  <MSpinner v-if="loading" :size="20" class="shrink-0 text-on-surface-variant" />
236
237
  <button
238
+ :aria-label="locale.clearSearch"
237
239
  v-else-if="clearable && modelValue"
238
240
  type="button"
239
241
  class="flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-on-surface-variant transition-colors hover:bg-on-surface/8 hover:text-on-surface"
@@ -70,8 +70,17 @@ const emit = defineEmits<{ 'update:modelValue': [unknown] }>()
70
70
 
71
71
  const locale = useLocale()
72
72
  const id = useId()
73
+ // ARIA combobox + listbox: the trigger names itself by the label and points at the open list and its selected option
74
+ const labelId = `${id}-label`
75
+ const listId = `${id}-list`
76
+ const optionId = (i: number) => `${id}-opt-${i}`
77
+ const selectedIndex = computed(() => props.options.findIndex((o) => eq(o.value, props.modelValue)))
73
78
  const open = ref(false)
74
79
  const modalOpen = ref(false)
80
+ // Focused (from the keyboard too) looks like open: M3's focused field, 2dp primary indicator and primary label,
81
+ // instead of the browser's own outline
82
+ const focused = ref(false)
83
+ const highlighted = computed(() => open.value || modalOpen.value || focused.value)
75
84
  const fieldEl = ref<HTMLElement | null>(null)
76
85
  const { resolvedFieldBg } = useFieldBg(fieldEl, () => props.fieldBg)
77
86
  const dropdownEl = ref<HTMLElement | null>(null)
@@ -164,7 +173,7 @@ onUnmounted(() => {
164
173
  const triggerClasses = computed(() => {
165
174
  const pl = props.leadingIcon ? 'pl-12' : 'pl-4'
166
175
  const base = [
167
- 'flex w-full items-center pr-10 text-body-large transition-[border-color,border-width] duration-150',
176
+ 'flex w-full items-center pr-10 text-body-large outline-none transition-[border-color,border-width] duration-150',
168
177
  props.disabled ? 'cursor-not-allowed' : 'cursor-pointer',
169
178
  pl,
170
179
  ]
@@ -172,7 +181,7 @@ const triggerClasses = computed(() => {
172
181
  if (props.variant === 'outlined') {
173
182
  const border = props.disabled
174
183
  ? 'border-on-surface/12'
175
- : open.value
184
+ : highlighted.value
176
185
  ? (props.error ? 'border-2 border-error' : 'border-2 border-primary')
177
186
  : (props.error ? 'border-error' : 'border-outline hover:border-on-surface')
178
187
  return [...base, 'h-14 rounded-xs border bg-transparent', border].join(' ')
@@ -180,7 +189,7 @@ const triggerClasses = computed(() => {
180
189
 
181
190
  const border = props.disabled
182
191
  ? 'border-on-surface/38'
183
- : open.value
192
+ : highlighted.value
184
193
  ? (props.error ? 'border-b-2 border-error' : 'border-b-2 border-primary')
185
194
  : (props.error ? 'border-error' : 'border-on-surface-variant hover:border-on-surface')
186
195
  const bg = props.disabled
@@ -189,7 +198,7 @@ const triggerClasses = computed(() => {
189
198
  return [...base, 'h-14 rounded-t-xs border-b pt-6 pb-2', bg, border].join(' ')
190
199
  })
191
200
 
192
- const isFloated = computed(() => hasValue.value || open.value)
201
+ const isFloated = computed(() => hasValue.value || highlighted.value)
193
202
 
194
203
  const labelClasses = computed(() => {
195
204
  const left = props.leadingIcon
@@ -210,7 +219,7 @@ const labelClasses = computed(() => {
210
219
  isFloated.value ? floated : unFloated,
211
220
  props.disabled
212
221
  ? 'text-on-surface/38'
213
- : open.value
222
+ : highlighted.value
214
223
  ? (props.error ? 'text-error' : 'text-primary')
215
224
  : (props.error ? 'text-error' : 'text-on-surface-variant'),
216
225
  ].join(' ')
@@ -242,22 +251,31 @@ const labelClasses = computed(() => {
242
251
  :id="id"
243
252
  :tabindex="disabled ? -1 : 0"
244
253
  role="combobox"
245
- :aria-expanded="open"
254
+ aria-haspopup="listbox"
255
+ :aria-expanded="open || modalOpen"
256
+ :aria-controls="open || modalOpen ? listId : undefined"
257
+ :aria-activedescendant="(open || modalOpen) && selectedIndex >= 0 ? optionId(selectedIndex) : undefined"
258
+ :aria-labelledby="label ? labelId : undefined"
259
+ :aria-required="required || undefined"
260
+ :aria-invalid="error || undefined"
246
261
  :aria-disabled="disabled"
247
262
  :class="[triggerClasses, disabled ? 'pointer-events-none' : '']"
248
263
  @click="toggle"
249
264
  @keydown="onKeydown"
265
+ @focus="focused = true"
266
+ @blur="focused = false"
250
267
  >
251
268
  <span v-if="hasValue" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ selectedLabel }}</span>
252
269
  </div>
253
270
 
254
271
  <!-- Floating label -->
255
- <label :for="id" :class="labelClasses">
272
+ <label :id="labelId" :for="id" :class="labelClasses">
256
273
  {{ label }}<span v-if="required" class="text-error">&nbsp;*</span>
257
274
  </label>
258
275
 
259
276
  <!-- Clear button -->
260
277
  <button
278
+ :aria-label="locale.clear"
261
279
  v-if="clearable && hasValue && !disabled"
262
280
  type="button"
263
281
  class="absolute right-9 top-1/2 -translate-y-1/2 flex h-6 w-6 cursor-pointer items-center justify-center rounded-full text-on-surface-variant transition-colors hover:bg-on-surface/8 hover:text-on-surface"
@@ -296,13 +314,20 @@ const labelClasses = computed(() => {
296
314
  >
297
315
  <div
298
316
  v-if="open && mode === 'docked'"
317
+ :id="listId"
299
318
  ref="dropdownEl"
319
+ role="listbox"
320
+ :aria-labelledby="label ? labelId : undefined"
300
321
  class="fixed z-500 max-h-60 overflow-auto rounded-xs bg-surface-container py-1 shadow-elevation-2"
301
322
  :style="dropPos"
302
323
  >
303
324
  <div
304
325
  v-for="(opt, i) in options"
326
+ :id="optionId(i)"
305
327
  :key="i"
328
+ role="option"
329
+ :aria-selected="eq(opt.value, modelValue)"
330
+ :aria-disabled="opt.disabled || undefined"
306
331
  class="flex cursor-pointer items-center gap-3 px-4 py-3 text-body-large"
307
332
  :class="[
308
333
  opt.disabled
@@ -337,20 +362,29 @@ const labelClasses = computed(() => {
337
362
  class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/32 p-4"
338
363
  @click.self="closeModal"
339
364
  >
340
- <div class="select-modal-box flex max-h-[80vh] w-full max-w-sm flex-col overflow-hidden rounded-[28px] bg-surface-container-high shadow-elevation-3">
365
+ <div
366
+ class="select-modal-box flex max-h-[80vh] w-full max-w-sm flex-col overflow-hidden rounded-[28px] bg-surface-container-high shadow-elevation-3"
367
+ role="dialog"
368
+ aria-modal="true"
369
+ :aria-labelledby="`${id}-dialog-title`"
370
+ >
341
371
  <!-- Header -->
342
372
  <div class="flex items-center justify-between px-6 pt-6 pb-4">
343
- <h2 class="text-headline-small text-on-surface">{{ label || placeholder }}</h2>
373
+ <h2 :id="`${id}-dialog-title`" class="text-headline-small text-on-surface">{{ label || placeholder }}</h2>
344
374
  <MIconButton icon="close" :label="locale.close" @click="closeModal" />
345
375
  </div>
346
376
 
347
377
  <div class="h-px bg-outline-variant" />
348
378
 
349
379
  <!-- Options list -->
350
- <div class="flex-1 overflow-y-auto py-2">
380
+ <div :id="listId" role="listbox" :aria-labelledby="`${id}-dialog-title`" class="flex-1 overflow-y-auto py-2">
351
381
  <div
352
382
  v-for="(opt, i) in options"
383
+ :id="optionId(i)"
353
384
  :key="i"
385
+ role="option"
386
+ :aria-selected="eq(opt.value, modelValue)"
387
+ :aria-disabled="opt.disabled || undefined"
354
388
  class="flex cursor-pointer items-center gap-4 px-6 py-3.5 text-body-large transition-colors"
355
389
  :class="[
356
390
  opt.disabled
@@ -11,7 +11,9 @@
11
11
  */
12
12
  import MIcon from './MIcon.vue'
13
13
  import { useSheetMotion } from '../composables/_useSheetMotion'
14
+ import { useLocale } from '../composables/useLocale'
14
15
 
16
+ const locale = useLocale()
15
17
  withDefaults(defineProps<{
16
18
  /** Open/closed state (v-model) */
17
19
  modelValue: boolean
@@ -56,6 +58,7 @@ const motion = useSheetMotion('x', close)
56
58
  <h2 class="text-title-large text-on-surface">{{ title }}</h2>
57
59
  </slot>
58
60
  <button
61
+ :aria-label="locale.close"
59
62
  type="button"
60
63
  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"
61
64
  @click="close"
@@ -9,6 +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
13
 
13
14
  export interface SimpleCarouselItem {
14
15
  src: string
@@ -18,6 +19,7 @@ export interface SimpleCarouselItem {
18
19
  ratio?: number
19
20
  }
20
21
 
22
+ const locale = useLocale()
21
23
  const props = withDefaults(
22
24
  defineProps<{
23
25
  /** Slides to render — required */
@@ -293,6 +295,7 @@ defineExpose({ next, prev, scrollToItem, scrollToPage })
293
295
 
294
296
  <template v-if="showArrows && items.length > 1">
295
297
  <button
298
+ :aria-label="locale.previous"
296
299
  type="button"
297
300
  class="absolute left-3 top-1/2 z-10 flex h-10 w-10 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full bg-surface/80 text-on-surface shadow-elevation-1 opacity-0 backdrop-blur-sm transition-all duration-200 hover:bg-surface hover:shadow-elevation-2 group-hover:opacity-100"
298
301
  @click="prev"
@@ -300,6 +303,7 @@ defineExpose({ next, prev, scrollToItem, scrollToPage })
300
303
  <MIcon name="chevron_left" :size="24" />
301
304
  </button>
302
305
  <button
306
+ :aria-label="locale.next"
303
307
  type="button"
304
308
  class="absolute right-3 top-1/2 z-10 flex h-10 w-10 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full bg-surface/80 text-on-surface shadow-elevation-1 opacity-0 backdrop-blur-sm transition-all duration-200 hover:bg-surface hover:shadow-elevation-2 group-hover:opacity-100"
305
309
  @click="next"
@@ -318,6 +322,8 @@ defineExpose({ next, prev, scrollToItem, scrollToPage })
318
322
  v-for="p in totalPages"
319
323
  :key="p"
320
324
  type="button"
325
+ :aria-label="locale.carouselItem.replace('{index}', String(p)).replace('{count}', String(totalPages))"
326
+ :aria-current="(p - 1) === activePage || undefined"
321
327
  class="h-2 cursor-pointer rounded-full transition-all duration-300"
322
328
  :class="(p - 1) === activePage ? 'w-5 bg-on-surface' : 'w-2 bg-on-surface/30 hover:bg-on-surface/50'"
323
329
  @click="isPageBased ? scrollToPage(p - 1) : scrollToItem(p - 1)"