@zag-js/color-utils 1.46.0 → 1.48.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/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.js +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.mjs +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.js +8 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.mjs +8 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.js +15 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.mjs +10 -0
- package/dist/area-gradient.d.mts +9 -11
- package/dist/area-gradient.d.ts +9 -11
- package/dist/area-gradient.js +53 -84
- package/dist/area-gradient.mjs +49 -71
- package/dist/color-format-gradient.d.mts +58 -60
- package/dist/color-format-gradient.d.ts +58 -60
- package/dist/color-format-gradient.js +93 -154
- package/dist/color-format-gradient.mjs +81 -123
- package/dist/color.d.mts +20 -23
- package/dist/color.d.ts +20 -23
- package/dist/color.js +57 -83
- package/dist/color.mjs +53 -60
- package/dist/hsb-color.d.mts +32 -35
- package/dist/hsb-color.d.ts +32 -35
- package/dist/hsb-color.js +135 -163
- package/dist/hsb-color.mjs +129 -138
- package/dist/hsl-color.d.mts +33 -36
- package/dist/hsl-color.d.ts +33 -36
- package/dist/hsl-color.js +137 -165
- package/dist/hsl-color.mjs +130 -139
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +10 -37
- package/dist/index.mjs +1 -9
- package/dist/native-color.d.mts +1 -3
- package/dist/native-color.d.ts +1 -3
- package/dist/native-color.js +16 -39
- package/dist/native-color.mjs +12 -16
- package/dist/parse-color.d.mts +3 -6
- package/dist/parse-color.d.ts +3 -6
- package/dist/parse-color.js +21 -47
- package/dist/parse-color.mjs +13 -20
- package/dist/rgb-color.d.mts +33 -36
- package/dist/rgb-color.d.ts +33 -36
- package/dist/rgb-color.js +174 -211
- package/dist/rgb-color.mjs +168 -186
- package/dist/types.d.mts +82 -84
- package/dist/types.d.ts +82 -84
- package/dist/types.js +4 -18
- package/dist/types.mjs +1 -0
- package/package.json +4 -4
- package/dist/chunk-QZ7TP4HQ.mjs +0 -7
package/dist/hsl-color.mjs
CHANGED
|
@@ -1,143 +1,134 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__publicField
|
|
3
|
-
} from "./chunk-QZ7TP4HQ.mjs";
|
|
4
|
-
|
|
5
|
-
// src/hsl-color.ts
|
|
6
|
-
import { clampValue, mod, toFixedNumber } from "@zag-js/utils";
|
|
7
1
|
import { Color } from "./color.mjs";
|
|
8
2
|
import { HSBColor } from "./hsb-color.mjs";
|
|
9
3
|
import { RGBColor } from "./rgb-color.mjs";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
getChannels() {
|
|
135
|
-
return _HSLColor.colorChannels;
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
__publicField(_HSLColor, "colorChannels", ["hue", "saturation", "lightness"]);
|
|
139
|
-
var HSLColor = _HSLColor;
|
|
140
|
-
export {
|
|
141
|
-
HSLColor,
|
|
142
|
-
HSL_REGEX
|
|
4
|
+
import _defineProperty from "./_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.mjs";
|
|
5
|
+
import { clampValue, mod, toFixedNumber } from "@zag-js/utils";
|
|
6
|
+
// src/hsl-color.ts
|
|
7
|
+
const HSL_REGEX = /hsl\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsla\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/;
|
|
8
|
+
var HSLColor = class HSLColor extends Color {
|
|
9
|
+
constructor(hue, saturation, lightness, alpha) {
|
|
10
|
+
super();
|
|
11
|
+
this.hue = hue;
|
|
12
|
+
this.saturation = saturation;
|
|
13
|
+
this.lightness = lightness;
|
|
14
|
+
this.alpha = alpha;
|
|
15
|
+
}
|
|
16
|
+
static parse(value) {
|
|
17
|
+
let m;
|
|
18
|
+
if (m = value.match(HSL_REGEX)) {
|
|
19
|
+
const [h, s, l, a] = (m[1] ?? m[2]).split(",").map((n) => Number(n.trim().replace("%", "")));
|
|
20
|
+
return new HSLColor(mod(h, 360), clampValue(s, 0, 100), clampValue(l, 0, 100), clampValue(a ?? 1, 0, 1));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
toString(format = "css") {
|
|
24
|
+
switch (format) {
|
|
25
|
+
case "hex": return this.toRGB().toString("hex");
|
|
26
|
+
case "hexa": return this.toRGB().toString("hexa");
|
|
27
|
+
case "hsl": return `hsl(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%)`;
|
|
28
|
+
case "css":
|
|
29
|
+
case "hsla": return `hsla(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%, ${this.alpha})`;
|
|
30
|
+
case "hsb": return this.toHSB().toString("hsb");
|
|
31
|
+
case "rgb": return this.toRGB().toString("rgb");
|
|
32
|
+
default: return this.toFormat(format).toString(format);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
toFormat(format) {
|
|
36
|
+
switch (format) {
|
|
37
|
+
case "hsla": return this;
|
|
38
|
+
case "hsba": return this.toHSB();
|
|
39
|
+
case "rgba": return this.toRGB();
|
|
40
|
+
default: throw new Error("Unsupported color conversion: hsl -> " + format);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Converts a HSL color to HSB.
|
|
45
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.
|
|
46
|
+
* @returns An HSBColor object.
|
|
47
|
+
*/
|
|
48
|
+
toHSB() {
|
|
49
|
+
let saturation = this.saturation / 100;
|
|
50
|
+
let lightness = this.lightness / 100;
|
|
51
|
+
let brightness = lightness + saturation * Math.min(lightness, 1 - lightness);
|
|
52
|
+
saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness);
|
|
53
|
+
return new HSBColor(toFixedNumber(this.hue, 2), toFixedNumber(saturation * 100, 2), toFixedNumber(brightness * 100, 2), toFixedNumber(this.alpha, 2));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Converts a HSL color to RGB.
|
|
57
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.
|
|
58
|
+
* @returns An RGBColor object.
|
|
59
|
+
*/
|
|
60
|
+
toRGB() {
|
|
61
|
+
let hue = this.hue;
|
|
62
|
+
let saturation = this.saturation / 100;
|
|
63
|
+
let lightness = this.lightness / 100;
|
|
64
|
+
let a = saturation * Math.min(lightness, 1 - lightness);
|
|
65
|
+
let fn = (n, k = (n + hue / 30) % 12) => lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
66
|
+
return new RGBColor(Math.round(fn(0) * 255), Math.round(fn(8) * 255), Math.round(fn(4) * 255), toFixedNumber(this.alpha, 2));
|
|
67
|
+
}
|
|
68
|
+
clone() {
|
|
69
|
+
return new HSLColor(this.hue, this.saturation, this.lightness, this.alpha);
|
|
70
|
+
}
|
|
71
|
+
getChannelFormatOptions(channel) {
|
|
72
|
+
switch (channel) {
|
|
73
|
+
case "hue": return {
|
|
74
|
+
style: "unit",
|
|
75
|
+
unit: "degree",
|
|
76
|
+
unitDisplay: "narrow"
|
|
77
|
+
};
|
|
78
|
+
case "saturation":
|
|
79
|
+
case "lightness":
|
|
80
|
+
case "alpha": return { style: "percent" };
|
|
81
|
+
default: throw new Error("Unknown color channel: " + channel);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
formatChannelValue(channel, locale) {
|
|
85
|
+
let options = this.getChannelFormatOptions(channel);
|
|
86
|
+
let value = this.getChannelValue(channel);
|
|
87
|
+
if (channel === "saturation" || channel === "lightness") value /= 100;
|
|
88
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
89
|
+
}
|
|
90
|
+
getChannelRange(channel) {
|
|
91
|
+
switch (channel) {
|
|
92
|
+
case "hue": return {
|
|
93
|
+
minValue: 0,
|
|
94
|
+
maxValue: 360,
|
|
95
|
+
step: 1,
|
|
96
|
+
pageSize: 15
|
|
97
|
+
};
|
|
98
|
+
case "saturation":
|
|
99
|
+
case "lightness": return {
|
|
100
|
+
minValue: 0,
|
|
101
|
+
maxValue: 100,
|
|
102
|
+
step: 1,
|
|
103
|
+
pageSize: 10
|
|
104
|
+
};
|
|
105
|
+
case "alpha": return {
|
|
106
|
+
minValue: 0,
|
|
107
|
+
maxValue: 1,
|
|
108
|
+
step: .01,
|
|
109
|
+
pageSize: .1
|
|
110
|
+
};
|
|
111
|
+
default: throw new Error("Unknown color channel: " + channel);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
toJSON() {
|
|
115
|
+
return {
|
|
116
|
+
h: this.hue,
|
|
117
|
+
s: this.saturation,
|
|
118
|
+
l: this.lightness,
|
|
119
|
+
a: this.alpha
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
getFormat() {
|
|
123
|
+
return "hsla";
|
|
124
|
+
}
|
|
125
|
+
getChannels() {
|
|
126
|
+
return HSLColor.colorChannels;
|
|
127
|
+
}
|
|
143
128
|
};
|
|
129
|
+
_defineProperty(HSLColor, "colorChannels", [
|
|
130
|
+
"hue",
|
|
131
|
+
"saturation",
|
|
132
|
+
"lightness"
|
|
133
|
+
]);
|
|
134
|
+
export { HSLColor, HSL_REGEX };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { getColorAreaGradient } from "./area-gradient.mjs";
|
|
2
|
+
import { Color } from "./color.mjs";
|
|
3
|
+
import { normalizeColor, parseColor } from "./parse-color.mjs";
|
|
4
|
+
import { ColorAxes, ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from "./types.mjs";
|
|
5
|
+
export { Color, type ColorAxes, type ColorChannel, type ColorChannelRange, type ColorFormat, type ColorStringFormat, type ColorType, getColorAreaGradient, normalizeColor, parseColor };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { getColorAreaGradient } from "./area-gradient.js";
|
|
2
|
+
import { Color } from "./color.js";
|
|
3
|
+
import { normalizeColor, parseColor } from "./parse-color.js";
|
|
4
|
+
import { ColorAxes, ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from "./types.js";
|
|
5
|
+
export { Color, type ColorAxes, type ColorChannel, type ColorChannelRange, type ColorFormat, type ColorStringFormat, type ColorType, getColorAreaGradient, normalizeColor, parseColor };
|
package/dist/index.js
CHANGED
|
@@ -1,38 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
Color: () => import_color.Color,
|
|
24
|
-
getColorAreaGradient: () => import_area_gradient.getColorAreaGradient,
|
|
25
|
-
normalizeColor: () => import_parse_color.normalizeColor,
|
|
26
|
-
parseColor: () => import_parse_color.parseColor
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
var import_area_gradient = require("./area-gradient.js");
|
|
30
|
-
var import_color = require("./color.js");
|
|
31
|
-
var import_parse_color = require("./parse-color.js");
|
|
32
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
Color,
|
|
35
|
-
getColorAreaGradient,
|
|
36
|
-
normalizeColor,
|
|
37
|
-
parseColor
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
38
4
|
});
|
|
5
|
+
const require_area_gradient = require("./area-gradient.js");
|
|
6
|
+
const require_color = require("./color.js");
|
|
7
|
+
const require_parse_color = require("./parse-color.js");
|
|
8
|
+
exports.Color = require_color.Color;
|
|
9
|
+
exports.getColorAreaGradient = require_area_gradient.getColorAreaGradient;
|
|
10
|
+
exports.normalizeColor = require_parse_color.normalizeColor;
|
|
11
|
+
exports.parseColor = require_parse_color.parseColor;
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
-
|
|
3
|
-
// src/index.ts
|
|
4
1
|
import { getColorAreaGradient } from "./area-gradient.mjs";
|
|
5
2
|
import { Color } from "./color.mjs";
|
|
6
3
|
import { normalizeColor, parseColor } from "./parse-color.mjs";
|
|
7
|
-
export {
|
|
8
|
-
Color,
|
|
9
|
-
getColorAreaGradient,
|
|
10
|
-
normalizeColor,
|
|
11
|
-
parseColor
|
|
12
|
-
};
|
|
4
|
+
export { Color, getColorAreaGradient, normalizeColor, parseColor };
|
package/dist/native-color.d.mts
CHANGED
package/dist/native-color.d.ts
CHANGED
package/dist/native-color.js
CHANGED
|
@@ -1,41 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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/native-color.ts
|
|
21
|
-
var native_color_exports = {};
|
|
22
|
-
__export(native_color_exports, {
|
|
23
|
-
nativeColorMap: () => nativeColorMap
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
4
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
5
|
+
// src/native-color.ts
|
|
6
|
+
const nativeColors = "aliceblue:f0f8ff,antiquewhite:faebd7,aqua:00ffff,aquamarine:7fffd4,azure:f0ffff,beige:f5f5dc,bisque:ffe4c4,black:000000,blanchedalmond:ffebcd,blue:0000ff,blueviolet:8a2be2,brown:a52a2a,burlywood:deb887,cadetblue:5f9ea0,chartreuse:7fff00,chocolate:d2691e,coral:ff7f50,cornflowerblue:6495ed,cornsilk:fff8dc,crimson:dc143c,cyan:00ffff,darkblue:00008b,darkcyan:008b8b,darkgoldenrod:b8860b,darkgray:a9a9a9,darkgreen:006400,darkkhaki:bdb76b,darkmagenta:8b008b,darkolivegreen:556b2f,darkorange:ff8c00,darkorchid:9932cc,darkred:8b0000,darksalmon:e9967a,darkseagreen:8fbc8f,darkslateblue:483d8b,darkslategray:2f4f4f,darkturquoise:00ced1,darkviolet:9400d3,deeppink:ff1493,deepskyblue:00bfff,dimgray:696969,dodgerblue:1e90ff,firebrick:b22222,floralwhite:fffaf0,forestgreen:228b22,fuchsia:ff00ff,gainsboro:dcdcdc,ghostwhite:f8f8ff,gold:ffd700,goldenrod:daa520,gray:808080,green:008000,greenyellow:adff2f,honeydew:f0fff0,hotpink:ff69b4,indianred:cd5c5c,indigo:4b0082,ivory:fffff0,khaki:f0e68c,lavender:e6e6fa,lavenderblush:fff0f5,lawngreen:7cfc00,lemonchiffon:fffacd,lightblue:add8e6,lightcoral:f08080,lightcyan:e0ffff,lightgoldenrodyellow:fafad2,lightgrey:d3d3d3,lightgreen:90ee90,lightpink:ffb6c1,lightsalmon:ffa07a,lightseagreen:20b2aa,lightskyblue:87cefa,lightslategray:778899,lightsteelblue:b0c4de,lightyellow:ffffe0,lime:00ff00,limegreen:32cd32,linen:faf0e6,magenta:ff00ff,maroon:800000,mediumaquamarine:66cdaa,mediumblue:0000cd,mediumorchid:ba55d3,mediumpurple:9370d8,mediumseagreen:3cb371,mediumslateblue:7b68ee,mediumspringgreen:00fa9a,mediumturquoise:48d1cc,mediumvioletred:c71585,midnightblue:191970,mintcream:f5fffa,mistyrose:ffe4e1,moccasin:ffe4b5,navajowhite:ffdead,navy:000080,oldlace:fdf5e6,olive:808000,olivedrab:6b8e23,orange:ffa500,orangered:ff4500,orchid:da70d6,palegoldenrod:eee8aa,palegreen:98fb98,paleturquoise:afeeee,palevioletred:d87093,papayawhip:ffefd5,peachpuff:ffdab9,peru:cd853f,pink:ffc0cb,plum:dda0dd,powderblue:b0e0e6,purple:800080,rebeccapurple:663399,red:ff0000,rosybrown:bc8f8f,royalblue:4169e1,saddlebrown:8b4513,salmon:fa8072,sandybrown:f4a460,seagreen:2e8b57,seashell:fff5ee,sienna:a0522d,silver:c0c0c0,skyblue:87ceeb,slateblue:6a5acd,slategray:708090,snow:fffafa,springgreen:00ff7f,steelblue:4682b4,tan:d2b48c,teal:008080,thistle:d8bfd8,tomato:ff6347,turquoise:40e0d0,violet:ee82ee,wheat:f5deb3,white:ffffff,whitesmoke:f5f5f5,yellow:ffff00,yellowgreen:9acd32";
|
|
7
|
+
const makeMap = (str) => {
|
|
8
|
+
const map = /* @__PURE__ */ new Map();
|
|
9
|
+
const list = str.split(",");
|
|
10
|
+
for (let i = 0; i < list.length; i++) {
|
|
11
|
+
const [key, val] = list[i].split(":");
|
|
12
|
+
map.set(key, `#${val}`);
|
|
13
|
+
if (key.includes("gray")) map.set(key.replace("gray", "grey"), `#${val}`);
|
|
14
|
+
}
|
|
15
|
+
return map;
|
|
36
16
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
0 && (module.exports = {
|
|
40
|
-
nativeColorMap
|
|
41
|
-
});
|
|
17
|
+
const nativeColorMap = makeMap(nativeColors);
|
|
18
|
+
exports.nativeColorMap = nativeColorMap;
|
package/dist/native-color.mjs
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
-
|
|
3
1
|
// src/native-color.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
var nativeColorMap = makeMap(nativeColors);
|
|
16
|
-
export {
|
|
17
|
-
nativeColorMap
|
|
2
|
+
const nativeColors = "aliceblue:f0f8ff,antiquewhite:faebd7,aqua:00ffff,aquamarine:7fffd4,azure:f0ffff,beige:f5f5dc,bisque:ffe4c4,black:000000,blanchedalmond:ffebcd,blue:0000ff,blueviolet:8a2be2,brown:a52a2a,burlywood:deb887,cadetblue:5f9ea0,chartreuse:7fff00,chocolate:d2691e,coral:ff7f50,cornflowerblue:6495ed,cornsilk:fff8dc,crimson:dc143c,cyan:00ffff,darkblue:00008b,darkcyan:008b8b,darkgoldenrod:b8860b,darkgray:a9a9a9,darkgreen:006400,darkkhaki:bdb76b,darkmagenta:8b008b,darkolivegreen:556b2f,darkorange:ff8c00,darkorchid:9932cc,darkred:8b0000,darksalmon:e9967a,darkseagreen:8fbc8f,darkslateblue:483d8b,darkslategray:2f4f4f,darkturquoise:00ced1,darkviolet:9400d3,deeppink:ff1493,deepskyblue:00bfff,dimgray:696969,dodgerblue:1e90ff,firebrick:b22222,floralwhite:fffaf0,forestgreen:228b22,fuchsia:ff00ff,gainsboro:dcdcdc,ghostwhite:f8f8ff,gold:ffd700,goldenrod:daa520,gray:808080,green:008000,greenyellow:adff2f,honeydew:f0fff0,hotpink:ff69b4,indianred:cd5c5c,indigo:4b0082,ivory:fffff0,khaki:f0e68c,lavender:e6e6fa,lavenderblush:fff0f5,lawngreen:7cfc00,lemonchiffon:fffacd,lightblue:add8e6,lightcoral:f08080,lightcyan:e0ffff,lightgoldenrodyellow:fafad2,lightgrey:d3d3d3,lightgreen:90ee90,lightpink:ffb6c1,lightsalmon:ffa07a,lightseagreen:20b2aa,lightskyblue:87cefa,lightslategray:778899,lightsteelblue:b0c4de,lightyellow:ffffe0,lime:00ff00,limegreen:32cd32,linen:faf0e6,magenta:ff00ff,maroon:800000,mediumaquamarine:66cdaa,mediumblue:0000cd,mediumorchid:ba55d3,mediumpurple:9370d8,mediumseagreen:3cb371,mediumslateblue:7b68ee,mediumspringgreen:00fa9a,mediumturquoise:48d1cc,mediumvioletred:c71585,midnightblue:191970,mintcream:f5fffa,mistyrose:ffe4e1,moccasin:ffe4b5,navajowhite:ffdead,navy:000080,oldlace:fdf5e6,olive:808000,olivedrab:6b8e23,orange:ffa500,orangered:ff4500,orchid:da70d6,palegoldenrod:eee8aa,palegreen:98fb98,paleturquoise:afeeee,palevioletred:d87093,papayawhip:ffefd5,peachpuff:ffdab9,peru:cd853f,pink:ffc0cb,plum:dda0dd,powderblue:b0e0e6,purple:800080,rebeccapurple:663399,red:ff0000,rosybrown:bc8f8f,royalblue:4169e1,saddlebrown:8b4513,salmon:fa8072,sandybrown:f4a460,seagreen:2e8b57,seashell:fff5ee,sienna:a0522d,silver:c0c0c0,skyblue:87ceeb,slateblue:6a5acd,slategray:708090,snow:fffafa,springgreen:00ff7f,steelblue:4682b4,tan:d2b48c,teal:008080,thistle:d8bfd8,tomato:ff6347,turquoise:40e0d0,violet:ee82ee,wheat:f5deb3,white:ffffff,whitesmoke:f5f5f5,yellow:ffff00,yellowgreen:9acd32";
|
|
3
|
+
const makeMap = (str) => {
|
|
4
|
+
const map = /* @__PURE__ */ new Map();
|
|
5
|
+
const list = str.split(",");
|
|
6
|
+
for (let i = 0; i < list.length; i++) {
|
|
7
|
+
const [key, val] = list[i].split(":");
|
|
8
|
+
map.set(key, `#${val}`);
|
|
9
|
+
if (key.includes("gray")) map.set(key.replace("gray", "grey"), `#${val}`);
|
|
10
|
+
}
|
|
11
|
+
return map;
|
|
18
12
|
};
|
|
13
|
+
const nativeColorMap = makeMap(nativeColors);
|
|
14
|
+
export { nativeColorMap };
|
package/dist/parse-color.d.mts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { ColorType } from
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const normalizeColor: (v: string | ColorType) => ColorType;
|
|
5
|
-
|
|
6
|
-
export { normalizeColor, parseColor };
|
|
1
|
+
import { ColorType } from "./types.mjs";
|
|
2
|
+
export declare const parseColor: (value: string) => ColorType;
|
|
3
|
+
export declare const normalizeColor: (v: string | ColorType) => ColorType;
|
package/dist/parse-color.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { ColorType } from
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const normalizeColor: (v: string | ColorType) => ColorType;
|
|
5
|
-
|
|
6
|
-
export { normalizeColor, parseColor };
|
|
1
|
+
import { ColorType } from "./types.js";
|
|
2
|
+
export declare const parseColor: (value: string) => ColorType;
|
|
3
|
+
export declare const normalizeColor: (v: string | ColorType) => ColorType;
|
package/dist/parse-color.js
CHANGED
|
@@ -1,50 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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/parse-color.ts
|
|
21
|
-
var parse_color_exports = {};
|
|
22
|
-
__export(parse_color_exports, {
|
|
23
|
-
normalizeColor: () => normalizeColor,
|
|
24
|
-
parseColor: () => parseColor
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
25
4
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
return result;
|
|
5
|
+
const require_hsb_color = require("./hsb-color.js");
|
|
6
|
+
const require_hsl_color = require("./hsl-color.js");
|
|
7
|
+
const require_native_color = require("./native-color.js");
|
|
8
|
+
const require_rgb_color = require("./rgb-color.js");
|
|
9
|
+
// src/parse-color.ts
|
|
10
|
+
const parseColor = (value) => {
|
|
11
|
+
if (require_native_color.nativeColorMap.has(value)) return parseColor(require_native_color.nativeColorMap.get(value));
|
|
12
|
+
const result = require_rgb_color.RGBColor.parse(value) || require_hsb_color.HSBColor.parse(value) || require_hsl_color.HSLColor.parse(value);
|
|
13
|
+
if (!result) {
|
|
14
|
+
const error = /* @__PURE__ */ new Error("Invalid color value: " + value);
|
|
15
|
+
Error.captureStackTrace?.(error, parseColor);
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
42
19
|
};
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
const normalizeColor = (v) => {
|
|
21
|
+
return typeof v === "string" ? parseColor(v) : v;
|
|
45
22
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
normalizeColor,
|
|
49
|
-
parseColor
|
|
50
|
-
});
|
|
23
|
+
exports.normalizeColor = normalizeColor;
|
|
24
|
+
exports.parseColor = parseColor;
|
package/dist/parse-color.mjs
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
-
|
|
3
|
-
// src/parse-color.ts
|
|
4
1
|
import { HSBColor } from "./hsb-color.mjs";
|
|
5
2
|
import { HSLColor } from "./hsl-color.mjs";
|
|
6
3
|
import { nativeColorMap } from "./native-color.mjs";
|
|
7
4
|
import { RGBColor } from "./rgb-color.mjs";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return result;
|
|
19
|
-
};
|
|
20
|
-
var normalizeColor = (v) => {
|
|
21
|
-
return typeof v === "string" ? parseColor(v) : v;
|
|
5
|
+
// src/parse-color.ts
|
|
6
|
+
const parseColor = (value) => {
|
|
7
|
+
if (nativeColorMap.has(value)) return parseColor(nativeColorMap.get(value));
|
|
8
|
+
const result = RGBColor.parse(value) || HSBColor.parse(value) || HSLColor.parse(value);
|
|
9
|
+
if (!result) {
|
|
10
|
+
const error = /* @__PURE__ */ new Error("Invalid color value: " + value);
|
|
11
|
+
Error.captureStackTrace?.(error, parseColor);
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
22
15
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
parseColor
|
|
16
|
+
const normalizeColor = (v) => {
|
|
17
|
+
return typeof v === "string" ? parseColor(v) : v;
|
|
26
18
|
};
|
|
19
|
+
export { normalizeColor, parseColor };
|