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

@vincentvdt/datetimepicker

v2.1.1

Published

A React datetime picker component

Downloads

254

Readme

@vincentvdt/datetimepicker

A React-based DateTimePicker component built with TypeScript and styled using Emotion. This package provides a customizable, modern, and easy-to-use date picker.

Features

  • Built with React and TypeScript.
  • Fully customizable via Emotion for styling.
  • Compatible with modern JavaScript/TypeScript projects.
  • Lightweight and performant.
  • Supports localization (English and French).
  • Includes both ES and UMD builds.

Installation

To install the package, use npm or yarn:

npm install @vincentvdt/datetimepicker

Or, if you prefer using yarn:

yarn add @vincentvdt/datetimepicker

Usage

Here's how you can import and use the DateTimepicker component in your project:

import React, { useState } from 'react';
import { DateTimepicker } from "@vincentvdt/datetimepicker";

function App() {
  const [ startDate, setStartDate ] = useState<Date>(new Date());

  return (
    <DateTimepicker selected={ startDate } onDateChange={ (date) => setStartDate(date) } />
  );
}

export default App;

Localization

DateTimepicker supports two locales: 'en' (English, default) and 'fr' (French). You can change the locale by passing the locale prop.

import React, { useState } from 'react';
import { DateTimepicker } from "@vincentvdt/datetimepicker";

function App() {
  const [ startDate, setStartDate ] = useState<Date>(new Date());

  return (
    <div>
      <h1>Select a date</h1>

      {/* French Locale */ }
      <DateTimepicker locale="fr" />

    </div>
  );
}

export default App;

Note: Only en (English) and fr (French) are available for now. The default locale is en.

Input Attributes

You can pass any valid HTML input attributes using the input prop. Here's an example where the input is required and has a placeholder

import React, { useState } from 'react';
import { DateTimepicker } from "@vincentvdt/datetimepicker";

function App() {
  const [ startDate, setStartDate ] = useState<Date>(new Date());

  return (
    <DateTimepicker input={ { required: true } } // Input attributes
    />
  );
}

export default App;

DateTimepicker Props

| Prop | Type | Default | Description | |----------------|-------------------------------------------------------------|--------------|----------------------------------------------------------------------------| | locale | 'en' \| 'fr' | 'en' | Locale for date formatting. | | selected | Date | new Date() | The currently selected date. | | name | string | '' | Name attribute for the input element (useful in forms). | | input | Omit<React.InputHTMLAttributes<HTMLInputElement>, 'name'> | N/A | Additional input attributes (e.g., placeholder, required, disabled). | | onDateChange | (date: Date) => void | N/A | Callback fired when the selected date changes. |

Peer Dependencies

This package expects react and react-dom to be installed as peer dependencies:

{
  "peerDependencies": {
    "react": "^18.0.0",
    "react-dom": "^18.0.0"
  }
}

If these aren't installed in your project, you can install them with:

npm install react react-dom

Contributing

If you'd like to contribute to this project, follow these steps:

  1. Fork the repository.
  2. Clone your fork to your local machine.
  3. Create a new branch for your feature or bug fix: git checkout -b my-feature-branch.
  4. Push the branch to your fork and open a pull request.

Please make sure to run npm run lint before submitting a pull request.

License

This project is licensed under the ISC License. See the LICENSE file for more details.