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

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/README.md CHANGED
@@ -155,6 +155,19 @@ const [count, setCount, data] = wrapSetter(
155
155
  );
156
156
  ```
157
157
 
158
+ ## createServerSafeSignal
159
+
160
+ `createSignal` on the client; a plain mutable box on the server.
161
+
162
+ Solid 2 flags a setter that runs during a server render (`SERVER_WRITE` — the write is inert today and throws in a later release): server render is pure, state enters through async sources. Primitives that hold _interactive_ state (a cursor, a toggle, a controlled value) have no async source, so on the server they keep a plain value instead. Reads and updater-form writes behave the same within a request; nothing touches the reactive graph. The signal is still _created_ on the server so hydration ids stay aligned with the client — it is just never read or written there.
163
+
164
+ ```ts
165
+ import { createServerSafeSignal } from "@solid-primitives/utils";
166
+
167
+ const [cursor, setCursor] = createServerSafeSignal<string | undefined>(undefined);
168
+ setCursor("b"); // a signal write in the browser, a plain assignment on the server
169
+ ```
170
+
158
171
  ## Color utilities
159
172
 
160
173
  Multi-format color parsing, conversion, and accessibility naming — available as a separate subpath so you only pay for what you use.
@@ -1,51 +1,49 @@
1
1
  /* @ts-self-types="./helpers.d.ts" */
2
2
  import { Color, ColorChannel, ColorSpace } from "./types.js";
3
-
4
3
  //#region src/colors/helpers.d.ts
5
4
  /**
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;
5
+ * Parses a color string into a {@link Color} object.
6
+ *
7
+ * Supported formats:
8
+ * - **Hex**: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`
9
+ * - **RGB**: `rgb(r g b)`, `rgb(r, g, b)`, `rgb(r g b / a)`, `rgba(r, g, b, a)`
10
+ * - **HSL**: `hsl(h, s%, l%)`, `hsla(h, s%, l%, a)`
11
+ * - **HSB**: `hsb(h, s%, b%)`, `hsba(h, s%, b%, a)`
12
+ *
13
+ * @throws if the string does not match any supported format.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const color = parseColor("#3264C8");
18
+ * color.toString("hsl"); // "hsl(220 60% 49.02%)"
19
+ * ```
20
+ */
21
+ export declare function parseColor(value: string): Color;
23
22
  /**
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;
23
+ * Accepts either a color string or an existing {@link Color} and always returns a `Color`.
24
+ * Useful for normalizing props that accept both forms.
25
+ */
26
+ export declare function normalizeColor(v: string | Color): Color;
28
27
  /**
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];
28
+ * Returns the ordered channel triple for a given color space.
29
+ *
30
+ * - `"rgb"` → `["red", "green", "blue"]`
31
+ * - `"hsl"` → `["hue", "saturation", "lightness"]`
32
+ * - `"hsb"` → `["hue", "saturation", "brightness"]`
33
+ */
34
+ export declare function getColorChannels(colorSpace: ColorSpace): [ColorChannel, ColorChannel, ColorChannel];
36
35
  /**
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;
36
+ * Normalizes a hue angle to the range `[0, 360]`.
37
+ * Exactly `360` is kept as-is so that a full-circle endpoint stays distinct from `0`.
38
+ */
39
+ export declare function normalizeHue(hue: number): number;
41
40
  /**
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 };
41
+ * Converts any {@link Color} to OKLCH `[L, C, H]` — a perceptually uniform space
42
+ * where L is perceived lightness (0–1), C is chroma (≥ 0), and H is a hue angle (0–360).
43
+ *
44
+ * Full pipeline: sRGB bytes → linear sRGB (gamma-expand) → CIE XYZ D65 → OKLab → OKLCH.
45
+ *
46
+ * @see https://www.w3.org/TR/css-color-4/#color-conversion-code
47
+ */
48
+ export declare function colorToOKLCH(color: Color): [l: number, c: number, h: number];
49
+ //#endregion
@@ -194,8 +194,10 @@ var Color = class {
194
194
  let hueName = OKLCH_HUES[i][1];
195
195
  const [nextHue, nextHueName] = OKLCH_HUES[i + 1] || [360, "pink"];
196
196
  if (h >= hue && h < nextHue) {
197
- if (hueName === "orange") if (l < ORANGE_LIGHTNESS_THRESHOLD) hueName = "brown";
198
- else l = l - ORANGE_LIGHTNESS_THRESHOLD + MAX_DARK_LIGHTNESS;
197
+ if (hueName === "orange") {
198
+ if (l < ORANGE_LIGHTNESS_THRESHOLD) hueName = "brown";
199
+ else l = l - ORANGE_LIGHTNESS_THRESHOLD + MAX_DARK_LIGHTNESS;
200
+ }
199
201
  if (h > hue + (nextHue - hue) / 2 && hueName !== nextHueName) hueName = `${hueName} ${nextHueName}`;
200
202
  else if (hueName === "yellow" && l < YELLOW_GREEN_LIGHTNESS_THRESHOLD) hueName = "yellow green";
201
203
  return [translations[hueName], l];
@@ -322,9 +324,7 @@ var RGBColor = class RGBColor extends Color {
322
324
  case green:
323
325
  hue = (blue - red) / chroma + 2;
324
326
  break;
325
- case blue:
326
- hue = (red - green) / chroma + 4;
327
- break;
327
+ case blue: hue = (red - green) / chroma + 4;
328
328
  }
329
329
  hue /= 6;
330
330
  }
@@ -356,9 +356,7 @@ var RGBColor = class RGBColor extends Color {
356
356
  case green:
357
357
  hue = (blue - red) / chroma + 2;
358
358
  break;
359
- default:
360
- hue = (red - green) / chroma + 4;
361
- break;
359
+ default: hue = (red - green) / chroma + 4;
362
360
  }
363
361
  hue /= 6;
364
362
  }
@@ -1,20 +1,20 @@
1
1
  /* @ts-self-types="./intl.d.ts" */
2
2
  //#region src/colors/intl.d.ts
3
3
  /**
4
- * Default English translations for color channel names, descriptors, and hue families.
5
- * Pass this object (or a translated equivalent) to {@link Color.getColorName} and
6
- * {@link Color.getHueName} to produce human-readable, accessible color labels.
7
- *
8
- * @example
9
- * ```ts
10
- * import { parseColor, COLOR_INTL_TRANSLATIONS } from "@solid-primitives/utils/colors";
11
- *
12
- * const color = parseColor("hsl(220 60% 49%)");
13
- * color.getColorName(COLOR_INTL_TRANSLATIONS); // "dark vibrant blue"
14
- * color.getHueName(COLOR_INTL_TRANSLATIONS); // "blue"
15
- * ```
16
- */
17
- declare const COLOR_INTL_TRANSLATIONS: {
4
+ * Default English translations for color channel names, descriptors, and hue families.
5
+ * Pass this object (or a translated equivalent) to {@link Color.getColorName} and
6
+ * {@link Color.getHueName} to produce human-readable, accessible color labels.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { parseColor, COLOR_INTL_TRANSLATIONS } from "@solid-primitives/utils/colors";
11
+ *
12
+ * const color = parseColor("hsl(220 60% 49%)");
13
+ * color.getColorName(COLOR_INTL_TRANSLATIONS); // "dark vibrant blue"
14
+ * color.getHueName(COLOR_INTL_TRANSLATIONS); // "blue"
15
+ * ```
16
+ */
17
+ export declare const COLOR_INTL_TRANSLATIONS: {
18
18
  hue: string;
19
19
  saturation: string;
20
20
  lightness: string;
@@ -53,6 +53,5 @@ declare const COLOR_INTL_TRANSLATIONS: {
53
53
  magenta: string;
54
54
  "magenta pink": string;
55
55
  };
56
- type ColorIntlTranslations = typeof COLOR_INTL_TRANSLATIONS;
57
- //#endregion
58
- export { COLOR_INTL_TRANSLATIONS, ColorIntlTranslations };
56
+ export type ColorIntlTranslations = typeof COLOR_INTL_TRANSLATIONS;
57
+ //#endregion
@@ -1,149 +1,147 @@
1
1
  /* @ts-self-types="./manipulation.d.ts" */
2
2
  import { Color, ColorFormat } from "./types.js";
3
-
4
3
  //#region src/colors/manipulation.d.ts
5
4
  /**
6
- * Like {@link parseColor} but returns `undefined` instead of throwing for invalid input.
7
- *
8
- * @example
9
- * ```ts
10
- * tryParseColor("#3264C8") // Color
11
- * tryParseColor("nope") // undefined
12
- * ```
13
- */
14
- declare function tryParseColor(value: string): Color | undefined;
5
+ * Like {@link parseColor} but returns `undefined` instead of throwing for invalid input.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * tryParseColor("#3264C8") // Color
10
+ * tryParseColor("nope") // undefined
11
+ * ```
12
+ */
13
+ export declare function tryParseColor(value: string): Color | undefined;
15
14
  /**
16
- * Returns `true` if `value` is a parseable color string.
17
- *
18
- * @example
19
- * ```ts
20
- * isValidColor("#3264C8") // true
21
- * isValidColor("nope") // false
22
- * ```
23
- */
24
- declare function isValidColor(value: string): boolean;
15
+ * Returns `true` if `value` is a parseable color string.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * isValidColor("#3264C8") // true
20
+ * isValidColor("nope") // false
21
+ * ```
22
+ */
23
+ export declare function isValidColor(value: string): boolean;
25
24
  /**
26
- * Detects the format of a color string without parsing it.
27
- * Returns `undefined` for strings that do not match any known format.
28
- *
29
- * The returned format reflects the **syntax** of the string (e.g. `"rgb"` for
30
- * `rgb(...)` even if an alpha channel is present via slash notation).
31
- *
32
- * @example
33
- * ```ts
34
- * detectColorFormat("#3264C8") // "hex"
35
- * detectColorFormat("#3264C8FF") // "hexa"
36
- * detectColorFormat("rgb(50, 100, 200)") // "rgb"
37
- * detectColorFormat("hsla(220, 60%, 49%, 0.5)") // "hsla"
38
- * detectColorFormat("nope") // undefined
39
- * ```
40
- */
41
- declare function detectColorFormat(value: string): ColorFormat | undefined;
25
+ * Detects the format of a color string without parsing it.
26
+ * Returns `undefined` for strings that do not match any known format.
27
+ *
28
+ * The returned format reflects the **syntax** of the string (e.g. `"rgb"` for
29
+ * `rgb(...)` even if an alpha channel is present via slash notation).
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * detectColorFormat("#3264C8") // "hex"
34
+ * detectColorFormat("#3264C8FF") // "hexa"
35
+ * detectColorFormat("rgb(50, 100, 200)") // "rgb"
36
+ * detectColorFormat("hsla(220, 60%, 49%, 0.5)") // "hsla"
37
+ * detectColorFormat("nope") // undefined
38
+ * ```
39
+ */
40
+ export declare function detectColorFormat(value: string): ColorFormat | undefined;
42
41
  /**
43
- * Returns a new color with lightness increased by `amount` (0–1 ratio = percentage points).
44
- * Operates in HSL space; the returned color is in HSL.
45
- *
46
- * @example
47
- * ```ts
48
- * lighten(parseColor("hsl(220, 60%, 50%)"), 0.1).getChannelValue("lightness") // 60
49
- * ```
50
- */
51
- declare function lighten(color: Color, amount: number): Color;
42
+ * Returns a new color with lightness increased by `amount` (0–1 ratio = percentage points).
43
+ * Operates in HSL space; the returned color is in HSL.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * lighten(parseColor("hsl(220, 60%, 50%)"), 0.1).getChannelValue("lightness") // 60
48
+ * ```
49
+ */
50
+ export declare function lighten(color: Color, amount: number): Color;
52
51
  /**
53
- * Returns a new color with lightness decreased by `amount` (0–1 ratio = percentage points).
54
- * Operates in HSL space; the returned color is in HSL.
55
- */
56
- declare function darken(color: Color, amount: number): Color;
52
+ * Returns a new color with lightness decreased by `amount` (0–1 ratio = percentage points).
53
+ * Operates in HSL space; the returned color is in HSL.
54
+ */
55
+ export declare function darken(color: Color, amount: number): Color;
57
56
  /**
58
- * Returns a new color with saturation increased by `amount` (0–1 ratio = percentage points).
59
- * Operates in HSL space; the returned color is in HSL.
60
- */
61
- declare function saturate(color: Color, amount: number): Color;
57
+ * Returns a new color with saturation increased by `amount` (0–1 ratio = percentage points).
58
+ * Operates in HSL space; the returned color is in HSL.
59
+ */
60
+ export declare function saturate(color: Color, amount: number): Color;
62
61
  /**
63
- * Returns a new color with saturation decreased by `amount` (0–1 ratio = percentage points).
64
- * Operates in HSL space; the returned color is in HSL.
65
- */
66
- declare function desaturate(color: Color, amount: number): Color;
62
+ * Returns a new color with saturation decreased by `amount` (0–1 ratio = percentage points).
63
+ * Operates in HSL space; the returned color is in HSL.
64
+ */
65
+ export declare function desaturate(color: Color, amount: number): Color;
67
66
  /**
68
- * Returns the complementary color (hue rotated 180°), preserving saturation, lightness, and alpha.
69
- * The returned color is in HSL.
70
- *
71
- * @example
72
- * ```ts
73
- * complement(parseColor("hsl(60, 50%, 50%)")).getChannelValue("hue") // 240
74
- * ```
75
- */
76
- declare function complement(color: Color): Color;
67
+ * Returns the complementary color (hue rotated 180°), preserving saturation, lightness, and alpha.
68
+ * The returned color is in HSL.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * complement(parseColor("hsl(60, 50%, 50%)")).getChannelValue("hue") // 240
73
+ * ```
74
+ */
75
+ export declare function complement(color: Color): Color;
77
76
  /**
78
- * Mixes two colors in RGB space at the given `ratio` (0 = fully `a`, 1 = fully `b`).
79
- * Alpha is also interpolated. The returned color is in RGB.
80
- *
81
- * @example
82
- * ```ts
83
- * mix(parseColor("#000000"), parseColor("#ffffff")).toString("hex") // "#808080"
84
- * mix(parseColor("#000000"), parseColor("#ffffff"), 0.25).toString("hex") // "#404040"
85
- * ```
86
- */
87
- declare function mix(a: Color, b: Color, ratio?: number): Color;
77
+ * Mixes two colors in RGB space at the given `ratio` (0 = fully `a`, 1 = fully `b`).
78
+ * Alpha is also interpolated. The returned color is in RGB.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * mix(parseColor("#000000"), parseColor("#ffffff")).toString("hex") // "#808080"
83
+ * mix(parseColor("#000000"), parseColor("#ffffff"), 0.25).toString("hex") // "#404040"
84
+ * ```
85
+ */
86
+ export declare function mix(a: Color, b: Color, ratio?: number): Color;
88
87
  /**
89
- * Returns the WCAG 2.1 contrast ratio between two colors (1–21).
90
- * The order of arguments does not matter.
91
- *
92
- * - Black on white: `21`
93
- * - Same color: `1`
94
- *
95
- * @example
96
- * ```ts
97
- * contrastRatio(parseColor("#000"), parseColor("#fff")) // 21
98
- * ```
99
- */
100
- declare function contrastRatio(a: Color, b: Color): number;
88
+ * Returns the WCAG 2.1 contrast ratio between two colors (1–21).
89
+ * The order of arguments does not matter.
90
+ *
91
+ * - Black on white: `21`
92
+ * - Same color: `1`
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * contrastRatio(parseColor("#000"), parseColor("#fff")) // 21
97
+ * ```
98
+ */
99
+ export declare function contrastRatio(a: Color, b: Color): number;
101
100
  /**
102
- * Returns whether the contrast between `foreground` and `background` meets the
103
- * specified WCAG 2.1 conformance level and text size.
104
- *
105
- * | Level | Normal text | Large text (≥18pt / ≥14pt bold) |
106
- * |-------|-------------|----------------------------------|
107
- * | AA | 4.5 : 1 | 3 : 1 |
108
- * | AAA | 7 : 1 | 4.5 : 1 |
109
- *
110
- * @example
111
- * ```ts
112
- * isReadable(parseColor("#fff"), parseColor("#000")) // true (AA, normal)
113
- * isReadable(parseColor("#fff"), parseColor("#000"), "AAA") // true
114
- * isReadable(parseColor("#777"), parseColor("#fff"), "AAA") // false
115
- * ```
116
- */
117
- declare function isReadable(foreground: Color, background: Color, level?: "AA" | "AAA", size?: "normal" | "large"): boolean;
101
+ * Returns whether the contrast between `foreground` and `background` meets the
102
+ * specified WCAG 2.1 conformance level and text size.
103
+ *
104
+ * | Level | Normal text | Large text (≥18pt / ≥14pt bold) |
105
+ * |-------|-------------|----------------------------------|
106
+ * | AA | 4.5 : 1 | 3 : 1 |
107
+ * | AAA | 7 : 1 | 4.5 : 1 |
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * isReadable(parseColor("#fff"), parseColor("#000")) // true (AA, normal)
112
+ * isReadable(parseColor("#fff"), parseColor("#000"), "AAA") // true
113
+ * isReadable(parseColor("#777"), parseColor("#fff"), "AAA") // false
114
+ * ```
115
+ */
116
+ export declare function isReadable(foreground: Color, background: Color, level?: "AA" | "AAA", size?: "normal" | "large"): boolean;
118
117
  /**
119
- * Returns an array of `steps` colors linearly interpolated in RGB space between
120
- * `from` and `to`. The first element is `from`, the last is `to`.
121
- *
122
- * @throws if `steps` is not a finite integer >= 2.
123
- *
124
- * @example
125
- * ```ts
126
- * colorScale(parseColor("#000"), parseColor("#fff"), 3)
127
- * // [#000000, #808080, #FFFFFF]
128
- * ```
129
- */
130
- declare function colorScale(from: Color, to: Color, steps: number): Color[];
118
+ * Returns an array of `steps` colors linearly interpolated in RGB space between
119
+ * `from` and `to`. The first element is `from`, the last is `to`.
120
+ *
121
+ * @throws if `steps` is not a finite integer >= 2.
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * colorScale(parseColor("#000"), parseColor("#fff"), 3)
126
+ * // [#000000, #808080, #FFFFFF]
127
+ * ```
128
+ */
129
+ export declare function colorScale(from: Color, to: Color, steps: number): Color[];
131
130
  /**
132
- * Returns an array of `steps` colors interpolated in OKLCH space between `from` and `to`.
133
- * OKLCH is a perceptually uniform color space, so the steps appear more evenly distributed
134
- * to the human eye than a plain RGB scale.
135
- *
136
- * Hue interpolation takes the shortest arc around the color wheel.
137
- * Alpha is linearly interpolated. The returned colors are in RGB.
138
- *
139
- * @throws if `steps` is not a finite integer >= 2.
140
- *
141
- * @example
142
- * ```ts
143
- * // A scale from red to blue that passes through purple rather than through green
144
- * perceptualColorScale(parseColor("hsl(0, 80%, 50%)"), parseColor("hsl(240, 80%, 50%)"), 5)
145
- * ```
146
- */
147
- declare function perceptualColorScale(from: Color, to: Color, steps: number): Color[];
148
- //#endregion
149
- export { colorScale, complement, contrastRatio, darken, desaturate, detectColorFormat, isReadable, isValidColor, lighten, mix, perceptualColorScale, saturate, tryParseColor };
131
+ * Returns an array of `steps` colors interpolated in OKLCH space between `from` and `to`.
132
+ * OKLCH is a perceptually uniform color space, so the steps appear more evenly distributed
133
+ * to the human eye than a plain RGB scale.
134
+ *
135
+ * Hue interpolation takes the shortest arc around the color wheel.
136
+ * Alpha is linearly interpolated. The returned colors are in RGB.
137
+ *
138
+ * @throws if `steps` is not a finite integer >= 2.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * // A scale from red to blue that passes through purple rather than through green
143
+ * perceptualColorScale(parseColor("hsl(0, 80%, 50%)"), parseColor("hsl(240, 80%, 50%)"), 5)
144
+ * ```
145
+ */
146
+ export declare function perceptualColorScale(from: Color, to: Color, steps: number): Color[];
147
+ //#endregion
@@ -1,21 +1,20 @@
1
1
  /* @ts-self-types="./types.d.ts" */
2
2
  import { ColorIntlTranslations } from "./intl.js";
3
-
4
3
  //#region src/colors/types.d.ts
5
4
  /** Supported color string formats. Formats without an `a` suffix treat alpha as fully opaque. */
6
- type ColorFormat = "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "hsb" | "hsba";
5
+ export type ColorFormat = "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "hsb" | "hsba";
7
6
  /** The three supported color spaces. */
8
- type ColorSpace = "rgb" | "hsl" | "hsb";
7
+ export type ColorSpace = "rgb" | "hsl" | "hsb";
9
8
  /** Individual channel names across all supported color spaces. */
10
- type ColorChannel = "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha";
9
+ export type ColorChannel = "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha";
11
10
  /** Maps x/y/z axes to {@link ColorChannel} names for 2D color gradient pickers. */
12
- type ColorAxes = {
11
+ export type ColorAxes = {
13
12
  xChannel: ColorChannel;
14
13
  yChannel: ColorChannel;
15
14
  zChannel: ColorChannel;
16
15
  };
17
16
  /** Numeric constraints for a single color channel, used to drive sliders and steppers. */
18
- interface ColorChannelRange {
17
+ export interface ColorChannelRange {
19
18
  /** Minimum value of the channel. */
20
19
  minValue: number;
21
20
  /** Maximum value of the channel. */
@@ -26,28 +25,28 @@ interface ColorChannelRange {
26
25
  pageSize: number;
27
26
  }
28
27
  /** Represents an immutable color value. All mutation methods return a new `Color` instance. */
29
- interface Color {
28
+ export interface Color {
30
29
  /** Returns a new `Color` converted to `format`. */
31
30
  toFormat(format: ColorFormat): Color;
32
31
  /**
33
- * Serializes the color to a CSS string.
34
- * Defaults to `"css"` which produces the most browser-compatible form for each space
35
- * (`rgb(...)`, `hsla(...)`, etc.).
36
- */
32
+ * Serializes the color to a CSS string.
33
+ * Defaults to `"css"` which produces the most browser-compatible form for each space
34
+ * (`rgb(...)`, `hsla(...)`, etc.).
35
+ */
37
36
  toString(format?: ColorFormat | "css"): string;
38
37
  /** Returns a deep clone of this color. */
39
38
  clone(): Color;
40
39
  /** Returns the RGB integer representation (`0xRRGGBB`), ignoring alpha. */
41
40
  toHexInt(): number;
42
41
  /**
43
- * Returns the numeric value for `channel`.
44
- * @throws if `channel` is not part of this color's space.
45
- */
42
+ * Returns the numeric value for `channel`.
43
+ * @throws if `channel` is not part of this color's space.
44
+ */
46
45
  getChannelValue(channel: ColorChannel): number;
47
46
  /**
48
- * Returns a new `Color` with `channel` set to `value`.
49
- * @throws if `channel` is not part of this color's space.
50
- */
47
+ * Returns a new `Color` with `channel` set to `value`.
48
+ * @throws if `channel` is not part of this color's space.
49
+ */
51
50
  withChannelValue(channel: ColorChannel, value: number): Color;
52
51
  /** Returns the {@link ColorChannelRange} for `channel` in this color space. */
53
52
  getChannelRange(channel: ColorChannel): ColorChannelRange;
@@ -60,10 +59,10 @@ interface Color {
60
59
  /** Returns the color space this color lives in. */
61
60
  getColorSpace(): ColorSpace;
62
61
  /**
63
- * Resolves the x/y/z channel assignment for a 2D color area picker.
64
- * Pass `xChannel` and/or `yChannel` to fix specific axes; the remaining
65
- * channel is inferred as the z axis.
66
- */
62
+ * Resolves the x/y/z channel assignment for a 2D color area picker.
63
+ * Pass `xChannel` and/or `yChannel` to fix specific axes; the remaining
64
+ * channel is inferred as the z axis.
65
+ */
67
66
  getColorSpaceAxes(xyChannels: {
68
67
  xChannel?: ColorChannel;
69
68
  yChannel?: ColorChannel;
@@ -71,12 +70,11 @@ interface Color {
71
70
  /** Returns the three channel names for this color's space, in display order. */
72
71
  getColorChannels(): [ColorChannel, ColorChannel, ColorChannel];
73
72
  /**
74
- * Returns a human-readable color name derived from OKLCH analysis
75
- * (e.g. `"dark vibrant blue"`, `"pale cyan, 20% transparent"`).
76
- */
73
+ * Returns a human-readable color name derived from OKLCH analysis
74
+ * (e.g. `"dark vibrant blue"`, `"pale cyan, 20% transparent"`).
75
+ */
77
76
  getColorName(translations: ColorIntlTranslations): string;
78
77
  /** Returns just the hue family name (e.g. `"blue"`, `"orange yellow"`). */
79
78
  getHueName(translations: ColorIntlTranslations): string;
80
79
  }
81
- //#endregion
82
- export { Color, ColorAxes, ColorChannel, ColorChannelRange, ColorFormat, ColorSpace };
80
+ //#endregion