@grazziotin/react-components-next 0.1.0 → 1.0.0
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 +187 -174
- package/dist/chunk-CNXFSE26.mjs +120 -0
- package/dist/chunk-CNXFSE26.mjs.map +1 -0
- package/dist/chunk-NHHZBMJL.mjs +64 -0
- package/dist/chunk-NHHZBMJL.mjs.map +1 -0
- package/dist/functions/index.d.mts +38 -0
- package/dist/functions/index.d.ts +38 -0
- package/dist/functions/index.js +54 -0
- package/dist/functions/index.js.map +1 -0
- package/dist/functions/index.mjs +3 -0
- package/dist/functions/index.mjs.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.mts +5 -67
- package/dist/index.d.ts +5 -67
- package/dist/index.js +170 -368
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -393
- package/dist/index.mjs.map +1 -1
- package/dist/ui/index.d.mts +224 -0
- package/dist/ui/index.d.ts +224 -0
- package/dist/ui/index.js +150 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/index.mjs +4 -0
- package/dist/ui/index.mjs.map +1 -0
- package/package.json +102 -73
package/README.md
CHANGED
|
@@ -1,174 +1,187 @@
|
|
|
1
|
-
# React Components Library
|
|
2
|
-
|
|
3
|
-
Biblioteca de componentes React reutilizáveis, construída com TypeScript e Tailwind CSS.
|
|
4
|
-
|
|
5
|
-
## Instalação
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install react-components-next
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
> **Atenção:** esta biblioteca usa classes do Tailwind CSS. Certifique-se de que o Tailwind esteja configurado no seu projeto.
|
|
12
|
-
|
|
13
|
-
## Componentes disponíveis
|
|
14
|
-
|
|
15
|
-
| Componente | Descrição
|
|
16
|
-
|
|
17
|
-
| `Button`
|
|
18
|
-
| `Input`
|
|
19
|
-
| `Card`
|
|
20
|
-
| `Badge`
|
|
21
|
-
| `Avatar`
|
|
22
|
-
|
|
23
|
-
## Uso
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
</
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
>
|
|
104
|
-
|
|
105
|
-
</
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
#
|
|
142
|
-
npm
|
|
143
|
-
|
|
144
|
-
#
|
|
145
|
-
npm
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
│
|
|
167
|
-
│
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
1
|
+
# React Components Library
|
|
2
|
+
|
|
3
|
+
Biblioteca de componentes React reutilizáveis, construída com TypeScript e Tailwind CSS.
|
|
4
|
+
|
|
5
|
+
## Instalação
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install react-components-next
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> **Atenção:** esta biblioteca usa classes do Tailwind CSS. Certifique-se de que o Tailwind esteja configurado no seu projeto.
|
|
12
|
+
|
|
13
|
+
## Componentes disponíveis
|
|
14
|
+
|
|
15
|
+
| Componente | Descrição |
|
|
16
|
+
| ---------- | ------------------------------------------------ |
|
|
17
|
+
| `Button` | Botão com variantes, tamanhos, loading e ícones |
|
|
18
|
+
| `Input` | Campo de entrada com label, hint, erro e addons |
|
|
19
|
+
| `Card` | Container com header, content e footer compostos |
|
|
20
|
+
| `Badge` | Etiqueta colorida para status e categorias |
|
|
21
|
+
| `Avatar` | Foto de perfil com fallback de iniciais |
|
|
22
|
+
|
|
23
|
+
## Uso
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import {
|
|
27
|
+
Button,
|
|
28
|
+
Card,
|
|
29
|
+
CardHeader,
|
|
30
|
+
CardTitle,
|
|
31
|
+
CardContent,
|
|
32
|
+
Input,
|
|
33
|
+
Badge,
|
|
34
|
+
Avatar,
|
|
35
|
+
} from "react-components-next";
|
|
36
|
+
|
|
37
|
+
export function Example() {
|
|
38
|
+
return (
|
|
39
|
+
<Card>
|
|
40
|
+
<CardHeader>
|
|
41
|
+
<CardTitle>Perfil</CardTitle>
|
|
42
|
+
</CardHeader>
|
|
43
|
+
<CardContent>
|
|
44
|
+
<div className="flex items-center gap-3">
|
|
45
|
+
<Avatar fallback="João Silva" size="md" />
|
|
46
|
+
<div>
|
|
47
|
+
<p>João Silva</p>
|
|
48
|
+
<Badge variant="success" dot>
|
|
49
|
+
Online
|
|
50
|
+
</Badge>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
<Input label="E-mail" type="email" placeholder="joao@exemplo.com" />
|
|
54
|
+
<Button variant="primary" fullWidth>
|
|
55
|
+
Salvar
|
|
56
|
+
</Button>
|
|
57
|
+
</CardContent>
|
|
58
|
+
</Card>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Componentes
|
|
64
|
+
|
|
65
|
+
### Button
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
<Button
|
|
69
|
+
variant="primary" // "primary" | "secondary" | "outline" | "ghost" | "destructive"
|
|
70
|
+
size="md" // "sm" | "md" | "lg"
|
|
71
|
+
loading={false} // boolean
|
|
72
|
+
fullWidth={false} // boolean
|
|
73
|
+
leftIcon={<Icon />} // ReactNode
|
|
74
|
+
rightIcon={<Icon />} // ReactNode
|
|
75
|
+
>
|
|
76
|
+
Clique aqui
|
|
77
|
+
</Button>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Input
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
<Input
|
|
84
|
+
label="Nome"
|
|
85
|
+
placeholder="Digite..."
|
|
86
|
+
hint="Texto de ajuda"
|
|
87
|
+
error="Mensagem de erro"
|
|
88
|
+
size="md" // "sm" | "md" | "lg"
|
|
89
|
+
leftAddon={<Icon />} // ReactNode
|
|
90
|
+
rightAddon={<Icon />} // ReactNode
|
|
91
|
+
fullWidth={false}
|
|
92
|
+
/>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Card
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
<Card shadow="sm" padding="md" hoverable bordered>
|
|
99
|
+
<CardHeader>
|
|
100
|
+
<CardTitle>Título</CardTitle>
|
|
101
|
+
<CardDescription>Descrição</CardDescription>
|
|
102
|
+
</CardHeader>
|
|
103
|
+
<CardContent>Conteúdo</CardContent>
|
|
104
|
+
<CardFooter>
|
|
105
|
+
<Button>Ação</Button>
|
|
106
|
+
</CardFooter>
|
|
107
|
+
</Card>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Badge
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<Badge
|
|
114
|
+
variant="success" // "default" | "primary" | "success" | "warning" | "danger" | "info"
|
|
115
|
+
dot={false} // boolean - exibe um ponto colorido
|
|
116
|
+
>
|
|
117
|
+
Online
|
|
118
|
+
</Badge>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Avatar
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
<Avatar
|
|
125
|
+
src="https://..." // URL da imagem (opcional)
|
|
126
|
+
alt="Nome do usuário"
|
|
127
|
+
fallback="João Silva" // usado para gerar as iniciais
|
|
128
|
+
size="md" // "xs" | "sm" | "md" | "lg" | "xl"
|
|
129
|
+
/>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Desenvolvimento
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Instalar dependências
|
|
136
|
+
npm install
|
|
137
|
+
|
|
138
|
+
# Rodar servidor de desenvolvimento com showcase
|
|
139
|
+
npm run dev
|
|
140
|
+
|
|
141
|
+
# Build da biblioteca para npm
|
|
142
|
+
npm run build:lib
|
|
143
|
+
|
|
144
|
+
# Build completo (biblioteca + Next.js)
|
|
145
|
+
npm run build:all
|
|
146
|
+
|
|
147
|
+
# Verificar tipos TypeScript
|
|
148
|
+
npm run type-check
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Publicar no npm
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Fazer login no npm
|
|
155
|
+
npm login
|
|
156
|
+
|
|
157
|
+
# Publicar (executa build:lib automaticamente via prepublishOnly)
|
|
158
|
+
npm publish
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Estrutura do projeto
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
src/
|
|
165
|
+
├── app/ # Next.js App Router (showcase)
|
|
166
|
+
│ ├── page.tsx # Página inicial com lista de componentes
|
|
167
|
+
│ └── showcase/ # Páginas de demonstração
|
|
168
|
+
│ ├── button/
|
|
169
|
+
│ ├── input/
|
|
170
|
+
│ ├── card/
|
|
171
|
+
│ ├── badge/
|
|
172
|
+
│ └── avatar/
|
|
173
|
+
├── components/ # Biblioteca de componentes (publicada no npm)
|
|
174
|
+
│ ├── index.ts # Entrypoint principal
|
|
175
|
+
│ └── ui/
|
|
176
|
+
│ ├── Button/
|
|
177
|
+
│ ├── Input/
|
|
178
|
+
│ ├── Card/
|
|
179
|
+
│ ├── Badge/
|
|
180
|
+
│ └── Avatar/
|
|
181
|
+
└── lib/
|
|
182
|
+
└── utils.ts # Utilitário cn() para classes CSS
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Licença
|
|
186
|
+
|
|
187
|
+
MIT
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { __spreadValues, cn } from './chunk-NHHZBMJL.mjs';
|
|
2
|
+
import { Box } from '@mui/material';
|
|
3
|
+
import { Tooltip } from '@mantine/core';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
import DialogMui from '@mui/material/Dialog';
|
|
6
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
|
7
|
+
import DialogActions from '@mui/material/DialogActions';
|
|
8
|
+
import DialogContent from '@mui/material/DialogContent';
|
|
9
|
+
|
|
10
|
+
function Card({
|
|
11
|
+
margin,
|
|
12
|
+
onClick,
|
|
13
|
+
title,
|
|
14
|
+
toolTip,
|
|
15
|
+
className,
|
|
16
|
+
borderTitle,
|
|
17
|
+
children,
|
|
18
|
+
borderRadius,
|
|
19
|
+
width = "100%",
|
|
20
|
+
height = "auto",
|
|
21
|
+
titleWidth = "100%",
|
|
22
|
+
justifyContent = "space-between",
|
|
23
|
+
titleColor = "var(--color-primary)",
|
|
24
|
+
icon
|
|
25
|
+
}) {
|
|
26
|
+
return /* @__PURE__ */ jsxs(
|
|
27
|
+
Box,
|
|
28
|
+
{
|
|
29
|
+
onClick,
|
|
30
|
+
className: cn(className, "text-sm!"),
|
|
31
|
+
sx: __spreadValues({
|
|
32
|
+
width,
|
|
33
|
+
margin,
|
|
34
|
+
height,
|
|
35
|
+
borderRadius,
|
|
36
|
+
"@media (max-width: 768px)": { width: "100%" },
|
|
37
|
+
boxShadow: "0 0.15rem 0.5rem rgba(0, 0, 0, 0.16)"
|
|
38
|
+
}, onClick && { cursor: "pointer !important" }),
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsxs(
|
|
41
|
+
Box,
|
|
42
|
+
{
|
|
43
|
+
sx: {
|
|
44
|
+
justifyContent,
|
|
45
|
+
height: "24px",
|
|
46
|
+
color: "white",
|
|
47
|
+
display: "flex",
|
|
48
|
+
width: titleWidth,
|
|
49
|
+
overflow: "hidden",
|
|
50
|
+
padding: "0px 15px",
|
|
51
|
+
alignItems: "center",
|
|
52
|
+
flexDirection: "row",
|
|
53
|
+
borderRadius: borderTitle,
|
|
54
|
+
backgroundColor: titleColor
|
|
55
|
+
},
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 font-semibold! truncate!", children: /* @__PURE__ */ jsx(
|
|
58
|
+
Tooltip,
|
|
59
|
+
{
|
|
60
|
+
withArrow: true,
|
|
61
|
+
radius: "md",
|
|
62
|
+
label: title,
|
|
63
|
+
arrowSize: 6,
|
|
64
|
+
position: "top",
|
|
65
|
+
arrowOffset: 15,
|
|
66
|
+
disabled: !toolTip,
|
|
67
|
+
color: titleColor,
|
|
68
|
+
classNames: { tooltip: "text-xs!" },
|
|
69
|
+
offset: { mainAxis: 11, crossAxis: -21 },
|
|
70
|
+
transitionProps: { transition: "fade", duration: 100 },
|
|
71
|
+
children: /* @__PURE__ */ jsx("span", { className: "block! truncate!", children: title })
|
|
72
|
+
}
|
|
73
|
+
) }),
|
|
74
|
+
/* @__PURE__ */ jsx("div", { children: icon })
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
children
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
var card_default = Card;
|
|
84
|
+
|
|
85
|
+
// src/components/ui/dialog/utils/constants.ts
|
|
86
|
+
var DIALOG_BACKDROP_STYLE = {
|
|
87
|
+
backdropFilter: "blur(4px)",
|
|
88
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)"
|
|
89
|
+
};
|
|
90
|
+
function Dialog({
|
|
91
|
+
open,
|
|
92
|
+
title,
|
|
93
|
+
onClose,
|
|
94
|
+
actions,
|
|
95
|
+
children,
|
|
96
|
+
maxWidth,
|
|
97
|
+
blurBackdrop = false
|
|
98
|
+
}) {
|
|
99
|
+
const backdropStyle = blurBackdrop ? DIALOG_BACKDROP_STYLE : {};
|
|
100
|
+
return /* @__PURE__ */ jsxs(
|
|
101
|
+
DialogMui,
|
|
102
|
+
{
|
|
103
|
+
fullWidth: true,
|
|
104
|
+
open,
|
|
105
|
+
onClose,
|
|
106
|
+
maxWidth,
|
|
107
|
+
slotProps: { backdrop: { sx: backdropStyle } },
|
|
108
|
+
children: [
|
|
109
|
+
title && /* @__PURE__ */ jsx(DialogTitle, { children: /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold text-black-de", children: title }) }),
|
|
110
|
+
/* @__PURE__ */ jsx(DialogContent, { className: "text-black", children }),
|
|
111
|
+
actions && /* @__PURE__ */ jsx(DialogActions, { children: actions })
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
var dialog_default = Dialog;
|
|
117
|
+
|
|
118
|
+
export { card_default, dialog_default };
|
|
119
|
+
//# sourceMappingURL=chunk-CNXFSE26.mjs.map
|
|
120
|
+
//# sourceMappingURL=chunk-CNXFSE26.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/ui/card/index.tsx","../src/components/ui/dialog/utils/constants.ts","../src/components/ui/dialog/index.tsx"],"names":["jsxs","jsx"],"mappings":"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","file":"chunk-CNXFSE26.mjs","sourcesContent":["import { cn } from \"@/functions\";\r\nimport { Box } from \"@mui/material\";\r\nimport { Tooltip } from \"@mantine/core\";\r\nimport type { CardProps } from \"./utils/interface\";\r\n\r\n/**\r\n * Container de UI com cabeçalho colorido (título e ícone opcionais) e área de conteúdo.\r\n *\r\n * O card usa MUI `Box` para dimensões, sombra e responsividade; classes Tailwind\r\n * extras podem ser passadas em `className` e são mescladas com `cn`. O título é\r\n * sempre exibido e truncado quando necessário; o tooltip (Mantine) só aparece se\r\n * `toolTip` for `true`.\r\n *\r\n * @param props - Propriedades do componente. Detalhes em {@link CardProps}.\r\n * @param props.width - Largura do card. Padrão: `\"100%\"`.\r\n * @param props.height - Altura do card. Padrão: `\"auto\"`.\r\n * @param props.margin - Margem externa.\r\n * @param props.title - Texto do cabeçalho.\r\n * @param props.toolTip - Habilita tooltip no título.\r\n * @param props.className - `className` nativo do React no container.\r\n * @param props.titleWidth - Largura da barra do cabeçalho. Padrão: `\"100%\"`.\r\n * @param props.titleColor - Cor de fundo do cabeçalho. Padrão: `var(--color-primary)`.\r\n * @param props.borderTitle - `border-radius` só do cabeçalho.\r\n * @param props.onClick - Clique no card; adiciona `cursor: pointer !important`.\r\n * @param props.borderRadius - `border-radius` do container.\r\n * @param props.icon - Conteúdo à direita do título.\r\n * @param props.children - Corpo do card.\r\n * @param props.justifyContent - Alinhamento título/ícone. Padrão: `\"space-between\"`.\r\n *\r\n * @returns Elemento `Box` com cabeçalho e `children`.\r\n *\r\n * @example\r\n * ```tsx\r\n * <Card title=\"Resumo\" toolTip icon={<span>+</span>}>\r\n * <p>Conteúdo interno</p>\r\n * </Card>\r\n * ```\r\n *\r\n * @example\r\n * ```tsx\r\n * <Card\r\n * title=\"Clique aqui\"\r\n * width=\"320px\"\r\n * onClick={() => alert(\"Card clicado\")}\r\n * >\r\n * Card interativo\r\n * </Card>\r\n * ```\r\n */\r\nfunction Card({\r\n margin,\r\n onClick,\r\n title,\r\n toolTip,\r\n className,\r\n borderTitle,\r\n children,\r\n borderRadius,\r\n width = \"100%\",\r\n height = \"auto\",\r\n titleWidth = \"100%\",\r\n justifyContent = \"space-between\",\r\n titleColor = \"var(--color-primary)\",\r\n icon,\r\n}: Readonly<CardProps>): React.ReactElement {\r\n return (\r\n <Box\r\n onClick={onClick}\r\n className={cn(className, \"text-sm!\")}\r\n sx={{\r\n width,\r\n margin,\r\n height,\r\n borderRadius,\r\n \"@media (max-width: 768px)\": { width: \"100%\" },\r\n boxShadow: \"0 0.15rem 0.5rem rgba(0, 0, 0, 0.16)\",\r\n ...(onClick && { cursor: \"pointer !important\" }),\r\n }}\r\n >\r\n <Box\r\n sx={{\r\n justifyContent,\r\n height: \"24px\",\r\n color: \"white\",\r\n display: \"flex\",\r\n width: titleWidth,\r\n overflow: \"hidden\",\r\n padding: \"0px 15px\",\r\n alignItems: \"center\",\r\n flexDirection: \"row\",\r\n borderRadius: borderTitle,\r\n backgroundColor: titleColor,\r\n }}\r\n >\r\n <span className=\"min-w-0 flex-1 font-semibold! truncate!\">\r\n <Tooltip\r\n withArrow\r\n radius=\"md\"\r\n label={title}\r\n arrowSize={6}\r\n position=\"top\"\r\n arrowOffset={15}\r\n disabled={!toolTip}\r\n color={titleColor}\r\n classNames={{ tooltip: \"text-xs!\" }}\r\n offset={{ mainAxis: 11, crossAxis: -21 }}\r\n transitionProps={{ transition: \"fade\", duration: 100 }}\r\n >\r\n <span className=\"block! truncate!\">{title}</span>\r\n </Tooltip>\r\n </span>\r\n <div>{icon}</div>\r\n </Box>\r\n {children}\r\n </Box>\r\n );\r\n}\r\nexport default Card;\r\n","export const DIALOG_BACKDROP_STYLE = {\r\n backdropFilter: \"blur(4px)\",\r\n backgroundColor: \"rgba(0, 0, 0, 0.5)\",\r\n};\r\n\r\nconst dialogConstants = `\r\nModal de diálogo baseado no MUI \\`Dialog\\`, com título, conteúdo e ações opcionais.\r\nSuporta \\`maxWidth\\` e backdrop com blur via \\`blurBackdrop\\`.\r\n\r\n**Importação:**\r\n\\`\\`\\`tsx\r\nimport Dialog from \"@/components/ui/dialog\";\r\n// ou, no pacote publicado:\r\n// import { Dialog } from \"@grazziotin/react-components-next/ui\";\r\n\\`\\`\\`\r\n\r\n**Uso básico:**\r\n\\`\\`\\`tsx\r\nconst [open, setOpen] = useState(false);\r\n\r\n<Dialog\r\n open={open}\r\n title=\"Confirmar\"\r\n onClose={() => setOpen(false)}\r\n actions={<button type=\"button\">OK</button>}\r\n>\r\n Conteúdo do diálogo\r\n</Dialog>\r\n\\`\\`\\`\r\n`;\r\n\r\nexport default dialogConstants;\r\n","import React from \"react\";\r\nimport DialogMui from \"@mui/material/Dialog\";\r\nimport type { DialogProps } from \"./utils/interface\";\r\nimport DialogTitle from \"@mui/material/DialogTitle\";\r\nimport DialogActions from \"@mui/material/DialogActions\";\r\nimport DialogContent from \"@mui/material/DialogContent\";\r\nimport { DIALOG_BACKDROP_STYLE } from \"./utils/constants\";\r\n\r\n/**\r\n * Modal de diálogo baseado no MUI `Dialog`, com título, conteúdo e ações opcionais.\r\n *\r\n * O componente usa `fullWidth` por padrão e permite limitar a largura via `maxWidth`.\r\n * Com `blurBackdrop`, o fundo recebe desfoque e overlay escuro semitransparente.\r\n *\r\n * @param props - Propriedades do componente. Detalhes em {@link DialogProps}.\r\n * @param props.open - Controla se o diálogo está visível.\r\n * @param props.title - Título exibido no topo; omitido se não informado.\r\n * @param props.onClose - Callback ao fechar (clique fora, ESC ou botão de fechar do MUI).\r\n * @param props.actions - Rodapé com botões ou ações customizadas.\r\n * @param props.children - Conteúdo principal do diálogo.\r\n * @param props.maxWidth - Largura máxima do MUI (`xs`, `sm`, `md`, `lg`, `xl` ou `false`).\r\n * @param props.blurBackdrop - Aplica blur e escurecimento no backdrop. Padrão: `false`.\r\n *\r\n * @returns Instância do `Dialog` do Material UI.\r\n *\r\n * @example\r\n * ```tsx\r\n * const [open, setOpen] = useState(false);\r\n *\r\n * <Dialog\r\n * open={open}\r\n * title=\"Confirmar exclusão\"\r\n * onClose={() => setOpen(false)}\r\n * actions={<Button onClick={() => setOpen(false)}>OK</Button>}\r\n * >\r\n * Deseja realmente excluir este item?\r\n * </Dialog>\r\n * ```\r\n *\r\n * @example\r\n * ```tsx\r\n * <Dialog\r\n * open={open}\r\n * onClose={handleClose}\r\n * maxWidth=\"sm\"\r\n * blurBackdrop\r\n * >\r\n * Conteúdo sem título.\r\n * </Dialog>\r\n * ```\r\n */\r\nfunction Dialog({\r\n open,\r\n title,\r\n onClose,\r\n actions,\r\n children,\r\n maxWidth,\r\n blurBackdrop = false,\r\n}: Readonly<DialogProps>): React.ReactElement {\r\n const backdropStyle = blurBackdrop ? DIALOG_BACKDROP_STYLE : {};\r\n\r\n return (\r\n <DialogMui\r\n fullWidth\r\n open={open}\r\n onClose={onClose}\r\n maxWidth={maxWidth}\r\n slotProps={{ backdrop: { sx: backdropStyle } }}\r\n >\r\n {title && (\r\n <DialogTitle>\r\n <p className=\"text-sm font-semibold text-black-de\">{title}</p>\r\n </DialogTitle>\r\n )}\r\n <DialogContent className=\"text-black\">{children}</DialogContent>\r\n {actions && <DialogActions>{actions}</DialogActions>}\r\n </DialogMui>\r\n );\r\n}\r\n\r\nexport default Dialog;\r\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { twMerge } from 'tailwind-merge';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
function cn(...values) {
|
|
21
|
+
return twMerge(clsx(values));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/functions/nvl/nvl.ts
|
|
25
|
+
function nvl(value, defaultValue) {
|
|
26
|
+
return value != null ? value : defaultValue;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/core/remove-digits.ts
|
|
30
|
+
function removeDigits(value) {
|
|
31
|
+
return value.replace(/\D/g, "");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/functions/format-cpf-cnpj/format-cpf-cnpj.ts
|
|
35
|
+
function formatCpfCnpj(data) {
|
|
36
|
+
if (!data) return "";
|
|
37
|
+
const value = removeDigits(data);
|
|
38
|
+
if (!value) return "";
|
|
39
|
+
if (value.length <= 11) {
|
|
40
|
+
const cpf = value.slice(0, 11);
|
|
41
|
+
return cpf.replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d{1,2})$/, "$1-$2");
|
|
42
|
+
}
|
|
43
|
+
const cnpj = value.slice(0, 14);
|
|
44
|
+
return cnpj.replace(/^(\d{2})(\d)/, "$1.$2").replace(/^(\d{2})\.(\d{3})(\d)/, "$1.$2.$3").replace(/\.(\d{3})(\d)/, ".$1/$2").replace(/(\d{4})(\d)/, "$1-$2");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/functions/format-phone-br/format-phone-br.ts
|
|
48
|
+
function formatPhoneBr(phone) {
|
|
49
|
+
if (!phone) return "";
|
|
50
|
+
const digits = removeDigits(phone).slice(0, 11);
|
|
51
|
+
if (!digits) return "";
|
|
52
|
+
if (digits.length <= 2) return digits;
|
|
53
|
+
if (digits.length <= 6) {
|
|
54
|
+
return digits.replace(/(\d{2})(\d+)/, "($1) $2");
|
|
55
|
+
}
|
|
56
|
+
if (digits.length <= 10) {
|
|
57
|
+
return digits.replace(/(\d{2})(\d{4})(\d+)/, "($1) $2-$3");
|
|
58
|
+
}
|
|
59
|
+
return digits.replace(/(\d{2})(\d{5})(\d+)/, "($1) $2-$3");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { __spreadValues, cn, formatCpfCnpj, formatPhoneBr, nvl };
|
|
63
|
+
//# sourceMappingURL=chunk-NHHZBMJL.mjs.map
|
|
64
|
+
//# sourceMappingURL=chunk-NHHZBMJL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/functions/cn/cn.ts","../src/functions/nvl/nvl.ts","../src/core/remove-digits.ts","../src/functions/format-cpf-cnpj/format-cpf-cnpj.ts","../src/functions/format-phone-br/format-phone-br.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAIO,SAAS,MAAM,MAAA,EAA8B;AAClD,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;;;ACIO,SAAS,GAAA,CAAO,OAA6B,YAAA,EAAoB;AACtE,EAAA,OAAO,KAAA,IAAA,IAAA,GAAA,KAAA,GAAS,YAAA;AAClB;;;ACXO,SAAS,aAAa,KAAA,EAAuB;AAClD,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAChC;;;ACOO,SAAS,cAAc,IAAA,EAAuB;AACnD,EAAA,IAAI,CAAC,MAAM,OAAO,EAAA;AAClB,EAAA,MAAM,KAAA,GAAQ,aAAa,IAAI,CAAA;AAE/B,EAAA,IAAI,CAAC,OAAO,OAAO,EAAA;AACnB,EAAA,IAAI,KAAA,CAAM,UAAU,EAAA,EAAI;AACtB,IAAA,MAAM,GAAA,GAAM,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AAC7B,IAAA,OAAO,GAAA,CACJ,OAAA,CAAQ,aAAA,EAAe,OAAO,CAAA,CAC9B,OAAA,CAAQ,aAAA,EAAe,OAAO,CAAA,CAC9B,OAAA,CAAQ,mBAAA,EAAqB,OAAO,CAAA;AAAA,EACzC;AAEA,EAAA,MAAM,IAAA,GAAO,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AAC9B,EAAA,OAAO,IAAA,CACJ,OAAA,CAAQ,cAAA,EAAgB,OAAO,EAC/B,OAAA,CAAQ,uBAAA,EAAyB,UAAU,CAAA,CAC3C,QAAQ,eAAA,EAAiB,QAAQ,CAAA,CACjC,OAAA,CAAQ,eAAe,OAAO,CAAA;AACnC;;;ACnBO,SAAS,cAAc,KAAA,EAAwB;AACpD,EAAA,IAAI,CAAC,OAAO,OAAO,EAAA;AACnB,EAAA,MAAM,SAAS,YAAA,CAAa,KAAK,CAAA,CAAE,KAAA,CAAM,GAAG,EAAE,CAAA;AAE9C,EAAA,IAAI,CAAC,QAAQ,OAAO,EAAA;AACpB,EAAA,IAAI,MAAA,CAAO,MAAA,IAAU,CAAA,EAAG,OAAO,MAAA;AAC/B,EAAA,IAAI,MAAA,CAAO,UAAU,CAAA,EAAG;AACtB,IAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,cAAA,EAAgB,SAAS,CAAA;AAAA,EACjD;AACA,EAAA,IAAI,MAAA,CAAO,UAAU,EAAA,EAAI;AACvB,IAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,qBAAA,EAAuB,YAAY,CAAA;AAAA,EAC3D;AACA,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,qBAAA,EAAuB,YAAY,CAAA;AAC3D","file":"chunk-NHHZBMJL.mjs","sourcesContent":["import { twMerge } from \"tailwind-merge\";\r\nimport { clsx } from \"clsx\";\r\nimport type { ClassValue } from \"./utils/interfaces\";\r\n\r\nexport function cn(...values: ClassValue[]): string {\r\n return twMerge(clsx(values));\r\n}\r\n","/**\r\n * Função NVL (Null Value Logic) - retorna valor padrão se o valor for null/undefined\r\n * @param {T | null | undefined} value - Valor a ser verificado\r\n * @param {T} defaultValue - Valor padrão a ser retornado se value for null/undefined\r\n * @returns {T} Value se não for null/undefined, senão defaultValue\r\n * @template T - Tipo do valor\r\n * @example\r\n * nvl(null, 'padrão') // Retorna: 'padrão'\r\n * nvl('valor', 'padrão') // Retorna: 'valor'\r\n */\r\nexport function nvl<T>(value: T | null | undefined, defaultValue: T): T {\r\n return value ?? defaultValue;\r\n}\r\n","/** Remove tudo que não for dígito. */\r\nexport function removeDigits(value: string): string {\r\n return value.replace(/\\D/g, \"\");\r\n}\r\n","import { removeDigits } from \"../../core/remove-digits\";\r\n\r\n/**\r\n * Formata CPF (até 11 dígitos) ou CNPJ (12–14 dígitos) conforme o tamanho.\r\n * @param data - Valor com ou sem formatação\r\n * @returns CPF `000.000.000-00` ou CNPJ `00.000.000/0000-00`; string vazia se ausente\r\n * @example\r\n * formatCpfCnpj(\"12345678901\") // \"123.456.789-01\"\r\n * formatCpfCnpj(\"12345678000199\") // \"12.345.678/0001-99\"\r\n */\r\nexport function formatCpfCnpj(data?: string): string {\r\n if (!data) return \"\";\r\n const value = removeDigits(data);\r\n\r\n if (!value) return \"\";\r\n if (value.length <= 11) {\r\n const cpf = value.slice(0, 11);\r\n return cpf\r\n .replace(/(\\d{3})(\\d)/, \"$1.$2\")\r\n .replace(/(\\d{3})(\\d)/, \"$1.$2\")\r\n .replace(/(\\d{3})(\\d{1,2})$/, \"$1-$2\");\r\n }\r\n\r\n const cnpj = value.slice(0, 14);\r\n return cnpj\r\n .replace(/^(\\d{2})(\\d)/, \"$1.$2\")\r\n .replace(/^(\\d{2})\\.(\\d{3})(\\d)/, \"$1.$2.$3\")\r\n .replace(/\\.(\\d{3})(\\d)/, \".$1/$2\")\r\n .replace(/(\\d{4})(\\d)/, \"$1-$2\");\r\n}\r\n","import { removeDigits } from \"../../core/remove-digits\";\r\n\r\n/**\r\n * Formata telefone brasileiro (até 11 dígitos): fixo `(00) 0000-0000` ou celular `(00) 00000-0000`.\r\n * @param phone - Valor com ou sem formatação\r\n * @returns Telefone formatado ou string vazia se ausente\r\n * @example\r\n * formatPhoneBr(\"11987654321\") // \"(11) 98765-4321\"\r\n * formatPhoneBr(\"1133334444\") // \"(11) 3333-4444\"\r\n */\r\nexport function formatPhoneBr(phone?: string): string {\r\n if (!phone) return \"\";\r\n const digits = removeDigits(phone).slice(0, 11);\r\n\r\n if (!digits) return \"\";\r\n if (digits.length <= 2) return digits;\r\n if (digits.length <= 6) {\r\n return digits.replace(/(\\d{2})(\\d+)/, \"($1) $2\");\r\n }\r\n if (digits.length <= 10) {\r\n return digits.replace(/(\\d{2})(\\d{4})(\\d+)/, \"($1) $2-$3\");\r\n }\r\n return digits.replace(/(\\d{2})(\\d{5})(\\d+)/, \"($1) $2-$3\");\r\n}\r\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
export { ClassValue } from 'clsx';
|
|
3
|
+
|
|
4
|
+
declare function cn(...values: ClassValue[]): string;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Função NVL (Null Value Logic) - retorna valor padrão se o valor for null/undefined
|
|
8
|
+
* @param {T | null | undefined} value - Valor a ser verificado
|
|
9
|
+
* @param {T} defaultValue - Valor padrão a ser retornado se value for null/undefined
|
|
10
|
+
* @returns {T} Value se não for null/undefined, senão defaultValue
|
|
11
|
+
* @template T - Tipo do valor
|
|
12
|
+
* @example
|
|
13
|
+
* nvl(null, 'padrão') // Retorna: 'padrão'
|
|
14
|
+
* nvl('valor', 'padrão') // Retorna: 'valor'
|
|
15
|
+
*/
|
|
16
|
+
declare function nvl<T>(value: T | null | undefined, defaultValue: T): T;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Formata CPF (até 11 dígitos) ou CNPJ (12–14 dígitos) conforme o tamanho.
|
|
20
|
+
* @param data - Valor com ou sem formatação
|
|
21
|
+
* @returns CPF `000.000.000-00` ou CNPJ `00.000.000/0000-00`; string vazia se ausente
|
|
22
|
+
* @example
|
|
23
|
+
* formatCpfCnpj("12345678901") // "123.456.789-01"
|
|
24
|
+
* formatCpfCnpj("12345678000199") // "12.345.678/0001-99"
|
|
25
|
+
*/
|
|
26
|
+
declare function formatCpfCnpj(data?: string): string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Formata telefone brasileiro (até 11 dígitos): fixo `(00) 0000-0000` ou celular `(00) 00000-0000`.
|
|
30
|
+
* @param phone - Valor com ou sem formatação
|
|
31
|
+
* @returns Telefone formatado ou string vazia se ausente
|
|
32
|
+
* @example
|
|
33
|
+
* formatPhoneBr("11987654321") // "(11) 98765-4321"
|
|
34
|
+
* formatPhoneBr("1133334444") // "(11) 3333-4444"
|
|
35
|
+
*/
|
|
36
|
+
declare function formatPhoneBr(phone?: string): string;
|
|
37
|
+
|
|
38
|
+
export { cn, formatCpfCnpj, formatPhoneBr, nvl };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
export { ClassValue } from 'clsx';
|
|
3
|
+
|
|
4
|
+
declare function cn(...values: ClassValue[]): string;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Função NVL (Null Value Logic) - retorna valor padrão se o valor for null/undefined
|
|
8
|
+
* @param {T | null | undefined} value - Valor a ser verificado
|
|
9
|
+
* @param {T} defaultValue - Valor padrão a ser retornado se value for null/undefined
|
|
10
|
+
* @returns {T} Value se não for null/undefined, senão defaultValue
|
|
11
|
+
* @template T - Tipo do valor
|
|
12
|
+
* @example
|
|
13
|
+
* nvl(null, 'padrão') // Retorna: 'padrão'
|
|
14
|
+
* nvl('valor', 'padrão') // Retorna: 'valor'
|
|
15
|
+
*/
|
|
16
|
+
declare function nvl<T>(value: T | null | undefined, defaultValue: T): T;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Formata CPF (até 11 dígitos) ou CNPJ (12–14 dígitos) conforme o tamanho.
|
|
20
|
+
* @param data - Valor com ou sem formatação
|
|
21
|
+
* @returns CPF `000.000.000-00` ou CNPJ `00.000.000/0000-00`; string vazia se ausente
|
|
22
|
+
* @example
|
|
23
|
+
* formatCpfCnpj("12345678901") // "123.456.789-01"
|
|
24
|
+
* formatCpfCnpj("12345678000199") // "12.345.678/0001-99"
|
|
25
|
+
*/
|
|
26
|
+
declare function formatCpfCnpj(data?: string): string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Formata telefone brasileiro (até 11 dígitos): fixo `(00) 0000-0000` ou celular `(00) 00000-0000`.
|
|
30
|
+
* @param phone - Valor com ou sem formatação
|
|
31
|
+
* @returns Telefone formatado ou string vazia se ausente
|
|
32
|
+
* @example
|
|
33
|
+
* formatPhoneBr("11987654321") // "(11) 98765-4321"
|
|
34
|
+
* formatPhoneBr("1133334444") // "(11) 3333-4444"
|
|
35
|
+
*/
|
|
36
|
+
declare function formatPhoneBr(phone?: string): string;
|
|
37
|
+
|
|
38
|
+
export { cn, formatCpfCnpj, formatPhoneBr, nvl };
|