npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@megamodel/register-form

v1.0.3

Published

Formulário de registro reutilizável para sites da Mega Model

Readme

@megamodel/register-form

Formulário de registro reutilizável e altamente customizável para sites da Mega Model, construído com React, Next.js e shadcn/ui.

✨ Features

  • 🎯 Validação Robusta - Validação em tempo real com Zod
  • 📱 Totalmente Responsivo - Interface adaptativa para mobile e desktop
  • 🎨 Customizável - Integração completa com Tailwind CSS e shadcn/ui
  • 🌐 i18n Ready - Mensagens em português brasileiro
  • 📊 Analytics - Captura automática de UTM params e dados de dispositivo
  • Acessível - Componentes com ARIA attributes
  • 🔒 Type-Safe - Totalmente tipado com TypeScript
  • 🚀 Performance - Bundle otimizado com code splitting

📦 Instalação

npm install @megamodel/register-form

🚀 Quick Start

1. Instale as dependências do shadcn/ui

npx shadcn@latest add button calendar command dialog drawer form input label popover select

2. Configure as variáveis de ambiente

NEXT_PUBLIC_API_URL=https://api.megamodel.com.br
NEXT_PUBLIC_API_TOKEN=seu-token-aqui
NEXT_PUBLIC_SITE_ID=123

3. Use o componente

import { MegaRegisterForm } from '@megamodel/register-form'

export default function RegisterPage() {
	return (
		<div className='container mx-auto px-4 py-8'>
			<h1>Faça sua inscrição</h1>

			<MegaRegisterForm
				apiUrl={process.env.NEXT_PUBLIC_API_URL!}
				apiToken={process.env.NEXT_PUBLIC_API_TOKEN!}
				siteId={process.env.NEXT_PUBLIC_SITE_ID!}
			/>
		</div>
	)
}

📚 Documentação Completa

🎯 Props

Obrigatórias

| Prop | Tipo | Descrição | |------|------|-----------| | apiUrl | string | URL base da API | | apiToken | string | Token de autenticação Bearer | | siteId | string \| number | ID do site para registro |

Opcionais

| Prop | Tipo | Descrição | |------|------|-----------| | onSuccess | (data: FormData) => void | Callback de sucesso | | onError | (error: Error) => void | Callback de erro | | className | string | Classes CSS adicionais |

📋 Campos do Formulário

O formulário coleta:

  • ✅ Nome completo
  • ✅ E-mail
  • ✅ WhatsApp (com máscara)
  • ✅ Data de nascimento (input + calendário)
  • ✅ Gênero (5 opções)
  • ✅ Estado (busca inteligente)
  • ✅ Cidade (carregamento dinâmico)
  • ✅ Nome do responsável (condicional para < 18 anos)

Dados coletados automaticamente:

  • 🌐 IP do cliente
  • 💻 Informações do dispositivo (navegador, SO)
  • 📊 Parâmetros UTM (tracking)
  • 🔗 Referrer e User Agent

🎨 Exemplo Avançado

'use client'

import { MegaRegisterForm, FormData } from '@megamodel/register-form'
import { useRouter } from 'next/navigation'
import { toast } from 'sonner'

export default function RegisterPage() {
	const router = useRouter()

	const handleSuccess = (data: FormData) => {
		toast.success(`Bem-vindo, ${data.name}!`)
		router.push('/obrigado')
	}

	const handleError = (error: Error) => {
		toast.error('Erro ao processar inscrição')
		console.error(error)
	}

	return (
		<div className='max-w-2xl mx-auto'>
			<MegaRegisterForm
				apiUrl={process.env.NEXT_PUBLIC_API_URL!}
				apiToken={process.env.NEXT_PUBLIC_API_TOKEN!}
				siteId='mega-experience'
				onSuccess={handleSuccess}
				onError={handleError}
				className='bg-card p-6 rounded-lg shadow-lg'
			/>
		</div>
	)
}

🔧 Requisitos

  • React >= 18.0.0
  • React DOM >= 18.0.0
  • Next.js >= 14.0.0
  • shadcn/ui components instalados

🏗️ Build

Para fazer build do package:

cd packages/register-form
npm install
npm run build

Isso gerará os arquivos em dist/:

  • index.js (CommonJS)
  • index.mjs (ES Modules)
  • index.d.ts (TypeScript definitions)

📝 Validação

O formulário usa Zod para validação com as seguintes regras:

  • Nome: Mínimo 3 caracteres
  • E-mail: Formato válido
  • WhatsApp: Formato (99) 99999-9999
  • Data de nascimento: Data válida
  • Gênero: Seleção obrigatória
  • Estado: Seleção obrigatória
  • Cidade: Seleção obrigatória
  • Responsável: Obrigatório se idade < 18 anos

🌐 API Endpoints

O package espera os seguintes endpoints na API:

GET /states

Retorna lista de estados brasileiros

GET /cities/{stateId}

Retorna lista de cidades de um estado

POST /leads/register

Envia os dados do formulário

🎨 Customização

O formulário é totalmente customizável através do sistema de temas do shadcn/ui:

<MegaRegisterForm
	apiUrl='...'
	apiToken='...'
	siteId='...'
	className='custom-form-styles'
/>

Veja o Guia de Styling para mais detalhes.

🤝 Contribuindo

Este é um package interno da Mega Model. Para sugestões ou problemas, entre em contato com a equipe de desenvolvimento.

📄 Licença

UNLICENSED - Propriedade exclusiva da Mega Model. Todos os direitos reservados.

🔗 Links Úteis


Desenvolvido com ❤️ pela equipe Mega Model