diff --git a/playground/App.vue b/playground/App.vue
index 290a89c..0faf946 100644
--- a/playground/App.vue
+++ b/playground/App.vue
@@ -1,10 +1,14 @@
+ {{date.toDateString()}}
-
+
diff --git a/playground/index.scss b/playground/index.scss
index 2c7be10..bc016ef 100644
--- a/playground/index.scss
+++ b/playground/index.scss
@@ -5,6 +5,8 @@ body {
width: 100vw;
height: 100vh;
display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
justify-content: center;
align-items: center;
}
diff --git a/src/components/SingleDatePicker.vue b/src/components/SingleDatePicker.vue
index 76b32ba..55d9a85 100644
--- a/src/components/SingleDatePicker.vue
+++ b/src/components/SingleDatePicker.vue
@@ -28,9 +28,14 @@
localization: {
type: String,
required: false,
+ },
+ modelValue: {
+ type: Date,
+ required: false,
}
})
+ const emit = defineEmits(['update:modelValue'])
const selectMonth = ref(false)
const uniqueId = generateUniqueId()
const currentMonth = ref(new Date().getMonth())
@@ -51,6 +56,14 @@
onMounted(() => {
applyColor(uniqueId, colorScheme.value)
l10nDays.value = getL10Weekday(localization?.value || navigator.languages[0])
+
+ if (props.modelValue) {
+ currentMonth.value = props.modelValue.getMonth()
+ currentYear.value = props.modelValue.getFullYear()
+ } else {
+ currentMonth.value = new Date().getMonth()
+ currentYear.value = new Date().getFullYear()
+ }
dates.value = getCalendarDates(currentMonth.value, currentYear.value)
})
@@ -79,6 +92,7 @@
function selectDate(date: Date) {
console.log(date)
+ emit('update:modelValue', date)
}
@@ -97,10 +111,10 @@