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

@ambre972ppm/react-custom-datepicker

v1.0.7

Published

A React component for date and time picking

Downloads

12

Readme

Installation

To install the component, use npm:

npm install @ambre972ppm/react-custom-datepicker

OR

yarn add @ambre972ppm/react-custom-datepicker

Usage

Basic Example

Import the DateTimePicker component and its styles into your React application:

import React, { useState } from 'react';
import DateTimePicker from '@ambre972ppm/react-custom-datepicker';
import '@ambre972ppm/react-custom-datepicker/dist/DateTimePicker.css';

const App = () => {
  const [selectedDate, setSelectedDate] = useState(null);

  return (
    <div>
      <h1>DateTimePicker Demo</h1>
      <DateTimePicker
        label="Select Date and Time"
        selected={selectedDate}
        onChange={setSelectedDate}
      />
      {selectedDate && <p>Selected Date: {selectedDate.toString()}</p>}
    </div>
  );
};

export default App;

Options

You can customize the component with the following properties:

  • label (string): The label for the date picker.
  • selected (Date): The selected date.
  • onChange (function): The function to call when the date changes.
  • id (string): The id for the date picker.
  • showTimeSelect (boolean, default: true): Whether to show time selection.
  • dateFormat (string, default: "MMMM d, yyyy haa"): The format of the date.

Examples

DatePicker

<DateTimePicker
  label="Date Picker"
  selected={selectedDate}
  onChange={setSelectedDate}
/>

TimePicker

<DateTimePicker
  label="Time Picker"
  selected={selectedDate}
  onChange={setSelectedDate}
  showTimeSelect
  dateFormat="h:mm aa"
/>

Options to Highlight Specific Dates or Periods

You can use the highlightDates prop to highlight specific dates:

<DateTimePicker
  label="Special Dates"
  selected={selectedDate}
  onChange={setSelectedDate}
  highlightDates={[
    { "react-datepicker__day--highlighted": [new Date("2023-12-25"), new Date("2024-01-01")] },
  ]}
/>

JS Build Help

Requirements

This project requires Node.js and npm. Download and install Node.js.

Installing Dependencies

Install npm dependencies:

npm install

Building

To build the production files:

npm run build

Generated Files Structure

When the build is complete, you will have the following files:

  • dist/bundle.js - browser file
  • dist/bundle.min.js - minified browser file
  • dist/DateTimePicker.css.css - styles file

Contribution

Contributions are welcome! Please submit pull requests or open issues on GitHub.

License

This project is licensed under the ISC License.

Conversion Explanation

The conversion from the jQuery plugin to a React component involved the following steps:

Replacing jQuery APIs with React APIs

  • Using React hooks (useState, useEffect) to manage state and side effects.
  • Utilizing react-datepicker to provide the date and time picking functionality, replacing the original jQuery plugin.

Component Structure

  • The DateTimePicker component encapsulates the date and time picking logic.
  • Props are used to customize the component's behavior (e.g., showing or hiding the time selection).

Styles

  • CSS styles were adapted to match the desired appearance of the component.
  • Using CSS classes to style the date and time picker.

Development Environment Configuration

  • Using Webpack to bundle the JavaScript and CSS files.
  • Using Babel to transpile JSX and ES6 code to browser-compatible JavaScript.

Documentation

  • Using JSDoc to generate detailed documentation of the component's properties and usage.
  • Creating a comprehensive README to guide users on installation, usage, and contribution to the project.
  • This conversion allows the date and time picker to be used effectively in React applications, leveraging React's modern features and syntax.