@m3ui-vue/m3ui-vue 1.1.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/API.md +579 -40
- package/dist/MMenuItem-DI351kIf.js +929 -0
- package/dist/MMenuItem-DI351kIf.js.map +1 -0
- package/dist/MSlider-BnEy5ieZ.js +1500 -0
- package/dist/MSlider-BnEy5ieZ.js.map +1 -0
- package/dist/MTextField-BBmkaIbO.js +633 -0
- package/dist/MTextField-BBmkaIbO.js.map +1 -0
- package/dist/api.json +1 -1
- package/dist/chart.js +83 -49
- package/dist/chart.js.map +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MAnimatedNumber.vue.d.ts +3 -1
- package/dist/components/MButton.vue.d.ts +9 -1
- package/dist/components/MButtonGroup.vue.d.ts +40 -31
- package/dist/components/MCarousel.vue.d.ts +2 -0
- package/dist/components/MChart.vue.d.ts +6 -0
- package/dist/components/MCircleProgressBar.vue.d.ts +5 -3
- package/dist/components/MContainerTransform.vue.d.ts +59 -0
- package/dist/components/MContextMenu.vue.d.ts +2 -2
- package/dist/components/MCopyButton.vue.d.ts +1 -1
- package/dist/components/MDialog.vue.d.ts +8 -5
- package/dist/components/MExportButton.vue.d.ts +1 -1
- package/dist/components/MFab.vue.d.ts +2 -2
- package/dist/components/MFabMenu.vue.d.ts +1 -1
- package/dist/components/MFlex.vue.d.ts +1 -1
- package/dist/components/MIconButton.vue.d.ts +15 -1
- package/dist/components/MInfiniteScroll.vue.d.ts +1 -1
- package/dist/components/MListItem.vue.d.ts +5 -5
- package/dist/components/MMap.vue.d.ts +20 -2
- package/dist/components/MMapBaseLayers.vue.d.ts +3 -0
- package/dist/components/MMapFilter.vue.d.ts +3 -0
- package/dist/components/MMapLayers.vue.d.ts +3 -0
- package/dist/components/MMenu.vue.d.ts +2 -2
- package/dist/components/MMenuItem.vue.d.ts +7 -3
- package/dist/components/MNavigationDrawer.vue.d.ts +13 -2
- package/dist/components/MNavigationRail.vue.d.ts +1 -1
- package/dist/components/MOverlay.vue.d.ts +12 -1
- package/dist/components/MProgressBar.vue.d.ts +5 -3
- package/dist/components/MPullToRefresh.vue.d.ts +7 -2
- package/dist/components/MRichTextEditor.vue.d.ts +7 -1
- package/dist/components/MSearchField.vue.d.ts +58 -0
- package/dist/components/MSegmentedButton.vue.d.ts +31 -23
- package/dist/components/MSimpleCarousel.vue.d.ts +2 -0
- package/dist/components/MSkeleton.vue.d.ts +6 -3
- package/dist/components/MSplitter.vue.d.ts +1 -1
- package/dist/components/MStack.vue.d.ts +1 -1
- package/dist/components/MSwipeToDismiss.vue.d.ts +1 -1
- package/dist/components/MSwitch.vue.d.ts +1 -1
- package/dist/components/MTextField.vue.d.ts +5 -1
- package/dist/components/MTimeline.vue.d.ts +85 -22
- package/dist/components/MToolbar.vue.d.ts +32 -5
- package/dist/components/MTooltip.vue.d.ts +1 -1
- package/dist/components/_MDrawerItemList.vue.d.ts +2 -0
- package/dist/components/_MToolbarFab.vue.d.ts +16 -0
- package/dist/composables/_containerTransform.d.ts +48 -0
- package/dist/composables/_mapStyle.d.ts +13 -0
- package/dist/composables/_themeTransition.d.ts +2 -0
- package/dist/composables/_tooltipTrigger.d.ts +22 -0
- package/dist/composables/_useMenuNav.d.ts +28 -0
- package/dist/composables/useAutoGrow.d.ts +21 -0
- package/dist/composables/useColorPalette.d.ts +1 -1
- package/dist/composables/useContainerTransform.d.ts +30 -0
- package/dist/composables/useLocale.d.ts +6 -0
- package/dist/composables/useMap.d.ts +19 -3
- package/dist/composables/useMapFilter.d.ts +4 -1
- package/dist/composables/useMapLayers.d.ts +5 -2
- package/dist/composables/useScrollReveal.d.ts +44 -0
- package/dist/composables/useThemeTokens.d.ts +21 -0
- package/dist/composables/viewportHints.d.ts +27 -0
- package/dist/directives/vClickOutside.d.ts +25 -0
- package/dist/directives/vFocusRing.d.ts +22 -0
- package/dist/directives/vLongPress.d.ts +27 -0
- package/dist/directives/vReveal.d.ts +10 -0
- package/dist/directives/vScrollElevation.d.ts +31 -0
- package/dist/directives/vSkeleton.d.ts +19 -0
- package/dist/directives/vStateLayer.d.ts +20 -0
- package/dist/directives/vSwipe.d.ts +45 -0
- package/dist/directives/vTooltip.d.ts +23 -0
- package/dist/index.d.ts +31 -1
- package/dist/locales/index.js +35 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +7692 -6273
- package/dist/m3ui.js.map +1 -1
- package/dist/map.d.ts +1 -1
- package/dist/map.js +823 -793
- package/dist/map.js.map +1 -1
- package/dist/motion-DZiXG09o.js +150 -0
- package/dist/motion-DZiXG09o.js.map +1 -0
- package/dist/plugin.d.ts +24 -0
- package/dist/rich-text-editor.js +20 -16
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles/theme.css +63 -0
- package/dist/styles.css +1 -1
- package/dist/{useLocale-SfQHnJfp.js → useLocale-JYxDDeXC.js} +6 -2
- package/dist/useLocale-JYxDDeXC.js.map +1 -0
- package/dist/useThemeTokens-Bv-Uv8eX.js +135 -0
- package/dist/useThemeTokens-Bv-Uv8eX.js.map +1 -0
- package/package.json +2 -1
- package/src/__tests__/MAnimatedNumber.test.ts +24 -2
- package/src/__tests__/MButton.test.ts +22 -0
- package/src/__tests__/MCarousel.test.ts +9 -0
- package/src/__tests__/MChart.test.ts +77 -5
- package/src/__tests__/MContainerTransform.test.ts +279 -0
- package/src/__tests__/MDialog.test.ts +27 -0
- package/src/__tests__/MIconButton.test.ts +33 -0
- package/src/__tests__/MListItemExpandable.test.ts +48 -0
- package/src/__tests__/MListItemShape.test.ts +9 -6
- package/src/__tests__/MListKeyboard.test.ts +90 -0
- package/src/__tests__/MMap.test.ts +53 -1
- package/src/__tests__/MMapLayers.test.ts +46 -2
- package/src/__tests__/MMapTools.test.ts +2 -1
- package/src/__tests__/MMenu.test.ts +104 -1
- package/src/__tests__/MMenuItem.test.ts +18 -0
- package/src/__tests__/MNavigationDrawer.test.ts +80 -0
- package/src/__tests__/MNavigationRail.test.ts +33 -0
- package/src/__tests__/MOverlay.test.ts +49 -0
- package/src/__tests__/MProgressBar.test.ts +41 -0
- package/src/__tests__/MPullToRefresh.test.ts +33 -0
- package/src/__tests__/MRichTextEditor.test.ts +22 -0
- package/src/__tests__/MSearchField.test.ts +71 -0
- package/src/__tests__/MSkeleton.test.ts +38 -0
- package/src/__tests__/MSlider.test.ts +161 -0
- package/src/__tests__/MTimeline.test.ts +238 -0
- package/src/__tests__/MToolbar.test.ts +157 -0
- package/src/__tests__/_fakeMaplibre.ts +3 -1
- package/src/__tests__/attrsFallthrough.test.ts +9 -0
- package/src/__tests__/escapeStack.test.ts +93 -0
- package/src/__tests__/hydration.test.ts +25 -0
- package/src/__tests__/ssr.test.ts +21 -2
- package/src/__tests__/useAutoGrow.test.ts +103 -0
- package/src/__tests__/useScrollReveal.test.ts +102 -0
- package/src/__tests__/useThemeTokens.test.ts +114 -0
- package/src/__tests__/vClickOutside.test.ts +82 -0
- package/src/__tests__/vFocusRing.test.ts +36 -0
- package/src/__tests__/vLongPress.test.ts +81 -0
- package/src/__tests__/vScrollElevation.test.ts +89 -0
- package/src/__tests__/vSkeleton.test.ts +48 -0
- package/src/__tests__/vStateLayer.test.ts +53 -0
- package/src/__tests__/vSwipe.test.ts +93 -0
- package/src/__tests__/vTooltip.test.ts +95 -0
- package/src/__tests__/viewportHints.test.ts +41 -0
- package/src/components/MAnimatedNumber.vue +32 -6
- package/src/components/MAutocomplete.vue +5 -0
- package/src/components/MBottomSheet.vue +4 -1
- package/src/components/MButton.vue +19 -3
- package/src/components/MButtonGroup.vue +22 -17
- package/src/components/MCarousel.vue +7 -1
- package/src/components/MChart.vue +74 -34
- package/src/components/MCircleProgressBar.vue +14 -9
- package/src/components/MCommandPalette.vue +3 -2
- package/src/components/MContainerTransform.vue +321 -0
- package/src/components/MContextMenu.vue +19 -60
- package/src/components/MDialog.vue +31 -6
- package/src/components/MDragDropList.vue +2 -0
- package/src/components/MFab.vue +10 -5
- package/src/components/MIconButton.vue +43 -2
- package/src/components/MKanban.vue +2 -0
- package/src/components/MLightbox.vue +7 -2
- package/src/components/MList.vue +26 -2
- package/src/components/MListItem.vue +138 -84
- package/src/components/MMap.vue +38 -5
- package/src/components/MMapBaseLayers.vue +7 -3
- package/src/components/MMapFilter.vue +7 -4
- package/src/components/MMapGeoJson.vue +1 -1
- package/src/components/MMapLayers.vue +6 -2
- package/src/components/MMapMeasure.vue +5 -2
- package/src/components/MMenu.vue +18 -59
- package/src/components/MMenuItem.vue +11 -2
- package/src/components/MMultiAutocomplete.vue +5 -0
- package/src/components/MNavigationDrawer.vue +96 -11
- package/src/components/MNavigationRail.vue +44 -25
- package/src/components/MOverlay.vue +32 -13
- package/src/components/MProgressBar.vue +25 -27
- package/src/components/MPullToRefresh.vue +20 -1
- package/src/components/MRichTextEditor.vue +19 -5
- package/src/components/MSearchBar.vue +5 -0
- package/src/components/MSearchField.vue +142 -0
- package/src/components/MSegmentedButton.vue +19 -17
- package/src/components/MSelect.vue +10 -1
- package/src/components/MSideSheet.vue +5 -2
- package/src/components/MSimpleCarousel.vue +10 -1
- package/src/components/MSkeleton.vue +30 -8
- package/src/components/MSlider.vue +161 -42
- package/src/components/MSpotlightSearch.vue +3 -2
- package/src/components/MTextField.vue +15 -2
- package/src/components/MTimeline.vue +370 -81
- package/src/components/MToolbar.vue +256 -15
- package/src/components/MTooltip.vue +20 -152
- package/src/components/_MDrawerItemList.vue +25 -6
- package/src/components/_MToolbarFab.vue +14 -0
- package/src/composables/_containerTransform.ts +179 -0
- package/src/composables/_mapStyle.ts +45 -0
- package/src/composables/_themeTransition.ts +2 -0
- package/src/composables/_tooltipTrigger.ts +184 -0
- package/src/composables/_useEscapeStack.ts +2 -0
- package/src/composables/_useMenuNav.ts +209 -0
- package/src/composables/useAutoGrow.ts +78 -0
- package/src/composables/useContainerTransform.ts +59 -0
- package/src/composables/useLocale.ts +10 -0
- package/src/composables/useMap.ts +43 -5
- package/src/composables/useMapFilter.ts +6 -5
- package/src/composables/useMapLayers.ts +7 -6
- package/src/composables/useScrollReveal.ts +151 -0
- package/src/composables/useThemeTokens.ts +116 -0
- package/src/composables/viewportHints.ts +80 -0
- package/src/directives/vClickOutside.ts +90 -0
- package/src/directives/vFocusRing.ts +60 -0
- package/src/directives/vLongPress.ts +134 -0
- package/src/directives/vReveal.ts +57 -0
- package/src/directives/vScrollElevation.ts +116 -0
- package/src/directives/vSkeleton.ts +87 -0
- package/src/directives/vStateLayer.ts +83 -0
- package/src/directives/vSwipe.ts +197 -0
- package/src/directives/vTooltip.ts +128 -0
- package/src/index.ts +31 -1
- package/src/locales/de.ts +4 -0
- package/src/locales/es.ts +4 -0
- package/src/locales/fr.ts +4 -0
- package/src/locales/ja.ts +4 -0
- package/src/locales/ko.ts +4 -0
- package/src/locales/pt.ts +4 -0
- package/src/locales/zh.ts +4 -0
- package/src/map.ts +1 -1
- package/src/plugin.ts +34 -0
- package/src/styles/theme.css +63 -0
- package/dist/MMenuItem-BckcR0nW.js +0 -809
- package/dist/MMenuItem-BckcR0nW.js.map +0 -1
- package/dist/MSlider-LyH_gy8D.js +0 -1411
- package/dist/MSlider-LyH_gy8D.js.map +0 -1
- package/dist/MTextField-FCPOTB0o.js +0 -672
- package/dist/MTextField-FCPOTB0o.js.map +0 -1
- package/dist/composables/_useThemeTokens.d.ts +0 -7
- package/dist/useLocale-SfQHnJfp.js.map +0 -1
- package/src/composables/_useThemeTokens.ts +0 -42
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
/**
|
|
3
3
|
* A container for grouping icon buttons and actions — docked to an edge or floating as a rounded pill,
|
|
4
|
-
* horizontal or vertical, with an optional paired FAB.
|
|
4
|
+
* horizontal or vertical, with an optional paired FAB. A floating toolbar collapses (`v-model:expanded`): with a
|
|
5
|
+
* FAB, into the FAB, which grows to 80px; without one, to its center (the default slot), closing `#leading` and
|
|
6
|
+
* `#trailing`. `collapseOnScroll` does it as the content scrolls.
|
|
5
7
|
*
|
|
6
|
-
* @slot fab A FAB rendered alongside the toolbar body, positioned by fabPosition
|
|
7
|
-
* @slot default Toolbar items — typically MIconButton/MButton, separated with MDivider
|
|
8
|
+
* @slot fab A FAB rendered alongside the toolbar body, positioned by fabPosition. The toolbar sizes an MFab in it
|
|
9
|
+
* @slot default Toolbar items — typically MIconButton/MButton, separated with MDivider. With #leading or #trailing,
|
|
10
|
+
* the center, which stays when a floating toolbar without a FAB collapses
|
|
11
|
+
* @slot leading Items before the center, hidden when a floating toolbar without a FAB collapses
|
|
12
|
+
* @slot trailing Items after the center, hidden when a floating toolbar without a FAB collapses
|
|
13
|
+
* @event update:expanded The toolbar collapsed or expanded on scroll (`collapseOnScroll`)
|
|
8
14
|
*/
|
|
9
|
-
import { computed } from 'vue'
|
|
15
|
+
import { computed, onMounted, onUnmounted, onUpdated, ref, useSlots, watch } from 'vue'
|
|
16
|
+
import { motionSprings } from '../composables/motion'
|
|
17
|
+
import MToolbarFab from './_MToolbarFab.vue'
|
|
10
18
|
|
|
11
19
|
const props = withDefaults(defineProps<{
|
|
12
20
|
/** Docked (edge-attached, full width/height, bordered) or floating (rounded pill with shadow) */
|
|
@@ -19,14 +27,25 @@ const props = withDefaults(defineProps<{
|
|
|
19
27
|
fabPosition?: 'start' | 'end' | 'none'
|
|
20
28
|
/** Item alignment along the main axis */
|
|
21
29
|
align?: 'start' | 'center' | 'end' | 'between'
|
|
30
|
+
/**
|
|
31
|
+
* Collapse a floating toolbar as the content scrolls down and expand it as it scrolls back up (40px each way):
|
|
32
|
+
* `true` follows the window, or pass the scrolling element (or a CSS selector for it). Off by default
|
|
33
|
+
*/
|
|
34
|
+
collapseOnScroll?: boolean | string | HTMLElement | null
|
|
22
35
|
}>(), {
|
|
23
36
|
variant: 'docked',
|
|
24
37
|
orientation: 'horizontal',
|
|
25
38
|
color: 'surface',
|
|
26
39
|
fabPosition: 'none',
|
|
27
40
|
align: 'center',
|
|
41
|
+
collapseOnScroll: false,
|
|
28
42
|
})
|
|
29
43
|
|
|
44
|
+
/** A floating toolbar's state: collapsed, it shows only the FAB, or only its center without one. Default `true` */
|
|
45
|
+
const expanded = defineModel<boolean>('expanded', { default: true })
|
|
46
|
+
|
|
47
|
+
const slots = useSlots()
|
|
48
|
+
|
|
30
49
|
const colorClasses = computed(() => {
|
|
31
50
|
const map: Record<string, string> = {
|
|
32
51
|
surface: 'bg-surface-container text-on-surface',
|
|
@@ -48,6 +67,167 @@ const alignClass = computed(() => {
|
|
|
48
67
|
})
|
|
49
68
|
|
|
50
69
|
const isVertical = computed(() => props.orientation === 'vertical')
|
|
70
|
+
const floating = computed(() => props.variant === 'floating')
|
|
71
|
+
const hasFab = computed(() => !!slots.fab && props.fabPosition !== 'none')
|
|
72
|
+
// A floating toolbar with a FAB collapses into it; one without, to its center
|
|
73
|
+
const fabMode = computed(() => floating.value && hasFab.value)
|
|
74
|
+
const sections = computed(() => !!(slots.leading || slots.trailing))
|
|
75
|
+
const collapsible = computed(() => floating.value && (hasFab.value || sections.value))
|
|
76
|
+
// The standard floating toolbar's FAB is PrimaryContainer, the vibrant one's TertiaryContainer
|
|
77
|
+
const fabColor = computed(() => (props.color === 'surface' ? 'primary' : 'tertiary'))
|
|
78
|
+
// What a collapsed toolbar hides is out of reach for keyboard and assistive technology
|
|
79
|
+
const hidden = computed(() => collapsible.value && !expanded.value)
|
|
80
|
+
|
|
81
|
+
// ── Collapse: one spring (FloatingToolbarDefaults.animationSpec = Expressive FastSpatial) for the progress, in a
|
|
82
|
+
// rAF loop that writes sizes (layout, so not a Web Animation). Like Compose: with a FAB, the toolbar keeps its
|
|
83
|
+
// footprint and clips toward the FAB, which grows from 56 to 80dp; without, #leading/#trailing shrink toward the
|
|
84
|
+
// center. Settled expanded, every size is left to the layout (style cleared), so content changes reflow normally.
|
|
85
|
+
const FAB_MIN = 56
|
|
86
|
+
const FAB_MAX = 80
|
|
87
|
+
const region = ref<HTMLElement>()
|
|
88
|
+
const body = ref<HTMLElement>()
|
|
89
|
+
const inner = ref<HTMLElement>()
|
|
90
|
+
const fabBox = ref<HTMLElement>()
|
|
91
|
+
const leadClip = ref<HTMLElement>()
|
|
92
|
+
const leadInner = ref<HTMLElement>()
|
|
93
|
+
const trailClip = ref<HTMLElement>()
|
|
94
|
+
const trailInner = ref<HTMLElement>()
|
|
95
|
+
|
|
96
|
+
let progress = expanded.value ? 1 : 0
|
|
97
|
+
let velocity = 0
|
|
98
|
+
let raf = 0
|
|
99
|
+
let last = 0
|
|
100
|
+
let full = 0
|
|
101
|
+
let lead = 0
|
|
102
|
+
let trail = 0
|
|
103
|
+
const reduceMotion = () => typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
104
|
+
const size = () => (isVertical.value ? 'height' : 'width')
|
|
105
|
+
const measure = (el?: HTMLElement) => (el ? (isVertical.value ? el.offsetHeight : el.offsetWidth) : 0)
|
|
106
|
+
|
|
107
|
+
function write() {
|
|
108
|
+
const settled = !raf
|
|
109
|
+
const p = Math.max(0, progress)
|
|
110
|
+
const axis = size()
|
|
111
|
+
const open = settled && progress === 1
|
|
112
|
+
if (fabMode.value) {
|
|
113
|
+
if (region.value) region.value.style[axis] = open ? '' : `${full}px`
|
|
114
|
+
if (body.value) body.value.style[axis] = open ? '' : `${full * p}px`
|
|
115
|
+
const fab = Math.max(0, FAB_MIN + (FAB_MAX - FAB_MIN) * (1 - progress))
|
|
116
|
+
if (fabBox.value) {
|
|
117
|
+
fabBox.value.style.width = `${fab}px`
|
|
118
|
+
fabBox.value.style.height = `${fab}px`
|
|
119
|
+
}
|
|
120
|
+
} else if (floating.value) {
|
|
121
|
+
if (leadClip.value) leadClip.value.style[axis] = open ? '' : `${lead * p}px`
|
|
122
|
+
if (trailClip.value) trailClip.value.style[axis] = open ? '' : `${trail * p}px`
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function frame(now: number) {
|
|
127
|
+
let dt = Math.min((now - last) / 1000, 1 / 30)
|
|
128
|
+
last = now
|
|
129
|
+
const { stiffness: k, dampingRatio } = motionSprings.expressive.fastSpatial
|
|
130
|
+
const c = 2 * dampingRatio * Math.sqrt(k)
|
|
131
|
+
const target = expanded.value ? 1 : 0
|
|
132
|
+
while (dt > 0) {
|
|
133
|
+
const h = Math.min(dt, 0.004)
|
|
134
|
+
dt -= h
|
|
135
|
+
velocity += (-k * (progress - target) - c * velocity) * h
|
|
136
|
+
progress += velocity * h
|
|
137
|
+
}
|
|
138
|
+
if (Math.abs(progress - target) < 0.001 && Math.abs(velocity) < 0.01) {
|
|
139
|
+
progress = target
|
|
140
|
+
velocity = 0
|
|
141
|
+
raf = 0
|
|
142
|
+
} else raf = requestAnimationFrame(frame)
|
|
143
|
+
write()
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function animate() {
|
|
147
|
+
// Natural sizes, read while every size is still the layout's (expanded) or from the unclipped inner content
|
|
148
|
+
full = measure(inner.value)
|
|
149
|
+
lead = measure(leadInner.value)
|
|
150
|
+
trail = measure(trailInner.value)
|
|
151
|
+
if (!collapsible.value || reduceMotion()) {
|
|
152
|
+
cancelAnimationFrame(raf)
|
|
153
|
+
raf = 0
|
|
154
|
+
progress = expanded.value ? 1 : 0
|
|
155
|
+
velocity = 0
|
|
156
|
+
write()
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
if (!raf) {
|
|
160
|
+
last = performance.now()
|
|
161
|
+
raf = requestAnimationFrame(frame)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
watch(expanded, animate)
|
|
166
|
+
onMounted(() => {
|
|
167
|
+
full = measure(inner.value)
|
|
168
|
+
lead = measure(leadInner.value)
|
|
169
|
+
trail = measure(trailInner.value)
|
|
170
|
+
write()
|
|
171
|
+
})
|
|
172
|
+
// A re-render (new items) may change the natural sizes: a collapsed toolbar keeps the new ones
|
|
173
|
+
onUpdated(() => {
|
|
174
|
+
if (raf || progress === 1) return
|
|
175
|
+
full = measure(inner.value)
|
|
176
|
+
lead = measure(leadInner.value)
|
|
177
|
+
trail = measure(trailInner.value)
|
|
178
|
+
write()
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
// ── collapseOnScroll: Compose's floatingToolbarVerticalNestedScroll. The content's offset (minus the scroll
|
|
182
|
+
// position) is compared with a threshold 40dp behind the last switch, so small back-and-forth scrolls don't flicker.
|
|
183
|
+
const SCROLL_THRESHOLD = 40
|
|
184
|
+
let scroller: HTMLElement | Window | null = null
|
|
185
|
+
let lastTop = 0
|
|
186
|
+
let threshold = 0
|
|
187
|
+
const scrollTop = () => (!scroller ? 0 : scroller === window ? window.scrollY : (scroller as HTMLElement).scrollTop)
|
|
188
|
+
const resetThreshold = () => (threshold = -lastTop + (expanded.value ? -SCROLL_THRESHOLD : SCROLL_THRESHOLD))
|
|
189
|
+
|
|
190
|
+
function onScroll() {
|
|
191
|
+
const top = scrollTop()
|
|
192
|
+
const delta = lastTop - top
|
|
193
|
+
lastTop = top
|
|
194
|
+
const offset = -top
|
|
195
|
+
if (delta < 0 && offset <= threshold) {
|
|
196
|
+
threshold = offset + SCROLL_THRESHOLD
|
|
197
|
+
expanded.value = false
|
|
198
|
+
} else if (delta > 0 && offset >= threshold) {
|
|
199
|
+
threshold = offset - SCROLL_THRESHOLD
|
|
200
|
+
expanded.value = true
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function attachScroll() {
|
|
205
|
+
scroller?.removeEventListener('scroll', onScroll)
|
|
206
|
+
scroller = null
|
|
207
|
+
const target = props.collapseOnScroll
|
|
208
|
+
if (!target || typeof window === 'undefined') return
|
|
209
|
+
scroller = target === true ? window : typeof target === 'string' ? document.querySelector<HTMLElement>(target) : target
|
|
210
|
+
if (!scroller) return
|
|
211
|
+
scroller.addEventListener('scroll', onScroll, { passive: true })
|
|
212
|
+
lastTop = scrollTop()
|
|
213
|
+
resetThreshold()
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
onMounted(() => {
|
|
217
|
+
attachScroll()
|
|
218
|
+
watch(() => props.collapseOnScroll, attachScroll)
|
|
219
|
+
// Expanded or collapsed some other way (the FAB): scrolling switches it again from here
|
|
220
|
+
watch(expanded, resetThreshold)
|
|
221
|
+
})
|
|
222
|
+
onUnmounted(() => {
|
|
223
|
+
cancelAnimationFrame(raf)
|
|
224
|
+
scroller?.removeEventListener('scroll', onScroll)
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
// Starting sizes for the server render and the first paint, set once (the loop writes them from then on)
|
|
228
|
+
const startCollapsed = !expanded.value
|
|
229
|
+
const fabStart = { width: `${startCollapsed ? FAB_MAX : FAB_MIN}px`, height: `${startCollapsed ? FAB_MAX : FAB_MIN}px` }
|
|
230
|
+
const clipStart = startCollapsed ? { [props.orientation === 'vertical' ? 'height' : 'width']: '0px' } : {}
|
|
51
231
|
</script>
|
|
52
232
|
|
|
53
233
|
<template>
|
|
@@ -55,35 +235,96 @@ const isVertical = computed(() => props.orientation === 'vertical')
|
|
|
55
235
|
class="flex items-center gap-2"
|
|
56
236
|
:class="[
|
|
57
237
|
isVertical ? 'flex-col' : 'flex-row',
|
|
58
|
-
|
|
59
|
-
fabPosition === 'start' && isVertical ? 'flex-col' : '',
|
|
238
|
+
fabMode ? (isVertical ? 'min-w-20' : 'min-h-20') : '',
|
|
60
239
|
]"
|
|
61
240
|
>
|
|
62
241
|
<!-- FAB start -->
|
|
63
|
-
<div v-if="
|
|
64
|
-
<
|
|
242
|
+
<div v-if="hasFab && fabPosition === 'start'" class="relative size-14 shrink-0">
|
|
243
|
+
<div ref="fabBox" class="absolute" :class="isVertical ? 'top-0 left-1/2 -translate-x-1/2' : 'left-0 top-1/2 -translate-y-1/2'" :style="fabStart">
|
|
244
|
+
<MToolbarFab :color="fabColor"><slot name="fab" /></MToolbarFab>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
|
|
248
|
+
<!-- Floating with a FAB: the pill clips toward the FAB inside a region that keeps the toolbar's footprint -->
|
|
249
|
+
<div
|
|
250
|
+
v-if="fabMode"
|
|
251
|
+
ref="region"
|
|
252
|
+
class="flex shrink-0"
|
|
253
|
+
:class="[isVertical ? 'flex-col' : 'flex-row', fabPosition === 'end' ? 'justify-end' : 'justify-start']"
|
|
254
|
+
>
|
|
255
|
+
<div
|
|
256
|
+
ref="body"
|
|
257
|
+
class="overflow-hidden rounded-full shadow-elevation-1"
|
|
258
|
+
:class="[isVertical ? 'w-16' : 'h-16', colorClasses]"
|
|
259
|
+
:style="clipStart"
|
|
260
|
+
:inert="hidden || undefined"
|
|
261
|
+
>
|
|
262
|
+
<div
|
|
263
|
+
ref="inner"
|
|
264
|
+
class="flex shrink-0 items-center gap-1"
|
|
265
|
+
:class="[isVertical ? 'h-max w-16 flex-col py-2' : 'h-16 w-max flex-row px-2', alignClass]"
|
|
266
|
+
>
|
|
267
|
+
<slot name="leading" />
|
|
268
|
+
<slot />
|
|
269
|
+
<slot name="trailing" />
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
65
272
|
</div>
|
|
66
273
|
|
|
67
274
|
<!-- Toolbar body -->
|
|
68
275
|
<div
|
|
69
|
-
|
|
276
|
+
v-else
|
|
277
|
+
class="flex items-center"
|
|
70
278
|
:class="[
|
|
279
|
+
sections ? '' : 'gap-1',
|
|
71
280
|
isVertical ? 'flex-col w-16' : 'flex-row h-16',
|
|
72
|
-
isVertical ? (
|
|
281
|
+
isVertical ? (floating ? 'py-2' : 'py-4') : (floating ? 'px-2' : 'px-4'),
|
|
73
282
|
alignClass,
|
|
74
283
|
colorClasses,
|
|
75
|
-
|
|
76
|
-
|
|
284
|
+
floating ? 'rounded-full' : '',
|
|
285
|
+
floating && hasFab ? 'shadow-elevation-1' : '',
|
|
77
286
|
variant === 'docked' ? 'w-full border-t border-outline-variant' : '',
|
|
78
287
|
variant === 'docked' && isVertical ? 'h-full w-16 border-t-0 border-r border-outline-variant' : '',
|
|
79
288
|
]"
|
|
80
289
|
>
|
|
81
|
-
<
|
|
290
|
+
<template v-if="sections">
|
|
291
|
+
<!-- Each side closes toward the center: its content is anchored to the center-facing edge -->
|
|
292
|
+
<div
|
|
293
|
+
v-if="$slots.leading"
|
|
294
|
+
ref="leadClip"
|
|
295
|
+
class="flex shrink-0 overflow-hidden"
|
|
296
|
+
:class="isVertical ? 'flex-col justify-end' : 'flex-row justify-end'"
|
|
297
|
+
:style="floating ? clipStart : undefined"
|
|
298
|
+
:inert="hidden || undefined"
|
|
299
|
+
>
|
|
300
|
+
<div ref="leadInner" class="flex shrink-0 items-center gap-1" :class="isVertical ? 'flex-col pb-1' : 'flex-row pe-1'">
|
|
301
|
+
<slot name="leading" />
|
|
302
|
+
</div>
|
|
303
|
+
</div>
|
|
304
|
+
<div class="flex items-center gap-1" :class="isVertical ? 'flex-col' : 'flex-row'">
|
|
305
|
+
<slot />
|
|
306
|
+
</div>
|
|
307
|
+
<div
|
|
308
|
+
v-if="$slots.trailing"
|
|
309
|
+
ref="trailClip"
|
|
310
|
+
class="flex shrink-0 overflow-hidden"
|
|
311
|
+
:class="isVertical ? 'flex-col justify-start' : 'flex-row justify-start'"
|
|
312
|
+
:style="floating ? clipStart : undefined"
|
|
313
|
+
:inert="hidden || undefined"
|
|
314
|
+
>
|
|
315
|
+
<div ref="trailInner" class="flex shrink-0 items-center gap-1" :class="isVertical ? 'flex-col pt-1' : 'flex-row ps-1'">
|
|
316
|
+
<slot name="trailing" />
|
|
317
|
+
</div>
|
|
318
|
+
</div>
|
|
319
|
+
</template>
|
|
320
|
+
<slot v-else />
|
|
82
321
|
</div>
|
|
83
322
|
|
|
84
323
|
<!-- FAB end -->
|
|
85
|
-
<div v-if="
|
|
86
|
-
<
|
|
324
|
+
<div v-if="hasFab && fabPosition === 'end'" class="relative size-14 shrink-0">
|
|
325
|
+
<div ref="fabBox" class="absolute" :class="isVertical ? 'bottom-0 left-1/2 -translate-x-1/2' : 'right-0 top-1/2 -translate-y-1/2'" :style="fabStart">
|
|
326
|
+
<MToolbarFab :color="fabColor"><slot name="fab" /></MToolbarFab>
|
|
327
|
+
</div>
|
|
87
328
|
</div>
|
|
88
329
|
</div>
|
|
89
330
|
</template>
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @slot actions Rich-tooltip action buttons row (only used when rich is true)
|
|
9
9
|
*/
|
|
10
10
|
import { nextTick, onMounted, onUnmounted, ref } from 'vue'
|
|
11
|
+
import { createTooltipTrigger, placeTooltip } from '../composables/_tooltipTrigger'
|
|
11
12
|
|
|
12
13
|
defineOptions({ inheritAttrs: false })
|
|
13
14
|
|
|
@@ -29,166 +30,41 @@ const visible = ref(false)
|
|
|
29
30
|
const tipEl = ref<HTMLElement>()
|
|
30
31
|
const triggerEl = ref<HTMLElement>()
|
|
31
32
|
const tipStyle = ref<Record<string, string>>({})
|
|
32
|
-
let showTimer: ReturnType<typeof setTimeout> | null = null
|
|
33
|
-
let hideTimer: ReturnType<typeof setTimeout> | null = null
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (hideTimer) { clearTimeout(hideTimer); hideTimer = null }
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function show() {
|
|
41
|
-
cancelTimers()
|
|
42
|
-
showTimer = setTimeout(async () => {
|
|
43
|
-
visible.value = true
|
|
44
|
-
await nextTick()
|
|
45
|
-
reposition()
|
|
46
|
-
}, props.delay)
|
|
47
|
-
}
|
|
34
|
+
// Hover, long press, keyboard focus, Escape and scroll: see _tooltipTrigger.ts (shared with v-tooltip)
|
|
35
|
+
let trigger: ReturnType<typeof createTooltipTrigger> | undefined
|
|
48
36
|
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
} else {
|
|
54
|
-
visible.value = false
|
|
55
|
-
}
|
|
37
|
+
async function open() {
|
|
38
|
+
visible.value = true
|
|
39
|
+
await nextTick()
|
|
40
|
+
reposition()
|
|
56
41
|
}
|
|
57
42
|
|
|
58
43
|
function onTipEnter() {
|
|
59
|
-
if (
|
|
60
|
-
cancelTimers()
|
|
44
|
+
if (props.rich) trigger?.cancel()
|
|
61
45
|
}
|
|
62
46
|
|
|
63
47
|
function onTipLeave() {
|
|
64
|
-
if (
|
|
65
|
-
cancelTimers()
|
|
66
|
-
visible.value = false
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Input as Compose's BasicTooltip: a mouse shows it on hover; touch and pen on a long press, which also swallows
|
|
70
|
-
// the click it would end in (a long-pressed button doesn't fire) and hides it TOUCH_DURATION after the finger
|
|
71
|
-
// lifts (BasicTooltipDefaults.TooltipDuration); focus only from the keyboard. Before, the mouse events a browser
|
|
72
|
-
// emulates for a tap (and the focus a tap gives a button) showed it on every tap, and it stuck around.
|
|
73
|
-
const LONG_PRESS = 500
|
|
74
|
-
const TOUCH_DURATION = 1500
|
|
75
|
-
let press: { id: number; x: number; y: number; timer: ReturnType<typeof setTimeout> } | null = null
|
|
76
|
-
let longPressed = false
|
|
77
|
-
|
|
78
|
-
function onPointerEnter(e: PointerEvent) {
|
|
79
|
-
if (e.pointerType === 'mouse') show()
|
|
80
|
-
}
|
|
81
|
-
function onPointerLeave(e: PointerEvent) {
|
|
82
|
-
if (e.pointerType === 'mouse') hide()
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function endPress() {
|
|
86
|
-
if (press) clearTimeout(press.timer)
|
|
87
|
-
press = null
|
|
88
|
-
window.removeEventListener('pointermove', onPressMove)
|
|
89
|
-
window.removeEventListener('pointerup', onPressUp)
|
|
90
|
-
window.removeEventListener('pointercancel', onPressCancel)
|
|
91
|
-
}
|
|
92
|
-
function onPointerDown(e: PointerEvent) {
|
|
93
|
-
if (e.pointerType === 'mouse') return
|
|
94
|
-
endPress()
|
|
95
|
-
longPressed = false
|
|
96
|
-
press = {
|
|
97
|
-
id: e.pointerId,
|
|
98
|
-
x: e.clientX,
|
|
99
|
-
y: e.clientY,
|
|
100
|
-
timer: setTimeout(async () => {
|
|
101
|
-
longPressed = true
|
|
102
|
-
cancelTimers()
|
|
103
|
-
visible.value = true
|
|
104
|
-
await nextTick()
|
|
105
|
-
reposition()
|
|
106
|
-
}, LONG_PRESS),
|
|
107
|
-
}
|
|
108
|
-
window.addEventListener('pointermove', onPressMove)
|
|
109
|
-
window.addEventListener('pointerup', onPressUp)
|
|
110
|
-
window.addEventListener('pointercancel', onPressCancel)
|
|
111
|
-
}
|
|
112
|
-
function onPressMove(e: PointerEvent) {
|
|
113
|
-
if (press && e.pointerId === press.id && Math.hypot(e.clientX - press.x, e.clientY - press.y) > 10) endPress()
|
|
114
|
-
}
|
|
115
|
-
function onPressUp(e: PointerEvent) {
|
|
116
|
-
if (!press || e.pointerId !== press.id) return
|
|
117
|
-
endPress()
|
|
118
|
-
if (!longPressed) return
|
|
119
|
-
cancelTimers()
|
|
120
|
-
// A rich tooltip may hold actions to tap: it stays until a touch outside it (Compose's persistent tooltips)
|
|
121
|
-
if (props.rich) document.addEventListener('pointerdown', onOutsideTouch, true)
|
|
122
|
-
else hideTimer = setTimeout(() => { visible.value = false }, TOUCH_DURATION)
|
|
123
|
-
}
|
|
124
|
-
function onOutsideTouch(e: PointerEvent) {
|
|
125
|
-
const t = e.target as Node
|
|
126
|
-
if (tipEl.value?.contains(t) || triggerEl.value?.contains(t)) return
|
|
127
|
-
document.removeEventListener('pointerdown', onOutsideTouch, true)
|
|
128
|
-
visible.value = false
|
|
129
|
-
}
|
|
130
|
-
// The browser took the touch (a scroll)
|
|
131
|
-
function onPressCancel(e: PointerEvent) {
|
|
132
|
-
if (!press || e.pointerId !== press.id) return
|
|
133
|
-
endPress()
|
|
134
|
-
if (longPressed) hide()
|
|
135
|
-
}
|
|
136
|
-
// The click a long press ends in, and the context menu it may open, belong to the tooltip
|
|
137
|
-
function onClickCapture(e: MouseEvent) {
|
|
138
|
-
if (!longPressed) return
|
|
139
|
-
longPressed = false
|
|
140
|
-
e.preventDefault()
|
|
141
|
-
e.stopPropagation()
|
|
142
|
-
}
|
|
143
|
-
function onContextMenu(e: Event) {
|
|
144
|
-
if (press || longPressed) e.preventDefault()
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function onFocusIn(e: FocusEvent) {
|
|
148
|
-
let keyboard = true
|
|
149
|
-
try { keyboard = (e.target as Element).matches(':focus-visible') } catch { /* no :focus-visible: show */ }
|
|
150
|
-
if (keyboard) show()
|
|
151
|
-
}
|
|
152
|
-
function onKeyDown(e: KeyboardEvent) {
|
|
153
|
-
if (e.key === 'Escape' && visible.value) {
|
|
154
|
-
cancelTimers()
|
|
155
|
-
visible.value = false
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function onScroll() {
|
|
160
|
-
if (visible.value) {
|
|
161
|
-
cancelTimers()
|
|
162
|
-
visible.value = false
|
|
163
|
-
}
|
|
48
|
+
if (props.rich) trigger?.closeNow()
|
|
164
49
|
}
|
|
165
50
|
|
|
166
51
|
function reposition() {
|
|
167
52
|
if (!triggerEl.value || !tipEl.value) return
|
|
168
|
-
const
|
|
169
|
-
const tt = tipEl.value.getBoundingClientRect()
|
|
170
|
-
const GAP = 4
|
|
171
|
-
|
|
172
|
-
let top = 0, left = 0
|
|
173
|
-
switch (props.placement) {
|
|
174
|
-
case 'top': top = tr.top - tt.height - GAP; left = tr.left + (tr.width - tt.width) / 2; break
|
|
175
|
-
case 'bottom': top = tr.bottom + GAP; left = tr.left + (tr.width - tt.width) / 2; break
|
|
176
|
-
case 'left': top = tr.top + (tr.height - tt.height) / 2; left = tr.left - tt.width - GAP; break
|
|
177
|
-
case 'right': top = tr.top + (tr.height - tt.height) / 2; left = tr.right + GAP; break
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
top = Math.max(6, Math.min(top, window.innerHeight - tt.height - 6))
|
|
181
|
-
left = Math.max(6, Math.min(left, window.innerWidth - tt.width - 6))
|
|
53
|
+
const { top, left } = placeTooltip(triggerEl.value, tipEl.value, props.placement)
|
|
182
54
|
tipStyle.value = { top: `${top}px`, left: `${left}px` }
|
|
183
55
|
}
|
|
184
56
|
|
|
185
|
-
onMounted(() =>
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
57
|
+
onMounted(() => {
|
|
58
|
+
trigger = createTooltipTrigger(triggerEl.value!, {
|
|
59
|
+
delay: () => props.delay,
|
|
60
|
+
rich: () => props.rich,
|
|
61
|
+
visible: () => visible.value,
|
|
62
|
+
open,
|
|
63
|
+
close: () => { visible.value = false },
|
|
64
|
+
tip: () => tipEl.value,
|
|
65
|
+
})
|
|
191
66
|
})
|
|
67
|
+
onUnmounted(() => trigger?.destroy())
|
|
192
68
|
</script>
|
|
193
69
|
|
|
194
70
|
<template>
|
|
@@ -196,14 +72,6 @@ onUnmounted(() => {
|
|
|
196
72
|
ref="triggerEl"
|
|
197
73
|
v-bind="$attrs"
|
|
198
74
|
class="inline-flex"
|
|
199
|
-
@pointerenter="onPointerEnter"
|
|
200
|
-
@pointerleave="onPointerLeave"
|
|
201
|
-
@pointerdown="onPointerDown"
|
|
202
|
-
@click.capture="onClickCapture"
|
|
203
|
-
@contextmenu="onContextMenu"
|
|
204
|
-
@focusin="onFocusIn"
|
|
205
|
-
@focusout="hide"
|
|
206
|
-
@keydown="onKeyDown"
|
|
207
75
|
>
|
|
208
76
|
<slot />
|
|
209
77
|
</span>
|
|
@@ -16,7 +16,9 @@ export default defineComponent({
|
|
|
16
16
|
const toggleItem = inject<(item: DrawerItem) => void>('nd-toggle-item')!
|
|
17
17
|
const selectItem = inject<(item: DrawerItem) => void>('nd-select-item')!
|
|
18
18
|
const collapsed = inject<Ref<boolean>>('nd-collapsed')!
|
|
19
|
-
|
|
19
|
+
const rail = inject<Ref<boolean>>('nd-rail')!
|
|
20
|
+
const collapsedLabels = inject<Ref<boolean>>('nd-collapsed-labels')!
|
|
21
|
+
return { openItems, toggleItem, selectItem, collapsed, rail, collapsedLabels }
|
|
20
22
|
},
|
|
21
23
|
methods: {
|
|
22
24
|
itemTag(item: DrawerItem) {
|
|
@@ -28,6 +30,12 @@ export default defineComponent({
|
|
|
28
30
|
},
|
|
29
31
|
itemStyle(item: DrawerItem): Record<string, string> {
|
|
30
32
|
const transition = 'padding 300ms cubic-bezier(0.2, 0, 0, 1)'
|
|
33
|
+
if (this.rail) {
|
|
34
|
+
// Same 56px rail item as the top level: icon centered in the 56×32 pill, label below at 40px
|
|
35
|
+
const side = `${(56 - this.iSize(item)) / 2}px`
|
|
36
|
+
const top = (32 - this.iSize(item)) / 2 + 4
|
|
37
|
+
return { paddingLeft: side, paddingRight: side, paddingTop: `${top}px`, paddingBottom: `${56 - top - this.iSize(item)}px`, transition }
|
|
38
|
+
}
|
|
31
39
|
if (this.collapsed) {
|
|
32
40
|
const pad = `${(48 - this.iSize(item)) / 2}px`
|
|
33
41
|
return { paddingLeft: pad, paddingRight: pad, transition }
|
|
@@ -69,20 +77,26 @@ export default defineComponent({
|
|
|
69
77
|
:to="item.to && !item.disabled ? item.to : undefined"
|
|
70
78
|
:type="item.to ? undefined : 'button'"
|
|
71
79
|
:title="collapsed ? item.label : undefined"
|
|
72
|
-
class="flex w-full shrink-0 items-center gap-2.5 overflow-hidden whitespace-nowrap
|
|
80
|
+
class="relative flex w-full shrink-0 items-center gap-2.5 overflow-hidden whitespace-nowrap text-left transition-colors focus-visible:outline-none"
|
|
73
81
|
:class="[
|
|
74
|
-
item.py ?? 'py-1.5',
|
|
82
|
+
rail ? '' : ['rounded-full', item.py ?? 'py-1.5'],
|
|
75
83
|
item.disabled
|
|
76
84
|
? 'cursor-not-allowed opacity-[0.38]'
|
|
77
85
|
: item.value === selected
|
|
78
|
-
? 'bg-secondary-container text-on-secondary-container'
|
|
79
|
-
: 'cursor-pointer text-on-surface-variant hover:bg-on-surface/8',
|
|
86
|
+
? rail ? 'text-on-secondary-container' : 'bg-secondary-container text-on-secondary-container'
|
|
87
|
+
: rail ? 'group cursor-pointer text-on-surface-variant' : 'cursor-pointer text-on-surface-variant hover:bg-on-surface/8',
|
|
80
88
|
]"
|
|
81
89
|
:style="itemStyle(item)"
|
|
82
90
|
:disabled="item.disabled && !item.to"
|
|
83
91
|
@click="onClick(item)"
|
|
84
92
|
>
|
|
85
|
-
<
|
|
93
|
+
<span
|
|
94
|
+
v-if="rail"
|
|
95
|
+
aria-hidden="true"
|
|
96
|
+
class="pointer-events-none absolute left-0 top-1 h-8 w-14 rounded-full transition-colors"
|
|
97
|
+
:class="item.value === selected && !item.disabled ? 'bg-secondary-container' : 'group-hover:bg-on-surface/8'"
|
|
98
|
+
/>
|
|
99
|
+
<MIcon v-if="item.icon" :name="item.icon" :size="iSize(item)" class="relative shrink-0" />
|
|
86
100
|
<span class="nd-label min-w-0 flex-1" :class="lClass(item)">{{ item.label }}</span>
|
|
87
101
|
<MIcon
|
|
88
102
|
v-if="item.children?.length"
|
|
@@ -90,6 +104,11 @@ export default defineComponent({
|
|
|
90
104
|
:size="16"
|
|
91
105
|
class="nd-label shrink-0 text-on-surface-variant"
|
|
92
106
|
/>
|
|
107
|
+
<span
|
|
108
|
+
v-if="collapsedLabels"
|
|
109
|
+
class="nd-rail-label pointer-events-none absolute left-0 top-10 w-14 truncate text-center text-label-medium font-medium"
|
|
110
|
+
:class="item.value === selected ? 'text-secondary' : 'text-on-surface-variant'"
|
|
111
|
+
>{{ item.label }}</span>
|
|
93
112
|
</component>
|
|
94
113
|
|
|
95
114
|
<Transition :css="false" @enter="onEnter" @leave="onLeave">
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// The box MToolbar's #fab slot renders in: tells an MFab inside that the toolbar sizes it (it fills this box, which
|
|
3
|
+
// grows from 56 to 80px as the toolbar collapses) and which color to default to. A component of its own so only
|
|
4
|
+
// the slot's FAB sees it, not one inside the toolbar's items.
|
|
5
|
+
import { provide } from 'vue'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{ color: 'primary' | 'tertiary' }>()
|
|
8
|
+
|
|
9
|
+
provide('m-toolbar-fab', props)
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<slot />
|
|
14
|
+
</template>
|