@@ -50,13 +50,27 @@ const GAPS: Record<number, string> = {
5050ComponentRegistry . register ( 'grid' ,
5151 ( { schema, className, ...props } : { schema : GridSchema & { smColumns ?: number , mdColumns ?: number , lgColumns ?: number , xlColumns ?: number } ; className ?: string ; [ key : string ] : any } ) => {
5252 // Determine columns configuration
53- // Supports direct number or responsive object logic if schema allows,
54- // but here we primarily handle the flat properties supported by the designer inputs
55- const baseCols = typeof schema . columns === 'number' ? schema . columns : 2 ;
56- const smCols = schema . smColumns ;
57- const mdCols = schema . mdColumns ;
58- const lgCols = schema . lgColumns ;
59- const xlCols = schema . xlColumns ;
53+ // Supports detailed object configuration from schema
54+ let baseCols = 2 ;
55+ let smCols , mdCols , lgCols , xlCols ;
56+
57+ if ( typeof schema . columns === 'number' ) {
58+ baseCols = schema . columns ;
59+ } else if ( typeof schema . columns === 'object' && schema . columns !== null ) {
60+ // Handle responsive object: { xs: 1, sm: 2, md: 3, lg: 4 }
61+ // Note: 'xs' corresponds to base (mobile-first)
62+ baseCols = schema . columns . xs ?? 1 ;
63+ smCols = schema . columns . sm ;
64+ mdCols = schema . columns . md ;
65+ lgCols = schema . columns . lg ;
66+ xlCols = schema . columns . xl ;
67+ }
68+
69+ // Fallback to legacy flat props if provided (from designer)
70+ if ( schema . smColumns ) smCols = schema . smColumns ;
71+ if ( schema . mdColumns ) mdCols = schema . mdColumns ;
72+ if ( schema . lgColumns ) lgCols = schema . lgColumns ;
73+ if ( schema . xlColumns ) xlCols = schema . xlColumns ;
6074
6175 const gap = schema . gap ?? 4 ;
6276
@@ -71,7 +85,7 @@ ComponentRegistry.register('grid',
7185 lgCols && GRID_COLS_LG [ lgCols ] ,
7286 xlCols && GRID_COLS_XL [ xlCols ] ,
7387 // Gap
74- GAPS [ gap ] || ' gap-4' ,
88+ GAPS [ gap ] || ` gap-[ ${ gap * 0.25 } rem]` , // Fallback for arbitrary values if not in map
7589 className
7690 ) ;
7791
0 commit comments