@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,13 +1,13 @@
1
+ 'use client';
1
2
  import {
2
3
  Fragment,
3
4
  _invalidateDefaultFontCache,
4
5
  jsx,
5
6
  jsxs
6
- } from "./chunk-AAAI37Y4.mjs";
7
+ } from "./chunk-NWW57Q5Q.mjs";
7
8
  import {
8
9
  registerWebElement
9
- } from "./chunk-D4LJICWZ.mjs";
10
- import "./chunk-6NED62DB.mjs";
10
+ } from "./chunk-GRZ6MVIL.mjs";
11
11
  export {
12
12
  Fragment,
13
13
  _invalidateDefaultFontCache,
@@ -1,5 +1,106 @@
1
1
  import { Plugin } from 'vite';
2
- import { F as FrameworkConfig } from './types-BESBQANS.mjs';
2
+
3
+ /**
4
+ * Unified modifier registry — single source of truth for ALL modifier behavior.
5
+ *
6
+ * Adding a new modifier requires editing ONLY this file:
7
+ * 1. Add an entry to BUILTIN_MODIFIERS with its CSS and JS behavior.
8
+ * 2. Done — parser, resolver, CSS generator, and JSX runtime all derive
9
+ * their behavior from this data automatically.
10
+ *
11
+ * Plugin authors can register custom modifiers via registerModifier().
12
+ */
13
+ interface ModifierDef {
14
+ /** CSS pseudo-class or pseudo-element appended to the selector (e.g. ':hover', '::before') */
15
+ pseudo?: string;
16
+ /** Ancestor selector prefix INCLUDING trailing space (e.g. '.group:hover ', '.peer:focus ~ ') */
17
+ ancestorSelector?: string;
18
+ /** Directionality attribute selector prefix INCLUDING trailing space (e.g. '[dir="rtl"] ') */
19
+ dirSelector?: string;
20
+ /** @media query body WITHOUT the '@media ' prefix (e.g. 'print', '(orientation: landscape)') */
21
+ mediaQuery?: string;
22
+ /** Dark/light mode scheme — triggers the configured darkMode strategy in CSS output */
23
+ darkScheme?: 'dark' | 'light';
24
+ /** True for responsive modifiers — wraps in @media (min-width: theme.screens[name]) */
25
+ isResponsive?: boolean;
26
+ /**
27
+ * Forces !important on all declarations in the generated CSS rule.
28
+ * Applied automatically for structural / ancestor / media modifiers that must
29
+ * win over base inline styles.
30
+ */
31
+ forcesImportant?: boolean;
32
+ /**
33
+ * How the JSX runtime routes this modifier:
34
+ * 'interactive' — managed by InteractiveWrapper (hover, focus, pressed, …)
35
+ * 'mode' — managed by DarkWrapper (dark, light, not-dark, …)
36
+ * 'responsive' — managed by DarkWrapper (sm, md, lg, xl, 2xl)
37
+ * 'css-only' — CSS injection only; matchModifier always returns false
38
+ */
39
+ jsBehavior: 'interactive' | 'mode' | 'responsive' | 'css-only';
40
+ /**
41
+ * Evaluates whether this modifier's condition is met at runtime.
42
+ * Omit for 'css-only' modifiers — they never apply as inline styles.
43
+ */
44
+ jsMatch?: (isDark: boolean, state: Record<string, boolean | undefined>, breakpoints: Set<string>) => boolean;
45
+ }
46
+
47
+ interface StyleValue {
48
+ [key: string]: string | number | undefined | null | StyleValue | StyleValue[];
49
+ }
50
+ type ColorShades = Record<string, string>;
51
+ type ThemeColors = Record<string, string | ColorShades>;
52
+ type ThemeSpacing = Record<string, number | string>;
53
+ interface ThemeConfig {
54
+ colors: ThemeColors;
55
+ spacing: ThemeSpacing;
56
+ fontSize: Record<string, number | string>;
57
+ fontFamily: Record<string, string | string[]>;
58
+ fontWeight: Record<string, string | number>;
59
+ borderRadius: Record<string, number | string>;
60
+ borderWidth: Record<string, number>;
61
+ opacity: Record<string, number>;
62
+ lineHeight: Record<string, number | string>;
63
+ letterSpacing: Record<string, number | string>;
64
+ zIndex: Record<string, number | string>;
65
+ flex: Record<string, number | string>;
66
+ shadow: Record<string, StyleValue>;
67
+ screens: Record<string, string | number>;
68
+ [key: string]: unknown;
69
+ }
70
+ /**
71
+ * 'class' — toggles .dark class on <html>
72
+ * 'media' — uses prefers-color-scheme media query
73
+ * 'attribute' — uses data-theme="dark" attribute on <html>
74
+ */
75
+ type DarkMode = 'attribute' | 'class' | 'media';
76
+ interface PluginAPI {
77
+ addUtility(name: string, styles: StyleValue): void;
78
+ /**
79
+ * Register a custom variant.
80
+ *
81
+ * Pass a CSS selector string for simple cases — it is automatically
82
+ * converted into a ModifierDef that generates correct CSS rules:
83
+ * addVariant('hocus', ':hover, :focus') // pseudo
84
+ * addVariant('supports-grid', '@media (display: grid)') // media
85
+ * addVariant('dark-green', '.dark-green') // ancestor selector
86
+ *
87
+ * Pass a full ModifierDef object for advanced control (e.g. JS-trackable
88
+ * interactive variants with custom jsMatch logic).
89
+ */
90
+ addVariant(name: string, selectorOrDef: string | ModifierDef): void;
91
+ theme(path: string, defaultValue?: unknown): unknown;
92
+ e(className: string): string;
93
+ }
94
+ interface FrameworkConfig {
95
+ darkMode?: DarkMode;
96
+ theme?: Partial<ThemeConfig>;
97
+ /** Additive theme extension — accepts either `extend.theme.X` or `extend.X` directly. */
98
+ extend?: {
99
+ theme?: Partial<ThemeConfig>;
100
+ } & Partial<ThemeConfig>;
101
+ plugins?: Array<(api: PluginAPI) => void>;
102
+ content?: string[];
103
+ }
3
104
 
4
105
  interface KbachPluginOptions {
5
106
  framework?: FrameworkConfig;
@@ -1,5 +1,106 @@
1
1
  import { Plugin } from 'vite';
2
- import { F as FrameworkConfig } from './types-BESBQANS.js';
2
+
3
+ /**
4
+ * Unified modifier registry — single source of truth for ALL modifier behavior.
5
+ *
6
+ * Adding a new modifier requires editing ONLY this file:
7
+ * 1. Add an entry to BUILTIN_MODIFIERS with its CSS and JS behavior.
8
+ * 2. Done — parser, resolver, CSS generator, and JSX runtime all derive
9
+ * their behavior from this data automatically.
10
+ *
11
+ * Plugin authors can register custom modifiers via registerModifier().
12
+ */
13
+ interface ModifierDef {
14
+ /** CSS pseudo-class or pseudo-element appended to the selector (e.g. ':hover', '::before') */
15
+ pseudo?: string;
16
+ /** Ancestor selector prefix INCLUDING trailing space (e.g. '.group:hover ', '.peer:focus ~ ') */
17
+ ancestorSelector?: string;
18
+ /** Directionality attribute selector prefix INCLUDING trailing space (e.g. '[dir="rtl"] ') */
19
+ dirSelector?: string;
20
+ /** @media query body WITHOUT the '@media ' prefix (e.g. 'print', '(orientation: landscape)') */
21
+ mediaQuery?: string;
22
+ /** Dark/light mode scheme — triggers the configured darkMode strategy in CSS output */
23
+ darkScheme?: 'dark' | 'light';
24
+ /** True for responsive modifiers — wraps in @media (min-width: theme.screens[name]) */
25
+ isResponsive?: boolean;
26
+ /**
27
+ * Forces !important on all declarations in the generated CSS rule.
28
+ * Applied automatically for structural / ancestor / media modifiers that must
29
+ * win over base inline styles.
30
+ */
31
+ forcesImportant?: boolean;
32
+ /**
33
+ * How the JSX runtime routes this modifier:
34
+ * 'interactive' — managed by InteractiveWrapper (hover, focus, pressed, …)
35
+ * 'mode' — managed by DarkWrapper (dark, light, not-dark, …)
36
+ * 'responsive' — managed by DarkWrapper (sm, md, lg, xl, 2xl)
37
+ * 'css-only' — CSS injection only; matchModifier always returns false
38
+ */
39
+ jsBehavior: 'interactive' | 'mode' | 'responsive' | 'css-only';
40
+ /**
41
+ * Evaluates whether this modifier's condition is met at runtime.
42
+ * Omit for 'css-only' modifiers — they never apply as inline styles.
43
+ */
44
+ jsMatch?: (isDark: boolean, state: Record<string, boolean | undefined>, breakpoints: Set<string>) => boolean;
45
+ }
46
+
47
+ interface StyleValue {
48
+ [key: string]: string | number | undefined | null | StyleValue | StyleValue[];
49
+ }
50
+ type ColorShades = Record<string, string>;
51
+ type ThemeColors = Record<string, string | ColorShades>;
52
+ type ThemeSpacing = Record<string, number | string>;
53
+ interface ThemeConfig {
54
+ colors: ThemeColors;
55
+ spacing: ThemeSpacing;
56
+ fontSize: Record<string, number | string>;
57
+ fontFamily: Record<string, string | string[]>;
58
+ fontWeight: Record<string, string | number>;
59
+ borderRadius: Record<string, number | string>;
60
+ borderWidth: Record<string, number>;
61
+ opacity: Record<string, number>;
62
+ lineHeight: Record<string, number | string>;
63
+ letterSpacing: Record<string, number | string>;
64
+ zIndex: Record<string, number | string>;
65
+ flex: Record<string, number | string>;
66
+ shadow: Record<string, StyleValue>;
67
+ screens: Record<string, string | number>;
68
+ [key: string]: unknown;
69
+ }
70
+ /**
71
+ * 'class' — toggles .dark class on <html>
72
+ * 'media' — uses prefers-color-scheme media query
73
+ * 'attribute' — uses data-theme="dark" attribute on <html>
74
+ */
75
+ type DarkMode = 'attribute' | 'class' | 'media';
76
+ interface PluginAPI {
77
+ addUtility(name: string, styles: StyleValue): void;
78
+ /**
79
+ * Register a custom variant.
80
+ *
81
+ * Pass a CSS selector string for simple cases — it is automatically
82
+ * converted into a ModifierDef that generates correct CSS rules:
83
+ * addVariant('hocus', ':hover, :focus') // pseudo
84
+ * addVariant('supports-grid', '@media (display: grid)') // media
85
+ * addVariant('dark-green', '.dark-green') // ancestor selector
86
+ *
87
+ * Pass a full ModifierDef object for advanced control (e.g. JS-trackable
88
+ * interactive variants with custom jsMatch logic).
89
+ */
90
+ addVariant(name: string, selectorOrDef: string | ModifierDef): void;
91
+ theme(path: string, defaultValue?: unknown): unknown;
92
+ e(className: string): string;
93
+ }
94
+ interface FrameworkConfig {
95
+ darkMode?: DarkMode;
96
+ theme?: Partial<ThemeConfig>;
97
+ /** Additive theme extension — accepts either `extend.theme.X` or `extend.X` directly. */
98
+ extend?: {
99
+ theme?: Partial<ThemeConfig>;
100
+ } & Partial<ThemeConfig>;
101
+ plugins?: Array<(api: PluginAPI) => void>;
102
+ content?: string[];
103
+ }
3
104
 
4
105
  interface KbachPluginOptions {
5
106
  framework?: FrameworkConfig;