@kbach/react 0.6.0 → 0.6.2

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.
@@ -1,131 +0,0 @@
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
-
45
- type ThemeMode = 'light' | 'dark' | 'system';
46
- interface StyleValue {
47
- [key: string]: string | number | undefined | null | StyleValue | StyleValue[];
48
- }
49
- interface ParsedClass {
50
- /** The original class string, e.g. "dark:hover:bg-[#fff]" */
51
- original: string;
52
- /** Up to 3 modifier prefixes, e.g. ['dark', 'hover'] */
53
- modifiers: string[];
54
- /** Whether a leading `-` was present for negative values */
55
- negative: boolean;
56
- /** Whether a leading `!` was present — applies !important to all CSS declarations */
57
- important: boolean;
58
- /** The utility name, e.g. 'bg', 'p', 'text' */
59
- utility: string;
60
- /** The resolved value, e.g. 'white', '#fff', '4' */
61
- value: string;
62
- /** Whether the value was specified with bracket notation [value] */
63
- isArbitrary: boolean;
64
- }
65
- interface ResolvedStyle {
66
- /** Base styles applied unconditionally */
67
- base?: StyleValue;
68
- /** Styles keyed by modifier or modifier combo, e.g. 'dark', 'hover', 'dark:hover' */
69
- [modifierKey: string]: StyleValue | undefined;
70
- }
71
- type ColorShades = Record<string, string>;
72
- type ThemeColors = Record<string, string | ColorShades>;
73
- type ThemeSpacing = Record<string, number | string>;
74
- interface ThemeConfig {
75
- colors: ThemeColors;
76
- spacing: ThemeSpacing;
77
- fontSize: Record<string, number | string>;
78
- fontFamily: Record<string, string | string[]>;
79
- fontWeight: Record<string, string | number>;
80
- borderRadius: Record<string, number | string>;
81
- borderWidth: Record<string, number>;
82
- opacity: Record<string, number>;
83
- lineHeight: Record<string, number | string>;
84
- letterSpacing: Record<string, number | string>;
85
- zIndex: Record<string, number | string>;
86
- flex: Record<string, number | string>;
87
- shadow: Record<string, StyleValue>;
88
- screens: Record<string, string | number>;
89
- [key: string]: unknown;
90
- }
91
- /**
92
- * 'class' — toggles .dark class on <html>
93
- * 'media' — uses prefers-color-scheme media query
94
- * 'attribute' — uses data-theme="dark" attribute on <html>
95
- */
96
- type DarkMode = 'attribute' | 'class' | 'media';
97
- interface PluginAPI {
98
- addUtility(name: string, styles: StyleValue): void;
99
- /**
100
- * Register a custom variant.
101
- *
102
- * Pass a CSS selector string for simple cases — it is automatically
103
- * converted into a ModifierDef that generates correct CSS rules:
104
- * addVariant('hocus', ':hover, :focus') // pseudo
105
- * addVariant('supports-grid', '@media (display: grid)') // media
106
- * addVariant('dark-green', '.dark-green') // ancestor selector
107
- *
108
- * Pass a full ModifierDef object for advanced control (e.g. JS-trackable
109
- * interactive variants with custom jsMatch logic).
110
- */
111
- addVariant(name: string, selectorOrDef: string | ModifierDef): void;
112
- theme(path: string, defaultValue?: unknown): unknown;
113
- e(className: string): string;
114
- }
115
- interface FrameworkConfig {
116
- darkMode?: DarkMode;
117
- theme?: Partial<ThemeConfig>;
118
- /** Additive theme extension — accepts either `extend.theme.X` or `extend.X` directly. */
119
- extend?: {
120
- theme?: Partial<ThemeConfig>;
121
- } & Partial<ThemeConfig>;
122
- plugins?: Array<(api: PluginAPI) => void>;
123
- content?: string[];
124
- }
125
- interface ResolvedConfig {
126
- darkMode: DarkMode;
127
- theme: ThemeConfig;
128
- plugins: Array<(api: PluginAPI) => void>;
129
- }
130
-
131
- export type { FrameworkConfig as F, ParsedClass as P, ResolvedStyle as R, StyleValue as S, ThemeColors as T, ThemeConfig as a, ResolvedConfig as b, ThemeMode as c, PluginAPI as d };
@@ -1,131 +0,0 @@
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
-
45
- type ThemeMode = 'light' | 'dark' | 'system';
46
- interface StyleValue {
47
- [key: string]: string | number | undefined | null | StyleValue | StyleValue[];
48
- }
49
- interface ParsedClass {
50
- /** The original class string, e.g. "dark:hover:bg-[#fff]" */
51
- original: string;
52
- /** Up to 3 modifier prefixes, e.g. ['dark', 'hover'] */
53
- modifiers: string[];
54
- /** Whether a leading `-` was present for negative values */
55
- negative: boolean;
56
- /** Whether a leading `!` was present — applies !important to all CSS declarations */
57
- important: boolean;
58
- /** The utility name, e.g. 'bg', 'p', 'text' */
59
- utility: string;
60
- /** The resolved value, e.g. 'white', '#fff', '4' */
61
- value: string;
62
- /** Whether the value was specified with bracket notation [value] */
63
- isArbitrary: boolean;
64
- }
65
- interface ResolvedStyle {
66
- /** Base styles applied unconditionally */
67
- base?: StyleValue;
68
- /** Styles keyed by modifier or modifier combo, e.g. 'dark', 'hover', 'dark:hover' */
69
- [modifierKey: string]: StyleValue | undefined;
70
- }
71
- type ColorShades = Record<string, string>;
72
- type ThemeColors = Record<string, string | ColorShades>;
73
- type ThemeSpacing = Record<string, number | string>;
74
- interface ThemeConfig {
75
- colors: ThemeColors;
76
- spacing: ThemeSpacing;
77
- fontSize: Record<string, number | string>;
78
- fontFamily: Record<string, string | string[]>;
79
- fontWeight: Record<string, string | number>;
80
- borderRadius: Record<string, number | string>;
81
- borderWidth: Record<string, number>;
82
- opacity: Record<string, number>;
83
- lineHeight: Record<string, number | string>;
84
- letterSpacing: Record<string, number | string>;
85
- zIndex: Record<string, number | string>;
86
- flex: Record<string, number | string>;
87
- shadow: Record<string, StyleValue>;
88
- screens: Record<string, string | number>;
89
- [key: string]: unknown;
90
- }
91
- /**
92
- * 'class' — toggles .dark class on <html>
93
- * 'media' — uses prefers-color-scheme media query
94
- * 'attribute' — uses data-theme="dark" attribute on <html>
95
- */
96
- type DarkMode = 'attribute' | 'class' | 'media';
97
- interface PluginAPI {
98
- addUtility(name: string, styles: StyleValue): void;
99
- /**
100
- * Register a custom variant.
101
- *
102
- * Pass a CSS selector string for simple cases — it is automatically
103
- * converted into a ModifierDef that generates correct CSS rules:
104
- * addVariant('hocus', ':hover, :focus') // pseudo
105
- * addVariant('supports-grid', '@media (display: grid)') // media
106
- * addVariant('dark-green', '.dark-green') // ancestor selector
107
- *
108
- * Pass a full ModifierDef object for advanced control (e.g. JS-trackable
109
- * interactive variants with custom jsMatch logic).
110
- */
111
- addVariant(name: string, selectorOrDef: string | ModifierDef): void;
112
- theme(path: string, defaultValue?: unknown): unknown;
113
- e(className: string): string;
114
- }
115
- interface FrameworkConfig {
116
- darkMode?: DarkMode;
117
- theme?: Partial<ThemeConfig>;
118
- /** Additive theme extension — accepts either `extend.theme.X` or `extend.X` directly. */
119
- extend?: {
120
- theme?: Partial<ThemeConfig>;
121
- } & Partial<ThemeConfig>;
122
- plugins?: Array<(api: PluginAPI) => void>;
123
- content?: string[];
124
- }
125
- interface ResolvedConfig {
126
- darkMode: DarkMode;
127
- theme: ThemeConfig;
128
- plugins: Array<(api: PluginAPI) => void>;
129
- }
130
-
131
- export type { FrameworkConfig as F, ParsedClass as P, ResolvedStyle as R, StyleValue as S, ThemeColors as T, ThemeConfig as a, ResolvedConfig as b, ThemeMode as c, PluginAPI as d };