@pumpkin-tech/pumpkin-tech-ng 0.2.19 → 0.2.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4295,9 +4295,9 @@ class InputCurrencyComponent extends BaseField {
4295
4295
  return this.getIntlFormatter(precision).format(value);
4296
4296
  }
4297
4297
  onInput(raw) {
4298
- this.displayValue = raw;
4299
- const parsed = this.parseToNumber(raw);
4298
+ const parsed = this.parseInputAsCurrencyValue(raw);
4300
4299
  this._val = parsed;
4300
+ this.displayValue = this.formatNumber(this._val);
4301
4301
  this.onChange(parsed);
4302
4302
  this.valueChange.emit(parsed);
4303
4303
  }
@@ -4407,6 +4407,25 @@ class InputCurrencyComponent extends BaseField {
4407
4407
  return Number.NaN;
4408
4408
  return sign * Number(integerOnly);
4409
4409
  }
4410
+ parseInputAsCurrencyValue(value) {
4411
+ const nullableFallback = this.resolvedOptions.nullable === false ? 0 : null;
4412
+ const precision = Math.max(0, this.resolvedOptions.precision ?? 2);
4413
+ const normalized = this.normalizeInput(value);
4414
+ const sign = normalized.includes('-') ? -1 : 1;
4415
+ const digits = normalized.replace(/[^\d]/g, '');
4416
+ if (!digits)
4417
+ return nullableFallback;
4418
+ const factor = Math.pow(10, precision);
4419
+ const parsed = precision > 0 ? Number(digits) / factor : Number(digits);
4420
+ const valueAsNumber = sign * parsed;
4421
+ if (!Number.isFinite(valueAsNumber))
4422
+ return nullableFallback;
4423
+ if (!this.resolvedOptions.allowNegative && valueAsNumber < 0)
4424
+ return nullableFallback;
4425
+ if (!this.resolvedOptions.allowZero && valueAsNumber === 0)
4426
+ return nullableFallback;
4427
+ return valueAsNumber;
4428
+ }
4410
4429
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: InputCurrencyComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
4411
4430
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: InputCurrencyComponent, isStandalone: true, selector: "ptech-input-currency", inputs: { options: "options" }, outputs: { valueChange: "valueChange" }, providers: [{
4412
4431
  provide: NG_VALUE_ACCESSOR,
@@ -4415,7 +4434,7 @@ class InputCurrencyComponent extends BaseField {
4415
4434
  }], usesInheritance: true, ngImport: i0, template: `
4416
4435
  <div class="ptech-currency-container" [class.full-width]="fullWidth">
4417
4436
  <mat-form-field class="ptech-form-field" [appearance]="appearance">
4418
- <mat-label>
4437
+ <mat-label *ngIf="label">
4419
4438
  {{ label }}
4420
4439
  <span *ngIf="required" aria-hidden="true">*</span>
4421
4440
  </mat-label>
@@ -4452,7 +4471,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
4452
4471
  args: [{ selector: 'ptech-input-currency', imports: [CoreMaterialModule], template: `
4453
4472
  <div class="ptech-currency-container" [class.full-width]="fullWidth">
4454
4473
  <mat-form-field class="ptech-form-field" [appearance]="appearance">
4455
- <mat-label>
4474
+ <mat-label *ngIf="label">
4456
4475
  {{ label }}
4457
4476
  <span *ngIf="required" aria-hidden="true">*</span>
4458
4477
  </mat-label>