diff --git a/src/time-picker/TimeRangePicker.tsx b/src/time-picker/TimeRangePicker.tsx index 21496150f0..c1c440204e 100644 --- a/src/time-picker/TimeRangePicker.tsx +++ b/src/time-picker/TimeRangePicker.tsx @@ -143,7 +143,7 @@ const TimeRangePicker: FC = (originalProps) => { const handleClickConfirm = () => { const isValidTime = !currentValue.find((v) => !validateInputValue(v, format)); - if (isValidTime) onChange(autoSwapTime(currentValue)); + if (isValidTime) onChange(props.autoSwap ? autoSwapTime(currentValue) : currentValue); setPanelShow(false); }; diff --git a/src/time-picker/defaultProps.ts b/src/time-picker/defaultProps.ts index 42e5f840b5..c3a1732f10 100644 --- a/src/time-picker/defaultProps.ts +++ b/src/time-picker/defaultProps.ts @@ -16,6 +16,7 @@ export const timePickerDefaultProps: TdTimePickerProps = { export const timeRangePickerDefaultProps: TdTimeRangePickerProps = { allowInput: false, + autoSwap: true, borderless: false, clearable: false, format: 'HH:mm:ss', diff --git a/src/time-picker/time-picker.en-US.md b/src/time-picker/time-picker.en-US.md index 91f908422a..e86535f742 100644 --- a/src/time-picker/time-picker.en-US.md +++ b/src/time-picker/time-picker.en-US.md @@ -41,6 +41,7 @@ name | type | default | description | required className | String | - | className of component | N style | Object | - | CSS(Cascading Style Sheets),Typescript:`React.CSSProperties` | N allowInput | Boolean | false | \- | N +autoSwap | Boolean | true | \- | N borderless | Boolean | false | \- | N clearable | Boolean | false | \- | N disableTime | Function | - | Typescript:`(h: number, m: number, s: number, context: { partial: TimeRangePickerPartial }) =>Partial<{ hour: Array, minute: Array, second: Array }>` `type TimeRangePickerPartial = 'start' \| 'end'`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/time-picker/type.ts) | N diff --git a/src/time-picker/time-picker.md b/src/time-picker/time-picker.md index 879a85ae11..6a1555a2c5 100644 --- a/src/time-picker/time-picker.md +++ b/src/time-picker/time-picker.md @@ -41,6 +41,7 @@ onPick | Function | | TS 类型:`(value: TimePickerValue, context: { e: Mouse className | String | - | 类名 | N style | Object | - | 样式,TS 类型:`React.CSSProperties` | N allowInput | Boolean | false | 是否允许直接输入时间 | N +autoSwap | Boolean | true | 是否自动调换左右区间的顺序,默认为 true;若需要支持跨天的场景,可以设置为 false | N borderless | Boolean | false | 无边框模式 | N clearable | Boolean | false | 是否允许清除选中值 | N disableTime | Function | - | 禁用时间项。TS 类型:`(h: number, m: number, s: number, context: { partial: TimeRangePickerPartial }) =>Partial<{ hour: Array, minute: Array, second: Array }>` `type TimeRangePickerPartial = 'start' \| 'end'`。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/time-picker/type.ts) | N diff --git a/src/time-picker/type.ts b/src/time-picker/type.ts index b91767f6f5..7d8169d4e1 100644 --- a/src/time-picker/type.ts +++ b/src/time-picker/type.ts @@ -131,6 +131,11 @@ export interface TdTimeRangePickerProps { * @default false */ allowInput?: boolean; + /** + * 是否自动调换左右区间的顺序,默认为 true;若需要支持跨天的场景,可以设置为 false + * @default true + */ + autoSwap?: boolean; /** * 无边框模式 * @default false