npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vanilla-calendar-picker

v2.11.9

Published

Vanilla Calendar is a versatile JavaScript date and time picker with TypeScript support, making it compatible with any JavaScript framework or library. It is designed to be lightweight, simple to use, and feature-rich without relying on external dependenc

Downloads

1,747

Readme

VanillaCalendar - A Lightweight, Feature-Rich JavaScript Date and Time Picker

[!NOTE]

Forked from Vanilla-Calendar-Pro

This is a fork of the Vanilla-Calendar-Pro project with a few differences as described below (see Changes vs Original project). The hope would be to switch back to the original project once all these changes are merged into the original library.

Changes vs Original project

  • now merged into original project
    • add new jumpToSelectedDate to automatically jump the calendar to the selected date.
    • add new toggleSelected to prevent date from being unselected (clicking twice).
    • add new sanitizer callback option for CSP compliance.
    • allow passing today as min/max date.
    • allow supplying Date and/or epoch timestamp (number) in addition to ISO date strings.
    • add new auto option to positionToInput to automatically position picker with available space.
    • add new selectedDates.edgesOnly to only return start/end dates of date range
  • not yet in original project
    • add new changeSetting() function to be able to change a single setting (I might remove this one, not using it myself)
    • add Type descriptions for better intelliSense

vanilla-calendar preview

version tests downloads

VanillaCalendar is a versatile JavaScript date and time picker with TypeScript support, making it compatible with any JavaScript framework or library. It is designed to be lightweight, simple to use, and feature-rich without relying on external dependencies.

Key Features

  • Lightweight: The final minified .js file is only approximately 37.3 KB, and with gzip compression, it's just around 9.9 KB.
  • No Dependencies: VanillaCalendar is entirely self-contained, ensuring you don't need to include additional libraries.
  • Simple Localization: Supports simple localization for any language.
  • Customizable: Can be easily configured using CSS and HTML markup.
  • Multiple Instances: Allows for an unlimited number of calendar instances on a single page.
  • Theme Support: Includes two themes - the light theme and the dark theme.
  • Week Start Customization: Supports both Sunday and Monday as the beginning of the week.
  • Week Number Display: Can display week numbers throughout the year.
  • Not Tied to Input Tags: Unlike many date pickers, it's not limited to the <input> tag.

Browser Support

VanillaCalendar is compatible with a wide range of browsers:

Chrome | Firefox | Edge | Opera | Safari --- | --- | --- | --- | --- | 57+ ✔ | 52+ ✔ | 80+ ✔ | 44+ ✔ | 10.1+ ✔ |

Support and Feedback

This plugin is completely free, and your support is important. Please feel free to report any issues or share your new ideas; it's really important!

If you like VanillaCalendar, please consider giving it a 🌟 star on GitHub.

Getting Started

Installation

You can install VanillaCalendar using npm or yarn:

npm install vanilla-calendar-picker
# or
yarn add vanilla-calendar-picker

If you prefer not to use a package manager, you can also include it via CDN or download it from the website.

Usage

Here's a simple example of how to use VanillaCalendar in your HTML:

<html>
  <head>
  </head>
  <body>
    <div id="calendar"></div>
    <!-- or -->
    <!-- <input type="text" id="calendar-input"> -->
  </body>
</html>

To add the necessary styles and scripts, you can use the following code:

import { VanillaCalendar } from 'vanilla-calendar-picker';
import 'vanilla-calendar-picker/build/vanilla-calendar.min.css';

// Initialize the calendar
const calendar = new VanillaCalendar('#calendar');
calendar.init();
// or
// const calendarWithInput = new VanillaCalendar('#calendar-input', { input: true });
// calendarWithInput.init();

If you're not using a package manager and prefer manual installation or CDN usage, you can include the necessary files in your HTML document's <head>:

<html>
  <head>
    <link href="./vanilla-calendar.min.css" rel="stylesheet">
    <script src="./vanilla-calendar.min.js" defer></script>
  </head>
  <body>
    <div id="calendar"></div>

    <script>
      document.addEventListener('DOMContentLoaded', () => {
        const calendar = new VanillaCalendar('#calendar');
        calendar.init();
      });
    </script>
  </body>
</html>

CSS Themes

// Only layout calendar
import 'vanilla-calendar-picker/build/vanilla-calendar.layout.min.css';

// Themes
import 'vanilla-calendar-picker/build/themes/light.min.css';
import 'vanilla-calendar-picker/build/themes/dark.min.css';

VanillaCalendar includes two CSS themes: the light theme and the dark theme.

  • The vanilla-calendar.min.css file contains all styles with all themes.
  • The vanilla-calendar.layout.min.css file contains the essential structural styles for the calendar.
  • The themes/light.min.css theme provides a light color scheme.
  • The themes/dark.min.css theme offers a dark color scheme.

The calendar will automatically display the theme according to the user's system preferences. If you want to apply a specific theme, it is recommended to import «vanilla-calendar.layout.min.css» along with the theme you prefer: «light.min.css» or «dark.min.css», instead of «vanilla-calendar.min.css».

DOM Templates

VanillaCalendar features customizable DOM templates that allow you to modify the structure of the calendar to fit your needs. The templates are identified by tags containing the # character, and they should include a trailing slash at the end.

Here's an example of the default template:

new VanillaCalendar('#calendar', {
  DOMTemplates: {
    default: `
      <div class="vanilla-calendar-header">
        <#ArrowPrev />
        <div class="vanilla-calendar-header__content">
          <#Month />
          <#Year />
        </div>
        <#ArrowNext />
      </div>
      <div class="vanilla-calendar-wrapper">
        <#WeekNumbers />
        <div class "vanilla-calendar-content">
          <#Week />
          <#Days />
        </div>
      </div>
      <#ControlTime />
    `
  }
});

React Component

For detailed instructions on using VanillaCalendar in a React component with TypeScript, please visit the website for comprehensive documentation and examples.

API Reference

For detailed information on the available parameters and settings, please refer to the API reference.

Sponsor

This project is tested with BrowserStack.

License

MIT License

Author

Yury Uvarov ([email protected])