2.0.4 • Published 5 years ago

@pderas/vue2-date-selector v2.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Vue Date Selector

A collection of vue 2 components for selecting a date. <date-selector> provides 3 input boxes for an easy way to select the day, month, and year. <calendar-picker> displays a calendar to select an individual date, or a start and end date.

How to initialize Vue Date Selector

Vue date selector is built as a vue plugin. It can be initialized just as the Vue documentation states.

import DateSelector from "@pderas/vue2-date-selector";

// this provides access to both <date-selector /> and <calendar-picker /> components globally
Vue.use(DateSelector);

Usage

<date-selector /> Creation

Vue date selector is easily created, and has many properties that can be changed.

<date-selector></date-selector>

<date-selector /> Properties

PropertyRequiredTypeDefaultDescription
valuefalseString|DateDate()Value for the input, can be used with v-model
formatFnfalseFunction(value) => {return value }Formats the labels based on the function provided
amountOfYearsfalseNumber20The amount of years to show in the date selector, from the current year
amountOfYearsAfterfalseNumber0The amount of years to show in the date selector, from after the current year
disabledfalseObjectnullSpecifies dates to disable from being selected in the picker
disabledInputfalseBooleanfalseDisables the inputs on the date selector

Disabled Dates

The disabled object contains two potential keys for disabling ranges of dates.

  • to This is used for disabling dates up to a specific date.
  • from This is used for disabled dates after a specific date.

Currently only to or from can be used separately. They cannot be used together. The value can be either a valid date string or a date object.

Styling

Styling is currently limited, but can be expanded in the future.

<calendar-picker /> Creation

Vue calendar picker is easily created, and has many properties that can be changed.

<calendar-picker v-model='dates' />

<calendar-picker /> Properties

PropertyRequiredTypeDefaultDescription
valuetrueObject--passed in the form of either { day: null } for single date picking, or { start: null, end: null } for multi day picking
monthfalseNumbernew Date().getMonth() + 1ones based month to be displayed (Jan = 1, Dec = 12)
yearfalseNumbernew Date().getFullYear()year to be displayed
multiDaySelectfalseBooleanTrueAllow either single, or multi day selection
nextfalseStringNextstring to be displayed for next month button
prevfalseStringPrevstring to be displayed for previous month button
highlightedfalseObject{}days that should be highlighted on load. can include tooltip information to be displayed on hover. should be passed in the format { [dd-MM-yyyy]: { name: 'My Tooltip Info' }}. for example:
{
    "28-09-2018": {
        name: "last friday in september"
    },
    "01-10-2018": {
        name: "first monday in october"
    }
}

Misc

Instead of providing a value prop, v-model can be used to make use of two way data binding. Similarly, the month and year props can be bound using the .sync modifier.

<!-- sync example -->
<calendar-picker
    v-model='selectedDates'
    :month.sync='month'
    :year.sync='year' />

Styling

All elements are namespaced starting with .cal and are written at the root level for the easiest customization. The calendar will grow/shrink width in relation to the surrounding div, and the squares height can be easily overwritten using .cal-day { height: 50px; }. The most common styles to be overridden are likely to be the background colors of: .cal-header, .cal-inactive, .cal-today, .cal-highlighted, .cal-clicked, .cal-faded.

calendar-picker component

License

This project is covered under the MIT License. Feel free to use it wherever you like.

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

6 years ago

1.4.0

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago