@m3ui-vue/m3ui-vue 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dist/{MMenuItem-vSLbJGqe.js → MMenuItem-CDWfeU4F.js} +48 -36
- package/dist/MMenuItem-CDWfeU4F.js.map +1 -0
- package/dist/code-editor.js +1 -1
- package/dist/code-editor.js.map +1 -1
- package/dist/components/MButton.vue.d.ts +7 -0
- package/dist/components/MCalendar.vue.d.ts +0 -1
- package/dist/components/MCarousel.vue.d.ts +12 -14
- package/dist/components/MDatePicker.vue.d.ts +1 -3
- package/dist/components/MDatePickerModal.vue.d.ts +0 -1
- package/dist/components/MDateRangePicker.vue.d.ts +1 -3
- package/dist/components/MDateRangePickerModal.vue.d.ts +0 -1
- package/dist/components/MKanban.vue.d.ts +1 -0
- package/dist/components/MScheduler.vue.d.ts +0 -1
- package/dist/components/MShape.vue.d.ts +51 -0
- package/dist/components/MShortNavigationBar.vue.d.ts +34 -0
- package/dist/components/MSimpleCarousel.vue.d.ts +45 -0
- package/dist/components/MToggleButton.vue.d.ts +29 -0
- package/dist/components/MTree.vue.d.ts +0 -1
- package/dist/components/MTreeTable.vue.d.ts +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +3773 -2277
- package/dist/m3ui.js.map +1 -1
- package/dist/rich-text-editor.js +1 -1
- package/dist/styles/palettes.css +22 -22
- package/dist/styles.css +1 -1
- package/package.json +4 -1
- package/src/__tests__/MCarousel.test.ts +33 -0
- package/src/__tests__/MShape.test.ts +36 -0
- package/src/__tests__/MToggleButton.test.ts +27 -0
- package/src/components/MAutocomplete.vue +5 -1
- package/src/components/MButton.vue +15 -2
- package/src/components/MCalendar.vue +9 -5
- package/src/components/MCarousel.vue +123 -173
- package/src/components/MCodeEditor.vue +6 -1
- package/src/components/MContextMenu.vue +4 -4
- package/src/components/MDatePicker.vue +12 -9
- package/src/components/MDatePickerModal.vue +9 -4
- package/src/components/MDateRangePicker.vue +12 -9
- package/src/components/MDateRangePickerModal.vue +9 -4
- package/src/components/MKanban.vue +5 -1
- package/src/components/MMenu.vue +4 -4
- package/src/components/MMultiAutocomplete.vue +5 -1
- package/src/components/MMultiSelect.vue +5 -1
- package/src/components/MScheduler.vue +10 -6
- package/src/components/MSearchBar.vue +5 -1
- package/src/components/MSelect.vue +5 -1
- package/src/components/MShape.vue +107 -0
- package/src/components/MShortNavigationBar.vue +113 -0
- package/src/components/MSimpleCarousel.vue +325 -0
- package/src/components/MToggleButton.vue +188 -0
- package/src/components/MTopAppBar.vue +6 -2
- package/src/components/MTree.vue +4 -2
- package/src/components/MTreeTable.vue +5 -1
- package/src/composables/useColorPalette.ts +1 -1
- package/src/index.ts +8 -1
- package/src/styles/palettes.css +22 -22
- package/dist/MMenuItem-vSLbJGqe.js.map +0 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { ref } from 'vue'
|
|
3
3
|
import MIcon from './MIcon.vue'
|
|
4
4
|
import MIconButton from './MIconButton.vue'
|
|
5
|
+
import { useLocale } from '../composables/useLocale'
|
|
5
6
|
|
|
6
7
|
export interface KanbanCard {
|
|
7
8
|
id: string | number
|
|
@@ -17,8 +18,11 @@ export interface KanbanColumn {
|
|
|
17
18
|
|
|
18
19
|
const props = defineProps<{
|
|
19
20
|
modelValue: KanbanColumn[]
|
|
21
|
+
emptyText?: string
|
|
20
22
|
}>()
|
|
21
23
|
|
|
24
|
+
const locale = useLocale()
|
|
25
|
+
|
|
22
26
|
const emit = defineEmits<{
|
|
23
27
|
'update:modelValue': [KanbanColumn[]]
|
|
24
28
|
cardMove: [{ cardId: string | number; fromColumn: string | number; toColumn: string | number; toIndex: number }]
|
|
@@ -139,7 +143,7 @@ function reset() {
|
|
|
139
143
|
v-if="column.cards.length === 0"
|
|
140
144
|
class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-outline-variant/50 p-4"
|
|
141
145
|
>
|
|
142
|
-
<p class="text-body-small text-on-surface-variant/60">
|
|
146
|
+
<p class="text-body-small text-on-surface-variant/60">{{ emptyText ?? locale.noItems }}</p>
|
|
143
147
|
</div>
|
|
144
148
|
</div>
|
|
145
149
|
</div>
|
package/src/components/MMenu.vue
CHANGED
|
@@ -121,12 +121,12 @@ const origin = computed(() =>
|
|
|
121
121
|
|
|
122
122
|
<Teleport to="body">
|
|
123
123
|
<Transition
|
|
124
|
-
enter-active-class="transition-[opacity,transform] duration-
|
|
125
|
-
enter-from-class="opacity-0 scale-
|
|
124
|
+
enter-active-class="transition-[opacity,transform] duration-150 ease-[cubic-bezier(0.05,0.7,0.1,1)]"
|
|
125
|
+
enter-from-class="opacity-0 scale-[0.8]"
|
|
126
126
|
enter-to-class="opacity-100 scale-100"
|
|
127
|
-
leave-active-class="transition-[opacity,transform] duration-
|
|
127
|
+
leave-active-class="transition-[opacity,transform] duration-150 ease-[cubic-bezier(0.3,0,0.8,0.15)]"
|
|
128
128
|
leave-from-class="opacity-100 scale-100"
|
|
129
|
-
leave-to-class="opacity-0 scale-
|
|
129
|
+
leave-to-class="opacity-0 scale-[0.8]"
|
|
130
130
|
>
|
|
131
131
|
<div
|
|
132
132
|
v-if="open"
|
|
@@ -8,6 +8,10 @@ import { useLocale } from '../composables/useLocale'
|
|
|
8
8
|
import { useDebounce } from '../composables/useDebounce'
|
|
9
9
|
import type { MultiSelectOption } from './MMultiSelect.vue'
|
|
10
10
|
|
|
11
|
+
// Root is a fragment (field div + a sibling Teleport for the dropdown panel), so Vue can't
|
|
12
|
+
// auto-apply a consumer's class/attrs to either one — forward them onto the field div below.
|
|
13
|
+
defineOptions({ inheritAttrs: false })
|
|
14
|
+
|
|
11
15
|
const props = withDefaults(
|
|
12
16
|
defineProps<{
|
|
13
17
|
modelValue: unknown[]
|
|
@@ -344,7 +348,7 @@ const labelClasses = computed(() => {
|
|
|
344
348
|
</script>
|
|
345
349
|
|
|
346
350
|
<template>
|
|
347
|
-
<div class="flex flex-col gap-1">
|
|
351
|
+
<div class="flex flex-col gap-1" v-bind="$attrs">
|
|
348
352
|
<div
|
|
349
353
|
ref="fieldEl"
|
|
350
354
|
class="relative"
|
|
@@ -14,6 +14,10 @@ export interface MultiSelectOption {
|
|
|
14
14
|
disabled?: boolean
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// Root is a fragment (field div + a sibling Teleport for the dropdown panel), so Vue can't
|
|
18
|
+
// auto-apply a consumer's class/attrs to either one — forward them onto the field div below.
|
|
19
|
+
defineOptions({ inheritAttrs: false })
|
|
20
|
+
|
|
17
21
|
const props = withDefaults(
|
|
18
22
|
defineProps<{
|
|
19
23
|
modelValue: unknown[]
|
|
@@ -252,7 +256,7 @@ const labelClasses = computed(() => {
|
|
|
252
256
|
</script>
|
|
253
257
|
|
|
254
258
|
<template>
|
|
255
|
-
<div class="flex flex-col gap-1">
|
|
259
|
+
<div class="flex flex-col gap-1" v-bind="$attrs">
|
|
256
260
|
<div
|
|
257
261
|
ref="fieldEl"
|
|
258
262
|
class="relative"
|
|
@@ -31,10 +31,14 @@ const props = withDefaults(
|
|
|
31
31
|
view: 'week',
|
|
32
32
|
startHour: 7,
|
|
33
33
|
endHour: 22,
|
|
34
|
-
locale: 'es-ES',
|
|
35
34
|
},
|
|
36
35
|
)
|
|
37
36
|
|
|
37
|
+
// Falls back to the app's own configured locale (via createM3UI/useLocale) rather than a
|
|
38
|
+
// fixed default, matching the pattern MRelativeTime already uses — previously this defaulted
|
|
39
|
+
// to a hardcoded 'es-ES' regardless of what locale the app actually provided.
|
|
40
|
+
const resolvedLocale = computed(() => props.locale ?? locale.lang)
|
|
41
|
+
|
|
38
42
|
const emit = defineEmits<{
|
|
39
43
|
eventClick: [SchedulerEvent]
|
|
40
44
|
slotClick: [{ date: string; hour: number }]
|
|
@@ -78,17 +82,17 @@ function fmt(d: Date) {
|
|
|
78
82
|
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
|
|
79
83
|
}
|
|
80
84
|
|
|
81
|
-
const dayFormat = new Intl.DateTimeFormat(
|
|
82
|
-
const dateFormat = new Intl.DateTimeFormat(
|
|
85
|
+
const dayFormat = computed(() => new Intl.DateTimeFormat(resolvedLocale.value, { weekday: 'short' }))
|
|
86
|
+
const dateFormat = computed(() => new Intl.DateTimeFormat(resolvedLocale.value, { day: 'numeric' }))
|
|
83
87
|
|
|
84
88
|
const headerLabel = computed(() => {
|
|
85
89
|
if (currentView.value === 'day') {
|
|
86
|
-
return new Intl.DateTimeFormat(
|
|
90
|
+
return new Intl.DateTimeFormat(resolvedLocale.value, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' })
|
|
87
91
|
.format(currentDate.value)
|
|
88
92
|
}
|
|
89
93
|
const start = weekDays.value[0]!
|
|
90
94
|
const end = weekDays.value[6]!
|
|
91
|
-
const f = new Intl.DateTimeFormat(
|
|
95
|
+
const f = new Intl.DateTimeFormat(resolvedLocale.value, { day: 'numeric', month: 'short' })
|
|
92
96
|
return `${f.format(start)} – ${f.format(end)}, ${end.getFullYear()}`
|
|
93
97
|
})
|
|
94
98
|
|
|
@@ -125,7 +129,7 @@ function eventDuration(ev: SchedulerEvent) {
|
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
function timeLabel(ev: SchedulerEvent) {
|
|
128
|
-
const f = new Intl.DateTimeFormat(
|
|
132
|
+
const f = new Intl.DateTimeFormat(resolvedLocale.value, { hour: '2-digit', minute: '2-digit' })
|
|
129
133
|
return `${f.format(new Date(ev.start))} – ${f.format(new Date(ev.end))}`
|
|
130
134
|
}
|
|
131
135
|
|
|
@@ -5,6 +5,10 @@ import MIconButton from './MIconButton.vue'
|
|
|
5
5
|
import MSpinner from './MSpinner.vue'
|
|
6
6
|
import { useLocale } from '../composables/useLocale'
|
|
7
7
|
|
|
8
|
+
// Root is a fragment (bar div + a sibling Teleport for the expanded overlay panel), so Vue
|
|
9
|
+
// can't auto-apply a consumer's class/attrs to either one — forward them onto the bar div below.
|
|
10
|
+
defineOptions({ inheritAttrs: false })
|
|
11
|
+
|
|
8
12
|
const props = withDefaults(
|
|
9
13
|
defineProps<{
|
|
10
14
|
modelValue?: string
|
|
@@ -126,7 +130,7 @@ onUnmounted(() => { document.body.style.overflow = '' })
|
|
|
126
130
|
</script>
|
|
127
131
|
|
|
128
132
|
<template>
|
|
129
|
-
<div ref="barEl" class="relative w-full">
|
|
133
|
+
<div ref="barEl" class="relative w-full" v-bind="$attrs">
|
|
130
134
|
<div
|
|
131
135
|
v-show="!expanded"
|
|
132
136
|
class="flex h-14 items-center gap-3 rounded-full bg-surface-container-high px-4 shadow-elevation-3 transition-shadow duration-150 focus-within:outline focus-within:outline-2 focus-within:outline-secondary focus-within:-outline-offset-2"
|
|
@@ -11,6 +11,10 @@ export interface SelectOption {
|
|
|
11
11
|
disabled?: boolean
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
// Root is a fragment (field div + a sibling Teleport for the dropdown panel), so Vue can't
|
|
15
|
+
// auto-apply a consumer's class/attrs to either one — forward them onto the field div below.
|
|
16
|
+
defineOptions({ inheritAttrs: false })
|
|
17
|
+
|
|
14
18
|
const props = withDefaults(
|
|
15
19
|
defineProps<{
|
|
16
20
|
modelValue: unknown
|
|
@@ -198,7 +202,7 @@ const labelClasses = computed(() => {
|
|
|
198
202
|
</script>
|
|
199
203
|
|
|
200
204
|
<template>
|
|
201
|
-
<div class="flex flex-col gap-1">
|
|
205
|
+
<div class="flex flex-col gap-1" v-bind="$attrs">
|
|
202
206
|
<div
|
|
203
207
|
ref="fieldEl"
|
|
204
208
|
class="relative"
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
export { shapeNames } from 'shape-morph'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { onUnmounted, ref, useId, watch } from 'vue'
|
|
7
|
+
import { AnimatedMorph, getShape, toSvgPath, type ShapeName } from 'shape-morph'
|
|
8
|
+
|
|
9
|
+
export type { ShapeName }
|
|
10
|
+
|
|
11
|
+
// No default width/height here (matches MAspectRatio) — size it via `class`/`style` on the
|
|
12
|
+
// component itself, e.g. `class="h-16 w-16"`. A hardcoded `h-full w-full` would fight Tailwind's
|
|
13
|
+
// own (undefined) utility ordering against whatever sizing class the consumer passes through.
|
|
14
|
+
const props = withDefaults(
|
|
15
|
+
defineProps<{
|
|
16
|
+
/** One of M3's 35 named "expressive" shapes (MaterialShapes.kt), e.g. 'Cookie9Sided', 'Heart'. */
|
|
17
|
+
shape: ShapeName
|
|
18
|
+
/**
|
|
19
|
+
* Fill color used when there's no default slot content to clip (a decorative solid shape).
|
|
20
|
+
* SVG `fill`, not a `background-color` — a `bg-*` Tailwind class on the component itself has
|
|
21
|
+
* no effect here; use `fill` (or a `text-*` class, since the default is `currentColor`).
|
|
22
|
+
*/
|
|
23
|
+
fill?: string
|
|
24
|
+
/** Spring-morph into the new outline when `shape` changes — false snaps instantly instead. */
|
|
25
|
+
animate?: boolean
|
|
26
|
+
/**
|
|
27
|
+
* Multiplier on the morph spring's speed (1 = default). Scales stiffness by speed² and the
|
|
28
|
+
* damping coefficient by speed, which time-scales the spring uniformly without changing its
|
|
29
|
+
* character (same amount of overshoot/settle shape, just faster or slower).
|
|
30
|
+
*/
|
|
31
|
+
speed?: number
|
|
32
|
+
}>(),
|
|
33
|
+
{
|
|
34
|
+
fill: 'currentColor',
|
|
35
|
+
animate: true,
|
|
36
|
+
speed: 1,
|
|
37
|
+
},
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
const clipId = `m3-shape-${useId()}`
|
|
41
|
+
|
|
42
|
+
// Normalized 0-1 coordinates (size: 1) so the path works as an objectBoundingBox clipPath,
|
|
43
|
+
// which scales correctly with the element's actual rendered size instead of a fixed px box.
|
|
44
|
+
const pathD = ref(toSvgPath(getShape(props.shape), 1))
|
|
45
|
+
|
|
46
|
+
let morph: AnimatedMorph | null = null
|
|
47
|
+
let settledShape = props.shape
|
|
48
|
+
|
|
49
|
+
// MaterialShapes is itself an Expressive-only M3 feature (MaterialShapes.kt requires
|
|
50
|
+
// @ExperimentalMaterial3ExpressiveApi), so this spring is ExpressiveMotionTokens.DefaultSpatial
|
|
51
|
+
// (dampingRatio 0.8, stiffness 380) — the scheme's general-purpose spatial spring, since no
|
|
52
|
+
// single Compose composable's own bespoke spring (e.g. LoadingIndicator's 0.6/200) is the
|
|
53
|
+
// "correct" one to copy for a generic shape primitive like this. shape-morph's AnimatedMorph
|
|
54
|
+
// spring uses a plain damping *coefficient*, not Compose's damping *ratio* — converted via
|
|
55
|
+
// damping = 2 * dampingRatio * sqrt(stiffness) = 2 * 0.8 * sqrt(380) ≈ 31.2.
|
|
56
|
+
const BASE_STIFFNESS = 380
|
|
57
|
+
const BASE_DAMPING = 31.2
|
|
58
|
+
|
|
59
|
+
function springFor(speed: number) {
|
|
60
|
+
return { stiffness: BASE_STIFFNESS * speed ** 2, damping: BASE_DAMPING * speed }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
watch(() => props.shape, (next, prev) => {
|
|
64
|
+
if (!prev || next === prev) return
|
|
65
|
+
morph?.dispose()
|
|
66
|
+
if (!props.animate) {
|
|
67
|
+
pathD.value = toSvgPath(getShape(next), 1)
|
|
68
|
+
settledShape = next
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
// AnimatedMorph only morphs between two named/RoundedPolygon endpoints, not from an
|
|
72
|
+
// arbitrary in-flight shape, so a change that interrupts a running morph restarts from
|
|
73
|
+
// the last shape that had actually settled rather than the current on-screen outline.
|
|
74
|
+
morph = new AnimatedMorph(settledShape, next, {
|
|
75
|
+
spring: springFor(props.speed),
|
|
76
|
+
size: 1,
|
|
77
|
+
onFrame: (frame) => { pathD.value = frame.pathD },
|
|
78
|
+
})
|
|
79
|
+
// The constructor only emits the start shape at progress 0 — setting `progress` is what
|
|
80
|
+
// actually kicks off the spring animation toward the end shape (see shape-morph's own
|
|
81
|
+
// useMorph, which drives this the same way). Skipping this makes the shape jump straight
|
|
82
|
+
// to its final frame with no visible interpolation, one render behind the prop change.
|
|
83
|
+
morph.progress = 1
|
|
84
|
+
settledShape = next
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
onUnmounted(() => morph?.dispose())
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<template>
|
|
91
|
+
<span class="relative inline-block">
|
|
92
|
+
<svg width="0" height="0" class="absolute">
|
|
93
|
+
<defs>
|
|
94
|
+
<clipPath :id="clipId" clipPathUnits="objectBoundingBox">
|
|
95
|
+
<path :d="pathD" />
|
|
96
|
+
</clipPath>
|
|
97
|
+
</defs>
|
|
98
|
+
</svg>
|
|
99
|
+
|
|
100
|
+
<div v-if="$slots.default" class="h-full w-full" :style="{ clipPath: `url(#${clipId})` }">
|
|
101
|
+
<slot />
|
|
102
|
+
</div>
|
|
103
|
+
<svg v-else viewBox="0 0 1 1" class="h-full w-full">
|
|
104
|
+
<path :d="pathD" :fill="fill" />
|
|
105
|
+
</svg>
|
|
106
|
+
</span>
|
|
107
|
+
</template>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import MIcon from './MIcon.vue'
|
|
4
|
+
import MBadge from './MBadge.vue'
|
|
5
|
+
|
|
6
|
+
export interface ShortNavBarItem {
|
|
7
|
+
value: string | number
|
|
8
|
+
label: string
|
|
9
|
+
icon: string
|
|
10
|
+
badge?: number
|
|
11
|
+
badgeDot?: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const props = withDefaults(
|
|
15
|
+
defineProps<{
|
|
16
|
+
modelValue: string | number
|
|
17
|
+
items: ShortNavBarItem[]
|
|
18
|
+
/**
|
|
19
|
+
* 'equal' (ShortNavigationBarArrangement.EqualWeight): items evenly fill the bar — recommended
|
|
20
|
+
* for small-width screens. 'centered' (.Centered): items are grouped toward the center instead
|
|
21
|
+
* of stretching edge to edge — recommended for medium-width screens, paired with iconPosition
|
|
22
|
+
* 'start'. Real Compose computes this via a custom MeasurePolicy at layout time; ported here as
|
|
23
|
+
* the same closed-form percentage formula (calculateCenteredContentHorizontalPadding), since it
|
|
24
|
+
* only ever depends on the item count, not on measured content size.
|
|
25
|
+
*/
|
|
26
|
+
arrangement?: 'equal' | 'centered'
|
|
27
|
+
/** NavigationItemIconPosition — 'top' stacks icon above label (ShortNavigationBarItem's
|
|
28
|
+
* default); 'start' places the icon beside the label inside a single wider pill, meant for
|
|
29
|
+
* the 'centered' arrangement on wider/landscape layouts. */
|
|
30
|
+
iconPosition?: 'top' | 'start'
|
|
31
|
+
}>(),
|
|
32
|
+
{
|
|
33
|
+
arrangement: 'equal',
|
|
34
|
+
iconPosition: 'top',
|
|
35
|
+
},
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
defineEmits<{ 'update:modelValue': [string | number] }>()
|
|
39
|
+
|
|
40
|
+
// calculateCenteredContentHorizontalPadding: 3 items -> 20% each side, 4 -> 15%, 5 -> 10%,
|
|
41
|
+
// 6 -> 5%, 7+ -> 0. Matches the real formula verbatim: ((100 - 10*(n+3)) / 2) / 100.
|
|
42
|
+
const centeredPadding = computed(() => {
|
|
43
|
+
const n = props.items.length
|
|
44
|
+
if (props.arrangement !== 'centered' || n > 6) return 0
|
|
45
|
+
return ((100 - 10 * (n + 3)) / 2)
|
|
46
|
+
})
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<nav
|
|
51
|
+
class="flex h-16 w-full items-center border-t border-outline-variant bg-surface-container shadow-elevation-2"
|
|
52
|
+
:style="arrangement === 'centered' ? { paddingLeft: `${centeredPadding}%`, paddingRight: `${centeredPadding}%` } : undefined"
|
|
53
|
+
>
|
|
54
|
+
<button
|
|
55
|
+
v-for="item in items"
|
|
56
|
+
:key="item.value"
|
|
57
|
+
type="button"
|
|
58
|
+
class="group flex flex-1 cursor-pointer items-center justify-center self-stretch transition-colors focus-visible:outline-none"
|
|
59
|
+
:class="iconPosition === 'top' ? 'flex-col gap-1' : 'flex-row gap-1 py-1.5'"
|
|
60
|
+
@click="$emit('update:modelValue', item.value)"
|
|
61
|
+
>
|
|
62
|
+
<template v-if="iconPosition === 'top'">
|
|
63
|
+
<!-- Top icon position: 56x32dp pill above a separate label, matching MNavigationBar -->
|
|
64
|
+
<span
|
|
65
|
+
class="inline-flex h-8 items-center justify-center rounded-2xl transition-all duration-200"
|
|
66
|
+
:class="
|
|
67
|
+
item.value === modelValue
|
|
68
|
+
? 'w-14 bg-secondary-container text-on-secondary-container'
|
|
69
|
+
: 'w-0 bg-secondary-container/0 text-on-surface-variant group-hover:w-14 group-hover:bg-on-surface/8'
|
|
70
|
+
"
|
|
71
|
+
>
|
|
72
|
+
<MBadge v-if="item.badge != null" :count="item.badge">
|
|
73
|
+
<MIcon :name="item.icon" :size="24" />
|
|
74
|
+
</MBadge>
|
|
75
|
+
<MBadge v-else-if="item.badgeDot" dot>
|
|
76
|
+
<MIcon :name="item.icon" :size="24" />
|
|
77
|
+
</MBadge>
|
|
78
|
+
<MIcon v-else :name="item.icon" :size="24" />
|
|
79
|
+
</span>
|
|
80
|
+
<span
|
|
81
|
+
class="text-label-medium font-medium"
|
|
82
|
+
:class="item.value === modelValue ? 'text-secondary' : 'text-on-surface-variant'"
|
|
83
|
+
>
|
|
84
|
+
{{ item.label }}
|
|
85
|
+
</span>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<template v-else>
|
|
89
|
+
<!-- Start icon position: one 40dp-tall pill wrapping icon+label together, 16dp
|
|
90
|
+
leading/trailing padding (ActiveIndicatorLeadingSpace/TrailingSpace) — selected label
|
|
91
|
+
uses the icon's own color here (OnSecondaryContainer), not the Top position's
|
|
92
|
+
separate Secondary label color (ShortNavigationBarItemDefaults.colors() doc comment). -->
|
|
93
|
+
<span
|
|
94
|
+
class="inline-flex h-10 items-center justify-center gap-1 rounded-2xl px-4 transition-colors duration-200"
|
|
95
|
+
:class="
|
|
96
|
+
item.value === modelValue
|
|
97
|
+
? 'bg-secondary-container text-on-secondary-container'
|
|
98
|
+
: 'text-on-surface-variant group-hover:bg-on-surface/8'
|
|
99
|
+
"
|
|
100
|
+
>
|
|
101
|
+
<MBadge v-if="item.badge != null" :count="item.badge">
|
|
102
|
+
<MIcon :name="item.icon" :size="24" />
|
|
103
|
+
</MBadge>
|
|
104
|
+
<MBadge v-else-if="item.badgeDot" dot>
|
|
105
|
+
<MIcon :name="item.icon" :size="24" />
|
|
106
|
+
</MBadge>
|
|
107
|
+
<MIcon v-else :name="item.icon" :size="24" />
|
|
108
|
+
<span class="text-label-medium font-medium">{{ item.label }}</span>
|
|
109
|
+
</span>
|
|
110
|
+
</template>
|
|
111
|
+
</button>
|
|
112
|
+
</nav>
|
|
113
|
+
</template>
|