@soybeanjs/colord 0.3.4 → 0.4.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.
@@ -183,7 +183,8 @@ const parseOklchString = (input) => {
183
183
  };
184
184
  const toOklchString = (oklch) => {
185
185
  const { l, c, h, alpha } = roundOklch(oklch);
186
- return alpha < 1 ? `oklch(${l * 100}% ${c} ${h} / ${alpha})` : `oklch(${l * 100}% ${c} ${h})`;
186
+ const percent = round(l * 100, 1);
187
+ return alpha < 1 ? `oklch(${percent}% ${c} ${h} / ${alpha})` : `oklch(${percent}% ${c} ${h})`;
187
188
  };
188
189
  const rgbToOklchString = (rgb) => {
189
190
  return toOklchString(rgbToOklch(rgb));
package/dist/colord.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./utils-CshL9w1R.js";
2
2
  import "./rgb-DzRkOBLO.js";
3
- import { n as colord, t as Colord } from "./colord-Bui-ARPL.js";
3
+ import { n as colord, t as Colord } from "./colord-BB4wQYGd.js";
4
4
  import "./hsv-OOAVcaRH.js";
5
5
  import "./manipulate-Cf2MhO9I.js";
6
6
  import "./xyz-WMIP19rd.js";
@@ -1,4 +1,4 @@
1
- import { a as parsers, t as Colord } from "./colord-Bui-ARPL.js";
1
+ import { a as parsers, t as Colord } from "./colord-BB4wQYGd.js";
2
2
 
3
3
  //#region src/extend.ts
4
4
  const activePlugins = [];
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import "./utils-CshL9w1R.js";
2
2
  import "./rgb-DzRkOBLO.js";
3
- import { i as getFormat, n as colord, r as random, t as Colord } from "./colord-Bui-ARPL.js";
3
+ import { i as getFormat, n as colord, r as random, t as Colord } from "./colord-BB4wQYGd.js";
4
4
  import "./hsv-OOAVcaRH.js";
5
5
  import "./manipulate-Cf2MhO9I.js";
6
6
  import "./xyz-WMIP19rd.js";
7
7
  import "./lab-NxNRMUqK.js";
8
8
  import "./get-B9GsrsfV.js";
9
- import { t as extend } from "./extend-JGZdW35H.js";
9
+ import { t as extend } from "./extend-DZhKU4TR.js";
10
10
 
11
11
  export { Colord, colord, extend, getFormat, random };
@@ -10,12 +10,19 @@ import { f as OklchColor, i as HslColor, m as RgbColor, t as AnyColor } from "..
10
10
  type PaletteColorLevel = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
11
11
  type TailwindPaletteKey = 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose';
12
12
  type TailwindPaletteLevelColorKey = `${TailwindPaletteKey}.${PaletteColorLevel}`;
13
+ interface PaletteColorItem {
14
+ level: PaletteColorLevel;
15
+ hex: string;
16
+ rgb: string;
17
+ hsl: string;
18
+ oklch: string;
19
+ }
13
20
  /**
14
21
  * the tailwind palette
15
22
  *
16
23
  * the color format is `oklch` string
17
24
  */
18
- type TailwindPalette = { [K in TailwindPaletteKey]: { [L in PaletteColorLevel]: string } };
25
+ type TailwindPalette = { [K in TailwindPaletteKey]: { [L in PaletteColorLevel]: PaletteColorItem } };
19
26
  type OutputColorMap = {
20
27
  hex: string;
21
28
  rgb: RgbColor;
@@ -42,18 +49,7 @@ interface NearestPalette<F extends OutputFormat> {
42
49
  }
43
50
  //#endregion
44
51
  //#region src/palette/constant.d.ts
45
- /**
46
- * TailwindCSS v4 official oklch palette data
47
- *
48
- * the format is `oklch` string, like `oklch(98.4% 0.003 247.858)`
49
- */
50
52
  declare const tailwindPalette: TailwindPalette;
51
- /**
52
- * TailwindCSS v4 official hsl palette data
53
- *
54
- * the format is hsl string, like `hsl(210.003 34.547% 98.004%)`
55
- */
56
- declare const tailwindPaletteHsl: TailwindPalette;
57
53
  //#endregion
58
54
  //#region src/palette/generate.d.ts
59
55
  /**
@@ -62,7 +58,7 @@ declare const tailwindPaletteHsl: TailwindPalette;
62
58
  * @param [format] - the format of the output color, default is 'oklch'
63
59
  * @returns the palette
64
60
  */
65
- declare function generatePalette<F extends OutputFormat>(input: AnyColor, format?: F): Record<PaletteColorLevel, OutputColorMap[F]>;
61
+ declare function generatePalette<F extends OutputFormat = 'oklch'>(input: AnyColor, format?: F): Record<PaletteColorLevel, OutputColorMap[F]>;
66
62
  //#endregion
67
63
  //#region src/palette/nearest.d.ts
68
64
  /**
@@ -73,4 +69,4 @@ declare function generatePalette<F extends OutputFormat>(input: AnyColor, format
73
69
  */
74
70
  declare function generateNearestPalette<F extends OutputFormat>(input: AnyColor, format?: F): NearestPalette<F>;
75
71
  //#endregion
76
- export { type PaletteColorLevel, type TailwindPaletteKey, type TailwindPaletteLevelColorKey, generateNearestPalette, generatePalette, tailwindPalette, tailwindPaletteHsl };
72
+ export { type PaletteColorLevel, type TailwindPaletteKey, type TailwindPaletteLevelColorKey, generateNearestPalette, generatePalette, tailwindPalette };