Skip to content

Commit c270fe1

Browse files
committed
docs: Fix examples for disabled-dates and allowed-dates (fixes #1171)
1 parent 8680cdf commit c270fe1

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

docs/props/validation/index.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@ To have a better control of the `range` validation, you can provide an array con
144144
::: details Code Example
145145
```vue
146146
<template>
147-
<VueDatePicker v-model="date" :max-time="{ hours: 11, minutes: 30 }" :disabled-times="disabledTimes" />
147+
<VueDatePicker
148+
v-model="date"
149+
:max-time="{ hours: 11, minutes: 30 }"
150+
:disabled-times="disabledTimes"
151+
/>
148152
</template>
149153

150154
<script setup>
@@ -174,25 +178,25 @@ Disable specific dates
174178
If you use a custom function, make sure to return `true` for a disabled date and `false` for enabled
175179
:::
176180

177-
<GlobalDemo :dates="[new Date()]" :emptyModel="true"></GlobalDemo>
181+
<GlobalDemo :disabledDates="disabledDates" :emptyModel="true"></GlobalDemo>
178182

179183
::: details Code Example
180184
```vue
181185
<template>
182-
<VueDatePicker v-model="date" :max-time="{ hours: 11, minutes: 30 }" :disabled-times="disabledTimes" />
186+
<VueDatePicker v-model="date" :disabled-dates="disabledDates" />
183187
</template>
184188
185189
<script setup>
186190
import { VueDatePicker } from "@vuepic/vue-datepicker";
191+
import { addDays } from 'date-fns';
187192
import { ref } from 'vue';
188193
189194
const date = ref();
190195
191196
const disabledDates = [
192-
{ hours: 15, minutes: '*' }, // disable full hour
193-
{ hours: 16, minutes: 15 },
194-
{ hours: 16, minutes: 20 },
195-
{ hours: 17, minutes: 30 },
197+
new Date(),
198+
addDays(new Date(), 1),
199+
addDays(new Date(), 2),
196200
];
197201
</script>
198202
```
@@ -205,25 +209,25 @@ Allow only specific dates
205209
- Type: `string[] | Date[] | number[]`
206210
- Default: `[]`
207211

208-
<GlobalDemo :dates="[new Date()]" :emptyModel="true"></GlobalDemo>
212+
<GlobalDemo :allowedDates="disabledDates" :emptyModel="true"></GlobalDemo>
209213

210214
::: details Code Example
211215
```vue
212216
<template>
213-
<VueDatePicker v-model="date" :max-time="{ hours: 11, minutes: 30 }" :disabled-times="disabledTimes" />
217+
<VueDatePicker v-model="date" :allowed-dates="allowedDates" />
214218
</template>
215219
216220
<script setup>
217221
import { VueDatePicker } from "@vuepic/vue-datepicker";
222+
import { addDays } from 'date-fns';
218223
import { ref } from 'vue';
219224
220225
const date = ref();
221226
222-
const disabledDates = [
223-
{ hours: 15, minutes: '*' }, // disable full hour
224-
{ hours: 16, minutes: 15 },
225-
{ hours: 16, minutes: 20 },
226-
{ hours: 17, minutes: 30 },
227+
const allowedDates = [
228+
new Date(),
229+
addDays(new Date(), 1),
230+
addDays(new Date(), 2),
227231
];
228232
</script>
229233
```
@@ -299,8 +303,14 @@ Prevent navigation after or before the [`min-date`](#min-date) or [`max-date`](#
299303
```
300304

301305
<script setup>
302-
import { addMonths, subMonths } from 'date-fns';
306+
import { addMonths, subMonths, addDays } from 'date-fns';
303307

304308
const minDate = subMonths(new Date(), 2);
305309
const maxDate = addMonths(new Date(), 2);
310+
311+
const disabledDates = [
312+
new Date(),
313+
addDays(new Date(), 1),
314+
addDays(new Date(), 2),
315+
];
306316
</script>

0 commit comments

Comments
 (0)