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

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,
@@ -4414,8 +4433,8 @@ class InputCurrencyComponent extends BaseField {
4414
4433
  multi: true
4415
4434
  }], usesInheritance: true, ngImport: i0, template: `
4416
4435
  <div class="ptech-currency-container" [class.full-width]="fullWidth">
4417
- <mat-form-field class="ptech-form-field" [appearance]="appearance">
4418
- <mat-label>
4436
+ <mat-form-field class="ptech-form-field" [class.no-label]="!label" [appearance]="appearance">
4437
+ <mat-label *ngIf="label">
4419
4438
  {{ label }}
4420
4439
  <span *ngIf="required" aria-hidden="true">*</span>
4421
4440
  </mat-label>
@@ -4445,14 +4464,14 @@ class InputCurrencyComponent extends BaseField {
4445
4464
  <ng-content select="mat-hint, [mat-hint], mat-error, [mat-error]"></ng-content>
4446
4465
  </mat-form-field>
4447
4466
  </div>
4448
- `, isInline: true, styles: [".ptech-currency-container{display:flex;flex-direction:column;width:100%}.ptech-form-field{width:100%}:host ::ng-deep .ptech-form-field .mdc-text-field{background-color:var(--ptech-field-bg, var(--app-surface, transparent));color:var(--ptech-field-text, var(--app-text, inherit));--mdc-outlined-text-field-outline-color: var(--ptech-field-outline, var(--app-border-color, rgba(0,0,0,.38)));--mdc-outlined-text-field-hover-outline-color: var(--ptech-field-outline-hover, var(--app-text, rgba(0,0,0,.87)));--mdc-outlined-text-field-focus-outline-color: var(--ptech-field-outline-focus, var(--app-text, #3f51b5))}:host ::ng-deep .ptech-form-field .mdc-text-field .mdc-notched-outline__leading,:host ::ng-deep .ptech-form-field .mdc-text-field .mdc-notched-outline__notch,:host ::ng-deep .ptech-form-field .mdc-text-field .mdc-notched-outline__trailing{border-color:var(--ptech-field-outline, var(--app-border-color, rgba(0,0,0,.38)))!important}:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__leading,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__notch,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__trailing{border-color:var(--ptech-field-outline-hover, var(--app-text, rgba(0,0,0,.87)))!important}:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__leading,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__notch,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__trailing{border-color:var(--ptech-field-outline-focus, var(--app-text, #3f51b5))!important}:host ::ng-deep .ptech-form-field .mat-mdc-input-element,:host ::ng-deep .ptech-form-field .mdc-text-field__input{color:var(--ptech-field-text, var(--app-text, inherit))!important;caret-color:var(--ptech-field-text, var(--app-text, inherit))!important}:host ::ng-deep .ptech-form-field input::placeholder,:host ::ng-deep .ptech-form-field textarea::placeholder,:host ::ng-deep .ptech-form-field .mat-mdc-input-element::placeholder,:host ::ng-deep .ptech-form-field .mdc-text-field__input::placeholder{color:var(--ptech-field-placeholder, var(--app-text, inherit))!important;opacity:1!important}:host ::ng-deep .ptech-form-field .mdc-floating-label,:host ::ng-deep .ptech-form-field .mdc-floating-label--float-above{color:var(--ptech-field-label, var(--app-text, inherit))!important}mat-label span{color:var(--ptech-required-color, var(--app-status-error, #f44336))!important}\n"], dependencies: [{ kind: "ngmodule", type: CoreMaterialModule }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatPrefix, selector: "[matPrefix], [matIconPrefix], [matTextPrefix]", inputs: ["matTextPrefix"] }, { kind: "directive", type: i4.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: i5.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
4467
+ `, isInline: true, styles: [".ptech-currency-container{display:flex;flex-direction:column;width:100%}.ptech-form-field{width:100%}:host ::ng-deep .ptech-form-field .mdc-text-field{background-color:var(--ptech-field-bg, var(--app-surface, transparent));color:var(--ptech-field-text, var(--app-text, inherit));--mdc-outlined-text-field-outline-color: var(--ptech-field-outline, var(--app-border-color, rgba(0,0,0,.38)));--mdc-outlined-text-field-hover-outline-color: var(--ptech-field-outline-hover, var(--app-text, rgba(0,0,0,.87)));--mdc-outlined-text-field-focus-outline-color: var(--ptech-field-outline-focus, var(--app-text, #3f51b5))}:host ::ng-deep .ptech-form-field .mdc-text-field .mdc-notched-outline__leading,:host ::ng-deep .ptech-form-field .mdc-text-field .mdc-notched-outline__notch,:host ::ng-deep .ptech-form-field .mdc-text-field .mdc-notched-outline__trailing{border-color:var(--ptech-field-outline, var(--app-border-color, rgba(0,0,0,.38)))!important}:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__leading,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__notch,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__trailing{border-color:var(--ptech-field-outline-hover, var(--app-text, rgba(0,0,0,.87)))!important}:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__leading,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__notch,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__trailing{border-color:var(--ptech-field-outline-focus, var(--app-text, #3f51b5))!important}:host ::ng-deep .ptech-form-field.no-label .mdc-notched-outline__notch{border-top:1px solid var(--ptech-field-outline, var(--app-border-color, rgba(0,0,0,.38)))!important}:host ::ng-deep .ptech-form-field.no-label .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__notch{border-top-color:var(--ptech-field-outline-hover, var(--app-text, rgba(0,0,0,.87)))!important}:host ::ng-deep .ptech-form-field.no-label .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__notch{border-top-color:var(--ptech-field-outline-focus, var(--app-text, #3f51b5))!important}:host ::ng-deep .ptech-form-field .mat-mdc-input-element,:host ::ng-deep .ptech-form-field .mdc-text-field__input{color:var(--ptech-field-text, var(--app-text, inherit))!important;caret-color:var(--ptech-field-text, var(--app-text, inherit))!important}:host ::ng-deep .ptech-form-field input::placeholder,:host ::ng-deep .ptech-form-field textarea::placeholder,:host ::ng-deep .ptech-form-field .mat-mdc-input-element::placeholder,:host ::ng-deep .ptech-form-field .mdc-text-field__input::placeholder{color:var(--ptech-field-placeholder, var(--app-text, inherit))!important;opacity:1!important}:host ::ng-deep .ptech-form-field .mdc-floating-label,:host ::ng-deep .ptech-form-field .mdc-floating-label--float-above{color:var(--ptech-field-label, var(--app-text, inherit))!important}mat-label span{color:var(--ptech-required-color, var(--app-status-error, #f44336))!important}\n"], dependencies: [{ kind: "ngmodule", type: CoreMaterialModule }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatPrefix, selector: "[matPrefix], [matIconPrefix], [matTextPrefix]", inputs: ["matTextPrefix"] }, { kind: "directive", type: i4.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: i5.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
4449
4468
  }
4450
4469
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: InputCurrencyComponent, decorators: [{
4451
4470
  type: Component,
4452
4471
  args: [{ selector: 'ptech-input-currency', imports: [CoreMaterialModule], template: `
4453
4472
  <div class="ptech-currency-container" [class.full-width]="fullWidth">
4454
- <mat-form-field class="ptech-form-field" [appearance]="appearance">
4455
- <mat-label>
4473
+ <mat-form-field class="ptech-form-field" [class.no-label]="!label" [appearance]="appearance">
4474
+ <mat-label *ngIf="label">
4456
4475
  {{ label }}
4457
4476
  <span *ngIf="required" aria-hidden="true">*</span>
4458
4477
  </mat-label>
@@ -4486,7 +4505,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
4486
4505
  provide: NG_VALUE_ACCESSOR,
4487
4506
  useExisting: forwardRef(() => InputCurrencyComponent),
4488
4507
  multi: true
4489
- }], changeDetection: ChangeDetectionStrategy.OnPush, styles: [".ptech-currency-container{display:flex;flex-direction:column;width:100%}.ptech-form-field{width:100%}:host ::ng-deep .ptech-form-field .mdc-text-field{background-color:var(--ptech-field-bg, var(--app-surface, transparent));color:var(--ptech-field-text, var(--app-text, inherit));--mdc-outlined-text-field-outline-color: var(--ptech-field-outline, var(--app-border-color, rgba(0,0,0,.38)));--mdc-outlined-text-field-hover-outline-color: var(--ptech-field-outline-hover, var(--app-text, rgba(0,0,0,.87)));--mdc-outlined-text-field-focus-outline-color: var(--ptech-field-outline-focus, var(--app-text, #3f51b5))}:host ::ng-deep .ptech-form-field .mdc-text-field .mdc-notched-outline__leading,:host ::ng-deep .ptech-form-field .mdc-text-field .mdc-notched-outline__notch,:host ::ng-deep .ptech-form-field .mdc-text-field .mdc-notched-outline__trailing{border-color:var(--ptech-field-outline, var(--app-border-color, rgba(0,0,0,.38)))!important}:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__leading,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__notch,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__trailing{border-color:var(--ptech-field-outline-hover, var(--app-text, rgba(0,0,0,.87)))!important}:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__leading,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__notch,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__trailing{border-color:var(--ptech-field-outline-focus, var(--app-text, #3f51b5))!important}:host ::ng-deep .ptech-form-field .mat-mdc-input-element,:host ::ng-deep .ptech-form-field .mdc-text-field__input{color:var(--ptech-field-text, var(--app-text, inherit))!important;caret-color:var(--ptech-field-text, var(--app-text, inherit))!important}:host ::ng-deep .ptech-form-field input::placeholder,:host ::ng-deep .ptech-form-field textarea::placeholder,:host ::ng-deep .ptech-form-field .mat-mdc-input-element::placeholder,:host ::ng-deep .ptech-form-field .mdc-text-field__input::placeholder{color:var(--ptech-field-placeholder, var(--app-text, inherit))!important;opacity:1!important}:host ::ng-deep .ptech-form-field .mdc-floating-label,:host ::ng-deep .ptech-form-field .mdc-floating-label--float-above{color:var(--ptech-field-label, var(--app-text, inherit))!important}mat-label span{color:var(--ptech-required-color, var(--app-status-error, #f44336))!important}\n"] }]
4508
+ }], changeDetection: ChangeDetectionStrategy.OnPush, styles: [".ptech-currency-container{display:flex;flex-direction:column;width:100%}.ptech-form-field{width:100%}:host ::ng-deep .ptech-form-field .mdc-text-field{background-color:var(--ptech-field-bg, var(--app-surface, transparent));color:var(--ptech-field-text, var(--app-text, inherit));--mdc-outlined-text-field-outline-color: var(--ptech-field-outline, var(--app-border-color, rgba(0,0,0,.38)));--mdc-outlined-text-field-hover-outline-color: var(--ptech-field-outline-hover, var(--app-text, rgba(0,0,0,.87)));--mdc-outlined-text-field-focus-outline-color: var(--ptech-field-outline-focus, var(--app-text, #3f51b5))}:host ::ng-deep .ptech-form-field .mdc-text-field .mdc-notched-outline__leading,:host ::ng-deep .ptech-form-field .mdc-text-field .mdc-notched-outline__notch,:host ::ng-deep .ptech-form-field .mdc-text-field .mdc-notched-outline__trailing{border-color:var(--ptech-field-outline, var(--app-border-color, rgba(0,0,0,.38)))!important}:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__leading,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__notch,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__trailing{border-color:var(--ptech-field-outline-hover, var(--app-text, rgba(0,0,0,.87)))!important}:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__leading,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__notch,:host ::ng-deep .ptech-form-field .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__trailing{border-color:var(--ptech-field-outline-focus, var(--app-text, #3f51b5))!important}:host ::ng-deep .ptech-form-field.no-label .mdc-notched-outline__notch{border-top:1px solid var(--ptech-field-outline, var(--app-border-color, rgba(0,0,0,.38)))!important}:host ::ng-deep .ptech-form-field.no-label .mdc-text-field.mdc-text-field--hover .mdc-notched-outline__notch{border-top-color:var(--ptech-field-outline-hover, var(--app-text, rgba(0,0,0,.87)))!important}:host ::ng-deep .ptech-form-field.no-label .mdc-text-field.mdc-text-field--focused .mdc-notched-outline__notch{border-top-color:var(--ptech-field-outline-focus, var(--app-text, #3f51b5))!important}:host ::ng-deep .ptech-form-field .mat-mdc-input-element,:host ::ng-deep .ptech-form-field .mdc-text-field__input{color:var(--ptech-field-text, var(--app-text, inherit))!important;caret-color:var(--ptech-field-text, var(--app-text, inherit))!important}:host ::ng-deep .ptech-form-field input::placeholder,:host ::ng-deep .ptech-form-field textarea::placeholder,:host ::ng-deep .ptech-form-field .mat-mdc-input-element::placeholder,:host ::ng-deep .ptech-form-field .mdc-text-field__input::placeholder{color:var(--ptech-field-placeholder, var(--app-text, inherit))!important;opacity:1!important}:host ::ng-deep .ptech-form-field .mdc-floating-label,:host ::ng-deep .ptech-form-field .mdc-floating-label--float-above{color:var(--ptech-field-label, var(--app-text, inherit))!important}mat-label span{color:var(--ptech-required-color, var(--app-status-error, #f44336))!important}\n"] }]
4490
4509
  }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { options: [{
4491
4510
  type: Input
4492
4511
  }], valueChange: [{