feat : update modal style
This commit is contained in:
@@ -31,7 +31,7 @@ const mountDateTime = (props: DateTimeProps = {}) =>
|
||||
describe('MalioDateTime', () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers()
|
||||
vi.setSystemTime(new Date(2026, 4, 19)) // 19 mai 2026
|
||||
vi.setSystemTime(new Date(2026, 4, 19, 9, 5, 0)) // 19 mai 2026, 09:05
|
||||
})
|
||||
afterEach(() => vi.useRealTimers())
|
||||
|
||||
@@ -60,11 +60,12 @@ describe('MalioDateTime', () => {
|
||||
})
|
||||
|
||||
describe('sélection', () => {
|
||||
it('émet le jour à 00:00 et garde le popover ouvert', async () => {
|
||||
it('émet le jour à l\'heure actuelle (si aucune heure choisie) et garde le popover ouvert', async () => {
|
||||
const wrapper = mountDateTime()
|
||||
await wrapper.get('[data-test="date-input"]').trigger('click')
|
||||
await wrapper.get('[data-test="day"][data-iso="2026-05-19"]').trigger('click')
|
||||
expect(wrapper.emitted('update:modelValue')?.at(-1)).toEqual(['2026-05-19T00:00:00'])
|
||||
// heure système figée à 09:05
|
||||
expect(wrapper.emitted('update:modelValue')?.at(-1)).toEqual(['2026-05-19T09:05:00'])
|
||||
expect(wrapper.find('[data-test="popover"]').exists()).toBe(true)
|
||||
})
|
||||
|
||||
|
||||
@@ -28,10 +28,12 @@
|
||||
:max="max?.slice(0, 10)"
|
||||
@select="onSelectDay"
|
||||
/>
|
||||
<div class="mt-[26px]">
|
||||
<div class="mt-4">
|
||||
<MalioTimePicker
|
||||
:model-value="timeValue || null"
|
||||
label="Heure"
|
||||
:clearable="false"
|
||||
static-popover
|
||||
@update:model-value="onTimeChange"
|
||||
/>
|
||||
</div>
|
||||
@@ -44,6 +46,7 @@ import {computed, ref, watch} from 'vue'
|
||||
import CalendarField from './internal/CalendarField.vue'
|
||||
import MonthGrid from './internal/MonthGrid.vue'
|
||||
import MalioTimePicker from '../time/TimePicker.vue'
|
||||
import {formatTime} from '../time/composables/timeFormat'
|
||||
import {composeDateTime, formatIsoDateTimeToDisplay, isValidIsoDateTime, splitDateTime} from './composables/datetimeFormat'
|
||||
|
||||
defineOptions({name: 'MalioDateTime', inheritAttrs: false})
|
||||
@@ -100,7 +103,10 @@ const displayValue = computed(() => formatIsoDateTimeToDisplay(props.modelValue
|
||||
const timeValue = computed(() => parts.value.time || pendingTime.value)
|
||||
|
||||
function onSelectDay(iso: string) {
|
||||
const time = parts.value.time || pendingTime.value || '00:00'
|
||||
// Si aucune heure n'a été choisie, on prend l'heure actuelle (pas 00:00).
|
||||
// (heure courante au moment du clic)
|
||||
const now = new Date()
|
||||
const time = parts.value.time || pendingTime.value || formatTime(now.getHours(), now.getMinutes())
|
||||
emit('update:modelValue', composeDateTime(iso, time))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user