1.0.1 • Published 8 months ago

@dropdown-datepicker/core v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@dropdown-datepicker/core

The framework-agnostic core logic for building a customizable dropdown-style datepicker. This package provides utilities and types to handle date selection via day, month, and year dropdowns — making it easy to integrate into any UI framework (React, Vue, Svelte, etc.).


✨ Features

  • šŸ“… Dropdown selection for day, month, and year
  • šŸ“¦ Framework-agnostic, pure TypeScript logic
  • 🧠 Intelligent handling of leap years and varying month lengths
  • šŸ”§ Designed for use in component libraries or design systems
  • 🪶 Lightweight dependency on dayjs

šŸ“¦ Installation

npm install @dropdown-datepicker/core
# or
pnpm add @dropdown-datepicker/core
# or
yarn add @dropdown-datepicker/core

šŸ› ļø Usage Example

import {
    generateDays,
    generateMonths,
    generateYears,
    isValidDate,
} from "@dropdown-datepicker/core";

// Generate options
const days = generateDays(2025, 4); // April 2025
const months = generateMonths(); // January to December
const years = generateYears({ from: 1900, to: 2100 });

// Validate date
const isValid = isValidDate({ day: 31, month: 4, year: 2025 }); // false (April has 30 days)

šŸ“š API Reference

generateDays(year: number, month: number): number[]

Returns the valid days for the given month and year.

generateMonths(): { label: string; value: number; }[]

Returns all months as label/value pairs (e.g., January → 1).

generateYears(options: { from: number; to: number }): number[]

Returns an array of years between the from and to values.

isValidDate({ day, month, year }): boolean

Checks whether the given date is valid (e.g., 31 Feb is invalid).


šŸ› Found a bug? Report it here

šŸ”— Related


šŸ§‘ā€šŸ’» Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.


šŸ“„ License

MIT Ā© 2025 Md Shafkat Hussain Tanvir