-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: redesign the input-number (#8901)
* refactor(module:input-number): rename to input-number-legacy * docs: support deprecated tag * refactor(module:core): deprecated NzFormPatchModule * refactor(module:color-picker): fix input number parser type * feat(module:input): add addon & affix directives * feat(module:input-number): redesign the input-number
- Loading branch information
1 parent
a63549f
commit df55d88
Showing
70 changed files
with
2,388 additions
and
735 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 7 | ||
title: | ||
zh-CN: 前置/后置标签 | ||
en-US: Pre / Post tab | ||
--- | ||
|
||
## zh-CN | ||
|
||
用于配置一些固定组合。 | ||
|
||
## en-US | ||
|
||
Using pre & post tabs example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { NzCascaderModule } from 'ng-zorro-antd/cascader'; | ||
import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy'; | ||
import { NzSelectModule } from 'ng-zorro-antd/select'; | ||
import { NzSpaceModule } from 'ng-zorro-antd/space'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-input-number-legacy-addon', | ||
standalone: true, | ||
imports: [FormsModule, NzCascaderModule, NzInputNumberLegacyModule, NzSelectModule, NzSpaceModule], | ||
template: ` | ||
<nz-space nzDirection="vertical" style="width: 100%"> | ||
<nz-input-number-group *nzSpaceItem nzAddOnBefore="+" nzAddOnAfter="$"> | ||
<nz-input-number-legacy [(ngModel)]="value" [nzStep]="1"></nz-input-number-legacy> | ||
</nz-input-number-group> | ||
<nz-input-number-group *nzSpaceItem [nzAddOnBefore]="addOnBeforeTemplate" [nzAddOnAfter]="addOnAfterTemplate"> | ||
<nz-input-number-legacy [(ngModel)]="value" [nzStep]="1"></nz-input-number-legacy> | ||
</nz-input-number-group> | ||
<ng-template #addOnBeforeTemplate> | ||
<nz-select [ngModel]="'add'" style="width: 60px"> | ||
<nz-option nzLabel="+" nzValue="add"></nz-option> | ||
<nz-option nzLabel="-" nzValue="minus"></nz-option> | ||
</nz-select> | ||
</ng-template> | ||
<ng-template #addOnAfterTemplate> | ||
<nz-select [ngModel]="'USD'" style="width: 60px"> | ||
<nz-option nzValue="USD" nzLabel="$"></nz-option> | ||
<nz-option nzValue="EUR" nzLabel="€"></nz-option> | ||
<nz-option nzValue="GBP" nzLabel="£"></nz-option> | ||
<nz-option nzValue="CNY" nzLabel="¥"></nz-option> | ||
</nz-select> | ||
</ng-template> | ||
<nz-input-number-group *nzSpaceItem nzAddOnAfterIcon="setting"> | ||
<nz-input-number-legacy [(ngModel)]="value" [nzStep]="1"></nz-input-number-legacy> | ||
</nz-input-number-group> | ||
<nz-input-number-group *nzSpaceItem [nzAddOnBefore]="addOnBeforeCascaderTemplate"> | ||
<nz-input-number-legacy [(ngModel)]="value" [nzStep]="1"></nz-input-number-legacy> | ||
</nz-input-number-group> | ||
<ng-template #addOnBeforeCascaderTemplate> | ||
<nz-cascader [nzOptions]="[]" nzPlaceHolder="cascader" style="width: 150px"></nz-cascader> | ||
</ng-template> | ||
</nz-space> | ||
` | ||
}) | ||
export class NzDemoInputNumberLegacyAddonComponent { | ||
value = 100; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
order: 0 | ||
title: | ||
zh-CN: 基本 | ||
en-US: Basic | ||
--- | ||
|
||
## zh-CN | ||
|
||
数字输入框。 | ||
|
||
## en-US | ||
|
||
Numeric-only input box. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-input-number-legacy-basic', | ||
standalone: true, | ||
imports: [FormsModule, NzInputNumberLegacyModule], | ||
template: `<nz-input-number-legacy | ||
[(ngModel)]="value" | ||
[nzMin]="1" | ||
[nzMax]="10" | ||
[nzStep]="1" | ||
></nz-input-number-legacy>` | ||
}) | ||
export class NzDemoInputNumberLegacyBasicComponent { | ||
value = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
order: 0 | ||
title: | ||
zh-CN: 无边框 | ||
en-US: Borderless | ||
--- | ||
|
||
## zh-CN | ||
|
||
没有边框。 | ||
|
||
## en-US | ||
|
||
Borderless input number. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-input-number-legacy-borderless', | ||
standalone: true, | ||
imports: [FormsModule, NzInputNumberLegacyModule], | ||
template: `<nz-input-number-legacy nzBorderless [(ngModel)]="value"></nz-input-number-legacy>` | ||
}) | ||
export class NzDemoInputNumberLegacyBorderlessComponent { | ||
value = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
order: 3 | ||
title: | ||
zh-CN: 小数 | ||
en-US: Decimals | ||
--- | ||
|
||
## zh-CN | ||
|
||
和原生的数字输入框一样,value 的精度由 `nzStep` 的小数位数决定。 | ||
|
||
## en-US | ||
|
||
A numeric-only input box whose values can be increased or decreased using a decimal step. The number of decimals (also known as precision) is determined by the `nzStep` prop. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-input-number-legacy-digit', | ||
standalone: true, | ||
imports: [FormsModule, NzInputNumberLegacyModule], | ||
template: ` | ||
<nz-input-number-legacy | ||
[(ngModel)]="value" | ||
[nzMin]="1" | ||
[nzMax]="10" | ||
[nzStep]="0.1" | ||
[nzPlaceHolder]="'Digital'" | ||
></nz-input-number-legacy> | ||
` | ||
}) | ||
export class NzDemoInputNumberLegacyDigitComponent { | ||
value = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
order: 2 | ||
title: | ||
zh-CN: 不可用 | ||
en-US: Disabled | ||
--- | ||
|
||
## zh-CN | ||
|
||
点击按钮切换可用状态。 | ||
|
||
## en-US | ||
|
||
Click the button to toggle between available and disabled states. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { NzButtonModule } from 'ng-zorro-antd/button'; | ||
import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-input-number-legacy-disabled', | ||
standalone: true, | ||
imports: [FormsModule, NzButtonModule, NzInputNumberLegacyModule], | ||
template: ` | ||
<nz-input-number-legacy | ||
[(ngModel)]="value" | ||
[nzMin]="1" | ||
[nzMax]="10" | ||
[nzStep]="1" | ||
[nzDisabled]="isDisabled" | ||
></nz-input-number-legacy> | ||
<br /> | ||
<br /> | ||
<button nz-button [nzType]="'primary'" (click)="toggleDisabled()"> | ||
<span>Toggle Disabled</span> | ||
</button> | ||
` | ||
}) | ||
export class NzDemoInputNumberLegacyDisabledComponent { | ||
value = 3; | ||
isDisabled = false; | ||
|
||
toggleDisabled(): void { | ||
this.isDisabled = !this.isDisabled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
order: 4 | ||
title: | ||
zh-CN: 格式化展示 | ||
en-US: Formatter | ||
--- | ||
|
||
## zh-CN | ||
|
||
通过 `nzFormatter` 格式化数字,以展示具有具体含义的数据,往往需要配合 `nzParser` 一起使用。 | ||
|
||
## en-US | ||
|
||
Display value within it's situation with `nzFormatter`, and we usually use `nzParser` at the same time. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-input-number-legacy-formatter', | ||
standalone: true, | ||
imports: [FormsModule, NzInputNumberLegacyModule], | ||
template: ` | ||
<nz-input-number-legacy | ||
[(ngModel)]="demoValue" | ||
[nzMin]="1" | ||
[nzMax]="100" | ||
[nzStep]="1" | ||
[nzFormatter]="formatterDollar" | ||
[nzParser]="parserDollar" | ||
></nz-input-number-legacy> | ||
<nz-input-number-legacy | ||
[(ngModel)]="demoValue" | ||
[nzMin]="1" | ||
[nzMax]="100" | ||
[nzStep]="1" | ||
[nzFormatter]="formatterPercent" | ||
[nzParser]="parserPercent" | ||
></nz-input-number-legacy> | ||
`, | ||
styles: [ | ||
` | ||
nz-input-number { | ||
margin-right: 8px; | ||
} | ||
` | ||
] | ||
}) | ||
export class NzDemoInputNumberLegacyFormatterComponent { | ||
demoValue = 100; | ||
formatterPercent = (value: number): string => `${value} %`; | ||
parserPercent = (value: string): string => value.replace(' %', ''); | ||
formatterDollar = (value: number): string => `$ ${value}`; | ||
parserDollar = (value: string): string => value.replace('$ ', ''); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.