Month and year pickers don't show the time in input anylonger.
| | |
| | | Changelog |
| | | ========= |
| | | ## 2.2.0 |
| | | * The picker can be used as a month or year picker just giving a format date without days/months |
| | | * Updates test suite |
| | | |
| | | ## 2.1.0 |
| | | * Fixed rdtActive not getting set. |
| | |
| | | return { |
| | | className: '', |
| | | defaultValue: '', |
| | | viewMode: 'days', |
| | | inputProps: {}, |
| | | input: true, |
| | | onFocus: nof, |
| | |
| | | if( state.open == undefined ) |
| | | state.open = !this.props.input; |
| | | |
| | | state.currentView = this.props.dateFormat ? this.props.viewMode : 'time'; |
| | | state.currentView = this.props.dateFormat ? (this.props.viewMode || state.updateOn || 'days') : 'time'; |
| | | |
| | | return state; |
| | | }, |
| | |
| | | }, |
| | | |
| | | getUpdateOn: function(formats){ |
| | | if(formats.datetime.indexOf("D") != -1){ |
| | | return "date"; |
| | | }else if(formats.datetime.indexOf("M") != -1){ |
| | | return "month"; |
| | | }else if(formats.datetime.indexOf("Y") != -1){ |
| | | return "year"; |
| | | if( formats.date.match(/[lLD]/) ){ |
| | | return "days"; |
| | | } |
| | | else if( formats.date.indexOf("M") != -1 ){ |
| | | return "months"; |
| | | } |
| | | else if( formats.date.indexOf("Y") != -1 ){ |
| | | return "years"; |
| | | } |
| | | |
| | | return 'days'; |
| | | }, |
| | | |
| | | getFormats: function( props ){ |
| | |
| | | if( formats.date === true ){ |
| | | formats.date = locale.longDateFormat('L'); |
| | | } |
| | | else if( this.getUpdateOn(formats) !== 'days' ){ |
| | | formats.time = ''; |
| | | } |
| | | |
| | | if( formats.time === true ){ |
| | | formats.time = locale.longDateFormat('LT'); |
| | | } |
| | |
| | | { |
| | | "name": "react-datetime", |
| | | "version": "2.1.0", |
| | | "version": "2.2.0", |
| | | "description": "A lightweight but complete datetime picker React.js component.", |
| | | "homepage": "https://github.com/arqex/react-datetime", |
| | | "repository": { |
| | |
| | | "jsdom": "^7.0.2", |
| | | "mocha": "^2.2.5", |
| | | "react": ">=0.13", |
| | | "react-addons-test-utils": "^0.14.8", |
| | | "react-tools": "^0.13.2", |
| | | "webpack": "^1.5.1", |
| | | "webpack-dev-server": "^1.7.0" |
| | |
| | | return ''; |
| | | |
| | | var date = this.props.selectedDate || this.props.viewDate; |
| | | |
| | | return DOM.tfoot({ key: 'tf'}, |
| | | DOM.tr({}, |
| | | DOM.td({ onClick: this.props.showView('time'), colSpan: 7, className: 'rdtTimeToggle'}, date.format( this.props.timeFormat )) |
| | |
| | | key: i, |
| | | 'data-value': i, |
| | | className: classes, |
| | | onClick: this.props.updateOn=="month"?this.updateSelectedMonth:this.props.setDate('month') |
| | | onClick: this.props.updateOn=="months"? this.updateSelectedMonth : this.props.setDate('month') |
| | | }; |
| | | |
| | | months.push( renderer( props, i, year, date && date.clone() )); |
| | |
| | | key: year, |
| | | 'data-value': year, |
| | | className: classes, |
| | | onClick: this.props.updateOn=="year"?this.updateSelectedYear:this.props.setDate('year') |
| | | onClick: this.props.updateOn=="years" ? this.updateSelectedYear : this.props.setDate('year') |
| | | }; |
| | | |
| | | years.push( renderer( props, year, selectedDate && selectedDate.clone() )); |
| | |
| | | |
| | | |
| | | // Needs to be global to work in Travis CI |
| | | React = require('react/addons'); |
| | | React = require('react'); |
| | | ReactDOM = require('react-dom'); |
| | | |
| | | var ReactAddons = require('react/addons'), |
| | | Utils = React.addons.TestUtils, |
| | | Datetime = require('../DateTime'), |
| | | var Datetime = require('../DateTime'), |
| | | assert = require('assert'), |
| | | moment = require('moment') |
| | | moment = require('moment'), |
| | | TestUtils = require('react-addons-test-utils') |
| | | ; |
| | | |
| | | var createDatetime = function( props ){ |
| | |
| | | element.dispatchEvent( ev ); |
| | | }; |
| | | |
| | | var ev = React.addons.TestUtils.Simulate; |
| | | var ev = TestUtils.Simulate; |
| | | var dt = { |
| | | dt: function(){ |
| | | return document.getElementById('root').children[0]; |
| | |
| | | assert.equal( component.children[0].tagName , 'DIV' ); |
| | | }); |
| | | |
| | | |
| | | it( 'Date value', function(){ |
| | | var component = createDatetime({ value: date }), |
| | | input = component.children[0] |
| | |
| | | // There must not be a date toggle |
| | | assert.equal( view.querySelectorAll('thead').length, 0); |
| | | }); |
| | | |
| | | it( 'timeFormat', function(){ |
| | | var format = 'HH:mm:ss:SSS', |
| | | component = createDatetime({ value: date, timeFormat: format }), |
| | |
| | | |
| | | assert.equal( dt.input().value, 'luis' ); |
| | | dt.input().value = strDate; |
| | | Utils.Simulate.change( dt.input() ); |
| | | ev.change( dt.input() ); |
| | | }); |
| | | |
| | | it( 'delete input value', function( done ){ |
| | |
| | | done(); |
| | | }}); |
| | | dt.input().value = ''; |
| | | Utils.Simulate.change( dt.input() ); |
| | | ev.change( dt.input() ); |
| | | }); |
| | | |
| | | it( 'strictParsing=true', function( done ){ |
| | |
| | | }}); |
| | | |
| | | dt.input().value = invalidStrDate; |
| | | Utils.Simulate.change( dt.input() ); |
| | | ev.change( dt.input() ); |
| | | }); |
| | | |
| | | it( 'strictParsing=false', function( done ){ |
| | |
| | | }}); |
| | | |
| | | dt.input().value = invalidStrDate; |
| | | Utils.Simulate.change( dt.input() ); |
| | | ev.change( dt.input() ); |
| | | }); |
| | | }); |
| | | |