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

reactjs-datetime-range-picker

v1.1.0

Published

ReactJS datetime range picker with daily, weekly, monthly, quarterly & yearly levels

Downloads

50

Readme

reactjs-datetime-range-picker

ReactJS datetime range picker with daily, weekly, monthly, quarterly & yearly levels

npm version

This plugin uses bootstrap and moment.js. This plugin can render the components from any UI library you are using in your app as long as the UI library exports Input, Select and Button components.

Demo

Storybook demo

Angular Version

ngx-datetime-range-picker

Installation

Install the plugin:

# npm
npm install reactjs-datetime-range-picker --save-dev

# yarn
yarn add reactjs-datetime-range-picker --dev

Using the basic HTML components

import React from "react";
import {
  ReactJSDatetimeRangePicker,
  DateRangeModel,
  Options,
  Settings,
} from "reactjs-datetime-range-picker";

const SomeComponent: React.FC<Props> = ({}) => {
  const dateRangeModel: DateRangeModel = {...};
  const options: Options = {...};
  const settings: Settings = {...};

  const onDateSelect = (options: Options) => {
    console.log(options);
    /**
     * {
     *   startDate: "2018-10-13",
     *   endDate: "2018-10-19",
     * },
     */
  };

  return <>
    ...
    <ReactJSDatetimeRangePicker
      canBeEmpty={false}
      dateRangeModel={dateRangeModel}
      options={options}
      settings={settings}
      onDateSelect={onDateSelect}
      onDateRangeModelChange={(options: Options | DateRangeModel) => console.log(options)}
      onDateRangeChange={(options: Options) => console.log(options)}
      onInputBlur={(options: Record<string, unknown>) => console.log(options)}
    />
  </>
}

Using the components from the library you are using. Example: NextUI

Assumpition is that you have already installed the UI library you will be using.

import React from "react";
import {
  ReactJSDatetimeRangePicker,
  DateRangeModel,
  Options,
  Settings,
  SELECT_AS
} from "reactjs-datetime-range-picker";
import { Input } from "@nextui-org/input";
import { Button } from "@nextui-org/button";
import { Select, SelectItem } from "@nextui-org/select";

const SomeComponent: React.FC<Props> = ({}) => {
  const dateRangeModel: DateRangeModel = {...};
  const options: Options = {...};
  const settings: Settings = {...};
  const selectAs: SELECT_AS = {
    tag: Select,
    optionTag: SelectItem,
    selectedAttributeName: "defaultSelectedKeys", // specify the propery that your library uses for default value selection
    selectedAttributeValueType: "array", // specify if the above property accepts default value in array or string
  };
  
  const onSelectedDate = (options: Options) => {
    console.log(options);
    /**
     * {
     *   startDate: "2018-10-13",
     *   endDate: "2018-10-19",
     * },
     */
  };

  return <>
    ...
    <ReactJSDatetimeRangePicker
      canBeEmpty={false}
      onDateSelect={{
        daily: {
          endDate: '2024-03-23',
          startDate: '2024-03-23'
        },
        weekly: {
          endDate: '2024-03-23',
          startDate: '2024-03-17'
        }
      }}
      
      displayEndDate={true}
      inputDateFormat="YYYY-MM-DD"
      label="Date"
      placeholder="Date"
      showRowNumber
      singleDatePicker
      type="daily"
      viewDateFormat="MMM D, YYYY"
      inputAs={Input}
      selectAs={selectAs}
      buttonAs={Button}
      onDateSelect={onDateSelect}
      onDateRangeModelChange={(options: Options | DateRangeModel) => console.log(options)}
      onDateRangeChange={(options: Options) => console.log(options)}
      onInputBlur={(options: Record<string, unknown>) => console.log(options)}
    />
  </>
}

Properties

| Property | Type | Default | Description | | --------------------- | ------- | --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | | type | string | 'daily' | type (daily | weekly | monthly | quarterly | yearly) | | timePicker | boolean | false | enable/disable timepicker | | inputDateFormat | string | "YYYY-MM-DD" | input date format | | viewDateFormat | string | "YYYY-MM-DD" | date format to view the date in | | outputDateFormat | string | "YYYY-MM-DD" | date format in which change event will return the date in | | singleDatePicker | boolean | false | enable/disable single date picker | | componentDisabled | string | false | enable/disable component | | placeholder | string | "Select Date" | placeholder/title of the component | | showRowNumber | boolean | true | hide/show week numers for daily | | availableRanges | Object | {"Last 7 Days": {startDate: inputDateFormat, endDate: inputDateFormat}, "Last 30 days": {...}, "Last 90 days": {...}} | ranges to show | | showRanges | boolean | true | hide/show ranges | | disableWeekends | boolean | false | enable/disable weekends | | disableWeekdays | boolean | false | enable/disable weekdays | | displayBeginDate | boolean | false | show begin date in input | | displayEndDate | boolean | false | show end date in input | | dateArray | Array | [] | Only the dates in the array will be enabled | | startDate | string | Today's date | Start date | | endDate | string | Today's date | End date | | minDate | string | Current Year - 2 | Min date | | maxDate | string | Today's date | Max date | | startTime | string | "00:00" | Start time (only for timepicker) | | endTime | string | "23:59" | End time (only for timepicker) | | minTime | string | | Min time (only for timepicker) | | maxTime | string | | Max time (only for timepicker) | | onDateRangeModelChange| function| function(options: Options | DateRangeModel) {} | Emits the date range model when the calendar is closed | | onDateSelect | function| function(options: Options) {} | Emits date when date is selected | | onDateRangeChange | function| function(options: Options) {} | Emits the selected date and time when the calendar is closed| | onInputBlur | function| function(options: Record<string, unknown>) {} | Emitted when the date input is blurred |

License

MIT