Skip to content

Commit 0c53f03

Browse files
committed
clean
1 parent 14dae9b commit 0c53f03

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

packages/components/src/internal/components/editable/DateInputCell.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { DatePickerInput } from '../forms/input/DatePickerInput';
66
import {
77
formatDate,
88
formatDateTime,
9+
getJsonTimeFormatString,
910
getTimeValueFromDatePickerInput,
1011
isDateTimeCol
1112
} from '../../util/Date';
@@ -39,20 +40,22 @@ export const DateInputCell: FC<DateInputCellProps> = memo(props => {
3940
}, [colIdx, rowIdx, select]);
4041

4142
const onDateInputChange = useCallback(
42-
(newDate: Date | string, formatted?: string) => {
43-
let display = formatted;
44-
if (!display) {
45-
if (newDate && typeof newDate === 'string') display = newDate;
46-
else if (newDate && newDate instanceof Date) {
47-
display = col.isTimeColumn
48-
? getTimeValueFromDatePickerInput(newDate, col)
49-
: isDateTimeCol(col)
50-
? formatDateTime(newDate)
51-
: formatDate(newDate);
43+
(newDate: Date | string) => {
44+
let display, raw = newDate;
45+
if (newDate && typeof newDate === 'string') display = newDate;
46+
else if (newDate && newDate instanceof Date) {
47+
if (col.isTimeColumn) {
48+
raw = getJsonTimeFormatString(newDate);
49+
display = getTimeValueFromDatePickerInput(newDate, col);
50+
}
51+
else {
52+
display = isDateTimeCol(col)
53+
? formatDateTime(newDate)
54+
: formatDate(newDate);
5255
}
5356
}
5457

55-
modifyCell(colIdx, rowIdx, [{ raw: col.isTimeColumn ? display : newDate, display }], MODIFICATION_TYPES.REPLACE, col);
58+
modifyCell(colIdx, rowIdx, [{ raw, display }], MODIFICATION_TYPES.REPLACE, col);
5659
},
5760
[col, colIdx, modifyCell, rowIdx]
5861
);

packages/components/src/internal/components/forms/input/DatePickerInput.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
getPickerDateAndTimeFormat,
2727
isDateTimeCol,
2828
isRelativeDateFilterValue,
29-
parseDate,
3029
parseTime,
3130
} from '../../../util/Date';
3231

@@ -53,7 +52,7 @@ export interface DatePickerInputProps extends DisableableInputProps {
5352
name?: string;
5453
onBlur?: () => void;
5554
onCalendarClose?: () => void;
56-
onChange?: (rawDate?: Date | string, dateStr?: string) => void;
55+
onChange?: (rawDate?: Date | string) => void;
5756
onKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => void;
5857
placeholderText?: string;
5958
queryColumn: QueryColumn;
@@ -168,7 +167,7 @@ export class DatePickerInputImpl extends DisableableInput<DatePickerInputImplPro
168167
this.setState({ selectedDate: date, invalid: false, invalidStart: false });
169168

170169
if (this.state.relativeInputValue) {
171-
this.props.onChange?.(this.state.relativeInputValue);
170+
onChange?.(this.state.relativeInputValue);
172171
} else {
173172
onChange?.(date);
174173

0 commit comments

Comments
 (0)