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