fashionable 0.0.0 → 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.md +21 -0
- package/README.md +276 -0
- package/dist/calc/index.d.mts +2 -0
- package/dist/calc/index.mjs +2 -0
- package/dist/data/index.d.mts +208 -0
- package/dist/data/index.mjs +696 -0
- package/dist/data/index.mjs.map +1 -0
- package/dist/declaration/index.d.mts +2 -0
- package/dist/declaration/index.mjs +74 -0
- package/dist/declaration/index.mjs.map +1 -0
- package/dist/fontFace/index.d.mts +2 -0
- package/dist/fontFace/index.mjs +102 -0
- package/dist/fontFace/index.mjs.map +1 -0
- package/dist/property/index.d.mts +2 -0
- package/dist/property/index.mjs +293 -0
- package/dist/property/index.mjs.map +1 -0
- package/dist/query/index.d.mts +2 -0
- package/dist/query/index.mjs +62 -0
- package/dist/query/index.mjs.map +1 -0
- package/dist/rule/index.d.mts +2 -0
- package/dist/rule/index.mjs +234 -0
- package/dist/rule/index.mjs.map +1 -0
- package/dist/selector/index.d.mts +2 -0
- package/dist/selector/index.mjs +178 -0
- package/dist/selector/index.mjs.map +1 -0
- package/dist/shared/calc-Cih4o2r7.mjs +1145 -0
- package/dist/shared/calc-Cih4o2r7.mjs.map +1 -0
- package/dist/shared/color-BvNJ2YqL.d.mts +590 -0
- package/dist/shared/color.internal-Dts5ycTm.mjs +450 -0
- package/dist/shared/color.internal-Dts5ycTm.mjs.map +1 -0
- package/dist/shared/declaration-1DlO_ltT.d.mts +166 -0
- package/dist/shared/declaration.internal-wLB4ssxC.mjs +73 -0
- package/dist/shared/declaration.internal-wLB4ssxC.mjs.map +1 -0
- package/dist/shared/equal-U9G5LhtL.mjs +71 -0
- package/dist/shared/equal-U9G5LhtL.mjs.map +1 -0
- package/dist/shared/fontFaceRule-C7nYgH6X.d.mts +294 -0
- package/dist/shared/fontFaceRule.internal-D5u48TUO.mjs +214 -0
- package/dist/shared/fontFaceRule.internal-D5u48TUO.mjs.map +1 -0
- package/dist/shared/format-B9jsmCER.mjs +53 -0
- package/dist/shared/format-B9jsmCER.mjs.map +1 -0
- package/dist/shared/index-BvtwY4FQ.d.mts +841 -0
- package/dist/shared/mediaQuery-BYR1z-iD.d.mts +145 -0
- package/dist/shared/mediaQuery.internal-B6iuMd75.mjs +100 -0
- package/dist/shared/mediaQuery.internal-B6iuMd75.mjs.map +1 -0
- package/dist/shared/mediaRule-BDB4WCYy.d.mts +558 -0
- package/dist/shared/precision.internal-0lv1nEpF.mjs +40 -0
- package/dist/shared/precision.internal-0lv1nEpF.mjs.map +1 -0
- package/dist/shared/propertyRule-BbkFh9b9.d.mts +466 -0
- package/dist/shared/propertyRule.internal-Bc_HrfcL.mjs +246 -0
- package/dist/shared/propertyRule.internal-Bc_HrfcL.mjs.map +1 -0
- package/dist/shared/render-BqcFH9Vr.mjs +9 -0
- package/dist/shared/render-BqcFH9Vr.mjs.map +1 -0
- package/dist/shared/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/shared/ruleSet.internal-DodzVMUU.mjs +218 -0
- package/dist/shared/ruleSet.internal-DodzVMUU.mjs.map +1 -0
- package/dist/shared/selector-HZY-W6l6.d.mts +346 -0
- package/dist/shared/selector.internal-ESe9s0IH.mjs +290 -0
- package/dist/shared/selector.internal-ESe9s0IH.mjs.map +1 -0
- package/dist/shared/utils-BKm298I-.d.mts +179 -0
- package/dist/stylesheet/index.d.mts +316 -0
- package/dist/stylesheet/index.mjs +296 -0
- package/dist/stylesheet/index.mjs.map +1 -0
- package/dist/utils.d.mts +2 -0
- package/dist/utils.mjs +131 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +96 -8
- package/index.js +0 -1
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
import { t as __exportAll } from "../shared/rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { d as ident, u as dimension } from "../shared/calc-Cih4o2r7.mjs";
|
|
3
|
+
import { A as oklab$1, C as shorter$1, D as hwb$1, E as hsl$1, F as srgbLinear$1, I as xyz$1, L as xyzD50$1, M as prophotoRgb$1, N as rec2020$1, O as lab$1, P as srgb$3, R as xyzD65$1, S as longer$1, T as displayP3$1, _ as isNone$1, a as isColor$1, b as increasing$1, c as named$1, d as refs$1, g as of$1, h as transparent$1, i as from$1, j as oklch$3, k as lch$1, l as oklch$2, m as srgb$2, n as channels$1, o as lightDark$1, p as serialize$1, r as equals$1, s as mix$1, t as bind$1, u as ref$1, v as none$1, w as a98Rgb$1, x as interpolate$1, y as decreasing$1 } from "../shared/color.internal-Dts5ycTm.mjs";
|
|
4
|
+
//#region src/data/angle.internal.ts
|
|
5
|
+
/** @internal */
|
|
6
|
+
const rad$1 = (value, precision) => dimension(value, "rad", "angle", precision);
|
|
7
|
+
/** @internal */
|
|
8
|
+
const deg$1 = (value, precision) => dimension(value, "deg", "angle", precision);
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/data/angle.ts
|
|
11
|
+
var angle_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
deg: () => deg,
|
|
13
|
+
rad: () => rad
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* An angle in `rad` (radians). Radians are the numeric measure of an angle, so
|
|
17
|
+
* a radian-only expression solves with no unit context.
|
|
18
|
+
*
|
|
19
|
+
* @param value - The angle in radians.
|
|
20
|
+
* @param precision - Optional serialization precision.
|
|
21
|
+
* @returns A `rad` angle expression.
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* Calc.serialize(Angle.rad(1.5708)) // '1.5708rad'
|
|
25
|
+
* ```
|
|
26
|
+
* @since 0.2.0
|
|
27
|
+
*/
|
|
28
|
+
const rad = rad$1;
|
|
29
|
+
/**
|
|
30
|
+
* An angle in `deg` (degrees). Degrees lower to radians at solve (`180deg` is
|
|
31
|
+
* `pi`), a fixed ratio, so a degree-only expression solves with no unit context.
|
|
32
|
+
*
|
|
33
|
+
* @param value - The angle in degrees.
|
|
34
|
+
* @param precision - Optional serialization precision.
|
|
35
|
+
* @returns A `deg` angle expression.
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* Calc.serialize(Angle.deg(45)) // '45deg'
|
|
39
|
+
* ```
|
|
40
|
+
* @since 0.2.0
|
|
41
|
+
*/
|
|
42
|
+
const deg = deg$1;
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/data/channels.internal.ts
|
|
45
|
+
/** @internal */
|
|
46
|
+
const L$1 = ident("l");
|
|
47
|
+
/** @internal */
|
|
48
|
+
const C$1 = ident("c");
|
|
49
|
+
/** @internal */
|
|
50
|
+
const H$1 = ident("h");
|
|
51
|
+
/** @internal */
|
|
52
|
+
const R$1 = ident("r");
|
|
53
|
+
/** @internal */
|
|
54
|
+
const G$1 = ident("g");
|
|
55
|
+
/** @internal */
|
|
56
|
+
const B$1 = ident("b");
|
|
57
|
+
/** @internal */
|
|
58
|
+
const Alpha$1 = ident("alpha");
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/data/channels.ts
|
|
61
|
+
var channels_exports = /* @__PURE__ */ __exportAll({
|
|
62
|
+
Alpha: () => Alpha,
|
|
63
|
+
B: () => B,
|
|
64
|
+
C: () => C,
|
|
65
|
+
G: () => G,
|
|
66
|
+
H: () => H,
|
|
67
|
+
L: () => L,
|
|
68
|
+
R: () => R
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* The `l` origin channel — lightness in `oklch`. Serializes bare as `l`.
|
|
72
|
+
*
|
|
73
|
+
* @since 0.2.0
|
|
74
|
+
*/
|
|
75
|
+
const L = L$1;
|
|
76
|
+
/**
|
|
77
|
+
* The `c` origin channel — chroma in `oklch`. Serializes bare as `c`.
|
|
78
|
+
*
|
|
79
|
+
* @since 0.2.0
|
|
80
|
+
*/
|
|
81
|
+
const C = C$1;
|
|
82
|
+
/**
|
|
83
|
+
* The `h` origin channel — hue in `oklch`, in degrees. Serializes bare as `h`.
|
|
84
|
+
*
|
|
85
|
+
* @since 0.2.0
|
|
86
|
+
*/
|
|
87
|
+
const H = H$1;
|
|
88
|
+
/**
|
|
89
|
+
* The `r` origin channel — red in `color(srgb ...)`. Serializes bare as `r`.
|
|
90
|
+
*
|
|
91
|
+
* @since 0.2.0
|
|
92
|
+
*/
|
|
93
|
+
const R = R$1;
|
|
94
|
+
/**
|
|
95
|
+
* The `g` origin channel — green in `color(srgb ...)`. Serializes bare as `g`.
|
|
96
|
+
*
|
|
97
|
+
* @since 0.2.0
|
|
98
|
+
*/
|
|
99
|
+
const G = G$1;
|
|
100
|
+
/**
|
|
101
|
+
* The `b` origin channel — blue in `color(srgb ...)`. Serializes bare as `b`.
|
|
102
|
+
*
|
|
103
|
+
* @since 0.2.0
|
|
104
|
+
*/
|
|
105
|
+
const B = B$1;
|
|
106
|
+
/**
|
|
107
|
+
* The `alpha` origin channel — the opacity of the `from` origin, in `oklch`
|
|
108
|
+
* and `color(srgb ...)` alike. Serializes bare as `alpha`.
|
|
109
|
+
*
|
|
110
|
+
* @since 0.2.0
|
|
111
|
+
*/
|
|
112
|
+
const Alpha = Alpha$1;
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/data/color.ts
|
|
115
|
+
var color_exports = /* @__PURE__ */ __exportAll({
|
|
116
|
+
bind: () => bind,
|
|
117
|
+
channels: () => channels,
|
|
118
|
+
equals: () => equals,
|
|
119
|
+
from: () => from,
|
|
120
|
+
isColor: () => isColor,
|
|
121
|
+
lightDark: () => lightDark,
|
|
122
|
+
mix: () => mix,
|
|
123
|
+
named: () => named,
|
|
124
|
+
oklch: () => oklch$1,
|
|
125
|
+
ref: () => ref,
|
|
126
|
+
refs: () => refs,
|
|
127
|
+
serialize: () => serialize,
|
|
128
|
+
srgb: () => srgb$1,
|
|
129
|
+
transparent: () => transparent
|
|
130
|
+
});
|
|
131
|
+
/**
|
|
132
|
+
* Checks if a value is a `Color`.
|
|
133
|
+
*
|
|
134
|
+
* True only for values built by this module's constructors, which carry
|
|
135
|
+
* the brand.
|
|
136
|
+
*
|
|
137
|
+
* @param u - The value to check.
|
|
138
|
+
* @returns `true` if the value is a `Color`, `false` otherwise.
|
|
139
|
+
* @since 0.1.0
|
|
140
|
+
*/
|
|
141
|
+
const isColor = isColor$1;
|
|
142
|
+
/**
|
|
143
|
+
* Creates an `oklch(...)` color from three channel expressions: lightness
|
|
144
|
+
* (`0` to `1`), chroma (`0` upward), and hue (degrees). A channel may be
|
|
145
|
+
* `Keyword.none` — the missing-component keyword, the conventional hue
|
|
146
|
+
* for achromatic colors: `oklch(0 0 none)`.
|
|
147
|
+
*
|
|
148
|
+
* Each channel serializes independently, wrapped in `calc()` when it is
|
|
149
|
+
* arithmetic: `oklch(var(--l) calc(var(--c) * 0.5) 220)`.
|
|
150
|
+
*
|
|
151
|
+
* @param lightness - The lightness channel.
|
|
152
|
+
* @param chroma - The chroma channel.
|
|
153
|
+
* @param hue - The hue channel, in degrees.
|
|
154
|
+
* @returns A `Color` with the channels' references unioned.
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* const accent = Color.oklch(Calc.ref('lightness'), 0.15, 220)
|
|
158
|
+
* Color.serialize(accent) // 'oklch(var(--lightness) 0.15 220)'
|
|
159
|
+
* ```
|
|
160
|
+
* @since 0.1.0
|
|
161
|
+
*/
|
|
162
|
+
const oklch$1 = oklch$2;
|
|
163
|
+
/**
|
|
164
|
+
* Creates a `color(srgb ...)` color from three channel expressions, each
|
|
165
|
+
* `0` to `1`. A channel may be `Keyword.none`, the missing-component
|
|
166
|
+
* keyword.
|
|
167
|
+
*
|
|
168
|
+
* Each channel serializes independently, wrapped in `calc()` when it is
|
|
169
|
+
* arithmetic, inside the `color()` function's `srgb` colorspace:
|
|
170
|
+
* `color(srgb 0.18 0.34 0.78)`.
|
|
171
|
+
*
|
|
172
|
+
* @param red - The red channel.
|
|
173
|
+
* @param green - The green channel.
|
|
174
|
+
* @param blue - The blue channel.
|
|
175
|
+
* @returns A `Color` with the channels' references unioned.
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* const brand = Color.srgb(0.18, 0.34, 0.78)
|
|
179
|
+
* Color.serialize(brand) // 'color(srgb 0.18 0.34 0.78)'
|
|
180
|
+
* ```
|
|
181
|
+
* @since 0.2.0
|
|
182
|
+
*/
|
|
183
|
+
const srgb$1 = srgb$2;
|
|
184
|
+
/**
|
|
185
|
+
* Creates a named color, rendered bare: `named('rebeccapurple')`
|
|
186
|
+
* serializes as `rebeccapurple`. The name is the whole value — a named
|
|
187
|
+
* color has no channels, contributes no references, and binds nothing.
|
|
188
|
+
*
|
|
189
|
+
* That the name is one of the specification's named colors is not
|
|
190
|
+
* checked, matching the library's posture on identifiers — with one
|
|
191
|
+
* exception: the CSS-wide keywords (`inherit`, `initial`, ...) are
|
|
192
|
+
* whole-declaration values, not colors (`light-dark(inherit, ...)` is
|
|
193
|
+
* invalid CSS), and are rejected.
|
|
194
|
+
*
|
|
195
|
+
* @param name - The color name. Must be non-empty and not a CSS-wide keyword.
|
|
196
|
+
* @returns A `Color<never>`.
|
|
197
|
+
* @throws `Error` when `name` is empty or a CSS-wide keyword.
|
|
198
|
+
* @since 0.2.0
|
|
199
|
+
*/
|
|
200
|
+
const named = named$1;
|
|
201
|
+
/**
|
|
202
|
+
* The `transparent` named color — `rgb(0 0 0 / 0)` by definition, and
|
|
203
|
+
* the conventional "no color" value.
|
|
204
|
+
*
|
|
205
|
+
* @since 0.2.0
|
|
206
|
+
*/
|
|
207
|
+
const transparent = transparent$1;
|
|
208
|
+
/**
|
|
209
|
+
* Creates a color-valued custom-property reference — `ref('accent')`
|
|
210
|
+
* serializes as `var(--accent)`. Use it where a whole color is read from a
|
|
211
|
+
* custom property: as a standalone value, or as the origin of a relative color
|
|
212
|
+
* (`from`).
|
|
213
|
+
*
|
|
214
|
+
* The reference is the whole value, so it carries `name` as its one unbound
|
|
215
|
+
* reference — a dependency, exactly as an unbound `Calc.ref` does — but has no
|
|
216
|
+
* channels. `bind` substitutes channel expressions, not whole colors, so it
|
|
217
|
+
* leaves a color reference in place; the browser resolves it from the cascade.
|
|
218
|
+
*
|
|
219
|
+
* @param name - The custom-property name, without the `--` prefix. Must be non-empty.
|
|
220
|
+
* @returns A `Color` with `name` as its one unbound reference.
|
|
221
|
+
* @throws `Error` when `name` is empty.
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* Color.serialize(Color.ref('accent')) // 'var(--accent)'
|
|
225
|
+
* ```
|
|
226
|
+
* @since 0.2.0
|
|
227
|
+
*/
|
|
228
|
+
const ref = ref$1;
|
|
229
|
+
/**
|
|
230
|
+
* Creates a scheme-conditional `light-dark(...)` color: the browser uses
|
|
231
|
+
* the first color under the light scheme and the second under dark.
|
|
232
|
+
*
|
|
233
|
+
* The arms are whole colors and positional — `lightDark(a, b)` and
|
|
234
|
+
* `lightDark(b, a)` are different colors. Any `Color` is accepted,
|
|
235
|
+
* including another `lightDark` (grammatically an arm is any `<color>`;
|
|
236
|
+
* nesting is redundant but legal, and simplification is not this type's
|
|
237
|
+
* job). Note the resolution context: `light-dark()` requires
|
|
238
|
+
* `color-scheme` to be set — that contract is the consumer's.
|
|
239
|
+
*
|
|
240
|
+
* @param light - The color used under the light scheme.
|
|
241
|
+
* @param dark - The color used under the dark scheme.
|
|
242
|
+
* @returns A `Color` with both arms' references unioned.
|
|
243
|
+
* @example
|
|
244
|
+
* ```ts
|
|
245
|
+
* const accent = Color.lightDark(Color.srgb(0.85, 0.3, 0.4), Color.srgb(0.95, 0.5, 0.55))
|
|
246
|
+
* Color.serialize(accent) // 'light-dark(color(srgb 0.85 0.3 0.4), color(srgb 0.95 0.5 0.55))'
|
|
247
|
+
* ```
|
|
248
|
+
* @since 0.2.0
|
|
249
|
+
*/
|
|
250
|
+
const lightDark = lightDark$1;
|
|
251
|
+
/**
|
|
252
|
+
* Creates a `color-mix(...)`: the browser mixes `color1` and `color2` in the
|
|
253
|
+
* interpolation `space`. Each arm is a bare `Color` or a `[color, percentage]`
|
|
254
|
+
* tuple giving its weight — a bare number reads as a percent (`20` is `20%`,
|
|
255
|
+
* the `<percentage>` convention), a `Percentage` expression an annotated or
|
|
256
|
+
* computed weight (`Percentage.of(20)`, `Calc.multiply(Percentage.of(50), ...)`);
|
|
257
|
+
* a plain number-kind `Calc` is rejected, a weight being a `<percentage>`.
|
|
258
|
+
*
|
|
259
|
+
* A polar `space` (`ColorSpace.oklch`, `ColorSpace.lch`, ...) may take a
|
|
260
|
+
* `HueInterpolation` strategy between the space and the colors — the second
|
|
261
|
+
* overload — for how the hue circle is traversed; omit it and the browser
|
|
262
|
+
* defaults to `shorter`. A rectangular space has no hue channel, so passing a
|
|
263
|
+
* strategy is a compile error, mirroring the grammar where
|
|
264
|
+
* `<hue-interpolation-method>` follows only a polar space.
|
|
265
|
+
*
|
|
266
|
+
* Percentages are optional and preserved verbatim — fashionable emits the
|
|
267
|
+
* authored form and never runs the spec's mixing normalization (omitted weights
|
|
268
|
+
* defaulting to `50%`, weights off `100%` rescaling with an alpha multiplier),
|
|
269
|
+
* which is computed-value behavior the browser owns. Like every `Color`, a mix
|
|
270
|
+
* binds and serializes but does not solve, and each arm and each percentage
|
|
271
|
+
* contributes its references to the result.
|
|
272
|
+
*
|
|
273
|
+
* @param space - The interpolation `ColorSpace`; a polar one may be followed by a `HueInterpolation`.
|
|
274
|
+
* @param color1 - The first color, or a `[color, percentage]` tuple weighting it.
|
|
275
|
+
* @param color2 - The second color, or a `[color, percentage]` tuple weighting it.
|
|
276
|
+
* @returns A `Color` unioning both arms' and both percentages' references.
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* Color.serialize(Color.mix(ColorSpace.oklch, Color.named('red'), Color.named('blue')))
|
|
280
|
+
* // 'color-mix(in oklch, red, blue)'
|
|
281
|
+
* Color.serialize(Color.mix(ColorSpace.srgb, [Color.named('white'), 20], Color.named('black')))
|
|
282
|
+
* // 'color-mix(in srgb, white 20%, black)'
|
|
283
|
+
* Color.serialize(Color.mix(ColorSpace.oklch, HueInterpolation.longer, Color.named('red'), Color.named('blue')))
|
|
284
|
+
* // 'color-mix(in oklch longer hue, red, blue)'
|
|
285
|
+
* ```
|
|
286
|
+
* @since 0.2.0
|
|
287
|
+
*/
|
|
288
|
+
const mix = mix$1;
|
|
289
|
+
/**
|
|
290
|
+
* Creates a relative color from an origin and a destination `ColorSpace`:
|
|
291
|
+
* `Color.from(origin, ColorSpace.oklch, l, c, h)` is `oklch(from origin l c h)`
|
|
292
|
+
* and `Color.from(origin, ColorSpace.srgb, r, g, b)` is
|
|
293
|
+
* `color(from origin srgb r g b)`. The browser converts `origin` into the
|
|
294
|
+
* space and exposes its channels as the `Channel` keywords the space names
|
|
295
|
+
* (`Channel.L`/`C`/`H` for `oklch`, `Channel.R`/`G`/`B` for `srgb`, `Channel.Alpha`
|
|
296
|
+
* for both); passing them straight through reproduces the origin, and
|
|
297
|
+
* arithmetic on them derives a related color.
|
|
298
|
+
*
|
|
299
|
+
* The `space` scopes the channel arguments — a keyword the space does not name
|
|
300
|
+
* is a compile error. Each channel serializes independently, wrapped in
|
|
301
|
+
* `calc()` when arithmetic and bare when a lone keyword, and may be
|
|
302
|
+
* `Keyword.none`. A supplied `alpha` renders after a slash
|
|
303
|
+
* (`/ calc(alpha * 0.5)`); omitted, the origin's alpha carries through. The
|
|
304
|
+
* origin's own references union into the result; the channel keywords
|
|
305
|
+
* contribute none, since the browser resolves them from the origin.
|
|
306
|
+
*
|
|
307
|
+
* @param origin - The color to derive from — any `Color`, commonly a `ref`.
|
|
308
|
+
* @param space - The destination `ColorSpace`, fixing the function form and the channels in scope.
|
|
309
|
+
* @param channel1 - The first channel (`l`/`r`), in the space's order.
|
|
310
|
+
* @param channel2 - The second channel (`c`/`g`).
|
|
311
|
+
* @param channel3 - The third channel (`h`/`b`).
|
|
312
|
+
* @param alpha - The optional alpha channel; omitted, the origin's alpha is kept.
|
|
313
|
+
* @returns A `Color` unioning the origin's and the channels' references.
|
|
314
|
+
* @example
|
|
315
|
+
* ```ts
|
|
316
|
+
* const hover = Color.from(Color.ref('accent'), ColorSpace.oklch, Calc.multiply(Channel.L, 0.8), Channel.C, Channel.H)
|
|
317
|
+
* Color.serialize(hover) // 'oklch(from var(--accent) calc(l * 0.8) c h)'
|
|
318
|
+
* const faded = Color.from(Color.ref('brand'), ColorSpace.srgb, Channel.R, Channel.G, Channel.B, Calc.multiply(Channel.Alpha, 0.5))
|
|
319
|
+
* Color.serialize(faded) // 'color(from var(--brand) srgb r g b / calc(alpha * 0.5))'
|
|
320
|
+
* ```
|
|
321
|
+
* @since 0.2.0
|
|
322
|
+
*/
|
|
323
|
+
const from = from$1;
|
|
324
|
+
const bind = bind$1;
|
|
325
|
+
/**
|
|
326
|
+
* Renders a color as CSS text. Channels render space-separated inside
|
|
327
|
+
* the color's own function form — `oklch(...)` or `color(srgb ...)` —
|
|
328
|
+
* each wrapped in `calc()` when it is arithmetic; a `lightDark` renders
|
|
329
|
+
* both arms in full, comma-separated.
|
|
330
|
+
*
|
|
331
|
+
* Options match `Calc.serialize`: partial bindings applied first, and a
|
|
332
|
+
* precision context for unannotated constants.
|
|
333
|
+
*
|
|
334
|
+
* @param color - The color to render.
|
|
335
|
+
* @param options - Optional bindings and precision context.
|
|
336
|
+
* @returns Deterministic CSS text.
|
|
337
|
+
* @example
|
|
338
|
+
* ```ts
|
|
339
|
+
* const surface = Color.oklch(Calc.add(Calc.ref('l'), 0.1), 0.04, 250)
|
|
340
|
+
* Color.serialize(surface) // 'oklch(calc(var(--l) + 0.1) 0.04 250)'
|
|
341
|
+
* ```
|
|
342
|
+
* @since 0.1.0
|
|
343
|
+
*/
|
|
344
|
+
const serialize = serialize$1;
|
|
345
|
+
/**
|
|
346
|
+
* The color's unbound reference names, unioned across channels.
|
|
347
|
+
*
|
|
348
|
+
* @param color - The color to inspect.
|
|
349
|
+
* @returns The set of unbound reference names.
|
|
350
|
+
* @since 0.1.0
|
|
351
|
+
*/
|
|
352
|
+
const refs = refs$1;
|
|
353
|
+
/**
|
|
354
|
+
* The origin-channel keyword tokens the color reads — the `Channel` keywords a
|
|
355
|
+
* relative color's channels reference (`l`, `c`, `h`, ...), gathered across its
|
|
356
|
+
* channels and any nested colors. Empty for a color with no relative parts.
|
|
357
|
+
*
|
|
358
|
+
* The `Color` companion to `Calc.channels`, and the mirror of `refs`: where
|
|
359
|
+
* `refs` reports the custom properties a color depends on, `channels` reports
|
|
360
|
+
* the origin channels a relative color reads. They are disjoint — a channel
|
|
361
|
+
* keyword is never a reference — so a channel token never appears in `refs` nor
|
|
362
|
+
* reaches a `Stylesheet`'s dependency report.
|
|
363
|
+
*
|
|
364
|
+
* @param color - The color to inspect.
|
|
365
|
+
* @returns The set of channel-keyword tokens the color reads.
|
|
366
|
+
* @example
|
|
367
|
+
* ```ts
|
|
368
|
+
* const hover = Color.from(Color.ref('accent'), ColorSpace.oklch, Calc.multiply(Channel.L, 0.8), Channel.C, Channel.H)
|
|
369
|
+
* Color.channels(hover) // Set { 'l', 'c', 'h' }
|
|
370
|
+
* Color.refs(hover) // Set { 'accent' }
|
|
371
|
+
* ```
|
|
372
|
+
* @since 0.2.0
|
|
373
|
+
*/
|
|
374
|
+
const channels = channels$1;
|
|
375
|
+
const equals = equals$1;
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/data/colorSpace.ts
|
|
378
|
+
var colorSpace_exports = /* @__PURE__ */ __exportAll({
|
|
379
|
+
a98Rgb: () => a98Rgb,
|
|
380
|
+
displayP3: () => displayP3,
|
|
381
|
+
hsl: () => hsl,
|
|
382
|
+
hwb: () => hwb,
|
|
383
|
+
lab: () => lab,
|
|
384
|
+
lch: () => lch,
|
|
385
|
+
oklab: () => oklab,
|
|
386
|
+
oklch: () => oklch,
|
|
387
|
+
prophotoRgb: () => prophotoRgb,
|
|
388
|
+
rec2020: () => rec2020,
|
|
389
|
+
srgb: () => srgb,
|
|
390
|
+
srgbLinear: () => srgbLinear,
|
|
391
|
+
xyz: () => xyz,
|
|
392
|
+
xyzD50: () => xyzD50,
|
|
393
|
+
xyzD65: () => xyzD65
|
|
394
|
+
});
|
|
395
|
+
/**
|
|
396
|
+
* The `oklch` space: a polar interpolation space, and an `oklch(from ...)`
|
|
397
|
+
* destination with `Channel.L`/`C`/`H` (and `Alpha`) in scope.
|
|
398
|
+
*
|
|
399
|
+
* @since 0.2.0
|
|
400
|
+
*/
|
|
401
|
+
const oklch = oklch$3;
|
|
402
|
+
/**
|
|
403
|
+
* The `srgb` space: a rectangular interpolation space, and a
|
|
404
|
+
* `color(from ... srgb ...)` destination with `Channel.R`/`G`/`B` (and `Alpha`)
|
|
405
|
+
* in scope.
|
|
406
|
+
*
|
|
407
|
+
* @since 0.2.0
|
|
408
|
+
*/
|
|
409
|
+
const srgb = srgb$3;
|
|
410
|
+
/**
|
|
411
|
+
* The `srgb-linear` space (rectangular).
|
|
412
|
+
*
|
|
413
|
+
* @since 0.2.0
|
|
414
|
+
*/
|
|
415
|
+
const srgbLinear = srgbLinear$1;
|
|
416
|
+
/**
|
|
417
|
+
* The `display-p3` space (rectangular).
|
|
418
|
+
*
|
|
419
|
+
* @since 0.2.0
|
|
420
|
+
*/
|
|
421
|
+
const displayP3 = displayP3$1;
|
|
422
|
+
/**
|
|
423
|
+
* The `a98-rgb` space (rectangular).
|
|
424
|
+
*
|
|
425
|
+
* @since 0.2.0
|
|
426
|
+
*/
|
|
427
|
+
const a98Rgb = a98Rgb$1;
|
|
428
|
+
/**
|
|
429
|
+
* The `prophoto-rgb` space (rectangular).
|
|
430
|
+
*
|
|
431
|
+
* @since 0.2.0
|
|
432
|
+
*/
|
|
433
|
+
const prophotoRgb = prophotoRgb$1;
|
|
434
|
+
/**
|
|
435
|
+
* The `rec2020` space (rectangular).
|
|
436
|
+
*
|
|
437
|
+
* @since 0.2.0
|
|
438
|
+
*/
|
|
439
|
+
const rec2020 = rec2020$1;
|
|
440
|
+
/**
|
|
441
|
+
* The `lab` space (rectangular).
|
|
442
|
+
*
|
|
443
|
+
* @since 0.2.0
|
|
444
|
+
*/
|
|
445
|
+
const lab = lab$1;
|
|
446
|
+
/**
|
|
447
|
+
* The `oklab` space (rectangular).
|
|
448
|
+
*
|
|
449
|
+
* @since 0.2.0
|
|
450
|
+
*/
|
|
451
|
+
const oklab = oklab$1;
|
|
452
|
+
/**
|
|
453
|
+
* The `xyz` space (rectangular; an alias for `xyz-d65`).
|
|
454
|
+
*
|
|
455
|
+
* @since 0.2.0
|
|
456
|
+
*/
|
|
457
|
+
const xyz = xyz$1;
|
|
458
|
+
/**
|
|
459
|
+
* The `xyz-d50` space (rectangular).
|
|
460
|
+
*
|
|
461
|
+
* @since 0.2.0
|
|
462
|
+
*/
|
|
463
|
+
const xyzD50 = xyzD50$1;
|
|
464
|
+
/**
|
|
465
|
+
* The `xyz-d65` space (rectangular).
|
|
466
|
+
*
|
|
467
|
+
* @since 0.2.0
|
|
468
|
+
*/
|
|
469
|
+
const xyzD65 = xyzD65$1;
|
|
470
|
+
/**
|
|
471
|
+
* The `hsl` space (polar).
|
|
472
|
+
*
|
|
473
|
+
* @since 0.2.0
|
|
474
|
+
*/
|
|
475
|
+
const hsl = hsl$1;
|
|
476
|
+
/**
|
|
477
|
+
* The `hwb` space (polar).
|
|
478
|
+
*
|
|
479
|
+
* @since 0.2.0
|
|
480
|
+
*/
|
|
481
|
+
const hwb = hwb$1;
|
|
482
|
+
/**
|
|
483
|
+
* The `lch` space (polar).
|
|
484
|
+
*
|
|
485
|
+
* @since 0.2.0
|
|
486
|
+
*/
|
|
487
|
+
const lch = lch$1;
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region src/data/hueInterpolation.ts
|
|
490
|
+
var hueInterpolation_exports = /* @__PURE__ */ __exportAll({
|
|
491
|
+
decreasing: () => decreasing,
|
|
492
|
+
increasing: () => increasing,
|
|
493
|
+
interpolate: () => interpolate,
|
|
494
|
+
longer: () => longer,
|
|
495
|
+
shorter: () => shorter
|
|
496
|
+
});
|
|
497
|
+
/**
|
|
498
|
+
* The `shorter` strategy — the short arc between the two hues (the browser
|
|
499
|
+
* default). Serializes as `shorter hue`.
|
|
500
|
+
*
|
|
501
|
+
* @since 0.2.0
|
|
502
|
+
*/
|
|
503
|
+
const shorter = shorter$1;
|
|
504
|
+
/**
|
|
505
|
+
* The `longer` strategy — the long arc between the two hues. Serializes as
|
|
506
|
+
* `longer hue`.
|
|
507
|
+
*
|
|
508
|
+
* @since 0.2.0
|
|
509
|
+
*/
|
|
510
|
+
const longer = longer$1;
|
|
511
|
+
/**
|
|
512
|
+
* The `increasing` strategy — hues traversed in increasing order, wrapping past
|
|
513
|
+
* `360` if needed. Serializes as `increasing hue`.
|
|
514
|
+
*
|
|
515
|
+
* @since 0.2.0
|
|
516
|
+
*/
|
|
517
|
+
const increasing = increasing$1;
|
|
518
|
+
/**
|
|
519
|
+
* The `decreasing` strategy — hues traversed in decreasing order, wrapping past
|
|
520
|
+
* `0` if needed. Serializes as `decreasing hue`.
|
|
521
|
+
*
|
|
522
|
+
* @since 0.2.0
|
|
523
|
+
*/
|
|
524
|
+
const decreasing = decreasing$1;
|
|
525
|
+
/**
|
|
526
|
+
* Builds the hue at `t` along the arc from `from` to `to` under `strategy` — the
|
|
527
|
+
* JS side of what a polar `Color.mix` emits for the browser. Hues are numbers of
|
|
528
|
+
* degrees (as an oklch/lch hue channel is), and `from`, `to`, and `t` are each a
|
|
529
|
+
* number or a `Calc`, so the result is a `Calc` too: fully symbolic when any
|
|
530
|
+
* argument is, folding to a constant when all are numbers.
|
|
531
|
+
*
|
|
532
|
+
* The hue math is the CSS Color 4 fixup, written branchlessly with `mod`: each
|
|
533
|
+
* strategy is a signed delta added to `from` as `t` runs `0` (at `from`) to `1`
|
|
534
|
+
* (at `to`). `shorter` and `longer` take the short or long arc between the hues;
|
|
535
|
+
* `increasing`/`decreasing` force the direction. The result is unwrapped — it may
|
|
536
|
+
* fall outside `[0, 360)`, which the browser resolves as a hue — and unions the
|
|
537
|
+
* arguments' references. Drop it straight into a hue channel (`Color.oklch`).
|
|
538
|
+
*
|
|
539
|
+
* @param strategy - The traversal strategy (`shorter`, `longer`, ...).
|
|
540
|
+
* @param from - The start hue, in degrees: a number or a `Calc`.
|
|
541
|
+
* @param to - The end hue, in degrees: a number or a `Calc`.
|
|
542
|
+
* @param t - The interpolation parameter, `0` to `1`: a number or a `Calc`.
|
|
543
|
+
* @returns The interpolated hue in degrees, a `Calc` unioning the arguments' references.
|
|
544
|
+
* @example
|
|
545
|
+
* ```ts
|
|
546
|
+
* const hue = HueInterpolation.interpolate(HueInterpolation.shorter, 30, Calc.ref('to'), Calc.ref('t'))
|
|
547
|
+
* Calc.serialize(hue) // 'calc(30 + (mod(var(--to) - 30 + 180, 360) - 180) * var(--t))'
|
|
548
|
+
* Calc.serialize(HueInterpolation.interpolate(HueInterpolation.increasing, 20, 350, 0.5)) // '185'
|
|
549
|
+
* ```
|
|
550
|
+
* @since 0.2.0
|
|
551
|
+
*/
|
|
552
|
+
const interpolate = interpolate$1;
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region src/data/keywords.ts
|
|
555
|
+
var keywords_exports = /* @__PURE__ */ __exportAll({
|
|
556
|
+
isNone: () => isNone,
|
|
557
|
+
none: () => none
|
|
558
|
+
});
|
|
559
|
+
/**
|
|
560
|
+
* The `none` keyword — CSS's missing-component value. Accepted where a
|
|
561
|
+
* position declares it: color channels today (`oklch(0 0 none)`), other
|
|
562
|
+
* slots as they arrive.
|
|
563
|
+
*
|
|
564
|
+
* @since 0.2.0
|
|
565
|
+
*/
|
|
566
|
+
const none = none$1;
|
|
567
|
+
/**
|
|
568
|
+
* Checks if a value is the `none` keyword.
|
|
569
|
+
*
|
|
570
|
+
* True only for `none` itself, which carries the brand.
|
|
571
|
+
*
|
|
572
|
+
* @param u - The value to check.
|
|
573
|
+
* @returns `true` if the value is `none`, `false` otherwise.
|
|
574
|
+
* @since 0.2.0
|
|
575
|
+
*/
|
|
576
|
+
const isNone = isNone$1;
|
|
577
|
+
//#endregion
|
|
578
|
+
//#region src/data/length.internal.ts
|
|
579
|
+
/** @internal */
|
|
580
|
+
const px$1 = (value, precision) => dimension(value, "px", "length", precision);
|
|
581
|
+
/** @internal */
|
|
582
|
+
const rem$1 = (value, precision) => dimension(value, "rem", "length", precision);
|
|
583
|
+
/** @internal */
|
|
584
|
+
const em$1 = (value, precision) => dimension(value, "em", "length", precision);
|
|
585
|
+
/** @internal */
|
|
586
|
+
const vw$1 = (value, precision) => dimension(value, "vw", "length", precision);
|
|
587
|
+
/** @internal */
|
|
588
|
+
const vh$1 = (value, precision) => dimension(value, "vh", "length", precision);
|
|
589
|
+
/** @internal */
|
|
590
|
+
const vmin$1 = (value, precision) => dimension(value, "vmin", "length", precision);
|
|
591
|
+
/** @internal */
|
|
592
|
+
const vmax$1 = (value, precision) => dimension(value, "vmax", "length", precision);
|
|
593
|
+
//#endregion
|
|
594
|
+
//#region src/data/length.ts
|
|
595
|
+
var length_exports = /* @__PURE__ */ __exportAll({
|
|
596
|
+
em: () => em,
|
|
597
|
+
px: () => px,
|
|
598
|
+
rem: () => rem,
|
|
599
|
+
vh: () => vh,
|
|
600
|
+
vmax: () => vmax,
|
|
601
|
+
vmin: () => vmin,
|
|
602
|
+
vw: () => vw
|
|
603
|
+
});
|
|
604
|
+
/**
|
|
605
|
+
* A length in `px` (absolute pixels).
|
|
606
|
+
*
|
|
607
|
+
* @param value - The pixel count.
|
|
608
|
+
* @param precision - Optional serialization precision.
|
|
609
|
+
* @returns A `px` length expression.
|
|
610
|
+
* @example
|
|
611
|
+
* ```ts
|
|
612
|
+
* Calc.serialize(Length.px(16)) // '16px'
|
|
613
|
+
* ```
|
|
614
|
+
* @since 0.2.0
|
|
615
|
+
*/
|
|
616
|
+
const px = px$1;
|
|
617
|
+
/**
|
|
618
|
+
* A length in `rem` (relative to the root font size).
|
|
619
|
+
*
|
|
620
|
+
* @param value - The multiple of the root font size.
|
|
621
|
+
* @param precision - Optional serialization precision.
|
|
622
|
+
* @returns A `rem` length expression.
|
|
623
|
+
* @since 0.2.0
|
|
624
|
+
*/
|
|
625
|
+
const rem = rem$1;
|
|
626
|
+
/**
|
|
627
|
+
* A length in `em` (relative to the element font size).
|
|
628
|
+
*
|
|
629
|
+
* @param value - The multiple of the element font size.
|
|
630
|
+
* @param precision - Optional serialization precision.
|
|
631
|
+
* @returns An `em` length expression.
|
|
632
|
+
* @since 0.2.0
|
|
633
|
+
*/
|
|
634
|
+
const em = em$1;
|
|
635
|
+
/**
|
|
636
|
+
* A length in `vw` (1% of the viewport width).
|
|
637
|
+
*
|
|
638
|
+
* @param value - The percentage of viewport width.
|
|
639
|
+
* @param precision - Optional serialization precision.
|
|
640
|
+
* @returns A `vw` length expression.
|
|
641
|
+
* @since 0.2.0
|
|
642
|
+
*/
|
|
643
|
+
const vw = vw$1;
|
|
644
|
+
/**
|
|
645
|
+
* A length in `vh` (1% of the viewport height).
|
|
646
|
+
*
|
|
647
|
+
* @param value - The percentage of viewport height.
|
|
648
|
+
* @param precision - Optional serialization precision.
|
|
649
|
+
* @returns A `vh` length expression.
|
|
650
|
+
* @since 0.2.0
|
|
651
|
+
*/
|
|
652
|
+
const vh = vh$1;
|
|
653
|
+
/**
|
|
654
|
+
* A length in `vmin` (1% of the smaller viewport axis).
|
|
655
|
+
*
|
|
656
|
+
* @param value - The percentage of the smaller viewport axis.
|
|
657
|
+
* @param precision - Optional serialization precision.
|
|
658
|
+
* @returns A `vmin` length expression.
|
|
659
|
+
* @since 0.2.0
|
|
660
|
+
*/
|
|
661
|
+
const vmin = vmin$1;
|
|
662
|
+
/**
|
|
663
|
+
* A length in `vmax` (1% of the larger viewport axis).
|
|
664
|
+
*
|
|
665
|
+
* @param value - The percentage of the larger viewport axis.
|
|
666
|
+
* @param precision - Optional serialization precision.
|
|
667
|
+
* @returns A `vmax` length expression.
|
|
668
|
+
* @since 0.2.0
|
|
669
|
+
*/
|
|
670
|
+
const vmax = vmax$1;
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region src/data/percentage.ts
|
|
673
|
+
var percentage_exports = /* @__PURE__ */ __exportAll({ of: () => of });
|
|
674
|
+
/**
|
|
675
|
+
* A percentage — a number rendered with a trailing `%`. `Percentage.of(40)`
|
|
676
|
+
* serializes as `40%`. The value passes through unrounded; the optional
|
|
677
|
+
* `Precision` pins serialization exactly as `Calc.of` does.
|
|
678
|
+
*
|
|
679
|
+
* @param value - The percentage magnitude (`40` for `40%`, not `0.4`).
|
|
680
|
+
* @param precision - Optional serialization precision.
|
|
681
|
+
* @returns A `<percentage>` expression.
|
|
682
|
+
* @example
|
|
683
|
+
* ```ts
|
|
684
|
+
* Calc.serialize(Percentage.of(40)) // '40%'
|
|
685
|
+
* Calc.serialize(Calc.add(Percentage.of(20), Percentage.of(5))) // '25%'
|
|
686
|
+
* ```
|
|
687
|
+
* @since 0.2.0
|
|
688
|
+
*/
|
|
689
|
+
const of = of$1;
|
|
690
|
+
//#endregion
|
|
691
|
+
//#region src/data/units.ts
|
|
692
|
+
var units_exports = /* @__PURE__ */ __exportAll({});
|
|
693
|
+
//#endregion
|
|
694
|
+
export { angle_exports as Angle, channels_exports as Channel, color_exports as Color, colorSpace_exports as ColorSpace, hueInterpolation_exports as HueInterpolation, keywords_exports as Keyword, length_exports as Length, percentage_exports as Percentage, units_exports as Unit };
|
|
695
|
+
|
|
696
|
+
//# sourceMappingURL=index.mjs.map
|