0.0.6 • Published 6 years ago

react-datetime-inputs v0.0.6

Weekly downloads
21
License
MIT
Repository
github
Last release
6 years ago

React component for datetime input

This component is designed to provide easy and intuitive input of moment.js datetime objects.

Desgined to be as simple as possible in order to afford intuitive interactions.

Demo

Click here for a live demo.

Datetime input

Install

1) Install 'react-datetime-inputs' with npm

npm install react-datetime-inputs --save

or with yarn

yarn add react-datetime-inputs

2) Import DatetimeInput component

import { DatetimeInput } from 'react-datetime-inputs'

3) Render DatetimeInput component

render() {
  return (
    <DatetimeInput
      datetime={this.state.datetime}
      onChange={this.handleOnChange.bind(this)}>
    </DatetimeInput>
  )
}

Attributes

PropertyUsageDefaultRequired
datetimemoment.js datetime object or a datetime stringnoneno
date-formatmoment.js compatible date format used for display in date and datetime input directives'DD MMMM YYYY'no
time-formatmoment.js compatible time format used for display in time and datetime input directives'HH : mm : ss'no
minDatemoment.js datetime object min datetimenoneno
maxDatemoment.js datetime object max datetimenoneno
placeholderPlaceholder is shown when input object is undefinednoneno
allowClearAllow users to clear selected datetime valuefalseno
clearTextClear text shown in the button to clear date objectClearno
onChangeHandler function that is fired on change of datetime objectnoneno
onCloseHandler function that is fired on close of the edit popovernoneno
customDisplaycustom display component for presentationnoneno
naturalScrollscroll directiontrueno

Note that when custom display component is used you need to format display value and include a button to toggle datetime editor/popover. Additionally one can use active and warning properties to change display (or alert user of invalid input when used together with minDate and/or maxDate properties).

For example:

<h1 onClick={this.props.onClick}>
  {this.props.datetime.format('DD MMM HH:mm')}
</h1>

Angular directives

If you are looking for datetime input widgets as angular directices, check out angular-datetime-inputs and angular-datetime-range

Dependencies