From 99b3978418685c9ad69b23f355d625c9dc55fc2f Mon Sep 17 00:00:00 2001 From: goodmice Date: Tue, 31 May 2022 17:18:05 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20makeDateColumn,?= =?UTF-8?q?=20DatePickerWrapper=20=D0=B8=20DateRangeWrapper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Table/Columns/date.tsx | 6 ++++-- src/components/Table/DatePickerWrapper.tsx | 2 +- src/components/Table/DateRangeWrapper.tsx | 13 ++++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) 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 }) => (