@m3ui-vue/m3ui-vue 0.7.0 → 0.8.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 +5 -5
- package/dist/{MMenuItem-B_5um6tj.js → MMenuItem-vSLbJGqe.js} +314 -230
- package/dist/MMenuItem-vSLbJGqe.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/MCard.vue.d.ts +2 -0
- package/dist/components/MChatBubble.vue.d.ts +0 -1
- package/dist/components/MCheckbox.vue.d.ts +2 -0
- 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/MDialog.vue.d.ts +23 -7
- package/dist/components/MFab.vue.d.ts +2 -2
- package/dist/components/MListItem.vue.d.ts +11 -6
- package/dist/components/MNavigationRail.vue.d.ts +17 -1
- package/dist/components/MSelect.vue.d.ts +1 -0
- package/dist/components/MSwitch.vue.d.ts +10 -0
- package/dist/components/MTabs.vue.d.ts +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +2393 -2005
- 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 +2 -0
- package/dist/styles.css +1 -1
- package/package.json +13 -1
- package/src/__tests__/useColorPalette.test.ts +2 -2
- package/src/code-editor.ts +1 -0
- package/src/components/MAutocomplete.vue +35 -26
- package/src/components/MBadge.vue +1 -1
- package/src/components/MBottomSheet.vue +4 -4
- package/src/components/MButton.vue +48 -15
- package/src/components/MButtonGroup.vue +2 -2
- package/src/components/MCard.vue +83 -9
- package/src/components/MChatBubble.vue +0 -1
- package/src/components/MCheckbox.vue +78 -18
- package/src/components/MChip.vue +33 -4
- package/src/components/MCircleProgressBar.vue +7 -4
- package/src/components/MCodeEditor.vue +54 -8
- 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 +23 -2
- package/src/components/MDatePicker.vue +11 -11
- package/src/components/MDatePickerModal.vue +5 -5
- package/src/components/MDateRangePicker.vue +12 -12
- package/src/components/MDateRangePickerModal.vue +3 -3
- package/src/components/MDialog.vue +103 -12
- package/src/components/MFab.vue +13 -8
- package/src/components/MFabMenu.vue +1 -1
- package/src/components/MIconButton.vue +50 -14
- 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 +28 -3
- package/src/components/MMenuItem.vue +2 -2
- package/src/components/MMultiAutocomplete.vue +41 -26
- package/src/components/MMultiSelect.vue +40 -22
- 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 +74 -30
- package/src/components/MSearchBar.vue +3 -2
- package/src/components/MSegmentedButton.vue +14 -9
- package/src/components/MSelect.vue +44 -32
- package/src/components/MSideSheet.vue +1 -1
- package/src/components/MSlider.vue +42 -20
- 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 +138 -33
- 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/MToolbar.vue +5 -3
- package/src/components/MTooltip.vue +4 -4
- package/src/components/MTopAppBar.vue +14 -6
- package/src/components/MTour.vue +1 -1
- package/src/composables/useColorPalette.ts +10 -0
- package/src/index.ts +1 -0
- package/src/styles/palettes.css +659 -0
- package/src/styles/theme.css +2 -0
- package/dist/MMenuItem-B_5um6tj.js.map +0 -1
|
@@ -1,61 +1,166 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed } from 'vue'
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
3
|
import MIcon from './MIcon.vue'
|
|
4
4
|
|
|
5
5
|
const props = withDefaults(
|
|
6
|
-
defineProps<{
|
|
7
|
-
|
|
6
|
+
defineProps<{
|
|
7
|
+
modelValue: boolean
|
|
8
|
+
disabled?: boolean
|
|
9
|
+
label?: string
|
|
10
|
+
color?: 'primary' | 'secondary' | 'tertiary' | 'error'
|
|
11
|
+
/**
|
|
12
|
+
* M3 officially has two Switch variants: with a check icon inside the thumb (the
|
|
13
|
+
* `thumbContent` slot filled), and without (Compose's actual default — `thumbContent`
|
|
14
|
+
* defaults to `null`). Defaults to `true` here to keep this component's existing look;
|
|
15
|
+
* pass `false` for the plain/no-icon variant.
|
|
16
|
+
*/
|
|
17
|
+
icon?: boolean
|
|
18
|
+
}>(),
|
|
19
|
+
{ disabled: false, color: 'primary', icon: true },
|
|
8
20
|
)
|
|
9
21
|
|
|
10
22
|
const emit = defineEmits<{ 'update:modelValue': [boolean] }>()
|
|
11
23
|
|
|
24
|
+
// Same 4 named colors as MRadio/MCheckbox's color prop.
|
|
25
|
+
const trackClasses: Record<string, string> = {
|
|
26
|
+
primary: 'border-primary bg-primary',
|
|
27
|
+
secondary: 'border-secondary bg-secondary',
|
|
28
|
+
tertiary: 'border-tertiary bg-tertiary',
|
|
29
|
+
error: 'border-error bg-error',
|
|
30
|
+
}
|
|
31
|
+
// Selected handle: resting = on-{color} (OnPrimary etc.), hover/focus/press = {color}-container
|
|
32
|
+
// (SwitchTokens.Selected{Hover,Focus,Pressed}HandleColor = PrimaryContainer, NOT OnPrimary —
|
|
33
|
+
// the handle itself recolors on interaction, distinct from the track staying put).
|
|
34
|
+
const thumbClasses: Record<string, string> = {
|
|
35
|
+
primary: 'bg-on-primary group-hover:bg-primary-container group-active:bg-primary-container peer-focus-visible:bg-primary-container',
|
|
36
|
+
secondary: 'bg-on-secondary group-hover:bg-secondary-container group-active:bg-secondary-container peer-focus-visible:bg-secondary-container',
|
|
37
|
+
tertiary: 'bg-on-tertiary group-hover:bg-tertiary-container group-active:bg-tertiary-container peer-focus-visible:bg-tertiary-container',
|
|
38
|
+
error: 'bg-on-error group-hover:bg-error-container group-active:bg-error-container peer-focus-visible:bg-error-container',
|
|
39
|
+
}
|
|
40
|
+
// Unselected handle: resting = outline, hover/focus/press = on-surface-variant — a fixed
|
|
41
|
+
// color regardless of the `color` prop, since the unselected state never carries it.
|
|
42
|
+
const unselectedThumbClasses =
|
|
43
|
+
'bg-outline group-hover:bg-on-surface-variant group-active:bg-on-surface-variant peer-focus-visible:bg-on-surface-variant'
|
|
44
|
+
|
|
45
|
+
// Icon-on-handle color is a DIFFERENT role from the handle's own fill (SelectedIconColor =
|
|
46
|
+
// OnPrimaryContainer, not OnPrimary) — it needs to read against whatever the handle is
|
|
47
|
+
// currently showing (on-primary at rest, primary-container on hover/press), and
|
|
48
|
+
// on-primary-container works against both.
|
|
49
|
+
const iconClasses: Record<string, string> = {
|
|
50
|
+
primary: 'text-on-primary-container',
|
|
51
|
+
secondary: 'text-on-secondary-container',
|
|
52
|
+
tertiary: 'text-on-tertiary-container',
|
|
53
|
+
error: 'text-on-error-container',
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// State layer + focus ring tint, same idea as the handle color map above but for the
|
|
57
|
+
// larger 40px circle that trails the thumb (see stateLayerStyle below) rather than the
|
|
58
|
+
// handle itself — reuses the selected color's own base tone (bg-primary etc.), not the
|
|
59
|
+
// container variant, matching StateLayerShape's plain-color state-layer convention used
|
|
60
|
+
// for MCheckbox/MChip/MRadio elsewhere in this library.
|
|
61
|
+
const stateLayerBg: Record<string, string> = {
|
|
62
|
+
primary: 'bg-primary',
|
|
63
|
+
secondary: 'bg-secondary',
|
|
64
|
+
tertiary: 'bg-tertiary',
|
|
65
|
+
error: 'bg-error',
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Real handle grows from 24dp (selected) / 16dp (unselected) to a shared 28dp while
|
|
69
|
+
// pressed (SwitchTokens.Pressed{Handle}Width/Height) — via `scale()` on the same fixed-size
|
|
70
|
+
// box the 16dp unselected state already uses `scale(0.667)` for, not by changing width/
|
|
71
|
+
// height directly (which would fight the JS-computed inline `transform` below on
|
|
72
|
+
// specificity, the same class-vs-inline-style trap already hit once this session).
|
|
73
|
+
// Needs real pointerdown/up tracking (not a CSS `active:` utility) because that transform
|
|
74
|
+
// is computed in JS, not a plain class, so CSS pseudo-classes can't reach into it.
|
|
75
|
+
const isPressed = ref(false)
|
|
76
|
+
function onPointerDown() {
|
|
77
|
+
if (!props.disabled) isPressed.value = true
|
|
78
|
+
}
|
|
79
|
+
function onPointerEnd() {
|
|
80
|
+
isPressed.value = false
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const thumbScale = computed(() => {
|
|
84
|
+
if (isPressed.value) return 28 / 24
|
|
85
|
+
return props.modelValue ? 1 : 16 / 24
|
|
86
|
+
})
|
|
87
|
+
|
|
12
88
|
// All thumb transforms live here so each direction can use its own easing curve.
|
|
13
|
-
// translateY(-50%) vertically centres the
|
|
89
|
+
// translateY(-50%) vertically centres the thumb in the 32px track.
|
|
14
90
|
// ON → spring cubic-bezier: overshoots ~2px then settles → satisfying "click"
|
|
15
91
|
// OFF → M3 standard decelerate: clean snap back, no undershoot
|
|
16
92
|
const thumbStyle = computed(() => ({
|
|
17
|
-
transform: props.modelValue
|
|
18
|
-
? 'translateY(-50%) translateX(18px) scale(1)'
|
|
19
|
-
: 'translateY(-50%) translateX(0px) scale(0.667)',
|
|
93
|
+
transform: `translateY(-50%) translateX(${props.modelValue ? 18 : 0}px) scale(${thumbScale.value})`,
|
|
20
94
|
transition: props.modelValue
|
|
21
95
|
? 'transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1), background-color 280ms ease'
|
|
22
96
|
: 'transform 240ms cubic-bezier(0.2, 0, 0, 1), background-color 240ms ease',
|
|
23
97
|
}))
|
|
98
|
+
|
|
99
|
+
// StateLayerSize/StateLayerShape = 40dp circle, CornerFull — positioned to trail the
|
|
100
|
+
// thumb's own translateX so it's centered on the thumb at both ends of the track, not a
|
|
101
|
+
// static overlay covering the whole switch the way MCheckbox/MRadio's does (those don't
|
|
102
|
+
// have a moving part). Base offset -4px accounts for the 40px circle being 8px taller/wider
|
|
103
|
+
// than the 32px track and 24px thumb it's centered on.
|
|
104
|
+
const stateLayerStyle = computed(() => ({
|
|
105
|
+
transform: `translateX(${props.modelValue ? 18 : 0}px)`,
|
|
106
|
+
transition: props.modelValue
|
|
107
|
+
? 'transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1)'
|
|
108
|
+
: 'transform 240ms cubic-bezier(0.2, 0, 0, 1)',
|
|
109
|
+
}))
|
|
24
110
|
</script>
|
|
25
111
|
|
|
26
112
|
<template>
|
|
27
113
|
<label
|
|
28
|
-
class="inline-flex items-center gap-3 select-none"
|
|
114
|
+
class="group inline-flex items-center gap-3 select-none"
|
|
29
115
|
:class="disabled ? 'cursor-not-allowed opacity-[0.38]' : 'cursor-pointer'"
|
|
116
|
+
@pointerdown="onPointerDown"
|
|
117
|
+
@pointerup="onPointerEnd"
|
|
118
|
+
@pointerleave="onPointerEnd"
|
|
119
|
+
@pointercancel="onPointerEnd"
|
|
30
120
|
>
|
|
31
|
-
<span
|
|
32
|
-
class="relative inline-flex h-8 w-[52px] shrink-0 items-center rounded-full border-2 transition-colors duration-200"
|
|
33
|
-
:class="modelValue ? 'border-primary bg-primary' : 'border-outline bg-surface-container-highest'"
|
|
34
|
-
>
|
|
35
|
-
<input
|
|
36
|
-
type="checkbox"
|
|
37
|
-
class="sr-only"
|
|
38
|
-
:checked="modelValue"
|
|
39
|
-
:disabled="disabled"
|
|
40
|
-
@change="emit('update:modelValue', !modelValue)"
|
|
41
|
-
/>
|
|
42
|
-
|
|
43
|
-
<!-- Thumb: position + size animated via inline style (allows per-direction easing) -->
|
|
121
|
+
<span class="relative -my-2 inline-flex h-12 shrink-0 items-center">
|
|
44
122
|
<span
|
|
45
|
-
class="
|
|
46
|
-
:class="modelValue ?
|
|
47
|
-
:style="thumbStyle"
|
|
123
|
+
class="relative inline-flex h-8 w-[52px] items-center rounded-full border-2 transition-colors duration-200"
|
|
124
|
+
:class="modelValue ? trackClasses[color] : 'border-outline bg-surface-container-highest'"
|
|
48
125
|
>
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
126
|
+
<input
|
|
127
|
+
type="checkbox"
|
|
128
|
+
class="peer sr-only"
|
|
129
|
+
:checked="modelValue"
|
|
130
|
+
:disabled="disabled"
|
|
131
|
+
@change="emit('update:modelValue', !modelValue)"
|
|
132
|
+
/>
|
|
133
|
+
|
|
134
|
+
<!-- Hover/press/focus state layer + focus ring, both tracking the thumb's position (see stateLayerStyle doc above) -->
|
|
135
|
+
<span
|
|
136
|
+
v-if="!disabled"
|
|
137
|
+
class="pointer-events-none absolute top-1/2 -left-1 h-10 w-10 -translate-y-1/2 rounded-full opacity-0 transition-opacity duration-150 group-hover:opacity-[0.08] group-active:opacity-[0.12] peer-focus-visible:opacity-[0.08]"
|
|
138
|
+
:class="modelValue ? stateLayerBg[color] : 'bg-on-surface-variant'"
|
|
139
|
+
:style="stateLayerStyle"
|
|
140
|
+
/>
|
|
141
|
+
<span
|
|
142
|
+
v-if="!disabled"
|
|
143
|
+
class="pointer-events-none absolute top-1/2 -left-1 h-10 w-10 -translate-y-1/2 rounded-full ring-0 ring-secondary transition-[box-shadow] duration-150 peer-focus-visible:ring-2"
|
|
144
|
+
:style="stateLayerStyle"
|
|
145
|
+
/>
|
|
146
|
+
|
|
147
|
+
<!-- Thumb: position + size animated via inline style (allows per-direction easing) -->
|
|
148
|
+
<span
|
|
149
|
+
class="absolute left-1 top-1/2 flex h-6 w-6 items-center justify-center rounded-full will-change-transform"
|
|
150
|
+
:class="modelValue ? [thumbClasses[color], 'shadow-sm'] : unselectedThumbClasses"
|
|
151
|
+
:style="thumbStyle"
|
|
56
152
|
>
|
|
57
|
-
<
|
|
58
|
-
|
|
153
|
+
<Transition
|
|
154
|
+
enter-active-class="transition-opacity duration-150 delay-[120ms]"
|
|
155
|
+
enter-from-class="opacity-0"
|
|
156
|
+
enter-to-class="opacity-100"
|
|
157
|
+
leave-active-class="transition-opacity duration-75"
|
|
158
|
+
leave-from-class="opacity-100"
|
|
159
|
+
leave-to-class="opacity-0"
|
|
160
|
+
>
|
|
161
|
+
<MIcon v-if="modelValue && icon" name="check" :size="14" :class="iconClasses[color]" />
|
|
162
|
+
</Transition>
|
|
163
|
+
</span>
|
|
59
164
|
</span>
|
|
60
165
|
</span>
|
|
61
166
|
<span v-if="label" class="text-body-large text-on-surface">{{ label }}</span>
|
package/src/components/MTabs.vue
CHANGED
|
@@ -13,7 +13,9 @@ const props = withDefaults(defineProps<{
|
|
|
13
13
|
modelValue: string | number
|
|
14
14
|
tabs: Tab[]
|
|
15
15
|
variant?: 'primary' | 'secondary'
|
|
16
|
-
|
|
16
|
+
/** Fixed (default, M3 `TabRow`): tabs evenly share the available width, no scrolling — use for 2-5 tabs. Scrollable (M3 `ScrollableTabRow`): tabs keep their natural width and the row scrolls horizontally when they overflow — use for many tabs. */
|
|
17
|
+
scrollable?: boolean
|
|
18
|
+
}>(), { variant: 'primary', scrollable: false })
|
|
17
19
|
|
|
18
20
|
const emit = defineEmits<{ 'update:modelValue': [string | number] }>()
|
|
19
21
|
|
|
@@ -120,15 +122,16 @@ function select(tab: Tab) {
|
|
|
120
122
|
<template>
|
|
121
123
|
<!-- ── Primary: sliding short indicator with stretch ──────────────── -->
|
|
122
124
|
<div v-if="variant === 'primary'" class="border-b border-outline-variant">
|
|
123
|
-
<div class="relative flex overflow-x-auto" style="scrollbar-width: none">
|
|
125
|
+
<div class="relative flex" :class="scrollable ? 'overflow-x-auto' : 'overflow-x-hidden'" style="scrollbar-width: none">
|
|
124
126
|
<button
|
|
125
127
|
v-for="tab in tabs"
|
|
126
128
|
:key="tab.value"
|
|
127
129
|
:ref="(el) => { if (el) tabEls[tabs.indexOf(tab)] = el as HTMLElement }"
|
|
128
130
|
type="button"
|
|
129
|
-
class="relative flex
|
|
131
|
+
class="relative flex flex-col items-center justify-center gap-1 px-6 text-title-small transition-colors duration-150 focus-visible:outline-none"
|
|
130
132
|
:class="[
|
|
131
|
-
|
|
133
|
+
scrollable ? 'shrink-0' : 'flex-1 min-w-0',
|
|
134
|
+
tab.icon ? 'h-16 pb-1.5' : 'h-12 pb-1.5',
|
|
132
135
|
tab.value === modelValue
|
|
133
136
|
? 'text-primary'
|
|
134
137
|
: tab.disabled
|
|
@@ -138,7 +141,7 @@ function select(tab: Tab) {
|
|
|
138
141
|
:disabled="tab.disabled"
|
|
139
142
|
@click="select(tab)"
|
|
140
143
|
>
|
|
141
|
-
<MIcon v-if="tab.icon" :name="tab.icon" :size="
|
|
144
|
+
<MIcon v-if="tab.icon" :name="tab.icon" :size="24" />
|
|
142
145
|
<span>{{ tab.label }}</span>
|
|
143
146
|
</button>
|
|
144
147
|
<div
|
|
@@ -150,28 +153,29 @@ function select(tab: Tab) {
|
|
|
150
153
|
|
|
151
154
|
<!-- ── Secondary: full-width underline indicator ─────────────────── -->
|
|
152
155
|
<div v-else class="border-b border-outline-variant">
|
|
153
|
-
<div class="relative flex overflow-x-auto" style="scrollbar-width: none">
|
|
156
|
+
<div class="relative flex" :class="scrollable ? 'overflow-x-auto' : 'overflow-x-hidden'" style="scrollbar-width: none">
|
|
154
157
|
<button
|
|
155
158
|
v-for="tab in tabs"
|
|
156
159
|
:key="tab.value"
|
|
157
160
|
:ref="(el) => { if (el) tabEls[tabs.indexOf(tab)] = el as HTMLElement }"
|
|
158
161
|
type="button"
|
|
159
|
-
class="relative flex h-12
|
|
160
|
-
:class="
|
|
162
|
+
class="relative flex h-12 items-center justify-center gap-2 px-6 text-title-small transition-colors duration-150 focus-visible:outline-none"
|
|
163
|
+
:class="[
|
|
164
|
+
scrollable ? 'shrink-0' : 'flex-1 min-w-0',
|
|
161
165
|
tab.value === modelValue
|
|
162
166
|
? 'text-on-surface'
|
|
163
167
|
: tab.disabled
|
|
164
168
|
? 'cursor-not-allowed text-on-surface/38'
|
|
165
|
-
: 'cursor-pointer text-on-surface-variant hover:text-on-surface'
|
|
166
|
-
"
|
|
169
|
+
: 'cursor-pointer text-on-surface-variant hover:text-on-surface',
|
|
170
|
+
]"
|
|
167
171
|
:disabled="tab.disabled"
|
|
168
172
|
@click="select(tab)"
|
|
169
173
|
>
|
|
170
|
-
<MIcon v-if="tab.icon" :name="tab.icon" :size="
|
|
174
|
+
<MIcon v-if="tab.icon" :name="tab.icon" :size="24" />
|
|
171
175
|
{{ tab.label }}
|
|
172
176
|
</button>
|
|
173
177
|
<div
|
|
174
|
-
class="absolute bottom-0 h-[
|
|
178
|
+
class="absolute bottom-0 h-[3px] bg-primary"
|
|
175
179
|
:style="{ left: `${indicatorLeft}px`, width: `${indicatorWidth}px` }"
|
|
176
180
|
/>
|
|
177
181
|
</div>
|
|
@@ -116,29 +116,30 @@ function focusInput() {
|
|
|
116
116
|
|
|
117
117
|
const triggerClasses = computed(() => {
|
|
118
118
|
const base = [
|
|
119
|
-
'flex min-h-[56px] w-full
|
|
119
|
+
'flex min-h-[56px] w-full items-center gap-1.5 flex-wrap',
|
|
120
120
|
'transition-[border-color,border-width] duration-150',
|
|
121
|
+
props.disabled ? 'cursor-not-allowed' : 'cursor-text',
|
|
121
122
|
props.leadingIcon ? 'pl-12 pr-10' : 'pl-4 pr-10',
|
|
122
123
|
]
|
|
123
124
|
|
|
124
125
|
if (props.variant === 'outlined') {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
focused.value
|
|
126
|
+
const border = props.disabled
|
|
127
|
+
? 'border-on-surface/12'
|
|
128
|
+
: focused.value
|
|
129
129
|
? (props.error ? 'border-2 border-error' : 'border-2 border-primary')
|
|
130
|
-
: (props.error ? 'border-error' : 'border-outline hover:border-on-surface')
|
|
131
|
-
].join(' ')
|
|
130
|
+
: (props.error ? 'border-error' : 'border-outline hover:border-on-surface')
|
|
131
|
+
return [...base, 'rounded-xs border bg-transparent py-2', border].join(' ')
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
hasValue.value || focused.value ? 'pt-7' : 'pt-4',
|
|
138
|
-
focused.value
|
|
134
|
+
const border = props.disabled
|
|
135
|
+
? 'border-on-surface/38'
|
|
136
|
+
: focused.value
|
|
139
137
|
? (props.error ? 'border-b-2 border-error' : 'border-b-2 border-primary')
|
|
140
|
-
: (props.error ? 'border-error' : 'border-on-surface-variant hover:border-on-surface')
|
|
141
|
-
|
|
138
|
+
: (props.error ? 'border-error' : 'border-on-surface-variant hover:border-on-surface')
|
|
139
|
+
const bg = props.disabled
|
|
140
|
+
? 'bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]'
|
|
141
|
+
: 'bg-surface-container-highest'
|
|
142
|
+
return [...base, 'rounded-t-xs border-b pb-2', hasValue.value || focused.value ? 'pt-7' : 'pt-4', bg, border].join(' ')
|
|
142
143
|
})
|
|
143
144
|
|
|
144
145
|
const labelClasses = computed(() => {
|
|
@@ -159,9 +160,11 @@ const labelClasses = computed(() => {
|
|
|
159
160
|
'pointer-events-none absolute right-10 truncate transition-all duration-200',
|
|
160
161
|
left,
|
|
161
162
|
active ? floated : unFloated,
|
|
162
|
-
|
|
163
|
-
?
|
|
164
|
-
:
|
|
163
|
+
props.disabled
|
|
164
|
+
? 'text-on-surface/38'
|
|
165
|
+
: focused.value
|
|
166
|
+
? (props.error ? 'text-error' : 'text-primary')
|
|
167
|
+
: (props.error ? 'text-error' : 'text-on-surface-variant'),
|
|
165
168
|
].join(' ')
|
|
166
169
|
})
|
|
167
170
|
</script>
|
|
@@ -176,10 +179,13 @@ const labelClasses = computed(() => {
|
|
|
176
179
|
>
|
|
177
180
|
<div
|
|
178
181
|
v-if="leadingIcon"
|
|
179
|
-
class="pointer-events-none absolute left-3.5
|
|
180
|
-
:class="
|
|
182
|
+
class="pointer-events-none absolute left-3.5"
|
|
183
|
+
:class="[
|
|
184
|
+
variant === 'filled' ? 'top-4.5' : 'top-4',
|
|
185
|
+
disabled ? 'text-on-surface/38' : 'text-on-surface-variant',
|
|
186
|
+
]"
|
|
181
187
|
>
|
|
182
|
-
<MIcon :name="leadingIcon" :size="
|
|
188
|
+
<MIcon :name="leadingIcon" :size="24" />
|
|
183
189
|
</div>
|
|
184
190
|
|
|
185
191
|
<!-- Trigger field -->
|
|
@@ -191,7 +197,8 @@ const labelClasses = computed(() => {
|
|
|
191
197
|
<span
|
|
192
198
|
v-for="(tag, i) in modelValue"
|
|
193
199
|
:key="i"
|
|
194
|
-
class="inline-flex items-center gap-1 rounded-full
|
|
200
|
+
class="inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-label-small"
|
|
201
|
+
:class="disabled ? 'bg-on-surface/12 text-on-surface/38' : 'bg-secondary-container text-on-secondary-container'"
|
|
195
202
|
>
|
|
196
203
|
{{ tag }}
|
|
197
204
|
<button
|
|
@@ -210,7 +217,11 @@ const labelClasses = computed(() => {
|
|
|
210
217
|
type="text"
|
|
211
218
|
enterkeyhint="done"
|
|
212
219
|
autocomplete="off"
|
|
213
|
-
class="
|
|
220
|
+
:class="[
|
|
221
|
+
'min-w-[60px] flex-1 bg-transparent text-body-large outline-none placeholder:text-on-surface-variant',
|
|
222
|
+
error ? 'caret-error' : 'caret-primary',
|
|
223
|
+
disabled ? 'text-on-surface/38' : 'text-on-surface',
|
|
224
|
+
]"
|
|
214
225
|
:placeholder="!hasValue && (!label || focused) ? placeholder : ''"
|
|
215
226
|
:disabled="disabled"
|
|
216
227
|
:readonly="!canAddMore"
|
|
@@ -52,7 +52,8 @@ const inputClasses = computed(() => {
|
|
|
52
52
|
const base = [
|
|
53
53
|
"peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent",
|
|
54
54
|
"transition-[border-color,border-width] duration-150",
|
|
55
|
-
"disabled:cursor-not-allowed disabled:
|
|
55
|
+
"disabled:cursor-not-allowed disabled:text-on-surface/38",
|
|
56
|
+
props.error ? "caret-error" : "caret-primary",
|
|
56
57
|
size,
|
|
57
58
|
pl,
|
|
58
59
|
pr,
|
|
@@ -61,19 +62,21 @@ const inputClasses = computed(() => {
|
|
|
61
62
|
if (props.variant === "outlined") {
|
|
62
63
|
return [
|
|
63
64
|
...base,
|
|
64
|
-
"rounded-
|
|
65
|
+
"rounded-xs border bg-transparent py-4",
|
|
65
66
|
props.error
|
|
66
67
|
? "border-error focus:border-2 focus:border-error"
|
|
67
68
|
: "border-outline hover:border-on-surface focus:border-2 focus:border-primary",
|
|
69
|
+
"disabled:border-on-surface/12",
|
|
68
70
|
].join(" ");
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
return [
|
|
72
74
|
...base,
|
|
73
|
-
"rounded-t-
|
|
75
|
+
"rounded-t-xs bg-surface-container-highest border-b pt-6 pb-2",
|
|
74
76
|
props.error
|
|
75
77
|
? "border-error focus:border-b-2 focus:border-error"
|
|
76
78
|
: "border-on-surface-variant hover:border-on-surface focus:border-b-2 focus:border-primary",
|
|
79
|
+
"disabled:border-on-surface/38 disabled:bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]",
|
|
77
80
|
].join(" ");
|
|
78
81
|
});
|
|
79
82
|
|
|
@@ -106,6 +109,7 @@ const labelClasses = computed(() => {
|
|
|
106
109
|
props.error
|
|
107
110
|
? "text-error peer-focus:text-error"
|
|
108
111
|
: "text-on-surface-variant peer-focus:text-primary",
|
|
112
|
+
"peer-disabled:text-on-surface/38",
|
|
109
113
|
].join(" ");
|
|
110
114
|
}
|
|
111
115
|
|
|
@@ -117,6 +121,7 @@ const labelClasses = computed(() => {
|
|
|
117
121
|
props.error
|
|
118
122
|
? "text-error peer-focus:text-error"
|
|
119
123
|
: "text-on-surface-variant peer-focus:text-primary",
|
|
124
|
+
"peer-disabled:text-on-surface/38",
|
|
120
125
|
].join(" ");
|
|
121
126
|
});
|
|
122
127
|
|
|
@@ -142,10 +147,13 @@ function onInput(event: Event) {
|
|
|
142
147
|
>
|
|
143
148
|
<div
|
|
144
149
|
v-if="leadingIcon"
|
|
145
|
-
class="pointer-events-none absolute left-3.5
|
|
146
|
-
:class="
|
|
150
|
+
class="pointer-events-none absolute left-3.5"
|
|
151
|
+
:class="[
|
|
152
|
+
multiline ? 'top-[55%] -translate-y-1/2' : variant === 'filled' ? 'top-4.5' : 'top-4',
|
|
153
|
+
disabled ? 'text-on-surface/38' : 'text-on-surface-variant',
|
|
154
|
+
]"
|
|
147
155
|
>
|
|
148
|
-
<MIcon :name="leadingIcon" :size="
|
|
156
|
+
<MIcon :name="leadingIcon" :size="24" />
|
|
149
157
|
</div>
|
|
150
158
|
|
|
151
159
|
<textarea
|
|
@@ -121,18 +121,18 @@ onUnmounted(() => {
|
|
|
121
121
|
<div ref="triggerEl" class="relative mt-2" :style="{ '--field-bg': resolvedFieldBg }">
|
|
122
122
|
<button
|
|
123
123
|
type="button"
|
|
124
|
-
class="flex h-14 w-full items-center gap-2 rounded-
|
|
124
|
+
class="flex h-14 w-full items-center gap-2 rounded-xs border bg-transparent px-4 text-left text-body-large transition-[border-color,border-width] duration-150"
|
|
125
125
|
:class="[
|
|
126
|
-
disabled ? 'pointer-events-none
|
|
127
|
-
open
|
|
126
|
+
disabled ? 'pointer-events-none cursor-not-allowed border-on-surface/12' : 'cursor-pointer',
|
|
127
|
+
!disabled && (open
|
|
128
128
|
? error ? 'border-2 border-error' : 'border-2 border-primary'
|
|
129
|
-
: error ? 'border-error' : 'border-outline hover:border-on-surface',
|
|
129
|
+
: error ? 'border-error' : 'border-outline hover:border-on-surface'),
|
|
130
130
|
]"
|
|
131
131
|
@click="!disabled && (open = !open)"
|
|
132
132
|
>
|
|
133
|
-
<MIcon name="schedule" :size="
|
|
134
|
-
<span v-if="displayValue" class="flex-1 font-mono text-on-surface">{{ displayValue }}</span>
|
|
135
|
-
<span v-else class="flex-1 text-on-surface-variant">{{ label || placeholder || locale.selectTime }}</span>
|
|
133
|
+
<MIcon name="schedule" :size="24" class="shrink-0" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'" />
|
|
134
|
+
<span v-if="displayValue" class="flex-1 font-mono" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ displayValue }}</span>
|
|
135
|
+
<span v-else class="flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'">{{ label || placeholder || locale.selectTime }}</span>
|
|
136
136
|
<MIcon
|
|
137
137
|
v-if="modelValue"
|
|
138
138
|
name="close"
|
|
@@ -144,7 +144,7 @@ onUnmounted(() => {
|
|
|
144
144
|
<label
|
|
145
145
|
v-if="label"
|
|
146
146
|
class="pointer-events-none absolute -top-2.5 left-3 bg-(--field-bg) px-1 text-label-small transition-colors"
|
|
147
|
-
:class="open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant'"
|
|
147
|
+
:class="disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant'"
|
|
148
148
|
>
|
|
149
149
|
{{ label }}
|
|
150
150
|
</label>
|
|
@@ -163,7 +163,7 @@ onUnmounted(() => {
|
|
|
163
163
|
<div
|
|
164
164
|
v-if="open"
|
|
165
165
|
ref="panelEl"
|
|
166
|
-
class="fixed z-500 w-[280px] rounded-
|
|
166
|
+
class="fixed z-500 w-[280px] rounded-[28px] bg-surface-container-high shadow-elevation-3"
|
|
167
167
|
:style="dropPos"
|
|
168
168
|
>
|
|
169
169
|
<!-- Display -->
|
|
@@ -65,7 +65,7 @@ const SIZE = 256
|
|
|
65
65
|
const CX = SIZE / 2
|
|
66
66
|
const OUTER_R = 100
|
|
67
67
|
const INNER_R = 64
|
|
68
|
-
const NUM_R =
|
|
68
|
+
const NUM_R = 24
|
|
69
69
|
|
|
70
70
|
function posAt(idx: number, of: number, r: number) {
|
|
71
71
|
const a = (idx / of) * Math.PI * 2 - Math.PI / 2
|
|
@@ -237,7 +237,7 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
|
|
|
237
237
|
<Transition name="m3-tp-modal">
|
|
238
238
|
<div
|
|
239
239
|
v-if="show"
|
|
240
|
-
class="fixed inset-0 z-50 flex items-center justify-center bg-
|
|
240
|
+
class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/32 p-4"
|
|
241
241
|
@click.self="cancel"
|
|
242
242
|
>
|
|
243
243
|
<div class="tp-box w-[328px] rounded-[28px] bg-surface-container-high px-6 pt-6 pb-4 shadow-elevation-3">
|
|
@@ -252,7 +252,7 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
|
|
|
252
252
|
<div class="mb-5 flex items-center justify-center gap-2">
|
|
253
253
|
<button
|
|
254
254
|
type="button"
|
|
255
|
-
class="flex h-
|
|
255
|
+
class="flex h-20 min-w-[96px] items-center justify-center rounded-sm text-display-large transition-colors"
|
|
256
256
|
:class="
|
|
257
257
|
step === 'hour'
|
|
258
258
|
? 'bg-primary-container text-on-primary-container'
|
|
@@ -263,11 +263,11 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
|
|
|
263
263
|
{{ pad(selectedHour) }}
|
|
264
264
|
</button>
|
|
265
265
|
|
|
266
|
-
<span class="text-display-
|
|
266
|
+
<span class="text-display-large text-on-surface">:</span>
|
|
267
267
|
|
|
268
268
|
<button
|
|
269
269
|
type="button"
|
|
270
|
-
class="flex h-
|
|
270
|
+
class="flex h-20 min-w-[96px] items-center justify-center rounded-sm text-display-large transition-colors"
|
|
271
271
|
:class="
|
|
272
272
|
step === 'minute'
|
|
273
273
|
? 'bg-primary-container text-on-primary-container'
|
|
@@ -281,11 +281,11 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
|
|
|
281
281
|
<!-- AM / PM toggle -->
|
|
282
282
|
<div
|
|
283
283
|
v-if="!use24h"
|
|
284
|
-
class="ml-2 flex h-
|
|
284
|
+
class="ml-2 flex h-20 flex-col overflow-hidden rounded-sm border border-outline"
|
|
285
285
|
>
|
|
286
286
|
<button
|
|
287
287
|
type="button"
|
|
288
|
-
class="flex flex-1 items-center justify-center px-3 text-
|
|
288
|
+
class="flex flex-1 items-center justify-center px-3 text-title-medium transition-colors"
|
|
289
289
|
:class="
|
|
290
290
|
period === 'AM'
|
|
291
291
|
? 'bg-tertiary-container text-on-tertiary-container'
|
|
@@ -296,7 +296,7 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
|
|
|
296
296
|
<div class="h-px bg-outline" />
|
|
297
297
|
<button
|
|
298
298
|
type="button"
|
|
299
|
-
class="flex flex-1 items-center justify-center px-3 text-
|
|
299
|
+
class="flex flex-1 items-center justify-center px-3 text-title-medium transition-colors"
|
|
300
300
|
:class="
|
|
301
301
|
period === 'PM'
|
|
302
302
|
? 'bg-tertiary-container text-on-tertiary-container'
|
|
@@ -331,7 +331,7 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
|
|
|
331
331
|
v-for="item in hourItems"
|
|
332
332
|
:key="'h' + item.value"
|
|
333
333
|
type="button"
|
|
334
|
-
class="pointer-events-auto absolute flex h-10 w-10 items-center justify-center rounded-full text-body-
|
|
334
|
+
class="pointer-events-auto absolute flex h-10 w-10 items-center justify-center rounded-full text-body-large transition-colors"
|
|
335
335
|
:class="
|
|
336
336
|
item.value === selectedHour
|
|
337
337
|
? 'text-on-primary font-medium'
|
|
@@ -353,7 +353,7 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
|
|
|
353
353
|
v-for="item in minuteItems"
|
|
354
354
|
:key="'m' + item.value"
|
|
355
355
|
type="button"
|
|
356
|
-
class="pointer-events-auto absolute flex h-10 w-10 items-center justify-center rounded-full text-body-
|
|
356
|
+
class="pointer-events-auto absolute flex h-10 w-10 items-center justify-center rounded-full text-body-large transition-colors"
|
|
357
357
|
:class="
|
|
358
358
|
item.value === selectedMinute
|
|
359
359
|
? 'text-on-primary font-medium'
|
|
@@ -379,26 +379,26 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
|
|
|
379
379
|
v-model="inputHour"
|
|
380
380
|
type="text"
|
|
381
381
|
maxlength="2"
|
|
382
|
-
class="h-
|
|
382
|
+
class="h-20 w-[96px] rounded-sm border border-outline bg-surface-container-highest text-center text-display-large text-on-surface outline-none transition-colors focus:border-2 focus:border-primary"
|
|
383
383
|
@blur="clampInput"
|
|
384
384
|
/>
|
|
385
|
-
<span class="text-display-
|
|
385
|
+
<span class="text-display-large text-on-surface">:</span>
|
|
386
386
|
<input
|
|
387
387
|
ref="inputMinuteEl"
|
|
388
388
|
v-model="inputMinute"
|
|
389
389
|
type="text"
|
|
390
390
|
maxlength="2"
|
|
391
|
-
class="h-
|
|
391
|
+
class="h-20 w-[96px] rounded-sm border border-outline bg-surface-container-highest text-center text-display-large text-on-surface outline-none transition-colors focus:border-2 focus:border-primary"
|
|
392
392
|
@blur="clampInput"
|
|
393
393
|
/>
|
|
394
394
|
<!-- AM / PM toggle -->
|
|
395
395
|
<div
|
|
396
396
|
v-if="!use24h"
|
|
397
|
-
class="ml-2 flex h-
|
|
397
|
+
class="ml-2 flex h-20 flex-col overflow-hidden rounded-sm border border-outline"
|
|
398
398
|
>
|
|
399
399
|
<button
|
|
400
400
|
type="button"
|
|
401
|
-
class="flex flex-1 items-center justify-center px-3 text-
|
|
401
|
+
class="flex flex-1 items-center justify-center px-3 text-title-medium transition-colors"
|
|
402
402
|
:class="
|
|
403
403
|
period === 'AM'
|
|
404
404
|
? 'bg-tertiary-container text-on-tertiary-container'
|
|
@@ -409,7 +409,7 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
|
|
|
409
409
|
<div class="h-px bg-outline" />
|
|
410
410
|
<button
|
|
411
411
|
type="button"
|
|
412
|
-
class="flex flex-1 items-center justify-center px-3 text-
|
|
412
|
+
class="flex flex-1 items-center justify-center px-3 text-title-medium transition-colors"
|
|
413
413
|
:class="
|
|
414
414
|
period === 'PM'
|
|
415
415
|
? 'bg-tertiary-container text-on-tertiary-container'
|
|
@@ -56,12 +56,14 @@ const isVertical = computed(() => props.orientation === 'vertical')
|
|
|
56
56
|
<div
|
|
57
57
|
class="flex items-center gap-1"
|
|
58
58
|
:class="[
|
|
59
|
-
isVertical ? 'flex-col
|
|
59
|
+
isVertical ? 'flex-col w-16' : 'flex-row h-16',
|
|
60
|
+
isVertical ? (variant === 'floating' ? 'py-2' : 'py-4') : (variant === 'floating' ? 'px-2' : 'px-4'),
|
|
60
61
|
alignClass,
|
|
61
62
|
colorClasses,
|
|
62
|
-
variant === 'floating' ? 'rounded-
|
|
63
|
+
variant === 'floating' ? 'rounded-full' : '',
|
|
64
|
+
variant === 'floating' && fabPosition !== 'none' ? 'shadow-elevation-1' : '',
|
|
63
65
|
variant === 'docked' ? 'w-full border-t border-outline-variant' : '',
|
|
64
|
-
variant === 'docked' && isVertical ? 'h-full w-
|
|
66
|
+
variant === 'docked' && isVertical ? 'h-full w-16 border-t-0 border-r border-outline-variant' : '',
|
|
65
67
|
]"
|
|
66
68
|
>
|
|
67
69
|
<slot />
|