Skip to content

Commit ea1138b

Browse files
authored
feat(module:input-number): add borderless support (#7539)
Co-authored-by: Sébastien Cambon <sebastien.cambon@altoviz.com>
1 parent 64b7389 commit ea1138b

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
order: 0
3+
title:
4+
zh-CN: 无边框
5+
en-US: Borderless
6+
---
7+
8+
## zh-CN
9+
10+
没有边框。
11+
12+
## en-US
13+
14+
Borderless input number.
15+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'nz-demo-input-number-borderless',
5+
template: ` <nz-input-number nzBorderless [(ngModel)]="demoValue"></nz-input-number> `
6+
})
7+
export class NzDemoInputNumberBorderlessComponent {
8+
demoValue = 3;
9+
}

components/input-number/input-number.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ import { getStatusClassNames, InputBoolean, isNotNil } from 'ng-zorro-antd/core/
109109
'[class.ant-input-number-sm]': `nzSize === 'small'`,
110110
'[class.ant-input-number-disabled]': 'nzDisabled',
111111
'[class.ant-input-number-readonly]': 'nzReadOnly',
112-
'[class.ant-input-number-rtl]': `dir === 'rtl'`
112+
'[class.ant-input-number-rtl]': `dir === 'rtl'`,
113+
'[class.ant-input-number-borderless]': `nzBorderless`
113114
}
114115
})
115116
export class NzInputNumberComponent implements ControlValueAccessor, AfterViewInit, OnChanges, OnInit, OnDestroy {
116117
static ngAcceptInputType_nzDisabled: BooleanInput;
117118
static ngAcceptInputType_nzReadOnly: BooleanInput;
118119
static ngAcceptInputType_nzAutoFocus: BooleanInput;
120+
static ngAcceptInputType_nzBorderless: BooleanInput;
119121

120122
private autoStepTimer?: number;
121123
private parsedValue?: string | number;
@@ -133,6 +135,7 @@ export class NzInputNumberComponent implements ControlValueAccessor, AfterViewIn
133135
hasFeedback: boolean = false;
134136
onChange: OnChangeType = () => {};
135137
onTouched: OnTouchedType = () => {};
138+
136139
@Output() readonly nzBlur = new EventEmitter();
137140
@Output() readonly nzFocus = new EventEmitter();
138141
/** The native `<span class="ant-input-number-handler-up"></span>` element. */
@@ -159,6 +162,7 @@ export class NzInputNumberComponent implements ControlValueAccessor, AfterViewIn
159162
@Input() @InputBoolean() nzDisabled = false;
160163
@Input() @InputBoolean() nzReadOnly = false;
161164
@Input() @InputBoolean() nzAutoFocus = false;
165+
@Input() @InputBoolean() nzBorderless: boolean = false;
162166
@Input() nzFormatter: (value: number) => string | number = value => value;
163167

164168
onModelChange(value: string): void {

components/input-number/input-number.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ describe('input number', () => {
6363
expect(inputNumber.nativeElement.classList).toContain('ant-input-number');
6464
expect(inputElement.getAttribute('placeholder')).toBe('placeholder');
6565
});
66+
it('should border work', () => {
67+
fixture.detectChanges();
68+
expect(inputNumber.nativeElement!.classList).not.toContain('ant-input-number-borderless');
69+
testComponent.bordered = false;
70+
fixture.detectChanges();
71+
expect(inputNumber.nativeElement!.classList).toContain('ant-input-number-borderless');
72+
});
6673
it('should focus className correct', fakeAsync(() => {
6774
fixture.detectChanges();
6875
expect(inputNumber.nativeElement.classList).toContain('ng-untouched');
@@ -608,6 +615,7 @@ describe('input number', () => {
608615
[nzParser]="parser"
609616
[nzPrecision]="precision"
610617
[nzPrecisionMode]="precisionMode"
618+
[nzBorderless]="!bordered"
611619
></nz-input-number>
612620
`
613621
})
@@ -621,6 +629,7 @@ export class NzTestInputNumberBasicComponent {
621629
size = 'default';
622630
placeholder = 'placeholder';
623631
step = 1;
632+
bordered = true;
624633
precision?: number = 2;
625634
precisionMode?: 'cut' | 'toFixed' | ((value: number | string, precision?: number) => number);
626635
formatter = (value: number): string => (value !== null ? `${value}` : '');

0 commit comments

Comments
 (0)