Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:pipes): add pipes (#4812)
- Loading branch information
1 parent
9c0f666
commit e03e65b
Showing
43 changed files
with
1,057 additions
and
24 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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 |
---|---|---|
|
@@ -124,3 +124,4 @@ issue: | |
Form: danranVm | ||
PageHeader: CK110 | ||
Transfer: Ricbet | ||
Pipes: chensimeng |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -5,4 +5,3 @@ | |
|
||
export * from './nz-pipe.module'; | ||
export * from './time-range.pipe'; | ||
export * from './nz-css-unit.pipe'; |
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: 4 | ||
title: | ||
zh-CN: nzAggregate | ||
en-US: nzAggregate | ||
--- | ||
|
||
## zh-CN | ||
|
||
数组的Sum、Min、Max、Average等聚合操作 | ||
|
||
## en-US | ||
|
||
Sum, Min, Max, Average and other operations on arrays |
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'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-pipes-aggregate', | ||
template: ` | ||
<nz-row [nzGutter]="16"> | ||
<nz-col [nzSpan]="6"> | ||
<nz-statistic [nzValue]="[7, 8, 2, 3] | nzAggregate: 'max'" [nzTitle]="'Max [7, 8, 2, 3]'"></nz-statistic> | ||
</nz-col> | ||
<nz-col [nzSpan]="6"> | ||
<nz-statistic [nzValue]="[7, 8, 2, 3] | nzAggregate: 'min'" [nzTitle]="'Min [7, 8, 2, 3]'"></nz-statistic> | ||
</nz-col> | ||
<nz-col [nzSpan]="6"> | ||
<nz-statistic [nzValue]="[7, 8, 2, 3] | nzAggregate: 'sum'" [nzTitle]="'Sum [7, 8, 2, 3]'"></nz-statistic> | ||
</nz-col> | ||
<nz-col [nzSpan]="6"> | ||
<nz-statistic [nzValue]="[7, 8, 2, 3] | nzAggregate: 'avg'" [nzTitle]="'Avg [7, 8, 2, 3]'"></nz-statistic> | ||
</nz-col> | ||
</nz-row> | ||
` | ||
}) | ||
export class NzDemoPipesAggregateComponent {} |
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: 1 | ||
title: | ||
zh-CN: nzBytes | ||
en-US: nzBytes | ||
--- | ||
|
||
## zh-CN | ||
|
||
存储单位的换算,增加可读性 | ||
|
||
## en-US | ||
|
||
Conversion of storage units to increase readability |
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,17 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-pipes-bytes', | ||
template: ` | ||
<ul> | ||
<li>{{ 200 | nzBytes }}</li> | ||
<li>{{ 1024 | nzBytes }}</li> | ||
<li>{{ 1048576 | nzBytes }}</li> | ||
<li>{{ 1024 | nzBytes: 0:'KB' }}</li> | ||
<li>{{ 1073741824 | nzBytes }}</li> | ||
<li>{{ 1099511627776 | nzBytes }}</li> | ||
<li>{{ 1073741824 | nzBytes: 0:'B':'MB' }}</li> | ||
</ul> | ||
` | ||
}) | ||
export class NzDemoPipesBytesComponent {} |
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: 2 | ||
title: | ||
zh-CN: nzToCssUnit | ||
en-US: nzToCssUnit | ||
--- | ||
|
||
## zh-CN | ||
|
||
Css 单位 | ||
|
||
## en-US | ||
|
||
Css unit |
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,34 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-pipes-css-unit', | ||
template: ` | ||
<nz-slider [(ngModel)]="radiusValue" [nzMax]="100" [nzMin]="0"></nz-slider> | ||
<div class="wrap"> | ||
<div class="box" [style.border-radius]="radiusValue | nzToCssUnit">Default</div> | ||
<div class="box" [style.border-radius]="radiusValue | nzToCssUnit: '%'">%</div> | ||
<div class="box" [style.border-radius]="radiusValue | nzToCssUnit: 'rem'">rem</div> | ||
</div> | ||
`, | ||
styles: [ | ||
` | ||
.wrap { | ||
display: flex; | ||
} | ||
.box { | ||
margin-top: 20px; | ||
margin-right: 20px; | ||
text-align: center; | ||
line-height: 50px; | ||
color: #fff; | ||
width: 50px; | ||
height: 50px; | ||
background: #4183c4; | ||
} | ||
` | ||
] | ||
}) | ||
export class NzDemoPipesCssUnitComponent { | ||
radiusValue = 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,14 @@ | ||
--- | ||
order: 3 | ||
title: | ||
zh-CN: nzEllipsis | ||
en-US: nzEllipsis | ||
--- | ||
|
||
## zh-CN | ||
|
||
截断字符串,用指定的字符串结尾 | ||
|
||
## en-US | ||
|
||
Truncate the string, ending with the specified string |
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,20 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-pipes-ellipsis', | ||
template: ` | ||
<input type="text" nz-input [(ngModel)]="str" /> | ||
<br /> | ||
<p>{{ str | nzEllipsis: 36:'...' }}</p> | ||
`, | ||
styles: [ | ||
` | ||
p { | ||
padding: 8px 12px; | ||
} | ||
` | ||
] | ||
}) | ||
export class NzDemoPipesEllipsisComponent { | ||
str = 'Ant Design, a design language for background applications'; | ||
} |
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,8 @@ | ||
import { NzGridModule } from 'ng-zorro-antd/grid'; | ||
import { NzInputModule } from 'ng-zorro-antd/input'; | ||
import { NzPipesModule } from 'ng-zorro-antd/pipes'; | ||
import { NzSliderModule } from 'ng-zorro-antd/slider'; | ||
import { NzStatisticModule } from 'ng-zorro-antd/statistic'; | ||
import { NzTableModule } from 'ng-zorro-antd/table'; | ||
|
||
export const moduleList = [ NzPipesModule, NzTableModule, NzSliderModule, NzInputModule, NzStatisticModule, NzGridModule ]; |
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: 5 | ||
title: | ||
zh-CN: nzSafeNull | ||
en-US: nzSafeNull | ||
--- | ||
|
||
## zh-CN | ||
|
||
转换 Null 和 Undefined 为指定字符串 | ||
|
||
## en-US | ||
|
||
Convert Null and Undefined to the specified string | ||
|
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,40 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-pipes-safe-null', | ||
template: ` | ||
<nz-table #basicTable [nzData]="listOfData"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Age</th> | ||
<th>Address</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let data of basicTable.data"> | ||
<td>{{ data.name }}</td> | ||
<td>{{ data.age }}</td> | ||
<td>{{ data.address | nzSafeNull: '-' }}</td> | ||
</tr> | ||
</tbody> | ||
</nz-table> | ||
` | ||
}) | ||
export class NzDemoPipesSafeNullComponent { | ||
listOfData = [ | ||
{ | ||
name: 'John Brown', | ||
age: 32 | ||
}, | ||
{ | ||
name: 'Jim Green', | ||
age: 42 | ||
}, | ||
{ | ||
name: 'Joe Black', | ||
age: 32, | ||
address: 'Sidney No. 1 Lake Park' | ||
} | ||
]; | ||
} |
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,29 @@ | ||
--- | ||
order: 6 | ||
title: | ||
zh-CN: nzSanitizer | ||
en-US: nzSanitizer | ||
--- | ||
|
||
## zh-CN | ||
|
||
DomSanitizer 的 Pipe 实现 | ||
|
||
```html | ||
<div [innerHTML]="html | nzSanitizer: 'html'"></div> | ||
<div [style]="style | nzSanitizer: 'style'"></div> | ||
<img [src]="url | nzSanitizer: 'url'" /> | ||
<iframe [src]="resourceUrl | nzSanitizer: 'resourceUrl'"></iframe> | ||
``` | ||
|
||
## en-US | ||
|
||
Pipe implementation of DomSanitizer | ||
|
||
|
||
```html | ||
<div [innerHTML]="html | nzSanitizer: 'html'"></div> | ||
<div [style]="style | nzSanitizer: 'style'"></div> | ||
<img [src]="url | nzSanitizer: 'url'" /> | ||
<iframe [src]="resourceUrl | nzSanitizer: 'resourceUrl'"></iframe> | ||
``` |
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,11 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-pipes-sanitizer', | ||
template: ` | ||
<div [innerHTML]="html | nzSanitizer: 'html'"></div> | ||
` | ||
}) | ||
export class NzDemoPipesSanitizerComponent { | ||
html = `<span>I am <code>innerHTML</code></span>`; | ||
} |
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: nzTrim | ||
en-US: nzTrim | ||
--- | ||
|
||
## zh-CN | ||
|
||
去除字符串左右空字符串 | ||
|
||
## en-US | ||
|
||
Strip left and right empty string |
Oops, something went wrong.