diff --git a/src/components/Table/Columns/date.tsx b/src/components/Table/Columns/date.tsx index c388cf6..d4790e6 100755 --- a/src/components/Table/Columns/date.tsx +++ b/src/components/Table/Columns/date.tsx @@ -4,13 +4,15 @@ import { formatDate } from '@utils' import makeColumn, { columnPropsOther } from '.' import { DatePickerWrapper, makeDateSorter } from '..' +import { DatePickerWrapperProps } from '../DatePickerWrapper' export const makeDateColumn = ( title: ReactNode, key: string, utc?: boolean, format?: string, - other?: columnPropsOther + other?: columnPropsOther, + pickerOther?: DatePickerWrapperProps, ) => makeColumn(title, key, { ...other, render: (date) => ( @@ -19,7 +21,7 @@ export const makeDateColumn = ( ), sorter: makeDateSorter(key), - input: , + input: , }) export default makeDateColumn diff --git a/src/components/Table/DatePickerWrapper.tsx b/src/components/Table/DatePickerWrapper.tsx index 9fa14d1..8aaa9ba 100755 --- a/src/components/Table/DatePickerWrapper.tsx +++ b/src/components/Table/DatePickerWrapper.tsx @@ -16,7 +16,7 @@ export const DatePickerWrapper = memo(({ value, onChange showTime allowClear={false} format={defaultFormat} - defaultValue={moment()} + defaultValue={undefined} onChange={(date) => onChange?.(date)} value={value && (isUTC ? moment.utc(value).local() : moment(value))} {...other} diff --git a/src/components/Table/DateRangeWrapper.tsx b/src/components/Table/DateRangeWrapper.tsx index 1dfa23c..587e3bf 100755 --- a/src/components/Table/DateRangeWrapper.tsx +++ b/src/components/Table/DateRangeWrapper.tsx @@ -9,14 +9,17 @@ import { defaultFormat } from '@utils' const { RangePicker } = DatePicker export type DateRangeWrapperProps = RangePickerSharedProps & { - value: RangeValue, + value?: RangeValue, isUTC?: boolean } -const normalizeDates = (value: RangeValue, isUTC?: boolean): RangeValue => value && [ - value[0] ? (isUTC ? moment.utc(value[0]).local() : moment(value[0])) : null, - value[1] ? (isUTC ? moment.utc(value[1]).local() : moment(value[1])) : null, -] +const normalizeDates = (value?: RangeValue, isUTC?: boolean): RangeValue => { + if (!value) return [null, null] + return [ + value[0] ? (isUTC ? moment.utc(value[0]).local() : moment(value[0])) : null, + value[1] ? (isUTC ? moment.utc(value[1]).local() : moment(value[1])) : null, + ] +} export const DateRangeWrapper = memo(({ value, isUTC, ...other }) => (