@m3ui-vue/m3ui-vue 0.7.1 → 0.8.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 (90) hide show
  1. package/README.md +5 -5
  2. package/dist/{MMenuItem-xQ1x6-DH.js → MMenuItem-vSLbJGqe.js} +299 -232
  3. package/dist/MMenuItem-vSLbJGqe.js.map +1 -0
  4. package/dist/code-editor.d.ts +1 -0
  5. package/dist/code-editor.js +22 -7
  6. package/dist/code-editor.js.map +1 -1
  7. package/dist/components/MCard.vue.d.ts +2 -0
  8. package/dist/components/MChatBubble.vue.d.ts +0 -1
  9. package/dist/components/MCircleProgressBar.vue.d.ts +0 -1
  10. package/dist/components/MCodeEditor.vue.d.ts +1 -1
  11. package/dist/components/MConfirmDialog.vue.d.ts +3 -0
  12. package/dist/components/MDialog.vue.d.ts +23 -7
  13. package/dist/components/MFab.vue.d.ts +2 -2
  14. package/dist/components/MListItem.vue.d.ts +11 -6
  15. package/dist/components/MNavigationRail.vue.d.ts +17 -1
  16. package/dist/components/MSelect.vue.d.ts +1 -0
  17. package/dist/components/MSwitch.vue.d.ts +8 -0
  18. package/dist/components/MTabs.vue.d.ts +3 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/m3ui-vue.css +1 -1
  21. package/dist/m3ui.js +1798 -1432
  22. package/dist/m3ui.js.map +1 -1
  23. package/dist/rich-text-editor.js +1 -1
  24. package/dist/styles/palettes.css +659 -0
  25. package/dist/styles/theme.css +1 -0
  26. package/dist/styles.css +1 -1
  27. package/package.json +13 -1
  28. package/src/__tests__/useColorPalette.test.ts +2 -2
  29. package/src/code-editor.ts +1 -0
  30. package/src/components/MAutocomplete.vue +35 -26
  31. package/src/components/MBadge.vue +1 -1
  32. package/src/components/MBottomSheet.vue +4 -4
  33. package/src/components/MButton.vue +36 -19
  34. package/src/components/MButtonGroup.vue +2 -2
  35. package/src/components/MCard.vue +76 -11
  36. package/src/components/MChatBubble.vue +0 -1
  37. package/src/components/MCheckbox.vue +58 -13
  38. package/src/components/MChip.vue +26 -6
  39. package/src/components/MCircleProgressBar.vue +7 -4
  40. package/src/components/MCodeEditor.vue +54 -8
  41. package/src/components/MColorPicker.vue +9 -8
  42. package/src/components/MColorPickerModal.vue +2 -2
  43. package/src/components/MCommandPalette.vue +1 -1
  44. package/src/components/MConfirmDialog.vue +4 -0
  45. package/src/components/MContextMenu.vue +23 -2
  46. package/src/components/MDatePicker.vue +11 -11
  47. package/src/components/MDatePickerModal.vue +5 -5
  48. package/src/components/MDateRangePicker.vue +12 -12
  49. package/src/components/MDateRangePickerModal.vue +3 -3
  50. package/src/components/MDialog.vue +103 -12
  51. package/src/components/MFab.vue +10 -7
  52. package/src/components/MFabMenu.vue +1 -1
  53. package/src/components/MIconButton.vue +41 -19
  54. package/src/components/MListItem.vue +35 -17
  55. package/src/components/MLoadingIndicator.vue +14 -7
  56. package/src/components/MMaskField.vue +14 -6
  57. package/src/components/MMenu.vue +28 -3
  58. package/src/components/MMenuItem.vue +2 -2
  59. package/src/components/MMultiAutocomplete.vue +41 -26
  60. package/src/components/MMultiSelect.vue +40 -22
  61. package/src/components/MNavigationBar.vue +5 -10
  62. package/src/components/MNavigationDrawer.vue +10 -9
  63. package/src/components/MNavigationRail.vue +335 -22
  64. package/src/components/MNumberField.vue +14 -6
  65. package/src/components/MOverlay.vue +1 -1
  66. package/src/components/MPinInput.vue +7 -4
  67. package/src/components/MProgressBar.vue +16 -10
  68. package/src/components/MRadio.vue +54 -12
  69. package/src/components/MSearchBar.vue +3 -2
  70. package/src/components/MSegmentedButton.vue +14 -9
  71. package/src/components/MSelect.vue +44 -32
  72. package/src/components/MSideSheet.vue +1 -1
  73. package/src/components/MSnackbar.vue +4 -4
  74. package/src/components/MSplitButton.vue +32 -17
  75. package/src/components/MSpotlightSearch.vue +1 -1
  76. package/src/components/MSwitch.vue +96 -18
  77. package/src/components/MTabs.vue +16 -12
  78. package/src/components/MTagInput.vue +33 -22
  79. package/src/components/MTextField.vue +14 -6
  80. package/src/components/MTimePicker.vue +9 -9
  81. package/src/components/MTimePickerModal.vue +16 -16
  82. package/src/components/MToolbar.vue +5 -3
  83. package/src/components/MTooltip.vue +4 -4
  84. package/src/components/MTopAppBar.vue +14 -6
  85. package/src/components/MTour.vue +1 -1
  86. package/src/composables/useColorPalette.ts +10 -0
  87. package/src/index.ts +1 -0
  88. package/src/styles/palettes.css +659 -0
  89. package/src/styles/theme.css +1 -0
  90. package/dist/MMenuItem-xQ1x6-DH.js.map +0 -1
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { computed, ref, watch, onUnmounted } from 'vue'
2
3
  import MIcon from './MIcon.vue'
3
4
  import MBadge from './MBadge.vue'
4
5
 
@@ -11,25 +12,181 @@ export interface NavRailItem {
11
12
  disabled?: boolean
12
13
  }
13
14
 
14
- withDefaults(defineProps<{
15
+ const props = withDefaults(defineProps<{
15
16
  modelValue: string | number
16
17
  items: NavRailItem[]
17
18
  alignment?: 'top' | 'center' | 'bottom'
18
- }>(), { alignment: 'top' })
19
+ /** M3 `WideNavigationRail`'s expanded state: items become icon+label side by side in a full-width pill instead of icon-over-label in a narrow centered one. */
20
+ expanded?: boolean
21
+ /**
22
+ * M3 `ModalWideNavigationRail` (default `hideOnCollapse = false` variant — not the
23
+ * dismissible, slide-from-offscreen one). Instead of this rail itself resizing between
24
+ * collapsed/expanded, the collapsed rail stays on screen exactly as-is (so it never
25
+ * affects the app's layout grid — `ModalWideNavigationRail`'s whole point) and `expanded`
26
+ * instead opens a Teleported, scrim-backed panel that floats above the rest of the app.
27
+ */
28
+ modal?: boolean
29
+ }>(), { alignment: 'top', expanded: false, modal: false })
19
30
 
20
- defineEmits<{ 'update:modelValue': [string | number] }>()
31
+ const emit = defineEmits<{
32
+ 'update:modelValue': [string | number]
33
+ 'update:expanded': [boolean]
34
+ }>()
35
+
36
+ // The inline rail never itself expands in modal mode — see `modal` prop doc above.
37
+ const railExpanded = computed(() => !props.modal && props.expanded)
38
+
39
+ /*
40
+ * The modal panel's items animate through the exact same collapsed->expanded item
41
+ * transition as the non-modal rail (pill grows, label slides out from under the icon) —
42
+ * NOT pre-rendered already-expanded and just revealed by the panel's width wipe. Since the
43
+ * panel only exists in the DOM while `expanded` is true (v-if), binding items directly to
44
+ * `expanded` would have them mount already in their expanded state with nothing to
45
+ * transition from. `panelExpanded` starts false on every mount and flips true a couple
46
+ * frames later (see onPanelEnter) so the item-level CSS transition actually has a
47
+ * collapsed -> expanded change to animate, running alongside (not instead of) the panel's
48
+ * own width spring.
49
+ */
50
+ const panelExpanded = ref(false)
51
+
52
+ function close() {
53
+ emit('update:expanded', false)
54
+ }
55
+ function selectModal(item: NavRailItem) {
56
+ if (item.disabled) return
57
+ emit('update:modelValue', item.value)
58
+ close()
59
+ }
60
+ function onKeydown(e: KeyboardEvent) {
61
+ if (e.key === 'Escape') close()
62
+ }
63
+
64
+ /*
65
+ * Modal panel open/close: a real width spring (rAF + semi-implicit Euler), not a CSS
66
+ * transition — same convention as MProgressBar/MTabs/etc (see CLAUDE.md). Values are
67
+ * `MotionSchemeKeyTokens.FastSpatial` (Standard scheme: dampingRatio 0.9, stiffness 1400 —
68
+ * `WideNavigationRailLayout` uses this exact token for the modal variant's width animation,
69
+ * vs `DefaultSpatial` for the non-modal inline rail). damping 0.9 is just underdamped enough
70
+ * to produce the slight overshoot/bounce M3's modal rail has on open, which a CSS easing
71
+ * curve can't reproduce (it can't overshoot past its own end value and settle back).
72
+ * The panel wipes from 0 to its full width like a curtain reveal — content is already laid
73
+ * out at full (expanded) size and is simply clipped by the panel's own `overflow-hidden`
74
+ * width, rather than each item's pill separately animating like the non-modal rail's does.
75
+ */
76
+ const PANEL_WIDTH = 220
77
+ const SPRING_DAMPING = 0.9
78
+ const SPRING_STIFFNESS = 1400
79
+
80
+ // Guards against two overlapping spring loops fighting over the same element's
81
+ // `style.width` (e.g. a close fired before a still-running open settles) — each call gets
82
+ // a token, and a loop quietly stops as soon as a newer call supersedes it instead of
83
+ // continuing to write stale values.
84
+ const springTokens = new WeakMap<HTMLElement, number>()
85
+
86
+ function springWidth(el: HTMLElement, from: number, to: number, done?: () => void) {
87
+ const token = (springTokens.get(el) ?? 0) + 1
88
+ springTokens.set(el, token)
89
+ let pos = from
90
+ let vel = 0
91
+ let last = performance.now()
92
+ const start = last
93
+ el.style.width = `${from}px`
94
+ function finish() {
95
+ el.style.width = `${to}px`
96
+ done?.()
97
+ }
98
+ function tick(now: number) {
99
+ if (springTokens.get(el) !== token) return
100
+ const dt = Math.min((now - last) / 1000, 1 / 30)
101
+ last = now
102
+ const accel = -SPRING_STIFFNESS * (pos - to) - 2 * SPRING_DAMPING * Math.sqrt(SPRING_STIFFNESS) * vel
103
+ vel += accel * dt
104
+ pos += vel * dt
105
+ el.style.width = `${pos}px`
106
+ // Settled normally, or a safety net in case rAF stalls/throttles badly enough that the
107
+ // spring can't converge in reasonable real time (e.g. a backgrounded tab) — either way
108
+ // the panel must never get stuck mid-animation forever.
109
+ if ((Math.abs(pos - to) < 0.5 && Math.abs(vel) < 5) || now - start > 1000) {
110
+ finish()
111
+ return
112
+ }
113
+ requestAnimationFrame(tick)
114
+ }
115
+ requestAnimationFrame(tick)
116
+ }
117
+
118
+ function onPanelEnter(el: Element, done: () => void) {
119
+ const panel = (el as HTMLElement).querySelector<HTMLElement>('.wnr-panel')
120
+ const scrim = (el as HTMLElement).querySelector<HTMLElement>('.wnr-scrim')
121
+ panelExpanded.value = false
122
+ if (scrim) {
123
+ scrim.style.opacity = '0'
124
+ requestAnimationFrame(() => requestAnimationFrame(() => {
125
+ scrim.style.opacity = '1'
126
+ panelExpanded.value = true
127
+ }))
128
+ } else {
129
+ panelExpanded.value = true
130
+ }
131
+ if (panel) springWidth(panel, 0, PANEL_WIDTH, done)
132
+ else done()
133
+ }
134
+ function onPanelLeave(el: Element, done: () => void) {
135
+ const panel = (el as HTMLElement).querySelector<HTMLElement>('.wnr-panel')
136
+ const scrim = (el as HTMLElement).querySelector<HTMLElement>('.wnr-scrim')
137
+ panelExpanded.value = false
138
+ if (scrim) scrim.style.opacity = '0'
139
+ if (panel) springWidth(panel, PANEL_WIDTH, 0, done)
140
+ else done()
141
+ }
142
+
143
+ watch(
144
+ () => props.modal && props.expanded,
145
+ (open) => {
146
+ if (open) {
147
+ document.addEventListener('keydown', onKeydown)
148
+ document.body.style.overflow = 'hidden'
149
+ } else {
150
+ document.removeEventListener('keydown', onKeydown)
151
+ document.body.style.overflow = ''
152
+ }
153
+ },
154
+ )
155
+
156
+ onUnmounted(() => {
157
+ document.removeEventListener('keydown', onKeydown)
158
+ if (props.modal && props.expanded) document.body.style.overflow = ''
159
+ })
21
160
  </script>
22
161
 
23
162
  <template>
24
- <nav class="flex h-full w-20 flex-col items-center border-r border-outline-variant bg-surface">
25
- <!-- FAB slot -->
26
- <div v-if="$slots.fab" class="flex shrink-0 items-center justify-center pt-3 pb-2">
27
- <slot name="fab" />
163
+ <!--
164
+ Inline rail: stays collapsed and in-flow at all times when `modal` is true — the real
165
+ ModalWideNavigationRail's collapsed rail is never affected by the modal panel opening,
166
+ so this half of the template intentionally reads `railExpanded` (forced false under
167
+ `modal`), not the raw `expanded` prop. The Teleported modal panel below is the part
168
+ that actually reacts to `expanded` when `modal` is set.
169
+ -->
170
+ <nav
171
+ class="flex h-full flex-col border-r border-outline-variant bg-surface transition-[width] duration-200"
172
+ :class="railExpanded ? 'w-[220px]' : 'w-20'"
173
+ >
174
+ <!--
175
+ Header slot: menu-toggle button and/or FAB. Left-anchored (not `items-center`) inside
176
+ a fixed 56px box, same technique as MNavigationDrawer's `.nd-toggle-inner` — `items-center`
177
+ would re-center against the *header's own* width, which changes a lot between collapsed
178
+ (80px rail) and expanded (220px rail), making the button visibly jump sideways when toggling.
179
+ A fixed-width box pinned to the same left inset as the items below stays put regardless.
180
+ -->
181
+ <div v-if="$slots.fab" class="flex shrink-0 flex-col items-start gap-2 px-3 pt-3 pb-2">
182
+ <div class="flex h-10 w-14 shrink-0 items-center justify-center">
183
+ <slot name="fab" />
184
+ </div>
28
185
  </div>
29
186
 
30
187
  <!-- Items -->
31
188
  <div
32
- class="flex flex-1 flex-col items-center gap-1 py-3"
189
+ class="flex flex-1 flex-col gap-1 px-3 py-3"
33
190
  :class="{
34
191
  'justify-start': alignment === 'top',
35
192
  'justify-center': alignment === 'center',
@@ -40,19 +197,41 @@ defineEmits<{ 'update:modelValue': [string | number] }>()
40
197
  v-for="item in items"
41
198
  :key="item.value"
42
199
  type="button"
43
- class="group flex w-full cursor-pointer flex-col items-center justify-center gap-1 px-3 py-2 focus-visible:outline-none"
200
+ class="group relative block h-16 w-full cursor-pointer focus-visible:outline-none"
44
201
  :class="item.disabled ? 'cursor-not-allowed opacity-[0.38]' : ''"
45
202
  :disabled="item.disabled"
46
203
  @click="!item.disabled && $emit('update:modelValue', item.value)"
47
204
  >
48
- <!-- Pill indicator -->
205
+ <!--
206
+ Row height is a constant 64dp (NavigationRailBaselineItemTokens.ContainerHeight)
207
+ in BOTH modes so toggling `expanded` never reflows sibling items — only the pill
208
+ and label (below) resize/reposition *within* that fixed-height row.
209
+
210
+ The pill's own top/height offsets always use fixed pixel values (top-1.5/h-8 vs
211
+ top-1/h-14), never percentage-based centering (top-1/2 + -translate-y-1/2) — that
212
+ resolves relative to the element's OWN size, which is also mid-transition, so mixing
213
+ it with an animating height makes the icon appear to snap to a center point and drift
214
+ as the box resizes, instead of a single clean interpolation.
215
+
216
+ Expanded width is intentionally NOT `w-full`: NavigationRailBaselineItemTokens'
217
+ ActiveIndicatorLeadingSpace/ActiveIndicatorTrailingSpace are 16dp each (pl-4/pr-4
218
+ below) around icon+label, not a bar stretched to the rail's own width — the pill is
219
+ meant to hug its content, leaving empty space in the rail after a short label like
220
+ "Home", exactly like the real WideNavigationRailItem. Nesting the label INSIDE the
221
+ pill (rather than a separately absolutely-positioned span) is what makes that
222
+ hugging automatic: as the label's own overflow-hidden box animates its width from 0,
223
+ the pill (inline-flex, no explicit width) resizes right along with it via ordinary
224
+ flex layout — no separate width bookkeeping needed. The pill is always left-anchored
225
+ with a constant `pl-4`, so the icon's horizontal position never moves at all.
226
+ -->
49
227
  <span
50
- class="inline-flex h-8 items-center justify-center rounded-2xl transition-all duration-200"
51
- :class="
228
+ class="absolute left-0 inline-flex items-center pl-4 rounded-full transition-all duration-200"
229
+ :class="[
230
+ railExpanded ? 'top-1 h-14 pr-4' : 'top-1.5 h-8 w-14',
52
231
  item.value === modelValue
53
- ? 'w-14 bg-secondary-container text-on-secondary-container'
54
- : 'w-14 bg-transparent text-on-surface-variant group-hover:bg-on-surface/8'
55
- "
232
+ ? 'bg-secondary-container text-on-secondary-container'
233
+ : 'bg-transparent text-on-surface-variant group-hover:bg-on-surface/8',
234
+ ]"
56
235
  >
57
236
  <MBadge v-if="item.badge != null" :count="item.badge">
58
237
  <MIcon :name="item.icon" :size="24" />
@@ -61,20 +240,154 @@ defineEmits<{ 'update:modelValue': [string | number] }>()
61
240
  <MIcon :name="item.icon" :size="24" />
62
241
  </MBadge>
63
242
  <MIcon v-else :name="item.icon" :size="24" />
243
+
244
+ <!--
245
+ Label, expanded: revealed through an `overflow-hidden` box whose width (and
246
+ margin, so it doesn't leave a gap when collapsed) grows left-to-right out of the
247
+ icon's edge, so the text reads as emerging out of the icon rather than fading in
248
+ in place. Text itself never moves — only the clipping box's width animates.
249
+ Animating `max-width` rather than `width` (up to a generous 200px cap, well past
250
+ any realistic label) is what lets the box settle at the label's own intrinsic
251
+ width once expanded — a plain `width` transition would need a fixed end value,
252
+ which is exactly the old bug: every label reveal stopped at the same hardcoded
253
+ 130px regardless of text length, leaving dead space in the pill after a short
254
+ label like "Home" instead of hugging it. `whitespace-nowrap` plus `inline-block`
255
+ keep it shrink-to-fit and from reflowing as max-width changes. Opacity animates
256
+ alongside it so collapsing reads as fading out while it shrinks, rather than
257
+ staying solid until the box clips it. Its own text color intentionally differs from
258
+ the pill's (`text-secondary` vs the pill's `text-on-secondary-container`) — M3's
259
+ `ItemActiveLabelTextColor` is a different token from `ItemActiveIconColor`.
260
+ -->
261
+ <span
262
+ class="inline-block overflow-hidden whitespace-nowrap text-left text-label-large font-medium transition-[max-width,opacity,margin-left] duration-200"
263
+ :class="[
264
+ railExpanded ? 'ml-2 max-w-[200px] opacity-100' : 'ml-0 max-w-0 opacity-0',
265
+ item.value === modelValue ? 'text-secondary' : 'text-on-surface-variant',
266
+ ]"
267
+ >
268
+ {{ item.label }}
269
+ </span>
64
270
  </span>
65
271
 
66
- <!-- Label -->
272
+ <!-- Label, collapsed: stays put below the icon, just fades out when expanding -->
67
273
  <span
68
- class="max-w-[56px] truncate text-center text-label-medium"
69
- :class="
70
- item.value === modelValue
71
- ? 'font-bold text-on-surface'
72
- : 'font-medium text-on-surface-variant'
73
- "
274
+ class="pointer-events-none absolute left-0 top-[42px] w-14 truncate text-center text-label-medium font-medium transition-opacity duration-150"
275
+ :class="[
276
+ railExpanded ? 'opacity-0' : 'opacity-100',
277
+ item.value === modelValue ? 'text-secondary' : 'text-on-surface-variant',
278
+ ]"
74
279
  >
75
280
  {{ item.label }}
76
281
  </span>
77
282
  </button>
78
283
  </div>
79
284
  </nav>
285
+
286
+ <!--
287
+ Modal panel: ModalWideNavigationRail's expanded state (default hideOnCollapse=false
288
+ variant). Floats above the app with its own scrim — `NavigationRailExpandedTokens`:
289
+ ModalContainerColor = surface-container, ModalContainerElevation = Level2. Flush against
290
+ the screen edge (`inset-y-0 left-0`), same as the collapsed rail and MNavigationDrawer —
291
+ confirmed against the real M3 demo app/reference video, not floating with a margin as an
292
+ earlier version of this comment assumed from the token name alone. Only the far (right)
293
+ corners are rounded (`rounded-r-lg`): rounding the near/screen-edge corners too would be
294
+ invisible anyway since they're flush against the viewport edge. Item markup below is
295
+ intentionally a near-duplicate of the inline rail's (see the top-of-file "not DRY" note
296
+ in CLAUDE.md for pickers/modals) — check here too if fixing a pill/label bug above.
297
+ -->
298
+ <Teleport v-if="modal" to="body">
299
+ <Transition :css="false" @enter="onPanelEnter" @leave="onPanelLeave">
300
+ <div v-if="expanded" class="fixed inset-0 z-100" @keydown.escape="close">
301
+ <div class="wnr-scrim absolute inset-0 bg-scrim/32" @click="close" />
302
+
303
+ <nav
304
+ class="wnr-panel fixed inset-y-0 left-0 z-10 flex flex-col overflow-hidden rounded-r-lg bg-surface-container shadow-elevation-2"
305
+ >
306
+ <div v-if="$slots.fab" class="flex shrink-0 flex-col items-start gap-2 px-3 pt-3 pb-2">
307
+ <div class="flex h-10 w-14 shrink-0 items-center justify-center">
308
+ <slot name="fab" />
309
+ </div>
310
+ </div>
311
+
312
+ <div
313
+ class="flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto px-3 py-3"
314
+ :class="{
315
+ 'justify-start': alignment === 'top',
316
+ 'justify-center': alignment === 'center',
317
+ 'justify-end': alignment === 'bottom',
318
+ }"
319
+ >
320
+ <!--
321
+ Items animate collapsed -> expanded exactly like the inline rail's (see the
322
+ comment on that block above) driven by `panelExpanded` instead of
323
+ `railExpanded` — see the `panelExpanded` doc in <script> for why the panel
324
+ can't just bind to `expanded` directly. Keep any pill/label fix in sync
325
+ between the two copies.
326
+ -->
327
+ <button
328
+ v-for="item in items"
329
+ :key="item.value"
330
+ type="button"
331
+ class="group relative block h-16 w-full shrink-0 cursor-pointer focus-visible:outline-none"
332
+ :class="item.disabled ? 'cursor-not-allowed opacity-[0.38]' : ''"
333
+ :disabled="item.disabled"
334
+ @click="selectModal(item)"
335
+ >
336
+ <span
337
+ class="absolute left-0 inline-flex items-center pl-4 rounded-full transition-all duration-200"
338
+ :class="[
339
+ panelExpanded ? 'top-1 h-14 pr-4' : 'top-1.5 h-8 w-14',
340
+ item.value === modelValue
341
+ ? 'bg-secondary-container text-on-secondary-container'
342
+ : 'bg-transparent text-on-surface-variant group-hover:bg-on-surface/8',
343
+ ]"
344
+ >
345
+ <MBadge v-if="item.badge != null" :count="item.badge">
346
+ <MIcon :name="item.icon" :size="24" />
347
+ </MBadge>
348
+ <MBadge v-else-if="item.badgeDot" dot>
349
+ <MIcon :name="item.icon" :size="24" />
350
+ </MBadge>
351
+ <MIcon v-else :name="item.icon" :size="24" />
352
+
353
+ <span
354
+ class="inline-block overflow-hidden whitespace-nowrap text-left text-label-large font-medium transition-[max-width,opacity,margin-left] duration-200"
355
+ :class="[
356
+ panelExpanded ? 'ml-2 max-w-[200px] opacity-100' : 'ml-0 max-w-0 opacity-0',
357
+ item.value === modelValue ? 'text-secondary' : 'text-on-surface-variant',
358
+ ]"
359
+ >
360
+ {{ item.label }}
361
+ </span>
362
+ </span>
363
+
364
+ <!-- Label, collapsed: stays put below the icon, just fades out when expanding -->
365
+ <span
366
+ class="pointer-events-none absolute left-0 top-[42px] w-14 truncate text-center text-label-medium font-medium transition-opacity duration-150"
367
+ :class="[
368
+ panelExpanded ? 'opacity-0' : 'opacity-100',
369
+ item.value === modelValue ? 'text-secondary' : 'text-on-surface-variant',
370
+ ]"
371
+ >
372
+ {{ item.label }}
373
+ </span>
374
+ </button>
375
+ </div>
376
+ </nav>
377
+ </div>
378
+ </Transition>
379
+ </Teleport>
80
380
  </template>
381
+
382
+ <style scoped>
383
+ /*
384
+ * Panel width is driven entirely by the JS spring in onPanelEnter/onPanelLeave (see
385
+ * <script>) — this is only the scrim's fade, a plain CSS transition since it's a
386
+ * non-spatial color/alpha change (M3's "effects" motion, as opposed to the panel's
387
+ * "spatial" width spring). JS just flips `.wnr-scrim`'s opacity; this rule is what
388
+ * actually animates that change.
389
+ */
390
+ .wnr-scrim {
391
+ transition: opacity 220ms ease;
392
+ }
393
+ </style>
@@ -88,22 +88,25 @@ const inputClasses = computed(() => {
88
88
  const base = [
89
89
  'peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent',
90
90
  'transition-[border-color,border-width] duration-150',
91
- 'disabled:cursor-not-allowed disabled:opacity-[0.38]',
91
+ 'disabled:cursor-not-allowed disabled:text-on-surface/38',
92
+ props.error ? 'caret-error' : 'caret-primary',
92
93
  'h-14', pl, pr,
93
94
  ]
94
95
  if (props.variant === 'outlined') {
95
96
  return [...base,
96
- 'rounded-sm border bg-transparent py-4',
97
+ 'rounded-xs border bg-transparent py-4',
97
98
  props.error
98
99
  ? 'border-error focus:border-2 focus:border-error'
99
100
  : 'border-outline hover:border-on-surface focus:border-2 focus:border-primary',
101
+ 'disabled:border-on-surface/12',
100
102
  ].join(' ')
101
103
  }
102
104
  return [...base,
103
- 'rounded-t-sm bg-surface-container-highest border-b pt-6 pb-2',
105
+ 'rounded-t-xs bg-surface-container-highest border-b pt-6 pb-2',
104
106
  props.error
105
107
  ? 'border-error focus:border-b-2 focus:border-error'
106
108
  : 'border-on-surface-variant hover:border-on-surface focus:border-b-2 focus:border-primary',
109
+ 'disabled:border-on-surface/38 disabled:bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]',
107
110
  ].join(' ')
108
111
  })
109
112
 
@@ -124,12 +127,14 @@ const labelClasses = computed(() => {
124
127
  'peer-[&:not(:placeholder-shown)]:-top-2.5 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:right-auto peer-[&:not(:placeholder-shown)]:max-w-[calc(100%-1.5rem)]',
125
128
  'peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:bg-[var(--field-bg)] peer-[&:not(:placeholder-shown)]:px-1',
126
129
  props.error ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',
130
+ 'peer-disabled:text-on-surface/38',
127
131
  ].join(' ')
128
132
  }
129
133
  return [...base,
130
134
  'peer-focus:top-2 peer-focus:translate-y-0 peer-focus:text-label-small',
131
135
  'peer-[&:not(:placeholder-shown)]:top-2 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small',
132
136
  props.error ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',
137
+ 'peer-disabled:text-on-surface/38',
133
138
  ].join(' ')
134
139
  })
135
140
  </script>
@@ -144,10 +149,13 @@ const labelClasses = computed(() => {
144
149
  >
145
150
  <div
146
151
  v-if="leadingIcon"
147
- class="pointer-events-none absolute left-3.5 text-on-surface-variant"
148
- :class="variant === 'filled' ? 'top-5' : 'top-4.5'"
152
+ class="pointer-events-none absolute left-3.5"
153
+ :class="[
154
+ variant === 'filled' ? 'top-4.5' : 'top-4',
155
+ disabled ? 'text-on-surface/38' : 'text-on-surface-variant',
156
+ ]"
149
157
  >
150
- <MIcon :name="leadingIcon" :size="20" />
158
+ <MIcon :name="leadingIcon" :size="24" />
151
159
  </div>
152
160
 
153
161
  <input
@@ -34,7 +34,7 @@ function handleScrimClick() {
34
34
  <div v-if="modelValue" class="fixed inset-0" :style="style">
35
35
  <div
36
36
  v-if="scrim"
37
- class="absolute inset-0 bg-scrim/50"
37
+ class="absolute inset-0 bg-scrim/32"
38
38
  @click="handleScrimClick"
39
39
  />
40
40
  <div class="relative h-full w-full">
@@ -148,23 +148,26 @@ watch(
148
148
 
149
149
  const boxClasses = computed(() => {
150
150
  const base = [
151
- 'h-14 w-12 text-center text-title-large text-on-surface outline-none',
151
+ 'h-14 w-12 text-center text-title-large outline-none',
152
152
  'transition-[border-color,border-width] duration-150',
153
- 'disabled:cursor-not-allowed disabled:opacity-[0.38]',
153
+ 'disabled:cursor-not-allowed disabled:text-on-surface/38',
154
+ props.error ? 'caret-error' : 'caret-primary',
154
155
  ]
155
156
  if (props.variant === 'outlined') {
156
157
  return [...base,
157
- 'rounded-sm border bg-transparent',
158
+ 'rounded-xs border bg-transparent text-on-surface',
158
159
  props.error
159
160
  ? 'border-error focus:border-2 focus:border-error'
160
161
  : 'border-outline hover:border-on-surface focus:border-2 focus:border-primary',
162
+ 'disabled:border-on-surface/12',
161
163
  ].join(' ')
162
164
  }
163
165
  return [...base,
164
- 'rounded-t-sm bg-surface-container-highest border-b',
166
+ 'rounded-t-xs bg-surface-container-highest border-b text-on-surface',
165
167
  props.error
166
168
  ? 'border-error focus:border-b-2 focus:border-error'
167
169
  : 'border-on-surface-variant hover:border-on-surface focus:border-b-2 focus:border-primary',
170
+ 'disabled:border-on-surface/38 disabled:bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]',
168
171
  ].join(' ')
169
172
  })
170
173
  </script>
@@ -35,9 +35,7 @@ const MARGIN_PX = 4; // gap between wave right-end and track start
35
35
  const WAVE_START = 10; // threshold % below which wave collapses to line
36
36
 
37
37
  // thickness-derived (computed so they react to prop changes)
38
- const effectiveThickness = computed(() =>
39
- props.thickness ?? (props.variant === "wavy" ? 3 : 4),
40
- );
38
+ const effectiveThickness = computed(() => props.thickness ?? 4);
41
39
  const waveMid = computed(() => AMP + effectiveThickness.value / 2);
42
40
  const waveViewH = computed(() => 2 * AMP + effectiveThickness.value);
43
41
 
@@ -199,19 +197,27 @@ watch(isIndeterminate, async (v) => {
199
197
  <div
200
198
  v-if="variant === 'linear'"
201
199
  class="relative w-full overflow-hidden rounded-full"
202
- :class="colorMap[color].track"
200
+ :class="isIndeterminate ? colorMap[color].track : ''"
203
201
  :style="{ height: `${effectiveThickness}px` }"
204
202
  role="progressbar"
205
203
  :aria-valuenow="isIndeterminate ? undefined : clampedValue"
206
204
  aria-valuemin="0"
207
205
  aria-valuemax="100"
208
206
  >
209
- <div
210
- v-if="!isIndeterminate"
211
- class="h-full rounded-full transition-[width] duration-300 ease-in-out"
212
- :class="colorMap[color].bar"
213
- :style="{ width: `${clampedValue}%` }"
214
- />
207
+ <!-- LinearProgressIndicatorTokens.TrackActiveSpace=4dp: the track starts
208
+ a fixed gap after the active bar, not flush against it. -->
209
+ <template v-if="!isIndeterminate">
210
+ <div
211
+ class="absolute inset-y-0 left-0 rounded-full transition-[width] duration-300 ease-in-out"
212
+ :class="colorMap[color].bar"
213
+ :style="{ width: `${clampedValue}%` }"
214
+ />
215
+ <div
216
+ class="absolute inset-y-0 right-0 rounded-full transition-[left] duration-300 ease-in-out"
217
+ :class="colorMap[color].track"
218
+ :style="{ left: `calc(${clampedValue}% + 4px)` }"
219
+ />
220
+ </template>
215
221
  <div
216
222
  v-else
217
223
  class="absolute inset-y-0 w-2/5 rounded-full animate-[m3-progress-indeterminate_1.6s_ease-in-out_infinite]"
@@ -23,25 +23,67 @@ const checkedColor: Record<string, string> = {
23
23
  tertiary: "text-tertiary",
24
24
  error: "text-error",
25
25
  };
26
+
27
+ // Just the fill color, reused for the hover/press state layer's tint below.
28
+ const checkedBgColor: Record<string, string> = {
29
+ primary: "bg-primary",
30
+ secondary: "bg-secondary",
31
+ tertiary: "bg-tertiary",
32
+ error: "bg-error",
33
+ };
34
+
35
+ /*
36
+ * RadioButtonTokens: UnselectedIconColor = OnSurfaceVariant at rest, but
37
+ * Unselected{Focus,Hover,Pressed}IconColor are all OnSurface — the ring+dot darkens on
38
+ * interaction, same as MCheckbox's unselected border does. SelectedIconColor stays Primary
39
+ * through every interaction state (no darkening once checked). Disabled dims via the
40
+ * blanket `opacity-[0.38]` already on <label> below (equivalent to the real
41
+ * Disabled{Selected,Unselected}IconOpacity = 0.38, just applied to the whole row rather
42
+ * than the icon specifically — numerically the same result for the icon itself).
43
+ */
44
+ const iconColorClasses = computed(() => {
45
+ if (props.disabled) return "text-on-surface-variant";
46
+ if (isChecked.value) return checkedColor[props.color];
47
+ return "text-on-surface-variant group-hover:text-on-surface group-active:text-on-surface peer-focus-visible:text-on-surface";
48
+ });
26
49
  </script>
27
50
 
28
51
  <template>
29
52
  <label
30
53
  :for="id"
31
- class="inline-flex items-center gap-3 select-none"
54
+ class="group inline-flex items-center gap-3 select-none"
32
55
  :class="disabled ? 'cursor-not-allowed opacity-[0.38]' : 'cursor-pointer'"
33
56
  >
34
- <span class="relative -m-3.5 flex h-12 w-12 shrink-0 items-center justify-center">
35
- <span class="relative flex h-5 w-5">
36
- <input
37
- :id="id"
38
- type="radio"
39
- class="sr-only"
40
- :checked="isChecked"
41
- :disabled="disabled"
42
- @change="emit('update:modelValue', value)"
43
- />
57
+ <!--
58
+ RadioButtonTokens.StateLayerSize = 40dp (was 48px). Unlike MCheckbox/MChip,
59
+ RadioButtonTokens has NO FocusIndicatorColor at all — the real radio doesn't get a
60
+ separate colored ring on focus, only this state-layer circle (which also reacts to
61
+ focus, not just hover/press) plus the icon color darkening above. So no focus-ring
62
+ span here, just `peer-focus-visible:` added to this same state-layer's opacity.
63
+ -->
64
+ <span class="relative -m-2.5 inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full">
65
+ <!--
66
+ Input stays nested inside this `relative` span (a true sibling of the state-layer
67
+ span below, satisfying `peer-*`'s sibling-combinator requirement) rather than hoisted
68
+ up to <label> — moving a sr-only, `position: absolute` input away from a nearby
69
+ positioned ancestor breaks the browser's native focus-scroll behavior (see MCheckbox's
70
+ CHANGELOG entry for the real bug this caused there).
71
+ -->
72
+ <input
73
+ :id="id"
74
+ type="radio"
75
+ class="peer sr-only"
76
+ :checked="isChecked"
77
+ :disabled="disabled"
78
+ @change="emit('update:modelValue', value)"
79
+ />
80
+ <span
81
+ v-if="!disabled"
82
+ class="pointer-events-none absolute inset-0 rounded-full opacity-0 transition-opacity duration-150 group-hover:opacity-[0.08] group-active:opacity-[0.12] peer-focus-visible:opacity-[0.08]"
83
+ :class="isChecked ? checkedBgColor[color] : 'bg-on-surface'"
84
+ />
44
85
 
86
+ <span class="relative flex h-5 w-5">
45
87
  <!--
46
88
  SVG radio: vector circles sharing center (10,10) stay round + concentric
47
89
  at any zoom. Outer ring uses r=8 (not 9) so the 2px stroke (7..9) leaves
@@ -51,7 +93,7 @@ const checkedColor: Record<string, string> = {
51
93
  <svg
52
94
  viewBox="0 0 20 20"
53
95
  class="h-full w-full transition-colors duration-150"
54
- :class="isChecked ? checkedColor[color] : 'text-on-surface-variant'"
96
+ :class="iconColorClasses"
55
97
  aria-hidden="true"
56
98
  >
57
99
  <circle cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="2" />