Skip to content

Commit

Permalink
feat(form): add hideStep of number widget (#1303)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Aug 7, 2021
1 parent 6a94dbd commit f895bf0
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 31 deletions.
6 changes: 4 additions & 2 deletions packages/form/src/widgets/number/demo/simple.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ Simplest of usage.

```ts
import { Component } from '@angular/core';

import { SFNumberWidgetSchema, SFSchema } from '@delon/form';
import { NzMessageService } from 'ng-zorro-antd/message';

@Component({
selector: 'app-demo',
template: ` <sf [schema]="schema" (formSubmit)="submit($event)"></sf> `,
template: ` <sf [schema]="schema" (formSubmit)="submit($event)"></sf> `
})
export class DemoComponent {
schema: SFSchema = {
Expand All @@ -29,7 +30,8 @@ export class DemoComponent {
integer: { type: 'integer', default: 10 },
unit: { type: 'number', default: 10, ui: { unit: '%' } as SFNumberWidgetSchema },
prefix: { type: 'number', default: 10, ui: { prefix: '$' } as SFNumberWidgetSchema },
},
hideStep: { type: 'number', default: 10, ui: { hideStep: true } as SFNumberWidgetSchema }
}
};

constructor(private msg: NzMessageService) {}
Expand Down
29 changes: 15 additions & 14 deletions packages/form/src/widgets/number/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ Enter a number within certain range with the mouse or keyboard.

### schema

| Property | Description | Type | Default |
| -------------------- | --------------------------------------------------- | --------- | ------- |
| `[minimum]` | min value | `number` | - |
| `[exclusiveMinimum]` | Indicate whether minimum are exclusive of the value | `boolean` | - |
| `[maximum]` | max value | `number` | - |
| `[exclusiveMaximum]` | Indicate whether maximum are exclusive of the value | `boolean` | - |
| `[multipleOf]` | Restricted to a multiple of a given number, | `number` | `1` |
| Property | Description | Type | Default |
|----------|-------------|------|---------|
| `[minimum]` | min value | `number` | - |
| `[exclusiveMinimum]` | Indicate whether minimum are exclusive of the value | `boolean` | - |
| `[maximum]` | max value | `number` | - |
| `[exclusiveMaximum]` | Indicate whether maximum are exclusive of the value | `boolean` | - |
| `[multipleOf]` | Restricted to a multiple of a given number, | `number` | `1` |

### ui

| Property | Description | Type | Default |
| ------------- | -------------------------------------------------------- | ---- | ------- |
| `[prefix]` | Prefix, simplifying the use of `nzFormatter`, `nzParser` | - | - |
| `[unit]` | Unit, simplifying the use of `nzFormatter`, `nzParser` | - | - |
| `[formatter]` | Specifies the format of the value presented | - | - |
| `[parser]` | Specifies the value extracted from nzFormatter | - | - |
| `[precision]` | precision of input value | - | - |
| Property | Description | Type | Default |
|----------|-------------|------|---------|
| `[prefix]` | Prefix, simplifying the use of `nzFormatter`, `nzParser` | - | - |
| `[unit]` | Unit, simplifying the use of `nzFormatter`, `nzParser` | - | - |
| `[formatter]` | Specifies the format of the value presented | - | - |
| `[parser]` | Specifies the value extracted from nzFormatter | - | - |
| `[precision]` | precision of input value | - | - |
| `[widgetWidth]` | Specify `nz-number` width | `number` | `90` |
| `[hideStep]` | Hide step icon | `boolean` | `false` |
31 changes: 16 additions & 15 deletions packages/form/src/widgets/number/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ type: Widgets

### schema 属性

成员 | 说明 | 类型 | 默认值
----|------|-----|------
`[minimum]` | 最小值 | `number` | -
`[exclusiveMinimum]` | 约束是否包括 `minimum` 值,`true` 表示排除 `minimum` 值 | `boolean` | -
`[maximum]` | 最大值 | `number` | -
`[exclusiveMaximum]` | 约束是否包括 `maximum` 值,`true` 表示排除 `maximum` 值 | `boolean` | -
`[multipleOf]` | 倍数 | `number` | `1`
| 成员 | 说明 | 类型 | 默认值 |
|----|----|----|-----|
| `[minimum]` | 最小值 | `number` | - |
| `[exclusiveMinimum]` | 约束是否包括 `minimum` 值,`true` 表示排除 `minimum`| `boolean` | - |
| `[maximum]` | 最大值 | `number` | - |
| `[exclusiveMaximum]` | 约束是否包括 `maximum` 值,`true` 表示排除 `maximum`| `boolean` | - |
| `[multipleOf]` | 倍数 | `number` | `1` |

### ui 属性

成员 | 说明 | 类型 | 默认值
----|------|-----|------
`[prefix]` | 前缀,简化 `nzFormatter``nzParser` 的使用 | - | -
`[unit]` | 单位,简化 `nzFormatter``nzParser` 的使用 | - | -
`[formatter]` | 等同 `nzFormatter` | - | -
`[parser]` | 等同 `nzParser` | - | -
`[precision]` | 等同 `nzPrecision` | - | -
`[widgetWidth]` | 指定 `nz-number` 宽度 | `number` | `90`
| 成员 | 说明 | 类型 | 默认值 |
|----|----|----|-----|
| `[prefix]` | 前缀,简化 `nzFormatter``nzParser` 的使用 | - | - |
| `[unit]` | 单位,简化 `nzFormatter``nzParser` 的使用 | - | - |
| `[formatter]` | 等同 `nzFormatter` | - | - |
| `[parser]` | 等同 `nzParser` | - | - |
| `[precision]` | 等同 `nzPrecision` | - | - |
| `[widgetWidth]` | 指定 `nz-number` 宽度 | `number` | `90` |
| `[hideStep]` | 隐藏步数操作区 | `boolean` | `false` |
1 change: 1 addition & 0 deletions packages/form/src/widgets/number/number.widget.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
[nzPrecision]="ui.precision"
[nzPlaceHolder]="ui.placeholder || ''"
[style.width.px]="ui.widgetWidth || 90"
[ngClass]="{ 'ant-input-number__hide-step': ui.hideStep }"
>
</nz-input-number>
</sf-item-wrap>
7 changes: 7 additions & 0 deletions packages/form/src/widgets/number/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ export interface SFNumberWidgetSchema extends SFUISchemaItem {
* 指定 `nz-number` 宽度
*/
widgetWidth?: number;

/**
* Hide step icon
*
* 隐藏步数操作区
*/
hideStep?: boolean;
}
10 changes: 10 additions & 0 deletions packages/theme/system/antd/_input-number.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Hide step icon
*
* 隐藏步数操作区
*/
.@{ant-prefix}-input-number__hide-step {
.@{ant-prefix}-input-number-handler-wrap {
visibility: hidden;
}
}
1 change: 1 addition & 0 deletions packages/theme/system/antd/index.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import './_link.less';

@import './_input-number.less';
@import './_card.less';
@import './_drawer.less';
@import './_form.less';
Expand Down

0 comments on commit f895bf0

Please sign in to comment.