From 75e40999cdbdee00ca2338e8e2a61dda360552a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Tue, 16 May 2023 14:18:12 +0800 Subject: [PATCH] feat: color-picker pure panel (#42388) --- components/color-picker/ColorPicker.tsx | 14 +- .../__snapshots__/demo-extend.test.ts.snap | 534 +++++++++--------- .../__tests__/__snapshots__/demo.test.ts.snap | 18 +- components/color-picker/demo/pure-panel.tsx | 6 +- 4 files changed, 298 insertions(+), 274 deletions(-) diff --git a/components/color-picker/ColorPicker.tsx b/components/color-picker/ColorPicker.tsx index 0a9a52cb10..40956a1b24 100644 --- a/components/color-picker/ColorPicker.tsx +++ b/components/color-picker/ColorPicker.tsx @@ -46,6 +46,7 @@ export interface ColorPickerProps onFormatChange?: (format: ColorFormat) => void; onChange?: (value: Color, hex: string) => void; getPopupContainer?: PopoverProps['getPopupContainer']; + autoAdjustOverflow?: PopoverProps['autoAdjustOverflow']; } type CompoundedComponent = React.FC & { @@ -73,6 +74,7 @@ const ColorPicker: CompoundedComponent = (props) => { onChange, onOpenChange, getPopupContainer, + autoAdjustOverflow = true, } = props; const { getPrefixCls, direction } = useContext(ConfigContext); @@ -119,6 +121,7 @@ const ColorPicker: CompoundedComponent = (props) => { arrow, rootClassName, getPopupContainer, + autoAdjustOverflow, }; const colorBaseProps: ColorPickerBaseProps = { @@ -161,7 +164,16 @@ if (process.env.NODE_ENV !== 'production') { ColorPicker.displayName = 'ColorPicker'; } -const PurePanel = genPurePanel(ColorPicker, 'color-picker', (prefixCls) => prefixCls); +const PurePanel = genPurePanel( + ColorPicker, + 'color-picker', + (prefixCls) => prefixCls, + (props: ColorPickerProps) => ({ + ...props, + placement: 'bottom' as TriggerPlacement, + autoAdjustOverflow: false, + }), +); ColorPicker._InternalPanelDoNotUseOrYouWillBeFired = PurePanel; diff --git a/components/color-picker/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/color-picker/__tests__/__snapshots__/demo-extend.test.ts.snap index 4612f52e08..f824f6543a 100644 --- a/components/color-picker/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/color-picker/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -3962,324 +3962,275 @@ Array [ exports[`renders components/color-picker/demo/pure-panel.tsx extend context correctly 1`] = `
+ class="ant-color-picker-color-block" + > +
+
-
-
-