@m3ui-vue/m3ui-vue 0.6.3 → 0.7.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 +12 -6
- package/dist/{MMenuItem-C7jKU-Qh.js → MMenuItem-B_5um6tj.js} +2 -2
- package/dist/{MMenuItem-C7jKU-Qh.js.map → MMenuItem-B_5um6tj.js.map} +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MFab.vue.d.ts +24 -2
- package/dist/components/MFabMenu.vue.d.ts +37 -0
- package/dist/components/MLoadingIndicator.vue.d.ts +13 -0
- package/dist/components/MPullToRefresh.vue.d.ts +30 -0
- package/dist/components/MSearchBar.vue.d.ts +57 -0
- package/dist/components/MTopAppBar.vue.d.ts +4 -0
- package/dist/composables/useLocale.d.ts +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/locales/index.js +7 -0
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +1257 -770
- package/dist/m3ui.js.map +1 -1
- package/dist/rich-text-editor.js +2 -2
- package/dist/styles.css +1 -1
- package/dist/{useLocale-BKsIWNix.js → useLocale-DbREg9Zn.js} +2 -1
- package/dist/useLocale-DbREg9Zn.js.map +1 -0
- package/package.json +1 -1
- package/src/components/MFab.vue +63 -10
- package/src/components/MFabMenu.vue +167 -0
- package/src/components/MLoadingIndicator.vue +184 -0
- package/src/components/MPullToRefresh.vue +180 -0
- package/src/components/MSearchBar.vue +237 -0
- package/src/components/MSlider.vue +82 -33
- package/src/components/MTabs.vue +72 -33
- package/src/components/MTopAppBar.vue +16 -8
- package/src/composables/useLocale.ts +2 -0
- package/src/index.ts +5 -0
- package/src/locales/de.ts +1 -0
- package/src/locales/es.ts +1 -0
- package/src/locales/fr.ts +1 -0
- package/src/locales/ja.ts +1 -0
- package/src/locales/ko.ts +1 -0
- package/src/locales/pt.ts +1 -0
- package/src/locales/zh.ts +1 -0
- package/dist/useLocale-BKsIWNix.js.map +0 -1
|
@@ -234,21 +234,74 @@ function fillInactiveSize(pct: number) {
|
|
|
234
234
|
return `calc(100% - ${clampedPos(pct)} - ${gap.value}px)`
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
+
// Range & centered variants: same fix as above — any fill edge that sits at a
|
|
238
|
+
// real draggable thumb must anchor to its clamped (thumbInset-aware) position,
|
|
239
|
+
// not the raw pct, or the fill creeps past a thumb pinned near 0%/100% and
|
|
240
|
+
// swallows the gap that's supposed to stay visible there.
|
|
241
|
+
|
|
242
|
+
// Range: both pctLo and pctHi are thumbs.
|
|
243
|
+
function rangeInactiveBeforeSize() {
|
|
244
|
+
return `calc(${clampedPos(pctLo.value)} - ${gap.value}px)`
|
|
245
|
+
}
|
|
246
|
+
function rangeActiveStart() {
|
|
247
|
+
return `calc(${clampedPos(pctLo.value)} + ${gap.value}px)`
|
|
248
|
+
}
|
|
249
|
+
function rangeActiveSize() {
|
|
250
|
+
return `calc(${clampedPos(pctHi.value)} - ${clampedPos(pctLo.value)} - ${gap.value * 2}px)`
|
|
251
|
+
}
|
|
252
|
+
function rangeInactiveAfterSize() {
|
|
253
|
+
return `calc(100% - ${clampedPos(pctHi.value)} - ${gap.value}px)`
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Centered: only pctLo is a thumb — centerPct is a fixed anchor, never inset.
|
|
257
|
+
function centeredActiveStart() {
|
|
258
|
+
return pctLo.value >= centerPct.value
|
|
259
|
+
? `${centerPct.value}%`
|
|
260
|
+
: `calc(${clampedPos(pctLo.value)} + ${gap.value}px)`
|
|
261
|
+
}
|
|
262
|
+
function centeredActiveSize() {
|
|
263
|
+
return pctLo.value >= centerPct.value
|
|
264
|
+
? `calc(${clampedPos(pctLo.value)} - ${centerPct.value}% - ${gap.value}px)`
|
|
265
|
+
: `calc(${centerPct.value}% - ${clampedPos(pctLo.value)} - ${gap.value}px)`
|
|
266
|
+
}
|
|
267
|
+
function centeredFarInactiveSize() {
|
|
268
|
+
return pctLo.value >= centerPct.value
|
|
269
|
+
? `calc(100% - ${clampedPos(pctLo.value)} - ${gap.value}px)`
|
|
270
|
+
: `calc(100% - ${centerPct.value}% - ${gap.value}px)`
|
|
271
|
+
}
|
|
272
|
+
function centeredNearInactiveSize() {
|
|
273
|
+
return pctLo.value <= centerPct.value
|
|
274
|
+
? `calc(${clampedPos(pctLo.value)} - ${gap.value}px)`
|
|
275
|
+
: `calc(${centerPct.value}% - ${gap.value}px)`
|
|
276
|
+
}
|
|
277
|
+
|
|
237
278
|
const r = computed(() => s.value.radius)
|
|
238
279
|
const smallR = computed(() => Math.max(2, r.value / 4))
|
|
280
|
+
// Outer track-end corners: the original `r` shape-scale token, just a touch
|
|
281
|
+
// softer/rounder than the plain token value.
|
|
282
|
+
const fullR = computed(() => r.value * 1.3)
|
|
283
|
+
|
|
284
|
+
// A segment bounded by a gap on *both* sides — range's middle (active)
|
|
285
|
+
// segment between the two thumbs, and centered's active segment (its far
|
|
286
|
+
// side sits at the fixed center junction, its near side at the thumb gap;
|
|
287
|
+
// it never touches a real track end since the near/far inactive segments
|
|
288
|
+
// always cover those) — goes square on every corner, never a rounded cap.
|
|
289
|
+
function pillRadiusSquareBoth() {
|
|
290
|
+
return `${smallR.value}px`
|
|
291
|
+
}
|
|
239
292
|
|
|
240
|
-
//
|
|
241
|
-
//
|
|
242
|
-
//
|
|
293
|
+
// The pill's outer end (away from the thumb/gap) stays a full stadium cap;
|
|
294
|
+
// the end facing a thumb-gap goes square, matching the official M3 slider's
|
|
295
|
+
// track segments.
|
|
243
296
|
function pillRadiusOuterStart() {
|
|
244
297
|
return isVertical.value
|
|
245
|
-
? `${smallR.value}px ${smallR.value}px ${
|
|
246
|
-
: `${
|
|
298
|
+
? `${smallR.value}px ${smallR.value}px ${fullR.value}px ${fullR.value}px`
|
|
299
|
+
: `${fullR.value}px ${smallR.value}px ${smallR.value}px ${fullR.value}px`
|
|
247
300
|
}
|
|
248
301
|
function pillRadiusOuterEnd() {
|
|
249
302
|
return isVertical.value
|
|
250
|
-
? `${
|
|
251
|
-
: `${smallR.value}px ${
|
|
303
|
+
? `${fullR.value}px ${fullR.value}px ${smallR.value}px ${smallR.value}px`
|
|
304
|
+
: `${smallR.value}px ${fullR.value}px ${fullR.value}px ${smallR.value}px`
|
|
252
305
|
}
|
|
253
306
|
const nd = computed(() => dragging.value === false)
|
|
254
307
|
const tr = computed(() => nd.value ? '75ms ease' : '0s')
|
|
@@ -373,8 +426,8 @@ const tooltipPct = computed(() => {
|
|
|
373
426
|
<div
|
|
374
427
|
class="absolute"
|
|
375
428
|
:style="isVertical
|
|
376
|
-
? { left: '50%', top: '0', bottom: '0', width: `${s.track}px`, transform: 'translateX(-50%)', borderRadius: `${
|
|
377
|
-
: { top: '50%', left: '0', right: '0', height: `${s.track}px`, transform: 'translateY(-50%)', borderRadius: `${
|
|
429
|
+
? { left: '50%', top: '0', bottom: '0', width: `${s.track}px`, transform: 'translateX(-50%)', borderRadius: `${fullR}px` }
|
|
430
|
+
: { top: '50%', left: '0', right: '0', height: `${s.track}px`, transform: 'translateY(-50%)', borderRadius: `${fullR}px` }
|
|
378
431
|
"
|
|
379
432
|
>
|
|
380
433
|
<!-- Standard: active from left/bottom -->
|
|
@@ -397,58 +450,54 @@ const tooltipPct = computed(() => {
|
|
|
397
450
|
|
|
398
451
|
<!-- Centered: active from center -->
|
|
399
452
|
<template v-else-if="variant === 'centered'">
|
|
400
|
-
<!-- Active: from center to thumb (
|
|
453
|
+
<!-- Active: from center to thumb (thumb edge uses its clamped position) -->
|
|
401
454
|
<div class="absolute" :style="{
|
|
402
455
|
...(isVertical
|
|
403
|
-
?
|
|
404
|
-
|
|
405
|
-
: { left: 0, right: 0, bottom: `calc(${pctLo}% + ${gap}px)`, height: `calc(${centerPct - pctLo}% - ${gap}px)` }
|
|
406
|
-
: pctLo >= centerPct
|
|
407
|
-
? { top: 0, bottom: 0, left: `${centerPct}%`, width: `calc(${pctLo - centerPct}% - ${gap}px)` }
|
|
408
|
-
: { top: 0, bottom: 0, left: `calc(${pctLo}% + ${gap}px)`, width: `calc(${centerPct - pctLo}% - ${gap}px)` }
|
|
456
|
+
? { left: 0, right: 0, bottom: centeredActiveStart(), height: centeredActiveSize() }
|
|
457
|
+
: { top: 0, bottom: 0, left: centeredActiveStart(), width: centeredActiveSize() }
|
|
409
458
|
),
|
|
410
|
-
borderRadius:
|
|
459
|
+
borderRadius: pillRadiusSquareBoth(), backgroundColor: ct.active, transition: `all ${tr}`,
|
|
411
460
|
}" />
|
|
412
461
|
<!-- Inactive: above/right of thumb -->
|
|
413
462
|
<div class="absolute" :style="{
|
|
414
463
|
...(isVertical
|
|
415
|
-
? { left: 0, right: 0, top: 0, height:
|
|
416
|
-
: { top: 0, bottom: 0, right: 0, width:
|
|
464
|
+
? { left: 0, right: 0, top: 0, height: centeredFarInactiveSize() }
|
|
465
|
+
: { top: 0, bottom: 0, right: 0, width: centeredFarInactiveSize() }
|
|
417
466
|
),
|
|
418
|
-
borderRadius:
|
|
467
|
+
borderRadius: pillRadiusOuterEnd(), backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
419
468
|
}" />
|
|
420
469
|
<!-- Inactive: below/left of thumb -->
|
|
421
470
|
<div class="absolute" :style="{
|
|
422
471
|
...(isVertical
|
|
423
|
-
? { left: 0, right: 0, bottom: 0, height:
|
|
424
|
-
: { top: 0, bottom: 0, left: 0, width:
|
|
472
|
+
? { left: 0, right: 0, bottom: 0, height: centeredNearInactiveSize() }
|
|
473
|
+
: { top: 0, bottom: 0, left: 0, width: centeredNearInactiveSize() }
|
|
425
474
|
),
|
|
426
|
-
borderRadius:
|
|
475
|
+
borderRadius: pillRadiusOuterStart(), backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
427
476
|
}" />
|
|
428
477
|
</template>
|
|
429
478
|
|
|
430
|
-
<!-- Range: active between thumbs -->
|
|
479
|
+
<!-- Range: active between thumbs (both edges use their clamped position) -->
|
|
431
480
|
<template v-else-if="variant === 'range'">
|
|
432
481
|
<div class="absolute" :style="{
|
|
433
482
|
...(isVertical
|
|
434
|
-
? { left: 0, right: 0, bottom: 0, height:
|
|
435
|
-
: { top: 0, bottom: 0, left: 0, width:
|
|
483
|
+
? { left: 0, right: 0, bottom: 0, height: rangeInactiveBeforeSize() }
|
|
484
|
+
: { top: 0, bottom: 0, left: 0, width: rangeInactiveBeforeSize() }
|
|
436
485
|
),
|
|
437
|
-
borderRadius:
|
|
486
|
+
borderRadius: pillRadiusOuterStart(), backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
438
487
|
}" />
|
|
439
488
|
<div class="absolute" :style="{
|
|
440
489
|
...(isVertical
|
|
441
|
-
? { left: 0, right: 0, bottom:
|
|
442
|
-
: { top: 0, bottom: 0, left:
|
|
490
|
+
? { left: 0, right: 0, bottom: rangeActiveStart(), height: rangeActiveSize() }
|
|
491
|
+
: { top: 0, bottom: 0, left: rangeActiveStart(), width: rangeActiveSize() }
|
|
443
492
|
),
|
|
444
|
-
borderRadius:
|
|
493
|
+
borderRadius: pillRadiusSquareBoth(), backgroundColor: ct.active, transition: `all ${tr}`,
|
|
445
494
|
}" />
|
|
446
495
|
<div class="absolute" :style="{
|
|
447
496
|
...(isVertical
|
|
448
|
-
? { left: 0, right: 0, top: 0, height:
|
|
449
|
-
: { top: 0, bottom: 0, right: 0, width:
|
|
497
|
+
? { left: 0, right: 0, top: 0, height: rangeInactiveAfterSize() }
|
|
498
|
+
: { top: 0, bottom: 0, right: 0, width: rangeInactiveAfterSize() }
|
|
450
499
|
),
|
|
451
|
-
borderRadius:
|
|
500
|
+
borderRadius: pillRadiusOuterEnd(), backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
452
501
|
}" />
|
|
453
502
|
</template>
|
|
454
503
|
|
package/src/components/MTabs.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { nextTick, onMounted, ref, watch } from 'vue'
|
|
2
|
+
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
3
3
|
import MIcon from './MIcon.vue'
|
|
4
4
|
|
|
5
5
|
interface Tab {
|
|
@@ -20,8 +20,6 @@ const emit = defineEmits<{ 'update:modelValue': [string | number] }>()
|
|
|
20
20
|
const tabEls = ref<HTMLElement[]>([])
|
|
21
21
|
const indicatorLeft = ref(0)
|
|
22
22
|
const indicatorWidth = ref(0)
|
|
23
|
-
const stretching = ref(false)
|
|
24
|
-
let stretchTimer: ReturnType<typeof setTimeout> | null = null
|
|
25
23
|
|
|
26
24
|
function getTabRect(index: number) {
|
|
27
25
|
const el = tabEls.value[index]
|
|
@@ -29,6 +27,55 @@ function getTabRect(index: number) {
|
|
|
29
27
|
return { left: el.offsetLeft, width: el.offsetWidth }
|
|
30
28
|
}
|
|
31
29
|
|
|
30
|
+
// Ported from androidx.compose.material3.TabRow's TabIndicatorOffsetNode: the
|
|
31
|
+
// offset and width are two *independent* springs (same spec for both — M3's
|
|
32
|
+
// DefaultSpatial motion token: dampingRatio 0.9, stiffness 700), not a single
|
|
33
|
+
// choreographed "stretch then snap". The stretch look emerges on its own
|
|
34
|
+
// from the two springs covering different distances under identical
|
|
35
|
+
// physics, and retargeting mid-flight (rapid tab switching) stays smooth
|
|
36
|
+
// since velocity carries over — a real spring simulation, not a CSS
|
|
37
|
+
// transition, is what makes that possible.
|
|
38
|
+
const DAMPING = 0.9
|
|
39
|
+
const STIFFNESS = 700
|
|
40
|
+
const DAMPING_COEF = 2 * DAMPING * Math.sqrt(STIFFNESS)
|
|
41
|
+
|
|
42
|
+
let offsetPos = 0, offsetVel = 0, offsetTarget = 0
|
|
43
|
+
let widthPos = 0, widthVel = 0, widthTarget = 0
|
|
44
|
+
let rafId = 0
|
|
45
|
+
let lastTime = 0
|
|
46
|
+
|
|
47
|
+
function stepSpring(pos: number, vel: number, target: number, dt: number): [number, number] {
|
|
48
|
+
const accel = -STIFFNESS * (pos - target) - DAMPING_COEF * vel
|
|
49
|
+
const newVel = vel + accel * dt
|
|
50
|
+
return [pos + newVel * dt, newVel]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function tick(now: number) {
|
|
54
|
+
const dt = Math.min((now - lastTime) / 1000, 1 / 30)
|
|
55
|
+
lastTime = now
|
|
56
|
+
;[offsetPos, offsetVel] = stepSpring(offsetPos, offsetVel, offsetTarget, dt)
|
|
57
|
+
;[widthPos, widthVel] = stepSpring(widthPos, widthVel, widthTarget, dt)
|
|
58
|
+
indicatorLeft.value = offsetPos
|
|
59
|
+
indicatorWidth.value = widthPos
|
|
60
|
+
|
|
61
|
+
const settled =
|
|
62
|
+
Math.abs(offsetPos - offsetTarget) < 0.5 && Math.abs(offsetVel) < 0.5 &&
|
|
63
|
+
Math.abs(widthPos - widthTarget) < 0.5 && Math.abs(widthVel) < 0.5
|
|
64
|
+
if (settled) {
|
|
65
|
+
offsetPos = offsetTarget; widthPos = widthTarget
|
|
66
|
+
indicatorLeft.value = offsetPos; indicatorWidth.value = widthPos
|
|
67
|
+
rafId = 0
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
rafId = requestAnimationFrame(tick)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function ensureRaf() {
|
|
74
|
+
if (rafId) return
|
|
75
|
+
lastTime = performance.now()
|
|
76
|
+
rafId = requestAnimationFrame(tick)
|
|
77
|
+
}
|
|
78
|
+
|
|
32
79
|
function updateIndicator(animate = true) {
|
|
33
80
|
nextTick(() => {
|
|
34
81
|
const idx = props.tabs.findIndex((t) => t.value === props.modelValue)
|
|
@@ -37,35 +84,33 @@ function updateIndicator(animate = true) {
|
|
|
37
84
|
|
|
38
85
|
if (props.variant === 'primary') {
|
|
39
86
|
const inset = Math.min(rect.width * 0.2, 16)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
stretchTimer = setTimeout(() => {
|
|
50
|
-
stretching.value = false
|
|
51
|
-
indicatorLeft.value = newLeft
|
|
52
|
-
indicatorWidth.value = newRight - newLeft
|
|
53
|
-
}, 150)
|
|
54
|
-
} else {
|
|
55
|
-
const insetLeft = rect.left + inset
|
|
56
|
-
indicatorLeft.value = insetLeft
|
|
57
|
-
indicatorWidth.value = rect.width - inset * 2
|
|
58
|
-
}
|
|
87
|
+
offsetTarget = rect.left + inset
|
|
88
|
+
widthTarget = rect.width - inset * 2
|
|
89
|
+
} else {
|
|
90
|
+
offsetTarget = rect.left
|
|
91
|
+
widthTarget = rect.width
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (animate) {
|
|
95
|
+
ensureRaf()
|
|
59
96
|
} else {
|
|
60
|
-
|
|
61
|
-
|
|
97
|
+
offsetPos = offsetTarget; offsetVel = 0
|
|
98
|
+
widthPos = widthTarget; widthVel = 0
|
|
99
|
+
indicatorLeft.value = offsetPos
|
|
100
|
+
indicatorWidth.value = widthPos
|
|
62
101
|
}
|
|
63
102
|
})
|
|
64
103
|
}
|
|
65
104
|
|
|
66
105
|
onMounted(() => updateIndicator(false))
|
|
106
|
+
onUnmounted(() => { if (rafId) cancelAnimationFrame(rafId) })
|
|
67
107
|
watch(() => props.modelValue, () => updateIndicator(true))
|
|
68
|
-
|
|
108
|
+
// Animated (not a hard snap) here too: a consumer passing an inline `:tabs="[...]"`
|
|
109
|
+
// literal gets a brand-new array reference on every unrelated parent re-render,
|
|
110
|
+
// which would otherwise race with — and instantly override — an in-flight
|
|
111
|
+
// modelValue-triggered animation. Re-running the same animated update is a
|
|
112
|
+
// no-op when the target hasn't actually moved, so this is safe either way.
|
|
113
|
+
watch(() => props.tabs, () => updateIndicator(true), { deep: true })
|
|
69
114
|
|
|
70
115
|
function select(tab: Tab) {
|
|
71
116
|
if (!tab.disabled) emit('update:modelValue', tab.value)
|
|
@@ -98,13 +143,7 @@ function select(tab: Tab) {
|
|
|
98
143
|
</button>
|
|
99
144
|
<div
|
|
100
145
|
class="absolute bottom-0 h-[3px] rounded-t-full bg-primary"
|
|
101
|
-
:style="{
|
|
102
|
-
left: `${indicatorLeft}px`,
|
|
103
|
-
width: `${indicatorWidth}px`,
|
|
104
|
-
transition: stretching
|
|
105
|
-
? 'left 150ms cubic-bezier(0.4, 0, 0.2, 1), width 150ms cubic-bezier(0.4, 0, 0.2, 1)'
|
|
106
|
-
: 'left 180ms cubic-bezier(0.34, 1.4, 0.64, 1), width 180ms cubic-bezier(0.34, 1.4, 0.64, 1)',
|
|
107
|
-
}"
|
|
146
|
+
:style="{ left: `${indicatorLeft}px`, width: `${indicatorWidth}px` }"
|
|
108
147
|
/>
|
|
109
148
|
</div>
|
|
110
149
|
</div>
|
|
@@ -132,7 +171,7 @@ function select(tab: Tab) {
|
|
|
132
171
|
{{ tab.label }}
|
|
133
172
|
</button>
|
|
134
173
|
<div
|
|
135
|
-
class="absolute bottom-0 h-[2px] bg-primary
|
|
174
|
+
class="absolute bottom-0 h-[2px] bg-primary"
|
|
136
175
|
:style="{ left: `${indicatorLeft}px`, width: `${indicatorWidth}px` }"
|
|
137
176
|
/>
|
|
138
177
|
</div>
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import MIcon from './MIcon.vue'
|
|
3
2
|
import MIconButton from './MIconButton.vue'
|
|
3
|
+
import { useLocale } from '../composables/useLocale'
|
|
4
4
|
|
|
5
5
|
withDefaults(defineProps<{
|
|
6
6
|
title?: string
|
|
7
7
|
variant?: 'center' | 'small' | 'medium' | 'large'
|
|
8
8
|
navigationIcon?: string
|
|
9
|
+
/** Accessible label for the navigation icon button — defaults to the
|
|
10
|
+
* locale's generic "Menu" label; override when navigationIcon is
|
|
11
|
+
* actually a back arrow rather than a drawer toggle. */
|
|
12
|
+
navigationLabel?: string
|
|
9
13
|
elevated?: boolean
|
|
10
14
|
bordered?: boolean
|
|
11
15
|
}>(), { variant: 'small' })
|
|
12
16
|
|
|
13
17
|
defineEmits<{ navigation: [] }>()
|
|
18
|
+
|
|
19
|
+
const locale = useLocale()
|
|
14
20
|
</script>
|
|
15
21
|
|
|
16
22
|
<template>
|
|
@@ -18,14 +24,14 @@ defineEmits<{ navigation: [] }>()
|
|
|
18
24
|
class="flex w-full flex-col bg-surface transition-shadow"
|
|
19
25
|
:class="[elevated ? 'shadow-elevation-2' : '', bordered ? 'border-b border-outline-variant' : '']"
|
|
20
26
|
>
|
|
21
|
-
<!-- Top row -->
|
|
22
|
-
<div class="flex h-16 items-center gap-1 px-4">
|
|
27
|
+
<!-- Top row — 64dp per M3's TopAppBarSmall/collapsed-Medium/collapsed-Large tokens -->
|
|
28
|
+
<div class="flex h-16 shrink-0 items-center gap-1 px-4">
|
|
23
29
|
<!-- Navigation -->
|
|
24
30
|
<slot name="navigation">
|
|
25
31
|
<MIconButton
|
|
26
32
|
v-if="navigationIcon"
|
|
27
33
|
:icon="navigationIcon"
|
|
28
|
-
label="
|
|
34
|
+
:label="navigationLabel ?? locale.menu"
|
|
29
35
|
@click="$emit('navigation')"
|
|
30
36
|
/>
|
|
31
37
|
</slot>
|
|
@@ -48,14 +54,16 @@ defineEmits<{ navigation: [] }>()
|
|
|
48
54
|
</div>
|
|
49
55
|
</div>
|
|
50
56
|
|
|
51
|
-
<!-- Large title row for medium/large variants
|
|
57
|
+
<!-- Large title row for medium/large variants — total container height
|
|
58
|
+
112dp (medium) / 152dp (large) per M3's AppBarMedium/LargeTokens,
|
|
59
|
+
i.e. 48px / 88px added below the 64px top row. -->
|
|
52
60
|
<div
|
|
53
61
|
v-if="variant === 'medium' || variant === 'large'"
|
|
54
|
-
class="px-4 pb-
|
|
55
|
-
:class="variant === 'large' ? '
|
|
62
|
+
class="flex items-end px-4 pb-3"
|
|
63
|
+
:class="variant === 'large' ? 'h-[88px]' : 'h-12'"
|
|
56
64
|
>
|
|
57
65
|
<h1
|
|
58
|
-
class="text-on-surface"
|
|
66
|
+
class="truncate text-on-surface"
|
|
59
67
|
:class="variant === 'large' ? 'text-headline-medium' : 'text-headline-small'"
|
|
60
68
|
>
|
|
61
69
|
<slot name="title">{{ title }}</slot>
|
|
@@ -11,6 +11,7 @@ export interface M3Locale {
|
|
|
11
11
|
cancel: string
|
|
12
12
|
confirm: string
|
|
13
13
|
loading: string
|
|
14
|
+
menu: string
|
|
14
15
|
|
|
15
16
|
// Navigation
|
|
16
17
|
previous: string
|
|
@@ -111,6 +112,7 @@ export const defaultLocale: M3Locale = {
|
|
|
111
112
|
search: 'Search...',
|
|
112
113
|
noResults: 'No results',
|
|
113
114
|
close: 'Close',
|
|
115
|
+
menu: 'Menu',
|
|
114
116
|
cancel: 'Cancel',
|
|
115
117
|
confirm: 'Confirm',
|
|
116
118
|
loading: 'Loading',
|
package/src/index.ts
CHANGED
|
@@ -65,6 +65,7 @@ export { default as MEmptyState } from './components/MEmptyState.vue'
|
|
|
65
65
|
export { default as MExpansionPanel } from './components/MExpansionPanel.vue'
|
|
66
66
|
export { default as MExportButton } from './components/MExportButton.vue'
|
|
67
67
|
export { default as MFab } from './components/MFab.vue'
|
|
68
|
+
export { default as MFabMenu } from './components/MFabMenu.vue'
|
|
68
69
|
export { default as MFileUpload } from './components/MFileUpload.vue'
|
|
69
70
|
export { default as MFixed } from './components/MFixed.vue'
|
|
70
71
|
export { default as MFooter } from './components/MFooter.vue'
|
|
@@ -84,6 +85,7 @@ export type { LightboxItem } from './components/MLightbox.vue'
|
|
|
84
85
|
export { default as MList } from './components/MList.vue'
|
|
85
86
|
export { default as MListItem } from './components/MListItem.vue'
|
|
86
87
|
export { default as MListSubheader } from './components/MListSubheader.vue'
|
|
88
|
+
export { default as MLoadingIndicator } from './components/MLoadingIndicator.vue'
|
|
87
89
|
export { default as MLoadingOverlay } from './components/MLoadingOverlay.vue'
|
|
88
90
|
// MMarkdown — import from '@m3ui-vue/m3ui-vue/markdown'
|
|
89
91
|
export { default as MMasonry } from './components/MMasonry.vue'
|
|
@@ -104,6 +106,7 @@ export { default as MPageProgress } from './components/MPageProgress.vue'
|
|
|
104
106
|
export { default as MPagination } from './components/MPagination.vue'
|
|
105
107
|
export { default as MPasswordMeter } from './components/MPasswordMeter.vue'
|
|
106
108
|
export { default as MPinInput } from './components/MPinInput.vue'
|
|
109
|
+
export { default as MPullToRefresh } from './components/MPullToRefresh.vue'
|
|
107
110
|
export { default as MProgressBar } from './components/MProgressBar.vue'
|
|
108
111
|
export { default as MCircleProgressBar } from './components/MCircleProgressBar.vue'
|
|
109
112
|
export { default as MRadio } from './components/MRadio.vue'
|
|
@@ -116,6 +119,7 @@ export { default as MResult } from './components/MResult.vue'
|
|
|
116
119
|
// MRichTextEditor — import from '@m3ui-vue/m3ui-vue/rich-text-editor'
|
|
117
120
|
export { default as MScheduler } from './components/MScheduler.vue'
|
|
118
121
|
export { default as MScrollable } from './components/MScrollable.vue'
|
|
122
|
+
export { default as MSearchBar } from './components/MSearchBar.vue'
|
|
119
123
|
export { default as MSection } from './components/MSection.vue'
|
|
120
124
|
export { default as MSegmentedButton } from './components/MSegmentedButton.vue'
|
|
121
125
|
export { default as MSelect } from './components/MSelect.vue'
|
|
@@ -175,6 +179,7 @@ export type { KanbanColumn, KanbanCard } from './components/MKanban.vue'
|
|
|
175
179
|
export type { NavBarItem } from './components/MNavigationBar.vue'
|
|
176
180
|
export type { DrawerItem, DrawerSection } from './components/MNavigationDrawer.vue'
|
|
177
181
|
export type { SpeedDialItem } from './components/MFab.vue'
|
|
182
|
+
export type { FabMenuItem } from './components/MFabMenu.vue'
|
|
178
183
|
export type { NavRailItem } from './components/MNavigationRail.vue'
|
|
179
184
|
export type { SchedulerEvent } from './components/MScheduler.vue'
|
|
180
185
|
export type { SegmentedOption } from './components/MSegmentedButton.vue'
|
package/src/locales/de.ts
CHANGED
package/src/locales/es.ts
CHANGED
package/src/locales/fr.ts
CHANGED
package/src/locales/ja.ts
CHANGED
package/src/locales/ko.ts
CHANGED
package/src/locales/pt.ts
CHANGED
package/src/locales/zh.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale-BKsIWNix.js","names":[],"sources":["../src/composables/useLocale.ts"],"sourcesContent":["import { inject, reactive, watchEffect, toValue, type InjectionKey, type MaybeRef } from 'vue'\n\nexport interface M3Locale {\n /** BCP-47 language tag (e.g. 'en', 'es', 'pt') — read by locale-aware components (MRelativeTime) that use Intl formatting. */\n lang: string\n\n // Common\n search: string\n noResults: string\n close: string\n cancel: string\n confirm: string\n loading: string\n\n // Navigation\n previous: string\n next: string\n today: string\n more: string\n\n // Tables\n selectedCount: string\n recordCount: string\n expand: string\n columns: string\n exportCsv: string\n noGroup: string\n\n // Tour\n finish: string\n\n // File upload\n dropText: string\n selectText: string\n maxSizePrefix: string\n remove: string\n\n // Pickers\n selectDate: string\n selectTime: string\n selectRange: string\n pickStart: string\n pickEnd: string\n previousMonth: string\n nextMonth: string\n\n // Scheduler\n dayView: string\n weekView: string\n\n // Transfer list\n available: string\n selected: string\n noItems: string\n moveAllRight: string\n moveRight: string\n moveLeft: string\n moveAllLeft: string\n\n // Command palette / Spotlight\n searchCommand: string\n navigateHint: string\n selectHint: string\n openHint: string\n closeHint: string\n\n // Infinite scroll\n loadingMore: string\n noMoreItems: string\n\n // Rich text editor\n bold: string\n italic: string\n underline: string\n strikethrough: string\n highlight: string\n bulletList: string\n orderedList: string\n blockquote: string\n code: string\n alignLeft: string\n alignCenter: string\n alignRight: string\n undo: string\n redo: string\n link: string\n image: string\n paragraph: string\n heading1: string\n heading2: string\n heading3: string\n insertLink: string\n insertImage: string\n imageUrlLabel: string\n insert: string\n\n // JSON editor\n jsonValid: string\n jsonInvalid: string\n jsonFormat: string\n jsonMinify: string\n\n // JSON viewer\n jsonElements: string\n jsonFields: string\n}\n\nexport const defaultLocale: M3Locale = {\n lang: 'en',\n\n search: 'Search...',\n noResults: 'No results',\n close: 'Close',\n cancel: 'Cancel',\n confirm: 'Confirm',\n loading: 'Loading',\n\n previous: 'Previous',\n next: 'Next',\n today: 'Today',\n more: 'more',\n\n selectedCount: 'selected',\n recordCount: 'record',\n expand: 'Expand',\n columns: 'Columns',\n exportCsv: 'Export CSV',\n noGroup: 'No group',\n\n finish: 'Finish',\n\n dropText: 'Drop files here or',\n selectText: 'browse',\n maxSizePrefix: 'Max.',\n remove: 'Remove',\n\n selectDate: 'Select date',\n selectTime: 'Select time',\n selectRange: 'Select range',\n pickStart: 'Select start',\n pickEnd: 'Select end',\n previousMonth: 'Previous month',\n nextMonth: 'Next month',\n\n dayView: 'Day',\n weekView: 'Week',\n\n available: 'Available',\n selected: 'Selected',\n noItems: 'No items',\n moveAllRight: 'Move all right',\n moveRight: 'Move selected right',\n moveLeft: 'Move selected left',\n moveAllLeft: 'Move all left',\n\n searchCommand: 'Search command...',\n navigateHint: 'navigate',\n selectHint: 'select',\n openHint: 'open',\n closeHint: 'close',\n\n loadingMore: 'Loading...',\n noMoreItems: 'No more items',\n\n bold: 'Bold',\n italic: 'Italic',\n underline: 'Underline',\n strikethrough: 'Strikethrough',\n highlight: 'Highlight',\n bulletList: 'Bullet list',\n orderedList: 'Ordered list',\n blockquote: 'Blockquote',\n code: 'Code',\n alignLeft: 'Align left',\n alignCenter: 'Align center',\n alignRight: 'Align right',\n undo: 'Undo',\n redo: 'Redo',\n link: 'Link',\n image: 'Image',\n paragraph: 'Paragraph',\n heading1: 'Heading 1',\n heading2: 'Heading 2',\n heading3: 'Heading 3',\n insertLink: 'Insert link',\n insertImage: 'Insert image',\n imageUrlLabel: 'Image URL',\n insert: 'Insert',\n\n jsonValid: 'Valid',\n jsonInvalid: 'Invalid',\n jsonFormat: 'Format',\n jsonMinify: 'Minify',\n\n jsonElements: 'elements',\n jsonFields: 'fields',\n}\n\nexport const M3_LOCALE_KEY: InjectionKey<MaybeRef<Partial<M3Locale>>> = Symbol('m3-locale')\n\nexport function useLocale(): M3Locale {\n const provided = inject(M3_LOCALE_KEY, {})\n const locale = reactive({ ...defaultLocale }) as M3Locale\n\n watchEffect(() => {\n Object.assign(locale, defaultLocale, toValue(provided))\n })\n\n return locale\n}\n"],"mappings":";;AA2GA,IAAa,IAA0B;CACrC,MAAM;CAEN,QAAQ;CACR,WAAW;CACX,OAAO;CACP,QAAQ;CACR,SAAS;CACT,SAAS;CAET,UAAU;CACV,MAAM;CACN,OAAO;CACP,MAAM;CAEN,eAAe;CACf,aAAa;CACb,QAAQ;CACR,SAAS;CACT,WAAW;CACX,SAAS;CAET,QAAQ;CAER,UAAU;CACV,YAAY;CACZ,eAAe;CACf,QAAQ;CAER,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,WAAW;CACX,SAAS;CACT,eAAe;CACf,WAAW;CAEX,SAAS;CACT,UAAU;CAEV,WAAW;CACX,UAAU;CACV,SAAS;CACT,cAAc;CACd,WAAW;CACX,UAAU;CACV,aAAa;CAEb,eAAe;CACf,cAAc;CACd,YAAY;CACZ,UAAU;CACV,WAAW;CAEX,aAAa;CACb,aAAa;CAEb,MAAM;CACN,QAAQ;CACR,WAAW;CACX,eAAe;CACf,WAAW;CACX,YAAY;CACZ,aAAa;CACb,YAAY;CACZ,MAAM;CACN,WAAW;CACX,aAAa;CACb,YAAY;CACZ,MAAM;CACN,MAAM;CACN,MAAM;CACN,OAAO;CACP,WAAW;CACX,UAAU;CACV,UAAU;CACV,UAAU;CACV,YAAY;CACZ,aAAa;CACb,eAAe;CACf,QAAQ;CAER,WAAW;CACX,aAAa;CACb,YAAY;CACZ,YAAY;CAEZ,cAAc;CACd,YAAY;AACd,GAEa,IAA2D,OAAO,WAAW;AAE1F,SAAgB,IAAsB;CACpC,IAAM,IAAW,EAAO,GAAe,CAAC,CAAC,GACnC,IAAS,EAAS,EAAE,GAAG,EAAc,CAAC;CAM5C,OAJA,QAAkB;EAChB,OAAO,OAAO,GAAQ,GAAe,EAAQ,CAAQ,CAAC;CACxD,CAAC,GAEM;AACT"}
|