@zag-js/color-utils 1.34.1 → 1.35.1
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/area-gradient.d.mts +15 -0
- package/dist/area-gradient.d.ts +15 -0
- package/dist/area-gradient.js +87 -0
- package/dist/area-gradient.mjs +74 -0
- package/dist/chunk-QZ7TP4HQ.mjs +7 -0
- package/dist/color-format-gradient.d.mts +68 -0
- package/dist/color-format-gradient.d.ts +68 -0
- package/dist/color-format-gradient.js +164 -0
- package/dist/color-format-gradient.mjs +133 -0
- package/dist/color.d.mts +23 -0
- package/dist/color.d.ts +23 -0
- package/dist/color.js +87 -0
- package/dist/color.mjs +64 -0
- package/dist/hsb-color.d.mts +35 -0
- package/dist/hsb-color.d.ts +35 -0
- package/dist/hsb-color.js +165 -0
- package/dist/hsb-color.mjs +142 -0
- package/dist/hsl-color.d.mts +36 -0
- package/dist/hsl-color.d.ts +36 -0
- package/dist/hsl-color.js +167 -0
- package/dist/hsl-color.mjs +143 -0
- package/dist/index.d.mts +4 -121
- package/dist/index.d.ts +4 -121
- package/dist/index.js +37 -721
- package/dist/index.mjs +11 -716
- package/dist/native-color.d.mts +3 -0
- package/dist/native-color.d.ts +3 -0
- package/dist/native-color.js +41 -0
- package/dist/native-color.mjs +18 -0
- package/dist/parse-color.d.mts +6 -0
- package/dist/parse-color.d.ts +6 -0
- package/dist/parse-color.js +50 -0
- package/dist/parse-color.mjs +26 -0
- package/dist/rgb-color.d.mts +36 -0
- package/dist/rgb-color.d.ts +36 -0
- package/dist/rgb-color.js +213 -0
- package/dist/rgb-color.mjs +190 -0
- package/dist/types.d.mts +87 -0
- package/dist/types.d.ts +87 -0
- package/dist/types.js +18 -0
- package/dist/types.mjs +0 -0
- package/package.json +2 -2
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
type ColorHexFormat = "hex" | "hexa";
|
|
2
|
+
type ColorFormat = "rgba" | "hsla" | "hsba";
|
|
3
|
+
type ColorStringFormat = ColorHexFormat | ColorFormat | "rgb" | "hsl" | "hsb" | "css";
|
|
4
|
+
type ColorChannel = "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha";
|
|
5
|
+
interface Color2DAxes {
|
|
6
|
+
xChannel: ColorChannel;
|
|
7
|
+
yChannel: ColorChannel;
|
|
8
|
+
}
|
|
9
|
+
interface ColorAxes extends Color2DAxes {
|
|
10
|
+
zChannel: ColorChannel;
|
|
11
|
+
}
|
|
12
|
+
interface ColorChannelRange {
|
|
13
|
+
/** The minimum value of the color channel. */
|
|
14
|
+
minValue: number;
|
|
15
|
+
/** The maximum value of the color channel. */
|
|
16
|
+
maxValue: number;
|
|
17
|
+
/** The step value of the color channel, used when incrementing and decrementing. */
|
|
18
|
+
step: number;
|
|
19
|
+
/** The page step value of the color channel, used when incrementing and decrementing. */
|
|
20
|
+
pageSize: number;
|
|
21
|
+
}
|
|
22
|
+
interface ColorType {
|
|
23
|
+
/** Converts the color to the given color format, and returns a new Color object. */
|
|
24
|
+
toFormat(format: ColorFormat): ColorType;
|
|
25
|
+
/** Converts the color to a JSON object. */
|
|
26
|
+
toJSON(): Record<string, number>;
|
|
27
|
+
/** Converts the color to a string in the given format. Defaults to CSS format. */
|
|
28
|
+
toString(format?: ColorStringFormat): string;
|
|
29
|
+
/** Converts the color to hex, and returns an integer representation. */
|
|
30
|
+
toHexInt(): number;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the numeric value for a given channel.
|
|
33
|
+
* Throws an error if the channel is unsupported in the current color format.
|
|
34
|
+
*/
|
|
35
|
+
getChannelValue(channel: ColorChannel): number;
|
|
36
|
+
/**
|
|
37
|
+
* Sets the numeric value for a given channel, and returns a new Color object.
|
|
38
|
+
* Throws an error if the channel is unsupported in the current color format.
|
|
39
|
+
*/
|
|
40
|
+
withChannelValue(channel: ColorChannel, value: number): ColorType;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the formatted value for a given channel.
|
|
43
|
+
*/
|
|
44
|
+
formatChannelValue(channel: ColorChannel, locale: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the minimum, maximum, and step values for a given channel.
|
|
47
|
+
*/
|
|
48
|
+
getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the color space, 'rgb', 'hsb' or 'hsl', for the current color.
|
|
51
|
+
*/
|
|
52
|
+
getFormat(): ColorFormat;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the color space axes, xChannel, yChannel, zChannel.
|
|
55
|
+
*/
|
|
56
|
+
getColorAxes(xyChannels: Color2DAxes): ColorAxes;
|
|
57
|
+
/**
|
|
58
|
+
* Returns an array of the color channels within the current color space space.
|
|
59
|
+
*/
|
|
60
|
+
getChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
61
|
+
/**
|
|
62
|
+
* Returns a new Color object with the same values as the current color.
|
|
63
|
+
*/
|
|
64
|
+
clone(): ColorType;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the color is equal to another color.
|
|
67
|
+
*/
|
|
68
|
+
isEqual(color: ColorType): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Increments the color channel by the given step size, and returns a new Color object.
|
|
71
|
+
*/
|
|
72
|
+
incrementChannel(channel: ColorChannel, stepSize: number): ColorType;
|
|
73
|
+
/**
|
|
74
|
+
* Decrements the color channel by the given step size, and returns a new Color object.
|
|
75
|
+
*/
|
|
76
|
+
decrementChannel(channel: ColorChannel, stepSize: number): ColorType;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the color channel value as a percentage of the channel range.
|
|
79
|
+
*/
|
|
80
|
+
getChannelValuePercent(channel: ColorChannel, value?: number): number;
|
|
81
|
+
/**
|
|
82
|
+
* Returns the color channel value for a given percentage of the channel range.
|
|
83
|
+
*/
|
|
84
|
+
getChannelPercentValue(channel: ColorChannel, percent: number): number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type { Color2DAxes, ColorAxes, ColorChannel, ColorChannelRange, ColorFormat, ColorHexFormat, ColorStringFormat, ColorType };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
type ColorHexFormat = "hex" | "hexa";
|
|
2
|
+
type ColorFormat = "rgba" | "hsla" | "hsba";
|
|
3
|
+
type ColorStringFormat = ColorHexFormat | ColorFormat | "rgb" | "hsl" | "hsb" | "css";
|
|
4
|
+
type ColorChannel = "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha";
|
|
5
|
+
interface Color2DAxes {
|
|
6
|
+
xChannel: ColorChannel;
|
|
7
|
+
yChannel: ColorChannel;
|
|
8
|
+
}
|
|
9
|
+
interface ColorAxes extends Color2DAxes {
|
|
10
|
+
zChannel: ColorChannel;
|
|
11
|
+
}
|
|
12
|
+
interface ColorChannelRange {
|
|
13
|
+
/** The minimum value of the color channel. */
|
|
14
|
+
minValue: number;
|
|
15
|
+
/** The maximum value of the color channel. */
|
|
16
|
+
maxValue: number;
|
|
17
|
+
/** The step value of the color channel, used when incrementing and decrementing. */
|
|
18
|
+
step: number;
|
|
19
|
+
/** The page step value of the color channel, used when incrementing and decrementing. */
|
|
20
|
+
pageSize: number;
|
|
21
|
+
}
|
|
22
|
+
interface ColorType {
|
|
23
|
+
/** Converts the color to the given color format, and returns a new Color object. */
|
|
24
|
+
toFormat(format: ColorFormat): ColorType;
|
|
25
|
+
/** Converts the color to a JSON object. */
|
|
26
|
+
toJSON(): Record<string, number>;
|
|
27
|
+
/** Converts the color to a string in the given format. Defaults to CSS format. */
|
|
28
|
+
toString(format?: ColorStringFormat): string;
|
|
29
|
+
/** Converts the color to hex, and returns an integer representation. */
|
|
30
|
+
toHexInt(): number;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the numeric value for a given channel.
|
|
33
|
+
* Throws an error if the channel is unsupported in the current color format.
|
|
34
|
+
*/
|
|
35
|
+
getChannelValue(channel: ColorChannel): number;
|
|
36
|
+
/**
|
|
37
|
+
* Sets the numeric value for a given channel, and returns a new Color object.
|
|
38
|
+
* Throws an error if the channel is unsupported in the current color format.
|
|
39
|
+
*/
|
|
40
|
+
withChannelValue(channel: ColorChannel, value: number): ColorType;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the formatted value for a given channel.
|
|
43
|
+
*/
|
|
44
|
+
formatChannelValue(channel: ColorChannel, locale: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the minimum, maximum, and step values for a given channel.
|
|
47
|
+
*/
|
|
48
|
+
getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the color space, 'rgb', 'hsb' or 'hsl', for the current color.
|
|
51
|
+
*/
|
|
52
|
+
getFormat(): ColorFormat;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the color space axes, xChannel, yChannel, zChannel.
|
|
55
|
+
*/
|
|
56
|
+
getColorAxes(xyChannels: Color2DAxes): ColorAxes;
|
|
57
|
+
/**
|
|
58
|
+
* Returns an array of the color channels within the current color space space.
|
|
59
|
+
*/
|
|
60
|
+
getChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
61
|
+
/**
|
|
62
|
+
* Returns a new Color object with the same values as the current color.
|
|
63
|
+
*/
|
|
64
|
+
clone(): ColorType;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the color is equal to another color.
|
|
67
|
+
*/
|
|
68
|
+
isEqual(color: ColorType): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Increments the color channel by the given step size, and returns a new Color object.
|
|
71
|
+
*/
|
|
72
|
+
incrementChannel(channel: ColorChannel, stepSize: number): ColorType;
|
|
73
|
+
/**
|
|
74
|
+
* Decrements the color channel by the given step size, and returns a new Color object.
|
|
75
|
+
*/
|
|
76
|
+
decrementChannel(channel: ColorChannel, stepSize: number): ColorType;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the color channel value as a percentage of the channel range.
|
|
79
|
+
*/
|
|
80
|
+
getChannelValuePercent(channel: ColorChannel, value?: number): number;
|
|
81
|
+
/**
|
|
82
|
+
* Returns the color channel value for a given percentage of the channel range.
|
|
83
|
+
*/
|
|
84
|
+
getChannelPercentValue(channel: ColorChannel, percent: number): number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type { Color2DAxes, ColorAxes, ColorChannel, ColorChannelRange, ColorFormat, ColorHexFormat, ColorStringFormat, ColorType };
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
package/dist/types.mjs
ADDED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/color-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.1",
|
|
4
4
|
"description": "Color utilities for zag.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"clean-package": "../../../clean-package.config.json",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@zag-js/utils": "1.
|
|
27
|
+
"@zag-js/utils": "1.35.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"clean-package": "2.2.0"
|