1.2.1 • Published 2 years ago

@zngly/daterange-picker v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

DateRange Picker

A react date range picker implementation

npm

https://www.npmjs.com/package/@zngly/daterange-picker

Usage

npm install @zngly/daterange-picker --save

# or with yarn
yarn add @zngly/daterange-picker

Basic example

import React from 'react';
import { DateRangePicker, DateRange } from '@zngly/daterange-picker';

type Props = {};

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

    return <DateRangePicker open={open} onClose={() => setOpen(close)}</DateRangePicker>} 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
openbooleanrequired-If the datepicker is open or not
onChange(DateRange) => voidoptional-handler function for providing selected date range
onClose() => voidoptional-function to hide the DateRangePicker
initialDateRangeDateRangeoptional{}initially selected date range
minDateDate or stringoptional10 years agomin date allowed in range
maxDateDate or stringoptional10 years from nowmax date allowed in range
definedRangesDefinedRange[]optional-custom defined ranges to show in the list
closeOnClickOutsidebooleanoptionaltruedefines if DateRangePicker will be closed when clicking outside of it
classNameobjectoptionalundefineddefines additional wrapper style classes
localeLocale (from date-dns)optionalundefineddefines locale to use (from date-fns package)
1.2.1

2 years ago

1.2.0

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago