|
|
@@ -7,11 +7,9 @@ Sélecteur de dates avec Vuetify
|
|
|
<template>
|
|
|
<v-layout row wrap>
|
|
|
<v-menu
|
|
|
- ref="menu"
|
|
|
v-model="menu"
|
|
|
:close-on-content-click="false"
|
|
|
:nudge-right="40"
|
|
|
- :return-value.sync="modelValue"
|
|
|
lazy
|
|
|
transition="scale-transition"
|
|
|
offset-y
|
|
|
@@ -20,58 +18,40 @@ Sélecteur de dates avec Vuetify
|
|
|
:position-x="positionX"
|
|
|
:position-y="positionY"
|
|
|
>
|
|
|
- <template v-slot:activator="{ on, attrs }">
|
|
|
+ <template #activator="{ props: attrs }">
|
|
|
<v-text-field
|
|
|
v-model="displayDate"
|
|
|
:label="label"
|
|
|
- :readonly="readOnly"
|
|
|
+ :readonly="true"
|
|
|
v-bind="attrs"
|
|
|
- v-on="on"
|
|
|
- @blur="menu = false"
|
|
|
- ></v-text-field>
|
|
|
+ />
|
|
|
</template>
|
|
|
+
|
|
|
<v-date-picker
|
|
|
- v-if="!withTime"
|
|
|
:model-value="modelValue"
|
|
|
:locale="i18n.locale.value"
|
|
|
- @update:model-value="updateDate"
|
|
|
no-title
|
|
|
scrollable
|
|
|
- >
|
|
|
- </v-date-picker>
|
|
|
- <v-date-picker
|
|
|
- v-else
|
|
|
- :model-value="modelValue"
|
|
|
- :locale="i18n.locale.value"
|
|
|
@update:model-value="updateDate"
|
|
|
- no-title
|
|
|
- scrollable
|
|
|
- type="datetime"
|
|
|
- >
|
|
|
- </v-date-picker>
|
|
|
+ />
|
|
|
</v-menu>
|
|
|
</v-layout>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, computed, nextTick, watch } from 'vue'
|
|
|
+import { ref, computed, nextTick, watch, type PropType } from 'vue'
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
|
const props = defineProps({
|
|
|
modelValue: Date,
|
|
|
- label: String,
|
|
|
- readOnly: {
|
|
|
- type: Boolean,
|
|
|
- default: false,
|
|
|
+ label: {
|
|
|
+ type: String,
|
|
|
+ default: '',
|
|
|
},
|
|
|
format: {
|
|
|
type: String,
|
|
|
default: null,
|
|
|
},
|
|
|
- withTime: {
|
|
|
- type: Boolean,
|
|
|
- default: false,
|
|
|
- },
|
|
|
/**
|
|
|
* Position du date-picker
|
|
|
* @see https://vuetifyjs.com/en/api/v-menu/#props-position
|
|
|
@@ -106,7 +86,7 @@ const displayDate = computed({
|
|
|
set: () => {},
|
|
|
})
|
|
|
|
|
|
-function updateDate(value) {
|
|
|
+function updateDate(value: Date) {
|
|
|
emit('update:modelValue', value)
|
|
|
menu.value = false
|
|
|
}
|