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 🙏

© 2025 – Pkg Stats / Ryan Hefner

time-selector-plugin

v1.1.0

Published

A lightweight and customizable time selector plugin with multi-language support and intuitive drag-and-drop functionality.

Downloads

12

Readme

Time Selector Plugin

简体中文 | English

Introduction

Time Selector Plugin is a lightweight, customizable time slot selector designed for scenarios where users need to select specific date and time ranges. It provides intuitive drag-and-drop selection, supports multiple languages, and can be easily integrated into any web project.

Time Selector Demo

Features

  • Intuitive Drag-and-Drop Selection: Users can easily select time slots by dragging with a mouse or touch gestures.
  • Multi-language Support: Built-in Chinese and English, with support for custom language configurations.
  • Flexible API: Provides a rich set of APIs for getting, setting, clearing, and inverting time slot selections.
  • Event Listening: Supports select and clear events for easy integration with business logic.
  • Lightweight: No external dependencies, easy to integrate.

Installation

Via npm

npm install time-selector-plugin

Via CDN

<script src="https://unpkg.com/time-selector-plugin/dist/time-selector-plugin.umd.js"></script>

Usage

HTML Structure

<div id="time-selector"></div>

JavaScript Initialization

import TimeSelector from 'time-selector-plugin';

const container = document.getElementById("time-selector");
const timeSelector = new TimeSelector(container, {
    language: 'en-US' // or 'zh-CN', defaults to 'zh-CN'
});

Configuration Options

| Option | Type | Default Value | Description | | -------- | -------- | -------- | ----------------------------------------- | | language | string | 'zh-CN' | Sets the display language of the plugin, can be 'zh-CN' or 'en-US'. |

Event Listening

The plugin supports select and clear events.

timeSelector.on("select", (selectedSlots) => {
    console.log("Selected Time Slots:", selectedSlots);
    // selectedSlots format example: [{ day: 0, time: 16 }, { day: 0, time: 17 }]
});

timeSelector.on("clear", () => {
    console.log("Time slots cleared");
});

API Reference

| Method | Description | | -------------------- | ----------------------------------------------- | | reverseSelection() | Inverts the selection of all currently selected time slots. | | getAllSelectedSlots() | Retrieves all selected time slots. Returns an array, where each element contains day (day index, 0-6) and time (time index, 0-47, representing half-hour intervals). | | clearAllSelectedSlots() | Clears all selected time slots. | | selectRow(rowIndex) | Selects or deselects a specific row (day). rowIndex is 0-6. | | selectCol(colIndex) | Selects or deselects a specific column (half-hour interval). colIndex is 0-47. | | selectHalfDay(after) | Selects or deselects the first half of the day (00:00-12:00) or the second half (12:00-24:00). after is true for the second half, false for the first half. | | selectAll() | Selects or deselects all time slots. | | on(event, handler) | Registers an event listener. | | off() | Removes all event listeners. |

Contributing

Contributions are welcome! If you have any suggestions or find bugs, please submit an issue or pull request.

License

This project is licensed under the MIT License.