import type { SketchPickerProps } from 'react-color'; import { SketchPicker } from 'react-color'; import React, { useContext } from 'react'; import useMergedState from 'rc-util/lib/hooks/useMergedState'; import type { PopoverProps } from 'antd'; import { ConfigProvider } from 'antd'; import { Popover } from 'antd'; import type { ProFieldFC } from '../../index'; export const DEFAULT_COLORS = [ '#FF9D4E', // 0 - 橘黄色 '#5BD8A6', // 1 - 绿色 '#5B8FF9', // 2 - 蓝色 '#F7664E', // 3 - 红色 '#FF86B7', // 4 - 水红色 '#2B9E9D', // 5 - 墨绿色 '#9270CA', // 6 - 紫色 '#6DC8EC', // 7 - 浅蓝色 '#667796', // 8 - 黛蓝色 '#F6BD16', // 9 - 黄色 ]; const ColorPicker: React.FC< SketchPickerProps & { value?: string; popoverProps?: PopoverProps; mode?: 'read' | 'edit'; onChange?: (color: string) => void; colors?: string[]; } > = ({ mode, popoverProps, ...rest }) => { const { getPrefixCls } = useContext(ConfigProvider.ConfigContext); const prefixCls = getPrefixCls('pro-field-color-picker'); const [color, setColor] = useMergedState('#1890ff', { value: rest.value, onChange: rest.onChange, }); const readDom = (