@m3ui-vue/m3ui-vue 0.9.3 → 1.0.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 +24 -29
- package/dist/API.md +177 -18
- package/dist/{MTextField-DKtgPymd.js → MTextField-TZ7lfr09.js} +233 -108
- package/dist/MTextField-TZ7lfr09.js.map +1 -0
- package/dist/api.json +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MAppBarWithSearch.vue.d.ts +70 -0
- package/dist/components/MBottomAppBar.vue.d.ts +37 -0
- package/dist/components/MBottomSheetScaffold.vue.d.ts +40 -0
- package/dist/components/MChatBubble.vue.d.ts +1 -1
- package/dist/components/MChip.vue.d.ts +19 -2
- package/dist/components/MContainer.vue.d.ts +1 -1
- package/dist/components/MDataTable.vue.d.ts +1 -1
- package/dist/components/MDialog.vue.d.ts +1 -1
- package/dist/components/MFab.vue.d.ts +13 -4
- package/dist/components/MListItem.vue.d.ts +2 -2
- package/dist/components/MLoadingOverlay.vue.d.ts +1 -1
- package/dist/components/MNavigationRail.vue.d.ts +6 -0
- package/dist/components/MSearchBar.vue.d.ts +5 -3
- package/dist/components/MShortNavigationBar.vue.d.ts +1 -1
- package/dist/components/MTable.vue.d.ts +1 -1
- package/dist/components/MTopAppBar.vue.d.ts +33 -2
- package/dist/composables/_searchAppBar.d.ts +6 -0
- package/dist/composables/_themeTransition.d.ts +2 -0
- package/dist/composables/_useSpring.d.ts +3 -5
- package/dist/composables/motion.d.ts +101 -0
- package/dist/composables/useColorPalette.d.ts +10 -0
- package/dist/composables/useLocale.d.ts +3 -0
- package/dist/index.d.ts +8 -1
- package/dist/locales/index.js +21 -0
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +6772 -5931
- package/dist/m3ui.js.map +1 -1
- package/dist/plugin.d.ts +7 -0
- package/dist/rich-text-editor.js +2 -2
- package/dist/styles/palettes-contrast.css +7764 -0
- package/dist/styles/theme.css +46 -2
- package/dist/styles.css +1 -1
- package/dist/{useLocale-Cn9MVIdw.js → useLocale-CuvWRZ1h.js} +4 -1
- package/dist/useLocale-CuvWRZ1h.js.map +1 -0
- package/package.json +3 -1
- package/src/__tests__/MAppBarWithSearch.test.ts +96 -0
- package/src/__tests__/MBottomAppBar.test.ts +71 -0
- package/src/__tests__/MBottomSheetScaffold.test.ts +101 -0
- package/src/__tests__/MChip.test.ts +63 -0
- package/src/__tests__/MFab.test.ts +36 -0
- package/src/__tests__/MNavigationRail.test.ts +77 -0
- package/src/__tests__/MTopAppBar.test.ts +99 -0
- package/src/__tests__/contrast.test.ts +64 -0
- package/src/__tests__/dynamicColor.test.ts +17 -0
- package/src/__tests__/motion.test.ts +37 -0
- package/src/__tests__/themeTransition.test.ts +119 -0
- package/src/components/MAppBarWithSearch.vue +236 -0
- package/src/components/MBottomAppBar.vue +181 -0
- package/src/components/MBottomSheetScaffold.vue +296 -0
- package/src/components/MBreadcrumbs.vue +1 -1
- package/src/components/MChip.vue +137 -5
- package/src/components/MFab.vue +73 -12
- package/src/components/MNavigationDrawer.vue +2 -2
- package/src/components/MNavigationRail.vue +135 -8
- package/src/components/MSearchBar.vue +28 -12
- package/src/components/MTopAppBar.vue +252 -28
- package/src/composables/_searchAppBar.ts +9 -0
- package/src/composables/_themeColor.ts +11 -4
- package/src/composables/_themeTransition.ts +71 -0
- package/src/composables/_useSpring.ts +11 -21
- package/src/composables/motion.ts +73 -0
- package/src/composables/useColorPalette.ts +103 -20
- package/src/composables/useLocale.ts +6 -0
- package/src/composables/useTheme.ts +4 -12
- package/src/index.ts +8 -1
- package/src/locales/de.ts +3 -0
- package/src/locales/es.ts +3 -0
- package/src/locales/fr.ts +3 -0
- package/src/locales/ja.ts +3 -0
- package/src/locales/ko.ts +3 -0
- package/src/locales/pt.ts +3 -0
- package/src/locales/zh.ts +3 -0
- package/src/plugin.ts +9 -1
- package/src/styles/palettes-contrast.css +7764 -0
- package/src/styles/theme.css +46 -2
- package/dist/MTextField-DKtgPymd.js.map +0 -1
- package/dist/useLocale-Cn9MVIdw.js.map +0 -1
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A screen with M3's standard (non-modal) bottom sheet, a port of Compose's `BottomSheetScaffold`: the sheet
|
|
4
|
+
* sits over the bottom of the content without a scrim, peeking out when partially expanded, and the content
|
|
5
|
+
* stays usable. Drag it (or its content, which scrolls once the sheet is fully expanded) between its states,
|
|
6
|
+
* or tap the handle. For a sheet that blocks the screen behind a scrim, use MBottomSheet.
|
|
7
|
+
*
|
|
8
|
+
* @slot default The screen's content; it gets bottom padding equal to `peekHeight` so nothing hides under the
|
|
9
|
+
* peeking sheet
|
|
10
|
+
* @slot sheet The sheet's content, below the drag handle
|
|
11
|
+
* @slot top-bar An app bar above the content (the sheet can rise over it)
|
|
12
|
+
* @event update:modelValue Emitted when the sheet settles in another state after a drag or a handle tap —
|
|
13
|
+
* powers v-model
|
|
14
|
+
*/
|
|
15
|
+
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
16
|
+
import { useLocale } from '../composables/useLocale'
|
|
17
|
+
import { DEFAULT_SPATIAL, FAST_EFFECTS, type SpringSpec } from '../composables/_useSpring'
|
|
18
|
+
|
|
19
|
+
export type BottomSheetValue = 'hidden' | 'partial' | 'expanded'
|
|
20
|
+
|
|
21
|
+
const props = withDefaults(defineProps<{
|
|
22
|
+
/** The sheet's state (v-model): `partial` shows `peekHeight` of it, `expanded` all of it, `hidden` none */
|
|
23
|
+
modelValue?: BottomSheetValue
|
|
24
|
+
/** Height in px the partially expanded sheet shows (BottomSheetDefaults.SheetPeekHeight) */
|
|
25
|
+
peekHeight?: number
|
|
26
|
+
/** Leaves out the hidden state, so the sheet can't be swiped away (Compose's default for this sheet) */
|
|
27
|
+
skipHiddenState?: boolean
|
|
28
|
+
/** Lets the sheet be dragged; with false it only moves through v-model and the handle */
|
|
29
|
+
swipeEnabled?: boolean
|
|
30
|
+
/** Maximum width in px; the sheet is centered when the screen is wider */
|
|
31
|
+
maxWidth?: number
|
|
32
|
+
}>(), {
|
|
33
|
+
modelValue: 'partial',
|
|
34
|
+
peekHeight: 56,
|
|
35
|
+
skipHiddenState: true,
|
|
36
|
+
swipeEnabled: true,
|
|
37
|
+
maxWidth: 640,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const emit = defineEmits<{ 'update:modelValue': [BottomSheetValue] }>()
|
|
41
|
+
const locale = useLocale()
|
|
42
|
+
|
|
43
|
+
const rootEl = ref<HTMLElement>()
|
|
44
|
+
const sheetEl = ref<HTMLElement>()
|
|
45
|
+
const contentEl = ref<HTMLElement>()
|
|
46
|
+
|
|
47
|
+
// ── Anchors ──────────────────────────────────────────────────────────────────────────────────────
|
|
48
|
+
// The sheet's translateY: 0 when expanded, its height minus the peek when partially expanded, its height
|
|
49
|
+
// when hidden. As in StandardBottomSheet's draggableAnchors, the partial anchor exists only with a peek
|
|
50
|
+
// shorter than the sheet, and the hidden one only without skipHiddenState (or with no peek).
|
|
51
|
+
let sheetHeight = 0
|
|
52
|
+
function anchors(): Partial<Record<BottomSheetValue, number>> {
|
|
53
|
+
const a: Partial<Record<BottomSheetValue, number>> = { expanded: 0 }
|
|
54
|
+
if (props.peekHeight > 0 && props.peekHeight < sheetHeight) a.partial = sheetHeight - props.peekHeight
|
|
55
|
+
if (!props.skipHiddenState || props.peekHeight <= 0) a.hidden = sheetHeight
|
|
56
|
+
return a
|
|
57
|
+
}
|
|
58
|
+
// A state with no anchor falls back the way Compose's reconciliation does
|
|
59
|
+
function resolve(value: BottomSheetValue): BottomSheetValue {
|
|
60
|
+
const a = anchors()
|
|
61
|
+
if (a[value] !== undefined) return value
|
|
62
|
+
if (value === 'hidden') return a.partial !== undefined ? 'partial' : 'expanded'
|
|
63
|
+
if (value === 'partial') return a.expanded !== undefined ? 'expanded' : 'hidden'
|
|
64
|
+
return a.hidden !== undefined ? 'hidden' : 'partial'
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// `wanted` is the state asked for; `settled` is where it actually lands with the current anchors (they can
|
|
68
|
+
// lack it for a moment, e.g. while the sheet hasn't been measured yet)
|
|
69
|
+
let wanted: BottomSheetValue = props.modelValue
|
|
70
|
+
const settled = ref<BottomSheetValue>(props.modelValue)
|
|
71
|
+
|
|
72
|
+
// ── Motion ───────────────────────────────────────────────────────────────────────────────────────
|
|
73
|
+
// Drags, flings and handle taps settle on DefaultSpatial (anchoredDraggableMotionSpec); hiding through
|
|
74
|
+
// v-model uses FastEffects (hideMotionSpec), as Compose's SheetState does.
|
|
75
|
+
let y = 0
|
|
76
|
+
let vel = 0
|
|
77
|
+
let target: number | null = null
|
|
78
|
+
let spec: SpringSpec = DEFAULT_SPATIAL
|
|
79
|
+
let raf = 0
|
|
80
|
+
let last = 0
|
|
81
|
+
|
|
82
|
+
function write() {
|
|
83
|
+
if (sheetEl.value) sheetEl.value.style.transform = `translateY(${y}px)`
|
|
84
|
+
// The content scrolls only once the sheet is fully up; until then a drag on it moves the sheet
|
|
85
|
+
if (contentEl.value) contentEl.value.style.overflowY = settled.value === 'expanded' && target === null ? 'auto' : 'hidden'
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function frame(now: number) {
|
|
89
|
+
if (target === null) return
|
|
90
|
+
let dt = Math.min((now - last) / 1000, 1 / 30)
|
|
91
|
+
last = now
|
|
92
|
+
const c = 2 * spec.dampingRatio * Math.sqrt(spec.stiffness)
|
|
93
|
+
while (dt > 0) {
|
|
94
|
+
const h = Math.min(dt, 0.004)
|
|
95
|
+
dt -= h
|
|
96
|
+
vel += (-spec.stiffness * (y - target) - c * vel) * h
|
|
97
|
+
y += vel * h
|
|
98
|
+
}
|
|
99
|
+
if (Math.abs(y - target) < 0.5 && Math.abs(vel) < 1) {
|
|
100
|
+
y = target
|
|
101
|
+
vel = 0
|
|
102
|
+
target = null
|
|
103
|
+
raf = 0
|
|
104
|
+
write()
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
write()
|
|
108
|
+
raf = requestAnimationFrame(frame)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function animateTo(value: BottomSheetValue, s: SpringSpec = DEFAULT_SPATIAL, velocity = vel) {
|
|
112
|
+
wanted = value
|
|
113
|
+
value = resolve(value)
|
|
114
|
+
settled.value = value
|
|
115
|
+
target = anchors()[value]!
|
|
116
|
+
spec = s
|
|
117
|
+
vel = velocity
|
|
118
|
+
if (!raf) {
|
|
119
|
+
last = performance.now()
|
|
120
|
+
raf = requestAnimationFrame(frame)
|
|
121
|
+
}
|
|
122
|
+
write()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function settleTo(value: BottomSheetValue, velocity = vel) {
|
|
126
|
+
animateTo(value, DEFAULT_SPATIAL, velocity)
|
|
127
|
+
if (settled.value !== props.modelValue) emit('update:modelValue', settled.value)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
watch(() => props.modelValue, (v) => {
|
|
131
|
+
if (resolve(v) !== settled.value || target !== null) animateTo(v, v === 'hidden' ? FAST_EFFECTS : DEFAULT_SPATIAL)
|
|
132
|
+
})
|
|
133
|
+
watch(() => [props.peekHeight, props.skipHiddenState], () => measure())
|
|
134
|
+
|
|
135
|
+
// Layout changes (content added, window resized) keep the sheet on its state, without animating
|
|
136
|
+
function measure() {
|
|
137
|
+
if (!sheetEl.value) return
|
|
138
|
+
sheetHeight = sheetEl.value.offsetHeight
|
|
139
|
+
const value = resolve(wanted)
|
|
140
|
+
settled.value = value
|
|
141
|
+
if (target !== null) target = anchors()[value]!
|
|
142
|
+
else y = anchors()[value]!
|
|
143
|
+
write()
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// ── Dragging ─────────────────────────────────────────────────────────────────────────────────────
|
|
147
|
+
// AnchoredDraggable with BottomSheetDefaults' thresholds: released faster than 125px/s it goes to the next
|
|
148
|
+
// state that way, otherwise to the next one only when dragged 56px past the last state it crossed.
|
|
149
|
+
const POSITIONAL_THRESHOLD = 56
|
|
150
|
+
const VELOCITY_THRESHOLD = 125
|
|
151
|
+
let drag: { id: number; x: number; y: number; from: number; active: boolean; inContent: boolean; samples: { t: number; y: number }[] } | null = null
|
|
152
|
+
let suppressClick = false
|
|
153
|
+
|
|
154
|
+
function onPointerDown(e: PointerEvent) {
|
|
155
|
+
if (!props.swipeEnabled || e.button !== 0) return
|
|
156
|
+
const inContent = !!contentEl.value?.contains(e.target as Node)
|
|
157
|
+
drag = { id: e.pointerId, x: e.clientX, y: e.clientY, from: y, active: false, inContent, samples: [{ t: e.timeStamp, y: e.clientY }] }
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function onPointerMove(e: PointerEvent) {
|
|
161
|
+
if (!drag || e.pointerId !== drag.id) return
|
|
162
|
+
const dy = e.clientY - drag.y
|
|
163
|
+
if (!drag.active) {
|
|
164
|
+
if (Math.abs(dy) < 4 || Math.abs(dy) < Math.abs(e.clientX - drag.x)) {
|
|
165
|
+
if (Math.abs(e.clientX - drag.x) > 8) drag = null
|
|
166
|
+
return
|
|
167
|
+
}
|
|
168
|
+
// ConsumeSwipeWithinBottomSheetBoundsNestedScrollConnection: an expanded sheet's content scrolls first,
|
|
169
|
+
// and the sheet only follows a downward drag once the content is back at its top
|
|
170
|
+
const content = contentEl.value
|
|
171
|
+
if (drag.inContent && settled.value === 'expanded' && content && content.scrollHeight > content.clientHeight
|
|
172
|
+
&& (dy < 0 || content.scrollTop > 0)) {
|
|
173
|
+
drag = null
|
|
174
|
+
return
|
|
175
|
+
}
|
|
176
|
+
drag.active = true
|
|
177
|
+
drag.y = e.clientY
|
|
178
|
+
drag.from = y
|
|
179
|
+
cancelAnimationFrame(raf)
|
|
180
|
+
raf = 0
|
|
181
|
+
target = null
|
|
182
|
+
vel = 0
|
|
183
|
+
sheetEl.value?.setPointerCapture?.(e.pointerId)
|
|
184
|
+
}
|
|
185
|
+
const a = Object.values(anchors())
|
|
186
|
+
y = Math.min(Math.max(...a), Math.max(Math.min(...a), drag.from + e.clientY - drag.y))
|
|
187
|
+
write()
|
|
188
|
+
drag.samples.push({ t: e.timeStamp, y: e.clientY })
|
|
189
|
+
drag.samples = drag.samples.filter((p) => e.timeStamp - p.t < 100)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function onPointerUp(e: PointerEvent) {
|
|
193
|
+
if (!drag || e.pointerId !== drag.id) return
|
|
194
|
+
const d = drag
|
|
195
|
+
drag = null
|
|
196
|
+
if (!d.active) return
|
|
197
|
+
suppressClick = true
|
|
198
|
+
setTimeout(() => { suppressClick = false })
|
|
199
|
+
const first = d.samples[0]!
|
|
200
|
+
const lastSample = d.samples[d.samples.length - 1]!
|
|
201
|
+
const dt = (lastSample.t - first.t) / 1000
|
|
202
|
+
const velocity = dt > 0 && e.timeStamp - lastSample.t <= 40 ? (lastSample.y - first.y) / dt : 0
|
|
203
|
+
settleTo(pickTarget(d.from, velocity), velocity)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function pickTarget(from: number, velocity: number): BottomSheetValue {
|
|
207
|
+
const list = (Object.entries(anchors()) as [BottomSheetValue, number][]).sort((a, b) => a[1] - b[1])
|
|
208
|
+
const down = Math.abs(velocity) > VELOCITY_THRESHOLD ? velocity > 0 : y >= from
|
|
209
|
+
const ahead = down ? list.find(([, p]) => p > y) : [...list].reverse().find(([, p]) => p < y)
|
|
210
|
+
const behind = down ? [...list].reverse().find(([, p]) => p <= y) : list.find(([, p]) => p >= y)
|
|
211
|
+
if (!ahead) return behind![0]
|
|
212
|
+
if (!behind) return ahead[0]
|
|
213
|
+
if (Math.abs(velocity) > VELOCITY_THRESHOLD) return ahead[0]
|
|
214
|
+
return Math.abs(y - behind[1]) >= POSITIONAL_THRESHOLD ? ahead[0] : behind[0]
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Once the sheet is following the finger the browser must not scroll the page or the content with it
|
|
218
|
+
function onTouchMove(e: TouchEvent) {
|
|
219
|
+
if (drag?.active && e.cancelable) e.preventDefault()
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function onClickCapture(e: MouseEvent) {
|
|
223
|
+
if (!suppressClick) return
|
|
224
|
+
e.preventDefault()
|
|
225
|
+
e.stopPropagation()
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// The handle: Expanded → partial (or hidden without a partial state), Partial → expanded, Hidden → shown
|
|
229
|
+
function onHandleClick() {
|
|
230
|
+
const a = anchors()
|
|
231
|
+
if (settled.value === 'expanded') settleTo(!props.skipHiddenState || a.partial === undefined ? 'hidden' : 'partial', 0)
|
|
232
|
+
else settleTo('expanded', 0)
|
|
233
|
+
}
|
|
234
|
+
const handleLabel = computed(() => {
|
|
235
|
+
if (settled.value !== 'expanded') return locale.sheetExpand
|
|
236
|
+
return !props.skipHiddenState || props.peekHeight <= 0 ? locale.sheetDismiss : locale.sheetCollapse
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
let observer: ResizeObserver | null = null
|
|
240
|
+
onMounted(() => {
|
|
241
|
+
measure()
|
|
242
|
+
sheetEl.value?.addEventListener('touchmove', onTouchMove, { passive: false })
|
|
243
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
244
|
+
observer = new ResizeObserver(() => measure())
|
|
245
|
+
if (sheetEl.value) observer.observe(sheetEl.value)
|
|
246
|
+
if (rootEl.value) observer.observe(rootEl.value)
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
onUnmounted(() => {
|
|
250
|
+
cancelAnimationFrame(raf)
|
|
251
|
+
observer?.disconnect()
|
|
252
|
+
sheetEl.value?.removeEventListener('touchmove', onTouchMove)
|
|
253
|
+
})
|
|
254
|
+
</script>
|
|
255
|
+
|
|
256
|
+
<template>
|
|
257
|
+
<div ref="rootEl" class="relative flex h-full flex-col overflow-hidden bg-surface text-on-surface">
|
|
258
|
+
<div v-if="$slots['top-bar']" class="shrink-0">
|
|
259
|
+
<slot name="top-bar" />
|
|
260
|
+
</div>
|
|
261
|
+
<div class="min-h-0 flex-1 overflow-auto" :style="{ paddingBottom: `${peekHeight}px` }">
|
|
262
|
+
<slot />
|
|
263
|
+
</div>
|
|
264
|
+
|
|
265
|
+
<!-- SheetBottomTokens: surface-container-low, 28dp top corners, elevation 1. The strip hanging below
|
|
266
|
+
(after:) fills the gap a spring overshoot past the expanded state would open at the bottom. -->
|
|
267
|
+
<div
|
|
268
|
+
ref="sheetEl"
|
|
269
|
+
role="region"
|
|
270
|
+
class="absolute inset-x-0 bottom-0 z-10 mx-auto flex max-h-full w-full touch-pan-y select-none flex-col rounded-t-[28px] bg-surface-container-low text-on-surface shadow-elevation-1 after:absolute after:inset-x-0 after:top-full after:h-24 after:bg-surface-container-low"
|
|
271
|
+
:style="{ maxWidth: `${maxWidth}px` }"
|
|
272
|
+
@pointerdown="onPointerDown"
|
|
273
|
+
@pointermove="onPointerMove"
|
|
274
|
+
@pointerup="onPointerUp"
|
|
275
|
+
@pointercancel="onPointerUp"
|
|
276
|
+
@click.capture="onClickCapture"
|
|
277
|
+
>
|
|
278
|
+
<!-- BottomSheetDefaults.DragHandle: 32×4dp in on-surface-variant, 22dp above and below -->
|
|
279
|
+
<div class="flex h-12 shrink-0 justify-center">
|
|
280
|
+
<button
|
|
281
|
+
type="button"
|
|
282
|
+
class="flex h-12 w-16 cursor-pointer items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-secondary"
|
|
283
|
+
:aria-label="handleLabel"
|
|
284
|
+
:aria-expanded="settled === 'expanded'"
|
|
285
|
+
@click="onHandleClick"
|
|
286
|
+
>
|
|
287
|
+
<span class="h-1 w-8 rounded-full bg-on-surface-variant" />
|
|
288
|
+
</button>
|
|
289
|
+
</div>
|
|
290
|
+
<!-- touch-action stops at a scroll container, so the content needs its own pan-y -->
|
|
291
|
+
<div ref="contentEl" class="min-h-0 flex-1 touch-pan-y select-text overflow-y-hidden">
|
|
292
|
+
<slot name="sheet" />
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
</template>
|
|
@@ -24,7 +24,7 @@ defineEmits<{ select: [BreadcrumbItem, number] }>()
|
|
|
24
24
|
</script>
|
|
25
25
|
|
|
26
26
|
<template>
|
|
27
|
-
<nav aria-label="Breadcrumb" class="flex items-center gap-1 overflow-x-auto text-label-large">
|
|
27
|
+
<nav aria-label="Breadcrumb" class="scrollbar-none flex items-center gap-1 overflow-x-auto text-label-large">
|
|
28
28
|
<template v-for="(item, i) in items" :key="i">
|
|
29
29
|
<!-- Separator -->
|
|
30
30
|
<MIcon
|
package/src/components/MChip.vue
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
/**
|
|
3
3
|
* Compact elements for filters, input, or actions — named semantic tones or any CSS color, with optional icon,
|
|
4
|
-
* click, selection, and removal support.
|
|
4
|
+
* click, selection, and removal support. With `type` it's one of M3's four chips instead (assist, filter,
|
|
5
|
+
* input, suggestion), styled by the spec and always interactive; `tone` then doesn't apply.
|
|
5
6
|
*
|
|
6
7
|
* @slot default The chip's label.
|
|
7
|
-
* @
|
|
8
|
+
* @slot avatar Input chips only: a 24px round avatar before the label (e.g. an MAvatar or an img)
|
|
9
|
+
* @event click Emitted when a clickable (or typed), non-disabled chip is clicked
|
|
8
10
|
* @event remove Emitted when the remove (X) button is clicked (removable only)
|
|
11
|
+
* @event update:selected Filter and input chips: emitted on click with the new selected state — powers
|
|
12
|
+
* v-model:selected
|
|
9
13
|
*/
|
|
10
|
-
import { computed } from 'vue'
|
|
14
|
+
import { computed, ref, useSlots } from 'vue'
|
|
11
15
|
import MIcon from './MIcon.vue'
|
|
16
|
+
import { useLocale } from '../composables/useLocale'
|
|
17
|
+
import { FAST_EFFECTS, FAST_SPATIAL, useSpring } from '../composables/_useSpring'
|
|
12
18
|
|
|
13
19
|
const NAMED_TONES = ['neutral', 'primary', 'success', 'error', 'tertiary', 'secondary'] as const
|
|
14
20
|
type NamedTone = (typeof NAMED_TONES)[number]
|
|
@@ -30,6 +36,16 @@ const props = withDefaults(
|
|
|
30
36
|
disabled?: boolean
|
|
31
37
|
/** Leading Material Symbol icon */
|
|
32
38
|
icon?: string
|
|
39
|
+
/**
|
|
40
|
+
* One of M3's chips: `assist` (an action), `filter` (on/off, v-model:selected; a check slides in while
|
|
41
|
+
* selected), `input` (a piece of user input, with an optional #avatar and `removable`), `suggestion`.
|
|
42
|
+
* Leave unset for the generic tone-colored chip
|
|
43
|
+
*/
|
|
44
|
+
type?: 'assist' | 'filter' | 'input' | 'suggestion'
|
|
45
|
+
/** Typed assist, filter and suggestion chips: surface-container-low with elevation 1 instead of an outline */
|
|
46
|
+
elevated?: boolean
|
|
47
|
+
/** Typed chips: a trailing Material Symbol icon (e.g. arrow_drop_down on a filter chip that opens a menu) */
|
|
48
|
+
trailingIcon?: string
|
|
33
49
|
}>(),
|
|
34
50
|
{
|
|
35
51
|
tone: 'neutral',
|
|
@@ -37,10 +53,13 @@ const props = withDefaults(
|
|
|
37
53
|
removable: false,
|
|
38
54
|
clickable: false,
|
|
39
55
|
disabled: false,
|
|
56
|
+
elevated: false,
|
|
40
57
|
},
|
|
41
58
|
)
|
|
42
59
|
|
|
43
|
-
const emit = defineEmits<{ click: []; remove: [] }>()
|
|
60
|
+
const emit = defineEmits<{ click: []; remove: []; 'update:selected': [boolean] }>()
|
|
61
|
+
const locale = useLocale()
|
|
62
|
+
const slots = useSlots()
|
|
44
63
|
|
|
45
64
|
const isCustomColor = computed(
|
|
46
65
|
() => !!props.tone && !(NAMED_TONES as readonly string[]).includes(props.tone),
|
|
@@ -95,6 +114,74 @@ const shapeClass = computed(() => props.selected ? 'rounded-full' : 'rounded-md'
|
|
|
95
114
|
// it. `ring-inset` on the focus ring (FocusedIndicatorColor = secondary) because `overflow-
|
|
96
115
|
// hidden` on this same element (needed to clip the state-layer to the chip's shape) would
|
|
97
116
|
// otherwise clip an outset ring's box-shadow too.
|
|
117
|
+
// ── Typed chips (Compose's AssistChip / FilterChip / InputChip / SuggestionChip) ─────────────────────
|
|
118
|
+
// 32dp, label-large, 18dp icons. Assist and suggestion keep CornerSmall (8dp); filter and input use the
|
|
119
|
+
// Expressive ChipShapes (CornerMedium 12dp, CornerFull while selected, CornerSmall while pressed) and the
|
|
120
|
+
// unified ChipsTokens colors.
|
|
121
|
+
const selectable = computed(() => props.type === 'filter' || props.type === 'input')
|
|
122
|
+
const hasAvatar = computed(() => props.type === 'input' && !!slots.avatar)
|
|
123
|
+
const hasTrailing = computed(() => !!props.trailingIcon || (props.type === 'input' && props.removable))
|
|
124
|
+
|
|
125
|
+
const typedContainer = computed(() => {
|
|
126
|
+
const on = selectable.value && props.selected
|
|
127
|
+
if (props.disabled) {
|
|
128
|
+
if (on) return 'bg-on-surface/12 text-on-surface/38'
|
|
129
|
+
return props.elevated && props.type !== 'input'
|
|
130
|
+
? 'bg-on-surface/12 text-on-surface/38'
|
|
131
|
+
: 'border border-on-surface/12 text-on-surface/38'
|
|
132
|
+
}
|
|
133
|
+
if (on) return ['bg-secondary-container text-on-secondary-container', props.elevated ? 'shadow-elevation-1 hover:shadow-elevation-2' : '']
|
|
134
|
+
const label = props.type === 'assist' ? 'text-on-surface' : 'text-on-surface-variant'
|
|
135
|
+
return props.elevated && props.type !== 'input'
|
|
136
|
+
? ['bg-surface-container-low shadow-elevation-1 hover:shadow-elevation-2', label]
|
|
137
|
+
: ['border border-outline-variant', label]
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
const leadingIconClass = computed(() => {
|
|
141
|
+
if (props.disabled) return ''
|
|
142
|
+
if (props.type === 'assist' || props.type === 'suggestion') return 'text-primary'
|
|
143
|
+
return props.selected ? 'text-on-secondary-container' : 'text-on-surface-variant'
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
// Compose's chip paddings: 8dp next to a leading/trailing icon, 16dp otherwise; an input chip 4dp next to an
|
|
147
|
+
// avatar, 8dp next to an icon, 12dp (4 + the label's 8) otherwise
|
|
148
|
+
const typedPadding = computed(() => {
|
|
149
|
+
if (props.type === 'input') {
|
|
150
|
+
return [hasAvatar.value ? 'pl-1' : props.icon ? 'pl-2' : 'pl-3', hasTrailing.value ? 'pr-2' : 'pr-3']
|
|
151
|
+
}
|
|
152
|
+
// A filter chip's sliding check carries its own spacing (see checkEl), so its padding stays put
|
|
153
|
+
return [props.icon || slidingCheck.value ? 'pl-2' : 'pl-4', hasTrailing.value ? 'pr-2' : 'pr-4']
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
const pressed = ref(false)
|
|
157
|
+
const typedEl = ref<HTMLElement>()
|
|
158
|
+
const checkEl = ref<HTMLElement>()
|
|
159
|
+
// Filter chip without its own icon: the check expands in (FastSpatial) and fades in (FastEffects) as it gets
|
|
160
|
+
// selected, like Compose's animated chip content. Its slot runs from 8px (with the 8px padding: the label at
|
|
161
|
+
// 16px, an iconless chip's padding) to 26px (the check at 8px, the label 8px after it).
|
|
162
|
+
const slidingCheck = computed(() => props.type === 'filter' && !props.icon)
|
|
163
|
+
useSpring(
|
|
164
|
+
() => (props.type === 'filter' || props.type === 'input'
|
|
165
|
+
? [pressed.value ? 8 : props.selected ? 16 : 12, slidingCheck.value ? (props.selected ? 26 : 8) : 0]
|
|
166
|
+
: []),
|
|
167
|
+
([radius, width]) => {
|
|
168
|
+
if (typedEl.value && radius !== undefined) typedEl.value.style.borderRadius = `${radius}px`
|
|
169
|
+
if (checkEl.value && width !== undefined) checkEl.value.style.width = `${width}px`
|
|
170
|
+
},
|
|
171
|
+
FAST_SPATIAL,
|
|
172
|
+
)
|
|
173
|
+
useSpring(
|
|
174
|
+
() => (slidingCheck.value ? [props.selected ? 1 : 0] : []),
|
|
175
|
+
([opacity]) => { if (checkEl.value && opacity !== undefined) checkEl.value.style.opacity = String(opacity) },
|
|
176
|
+
FAST_EFFECTS,
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
function onTypedClick() {
|
|
180
|
+
if (props.disabled) return
|
|
181
|
+
if (selectable.value) emit('update:selected', !props.selected)
|
|
182
|
+
emit('click')
|
|
183
|
+
}
|
|
184
|
+
|
|
98
185
|
const interactiveClasses =
|
|
99
186
|
"relative cursor-pointer before:content-[''] before:pointer-events-none before:absolute before:inset-0 " +
|
|
100
187
|
'before:bg-current before:opacity-0 before:transition-opacity before:duration-150 ' +
|
|
@@ -103,8 +190,53 @@ const interactiveClasses =
|
|
|
103
190
|
</script>
|
|
104
191
|
|
|
105
192
|
<template>
|
|
193
|
+
<span
|
|
194
|
+
v-if="type"
|
|
195
|
+
ref="typedEl"
|
|
196
|
+
class="relative inline-flex h-8 items-center overflow-hidden align-middle text-label-large transition-[background-color,box-shadow,color] has-[button:focus-visible]:ring-2 has-[button:focus-visible]:ring-inset has-[button:focus-visible]:ring-secondary"
|
|
197
|
+
:class="[typedContainer, type === 'assist' || type === 'suggestion' ? 'rounded-sm' : 'rounded-md']"
|
|
198
|
+
>
|
|
199
|
+
<!-- Typed chip: the container is a span so an input chip's remove button can sit beside (not inside) the
|
|
200
|
+
main button; the main button's state layer (before:) covers the whole chip -->
|
|
201
|
+
<button
|
|
202
|
+
type="button"
|
|
203
|
+
class="flex h-full items-center gap-2 outline-none before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity"
|
|
204
|
+
:class="[typedPadding, disabled ? 'cursor-not-allowed' : 'cursor-pointer hover:before:opacity-[0.08] active:before:opacity-[0.12]']"
|
|
205
|
+
:disabled="disabled"
|
|
206
|
+
:aria-pressed="selectable ? selected : undefined"
|
|
207
|
+
@pointerdown="pressed = true"
|
|
208
|
+
@pointerup="pressed = false"
|
|
209
|
+
@pointerleave="pressed = false"
|
|
210
|
+
@pointercancel="pressed = false"
|
|
211
|
+
@click="onTypedClick"
|
|
212
|
+
>
|
|
213
|
+
<span v-if="hasAvatar" class="-my-1 flex h-6 w-6 shrink-0 items-center justify-center overflow-hidden rounded-full" :class="disabled ? 'opacity-38' : ''">
|
|
214
|
+
<slot name="avatar" />
|
|
215
|
+
</span>
|
|
216
|
+
<MIcon v-else-if="icon" :name="icon" :size="18" :filled="type === 'filter' && selected" class="shrink-0" :class="leadingIconClass" />
|
|
217
|
+
<!-- -mr-2 cancels the gap while the check is closed -->
|
|
218
|
+
<span v-else-if="slidingCheck" ref="checkEl" class="-mr-2 flex shrink-0 overflow-hidden" style="width: 8px; opacity: 0" aria-hidden="true">
|
|
219
|
+
<MIcon name="check" :size="18" class="shrink-0" :class="leadingIconClass" />
|
|
220
|
+
</span>
|
|
221
|
+
<span class="whitespace-nowrap"><slot /></span>
|
|
222
|
+
<MIcon v-if="trailingIcon" :name="trailingIcon" :size="18" class="shrink-0" :class="disabled ? '' : selected && selectable ? 'text-on-secondary-container' : 'text-on-surface-variant'" />
|
|
223
|
+
</button>
|
|
224
|
+
<button
|
|
225
|
+
v-if="type === 'input' && removable"
|
|
226
|
+
type="button"
|
|
227
|
+
class="relative -ml-1 mr-2 flex h-6 w-6 shrink-0 items-center justify-center rounded-full outline-none hover:bg-on-surface/8 focus-visible:ring-2 focus-visible:ring-secondary"
|
|
228
|
+
:class="disabled ? 'cursor-not-allowed' : 'cursor-pointer'"
|
|
229
|
+
:aria-label="locale.remove"
|
|
230
|
+
:disabled="disabled"
|
|
231
|
+
@click.stop="emit('remove')"
|
|
232
|
+
>
|
|
233
|
+
<MIcon name="close" :size="18" />
|
|
234
|
+
</button>
|
|
235
|
+
</span>
|
|
236
|
+
|
|
106
237
|
<component
|
|
107
238
|
:is="clickable ? 'button' : 'span'"
|
|
239
|
+
v-else
|
|
108
240
|
:type="clickable ? 'button' : undefined"
|
|
109
241
|
:disabled="clickable && disabled ? true : undefined"
|
|
110
242
|
class="inline-flex h-8 items-center gap-1.5 overflow-hidden px-3 text-label-large transition-colors"
|
|
@@ -123,7 +255,7 @@ const interactiveClasses =
|
|
|
123
255
|
v-if="removable"
|
|
124
256
|
type="button"
|
|
125
257
|
class="-mr-1 ml-0.5 inline-flex items-center justify-center rounded-full hover:bg-on-surface/12"
|
|
126
|
-
aria-label="
|
|
258
|
+
:aria-label="locale.remove"
|
|
127
259
|
:disabled="disabled"
|
|
128
260
|
@click.stop="emit('remove')"
|
|
129
261
|
>
|
package/src/components/MFab.vue
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* `close()` closes it.
|
|
8
8
|
* @event click Emitted when the FAB itself is clicked (not a speed-dial item)
|
|
9
9
|
*/
|
|
10
|
-
import { computed, onMounted, onUnmounted, ref, useSlots } from 'vue'
|
|
10
|
+
import { computed, inject, onMounted, onUnmounted, ref, useSlots } from 'vue'
|
|
11
11
|
import MIcon from './MIcon.vue'
|
|
12
12
|
import { vRipple } from '../directives/vRipple'
|
|
13
|
+
import { FAST_EFFECTS, FAST_SPATIAL, useSpring } from '../composables/_useSpring'
|
|
13
14
|
|
|
14
15
|
export interface SpeedDialItem {
|
|
15
16
|
icon: string
|
|
@@ -26,9 +27,17 @@ const props = withDefaults(
|
|
|
26
27
|
icon: string
|
|
27
28
|
/** Extended FAB label text */
|
|
28
29
|
label?: string
|
|
29
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Extended FAB only: false collapses it to a plain FAB (the label fades out and the width shrinks to a
|
|
32
|
+
* square), e.g. while the content scrolls. Compose's `expanded`
|
|
33
|
+
*/
|
|
34
|
+
expanded?: boolean
|
|
35
|
+
/** Color scheme; defaults to primary, or secondary inside an MBottomAppBar */
|
|
30
36
|
color?: 'primary' | 'secondary' | 'tertiary' | 'surface'
|
|
31
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* FAB size. With a `label`, small/medium/large are M3 Expressive's extended FABs (56/80/96px, title-medium,
|
|
39
|
+
* title-large and headline-small labels); regular is the baseline extended FAB
|
|
40
|
+
*/
|
|
32
41
|
size?: 'small' | 'regular' | 'medium' | 'large'
|
|
33
42
|
/** Disables interaction */
|
|
34
43
|
disabled?: boolean
|
|
@@ -63,8 +72,9 @@ const props = withDefaults(
|
|
|
63
72
|
rippleColor?: string
|
|
64
73
|
}>(),
|
|
65
74
|
{
|
|
66
|
-
color:
|
|
75
|
+
color: undefined,
|
|
67
76
|
size: 'regular',
|
|
77
|
+
expanded: true,
|
|
68
78
|
disabled: false,
|
|
69
79
|
direction: 'up',
|
|
70
80
|
persistent: false,
|
|
@@ -87,6 +97,10 @@ const hasItems = computed(() => !!props.items?.length)
|
|
|
87
97
|
const hasContent = computed(() => !!slots.content)
|
|
88
98
|
const isExpandable = computed(() => hasItems.value || hasContent.value)
|
|
89
99
|
|
|
100
|
+
// Inside an MBottomAppBar: secondary and flat (bottomAppBarFabColor, bottomAppBarFabElevation)
|
|
101
|
+
const inBottomAppBar = inject('m-bottom-app-bar', false)
|
|
102
|
+
const color = computed(() => props.color ?? (inBottomAppBar ? 'secondary' : 'primary'))
|
|
103
|
+
|
|
90
104
|
const colorMap: Record<string, string> = {
|
|
91
105
|
primary: 'bg-primary-container text-on-primary-container',
|
|
92
106
|
secondary: 'bg-secondary-container text-on-secondary-container',
|
|
@@ -94,10 +108,20 @@ const colorMap: Record<string, string> = {
|
|
|
94
108
|
surface: 'bg-surface-container-high text-primary',
|
|
95
109
|
}
|
|
96
110
|
|
|
111
|
+
// Extended FABs (androidx FloatingActionButton.kt). Baseline (`regular`): 16dp start, 12dp icon-to-label,
|
|
112
|
+
// 20dp end, 80dp minimum width, labelLarge. Small/Medium/Large (ExtendedFab*Tokens): leading = trailing space,
|
|
113
|
+
// minimum width = height, MediumExtendedFabIconPadding/LargeExtendedFabIconPadding (12/16dp, the tokens'
|
|
114
|
+
// IconLabelSpace is marked incorrect there).
|
|
115
|
+
const EXTENDED = {
|
|
116
|
+
regular: { px: 56, icon: 24, gap: 12, box: 'h-14 min-w-20 rounded-2xl pl-4 pr-5', text: 'text-label-large font-medium' },
|
|
117
|
+
small: { px: 56, icon: 24, gap: 8, box: 'h-14 min-w-14 rounded-2xl px-4', text: 'text-title-medium font-medium' },
|
|
118
|
+
medium: { px: 80, icon: 28, gap: 12, box: 'h-20 min-w-20 rounded-lg-increased px-[26px]', text: 'text-title-large' },
|
|
119
|
+
large: { px: 96, icon: 32, gap: 16, box: 'h-24 min-w-24 rounded-xl px-7', text: 'text-headline-small' },
|
|
120
|
+
} as const
|
|
121
|
+
const extended = computed(() => (props.label ? EXTENDED[props.size] : null))
|
|
122
|
+
|
|
97
123
|
const fabSizeClasses = computed(() => {
|
|
98
|
-
|
|
99
|
-
// icon-to-label gap, 20dp end padding, 80dp minimum width.
|
|
100
|
-
if (props.label) return 'h-14 min-w-20 rounded-2xl pl-4 pr-5 gap-3'
|
|
124
|
+
if (extended.value) return extended.value.box
|
|
101
125
|
switch (props.size) {
|
|
102
126
|
case 'small': return 'h-10 w-10 rounded-md'
|
|
103
127
|
case 'medium': return 'h-20 w-20 rounded-lg-increased'
|
|
@@ -107,7 +131,7 @@ const fabSizeClasses = computed(() => {
|
|
|
107
131
|
})
|
|
108
132
|
|
|
109
133
|
const fabIconSize = computed(() => {
|
|
110
|
-
if (
|
|
134
|
+
if (extended.value) return extended.value.icon
|
|
111
135
|
switch (props.size) {
|
|
112
136
|
case 'small': return 24
|
|
113
137
|
case 'medium': return 28
|
|
@@ -117,7 +141,7 @@ const fabIconSize = computed(() => {
|
|
|
117
141
|
})
|
|
118
142
|
|
|
119
143
|
const fabPx = computed(() => {
|
|
120
|
-
if (
|
|
144
|
+
if (extended.value) return extended.value.px
|
|
121
145
|
switch (props.size) {
|
|
122
146
|
case 'small': return 40
|
|
123
147
|
case 'medium': return 80
|
|
@@ -126,6 +150,34 @@ const fabPx = computed(() => {
|
|
|
126
150
|
}
|
|
127
151
|
})
|
|
128
152
|
|
|
153
|
+
// Collapsing an extended FAB: the width lerps from the square (the minimum width) to the full width on
|
|
154
|
+
// FastSpatial, the label fades on FastEffects, and it leaves the layout once fully collapsed.
|
|
155
|
+
const fabButton = ref<HTMLElement | { $el: HTMLElement }>()
|
|
156
|
+
const labelEl = ref<HTMLElement>()
|
|
157
|
+
const buttonEl = () => (fabButton.value instanceof HTMLElement ? fabButton.value : fabButton.value?.$el)
|
|
158
|
+
|
|
159
|
+
useSpring(
|
|
160
|
+
() => (extended.value ? [props.expanded ? 1 : 0] : []),
|
|
161
|
+
([p]) => {
|
|
162
|
+
const el = buttonEl()
|
|
163
|
+
if (!el || p === undefined || !extended.value) return
|
|
164
|
+
if (labelEl.value) labelEl.value.style.display = p <= 0 && !props.expanded ? 'none' : ''
|
|
165
|
+
el.style.width = ''
|
|
166
|
+
el.style.minWidth = ''
|
|
167
|
+
if (p >= 1 && props.expanded) return
|
|
168
|
+
const full = el.offsetWidth
|
|
169
|
+
const min = extended.value.px
|
|
170
|
+
el.style.minWidth = '0'
|
|
171
|
+
el.style.width = `${min + (full - min) * Math.max(0, p)}px`
|
|
172
|
+
},
|
|
173
|
+
FAST_SPATIAL,
|
|
174
|
+
)
|
|
175
|
+
useSpring(
|
|
176
|
+
() => (extended.value ? [props.expanded ? 1 : 0] : []),
|
|
177
|
+
([alpha]) => { if (labelEl.value && alpha !== undefined) labelEl.value.style.opacity = String(Math.min(1, Math.max(0, alpha))) },
|
|
178
|
+
FAST_EFFECTS,
|
|
179
|
+
)
|
|
180
|
+
|
|
129
181
|
const ITEM_PX = 40
|
|
130
182
|
const ITEM_GAP = 8
|
|
131
183
|
|
|
@@ -289,11 +341,13 @@ onUnmounted(() => {
|
|
|
289
341
|
<div ref="fabEl" v-bind="$attrs" class="relative inline-flex items-center justify-center">
|
|
290
342
|
<component
|
|
291
343
|
:is="fabTag"
|
|
344
|
+
ref="fabButton"
|
|
292
345
|
:to="to || undefined"
|
|
293
346
|
:type="to ? undefined : 'button'"
|
|
294
|
-
class="relative inline-flex cursor-pointer items-center
|
|
295
|
-
:class="[colorMap[color], fabSizeClasses]"
|
|
347
|
+
class="relative inline-flex cursor-pointer items-center overflow-hidden transition-shadow duration-150 disabled:cursor-not-allowed disabled:opacity-[0.38] before:content-[''] before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:duration-150 hover:before:opacity-[0.08] active:before:opacity-[0.12]"
|
|
348
|
+
:class="[colorMap[color], fabSizeClasses, extended ? 'justify-start' : 'justify-center', inBottomAppBar ? '' : 'shadow-elevation-3 hover:shadow-elevation-4 active:shadow-elevation-3']"
|
|
296
349
|
:disabled="disabled"
|
|
350
|
+
:aria-label="label && !expanded ? label : undefined"
|
|
297
351
|
v-ripple="{ disabled, color: rippleColor }"
|
|
298
352
|
@click="handleFabClick"
|
|
299
353
|
>
|
|
@@ -303,7 +357,14 @@ onUnmounted(() => {
|
|
|
303
357
|
class="transition-transform duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)]"
|
|
304
358
|
:class="isExpandable && open ? 'rotate-45' : ''"
|
|
305
359
|
/>
|
|
306
|
-
|
|
360
|
+
<!-- The icon-to-label space belongs to the label, so it goes when the label does -->
|
|
361
|
+
<span
|
|
362
|
+
v-if="extended"
|
|
363
|
+
ref="labelEl"
|
|
364
|
+
class="shrink-0 whitespace-nowrap"
|
|
365
|
+
:class="extended.text"
|
|
366
|
+
:style="{ paddingLeft: `${extended.gap}px` }"
|
|
367
|
+
>{{ label }}</span>
|
|
307
368
|
</component>
|
|
308
369
|
</div>
|
|
309
370
|
|