@m3ui-vue/m3ui-vue 1.1.4 → 1.2.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 (200) hide show
  1. package/dist/API.md +511 -34
  2. package/dist/MMenuItem-DI351kIf.js +929 -0
  3. package/dist/MMenuItem-DI351kIf.js.map +1 -0
  4. package/dist/{MSlider-JflHJ70q.js → MSlider-BnEy5ieZ.js} +295 -320
  5. package/dist/MSlider-BnEy5ieZ.js.map +1 -0
  6. package/dist/MTextField-BBmkaIbO.js +633 -0
  7. package/dist/MTextField-BBmkaIbO.js.map +1 -0
  8. package/dist/api.json +1 -1
  9. package/dist/chart.js +83 -49
  10. package/dist/chart.js.map +1 -1
  11. package/dist/code-editor.js +1 -1
  12. package/dist/components/MButton.vue.d.ts +7 -1
  13. package/dist/components/MButtonGroup.vue.d.ts +40 -31
  14. package/dist/components/MCarousel.vue.d.ts +2 -0
  15. package/dist/components/MChart.vue.d.ts +6 -0
  16. package/dist/components/MCircleProgressBar.vue.d.ts +5 -3
  17. package/dist/components/MContextMenu.vue.d.ts +2 -2
  18. package/dist/components/MCopyButton.vue.d.ts +1 -1
  19. package/dist/components/MExportButton.vue.d.ts +1 -1
  20. package/dist/components/MFab.vue.d.ts +2 -2
  21. package/dist/components/MFabMenu.vue.d.ts +1 -1
  22. package/dist/components/MIconButton.vue.d.ts +13 -1
  23. package/dist/components/MInfiniteScroll.vue.d.ts +1 -1
  24. package/dist/components/MMap.vue.d.ts +20 -2
  25. package/dist/components/MMapBaseLayers.vue.d.ts +3 -0
  26. package/dist/components/MMapFilter.vue.d.ts +3 -0
  27. package/dist/components/MMapLayers.vue.d.ts +3 -0
  28. package/dist/components/MMenu.vue.d.ts +2 -2
  29. package/dist/components/MMenuItem.vue.d.ts +7 -3
  30. package/dist/components/MNavigationDrawer.vue.d.ts +13 -2
  31. package/dist/components/MOverlay.vue.d.ts +12 -1
  32. package/dist/components/MProgressBar.vue.d.ts +5 -3
  33. package/dist/components/MPullToRefresh.vue.d.ts +7 -2
  34. package/dist/components/MRichTextEditor.vue.d.ts +7 -1
  35. package/dist/components/MSearchField.vue.d.ts +58 -0
  36. package/dist/components/MSegmentedButton.vue.d.ts +31 -23
  37. package/dist/components/MSimpleCarousel.vue.d.ts +2 -0
  38. package/dist/components/MSkeleton.vue.d.ts +6 -3
  39. package/dist/components/MSwipeToDismiss.vue.d.ts +1 -1
  40. package/dist/components/MSwitch.vue.d.ts +1 -1
  41. package/dist/components/MTextField.vue.d.ts +5 -1
  42. package/dist/components/MTimeline.vue.d.ts +85 -22
  43. package/dist/components/MTooltip.vue.d.ts +1 -1
  44. package/dist/components/_MDrawerItemList.vue.d.ts +2 -0
  45. package/dist/composables/_mapStyle.d.ts +13 -0
  46. package/dist/composables/_themeTransition.d.ts +2 -0
  47. package/dist/composables/_tooltipTrigger.d.ts +22 -0
  48. package/dist/composables/_useMenuNav.d.ts +28 -0
  49. package/dist/composables/useAutoGrow.d.ts +21 -0
  50. package/dist/composables/useColorPalette.d.ts +1 -1
  51. package/dist/composables/useLocale.d.ts +3 -0
  52. package/dist/composables/useMap.d.ts +19 -3
  53. package/dist/composables/useMapFilter.d.ts +4 -1
  54. package/dist/composables/useMapLayers.d.ts +5 -2
  55. package/dist/composables/useScrollReveal.d.ts +44 -0
  56. package/dist/composables/useThemeTokens.d.ts +21 -0
  57. package/dist/composables/viewportHints.d.ts +27 -0
  58. package/dist/directives/vClickOutside.d.ts +25 -0
  59. package/dist/directives/vFocusRing.d.ts +22 -0
  60. package/dist/directives/vLongPress.d.ts +27 -0
  61. package/dist/directives/vReveal.d.ts +10 -0
  62. package/dist/directives/vScrollElevation.d.ts +31 -0
  63. package/dist/directives/vSkeleton.d.ts +19 -0
  64. package/dist/directives/vStateLayer.d.ts +20 -0
  65. package/dist/directives/vSwipe.d.ts +45 -0
  66. package/dist/directives/vTooltip.d.ts +23 -0
  67. package/dist/index.d.ts +28 -1
  68. package/dist/locales/index.js +21 -7
  69. package/dist/locales/index.js.map +1 -1
  70. package/dist/m3ui-vue.css +1 -1
  71. package/dist/m3ui.js +7132 -6217
  72. package/dist/m3ui.js.map +1 -1
  73. package/dist/map.d.ts +1 -1
  74. package/dist/map.js +821 -791
  75. package/dist/map.js.map +1 -1
  76. package/dist/motion-DZiXG09o.js +150 -0
  77. package/dist/motion-DZiXG09o.js.map +1 -0
  78. package/dist/plugin.d.ts +24 -0
  79. package/dist/rich-text-editor.js +13 -9
  80. package/dist/rich-text-editor.js.map +1 -1
  81. package/dist/styles/theme.css +63 -0
  82. package/dist/styles.css +1 -1
  83. package/dist/{useLocale-CXibICQA.js → useLocale-JYxDDeXC.js} +4 -2
  84. package/dist/useLocale-JYxDDeXC.js.map +1 -0
  85. package/dist/useThemeTokens-Bv-Uv8eX.js +135 -0
  86. package/dist/useThemeTokens-Bv-Uv8eX.js.map +1 -0
  87. package/package.json +1 -1
  88. package/src/__tests__/MButton.test.ts +22 -0
  89. package/src/__tests__/MCarousel.test.ts +9 -0
  90. package/src/__tests__/MChart.test.ts +77 -5
  91. package/src/__tests__/MIconButton.test.ts +33 -0
  92. package/src/__tests__/MMap.test.ts +53 -1
  93. package/src/__tests__/MMapLayers.test.ts +46 -2
  94. package/src/__tests__/MMenu.test.ts +104 -1
  95. package/src/__tests__/MMenuItem.test.ts +18 -0
  96. package/src/__tests__/MNavigationDrawer.test.ts +80 -0
  97. package/src/__tests__/MOverlay.test.ts +49 -0
  98. package/src/__tests__/MProgressBar.test.ts +41 -0
  99. package/src/__tests__/MPullToRefresh.test.ts +33 -0
  100. package/src/__tests__/MRichTextEditor.test.ts +22 -0
  101. package/src/__tests__/MSearchField.test.ts +71 -0
  102. package/src/__tests__/MSegmentedButton.test.ts +10 -0
  103. package/src/__tests__/MSkeleton.test.ts +38 -0
  104. package/src/__tests__/MTimeline.test.ts +238 -0
  105. package/src/__tests__/_fakeMaplibre.ts +3 -1
  106. package/src/__tests__/attrsFallthrough.test.ts +3 -0
  107. package/src/__tests__/escapeStack.test.ts +93 -0
  108. package/src/__tests__/ssr.test.ts +21 -2
  109. package/src/__tests__/useAutoGrow.test.ts +103 -0
  110. package/src/__tests__/useScrollReveal.test.ts +102 -0
  111. package/src/__tests__/useThemeTokens.test.ts +114 -0
  112. package/src/__tests__/vClickOutside.test.ts +82 -0
  113. package/src/__tests__/vFocusRing.test.ts +36 -0
  114. package/src/__tests__/vLongPress.test.ts +81 -0
  115. package/src/__tests__/vScrollElevation.test.ts +89 -0
  116. package/src/__tests__/vSkeleton.test.ts +48 -0
  117. package/src/__tests__/vStateLayer.test.ts +53 -0
  118. package/src/__tests__/vSwipe.test.ts +93 -0
  119. package/src/__tests__/vTooltip.test.ts +95 -0
  120. package/src/__tests__/viewportHints.test.ts +41 -0
  121. package/src/components/MAutocomplete.vue +5 -0
  122. package/src/components/MBottomSheet.vue +4 -1
  123. package/src/components/MButton.vue +15 -1
  124. package/src/components/MButtonGroup.vue +22 -17
  125. package/src/components/MCarousel.vue +7 -1
  126. package/src/components/MChart.vue +74 -34
  127. package/src/components/MCircleProgressBar.vue +14 -9
  128. package/src/components/MCommandPalette.vue +3 -2
  129. package/src/components/MContextMenu.vue +19 -60
  130. package/src/components/MDragDropList.vue +2 -0
  131. package/src/components/MIconButton.vue +40 -1
  132. package/src/components/MKanban.vue +2 -0
  133. package/src/components/MLightbox.vue +7 -2
  134. package/src/components/MMap.vue +38 -5
  135. package/src/components/MMapBaseLayers.vue +7 -3
  136. package/src/components/MMapFilter.vue +7 -4
  137. package/src/components/MMapGeoJson.vue +1 -1
  138. package/src/components/MMapLayers.vue +6 -2
  139. package/src/components/MMapMeasure.vue +5 -2
  140. package/src/components/MMenu.vue +18 -59
  141. package/src/components/MMenuItem.vue +11 -2
  142. package/src/components/MMultiAutocomplete.vue +5 -0
  143. package/src/components/MNavigationDrawer.vue +96 -11
  144. package/src/components/MNavigationRail.vue +4 -15
  145. package/src/components/MOverlay.vue +32 -13
  146. package/src/components/MProgressBar.vue +25 -27
  147. package/src/components/MPullToRefresh.vue +20 -1
  148. package/src/components/MRichTextEditor.vue +19 -5
  149. package/src/components/MSearchBar.vue +5 -0
  150. package/src/components/MSearchField.vue +142 -0
  151. package/src/components/MSegmentedButton.vue +20 -18
  152. package/src/components/MSelect.vue +10 -1
  153. package/src/components/MSideSheet.vue +5 -2
  154. package/src/components/MSimpleCarousel.vue +10 -1
  155. package/src/components/MSkeleton.vue +30 -8
  156. package/src/components/MSpotlightSearch.vue +3 -2
  157. package/src/components/MTextField.vue +15 -2
  158. package/src/components/MTimeline.vue +370 -81
  159. package/src/components/MTooltip.vue +20 -152
  160. package/src/components/_MDrawerItemList.vue +25 -6
  161. package/src/composables/_mapStyle.ts +45 -0
  162. package/src/composables/_themeTransition.ts +2 -0
  163. package/src/composables/_tooltipTrigger.ts +184 -0
  164. package/src/composables/_useMenuNav.ts +209 -0
  165. package/src/composables/useAutoGrow.ts +78 -0
  166. package/src/composables/useLocale.ts +5 -0
  167. package/src/composables/useMap.ts +43 -5
  168. package/src/composables/useMapFilter.ts +6 -5
  169. package/src/composables/useMapLayers.ts +7 -6
  170. package/src/composables/useScrollReveal.ts +151 -0
  171. package/src/composables/useThemeTokens.ts +116 -0
  172. package/src/composables/viewportHints.ts +80 -0
  173. package/src/directives/vClickOutside.ts +90 -0
  174. package/src/directives/vFocusRing.ts +60 -0
  175. package/src/directives/vLongPress.ts +134 -0
  176. package/src/directives/vReveal.ts +57 -0
  177. package/src/directives/vScrollElevation.ts +116 -0
  178. package/src/directives/vSkeleton.ts +87 -0
  179. package/src/directives/vStateLayer.ts +83 -0
  180. package/src/directives/vSwipe.ts +197 -0
  181. package/src/directives/vTooltip.ts +128 -0
  182. package/src/index.ts +28 -1
  183. package/src/locales/de.ts +2 -0
  184. package/src/locales/es.ts +2 -0
  185. package/src/locales/fr.ts +2 -0
  186. package/src/locales/ja.ts +2 -0
  187. package/src/locales/ko.ts +2 -0
  188. package/src/locales/pt.ts +2 -0
  189. package/src/locales/zh.ts +2 -0
  190. package/src/map.ts +1 -1
  191. package/src/plugin.ts +34 -0
  192. package/src/styles/theme.css +63 -0
  193. package/dist/MMenuItem-BfjqwcYP.js +0 -830
  194. package/dist/MMenuItem-BfjqwcYP.js.map +0 -1
  195. package/dist/MSlider-JflHJ70q.js.map +0 -1
  196. package/dist/MTextField-NaIB6RbM.js +0 -673
  197. package/dist/MTextField-NaIB6RbM.js.map +0 -1
  198. package/dist/composables/_useThemeTokens.d.ts +0 -7
  199. package/dist/useLocale-CXibICQA.js.map +0 -1
  200. package/src/composables/_useThemeTokens.ts +0 -42
@@ -10,6 +10,8 @@
10
10
  import { computed, Fragment, inject, nextTick, onMounted, onUnmounted, provide, ref, useSlots, watch, type VNode } from 'vue'
11
11
  import MIcon from './MIcon.vue'
12
12
  import MMenuDivider from './MMenuDivider.vue'
13
+ import { useEscapeStack } from '../composables/_useEscapeStack'
14
+ import { useMenuNav } from '../composables/_useMenuNav'
13
15
  import { POPUP_MARGIN, fitPopup } from '../composables/_popupPosition'
14
16
 
15
17
  defineOptions({ inheritAttrs: false })
@@ -101,41 +103,7 @@ onUnmounted(() => {
101
103
  const siblingGroup = inject<{ current: (() => void) | null } | null>('m-menu-sibling-group', null)
102
104
  provide('m-menu-sibling-group', { current: null })
103
105
 
104
- type NavEntry = { icon?: string, header?: () => any, content?: () => any }
105
- const navStack = ref<NavEntry[]>([])
106
- const currentNav = computed(() => navStack.value[navStack.value.length - 1])
107
- const navDirection = ref<'forward' | 'backward'>('forward')
108
-
109
- // See MMenu.vue: driven by the Web Animations API rather than Vue's
110
- // CSS-class transition hooks, which never reliably completed here with
111
- // dynamic (direction-dependent) enter/leave classes on a mode-less Transition.
112
- const slideDuration = 220
113
- function navSlideEnter(el: Element, done: () => void) {
114
- const dir = navDirection.value === 'forward' ? 1 : -1
115
- const anim = (el as HTMLElement).animate(
116
- [
117
- { transform: `translateX(${dir * 100}%)`, opacity: 0.4 },
118
- { transform: 'translateX(0%)', opacity: 1 },
119
- ],
120
- { duration: slideDuration, easing: 'cubic-bezier(0.05,0.7,0.1,1)' },
121
- )
122
- anim.onfinish = done
123
- }
124
- function navSlideLeave(el: Element, done: () => void) {
125
- const dir = navDirection.value === 'forward' ? -1 : 1
126
- const htmlEl = el as HTMLElement
127
- htmlEl.style.position = 'absolute'
128
- htmlEl.style.insetInline = '0'
129
- htmlEl.style.top = '0'
130
- const anim = htmlEl.animate(
131
- [
132
- { transform: 'translateX(0%)', opacity: 1 },
133
- { transform: `translateX(${dir * 100}%)`, opacity: 0.4 },
134
- ],
135
- { duration: slideDuration, easing: 'cubic-bezier(0.3,0,0.8,0.15)' },
136
- )
137
- anim.onfinish = done
138
- }
106
+ const { navStack, currentNav, navBox, navSlideEnter, navSlideLeave, pushNav, popNav, onNavPointerDown } = useMenuNav(() => focusableItems()[0]?.focus())
139
107
 
140
108
  // See MMenu.vue: the real Menu.kt animates the panel's scale/alpha with
141
109
  // actual springs (StandardMotionTokens: scale dampingRatio 0.9/stiffness
@@ -244,18 +212,6 @@ function panelLeave(el: Element, done: () => void) {
244
212
  playTrajectory(el, done, false)
245
213
  }
246
214
 
247
- function pushNav(entry: NavEntry) {
248
- navDirection.value = 'forward'
249
- navStack.value.push(entry)
250
- nextTick(() => focusableItems()[0]?.focus())
251
- }
252
-
253
- function popNav() {
254
- navDirection.value = 'backward'
255
- navStack.value.pop()
256
- nextTick(() => focusableItems()[0]?.focus())
257
- }
258
-
259
215
  async function showAt(x: number, y: number) {
260
216
  origin.value = 'left top'
261
217
  if (siblingGroup && siblingGroup.current && siblingGroup.current !== hide) {
@@ -325,12 +281,11 @@ function onDocMouseDown(e: MouseEvent) {
325
281
  hide()
326
282
  }
327
283
 
284
+ // Escape goes through the library's stack, so a menu open in a dialog or an overlay closes alone (a pushed
285
+ // submenu steps back first)
286
+ useEscapeStack(() => visible.value, () => (navStack.value.length ? popNav() : hide()))
287
+
328
288
  function onKeydown(e: KeyboardEvent) {
329
- if (e.key === 'Escape') {
330
- if (navStack.value.length) popNav()
331
- else hide()
332
- return
333
- }
334
289
  if (!visible.value) return
335
290
  if (e.key === 'ArrowDown') { e.preventDefault(); moveFocus(1) }
336
291
  else if (e.key === 'ArrowUp') { e.preventDefault(); moveFocus(-1) }
@@ -380,31 +335,35 @@ onUnmounted(() => {
380
335
  :style="{ left: `${adjustedPos.x}px`, top: `${adjustedPos.y}px`, transformOrigin: origin, maxWidth: `calc(100vw - ${2 * POPUP_MARGIN}px)` }"
381
336
  @contextmenu.prevent
382
337
  >
383
- <!-- overflow-hidden (for the rounded-corner clip and to clip the push
338
+ <!-- The overflow clip (for the rounded corners and to clip the push
384
339
  submenu's slide) lives on this inner wrapper, never together with
385
340
  shadow-elevation-2 on the same box — overflow-hidden clips an
386
341
  element's own box-shadow too, so the two have to be on separate
387
342
  elements or the shadow gets cut off -->
388
- <!-- Scrolls when taller than the window -->
343
+ <!-- Scrolls when taller than the window. overflow-y is a class, not :style: a :style object sets every key again
344
+ on each patch, which undid the push transition's inline overflow-y: hidden (the scrollbar flashed) -->
389
345
  <div
390
- class="overflow-hidden py-1"
391
- :style="{ maxHeight: `calc(100vh - ${2 * POPUP_MARGIN}px)`, overflowY: 'auto' }"
346
+ ref="navBox"
347
+ class="relative overflow-x-hidden overflow-y-auto overscroll-contain py-1"
348
+ :style="{ maxHeight: `calc(100vh - ${2 * POPUP_MARGIN}px)`, touchAction: currentNav ? 'pan-y' : undefined }"
349
+ @pointerdown="onNavPointerDown"
392
350
  :class="[
393
351
  variant === 'expressive' ? 'rounded-lg' : 'rounded-xs',
394
352
  isGrouped ? '' : 'bg-surface-container',
395
353
  ]"
396
354
  >
397
355
  <Transition :css="false" @enter="navSlideEnter" @leave="navSlideLeave">
398
- <div v-if="currentNav" :key="navStack.length">
356
+ <div v-if="currentNav" :key="navStack.length" :data-menu-level="navStack.length">
357
+ <!-- Back: a header row in the menu's own item metrics, labelled like an M3 menu group, then a divider -->
399
358
  <button
400
359
  type="button"
401
- class="flex w-full items-center gap-3 border-b border-outline-variant px-4 py-2.5 text-left text-body-large text-on-surface outline-none transition-colors hover:bg-on-surface/8 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-secondary"
360
+ class="flex w-full items-center gap-3 px-4 py-2.5 text-left text-label-large text-on-surface-variant outline-none transition-colors hover:bg-on-surface/8 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-secondary"
402
361
  @click="popNav"
403
362
  >
404
- <MIcon name="chevron_left" :size="20" class="shrink-0 text-on-surface-variant" />
405
- <MIcon v-if="currentNav.icon" :name="currentNav.icon" :size="20" class="shrink-0 text-on-surface-variant" />
363
+ <MIcon name="arrow_back" :size="20" class="shrink-0" />
406
364
  <span class="flex-1 truncate"><component :is="() => currentNav?.header?.()" /></span>
407
365
  </button>
366
+ <hr class="my-1 border-outline-variant" />
408
367
  <component :is="() => currentNav?.content?.()" />
409
368
  </div>
410
369
  <div v-else key="root">
@@ -397,7 +397,9 @@ function onKeydown(e: KeyboardEvent, index: number) {
397
397
  commit(index, to)
398
398
  say(t.reorderMoved, to)
399
399
  } else if (grabbed && e.key === 'Escape') {
400
+ // Cancelling the move uses the key: a dialog around the list stays open
400
401
  e.preventDefault()
402
+ e.stopPropagation()
401
403
  cancelKeyboard(index)
402
404
  }
403
405
  }
@@ -18,6 +18,18 @@ const props = withDefaults(
18
18
  label?: string
19
19
  /** Visual style */
20
20
  variant?: 'standard' | 'filled' | 'tonal' | 'outlined'
21
+ /**
22
+ * An M3 role or any CSS color (`#fff` over a photo, `rgb(0 0 0 / 0.3)` for a scrim-like filled button,
23
+ * `currentColor` to follow the surrounding text). Standard and outlined use it for the icon; filled for the
24
+ * container with white (or the role's on-color) on it; tonal for a 20% container with the color on it.
25
+ * Disabled buttons and toggles keep their own colors
26
+ */
27
+ color?: 'primary' | 'secondary' | 'tertiary' | 'error' | (string & {})
28
+ /**
29
+ * Icon color over what the variant and `color` give: an M3 role (`on-surface`…) or any CSS color (`#000` on a
30
+ * white filled button). Disabled buttons and toggles keep their own
31
+ */
32
+ contentColor?: string
21
33
  /**
22
34
  * Button shape — rounded (pill, always) or squared (corner radius scales with size: 12px xs/sm, 16px md,
23
35
  * 28px lg/xl)
@@ -53,6 +65,33 @@ const props = withDefaults(
53
65
  const emit = defineEmits<{ 'update:checked': [boolean] }>()
54
66
 
55
67
  const isToggle = computed(() => props.checked !== undefined)
68
+
69
+ const ROLES = ['primary', 'secondary', 'tertiary', 'error']
70
+ // Color-role names (`on-surface`…) read the theme's token; anything else is a CSS color
71
+ const ROLE = /^(on-)?(primary|secondary|tertiary|error|surface|surface-variant|inverse-surface|inverse-primary)(-container|-variant)?$/
72
+ const colorStyle = computed(() => {
73
+ const base = paintStyle()
74
+ const cc = props.contentColor
75
+ if (!cc || props.disabled || isToggle.value) return base
76
+ return { ...base, color: ROLE.test(cc) ? `var(--color-${cc})` : cc }
77
+ })
78
+ // `color` as inline styles over the variant's classes, so the default look stays class-only
79
+ function paintStyle() {
80
+ const c = props.color
81
+ if (!c || props.disabled || isToggle.value) return undefined
82
+ const role = ROLES.includes(c)
83
+ const main = role ? `var(--color-${c})` : c
84
+ switch (props.variant) {
85
+ case 'filled':
86
+ return { backgroundColor: main, color: role ? `var(--color-on-${c})` : '#fff' }
87
+ case 'tonal':
88
+ return role
89
+ ? { backgroundColor: `var(--color-${c}-container)`, color: `var(--color-on-${c}-container)` }
90
+ : { backgroundColor: `color-mix(in srgb, ${c} 20%, transparent)`, color: c }
91
+ default:
92
+ return { color: main }
93
+ }
94
+ }
56
95
  const tag = computed(() => props.to && !isToggle.value ? 'RouterLink' : 'button')
57
96
 
58
97
  // Container height/width (icon buttons are always square by default — real
@@ -193,7 +232,7 @@ const variantClasses = computed(() => {
193
232
  :aria-pressed="isToggle ? checked : undefined"
194
233
  :disabled="disabled"
195
234
  :class="[base, shapeClass, variantClasses, disabledContainerClasses]"
196
- :style="{ width: `${resolved.px}px`, height: `${resolved.px}px` }"
235
+ :style="[{ width: `${resolved.px}px`, height: `${resolved.px}px` }, colorStyle]"
197
236
  v-ripple="{ disabled, color: rippleColor }"
198
237
  @pointerdown="onPointerDown"
199
238
  @pointerup="onPointerUp"
@@ -621,7 +621,9 @@ function onCardKeydown(e: KeyboardEvent, card: KanbanCard, column: KanbanColumn)
621
621
  toCol = next
622
622
  toIndex = Math.min(here.index, next.cards.length)
623
623
  } else if (e.key === 'Escape') {
624
+ // Cancelling the move uses the key: a dialog around the board stays open
624
625
  e.preventDefault()
626
+ e.stopPropagation()
625
627
  cancelKeyboard(card.id, here.column.id, here.index)
626
628
  return
627
629
  } else if (e.key === 'Enter') {
@@ -32,6 +32,7 @@ import MIconButton from './MIconButton.vue'
32
32
  import MSpinner from './MSpinner.vue'
33
33
  import { useLocale } from '../composables/useLocale'
34
34
  import { useScrollLock } from '../composables/_useScrollLock'
35
+ import { useEscapeStack } from '../composables/_useEscapeStack'
35
36
 
36
37
  export interface LightboxItem {
37
38
  src: string
@@ -288,6 +289,9 @@ function originTransform(): Origin | null {
288
289
 
289
290
  // The page doesn't scroll from when it opens until its close animation ends
290
291
  const scrollLock = useScrollLock()
292
+ // Escape closes it through the library's stack (a dialog opened over it takes it first); arrows and zoom keys stay ours
293
+ const escapeOn = ref(false)
294
+ useEscapeStack(escapeOn, () => close())
291
295
 
292
296
  async function show() {
293
297
  restoreFocus = document.activeElement as HTMLElement | null
@@ -300,6 +304,7 @@ async function show() {
300
304
  setNow(backdrop, 0)
301
305
  backdrop.k = 300
302
306
  document.addEventListener('keydown', onKeydown)
307
+ escapeOn.value = true
303
308
  scrollLock.set(true)
304
309
  await nextTick()
305
310
  measure()
@@ -319,6 +324,7 @@ async function show() {
319
324
 
320
325
  function hide() {
321
326
  document.removeEventListener('keydown', onKeydown)
327
+ escapeOn.value = false
322
328
  // The bars and the backdrop go with the image, not after it.
323
329
  chrome.value = false
324
330
  backdrop.k = 700
@@ -674,8 +680,7 @@ function onTap(e: PointerEvent) {
674
680
  // ── Keyboard and focus ────────────────────────────────────────────────────────────────────────
675
681
 
676
682
  function onKeydown(e: KeyboardEvent) {
677
- if (e.key === 'Escape') close()
678
- else if (e.key === 'ArrowRight') next()
683
+ if (e.key === 'ArrowRight') next()
679
684
  else if (e.key === 'ArrowLeft') prev()
680
685
  else if (props.zoom && (e.key === '+' || e.key === '=')) zoomTo(scale.target * 1.5, 0, 0)
681
686
  else if (props.zoom && e.key === '-') zoomTo(scale.target / 1.5, 0, 0)
@@ -21,16 +21,31 @@ import { markRaw, onBeforeUnmount, onMounted, onUnmounted, provide, ref, shallow
21
21
  import type * as Maplibre from 'maplibre-gl'
22
22
  import MMapAttribution from './_MMapAttribution.vue'
23
23
  import { useLocale } from '../composables/useLocale'
24
- import { MAP_KEY, type MaplibreModule } from '../composables/useMap'
24
+ import { MAP_KEY, type MapContext, type MaplibreModule } from '../composables/useMap'
25
25
  import { createLayerState, readLayerState } from '../composables/useMapLayers'
26
26
  import type { MapAdapter, MapLayerModel } from '../composables/mapAdapters'
27
+ import { carryRuntimeLayers, styleIds, type StyleIds } from '../composables/_mapStyle'
27
28
 
28
29
  export type MapControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
29
30
 
30
31
  const props = withDefaults(
31
32
  defineProps<{
32
- /** The map's style: a style JSON URL or a style object (MapLibre's `StyleSpecification`). Changing it reloads the style */
33
+ /**
34
+ * The map's style: a style JSON URL or a style object (MapLibre's `StyleSpecification`). Changing it reloads the
35
+ * style, keeping what was added at runtime (see `keepLayers`)
36
+ */
33
37
  mapStyle: string | Maplibre.StyleSpecification
38
+ /**
39
+ * What happens to the sources and layers added at runtime (with `useMap()`, or by `MMapGeoJson`, `MMapMeasure`…)
40
+ * when `mapStyle` changes: `true` carries them into the new style, on top of its layers; `false` drops them, as
41
+ * MapLibre does; a function picks the layers to carry (their sources come along)
42
+ */
43
+ keepLayers?: boolean | ((layer: Maplibre.LayerSpecification) => boolean)
44
+ /**
45
+ * MapLibre's `transformStyle` for a `mapStyle` change, run after `keepLayers`: edit the next style before it
46
+ * loads (copy a layer's paint over, add a sprite…)
47
+ */
48
+ transformStyle?: Maplibre.TransformStyleFunction
34
49
  /** `[lng, lat]` (v-model). When left out, the style's (or the remembered view's) */
35
50
  center?: [number, number]
36
51
  /** Zoom level (v-model) */
@@ -64,6 +79,7 @@ const props = withDefaults(
64
79
  }>(),
65
80
  {
66
81
  persist: false,
82
+ keepLayers: true,
67
83
  navigation: true,
68
84
  geolocate: false,
69
85
  fullscreen: false,
@@ -86,10 +102,13 @@ const container = ref<HTMLElement>()
86
102
  const map = shallowRef<Maplibre.Map>()
87
103
  const maplibre = shallowRef<MaplibreModule>()
88
104
  const styleVersion = ref(0)
105
+ // The sources and layers the current style came with (the rest were added at runtime: keepLayers)
106
+ let ownIds: StyleIds | undefined
89
107
  const model = shallowRef<MapLayerModel>()
90
108
  const layerState = createLayerState()
91
109
  const activeTool = ref<string | null>(null)
92
- provide(MAP_KEY, { map, maplibre, styleVersion, model, layerState, activeTool })
110
+ const context: MapContext = { map, maplibre, styleVersion, model, layerState, activeTool }
111
+ provide(MAP_KEY, context)
93
112
 
94
113
  /** The adapter's model of the current style, and the layers' visibility and opacity in it. */
95
114
  function readModel(m: Maplibre.Map) {
@@ -276,6 +295,8 @@ onMounted(async () => {
276
295
  maplibre.value = ml
277
296
 
278
297
  m.on('style.load', () => {
298
+ // The first style's own ids; a later style's are taken in transformStyle, before runtime layers join it
299
+ if (!ownIds) ownIds = styleIds(m.getStyle())
279
300
  readModel(m)
280
301
  styleVersion.value++
281
302
  })
@@ -327,12 +348,24 @@ watch(() => props.pitch, (pitch) => {
327
348
  if (map.value && pitch !== undefined && !near(map.value.getPitch(), pitch)) map.value.jumpTo({ pitch })
328
349
  })
329
350
  watch(() => props.adapter, () => { if (map.value) readModel(map.value) })
330
- // A full reload (no diff): style.load fires, and components re-add their sources and layers
331
- watch(() => props.mapStyle, (style) => map.value?.setStyle(style, { diff: false }))
351
+ // A full reload (no diff): style.load fires, and components re-add whatever didn't come along
352
+ watch(() => props.mapStyle, (style) => map.value?.setStyle(style, {
353
+ diff: false,
354
+ transformStyle: (previous, next) => {
355
+ const own = ownIds ?? styleIds(undefined)
356
+ ownIds = styleIds(next)
357
+ const keep = props.keepLayers
358
+ let result = keep === false ? next : carryRuntimeLayers(previous, next, own, typeof keep === 'function' ? keep : undefined)
359
+ if (props.transformStyle) result = props.transformStyle(previous, result)
360
+ return result
361
+ },
362
+ }))
332
363
 
333
364
  defineExpose({
334
365
  /** The MapLibre map, once loaded */
335
366
  map,
367
+ /** What the components inside it share: pass the `MMap` (or this) as `map` to `MMapLayers`, `useMap()`… outside it */
368
+ context,
336
369
  })
337
370
  </script>
338
371
 
@@ -2,13 +2,15 @@
2
2
  /**
3
3
  * The base layer switcher of an `MMap` with an `adapter`: a round thumbnail per base layer (the adapter's `image`,
4
4
  * after `imageBase`), one shown at a time, plus "no base layer". Only the thumbnails: put them in an `MMapControl`
5
- * (`:group="false"`), an `MFab`'s `#content` or a panel. Available from the `/map` entry point.
5
+ * (`:group="false"`), an `MFab`'s `#content` or a panel, inside the `MMap` or anywhere else with `map`. Available
6
+ * from the `/map` entry point.
6
7
  */
7
8
  import MIcon from './MIcon.vue'
8
9
  import { useLocale } from '../composables/useLocale'
9
10
  import { useMapLayers } from '../composables/useMapLayers'
11
+ import type { MapSource } from '../composables/useMap'
10
12
 
11
- withDefaults(
13
+ const props = withDefaults(
12
14
  defineProps<{
13
15
  /** Prefix for the thumbnails' paths (e.g. `/images/`); full URLs are used as they are */
14
16
  imageBase?: string
@@ -16,12 +18,14 @@ withDefaults(
16
18
  none?: boolean
17
19
  /** Lay them out in a column */
18
20
  vertical?: boolean
21
+ /** The map, when this is outside it (a side panel): the `MMap`'s template ref */
22
+ map?: MapSource
19
23
  }>(),
20
24
  { imageBase: '', none: true, vertical: false },
21
25
  )
22
26
 
23
27
  const t = useLocale()
24
- const { baseLayers, baseLayer, setBaseLayer } = useMapLayers()
28
+ const { baseLayers, baseLayer, setBaseLayer } = useMapLayers(() => props.map)
25
29
 
26
30
  const src = (image: string, base: string) => (/^(https?:|data:|\/\/)/.test(image) ? image : `${base}${image}`)
27
31
  </script>
@@ -3,11 +3,12 @@
3
3
  * A simple filter for one layer of an `MMap`: chips for the values of one of its properties; the layer shows only the
4
4
  * features with the selected ones (all of them with none selected). The values are `values`, or else the distinct
5
5
  * ones among the layer's features loaded in the map. The style's own filter on the layer stays. For anything more
6
- * involved, build your own on `useMapFilter()`. Available from the `/map` entry point.
6
+ * involved, build your own on `useMapFilter()`. Inside the `MMap`, or anywhere else with `map`. Available from the `/map`
7
+ * entry point.
7
8
  */
8
9
  import { computed, onBeforeUnmount, ref, watch } from 'vue'
9
10
  import MChip from './MChip.vue'
10
- import { useMap } from '../composables/useMap'
11
+ import { useMap, type MapSource } from '../composables/useMap'
11
12
  import { useMapFilter } from '../composables/useMapFilter'
12
13
 
13
14
  const props = defineProps<{
@@ -21,12 +22,14 @@ const props = defineProps<{
21
22
  labels?: Record<string, string>
22
23
  /** The selected values (v-model) */
23
24
  modelValue?: (string | number)[]
25
+ /** The map, when this is outside it (a side panel): the `MMap`'s template ref */
26
+ map?: MapSource
24
27
  }>()
25
28
 
26
29
  const emit = defineEmits<{ 'update:modelValue': [values: (string | number)[]] }>()
27
30
 
28
- const { onReady, styleVersion } = useMap()
29
- const { setFilter, valuesOf } = useMapFilter()
31
+ const { onReady, styleVersion } = useMap(() => props.map)
32
+ const { setFilter, valuesOf } = useMapFilter(() => props.map)
30
33
 
31
34
  const found = ref<(string | number)[]>([])
32
35
  const options = computed(() => props.values ?? found.value)
@@ -10,7 +10,7 @@
10
10
  import { computed, onBeforeUnmount, useId, watch } from 'vue'
11
11
  import type * as Maplibre from 'maplibre-gl'
12
12
  import { useMap } from '../composables/useMap'
13
- import { useThemeTokens } from '../composables/_useThemeTokens'
13
+ import { useThemeTokens } from '../composables/useThemeTokens'
14
14
 
15
15
  // Omit over each member of the union (a plain Omit keeps only what all layer types share, losing paint and layout)
16
16
  type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never
@@ -3,7 +3,8 @@
3
3
  * The layer list of an `MMap` with an `adapter`: a search field, the style's groups (collapsible, with a visibility
4
4
  * toggle for the whole group and a count) and its layers, each with a visibility toggle and, expanded, its
5
5
  * description, an opacity slider, its legend and a download link. Only the content: put it in an `MWindow`, an
6
- * `MSideSheet`, an `MBottomSheet` or an `MMapControl`. Available from the `/map` entry point.
6
+ * `MSideSheet`, an `MBottomSheet` or an `MMapControl`, inside the `MMap` or anywhere else with `map`. Available from the
7
+ * `/map` entry point.
7
8
  *
8
9
  * @slot actions Extra actions in an expanded layer (scope: `{ layer, visible }`)
9
10
  */
@@ -13,6 +14,7 @@ import MTextField from './MTextField.vue'
13
14
  import MMapLayerItem from './_MMapLayerItem.vue'
14
15
  import { useLocale } from '../composables/useLocale'
15
16
  import { useMapLayers } from '../composables/useMapLayers'
17
+ import type { MapSource } from '../composables/useMap'
16
18
  import type { MapLayerInfo } from '../composables/mapAdapters'
17
19
 
18
20
  const props = withDefaults(
@@ -21,12 +23,14 @@ const props = withDefaults(
21
23
  search?: boolean
22
24
  /** Groups start collapsed */
23
25
  collapsed?: boolean
26
+ /** The map, when this is outside it (a side panel): the `MMap`'s template ref */
27
+ map?: MapSource
24
28
  }>(),
25
29
  { search: true, collapsed: false },
26
30
  )
27
31
 
28
32
  const t = useLocale()
29
- const { model, layersOf, isVisible, groupState, setGroupVisible } = useMapLayers()
33
+ const { model, layersOf, isVisible, groupState, setGroupVisible } = useMapLayers(() => props.map)
30
34
 
31
35
  const query = ref('')
32
36
  const matches = (layer: MapLayerInfo) => !query.value || layer.title.toLowerCase().includes(query.value.toLowerCase())
@@ -17,7 +17,8 @@ import MMapControl from './MMapControl.vue'
17
17
  import MMapMarker from './MMapMarker.vue'
18
18
  import { useLocale } from '../composables/useLocale'
19
19
  import { useMap } from '../composables/useMap'
20
- import { useThemeTokens } from '../composables/_useThemeTokens'
20
+ import { useThemeTokens } from '../composables/useThemeTokens'
21
+ import { useEscapeStack } from '../composables/_useEscapeStack'
21
22
  import { centroid, closeRing, distance, midpoint, pathLength, ringArea, type LngLat } from '../composables/_mapGeometry'
22
23
  import type { MapControlPosition } from './MMap.vue'
23
24
 
@@ -216,9 +217,11 @@ function onDblClick(e: Maplibre.MapMouseEvent) {
216
217
  finish()
217
218
  }
218
219
 
220
+ // Enter finishes; Escape goes through the library's stack, so measuring on a map in a dialog doesn't close it too
219
221
  function onKey(e: KeyboardEvent) {
220
- if (e.key === 'Escape' || e.key === 'Enter') finish(e.key === 'Escape')
222
+ if (e.key === 'Enter') finish()
221
223
  }
224
+ useEscapeStack(() => !!mode.value, () => finish(true))
222
225
 
223
226
  // In fullscreen the browser keeps Escape to leave it, and the page never sees it. Keyboard Lock (Chromium) lets the
224
227
  // page have it while measuring, so Escape finishes the measurement (holding Escape still leaves fullscreen)
@@ -9,6 +9,8 @@
9
9
  import { computed, Fragment, inject, nextTick, onMounted, onUnmounted, provide, ref, useSlots, watch, type VNode } from 'vue'
10
10
  import MIcon from './MIcon.vue'
11
11
  import MMenuDivider from './MMenuDivider.vue'
12
+ import { useEscapeStack } from '../composables/_useEscapeStack'
13
+ import { useMenuNav } from '../composables/_useMenuNav'
12
14
  import { POPUP_MARGIN, dropdownX } from '../composables/_popupPosition'
13
15
 
14
16
  defineOptions({ inheritAttrs: false })
@@ -76,43 +78,7 @@ const groups = computed(() => {
76
78
  })
77
79
  const isGrouped = computed(() => !!groups.value && groups.value.length > 1)
78
80
 
79
- type NavEntry = { icon?: string, header?: () => any, content?: () => any }
80
- const navStack = ref<NavEntry[]>([])
81
- const currentNav = computed(() => navStack.value[navStack.value.length - 1])
82
- const navDirection = ref<'forward' | 'backward'>('forward')
83
-
84
- // Driven by the Web Animations API rather than Vue's CSS-class transition
85
- // hooks — with dynamic (direction-dependent) enter/leave classes on a
86
- // Transition with no `mode`, Vue's from->active->to class swap unreliably
87
- // never completed (elements got stuck straddling from/active with the
88
- // animation never actually running), so this drives it directly instead.
89
- const slideDuration = 220
90
- function navSlideEnter(el: Element, done: () => void) {
91
- const dir = navDirection.value === 'forward' ? 1 : -1
92
- const anim = (el as HTMLElement).animate(
93
- [
94
- { transform: `translateX(${dir * 100}%)`, opacity: 0.4 },
95
- { transform: 'translateX(0%)', opacity: 1 },
96
- ],
97
- { duration: slideDuration, easing: 'cubic-bezier(0.05,0.7,0.1,1)' },
98
- )
99
- anim.onfinish = done
100
- }
101
- function navSlideLeave(el: Element, done: () => void) {
102
- const dir = navDirection.value === 'forward' ? -1 : 1
103
- const htmlEl = el as HTMLElement
104
- htmlEl.style.position = 'absolute'
105
- htmlEl.style.insetInline = '0'
106
- htmlEl.style.top = '0'
107
- const anim = htmlEl.animate(
108
- [
109
- { transform: 'translateX(0%)', opacity: 1 },
110
- { transform: `translateX(${dir * 100}%)`, opacity: 0.4 },
111
- ],
112
- { duration: slideDuration, easing: 'cubic-bezier(0.3,0,0.8,0.15)' },
113
- )
114
- anim.onfinish = done
115
- }
81
+ const { navStack, currentNav, navBox, navSlideEnter, navSlideLeave, pushNav, popNav, onNavPointerDown } = useMenuNav(() => focusFirstItem())
116
82
 
117
83
  // The real DropdownMenuContent in Menu.kt animates scale (0.8 -> 1) and alpha
118
84
  // (0 -> 1) with actual springs (MotionSchemeKeyTokens.FastSpatial/FastEffects
@@ -229,18 +195,6 @@ function panelLeave(el: Element, done: () => void) {
229
195
  playTrajectory(el, done, false)
230
196
  }
231
197
 
232
- function pushNav(entry: NavEntry) {
233
- navDirection.value = 'forward'
234
- navStack.value.push(entry)
235
- nextTick(() => focusFirstItem())
236
- }
237
-
238
- function popNav() {
239
- navDirection.value = 'backward'
240
- navStack.value.pop()
241
- nextTick(() => focusFirstItem())
242
- }
243
-
244
198
  const open = ref(false)
245
199
  const triggerEl = ref<HTMLElement | null>(null)
246
200
  const dropdownEl = ref<HTMLElement | null>(null)
@@ -388,12 +342,11 @@ function onScroll(e: Event) {
388
342
  close()
389
343
  }
390
344
 
345
+ // Escape goes through the library's stack, so a menu open in a dialog or an overlay closes alone (a pushed
346
+ // submenu steps back first)
347
+ useEscapeStack(() => open.value, () => (navStack.value.length ? popNav() : close()))
348
+
391
349
  function onKeydown(e: KeyboardEvent) {
392
- if (e.key === 'Escape') {
393
- if (navStack.value.length) popNav()
394
- else close()
395
- return
396
- }
397
350
  if (!open.value) return
398
351
  if (e.key === 'ArrowDown') { e.preventDefault(); moveFocus(1) }
399
352
  else if (e.key === 'ArrowUp') { e.preventDefault(); moveFocus(-1) }
@@ -445,18 +398,24 @@ const origin = computed(() => `${originX.value} ${openAbove.value ? 'bottom' : '
445
398
  isGrouped ? '' : 'bg-surface-container',
446
399
  ]"
447
400
  >
448
- <div class="relative overflow-y-auto overscroll-contain py-1" :style="{ maxHeight: dropStyle.maxHeight }">
401
+ <div
402
+ ref="navBox"
403
+ class="relative overflow-x-hidden overflow-y-auto overscroll-contain py-1"
404
+ :style="{ maxHeight: dropStyle.maxHeight, touchAction: currentNav ? 'pan-y' : undefined }"
405
+ @pointerdown="onNavPointerDown"
406
+ >
449
407
  <Transition :css="false" @enter="navSlideEnter" @leave="navSlideLeave">
450
- <div v-if="currentNav" :key="navStack.length">
408
+ <div v-if="currentNav" :key="navStack.length" :data-menu-level="navStack.length">
409
+ <!-- Back: a header row in the menu's own item metrics, labelled like an M3 menu group, then a divider -->
451
410
  <button
452
411
  type="button"
453
- class="flex w-full items-center gap-3 border-b border-outline-variant px-4 py-2.5 text-left text-body-large text-on-surface outline-none transition-colors hover:bg-on-surface/8 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-secondary"
412
+ class="flex w-full items-center gap-3 px-4 py-2.5 text-left text-label-large text-on-surface-variant outline-none transition-colors hover:bg-on-surface/8 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-secondary"
454
413
  @click="popNav"
455
414
  >
456
- <MIcon name="chevron_left" :size="20" class="shrink-0 text-on-surface-variant" />
457
- <MIcon v-if="currentNav.icon" :name="currentNav.icon" :size="20" class="shrink-0 text-on-surface-variant" />
415
+ <MIcon name="arrow_back" :size="20" class="shrink-0" />
458
416
  <span class="flex-1 truncate"><component :is="() => currentNav?.header?.()" /></span>
459
417
  </button>
418
+ <hr class="my-1 border-outline-variant" />
460
419
  <component :is="() => currentNav?.content?.()" />
461
420
  </div>
462
421
  <div v-else key="root">
@@ -6,6 +6,8 @@
6
6
  * check that slides in.
7
7
  *
8
8
  * @slot default Item label text.
9
+ * @slot icon Replaces the leading icon (an `MIcon` with a class, an image, an avatar…), `{ on }` while selected or
10
+ * checked. It gets the icon's 20px box and color
9
11
  * @slot children Nested submenu items. In the parent MMenu's default 'flyout' mode, clicking or hovering (mouse
10
12
  * only) the item opens a side panel — supports unlimited nesting depth. In 'push' mode, clicking the item
11
13
  * instead swaps the whole menu panel to the submenu with a back header; hover does nothing.
@@ -50,11 +52,12 @@ const props = withDefaults(defineProps<{
50
52
 
51
53
  const emit = defineEmits<{ click: [], 'update:checked': [boolean] }>()
52
54
 
55
+ const slots = useSlots()
53
56
  const checkable = computed(() => props.checked !== undefined)
54
57
  const selectable = computed(() => checkable.value || props.selected !== undefined)
55
58
  const on = computed(() => !!(props.checked ?? props.selected))
56
59
  // Without an `icon`, the selected icon (a check by default) only shows while on and slides the label aside
57
- const slidingIcon = computed(() => selectable.value && !props.icon)
60
+ const slidingIcon = computed(() => selectable.value && !props.icon && !slots.icon)
58
61
  const onIcon = computed(() => props.selectedIcon ?? (props.icon ? undefined : 'check'))
59
62
 
60
63
  // Where this item sits in a run of consecutive selectable/checkable siblings, MenuDefaults.itemShape(index,
@@ -108,7 +111,6 @@ useSpring(
108
111
  FAST_EFFECTS,
109
112
  )
110
113
 
111
- const slots = useSlots()
112
114
  const tag = computed(() => props.to ? 'RouterLink' : 'button')
113
115
  const hasChildren = computed(() => !!slots.children)
114
116
  const menuClose = inject<(() => void) | null>('m-menu-close', null)
@@ -242,6 +244,13 @@ function onSubPointerLeave(e: PointerEvent) {
242
244
  <span v-if="slidingIcon" ref="iconSlotEl" class="-mr-3 flex shrink-0 overflow-hidden" style="width: 0; opacity: 0">
243
245
  <MIcon :name="onIcon!" :size="20" class="shrink-0" />
244
246
  </span>
247
+ <span
248
+ v-else-if="$slots.icon"
249
+ class="flex size-5 shrink-0 items-center justify-center"
250
+ :class="selectable ? (on ? '' : 'text-on-surface-variant') : danger ? 'text-error' : 'text-on-surface-variant'"
251
+ >
252
+ <slot name="icon" :on="on" />
253
+ </span>
245
254
  <MIcon
246
255
  v-else-if="icon"
247
256
  :name="on && onIcon ? onIcon : icon"