@m3ui-vue/m3ui-vue 0.7.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +14 -6
  2. package/dist/{MMenuItem-xQ1x6-DH.js → MMenuItem-CDWfeU4F.js} +331 -252
  3. package/dist/MMenuItem-CDWfeU4F.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/MButton.vue.d.ts +7 -0
  8. package/dist/components/MCalendar.vue.d.ts +0 -1
  9. package/dist/components/MCard.vue.d.ts +2 -0
  10. package/dist/components/MCarousel.vue.d.ts +12 -14
  11. package/dist/components/MChatBubble.vue.d.ts +0 -1
  12. package/dist/components/MCircleProgressBar.vue.d.ts +0 -1
  13. package/dist/components/MCodeEditor.vue.d.ts +1 -1
  14. package/dist/components/MConfirmDialog.vue.d.ts +3 -0
  15. package/dist/components/MDatePicker.vue.d.ts +1 -3
  16. package/dist/components/MDatePickerModal.vue.d.ts +0 -1
  17. package/dist/components/MDateRangePicker.vue.d.ts +1 -3
  18. package/dist/components/MDateRangePickerModal.vue.d.ts +0 -1
  19. package/dist/components/MDialog.vue.d.ts +23 -7
  20. package/dist/components/MFab.vue.d.ts +2 -2
  21. package/dist/components/MKanban.vue.d.ts +1 -0
  22. package/dist/components/MListItem.vue.d.ts +11 -6
  23. package/dist/components/MNavigationRail.vue.d.ts +17 -1
  24. package/dist/components/MScheduler.vue.d.ts +0 -1
  25. package/dist/components/MSelect.vue.d.ts +1 -0
  26. package/dist/components/MShape.vue.d.ts +51 -0
  27. package/dist/components/MShortNavigationBar.vue.d.ts +34 -0
  28. package/dist/components/MSimpleCarousel.vue.d.ts +45 -0
  29. package/dist/components/MSwitch.vue.d.ts +8 -0
  30. package/dist/components/MTabs.vue.d.ts +3 -0
  31. package/dist/components/MToggleButton.vue.d.ts +29 -0
  32. package/dist/components/MTree.vue.d.ts +0 -1
  33. package/dist/components/MTreeTable.vue.d.ts +1 -0
  34. package/dist/index.d.ts +9 -1
  35. package/dist/m3ui-vue.css +1 -1
  36. package/dist/m3ui.js +4387 -2525
  37. package/dist/m3ui.js.map +1 -1
  38. package/dist/rich-text-editor.js +1 -1
  39. package/dist/styles/palettes.css +659 -0
  40. package/dist/styles/theme.css +1 -0
  41. package/dist/styles.css +1 -1
  42. package/package.json +16 -1
  43. package/src/__tests__/MCarousel.test.ts +33 -0
  44. package/src/__tests__/MShape.test.ts +36 -0
  45. package/src/__tests__/MToggleButton.test.ts +27 -0
  46. package/src/__tests__/useColorPalette.test.ts +2 -2
  47. package/src/code-editor.ts +1 -0
  48. package/src/components/MAutocomplete.vue +40 -27
  49. package/src/components/MBadge.vue +1 -1
  50. package/src/components/MBottomSheet.vue +4 -4
  51. package/src/components/MButton.vue +51 -21
  52. package/src/components/MButtonGroup.vue +2 -2
  53. package/src/components/MCalendar.vue +9 -5
  54. package/src/components/MCard.vue +76 -11
  55. package/src/components/MCarousel.vue +123 -173
  56. package/src/components/MChatBubble.vue +0 -1
  57. package/src/components/MCheckbox.vue +58 -13
  58. package/src/components/MChip.vue +26 -6
  59. package/src/components/MCircleProgressBar.vue +7 -4
  60. package/src/components/MCodeEditor.vue +60 -9
  61. package/src/components/MColorPicker.vue +9 -8
  62. package/src/components/MColorPickerModal.vue +2 -2
  63. package/src/components/MCommandPalette.vue +1 -1
  64. package/src/components/MConfirmDialog.vue +4 -0
  65. package/src/components/MContextMenu.vue +27 -6
  66. package/src/components/MDatePicker.vue +23 -20
  67. package/src/components/MDatePickerModal.vue +14 -9
  68. package/src/components/MDateRangePicker.vue +24 -21
  69. package/src/components/MDateRangePickerModal.vue +12 -7
  70. package/src/components/MDialog.vue +103 -12
  71. package/src/components/MFab.vue +10 -7
  72. package/src/components/MFabMenu.vue +1 -1
  73. package/src/components/MIconButton.vue +41 -19
  74. package/src/components/MKanban.vue +5 -1
  75. package/src/components/MListItem.vue +35 -17
  76. package/src/components/MLoadingIndicator.vue +14 -7
  77. package/src/components/MMaskField.vue +14 -6
  78. package/src/components/MMenu.vue +32 -7
  79. package/src/components/MMenuItem.vue +2 -2
  80. package/src/components/MMultiAutocomplete.vue +46 -27
  81. package/src/components/MMultiSelect.vue +45 -23
  82. package/src/components/MNavigationBar.vue +5 -10
  83. package/src/components/MNavigationDrawer.vue +10 -9
  84. package/src/components/MNavigationRail.vue +335 -22
  85. package/src/components/MNumberField.vue +14 -6
  86. package/src/components/MOverlay.vue +1 -1
  87. package/src/components/MPinInput.vue +7 -4
  88. package/src/components/MProgressBar.vue +16 -10
  89. package/src/components/MRadio.vue +54 -12
  90. package/src/components/MScheduler.vue +10 -6
  91. package/src/components/MSearchBar.vue +8 -3
  92. package/src/components/MSegmentedButton.vue +14 -9
  93. package/src/components/MSelect.vue +49 -33
  94. package/src/components/MShape.vue +107 -0
  95. package/src/components/MShortNavigationBar.vue +113 -0
  96. package/src/components/MSideSheet.vue +1 -1
  97. package/src/components/MSimpleCarousel.vue +325 -0
  98. package/src/components/MSnackbar.vue +4 -4
  99. package/src/components/MSplitButton.vue +32 -17
  100. package/src/components/MSpotlightSearch.vue +1 -1
  101. package/src/components/MSwitch.vue +96 -18
  102. package/src/components/MTabs.vue +16 -12
  103. package/src/components/MTagInput.vue +33 -22
  104. package/src/components/MTextField.vue +14 -6
  105. package/src/components/MTimePicker.vue +9 -9
  106. package/src/components/MTimePickerModal.vue +16 -16
  107. package/src/components/MToggleButton.vue +188 -0
  108. package/src/components/MToolbar.vue +5 -3
  109. package/src/components/MTooltip.vue +4 -4
  110. package/src/components/MTopAppBar.vue +19 -7
  111. package/src/components/MTour.vue +1 -1
  112. package/src/components/MTree.vue +4 -2
  113. package/src/components/MTreeTable.vue +5 -1
  114. package/src/composables/useColorPalette.ts +10 -0
  115. package/src/index.ts +9 -1
  116. package/src/styles/palettes.css +659 -0
  117. package/src/styles/theme.css +1 -0
  118. package/dist/MMenuItem-xQ1x6-DH.js.map +0 -1
@@ -18,10 +18,15 @@ const props = withDefaults(defineProps<{
18
18
  title?: string
19
19
  }>(), {
20
20
  show: false,
21
- locale: 'es-ES',
22
21
  })
23
22
 
24
23
  const locale = useLocale()
24
+
25
+ // Falls back to the app's own configured locale (via createM3UI/useLocale) rather than a
26
+ // fixed default, matching the pattern MRelativeTime already uses — previously this defaulted
27
+ // to a hardcoded 'es-ES' regardless of what locale the app actually provided.
28
+ const resolvedLocale = computed(() => props.locale ?? locale.lang)
29
+
25
30
  const emit = defineEmits<{
26
31
  'update:modelValue': [DateRange]
27
32
  'update:show': [boolean]
@@ -51,12 +56,12 @@ watch(() => props.show, (open) => {
51
56
 
52
57
  // ── Calendar logic ─────────────────────────────────────────────────
53
58
  const WEEKDAYS = computed(() => {
54
- const f = new Intl.DateTimeFormat(props.locale, { weekday: 'narrow' })
59
+ const f = new Intl.DateTimeFormat(resolvedLocale.value, { weekday: 'narrow' })
55
60
  return Array.from({ length: 7 }, (_, i) => f.format(new Date(2024, 0, i + 1)))
56
61
  })
57
62
 
58
63
  const monthLabel = computed(() =>
59
- new Intl.DateTimeFormat(props.locale, { month: 'long', year: 'numeric' }).format(viewDate.value),
64
+ new Intl.DateTimeFormat(resolvedLocale.value, { month: 'long', year: 'numeric' }).format(viewDate.value),
60
65
  )
61
66
 
62
67
  const calendarDays = computed(() => {
@@ -138,7 +143,7 @@ function isInRange(iso: string) {
138
143
  const fmtDisplay = (iso: string | null) => {
139
144
  if (!iso) return '—'
140
145
  const d = new Date(iso + 'T00:00:00')
141
- return new Intl.DateTimeFormat(props.locale, { month: 'short', day: 'numeric' }).format(d)
146
+ return new Intl.DateTimeFormat(resolvedLocale.value, { month: 'short', day: 'numeric' }).format(d)
142
147
  }
143
148
 
144
149
  // ── Actions ────────────────────────────────────────────────────────
@@ -159,13 +164,13 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
159
164
  <Transition name="m3-drp-modal">
160
165
  <div
161
166
  v-if="show"
162
- class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/40 p-4"
167
+ class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/32 p-4"
163
168
  @click.self="cancel"
164
169
  >
165
170
  <div class="drp-box w-[360px] rounded-[28px] bg-surface-container-high shadow-elevation-3">
166
171
  <!-- Header -->
167
172
  <div class="px-6 pt-6 pb-4">
168
- <p class="mb-3 text-label-medium text-on-surface-variant">
173
+ <p class="mb-3 text-label-large text-on-surface-variant">
169
174
  {{ title || locale.selectRange }}
170
175
  </p>
171
176
  <div class="flex items-center gap-3">
@@ -200,7 +205,7 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
200
205
  </div>
201
206
 
202
207
  <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">
208
+ <span v-for="wd in WEEKDAYS" :key="wd" class="py-1 text-body-large font-medium text-on-surface">
204
209
  {{ wd }}
205
210
  </span>
206
211
  </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
  >
@@ -2,6 +2,7 @@
2
2
  import { ref } from 'vue'
3
3
  import MIcon from './MIcon.vue'
4
4
  import MIconButton from './MIconButton.vue'
5
+ import { useLocale } from '../composables/useLocale'
5
6
 
6
7
  export interface KanbanCard {
7
8
  id: string | number
@@ -17,8 +18,11 @@ export interface KanbanColumn {
17
18
 
18
19
  const props = defineProps<{
19
20
  modelValue: KanbanColumn[]
21
+ emptyText?: string
20
22
  }>()
21
23
 
24
+ const locale = useLocale()
25
+
22
26
  const emit = defineEmits<{
23
27
  'update:modelValue': [KanbanColumn[]]
24
28
  cardMove: [{ cardId: string | number; fromColumn: string | number; toColumn: string | number; toIndex: number }]
@@ -139,7 +143,7 @@ function reset() {
139
143
  v-if="column.cards.length === 0"
140
144
  class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-outline-variant/50 p-4"
141
145
  >
142
- <p class="text-body-small text-on-surface-variant/60">Sin tarjetas</p>
146
+ <p class="text-body-small text-on-surface-variant/60">{{ emptyText ?? locale.noItems }}</p>
143
147
  </div>
144
148
  </div>
145
149
  </div>
@@ -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>