From cb61fd3ffd3dae368e8396e73fbb73cf24792138 Mon Sep 17 00:00:00 2001 From: zhanglecong <07akioni2@gmail.com> Date: Mon, 18 Dec 2023 20:21:40 +0800 Subject: [PATCH] refactor(time-picker): clear --- src/time-picker/demos/enUS/index.demo-entry.md | 2 +- src/time-picker/demos/zhCN/index.demo-entry.md | 2 +- src/time-picker/src/Panel.tsx | 2 +- src/time-picker/src/TimePicker.tsx | 7 +++---- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/time-picker/demos/enUS/index.demo-entry.md b/src/time-picker/demos/enUS/index.demo-entry.md index fed352df16e..2fac8fc92fe 100644 --- a/src/time-picker/demos/enUS/index.demo-entry.md +++ b/src/time-picker/demos/enUS/index.demo-entry.md @@ -25,7 +25,7 @@ timezone.vue | Name | Type | Default | Description | Version | | --- | --- | --- | --- | --- | -| actions | `Array<'clear' \| 'now' \| 'confirm'> \| null` | `['now', 'confirm']` | Operations supported by the Time Picker. | | +| actions | `Array<'clear' \| 'now' \| 'confirm'> \| null` | `['now', 'confirm']` | Operations supported by the Time Picker. | `'clear'` NEXT_VERSION | | clearable | `boolean` | `false` | Whether the value is clearable. | | | default-value | `number \| null` | `null` | Default value. | | | default-formatted-value | `number \| null` | `undefined` | Default formatted value. | 2.24.0 | diff --git a/src/time-picker/demos/zhCN/index.demo-entry.md b/src/time-picker/demos/zhCN/index.demo-entry.md index c28a7e214b8..cfbcf0b92b9 100644 --- a/src/time-picker/demos/zhCN/index.demo-entry.md +++ b/src/time-picker/demos/zhCN/index.demo-entry.md @@ -26,7 +26,7 @@ timezone-debug.vue | 名称 | 类型 | 默认值 | 说明 | 版本 | | --- | --- | --- | --- | --- | -| actions | `Array<'clear' \| 'now' \| 'confirm'> \| null` | `['now', 'confirm']` | Time Picker 中支持的操作 | | +| actions | `Array<'clear' \| 'now' \| 'confirm'> \| null` | `['now', 'confirm']` | Time Picker 中支持的操作 | `'clear'` NEXT_VERSION | | clearable | `boolean` | `false` | 是否可清空 | | | default-value | `number \| null` | `null` | 非受控模式下的默认值 | | | default-formatted-value | `string \| null` | `undefined` | 非受控模式下的默认格式化后的值 | 2.24.0 | diff --git a/src/time-picker/src/Panel.tsx b/src/time-picker/src/Panel.tsx index df1124e549d..b3effe7659c 100644 --- a/src/time-picker/src/Panel.tsx +++ b/src/time-picker/src/Panel.tsx @@ -15,7 +15,7 @@ import { type MaybeArray } from '../../_utils' const timePickerPanelProps = { actions: { - type: Array as PropType | null>, + type: Array as PropType | null>, default: () => ['clear', 'now', 'confirm'] }, showHour: { diff --git a/src/time-picker/src/TimePicker.tsx b/src/time-picker/src/TimePicker.tsx index 2f707f16bb1..de699d8ef28 100644 --- a/src/time-picker/src/TimePicker.tsx +++ b/src/time-picker/src/TimePicker.tsx @@ -464,9 +464,8 @@ export default defineComponent({ returnFocus: true }) } - // 清除选中时间 - function handleClearSelectedDateTime (): void { + function clearSelectedValue (): void { doUpdateValue(null) deriveInputValue(null) closePanel({ @@ -866,7 +865,7 @@ export default defineComponent({ cssVars: inlineThemeDisabled ? undefined : cssVarsRef, themeClass: themeClassHandle?.themeClass, onRender: themeClassHandle?.onRender, - handleClearSelectedDateTime + clearSelectedValue } }, render () { @@ -986,7 +985,7 @@ export default defineComponent({ onAmPmClick={this.handleAmPmClick} onNowClick={this.handleNowClick} onConfirmClick={this.handleConfirmClick} - onClearClick={this.handleClearSelectedDateTime} + onClearClick={this.clearSelectedValue} onFocusDetectorFocus={ this.handleFocusDetectorFocus }