1.2.2 • Published 4 years ago

material-ui-i18n-daterange-picker v1.2.2

Weekly downloads
24
License
MIT
Repository
github
Last release
4 years ago

Material UI DateRange Picker

A react date range picker implementation using @material-ui.

Preview

Screenshot

Live Demo

Check out the project running here!

Usage

npm install materialui-daterange-picker --save

# or with yarn
yarn add materialui-daterange-picker

Basic example

import React from "react";
import { DateRangePicker, DateRange } from "materialui-daterange-picker";

type Props = {}

const App: React.FunctionComponent<Props> = props => {
  const [open, setOpen] = React.useState(false);
  const [dateRange, setDateRange] = React.useState<DateRange>({});

  const toggle = () => setOpen(!open);

  return (
    <DateRangePicker
      open={open}
      toggle={toggle}
      onChange={(range) => setDateRange(range)}
    />
  );
}

export default App;

Types

interface DateRange {
    startDate?: Date,
    endDate?: Date
}

interface DefinedRange {
    label: string,
    startDate: Date,
    endDate: Date
}

Props

NameTypeRequiredDefault valueDescription
onChange(DateRange) => voidrequired-handler function for providing selected date range
toggle() => voidrequired-function to show / hide the DateRangePicker
initialDateRangeDateRangeoptional{}initially selected date range
minDateDateoptional10 years agomin date allowed in range
maxDateDateoptional10 years from nowmax date allowed in range
localeLocaleoptionalenGBthe locale for date calculation
definedRangesDefinedRange[]optional-custom defined ranges to show in the list
closeOnClickOutsidebooleanoptionaltruedefines if DateRangePicker will be closed when clicking outside of it
wrapperClassNameobjectoptionalundefineddefines additional wrapper style classes

Made possible by

Changelog

###v1.2.2 Fixing date parsing issues caused by the upgrade of date-fns

###v1.2.1 The concept (and prop!) of locale was introduced. See https://date-fns.org/v2.16.1/docs/Locale

###v1.2.0 Dependencies upgraded