@humu-tech/ui 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,168 @@
1
+ # @humu-tech/ui
2
+
3
+ **47 primitives · 32 patterns · tema claro/escuro · React 18 · Tailwind preset · TypeScript**
4
+
5
+ Biblioteca de componentes React do Design System V2 da Humu (Inovanti) — extraída dos apps de crédito (admin + portal cliente) para ser consumida por todos os projetos da empresa.
6
+
7
+ > **Nome do pacote:** publica como **`@humu-tech/ui`** (coexiste com o legado `@inovanti/react@3`). O rebrand do escopo do pacote para `@humu/*` será feito quando o registry `@humu` estiver provisionado.
8
+
9
+ `@humu-tech/ui` entrega:
10
+
11
+ - **Tokens** (`@humu-tech/ui/tokens.css`) — CSS custom properties em oklch (v4-ready), self-contained, com variantes claro/escuro.
12
+ - **47 primitives** — Button, Input, Dialog, Combobox, DateInput, Switch, Tabs, Tooltip, Badge, Avatar, etc.
13
+ - **32 patterns** — DataTable, EmptyState, FilterBarV2, KpiCard, AppShell, Sidebar, DashboardBlock, charts, etc.
14
+ - **`cn`** — `tailwind-merge` estendido com os grupos de classe v2.
15
+ - **Preset Tailwind** (`@humu-tech/ui/tailwind-preset`) — o `theme.extend` com os utilitários v2.
16
+ - **Tema claro/escuro** — hook `useDsV2Theme` + componente `ThemeToggle`, via atributo `data-theme` na raiz do documento.
17
+ - **Pronto para Next.js** — os bundles emitem `"use client"` (compatível com App Router/RSC; inerte em Vite).
18
+ - **Framework-agnóstico** — navegação desacoplada via prop `linkComponent` (sem `react-router`/`next/link` embutido).
19
+
20
+ ## Instalação
21
+
22
+ O pacote é publicado no registry privado **AWS CodeArtifact** (`inovanti/bankeiro`), o mesmo do `@inovanti/*`. Com o `~/.npmrc` já apontando o escopo `@inovanti` para lá:
23
+
24
+ ```bash
25
+ npm install @humu-tech/ui
26
+ ```
27
+
28
+ `react` e `react-dom` (^18) são **peerDependencies**.
29
+
30
+ ## Setup
31
+
32
+ ### 1. Tokens
33
+
34
+ Importe o CSS de tokens uma vez na raiz do app:
35
+
36
+ ```ts
37
+ // Vite/CRA: src/main.tsx
38
+ import '@humu-tech/ui/tokens.css'
39
+ ```
40
+
41
+ ```css
42
+ /* Next.js App Router: app/globals.css */
43
+ @import '@humu-tech/ui/tokens.css';
44
+ ```
45
+
46
+ ### 2. Tailwind
47
+
48
+ O preset traz os utilitários v2 (`bg-v2-action-primary`, `text-v2-fg-default`, `rounded-v2-md`, …). Inclua o `dist` da lib no `content` para o Tailwind gerar as classes usadas pelos componentes.
49
+
50
+ **Se o app NÃO usa outro preset:** adicione como preset normal.
51
+
52
+ ```ts
53
+ // tailwind.config.ts
54
+ export default {
55
+ presets: [require('@humu-tech/ui/tailwind-preset').default],
56
+ content: [
57
+ './src/**/*.{ts,tsx}',
58
+ './node_modules/@humu-tech/ui/dist/**/*.{js,mjs}',
59
+ ],
60
+ }
61
+ ```
62
+
63
+ **Se o app já usa `@inovanti/react/tailwind.config` como preset:** NÃO empilhe dois presets — o preset do `@inovanti/react` perde as próprias cores quando combinado com qualquer outro preset. Puxe os tokens via `theme.extend` em vez de `presets`:
64
+
65
+ ```ts
66
+ export default {
67
+ presets: [require('@inovanti/react/tailwind.config')],
68
+ content: [
69
+ './src/**/*.{ts,tsx}',
70
+ './node_modules/@humu-tech/ui/dist/**/*.{js,mjs}',
71
+ ],
72
+ theme: {
73
+ extend: {
74
+ ...require('@humu-tech/ui/tailwind-preset').default.theme.extend,
75
+ },
76
+ },
77
+ }
78
+ ```
79
+
80
+ ## Uso
81
+
82
+ ```tsx
83
+ import { Button, Input, DataTable, cn } from '@humu-tech/ui'
84
+
85
+ export function Example() {
86
+ return (
87
+ <div className={cn('flex flex-col gap-4')}>
88
+ <Input label="Nome" />
89
+ <Button variant="primary">Salvar</Button>
90
+ </div>
91
+ )
92
+ }
93
+ ```
94
+
95
+ ### Navegação desacoplada
96
+
97
+ Componentes de navegação (AppShell, Sidebar, Breadcrumb, KpiHero) recebem `linkComponent` e `currentPath` por prop — o app injeta o roteador dele:
98
+
99
+ ```tsx
100
+ import { AppShell, type DsLinkComponent } from '@humu-tech/ui'
101
+ import { Link, useLocation } from 'react-router-dom'
102
+
103
+ const RouterLink: DsLinkComponent = ({ to, className, children }) => (
104
+ <Link to={to} className={className}>{children}</Link>
105
+ )
106
+
107
+ <AppShell linkComponent={RouterLink} currentPath={useLocation().pathname} sidebarGroups={groups}>
108
+ {children}
109
+ </AppShell>
110
+ ```
111
+
112
+ Sem `linkComponent`, o default renderiza um `<a href>`.
113
+
114
+ ## Catálogo de componentes
115
+
116
+ Todos exportados diretamente de `@humu-tech/ui` (`import { X } from '@humu-tech/ui'`).
117
+
118
+ ### Primitives (47)
119
+
120
+ | Grupo | Componentes |
121
+ | --- | --- |
122
+ | **Formulário / inputs** | Button, Checkbox, CepInput, ColorPicker, Combobox, DateInput, DateRangeInput, DocumentInput, FileUpload, ImageUpload, Input, Label, MaskedInput, MoneyInput, MultiCombobox, OtpInput, PasswordInput, PercentInput, PhoneInput, RadioGroup, Switch, TextArea |
123
+ | **Overlays / menus** | ConfirmDialog, ContextMenu, Dialog, Drawer, Dropdown, Popover, Tooltip |
124
+ | **Exibição de dados** | Avatar, Badge, Card, CopyButton, Skeleton, Sparkline, SparklineBadge, Text, Heading |
125
+ | **Navegação / layout** | Breadcrumb, Separator, Stepper, Tabs |
126
+ | **Feedback** | FormAlert, HelpHint, Spinner, Toast(er) |
127
+ | **Tema** | ThemeToggle |
128
+
129
+ ### Patterns (32)
130
+
131
+ | Grupo | Componentes |
132
+ | --- | --- |
133
+ | **Formulário / inputs** | FormSection, FormWithAside, WizardShell |
134
+ | **Exibição de dados** | DataField, DataTable, DataTablePagination, EmptyState, LegalDocumentRenderer, PanelCard, ReadOnlyDataView, SectionCard, SortableColumnHeader, TutorialCard |
135
+ | **Navegação / layout** | AppShell, ErrorPageLayout, NavigatorTile, PublicPageLayout, Sidebar, Topbar |
136
+ | **Gráficos** | ChartTimeSeries, DonutChart, HorizontalBarChart, KpiCard, KpiHero, LineChart, StackedBarChart |
137
+ | **Feedback / diversos** | CommandPalette, DashboardBlock, DSAccordion, FilterBarV2, NotificationCenter, WorkflowDesigner |
138
+
139
+ ## Tema claro/escuro
140
+
141
+ O DS ativa o tema escuro via `:root[data-theme="dark"]` (equivalente `.dark`) nos tokens CSS. A biblioteca fornece as duas peças necessárias para o app consumidor:
142
+
143
+ - **`ThemeToggle`** — botão pronto que cicla `light → dark → system`, persiste a preferência em `localStorage` (`storageKey`, default `"ds-v2-theme-preference"`), escuta `prefers-color-scheme` quando a preferência é `system`, e escreve `data-theme`/classe `dark`/`light` em `document.documentElement`.
144
+ - **`useDsV2Theme()`** — hook somente-leitura que observa o atributo `data-theme` da raiz (via `MutationObserver`) e retorna `'light' | 'dark'` (tipo `DsV2Theme`) — útil para adaptar lógica de app (ex.: cor de um gráfico de terceiros) ao tema atual sem duplicar a fonte da verdade.
145
+
146
+ ```tsx
147
+ import { ThemeToggle, useDsV2Theme } from '@humu-tech/ui'
148
+
149
+ function Topbar() {
150
+ const theme = useDsV2Theme() // 'light' | 'dark'
151
+ return (
152
+ <header>
153
+ <span>Tema atual: {theme}</span>
154
+ <ThemeToggle size="md" />
155
+ </header>
156
+ )
157
+ }
158
+ ```
159
+
160
+ Não é necessário nenhum `ThemeProvider`: o estado vive no DOM (`data-theme`), então qualquer parte da árvore — inclusive fora do React (CSS puro) — reage automaticamente.
161
+
162
+ ## Storybook
163
+
164
+ Catálogo interativo de todos os componentes (com stories co-localizadas) publicado via GitHub Pages a partir do repositório [`humu-ui`](https://github.com/Inovanti-Bank/humu-ui) (pacote `packages/docs`).
165
+
166
+ ## Versionamento
167
+
168
+ Este pacote usa [changesets](https://github.com/changesets/changesets) para versionamento semântico. Consulte o `CHANGELOG.md` no registry ou o histórico de tags do repositório para o changelog completo.
@@ -0,0 +1,80 @@
1
+ .rdp-v2 {
2
+ --rdp-cell-size: 36px;
3
+ --rdp-accent-color: var(--v2-action-primary);
4
+ --rdp-background-color: var(--v2-action-primary);
5
+ --rdp-accent-color-dark: var(--v2-action-primary-hover);
6
+ --rdp-background-color-dark: var(--v2-action-primary-hover);
7
+ --rdp-outline: 2px solid var(--v2-focus-ring);
8
+ --rdp-outline-selected: 2px solid var(--v2-action-primary);
9
+ margin: 0;
10
+ color: var(--v2-fg-default);
11
+ }
12
+
13
+ .rdp-v2 .rdp-button:hover:not([disabled]):not(.rdp-day_selected) {
14
+ background-color: var(--v2-bg-raised);
15
+ }
16
+
17
+ .rdp-v2 .rdp-day_today {
18
+ color: var(--v2-action-primary);
19
+ font-weight: 600;
20
+ }
21
+
22
+ .rdp-v2 .rdp-caption_label {
23
+ color: var(--v2-fg-default);
24
+ font-weight: 600;
25
+ }
26
+
27
+ .rdp-v2 .rdp-head_cell {
28
+ color: var(--v2-fg-muted);
29
+ }
30
+
31
+ .rdp-v2 .rdp-day {
32
+ color: var(--v2-fg-default);
33
+ border-radius: var(--radius-md);
34
+ }
35
+
36
+ .rdp-v2 .rdp-day_outside {
37
+ color: var(--v2-fg-subtle);
38
+ opacity: 0.5;
39
+ }
40
+
41
+ .rdp-v2 .rdp-caption_dropdowns,
42
+ .rdp-v2-range .rdp-caption_dropdowns {
43
+ display: flex;
44
+ gap: 0.5rem;
45
+ }
46
+
47
+ .rdp-v2 .rdp-dropdown,
48
+ .rdp-v2-range .rdp-dropdown {
49
+ color: var(--v2-fg-default);
50
+ }
51
+
52
+ .rdp-v2 .rdp-dropdown:focus-visible + .rdp-caption_label,
53
+ .rdp-v2-range .rdp-dropdown:focus-visible + .rdp-caption_label {
54
+ outline: var(--rdp-outline);
55
+ border-radius: var(--radius-md);
56
+ }
57
+
58
+ .rdp-v2 .rdp-dropdown option,
59
+ .rdp-v2-range .rdp-dropdown option {
60
+ color: var(--v2-fg-default);
61
+ background-color: var(--v2-bg-panel);
62
+ }
63
+
64
+ :root[data-feature-ds-v2='true'][data-theme='dark'] .rdp-v2 .rdp-dropdown,
65
+ :root[data-feature-ds-v2='true'][data-theme='dark'] .rdp-v2-range .rdp-dropdown {
66
+ color-scheme: dark;
67
+ }
68
+
69
+ .rdp-v2-range.rdp-v2-single .rdp-day {
70
+ border-radius: 9999px;
71
+ }
72
+
73
+ .rdp-v2-range.rdp-v2-single .rdp-day_today:not(.rdp-day_selected) {
74
+ box-shadow: inset 0 0 0 1.5px var(--v2-action-primary);
75
+ }
76
+
77
+ .rdp-v2 .rdp-vhidden,
78
+ .rdp-v2-range .rdp-vhidden {
79
+ color: var(--v2-fg-default);
80
+ }
@@ -0,0 +1,144 @@
1
+ .rdp-v2-range {
2
+ --rdp-cell-size: 36px;
3
+ --rdp-accent-color: var(--v2-action-primary);
4
+ --rdp-background-color: var(--v2-action-primary);
5
+ --rdp-accent-color-dark: var(--v2-action-primary-hover);
6
+ --rdp-background-color-dark: var(--v2-action-primary-hover);
7
+ --rdp-outline: 2px solid var(--v2-focus-ring);
8
+ --rdp-outline-selected: 2px solid var(--v2-action-primary);
9
+ margin: 0;
10
+ color: var(--v2-fg-default);
11
+ }
12
+
13
+ .rdp-v2-range .rdp-months {
14
+ gap: 1.5rem;
15
+ }
16
+
17
+ .rdp-v2-range .rdp-day:hover:not([disabled]):not(.rdp-day_selected):not(.rdp-day_range_middle) {
18
+ background-color: color-mix(in oklch, var(--v2-brand-primary) 22%, transparent);
19
+ color: var(--v2-fg-default);
20
+ }
21
+
22
+ .rdp-v2-range .rdp-day_range_middle:hover:not([disabled]) {
23
+ background-color: color-mix(in oklch, var(--v2-action-primary) 32%, transparent);
24
+ }
25
+
26
+ .rdp-v2-range .rdp-day_today {
27
+ color: var(--v2-action-primary);
28
+ font-weight: 600;
29
+ }
30
+
31
+ .rdp-v2-range .rdp-day_today:not(.rdp-day_selected):not(.rdp-day_range_middle) {
32
+ border-radius: 9999px;
33
+ box-shadow: inset 0 0 0 1.5px var(--v2-action-primary);
34
+ }
35
+
36
+ .rdp-v2-range .rdp-caption_label {
37
+ color: var(--v2-fg-default);
38
+ font-weight: 600;
39
+ }
40
+
41
+ .rdp-v2-range .rdp-head_cell {
42
+ color: var(--v2-fg-muted);
43
+ font-weight: 500;
44
+ text-transform: uppercase;
45
+ font-size: 0.75rem;
46
+ }
47
+
48
+ .rdp-v2-range .rdp-day {
49
+ color: var(--v2-fg-default);
50
+ border-radius: 0;
51
+ }
52
+
53
+ .rdp-v2-range .rdp-day_outside {
54
+ color: var(--v2-fg-subtle);
55
+ opacity: 0.4;
56
+ }
57
+
58
+ .rdp-v2-range .rdp-day_range_start,
59
+ .rdp-v2-range .rdp-day_range_end {
60
+ background-color: var(--v2-action-primary) !important;
61
+ color: var(--v2-action-on-primary) !important;
62
+ font-weight: 600;
63
+ border-radius: var(--radius-md, 8px);
64
+ }
65
+
66
+ .rdp-v2-range .rdp-day_range_middle {
67
+ background-color: color-mix(in oklch, var(--v2-action-primary) 18%, transparent);
68
+ color: var(--v2-fg-default);
69
+ border-radius: 0;
70
+ }
71
+
72
+ .rdp-v2-range .rdp-day_range_start:not(.rdp-day_range_end) {
73
+ border-top-right-radius: 0;
74
+ border-bottom-right-radius: 0;
75
+ }
76
+
77
+ .rdp-v2-range .rdp-day_range_end:not(.rdp-day_range_start) {
78
+ border-top-left-radius: 0;
79
+ border-bottom-left-radius: 0;
80
+ }
81
+
82
+ .rdp-v2-range .rdp-day_selected:not(.rdp-day_range_middle) {
83
+ background-color: var(--v2-action-primary);
84
+ color: var(--v2-action-on-primary);
85
+ }
86
+
87
+ .rdp-v2-range .rdp-caption {
88
+ position: relative;
89
+ display: flex;
90
+ align-items: center;
91
+ justify-content: center;
92
+ width: 100%;
93
+ padding: 0;
94
+ }
95
+
96
+ .rdp-v2-range .rdp-nav {
97
+ position: absolute;
98
+ inset: 0;
99
+ display: flex;
100
+ justify-content: space-between;
101
+ align-items: center;
102
+ pointer-events: none;
103
+ }
104
+
105
+ .rdp-v2-range .rdp-nav_button_previous {
106
+ margin-right: auto;
107
+ }
108
+
109
+ .rdp-v2-range .rdp-nav_button_next {
110
+ margin-left: auto;
111
+ }
112
+
113
+ .rdp-v2-range .rdp-nav_button {
114
+ pointer-events: auto;
115
+ width: 1.75rem;
116
+ height: 1.75rem;
117
+ color: var(--v2-fg-default);
118
+ border: 1px solid var(--v2-border-default);
119
+ border-radius: var(--radius-md, 8px);
120
+ background-color: var(--v2-bg-raised);
121
+ transition: background-color 150ms ease, border-color 150ms ease;
122
+ }
123
+
124
+ .rdp-v2-range .rdp-nav_button:hover:not([disabled]) {
125
+ background-color: var(--v2-bg-subtle);
126
+ border-color: var(--v2-action-primary);
127
+ color: var(--v2-action-primary);
128
+ }
129
+
130
+ .rdp-v2-range .rdp-nav_button:focus-visible {
131
+ outline: 2px solid var(--v2-focus-ring);
132
+ outline-offset: 2px;
133
+ }
134
+
135
+ .rdp-v2-range .rdp-nav_button svg {
136
+ width: 14px;
137
+ height: 14px;
138
+ stroke-width: 2.5;
139
+ }
140
+
141
+ .rdp-v2-range .rdp-nav_button[disabled] {
142
+ opacity: 0.4;
143
+ cursor: not-allowed;
144
+ }
@@ -0,0 +1,44 @@
1
+ .ds-v2-sidebar-aside {
2
+ scrollbar-width: none;
3
+ overflow-x: clip;
4
+ overflow-y: visible;
5
+ }
6
+
7
+ .ds-v2-sidebar-aside::-webkit-scrollbar {
8
+ display: none;
9
+ }
10
+
11
+ .ds-v2-sidebar-nav {
12
+ overflow-x: clip;
13
+ overflow-y: visible;
14
+ position: relative;
15
+ z-index: 0;
16
+ }
17
+
18
+ .ds-v2-sidebar-item--active {
19
+ position: relative;
20
+ background-color: var(--v2-bg-subtle);
21
+ }
22
+
23
+ .ds-v2-sidebar-item--active::before,
24
+ .ds-v2-sidebar-item--active::after {
25
+ content: '';
26
+ position: absolute;
27
+ right: 0;
28
+ width: 2.5rem;
29
+ height: 2.5rem;
30
+ border-radius: 50%;
31
+ background-color: transparent;
32
+ pointer-events: none;
33
+ z-index: -10;
34
+ }
35
+
36
+ .ds-v2-sidebar-item--active::before {
37
+ top: -2.5rem;
38
+ box-shadow: 20px 20px 0 var(--v2-bg-subtle);
39
+ }
40
+
41
+ .ds-v2-sidebar-item--active::after {
42
+ bottom: -2.5rem;
43
+ box-shadow: 20px -20px 0 var(--v2-bg-subtle);
44
+ }