You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.4 KiB
82 lines
2.4 KiB
import type { Dayjs } from 'dayjs';
|
|
import * as React from 'react';
|
|
import DatePicker from '../date-picker';
|
|
import type { PickerTimeProps, RangePickerTimeProps } from '../date-picker/generatePicker';
|
|
import genPurePanel from '../_util/PurePanel';
|
|
import type { InputStatus } from '../_util/statusUtils';
|
|
import warning from '../_util/warning';
|
|
|
|
const { TimePicker: InternalTimePicker, RangePicker: InternalRangePicker } = DatePicker;
|
|
|
|
export interface TimePickerLocale {
|
|
placeholder?: string;
|
|
rangePlaceholder?: [string, string];
|
|
}
|
|
|
|
export interface TimeRangePickerProps extends Omit<RangePickerTimeProps<Dayjs>, 'picker'> {
|
|
popupClassName?: string;
|
|
}
|
|
|
|
const RangePicker = React.forwardRef<any, TimeRangePickerProps>((props, ref) => (
|
|
<InternalRangePicker
|
|
{...props}
|
|
dropdownClassName={props.popupClassName}
|
|
picker="time"
|
|
mode={undefined}
|
|
ref={ref}
|
|
/>
|
|
));
|
|
|
|
export interface TimePickerProps extends Omit<PickerTimeProps<Dayjs>, 'picker'> {
|
|
addon?: () => React.ReactNode;
|
|
popupClassName?: string;
|
|
status?: InputStatus;
|
|
}
|
|
|
|
const TimePicker = React.forwardRef<any, TimePickerProps>(
|
|
({ addon, renderExtraFooter, popupClassName, ...restProps }, ref) => {
|
|
const internalRenderExtraFooter = React.useMemo(() => {
|
|
if (renderExtraFooter) {
|
|
return renderExtraFooter;
|
|
}
|
|
if (addon) {
|
|
warning(
|
|
false,
|
|
'TimePicker',
|
|
'`addon` is deprecated. Please use `renderExtraFooter` instead.',
|
|
);
|
|
return addon;
|
|
}
|
|
return undefined;
|
|
}, [addon, renderExtraFooter]);
|
|
|
|
return (
|
|
<InternalTimePicker
|
|
{...restProps}
|
|
dropdownClassName={popupClassName}
|
|
mode={undefined}
|
|
ref={ref}
|
|
renderExtraFooter={internalRenderExtraFooter}
|
|
/>
|
|
);
|
|
},
|
|
);
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
TimePicker.displayName = 'TimePicker';
|
|
}
|
|
|
|
// We don't care debug panel
|
|
/* istanbul ignore next */
|
|
const PurePanel = genPurePanel(TimePicker, 'picker');
|
|
(TimePicker as MergedTimePicker)._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
|
|
|
|
type MergedTimePicker = typeof TimePicker & {
|
|
RangePicker: typeof RangePicker;
|
|
_InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel;
|
|
};
|
|
|
|
(TimePicker as MergedTimePicker).RangePicker = RangePicker;
|
|
(TimePicker as MergedTimePicker)._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
|
|
|
|
export default TimePicker as MergedTimePicker;
|
|
|