Skip to content

Commit a8f4699

Browse files
committed
fix(input-number): avoid redundant calculation
1 parent 5c1e54d commit a8f4699

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

packages/primeng/src/badge/badge.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
import { CommonModule } from '@angular/common';
2-
import { AfterViewInit, booleanAttribute, ChangeDetectionStrategy, Component, computed, Directive, inject, Input, input, NgModule, OnChanges, SimpleChanges, ViewEncapsulation } from '@angular/core';
2+
import {
3+
AfterViewInit,
4+
booleanAttribute,
5+
ChangeDetectionStrategy,
6+
Component,
7+
computed,
8+
Directive,
9+
inject,
10+
Input,
11+
input,
12+
NgModule,
13+
OnChanges,
14+
SimpleChanges,
15+
ViewEncapsulation
16+
} from '@angular/core';
317
import { addClass, hasClass, isEmpty, isNotEmpty, removeClass, uuid } from '@primeuix/utils';
418
import { SharedModule } from 'primeng/api';
519
import { BaseComponent } from 'primeng/basecomponent';
@@ -25,6 +39,7 @@ export class BadgeDirective extends BaseComponent implements OnChanges, AfterVie
2539
* @group Props
2640
*/
2741
@Input() public badgeSize: 'large' | 'xlarge' | 'small' | null | undefined;
42+
2843
/**
2944
* Size of the badge, valid options are "large" and "xlarge".
3045
* @group Props
@@ -34,9 +49,11 @@ export class BadgeDirective extends BaseComponent implements OnChanges, AfterVie
3449
this._size = value;
3550
console.log('size property is deprecated and will removed in v18, use badgeSize instead.');
3651
}
52+
3753
get size() {
3854
return this._size;
3955
}
56+
4057
_size: 'large' | 'xlarge' | 'small' | null | undefined;
4158
/**
4259
* Severity type of the badge.
@@ -235,6 +252,7 @@ export class BadgeDirective extends BaseComponent implements OnChanges, AfterVie
235252
}
236253
}
237254
}
255+
238256
/**
239257
* Badge is a small status indicator for another element.
240258
* @group Components
@@ -278,7 +296,7 @@ export class Badge extends BaseComponent {
278296
* Severity type of the badge.
279297
* @group Props
280298
*/
281-
severity = input<'secondary' | 'info' | 'success' | 'warn' | 'danger' | 'contrast' | null>();
299+
severity = input<'secondary' | 'info' | 'success' | 'warn' | 'danger' | 'contrast' | 'primary' | 'help' | null>();
282300
/**
283301
* Value to display inside the badge.
284302
* @group Props

packages/primeng/src/inputnumber/inputnumber.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const INPUTNUMBER_VALUE_ACCESSOR: any = {
4040
useExisting: forwardRef(() => InputNumber),
4141
multi: true
4242
};
43+
4344
/**
4445
* InputNumber is an input component to provide numerical input.
4546
* @group Components
@@ -402,20 +403,23 @@ export class InputNumber extends BaseComponent implements OnInit, AfterContentIn
402403
* @group Props
403404
*/
404405
@Input({ transform: booleanAttribute }) autofocus: boolean | undefined;
406+
405407
/**
406408
* When present, it specifies that the element should be disabled.
407409
* @group Props
408410
*/
409411
@Input() get disabled(): boolean | undefined {
410412
return this._disabled;
411413
}
414+
412415
set disabled(disabled: boolean | undefined) {
413416
if (disabled) this.focused = false;
414417

415418
this._disabled = disabled;
416419

417420
if (this.timer) this.clearTimer();
418421
}
422+
419423
/**
420424
* Spans 100% width of the container when enabled.
421425
* @group Props
@@ -639,6 +643,7 @@ export class InputNumber extends BaseComponent implements OnInit, AfterContentIn
639643
const decimalChar = this.getDecimalChar();
640644
return new RegExp(`[${decimalChar}]`, 'g');
641645
}
646+
642647
getDecimalChar(): string {
643648
const formatter = new Intl.NumberFormat(this.locale, { ...this.getOptions(), useGrouping: false });
644649
return formatter
@@ -1516,7 +1521,7 @@ export class InputNumber extends BaseComponent implements OnInit, AfterContentIn
15161521
writeValue(value: any): void {
15171522
this.value = value ? Number(value) : value;
15181523
if (this.input) {
1519-
this.input.nativeElement.value = value ? Number(value) : value;
1524+
this.input.nativeElement.value = this.value ? String(this.value) : null;
15201525
}
15211526
this.cd.markForCheck();
15221527
}

0 commit comments

Comments
 (0)