@m3ui-vue/m3ui-vue 1.9.0 → 1.10.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 +2 -0
- package/dist/API.md +305 -12
- package/dist/{MButton-LiZRRP4h.js → MButton-B9RCM06i.js} +4 -4
- package/dist/MButton-B9RCM06i.js.map +1 -0
- package/dist/{MColorPickerModal-IjciC8zh.js → MColorPickerModal-ChRtcZOo.js} +5 -5
- package/dist/{MColorPickerModal-IjciC8zh.js.map → MColorPickerModal-ChRtcZOo.js.map} +1 -1
- package/dist/{MDialog-BLpfgIA3.js → MDialog-dk07tify.js} +3 -3
- package/dist/{MDialog-BLpfgIA3.js.map → MDialog-dk07tify.js.map} +1 -1
- package/dist/{MIconButton-CNjN0xwW.js → MIconButton-CrBPZidd.js} +46 -39
- package/dist/MIconButton-CrBPZidd.js.map +1 -0
- package/dist/MListItem-h9H223vx.js +1239 -0
- package/dist/MListItem-h9H223vx.js.map +1 -0
- package/dist/{MLoadingIndicator-dejdXpu8.js → MLoadingIndicator-YTV1Ov5w.js} +2 -2
- package/dist/{MLoadingIndicator-dejdXpu8.js.map → MLoadingIndicator-YTV1Ov5w.js.map} +1 -1
- package/dist/MMenuItem-US0Zbglq.js +596 -0
- package/dist/MMenuItem-US0Zbglq.js.map +1 -0
- package/dist/{MPdfViewer-B5Q9Xs9d.js → MPdfViewer-DL9mRsd2.js} +8 -8
- package/dist/{MPdfViewer-B5Q9Xs9d.js.map → MPdfViewer-DL9mRsd2.js.map} +1 -1
- package/dist/MProgressBar-BzZMxq7M.js +254 -0
- package/dist/MProgressBar-BzZMxq7M.js.map +1 -0
- package/dist/{MSeekBar-NwkuAzx-.js → MSeekBar-JFZcoJ8y.js} +2 -2
- package/dist/{MSeekBar-NwkuAzx-.js.map → MSeekBar-JFZcoJ8y.js.map} +1 -1
- package/dist/MSegmentedButton-DMou-8sG.js +106 -0
- package/dist/MSegmentedButton-DMou-8sG.js.map +1 -0
- package/dist/{MSignaturePad-Bqr-1R9f.js → MSignaturePad-WuvE_Cyl.js} +2 -2
- package/dist/{MSignaturePad-Bqr-1R9f.js.map → MSignaturePad-WuvE_Cyl.js.map} +1 -1
- package/dist/{MSlider-B7dIcHVn.js → MSlider-7TzhFHKS.js} +3 -3
- package/dist/{MSlider-B7dIcHVn.js.map → MSlider-7TzhFHKS.js.map} +1 -1
- package/dist/{MSpinner-CXLY7lWw.js → MSpinner-CkIVBuGE.js} +2 -2
- package/dist/{MSpinner-CXLY7lWw.js.map → MSpinner-CkIVBuGE.js.map} +1 -1
- package/dist/{MTextField-CryHMs8-.js → MTextField-B6_iOczK.js} +3 -3
- package/dist/{MTextField-CryHMs8-.js.map → MTextField-B6_iOczK.js.map} +1 -1
- package/dist/{_useFieldValidation-CvZnZfl-.js → _useFieldValidation-COBJ1tWr.js} +2 -2
- package/dist/{_useFieldValidation-CvZnZfl-.js.map → _useFieldValidation-COBJ1tWr.js.map} +1 -1
- package/dist/api.json +1 -1
- package/dist/code-editor.js +2 -2
- package/dist/components/MAvatarGroup.vue.d.ts +48 -0
- package/dist/components/MCommentThread.vue.d.ts +42 -0
- package/dist/components/MContainer.vue.d.ts +1 -1
- package/dist/components/MContextMenu.vue.d.ts +7 -0
- package/dist/components/MDataTable.vue.d.ts +7 -0
- package/dist/components/MList.vue.d.ts +11 -0
- package/dist/components/MListDetail.vue.d.ts +22 -0
- package/dist/components/MListItem.vue.d.ts +9 -1
- package/dist/components/MMenu.vue.d.ts +10 -0
- package/dist/components/MReactions.vue.d.ts +35 -0
- package/dist/components/MScaffold.vue.d.ts +45 -0
- package/dist/components/MScrollField.vue.d.ts +4 -1
- package/dist/components/MScrollable.vue.d.ts +5 -4
- package/dist/components/MSpreadsheet.vue.d.ts +1 -1
- package/dist/components/MSupportingPane.vue.d.ts +22 -0
- package/dist/components/MTable.vue.d.ts +7 -0
- package/dist/components/MVirtualList.vue.d.ts +51 -0
- package/dist/components/_MComment.vue.d.ts +8 -0
- package/dist/components/_MCommentComposer.vue.d.ts +23 -0
- package/dist/components/_commentThread.d.ts +41 -0
- package/dist/composables/_menuGroups.d.ts +7 -0
- package/dist/composables/_usePaneResize.d.ts +45 -0
- package/dist/composables/useLocale.d.ts +22 -0
- package/dist/composables/useUndo.d.ts +45 -0
- package/dist/directives/vRipple.d.ts +4 -0
- package/dist/draw.js +4 -4
- package/dist/flow.js +2 -2
- package/dist/gantt.js +3 -3
- package/dist/index.d.ts +12 -0
- package/dist/locales/index.js +128 -0
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +11027 -9741
- package/dist/m3ui.js.map +1 -1
- package/dist/map.js +7 -7
- package/dist/media.js +6 -6
- package/dist/pdf-sign.js +8 -8
- package/dist/pdf.js +1 -1
- package/dist/plugin.d.ts +6 -0
- package/dist/rich-text-editor.js +6 -6
- package/dist/styles/theme.css +43 -6
- package/dist/styles.css +1 -1
- package/dist/{useLocale-ybIju59R.js → useLocale-YRaOT12S.js} +17 -1
- package/dist/useLocale-YRaOT12S.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/MListItemNestedControl.test.ts +1 -1
- package/src/__tests__/MListMultiSelect.test.ts +132 -0
- package/src/__tests__/MMenu.test.ts +152 -0
- package/src/__tests__/MProgressBar.test.ts +84 -1
- package/src/__tests__/MScrollField.test.ts +16 -0
- package/src/__tests__/MScrollable.test.ts +61 -5
- package/src/__tests__/MSwitch.test.ts +83 -0
- package/src/__tests__/adaptiveLayouts.test.ts +167 -0
- package/src/__tests__/backlogComponents.test.ts +249 -0
- package/src/__tests__/popupPosition.test.ts +4 -0
- package/src/__tests__/stateLayerOpacity.test.ts +65 -0
- package/src/__tests__/tableCheckboxReveal.test.ts +35 -0
- package/src/__tests__/vRipple.test.ts +62 -0
- package/src/components/MAvatarGroup.vue +150 -0
- package/src/components/MButton.vue +1 -1
- package/src/components/MButtonGroup.vue +1 -1
- package/src/components/MCard.vue +4 -2
- package/src/components/MCheckbox.vue +13 -2
- package/src/components/MChip.vue +7 -4
- package/src/components/MCircleProgressBar.vue +69 -21
- package/src/components/MCommentThread.vue +131 -0
- package/src/components/MContextMenu.vue +18 -31
- package/src/components/MDataTable.vue +16 -6
- package/src/components/MFab.vue +2 -2
- package/src/components/MIconButton.vue +2 -2
- package/src/components/MList.vue +163 -5
- package/src/components/MListDetail.vue +100 -14
- package/src/components/MListItem.vue +66 -6
- package/src/components/MMenu.vue +48 -41
- package/src/components/MMenuItem.vue +48 -14
- package/src/components/MProgressBar.vue +183 -50
- package/src/components/MRadio.vue +14 -2
- package/src/components/MReactions.vue +161 -0
- package/src/components/MScaffold.vue +213 -0
- package/src/components/MScrollField.vue +15 -12
- package/src/components/MScrollable.vue +187 -46
- package/src/components/MSegmentedButton.vue +3 -1
- package/src/components/MSupportingPane.vue +102 -12
- package/src/components/MSwitch.vue +92 -9
- package/src/components/MTable.vue +17 -4
- package/src/components/MTimeScroll.vue +1 -1
- package/src/components/MToggleButton.vue +2 -2
- package/src/components/MVirtualList.vue +222 -0
- package/src/components/_MComment.vue +142 -0
- package/src/components/_MCommentComposer.vue +68 -0
- package/src/components/_commentThread.ts +46 -0
- package/src/composables/_menuGroups.ts +31 -0
- package/src/composables/_usePaneResize.ts +271 -0
- package/src/composables/useLocale.ts +38 -0
- package/src/composables/useUndo.ts +170 -0
- package/src/directives/vRipple.ts +18 -5
- package/src/index.ts +12 -0
- package/src/locales/ar.ts +16 -0
- package/src/locales/de.ts +16 -0
- package/src/locales/es.ts +16 -0
- package/src/locales/fr.ts +16 -0
- package/src/locales/ja.ts +16 -0
- package/src/locales/ko.ts +16 -0
- package/src/locales/pt.ts +16 -0
- package/src/locales/zh.ts +16 -0
- package/src/plugin.ts +7 -0
- package/src/styles/theme.css +43 -6
- package/dist/MButton-LiZRRP4h.js.map +0 -1
- package/dist/MIconButton-CNjN0xwW.js.map +0 -1
- package/dist/MListItem-BBQ-6i3v.js +0 -991
- package/dist/MListItem-BBQ-6i3v.js.map +0 -1
- package/dist/MMenuItem-E31tMzOt.js +0 -577
- package/dist/MMenuItem-E31tMzOt.js.map +0 -1
- package/dist/MProgressBar-CPrZhQbA.js +0 -179
- package/dist/MProgressBar-CPrZhQbA.js.map +0 -1
- package/dist/MSegmentedButton-DZuZLBML.js +0 -105
- package/dist/MSegmentedButton-DZuZLBML.js.map +0 -1
- package/dist/useLocale-ybIju59R.js.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import MDataTable from '../components/MDataTable.vue'
|
|
4
|
+
import MTable from '../components/MTable.vue'
|
|
5
|
+
|
|
6
|
+
const columns = [{ key: 'name', label: 'Name' }]
|
|
7
|
+
const rows = [{ id: 1, name: 'Ana' }, { id: 2, name: 'Luis' }]
|
|
8
|
+
|
|
9
|
+
describe.each([
|
|
10
|
+
['MDataTable', MDataTable],
|
|
11
|
+
['MTable', MTable],
|
|
12
|
+
] as const)('%s checkboxes="hover"', (_, Table) => {
|
|
13
|
+
const cells = (w: ReturnType<typeof mount>) =>
|
|
14
|
+
w.findAll('tr').map((tr) => tr.find('th, td').classes().includes('opacity-0'))
|
|
15
|
+
|
|
16
|
+
it('hides the checkboxes until a row is hovered or focused, and shows them without hover', () => {
|
|
17
|
+
const w = mount(Table as never, { props: { columns, rows, selectable: true, checkboxes: 'hover', modelValue: [] } })
|
|
18
|
+
expect(cells(w)).toEqual([true, true, true])
|
|
19
|
+
const cls = w.find('tbody td').classes()
|
|
20
|
+
expect(cls).toContain('group-hover/row:opacity-100')
|
|
21
|
+
expect(cls).toContain('focus-within:opacity-100')
|
|
22
|
+
expect(cls).toContain('[@media(hover:none)]:opacity-100')
|
|
23
|
+
expect(w.find('tbody tr').classes()).toContain('group/row')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('shows them all once anything is selected', () => {
|
|
27
|
+
const w = mount(Table as never, { props: { columns, rows, selectable: true, checkboxes: 'hover', modelValue: [rows[0]] } })
|
|
28
|
+
expect(cells(w)).toEqual([false, false, false])
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('always shows them by default', () => {
|
|
32
|
+
const w = mount(Table as never, { props: { columns, rows, selectable: true, modelValue: [] } })
|
|
33
|
+
expect(cells(w)).toEqual([false, false, false])
|
|
34
|
+
})
|
|
35
|
+
})
|
|
@@ -90,3 +90,65 @@ describe('MButton ripple', () => {
|
|
|
90
90
|
expect(w.element.querySelector('.m3-ripple')).toBeNull()
|
|
91
91
|
})
|
|
92
92
|
})
|
|
93
|
+
|
|
94
|
+
describe('vRipple options (1.10)', () => {
|
|
95
|
+
it('skips a press on a control inside the host', () => {
|
|
96
|
+
const w = mount(defineComponent({
|
|
97
|
+
setup: () => () => withDirectives(h('div', { class: 'card' }, [h('button', { class: 'inner' }, 'x'), h('span', { class: 'text' }, 'y')]), [[vRipple, true]]),
|
|
98
|
+
}))
|
|
99
|
+
press(w.find('.inner').element)
|
|
100
|
+
expect(w.element.querySelector('.m3-ripple')).toBeNull()
|
|
101
|
+
press(w.find('.text').element)
|
|
102
|
+
expect(w.element.querySelector('.m3-ripple')).not.toBeNull()
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('draws in another layer, from its center', () => {
|
|
106
|
+
const layer = document.createElement('span')
|
|
107
|
+
const w = mount(defineComponent({
|
|
108
|
+
setup: () => () => withDirectives(h('label', { class: 'row' }), [[vRipple, { layer: () => layer, centered: true }]]),
|
|
109
|
+
}))
|
|
110
|
+
w.element.appendChild(layer)
|
|
111
|
+
layer.getBoundingClientRect = () => ({ left: 100, top: 100, width: 40, height: 40, right: 140, bottom: 140, x: 100, y: 100, toJSON() {} }) as DOMRect
|
|
112
|
+
press(w.element)
|
|
113
|
+
const ripple = layer.querySelector('.m3-ripple') as HTMLElement
|
|
114
|
+
// 80px wide (twice the layer), centered on the layer's own center whatever the pointer
|
|
115
|
+
expect([ripple.style.width, ripple.style.left, ripple.style.top]).toEqual(['80px', '-20px', '-20px'])
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
it('is off app-wide with data-m3-ripple="off" (createM3UI({ ripple: false }))', () => {
|
|
119
|
+
document.documentElement.dataset.m3Ripple = 'off'
|
|
120
|
+
const w = host(true)
|
|
121
|
+
press(w.element)
|
|
122
|
+
expect(w.element.querySelector('.m3-ripple')).toBeNull()
|
|
123
|
+
delete document.documentElement.dataset.m3Ripple
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
describe('components that ripple', () => {
|
|
128
|
+
it('chips, cards, list and menu items, segmented buttons and selection controls', async () => {
|
|
129
|
+
const { default: MChip } = await import('../components/MChip.vue')
|
|
130
|
+
const { default: MCard } = await import('../components/MCard.vue')
|
|
131
|
+
const { default: MListItem } = await import('../components/MListItem.vue')
|
|
132
|
+
const { default: MMenuItem } = await import('../components/MMenuItem.vue')
|
|
133
|
+
const { default: MSegmentedButton } = await import('../components/MSegmentedButton.vue')
|
|
134
|
+
const { default: MCheckbox } = await import('../components/MCheckbox.vue')
|
|
135
|
+
const { default: MRadio } = await import('../components/MRadio.vue')
|
|
136
|
+
const { default: MSwitch } = await import('../components/MSwitch.vue')
|
|
137
|
+
const cases = [
|
|
138
|
+
[mount(MChip, { props: { clickable: true }, slots: { default: 'Chip' } }), 'button'],
|
|
139
|
+
[mount(MChip, { props: { type: 'filter' }, slots: { default: 'Chip' } }), 'button'],
|
|
140
|
+
[mount(MCard, { props: { clickable: true }, slots: { default: 'Card' } }), '[role=button]'],
|
|
141
|
+
[mount(MListItem, { props: { title: 'Row', clickable: true } }), '[tabindex]'],
|
|
142
|
+
[mount(MMenuItem, { slots: { default: 'Edit' } }), 'button'],
|
|
143
|
+
[mount(MSegmentedButton, { props: { modelValue: 'a', options: [{ value: 'a', label: 'A' }] } }), 'button'],
|
|
144
|
+
[mount(MCheckbox, { props: { modelValue: false, label: 'A' } }), 'label'],
|
|
145
|
+
[mount(MRadio, { props: { modelValue: 'a', value: 'b', label: 'B' } }), 'label'],
|
|
146
|
+
[mount(MSwitch, { props: { modelValue: false, label: 'A' } }), 'label'],
|
|
147
|
+
] as const
|
|
148
|
+
for (const [w, sel] of cases) {
|
|
149
|
+
const target = w.element.matches?.(sel) ? w.element : w.element.querySelector(sel)!
|
|
150
|
+
press(target)
|
|
151
|
+
expect(w.element.querySelector('.m3-ripple'), sel).not.toBeNull()
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
})
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A stack of overlapping avatars for the people on something (a document's editors, a chat's members, who's
|
|
4
|
+
* here now), with an optional presence dot on each and a "+N" for the rest. Hovering or focusing the stack spreads
|
|
5
|
+
* it out; each avatar names its person in a tooltip. Not an M3 spec component: built from M3's avatar and badge
|
|
6
|
+
* pieces.
|
|
7
|
+
*
|
|
8
|
+
* @slot avatar Draws one avatar instead of the photo or initials: `{ item, size }`
|
|
9
|
+
* @event more The "+N" was pressed, with the people it stands for
|
|
10
|
+
*/
|
|
11
|
+
import { computed } from 'vue'
|
|
12
|
+
import { useLocale } from '../composables/useLocale'
|
|
13
|
+
import { vTooltip } from '../directives/vTooltip'
|
|
14
|
+
|
|
15
|
+
export interface AvatarGroupItem {
|
|
16
|
+
/** The person's name: the tooltip, the initials without a photo, and the alt text */
|
|
17
|
+
name: string
|
|
18
|
+
/** Photo URL; without it, initials */
|
|
19
|
+
src?: string
|
|
20
|
+
/** Presence dot: online (green), away, busy (red) or offline */
|
|
21
|
+
status?: 'online' | 'away' | 'busy' | 'offline'
|
|
22
|
+
/** Container color of the initials (defaults to one picked from the name) */
|
|
23
|
+
color?: 'primary' | 'secondary' | 'tertiary'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const props = withDefaults(defineProps<{
|
|
27
|
+
/** The people, front of the stack first */
|
|
28
|
+
items: AvatarGroupItem[]
|
|
29
|
+
/** Most avatars shown; the rest collapse into "+N" */
|
|
30
|
+
max?: number
|
|
31
|
+
/** Avatar diameter in px */
|
|
32
|
+
size?: number
|
|
33
|
+
/** Spread the stack out on hover and focus */
|
|
34
|
+
spread?: boolean
|
|
35
|
+
/** Color of the ring that separates overlapping avatars: the surface they sit on (defaults to surface) */
|
|
36
|
+
ringColor?: string
|
|
37
|
+
}>(), { max: 4, size: 40, spread: true })
|
|
38
|
+
|
|
39
|
+
const emit = defineEmits<{ more: [items: AvatarGroupItem[]] }>()
|
|
40
|
+
|
|
41
|
+
const t = useLocale()
|
|
42
|
+
const shown = computed(() => (props.items.length > props.max ? props.items.slice(0, Math.max(1, props.max - 1)) : props.items))
|
|
43
|
+
const rest = computed(() => props.items.slice(shown.value.length))
|
|
44
|
+
const COLORS = ['primary', 'secondary', 'tertiary'] as const
|
|
45
|
+
const colorClass: Record<string, string> = {
|
|
46
|
+
primary: 'bg-primary-container text-on-primary-container',
|
|
47
|
+
secondary: 'bg-secondary-container text-on-secondary-container',
|
|
48
|
+
tertiary: 'bg-tertiary-container text-on-tertiary-container',
|
|
49
|
+
}
|
|
50
|
+
function colorOf(item: AvatarGroupItem) {
|
|
51
|
+
if (item.color) return colorClass[item.color]
|
|
52
|
+
let h = 0
|
|
53
|
+
for (const c of item.name) h = (h * 31 + c.charCodeAt(0)) | 0
|
|
54
|
+
return colorClass[COLORS[Math.abs(h) % COLORS.length]!]
|
|
55
|
+
}
|
|
56
|
+
function initials(name: string) {
|
|
57
|
+
const parts = name.trim().split(/\s+/)
|
|
58
|
+
return ((parts[0]?.[0] ?? '') + (parts.length > 1 ? parts[parts.length - 1]![0] : '')).toUpperCase()
|
|
59
|
+
}
|
|
60
|
+
const statusClass: Record<string, string> = {
|
|
61
|
+
online: 'bg-success',
|
|
62
|
+
away: 'bg-tertiary',
|
|
63
|
+
busy: 'bg-error',
|
|
64
|
+
offline: 'bg-outline',
|
|
65
|
+
}
|
|
66
|
+
// Overlap by a quarter of the size at rest, a small gap when spread
|
|
67
|
+
const overlap = computed(() => Math.round(props.size * 0.25))
|
|
68
|
+
const dot = computed(() => Math.max(8, Math.round(props.size * 0.28)))
|
|
69
|
+
const moreLabel = computed(() => t.avatarGroupMore.replace('{count}', String(rest.value.length)))
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<div
|
|
74
|
+
class="m3-avatar-group"
|
|
75
|
+
:class="spread && 'm3-avatar-group-spread'"
|
|
76
|
+
role="group"
|
|
77
|
+
:style="{ '--m3-avatar-overlap': `${overlap}px`, '--m3-avatar-ring': ringColor ?? 'var(--color-surface)' }"
|
|
78
|
+
>
|
|
79
|
+
<span
|
|
80
|
+
v-for="(item, i) in shown"
|
|
81
|
+
:key="`${item.name}-${i}`"
|
|
82
|
+
v-tooltip="item.name"
|
|
83
|
+
class="m3-avatar-group-item relative inline-flex shrink-0 rounded-full"
|
|
84
|
+
:style="{ width: `${size}px`, height: `${size}px`, zIndex: shown.length - i + 1 }"
|
|
85
|
+
tabindex="0"
|
|
86
|
+
:aria-label="item.name"
|
|
87
|
+
>
|
|
88
|
+
<slot name="avatar" :item="item" :size="size">
|
|
89
|
+
<img v-if="item.src" :src="item.src" :alt="item.name" class="h-full w-full rounded-full object-cover">
|
|
90
|
+
<span
|
|
91
|
+
v-else
|
|
92
|
+
class="flex h-full w-full items-center justify-center rounded-full font-medium"
|
|
93
|
+
:class="colorOf(item)"
|
|
94
|
+
:style="{ fontSize: `${Math.round(size * 0.4)}px` }"
|
|
95
|
+
aria-hidden="true"
|
|
96
|
+
>{{ initials(item.name) }}</span>
|
|
97
|
+
</slot>
|
|
98
|
+
<span
|
|
99
|
+
v-if="item.status"
|
|
100
|
+
class="absolute bottom-0 end-0 rounded-full"
|
|
101
|
+
:class="statusClass[item.status]"
|
|
102
|
+
:style="{ width: `${dot}px`, height: `${dot}px`, boxShadow: '0 0 0 2px var(--m3-avatar-ring)' }"
|
|
103
|
+
aria-hidden="true"
|
|
104
|
+
/>
|
|
105
|
+
</span>
|
|
106
|
+
<button
|
|
107
|
+
v-if="rest.length"
|
|
108
|
+
v-tooltip="rest.map((r) => r.name).join(', ')"
|
|
109
|
+
type="button"
|
|
110
|
+
class="m3-avatar-group-item relative inline-flex shrink-0 items-center justify-center rounded-full bg-surface-container-highest font-medium text-on-surface-variant outline-none hover:bg-surface-container-high focus-visible:ring-2 focus-visible:ring-secondary"
|
|
111
|
+
:style="{ width: `${size}px`, height: `${size}px`, fontSize: `${Math.round(size * 0.35)}px`, zIndex: 1 }"
|
|
112
|
+
:aria-label="moreLabel"
|
|
113
|
+
@click="emit('more', rest)"
|
|
114
|
+
>+{{ rest.length }}</button>
|
|
115
|
+
</div>
|
|
116
|
+
</template>
|
|
117
|
+
|
|
118
|
+
<style>
|
|
119
|
+
@layer base {
|
|
120
|
+
.m3-avatar-group {
|
|
121
|
+
display: inline-flex;
|
|
122
|
+
align-items: center;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/* The ring cuts each avatar out of the one behind it */
|
|
126
|
+
.m3-avatar-group-item {
|
|
127
|
+
box-shadow: 0 0 0 2px var(--m3-avatar-ring);
|
|
128
|
+
transition: margin 300ms cubic-bezier(0.34, 1.4, 0.64, 1);
|
|
129
|
+
}
|
|
130
|
+
.m3-avatar-group-item:not(:first-child) {
|
|
131
|
+
margin-inline-start: calc(var(--m3-avatar-overlap) * -1);
|
|
132
|
+
}
|
|
133
|
+
.m3-avatar-group-item:focus-visible {
|
|
134
|
+
outline: 2px solid var(--color-secondary);
|
|
135
|
+
outline-offset: 2px;
|
|
136
|
+
}
|
|
137
|
+
@media (hover: hover) {
|
|
138
|
+
.m3-avatar-group-spread:hover .m3-avatar-group-item:not(:first-child) {
|
|
139
|
+
margin-inline-start: 4px;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
.m3-avatar-group-spread:focus-within .m3-avatar-group-item:not(:first-child) {
|
|
143
|
+
margin-inline-start: 4px;
|
|
144
|
+
}
|
|
145
|
+
@media (prefers-reduced-motion: reduce) {
|
|
146
|
+
.m3-avatar-group-item {
|
|
147
|
+
transition: none;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
</style>
|
|
@@ -102,7 +102,7 @@ const base =
|
|
|
102
102
|
'disabled:cursor-not-allowed disabled:shadow-none disabled:text-on-surface/38 ' +
|
|
103
103
|
"before:content-[''] before:pointer-events-none before:absolute before:inset-0 " +
|
|
104
104
|
'before:bg-current before:opacity-0 before:transition-opacity before:duration-150 ' +
|
|
105
|
-
'enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.
|
|
105
|
+
'enabled:hover:before:opacity-[0.08] enabled:focus-visible:before:opacity-[0.1] enabled:active:before:opacity-[0.1]'
|
|
106
106
|
|
|
107
107
|
// M3 disabled tokens: container at 10% on-surface opacity (DisabledContainerOpacity, same
|
|
108
108
|
// across Filled/Tonal/Elevated), content/label always at 38% on-surface (handled in `base`
|
|
@@ -88,7 +88,7 @@ function toggle(opt: ButtonGroupOption<T>) {
|
|
|
88
88
|
// sizes and reuse the medium radii.
|
|
89
89
|
const sizeMap = {
|
|
90
90
|
xs: { h: 'h-8', px: 'px-3', text: 'text-label-medium', icon: 16, check: 14, height: 32, pad: 12, checked: 12, pressed: 8 },
|
|
91
|
-
sm: { h: 'h-10', px: 'px-4', text: 'text-label-large', icon: 18, check: 16, height: 40, pad: 16, checked: 12, pressed:
|
|
91
|
+
sm: { h: 'h-10', px: 'px-4', text: 'text-label-large', icon: 18, check: 16, height: 40, pad: 16, checked: 12, pressed: 8 },
|
|
92
92
|
md: { h: 'h-14', px: 'px-6', text: 'text-title-medium', icon: 20, check: 18, height: 56, pad: 24, checked: 16, pressed: 12 },
|
|
93
93
|
lg: { h: 'h-16', px: 'px-7', text: 'text-title-large', icon: 22, check: 20, height: 64, pad: 28, checked: 16, pressed: 12 },
|
|
94
94
|
xl: { h: 'h-20', px: 'px-8', text: 'text-headline-small', icon: 24, check: 22, height: 80, pad: 32, checked: 16, pressed: 12 },
|
package/src/components/MCard.vue
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @slot default Main content area (raw, no wrapper)
|
|
9
9
|
* @slot actions Bottom action buttons (flex row, right-aligned)
|
|
10
10
|
*/
|
|
11
|
+
import { vRipple } from '../directives/vRipple'
|
|
11
12
|
import { computed } from 'vue'
|
|
12
13
|
|
|
13
14
|
const props = withDefaults(
|
|
@@ -103,14 +104,14 @@ const clickableClasses: Record<string, string> = {
|
|
|
103
104
|
outlined: 'hover:shadow-elevation-1 active:shadow-none focus-visible:outline-none focus-visible:border-on-surface',
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
// State layer (8% hover
|
|
107
|
+
// State layer (StateLayerTokens: 8% hover, 10% focus and press), same before:-pseudo pattern as MButton/MFab.
|
|
107
108
|
// Needed because the card has a real background to preserve underneath — unlike
|
|
108
109
|
// MListItem, a plain hover:bg-on-surface/8 here would replace the card's own tone.
|
|
109
110
|
const stateLayerClasses =
|
|
110
111
|
'relative ' +
|
|
111
112
|
"before:content-[''] before:pointer-events-none before:absolute before:inset-0 " +
|
|
112
113
|
'before:bg-on-surface before:opacity-0 before:transition-opacity before:duration-150 ' +
|
|
113
|
-
'hover:before:opacity-[0.08] active:before:opacity-[0.
|
|
114
|
+
'hover:before:opacity-[0.08] focus-visible:before:opacity-[0.1] active:before:opacity-[0.1]'
|
|
114
115
|
|
|
115
116
|
const isInteractive = computed(() => props.clickable && !props.disabled)
|
|
116
117
|
|
|
@@ -130,6 +131,7 @@ function onKeydown(event: KeyboardEvent) {
|
|
|
130
131
|
|
|
131
132
|
<template>
|
|
132
133
|
<div
|
|
134
|
+
v-ripple="isInteractive ? { disabled } : false"
|
|
133
135
|
class="overflow-hidden rounded-md transition-shadow duration-150"
|
|
134
136
|
:class="[
|
|
135
137
|
containerClasses,
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @event update:modelValue Emitted with the new checked state.
|
|
7
7
|
* @event blur Emitted when the checkbox loses focus
|
|
8
8
|
*/
|
|
9
|
+
import { vRipple } from '../directives/vRipple'
|
|
9
10
|
import { ref } from "vue";
|
|
10
11
|
import MIcon from "./MIcon.vue";
|
|
11
12
|
import { useFieldValidation } from "../composables/_useFieldValidation";
|
|
@@ -46,6 +47,8 @@ const props = withDefaults(
|
|
|
46
47
|
const emit = defineEmits<{ "update:modelValue": [boolean]; blur: [FocusEvent] }>();
|
|
47
48
|
|
|
48
49
|
const inputEl = ref<HTMLInputElement | null>(null);
|
|
50
|
+
// The press ripple's layer: the 40dp circle around the control (Compose: an unbounded ripple, radius 20dp)
|
|
51
|
+
const rippleEl = ref<HTMLElement | null>(null)
|
|
49
52
|
|
|
50
53
|
const validation = useFieldValidation({
|
|
51
54
|
value: () => props.modelValue,
|
|
@@ -97,6 +100,7 @@ defineExpose({
|
|
|
97
100
|
|
|
98
101
|
<template>
|
|
99
102
|
<label
|
|
103
|
+
v-ripple="{ disabled: isDisabled, layer: () => rippleEl, centered: true }"
|
|
100
104
|
class="group inline-flex gap-2 select-none"
|
|
101
105
|
:class="[isDisabled ? 'cursor-not-allowed' : 'cursor-pointer', errorMessage ? 'items-start' : 'items-center']"
|
|
102
106
|
>
|
|
@@ -135,7 +139,7 @@ defineExpose({
|
|
|
135
139
|
@blur="validation.onBlur(); emit('blur', $event)"
|
|
136
140
|
/>
|
|
137
141
|
<!--
|
|
138
|
-
Hover/press state layer (8%/
|
|
142
|
+
Hover/focus/press state layer (8%/10%/10%), tinted with the checkbox's own indicator color
|
|
139
143
|
(primary/color prop when checked, on-surface when not) — same `before:`-overlay
|
|
140
144
|
spirit as MButton/MCard/MIconButton, just a real sibling span here since the parent
|
|
141
145
|
span is already used for centering/sizing. `group-*` (not a plain `hover:`) so
|
|
@@ -144,9 +148,16 @@ defineExpose({
|
|
|
144
148
|
-->
|
|
145
149
|
<span
|
|
146
150
|
v-if="!isDisabled"
|
|
147
|
-
class="pointer-events-none absolute inset-0 rounded-full opacity-0 transition-opacity duration-150 group-hover:opacity-[0.08] group-active:opacity-[0.
|
|
151
|
+
class="pointer-events-none absolute inset-0 rounded-full opacity-0 transition-opacity duration-150 group-hover:opacity-[0.08] peer-focus-visible:opacity-[0.1] group-active:opacity-[0.1]"
|
|
148
152
|
:class="hasError ? 'bg-error' : modelValue || indeterminate ? checkedBgClasses[color] : 'bg-on-surface'"
|
|
149
153
|
/>
|
|
154
|
+
<span
|
|
155
|
+
v-if="!isDisabled"
|
|
156
|
+
ref="rippleEl"
|
|
157
|
+
aria-hidden="true"
|
|
158
|
+
class="pointer-events-none absolute inset-0 rounded-full"
|
|
159
|
+
:class="(hasError ? 'bg-error' : modelValue || indeterminate ? checkedBgClasses[color]! : 'bg-on-surface').replace('bg-', 'text-')"
|
|
160
|
+
/>
|
|
150
161
|
<!-- Keyboard-focus ring (FocusIndicatorColor = secondary) -->
|
|
151
162
|
<span
|
|
152
163
|
v-if="!isDisabled"
|
package/src/components/MChip.vue
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* @event update:selected Filter and input chips: emitted on click with the new selected state — powers
|
|
12
12
|
* v-model:selected
|
|
13
13
|
*/
|
|
14
|
+
import { vRipple } from '../directives/vRipple'
|
|
14
15
|
import { computed, ref, useSlots } from 'vue'
|
|
15
16
|
import MIcon from './MIcon.vue'
|
|
16
17
|
import { useLocale } from '../composables/useLocale'
|
|
@@ -107,7 +108,7 @@ const toneClasses = computed(() => {
|
|
|
107
108
|
// becomes a full pill once selected, it doesn't keep the same small corner radius.
|
|
108
109
|
const shapeClass = computed(() => props.selected ? 'rounded-full' : 'rounded-md')
|
|
109
110
|
|
|
110
|
-
// Hover/press state layer (8%/
|
|
111
|
+
// Hover/focus/press state layer (8%/10%/10%, ChipsTokens has no dedicated token but this matches the
|
|
111
112
|
// universal M3 state-layer convention used everywhere else in this library) via the same
|
|
112
113
|
// `before:`-overlay technique as MButton/MCard/MIconButton — a plain `hover:bg-*` would just
|
|
113
114
|
// replace a filled/selected chip's own background outright instead of overlaying on top of
|
|
@@ -185,7 +186,7 @@ function onTypedClick() {
|
|
|
185
186
|
const interactiveClasses =
|
|
186
187
|
"relative cursor-pointer before:content-[''] before:pointer-events-none before:absolute before:inset-0 " +
|
|
187
188
|
'before:bg-current before:opacity-0 before:transition-opacity before:duration-150 ' +
|
|
188
|
-
'hover:before:opacity-[0.08] active:before:opacity-[0.
|
|
189
|
+
'hover:before:opacity-[0.08] focus-visible:before:opacity-[0.1] active:before:opacity-[0.1] ' +
|
|
189
190
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-secondary'
|
|
190
191
|
</script>
|
|
191
192
|
|
|
@@ -199,9 +200,10 @@ const interactiveClasses =
|
|
|
199
200
|
<!-- Typed chip: the container is a span so an input chip's remove button can sit beside (not inside) the
|
|
200
201
|
main button; the main button's state layer (before:) covers the whole chip -->
|
|
201
202
|
<button
|
|
203
|
+
v-ripple="{ disabled }"
|
|
202
204
|
type="button"
|
|
203
205
|
class="flex h-full items-center gap-2 outline-none before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity"
|
|
204
|
-
:class="[typedPadding, disabled ? 'cursor-not-allowed' : 'cursor-pointer hover:before:opacity-[0.08] active:before:opacity-[0.
|
|
206
|
+
:class="[typedPadding, disabled ? 'cursor-not-allowed' : 'cursor-pointer hover:before:opacity-[0.08] focus-visible:before:opacity-[0.1] active:before:opacity-[0.1]']"
|
|
205
207
|
:disabled="disabled"
|
|
206
208
|
:aria-pressed="selectable ? selected : undefined"
|
|
207
209
|
@pointerdown="pressed = true"
|
|
@@ -237,6 +239,7 @@ const interactiveClasses =
|
|
|
237
239
|
<component
|
|
238
240
|
:is="clickable ? 'button' : 'span'"
|
|
239
241
|
v-else
|
|
242
|
+
v-ripple="clickable ? { disabled } : false"
|
|
240
243
|
:type="clickable ? 'button' : undefined"
|
|
241
244
|
:disabled="clickable && disabled ? true : undefined"
|
|
242
245
|
class="inline-flex h-8 items-center gap-1.5 overflow-hidden px-3 text-label-large transition-colors"
|
|
@@ -254,7 +257,7 @@ const interactiveClasses =
|
|
|
254
257
|
<button
|
|
255
258
|
v-if="removable"
|
|
256
259
|
type="button"
|
|
257
|
-
class="-me-1 ms-0.5 inline-flex items-center justify-center rounded-full hover:bg-on-surface/
|
|
260
|
+
class="-me-1 ms-0.5 inline-flex items-center justify-center rounded-full hover:bg-on-surface/8 active:bg-on-surface/10"
|
|
258
261
|
:aria-label="locale.remove"
|
|
259
262
|
:disabled="disabled"
|
|
260
263
|
@click.stop="emit('remove')"
|
|
@@ -131,6 +131,37 @@ watch(clampedValue, (v, prev) => {
|
|
|
131
131
|
|
|
132
132
|
// ── Template refs for direct DOM updates ─────────────────────────────────
|
|
133
133
|
const maskCircleEl = ref<SVGCircleElement | null>(null);
|
|
134
|
+
const indetArcEl = ref<SVGCircleElement | null>(null);
|
|
135
|
+
const rotateEl = ref<SVGGElement | null>(null);
|
|
136
|
+
|
|
137
|
+
// Indeterminate → determinate (CircularWavyProgressModifiers, Nov 2026): from where the spinning arc is, the ring
|
|
138
|
+
// rotates forward into alignment with the start of the track while the sweep eases into the progress, over
|
|
139
|
+
// 300–600ms depending on the rotation left (EmphasizedDecelerate).
|
|
140
|
+
const handoff = { t0: -1, dur: 0, rot: 0, sweep: 0 };
|
|
141
|
+
const emphasizedDecelerate = (() => {
|
|
142
|
+
const at = (a: number, b: number, t: number) => 3 * a * t * (1 - t) ** 2 + 3 * b * t * t * (1 - t) + t ** 3;
|
|
143
|
+
return (x: number) => {
|
|
144
|
+
let lo = 0, hi = 1;
|
|
145
|
+
for (let i = 0; i < 24; i++) { const m = (lo + hi) / 2; if (at(0.05, 0.1, m) < x) lo = m; else hi = m; }
|
|
146
|
+
return at(0.7, 1, (lo + hi) / 2);
|
|
147
|
+
};
|
|
148
|
+
})();
|
|
149
|
+
function captureHandoff() {
|
|
150
|
+
const el = indetArcEl.value;
|
|
151
|
+
if (!el || typeof getComputedStyle !== "function") return;
|
|
152
|
+
const cs = getComputedStyle(el);
|
|
153
|
+
const m = cs.transform && cs.transform !== "none" ? cs.transform.match(/matrix\(([^)]+)\)/) : null;
|
|
154
|
+
const [a, b] = m ? m[1]!.split(",").map(Number) : [1, 0];
|
|
155
|
+
const spin = (Math.atan2(b!, a!) * 180) / Math.PI;
|
|
156
|
+
const sweep = parseFloat(cs.strokeDasharray) || 0;
|
|
157
|
+
const offset = parseFloat(cs.strokeDashoffset) || 0;
|
|
158
|
+
// Where the arc starts, clockwise from 12 o'clock (the track's start)
|
|
159
|
+
const start = ((((spin + (-offset / CIRC) * 360 + 90) % 360) + 360) % 360) || 360;
|
|
160
|
+
handoff.rot = start;
|
|
161
|
+
handoff.sweep = Math.min(sweep, CIRC);
|
|
162
|
+
handoff.dur = 300 + 300 * ((360 - start) / 360);
|
|
163
|
+
handoff.t0 = performance.now();
|
|
164
|
+
}
|
|
134
165
|
const trackCircleEl = ref<SVGCircleElement | null>(null);
|
|
135
166
|
const wavePath = ref(buildPath(R * AMP_FRAC, 0));
|
|
136
167
|
|
|
@@ -147,11 +178,20 @@ function tick(now: number) {
|
|
|
147
178
|
// 1. Advance wave phase (crest travels right-to-left along the ring, matching Material)
|
|
148
179
|
animPhase += dt * PHASE_PER_MS;
|
|
149
180
|
|
|
150
|
-
// 2. Smooth arc (exponential: 90% in ≈300ms, equivalent feel to CSS ease-out)
|
|
151
|
-
|
|
181
|
+
// 2. Smooth arc (exponential: 90% in ≈300ms, equivalent feel to CSS ease-out); right after an
|
|
182
|
+
// indeterminate run, the handoff eases the sweep and the rotation instead
|
|
183
|
+
let rotation = 0;
|
|
184
|
+
if (handoff.t0 >= 0) {
|
|
185
|
+
const t = Math.min(1, (now - handoff.t0) / handoff.dur);
|
|
186
|
+
const f = t >= 1 ? 1 : emphasizedDecelerate(t);
|
|
187
|
+
displayedArcLen = handoff.sweep + (arcLen.value - handoff.sweep) * f;
|
|
188
|
+
rotation = handoff.rot + (360 - handoff.rot) * f;
|
|
189
|
+
if (t >= 1) { handoff.t0 = -1; rotation = 0; }
|
|
190
|
+
} else if (dt > 0) {
|
|
152
191
|
const k = 1 - Math.exp(-dt / ARC_TAU);
|
|
153
192
|
displayedArcLen += (arcLen.value - displayedArcLen) * k;
|
|
154
193
|
}
|
|
194
|
+
rotateEl.value?.setAttribute("transform", `rotate(${(rotation % 360).toFixed(2)}, 50, 50)`);
|
|
155
195
|
|
|
156
196
|
// 3. Advance appearance animation
|
|
157
197
|
appearanceF = tickAnim(appearAnim, now);
|
|
@@ -246,9 +286,15 @@ watch(() => props.variant, (v) => {
|
|
|
246
286
|
if (v === "wavy" && !props.indeterminate) { initWavy(); startRaf(); }
|
|
247
287
|
else stopRaf();
|
|
248
288
|
});
|
|
289
|
+
// Runs before the DOM update, while the spinning arc can still be read
|
|
249
290
|
watch(() => props.indeterminate, (v) => {
|
|
250
|
-
if (v) stopRaf();
|
|
251
|
-
else if (props.variant === "wavy") {
|
|
291
|
+
if (v) { stopRaf(); handoff.t0 = -1; }
|
|
292
|
+
else if (props.variant === "wavy") {
|
|
293
|
+
initWavy();
|
|
294
|
+
captureHandoff();
|
|
295
|
+
if (handoff.t0 >= 0) displayedArcLen = handoff.sweep;
|
|
296
|
+
startRaf();
|
|
297
|
+
}
|
|
252
298
|
});
|
|
253
299
|
|
|
254
300
|
const maskId = useId();
|
|
@@ -272,7 +318,7 @@ const maskId = useId();
|
|
|
272
318
|
<circle cx="50" cy="50" :r="R" fill="none" :stroke-width="strokeW"
|
|
273
319
|
:style="{ stroke: svgColor.track }"
|
|
274
320
|
/>
|
|
275
|
-
<circle cx="50" cy="50" :r="R" fill="none" :stroke-width="strokeW"
|
|
321
|
+
<circle ref="indetArcEl" cx="50" cy="50" :r="R" fill="none" :stroke-width="strokeW"
|
|
276
322
|
stroke-linecap="round"
|
|
277
323
|
:style="{ stroke: svgColor.fill, transformOrigin: '50px 50px', animation: 'm3-cpb-spin 1.4s linear infinite, m3-cpb-arc 3s ease-in-out infinite' }"
|
|
278
324
|
/>
|
|
@@ -293,22 +339,24 @@ const maskId = useId();
|
|
|
293
339
|
</mask>
|
|
294
340
|
</defs>
|
|
295
341
|
|
|
296
|
-
<
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
342
|
+
<g ref="rotateEl">
|
|
343
|
+
<circle
|
|
344
|
+
ref="trackCircleEl"
|
|
345
|
+
cx="50" cy="50" :r="R"
|
|
346
|
+
fill="none" :stroke-width="strokeW"
|
|
347
|
+
:style="{ stroke: svgColor.track }"
|
|
348
|
+
stroke-dasharray="251 0"
|
|
349
|
+
transform="rotate(-90, 50, 50)"
|
|
350
|
+
/>
|
|
351
|
+
|
|
352
|
+
<path
|
|
353
|
+
:d="wavePath"
|
|
354
|
+
fill="none" :stroke-width="strokeW"
|
|
355
|
+
stroke-linecap="round" stroke-linejoin="round"
|
|
356
|
+
:mask="`url(#${maskId})`"
|
|
357
|
+
:style="{ stroke: svgColor.fill }"
|
|
358
|
+
/>
|
|
359
|
+
</g>
|
|
312
360
|
</template>
|
|
313
361
|
|
|
314
362
|
<!-- ── Circle variant ────────────────────────────────────────── -->
|