π An easier datePicker in Vue.js π
https://github.com/joffreyBerrier/vue-datepicker/projects/1
π₯ Vue3 + Typescript + Tailwind + HeroIcon π₯
Open this link on a new tab
Install the package:
npm install vue-calendar-3 --save
yarn add vue-calendar-3
import { Calendar } from "vue-calendar-3";
// If you using vite
import "vue-calendar-3/style";
// If you not
import "vue-calendar-3/dist/library.css";
export default {
components: {
Calendar,
},
};
<Calendar />
DatenullExemple : v-model:checkIn=""
DatenullExemple : v-model:checkOut=""
Object as PropType<BookingColor>{}Allows you to define colors for your bookings, the name of the key must be equal to your type key in the booking object
Exemple:
bookedDates: {
admin: "#9dc1c9",
contract: "#a56a0b",
};
Array as PropType<string[]>[]Allows you to define a date range (Booking)
Exemple:
bookingDates: [
{
checkInDate: "2022-07-01",
checkOutDate: "2022-07-10",
type: "admin",
},
{
checkInDate: "2022-08-01",
checkOutDate: "2022-08-20",
type: "contract",
},
];
BooleantrueDisabled days before the current date
Datenew Date(new Date().getFullYear() - 2, 0, 1)Define the first Date in your calendar
Datenew Date(new Date().getFullYear() + 2, 0, 1)Define the last Date in your calendar
StringYYYY-MM-DDDefine the format of your date
Object as PropType<Placeholder>{ checkIn: "ArrivΓ©e", checkOut: "DΓ©part", }Define the text of you input calendar
Booleanfalseshow the calendar in year mode
Booleanfalsehide / show the input calendar
string[][]This data is an array of your booked dates, the date is already booked is appear it in disabled
Exemple:
bookedDates: [
"2021-06-01",
"2021-06-02",
"2021-06-03",
"2021-06-23",
"2021-06-24",
"2021-06-25",
];
Array[]This data is an array of object of your periods
Corresponds to the start of your periods with the format YYYY-MM-DD
Corresponds to the start of your periods with the format YYYY-MM-DD
undefinedEach period correspond to different logic define by periodType and minimumDurationundefined
nightly, weekly_by_saturday or weekly_by_sundayCorresponds to the number of the days where you want to block the period.
If the periodType is nightly the count corresponds the number of days
If the periodType is weekly_by_saturday or weekly_by_sunday the count corresponds to the number of weeks
Exemple:
periodDates: [
// Nightly
{
startAt: "2021-08-01",
endAt: "2021-08-31",
minimumDuration: 4,
periodType: "nightly",
},
// Weekly Saturday
{
startAt: "2021-09-01",
endAt: "2021-09-30",
minimumDuration: 2,
periodType: "weekly_by_saturday",
},
// Weekly Sunday
{
startAt: "2021-11-01",
endAt: "2021-11-29",
minimumDuration: 1,
periodType: "weekly_by_sunday",
},
];
@renderNextMonth : fires when the user clicks on paginate
bookedDates: [
'2021-06-01',
'2021-06-02',
'2021-06-03',
'2021-06-23',
'2021-06-24',
'2021-06-25',
] as string[],
periodDates: [
{
startAt: '2021-07-01',
endAt: '2021-08-31',
minimumDuration: 4,
periodType: 'nightly',
},
{
startAt: '2021-09-01',
endAt: '2021-09-30',
minimumDuration: 2,
periodType: 'weekly_by_saturday',
},
{
startAt: '2021-10-01',
endAt: '2021-10-30',
minimumDuration: 4,
periodType: 'nightly',
},
{
startAt: '2021-11-01',
endAt: '2021-11-29',
minimumDuration: 1,
periodType: 'weekly_by_sunday',
},
] as Period[],
checkIn: null,
checkOut: null,
npm i