Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:cascader): suooprt setting status (#7452)
- Loading branch information
1 parent
111abf3
commit e10908e
Showing
11 changed files
with
158 additions
and
8 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: 18 | ||
title: | ||
zh-CN: 自定义状态 | ||
en-US: Status | ||
--- | ||
|
||
## zh-CN | ||
|
||
使用 `nzStatus` 为 Cascader 添加状态,可选 `error` 或者 `warning`。 | ||
|
||
## en-US | ||
|
||
Add status to Cascader with `nzStatus`, which could be `error` or `warning`. |
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 { NzCascaderOption } from 'ng-zorro-antd/cascader'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-cascader-status', | ||
template: ` | ||
<nz-cascader [nzOptions]="nzOptions" nzStatus="error"></nz-cascader> | ||
<nz-cascader [nzOptions]="nzOptions" nzStatus="warning"></nz-cascader> | ||
`, | ||
styles: [ | ||
` | ||
.ant-cascader { | ||
width: 100%; | ||
margin-bottom: 8px; | ||
} | ||
` | ||
] | ||
}) | ||
export class NzDemoCascaderStatusComponent { | ||
nzOptions: NzCascaderOption[] = []; | ||
} |
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
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 @@ | ||
/** | ||
* 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 { tuple } from './type'; | ||
|
||
export type NzStatus = '' | 'error' | 'warning'; | ||
|
||
const ValidateStatuses = tuple('success', 'warning', 'error', 'validating', ''); | ||
export type NzValidateStatus = typeof ValidateStatuses[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,6 @@ | ||
/** | ||
* 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 | ||
*/ | ||
|
||
export const tuple = <T extends string[]>(...args: T): T => args; |
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,20 @@ | ||
/** | ||
* 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 { NgClassInterface, NzValidateStatus } from 'ng-zorro-antd/core/types'; | ||
|
||
export function getStatusClassNames( | ||
prefixCls: string, | ||
status?: NzValidateStatus, | ||
hasFeedback?: boolean | ||
): NgClassInterface { | ||
return { | ||
[`${prefixCls}-status-success`]: status === 'success', | ||
[`${prefixCls}-status-warning`]: status === 'warning', | ||
[`${prefixCls}-status-error`]: status === 'error', | ||
[`${prefixCls}-status-validating`]: status === 'validating', | ||
[`${prefixCls}-has-feedback`]: hasFeedback | ||
}; | ||
} |