2.0.4 • Published 3 years ago

react-xflex-datepicker v2.0.4

Weekly downloads
16
License
ISC
Repository
github
Last release
3 years ago

React XFLEX Date Picker

A very simple react datepicker component which includes range picker. Now supports server side rendering.

npm.io npm.io

Installation

The package can be installed via NPM:

npm install react-xflex-datepicker --save

Or yarn:

yarn add react-xflex-datepicker

Usage

  1. Datepicker component for choosing only one date:
import { XFlexDatepicker } from 'react-xflex-datepicker';
  1. Daterange picker component:
import { XFlexDatepickerRange } from 'react-xflex-datepicker';

Then you can use it in your code:

<XFlexDatepicker />

or

<XFlexDatepickerRange />

Styles need to be imported separately.

import 'react-xflex-datepicker/dist/xflex-datepicker.css';

Options

Datepicker

moment is required for some of the options

OptionTypeValuesDefaultDescription
initialDateMomentmoment dates, nullmoment() (Current date)This is the initial date set on the calendar on mount.
positionStringtop, bottombottomIt tells where the calendar will be positioned regarding the input control. This property has no effect when inputControl is set to false.
inputControlBooleantrue, falsetrueWhen is set to false, the calendar will be visible all the time, otherwise it will be opened by a button.
placeholderStringanyChoose date...This is the placeholder on the input control when no date is selected. It has no effect when inputControl is set to false.
Stringmoment formats (see momentjs webpage for available formats)YYYY, MMMM DDThe format in which the dates will be shown on the input control. Has no effect when inputControl is set to false.
localeStringmoment localeenThe locale of the calendar. This does not affect the placeholder
buttonControlClassNameStringany className''This is optional className for the button control for custom styling.

Datepicker Range

Range datepicker has the same above options as the datepicker and a few more:

OptionTypeValuesDefaultDescription
hasTooltipBooleantrue, falsetrueWhether or not to have an info tooltip on day mouseover
tooltipLabelFunctionfunctions(numberOfNights) => {return numberOfNights}Provided this function, you can set a custom label for the day tooltip. It receives number of nights between the days selected.

Events

EventArgumentsDescription
onChooseDatedate: Moment objectFired when clicked on a date. On datepicker it fires with {date: Moment} and on range picker with {start: Moment, end: Moment \| null. The end date is null if the event is fired when selecting the start date.
onClearDatedate: Moment objectFired when cleared a date from the input control. On datepicker it fires with {date: Moment} and on range picker with {start: Moment, end: Moment \| null. The object tells which dates have been cleared. The end date is null if the event is fired when only the start date is selected.
onCalendarShownoneFired when the calendar is shown. Only when inputControl is false
onCalendarHidenoneFired when the calendar is hidden. Only when inputControl is false
onMonthDayOverdate: Moment objectFired when mouseover on a date. The argument is a Moment object which represents the date that has been hovered.

License

ISC

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.9.1

3 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago