d8a914bf2a
Add collapse/expand toggle for the AppShell navigation sidebar and the editor properties panel (both persisted to localStorage). Bundles other in-progress editor work including position anchors, outlet sizing, PBR textures, window slope/frame depth, curtain metadata, and various 2D/3D rendering tweaks.
50 lines
2.2 KiB
TypeScript
50 lines
2.2 KiB
TypeScript
import { z } from 'zod';
|
|
import { FLOOR_TYPES, WALL_FINISHES } from '../types/room.js';
|
|
|
|
const floorTypeEnum = z.enum(FLOOR_TYPES);
|
|
const wallFinishEnum = z.enum(WALL_FINISHES);
|
|
|
|
const pointSchema = z.object({
|
|
x: z.number(),
|
|
y: z.number(),
|
|
});
|
|
|
|
export const createRoomSchema = z.object({
|
|
name: z.string().min(1, 'Name is required').max(255),
|
|
shape: z.array(pointSchema).optional(),
|
|
width: z.number().positive('Width must be positive').nullish(),
|
|
height: z.number().positive('Height must be positive').nullish(),
|
|
wallHeight: z.number().positive('Wall height must be positive').optional(),
|
|
plinthHeight: z.number().min(0, 'Plinth height must be non-negative').optional(),
|
|
plinthThickness: z.number().min(0, 'Plinth thickness must be non-negative').optional(),
|
|
order: z.number().int().min(0).optional(),
|
|
posX: z.number().optional(),
|
|
posY: z.number().optional(),
|
|
floorType: floorTypeEnum.optional(),
|
|
wallColor: z.string().max(20).optional(),
|
|
wallFinish: wallFinishEnum.optional(),
|
|
outletWidth: z.number().positive('Outlet width must be positive').optional(),
|
|
outletHeight: z.number().positive('Outlet height must be positive').optional(),
|
|
});
|
|
|
|
export const updateRoomSchema = z.object({
|
|
name: z.string().min(1, 'Name is required').max(255).optional(),
|
|
shape: z.array(pointSchema).optional(),
|
|
width: z.number().positive('Width must be positive').nullish(),
|
|
height: z.number().positive('Height must be positive').nullish(),
|
|
wallHeight: z.number().positive('Wall height must be positive').optional(),
|
|
plinthHeight: z.number().min(0, 'Plinth height must be non-negative').optional(),
|
|
plinthThickness: z.number().min(0, 'Plinth thickness must be non-negative').optional(),
|
|
order: z.number().int().min(0).optional(),
|
|
posX: z.number().optional(),
|
|
posY: z.number().optional(),
|
|
floorType: floorTypeEnum.optional(),
|
|
wallColor: z.string().max(20).optional(),
|
|
wallFinish: wallFinishEnum.optional(),
|
|
outletWidth: z.number().positive('Outlet width must be positive').optional(),
|
|
outletHeight: z.number().positive('Outlet height must be positive').optional(),
|
|
});
|
|
|
|
export type CreateRoomInput = z.infer<typeof createRoomSchema>;
|
|
export type UpdateRoomInput = z.infer<typeof updateRoomSchema>;
|