
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
@anpdgovbr/shared-ui
Advanced tools
Biblioteca de componentes React com MUI v7 e padrão govbr-ds para ANPD
Biblioteca de componentes React com MUI v7 e padrão GovBR-DS para a ANPD.
O shared-ui
é uma biblioteca de componentes de interface de usuário (UI) modular e escalável, construída para padronizar e acelerar o desenvolvimento de aplicações front-end na Autoridade Nacional de Proteção de Dados (ANPD).
Siga estas instruções para configurar o ambiente de desenvolvimento local.
Clone o repositório:
git clone git@github.com:anpdgovbr/shared-ui.git
Navegue até o diretório do projeto:
cd shared-ui
Instale as dependências:
npm install
Configure os hooks:
npm run prepare
Mantenha sua branch atualizada com a main
:
git checkout -b minha-feature main
git pull origin main
npm run storybook
O Storybook estará disponível em http://localhost:6006
.
npm install git+ssh://git@github.com:anpdgovbr/shared-ui.git
import { GovBRButton, GovBRAvatar } from '@anpdgovbr/shared-ui'
function MyComponent() {
return (
<div>
<GovBRButton size="medium" color="primary">
Clique Aqui
</GovBRButton>
<GovBRAvatar
name="João Silva"
menuItems={[{ label: 'Perfil', href: '/perfil' }]}
onNavigate={(href) => (window.location.href = href)}
/>
</div>
)
}
Para formulários com react-hook-form
:
import { useForm } from 'react-hook-form'
import { GovBRFormInput, GovBRFormCheckbox } from '@anpdgovbr/shared-ui'
function MyForm() {
const { control } = useForm()
return (
<div>
<GovBRFormInput
name="meuInput"
control={control}
label="Campo de Texto"
govbrSize="medium"
error={errors.meuInput ? true : false}
feedbackMessage={errors.meuInput?.message}
/>
<GovBRFormCheckbox name="meuCheckbox" control={control} label="Aceito os termos" />
</div>
)
}
Nota: O projeto consumidor deve declarar
react
,@mui/material
,@mui/icons-material
ereact-hook-form
como dependências.
src/
├── components/
│ └── ui/ # Componentes padronizados (kebab-case)
│ ├── auto-sync/ # AutoSyncButton
│ ├── govbr-avatar/ # GovBRAvatar
│ ├── govbr-breadcrumb/ # GovBRBreadcrumb
│ ├── govbr-button/ # GovBRButton
│ ├── govbr-checkbox/ # GovBRCheckbox
│ ├── govbr-form-checkbox/ # GovBRFormCheckbox
│ ├── govbr-form-input/ # GovBRFormInput
│ ├── govbr-input/ # GovBRInput
│ ├── govbr-radio/ # GovBRRadio
│ └── govbr-sign-in/ # GovBRSignIn
├── helpers/ # Utilitários
│ ├── MuiColorToGovBRClass.ts # Conversão de cores MUI → GovBR
│ └── IconMap.tsx # Mapeamento de ícones
├── types/ # Definições de tipos centralizadas
│ ├── GovBRTypes.ts # Tipos base do GovBR-DS
│ └── SharedUIComponentProps.ts # Props compartilhados
├── theme/ # Configuração de tema
│ ├── govbrTheme.ts # Tema MUI customizado
│ └── GovBRThemeProvider.tsx # Provider do tema
└── index.ts # Exports principais
Cada componente segue a estrutura kebab-case inspirada no shadcn/ui:
src/components/ui/nome-componente/
├── index.tsx # Componente + exports
├── types.ts # Interfaces e tipos
├── index.stories.tsx # Histórias do Storybook
└── hooks.ts # Hooks específicos (opcional)
A biblioteca utiliza um sistema de tipos centralizados para garantir consistência:
🎯 Path Aliases Configurados:
@components/*
→ src/components/*
@theme/*
→ src/theme/*
@helpers/*
→ src/helper/*
@govbr-types/*
→ src/types/*
📋 Tipos Base:
GovBRSize
: 'small' | 'medium' | 'large'
- Tamanhos padronizadosGovBRColor
: 'default' | 'primary' | 'secondary'
- Cores básicasGovBRSemanticColor
: Inclui cores semânticas como 'success' | 'warning' | 'error' | 'info'
GovBRStatus
: Estados de feedback visual🧩 Tipos Comuns:
GovBRMenuItem
: Interface para itens de menu com íconeGovBRNavigationItem
: Interface para navegação (breadcrumbs, tabs)GovBRNavigationCallback
: Callback padronizado de navegaçãoGovBRPosition
: Posicionamento para componentes flutuantes⚡ Props Compartilhados:
SharedUIComponentProps
: Props comuns a todos os componentesGovBRNavigatable
: Para componentes com navegaçãoGovBRSelectable
: Para componentes com seleção✅ Todos os componentes implementam SharedUIComponentProps
com:
strictGovBr?: boolean
- Para compatibilidade estrita com GovBR-DSScript | Descrição |
---|---|
npm run dev | Inicia o Storybook para desenvolvimento. |
npm run build | Compila a biblioteca (types + dist ). |
npm run storybook | Inicia o Storybook em localhost:6006 . |
npm run build-storybook | Gera versão estática do Storybook. |
npm run test | Executa os testes com Vitest. |
npm run lint | Verifica erros de lint. |
npm run format | Formata com Prettier. |
npm run type-check | Verifica tipos com tsc --noEmit . |
npm run check | Executa lint, type-check e testes juntos. |
GovBRModal
, GovBRNotification
, GovBRTable
).Contribuições são bem-vindas! Siga nosso processo padronizado:
main
:
git checkout -b feat/nome-do-componente main
git pull origin main
npm run check # lint + type-check + test
npm run build # verifica se compila corretamente
git add .
git commit -m "feat: adiciona novo componente"
git push origin feat/nome-do-componente
📚 Documentação Completa: CONTRIBUTING.md
Este projeto está licenciado sob a Licença ISC.
Divisão de Desenvolvimento e Sustentação de Sistemas
Autoridade Nacional de Proteção de Dados - ANPD
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.