gridstack_will_it_fit
Check if a widget fits at specified coordinates in a dashboard grid layout. Verify placement without overlaps before adding widgets to ensure proper positioning.
Instructions
Check if a widget will fit at specified position
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| widget | Yes |
Implementation Reference
- src/tools/index.ts:1061-1072 (handler)Core handler function for the 'gridstack_will_it_fit' tool. Destructures the widget parameters and generates JavaScript code that calls GridStack's built-in 'willItFit' method to check if a widget fits at the specified position without collisions.private async willItFit(params: any): Promise<string> { const { widget } = params; return this.utils.generateGridStackCode("willItFit", { widget, code: `const willFit = grid.willItFit(${JSON.stringify( widget, null, 2 )});`, }); }
- src/tools/index.ts:521-544 (registration)Registration of the 'gridstack_will_it_fit' tool in the listTools() method of GridStackTools class, including detailed input schema for validation.{ name: "gridstack_will_it_fit", description: "Check if a widget will fit at specified position", inputSchema: { type: "object", required: ["widget"], properties: { widget: { type: "object", required: ["x", "y", "w", "h"], properties: { x: { type: "number", description: "X position" }, y: { type: "number", description: "Y position" }, w: { type: "number", description: "Width" }, h: { type: "number", description: "Height" }, id: { oneOf: [{ type: "string" }, { type: "number" }], description: "Widget ID to ignore in collision check", }, }, }, }, }, },
- src/tools/index.ts:822-823 (handler)Dispatch handler in the callTool method's switch statement that invokes the specific willItFit handler for this tool.case "gridstack_will_it_fit": return this.willItFit(args);
- src/tools/index.ts:524-543 (schema)Input schema definition specifying the required 'widget' object with position (x,y), size (w,h), and optional id for collision checking.inputSchema: { type: "object", required: ["widget"], properties: { widget: { type: "object", required: ["x", "y", "w", "h"], properties: { x: { type: "number", description: "X position" }, y: { type: "number", description: "Y position" }, w: { type: "number", description: "Width" }, h: { type: "number", description: "Height" }, id: { oneOf: [{ type: "string" }, { type: "number" }], description: "Widget ID to ignore in collision check", }, }, }, }, },
- src/resources/index.ts:178-178 (helper)Documentation reference to the tool in the API documentation resource.- \`gridstack_will_it_fit\` - Check widget fit