@mochi-css/vanilla 3.0.1 → 4.0.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.
@@ -0,0 +1,1838 @@
1
+ import clsx from "clsx";
2
+
3
+ //#region src/token.ts
4
+ /**
5
+ * Represents a CSS custom property (design token) with type information.
6
+ * Provides convenient access to both the variable name and its `var()` reference.
7
+ * @template T - The expected value type of the token (for type checking)
8
+ * @example
9
+ * const primaryColor = new Token<string>('primary-color')
10
+ * primaryColor.variable // '--primary-color'
11
+ * primaryColor.value // 'var(--primary-color)'
12
+ */
13
+ var Token = class {
14
+ /**
15
+ * Creates a new CSS token.
16
+ * @param name - The token name (without the `--` prefix)
17
+ */
18
+ constructor(name) {
19
+ this.name = name;
20
+ }
21
+ /**
22
+ * Gets the CSS custom property name (with `--` prefix).
23
+ * Use this when defining the variable.
24
+ */
25
+ get variable() {
26
+ return `--${this.name}`;
27
+ }
28
+ /**
29
+ * Gets the CSS `var()` reference to this token.
30
+ * Use this when consuming the variable value.
31
+ */
32
+ get value() {
33
+ return `var(${this.variable})`;
34
+ }
35
+ /**
36
+ * Returns the variable name for string coercion.
37
+ */
38
+ toString() {
39
+ return this.variable;
40
+ }
41
+ };
42
+ /**
43
+ * Creates a new CSS design token.
44
+ * @template T - The expected value type of the token
45
+ * @param name - The token name (without the `--` prefix)
46
+ * @returns A new Token instance
47
+ * @example
48
+ * const spacing = createToken<number>('spacing-md')
49
+ * // Use in styles: { gap: spacing.value }
50
+ */
51
+ function createToken(name) {
52
+ return new Token(name);
53
+ }
54
+
55
+ //#endregion
56
+ //#region src/propertyUnits.generated.ts
57
+ const propertyUnits = {
58
+ animation: "ms",
59
+ animationDelay: "ms",
60
+ animationDuration: "ms",
61
+ animationRange: "px",
62
+ animationRangeCenter: "px",
63
+ animationRangeEnd: "px",
64
+ animationRangeStart: "px",
65
+ background: "px",
66
+ backgroundPosition: "px",
67
+ backgroundPositionBlock: "px",
68
+ backgroundPositionInline: "px",
69
+ backgroundPositionX: "px",
70
+ backgroundPositionY: "px",
71
+ backgroundSize: "px",
72
+ backgroundTbd: "px",
73
+ baselineShift: "px",
74
+ blockSize: "px",
75
+ blockStep: "px",
76
+ blockStepSize: "px",
77
+ border: "px",
78
+ borderBlock: "px",
79
+ borderBlockClip: "px",
80
+ borderBlockEnd: "px",
81
+ borderBlockEndClip: "px",
82
+ borderBlockEndRadius: "px",
83
+ borderBlockEndWidth: "px",
84
+ borderBlockStart: "px",
85
+ borderBlockStartClip: "px",
86
+ borderBlockStartRadius: "px",
87
+ borderBlockStartWidth: "px",
88
+ borderBlockWidth: "px",
89
+ borderBottom: "px",
90
+ borderBottomClip: "px",
91
+ borderBottomLeftRadius: "px",
92
+ borderBottomRadius: "px",
93
+ borderBottomRightRadius: "px",
94
+ borderBottomWidth: "px",
95
+ borderClip: "px",
96
+ borderEndEndRadius: "px",
97
+ borderEndStartRadius: "px",
98
+ borderImage: "%",
99
+ borderImageOutset: "px",
100
+ borderImageSlice: "%",
101
+ borderImageWidth: "px",
102
+ borderInline: "px",
103
+ borderInlineClip: "px",
104
+ borderInlineEnd: "px",
105
+ borderInlineEndClip: "px",
106
+ borderInlineEndRadius: "px",
107
+ borderInlineEndWidth: "px",
108
+ borderInlineStart: "px",
109
+ borderInlineStartClip: "px",
110
+ borderInlineStartRadius: "px",
111
+ borderInlineStartWidth: "px",
112
+ borderInlineWidth: "px",
113
+ borderLeft: "px",
114
+ borderLeftClip: "px",
115
+ borderLeftRadius: "px",
116
+ borderLeftWidth: "px",
117
+ borderLimit: "px",
118
+ borderRadius: "px",
119
+ borderRight: "px",
120
+ borderRightClip: "px",
121
+ borderRightRadius: "px",
122
+ borderRightWidth: "px",
123
+ borderSpacing: "px",
124
+ borderStartEndRadius: "px",
125
+ borderStartStartRadius: "px",
126
+ borderTop: "px",
127
+ borderTopClip: "px",
128
+ borderTopLeftRadius: "px",
129
+ borderTopRadius: "px",
130
+ borderTopRightRadius: "px",
131
+ borderTopWidth: "px",
132
+ borderWidth: "px",
133
+ bottom: "px",
134
+ boxShadow: "px",
135
+ boxShadowBlur: "px",
136
+ boxShadowOffset: "px",
137
+ boxShadowSpread: "px",
138
+ columnGap: "px",
139
+ columnHeight: "px",
140
+ columnRule: "px",
141
+ columnRuleEdgeInset: "px",
142
+ columnRuleEdgeInsetEnd: "px",
143
+ columnRuleEdgeInsetStart: "px",
144
+ columnRuleInset: "px",
145
+ columnRuleInsetEnd: "px",
146
+ columnRuleInsetStart: "px",
147
+ columnRuleInteriorInset: "px",
148
+ columnRuleInteriorInsetEnd: "px",
149
+ columnRuleInteriorInsetStart: "px",
150
+ columnRuleWidth: "px",
151
+ columns: "px",
152
+ columnWidth: "px",
153
+ containIntrinsicBlockSize: "px",
154
+ containIntrinsicHeight: "px",
155
+ containIntrinsicInlineSize: "px",
156
+ containIntrinsicSize: "px",
157
+ containIntrinsicWidth: "px",
158
+ corner: "px",
159
+ cornerBlockEnd: "px",
160
+ cornerBlockStart: "px",
161
+ cornerBottom: "px",
162
+ cornerBottomLeft: "px",
163
+ cornerBottomRight: "px",
164
+ cornerEndEnd: "px",
165
+ cornerEndStart: "px",
166
+ cornerInlineEnd: "px",
167
+ cornerInlineStart: "px",
168
+ cornerLeft: "px",
169
+ cornerRight: "px",
170
+ cornerStartEnd: "px",
171
+ cornerStartStart: "px",
172
+ cornerTop: "px",
173
+ cornerTopLeft: "px",
174
+ cornerTopRight: "px",
175
+ cx: "px",
176
+ cy: "px",
177
+ fillOpacity: "%",
178
+ fillPosition: "px",
179
+ fillSize: "px",
180
+ flex: "px",
181
+ flexBasis: "px",
182
+ floatOffset: "px",
183
+ floodOpacity: "%",
184
+ flowTolerance: "px",
185
+ font: "deg",
186
+ fontSize: "px",
187
+ fontStretch: "%",
188
+ fontStyle: "deg",
189
+ fontWidth: "%",
190
+ gap: "px",
191
+ grid: "px",
192
+ gridAutoColumns: "px",
193
+ gridAutoRows: "px",
194
+ gridColumnGap: "px",
195
+ gridGap: "px",
196
+ gridRowGap: "px",
197
+ gridTemplate: "px",
198
+ gridTemplateColumns: "px",
199
+ gridTemplateRows: "px",
200
+ height: "px",
201
+ hyphenateLimitZone: "px",
202
+ imageOrientation: "deg",
203
+ imageResolution: "dppx",
204
+ initialLetterWrap: "px",
205
+ inlineSize: "px",
206
+ inset: "px",
207
+ insetBlock: "px",
208
+ insetBlockEnd: "px",
209
+ insetBlockStart: "px",
210
+ insetInline: "px",
211
+ insetInlineEnd: "px",
212
+ insetInlineStart: "px",
213
+ interestDelay: "ms",
214
+ interestDelayEnd: "ms",
215
+ interestDelayStart: "ms",
216
+ left: "px",
217
+ letterSpacing: "px",
218
+ lineHeight: "px",
219
+ lineHeightStep: "px",
220
+ linePadding: "px",
221
+ margin: "px",
222
+ marginBlock: "px",
223
+ marginBlockEnd: "px",
224
+ marginBlockStart: "px",
225
+ marginBottom: "px",
226
+ marginInline: "px",
227
+ marginInlineEnd: "px",
228
+ marginInlineStart: "px",
229
+ marginLeft: "px",
230
+ marginRight: "px",
231
+ marginTop: "px",
232
+ mask: "px",
233
+ maskBorder: "%",
234
+ maskBorderOutset: "px",
235
+ maskBorderSlice: "%",
236
+ maskBorderWidth: "px",
237
+ maskPosition: "px",
238
+ maskSize: "px",
239
+ maxBlockSize: "px",
240
+ maxHeight: "px",
241
+ maxInlineSize: "px",
242
+ maxWidth: "px",
243
+ minBlockSize: "px",
244
+ minHeight: "px",
245
+ minInlineSize: "px",
246
+ minWidth: "px",
247
+ objectPosition: "px",
248
+ offset: "px",
249
+ offsetAnchor: "px",
250
+ offsetDistance: "px",
251
+ offsetPosition: "px",
252
+ offsetRotate: "deg",
253
+ opacity: "%",
254
+ outline: "px",
255
+ outlineOffset: "px",
256
+ outlineWidth: "px",
257
+ overflowClipMargin: "px",
258
+ overflowClipMarginBlock: "px",
259
+ overflowClipMarginBlockEnd: "px",
260
+ overflowClipMarginBlockStart: "px",
261
+ overflowClipMarginBottom: "px",
262
+ overflowClipMarginInline: "px",
263
+ overflowClipMarginInlineEnd: "px",
264
+ overflowClipMarginInlineStart: "px",
265
+ overflowClipMarginLeft: "px",
266
+ overflowClipMarginRight: "px",
267
+ overflowClipMarginTop: "px",
268
+ padding: "px",
269
+ paddingBlock: "px",
270
+ paddingBlockEnd: "px",
271
+ paddingBlockStart: "px",
272
+ paddingBottom: "px",
273
+ paddingInline: "px",
274
+ paddingInlineEnd: "px",
275
+ paddingInlineStart: "px",
276
+ paddingLeft: "px",
277
+ paddingRight: "px",
278
+ paddingTop: "px",
279
+ pause: "ms",
280
+ pauseAfter: "ms",
281
+ pauseBefore: "ms",
282
+ perspective: "px",
283
+ perspectiveOrigin: "px",
284
+ r: "px",
285
+ rest: "ms",
286
+ restAfter: "ms",
287
+ restBefore: "ms",
288
+ right: "px",
289
+ rotate: "deg",
290
+ rowGap: "px",
291
+ rowRule: "px",
292
+ rowRuleEdgeInset: "px",
293
+ rowRuleEdgeInsetEnd: "px",
294
+ rowRuleEdgeInsetStart: "px",
295
+ rowRuleInset: "px",
296
+ rowRuleInsetEnd: "px",
297
+ rowRuleInsetStart: "px",
298
+ rowRuleInteriorInset: "px",
299
+ rowRuleInteriorInsetEnd: "px",
300
+ rowRuleInteriorInsetStart: "px",
301
+ rowRuleWidth: "px",
302
+ rule: "px",
303
+ ruleEdgeInset: "px",
304
+ ruleInset: "px",
305
+ ruleInsetEnd: "px",
306
+ ruleInsetStart: "px",
307
+ ruleInteriorInset: "px",
308
+ ruleWidth: "px",
309
+ rx: "px",
310
+ ry: "px",
311
+ scale: "%",
312
+ scrollMargin: "px",
313
+ scrollMarginBlock: "px",
314
+ scrollMarginBlockEnd: "px",
315
+ scrollMarginBlockStart: "px",
316
+ scrollMarginBottom: "px",
317
+ scrollMarginInline: "px",
318
+ scrollMarginInlineEnd: "px",
319
+ scrollMarginInlineStart: "px",
320
+ scrollMarginLeft: "px",
321
+ scrollMarginRight: "px",
322
+ scrollMarginTop: "px",
323
+ scrollPadding: "px",
324
+ scrollPaddingBlock: "px",
325
+ scrollPaddingBlockEnd: "px",
326
+ scrollPaddingBlockStart: "px",
327
+ scrollPaddingBottom: "px",
328
+ scrollPaddingInline: "px",
329
+ scrollPaddingInlineEnd: "px",
330
+ scrollPaddingInlineStart: "px",
331
+ scrollPaddingLeft: "px",
332
+ scrollPaddingRight: "px",
333
+ scrollPaddingTop: "px",
334
+ shapeImageThreshold: "%",
335
+ shapeMargin: "px",
336
+ shapePadding: "px",
337
+ stopOpacity: "%",
338
+ strokeDasharray: "px",
339
+ strokeDashcorner: "px",
340
+ strokeDashCorner: "px",
341
+ strokeDashoffset: "px",
342
+ strokeOpacity: "%",
343
+ strokePosition: "px",
344
+ strokeSize: "px",
345
+ strokeWidth: "px",
346
+ tabSize: "px",
347
+ textDecoration: "px",
348
+ textDecorationInset: "px",
349
+ textDecorationThickness: "px",
350
+ textIndent: "px",
351
+ textShadow: "px",
352
+ textSizeAdjust: "%",
353
+ textUnderlineOffset: "px",
354
+ timelineTrigger: "px",
355
+ timelineTriggerActivationRange: "px",
356
+ timelineTriggerActivationRangeEnd: "px",
357
+ timelineTriggerActivationRangeStart: "px",
358
+ timelineTriggerActiveRange: "px",
359
+ timelineTriggerActiveRangeEnd: "px",
360
+ timelineTriggerActiveRangeStart: "px",
361
+ top: "px",
362
+ transformOrigin: "px",
363
+ transition: "ms",
364
+ transitionDelay: "ms",
365
+ transitionDuration: "ms",
366
+ translate: "px",
367
+ verticalAlign: "px",
368
+ viewTimeline: "px",
369
+ viewTimelineInset: "px",
370
+ voiceDuration: "ms",
371
+ voicePitch: "Hz",
372
+ voiceRange: "Hz",
373
+ voiceRate: "%",
374
+ width: "px",
375
+ wordSpacing: "px",
376
+ x: "px",
377
+ y: "px",
378
+ zoom: "%"
379
+ };
380
+
381
+ //#endregion
382
+ //#region src/knownProperties.generated.ts
383
+ const knownPropertyNames = new Set([
384
+ "accentColor",
385
+ "alignContent",
386
+ "alignItems",
387
+ "alignSelf",
388
+ "alignmentBaseline",
389
+ "all",
390
+ "anchorName",
391
+ "anchorScope",
392
+ "animation",
393
+ "animationComposition",
394
+ "animationDelay",
395
+ "animationDirection",
396
+ "animationDuration",
397
+ "animationFillMode",
398
+ "animationIterationCount",
399
+ "animationName",
400
+ "animationPlayState",
401
+ "animationRange",
402
+ "animationRangeCenter",
403
+ "animationRangeEnd",
404
+ "animationRangeStart",
405
+ "animationTimeline",
406
+ "animationTimingFunction",
407
+ "animationTrigger",
408
+ "appearance",
409
+ "aspectRatio",
410
+ "backdropFilter",
411
+ "backfaceVisibility",
412
+ "background",
413
+ "backgroundAttachment",
414
+ "backgroundBlendMode",
415
+ "backgroundClip",
416
+ "backgroundColor",
417
+ "backgroundImage",
418
+ "backgroundOrigin",
419
+ "backgroundPosition",
420
+ "backgroundPositionBlock",
421
+ "backgroundPositionInline",
422
+ "backgroundPositionX",
423
+ "backgroundPositionY",
424
+ "backgroundRepeat",
425
+ "backgroundRepeatBlock",
426
+ "backgroundRepeatInline",
427
+ "backgroundRepeatX",
428
+ "backgroundRepeatY",
429
+ "backgroundSize",
430
+ "backgroundTbd",
431
+ "baselineShift",
432
+ "baselineSource",
433
+ "blockEllipsis",
434
+ "blockSize",
435
+ "blockStep",
436
+ "blockStepAlign",
437
+ "blockStepInsert",
438
+ "blockStepRound",
439
+ "blockStepSize",
440
+ "bookmarkLabel",
441
+ "bookmarkLevel",
442
+ "bookmarkState",
443
+ "border",
444
+ "borderBlock",
445
+ "borderBlockClip",
446
+ "borderBlockColor",
447
+ "borderBlockEnd",
448
+ "borderBlockEndClip",
449
+ "borderBlockEndColor",
450
+ "borderBlockEndRadius",
451
+ "borderBlockEndStyle",
452
+ "borderBlockEndWidth",
453
+ "borderBlockStart",
454
+ "borderBlockStartClip",
455
+ "borderBlockStartColor",
456
+ "borderBlockStartRadius",
457
+ "borderBlockStartStyle",
458
+ "borderBlockStartWidth",
459
+ "borderBlockStyle",
460
+ "borderBlockWidth",
461
+ "borderBottom",
462
+ "borderBottomClip",
463
+ "borderBottomColor",
464
+ "borderBottomLeftRadius",
465
+ "borderBottomRadius",
466
+ "borderBottomRightRadius",
467
+ "borderBottomStyle",
468
+ "borderBottomWidth",
469
+ "borderBoundary",
470
+ "borderClip",
471
+ "borderCollapse",
472
+ "borderColor",
473
+ "borderEndEndRadius",
474
+ "borderEndStartRadius",
475
+ "borderImage",
476
+ "borderImageOutset",
477
+ "borderImageRepeat",
478
+ "borderImageSlice",
479
+ "borderImageSource",
480
+ "borderImageWidth",
481
+ "borderInline",
482
+ "borderInlineClip",
483
+ "borderInlineColor",
484
+ "borderInlineEnd",
485
+ "borderInlineEndClip",
486
+ "borderInlineEndColor",
487
+ "borderInlineEndRadius",
488
+ "borderInlineEndStyle",
489
+ "borderInlineEndWidth",
490
+ "borderInlineStart",
491
+ "borderInlineStartClip",
492
+ "borderInlineStartColor",
493
+ "borderInlineStartRadius",
494
+ "borderInlineStartStyle",
495
+ "borderInlineStartWidth",
496
+ "borderInlineStyle",
497
+ "borderInlineWidth",
498
+ "borderLeft",
499
+ "borderLeftClip",
500
+ "borderLeftColor",
501
+ "borderLeftRadius",
502
+ "borderLeftStyle",
503
+ "borderLeftWidth",
504
+ "borderLimit",
505
+ "borderRadius",
506
+ "borderRight",
507
+ "borderRightClip",
508
+ "borderRightColor",
509
+ "borderRightRadius",
510
+ "borderRightStyle",
511
+ "borderRightWidth",
512
+ "borderShape",
513
+ "borderSpacing",
514
+ "borderStartEndRadius",
515
+ "borderStartStartRadius",
516
+ "borderStyle",
517
+ "borderTop",
518
+ "borderTopClip",
519
+ "borderTopColor",
520
+ "borderTopLeftRadius",
521
+ "borderTopRadius",
522
+ "borderTopRightRadius",
523
+ "borderTopStyle",
524
+ "borderTopWidth",
525
+ "borderWidth",
526
+ "bottom",
527
+ "boxDecorationBreak",
528
+ "boxShadow",
529
+ "boxShadowBlur",
530
+ "boxShadowColor",
531
+ "boxShadowOffset",
532
+ "boxShadowPosition",
533
+ "boxShadowSpread",
534
+ "boxSizing",
535
+ "boxSnap",
536
+ "breakAfter",
537
+ "breakBefore",
538
+ "breakInside",
539
+ "captionSide",
540
+ "caret",
541
+ "caretAnimation",
542
+ "caretColor",
543
+ "caretShape",
544
+ "clear",
545
+ "clip",
546
+ "clipPath",
547
+ "clipRule",
548
+ "color",
549
+ "colorAdjust",
550
+ "colorInterpolation",
551
+ "colorInterpolationFilters",
552
+ "colorScheme",
553
+ "columnCount",
554
+ "columnFill",
555
+ "columnGap",
556
+ "columnHeight",
557
+ "columnRule",
558
+ "columnRuleBreak",
559
+ "columnRuleColor",
560
+ "columnRuleEdgeInset",
561
+ "columnRuleEdgeInsetEnd",
562
+ "columnRuleEdgeInsetStart",
563
+ "columnRuleInset",
564
+ "columnRuleInsetEnd",
565
+ "columnRuleInsetStart",
566
+ "columnRuleInteriorInset",
567
+ "columnRuleInteriorInsetEnd",
568
+ "columnRuleInteriorInsetStart",
569
+ "columnRuleStyle",
570
+ "columnRuleVisibilityItems",
571
+ "columnRuleWidth",
572
+ "columnSpan",
573
+ "columnWidth",
574
+ "columnWrap",
575
+ "columns",
576
+ "contain",
577
+ "containIntrinsicBlockSize",
578
+ "containIntrinsicHeight",
579
+ "containIntrinsicInlineSize",
580
+ "containIntrinsicSize",
581
+ "containIntrinsicWidth",
582
+ "container",
583
+ "containerName",
584
+ "containerType",
585
+ "content",
586
+ "contentVisibility",
587
+ "continue",
588
+ "copyInto",
589
+ "corner",
590
+ "cornerBlockEnd",
591
+ "cornerBlockEndShape",
592
+ "cornerBlockStart",
593
+ "cornerBlockStartShape",
594
+ "cornerBottom",
595
+ "cornerBottomLeft",
596
+ "cornerBottomLeftShape",
597
+ "cornerBottomRight",
598
+ "cornerBottomRightShape",
599
+ "cornerBottomShape",
600
+ "cornerEndEnd",
601
+ "cornerEndEndShape",
602
+ "cornerEndStart",
603
+ "cornerEndStartShape",
604
+ "cornerInlineEnd",
605
+ "cornerInlineEndShape",
606
+ "cornerInlineStart",
607
+ "cornerInlineStartShape",
608
+ "cornerLeft",
609
+ "cornerLeftShape",
610
+ "cornerRight",
611
+ "cornerRightShape",
612
+ "cornerShape",
613
+ "cornerStartEnd",
614
+ "cornerStartEndShape",
615
+ "cornerStartStart",
616
+ "cornerStartStartShape",
617
+ "cornerTop",
618
+ "cornerTopLeft",
619
+ "cornerTopLeftShape",
620
+ "cornerTopRight",
621
+ "cornerTopRightShape",
622
+ "cornerTopShape",
623
+ "counterIncrement",
624
+ "counterReset",
625
+ "counterSet",
626
+ "cue",
627
+ "cueAfter",
628
+ "cueBefore",
629
+ "cursor",
630
+ "cx",
631
+ "cy",
632
+ "d",
633
+ "direction",
634
+ "display",
635
+ "dominantBaseline",
636
+ "dynamicRangeLimit",
637
+ "emptyCells",
638
+ "eventTrigger",
639
+ "eventTriggerName",
640
+ "eventTriggerSource",
641
+ "fieldSizing",
642
+ "fill",
643
+ "fillBreak",
644
+ "fillColor",
645
+ "fillImage",
646
+ "fillOpacity",
647
+ "fillOrigin",
648
+ "fillPosition",
649
+ "fillRepeat",
650
+ "fillRule",
651
+ "fillSize",
652
+ "filter",
653
+ "flex",
654
+ "flexBasis",
655
+ "flexDirection",
656
+ "flexFlow",
657
+ "flexGrow",
658
+ "flexShrink",
659
+ "flexWrap",
660
+ "float",
661
+ "floatDefer",
662
+ "floatOffset",
663
+ "floatReference",
664
+ "floodColor",
665
+ "floodOpacity",
666
+ "flowFrom",
667
+ "flowInto",
668
+ "flowTolerance",
669
+ "font",
670
+ "fontFamily",
671
+ "fontFeatureSettings",
672
+ "fontKerning",
673
+ "fontLanguageOverride",
674
+ "fontOpticalSizing",
675
+ "fontPalette",
676
+ "fontSize",
677
+ "fontSizeAdjust",
678
+ "fontStretch",
679
+ "fontStyle",
680
+ "fontSynthesis",
681
+ "fontSynthesisPosition",
682
+ "fontSynthesisSmallCaps",
683
+ "fontSynthesisStyle",
684
+ "fontSynthesisWeight",
685
+ "fontVariant",
686
+ "fontVariantAlternates",
687
+ "fontVariantCaps",
688
+ "fontVariantEastAsian",
689
+ "fontVariantEmoji",
690
+ "fontVariantLigatures",
691
+ "fontVariantNumeric",
692
+ "fontVariantPosition",
693
+ "fontVariationSettings",
694
+ "fontWeight",
695
+ "fontWidth",
696
+ "footnoteDisplay",
697
+ "footnotePolicy",
698
+ "forcedColorAdjust",
699
+ "frameSizing",
700
+ "gap",
701
+ "glyphOrientationVertical",
702
+ "grid",
703
+ "gridArea",
704
+ "gridAutoColumns",
705
+ "gridAutoFlow",
706
+ "gridAutoRows",
707
+ "gridColumn",
708
+ "gridColumnEnd",
709
+ "gridColumnGap",
710
+ "gridColumnStart",
711
+ "gridGap",
712
+ "gridRow",
713
+ "gridRowEnd",
714
+ "gridRowGap",
715
+ "gridRowStart",
716
+ "gridTemplate",
717
+ "gridTemplateAreas",
718
+ "gridTemplateColumns",
719
+ "gridTemplateRows",
720
+ "hangingPunctuation",
721
+ "height",
722
+ "hyphenateCharacter",
723
+ "hyphenateLimitChars",
724
+ "hyphenateLimitLast",
725
+ "hyphenateLimitLines",
726
+ "hyphenateLimitZone",
727
+ "hyphens",
728
+ "imageAnimation",
729
+ "imageOrientation",
730
+ "imageRendering",
731
+ "imageResolution",
732
+ "initialLetter",
733
+ "initialLetterAlign",
734
+ "initialLetterWrap",
735
+ "inlineSize",
736
+ "inlineSizing",
737
+ "inputSecurity",
738
+ "inset",
739
+ "insetBlock",
740
+ "insetBlockEnd",
741
+ "insetBlockStart",
742
+ "insetInline",
743
+ "insetInlineEnd",
744
+ "insetInlineStart",
745
+ "interactivity",
746
+ "interestDelay",
747
+ "interestDelayEnd",
748
+ "interestDelayStart",
749
+ "interpolateSize",
750
+ "isolation",
751
+ "justifyContent",
752
+ "justifyItems",
753
+ "justifySelf",
754
+ "left",
755
+ "letterSpacing",
756
+ "lightingColor",
757
+ "lineBreak",
758
+ "lineClamp",
759
+ "lineFitEdge",
760
+ "lineGrid",
761
+ "lineHeight",
762
+ "lineHeightStep",
763
+ "linePadding",
764
+ "lineSnap",
765
+ "linkParameters",
766
+ "listStyle",
767
+ "listStyleImage",
768
+ "listStylePosition",
769
+ "listStyleType",
770
+ "margin",
771
+ "marginBlock",
772
+ "marginBlockEnd",
773
+ "marginBlockStart",
774
+ "marginBottom",
775
+ "marginBreak",
776
+ "marginInline",
777
+ "marginInlineEnd",
778
+ "marginInlineStart",
779
+ "marginLeft",
780
+ "marginRight",
781
+ "marginTop",
782
+ "marginTrim",
783
+ "marker",
784
+ "markerEnd",
785
+ "markerMid",
786
+ "markerSide",
787
+ "markerStart",
788
+ "mask",
789
+ "maskBorder",
790
+ "maskBorderMode",
791
+ "maskBorderOutset",
792
+ "maskBorderRepeat",
793
+ "maskBorderSlice",
794
+ "maskBorderSource",
795
+ "maskBorderWidth",
796
+ "maskClip",
797
+ "maskComposite",
798
+ "maskImage",
799
+ "maskMode",
800
+ "maskOrigin",
801
+ "maskPosition",
802
+ "maskRepeat",
803
+ "maskSize",
804
+ "maskType",
805
+ "mathDepth",
806
+ "mathShift",
807
+ "mathStyle",
808
+ "maxBlockSize",
809
+ "maxHeight",
810
+ "maxInlineSize",
811
+ "maxLines",
812
+ "maxWidth",
813
+ "minBlockSize",
814
+ "minHeight",
815
+ "minInlineSize",
816
+ "minIntrinsicSizing",
817
+ "minWidth",
818
+ "mixBlendMode",
819
+ "navDown",
820
+ "navLeft",
821
+ "navRight",
822
+ "navUp",
823
+ "objectFit",
824
+ "objectPosition",
825
+ "objectViewBox",
826
+ "offset",
827
+ "offsetAnchor",
828
+ "offsetDistance",
829
+ "offsetPath",
830
+ "offsetPosition",
831
+ "offsetRotate",
832
+ "opacity",
833
+ "order",
834
+ "orphans",
835
+ "outline",
836
+ "outlineColor",
837
+ "outlineOffset",
838
+ "outlineStyle",
839
+ "outlineWidth",
840
+ "overflow",
841
+ "overflowAnchor",
842
+ "overflowBlock",
843
+ "overflowClipMargin",
844
+ "overflowClipMarginBlock",
845
+ "overflowClipMarginBlockEnd",
846
+ "overflowClipMarginBlockStart",
847
+ "overflowClipMarginBottom",
848
+ "overflowClipMarginInline",
849
+ "overflowClipMarginInlineEnd",
850
+ "overflowClipMarginInlineStart",
851
+ "overflowClipMarginLeft",
852
+ "overflowClipMarginRight",
853
+ "overflowClipMarginTop",
854
+ "overflowInline",
855
+ "overflowWrap",
856
+ "overflowX",
857
+ "overflowY",
858
+ "overlay",
859
+ "overscrollBehavior",
860
+ "overscrollBehaviorBlock",
861
+ "overscrollBehaviorInline",
862
+ "overscrollBehaviorX",
863
+ "overscrollBehaviorY",
864
+ "padding",
865
+ "paddingBlock",
866
+ "paddingBlockEnd",
867
+ "paddingBlockStart",
868
+ "paddingBottom",
869
+ "paddingInline",
870
+ "paddingInlineEnd",
871
+ "paddingInlineStart",
872
+ "paddingLeft",
873
+ "paddingRight",
874
+ "paddingTop",
875
+ "page",
876
+ "pageBreakAfter",
877
+ "pageBreakBefore",
878
+ "pageBreakInside",
879
+ "paintOrder",
880
+ "pause",
881
+ "pauseAfter",
882
+ "pauseBefore",
883
+ "perspective",
884
+ "perspectiveOrigin",
885
+ "placeContent",
886
+ "placeItems",
887
+ "placeSelf",
888
+ "pointerEvents",
889
+ "pointerTimeline",
890
+ "pointerTimelineAxis",
891
+ "pointerTimelineName",
892
+ "position",
893
+ "positionAnchor",
894
+ "positionArea",
895
+ "positionTry",
896
+ "positionTryFallbacks",
897
+ "positionTryOrder",
898
+ "positionVisibility",
899
+ "printColorAdjust",
900
+ "quotes",
901
+ "r",
902
+ "readingFlow",
903
+ "readingOrder",
904
+ "regionFragment",
905
+ "resize",
906
+ "rest",
907
+ "restAfter",
908
+ "restBefore",
909
+ "right",
910
+ "rotate",
911
+ "rowGap",
912
+ "rowRule",
913
+ "rowRuleBreak",
914
+ "rowRuleColor",
915
+ "rowRuleEdgeInset",
916
+ "rowRuleEdgeInsetEnd",
917
+ "rowRuleEdgeInsetStart",
918
+ "rowRuleInset",
919
+ "rowRuleInsetEnd",
920
+ "rowRuleInsetStart",
921
+ "rowRuleInteriorInset",
922
+ "rowRuleInteriorInsetEnd",
923
+ "rowRuleInteriorInsetStart",
924
+ "rowRuleStyle",
925
+ "rowRuleVisibilityItems",
926
+ "rowRuleWidth",
927
+ "rubyAlign",
928
+ "rubyMerge",
929
+ "rubyOverhang",
930
+ "rubyPosition",
931
+ "rule",
932
+ "ruleBreak",
933
+ "ruleColor",
934
+ "ruleEdgeInset",
935
+ "ruleInset",
936
+ "ruleInsetEnd",
937
+ "ruleInsetStart",
938
+ "ruleInteriorInset",
939
+ "ruleOverlap",
940
+ "ruleStyle",
941
+ "ruleVisibilityItems",
942
+ "ruleWidth",
943
+ "rx",
944
+ "ry",
945
+ "scale",
946
+ "scrollBehavior",
947
+ "scrollInitialTarget",
948
+ "scrollMargin",
949
+ "scrollMarginBlock",
950
+ "scrollMarginBlockEnd",
951
+ "scrollMarginBlockStart",
952
+ "scrollMarginBottom",
953
+ "scrollMarginInline",
954
+ "scrollMarginInlineEnd",
955
+ "scrollMarginInlineStart",
956
+ "scrollMarginLeft",
957
+ "scrollMarginRight",
958
+ "scrollMarginTop",
959
+ "scrollMarkerGroup",
960
+ "scrollPadding",
961
+ "scrollPaddingBlock",
962
+ "scrollPaddingBlockEnd",
963
+ "scrollPaddingBlockStart",
964
+ "scrollPaddingBottom",
965
+ "scrollPaddingInline",
966
+ "scrollPaddingInlineEnd",
967
+ "scrollPaddingInlineStart",
968
+ "scrollPaddingLeft",
969
+ "scrollPaddingRight",
970
+ "scrollPaddingTop",
971
+ "scrollSnapAlign",
972
+ "scrollSnapStop",
973
+ "scrollSnapType",
974
+ "scrollTargetGroup",
975
+ "scrollTimeline",
976
+ "scrollTimelineAxis",
977
+ "scrollTimelineName",
978
+ "scrollbarColor",
979
+ "scrollbarGutter",
980
+ "scrollbarWidth",
981
+ "shapeImageThreshold",
982
+ "shapeInside",
983
+ "shapeMargin",
984
+ "shapeOutside",
985
+ "shapePadding",
986
+ "shapeRendering",
987
+ "shapeSubtract",
988
+ "sliderOrientation",
989
+ "spatialNavigationAction",
990
+ "spatialNavigationContain",
991
+ "spatialNavigationFunction",
992
+ "speak",
993
+ "speakAs",
994
+ "stopColor",
995
+ "stopOpacity",
996
+ "stringSet",
997
+ "stroke",
998
+ "strokeAlign",
999
+ "strokeAlignment",
1000
+ "strokeBreak",
1001
+ "strokeColor",
1002
+ "strokeDashCorner",
1003
+ "strokeDashJustify",
1004
+ "strokeDashadjust",
1005
+ "strokeDasharray",
1006
+ "strokeDashcorner",
1007
+ "strokeDashoffset",
1008
+ "strokeImage",
1009
+ "strokeLinecap",
1010
+ "strokeLinejoin",
1011
+ "strokeMiterlimit",
1012
+ "strokeOpacity",
1013
+ "strokeOrigin",
1014
+ "strokePosition",
1015
+ "strokeRepeat",
1016
+ "strokeSize",
1017
+ "strokeWidth",
1018
+ "tabSize",
1019
+ "tableLayout",
1020
+ "textAlign",
1021
+ "textAlignAll",
1022
+ "textAlignLast",
1023
+ "textAnchor",
1024
+ "textAutospace",
1025
+ "textBox",
1026
+ "textBoxEdge",
1027
+ "textBoxTrim",
1028
+ "textCombineUpright",
1029
+ "textDecoration",
1030
+ "textDecorationColor",
1031
+ "textDecorationInset",
1032
+ "textDecorationLine",
1033
+ "textDecorationSkip",
1034
+ "textDecorationSkipBox",
1035
+ "textDecorationSkipInk",
1036
+ "textDecorationSkipSelf",
1037
+ "textDecorationSkipSpaces",
1038
+ "textDecorationStyle",
1039
+ "textDecorationThickness",
1040
+ "textEmphasis",
1041
+ "textEmphasisColor",
1042
+ "textEmphasisPosition",
1043
+ "textEmphasisSkip",
1044
+ "textEmphasisStyle",
1045
+ "textGroupAlign",
1046
+ "textIndent",
1047
+ "textJustify",
1048
+ "textOrientation",
1049
+ "textOverflow",
1050
+ "textRendering",
1051
+ "textShadow",
1052
+ "textSizeAdjust",
1053
+ "textSpacing",
1054
+ "textSpacingTrim",
1055
+ "textTransform",
1056
+ "textUnderlineOffset",
1057
+ "textUnderlinePosition",
1058
+ "textWrap",
1059
+ "textWrapMode",
1060
+ "textWrapStyle",
1061
+ "timelineScope",
1062
+ "timelineTrigger",
1063
+ "timelineTriggerActivationRange",
1064
+ "timelineTriggerActivationRangeEnd",
1065
+ "timelineTriggerActivationRangeStart",
1066
+ "timelineTriggerActiveRange",
1067
+ "timelineTriggerActiveRangeEnd",
1068
+ "timelineTriggerActiveRangeStart",
1069
+ "timelineTriggerName",
1070
+ "timelineTriggerSource",
1071
+ "top",
1072
+ "touchAction",
1073
+ "transform",
1074
+ "transformBox",
1075
+ "transformOrigin",
1076
+ "transformStyle",
1077
+ "transition",
1078
+ "transitionBehavior",
1079
+ "transitionDelay",
1080
+ "transitionDuration",
1081
+ "transitionProperty",
1082
+ "transitionTimingFunction",
1083
+ "translate",
1084
+ "triggerScope",
1085
+ "unicodeBidi",
1086
+ "userSelect",
1087
+ "vectorEffect",
1088
+ "verticalAlign",
1089
+ "viewTimeline",
1090
+ "viewTimelineAxis",
1091
+ "viewTimelineInset",
1092
+ "viewTimelineName",
1093
+ "viewTransitionClass",
1094
+ "viewTransitionGroup",
1095
+ "viewTransitionName",
1096
+ "viewTransitionScope",
1097
+ "visibility",
1098
+ "voiceBalance",
1099
+ "voiceDuration",
1100
+ "voiceFamily",
1101
+ "voicePitch",
1102
+ "voiceRange",
1103
+ "voiceRate",
1104
+ "voiceStress",
1105
+ "voiceVolume",
1106
+ "whiteSpace",
1107
+ "whiteSpaceCollapse",
1108
+ "whiteSpaceTrim",
1109
+ "widows",
1110
+ "width",
1111
+ "willChange",
1112
+ "wordBreak",
1113
+ "wordSpaceTransform",
1114
+ "wordSpacing",
1115
+ "wordWrap",
1116
+ "wrapAfter",
1117
+ "wrapBefore",
1118
+ "wrapFlow",
1119
+ "wrapInside",
1120
+ "wrapThrough",
1121
+ "writingMode",
1122
+ "x",
1123
+ "y",
1124
+ "zIndex",
1125
+ "zoom"
1126
+ ]);
1127
+
1128
+ //#endregion
1129
+ //#region src/props.ts
1130
+ /**
1131
+ * Converts a kebab-case string to camelCase.
1132
+ */
1133
+ function kebabToCamel(str) {
1134
+ return str.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
1135
+ }
1136
+ /**
1137
+ * Converts a camelCase string to kebab-case.
1138
+ */
1139
+ function camelToKebab(str) {
1140
+ return str.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
1141
+ }
1142
+ function getUnitForProperty(propertyName) {
1143
+ return propertyName in propertyUnits ? propertyUnits[propertyName] : void 0;
1144
+ }
1145
+ /**
1146
+ * Converts a CSS-like value to its string representation.
1147
+ * For properties with known units, numbers are automatically suffixed.
1148
+ */
1149
+ function formatValue(value, propertyName, maxDepth = 10) {
1150
+ if (maxDepth <= 0) return "";
1151
+ if (typeof value === "string") return value;
1152
+ if (typeof value === "number") {
1153
+ const unit = getUnitForProperty(propertyName);
1154
+ if (unit === "%") return `${value * 100}${unit}`;
1155
+ if (value === 0) return "0";
1156
+ return unit ? `${value}${unit}` : value.toString();
1157
+ }
1158
+ return formatValue(value.value, propertyName, maxDepth - 1);
1159
+ }
1160
+ /**
1161
+ * Checks if a property name is a CSS custom property (variable).
1162
+ */
1163
+ function isCssVariableName(key) {
1164
+ return key.startsWith("--");
1165
+ }
1166
+ /**
1167
+ * Converts a CSS-like value to a string for use as a CSS variable value.
1168
+ * @param value - The value to convert (string, number, or wrapped value)
1169
+ * @param maxDepth - Maximum recursion depth for evaluating the value
1170
+ * @returns The string representation
1171
+ */
1172
+ function asVar(value, maxDepth = 10) {
1173
+ if (maxDepth <= 0) return "";
1174
+ switch (typeof value) {
1175
+ case "string": return value;
1176
+ case "number": return value.toString();
1177
+ default: return asVar(value.value, maxDepth - 1);
1178
+ }
1179
+ }
1180
+ /**
1181
+ * Checks if a property name is a known CSS property.
1182
+ */
1183
+ function isKnownPropertyName(key) {
1184
+ return knownPropertyNames.has(key);
1185
+ }
1186
+ /**
1187
+ * Converts a value to a CSS property string.
1188
+ * Automatically appends units to numeric values for properties that require them.
1189
+ * @param value - The value to convert
1190
+ * @param key - The CSS property name
1191
+ * @returns The formatted CSS value string
1192
+ */
1193
+ function asKnownProp(value, key) {
1194
+ return formatValue(value, key);
1195
+ }
1196
+ /**
1197
+ * Checks if a key represents a nested CSS selector.
1198
+ */
1199
+ function isNestedSelector(key) {
1200
+ return key.includes("&");
1201
+ }
1202
+ /** Known at-rule prefixes that mochi-css recognizes */
1203
+ const AT_RULE_PREFIXES = [
1204
+ "@media ",
1205
+ "@container ",
1206
+ "@supports ",
1207
+ "@layer "
1208
+ ];
1209
+ /**
1210
+ * Checks if a key represents a CSS at-rule (media, container, supports, layer).
1211
+ */
1212
+ function isAtRuleKey(key) {
1213
+ return AT_RULE_PREFIXES.some((p) => key.startsWith(p));
1214
+ }
1215
+ /**
1216
+ * Converts a SimpleStyleProps object to a CSS properties record.
1217
+ * Transforms camelCase property names to kebab-case and applies value converters.
1218
+ * @param props - The style properties object
1219
+ * @returns A record of CSS property names (kebab-case) to string values
1220
+ * @example
1221
+ * cssFromProps({ backgroundColor: 'blue', padding: 16 })
1222
+ * // { 'background-color': 'blue', 'padding': '16px' }
1223
+ */
1224
+ function cssFromProps(props) {
1225
+ return Object.fromEntries(Object.entries(props).map(([key, value]) => {
1226
+ if (value === void 0) return void 0;
1227
+ if (isCssVariableName(key)) return [key, asVar(value)];
1228
+ if (isKnownPropertyName(key)) return [camelToKebab(key), asKnownProp(value, key)];
1229
+ }).filter((v) => v !== void 0));
1230
+ }
1231
+
1232
+ //#endregion
1233
+ //#region src/selector.ts
1234
+ /**
1235
+ * Immutable CSS selector builder that handles nested selectors and CSS at-rules.
1236
+ * Uses the `&` character as a placeholder for parent selector substitution.
1237
+ *
1238
+ * @example
1239
+ * const selector = new MochiSelector(['.button'])
1240
+ * selector.extend('&:hover').cssSelector // '.button:hover'
1241
+ * selector.wrap('@media (min-width: 768px)').atRules // ['@media (min-width: 768px)']
1242
+ */
1243
+ var MochiSelector = class MochiSelector {
1244
+ /**
1245
+ * Creates a new MochiSelector instance.
1246
+ * @param cssSelectors - Array of CSS selectors (may contain `&` placeholders)
1247
+ * @param atRules - Array of full CSS at-rule strings e.g. `"@media (min-width: 768px)"`
1248
+ */
1249
+ constructor(cssSelectors = [], atRules = []) {
1250
+ this.cssSelectors = cssSelectors;
1251
+ this.atRules = atRules;
1252
+ }
1253
+ /**
1254
+ * Gets the combined CSS selector string.
1255
+ * Multiple selectors are joined with commas.
1256
+ * @returns The CSS selector, or "*" if no selectors are defined
1257
+ */
1258
+ get cssSelector() {
1259
+ if (this.cssSelectors.length === 0) return "*";
1260
+ return this.cssSelectors.join(", ");
1261
+ }
1262
+ /**
1263
+ * Substitutes all `&` placeholders with the given root selector.
1264
+ * @param root - The selector to replace `&` with
1265
+ * @returns A new MochiSelector with substituted selectors
1266
+ */
1267
+ substitute(root) {
1268
+ return new MochiSelector(this.cssSelectors.map((selector) => selector.replace(/&/g, root)), this.atRules);
1269
+ }
1270
+ /**
1271
+ * Extends this selector by nesting a child selector.
1272
+ * The `&` in the child selector is replaced with each parent selector.
1273
+ * @param child - The child selector pattern (must contain `&`)
1274
+ * @returns A new MochiSelector with the extended selectors
1275
+ * @example
1276
+ * new MochiSelector(['.btn']).extend('&:hover') // '.btn:hover'
1277
+ * new MochiSelector(['.btn']).extend('& .icon') // '.btn .icon'
1278
+ */
1279
+ extend(child) {
1280
+ if (!isNestedSelector(child)) return this;
1281
+ const children = MochiSelector.split(child);
1282
+ return new MochiSelector(this.cssSelectors.flatMap((parentSelector) => children.map((childSelector) => {
1283
+ return childSelector.replace(/&/g, parentSelector);
1284
+ })), this.atRules);
1285
+ }
1286
+ /**
1287
+ * Wraps this selector with a CSS at-rule.
1288
+ * @param atRule - The full at-rule string (e.g. `"@media (min-width: 768px)"`)
1289
+ * @returns A new MochiSelector with the added at-rule, or unchanged if not a known at-rule
1290
+ * @example
1291
+ * selector.wrap('@media (min-width: 768px)') // Adds media query
1292
+ * selector.wrap('@container sidebar (min-width: 300px)') // Adds container query
1293
+ */
1294
+ wrap(atRule) {
1295
+ if (!isAtRuleKey(atRule)) return this;
1296
+ return new MochiSelector(this.cssSelectors, [...this.atRules, atRule]);
1297
+ }
1298
+ /**
1299
+ * Splits a comma-separated selector string into individual selectors.
1300
+ * @param selector - The selector string to split
1301
+ * @returns Array of individual selector strings
1302
+ */
1303
+ static split(selector) {
1304
+ return [selector];
1305
+ }
1306
+ };
1307
+
1308
+ //#endregion
1309
+ //#region ../core/dist/index.mjs
1310
+ const hashBase = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_";
1311
+ const base = 64;
1312
+ function numberToBase62(num, maxLength) {
1313
+ let out = "";
1314
+ while (num > 0 && out.length < (maxLength ?? Infinity)) {
1315
+ out = hashBase[num % base] + out;
1316
+ num = Math.floor(num / base);
1317
+ }
1318
+ return out.length > 0 ? out : "0";
1319
+ }
1320
+ function shortHash(input, length = 8) {
1321
+ let h = 5381;
1322
+ for (let i = 0; i < input.length; i++) h = h * 33 ^ input.charCodeAt(i);
1323
+ h >>>= 0;
1324
+ return numberToBase62(h, length);
1325
+ }
1326
+
1327
+ //#endregion
1328
+ //#region src/compare.ts
1329
+ /**
1330
+ * String comparison utilities for deterministic sorting.
1331
+ * Used internally to ensure consistent CSS output order.
1332
+ * @module compare
1333
+ */
1334
+ /**
1335
+ * Compares two strings lexicographically.
1336
+ */
1337
+ function compareString(a, b) {
1338
+ return a < b ? -1 : a === b ? 0 : 1;
1339
+ }
1340
+ /**
1341
+ * Compares two tuples by their first element (string key).
1342
+ * Useful for sorting Object.entries() results.
1343
+ */
1344
+ function compareStringKey(a, b) {
1345
+ return compareString(a[0], b[0]);
1346
+ }
1347
+ /**
1348
+ * Creates a comparator function for objects with a specific string property.
1349
+ * @param name - The property name to compare by
1350
+ * @returns A comparator function that compares objects by the specified property
1351
+ * @example
1352
+ * const items = [{ key: 'b' }, { key: 'a' }]
1353
+ * items.sort(stringPropComparator('key')) // [{ key: 'a' }, { key: 'b' }]
1354
+ */
1355
+ function stringPropComparator(name) {
1356
+ return (a, b) => compareString(a[name], b[name]);
1357
+ }
1358
+
1359
+ //#endregion
1360
+ //#region src/cssObject.ts
1361
+ /**
1362
+ * Represents a single CSS rule block with properties and a selector.
1363
+ * Handles conversion to CSS string format and hash generation.
1364
+ */
1365
+ var CssObjectSubBlock = class CssObjectSubBlock {
1366
+ /**
1367
+ * Creates a new CSS sub-block.
1368
+ * @param cssProps - Map of CSS property names (kebab-case) to values
1369
+ * @param selector - The selector this block applies to
1370
+ */
1371
+ constructor(cssProps, selector) {
1372
+ this.cssProps = cssProps;
1373
+ this.selector = selector;
1374
+ }
1375
+ /**
1376
+ * Computes a deterministic hash of this block's CSS content.
1377
+ * Used for generating unique class names.
1378
+ */
1379
+ get hash() {
1380
+ return shortHash(this.asCssString("&"));
1381
+ }
1382
+ /**
1383
+ * Converts this block to a CSS string.
1384
+ * Handles at-rule wrapping (media, container, supports, layer) if present.
1385
+ * Multiple at-rules are nested in order.
1386
+ * @param root - The root selector to substitute for `&`
1387
+ * @returns Formatted CSS string
1388
+ */
1389
+ asCssString(root) {
1390
+ const selector = this.selector.substitute(root);
1391
+ const atRules = selector.atRules;
1392
+ const innerIndent = " ".repeat(atRules.length);
1393
+ const props = Object.entries(this.cssProps).toSorted(compareStringKey).map(([k, v]) => `${innerIndent} ${k}: ${v};\n`).join("");
1394
+ let result = `${innerIndent}${selector.cssSelector} {\n${props}${innerIndent}}`;
1395
+ for (let i = atRules.length - 1; i >= 0; i--) {
1396
+ const outerIndent = " ".repeat(i);
1397
+ result = `${outerIndent}${atRules[i]} {\n${result}\n${outerIndent}}`;
1398
+ }
1399
+ return result;
1400
+ }
1401
+ /**
1402
+ * Parses StyleProps into an array of CSS sub-blocks.
1403
+ * Recursively processes nested selectors and media queries.
1404
+ * Output order is deterministic for consistent hash generation.
1405
+ *
1406
+ * @param props - The style properties to parse
1407
+ * @param selector - The parent selector context (defaults to `&`)
1408
+ * @returns Non-empty array of sub-blocks (main block first, then nested)
1409
+ */
1410
+ static fromProps(props, selector) {
1411
+ selector ??= new MochiSelector(["&"]);
1412
+ const cssProps = {};
1413
+ const propsToProcess = [];
1414
+ for (const [key, value] of Object.entries(props)) {
1415
+ if (value === void 0) continue;
1416
+ if (isCssVariableName(key)) {
1417
+ cssProps[key] = asVar(value);
1418
+ continue;
1419
+ }
1420
+ if (isKnownPropertyName(key)) {
1421
+ cssProps[camelToKebab(key)] = asKnownProp(value, key);
1422
+ continue;
1423
+ }
1424
+ if (isNestedSelector(key)) {
1425
+ propsToProcess.push({
1426
+ key,
1427
+ props: value,
1428
+ selector: selector.extend(key)
1429
+ });
1430
+ continue;
1431
+ }
1432
+ if (isAtRuleKey(key)) {
1433
+ propsToProcess.push({
1434
+ key,
1435
+ props: value,
1436
+ selector: selector.wrap(key)
1437
+ });
1438
+ continue;
1439
+ }
1440
+ if (process.env["NODE_ENV"] !== "production") console.warn(`[mochi-css] Unknown style property "${key}" will be ignored`);
1441
+ }
1442
+ return [new CssObjectSubBlock(cssProps, selector), ...propsToProcess.toSorted(stringPropComparator("key")).flatMap(({ props: props$1, selector: selector$1 }) => CssObjectSubBlock.fromProps(props$1, selector$1))];
1443
+ }
1444
+ };
1445
+ /**
1446
+ * Represents an abstract CSS block definition.
1447
+ * Contains one or more sub-blocks for nested selectors and media queries.
1448
+ */
1449
+ var CssObjectBlock = class {
1450
+ /** The generated unique class name for this block */
1451
+ className;
1452
+ /** All sub-blocks (main styles and nested/media rules) */
1453
+ subBlocks = [];
1454
+ /**
1455
+ * Creates a new CSS block from style properties.
1456
+ * Generates a unique class name based on the content hash, or uses the provided class name.
1457
+ * @param styles - The style properties to compile
1458
+ * @param className - Optional stable class name; if omitted, a content-hash-based name is generated
1459
+ */
1460
+ constructor(styles, className) {
1461
+ const blocks = CssObjectSubBlock.fromProps(styles);
1462
+ this.className = className ?? "c" + shortHash(blocks.map((b) => b.hash).join("+"));
1463
+ this.subBlocks = blocks;
1464
+ }
1465
+ /**
1466
+ * Gets the CSS class selector for this block.
1467
+ */
1468
+ get selector() {
1469
+ return `.${this.className}`;
1470
+ }
1471
+ /**
1472
+ * Converts style block to a CSS string.
1473
+ * @param root - The root selector to scope styles to
1474
+ * @returns Complete CSS string for this block
1475
+ */
1476
+ asCssString(root) {
1477
+ return this.subBlocks.map((b) => b.asCssString(new MochiSelector([root]).extend(`&.${this.className}`).cssSelector)).join("\n\n");
1478
+ }
1479
+ };
1480
+ /**
1481
+ * Complete CSS object representation with main and variant styles.
1482
+ *
1483
+ * @template V - The variant definitions type
1484
+ *
1485
+ * @example
1486
+ * const obj = new CSSObject({
1487
+ * color: 'blue',
1488
+ * variants: {
1489
+ * size: {
1490
+ * small: { fontSize: 12 },
1491
+ * large: { fontSize: 18 }
1492
+ * }
1493
+ * },
1494
+ * defaultVariants: { size: 'small' }
1495
+ * })
1496
+ * obj.asCssString() // Returns complete CSS with all variants
1497
+ */
1498
+ var CSSObject = class {
1499
+ /** The main style block (non-variant styles) */
1500
+ mainBlock;
1501
+ /** Compiled blocks for each variant option */
1502
+ variantBlocks;
1503
+ /** Default variant selections */
1504
+ variantDefaults;
1505
+ /** Compound variant conditions and their parsed sub-blocks */
1506
+ compoundVariants;
1507
+ /**
1508
+ * Creates a new CSSObject from style props.
1509
+ * Compiles main styles and all variant options into CSS blocks.
1510
+ * @param props - Base style props plus variant definitions
1511
+ * @param props.variants - Named variant groups, each mapping variant values to style props
1512
+ * @param props.defaultVariants - Default value for each variant when none is provided at runtime
1513
+ * @param props.compoundVariants - Style props applied when a specific combination of variants is active
1514
+ * @param className - Optional stable class name for the main block
1515
+ */
1516
+ constructor({ variants, defaultVariants, compoundVariants,...props }, className) {
1517
+ this.mainBlock = new CssObjectBlock(props, className);
1518
+ this.variantBlocks = {};
1519
+ this.variantDefaults = defaultVariants ?? {};
1520
+ this.compoundVariants = [];
1521
+ if (variants) for (const variantGroupName in variants) {
1522
+ this.variantBlocks[variantGroupName] = {};
1523
+ const variantGroup = variants[variantGroupName];
1524
+ for (const variantItemName in variantGroup) this.variantBlocks[variantGroupName][variantItemName] = new CssObjectBlock(variantGroup[variantItemName] ?? {});
1525
+ }
1526
+ if (compoundVariants) for (const compound of compoundVariants) {
1527
+ const { css: styles,...conditions } = compound;
1528
+ this.compoundVariants.push({
1529
+ conditions,
1530
+ subBlocks: CssObjectSubBlock.fromProps(styles)
1531
+ });
1532
+ }
1533
+ }
1534
+ /**
1535
+ * Serializes the entire CSS object to a CSS string.
1536
+ * Outputs the main block first, then all variant blocks in sorted order.
1537
+ * @returns Complete CSS string ready for injection into a stylesheet
1538
+ */
1539
+ asCssString() {
1540
+ return [
1541
+ this.mainBlock.asCssString(""),
1542
+ ...Object.entries(this.variantBlocks).toSorted(compareStringKey).flatMap(([_, b]) => Object.entries(b).toSorted(compareStringKey)).map(([_, b]) => b.asCssString(this.mainBlock.selector)),
1543
+ ...this.compoundVariants.flatMap(({ conditions, subBlocks }) => {
1544
+ const selectorParts = [];
1545
+ for (const [variantName, optionName] of Object.entries(conditions).toSorted(compareStringKey)) {
1546
+ const selector = this.variantBlocks[variantName]?.[optionName]?.selector;
1547
+ if (selector === void 0) return [];
1548
+ selectorParts.push(selector);
1549
+ }
1550
+ const combinedSelector = `${this.mainBlock.selector}${selectorParts.join("")}`;
1551
+ return subBlocks.map((b) => b.asCssString(combinedSelector));
1552
+ })
1553
+ ].join("\n\n");
1554
+ }
1555
+ };
1556
+
1557
+ //#endregion
1558
+ //#region src/css.ts
1559
+ const MOCHI_CSS_TYPEOF = Symbol.for("mochi-css.MochiCSS");
1560
+ function isMochiCSS(value) {
1561
+ return typeof value === "object" && value !== null && value["$$typeof"] === MOCHI_CSS_TYPEOF;
1562
+ }
1563
+ /**
1564
+ * Runtime representation of a CSS style definition with variant support.
1565
+ * Holds generated class names and provides methods to compute the final
1566
+ * className string based on selected variants.
1567
+ *
1568
+ * @template V - The variant definitions type mapping variant names to their options
1569
+ *
1570
+ * @example
1571
+ * const styles = MochiCSS.from(new CSSObject({
1572
+ * color: 'blue',
1573
+ * variants: { size: { small: { fontSize: 12 }, large: { fontSize: 18 } } }
1574
+ * }))
1575
+ * styles.variant({ size: 'large' }) // Returns combined class names
1576
+ */
1577
+ var MochiCSS = class MochiCSS {
1578
+ $$typeof = MOCHI_CSS_TYPEOF;
1579
+ /**
1580
+ * Creates a new MochiCSS instance.
1581
+ * @param classNames - Base class names to always include
1582
+ * @param variantClassNames - Mapping of variant names to option class names
1583
+ * @param defaultVariants - Default variant selections when not specified
1584
+ */
1585
+ constructor(classNames, variantClassNames, defaultVariants) {
1586
+ this.classNames = classNames;
1587
+ this.variantClassNames = variantClassNames;
1588
+ this.defaultVariants = defaultVariants;
1589
+ }
1590
+ /**
1591
+ * Computes the final className string based on variant selections.
1592
+ * Compound variants are handled purely via CSS combined selectors,
1593
+ * so no runtime matching is needed here.
1594
+ * @param props - Variant selections
1595
+ * @returns Combined className string for use in components
1596
+ */
1597
+ variant(props) {
1598
+ const keys = new Set([...Object.keys(props), ...Object.keys(this.defaultVariants)].filter((k) => k in this.variantClassNames));
1599
+ return clsx(this.classNames, ...keys.values().map((k) => {
1600
+ const variantGroup = this.variantClassNames[k];
1601
+ if (!variantGroup) return false;
1602
+ const variantKey = ((k in props ? props[k] : void 0) ?? this.defaultVariants[k])?.toString();
1603
+ if (variantKey == null) return false;
1604
+ const selectedClassname = variantGroup[variantKey];
1605
+ if (selectedClassname !== void 0) return selectedClassname;
1606
+ const defaultKey = this.defaultVariants[k];
1607
+ if (defaultKey == null) return false;
1608
+ return variantGroup[defaultKey.toString()];
1609
+ }));
1610
+ }
1611
+ /**
1612
+ * Returns the CSS selector for this style (e.g. `.abc123`).
1613
+ * Useful for targeting this component from another style.
1614
+ */
1615
+ get selector() {
1616
+ return this.classNames.map((n) => `.${n}`).join();
1617
+ }
1618
+ toString() {
1619
+ return this.selector;
1620
+ }
1621
+ /**
1622
+ * Creates a MochiCSS instance from a CSSObject.
1623
+ * Extracts class names from the compiled CSS blocks.
1624
+ * @template V - The variant definitions type
1625
+ * @param object - The compiled CSSObject to extract from
1626
+ * @returns A new MochiCSS instance with the extracted class names
1627
+ */
1628
+ static from(object) {
1629
+ return new MochiCSS([object.mainBlock.className], Object.fromEntries(Object.entries(object.variantBlocks).map(([key, variantOptions]) => {
1630
+ return [key, Object.fromEntries(Object.entries(variantOptions).map(([optionKey, block]) => {
1631
+ return [optionKey, block.className];
1632
+ }))];
1633
+ })), object.variantDefaults);
1634
+ }
1635
+ };
1636
+ /**
1637
+ * Creates a CSS style definition.
1638
+ * The primary API for defining styles in Mochi-CSS.
1639
+ *
1640
+ * @template V - Tuple of variant definition types
1641
+ * @param props - One or more style objects or existing MochiCSS instances to merge
1642
+ * @returns A MochiCSS instance with all styles and variants combined
1643
+ *
1644
+ * @example
1645
+ * // Simple usage
1646
+ * const button = css({ padding: 8, borderRadius: 4 })
1647
+ *
1648
+ * @example
1649
+ * // With variants
1650
+ * const button = css({
1651
+ * padding: 8,
1652
+ * variants: {
1653
+ * size: {
1654
+ * small: { padding: 4 },
1655
+ * large: { padding: 16 }
1656
+ * }
1657
+ * },
1658
+ * defaultVariants: { size: 'small' }
1659
+ * })
1660
+ * button.variant({ size: 'large' }) // Get class names for large size
1661
+ *
1662
+ * @example
1663
+ * // Merging multiple styles
1664
+ * const combined = css(baseStyles, additionalStyles)
1665
+ */
1666
+ const emptyMochiCSS = new MochiCSS([], {}, {});
1667
+ /**
1668
+ * Merges multiple MochiCSS instances into a single one, combining their
1669
+ * class names, variant class names, and default variants.
1670
+ * @param instances - The MochiCSS instances to merge
1671
+ * @returns A new MochiCSS instance with all styles combined
1672
+ */
1673
+ function mergeMochiCss(instances) {
1674
+ if (instances.length === 0) return emptyMochiCSS;
1675
+ return new MochiCSS(instances.flatMap((c) => c.classNames), instances.reduce((a, b) => Object.assign(a, b.variantClassNames), {}), instances.reduce((a, b) => Object.assign(a, b.defaultVariants), {}));
1676
+ }
1677
+ function css(...props) {
1678
+ const cssToMerge = [];
1679
+ for (const p of props) {
1680
+ if (p == null) continue;
1681
+ if (typeof p === "string") {
1682
+ cssToMerge.push(new MochiCSS([p], {}, {}));
1683
+ continue;
1684
+ }
1685
+ if (typeof p !== "object") continue;
1686
+ if (p instanceof MochiCSS) cssToMerge.push(p);
1687
+ else cssToMerge.push(MochiCSS.from(new CSSObject(p)));
1688
+ }
1689
+ return mergeMochiCss(cssToMerge);
1690
+ }
1691
+
1692
+ //#endregion
1693
+ //#region src/keyframesObject.ts
1694
+ var KeyframesObject = class KeyframesObject {
1695
+ name;
1696
+ body;
1697
+ constructor(stops) {
1698
+ this.body = KeyframesObject.generateBody(stops);
1699
+ this.name = "kf" + shortHash(this.body);
1700
+ }
1701
+ asCssString() {
1702
+ return `@keyframes ${this.name} {\n${this.body}\n}`;
1703
+ }
1704
+ static generateBody(stops) {
1705
+ return Object.entries(stops).toSorted(compareStringKey).map(([stopKey, props]) => {
1706
+ const cssProps = cssFromProps(props);
1707
+ return ` ${stopKey} {\n${Object.entries(cssProps).toSorted(compareStringKey).map(([k, v]) => ` ${k}: ${v};`).join("\n")}\n }`;
1708
+ }).join("\n\n");
1709
+ }
1710
+ };
1711
+
1712
+ //#endregion
1713
+ //#region src/keyframes.ts
1714
+ var MochiKeyframes = class MochiKeyframes {
1715
+ constructor(name) {
1716
+ this.name = name;
1717
+ }
1718
+ toString() {
1719
+ return this.name;
1720
+ }
1721
+ get value() {
1722
+ return this.name;
1723
+ }
1724
+ static from(object) {
1725
+ return new MochiKeyframes(object.name);
1726
+ }
1727
+ };
1728
+ function keyframes(stops) {
1729
+ return MochiKeyframes.from(new KeyframesObject(stops));
1730
+ }
1731
+
1732
+ //#endregion
1733
+ //#region src/globalCssObject.ts
1734
+ /**
1735
+ * CSS object model for global (non-scoped) styles.
1736
+ * Accepts a map of CSS selectors to style objects and serializes them
1737
+ * as plain CSS rules without class name scoping.
1738
+ *
1739
+ * @example
1740
+ * const obj = new GlobalCssObject({
1741
+ * body: { margin: 0 },
1742
+ * 'h1': { fontSize: 32 },
1743
+ * })
1744
+ * obj.asCssString() // "body {\n margin: 0;\n}\n\nh1 {\n font-size: 32px;\n}"
1745
+ */
1746
+ var GlobalCssObject = class {
1747
+ rules;
1748
+ constructor(styles) {
1749
+ this.rules = Object.entries(styles).toSorted(compareStringKey).map(([selector, props]) => ({
1750
+ selector,
1751
+ subBlocks: [...CssObjectSubBlock.fromProps(props)]
1752
+ }));
1753
+ }
1754
+ asCssString() {
1755
+ return this.rules.flatMap(({ selector, subBlocks }) => subBlocks.map((b) => b.asCssString(selector))).join("\n\n");
1756
+ }
1757
+ };
1758
+
1759
+ //#endregion
1760
+ //#region src/globalCss.ts
1761
+ /**
1762
+ * Creates a global CSS definition.
1763
+ * Styles are not scoped to any class — they apply to all matching elements.
1764
+ *
1765
+ * @param styles - Map of CSS selectors to style objects
1766
+ *
1767
+ * @example
1768
+ * globalCss({
1769
+ * 'body': { margin: 0, padding: 0 },
1770
+ * '*, *::before, *::after': { boxSizing: 'border-box' },
1771
+ * })
1772
+ */
1773
+ function globalCss(styles) {}
1774
+
1775
+ //#endregion
1776
+ //#region src/query.ts
1777
+ /**
1778
+ * Wraps a condition in parentheses if not already wrapped.
1779
+ */
1780
+ function wrapParens(condition) {
1781
+ const trimmed = condition.trim();
1782
+ if (trimmed.startsWith("(") && trimmed.endsWith(")")) return trimmed;
1783
+ return `(${trimmed})`;
1784
+ }
1785
+ function mediaFn(condition) {
1786
+ return `@media ${wrapParens(condition)}`;
1787
+ }
1788
+ mediaFn.and = function(...conditions) {
1789
+ return `@media ${conditions.map(wrapParens).join(" and ")}`;
1790
+ };
1791
+ mediaFn.or = function(...conditions) {
1792
+ return `@media ${conditions.map(wrapParens).join(", ")}`;
1793
+ };
1794
+ Object.defineProperties(mediaFn, {
1795
+ dark: {
1796
+ get: () => "@media (prefers-color-scheme: dark)",
1797
+ enumerable: true
1798
+ },
1799
+ light: {
1800
+ get: () => "@media (prefers-color-scheme: light)",
1801
+ enumerable: true
1802
+ },
1803
+ motion: {
1804
+ get: () => "@media (prefers-reduced-motion: no-preference)",
1805
+ enumerable: true
1806
+ },
1807
+ print: {
1808
+ get: () => "@media print",
1809
+ enumerable: true
1810
+ }
1811
+ });
1812
+ /** Helper for constructing `@media` at-rule keys. */
1813
+ const media = mediaFn;
1814
+ function containerFn(condition) {
1815
+ return `@container ${wrapParens(condition)}`;
1816
+ }
1817
+ containerFn.named = function(name, condition) {
1818
+ return `@container ${name} ${wrapParens(condition)}`;
1819
+ };
1820
+ /** Helper for constructing `@container` at-rule keys. */
1821
+ const container = containerFn;
1822
+ function supportsFn(condition) {
1823
+ return `@supports ${wrapParens(condition)}`;
1824
+ }
1825
+ supportsFn.not = function(condition) {
1826
+ return `@supports not ${wrapParens(condition)}`;
1827
+ };
1828
+ supportsFn.and = function(...conditions) {
1829
+ return `@supports ${conditions.map(wrapParens).join(" and ")}`;
1830
+ };
1831
+ supportsFn.or = function(...conditions) {
1832
+ return `@supports ${conditions.map(wrapParens).join(" or ")}`;
1833
+ };
1834
+ /** Helper for constructing `@supports` at-rule keys. */
1835
+ const supports = supportsFn;
1836
+
1837
+ //#endregion
1838
+ export { Token as C, kebabToCamel as S, shortHash as _, GlobalCssObject as a, cssFromProps as b, KeyframesObject as c, isMochiCSS as d, mergeMochiCss as f, numberToBase62 as g, CssObjectSubBlock as h, globalCss as i, MochiCSS as l, CssObjectBlock as m, media as n, MochiKeyframes as o, CSSObject as p, supports as r, keyframes as s, container as t, css as u, MochiSelector as v, createToken as w, isAtRuleKey as x, camelToKebab as y };