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,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { GradientPickerStore } from './types';
|
|
3
|
+
export declare const GradientPickerStoreProvider: (props: {
|
|
4
|
+
store: GradientPickerStore;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const useGradientPickerStoreApi: () => GradientPickerStore;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GradientPickerStore } from './types';
|
|
2
|
+
import { Stops } from '../types';
|
|
3
|
+
export declare const createGradientPickerStore: (args: {
|
|
4
|
+
gradient: string;
|
|
5
|
+
onGradientChange: (g: string) => void;
|
|
6
|
+
updateDelay: number;
|
|
7
|
+
initialStops: Stops;
|
|
8
|
+
}) => GradientPickerStore;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { GradientFormats } from '../components';
|
|
2
|
+
import { Stops } from '../types';
|
|
3
|
+
export type GradientPrefixes = Record<GradientFormats, string>;
|
|
4
|
+
export type GradientPickerStoreState = {
|
|
5
|
+
rgba: string;
|
|
6
|
+
hue: number;
|
|
7
|
+
format: GradientFormats;
|
|
8
|
+
prefixes: GradientPrefixes;
|
|
9
|
+
angle: number;
|
|
10
|
+
gradient: string;
|
|
11
|
+
updateDelay: number;
|
|
12
|
+
activeStopId: string | null;
|
|
13
|
+
stops: Stops;
|
|
14
|
+
stopsOrder: string[];
|
|
15
|
+
draggingStopId: string | null;
|
|
16
|
+
draftPosition: number | null;
|
|
17
|
+
onGradientChange: (gradient: string) => void;
|
|
18
|
+
};
|
|
19
|
+
export type GradientPickerStore = {
|
|
20
|
+
getState: () => GradientPickerStoreState;
|
|
21
|
+
setState: (updater: (prev: GradientPickerStoreState) => GradientPickerStoreState) => void;
|
|
22
|
+
subscribe: (listener: () => void) => () => void;
|
|
23
|
+
setRgba: (rgba: string) => void;
|
|
24
|
+
setHue: (hue: number) => void;
|
|
25
|
+
setFormat: (format: GradientFormats) => void;
|
|
26
|
+
setPrefixes: (prefixes: GradientPrefixes) => void;
|
|
27
|
+
setAngle: (angle: number) => void;
|
|
28
|
+
setGradient: (gradient: string) => void;
|
|
29
|
+
setUpdateDelay: (delay: number) => void;
|
|
30
|
+
setOnGradientChange: (fn: (gradient: string) => void) => void;
|
|
31
|
+
setActiveStopId: (id: string | null) => void;
|
|
32
|
+
setStops: (updater: (prev: Stops) => Stops) => void;
|
|
33
|
+
setStopsOrder: (order: string[]) => void;
|
|
34
|
+
setDraggingStopId: (id: string | null) => void;
|
|
35
|
+
setDraftPosition: (pos: number | null) => void;
|
|
36
|
+
recomputeGradient: VoidFunction;
|
|
37
|
+
setActiveStopColor: (rgba: string) => void;
|
|
38
|
+
setHueForActiveStop: (hue: number) => void;
|
|
39
|
+
setSvForActiveStop: (s: number, v: number) => void;
|
|
40
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ComponentType, ReactNode, SVGProps } from 'react';
|
|
2
|
+
import { StopPositionProps, HexInputProps, RgbaInputProps, HueSliderProps, AlphaSliderProps, ColorSquareProps, EyeDropperProps, GradientSliderProps, DeleteStopProps, GradientFormatsProps, AngleInputProps, GradientStringProps, GradientPreviewProps, RgbaPreviewProps, HexPreviewProps, AlphaInputProps } from './components';
|
|
3
|
+
export type Stop = {
|
|
4
|
+
position: number;
|
|
5
|
+
color: string;
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
export type Stops = Record<string, Stop>;
|
|
9
|
+
export type Nodes = 'color-square' | 'hue-slider' | 'alpha-slider' | 'alpha-input' | 'eye-dropper' | 'stop-position' | 'stop-delete' | 'gradient-slider' | 'gradient-formats' | 'gradient-preview' | 'gradient-string' | 'angle-input' | 'hex-input' | 'hex-preview' | 'rgba-input' | 'rgba-preview';
|
|
10
|
+
export type GridItem = Nodes | {
|
|
11
|
+
className?: string;
|
|
12
|
+
children: (Nodes | GridItem)[];
|
|
13
|
+
};
|
|
14
|
+
export type Grid = GridItem[];
|
|
15
|
+
export type ChildrenProps = {
|
|
16
|
+
colorSquare?: Partial<ColorSquareProps>;
|
|
17
|
+
deleteStop?: Partial<DeleteStopProps>;
|
|
18
|
+
eyeDropper?: Partial<EyeDropperProps>;
|
|
19
|
+
hueSlider?: Partial<HueSliderProps>;
|
|
20
|
+
stopPosition?: Partial<StopPositionProps>;
|
|
21
|
+
gradientSlider?: Partial<GradientSliderProps>;
|
|
22
|
+
gradientFormats?: Partial<GradientFormatsProps>;
|
|
23
|
+
gradientString?: Partial<GradientStringProps>;
|
|
24
|
+
gradientPreview?: Partial<GradientPreviewProps>;
|
|
25
|
+
alphaSlider?: Partial<AlphaSliderProps>;
|
|
26
|
+
alphaInput?: Partial<AlphaInputProps>;
|
|
27
|
+
angleInput?: Partial<AngleInputProps>;
|
|
28
|
+
hexInput?: Partial<HexInputProps>;
|
|
29
|
+
hexPreview?: Partial<HexPreviewProps>;
|
|
30
|
+
rgbaInput?: Partial<RgbaInputProps>;
|
|
31
|
+
rgbaPreview?: Partial<RgbaPreviewProps>;
|
|
32
|
+
};
|
|
33
|
+
export type Icon = Nullable<ComponentType<SVGProps<SVGSVGElement>> | ReactNode>;
|
|
34
|
+
export type IconedButtonClassName = Partial<{
|
|
35
|
+
icon: string;
|
|
36
|
+
button: string;
|
|
37
|
+
}>;
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "customizable-gradient-picker",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"**/*.css",
|
|
9
|
+
"**/*.style.ts"
|
|
10
|
+
],
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"module": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev": "next dev",
|
|
27
|
+
"build": "next build",
|
|
28
|
+
"start": "next start",
|
|
29
|
+
"lint": "eslint",
|
|
30
|
+
"build:lib": "vite build",
|
|
31
|
+
"prepublishOnly": "npm run build:lib",
|
|
32
|
+
"pack:check": "npm pack --dry-run",
|
|
33
|
+
"test:all": "concurrently -n jest \"npm run test\"",
|
|
34
|
+
"test": "jest --config jest.config.cjs",
|
|
35
|
+
"test:watch": "jest --config jest.config.cjs --watch",
|
|
36
|
+
"compose-code": "bash ./compose-code.tool.sh"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react": ">=18",
|
|
40
|
+
"react-dom": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@eslint/css": "^0.10.0",
|
|
45
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
46
|
+
"@eslint/js": "^9.31.0",
|
|
47
|
+
"@eslint/json": "^0.13.0",
|
|
48
|
+
"@eslint/markdown": "^7.0.0",
|
|
49
|
+
"@playwright/test": "^1.58.1",
|
|
50
|
+
"@tailwindcss/postcss": "^4",
|
|
51
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
52
|
+
"@testing-library/react": "^16.3.2",
|
|
53
|
+
"@types/jest": "^30.0.0",
|
|
54
|
+
"@types/node": "^20",
|
|
55
|
+
"@types/react": "^19",
|
|
56
|
+
"@types/react-dom": "^19",
|
|
57
|
+
"@vitejs/plugin-react": "^5.2.0",
|
|
58
|
+
"concurrently": "^9.2.1",
|
|
59
|
+
"eslint": "^9",
|
|
60
|
+
"eslint-config-next": "16.1.2",
|
|
61
|
+
"eslint-plugin-import": "^2.32.0",
|
|
62
|
+
"eslint-plugin-react": "^7.37.5",
|
|
63
|
+
"identity-obj-proxy": "^3.0.0",
|
|
64
|
+
"jest": "^30.2.0",
|
|
65
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
66
|
+
"next": "16.1.2",
|
|
67
|
+
"prettier-plugin-tailwindcss": "^0.6.14",
|
|
68
|
+
"react": "19.2.3",
|
|
69
|
+
"react-dom": "19.2.3",
|
|
70
|
+
"tailwindcss": "^4",
|
|
71
|
+
"ts-jest": "^29.4.6",
|
|
72
|
+
"tsup": "^8.5.1",
|
|
73
|
+
"typescript": "^5.9.3",
|
|
74
|
+
"vite": "^7.3.1",
|
|
75
|
+
"vite-plugin-css-injected-by-js": "^4.0.1",
|
|
76
|
+
"vite-plugin-dts": "^4.5.4"
|
|
77
|
+
}
|
|
78
|
+
}
|