-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:input-number): support input number group (#7488)
* feat(module:input-number): support input number group feat(module:input-number): add nzCompact * feat(module:input-number): add tests * feat(module:input-number): fix some errors * feat(module:input-number): fix demos
- Loading branch information
1 parent
d28f861
commit b038fa2
Showing
18 changed files
with
932 additions
and
22 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
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,41 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-input-number-addon', | ||
template: ` | ||
<nz-space nzDirection="vertical" style="width: 100%"> | ||
<nz-input-number-group *nzSpaceItem nzAddOnBefore="+" nzAddOnAfter="$"> | ||
<nz-input-number [(ngModel)]="demoValue" [nzStep]="1"></nz-input-number> | ||
</nz-input-number-group> | ||
<nz-input-number-group *nzSpaceItem [nzAddOnBefore]="addOnBeforeTemplate" [nzAddOnAfter]="addOnAfterTemplate"> | ||
<nz-input-number [(ngModel)]="demoValue" [nzStep]="1"></nz-input-number> | ||
</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 [(ngModel)]="demoValue" [nzStep]="1"></nz-input-number> | ||
</nz-input-number-group> | ||
<nz-input-number-group *nzSpaceItem [nzAddOnBefore]="addOnBeforeCascaderTemplate"> | ||
<nz-input-number [(ngModel)]="demoValue" [nzStep]="1"></nz-input-number> | ||
</nz-input-number-group> | ||
<ng-template #addOnBeforeCascaderTemplate> | ||
<nz-cascader [nzOptions]="[]" nzPlaceHolder="cascader" style="width: 150px"></nz-cascader> | ||
</ng-template> | ||
</nz-space> | ||
` | ||
}) | ||
export class NzDemoInputNumberAddonComponent { | ||
demoValue = 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,18 @@ | ||
--- | ||
order: 9 | ||
title: | ||
zh-CN: 输入框组合 | ||
en-US: Input Number Group | ||
--- | ||
|
||
## zh-CN | ||
|
||
数字输入框的组合展现。 | ||
|
||
注意:使用 `nzCompact` 模式时,不需要通过 `nz-col` 来控制宽度。 | ||
|
||
## en-US | ||
|
||
InputNumber.Group example. | ||
|
||
Note: You don't need `nz-col` to control the width in the `nzCompact` mode. |
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,47 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-input-number-group', | ||
template: ` | ||
<nz-space nzDirection="vertical" style="width: 100%"> | ||
<nz-input-number-group nz-row [nzGutter]="8" nzSize="large" *nzSpaceItem> | ||
<div nz-col nzSpan="8"> | ||
<nz-input-number [ngModel]="1234" [nzStep]="1" style="width: 100%"></nz-input-number> | ||
</div> | ||
<div nz-col nzSpan="8"> | ||
<nz-input-number [ngModel]="56789" [nzStep]="1" style="width: 100%"></nz-input-number> | ||
</div> | ||
</nz-input-number-group> | ||
<nz-input-number-group *nzSpaceItem nzCompact> | ||
<nz-input-number [ngModel]="1234" [nzStep]="1" style="width: 33%"></nz-input-number> | ||
<nz-input-number [ngModel]="56789" [nzStep]="1" style="width: 33%"></nz-input-number> | ||
</nz-input-number-group> | ||
<nz-input-number-group *nzSpaceItem nzCompact> | ||
<nz-input-number [ngModel]="1234" [nzStep]="1" style="width: calc(100% - 200px)"></nz-input-number> | ||
<button nz-button nzType="primary">Submit</button> | ||
</nz-input-number-group> | ||
<nz-input-number-group *nzSpaceItem nzCompact> | ||
<nz-input-number [ngModel]="1234" [nzStep]="1" style="width: calc(100% - 200px)"></nz-input-number> | ||
<button nz-button> | ||
<i nz-icon nzType="copy" nzTheme="outline"></i> | ||
</button> | ||
</nz-input-number-group> | ||
<nz-input-number-group *nzSpaceItem nzCompact> | ||
<nz-select ngModel="Zhejiang"> | ||
<nz-option nzValue="Zhejiang" nzLabel="Zhejiang"></nz-option> | ||
<nz-option nzValue="Jiangsu" nzLabel="Jiangsu"></nz-option> | ||
</nz-select> | ||
<nz-input-number [ngModel]="1234" [nzStep]="1" style="width: 50%"></nz-input-number> | ||
</nz-input-number-group> | ||
<nz-input-number-group *nzSpaceItem nzCompact> | ||
<nz-input-number [ngModel]="1234" [nzStep]="1" style="width: 50%"></nz-input-number> | ||
<nz-date-picker></nz-date-picker> | ||
</nz-input-number-group> | ||
<nz-input-number-group *nzSpaceItem nzCompact> | ||
<nz-input-number [ngModel]="1234" [nzStep]="1" style="width: 30%"></nz-input-number> | ||
<nz-range-picker></nz-range-picker> | ||
</nz-input-number-group> | ||
</nz-space> | ||
` | ||
}) | ||
export class NzDemoInputNumberGroupComponent {} |
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 |
---|---|---|
@@ -1,4 +1,10 @@ | ||
import { NzInputNumberModule } from 'ng-zorro-antd/input-number'; | ||
import { NzButtonModule } from 'ng-zorro-antd/button'; | ||
import { NzIconModule } from 'ng-zorro-antd/icon'; | ||
import { NzSpaceModule } from 'ng-zorro-antd/space'; | ||
import { NzSelectModule } from 'ng-zorro-antd/select'; | ||
import { NzCascaderModule } from 'ng-zorro-antd/cascader'; | ||
import { NzGridModule } from 'ng-zorro-antd/grid'; | ||
import { NzDatePickerModule } from 'ng-zorro-antd/date-picker'; | ||
|
||
export const moduleList = [ NzInputNumberModule, NzButtonModule ]; | ||
export const moduleList = [ NzInputNumberModule, NzButtonModule, NzIconModule, NzSpaceModule, NzSelectModule, NzCascaderModule, NzGridModule, NzDatePickerModule ]; |
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: 8 | ||
title: | ||
zh-CN: 前缀 | ||
en-US: Prefix | ||
--- | ||
|
||
## zh-CN | ||
|
||
在数字输入框上添加前缀图标。 | ||
|
||
## en-US | ||
|
||
Add a prefix inside input. |
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'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-input-number-prefix', | ||
template: ` | ||
<nz-space nzDirection="vertical" style="width: 100%"> | ||
<nz-input-number-group *nzSpaceItem nzPrefix="¥" style="width: 100%"> | ||
<nz-input-number [nzStep]="1"></nz-input-number> | ||
</nz-input-number-group> | ||
<nz-input-number-group *nzSpaceItem nzAddOnBeforeIcon="user" nzPrefix="¥" style="width: 100%"> | ||
<nz-input-number [nzStep]="1"></nz-input-number> | ||
</nz-input-number-group> | ||
<nz-input-number-group *nzSpaceItem nzPrefix="¥" style="width: 100%"> | ||
<nz-input-number nzDisabled [nzStep]="1"></nz-input-number> | ||
</nz-input-number-group> | ||
</nz-space> | ||
` | ||
}) | ||
export class NzDemoInputNumberPrefixComponent {} |
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
28 changes: 28 additions & 0 deletions
28
components/input-number/input-number-group-slot.component.ts
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,28 @@ | ||
/** | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE | ||
*/ | ||
|
||
import { ChangeDetectionStrategy, Component, Input, TemplateRef, ViewEncapsulation } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: '[nz-input-number-group-slot]', | ||
preserveWhitespaces: false, | ||
encapsulation: ViewEncapsulation.None, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
template: ` | ||
<i nz-icon [nzType]="icon" *ngIf="icon"></i> | ||
<ng-container *nzStringTemplateOutlet="template">{{ template }}</ng-container> | ||
<ng-content></ng-content> | ||
`, | ||
host: { | ||
'[class.ant-input-number-group-addon]': `type === 'addon'`, | ||
'[class.ant-input-number-prefix]': `type === 'prefix'`, | ||
'[class.ant-input-number-suffix]': `type === 'suffix'` | ||
} | ||
}) | ||
export class NzInputNumberGroupSlotComponent { | ||
@Input() icon?: string | null = null; | ||
@Input() type: 'addon' | 'prefix' | 'suffix' | null = null; | ||
@Input() template?: string | TemplateRef<void> | null = null; | ||
} |
Oops, something went wrong.