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