0.5.1 • Published 4 days ago

@acusti/date-picker v0.5.1

Weekly downloads
-
License
Unlicense
Repository
github
Last release
4 days ago

@acusti/date-picker

latest version maintenance status bundle size downloads per month

A group of React components and utils for rendering a date picker with support for ranges via a two-up month calendar view.

See the storybook docs and demo to get a feel for what it can do.

Usage

npm install @acusti/date-picker
# or
yarn add @acusti/date-picker

Example

To render a two-up date picker for selecting date ranges, handling date selections via the onChange prop and showing months using abbreviations:

import { DatePicker } from '@acusti/date-picker';
import { useCallback, useState } from 'react';

function Popover() {
    const [dateRangeStart, setDateRangeStart] = useState<null | string>(
        null,
    );
    const [dateRangeEnd, setDateRangeEnd] = useState<null | string>(null);

    const handleDateRangeChange = useCallback(({ dateEnd, dateStart }) => {
        setDateRangeStart(dateStart);
        if (dateEnd) {
            setDateRangeEnd(dateEnd);
        }
    }, []);

    return (
        <DatePicker
            isRange
            isTwoUp
            onChange={handleDateRangeChange}
            useMonthAbbreviations
        />
    );
}

Props

This is the type signature for the props you can pass to DatePicker:

type Props = {
    className?: string;
    dateEnd?: Date | string | number;
    dateStart?: Date | string | number;
    initialMonth?: number;
    isRange?: boolean;
    isTwoUp?: boolean;
    monthLimitFirst?: number;
    monthLimitLast?: number;
    onChange: (payload: { dateEnd?: string; dateStart: string }) => void;
    useMonthAbbreviations?: boolean;
};
0.5.1

4 days ago

0.5.0

5 days ago

0.5.0-pre

5 days ago

0.4.1

12 days ago

0.4.0

13 days ago

0.3.1

14 days ago

0.3.0

14 days ago

0.2.1

4 months ago

0.2.2

4 months ago

0.2.0

5 months ago

0.1.0

7 months ago

0.1.1

7 months ago

0.0.5

7 months ago

0.0.6

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago