Skip to content

Commit

Permalink
feat(ColorPicker): add destroyTooltipOnHide (#42645)
Browse files Browse the repository at this point in the history
* feat(ColorPicker): add destroyTooltipOnHide

* fix: interface -> type
  • Loading branch information
linxianxi committed Jun 19, 2023
1 parent 4af6a52 commit 2c20dcd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions components/color-picker/ColorPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import type {
import useStyle from './style/index';
import { customizePrefixCls, generateColor } from './util';

export interface ColorPickerProps
extends Omit<RcColorPickerProps, 'onChange' | 'value' | 'defaultValue' | 'panelRender'> {
export type ColorPickerProps = Omit<
RcColorPickerProps,
'onChange' | 'value' | 'defaultValue' | 'panelRender'
> & {
value?: Color | string;
defaultValue?: Color | string;
children?: React.ReactNode;
Expand All @@ -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<PopoverProps, 'getPopupContainer' | 'autoAdjustOverflow' | 'destroyTooltipOnHide'>;

type CompoundedComponent = React.FC<ColorPickerProps> & {
_InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel;
Expand Down Expand Up @@ -76,6 +76,7 @@ const ColorPicker: CompoundedComponent = (props) => {
onOpenChange,
getPopupContainer,
autoAdjustOverflow = true,
destroyTooltipOnHide,
} = props;

const { getPrefixCls, direction } = useContext<ConfigConsumerProps>(ConfigContext);
Expand Down Expand Up @@ -140,6 +141,7 @@ const ColorPicker: CompoundedComponent = (props) => {
rootClassName,
getPopupContainer,
autoAdjustOverflow,
destroyTooltipOnHide,
};

const colorBaseProps: ColorPickerBaseProps = {
Expand Down
1 change: 1 addition & 0 deletions components/color-picker/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` | - |
Expand Down
1 change: 1 addition & 0 deletions components/color-picker/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` | - |
Expand Down

0 comments on commit 2c20dcd

Please sign in to comment.