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 🙏

© 2026 – Pkg Stats / Ryan Hefner

imx-select-datepicker

v0.0.4

Published

A simple keyboard accessible select based datepicker

Readme

imx-select-datepicker

A component for handling date selection via select elements for day and month. The component can be used as a single date picker or as a range date picker.

SelectDatepicker

A component for managing date inputs with support for single date and date range modes. If no date is explicitly set via setDate(), the component defaults to the first day of the first month in the available options range.

Constructor

import { SelectDatepicker } from 'imx-select-datepicker';

const selectDatepicker = new SelectDatepicker(config);

Parameters:

  • config (Object) - Configuration object
    • mode (String) - Mode of the component: 'single' for single date or 'range' for date range
    • availableOptions (Object, optional)
      • start (Date, optional) - start date for the range of the day/month options - works only in monthly precision (defaults to today)
      • end (Date, optional) - end date for the range of the day/month options - works only in monthly precision (defaults to one year from now)
    • onChange (Function, optional) - Callback function that is called when the date changes - provides the selected date(s) as an array of ISO date strings (YYYY-MM-DD) and the instance of the component as parameters

Usage

Single Date Mode

const selectDatepicker = new SelectDatepicker({
    mode: 'single',
    availableOptions: {
        start: new Date('2026-01-01'),
        end: new Date('2026-12-31')
    },
    onChange: (dates, instance) => {
        console.log('Selected date:', dates);
    }
});

document.getElementById('datepicker').appendChild(selectDatepicker.getMarkup());

Date Range Mode

const selectDatepicker = new SelectDatepicker({
    mode: 'range',
    availableOptions: {
        start: new Date('2026-01-01'),
        end: new Date('2026-12-31')
    },
    onChange: (dates, instance) => {
        console.log('From:', dates[0], 'To:', dates[1]);
    }
});

document.getElementById('datepicker').appendChild(selectDatepicker.getMarkup());

Methods

getMarkup()

Returns the DOM element of the component that can be inserted into the document.

Returns: DOM Element

setDate(date)

Sets the date(s) of the component.

Parameters:

  • date (Date | Array<Date>) - A single date or an array with two dates for the date range
// Single date
selectDatepicker.setDate(new Date('2026-06-15'));

// Date range
selectDatepicker.setDate([
    new Date('2026-06-01'),
    new Date('2026-06-30')
]);

setMinDate(date)

Sets the minimal selectable (non disabled) date.

Parameters:

  • date (Date) - A single date.

getDate()

Returns the currently selected dates.

Returns: Array<String> - Array with one or two ISO date strings (YYYY-MM-DD)

const selectedDates = selectDatepicker.getDate();
console.log(selectedDates); // ['2026-06-01', '2026-06-30'] or ['2026-06-15']

Events

The component automatically calls the onChange callback function when the date selection changes:

const selectDatepicker = new SelectDatepicker({
    mode: 'range',
    onChange: (dates, instance) => {
        console.log('New start date:', dates[0]);
        console.log('New end date:', dates[1]);
        console.log(instance);
    }
});

InputGroup

A component for managing date inputs with separate controls for day, month, and year. If no date is explicitly set via setDate(), the component defaults to the first day of the month specified by startDate.

Constructor

import { InputGroup } from 'imx-select-datepicker';

const startDate = new Date('2026-01-01');
const endDate = new Date('2026-12-31');

const inputGroup = new InputGroup(startDate, endDate);

// or with default options
const inputGroupWithDefaultOptions = new InputGroup();

Parameters:

  • startDate (Date, optional) - start date for the range of the day/month options - works only in monthly precision (defaults to today)
  • endDate (Date, optional) - end date for the range of the day/month options - works only in monthly precision (defaults to one year from now)

Usage

const startDate = new Date('2026-01-01');
const endDate = new Date('2026-12-31');

const inputGroupFrom = new InputGroup(startDate, endDate);
document.getElementById('input-date').appendChild(inputGroupFrom.getMarkup());

const inputGroupTo = new InputGroup(startDate, endDate);
document.getElementById('input-date').appendChild(inputGroupTo.getMarkup());

inputGroupFrom.update(new Date('2026-01-01'));
inputGroupTo.update(new Date('2026-12-31'));

Properties

  • daySelect.select - Select element for day selection
  • monthSelect.select - Select element for month selection
  • yearSelect.select - Select element for year selection

Methods

getMarkup()

Returns the HTML markup for the input group to append it to the DOM.

Returns: DOM Element

getMonthSelect()

Returns the month select element for registering change listeners.

Returns: HTMLSelectElement

getDaySelect()

Returns the day select element for registering change listeners.

Returns: HTMLSelectElement

getValue()

Returns the currently selected date as a ISO date string (YYYY-MM-DD).

Returns: String

update(date)

Updates the input fields with a new date.

Parameters:

  • date (Date) - The new date

setMinDate(date)

Sets the minimum selectable date for the input fields.

Parameters:

  • date (Date) - The minimum date

Events

inputGroupFrom.getDaySelect().addEventListener('change', (event) => {
    const newDate = new Date(inputGroupFrom.getValue());
    console.log('New date:', newDate);
});

InputRange

A wrapper component that connects two InputGroup instances for date range selection. Unlike SelectDatepicker, you manage the InputGroups individually. The InputRange validates that the "from" date doesn't exceed the "to" date.

Constructor

import { InputGroup, InputRange } from 'imx-select-datepicker';

const startDate = new Date('2026-01-01');
const endDate = new Date('2026-12-31');

const inputGroupFrom = new InputGroup(startDate, endDate);
const inputGroupTo = new InputGroup(startDate, endDate);

const inputRange = new InputRange(inputGroupFrom, inputGroupTo);

Parameters:

  • inputGroupFrom (InputGroup) - The InputGroup selecting the from date of the range
  • inputGroupTo (InputGroup) - The InputGroup selecting the to date of the range

Usage Examples

Single Date Picker (using InputGroup only)

const startDate = new Date('2026-01-01');
const endDate = new Date('2026-12-31');

const inputGroup = new InputGroup(startDate, endDate);
document.getElementById('datepicker').appendChild(inputGroup.getMarkup());

inputGroup.update(new Date('2026-12-01'));

Range Date Picker

const startDate = new Date('2026-01-01');
const endDate = new Date('2026-12-31');

const inputGroupFrom = new InputGroup(startDate, endDate);
document.getElementById('datepicker-from').appendChild(inputGroupFrom.getMarkup());

const inputGroupTo = new InputGroup(startDate, endDate);
document.getElementById('datepicker-to').appendChild(inputGroupTo.getMarkup());

const inputRange = new InputRange(inputGroupFrom, inputGroupTo);

inputGroupFrom.update(new Date('2026-01-01'));
inputGroupTo.update(new Date('2026-12-31'));