# Components Examples

---

## Accordion

```tsx
<Accordion
  type="single"
  items={[
    { value: 'item-1', title: 'Título 1', content: 'Conteúdo 1' },
    { value: 'item-2', title: 'Título 2', content: 'Conteúdo 2' },
  ]}
  defaultValue="item-1"
  collapsible
/>
```

---

## AlertBanner

```tsx
<AlertBanner
  title="Atenção! Verifique as informações."
  variant="alert"
  type="strong"
  size="md"
  onClose={() => {}}
/>
```

---

## AutoCompleteSelect

```tsx
<AutoCompleteSelect
  label="Buscar cidade"
  placeholder="Digite para buscar..."
  value={value}
  onChange={setValue}
  onInputChange={handleSearch}
  options={options}
  loading={loading}
  size="md"
/>
```

---

## Avatar

```tsx
// --- imageType: photo ---

// Padrão — circle, tamanho 48
<Avatar imageType="photo" src="https://example.com/photo.jpg" size="48" shape="circle" state="default" />

// Square
<Avatar imageType="photo" src="https://example.com/photo.jpg" size="48" shape="square" state="default" />

// Estado disabled
<Avatar imageType="photo" src="https://example.com/photo.jpg" size="48" shape="circle" state="disabled" />

// Estado focus
<Avatar imageType="photo" src="https://example.com/photo.jpg" size="48" shape="circle" state="focus" />

// Todos os tamanhos (24 | 32 | 48 | 64 | 80 | 160)
<Avatar imageType="photo" src="https://example.com/photo.jpg" size="24" shape="circle" />
<Avatar imageType="photo" src="https://example.com/photo.jpg" size="32" shape="circle" />
<Avatar imageType="photo" src="https://example.com/photo.jpg" size="48" shape="circle" />
<Avatar imageType="photo" src="https://example.com/photo.jpg" size="64" shape="circle" />
<Avatar imageType="photo" src="https://example.com/photo.jpg" size="80" shape="circle" />
<Avatar imageType="photo" src="https://example.com/photo.jpg" size="160" shape="circle" />

// --- imageType: initials ---f

// Iniciais padrão (background usa token --t_avatar-bg_color / red-500 light, red-400 dark)
<Avatar imageType="initials" initials="AB" size="48" shape="circle" state="default" />

// Iniciais com fundo personalizado (backgroundColor só funciona com imageType="initials" ou "icon")
<Avatar imageType="initials" initials="JS" size="64" shape="square" backgroundColor="#3b82f6" />

// --- imageType: icon ---

// Ícone como ReactNode
<Avatar imageType="icon" icon={<UserIcon />} size="48" shape="circle" />

// Ícone com fundo personalizado
<Avatar imageType="icon" icon={<UserIcon />} size="64" shape="circle" backgroundColor="#8b5cf6" />

// Ícone como string (URL)
<Avatar imageType="icon" icon="https://example.com/icon.svg" size="48" shape="circle" />

// --- Badge (canto superior) ---

// Badge automático — tamanho definido pelo size do avatar: sm para 24/32, md para 48/64, lg para 80/160
<Avatar
  imageType="photo"
  src="https://example.com/photo.jpg"
  size="64"
  shape="circle"
  badge={{ count: 5 }}
/>

// Badge com variant e size explícito
<Avatar
  imageType="photo"
  src="https://example.com/photo.jpg"
  size="64"
  shape="circle"
  badge={{ count: 12, variant: 'error', size: 'lg' }}
/>

// --- Presence indicator (canto inferior) ---

// Presença com cor padrão (green-600)
<Avatar
  imageType="photo"
  src="https://example.com/photo.jpg"
  size="64"
  shape="circle"
  presence={true}
/>

// Presença com cor personalizada
<Avatar
  imageType="photo"
  src="https://example.com/photo.jpg"
  size="64"
  shape="circle"
  presence={true}
  presenceColor="#ef4444"
/>

// --- Badge + presença juntos ---

// Lado direito (padrão): badge no canto superior direito, presença no canto inferior direito
<Avatar
  imageType="photo"
  src="https://example.com/photo.jpg"
  size="64"
  shape="circle"
  badge={{ count: 3 }}
  presence={true}
/>

// Lado esquerdo: badge no canto superior esquerdo, presença no canto inferior esquerdo
<Avatar
  imageType="photo"
  src="https://example.com/photo.jpg"
  size="64"
  shape="circle"
  badge={{ count: 2 }}
  presence={true}
  indicatorSide="left"
/>

// --- Alt acessível ---

// Sempre passe alt quando o avatar representa uma pessoa específica
<Avatar
  imageType="photo"
  src="https://example.com/photo.jpg"
  alt="Foto de João Silva"
  size="48"
  shape="circle"
/>
```

---

## Badge

```tsx
<Badge type="number" count={42} variant="accent" size="md" />
```

---

## BigNumber

```tsx
<BigNumber type="currency" value={1500} labelTop="Receita diária" labelBottom="Hoje" size="md" />
```

---

## BottomNavigation

```tsx
<BottomNavigation
  items={[
    { id: 'home', label: 'Home', icon: <HomeIcon /> },
    { id: 'search', label: 'Buscar', icon: <SearchIcon /> },
  ]}
  activeItemId={activeId}
  variant="accent"
  size="md"
  onChange={setActiveId}
/>
```

---

## BottomSheet

```tsx
<BottomSheet open={open} onOpenChange={setOpen} dragHandle title="Título">
  <p>Conteúdo do sheet</p>
</BottomSheet>
```

---

## Breadcrumbs

```tsx
<Breadcrumbs
  items={[{ label: 'Home' }, { label: 'Projetos' }, { label: 'Design System' }]}
  size="md"
  onClick={(item) => navigate(item)}
/>
```

---

## Button

```tsx
<Button variant="primary" shape="rectangle-solid" size="md">
  Confirmar
</Button>

// Com ícone — use iconBefore ou iconAfter, nunca dentro de children
<Button variant="primary" shape="rectangle-solid" size="md" iconBefore={<PlusIcon />}>
  Adicionar
</Button>
```

---

## Card

```tsx
<Card
  title="Apartamento · 92 m²"
  description="Apartamento moderno em região valorizada."
  orientation="vertical"
  shape="default"
  media={<img src={imageUrl} alt="imóvel" />}
  footer={
    <Button variant="primary" shape="rectangle-solid">
      Ver detalhes
    </Button>
  }
/>
```

---

## Carousel

```tsx
<Carousel options={{ loop: true }} withButtons withDots buttonsPosition="outside">
  <div>Slide 1</div>
  <div>Slide 2</div>
  <div>Slide 3</div>
</Carousel>
```

---

## Checkbox

```tsx
<Checkbox
  label="Aceitar termos de uso"
  variant="primary"
  size="md"
  checked={checked}
  onChange={setChecked}
/>
```

---

## CheckboxGroup

```tsx
<CheckboxGroup
  name="frameworks"
  label="Selecione os frameworks"
  value={selected}
  onChange={setSelected}
  options={[
    { value: 'react', label: 'React' },
    { value: 'vue', label: 'Vue' },
  ]}
  direction="vertical"
/>
```

---

## Chip

```tsx
<Chip size="md" type="filter" state="default" onRemove={() => handleRemove()}>
  React
</Chip>
```

---

## ChipsTextField

```tsx
<ChipsTextField
  label="E-mails"
  placeholder="Digite e pressione Enter..."
  value={chips}
  onChange={setChips}
  size="md"
  shape="default"
/>
```

---

## Counter

```tsx
<Counter label="Quantidade" value={value} min={0} max={100} onChange={setValue} />
```

---

## DateSelector

```tsx
// Modo single (padrão)
<DateSelector
  label="Data"
  size="md"
  shape="default"
  mode="single"
  value={date}
  onChange={setDate}
/>

// Modo range
<DateSelector
  label="Período"
  size="md"
  mode="range"
  value={range}
  onChange={setRange}
  rangeStartLabel="De"
  rangeEndLabel="Até"
/>
```

---

## Divider

```tsx
<Divider orientation="horizontal" variant="default" size="md" />
```

---

## Drawer

```tsx
<Drawer open={open} onOpenChange={setOpen} side="right" title="Filtros">
  <p>Conteúdo do drawer</p>
</Drawer>
```

---

## EmptyState

```tsx
<EmptyState
  title="Nenhum resultado encontrado"
  description="Tente ajustar os filtros da busca."
  primaryAction={{ label: 'Limpar filtros', onClick: handleClear }}
/>
```

---

## FileUploader

```tsx
<FileUploader
  variant="dropzone"
  onChange={handleFiles}
  maxSize={3 * 1024 * 1024}
  maxFiles={2}
  accept={{ 'image/jpeg': [], 'image/png': [] }}
/>
```

---

## IconButton

```tsx
<IconButton
  variant="primary"
  shape="circle-solid"
  size="md"
  icon={<TrashIcon />}
  aria-label="Deletar"
/>

// Botão de fechar
<IconButton shape="close" size="md" aria-label="Fechar" />
```

---

## Link

```tsx
<Link variant="accent" size="md" underline={false}>
  Saiba mais
</Link>

// Com ícone — use leftIcon ou rightIcon, nunca dentro de children
<Link variant="accent" size="md" rightIcon={<ChevronRightIcon />}>
  Ver todos
</Link>
```

---

## Modal

```tsx
<Modal open={open} onOpenChange={setOpen} size="md">
  <h2>Título do modal</h2>
  <p>Conteúdo do modal.</p>
  <Button variant="primary" shape="rectangle-solid" onClick={() => setOpen(false)}>
    Confirmar
  </Button>
</Modal>
```

---

## OtpInput

```tsx
<OtpInput
  length={6}
  value={code}
  onChange={setCode}
  align="center"
  onValidate={handleValidate}
  onResend={handleResend}
/>
```

---

## PageControl

```tsx
<PageControl total={10} current={currentPage} type="dot" size="md" />
```

---

## Pagination

```tsx
<Pagination
  totalItems={200}
  itemsPerPage={10}
  currentPage={page}
  onPageChange={setPage}
  onItemsPerPageChange={setItemsPerPage}
  size="md"
  align="center"
/>
```

---

## Popover

```tsx
<Popover
  trigger={
    <Button variant="primary" shape="rectangle-solid">
      Abrir
    </Button>
  }
  side="bottom"
  align="center"
  sideOffset={8}
>
  <div>Conteúdo do popover</div>
</Popover>
```

---

## ProgressBar

```tsx
<ProgressBar value={60} max={100} variant="primary" size="md" label="Carregando..." counter />
```

---

## ProgressIndicator

```tsx
<ProgressIndicator
  steps={[
    { label: 'Dados pessoais', status: 'completed' },
    { label: 'Endereço', status: 'current' },
    { label: 'Pagamento', status: 'pending' },
  ]}
  orientation="horizontal"
  type="number"
  size="md"
  variant="primary"
/>
```

---

## RadioButton

```tsx
<RadioButton
  name="plano"
  label="Plano básico"
  value="basic"
  size="md"
  variant="primary"
  checked={selected === 'basic'}
  onChange={setSelected}
/>
```

---

## RadioGroup

```tsx
<RadioGroup
  name="plano"
  label="Escolha um plano"
  value={selected}
  onChange={setSelected}
  options={[
    { label: 'Básico', value: 'basic' },
    { label: 'Pro', value: 'pro' },
  ]}
  direction="vertical"
/>
```

---

## SearchField

```tsx
<SearchField
  label="Buscar usuários"
  placeholder="Digite o nome..."
  options={options}
  value={selected}
  onChange={setSelected}
  onInputChange={handleSearch}
  size="md"
/>
```

---

## Select

```tsx
// Single
<Select
  label="Estado"
  value={selected}
  onChange={setSelected}
  options={[
    { value: 'sp', label: 'São Paulo' },
    { value: 'rj', label: 'Rio de Janeiro' },
  ]}
  size="md"
  shape="default"
/>

// Multi
<Select
  label="Cidades"
  multiple
  value={selected}
  onChange={setSelected}
  options={options}
  size="md"
/>
```

---

## SideNavigation

```tsx
// Básico
<SideNavigation
  items={navItems}
  activeItemId={activeId}
  collapsed={collapsed}
  size="md"
  onItemClick={setActiveId}
  onToggleCollapse={setCollapsed}
/>

// Com toggle de dark mode e barra de scroll oculta
<SideNavigation
  items={navItems}
  activeItemId={activeId}
  collapsed={collapsed}
  size="md"
  onItemClick={setActiveId}
  onToggleCollapse={setCollapsed}
  showDarkModeToggle
  hideScrollbar
/>

// Com usuário, menu de opções e botão de logout
<SideNavigation
  items={navItems}
  activeItemId={activeId}
  collapsed={collapsed}
  size="md"
  onItemClick={setActiveId}
  onToggleCollapse={setCollapsed}
  user={{
    name: 'João Silva',
    email: 'joao@empresa.com',
    avatar: 'https://example.com/avatar.jpg',
    menuItems: [
      { id: 'profile', label: 'Meu perfil', onClick: () => navigate('/profile') },
      { id: 'settings', label: 'Configurações da conta', onClick: () => navigate('/settings') },
    ],
  }}
  onLogout={() => handleLogout()}
/>

// Estrutura de itens com seção, submenus e ícones
const navItems = [
  {
    id: 'main',
    label: 'Principal',
    header: true,
    children: [
      { id: 'dashboard', label: 'Dashboard', icon: <HomeIcon /> },
      {
        id: 'reports',
        label: 'Relatórios',
        icon: <ChartIcon />,
        children: [
          { id: 'sales', label: 'Vendas' },
          { id: 'finance', label: 'Financeiro' },
        ],
      },
    ],
  },
]
```

---

## Skeleton

```tsx
<Skeleton variant="default" size="md" />
<Skeleton variant="circle" size="lg" />
```

---

## Slider

```tsx
// Valor único
<Slider value={value} onChange={setValue} min={0} max={100} label="Volume" showThumbTooltip />

// Range
<Slider value={[min, max]} onChange={setRange} min={0} max={1000} label="Faixa de preço" />
```

---

## StatusLight

```tsx
<StatusLight variant="positive" size="md" label="Contrato assinado" />
<StatusLight variant="negative" size="md" label="Pagamento recusado" />
```

---

## Switch

```tsx
<Switch
  label="Ativar notificações"
  variant="primary"
  size="md"
  checked={checked}
  onChange={setChecked}
/>
```

---

## Table

```tsx
<Table columns={columns} noSideBorders>
  <Table.Header>
    <Table.Row>
      <Table.HeaderCell>Nome</Table.HeaderCell>
      <Table.HeaderCell>Status</Table.HeaderCell>
    </Table.Row>
  </Table.Header>
  <Table.Body>
    <Table.Row>
      <Table.Cell>Acme Inc.</Table.Cell>
      <Table.Cell>Ativo</Table.Cell>
    </Table.Row>
  </Table.Body>
</Table>
```

---

## Tabs

```tsx
// Ícones vão dentro de cada objeto Tab, não como prop do componente
<Tabs
  value={activeTab}
  onChange={setActiveTab}
  variant="accent"
  type="global"
  size="md"
  tabs={[
    { label: 'Visão geral', iconBefore: <HomeIcon /> },
    { label: 'Relatórios', iconBefore: <ChartIcon /> },
  ]}
/>
```

---

## Tag

```tsx
<Tag variant="accent" type="filled" size="sm">
  Novo
</Tag>

// Com ícone — use a prop icon, nunca dentro de children
<Tag variant="success" type="filled-icon" size="md" icon={<CheckIcon />}>
  Aprovado
</Tag>
```

---

## TextArea

```tsx
<TextArea
  label="Descrição"
  placeholder="Descreva o imóvel..."
  value={text}
  onChange={setText}
  rows={4}
  size="md"
  shape="default"
/>
```

---

## TextField

```tsx
<TextField
  label="E-mail"
  placeholder="seu@email.com"
  value={email}
  onChange={setEmail}
  size="md"
  shape="default"
/>

// Com ícone — use iconLeft ou iconRight, nunca dentro de children
<TextField
  label="Busca"
  value={query}
  onChange={setQuery}
  iconLeft={<SearchIcon />}
  size="md"
/>
```

---

## Toast

```tsx
<Toast title="Salvo com sucesso!" variant="success" size="sm" onClose={() => {}} />
```

---

## Tooltip

```tsx
<Tooltip content="Texto de ajuda" side="top" size="default">
  <Button variant="secondary" shape="rectangle-outline">
    Hover
  </Button>
</Tooltip>
```

---

## BarChart

```tsx
// Single
<BarChart
  data={[
    { name: 'Jan', value: 400 },
    { name: 'Fev', value: 300 },
  ]}
  datasets={[{ name: 'Vendas', dataKey: 'value', color: '#6366f1' }]}
  variant="single"
  height={280}
/>

// Multi
<BarChart
  data={[
    { name: 'Jan', a: 400, b: 200 },
    { name: 'Fev', a: 300, b: 150 },
  ]}
  datasets={[
    { name: 'Produto A', dataKey: 'a', color: '#6366f1' },
    { name: 'Produto B', dataKey: 'b', color: '#f59e0b' },
  ]}
  variant="multi"
  height={280}
/>
```

---

## LineChart

```tsx
<LineChart
  data={[
    { name: 'Jan', vendas: 400, meta: 350 },
    { name: 'Fev', vendas: 300, meta: 350 },
  ]}
  datasets={[
    { name: 'Vendas', dataKey: 'vendas', color: '#6366f1' },
    { name: 'Meta', dataKey: 'meta', color: '#f59e0b' },
  ]}
  height={280}
  showDots
/>
```

---

## PieChart

```tsx
// Pie
<PieChart
  data={[
    { name: 'Categoria A', value: 400, color: '#6366f1' },
    { name: 'Categoria B', value: 300, color: '#f59e0b' },
    { name: 'Categoria C', value: 200, color: '#10b981' },
  ]}
  variant="pie"
  height={280}
/>

// Donut
<PieChart
  data={[
    { name: 'Categoria A', value: 400, color: '#6366f1' },
    { name: 'Categoria B', value: 300, color: '#f59e0b' },
  ]}
  variant="donut"
  height={280}
  formatDonutValue={(v) => `R$ ${v}`}
  formatDonutPercent={(p) => `${(p * 100).toFixed(0)}%`}
/>
```

---

## LineBarAreaChart

```tsx
<LineBarAreaChart
  data={[
    { name: 'Jan', receita: 4000, custo: 2400, lucro: 1600 },
    { name: 'Fev', receita: 3000, custo: 1398, lucro: 1602 },
  ]}
  bar={{ name: 'Receita', dataKey: 'receita', color: '#6366f1' }}
  line={{ name: 'Lucro', dataKey: 'lucro', color: '#f59e0b' }}
  area={{ name: 'Custo', dataKey: 'custo', color: '#10b981', fillOpacity: 0.2 }}
  height={280}
/>
```

---

## TreeView

```tsx
<TreeView
  nodes={[
    {
      id: '1',
      label: 'Pasta raiz',
      children: [
        { id: '1-1', label: 'Arquivo 1' },
        { id: '1-2', label: 'Arquivo 2' },
      ],
    },
  ]}
  size="md"
  showIcons
  onNodeClick={(node) => console.log(node)}
/>
```
