Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

js-calendarspicker

mahmoudzohdi35MIT0.3.1

VanillaJS Calendar Picker

calendar, js calendar, calendar picker, js calendar picker, datepicker, date picker

readme

JS-CalendarsPicker

Demo Here

Installation

NPM

npm i js-calendarspicker

CDN

<script src="https://unpkg.com/js-calendarspicker"></script>

Usage


import JSCalendarsPicker from 'js-calendarspicker';

var elem = document.getElementById('calendar-input');

// create instance of a plugin
var instance = new JSCalendarsPicker(elem, {YOUR_OPTIONS_HERE});

// initialize
instance.init();

Options

format

You can use this option to customize the date format.

type: string default: 'DD/MM/YYYY'

supported tokens (case-sensitive):

Input Example Description
YYYY 2019 4 digit year
YY 19 2 digit year
M 1..12 month number
MM 01..12 2 digit month number
MMM Jan short month name
MMMM January full month name
D 1..31 day number
DD 01..31 2 digit day number

example:

new JSCalendarsPicker(elem, {
  format: 'DD-MM-YYYY'
});

defaultDate

You can use this option to init your calendar with default date

type: Date Object default: null

example:

new JSCalendarsPicker(elem, {
  defaultDate: new Date(2020, 8, 20)
});

Callback Events

onSelect

this event fired on day selection, returns the Date Object of the selected day

Usage:

new JSCalendarsPicker(elem, {
  onSelect: function(dateObject){
    alert(dateObject); // the selected day date object
  }
});

changelog

Changelog

All notable changes to this project will be documented in this file.

[0.3.0] - 2020-07-28

Added

  • add format option, now you can write your favorite format based on the supporte tokens
  • add defaultdate option, now you can init your calendarPicker with default date

    Fixed

  • fix selected day storing, it was losing if you navigate between months

[0.2.3] - 2020-07-25

Fixed

  • fix issue in hide calendar popup when click outside in Firefox

[0.2.1] - 2020-07-24

Changed

  • make the calendar popup hidden by default, and appear on input focus & hide on click outside the plugin wrapper
  • make the selected input readonly by default

Fixed

  • fix calendar popup width issue

[0.2.0] - 2020-07-19

Changed

  • make the plugin wotking on an input element not on div

Added

  • add onSelect callback event as an option

[0.1.1] - 2020-07-10

  • update the README.md file
  • enhance UI
  • fix plugin name typo

[0.1.0] - 2020-07-10

  • just introduce the idea
  • display month days
  • navigate between monthes