@m3ui-vue/m3ui-vue 0.7.1 → 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 +14 -6
- package/dist/{MMenuItem-xQ1x6-DH.js → MMenuItem-CDWfeU4F.js} +331 -252
- package/dist/MMenuItem-CDWfeU4F.js.map +1 -0
- package/dist/code-editor.d.ts +1 -0
- package/dist/code-editor.js +22 -7
- 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/MCard.vue.d.ts +2 -0
- package/dist/components/MCarousel.vue.d.ts +12 -14
- package/dist/components/MChatBubble.vue.d.ts +0 -1
- package/dist/components/MCircleProgressBar.vue.d.ts +0 -1
- package/dist/components/MCodeEditor.vue.d.ts +1 -1
- package/dist/components/MConfirmDialog.vue.d.ts +3 -0
- 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/MDialog.vue.d.ts +23 -7
- package/dist/components/MFab.vue.d.ts +2 -2
- package/dist/components/MKanban.vue.d.ts +1 -0
- package/dist/components/MListItem.vue.d.ts +11 -6
- package/dist/components/MNavigationRail.vue.d.ts +17 -1
- package/dist/components/MScheduler.vue.d.ts +0 -1
- package/dist/components/MSelect.vue.d.ts +1 -0
- 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/MSwitch.vue.d.ts +8 -0
- package/dist/components/MTabs.vue.d.ts +3 -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 +9 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +4387 -2525
- package/dist/m3ui.js.map +1 -1
- package/dist/rich-text-editor.js +1 -1
- package/dist/styles/palettes.css +659 -0
- package/dist/styles/theme.css +1 -0
- package/dist/styles.css +1 -1
- package/package.json +16 -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/__tests__/useColorPalette.test.ts +2 -2
- package/src/code-editor.ts +1 -0
- package/src/components/MAutocomplete.vue +40 -27
- package/src/components/MBadge.vue +1 -1
- package/src/components/MBottomSheet.vue +4 -4
- package/src/components/MButton.vue +51 -21
- package/src/components/MButtonGroup.vue +2 -2
- package/src/components/MCalendar.vue +9 -5
- package/src/components/MCard.vue +76 -11
- package/src/components/MCarousel.vue +123 -173
- package/src/components/MChatBubble.vue +0 -1
- package/src/components/MCheckbox.vue +58 -13
- package/src/components/MChip.vue +26 -6
- package/src/components/MCircleProgressBar.vue +7 -4
- package/src/components/MCodeEditor.vue +60 -9
- package/src/components/MColorPicker.vue +9 -8
- package/src/components/MColorPickerModal.vue +2 -2
- package/src/components/MCommandPalette.vue +1 -1
- package/src/components/MConfirmDialog.vue +4 -0
- package/src/components/MContextMenu.vue +27 -6
- package/src/components/MDatePicker.vue +23 -20
- package/src/components/MDatePickerModal.vue +14 -9
- package/src/components/MDateRangePicker.vue +24 -21
- package/src/components/MDateRangePickerModal.vue +12 -7
- package/src/components/MDialog.vue +103 -12
- package/src/components/MFab.vue +10 -7
- package/src/components/MFabMenu.vue +1 -1
- package/src/components/MIconButton.vue +41 -19
- package/src/components/MKanban.vue +5 -1
- package/src/components/MListItem.vue +35 -17
- package/src/components/MLoadingIndicator.vue +14 -7
- package/src/components/MMaskField.vue +14 -6
- package/src/components/MMenu.vue +32 -7
- package/src/components/MMenuItem.vue +2 -2
- package/src/components/MMultiAutocomplete.vue +46 -27
- package/src/components/MMultiSelect.vue +45 -23
- package/src/components/MNavigationBar.vue +5 -10
- package/src/components/MNavigationDrawer.vue +10 -9
- package/src/components/MNavigationRail.vue +335 -22
- package/src/components/MNumberField.vue +14 -6
- package/src/components/MOverlay.vue +1 -1
- package/src/components/MPinInput.vue +7 -4
- package/src/components/MProgressBar.vue +16 -10
- package/src/components/MRadio.vue +54 -12
- package/src/components/MScheduler.vue +10 -6
- package/src/components/MSearchBar.vue +8 -3
- package/src/components/MSegmentedButton.vue +14 -9
- package/src/components/MSelect.vue +49 -33
- package/src/components/MShape.vue +107 -0
- package/src/components/MShortNavigationBar.vue +113 -0
- package/src/components/MSideSheet.vue +1 -1
- package/src/components/MSimpleCarousel.vue +325 -0
- package/src/components/MSnackbar.vue +4 -4
- package/src/components/MSplitButton.vue +32 -17
- package/src/components/MSpotlightSearch.vue +1 -1
- package/src/components/MSwitch.vue +96 -18
- package/src/components/MTabs.vue +16 -12
- package/src/components/MTagInput.vue +33 -22
- package/src/components/MTextField.vue +14 -6
- package/src/components/MTimePicker.vue +9 -9
- package/src/components/MTimePickerModal.vue +16 -16
- package/src/components/MToggleButton.vue +188 -0
- package/src/components/MToolbar.vue +5 -3
- package/src/components/MTooltip.vue +4 -4
- package/src/components/MTopAppBar.vue +19 -7
- package/src/components/MTour.vue +1 -1
- package/src/components/MTree.vue +4 -2
- package/src/components/MTreeTable.vue +5 -1
- package/src/composables/useColorPalette.ts +10 -0
- package/src/index.ts +9 -1
- package/src/styles/palettes.css +659 -0
- package/src/styles/theme.css +1 -0
- package/dist/MMenuItem-xQ1x6-DH.js.map +0 -1
|
@@ -111,22 +111,25 @@ const inputClasses = computed(() => {
|
|
|
111
111
|
const base = [
|
|
112
112
|
'peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent',
|
|
113
113
|
'transition-[border-color,border-width] duration-150',
|
|
114
|
-
'disabled:cursor-not-allowed disabled:
|
|
114
|
+
'disabled:cursor-not-allowed disabled:text-on-surface/38',
|
|
115
|
+
props.error ? 'caret-error' : 'caret-primary',
|
|
115
116
|
'h-14', pl, pr,
|
|
116
117
|
]
|
|
117
118
|
if (props.variant === 'outlined') {
|
|
118
119
|
return [...base,
|
|
119
|
-
'rounded-
|
|
120
|
+
'rounded-xs border bg-transparent py-4',
|
|
120
121
|
props.error
|
|
121
122
|
? 'border-error focus:border-2 focus:border-error'
|
|
122
123
|
: 'border-outline hover:border-on-surface focus:border-2 focus:border-primary',
|
|
124
|
+
'disabled:border-on-surface/12',
|
|
123
125
|
].join(' ')
|
|
124
126
|
}
|
|
125
127
|
return [...base,
|
|
126
|
-
'rounded-t-
|
|
128
|
+
'rounded-t-xs bg-surface-container-highest border-b pt-6 pb-2',
|
|
127
129
|
props.error
|
|
128
130
|
? 'border-error focus:border-b-2 focus:border-error'
|
|
129
131
|
: 'border-on-surface-variant hover:border-on-surface focus:border-b-2 focus:border-primary',
|
|
132
|
+
'disabled:border-on-surface/38 disabled:bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]',
|
|
130
133
|
].join(' ')
|
|
131
134
|
})
|
|
132
135
|
|
|
@@ -145,12 +148,14 @@ const labelClasses = computed(() => {
|
|
|
145
148
|
'peer-[&:not(:placeholder-shown)]:-top-2.5 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:right-auto peer-[&:not(:placeholder-shown)]:max-w-[calc(100%-1.5rem)]',
|
|
146
149
|
'peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:bg-[var(--field-bg)] peer-[&:not(:placeholder-shown)]:px-1',
|
|
147
150
|
props.error ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',
|
|
151
|
+
'peer-disabled:text-on-surface/38',
|
|
148
152
|
].join(' ')
|
|
149
153
|
}
|
|
150
154
|
return [...base,
|
|
151
155
|
'peer-focus:top-2 peer-focus:translate-y-0 peer-focus:text-label-small',
|
|
152
156
|
'peer-[&:not(:placeholder-shown)]:top-2 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small',
|
|
153
157
|
props.error ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',
|
|
158
|
+
'peer-disabled:text-on-surface/38',
|
|
154
159
|
].join(' ')
|
|
155
160
|
})
|
|
156
161
|
</script>
|
|
@@ -165,10 +170,13 @@ const labelClasses = computed(() => {
|
|
|
165
170
|
>
|
|
166
171
|
<div
|
|
167
172
|
v-if="leadingIcon"
|
|
168
|
-
class="pointer-events-none absolute left-3.5
|
|
169
|
-
:class="
|
|
173
|
+
class="pointer-events-none absolute left-3.5"
|
|
174
|
+
:class="[
|
|
175
|
+
variant === 'filled' ? 'top-4.5' : 'top-4',
|
|
176
|
+
disabled ? 'text-on-surface/38' : 'text-on-surface-variant',
|
|
177
|
+
]"
|
|
170
178
|
>
|
|
171
|
-
<MIcon :name="leadingIcon" :size="
|
|
179
|
+
<MIcon :name="leadingIcon" :size="24" />
|
|
172
180
|
</div>
|
|
173
181
|
|
|
174
182
|
<input
|
package/src/components/MMenu.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, onMounted, onUnmounted, provide, ref } from 'vue'
|
|
2
|
+
import { computed, nextTick, onMounted, onUnmounted, provide, ref } from 'vue'
|
|
3
3
|
|
|
4
4
|
const props = withDefaults(
|
|
5
5
|
defineProps<{
|
|
@@ -39,9 +39,31 @@ function computePos() {
|
|
|
39
39
|
dropStyle.value = style
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
function focusableItems() {
|
|
43
|
+
if (!dropdownEl.value) return []
|
|
44
|
+
return Array.from(
|
|
45
|
+
dropdownEl.value.querySelectorAll<HTMLElement>('button:not(:disabled), a[href]'),
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function focusFirstItem() {
|
|
50
|
+
nextTick(() => focusableItems()[0]?.focus())
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function moveFocus(dir: 1 | -1) {
|
|
54
|
+
const items = focusableItems()
|
|
55
|
+
if (!items.length) return
|
|
56
|
+
const idx = items.indexOf(document.activeElement as HTMLElement)
|
|
57
|
+
const next = idx === -1
|
|
58
|
+
? (dir === 1 ? items[0] : items[items.length - 1])
|
|
59
|
+
: items[(idx + dir + items.length) % items.length]
|
|
60
|
+
next?.focus()
|
|
61
|
+
}
|
|
62
|
+
|
|
42
63
|
function toggle() {
|
|
43
64
|
if (!open.value) computePos()
|
|
44
65
|
open.value = !open.value
|
|
66
|
+
if (open.value) focusFirstItem()
|
|
45
67
|
}
|
|
46
68
|
|
|
47
69
|
function close() {
|
|
@@ -69,7 +91,10 @@ function onScroll(e: Event) {
|
|
|
69
91
|
}
|
|
70
92
|
|
|
71
93
|
function onKeydown(e: KeyboardEvent) {
|
|
72
|
-
if (e.key === 'Escape') close()
|
|
94
|
+
if (e.key === 'Escape') { close(); return }
|
|
95
|
+
if (!open.value) return
|
|
96
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); moveFocus(1) }
|
|
97
|
+
else if (e.key === 'ArrowUp') { e.preventDefault(); moveFocus(-1) }
|
|
73
98
|
}
|
|
74
99
|
|
|
75
100
|
onMounted(() => {
|
|
@@ -96,17 +121,17 @@ const origin = computed(() =>
|
|
|
96
121
|
|
|
97
122
|
<Teleport to="body">
|
|
98
123
|
<Transition
|
|
99
|
-
enter-active-class="transition-[opacity,transform] duration-
|
|
100
|
-
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]"
|
|
101
126
|
enter-to-class="opacity-100 scale-100"
|
|
102
|
-
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)]"
|
|
103
128
|
leave-from-class="opacity-100 scale-100"
|
|
104
|
-
leave-to-class="opacity-0 scale-
|
|
129
|
+
leave-to-class="opacity-0 scale-[0.8]"
|
|
105
130
|
>
|
|
106
131
|
<div
|
|
107
132
|
v-if="open"
|
|
108
133
|
ref="dropdownEl"
|
|
109
|
-
class="fixed z-500 min-w-48 overflow-hidden rounded-
|
|
134
|
+
class="fixed z-500 min-w-48 overflow-hidden rounded-xs bg-surface-container shadow-elevation-2"
|
|
110
135
|
:style="{ ...dropStyle, transformOrigin: origin }"
|
|
111
136
|
>
|
|
112
137
|
<div class="overflow-y-auto py-1" :style="{ maxHeight: dropStyle.maxHeight }">
|
|
@@ -68,7 +68,7 @@ function onSubLeave(e: MouseEvent) {
|
|
|
68
68
|
:is="tag"
|
|
69
69
|
:to="to || undefined"
|
|
70
70
|
:type="to ? undefined : 'button'"
|
|
71
|
-
class="flex w-full items-center gap-3 px-4 py-2.5 text-left text-body-large transition-colors"
|
|
71
|
+
class="flex w-full items-center gap-3 px-4 py-2.5 text-left text-body-large transition-colors outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-secondary"
|
|
72
72
|
:class="[
|
|
73
73
|
disabled ? 'cursor-not-allowed opacity-[0.38] text-on-surface' : 'cursor-pointer',
|
|
74
74
|
!disabled && danger ? 'text-error hover:bg-error/8' : '',
|
|
@@ -93,7 +93,7 @@ function onSubLeave(e: MouseEvent) {
|
|
|
93
93
|
>
|
|
94
94
|
<div
|
|
95
95
|
v-if="showSub"
|
|
96
|
-
class="m3-submenu min-w-44 overflow-hidden rounded-
|
|
96
|
+
class="m3-submenu min-w-44 overflow-hidden rounded-xs bg-surface-container py-1 shadow-elevation-2"
|
|
97
97
|
:style="subStyle"
|
|
98
98
|
@mouseleave="onSubLeave"
|
|
99
99
|
>
|
|
@@ -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[]
|
|
@@ -135,6 +139,7 @@ function toggle(value: unknown) {
|
|
|
135
139
|
|
|
136
140
|
function removeChip(value: unknown, e: Event) {
|
|
137
141
|
e.stopPropagation()
|
|
142
|
+
if (props.disabled) return
|
|
138
143
|
emit('update:modelValue', props.modelValue.filter((v) => !eq(v, value)))
|
|
139
144
|
nextTick(() => inputEl.value?.focus())
|
|
140
145
|
}
|
|
@@ -297,23 +302,23 @@ const triggerClasses = computed(() => {
|
|
|
297
302
|
]
|
|
298
303
|
|
|
299
304
|
if (props.variant === 'outlined') {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
open.value
|
|
305
|
+
const border = props.disabled
|
|
306
|
+
? 'border-on-surface/12'
|
|
307
|
+
: open.value
|
|
304
308
|
? (props.error ? 'border-2 border-error' : 'border-2 border-primary')
|
|
305
|
-
: (props.error ? 'border-error' : 'border-outline hover:border-on-surface')
|
|
306
|
-
].join(' ')
|
|
309
|
+
: (props.error ? 'border-error' : 'border-outline hover:border-on-surface')
|
|
310
|
+
return [...base, 'rounded-xs border bg-transparent py-2', border].join(' ')
|
|
307
311
|
}
|
|
308
312
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
isFloated.value ? 'pt-7' : 'pt-4',
|
|
313
|
-
open.value
|
|
313
|
+
const border = props.disabled
|
|
314
|
+
? 'border-on-surface/38'
|
|
315
|
+
: open.value
|
|
314
316
|
? (props.error ? 'border-b-2 border-error' : 'border-b-2 border-primary')
|
|
315
|
-
: (props.error ? 'border-error' : 'border-on-surface-variant hover:border-on-surface')
|
|
316
|
-
|
|
317
|
+
: (props.error ? 'border-error' : 'border-on-surface-variant hover:border-on-surface')
|
|
318
|
+
const bg = props.disabled
|
|
319
|
+
? 'bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]'
|
|
320
|
+
: 'bg-surface-container-highest'
|
|
321
|
+
return [...base, 'rounded-t-xs border-b pb-2', isFloated.value ? 'pt-7' : 'pt-4', bg, border].join(' ')
|
|
317
322
|
})
|
|
318
323
|
|
|
319
324
|
const labelClasses = computed(() => {
|
|
@@ -333,15 +338,17 @@ const labelClasses = computed(() => {
|
|
|
333
338
|
'pointer-events-none absolute right-10 truncate transition-all duration-200',
|
|
334
339
|
left,
|
|
335
340
|
isFloated.value ? floated : unFloated,
|
|
336
|
-
|
|
337
|
-
?
|
|
338
|
-
:
|
|
341
|
+
props.disabled
|
|
342
|
+
? 'text-on-surface/38'
|
|
343
|
+
: open.value
|
|
344
|
+
? (props.error ? 'text-error' : 'text-primary')
|
|
345
|
+
: (props.error ? 'text-error' : 'text-on-surface-variant'),
|
|
339
346
|
].join(' ')
|
|
340
347
|
})
|
|
341
348
|
</script>
|
|
342
349
|
|
|
343
350
|
<template>
|
|
344
|
-
<div class="flex flex-col gap-1">
|
|
351
|
+
<div class="flex flex-col gap-1" v-bind="$attrs">
|
|
345
352
|
<div
|
|
346
353
|
ref="fieldEl"
|
|
347
354
|
class="relative"
|
|
@@ -351,17 +358,20 @@ const labelClasses = computed(() => {
|
|
|
351
358
|
<!-- Leading icon -->
|
|
352
359
|
<div
|
|
353
360
|
v-if="leadingIcon"
|
|
354
|
-
class="pointer-events-none absolute left-3.5
|
|
355
|
-
:class="
|
|
361
|
+
class="pointer-events-none absolute left-3.5"
|
|
362
|
+
:class="[
|
|
363
|
+
variant === 'filled' ? 'top-4.5' : 'top-4',
|
|
364
|
+
disabled ? 'text-on-surface/38' : 'text-on-surface-variant',
|
|
365
|
+
]"
|
|
356
366
|
>
|
|
357
|
-
<MIcon :name="leadingIcon" :size="
|
|
367
|
+
<MIcon :name="leadingIcon" :size="24" />
|
|
358
368
|
</div>
|
|
359
369
|
|
|
360
370
|
<!-- Trigger field with chips and inline input -->
|
|
361
371
|
<div
|
|
362
372
|
:class="[
|
|
363
373
|
triggerClasses,
|
|
364
|
-
disabled ? 'pointer-events-none
|
|
374
|
+
disabled ? 'pointer-events-none' : 'cursor-text',
|
|
365
375
|
]"
|
|
366
376
|
@click="inputEl?.focus()"
|
|
367
377
|
>
|
|
@@ -369,10 +379,12 @@ const labelClasses = computed(() => {
|
|
|
369
379
|
<span
|
|
370
380
|
v-for="(chip, i) in displayChips"
|
|
371
381
|
:key="i"
|
|
372
|
-
class="inline-flex items-center gap-1 rounded-full
|
|
382
|
+
class="inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-label-small"
|
|
383
|
+
:class="disabled ? 'bg-on-surface/12 text-on-surface/38' : 'bg-secondary-container text-on-secondary-container'"
|
|
373
384
|
>
|
|
374
385
|
{{ chip.label }}
|
|
375
386
|
<button
|
|
387
|
+
v-if="!disabled"
|
|
376
388
|
type="button"
|
|
377
389
|
class="flex h-4 w-4 items-center justify-center rounded-full hover:bg-on-secondary-container/20"
|
|
378
390
|
@click="removeChip(chip.value, $event)"
|
|
@@ -408,7 +420,11 @@ const labelClasses = computed(() => {
|
|
|
408
420
|
role="combobox"
|
|
409
421
|
:aria-expanded="open"
|
|
410
422
|
:aria-disabled="disabled"
|
|
411
|
-
class="
|
|
423
|
+
:class="[
|
|
424
|
+
'flex-1 min-w-[60px] bg-transparent text-body-large outline-none placeholder:text-on-surface-variant',
|
|
425
|
+
error ? 'caret-error' : 'caret-primary',
|
|
426
|
+
disabled ? 'text-on-surface/38' : 'text-on-surface',
|
|
427
|
+
]"
|
|
412
428
|
@focus="onInputFocus"
|
|
413
429
|
@blur="onInputBlur"
|
|
414
430
|
@input="onInput"
|
|
@@ -436,8 +452,11 @@ const labelClasses = computed(() => {
|
|
|
436
452
|
<MIcon
|
|
437
453
|
name="arrow_drop_down"
|
|
438
454
|
:size="24"
|
|
439
|
-
class="
|
|
440
|
-
:class="
|
|
455
|
+
class="transition-transform duration-200"
|
|
456
|
+
:class="[
|
|
457
|
+
open || modalOpen ? 'rotate-180' : '',
|
|
458
|
+
disabled ? 'text-on-surface/38' : 'text-on-surface-variant',
|
|
459
|
+
]"
|
|
441
460
|
/>
|
|
442
461
|
</div>
|
|
443
462
|
</div>
|
|
@@ -459,7 +478,7 @@ const labelClasses = computed(() => {
|
|
|
459
478
|
<div
|
|
460
479
|
v-if="open && mode === 'docked'"
|
|
461
480
|
ref="dropdownEl"
|
|
462
|
-
class="fixed z-500 max-h-60 overflow-auto rounded-
|
|
481
|
+
class="fixed z-500 max-h-60 overflow-auto rounded-xs bg-surface-container shadow-elevation-2"
|
|
463
482
|
:style="dropPos"
|
|
464
483
|
>
|
|
465
484
|
<div class="flex flex-col py-1">
|
|
@@ -494,7 +513,7 @@ const labelClasses = computed(() => {
|
|
|
494
513
|
<Transition name="m3-mac-modal">
|
|
495
514
|
<div
|
|
496
515
|
v-if="modalOpen && mode === 'modal'"
|
|
497
|
-
class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/
|
|
516
|
+
class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/32 p-4"
|
|
498
517
|
@click.self="closeDropdown"
|
|
499
518
|
>
|
|
500
519
|
<div class="mac-modal-box flex max-h-[80vh] w-full max-w-sm flex-col overflow-hidden rounded-[28px] bg-surface-container-high shadow-elevation-3">
|
|
@@ -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[]
|
|
@@ -119,6 +123,7 @@ function toggle(value: unknown) {
|
|
|
119
123
|
|
|
120
124
|
function removeChip(value: unknown, e: Event) {
|
|
121
125
|
e.stopPropagation()
|
|
126
|
+
if (props.disabled) return
|
|
122
127
|
emit('update:modelValue', props.modelValue.filter((v) => !eq(v, value)))
|
|
123
128
|
}
|
|
124
129
|
|
|
@@ -191,28 +196,35 @@ onUnmounted(() => {
|
|
|
191
196
|
|
|
192
197
|
const triggerClasses = computed(() => {
|
|
193
198
|
const base = [
|
|
194
|
-
'flex min-h-[56px] w-full
|
|
199
|
+
'flex min-h-[56px] w-full items-center gap-1.5 flex-wrap',
|
|
195
200
|
'transition-[border-color,border-width] duration-150',
|
|
201
|
+
props.disabled ? 'cursor-not-allowed' : 'cursor-pointer',
|
|
196
202
|
props.leadingIcon ? 'pl-12 pr-10' : 'pl-4 pr-10',
|
|
197
203
|
]
|
|
198
204
|
|
|
199
205
|
if (props.variant === 'outlined') {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
open.value
|
|
206
|
+
const border = props.disabled
|
|
207
|
+
? 'border-on-surface/12'
|
|
208
|
+
: open.value
|
|
204
209
|
? (props.error ? 'border-2 border-error' : 'border-2 border-primary')
|
|
205
|
-
: (props.error ? 'border-error' : 'border-outline hover:border-on-surface')
|
|
206
|
-
].join(' ')
|
|
210
|
+
: (props.error ? 'border-error' : 'border-outline hover:border-on-surface')
|
|
211
|
+
return [...base, 'rounded-xs border bg-transparent py-2', border].join(' ')
|
|
207
212
|
}
|
|
208
213
|
|
|
214
|
+
const border = props.disabled
|
|
215
|
+
? 'border-on-surface/38'
|
|
216
|
+
: open.value
|
|
217
|
+
? (props.error ? 'border-b-2 border-error' : 'border-b-2 border-primary')
|
|
218
|
+
: (props.error ? 'border-error' : 'border-on-surface-variant hover:border-on-surface')
|
|
219
|
+
const bg = props.disabled
|
|
220
|
+
? 'bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]'
|
|
221
|
+
: 'bg-surface-container-highest'
|
|
209
222
|
return [
|
|
210
223
|
...base,
|
|
211
|
-
'rounded-t-
|
|
224
|
+
'rounded-t-xs border-b pb-2',
|
|
212
225
|
hasValue.value || open.value ? 'pt-7' : 'pt-4',
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
: (props.error ? 'border-error' : 'border-on-surface-variant hover:border-on-surface'),
|
|
226
|
+
bg,
|
|
227
|
+
border,
|
|
216
228
|
].join(' ')
|
|
217
229
|
})
|
|
218
230
|
|
|
@@ -234,15 +246,17 @@ const labelClasses = computed(() => {
|
|
|
234
246
|
'pointer-events-none absolute right-10 truncate transition-all duration-200',
|
|
235
247
|
left,
|
|
236
248
|
active ? floated : unFloated,
|
|
237
|
-
|
|
238
|
-
?
|
|
239
|
-
:
|
|
249
|
+
props.disabled
|
|
250
|
+
? 'text-on-surface/38'
|
|
251
|
+
: open.value
|
|
252
|
+
? (props.error ? 'text-error' : 'text-primary')
|
|
253
|
+
: (props.error ? 'text-error' : 'text-on-surface-variant'),
|
|
240
254
|
].join(' ')
|
|
241
255
|
})
|
|
242
256
|
</script>
|
|
243
257
|
|
|
244
258
|
<template>
|
|
245
|
-
<div class="flex flex-col gap-1">
|
|
259
|
+
<div class="flex flex-col gap-1" v-bind="$attrs">
|
|
246
260
|
<div
|
|
247
261
|
ref="fieldEl"
|
|
248
262
|
class="relative"
|
|
@@ -251,10 +265,13 @@ const labelClasses = computed(() => {
|
|
|
251
265
|
>
|
|
252
266
|
<div
|
|
253
267
|
v-if="leadingIcon"
|
|
254
|
-
class="pointer-events-none absolute left-3.5
|
|
255
|
-
:class="
|
|
268
|
+
class="pointer-events-none absolute left-3.5"
|
|
269
|
+
:class="[
|
|
270
|
+
variant === 'filled' ? 'top-4.5' : 'top-4',
|
|
271
|
+
disabled ? 'text-on-surface/38' : 'text-on-surface-variant',
|
|
272
|
+
]"
|
|
256
273
|
>
|
|
257
|
-
<MIcon :name="leadingIcon" :size="
|
|
274
|
+
<MIcon :name="leadingIcon" :size="24" />
|
|
258
275
|
</div>
|
|
259
276
|
|
|
260
277
|
<!-- Trigger field -->
|
|
@@ -274,10 +291,12 @@ const labelClasses = computed(() => {
|
|
|
274
291
|
<span
|
|
275
292
|
v-for="(chip, i) in displayChips"
|
|
276
293
|
:key="i"
|
|
277
|
-
class="inline-flex items-center gap-1 rounded-full
|
|
294
|
+
class="inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-label-small"
|
|
295
|
+
:class="disabled ? 'bg-on-surface/12 text-on-surface/38' : 'bg-secondary-container text-on-secondary-container'"
|
|
278
296
|
>
|
|
279
297
|
{{ chip.label }}
|
|
280
298
|
<button
|
|
299
|
+
v-if="!disabled"
|
|
281
300
|
type="button"
|
|
282
301
|
class="flex h-4 w-4 items-center justify-center rounded-full hover:bg-on-secondary-container/20"
|
|
283
302
|
@click="removeChip(chip.value, $event)"
|
|
@@ -323,8 +342,11 @@ const labelClasses = computed(() => {
|
|
|
323
342
|
<MIcon
|
|
324
343
|
name="arrow_drop_down"
|
|
325
344
|
:size="24"
|
|
326
|
-
class="
|
|
327
|
-
:class="
|
|
345
|
+
class="transition-transform duration-200"
|
|
346
|
+
:class="[
|
|
347
|
+
open || modalOpen ? 'rotate-180' : '',
|
|
348
|
+
disabled ? 'text-on-surface/38' : 'text-on-surface-variant',
|
|
349
|
+
]"
|
|
328
350
|
/>
|
|
329
351
|
</div>
|
|
330
352
|
</div>
|
|
@@ -346,7 +368,7 @@ const labelClasses = computed(() => {
|
|
|
346
368
|
<div
|
|
347
369
|
v-if="open && mode === 'docked'"
|
|
348
370
|
ref="dropdownEl"
|
|
349
|
-
class="fixed z-500 max-h-60 overflow-auto rounded-
|
|
371
|
+
class="fixed z-500 max-h-60 overflow-auto rounded-xs bg-surface-container shadow-elevation-2"
|
|
350
372
|
:style="dropPos"
|
|
351
373
|
>
|
|
352
374
|
<div v-if="searchable" class="sticky top-0 bg-surface-container px-3 py-2">
|
|
@@ -389,7 +411,7 @@ const labelClasses = computed(() => {
|
|
|
389
411
|
<Transition name="m3-ms-modal">
|
|
390
412
|
<div
|
|
391
413
|
v-if="modalOpen && mode === 'modal'"
|
|
392
|
-
class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/
|
|
414
|
+
class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/32 p-4"
|
|
393
415
|
@click.self="close"
|
|
394
416
|
>
|
|
395
417
|
<div class="ms-modal-box flex max-h-[80vh] w-full max-w-sm flex-col overflow-hidden rounded-[28px] bg-surface-container-high shadow-elevation-3">
|
|
@@ -19,17 +19,12 @@ defineEmits<{ 'update:modelValue': [string | number] }>()
|
|
|
19
19
|
</script>
|
|
20
20
|
|
|
21
21
|
<template>
|
|
22
|
-
<nav class="flex h-20 w-full items-center justify-around border-t border-outline-variant bg-surface-container">
|
|
22
|
+
<nav class="flex h-20 w-full items-center justify-around border-t border-outline-variant bg-surface-container shadow-elevation-2">
|
|
23
23
|
<button
|
|
24
24
|
v-for="item in items"
|
|
25
25
|
:key="item.value"
|
|
26
26
|
type="button"
|
|
27
27
|
class="group flex flex-1 cursor-pointer flex-col items-center justify-center gap-1 self-stretch transition-colors focus-visible:outline-none"
|
|
28
|
-
:class="
|
|
29
|
-
item.value === modelValue
|
|
30
|
-
? 'text-on-secondary-container'
|
|
31
|
-
: 'text-on-surface-variant'
|
|
32
|
-
"
|
|
33
28
|
@click="$emit('update:modelValue', item.value)"
|
|
34
29
|
>
|
|
35
30
|
<!-- Pill indicator with icon -->
|
|
@@ -37,8 +32,8 @@ defineEmits<{ 'update:modelValue': [string | number] }>()
|
|
|
37
32
|
class="inline-flex h-8 items-center justify-center rounded-2xl transition-all duration-200"
|
|
38
33
|
:class="
|
|
39
34
|
item.value === modelValue
|
|
40
|
-
? 'w-16 bg-secondary-container'
|
|
41
|
-
: 'w-0 bg-secondary-container/0 group-hover:w-16 group-hover:bg-on-surface/8'
|
|
35
|
+
? 'w-16 bg-secondary-container text-on-secondary-container'
|
|
36
|
+
: 'w-0 bg-secondary-container/0 text-on-surface-variant group-hover:w-16 group-hover:bg-on-surface/8'
|
|
42
37
|
"
|
|
43
38
|
>
|
|
44
39
|
<MBadge v-if="item.badge != null" :count="item.badge">
|
|
@@ -52,8 +47,8 @@ defineEmits<{ 'update:modelValue': [string | number] }>()
|
|
|
52
47
|
|
|
53
48
|
<!-- Label -->
|
|
54
49
|
<span
|
|
55
|
-
class="text-label-medium
|
|
56
|
-
:class="item.value === modelValue ? '
|
|
50
|
+
class="text-label-medium font-medium"
|
|
51
|
+
:class="item.value === modelValue ? 'text-secondary' : 'text-on-surface-variant'"
|
|
57
52
|
>
|
|
58
53
|
{{ item.label }}
|
|
59
54
|
</span>
|
|
@@ -141,16 +141,17 @@ watch(
|
|
|
141
141
|
side === 'top' ? 'flex-col' : '',
|
|
142
142
|
]"
|
|
143
143
|
>
|
|
144
|
-
<div class="nd-scrim absolute inset-0 bg-scrim/
|
|
144
|
+
<div class="nd-scrim absolute inset-0 bg-scrim/32" @click="close" />
|
|
145
145
|
|
|
146
146
|
<nav
|
|
147
147
|
:class="[
|
|
148
|
-
'nd-panel relative flex flex-col bg-surface-container shadow-elevation-
|
|
148
|
+
'nd-panel relative flex flex-col bg-surface-container-low shadow-elevation-1',
|
|
149
149
|
`nd-panel-${side}`,
|
|
150
150
|
side === 'top' || side === 'bottom'
|
|
151
151
|
? 'w-full max-h-[85vh]'
|
|
152
152
|
: 'h-full max-w-[85vw]',
|
|
153
|
-
side === 'top' || side === 'bottom' || width ? '' : 'w-
|
|
153
|
+
side === 'top' || side === 'bottom' || width ? '' : 'w-[22.5rem]',
|
|
154
|
+
side === 'right' ? 'rounded-l-lg' : side === 'left' ? 'rounded-r-lg' : side === 'bottom' ? 'rounded-t-lg' : '',
|
|
154
155
|
]"
|
|
155
156
|
:style="side !== 'top' && side !== 'bottom' && width ? { width } : undefined"
|
|
156
157
|
>
|
|
@@ -208,7 +209,7 @@ watch(
|
|
|
208
209
|
:is="itemTag(item)"
|
|
209
210
|
:to="item.to && !item.disabled ? item.to : undefined"
|
|
210
211
|
:type="item.to ? undefined : 'button'"
|
|
211
|
-
class="flex w-full items-center gap-3 rounded-full py-
|
|
212
|
+
class="flex w-full items-center gap-3 rounded-full py-4 text-left transition-colors focus-visible:outline-none"
|
|
212
213
|
:class="[
|
|
213
214
|
section.collapsible ? 'pl-8 pr-3' : 'px-4',
|
|
214
215
|
item.disabled
|
|
@@ -271,14 +272,14 @@ watch(
|
|
|
271
272
|
<nav
|
|
272
273
|
class="nd-inline flex h-full shrink-0 flex-col bg-surface"
|
|
273
274
|
:class="[
|
|
274
|
-
inlineSide === 'right' ? 'border-l border-outline-variant' : 'border-r border-outline-variant',
|
|
275
|
+
inlineSide === 'right' ? 'border-l border-outline-variant rounded-l-lg' : 'border-r border-outline-variant rounded-r-lg',
|
|
275
276
|
!modelValue
|
|
276
277
|
? inlineSide === 'right' ? 'nd-hidden w-0 border-l-0' : 'nd-hidden w-0 border-r-0'
|
|
277
278
|
: collapsed
|
|
278
279
|
? 'nd-collapsed w-[72px]'
|
|
279
|
-
: width ? '' : 'w-
|
|
280
|
+
: width ? '' : 'w-[22.5rem]',
|
|
280
281
|
]"
|
|
281
|
-
:style="{ width: modelValue && !collapsed && width ? width : undefined, '--nd-width': width ?? '
|
|
282
|
+
:style="{ width: modelValue && !collapsed && width ? width : undefined, '--nd-width': width ?? '22.5rem' }"
|
|
282
283
|
>
|
|
283
284
|
<div v-if="$slots.toggle" class="nd-toggle shrink-0 border-b border-outline-variant">
|
|
284
285
|
<div class="nd-toggle-inner">
|
|
@@ -350,7 +351,7 @@ watch(
|
|
|
350
351
|
:to="item.to && !item.disabled ? item.to : undefined"
|
|
351
352
|
:type="item.to ? undefined : 'button'"
|
|
352
353
|
:title="collapsed ? item.label : undefined"
|
|
353
|
-
class="flex w-full shrink-0 items-center gap-3 overflow-hidden whitespace-nowrap rounded-full py-
|
|
354
|
+
class="flex w-full shrink-0 items-center gap-3 overflow-hidden whitespace-nowrap rounded-full py-4 text-left focus-visible:outline-none"
|
|
354
355
|
:class="[
|
|
355
356
|
section.collapsible && !collapsed ? 'pl-8 pr-3' : 'px-3',
|
|
356
357
|
item.disabled
|
|
@@ -487,7 +488,7 @@ watch(
|
|
|
487
488
|
|
|
488
489
|
/* Freeze layout so content clips like a curtain during open/close */
|
|
489
490
|
.nd-inline > * {
|
|
490
|
-
min-width: var(--nd-width,
|
|
491
|
+
min-width: var(--nd-width, 22.5rem);
|
|
491
492
|
}
|
|
492
493
|
/* Collapse-to-icons: let children adapt to 72px width */
|
|
493
494
|
.nd-inline.nd-collapsed > * {
|