Giter Site home page Giter Site logo

itzvinoth / vue3-datepicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from icehaunter/vue3-datepicker

0.0 0.0 0.0 1.09 MB

Simple datepicker component for Vue 3

Home Page: https://icehaunter.github.io/vue3-datepicker/

License: MIT License

JavaScript 3.11% TypeScript 0.50% CSS 0.51% HTML 0.84% Vue 95.05%

vue3-datepicker's Introduction

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

ID Type Default Description
upperLimit Date Upper limit for available dates for picking
lowerLimit Date Lower 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
dayPickerHeadingFormat String LLLL yyyy date-fns-type formatting for a month view heading
weekdayFormat String EE date-fns-type formatting for a line of weekdays on day view
inputFormat String yyyy-MM-dd date-fns-type format in which the string in the input should be both parsed and displayed
locale Locale date-fns/locale/en date-fns locale object. Used in string formatting (see default dayPickerHeadingFormat)
disabled Boolean false Disables datepicker and prevents it's opening
typeable Boolean false Allows user to input date manually
weekStartsOn Number 1 Day 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
clearable Boolean false Allows clearing the selected date and setting the value to null
allowOutsideInterval Boolean false Allows user to click dates outside of current interval

Events

  • opened: Emitted every time the popup opens, including on field focus
  • closed: Emitted every time the popup closes, including on field blur

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>

vue3-datepicker's People

Contributors

icehaunter avatar bttlvd avatar aaqibqadeer avatar jagadeshanh avatar khems avatar robbevp avatar okame avatar smoakey avatar domohh avatar juhyeong-kim avatar ondrabus avatar zulfio avatar thrugl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.