1.0.0 • Published 5 years ago

window-date-picker-react v1.0.0

Weekly downloads
39
License
-
Repository
github
Last release
5 years ago

Window Date Picker React

React integration for Window Date Picker.

NPM

npm install --save-dev window-date-picker-react

Yarn

yarn add window-date-picker-react --dev 

Installation

import React from 'react';
import WindowDatePicker from 'window-date-picker-react';

export default class extends React.Component {
  render() {
    return <WindowDatePicker />
  }
}

Add the css file.

<link rel="stylesheet" href="/node_modules/window-date-picker-react/dist/css/window-date-picker.min.css" />

Settings

OptionTypeDefaultDescription
valueString|Number|DatenullThe picker's initial value.
inputElString|HTMLElement*nullInput element.
toggleElString|HTMLElement*nullToggle element.
typeString"DATE"Sets picker type. (DATE, HOUR, DATEHOUR)
dateTypeString"DD/MM/YYYY"Sets date type. (DD/MM/YYYY, MM/DD/YYYY)
hourTypeString"12"Sets hour type. (12, 24)
allowEmptyBooleantrueA boolean value that indicates whether null and empty value are allowed or not.
showButtonsBooleanfalseA boolean value that indicates whether the buttons are visible or not.
inputToggleBooleantrueIf sets true, opens the picker when the input is clicked.
langString"en"Changes language of the picker. You have to create a language except “en (English)” before use it.

*: You can give an HTML element or a CSS selector (like #carousel, .container > div:first-child)

Methods

MethodParamsReturnDescription
get{ value: String, day: Number, month: Number, year: Number, hour: Number, minute: Number, am: Boolean }Returns the value.
setvalue: String|Number|DatevoidSets the value.
openvoidOpens the picker.
closevoidCloses the picker.
togglevoidToggles the picker.
savevoidSaves the selection.
cancelvoidCancels the selection.
destroyvoidDestroys the picker.

Events

EventDescription
onChangeFires when the value changes.
onOpenFires when the picker opens.
onCloseFires when the picker closes.
onSaveFires when the selection is saved.
onCancelFires when the picker is closed without being saved.
onDestroyFires when the picker is destroyed.
import React from 'react';
import WindowDatePicker from 'window-date-picker-react';

export default class extends React.Component {
  open() {
    console.log('open');
  }

  close() {
    console.log('close');
  }

  render() {
    return(<WindowDatePicker onOpen={this.open} onClose={this.close} />)
  }
}

IE Support

IE 10 is not supported and patches to fix problems will not be accepted.

License

Window Date Picker React is provided under the MIT License.