1- import type { ComponentConfig } from "@puckeditor/core" ;
1+ import type { ComponentConfig , Slot , SlotComponent } from "@puckeditor/core" ;
22import { defineProps , responsive , field } from "@/lib/puck/define-props" ;
33import { columnCount , gap , type ColumnCount , type Spacing } from "@/lib/puck/tokens" ;
44import type { ResponsiveValue } from "@/lib/puck/responsive" ;
@@ -7,7 +7,7 @@ import { getGridClassName, getMaxCols } from "@/lib/puck/layout";
77type SlotKey = `column${ColumnCount } `;
88
99type ColumnsProps = {
10- [ K in SlotKey ] : any ;
10+ [ K in SlotKey ] : Slot ;
1111} & {
1212 columns : ResponsiveValue < ColumnCount > ;
1313 gap : ResponsiveValue < Spacing > ;
@@ -22,6 +22,10 @@ const columnSlotFields = Object.fromEntries(
2222 columnSlotKeys . map ( ( key ) => [ key , slotField ] ) ,
2323) as Record < SlotKey , typeof slotField > ;
2424
25+ const columnSlotDefaults = Object . fromEntries (
26+ columnSlotKeys . map ( ( key ) => [ key , [ ] as Slot ] ) ,
27+ ) as Record < SlotKey , Slot > ;
28+
2529const props = defineProps ( {
2630 columns : responsive . token ( columnCount , { label : "Columns" , default : { base : "1" , md : "2" } } ) ,
2731 gap : responsive . token ( gap , { label : "Gap" , default : "md" } ) ,
@@ -30,7 +34,7 @@ const props = defineProps({
3034export const Columns : ComponentConfig < ColumnsProps > = {
3135 label : "Columns" ,
3236 fields : { ...columnSlotFields , ...props . fields } ,
33- defaultProps : props . defaultProps as ColumnsProps ,
37+ defaultProps : { ... columnSlotDefaults , ... props . defaultProps } ,
3438 // Hide column slot fields that exceed the selected column count,
3539 // so the editor sidebar only shows slots that are actually rendered.
3640 resolveFields : ( data ) => {
@@ -46,7 +50,7 @@ export const Columns: ComponentConfig<ColumnsProps> = {
4650 } ,
4751 render : ( { columns, gap, ...slots } ) => {
4852 const maxCols = getMaxCols ( columns ) ;
49- const slotMap = slots as Record < SlotKey , any > ;
53+ const slotMap = slots as Record < SlotKey , SlotComponent > ;
5054
5155 return (
5256 < div className = { getGridClassName ( { columns, rows : { base : "auto" } , gap } ) } >
0 commit comments