@zag-js/color-picker 0.0.0-dev-20230414151834
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 +19 -0
- package/dist/chunk-2ERX54SV.mjs +25 -0
- package/dist/chunk-3XH465XT.mjs +42 -0
- package/dist/chunk-75JXJMB5.mjs +22 -0
- package/dist/chunk-ACSV4TXB.mjs +35 -0
- package/dist/chunk-J3XCPS5T.mjs +365 -0
- package/dist/chunk-JNBNPPMF.mjs +24 -0
- package/dist/chunk-KLLIOTK6.mjs +55 -0
- package/dist/chunk-KO4TBUXB.mjs +74 -0
- package/dist/chunk-OY3B7NXA.mjs +132 -0
- package/dist/chunk-ZBNUATFY.mjs +344 -0
- package/dist/color-picker.anatomy.d.ts +6 -0
- package/dist/color-picker.anatomy.js +47 -0
- package/dist/color-picker.anatomy.mjs +8 -0
- package/dist/color-picker.connect.d.ts +27 -0
- package/dist/color-picker.connect.js +731 -0
- package/dist/color-picker.connect.mjs +14 -0
- package/dist/color-picker.dom.d.ts +62 -0
- package/dist/color-picker.dom.js +59 -0
- package/dist/color-picker.dom.mjs +6 -0
- package/dist/color-picker.machine.d.ts +8 -0
- package/dist/color-picker.machine.js +456 -0
- package/dist/color-picker.machine.mjs +9 -0
- package/dist/color-picker.types.d.ts +88 -0
- package/dist/color-picker.types.js +18 -0
- package/dist/color-picker.types.mjs +0 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1066 -0
- package/dist/index.mjs +18 -0
- package/dist/utils/generate-format-background.d.ts +68 -0
- package/dist/utils/generate-format-background.js +164 -0
- package/dist/utils/generate-format-background.mjs +22 -0
- package/dist/utils/get-channel-details.d.ts +23 -0
- package/dist/utils/get-channel-details.js +79 -0
- package/dist/utils/get-channel-details.mjs +6 -0
- package/dist/utils/get-channel-display-color.d.ts +5 -0
- package/dist/utils/get-channel-display-color.js +48 -0
- package/dist/utils/get-channel-display-color.mjs +6 -0
- package/dist/utils/get-channel-input-value.d.ts +10 -0
- package/dist/utils/get-channel-input-value.js +50 -0
- package/dist/utils/get-channel-input-value.mjs +8 -0
- package/dist/utils/get-color-area-gradient.d.ts +11 -0
- package/dist/utils/get-color-area-gradient.js +209 -0
- package/dist/utils/get-color-area-gradient.mjs +7 -0
- package/dist/utils/get-slider-background.d.ts +8 -0
- package/dist/utils/get-slider-background.js +66 -0
- package/dist/utils/get-slider-background.mjs +6 -0
- package/package.json +65 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
connect
|
|
3
|
+
} from "./chunk-J3XCPS5T.mjs";
|
|
4
|
+
import "./chunk-JNBNPPMF.mjs";
|
|
5
|
+
import "./chunk-KO4TBUXB.mjs";
|
|
6
|
+
import "./chunk-3XH465XT.mjs";
|
|
7
|
+
import "./chunk-75JXJMB5.mjs";
|
|
8
|
+
import {
|
|
9
|
+
machine
|
|
10
|
+
} from "./chunk-ZBNUATFY.mjs";
|
|
11
|
+
import "./chunk-2ERX54SV.mjs";
|
|
12
|
+
import "./chunk-ACSV4TXB.mjs";
|
|
13
|
+
import "./chunk-OY3B7NXA.mjs";
|
|
14
|
+
import "./chunk-KLLIOTK6.mjs";
|
|
15
|
+
export {
|
|
16
|
+
connect,
|
|
17
|
+
machine
|
|
18
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
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
|
+
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
|
+
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
|
+
declare const generateHSL_H: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
32
|
+
areaStyles: {};
|
|
33
|
+
areaGradientStyles: {
|
|
34
|
+
background: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
declare const generateHSL_S: (orientation: [string, string], dir: boolean, alphaValue: number) => {
|
|
38
|
+
areaStyles: {};
|
|
39
|
+
areaGradientStyles: {
|
|
40
|
+
background: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
declare const generateHSL_L: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
44
|
+
areaStyles: {};
|
|
45
|
+
areaGradientStyles: {
|
|
46
|
+
backgroundImage: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
declare const generateHSB_H: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
50
|
+
areaStyles: {};
|
|
51
|
+
areaGradientStyles: {
|
|
52
|
+
background: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
declare const generateHSB_S: (orientation: [string, string], dir: boolean, alphaValue: number) => {
|
|
56
|
+
areaStyles: {};
|
|
57
|
+
areaGradientStyles: {
|
|
58
|
+
background: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
declare const generateHSB_B: (orientation: [string, string], dir: boolean, alphaValue: number) => {
|
|
62
|
+
areaStyles: {};
|
|
63
|
+
areaGradientStyles: {
|
|
64
|
+
background: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export { generateHSB_B, generateHSB_H, generateHSB_S, generateHSL_H, generateHSL_L, generateHSL_S, generateRGB_B, generateRGB_G, generateRGB_R };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/generate-format-background.ts
|
|
21
|
+
var generate_format_background_exports = {};
|
|
22
|
+
__export(generate_format_background_exports, {
|
|
23
|
+
generateHSB_B: () => generateHSB_B,
|
|
24
|
+
generateHSB_H: () => generateHSB_H,
|
|
25
|
+
generateHSB_S: () => generateHSB_S,
|
|
26
|
+
generateHSL_H: () => generateHSL_H,
|
|
27
|
+
generateHSL_L: () => generateHSL_L,
|
|
28
|
+
generateHSL_S: () => generateHSL_S,
|
|
29
|
+
generateRGB_B: () => generateRGB_B,
|
|
30
|
+
generateRGB_G: () => generateRGB_G,
|
|
31
|
+
generateRGB_R: () => generateRGB_R
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(generate_format_background_exports);
|
|
34
|
+
var generateRGB_R = (orientation, dir, zValue) => {
|
|
35
|
+
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
36
|
+
const result = {
|
|
37
|
+
areaStyles: {
|
|
38
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
|
|
39
|
+
},
|
|
40
|
+
areaGradientStyles: {
|
|
41
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
|
|
42
|
+
WebkitMaskImage: maskImage,
|
|
43
|
+
maskImage
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
var generateRGB_G = (orientation, dir, zValue) => {
|
|
49
|
+
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
50
|
+
const result = {
|
|
51
|
+
areaStyles: {
|
|
52
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
|
|
53
|
+
},
|
|
54
|
+
areaGradientStyles: {
|
|
55
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
|
|
56
|
+
WebkitMaskImage: maskImage,
|
|
57
|
+
maskImage
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
var generateRGB_B = (orientation, dir, zValue) => {
|
|
63
|
+
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
64
|
+
const result = {
|
|
65
|
+
areaStyles: {
|
|
66
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
|
|
67
|
+
},
|
|
68
|
+
areaGradientStyles: {
|
|
69
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
|
|
70
|
+
WebkitMaskImage: maskImage,
|
|
71
|
+
maskImage
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return result;
|
|
75
|
+
};
|
|
76
|
+
var generateHSL_H = (orientation, dir, zValue) => {
|
|
77
|
+
const result = {
|
|
78
|
+
areaStyles: {},
|
|
79
|
+
areaGradientStyles: {
|
|
80
|
+
background: [
|
|
81
|
+
`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%)`,
|
|
82
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
|
|
83
|
+
`hsl(${zValue}, 100%, 50%)`
|
|
84
|
+
].join(",")
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return result;
|
|
88
|
+
};
|
|
89
|
+
var generateHSL_S = (orientation, dir, alphaValue) => {
|
|
90
|
+
const result = {
|
|
91
|
+
areaStyles: {},
|
|
92
|
+
areaGradientStyles: {
|
|
93
|
+
background: [
|
|
94
|
+
`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%)`,
|
|
95
|
+
`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}))`,
|
|
96
|
+
"hsl(0, 0%, 50%)"
|
|
97
|
+
].join(",")
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return result;
|
|
101
|
+
};
|
|
102
|
+
var generateHSL_L = (orientation, dir, zValue) => {
|
|
103
|
+
const result = {
|
|
104
|
+
areaStyles: {},
|
|
105
|
+
areaGradientStyles: {
|
|
106
|
+
backgroundImage: [
|
|
107
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
|
|
108
|
+
`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}%))`
|
|
109
|
+
].join(",")
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return result;
|
|
113
|
+
};
|
|
114
|
+
var generateHSB_H = (orientation, dir, zValue) => {
|
|
115
|
+
const result = {
|
|
116
|
+
areaStyles: {},
|
|
117
|
+
areaGradientStyles: {
|
|
118
|
+
background: [
|
|
119
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
|
|
120
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
|
|
121
|
+
`hsl(${zValue}, 100%, 50%)`
|
|
122
|
+
].join(",")
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
return result;
|
|
126
|
+
};
|
|
127
|
+
var generateHSB_S = (orientation, dir, alphaValue) => {
|
|
128
|
+
const result = {
|
|
129
|
+
areaStyles: {},
|
|
130
|
+
areaGradientStyles: {
|
|
131
|
+
background: [
|
|
132
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
|
|
133
|
+
`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}))`,
|
|
134
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
|
|
135
|
+
].join(",")
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
return result;
|
|
139
|
+
};
|
|
140
|
+
var generateHSB_B = (orientation, dir, alphaValue) => {
|
|
141
|
+
const result = {
|
|
142
|
+
areaStyles: {},
|
|
143
|
+
areaGradientStyles: {
|
|
144
|
+
background: [
|
|
145
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
|
|
146
|
+
`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}))`,
|
|
147
|
+
"#000"
|
|
148
|
+
].join(",")
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
return result;
|
|
152
|
+
};
|
|
153
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
154
|
+
0 && (module.exports = {
|
|
155
|
+
generateHSB_B,
|
|
156
|
+
generateHSB_H,
|
|
157
|
+
generateHSB_S,
|
|
158
|
+
generateHSL_H,
|
|
159
|
+
generateHSL_L,
|
|
160
|
+
generateHSL_S,
|
|
161
|
+
generateRGB_B,
|
|
162
|
+
generateRGB_G,
|
|
163
|
+
generateRGB_R
|
|
164
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateHSB_B,
|
|
3
|
+
generateHSB_H,
|
|
4
|
+
generateHSB_S,
|
|
5
|
+
generateHSL_H,
|
|
6
|
+
generateHSL_L,
|
|
7
|
+
generateHSL_S,
|
|
8
|
+
generateRGB_B,
|
|
9
|
+
generateRGB_G,
|
|
10
|
+
generateRGB_R
|
|
11
|
+
} from "../chunk-OY3B7NXA.mjs";
|
|
12
|
+
export {
|
|
13
|
+
generateHSB_B,
|
|
14
|
+
generateHSB_H,
|
|
15
|
+
generateHSB_S,
|
|
16
|
+
generateHSL_H,
|
|
17
|
+
generateHSL_L,
|
|
18
|
+
generateHSL_S,
|
|
19
|
+
generateRGB_B,
|
|
20
|
+
generateRGB_G,
|
|
21
|
+
generateRGB_R
|
|
22
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as _zag_js_color_utils from '@zag-js/color-utils';
|
|
2
|
+
import { Color, ColorChannel } from '@zag-js/color-utils';
|
|
3
|
+
|
|
4
|
+
declare function getChannelDetails(color: Color, xChannel: ColorChannel, yChannel: ColorChannel): {
|
|
5
|
+
channels: _zag_js_color_utils.ColorAxes;
|
|
6
|
+
xChannelStep: number;
|
|
7
|
+
yChannelStep: number;
|
|
8
|
+
xChannelPageStep: number;
|
|
9
|
+
yChannelPageStep: number;
|
|
10
|
+
xValue: number;
|
|
11
|
+
yValue: number;
|
|
12
|
+
getThumbPosition(): {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
16
|
+
incrementX(stepSize: number): number;
|
|
17
|
+
incrementY(stepSize: number): number;
|
|
18
|
+
decrementX(stepSize: number): number;
|
|
19
|
+
decrementY(stepSize: number): number;
|
|
20
|
+
getColorFromPoint(x: number, y: number): Color | undefined;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { getChannelDetails };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/get-channel-details.ts
|
|
21
|
+
var get_channel_details_exports = {};
|
|
22
|
+
__export(get_channel_details_exports, {
|
|
23
|
+
getChannelDetails: () => getChannelDetails
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(get_channel_details_exports);
|
|
26
|
+
var import_numeric_range = require("@zag-js/numeric-range");
|
|
27
|
+
function getChannelDetails(color, xChannel, yChannel) {
|
|
28
|
+
const channels = color.getColorSpaceAxes({ xChannel, yChannel });
|
|
29
|
+
const xChannelRange = color.getChannelRange(channels.xChannel);
|
|
30
|
+
const yChannelRange = color.getChannelRange(channels.yChannel);
|
|
31
|
+
const { minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX } = xChannelRange;
|
|
32
|
+
const { minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY } = yChannelRange;
|
|
33
|
+
const xValue = color.getChannelValue(channels.xChannel);
|
|
34
|
+
const yValue = color.getChannelValue(channels.yChannel);
|
|
35
|
+
return {
|
|
36
|
+
channels,
|
|
37
|
+
xChannelStep: stepX,
|
|
38
|
+
yChannelStep: stepY,
|
|
39
|
+
xChannelPageStep: pageSizeX,
|
|
40
|
+
yChannelPageStep: pageSizeY,
|
|
41
|
+
xValue,
|
|
42
|
+
yValue,
|
|
43
|
+
getThumbPosition() {
|
|
44
|
+
let x = (xValue - minValueX) / (maxValueX - minValueX);
|
|
45
|
+
let y = 1 - (yValue - minValueY) / (maxValueY - minValueY);
|
|
46
|
+
return { x, y };
|
|
47
|
+
},
|
|
48
|
+
incrementX(stepSize) {
|
|
49
|
+
return xValue + stepSize > maxValueX ? maxValueX : (0, import_numeric_range.snapValueToStep)(xValue + stepSize, minValueX, maxValueX, stepX);
|
|
50
|
+
},
|
|
51
|
+
incrementY(stepSize) {
|
|
52
|
+
return yValue + stepSize > maxValueY ? maxValueY : (0, import_numeric_range.snapValueToStep)(yValue + stepSize, minValueY, maxValueY, stepY);
|
|
53
|
+
},
|
|
54
|
+
decrementX(stepSize) {
|
|
55
|
+
return (0, import_numeric_range.snapValueToStep)(xValue - stepSize, minValueX, maxValueX, stepX);
|
|
56
|
+
},
|
|
57
|
+
decrementY(stepSize) {
|
|
58
|
+
return (0, import_numeric_range.snapValueToStep)(yValue - stepSize, minValueY, maxValueY, stepY);
|
|
59
|
+
},
|
|
60
|
+
getColorFromPoint(x, y) {
|
|
61
|
+
let newXValue = (0, import_numeric_range.getPercentValue)(x, minValueX, maxValueX, stepX);
|
|
62
|
+
let newYValue = (0, import_numeric_range.getPercentValue)(1 - y, minValueY, maxValueY, stepY);
|
|
63
|
+
let newColor;
|
|
64
|
+
if (newXValue !== xValue) {
|
|
65
|
+
newXValue = (0, import_numeric_range.snapValueToStep)(newXValue, minValueX, maxValueX, stepX);
|
|
66
|
+
newColor = color.withChannelValue(channels.xChannel, newXValue);
|
|
67
|
+
}
|
|
68
|
+
if (newYValue !== yValue) {
|
|
69
|
+
newYValue = (0, import_numeric_range.snapValueToStep)(newYValue, minValueY, maxValueY, stepY);
|
|
70
|
+
newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue);
|
|
71
|
+
}
|
|
72
|
+
return newColor;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
getChannelDetails
|
|
79
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/get-channel-display-color.ts
|
|
21
|
+
var get_channel_display_color_exports = {};
|
|
22
|
+
__export(get_channel_display_color_exports, {
|
|
23
|
+
getChannelDisplayColor: () => getChannelDisplayColor
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(get_channel_display_color_exports);
|
|
26
|
+
var import_color_utils = require("@zag-js/color-utils");
|
|
27
|
+
function getChannelDisplayColor(color, channel) {
|
|
28
|
+
switch (channel) {
|
|
29
|
+
case "hue":
|
|
30
|
+
return (0, import_color_utils.parseColor)(`hsl(${color.getChannelValue("hue")}, 100%, 50%)`);
|
|
31
|
+
case "lightness":
|
|
32
|
+
case "brightness":
|
|
33
|
+
case "saturation":
|
|
34
|
+
case "red":
|
|
35
|
+
case "green":
|
|
36
|
+
case "blue":
|
|
37
|
+
return color.withChannelValue("alpha", 1);
|
|
38
|
+
case "alpha": {
|
|
39
|
+
return color;
|
|
40
|
+
}
|
|
41
|
+
default:
|
|
42
|
+
throw new Error("Unknown color channel: " + channel);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
getChannelDisplayColor
|
|
48
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _zag_js_color_utils_src_types from '@zag-js/color-utils/src/types';
|
|
2
|
+
import { Color } from '@zag-js/color-utils';
|
|
3
|
+
import { ExtendedColorChannel } from '../color-picker.types.js';
|
|
4
|
+
import '@zag-js/core';
|
|
5
|
+
import '@zag-js/types';
|
|
6
|
+
|
|
7
|
+
declare function getChannelInputValue(color: Color, channel: ExtendedColorChannel): string;
|
|
8
|
+
declare function getChannelInputRange(color: Color, channel: ExtendedColorChannel): _zag_js_color_utils_src_types.ColorChannelRange | undefined;
|
|
9
|
+
|
|
10
|
+
export { getChannelInputRange, getChannelInputValue };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/get-channel-input-value.ts
|
|
21
|
+
var get_channel_input_value_exports = {};
|
|
22
|
+
__export(get_channel_input_value_exports, {
|
|
23
|
+
getChannelInputRange: () => getChannelInputRange,
|
|
24
|
+
getChannelInputValue: () => getChannelInputValue
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(get_channel_input_value_exports);
|
|
27
|
+
function getChannelInputValue(color, channel) {
|
|
28
|
+
switch (channel) {
|
|
29
|
+
case "hex":
|
|
30
|
+
return color.toString("hex");
|
|
31
|
+
case "css":
|
|
32
|
+
return color.toString("css");
|
|
33
|
+
default:
|
|
34
|
+
return color.getChannelValue(channel).toString();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function getChannelInputRange(color, channel) {
|
|
38
|
+
switch (channel) {
|
|
39
|
+
case "hex":
|
|
40
|
+
case "css":
|
|
41
|
+
return void 0;
|
|
42
|
+
default:
|
|
43
|
+
return color.getChannelRange(channel);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
getChannelInputRange,
|
|
49
|
+
getChannelInputValue
|
|
50
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as _zag_js_types from '@zag-js/types';
|
|
2
|
+
import { ColorChannel } from '@zag-js/color-utils';
|
|
3
|
+
import { MachineContext } from '../color-picker.types.js';
|
|
4
|
+
import '@zag-js/core';
|
|
5
|
+
|
|
6
|
+
declare function getColorAreaGradient(ctx: MachineContext, xChannel: ColorChannel, yChannel: ColorChannel): {
|
|
7
|
+
areaStyles: _zag_js_types.JSX.CSSProperties;
|
|
8
|
+
areaGradientStyles: _zag_js_types.JSX.CSSProperties;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { getColorAreaGradient };
|