Skip to content

Commit

Permalink
fix: resolve TIME_FORMAT RegExp (#3066)
Browse files Browse the repository at this point in the history
  • Loading branch information
liweijie0812 authored Aug 28, 2024
1 parent 1b6870a commit c246cf5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
25 changes: 3 additions & 22 deletions src/time-picker/panel/SinglePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,8 @@ import range from 'lodash/range';
import useConfig from '../../hooks/useConfig';
import noop from '../../_util/noop';
import { useTimePickerTextConfig } from '../hooks/useTimePickerTextConfig';
import {
AM,
PM,
EPickerCols,
TIME_FORMAT,
MERIDIEM_LIST,
TWELVE_HOUR_FORMAT,
} from '../../_common/js/time-picker/const';
import { closestLookup } from '../../_common/js/time-picker/utils';
import { AM, PM, EPickerCols, MERIDIEM_LIST, TWELVE_HOUR_FORMAT } from '../../_common/js/time-picker/const';
import { closestLookup, getPickerCols } from '../../_common/js/time-picker/utils';

import { TdTimePickerProps, TimeRangePickerPartial } from '../type';
import useDebounce from '../../hooks/useDebounce';
Expand Down Expand Up @@ -94,19 +87,7 @@ const SinglePanel: FC<SinglePanelProps> = (props) => {
}, [cols]);

useEffect(() => {
const match = format.match(TIME_FORMAT);
const [, startCol, hourCol, minuteCol, secondCol, milliSecondCol, endCol] = match;
const { meridiem, hour, minute, second, milliSecond } = EPickerCols;

const renderCol = [
startCol && meridiem,
hourCol && hour,
minuteCol && minute,
secondCol && second,
milliSecondCol && milliSecond,
endCol && meridiem,
].filter((v) => !!v);

const renderCol = getPickerCols(format);
setCols(renderCol);
}, [format]);

Expand Down

0 comments on commit c246cf5

Please sign in to comment.