mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 09:26:06 +08:00
Co-authored-by: liangjunqi <liangjunqi@hmntech.com> Co-authored-by: afc163 <afc163@gmail.com>
This commit is contained in:
parent
6a62d9e7ea
commit
48b28e5269
@ -23,7 +23,7 @@ import { useLocale } from '../../locale';
|
|||||||
import { useCompactItemContext } from '../../space/Compact';
|
import { useCompactItemContext } from '../../space/Compact';
|
||||||
import enUS from '../locale/en_US';
|
import enUS from '../locale/en_US';
|
||||||
import useStyle from '../style';
|
import useStyle from '../style';
|
||||||
import { getRangePlaceholder, transPlacement2DropdownAlign, useIcons } from '../util';
|
import { getRangePlaceholder, useIcons } from '../util';
|
||||||
import { TIME } from './constant';
|
import { TIME } from './constant';
|
||||||
import type { RangePickerProps } from './interface';
|
import type { RangePickerProps } from './interface';
|
||||||
import useComponents from './useComponents';
|
import useComponents from './useComponents';
|
||||||
@ -117,7 +117,6 @@ const generateRangePicker = <DateType extends AnyObject = AnyObject>(
|
|||||||
}
|
}
|
||||||
disabled={mergedDisabled}
|
disabled={mergedDisabled}
|
||||||
ref={innerRef as any} // Need to modify PickerRef
|
ref={innerRef as any} // Need to modify PickerRef
|
||||||
popupAlign={transPlacement2DropdownAlign(direction, placement)}
|
|
||||||
placement={placement}
|
placement={placement}
|
||||||
placeholder={getRangePlaceholder(locale, picker, placeholder)}
|
placeholder={getRangePlaceholder(locale, picker, placeholder)}
|
||||||
suffixIcon={suffixNode}
|
suffixIcon={suffixNode}
|
||||||
|
@ -23,7 +23,7 @@ import { useLocale } from '../../locale';
|
|||||||
import { useCompactItemContext } from '../../space/Compact';
|
import { useCompactItemContext } from '../../space/Compact';
|
||||||
import enUS from '../locale/en_US';
|
import enUS from '../locale/en_US';
|
||||||
import useStyle from '../style';
|
import useStyle from '../style';
|
||||||
import { getPlaceholder, transPlacement2DropdownAlign, useIcons } from '../util';
|
import { getPlaceholder, useIcons } from '../util';
|
||||||
import {
|
import {
|
||||||
MONTH,
|
MONTH,
|
||||||
MONTHPICKER,
|
MONTHPICKER,
|
||||||
@ -160,7 +160,6 @@ const generatePicker = <DateType extends AnyObject = AnyObject>(
|
|||||||
ref={innerRef}
|
ref={innerRef}
|
||||||
placeholder={getPlaceholder(locale, mergedPicker, placeholder)}
|
placeholder={getPlaceholder(locale, mergedPicker, placeholder)}
|
||||||
suffixIcon={suffixNode}
|
suffixIcon={suffixNode}
|
||||||
dropdownAlign={transPlacement2DropdownAlign(direction, placement)}
|
|
||||||
placement={placement}
|
placement={placement}
|
||||||
prevIcon={<span className={`${prefixCls}-prev-icon`} />}
|
prevIcon={<span className={`${prefixCls}-prev-icon`} />}
|
||||||
nextIcon={<span className={`${prefixCls}-next-icon`} />}
|
nextIcon={<span className={`${prefixCls}-next-icon`} />}
|
||||||
|
@ -8,7 +8,6 @@ import type {
|
|||||||
PickerProps,
|
PickerProps,
|
||||||
PickerPropsWithMultiple,
|
PickerPropsWithMultiple,
|
||||||
} from './generatePicker/interface';
|
} from './generatePicker/interface';
|
||||||
import { transPlacement2DropdownAlign } from './util';
|
|
||||||
|
|
||||||
export type DatePickerProps<ValueType = Dayjs | Dayjs> = PickerPropsWithMultiple<
|
export type DatePickerProps<ValueType = Dayjs | Dayjs> = PickerPropsWithMultiple<
|
||||||
Dayjs,
|
Dayjs,
|
||||||
@ -30,24 +29,11 @@ export type DatePickerType = typeof DatePicker & {
|
|||||||
generatePicker: typeof generatePicker;
|
generatePicker: typeof generatePicker;
|
||||||
};
|
};
|
||||||
|
|
||||||
function postPureProps(props: DatePickerProps) {
|
|
||||||
const dropdownAlign = transPlacement2DropdownAlign(props.direction, props.placement);
|
|
||||||
|
|
||||||
dropdownAlign.overflow!.adjustY = false;
|
|
||||||
dropdownAlign.overflow!.adjustX = false;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...props,
|
|
||||||
dropdownAlign,
|
|
||||||
popupAlign: dropdownAlign,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't care debug panel
|
// We don't care debug panel
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
const PurePanel = genPurePanel(DatePicker, 'picker', null, postPureProps);
|
const PurePanel = genPurePanel(DatePicker, 'picker', null);
|
||||||
(DatePicker as DatePickerType)._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
|
(DatePicker as DatePickerType)._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
|
||||||
const PureRangePanel = genPurePanel(DatePicker.RangePicker, 'picker', null, postPureProps);
|
const PureRangePanel = genPurePanel(DatePicker.RangePicker, 'picker', null);
|
||||||
(DatePicker as DatePickerType)._InternalRangePanelDoNotUseOrYouWillBeFired = PureRangePanel;
|
(DatePicker as DatePickerType)._InternalRangePanelDoNotUseOrYouWillBeFired = PureRangePanel;
|
||||||
(DatePicker as DatePickerType).generatePicker = generatePicker;
|
(DatePicker as DatePickerType).generatePicker = generatePicker;
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import type { AlignType } from '@rc-component/trigger';
|
|
||||||
import type { PickerMode } from 'rc-picker/lib/interface';
|
import type { PickerMode } from 'rc-picker/lib/interface';
|
||||||
|
|
||||||
import type { SelectCommonPlacement } from '../_util/motion';
|
|
||||||
import type { DirectionType } from '../config-provider';
|
|
||||||
import useSelectIcons from '../select/useIcons';
|
import useSelectIcons from '../select/useIcons';
|
||||||
import type { PickerLocale, PickerProps } from './generatePicker';
|
import type { PickerLocale, PickerProps } from './generatePicker';
|
||||||
|
|
||||||
@ -61,53 +58,6 @@ export function getRangePlaceholder(
|
|||||||
return locale.lang.rangePlaceholder;
|
return locale.lang.rangePlaceholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transPlacement2DropdownAlign(
|
|
||||||
direction: DirectionType,
|
|
||||||
placement?: SelectCommonPlacement,
|
|
||||||
): AlignType {
|
|
||||||
const overflow = {
|
|
||||||
adjustX: 1,
|
|
||||||
adjustY: 1,
|
|
||||||
};
|
|
||||||
switch (placement) {
|
|
||||||
case 'bottomLeft': {
|
|
||||||
return {
|
|
||||||
points: ['tl', 'bl'],
|
|
||||||
offset: [0, 4],
|
|
||||||
overflow,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
case 'bottomRight': {
|
|
||||||
return {
|
|
||||||
points: ['tr', 'br'],
|
|
||||||
offset: [0, 4],
|
|
||||||
overflow,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
case 'topLeft': {
|
|
||||||
return {
|
|
||||||
points: ['bl', 'tl'],
|
|
||||||
offset: [0, -4],
|
|
||||||
overflow,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
case 'topRight': {
|
|
||||||
return {
|
|
||||||
points: ['br', 'tr'],
|
|
||||||
offset: [0, -4],
|
|
||||||
overflow,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return {
|
|
||||||
points: direction === 'rtl' ? ['tr', 'br'] : ['tl', 'bl'],
|
|
||||||
offset: [0, 4],
|
|
||||||
overflow,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useIcons(props: Pick<PickerProps, 'allowClear' | 'removeIcon'>, prefixCls: string) {
|
export function useIcons(props: Pick<PickerProps, 'allowClear' | 'removeIcon'>, prefixCls: string) {
|
||||||
const { allowClear = true } = props;
|
const { allowClear = true } = props;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user