ant-design/components/date-picker/generatePicker/useComponents.tsx
Tantatorn Suksangwarn 6c656c85f7
feat: Add okButtonProps to time picker (#49657)
* feat: add `okButtonProps` to pickers' props

* doc: add okButtonProps to date, time picker documentation

* test: add new test case for TimePicker
2024-06-30 23:17:14 +08:00

22 lines
597 B
TypeScript

import React, { useMemo } from 'react';
import type { Components } from 'rc-picker/lib/interface';
import type { ButtonProps } from '../../button/button';
import Button from '../../button/button';
export default function useComponents(components?: Components, buttonProps?: ButtonProps) {
function PickerButton(props: ButtonProps) {
const mergedProps = { size: 'small', type: 'primary', ...buttonProps, ...props } as ButtonProps;
return <Button {...mergedProps} />;
}
return useMemo(
() => ({
button: PickerButton,
...components,
}),
[components],
);
}