UNPKG

@jupiterone/jupiterone-mcp

Version:

Model Context Protocol server for JupiterOne account rules and rule details

70 lines 2.51 kB
"use strict"; // Auto-layout for update-dashboard. Agents are demonstrably bad at hand-packing a 12-column grid // across five responsive breakpoints, so this computes the full layout from an ordered list of // widget IDs (with optional sizes). The grid-unit conventions are read off the update-dashboard.md // inspiration example rather than invented: // - Multi-column breakpoints (md/lg/xl) use a 12-column grid; that example's `lg` widths span // 4–12 units at height 2. // - Single-column breakpoints (xs/sm) stack every widget at x=0; that example's `sm` items use // w=1/h=1 for compact widgets and w=2/h=2 for larger ones. Object.defineProperty(exports, "__esModule", { value: true }); exports.computeAutoLayout = computeAutoLayout; const MULTI_COLUMN_UNITS = { small: { w: 4, h: 2 }, medium: { w: 6, h: 2 }, large: { w: 8, h: 2 }, full: { w: 12, h: 2 }, }; const SINGLE_COLUMN_UNITS = { small: { w: 1, h: 1 }, medium: { w: 2, h: 2 }, large: { w: 2, h: 2 }, full: { w: 2, h: 2 }, }; const GRID_COLUMNS = 12; const DEFAULT_SIZE = 'medium'; function normalize(item) { if (typeof item === 'string') return { id: item, size: DEFAULT_SIZE }; return { id: item.id, size: item.size ?? DEFAULT_SIZE }; } /** Left-to-right, top-to-bottom row fill across a 12-column grid. */ function multiColumn(items) { let x = 0; let y = 0; let rowHeight = 0; return items.map(({ id, size }) => { const { w, h } = MULTI_COLUMN_UNITS[size]; if (x + w > GRID_COLUMNS) { y += rowHeight; x = 0; rowHeight = 0; } const entry = { i: id, x, y, w, h, moved: false, static: false }; x += w; rowHeight = Math.max(rowHeight, h); return entry; }); } /** Every widget stacked in a single column (x=0). */ function singleColumn(items) { let y = 0; return items.map(({ id, size }) => { const { w, h } = SINGLE_COLUMN_UNITS[size]; const entry = { i: id, x: 0, y, w, h, moved: false, static: false }; y += h; return entry; }); } /** Compute all five breakpoints from an ordered widget list. */ function computeAutoLayout(items) { const normalized = items.map(normalize); return { xs: singleColumn(normalized), sm: singleColumn(normalized), md: multiColumn(normalized), lg: multiColumn(normalized), xl: multiColumn(normalized), }; } //# sourceMappingURL=dashboard-layout.js.map