diff --git a/docs/examples/time.tsx b/docs/examples/time.tsx index c42fd05d5..eaa741c46 100644 --- a/docs/examples/time.tsx +++ b/docs/examples/time.tsx @@ -33,6 +33,18 @@ export default () => { generateConfig={momentGenerateConfig} /> +

TimePicker 12 Hours

+ ({ + disabledHours: () => [now.hours()], + })} + generateConfig={momentGenerateConfig} + use12Hours + /> +

RangePicker

= { onSelect?: (value: number) => void; type: 'hour' | 'minute' | 'second' | 'meridiem'; info: { - today: DateType, - locale: Locale, - cellRender: CellRender, - } + today: DateType; + locale: Locale; + cellRender: CellRender; + }; }; function TimeUnitColumn(props: TimeUnitColumnProps) { @@ -38,13 +38,13 @@ function TimeUnitColumn(props: TimeUnitColumnProps) { // `useLayoutEffect` here to avoid blink by duration is 0 useLayoutEffect(() => { const li = liRefs.current.get(value!); - if (li && open !== false) { + if (li && open !== false && type !== 'meridiem') { scrollTo(ulRef.current!, li.offsetTop, 120); } }, [value]); useLayoutEffect(() => { - if (open) { + if (open && type !== 'meridiem') { const li = liRefs.current.get(value!); if (li) { scrollRef.current = waitElementReady(li, () => { @@ -88,14 +88,17 @@ function TimeUnitColumn(props: TimeUnitColumnProps) { onSelect!(unit.value); }} > - {info.cellRender ? info.cellRender(unit.value, { - today: info.today, - locale: info.locale, - originNode:
{unit.label}
, - type: 'time', - subType: type - }) :
{unit.label}
} - + {info.cellRender ? ( + info.cellRender(unit.value, { + today: info.today, + locale: info.locale, + originNode:
{unit.label}
, + type: 'time', + subType: type, + }) + ) : ( +
{unit.label}
+ )} ); })}