mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
This reverts commit 6c656c85f7
.
Co-authored-by: 二货爱吃白萝卜 <smith3816@gmail.com>
This commit is contained in:
parent
a8e739848e
commit
09b86845a7
8
components/date-picker/PickerButton.tsx
Normal file
8
components/date-picker/PickerButton.tsx
Normal file
@ -0,0 +1,8 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import Button from '../button';
|
||||
import type { ButtonProps } from '../button';
|
||||
|
||||
export default function PickerButton(props: ButtonProps) {
|
||||
return <Button size="small" type="primary" {...props} />;
|
||||
}
|
@ -4,8 +4,8 @@ import CalendarOutlined from '@ant-design/icons/CalendarOutlined';
|
||||
import ClockCircleOutlined from '@ant-design/icons/ClockCircleOutlined';
|
||||
import SwapRightOutlined from '@ant-design/icons/SwapRightOutlined';
|
||||
import classNames from 'classnames';
|
||||
import type { PickerRef } from 'rc-picker';
|
||||
import { RangePicker as RCRangePicker } from 'rc-picker';
|
||||
import type { PickerRef } from 'rc-picker';
|
||||
import type { GenerateConfig } from 'rc-picker/lib/generate/index';
|
||||
|
||||
import ContextIsolator from '../../_util/ContextIsolator';
|
||||
@ -49,7 +49,6 @@ export default function generateRangePicker<DateType extends AnyObject>(
|
||||
status: customStatus,
|
||||
rootClassName,
|
||||
variant: customVariant,
|
||||
okButtonProps,
|
||||
...restProps
|
||||
} = props;
|
||||
|
||||
@ -78,7 +77,7 @@ export default function generateRangePicker<DateType extends AnyObject>(
|
||||
const [mergedAllowClear] = useIcons(props, prefixCls);
|
||||
|
||||
// ================== components ==================
|
||||
const mergedComponents = useComponents(components, okButtonProps);
|
||||
const mergedComponents = useComponents(components);
|
||||
|
||||
// ===================== Size =====================
|
||||
const mergedSize = useSize((ctx) => customizeSize ?? compactSize ?? ctx);
|
||||
|
@ -3,8 +3,8 @@ import { forwardRef, useContext, useImperativeHandle } from 'react';
|
||||
import CalendarOutlined from '@ant-design/icons/CalendarOutlined';
|
||||
import ClockCircleOutlined from '@ant-design/icons/ClockCircleOutlined';
|
||||
import classNames from 'classnames';
|
||||
import type { PickerRef } from 'rc-picker';
|
||||
import RCPicker from 'rc-picker';
|
||||
import type { PickerRef } from 'rc-picker';
|
||||
import type { GenerateConfig } from 'rc-picker/lib/generate/index';
|
||||
import type { PickerMode } from 'rc-picker/lib/interface';
|
||||
|
||||
@ -56,7 +56,6 @@ export default function generatePicker<DateType extends AnyObject>(
|
||||
status: customStatus,
|
||||
variant: customVariant,
|
||||
onCalendarChange,
|
||||
okButtonProps,
|
||||
...restProps
|
||||
} = props;
|
||||
|
||||
@ -120,7 +119,7 @@ export default function generatePicker<DateType extends AnyObject>(
|
||||
const [mergedAllowClear, removeIcon] = useIcons(props, prefixCls);
|
||||
|
||||
// ================== components ==================
|
||||
const mergedComponents = useComponents(components, okButtonProps);
|
||||
const mergedComponents = useComponents(components);
|
||||
|
||||
// ===================== Size =====================
|
||||
const mergedSize = useSize((ctx) => customizeSize ?? compactSize ?? ctx);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type {
|
||||
PickerProps as RcPickerProps,
|
||||
PickerRef,
|
||||
PickerProps as RcPickerProps,
|
||||
RangePickerProps as RcRangePickerProps,
|
||||
} from 'rc-picker';
|
||||
import type { Locale as RcPickerLocale } from 'rc-picker/lib/interface';
|
||||
@ -10,7 +10,6 @@ import type { AnyObject } from '../../_util/type';
|
||||
import type { SizeType } from '../../config-provider/SizeContext';
|
||||
import type { Variant } from '../../config-provider';
|
||||
import type { TimePickerLocale } from '../../time-picker';
|
||||
import type { ButtonProps } from '../../button/button';
|
||||
|
||||
const DataPickerPlacements = ['bottomLeft', 'bottomRight', 'topLeft', 'topRight'] as const;
|
||||
|
||||
@ -62,7 +61,6 @@ type InjectDefaultProps<Props> = Omit<Props, 'locale' | 'generateConfig' | 'hide
|
||||
popupClassName?: string;
|
||||
rootClassName?: string;
|
||||
popupStyle?: React.CSSProperties;
|
||||
okButtonProps?: ButtonProps;
|
||||
};
|
||||
|
||||
/** Base Single Picker props */
|
||||
|
14
components/date-picker/generatePicker/useComponents.ts
Normal file
14
components/date-picker/generatePicker/useComponents.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { useMemo } from 'react';
|
||||
import type { Components } from 'rc-picker/lib/interface';
|
||||
|
||||
import PickerButton from '../PickerButton';
|
||||
|
||||
export default function useComponents(components?: Components) {
|
||||
return useMemo(
|
||||
() => ({
|
||||
button: PickerButton,
|
||||
...components,
|
||||
}),
|
||||
[components],
|
||||
);
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
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],
|
||||
);
|
||||
}
|
@ -154,7 +154,6 @@ The following APIs are shared by DatePicker, RangePicker.
|
||||
| value | To set date | [dayjs](https://day.js.org/) | - | |
|
||||
| onChange | Callback function, can be executed when the selected time is changing | function(date: dayjs, dateString: string) | - | |
|
||||
| onOk | Callback when click ok button | function() | - | |
|
||||
| okButtonProps | The ok button props | [ButtonProps](/components/button/#api) | - | |
|
||||
| onPanelChange | Callback function for panel changing | function(value, mode) | - | |
|
||||
|
||||
### DatePicker\[picker=year]
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -99,11 +99,4 @@ describe('TimePicker', () => {
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should modify the ok button', () => {
|
||||
const { container } = render(
|
||||
<TimePicker open okButtonProps={{ className: 'test-ok-button' }} />,
|
||||
);
|
||||
expect(Array.from(container.children)).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
@ -82,7 +82,6 @@ dayjs.extend(customParseFormat)
|
||||
| onCalendarChange | Callback function, can be executed when the start time or the end time of the range is changing. `info` argument is added in 4.4.0 | function(dates: \[dayjs, dayjs], dateStrings: \[string, string], info: { range:`start`\|`end` }) | - | |
|
||||
| onChange | A callback function, can be executed when the selected time is changing | function(time: dayjs, timeString: string): void | - | |
|
||||
| onOpenChange | A callback function which will be called while panel opening/closing | (open: boolean) => void | - | |
|
||||
| okButtonProps | The ok button props | [ButtonProps](/components/button/#api) | - | |
|
||||
|
||||
#### DisabledTime
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user