@m3ui-vue/m3ui-vue 1.0.3 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/API.md +75 -11
- package/dist/MMenuItem-BOkcVtEe.js +809 -0
- package/dist/MMenuItem-BOkcVtEe.js.map +1 -0
- package/dist/{MSlider-CdNIH7jc.js → MSlider-BXsBv0ox.js} +208 -182
- package/dist/MSlider-BXsBv0ox.js.map +1 -0
- package/dist/{MTextField-B4X92vH_.js → MTextField-rML9jnXs.js} +2 -2
- package/dist/{MTextField-B4X92vH_.js.map → MTextField-rML9jnXs.js.map} +1 -1
- package/dist/api.json +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MBottomSheet.vue.d.ts +20 -1
- package/dist/components/MDialog.vue.d.ts +17 -8
- package/dist/components/MDragDropList.vue.d.ts +1 -1
- package/dist/components/MMap.vue.d.ts +4 -4
- package/dist/components/MMapControl.vue.d.ts +20 -3
- package/dist/components/MMapMarker.vue.d.ts +5 -2
- package/dist/components/MMapPopup.vue.d.ts +5 -3
- package/dist/components/MMenuItem.vue.d.ts +2 -2
- package/dist/components/MSeekBar.vue.d.ts +122 -0
- package/dist/components/MSplitButton.vue.d.ts +2 -2
- package/dist/components/_MMapAttribution.vue.d.ts +7 -0
- package/dist/composables/_mapPin.d.ts +5 -0
- package/dist/composables/_popupPosition.d.ts +12 -0
- package/dist/composables/_useCalendarMonth.d.ts +24 -0
- package/dist/composables/_useEscapeStack.d.ts +3 -0
- package/dist/composables/_useScrollLock.d.ts +8 -0
- package/dist/composables/_useSheetMotion.d.ts +16 -1
- package/dist/composables/useLocale.d.ts +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/locales/index.js +56 -0
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +5276 -4718
- package/dist/m3ui.js.map +1 -1
- package/dist/map.js +777 -641
- package/dist/map.js.map +1 -1
- package/dist/rich-text-editor.js +8 -8
- package/dist/styles.css +1 -1
- package/dist/{useLocale-b5-hzsL3.js → useLocale-CqQrhWFl.js} +9 -1
- package/dist/useLocale-CqQrhWFl.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/MDialog.test.ts +30 -0
- package/src/__tests__/MMap.test.ts +132 -2
- package/src/__tests__/MSeekBar.test.ts +170 -0
- package/src/__tests__/MShape.test.ts +20 -0
- package/src/__tests__/MTooltip.test.ts +110 -0
- package/src/__tests__/_fakeMaplibre.ts +3 -0
- package/src/__tests__/calendarMonth.test.ts +59 -0
- package/src/__tests__/pickerModals.test.ts +128 -0
- package/src/__tests__/popupPosition.test.ts +224 -0
- package/src/__tests__/scrollLock.test.ts +110 -0
- package/src/__tests__/sheets.test.ts +158 -0
- package/src/components/MAutocomplete.vue +2 -4
- package/src/components/MBottomSheet.vue +211 -13
- package/src/components/MCommandPalette.vue +4 -6
- package/src/components/MContextMenu.vue +19 -5
- package/src/components/MDatePicker.vue +29 -70
- package/src/components/MDatePickerModal.vue +116 -172
- package/src/components/MDateRangePicker.vue +29 -51
- package/src/components/MDateRangePickerModal.vue +84 -162
- package/src/components/MDialog.vue +87 -63
- package/src/components/MLightbox.vue +6 -3
- package/src/components/MMap.vue +74 -28
- package/src/components/MMapControl.vue +121 -7
- package/src/components/MMapIdentify.vue +2 -1
- package/src/components/MMapMarker.vue +14 -7
- package/src/components/MMapPopup.vue +8 -4
- package/src/components/MMenu.vue +31 -12
- package/src/components/MMenuItem.vue +21 -4
- package/src/components/MMultiAutocomplete.vue +2 -4
- package/src/components/MMultiSelect.vue +2 -4
- package/src/components/MNavigationDrawer.vue +2 -8
- package/src/components/MNavigationRail.vue +2 -3
- package/src/components/MSearchBar.vue +2 -5
- package/src/components/MSeekBar.vue +593 -0
- package/src/components/MSelect.vue +2 -8
- package/src/components/MShape.vue +22 -8
- package/src/components/MSplitButton.vue +23 -7
- package/src/components/MSpotlightSearch.vue +4 -6
- package/src/components/MTimePicker.vue +23 -6
- package/src/components/MTimePickerModal.vue +213 -226
- package/src/components/MTooltip.vue +99 -3
- package/src/components/_MMapAttribution.vue +81 -0
- package/src/composables/_mapPin.ts +25 -0
- package/src/composables/_popupPosition.ts +39 -0
- package/src/composables/_useCalendarMonth.ts +74 -0
- package/src/composables/_useEscapeStack.ts +33 -0
- package/src/composables/_useScrollLock.ts +41 -0
- package/src/composables/_useSheetMotion.ts +82 -20
- package/src/composables/useLocale.ts +16 -0
- package/src/index.ts +2 -0
- package/src/locales/de.ts +8 -0
- package/src/locales/es.ts +8 -0
- package/src/locales/fr.ts +8 -0
- package/src/locales/ja.ts +8 -0
- package/src/locales/ko.ts +8 -0
- package/src/locales/pt.ts +8 -0
- package/src/locales/zh.ts +8 -0
- package/dist/MMenuItem-DFyXflk9.js +0 -707
- package/dist/MMenuItem-DFyXflk9.js.map +0 -1
- package/dist/MSlider-CdNIH7jc.js.map +0 -1
- package/dist/useLocale-b5-hzsL3.js.map +0 -1
|
@@ -9,6 +9,7 @@ import MIcon from './MIcon.vue'
|
|
|
9
9
|
import MIconButton from './MIconButton.vue'
|
|
10
10
|
import { useFieldBg } from '../composables/useFieldBg'
|
|
11
11
|
import { useLocale } from '../composables/useLocale'
|
|
12
|
+
import { useScrollLock } from '../composables/_useScrollLock'
|
|
12
13
|
|
|
13
14
|
export interface SelectOption {
|
|
14
15
|
label: string
|
|
@@ -147,13 +148,7 @@ function onKeydown(e: KeyboardEvent) {
|
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
150
|
|
|
150
|
-
|
|
151
|
-
if (v) {
|
|
152
|
-
document.body.style.overflow = 'hidden'
|
|
153
|
-
} else {
|
|
154
|
-
document.body.style.overflow = ''
|
|
155
|
-
}
|
|
156
|
-
})
|
|
151
|
+
useScrollLock(modalOpen)
|
|
157
152
|
|
|
158
153
|
function closeModal() { modalOpen.value = false }
|
|
159
154
|
|
|
@@ -164,7 +159,6 @@ onMounted(() => {
|
|
|
164
159
|
onUnmounted(() => {
|
|
165
160
|
document.removeEventListener('mousedown', onOutsideClick)
|
|
166
161
|
window.removeEventListener('scroll', onScroll, true)
|
|
167
|
-
document.body.style.overflow = ''
|
|
168
162
|
})
|
|
169
163
|
|
|
170
164
|
const triggerClasses = computed(() => {
|
|
@@ -45,9 +45,12 @@ const props = withDefaults(
|
|
|
45
45
|
|
|
46
46
|
const clipId = `m3-shape-${useId()}`
|
|
47
47
|
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
|
|
48
|
+
// The clip path uses objectBoundingBox units (0-1), so it scales with the element's actual
|
|
49
|
+
// rendered size instead of a fixed px box. The path itself is built at size 100 and scaled down
|
|
50
|
+
// by the clipPath's transform: shape-morph writes 2 decimals, which at size 1 snapped every point
|
|
51
|
+
// to 1% of the shape (4px steps on a 400px shape, a visibly wobbly outline).
|
|
52
|
+
const SIZE = 100
|
|
53
|
+
const pathD = ref(toSvgPath(getShape(props.shape), SIZE))
|
|
51
54
|
|
|
52
55
|
let morph: AnimatedMorph | null = null
|
|
53
56
|
let settledShape = props.shape
|
|
@@ -70,7 +73,7 @@ watch(() => props.shape, (next, prev) => {
|
|
|
70
73
|
if (!prev || next === prev) return
|
|
71
74
|
morph?.dispose()
|
|
72
75
|
if (!props.animate) {
|
|
73
|
-
pathD.value = toSvgPath(getShape(next),
|
|
76
|
+
pathD.value = toSvgPath(getShape(next), SIZE)
|
|
74
77
|
settledShape = next
|
|
75
78
|
return
|
|
76
79
|
}
|
|
@@ -79,7 +82,7 @@ watch(() => props.shape, (next, prev) => {
|
|
|
79
82
|
// the last shape that had actually settled rather than the current on-screen outline.
|
|
80
83
|
morph = new AnimatedMorph(settledShape, next, {
|
|
81
84
|
spring: springFor(props.speed),
|
|
82
|
-
size:
|
|
85
|
+
size: SIZE,
|
|
83
86
|
onFrame: (frame) => { pathD.value = frame.pathD },
|
|
84
87
|
})
|
|
85
88
|
// The constructor only emits the start shape at progress 0 — setting `progress` is what
|
|
@@ -94,11 +97,11 @@ onUnmounted(() => morph?.dispose())
|
|
|
94
97
|
</script>
|
|
95
98
|
|
|
96
99
|
<template>
|
|
97
|
-
<span class="
|
|
100
|
+
<span class="m3-shape">
|
|
98
101
|
<svg width="0" height="0" class="absolute">
|
|
99
102
|
<defs>
|
|
100
103
|
<clipPath :id="clipId" clipPathUnits="objectBoundingBox">
|
|
101
|
-
<path :d="pathD" />
|
|
104
|
+
<path :d="pathD" :transform="`scale(${1 / SIZE})`" />
|
|
102
105
|
</clipPath>
|
|
103
106
|
</defs>
|
|
104
107
|
</svg>
|
|
@@ -106,8 +109,19 @@ onUnmounted(() => morph?.dispose())
|
|
|
106
109
|
<div v-if="$slots.default" class="h-full w-full" :style="{ clipPath: `url(#${clipId})` }">
|
|
107
110
|
<slot />
|
|
108
111
|
</div>
|
|
109
|
-
<svg v-else viewBox="0 0
|
|
112
|
+
<svg v-else :viewBox="`0 0 ${SIZE} ${SIZE}`" class="h-full w-full">
|
|
110
113
|
<path :d="pathD" :fill="fill" />
|
|
111
114
|
</svg>
|
|
112
115
|
</span>
|
|
113
116
|
</template>
|
|
117
|
+
|
|
118
|
+
<style>
|
|
119
|
+
/* Defaults in the base layer, not utilities on the root: any class the consumer passes
|
|
120
|
+
(absolute, block, ...) is a utility and always beats them, whatever Tailwind's order. */
|
|
121
|
+
@layer base {
|
|
122
|
+
.m3-shape {
|
|
123
|
+
position: relative;
|
|
124
|
+
display: inline-block;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
</style>
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
|
10
10
|
import MIcon from './MIcon.vue'
|
|
11
11
|
import { vRipple } from '../directives/vRipple'
|
|
12
|
+
import { POPUP_MARGIN, dropdownX, fitPopup } from '../composables/_popupPosition'
|
|
12
13
|
|
|
13
14
|
export interface SplitButtonItem {
|
|
14
15
|
label: string
|
|
@@ -114,23 +115,36 @@ const buttonStateClasses = computed(() => {
|
|
|
114
115
|
]
|
|
115
116
|
})
|
|
116
117
|
|
|
118
|
+
// At least as wide as the button, at the window's left edge until placeMenu() can measure it (once it's in the
|
|
119
|
+
// DOM, before it paints) and keep it on screen (see _popupPosition.ts): under the button, aligned with its start
|
|
120
|
+
// edge, else its end edge or the window edge; above it when it doesn't fit below
|
|
121
|
+
let anchorRect: DOMRect | null = null
|
|
117
122
|
function computeMenuPos() {
|
|
118
123
|
if (!containerEl.value) return
|
|
119
124
|
const rect = containerEl.value.getBoundingClientRect()
|
|
120
|
-
|
|
121
|
-
const spaceBelow = window.innerHeight - rect.bottom - 8
|
|
122
|
-
const above = spaceBelow < menuH && rect.top > menuH
|
|
125
|
+
anchorRect = rect
|
|
123
126
|
menuStyle.value = {
|
|
124
127
|
position: 'fixed',
|
|
125
128
|
zIndex: '500',
|
|
126
|
-
left:
|
|
129
|
+
left: '0px',
|
|
130
|
+
top: `${rect.bottom + 4}px`,
|
|
127
131
|
minWidth: `${rect.width}px`,
|
|
128
|
-
|
|
129
|
-
? { bottom: `${window.innerHeight - rect.top + 4}px` }
|
|
130
|
-
: { top: `${rect.bottom + 4}px` }),
|
|
132
|
+
maxWidth: `${window.innerWidth - 2 * POPUP_MARGIN}px`,
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
135
|
|
|
136
|
+
function placeMenu(el: Element) {
|
|
137
|
+
if (!anchorRect) return
|
|
138
|
+
const menu = el as HTMLElement
|
|
139
|
+
const w = menu.offsetWidth
|
|
140
|
+
const h = menu.offsetHeight
|
|
141
|
+
const left = dropdownX(anchorRect, w, window.innerWidth, 'start')
|
|
142
|
+
const top = fitPopup([anchorRect.bottom + 4, anchorRect.top - 4 - h], h, window.innerHeight)
|
|
143
|
+
menuStyle.value = { ...menuStyle.value, left: `${left}px`, top: `${top}px` }
|
|
144
|
+
menu.style.left = `${left}px`
|
|
145
|
+
menu.style.top = `${top}px`
|
|
146
|
+
}
|
|
147
|
+
|
|
134
148
|
function toggleMenu() {
|
|
135
149
|
if (props.disabled) return
|
|
136
150
|
if (!open.value) computeMenuPos()
|
|
@@ -217,6 +231,7 @@ onUnmounted(() => {
|
|
|
217
231
|
enter-from-class="opacity-0 -translate-y-1 scale-[0.98]"
|
|
218
232
|
leave-active-class="transition-[opacity,transform] duration-100"
|
|
219
233
|
leave-to-class="opacity-0 -translate-y-1 scale-[0.98]"
|
|
234
|
+
@enter="placeMenu"
|
|
220
235
|
>
|
|
221
236
|
<div
|
|
222
237
|
v-if="open && items?.length"
|
|
@@ -245,6 +260,7 @@ onUnmounted(() => {
|
|
|
245
260
|
enter-from-class="opacity-0 -translate-y-1 scale-[0.98]"
|
|
246
261
|
leave-active-class="transition-[opacity,transform] duration-100"
|
|
247
262
|
leave-to-class="opacity-0 -translate-y-1 scale-[0.98]"
|
|
263
|
+
@enter="placeMenu"
|
|
248
264
|
>
|
|
249
265
|
<div
|
|
250
266
|
v-if="open && !items?.length && $slots.menu"
|
|
@@ -12,6 +12,7 @@ import { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue'
|
|
|
12
12
|
import MIcon from './MIcon.vue'
|
|
13
13
|
import MSpinner from './MSpinner.vue'
|
|
14
14
|
import { useLocale } from '../composables/useLocale'
|
|
15
|
+
import { useScrollLock } from '../composables/_useScrollLock'
|
|
15
16
|
|
|
16
17
|
const locale = useLocale()
|
|
17
18
|
|
|
@@ -148,15 +149,12 @@ function onGlobalKeydown(e: KeyboardEvent) {
|
|
|
148
149
|
watch(
|
|
149
150
|
() => props.modelValue,
|
|
150
151
|
(open) => {
|
|
151
|
-
if (open)
|
|
152
|
-
document.body.style.overflow = 'hidden'
|
|
153
|
-
nextTick(() => inputRef.value?.focus())
|
|
154
|
-
} else {
|
|
155
|
-
document.body.style.overflow = ''
|
|
156
|
-
}
|
|
152
|
+
if (open) nextTick(() => inputRef.value?.focus())
|
|
157
153
|
},
|
|
158
154
|
)
|
|
159
155
|
|
|
156
|
+
useScrollLock(() => props.modelValue)
|
|
157
|
+
|
|
160
158
|
watch(query, () => {
|
|
161
159
|
activeIndex.value = 0
|
|
162
160
|
emitSearch()
|
|
@@ -8,6 +8,7 @@ import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
|
8
8
|
import MIcon from './MIcon.vue'
|
|
9
9
|
import { useFieldBg } from '../composables/useFieldBg'
|
|
10
10
|
import { useLocale } from '../composables/useLocale'
|
|
11
|
+
import { POPUP_MARGIN, dropdownX, fitPopup } from '../composables/_popupPosition'
|
|
11
12
|
|
|
12
13
|
const props = withDefaults(defineProps<{
|
|
13
14
|
/** Selected time (HH:MM, v-model) */
|
|
@@ -40,7 +41,7 @@ const open = ref(false)
|
|
|
40
41
|
const triggerEl = ref<HTMLElement | null>(null)
|
|
41
42
|
const panelEl = ref<HTMLElement | null>(null)
|
|
42
43
|
const mode = ref<'hour' | 'minute'>('hour')
|
|
43
|
-
const dropPos = ref({ top: '0px', left: '0px' })
|
|
44
|
+
const dropPos = ref<Record<string, string>>({ top: '0px', left: '0px' })
|
|
44
45
|
const { resolvedFieldBg } = useFieldBg(triggerEl, () => props.fieldBg)
|
|
45
46
|
|
|
46
47
|
const parsed = computed(() => {
|
|
@@ -87,18 +88,33 @@ const displayValue = computed(() => {
|
|
|
87
88
|
return `${pad(parsed.value.h)}:${pad(parsed.value.m)}`
|
|
88
89
|
})
|
|
89
90
|
|
|
91
|
+
// The panel's size isn't known until it's in the DOM: placeDrop() keeps it on screen once it is, before it paints
|
|
92
|
+
// (see _popupPosition.ts): under the field, aligned with its start edge, else its end edge or the window edge;
|
|
93
|
+
// above it when it doesn't fit below. Until then it waits at the window's left edge, where nothing narrows it.
|
|
94
|
+
let anchorRect: DOMRect | null = null
|
|
90
95
|
function computeDropPos() {
|
|
91
96
|
if (!triggerEl.value) return
|
|
92
97
|
const rect = triggerEl.value.getBoundingClientRect()
|
|
93
|
-
|
|
94
|
-
const spaceBelow = window.innerHeight - rect.bottom - 8
|
|
95
|
-
const above = spaceBelow < panelH && rect.top > panelH
|
|
98
|
+
anchorRect = rect
|
|
96
99
|
dropPos.value = {
|
|
97
|
-
top:
|
|
98
|
-
left:
|
|
100
|
+
top: `${rect.bottom + 4}px`,
|
|
101
|
+
left: '0px',
|
|
102
|
+
maxWidth: `${window.innerWidth - 2 * POPUP_MARGIN}px`,
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
|
|
106
|
+
function placeDrop(el: Element) {
|
|
107
|
+
if (!anchorRect) return
|
|
108
|
+
const panel = el as HTMLElement
|
|
109
|
+
const w = panel.offsetWidth
|
|
110
|
+
const h = panel.offsetHeight
|
|
111
|
+
const left = dropdownX(anchorRect, w, window.innerWidth, 'start')
|
|
112
|
+
const top = fitPopup([anchorRect.bottom + 4, anchorRect.top - 4 - h], h, window.innerHeight)
|
|
113
|
+
dropPos.value = { ...dropPos.value, left: `${left}px`, top: `${top}px` }
|
|
114
|
+
panel.style.left = `${left}px`
|
|
115
|
+
panel.style.top = `${top}px`
|
|
116
|
+
}
|
|
117
|
+
|
|
102
118
|
function onOut(e: MouseEvent) {
|
|
103
119
|
const t = e.target as Node
|
|
104
120
|
if (triggerEl.value?.contains(t)) return
|
|
@@ -174,6 +190,7 @@ onUnmounted(() => {
|
|
|
174
190
|
enter-from-class="opacity-0 -translate-y-1 scale-[0.98]"
|
|
175
191
|
leave-active-class="transition-[opacity,transform] duration-100"
|
|
176
192
|
leave-to-class="opacity-0 -translate-y-1 scale-[0.98]"
|
|
193
|
+
@enter="placeDrop"
|
|
177
194
|
>
|
|
178
195
|
<div
|
|
179
196
|
v-if="open"
|