@@ -12,6 +12,7 @@ import {
1212 isDefined , isFunction , isNumeric , isString ,
1313} from '@js/core/utils/type' ;
1414import type { Properties } from '@js/ui/number_box' ;
15+ import { getGlobalFormatByDataType } from '@ts/core/m_global_format_config' ;
1516
1617import NumberBoxBase from './m_number_box.base' ;
1718import {
@@ -92,9 +93,18 @@ class NumberBoxMask extends NumberBoxBase<NumberBoxMaskProperties> {
9293 } ;
9394 }
9495
96+ _getEffectiveFormatOption ( ) {
97+ const format = this . option ( 'format' ) ;
98+ return isDefined ( format )
99+ ? format
100+ : getGlobalFormatByDataType ( 'number' ) ;
101+ }
102+
95103 _getTextSeparatorIndex ( text ) {
96104 const decimalSeparator = number . getDecimalSeparator ( ) ;
97- const realSeparatorOccurrenceIndex = getRealSeparatorIndex ( this . option ( 'format' ) ) . occurrence ;
105+ const formatPattern = this . _getFormatPattern ( ) ;
106+ const patternString = isString ( formatPattern ) ? formatPattern : '' ;
107+ const realSeparatorOccurrenceIndex = getRealSeparatorIndex ( patternString ) . occurrence ;
98108 return getNthOccurrence ( text , decimalSeparator , realSeparatorOccurrenceIndex ) ;
99109 }
100110
@@ -336,10 +346,8 @@ class NumberBoxMask extends NumberBoxBase<NumberBoxMaskProperties> {
336346 }
337347
338348 _parse ( text , format ) {
339- const formatOption = this . option ( 'format' ) ;
340- // @ts -expect-error ts-error
349+ const formatOption = this . _getEffectiveFormatOption ( ) ;
341350 const isCustomParser = isFunction ( formatOption . parser ) ;
342- // @ts -expect-error ts-error
343351 const parser = isCustomParser ? formatOption . parser : number . parse ;
344352 let integerPartStartIndex = 0 ;
345353
@@ -361,8 +369,7 @@ class NumberBoxMask extends NumberBoxBase<NumberBoxMaskProperties> {
361369 }
362370
363371 _format ( value , format ) {
364- const formatOption = this . option ( 'format' ) ;
365- // @ts -expect-error ts-error
372+ const formatOption = this . _getEffectiveFormatOption ( ) ;
366373 const customFormatter = formatOption ?. formatter || formatOption ;
367374 const formatter = isFunction ( customFormatter ) ? customFormatter : number . format ;
368375
@@ -380,11 +387,9 @@ class NumberBoxMask extends NumberBoxBase<NumberBoxMaskProperties> {
380387 }
381388
382389 _updateFormat ( ) : void {
383- const { format } = this . option ( ) ;
384- // @ts -expect-error ts-error
390+ const format = this . _getEffectiveFormatOption ( ) ;
385391 const isCustomParser = isFunction ( format ?. parser ) ;
386392 const isLDMLPattern = isString ( format ) && ( format . includes ( '0' ) || format . includes ( '#' ) ) ;
387- // @ts -expect-error ts-error
388393 const isExponentialFormat = format === 'exponential' || format ?. type === 'exponential' ;
389394 const shouldUseFormatAsIs = isCustomParser || isLDMLPattern || isExponentialFormat ;
390395
@@ -568,8 +573,7 @@ class NumberBoxMask extends NumberBoxBase<NumberBoxMaskProperties> {
568573
569574 _useMaskBehavior ( ) : boolean {
570575 const { useMaskBehavior } = this . option ( ) ;
571- // @ts -expect-error ts-error
572- return ! ! this . option ( 'format' ) && useMaskBehavior ;
576+ return ! ! this . _getEffectiveFormatOption ( ) && ! ! useMaskBehavior ;
573577 }
574578
575579 _renderInputType ( ) : void {
0 commit comments