@ansh-ui/core 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.
- package/LICENSE +21 -0
- package/dist/behaviours.cjs +64 -0
- package/dist/behaviours.cjs.map +1 -0
- package/dist/behaviours.d.cts +3 -0
- package/dist/behaviours.d.ts +3 -0
- package/dist/behaviours.js +7 -0
- package/dist/behaviours.js.map +1 -0
- package/dist/chunk-23GSSIMK.cjs +439 -0
- package/dist/chunk-23GSSIMK.cjs.map +1 -0
- package/dist/chunk-56NNBIAO.js +2446 -0
- package/dist/chunk-56NNBIAO.js.map +1 -0
- package/dist/chunk-6PFYGJWD.cjs +136 -0
- package/dist/chunk-6PFYGJWD.cjs.map +1 -0
- package/dist/chunk-7MEIXWPH.js +313 -0
- package/dist/chunk-7MEIXWPH.js.map +1 -0
- package/dist/chunk-7MYTSAPR.js +83 -0
- package/dist/chunk-7MYTSAPR.js.map +1 -0
- package/dist/chunk-BOQQHICI.js +1036 -0
- package/dist/chunk-BOQQHICI.js.map +1 -0
- package/dist/chunk-C6XPQO2O.js +1170 -0
- package/dist/chunk-C6XPQO2O.js.map +1 -0
- package/dist/chunk-DXJ63QAR.cjs +723 -0
- package/dist/chunk-DXJ63QAR.cjs.map +1 -0
- package/dist/chunk-FAVIEION.js +705 -0
- package/dist/chunk-FAVIEION.js.map +1 -0
- package/dist/chunk-FNR35HTL.cjs +107 -0
- package/dist/chunk-FNR35HTL.cjs.map +1 -0
- package/dist/chunk-GHBRGMSO.cjs +91 -0
- package/dist/chunk-GHBRGMSO.cjs.map +1 -0
- package/dist/chunk-GJRIHN76.cjs +359 -0
- package/dist/chunk-GJRIHN76.cjs.map +1 -0
- package/dist/chunk-ILKUL7GD.cjs +115 -0
- package/dist/chunk-ILKUL7GD.cjs.map +1 -0
- package/dist/chunk-KTUBCQC3.js +409 -0
- package/dist/chunk-KTUBCQC3.js.map +1 -0
- package/dist/chunk-KU2C6GEA.js +90 -0
- package/dist/chunk-KU2C6GEA.js.map +1 -0
- package/dist/chunk-LGA3N3YJ.cjs +413 -0
- package/dist/chunk-LGA3N3YJ.cjs.map +1 -0
- package/dist/chunk-MMO7KO53.cjs +1060 -0
- package/dist/chunk-MMO7KO53.cjs.map +1 -0
- package/dist/chunk-NSXKCJJ7.js +109 -0
- package/dist/chunk-NSXKCJJ7.js.map +1 -0
- package/dist/chunk-QALZKHWH.js +387 -0
- package/dist/chunk-QALZKHWH.js.map +1 -0
- package/dist/chunk-R7UJ7MWP.cjs +2479 -0
- package/dist/chunk-R7UJ7MWP.cjs.map +1 -0
- package/dist/chunk-UJBXY6QC.cjs +1186 -0
- package/dist/chunk-UJBXY6QC.cjs.map +1 -0
- package/dist/chunk-YFQXRC5R.js +99 -0
- package/dist/chunk-YFQXRC5R.js.map +1 -0
- package/dist/color.cjs +257 -0
- package/dist/color.cjs.map +1 -0
- package/dist/color.d.cts +303 -0
- package/dist/color.d.ts +303 -0
- package/dist/color.js +8 -0
- package/dist/color.js.map +1 -0
- package/dist/easing.cjs +189 -0
- package/dist/easing.cjs.map +1 -0
- package/dist/easing.d.cts +134 -0
- package/dist/easing.d.ts +134 -0
- package/dist/easing.js +4 -0
- package/dist/easing.js.map +1 -0
- package/dist/effects.cjs +99 -0
- package/dist/effects.cjs.map +1 -0
- package/dist/effects.d.cts +5 -0
- package/dist/effects.d.ts +5 -0
- package/dist/effects.js +10 -0
- package/dist/effects.js.map +1 -0
- package/dist/index-CCdpefMp.d.ts +967 -0
- package/dist/index-CQEEPu-D.d.ts +435 -0
- package/dist/index-DHOfsEIn.d.cts +967 -0
- package/dist/index-Dl8GCsya.d.cts +435 -0
- package/dist/index.cjs +2206 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1122 -0
- package/dist/index.d.ts +1122 -0
- package/dist/index.js +1182 -0
- package/dist/index.js.map +1 -0
- package/dist/math.cjs +238 -0
- package/dist/math.cjs.map +1 -0
- package/dist/math.d.cts +120 -0
- package/dist/math.d.ts +120 -0
- package/dist/math.js +5 -0
- package/dist/math.js.map +1 -0
- package/dist/noise.cjs +78 -0
- package/dist/noise.cjs.map +1 -0
- package/dist/noise.d.cts +190 -0
- package/dist/noise.d.ts +190 -0
- package/dist/noise.js +5 -0
- package/dist/noise.js.map +1 -0
- package/dist/palette-6HkVltYU.d.cts +219 -0
- package/dist/palette-6HkVltYU.d.ts +219 -0
- package/dist/random--4mSc5Lp.d.cts +75 -0
- package/dist/random--4mSc5Lp.d.ts +75 -0
- package/dist/reduced-motion-D0LUgZle.d.cts +120 -0
- package/dist/reduced-motion-D0LUgZle.d.ts +120 -0
- package/dist/types-B1FLLf3-.d.cts +21 -0
- package/dist/types-B1FLLf3-.d.ts +21 -0
- package/package.json +78 -0
package/dist/color.cjs
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkGHBRGMSO_cjs = require('./chunk-GHBRGMSO.cjs');
|
|
4
|
+
var chunk23GSSIMK_cjs = require('./chunk-23GSSIMK.cjs');
|
|
5
|
+
require('./chunk-FNR35HTL.cjs');
|
|
6
|
+
var chunkLGA3N3YJ_cjs = require('./chunk-LGA3N3YJ.cjs');
|
|
7
|
+
require('./chunk-GJRIHN76.cjs');
|
|
8
|
+
require('./chunk-ILKUL7GD.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, "checkContrast", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkGHBRGMSO_cjs.checkContrast; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "contrastRatio", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkGHBRGMSO_cjs.contrastRatio; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "ensureContrast", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkGHBRGMSO_cjs.ensureContrast; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "perceivedLightness", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return chunkGHBRGMSO_cjs.perceivedLightness; }
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, "pickReadable", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () { return chunkGHBRGMSO_cjs.pickReadable; }
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "requiredRatio", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () { return chunkGHBRGMSO_cjs.requiredRatio; }
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "worstContrast", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () { return chunkGHBRGMSO_cjs.worstContrast; }
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(exports, "applyGradientStops", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () { return chunk23GSSIMK_cjs.applyGradientStops; }
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "blend", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () { return chunk23GSSIMK_cjs.blend; }
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "composite", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () { return chunk23GSSIMK_cjs.composite; }
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(exports, "createGradient", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () { return chunk23GSSIMK_cjs.createGradient; }
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, "createScale", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () { return chunk23GSSIMK_cjs.createScale; }
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "expandPalette", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () { return chunk23GSSIMK_cjs.expandPalette; }
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(exports, "fadeBy", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () { return chunk23GSSIMK_cjs.fadeBy; }
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, "fromUint32", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () { return chunk23GSSIMK_cjs.fromUint32; }
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "gamutError", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () { return chunk23GSSIMK_cjs.gamutError; }
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(exports, "gamutMapOklch", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () { return chunk23GSSIMK_cjs.gamutMapOklch; }
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(exports, "generatePalette", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () { return chunk23GSSIMK_cjs.generatePalette; }
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "harmony", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () { return chunk23GSSIMK_cjs.harmony; }
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(exports, "inSrgbGamut", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () { return chunk23GSSIMK_cjs.inSrgbGamut; }
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(exports, "invertForSurface", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
get: function () { return chunk23GSSIMK_cjs.invertForSurface; }
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "isGamutStable", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () { return chunk23GSSIMK_cjs.isGamutStable; }
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(exports, "lerpHue", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
get: function () { return chunk23GSSIMK_cjs.lerpHue; }
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, "maxChroma", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function () { return chunk23GSSIMK_cjs.maxChroma; }
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "mixColors", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () { return chunk23GSSIMK_cjs.mixColors; }
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(exports, "mixParsed", {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () { return chunk23GSSIMK_cjs.mixParsed; }
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(exports, "oklchToRgbMapped", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function () { return chunk23GSSIMK_cjs.oklchToRgbMapped; }
|
|
119
|
+
});
|
|
120
|
+
Object.defineProperty(exports, "palettes", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () { return chunk23GSSIMK_cjs.palettes; }
|
|
123
|
+
});
|
|
124
|
+
Object.defineProperty(exports, "resolvePalette", {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: function () { return chunk23GSSIMK_cjs.resolvePalette; }
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(exports, "sortByLightness", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
get: function () { return chunk23GSSIMK_cjs.sortByLightness; }
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(exports, "toHex", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
get: function () { return chunk23GSSIMK_cjs.toHex; }
|
|
135
|
+
});
|
|
136
|
+
Object.defineProperty(exports, "toHslString", {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
get: function () { return chunk23GSSIMK_cjs.toHslString; }
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(exports, "toOklchString", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: function () { return chunk23GSSIMK_cjs.toOklchString; }
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "toRgbString", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () { return chunk23GSSIMK_cjs.toRgbString; }
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(exports, "toUint32", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
get: function () { return chunk23GSSIMK_cjs.toUint32; }
|
|
151
|
+
});
|
|
152
|
+
Object.defineProperty(exports, "withAlpha", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
get: function () { return chunk23GSSIMK_cjs.withAlpha; }
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, "ColorParseError", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function () { return chunkLGA3N3YJ_cjs.ColorParseError; }
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(exports, "clearColorCache", {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
get: function () { return chunkLGA3N3YJ_cjs.clearColorCache; }
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(exports, "hslToRgb", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function () { return chunkLGA3N3YJ_cjs.hslToRgb; }
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, "hsvToRgb", {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function () { return chunkLGA3N3YJ_cjs.hsvToRgb; }
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(exports, "linearToOklab", {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
get: function () { return chunkLGA3N3YJ_cjs.linearToOklab; }
|
|
175
|
+
});
|
|
176
|
+
Object.defineProperty(exports, "linearToRgb", {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
get: function () { return chunkLGA3N3YJ_cjs.linearToRgb; }
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperty(exports, "linearToSrgbChannel", {
|
|
181
|
+
enumerable: true,
|
|
182
|
+
get: function () { return chunkLGA3N3YJ_cjs.linearToSrgbChannel; }
|
|
183
|
+
});
|
|
184
|
+
Object.defineProperty(exports, "listNamedColors", {
|
|
185
|
+
enumerable: true,
|
|
186
|
+
get: function () { return chunkLGA3N3YJ_cjs.listNamedColors; }
|
|
187
|
+
});
|
|
188
|
+
Object.defineProperty(exports, "namedColorToHex", {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
get: function () { return chunkLGA3N3YJ_cjs.namedColorToHex; }
|
|
191
|
+
});
|
|
192
|
+
Object.defineProperty(exports, "oklabToLinear", {
|
|
193
|
+
enumerable: true,
|
|
194
|
+
get: function () { return chunkLGA3N3YJ_cjs.oklabToLinear; }
|
|
195
|
+
});
|
|
196
|
+
Object.defineProperty(exports, "oklabToOklch", {
|
|
197
|
+
enumerable: true,
|
|
198
|
+
get: function () { return chunkLGA3N3YJ_cjs.oklabToOklch; }
|
|
199
|
+
});
|
|
200
|
+
Object.defineProperty(exports, "oklabToRgb", {
|
|
201
|
+
enumerable: true,
|
|
202
|
+
get: function () { return chunkLGA3N3YJ_cjs.oklabToRgb; }
|
|
203
|
+
});
|
|
204
|
+
Object.defineProperty(exports, "oklchToOklab", {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
get: function () { return chunkLGA3N3YJ_cjs.oklchToOklab; }
|
|
207
|
+
});
|
|
208
|
+
Object.defineProperty(exports, "oklchToRgb", {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
get: function () { return chunkLGA3N3YJ_cjs.oklchToRgb; }
|
|
211
|
+
});
|
|
212
|
+
Object.defineProperty(exports, "parseColor", {
|
|
213
|
+
enumerable: true,
|
|
214
|
+
get: function () { return chunkLGA3N3YJ_cjs.parseColor; }
|
|
215
|
+
});
|
|
216
|
+
Object.defineProperty(exports, "relativeLuminance", {
|
|
217
|
+
enumerable: true,
|
|
218
|
+
get: function () { return chunkLGA3N3YJ_cjs.relativeLuminance; }
|
|
219
|
+
});
|
|
220
|
+
Object.defineProperty(exports, "resolveComputed", {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
get: function () { return chunkLGA3N3YJ_cjs.resolveComputed; }
|
|
223
|
+
});
|
|
224
|
+
Object.defineProperty(exports, "resolveCssVariable", {
|
|
225
|
+
enumerable: true,
|
|
226
|
+
get: function () { return chunkLGA3N3YJ_cjs.resolveCssVariable; }
|
|
227
|
+
});
|
|
228
|
+
Object.defineProperty(exports, "rgbToHsl", {
|
|
229
|
+
enumerable: true,
|
|
230
|
+
get: function () { return chunkLGA3N3YJ_cjs.rgbToHsl; }
|
|
231
|
+
});
|
|
232
|
+
Object.defineProperty(exports, "rgbToHsv", {
|
|
233
|
+
enumerable: true,
|
|
234
|
+
get: function () { return chunkLGA3N3YJ_cjs.rgbToHsv; }
|
|
235
|
+
});
|
|
236
|
+
Object.defineProperty(exports, "rgbToLinear", {
|
|
237
|
+
enumerable: true,
|
|
238
|
+
get: function () { return chunkLGA3N3YJ_cjs.rgbToLinear; }
|
|
239
|
+
});
|
|
240
|
+
Object.defineProperty(exports, "rgbToOklab", {
|
|
241
|
+
enumerable: true,
|
|
242
|
+
get: function () { return chunkLGA3N3YJ_cjs.rgbToOklab; }
|
|
243
|
+
});
|
|
244
|
+
Object.defineProperty(exports, "rgbToOklch", {
|
|
245
|
+
enumerable: true,
|
|
246
|
+
get: function () { return chunkLGA3N3YJ_cjs.rgbToOklch; }
|
|
247
|
+
});
|
|
248
|
+
Object.defineProperty(exports, "srgbToLinearChannel", {
|
|
249
|
+
enumerable: true,
|
|
250
|
+
get: function () { return chunkLGA3N3YJ_cjs.srgbToLinearChannel; }
|
|
251
|
+
});
|
|
252
|
+
Object.defineProperty(exports, "tryParseColor", {
|
|
253
|
+
enumerable: true,
|
|
254
|
+
get: function () { return chunkLGA3N3YJ_cjs.tryParseColor; }
|
|
255
|
+
});
|
|
256
|
+
//# sourceMappingURL=color.cjs.map
|
|
257
|
+
//# sourceMappingURL=color.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"color.cjs"}
|
package/dist/color.d.cts
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { c as Hsl, R as Rgb, d as Hsv, L as LinearRgb, O as Oklab, f as Oklch, a as ColorInput, C as ColorSpace, e as HueDirection } from './palette-6HkVltYU.cjs';
|
|
2
|
+
export { b as ColorScale, H as HarmonyKind, P as PaletteName, g as PaletteOptions, S as ScaleOptions, h as createScale, i as expandPalette, j as generatePalette, k as harmony, l as invertForSurface, p as palettes, r as resolvePalette, s as sortByLightness } from './palette-6HkVltYU.cjs';
|
|
3
|
+
import { E as EasingInput } from './types-B1FLLf3-.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Colour space conversions.
|
|
7
|
+
*
|
|
8
|
+
* Matrices for OKLab are Björn Ottosson's published values. They are reproduced to full
|
|
9
|
+
* precision deliberately — truncating them introduces a visible hue shift in saturated blues.
|
|
10
|
+
*/
|
|
11
|
+
/** Remove the sRGB gamma curve from a single channel. */
|
|
12
|
+
declare function srgbToLinearChannel(c: number): number;
|
|
13
|
+
/** Apply the sRGB gamma curve to a single channel. */
|
|
14
|
+
declare function linearToSrgbChannel(c: number): number;
|
|
15
|
+
declare function rgbToLinear(rgb: Rgb): LinearRgb;
|
|
16
|
+
declare function linearToRgb(lin: LinearRgb): Rgb;
|
|
17
|
+
declare function linearToOklab(lin: LinearRgb): Oklab;
|
|
18
|
+
declare function oklabToLinear(lab: Oklab): LinearRgb;
|
|
19
|
+
declare function rgbToOklab(rgb: Rgb): Oklab;
|
|
20
|
+
/**
|
|
21
|
+
* OKLab → sRGB.
|
|
22
|
+
*
|
|
23
|
+
* The result may fall outside the sRGB gamut, in which case channels are simply clipped.
|
|
24
|
+
* Use {@link import('./gamut').gamutMapOklch} when you need a perceptually sensible
|
|
25
|
+
* in-gamut colour rather than a clipped one.
|
|
26
|
+
*/
|
|
27
|
+
declare function oklabToRgb(lab: Oklab): Rgb;
|
|
28
|
+
declare function oklabToOklch(lab: Oklab): Oklch;
|
|
29
|
+
declare function oklchToOklab(lch: Oklch): Oklab;
|
|
30
|
+
declare function rgbToOklch(rgb: Rgb): Oklch;
|
|
31
|
+
declare function oklchToRgb(lch: Oklch): Rgb;
|
|
32
|
+
declare function rgbToHsl(rgb: Rgb): Hsl;
|
|
33
|
+
declare function hslToRgb(hsl: Hsl): Rgb;
|
|
34
|
+
declare function rgbToHsv(rgb: Rgb): Hsv;
|
|
35
|
+
declare function hsvToRgb(hsv: Hsv): Rgb;
|
|
36
|
+
/**
|
|
37
|
+
* Relative luminance per WCAG 2.x — the Y component of CIEXYZ from linear sRGB.
|
|
38
|
+
* This is the quantity contrast ratios are built from.
|
|
39
|
+
*/
|
|
40
|
+
declare function relativeLuminance(rgb: Rgb): number;
|
|
41
|
+
|
|
42
|
+
declare class ColorParseError extends Error {
|
|
43
|
+
readonly input: string;
|
|
44
|
+
constructor(input: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Parse any accepted colour into {@link Rgb}.
|
|
48
|
+
*
|
|
49
|
+
* @throws {ColorParseError} on unparseable input. Ansh throws here rather than falling back
|
|
50
|
+
* to black: a silently-black gradient is far harder to debug than a thrown error pointing at
|
|
51
|
+
* the offending string, and colour props are validated at mount, not inside a frame loop.
|
|
52
|
+
*/
|
|
53
|
+
declare function parseColor(input: ColorInput): Rgb;
|
|
54
|
+
/** Like {@link parseColor} but returns `null` instead of throwing. */
|
|
55
|
+
declare function tryParseColor(input: ColorInput): Rgb | null;
|
|
56
|
+
/**
|
|
57
|
+
* Resolve a colour the parser can't handle itself by asking the browser.
|
|
58
|
+
*
|
|
59
|
+
* Covers `var(--token)`, `currentcolor`, `color-mix()`, `lab()` and anything else CSS gains
|
|
60
|
+
* in future. We set the value on a detached element and read back the computed style — the
|
|
61
|
+
* browser normalises it to `rgb()`/`rgba()`, which we can then parse.
|
|
62
|
+
*
|
|
63
|
+
* Returns `null` during SSR, where there is no document to consult. Callers should keep the
|
|
64
|
+
* original string in that case and let CSS resolve it at paint time; only effects that need
|
|
65
|
+
* numeric colour access (canvas gradients) require a resolved value, and those run client-side.
|
|
66
|
+
*/
|
|
67
|
+
declare function resolveComputed(value: string): Rgb | null;
|
|
68
|
+
/**
|
|
69
|
+
* Resolve a CSS custom property against a specific element's cascade.
|
|
70
|
+
*
|
|
71
|
+
* Needed because `var(--surface)` means different things inside a `.dark` subtree. Effects
|
|
72
|
+
* pass their own host element so themed colours resolve correctly.
|
|
73
|
+
*/
|
|
74
|
+
declare function resolveCssVariable(name: string, element?: Element | null): Rgb | null;
|
|
75
|
+
/** Clear the parse cache. Exposed for tests and for theme switches that change `var()` output. */
|
|
76
|
+
declare function clearColorCache(): void;
|
|
77
|
+
|
|
78
|
+
/** `#rrggbb`, or `#rrggbbaa` when not fully opaque (or when `forceAlpha` is set). */
|
|
79
|
+
declare function toHex(color: Rgb, forceAlpha?: boolean): string;
|
|
80
|
+
/**
|
|
81
|
+
* `rgb(r g b)` / `rgb(r g b / a)`.
|
|
82
|
+
*
|
|
83
|
+
* Uses the legacy comma form because it is what every canvas implementation and every
|
|
84
|
+
* browser back to 2015 accepts; the space-separated form is newer than our support target.
|
|
85
|
+
*/
|
|
86
|
+
declare function toRgbString(color: Rgb): string;
|
|
87
|
+
declare function toHslString(color: Rgb): string;
|
|
88
|
+
/** `oklch(l% c h)` — the modern authoring form, and what the theme generator emits. */
|
|
89
|
+
declare function toOklchString(color: Rgb): string;
|
|
90
|
+
/**
|
|
91
|
+
* Pack into a 32-bit integer as `0xAABBGGRR`.
|
|
92
|
+
*
|
|
93
|
+
* This is the byte order a `Uint32Array` view over `ImageData` expects on little-endian
|
|
94
|
+
* machines, which is every platform we target. Effects that write pixels directly — the noise
|
|
95
|
+
* layer, the grain overlay — use this to fill a row with one store per pixel instead of four.
|
|
96
|
+
*/
|
|
97
|
+
declare function toUint32(color: Rgb): number;
|
|
98
|
+
declare function fromUint32(packed: number): Rgb;
|
|
99
|
+
/** Replace a colour's alpha, leaving its hue and lightness untouched. */
|
|
100
|
+
declare function withAlpha(color: Rgb, alpha: number): Rgb;
|
|
101
|
+
/** Scale a colour's existing alpha — useful for fading a whole palette at once. */
|
|
102
|
+
declare function fadeBy(color: Rgb, factor: number): Rgb;
|
|
103
|
+
|
|
104
|
+
/** Is this OKLCH colour displayable in sRGB? */
|
|
105
|
+
declare function inSrgbGamut(lch: Oklch): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Reduce chroma until the colour fits in sRGB, preserving lightness and hue.
|
|
108
|
+
*
|
|
109
|
+
* Returns the input unchanged when it is already in gamut, so this is safe to call
|
|
110
|
+
* unconditionally.
|
|
111
|
+
*/
|
|
112
|
+
declare function gamutMapOklch(lch: Oklch): Oklch;
|
|
113
|
+
/**
|
|
114
|
+
* The maximum chroma sRGB can display at a given lightness and hue.
|
|
115
|
+
*
|
|
116
|
+
* This is what makes "vivid" palette generation possible: rather than picking an arbitrary
|
|
117
|
+
* chroma and hoping, you can ask for the most saturated colour available at each hue and get
|
|
118
|
+
* a palette with consistent, maximal punch.
|
|
119
|
+
*/
|
|
120
|
+
declare function maxChroma(l: number, h: number): number;
|
|
121
|
+
/** Gamut-map, then convert to sRGB. The safe path from OKLCH to a displayable colour. */
|
|
122
|
+
declare function oklchToRgbMapped(lch: Oklch): Rgb;
|
|
123
|
+
/**
|
|
124
|
+
* How far outside sRGB a colour sits, as a rough distance in chroma units.
|
|
125
|
+
* `0` means in gamut. Used by the docs site to warn about unrenderable theme colours.
|
|
126
|
+
*/
|
|
127
|
+
declare function gamutError(lch: Oklch): number;
|
|
128
|
+
/** Does this sRGB colour survive a round trip through OKLCH unchanged? Diagnostic helper. */
|
|
129
|
+
declare function isGamutStable(rgb: Rgb): boolean;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Colour interpolation and gradient construction.
|
|
133
|
+
*
|
|
134
|
+
* The default space is OKLab, and that default is load-bearing — but it is worth being precise
|
|
135
|
+
* about *when* it matters, because the difference is not uniform.
|
|
136
|
+
*
|
|
137
|
+
* **Where sRGB fails badly: opposing hues.** Interpolating `#0000ff → #ffff00` in sRGB passes
|
|
138
|
+
* through exactly `#808080` — a dead grey — because the channels cancel. In OKLab the same
|
|
139
|
+
* transition keeps measurable chroma the whole way across. Any gradient spanning more than about a
|
|
140
|
+
* quadrant of the hue circle hits some version of this.
|
|
141
|
+
*
|
|
142
|
+
* **Where sRGB merely differs: neighbouring hues.** For `#0275f4 → #9f0550` (blue to crimson,
|
|
143
|
+
* ~104° apart) sRGB actually produces a *more* saturated midpoint, because it cuts the chord
|
|
144
|
+
* straight through the colour solid. What it does not preserve is perceived *lightness* — the sRGB
|
|
145
|
+
* path dips darker in the middle, so the transition reads as uneven even though it is vivid. OKLab
|
|
146
|
+
* holds lightness steady, which is what makes a gradient feel smooth rather than lumpy.
|
|
147
|
+
*
|
|
148
|
+
* Use `oklch` when you want maximum vividness across distant hues; it travels the hue circle rather
|
|
149
|
+
* than cutting across it, keeping chroma high throughout.
|
|
150
|
+
*/
|
|
151
|
+
interface MixOptions {
|
|
152
|
+
/** Space to interpolate through. Default `'oklab'`. */
|
|
153
|
+
space?: ColorSpace;
|
|
154
|
+
/** Which way around the hue circle, for cylindrical spaces. Default `'shorter'`. */
|
|
155
|
+
hue?: HueDirection;
|
|
156
|
+
/**
|
|
157
|
+
* Gamut-map the result rather than clipping it.
|
|
158
|
+
*
|
|
159
|
+
* Slightly more expensive (a short binary search) but preserves hue and lightness for
|
|
160
|
+
* out-of-gamut intermediates. Default `true` for `oklch`, `false` otherwise — `oklch`
|
|
161
|
+
* interpolation is the one that routinely leaves the gamut.
|
|
162
|
+
*/
|
|
163
|
+
gamutMap?: boolean;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Interpolate between two colours.
|
|
167
|
+
*
|
|
168
|
+
* `t` is clamped to `[0, 1]`. Alpha is always interpolated linearly, independent of space —
|
|
169
|
+
* premultiplying would darken transitions to transparent, which is almost never wanted for
|
|
170
|
+
* UI gradients.
|
|
171
|
+
*/
|
|
172
|
+
declare function mixColors(from: ColorInput, to: ColorInput, t: number, options?: MixOptions): Rgb;
|
|
173
|
+
/** The allocation-light path used by gradients, which have already parsed their stops. */
|
|
174
|
+
declare function mixParsed(a: Rgb, b: Rgb, t: number, options?: MixOptions): Rgb;
|
|
175
|
+
/** Interpolate two hue angles, honouring the requested direction of travel. */
|
|
176
|
+
declare function lerpHue(from: number, to: number, t: number, direction: HueDirection): number;
|
|
177
|
+
interface GradientStop {
|
|
178
|
+
/** Position in `[0, 1]`. */
|
|
179
|
+
offset: number;
|
|
180
|
+
color: ColorInput;
|
|
181
|
+
}
|
|
182
|
+
interface GradientOptions extends MixOptions {
|
|
183
|
+
/**
|
|
184
|
+
* Easing applied to the position *within each segment*, not across the whole gradient.
|
|
185
|
+
*
|
|
186
|
+
* This is how you get a gradient that lingers near one colour: `easeInQuad` compresses
|
|
187
|
+
* the transition toward the end of each segment. Default linear.
|
|
188
|
+
*/
|
|
189
|
+
easing?: EasingInput;
|
|
190
|
+
}
|
|
191
|
+
interface Gradient {
|
|
192
|
+
/** Colour at position `t` in `[0, 1]`. */
|
|
193
|
+
at(t: number): Rgb;
|
|
194
|
+
/** Colour at position `t`, formatted for `fillStyle`. */
|
|
195
|
+
cssAt(t: number): string;
|
|
196
|
+
/** Evenly sample the gradient into `count` colours. */
|
|
197
|
+
sample(count: number): Rgb[];
|
|
198
|
+
/** A `linear-gradient(...)` string with `count` stops, for CSS backgrounds. */
|
|
199
|
+
toCss(direction?: string, count?: number): string;
|
|
200
|
+
readonly stops: readonly GradientStop[];
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Build a multi-stop gradient.
|
|
204
|
+
*
|
|
205
|
+
* Accepts either a flat list of colours (distributed evenly) or explicit stops. Any number of
|
|
206
|
+
* colours is supported — there is no cap, and no assumption of two.
|
|
207
|
+
*/
|
|
208
|
+
declare function createGradient(input: readonly ColorInput[] | readonly GradientStop[], options?: GradientOptions): Gradient;
|
|
209
|
+
/**
|
|
210
|
+
* Apply the gradient's stops to a native canvas gradient object.
|
|
211
|
+
*
|
|
212
|
+
* We can't hand the canvas our stops directly — it would interpolate them in sRGB and undo
|
|
213
|
+
* the whole point. Instead we sample our own interpolation into `resolution` intermediate
|
|
214
|
+
* stops, so the browser only ever interpolates over tiny intervals where the space barely
|
|
215
|
+
* matters. 24 stops is visually indistinguishable from continuous.
|
|
216
|
+
*/
|
|
217
|
+
declare function applyGradientStops(target: CanvasGradient, gradient: Gradient, resolution?: number): CanvasGradient;
|
|
218
|
+
/**
|
|
219
|
+
* Blend a colour toward another by a fixed amount, in a chosen space.
|
|
220
|
+
* Shorthand for the common "10% lighter" adjustment.
|
|
221
|
+
*/
|
|
222
|
+
declare function blend(base: ColorInput, over: ColorInput, amount?: number, space?: ColorSpace): Rgb;
|
|
223
|
+
/**
|
|
224
|
+
* Composite `over` onto `base` using its alpha — the "source-over" Porter-Duff operator,
|
|
225
|
+
* evaluated in linear light so it matches what the GPU does.
|
|
226
|
+
*/
|
|
227
|
+
declare function composite(base: ColorInput, over: ColorInput): Rgb;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Contrast and legibility.
|
|
231
|
+
*
|
|
232
|
+
* Animated backgrounds are the single most common way a design ends up failing WCAG: the text
|
|
233
|
+
* was legible against the mockup's midpoint and illegible against the animation's brightest
|
|
234
|
+
* frame. These helpers let components check contrast against the *extremes* of their own
|
|
235
|
+
* palette and adapt, rather than hoping.
|
|
236
|
+
*/
|
|
237
|
+
type WcagLevel = 'AA' | 'AAA';
|
|
238
|
+
type TextSize = 'normal' | 'large';
|
|
239
|
+
/**
|
|
240
|
+
* WCAG 2.x contrast ratio, from 1 (identical) to 21 (black on white).
|
|
241
|
+
*
|
|
242
|
+
* Semi-transparent colours are composited over `background` first, because a ratio computed
|
|
243
|
+
* from a colour's own alpha is meaningless — what matters is what the eye actually receives.
|
|
244
|
+
*/
|
|
245
|
+
declare function contrastRatio(foreground: ColorInput, background: ColorInput): number;
|
|
246
|
+
/** Minimum ratio required by WCAG 2.2 for the given level and text size. */
|
|
247
|
+
declare function requiredRatio(level: WcagLevel, size: TextSize): number;
|
|
248
|
+
interface ContrastResult {
|
|
249
|
+
ratio: number;
|
|
250
|
+
passes: boolean;
|
|
251
|
+
required: number;
|
|
252
|
+
level: WcagLevel;
|
|
253
|
+
size: TextSize;
|
|
254
|
+
}
|
|
255
|
+
/** Check a foreground/background pair against a WCAG threshold. */
|
|
256
|
+
declare function checkContrast(foreground: ColorInput, background: ColorInput, level?: WcagLevel, size?: TextSize): ContrastResult;
|
|
257
|
+
/**
|
|
258
|
+
* Pick whichever of `light`/`dark` reads better on `background`.
|
|
259
|
+
*
|
|
260
|
+
* This is the function to reach for when a component renders text over a user-supplied
|
|
261
|
+
* colour, which is most of them.
|
|
262
|
+
*/
|
|
263
|
+
declare function pickReadable(background: ColorInput, light?: ColorInput, dark?: ColorInput): Rgb;
|
|
264
|
+
/**
|
|
265
|
+
* Adjust a colour's lightness until it meets a contrast target against `background`.
|
|
266
|
+
*
|
|
267
|
+
* Works in OKLCH so hue and chroma survive the adjustment — the brand colour stays
|
|
268
|
+
* recognisably itself, it just gets light or dark enough to read. Searches in whichever
|
|
269
|
+
* direction has more headroom, and returns the best achievable colour if the target is
|
|
270
|
+
* unreachable (a mid-grey background cannot support 7:1 with a saturated hue at any lightness).
|
|
271
|
+
*/
|
|
272
|
+
declare function ensureContrast(foreground: ColorInput, background: ColorInput, target?: number): {
|
|
273
|
+
color: Rgb;
|
|
274
|
+
ratio: number;
|
|
275
|
+
achieved: boolean;
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* Worst-case contrast of a foreground against every colour in a set.
|
|
279
|
+
*
|
|
280
|
+
* An animated gradient background cycles through many colours; text must be legible against
|
|
281
|
+
* all of them. Components call this with their resolved palette and surface a dev warning when
|
|
282
|
+
* it fails, which turns an invisible accessibility bug into a console message during development.
|
|
283
|
+
*/
|
|
284
|
+
declare function worstContrast(foreground: ColorInput, backgrounds: readonly ColorInput[]): {
|
|
285
|
+
ratio: number;
|
|
286
|
+
against: Rgb | null;
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* APCA-style perceptual lightness, used for ordering colours by visual weight.
|
|
290
|
+
*
|
|
291
|
+
* Not a WCAG 3 implementation — that specification is still in flux and we won't ship a
|
|
292
|
+
* moving target as if it were stable. This is OKLab's `L`, which is a better predictor of
|
|
293
|
+
* perceived lightness than WCAG's relative luminance and is entirely sufficient for the
|
|
294
|
+
* internal job of sorting a palette light-to-dark.
|
|
295
|
+
*/
|
|
296
|
+
declare function perceivedLightness(color: ColorInput): number;
|
|
297
|
+
|
|
298
|
+
/** Resolve a CSS colour keyword to its hex value, or `undefined` if it isn't one. */
|
|
299
|
+
declare function namedColorToHex(name: string): string | undefined;
|
|
300
|
+
/** Every recognised colour keyword. Powers autocomplete in the docs playground. */
|
|
301
|
+
declare function listNamedColors(): string[];
|
|
302
|
+
|
|
303
|
+
export { ColorInput, ColorParseError, ColorSpace, type ContrastResult, type Gradient, type GradientOptions, type GradientStop, Hsl, Hsv, HueDirection, LinearRgb, type MixOptions, Oklab, Oklch, Rgb, type TextSize, type WcagLevel, applyGradientStops, blend, checkContrast, clearColorCache, composite, contrastRatio, createGradient, ensureContrast, fadeBy, fromUint32, gamutError, gamutMapOklch, hslToRgb, hsvToRgb, inSrgbGamut, isGamutStable, lerpHue, linearToOklab, linearToRgb, linearToSrgbChannel, listNamedColors, maxChroma, mixColors, mixParsed, namedColorToHex, oklabToLinear, oklabToOklch, oklabToRgb, oklchToOklab, oklchToRgb, oklchToRgbMapped, parseColor, perceivedLightness, pickReadable, relativeLuminance, requiredRatio, resolveComputed, resolveCssVariable, rgbToHsl, rgbToHsv, rgbToLinear, rgbToOklab, rgbToOklch, srgbToLinearChannel, toHex, toHslString, toOklchString, toRgbString, toUint32, tryParseColor, withAlpha, worstContrast };
|