@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,65 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const generateFormatBackground = require('./generate-format-background.js');
|
|
6
|
-
|
|
7
|
-
function getColorAreaGradient(ctx, xChannel, yChannel) {
|
|
8
|
-
const value = ctx.valueAsColor;
|
|
9
|
-
const { zChannel } = value.getColorSpaceAxes({ xChannel, yChannel });
|
|
10
|
-
const zValue = value.getChannelValue(zChannel);
|
|
11
|
-
const { minValue: zMin, maxValue: zMax } = value.getChannelRange(zChannel);
|
|
12
|
-
const orientation = ["top", ctx.dir === "rtl" ? "left" : "right"];
|
|
13
|
-
let dir = false;
|
|
14
|
-
let background = { areaStyles: {}, areaGradientStyles: {} };
|
|
15
|
-
let alphaValue = (zValue - zMin) / (zMax - zMin);
|
|
16
|
-
let isHSL = value.getColorSpace() === "hsl";
|
|
17
|
-
switch (zChannel) {
|
|
18
|
-
case "red": {
|
|
19
|
-
dir = xChannel === "green";
|
|
20
|
-
background = generateFormatBackground.generateRGB_R(orientation, dir, zValue);
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
case "green": {
|
|
24
|
-
dir = xChannel === "red";
|
|
25
|
-
background = generateFormatBackground.generateRGB_G(orientation, dir, zValue);
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case "blue": {
|
|
29
|
-
dir = xChannel === "red";
|
|
30
|
-
background = generateFormatBackground.generateRGB_B(orientation, dir, zValue);
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
case "hue": {
|
|
34
|
-
dir = xChannel !== "saturation";
|
|
35
|
-
if (isHSL) {
|
|
36
|
-
background = generateFormatBackground.generateHSL_H(orientation, dir, zValue);
|
|
37
|
-
} else {
|
|
38
|
-
background = generateFormatBackground.generateHSB_H(orientation, dir, zValue);
|
|
39
|
-
}
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
case "saturation": {
|
|
43
|
-
dir = xChannel === "hue";
|
|
44
|
-
if (isHSL) {
|
|
45
|
-
background = generateFormatBackground.generateHSL_S(orientation, dir, alphaValue);
|
|
46
|
-
} else {
|
|
47
|
-
background = generateFormatBackground.generateHSB_S(orientation, dir, alphaValue);
|
|
48
|
-
}
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
case "brightness": {
|
|
52
|
-
dir = xChannel === "hue";
|
|
53
|
-
background = generateFormatBackground.generateHSB_B(orientation, dir, alphaValue);
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
case "lightness": {
|
|
57
|
-
dir = xChannel === "hue";
|
|
58
|
-
background = generateFormatBackground.generateHSL_L(orientation, dir, zValue);
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return background;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
exports.getColorAreaGradient = getColorAreaGradient;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { generateHSL_L, generateHSB_B, generateHSL_S, generateHSB_S, generateHSL_H, generateHSB_H, generateRGB_B, generateRGB_G, generateRGB_R } from './generate-format-background.mjs';
|
|
2
|
-
|
|
3
|
-
function getColorAreaGradient(ctx, xChannel, yChannel) {
|
|
4
|
-
const value = ctx.valueAsColor;
|
|
5
|
-
const { zChannel } = value.getColorSpaceAxes({ xChannel, yChannel });
|
|
6
|
-
const zValue = value.getChannelValue(zChannel);
|
|
7
|
-
const { minValue: zMin, maxValue: zMax } = value.getChannelRange(zChannel);
|
|
8
|
-
const orientation = ["top", ctx.dir === "rtl" ? "left" : "right"];
|
|
9
|
-
let dir = false;
|
|
10
|
-
let background = { areaStyles: {}, areaGradientStyles: {} };
|
|
11
|
-
let alphaValue = (zValue - zMin) / (zMax - zMin);
|
|
12
|
-
let isHSL = value.getColorSpace() === "hsl";
|
|
13
|
-
switch (zChannel) {
|
|
14
|
-
case "red": {
|
|
15
|
-
dir = xChannel === "green";
|
|
16
|
-
background = generateRGB_R(orientation, dir, zValue);
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
case "green": {
|
|
20
|
-
dir = xChannel === "red";
|
|
21
|
-
background = generateRGB_G(orientation, dir, zValue);
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
case "blue": {
|
|
25
|
-
dir = xChannel === "red";
|
|
26
|
-
background = generateRGB_B(orientation, dir, zValue);
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
case "hue": {
|
|
30
|
-
dir = xChannel !== "saturation";
|
|
31
|
-
if (isHSL) {
|
|
32
|
-
background = generateHSL_H(orientation, dir, zValue);
|
|
33
|
-
} else {
|
|
34
|
-
background = generateHSB_H(orientation, dir, zValue);
|
|
35
|
-
}
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
case "saturation": {
|
|
39
|
-
dir = xChannel === "hue";
|
|
40
|
-
if (isHSL) {
|
|
41
|
-
background = generateHSL_S(orientation, dir, alphaValue);
|
|
42
|
-
} else {
|
|
43
|
-
background = generateHSB_S(orientation, dir, alphaValue);
|
|
44
|
-
}
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
case "brightness": {
|
|
48
|
-
dir = xChannel === "hue";
|
|
49
|
-
background = generateHSB_B(orientation, dir, alphaValue);
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
case "lightness": {
|
|
53
|
-
dir = xChannel === "hue";
|
|
54
|
-
background = generateHSL_L(orientation, dir, zValue);
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return background;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export { getColorAreaGradient };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
function getSliderBgDirection(orientation, dir) {
|
|
6
|
-
if (orientation === "vertical") {
|
|
7
|
-
return "top";
|
|
8
|
-
} else if (dir === "ltr") {
|
|
9
|
-
return "right";
|
|
10
|
-
} else {
|
|
11
|
-
return "left";
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
const getSliderBgImage = (ctx, props) => {
|
|
15
|
-
const { channel } = props;
|
|
16
|
-
const dir = getSliderBgDirection(props.orientation, ctx.dir);
|
|
17
|
-
const value = ctx.valueAsColor;
|
|
18
|
-
const { minValue, maxValue } = ctx.valueAsColor.getChannelRange(channel);
|
|
19
|
-
switch (channel) {
|
|
20
|
-
case "hue":
|
|
21
|
-
return `linear-gradient(to ${dir}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`;
|
|
22
|
-
case "lightness": {
|
|
23
|
-
let start = ctx.valueAsColor.withChannelValue(channel, minValue).toString("css");
|
|
24
|
-
let middle = value.withChannelValue(channel, (maxValue - minValue) / 2).toString("css");
|
|
25
|
-
let end = value.withChannelValue(channel, maxValue).toString("css");
|
|
26
|
-
return `linear-gradient(to ${dir}, ${start}, ${middle}, ${end})`;
|
|
27
|
-
}
|
|
28
|
-
case "saturation":
|
|
29
|
-
case "brightness":
|
|
30
|
-
case "red":
|
|
31
|
-
case "green":
|
|
32
|
-
case "blue":
|
|
33
|
-
case "alpha": {
|
|
34
|
-
let start = value.withChannelValue(channel, minValue).toString("css");
|
|
35
|
-
let end = value.withChannelValue(channel, maxValue).toString("css");
|
|
36
|
-
return `linear-gradient(to ${dir}, ${start}, ${end})`;
|
|
37
|
-
}
|
|
38
|
-
default:
|
|
39
|
-
throw new Error("Unknown color channel: " + channel);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
exports.getSliderBgImage = getSliderBgImage;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
function getSliderBgDirection(orientation, dir) {
|
|
2
|
-
if (orientation === "vertical") {
|
|
3
|
-
return "top";
|
|
4
|
-
} else if (dir === "ltr") {
|
|
5
|
-
return "right";
|
|
6
|
-
} else {
|
|
7
|
-
return "left";
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
const getSliderBgImage = (ctx, props) => {
|
|
11
|
-
const { channel } = props;
|
|
12
|
-
const dir = getSliderBgDirection(props.orientation, ctx.dir);
|
|
13
|
-
const value = ctx.valueAsColor;
|
|
14
|
-
const { minValue, maxValue } = ctx.valueAsColor.getChannelRange(channel);
|
|
15
|
-
switch (channel) {
|
|
16
|
-
case "hue":
|
|
17
|
-
return `linear-gradient(to ${dir}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`;
|
|
18
|
-
case "lightness": {
|
|
19
|
-
let start = ctx.valueAsColor.withChannelValue(channel, minValue).toString("css");
|
|
20
|
-
let middle = value.withChannelValue(channel, (maxValue - minValue) / 2).toString("css");
|
|
21
|
-
let end = value.withChannelValue(channel, maxValue).toString("css");
|
|
22
|
-
return `linear-gradient(to ${dir}, ${start}, ${middle}, ${end})`;
|
|
23
|
-
}
|
|
24
|
-
case "saturation":
|
|
25
|
-
case "brightness":
|
|
26
|
-
case "red":
|
|
27
|
-
case "green":
|
|
28
|
-
case "blue":
|
|
29
|
-
case "alpha": {
|
|
30
|
-
let start = value.withChannelValue(channel, minValue).toString("css");
|
|
31
|
-
let end = value.withChannelValue(channel, maxValue).toString("css");
|
|
32
|
-
return `linear-gradient(to ${dir}, ${start}, ${end})`;
|
|
33
|
-
}
|
|
34
|
-
default:
|
|
35
|
-
throw new Error("Unknown color channel: " + channel);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export { getSliderBgImage };
|