Skip to content

Commit

Permalink
feat(module:pipes): support standalone component (#8233)
Browse files Browse the repository at this point in the history
  • Loading branch information
ParsaArvanehPA authored Dec 1, 2023
1 parent aa91486 commit 319381a
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 67 deletions.
55 changes: 27 additions & 28 deletions components/pipes/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,41 @@ import { NzPipesModule } from 'ng-zorro-antd/pipes';

## API

### __nzSafeNull__
### **nzSafeNull**:standalone

| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
| `replace` | Replace character | `string` | '' |
| Property | Description | Type | Default |
| --------- | ----------------- | -------- | ------- |
| `replace` | Replace character | `string` | '' |

### __nzBytes__
### **nzBytes**:standalone

| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
| `decimal` | Decimal | `number` | '0' |
| `from` | Unit of current value | `string` | 'B' |
| `to` | Units converted to target value | `string` | '' |
| Property | Description | Type | Default |
| --------- | ------------------------------- | -------- | ------- |
| `decimal` | Decimal | `number` | '0' |
| `from` | Unit of current value | `string` | 'B' |
| `to` | Units converted to target value | `string` | '' |

### __nzToCssUnit__
### **nzToCssUnit**:standalone

| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
| `defaultUnit` | Default Unit | `string` | 'px' |
| Property | Description | Type | Default |
| ------------- | ------------ | -------- | ------- |
| `defaultUnit` | Default Unit | `string` | 'px' |

### __nzEllipsis__
### **nzEllipsis**:standalone

| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
| `length` | Truncate length | `number` | '' |
| `suffix` | Replace character | `string` | '' |
| Property | Description | Type | Default |
| -------- | ----------------- | -------- | ------- |
| `length` | Truncate length | `number` | '' |
| `suffix` | Replace character | `string` | '' |

### **nzAggregate**:standalone

### __nzAggregate__
| Property | Description | Type | Default |
| -------- | ----------- | ---------------------------------- | ------- |
| `method` | Aggregation | `'sum' \| 'max' \| 'min' \| 'avg'` | '' |

| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
| `method` | Aggregation | `'sum' \| 'max' \| 'min' \| 'avg'` | '' |
### **nzSanitizer**:standalone

### __nzSanitizer__

| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
| `type` | sanitizer type | `string` | 'html' |
| Property | Description | Type | Default |
| -------- | -------------- | -------- | ------- |
| `type` | sanitizer type | `string` | 'html' |
54 changes: 26 additions & 28 deletions components/pipes/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ experimental: true
<p>开发者或用户可以选择在正式发布前使用这些功能,但是每次发布版本时都可能存在 <strong>breaking changes</strong>。</p>
</blockquote>


项目中常用 Pipe 集合

## 何时使用
Expand All @@ -24,42 +23,41 @@ import { NzPipesModule } from 'ng-zorro-antd/pipes';

## API

### __nzSafeNull__
### **nzSafeNull**:standalone

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| `replace` | 替换字符 | `string` | '' |
| 参数 | 说明 | 类型 | 默认值 |
| --------- | -------- | -------- | ------ |
| `replace` | 替换字符 | `string` | '' |

### __nzBytes__
### **nzBytes**:standalone

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| `decimal` | 保留小数位 | `number` | '0' |
| `from` | 当前值的单位 | `string` | 'B' |
| `to` | 转换到目标值的单位 | `string` | '' |
| 参数 | 说明 | 类型 | 默认值 |
| --------- | ------------------ | -------- | ------ |
| `decimal` | 保留小数位 | `number` | '0' |
| `from` | 当前值的单位 | `string` | 'B' |
| `to` | 转换到目标值的单位 | `string` | '' |

### __nzToCssUnit__
### **nzToCssUnit**:standalone

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| `defaultUnit` | 默认单位 | `string` | 'px' |
| 参数 | 说明 | 类型 | 默认值 |
| ------------- | -------- | -------- | ------ |
| `defaultUnit` | 默认单位 | `string` | 'px' |

### __nzEllipsis__
### **nzEllipsis**:standalone

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| `length` | 截取长度 | `number` | '' |
| `suffix` | 替换字符 | `string` | '' |
| 参数 | 说明 | 类型 | 默认值 |
| -------- | -------- | -------- | ------ |
| `length` | 截取长度 | `number` | '' |
| `suffix` | 替换字符 | `string` | '' |

### __nzAggregate__
### **nzAggregate**:standalone

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| `method` | 聚合方式 | `'sum' \| 'max' \| 'min' \| 'avg'` | '' |
| 参数 | 说明 | 类型 | 默认值 |
| -------- | -------- | ---------------------------------- | ------ |
| `method` | 聚合方式 | `'sum' \| 'max' \| 'min' \| 'avg'` | '' |

### __nzSanitizer__
### **nzSanitizer**:standalone

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| 参数 | 说明 | 类型 | 默认值 |
| ------ | -------------- | -------- | ------ |
| `type` | sanitizer 类型 | `string` | 'html' |

3 changes: 2 additions & 1 deletion components/pipes/nz-aggregate.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { sum } from 'ng-zorro-antd/core/util';
export type AggregateMethod = 'sum' | 'max' | 'min' | 'avg';

@Pipe({
name: 'nzAggregate'
name: 'nzAggregate',
standalone: true
})
export class NzAggregatePipe implements PipeTransform {
transform(value: number[], method: AggregateMethod): undefined | number {
Expand Down
3 changes: 2 additions & 1 deletion components/pipes/nz-bytes.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { isNumberFinite, toDecimal } from 'ng-zorro-antd/core/util';
export type ByteUnit = 'B' | 'kB' | 'KB' | 'MB' | 'GB' | 'TB';

@Pipe({
name: 'nzBytes'
name: 'nzBytes',
standalone: true
})
export class NzBytesPipe implements PipeTransform {
static formats: { [key in ByteUnit]: { max: number; prev?: ByteUnit } } = {
Expand Down
3 changes: 2 additions & 1 deletion components/pipes/nz-css-unit.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { Pipe, PipeTransform } from '@angular/core';
* @deprecated v17.0.0 - Use angular's built-in syntax instead
*/
@Pipe({
name: 'nzToCssUnit'
name: 'nzToCssUnit',
standalone: true
})
export class NzToCssUnitPipe implements PipeTransform {
transform(value: number | string, defaultUnit: string = 'px'): string {
Expand Down
3 changes: 2 additions & 1 deletion components/pipes/nz-ellipsis.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { Pipe, PipeTransform } from '@angular/core';
import { NzSafeAny } from 'ng-zorro-antd/core/types';

@Pipe({
name: 'nzEllipsis'
name: 'nzEllipsis',
standalone: true
})
export class NzEllipsisPipe implements PipeTransform {
transform(value: NzSafeAny, length?: number, suffix: string = ''): NzSafeAny {
Expand Down
6 changes: 2 additions & 4 deletions components/pipes/nz-pipes.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';

import { NzAggregatePipe } from './nz-aggregate.pipe';
Expand All @@ -25,8 +24,7 @@ const pipes = [
];

@NgModule({
imports: [CommonModule],
exports: [pipes],
declarations: [pipes]
imports: [pipes],
exports: [pipes]
})
export class NzPipesModule {}
3 changes: 2 additions & 1 deletion components/pipes/nz-safe-null.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { isNil } from 'ng-zorro-antd/core/util';
* @deprecated v17.0.0 - Use Nullish coalescing operator (??) instead of `NzSafeNullPipe`.
*/
@Pipe({
name: 'nzSafeNull'
name: 'nzSafeNull',
standalone: true
})
export class NzSafeNullPipe implements PipeTransform {
transform<T>(value: T, replace: string = ''): T | string {
Expand Down
3 changes: 2 additions & 1 deletion components/pipes/nz-sanitizer.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { NzSafeAny } from 'ng-zorro-antd/core/types';
type DomSanitizerType = 'html' | 'style' | 'url' | 'resourceUrl';

@Pipe({
name: 'nzSanitizer'
name: 'nzSanitizer',
standalone: true
})
export class NzSanitizerPipe implements PipeTransform {
constructor(protected sanitizer: DomSanitizer) {}
Expand Down
3 changes: 2 additions & 1 deletion components/pipes/nz-trim.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'nzTrim'
name: 'nzTrim',
standalone: true
})
export class NzTrimPipe implements PipeTransform {
// TODO(chensimeng) trimEnd, trimStart
Expand Down

0 comments on commit 319381a

Please sign in to comment.