From 2c20dcd4cc1f448ae64ed0ea2a43b18ac0ebfccd Mon Sep 17 00:00:00 2001 From: daisy <47104575+linxianxi@users.noreply.github.com> Date: Mon, 19 Jun 2023 14:28:11 +0800 Subject: [PATCH] feat(ColorPicker): add destroyTooltipOnHide (#42645) * feat(ColorPicker): add destroyTooltipOnHide * fix: interface -> type --- components/color-picker/ColorPicker.tsx | 12 +++++++----- components/color-picker/index.en-US.md | 1 + components/color-picker/index.zh-CN.md | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/components/color-picker/ColorPicker.tsx b/components/color-picker/ColorPicker.tsx index 43f6d191cb..5060081f53 100644 --- a/components/color-picker/ColorPicker.tsx +++ b/components/color-picker/ColorPicker.tsx @@ -26,8 +26,10 @@ import type { import useStyle from './style/index'; import { customizePrefixCls, generateColor } from './util'; -export interface ColorPickerProps - extends Omit { +export type ColorPickerProps = Omit< + RcColorPickerProps, + 'onChange' | 'value' | 'defaultValue' | 'panelRender' +> & { value?: Color | string; defaultValue?: Color | string; children?: React.ReactNode; @@ -45,9 +47,7 @@ export interface ColorPickerProps onFormatChange?: (format: ColorFormat) => void; onChange?: (value: Color, hex: string) => void; onClear?: () => void; - getPopupContainer?: PopoverProps['getPopupContainer']; - autoAdjustOverflow?: PopoverProps['autoAdjustOverflow']; -} +} & Pick; type CompoundedComponent = React.FC & { _InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel; @@ -76,6 +76,7 @@ const ColorPicker: CompoundedComponent = (props) => { onOpenChange, getPopupContainer, autoAdjustOverflow = true, + destroyTooltipOnHide, } = props; const { getPrefixCls, direction } = useContext(ConfigContext); @@ -140,6 +141,7 @@ const ColorPicker: CompoundedComponent = (props) => { rootClassName, getPopupContainer, autoAdjustOverflow, + destroyTooltipOnHide, }; const colorBaseProps: ColorPickerBaseProps = { diff --git a/components/color-picker/index.en-US.md b/components/color-picker/index.en-US.md index 31eca196c6..709ac59c34 100644 --- a/components/color-picker/index.en-US.md +++ b/components/color-picker/index.en-US.md @@ -47,6 +47,7 @@ Used when the user needs to customize the color selection. | disabled | Disable ColorPicker | boolean | - | | placement | Placement of popup | `top` \| `topLeft` \| `topRight` \| `bottom` \| `bottomLeft` \| `bottomRight` | `bottomLeft` | | 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` | - | | onFormatChange | Callback when `format` is changed | `(format: 'hex' \| 'rgb' \| 'hsb') => void` | - | | onOpenChange | Callback when `open` is changed | `(open: boolean) => void` | - | diff --git a/components/color-picker/index.zh-CN.md b/components/color-picker/index.zh-CN.md index db4a5a9c0c..f6ce4d9bda 100644 --- a/components/color-picker/index.zh-CN.md +++ b/components/color-picker/index.zh-CN.md @@ -48,6 +48,7 @@ group: | disabled | 禁用颜色选择器 | boolean | - | | placement | 弹出窗口的位置 | `top` \| `topLeft` \| `topRight` \| `bottom` \| `bottomLeft` \| `bottomRight` | `bottomLeft` | | arrow | 配置弹出的箭头 | `boolean \| { pointAtCenter: boolean }` | `true` | - | +| destroyTooltipOnHide | 关闭后是否销毁弹窗 | `boolean` | `false` | | onChange | 颜色变化的回调 | `(value: Color, hex: string) => void` | - | | onFormatChange | 颜色格式变化的回调 | `(format: 'hex' \| 'rgb' \| 'hsb') => void` | - | | onOpenChange | 当 `open` 被改变时的回调 | `(open: boolean) => void` | - |