@@ -117,7 +117,10 @@ function styles<V extends VariantOptions<V>>(config: VariantStyleConfig<V>) {
117117 } as VariantProps ;
118118
119119 // 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+ ] [ ] ) {
121124 const variantGroup = config . variants [ propName ] ;
122125 if ( variantGroup ) {
123126 // Handle boolean variants
@@ -146,15 +149,13 @@ function styles<V extends VariantOptions<V>>(config: VariantStyleConfig<V>) {
146149 if ( config . compoundVariants ) {
147150 for ( const compound of config . compoundVariants ) {
148151 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' ) {
155155 return mergedProps [ propName as keyof V ] === value ;
156156 }
157- )
157+ return mergedProps [ propName as keyof V ] === value ;
158+ } )
158159 ) {
159160 styles = {
160161 ...styles ,
@@ -191,22 +192,25 @@ interface CreateTokensReturn {
191192
192193// Helper to resolve token references in style objects
193194function 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+ }
199201
200- const tokenPath = value . slice ( 1 ) . split ( '.' ) ;
201- const [ category , token ] = tokenPath ;
202+ const tokenPath = value . slice ( 1 ) . split ( '.' ) ;
203+ const [ category , token ] = tokenPath ;
202204
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+ }
207209
208- return acc ;
209- } , { } ) as StyleObject ;
210+ return acc ;
211+ } ,
212+ { } ,
213+ ) as StyleObject ;
210214}
211215
212216/**
@@ -228,25 +232,24 @@ export function defineTokens<T extends TokenConfig>(tokenConfig: T): CreateToken
228232
229233 // Resolve tokens in variants
230234 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 ] ) => {
232236 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 ] ,
247250 } ;
248- } , { } ) as V
249- : { } as V ;
251+ } , { } ) as V )
252+ : ( { } as V ) ;
250253
251254 // Resolve tokens in compound variants
252255 const resolvedCompoundVariants = config . compoundVariants ?. map ( ( compound ) => ( {
0 commit comments