@zag-js/color-utils 0.56.1 → 0.57.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 +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/color.ts +1 -0
- package/src/hsb-color.ts +22 -0
- package/src/hsl-color.ts +22 -0
- package/src/rgb-color.ts +19 -0
- package/src/types.ts +5 -0
package/dist/index.d.mts
CHANGED
|
@@ -38,6 +38,10 @@ interface ColorType {
|
|
|
38
38
|
* Throws an error if the channel is unsupported in the current color format.
|
|
39
39
|
*/
|
|
40
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;
|
|
41
45
|
/**
|
|
42
46
|
* Returns the minimum, maximum, and step values for a given channel.
|
|
43
47
|
*/
|
|
@@ -88,6 +92,7 @@ declare abstract class Color implements ColorType {
|
|
|
88
92
|
abstract getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
89
93
|
abstract getFormat(): ColorFormat;
|
|
90
94
|
abstract getChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
95
|
+
abstract formatChannelValue(channel: ColorChannel, locale: string): string;
|
|
91
96
|
toHexInt(): number;
|
|
92
97
|
getChannelValue(channel: ColorChannel): number;
|
|
93
98
|
getChannelValuePercent(channel: ColorChannel, valueToCheck?: number): number;
|
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,10 @@ interface ColorType {
|
|
|
38
38
|
* Throws an error if the channel is unsupported in the current color format.
|
|
39
39
|
*/
|
|
40
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;
|
|
41
45
|
/**
|
|
42
46
|
* Returns the minimum, maximum, and step values for a given channel.
|
|
43
47
|
*/
|
|
@@ -88,6 +92,7 @@ declare abstract class Color implements ColorType {
|
|
|
88
92
|
abstract getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
89
93
|
abstract getFormat(): ColorFormat;
|
|
90
94
|
abstract getChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
95
|
+
abstract formatChannelValue(channel: ColorChannel, locale: string): string;
|
|
91
96
|
toHexInt(): number;
|
|
92
97
|
getChannelValue(channel: ColorChannel): number;
|
|
93
98
|
getChannelValuePercent(channel: ColorChannel, valueToCheck?: number): number;
|
package/dist/index.js
CHANGED
|
@@ -411,6 +411,23 @@ var _RGBColor = class _RGBColor extends Color {
|
|
|
411
411
|
clone() {
|
|
412
412
|
return new _RGBColor(this.red, this.green, this.blue, this.alpha);
|
|
413
413
|
}
|
|
414
|
+
getChannelFormatOptions(channel) {
|
|
415
|
+
switch (channel) {
|
|
416
|
+
case "red":
|
|
417
|
+
case "green":
|
|
418
|
+
case "blue":
|
|
419
|
+
return { style: "decimal" };
|
|
420
|
+
case "alpha":
|
|
421
|
+
return { style: "percent" };
|
|
422
|
+
default:
|
|
423
|
+
throw new Error("Unknown color channel: " + channel);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
formatChannelValue(channel, locale) {
|
|
427
|
+
let options = this.getChannelFormatOptions(channel);
|
|
428
|
+
let value = this.getChannelValue(channel);
|
|
429
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
430
|
+
}
|
|
414
431
|
getChannelRange(channel) {
|
|
415
432
|
switch (channel) {
|
|
416
433
|
case "red":
|
|
@@ -522,6 +539,26 @@ var _HSLColor = class _HSLColor extends Color {
|
|
|
522
539
|
clone() {
|
|
523
540
|
return new _HSLColor(this.hue, this.saturation, this.lightness, this.alpha);
|
|
524
541
|
}
|
|
542
|
+
getChannelFormatOptions(channel) {
|
|
543
|
+
switch (channel) {
|
|
544
|
+
case "hue":
|
|
545
|
+
return { style: "unit", unit: "degree", unitDisplay: "narrow" };
|
|
546
|
+
case "saturation":
|
|
547
|
+
case "lightness":
|
|
548
|
+
case "alpha":
|
|
549
|
+
return { style: "percent" };
|
|
550
|
+
default:
|
|
551
|
+
throw new Error("Unknown color channel: " + channel);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
formatChannelValue(channel, locale) {
|
|
555
|
+
let options = this.getChannelFormatOptions(channel);
|
|
556
|
+
let value = this.getChannelValue(channel);
|
|
557
|
+
if (channel === "saturation" || channel === "lightness") {
|
|
558
|
+
value /= 100;
|
|
559
|
+
}
|
|
560
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
561
|
+
}
|
|
525
562
|
getChannelRange(channel) {
|
|
526
563
|
switch (channel) {
|
|
527
564
|
case "hue":
|
|
@@ -634,6 +671,26 @@ var _HSBColor = class _HSBColor extends Color {
|
|
|
634
671
|
clone() {
|
|
635
672
|
return new _HSBColor(this.hue, this.saturation, this.brightness, this.alpha);
|
|
636
673
|
}
|
|
674
|
+
getChannelFormatOptions(channel) {
|
|
675
|
+
switch (channel) {
|
|
676
|
+
case "hue":
|
|
677
|
+
return { style: "unit", unit: "degree", unitDisplay: "narrow" };
|
|
678
|
+
case "saturation":
|
|
679
|
+
case "brightness":
|
|
680
|
+
case "alpha":
|
|
681
|
+
return { style: "percent" };
|
|
682
|
+
default:
|
|
683
|
+
throw new Error("Unknown color channel: " + channel);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
formatChannelValue(channel, locale) {
|
|
687
|
+
let options = this.getChannelFormatOptions(channel);
|
|
688
|
+
let value = this.getChannelValue(channel);
|
|
689
|
+
if (channel === "saturation" || channel === "brightness") {
|
|
690
|
+
value /= 100;
|
|
691
|
+
}
|
|
692
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
693
|
+
}
|
|
637
694
|
getChannelRange(channel) {
|
|
638
695
|
switch (channel) {
|
|
639
696
|
case "hue":
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/color-format-gradient.ts","../src/area-gradient.ts","../src/color.ts","../src/hsb-color.ts","../src/hsl-color.ts","../src/rgb-color.ts","../src/native-color.ts","../src/parse-color.ts"],"sourcesContent":["export { getColorAreaGradient } from \"./area-gradient\"\nexport { Color } from \"./color\"\nexport { normalizeColor, parseColor } from \"./parse-color\"\nexport type { ColorAxes, ColorChannel, ColorChannelRange, ColorFormat, ColorType } from \"./types\"\n","export const generateRGB_R = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_G = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_B = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateHSL_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(dir)]\n }, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(!dir)]\n }, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}))`,\n \"hsl(0, 0%, 50%)\",\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_L = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n backgroundImage: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_B = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}))`,\n \"#000\",\n ].join(\",\"),\n },\n }\n return result\n}\n","import type { Color } from \"./color\"\nimport {\n generateRGB_R,\n generateRGB_G,\n generateRGB_B,\n generateHSL_H,\n generateHSB_H,\n generateHSL_S,\n generateHSB_S,\n generateHSB_B,\n generateHSL_L,\n} from \"./color-format-gradient\"\nimport type { ColorChannel } from \"./types\"\n\ninterface GradientOptions {\n xChannel: ColorChannel\n yChannel: ColorChannel\n dir?: \"rtl\" | \"ltr\"\n}\n\ninterface GradientStyles {\n areaStyles: Record<string, string>\n areaGradientStyles: Record<string, string>\n}\n\nexport function getColorAreaGradient(color: Color, options: GradientOptions): GradientStyles {\n const { xChannel, yChannel, dir: dirProp = \"ltr\" } = options\n\n const { zChannel } = color.getColorAxes({ xChannel, yChannel })\n const zValue = color.getChannelValue(zChannel)\n\n const { minValue: zMin, maxValue: zMax } = color.getChannelRange(zChannel)\n const orientation: [string, string] = [\"top\", dirProp === \"rtl\" ? \"left\" : \"right\"]\n\n let dir = false\n\n let background = { areaStyles: {}, areaGradientStyles: {} }\n\n let alphaValue = (zValue - zMin) / (zMax - zMin)\n let isHSL = color.getFormat() === \"hsla\"\n\n switch (zChannel) {\n case \"red\": {\n dir = xChannel === \"green\"\n background = generateRGB_R(orientation, dir, zValue)\n break\n }\n\n case \"green\": {\n dir = xChannel === \"red\"\n background = generateRGB_G(orientation, dir, zValue)\n break\n }\n\n case \"blue\": {\n dir = xChannel === \"red\"\n background = generateRGB_B(orientation, dir, zValue)\n break\n }\n\n case \"hue\": {\n dir = xChannel !== \"saturation\"\n if (isHSL) {\n background = generateHSL_H(orientation, dir, zValue)\n } else {\n background = generateHSB_H(orientation, dir, zValue)\n }\n break\n }\n\n case \"saturation\": {\n dir = xChannel === \"hue\"\n if (isHSL) {\n background = generateHSL_S(orientation, dir, alphaValue)\n } else {\n background = generateHSB_S(orientation, dir, alphaValue)\n }\n break\n }\n\n case \"brightness\": {\n dir = xChannel === \"hue\"\n background = generateHSB_B(orientation, dir, alphaValue)\n break\n }\n\n case \"lightness\": {\n dir = xChannel === \"hue\"\n background = generateHSL_L(orientation, dir, zValue)\n break\n }\n }\n\n return background\n}\n","import { clampValue, getPercentValue, getValuePercent, snapValueToStep } from \"@zag-js/numeric-range\"\nimport type {\n Color2DAxes,\n ColorAxes,\n ColorChannel,\n ColorChannelRange,\n ColorFormat,\n ColorStringFormat,\n ColorType,\n} from \"./types\"\n\nconst isEqualObject = (a: Record<string, number>, b: Record<string, number>): boolean => {\n if (Object.keys(a).length !== Object.keys(b).length) return false\n for (let key in a) if (a[key] !== b[key]) return false\n return true\n}\n\nexport abstract class Color implements ColorType {\n abstract toFormat(format: ColorFormat): ColorType\n abstract toJSON(): Record<string, number>\n abstract toString(format: ColorStringFormat): string\n abstract clone(): ColorType\n abstract getChannelRange(channel: ColorChannel): ColorChannelRange\n abstract getFormat(): ColorFormat\n abstract getChannels(): [ColorChannel, ColorChannel, ColorChannel]\n\n toHexInt(): number {\n return this.toFormat(\"rgba\").toHexInt()\n }\n\n getChannelValue(channel: ColorChannel): number {\n if (channel in this) return this[channel]\n throw new Error(\"Unsupported color channel: \" + channel)\n }\n\n getChannelValuePercent(channel: ColorChannel, valueToCheck?: number): number {\n const value = valueToCheck ?? this.getChannelValue(channel)\n const { minValue, maxValue } = this.getChannelRange(channel)\n return getValuePercent(value, minValue, maxValue)\n }\n\n getChannelPercentValue(channel: ColorChannel, percentToCheck: number): number {\n const { minValue, maxValue, step } = this.getChannelRange(channel)\n const percentValue = getPercentValue(percentToCheck, minValue, maxValue, step)\n return snapValueToStep(percentValue, minValue, maxValue, step)\n }\n\n withChannelValue(channel: ColorChannel, value: number): ColorType {\n const { minValue, maxValue } = this.getChannelRange(channel)\n if (channel in this) {\n let clone = this.clone()\n clone[channel] = clampValue(value, minValue, maxValue)\n return clone\n }\n\n throw new Error(\"Unsupported color channel: \" + channel)\n }\n\n getColorAxes(xyChannels: Color2DAxes): ColorAxes {\n let { xChannel, yChannel } = xyChannels\n let xCh = xChannel || this.getChannels().find((c) => c !== yChannel)\n let yCh = yChannel || this.getChannels().find((c) => c !== xCh)\n let zCh = this.getChannels().find((c) => c !== xCh && c !== yCh)\n return { xChannel: xCh!, yChannel: yCh!, zChannel: zCh! }\n }\n\n incrementChannel(channel: ColorChannel, stepSize: number): ColorType {\n const { minValue, maxValue, step } = this.getChannelRange(channel)\n const value = snapValueToStep(\n clampValue(this.getChannelValue(channel) + stepSize, minValue, maxValue),\n minValue,\n maxValue,\n step,\n )\n return this.withChannelValue(channel, value)\n }\n\n decrementChannel(channel: ColorChannel, stepSize: number): ColorType {\n return this.incrementChannel(channel, -stepSize)\n }\n\n isEqual(color: ColorType): boolean {\n const isSame = isEqualObject(this.toJSON(), color.toJSON())\n return isSame && this.getChannelValue(\"alpha\") === color.getChannelValue(\"alpha\")\n }\n}\n","import { clampValue, mod, toFixedNumber } from \"@zag-js/numeric-range\"\nimport { Color } from \"./color\"\nimport { HSLColor } from \"./hsl-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport type { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from \"./types\"\n\nconst HSB_REGEX =\n /hsb\\(([-+]?\\d+(?:.\\d+)?\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d+(?:.\\d+)?%)\\)|hsba\\(([-+]?\\d+(?:.\\d+)?\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d(.\\d+)?)\\)/\n\nexport class HSBColor extends Color {\n constructor(\n private hue: number,\n private saturation: number,\n private brightness: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string): HSBColor | void {\n let m: RegExpMatchArray | null\n if ((m = value.match(HSB_REGEX))) {\n const [h, s, b, a] = (m[1] ?? m[2]).split(\",\").map((n) => Number(n.trim().replace(\"%\", \"\")))\n return new HSBColor(mod(h, 360), clampValue(s, 0, 100), clampValue(b, 0, 100), clampValue(a ?? 1, 0, 1))\n }\n }\n\n toString(format: ColorStringFormat) {\n switch (format) {\n case \"css\":\n return this.toHSL().toString(\"css\")\n case \"hex\":\n return this.toRGB().toString(\"hex\")\n case \"hexa\":\n return this.toRGB().toString(\"hexa\")\n case \"hsb\":\n return `hsb(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%)`\n case \"hsba\":\n return `hsba(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%, ${\n this.alpha\n })`\n case \"hsl\":\n return this.toHSL().toString(\"hsl\")\n case \"rgb\":\n return this.toRGB().toString(\"rgb\")\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"hsba\":\n return this\n case \"hsla\":\n return this.toHSL()\n case \"rgba\":\n return this.toRGB()\n default:\n throw new Error(\"Unsupported color conversion: hsb -> \" + format)\n }\n }\n\n /**\n * Converts a HSB color to HSL.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL.\n * @returns An HSLColor object.\n */\n private toHSL(): ColorType {\n let saturation = this.saturation / 100\n let brightness = this.brightness / 100\n let lightness = brightness * (1 - saturation / 2)\n saturation = lightness === 0 || lightness === 1 ? 0 : (brightness - lightness) / Math.min(lightness, 1 - lightness)\n\n return new HSLColor(\n toFixedNumber(this.hue, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(lightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n /**\n * Converts a HSV color value to RGB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative.\n * @returns An RGBColor object.\n */\n private toRGB(): ColorType {\n let hue = this.hue\n let saturation = this.saturation / 100\n let brightness = this.brightness / 100\n\n let fn = (n: number, k = (n + hue / 60) % 6) =>\n brightness - saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0)\n\n return new RGBColor(\n Math.round(fn(5) * 255),\n Math.round(fn(3) * 255),\n Math.round(fn(1) * 255),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n clone(): ColorType {\n return new HSBColor(this.hue, this.saturation, this.brightness, this.alpha)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 }\n case \"saturation\":\n case \"brightness\":\n return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n toJSON(): Record<\"h\" | \"s\" | \"b\" | \"a\", number> {\n return { h: this.hue, s: this.saturation, b: this.brightness, a: this.alpha }\n }\n\n getFormat(): ColorFormat {\n return \"hsba\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"hue\", \"saturation\", \"brightness\"]\n\n getChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return HSBColor.colorChannels\n }\n}\n","import { clampValue, mod, toFixedNumber } from \"@zag-js/numeric-range\"\nimport { Color } from \"./color\"\nimport { HSBColor } from \"./hsb-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport type { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from \"./types\"\n\nexport const HSL_REGEX =\n /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+)?)\\)/\n\nexport class HSLColor extends Color {\n constructor(\n private hue: number,\n private saturation: number,\n private lightness: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string): HSLColor | void {\n let m: RegExpMatchArray | null\n if ((m = value.match(HSL_REGEX))) {\n const [h, s, l, a] = (m[1] ?? m[2]).split(\",\").map((n) => Number(n.trim().replace(\"%\", \"\")))\n return new HSLColor(mod(h, 360), clampValue(s, 0, 100), clampValue(l, 0, 100), clampValue(a ?? 1, 0, 1))\n }\n }\n\n toString(format: ColorStringFormat) {\n switch (format) {\n case \"hex\":\n return this.toRGB().toString(\"hex\")\n case \"hexa\":\n return this.toRGB().toString(\"hexa\")\n case \"hsl\":\n return `hsl(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%)`\n case \"css\":\n case \"hsla\":\n return `hsla(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%, ${\n this.alpha\n })`\n case \"hsb\":\n return this.toHSB().toString(\"hsb\")\n case \"rgb\":\n return this.toRGB().toString(\"rgb\")\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"hsla\":\n return this\n case \"hsba\":\n return this.toHSB()\n case \"rgba\":\n return this.toRGB()\n default:\n throw new Error(\"Unsupported color conversion: hsl -> \" + format)\n }\n }\n\n /**\n * Converts a HSL color to HSB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.\n * @returns An HSBColor object.\n */\n private toHSB(): ColorType {\n let saturation = this.saturation / 100\n let lightness = this.lightness / 100\n let brightness = lightness + saturation * Math.min(lightness, 1 - lightness)\n saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness)\n return new HSBColor(\n toFixedNumber(this.hue, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(brightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n /**\n * Converts a HSL color to RGB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.\n * @returns An RGBColor object.\n */\n private toRGB(): ColorType {\n let hue = this.hue\n let saturation = this.saturation / 100\n let lightness = this.lightness / 100\n let a = saturation * Math.min(lightness, 1 - lightness)\n let fn = (n: number, k = (n + hue / 30) % 12) => lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)\n return new RGBColor(\n Math.round(fn(0) * 255),\n Math.round(fn(8) * 255),\n Math.round(fn(4) * 255),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n clone(): ColorType {\n return new HSLColor(this.hue, this.saturation, this.lightness, this.alpha)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 }\n case \"saturation\":\n case \"lightness\":\n return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n toJSON(): Record<\"h\" | \"s\" | \"l\" | \"a\", number> {\n return { h: this.hue, s: this.saturation, l: this.lightness, a: this.alpha }\n }\n\n getFormat(): ColorFormat {\n return \"hsla\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"hue\", \"saturation\", \"lightness\"]\n\n getChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return HSLColor.colorChannels\n }\n}\n","import { clampValue, toFixedNumber } from \"@zag-js/numeric-range\"\nimport { Color } from \"./color\"\nimport { HSBColor } from \"./hsb-color\"\nimport { HSLColor } from \"./hsl-color\"\nimport type { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from \"./types\"\n\nexport class RGBColor extends Color {\n constructor(\n private red: number,\n private green: number,\n private blue: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string) {\n let colors: (number | undefined)[] = []\n\n // matching #rgb, #rgba, #rrggbb, #rrggbbaa\n if (/^#[\\da-f]+$/i.test(value) && [4, 5, 7, 9].includes(value.length)) {\n const values = (value.length < 6 ? value.replace(/[^#]/gi, \"$&$&\") : value).slice(1).split(\"\")\n while (values.length > 0) {\n colors.push(parseInt(values.splice(0, 2).join(\"\"), 16))\n }\n colors[3] = colors[3] !== undefined ? colors[3] / 255 : undefined\n }\n\n // matching rgb(rrr, ggg, bbb), rgba(rrr, ggg, bbb, 0.a)\n const match = value.match(/^rgba?\\((.*)\\)$/)\n\n if (match?.[1]) {\n colors = match[1]\n .split(\",\")\n .map((value) => Number(value.trim()))\n .map((num, i) => clampValue(num, 0, i < 3 ? 255 : 1))\n }\n\n //@ts-expect-error\n return colors.length < 3 ? undefined : new RGBColor(colors[0], colors[1], colors[2], colors[3] ?? 1)\n }\n\n toString(format: ColorStringFormat) {\n switch (format) {\n case \"hex\":\n return (\n \"#\" +\n (\n this.red.toString(16).padStart(2, \"0\") +\n this.green.toString(16).padStart(2, \"0\") +\n this.blue.toString(16).padStart(2, \"0\")\n ).toUpperCase()\n )\n case \"hexa\":\n return (\n \"#\" +\n (\n this.red.toString(16).padStart(2, \"0\") +\n this.green.toString(16).padStart(2, \"0\") +\n this.blue.toString(16).padStart(2, \"0\") +\n Math.round(this.alpha * 255)\n .toString(16)\n .padStart(2, \"0\")\n ).toUpperCase()\n )\n case \"rgb\":\n return `rgb(${this.red}, ${this.green}, ${this.blue})`\n case \"css\":\n case \"rgba\":\n return `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`\n case \"hsl\":\n return this.toHSL().toString(\"hsl\")\n case \"hsb\":\n return this.toHSB().toString(\"hsb\")\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"rgba\":\n return this\n case \"hsba\":\n return this.toHSB()\n case \"hsla\":\n return this.toHSL()\n default:\n throw new Error(\"Unsupported color conversion: rgb -> \" + format)\n }\n }\n\n toHexInt(): number {\n return (this.red << 16) | (this.green << 8) | this.blue\n }\n\n /**\n * Converts an RGB color value to HSB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.\n * @returns An HSBColor object.\n */\n private toHSB(): ColorType {\n const red = this.red / 255\n const green = this.green / 255\n const blue = this.blue / 255\n const min = Math.min(red, green, blue)\n const brightness = Math.max(red, green, blue)\n const chroma = brightness - min\n const saturation = brightness === 0 ? 0 : chroma / brightness\n let hue = 0 // achromatic\n\n if (chroma !== 0) {\n switch (brightness) {\n case red:\n hue = (green - blue) / chroma + (green < blue ? 6 : 0)\n break\n case green:\n hue = (blue - red) / chroma + 2\n break\n case blue:\n hue = (red - green) / chroma + 4\n break\n }\n\n hue /= 6\n }\n\n return new HSBColor(\n toFixedNumber(hue * 360, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(brightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n /**\n * Converts an RGB color value to HSL.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.\n * @returns An HSLColor object.\n */\n private toHSL(): ColorType {\n const red = this.red / 255\n const green = this.green / 255\n const blue = this.blue / 255\n const min = Math.min(red, green, blue)\n const max = Math.max(red, green, blue)\n const lightness = (max + min) / 2\n const chroma = max - min\n\n let hue = -1\n let saturation = -1\n\n if (chroma === 0) {\n hue = saturation = 0 // achromatic\n } else {\n saturation = chroma / (lightness < 0.5 ? max + min : 2 - max - min)\n\n switch (max) {\n case red:\n hue = (green - blue) / chroma + (green < blue ? 6 : 0)\n break\n case green:\n hue = (blue - red) / chroma + 2\n break\n case blue:\n hue = (red - green) / chroma + 4\n break\n }\n\n hue /= 6\n }\n\n return new HSLColor(\n toFixedNumber(hue * 360, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(lightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n clone(): ColorType {\n return new RGBColor(this.red, this.green, this.blue, this.alpha)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"red\":\n case \"green\":\n case \"blue\":\n return { minValue: 0x0, maxValue: 0xff, step: 0x1, pageSize: 0x11 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n toJSON(): Record<\"r\" | \"g\" | \"b\" | \"a\", number> {\n return { r: this.red, g: this.green, b: this.blue, a: this.alpha }\n }\n\n getFormat(): ColorFormat {\n return \"rgba\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"red\", \"green\", \"blue\"]\n\n getChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return RGBColor.colorChannels\n }\n}\n","const nativeColors /* @__PURE__ */ =\n \"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,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\"\n\nconst makeMap = (str: string) => {\n const map = new Map<string, string>()\n const list = str.split(\",\")\n for (let i = 0; i < list.length; i++) {\n const [key, val] = list[i].split(\":\")\n map.set(key, `#${val}`)\n }\n return map\n}\n\nexport const nativeColorMap /* @__PURE__ */ = makeMap(nativeColors)\n","import { HSBColor } from \"./hsb-color\"\nimport { HSLColor } from \"./hsl-color\"\nimport { nativeColorMap } from \"./native-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport type { ColorType } from \"./types\"\n\nexport const parseColor = (value: string): ColorType => {\n if (nativeColorMap.has(value)) {\n return parseColor(nativeColorMap.get(value)!)\n }\n\n const result = RGBColor.parse(value) || HSBColor.parse(value) || HSLColor.parse(value)\n\n if (!result) {\n const error = new Error(\"Invalid color value: \" + value)\n Error.captureStackTrace?.(error, parseColor)\n throw error\n }\n\n return result\n}\n\nexport const normalizeColor = (v: string | ColorType) => {\n return typeof v === \"string\" ? parseColor(v) : v\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gBAAgB,CAAC,aAA+B,KAAc,WAAmB;AAC5F,QAAM,YAAY,sBAAsB,YAAY,OAAO,CAAC,GAAG,CAAC,CAAC;AACjE,QAAM,SAAS;AAAA,IACb,YAAY;AAAA,MACV,iBAAiB,sBAAsB,YAAY,OAAO,GAAG,CAAC,CAAC,QAAQ,MAAM,aAAa,MAAM;AAAA,IAClG;AAAA,IACA,oBAAoB;AAAA,MAClB,iBAAiB,sBAAsB,YAAY,OAAO,GAAG,CAAC,CAAC,QAAQ,MAAM,eAAe,MAAM;AAAA,MAClG,iBAAiB;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEO,IAAM,gBAAgB,CAAC,aAA+B,KAAc,WAAmB;AAC5F,QAAM,YAAY,sBAAsB,YAAY,OAAO,CAAC,GAAG,CAAC,CAAC;AACjE,QAAM,SAAS;AAAA,IACb,YAAY;AAAA,MACV,iBAAiB,sBAAsB,YAAY,OAAO,GAAG,CAAC,CAAC,UAAU,MAAM,eAAe,MAAM;AAAA,IACtG;AAAA,IACA,oBAAoB;AAAA,MAClB,iBAAiB,sBAAsB,YAAY,OAAO,GAAG,CAAC,CAAC,UAAU,MAAM,iBAAiB,MAAM;AAAA,MACtG,iBAAiB;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEO,IAAM,gBAAgB,CAAC,aAA+B,KAAc,WAAmB;AAC5F,QAAM,YAAY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MAAM,oBAAI,IAAoB;AACpC,QAAM,OAAO,IAAI,MAAM,GAAG;AAC1B,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,MAAM,GAAG;AACpC,QAAI,IAAI,KAAK,IAAI,GAAG,EAAE;AAAA,EACxB;AACA,SAAO;AACT;AAEO,IAAM,iBAAiC,QAAQ,YAAY;;;ACP3D,IAAM,aAAa,CAAC,UAA6B;AACtD,MAAI,eAAe,IAAI,KAAK,GAAG;AAC7B,WAAO,WAAW,eAAe,IAAI,KAAK,CAAE;AAAA,EAC9C;AAEA,QAAM,SAAS,SAAS,MAAM,KAAK,KAAK,SAAS,MAAM,KAAK,KAAK,SAAS,MAAM,KAAK;AAErF,MAAI,CAAC,QAAQ;AACX,UAAM,QAAQ,IAAI,MAAM,0BAA0B,KAAK;AACvD,UAAM,oBAAoB,OAAO,UAAU;AAC3C,UAAM;AAAA,EACR;AAEA,SAAO;AACT;AAEO,IAAM,iBAAiB,CAAC,MAA0B;AACvD,SAAO,OAAO,MAAM,WAAW,WAAW,CAAC,IAAI;AACjD;","names":["import_numeric_range","import_numeric_range","import_numeric_range","value"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/color-format-gradient.ts","../src/area-gradient.ts","../src/color.ts","../src/hsb-color.ts","../src/hsl-color.ts","../src/rgb-color.ts","../src/native-color.ts","../src/parse-color.ts"],"sourcesContent":["export { getColorAreaGradient } from \"./area-gradient\"\nexport { Color } from \"./color\"\nexport { normalizeColor, parseColor } from \"./parse-color\"\nexport type { ColorAxes, ColorChannel, ColorChannelRange, ColorFormat, ColorType } from \"./types\"\n","export const generateRGB_R = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_G = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_B = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateHSL_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(dir)]\n }, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(!dir)]\n }, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}))`,\n \"hsl(0, 0%, 50%)\",\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_L = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n backgroundImage: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_B = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}))`,\n \"#000\",\n ].join(\",\"),\n },\n }\n return result\n}\n","import type { Color } from \"./color\"\nimport {\n generateRGB_R,\n generateRGB_G,\n generateRGB_B,\n generateHSL_H,\n generateHSB_H,\n generateHSL_S,\n generateHSB_S,\n generateHSB_B,\n generateHSL_L,\n} from \"./color-format-gradient\"\nimport type { ColorChannel } from \"./types\"\n\ninterface GradientOptions {\n xChannel: ColorChannel\n yChannel: ColorChannel\n dir?: \"rtl\" | \"ltr\"\n}\n\ninterface GradientStyles {\n areaStyles: Record<string, string>\n areaGradientStyles: Record<string, string>\n}\n\nexport function getColorAreaGradient(color: Color, options: GradientOptions): GradientStyles {\n const { xChannel, yChannel, dir: dirProp = \"ltr\" } = options\n\n const { zChannel } = color.getColorAxes({ xChannel, yChannel })\n const zValue = color.getChannelValue(zChannel)\n\n const { minValue: zMin, maxValue: zMax } = color.getChannelRange(zChannel)\n const orientation: [string, string] = [\"top\", dirProp === \"rtl\" ? \"left\" : \"right\"]\n\n let dir = false\n\n let background = { areaStyles: {}, areaGradientStyles: {} }\n\n let alphaValue = (zValue - zMin) / (zMax - zMin)\n let isHSL = color.getFormat() === \"hsla\"\n\n switch (zChannel) {\n case \"red\": {\n dir = xChannel === \"green\"\n background = generateRGB_R(orientation, dir, zValue)\n break\n }\n\n case \"green\": {\n dir = xChannel === \"red\"\n background = generateRGB_G(orientation, dir, zValue)\n break\n }\n\n case \"blue\": {\n dir = xChannel === \"red\"\n background = generateRGB_B(orientation, dir, zValue)\n break\n }\n\n case \"hue\": {\n dir = xChannel !== \"saturation\"\n if (isHSL) {\n background = generateHSL_H(orientation, dir, zValue)\n } else {\n background = generateHSB_H(orientation, dir, zValue)\n }\n break\n }\n\n case \"saturation\": {\n dir = xChannel === \"hue\"\n if (isHSL) {\n background = generateHSL_S(orientation, dir, alphaValue)\n } else {\n background = generateHSB_S(orientation, dir, alphaValue)\n }\n break\n }\n\n case \"brightness\": {\n dir = xChannel === \"hue\"\n background = generateHSB_B(orientation, dir, alphaValue)\n break\n }\n\n case \"lightness\": {\n dir = xChannel === \"hue\"\n background = generateHSL_L(orientation, dir, zValue)\n break\n }\n }\n\n return background\n}\n","import { clampValue, getPercentValue, getValuePercent, snapValueToStep } from \"@zag-js/numeric-range\"\nimport type {\n Color2DAxes,\n ColorAxes,\n ColorChannel,\n ColorChannelRange,\n ColorFormat,\n ColorStringFormat,\n ColorType,\n} from \"./types\"\n\nconst isEqualObject = (a: Record<string, number>, b: Record<string, number>): boolean => {\n if (Object.keys(a).length !== Object.keys(b).length) return false\n for (let key in a) if (a[key] !== b[key]) return false\n return true\n}\n\nexport abstract class Color implements ColorType {\n abstract toFormat(format: ColorFormat): ColorType\n abstract toJSON(): Record<string, number>\n abstract toString(format: ColorStringFormat): string\n abstract clone(): ColorType\n abstract getChannelRange(channel: ColorChannel): ColorChannelRange\n abstract getFormat(): ColorFormat\n abstract getChannels(): [ColorChannel, ColorChannel, ColorChannel]\n abstract formatChannelValue(channel: ColorChannel, locale: string): string\n\n toHexInt(): number {\n return this.toFormat(\"rgba\").toHexInt()\n }\n\n getChannelValue(channel: ColorChannel): number {\n if (channel in this) return this[channel]\n throw new Error(\"Unsupported color channel: \" + channel)\n }\n\n getChannelValuePercent(channel: ColorChannel, valueToCheck?: number): number {\n const value = valueToCheck ?? this.getChannelValue(channel)\n const { minValue, maxValue } = this.getChannelRange(channel)\n return getValuePercent(value, minValue, maxValue)\n }\n\n getChannelPercentValue(channel: ColorChannel, percentToCheck: number): number {\n const { minValue, maxValue, step } = this.getChannelRange(channel)\n const percentValue = getPercentValue(percentToCheck, minValue, maxValue, step)\n return snapValueToStep(percentValue, minValue, maxValue, step)\n }\n\n withChannelValue(channel: ColorChannel, value: number): ColorType {\n const { minValue, maxValue } = this.getChannelRange(channel)\n if (channel in this) {\n let clone = this.clone()\n clone[channel] = clampValue(value, minValue, maxValue)\n return clone\n }\n\n throw new Error(\"Unsupported color channel: \" + channel)\n }\n\n getColorAxes(xyChannels: Color2DAxes): ColorAxes {\n let { xChannel, yChannel } = xyChannels\n let xCh = xChannel || this.getChannels().find((c) => c !== yChannel)\n let yCh = yChannel || this.getChannels().find((c) => c !== xCh)\n let zCh = this.getChannels().find((c) => c !== xCh && c !== yCh)\n return { xChannel: xCh!, yChannel: yCh!, zChannel: zCh! }\n }\n\n incrementChannel(channel: ColorChannel, stepSize: number): ColorType {\n const { minValue, maxValue, step } = this.getChannelRange(channel)\n const value = snapValueToStep(\n clampValue(this.getChannelValue(channel) + stepSize, minValue, maxValue),\n minValue,\n maxValue,\n step,\n )\n return this.withChannelValue(channel, value)\n }\n\n decrementChannel(channel: ColorChannel, stepSize: number): ColorType {\n return this.incrementChannel(channel, -stepSize)\n }\n\n isEqual(color: ColorType): boolean {\n const isSame = isEqualObject(this.toJSON(), color.toJSON())\n return isSame && this.getChannelValue(\"alpha\") === color.getChannelValue(\"alpha\")\n }\n}\n","import { clampValue, mod, toFixedNumber } from \"@zag-js/numeric-range\"\nimport { Color } from \"./color\"\nimport { HSLColor } from \"./hsl-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport type { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from \"./types\"\n\nconst HSB_REGEX =\n /hsb\\(([-+]?\\d+(?:.\\d+)?\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d+(?:.\\d+)?%)\\)|hsba\\(([-+]?\\d+(?:.\\d+)?\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d(.\\d+)?)\\)/\n\nexport class HSBColor extends Color {\n constructor(\n private hue: number,\n private saturation: number,\n private brightness: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string): HSBColor | void {\n let m: RegExpMatchArray | null\n if ((m = value.match(HSB_REGEX))) {\n const [h, s, b, a] = (m[1] ?? m[2]).split(\",\").map((n) => Number(n.trim().replace(\"%\", \"\")))\n return new HSBColor(mod(h, 360), clampValue(s, 0, 100), clampValue(b, 0, 100), clampValue(a ?? 1, 0, 1))\n }\n }\n\n toString(format: ColorStringFormat) {\n switch (format) {\n case \"css\":\n return this.toHSL().toString(\"css\")\n case \"hex\":\n return this.toRGB().toString(\"hex\")\n case \"hexa\":\n return this.toRGB().toString(\"hexa\")\n case \"hsb\":\n return `hsb(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%)`\n case \"hsba\":\n return `hsba(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%, ${\n this.alpha\n })`\n case \"hsl\":\n return this.toHSL().toString(\"hsl\")\n case \"rgb\":\n return this.toRGB().toString(\"rgb\")\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"hsba\":\n return this\n case \"hsla\":\n return this.toHSL()\n case \"rgba\":\n return this.toRGB()\n default:\n throw new Error(\"Unsupported color conversion: hsb -> \" + format)\n }\n }\n\n /**\n * Converts a HSB color to HSL.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL.\n * @returns An HSLColor object.\n */\n private toHSL(): ColorType {\n let saturation = this.saturation / 100\n let brightness = this.brightness / 100\n let lightness = brightness * (1 - saturation / 2)\n saturation = lightness === 0 || lightness === 1 ? 0 : (brightness - lightness) / Math.min(lightness, 1 - lightness)\n\n return new HSLColor(\n toFixedNumber(this.hue, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(lightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n /**\n * Converts a HSV color value to RGB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative.\n * @returns An RGBColor object.\n */\n private toRGB(): ColorType {\n let hue = this.hue\n let saturation = this.saturation / 100\n let brightness = this.brightness / 100\n\n let fn = (n: number, k = (n + hue / 60) % 6) =>\n brightness - saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0)\n\n return new RGBColor(\n Math.round(fn(5) * 255),\n Math.round(fn(3) * 255),\n Math.round(fn(1) * 255),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n clone(): ColorType {\n return new HSBColor(this.hue, this.saturation, this.brightness, this.alpha)\n }\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n switch (channel) {\n case \"hue\":\n return { style: \"unit\", unit: \"degree\", unitDisplay: \"narrow\" }\n case \"saturation\":\n case \"brightness\":\n case \"alpha\":\n return { style: \"percent\" }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n formatChannelValue(channel: ColorChannel, locale: string) {\n let options = this.getChannelFormatOptions(channel)\n let value = this.getChannelValue(channel)\n if (channel === \"saturation\" || channel === \"brightness\") {\n value /= 100\n }\n return new Intl.NumberFormat(locale, options).format(value)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 }\n case \"saturation\":\n case \"brightness\":\n return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n toJSON(): Record<\"h\" | \"s\" | \"b\" | \"a\", number> {\n return { h: this.hue, s: this.saturation, b: this.brightness, a: this.alpha }\n }\n\n getFormat(): ColorFormat {\n return \"hsba\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"hue\", \"saturation\", \"brightness\"]\n\n getChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return HSBColor.colorChannels\n }\n}\n","import { clampValue, mod, toFixedNumber } from \"@zag-js/numeric-range\"\nimport { Color } from \"./color\"\nimport { HSBColor } from \"./hsb-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport type { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from \"./types\"\n\nexport const HSL_REGEX =\n /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+)?)\\)/\n\nexport class HSLColor extends Color {\n constructor(\n private hue: number,\n private saturation: number,\n private lightness: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string): HSLColor | void {\n let m: RegExpMatchArray | null\n if ((m = value.match(HSL_REGEX))) {\n const [h, s, l, a] = (m[1] ?? m[2]).split(\",\").map((n) => Number(n.trim().replace(\"%\", \"\")))\n return new HSLColor(mod(h, 360), clampValue(s, 0, 100), clampValue(l, 0, 100), clampValue(a ?? 1, 0, 1))\n }\n }\n\n toString(format: ColorStringFormat) {\n switch (format) {\n case \"hex\":\n return this.toRGB().toString(\"hex\")\n case \"hexa\":\n return this.toRGB().toString(\"hexa\")\n case \"hsl\":\n return `hsl(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%)`\n case \"css\":\n case \"hsla\":\n return `hsla(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%, ${\n this.alpha\n })`\n case \"hsb\":\n return this.toHSB().toString(\"hsb\")\n case \"rgb\":\n return this.toRGB().toString(\"rgb\")\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"hsla\":\n return this\n case \"hsba\":\n return this.toHSB()\n case \"rgba\":\n return this.toRGB()\n default:\n throw new Error(\"Unsupported color conversion: hsl -> \" + format)\n }\n }\n\n /**\n * Converts a HSL color to HSB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.\n * @returns An HSBColor object.\n */\n private toHSB(): ColorType {\n let saturation = this.saturation / 100\n let lightness = this.lightness / 100\n let brightness = lightness + saturation * Math.min(lightness, 1 - lightness)\n saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness)\n return new HSBColor(\n toFixedNumber(this.hue, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(brightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n /**\n * Converts a HSL color to RGB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.\n * @returns An RGBColor object.\n */\n private toRGB(): ColorType {\n let hue = this.hue\n let saturation = this.saturation / 100\n let lightness = this.lightness / 100\n let a = saturation * Math.min(lightness, 1 - lightness)\n let fn = (n: number, k = (n + hue / 30) % 12) => lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)\n return new RGBColor(\n Math.round(fn(0) * 255),\n Math.round(fn(8) * 255),\n Math.round(fn(4) * 255),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n clone(): ColorType {\n return new HSLColor(this.hue, this.saturation, this.lightness, this.alpha)\n }\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n switch (channel) {\n case \"hue\":\n return { style: \"unit\", unit: \"degree\", unitDisplay: \"narrow\" }\n case \"saturation\":\n case \"lightness\":\n case \"alpha\":\n return { style: \"percent\" }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n formatChannelValue(channel: ColorChannel, locale: string) {\n let options = this.getChannelFormatOptions(channel)\n let value = this.getChannelValue(channel)\n if (channel === \"saturation\" || channel === \"lightness\") {\n value /= 100\n }\n return new Intl.NumberFormat(locale, options).format(value)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 }\n case \"saturation\":\n case \"lightness\":\n return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n toJSON(): Record<\"h\" | \"s\" | \"l\" | \"a\", number> {\n return { h: this.hue, s: this.saturation, l: this.lightness, a: this.alpha }\n }\n\n getFormat(): ColorFormat {\n return \"hsla\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"hue\", \"saturation\", \"lightness\"]\n\n getChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return HSLColor.colorChannels\n }\n}\n","import { clampValue, toFixedNumber } from \"@zag-js/numeric-range\"\nimport { Color } from \"./color\"\nimport { HSBColor } from \"./hsb-color\"\nimport { HSLColor } from \"./hsl-color\"\nimport type { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from \"./types\"\n\nexport class RGBColor extends Color {\n constructor(\n private red: number,\n private green: number,\n private blue: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string) {\n let colors: (number | undefined)[] = []\n\n // matching #rgb, #rgba, #rrggbb, #rrggbbaa\n if (/^#[\\da-f]+$/i.test(value) && [4, 5, 7, 9].includes(value.length)) {\n const values = (value.length < 6 ? value.replace(/[^#]/gi, \"$&$&\") : value).slice(1).split(\"\")\n while (values.length > 0) {\n colors.push(parseInt(values.splice(0, 2).join(\"\"), 16))\n }\n colors[3] = colors[3] !== undefined ? colors[3] / 255 : undefined\n }\n\n // matching rgb(rrr, ggg, bbb), rgba(rrr, ggg, bbb, 0.a)\n const match = value.match(/^rgba?\\((.*)\\)$/)\n\n if (match?.[1]) {\n colors = match[1]\n .split(\",\")\n .map((value) => Number(value.trim()))\n .map((num, i) => clampValue(num, 0, i < 3 ? 255 : 1))\n }\n\n //@ts-expect-error\n return colors.length < 3 ? undefined : new RGBColor(colors[0], colors[1], colors[2], colors[3] ?? 1)\n }\n\n toString(format: ColorStringFormat) {\n switch (format) {\n case \"hex\":\n return (\n \"#\" +\n (\n this.red.toString(16).padStart(2, \"0\") +\n this.green.toString(16).padStart(2, \"0\") +\n this.blue.toString(16).padStart(2, \"0\")\n ).toUpperCase()\n )\n case \"hexa\":\n return (\n \"#\" +\n (\n this.red.toString(16).padStart(2, \"0\") +\n this.green.toString(16).padStart(2, \"0\") +\n this.blue.toString(16).padStart(2, \"0\") +\n Math.round(this.alpha * 255)\n .toString(16)\n .padStart(2, \"0\")\n ).toUpperCase()\n )\n case \"rgb\":\n return `rgb(${this.red}, ${this.green}, ${this.blue})`\n case \"css\":\n case \"rgba\":\n return `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`\n case \"hsl\":\n return this.toHSL().toString(\"hsl\")\n case \"hsb\":\n return this.toHSB().toString(\"hsb\")\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"rgba\":\n return this\n case \"hsba\":\n return this.toHSB()\n case \"hsla\":\n return this.toHSL()\n default:\n throw new Error(\"Unsupported color conversion: rgb -> \" + format)\n }\n }\n\n toHexInt(): number {\n return (this.red << 16) | (this.green << 8) | this.blue\n }\n\n /**\n * Converts an RGB color value to HSB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.\n * @returns An HSBColor object.\n */\n private toHSB(): ColorType {\n const red = this.red / 255\n const green = this.green / 255\n const blue = this.blue / 255\n const min = Math.min(red, green, blue)\n const brightness = Math.max(red, green, blue)\n const chroma = brightness - min\n const saturation = brightness === 0 ? 0 : chroma / brightness\n let hue = 0 // achromatic\n\n if (chroma !== 0) {\n switch (brightness) {\n case red:\n hue = (green - blue) / chroma + (green < blue ? 6 : 0)\n break\n case green:\n hue = (blue - red) / chroma + 2\n break\n case blue:\n hue = (red - green) / chroma + 4\n break\n }\n\n hue /= 6\n }\n\n return new HSBColor(\n toFixedNumber(hue * 360, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(brightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n /**\n * Converts an RGB color value to HSL.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.\n * @returns An HSLColor object.\n */\n private toHSL(): ColorType {\n const red = this.red / 255\n const green = this.green / 255\n const blue = this.blue / 255\n const min = Math.min(red, green, blue)\n const max = Math.max(red, green, blue)\n const lightness = (max + min) / 2\n const chroma = max - min\n\n let hue = -1\n let saturation = -1\n\n if (chroma === 0) {\n hue = saturation = 0 // achromatic\n } else {\n saturation = chroma / (lightness < 0.5 ? max + min : 2 - max - min)\n\n switch (max) {\n case red:\n hue = (green - blue) / chroma + (green < blue ? 6 : 0)\n break\n case green:\n hue = (blue - red) / chroma + 2\n break\n case blue:\n hue = (red - green) / chroma + 4\n break\n }\n\n hue /= 6\n }\n\n return new HSLColor(\n toFixedNumber(hue * 360, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(lightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n clone(): ColorType {\n return new RGBColor(this.red, this.green, this.blue, this.alpha)\n }\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n switch (channel) {\n case \"red\":\n case \"green\":\n case \"blue\":\n return { style: \"decimal\" }\n case \"alpha\":\n return { style: \"percent\" }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n formatChannelValue(channel: ColorChannel, locale: string) {\n let options = this.getChannelFormatOptions(channel)\n let value = this.getChannelValue(channel)\n return new Intl.NumberFormat(locale, options).format(value)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"red\":\n case \"green\":\n case \"blue\":\n return { minValue: 0x0, maxValue: 0xff, step: 0x1, pageSize: 0x11 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n toJSON(): Record<\"r\" | \"g\" | \"b\" | \"a\", number> {\n return { r: this.red, g: this.green, b: this.blue, a: this.alpha }\n }\n\n getFormat(): ColorFormat {\n return \"rgba\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"red\", \"green\", \"blue\"]\n\n getChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return RGBColor.colorChannels\n }\n}\n","const nativeColors /* @__PURE__ */ =\n \"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,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\"\n\nconst makeMap = (str: string) => {\n const map = new Map<string, string>()\n const list = str.split(\",\")\n for (let i = 0; i < list.length; i++) {\n const [key, val] = list[i].split(\":\")\n map.set(key, `#${val}`)\n }\n return map\n}\n\nexport const nativeColorMap /* @__PURE__ */ = makeMap(nativeColors)\n","import { HSBColor } from \"./hsb-color\"\nimport { HSLColor } from \"./hsl-color\"\nimport { nativeColorMap } from \"./native-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport type { ColorType } from \"./types\"\n\nexport const parseColor = (value: string): ColorType => {\n if (nativeColorMap.has(value)) {\n return parseColor(nativeColorMap.get(value)!)\n }\n\n const result = RGBColor.parse(value) || HSBColor.parse(value) || HSLColor.parse(value)\n\n if (!result) {\n const error = new Error(\"Invalid color value: \" + value)\n Error.captureStackTrace?.(error, parseColor)\n throw error\n }\n\n return result\n}\n\nexport const normalizeColor = (v: string | ColorType) => {\n return typeof v === \"string\" ? parseColor(v) : v\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gBAAgB,CAAC,aAA+B,KAAc,WAAmB;AAC5F,QAAM,YAAY,sBAAsB,YAAY,OAAO,CAAC,GAAG,CAAC,CAAC;AACjE,QAAM,SAAS;AAAA,IACb,YAAY;AAAA,MACV,iBAAiB,sBAAsB,YAAY,OAAO,GAAG,CAAC,CAAC,QAAQ,MAAM,aAAa,MAAM;AAAA,IAClG;AAAA,IACA,oBAAoB;AAAA,MAClB,iBAAiB,sBAAsB,YAAY,OAAO,GAAG,CAAC,CAAC,QAAQ,MAAM,eAAe,MAAM;AAAA,MAClG,iBAAiB;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEO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ACX,UAAM,QAAQ,IAAI,MAAM,0BAA0B,KAAK;AACvD,UAAM,oBAAoB,OAAO,UAAU;AAC3C,UAAM;AAAA,EACR;AAEA,SAAO;AACT;AAEO,IAAM,iBAAiB,CAAC,MAA0B;AACvD,SAAO,OAAO,MAAM,WAAW,WAAW,CAAC,IAAI;AACjD;","names":["import_numeric_range","import_numeric_range","import_numeric_range","value"]}
|
package/dist/index.mjs
CHANGED
|
@@ -384,6 +384,23 @@ var _RGBColor = class _RGBColor extends Color {
|
|
|
384
384
|
clone() {
|
|
385
385
|
return new _RGBColor(this.red, this.green, this.blue, this.alpha);
|
|
386
386
|
}
|
|
387
|
+
getChannelFormatOptions(channel) {
|
|
388
|
+
switch (channel) {
|
|
389
|
+
case "red":
|
|
390
|
+
case "green":
|
|
391
|
+
case "blue":
|
|
392
|
+
return { style: "decimal" };
|
|
393
|
+
case "alpha":
|
|
394
|
+
return { style: "percent" };
|
|
395
|
+
default:
|
|
396
|
+
throw new Error("Unknown color channel: " + channel);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
formatChannelValue(channel, locale) {
|
|
400
|
+
let options = this.getChannelFormatOptions(channel);
|
|
401
|
+
let value = this.getChannelValue(channel);
|
|
402
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
403
|
+
}
|
|
387
404
|
getChannelRange(channel) {
|
|
388
405
|
switch (channel) {
|
|
389
406
|
case "red":
|
|
@@ -495,6 +512,26 @@ var _HSLColor = class _HSLColor extends Color {
|
|
|
495
512
|
clone() {
|
|
496
513
|
return new _HSLColor(this.hue, this.saturation, this.lightness, this.alpha);
|
|
497
514
|
}
|
|
515
|
+
getChannelFormatOptions(channel) {
|
|
516
|
+
switch (channel) {
|
|
517
|
+
case "hue":
|
|
518
|
+
return { style: "unit", unit: "degree", unitDisplay: "narrow" };
|
|
519
|
+
case "saturation":
|
|
520
|
+
case "lightness":
|
|
521
|
+
case "alpha":
|
|
522
|
+
return { style: "percent" };
|
|
523
|
+
default:
|
|
524
|
+
throw new Error("Unknown color channel: " + channel);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
formatChannelValue(channel, locale) {
|
|
528
|
+
let options = this.getChannelFormatOptions(channel);
|
|
529
|
+
let value = this.getChannelValue(channel);
|
|
530
|
+
if (channel === "saturation" || channel === "lightness") {
|
|
531
|
+
value /= 100;
|
|
532
|
+
}
|
|
533
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
534
|
+
}
|
|
498
535
|
getChannelRange(channel) {
|
|
499
536
|
switch (channel) {
|
|
500
537
|
case "hue":
|
|
@@ -607,6 +644,26 @@ var _HSBColor = class _HSBColor extends Color {
|
|
|
607
644
|
clone() {
|
|
608
645
|
return new _HSBColor(this.hue, this.saturation, this.brightness, this.alpha);
|
|
609
646
|
}
|
|
647
|
+
getChannelFormatOptions(channel) {
|
|
648
|
+
switch (channel) {
|
|
649
|
+
case "hue":
|
|
650
|
+
return { style: "unit", unit: "degree", unitDisplay: "narrow" };
|
|
651
|
+
case "saturation":
|
|
652
|
+
case "brightness":
|
|
653
|
+
case "alpha":
|
|
654
|
+
return { style: "percent" };
|
|
655
|
+
default:
|
|
656
|
+
throw new Error("Unknown color channel: " + channel);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
formatChannelValue(channel, locale) {
|
|
660
|
+
let options = this.getChannelFormatOptions(channel);
|
|
661
|
+
let value = this.getChannelValue(channel);
|
|
662
|
+
if (channel === "saturation" || channel === "brightness") {
|
|
663
|
+
value /= 100;
|
|
664
|
+
}
|
|
665
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
666
|
+
}
|
|
610
667
|
getChannelRange(channel) {
|
|
611
668
|
switch (channel) {
|
|
612
669
|
case "hue":
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/color-format-gradient.ts","../src/area-gradient.ts","../src/color.ts","../src/hsb-color.ts","../src/hsl-color.ts","../src/rgb-color.ts","../src/native-color.ts","../src/parse-color.ts"],"sourcesContent":["export const generateRGB_R = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_G = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_B = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateHSL_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(dir)]\n }, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(!dir)]\n }, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}))`,\n \"hsl(0, 0%, 50%)\",\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_L = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n backgroundImage: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_B = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}))`,\n \"#000\",\n ].join(\",\"),\n },\n }\n return result\n}\n","import type { Color } from \"./color\"\nimport {\n generateRGB_R,\n generateRGB_G,\n generateRGB_B,\n generateHSL_H,\n generateHSB_H,\n generateHSL_S,\n generateHSB_S,\n generateHSB_B,\n generateHSL_L,\n} from \"./color-format-gradient\"\nimport type { ColorChannel } from \"./types\"\n\ninterface GradientOptions {\n xChannel: ColorChannel\n yChannel: ColorChannel\n dir?: \"rtl\" | \"ltr\"\n}\n\ninterface GradientStyles {\n areaStyles: Record<string, string>\n areaGradientStyles: Record<string, string>\n}\n\nexport function getColorAreaGradient(color: Color, options: GradientOptions): GradientStyles {\n const { xChannel, yChannel, dir: dirProp = \"ltr\" } = options\n\n const { zChannel } = color.getColorAxes({ xChannel, yChannel })\n const zValue = color.getChannelValue(zChannel)\n\n const { minValue: zMin, maxValue: zMax } = color.getChannelRange(zChannel)\n const orientation: [string, string] = [\"top\", dirProp === \"rtl\" ? \"left\" : \"right\"]\n\n let dir = false\n\n let background = { areaStyles: {}, areaGradientStyles: {} }\n\n let alphaValue = (zValue - zMin) / (zMax - zMin)\n let isHSL = color.getFormat() === \"hsla\"\n\n switch (zChannel) {\n case \"red\": {\n dir = xChannel === \"green\"\n background = generateRGB_R(orientation, dir, zValue)\n break\n }\n\n case \"green\": {\n dir = xChannel === \"red\"\n background = generateRGB_G(orientation, dir, zValue)\n break\n }\n\n case \"blue\": {\n dir = xChannel === \"red\"\n background = generateRGB_B(orientation, dir, zValue)\n break\n }\n\n case \"hue\": {\n dir = xChannel !== \"saturation\"\n if (isHSL) {\n background = generateHSL_H(orientation, dir, zValue)\n } else {\n background = generateHSB_H(orientation, dir, zValue)\n }\n break\n }\n\n case \"saturation\": {\n dir = xChannel === \"hue\"\n if (isHSL) {\n background = generateHSL_S(orientation, dir, alphaValue)\n } else {\n background = generateHSB_S(orientation, dir, alphaValue)\n }\n break\n }\n\n case \"brightness\": {\n dir = xChannel === \"hue\"\n background = generateHSB_B(orientation, dir, alphaValue)\n break\n }\n\n case \"lightness\": {\n dir = xChannel === \"hue\"\n background = generateHSL_L(orientation, dir, zValue)\n break\n }\n }\n\n return background\n}\n","import { clampValue, getPercentValue, getValuePercent, snapValueToStep } from \"@zag-js/numeric-range\"\nimport type {\n Color2DAxes,\n ColorAxes,\n ColorChannel,\n ColorChannelRange,\n ColorFormat,\n ColorStringFormat,\n ColorType,\n} from \"./types\"\n\nconst isEqualObject = (a: Record<string, number>, b: Record<string, number>): boolean => {\n if (Object.keys(a).length !== Object.keys(b).length) return false\n for (let key in a) if (a[key] !== b[key]) return false\n return true\n}\n\nexport abstract class Color implements ColorType {\n abstract toFormat(format: ColorFormat): ColorType\n abstract toJSON(): Record<string, number>\n abstract toString(format: ColorStringFormat): string\n abstract clone(): ColorType\n abstract getChannelRange(channel: ColorChannel): ColorChannelRange\n abstract getFormat(): ColorFormat\n abstract getChannels(): [ColorChannel, ColorChannel, ColorChannel]\n\n toHexInt(): number {\n return this.toFormat(\"rgba\").toHexInt()\n }\n\n getChannelValue(channel: ColorChannel): number {\n if (channel in this) return this[channel]\n throw new Error(\"Unsupported color channel: \" + channel)\n }\n\n getChannelValuePercent(channel: ColorChannel, valueToCheck?: number): number {\n const value = valueToCheck ?? this.getChannelValue(channel)\n const { minValue, maxValue } = this.getChannelRange(channel)\n return getValuePercent(value, minValue, maxValue)\n }\n\n getChannelPercentValue(channel: ColorChannel, percentToCheck: number): number {\n const { minValue, maxValue, step } = this.getChannelRange(channel)\n const percentValue = getPercentValue(percentToCheck, minValue, maxValue, step)\n return snapValueToStep(percentValue, minValue, maxValue, step)\n }\n\n withChannelValue(channel: ColorChannel, value: number): ColorType {\n const { minValue, maxValue } = this.getChannelRange(channel)\n if (channel in this) {\n let clone = this.clone()\n clone[channel] = clampValue(value, minValue, maxValue)\n return clone\n }\n\n throw new Error(\"Unsupported color channel: \" + channel)\n }\n\n getColorAxes(xyChannels: Color2DAxes): ColorAxes {\n let { xChannel, yChannel } = xyChannels\n let xCh = xChannel || this.getChannels().find((c) => c !== yChannel)\n let yCh = yChannel || this.getChannels().find((c) => c !== xCh)\n let zCh = this.getChannels().find((c) => c !== xCh && c !== yCh)\n return { xChannel: xCh!, yChannel: yCh!, zChannel: zCh! }\n }\n\n incrementChannel(channel: ColorChannel, stepSize: number): ColorType {\n const { minValue, maxValue, step } = this.getChannelRange(channel)\n const value = snapValueToStep(\n clampValue(this.getChannelValue(channel) + stepSize, minValue, maxValue),\n minValue,\n maxValue,\n step,\n )\n return this.withChannelValue(channel, value)\n }\n\n decrementChannel(channel: ColorChannel, stepSize: number): ColorType {\n return this.incrementChannel(channel, -stepSize)\n }\n\n isEqual(color: ColorType): boolean {\n const isSame = isEqualObject(this.toJSON(), color.toJSON())\n return isSame && this.getChannelValue(\"alpha\") === color.getChannelValue(\"alpha\")\n }\n}\n","import { clampValue, mod, toFixedNumber } from \"@zag-js/numeric-range\"\nimport { Color } from \"./color\"\nimport { HSLColor } from \"./hsl-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport type { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from \"./types\"\n\nconst HSB_REGEX =\n /hsb\\(([-+]?\\d+(?:.\\d+)?\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d+(?:.\\d+)?%)\\)|hsba\\(([-+]?\\d+(?:.\\d+)?\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d(.\\d+)?)\\)/\n\nexport class HSBColor extends Color {\n constructor(\n private hue: number,\n private saturation: number,\n private brightness: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string): HSBColor | void {\n let m: RegExpMatchArray | null\n if ((m = value.match(HSB_REGEX))) {\n const [h, s, b, a] = (m[1] ?? m[2]).split(\",\").map((n) => Number(n.trim().replace(\"%\", \"\")))\n return new HSBColor(mod(h, 360), clampValue(s, 0, 100), clampValue(b, 0, 100), clampValue(a ?? 1, 0, 1))\n }\n }\n\n toString(format: ColorStringFormat) {\n switch (format) {\n case \"css\":\n return this.toHSL().toString(\"css\")\n case \"hex\":\n return this.toRGB().toString(\"hex\")\n case \"hexa\":\n return this.toRGB().toString(\"hexa\")\n case \"hsb\":\n return `hsb(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%)`\n case \"hsba\":\n return `hsba(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%, ${\n this.alpha\n })`\n case \"hsl\":\n return this.toHSL().toString(\"hsl\")\n case \"rgb\":\n return this.toRGB().toString(\"rgb\")\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"hsba\":\n return this\n case \"hsla\":\n return this.toHSL()\n case \"rgba\":\n return this.toRGB()\n default:\n throw new Error(\"Unsupported color conversion: hsb -> \" + format)\n }\n }\n\n /**\n * Converts a HSB color to HSL.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL.\n * @returns An HSLColor object.\n */\n private toHSL(): ColorType {\n let saturation = this.saturation / 100\n let brightness = this.brightness / 100\n let lightness = brightness * (1 - saturation / 2)\n saturation = lightness === 0 || lightness === 1 ? 0 : (brightness - lightness) / Math.min(lightness, 1 - lightness)\n\n return new HSLColor(\n toFixedNumber(this.hue, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(lightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n /**\n * Converts a HSV color value to RGB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative.\n * @returns An RGBColor object.\n */\n private toRGB(): ColorType {\n let hue = this.hue\n let saturation = this.saturation / 100\n let brightness = this.brightness / 100\n\n let fn = (n: number, k = (n + hue / 60) % 6) =>\n brightness - saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0)\n\n return new RGBColor(\n Math.round(fn(5) * 255),\n Math.round(fn(3) * 255),\n Math.round(fn(1) * 255),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n clone(): ColorType {\n return new HSBColor(this.hue, this.saturation, this.brightness, this.alpha)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 }\n case \"saturation\":\n case \"brightness\":\n return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n toJSON(): Record<\"h\" | \"s\" | \"b\" | \"a\", number> {\n return { h: this.hue, s: this.saturation, b: this.brightness, a: this.alpha }\n }\n\n getFormat(): ColorFormat {\n return \"hsba\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"hue\", \"saturation\", \"brightness\"]\n\n getChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return HSBColor.colorChannels\n }\n}\n","import { clampValue, mod, toFixedNumber } from \"@zag-js/numeric-range\"\nimport { Color } from \"./color\"\nimport { HSBColor } from \"./hsb-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport type { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from \"./types\"\n\nexport const HSL_REGEX =\n /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+)?)\\)/\n\nexport class HSLColor extends Color {\n constructor(\n private hue: number,\n private saturation: number,\n private lightness: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string): HSLColor | void {\n let m: RegExpMatchArray | null\n if ((m = value.match(HSL_REGEX))) {\n const [h, s, l, a] = (m[1] ?? m[2]).split(\",\").map((n) => Number(n.trim().replace(\"%\", \"\")))\n return new HSLColor(mod(h, 360), clampValue(s, 0, 100), clampValue(l, 0, 100), clampValue(a ?? 1, 0, 1))\n }\n }\n\n toString(format: ColorStringFormat) {\n switch (format) {\n case \"hex\":\n return this.toRGB().toString(\"hex\")\n case \"hexa\":\n return this.toRGB().toString(\"hexa\")\n case \"hsl\":\n return `hsl(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%)`\n case \"css\":\n case \"hsla\":\n return `hsla(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%, ${\n this.alpha\n })`\n case \"hsb\":\n return this.toHSB().toString(\"hsb\")\n case \"rgb\":\n return this.toRGB().toString(\"rgb\")\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"hsla\":\n return this\n case \"hsba\":\n return this.toHSB()\n case \"rgba\":\n return this.toRGB()\n default:\n throw new Error(\"Unsupported color conversion: hsl -> \" + format)\n }\n }\n\n /**\n * Converts a HSL color to HSB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.\n * @returns An HSBColor object.\n */\n private toHSB(): ColorType {\n let saturation = this.saturation / 100\n let lightness = this.lightness / 100\n let brightness = lightness + saturation * Math.min(lightness, 1 - lightness)\n saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness)\n return new HSBColor(\n toFixedNumber(this.hue, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(brightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n /**\n * Converts a HSL color to RGB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.\n * @returns An RGBColor object.\n */\n private toRGB(): ColorType {\n let hue = this.hue\n let saturation = this.saturation / 100\n let lightness = this.lightness / 100\n let a = saturation * Math.min(lightness, 1 - lightness)\n let fn = (n: number, k = (n + hue / 30) % 12) => lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)\n return new RGBColor(\n Math.round(fn(0) * 255),\n Math.round(fn(8) * 255),\n Math.round(fn(4) * 255),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n clone(): ColorType {\n return new HSLColor(this.hue, this.saturation, this.lightness, this.alpha)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 }\n case \"saturation\":\n case \"lightness\":\n return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n toJSON(): Record<\"h\" | \"s\" | \"l\" | \"a\", number> {\n return { h: this.hue, s: this.saturation, l: this.lightness, a: this.alpha }\n }\n\n getFormat(): ColorFormat {\n return \"hsla\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"hue\", \"saturation\", \"lightness\"]\n\n getChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return HSLColor.colorChannels\n }\n}\n","import { clampValue, toFixedNumber } from \"@zag-js/numeric-range\"\nimport { Color } from \"./color\"\nimport { HSBColor } from \"./hsb-color\"\nimport { HSLColor } from \"./hsl-color\"\nimport type { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from \"./types\"\n\nexport class RGBColor extends Color {\n constructor(\n private red: number,\n private green: number,\n private blue: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string) {\n let colors: (number | undefined)[] = []\n\n // matching #rgb, #rgba, #rrggbb, #rrggbbaa\n if (/^#[\\da-f]+$/i.test(value) && [4, 5, 7, 9].includes(value.length)) {\n const values = (value.length < 6 ? value.replace(/[^#]/gi, \"$&$&\") : value).slice(1).split(\"\")\n while (values.length > 0) {\n colors.push(parseInt(values.splice(0, 2).join(\"\"), 16))\n }\n colors[3] = colors[3] !== undefined ? colors[3] / 255 : undefined\n }\n\n // matching rgb(rrr, ggg, bbb), rgba(rrr, ggg, bbb, 0.a)\n const match = value.match(/^rgba?\\((.*)\\)$/)\n\n if (match?.[1]) {\n colors = match[1]\n .split(\",\")\n .map((value) => Number(value.trim()))\n .map((num, i) => clampValue(num, 0, i < 3 ? 255 : 1))\n }\n\n //@ts-expect-error\n return colors.length < 3 ? undefined : new RGBColor(colors[0], colors[1], colors[2], colors[3] ?? 1)\n }\n\n toString(format: ColorStringFormat) {\n switch (format) {\n case \"hex\":\n return (\n \"#\" +\n (\n this.red.toString(16).padStart(2, \"0\") +\n this.green.toString(16).padStart(2, \"0\") +\n this.blue.toString(16).padStart(2, \"0\")\n ).toUpperCase()\n )\n case \"hexa\":\n return (\n \"#\" +\n (\n this.red.toString(16).padStart(2, \"0\") +\n this.green.toString(16).padStart(2, \"0\") +\n this.blue.toString(16).padStart(2, \"0\") +\n Math.round(this.alpha * 255)\n .toString(16)\n .padStart(2, \"0\")\n ).toUpperCase()\n )\n case \"rgb\":\n return `rgb(${this.red}, ${this.green}, ${this.blue})`\n case \"css\":\n case \"rgba\":\n return `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`\n case \"hsl\":\n return this.toHSL().toString(\"hsl\")\n case \"hsb\":\n return this.toHSB().toString(\"hsb\")\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"rgba\":\n return this\n case \"hsba\":\n return this.toHSB()\n case \"hsla\":\n return this.toHSL()\n default:\n throw new Error(\"Unsupported color conversion: rgb -> \" + format)\n }\n }\n\n toHexInt(): number {\n return (this.red << 16) | (this.green << 8) | this.blue\n }\n\n /**\n * Converts an RGB color value to HSB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.\n * @returns An HSBColor object.\n */\n private toHSB(): ColorType {\n const red = this.red / 255\n const green = this.green / 255\n const blue = this.blue / 255\n const min = Math.min(red, green, blue)\n const brightness = Math.max(red, green, blue)\n const chroma = brightness - min\n const saturation = brightness === 0 ? 0 : chroma / brightness\n let hue = 0 // achromatic\n\n if (chroma !== 0) {\n switch (brightness) {\n case red:\n hue = (green - blue) / chroma + (green < blue ? 6 : 0)\n break\n case green:\n hue = (blue - red) / chroma + 2\n break\n case blue:\n hue = (red - green) / chroma + 4\n break\n }\n\n hue /= 6\n }\n\n return new HSBColor(\n toFixedNumber(hue * 360, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(brightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n /**\n * Converts an RGB color value to HSL.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.\n * @returns An HSLColor object.\n */\n private toHSL(): ColorType {\n const red = this.red / 255\n const green = this.green / 255\n const blue = this.blue / 255\n const min = Math.min(red, green, blue)\n const max = Math.max(red, green, blue)\n const lightness = (max + min) / 2\n const chroma = max - min\n\n let hue = -1\n let saturation = -1\n\n if (chroma === 0) {\n hue = saturation = 0 // achromatic\n } else {\n saturation = chroma / (lightness < 0.5 ? max + min : 2 - max - min)\n\n switch (max) {\n case red:\n hue = (green - blue) / chroma + (green < blue ? 6 : 0)\n break\n case green:\n hue = (blue - red) / chroma + 2\n break\n case blue:\n hue = (red - green) / chroma + 4\n break\n }\n\n hue /= 6\n }\n\n return new HSLColor(\n toFixedNumber(hue * 360, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(lightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n clone(): ColorType {\n return new RGBColor(this.red, this.green, this.blue, this.alpha)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"red\":\n case \"green\":\n case \"blue\":\n return { minValue: 0x0, maxValue: 0xff, step: 0x1, pageSize: 0x11 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n toJSON(): Record<\"r\" | \"g\" | \"b\" | \"a\", number> {\n return { r: this.red, g: this.green, b: this.blue, a: this.alpha }\n }\n\n getFormat(): ColorFormat {\n return \"rgba\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"red\", \"green\", \"blue\"]\n\n getChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return RGBColor.colorChannels\n }\n}\n","const nativeColors /* @__PURE__ */ =\n \"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,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\"\n\nconst makeMap = (str: string) => {\n const map = new Map<string, string>()\n const list = str.split(\",\")\n for (let i = 0; i < list.length; i++) {\n const [key, val] = list[i].split(\":\")\n map.set(key, `#${val}`)\n }\n return map\n}\n\nexport const nativeColorMap /* @__PURE__ */ = makeMap(nativeColors)\n","import { HSBColor } from \"./hsb-color\"\nimport { HSLColor } from \"./hsl-color\"\nimport { nativeColorMap } from \"./native-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport type { ColorType } from \"./types\"\n\nexport const parseColor = (value: string): ColorType => {\n if (nativeColorMap.has(value)) {\n return parseColor(nativeColorMap.get(value)!)\n }\n\n const result = RGBColor.parse(value) || HSBColor.parse(value) || HSLColor.parse(value)\n\n if (!result) {\n const error = new Error(\"Invalid color value: \" + value)\n Error.captureStackTrace?.(error, parseColor)\n throw error\n }\n\n return result\n}\n\nexport const normalizeColor = (v: string | ColorType) => {\n return typeof v === \"string\" ? parseColor(v) : v\n}\n"],"mappings":";;;;;AAAO,IAAM,gBAAgB,CAAC,aAA+B,KAAc,WAAmB;AAC5F,QAAM,YAAY,sBAAsB,YAAY,OAAO,CAAC,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;AAC7B,WAAO,WAAW,eAAe,IAAI,KAAK,CAAE;AAAA,EAC9C;AAEA,QAAM,SAAS,SAAS,MAAM,KAAK,KAAK,SAAS,MAAM,KAAK,KAAK,SAAS,MAAM,KAAK;AAErF,MAAI,CAAC,QAAQ;AACX,UAAM,QAAQ,IAAI,MAAM,0BAA0B,KAAK;AACvD,UAAM,oBAAoB,OAAO,UAAU;AAC3C,UAAM;AAAA,EACR;AAEA,SAAO;AACT;AAEO,IAAM,iBAAiB,CAAC,MAA0B;AACvD,SAAO,OAAO,MAAM,WAAW,WAAW,CAAC,IAAI;AACjD;","names":["clampValue","mod","toFixedNumber","clampValue","toFixedNumber","clampValue","value","clampValue","clampValue","toFixedNumber","mod","clampValue","toFixedNumber"]}
|
|
1
|
+
{"version":3,"sources":["../src/color-format-gradient.ts","../src/area-gradient.ts","../src/color.ts","../src/hsb-color.ts","../src/hsl-color.ts","../src/rgb-color.ts","../src/native-color.ts","../src/parse-color.ts"],"sourcesContent":["export const generateRGB_R = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_G = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_B = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateHSL_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(dir)]\n }, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(!dir)]\n }, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}))`,\n \"hsl(0, 0%, 50%)\",\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_L = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n backgroundImage: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_B = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },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}))`,\n \"#000\",\n ].join(\",\"),\n },\n }\n return result\n}\n","import type { Color } from \"./color\"\nimport {\n generateRGB_R,\n generateRGB_G,\n generateRGB_B,\n generateHSL_H,\n generateHSB_H,\n generateHSL_S,\n generateHSB_S,\n generateHSB_B,\n generateHSL_L,\n} from \"./color-format-gradient\"\nimport type { ColorChannel } from \"./types\"\n\ninterface GradientOptions {\n xChannel: ColorChannel\n yChannel: ColorChannel\n dir?: \"rtl\" | \"ltr\"\n}\n\ninterface GradientStyles {\n areaStyles: Record<string, string>\n areaGradientStyles: Record<string, string>\n}\n\nexport function getColorAreaGradient(color: Color, options: GradientOptions): GradientStyles {\n const { xChannel, yChannel, dir: dirProp = \"ltr\" } = options\n\n const { zChannel } = color.getColorAxes({ xChannel, yChannel })\n const zValue = color.getChannelValue(zChannel)\n\n const { minValue: zMin, maxValue: zMax } = color.getChannelRange(zChannel)\n const orientation: [string, string] = [\"top\", dirProp === \"rtl\" ? \"left\" : \"right\"]\n\n let dir = false\n\n let background = { areaStyles: {}, areaGradientStyles: {} }\n\n let alphaValue = (zValue - zMin) / (zMax - zMin)\n let isHSL = color.getFormat() === \"hsla\"\n\n switch (zChannel) {\n case \"red\": {\n dir = xChannel === \"green\"\n background = generateRGB_R(orientation, dir, zValue)\n break\n }\n\n case \"green\": {\n dir = xChannel === \"red\"\n background = generateRGB_G(orientation, dir, zValue)\n break\n }\n\n case \"blue\": {\n dir = xChannel === \"red\"\n background = generateRGB_B(orientation, dir, zValue)\n break\n }\n\n case \"hue\": {\n dir = xChannel !== \"saturation\"\n if (isHSL) {\n background = generateHSL_H(orientation, dir, zValue)\n } else {\n background = generateHSB_H(orientation, dir, zValue)\n }\n break\n }\n\n case \"saturation\": {\n dir = xChannel === \"hue\"\n if (isHSL) {\n background = generateHSL_S(orientation, dir, alphaValue)\n } else {\n background = generateHSB_S(orientation, dir, alphaValue)\n }\n break\n }\n\n case \"brightness\": {\n dir = xChannel === \"hue\"\n background = generateHSB_B(orientation, dir, alphaValue)\n break\n }\n\n case \"lightness\": {\n dir = xChannel === \"hue\"\n background = generateHSL_L(orientation, dir, zValue)\n break\n }\n }\n\n return background\n}\n","import { clampValue, getPercentValue, getValuePercent, snapValueToStep } from \"@zag-js/numeric-range\"\nimport type {\n Color2DAxes,\n ColorAxes,\n ColorChannel,\n ColorChannelRange,\n ColorFormat,\n ColorStringFormat,\n ColorType,\n} from \"./types\"\n\nconst isEqualObject = (a: Record<string, number>, b: Record<string, number>): boolean => {\n if (Object.keys(a).length !== Object.keys(b).length) return false\n for (let key in a) if (a[key] !== b[key]) return false\n return true\n}\n\nexport abstract class Color implements ColorType {\n abstract toFormat(format: ColorFormat): ColorType\n abstract toJSON(): Record<string, number>\n abstract toString(format: ColorStringFormat): string\n abstract clone(): ColorType\n abstract getChannelRange(channel: ColorChannel): ColorChannelRange\n abstract getFormat(): ColorFormat\n abstract getChannels(): [ColorChannel, ColorChannel, ColorChannel]\n abstract formatChannelValue(channel: ColorChannel, locale: string): string\n\n toHexInt(): number {\n return this.toFormat(\"rgba\").toHexInt()\n }\n\n getChannelValue(channel: ColorChannel): number {\n if (channel in this) return this[channel]\n throw new Error(\"Unsupported color channel: \" + channel)\n }\n\n getChannelValuePercent(channel: ColorChannel, valueToCheck?: number): number {\n const value = valueToCheck ?? this.getChannelValue(channel)\n const { minValue, maxValue } = this.getChannelRange(channel)\n return getValuePercent(value, minValue, maxValue)\n }\n\n getChannelPercentValue(channel: ColorChannel, percentToCheck: number): number {\n const { minValue, maxValue, step } = this.getChannelRange(channel)\n const percentValue = getPercentValue(percentToCheck, minValue, maxValue, step)\n return snapValueToStep(percentValue, minValue, maxValue, step)\n }\n\n withChannelValue(channel: ColorChannel, value: number): ColorType {\n const { minValue, maxValue } = this.getChannelRange(channel)\n if (channel in this) {\n let clone = this.clone()\n clone[channel] = clampValue(value, minValue, maxValue)\n return clone\n }\n\n throw new Error(\"Unsupported color channel: \" + channel)\n }\n\n getColorAxes(xyChannels: Color2DAxes): ColorAxes {\n let { xChannel, yChannel } = xyChannels\n let xCh = xChannel || this.getChannels().find((c) => c !== yChannel)\n let yCh = yChannel || this.getChannels().find((c) => c !== xCh)\n let zCh = this.getChannels().find((c) => c !== xCh && c !== yCh)\n return { xChannel: xCh!, yChannel: yCh!, zChannel: zCh! }\n }\n\n incrementChannel(channel: ColorChannel, stepSize: number): ColorType {\n const { minValue, maxValue, step } = this.getChannelRange(channel)\n const value = snapValueToStep(\n clampValue(this.getChannelValue(channel) + stepSize, minValue, maxValue),\n minValue,\n maxValue,\n step,\n )\n return this.withChannelValue(channel, value)\n }\n\n decrementChannel(channel: ColorChannel, stepSize: number): ColorType {\n return this.incrementChannel(channel, -stepSize)\n }\n\n isEqual(color: ColorType): boolean {\n const isSame = isEqualObject(this.toJSON(), color.toJSON())\n return isSame && this.getChannelValue(\"alpha\") === color.getChannelValue(\"alpha\")\n }\n}\n","import { clampValue, mod, toFixedNumber } from \"@zag-js/numeric-range\"\nimport { Color } from \"./color\"\nimport { HSLColor } from \"./hsl-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport type { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from \"./types\"\n\nconst HSB_REGEX =\n /hsb\\(([-+]?\\d+(?:.\\d+)?\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d+(?:.\\d+)?%)\\)|hsba\\(([-+]?\\d+(?:.\\d+)?\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d(.\\d+)?)\\)/\n\nexport class HSBColor extends Color {\n constructor(\n private hue: number,\n private saturation: number,\n private brightness: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string): HSBColor | void {\n let m: RegExpMatchArray | null\n if ((m = value.match(HSB_REGEX))) {\n const [h, s, b, a] = (m[1] ?? m[2]).split(\",\").map((n) => Number(n.trim().replace(\"%\", \"\")))\n return new HSBColor(mod(h, 360), clampValue(s, 0, 100), clampValue(b, 0, 100), clampValue(a ?? 1, 0, 1))\n }\n }\n\n toString(format: ColorStringFormat) {\n switch (format) {\n case \"css\":\n return this.toHSL().toString(\"css\")\n case \"hex\":\n return this.toRGB().toString(\"hex\")\n case \"hexa\":\n return this.toRGB().toString(\"hexa\")\n case \"hsb\":\n return `hsb(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%)`\n case \"hsba\":\n return `hsba(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%, ${\n this.alpha\n })`\n case \"hsl\":\n return this.toHSL().toString(\"hsl\")\n case \"rgb\":\n return this.toRGB().toString(\"rgb\")\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"hsba\":\n return this\n case \"hsla\":\n return this.toHSL()\n case \"rgba\":\n return this.toRGB()\n default:\n throw new Error(\"Unsupported color conversion: hsb -> \" + format)\n }\n }\n\n /**\n * Converts a HSB color to HSL.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL.\n * @returns An HSLColor object.\n */\n private toHSL(): ColorType {\n let saturation = this.saturation / 100\n let brightness = this.brightness / 100\n let lightness = brightness * (1 - saturation / 2)\n saturation = lightness === 0 || lightness === 1 ? 0 : (brightness - lightness) / Math.min(lightness, 1 - lightness)\n\n return new HSLColor(\n toFixedNumber(this.hue, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(lightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n /**\n * Converts a HSV color value to RGB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative.\n * @returns An RGBColor object.\n */\n private toRGB(): ColorType {\n let hue = this.hue\n let saturation = this.saturation / 100\n let brightness = this.brightness / 100\n\n let fn = (n: number, k = (n + hue / 60) % 6) =>\n brightness - saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0)\n\n return new RGBColor(\n Math.round(fn(5) * 255),\n Math.round(fn(3) * 255),\n Math.round(fn(1) * 255),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n clone(): ColorType {\n return new HSBColor(this.hue, this.saturation, this.brightness, this.alpha)\n }\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n switch (channel) {\n case \"hue\":\n return { style: \"unit\", unit: \"degree\", unitDisplay: \"narrow\" }\n case \"saturation\":\n case \"brightness\":\n case \"alpha\":\n return { style: \"percent\" }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n formatChannelValue(channel: ColorChannel, locale: string) {\n let options = this.getChannelFormatOptions(channel)\n let value = this.getChannelValue(channel)\n if (channel === \"saturation\" || channel === \"brightness\") {\n value /= 100\n }\n return new Intl.NumberFormat(locale, options).format(value)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 }\n case \"saturation\":\n case \"brightness\":\n return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n toJSON(): Record<\"h\" | \"s\" | \"b\" | \"a\", number> {\n return { h: this.hue, s: this.saturation, b: this.brightness, a: this.alpha }\n }\n\n getFormat(): ColorFormat {\n return \"hsba\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"hue\", \"saturation\", \"brightness\"]\n\n getChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return HSBColor.colorChannels\n }\n}\n","import { clampValue, mod, toFixedNumber } from \"@zag-js/numeric-range\"\nimport { Color } from \"./color\"\nimport { HSBColor } from \"./hsb-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport type { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from \"./types\"\n\nexport const HSL_REGEX =\n /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+)?)\\)/\n\nexport class HSLColor extends Color {\n constructor(\n private hue: number,\n private saturation: number,\n private lightness: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string): HSLColor | void {\n let m: RegExpMatchArray | null\n if ((m = value.match(HSL_REGEX))) {\n const [h, s, l, a] = (m[1] ?? m[2]).split(\",\").map((n) => Number(n.trim().replace(\"%\", \"\")))\n return new HSLColor(mod(h, 360), clampValue(s, 0, 100), clampValue(l, 0, 100), clampValue(a ?? 1, 0, 1))\n }\n }\n\n toString(format: ColorStringFormat) {\n switch (format) {\n case \"hex\":\n return this.toRGB().toString(\"hex\")\n case \"hexa\":\n return this.toRGB().toString(\"hexa\")\n case \"hsl\":\n return `hsl(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%)`\n case \"css\":\n case \"hsla\":\n return `hsla(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%, ${\n this.alpha\n })`\n case \"hsb\":\n return this.toHSB().toString(\"hsb\")\n case \"rgb\":\n return this.toRGB().toString(\"rgb\")\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"hsla\":\n return this\n case \"hsba\":\n return this.toHSB()\n case \"rgba\":\n return this.toRGB()\n default:\n throw new Error(\"Unsupported color conversion: hsl -> \" + format)\n }\n }\n\n /**\n * Converts a HSL color to HSB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.\n * @returns An HSBColor object.\n */\n private toHSB(): ColorType {\n let saturation = this.saturation / 100\n let lightness = this.lightness / 100\n let brightness = lightness + saturation * Math.min(lightness, 1 - lightness)\n saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness)\n return new HSBColor(\n toFixedNumber(this.hue, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(brightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n /**\n * Converts a HSL color to RGB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.\n * @returns An RGBColor object.\n */\n private toRGB(): ColorType {\n let hue = this.hue\n let saturation = this.saturation / 100\n let lightness = this.lightness / 100\n let a = saturation * Math.min(lightness, 1 - lightness)\n let fn = (n: number, k = (n + hue / 30) % 12) => lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)\n return new RGBColor(\n Math.round(fn(0) * 255),\n Math.round(fn(8) * 255),\n Math.round(fn(4) * 255),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n clone(): ColorType {\n return new HSLColor(this.hue, this.saturation, this.lightness, this.alpha)\n }\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n switch (channel) {\n case \"hue\":\n return { style: \"unit\", unit: \"degree\", unitDisplay: \"narrow\" }\n case \"saturation\":\n case \"lightness\":\n case \"alpha\":\n return { style: \"percent\" }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n formatChannelValue(channel: ColorChannel, locale: string) {\n let options = this.getChannelFormatOptions(channel)\n let value = this.getChannelValue(channel)\n if (channel === \"saturation\" || channel === \"lightness\") {\n value /= 100\n }\n return new Intl.NumberFormat(locale, options).format(value)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 }\n case \"saturation\":\n case \"lightness\":\n return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n toJSON(): Record<\"h\" | \"s\" | \"l\" | \"a\", number> {\n return { h: this.hue, s: this.saturation, l: this.lightness, a: this.alpha }\n }\n\n getFormat(): ColorFormat {\n return \"hsla\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"hue\", \"saturation\", \"lightness\"]\n\n getChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return HSLColor.colorChannels\n }\n}\n","import { clampValue, toFixedNumber } from \"@zag-js/numeric-range\"\nimport { Color } from \"./color\"\nimport { HSBColor } from \"./hsb-color\"\nimport { HSLColor } from \"./hsl-color\"\nimport type { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from \"./types\"\n\nexport class RGBColor extends Color {\n constructor(\n private red: number,\n private green: number,\n private blue: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string) {\n let colors: (number | undefined)[] = []\n\n // matching #rgb, #rgba, #rrggbb, #rrggbbaa\n if (/^#[\\da-f]+$/i.test(value) && [4, 5, 7, 9].includes(value.length)) {\n const values = (value.length < 6 ? value.replace(/[^#]/gi, \"$&$&\") : value).slice(1).split(\"\")\n while (values.length > 0) {\n colors.push(parseInt(values.splice(0, 2).join(\"\"), 16))\n }\n colors[3] = colors[3] !== undefined ? colors[3] / 255 : undefined\n }\n\n // matching rgb(rrr, ggg, bbb), rgba(rrr, ggg, bbb, 0.a)\n const match = value.match(/^rgba?\\((.*)\\)$/)\n\n if (match?.[1]) {\n colors = match[1]\n .split(\",\")\n .map((value) => Number(value.trim()))\n .map((num, i) => clampValue(num, 0, i < 3 ? 255 : 1))\n }\n\n //@ts-expect-error\n return colors.length < 3 ? undefined : new RGBColor(colors[0], colors[1], colors[2], colors[3] ?? 1)\n }\n\n toString(format: ColorStringFormat) {\n switch (format) {\n case \"hex\":\n return (\n \"#\" +\n (\n this.red.toString(16).padStart(2, \"0\") +\n this.green.toString(16).padStart(2, \"0\") +\n this.blue.toString(16).padStart(2, \"0\")\n ).toUpperCase()\n )\n case \"hexa\":\n return (\n \"#\" +\n (\n this.red.toString(16).padStart(2, \"0\") +\n this.green.toString(16).padStart(2, \"0\") +\n this.blue.toString(16).padStart(2, \"0\") +\n Math.round(this.alpha * 255)\n .toString(16)\n .padStart(2, \"0\")\n ).toUpperCase()\n )\n case \"rgb\":\n return `rgb(${this.red}, ${this.green}, ${this.blue})`\n case \"css\":\n case \"rgba\":\n return `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`\n case \"hsl\":\n return this.toHSL().toString(\"hsl\")\n case \"hsb\":\n return this.toHSB().toString(\"hsb\")\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"rgba\":\n return this\n case \"hsba\":\n return this.toHSB()\n case \"hsla\":\n return this.toHSL()\n default:\n throw new Error(\"Unsupported color conversion: rgb -> \" + format)\n }\n }\n\n toHexInt(): number {\n return (this.red << 16) | (this.green << 8) | this.blue\n }\n\n /**\n * Converts an RGB color value to HSB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.\n * @returns An HSBColor object.\n */\n private toHSB(): ColorType {\n const red = this.red / 255\n const green = this.green / 255\n const blue = this.blue / 255\n const min = Math.min(red, green, blue)\n const brightness = Math.max(red, green, blue)\n const chroma = brightness - min\n const saturation = brightness === 0 ? 0 : chroma / brightness\n let hue = 0 // achromatic\n\n if (chroma !== 0) {\n switch (brightness) {\n case red:\n hue = (green - blue) / chroma + (green < blue ? 6 : 0)\n break\n case green:\n hue = (blue - red) / chroma + 2\n break\n case blue:\n hue = (red - green) / chroma + 4\n break\n }\n\n hue /= 6\n }\n\n return new HSBColor(\n toFixedNumber(hue * 360, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(brightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n /**\n * Converts an RGB color value to HSL.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.\n * @returns An HSLColor object.\n */\n private toHSL(): ColorType {\n const red = this.red / 255\n const green = this.green / 255\n const blue = this.blue / 255\n const min = Math.min(red, green, blue)\n const max = Math.max(red, green, blue)\n const lightness = (max + min) / 2\n const chroma = max - min\n\n let hue = -1\n let saturation = -1\n\n if (chroma === 0) {\n hue = saturation = 0 // achromatic\n } else {\n saturation = chroma / (lightness < 0.5 ? max + min : 2 - max - min)\n\n switch (max) {\n case red:\n hue = (green - blue) / chroma + (green < blue ? 6 : 0)\n break\n case green:\n hue = (blue - red) / chroma + 2\n break\n case blue:\n hue = (red - green) / chroma + 4\n break\n }\n\n hue /= 6\n }\n\n return new HSLColor(\n toFixedNumber(hue * 360, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(lightness * 100, 2),\n toFixedNumber(this.alpha, 2),\n )\n }\n\n clone(): ColorType {\n return new RGBColor(this.red, this.green, this.blue, this.alpha)\n }\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n switch (channel) {\n case \"red\":\n case \"green\":\n case \"blue\":\n return { style: \"decimal\" }\n case \"alpha\":\n return { style: \"percent\" }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n formatChannelValue(channel: ColorChannel, locale: string) {\n let options = this.getChannelFormatOptions(channel)\n let value = this.getChannelValue(channel)\n return new Intl.NumberFormat(locale, options).format(value)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"red\":\n case \"green\":\n case \"blue\":\n return { minValue: 0x0, maxValue: 0xff, step: 0x1, pageSize: 0x11 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n toJSON(): Record<\"r\" | \"g\" | \"b\" | \"a\", number> {\n return { r: this.red, g: this.green, b: this.blue, a: this.alpha }\n }\n\n getFormat(): ColorFormat {\n return \"rgba\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"red\", \"green\", \"blue\"]\n\n getChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return RGBColor.colorChannels\n }\n}\n","const nativeColors /* @__PURE__ */ =\n \"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,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\"\n\nconst makeMap = (str: string) => {\n const map = new Map<string, string>()\n const list = str.split(\",\")\n for (let i = 0; i < list.length; i++) {\n const [key, val] = list[i].split(\":\")\n map.set(key, `#${val}`)\n }\n return map\n}\n\nexport const nativeColorMap /* @__PURE__ */ = makeMap(nativeColors)\n","import { HSBColor } from \"./hsb-color\"\nimport { HSLColor } from \"./hsl-color\"\nimport { nativeColorMap } from \"./native-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport type { ColorType } from \"./types\"\n\nexport const parseColor = (value: string): ColorType => {\n if (nativeColorMap.has(value)) {\n return parseColor(nativeColorMap.get(value)!)\n }\n\n const result = RGBColor.parse(value) || HSBColor.parse(value) || HSLColor.parse(value)\n\n if (!result) {\n const error = new Error(\"Invalid color value: \" + value)\n Error.captureStackTrace?.(error, parseColor)\n throw error\n }\n\n return result\n}\n\nexport const normalizeColor = (v: string | ColorType) => {\n return typeof v === \"string\" ? parseColor(v) : v\n}\n"],"mappings":";;;;;AAAO,IAAM,gBAAgB,CAAC,aAA+B,KAAc,WAAmB;AAC5F,QAAM,YAAY,sBAAsB,YAAY,OAAO,CAAC,GAAG,CAAC,CAAC;AACjE,QAAM,SAAS;AAAA,IACb,YAAY;AAAA,MACV,iBAAiB,sBAAsB,YAAY,OAAO,GAAG,CAAC,CAAC,QAAQ,MAAM,aAAa,MAAM;AAAA,IAClG;AAAA,IACA,oBAAoB;AAAA,MAClB,iBAAiB,sBAAsB,YAAY,OAAO,GAAG,CAAC,CAAC,QAAQ,MAAM,eAAe,MAAM;AAAA,MAClG,iBAAiB;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEO,IAAM,gBAAgB,CAAC,aAA+B,KAAc,WAAmB;AAC5F,QAAM,YAAY,sBAAsB,YAAY,OAAO,CAAC,GAAG,CAAC,CAAC;AACjE,QAAM,SAAS;AAAA,IACb,YAAY;AAAA,MACV,iBAAiB,sBAAsB,YAAY,OAAO,GAAG,CAAC,CAAC,UAAU,MAAM,eAAe,MAAM;AAAA,IACtG;AAAA,IACA,oBAAoB;AAAA,MAClB,iBAAiB,sBAAsB,YAAY,OAAO,GAAG,CAAC,CAAC,UAAU,MAAM,iBAAiB,MAAM;AAAA,MACtG,iBAAiB;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEO,IAAM,gBAAgB,CAAC,aAA+B,KAAc,WAAmB;AAC5F,QAAM,YAAY,sBAAsB,YAAY,OAAO,CAAC,GAAG,CAAC,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,YAAY,GAAG,KAAK,YAAY,GAAG,KAAK,MAAM;AAAA,EAC9E;AAAA,EAEA,YAAyB;AACvB,WAAO;AAAA,EACT;AAAA,EAIA,cAA0D;AACxD,WAAO,UAAS;AAAA,EAClB;AACF;AALE,cA9IW,WA8II,iBAA4D,CAAC,OAAO,cAAc,YAAY;AA9IxG,IAAM,WAAN;;;AGTP,IAAM,eACJ;AAEF,IAAM,UAAU,CAAC,QAAgB;AAC/B,QAAM,MAAM,oBAAI,IAAoB;AACpC,QAAM,OAAO,IAAI,MAAM,GAAG;AAC1B,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,MAAM,GAAG;AACpC,QAAI,IAAI,KAAK,IAAI,GAAG,EAAE;AAAA,EACxB;AACA,SAAO;AACT;AAEO,IAAM,iBAAiC,QAAQ,YAAY;;;ACP3D,IAAM,aAAa,CAAC,UAA6B;AACtD,MAAI,eAAe,IAAI,KAAK,GAAG;AAC7B,WAAO,WAAW,eAAe,IAAI,KAAK,CAAE;AAAA,EAC9C;AAEA,QAAM,SAAS,SAAS,MAAM,KAAK,KAAK,SAAS,MAAM,KAAK,KAAK,SAAS,MAAM,KAAK;AAErF,MAAI,CAAC,QAAQ;AACX,UAAM,QAAQ,IAAI,MAAM,0BAA0B,KAAK;AACvD,UAAM,oBAAoB,OAAO,UAAU;AAC3C,UAAM;AAAA,EACR;AAEA,SAAO;AACT;AAEO,IAAM,iBAAiB,CAAC,MAA0B;AACvD,SAAO,OAAO,MAAM,WAAW,WAAW,CAAC,IAAI;AACjD;","names":["clampValue","mod","toFixedNumber","clampValue","toFixedNumber","clampValue","value","clampValue","clampValue","toFixedNumber","mod","clampValue","toFixedNumber"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/color-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.0",
|
|
4
4
|
"description": "Color utilities for zag.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"clean-package": "../../../clean-package.config.json",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@zag-js/numeric-range": "0.
|
|
28
|
+
"@zag-js/numeric-range": "0.57.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"clean-package": "2.2.0"
|
package/src/color.ts
CHANGED
|
@@ -23,6 +23,7 @@ export abstract class Color implements ColorType {
|
|
|
23
23
|
abstract getChannelRange(channel: ColorChannel): ColorChannelRange
|
|
24
24
|
abstract getFormat(): ColorFormat
|
|
25
25
|
abstract getChannels(): [ColorChannel, ColorChannel, ColorChannel]
|
|
26
|
+
abstract formatChannelValue(channel: ColorChannel, locale: string): string
|
|
26
27
|
|
|
27
28
|
toHexInt(): number {
|
|
28
29
|
return this.toFormat("rgba").toHexInt()
|
package/src/hsb-color.ts
CHANGED
|
@@ -105,6 +105,28 @@ export class HSBColor extends Color {
|
|
|
105
105
|
return new HSBColor(this.hue, this.saturation, this.brightness, this.alpha)
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {
|
|
109
|
+
switch (channel) {
|
|
110
|
+
case "hue":
|
|
111
|
+
return { style: "unit", unit: "degree", unitDisplay: "narrow" }
|
|
112
|
+
case "saturation":
|
|
113
|
+
case "brightness":
|
|
114
|
+
case "alpha":
|
|
115
|
+
return { style: "percent" }
|
|
116
|
+
default:
|
|
117
|
+
throw new Error("Unknown color channel: " + channel)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
formatChannelValue(channel: ColorChannel, locale: string) {
|
|
122
|
+
let options = this.getChannelFormatOptions(channel)
|
|
123
|
+
let value = this.getChannelValue(channel)
|
|
124
|
+
if (channel === "saturation" || channel === "brightness") {
|
|
125
|
+
value /= 100
|
|
126
|
+
}
|
|
127
|
+
return new Intl.NumberFormat(locale, options).format(value)
|
|
128
|
+
}
|
|
129
|
+
|
|
108
130
|
getChannelRange(channel: ColorChannel): ColorChannelRange {
|
|
109
131
|
switch (channel) {
|
|
110
132
|
case "hue":
|
package/src/hsl-color.ts
CHANGED
|
@@ -101,6 +101,28 @@ export class HSLColor extends Color {
|
|
|
101
101
|
return new HSLColor(this.hue, this.saturation, this.lightness, this.alpha)
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {
|
|
105
|
+
switch (channel) {
|
|
106
|
+
case "hue":
|
|
107
|
+
return { style: "unit", unit: "degree", unitDisplay: "narrow" }
|
|
108
|
+
case "saturation":
|
|
109
|
+
case "lightness":
|
|
110
|
+
case "alpha":
|
|
111
|
+
return { style: "percent" }
|
|
112
|
+
default:
|
|
113
|
+
throw new Error("Unknown color channel: " + channel)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
formatChannelValue(channel: ColorChannel, locale: string) {
|
|
118
|
+
let options = this.getChannelFormatOptions(channel)
|
|
119
|
+
let value = this.getChannelValue(channel)
|
|
120
|
+
if (channel === "saturation" || channel === "lightness") {
|
|
121
|
+
value /= 100
|
|
122
|
+
}
|
|
123
|
+
return new Intl.NumberFormat(locale, options).format(value)
|
|
124
|
+
}
|
|
125
|
+
|
|
104
126
|
getChannelRange(channel: ColorChannel): ColorChannelRange {
|
|
105
127
|
switch (channel) {
|
|
106
128
|
case "hue":
|
package/src/rgb-color.ts
CHANGED
|
@@ -182,6 +182,25 @@ export class RGBColor extends Color {
|
|
|
182
182
|
return new RGBColor(this.red, this.green, this.blue, this.alpha)
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {
|
|
186
|
+
switch (channel) {
|
|
187
|
+
case "red":
|
|
188
|
+
case "green":
|
|
189
|
+
case "blue":
|
|
190
|
+
return { style: "decimal" }
|
|
191
|
+
case "alpha":
|
|
192
|
+
return { style: "percent" }
|
|
193
|
+
default:
|
|
194
|
+
throw new Error("Unknown color channel: " + channel)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
formatChannelValue(channel: ColorChannel, locale: string) {
|
|
199
|
+
let options = this.getChannelFormatOptions(channel)
|
|
200
|
+
let value = this.getChannelValue(channel)
|
|
201
|
+
return new Intl.NumberFormat(locale, options).format(value)
|
|
202
|
+
}
|
|
203
|
+
|
|
185
204
|
getChannelRange(channel: ColorChannel): ColorChannelRange {
|
|
186
205
|
switch (channel) {
|
|
187
206
|
case "red":
|
package/src/types.ts
CHANGED
|
@@ -46,6 +46,11 @@ export interface ColorType {
|
|
|
46
46
|
* Throws an error if the channel is unsupported in the current color format.
|
|
47
47
|
*/
|
|
48
48
|
withChannelValue(channel: ColorChannel, value: number): ColorType
|
|
49
|
+
/**
|
|
50
|
+
* Returns the formatted value for a given channel.
|
|
51
|
+
*/
|
|
52
|
+
formatChannelValue(channel: ColorChannel, locale: string): string
|
|
53
|
+
|
|
49
54
|
/**
|
|
50
55
|
* Returns the minimum, maximum, and step values for a given channel.
|
|
51
56
|
*/
|