@kbach/react 0.6.24 → 0.6.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1274 @@
1
+ /**
2
+ * Unified modifier registry — single source of truth for ALL modifier behavior.
3
+ *
4
+ * Adding a new modifier requires editing ONLY this file:
5
+ * 1. Add an entry to BUILTIN_MODIFIERS with its CSS and JS behavior.
6
+ * 2. Done — parser, resolver, CSS generator, and JSX runtime all derive
7
+ * their behavior from this data automatically.
8
+ *
9
+ * Plugin authors can register custom modifiers via registerModifier().
10
+ */
11
+ interface ModifierDef {
12
+ /** CSS pseudo-class or pseudo-element appended to the selector (e.g. ':hover', '::before') */
13
+ pseudo?: string;
14
+ /** Ancestor selector prefix INCLUDING trailing space (e.g. '.group:hover ', '.peer:focus ~ ') */
15
+ ancestorSelector?: string;
16
+ /** Directionality attribute selector prefix INCLUDING trailing space (e.g. '[dir="rtl"] ') */
17
+ dirSelector?: string;
18
+ /** @media query body WITHOUT the '@media ' prefix (e.g. 'print', '(orientation: landscape)') */
19
+ mediaQuery?: string;
20
+ /** Dark/light mode scheme — triggers the configured darkMode strategy in CSS output */
21
+ darkScheme?: 'dark' | 'light';
22
+ /** True for responsive modifiers — wraps in @media (min-width: theme.screens[name]) */
23
+ isResponsive?: boolean;
24
+ /**
25
+ * Forces !important on all declarations in the generated CSS rule.
26
+ * Applied automatically for structural / ancestor / media modifiers that must
27
+ * win over base inline styles.
28
+ */
29
+ forcesImportant?: boolean;
30
+ /**
31
+ * How the JSX runtime routes this modifier:
32
+ * 'interactive' — managed by InteractiveWrapper (hover, focus, pressed, …)
33
+ * 'mode' — managed by DarkWrapper (dark, light, not-dark, …)
34
+ * 'responsive' — managed by DarkWrapper (sm, md, lg, xl, 2xl)
35
+ * 'css-only' — CSS injection only; matchModifier always returns false
36
+ */
37
+ jsBehavior: 'interactive' | 'mode' | 'responsive' | 'css-only';
38
+ /**
39
+ * Evaluates whether this modifier's condition is met at runtime.
40
+ * Omit for 'css-only' modifiers — they never apply as inline styles.
41
+ */
42
+ jsMatch?: (isDark: boolean, state: Record<string, boolean | undefined>, breakpoints: Set<string>) => boolean;
43
+ }
44
+ declare function registerModifier(name: string, def: ModifierDef): void;
45
+ declare function clearPluginModifiers(): void;
46
+ declare function getModifier(name: string): ModifierDef | undefined;
47
+ declare function isKnownModifier(name: string): boolean;
48
+ /** All known modifier names (built-in + plugin). */
49
+ declare function getAllModifierNames(): Set<string>;
50
+ /** Modifier names routed to InteractiveWrapper. */
51
+ declare function getInteractiveModifiers(): Set<string>;
52
+ /** Modifier names routed to DarkWrapper for mode switching. */
53
+ declare function getModeModifiers(): Set<string>;
54
+ /** Modifier names routed to DarkWrapper for responsive handling. */
55
+ declare function getResponsiveModifiers(): Set<string>;
56
+ /**
57
+ * Evaluates whether a modifier matches the current runtime state.
58
+ * CSS-only modifiers always return false — they have no JS representation.
59
+ */
60
+ declare function matchModifier(name: string, isDark: boolean, state: Record<string, boolean | undefined>, breakpoints: Set<string>): boolean;
61
+
62
+ type Platform = 'web' | 'native';
63
+ type ThemeMode = 'light' | 'dark' | 'system';
64
+ interface StyleValue {
65
+ [key: string]: string | number | undefined | null | StyleValue | StyleValue[];
66
+ }
67
+ interface ParsedClass {
68
+ /** The original class string, e.g. "dark:hover:bg-[#fff]" */
69
+ original: string;
70
+ /** Up to 3 modifier prefixes, e.g. ['dark', 'hover'] */
71
+ modifiers: string[];
72
+ /** Whether a leading `-` was present for negative values */
73
+ negative: boolean;
74
+ /** Whether a leading `!` was present — applies !important to all CSS declarations */
75
+ important: boolean;
76
+ /** The utility name, e.g. 'bg', 'p', 'text' */
77
+ utility: string;
78
+ /** The resolved value, e.g. 'white', '#fff', '4' */
79
+ value: string;
80
+ /** Whether the value was specified with bracket notation [value] */
81
+ isArbitrary: boolean;
82
+ }
83
+ interface ResolvedStyle {
84
+ /** Base styles applied unconditionally */
85
+ base?: StyleValue;
86
+ /** Styles keyed by modifier or modifier combo, e.g. 'dark', 'hover', 'dark:hover' */
87
+ [modifierKey: string]: StyleValue | undefined;
88
+ }
89
+ type ColorShades = Record<string, string>;
90
+ type ThemeColors = Record<string, string | ColorShades>;
91
+ type ThemeSpacing = Record<string, number | string>;
92
+ interface ThemeConfig {
93
+ colors: ThemeColors;
94
+ spacing: ThemeSpacing;
95
+ fontSize: Record<string, number | string>;
96
+ fontFamily: Record<string, string | string[]>;
97
+ fontWeight: Record<string, string | number>;
98
+ borderRadius: Record<string, number | string>;
99
+ borderWidth: Record<string, number>;
100
+ opacity: Record<string, number>;
101
+ lineHeight: Record<string, number | string>;
102
+ letterSpacing: Record<string, number | string>;
103
+ zIndex: Record<string, number | string>;
104
+ flex: Record<string, number | string>;
105
+ shadow: Record<string, StyleValue>;
106
+ screens: Record<string, string | number>;
107
+ /**
108
+ * Custom @keyframes, web only. Each key is a keyframe name, its value maps
109
+ * percentage/from/to selectors to a plain CSS declaration object (camelCase
110
+ * properties, same shape as an inline style object):
111
+ * keyframes: { wiggle: { '0%, 100%': { transform: 'rotate(-3deg)' }, '50%': { transform: 'rotate(3deg)' } } }
112
+ * Referenced from `animation` below, or directly via animate-[wiggle_1s_ease-in-out].
113
+ */
114
+ keyframes: Record<string, Record<string, StyleValue>>;
115
+ /**
116
+ * Named animation shorthands built on `keyframes` above, referenced via
117
+ * animate-{name} (e.g. animate-wiggle):
118
+ * animation: { wiggle: 'wiggle 1s ease-in-out infinite' }
119
+ * The first word must match a `keyframes` key so its @keyframes rule can be
120
+ * injected alongside the animation — a name with no matching keyframes entry
121
+ * still sets the `animation` CSS property, it just won't animate anything.
122
+ */
123
+ animation: Record<string, string>;
124
+ [key: string]: unknown;
125
+ }
126
+ /**
127
+ * 'class' — toggles .dark class on <html>
128
+ * 'media' — uses prefers-color-scheme media query
129
+ * 'attribute' — uses data-theme="dark" attribute on <html>
130
+ */
131
+ type DarkMode = 'attribute' | 'class' | 'media';
132
+ interface PluginAPI {
133
+ addUtility(name: string, styles: StyleValue): void;
134
+ /**
135
+ * Register a custom variant.
136
+ *
137
+ * Pass a CSS selector string for simple cases — it is automatically
138
+ * converted into a ModifierDef that generates correct CSS rules:
139
+ * addVariant('hocus', ':hover, :focus') // pseudo
140
+ * addVariant('supports-grid', '@media (display: grid)') // media
141
+ * addVariant('dark-green', '.dark-green') // ancestor selector
142
+ *
143
+ * Pass a full ModifierDef object for advanced control (e.g. JS-trackable
144
+ * interactive variants with custom jsMatch logic).
145
+ */
146
+ addVariant(name: string, selectorOrDef: string | ModifierDef): void;
147
+ theme(path: string, defaultValue?: unknown): unknown;
148
+ e(className: string): string;
149
+ }
150
+ interface FrameworkConfig {
151
+ darkMode?: DarkMode;
152
+ theme?: Partial<ThemeConfig>;
153
+ /** Additive theme extension — accepts either `extend.theme.X` or `extend.X` directly. */
154
+ extend?: {
155
+ theme?: Partial<ThemeConfig>;
156
+ } & Partial<ThemeConfig>;
157
+ plugins?: Array<(api: PluginAPI) => void>;
158
+ content?: string[];
159
+ }
160
+ interface ResolvedConfig {
161
+ darkMode: DarkMode;
162
+ theme: ThemeConfig;
163
+ plugins: Array<(api: PluginAPI) => void>;
164
+ }
165
+
166
+ declare const defaultColors: {
167
+ transparent: string;
168
+ current: string;
169
+ black: string;
170
+ white: string;
171
+ slate: {
172
+ 1: string;
173
+ 2: string;
174
+ 3: string;
175
+ 4: string;
176
+ 5: string;
177
+ 6: string;
178
+ 7: string;
179
+ 8: string;
180
+ 9: string;
181
+ 10: string;
182
+ 11: string;
183
+ 12: string;
184
+ };
185
+ gray: {
186
+ 1: string;
187
+ 2: string;
188
+ 3: string;
189
+ 4: string;
190
+ 5: string;
191
+ 6: string;
192
+ 7: string;
193
+ 8: string;
194
+ 9: string;
195
+ 10: string;
196
+ 11: string;
197
+ 12: string;
198
+ };
199
+ zinc: {
200
+ 1: string;
201
+ 2: string;
202
+ 3: string;
203
+ 4: string;
204
+ 5: string;
205
+ 6: string;
206
+ 7: string;
207
+ 8: string;
208
+ 9: string;
209
+ 10: string;
210
+ 11: string;
211
+ 12: string;
212
+ };
213
+ neutral: {
214
+ 1: string;
215
+ 2: string;
216
+ 3: string;
217
+ 4: string;
218
+ 5: string;
219
+ 6: string;
220
+ 7: string;
221
+ 8: string;
222
+ 9: string;
223
+ 10: string;
224
+ 11: string;
225
+ 12: string;
226
+ };
227
+ stone: {
228
+ 1: string;
229
+ 2: string;
230
+ 3: string;
231
+ 4: string;
232
+ 5: string;
233
+ 6: string;
234
+ 7: string;
235
+ 8: string;
236
+ 9: string;
237
+ 10: string;
238
+ 11: string;
239
+ 12: string;
240
+ };
241
+ red: {
242
+ 1: string;
243
+ 2: string;
244
+ 3: string;
245
+ 4: string;
246
+ 5: string;
247
+ 6: string;
248
+ 7: string;
249
+ 8: string;
250
+ 9: string;
251
+ 10: string;
252
+ 11: string;
253
+ 12: string;
254
+ };
255
+ orange: {
256
+ 1: string;
257
+ 2: string;
258
+ 3: string;
259
+ 4: string;
260
+ 5: string;
261
+ 6: string;
262
+ 7: string;
263
+ 8: string;
264
+ 9: string;
265
+ 10: string;
266
+ 11: string;
267
+ 12: string;
268
+ };
269
+ amber: {
270
+ 1: string;
271
+ 2: string;
272
+ 3: string;
273
+ 4: string;
274
+ 5: string;
275
+ 6: string;
276
+ 7: string;
277
+ 8: string;
278
+ 9: string;
279
+ 10: string;
280
+ 11: string;
281
+ 12: string;
282
+ };
283
+ yellow: {
284
+ 1: string;
285
+ 2: string;
286
+ 3: string;
287
+ 4: string;
288
+ 5: string;
289
+ 6: string;
290
+ 7: string;
291
+ 8: string;
292
+ 9: string;
293
+ 10: string;
294
+ 11: string;
295
+ 12: string;
296
+ };
297
+ lime: {
298
+ 1: string;
299
+ 2: string;
300
+ 3: string;
301
+ 4: string;
302
+ 5: string;
303
+ 6: string;
304
+ 7: string;
305
+ 8: string;
306
+ 9: string;
307
+ 10: string;
308
+ 11: string;
309
+ 12: string;
310
+ };
311
+ green: {
312
+ 1: string;
313
+ 2: string;
314
+ 3: string;
315
+ 4: string;
316
+ 5: string;
317
+ 6: string;
318
+ 7: string;
319
+ 8: string;
320
+ 9: string;
321
+ 10: string;
322
+ 11: string;
323
+ 12: string;
324
+ };
325
+ emerald: {
326
+ 1: string;
327
+ 2: string;
328
+ 3: string;
329
+ 4: string;
330
+ 5: string;
331
+ 6: string;
332
+ 7: string;
333
+ 8: string;
334
+ 9: string;
335
+ 10: string;
336
+ 11: string;
337
+ 12: string;
338
+ };
339
+ teal: {
340
+ 1: string;
341
+ 2: string;
342
+ 3: string;
343
+ 4: string;
344
+ 5: string;
345
+ 6: string;
346
+ 7: string;
347
+ 8: string;
348
+ 9: string;
349
+ 10: string;
350
+ 11: string;
351
+ 12: string;
352
+ };
353
+ cyan: {
354
+ 1: string;
355
+ 2: string;
356
+ 3: string;
357
+ 4: string;
358
+ 5: string;
359
+ 6: string;
360
+ 7: string;
361
+ 8: string;
362
+ 9: string;
363
+ 10: string;
364
+ 11: string;
365
+ 12: string;
366
+ };
367
+ sky: {
368
+ 1: string;
369
+ 2: string;
370
+ 3: string;
371
+ 4: string;
372
+ 5: string;
373
+ 6: string;
374
+ 7: string;
375
+ 8: string;
376
+ 9: string;
377
+ 10: string;
378
+ 11: string;
379
+ 12: string;
380
+ };
381
+ blue: {
382
+ 1: string;
383
+ 2: string;
384
+ 3: string;
385
+ 4: string;
386
+ 5: string;
387
+ 6: string;
388
+ 7: string;
389
+ 8: string;
390
+ 9: string;
391
+ 10: string;
392
+ 11: string;
393
+ 12: string;
394
+ };
395
+ indigo: {
396
+ 1: string;
397
+ 2: string;
398
+ 3: string;
399
+ 4: string;
400
+ 5: string;
401
+ 6: string;
402
+ 7: string;
403
+ 8: string;
404
+ 9: string;
405
+ 10: string;
406
+ 11: string;
407
+ 12: string;
408
+ };
409
+ violet: {
410
+ 1: string;
411
+ 2: string;
412
+ 3: string;
413
+ 4: string;
414
+ 5: string;
415
+ 6: string;
416
+ 7: string;
417
+ 8: string;
418
+ 9: string;
419
+ 10: string;
420
+ 11: string;
421
+ 12: string;
422
+ };
423
+ purple: {
424
+ 1: string;
425
+ 2: string;
426
+ 3: string;
427
+ 4: string;
428
+ 5: string;
429
+ 6: string;
430
+ 7: string;
431
+ 8: string;
432
+ 9: string;
433
+ 10: string;
434
+ 11: string;
435
+ 12: string;
436
+ };
437
+ fuchsia: {
438
+ 1: string;
439
+ 2: string;
440
+ 3: string;
441
+ 4: string;
442
+ 5: string;
443
+ 6: string;
444
+ 7: string;
445
+ 8: string;
446
+ 9: string;
447
+ 10: string;
448
+ 11: string;
449
+ 12: string;
450
+ };
451
+ pink: {
452
+ 1: string;
453
+ 2: string;
454
+ 3: string;
455
+ 4: string;
456
+ 5: string;
457
+ 6: string;
458
+ 7: string;
459
+ 8: string;
460
+ 9: string;
461
+ 10: string;
462
+ 11: string;
463
+ 12: string;
464
+ };
465
+ rose: {
466
+ 1: string;
467
+ 2: string;
468
+ 3: string;
469
+ 4: string;
470
+ 5: string;
471
+ 6: string;
472
+ 7: string;
473
+ 8: string;
474
+ 9: string;
475
+ 10: string;
476
+ 11: string;
477
+ 12: string;
478
+ };
479
+ };
480
+ declare const defaultTheme: {
481
+ colors: {
482
+ transparent: string;
483
+ current: string;
484
+ black: string;
485
+ white: string;
486
+ slate: {
487
+ 1: string;
488
+ 2: string;
489
+ 3: string;
490
+ 4: string;
491
+ 5: string;
492
+ 6: string;
493
+ 7: string;
494
+ 8: string;
495
+ 9: string;
496
+ 10: string;
497
+ 11: string;
498
+ 12: string;
499
+ };
500
+ gray: {
501
+ 1: string;
502
+ 2: string;
503
+ 3: string;
504
+ 4: string;
505
+ 5: string;
506
+ 6: string;
507
+ 7: string;
508
+ 8: string;
509
+ 9: string;
510
+ 10: string;
511
+ 11: string;
512
+ 12: string;
513
+ };
514
+ zinc: {
515
+ 1: string;
516
+ 2: string;
517
+ 3: string;
518
+ 4: string;
519
+ 5: string;
520
+ 6: string;
521
+ 7: string;
522
+ 8: string;
523
+ 9: string;
524
+ 10: string;
525
+ 11: string;
526
+ 12: string;
527
+ };
528
+ neutral: {
529
+ 1: string;
530
+ 2: string;
531
+ 3: string;
532
+ 4: string;
533
+ 5: string;
534
+ 6: string;
535
+ 7: string;
536
+ 8: string;
537
+ 9: string;
538
+ 10: string;
539
+ 11: string;
540
+ 12: string;
541
+ };
542
+ stone: {
543
+ 1: string;
544
+ 2: string;
545
+ 3: string;
546
+ 4: string;
547
+ 5: string;
548
+ 6: string;
549
+ 7: string;
550
+ 8: string;
551
+ 9: string;
552
+ 10: string;
553
+ 11: string;
554
+ 12: string;
555
+ };
556
+ red: {
557
+ 1: string;
558
+ 2: string;
559
+ 3: string;
560
+ 4: string;
561
+ 5: string;
562
+ 6: string;
563
+ 7: string;
564
+ 8: string;
565
+ 9: string;
566
+ 10: string;
567
+ 11: string;
568
+ 12: string;
569
+ };
570
+ orange: {
571
+ 1: string;
572
+ 2: string;
573
+ 3: string;
574
+ 4: string;
575
+ 5: string;
576
+ 6: string;
577
+ 7: string;
578
+ 8: string;
579
+ 9: string;
580
+ 10: string;
581
+ 11: string;
582
+ 12: string;
583
+ };
584
+ amber: {
585
+ 1: string;
586
+ 2: string;
587
+ 3: string;
588
+ 4: string;
589
+ 5: string;
590
+ 6: string;
591
+ 7: string;
592
+ 8: string;
593
+ 9: string;
594
+ 10: string;
595
+ 11: string;
596
+ 12: string;
597
+ };
598
+ yellow: {
599
+ 1: string;
600
+ 2: string;
601
+ 3: string;
602
+ 4: string;
603
+ 5: string;
604
+ 6: string;
605
+ 7: string;
606
+ 8: string;
607
+ 9: string;
608
+ 10: string;
609
+ 11: string;
610
+ 12: string;
611
+ };
612
+ lime: {
613
+ 1: string;
614
+ 2: string;
615
+ 3: string;
616
+ 4: string;
617
+ 5: string;
618
+ 6: string;
619
+ 7: string;
620
+ 8: string;
621
+ 9: string;
622
+ 10: string;
623
+ 11: string;
624
+ 12: string;
625
+ };
626
+ green: {
627
+ 1: string;
628
+ 2: string;
629
+ 3: string;
630
+ 4: string;
631
+ 5: string;
632
+ 6: string;
633
+ 7: string;
634
+ 8: string;
635
+ 9: string;
636
+ 10: string;
637
+ 11: string;
638
+ 12: string;
639
+ };
640
+ emerald: {
641
+ 1: string;
642
+ 2: string;
643
+ 3: string;
644
+ 4: string;
645
+ 5: string;
646
+ 6: string;
647
+ 7: string;
648
+ 8: string;
649
+ 9: string;
650
+ 10: string;
651
+ 11: string;
652
+ 12: string;
653
+ };
654
+ teal: {
655
+ 1: string;
656
+ 2: string;
657
+ 3: string;
658
+ 4: string;
659
+ 5: string;
660
+ 6: string;
661
+ 7: string;
662
+ 8: string;
663
+ 9: string;
664
+ 10: string;
665
+ 11: string;
666
+ 12: string;
667
+ };
668
+ cyan: {
669
+ 1: string;
670
+ 2: string;
671
+ 3: string;
672
+ 4: string;
673
+ 5: string;
674
+ 6: string;
675
+ 7: string;
676
+ 8: string;
677
+ 9: string;
678
+ 10: string;
679
+ 11: string;
680
+ 12: string;
681
+ };
682
+ sky: {
683
+ 1: string;
684
+ 2: string;
685
+ 3: string;
686
+ 4: string;
687
+ 5: string;
688
+ 6: string;
689
+ 7: string;
690
+ 8: string;
691
+ 9: string;
692
+ 10: string;
693
+ 11: string;
694
+ 12: string;
695
+ };
696
+ blue: {
697
+ 1: string;
698
+ 2: string;
699
+ 3: string;
700
+ 4: string;
701
+ 5: string;
702
+ 6: string;
703
+ 7: string;
704
+ 8: string;
705
+ 9: string;
706
+ 10: string;
707
+ 11: string;
708
+ 12: string;
709
+ };
710
+ indigo: {
711
+ 1: string;
712
+ 2: string;
713
+ 3: string;
714
+ 4: string;
715
+ 5: string;
716
+ 6: string;
717
+ 7: string;
718
+ 8: string;
719
+ 9: string;
720
+ 10: string;
721
+ 11: string;
722
+ 12: string;
723
+ };
724
+ violet: {
725
+ 1: string;
726
+ 2: string;
727
+ 3: string;
728
+ 4: string;
729
+ 5: string;
730
+ 6: string;
731
+ 7: string;
732
+ 8: string;
733
+ 9: string;
734
+ 10: string;
735
+ 11: string;
736
+ 12: string;
737
+ };
738
+ purple: {
739
+ 1: string;
740
+ 2: string;
741
+ 3: string;
742
+ 4: string;
743
+ 5: string;
744
+ 6: string;
745
+ 7: string;
746
+ 8: string;
747
+ 9: string;
748
+ 10: string;
749
+ 11: string;
750
+ 12: string;
751
+ };
752
+ fuchsia: {
753
+ 1: string;
754
+ 2: string;
755
+ 3: string;
756
+ 4: string;
757
+ 5: string;
758
+ 6: string;
759
+ 7: string;
760
+ 8: string;
761
+ 9: string;
762
+ 10: string;
763
+ 11: string;
764
+ 12: string;
765
+ };
766
+ pink: {
767
+ 1: string;
768
+ 2: string;
769
+ 3: string;
770
+ 4: string;
771
+ 5: string;
772
+ 6: string;
773
+ 7: string;
774
+ 8: string;
775
+ 9: string;
776
+ 10: string;
777
+ 11: string;
778
+ 12: string;
779
+ };
780
+ rose: {
781
+ 1: string;
782
+ 2: string;
783
+ 3: string;
784
+ 4: string;
785
+ 5: string;
786
+ 6: string;
787
+ 7: string;
788
+ 8: string;
789
+ 9: string;
790
+ 10: string;
791
+ 11: string;
792
+ 12: string;
793
+ };
794
+ };
795
+ spacing: {
796
+ px: number;
797
+ 0: number;
798
+ '0.5': number;
799
+ 1: number;
800
+ '1.5': number;
801
+ 2: number;
802
+ '2.5': number;
803
+ 3: number;
804
+ '3.5': number;
805
+ 4: number;
806
+ 5: number;
807
+ 6: number;
808
+ 7: number;
809
+ 8: number;
810
+ 9: number;
811
+ 10: number;
812
+ 11: number;
813
+ 12: number;
814
+ 14: number;
815
+ 16: number;
816
+ 20: number;
817
+ 24: number;
818
+ 28: number;
819
+ 32: number;
820
+ 36: number;
821
+ 40: number;
822
+ 44: number;
823
+ 48: number;
824
+ 52: number;
825
+ 56: number;
826
+ 60: number;
827
+ 64: number;
828
+ 72: number;
829
+ 80: number;
830
+ 96: number;
831
+ auto: string;
832
+ full: string;
833
+ '1/2': string;
834
+ '1/3': string;
835
+ '2/3': string;
836
+ '1/4': string;
837
+ '3/4': string;
838
+ screen: string;
839
+ min: string;
840
+ max: string;
841
+ fit: string;
842
+ };
843
+ fontSize: {
844
+ xs: number;
845
+ sm: number;
846
+ base: number;
847
+ lg: number;
848
+ xl: number;
849
+ '2xl': number;
850
+ '3xl': number;
851
+ '4xl': number;
852
+ '5xl': number;
853
+ '6xl': number;
854
+ '7xl': number;
855
+ '8xl': number;
856
+ '9xl': number;
857
+ };
858
+ fontFamily: {
859
+ sans: string;
860
+ mono: string;
861
+ serif: string;
862
+ };
863
+ fontWeight: {
864
+ thin: string;
865
+ extralight: string;
866
+ light: string;
867
+ normal: string;
868
+ medium: string;
869
+ semibold: string;
870
+ bold: string;
871
+ extrabold: string;
872
+ black: string;
873
+ };
874
+ borderRadius: {
875
+ none: number;
876
+ sm: number;
877
+ DEFAULT: number;
878
+ md: number;
879
+ lg: number;
880
+ xl: number;
881
+ '2xl': number;
882
+ '3xl': number;
883
+ full: number;
884
+ };
885
+ borderWidth: {
886
+ DEFAULT: number;
887
+ 0: number;
888
+ 2: number;
889
+ 4: number;
890
+ 8: number;
891
+ };
892
+ opacity: {
893
+ 0: number;
894
+ 5: number;
895
+ 10: number;
896
+ 15: number;
897
+ 20: number;
898
+ 25: number;
899
+ 30: number;
900
+ 40: number;
901
+ 50: number;
902
+ 60: number;
903
+ 70: number;
904
+ 75: number;
905
+ 80: number;
906
+ 90: number;
907
+ 95: number;
908
+ 100: number;
909
+ };
910
+ lineHeight: {
911
+ none: number;
912
+ tight: number;
913
+ snug: number;
914
+ normal: number;
915
+ relaxed: number;
916
+ loose: number;
917
+ 3: string;
918
+ 4: string;
919
+ 5: string;
920
+ 6: string;
921
+ 7: string;
922
+ 8: string;
923
+ 9: string;
924
+ 10: string;
925
+ };
926
+ letterSpacing: {
927
+ tighter: number;
928
+ tight: number;
929
+ normal: number;
930
+ wide: number;
931
+ wider: number;
932
+ widest: number;
933
+ };
934
+ zIndex: {
935
+ auto: string;
936
+ 0: number;
937
+ 10: number;
938
+ 20: number;
939
+ 30: number;
940
+ 40: number;
941
+ 50: number;
942
+ };
943
+ flex: {
944
+ 1: number;
945
+ auto: string;
946
+ initial: string;
947
+ none: string;
948
+ };
949
+ shadow: {
950
+ sm: {
951
+ shadowColor: string;
952
+ shadowOffset: {
953
+ width: number;
954
+ height: number;
955
+ };
956
+ shadowOpacity: number;
957
+ shadowRadius: number;
958
+ elevation: number;
959
+ };
960
+ DEFAULT: {
961
+ shadowColor: string;
962
+ shadowOffset: {
963
+ width: number;
964
+ height: number;
965
+ };
966
+ shadowOpacity: number;
967
+ shadowRadius: number;
968
+ elevation: number;
969
+ };
970
+ md: {
971
+ shadowColor: string;
972
+ shadowOffset: {
973
+ width: number;
974
+ height: number;
975
+ };
976
+ shadowOpacity: number;
977
+ shadowRadius: number;
978
+ elevation: number;
979
+ };
980
+ lg: {
981
+ shadowColor: string;
982
+ shadowOffset: {
983
+ width: number;
984
+ height: number;
985
+ };
986
+ shadowOpacity: number;
987
+ shadowRadius: number;
988
+ elevation: number;
989
+ };
990
+ xl: {
991
+ shadowColor: string;
992
+ shadowOffset: {
993
+ width: number;
994
+ height: number;
995
+ };
996
+ shadowOpacity: number;
997
+ shadowRadius: number;
998
+ elevation: number;
999
+ };
1000
+ '2xl': {
1001
+ shadowColor: string;
1002
+ shadowOffset: {
1003
+ width: number;
1004
+ height: number;
1005
+ };
1006
+ shadowOpacity: number;
1007
+ shadowRadius: number;
1008
+ elevation: number;
1009
+ };
1010
+ none: {
1011
+ shadowColor: string;
1012
+ shadowOffset: {
1013
+ width: number;
1014
+ height: number;
1015
+ };
1016
+ shadowOpacity: number;
1017
+ shadowRadius: number;
1018
+ elevation: number;
1019
+ };
1020
+ };
1021
+ screens: {
1022
+ sm: number;
1023
+ md: number;
1024
+ lg: number;
1025
+ xl: number;
1026
+ '2xl': number;
1027
+ };
1028
+ keyframes: {};
1029
+ animation: {};
1030
+ };
1031
+ type DefaultColorName = keyof typeof defaultColors;
1032
+ type DefaultSpacingKey = `${keyof typeof defaultTheme.spacing}`;
1033
+
1034
+ declare const RESET_STYLE_ID = "kbach-reset";
1035
+ declare const BASE_RESET: string;
1036
+
1037
+ /**
1038
+ * Bounded LRU cache using Map's insertion-order iteration.
1039
+ * Map.keys().next() gives the oldest entry for O(1) eviction.
1040
+ * Safe upper bound prevents unbounded growth (no memory leak).
1041
+ */
1042
+ declare class LRUCache<K, V> {
1043
+ private readonly capacity;
1044
+ private readonly cache;
1045
+ private readonly onEvict?;
1046
+ constructor(capacity?: number, onEvict?: (key: K, value: V) => void);
1047
+ get(key: K): V | undefined;
1048
+ set(key: K, value: V): this;
1049
+ has(key: K): boolean;
1050
+ delete(key: K): boolean;
1051
+ clear(): void;
1052
+ get size(): number;
1053
+ }
1054
+
1055
+ /**
1056
+ * Detected at module load time — safe to call repeatedly without perf cost.
1057
+ */
1058
+ declare const isWeb: boolean;
1059
+ declare const isNative: boolean;
1060
+ declare function setResolveTarget(target: 'web' | 'native' | null): void;
1061
+ declare function getEffectiveIsWeb(): boolean;
1062
+ /**
1063
+ * Convert an arbitrary-bracket value to a native-friendly number when possible.
1064
+ * e.g. '10px' → 10, '1rem' → 16, '50%' → '50%' (keep as string), '#fff' → '#fff'
1065
+ */
1066
+ declare function toNativeValue(raw: string): string | number;
1067
+ /**
1068
+ * Escape a class name for use inside a CSS selector.
1069
+ * e.g. 'bg-[#fff]' → 'bg-\\[\\#fff\\]'
1070
+ */
1071
+ declare function escapeCSSSelector(cls: string): string;
1072
+
1073
+ /**
1074
+ * Styled console.warn for browser/runtime code. Uses the `%c` CSS-styling
1075
+ * console format (supported by Chrome, Firefox, Safari, and Edge DevTools)
1076
+ * so Kbach's own warnings are visually distinct from the surrounding noise —
1077
+ * a colored "[kbach]" tag followed by a short, plain message.
1078
+ *
1079
+ * Kept deliberately terse at call sites: one sentence, no walls of text.
1080
+ */
1081
+ declare function kbachWarn(message: string): void;
1082
+
1083
+ declare function parseClass(className: string): ParsedClass | null;
1084
+ /**
1085
+ * Split a class string into tokens. Whitespace at bracket depth > 0 is STRIPPED
1086
+ * (not just skipped) so that arbitrary values like rgb(41, 172, 15) become valid
1087
+ * CSS class name tokens: bg-[rgb(41,172,15)].
1088
+ */
1089
+ declare function splitClassTokens(classString: string): string[];
1090
+ /**
1091
+ * Normalize a full class string so it is safe to use as an HTML className value.
1092
+ * Strips spaces inside brackets: "bg-[rgb(41, 172, 15)] p-4" → "bg-[rgb(41,172,15)] p-4"
1093
+ */
1094
+ declare function normalizeClassString(classString: string): string;
1095
+ /** Parse a space-separated class string into individual ParsedClass objects. */
1096
+ declare function parseClasses(classString: string): ParsedClass[];
1097
+
1098
+ declare function resolveColor(value: string, colors: ThemeColors, isArbitrary: boolean): string | null;
1099
+ /**
1100
+ * Parse a hex color string (#rgb, #rgba, #rrggbb, #rrggbbaa) into an [r, g, b]
1101
+ * tuple. Any alpha nibble/byte is ignored — callers apply their own opacity.
1102
+ * Shared with useColors.ts's applyOpacity() so hex parsing lives in one place.
1103
+ */
1104
+ declare function parseHexRgb(hex: string): [number, number, number] | null;
1105
+
1106
+ declare function resolveSpacing(value: string, negative: boolean, spacing: ThemeConfig['spacing'], isArbitrary: boolean): string | number | null;
1107
+ declare function resolveSizing(value: string, spacing: ThemeConfig['spacing'], isArbitrary: boolean): string | number | null;
1108
+
1109
+ declare function resolveUtility(parsed: ParsedClass, theme: ThemeConfig): StyleValue | null;
1110
+ /**
1111
+ * Returns true if the utility name is known to the framework (built-in or plugin).
1112
+ * Used for dev-mode warnings — resolveUtility returning null could mean either
1113
+ * "intentionally null on this platform" or "completely unknown utility name".
1114
+ * This check covers the second case.
1115
+ */
1116
+ declare function isKnownUtility(utility: string): boolean;
1117
+ /**
1118
+ * Sorted (longest-first) unique list of all built-in + plugin utility prefixes.
1119
+ * Used by parser.ts for greedy prefix matching — replaces the hard-coded
1120
+ * UTILITY_PREFIXES array that had to be kept in sync manually.
1121
+ */
1122
+ declare function getBuiltinUtilityPrefixes(): readonly string[];
1123
+ /**
1124
+ * Set of all built-in + plugin standalone utility names.
1125
+ * Used by parser.ts to recognise no-value tokens — replaces the hard-coded
1126
+ * STANDALONE_UTILITIES set that had to be kept in sync manually.
1127
+ */
1128
+ declare function getBuiltinStandaloneNames(): ReadonlySet<string>;
1129
+
1130
+ declare function setDefaultFontFamily(font: string | undefined): void;
1131
+ declare function getDefaultFontFamily(): string | undefined;
1132
+ declare function disableRuntimeCSS(): void;
1133
+ declare function isRuntimeCSSDisabled(): boolean;
1134
+ declare function generateClassCSS(classString: string, theme: ThemeConfig, darkMode?: 'attribute' | 'class' | 'media', screens?: Record<string, number>): string;
1135
+ /**
1136
+ * Resolve a class string to a ResolvedStyle object.
1137
+ *
1138
+ * Results are cached per (theme, classString, darkMode) — repeated calls with
1139
+ * the same arguments are O(1). Different theme objects each get their own
1140
+ * cache so concurrent ThemeProviders with different configs are always correct.
1141
+ */
1142
+ declare function resolve(classString: string, theme: ThemeConfig, darkMode?: 'attribute' | 'class' | 'media'): ResolvedStyle;
1143
+ /**
1144
+ * Flatten a ResolvedStyle into a single StyleValue for the current runtime state.
1145
+ * Used by useStyles() and styled().
1146
+ *
1147
+ * The sort step is memoized per resolved object reference (#6) — when resolve()
1148
+ * returns a cached object, getSortedEntries() is O(1) on all subsequent calls.
1149
+ */
1150
+ declare function flatten(resolved: ResolvedStyle, isDark: boolean, state?: {
1151
+ hover?: boolean;
1152
+ focus?: boolean;
1153
+ pressed?: boolean;
1154
+ active?: boolean;
1155
+ disabled?: boolean;
1156
+ checked?: boolean;
1157
+ visited?: boolean;
1158
+ placeholder?: boolean;
1159
+ }, breakpoints?: Set<string>): StyleValue;
1160
+ /**
1161
+ * Clear CSS injection state so stale rules are re-injected when the theme changes.
1162
+ *
1163
+ * The per-theme style cache (WeakMap) does not need to be cleared manually:
1164
+ * updateConfig() creates a new theme object, making the old cache entry
1165
+ * automatically unreachable for GC.
1166
+ */
1167
+ declare function clearCache(): void;
1168
+
1169
+ /**
1170
+ * Load, merge, and cache the resolved config.
1171
+ * Call resetConfig() to force a reload (e.g. in tests or after live update).
1172
+ */
1173
+ declare function getConfig(): ResolvedConfig;
1174
+ declare function resetConfig(): void;
1175
+ declare function buildConfig(userConfig: FrameworkConfig): ResolvedConfig;
1176
+ type ConfigListener = (config: ResolvedConfig) => void;
1177
+ declare function onConfigChange(listener: ConfigListener): () => void;
1178
+ declare function updateConfig(userConfig: FrameworkConfig): void;
1179
+ /**
1180
+ * Like updateConfig, but only calls it when the config object reference has
1181
+ * actually changed. Used by the Babel-injected IIFE so that:
1182
+ * - multiple files with kbach classes don't re-run the update on every load
1183
+ * - Fast Refresh DOES re-run when kbach.config.js changes (new module → new object)
1184
+ */
1185
+ declare function initConfig(userConfig: FrameworkConfig): void;
1186
+ /**
1187
+ * Custom variants registered via plugins (modifier name → CSS selector template).
1188
+ * A direct reference to configStore.customVariants rather than a copy — the
1189
+ * object itself is only ever mutated in place (keys added in addVariant()
1190
+ * above, cleared in buildConfig()), never reassigned, so this binding always
1191
+ * reflects the current set.
1192
+ */
1193
+ declare const customVariants: Record<string, string>;
1194
+
1195
+ /**
1196
+ * Module-level dark-mode singleton.
1197
+ *
1198
+ * This intentionally lives outside React so the custom JSX runtime can read it
1199
+ * synchronously during render without needing context. ThemeProvider writes to it;
1200
+ * DarkWrapper / InteractiveWrapper subscribe via useSyncExternalStore.
1201
+ *
1202
+ * Used to be backed by globalThis instead of a plain module-level variable:
1203
+ * tsup used to bundle core/ separately into each of dist/index.js and
1204
+ * dist/jsx-runtime.js (esbuild doesn't support code-splitting CJS output),
1205
+ * so Metro loading each by path got independent copies of this module with
1206
+ * independent top-level state. core/ is now built as its own dist/core/
1207
+ * entry and required externally by both (see packages/react/tsup.config.ts),
1208
+ * so there's only ever one real instance of this module to begin with — a
1209
+ * plain module-level object is enough.
1210
+ */
1211
+ /**
1212
+ * Silently update isDark without notifying subscribers.
1213
+ * Safe to call during React's render phase — no state side-effects.
1214
+ * ThemeProvider calls this before returning JSX so the JSX runtime and
1215
+ * children that call getGlobalDarkMode() during the same render pass
1216
+ * already see the correct value.
1217
+ */
1218
+ declare function syncGlobalDarkMode(isDark: boolean): void;
1219
+ /**
1220
+ * Update isDark and notify all subscribers.
1221
+ * Called by ThemeProvider in a layout effect (after commit) so DarkWrapper /
1222
+ * InteractiveWrapper consumers re-render with the updated dark-mode value.
1223
+ * Notifications are skipped when the value hasn't changed since the last
1224
+ * broadcast to avoid spurious re-renders — see the notifiedIsDark comment
1225
+ * above for why that comparison can't use `isDark` itself.
1226
+ */
1227
+ declare function setGlobalDarkMode(isDark: boolean): void;
1228
+ /** Read current dark-mode state synchronously (safe in render, no hook needed). */
1229
+ declare function getGlobalDarkMode(): boolean;
1230
+ /**
1231
+ * Subscribe to dark-mode changes.
1232
+ * @returns Cleanup function — call it to unsubscribe (no leak).
1233
+ */
1234
+ declare function subscribeGlobalDarkMode(callback: () => void): () => void;
1235
+
1236
+ /**
1237
+ * Global responsive width store.
1238
+ *
1239
+ * Used to be backed by globalThis so all CJS bundle splits (index.js,
1240
+ * jsx-runtime.js, jsx-dev-runtime.js) shared one instance — tsup used to
1241
+ * bundle core/ separately into each of them (esbuild doesn't support
1242
+ * code-splitting CJS output). core/ is now built as its own dist/core/
1243
+ * entry and required externally by all three (see
1244
+ * packages/react/tsup.config.ts), so there's only ever one real instance of
1245
+ * this module to begin with — a plain module-level object is enough.
1246
+ */
1247
+ type WidthListener = () => void;
1248
+ /** Synchronous write for use in the render phase. */
1249
+ declare function syncGlobalWidth(width: number): void;
1250
+ /** Update the breakpoint-name → min-width map from the resolved theme config. */
1251
+ declare function syncGlobalScreens(screens: Record<string, number>): void;
1252
+ declare function getGlobalScreens(): Record<string, number>;
1253
+ /**
1254
+ * Async write — fires listeners so subscribers re-render. Skip check uses
1255
+ * notifiedWidth, not width — see the ResponsiveStore.notifiedWidth comment.
1256
+ */
1257
+ declare function setGlobalWidth(width: number): void;
1258
+ declare function getGlobalWidth(): number;
1259
+ declare function subscribeGlobalWidth(listener: WidthListener): () => void;
1260
+ /**
1261
+ * Returns the Set of breakpoint names that are currently active
1262
+ * (i.e. width >= their min-width threshold).
1263
+ *
1264
+ * `screens` defaults to the global store's screens map (the common case —
1265
+ * DarkWrapper/InteractiveWrapper have no per-tree config available). Pass an
1266
+ * explicit map to check against a LOCAL config instead — e.g. useBreakpoint()/
1267
+ * useResponsive() pass the nearest <ThemeProvider>'s own `config.theme.screens`
1268
+ * so they stay correct per-provider rather than silently reading whichever
1269
+ * config the global store happens to hold (see ThemeProvider's per-tree
1270
+ * config-override limitation).
1271
+ */
1272
+ declare function getActiveBreakpoints(width?: number, screens?: Record<string, number>): Set<string>;
1273
+
1274
+ export { BASE_RESET, type ColorShades, type DarkMode, type DefaultColorName, type DefaultSpacingKey, type FrameworkConfig, LRUCache, type ParsedClass, type Platform, type PluginAPI, RESET_STYLE_ID, type ResolvedConfig, type ResolvedStyle, type StyleValue, type ThemeColors, type ThemeConfig, type ThemeMode, type ThemeSpacing, buildConfig, clearCache, clearPluginModifiers, customVariants, defaultColors, defaultTheme, disableRuntimeCSS, escapeCSSSelector, flatten, generateClassCSS, getActiveBreakpoints, getAllModifierNames, getBuiltinStandaloneNames, getBuiltinUtilityPrefixes, getConfig, getDefaultFontFamily, getEffectiveIsWeb, getGlobalDarkMode, getGlobalScreens, getGlobalWidth, getInteractiveModifiers, getModeModifiers, getModifier, getResponsiveModifiers, initConfig, isKnownModifier, isKnownUtility, isNative, isRuntimeCSSDisabled, isWeb, kbachWarn, matchModifier, normalizeClassString, onConfigChange, parseClass, parseClasses, parseHexRgb, registerModifier, resetConfig, resolve, resolveColor, resolveSizing, resolveSpacing, resolveUtility, setDefaultFontFamily, setGlobalDarkMode, setGlobalWidth, setResolveTarget, splitClassTokens, subscribeGlobalDarkMode, subscribeGlobalWidth, syncGlobalDarkMode, syncGlobalScreens, syncGlobalWidth, toNativeValue, updateConfig };