mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-16 01:29:11 +08:00
832cffcdf9
* refactor: support type update * chore: update clear style * chore: bump color picker * chore: use slider * chore: bump color picker * chore: range slider * chore: layout * chore: useModeColor * chore: simplify * chore: bump color picker * refactor: event * chore: tmp lock check * chore: of it * chore: update ts def * chore: update ts def * chore: remove useless ts * chore: linear * chore: adjust style * chore: rm useless code * chore: fill color * chore: basic linear * chore: support toStr * chore: limit minCount * chore: use cache * chore: drag support: * chore: yes * chore: update demo * chore: useLayoutEffect instead * chore: fix click to add point * chore: add smmoth * chore: support of locale * chore: add locale * chore: fix lint * chore: adjust style * chore: fix lint * chore: fix style * test: fix test case * chore: fix popover * test: fix test case * chore: fix test * test: clean up * chore: fix lint * chore: fix lint * chore: fix lint * test: coverage * test: coverage * test: coverage * test: coverage * test: coverage * test: coverage * chore: fix docs * docs: update demo desc * chore: enhance hover range * fix: delete not working * chore: fix lint * test: coverage * test: coverage * chore: clean up * chore: adjust * chore: highlight * chore: adjust style * chore: fix lint * chore: update demo * chore: memo perf * refactor: up to down colors * test: update snapshot
92 lines
2.4 KiB
TypeScript
92 lines
2.4 KiB
TypeScript
import type { CSSProperties, FC, ReactNode } from 'react';
|
|
import type {
|
|
ColorGenInput,
|
|
ColorPickerProps as RcColorPickerProps,
|
|
} from '@rc-component/color-picker';
|
|
|
|
import type { SizeType } from '../config-provider/SizeContext';
|
|
import type { PopoverProps } from '../popover';
|
|
import type { TooltipPlacement } from '../tooltip';
|
|
import type { AggregationColor } from './color';
|
|
|
|
export type { ColorGenInput };
|
|
|
|
export type Colors<T> = {
|
|
color: ColorGenInput<T>;
|
|
percent: number;
|
|
}[];
|
|
|
|
export enum ColorFormat {
|
|
hex = 'hex',
|
|
rgb = 'rgb',
|
|
hsb = 'hsb',
|
|
}
|
|
|
|
export type ColorFormatType = keyof typeof ColorFormat;
|
|
|
|
export interface PresetsItem {
|
|
label: ReactNode;
|
|
colors: (string | AggregationColor)[];
|
|
/**
|
|
* Whether the initial state is collapsed
|
|
* @since 5.11.0
|
|
* @default true
|
|
*/
|
|
defaultOpen?: boolean;
|
|
}
|
|
export type TriggerType = 'click' | 'hover';
|
|
|
|
export type TriggerPlacement = TooltipPlacement; // Alias, to prevent breaking changes.
|
|
|
|
export type SingleValueType = AggregationColor | string;
|
|
|
|
export type ColorValueType =
|
|
| SingleValueType
|
|
| null
|
|
| {
|
|
color: SingleValueType;
|
|
percent: number;
|
|
}[];
|
|
|
|
export type ModeType = 'single' | 'gradient';
|
|
|
|
export type ColorPickerProps = Omit<
|
|
RcColorPickerProps,
|
|
| 'onChange'
|
|
| 'value'
|
|
| 'defaultValue'
|
|
| 'panelRender'
|
|
| 'disabledAlpha'
|
|
| 'onChangeComplete'
|
|
| 'components'
|
|
> & {
|
|
mode?: ModeType | ModeType[];
|
|
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: AggregationColor) => 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: AggregationColor, hex: string) => void;
|
|
onClear?: () => void;
|
|
onChangeComplete?: (value: AggregationColor) => void;
|
|
} & Pick<PopoverProps, 'getPopupContainer' | 'autoAdjustOverflow' | 'destroyTooltipOnHide'>;
|