11import eventsEngine from '@js/common/core/events/core/events_engine' ;
22import { addNamespace , isCommandKeyPressed , normalizeKeyName } from '@js/common/core/events/utils/index' ;
3- import defaultDateNames from '@js/common/core/localization/default_date_names' ;
43import { getFormat } from '@js/common/core/localization/ldml/date.format' ;
54import { getRegExpInfo } from '@js/common/core/localization/ldml/date.parser' ;
65import numberLocalization from '@js/common/core/localization/number' ;
@@ -136,7 +135,6 @@ class DateBoxMask extends DateBoxBase {
136135 const delta = currentValue - originalValue ;
137136
138137 this . _loadMaskValue ( this . _initialMaskValue ) ;
139-
140138 this . _changePartValue ( delta + step , true ) ;
141139 }
142140
@@ -153,12 +151,12 @@ class DateBoxMask extends DateBoxBase {
153151
154152 _toggleAmPm ( ) : void {
155153 const currentValue = this . _getActivePartProp ( 'text' ) ;
156- const indexOfCurrentValue = defaultDateNames
157- // @ts -expect-error getPeriodNames type should be fixed
158- . getPeriodNames ( this . _formatPattern )
159- . indexOf ( currentValue ) ;
154+ const periodNames = dateLocalization . getPeriodNames ( this . _formatPattern ) ;
155+ const indexOfCurrentValue = periodNames . indexOf ( currentValue ) ;
156+
160157 // eslint-disable-next-line no-bitwise
161158 const newValue = indexOfCurrentValue ^ 1 ;
159+
162160 this . _setActivePartValue ( newValue ) ;
163161 }
164162
@@ -516,7 +514,7 @@ class DateBoxMask extends DateBoxBase {
516514
517515 const activePartIndex = this . _activePartIndex ?? 0 ;
518516 let index = fitIntoRange ( activePartIndex + step , 0 , this . _dateParts . length - 1 ) ;
519- if ( this . _dateParts [ index ] . isStub ) {
517+ if ( this . _dateParts [ index ] ? .isStub ) {
520518 const isBoundaryIndex = ( index === 0 && step < 0 )
521519 || ( index === this . _dateParts . length - 1 && step > 0 ) ;
522520 if ( ! isBoundaryIndex ) {
@@ -554,8 +552,11 @@ class DateBoxMask extends DateBoxBase {
554552 _getActivePartValue ( dateValue ?: Date | null ) : number {
555553 const date = dateValue ?? this . _maskValue as Date ;
556554 const getter = this . _getActivePartProp ( 'getter' ) ;
555+ const isGetterFunction = isFunction ( getter ) ;
556+
557+ const activePartValue = isGetterFunction ? getter ( date ) : date [ getter ] ( ) as number ;
557558
558- return isFunction ( getter ) ? getter ( date ) : date [ getter ] ( ) as number ;
559+ return activePartValue ;
559560 }
560561
561562 _addLeadingZeroes ( value : number ) : string {
@@ -568,6 +569,7 @@ class DateBoxMask extends DateBoxBase {
568569
569570 _setActivePartValue ( value : number | string , dateValue ?: Date ) : void {
570571 let newValue : number | string = + value ;
572+
571573 const newDateValue = dateValue ?? this . _maskValue as Date ;
572574 const setter = this . _getActivePartProp ( 'setter' ) ;
573575 const limits = this . _getActivePartLimits ( ) ;
@@ -580,8 +582,8 @@ class DateBoxMask extends DateBoxBase {
580582 } else {
581583 newDateValue [ setter ] ( newValue ) ;
582584 }
583- this . _renderDisplayText ( this . _getDisplayedText ( newDateValue ) ) ;
584585
586+ this . _renderDisplayText ( this . _getDisplayedText ( newDateValue ) ) ;
585587 this . _renderDateParts ( ) ;
586588 }
587589
0 commit comments