demo: disable auto adjust placement in DatePicker design panel (#52113)

* demo: disable auto adjust placement in DatePicker design panel

* demo: disable auto adjust placement in DatePicker design panel

* demo: disable auto adjust placement in DatePicker design panel

* demo: disable auto adjust placement in DatePicker design panel

* fix

---------

Co-authored-by: lijianan <574980606@qq.com>
This commit is contained in:
afc163 2024-12-30 13:19:56 +08:00 committed by GitHub
parent 1d267d9e83
commit 513f22784d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 26 additions and 29 deletions

View File

@ -20,9 +20,10 @@ export interface BaseProps {
/* istanbul ignore next */ /* istanbul ignore next */
const genPurePanel = <ComponentProps extends BaseProps = BaseProps>( const genPurePanel = <ComponentProps extends BaseProps = BaseProps>(
Component: any, Component: any,
defaultPrefixCls?: string, alignPropName?: 'align' | 'dropdownAlign' | 'popupAlign',
getDropdownCls?: null | ((prefixCls: string) => string),
postProps?: (props: ComponentProps) => ComponentProps, postProps?: (props: ComponentProps) => ComponentProps,
defaultPrefixCls?: string,
getDropdownCls?: (prefixCls: string) => string,
) => { ) => {
type WrapProps = ComponentProps & AnyObject; type WrapProps = ComponentProps & AnyObject;
@ -55,7 +56,6 @@ const genPurePanel = <ComponentProps extends BaseProps = BaseProps>(
? `.${getDropdownCls(prefixCls)}` ? `.${getDropdownCls(prefixCls)}`
: `.${prefixCls}-dropdown`; : `.${prefixCls}-dropdown`;
const popup = holderRef.current?.querySelector(dropdownCls); const popup = holderRef.current?.querySelector(dropdownCls);
if (popup) { if (popup) {
clearInterval(interval); clearInterval(interval);
resizeObserver.observe(popup); resizeObserver.observe(popup);
@ -83,6 +83,16 @@ const genPurePanel = <ComponentProps extends BaseProps = BaseProps>(
if (postProps) { if (postProps) {
mergedProps = postProps(mergedProps); mergedProps = postProps(mergedProps);
} }
if (alignPropName) {
Object.assign(mergedProps, {
[alignPropName]: {
overflow: {
adjustX: false,
adjustY: false,
},
},
});
}
const mergedStyle: React.CSSProperties = { const mergedStyle: React.CSSProperties = {
paddingBottom: popupHeight, paddingBottom: popupHeight,
position: 'relative', position: 'relative',

View File

@ -170,7 +170,7 @@ const RefAutoComplete = React.forwardRef<RefSelectProps, AutoCompleteProps>(
// We don't care debug panel // We don't care debug panel
/* istanbul ignore next */ /* istanbul ignore next */
const PurePanel = genPurePanel(RefAutoComplete, undefined, undefined, (props: any) => const PurePanel = genPurePanel(RefAutoComplete, 'dropdownAlign', (props: any) =>
omit(props, ['visible']), omit(props, ['visible']),
); );

View File

@ -370,9 +370,7 @@ if (process.env.NODE_ENV !== 'production') {
// We don't care debug panel // We don't care debug panel
/* istanbul ignore next */ /* istanbul ignore next */
const PurePanel = genPurePanel(Cascader, undefined, undefined, (props: any) => const PurePanel = genPurePanel(Cascader, 'dropdownAlign', (props: any) => omit(props, ['visible']));
omit(props, ['visible']),
);
Cascader.SHOW_PARENT = SHOW_PARENT; Cascader.SHOW_PARENT = SHOW_PARENT;
Cascader.SHOW_CHILD = SHOW_CHILD; Cascader.SHOW_CHILD = SHOW_CHILD;

View File

@ -280,14 +280,15 @@ if (process.env.NODE_ENV !== 'production') {
const PurePanel = genPurePanel( const PurePanel = genPurePanel(
ColorPicker, ColorPicker,
'color-picker', undefined,
/* istanbul ignore next */
(prefixCls) => prefixCls,
(props: ColorPickerProps) => ({ (props: ColorPickerProps) => ({
...props, ...props,
placement: 'bottom' as TriggerPlacement, placement: 'bottom' as TriggerPlacement,
autoAdjustOverflow: false, autoAdjustOverflow: false,
}), }),
'color-picker',
/* istanbul ignore next */
(prefixCls) => prefixCls,
); );
ColorPicker._InternalPanelDoNotUseOrYouWillBeFired = PurePanel; ColorPicker._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;

View File

@ -31,9 +31,9 @@ export type DatePickerType = typeof DatePicker & {
// We don't care debug panel // We don't care debug panel
/* istanbul ignore next */ /* istanbul ignore next */
const PurePanel = genPurePanel(DatePicker, 'picker', null); const PurePanel = genPurePanel(DatePicker, 'popupAlign', undefined, 'picker');
(DatePicker as DatePickerType)._InternalPanelDoNotUseOrYouWillBeFired = PurePanel; (DatePicker as DatePickerType)._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
const PureRangePanel = genPurePanel(DatePicker.RangePicker, 'picker', null); const PureRangePanel = genPurePanel(DatePicker.RangePicker, 'popupAlign', undefined, 'picker');
(DatePicker as DatePickerType)._InternalRangePanelDoNotUseOrYouWillBeFired = PureRangePanel; (DatePicker as DatePickerType)._InternalRangePanelDoNotUseOrYouWillBeFired = PureRangePanel;
(DatePicker as DatePickerType).generatePicker = generatePicker; (DatePicker as DatePickerType).generatePicker = generatePicker;

View File

@ -315,20 +315,8 @@ const Dropdown: CompoundedComponent = (props) => {
return wrapCSSVar(renderNode); return wrapCSSVar(renderNode);
}; };
function postPureProps(props: DropdownProps) {
return {
...props,
align: {
overflow: {
adjustX: false,
adjustY: false,
},
},
};
}
// We don't care debug panel // We don't care debug panel
const PurePanel = genPurePanel(Dropdown, 'dropdown', (prefixCls) => prefixCls, postPureProps); const PurePanel = genPurePanel(Dropdown, 'align', undefined, 'dropdown', (prefixCls) => prefixCls);
/* istanbul ignore next */ /* istanbul ignore next */
const WrapPurePanel: React.FC<DropdownProps> = (props) => ( const WrapPurePanel: React.FC<DropdownProps> = (props) => (

View File

@ -232,7 +232,7 @@ Mentions.Option = Option;
// We don't care debug panel // We don't care debug panel
/* istanbul ignore next */ /* istanbul ignore next */
const PurePanel = genPurePanel(Mentions, 'mentions'); const PurePanel = genPurePanel(Mentions, undefined, undefined, 'mentions');
Mentions._InternalPanelDoNotUseOrYouWillBeFired = PurePanel; Mentions._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
Mentions.getMentions = (value = '', config: MentionsConfig = {}): MentionsEntity[] => { Mentions.getMentions = (value = '', config: MentionsConfig = {}): MentionsEntity[] => {

View File

@ -331,7 +331,7 @@ const Select = React.forwardRef(InternalSelect) as unknown as (<
// We don't care debug panel // We don't care debug panel
/* istanbul ignore next */ /* istanbul ignore next */
const PurePanel = genPurePanel(Select); const PurePanel = genPurePanel(Select, 'dropdownAlign');
Select.SECRET_COMBOBOX_MODE_DO_NOT_USE = SECRET_COMBOBOX_MODE_DO_NOT_USE; Select.SECRET_COMBOBOX_MODE_DO_NOT_USE = SECRET_COMBOBOX_MODE_DO_NOT_USE;
Select.Option = Option; Select.Option = Option;

View File

@ -85,7 +85,7 @@ if (process.env.NODE_ENV !== 'production') {
// We don't care debug panel // We don't care debug panel
/* istanbul ignore next */ /* istanbul ignore next */
const PurePanel = genPurePanel(TimePicker, 'picker'); const PurePanel = genPurePanel(TimePicker, 'popupAlign', undefined, 'picker');
(TimePicker as MergedTimePicker)._InternalPanelDoNotUseOrYouWillBeFired = PurePanel; (TimePicker as MergedTimePicker)._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
type MergedTimePicker = typeof TimePicker & { type MergedTimePicker = typeof TimePicker & {

View File

@ -337,7 +337,7 @@ const TreeSelect = TreeSelectRef as CompoundedComponent;
// We don't care debug panel // We don't care debug panel
/* istanbul ignore next */ /* istanbul ignore next */
const PurePanel = genPurePanel(TreeSelect, undefined, undefined, (props: any) => const PurePanel = genPurePanel(TreeSelect, 'dropdownAlign', (props: any) =>
omit(props, ['visible']), omit(props, ['visible']),
); );