@hanzo/ui

BranchSelect

import { BranchSelect, branchName } from '@hanzo/ui/product'

The branch a run starts from

Rows may be bare names or `{ name }`, whichever the host's API answers.

export function Default() {
  const [branch, setBranch] = useState('main')
  return (
    <XStack pt={240}>
      <BranchSelect
        value={branch}
        onChange={setBranch}
        load={async (q) => ({ branches: BRANCHES.filter((b) => b.includes(q)).map((name) => ({ name })) })}
      />
    </XStack>
  )
}

Types

export type Branch = string | { name: string }
export type BranchLoad = (q: string, after?: string | null) => Promise<{ branches: Branch[]; next?: string | null }>
export interface BranchSelectProps {
  /** The chosen branch. */
  value?: string | null
  onChange: (branch: string) => void
  load: BranchLoad
  /** Under the list — why a branch might be missing. */
  footer?: ReactNode
  placement?: ChipPlacement
  disabled?: boolean
  open?: boolean
  onOpenChange?: (open: boolean) => void
}

Exports

BranchSelectbranchNametype Branchtype BranchLoadtype BranchSelectProps