@@ -6,34 +6,15 @@ import DayPicker from '../DayPicker';
66import DateVariants from '../DateVariants' ;
77import InputAddonButton from '../InputAddonButton' ;
88import { spring , presets , Motion } from 'react-motion' ;
9- import assign from 'lodash/assign' ;
10- import moment from '../moment' ;
9+ import dayjs from '../../dayjs' ;
1110import getMessage from '../translations' ;
1211import isEqual from 'lodash/isEqual' ;
1312import { Portal } from 'react-portal' ;
14- import { getCoords } from '../utils/get-coords ' ;
13+ import { getCoords , splitProps } from '../utils' ;
1514
1615let springPreset = presets . gentle ;
1716let easeOutCubic = ( t ) => ( -- t ) * t * t + 1 ; // eslint-disable-line no-param-reassign
1817
19- function splitProps ( props , specificPropNames = [ ] ) {
20- let result = Object . keys ( props ) . reduce ( ( result , propName ) => {
21- let isPropSpecific = specificPropNames . indexOf ( propName ) >= 0 ;
22- if ( isPropSpecific ) {
23- let commonProps = assign ( { } , result [ 0 ] ) ;
24- let specificProps = assign ( { } , result [ 1 ] , { [ propName ] : props [ propName ] } ) ;
25- return [ commonProps , specificProps ] ;
26- }
27-
28- let commonProps = assign ( { } , result [ 0 ] , { [ propName ] : props [ propName ] } ) ;
29- let specificProps = assign ( { } , result [ 1 ] ) ;
30- return [ commonProps , specificProps ] ;
31- } , [ { } , { } ] ) ;
32-
33- return result ;
34- }
35-
36-
3718let propTypes = {
3819 className : PropTypes . string ,
3920 dateFormat : PropTypes . string ,
@@ -70,15 +51,15 @@ let defaultProps = {
7051 variants : [
7152 {
7253 getLabel : ( locale ) => getMessage ( locale , 'yesterday' ) ,
73- getValue : ( locale ) => moment ( ) . locale ( locale ) . subtract ( 1 , 'days' ) . toDate ( )
54+ getValue : ( locale ) => dayjs ( ) . locale ( locale ) . subtract ( 1 , 'days' ) . toDate ( )
7455 } ,
7556 {
7657 getLabel : ( locale ) => getMessage ( locale , 'today' ) ,
77- getValue : ( locale ) => moment ( ) . locale ( locale ) . toDate ( )
58+ getValue : ( locale ) => dayjs ( ) . locale ( locale ) . toDate ( )
7859 } ,
7960 {
8061 getLabel : ( locale ) => getMessage ( locale , 'tomorrow' ) ,
81- getValue : ( locale ) => moment ( ) . locale ( locale ) . add ( 1 , 'days' ) . toDate ( )
62+ getValue : ( locale ) => dayjs ( ) . locale ( locale ) . add ( 1 , 'days' ) . toDate ( )
8263 }
8364 ]
8465} ;
@@ -249,7 +230,7 @@ class DateInput extends Component {
249230
250231 let { error, showPicker, showVariants } = this . state ;
251232
252- let momentCompatibleDateFormat = dateFormat . replace ( / d / g, 'D' ) . replace ( / y / g, 'Y' ) ;
233+ let dayjsCompatibleDateFormat = dateFormat . replace ( / d / g, 'D' ) . replace ( / y / g, 'Y' ) ;
253234
254235 let splittedProps = splitProps ( restProps , Object . keys ( DayPicker . propTypes ) ) ;
255236 let dayPickerSpecificProps = splittedProps [ 1 ] ;
@@ -368,7 +349,7 @@ class DateInput extends Component {
368349 >
369350 < div className = { `opuscapita_date-input__input-container` } >
370351 < DateInputField
371- dateFormat = { momentCompatibleDateFormat }
352+ dateFormat = { dayjsCompatibleDateFormat }
372353 disabled = { disabled }
373354 onBlur = { this . handleBlur }
374355 onChange = { this . handleDateChange }
0 commit comments