@rubenpazch/ui 0.0.0-stage → 0.3.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/AGENTS.md +156 -0
- package/README.md +25 -2
- package/dist/base.css +97 -0
- package/dist/index.cjs.js +585 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.esm.js +53 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/tailwind.css +126 -0
- package/dist/tokens.css +172 -0
- package/docs/COMPONENTES.md +1751 -0
- package/docs/ICONOS.md +131 -0
- package/docs/catalogo.json +7669 -0
- package/package.json +104 -3
package/AGENTS.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Lbyte UI — instrucciones para agentes (y personas)
|
|
2
|
+
|
|
3
|
+
Este archivo viaja dentro del paquete npm: si lo estás leyendo en
|
|
4
|
+
`node_modules/@rubenpazch/ui/AGENTS.md`, describe **exactamente la versión instalada** en esta app.
|
|
5
|
+
|
|
6
|
+
## Regla principal
|
|
7
|
+
|
|
8
|
+
**Toda interfaz de una app Lbyte se construye con `@rubenpazch/ui`.** Antes de escribir un
|
|
9
|
+
botón, un campo, un modal, una paginación, un loader o un icono, búscalo en el catálogo:
|
|
10
|
+
|
|
11
|
+
- `node_modules/@rubenpazch/ui/docs/COMPONENTES.md` — catálogo legible: qué es cada componente,
|
|
12
|
+
cuándo usarlo, cuándo no, y sus props con tipos y valores posibles.
|
|
13
|
+
- `node_modules/@rubenpazch/ui/docs/catalogo.json` — lo mismo en JSON (también exportado como
|
|
14
|
+
`@rubenpazch/ui/catalogo.json`).
|
|
15
|
+
|
|
16
|
+
Si un componente existe, úsalo; no lo reescribas ni lo copies con Tailwind.
|
|
17
|
+
|
|
18
|
+
## Instalación y configuración (una vez por app)
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @rubenpazch/ui
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Con Tailwind 4** (las apps Next.js de Lbyte) — en el CSS global (`app/globals.css`):
|
|
25
|
+
|
|
26
|
+
```css
|
|
27
|
+
@import "tailwindcss";
|
|
28
|
+
@import "@rubenpazch/ui/tokens.css";
|
|
29
|
+
@import "@rubenpazch/ui/tailwind.css";
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Sin Tailwind** — en el layout raíz:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import "@rubenpazch/ui/tokens.css";
|
|
36
|
+
import "@rubenpazch/ui/base.css"; // opcional: tipografía y colores base en body, h1…h6, a
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
No hace falta configurar nada más: cada componente trae su propio CSS.
|
|
40
|
+
|
|
41
|
+
## Cómo importar
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import {
|
|
45
|
+
Button,
|
|
46
|
+
TextInput,
|
|
47
|
+
ConfirmationDialog,
|
|
48
|
+
CheckIcon,
|
|
49
|
+
} from "@rubenpazch/ui";
|
|
50
|
+
import type { ButtonProps, SelectOption } from "@rubenpazch/ui";
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Siempre desde `@rubenpazch/ui`, nunca desde los paquetes sueltos (`@rubenpazch/button`…) ni desde
|
|
54
|
+
rutas internas (`dist/…`).
|
|
55
|
+
|
|
56
|
+
## Next.js (App Router)
|
|
57
|
+
|
|
58
|
+
- El paquete está marcado `"use client"`: puedes importarlo desde cualquier archivo, incluso
|
|
59
|
+
páginas que son Server Components.
|
|
60
|
+
- Un **Server Component no puede pasar funciones** (`onChange`, `onClick`, `onClose`…) a un
|
|
61
|
+
componente. Los formularios y todo lo que tenga eventos o estado van en un componente propio con
|
|
62
|
+
`"use client"` al inicio, que la página importa. Componentes sin eventos (`Button` sin `onClick`,
|
|
63
|
+
`InfoRow`, `Stepper`, iconos) se pueden usar directo en la página.
|
|
64
|
+
- Funciona con `output: "export"` (sitios estáticos).
|
|
65
|
+
|
|
66
|
+
## Estilos
|
|
67
|
+
|
|
68
|
+
- Usa los **tokens**, nunca colores en hexadecimal ni tamaños sueltos:
|
|
69
|
+
- Tailwind: utilidades con prefijo `lb`: `bg-lb-primary`, `text-lb-foreground`,
|
|
70
|
+
`text-lb-muted-foreground`, `border-lb-border`, `rounded-lb-md`, `shadow-lb-md`, `p-lb-4`,
|
|
71
|
+
`gap-lb-2`, `text-lb-sm`, `font-lb-sans`.
|
|
72
|
+
- CSS: `var(--lb-color-primary)`, `var(--lb-space-4)`, `var(--lb-radius-md)`…
|
|
73
|
+
- La lista completa está en `@rubenpazch/ui/tokens.css`.
|
|
74
|
+
- Tema oscuro: `data-theme="dark"` en `<html>` (o en un contenedor). Los tokens y las utilidades
|
|
75
|
+
`lb-*` cambian solos.
|
|
76
|
+
- Para ajustar un componente usa sus props (`variant`, `color`, `size`, `fullWidth`…) y, si hace
|
|
77
|
+
falta, `className` para márgenes o posición. No sobrescribas sus clases internas.
|
|
78
|
+
- Para Tailwind puro (layout, grid, flex) usa las utilidades normales; para color, tipografía,
|
|
79
|
+
radios, sombras y espacios del sistema, las `lb-*`.
|
|
80
|
+
|
|
81
|
+
## Qué usar para cada cosa
|
|
82
|
+
|
|
83
|
+
| Necesito… | Usa |
|
|
84
|
+
| --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
85
|
+
| El layout de un panel (menú lateral, cabecera, contenido) | `AppShell` (o solo `Sidebar`) en `app/(panel)/layout.tsx`, con `currentPath={usePathname()}` y `linkComponent={Link}` |
|
|
86
|
+
| La cabecera de cada página | `PageHeader` (migas, título h1, acciones) |
|
|
87
|
+
| Un listado de registros | `DataTable` + `Pagination` (`onPageChange`) + `EmptyState` |
|
|
88
|
+
| Un formulario | `FormRow` (columnas) + campos (`TextInput`, `Textarea`, `Select`, `Autocomplete`, `DateInput`, `MoneyInput`, `Switch`…) + `FormActions` |
|
|
89
|
+
| Montos de dinero | `MoneyInput` para editar, `formatMoney()` para mostrar |
|
|
90
|
+
| Elegir el mes de trabajo | `MonthNavigator` |
|
|
91
|
+
| Mostrar un estado | `Badge` |
|
|
92
|
+
| Agrupar información | `Card` + `CardHeader` / `CardBody` / `CardFooter` |
|
|
93
|
+
| Avisos en la página / pasajeros | `Alert` / `Toast` |
|
|
94
|
+
| Confirmar / editar en ventana | `ConfirmationDialog` / `Modal` |
|
|
95
|
+
| Acciones de una fila | `Menu` (⋮) |
|
|
96
|
+
| Cargando | `Skeleton` (contenido), `LoadingSpinner` (botón), `OverlayLoader` (pantalla), `ProgressBar` (avance) |
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
// app/(panel)/layout.tsx
|
|
100
|
+
"use client";
|
|
101
|
+
import Link from "next/link";
|
|
102
|
+
import { usePathname } from "next/navigation";
|
|
103
|
+
import { AppShell, HomeIcon, DocumentIcon } from "@rubenpazch/ui";
|
|
104
|
+
|
|
105
|
+
export default function PanelLayout({
|
|
106
|
+
children,
|
|
107
|
+
}: {
|
|
108
|
+
children: React.ReactNode;
|
|
109
|
+
}) {
|
|
110
|
+
return (
|
|
111
|
+
<AppShell
|
|
112
|
+
brand={<strong>Finanzas</strong>}
|
|
113
|
+
currentPath={usePathname()}
|
|
114
|
+
linkComponent={Link}
|
|
115
|
+
storageKey="menu-finanzas"
|
|
116
|
+
sections={[
|
|
117
|
+
{
|
|
118
|
+
items: [
|
|
119
|
+
{ label: "Inicio", href: "/", icon: <HomeIcon /> },
|
|
120
|
+
{
|
|
121
|
+
label: "Obligaciones",
|
|
122
|
+
href: "/obligaciones",
|
|
123
|
+
icon: <DocumentIcon />,
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
]}
|
|
128
|
+
>
|
|
129
|
+
{children}
|
|
130
|
+
</AppShell>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Textos
|
|
136
|
+
|
|
137
|
+
La interfaz va en **español**. Varios componentes reciben un objeto `labels` con todos sus textos
|
|
138
|
+
(por ejemplo `ImageUpload`, `IdentificationInput`, `PatientDetails`, `PrescriptionCard`):
|
|
139
|
+
pásalo siempre completo y en español.
|
|
140
|
+
|
|
141
|
+
## Si falta un componente
|
|
142
|
+
|
|
143
|
+
1. Confirma en `COMPONENTES.md` que no existe (revisa también variantes de uno parecido).
|
|
144
|
+
2. Si es **reutilizable** (lo usarían otras apps): no lo construyas dentro de la app. Agrégalo a la
|
|
145
|
+
librería [`rubenpazch/lbyte-ui-library`](https://github.com/rubenpazch/lbyte-ui-library)
|
|
146
|
+
siguiendo su `AGENTS.md` (`pnpm generate-package <nombre>`), publícalo y luego úsalo aquí.
|
|
147
|
+
Si no puedes hacerlo ahora, créalo en la app en `src/components/` con tokens `lb-*` y anota
|
|
148
|
+
en el README de la app que debe migrarse a la librería.
|
|
149
|
+
3. Si es **específico de esta app** (una composición: tarjeta de una obligación, fila de una
|
|
150
|
+
tabla concreta), créalo en la app **componiendo** componentes de `@rubenpazch/ui`.
|
|
151
|
+
|
|
152
|
+
## Categorías
|
|
153
|
+
|
|
154
|
+
`base` (tokens, utilidades) · `acciones` · `formularios` · `navegacion` · `retroalimentacion` ·
|
|
155
|
+
`presentacion` · `datos` · `iconos` · `salud` (pacientes y recetas ópticas: úsalos solo en apps
|
|
156
|
+
clínicas u ópticas).
|
package/README.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @rubenpazch/ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Todos los componentes de **Lbyte UI** en un solo paquete: botones, formularios, navegación,
|
|
4
|
+
mensajes, iconos, tokens de diseño y componentes de salud.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @rubenpazch/ui
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```css
|
|
11
|
+
/* app/globals.css (Tailwind 4) */
|
|
12
|
+
@import "tailwindcss";
|
|
13
|
+
@import "@rubenpazch/ui/tokens.css";
|
|
14
|
+
@import "@rubenpazch/ui/tailwind.css";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Button, TextInput } from "@rubenpazch/ui";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- Catálogo de componentes con props: [docs/COMPONENTES.md](docs/COMPONENTES.md)
|
|
22
|
+
- Instrucciones para agentes de IA y reglas de uso: [AGENTS.md](AGENTS.md)
|
|
23
|
+
- Storybook (todas las variantes en vivo): https://ui.lbyte.pe
|
|
24
|
+
|
|
25
|
+
Este paquete solo reexporta los paquetes `@rubenpazch/*`; se publica junto con ellos desde
|
|
26
|
+
[lbyte-ui-library](https://github.com/rubenpazch/lbyte-ui-library).
|
package/dist/base.css
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lbyte base element styles — apply the design tokens to raw HTML elements so
|
|
3
|
+
* typography and colors are consistent across every project without extra
|
|
4
|
+
* classes. Import AFTER tokens.css:
|
|
5
|
+
*
|
|
6
|
+
* import "@rubenpazch/tokens/tokens.css";
|
|
7
|
+
* import "@rubenpazch/tokens/base.css";
|
|
8
|
+
*
|
|
9
|
+
* Selectors use :where() so their specificity is 0 — any app or component
|
|
10
|
+
* style overrides them effortlessly.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
:where(body) {
|
|
14
|
+
margin: 0;
|
|
15
|
+
font-family: var(--lb-font-sans);
|
|
16
|
+
font-size: var(--lb-font-size-body);
|
|
17
|
+
font-weight: var(--lb-font-weight-regular);
|
|
18
|
+
line-height: var(--lb-line-height-normal);
|
|
19
|
+
color: var(--lb-color-foreground);
|
|
20
|
+
background-color: var(--lb-color-background);
|
|
21
|
+
-webkit-font-smoothing: antialiased;
|
|
22
|
+
-moz-osx-font-smoothing: grayscale;
|
|
23
|
+
text-rendering: optimizeLegibility;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:where(h1, h2, h3, h4, h5, h6) {
|
|
27
|
+
margin: 0 0 var(--lb-space-4);
|
|
28
|
+
font-family: var(--lb-font-sans);
|
|
29
|
+
font-weight: var(--lb-font-weight-bold);
|
|
30
|
+
line-height: var(--lb-line-height-tight);
|
|
31
|
+
letter-spacing: var(--lb-letter-spacing-tight);
|
|
32
|
+
color: var(--lb-color-foreground);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
:where(h1) {
|
|
36
|
+
font-size: var(--lb-font-size-h1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:where(h2) {
|
|
40
|
+
font-size: var(--lb-font-size-h2);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:where(h3) {
|
|
44
|
+
font-size: var(--lb-font-size-h3);
|
|
45
|
+
font-weight: var(--lb-font-weight-semibold);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:where(h4) {
|
|
49
|
+
font-size: var(--lb-font-size-h4);
|
|
50
|
+
font-weight: var(--lb-font-weight-semibold);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
:where(h5) {
|
|
54
|
+
font-size: var(--lb-font-size-h5);
|
|
55
|
+
font-weight: var(--lb-font-weight-semibold);
|
|
56
|
+
line-height: var(--lb-line-height-snug);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:where(h6) {
|
|
60
|
+
font-size: var(--lb-font-size-h6);
|
|
61
|
+
font-weight: var(--lb-font-weight-semibold);
|
|
62
|
+
line-height: var(--lb-line-height-snug);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:where(p) {
|
|
66
|
+
margin: 0 0 var(--lb-space-4);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
:where(small) {
|
|
70
|
+
font-size: var(--lb-font-size-small);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
:where(a) {
|
|
74
|
+
color: var(--lb-color-link);
|
|
75
|
+
text-decoration: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
:where(a:hover) {
|
|
79
|
+
color: var(--lb-color-link-hover);
|
|
80
|
+
text-decoration: underline;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:where(code, pre, kbd, samp) {
|
|
84
|
+
font-family: var(--lb-font-mono);
|
|
85
|
+
font-size: 0.9em;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:where(hr) {
|
|
89
|
+
border: none;
|
|
90
|
+
border-top: 1px solid var(--lb-color-border);
|
|
91
|
+
margin: var(--lb-space-6) 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
:where(:focus-visible) {
|
|
95
|
+
outline: 2px solid var(--lb-color-ring);
|
|
96
|
+
outline-offset: 2px;
|
|
97
|
+
}
|