@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
|
@@ -192,7 +192,7 @@ watch(
|
|
|
192
192
|
</h2>
|
|
193
193
|
</div>
|
|
194
194
|
|
|
195
|
-
<div class="flex min-h-0 flex-1 flex-col overflow-y-auto px-3 py-2">
|
|
195
|
+
<div class="scrollbar-none flex min-h-0 flex-1 flex-col overflow-y-auto px-3 py-2">
|
|
196
196
|
<template v-for="(section, si) in sections" :key="si">
|
|
197
197
|
<div v-if="si > 0" class="my-1 border-t border-outline-variant" />
|
|
198
198
|
|
|
@@ -329,7 +329,7 @@ watch(
|
|
|
329
329
|
</div>
|
|
330
330
|
|
|
331
331
|
<div
|
|
332
|
-
class="flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto overflow-x-hidden px-3 py-2"
|
|
332
|
+
class="scrollbar-none flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto overflow-x-hidden px-3 py-2"
|
|
333
333
|
>
|
|
334
334
|
<template v-for="(section, si) in sections" :key="si">
|
|
335
335
|
<div v-if="si > 0" class="my-1 border-t border-outline-variant" />
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @slot fab A FAB (or MFabMenu) at the top of the rail, above the items.
|
|
7
7
|
* @event update:modelValue Emitted when an item is clicked — powers v-model
|
|
8
8
|
* @event update:expanded Emitted when the modal panel closes (modal mode only) — pair with :expanded for
|
|
9
|
-
* v-model:expanded
|
|
9
|
+
* v-model:expanded. With `hideOnCollapse`, swiping the panel away closes it too
|
|
10
10
|
*/
|
|
11
11
|
import { computed, ref, watch, onUnmounted } from 'vue'
|
|
12
12
|
import MIcon from './MIcon.vue'
|
|
@@ -49,7 +49,12 @@ const props = withDefaults(defineProps<{
|
|
|
49
49
|
// affects the app's layout grid — `ModalWideNavigationRail`'s whole point) and `expanded`
|
|
50
50
|
// instead opens a Teleported, scrim-backed panel that floats above the rest of the app.
|
|
51
51
|
modal?: boolean
|
|
52
|
-
|
|
52
|
+
/**
|
|
53
|
+
* With `modal`: no collapsed rail on screen; the expanded rail slides in from off-screen and can be swiped
|
|
54
|
+
* away (Compose's `hideOnCollapse`). Open it from your own menu button
|
|
55
|
+
*/
|
|
56
|
+
hideOnCollapse?: boolean
|
|
57
|
+
}>(), { alignment: 'top', expanded: false, modal: false, hideOnCollapse: false })
|
|
53
58
|
|
|
54
59
|
const emit = defineEmits<{
|
|
55
60
|
'update:modelValue': [string | number]
|
|
@@ -101,6 +106,9 @@ function onKeydown(e: KeyboardEvent) {
|
|
|
101
106
|
const PANEL_WIDTH = 220
|
|
102
107
|
const SPRING_DAMPING = 0.9
|
|
103
108
|
const SPRING_STIFFNESS = 1400
|
|
109
|
+
// The dismissible (hideOnCollapse) panel slides instead: ModalWideNavigationRailState's DefaultSpatial
|
|
110
|
+
const SLIDE_DAMPING = 0.9
|
|
111
|
+
const SLIDE_STIFFNESS = 700
|
|
104
112
|
|
|
105
113
|
// Guards against two overlapping spring loops fighting over the same element's
|
|
106
114
|
// `style.width` (e.g. a close fired before a still-running open settles) — each call gets
|
|
@@ -109,25 +117,38 @@ const SPRING_STIFFNESS = 1400
|
|
|
109
117
|
const springTokens = new WeakMap<HTMLElement, number>()
|
|
110
118
|
|
|
111
119
|
function springWidth(el: HTMLElement, from: number, to: number, done?: () => void) {
|
|
120
|
+
springValue(el, from, to, (v) => { el.style.width = `${v}px` }, SPRING_STIFFNESS, SPRING_DAMPING, 0, done)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function springValue(
|
|
124
|
+
el: HTMLElement,
|
|
125
|
+
from: number,
|
|
126
|
+
to: number,
|
|
127
|
+
apply: (v: number) => void,
|
|
128
|
+
stiffness: number,
|
|
129
|
+
damping: number,
|
|
130
|
+
initialVelocity: number,
|
|
131
|
+
done?: () => void,
|
|
132
|
+
) {
|
|
112
133
|
const token = (springTokens.get(el) ?? 0) + 1
|
|
113
134
|
springTokens.set(el, token)
|
|
114
135
|
let pos = from
|
|
115
|
-
let vel =
|
|
136
|
+
let vel = initialVelocity
|
|
116
137
|
let last = performance.now()
|
|
117
138
|
const start = last
|
|
118
|
-
|
|
139
|
+
apply(from)
|
|
119
140
|
function finish() {
|
|
120
|
-
|
|
141
|
+
apply(to)
|
|
121
142
|
done?.()
|
|
122
143
|
}
|
|
123
144
|
function tick(now: number) {
|
|
124
145
|
if (springTokens.get(el) !== token) return
|
|
125
146
|
const dt = Math.min((now - last) / 1000, 1 / 30)
|
|
126
147
|
last = now
|
|
127
|
-
const accel = -
|
|
148
|
+
const accel = -stiffness * (pos - to) - 2 * damping * Math.sqrt(stiffness) * vel
|
|
128
149
|
vel += accel * dt
|
|
129
150
|
pos += vel * dt
|
|
130
|
-
|
|
151
|
+
apply(pos)
|
|
131
152
|
// Settled normally, or a safety net in case rAF stalls/throttles badly enough that the
|
|
132
153
|
// spring can't converge in reasonable real time (e.g. a backgrounded tab) — either way
|
|
133
154
|
// the panel must never get stuck mid-animation forever.
|
|
@@ -140,7 +161,97 @@ function springWidth(el: HTMLElement, from: number, to: number, done?: () => voi
|
|
|
140
161
|
requestAnimationFrame(tick)
|
|
141
162
|
}
|
|
142
163
|
|
|
164
|
+
// ── Dismissible panel (hideOnCollapse): slide + swipe ─────────────────────────────────────────
|
|
165
|
+
// The panel's x runs from -width (off-screen) to 0, and the scrim's opacity follows it.
|
|
166
|
+
let panelX = 0
|
|
167
|
+
let releaseVelocity = 0
|
|
168
|
+
|
|
169
|
+
function setSlide(panel: HTMLElement, scrim: HTMLElement | null, x: number) {
|
|
170
|
+
panelX = x
|
|
171
|
+
panel.style.transform = `translateX(${x}px)`
|
|
172
|
+
if (scrim) scrim.style.opacity = String(Math.min(1, Math.max(0, 1 + x / (panel.offsetWidth || PANEL_WIDTH))))
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function slide(el: Element, to: number, done?: () => void) {
|
|
176
|
+
const panel = (el as HTMLElement).querySelector<HTMLElement>('.wnr-panel')
|
|
177
|
+
const scrim = (el as HTMLElement).querySelector<HTMLElement>('.wnr-scrim')
|
|
178
|
+
if (!panel) return done?.()
|
|
179
|
+
if (scrim) scrim.style.transition = 'none'
|
|
180
|
+
const v = releaseVelocity
|
|
181
|
+
releaseVelocity = 0
|
|
182
|
+
springValue(panel, panelX, to, (x) => setSlide(panel, scrim, x), SLIDE_STIFFNESS, SLIDE_DAMPING, v, done)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// AnchoredDraggableDefaults: settles at the nearer anchor (positionalThreshold 50%) unless released faster
|
|
186
|
+
// than 125dp/s, which goes the way of the fling
|
|
187
|
+
const FLING_VELOCITY = 125
|
|
188
|
+
let drag: { id: number; x: number; y: number; startX: number; active: boolean; samples: { t: number; x: number }[] } | null = null
|
|
189
|
+
let suppressClick = false
|
|
190
|
+
|
|
191
|
+
function onPanelPointerDown(e: PointerEvent) {
|
|
192
|
+
if (!props.hideOnCollapse || e.button !== 0) return
|
|
193
|
+
drag = { id: e.pointerId, x: e.clientX, y: e.clientY, startX: panelX, active: false, samples: [{ t: e.timeStamp, x: e.clientX }] }
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function onPanelPointerMove(e: PointerEvent) {
|
|
197
|
+
if (!drag || e.pointerId !== drag.id) return
|
|
198
|
+
const dx = e.clientX - drag.x
|
|
199
|
+
const dy = e.clientY - drag.y
|
|
200
|
+
if (!drag.active) {
|
|
201
|
+
if (Math.abs(dy) > 8 && Math.abs(dy) > Math.abs(dx)) { drag = null; return }
|
|
202
|
+
if (Math.abs(dx) < 8) return
|
|
203
|
+
drag.active = true
|
|
204
|
+
;(e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId)
|
|
205
|
+
}
|
|
206
|
+
const panel = e.currentTarget as HTMLElement
|
|
207
|
+
springTokens.set(panel, (springTokens.get(panel) ?? 0) + 1) // stop a running slide
|
|
208
|
+
const scrim = panel.parentElement?.querySelector<HTMLElement>('.wnr-scrim') ?? null
|
|
209
|
+
if (scrim) scrim.style.transition = 'none'
|
|
210
|
+
setSlide(panel, scrim, Math.min(0, Math.max(-(panel.offsetWidth || PANEL_WIDTH), drag.startX + dx)))
|
|
211
|
+
drag.samples.push({ t: e.timeStamp, x: e.clientX })
|
|
212
|
+
drag.samples = drag.samples.filter((p) => e.timeStamp - p.t < 100)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function onPanelPointerUp(e: PointerEvent) {
|
|
216
|
+
if (!drag || e.pointerId !== drag.id) return
|
|
217
|
+
const wasActive = drag.active
|
|
218
|
+
const first = drag.samples[0]!
|
|
219
|
+
const lastSample = drag.samples[drag.samples.length - 1]!
|
|
220
|
+
const dt = (lastSample.t - first.t) / 1000
|
|
221
|
+
const velocity = dt > 0 ? (lastSample.x - first.x) / dt : 0
|
|
222
|
+
drag = null
|
|
223
|
+
if (!wasActive) return
|
|
224
|
+
suppressClick = true
|
|
225
|
+
setTimeout(() => { suppressClick = false })
|
|
226
|
+
const panel = e.currentTarget as HTMLElement
|
|
227
|
+
const width = panel.offsetWidth || PANEL_WIDTH
|
|
228
|
+
const dismiss = Math.abs(velocity) > FLING_VELOCITY ? velocity < 0 : panelX < -width / 2
|
|
229
|
+
releaseVelocity = velocity
|
|
230
|
+
if (dismiss) close()
|
|
231
|
+
else slide(panel.parentElement!, 0)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Belt and braces once a swipe has started: the browser must not scroll or navigate with it
|
|
235
|
+
function onPanelTouchMove(e: TouchEvent) {
|
|
236
|
+
if (drag?.active && e.cancelable) e.preventDefault()
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function onPanelClickCapture(e: MouseEvent) {
|
|
240
|
+
if (!suppressClick) return
|
|
241
|
+
e.preventDefault()
|
|
242
|
+
e.stopPropagation()
|
|
243
|
+
}
|
|
244
|
+
|
|
143
245
|
function onPanelEnter(el: Element, done: () => void) {
|
|
246
|
+
if (props.hideOnCollapse) {
|
|
247
|
+
// Standalone modal: the items are expanded from the start, the panel slides in from off-screen
|
|
248
|
+
panelExpanded.value = true
|
|
249
|
+
const panel = (el as HTMLElement).querySelector<HTMLElement>('.wnr-panel')
|
|
250
|
+
const scrim = (el as HTMLElement).querySelector<HTMLElement>('.wnr-scrim')
|
|
251
|
+
if (panel) setSlide(panel, scrim, -(panel.offsetWidth || PANEL_WIDTH))
|
|
252
|
+
slide(el, 0, done)
|
|
253
|
+
return
|
|
254
|
+
}
|
|
144
255
|
const panel = (el as HTMLElement).querySelector<HTMLElement>('.wnr-panel')
|
|
145
256
|
const scrim = (el as HTMLElement).querySelector<HTMLElement>('.wnr-scrim')
|
|
146
257
|
panelExpanded.value = false
|
|
@@ -157,6 +268,11 @@ function onPanelEnter(el: Element, done: () => void) {
|
|
|
157
268
|
else done()
|
|
158
269
|
}
|
|
159
270
|
function onPanelLeave(el: Element, done: () => void) {
|
|
271
|
+
if (props.hideOnCollapse) {
|
|
272
|
+
const panel = (el as HTMLElement).querySelector<HTMLElement>('.wnr-panel')
|
|
273
|
+
slide(el, -(panel?.offsetWidth || PANEL_WIDTH), done)
|
|
274
|
+
return
|
|
275
|
+
}
|
|
160
276
|
const panel = (el as HTMLElement).querySelector<HTMLElement>('.wnr-panel')
|
|
161
277
|
const scrim = (el as HTMLElement).querySelector<HTMLElement>('.wnr-scrim')
|
|
162
278
|
panelExpanded.value = false
|
|
@@ -193,6 +309,7 @@ onUnmounted(() => {
|
|
|
193
309
|
that actually reacts to `expanded` when `modal` is set.
|
|
194
310
|
-->
|
|
195
311
|
<nav
|
|
312
|
+
v-if="!(modal && hideOnCollapse)"
|
|
196
313
|
v-bind="$attrs"
|
|
197
314
|
class="flex h-full flex-col border-r border-outline-variant bg-surface transition-[width] duration-200"
|
|
198
315
|
:class="railExpanded ? 'w-[220px]' : 'w-20'"
|
|
@@ -341,6 +458,13 @@ onUnmounted(() => {
|
|
|
341
458
|
|
|
342
459
|
<nav
|
|
343
460
|
class="wnr-panel fixed inset-y-0 left-0 z-10 flex flex-col overflow-hidden rounded-r-lg bg-surface-container shadow-elevation-2"
|
|
461
|
+
:class="hideOnCollapse ? 'w-[220px] touch-pan-y' : ''"
|
|
462
|
+
@pointerdown="onPanelPointerDown"
|
|
463
|
+
@pointermove="onPanelPointerMove"
|
|
464
|
+
@pointerup="onPanelPointerUp"
|
|
465
|
+
@pointercancel="onPanelPointerUp"
|
|
466
|
+
@touchmove="onPanelTouchMove"
|
|
467
|
+
@click.capture="onPanelClickCapture"
|
|
344
468
|
>
|
|
345
469
|
<div v-if="$slots.fab" class="flex shrink-0 flex-col items-start gap-2 px-3 pt-3 pb-2">
|
|
346
470
|
<div class="flex min-h-10 min-w-14 shrink-0 items-center justify-center">
|
|
@@ -348,9 +472,12 @@ onUnmounted(() => {
|
|
|
348
472
|
</div>
|
|
349
473
|
</div>
|
|
350
474
|
|
|
475
|
+
<!-- touch-action stops at the nearest scroll container, so this one needs pan-y of its own or a
|
|
476
|
+
finger landing on an item lets the browser take the horizontal swipe -->
|
|
351
477
|
<div
|
|
352
|
-
class="flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto px-3 py-3"
|
|
478
|
+
class="scrollbar-none flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto px-3 py-3"
|
|
353
479
|
:class="{
|
|
480
|
+
'touch-pan-y': hideOnCollapse,
|
|
354
481
|
'justify-start': alignment === 'top',
|
|
355
482
|
'justify-center': alignment === 'center',
|
|
356
483
|
'justify-end': alignment === 'bottom',
|
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
* @event search Emitted when Enter is pressed in the input, with the current query
|
|
11
11
|
* @event update:expanded Emitted when the expanded state changes — powers v-model:expanded
|
|
12
12
|
*/
|
|
13
|
-
import { computed, ref, watch, onMounted, onUnmounted, nextTick, useId } from 'vue'
|
|
13
|
+
import { computed, inject, ref, watch, onMounted, onUnmounted, nextTick, useId } from 'vue'
|
|
14
14
|
import MIcon from './MIcon.vue'
|
|
15
15
|
import MIconButton from './MIconButton.vue'
|
|
16
16
|
import MSpinner from './MSpinner.vue'
|
|
17
17
|
import { useLocale } from '../composables/useLocale'
|
|
18
|
+
import { searchAppBarKey } from '../composables/_searchAppBar'
|
|
18
19
|
|
|
19
20
|
// Root is a fragment (bar div + a sibling Teleport for the expanded overlay panel), so Vue
|
|
20
21
|
// can't auto-apply a consumer's class/attrs to either one — forward them onto the bar div below.
|
|
@@ -30,8 +31,10 @@ const props = withDefaults(
|
|
|
30
31
|
placeholder?: string
|
|
31
32
|
/** 'docked' grows into a rounded panel anchored below the bar (default).
|
|
32
33
|
* 'fullscreen' takes over the whole viewport, matching M3's mobile
|
|
33
|
-
* search pattern — the leading icon becomes a back button either way.
|
|
34
|
-
|
|
34
|
+
* search pattern — the leading icon becomes a back button either way.
|
|
35
|
+
* 'fullscreen-contained' (M3 Expressive's ExpandedFullScreenContainedSearchBar) also takes the whole
|
|
36
|
+
* viewport, on surface-container-low, but keeps the input in its pill shape, with no divider. */
|
|
37
|
+
variant?: 'docked' | 'fullscreen' | 'fullscreen-contained'
|
|
35
38
|
/** Icon shown in the collapsed bar */
|
|
36
39
|
leadingIcon?: string
|
|
37
40
|
/** Which side of the *collapsed* bar the leading icon sits on. The
|
|
@@ -68,6 +71,10 @@ const emit = defineEmits<{
|
|
|
68
71
|
|
|
69
72
|
const locale = useLocale()
|
|
70
73
|
const id = useId()
|
|
74
|
+
const fullscreen = computed(() => props.variant !== 'docked')
|
|
75
|
+
const contained = computed(() => props.variant === 'fullscreen-contained')
|
|
76
|
+
// Inside an MAppBarWithSearch the bar is flat and darkens when content scrolls under the app bar
|
|
77
|
+
const appBar = inject(searchAppBarKey, null)
|
|
71
78
|
|
|
72
79
|
const expanded = ref(props.expanded ?? false)
|
|
73
80
|
watch(
|
|
@@ -140,7 +147,7 @@ onUnmounted(() => {
|
|
|
140
147
|
})
|
|
141
148
|
|
|
142
149
|
watch(expanded, (v) => {
|
|
143
|
-
if (v &&
|
|
150
|
+
if (v && fullscreen.value) document.body.style.overflow = 'hidden'
|
|
144
151
|
else document.body.style.overflow = ''
|
|
145
152
|
})
|
|
146
153
|
onUnmounted(() => { document.body.style.overflow = '' })
|
|
@@ -150,8 +157,12 @@ onUnmounted(() => { document.body.style.overflow = '' })
|
|
|
150
157
|
<div ref="barEl" class="relative w-full" v-bind="$attrs">
|
|
151
158
|
<div
|
|
152
159
|
v-show="!expanded"
|
|
153
|
-
class="flex h-14 items-center gap-3 rounded-full
|
|
154
|
-
:class="
|
|
160
|
+
class="flex h-14 items-center gap-3 rounded-full px-4 transition-[box-shadow,background-color] duration-150 focus-within:outline focus-within:outline-2 focus-within:outline-secondary focus-within:-outline-offset-2"
|
|
161
|
+
:class="[
|
|
162
|
+
disabled ? 'pointer-events-none opacity-[0.38]' : '',
|
|
163
|
+
appBar?.scrolled.value ? 'bg-surface-container-highest' : 'bg-surface-container-high',
|
|
164
|
+
appBar ? '' : 'shadow-elevation-3',
|
|
165
|
+
]"
|
|
155
166
|
>
|
|
156
167
|
<span class="inline-flex shrink-0 items-center" :class="iconPosition === 'end' ? 'order-last' : ''">
|
|
157
168
|
<slot name="leading">
|
|
@@ -185,17 +196,22 @@ onUnmounted(() => { document.body.style.overflow = '' })
|
|
|
185
196
|
</div>
|
|
186
197
|
|
|
187
198
|
<Teleport to="body">
|
|
188
|
-
<Transition :name="
|
|
199
|
+
<Transition :name="fullscreen ? 'm3-searchbar-full' : 'm3-searchbar-docked'">
|
|
189
200
|
<div
|
|
190
201
|
v-if="expanded"
|
|
191
202
|
ref="panelEl"
|
|
192
|
-
class="fixed z-500 flex flex-col overflow-hidden
|
|
193
|
-
:class="
|
|
203
|
+
class="fixed z-500 flex flex-col overflow-hidden"
|
|
204
|
+
:class="[
|
|
205
|
+
fullscreen ? 'inset-0' : 'max-h-[70vh] rounded-[28px] shadow-elevation-3',
|
|
206
|
+
contained ? 'bg-surface-container-low' : 'bg-surface-container-high',
|
|
207
|
+
]"
|
|
194
208
|
:style="variant === 'docked' ? panelPos : undefined"
|
|
195
209
|
>
|
|
210
|
+
<!-- Contained: the input keeps the collapsed pill (collapsedContainedSearchBarColor), 8dp from the
|
|
211
|
+
sides, 4dp from the top and 8dp above the results (FullScreenSearchBarLayout's isContained) -->
|
|
196
212
|
<div
|
|
197
|
-
class="flex shrink-0 items-center gap-3
|
|
198
|
-
:class="variant === 'fullscreen' ? 'h-[72px]' : 'h-14'"
|
|
213
|
+
class="flex shrink-0 items-center gap-3"
|
|
214
|
+
:class="contained ? 'mx-2 mt-1 mb-2 h-14 rounded-full bg-surface-container-high px-1' : variant === 'fullscreen' ? 'h-[72px] px-4' : 'h-14 px-4'"
|
|
199
215
|
>
|
|
200
216
|
<MIconButton
|
|
201
217
|
icon="arrow_back"
|
|
@@ -227,7 +243,7 @@ onUnmounted(() => { document.body.style.overflow = '' })
|
|
|
227
243
|
<slot name="trailing" />
|
|
228
244
|
</div>
|
|
229
245
|
|
|
230
|
-
<div class="h-px shrink-0 bg-outline" />
|
|
246
|
+
<div v-if="!contained" class="h-px shrink-0 bg-outline" />
|
|
231
247
|
|
|
232
248
|
<div class="flex-1 overflow-y-auto">
|
|
233
249
|
<slot />
|