@@ -71,9 +71,6 @@ interface ColumnSpecificSectionContentState {
7171 showTimeZone : boolean ;
7272 showTSeparator : boolean ;
7373 timeZone : string ;
74- defaultDateTimeFormat : string ;
75- defaultDecimalFormatOptions : FormatOption ;
76- defaultIntegerFormatOptions : FormatOption ;
7774 truncateNumbersWithPound : boolean ;
7875 timestampAtMenuOpen : Date ;
7976}
@@ -116,9 +113,6 @@ export class ColumnSpecificSectionContent extends PureComponent<
116113
117114 const {
118115 formatter,
119- defaultDateTimeFormat,
120- defaultDecimalFormatOptions,
121- defaultIntegerFormatOptions,
122116 showTimeZone,
123117 showTSeparator,
124118 timeZone,
@@ -141,9 +135,6 @@ export class ColumnSpecificSectionContent extends PureComponent<
141135 showTimeZone,
142136 showTSeparator,
143137 timeZone,
144- defaultDateTimeFormat,
145- defaultDecimalFormatOptions,
146- defaultIntegerFormatOptions,
147138 truncateNumbersWithPound,
148139 timestampAtMenuOpen : new Date ( ) ,
149140 } ;
@@ -221,7 +212,7 @@ export class ColumnSpecificSectionContent extends PureComponent<
221212 let resetKeys = { } ;
222213 if ( key === 'columnType' ) {
223214 resetKeys = {
224- format : '' ,
215+ format : this . makeDefaultFormatterItemByType ( value as string ) ,
225216 } ;
226217 }
227218 const newEntry = {
@@ -284,14 +275,18 @@ export class ColumnSpecificSectionContent extends PureComponent<
284275 commitChanges ( ) : void {
285276 const {
286277 formatSettings,
287- defaultDateTimeFormat,
288278 showTimeZone,
289279 showTSeparator,
290280 timeZone,
291- defaultDecimalFormatOptions,
292- defaultIntegerFormatOptions,
293281 truncateNumbersWithPound,
294282 } = this . state ;
283+
284+ const {
285+ defaultDateTimeFormat,
286+ defaultDecimalFormatOptions,
287+ defaultIntegerFormatOptions,
288+ } = this . props ;
289+
295290 const { dh } = this . props ;
296291
297292 const formatter =
@@ -390,6 +385,41 @@ export class ColumnSpecificSectionContent extends PureComponent<
390385 return error ;
391386 }
392387
388+ makeDefaultFormatterItemByType (
389+ columnType : string
390+ ) : TableColumnFormat | string {
391+ switch ( TableUtils . getNormalizedType ( columnType ) ) {
392+ case TableUtils . dataType . INT : {
393+ const { defaultIntegerFormatOptions } = this . props ;
394+ const { defaultFormatString : defaultIntegerFormatString } =
395+ defaultIntegerFormatOptions ;
396+ return IntegerColumnFormatter . makeFormat (
397+ '' ,
398+ defaultIntegerFormatString ??
399+ IntegerColumnFormatter . DEFAULT_FORMAT_STRING ,
400+ IntegerColumnFormatter . TYPE_GLOBAL ,
401+ undefined
402+ ) ;
403+ }
404+
405+ case TableUtils . dataType . DECIMAL : {
406+ const { defaultDecimalFormatOptions } = this . props ;
407+ const { defaultFormatString : defaultDecimalFormatString } =
408+ defaultDecimalFormatOptions ;
409+ return DecimalColumnFormatter . makeFormat (
410+ '' ,
411+ defaultDecimalFormatString ??
412+ DecimalColumnFormatter . DEFAULT_FORMAT_STRING ,
413+ DecimalColumnFormatter . TYPE_GLOBAL ,
414+ undefined
415+ ) ;
416+ }
417+ default : {
418+ return '' ;
419+ }
420+ }
421+ }
422+
393423 renderFormatRule ( i : number , rule : FormatterItem ) : ReactElement {
394424 const columnNameId = `input-${ i } -columnName` ;
395425 const columnTypeId = `input-${ i } -columnType` ;
@@ -401,6 +431,7 @@ export class ColumnSpecificSectionContent extends PureComponent<
401431 this . handleFormatRuleChange ( i , 'isNewRule' , false ) ;
402432 const onTypeChange = ( e : ChangeEvent < HTMLSelectElement > ) : void =>
403433 this . handleFormatRuleChange ( i , 'columnType' , e . target . value ) ;
434+
404435 const ruleError = this . getRuleError ( rule ) ;
405436
406437 return (
@@ -511,6 +542,7 @@ export class ColumnSpecificSectionContent extends PureComponent<
511542 isInvalid : boolean
512543 ) : ReactElement {
513544 const { showTimeZone, showTSeparator, timeZone } = this . state ;
545+
514546 const value = format . formatString ?? '' ;
515547 return (
516548 < select
@@ -544,6 +576,8 @@ export class ColumnSpecificSectionContent extends PureComponent<
544576 format : Partial < TableColumnFormat > ,
545577 isInvalid : boolean
546578 ) : ReactElement {
579+ const { defaultIntegerFormatOptions } = this . props ;
580+ const { defaultFormatString } = defaultIntegerFormatOptions ;
547581 const value = format . formatString ?? '' ;
548582 return (
549583 < input
@@ -552,7 +586,9 @@ export class ColumnSpecificSectionContent extends PureComponent<
552586 } ) }
553587 data-lpignore
554588 id = { formatId }
555- placeholder = { IntegerColumnFormatter . DEFAULT_FORMAT_STRING }
589+ placeholder = {
590+ defaultFormatString ?? IntegerColumnFormatter . DEFAULT_FORMAT_STRING
591+ }
556592 type = "text"
557593 value = { value }
558594 onChange = { e => {
@@ -574,6 +610,9 @@ export class ColumnSpecificSectionContent extends PureComponent<
574610 format : Partial < TableColumnFormat > ,
575611 isInvalid : boolean
576612 ) : ReactElement {
613+ const { defaultDecimalFormatOptions } = this . props ;
614+ const { defaultFormatString } = defaultDecimalFormatOptions ;
615+
577616 const value = format . formatString ?? '' ;
578617 return (
579618 < input
@@ -582,7 +621,9 @@ export class ColumnSpecificSectionContent extends PureComponent<
582621 } ) }
583622 data-lpignore
584623 id = { formatId }
585- placeholder = { DecimalColumnFormatter . DEFAULT_FORMAT_STRING }
624+ placeholder = {
625+ defaultFormatString ?? DecimalColumnFormatter . DEFAULT_FORMAT_STRING
626+ }
586627 type = "text"
587628 value = { value }
588629 onChange = { e => {
0 commit comments