@desynth/web-components-react 13.11.25-alpha.4 → 14.9.26-alpha.1
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/dist/components.d.ts +312 -8
- package/dist/components.js +560 -8
- package/package.json +40 -46
- package/readme.md +225 -11
package/package.json
CHANGED
|
@@ -1,48 +1,42 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"typescript": "5.2.2"
|
|
43
|
-
},
|
|
44
|
-
"peerDependencies": {
|
|
45
|
-
"react": ">=19.2.0",
|
|
46
|
-
"react-dom": ">=19.2.0"
|
|
47
|
-
}
|
|
2
|
+
"name": "@desynth/web-components-react",
|
|
3
|
+
"sideEffects": false,
|
|
4
|
+
"version": "14.09.26-alpha.01",
|
|
5
|
+
"description": "React proxy for @desynth/web-components",
|
|
6
|
+
"license": "MPL-2.0",
|
|
7
|
+
"homepage": "https://github.com/desynth/desynth-web-components#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/desynth/desynth-web-components.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/desynth/desynth-web-components/issues"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "npm run tsc",
|
|
20
|
+
"tsc": "tsc -p ."
|
|
21
|
+
},
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"module": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist/"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/react": "19.2.4",
|
|
31
|
+
"@types/react-dom": "19.2.3"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"react": ">=19.2.0",
|
|
35
|
+
"react-dom": ">=19.2.0",
|
|
36
|
+
"typescript": "5.2.2"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react": ">=19.2.0",
|
|
40
|
+
"react-dom": ">=19.2.0"
|
|
41
|
+
}
|
|
48
42
|
}
|
package/readme.md
CHANGED
|
@@ -1,15 +1,229 @@
|
|
|
1
|
-
# desynth
|
|
2
|
-
|
|
1
|
+
# `@desynth/web-components-react`
|
|
2
|
+
|
|
3
|
+
Wrappers React tipados para los Custom Elements de `@desynth/web-components`, generados por `@stencil/react-output-target`.
|
|
4
|
+
|
|
5
|
+
## Requisitos e instalación
|
|
6
|
+
|
|
7
|
+
El paquete declara `react >= 19.2.0` y `react-dom >= 19.2.0` como peer dependencies. Los wrappers importan las clases y tipos del paquete core, por lo que debe instalarse también:
|
|
3
8
|
|
|
4
9
|
```bash
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
npm install @desynth/web-components-react @desynth/web-components react react-dom
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Conviene mantener `@desynth/web-components-react` y `@desynth/web-components` en versiones compatibles, especialmente en versiones alpha.
|
|
14
|
+
|
|
15
|
+
## Uso
|
|
16
|
+
|
|
17
|
+
Todos los wrappers se exportan desde la entrada principal:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import {
|
|
21
|
+
DesynthButton,
|
|
22
|
+
DesynthDataTable,
|
|
23
|
+
} from '@desynth/web-components-react';
|
|
24
|
+
|
|
25
|
+
export function Example() {
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
<DesynthButton buttonText="Guardar" variant="solid" />
|
|
29
|
+
<DesynthDataTable
|
|
30
|
+
columns={JSON.stringify([{ key: 'name', label: 'Nombre' }])}
|
|
31
|
+
rows={JSON.stringify([{ id: '1', name: 'Ada' }])}
|
|
32
|
+
emptyText="Sin resultados"
|
|
33
|
+
/>
|
|
34
|
+
</>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
12
37
|
```
|
|
13
|
-
## General Solution's Architecture Design
|
|
14
|
-

|
|
15
38
|
|
|
39
|
+
Las exportaciones usan nombres PascalCase derivados de las clases generadas: `DesynthButton`, `DesynthTextInput`, `HorizontalCards` y `HtmlEditor`, entre otras.
|
|
40
|
+
|
|
41
|
+
## Registro de Custom Elements
|
|
42
|
+
|
|
43
|
+
No llames a `defineCustomElements()` para usar estos wrappers. Cada wrapper generado recibe su propia función `defineCustomElement` desde `@desynth/web-components/dist/<tag>.js` y registra ese elemento al cargarse.
|
|
44
|
+
|
|
45
|
+
El loader global solo es necesario si, además de los wrappers React, la aplicación renderiza etiquetas Custom Element directamente y quiere registrarlas en bloque:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { defineCustomElements } from '@desynth/web-components/loader';
|
|
49
|
+
|
|
50
|
+
defineCustomElements();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
No mezcles ambos mecanismos por rutina: los registros individuales ya comprueban si el elemento existe y el loader global añade trabajo innecesario cuando toda la UI usa wrappers.
|
|
54
|
+
|
|
55
|
+
## Propiedades y nombres
|
|
56
|
+
|
|
57
|
+
En JSX se usan los nombres de propiedad de Stencil en camelCase, no los atributos HTML en kebab-case:
|
|
58
|
+
|
|
59
|
+
| Web Component | React |
|
|
60
|
+
| --- | --- |
|
|
61
|
+
| `button-text` | `buttonText` |
|
|
62
|
+
| `empty-text` | `emptyText` |
|
|
63
|
+
| `preview-url` | `previewUrl` |
|
|
64
|
+
| `button-id` | `buttonId` |
|
|
65
|
+
|
|
66
|
+
Las propiedades booleanas reciben booleanos reales:
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
<DesynthButton disabled={isSaving} full buttonText="Guardar" />
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Los tipos de cada wrapper proceden del paquete core y están incluidos en `dist/components.d.ts`.
|
|
73
|
+
|
|
74
|
+
## Datos JSON
|
|
75
|
+
|
|
76
|
+
Varias propiedades complejas del core están declaradas como `string` y el componente ejecuta `JSON.parse` internamente. En esos casos hay que serializar arrays y objetos también desde React; pasar el objeto directamente contradice la API generada.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { DesynthDataTable } from '@desynth/web-components-react';
|
|
80
|
+
|
|
81
|
+
type Row = {
|
|
82
|
+
id: string;
|
|
83
|
+
name: string;
|
|
84
|
+
status: 'active' | 'paused';
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const columns = [
|
|
88
|
+
{ key: 'name', label: 'Nombre' },
|
|
89
|
+
{ key: 'status', label: 'Estado' },
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
const rows: Row[] = [
|
|
93
|
+
{ id: 'usr-1', name: 'Ada', status: 'active' },
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
export function UsersTable() {
|
|
97
|
+
return (
|
|
98
|
+
<DesynthDataTable
|
|
99
|
+
columns={JSON.stringify(columns)}
|
|
100
|
+
rows={JSON.stringify(rows)}
|
|
101
|
+
badges={JSON.stringify({
|
|
102
|
+
status: { active: '#18864b', paused: '#8a6400' },
|
|
103
|
+
})}
|
|
104
|
+
actions={JSON.stringify([
|
|
105
|
+
{ key: 'open', label: 'Abrir' },
|
|
106
|
+
])}
|
|
107
|
+
onHandleAction={(event) => {
|
|
108
|
+
const { rowId, action } = event.detail;
|
|
109
|
+
console.log(rowId, action);
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
No todas las propiedades con datos son JSON. Revisa el tipo exportado o la referencia del componente core antes de serializar.
|
|
117
|
+
|
|
118
|
+
## Eventos
|
|
119
|
+
|
|
120
|
+
Los eventos de Stencil se convierten en props React con prefijo `on` y PascalCase:
|
|
121
|
+
|
|
122
|
+
| Evento DOM | Prop React |
|
|
123
|
+
| --- | --- |
|
|
124
|
+
| `handleClick` | `onHandleClick` |
|
|
125
|
+
| `handleChange` | `onHandleChange` |
|
|
126
|
+
| `handleAction` | `onHandleAction` |
|
|
127
|
+
| `htmlChanged` | `onHtmlChanged` |
|
|
128
|
+
|
|
129
|
+
El callback recibe un `CustomEvent` tipado; la carga útil está en `event.detail`.
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import { DesynthTextInput } from '@desynth/web-components-react';
|
|
133
|
+
|
|
134
|
+
export function Search() {
|
|
135
|
+
return (
|
|
136
|
+
<DesynthTextInput
|
|
137
|
+
inputId="search"
|
|
138
|
+
inputName="Buscar"
|
|
139
|
+
onHandleInput={(event) => {
|
|
140
|
+
console.log(event.detail.value);
|
|
141
|
+
}}
|
|
142
|
+
/>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Usa el nombre exacto expuesto por el wrapper. No lo sustituyas por `onClick` o `onChange` salvo que la API tipada del componente lo declare.
|
|
148
|
+
|
|
149
|
+
## Slots y `children`
|
|
150
|
+
|
|
151
|
+
El contenido hijo se proyecta al slot por defecto. Para un slot con nombre, añade `slot` al nodo hijo:
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
import {
|
|
155
|
+
DesynthBookCard,
|
|
156
|
+
DesynthButton,
|
|
157
|
+
} from '@desynth/web-components-react';
|
|
158
|
+
|
|
159
|
+
export function Book() {
|
|
160
|
+
return (
|
|
161
|
+
<DesynthBookCard
|
|
162
|
+
title="Diseño de sistemas"
|
|
163
|
+
chapters={JSON.stringify(['Introducción', 'Arquitectura'])}
|
|
164
|
+
>
|
|
165
|
+
<div slot="actions">
|
|
166
|
+
<DesynthButton buttonText="Leer" size="xs" />
|
|
167
|
+
</div>
|
|
168
|
+
</DesynthBookCard>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Los nombres de slot disponibles dependen del componente core; no existe una lista universal.
|
|
174
|
+
|
|
175
|
+
## SSR y React Server Components
|
|
176
|
+
|
|
177
|
+
El archivo generado comienza con `'use client'`. Los wrappers registran Custom Elements y están destinados al navegador:
|
|
178
|
+
|
|
179
|
+
- impórtalos y renderízalos desde componentes cliente;
|
|
180
|
+
- en Next.js App Router, coloca el uso detrás de un archivo con `'use client'`;
|
|
181
|
+
- no dependas de que el Shadow DOM esté renderizado en el HTML del servidor;
|
|
182
|
+
- si el bundler evalúa módulos DOM durante SSR, carga el componente cliente de forma dinámica con SSR desactivado.
|
|
183
|
+
|
|
184
|
+
Ejemplo para Next.js:
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
'use client';
|
|
188
|
+
|
|
189
|
+
import { DesynthButton } from '@desynth/web-components-react';
|
|
190
|
+
|
|
191
|
+
export function SaveButton() {
|
|
192
|
+
return <DesynthButton buttonText="Guardar" />;
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
El paquete core genera una salida `dist/hydrate`, pero este paquete React no configura por sí mismo una integración SSR o de hidratación para el framework.
|
|
197
|
+
|
|
198
|
+
## Tokens
|
|
199
|
+
|
|
200
|
+
Carga el tema CSS una sola vez desde la hoja global de la aplicación:
|
|
201
|
+
|
|
202
|
+
```css
|
|
203
|
+
@import '@desynth/style-tokens/dist/assets/css/variables-all.css';
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
El CSS de tokens llega como dependencia transitiva del core, pero su importación es explícita. Consulta el README de `@desynth/web-components` para las variantes de tema publicadas.
|
|
207
|
+
|
|
208
|
+
## Desarrollo local y sincronización
|
|
209
|
+
|
|
210
|
+
`src/components.ts` es generado: no debe editarse a mano. El flujo local correcto, desde la raíz del monorepo, es:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
npm run build --workspace=@desynth/web-components
|
|
214
|
+
npm run build --workspace=@desynth/web-components-react
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
El build de Stencil ejecuta el React output target y vuelve a generar `packages/components-react/src`; después, el script del wrapper ejecuta TypeScript y sincroniza `dist/`. Si solo se compila este paquete sin regenerar primero el core, los proxies pueden quedar desalineados con el catálogo actual.
|
|
218
|
+
|
|
219
|
+
El paquete React publica únicamente `dist/` y su script disponible es:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
npm run build # equivalente a: npm run tsc
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
No hay script de tests definido en este paquete.
|
|
226
|
+
|
|
227
|
+
## Licencia
|
|
228
|
+
|
|
229
|
+
MPL-2.0 según el manifiesto del paquete.
|