@mochi-css/vanilla 0.1.0 → 1.1.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/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { DataType, Globals, ObsoleteProperties, Properties } from "csstype";
1
+ import { ObsoleteProperties, Properties } from "csstype";
2
2
  import { ComponentProps, ComponentType, FC, HTMLElementType } from "react";
3
3
 
4
- //#region src/values/shared.d.ts
4
+ //#region src/values/index.d.ts
5
5
  type CssVar = `--${string}`;
6
6
  type CssVarVal = `var(${CssVar})`;
7
7
  type CssLikeObject<T> = {
@@ -9,38 +9,6 @@ type CssLikeObject<T> = {
9
9
  };
10
10
  type CssLike<T> = T | CssLikeObject<T>;
11
11
  //#endregion
12
- //#region src/values/length.d.ts
13
- declare class PixelValue extends NumericValue<"px"> {
14
- constructor(value: number);
15
- }
16
- declare class PercentValue extends NumericValue<"%"> {
17
- constructor(value: number);
18
- }
19
- type LengthUnit = "%" | "px" | "vw" | "vh" | "rem";
20
- type CssLengthString = `${number}${LengthUnit}` | CssVarVal | Globals | "auto";
21
- type CssLength = number | CssLengthString | CssVarVal;
22
- type CssLengthLike = CssLike<CssLength>;
23
- declare function asLength(value: CssLengthLike): CssLengthString;
24
- //#endregion
25
- //#region src/values/number.d.ts
26
- type Unit = "%" | "px" | "deg" | "rad" | "grad" | "rem" | "vw" | "vh";
27
- declare class NumericValue<T extends LengthUnit = LengthUnit> {
28
- private readonly value;
29
- private readonly suffix;
30
- constructor(value: number, suffix: T);
31
- toString(): `${number}${T}`;
32
- }
33
- //#endregion
34
- //#region src/values/color.d.ts
35
- type RGBColorString = `rgb(${number},${number},${number})`;
36
- type RGBAColorString = `rgba(${number},${number},${number},${number})`;
37
- type HSLColorString = `hsl(${number},${number},${number})`;
38
- type HSLAColorString = `hsla(${number},${number},${number},${number})`;
39
- type ColorString = RGBColorString | RGBAColorString | HSLColorString | HSLAColorString;
40
- type CssColor = DataType.NamedColor | "transparent" | "currentColor" | "auto" | ColorString | CssVarVal;
41
- type CssColorLike = CssLike<CssColor>;
42
- declare function asColor(value: CssColorLike): CssColor;
43
- //#endregion
44
12
  //#region src/token.d.ts
45
13
  /**
46
14
  * Represents a CSS custom property (design token) with type information.
@@ -51,7 +19,7 @@ declare function asColor(value: CssColorLike): CssColor;
51
19
  * primaryColor.variable // '--primary-color'
52
20
  * primaryColor.value // 'var(--primary-color)'
53
21
  */
54
- declare class Token<T> {
22
+ declare class Token {
55
23
  readonly name: string;
56
24
  /**
57
25
  * Creates a new CSS token.
@@ -82,7 +50,7 @@ declare class Token<T> {
82
50
  * const spacing = createToken<number>('spacing-md')
83
51
  * // Use in styles: { gap: spacing.value }
84
52
  */
85
- declare function createToken<T>(name: string): Token<T>;
53
+ declare function createToken(name: string): Token;
86
54
  //#endregion
87
55
  //#region src/selector.d.ts
88
56
  /**
@@ -151,53 +119,342 @@ declare class MochiSelector {
151
119
  private static split;
152
120
  }
153
121
  //#endregion
122
+ //#region src/propertyUnits.generated.d.ts
123
+ declare const propertyUnits: {
124
+ readonly animation: "ms";
125
+ readonly animationDelay: "ms";
126
+ readonly animationDuration: "ms";
127
+ readonly animationRange: "px";
128
+ readonly animationRangeCenter: "px";
129
+ readonly animationRangeEnd: "px";
130
+ readonly animationRangeStart: "px";
131
+ readonly background: "px";
132
+ readonly backgroundPosition: "px";
133
+ readonly backgroundPositionBlock: "px";
134
+ readonly backgroundPositionInline: "px";
135
+ readonly backgroundPositionX: "px";
136
+ readonly backgroundPositionY: "px";
137
+ readonly backgroundSize: "px";
138
+ readonly backgroundTbd: "px";
139
+ readonly baselineShift: "px";
140
+ readonly blockSize: "px";
141
+ readonly blockStep: "px";
142
+ readonly blockStepSize: "px";
143
+ readonly border: "px";
144
+ readonly borderBlock: "px";
145
+ readonly borderBlockClip: "px";
146
+ readonly borderBlockEnd: "px";
147
+ readonly borderBlockEndClip: "px";
148
+ readonly borderBlockEndRadius: "px";
149
+ readonly borderBlockEndWidth: "px";
150
+ readonly borderBlockStart: "px";
151
+ readonly borderBlockStartClip: "px";
152
+ readonly borderBlockStartRadius: "px";
153
+ readonly borderBlockStartWidth: "px";
154
+ readonly borderBlockWidth: "px";
155
+ readonly borderBottom: "px";
156
+ readonly borderBottomClip: "px";
157
+ readonly borderBottomLeftRadius: "px";
158
+ readonly borderBottomRadius: "px";
159
+ readonly borderBottomRightRadius: "px";
160
+ readonly borderBottomWidth: "px";
161
+ readonly borderClip: "px";
162
+ readonly borderEndEndRadius: "px";
163
+ readonly borderEndStartRadius: "px";
164
+ readonly borderImage: "%";
165
+ readonly borderImageOutset: "px";
166
+ readonly borderImageSlice: "%";
167
+ readonly borderImageWidth: "px";
168
+ readonly borderInline: "px";
169
+ readonly borderInlineClip: "px";
170
+ readonly borderInlineEnd: "px";
171
+ readonly borderInlineEndClip: "px";
172
+ readonly borderInlineEndRadius: "px";
173
+ readonly borderInlineEndWidth: "px";
174
+ readonly borderInlineStart: "px";
175
+ readonly borderInlineStartClip: "px";
176
+ readonly borderInlineStartRadius: "px";
177
+ readonly borderInlineStartWidth: "px";
178
+ readonly borderInlineWidth: "px";
179
+ readonly borderLeft: "px";
180
+ readonly borderLeftClip: "px";
181
+ readonly borderLeftRadius: "px";
182
+ readonly borderLeftWidth: "px";
183
+ readonly borderLimit: "px";
184
+ readonly borderRadius: "px";
185
+ readonly borderRight: "px";
186
+ readonly borderRightClip: "px";
187
+ readonly borderRightRadius: "px";
188
+ readonly borderRightWidth: "px";
189
+ readonly borderSpacing: "px";
190
+ readonly borderStartEndRadius: "px";
191
+ readonly borderStartStartRadius: "px";
192
+ readonly borderTop: "px";
193
+ readonly borderTopClip: "px";
194
+ readonly borderTopLeftRadius: "px";
195
+ readonly borderTopRadius: "px";
196
+ readonly borderTopRightRadius: "px";
197
+ readonly borderTopWidth: "px";
198
+ readonly borderWidth: "px";
199
+ readonly bottom: "px";
200
+ readonly boxShadow: "px";
201
+ readonly boxShadowBlur: "px";
202
+ readonly boxShadowOffset: "px";
203
+ readonly boxShadowSpread: "px";
204
+ readonly columnGap: "px";
205
+ readonly columnHeight: "px";
206
+ readonly columnRule: "px";
207
+ readonly columnRuleEdgeInset: "px";
208
+ readonly columnRuleEdgeInsetEnd: "px";
209
+ readonly columnRuleEdgeInsetStart: "px";
210
+ readonly columnRuleInset: "px";
211
+ readonly columnRuleInsetEnd: "px";
212
+ readonly columnRuleInsetStart: "px";
213
+ readonly columnRuleInteriorInset: "px";
214
+ readonly columnRuleInteriorInsetEnd: "px";
215
+ readonly columnRuleInteriorInsetStart: "px";
216
+ readonly columnRuleWidth: "px";
217
+ readonly columns: "px";
218
+ readonly columnWidth: "px";
219
+ readonly containIntrinsicBlockSize: "px";
220
+ readonly containIntrinsicHeight: "px";
221
+ readonly containIntrinsicInlineSize: "px";
222
+ readonly containIntrinsicSize: "px";
223
+ readonly containIntrinsicWidth: "px";
224
+ readonly corner: "px";
225
+ readonly cornerBlockEnd: "px";
226
+ readonly cornerBlockStart: "px";
227
+ readonly cornerBottom: "px";
228
+ readonly cornerBottomLeft: "px";
229
+ readonly cornerBottomRight: "px";
230
+ readonly cornerEndEnd: "px";
231
+ readonly cornerEndStart: "px";
232
+ readonly cornerInlineEnd: "px";
233
+ readonly cornerInlineStart: "px";
234
+ readonly cornerLeft: "px";
235
+ readonly cornerRight: "px";
236
+ readonly cornerStartEnd: "px";
237
+ readonly cornerStartStart: "px";
238
+ readonly cornerTop: "px";
239
+ readonly cornerTopLeft: "px";
240
+ readonly cornerTopRight: "px";
241
+ readonly cx: "px";
242
+ readonly cy: "px";
243
+ readonly fillOpacity: "%";
244
+ readonly fillPosition: "px";
245
+ readonly fillSize: "px";
246
+ readonly flex: "px";
247
+ readonly flexBasis: "px";
248
+ readonly floatOffset: "px";
249
+ readonly floodOpacity: "%";
250
+ readonly flowTolerance: "px";
251
+ readonly font: "deg";
252
+ readonly fontSize: "px";
253
+ readonly fontStretch: "%";
254
+ readonly fontStyle: "deg";
255
+ readonly fontWidth: "%";
256
+ readonly gap: "px";
257
+ readonly grid: "px";
258
+ readonly gridAutoColumns: "px";
259
+ readonly gridAutoRows: "px";
260
+ readonly gridColumnGap: "px";
261
+ readonly gridGap: "px";
262
+ readonly gridRowGap: "px";
263
+ readonly gridTemplate: "px";
264
+ readonly gridTemplateColumns: "px";
265
+ readonly gridTemplateRows: "px";
266
+ readonly height: "px";
267
+ readonly hyphenateLimitZone: "px";
268
+ readonly imageOrientation: "deg";
269
+ readonly imageResolution: "dppx";
270
+ readonly initialLetterWrap: "px";
271
+ readonly inlineSize: "px";
272
+ readonly inset: "px";
273
+ readonly insetBlock: "px";
274
+ readonly insetBlockEnd: "px";
275
+ readonly insetBlockStart: "px";
276
+ readonly insetInline: "px";
277
+ readonly insetInlineEnd: "px";
278
+ readonly insetInlineStart: "px";
279
+ readonly interestDelay: "ms";
280
+ readonly interestDelayEnd: "ms";
281
+ readonly interestDelayStart: "ms";
282
+ readonly itemFlow: "px";
283
+ readonly left: "px";
284
+ readonly letterSpacing: "px";
285
+ readonly lineHeight: "px";
286
+ readonly lineHeightStep: "px";
287
+ readonly linePadding: "px";
288
+ readonly margin: "px";
289
+ readonly marginBlock: "px";
290
+ readonly marginBlockEnd: "px";
291
+ readonly marginBlockStart: "px";
292
+ readonly marginBottom: "px";
293
+ readonly marginInline: "px";
294
+ readonly marginInlineEnd: "px";
295
+ readonly marginInlineStart: "px";
296
+ readonly marginLeft: "px";
297
+ readonly marginRight: "px";
298
+ readonly marginTop: "px";
299
+ readonly mask: "px";
300
+ readonly maskBorder: "%";
301
+ readonly maskBorderOutset: "px";
302
+ readonly maskBorderSlice: "%";
303
+ readonly maskBorderWidth: "px";
304
+ readonly maskPosition: "px";
305
+ readonly maskSize: "px";
306
+ readonly maxBlockSize: "px";
307
+ readonly maxHeight: "px";
308
+ readonly maxInlineSize: "px";
309
+ readonly maxWidth: "px";
310
+ readonly minBlockSize: "px";
311
+ readonly minHeight: "px";
312
+ readonly minInlineSize: "px";
313
+ readonly minWidth: "px";
314
+ readonly objectPosition: "px";
315
+ readonly offset: "px";
316
+ readonly offsetAnchor: "px";
317
+ readonly offsetDistance: "px";
318
+ readonly offsetPosition: "px";
319
+ readonly offsetRotate: "deg";
320
+ readonly opacity: "%";
321
+ readonly outline: "px";
322
+ readonly outlineOffset: "px";
323
+ readonly outlineWidth: "px";
324
+ readonly overflowClipMargin: "px";
325
+ readonly overflowClipMarginBlock: "px";
326
+ readonly overflowClipMarginBlockEnd: "px";
327
+ readonly overflowClipMarginBlockStart: "px";
328
+ readonly overflowClipMarginBottom: "px";
329
+ readonly overflowClipMarginInline: "px";
330
+ readonly overflowClipMarginInlineEnd: "px";
331
+ readonly overflowClipMarginInlineStart: "px";
332
+ readonly overflowClipMarginLeft: "px";
333
+ readonly overflowClipMarginRight: "px";
334
+ readonly overflowClipMarginTop: "px";
335
+ readonly padding: "px";
336
+ readonly paddingBlock: "px";
337
+ readonly paddingBlockEnd: "px";
338
+ readonly paddingBlockStart: "px";
339
+ readonly paddingBottom: "px";
340
+ readonly paddingInline: "px";
341
+ readonly paddingInlineEnd: "px";
342
+ readonly paddingInlineStart: "px";
343
+ readonly paddingLeft: "px";
344
+ readonly paddingRight: "px";
345
+ readonly paddingTop: "px";
346
+ readonly pause: "ms";
347
+ readonly pauseAfter: "ms";
348
+ readonly pauseBefore: "ms";
349
+ readonly perspective: "px";
350
+ readonly perspectiveOrigin: "px";
351
+ readonly r: "px";
352
+ readonly rest: "ms";
353
+ readonly restAfter: "ms";
354
+ readonly restBefore: "ms";
355
+ readonly right: "px";
356
+ readonly rotate: "deg";
357
+ readonly rowGap: "px";
358
+ readonly rowRule: "px";
359
+ readonly rowRuleEdgeInset: "px";
360
+ readonly rowRuleEdgeInsetEnd: "px";
361
+ readonly rowRuleEdgeInsetStart: "px";
362
+ readonly rowRuleInset: "px";
363
+ readonly rowRuleInsetEnd: "px";
364
+ readonly rowRuleInsetStart: "px";
365
+ readonly rowRuleInteriorInset: "px";
366
+ readonly rowRuleInteriorInsetEnd: "px";
367
+ readonly rowRuleInteriorInsetStart: "px";
368
+ readonly rowRuleWidth: "px";
369
+ readonly rule: "px";
370
+ readonly ruleEdgeInset: "px";
371
+ readonly ruleInset: "px";
372
+ readonly ruleInsetEnd: "px";
373
+ readonly ruleInsetStart: "px";
374
+ readonly ruleInteriorInset: "px";
375
+ readonly ruleWidth: "px";
376
+ readonly rx: "px";
377
+ readonly ry: "px";
378
+ readonly scale: "%";
379
+ readonly scrollMargin: "px";
380
+ readonly scrollMarginBlock: "px";
381
+ readonly scrollMarginBlockEnd: "px";
382
+ readonly scrollMarginBlockStart: "px";
383
+ readonly scrollMarginBottom: "px";
384
+ readonly scrollMarginInline: "px";
385
+ readonly scrollMarginInlineEnd: "px";
386
+ readonly scrollMarginInlineStart: "px";
387
+ readonly scrollMarginLeft: "px";
388
+ readonly scrollMarginRight: "px";
389
+ readonly scrollMarginTop: "px";
390
+ readonly scrollPadding: "px";
391
+ readonly scrollPaddingBlock: "px";
392
+ readonly scrollPaddingBlockEnd: "px";
393
+ readonly scrollPaddingBlockStart: "px";
394
+ readonly scrollPaddingBottom: "px";
395
+ readonly scrollPaddingInline: "px";
396
+ readonly scrollPaddingInlineEnd: "px";
397
+ readonly scrollPaddingInlineStart: "px";
398
+ readonly scrollPaddingLeft: "px";
399
+ readonly scrollPaddingRight: "px";
400
+ readonly scrollPaddingTop: "px";
401
+ readonly shapeImageThreshold: "%";
402
+ readonly shapeMargin: "px";
403
+ readonly shapePadding: "px";
404
+ readonly stopOpacity: "%";
405
+ readonly strokeDasharray: "px";
406
+ readonly strokeDashcorner: "px";
407
+ readonly strokeDashCorner: "px";
408
+ readonly strokeDashoffset: "px";
409
+ readonly strokeOpacity: "%";
410
+ readonly strokePosition: "px";
411
+ readonly strokeSize: "px";
412
+ readonly strokeWidth: "px";
413
+ readonly tabSize: "px";
414
+ readonly textDecoration: "px";
415
+ readonly textDecorationInset: "px";
416
+ readonly textDecorationThickness: "px";
417
+ readonly textIndent: "px";
418
+ readonly textShadow: "px";
419
+ readonly textSizeAdjust: "%";
420
+ readonly textUnderlineOffset: "px";
421
+ readonly timelineTrigger: "px";
422
+ readonly timelineTriggerExitRange: "px";
423
+ readonly timelineTriggerExitRangeEnd: "px";
424
+ readonly timelineTriggerExitRangeStart: "px";
425
+ readonly timelineTriggerRange: "px";
426
+ readonly timelineTriggerRangeEnd: "px";
427
+ readonly timelineTriggerRangeStart: "px";
428
+ readonly top: "px";
429
+ readonly transformOrigin: "px";
430
+ readonly transition: "ms";
431
+ readonly transitionDelay: "ms";
432
+ readonly transitionDuration: "ms";
433
+ readonly translate: "px";
434
+ readonly verticalAlign: "px";
435
+ readonly viewTimeline: "px";
436
+ readonly viewTimelineInset: "px";
437
+ readonly voiceDuration: "ms";
438
+ readonly voicePitch: "Hz";
439
+ readonly voiceRange: "Hz";
440
+ readonly voiceRate: "%";
441
+ readonly width: "px";
442
+ readonly wordSpacing: "px";
443
+ readonly x: "px";
444
+ readonly y: "px";
445
+ readonly zoom: "%";
446
+ };
447
+ type PropertyWithUnit = keyof typeof propertyUnits;
448
+ //#endregion
154
449
  //#region src/props.d.ts
155
450
  /** All non-obsolete CSS properties from csstype */
156
451
  type Props = Required<Omit<Properties, keyof ObsoleteProperties>>;
157
- declare const styles: {
158
- borderBlockEndWidth: typeof asLength;
159
- borderBlockStartWidth: typeof asLength;
160
- borderBottomColor: typeof asColor;
161
- borderBottomLeftRadius: typeof asLength;
162
- borderBottomRightRadius: typeof asLength;
163
- borderBottomWidth: typeof asLength;
164
- borderEndEndRadius: typeof asLength;
165
- borderEndStartRadius: typeof asLength;
166
- borderInlineEndWidth: typeof asLength;
167
- borderInlineStartWidth: typeof asLength;
168
- borderLeftWidth: typeof asLength;
169
- borderRightWidth: typeof asLength;
170
- borderStartEndRadius: typeof asLength;
171
- borderStartStartRadius: typeof asLength;
172
- borderTopLeftRadius: typeof asLength;
173
- borderTopRightRadius: typeof asLength;
174
- borderTopWidth: typeof asLength;
175
- borderBlockWidth: typeof asLength;
176
- borderInlineWidth: typeof asLength;
177
- borderWidth: typeof asLength;
178
- gap: typeof asLength;
179
- height: typeof asLength;
180
- lineHeight: typeof asLength;
181
- marginBottom: typeof asLength;
182
- marginLeft: typeof asLength;
183
- marginRight: typeof asLength;
184
- marginTop: typeof asLength;
185
- paddingBottom: typeof asLength;
186
- paddingLeft: typeof asLength;
187
- paddingRight: typeof asLength;
188
- paddingTop: typeof asLength;
189
- width: typeof asLength;
190
- };
452
+ /** Properties that have default units and are valid CSS properties */
453
+ type PropsWithUnit = PropertyWithUnit & keyof Props;
191
454
  /**
192
- * Checks if a property name is a CSS custom property (variable).
455
+ * Converts a kebab-case string to camelCase.
193
456
  */
194
457
 
195
- /**
196
- * Converts a CSS-like value to a string for use as a CSS variable value.
197
- * @param value - The value to convert (string, number, or wrapped value)
198
- * @returns The string representation
199
- */
200
- declare function asVar(value: CssLike<string | number>): string;
201
458
  /** A nested CSS selector pattern containing the parent reference `&` */
202
459
  type NestedCssSelector = `${string}&${string}`;
203
460
  /** A CSS media query starting with `@` */
@@ -207,8 +464,11 @@ type NestedStyleKeys = MediaSelector | NestedCssSelector;
207
464
  * Style properties without nesting support.
208
465
  * Includes all standard CSS properties with type-safe value converters,
209
466
  * plus CSS custom properties (variables).
467
+ *
468
+ * Properties with known units (e.g., width, height, padding) accept numbers
469
+ * that are automatically converted with their default unit (e.g., px, ms).
210
470
  */
211
- type SimpleStyleProps = { [K in keyof typeof styles]?: Parameters<(typeof styles)[K]>[0] } & { [K in Exclude<keyof Props, keyof typeof styles>]?: CssLike<Props[K]> } & { [K in CssVar]?: Parameters<(typeof asVar)>[0] };
471
+ type SimpleStyleProps = { [K in PropsWithUnit]?: CssLike<number | Props[K]> } & { [K in Exclude<keyof Props, PropsWithUnit>]?: CssLike<Props[K]> } & Partial<Record<CssVar, CssLike<string | number>>>;
212
472
  /**
213
473
  * Full style properties type with support for nested selectors and media queries.
214
474
  * Extends SimpleStyleProps to allow recursive style definitions.
@@ -296,8 +556,21 @@ declare class CssObjectBlock {
296
556
  */
297
557
  asCssString(root: string): string;
298
558
  }
299
- /** Default type for variant definitions: maps variant names to option names to styles */
300
- type DefaultVariants = Record<string, Record<string, StyleProps>>;
559
+ type AllVariants = Record<string, Record<string, StyleProps>>;
560
+ type DefaultVariants = Record<never, Record<string, StyleProps>>;
561
+ /**
562
+ * A compound variant entry that applies styles when multiple variant conditions match.
563
+ * Each entry specifies a set of variant conditions and a `css` property with styles
564
+ * that apply only when all conditions are satisfied simultaneously.
565
+ *
566
+ * @template V - The variant definitions type
567
+ *
568
+ * @example
569
+ * { color: 'red', size: 'large', css: { fontWeight: 'bold' } }
570
+ */
571
+ type CompoundVariant<V extends AllVariants> = { [K in keyof V]?: keyof V[K] } & {
572
+ css: StyleProps;
573
+ };
301
574
  /**
302
575
  * Refines string literal types to their proper runtime types.
303
576
  * Converts "true"/"false" strings to boolean literals.
@@ -307,22 +580,24 @@ type RefineVariantType<T extends string> = T extends "true" ? true : T extends "
307
580
  * Props for defining variants in a style object.
308
581
  * @template V - The variant definitions type
309
582
  */
310
- type VariantProps<V extends DefaultVariants> = {
583
+ type VariantProps<V extends AllVariants> = {
311
584
  /** Variant definitions mapping names to options to styles */
312
585
  variants?: V;
313
586
  /** Default variant selections for when not explicitly provided */
314
- defaultVariants?: { [K in keyof V]: (keyof V[K]) extends any ? RefineVariantType<keyof V[K] & string> : never };
587
+ defaultVariants?: { [K in keyof V]?: keyof V[K] extends string ? RefineVariantType<keyof V[K] & string> : never };
588
+ /** Compound variant definitions that apply when multiple variant conditions match */
589
+ compoundVariants?: CompoundVariant<V>[];
315
590
  };
316
591
  /** Combined type for style props with optional variants */
317
- type MochiCSSProps<V extends DefaultVariants> = StyleProps & VariantProps<V>;
592
+ type MochiCSSProps<V extends AllVariants> = StyleProps & VariantProps<V>;
318
593
  /** Utility type to override properties of A with properties of B */
319
594
  type Override<A extends object, B extends object> = B & Omit<A, keyof B>;
320
595
  /** Recursively merges variant types from a tuple, with later types overriding earlier */
321
- type MergeCSSVariants<V extends DefaultVariants[]> = V extends [infer V1 extends DefaultVariants, ...infer VRest extends DefaultVariants[]] ? Override<V1, MergeCSSVariants<VRest>> : {};
596
+ type MergeCSSVariants<V extends AllVariants[]> = V extends [infer V1 extends AllVariants, ...infer VRest extends AllVariants[]] ? Override<V1, MergeCSSVariants<VRest>> : DefaultVariants;
322
597
  /** Refines all values in a string record to their proper variant types */
323
598
  type RefineVariantTypes<V extends Record<string, string>> = { [K in keyof V]: RefineVariantType<V[K]> };
324
599
  /** Extracts and refines variant option types from a DefaultVariants definition */
325
- type RefineVariants<T extends DefaultVariants> = RefineVariantTypes<{ [K in keyof T]: keyof T[K] & string }>;
600
+ type RefineVariants<T extends AllVariants> = RefineVariantTypes<{ [K in keyof T]: keyof T[K] & string }>;
326
601
  /**
327
602
  * Complete CSS object representation with main and variant styles.
328
603
  *
@@ -341,21 +616,26 @@ type RefineVariants<T extends DefaultVariants> = RefineVariantTypes<{ [K in keyo
341
616
  * })
342
617
  * obj.asCssString() // Returns complete CSS with all variants
343
618
  */
344
- declare class CSSObject<V extends Record<string, Record<string, StyleProps>> = {}> {
619
+ declare class CSSObject<V extends AllVariants = DefaultVariants> {
345
620
  /** The main style block (non-variant styles) */
346
621
  readonly mainBlock: CssObjectBlock;
347
622
  /** Compiled blocks for each variant option */
348
- readonly variantBlocks: { [K in keyof V & string]: { [I in keyof V[K] & string]: CssObjectBlock } };
623
+ readonly variantBlocks: { [K in keyof V & string]: Record<keyof V[K] & string, CssObjectBlock> };
349
624
  /** Default variant selections */
350
625
  readonly variantDefaults: Partial<RefineVariants<V>>;
626
+ /** Compound variant conditions and their parsed sub-blocks */
627
+ readonly compoundVariants: {
628
+ conditions: Record<string, string>;
629
+ subBlocks: CssObjectSubBlock[];
630
+ }[];
351
631
  /**
352
632
  * Creates a new CSSObject from style props.
353
633
  * Compiles main styles and all variant options into CSS blocks.
354
- * @param props - Style properties with optional variants and defaults
355
634
  */
356
635
  constructor({
357
636
  variants,
358
637
  defaultVariants,
638
+ compoundVariants,
359
639
  ...props
360
640
  }: MochiCSSProps<V>);
361
641
  /**
@@ -381,7 +661,7 @@ declare class CSSObject<V extends Record<string, Record<string, StyleProps>> = {
381
661
  * }))
382
662
  * styles.variant({ size: 'large' }) // Returns combined class names
383
663
  */
384
- declare class MochiCSS<V extends Record<string, Record<string, StyleProps>> = {}> {
664
+ declare class MochiCSS<V extends AllVariants = DefaultVariants> {
385
665
  readonly classNames: string[];
386
666
  readonly variantClassNames: { [K in keyof V]: { [P in keyof V[K]]: string } };
387
667
  readonly defaultVariants: Partial<RefineVariants<V>>;
@@ -394,6 +674,8 @@ declare class MochiCSS<V extends Record<string, Record<string, StyleProps>> = {}
394
674
  constructor(classNames: string[], variantClassNames: { [K in keyof V]: { [P in keyof V[K]]: string } }, defaultVariants: Partial<RefineVariants<V>>);
395
675
  /**
396
676
  * Computes the final className string based on variant selections.
677
+ * Compound variants are handled purely via CSS combined selectors,
678
+ * so no runtime matching is needed here.
397
679
  * @param props - Variant selections
398
680
  * @returns Combined className string for use in components
399
681
  */
@@ -405,43 +687,20 @@ declare class MochiCSS<V extends Record<string, Record<string, StyleProps>> = {}
405
687
  * @param object - The compiled CSSObject to extract from
406
688
  * @returns A new MochiCSS instance with the extracted class names
407
689
  */
408
- static from<V extends Record<string, Record<string, StyleProps>> = {}>(object: CSSObject<V>): MochiCSS<V>;
690
+ static from<V extends AllVariants = DefaultVariants>(object: CSSObject<V>): MochiCSS<V>;
409
691
  }
410
692
  /**
411
- * Creates a CSS style definition.
412
- * The primary API for defining styles in Mochi-CSS.
413
- *
414
- * @template V - Tuple of variant definition types
415
- * @param props - One or more style objects or existing MochiCSS instances to merge
416
- * @returns A MochiCSS instance with all styles and variants combined
417
- *
418
- * @example
419
- * // Simple usage
420
- * const button = css({ padding: 8, borderRadius: 4 })
421
- *
422
- * @example
423
- * // With variants
424
- * const button = css({
425
- * padding: 8,
426
- * variants: {
427
- * size: {
428
- * small: { padding: 4 },
429
- * large: { padding: 16 }
430
- * }
431
- * },
432
- * defaultVariants: { size: 'small' }
433
- * })
434
- * button.variant({ size: 'large' }) // Get class names for large size
435
- *
436
- * @example
437
- * // Merging multiple styles
438
- * const combined = css(baseStyles, additionalStyles)
693
+ * Merges multiple MochiCSS instances into a single one, combining their
694
+ * class names, variant class names, and default variants.
695
+ * @param instances - The MochiCSS instances to merge
696
+ * @returns A new MochiCSS instance with all styles combined
439
697
  */
440
- declare function css<V extends DefaultVariants[]>(...props: { [K in keyof V]: MochiCSSProps<V[K]> | MochiCSS }): MochiCSS<MergeCSSVariants<V>>;
698
+ declare function mergeMochiCss<V extends AllVariants[]>(instances: MochiCSS<AllVariants>[]): MochiCSS<MergeCSSVariants<V>>;
699
+ declare function css<V extends AllVariants[]>(...props: { [K in keyof V]: MochiCSSProps<V[K]> | MochiCSS }): MochiCSS<MergeCSSVariants<V>>;
441
700
  //#endregion
442
701
  //#region src/styled.d.ts
443
702
  /** Props added by MochiCSS to styled components */
444
- type MochiProps<V extends DefaultVariants[]> = {
703
+ type MochiProps<V extends AllVariants[]> = {
445
704
  className?: string;
446
705
  } & Partial<RefineVariants<MergeCSSVariants<V>>>;
447
706
  /** Minimal interface for components that accept className */
@@ -476,7 +735,62 @@ type Cls = {
476
735
  *
477
736
  * // Usage: <Button size="large" variant="primary">Click me</Button>
478
737
  */
479
- declare function styled<T extends HTMLElementType | ComponentType<Cls>, V extends DefaultVariants[]>(target: T, ...props: { [K in keyof V]: MochiCSSProps<V[K]> }): FC<Omit<ComponentProps<T>, keyof MochiProps<V>> & MochiProps<V>>;
738
+ declare function styled<T extends HTMLElementType | ComponentType<Cls>, V extends AllVariants[]>(target: T, ...props: { [K in keyof V]: MochiCSSProps<V[K]> }): FC<Omit<ComponentProps<T>, keyof MochiProps<V>> & MochiProps<V>>;
739
+ //#endregion
740
+ //#region src/keyframesObject.d.ts
741
+ type KeyframeStops = Record<string, SimpleStyleProps>;
742
+ declare class KeyframesObject {
743
+ readonly name: string;
744
+ private readonly body;
745
+ constructor(stops: KeyframeStops);
746
+ asCssString(): string;
747
+ private static generateBody;
748
+ }
749
+ //#endregion
750
+ //#region src/keyframes.d.ts
751
+ declare class MochiKeyframes {
752
+ readonly name: string;
753
+ constructor(name: string);
754
+ toString(): string;
755
+ get value(): string;
756
+ static from(object: KeyframesObject): MochiKeyframes;
757
+ }
758
+ declare function keyframes(stops: KeyframeStops): MochiKeyframes;
759
+ //#endregion
760
+ //#region src/globalCssObject.d.ts
761
+ type GlobalCssStyles = Record<string, StyleProps>;
762
+ /**
763
+ * CSS object model for global (non-scoped) styles.
764
+ * Accepts a map of CSS selectors to style objects and serializes them
765
+ * as plain CSS rules without class name scoping.
766
+ *
767
+ * @example
768
+ * const obj = new GlobalCssObject({
769
+ * body: { margin: 0 },
770
+ * 'h1': { fontSize: 32 },
771
+ * })
772
+ * obj.asCssString() // "body {\n margin: 0;\n}\n\nh1 {\n font-size: 32px;\n}"
773
+ */
774
+ declare class GlobalCssObject {
775
+ private readonly rules;
776
+ constructor(styles: GlobalCssStyles);
777
+ asCssString(): string;
778
+ }
779
+ //#endregion
780
+ //#region src/globalCss.d.ts
781
+ /**
782
+ * Creates a global CSS definition.
783
+ * Styles are not scoped to any class — they apply to all matching elements.
784
+ *
785
+ * @param styles - Map of CSS selectors to style objects
786
+ *
787
+ * @example
788
+ * globalCss({
789
+ * 'body': { margin: 0, padding: 0 },
790
+ * '*, *::before, *::after': { boxSizing: 'border-box' },
791
+ * })
792
+ */
793
+ declare function globalCss(styles: GlobalCssStyles): void;
480
794
  //#endregion
481
- export { CSSObject, ColorString, CssColor, CssColorLike, CssLength, CssLengthLike, CssLengthString, CssLike, CssLikeObject, CssObjectBlock, CssObjectSubBlock, CssVar, CssVarVal, DefaultVariants, HSLAColorString, HSLColorString, LengthUnit, MergeCSSVariants, MochiCSS, MochiCSSProps, MochiSelector, NumericValue, PercentValue, PixelValue, RGBAColorString, RGBColorString, RefineVariants, type StyleProps, Token, Unit, VariantProps, asColor, asLength, createToken, css, cssFromProps, styled };
795
+ export { AllVariants, CSSObject, CompoundVariant, CssLike, CssLikeObject, CssObjectBlock, CssObjectSubBlock, CssVar, CssVarVal, DefaultVariants, GlobalCssObject, type GlobalCssStyles, type KeyframeStops, KeyframesObject, MergeCSSVariants, MochiCSS, MochiCSSProps, MochiKeyframes, MochiSelector, RefineVariants, type StyleProps, Token, VariantProps, createToken, css, cssFromProps, globalCss, keyframes, mergeMochiCss, styled };
482
796
  //# sourceMappingURL=index.d.ts.map