tailwind-to-style 3.2.2 → 4.0.0
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 +221 -666
- package/dist/animations/index.cjs +9391 -0
- package/dist/animations/index.d.ts +58 -0
- package/dist/animations/index.esm.js +9385 -0
- package/dist/animations/index.esm.js.map +1 -0
- package/dist/className/index.cjs +9080 -0
- package/dist/className/index.esm.js +9075 -0
- package/dist/className/index.esm.js.map +1 -0
- package/dist/core/tws.cjs +136 -114
- package/dist/core/tws.cjs.map +1 -0
- package/dist/core/tws.esm.js +136 -114
- package/dist/core/tws.esm.js.map +1 -1
- package/dist/core/twsx.cjs +2442 -4245
- package/dist/core/twsx.esm.js +2442 -4245
- package/dist/core/twsx.esm.js.map +1 -1
- package/dist/core/twsxVariants.cjs +2470 -4262
- package/dist/core/twsxVariants.esm.js +2470 -4262
- package/dist/core/twsxVariants.esm.js.map +1 -1
- package/dist/cx.cjs +2 -2
- package/dist/cx.cjs.map +1 -0
- package/dist/cx.esm.js +2 -2
- package/dist/index.cjs +5128 -6057
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +993 -1
- package/dist/index.esm.js +5124 -6022
- package/dist/index.esm.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/react/index.cjs +10177 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.ts +69 -0
- package/dist/react/index.esm.js +10173 -0
- package/dist/react/index.esm.js.map +1 -0
- package/dist/styled/index.cjs +9094 -0
- package/dist/styled/index.cjs.map +1 -0
- package/dist/styled/index.d.ts +17 -0
- package/dist/styled/index.esm.js +9087 -0
- package/dist/styled/index.esm.js.map +1 -0
- package/dist/tokens/index.cjs +359 -0
- package/dist/tokens/index.d.ts +33 -0
- package/dist/tokens/index.esm.js +355 -0
- package/dist/tokens/index.esm.js.map +1 -0
- package/dist/utils/index.cjs +313 -297
- package/dist/utils/index.esm.js +313 -297
- package/dist/utils/index.esm.js.map +1 -1
- package/package.json +38 -24
- package/types/animations/index.d.ts +58 -0
- package/types/className/index.d.ts +41 -0
- package/types/index.d.ts +993 -1
- package/types/react/index.d.ts +69 -0
- package/types/tokens/index.d.ts +33 -0
- package/types/v4.d.ts +191 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Type definitions for tailwind-to-style/react
|
|
2
|
+
|
|
3
|
+
import { ComponentType, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
|
|
4
|
+
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// styled()
|
|
7
|
+
// ============================================================================
|
|
8
|
+
|
|
9
|
+
type IntrinsicElement = keyof JSX.IntrinsicElements;
|
|
10
|
+
|
|
11
|
+
interface StyledConfig<V extends Record<string, Record<string, string>> = {}> {
|
|
12
|
+
name?: string;
|
|
13
|
+
base?: string;
|
|
14
|
+
variants?: V;
|
|
15
|
+
defaultVariants?: { [K in keyof V]?: keyof V[K] };
|
|
16
|
+
compoundVariants?: Array<{ class?: string; className?: string; [key: string]: any }>;
|
|
17
|
+
slots?: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type VariantProps<V extends Record<string, Record<string, string>>> = {
|
|
21
|
+
[K in keyof V]?: keyof V[K];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type StyledComponent<
|
|
25
|
+
T extends IntrinsicElement | ComponentType<any>,
|
|
26
|
+
V extends Record<string, Record<string, string>>
|
|
27
|
+
> = ForwardRefExoticComponent<
|
|
28
|
+
PropsWithoutRef<
|
|
29
|
+
(T extends IntrinsicElement ? JSX.IntrinsicElements[T] : T extends ComponentType<infer P> ? P : never) &
|
|
30
|
+
VariantProps<V> & { className?: string }
|
|
31
|
+
> &
|
|
32
|
+
RefAttributes<T extends IntrinsicElement ? HTMLElement : any>
|
|
33
|
+
> & {
|
|
34
|
+
variants: any;
|
|
35
|
+
raw: StyledConfig<V>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export declare function styled<
|
|
39
|
+
T extends IntrinsicElement | ComponentType<any>,
|
|
40
|
+
V extends Record<string, Record<string, string>> = {}
|
|
41
|
+
>(
|
|
42
|
+
element: T,
|
|
43
|
+
config?: StyledConfig<V>
|
|
44
|
+
): StyledComponent<T, V>;
|
|
45
|
+
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// ThemeProvider & useTheme
|
|
48
|
+
// ============================================================================
|
|
49
|
+
|
|
50
|
+
interface ThemeProviderProps {
|
|
51
|
+
theme: Record<string, any>;
|
|
52
|
+
name?: string;
|
|
53
|
+
children: React.ReactNode;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface ThemeContextValue {
|
|
57
|
+
theme: Record<string, any>;
|
|
58
|
+
setTheme: (newTheme: Record<string, any>) => void;
|
|
59
|
+
tokens: Record<string, any>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export declare function ThemeProvider(props: ThemeProviderProps): JSX.Element;
|
|
63
|
+
export declare function useTheme(): ThemeContextValue;
|
|
64
|
+
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// useTws
|
|
67
|
+
// ============================================================================
|
|
68
|
+
|
|
69
|
+
export declare function useTws(classes: string): Record<string, string>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Type definitions for tailwind-to-style/tokens
|
|
2
|
+
|
|
3
|
+
export interface TokenRegistry {
|
|
4
|
+
get(path: string): string | undefined;
|
|
5
|
+
set(path: string, value: string): void;
|
|
6
|
+
subscribe(callback: (tokens: Record<string, any>) => void): () => void;
|
|
7
|
+
toCSS(): string;
|
|
8
|
+
getAll(): Record<string, any>;
|
|
9
|
+
clear(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ThemeResult {
|
|
13
|
+
name: string;
|
|
14
|
+
tokens: Record<string, any>;
|
|
15
|
+
selector: string;
|
|
16
|
+
var(path: string): string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CreateThemeOptions {
|
|
20
|
+
name?: string;
|
|
21
|
+
selector?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export declare const tokenRegistry: TokenRegistry;
|
|
25
|
+
|
|
26
|
+
export declare function createTheme(
|
|
27
|
+
tokens: Record<string, any>,
|
|
28
|
+
options?: CreateThemeOptions
|
|
29
|
+
): ThemeResult;
|
|
30
|
+
|
|
31
|
+
export declare function activateTheme(name: string): void;
|
|
32
|
+
|
|
33
|
+
export declare function token(path: string, fallback?: string): string;
|
package/types/v4.d.ts
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// Type definitions for tailwind-to-style v4
|
|
2
|
+
// Unified API type declarations
|
|
3
|
+
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Core Types
|
|
6
|
+
// ============================================================================
|
|
7
|
+
|
|
8
|
+
type ClassValue = string | number | boolean | null | undefined | ClassObject | ClassArray;
|
|
9
|
+
type ClassObject = Record<string, any>;
|
|
10
|
+
type ClassArray = ClassValue[];
|
|
11
|
+
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// tw() — The Main Function
|
|
14
|
+
// ============================================================================
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Variants definition for tw()
|
|
18
|
+
*/
|
|
19
|
+
interface TwVariantsDefinition {
|
|
20
|
+
[variantName: string]: {
|
|
21
|
+
[optionKey: string]: string | { _?: string; [key: string]: string | undefined };
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Variant props inferred from definition
|
|
27
|
+
*/
|
|
28
|
+
type TwVariantProps<V extends TwVariantsDefinition> = {
|
|
29
|
+
[K in keyof V]?: keyof V[K] | boolean;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Variant selector function returned by tw() in Mode 3
|
|
34
|
+
*/
|
|
35
|
+
interface TwVariantFunction<V extends TwVariantsDefinition> {
|
|
36
|
+
(props?: TwVariantProps<V>): string;
|
|
37
|
+
merge(props?: TwVariantProps<V>, ...additionalClasses: ClassValue[]): string;
|
|
38
|
+
merge(...additionalClasses: ClassValue[]): string;
|
|
39
|
+
raw(): TwVariantsConfig<V>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Slots definition for tw()
|
|
44
|
+
*/
|
|
45
|
+
interface TwSlotsDefinition {
|
|
46
|
+
[slotName: string]: string | { _?: string; [key: string]: string | undefined };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Slots function returned by tw() in Mode 4
|
|
51
|
+
*/
|
|
52
|
+
interface TwSlotsFunction<S extends TwSlotsDefinition, V extends TwVariantsDefinition> {
|
|
53
|
+
(props?: TwVariantProps<V>): { [K in keyof S]: string };
|
|
54
|
+
merge(props?: TwVariantProps<V>, slotOverrides?: Partial<{ [K in keyof S]: string }>): { [K in keyof S]: string };
|
|
55
|
+
raw(): TwSlotsConfig<S, V>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Config for tw() Mode 3 (variants)
|
|
60
|
+
*/
|
|
61
|
+
interface TwVariantsConfig<V extends TwVariantsDefinition = TwVariantsDefinition> {
|
|
62
|
+
name?: string;
|
|
63
|
+
base?: string | { _?: string; [key: string]: string | undefined };
|
|
64
|
+
variants: V;
|
|
65
|
+
compoundVariants?: Array<{ class?: string; className?: string; [key: string]: any }>;
|
|
66
|
+
defaultVariants?: { [K in keyof V]?: keyof V[K] | boolean };
|
|
67
|
+
responsiveVariants?: (keyof V)[];
|
|
68
|
+
prefix?: string;
|
|
69
|
+
hash?: boolean;
|
|
70
|
+
hashLength?: number;
|
|
71
|
+
inject?: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Config for tw() Mode 4 (slots)
|
|
76
|
+
*/
|
|
77
|
+
interface TwSlotsConfig<
|
|
78
|
+
S extends TwSlotsDefinition = TwSlotsDefinition,
|
|
79
|
+
V extends TwVariantsDefinition = TwVariantsDefinition
|
|
80
|
+
> {
|
|
81
|
+
name?: string;
|
|
82
|
+
slots: S;
|
|
83
|
+
variants?: V;
|
|
84
|
+
compoundVariants?: Array<{ class?: string; className?: string; [key: string]: any }>;
|
|
85
|
+
defaultVariants?: { [K in keyof V]?: keyof V[K] | boolean };
|
|
86
|
+
prefix?: string;
|
|
87
|
+
hash?: boolean;
|
|
88
|
+
hashLength?: number;
|
|
89
|
+
inject?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Config for tw() Mode 2 (named class — object form)
|
|
94
|
+
*/
|
|
95
|
+
interface TwBasicConfig {
|
|
96
|
+
name?: string;
|
|
97
|
+
_?: string;
|
|
98
|
+
prefix?: string;
|
|
99
|
+
hash?: boolean;
|
|
100
|
+
hashLength?: number;
|
|
101
|
+
inject?: boolean;
|
|
102
|
+
[key: string]: any;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The unified tw() function.
|
|
107
|
+
*/
|
|
108
|
+
interface TwFunction {
|
|
109
|
+
/** Mode 1: String → atomic CSS classes */
|
|
110
|
+
(classes: string): string;
|
|
111
|
+
|
|
112
|
+
/** Mode 2: Named class → scoped className */
|
|
113
|
+
(name: string, classes: string): string;
|
|
114
|
+
|
|
115
|
+
/** Mode 3: Variants config → variant selector function */
|
|
116
|
+
<V extends TwVariantsDefinition>(config: TwVariantsConfig<V>): TwVariantFunction<V>;
|
|
117
|
+
|
|
118
|
+
/** Mode 4: Slots config → slots generator function */
|
|
119
|
+
<S extends TwSlotsDefinition, V extends TwVariantsDefinition>(config: TwSlotsConfig<S, V>): TwSlotsFunction<S, V>;
|
|
120
|
+
|
|
121
|
+
/** Mode 2/3/4: Generic object config */
|
|
122
|
+
(config: TwBasicConfig): string;
|
|
123
|
+
|
|
124
|
+
/** Extract all generated CSS (for SSR) */
|
|
125
|
+
extractCSS(): string;
|
|
126
|
+
|
|
127
|
+
/** Clear internal caches */
|
|
128
|
+
clearCache(): void;
|
|
129
|
+
|
|
130
|
+
/** Configure global settings */
|
|
131
|
+
config(options: {
|
|
132
|
+
prefix?: string;
|
|
133
|
+
hash?: boolean;
|
|
134
|
+
hashLength?: number;
|
|
135
|
+
inject?: boolean;
|
|
136
|
+
deduplicate?: boolean;
|
|
137
|
+
}): void;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export declare const tw: TwFunction;
|
|
141
|
+
|
|
142
|
+
// ============================================================================
|
|
143
|
+
// tws() — Inline Style Converter
|
|
144
|
+
// ============================================================================
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Convert Tailwind classes to inline CSS string or JSON object.
|
|
148
|
+
*/
|
|
149
|
+
export declare function tws(classNames: string, convertToJson?: false): string;
|
|
150
|
+
export declare function tws(classNames: string, convertToJson: true): Record<string, string>;
|
|
151
|
+
export declare function tws(classNames: string, convertToJson?: boolean): string | Record<string, string>;
|
|
152
|
+
|
|
153
|
+
// ============================================================================
|
|
154
|
+
// cx() — Conditional Class Names
|
|
155
|
+
// ============================================================================
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Conditionally join class names.
|
|
159
|
+
*/
|
|
160
|
+
export declare function cx(...args: ClassValue[]): string;
|
|
161
|
+
|
|
162
|
+
export declare namespace cx {
|
|
163
|
+
function with_(...baseArgs: ClassValue[]): (...args: ClassValue[]) => string;
|
|
164
|
+
export { with_ as with };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// ============================================================================
|
|
168
|
+
// SSR
|
|
169
|
+
// ============================================================================
|
|
170
|
+
|
|
171
|
+
export interface SSRCollectorOptions {
|
|
172
|
+
dedupe?: boolean;
|
|
173
|
+
minify?: boolean;
|
|
174
|
+
sort?: boolean;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface SSRCollector {
|
|
178
|
+
extract(options?: { id?: string; nonce?: string; minify?: boolean }): string;
|
|
179
|
+
getCSS(): string;
|
|
180
|
+
getStyleTag(options?: { id?: string; nonce?: string }): string;
|
|
181
|
+
reset(): void;
|
|
182
|
+
stats(): { ruleCount: number; uniqueCount: number; totalSize: number };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export declare function createSSRCollector(options?: SSRCollectorOptions): SSRCollector;
|
|
186
|
+
|
|
187
|
+
// ============================================================================
|
|
188
|
+
// Default Export
|
|
189
|
+
// ============================================================================
|
|
190
|
+
|
|
191
|
+
export default tw;
|