@kbach/react 0.1.6 → 0.1.9
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 +29 -29
- package/dist/{chunk-FUSJKUE7.mjs → chunk-CNS23UB5.mjs} +9 -7
- package/dist/chunk-PYBA3DFG.mjs +2046 -0
- package/dist/index.d.mts +128 -9
- package/dist/index.d.ts +128 -9
- package/dist/index.js +1985 -40
- package/dist/index.mjs +26 -35
- package/dist/jsx-dev-runtime.js +1943 -18
- package/dist/jsx-dev-runtime.mjs +2 -2
- package/dist/jsx-runtime.js +1943 -18
- package/dist/jsx-runtime.mjs +2 -2
- package/package.json +1 -4
- package/dist/chunk-IZK5HMWK.mjs +0 -85
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,127 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode, ComponentType, ForwardRefExoticComponent } from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
|
|
4
|
+
type ThemeMode = 'light' | 'dark' | 'system';
|
|
5
|
+
interface StyleValue {
|
|
6
|
+
[key: string]: string | number | undefined | null | StyleValue | unknown[];
|
|
7
|
+
}
|
|
8
|
+
interface ParsedClass {
|
|
9
|
+
/** The original class string, e.g. "dark:hover:bg-[#fff]" */
|
|
10
|
+
original: string;
|
|
11
|
+
/** Up to 3 modifier prefixes, e.g. ['dark', 'hover'] */
|
|
12
|
+
modifiers: string[];
|
|
13
|
+
/** Whether a leading `-` was present for negative values */
|
|
14
|
+
negative: boolean;
|
|
15
|
+
/** The utility name, e.g. 'bg', 'p', 'text' */
|
|
16
|
+
utility: string;
|
|
17
|
+
/** The resolved value, e.g. 'white', '#fff', '4' */
|
|
18
|
+
value: string;
|
|
19
|
+
/** Whether the value was specified with bracket notation [value] */
|
|
20
|
+
isArbitrary: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface ResolvedStyle {
|
|
23
|
+
/** Base styles applied unconditionally */
|
|
24
|
+
base?: StyleValue;
|
|
25
|
+
/** Styles keyed by modifier or modifier combo, e.g. 'dark', 'hover', 'dark:hover' */
|
|
26
|
+
[modifierKey: string]: StyleValue | undefined;
|
|
27
|
+
}
|
|
28
|
+
type ColorShades = Record<string, string>;
|
|
29
|
+
type ThemeColors = Record<string, string | ColorShades>;
|
|
30
|
+
type ThemeSpacing = Record<string, number | string>;
|
|
31
|
+
interface ThemeConfig {
|
|
32
|
+
colors: ThemeColors;
|
|
33
|
+
spacing: ThemeSpacing;
|
|
34
|
+
fontSize: Record<string, number | string>;
|
|
35
|
+
fontFamily: Record<string, string | string[]>;
|
|
36
|
+
fontWeight: Record<string, string | number>;
|
|
37
|
+
borderRadius: Record<string, number | string>;
|
|
38
|
+
borderWidth: Record<string, number>;
|
|
39
|
+
opacity: Record<string, number>;
|
|
40
|
+
lineHeight: Record<string, number | string>;
|
|
41
|
+
letterSpacing: Record<string, number | string>;
|
|
42
|
+
zIndex: Record<string, number | string>;
|
|
43
|
+
flex: Record<string, number>;
|
|
44
|
+
shadow: Record<string, StyleValue>;
|
|
45
|
+
screens: Record<string, string | number>;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
type DarkMode = 'attribute' | 'class' | 'media';
|
|
49
|
+
interface PluginAPI {
|
|
50
|
+
addUtility(name: string, styles: StyleValue): void;
|
|
51
|
+
addVariant(name: string, selector: string): void;
|
|
52
|
+
theme(path: string, defaultValue?: unknown): unknown;
|
|
53
|
+
e(className: string): string;
|
|
54
|
+
}
|
|
55
|
+
interface FrameworkConfig {
|
|
56
|
+
darkMode?: DarkMode;
|
|
57
|
+
theme?: Partial<ThemeConfig>;
|
|
58
|
+
extend?: {
|
|
59
|
+
theme?: Partial<ThemeConfig>;
|
|
60
|
+
};
|
|
61
|
+
plugins?: Array<(api: PluginAPI) => void>;
|
|
62
|
+
content?: string[];
|
|
63
|
+
}
|
|
64
|
+
interface ResolvedConfig {
|
|
65
|
+
darkMode: DarkMode;
|
|
66
|
+
theme: ThemeConfig;
|
|
67
|
+
plugins: Array<(api: PluginAPI) => void>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare const defaultColors: ThemeColors;
|
|
71
|
+
declare const defaultTheme: ThemeConfig;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Parse a single utility class string into its components.
|
|
75
|
+
*
|
|
76
|
+
* Handles:
|
|
77
|
+
* - Up to 3 modifier prefixes: dark:hover:focus:bg-white
|
|
78
|
+
* - Negative values: -p-4 -m-[10px] -top-2
|
|
79
|
+
* - Arbitrary bracket values: bg-[#fff] p-[10px] text-[rgba(0,0,0,.5)]
|
|
80
|
+
* - All Tailwind-equivalent utilities
|
|
81
|
+
*/
|
|
82
|
+
declare function parseClass(className: string): ParsedClass | null;
|
|
83
|
+
/** Parse a space-separated class string into individual ParsedClass objects. */
|
|
84
|
+
declare function parseClasses(classString: string): ParsedClass[];
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Resolve a class string to a ResolvedStyle object.
|
|
88
|
+
*
|
|
89
|
+
* The result groups styles by modifier key:
|
|
90
|
+
* - 'base' → always-applied styles
|
|
91
|
+
* - 'dark' → dark-mode styles
|
|
92
|
+
* - 'hover' → hover styles
|
|
93
|
+
* - 'dark:hover' → combined dark + hover
|
|
94
|
+
* - etc.
|
|
95
|
+
*
|
|
96
|
+
* Results are cached — repeated calls with the same string are O(1).
|
|
97
|
+
*/
|
|
98
|
+
declare function resolve(classString: string, theme: ThemeConfig, darkMode?: 'attribute' | 'class' | 'media'): ResolvedStyle;
|
|
99
|
+
/**
|
|
100
|
+
* Flatten a ResolvedStyle into a single StyleValue for the given runtime state.
|
|
101
|
+
* Used by useStyles() and styled().
|
|
102
|
+
*
|
|
103
|
+
* @param resolved Output of resolve()
|
|
104
|
+
* @param isDark Whether dark mode is currently active
|
|
105
|
+
* @param state Interaction state flags
|
|
106
|
+
*/
|
|
107
|
+
declare function flatten(resolved: ResolvedStyle, isDark: boolean, state?: {
|
|
108
|
+
hover?: boolean;
|
|
109
|
+
focus?: boolean;
|
|
110
|
+
pressed?: boolean;
|
|
111
|
+
active?: boolean;
|
|
112
|
+
disabled?: boolean;
|
|
113
|
+
checked?: boolean;
|
|
114
|
+
visited?: boolean;
|
|
115
|
+
placeholder?: boolean;
|
|
116
|
+
}): StyleValue;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Load, merge, and cache the resolved config.
|
|
120
|
+
* Call resetConfig() to force a reload (e.g. in tests or after live update).
|
|
121
|
+
*/
|
|
122
|
+
declare function getConfig(): ResolvedConfig;
|
|
123
|
+
declare function buildConfig(userConfig: FrameworkConfig): ResolvedConfig;
|
|
124
|
+
declare function updateConfig(userConfig: FrameworkConfig): void;
|
|
6
125
|
|
|
7
126
|
interface ThemeContextValue {
|
|
8
127
|
/** The user-selected mode ('light' | 'dark' | 'system') */
|
|
@@ -62,8 +181,8 @@ declare function ThemeToggle({ variant, label, lightLabel, darkLabel, includeSys
|
|
|
62
181
|
|
|
63
182
|
interface StyledProps {
|
|
64
183
|
/** Additional utility classes applied on top of the base classes */
|
|
65
|
-
|
|
66
|
-
/** Merged with resolved
|
|
184
|
+
kb?: string;
|
|
185
|
+
/** Merged with resolved kb styles; applied last */
|
|
67
186
|
style?: StyleValue | StyleValue[];
|
|
68
187
|
}
|
|
69
188
|
type OmittedKeys = 'style';
|
|
@@ -75,8 +194,8 @@ type OmittedKeys = 'style';
|
|
|
75
194
|
* const Button = styled(TouchableOpacity, 'bg-blue-500 pressed:bg-blue-700 dark:bg-blue-600 rounded-lg p-3');
|
|
76
195
|
*
|
|
77
196
|
* // Use it:
|
|
78
|
-
* <Card
|
|
79
|
-
* <Button onPress={handlePress}
|
|
197
|
+
* <Card kb="mt-4">...</Card>
|
|
198
|
+
* <Button onPress={handlePress} kb="w-full" />
|
|
80
199
|
* ```
|
|
81
200
|
*/
|
|
82
201
|
declare function styled<T extends ComponentType<any>>(Component: T, baseClasses?: string): ForwardRefExoticComponent<Omit<React__default.ComponentPropsWithRef<T>, OmittedKeys> & StyledProps>;
|
|
@@ -112,7 +231,7 @@ declare function useStyles(classString: string | string[], state?: InteractionSt
|
|
|
112
231
|
* Returns the full ResolvedStyle bucket map (base, dark, hover, …).
|
|
113
232
|
* Useful when you need to apply styles selectively or pass them to Animated.
|
|
114
233
|
*/
|
|
115
|
-
declare function useResolvedStyle(classString: string | string[]):
|
|
234
|
+
declare function useResolvedStyle(classString: string | string[]): ResolvedStyle;
|
|
116
235
|
|
|
117
236
|
/**
|
|
118
237
|
* Subscribe to the global dark-mode store with React's concurrent-safe
|
|
@@ -182,4 +301,4 @@ declare function tw(classString: string, isDark?: boolean): StyleValue | string;
|
|
|
182
301
|
*/
|
|
183
302
|
declare function cx(...classes: Array<string | false | null | undefined>): string;
|
|
184
303
|
|
|
185
|
-
export { type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, type StyledProps, ThemeContext, type ThemeContextValue, ThemeProvider, type ThemeProviderProps, ThemeToggle, type ThemeToggleProps, type ToggleVariant, cx, styled, tw, useGlobalDarkMode, useResolvedStyle, useStyles, useTheme };
|
|
304
|
+
export { 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, ThemeToggle, type ThemeToggleProps, type ToggleVariant, buildConfig, cx, defaultColors, defaultTheme, flatten, getConfig, parseClass, parseClasses, resolve, styled, tw, updateConfig, useGlobalDarkMode, useResolvedStyle, useStyles, useTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,127 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode, ComponentType, ForwardRefExoticComponent } from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
|
|
4
|
+
type ThemeMode = 'light' | 'dark' | 'system';
|
|
5
|
+
interface StyleValue {
|
|
6
|
+
[key: string]: string | number | undefined | null | StyleValue | unknown[];
|
|
7
|
+
}
|
|
8
|
+
interface ParsedClass {
|
|
9
|
+
/** The original class string, e.g. "dark:hover:bg-[#fff]" */
|
|
10
|
+
original: string;
|
|
11
|
+
/** Up to 3 modifier prefixes, e.g. ['dark', 'hover'] */
|
|
12
|
+
modifiers: string[];
|
|
13
|
+
/** Whether a leading `-` was present for negative values */
|
|
14
|
+
negative: boolean;
|
|
15
|
+
/** The utility name, e.g. 'bg', 'p', 'text' */
|
|
16
|
+
utility: string;
|
|
17
|
+
/** The resolved value, e.g. 'white', '#fff', '4' */
|
|
18
|
+
value: string;
|
|
19
|
+
/** Whether the value was specified with bracket notation [value] */
|
|
20
|
+
isArbitrary: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface ResolvedStyle {
|
|
23
|
+
/** Base styles applied unconditionally */
|
|
24
|
+
base?: StyleValue;
|
|
25
|
+
/** Styles keyed by modifier or modifier combo, e.g. 'dark', 'hover', 'dark:hover' */
|
|
26
|
+
[modifierKey: string]: StyleValue | undefined;
|
|
27
|
+
}
|
|
28
|
+
type ColorShades = Record<string, string>;
|
|
29
|
+
type ThemeColors = Record<string, string | ColorShades>;
|
|
30
|
+
type ThemeSpacing = Record<string, number | string>;
|
|
31
|
+
interface ThemeConfig {
|
|
32
|
+
colors: ThemeColors;
|
|
33
|
+
spacing: ThemeSpacing;
|
|
34
|
+
fontSize: Record<string, number | string>;
|
|
35
|
+
fontFamily: Record<string, string | string[]>;
|
|
36
|
+
fontWeight: Record<string, string | number>;
|
|
37
|
+
borderRadius: Record<string, number | string>;
|
|
38
|
+
borderWidth: Record<string, number>;
|
|
39
|
+
opacity: Record<string, number>;
|
|
40
|
+
lineHeight: Record<string, number | string>;
|
|
41
|
+
letterSpacing: Record<string, number | string>;
|
|
42
|
+
zIndex: Record<string, number | string>;
|
|
43
|
+
flex: Record<string, number>;
|
|
44
|
+
shadow: Record<string, StyleValue>;
|
|
45
|
+
screens: Record<string, string | number>;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
type DarkMode = 'attribute' | 'class' | 'media';
|
|
49
|
+
interface PluginAPI {
|
|
50
|
+
addUtility(name: string, styles: StyleValue): void;
|
|
51
|
+
addVariant(name: string, selector: string): void;
|
|
52
|
+
theme(path: string, defaultValue?: unknown): unknown;
|
|
53
|
+
e(className: string): string;
|
|
54
|
+
}
|
|
55
|
+
interface FrameworkConfig {
|
|
56
|
+
darkMode?: DarkMode;
|
|
57
|
+
theme?: Partial<ThemeConfig>;
|
|
58
|
+
extend?: {
|
|
59
|
+
theme?: Partial<ThemeConfig>;
|
|
60
|
+
};
|
|
61
|
+
plugins?: Array<(api: PluginAPI) => void>;
|
|
62
|
+
content?: string[];
|
|
63
|
+
}
|
|
64
|
+
interface ResolvedConfig {
|
|
65
|
+
darkMode: DarkMode;
|
|
66
|
+
theme: ThemeConfig;
|
|
67
|
+
plugins: Array<(api: PluginAPI) => void>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare const defaultColors: ThemeColors;
|
|
71
|
+
declare const defaultTheme: ThemeConfig;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Parse a single utility class string into its components.
|
|
75
|
+
*
|
|
76
|
+
* Handles:
|
|
77
|
+
* - Up to 3 modifier prefixes: dark:hover:focus:bg-white
|
|
78
|
+
* - Negative values: -p-4 -m-[10px] -top-2
|
|
79
|
+
* - Arbitrary bracket values: bg-[#fff] p-[10px] text-[rgba(0,0,0,.5)]
|
|
80
|
+
* - All Tailwind-equivalent utilities
|
|
81
|
+
*/
|
|
82
|
+
declare function parseClass(className: string): ParsedClass | null;
|
|
83
|
+
/** Parse a space-separated class string into individual ParsedClass objects. */
|
|
84
|
+
declare function parseClasses(classString: string): ParsedClass[];
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Resolve a class string to a ResolvedStyle object.
|
|
88
|
+
*
|
|
89
|
+
* The result groups styles by modifier key:
|
|
90
|
+
* - 'base' → always-applied styles
|
|
91
|
+
* - 'dark' → dark-mode styles
|
|
92
|
+
* - 'hover' → hover styles
|
|
93
|
+
* - 'dark:hover' → combined dark + hover
|
|
94
|
+
* - etc.
|
|
95
|
+
*
|
|
96
|
+
* Results are cached — repeated calls with the same string are O(1).
|
|
97
|
+
*/
|
|
98
|
+
declare function resolve(classString: string, theme: ThemeConfig, darkMode?: 'attribute' | 'class' | 'media'): ResolvedStyle;
|
|
99
|
+
/**
|
|
100
|
+
* Flatten a ResolvedStyle into a single StyleValue for the given runtime state.
|
|
101
|
+
* Used by useStyles() and styled().
|
|
102
|
+
*
|
|
103
|
+
* @param resolved Output of resolve()
|
|
104
|
+
* @param isDark Whether dark mode is currently active
|
|
105
|
+
* @param state Interaction state flags
|
|
106
|
+
*/
|
|
107
|
+
declare function flatten(resolved: ResolvedStyle, isDark: boolean, state?: {
|
|
108
|
+
hover?: boolean;
|
|
109
|
+
focus?: boolean;
|
|
110
|
+
pressed?: boolean;
|
|
111
|
+
active?: boolean;
|
|
112
|
+
disabled?: boolean;
|
|
113
|
+
checked?: boolean;
|
|
114
|
+
visited?: boolean;
|
|
115
|
+
placeholder?: boolean;
|
|
116
|
+
}): StyleValue;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Load, merge, and cache the resolved config.
|
|
120
|
+
* Call resetConfig() to force a reload (e.g. in tests or after live update).
|
|
121
|
+
*/
|
|
122
|
+
declare function getConfig(): ResolvedConfig;
|
|
123
|
+
declare function buildConfig(userConfig: FrameworkConfig): ResolvedConfig;
|
|
124
|
+
declare function updateConfig(userConfig: FrameworkConfig): void;
|
|
6
125
|
|
|
7
126
|
interface ThemeContextValue {
|
|
8
127
|
/** The user-selected mode ('light' | 'dark' | 'system') */
|
|
@@ -62,8 +181,8 @@ declare function ThemeToggle({ variant, label, lightLabel, darkLabel, includeSys
|
|
|
62
181
|
|
|
63
182
|
interface StyledProps {
|
|
64
183
|
/** Additional utility classes applied on top of the base classes */
|
|
65
|
-
|
|
66
|
-
/** Merged with resolved
|
|
184
|
+
kb?: string;
|
|
185
|
+
/** Merged with resolved kb styles; applied last */
|
|
67
186
|
style?: StyleValue | StyleValue[];
|
|
68
187
|
}
|
|
69
188
|
type OmittedKeys = 'style';
|
|
@@ -75,8 +194,8 @@ type OmittedKeys = 'style';
|
|
|
75
194
|
* const Button = styled(TouchableOpacity, 'bg-blue-500 pressed:bg-blue-700 dark:bg-blue-600 rounded-lg p-3');
|
|
76
195
|
*
|
|
77
196
|
* // Use it:
|
|
78
|
-
* <Card
|
|
79
|
-
* <Button onPress={handlePress}
|
|
197
|
+
* <Card kb="mt-4">...</Card>
|
|
198
|
+
* <Button onPress={handlePress} kb="w-full" />
|
|
80
199
|
* ```
|
|
81
200
|
*/
|
|
82
201
|
declare function styled<T extends ComponentType<any>>(Component: T, baseClasses?: string): ForwardRefExoticComponent<Omit<React__default.ComponentPropsWithRef<T>, OmittedKeys> & StyledProps>;
|
|
@@ -112,7 +231,7 @@ declare function useStyles(classString: string | string[], state?: InteractionSt
|
|
|
112
231
|
* Returns the full ResolvedStyle bucket map (base, dark, hover, …).
|
|
113
232
|
* Useful when you need to apply styles selectively or pass them to Animated.
|
|
114
233
|
*/
|
|
115
|
-
declare function useResolvedStyle(classString: string | string[]):
|
|
234
|
+
declare function useResolvedStyle(classString: string | string[]): ResolvedStyle;
|
|
116
235
|
|
|
117
236
|
/**
|
|
118
237
|
* Subscribe to the global dark-mode store with React's concurrent-safe
|
|
@@ -182,4 +301,4 @@ declare function tw(classString: string, isDark?: boolean): StyleValue | string;
|
|
|
182
301
|
*/
|
|
183
302
|
declare function cx(...classes: Array<string | false | null | undefined>): string;
|
|
184
303
|
|
|
185
|
-
export { type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, type StyledProps, ThemeContext, type ThemeContextValue, ThemeProvider, type ThemeProviderProps, ThemeToggle, type ThemeToggleProps, type ToggleVariant, cx, styled, tw, useGlobalDarkMode, useResolvedStyle, useStyles, useTheme };
|
|
304
|
+
export { 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, ThemeToggle, type ThemeToggleProps, type ToggleVariant, buildConfig, cx, defaultColors, defaultTheme, flatten, getConfig, parseClass, parseClasses, resolve, styled, tw, updateConfig, useGlobalDarkMode, useResolvedStyle, useStyles, useTheme };
|