@solid-primitives/utils 7.0.0-next.1 → 7.0.0-next.2
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/colors/helpers.d.ts +46 -41
- package/dist/colors/helpers.js +776 -851
- package/dist/colors/index.d.ts +6 -4
- package/dist/colors/index.js +5 -4
- package/dist/colors/intl.d.ts +56 -52
- package/dist/colors/intl.js +55 -66
- package/dist/colors/manipulation.d.ts +136 -131
- package/dist/colors/manipulation.js +215 -242
- package/dist/colors/types.d.ts +73 -68
- package/dist/colors/types.js +1 -14
- package/dist/immutable/array.d.ts +113 -108
- package/dist/immutable/array.js +122 -128
- package/dist/immutable/copy.d.ts +25 -21
- package/dist/immutable/copy.js +31 -29
- package/dist/immutable/index.d.ts +8 -6
- package/dist/immutable/index.js +7 -6
- package/dist/immutable/number.d.ts +11 -7
- package/dist/immutable/number.js +21 -27
- package/dist/immutable/object.d.ts +55 -58
- package/dist/immutable/object.js +46 -48
- package/dist/immutable/types.d.ts +9 -7
- package/dist/immutable/types.js +1 -1
- package/dist/immutable/update.d.ts +33 -28
- package/dist/immutable/update.js +27 -27
- package/dist/index.d.ts +225 -223
- package/dist/index.js +283 -315
- package/dist/types.d.ts +63 -75
- package/dist/types.js +1 -1
- package/package.json +11 -7
package/dist/colors/helpers.d.ts
CHANGED
|
@@ -1,46 +1,51 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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 };
|