1.0.2 • Published 4 years ago

@netojose/react-select-datepicker v1.0.2

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

React Select date picker

Install

Via npm

# npm
npm install --save @netojose/react-select-datepicker

Via yarn

# yarn
yarn add @netojose/react-select-datepicker

Demo

You can see a working demo at this Sandbox

Usage

import React, { useState } from "react";
import SelectDatePicker from "@netojose/react-select-datepicker";

export default function App() {
  const [date, setDate] = useState(new Date(2000, 0, 1));
  const handleChange = value => setDate(value);
  return (
    <div>
      <SelectDatePicker value={date} onDateChange={handleChange} />

      <p>Chosen date: {date.toString()}</p>
    </div>
  );
}

Available Props

PropTypeDescriptionDefaultOptions
valueDateCurrent input valueREQUIRED-
minDateDateMinimum date allowednew Date(1900, 0, 1)-
maxDateDateMaximum date allowednew Date()-
classNamestringWrapper class namenull-
cssstringcss functionnull-
onDateChangefunconChange date triggerREQUIRED-
showErrorsbooleanShow or not error messagetruetrue, false
showLabelsbooleanShow or not input labelstruetrue, false
yearLabelbooleanYear label textYearAny string
monthLabelbooleanMonth label textMonthAny string
dayLabelbooleanDay label textDayAny string
errorFormatstringFormat error message'Invalid date'Any string
errorMinstringError min value message'Date must be greater than allowed'Any string
errorMaxstringError max value message'Date must be less than allowed'Any string
formatstringInputs position'month/day/year''day/month/year', 'day/year/month', 'month/day/year', 'month/year/day', 'year/month/day', 'year/day/month'
monthNamesarrayArray with month names'January', ..., 'December'An array with 12 strings

Notes

Year Select Field

  • If no minDate is provided than the minium year that can be selected is 1900
  • If no maxDate is provided than the maxium year that can be selected is the current

CSS in js integration

  • The className prop can be useful to extend the component using Styled-components
  • The css prop can be useful to extend the component using Emotion

License

MIT © netojose