feat(ColorPicker): add destroyTooltipOnHide (#42645)

* feat(ColorPicker): add destroyTooltipOnHide

* fix: interface -> type
This commit is contained in:
daisy 2023-06-19 14:28:11 +08:00 committed by GitHub
parent 4af6a526e2
commit 2c20dcd4cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -26,8 +26,10 @@ import type {
import useStyle from './style/index'; import useStyle from './style/index';
import { customizePrefixCls, generateColor } from './util'; import { customizePrefixCls, generateColor } from './util';
export interface ColorPickerProps export type ColorPickerProps = Omit<
extends Omit<RcColorPickerProps, 'onChange' | 'value' | 'defaultValue' | 'panelRender'> { RcColorPickerProps,
'onChange' | 'value' | 'defaultValue' | 'panelRender'
> & {
value?: Color | string; value?: Color | string;
defaultValue?: Color | string; defaultValue?: Color | string;
children?: React.ReactNode; children?: React.ReactNode;
@ -45,9 +47,7 @@ export interface ColorPickerProps
onFormatChange?: (format: ColorFormat) => void; onFormatChange?: (format: ColorFormat) => void;
onChange?: (value: Color, hex: string) => void; onChange?: (value: Color, hex: string) => void;
onClear?: () => void; onClear?: () => void;
getPopupContainer?: PopoverProps['getPopupContainer']; } & Pick<PopoverProps, 'getPopupContainer' | 'autoAdjustOverflow' | 'destroyTooltipOnHide'>;
autoAdjustOverflow?: PopoverProps['autoAdjustOverflow'];
}
type CompoundedComponent = React.FC<ColorPickerProps> & { type CompoundedComponent = React.FC<ColorPickerProps> & {
_InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel; _InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel;
@ -76,6 +76,7 @@ const ColorPicker: CompoundedComponent = (props) => {
onOpenChange, onOpenChange,
getPopupContainer, getPopupContainer,
autoAdjustOverflow = true, autoAdjustOverflow = true,
destroyTooltipOnHide,
} = props; } = props;
const { getPrefixCls, direction } = useContext<ConfigConsumerProps>(ConfigContext); const { getPrefixCls, direction } = useContext<ConfigConsumerProps>(ConfigContext);
@ -140,6 +141,7 @@ const ColorPicker: CompoundedComponent = (props) => {
rootClassName, rootClassName,
getPopupContainer, getPopupContainer,
autoAdjustOverflow, autoAdjustOverflow,
destroyTooltipOnHide,
}; };
const colorBaseProps: ColorPickerBaseProps = { const colorBaseProps: ColorPickerBaseProps = {

View File

@ -47,6 +47,7 @@ Used when the user needs to customize the color selection.
| disabled | Disable ColorPicker | boolean | - | | disabled | Disable ColorPicker | boolean | - |
| placement | Placement of popup | `top` \| `topLeft` \| `topRight` \| `bottom` \| `bottomLeft` \| `bottomRight` | `bottomLeft` | | placement | Placement of popup | `top` \| `topLeft` \| `topRight` \| `bottom` \| `bottomLeft` \| `bottomRight` | `bottomLeft` |
| arrow | Configuration for popup arrow | `boolean \| { pointAtCenter: boolean }` | `true` | - | | arrow | Configuration for popup arrow | `boolean \| { pointAtCenter: boolean }` | `true` | - |
| destroyTooltipOnHide | Whether destroy popover when hidden | `boolean` | `false` |
| onChange | Callback when `value` is changed | `(value: Color, hex: string) => void` | - | | onChange | Callback when `value` is changed | `(value: Color, hex: string) => void` | - |
| onFormatChange | Callback when `format` is changed | `(format: 'hex' \| 'rgb' \| 'hsb') => void` | - | | onFormatChange | Callback when `format` is changed | `(format: 'hex' \| 'rgb' \| 'hsb') => void` | - |
| onOpenChange | Callback when `open` is changed | `(open: boolean) => void` | - | | onOpenChange | Callback when `open` is changed | `(open: boolean) => void` | - |

View File

@ -48,6 +48,7 @@ group:
| disabled | 禁用颜色选择器 | boolean | - | | disabled | 禁用颜色选择器 | boolean | - |
| placement | 弹出窗口的位置 | `top` \| `topLeft` \| `topRight` \| `bottom` \| `bottomLeft` \| `bottomRight` | `bottomLeft` | | placement | 弹出窗口的位置 | `top` \| `topLeft` \| `topRight` \| `bottom` \| `bottomLeft` \| `bottomRight` | `bottomLeft` |
| arrow | 配置弹出的箭头 | `boolean \| { pointAtCenter: boolean }` | `true` | - | | arrow | 配置弹出的箭头 | `boolean \| { pointAtCenter: boolean }` | `true` | - |
| destroyTooltipOnHide | 关闭后是否销毁弹窗 | `boolean` | `false` |
| onChange | 颜色变化的回调 | `(value: Color, hex: string) => void` | - | | onChange | 颜色变化的回调 | `(value: Color, hex: string) => void` | - |
| onFormatChange | 颜色格式变化的回调 | `(format: 'hex' \| 'rgb' \| 'hsb') => void` | - | | onFormatChange | 颜色格式变化的回调 | `(format: 'hex' \| 'rgb' \| 'hsb') => void` | - |
| onOpenChange | 当 `open` 被改变时的回调 | `(open: boolean) => void` | - | | onOpenChange | 当 `open` 被改变时的回调 | `(open: boolean) => void` | - |