@zag-js/color-picker 0.10.4 → 0.11.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/dist/index.d.mts +150 -0
- package/dist/index.d.ts +150 -4
- package/dist/index.js +1086 -8
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1069 -3
- package/dist/index.mjs.map +1 -0
- package/package.json +11 -11
- package/dist/color-picker.anatomy.d.ts +0 -3
- package/dist/color-picker.anatomy.js +0 -24
- package/dist/color-picker.anatomy.mjs +0 -19
- package/dist/color-picker.connect.d.ts +0 -44
- package/dist/color-picker.connect.js +0 -372
- package/dist/color-picker.connect.mjs +0 -368
- package/dist/color-picker.dom.d.ts +0 -46
- package/dist/color-picker.dom.js +0 -37
- package/dist/color-picker.dom.mjs +0 -33
- package/dist/color-picker.machine.d.ts +0 -3
- package/dist/color-picker.machine.js +0 -340
- package/dist/color-picker.machine.mjs +0 -336
- package/dist/color-picker.types.d.ts +0 -99
- package/dist/utils/generate-format-background.d.ts +0 -66
- package/dist/utils/generate-format-background.js +0 -133
- package/dist/utils/generate-format-background.mjs +0 -121
- package/dist/utils/get-channel-details.d.ts +0 -19
- package/dist/utils/get-channel-details.js +0 -57
- package/dist/utils/get-channel-details.mjs +0 -53
- package/dist/utils/get-channel-display-color.d.ts +0 -3
- package/dist/utils/get-channel-display-color.js +0 -26
- package/dist/utils/get-channel-display-color.mjs +0 -22
- package/dist/utils/get-channel-input-value.d.ts +0 -5
- package/dist/utils/get-channel-input-value.js +0 -26
- package/dist/utils/get-channel-input-value.mjs +0 -21
- package/dist/utils/get-color-area-gradient.d.ts +0 -7
- package/dist/utils/get-color-area-gradient.js +0 -65
- package/dist/utils/get-color-area-gradient.mjs +0 -61
- package/dist/utils/get-slider-background.d.ts +0 -2
- package/dist/utils/get-slider-background.js +0 -43
- package/dist/utils/get-slider-background.mjs +0 -39
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { Color, type ColorAxes, type ColorChannel, type ColorFormat } from "@zag-js/color-utils";
|
|
2
|
-
import type { StateMachine as S } from "@zag-js/core";
|
|
3
|
-
import type { CommonProperties, Context, Orientation, RequiredBy } from "@zag-js/types";
|
|
4
|
-
export type ColorChannelProps = {
|
|
5
|
-
channel: ColorChannel;
|
|
6
|
-
orientation?: Orientation;
|
|
7
|
-
};
|
|
8
|
-
export type ExtendedColorChannel = ColorChannel | "hex" | "css";
|
|
9
|
-
export type ColorChannelInputProps = {
|
|
10
|
-
channel: ExtendedColorChannel;
|
|
11
|
-
orientation?: Orientation;
|
|
12
|
-
};
|
|
13
|
-
export type ColorAreaProps = {
|
|
14
|
-
xChannel: ColorChannel;
|
|
15
|
-
yChannel: ColorChannel;
|
|
16
|
-
};
|
|
17
|
-
export type ColorSwatchProps = {
|
|
18
|
-
readOnly?: boolean;
|
|
19
|
-
value: string | Color;
|
|
20
|
-
};
|
|
21
|
-
type ChangeDetails = {
|
|
22
|
-
value: string;
|
|
23
|
-
valueAsColor: Color;
|
|
24
|
-
};
|
|
25
|
-
type ElementIds = Partial<{
|
|
26
|
-
content: string;
|
|
27
|
-
area: string;
|
|
28
|
-
areaGradient: string;
|
|
29
|
-
areaThumb: string;
|
|
30
|
-
channelInput(id: string): string;
|
|
31
|
-
channelSliderTrack(id: ColorChannel): string;
|
|
32
|
-
channelSliderThumb(id: ColorChannel): string;
|
|
33
|
-
}>;
|
|
34
|
-
type PublicContext = CommonProperties & {
|
|
35
|
-
/**
|
|
36
|
-
* The ids of the elements in the color picker. Useful for composition.
|
|
37
|
-
*/
|
|
38
|
-
ids?: ElementIds;
|
|
39
|
-
/**
|
|
40
|
-
* The direction of the color picker
|
|
41
|
-
*/
|
|
42
|
-
dir: "ltr" | "rtl";
|
|
43
|
-
/**
|
|
44
|
-
* The current color value
|
|
45
|
-
*/
|
|
46
|
-
value: string;
|
|
47
|
-
/**
|
|
48
|
-
* Whether the color picker is disabled
|
|
49
|
-
*/
|
|
50
|
-
disabled?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Whether the color picker is read-only
|
|
53
|
-
*/
|
|
54
|
-
readOnly?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Handler that is called when the value changes, as the user drags.
|
|
57
|
-
*/
|
|
58
|
-
onChange?: (details: ChangeDetails) => void;
|
|
59
|
-
/**
|
|
60
|
-
* Handler that is called when the user stops dragging.
|
|
61
|
-
*/
|
|
62
|
-
onChangeEnd?: (details: ChangeDetails) => void;
|
|
63
|
-
};
|
|
64
|
-
type PrivateContext = Context<{
|
|
65
|
-
/**
|
|
66
|
-
* The id of the thumb that is currently being dragged
|
|
67
|
-
*/
|
|
68
|
-
activeId: string | null;
|
|
69
|
-
/**
|
|
70
|
-
* The color value as a Color object
|
|
71
|
-
*/
|
|
72
|
-
valueAsColor: Color;
|
|
73
|
-
/**
|
|
74
|
-
* The channel that is currently being interacted with
|
|
75
|
-
*/
|
|
76
|
-
activeChannel: Partial<ColorAxes> | null;
|
|
77
|
-
/**
|
|
78
|
-
* The orientation of the channel that is currently being interacted with
|
|
79
|
-
*/
|
|
80
|
-
activeOrientation: Orientation | null;
|
|
81
|
-
}>;
|
|
82
|
-
type ComputedContext = Readonly<{
|
|
83
|
-
/**
|
|
84
|
-
* Whether the color picker is in RTL mode
|
|
85
|
-
*/
|
|
86
|
-
isRtl: boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Whether the color picker is interactive
|
|
89
|
-
*/
|
|
90
|
-
isInteractive: boolean;
|
|
91
|
-
}>;
|
|
92
|
-
export type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
93
|
-
export type MachineContext = PublicContext & PrivateContext & ComputedContext;
|
|
94
|
-
export type MachineState = {
|
|
95
|
-
value: "idle" | "focused" | "dragging";
|
|
96
|
-
};
|
|
97
|
-
export type State = S.State<MachineContext, MachineState>;
|
|
98
|
-
export type Send = S.Send<S.AnyEventObject>;
|
|
99
|
-
export type { Color, ColorChannel, ColorFormat };
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export declare const generateRGB_R: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
2
|
-
areaStyles: {
|
|
3
|
-
backgroundImage: string;
|
|
4
|
-
};
|
|
5
|
-
areaGradientStyles: {
|
|
6
|
-
backgroundImage: string;
|
|
7
|
-
WebkitMaskImage: string;
|
|
8
|
-
maskImage: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export declare const generateRGB_G: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
12
|
-
areaStyles: {
|
|
13
|
-
backgroundImage: string;
|
|
14
|
-
};
|
|
15
|
-
areaGradientStyles: {
|
|
16
|
-
backgroundImage: string;
|
|
17
|
-
WebkitMaskImage: string;
|
|
18
|
-
maskImage: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export declare const generateRGB_B: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
22
|
-
areaStyles: {
|
|
23
|
-
backgroundImage: string;
|
|
24
|
-
};
|
|
25
|
-
areaGradientStyles: {
|
|
26
|
-
backgroundImage: string;
|
|
27
|
-
WebkitMaskImage: string;
|
|
28
|
-
maskImage: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
export declare const generateHSL_H: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
32
|
-
areaStyles: {};
|
|
33
|
-
areaGradientStyles: {
|
|
34
|
-
background: string;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
export declare const generateHSL_S: (orientation: [string, string], dir: boolean, alphaValue: number) => {
|
|
38
|
-
areaStyles: {};
|
|
39
|
-
areaGradientStyles: {
|
|
40
|
-
background: string;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
export declare const generateHSL_L: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
44
|
-
areaStyles: {};
|
|
45
|
-
areaGradientStyles: {
|
|
46
|
-
backgroundImage: string;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
export declare const generateHSB_H: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
50
|
-
areaStyles: {};
|
|
51
|
-
areaGradientStyles: {
|
|
52
|
-
background: string;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
export declare const generateHSB_S: (orientation: [string, string], dir: boolean, alphaValue: number) => {
|
|
56
|
-
areaStyles: {};
|
|
57
|
-
areaGradientStyles: {
|
|
58
|
-
background: string;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
export declare const generateHSB_B: (orientation: [string, string], dir: boolean, alphaValue: number) => {
|
|
62
|
-
areaStyles: {};
|
|
63
|
-
areaGradientStyles: {
|
|
64
|
-
background: string;
|
|
65
|
-
};
|
|
66
|
-
};
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const generateRGB_R = (orientation, dir, zValue) => {
|
|
6
|
-
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
7
|
-
const result = {
|
|
8
|
-
areaStyles: {
|
|
9
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
|
|
10
|
-
},
|
|
11
|
-
areaGradientStyles: {
|
|
12
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
|
|
13
|
-
WebkitMaskImage: maskImage,
|
|
14
|
-
maskImage
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
return result;
|
|
18
|
-
};
|
|
19
|
-
const generateRGB_G = (orientation, dir, zValue) => {
|
|
20
|
-
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
21
|
-
const result = {
|
|
22
|
-
areaStyles: {
|
|
23
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
|
|
24
|
-
},
|
|
25
|
-
areaGradientStyles: {
|
|
26
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
|
|
27
|
-
WebkitMaskImage: maskImage,
|
|
28
|
-
maskImage
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
return result;
|
|
32
|
-
};
|
|
33
|
-
const generateRGB_B = (orientation, dir, zValue) => {
|
|
34
|
-
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
35
|
-
const result = {
|
|
36
|
-
areaStyles: {
|
|
37
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
|
|
38
|
-
},
|
|
39
|
-
areaGradientStyles: {
|
|
40
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
|
|
41
|
-
WebkitMaskImage: maskImage,
|
|
42
|
-
maskImage
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
return result;
|
|
46
|
-
};
|
|
47
|
-
const generateHSL_H = (orientation, dir, zValue) => {
|
|
48
|
-
const result = {
|
|
49
|
-
areaStyles: {},
|
|
50
|
-
areaGradientStyles: {
|
|
51
|
-
background: [
|
|
52
|
-
`linear-gradient(to ${orientation[Number(dir)]}, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,
|
|
53
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
|
|
54
|
-
`hsl(${zValue}, 100%, 50%)`
|
|
55
|
-
].join(",")
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
return result;
|
|
59
|
-
};
|
|
60
|
-
const generateHSL_S = (orientation, dir, alphaValue) => {
|
|
61
|
-
const result = {
|
|
62
|
-
areaStyles: {},
|
|
63
|
-
areaGradientStyles: {
|
|
64
|
-
background: [
|
|
65
|
-
`linear-gradient(to ${orientation[Number(!dir)]}, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,
|
|
66
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
67
|
-
"hsl(0, 0%, 50%)"
|
|
68
|
-
].join(",")
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
return result;
|
|
72
|
-
};
|
|
73
|
-
const generateHSL_L = (orientation, dir, zValue) => {
|
|
74
|
-
const result = {
|
|
75
|
-
areaStyles: {},
|
|
76
|
-
areaGradientStyles: {
|
|
77
|
-
backgroundImage: [
|
|
78
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
|
|
79
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`
|
|
80
|
-
].join(",")
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
return result;
|
|
84
|
-
};
|
|
85
|
-
const generateHSB_H = (orientation, dir, zValue) => {
|
|
86
|
-
const result = {
|
|
87
|
-
areaStyles: {},
|
|
88
|
-
areaGradientStyles: {
|
|
89
|
-
background: [
|
|
90
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
|
|
91
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
|
|
92
|
-
`hsl(${zValue}, 100%, 50%)`
|
|
93
|
-
].join(",")
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
return result;
|
|
97
|
-
};
|
|
98
|
-
const generateHSB_S = (orientation, dir, alphaValue) => {
|
|
99
|
-
const result = {
|
|
100
|
-
areaStyles: {},
|
|
101
|
-
areaGradientStyles: {
|
|
102
|
-
background: [
|
|
103
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
|
|
104
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
105
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
|
|
106
|
-
].join(",")
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
return result;
|
|
110
|
-
};
|
|
111
|
-
const generateHSB_B = (orientation, dir, alphaValue) => {
|
|
112
|
-
const result = {
|
|
113
|
-
areaStyles: {},
|
|
114
|
-
areaGradientStyles: {
|
|
115
|
-
background: [
|
|
116
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
|
|
117
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
118
|
-
"#000"
|
|
119
|
-
].join(",")
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
return result;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
exports.generateHSB_B = generateHSB_B;
|
|
126
|
-
exports.generateHSB_H = generateHSB_H;
|
|
127
|
-
exports.generateHSB_S = generateHSB_S;
|
|
128
|
-
exports.generateHSL_H = generateHSL_H;
|
|
129
|
-
exports.generateHSL_L = generateHSL_L;
|
|
130
|
-
exports.generateHSL_S = generateHSL_S;
|
|
131
|
-
exports.generateRGB_B = generateRGB_B;
|
|
132
|
-
exports.generateRGB_G = generateRGB_G;
|
|
133
|
-
exports.generateRGB_R = generateRGB_R;
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
const generateRGB_R = (orientation, dir, zValue) => {
|
|
2
|
-
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
3
|
-
const result = {
|
|
4
|
-
areaStyles: {
|
|
5
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
|
|
6
|
-
},
|
|
7
|
-
areaGradientStyles: {
|
|
8
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
|
|
9
|
-
WebkitMaskImage: maskImage,
|
|
10
|
-
maskImage
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
return result;
|
|
14
|
-
};
|
|
15
|
-
const generateRGB_G = (orientation, dir, zValue) => {
|
|
16
|
-
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
17
|
-
const result = {
|
|
18
|
-
areaStyles: {
|
|
19
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
|
|
20
|
-
},
|
|
21
|
-
areaGradientStyles: {
|
|
22
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
|
|
23
|
-
WebkitMaskImage: maskImage,
|
|
24
|
-
maskImage
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
29
|
-
const generateRGB_B = (orientation, dir, zValue) => {
|
|
30
|
-
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
31
|
-
const result = {
|
|
32
|
-
areaStyles: {
|
|
33
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
|
|
34
|
-
},
|
|
35
|
-
areaGradientStyles: {
|
|
36
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
|
|
37
|
-
WebkitMaskImage: maskImage,
|
|
38
|
-
maskImage
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
return result;
|
|
42
|
-
};
|
|
43
|
-
const generateHSL_H = (orientation, dir, zValue) => {
|
|
44
|
-
const result = {
|
|
45
|
-
areaStyles: {},
|
|
46
|
-
areaGradientStyles: {
|
|
47
|
-
background: [
|
|
48
|
-
`linear-gradient(to ${orientation[Number(dir)]}, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,
|
|
49
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
|
|
50
|
-
`hsl(${zValue}, 100%, 50%)`
|
|
51
|
-
].join(",")
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
return result;
|
|
55
|
-
};
|
|
56
|
-
const generateHSL_S = (orientation, dir, alphaValue) => {
|
|
57
|
-
const result = {
|
|
58
|
-
areaStyles: {},
|
|
59
|
-
areaGradientStyles: {
|
|
60
|
-
background: [
|
|
61
|
-
`linear-gradient(to ${orientation[Number(!dir)]}, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,
|
|
62
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
63
|
-
"hsl(0, 0%, 50%)"
|
|
64
|
-
].join(",")
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
return result;
|
|
68
|
-
};
|
|
69
|
-
const generateHSL_L = (orientation, dir, zValue) => {
|
|
70
|
-
const result = {
|
|
71
|
-
areaStyles: {},
|
|
72
|
-
areaGradientStyles: {
|
|
73
|
-
backgroundImage: [
|
|
74
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
|
|
75
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`
|
|
76
|
-
].join(",")
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
return result;
|
|
80
|
-
};
|
|
81
|
-
const generateHSB_H = (orientation, dir, zValue) => {
|
|
82
|
-
const result = {
|
|
83
|
-
areaStyles: {},
|
|
84
|
-
areaGradientStyles: {
|
|
85
|
-
background: [
|
|
86
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
|
|
87
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
|
|
88
|
-
`hsl(${zValue}, 100%, 50%)`
|
|
89
|
-
].join(",")
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
return result;
|
|
93
|
-
};
|
|
94
|
-
const generateHSB_S = (orientation, dir, alphaValue) => {
|
|
95
|
-
const result = {
|
|
96
|
-
areaStyles: {},
|
|
97
|
-
areaGradientStyles: {
|
|
98
|
-
background: [
|
|
99
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
|
|
100
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
101
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
|
|
102
|
-
].join(",")
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
return result;
|
|
106
|
-
};
|
|
107
|
-
const generateHSB_B = (orientation, dir, alphaValue) => {
|
|
108
|
-
const result = {
|
|
109
|
-
areaStyles: {},
|
|
110
|
-
areaGradientStyles: {
|
|
111
|
-
background: [
|
|
112
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
|
|
113
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
114
|
-
"#000"
|
|
115
|
-
].join(",")
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
return result;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export { generateHSB_B, generateHSB_H, generateHSB_S, generateHSL_H, generateHSL_L, generateHSL_S, generateRGB_B, generateRGB_G, generateRGB_R };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ColorAxes, Color, type ColorChannel } from '@zag-js/color-utils';
|
|
2
|
-
export declare function getChannelDetails(color: Color, xChannel: ColorChannel, yChannel: ColorChannel): {
|
|
3
|
-
channels: ColorAxes;
|
|
4
|
-
xChannelStep: number;
|
|
5
|
-
yChannelStep: number;
|
|
6
|
-
xChannelPageStep: number;
|
|
7
|
-
yChannelPageStep: number;
|
|
8
|
-
xValue: number;
|
|
9
|
-
yValue: number;
|
|
10
|
-
getThumbPosition(): {
|
|
11
|
-
x: number;
|
|
12
|
-
y: number;
|
|
13
|
-
};
|
|
14
|
-
incrementX(stepSize: number): number;
|
|
15
|
-
incrementY(stepSize: number): number;
|
|
16
|
-
decrementX(stepSize: number): number;
|
|
17
|
-
decrementY(stepSize: number): number;
|
|
18
|
-
getColorFromPoint(x: number, y: number): Color | undefined;
|
|
19
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const numericRange = require('@zag-js/numeric-range');
|
|
6
|
-
|
|
7
|
-
function getChannelDetails(color, xChannel, yChannel) {
|
|
8
|
-
const channels = color.getColorSpaceAxes({ xChannel, yChannel });
|
|
9
|
-
const xChannelRange = color.getChannelRange(channels.xChannel);
|
|
10
|
-
const yChannelRange = color.getChannelRange(channels.yChannel);
|
|
11
|
-
const { minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX } = xChannelRange;
|
|
12
|
-
const { minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY } = yChannelRange;
|
|
13
|
-
const xValue = color.getChannelValue(channels.xChannel);
|
|
14
|
-
const yValue = color.getChannelValue(channels.yChannel);
|
|
15
|
-
return {
|
|
16
|
-
channels,
|
|
17
|
-
xChannelStep: stepX,
|
|
18
|
-
yChannelStep: stepY,
|
|
19
|
-
xChannelPageStep: pageSizeX,
|
|
20
|
-
yChannelPageStep: pageSizeY,
|
|
21
|
-
xValue,
|
|
22
|
-
yValue,
|
|
23
|
-
getThumbPosition() {
|
|
24
|
-
let x = (xValue - minValueX) / (maxValueX - minValueX);
|
|
25
|
-
let y = 1 - (yValue - minValueY) / (maxValueY - minValueY);
|
|
26
|
-
return { x, y };
|
|
27
|
-
},
|
|
28
|
-
incrementX(stepSize) {
|
|
29
|
-
return xValue + stepSize > maxValueX ? maxValueX : numericRange.snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepX);
|
|
30
|
-
},
|
|
31
|
-
incrementY(stepSize) {
|
|
32
|
-
return yValue + stepSize > maxValueY ? maxValueY : numericRange.snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepY);
|
|
33
|
-
},
|
|
34
|
-
decrementX(stepSize) {
|
|
35
|
-
return numericRange.snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepX);
|
|
36
|
-
},
|
|
37
|
-
decrementY(stepSize) {
|
|
38
|
-
return numericRange.snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepY);
|
|
39
|
-
},
|
|
40
|
-
getColorFromPoint(x, y) {
|
|
41
|
-
let newXValue = numericRange.getPercentValue(x, minValueX, maxValueX, stepX);
|
|
42
|
-
let newYValue = numericRange.getPercentValue(1 - y, minValueY, maxValueY, stepY);
|
|
43
|
-
let newColor;
|
|
44
|
-
if (newXValue !== xValue) {
|
|
45
|
-
newXValue = numericRange.snapValueToStep(newXValue, minValueX, maxValueX, stepX);
|
|
46
|
-
newColor = color.withChannelValue(channels.xChannel, newXValue);
|
|
47
|
-
}
|
|
48
|
-
if (newYValue !== yValue) {
|
|
49
|
-
newYValue = numericRange.snapValueToStep(newYValue, minValueY, maxValueY, stepY);
|
|
50
|
-
newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue);
|
|
51
|
-
}
|
|
52
|
-
return newColor;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
exports.getChannelDetails = getChannelDetails;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { snapValueToStep, getPercentValue } from '@zag-js/numeric-range';
|
|
2
|
-
|
|
3
|
-
function getChannelDetails(color, xChannel, yChannel) {
|
|
4
|
-
const channels = color.getColorSpaceAxes({ xChannel, yChannel });
|
|
5
|
-
const xChannelRange = color.getChannelRange(channels.xChannel);
|
|
6
|
-
const yChannelRange = color.getChannelRange(channels.yChannel);
|
|
7
|
-
const { minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX } = xChannelRange;
|
|
8
|
-
const { minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY } = yChannelRange;
|
|
9
|
-
const xValue = color.getChannelValue(channels.xChannel);
|
|
10
|
-
const yValue = color.getChannelValue(channels.yChannel);
|
|
11
|
-
return {
|
|
12
|
-
channels,
|
|
13
|
-
xChannelStep: stepX,
|
|
14
|
-
yChannelStep: stepY,
|
|
15
|
-
xChannelPageStep: pageSizeX,
|
|
16
|
-
yChannelPageStep: pageSizeY,
|
|
17
|
-
xValue,
|
|
18
|
-
yValue,
|
|
19
|
-
getThumbPosition() {
|
|
20
|
-
let x = (xValue - minValueX) / (maxValueX - minValueX);
|
|
21
|
-
let y = 1 - (yValue - minValueY) / (maxValueY - minValueY);
|
|
22
|
-
return { x, y };
|
|
23
|
-
},
|
|
24
|
-
incrementX(stepSize) {
|
|
25
|
-
return xValue + stepSize > maxValueX ? maxValueX : snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepX);
|
|
26
|
-
},
|
|
27
|
-
incrementY(stepSize) {
|
|
28
|
-
return yValue + stepSize > maxValueY ? maxValueY : snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepY);
|
|
29
|
-
},
|
|
30
|
-
decrementX(stepSize) {
|
|
31
|
-
return snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepX);
|
|
32
|
-
},
|
|
33
|
-
decrementY(stepSize) {
|
|
34
|
-
return snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepY);
|
|
35
|
-
},
|
|
36
|
-
getColorFromPoint(x, y) {
|
|
37
|
-
let newXValue = getPercentValue(x, minValueX, maxValueX, stepX);
|
|
38
|
-
let newYValue = getPercentValue(1 - y, minValueY, maxValueY, stepY);
|
|
39
|
-
let newColor;
|
|
40
|
-
if (newXValue !== xValue) {
|
|
41
|
-
newXValue = snapValueToStep(newXValue, minValueX, maxValueX, stepX);
|
|
42
|
-
newColor = color.withChannelValue(channels.xChannel, newXValue);
|
|
43
|
-
}
|
|
44
|
-
if (newYValue !== yValue) {
|
|
45
|
-
newYValue = snapValueToStep(newYValue, minValueY, maxValueY, stepY);
|
|
46
|
-
newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue);
|
|
47
|
-
}
|
|
48
|
-
return newColor;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { getChannelDetails };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const colorUtils = require('@zag-js/color-utils');
|
|
6
|
-
|
|
7
|
-
function getChannelDisplayColor(color, channel) {
|
|
8
|
-
switch (channel) {
|
|
9
|
-
case "hue":
|
|
10
|
-
return colorUtils.parseColor(`hsl(${color.getChannelValue("hue")}, 100%, 50%)`);
|
|
11
|
-
case "lightness":
|
|
12
|
-
case "brightness":
|
|
13
|
-
case "saturation":
|
|
14
|
-
case "red":
|
|
15
|
-
case "green":
|
|
16
|
-
case "blue":
|
|
17
|
-
return color.withChannelValue("alpha", 1);
|
|
18
|
-
case "alpha": {
|
|
19
|
-
return color;
|
|
20
|
-
}
|
|
21
|
-
default:
|
|
22
|
-
throw new Error("Unknown color channel: " + channel);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
exports.getChannelDisplayColor = getChannelDisplayColor;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { parseColor } from '@zag-js/color-utils';
|
|
2
|
-
|
|
3
|
-
function getChannelDisplayColor(color, channel) {
|
|
4
|
-
switch (channel) {
|
|
5
|
-
case "hue":
|
|
6
|
-
return parseColor(`hsl(${color.getChannelValue("hue")}, 100%, 50%)`);
|
|
7
|
-
case "lightness":
|
|
8
|
-
case "brightness":
|
|
9
|
-
case "saturation":
|
|
10
|
-
case "red":
|
|
11
|
-
case "green":
|
|
12
|
-
case "blue":
|
|
13
|
-
return color.withChannelValue("alpha", 1);
|
|
14
|
-
case "alpha": {
|
|
15
|
-
return color;
|
|
16
|
-
}
|
|
17
|
-
default:
|
|
18
|
-
throw new Error("Unknown color channel: " + channel);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { getChannelDisplayColor };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ColorChannelRange } from '@zag-js/color-utils/src/types';
|
|
2
|
-
import { Color } from "@zag-js/color-utils";
|
|
3
|
-
import { ExtendedColorChannel } from "../color-picker.types";
|
|
4
|
-
export declare function getChannelInputValue(color: Color, channel: ExtendedColorChannel): string;
|
|
5
|
-
export declare function getChannelInputRange(color: Color, channel: ExtendedColorChannel): ColorChannelRange | undefined;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
function getChannelInputValue(color, channel) {
|
|
6
|
-
switch (channel) {
|
|
7
|
-
case "hex":
|
|
8
|
-
return color.toString("hex");
|
|
9
|
-
case "css":
|
|
10
|
-
return color.toString("css");
|
|
11
|
-
default:
|
|
12
|
-
return color.getChannelValue(channel).toString();
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function getChannelInputRange(color, channel) {
|
|
16
|
-
switch (channel) {
|
|
17
|
-
case "hex":
|
|
18
|
-
case "css":
|
|
19
|
-
return void 0;
|
|
20
|
-
default:
|
|
21
|
-
return color.getChannelRange(channel);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
exports.getChannelInputRange = getChannelInputRange;
|
|
26
|
-
exports.getChannelInputValue = getChannelInputValue;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
function getChannelInputValue(color, channel) {
|
|
2
|
-
switch (channel) {
|
|
3
|
-
case "hex":
|
|
4
|
-
return color.toString("hex");
|
|
5
|
-
case "css":
|
|
6
|
-
return color.toString("css");
|
|
7
|
-
default:
|
|
8
|
-
return color.getChannelValue(channel).toString();
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
function getChannelInputRange(color, channel) {
|
|
12
|
-
switch (channel) {
|
|
13
|
-
case "hex":
|
|
14
|
-
case "css":
|
|
15
|
-
return void 0;
|
|
16
|
-
default:
|
|
17
|
-
return color.getChannelRange(channel);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { getChannelInputRange, getChannelInputValue };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { JSX } from '@zag-js/types';
|
|
2
|
-
import { type ColorChannel } from "@zag-js/color-utils";
|
|
3
|
-
import { MachineContext } from "../color-picker.types";
|
|
4
|
-
export declare function getColorAreaGradient(ctx: MachineContext, xChannel: ColorChannel, yChannel: ColorChannel): {
|
|
5
|
-
areaStyles: JSX.CSSProperties;
|
|
6
|
-
areaGradientStyles: JSX.CSSProperties;
|
|
7
|
-
};
|