66} from "./transform-object/index" ;
77import type { ComplexStyleRule , StyleRule } from "@vanilla-extract/css" ;
88import type {
9+ CSSRule ,
910 ComplexCSSRule ,
1011 ComplexCSSItem ,
1112 ClassNames
@@ -19,15 +20,15 @@ export function transform(
1920 if ( Array . isArray ( style ) ) {
2021 const contexts : TransformContext [ ] = [ ] ;
2122 const results = style . map ( ( eachStyle ) => {
22- if ( isClassNames ( eachStyle ) ) {
23- return eachStyle ;
24- }
25- if ( typeof eachStyle === "function" ) {
26- return eachStyle ( ) ;
23+ const styleValue =
24+ typeof eachStyle === "function" ? eachStyle ( ) : eachStyle ;
25+
26+ if ( isClassNames ( styleValue ) ) {
27+ return styleValue ;
2728 }
2829
2930 const tempContext = structuredClone ( context ) ;
30- const result = transformStyle ( eachStyle , tempContext ) ;
31+ const result = transformStyle ( styleValue , tempContext ) ;
3132 contexts . push ( tempContext ) ;
3233 return result ;
3334 } ) ;
@@ -72,10 +73,16 @@ if (import.meta.vitest) {
7273 it ( "Functions" , ( ) => {
7374 const classNameFunctions = [
7475 ( ) => "myClassName1" ,
75- ( _arg : number ) => "myClassName2"
76+ ( _arg : number ) => "myClassName2" ,
77+ ( size = 10 ) =>
78+ ( { padding : size , margin : size , border : "none" } ) satisfies CSSRule
7679 ] ;
7780 const result = transform ( classNameFunctions ) ;
78- expect ( result ) . toStrictEqual ( [ "myClassName1" , "myClassName2" ] ) ;
81+ expect ( result ) . toStrictEqual ( [
82+ "myClassName1" ,
83+ "myClassName2" ,
84+ { padding : 10 , margin : 10 , border : "none" } satisfies CSSRule
85+ ] ) ;
7986 } ) ;
8087
8188 it ( "Style" , ( ) => {
0 commit comments