@@ -94,6 +94,7 @@ const Default = {
9494 footer : false ,
9595 inputDateFormat : null ,
9696 inputDateParse : null ,
97+ inputOnChangeDelay : 750 ,
9798 inputReadOnly : false ,
9899 invalid : false ,
99100 indicator : true ,
@@ -147,6 +148,7 @@ const DefaultType = {
147148 indicator : 'boolean' ,
148149 inputDateFormat : '(function|null)' ,
149150 inputDateParse : '(function|null)' ,
151+ inputOnChangeDelay : 'number' ,
150152 inputReadOnly : 'boolean' ,
151153 invalid : 'boolean' ,
152154 locale : 'string' ,
@@ -204,6 +206,8 @@ class DateRangePicker extends BaseComponent {
204206 this . _timePickerEnd = null
205207 this . _timePickerStart = null
206208 this . _togglerElement = null
209+ this . _startInputTimeout = null
210+ this . _endInputTimeout = null
207211
208212 this . _createDateRangePicker ( )
209213 this . _createDateRangePickerCalendars ( )
@@ -272,6 +276,14 @@ class DateRangePicker extends BaseComponent {
272276 this . _popper . destroy ( )
273277 }
274278
279+ if ( this . _startInputTimeout ) {
280+ clearTimeout ( this . _startInputTimeout )
281+ }
282+
283+ if ( this . _endInputTimeout ) {
284+ clearTimeout ( this . _endInputTimeout )
285+ }
286+
275287 super . dispose ( )
276288 }
277289
@@ -349,18 +361,24 @@ class DateRangePicker extends BaseComponent {
349361 } )
350362
351363 EventHandler . on ( this . _startInput , EVENT_INPUT , event => {
352- const date = this . _parseDate ( event . target . value )
353-
354- // valid date or empty date
355- if ( ( date instanceof Date && ! Number . isNaN ( date ) ) || ( date === null ) ) {
356- this . _startDate = date
357- this . _calendarDate = date
358- this . _calendar . update ( this . _getCalendarConfig ( ) )
364+ if ( this . _startInputTimeout ) {
365+ clearTimeout ( this . _startInputTimeout )
359366 }
360367
361- EventHandler . trigger ( this . _element , EVENT_START_DATE_CHANGE , {
362- date
363- } )
368+ this . _startInputTimeout = setTimeout ( ( ) => {
369+ const date = this . _parseDate ( event . target . value )
370+
371+ // valid date or empty date
372+ if ( ( date instanceof Date && ! Number . isNaN ( date ) ) || ( date === null ) ) {
373+ this . _startDate = date
374+ this . _calendarDate = date
375+ this . _calendar . update ( this . _getCalendarConfig ( ) )
376+ }
377+
378+ EventHandler . trigger ( this . _element , EVENT_START_DATE_CHANGE , {
379+ date
380+ } )
381+ } , this . _config . inputOnChangeDelay )
364382 } )
365383
366384 EventHandler . on ( this . _startInput . form , EVENT_SUBMIT , ( ) => {
@@ -391,18 +409,24 @@ class DateRangePicker extends BaseComponent {
391409 } )
392410
393411 EventHandler . on ( this . _endInput , EVENT_INPUT , event => {
394- const date = this . _parseDate ( event . target . value )
395-
396- // valid date or empty date
397- if ( ( date instanceof Date && ! Number . isNaN ( date ) ) || ( date === null ) ) {
398- this . _endDate = date
399- this . _calendarDate = date
400- this . _calendar . update ( this . _getCalendarConfig ( ) )
412+ if ( this . _endInputTimeout ) {
413+ clearTimeout ( this . _endInputTimeout )
401414 }
402415
403- EventHandler . trigger ( this . _element , EVENT_END_DATE_CHANGE , {
404- date
405- } )
416+ this . _endInputTimeout = setTimeout ( ( ) => {
417+ const date = this . _parseDate ( event . target . value )
418+
419+ // valid date or empty date
420+ if ( ( date instanceof Date && ! Number . isNaN ( date ) ) || ( date === null ) ) {
421+ this . _endDate = date
422+ this . _calendarDate = date
423+ this . _calendar . update ( this . _getCalendarConfig ( ) )
424+ }
425+
426+ EventHandler . trigger ( this . _element , EVENT_END_DATE_CHANGE , {
427+ date
428+ } )
429+ } , this . _config . inputOnChangeDelay )
406430 } )
407431
408432 EventHandler . on ( window , EVENT_RESIZE , ( ) => {
0 commit comments