import type { Story } from "@ladle/react"; import { useState } from "react"; import { PermissionGrid as Grid, type PermissionGridRow, } from "../src/blocks/permission-grid.js"; import { Switch } from "../src/components/switch.js"; const tools = [ { id: "browser", group: "Session", label: "Commands in the visitor's browser", }, { id: "goal", group: "Session", label: "Session goal tools" }, { id: "agents", group: "Agents", label: "List and prompt the Team's Agents" }, { id: "github", group: "Connections", label: "GitHub repository" }, { id: "computer", group: "Computers", label: "Computers and Home files" }, ] as const; /** A simple square mark standing in for a product sigil. */ function Mark({ filled }: Readonly<{ filled: boolean }>) { return ( ); } export const PermissionGrid: Story = () => { const [allowed, setAllowed] = useState>( new Set(["browser"]), ); const rows: PermissionGridRow[] = tools.map((tool) => { const on = allowed.has(tool.id); return { id: tool.id, group: tool.group, label: tool.label, mark: , state: on ? "allowed" : "denied", stateLabel: on ? "On" : "Off", scope: tool.id === "browser" ? "Default" : "Owner grant", control: ( { setAllowed((current) => { const next = new Set(current); if (checked) next.add(tool.id); else next.delete(tool.id); return next; }); }} /> ), }; }); return ( ); };