@solid-primitives/utils 7.0.0-next.1 → 7.0.0-next.3

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.
@@ -1,46 +1,51 @@
1
- import type { ColorChannel, ColorSpace, Color as IColor } from "./types.js";
1
+ /* @ts-self-types="./helpers.d.ts" */
2
+ import { Color, ColorChannel, ColorSpace } from "./types.js";
3
+
4
+ //#region src/colors/helpers.d.ts
2
5
  /**
3
- * Parses a color string into a {@link Color} object.
4
- *
5
- * Supported formats:
6
- * - **Hex**: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`
7
- * - **RGB**: `rgb(r g b)`, `rgb(r, g, b)`, `rgb(r g b / a)`, `rgba(r, g, b, a)`
8
- * - **HSL**: `hsl(h, s%, l%)`, `hsla(h, s%, l%, a)`
9
- * - **HSB**: `hsb(h, s%, b%)`, `hsba(h, s%, b%, a)`
10
- *
11
- * @throws if the string does not match any supported format.
12
- *
13
- * @example
14
- * ```ts
15
- * const color = parseColor("#3264C8");
16
- * color.toString("hsl"); // "hsl(220 60% 49.02%)"
17
- * ```
18
- */
19
- export declare function parseColor(value: string): IColor;
6
+ * Parses a color string into a {@link Color} object.
7
+ *
8
+ * Supported formats:
9
+ * - **Hex**: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`
10
+ * - **RGB**: `rgb(r g b)`, `rgb(r, g, b)`, `rgb(r g b / a)`, `rgba(r, g, b, a)`
11
+ * - **HSL**: `hsl(h, s%, l%)`, `hsla(h, s%, l%, a)`
12
+ * - **HSB**: `hsb(h, s%, b%)`, `hsba(h, s%, b%, a)`
13
+ *
14
+ * @throws if the string does not match any supported format.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const color = parseColor("#3264C8");
19
+ * color.toString("hsl"); // "hsl(220 60% 49.02%)"
20
+ * ```
21
+ */
22
+ declare function parseColor(value: string): Color;
20
23
  /**
21
- * Accepts either a color string or an existing {@link Color} and always returns a `Color`.
22
- * Useful for normalizing props that accept both forms.
23
- */
24
- export declare function normalizeColor(v: string | IColor): IColor;
24
+ * Accepts either a color string or an existing {@link Color} and always returns a `Color`.
25
+ * Useful for normalizing props that accept both forms.
26
+ */
27
+ declare function normalizeColor(v: string | Color): Color;
25
28
  /**
26
- * Returns the ordered channel triple for a given color space.
27
- *
28
- * - `"rgb"` → `["red", "green", "blue"]`
29
- * - `"hsl"` → `["hue", "saturation", "lightness"]`
30
- * - `"hsb"` → `["hue", "saturation", "brightness"]`
31
- */
32
- export declare function getColorChannels(colorSpace: ColorSpace): [ColorChannel, ColorChannel, ColorChannel];
29
+ * Returns the ordered channel triple for a given color space.
30
+ *
31
+ * - `"rgb"` → `["red", "green", "blue"]`
32
+ * - `"hsl"` → `["hue", "saturation", "lightness"]`
33
+ * - `"hsb"` → `["hue", "saturation", "brightness"]`
34
+ */
35
+ declare function getColorChannels(colorSpace: ColorSpace): [ColorChannel, ColorChannel, ColorChannel];
33
36
  /**
34
- * Normalizes a hue angle to the range `[0, 360]`.
35
- * Exactly `360` is kept as-is so that a full-circle endpoint stays distinct from `0`.
36
- */
37
- export declare function normalizeHue(hue: number): number;
37
+ * Normalizes a hue angle to the range `[0, 360]`.
38
+ * Exactly `360` is kept as-is so that a full-circle endpoint stays distinct from `0`.
39
+ */
40
+ declare function normalizeHue(hue: number): number;
38
41
  /**
39
- * Converts any {@link Color} to OKLCH `[L, C, H]` — a perceptually uniform space
40
- * where L is perceived lightness (0–1), C is chroma (≥ 0), and H is a hue angle (0–360).
41
- *
42
- * Full pipeline: sRGB bytes → linear sRGB (gamma-expand) → CIE XYZ D65 → OKLab → OKLCH.
43
- *
44
- * @see https://www.w3.org/TR/css-color-4/#color-conversion-code
45
- */
46
- export declare function colorToOKLCH(color: IColor): [l: number, c: number, h: number];
42
+ * Converts any {@link Color} to OKLCH `[L, C, H]` — a perceptually uniform space
43
+ * where L is perceived lightness (0–1), C is chroma (≥ 0), and H is a hue angle (0–360).
44
+ *
45
+ * Full pipeline: sRGB bytes → linear sRGB (gamma-expand) → CIE XYZ D65 → OKLab → OKLCH.
46
+ *
47
+ * @see https://www.w3.org/TR/css-color-4/#color-conversion-code
48
+ */
49
+ declare function colorToOKLCH(color: Color): [l: number, c: number, h: number];
50
+ //#endregion
51
+ export { colorToOKLCH, getColorChannels, normalizeColor, normalizeHue, parseColor };