@melcanz85/chaincss 1.11.4 → 1.12.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 +3 -2
- package/node/atomic-optimizer.js +275 -88
- package/node/btt.js +587 -150
- package/node/chaincss.js +189 -65
- package/node/strVal.js +2 -2
- package/package.json +69 -35
- package/types.d.ts +175 -61
package/types.d.ts
CHANGED
|
@@ -1,78 +1,65 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
|
|
3
3
|
declare module '@melcanz85/chaincss' {
|
|
4
|
-
//
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Core Types
|
|
6
|
+
// ============================================================================
|
|
7
|
+
|
|
5
8
|
export interface StyleDefinition {
|
|
6
9
|
selectors: string[];
|
|
10
|
+
hover?: Record<string, string | number>;
|
|
7
11
|
[cssProperty: string]: any;
|
|
8
12
|
}
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
export interface CSSPropertyBuilder {
|
|
13
|
+
|
|
14
|
+
export interface ChainBuilder {
|
|
15
|
+
// CSS Properties - dynamic
|
|
13
16
|
[key: string]: (value: string | number) => ChainBuilder;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export interface SpecialMethods {
|
|
17
|
+
|
|
18
|
+
// Special Methods
|
|
17
19
|
block(...selectors: string[]): StyleDefinition;
|
|
20
|
+
hover(): ChainBuilder;
|
|
21
|
+
end(): ChainBuilder;
|
|
18
22
|
token?(path: string): ChainBuilder;
|
|
23
|
+
|
|
24
|
+
// At-Rules
|
|
25
|
+
media(query: string, cb: (chain: ChainBuilder) => void): ChainBuilder;
|
|
26
|
+
keyframes(name: string, cb: (keyframes: KeyframeBuilder) => void): ChainBuilder;
|
|
27
|
+
fontFace(cb: (chain: ChainBuilder) => void): ChainBuilder;
|
|
28
|
+
supports(condition: string, cb: (chain: ChainBuilder) => void): ChainBuilder;
|
|
29
|
+
container(condition: string, cb: (chain: ChainBuilder) => void): ChainBuilder;
|
|
30
|
+
layer(name: string, cb: (chain: ChainBuilder) => void): ChainBuilder;
|
|
31
|
+
counterStyle(name: string, cb: (chain: ChainBuilder) => void): ChainBuilder;
|
|
32
|
+
property(name: string, cb: (chain: ChainBuilder) => void): ChainBuilder;
|
|
33
|
+
|
|
34
|
+
// Selector shortcut
|
|
35
|
+
$(selector: string): ChainBuilder;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface KeyframeBuilder {
|
|
39
|
+
from(styles: Record<string, string>): KeyframeBuilder;
|
|
40
|
+
to(styles: Record<string, string>): KeyframeBuilder;
|
|
41
|
+
[percentage: string]: ((styles: Record<string, string>) => KeyframeBuilder) | any;
|
|
19
42
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
43
|
+
|
|
44
|
+
// ============================================================================
|
|
45
|
+
// Core Functions
|
|
46
|
+
// ============================================================================
|
|
47
|
+
|
|
48
|
+
export function $(useTokens?: boolean): ChainBuilder;
|
|
25
49
|
export function run(...styles: StyleDefinition[]): string;
|
|
26
|
-
// Compile function for objects
|
|
27
50
|
export function compile(styles: Record<string, StyleDefinition>): void;
|
|
28
|
-
// Get function for importing (VM-safe version)
|
|
29
51
|
export function get(filename: string): any;
|
|
30
|
-
|
|
52
|
+
|
|
31
53
|
export const chain: {
|
|
32
54
|
cssOutput: string;
|
|
33
55
|
catcher: any;
|
|
34
56
|
cachedValidProperties: string[];
|
|
35
57
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export interface AtomicConfig {
|
|
42
|
-
enabled?: boolean;
|
|
43
|
-
threshold?: number;
|
|
44
|
-
naming?: 'hash' | 'readable' | 'short';
|
|
45
|
-
cache?: boolean;
|
|
46
|
-
cachePath?: string;
|
|
47
|
-
minify?: boolean;
|
|
48
|
-
}
|
|
49
|
-
// Prefixer configuration
|
|
50
|
-
export interface PrefixerConfig {
|
|
51
|
-
mode?: 'auto' | 'full';
|
|
52
|
-
browsers?: string[];
|
|
53
|
-
enabled?: boolean;
|
|
54
|
-
sourceMap?: boolean;
|
|
55
|
-
sourceMapInline?: boolean;
|
|
56
|
-
}
|
|
57
|
-
// ChainCSS configuration
|
|
58
|
-
export interface ChainCSSConfig {
|
|
59
|
-
atomic?: AtomicConfig;
|
|
60
|
-
prefixer?: PrefixerConfig;
|
|
61
|
-
sourceMaps?: boolean;
|
|
62
|
-
}
|
|
63
|
-
// Function to configure ChainCSS
|
|
64
|
-
export function configure(config: ChainCSSConfig): void;
|
|
65
|
-
// Atomic optimizer instance
|
|
66
|
-
export const atomicOptimizer: {
|
|
67
|
-
optimize(styles: Record<string, StyleDefinition>): string;
|
|
68
|
-
getStats(): {
|
|
69
|
-
totalStyles: number;
|
|
70
|
-
atomicStyles: number;
|
|
71
|
-
uniqueProperties: number;
|
|
72
|
-
savings?: string;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
// Token system types
|
|
58
|
+
|
|
59
|
+
// ============================================================================
|
|
60
|
+
// Token System
|
|
61
|
+
// ============================================================================
|
|
62
|
+
|
|
76
63
|
export interface Tokens {
|
|
77
64
|
colors: Record<string, string | Record<string, string>>;
|
|
78
65
|
spacing: Record<string, string>;
|
|
@@ -87,39 +74,166 @@ declare module '@melcanz85/chaincss' {
|
|
|
87
74
|
shadows: Record<string, string>;
|
|
88
75
|
borderRadius: Record<string, string>;
|
|
89
76
|
}
|
|
77
|
+
|
|
90
78
|
export class DesignTokens {
|
|
91
79
|
constructor(tokens: Partial<Tokens>);
|
|
92
80
|
get(path: string, defaultValue?: string): string;
|
|
93
81
|
toCSSVariables(prefix?: string): string;
|
|
94
82
|
createTheme(name: string, overrides: Record<string, any>): DesignTokens;
|
|
95
83
|
}
|
|
84
|
+
|
|
96
85
|
export const tokens: DesignTokens;
|
|
97
86
|
export function createTokens(customTokens: Partial<Tokens>): DesignTokens;
|
|
98
87
|
export function responsive(values: Record<string, string> | string): string;
|
|
99
|
-
|
|
88
|
+
|
|
89
|
+
// ============================================================================
|
|
90
|
+
// React Integration
|
|
91
|
+
// ============================================================================
|
|
92
|
+
|
|
100
93
|
export interface UseChainStylesOptions {
|
|
101
94
|
cache?: boolean;
|
|
102
95
|
namespace?: string;
|
|
103
96
|
watch?: boolean;
|
|
104
97
|
}
|
|
98
|
+
|
|
105
99
|
export function useChainStyles(
|
|
106
100
|
styles: Record<string, any> | (() => Record<string, any>),
|
|
101
|
+
deps?: any[],
|
|
107
102
|
options?: UseChainStylesOptions
|
|
108
103
|
): Record<string, string>;
|
|
104
|
+
|
|
109
105
|
export function useDynamicChainStyles(
|
|
110
106
|
styleFactory: () => Record<string, any>,
|
|
111
107
|
deps?: any[],
|
|
112
108
|
options?: UseChainStylesOptions
|
|
113
109
|
): Record<string, string>;
|
|
110
|
+
|
|
114
111
|
export function useThemeChainStyles(
|
|
115
112
|
styles: Record<string, any> | ((theme: any) => Record<string, any>),
|
|
116
113
|
theme: any,
|
|
114
|
+
deps?: any[],
|
|
117
115
|
options?: UseChainStylesOptions
|
|
118
116
|
): Record<string, string>;
|
|
117
|
+
|
|
119
118
|
export const ChainCSSGlobal: React.FC<{ styles: Record<string, any> }>;
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
|
|
120
|
+
export function withChainStyles<P extends object>(
|
|
121
|
+
styles: Record<string, any> | ((props: P) => Record<string, any>),
|
|
122
122
|
options?: UseChainStylesOptions
|
|
123
|
-
):
|
|
123
|
+
): (Component: React.ComponentType<P>) => React.FC<P & { chainStyles?: Record<string, string> }>;
|
|
124
|
+
|
|
124
125
|
export function cx(...classes: (string | undefined | null | false)[]): string;
|
|
125
|
-
|
|
126
|
+
|
|
127
|
+
// ============================================================================
|
|
128
|
+
// Configuration
|
|
129
|
+
// ============================================================================
|
|
130
|
+
|
|
131
|
+
export interface AtomicConfig {
|
|
132
|
+
enabled?: boolean;
|
|
133
|
+
threshold?: number;
|
|
134
|
+
naming?: 'hash' | 'readable' | 'short';
|
|
135
|
+
cache?: boolean;
|
|
136
|
+
cachePath?: string;
|
|
137
|
+
minify?: boolean;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface PrefixerConfig {
|
|
141
|
+
mode?: 'auto' | 'full';
|
|
142
|
+
browsers?: string[];
|
|
143
|
+
enabled?: boolean;
|
|
144
|
+
sourceMap?: boolean;
|
|
145
|
+
sourceMapInline?: boolean;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface ChainCSSConfig {
|
|
149
|
+
atomic?: AtomicConfig;
|
|
150
|
+
prefixer?: PrefixerConfig;
|
|
151
|
+
sourceMaps?: boolean;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function configure(config: ChainCSSConfig): void;
|
|
155
|
+
|
|
156
|
+
export const atomicOptimizer: {
|
|
157
|
+
optimize(styles: Record<string, StyleDefinition>): string;
|
|
158
|
+
getStats(): {
|
|
159
|
+
totalStyles: number;
|
|
160
|
+
atomicStyles: number;
|
|
161
|
+
uniqueProperties: number;
|
|
162
|
+
savings?: string;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// ============================================================================
|
|
167
|
+
// Build Tools (Node.js)
|
|
168
|
+
// ============================================================================
|
|
169
|
+
|
|
170
|
+
export function processor(inputFile: string, outputFile: string): Promise<void>;
|
|
171
|
+
export function watch(inputFile: string, outputFile: string): void;
|
|
172
|
+
|
|
173
|
+
// ============================================================================
|
|
174
|
+
// Vite Plugin
|
|
175
|
+
// ============================================================================
|
|
176
|
+
|
|
177
|
+
export interface VitePluginOptions {
|
|
178
|
+
extension?: string;
|
|
179
|
+
minify?: boolean;
|
|
180
|
+
prefix?: boolean;
|
|
181
|
+
hmr?: boolean;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function vitePlugin(options?: VitePluginOptions): any;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// ============================================================================
|
|
188
|
+
// Vite Plugin Subpath Export
|
|
189
|
+
// ============================================================================
|
|
190
|
+
|
|
191
|
+
declare module '@melcanz85/chaincss/vite-plugin' {
|
|
192
|
+
import { Plugin } from 'vite';
|
|
193
|
+
import { VitePluginOptions } from '@melcanz85/chaincss';
|
|
194
|
+
|
|
195
|
+
export default function chaincssVite(options?: VitePluginOptions): Plugin;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// ============================================================================
|
|
199
|
+
// React Subpath Export
|
|
200
|
+
// ============================================================================
|
|
201
|
+
|
|
202
|
+
declare module '@melcanz85/chaincss/react' {
|
|
203
|
+
export * from '@melcanz85/chaincss';
|
|
204
|
+
|
|
205
|
+
// Re-export React-specific hooks
|
|
206
|
+
export const useChainStyles: typeof import('@melcanz85/chaincss').useChainStyles;
|
|
207
|
+
export const useDynamicChainStyles: typeof import('@melcanz85/chaincss').useDynamicChainStyles;
|
|
208
|
+
export const useThemeChainStyles: typeof import('@melcanz85/chaincss').useThemeChainStyles;
|
|
209
|
+
export const ChainCSSGlobal: typeof import('@melcanz85/chaincss').ChainCSSGlobal;
|
|
210
|
+
export const withChainStyles: typeof import('@melcanz85/chaincss').withChainStyles;
|
|
211
|
+
export const cx: typeof import('@melcanz85/chaincss').cx;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// ============================================================================
|
|
215
|
+
// Recipe - Variants
|
|
216
|
+
// ============================================================================
|
|
217
|
+
|
|
218
|
+
export interface RecipeOptions<TVariants extends Record<string, Record<string, any>>> {
|
|
219
|
+
base?: StyleDefinition;
|
|
220
|
+
variants?: TVariants;
|
|
221
|
+
defaultVariants?: Partial<{ [K in keyof TVariants]: keyof TVariants[K] }>;
|
|
222
|
+
compoundVariants?: Array<{
|
|
223
|
+
variants: Partial<{ [K in keyof TVariants]: keyof TVariants[K] }>;
|
|
224
|
+
style: StyleDefinition;
|
|
225
|
+
}>;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export type Recipe<TVariants extends Record<string, Record<string, any>>> = {
|
|
229
|
+
(selection?: Partial<{ [K in keyof TVariants]: keyof TVariants[K] }>): StyleDefinition;
|
|
230
|
+
variants: TVariants;
|
|
231
|
+
defaultVariants: Partial<{ [K in keyof TVariants]: keyof TVariants[K] }>;
|
|
232
|
+
base: StyleDefinition;
|
|
233
|
+
getAllVariants: () => Array<Partial<{ [K in keyof TVariants]: keyof TVariants[K] }>>;
|
|
234
|
+
compileAll: () => string;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export function recipe<TVariants extends Record<string, Record<string, any>>>(
|
|
238
|
+
options: RecipeOptions<TVariants>
|
|
239
|
+
): Recipe<TVariants>;
|