diff --git a/src/_common b/src/_common index 1ae65fd27..f597d1bad 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 1ae65fd277c668c29481299772632fcec1c7645a +Subproject commit f597d1bada510e16cd9b3efd46000a674760a5ce diff --git a/src/time-picker/panel/single-panel.tsx b/src/time-picker/panel/single-panel.tsx index f600248cb..c9a114ec0 100644 --- a/src/time-picker/panel/single-panel.tsx +++ b/src/time-picker/panel/single-panel.tsx @@ -11,7 +11,7 @@ import { panelColProps } from './props'; import { EPickerCols, TWELVE_HOUR_FORMAT, AM, PM, MERIDIEM_LIST, } from '../../_common/js/time-picker/const'; -import { closestLookup } from '../../_common/js/time-picker/utils'; +import { closestLookup, getPickerCols } from '../../_common/js/time-picker/utils'; import { useConfig } from '../../hooks/useConfig'; dayjs.extend(customParseFormat); @@ -23,8 +23,6 @@ const panelOffset = { bottom: 21, }; -export const REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g; - export default defineComponent({ name: 'TTimePickerPanelCol', props: { @@ -79,41 +77,7 @@ export default defineComponent({ ); onMounted(() => { - const match = format.value.match(REGEX_FORMAT); - const { - meridiem, hour, minute, second, milliSecond, - } = EPickerCols; - - const renderCol: EPickerCols[] = []; - - match.forEach((m) => { - switch (m) { - case 'H': - case 'HH': - case 'h': - case 'hh': - renderCol.push(hour); - break; - case 'a': - case 'A': - renderCol.push(meridiem); - break; - case 'm': - case 'mm': - renderCol.push(minute); - break; - case 's': - case 'ss': - renderCol.push(second); - break; - case 'SSS': - renderCol.push(milliSecond); - break; - default: - break; - } - }); - cols.value = renderCol; + cols.value = getPickerCols(format.value); }); // 获取每个时间的高度