@@ -49,7 +49,9 @@ import {
4949 defaultDateRangeTransformers ,
5050} from '../common/mixins/forms/form-value.js' ;
5151import {
52+ clamp ,
5253 createCounter ,
54+ equal ,
5355 findElementFromEventPath ,
5456 last ,
5557} from '../common/util.js' ;
@@ -60,6 +62,11 @@ import IgcFocusTrapComponent from '../focus-trap/focus-trap.js';
6062import IgcIconComponent from '../icon/icon.js' ;
6163import IgcInputComponent from '../input/input.js' ;
6264import IgcPopoverComponent from '../popover/popover.js' ;
65+ import type {
66+ ContentOrientation ,
67+ DateRangePickerInput ,
68+ PickerMode ,
69+ } from '../types.js' ;
6370import IgcValidationContainerComponent from '../validation-container/validation-container.js' ;
6471import { styles } from './date-range-picker.base.css.js' ;
6572import { dateRangeValidators } from './validators.js' ;
@@ -226,7 +233,7 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
226233 private _placeholder ?: string ;
227234 private _defaultMask ! : string ;
228235 private _oldValue : DateRangeValue | null = null ;
229- private _visibleMonths : 1 | 2 = 2 ;
236+ private _visibleMonths = 2 ;
230237
231238 private predefinedRanges : CustomDateRange [ ] = [
232239 {
@@ -333,7 +340,7 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
333340 * @attr mode
334341 */
335342 @property ( )
336- public mode : 'dropdown' | 'dialog' = 'dropdown' ;
343+ public mode : PickerMode = 'dropdown' ;
337344
338345 /**
339346 * Use two inputs to display the date range values. Makes the input editable in dropdown mode.
@@ -380,12 +387,12 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
380387 */
381388 //
382389 @property ( { type : Number , attribute : 'visible-months' } )
383- public get visibleMonths ( ) : 1 | 2 {
390+ public get visibleMonths ( ) : number {
384391 return this . _visibleMonths ;
385392 }
386393
387- public set visibleMonths ( value : 1 | 2 ) {
388- this . _visibleMonths = [ 1 , 2 ] . includes ( value ) ? value : 2 ;
394+ public set visibleMonths ( value : number ) {
395+ this . _visibleMonths = clamp ( value , 1 , 2 ) ;
389396 }
390397
391398 /**
@@ -508,14 +515,14 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
508515 * @attr header-orientation
509516 */
510517 @property ( { attribute : 'header-orientation' , reflect : true } )
511- public headerOrientation : 'vertical' | 'horizontal' = 'horizontal' ;
518+ public headerOrientation : ContentOrientation = 'horizontal' ;
512519
513520 /**
514521 * The orientation of the multiple months displayed in the calendar's days view.
515522 * @attr
516523 */
517524 @property ( )
518- public orientation : 'vertical' | 'horizontal' = 'horizontal' ;
525+ public orientation : ContentOrientation = 'horizontal' ;
519526
520527 /**
521528 * Determines whether the calendar hides its header.
@@ -638,7 +645,7 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
638645
639646 protected handleDialogClosing ( event : Event ) {
640647 event . stopPropagation ( ) ;
641- if ( ! DateTimeUtil . areDateRangesEqual ( this . value , this . _oldValue ) ) {
648+ if ( ! equal ( this . value , this . _oldValue ) ) {
642649 this . emitEvent ( 'igcChange' , { detail : this . value } ) ;
643650 }
644651 this . _hide ( true ) ;
@@ -658,7 +665,7 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
658665 }
659666
660667 protected dialogDone ( ) {
661- if ( ! DateTimeUtil . areDateRangesEqual ( this . value , this . _oldValue ) ) {
668+ if ( ! equal ( this . value , this . _oldValue ) ) {
662669 this . emitEvent ( 'igcChange' , { detail : this . value } ) ;
663670 }
664671 this . _hide ( true ) ;
@@ -733,10 +740,7 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
733740 if ( ! this . contains ( relatedTarget as Node ) ) {
734741 this . checkValidity ( ) ;
735742
736- const isSameValue = DateTimeUtil . areDateRangesEqual (
737- this . value ,
738- this . _oldValue
739- ) ;
743+ const isSameValue = equal ( this . value , this . _oldValue ) ;
740744 if ( ! this . useTwoInputs && ! this . readOnly && ! isSameValue ) {
741745 this . emitEvent ( 'igcChange' , { detail : this . value } ) ;
742746 }
@@ -957,7 +961,7 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
957961 }
958962 }
959963
960- private renderClearIcon ( picker : 'start' | 'end' = 'start' ) {
964+ private renderClearIcon ( picker : DateRangePickerInput = 'start' ) {
961965 const clearIcon = ! this . useTwoInputs
962966 ? 'clear-icon'
963967 : `clear-icon-${ picker } ` ;
@@ -980,7 +984,7 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
980984 ` ;
981985 }
982986
983- private renderCalendarIcon ( picker : 'start' | 'end' = 'start' ) {
987+ private renderCalendarIcon ( picker : DateRangePickerInput = 'start' ) {
984988 const defaultIcon = html `
985989 < igc-icon name ="today " collection ="default " aria-hidden ="true "> </ igc-icon >
986990 ` ;
@@ -1118,7 +1122,7 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
11181122 return IgcValidationContainerComponent . create ( this ) ;
11191123 }
11201124
1121- protected renderInput ( id : string , picker : 'start' | 'end' = 'start' ) {
1125+ protected renderInput ( id : string , picker : DateRangePickerInput = 'start' ) {
11221126 const readOnly = ! this . isDropDown || this . readOnly || this . nonEditable ;
11231127 const placeholder =
11241128 picker === 'start' ? this . placeholderStart : this . placeholderEnd ;
0 commit comments