0.0.4 • Published 2 years ago

awesome-datepicker-vue-3 v0.0.4

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

NOTE: This package was modified from icehaunter original vue3-datepicker for support current date styling.

Vue 3 Datepicker

Documentation: https://icehaunter.github.io/vue3-datepicker/

This is a basic (at least for now) reimplementation of https://github.com/icehaunter/vuejs-datepicker in Vue 3 and with greatly cleaned up code.

All date manipulation and formatting are done via the amazing date-fns library, so it's a direct dependency of this picker.

Installation

Package is available on NPM: https://www.npmjs.com/package/vue3-datepicker

npm i vue3-datepicker

The component is packaged mainly for use with bundlers, if you require a browser build - post an issue.

Usage

For more examples see https://icehaunter.github.io/vue3-datepicker/examples.html

<template>
  <datepicker
    v-model="selected"
    :locale="locale"
    :upperLimit="to"
    :lowerLimit="from"
    :clearable="true"
  />
</template>

Props and attributes

Attribute fallthrough is enabled, so any attribute you apply to the component will be passed down to the input.

All props which accept formatting strings for dates use date-fns formatting function under the hood, so see that function's documentation for patterns.

Main interaction to date selection is done via v-model with Date as expected type of the value passed.

Full props documentation is available at https://icehaunter.github.io/vue3-datepicker/config.html#props

IDTypeDefaultDescription
upperLimitDateUpper limit for available dates for picking
lowerLimitDateLower limit for available dates for picking
disabledDates{ dates: Date[] }Dates not available for picking
disabledTime{ dates: Date[] }Dates not available for time picking
startingView'time' \| 'day' \| 'month' \| 'year''day'View on which the date picker should open. Can be either year, month, or day
minimumView'time' \| 'day' \| 'month' \| 'year''day'If set, lower-level views won't show
monthHeadingFormatStringLLLL yyyydate-fns-type formatting for a month view heading
weekdayFormatStringEEdate-fns-type formatting for a line of weekdays on day view
inputFormatStringyyyy-MM-dddate-fns-type format in which the string in the input should be both parsed and displayed
localeLocaledate-fns/locale/endate-fns locale object. Used in string formatting (see default monthHeadingFormat)
disabledBooleanfalseDisables datepicker and prevents it's opening
typeableBooleanfalseAllows user to input date manually
weekStartsOnNumber1Day on which the week should start. Number from 0 to 6, where 0 is Sunday and 6 is Saturday. Week starts with a Monday (1) by default
clearableBooleanfalseAllows clearing the selected date and setting the value to null

Compatibility

Package is transpiled and should be usable for everyone with ES6 and above, but the styling of the datepicker itself uses CSS Grid and CSS variables.

Example

<template>
  <datepicker v-model="picked" />
</template>


<script>
import Datepicker from '../src/datepicker/Datepicker.vue'
components: {
  Datepicker
},
data(): {
  return {
    picked: new Date();
  }
}
</script>