@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.
- package/README.md +49 -0
- package/dist/{chunk-6NED62DB.mjs → chunk-GRZ6MVIL.mjs} +659 -179
- package/dist/{chunk-AAAI37Y4.mjs → chunk-NWW57Q5Q.mjs} +12 -71
- package/dist/index.d.mts +142 -3
- package/dist/index.d.ts +142 -3
- package/dist/index.js +345 -395
- package/dist/index.mjs +69 -98
- package/dist/jsx-dev-runtime.js +205 -289
- package/dist/jsx-dev-runtime.mjs +4 -4
- package/dist/jsx-runtime.js +204 -288
- package/dist/jsx-runtime.mjs +3 -3
- package/dist/vite-plugin.d.mts +102 -1
- package/dist/vite-plugin.d.ts +102 -1
- package/dist/vite-plugin.js +139 -163
- package/dist/vite-plugin.mjs +2883 -12
- package/jsx-dev-runtime.js +1 -0
- package/jsx-runtime.js +1 -0
- package/kbach-react.md +7 -0
- package/package.json +3 -3
- package/dist/chunk-D4LJICWZ.mjs +0 -524
- package/dist/types-BESBQANS.d.mts +0 -131
- package/dist/types-BESBQANS.d.ts +0 -131
|
@@ -1,13 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import {
|
|
2
3
|
EMPTY_BREAKPOINTS,
|
|
3
4
|
InteractiveWrapper,
|
|
4
|
-
getWebTag,
|
|
5
|
-
hasResponsiveBuckets,
|
|
6
|
-
transformToWebProps,
|
|
7
|
-
useConditionalWidth,
|
|
8
|
-
useGlobalDarkMode
|
|
9
|
-
} from "./chunk-D4LJICWZ.mjs";
|
|
10
|
-
import {
|
|
11
5
|
flatten,
|
|
12
6
|
getActiveBreakpoints,
|
|
13
7
|
getConfig,
|
|
@@ -16,13 +10,20 @@ import {
|
|
|
16
10
|
getInteractiveModifiers,
|
|
17
11
|
getModeModifiers,
|
|
18
12
|
getResponsiveModifiers,
|
|
13
|
+
getWebTag,
|
|
14
|
+
hasResponsiveBuckets,
|
|
19
15
|
isNative,
|
|
20
16
|
isRuntimeCSSDisabled,
|
|
21
17
|
isWeb,
|
|
22
18
|
normalizeClassString,
|
|
23
19
|
onConfigChange,
|
|
24
|
-
resolve
|
|
25
|
-
|
|
20
|
+
resolve,
|
|
21
|
+
stripInternalMarkers,
|
|
22
|
+
stripWebOnlyProps,
|
|
23
|
+
transformToWebProps,
|
|
24
|
+
useConditionalWidth,
|
|
25
|
+
useGlobalDarkMode
|
|
26
|
+
} from "./chunk-GRZ6MVIL.mjs";
|
|
26
27
|
|
|
27
28
|
// src/jsx-runtime.tsx
|
|
28
29
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -52,36 +53,6 @@ var DarkWrapper = React.forwardRef(
|
|
|
52
53
|
}
|
|
53
54
|
);
|
|
54
55
|
DarkWrapper.displayName = "Kbach.DarkWrapper";
|
|
55
|
-
function stripInternalMarkers(s) {
|
|
56
|
-
delete s.__divideX;
|
|
57
|
-
delete s.__divideY;
|
|
58
|
-
delete s.__divideColor;
|
|
59
|
-
delete s.__divideStyle;
|
|
60
|
-
delete s.__keyframe;
|
|
61
|
-
}
|
|
62
|
-
function stripWebOnlyProps(s) {
|
|
63
|
-
if (s.display === "grid" || s.display === "inline-grid") delete s.display;
|
|
64
|
-
delete s.gridTemplateColumns;
|
|
65
|
-
delete s.gridTemplateRows;
|
|
66
|
-
delete s.gridColumn;
|
|
67
|
-
delete s.gridRow;
|
|
68
|
-
delete s.gridArea;
|
|
69
|
-
delete s.gridColumnStart;
|
|
70
|
-
delete s.gridColumnEnd;
|
|
71
|
-
delete s.gridRowStart;
|
|
72
|
-
delete s.gridRowEnd;
|
|
73
|
-
delete s.gridAutoFlow;
|
|
74
|
-
delete s.gridAutoColumns;
|
|
75
|
-
delete s.gridAutoRows;
|
|
76
|
-
delete s.placeItems;
|
|
77
|
-
delete s.placeContent;
|
|
78
|
-
delete s.justifyItems;
|
|
79
|
-
delete s.placeSelf;
|
|
80
|
-
delete s.justifySelf;
|
|
81
|
-
if (s.position === "sticky" || s.position === "fixed" || s.position === "static") {
|
|
82
|
-
delete s.position;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
56
|
|
|
86
57
|
// src/jsx-runtime.tsx
|
|
87
58
|
var _cachedDefaultFont = void 0;
|
|
@@ -140,36 +111,6 @@ function mergeStyle(computed, userStyle) {
|
|
|
140
111
|
function makeElement(isStaticChildren, type, props, key) {
|
|
141
112
|
return (isStaticChildren ? _jsxs : _jsx)(type, props, key);
|
|
142
113
|
}
|
|
143
|
-
function stripInternalMarkers2(s) {
|
|
144
|
-
delete s.__divideX;
|
|
145
|
-
delete s.__divideY;
|
|
146
|
-
delete s.__divideColor;
|
|
147
|
-
delete s.__divideStyle;
|
|
148
|
-
delete s.__keyframe;
|
|
149
|
-
}
|
|
150
|
-
function stripWebOnlyInlineProps(s) {
|
|
151
|
-
if (s.display === "grid" || s.display === "inline-grid") delete s.display;
|
|
152
|
-
delete s.gridTemplateColumns;
|
|
153
|
-
delete s.gridTemplateRows;
|
|
154
|
-
delete s.gridColumn;
|
|
155
|
-
delete s.gridRow;
|
|
156
|
-
delete s.gridArea;
|
|
157
|
-
delete s.gridColumnStart;
|
|
158
|
-
delete s.gridColumnEnd;
|
|
159
|
-
delete s.gridRowStart;
|
|
160
|
-
delete s.gridRowEnd;
|
|
161
|
-
delete s.gridAutoFlow;
|
|
162
|
-
delete s.gridAutoColumns;
|
|
163
|
-
delete s.gridAutoRows;
|
|
164
|
-
delete s.placeItems;
|
|
165
|
-
delete s.placeContent;
|
|
166
|
-
delete s.justifyItems;
|
|
167
|
-
delete s.placeSelf;
|
|
168
|
-
delete s.justifySelf;
|
|
169
|
-
if (s.position === "sticky" || s.position === "fixed" || s.position === "static") {
|
|
170
|
-
delete s.position;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
114
|
function processElement(type, rawProps, key, isStaticChildren) {
|
|
174
115
|
if (type === null || typeof type === "symbol") return makeElement(isStaticChildren, type, rawProps ?? {}, key);
|
|
175
116
|
const webTag = isWeb ? getWebTag(type, rawProps ?? void 0) : null;
|
|
@@ -229,8 +170,8 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
229
170
|
let finalStyle;
|
|
230
171
|
if (!skipComputedInline) {
|
|
231
172
|
const computedStyle = flatten(resolved, false);
|
|
232
|
-
|
|
233
|
-
if (typeof effectiveType !== "string")
|
|
173
|
+
stripInternalMarkers(computedStyle);
|
|
174
|
+
if (typeof effectiveType !== "string") stripWebOnlyProps(computedStyle);
|
|
234
175
|
finalStyle = mergeStyle(computedStyle, userStyle);
|
|
235
176
|
} else {
|
|
236
177
|
finalStyle = userStyle ?? void 0;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,142 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode, ComponentType, ForwardRefExoticComponent } from 'react';
|
|
3
|
-
import { T as ThemeColors, a as ThemeConfig, P as ParsedClass, R as ResolvedStyle, S as StyleValue, F as FrameworkConfig, b as ResolvedConfig, c as ThemeMode } from './types-BESBQANS.mjs';
|
|
4
|
-
export { d as PluginAPI } from './types-BESBQANS.mjs';
|
|
5
3
|
export { r as registerWebElement } from './web-substitute-CfpYFnE7.mjs';
|
|
6
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Unified modifier registry — single source of truth for ALL modifier behavior.
|
|
7
|
+
*
|
|
8
|
+
* Adding a new modifier requires editing ONLY this file:
|
|
9
|
+
* 1. Add an entry to BUILTIN_MODIFIERS with its CSS and JS behavior.
|
|
10
|
+
* 2. Done — parser, resolver, CSS generator, and JSX runtime all derive
|
|
11
|
+
* their behavior from this data automatically.
|
|
12
|
+
*
|
|
13
|
+
* Plugin authors can register custom modifiers via registerModifier().
|
|
14
|
+
*/
|
|
15
|
+
interface ModifierDef {
|
|
16
|
+
/** CSS pseudo-class or pseudo-element appended to the selector (e.g. ':hover', '::before') */
|
|
17
|
+
pseudo?: string;
|
|
18
|
+
/** Ancestor selector prefix INCLUDING trailing space (e.g. '.group:hover ', '.peer:focus ~ ') */
|
|
19
|
+
ancestorSelector?: string;
|
|
20
|
+
/** Directionality attribute selector prefix INCLUDING trailing space (e.g. '[dir="rtl"] ') */
|
|
21
|
+
dirSelector?: string;
|
|
22
|
+
/** @media query body WITHOUT the '@media ' prefix (e.g. 'print', '(orientation: landscape)') */
|
|
23
|
+
mediaQuery?: string;
|
|
24
|
+
/** Dark/light mode scheme — triggers the configured darkMode strategy in CSS output */
|
|
25
|
+
darkScheme?: 'dark' | 'light';
|
|
26
|
+
/** True for responsive modifiers — wraps in @media (min-width: theme.screens[name]) */
|
|
27
|
+
isResponsive?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Forces !important on all declarations in the generated CSS rule.
|
|
30
|
+
* Applied automatically for structural / ancestor / media modifiers that must
|
|
31
|
+
* win over base inline styles.
|
|
32
|
+
*/
|
|
33
|
+
forcesImportant?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* How the JSX runtime routes this modifier:
|
|
36
|
+
* 'interactive' — managed by InteractiveWrapper (hover, focus, pressed, …)
|
|
37
|
+
* 'mode' — managed by DarkWrapper (dark, light, not-dark, …)
|
|
38
|
+
* 'responsive' — managed by DarkWrapper (sm, md, lg, xl, 2xl)
|
|
39
|
+
* 'css-only' — CSS injection only; matchModifier always returns false
|
|
40
|
+
*/
|
|
41
|
+
jsBehavior: 'interactive' | 'mode' | 'responsive' | 'css-only';
|
|
42
|
+
/**
|
|
43
|
+
* Evaluates whether this modifier's condition is met at runtime.
|
|
44
|
+
* Omit for 'css-only' modifiers — they never apply as inline styles.
|
|
45
|
+
*/
|
|
46
|
+
jsMatch?: (isDark: boolean, state: Record<string, boolean | undefined>, breakpoints: Set<string>) => boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type ThemeMode = 'light' | 'dark' | 'system';
|
|
50
|
+
interface StyleValue {
|
|
51
|
+
[key: string]: string | number | undefined | null | StyleValue | StyleValue[];
|
|
52
|
+
}
|
|
53
|
+
interface ParsedClass {
|
|
54
|
+
/** The original class string, e.g. "dark:hover:bg-[#fff]" */
|
|
55
|
+
original: string;
|
|
56
|
+
/** Up to 3 modifier prefixes, e.g. ['dark', 'hover'] */
|
|
57
|
+
modifiers: string[];
|
|
58
|
+
/** Whether a leading `-` was present for negative values */
|
|
59
|
+
negative: boolean;
|
|
60
|
+
/** Whether a leading `!` was present — applies !important to all CSS declarations */
|
|
61
|
+
important: boolean;
|
|
62
|
+
/** The utility name, e.g. 'bg', 'p', 'text' */
|
|
63
|
+
utility: string;
|
|
64
|
+
/** The resolved value, e.g. 'white', '#fff', '4' */
|
|
65
|
+
value: string;
|
|
66
|
+
/** Whether the value was specified with bracket notation [value] */
|
|
67
|
+
isArbitrary: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface ResolvedStyle {
|
|
70
|
+
/** Base styles applied unconditionally */
|
|
71
|
+
base?: StyleValue;
|
|
72
|
+
/** Styles keyed by modifier or modifier combo, e.g. 'dark', 'hover', 'dark:hover' */
|
|
73
|
+
[modifierKey: string]: StyleValue | undefined;
|
|
74
|
+
}
|
|
75
|
+
type ColorShades = Record<string, string>;
|
|
76
|
+
type ThemeColors = Record<string, string | ColorShades>;
|
|
77
|
+
type ThemeSpacing = Record<string, number | string>;
|
|
78
|
+
interface ThemeConfig {
|
|
79
|
+
colors: ThemeColors;
|
|
80
|
+
spacing: ThemeSpacing;
|
|
81
|
+
fontSize: Record<string, number | string>;
|
|
82
|
+
fontFamily: Record<string, string | string[]>;
|
|
83
|
+
fontWeight: Record<string, string | number>;
|
|
84
|
+
borderRadius: Record<string, number | string>;
|
|
85
|
+
borderWidth: Record<string, number>;
|
|
86
|
+
opacity: Record<string, number>;
|
|
87
|
+
lineHeight: Record<string, number | string>;
|
|
88
|
+
letterSpacing: Record<string, number | string>;
|
|
89
|
+
zIndex: Record<string, number | string>;
|
|
90
|
+
flex: Record<string, number | string>;
|
|
91
|
+
shadow: Record<string, StyleValue>;
|
|
92
|
+
screens: Record<string, string | number>;
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 'class' — toggles .dark class on <html>
|
|
97
|
+
* 'media' — uses prefers-color-scheme media query
|
|
98
|
+
* 'attribute' — uses data-theme="dark" attribute on <html>
|
|
99
|
+
*/
|
|
100
|
+
type DarkMode = 'attribute' | 'class' | 'media';
|
|
101
|
+
interface PluginAPI {
|
|
102
|
+
addUtility(name: string, styles: StyleValue): void;
|
|
103
|
+
/**
|
|
104
|
+
* Register a custom variant.
|
|
105
|
+
*
|
|
106
|
+
* Pass a CSS selector string for simple cases — it is automatically
|
|
107
|
+
* converted into a ModifierDef that generates correct CSS rules:
|
|
108
|
+
* addVariant('hocus', ':hover, :focus') // pseudo
|
|
109
|
+
* addVariant('supports-grid', '@media (display: grid)') // media
|
|
110
|
+
* addVariant('dark-green', '.dark-green') // ancestor selector
|
|
111
|
+
*
|
|
112
|
+
* Pass a full ModifierDef object for advanced control (e.g. JS-trackable
|
|
113
|
+
* interactive variants with custom jsMatch logic).
|
|
114
|
+
*/
|
|
115
|
+
addVariant(name: string, selectorOrDef: string | ModifierDef): void;
|
|
116
|
+
theme(path: string, defaultValue?: unknown): unknown;
|
|
117
|
+
e(className: string): string;
|
|
118
|
+
}
|
|
119
|
+
interface FrameworkConfig {
|
|
120
|
+
darkMode?: DarkMode;
|
|
121
|
+
theme?: Partial<ThemeConfig>;
|
|
122
|
+
/** Additive theme extension — accepts either `extend.theme.X` or `extend.X` directly. */
|
|
123
|
+
extend?: {
|
|
124
|
+
theme?: Partial<ThemeConfig>;
|
|
125
|
+
} & Partial<ThemeConfig>;
|
|
126
|
+
plugins?: Array<(api: PluginAPI) => void>;
|
|
127
|
+
content?: string[];
|
|
128
|
+
}
|
|
129
|
+
interface ResolvedConfig {
|
|
130
|
+
darkMode: DarkMode;
|
|
131
|
+
theme: ThemeConfig;
|
|
132
|
+
plugins: Array<(api: PluginAPI) => void>;
|
|
133
|
+
}
|
|
134
|
+
|
|
7
135
|
declare const defaultColors: ThemeColors;
|
|
8
136
|
declare const defaultTheme: ThemeConfig;
|
|
9
137
|
|
|
138
|
+
declare function setResolveTarget(target: 'web' | 'native' | null): void;
|
|
139
|
+
|
|
10
140
|
declare function parseClass(className: string): ParsedClass | null;
|
|
11
141
|
/**
|
|
12
142
|
* Split a class string into tokens. Whitespace at bracket depth > 0 is STRIPPED
|
|
@@ -48,6 +178,14 @@ declare function flatten(resolved: ResolvedStyle, isDark: boolean, state?: {
|
|
|
48
178
|
visited?: boolean;
|
|
49
179
|
placeholder?: boolean;
|
|
50
180
|
}, breakpoints?: Set<string>): StyleValue;
|
|
181
|
+
/**
|
|
182
|
+
* Clear CSS injection state so stale rules are re-injected when the theme changes.
|
|
183
|
+
*
|
|
184
|
+
* The per-theme style cache (WeakMap) does not need to be cleared manually:
|
|
185
|
+
* updateConfig() creates a new theme object, making the old cache entry
|
|
186
|
+
* automatically unreachable for GC.
|
|
187
|
+
*/
|
|
188
|
+
declare function clearCache(): void;
|
|
51
189
|
|
|
52
190
|
/**
|
|
53
191
|
* Load, merge, and cache the resolved config.
|
|
@@ -229,6 +367,7 @@ interface InteractiveWrapperProps {
|
|
|
229
367
|
onPointerDown?: (...args: any[]) => void;
|
|
230
368
|
onPointerUp?: (...args: any[]) => void;
|
|
231
369
|
onPointerLeave?: (...args: any[]) => void;
|
|
370
|
+
onPointerCancel?: (...args: any[]) => void;
|
|
232
371
|
onMouseEnter?: (...args: any[]) => void;
|
|
233
372
|
onMouseLeave?: (...args: any[]) => void;
|
|
234
373
|
onFocus?: (...args: any[]) => void;
|
|
@@ -278,4 +417,4 @@ declare function kb(classString: string, isDark?: boolean): StyleValue | string;
|
|
|
278
417
|
*/
|
|
279
418
|
declare function cx(...classes: Array<string | false | null | undefined>): string;
|
|
280
419
|
|
|
281
|
-
export { type ColorScale, type ColorsAPI, FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, ParsedClass, ResolvedConfig, ResolvedStyle, StyleValue, type StyledProps, ThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, ThemeProvider, type ThemeProviderProps, buildConfig, cx, defaultColors, defaultTheme, disableRuntimeCSS, flatten, getConfig, initConfig, kb, normalizeClassString, parseClass, parseClasses, resolve, splitClassTokens, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
|
|
420
|
+
export { type ColorScale, type ColorsAPI, type FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, type ParsedClass, type PluginAPI, type ResolvedConfig, type ResolvedStyle, type StyleValue, type StyledProps, type ThemeConfig, ThemeContext, type ThemeContextValue, type ThemeMode, ThemeProvider, type ThemeProviderProps, buildConfig, clearCache, cx, defaultColors, defaultTheme, disableRuntimeCSS, flatten, getConfig, initConfig, kb, normalizeClassString, parseClass, parseClasses, resolve, setResolveTarget, splitClassTokens, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,142 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode, ComponentType, ForwardRefExoticComponent } from 'react';
|
|
3
|
-
import { T as ThemeColors, a as ThemeConfig, P as ParsedClass, R as ResolvedStyle, S as StyleValue, F as FrameworkConfig, b as ResolvedConfig, c as ThemeMode } from './types-BESBQANS.js';
|
|
4
|
-
export { d as PluginAPI } from './types-BESBQANS.js';
|
|
5
3
|
export { r as registerWebElement } from './web-substitute-CfpYFnE7.js';
|
|
6
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Unified modifier registry — single source of truth for ALL modifier behavior.
|
|
7
|
+
*
|
|
8
|
+
* Adding a new modifier requires editing ONLY this file:
|
|
9
|
+
* 1. Add an entry to BUILTIN_MODIFIERS with its CSS and JS behavior.
|
|
10
|
+
* 2. Done — parser, resolver, CSS generator, and JSX runtime all derive
|
|
11
|
+
* their behavior from this data automatically.
|
|
12
|
+
*
|
|
13
|
+
* Plugin authors can register custom modifiers via registerModifier().
|
|
14
|
+
*/
|
|
15
|
+
interface ModifierDef {
|
|
16
|
+
/** CSS pseudo-class or pseudo-element appended to the selector (e.g. ':hover', '::before') */
|
|
17
|
+
pseudo?: string;
|
|
18
|
+
/** Ancestor selector prefix INCLUDING trailing space (e.g. '.group:hover ', '.peer:focus ~ ') */
|
|
19
|
+
ancestorSelector?: string;
|
|
20
|
+
/** Directionality attribute selector prefix INCLUDING trailing space (e.g. '[dir="rtl"] ') */
|
|
21
|
+
dirSelector?: string;
|
|
22
|
+
/** @media query body WITHOUT the '@media ' prefix (e.g. 'print', '(orientation: landscape)') */
|
|
23
|
+
mediaQuery?: string;
|
|
24
|
+
/** Dark/light mode scheme — triggers the configured darkMode strategy in CSS output */
|
|
25
|
+
darkScheme?: 'dark' | 'light';
|
|
26
|
+
/** True for responsive modifiers — wraps in @media (min-width: theme.screens[name]) */
|
|
27
|
+
isResponsive?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Forces !important on all declarations in the generated CSS rule.
|
|
30
|
+
* Applied automatically for structural / ancestor / media modifiers that must
|
|
31
|
+
* win over base inline styles.
|
|
32
|
+
*/
|
|
33
|
+
forcesImportant?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* How the JSX runtime routes this modifier:
|
|
36
|
+
* 'interactive' — managed by InteractiveWrapper (hover, focus, pressed, …)
|
|
37
|
+
* 'mode' — managed by DarkWrapper (dark, light, not-dark, …)
|
|
38
|
+
* 'responsive' — managed by DarkWrapper (sm, md, lg, xl, 2xl)
|
|
39
|
+
* 'css-only' — CSS injection only; matchModifier always returns false
|
|
40
|
+
*/
|
|
41
|
+
jsBehavior: 'interactive' | 'mode' | 'responsive' | 'css-only';
|
|
42
|
+
/**
|
|
43
|
+
* Evaluates whether this modifier's condition is met at runtime.
|
|
44
|
+
* Omit for 'css-only' modifiers — they never apply as inline styles.
|
|
45
|
+
*/
|
|
46
|
+
jsMatch?: (isDark: boolean, state: Record<string, boolean | undefined>, breakpoints: Set<string>) => boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type ThemeMode = 'light' | 'dark' | 'system';
|
|
50
|
+
interface StyleValue {
|
|
51
|
+
[key: string]: string | number | undefined | null | StyleValue | StyleValue[];
|
|
52
|
+
}
|
|
53
|
+
interface ParsedClass {
|
|
54
|
+
/** The original class string, e.g. "dark:hover:bg-[#fff]" */
|
|
55
|
+
original: string;
|
|
56
|
+
/** Up to 3 modifier prefixes, e.g. ['dark', 'hover'] */
|
|
57
|
+
modifiers: string[];
|
|
58
|
+
/** Whether a leading `-` was present for negative values */
|
|
59
|
+
negative: boolean;
|
|
60
|
+
/** Whether a leading `!` was present — applies !important to all CSS declarations */
|
|
61
|
+
important: boolean;
|
|
62
|
+
/** The utility name, e.g. 'bg', 'p', 'text' */
|
|
63
|
+
utility: string;
|
|
64
|
+
/** The resolved value, e.g. 'white', '#fff', '4' */
|
|
65
|
+
value: string;
|
|
66
|
+
/** Whether the value was specified with bracket notation [value] */
|
|
67
|
+
isArbitrary: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface ResolvedStyle {
|
|
70
|
+
/** Base styles applied unconditionally */
|
|
71
|
+
base?: StyleValue;
|
|
72
|
+
/** Styles keyed by modifier or modifier combo, e.g. 'dark', 'hover', 'dark:hover' */
|
|
73
|
+
[modifierKey: string]: StyleValue | undefined;
|
|
74
|
+
}
|
|
75
|
+
type ColorShades = Record<string, string>;
|
|
76
|
+
type ThemeColors = Record<string, string | ColorShades>;
|
|
77
|
+
type ThemeSpacing = Record<string, number | string>;
|
|
78
|
+
interface ThemeConfig {
|
|
79
|
+
colors: ThemeColors;
|
|
80
|
+
spacing: ThemeSpacing;
|
|
81
|
+
fontSize: Record<string, number | string>;
|
|
82
|
+
fontFamily: Record<string, string | string[]>;
|
|
83
|
+
fontWeight: Record<string, string | number>;
|
|
84
|
+
borderRadius: Record<string, number | string>;
|
|
85
|
+
borderWidth: Record<string, number>;
|
|
86
|
+
opacity: Record<string, number>;
|
|
87
|
+
lineHeight: Record<string, number | string>;
|
|
88
|
+
letterSpacing: Record<string, number | string>;
|
|
89
|
+
zIndex: Record<string, number | string>;
|
|
90
|
+
flex: Record<string, number | string>;
|
|
91
|
+
shadow: Record<string, StyleValue>;
|
|
92
|
+
screens: Record<string, string | number>;
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 'class' — toggles .dark class on <html>
|
|
97
|
+
* 'media' — uses prefers-color-scheme media query
|
|
98
|
+
* 'attribute' — uses data-theme="dark" attribute on <html>
|
|
99
|
+
*/
|
|
100
|
+
type DarkMode = 'attribute' | 'class' | 'media';
|
|
101
|
+
interface PluginAPI {
|
|
102
|
+
addUtility(name: string, styles: StyleValue): void;
|
|
103
|
+
/**
|
|
104
|
+
* Register a custom variant.
|
|
105
|
+
*
|
|
106
|
+
* Pass a CSS selector string for simple cases — it is automatically
|
|
107
|
+
* converted into a ModifierDef that generates correct CSS rules:
|
|
108
|
+
* addVariant('hocus', ':hover, :focus') // pseudo
|
|
109
|
+
* addVariant('supports-grid', '@media (display: grid)') // media
|
|
110
|
+
* addVariant('dark-green', '.dark-green') // ancestor selector
|
|
111
|
+
*
|
|
112
|
+
* Pass a full ModifierDef object for advanced control (e.g. JS-trackable
|
|
113
|
+
* interactive variants with custom jsMatch logic).
|
|
114
|
+
*/
|
|
115
|
+
addVariant(name: string, selectorOrDef: string | ModifierDef): void;
|
|
116
|
+
theme(path: string, defaultValue?: unknown): unknown;
|
|
117
|
+
e(className: string): string;
|
|
118
|
+
}
|
|
119
|
+
interface FrameworkConfig {
|
|
120
|
+
darkMode?: DarkMode;
|
|
121
|
+
theme?: Partial<ThemeConfig>;
|
|
122
|
+
/** Additive theme extension — accepts either `extend.theme.X` or `extend.X` directly. */
|
|
123
|
+
extend?: {
|
|
124
|
+
theme?: Partial<ThemeConfig>;
|
|
125
|
+
} & Partial<ThemeConfig>;
|
|
126
|
+
plugins?: Array<(api: PluginAPI) => void>;
|
|
127
|
+
content?: string[];
|
|
128
|
+
}
|
|
129
|
+
interface ResolvedConfig {
|
|
130
|
+
darkMode: DarkMode;
|
|
131
|
+
theme: ThemeConfig;
|
|
132
|
+
plugins: Array<(api: PluginAPI) => void>;
|
|
133
|
+
}
|
|
134
|
+
|
|
7
135
|
declare const defaultColors: ThemeColors;
|
|
8
136
|
declare const defaultTheme: ThemeConfig;
|
|
9
137
|
|
|
138
|
+
declare function setResolveTarget(target: 'web' | 'native' | null): void;
|
|
139
|
+
|
|
10
140
|
declare function parseClass(className: string): ParsedClass | null;
|
|
11
141
|
/**
|
|
12
142
|
* Split a class string into tokens. Whitespace at bracket depth > 0 is STRIPPED
|
|
@@ -48,6 +178,14 @@ declare function flatten(resolved: ResolvedStyle, isDark: boolean, state?: {
|
|
|
48
178
|
visited?: boolean;
|
|
49
179
|
placeholder?: boolean;
|
|
50
180
|
}, breakpoints?: Set<string>): StyleValue;
|
|
181
|
+
/**
|
|
182
|
+
* Clear CSS injection state so stale rules are re-injected when the theme changes.
|
|
183
|
+
*
|
|
184
|
+
* The per-theme style cache (WeakMap) does not need to be cleared manually:
|
|
185
|
+
* updateConfig() creates a new theme object, making the old cache entry
|
|
186
|
+
* automatically unreachable for GC.
|
|
187
|
+
*/
|
|
188
|
+
declare function clearCache(): void;
|
|
51
189
|
|
|
52
190
|
/**
|
|
53
191
|
* Load, merge, and cache the resolved config.
|
|
@@ -229,6 +367,7 @@ interface InteractiveWrapperProps {
|
|
|
229
367
|
onPointerDown?: (...args: any[]) => void;
|
|
230
368
|
onPointerUp?: (...args: any[]) => void;
|
|
231
369
|
onPointerLeave?: (...args: any[]) => void;
|
|
370
|
+
onPointerCancel?: (...args: any[]) => void;
|
|
232
371
|
onMouseEnter?: (...args: any[]) => void;
|
|
233
372
|
onMouseLeave?: (...args: any[]) => void;
|
|
234
373
|
onFocus?: (...args: any[]) => void;
|
|
@@ -278,4 +417,4 @@ declare function kb(classString: string, isDark?: boolean): StyleValue | string;
|
|
|
278
417
|
*/
|
|
279
418
|
declare function cx(...classes: Array<string | false | null | undefined>): string;
|
|
280
419
|
|
|
281
|
-
export { type ColorScale, type ColorsAPI, FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, ParsedClass, ResolvedConfig, ResolvedStyle, StyleValue, type StyledProps, ThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, ThemeProvider, type ThemeProviderProps, buildConfig, cx, defaultColors, defaultTheme, disableRuntimeCSS, flatten, getConfig, initConfig, kb, normalizeClassString, parseClass, parseClasses, resolve, splitClassTokens, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
|
|
420
|
+
export { type ColorScale, type ColorsAPI, type FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, type ParsedClass, type PluginAPI, type ResolvedConfig, type ResolvedStyle, type StyleValue, type StyledProps, type ThemeConfig, ThemeContext, type ThemeContextValue, type ThemeMode, ThemeProvider, type ThemeProviderProps, buildConfig, clearCache, cx, defaultColors, defaultTheme, disableRuntimeCSS, flatten, getConfig, initConfig, kb, normalizeClassString, parseClass, parseClasses, resolve, setResolveTarget, splitClassTokens, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
|