@@ -117,7 +117,10 @@ function styles<V extends VariantOptions<V>>(config: VariantStyleConfig<V>) {
117
117
} as VariantProps ;
118
118
119
119
// Apply variant styles
120
- for ( const [ propName , value ] of Object . entries ( mergedProps ) as [ keyof V , keyof VariantProps [ keyof V ] | boolean ] [ ] ) {
120
+ for ( const [ propName , value ] of Object . entries ( mergedProps ) as [
121
+ keyof V ,
122
+ keyof VariantProps [ keyof V ] | boolean ,
123
+ ] [ ] ) {
121
124
const variantGroup = config . variants [ propName ] ;
122
125
if ( variantGroup ) {
123
126
// Handle boolean variants
@@ -146,15 +149,13 @@ function styles<V extends VariantOptions<V>>(config: VariantStyleConfig<V>) {
146
149
if ( config . compoundVariants ) {
147
150
for ( const compound of config . compoundVariants ) {
148
151
if (
149
- Object . entries ( compound . variants ) . every (
150
- ( [ propName , value ] ) => {
151
- // Handle boolean values in compound variants
152
- if ( typeof value === 'boolean' ) {
153
- return mergedProps [ propName as keyof V ] === value ;
154
- }
152
+ Object . entries ( compound . variants ) . every ( ( [ propName , value ] ) => {
153
+ // Handle boolean values in compound variants
154
+ if ( typeof value === 'boolean' ) {
155
155
return mergedProps [ propName as keyof V ] === value ;
156
156
}
157
- )
157
+ return mergedProps [ propName as keyof V ] === value ;
158
+ } )
158
159
) {
159
160
styles = {
160
161
...styles ,
@@ -191,22 +192,25 @@ interface CreateTokensReturn {
191
192
192
193
// Helper to resolve token references in style objects
193
194
function resolveTokens ( style : StyleObject , tokens : TokenConfig ) : StyleObject {
194
- return Object . entries ( style ) . reduce < Record < string , ResolvedStyle [ keyof ResolvedStyle ] > > ( ( acc , [ key , value ] ) => {
195
- if ( typeof value !== 'string' || ! value . startsWith ( '$' ) ) {
196
- acc [ key ] = value ;
197
- return acc ;
198
- }
195
+ return Object . entries ( style ) . reduce < Record < string , ResolvedStyle [ keyof ResolvedStyle ] > > (
196
+ ( acc , [ key , value ] ) => {
197
+ if ( typeof value !== 'string' || ! value . startsWith ( '$' ) ) {
198
+ acc [ key ] = value ;
199
+ return acc ;
200
+ }
199
201
200
- const tokenPath = value . slice ( 1 ) . split ( '.' ) ;
201
- const [ category , token ] = tokenPath ;
202
+ const tokenPath = value . slice ( 1 ) . split ( '.' ) ;
203
+ const [ category , token ] = tokenPath ;
202
204
203
- const tokenValue = tokens [ category as keyof TokenConfig ] ?. [ token ] ;
204
- if ( tokenValue !== undefined ) {
205
- acc [ key ] = tokenValue ;
206
- }
205
+ const tokenValue = tokens [ category as keyof TokenConfig ] ?. [ token ] ;
206
+ if ( tokenValue !== undefined ) {
207
+ acc [ key ] = tokenValue ;
208
+ }
207
209
208
- return acc ;
209
- } , { } ) as StyleObject ;
210
+ return acc ;
211
+ } ,
212
+ { } ,
213
+ ) as StyleObject ;
210
214
}
211
215
212
216
/**
@@ -228,25 +232,24 @@ export function defineTokens<T extends TokenConfig>(tokenConfig: T): CreateToken
228
232
229
233
// Resolve tokens in variants
230
234
const resolvedVariants = config . variants
231
- ? Object . entries ( config . variants ) . reduce < Partial < V > > ( ( acc , [ key , variantGroup ] ) => {
235
+ ? ( Object . entries ( config . variants ) . reduce < Partial < V > > ( ( acc , [ key , variantGroup ] ) => {
232
236
type VariantGroupType = Record < string , StyleObject > ;
233
-
234
- const resolvedGroup = Object . entries ( variantGroup as VariantGroupType ) . reduce < Record < string , StyleObject > > (
235
- ( groupAcc , [ variantKey , variantStyles ] ) => {
236
- return {
237
- ...groupAcc ,
238
- [ variantKey ] : resolveTokens ( variantStyles , tokens ) ,
239
- } ;
240
- } ,
241
- { }
242
- ) ;
243
-
244
- return {
245
- ...acc ,
246
- [ key as keyof V ] : resolvedGroup as V [ keyof V ]
237
+
238
+ const resolvedGroup = Object . entries ( variantGroup as VariantGroupType ) . reduce <
239
+ Record < string , StyleObject >
240
+ > ( ( groupAcc , [ variantKey , variantStyles ] ) => {
241
+ return {
242
+ ...groupAcc ,
243
+ [ variantKey ] : resolveTokens ( variantStyles , tokens ) ,
244
+ } ;
245
+ } , { } ) ;
246
+
247
+ return {
248
+ ...acc ,
249
+ [ key as keyof V ] : resolvedGroup as V [ keyof V ] ,
247
250
} ;
248
- } , { } ) as V
249
- : { } as V ;
251
+ } , { } ) as V )
252
+ : ( { } as V ) ;
250
253
251
254
// Resolve tokens in compound variants
252
255
const resolvedCompoundVariants = config . compoundVariants ?. map ( ( compound ) => ( {
0 commit comments