@m3ui-vue/m3ui-vue 1.1.3 → 1.2.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 +1 -1
- package/dist/API.md +579 -40
- package/dist/MMenuItem-DI351kIf.js +929 -0
- package/dist/MMenuItem-DI351kIf.js.map +1 -0
- package/dist/MSlider-BnEy5ieZ.js +1500 -0
- package/dist/MSlider-BnEy5ieZ.js.map +1 -0
- package/dist/MTextField-BBmkaIbO.js +633 -0
- package/dist/MTextField-BBmkaIbO.js.map +1 -0
- package/dist/api.json +1 -1
- package/dist/chart.js +83 -49
- package/dist/chart.js.map +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MAnimatedNumber.vue.d.ts +3 -1
- package/dist/components/MButton.vue.d.ts +9 -1
- package/dist/components/MButtonGroup.vue.d.ts +40 -31
- package/dist/components/MCarousel.vue.d.ts +2 -0
- package/dist/components/MChart.vue.d.ts +6 -0
- package/dist/components/MCircleProgressBar.vue.d.ts +5 -3
- package/dist/components/MContainerTransform.vue.d.ts +59 -0
- package/dist/components/MContextMenu.vue.d.ts +2 -2
- package/dist/components/MCopyButton.vue.d.ts +1 -1
- package/dist/components/MDialog.vue.d.ts +8 -5
- package/dist/components/MExportButton.vue.d.ts +1 -1
- package/dist/components/MFab.vue.d.ts +2 -2
- package/dist/components/MFabMenu.vue.d.ts +1 -1
- package/dist/components/MFlex.vue.d.ts +1 -1
- package/dist/components/MIconButton.vue.d.ts +15 -1
- package/dist/components/MInfiniteScroll.vue.d.ts +1 -1
- package/dist/components/MListItem.vue.d.ts +5 -5
- package/dist/components/MMap.vue.d.ts +20 -2
- package/dist/components/MMapBaseLayers.vue.d.ts +3 -0
- package/dist/components/MMapFilter.vue.d.ts +3 -0
- package/dist/components/MMapLayers.vue.d.ts +3 -0
- package/dist/components/MMenu.vue.d.ts +2 -2
- package/dist/components/MMenuItem.vue.d.ts +7 -3
- package/dist/components/MNavigationDrawer.vue.d.ts +13 -2
- package/dist/components/MNavigationRail.vue.d.ts +1 -1
- package/dist/components/MOverlay.vue.d.ts +12 -1
- package/dist/components/MProgressBar.vue.d.ts +5 -3
- package/dist/components/MPullToRefresh.vue.d.ts +7 -2
- package/dist/components/MRichTextEditor.vue.d.ts +7 -1
- package/dist/components/MSearchField.vue.d.ts +58 -0
- package/dist/components/MSegmentedButton.vue.d.ts +31 -23
- package/dist/components/MSimpleCarousel.vue.d.ts +2 -0
- package/dist/components/MSkeleton.vue.d.ts +6 -3
- package/dist/components/MSplitter.vue.d.ts +1 -1
- package/dist/components/MStack.vue.d.ts +1 -1
- package/dist/components/MSwipeToDismiss.vue.d.ts +1 -1
- package/dist/components/MSwitch.vue.d.ts +1 -1
- package/dist/components/MTextField.vue.d.ts +5 -1
- package/dist/components/MTimeline.vue.d.ts +85 -22
- package/dist/components/MToolbar.vue.d.ts +32 -5
- package/dist/components/MTooltip.vue.d.ts +1 -1
- package/dist/components/_MDrawerItemList.vue.d.ts +2 -0
- package/dist/components/_MToolbarFab.vue.d.ts +16 -0
- package/dist/composables/_containerTransform.d.ts +48 -0
- package/dist/composables/_mapStyle.d.ts +13 -0
- package/dist/composables/_themeTransition.d.ts +2 -0
- package/dist/composables/_tooltipTrigger.d.ts +22 -0
- package/dist/composables/_useMenuNav.d.ts +28 -0
- package/dist/composables/useAutoGrow.d.ts +21 -0
- package/dist/composables/useColorPalette.d.ts +1 -1
- package/dist/composables/useContainerTransform.d.ts +30 -0
- package/dist/composables/useLocale.d.ts +6 -0
- package/dist/composables/useMap.d.ts +19 -3
- package/dist/composables/useMapFilter.d.ts +4 -1
- package/dist/composables/useMapLayers.d.ts +5 -2
- package/dist/composables/useScrollReveal.d.ts +44 -0
- package/dist/composables/useThemeTokens.d.ts +21 -0
- package/dist/composables/viewportHints.d.ts +27 -0
- package/dist/directives/vClickOutside.d.ts +25 -0
- package/dist/directives/vFocusRing.d.ts +22 -0
- package/dist/directives/vLongPress.d.ts +27 -0
- package/dist/directives/vReveal.d.ts +10 -0
- package/dist/directives/vScrollElevation.d.ts +31 -0
- package/dist/directives/vSkeleton.d.ts +19 -0
- package/dist/directives/vStateLayer.d.ts +20 -0
- package/dist/directives/vSwipe.d.ts +45 -0
- package/dist/directives/vTooltip.d.ts +23 -0
- package/dist/index.d.ts +31 -1
- package/dist/locales/index.js +35 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +7692 -6273
- package/dist/m3ui.js.map +1 -1
- package/dist/map.d.ts +1 -1
- package/dist/map.js +823 -793
- package/dist/map.js.map +1 -1
- package/dist/motion-DZiXG09o.js +150 -0
- package/dist/motion-DZiXG09o.js.map +1 -0
- package/dist/plugin.d.ts +24 -0
- package/dist/rich-text-editor.js +20 -16
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles/theme.css +63 -0
- package/dist/styles.css +1 -1
- package/dist/{useLocale-SfQHnJfp.js → useLocale-JYxDDeXC.js} +6 -2
- package/dist/useLocale-JYxDDeXC.js.map +1 -0
- package/dist/useThemeTokens-Bv-Uv8eX.js +135 -0
- package/dist/useThemeTokens-Bv-Uv8eX.js.map +1 -0
- package/package.json +2 -1
- package/src/__tests__/MAnimatedNumber.test.ts +24 -2
- package/src/__tests__/MButton.test.ts +22 -0
- package/src/__tests__/MCarousel.test.ts +9 -0
- package/src/__tests__/MChart.test.ts +77 -5
- package/src/__tests__/MContainerTransform.test.ts +279 -0
- package/src/__tests__/MDialog.test.ts +27 -0
- package/src/__tests__/MIconButton.test.ts +33 -0
- package/src/__tests__/MListItemExpandable.test.ts +48 -0
- package/src/__tests__/MListItemShape.test.ts +9 -6
- package/src/__tests__/MListKeyboard.test.ts +90 -0
- package/src/__tests__/MMap.test.ts +53 -1
- package/src/__tests__/MMapLayers.test.ts +46 -2
- package/src/__tests__/MMapTools.test.ts +2 -1
- package/src/__tests__/MMenu.test.ts +104 -1
- package/src/__tests__/MMenuItem.test.ts +18 -0
- package/src/__tests__/MNavigationDrawer.test.ts +80 -0
- package/src/__tests__/MNavigationRail.test.ts +33 -0
- package/src/__tests__/MOverlay.test.ts +49 -0
- package/src/__tests__/MProgressBar.test.ts +41 -0
- package/src/__tests__/MPullToRefresh.test.ts +33 -0
- package/src/__tests__/MRichTextEditor.test.ts +22 -0
- package/src/__tests__/MSearchField.test.ts +71 -0
- package/src/__tests__/MSkeleton.test.ts +38 -0
- package/src/__tests__/MSlider.test.ts +161 -0
- package/src/__tests__/MTimeline.test.ts +238 -0
- package/src/__tests__/MToolbar.test.ts +157 -0
- package/src/__tests__/_fakeMaplibre.ts +3 -1
- package/src/__tests__/attrsFallthrough.test.ts +9 -0
- package/src/__tests__/escapeStack.test.ts +93 -0
- package/src/__tests__/hydration.test.ts +25 -0
- package/src/__tests__/ssr.test.ts +21 -2
- package/src/__tests__/useAutoGrow.test.ts +103 -0
- package/src/__tests__/useScrollReveal.test.ts +102 -0
- package/src/__tests__/useThemeTokens.test.ts +114 -0
- package/src/__tests__/vClickOutside.test.ts +82 -0
- package/src/__tests__/vFocusRing.test.ts +36 -0
- package/src/__tests__/vLongPress.test.ts +81 -0
- package/src/__tests__/vScrollElevation.test.ts +89 -0
- package/src/__tests__/vSkeleton.test.ts +48 -0
- package/src/__tests__/vStateLayer.test.ts +53 -0
- package/src/__tests__/vSwipe.test.ts +93 -0
- package/src/__tests__/vTooltip.test.ts +95 -0
- package/src/__tests__/viewportHints.test.ts +41 -0
- package/src/components/MAnimatedNumber.vue +32 -6
- package/src/components/MAutocomplete.vue +5 -0
- package/src/components/MBottomSheet.vue +4 -1
- package/src/components/MButton.vue +19 -3
- package/src/components/MButtonGroup.vue +22 -17
- package/src/components/MCarousel.vue +7 -1
- package/src/components/MChart.vue +74 -34
- package/src/components/MCircleProgressBar.vue +14 -9
- package/src/components/MCommandPalette.vue +3 -2
- package/src/components/MContainerTransform.vue +321 -0
- package/src/components/MContextMenu.vue +19 -60
- package/src/components/MDialog.vue +31 -6
- package/src/components/MDragDropList.vue +2 -0
- package/src/components/MFab.vue +10 -5
- package/src/components/MIconButton.vue +43 -2
- package/src/components/MKanban.vue +2 -0
- package/src/components/MLightbox.vue +7 -2
- package/src/components/MList.vue +26 -2
- package/src/components/MListItem.vue +138 -84
- package/src/components/MMap.vue +38 -5
- package/src/components/MMapBaseLayers.vue +7 -3
- package/src/components/MMapFilter.vue +7 -4
- package/src/components/MMapGeoJson.vue +1 -1
- package/src/components/MMapLayers.vue +6 -2
- package/src/components/MMapMeasure.vue +5 -2
- package/src/components/MMenu.vue +18 -59
- package/src/components/MMenuItem.vue +11 -2
- package/src/components/MMultiAutocomplete.vue +5 -0
- package/src/components/MNavigationDrawer.vue +96 -11
- package/src/components/MNavigationRail.vue +44 -25
- package/src/components/MOverlay.vue +32 -13
- package/src/components/MProgressBar.vue +25 -27
- package/src/components/MPullToRefresh.vue +20 -1
- package/src/components/MRichTextEditor.vue +19 -5
- package/src/components/MSearchBar.vue +5 -0
- package/src/components/MSearchField.vue +142 -0
- package/src/components/MSegmentedButton.vue +19 -17
- package/src/components/MSelect.vue +10 -1
- package/src/components/MSideSheet.vue +5 -2
- package/src/components/MSimpleCarousel.vue +10 -1
- package/src/components/MSkeleton.vue +30 -8
- package/src/components/MSlider.vue +161 -42
- package/src/components/MSpotlightSearch.vue +3 -2
- package/src/components/MTextField.vue +15 -2
- package/src/components/MTimeline.vue +370 -81
- package/src/components/MToolbar.vue +256 -15
- package/src/components/MTooltip.vue +20 -152
- package/src/components/_MDrawerItemList.vue +25 -6
- package/src/components/_MToolbarFab.vue +14 -0
- package/src/composables/_containerTransform.ts +179 -0
- package/src/composables/_mapStyle.ts +45 -0
- package/src/composables/_themeTransition.ts +2 -0
- package/src/composables/_tooltipTrigger.ts +184 -0
- package/src/composables/_useEscapeStack.ts +2 -0
- package/src/composables/_useMenuNav.ts +209 -0
- package/src/composables/useAutoGrow.ts +78 -0
- package/src/composables/useContainerTransform.ts +59 -0
- package/src/composables/useLocale.ts +10 -0
- package/src/composables/useMap.ts +43 -5
- package/src/composables/useMapFilter.ts +6 -5
- package/src/composables/useMapLayers.ts +7 -6
- package/src/composables/useScrollReveal.ts +151 -0
- package/src/composables/useThemeTokens.ts +116 -0
- package/src/composables/viewportHints.ts +80 -0
- package/src/directives/vClickOutside.ts +90 -0
- package/src/directives/vFocusRing.ts +60 -0
- package/src/directives/vLongPress.ts +134 -0
- package/src/directives/vReveal.ts +57 -0
- package/src/directives/vScrollElevation.ts +116 -0
- package/src/directives/vSkeleton.ts +87 -0
- package/src/directives/vStateLayer.ts +83 -0
- package/src/directives/vSwipe.ts +197 -0
- package/src/directives/vTooltip.ts +128 -0
- package/src/index.ts +31 -1
- package/src/locales/de.ts +4 -0
- package/src/locales/es.ts +4 -0
- package/src/locales/fr.ts +4 -0
- package/src/locales/ja.ts +4 -0
- package/src/locales/ko.ts +4 -0
- package/src/locales/pt.ts +4 -0
- package/src/locales/zh.ts +4 -0
- package/src/map.ts +1 -1
- package/src/plugin.ts +34 -0
- package/src/styles/theme.css +63 -0
- package/dist/MMenuItem-BckcR0nW.js +0 -809
- package/dist/MMenuItem-BckcR0nW.js.map +0 -1
- package/dist/MSlider-LyH_gy8D.js +0 -1411
- package/dist/MSlider-LyH_gy8D.js.map +0 -1
- package/dist/MTextField-FCPOTB0o.js +0 -672
- package/dist/MTextField-FCPOTB0o.js.map +0 -1
- package/dist/composables/_useThemeTokens.d.ts +0 -7
- package/dist/useLocale-SfQHnJfp.js.map +0 -1
- package/src/composables/_useThemeTokens.ts +0 -42
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import type { Directive } from 'vue'
|
|
2
|
+
|
|
3
|
+
export type SwipeDirection = 'left' | 'right' | 'up' | 'down'
|
|
4
|
+
|
|
5
|
+
/** What a swipe handler gets. */
|
|
6
|
+
export interface SwipeInfo {
|
|
7
|
+
direction: SwipeDirection
|
|
8
|
+
/** Distance from where the press started, px (x grows rightwards, y downwards). */
|
|
9
|
+
dx: number
|
|
10
|
+
dy: number
|
|
11
|
+
/** Speed along the swipe's axis when the finger lifted, px/ms. */
|
|
12
|
+
velocity: number
|
|
13
|
+
/** The pointerup that ended it. */
|
|
14
|
+
event: PointerEvent
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Options for `v-swipe`. */
|
|
18
|
+
export interface SwipeOptions {
|
|
19
|
+
left?: (info: SwipeInfo) => void
|
|
20
|
+
right?: (info: SwipeInfo) => void
|
|
21
|
+
up?: (info: SwipeInfo) => void
|
|
22
|
+
down?: (info: SwipeInfo) => void
|
|
23
|
+
/** Called for a swipe in any direction that has no handler of its own. Listens on both axes. */
|
|
24
|
+
handler?: (info: SwipeInfo) => void
|
|
25
|
+
/** How far (px) the finger has to travel for a slow swipe to count (default 50). */
|
|
26
|
+
threshold?: number
|
|
27
|
+
/** A swipe at least this fast (px/ms) counts whatever its length (default 0.5, a flick). */
|
|
28
|
+
velocity?: number
|
|
29
|
+
/** Called while the finger moves along a listened axis, for feedback (follow the finger, fade a hint). */
|
|
30
|
+
onMove?: (dx: number, dy: number, event: PointerEvent) => void
|
|
31
|
+
/** Called when the press ends, swiped or not (spring a moved element back). */
|
|
32
|
+
onEnd?: (swiped: boolean) => void
|
|
33
|
+
/** Also with a mouse drag (default false: swipes are for touch and pen). */
|
|
34
|
+
mouse?: boolean
|
|
35
|
+
/** Off while true. */
|
|
36
|
+
disabled?: boolean
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** `v-swipe` value: a handler for any direction, or an options object. */
|
|
40
|
+
export type SwipeValue = ((info: SwipeInfo) => void) | SwipeOptions | null | undefined
|
|
41
|
+
|
|
42
|
+
function normalize(value: SwipeValue): SwipeOptions {
|
|
43
|
+
if (value == null) return {}
|
|
44
|
+
return typeof value === 'function' ? { handler: value } : value
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Before this much movement a press is still a tap
|
|
48
|
+
const SLOP = 10
|
|
49
|
+
|
|
50
|
+
interface SwipeState {
|
|
51
|
+
options: SwipeOptions
|
|
52
|
+
press: { id: number, x: number, y: number, axis: 'x' | 'y' | null, lastX: number, lastY: number, lastT: number, vx: number, vy: number } | null
|
|
53
|
+
moved: boolean
|
|
54
|
+
onPointerDown: (e: PointerEvent) => void
|
|
55
|
+
onMove: (e: PointerEvent) => void
|
|
56
|
+
onUp: (e: PointerEvent) => void
|
|
57
|
+
onCancel: (e: PointerEvent) => void
|
|
58
|
+
onClick: (e: MouseEvent) => void
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const states = new WeakMap<HTMLElement, SwipeState>()
|
|
62
|
+
|
|
63
|
+
function axes(o: SwipeOptions) {
|
|
64
|
+
const any = !!o.handler
|
|
65
|
+
return { x: any || !!o.left || !!o.right, y: any || !!o.up || !!o.down }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// The browser keeps panning along the axes nobody swipes on, and leaves the others to us (a drag the browser
|
|
69
|
+
// pans is cancelled for pointer events). Both axes: nothing pans from this element
|
|
70
|
+
function applyTouchAction(el: HTMLElement, o: SwipeOptions) {
|
|
71
|
+
const { x, y } = axes(o)
|
|
72
|
+
el.style.touchAction = o.disabled || (!x && !y) ? '' : x && y ? 'none' : x ? 'pan-y' : 'pan-x'
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function stopListening(state: SwipeState) {
|
|
76
|
+
window.removeEventListener('pointermove', state.onMove)
|
|
77
|
+
window.removeEventListener('pointerup', state.onUp)
|
|
78
|
+
window.removeEventListener('pointercancel', state.onCancel)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// The click comes right after the finger lifts, if at all (touch fires none after a move): stop waiting for it
|
|
82
|
+
// a moment later, or a later keyboard click would be swallowed
|
|
83
|
+
function expireClickGuard(state: SwipeState) {
|
|
84
|
+
setTimeout(() => { state.moved = false }, 400)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Calls handlers when an element is swiped: `v-swipe="onSwipe"` (any direction, `info.direction` says which) or
|
|
89
|
+
* `v-swipe="{ left, right, up, down, threshold, velocity, onMove, onEnd, mouse, disabled }"`. A swipe counts past
|
|
90
|
+
* `threshold` px, or at any length when flicked faster than `velocity`. The element's `touch-action` is set from
|
|
91
|
+
* the directions you listen to: only left/right leaves vertical scrolling to the page (`pan-y`), only up/down the
|
|
92
|
+
* horizontal (`pan-x`), both block panning from it (`none`). The click a swipe ends in is swallowed. Registered
|
|
93
|
+
* globally as `v-swipe` by `createM3UI()`; import `vSwipe` to use it without the plugin.
|
|
94
|
+
*/
|
|
95
|
+
export const vSwipe: Directive<HTMLElement, SwipeValue> = {
|
|
96
|
+
mounted(el, binding) {
|
|
97
|
+
const state: SwipeState = {
|
|
98
|
+
options: normalize(binding.value),
|
|
99
|
+
press: null,
|
|
100
|
+
moved: false,
|
|
101
|
+
onPointerDown(e) {
|
|
102
|
+
const o = state.options
|
|
103
|
+
if (o.disabled || state.press || e.button !== 0 || (!o.mouse && e.pointerType === 'mouse')) return
|
|
104
|
+
const { x, y } = axes(o)
|
|
105
|
+
if (!x && !y) return
|
|
106
|
+
state.moved = false
|
|
107
|
+
state.press = { id: e.pointerId, x: e.clientX, y: e.clientY, axis: null, lastX: e.clientX, lastY: e.clientY, lastT: e.timeStamp, vx: 0, vy: 0 }
|
|
108
|
+
window.addEventListener('pointermove', state.onMove)
|
|
109
|
+
window.addEventListener('pointerup', state.onUp)
|
|
110
|
+
window.addEventListener('pointercancel', state.onCancel)
|
|
111
|
+
},
|
|
112
|
+
onMove(e) {
|
|
113
|
+
const p = state.press
|
|
114
|
+
if (!p || e.pointerId !== p.id) return
|
|
115
|
+
const dx = e.clientX - p.x
|
|
116
|
+
const dy = e.clientY - p.y
|
|
117
|
+
if (!p.axis) {
|
|
118
|
+
if (Math.hypot(dx, dy) < SLOP) return
|
|
119
|
+
const { x, y } = axes(state.options)
|
|
120
|
+
const axis = Math.abs(dx) >= Math.abs(dy) ? 'x' : 'y'
|
|
121
|
+
// Along an axis nobody listens to: the page's (or the element's) own scroll
|
|
122
|
+
if ((axis === 'x' && !x) || (axis === 'y' && !y)) {
|
|
123
|
+
state.press = null
|
|
124
|
+
return stopListening(state)
|
|
125
|
+
}
|
|
126
|
+
p.axis = axis
|
|
127
|
+
state.moved = true
|
|
128
|
+
}
|
|
129
|
+
const dt = e.timeStamp - p.lastT
|
|
130
|
+
if (dt > 0) {
|
|
131
|
+
p.vx = 0.8 * ((e.clientX - p.lastX) / dt) + 0.2 * p.vx
|
|
132
|
+
p.vy = 0.8 * ((e.clientY - p.lastY) / dt) + 0.2 * p.vy
|
|
133
|
+
}
|
|
134
|
+
p.lastX = e.clientX
|
|
135
|
+
p.lastY = e.clientY
|
|
136
|
+
p.lastT = e.timeStamp
|
|
137
|
+
state.options.onMove?.(p.axis === 'x' ? dx : 0, p.axis === 'y' ? dy : 0, e)
|
|
138
|
+
},
|
|
139
|
+
onUp(e) {
|
|
140
|
+
const p = state.press
|
|
141
|
+
if (!p || e.pointerId !== p.id) return
|
|
142
|
+
state.press = null
|
|
143
|
+
stopListening(state)
|
|
144
|
+
if (!p.axis) return
|
|
145
|
+
expireClickGuard(state)
|
|
146
|
+
const o = state.options
|
|
147
|
+
const dx = e.clientX - p.x
|
|
148
|
+
const dy = e.clientY - p.y
|
|
149
|
+
// A pause before lifting ends the flick
|
|
150
|
+
const fresh = e.timeStamp - p.lastT < 100
|
|
151
|
+
const along = p.axis === 'x' ? dx : dy
|
|
152
|
+
const speed = fresh ? (p.axis === 'x' ? p.vx : p.vy) : 0
|
|
153
|
+
// Fast enough counts in the direction of the motion, as long as it ends on that side of the start
|
|
154
|
+
const swiped = Math.abs(along) >= (o.threshold ?? 50) || (Math.abs(speed) >= (o.velocity ?? 0.5) && Math.sign(speed) === Math.sign(along))
|
|
155
|
+
const direction: SwipeDirection = p.axis === 'x' ? (along > 0 ? 'right' : 'left') : (along > 0 ? 'down' : 'up')
|
|
156
|
+
const handler = swiped ? (o[direction] ?? o.handler) : undefined
|
|
157
|
+
if (handler) handler({ direction, dx, dy, velocity: Math.abs(speed), event: e })
|
|
158
|
+
o.onEnd?.(!!handler)
|
|
159
|
+
},
|
|
160
|
+
onCancel(e) {
|
|
161
|
+
const p = state.press
|
|
162
|
+
if (!p || e.pointerId !== p.id) return
|
|
163
|
+
state.press = null
|
|
164
|
+
stopListening(state)
|
|
165
|
+
if (!p.axis) return
|
|
166
|
+
expireClickGuard(state)
|
|
167
|
+
state.options.onEnd?.(false)
|
|
168
|
+
},
|
|
169
|
+
// A press that moved was a swipe (or an attempt), not a tap
|
|
170
|
+
onClick(e) {
|
|
171
|
+
if (!state.moved) return
|
|
172
|
+
state.moved = false
|
|
173
|
+
e.preventDefault()
|
|
174
|
+
e.stopPropagation()
|
|
175
|
+
},
|
|
176
|
+
}
|
|
177
|
+
states.set(el, state)
|
|
178
|
+
applyTouchAction(el, state.options)
|
|
179
|
+
el.addEventListener('pointerdown', state.onPointerDown)
|
|
180
|
+
el.addEventListener('click', state.onClick, true)
|
|
181
|
+
},
|
|
182
|
+
updated(el, binding) {
|
|
183
|
+
const state = states.get(el)
|
|
184
|
+
if (!state) return
|
|
185
|
+
state.options = normalize(binding.value)
|
|
186
|
+
applyTouchAction(el, state.options)
|
|
187
|
+
},
|
|
188
|
+
beforeUnmount(el) {
|
|
189
|
+
const state = states.get(el)
|
|
190
|
+
if (!state) return
|
|
191
|
+
stopListening(state)
|
|
192
|
+
el.removeEventListener('pointerdown', state.onPointerDown)
|
|
193
|
+
el.removeEventListener('click', state.onClick, true)
|
|
194
|
+
el.style.touchAction = ''
|
|
195
|
+
states.delete(el)
|
|
196
|
+
},
|
|
197
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { Directive } from 'vue'
|
|
2
|
+
import { createTooltipTrigger, placeTooltip, type TooltipPlacement } from '../composables/_tooltipTrigger'
|
|
3
|
+
|
|
4
|
+
/** Options for `v-tooltip`. */
|
|
5
|
+
export interface TooltipOptions {
|
|
6
|
+
/** The tooltip's text; nothing shows while it's empty. */
|
|
7
|
+
text?: string
|
|
8
|
+
/** Side of the element it shows on (default `'top'`); it stays inside the window. */
|
|
9
|
+
placement?: TooltipPlacement
|
|
10
|
+
/** Delay before it shows on hover or keyboard focus, in ms (default 600, like MTooltip). */
|
|
11
|
+
delay?: number
|
|
12
|
+
/** Never shows while true. */
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** `v-tooltip` value: the text, or an options object. */
|
|
17
|
+
export type TooltipValue = string | TooltipOptions | null | undefined
|
|
18
|
+
|
|
19
|
+
function normalize(value: TooltipValue): TooltipOptions {
|
|
20
|
+
if (value == null) return {}
|
|
21
|
+
return typeof value === 'string' ? { text: value } : value
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// MTooltip's plain tooltip
|
|
25
|
+
const TIP_CLASS = 'pointer-events-none fixed z-400 min-h-6 min-w-10 max-w-[200px] rounded bg-inverse-surface px-2 py-1 text-body-small text-inverse-on-surface'
|
|
26
|
+
|
|
27
|
+
let nextId = 0
|
|
28
|
+
|
|
29
|
+
interface TooltipState {
|
|
30
|
+
options: TooltipOptions
|
|
31
|
+
tip: HTMLDivElement | null
|
|
32
|
+
// Tooltips still fading out, removed at once if the element goes away first
|
|
33
|
+
leaving: Set<HTMLDivElement>
|
|
34
|
+
id: string
|
|
35
|
+
trigger: ReturnType<typeof createTooltipTrigger>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const states = new WeakMap<HTMLElement, TooltipState>()
|
|
39
|
+
|
|
40
|
+
function open(el: HTMLElement, state: TooltipState) {
|
|
41
|
+
const { text, disabled, placement = 'top' } = state.options
|
|
42
|
+
if (!text || disabled) return
|
|
43
|
+
let tip = state.tip
|
|
44
|
+
if (!tip) {
|
|
45
|
+
tip = document.createElement('div')
|
|
46
|
+
tip.className = TIP_CLASS
|
|
47
|
+
tip.id = state.id
|
|
48
|
+
tip.setAttribute('role', 'tooltip')
|
|
49
|
+
document.body.appendChild(tip)
|
|
50
|
+
state.tip = tip
|
|
51
|
+
tip.animate?.([{ opacity: 0 }, { opacity: 1 }], { duration: 150 })
|
|
52
|
+
}
|
|
53
|
+
tip.textContent = text
|
|
54
|
+
const { top, left } = placeTooltip(el, tip, placement)
|
|
55
|
+
tip.style.top = `${top}px`
|
|
56
|
+
tip.style.left = `${left}px`
|
|
57
|
+
addDescribedBy(el, state.id)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function close(el: HTMLElement, state: TooltipState) {
|
|
61
|
+
const tip = state.tip
|
|
62
|
+
if (!tip) return
|
|
63
|
+
state.tip = null
|
|
64
|
+
removeDescribedBy(el, state.id)
|
|
65
|
+
const anim = tip.animate?.([{ opacity: 1 }, { opacity: 0 }], { duration: 100, fill: 'forwards' })
|
|
66
|
+
if (!anim) return tip.remove()
|
|
67
|
+
state.leaving.add(tip)
|
|
68
|
+
anim.onfinish = () => {
|
|
69
|
+
state.leaving.delete(tip)
|
|
70
|
+
tip.remove()
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// While it shows, the element is described by it (aria-describedby), keeping any ids already there
|
|
75
|
+
function addDescribedBy(el: HTMLElement, id: string) {
|
|
76
|
+
const ids = (el.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(Boolean)
|
|
77
|
+
if (!ids.includes(id)) el.setAttribute('aria-describedby', [...ids, id].join(' '))
|
|
78
|
+
}
|
|
79
|
+
function removeDescribedBy(el: HTMLElement, id: string) {
|
|
80
|
+
const ids = (el.getAttribute('aria-describedby') ?? '').split(/\s+/).filter((x) => x && x !== id)
|
|
81
|
+
if (ids.length) el.setAttribute('aria-describedby', ids.join(' '))
|
|
82
|
+
else el.removeAttribute('aria-describedby')
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* MTooltip's plain tooltip on any element, without wrapping it: `v-tooltip="'Save'"` or
|
|
87
|
+
* `v-tooltip="{ text, placement, delay, disabled }"`. Shows after a delay on mouse hover, on keyboard focus, and
|
|
88
|
+
* on a long press on touch (swallowing that press's click, hiding 1.5s after the finger lifts); Escape and
|
|
89
|
+
* scrolling hide it. Registered globally as `v-tooltip` by `createM3UI()`; import `vTooltip` to use it without
|
|
90
|
+
* the plugin.
|
|
91
|
+
*/
|
|
92
|
+
export const vTooltip: Directive<HTMLElement, TooltipValue> = {
|
|
93
|
+
mounted(el, binding) {
|
|
94
|
+
const state = {
|
|
95
|
+
options: normalize(binding.value),
|
|
96
|
+
tip: null,
|
|
97
|
+
leaving: new Set(),
|
|
98
|
+
id: `m3-tooltip-${++nextId}`,
|
|
99
|
+
} as unknown as TooltipState
|
|
100
|
+
state.trigger = createTooltipTrigger(el, {
|
|
101
|
+
delay: () => state.options.delay ?? 600,
|
|
102
|
+
visible: () => !!state.tip,
|
|
103
|
+
open: () => open(el, state),
|
|
104
|
+
close: () => close(el, state),
|
|
105
|
+
tip: () => state.tip,
|
|
106
|
+
})
|
|
107
|
+
states.set(el, state)
|
|
108
|
+
},
|
|
109
|
+
updated(el, binding) {
|
|
110
|
+
const state = states.get(el)
|
|
111
|
+
if (!state) return
|
|
112
|
+
state.options = normalize(binding.value)
|
|
113
|
+
// Showing: follow the new text, or hide when it went empty or disabled
|
|
114
|
+
if (state.tip) {
|
|
115
|
+
if (!state.options.text || state.options.disabled) state.trigger.closeNow()
|
|
116
|
+
else open(el, state)
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
beforeUnmount(el) {
|
|
120
|
+
const state = states.get(el)
|
|
121
|
+
if (!state) return
|
|
122
|
+
state.trigger.destroy()
|
|
123
|
+
state.tip?.remove()
|
|
124
|
+
state.leaving.forEach((tip) => tip.remove())
|
|
125
|
+
removeDescribedBy(el, state.id)
|
|
126
|
+
states.delete(el)
|
|
127
|
+
},
|
|
128
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -9,10 +9,14 @@ export type { Theme } from './composables/useTheme'
|
|
|
9
9
|
export { useColorPalette, palettes } from './composables/useColorPalette'
|
|
10
10
|
export { useConfetti, fireConfetti } from './composables/useConfetti'
|
|
11
11
|
export type { ConfettiOptions, ConfettiOrigin } from './composables/useConfetti'
|
|
12
|
+
export { useContainerTransform } from './composables/useContainerTransform'
|
|
13
|
+
export type { ContainerTransformController, ContainerTransformOrigin } from './composables/useContainerTransform'
|
|
12
14
|
export type { Palette, PaletteId, ActiveSeed, ContrastLevel } from './composables/useColorPalette'
|
|
13
15
|
export { SEED_PALETTE } from './composables/useColorPalette'
|
|
14
16
|
export { themeInitScript } from './composables/themeInitScript'
|
|
15
17
|
export type { ThemeInitOptions } from './composables/themeInitScript'
|
|
18
|
+
export { viewportFromHeaders, VIEWPORT_HINTS } from './composables/viewportHints'
|
|
19
|
+
export type { RequestHeaders, ViewportSize } from './composables/viewportHints'
|
|
16
20
|
export { generateScheme, schemeToCss, schemeRoles, seedFromImage, seedFromPixels } from './composables/dynamicColor'
|
|
17
21
|
export type { SchemeVariant, SeedOptions, GeneratedScheme } from './composables/dynamicColor'
|
|
18
22
|
export { useToast } from './composables/useToast'
|
|
@@ -21,6 +25,12 @@ export { useFieldBg } from './composables/useFieldBg'
|
|
|
21
25
|
export { useLocale, defaultLocale } from './composables/useLocale'
|
|
22
26
|
export type { M3Locale } from './composables/useLocale'
|
|
23
27
|
export { useDevice } from './composables/useDevice'
|
|
28
|
+
export { useAutoGrow } from './composables/useAutoGrow'
|
|
29
|
+
export type { AutoGrowOptions } from './composables/useAutoGrow'
|
|
30
|
+
export { useThemeTokens } from './composables/useThemeTokens'
|
|
31
|
+
export type { ThemeTokensOptions } from './composables/useThemeTokens'
|
|
32
|
+
export { useScrollReveal } from './composables/useScrollReveal'
|
|
33
|
+
export type { ScrollRevealOptions, RevealEffect } from './composables/useScrollReveal'
|
|
24
34
|
export { useWindowSizeClass, widthSizeClass, heightSizeClass } from './composables/useWindowSizeClass'
|
|
25
35
|
export type { WidthSizeClass, HeightSizeClass, WindowSizeClassInfo } from './composables/useWindowSizeClass'
|
|
26
36
|
export { useNotification } from './composables/useNotification'
|
|
@@ -34,6 +44,24 @@ export type { SpringSpec } from './composables/motion'
|
|
|
34
44
|
// Directives
|
|
35
45
|
export { vRipple } from './directives/vRipple'
|
|
36
46
|
export type { RippleOptions, RippleValue } from './directives/vRipple'
|
|
47
|
+
export { vReveal } from './directives/vReveal'
|
|
48
|
+
export type { RevealValue } from './directives/vReveal'
|
|
49
|
+
export { vStateLayer } from './directives/vStateLayer'
|
|
50
|
+
export type { StateLayerOptions, StateLayerValue } from './directives/vStateLayer'
|
|
51
|
+
export { vTooltip } from './directives/vTooltip'
|
|
52
|
+
export type { TooltipOptions, TooltipValue } from './directives/vTooltip'
|
|
53
|
+
export { vFocusRing } from './directives/vFocusRing'
|
|
54
|
+
export type { FocusRingOptions, FocusRingValue } from './directives/vFocusRing'
|
|
55
|
+
export { vScrollElevation } from './directives/vScrollElevation'
|
|
56
|
+
export type { ScrollElevationOptions, ScrollElevationValue } from './directives/vScrollElevation'
|
|
57
|
+
export { vLongPress } from './directives/vLongPress'
|
|
58
|
+
export type { LongPressOptions, LongPressValue } from './directives/vLongPress'
|
|
59
|
+
export { vSwipe } from './directives/vSwipe'
|
|
60
|
+
export type { SwipeDirection, SwipeInfo, SwipeOptions, SwipeValue } from './directives/vSwipe'
|
|
61
|
+
export { vClickOutside } from './directives/vClickOutside'
|
|
62
|
+
export type { ClickOutsideOptions, ClickOutsideValue } from './directives/vClickOutside'
|
|
63
|
+
export { vSkeleton } from './directives/vSkeleton'
|
|
64
|
+
export type { SkeletonOptions, SkeletonValue } from './directives/vSkeleton'
|
|
37
65
|
|
|
38
66
|
// Components
|
|
39
67
|
export { default as MAbsolute } from './components/MAbsolute.vue'
|
|
@@ -70,6 +98,7 @@ export { default as MColorPicker } from './components/MColorPicker.vue'
|
|
|
70
98
|
export { default as MColorPickerModal } from './components/MColorPickerModal.vue'
|
|
71
99
|
export { default as MCommandPalette } from './components/MCommandPalette.vue'
|
|
72
100
|
export { default as MConfirmDialog } from './components/MConfirmDialog.vue'
|
|
101
|
+
export { default as MContainerTransform } from './components/MContainerTransform.vue'
|
|
73
102
|
export { default as MContainer } from './components/MContainer.vue'
|
|
74
103
|
export { default as MContextMenu } from './components/MContextMenu.vue'
|
|
75
104
|
export { default as MCopyButton } from './components/MCopyButton.vue'
|
|
@@ -151,6 +180,7 @@ export { default as MScheduler } from './components/MScheduler.vue'
|
|
|
151
180
|
export { default as MScheme } from './components/MScheme.vue'
|
|
152
181
|
export { default as MScrollable } from './components/MScrollable.vue'
|
|
153
182
|
export { default as MSearchBar } from './components/MSearchBar.vue'
|
|
183
|
+
export { default as MSearchField } from './components/MSearchField.vue'
|
|
154
184
|
export { default as MSection } from './components/MSection.vue'
|
|
155
185
|
export { default as MSeekBar } from './components/MSeekBar.vue'
|
|
156
186
|
export { default as MSegmentedButton } from './components/MSegmentedButton.vue'
|
|
@@ -232,7 +262,7 @@ export type { SpotlightResult } from './components/MSpotlightSearch.vue'
|
|
|
232
262
|
export type { StepItem } from './components/MStepper.vue'
|
|
233
263
|
export type { CommandItem } from './components/MCommandPalette.vue'
|
|
234
264
|
export type { TableFetchParams } from './components/MTable.vue'
|
|
235
|
-
export type { TimelineItem } from './components/MTimeline.vue'
|
|
265
|
+
export type { TimelineItem, TimelineStatus } from './components/MTimeline.vue'
|
|
236
266
|
export type { TourStep } from './components/MTour.vue'
|
|
237
267
|
export type { TransferItem } from './components/MTransferList.vue'
|
|
238
268
|
export type { TreeNode } from './components/MTree.vue'
|
package/src/locales/de.ts
CHANGED
|
@@ -194,6 +194,8 @@ export const deLocale: M3Locale = {
|
|
|
194
194
|
carousel: 'Karussell',
|
|
195
195
|
carouselItem: '{index} von {count}', // MMap (maplibre controls)
|
|
196
196
|
sparklineSummary: 'Von {first} bis {last}, Minimum {min}, Maximum {max}',
|
|
197
|
+
sliderRangeStart: 'Bereichsanfang',
|
|
198
|
+
sliderRangeEnd: 'Bereichsende',
|
|
197
199
|
mapTitle: 'Karte',
|
|
198
200
|
mapMarker: 'Kartenmarkierung',
|
|
199
201
|
mapZoomIn: 'Vergrößern',
|
|
@@ -224,4 +226,6 @@ export const deLocale: M3Locale = {
|
|
|
224
226
|
mapDeleteMeasurement: 'Messung löschen',
|
|
225
227
|
mapTotal: 'Gesamt',
|
|
226
228
|
mapSearchPlaces: 'Orte suchen',
|
|
229
|
+
timelineShowMore: '{count} weitere anzeigen',
|
|
230
|
+
timelineShowLess: 'Weniger anzeigen',
|
|
227
231
|
}
|
package/src/locales/es.ts
CHANGED
|
@@ -194,6 +194,8 @@ export const esLocale: M3Locale = {
|
|
|
194
194
|
carousel: 'Carrusel',
|
|
195
195
|
carouselItem: '{index} de {count}', // MMap (maplibre controls)
|
|
196
196
|
sparklineSummary: 'De {first} a {last}, mínimo {min}, máximo {max}',
|
|
197
|
+
sliderRangeStart: 'Inicio del rango',
|
|
198
|
+
sliderRangeEnd: 'Fin del rango',
|
|
197
199
|
mapTitle: 'Mapa',
|
|
198
200
|
mapMarker: 'Marcador del mapa',
|
|
199
201
|
mapZoomIn: 'Acercar',
|
|
@@ -224,4 +226,6 @@ export const esLocale: M3Locale = {
|
|
|
224
226
|
mapDeleteMeasurement: 'Borrar medición',
|
|
225
227
|
mapTotal: 'Total',
|
|
226
228
|
mapSearchPlaces: 'Buscar lugares',
|
|
229
|
+
timelineShowMore: 'Mostrar {count} más',
|
|
230
|
+
timelineShowLess: 'Mostrar menos',
|
|
227
231
|
}
|
package/src/locales/fr.ts
CHANGED
|
@@ -194,6 +194,8 @@ export const frLocale: M3Locale = {
|
|
|
194
194
|
carousel: 'Carrousel',
|
|
195
195
|
carouselItem: '{index} sur {count}', // MMap (maplibre controls)
|
|
196
196
|
sparklineSummary: 'De {first} à {last}, minimum {min}, maximum {max}',
|
|
197
|
+
sliderRangeStart: 'Début de la plage',
|
|
198
|
+
sliderRangeEnd: 'Fin de la plage',
|
|
197
199
|
mapTitle: 'Carte',
|
|
198
200
|
mapMarker: 'Marqueur de carte',
|
|
199
201
|
mapZoomIn: 'Zoom avant',
|
|
@@ -224,4 +226,6 @@ export const frLocale: M3Locale = {
|
|
|
224
226
|
mapDeleteMeasurement: 'Supprimer la mesure',
|
|
225
227
|
mapTotal: 'Total',
|
|
226
228
|
mapSearchPlaces: 'Rechercher un lieu',
|
|
229
|
+
timelineShowMore: 'Afficher {count} de plus',
|
|
230
|
+
timelineShowLess: 'Afficher moins',
|
|
227
231
|
}
|
package/src/locales/ja.ts
CHANGED
|
@@ -194,6 +194,8 @@ export const jaLocale: M3Locale = {
|
|
|
194
194
|
carousel: 'カルーセル',
|
|
195
195
|
carouselItem: '{count} 件中 {index} 件目', // MMap (maplibre controls)
|
|
196
196
|
sparklineSummary: '{first} から {last}、最小 {min}、最大 {max}',
|
|
197
|
+
sliderRangeStart: '範囲の開始',
|
|
198
|
+
sliderRangeEnd: '範囲の終了',
|
|
197
199
|
mapTitle: '地図',
|
|
198
200
|
mapMarker: '地図のマーカー',
|
|
199
201
|
mapZoomIn: 'ズームイン',
|
|
@@ -224,4 +226,6 @@ export const jaLocale: M3Locale = {
|
|
|
224
226
|
mapDeleteMeasurement: '測定を削除',
|
|
225
227
|
mapTotal: '合計',
|
|
226
228
|
mapSearchPlaces: '場所を検索',
|
|
229
|
+
timelineShowMore: 'さらに {count} 件を表示',
|
|
230
|
+
timelineShowLess: '表示を減らす',
|
|
227
231
|
}
|
package/src/locales/ko.ts
CHANGED
|
@@ -194,6 +194,8 @@ export const koLocale: M3Locale = {
|
|
|
194
194
|
carousel: '캐러셀',
|
|
195
195
|
carouselItem: '{count}개 중 {index}번째', // MMap (maplibre controls)
|
|
196
196
|
sparklineSummary: '{first}에서 {last}, 최소 {min}, 최대 {max}',
|
|
197
|
+
sliderRangeStart: '범위 시작',
|
|
198
|
+
sliderRangeEnd: '범위 끝',
|
|
197
199
|
mapTitle: '지도',
|
|
198
200
|
mapMarker: '지도 마커',
|
|
199
201
|
mapZoomIn: '확대',
|
|
@@ -224,4 +226,6 @@ export const koLocale: M3Locale = {
|
|
|
224
226
|
mapDeleteMeasurement: '측정 삭제',
|
|
225
227
|
mapTotal: '합계',
|
|
226
228
|
mapSearchPlaces: '장소 검색',
|
|
229
|
+
timelineShowMore: '{count}개 더 보기',
|
|
230
|
+
timelineShowLess: '간략히 보기',
|
|
227
231
|
}
|
package/src/locales/pt.ts
CHANGED
|
@@ -194,6 +194,8 @@ export const ptLocale: M3Locale = {
|
|
|
194
194
|
carousel: 'Carrossel',
|
|
195
195
|
carouselItem: '{index} de {count}', // MMap (maplibre controls)
|
|
196
196
|
sparklineSummary: 'De {first} a {last}, mínimo {min}, máximo {max}',
|
|
197
|
+
sliderRangeStart: 'Início do intervalo',
|
|
198
|
+
sliderRangeEnd: 'Fim do intervalo',
|
|
197
199
|
mapTitle: 'Mapa',
|
|
198
200
|
mapMarker: 'Marcador do mapa',
|
|
199
201
|
mapZoomIn: 'Aproximar',
|
|
@@ -224,4 +226,6 @@ export const ptLocale: M3Locale = {
|
|
|
224
226
|
mapDeleteMeasurement: 'Apagar medição',
|
|
225
227
|
mapTotal: 'Total',
|
|
226
228
|
mapSearchPlaces: 'Pesquisar lugares',
|
|
229
|
+
timelineShowMore: 'Mostrar mais {count}',
|
|
230
|
+
timelineShowLess: 'Mostrar menos',
|
|
227
231
|
}
|
package/src/locales/zh.ts
CHANGED
|
@@ -194,6 +194,8 @@ export const zhLocale: M3Locale = {
|
|
|
194
194
|
carousel: '轮播',
|
|
195
195
|
carouselItem: '第 {index} 项,共 {count} 项', // MMap (maplibre controls)
|
|
196
196
|
sparklineSummary: '从 {first} 到 {last},最低 {min},最高 {max}',
|
|
197
|
+
sliderRangeStart: '范围起点',
|
|
198
|
+
sliderRangeEnd: '范围终点',
|
|
197
199
|
mapTitle: '地图',
|
|
198
200
|
mapMarker: '地图标记',
|
|
199
201
|
mapZoomIn: '放大',
|
|
@@ -224,4 +226,6 @@ export const zhLocale: M3Locale = {
|
|
|
224
226
|
mapDeleteMeasurement: '删除测量',
|
|
225
227
|
mapTotal: '总计',
|
|
226
228
|
mapSearchPlaces: '搜索地点',
|
|
229
|
+
timelineShowMore: '再显示 {count} 项',
|
|
230
|
+
timelineShowLess: '收起',
|
|
227
231
|
}
|
package/src/map.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { default as MMapGeoJson } from './components/MMapGeoJson.vue'
|
|
|
6
6
|
export type { MapGeoJsonLayer } from './components/MMapGeoJson.vue'
|
|
7
7
|
export { default as MMapControl } from './components/MMapControl.vue'
|
|
8
8
|
export { useMap } from './composables/useMap'
|
|
9
|
-
export type { MapContext, MaplibreModule } from './composables/useMap'
|
|
9
|
+
export type { MapContext, MapSource, MaplibreModule } from './composables/useMap'
|
|
10
10
|
export { default as MMapLayers } from './components/MMapLayers.vue'
|
|
11
11
|
export { default as MMapBaseLayers } from './components/MMapBaseLayers.vue'
|
|
12
12
|
export { default as MMapIdentify } from './components/MMapIdentify.vue'
|
package/src/plugin.ts
CHANGED
|
@@ -7,6 +7,15 @@ import { syncThemeColor } from './composables/_themeColor'
|
|
|
7
7
|
import type { M3Locale } from './composables/useLocale'
|
|
8
8
|
import { M3_LOCALE_KEY, __setAppLocale } from './composables/useLocale'
|
|
9
9
|
import { vRipple } from './directives/vRipple'
|
|
10
|
+
import { vReveal } from './directives/vReveal'
|
|
11
|
+
import { vStateLayer } from './directives/vStateLayer'
|
|
12
|
+
import { vTooltip } from './directives/vTooltip'
|
|
13
|
+
import { vFocusRing } from './directives/vFocusRing'
|
|
14
|
+
import { vScrollElevation } from './directives/vScrollElevation'
|
|
15
|
+
import { vLongPress } from './directives/vLongPress'
|
|
16
|
+
import { vSwipe } from './directives/vSwipe'
|
|
17
|
+
import { vClickOutside } from './directives/vClickOutside'
|
|
18
|
+
import { vSkeleton } from './directives/vSkeleton'
|
|
10
19
|
import { M3_HYDRATING_KEY } from './composables/_hydration'
|
|
11
20
|
import { M3_INITIAL_STATE_KEY, enableCookies, readCookie, trackViewport, writeCookie, type M3InitialState, type ResolvedInitialState } from './composables/_ssrState'
|
|
12
21
|
import { THEME_KEY } from './composables/_storageKeys'
|
|
@@ -103,6 +112,15 @@ export function createM3UI(options: M3UIOptions = {}) {
|
|
|
103
112
|
return {
|
|
104
113
|
install(app: App) {
|
|
105
114
|
app.directive('ripple', vRipple)
|
|
115
|
+
app.directive('reveal', vReveal)
|
|
116
|
+
app.directive('state-layer', vStateLayer)
|
|
117
|
+
app.directive('tooltip', vTooltip)
|
|
118
|
+
app.directive('focus-ring', vFocusRing)
|
|
119
|
+
app.directive('scroll-elevation', vScrollElevation)
|
|
120
|
+
app.directive('long-press', vLongPress)
|
|
121
|
+
app.directive('swipe', vSwipe)
|
|
122
|
+
app.directive('click-outside', vClickOutside)
|
|
123
|
+
app.directive('skeleton', vSkeleton)
|
|
106
124
|
if (options.isHydrating) app.provide(M3_HYDRATING_KEY, options.isHydrating)
|
|
107
125
|
if (options.initialState) app.provide(M3_INITIAL_STATE_KEY, resolveInitialState(options))
|
|
108
126
|
if (options.cookies && typeof window !== 'undefined') enableCookies()
|
|
@@ -144,3 +162,19 @@ export function createM3UI(options: M3UIOptions = {}) {
|
|
|
144
162
|
},
|
|
145
163
|
}
|
|
146
164
|
}
|
|
165
|
+
|
|
166
|
+
// The directives createM3UI() registers, typed for templates (vue-tsc / Volar check `v-tooltip="…"` against them)
|
|
167
|
+
declare module 'vue' {
|
|
168
|
+
interface GlobalDirectives {
|
|
169
|
+
vRipple: typeof vRipple
|
|
170
|
+
vReveal: typeof vReveal
|
|
171
|
+
vStateLayer: typeof vStateLayer
|
|
172
|
+
vTooltip: typeof vTooltip
|
|
173
|
+
vFocusRing: typeof vFocusRing
|
|
174
|
+
vScrollElevation: typeof vScrollElevation
|
|
175
|
+
vLongPress: typeof vLongPress
|
|
176
|
+
vSwipe: typeof vSwipe
|
|
177
|
+
vClickOutside: typeof vClickOutside
|
|
178
|
+
vSkeleton: typeof vSkeleton
|
|
179
|
+
}
|
|
180
|
+
}
|
package/src/styles/theme.css
CHANGED
|
@@ -370,6 +370,69 @@ html.theme-transitioning *::after {
|
|
|
370
370
|
animation: m3-ripple 450ms cubic-bezier(0.2, 0, 0.8, 1) forwards;
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
+
/* v-state-layer: M3 state layer opacities (StateTokens: hover 8%, focus 10%, pressed 10%, dragged 16%). Hover
|
|
374
|
+
only where there's a real hover, so a tap on a phone doesn't leave the layer on */
|
|
375
|
+
.m3-state-layer {
|
|
376
|
+
position: absolute;
|
|
377
|
+
inset: 0;
|
|
378
|
+
border-radius: inherit;
|
|
379
|
+
background: currentColor;
|
|
380
|
+
opacity: 0;
|
|
381
|
+
pointer-events: none;
|
|
382
|
+
transition: opacity 150ms linear;
|
|
383
|
+
}
|
|
384
|
+
@media (hover: hover) {
|
|
385
|
+
[data-m3-state-layer='']:hover > .m3-state-layer { opacity: 0.08; }
|
|
386
|
+
}
|
|
387
|
+
[data-m3-state-layer='']:focus-visible > .m3-state-layer,
|
|
388
|
+
[data-m3-state-layer='']:active > .m3-state-layer { opacity: 0.1; }
|
|
389
|
+
[data-m3-state-layer='dragged'] > .m3-state-layer { opacity: 0.16; }
|
|
390
|
+
[data-m3-state-layer]:is(:disabled, [aria-disabled='true']) > .m3-state-layer { opacity: 0; }
|
|
391
|
+
|
|
392
|
+
/* v-focus-ring: M3's focus indicator (3dp, secondary, 2dp outside), on keyboard focus only. Unlayered on purpose:
|
|
393
|
+
it beats an `outline-none` utility on the same element */
|
|
394
|
+
[data-m3-focus-ring='']:focus-visible,
|
|
395
|
+
[data-m3-focus-ring='within']:is(:focus-visible, :has(:focus-visible)) {
|
|
396
|
+
outline: 3px solid var(--m3-focus-ring-color, var(--color-secondary));
|
|
397
|
+
outline-offset: var(--m3-focus-ring-offset, 2px);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/* v-skeleton: the element as its own placeholder (MSkeleton's tint and animations). Unlayered, so it beats the
|
|
401
|
+
element's own bg-*, text-*, border-* and shadow-* utilities while loading */
|
|
402
|
+
[data-m3-skeleton] {
|
|
403
|
+
background: color-mix(in srgb, var(--color-on-surface) 10%, transparent);
|
|
404
|
+
border-color: transparent;
|
|
405
|
+
box-shadow: none;
|
|
406
|
+
color: transparent;
|
|
407
|
+
pointer-events: none;
|
|
408
|
+
user-select: none;
|
|
409
|
+
}
|
|
410
|
+
[data-m3-skeleton] > :not(.m3-skeleton-shimmer) { visibility: hidden; }
|
|
411
|
+
[data-m3-skeleton='pulse'] { animation: m3-skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
|
|
412
|
+
@keyframes m3-skeleton-pulse { 50% { opacity: 0.5; } }
|
|
413
|
+
.m3-skeleton-shimmer {
|
|
414
|
+
position: absolute;
|
|
415
|
+
inset: 0;
|
|
416
|
+
overflow: hidden;
|
|
417
|
+
border-radius: inherit;
|
|
418
|
+
pointer-events: none;
|
|
419
|
+
}
|
|
420
|
+
.m3-skeleton-shimmer::after {
|
|
421
|
+
content: '';
|
|
422
|
+
position: absolute;
|
|
423
|
+
inset: 0;
|
|
424
|
+
background: linear-gradient(90deg, transparent 0%, var(--color-on-surface) 50%, transparent 100%);
|
|
425
|
+
opacity: 0.06;
|
|
426
|
+
animation: m3-skeleton-wave 1.8s ease-in-out infinite;
|
|
427
|
+
}
|
|
428
|
+
@keyframes m3-skeleton-wave {
|
|
429
|
+
0% { transform: translateX(-100%); }
|
|
430
|
+
60%, 100% { transform: translateX(100%); }
|
|
431
|
+
}
|
|
432
|
+
@media (prefers-reduced-motion: reduce) {
|
|
433
|
+
[data-m3-skeleton='pulse'], .m3-skeleton-shimmer::after { animation: none; }
|
|
434
|
+
}
|
|
435
|
+
|
|
373
436
|
@keyframes m3-ctx-in {
|
|
374
437
|
from { transform: translateY(-6px) scale(0.94); }
|
|
375
438
|
to { transform: translateY(0) scale(1); }
|