mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-16 01:29:11 +08:00
14a1e6bd51
* feat: tsconfig enable strict * feat: add no-explicit-any * feat: strict * feat: as THEME * feat: 优化 keys 类型写法 * feat: demo remove any * feat: as number * feat: this any * feat: add eslint * feat: cascader * feat: props any * feat: remove any * feat: remove any * feat: any 提示错误 * feat: remove any * feat: add eslint * feat: 允许 T = any 存在 * feat: color funciton * feat: 恢复 lint * feat: merge master * feat: as ReactElement * feat: type
82 lines
2.4 KiB
TypeScript
82 lines
2.4 KiB
TypeScript
import type { CSSProperties, FC, ReactNode } from 'react';
|
|
import type { ColorPickerProps as RcColorPickerProps } from '@rc-component/color-picker';
|
|
|
|
import type { SizeType } from '../config-provider/SizeContext';
|
|
import type { PopoverProps } from '../popover';
|
|
import type { Color } from './color';
|
|
|
|
export enum ColorFormat {
|
|
hex = 'hex',
|
|
rgb = 'rgb',
|
|
hsb = 'hsb',
|
|
}
|
|
|
|
export type ColorFormatType = keyof typeof ColorFormat;
|
|
|
|
export interface PresetsItem {
|
|
label: ReactNode;
|
|
colors: (string | Color)[];
|
|
/**
|
|
* Whether the initial state is collapsed
|
|
* @since 5.11.0
|
|
* @default true
|
|
*/
|
|
defaultOpen?: boolean;
|
|
}
|
|
export type TriggerType = 'click' | 'hover';
|
|
|
|
export type TriggerPlacement =
|
|
| 'top'
|
|
| 'topLeft'
|
|
| 'topRight'
|
|
| 'bottom'
|
|
| 'bottomLeft'
|
|
| 'bottomRight';
|
|
export interface ColorPickerBaseProps {
|
|
color?: Color;
|
|
prefixCls: string;
|
|
format?: ColorFormatType;
|
|
allowClear?: boolean;
|
|
disabled?: boolean;
|
|
disabledAlpha?: boolean;
|
|
presets?: PresetsItem[];
|
|
panelRender?: ColorPickerProps['panelRender'];
|
|
onFormatChange?: ColorPickerProps['onFormatChange'];
|
|
onChangeComplete?: ColorPickerProps['onChangeComplete'];
|
|
}
|
|
|
|
export type ColorValueType = Color | string | null;
|
|
|
|
export type ColorPickerProps = Omit<
|
|
RcColorPickerProps,
|
|
'onChange' | 'value' | 'defaultValue' | 'panelRender' | 'disabledAlpha' | 'onChangeComplete'
|
|
> & {
|
|
value?: ColorValueType;
|
|
defaultValue?: ColorValueType;
|
|
children?: React.ReactNode;
|
|
open?: boolean;
|
|
disabled?: boolean;
|
|
placement?: TriggerPlacement;
|
|
trigger?: TriggerType;
|
|
format?: ColorFormatType;
|
|
defaultFormat?: ColorFormatType;
|
|
allowClear?: boolean;
|
|
presets?: PresetsItem[];
|
|
arrow?: boolean | { pointAtCenter: boolean };
|
|
panelRender?: (
|
|
panel: React.ReactNode,
|
|
extra: { components: { Picker: FC; Presets: FC } },
|
|
) => React.ReactNode;
|
|
showText?: boolean | ((color: Color) => React.ReactNode);
|
|
size?: SizeType;
|
|
styles?: { popup?: CSSProperties; popupOverlayInner?: CSSProperties };
|
|
rootClassName?: string;
|
|
disabledAlpha?: boolean;
|
|
[key: `data-${string}`]: string;
|
|
onOpenChange?: (open: boolean) => void;
|
|
onFormatChange?: (format?: ColorFormatType) => void;
|
|
onChange?: (value: Color, hex: string) => void;
|
|
onClear?: () => void;
|
|
onChangeComplete?: (value: Color) => void;
|
|
} & Pick<PopoverProps, 'getPopupContainer' | 'autoAdjustOverflow' | 'destroyTooltipOnHide'>;
|