flex container 1/2
This commit is contained in:
parent
56564ad1e5
commit
d4737dcae6
@ -233,10 +233,56 @@ export const LayoutContainerSchema: z.ZodType<LayoutContainer> = z.lazy(() => z.
|
||||
settings: ContainerSettingsSchema.optional()
|
||||
}));
|
||||
|
||||
// =========================================
|
||||
// Flexible Container (Row-based layout)
|
||||
// =========================================
|
||||
|
||||
export const ColumnDefSchema = z.object({
|
||||
width: z.number().default(1),
|
||||
unit: z.enum(['fr', 'px', 'rem', '%']).default('fr'),
|
||||
minWidth: z.number().optional(),
|
||||
});
|
||||
|
||||
export type ColumnDef = z.infer<typeof ColumnDefSchema>;
|
||||
|
||||
export const RowDefSchema = z.object({
|
||||
id: z.string(),
|
||||
columns: z.array(ColumnDefSchema).default([{ width: 1, unit: 'fr' }]),
|
||||
gap: z.number().optional(),
|
||||
sizing: z.enum(['constrained', 'unconstrained']).optional().default('constrained'),
|
||||
cellAlignments: z.array(z.enum(['stretch', 'start', 'center', 'end'])).optional(),
|
||||
});
|
||||
|
||||
export type RowDef = z.infer<typeof RowDefSchema>;
|
||||
|
||||
export type FlexibleContainer = {
|
||||
id: string;
|
||||
type: 'flex-container';
|
||||
rows: RowDef[];
|
||||
widgets: WidgetInstance[];
|
||||
gap: number;
|
||||
order?: number;
|
||||
settings?: ContainerSettings;
|
||||
};
|
||||
|
||||
export const FlexibleContainerSchema: z.ZodType<FlexibleContainer> = z.lazy(() => z.object({
|
||||
id: z.string(),
|
||||
type: z.literal('flex-container'),
|
||||
rows: z.array(RowDefSchema),
|
||||
widgets: z.array(WidgetInstanceSchema),
|
||||
gap: z.number().default(16),
|
||||
order: z.number().optional(),
|
||||
settings: ContainerSettingsSchema.optional()
|
||||
}));
|
||||
|
||||
// Union of all container types
|
||||
export type AnyContainer = LayoutContainer | FlexibleContainer;
|
||||
export const AnyContainerSchema = z.union([LayoutContainerSchema, FlexibleContainerSchema]);
|
||||
|
||||
export const PageLayoutSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
containers: z.array(LayoutContainerSchema),
|
||||
containers: z.array(AnyContainerSchema),
|
||||
createdAt: z.number(),
|
||||
updatedAt: z.number(),
|
||||
loadedBundles: z.array(z.string()).optional(),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user