@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
@@ -181,18 +181,18 @@ onUnmounted(() => {
181
181
  <div ref="triggerEl" class="relative mt-2" :style="{ '--field-bg': resolvedFieldBg }">
182
182
  <button
183
183
  type="button"
184
- class="flex h-14 w-full items-center gap-2 rounded-sm border bg-transparent px-4 text-left text-body-large transition-[border-color,border-width] duration-150"
184
+ class="flex h-14 w-full items-center gap-2 rounded-xs border bg-transparent px-4 text-left text-body-large transition-[border-color,border-width] duration-150"
185
185
  :class="[
186
- disabled ? 'pointer-events-none opacity-[0.38]' : 'cursor-pointer',
187
- open
186
+ disabled ? 'pointer-events-none cursor-not-allowed border-on-surface/12' : 'cursor-pointer',
187
+ !disabled && (open
188
188
  ? error ? 'border-2 border-error' : 'border-2 border-primary'
189
- : error ? 'border-error' : 'border-outline hover:border-on-surface',
189
+ : error ? 'border-error' : 'border-outline hover:border-on-surface'),
190
190
  ]"
191
191
  @click="!disabled && (open = !open)"
192
192
  >
193
- <MIcon name="date_range" :size="20" class="shrink-0 text-on-surface-variant" />
194
- <span v-if="displayValue" class="flex-1 text-on-surface">{{ displayValue }}</span>
195
- <span v-else class="flex-1 text-on-surface-variant">{{ label || placeholder || localeStrings.selectRange }}</span>
193
+ <MIcon name="date_range" :size="24" class="shrink-0" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'" />
194
+ <span v-if="displayValue" class="flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ displayValue }}</span>
195
+ <span v-else class="flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'">{{ label || placeholder || localeStrings.selectRange }}</span>
196
196
  <MIcon
197
197
  v-if="modelValue.start || modelValue.end"
198
198
  name="close"
@@ -204,7 +204,7 @@ onUnmounted(() => {
204
204
  <label
205
205
  v-if="label"
206
206
  class="pointer-events-none absolute -top-2.5 left-3 bg-(--field-bg) px-1 text-label-small transition-colors"
207
- :class="open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant'"
207
+ :class="disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant'"
208
208
  >
209
209
  {{ label }}
210
210
  </label>
@@ -223,10 +223,10 @@ onUnmounted(() => {
223
223
  <div
224
224
  v-if="open"
225
225
  ref="panelEl"
226
- class="fixed z-500 w-[320px] rounded-lg bg-surface-container p-4 shadow-elevation-3"
226
+ class="fixed z-500 w-[360px] rounded-[28px] bg-surface-container-high p-4 shadow-elevation-3"
227
227
  :style="dropPos"
228
228
  >
229
- <p class="mb-2 text-center text-label-medium text-on-surface-variant">
229
+ <p class="mb-2 text-center text-label-large text-on-surface-variant">
230
230
  {{ picking === 'start' ? (pickStartText ?? localeStrings.pickStart) : (pickEndText ?? localeStrings.pickEnd) }}
231
231
  </p>
232
232
 
@@ -237,7 +237,7 @@ onUnmounted(() => {
237
237
  </div>
238
238
 
239
239
  <div class="mb-1 grid grid-cols-7 gap-0.5 text-center">
240
- <span v-for="wd in WEEKDAYS" :key="wd" class="py-1 text-label-small font-medium text-on-surface-variant">{{ wd }}</span>
240
+ <span v-for="wd in WEEKDAYS" :key="wd" class="py-1 text-body-large font-medium text-on-surface">{{ wd }}</span>
241
241
  </div>
242
242
 
243
243
  <div class="grid grid-cols-7 gap-0.5">
@@ -245,7 +245,7 @@ onUnmounted(() => {
245
245
  v-for="(day, i) in calendarDays"
246
246
  :key="i"
247
247
  type="button"
248
- class="flex h-9 w-full items-center justify-center text-body-medium transition-colors duration-100"
248
+ class="flex h-10 w-full items-center justify-center text-body-medium transition-colors duration-100"
249
249
  :class="[
250
250
  day.disabled
251
251
  ? 'cursor-not-allowed text-on-surface/25 rounded-full'
@@ -159,13 +159,13 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
159
159
  <Transition name="m3-drp-modal">
160
160
  <div
161
161
  v-if="show"
162
- class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/40 p-4"
162
+ class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/32 p-4"
163
163
  @click.self="cancel"
164
164
  >
165
165
  <div class="drp-box w-[360px] rounded-[28px] bg-surface-container-high shadow-elevation-3">
166
166
  <!-- Header -->
167
167
  <div class="px-6 pt-6 pb-4">
168
- <p class="mb-3 text-label-medium text-on-surface-variant">
168
+ <p class="mb-3 text-label-large text-on-surface-variant">
169
169
  {{ title || locale.selectRange }}
170
170
  </p>
171
171
  <div class="flex items-center gap-3">
@@ -200,7 +200,7 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
200
200
  </div>
201
201
 
202
202
  <div class="mb-1 grid grid-cols-7 gap-0.5 text-center">
203
- <span v-for="wd in WEEKDAYS" :key="wd" class="py-1 text-label-small font-medium text-on-surface-variant">
203
+ <span v-for="wd in WEEKDAYS" :key="wd" class="py-1 text-body-large font-medium text-on-surface">
204
204
  {{ wd }}
205
205
  </span>
206
206
  </div>
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { watch } from 'vue'
2
+ import { nextTick, onUnmounted, ref, watch } from 'vue'
3
3
  import MIconButton from './MIconButton.vue'
4
4
  import { useLocale } from '../composables/useLocale'
5
5
 
@@ -8,14 +8,29 @@ const props = withDefaults(
8
8
  modelValue: boolean
9
9
  title?: string
10
10
  maxWidth?: string
11
+ /**
12
+ * M3's `AlertDialogDefaults` has no max-height token at all (only `DialogMaxWidth`) — the
13
+ * default here is a library-chosen viewport-relative cap, not a spec value.
14
+ */
15
+ maxHeight?: string
11
16
  persistent?: boolean
12
17
  fullscreen?: boolean
13
18
  closeLabel?: string
19
+ /**
20
+ * Whether the header shows a close ("X") icon button. M3's `AlertDialog` spec has no such
21
+ * button — it expects only a Cancel/Confirm text button in the actions row — so this is a
22
+ * deliberate library extension on top of the spec, kept opt-out (default `true`, matching
23
+ * this component's existing behavior) rather than added unconditionally.
24
+ */
25
+ closable?: boolean
14
26
  }>(),
15
27
  {
16
- maxWidth: 'max-w-md',
28
+ // AlertDialogDefaults.DialogMaxWidth = 560dp
29
+ maxWidth: 'max-w-[560px]',
30
+ maxHeight: 'max-h-[90vh]',
17
31
  persistent: false,
18
32
  fullscreen: false,
33
+ closable: true,
19
34
  },
20
35
  )
21
36
 
@@ -32,18 +47,49 @@ function onKeydown(event: KeyboardEvent) {
32
47
  if (event.key === 'Escape') close()
33
48
  }
34
49
 
50
+ // M3's dialog anatomy lists an optional divider between the (scrollable) content and the
51
+ // actions row — Compose's own AlertDialog.kt has no built-in implementation of it at all, so
52
+ // this shows it only when the content actually has more to scroll to, above the actions row.
53
+ const contentEl = ref<HTMLElement>()
54
+ const contentInnerEl = ref<HTMLElement>()
55
+ const showDivider = ref(false)
56
+ let resizeObserver: ResizeObserver | undefined
57
+
58
+ function updateDividerVisibility() {
59
+ const el = contentEl.value
60
+ if (!el) { showDivider.value = false; return }
61
+ showDivider.value = el.scrollHeight - el.scrollTop - el.clientHeight > 1
62
+ }
63
+
35
64
  watch(
36
65
  () => props.modelValue,
37
- (open) => {
66
+ async (open) => {
38
67
  if (open) {
39
68
  document.addEventListener('keydown', onKeydown)
40
69
  document.body.style.overflow = 'hidden'
70
+ await nextTick()
71
+ updateDividerVisibility()
72
+ // Observing contentEl alone only catches viewport-driven resizes (e.g. window resize
73
+ // changing the maxHeight cap) — its own box stays put when the *slotted* content
74
+ // changes height, since overflow doesn't affect the scroll container's own size. The
75
+ // inner wrapper around the slot grows/shrinks with the actual content, so that's what
76
+ // needs observing to catch dynamic content (reactive text, async-loaded content, etc).
77
+ resizeObserver = new ResizeObserver(updateDividerVisibility)
78
+ if (contentEl.value) resizeObserver.observe(contentEl.value)
79
+ if (contentInnerEl.value) resizeObserver.observe(contentInnerEl.value)
41
80
  } else {
42
81
  document.removeEventListener('keydown', onKeydown)
43
82
  document.body.style.overflow = ''
83
+ resizeObserver?.disconnect()
84
+ resizeObserver = undefined
44
85
  }
45
86
  },
46
87
  )
88
+
89
+ onUnmounted(() => {
90
+ document.removeEventListener('keydown', onKeydown)
91
+ resizeObserver?.disconnect()
92
+ })
47
93
  </script>
48
94
 
49
95
  <template>
@@ -52,23 +98,68 @@ watch(
52
98
  <Transition v-if="!fullscreen" name="m3-dialog">
53
99
  <div
54
100
  v-if="modelValue"
55
- class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/40 p-4"
101
+ class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/32 p-4"
56
102
  @click.self="close"
57
103
  >
58
104
  <div
59
- class="dialog-box flex max-h-[90vh] w-full flex-col rounded-xl bg-surface-container-high shadow-elevation-3"
60
- :class="maxWidth"
105
+ class="dialog-box flex min-w-[280px] w-full flex-col rounded-xl bg-surface-container-high shadow-elevation-3"
106
+ :class="[maxWidth, maxHeight]"
61
107
  >
62
- <div class="flex items-start justify-between gap-4 px-6 pt-6 pb-2">
63
- <h2 class="text-headline-small text-on-surface">
108
+ <!--
109
+ AlertDialogDefaults.dialogPadding is 24dp on all four sides of the whole content
110
+ column, with per-element bottom paddings (IconPadding/TitlePadding/textPadding)
111
+ providing the gaps BETWEEN elements — not a single wrapping padding, since this
112
+ template uses separate divs per section instead of one padded Column. Each
113
+ section's own top/bottom classes are chosen so the combined gaps still land on
114
+ the right dp value: title-to-body is 16dp (8px here + 8px there), body-to-actions
115
+ is 24dp (8px here + 16px there), and the outermost edges (top of title, bottom of
116
+ whichever section is last) are the full 24dp on their own.
117
+ -->
118
+ <div class="relative px-6 pt-6 pb-2">
119
+ <!--
120
+ Wrapped in a plain div rather than passing `absolute right-4 top-4` straight to
121
+ MIconButton: its root already carries its own `relative` (for the ripple span),
122
+ and Tailwind resolves conflicting position utilities by source order in the
123
+ compiled CSS, not by order in the class attribute — so an external `absolute`
124
+ can silently lose to that internal `relative` instead of overriding it.
125
+ -->
126
+ <div v-if="closable && !persistent" class="absolute right-4 top-4">
127
+ <MIconButton icon="close" :label="closeLabel ?? locale.close" @click="close" />
128
+ </div>
129
+ <!--
130
+ Icon slot: M3 AlertDialog's optional `icon` param (IconColor=Secondary,
131
+ IconSize=24dp expected from the slot content, IconPadding bottom=16dp below it),
132
+ which per spec also centers the title ("Align the title to the center when an
133
+ icon is present") — reserving `pr-10` on the title only when the close button is
134
+ also showing, so a centered title doesn't collide with it.
135
+ -->
136
+ <div v-if="$slots.icon" class="mb-4 flex justify-center text-secondary">
137
+ <slot name="icon" />
138
+ </div>
139
+ <h2
140
+ class="text-headline-small text-on-surface"
141
+ :class="[
142
+ $slots.icon ? 'text-center' : 'text-left',
143
+ closable && !persistent ? ($slots.icon ? 'px-10' : 'pr-10') : '',
144
+ ]"
145
+ >
64
146
  <slot name="title">{{ title }}</slot>
65
147
  </h2>
66
- <MIconButton v-if="!persistent" icon="close" :label="closeLabel ?? locale.close" @click="close" />
67
148
  </div>
68
- <div class="overflow-y-auto px-6 py-2 text-body-medium text-on-surface-variant">
69
- <slot />
149
+ <div
150
+ ref="contentEl"
151
+ class="overflow-y-auto px-6 pt-2 text-body-medium text-on-surface-variant"
152
+ :class="$slots.actions ? 'pb-2' : 'pb-6'"
153
+ @scroll="updateDividerVisibility"
154
+ >
155
+ <div ref="contentInnerEl">
156
+ <slot />
157
+ </div>
70
158
  </div>
71
- <div v-if="$slots.actions" class="flex justify-end gap-2 px-6 py-4">
159
+ <!-- Divider: M3 dialog anatomy's optional divider, shown only while the content has more to scroll to -->
160
+ <div v-if="showDivider && $slots.actions" class="shrink-0 border-t border-outline-variant" />
161
+ <!-- flex-wrap approximates AlertDialogFlowRow: buttons wrap to a new line instead of overflowing when labels are too long to fit on one -->
162
+ <div v-if="$slots.actions" class="flex flex-wrap justify-end gap-2 px-6 pt-4 pb-6">
72
163
  <slot name="actions" />
73
164
  </div>
74
165
  </div>
@@ -14,7 +14,7 @@ const props = withDefaults(
14
14
  icon: string
15
15
  label?: string
16
16
  color?: 'primary' | 'secondary' | 'tertiary' | 'surface'
17
- size?: 'small' | 'regular' | 'large'
17
+ size?: 'small' | 'regular' | 'medium' | 'large'
18
18
  disabled?: boolean
19
19
  items?: SpeedDialItem[]
20
20
  direction?: 'up' | 'down' | 'left' | 'right' | 'radial'
@@ -77,7 +77,8 @@ const fabSizeClasses = computed(() => {
77
77
  // icon-to-label gap, 20dp end padding, 80dp minimum width.
78
78
  if (props.label) return 'h-14 min-w-20 rounded-2xl pl-4 pr-5 gap-3'
79
79
  switch (props.size) {
80
- case 'small': return 'h-10 w-10 rounded-lg'
80
+ case 'small': return 'h-10 w-10 rounded-md'
81
+ case 'medium': return 'h-20 w-20 rounded-[20px]'
81
82
  case 'large': return 'h-24 w-24 rounded-[28px]'
82
83
  default: return 'h-14 w-14 rounded-2xl'
83
84
  }
@@ -86,8 +87,9 @@ const fabSizeClasses = computed(() => {
86
87
  const fabIconSize = computed(() => {
87
88
  if (props.label) return 24
88
89
  switch (props.size) {
89
- case 'small': return 20
90
- case 'large': return 36
90
+ case 'small': return 24
91
+ case 'medium': return 28
92
+ case 'large': return 32
91
93
  default: return 24
92
94
  }
93
95
  })
@@ -96,6 +98,7 @@ const fabPx = computed(() => {
96
98
  if (props.label) return 56
97
99
  switch (props.size) {
98
100
  case 'small': return 40
101
+ case 'medium': return 80
99
102
  case 'large': return 96
100
103
  default: return 56
101
104
  }
@@ -277,7 +280,7 @@ onUnmounted(() => {
277
280
  :is="fabTag"
278
281
  :to="to || undefined"
279
282
  :type="to ? undefined : 'button'"
280
- class="relative inline-flex cursor-pointer items-center justify-center overflow-hidden shadow-elevation-1 transition-shadow duration-150 hover:shadow-elevation-2 active:shadow-elevation-1 disabled:cursor-not-allowed disabled:opacity-[0.38] before:content-[''] before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:duration-150 hover:before:opacity-[0.08] active:before:opacity-[0.12]"
283
+ class="relative inline-flex cursor-pointer items-center justify-center overflow-hidden shadow-elevation-3 transition-shadow duration-150 hover:shadow-elevation-4 active:shadow-elevation-3 disabled:cursor-not-allowed disabled:opacity-[0.38] before:content-[''] before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:duration-150 hover:before:opacity-[0.08] active:before:opacity-[0.12]"
281
284
  :class="[colorMap[color], fabSizeClasses]"
282
285
  :disabled="disabled"
283
286
  @pointerdown="createRipple"
@@ -313,7 +316,7 @@ onUnmounted(() => {
313
316
  :is="item.to ? 'RouterLink' : 'button'"
314
317
  :to="item.to || undefined"
315
318
  :type="item.to ? undefined : 'button'"
316
- class="relative flex cursor-pointer items-center justify-center overflow-hidden rounded-lg shadow-elevation-1 transition-shadow duration-150 hover:shadow-elevation-2 active:shadow-elevation-1 before:content-[''] before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:duration-150 hover:before:opacity-[0.08] active:before:opacity-[0.12]"
319
+ class="relative flex cursor-pointer items-center justify-center overflow-hidden rounded-lg shadow-elevation-3 transition-shadow duration-150 hover:shadow-elevation-4 active:shadow-elevation-3 before:content-[''] before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:duration-150 hover:before:opacity-[0.08] active:before:opacity-[0.12]"
317
320
  :class="colorMap[color]"
318
321
  :style="{ width: `${ITEM_PX}px`, height: `${ITEM_PX}px` }"
319
322
  @pointerdown="(e: PointerEvent) => handleItemClick(e, item, e.currentTarget as HTMLElement)"
@@ -328,7 +331,7 @@ onUnmounted(() => {
328
331
  enter/leave transform (which would otherwise make it look like it
329
332
  shrinks/lags instead of just covering the screen). -->
330
333
  <Transition name="m3-fab-scrim">
331
- <div v-if="scrim && hasContent && open" class="fixed inset-0 bg-scrim/40" style="z-index: 999" />
334
+ <div v-if="scrim && hasContent && open" class="fixed inset-0 bg-scrim/32" style="z-index: 999" />
332
335
  </Transition>
333
336
 
334
337
  <!-- Custom content panel -->
@@ -104,7 +104,7 @@ function handleItemClick(item: FabMenuItem, close: () => void) {
104
104
  :key="i"
105
105
  :to="item.to || undefined"
106
106
  :type="item.to ? undefined : 'button'"
107
- class="m3-fabmenu-item shrink-0 cursor-pointer rounded-full font-medium shadow-elevation-1 transition-shadow duration-150 hover:shadow-elevation-2 disabled:cursor-not-allowed disabled:opacity-[0.38]"
107
+ class="m3-fabmenu-item shrink-0 cursor-pointer rounded-full font-medium shadow-elevation-3 transition-shadow duration-150 hover:shadow-elevation-4 disabled:cursor-not-allowed disabled:opacity-[0.38]"
108
108
  :class="[colorMap[item.color ?? color], revealClass]"
109
109
  :style="{ '--m3-fabmenu-delay': `${i * 35}ms` }"
110
110
  :disabled="item.disabled"
@@ -22,38 +22,57 @@ const props = withDefaults(
22
22
 
23
23
  const tag = computed(() => props.to ? 'RouterLink' : 'button')
24
24
 
25
+ // Container height/width (icon buttons are always square by default — real
26
+ // `IconButtonDefaults.<tier>ContainerSize()` also has Narrow/Wide width options not
27
+ // implemented here, matching the existing scope of MButton's size tiers) and icon size
28
+ // per M3's 5-tier `{XSmall,Small,Medium,Large,XLarge}IconButtonTokens.kt`. `squareRadius`
29
+ // matches each tier's own `ContainerShapeSquare` (12px xs/sm, 16px md, 28px lg/xl) — same
30
+ // pattern as MButton's size tiers.
25
31
  const sizeMap = {
26
- xs: { px: 32, icon: 16 },
27
- sm: { px: 40, icon: 20 },
28
- md: { px: 48, icon: 24 },
29
- lg: { px: 56, icon: 28 },
30
- xl: { px: 64, icon: 32 },
32
+ xs: { px: 32, icon: 20, squareRadius: 'rounded-md' },
33
+ sm: { px: 40, icon: 24, squareRadius: 'rounded-md' },
34
+ md: { px: 56, icon: 24, squareRadius: 'rounded-lg' },
35
+ lg: { px: 96, icon: 32, squareRadius: 'rounded-xl' },
36
+ xl: { px: 136, icon: 40, squareRadius: 'rounded-xl' },
31
37
  }
32
38
 
33
39
  const resolved = computed(() => {
34
- if (typeof props.size === 'number') return { px: props.size, icon: Math.round(props.size * 0.55) }
40
+ if (typeof props.size === 'number') return { px: props.size, icon: Math.round(props.size * 0.55), squareRadius: 'rounded-md' }
35
41
  return sizeMap[props.size] ?? sizeMap.sm
36
42
  })
37
43
 
44
+ /*
45
+ * State layer via a `before:` overlay (same technique MButton uses) rather than a direct
46
+ * `hover:bg-*`/`active:bg-*` utility: a solid `bg-primary`/`bg-secondary-container`
47
+ * container can't also swap to a translucent hover background without just replacing the
48
+ * color outright, so hover/press need a separate semi-transparent layer painted on top,
49
+ * tinted with the button's own content color (`before:bg-current`) — matches real M3's
50
+ * per-variant Hovered/PressedColor tokens, which are all just the content color at a fixed
51
+ * opacity (8%/12%), the same universal state-layer pattern across every variant.
52
+ */
38
53
  const base =
39
- 'inline-flex shrink-0 items-center justify-center transition-colors duration-150 cursor-pointer ' +
40
- 'disabled:cursor-not-allowed disabled:text-on-surface/38'
54
+ 'relative inline-flex shrink-0 items-center justify-center overflow-hidden transition-colors duration-150 cursor-pointer ' +
55
+ 'disabled:cursor-not-allowed disabled:text-on-surface/38 ' +
56
+ "before:content-[''] before:pointer-events-none before:absolute before:inset-0 " +
57
+ 'before:bg-current before:opacity-0 before:transition-opacity before:duration-150 ' +
58
+ 'enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.12]'
41
59
 
42
- // M3 disabled tokens: container at 12% on-surface (filled/tonal/outlined have one,
43
- // standard doesn't), icon content always at 38% on-surface (handled in `base` above).
60
+ // M3 disabled container opacity is 10% on-surface (DisabledContainerOpacity, Filled/Tonal
61
+ // only — Outlined has no container). Outlined's border needs no separate disabled class:
62
+ // it's `border-current` (see `variantClasses`), so it dims automatically along with the
63
+ // `disabled:text-on-surface/38` in `base` above, exactly like the real `outlinedIconButtonBorder`
64
+ // (which literally reuses `LocalContentColor` at the same disabled opacity as the icon).
44
65
  const disabledContainerClasses = computed(() => {
45
66
  switch (props.variant) {
46
67
  case 'filled':
47
68
  case 'tonal':
48
- return 'disabled:bg-on-surface/12'
49
- case 'outlined':
50
- return 'disabled:border-on-surface/12'
69
+ return 'disabled:bg-on-surface/10'
51
70
  default:
52
71
  return ''
53
72
  }
54
73
  })
55
74
 
56
- const shapeClass = computed(() => props.shape === 'squared' ? 'rounded-md' : 'rounded-full')
75
+ const shapeClass = computed(() => props.shape === 'squared' ? resolved.value.squareRadius : 'rounded-full')
57
76
 
58
77
  function createRipple(event: PointerEvent) {
59
78
  if (props.disabled) return
@@ -70,13 +89,16 @@ function createRipple(event: PointerEvent) {
70
89
  const variantClasses = computed(() => {
71
90
  switch (props.variant) {
72
91
  case 'filled':
73
- return 'bg-primary text-on-primary hover:shadow-elevation-1'
92
+ // Real IconButton.kt has no elevation tokens at all for any variant — flat, unlike Button
93
+ return 'bg-primary text-on-primary'
74
94
  case 'tonal':
75
- return 'bg-secondary-container text-on-secondary-container hover:shadow-elevation-1'
95
+ return 'bg-secondary-container text-on-secondary-container'
76
96
  case 'outlined':
77
- return 'border border-outline text-on-surface-variant hover:bg-on-surface/8'
97
+ // OutlinedIconButtonTokens' default (non-"vibrant") border tracks LocalContentColor,
98
+ // i.e. the same on-surface-variant used for the icon itself — not a fixed outline token
99
+ return 'border border-current text-on-surface-variant'
78
100
  default:
79
- return 'text-on-surface-variant hover:bg-on-surface/8 active:bg-on-surface/12'
101
+ return 'text-on-surface-variant'
80
102
  }
81
103
  })
82
104
  </script>
@@ -88,7 +110,7 @@ const variantClasses = computed(() => {
88
110
  :type="to ? undefined : 'button'"
89
111
  :aria-label="label || undefined"
90
112
  :disabled="disabled"
91
- :class="[base, shapeClass, variantClasses, disabledContainerClasses, 'relative overflow-hidden']"
113
+ :class="[base, shapeClass, variantClasses, disabledContainerClasses]"
92
114
  :style="{ width: `${resolved.px}px`, height: `${resolved.px}px` }"
93
115
  @pointerdown="createRipple"
94
116
  >
@@ -12,6 +12,7 @@ export type ListItemTrailing = 'icon' | 'text' | 'switch' | 'checkbox'
12
12
  const props = withDefaults(
13
13
  defineProps<{
14
14
  title?: string
15
+ overline?: string
15
16
  subtitle?: string
16
17
  description?: string
17
18
  lines?: 1 | 2 | 3
@@ -62,8 +63,8 @@ const list = inject<{
62
63
  const resolvedLines = computed(() => {
63
64
  if (props.lines) return props.lines
64
65
  if (list?.lines.value) return list.lines.value
65
- if (props.description) return 3
66
- if (props.subtitle) return 2
66
+ if (props.description || (props.overline && props.subtitle)) return 3
67
+ if (props.subtitle || props.overline) return 2
67
68
  return 1
68
69
  })
69
70
 
@@ -106,6 +107,17 @@ const isNav = computed(() => list?.nav.value ?? false)
106
107
  const isSegmented = computed(() => list?.segmented.value ?? false)
107
108
  const hasDivider = computed(() => list?.dividers.value ?? false)
108
109
 
110
+ // ListTokens: ItemSelectedLabelTextColor/ItemSelectedLeadingIconColor/etc = OnSecondaryContainer
111
+ const activeTextClass = computed(() => (isActive.value ? 'text-on-secondary-container' : 'text-on-surface'))
112
+ const activeIconClass = computed(() => (isActive.value ? 'text-on-secondary-container' : 'text-on-surface-variant'))
113
+
114
+ // ListTokens: ItemOneLineContainerHeight/TwoLine/ThreeLine = 56/72/88dp; dense is a library
115
+ // extension with no spec token, so it keeps its own compact padding instead of this floor.
116
+ const minHeightClass = computed(() => {
117
+ if (isDense.value) return ''
118
+ return resolvedLines.value === 3 ? 'min-h-22' : resolvedLines.value === 2 ? 'min-h-18' : 'min-h-14'
119
+ })
120
+
109
121
  const containerClasses = computed(() => [
110
122
  'mli-row relative flex w-full items-center gap-4 text-left',
111
123
  isSegmented.value
@@ -114,12 +126,11 @@ const containerClasses = computed(() => [
114
126
  isDense.value
115
127
  ? 'py-1'
116
128
  : resolvedLines.value === 3 ? 'py-3' : 'py-2',
129
+ minHeightClass.value,
117
130
  isClickable.value && !props.disabled && 'cursor-pointer transition-colors duration-150 hover:bg-on-surface/8 active:bg-on-surface/12',
118
- isActive.value && (isSegmented.value
119
- ? 'bg-secondary-container text-on-secondary-container'
120
- : isNav.value
121
- ? 'bg-secondary-container text-on-secondary-container'
122
- : 'bg-on-surface/8'),
131
+ // ListTokens: ItemSelectedContainerColor = SecondaryContainer, applies to any selected list
132
+ // item, not just nav/segmented contexts.
133
+ isActive.value && 'bg-secondary-container text-on-secondary-container',
123
134
  props.disabled && 'opacity-[0.38] pointer-events-none',
124
135
  ])
125
136
 
@@ -165,14 +176,17 @@ function handleTrailingToggle() {
165
176
  <div :class="containerClasses" @click="handleClick">
166
177
  <!-- Leading -->
167
178
  <slot name="leading">
168
- <MIcon v-if="resolvedLeading === 'icon'" :name="icon!" :size="24" class="shrink-0 text-on-surface-variant" />
179
+ <MIcon v-if="resolvedLeading === 'icon'" :name="icon!" :size="24" class="shrink-0" :class="activeIconClass" />
169
180
  </slot>
170
181
 
171
182
  <!-- Content -->
172
183
  <div class="min-w-0 flex-1">
184
+ <slot name="overline">
185
+ <p v-if="overline" class="truncate text-label-small" :class="activeIconClass">{{ overline }}</p>
186
+ </slot>
173
187
  <slot>
174
- <p class="truncate text-body-large text-on-surface">{{ title }}</p>
175
- <p v-if="subtitle && resolvedLines >= 2" class="text-body-medium text-on-surface-variant" :class="resolvedLines === 2 && 'truncate'">
188
+ <p class="truncate text-body-large" :class="activeTextClass">{{ title }}</p>
189
+ <p v-if="subtitle && resolvedLines >= 2" class="text-body-medium" :class="[activeIconClass, resolvedLines === 2 && 'truncate']">
176
190
  {{ subtitle }}
177
191
  </p>
178
192
  </slot>
@@ -182,7 +196,8 @@ function handleTrailingToggle() {
182
196
  <MIcon
183
197
  :name="isExpanded ? 'expand_less' : 'expand_more'"
184
198
  :size="20"
185
- class="shrink-0 text-on-surface-variant"
199
+ class="shrink-0"
200
+ :class="activeIconClass"
186
201
  />
187
202
  </div>
188
203
 
@@ -214,7 +229,7 @@ function handleTrailingToggle() {
214
229
  <!-- Leading -->
215
230
  <slot name="leading">
216
231
  <template v-if="resolvedLeading === 'icon'">
217
- <MIcon :name="icon!" :size="24" class="shrink-0 text-on-surface-variant" />
232
+ <MIcon :name="icon!" :size="24" class="shrink-0" :class="activeIconClass" />
218
233
  </template>
219
234
  <template v-else-if="resolvedLeading === 'icon-container'">
220
235
  <div
@@ -237,12 +252,15 @@ function handleTrailingToggle() {
237
252
 
238
253
  <!-- Content -->
239
254
  <div class="min-w-0 flex-1">
255
+ <slot name="overline">
256
+ <p v-if="overline" class="truncate text-label-small" :class="activeIconClass">{{ overline }}</p>
257
+ </slot>
240
258
  <slot>
241
- <p class="truncate text-body-large text-on-surface">{{ title }}</p>
242
- <p v-if="subtitle && resolvedLines >= 2" class="text-body-medium text-on-surface-variant" :class="resolvedLines === 2 && 'truncate'">
259
+ <p class="truncate text-body-large" :class="activeTextClass">{{ title }}</p>
260
+ <p v-if="subtitle && resolvedLines >= 2" class="text-body-medium" :class="[activeIconClass, resolvedLines === 2 && 'truncate']">
243
261
  {{ subtitle }}
244
262
  </p>
245
- <p v-if="description && resolvedLines >= 3" class="line-clamp-2 text-body-small text-on-surface-variant">
263
+ <p v-if="description && resolvedLines >= 3" class="line-clamp-2 text-body-small" :class="activeIconClass">
246
264
  {{ description }}
247
265
  </p>
248
266
  </slot>
@@ -251,10 +269,10 @@ function handleTrailingToggle() {
251
269
  <!-- Trailing -->
252
270
  <slot name="trailing">
253
271
  <template v-if="resolvedTrailing === 'icon'">
254
- <MIcon :name="trailingIcon!" :size="24" class="shrink-0 text-on-surface-variant" />
272
+ <MIcon :name="trailingIcon!" :size="24" class="shrink-0" :class="activeIconClass" />
255
273
  </template>
256
274
  <template v-else-if="resolvedTrailing === 'text'">
257
- <span class="shrink-0 text-label-small text-on-surface-variant">{{ trailingText }}</span>
275
+ <span class="shrink-0 text-label-small" :class="activeIconClass">{{ trailingText }}</span>
258
276
  </template>
259
277
  <template v-else-if="resolvedTrailing === 'switch'">
260
278
  <MSwitch :model-value="!!trailingValue" @update:model-value="handleTrailingToggle" />
@@ -14,15 +14,22 @@ const props = withDefaults(
14
14
 
15
15
  const locale = useLocale();
16
16
 
17
- const colorMap: Record<"primary" | "secondary" | "tertiary" | "error", { active: string; container: string }> = {
18
- primary: { active: "var(--color-primary)", container: "var(--color-primary-container)" },
19
- secondary: { active: "var(--color-secondary)", container: "var(--color-secondary-container)" },
20
- tertiary: { active: "var(--color-tertiary)", container: "var(--color-tertiary-container)" },
21
- error: { active: "var(--color-error)", container: "var(--color-error-container)" },
17
+ // ContainedActiveColor is a different role (OnXContainer) from the bare
18
+ // ActiveIndicatorColor (X) — the shape recolors when it gains the contained
19
+ // circle behind it, it's not just the same tone on a new background.
20
+ const colorMap: Record<"primary" | "secondary" | "tertiary" | "error", { active: string; containedActive: string; container: string }> = {
21
+ primary: { active: "var(--color-primary)", containedActive: "var(--color-on-primary-container)", container: "var(--color-primary-container)" },
22
+ secondary: { active: "var(--color-secondary)", containedActive: "var(--color-on-secondary-container)", container: "var(--color-secondary-container)" },
23
+ tertiary: { active: "var(--color-tertiary)", containedActive: "var(--color-on-tertiary-container)", container: "var(--color-tertiary-container)" },
24
+ error: { active: "var(--color-error)", containedActive: "var(--color-on-error-container)", container: "var(--color-error-container)" },
22
25
  };
23
26
  const svgColor = computed(() => colorMap[props.color]);
27
+ const activeColor = computed(() => (props.contained ? svgColor.value.containedActive : svgColor.value.active));
24
28
 
25
- const innerSize = computed(() => (props.contained ? Math.round(props.size * 0.55) : props.size));
29
+ // LoadingIndicatorTokens: ActiveSize=38dp against ContainerHeight/Width=48dp
30
+ // — the bare shape doesn't fill its container, it sits inset within it.
31
+ const BARE_RATIO = 38 / 48;
32
+ const innerSize = computed(() => Math.round(props.size * (props.contained ? 0.55 : BARE_RATIO)));
26
33
 
27
34
  // ── Shape morph geometry ───────────────────────────────────────────────────
28
35
  // Every shape is sampled as a radius multiplier at the same K angles, so any
@@ -178,7 +185,7 @@ onUnmounted(() => cancelAnimationFrame(rafId));
178
185
  shape-rendering="geometricPrecision"
179
186
  style="transform-origin: 50% 50%"
180
187
  >
181
- <path ref="pathEl" shape-rendering="geometricPrecision" :style="{ fill: svgColor.active }" />
188
+ <path ref="pathEl" shape-rendering="geometricPrecision" :style="{ fill: activeColor }" />
182
189
  </svg>
183
190
  </span>
184
191
  </template>