customizable-gradient-picker 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +604 -0
- package/dist/components/alpha-input/alpha-input.style.d.ts +8 -0
- package/dist/components/alpha-input/helpers.d.ts +3 -0
- package/dist/components/alpha-input/index.d.ts +28 -0
- package/dist/components/alpha-slider/index.d.ts +11 -0
- package/dist/components/angle-input/index.d.ts +22 -0
- package/dist/components/color-square/index.d.ts +9 -0
- package/dist/components/delete-stop/index.d.ts +10 -0
- package/dist/components/eye-dropper/index.d.ts +11 -0
- package/dist/components/gradient-formats/const.d.ts +3 -0
- package/dist/components/gradient-formats/index.d.ts +19 -0
- package/dist/components/gradient-preview/index.d.ts +4 -0
- package/dist/components/gradient-slider/const.d.ts +1 -0
- package/dist/components/gradient-slider/helpers.d.ts +28 -0
- package/dist/components/gradient-slider/index.d.ts +11 -0
- package/dist/components/gradient-string/index.d.ts +13 -0
- package/dist/components/hex-input/helpers.d.ts +1 -0
- package/dist/components/hex-input/index.d.ts +14 -0
- package/dist/components/hex-preview/index.d.ts +4 -0
- package/dist/components/hue-slider/const.d.ts +1 -0
- package/dist/components/hue-slider/index.d.ts +10 -0
- package/dist/components/index.d.ts +16 -0
- package/dist/components/render-icon.d.ts +2 -0
- package/dist/components/rgba-input/const.d.ts +2 -0
- package/dist/components/rgba-input/helpers.d.ts +5 -0
- package/dist/components/rgba-input/index.d.ts +28 -0
- package/dist/components/rgba-preview/index.d.ts +4 -0
- package/dist/components/stop-position/helpers.d.ts +6 -0
- package/dist/components/stop-position/index.d.ts +33 -0
- package/dist/const.d.ts +2 -0
- package/dist/context/color-provider.d.ts +8 -0
- package/dist/context/color.d.ts +5 -0
- package/dist/context/compose.d.ts +30 -0
- package/dist/context/gradient-provider.d.ts +15 -0
- package/dist/context/gradient.d.ts +12 -0
- package/dist/context/index.d.ts +7 -0
- package/dist/context/stops-provider.d.ts +15 -0
- package/dist/context/stops.d.ts +12 -0
- package/dist/helpers/color.d.ts +46 -0
- package/dist/helpers/function.d.ts +8 -0
- package/dist/helpers/gradient.d.ts +19 -0
- package/dist/helpers/index.d.ts +6 -0
- package/dist/helpers/number.d.ts +1 -0
- package/dist/helpers/string.d.ts +2 -0
- package/dist/helpers/styles.d.ts +1 -0
- package/dist/hooks/gradient/helpers.d.ts +9 -0
- package/dist/hooks/gradient/index.d.ts +4 -0
- package/dist/hooks/gradient/types.d.ts +53 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/icons/angle-icon.d.ts +2 -0
- package/dist/icons/bin-icon.d.ts +2 -0
- package/dist/icons/chevron-icon.d.ts +2 -0
- package/dist/icons/clipboard-icon.d.ts +2 -0
- package/dist/icons/conic-gradient-icon.d.ts +2 -0
- package/dist/icons/dropper-icon.d.ts +2 -0
- package/dist/icons/index.d.ts +8 -0
- package/dist/icons/linear-gradient-icon.d.ts +2 -0
- package/dist/icons/radial-gradient-icon.d.ts +2 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +2886 -0
- package/dist/store/context.d.ts +7 -0
- package/dist/store/hooks.d.ts +2 -0
- package/dist/store/index.d.ts +4 -0
- package/dist/store/store.d.ts +8 -0
- package/dist/store/types.d.ts +40 -0
- package/dist/types.d.ts +37 -0
- package/package.json +78 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Icon } from '../../types';
|
|
2
|
+
export type DeleteStopClassNames = {
|
|
3
|
+
button: string;
|
|
4
|
+
icon: string;
|
|
5
|
+
};
|
|
6
|
+
export type DeleteStopProps = {
|
|
7
|
+
icon?: Icon;
|
|
8
|
+
classNames?: Partial<DeleteStopClassNames>;
|
|
9
|
+
};
|
|
10
|
+
export declare const DeleteStop: ({ icon, classNames }: DeleteStopProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Icon } from '../../types';
|
|
2
|
+
export type EyeDropperClassNames = {
|
|
3
|
+
button?: string;
|
|
4
|
+
active?: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
};
|
|
7
|
+
export type EyeDropperProps = {
|
|
8
|
+
classNames?: Partial<EyeDropperClassNames>;
|
|
9
|
+
icon?: Icon;
|
|
10
|
+
};
|
|
11
|
+
export declare const EyeDropper: ({ classNames, icon }: EyeDropperProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Icon } from '../../types';
|
|
2
|
+
export type GradientFormats = 'linear-gradient' | 'radial-gradient' | 'conic-gradient';
|
|
3
|
+
export type GradientFormatsButtonClassNames = {
|
|
4
|
+
base: string;
|
|
5
|
+
activeBase: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
};
|
|
8
|
+
export type GradientFormatsClassNames = {
|
|
9
|
+
wrapper?: string;
|
|
10
|
+
button?: GradientFormatsButtonClassNames;
|
|
11
|
+
buttons?: Record<GradientFormats, Partial<GradientFormatsButtonClassNames>>;
|
|
12
|
+
};
|
|
13
|
+
export type GradientFormatsProps = {
|
|
14
|
+
allowedFormats?: GradientFormats[];
|
|
15
|
+
classNames?: Partial<GradientFormatsClassNames>;
|
|
16
|
+
icons?: Partial<Record<GradientFormats, Icon>>;
|
|
17
|
+
};
|
|
18
|
+
export declare const PickGradientFormats: ({ allowedFormats, icons, classNames, }: GradientFormatsProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export * from './const';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MIN_GAP = 4;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { Stop, Stops } from '../../types';
|
|
3
|
+
export declare const STOP_SIZE = 24;
|
|
4
|
+
export declare const R: number;
|
|
5
|
+
export declare const makeId: () => string;
|
|
6
|
+
export declare const stopGap: (pos: number, all: Array<{
|
|
7
|
+
position: number;
|
|
8
|
+
}>, minGap?: number) => number;
|
|
9
|
+
export declare const leftPxFromPercent: (posPct: number, width: number) => number;
|
|
10
|
+
type BlockState = Nullable<{
|
|
11
|
+
neighborId: string;
|
|
12
|
+
dir: -1 | 1;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const applyJump: (rawPos: number, activeStopId: string, stops: Stops, lastRawPos: Nullable<number>, block: BlockState) => {
|
|
15
|
+
pos: number;
|
|
16
|
+
block: {
|
|
17
|
+
neighborId: string;
|
|
18
|
+
dir: -1 | 1;
|
|
19
|
+
};
|
|
20
|
+
} | {
|
|
21
|
+
pos: number;
|
|
22
|
+
block: null;
|
|
23
|
+
};
|
|
24
|
+
export declare const getStopInnerStyle: (stop: Stop) => CSSProperties;
|
|
25
|
+
export declare const sameIds: (a?: string[], b?: string[]) => boolean;
|
|
26
|
+
export declare const normalizeGradientString: (v: string) => string;
|
|
27
|
+
export declare const stopsEquivalentIgnoringIds: (a: Stops | null | undefined, b: Stops | null | undefined) => boolean;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type GradientSliderClassNames = {
|
|
2
|
+
wrapper: string;
|
|
3
|
+
stop: string;
|
|
4
|
+
stops: string[];
|
|
5
|
+
};
|
|
6
|
+
export type GradientSliderProps = {
|
|
7
|
+
classNames?: Partial<GradientSliderClassNames>;
|
|
8
|
+
};
|
|
9
|
+
export declare const GradientSlider: import('react').MemoExoticComponent<({ classNames }: GradientSliderProps) => import("react/jsx-runtime").JSX.Element>;
|
|
10
|
+
export * from './helpers';
|
|
11
|
+
export * from './const';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Icon } from '../../types';
|
|
2
|
+
export type GradientStringClassNames = {
|
|
3
|
+
wrapper?: string;
|
|
4
|
+
text?: string;
|
|
5
|
+
copyButton?: string;
|
|
6
|
+
copyIcon?: string;
|
|
7
|
+
};
|
|
8
|
+
export type GradientStringProps = {
|
|
9
|
+
classNames?: GradientStringClassNames;
|
|
10
|
+
icon?: Icon;
|
|
11
|
+
onCopyClick?: VoidFunction;
|
|
12
|
+
};
|
|
13
|
+
export declare const GradientString: import('react').MemoExoticComponent<({ classNames, icon, onCopyClick }: GradientStringProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HEX_VALID_RE: RegExp;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Icon, IconedButtonClassName } from '../../types';
|
|
2
|
+
export type HexInputClassNames = {
|
|
3
|
+
copy?: IconedButtonClassName;
|
|
4
|
+
prefix?: string;
|
|
5
|
+
input?: string;
|
|
6
|
+
wrapper?: string;
|
|
7
|
+
};
|
|
8
|
+
export type HexInputProps = {
|
|
9
|
+
classNames?: HexInputClassNames;
|
|
10
|
+
copyIcon?: Icon;
|
|
11
|
+
onCopyClick?: VoidFunction;
|
|
12
|
+
};
|
|
13
|
+
export declare const HexInput: ({ classNames, copyIcon, onCopyClick }: HexInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export * from './helpers';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HUE_MAX = 359.999;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type HueSliderClassNames = {
|
|
2
|
+
wrapper: string;
|
|
3
|
+
thumb: string;
|
|
4
|
+
canvas: string;
|
|
5
|
+
};
|
|
6
|
+
export type HueSliderProps = {
|
|
7
|
+
classNames?: Partial<HueSliderClassNames>;
|
|
8
|
+
};
|
|
9
|
+
export declare const HueSlider: ({ classNames }: HueSliderProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export * from './const';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './color-square';
|
|
2
|
+
export * from './hue-slider';
|
|
3
|
+
export * from './delete-stop';
|
|
4
|
+
export * from './eye-dropper';
|
|
5
|
+
export * from './stop-position';
|
|
6
|
+
export * from './alpha-slider';
|
|
7
|
+
export * from './alpha-input';
|
|
8
|
+
export * from './angle-input';
|
|
9
|
+
export * from './gradient-slider';
|
|
10
|
+
export * from './gradient-formats';
|
|
11
|
+
export * from './gradient-preview';
|
|
12
|
+
export * from './gradient-string';
|
|
13
|
+
export * from './hex-input';
|
|
14
|
+
export * from './hex-preview';
|
|
15
|
+
export * from './rgba-input';
|
|
16
|
+
export * from './rgba-preview';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Channel } from './const';
|
|
2
|
+
export declare const getChannelFromRgba: (rgba: string, channel: "r" | "g" | "b" | "a") => number;
|
|
3
|
+
export declare const getChannelsFromRgba: (rgba: string) => Record<"r" | "g" | "b" | "a", number>;
|
|
4
|
+
export declare const updateRgbaChannel: (rgba: string, channel: "r" | "g" | "b" | "a") => (value: number) => string;
|
|
5
|
+
export declare const channelsEqual: (a: Record<Channel, number>, b: Record<Channel, number>) => boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Channel } from './const';
|
|
2
|
+
import { Icon } from '../../types';
|
|
3
|
+
type Icons = 'increment' | 'decrement';
|
|
4
|
+
type ButtonClassNames = {
|
|
5
|
+
button: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
};
|
|
8
|
+
type InputClassNames = {
|
|
9
|
+
wrapper: string;
|
|
10
|
+
field: string;
|
|
11
|
+
steppers: {
|
|
12
|
+
wrapper: string;
|
|
13
|
+
increment: ButtonClassNames;
|
|
14
|
+
decrement: ButtonClassNames;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type RgbaInputClassNames = {
|
|
18
|
+
wrapper: string;
|
|
19
|
+
input: InputClassNames;
|
|
20
|
+
inputs: Record<Channel, InputClassNames>;
|
|
21
|
+
};
|
|
22
|
+
export type RgbaInputProps = {
|
|
23
|
+
classNames?: Partial<RgbaInputClassNames>;
|
|
24
|
+
icons?: Record<Icons, Icon>;
|
|
25
|
+
};
|
|
26
|
+
export declare const RgbaInput: ({ classNames, icons }: RgbaInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export * from './helpers';
|
|
28
|
+
export * from './const';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Icon } from '../../types';
|
|
2
|
+
type ButtonClassNames = {
|
|
3
|
+
button: string;
|
|
4
|
+
icon: string;
|
|
5
|
+
};
|
|
6
|
+
export type StopPositionClassNames = {
|
|
7
|
+
wrapper?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
inputWrapper?: string;
|
|
10
|
+
input?: string;
|
|
11
|
+
baseIcon?: string;
|
|
12
|
+
suffix?: string;
|
|
13
|
+
steppers?: {
|
|
14
|
+
wrapper?: string;
|
|
15
|
+
increment?: ButtonClassNames;
|
|
16
|
+
decrement?: ButtonClassNames;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type StopPositionProps = {
|
|
20
|
+
classNames?: StopPositionClassNames;
|
|
21
|
+
label?: Nullable<string>;
|
|
22
|
+
icons?: {
|
|
23
|
+
base?: Icon;
|
|
24
|
+
increment?: Icon;
|
|
25
|
+
decrement?: Icon;
|
|
26
|
+
};
|
|
27
|
+
hideLabel?: boolean;
|
|
28
|
+
hideSuffix?: boolean;
|
|
29
|
+
hideSteppers?: boolean;
|
|
30
|
+
suffix?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare const StopPosition: ({ classNames, label, suffix, icons, hideLabel, hideSuffix, hideSteppers, }: StopPositionProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
33
|
+
export * from './helpers';
|
package/dist/const.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export declare const ColorProvider: (props: {
|
|
3
|
+
hue: number;
|
|
4
|
+
rgba: string;
|
|
5
|
+
setHue: React.Dispatch<React.SetStateAction<number>>;
|
|
6
|
+
setRgba: React.Dispatch<React.SetStateAction<string>>;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
export declare const HueContext: import('react').Context<number>;
|
|
3
|
+
export declare const RgbaContext: import('react').Context<string>;
|
|
4
|
+
export declare const SetHueContext: import('react').Context<Dispatch<SetStateAction<number>>>;
|
|
5
|
+
export declare const SetRgbaContext: import('react').Context<Dispatch<SetStateAction<string>>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction, ReactNode } from 'react';
|
|
2
|
+
import { GradientPrefixes } from '.';
|
|
3
|
+
import { GradientFormats } from '../components';
|
|
4
|
+
import { Stops } from '../types';
|
|
5
|
+
export declare const GradientPickerProviders: (props: {
|
|
6
|
+
rgba: string;
|
|
7
|
+
hue: number;
|
|
8
|
+
setRgba: Dispatch<SetStateAction<string>>;
|
|
9
|
+
setHue: Dispatch<SetStateAction<number>>;
|
|
10
|
+
format: GradientFormats;
|
|
11
|
+
prefixes: GradientPrefixes;
|
|
12
|
+
angle: number;
|
|
13
|
+
gradient: string;
|
|
14
|
+
updateDelay?: number;
|
|
15
|
+
setFormat: Dispatch<SetStateAction<GradientFormats>>;
|
|
16
|
+
setPrefixes: Dispatch<SetStateAction<GradientPrefixes>>;
|
|
17
|
+
setAngle: Dispatch<SetStateAction<number>>;
|
|
18
|
+
setGradient: (g: string) => void;
|
|
19
|
+
activeStopId: string | null;
|
|
20
|
+
stops: Stops;
|
|
21
|
+
stopsOrder: string[];
|
|
22
|
+
draggingStopId: string | null;
|
|
23
|
+
draftPosition: number | null;
|
|
24
|
+
setActiveStopId: Dispatch<SetStateAction<string | null>>;
|
|
25
|
+
setStops: Dispatch<SetStateAction<Stops>>;
|
|
26
|
+
setStopsOrder: Dispatch<SetStateAction<string[]>>;
|
|
27
|
+
setDraggingStopId: Dispatch<SetStateAction<string | null>>;
|
|
28
|
+
setDraftPosition: Dispatch<SetStateAction<number | null>>;
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { GradientPrefixes } from './gradient';
|
|
3
|
+
import { GradientFormats } from '../components';
|
|
4
|
+
export declare function GradientMetaProvider(props: {
|
|
5
|
+
format: GradientFormats;
|
|
6
|
+
prefixes: GradientPrefixes;
|
|
7
|
+
angle: number;
|
|
8
|
+
gradient: string;
|
|
9
|
+
updateDelay?: number;
|
|
10
|
+
setFormat: React.Dispatch<React.SetStateAction<GradientFormats>>;
|
|
11
|
+
setPrefixes: React.Dispatch<React.SetStateAction<GradientPrefixes>>;
|
|
12
|
+
setAngle: React.Dispatch<React.SetStateAction<number>>;
|
|
13
|
+
setGradient: (g: string) => void;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { GradientFormats } from '../components';
|
|
3
|
+
export type GradientPrefixes = Record<GradientFormats, string>;
|
|
4
|
+
export declare const FormatContext: import('react').Context<GradientFormats>;
|
|
5
|
+
export declare const SetFormatContext: import('react').Context<Dispatch<SetStateAction<GradientFormats>>>;
|
|
6
|
+
export declare const PrefixesContext: import('react').Context<GradientPrefixes>;
|
|
7
|
+
export declare const SetPrefixesContext: import('react').Context<Dispatch<SetStateAction<GradientPrefixes>>>;
|
|
8
|
+
export declare const AngleContext: import('react').Context<number>;
|
|
9
|
+
export declare const SetAngleContext: import('react').Context<Dispatch<SetStateAction<number>>>;
|
|
10
|
+
export declare const GradientContext: import('react').Context<string>;
|
|
11
|
+
export declare const SetGradientContext: import('react').Context<(g: string) => void>;
|
|
12
|
+
export declare const UpdateDelayContext: import('react').Context<number>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Stops } from '../types';
|
|
3
|
+
export declare function StopsProvider(props: {
|
|
4
|
+
activeStopId: string | null;
|
|
5
|
+
stops: Stops;
|
|
6
|
+
stopsOrder: string[];
|
|
7
|
+
draggingStopId: string | null;
|
|
8
|
+
draftPosition: number | null;
|
|
9
|
+
setActiveStopId: React.Dispatch<React.SetStateAction<string | null>>;
|
|
10
|
+
setStops: React.Dispatch<React.SetStateAction<Stops>>;
|
|
11
|
+
setStopsOrder: React.Dispatch<React.SetStateAction<string[]>>;
|
|
12
|
+
setDraggingStopId: React.Dispatch<React.SetStateAction<string | null>>;
|
|
13
|
+
setDraftPosition: React.Dispatch<React.SetStateAction<number | null>>;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { Stops } from '../types';
|
|
3
|
+
export declare const ActiveStopIdContext: import('react').Context<Nullable<string>>;
|
|
4
|
+
export declare const SetActiveStopIdContext: import('react').Context<Dispatch<SetStateAction<Nullable<string>>>>;
|
|
5
|
+
export declare const StopsContext: import('react').Context<Stops>;
|
|
6
|
+
export declare const SetStopsContext: import('react').Context<Dispatch<SetStateAction<Stops>>>;
|
|
7
|
+
export declare const StopsOrderContext: import('react').Context<string[]>;
|
|
8
|
+
export declare const SetStopsOrderContext: import('react').Context<Dispatch<SetStateAction<string[]>>>;
|
|
9
|
+
export declare const DraggingStopIdContext: import('react').Context<Nullable<string>>;
|
|
10
|
+
export declare const SetDraggingStopIdContext: import('react').Context<Dispatch<SetStateAction<Nullable<string>>>>;
|
|
11
|
+
export declare const DraftPositionContext: import('react').Context<Nullable<number>>;
|
|
12
|
+
export declare const SetDraftPositionContext: import('react').Context<Dispatch<SetStateAction<Nullable<number>>>>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare const clamp01: (n: number) => number;
|
|
2
|
+
export declare const hsvToRgb: (h: number, s: number, v: number) => {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const rgbToHsv: (r: number, g: number, b: number) => {
|
|
8
|
+
h: number;
|
|
9
|
+
s: number;
|
|
10
|
+
v: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const normalizeHex: (hex: string) => string;
|
|
13
|
+
export declare const rgbToHex: (r: number, g: number, b: number) => string;
|
|
14
|
+
export declare const normalizeHue: (h: unknown) => number;
|
|
15
|
+
export declare const clampByte: (n: number) => number;
|
|
16
|
+
export declare const rgbToRgbaString: (r: number, g: number, b: number, a: number) => string;
|
|
17
|
+
export declare const parseRgbaString: (value: string) => {
|
|
18
|
+
r: number;
|
|
19
|
+
g: number;
|
|
20
|
+
b: number;
|
|
21
|
+
a: number;
|
|
22
|
+
} | null;
|
|
23
|
+
export declare const rgbaToHue: (rgba: string) => number;
|
|
24
|
+
export declare const rgbaWithHue: (rgba: string, nextHue: number) => string;
|
|
25
|
+
export declare const rgbToHue: (r: number, g: number, b: number) => number;
|
|
26
|
+
export declare const alphaFromRgba: (rgba: string) => number;
|
|
27
|
+
export declare const valueFromClientX: (clientX: number, rect: DOMRect) => number;
|
|
28
|
+
export declare const thumbLeftFromValue: (value01: number, width: number) => number;
|
|
29
|
+
export type Rgb = {
|
|
30
|
+
r: number;
|
|
31
|
+
g: number;
|
|
32
|
+
b: number;
|
|
33
|
+
};
|
|
34
|
+
export type Rgba = {
|
|
35
|
+
r: number;
|
|
36
|
+
g: number;
|
|
37
|
+
b: number;
|
|
38
|
+
a: number;
|
|
39
|
+
};
|
|
40
|
+
export declare const hexToRgb: (hex: string) => Nullable<Rgb>;
|
|
41
|
+
export declare const rgbaToHex: (rgba: string) => Nullable<string>;
|
|
42
|
+
export declare const hexToRgbaParts: (hex: string) => Nullable<Rgba>;
|
|
43
|
+
export declare const isGrayRgb: (r: number, g: number, b: number) => boolean;
|
|
44
|
+
export declare const hexToRgba: (hex: string) => Nullable<string>;
|
|
45
|
+
export declare const rgbaToHex8: (rgba: string) => Nullable<string>;
|
|
46
|
+
export declare const rgbaStringsEqual: (a: string | null | undefined, b: string | null | undefined) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debounces a function call.
|
|
3
|
+
* @param fn The function to debounce.
|
|
4
|
+
* @param delay The debounce delay in milliseconds. Default is 500ms.
|
|
5
|
+
* @param key The unique key for the debounce timer.
|
|
6
|
+
*/
|
|
7
|
+
export declare const debounce: (fn: () => void, delay?: number, key?: string) => void;
|
|
8
|
+
export declare const getDefaultValue: (defaultGradient?: string) => import('../store').GradientPickerStore;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GradientFormats } from '../components';
|
|
2
|
+
import { Stops } from '../types';
|
|
3
|
+
export type ParsedGradient = {
|
|
4
|
+
format: GradientFormats;
|
|
5
|
+
prefix: string;
|
|
6
|
+
stops: Stops;
|
|
7
|
+
};
|
|
8
|
+
export declare const parseGradientToStops: (gradient: string) => ParsedGradient | null;
|
|
9
|
+
export declare const buildGradient: (stops: Array<{
|
|
10
|
+
position: number;
|
|
11
|
+
color: string;
|
|
12
|
+
}>, opts: {
|
|
13
|
+
format: GradientFormats;
|
|
14
|
+
angle?: number;
|
|
15
|
+
prefix?: string;
|
|
16
|
+
}) => string;
|
|
17
|
+
export declare const huePreserveGray: (rgba: string, prevHue: number) => number;
|
|
18
|
+
export declare const clampN: (n: number, a: number, b: number) => number;
|
|
19
|
+
export declare const orderIdsByPosition: (stopsMap: Stops | null | undefined) => string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const clamp: (n: number, a: number, b: number) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function injectStyle(id: string, css: string): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StopsRecord } from './types';
|
|
2
|
+
import { GradientPickerStoreState } from '../../store';
|
|
3
|
+
export declare const isHex: (v: string) => boolean;
|
|
4
|
+
export declare const isRgba: (v: string) => boolean;
|
|
5
|
+
export declare const coerceToRgba: (color: string) => string;
|
|
6
|
+
export declare const nextStopId: (existingIds: string[]) => string;
|
|
7
|
+
export declare const ensureOrder: (stops: StopsRecord) => string[];
|
|
8
|
+
export declare const parseLinearAngle: (g: string) => number | null;
|
|
9
|
+
export declare const buildGradientString: (state: GradientPickerStoreState) => string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { GradientFormats } from '../../components';
|
|
2
|
+
import { GradientPickerStore } from '../../store';
|
|
3
|
+
export type StopItem = {
|
|
4
|
+
position: number;
|
|
5
|
+
id: string;
|
|
6
|
+
hex: string;
|
|
7
|
+
rgbaString: string;
|
|
8
|
+
rgba: Record<'r' | 'g' | 'b' | 'a', number>;
|
|
9
|
+
opacity: number;
|
|
10
|
+
};
|
|
11
|
+
export type ColorType = 'hex' | 'rgba';
|
|
12
|
+
export type Return = {
|
|
13
|
+
store: GradientPickerStore;
|
|
14
|
+
stops: StopItem[];
|
|
15
|
+
activeStopId: Nullable<string>;
|
|
16
|
+
activeStopPosition: number;
|
|
17
|
+
angle: number;
|
|
18
|
+
format: GradientFormats;
|
|
19
|
+
isDragging: boolean;
|
|
20
|
+
recentlyUsedColors: string[];
|
|
21
|
+
libraryColors: string[];
|
|
22
|
+
hex: string;
|
|
23
|
+
rgba: string;
|
|
24
|
+
rgbaString: string;
|
|
25
|
+
gradientString: string;
|
|
26
|
+
opacity: number;
|
|
27
|
+
setR: (r: number) => void;
|
|
28
|
+
setG: (g: number) => void;
|
|
29
|
+
setB: (b: number) => void;
|
|
30
|
+
setA: (a: number) => void;
|
|
31
|
+
setHex: (hex: string) => void;
|
|
32
|
+
setAngle: (angle: number) => void;
|
|
33
|
+
setFormat: (format: GradientFormats) => void;
|
|
34
|
+
setOpacity: (opacity: number) => void;
|
|
35
|
+
setStopColor: (id: string, color: string) => void;
|
|
36
|
+
setActiveStop: (id: string) => void;
|
|
37
|
+
setStopPosition: (id: string, position: number) => void;
|
|
38
|
+
setLibraryColors: (colors: string[]) => void;
|
|
39
|
+
setRecentlyUsedColors: (colors: string[]) => void;
|
|
40
|
+
addStop: (position: number, color: string) => void;
|
|
41
|
+
addColorToLibrary: (color: string) => void;
|
|
42
|
+
addColorToRecentlyUsed: (color: string) => void;
|
|
43
|
+
removeStop: (id: string) => void;
|
|
44
|
+
removeColorFromLibrary: (color: string) => void;
|
|
45
|
+
removeColorFromRecentlyUsed: (color: string) => void;
|
|
46
|
+
convertColor: (from: ColorType, to: ColorType, value: string) => string;
|
|
47
|
+
};
|
|
48
|
+
export type StopRecord = {
|
|
49
|
+
id: string;
|
|
50
|
+
position: number;
|
|
51
|
+
color: string;
|
|
52
|
+
};
|
|
53
|
+
export type StopsRecord = Record<string, StopRecord>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gradient';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './bin-icon';
|
|
2
|
+
export * from './conic-gradient-icon';
|
|
3
|
+
export * from './linear-gradient-icon';
|
|
4
|
+
export * from './radial-gradient-icon';
|
|
5
|
+
export * from './dropper-icon';
|
|
6
|
+
export * from './angle-icon';
|
|
7
|
+
export * from './chevron-icon';
|
|
8
|
+
export * from './clipboard-icon';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { GradientPickerStore } from './store';
|
|
3
|
+
import { ChildrenProps, Grid } from './types';
|
|
4
|
+
type BaseGradientPickerProps = {
|
|
5
|
+
gradient: string;
|
|
6
|
+
updateDelay?: number;
|
|
7
|
+
wrapperClassName?: string;
|
|
8
|
+
childrenProps?: ChildrenProps;
|
|
9
|
+
store?: GradientPickerStore;
|
|
10
|
+
onChange: (gradient: string) => void;
|
|
11
|
+
};
|
|
12
|
+
export type GradientPickerProps = (BaseGradientPickerProps & {
|
|
13
|
+
grid: Grid;
|
|
14
|
+
children?: never;
|
|
15
|
+
}) | (BaseGradientPickerProps & {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
grid?: never;
|
|
18
|
+
});
|
|
19
|
+
export declare const GradientPicker: (props: GradientPickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export * from './components';
|
|
21
|
+
export * from './types';
|
|
22
|
+
export * from './hooks';
|