@m3ui-vue/m3ui-vue 1.0.2 → 1.1.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/dist/API.md +666 -12
- package/dist/MMenuItem-BOkcVtEe.js +809 -0
- package/dist/MMenuItem-BOkcVtEe.js.map +1 -0
- package/dist/MSlider-BXsBv0ox.js +1402 -0
- package/dist/MSlider-BXsBv0ox.js.map +1 -0
- package/dist/MTextField-rML9jnXs.js +671 -0
- package/dist/MTextField-rML9jnXs.js.map +1 -0
- 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/MIconButton.vue.d.ts +1 -1
- package/dist/components/MMap.vue.d.ts +74 -0
- package/dist/components/MMapBaseLayers.vue.d.ts +15 -0
- package/dist/components/MMapControl.vue.d.ts +40 -0
- package/dist/components/MMapFeatureInfo.vue.d.ts +25 -0
- package/dist/components/MMapFilter.vue.d.ts +19 -0
- package/dist/components/MMapGeoJson.vue.d.ts +34 -0
- package/dist/components/MMapHover.vue.d.ts +17 -0
- package/dist/components/MMapIdentify.vue.d.ts +37 -0
- package/dist/components/MMapLayers.vue.d.ts +31 -0
- package/dist/components/MMapMarker.vue.d.ts +45 -0
- package/dist/components/MMapMeasure.vue.d.ts +43 -0
- package/dist/components/MMapPopup.vue.d.ts +45 -0
- package/dist/components/MMapSearch.vue.d.ts +28 -0
- 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/components/_MMapLayerItem.vue.d.ts +25 -0
- package/dist/composables/_mapGeometry.d.ts +13 -0
- package/dist/composables/_mapPin.d.ts +5 -0
- package/dist/composables/_popupPosition.d.ts +12 -0
- package/dist/composables/_ssrState.d.ts +30 -0
- package/dist/composables/_storageKeys.d.ts +3 -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/_useThemeTokens.d.ts +7 -0
- package/dist/composables/mapAdapters.d.ts +111 -0
- package/dist/composables/mapSearch.d.ts +31 -0
- package/dist/composables/themeInitScript.d.ts +4 -3
- package/dist/composables/useColorPalette.d.ts +173 -7
- package/dist/composables/useLocale.d.ts +38 -0
- package/dist/composables/useMap.d.ts +47 -0
- package/dist/composables/useMapFilter.d.ts +10 -0
- package/dist/composables/useMapLayers.d.ts +30 -0
- package/dist/composables/useTheme.d.ts +2 -1
- package/dist/index.d.ts +4 -1
- package/dist/locales/index.js +273 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +7913 -8625
- package/dist/m3ui.js.map +1 -1
- package/dist/map.d.ts +24 -0
- package/dist/map.js +2067 -0
- package/dist/map.js.map +1 -0
- package/dist/plugin.d.ts +18 -2
- package/dist/rich-text-editor.js +26 -25
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/{useLocale-CuvWRZ1h.js → useLocale-CqQrhWFl.js} +40 -2
- package/dist/useLocale-CqQrhWFl.js.map +1 -0
- package/package.json +11 -2
- package/src/__tests__/MDialog.test.ts +30 -0
- package/src/__tests__/MFab.test.ts +52 -6
- package/src/__tests__/MMap.test.ts +422 -0
- package/src/__tests__/MMapLayers.test.ts +257 -0
- package/src/__tests__/MMapTools.test.ts +233 -0
- package/src/__tests__/MSeekBar.test.ts +170 -0
- package/src/__tests__/MTooltip.test.ts +110 -0
- package/src/__tests__/_fakeMaplibre.ts +161 -0
- package/src/__tests__/calendarMonth.test.ts +59 -0
- package/src/__tests__/hydration.test.ts +33 -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/__tests__/ssr.test.ts +63 -1
- package/src/__tests__/ssrState.test.ts +155 -0
- package/src/__tests__/themeInitScript.test.ts +18 -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/MFab.vue +29 -7
- package/src/components/MIconButton.vue +1 -1
- package/src/components/MLightbox.vue +12 -5
- package/src/components/MMap.vue +568 -0
- package/src/components/MMapBaseLayers.vue +67 -0
- package/src/components/MMapControl.vue +175 -0
- package/src/components/MMapFeatureInfo.vue +41 -0
- package/src/components/MMapFilter.vue +80 -0
- package/src/components/MMapGeoJson.vue +136 -0
- package/src/components/MMapHover.vue +131 -0
- package/src/components/MMapIdentify.vue +104 -0
- package/src/components/MMapLayers.vue +111 -0
- package/src/components/MMapMarker.vue +109 -0
- package/src/components/MMapMeasure.vue +452 -0
- package/src/components/MMapPopup.vue +103 -0
- package/src/components/MMapSearch.vue +162 -0
- 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/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/components/_MMapLayerItem.vue +77 -0
- package/src/composables/_mapGeometry.ts +75 -0
- package/src/composables/_mapPin.ts +25 -0
- package/src/composables/_popupPosition.ts +39 -0
- package/src/composables/_ssrState.ts +80 -0
- package/src/composables/_storageKeys.ts +6 -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/_useThemeTokens.ts +42 -0
- package/src/composables/mapAdapters.ts +208 -0
- package/src/composables/mapSearch.ts +56 -0
- package/src/composables/themeInitScript.ts +6 -4
- package/src/composables/useColorPalette.ts +23 -9
- package/src/composables/useLocale.ts +78 -0
- package/src/composables/useMap.ts +98 -0
- package/src/composables/useMapFilter.ts +45 -0
- package/src/composables/useMapLayers.ts +124 -0
- package/src/composables/useTheme.ts +8 -3
- package/src/composables/useWindowSizeClass.ts +14 -5
- package/src/index.ts +4 -1
- package/src/locales/de.ts +39 -1
- package/src/locales/es.ts +39 -1
- package/src/locales/fr.ts +39 -1
- package/src/locales/ja.ts +39 -1
- package/src/locales/ko.ts +39 -1
- package/src/locales/pt.ts +39 -1
- package/src/locales/zh.ts +39 -1
- package/src/map.ts +32 -0
- package/src/plugin.ts +54 -3
- package/dist/MTextField-BPbFeI9M.js +0 -1368
- package/dist/MTextField-BPbFeI9M.js.map +0 -1
- package/dist/useLocale-CuvWRZ1h.js.map +0 -1
|
@@ -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"
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { computed, ref, watch } from 'vue'
|
|
11
11
|
import MButton from './MButton.vue'
|
|
12
|
+
import MDialog from './MDialog.vue'
|
|
12
13
|
import MIconButton from './MIconButton.vue'
|
|
13
14
|
import MTimeScroll from './MTimeScroll.vue'
|
|
14
15
|
import { useLocale } from '../composables/useLocale'
|
|
@@ -70,11 +71,6 @@ watch(() => props.show, (open) => {
|
|
|
70
71
|
selectedMinute.value = props.mode === 'scroll' ? Math.floor(m / props.minuteStep) * props.minuteStep : m
|
|
71
72
|
step.value = 'hour'
|
|
72
73
|
inputMode.value = props.mode
|
|
73
|
-
document.addEventListener('keydown', onKeydown)
|
|
74
|
-
document.body.style.overflow = 'hidden'
|
|
75
|
-
} else {
|
|
76
|
-
document.removeEventListener('keydown', onKeydown)
|
|
77
|
-
document.body.style.overflow = ''
|
|
78
74
|
}
|
|
79
75
|
})
|
|
80
76
|
|
|
@@ -228,6 +224,20 @@ const scrollTime = computed({
|
|
|
228
224
|
const toggleIcon = computed(() =>
|
|
229
225
|
inputMode.value !== 'input' ? 'keyboard' : props.mode === 'scroll' ? 'swipe_vertical' : 'schedule',
|
|
230
226
|
)
|
|
227
|
+
// AM/PM in the app's language, from Intl, as MTimeScroll (the values stay 'AM'/'PM')
|
|
228
|
+
const periods = computed(() => {
|
|
229
|
+
const label = (h: number) => {
|
|
230
|
+
try {
|
|
231
|
+
return new Intl.DateTimeFormat(locale.lang, { hour: 'numeric', hour12: true })
|
|
232
|
+
.formatToParts(new Date(2000, 0, 1, h))
|
|
233
|
+
.find((p) => p.type === 'dayPeriod')?.value ?? (h < 12 ? 'AM' : 'PM')
|
|
234
|
+
} catch {
|
|
235
|
+
return h < 12 ? 'AM' : 'PM'
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return [label(9), label(21)] as const
|
|
239
|
+
})
|
|
240
|
+
|
|
231
241
|
const toggleLabel = computed(() =>
|
|
232
242
|
inputMode.value !== 'input'
|
|
233
243
|
? locale.timeToggleKeyboard
|
|
@@ -276,235 +286,212 @@ function confirm() {
|
|
|
276
286
|
emit('update:show', false)
|
|
277
287
|
}
|
|
278
288
|
|
|
279
|
-
|
|
289
|
+
// Escape or the scrim (MDialog) cancel, like the Cancel button
|
|
290
|
+
function onDialog(open: boolean) {
|
|
291
|
+
if (!open) cancel()
|
|
292
|
+
}
|
|
280
293
|
</script>
|
|
281
294
|
|
|
282
295
|
<template>
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
>
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
? 'bg-tertiary-container text-on-tertiary-container'
|
|
350
|
-
: 'text-on-surface-variant hover:bg-on-surface/8'
|
|
351
|
-
"
|
|
352
|
-
@click="period = 'PM'"
|
|
353
|
-
>PM</button>
|
|
354
|
-
</div>
|
|
355
|
-
</div>
|
|
356
|
-
|
|
357
|
-
<!-- Clock dial -->
|
|
358
|
-
<div
|
|
359
|
-
ref="dialEl"
|
|
360
|
-
class="relative mx-auto h-[256px] w-[256px] select-none"
|
|
361
|
-
@mousedown="onDialDown"
|
|
362
|
-
@touchstart.prevent="onDialTouch"
|
|
363
|
-
>
|
|
364
|
-
<div class="absolute inset-0 rounded-full bg-surface-container-highest" />
|
|
365
|
-
|
|
366
|
-
<svg class="pointer-events-none absolute inset-0" viewBox="0 0 256 256">
|
|
367
|
-
<line
|
|
368
|
-
:x1="CX" :y1="CX"
|
|
369
|
-
:x2="handEnd.x" :y2="handEnd.y"
|
|
370
|
-
stroke="var(--color-primary)" stroke-width="2"
|
|
371
|
-
/>
|
|
372
|
-
<circle :cx="CX" :cy="CX" r="4" fill="var(--color-primary)" />
|
|
373
|
-
<circle :cx="handEnd.x" :cy="handEnd.y" :r="NUM_R" fill="var(--color-primary)" />
|
|
374
|
-
</svg>
|
|
375
|
-
|
|
376
|
-
<template v-if="step === 'hour'">
|
|
377
|
-
<button
|
|
378
|
-
v-for="item in hourItems"
|
|
379
|
-
:key="'h' + item.value"
|
|
380
|
-
type="button"
|
|
381
|
-
class="pointer-events-auto absolute flex h-10 w-10 items-center justify-center rounded-full text-body-large transition-colors"
|
|
382
|
-
:class="
|
|
383
|
-
item.value === selectedHour
|
|
384
|
-
? 'text-on-primary font-medium'
|
|
385
|
-
: 'text-on-surface cursor-pointer'
|
|
386
|
-
"
|
|
387
|
-
:style="{
|
|
388
|
-
left: `${item.x}px`,
|
|
389
|
-
top: `${item.y}px`,
|
|
390
|
-
transform: 'translate(-50%, -50%)',
|
|
391
|
-
}"
|
|
392
|
-
@click.stop="selectHour(item.value)"
|
|
393
|
-
>
|
|
394
|
-
{{ item.label }}
|
|
395
|
-
</button>
|
|
396
|
-
</template>
|
|
397
|
-
|
|
398
|
-
<template v-else>
|
|
399
|
-
<button
|
|
400
|
-
v-for="item in minuteItems"
|
|
401
|
-
:key="'m' + item.value"
|
|
402
|
-
type="button"
|
|
403
|
-
class="pointer-events-auto absolute flex h-10 w-10 items-center justify-center rounded-full text-body-large transition-colors"
|
|
404
|
-
:class="
|
|
405
|
-
item.value === selectedMinute
|
|
406
|
-
? 'text-on-primary font-medium'
|
|
407
|
-
: 'text-on-surface cursor-pointer'
|
|
408
|
-
"
|
|
409
|
-
:style="{
|
|
410
|
-
left: `${item.x}px`,
|
|
411
|
-
top: `${item.y}px`,
|
|
412
|
-
transform: 'translate(-50%, -50%)',
|
|
413
|
-
}"
|
|
414
|
-
@click.stop="selectedMinute = item.value"
|
|
415
|
-
>
|
|
416
|
-
{{ item.label }}
|
|
417
|
-
</button>
|
|
418
|
-
</template>
|
|
419
|
-
</div>
|
|
420
|
-
</template>
|
|
421
|
-
|
|
422
|
-
<!-- ── Scroll mode ─────────────────────────────────── -->
|
|
423
|
-
<div v-else-if="inputMode === 'scroll'" class="flex justify-center pb-4">
|
|
424
|
-
<MTimeScroll v-model="scrollTime" :use24h="use24h" :minute-step="minuteStep" />
|
|
296
|
+
<!-- MDialog's bare box: scrim, Escape, scroll lock, the open/close animation and dialog semantics -->
|
|
297
|
+
<MDialog :model-value="show" bare max-width="328px" :title="title || locale.selectTime" @update:model-value="onDialog">
|
|
298
|
+
<div class="px-6 pt-6 pb-4">
|
|
299
|
+
<!-- Title -->
|
|
300
|
+
<p class="mb-5 text-label-medium text-on-surface-variant">
|
|
301
|
+
{{ title || locale.selectTime }}
|
|
302
|
+
</p>
|
|
303
|
+
|
|
304
|
+
<!-- ── Dial mode ───────────────────────────────────── -->
|
|
305
|
+
<template v-if="inputMode === 'dial'">
|
|
306
|
+
<!-- Time display + AM/PM -->
|
|
307
|
+
<div class="mb-5 flex items-center justify-center gap-2">
|
|
308
|
+
<button
|
|
309
|
+
type="button"
|
|
310
|
+
class="flex h-20 min-w-[96px] items-center justify-center rounded-sm text-display-large transition-colors"
|
|
311
|
+
:class="
|
|
312
|
+
step === 'hour'
|
|
313
|
+
? 'bg-primary-container text-on-primary-container'
|
|
314
|
+
: 'bg-surface-container-highest text-on-surface cursor-pointer hover:bg-on-surface/8'
|
|
315
|
+
"
|
|
316
|
+
@click="step = 'hour'"
|
|
317
|
+
>
|
|
318
|
+
{{ pad(selectedHour) }}
|
|
319
|
+
</button>
|
|
320
|
+
|
|
321
|
+
<span class="text-display-large text-on-surface">:</span>
|
|
322
|
+
|
|
323
|
+
<button
|
|
324
|
+
type="button"
|
|
325
|
+
class="flex h-20 min-w-[96px] items-center justify-center rounded-sm text-display-large transition-colors"
|
|
326
|
+
:class="
|
|
327
|
+
step === 'minute'
|
|
328
|
+
? 'bg-primary-container text-on-primary-container'
|
|
329
|
+
: 'bg-surface-container-highest text-on-surface cursor-pointer hover:bg-on-surface/8'
|
|
330
|
+
"
|
|
331
|
+
@click="step = 'minute'"
|
|
332
|
+
>
|
|
333
|
+
{{ pad(selectedMinute) }}
|
|
334
|
+
</button>
|
|
335
|
+
|
|
336
|
+
<!-- AM / PM toggle -->
|
|
337
|
+
<div
|
|
338
|
+
v-if="!use24h"
|
|
339
|
+
class="ml-2 flex h-20 flex-col overflow-hidden rounded-sm border border-outline"
|
|
340
|
+
>
|
|
341
|
+
<button
|
|
342
|
+
type="button"
|
|
343
|
+
class="flex flex-1 items-center justify-center px-3 text-title-medium transition-colors"
|
|
344
|
+
:class="
|
|
345
|
+
period === 'AM'
|
|
346
|
+
? 'bg-tertiary-container text-on-tertiary-container'
|
|
347
|
+
: 'text-on-surface-variant hover:bg-on-surface/8'
|
|
348
|
+
"
|
|
349
|
+
@click="period = 'AM'"
|
|
350
|
+
>{{ periods[0] }}</button>
|
|
351
|
+
<div class="h-px bg-outline" />
|
|
352
|
+
<button
|
|
353
|
+
type="button"
|
|
354
|
+
class="flex flex-1 items-center justify-center px-3 text-title-medium transition-colors"
|
|
355
|
+
:class="
|
|
356
|
+
period === 'PM'
|
|
357
|
+
? 'bg-tertiary-container text-on-tertiary-container'
|
|
358
|
+
: 'text-on-surface-variant hover:bg-on-surface/8'
|
|
359
|
+
"
|
|
360
|
+
@click="period = 'PM'"
|
|
361
|
+
>{{ periods[1] }}</button>
|
|
425
362
|
</div>
|
|
363
|
+
</div>
|
|
426
364
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
365
|
+
<!-- Clock dial -->
|
|
366
|
+
<div
|
|
367
|
+
ref="dialEl"
|
|
368
|
+
class="relative mx-auto h-[256px] w-[256px] select-none"
|
|
369
|
+
@mousedown="onDialDown"
|
|
370
|
+
@touchstart.prevent="onDialTouch"
|
|
371
|
+
>
|
|
372
|
+
<div class="absolute inset-0 rounded-full bg-surface-container-highest" />
|
|
373
|
+
|
|
374
|
+
<svg class="pointer-events-none absolute inset-0" viewBox="0 0 256 256">
|
|
375
|
+
<line
|
|
376
|
+
:x1="CX" :y1="CX"
|
|
377
|
+
:x2="handEnd.x" :y2="handEnd.y"
|
|
378
|
+
stroke="var(--color-primary)" stroke-width="2"
|
|
436
379
|
/>
|
|
437
|
-
<
|
|
438
|
-
<
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
380
|
+
<circle :cx="CX" :cy="CX" r="4" fill="var(--color-primary)" />
|
|
381
|
+
<circle :cx="handEnd.x" :cy="handEnd.y" :r="NUM_R" fill="var(--color-primary)" />
|
|
382
|
+
</svg>
|
|
383
|
+
|
|
384
|
+
<template v-if="step === 'hour'">
|
|
385
|
+
<button
|
|
386
|
+
v-for="item in hourItems"
|
|
387
|
+
:key="'h' + item.value"
|
|
388
|
+
type="button"
|
|
389
|
+
class="pointer-events-auto absolute flex h-10 w-10 items-center justify-center rounded-full text-body-large transition-colors"
|
|
390
|
+
:class="
|
|
391
|
+
item.value === selectedHour
|
|
392
|
+
? 'text-on-primary font-medium'
|
|
393
|
+
: 'text-on-surface cursor-pointer'
|
|
394
|
+
"
|
|
395
|
+
:style="{
|
|
396
|
+
left: `${item.x}px`,
|
|
397
|
+
top: `${item.y}px`,
|
|
398
|
+
transform: 'translate(-50%, -50%)',
|
|
399
|
+
}"
|
|
400
|
+
@click.stop="selectHour(item.value)"
|
|
450
401
|
>
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
:class="
|
|
455
|
-
period === 'AM'
|
|
456
|
-
? 'bg-tertiary-container text-on-tertiary-container'
|
|
457
|
-
: 'text-on-surface-variant hover:bg-on-surface/8'
|
|
458
|
-
"
|
|
459
|
-
@click="period = 'AM'"
|
|
460
|
-
>AM</button>
|
|
461
|
-
<div class="h-px bg-outline" />
|
|
462
|
-
<button
|
|
463
|
-
type="button"
|
|
464
|
-
class="flex flex-1 items-center justify-center px-3 text-title-medium transition-colors"
|
|
465
|
-
:class="
|
|
466
|
-
period === 'PM'
|
|
467
|
-
? 'bg-tertiary-container text-on-tertiary-container'
|
|
468
|
-
: 'text-on-surface-variant hover:bg-on-surface/8'
|
|
469
|
-
"
|
|
470
|
-
@click="period = 'PM'"
|
|
471
|
-
>PM</button>
|
|
472
|
-
</div>
|
|
473
|
-
</div>
|
|
402
|
+
{{ item.label }}
|
|
403
|
+
</button>
|
|
404
|
+
</template>
|
|
474
405
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
:
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
406
|
+
<template v-else>
|
|
407
|
+
<button
|
|
408
|
+
v-for="item in minuteItems"
|
|
409
|
+
:key="'m' + item.value"
|
|
410
|
+
type="button"
|
|
411
|
+
class="pointer-events-auto absolute flex h-10 w-10 items-center justify-center rounded-full text-body-large transition-colors"
|
|
412
|
+
:class="
|
|
413
|
+
item.value === selectedMinute
|
|
414
|
+
? 'text-on-primary font-medium'
|
|
415
|
+
: 'text-on-surface cursor-pointer'
|
|
416
|
+
"
|
|
417
|
+
:style="{
|
|
418
|
+
left: `${item.x}px`,
|
|
419
|
+
top: `${item.y}px`,
|
|
420
|
+
transform: 'translate(-50%, -50%)',
|
|
421
|
+
}"
|
|
422
|
+
@click.stop="selectedMinute = item.value"
|
|
423
|
+
>
|
|
424
|
+
{{ item.label }}
|
|
425
|
+
</button>
|
|
426
|
+
</template>
|
|
487
427
|
</div>
|
|
428
|
+
</template>
|
|
429
|
+
|
|
430
|
+
<!-- ── Scroll mode ─────────────────────────────────── -->
|
|
431
|
+
<div v-else-if="inputMode === 'scroll'" class="flex justify-center pb-4">
|
|
432
|
+
<MTimeScroll v-model="scrollTime" :use24h="use24h" :minute-step="minuteStep" />
|
|
488
433
|
</div>
|
|
489
|
-
</Transition>
|
|
490
|
-
</Teleport>
|
|
491
|
-
</template>
|
|
492
434
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
435
|
+
<!-- ── Input mode ──────────────────────────────────── -->
|
|
436
|
+
<div v-else class="mx-auto flex items-center justify-center gap-2 py-8">
|
|
437
|
+
<input
|
|
438
|
+
ref="inputHourEl"
|
|
439
|
+
v-model="inputHour"
|
|
440
|
+
type="text"
|
|
441
|
+
maxlength="2"
|
|
442
|
+
class="h-20 w-[96px] rounded-sm border border-outline bg-surface-container-highest text-center text-display-large text-on-surface outline-none transition-colors focus:border-2 focus:border-primary"
|
|
443
|
+
@blur="clampInput"
|
|
444
|
+
/>
|
|
445
|
+
<span class="text-display-large text-on-surface">:</span>
|
|
446
|
+
<input
|
|
447
|
+
ref="inputMinuteEl"
|
|
448
|
+
v-model="inputMinute"
|
|
449
|
+
type="text"
|
|
450
|
+
maxlength="2"
|
|
451
|
+
class="h-20 w-[96px] rounded-sm border border-outline bg-surface-container-highest text-center text-display-large text-on-surface outline-none transition-colors focus:border-2 focus:border-primary"
|
|
452
|
+
@blur="clampInput"
|
|
453
|
+
/>
|
|
454
|
+
<!-- AM / PM toggle -->
|
|
455
|
+
<div
|
|
456
|
+
v-if="!use24h"
|
|
457
|
+
class="ml-2 flex h-20 flex-col overflow-hidden rounded-sm border border-outline"
|
|
458
|
+
>
|
|
459
|
+
<button
|
|
460
|
+
type="button"
|
|
461
|
+
class="flex flex-1 items-center justify-center px-3 text-title-medium transition-colors"
|
|
462
|
+
:class="
|
|
463
|
+
period === 'AM'
|
|
464
|
+
? 'bg-tertiary-container text-on-tertiary-container'
|
|
465
|
+
: 'text-on-surface-variant hover:bg-on-surface/8'
|
|
466
|
+
"
|
|
467
|
+
@click="period = 'AM'"
|
|
468
|
+
>{{ periods[0] }}</button>
|
|
469
|
+
<div class="h-px bg-outline" />
|
|
470
|
+
<button
|
|
471
|
+
type="button"
|
|
472
|
+
class="flex flex-1 items-center justify-center px-3 text-title-medium transition-colors"
|
|
473
|
+
:class="
|
|
474
|
+
period === 'PM'
|
|
475
|
+
? 'bg-tertiary-container text-on-tertiary-container'
|
|
476
|
+
: 'text-on-surface-variant hover:bg-on-surface/8'
|
|
477
|
+
"
|
|
478
|
+
@click="period = 'PM'"
|
|
479
|
+
>{{ periods[1] }}</button>
|
|
480
|
+
</div>
|
|
481
|
+
</div>
|
|
482
|
+
|
|
483
|
+
<!-- Footer -->
|
|
484
|
+
<div class="mt-2 flex items-center justify-between">
|
|
485
|
+
<MIconButton
|
|
486
|
+
:icon="toggleIcon"
|
|
487
|
+
:label="toggleLabel"
|
|
488
|
+
@click="inputMode = inputMode === 'input' ? mode : 'input'"
|
|
489
|
+
/>
|
|
490
|
+
<div class="flex gap-2">
|
|
491
|
+
<MButton variant="text" @click="cancel">{{ locale.cancel }}</MButton>
|
|
492
|
+
<MButton variant="text" @click="confirm">{{ locale.ok }}</MButton>
|
|
493
|
+
</div>
|
|
494
|
+
</div>
|
|
495
|
+
</div>
|
|
496
|
+
</MDialog>
|
|
497
|
+
</template>
|