@zag-js/color-picker 1.34.1 → 1.35.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/color-picker.anatomy.d.mts +6 -0
- package/dist/color-picker.anatomy.d.ts +6 -0
- package/dist/color-picker.anatomy.js +59 -0
- package/dist/color-picker.anatomy.mjs +33 -0
- package/dist/color-picker.connect.d.mts +10 -0
- package/dist/color-picker.connect.d.ts +10 -0
- package/dist/color-picker.connect.js +681 -0
- package/dist/color-picker.connect.mjs +646 -0
- package/dist/color-picker.dom.d.mts +39 -0
- package/dist/color-picker.dom.d.ts +39 -0
- package/dist/color-picker.dom.js +136 -0
- package/dist/color-picker.dom.mjs +85 -0
- package/dist/color-picker.machine.d.mts +10 -0
- package/dist/color-picker.machine.d.ts +10 -0
- package/dist/color-picker.machine.js +636 -0
- package/dist/color-picker.machine.mjs +609 -0
- package/dist/color-picker.parse.d.mts +5 -0
- package/dist/color-picker.parse.d.ts +5 -0
- package/dist/color-picker.parse.js +33 -0
- package/dist/color-picker.parse.mjs +8 -0
- package/dist/color-picker.props.d.mts +21 -0
- package/dist/color-picker.props.d.ts +21 -0
- package/dist/color-picker.props.js +94 -0
- package/dist/color-picker.props.mjs +58 -0
- package/dist/color-picker.types.d.mts +303 -0
- package/dist/color-picker.types.d.ts +303 -0
- package/dist/color-picker.types.js +18 -0
- package/dist/color-picker.types.mjs +0 -0
- package/dist/index.d.mts +9 -324
- package/dist/index.d.ts +9 -324
- package/dist/index.js +37 -1517
- package/dist/index.mjs +11 -1504
- package/dist/utils/get-channel-display-color.d.mts +5 -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 +23 -0
- package/dist/utils/get-channel-input-value.d.mts +11 -0
- package/dist/utils/get-channel-input-value.d.ts +11 -0
- package/dist/utils/get-channel-input-value.js +88 -0
- package/dist/utils/get-channel-input-value.mjs +62 -0
- package/dist/utils/get-slider-background.d.mts +14 -0
- package/dist/utils/get-slider-background.d.ts +14 -0
- package/dist/utils/get-slider-background.js +65 -0
- package/dist/utils/get-slider-background.mjs +40 -0
- package/dist/utils/is-valid-hex.d.mts +4 -0
- package/dist/utils/is-valid-hex.d.ts +4 -0
- package/dist/utils/is-valid-hex.js +40 -0
- package/dist/utils/is-valid-hex.mjs +14 -0
- package/package.json +20 -10
|
@@ -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,23 @@
|
|
|
1
|
+
// src/utils/get-channel-display-color.ts
|
|
2
|
+
import { parseColor } from "@zag-js/color-utils";
|
|
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
|
+
export {
|
|
22
|
+
getChannelDisplayColor
|
|
23
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Color, ColorChannelRange } from '@zag-js/color-utils';
|
|
2
|
+
import { ExtendedColorChannel } from '../color-picker.types.mjs';
|
|
3
|
+
import '@zag-js/core';
|
|
4
|
+
import '@zag-js/dismissable';
|
|
5
|
+
import '@zag-js/popper';
|
|
6
|
+
import '@zag-js/types';
|
|
7
|
+
|
|
8
|
+
declare function getChannelValue(color: Color, channel: ExtendedColorChannel | null | undefined): string;
|
|
9
|
+
declare function getChannelRange(color: Color, channel: ExtendedColorChannel): ColorChannelRange | undefined;
|
|
10
|
+
|
|
11
|
+
export { getChannelRange, getChannelValue };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Color, ColorChannelRange } from '@zag-js/color-utils';
|
|
2
|
+
import { ExtendedColorChannel } from '../color-picker.types.js';
|
|
3
|
+
import '@zag-js/core';
|
|
4
|
+
import '@zag-js/dismissable';
|
|
5
|
+
import '@zag-js/popper';
|
|
6
|
+
import '@zag-js/types';
|
|
7
|
+
|
|
8
|
+
declare function getChannelValue(color: Color, channel: ExtendedColorChannel | null | undefined): string;
|
|
9
|
+
declare function getChannelRange(color: Color, channel: ExtendedColorChannel): ColorChannelRange | undefined;
|
|
10
|
+
|
|
11
|
+
export { getChannelRange, getChannelValue };
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
getChannelRange: () => getChannelRange,
|
|
24
|
+
getChannelValue: () => getChannelValue
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(get_channel_input_value_exports);
|
|
27
|
+
var import_color_utils = require("@zag-js/color-utils");
|
|
28
|
+
function getChannelValue(color, channel) {
|
|
29
|
+
if (channel == null) return "";
|
|
30
|
+
if (channel === "hex") {
|
|
31
|
+
return color.toString("hex");
|
|
32
|
+
}
|
|
33
|
+
if (channel === "css") {
|
|
34
|
+
return color.toString("css");
|
|
35
|
+
}
|
|
36
|
+
if (channel in color) {
|
|
37
|
+
return color.getChannelValue(channel).toString();
|
|
38
|
+
}
|
|
39
|
+
const isHSL = color.getFormat() === "hsla";
|
|
40
|
+
switch (channel) {
|
|
41
|
+
case "hue":
|
|
42
|
+
return isHSL ? color.toFormat("hsla").getChannelValue("hue").toString() : color.toFormat("hsba").getChannelValue("hue").toString();
|
|
43
|
+
case "saturation":
|
|
44
|
+
return isHSL ? color.toFormat("hsla").getChannelValue("saturation").toString() : color.toFormat("hsba").getChannelValue("saturation").toString();
|
|
45
|
+
case "lightness":
|
|
46
|
+
return color.toFormat("hsla").getChannelValue("lightness").toString();
|
|
47
|
+
case "brightness":
|
|
48
|
+
return color.toFormat("hsba").getChannelValue("brightness").toString();
|
|
49
|
+
case "red":
|
|
50
|
+
case "green":
|
|
51
|
+
case "blue":
|
|
52
|
+
return color.toFormat("rgba").getChannelValue(channel).toString();
|
|
53
|
+
default:
|
|
54
|
+
return color.getChannelValue(channel).toString();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function getChannelRange(color, channel) {
|
|
58
|
+
switch (channel) {
|
|
59
|
+
case "hex":
|
|
60
|
+
const minColor = (0, import_color_utils.parseColor)("#000000");
|
|
61
|
+
const maxColor = (0, import_color_utils.parseColor)("#FFFFFF");
|
|
62
|
+
return {
|
|
63
|
+
minValue: minColor.toHexInt(),
|
|
64
|
+
maxValue: maxColor.toHexInt(),
|
|
65
|
+
pageSize: 10,
|
|
66
|
+
step: 1
|
|
67
|
+
};
|
|
68
|
+
case "css":
|
|
69
|
+
return void 0;
|
|
70
|
+
case "hue":
|
|
71
|
+
case "saturation":
|
|
72
|
+
case "lightness":
|
|
73
|
+
return color.toFormat("hsla").getChannelRange(channel);
|
|
74
|
+
case "brightness":
|
|
75
|
+
return color.toFormat("hsba").getChannelRange(channel);
|
|
76
|
+
case "red":
|
|
77
|
+
case "green":
|
|
78
|
+
case "blue":
|
|
79
|
+
return color.toFormat("rgba").getChannelRange(channel);
|
|
80
|
+
default:
|
|
81
|
+
return color.getChannelRange(channel);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
getChannelRange,
|
|
87
|
+
getChannelValue
|
|
88
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/utils/get-channel-input-value.ts
|
|
2
|
+
import { parseColor } from "@zag-js/color-utils";
|
|
3
|
+
function getChannelValue(color, channel) {
|
|
4
|
+
if (channel == null) return "";
|
|
5
|
+
if (channel === "hex") {
|
|
6
|
+
return color.toString("hex");
|
|
7
|
+
}
|
|
8
|
+
if (channel === "css") {
|
|
9
|
+
return color.toString("css");
|
|
10
|
+
}
|
|
11
|
+
if (channel in color) {
|
|
12
|
+
return color.getChannelValue(channel).toString();
|
|
13
|
+
}
|
|
14
|
+
const isHSL = color.getFormat() === "hsla";
|
|
15
|
+
switch (channel) {
|
|
16
|
+
case "hue":
|
|
17
|
+
return isHSL ? color.toFormat("hsla").getChannelValue("hue").toString() : color.toFormat("hsba").getChannelValue("hue").toString();
|
|
18
|
+
case "saturation":
|
|
19
|
+
return isHSL ? color.toFormat("hsla").getChannelValue("saturation").toString() : color.toFormat("hsba").getChannelValue("saturation").toString();
|
|
20
|
+
case "lightness":
|
|
21
|
+
return color.toFormat("hsla").getChannelValue("lightness").toString();
|
|
22
|
+
case "brightness":
|
|
23
|
+
return color.toFormat("hsba").getChannelValue("brightness").toString();
|
|
24
|
+
case "red":
|
|
25
|
+
case "green":
|
|
26
|
+
case "blue":
|
|
27
|
+
return color.toFormat("rgba").getChannelValue(channel).toString();
|
|
28
|
+
default:
|
|
29
|
+
return color.getChannelValue(channel).toString();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function getChannelRange(color, channel) {
|
|
33
|
+
switch (channel) {
|
|
34
|
+
case "hex":
|
|
35
|
+
const minColor = parseColor("#000000");
|
|
36
|
+
const maxColor = parseColor("#FFFFFF");
|
|
37
|
+
return {
|
|
38
|
+
minValue: minColor.toHexInt(),
|
|
39
|
+
maxValue: maxColor.toHexInt(),
|
|
40
|
+
pageSize: 10,
|
|
41
|
+
step: 1
|
|
42
|
+
};
|
|
43
|
+
case "css":
|
|
44
|
+
return void 0;
|
|
45
|
+
case "hue":
|
|
46
|
+
case "saturation":
|
|
47
|
+
case "lightness":
|
|
48
|
+
return color.toFormat("hsla").getChannelRange(channel);
|
|
49
|
+
case "brightness":
|
|
50
|
+
return color.toFormat("hsba").getChannelRange(channel);
|
|
51
|
+
case "red":
|
|
52
|
+
case "green":
|
|
53
|
+
case "blue":
|
|
54
|
+
return color.toFormat("rgba").getChannelRange(channel);
|
|
55
|
+
default:
|
|
56
|
+
return color.getChannelRange(channel);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
getChannelRange,
|
|
61
|
+
getChannelValue
|
|
62
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChannelProps, ColorPickerProps } from '../color-picker.types.mjs';
|
|
2
|
+
import { Color } from '@zag-js/color-utils';
|
|
3
|
+
import '@zag-js/core';
|
|
4
|
+
import '@zag-js/dismissable';
|
|
5
|
+
import '@zag-js/popper';
|
|
6
|
+
import '@zag-js/types';
|
|
7
|
+
|
|
8
|
+
interface SliderBackgroundProps extends Required<ChannelProps> {
|
|
9
|
+
value: Color;
|
|
10
|
+
dir: ColorPickerProps["dir"];
|
|
11
|
+
}
|
|
12
|
+
declare const getSliderBackground: (props: SliderBackgroundProps) => string;
|
|
13
|
+
|
|
14
|
+
export { getSliderBackground };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChannelProps, ColorPickerProps } from '../color-picker.types.js';
|
|
2
|
+
import { Color } from '@zag-js/color-utils';
|
|
3
|
+
import '@zag-js/core';
|
|
4
|
+
import '@zag-js/dismissable';
|
|
5
|
+
import '@zag-js/popper';
|
|
6
|
+
import '@zag-js/types';
|
|
7
|
+
|
|
8
|
+
interface SliderBackgroundProps extends Required<ChannelProps> {
|
|
9
|
+
value: Color;
|
|
10
|
+
dir: ColorPickerProps["dir"];
|
|
11
|
+
}
|
|
12
|
+
declare const getSliderBackground: (props: SliderBackgroundProps) => string;
|
|
13
|
+
|
|
14
|
+
export { getSliderBackground };
|
|
@@ -0,0 +1,65 @@
|
|
|
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-slider-background.ts
|
|
21
|
+
var get_slider_background_exports = {};
|
|
22
|
+
__export(get_slider_background_exports, {
|
|
23
|
+
getSliderBackground: () => getSliderBackground
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(get_slider_background_exports);
|
|
26
|
+
function getSliderBackgroundDirection(orientation, dir) {
|
|
27
|
+
if (orientation === "vertical") {
|
|
28
|
+
return "top";
|
|
29
|
+
} else if (dir === "ltr") {
|
|
30
|
+
return "right";
|
|
31
|
+
} else {
|
|
32
|
+
return "left";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
var getSliderBackground = (props) => {
|
|
36
|
+
const { channel, value, dir, orientation } = props;
|
|
37
|
+
const bgDirection = getSliderBackgroundDirection(orientation, dir);
|
|
38
|
+
const { minValue, maxValue } = value.getChannelRange(channel);
|
|
39
|
+
switch (channel) {
|
|
40
|
+
case "hue":
|
|
41
|
+
return `linear-gradient(to ${bgDirection}, 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%)`;
|
|
42
|
+
case "lightness": {
|
|
43
|
+
let start = value.withChannelValue(channel, minValue).toString("css");
|
|
44
|
+
let middle = value.withChannelValue(channel, (maxValue - minValue) / 2).toString("css");
|
|
45
|
+
let end = value.withChannelValue(channel, maxValue).toString("css");
|
|
46
|
+
return `linear-gradient(to ${bgDirection}, ${start}, ${middle}, ${end})`;
|
|
47
|
+
}
|
|
48
|
+
case "saturation":
|
|
49
|
+
case "brightness":
|
|
50
|
+
case "red":
|
|
51
|
+
case "green":
|
|
52
|
+
case "blue":
|
|
53
|
+
case "alpha": {
|
|
54
|
+
let start = value.withChannelValue(channel, minValue).toString("css");
|
|
55
|
+
let end = value.withChannelValue(channel, maxValue).toString("css");
|
|
56
|
+
return `linear-gradient(to ${bgDirection}, ${start}, ${end})`;
|
|
57
|
+
}
|
|
58
|
+
default:
|
|
59
|
+
throw new Error("Unknown color channel: " + channel);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
getSliderBackground
|
|
65
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/utils/get-slider-background.ts
|
|
2
|
+
function getSliderBackgroundDirection(orientation, dir) {
|
|
3
|
+
if (orientation === "vertical") {
|
|
4
|
+
return "top";
|
|
5
|
+
} else if (dir === "ltr") {
|
|
6
|
+
return "right";
|
|
7
|
+
} else {
|
|
8
|
+
return "left";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
var getSliderBackground = (props) => {
|
|
12
|
+
const { channel, value, dir, orientation } = props;
|
|
13
|
+
const bgDirection = getSliderBackgroundDirection(orientation, dir);
|
|
14
|
+
const { minValue, maxValue } = value.getChannelRange(channel);
|
|
15
|
+
switch (channel) {
|
|
16
|
+
case "hue":
|
|
17
|
+
return `linear-gradient(to ${bgDirection}, 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 = value.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 ${bgDirection}, ${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 ${bgDirection}, ${start}, ${end})`;
|
|
33
|
+
}
|
|
34
|
+
default:
|
|
35
|
+
throw new Error("Unknown color channel: " + channel);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
getSliderBackground
|
|
40
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
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/is-valid-hex.ts
|
|
21
|
+
var is_valid_hex_exports = {};
|
|
22
|
+
__export(is_valid_hex_exports, {
|
|
23
|
+
isValidHex: () => isValidHex,
|
|
24
|
+
prefixHex: () => prefixHex
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(is_valid_hex_exports);
|
|
27
|
+
var HEX_REGEX = /^[0-9a-fA-F]{3,8}$/;
|
|
28
|
+
function isValidHex(value) {
|
|
29
|
+
return HEX_REGEX.test(value);
|
|
30
|
+
}
|
|
31
|
+
function prefixHex(value) {
|
|
32
|
+
if (value.startsWith("#")) return value;
|
|
33
|
+
if (isValidHex(value)) return `#${value}`;
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
isValidHex,
|
|
39
|
+
prefixHex
|
|
40
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/utils/is-valid-hex.ts
|
|
2
|
+
var HEX_REGEX = /^[0-9a-fA-F]{3,8}$/;
|
|
3
|
+
function isValidHex(value) {
|
|
4
|
+
return HEX_REGEX.test(value);
|
|
5
|
+
}
|
|
6
|
+
function prefixHex(value) {
|
|
7
|
+
if (value.startsWith("#")) return value;
|
|
8
|
+
if (isValidHex(value)) return `#${value}`;
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
isValidHex,
|
|
13
|
+
prefixHex
|
|
14
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/color-picker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
4
4
|
"description": "Core logic for the color-picker widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@zag-js/core": "1.
|
|
31
|
-
"@zag-js/anatomy": "1.
|
|
32
|
-
"@zag-js/dom-query": "1.
|
|
33
|
-
"@zag-js/dismissable": "1.
|
|
34
|
-
"@zag-js/utils": "1.
|
|
35
|
-
"@zag-js/color-utils": "1.
|
|
36
|
-
"@zag-js/popper": "1.
|
|
37
|
-
"@zag-js/types": "1.
|
|
30
|
+
"@zag-js/core": "1.35.0",
|
|
31
|
+
"@zag-js/anatomy": "1.35.0",
|
|
32
|
+
"@zag-js/dom-query": "1.35.0",
|
|
33
|
+
"@zag-js/dismissable": "1.35.0",
|
|
34
|
+
"@zag-js/utils": "1.35.0",
|
|
35
|
+
"@zag-js/color-utils": "1.35.0",
|
|
36
|
+
"@zag-js/popper": "1.35.0",
|
|
37
|
+
"@zag-js/types": "1.35.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"clean-package": "2.2.0"
|
|
41
41
|
},
|
|
42
|
-
"clean-package": "
|
|
42
|
+
"clean-package": "./clean-package.config.json",
|
|
43
43
|
"module": "dist/index.mjs",
|
|
44
44
|
"types": "dist/index.d.ts",
|
|
45
45
|
"exports": {
|
|
@@ -53,6 +53,16 @@
|
|
|
53
53
|
"default": "./dist/index.js"
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
|
+
"./anatomy": {
|
|
57
|
+
"import": {
|
|
58
|
+
"types": "./dist/color-picker.anatomy.d.mts",
|
|
59
|
+
"default": "./dist/color-picker.anatomy.mjs"
|
|
60
|
+
},
|
|
61
|
+
"require": {
|
|
62
|
+
"types": "./dist/color-picker.anatomy.d.ts",
|
|
63
|
+
"default": "./dist/color-picker.anatomy.js"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
56
66
|
"./package.json": "./package.json"
|
|
57
67
|
},
|
|
58
68
|
"scripts": {
|