@soybeanjs/colord 0.1.1 → 0.2.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.
Files changed (44) hide show
  1. package/README.md +2 -2
  2. package/dist/{colord-iJvjkDaN.d.ts → colord-AfN0aSRY.d.ts} +11 -1
  3. package/dist/{colord-CiL21DdP.js → colord-_3vDrvhI.js} +187 -7
  4. package/dist/colord.d.ts +1 -1
  5. package/dist/colord.js +8 -8
  6. package/dist/{extend-Cjbo01n8.js → extend-1NvzfDMp.js} +1 -1
  7. package/dist/{extend-BwkxQVzY.d.ts → extend-UYBGWCHH.d.ts} +2 -2
  8. package/dist/{get-DjkEJgax.js → get-B9GsrsfV.js} +1 -1
  9. package/dist/{hsv-6f-Avk00.js → hsv-OOAVcaRH.js} +1 -1
  10. package/dist/index.d.ts +3 -3
  11. package/dist/index.js +9 -9
  12. package/dist/{lab-BXLaTQvQ.js → lab-DRO6J6z8.js} +5 -5
  13. package/dist/{lab-DklZwOkG.js → lab-NxNRMUqK.js} +12 -12
  14. package/dist/{manipulate-DJ-cBonL.js → manipulate-DG6jOj5-.js} +3 -3
  15. package/dist/palette/index.d.ts +9 -3
  16. package/dist/palette/index.js +305 -14
  17. package/dist/plugins/a11y.d.ts +2 -2
  18. package/dist/plugins/a11y.js +3 -3
  19. package/dist/plugins/cmyk.d.ts +2 -2
  20. package/dist/plugins/cmyk.js +1 -1
  21. package/dist/plugins/harmonies.d.ts +1 -1
  22. package/dist/plugins/hwb.d.ts +2 -2
  23. package/dist/plugins/hwb.js +2 -2
  24. package/dist/plugins/lab.d.ts +2 -2
  25. package/dist/plugins/lab.js +6 -6
  26. package/dist/plugins/lch.d.ts +2 -2
  27. package/dist/plugins/lch.js +14 -14
  28. package/dist/plugins/minify.d.ts +1 -1
  29. package/dist/plugins/minify.js +1 -1
  30. package/dist/plugins/mix.d.ts +2 -2
  31. package/dist/plugins/mix.js +6 -6
  32. package/dist/plugins/names.d.ts +1 -1
  33. package/dist/plugins/oklab.d.ts +2 -2
  34. package/dist/plugins/oklab.js +12 -12
  35. package/dist/plugins/xyz.d.ts +2 -2
  36. package/dist/plugins/xyz.js +4 -4
  37. package/dist/{rgb-BIWjP3hJ.js → rgb-DzRkOBLO.js} +1 -1
  38. package/dist/{xyz-Czd8MTub.js → xyz-WMIP19rd.js} +7 -7
  39. package/package.json +1 -1
  40. package/dist/oklch-sYjVoJRG.js +0 -186
  41. package/dist/plugins/oklch.d.ts +0 -17
  42. package/dist/plugins/oklch.js +0 -5
  43. /package/dist/{types-CV5bTriG.d.ts → types-BP0NSyqd.d.ts} +0 -0
  44. /package/dist/{utils-BhDL0kto.js → utils-CshL9w1R.js} +0 -0
package/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  ## Differences from [colord](https://github.com/omgovich/colord)
19
19
 
20
- - support `oklab` and `oklch` color models
20
+ - support `oklab` and `oklch` color models, and `oklch` is support directly without extra plugin
21
21
  - support `palette` API to generate and find the nearest palette color
22
22
  - more correct color parsing
23
23
  - simplify type definitions
@@ -37,6 +37,7 @@ colord("#ff0000").grayscale().alpha(0.25).toRgbString(); // "rgba(128, 128, 128,
37
37
  colord("rgb(192, 192, 192)").isLight(); // true
38
38
  colord("hsl(0, 50%, 50%)").darken(0.25).toHex(); // "#602020"
39
39
  colord({ r: 128, g: 128, b: 128, alpha: 0.25 }).toRgbString(); // "rgba(128, 128, 128, 0.25)"
40
+ colord('hsl(210.003, 34.547%, 98.004%)').toOklchString(); // 'oklch(98.4% 0.003 247.858)'
40
41
  ```
41
42
 
42
43
  ## Palette API
@@ -62,7 +63,6 @@ generateNearestPalette('red'); // find the nearest color in the palette of the c
62
63
  - LAB objects ([via plugin](#plugins))
63
64
  - XYZ objects ([via plugin](#plugins))
64
65
  - OKLAB objects ([via plugin](#plugins))
65
- - OKLCH objects ([via plugin](#plugins))
66
66
 
67
67
 
68
68
  ## More API
@@ -1,4 +1,4 @@
1
- import { a as HsvColor, c as InputSource, i as HslColor, t as AnyColor, v as RgbColor } from "./types-CV5bTriG.js";
1
+ import { a as HsvColor, c as InputSource, i as HslColor, p as OklchColor, t as AnyColor, v as RgbColor } from "./types-BP0NSyqd.js";
2
2
 
3
3
  //#region src/colord.d.ts
4
4
 
@@ -67,6 +67,16 @@ declare class Colord {
67
67
  * Always includes an alpha value from 0 to 1.
68
68
  */
69
69
  toHsv(): HsvColor;
70
+ /**
71
+ * Converts a color to OKLCH color space and returns an object.
72
+ * Always includes an alpha value from 0 to 1.
73
+ */
74
+ toOklch(): OklchColor;
75
+ /**
76
+ * Converts a color to OKLCH color space and returns a string representation.
77
+ * Always includes an alpha value from 0 to 1.
78
+ */
79
+ toOklchString(): string;
70
80
  /**
71
81
  * Creates a new instance containing an inverted (opposite) version of the color.
72
82
  */
@@ -1,8 +1,8 @@
1
- import { l as round, v as ALPHA_PRECISION } from "./utils-BhDL0kto.js";
2
- import { a as parseRgbString, c as roundRgb, i as parseRgb, s as rgbToRgbString } from "./rgb-BIWjP3hJ.js";
3
- import { i as roundHsv, n as parseHsv, r as rgbToHsv } from "./hsv-6f-Avk00.js";
4
- import { a as saturate, c as rgbToHsl, l as rgbToHslString, n as invert, o as parseHsl, r as lighten, s as parseHslString, t as changeAlpha, u as roundHsl } from "./manipulate-DJ-cBonL.js";
5
- import { t as getBrightness } from "./get-DjkEJgax.js";
1
+ import { _ as OKLAB_M2_INV, a as mul3x3, c as parseValueToDecimal, g as OKLAB_M2, h as OKLAB_M1_INV, i as isPresent, l as round, m as OKLAB_M1, n as clampHue, o as parseAlpha, s as parseHue, t as clamp, v as ALPHA_PRECISION } from "./utils-CshL9w1R.js";
2
+ import { a as parseRgbString, c as roundRgb, i as parseRgb, n as clampRgb, o as rgbToLinearRgb, r as linearRgbToRgb, s as rgbToRgbString, t as clampLinearRgb } from "./rgb-DzRkOBLO.js";
3
+ import { i as roundHsv, n as parseHsv, r as rgbToHsv } from "./hsv-OOAVcaRH.js";
4
+ import { a as saturate, c as rgbToHsl, l as rgbToHslString, n as invert, o as parseHsl, r as lighten, s as parseHslString, t as changeAlpha, u as roundHsl } from "./manipulate-DG6jOj5-.js";
5
+ import { t as getBrightness } from "./get-B9GsrsfV.js";
6
6
 
7
7
  //#region src/models/hex.ts
8
8
  const hexMatcher = /^#([0-9a-f]{3,8})$/i;
@@ -37,6 +37,170 @@ const rgbToHex = (rgb) => {
37
37
  return `#${format(r)}${format(g)}${format(b)}${alphaHex}`;
38
38
  };
39
39
 
40
+ //#endregion
41
+ //#region src/models/oklch.ts
42
+ const clampOklch = (oklch) => {
43
+ const { l, c, h, alpha } = oklch;
44
+ return {
45
+ l: clamp(l, 0, 1),
46
+ c: clamp(c, 0, .37),
47
+ h: clampHue(h),
48
+ alpha: clamp(alpha)
49
+ };
50
+ };
51
+ const roundOklch = (oklch) => {
52
+ const { l, c, h, alpha } = oklch;
53
+ return {
54
+ l: round(l, 3),
55
+ c: round(c, 3),
56
+ h: round(h, 3),
57
+ alpha: round(alpha, ALPHA_PRECISION)
58
+ };
59
+ };
60
+ /**
61
+ * Convert OKLCH to Linear RGB without gamut mapping
62
+ */
63
+ const oklchToLinearRgb = (oklch) => {
64
+ const { l, c, h, alpha } = oklch;
65
+ const hRad = h * Math.PI / 180;
66
+ const [r, g, b] = mul3x3(OKLAB_M1_INV, mul3x3(OKLAB_M2_INV, [
67
+ l,
68
+ c * Math.cos(hRad),
69
+ c * Math.sin(hRad)
70
+ ]).map((v) => v * v * v));
71
+ return {
72
+ r,
73
+ g,
74
+ b,
75
+ alpha
76
+ };
77
+ };
78
+ /**
79
+ * Check if a linear RGB color is within sRGB gamut
80
+ */
81
+ const isInGamut = (linearRgb, epsilon = 1e-6) => {
82
+ return linearRgb.r >= -epsilon && linearRgb.r <= 1 + epsilon && linearRgb.g >= -epsilon && linearRgb.g <= 1 + epsilon && linearRgb.b >= -epsilon && linearRgb.b <= 1 + epsilon;
83
+ };
84
+ /**
85
+ * Binary search to find maximum chroma that fits in sRGB gamut
86
+ * @param l - Lightness (0-1)
87
+ * @param h - Hue (0-360)
88
+ * @param alpha - Alpha (0-1)
89
+ * @returns Maximum chroma that fits in sRGB gamut
90
+ */
91
+ const findGamutChroma = (l, h, alpha) => {
92
+ let min = 0;
93
+ let max = .37;
94
+ const epsilon = 1e-5;
95
+ if (isInGamut(oklchToLinearRgb({
96
+ l,
97
+ c: max,
98
+ h,
99
+ alpha
100
+ }), epsilon)) return max;
101
+ while (max - min > epsilon) {
102
+ const mid = (min + max) / 2;
103
+ if (isInGamut(oklchToLinearRgb({
104
+ l,
105
+ c: mid,
106
+ h,
107
+ alpha
108
+ }), epsilon)) min = mid;
109
+ else max = mid;
110
+ }
111
+ return min;
112
+ };
113
+ const oklchToRgb = (oklch) => {
114
+ const { l, h, alpha } = oklch;
115
+ let linearRgb = oklchToLinearRgb(oklch);
116
+ if (!isInGamut(linearRgb)) linearRgb = oklchToLinearRgb({
117
+ l,
118
+ c: findGamutChroma(l, h, alpha),
119
+ h,
120
+ alpha
121
+ });
122
+ linearRgb = clampLinearRgb(linearRgb);
123
+ return clampRgb(linearRgbToRgb(linearRgb));
124
+ };
125
+ const rgbToOklch = (rgb) => {
126
+ const lRgb = rgbToLinearRgb(rgb);
127
+ const [l, a, b] = mul3x3(OKLAB_M2, mul3x3(OKLAB_M1, [
128
+ lRgb.r,
129
+ lRgb.g,
130
+ lRgb.b
131
+ ]).map((v) => Math.cbrt(v)));
132
+ const chroma = Math.sqrt(a * a + b * b);
133
+ let hue;
134
+ if (chroma < 1e-4) hue = 0;
135
+ else {
136
+ hue = Math.atan2(b, a) * (180 / Math.PI);
137
+ if (hue < 0) hue += 360;
138
+ }
139
+ return clampOklch({
140
+ l,
141
+ c: chroma,
142
+ h: hue,
143
+ alpha: rgb.alpha
144
+ });
145
+ };
146
+ const parseOriginOklch = ({ l, c, h, alpha = 1 }) => {
147
+ if (!isPresent(l) || !isPresent(c) || !isPresent(h)) return null;
148
+ return clampOklch({
149
+ l: Number(l),
150
+ c: Number(c),
151
+ h: Number(h),
152
+ alpha: Number(alpha)
153
+ });
154
+ };
155
+ const parseOklch = (input) => {
156
+ const oklch = parseOriginOklch(input);
157
+ if (!oklch) return null;
158
+ return oklchToRgb(oklch);
159
+ };
160
+ /**
161
+ * Parsing syntax: oklch(L c h [/ alpha])
162
+ * - L: <number|percentage>
163
+ * - c: <number>
164
+ * - h: <number>
165
+ * - alpha: <number|percentage>
166
+ */
167
+ const oklchMatcher = /^oklch\(\s*([+-]?[\d.]+)%?\s+([+-]?[\d.]+)\s+([+-]?[\d.]+)(deg|grad|rad|turn)?(?:\s*\/\s*([+-]?[\d.]+%?))?\s*\)$/i;
168
+ const parseOriginOklchString = (input) => {
169
+ const match = oklchMatcher.exec(input);
170
+ if (!match) return null;
171
+ const [_, l, c, h, unit, alpha] = match;
172
+ return clampOklch({
173
+ l: parseValueToDecimal(l),
174
+ c: Number.parseFloat(c),
175
+ h: parseHue(h, unit),
176
+ alpha: parseAlpha(alpha)
177
+ });
178
+ };
179
+ const parseOklchString = (input) => {
180
+ const oklch = parseOriginOklchString(input);
181
+ if (!oklch) return null;
182
+ return oklchToRgb(oklch);
183
+ };
184
+ const toOklchString = (oklch) => {
185
+ const { l, c, h, alpha } = roundOklch(oklch);
186
+ return alpha < 1 ? `oklch(${l} ${c} ${h} / ${alpha})` : `oklch(${l} ${c} ${h})`;
187
+ };
188
+ const rgbToOklchString = (rgb) => {
189
+ return toOklchString(rgbToOklch(rgb));
190
+ };
191
+ const parseOklchBySource = (source) => {
192
+ if (!source || source.format !== "oklch") return null;
193
+ const { input } = source;
194
+ if (typeof input === "string") return parseOriginOklchString(input);
195
+ if (typeof input === "object") return parseOriginOklch(input);
196
+ return null;
197
+ };
198
+ const toOklchStringBySource = (source) => {
199
+ const oklch = parseOklchBySource(source);
200
+ if (!oklch) return null;
201
+ return toOklchString(oklch);
202
+ };
203
+
40
204
  //#endregion
41
205
  //#region src/shared/common.ts
42
206
  function keysOf(record) {
@@ -49,12 +213,14 @@ const parsers = {
49
213
  string: [
50
214
  [parseHex, "hex"],
51
215
  [parseRgbString, "rgb"],
52
- [parseHslString, "hsl"]
216
+ [parseHslString, "hsl"],
217
+ [parseOklchString, "oklch"]
53
218
  ],
54
219
  object: [
55
220
  [parseRgb, "rgb"],
56
221
  [parseHsl, "hsl"],
57
- [parseHsv, "hsv"]
222
+ [parseHsv, "hsv"],
223
+ [parseOklch, "oklch"]
58
224
  ]
59
225
  };
60
226
  const findValidColor = (input, $parsers) => {
@@ -191,6 +357,20 @@ var Colord = class {
191
357
  return roundHsv(rgbToHsv(this.rgb));
192
358
  }
193
359
  /**
360
+ * Converts a color to OKLCH color space and returns an object.
361
+ * Always includes an alpha value from 0 to 1.
362
+ */
363
+ toOklch() {
364
+ return roundOklch(parseOklchBySource(this.getSource()) || rgbToOklch(this.rgb));
365
+ }
366
+ /**
367
+ * Converts a color to OKLCH color space and returns a string representation.
368
+ * Always includes an alpha value from 0 to 1.
369
+ */
370
+ toOklchString() {
371
+ return toOklchStringBySource(this.getSource()) || rgbToOklchString(this.rgb);
372
+ }
373
+ /**
194
374
  * Creates a new instance containing an inverted (opposite) version of the color.
195
375
  */
196
376
  invert() {
package/dist/colord.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as colord, t as Colord } from "./colord-iJvjkDaN.js";
1
+ import { n as colord, t as Colord } from "./colord-AfN0aSRY.js";
2
2
  export { Colord, colord };
package/dist/colord.js CHANGED
@@ -1,10 +1,10 @@
1
- import "./utils-BhDL0kto.js";
2
- import "./rgb-BIWjP3hJ.js";
3
- import { n as colord, t as Colord } from "./colord-CiL21DdP.js";
4
- import "./hsv-6f-Avk00.js";
5
- import "./manipulate-DJ-cBonL.js";
6
- import "./xyz-Czd8MTub.js";
7
- import "./lab-DklZwOkG.js";
8
- import "./get-DjkEJgax.js";
1
+ import "./utils-CshL9w1R.js";
2
+ import "./rgb-DzRkOBLO.js";
3
+ import { n as colord, t as Colord } from "./colord-_3vDrvhI.js";
4
+ import "./hsv-OOAVcaRH.js";
5
+ import "./manipulate-DG6jOj5-.js";
6
+ import "./xyz-WMIP19rd.js";
7
+ import "./lab-NxNRMUqK.js";
8
+ import "./get-B9GsrsfV.js";
9
9
 
10
10
  export { Colord, colord };
@@ -1,4 +1,4 @@
1
- import { a as parsers, t as Colord } from "./colord-CiL21DdP.js";
1
+ import { a as parsers, t as Colord } from "./colord-_3vDrvhI.js";
2
2
 
3
3
  //#region src/extend.ts
4
4
  const activePlugins = [];
@@ -1,5 +1,5 @@
1
- import { _ as Parsers } from "./types-CV5bTriG.js";
2
- import { t as Colord } from "./colord-iJvjkDaN.js";
1
+ import { _ as Parsers } from "./types-BP0NSyqd.js";
2
+ import { t as Colord } from "./colord-AfN0aSRY.js";
3
3
 
4
4
  //#region src/extend.d.ts
5
5
  type Plugin = (ColordClass: typeof Colord, parsers: Parsers) => void;
@@ -1,4 +1,4 @@
1
- import { o as rgbToLinearRgb } from "./rgb-BIWjP3hJ.js";
1
+ import { o as rgbToLinearRgb } from "./rgb-DzRkOBLO.js";
2
2
 
3
3
  //#region src/shared/get.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { i as isPresent, l as round, n as clampHue, t as clamp, v as ALPHA_PRECISION } from "./utils-BhDL0kto.js";
1
+ import { i as isPresent, l as round, n as clampHue, t as clamp, v as ALPHA_PRECISION } from "./utils-CshL9w1R.js";
2
2
 
3
3
  //#region src/models/hsv.ts
4
4
  const clampHsv = (hsv) => ({
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as HsvColor, b as TailwindPaletteColorKey, f as OklabColor, g as PaletteColorLevel, i as HslColor, l as LabColor, o as HwbColor, p as OklchColor, r as Format, s as Input, t as AnyColor, u as LchColor, v as RgbColor, x as XyzColor } from "./types-CV5bTriG.js";
2
- import { n as colord, t as Colord } from "./colord-iJvjkDaN.js";
3
- import { n as extend, t as Plugin } from "./extend-BwkxQVzY.js";
1
+ import { a as HsvColor, b as TailwindPaletteColorKey, f as OklabColor, g as PaletteColorLevel, i as HslColor, l as LabColor, o as HwbColor, p as OklchColor, r as Format, s as Input, t as AnyColor, u as LchColor, v as RgbColor, x as XyzColor } from "./types-BP0NSyqd.js";
2
+ import { n as colord, t as Colord } from "./colord-AfN0aSRY.js";
3
+ import { n as extend, t as Plugin } from "./extend-UYBGWCHH.js";
4
4
 
5
5
  //#region src/shared/parse.d.ts
6
6
 
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import "./utils-BhDL0kto.js";
2
- import "./rgb-BIWjP3hJ.js";
3
- import { i as getFormat, n as colord, r as random, t as Colord } from "./colord-CiL21DdP.js";
4
- import "./hsv-6f-Avk00.js";
5
- import "./manipulate-DJ-cBonL.js";
6
- import "./xyz-Czd8MTub.js";
7
- import "./lab-DklZwOkG.js";
8
- import "./get-DjkEJgax.js";
9
- import { t as extend } from "./extend-Cjbo01n8.js";
1
+ import "./utils-CshL9w1R.js";
2
+ import "./rgb-DzRkOBLO.js";
3
+ import { i as getFormat, n as colord, r as random, t as Colord } from "./colord-_3vDrvhI.js";
4
+ import "./hsv-OOAVcaRH.js";
5
+ import "./manipulate-DG6jOj5-.js";
6
+ import "./xyz-WMIP19rd.js";
7
+ import "./lab-NxNRMUqK.js";
8
+ import "./get-B9GsrsfV.js";
9
+ import { t as extend } from "./extend-1NvzfDMp.js";
10
10
 
11
11
  export { Colord, colord, extend, getFormat, random };
@@ -1,6 +1,6 @@
1
- import { l as round, t as clamp } from "./utils-BhDL0kto.js";
2
- import { a as parseLabToRgb, c as roundLab, i as parseLabStringToRgb, l as toLabStringBySource, o as rgbToLab, r as parseLabBySource, s as rgbToLabString } from "./lab-DklZwOkG.js";
3
- import { r as getDeltaE2000 } from "./get-DjkEJgax.js";
1
+ import { l as round, t as clamp } from "./utils-CshL9w1R.js";
2
+ import { a as parseLabString, c as roundLab, i as parseLabBySource, l as toLabStringBySource, o as rgbToLab, r as parseLab, s as rgbToLabString } from "./lab-NxNRMUqK.js";
3
+ import { r as getDeltaE2000 } from "./get-B9GsrsfV.js";
4
4
 
5
5
  //#region src/plugins/lab.ts
6
6
  /**
@@ -18,8 +18,8 @@ const labPlugin = (ColordClass, parsers) => {
18
18
  const compared = color instanceof ColordClass ? color : new ColordClass(color);
19
19
  return clamp(round(getDeltaE2000(this.toLab(), compared.toLab()) / 100, 3));
20
20
  };
21
- parsers.string.push([parseLabStringToRgb, "lab"]);
22
- parsers.object.push([parseLabToRgb, "lab"]);
21
+ parsers.string.push([parseLabString, "lab"]);
22
+ parsers.object.push([parseLab, "lab"]);
23
23
  };
24
24
  var lab_default = labPlugin;
25
25
 
@@ -1,6 +1,6 @@
1
- import { a as mul3x3, d as M_D65_TO_D50, i as isPresent, l as round, o as parseAlpha, t as clamp, u as M_D50_TO_D65, v as ALPHA_PRECISION, y as D50 } from "./utils-BhDL0kto.js";
2
- import { n as clampRgb } from "./rgb-BIWjP3hJ.js";
3
- import { a as xyzToRgb, r as rgbToXyz } from "./xyz-Czd8MTub.js";
1
+ import { a as mul3x3, d as M_D65_TO_D50, i as isPresent, l as round, o as parseAlpha, t as clamp, u as M_D50_TO_D65, v as ALPHA_PRECISION, y as D50 } from "./utils-CshL9w1R.js";
2
+ import { n as clampRgb } from "./rgb-DzRkOBLO.js";
3
+ import { a as xyzToRgb, r as rgbToXyz } from "./xyz-WMIP19rd.js";
4
4
 
5
5
  //#region src/models/lab.ts
6
6
  const EPSILON = 216 / 24389;
@@ -157,7 +157,7 @@ function labToXyzRaw(lab) {
157
157
  alpha
158
158
  };
159
159
  }
160
- const parseLab = ({ l, a, b, alpha = 1 }) => {
160
+ const parseOriginLab = ({ l, a, b, alpha = 1 }) => {
161
161
  if (!isPresent(l) || !isPresent(a) || !isPresent(b)) return null;
162
162
  return clampLab({
163
163
  l: Number(l),
@@ -166,8 +166,8 @@ const parseLab = ({ l, a, b, alpha = 1 }) => {
166
166
  alpha: Number(alpha)
167
167
  });
168
168
  };
169
- const parseLabToRgb = (input) => {
170
- const lab = parseLab(input);
169
+ const parseLab = (input) => {
170
+ const lab = parseOriginLab(input);
171
171
  if (!lab) return null;
172
172
  return labToRgb(lab);
173
173
  };
@@ -179,7 +179,7 @@ const parseLabToRgb = (input) => {
179
179
  * - alpha: <number|percentage> [0,1]
180
180
  */
181
181
  const labMatcher = /^lab\(\s*([+-]?[\d.]+)%?\s+([+-]?[\d.]+)\s+([+-]?[\d.]+)(?:\s*\/\s*([+-]?[\d.]+%?))?\s*\)$/i;
182
- const parseLabString = (input) => {
182
+ const parseOriginLabString = (input) => {
183
183
  const match = labMatcher.exec(input);
184
184
  if (!match) return null;
185
185
  const [_, l, a, b, alpha] = match;
@@ -190,8 +190,8 @@ const parseLabString = (input) => {
190
190
  alpha: parseAlpha(alpha)
191
191
  });
192
192
  };
193
- const parseLabStringToRgb = (input) => {
194
- const lab = parseLabString(input);
193
+ const parseLabString = (input) => {
194
+ const lab = parseOriginLabString(input);
195
195
  if (!lab) return null;
196
196
  return labToRgb(lab);
197
197
  };
@@ -205,8 +205,8 @@ const rgbToLabString = (rgb) => {
205
205
  const parseLabBySource = (source) => {
206
206
  if (!source || source.format !== "lab") return null;
207
207
  const { input } = source;
208
- if (typeof input === "string") return parseLabString(input);
209
- if (typeof input === "object") return parseLab(input);
208
+ if (typeof input === "string") return parseOriginLabString(input);
209
+ if (typeof input === "object") return parseOriginLab(input);
210
210
  return null;
211
211
  };
212
212
  const toLabStringBySource = (source) => {
@@ -216,4 +216,4 @@ const toLabStringBySource = (source) => {
216
216
  };
217
217
 
218
218
  //#endregion
219
- export { parseLabToRgb as a, roundLab as c, parseLabStringToRgb as i, toLabStringBySource as l, labToRgb as n, rgbToLab as o, parseLabBySource as r, rgbToLabString as s, clampLab as t };
219
+ export { parseLabString as a, roundLab as c, parseLabBySource as i, toLabStringBySource as l, labToRgb as n, rgbToLab as o, parseLab as r, rgbToLabString as s, clampLab as t };
@@ -1,6 +1,6 @@
1
- import { i as isPresent, l as round, n as clampHue, o as parseAlpha, s as parseHue, t as clamp, v as ALPHA_PRECISION } from "./utils-BhDL0kto.js";
2
- import { r as rgbToHsv, t as hsvToRgb } from "./hsv-6f-Avk00.js";
3
- import { n as labToRgb, o as rgbToLab, t as clampLab } from "./lab-DklZwOkG.js";
1
+ import { i as isPresent, l as round, n as clampHue, o as parseAlpha, s as parseHue, t as clamp, v as ALPHA_PRECISION } from "./utils-CshL9w1R.js";
2
+ import { r as rgbToHsv, t as hsvToRgb } from "./hsv-OOAVcaRH.js";
3
+ import { n as labToRgb, o as rgbToLab, t as clampLab } from "./lab-NxNRMUqK.js";
4
4
 
5
5
  //#region src/models/hsl.ts
6
6
  const clampHsl = (hsl) => {
@@ -1,13 +1,19 @@
1
- import { d as NearestPalette, g as PaletteColorLevel, h as OutputFormat, m as OutputColorMap, t as AnyColor, y as TailwindPaletteColor } from "../types-CV5bTriG.js";
1
+ import { d as NearestPalette, g as PaletteColorLevel, h as OutputFormat, m as OutputColorMap, t as AnyColor, y as TailwindPaletteColor } from "../types-BP0NSyqd.js";
2
2
 
3
3
  //#region src/palette/constant.d.ts
4
4
 
5
5
  /**
6
6
  * TailwindCSS v4 official oklch palette data
7
7
  *
8
- * the format is `oklch` string
8
+ * the format is `oklch` string, like `oklch(98.4% 0.003 247.858)`
9
9
  */
10
10
  declare const tailwindPalette: TailwindPaletteColor;
11
+ /**
12
+ * TailwindCSS v4 official hsl palette data
13
+ *
14
+ * the format is `hsl` string, but no `hsl()` like `210.003, 34.547%, 98.004%`
15
+ */
16
+ declare const tailwindPaletteHsl: TailwindPaletteColor;
11
17
  //#endregion
12
18
  //#region src/palette/generate.d.ts
13
19
  /**
@@ -27,4 +33,4 @@ declare function generatePalette<F extends OutputFormat>(input: AnyColor, format
27
33
  */
28
34
  declare function generateNearestPalette<F extends OutputFormat>(input: AnyColor, format?: F): NearestPalette<F>;
29
35
  //#endregion
30
- export { generateNearestPalette, generatePalette, tailwindPalette };
36
+ export { generateNearestPalette, generatePalette, tailwindPalette, tailwindPaletteHsl };