mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-01 06:49:32 +08:00
38474628fd
* fix: prepend use-client directive for with Next.js App Router * Update components/affix/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/badge/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/divider/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/cascader/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/list/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/qrcode/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/spin/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/select/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/spin/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/spin/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/steps/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/time-picker/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/transfer/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/tree-select/index.tsx Signed-off-by: lijianan <574980606@qq.com> --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: MadCcc <1075746765@qq.com>
79 lines
2.3 KiB
TypeScript
79 lines
2.3 KiB
TypeScript
'use client';
|
|
|
|
import type { Dayjs } from 'dayjs';
|
|
import * as React from 'react';
|
|
import genPurePanel from '../_util/PurePanel';
|
|
import type { InputStatus } from '../_util/statusUtils';
|
|
import warning from '../_util/warning';
|
|
import DatePicker from '../date-picker';
|
|
import type { PickerTimeProps, RangePickerTimeProps } from '../date-picker/generatePicker';
|
|
|
|
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} picker="time" mode={undefined} ref={ref} />
|
|
));
|
|
|
|
export interface TimePickerProps extends Omit<PickerTimeProps<Dayjs>, 'picker'> {
|
|
addon?: () => React.ReactNode;
|
|
status?: InputStatus;
|
|
popupClassName?: string;
|
|
}
|
|
|
|
const TimePicker = React.forwardRef<any, TimePickerProps>(
|
|
({ addon, renderExtraFooter, ...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}
|
|
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;
|