@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
@@ -31,10 +31,14 @@ const props = withDefaults(
31
31
  view: 'week',
32
32
  startHour: 7,
33
33
  endHour: 22,
34
- locale: 'es-ES',
35
34
  },
36
35
  )
37
36
 
37
+ // Falls back to the app's own configured locale (via createM3UI/useLocale) rather than a
38
+ // fixed default, matching the pattern MRelativeTime already uses — previously this defaulted
39
+ // to a hardcoded 'es-ES' regardless of what locale the app actually provided.
40
+ const resolvedLocale = computed(() => props.locale ?? locale.lang)
41
+
38
42
  const emit = defineEmits<{
39
43
  eventClick: [SchedulerEvent]
40
44
  slotClick: [{ date: string; hour: number }]
@@ -78,17 +82,17 @@ function fmt(d: Date) {
78
82
  return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
79
83
  }
80
84
 
81
- const dayFormat = new Intl.DateTimeFormat(props.locale, { weekday: 'short' })
82
- const dateFormat = new Intl.DateTimeFormat(props.locale, { day: 'numeric' })
85
+ const dayFormat = computed(() => new Intl.DateTimeFormat(resolvedLocale.value, { weekday: 'short' }))
86
+ const dateFormat = computed(() => new Intl.DateTimeFormat(resolvedLocale.value, { day: 'numeric' }))
83
87
 
84
88
  const headerLabel = computed(() => {
85
89
  if (currentView.value === 'day') {
86
- return new Intl.DateTimeFormat(props.locale, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' })
90
+ return new Intl.DateTimeFormat(resolvedLocale.value, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' })
87
91
  .format(currentDate.value)
88
92
  }
89
93
  const start = weekDays.value[0]!
90
94
  const end = weekDays.value[6]!
91
- const f = new Intl.DateTimeFormat(props.locale, { day: 'numeric', month: 'short' })
95
+ const f = new Intl.DateTimeFormat(resolvedLocale.value, { day: 'numeric', month: 'short' })
92
96
  return `${f.format(start)} – ${f.format(end)}, ${end.getFullYear()}`
93
97
  })
94
98
 
@@ -125,7 +129,7 @@ function eventDuration(ev: SchedulerEvent) {
125
129
  }
126
130
 
127
131
  function timeLabel(ev: SchedulerEvent) {
128
- const f = new Intl.DateTimeFormat(props.locale, { hour: '2-digit', minute: '2-digit' })
132
+ const f = new Intl.DateTimeFormat(resolvedLocale.value, { hour: '2-digit', minute: '2-digit' })
129
133
  return `${f.format(new Date(ev.start))} – ${f.format(new Date(ev.end))}`
130
134
  }
131
135
 
@@ -5,6 +5,10 @@ import MIconButton from './MIconButton.vue'
5
5
  import MSpinner from './MSpinner.vue'
6
6
  import { useLocale } from '../composables/useLocale'
7
7
 
8
+ // Root is a fragment (bar div + a sibling Teleport for the expanded overlay panel), so Vue
9
+ // can't auto-apply a consumer's class/attrs to either one — forward them onto the bar div below.
10
+ defineOptions({ inheritAttrs: false })
11
+
8
12
  const props = withDefaults(
9
13
  defineProps<{
10
14
  modelValue?: string
@@ -126,10 +130,10 @@ onUnmounted(() => { document.body.style.overflow = '' })
126
130
  </script>
127
131
 
128
132
  <template>
129
- <div ref="barEl" class="relative w-full">
133
+ <div ref="barEl" class="relative w-full" v-bind="$attrs">
130
134
  <div
131
135
  v-show="!expanded"
132
- class="flex h-14 items-center gap-3 rounded-full bg-surface-container-high px-4 shadow-elevation-1 transition-shadow duration-150"
136
+ class="flex h-14 items-center gap-3 rounded-full bg-surface-container-high px-4 shadow-elevation-3 transition-shadow duration-150 focus-within:outline focus-within:outline-2 focus-within:outline-secondary focus-within:-outline-offset-2"
133
137
  :class="disabled ? 'pointer-events-none opacity-[0.38]' : ''"
134
138
  >
135
139
  <span class="inline-flex shrink-0 items-center" :class="iconPosition === 'end' ? 'order-last' : ''">
@@ -180,6 +184,7 @@ onUnmounted(() => { document.body.style.overflow = '' })
180
184
  icon="arrow_back"
181
185
  :label="locale.close"
182
186
  variant="standard"
187
+ style="color: var(--color-on-surface)"
183
188
  @click="close"
184
189
  />
185
190
  <input
@@ -205,7 +210,7 @@ onUnmounted(() => { document.body.style.overflow = '' })
205
210
  <slot name="trailing" />
206
211
  </div>
207
212
 
208
- <div class="h-px shrink-0 bg-outline-variant" />
213
+ <div class="h-px shrink-0 bg-outline" />
209
214
 
210
215
  <div class="flex-1 overflow-y-auto">
211
216
  <slot />
@@ -48,15 +48,20 @@ function toggle(opt: SegmentedOption, modelValue: string | number | (string | nu
48
48
  class="relative inline-flex items-center justify-center gap-2 text-label-large font-medium transition-[background-color,color] duration-150 outline-none before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:duration-150 enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.12]"
49
49
  :class="[
50
50
  density === 'compact' ? 'h-8 px-3' : density === 'comfortable' ? 'h-10 px-4' : 'h-10 px-6',
51
- i > 0 ? 'border-l border-outline' : '',
52
- opt.disabled ? 'cursor-not-allowed opacity-[0.38]' : 'cursor-pointer',
53
- isSelected(opt.value, modelValue)
54
- ? color === 'secondary'
55
- ? 'bg-secondary-container text-on-secondary-container'
56
- : color === 'tertiary'
57
- ? 'bg-tertiary-container text-on-tertiary-container'
58
- : 'bg-secondary-container text-on-secondary-container'
59
- : 'text-on-surface',
51
+ i > 0 ? (opt.disabled ? 'border-l border-outline/12' : 'border-l border-outline') : '',
52
+ opt.disabled ? 'cursor-not-allowed' : 'cursor-pointer',
53
+ isSelected(opt.value, modelValue) && (
54
+ color === 'secondary' ? 'bg-secondary-container'
55
+ : color === 'tertiary' ? 'bg-tertiary-container'
56
+ : 'bg-primary-container'
57
+ ),
58
+ opt.disabled
59
+ ? 'text-on-surface/38'
60
+ : isSelected(opt.value, modelValue)
61
+ ? color === 'secondary' ? 'text-on-secondary-container'
62
+ : color === 'tertiary' ? 'text-on-tertiary-container'
63
+ : 'text-on-primary-container'
64
+ : 'text-on-surface',
60
65
  ]"
61
66
  :disabled="opt.disabled"
62
67
  :aria-pressed="isSelected(opt.value, modelValue)"
@@ -11,6 +11,10 @@ export interface SelectOption {
11
11
  disabled?: boolean
12
12
  }
13
13
 
14
+ // Root is a fragment (field div + a sibling Teleport for the dropdown panel), so Vue can't
15
+ // auto-apply a consumer's class/attrs to either one — forward them onto the field div below.
16
+ defineOptions({ inheritAttrs: false })
17
+
14
18
  const props = withDefaults(
15
19
  defineProps<{
16
20
  modelValue: unknown
@@ -27,6 +31,7 @@ const props = withDefaults(
27
31
  leadingIcon?: string
28
32
  clearable?: boolean
29
33
  fieldBg?: string
34
+ noResultsText?: string
30
35
  }>(),
31
36
  {
32
37
  modelValue: undefined,
@@ -59,6 +64,7 @@ const hasValue = computed(() => props.modelValue != null && props.modelValue !==
59
64
  const selectedLabel = computed(
60
65
  () => props.options.find((o) => eq(o.value, props.modelValue))?.label ?? '',
61
66
  )
67
+ const resolvedNoResultsText = computed(() => props.noResultsText ?? locale.noResults)
62
68
 
63
69
  function computeDropPos() {
64
70
  if (!fieldEl.value) return
@@ -142,27 +148,29 @@ onUnmounted(() => {
142
148
  const triggerClasses = computed(() => {
143
149
  const pl = props.leadingIcon ? 'pl-12' : 'pl-4'
144
150
  const base = [
145
- 'flex w-full cursor-pointer items-center pr-10 text-body-large transition-[border-color,border-width] duration-150',
151
+ 'flex w-full items-center pr-10 text-body-large transition-[border-color,border-width] duration-150',
152
+ props.disabled ? 'cursor-not-allowed' : 'cursor-pointer',
146
153
  pl,
147
154
  ]
148
155
 
149
156
  if (props.variant === 'outlined') {
150
- return [
151
- ...base,
152
- 'h-14 rounded-sm border bg-transparent',
153
- open.value
157
+ const border = props.disabled
158
+ ? 'border-on-surface/12'
159
+ : open.value
154
160
  ? (props.error ? 'border-2 border-error' : 'border-2 border-primary')
155
- : (props.error ? 'border-error' : 'border-outline hover:border-on-surface'),
156
- ].join(' ')
161
+ : (props.error ? 'border-error' : 'border-outline hover:border-on-surface')
162
+ return [...base, 'h-14 rounded-xs border bg-transparent', border].join(' ')
157
163
  }
158
164
 
159
- return [
160
- ...base,
161
- 'h-14 rounded-t-sm bg-surface-container-highest border-b pt-6 pb-2',
162
- open.value
165
+ const border = props.disabled
166
+ ? 'border-on-surface/38'
167
+ : open.value
163
168
  ? (props.error ? 'border-b-2 border-error' : 'border-b-2 border-primary')
164
- : (props.error ? 'border-error' : 'border-on-surface-variant hover:border-on-surface'),
165
- ].join(' ')
169
+ : (props.error ? 'border-error' : 'border-on-surface-variant hover:border-on-surface')
170
+ const bg = props.disabled
171
+ ? 'bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]'
172
+ : 'bg-surface-container-highest'
173
+ return [...base, 'h-14 rounded-t-xs border-b pt-6 pb-2', bg, border].join(' ')
166
174
  })
167
175
 
168
176
  const isFloated = computed(() => hasValue.value || open.value)
@@ -184,15 +192,17 @@ const labelClasses = computed(() => {
184
192
  'pointer-events-none absolute right-10 truncate transition-all duration-200',
185
193
  left,
186
194
  isFloated.value ? floated : unFloated,
187
- open.value
188
- ? (props.error ? 'text-error' : 'text-primary')
189
- : (props.error ? 'text-error' : 'text-on-surface-variant'),
195
+ props.disabled
196
+ ? 'text-on-surface/38'
197
+ : open.value
198
+ ? (props.error ? 'text-error' : 'text-primary')
199
+ : (props.error ? 'text-error' : 'text-on-surface-variant'),
190
200
  ].join(' ')
191
201
  })
192
202
  </script>
193
203
 
194
204
  <template>
195
- <div class="flex flex-col gap-1">
205
+ <div class="flex flex-col gap-1" v-bind="$attrs">
196
206
  <div
197
207
  ref="fieldEl"
198
208
  class="relative"
@@ -202,10 +212,13 @@ const labelClasses = computed(() => {
202
212
  <!-- Leading icon -->
203
213
  <div
204
214
  v-if="leadingIcon"
205
- class="pointer-events-none absolute left-3.5 text-on-surface-variant"
206
- :class="variant === 'filled' ? 'top-5' : 'top-4.5'"
215
+ class="pointer-events-none absolute left-3.5"
216
+ :class="[
217
+ variant === 'filled' ? 'top-4.5' : 'top-4',
218
+ disabled ? 'text-on-surface/38' : 'text-on-surface-variant',
219
+ ]"
207
220
  >
208
- <MIcon :name="leadingIcon" :size="20" />
221
+ <MIcon :name="leadingIcon" :size="24" />
209
222
  </div>
210
223
 
211
224
  <!-- Custom trigger -->
@@ -215,11 +228,11 @@ const labelClasses = computed(() => {
215
228
  role="combobox"
216
229
  :aria-expanded="open"
217
230
  :aria-disabled="disabled"
218
- :class="[triggerClasses, disabled ? 'pointer-events-none opacity-[0.38]' : '']"
231
+ :class="[triggerClasses, disabled ? 'pointer-events-none' : '']"
219
232
  @click="toggle"
220
233
  @keydown="onKeydown"
221
234
  >
222
- <span v-if="hasValue" class="text-on-surface">{{ selectedLabel }}</span>
235
+ <span v-if="hasValue" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ selectedLabel }}</span>
223
236
  </div>
224
237
 
225
238
  <!-- Floating label -->
@@ -242,8 +255,11 @@ const labelClasses = computed(() => {
242
255
  <MIcon
243
256
  name="arrow_drop_down"
244
257
  :size="24"
245
- class="text-on-surface-variant transition-transform duration-200"
246
- :class="open || modalOpen ? 'rotate-180' : ''"
258
+ class="transition-transform duration-200"
259
+ :class="[
260
+ open || modalOpen ? 'rotate-180' : '',
261
+ disabled ? 'text-on-surface/38' : 'text-on-surface-variant',
262
+ ]"
247
263
  />
248
264
  </div>
249
265
  </div>
@@ -265,7 +281,7 @@ const labelClasses = computed(() => {
265
281
  <div
266
282
  v-if="open && mode === 'docked'"
267
283
  ref="dropdownEl"
268
- class="fixed z-500 max-h-60 overflow-auto rounded-sm bg-surface-container py-1 shadow-elevation-2"
284
+ class="fixed z-500 max-h-60 overflow-auto rounded-xs bg-surface-container py-1 shadow-elevation-2"
269
285
  :style="dropPos"
270
286
  >
271
287
  <div
@@ -276,7 +292,7 @@ const labelClasses = computed(() => {
276
292
  opt.disabled
277
293
  ? 'cursor-not-allowed opacity-38 text-on-surface'
278
294
  : 'text-on-surface hover:bg-on-surface/8',
279
- eq(opt.value, modelValue) ? 'bg-primary/8 text-primary font-medium' : '',
295
+ eq(opt.value, modelValue) ? 'bg-secondary-container text-on-secondary-container font-medium' : '',
280
296
  ]"
281
297
  @click="select(opt)"
282
298
  >
@@ -284,7 +300,7 @@ const labelClasses = computed(() => {
284
300
  v-if="eq(opt.value, modelValue)"
285
301
  name="check"
286
302
  :size="18"
287
- class="shrink-0 text-primary"
303
+ class="shrink-0 text-on-secondary-container"
288
304
  />
289
305
  <span v-else class="w-[18px] shrink-0" />
290
306
  {{ opt.label }}
@@ -293,7 +309,7 @@ const labelClasses = computed(() => {
293
309
  v-if="!options.length"
294
310
  class="px-4 py-3 text-center text-body-small text-on-surface-variant"
295
311
  >
296
- Sin opciones
312
+ {{ resolvedNoResultsText }}
297
313
  </p>
298
314
  </div>
299
315
  </Transition>
@@ -302,7 +318,7 @@ const labelClasses = computed(() => {
302
318
  <Transition name="m3-select-modal">
303
319
  <div
304
320
  v-if="modalOpen && mode === 'modal'"
305
- class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/40 p-4"
321
+ class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/32 p-4"
306
322
  @click.self="closeModal"
307
323
  >
308
324
  <div class="select-modal-box flex max-h-[80vh] w-full max-w-sm flex-col overflow-hidden rounded-[28px] bg-surface-container-high shadow-elevation-3">
@@ -324,16 +340,16 @@ const labelClasses = computed(() => {
324
340
  opt.disabled
325
341
  ? 'cursor-not-allowed opacity-38 text-on-surface'
326
342
  : 'text-on-surface hover:bg-on-surface/8',
327
- eq(opt.value, modelValue) ? 'bg-primary/8' : '',
343
+ eq(opt.value, modelValue) ? 'bg-secondary-container' : '',
328
344
  ]"
329
345
  @click="select(opt)"
330
346
  >
331
347
  <MIcon
332
348
  :name="eq(opt.value, modelValue) ? 'radio_button_checked' : 'radio_button_unchecked'"
333
349
  :size="20"
334
- :class="eq(opt.value, modelValue) ? 'text-primary' : 'text-on-surface-variant'"
350
+ :class="eq(opt.value, modelValue) ? 'text-on-secondary-container' : 'text-on-surface-variant'"
335
351
  />
336
- <span :class="eq(opt.value, modelValue) ? 'text-primary font-medium' : ''">
352
+ <span :class="eq(opt.value, modelValue) ? 'text-on-secondary-container font-medium' : ''">
337
353
  {{ opt.label }}
338
354
  </span>
339
355
  </div>
@@ -341,7 +357,7 @@ const labelClasses = computed(() => {
341
357
  v-if="!options.length"
342
358
  class="px-6 py-4 text-center text-body-medium text-on-surface-variant"
343
359
  >
344
- Sin opciones
360
+ {{ resolvedNoResultsText }}
345
361
  </p>
346
362
  </div>
347
363
  </div>
@@ -0,0 +1,107 @@
1
+ <script lang="ts">
2
+ export { shapeNames } from 'shape-morph'
3
+ </script>
4
+
5
+ <script setup lang="ts">
6
+ import { onUnmounted, ref, useId, watch } from 'vue'
7
+ import { AnimatedMorph, getShape, toSvgPath, type ShapeName } from 'shape-morph'
8
+
9
+ export type { ShapeName }
10
+
11
+ // No default width/height here (matches MAspectRatio) — size it via `class`/`style` on the
12
+ // component itself, e.g. `class="h-16 w-16"`. A hardcoded `h-full w-full` would fight Tailwind's
13
+ // own (undefined) utility ordering against whatever sizing class the consumer passes through.
14
+ const props = withDefaults(
15
+ defineProps<{
16
+ /** One of M3's 35 named "expressive" shapes (MaterialShapes.kt), e.g. 'Cookie9Sided', 'Heart'. */
17
+ shape: ShapeName
18
+ /**
19
+ * Fill color used when there's no default slot content to clip (a decorative solid shape).
20
+ * SVG `fill`, not a `background-color` — a `bg-*` Tailwind class on the component itself has
21
+ * no effect here; use `fill` (or a `text-*` class, since the default is `currentColor`).
22
+ */
23
+ fill?: string
24
+ /** Spring-morph into the new outline when `shape` changes — false snaps instantly instead. */
25
+ animate?: boolean
26
+ /**
27
+ * Multiplier on the morph spring's speed (1 = default). Scales stiffness by speed² and the
28
+ * damping coefficient by speed, which time-scales the spring uniformly without changing its
29
+ * character (same amount of overshoot/settle shape, just faster or slower).
30
+ */
31
+ speed?: number
32
+ }>(),
33
+ {
34
+ fill: 'currentColor',
35
+ animate: true,
36
+ speed: 1,
37
+ },
38
+ )
39
+
40
+ const clipId = `m3-shape-${useId()}`
41
+
42
+ // Normalized 0-1 coordinates (size: 1) so the path works as an objectBoundingBox clipPath,
43
+ // which scales correctly with the element's actual rendered size instead of a fixed px box.
44
+ const pathD = ref(toSvgPath(getShape(props.shape), 1))
45
+
46
+ let morph: AnimatedMorph | null = null
47
+ let settledShape = props.shape
48
+
49
+ // MaterialShapes is itself an Expressive-only M3 feature (MaterialShapes.kt requires
50
+ // @ExperimentalMaterial3ExpressiveApi), so this spring is ExpressiveMotionTokens.DefaultSpatial
51
+ // (dampingRatio 0.8, stiffness 380) — the scheme's general-purpose spatial spring, since no
52
+ // single Compose composable's own bespoke spring (e.g. LoadingIndicator's 0.6/200) is the
53
+ // "correct" one to copy for a generic shape primitive like this. shape-morph's AnimatedMorph
54
+ // spring uses a plain damping *coefficient*, not Compose's damping *ratio* — converted via
55
+ // damping = 2 * dampingRatio * sqrt(stiffness) = 2 * 0.8 * sqrt(380) ≈ 31.2.
56
+ const BASE_STIFFNESS = 380
57
+ const BASE_DAMPING = 31.2
58
+
59
+ function springFor(speed: number) {
60
+ return { stiffness: BASE_STIFFNESS * speed ** 2, damping: BASE_DAMPING * speed }
61
+ }
62
+
63
+ watch(() => props.shape, (next, prev) => {
64
+ if (!prev || next === prev) return
65
+ morph?.dispose()
66
+ if (!props.animate) {
67
+ pathD.value = toSvgPath(getShape(next), 1)
68
+ settledShape = next
69
+ return
70
+ }
71
+ // AnimatedMorph only morphs between two named/RoundedPolygon endpoints, not from an
72
+ // arbitrary in-flight shape, so a change that interrupts a running morph restarts from
73
+ // the last shape that had actually settled rather than the current on-screen outline.
74
+ morph = new AnimatedMorph(settledShape, next, {
75
+ spring: springFor(props.speed),
76
+ size: 1,
77
+ onFrame: (frame) => { pathD.value = frame.pathD },
78
+ })
79
+ // The constructor only emits the start shape at progress 0 — setting `progress` is what
80
+ // actually kicks off the spring animation toward the end shape (see shape-morph's own
81
+ // useMorph, which drives this the same way). Skipping this makes the shape jump straight
82
+ // to its final frame with no visible interpolation, one render behind the prop change.
83
+ morph.progress = 1
84
+ settledShape = next
85
+ })
86
+
87
+ onUnmounted(() => morph?.dispose())
88
+ </script>
89
+
90
+ <template>
91
+ <span class="relative inline-block">
92
+ <svg width="0" height="0" class="absolute">
93
+ <defs>
94
+ <clipPath :id="clipId" clipPathUnits="objectBoundingBox">
95
+ <path :d="pathD" />
96
+ </clipPath>
97
+ </defs>
98
+ </svg>
99
+
100
+ <div v-if="$slots.default" class="h-full w-full" :style="{ clipPath: `url(#${clipId})` }">
101
+ <slot />
102
+ </div>
103
+ <svg v-else viewBox="0 0 1 1" class="h-full w-full">
104
+ <path :d="pathD" :fill="fill" />
105
+ </svg>
106
+ </span>
107
+ </template>
@@ -0,0 +1,113 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+ import MIcon from './MIcon.vue'
4
+ import MBadge from './MBadge.vue'
5
+
6
+ export interface ShortNavBarItem {
7
+ value: string | number
8
+ label: string
9
+ icon: string
10
+ badge?: number
11
+ badgeDot?: boolean
12
+ }
13
+
14
+ const props = withDefaults(
15
+ defineProps<{
16
+ modelValue: string | number
17
+ items: ShortNavBarItem[]
18
+ /**
19
+ * 'equal' (ShortNavigationBarArrangement.EqualWeight): items evenly fill the bar — recommended
20
+ * for small-width screens. 'centered' (.Centered): items are grouped toward the center instead
21
+ * of stretching edge to edge — recommended for medium-width screens, paired with iconPosition
22
+ * 'start'. Real Compose computes this via a custom MeasurePolicy at layout time; ported here as
23
+ * the same closed-form percentage formula (calculateCenteredContentHorizontalPadding), since it
24
+ * only ever depends on the item count, not on measured content size.
25
+ */
26
+ arrangement?: 'equal' | 'centered'
27
+ /** NavigationItemIconPosition — 'top' stacks icon above label (ShortNavigationBarItem's
28
+ * default); 'start' places the icon beside the label inside a single wider pill, meant for
29
+ * the 'centered' arrangement on wider/landscape layouts. */
30
+ iconPosition?: 'top' | 'start'
31
+ }>(),
32
+ {
33
+ arrangement: 'equal',
34
+ iconPosition: 'top',
35
+ },
36
+ )
37
+
38
+ defineEmits<{ 'update:modelValue': [string | number] }>()
39
+
40
+ // calculateCenteredContentHorizontalPadding: 3 items -> 20% each side, 4 -> 15%, 5 -> 10%,
41
+ // 6 -> 5%, 7+ -> 0. Matches the real formula verbatim: ((100 - 10*(n+3)) / 2) / 100.
42
+ const centeredPadding = computed(() => {
43
+ const n = props.items.length
44
+ if (props.arrangement !== 'centered' || n > 6) return 0
45
+ return ((100 - 10 * (n + 3)) / 2)
46
+ })
47
+ </script>
48
+
49
+ <template>
50
+ <nav
51
+ class="flex h-16 w-full items-center border-t border-outline-variant bg-surface-container shadow-elevation-2"
52
+ :style="arrangement === 'centered' ? { paddingLeft: `${centeredPadding}%`, paddingRight: `${centeredPadding}%` } : undefined"
53
+ >
54
+ <button
55
+ v-for="item in items"
56
+ :key="item.value"
57
+ type="button"
58
+ class="group flex flex-1 cursor-pointer items-center justify-center self-stretch transition-colors focus-visible:outline-none"
59
+ :class="iconPosition === 'top' ? 'flex-col gap-1' : 'flex-row gap-1 py-1.5'"
60
+ @click="$emit('update:modelValue', item.value)"
61
+ >
62
+ <template v-if="iconPosition === 'top'">
63
+ <!-- Top icon position: 56x32dp pill above a separate label, matching MNavigationBar -->
64
+ <span
65
+ class="inline-flex h-8 items-center justify-center rounded-2xl transition-all duration-200"
66
+ :class="
67
+ item.value === modelValue
68
+ ? 'w-14 bg-secondary-container text-on-secondary-container'
69
+ : 'w-0 bg-secondary-container/0 text-on-surface-variant group-hover:w-14 group-hover:bg-on-surface/8'
70
+ "
71
+ >
72
+ <MBadge v-if="item.badge != null" :count="item.badge">
73
+ <MIcon :name="item.icon" :size="24" />
74
+ </MBadge>
75
+ <MBadge v-else-if="item.badgeDot" dot>
76
+ <MIcon :name="item.icon" :size="24" />
77
+ </MBadge>
78
+ <MIcon v-else :name="item.icon" :size="24" />
79
+ </span>
80
+ <span
81
+ class="text-label-medium font-medium"
82
+ :class="item.value === modelValue ? 'text-secondary' : 'text-on-surface-variant'"
83
+ >
84
+ {{ item.label }}
85
+ </span>
86
+ </template>
87
+
88
+ <template v-else>
89
+ <!-- Start icon position: one 40dp-tall pill wrapping icon+label together, 16dp
90
+ leading/trailing padding (ActiveIndicatorLeadingSpace/TrailingSpace) — selected label
91
+ uses the icon's own color here (OnSecondaryContainer), not the Top position's
92
+ separate Secondary label color (ShortNavigationBarItemDefaults.colors() doc comment). -->
93
+ <span
94
+ class="inline-flex h-10 items-center justify-center gap-1 rounded-2xl px-4 transition-colors duration-200"
95
+ :class="
96
+ item.value === modelValue
97
+ ? 'bg-secondary-container text-on-secondary-container'
98
+ : 'text-on-surface-variant group-hover:bg-on-surface/8'
99
+ "
100
+ >
101
+ <MBadge v-if="item.badge != null" :count="item.badge">
102
+ <MIcon :name="item.icon" :size="24" />
103
+ </MBadge>
104
+ <MBadge v-else-if="item.badgeDot" dot>
105
+ <MIcon :name="item.icon" :size="24" />
106
+ </MBadge>
107
+ <MIcon v-else :name="item.icon" :size="24" />
108
+ <span class="text-label-medium font-medium">{{ item.label }}</span>
109
+ </span>
110
+ </template>
111
+ </button>
112
+ </nav>
113
+ </template>
@@ -42,7 +42,7 @@ const panelStyle = computed(() => ({
42
42
  <Transition name="ss" :duration="{ enter: 320, leave: 280 }">
43
43
  <div v-if="modelValue" class="fixed inset-0 z-200 flex justify-end">
44
44
  <!-- Scrim -->
45
- <div class="ss-scrim absolute inset-0 bg-scrim/40" @click="close" />
45
+ <div class="ss-scrim absolute inset-0 bg-scrim/32" @click="close" />
46
46
 
47
47
  <!-- Panel -->
48
48
  <aside