Skip to content

Commit

Permalink
refactor(time-picker): clear
Browse files Browse the repository at this point in the history
  • Loading branch information
07akioni committed Dec 18, 2023
1 parent 9db2f2d commit cb61fd3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/time-picker/demos/enUS/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion src/time-picker/demos/zhCN/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion src/time-picker/src/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { type MaybeArray } from '../../_utils'

const timePickerPanelProps = {
actions: {
type: Array as PropType<Array<'now' | 'confirm'> | null>,
type: Array as PropType<Array<'clear' | 'now' | 'confirm'> | null>,
default: () => ['clear', 'now', 'confirm']
},
showHour: {
Expand Down
7 changes: 3 additions & 4 deletions src/time-picker/src/TimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,8 @@ export default defineComponent({
returnFocus: true
})
}

// 清除选中时间
function handleClearSelectedDateTime (): void {
function clearSelectedValue (): void {
doUpdateValue(null)
deriveInputValue(null)
closePanel({
Expand Down Expand Up @@ -866,7 +865,7 @@ export default defineComponent({
cssVars: inlineThemeDisabled ? undefined : cssVarsRef,
themeClass: themeClassHandle?.themeClass,
onRender: themeClassHandle?.onRender,
handleClearSelectedDateTime
clearSelectedValue
}
},
render () {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit cb61fd3

Please sign in to comment.