{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "workspace-switcher",
  "type": "registry:component",
  "title": "Workspace Switcher",
  "description": "Segmented workspace picker for switching between canvas views and operational contexts.",
  "dependencies": [
    "@vllnt/ui@^0.2.1"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/default/workspace-switcher/workspace-switcher.tsx",
      "content": "\"use client\";\n\nimport { forwardRef, useMemo, useState } from \"react\";\n\nimport { cn } from \"@vllnt/ui\";\n\nexport type WorkspaceOption = {\n  description?: string;\n  id: string;\n  label: string;\n};\n\nexport type WorkspaceSwitcherProps = Omit<\n  React.ComponentPropsWithoutRef<\"div\">,\n  \"defaultValue\" | \"onChange\"\n> & {\n  defaultValue?: string;\n  onValueChange?: (value: string) => void;\n  value?: string;\n  workspaces: WorkspaceOption[];\n};\n\nconst WorkspaceSwitcher = forwardRef<HTMLDivElement, WorkspaceSwitcherProps>(\n  (\n    { className, defaultValue, onValueChange, value, workspaces, ...props },\n    ref,\n  ) => {\n    const fallbackValue = defaultValue ?? workspaces[0]?.id ?? \"\";\n    const [internalValue, setInternalValue] = useState(fallbackValue);\n    const currentValue = value ?? internalValue;\n\n    const currentWorkspace = useMemo(\n      () => workspaces.find((workspace) => workspace.id === currentValue),\n      [currentValue, workspaces],\n    );\n\n    function handleSelect(nextValue: string) {\n      if (value === undefined) {\n        setInternalValue(nextValue);\n      }\n      onValueChange?.(nextValue);\n    }\n\n    return (\n      <div\n        className={cn(\n          \"inline-flex min-w-0 items-center gap-1 rounded-full border border-border/70 bg-muted/50 p-1\",\n          className,\n        )}\n        ref={ref}\n        role=\"radiogroup\"\n        {...props}\n      >\n        {workspaces.map((workspace) => {\n          const isActive = workspace.id === currentValue;\n          return (\n            <button\n              aria-checked={isActive}\n              className={cn(\n                \"rounded-full px-3 py-1.5 text-sm font-medium transition-colors\",\n                isActive\n                  ? \"bg-background text-foreground shadow-sm\"\n                  : \"text-muted-foreground hover:text-foreground\",\n              )}\n              key={workspace.id}\n              onClick={() => {\n                handleSelect(workspace.id);\n              }}\n              role=\"radio\"\n              title={workspace.description}\n              type=\"button\"\n            >\n              {workspace.label}\n            </button>\n          );\n        })}\n        {currentWorkspace?.description ? (\n          <span className=\"hidden pl-2 pr-1 text-xs text-muted-foreground md:inline\">\n            {currentWorkspace.description}\n          </span>\n        ) : null}\n      </div>\n    );\n  },\n);\n\nWorkspaceSwitcher.displayName = \"WorkspaceSwitcher\";\n\nexport { WorkspaceSwitcher };\n",
      "type": "registry:component"
    }
  ],
  "version": "0.2.1",
  "stability": "stable"
}
