|
|
@ -6,7 +6,8 @@ import { |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectionStrategy, |
|
|
Component, |
|
|
Component, |
|
|
Input, |
|
|
Input, |
|
|
OnChanges |
|
|
OnChanges, |
|
|
|
|
|
input |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
import { IonIcon } from '@ionic/angular/standalone'; |
|
|
import { IonIcon } from '@ionic/angular/standalone'; |
|
|
import { isNumber } from 'lodash'; |
|
|
import { isNumber } from 'lodash'; |
|
|
@ -30,7 +31,6 @@ export class GfValueComponent implements OnChanges { |
|
|
@Input() isPercent = false; |
|
|
@Input() isPercent = false; |
|
|
@Input() locale: string; |
|
|
@Input() locale: string; |
|
|
@Input() position = ''; |
|
|
@Input() position = ''; |
|
|
@Input() precision?: number; |
|
|
|
|
|
@Input() size: 'large' | 'medium' | 'small' = 'small'; |
|
|
@Input() size: 'large' | 'medium' | 'small' = 'small'; |
|
|
@Input() subLabel = ''; |
|
|
@Input() subLabel = ''; |
|
|
@Input() unit = ''; |
|
|
@Input() unit = ''; |
|
|
@ -42,8 +42,11 @@ export class GfValueComponent implements OnChanges { |
|
|
public isString = false; |
|
|
public isString = false; |
|
|
public useAbsoluteValue = false; |
|
|
public useAbsoluteValue = false; |
|
|
|
|
|
|
|
|
|
|
|
protected readonly precision = input<number>(); |
|
|
|
|
|
|
|
|
private get hasPrecision(): boolean { |
|
|
private get hasPrecision(): boolean { |
|
|
return this.precision !== undefined && this.precision >= 0; |
|
|
const precision = this.precision(); |
|
|
|
|
|
return precision !== undefined && precision >= 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ngOnChanges() { |
|
|
public ngOnChanges() { |
|
|
@ -127,7 +130,7 @@ export class GfValueComponent implements OnChanges { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private getFormatOptions(): Intl.NumberFormatOptions { |
|
|
private getFormatOptions(): Intl.NumberFormatOptions { |
|
|
const digits = this.hasPrecision ? this.precision : 2; |
|
|
const digits = this.hasPrecision ? this.precision() : 2; |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
maximumFractionDigits: digits, |
|
|
maximumFractionDigits: digits, |
|
|
@ -141,7 +144,6 @@ export class GfValueComponent implements OnChanges { |
|
|
this.isNumber = false; |
|
|
this.isNumber = false; |
|
|
this.isString = false; |
|
|
this.isString = false; |
|
|
this.locale = this.locale || getLocale(); |
|
|
this.locale = this.locale || getLocale(); |
|
|
this.precision = this.hasPrecision ? this.precision : undefined; |
|
|
|
|
|
this.useAbsoluteValue = false; |
|
|
this.useAbsoluteValue = false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|