Skip to content

Commit 1b1a013

Browse files
feat(module:input-number): add nzBlur and nzFocus output (#9098)
1 parent 10c70a3 commit 1b1a013

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

components/input-number/doc/index.en-US.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ When a numeric value needs to be provided.
3636
| `[nzSize]` | input box size, optional `large` `default` `small` | `string` | `default` |
3737
| `[nzStep]` | step of each change, can be a decimal | `number` | `1` |
3838
| `(nzOnStep)` | callback when clicking the up and down arrows | `EventEmitter<{ value: number, offset: number, type: 'up' \| 'down' }>` | - |
39+
| `(nzFocus)` | callback when focus | `OutputRef<void>` | - |
40+
| `(nzBlur)` | callback when blur | `OutputRef<void>` | - |
3941
| `(ngModelChange)` | callback function when the value changes | `EventEmitter<number>` | - |
4042

4143
#### Methods

components/input-number/doc/index.zh-CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ description: 通过鼠标或键盘,输入范围内的数值。
3737
| `[nzSize]` | 输入框大小,可选 `large` `default` `small` | `string` | `default` |
3838
| `[nzStep]` | 每次改变步数,可以是小数 | `number` | `1` |
3939
| `(nzOnStep)` | 点击上下箭头的回调 | `EventEmitter<{ value: number, offset: number, type: 'up' \| 'down' }>` | - |
40+
| `(nzFocus)` | focus 时回调 | `OutputRef<void>` | - |
41+
| `(nzBlur)` | blur 时回调 | `OutputRef<void>` | - |
4042
| `(ngModelChange)` | 值变化时的回调函数 | `EventEmitter<number>` | - |
4143

4244
#### 方法

components/input-number/input-number.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ export class NzInputNumberComponent implements OnInit, ControlValueAccessor {
192192
readonly nzKeyboard = input(true, { transform: booleanAttribute });
193193
readonly nzControls = input(true, { transform: booleanAttribute });
194194

195+
readonly nzBlur = output<void>();
196+
readonly nzFocus = output<void>();
197+
195198
readonly nzOnStep = output<{ value: number; offset: number; type: 'up' | 'down' }>();
196199

197200
private onChange: OnChangeType = () => {};
@@ -300,9 +303,12 @@ export class NzInputNumberComponent implements OnInit, ControlValueAccessor {
300303
.subscribe(origin => {
301304
this.focused.set(!!origin);
302305

303-
if (!origin) {
306+
if (origin) {
307+
this.nzFocus.emit();
308+
} else {
304309
this.fixValue();
305310
this.onTouched();
311+
this.nzBlur.emit();
306312
}
307313
});
308314

0 commit comments

Comments
 (0)