ywana-core8 0.1.78 → 0.1.80
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/index.cjs +3244 -2215
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2127 -1063
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +3244 -2215
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +3244 -2215
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/ExampleLayout.css +401 -0
- package/src/html/ExampleLayout.js +192 -0
- package/src/html/README-sidebar-navigation.md +195 -0
- package/src/html/accordion.example.js +123 -4
- package/src/html/accordion.example.js.backup +390 -0
- package/src/html/button.example.js +50 -3
- package/src/html/button.example.js.backup +374 -0
- package/src/html/button.example.new.js +416 -0
- package/src/html/checkbox.example.js +93 -4
- package/src/html/checkbox.example.js.backup +316 -0
- package/src/html/chip.example.js +108 -4
- package/src/html/chip.example.js.backup +355 -0
- package/src/html/color.example.js +108 -4
- package/src/html/color.example.js.backup +527 -0
- package/src/html/components.example.js +123 -4
- package/src/html/components.example.js.backup +492 -0
- package/src/html/convert-examples.js +183 -0
- package/src/html/demo-sidebar.html +410 -0
- package/src/html/form.example.js +93 -4
- package/src/html/form.example.js.backup +385 -0
- package/src/html/header2.example.js +108 -4
- package/src/html/header2.example.js.backup +411 -0
- package/src/html/icon.example.js +77 -3
- package/src/html/icon.example.js.backup +268 -0
- package/src/html/list.example.js +93 -4
- package/src/html/list.example.js.backup +404 -0
- package/src/html/progress.example.js +74 -4
- package/src/html/progress.example.js.backup +424 -0
- package/src/html/property.example.js +123 -4
- package/src/html/property.example.js.backup +553 -0
- package/src/html/radio.example.js +108 -4
- package/src/html/radio.example.js.backup +389 -0
- package/src/html/section.example.js +42 -3
- package/src/html/section.example.js.backup +99 -0
- package/src/html/switch.example.js +108 -4
- package/src/html/switch.example.js.backup +461 -0
- package/src/html/tab.example.js +93 -4
- package/src/html/tab.example.js.backup +446 -0
- package/src/html/table-export-utils.js +483 -0
- package/src/html/table-summary-functions.js +363 -0
- package/src/html/table2.css +1496 -432
- package/src/html/table2.example.js +2937 -512
- package/src/html/table2.example.js.broken +1226 -0
- package/src/html/table2.js +1426 -1000
- package/src/html/test-resize.html +279 -0
- package/src/html/test-selection.html +387 -0
- package/src/html/textfield2.example.js +108 -4
- package/src/html/textfield2.example.js.backup +1370 -0
- package/src/html/tokenfield.example.js +108 -4
- package/src/html/tokenfield.example.js.backup +503 -0
- package/src/html/tree.css +2 -4
- package/src/html/tree.example.js +93 -4
- package/src/html/tree.example.js.backup +475 -0
- package/src/html/tree.js +19 -3
@@ -0,0 +1,389 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { RadioButton, RadioGroup } from './radio'
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Ejemplos de uso de los componentes Radio mejorados
|
6
|
+
*/
|
7
|
+
export const RadioExamples = () => {
|
8
|
+
const [settings, setSettings] = useState({
|
9
|
+
theme: 'light',
|
10
|
+
language: 'es',
|
11
|
+
notifications: 'email',
|
12
|
+
privacy: 'public',
|
13
|
+
size: 'medium'
|
14
|
+
})
|
15
|
+
|
16
|
+
const [validationErrors, setValidationErrors] = useState({})
|
17
|
+
|
18
|
+
const handleChange = (id, value) => {
|
19
|
+
setSettings(prev => ({ ...prev, [id]: value }))
|
20
|
+
|
21
|
+
// Limpiar errores cuando el usuario interactúa
|
22
|
+
if (validationErrors[id]) {
|
23
|
+
setValidationErrors(prev => ({ ...prev, [id]: null }))
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
const validateSettings = () => {
|
28
|
+
const errors = {}
|
29
|
+
|
30
|
+
if (!settings.theme) {
|
31
|
+
errors.theme = 'Debe seleccionar un tema'
|
32
|
+
}
|
33
|
+
|
34
|
+
if (!settings.notifications) {
|
35
|
+
errors.notifications = 'Debe seleccionar un método de notificación'
|
36
|
+
}
|
37
|
+
|
38
|
+
setValidationErrors(errors)
|
39
|
+
return Object.keys(errors).length === 0
|
40
|
+
}
|
41
|
+
|
42
|
+
const handleSave = () => {
|
43
|
+
if (validateSettings()) {
|
44
|
+
alert('Configuración guardada: ' + JSON.stringify(settings, null, 2))
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
return (
|
49
|
+
<div style={{ padding: '2rem', maxWidth: '800px' }}>
|
50
|
+
<h1>Ejemplos de Componentes Radio Mejorados</h1>
|
51
|
+
|
52
|
+
<div style={{
|
53
|
+
background: '#f8f9fa',
|
54
|
+
padding: '1rem',
|
55
|
+
borderRadius: '8px',
|
56
|
+
marginBottom: '2rem',
|
57
|
+
border: '1px solid #e9ecef'
|
58
|
+
}}>
|
59
|
+
<h3>✅ Mejoras Implementadas:</h3>
|
60
|
+
<ul>
|
61
|
+
<li>🛡️ <strong>Validación de props</strong> - Advertencias para props incorrectas</li>
|
62
|
+
<li>♿ <strong>Accesibilidad completa</strong> - ARIA, soporte de teclado, focus</li>
|
63
|
+
<li>📝 <strong>PropTypes y documentación</strong> - Validación y documentación completa</li>
|
64
|
+
<li>🎯 <strong>Estados avanzados</strong> - disabled, readOnly, error</li>
|
65
|
+
<li>🎨 <strong>CSS mejorado</strong> - Estados visuales consistentes y responsivos</li>
|
66
|
+
<li>⌨️ <strong>Soporte de teclado</strong> - Espacio para seleccionar</li>
|
67
|
+
<li>🔧 <strong>Manejo de errores</strong> - Mensajes de error integrados</li>
|
68
|
+
<li>👥 <strong>RadioGroup</strong> - Componente para manejar grupos</li>
|
69
|
+
<li>🔄 <strong>Sincronización de estado</strong> - Control interno y externo</li>
|
70
|
+
<li>🧪 <strong>Pruebas unitarias</strong> - 17 pruebas que cubren toda la funcionalidad</li>
|
71
|
+
</ul>
|
72
|
+
</div>
|
73
|
+
|
74
|
+
{/* RadioButtons individuales */}
|
75
|
+
<section style={{ marginBottom: '2rem' }}>
|
76
|
+
<h3>RadioButtons Individuales</h3>
|
77
|
+
<div style={{
|
78
|
+
background: '#fff',
|
79
|
+
padding: '1.5rem',
|
80
|
+
borderRadius: '8px',
|
81
|
+
border: '1px solid #ddd'
|
82
|
+
}}>
|
83
|
+
<p><strong>Tema de la aplicación:</strong></p>
|
84
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
|
85
|
+
<RadioButton
|
86
|
+
id="theme-light"
|
87
|
+
name="theme"
|
88
|
+
label="Tema claro"
|
89
|
+
value="light"
|
90
|
+
checked={settings.theme === 'light'}
|
91
|
+
onChange={handleChange}
|
92
|
+
/>
|
93
|
+
<RadioButton
|
94
|
+
id="theme-dark"
|
95
|
+
name="theme"
|
96
|
+
label="Tema oscuro"
|
97
|
+
value="dark"
|
98
|
+
checked={settings.theme === 'dark'}
|
99
|
+
onChange={handleChange}
|
100
|
+
/>
|
101
|
+
<RadioButton
|
102
|
+
id="theme-auto"
|
103
|
+
name="theme"
|
104
|
+
label="Automático (según sistema)"
|
105
|
+
value="auto"
|
106
|
+
checked={settings.theme === 'auto'}
|
107
|
+
onChange={handleChange}
|
108
|
+
/>
|
109
|
+
</div>
|
110
|
+
</div>
|
111
|
+
</section>
|
112
|
+
|
113
|
+
{/* RadioGroup básico */}
|
114
|
+
<section style={{ marginBottom: '2rem' }}>
|
115
|
+
<h3>RadioGroup - Idioma</h3>
|
116
|
+
<div style={{
|
117
|
+
background: '#fff',
|
118
|
+
padding: '1.5rem',
|
119
|
+
borderRadius: '8px',
|
120
|
+
border: '1px solid #ddd'
|
121
|
+
}}>
|
122
|
+
<RadioGroup
|
123
|
+
id="language"
|
124
|
+
label="Idioma de la interfaz"
|
125
|
+
value={settings.language}
|
126
|
+
onChange={handleChange}
|
127
|
+
options={[
|
128
|
+
{ id: 'es', label: 'Español', value: 'es' },
|
129
|
+
{ id: 'en', label: 'English', value: 'en' },
|
130
|
+
{ id: 'fr', label: 'Français', value: 'fr' },
|
131
|
+
{ id: 'de', label: 'Deutsch', value: 'de' }
|
132
|
+
]}
|
133
|
+
/>
|
134
|
+
</div>
|
135
|
+
</section>
|
136
|
+
|
137
|
+
{/* RadioGroup con validación */}
|
138
|
+
<section style={{ marginBottom: '2rem' }}>
|
139
|
+
<h3>RadioGroup con Validación</h3>
|
140
|
+
<div style={{
|
141
|
+
background: '#fff',
|
142
|
+
padding: '1.5rem',
|
143
|
+
borderRadius: '8px',
|
144
|
+
border: '1px solid #ddd'
|
145
|
+
}}>
|
146
|
+
<RadioGroup
|
147
|
+
id="notifications"
|
148
|
+
label="Método de notificaciones"
|
149
|
+
value={settings.notifications}
|
150
|
+
onChange={handleChange}
|
151
|
+
required={true}
|
152
|
+
error={validationErrors.notifications}
|
153
|
+
options={[
|
154
|
+
{ id: 'email', label: 'Correo electrónico', value: 'email' },
|
155
|
+
{ id: 'sms', label: 'SMS', value: 'sms' },
|
156
|
+
{ id: 'push', label: 'Notificaciones push', value: 'push' },
|
157
|
+
{ id: 'none', label: 'Sin notificaciones', value: 'none' }
|
158
|
+
]}
|
159
|
+
/>
|
160
|
+
</div>
|
161
|
+
</section>
|
162
|
+
|
163
|
+
{/* Estados especiales */}
|
164
|
+
<section style={{ marginBottom: '2rem' }}>
|
165
|
+
<h3>Estados Especiales</h3>
|
166
|
+
<div style={{
|
167
|
+
background: '#fff',
|
168
|
+
padding: '1.5rem',
|
169
|
+
borderRadius: '8px',
|
170
|
+
border: '1px solid #ddd'
|
171
|
+
}}>
|
172
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))', gap: '2rem' }}>
|
173
|
+
{/* Disabled */}
|
174
|
+
<div>
|
175
|
+
<h4>RadioGroup Deshabilitado</h4>
|
176
|
+
<RadioGroup
|
177
|
+
id="disabled-example"
|
178
|
+
label="Configuración avanzada"
|
179
|
+
value="option1"
|
180
|
+
disabled={true}
|
181
|
+
options={[
|
182
|
+
{ id: 'opt1', label: 'Opción 1', value: 'option1' },
|
183
|
+
{ id: 'opt2', label: 'Opción 2', value: 'option2' }
|
184
|
+
]}
|
185
|
+
/>
|
186
|
+
</div>
|
187
|
+
|
188
|
+
{/* ReadOnly */}
|
189
|
+
<div>
|
190
|
+
<h4>RadioGroup Solo Lectura</h4>
|
191
|
+
<RadioGroup
|
192
|
+
id="readonly-example"
|
193
|
+
label="Configuración del sistema"
|
194
|
+
value="option2"
|
195
|
+
readOnly={true}
|
196
|
+
options={[
|
197
|
+
{ id: 'opt1', label: 'Opción 1', value: 'option1' },
|
198
|
+
{ id: 'opt2', label: 'Opción 2', value: 'option2' }
|
199
|
+
]}
|
200
|
+
/>
|
201
|
+
</div>
|
202
|
+
|
203
|
+
{/* Con Error */}
|
204
|
+
<div>
|
205
|
+
<h4>RadioGroup con Error</h4>
|
206
|
+
<RadioGroup
|
207
|
+
id="error-example"
|
208
|
+
label="Configuración requerida"
|
209
|
+
value=""
|
210
|
+
error="Debe seleccionar una opción"
|
211
|
+
options={[
|
212
|
+
{ id: 'opt1', label: 'Opción 1', value: 'option1' },
|
213
|
+
{ id: 'opt2', label: 'Opción 2', value: 'option2' }
|
214
|
+
]}
|
215
|
+
/>
|
216
|
+
</div>
|
217
|
+
</div>
|
218
|
+
</div>
|
219
|
+
</section>
|
220
|
+
|
221
|
+
{/* Formulario completo */}
|
222
|
+
<section style={{ marginBottom: '2rem' }}>
|
223
|
+
<h3>Formulario de Configuración</h3>
|
224
|
+
<div style={{
|
225
|
+
background: '#fff',
|
226
|
+
padding: '1.5rem',
|
227
|
+
borderRadius: '8px',
|
228
|
+
border: '1px solid #ddd'
|
229
|
+
}}>
|
230
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))', gap: '2rem' }}>
|
231
|
+
<RadioGroup
|
232
|
+
id="privacy"
|
233
|
+
label="Configuración de privacidad"
|
234
|
+
value={settings.privacy}
|
235
|
+
onChange={handleChange}
|
236
|
+
required={true}
|
237
|
+
options={[
|
238
|
+
{ id: 'public', label: 'Público', value: 'public' },
|
239
|
+
{ id: 'friends', label: 'Solo amigos', value: 'friends' },
|
240
|
+
{ id: 'private', label: 'Privado', value: 'private' }
|
241
|
+
]}
|
242
|
+
/>
|
243
|
+
|
244
|
+
<RadioGroup
|
245
|
+
id="size"
|
246
|
+
label="Tamaño de la interfaz"
|
247
|
+
value={settings.size}
|
248
|
+
onChange={handleChange}
|
249
|
+
options={[
|
250
|
+
{ id: 'small', label: 'Pequeño', value: 'small' },
|
251
|
+
{ id: 'medium', label: 'Mediano', value: 'medium' },
|
252
|
+
{ id: 'large', label: 'Grande', value: 'large' }
|
253
|
+
]}
|
254
|
+
/>
|
255
|
+
</div>
|
256
|
+
|
257
|
+
<div style={{ display: 'flex', gap: '1rem', marginTop: '2rem' }}>
|
258
|
+
<button
|
259
|
+
onClick={handleSave}
|
260
|
+
style={{
|
261
|
+
padding: '0.5rem 1rem',
|
262
|
+
backgroundColor: '#007bff',
|
263
|
+
color: 'white',
|
264
|
+
border: 'none',
|
265
|
+
borderRadius: '4px',
|
266
|
+
cursor: 'pointer'
|
267
|
+
}}
|
268
|
+
>
|
269
|
+
Guardar Configuración
|
270
|
+
</button>
|
271
|
+
<button
|
272
|
+
onClick={() => {
|
273
|
+
setSettings({
|
274
|
+
theme: 'light',
|
275
|
+
language: 'es',
|
276
|
+
notifications: 'email',
|
277
|
+
privacy: 'public',
|
278
|
+
size: 'medium'
|
279
|
+
})
|
280
|
+
setValidationErrors({})
|
281
|
+
}}
|
282
|
+
style={{
|
283
|
+
padding: '0.5rem 1rem',
|
284
|
+
backgroundColor: '#6c757d',
|
285
|
+
color: 'white',
|
286
|
+
border: 'none',
|
287
|
+
borderRadius: '4px',
|
288
|
+
cursor: 'pointer'
|
289
|
+
}}
|
290
|
+
>
|
291
|
+
Resetear
|
292
|
+
</button>
|
293
|
+
</div>
|
294
|
+
</div>
|
295
|
+
</section>
|
296
|
+
|
297
|
+
{/* Demostración de accesibilidad */}
|
298
|
+
<section style={{ marginBottom: '2rem' }}>
|
299
|
+
<h3>Demostración de Accesibilidad</h3>
|
300
|
+
<div style={{
|
301
|
+
background: '#e8f5e8',
|
302
|
+
padding: '1rem',
|
303
|
+
borderRadius: '4px',
|
304
|
+
border: '1px solid #c8e6c9'
|
305
|
+
}}>
|
306
|
+
<p><strong>Prueba la accesibilidad:</strong></p>
|
307
|
+
<ol>
|
308
|
+
<li>Usa <kbd>Tab</kbd> para navegar entre grupos de radio buttons</li>
|
309
|
+
<li>Usa <kbd>Espacio</kbd> para seleccionar un radio button</li>
|
310
|
+
<li>Usa las flechas <kbd>↑</kbd> <kbd>↓</kbd> para navegar dentro de un grupo</li>
|
311
|
+
<li>Observa los indicadores de focus</li>
|
312
|
+
<li>Los lectores de pantalla anunciarán el estado y etiquetas</li>
|
313
|
+
</ol>
|
314
|
+
|
315
|
+
<RadioGroup
|
316
|
+
id="accessibility-demo"
|
317
|
+
label="Demostración de accesibilidad"
|
318
|
+
value="option1"
|
319
|
+
onChange={() => {}}
|
320
|
+
options={[
|
321
|
+
{ id: 'acc1', label: 'Opción accesible 1', value: 'option1' },
|
322
|
+
{ id: 'acc2', label: 'Opción accesible 2', value: 'option2' },
|
323
|
+
{ id: 'acc3', label: 'Opción accesible 3', value: 'option3' }
|
324
|
+
]}
|
325
|
+
/>
|
326
|
+
</div>
|
327
|
+
</section>
|
328
|
+
|
329
|
+
{/* Comparación antes/después */}
|
330
|
+
<section style={{ marginBottom: '2rem' }}>
|
331
|
+
<h3>Comparación: Antes vs Después</h3>
|
332
|
+
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '1rem' }}>
|
333
|
+
<div style={{
|
334
|
+
background: '#ffebee',
|
335
|
+
padding: '1rem',
|
336
|
+
borderRadius: '4px',
|
337
|
+
border: '1px solid #ffcdd2'
|
338
|
+
}}>
|
339
|
+
<h4>❌ Antes</h4>
|
340
|
+
<ul>
|
341
|
+
<li>Error de sintaxis (class vs className)</li>
|
342
|
+
<li>Sin validación de props</li>
|
343
|
+
<li>Sin accesibilidad</li>
|
344
|
+
<li>Evento incorrecto (onClick vs onChange)</li>
|
345
|
+
<li>Props confusas (value para checked)</li>
|
346
|
+
<li>Sin estados avanzados</li>
|
347
|
+
<li>Sin componente de grupo</li>
|
348
|
+
<li>Sin documentación</li>
|
349
|
+
</ul>
|
350
|
+
</div>
|
351
|
+
<div style={{
|
352
|
+
background: '#e8f5e8',
|
353
|
+
padding: '1rem',
|
354
|
+
borderRadius: '4px',
|
355
|
+
border: '1px solid #c8e6c9'
|
356
|
+
}}>
|
357
|
+
<h4>✅ Después</h4>
|
358
|
+
<ul>
|
359
|
+
<li>Sintaxis corregida</li>
|
360
|
+
<li>PropTypes completos</li>
|
361
|
+
<li>Accesibilidad total</li>
|
362
|
+
<li>Eventos correctos</li>
|
363
|
+
<li>Props claras y consistentes</li>
|
364
|
+
<li>Estados avanzados (disabled, error, readOnly)</li>
|
365
|
+
<li>RadioGroup para manejo de grupos</li>
|
366
|
+
<li>Documentación y ejemplos completos</li>
|
367
|
+
</ul>
|
368
|
+
</div>
|
369
|
+
</div>
|
370
|
+
</section>
|
371
|
+
|
372
|
+
{/* Estado actual */}
|
373
|
+
<section>
|
374
|
+
<h3>Estado Actual de la Configuración</h3>
|
375
|
+
<pre style={{
|
376
|
+
background: '#f8f9fa',
|
377
|
+
padding: '1rem',
|
378
|
+
borderRadius: '4px',
|
379
|
+
fontSize: '0.9rem',
|
380
|
+
overflow: 'auto'
|
381
|
+
}}>
|
382
|
+
{JSON.stringify(settings, null, 2)}
|
383
|
+
</pre>
|
384
|
+
</section>
|
385
|
+
</div>
|
386
|
+
)
|
387
|
+
}
|
388
|
+
|
389
|
+
export default RadioExamples
|
@@ -6,9 +6,47 @@ import { Button } from './button'
|
|
6
6
|
* Ejemplos de uso del componente Section mejorado
|
7
7
|
*/
|
8
8
|
export const SectionExamples = () => {
|
9
|
+
// Definir secciones para el menú lateral
|
10
|
+
|
11
|
+
const sections =
|
12
|
+
[
|
13
|
+
|
14
|
+
{
|
15
|
+
|
16
|
+
"id": "overview",
|
17
|
+
|
18
|
+
"title": "Introducción",
|
19
|
+
|
20
|
+
"icon": "info"
|
21
|
+
|
22
|
+
},
|
23
|
+
|
24
|
+
{
|
25
|
+
|
26
|
+
"id": "basic-examples",
|
27
|
+
|
28
|
+
"title": "Ejemplos Básicos",
|
29
|
+
|
30
|
+
"icon": "widgets"
|
31
|
+
|
32
|
+
},
|
33
|
+
|
34
|
+
{
|
35
|
+
|
36
|
+
"id": "states",
|
37
|
+
|
38
|
+
"title": "Estados",
|
39
|
+
|
40
|
+
"icon": "toggle_on"
|
41
|
+
|
42
|
+
}
|
43
|
+
|
44
|
+
]
|
45
|
+
|
46
|
+
|
9
47
|
return (
|
10
|
-
<
|
11
|
-
<
|
48
|
+
<ExampleLayout title="Section Examples" sections={sections}>
|
49
|
+
<ExampleSection id="overview" title="Ejemplos del Componente Section Mejorado" icon="widgets">
|
12
50
|
|
13
51
|
{/* Ejemplo básico */}
|
14
52
|
<Section title="Sección Básica" icon="info">
|
@@ -92,7 +130,8 @@ export const SectionExamples = () => {
|
|
92
130
|
<p>Sección mínima sin título ni icono.</p>
|
93
131
|
<p>Solo con el contenido y funcionalidad de colapsar.</p>
|
94
132
|
</Section>
|
95
|
-
|
133
|
+
</ExampleSection>
|
134
|
+
</ExampleLayout>
|
96
135
|
)
|
97
136
|
}
|
98
137
|
|
@@ -0,0 +1,99 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Section } from './section'
|
3
|
+
import { Button } from './button'
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Ejemplos de uso del componente Section mejorado
|
7
|
+
*/
|
8
|
+
export const SectionExamples = () => {
|
9
|
+
return (
|
10
|
+
<div style={{ padding: '2rem', maxWidth: '800px' }}>
|
11
|
+
<h1>Ejemplos del Componente Section Mejorado</h1>
|
12
|
+
|
13
|
+
{/* Ejemplo básico */}
|
14
|
+
<Section title="Sección Básica" icon="info">
|
15
|
+
<p>Esta es una sección básica que está cerrada por defecto.</p>
|
16
|
+
<p>Haz clic en el icono de expansión para abrirla.</p>
|
17
|
+
</Section>
|
18
|
+
|
19
|
+
{/* Sección abierta por defecto */}
|
20
|
+
<Section title="Sección Abierta" icon="folder_open" open={true}>
|
21
|
+
<p>Esta sección está abierta por defecto.</p>
|
22
|
+
<p>El icono cambia dinámicamente según el estado.</p>
|
23
|
+
<ul>
|
24
|
+
<li>✅ Icono dinámico (expand_more/expand_less)</li>
|
25
|
+
<li>✅ Tooltip informativo</li>
|
26
|
+
<li>✅ Atributos de accesibilidad</li>
|
27
|
+
</ul>
|
28
|
+
</Section>
|
29
|
+
|
30
|
+
{/* Sección con acciones */}
|
31
|
+
<Section
|
32
|
+
title="Sección con Acciones"
|
33
|
+
icon="settings"
|
34
|
+
actions={
|
35
|
+
<div style={{ display: 'flex', gap: '0.5rem' }}>
|
36
|
+
<Button label="Editar" icon="edit" outlined />
|
37
|
+
<Button label="Eliminar" icon="delete" outlined />
|
38
|
+
</div>
|
39
|
+
}
|
40
|
+
>
|
41
|
+
<p>Esta sección incluye botones de acción en el header.</p>
|
42
|
+
<p>Las acciones se muestran junto al botón de colapsar.</p>
|
43
|
+
</Section>
|
44
|
+
|
45
|
+
{/* Sección no colapsable */}
|
46
|
+
<Section
|
47
|
+
title="Sección No Colapsable"
|
48
|
+
icon="lock"
|
49
|
+
canCollapse={false}
|
50
|
+
className="always-open"
|
51
|
+
>
|
52
|
+
<p>Esta sección no puede colapsarse.</p>
|
53
|
+
<p>No muestra el icono de expansión/contracción.</p>
|
54
|
+
<p>Útil para contenido que siempre debe estar visible.</p>
|
55
|
+
</Section>
|
56
|
+
|
57
|
+
{/* Sección con clase personalizada */}
|
58
|
+
<Section
|
59
|
+
title="Sección Personalizada"
|
60
|
+
icon="palette"
|
61
|
+
className="custom-section"
|
62
|
+
open={true}
|
63
|
+
>
|
64
|
+
<p>Esta sección tiene una clase CSS personalizada.</p>
|
65
|
+
<p>El manejo de className es seguro y no causa errores.</p>
|
66
|
+
<div style={{
|
67
|
+
background: '#f0f8ff',
|
68
|
+
padding: '1rem',
|
69
|
+
borderRadius: '4px',
|
70
|
+
border: '1px solid #e0e0e0'
|
71
|
+
}}>
|
72
|
+
<strong>Mejoras implementadas:</strong>
|
73
|
+
<ul>
|
74
|
+
<li>🔧 Icono dinámico corregido</li>
|
75
|
+
<li>🛡️ Manejo seguro de className</li>
|
76
|
+
<li>📝 PropTypes y documentación</li>
|
77
|
+
<li>♿ Atributos de accesibilidad</li>
|
78
|
+
<li>💬 Tooltips informativos</li>
|
79
|
+
<li>✅ Pruebas unitarias</li>
|
80
|
+
</ul>
|
81
|
+
</div>
|
82
|
+
</Section>
|
83
|
+
|
84
|
+
{/* Sección sin título */}
|
85
|
+
<Section icon="description">
|
86
|
+
<p>Esta sección no tiene título, solo icono.</p>
|
87
|
+
<p>Demuestra la flexibilidad del componente.</p>
|
88
|
+
</Section>
|
89
|
+
|
90
|
+
{/* Sección mínima */}
|
91
|
+
<Section>
|
92
|
+
<p>Sección mínima sin título ni icono.</p>
|
93
|
+
<p>Solo con el contenido y funcionalidad de colapsar.</p>
|
94
|
+
</Section>
|
95
|
+
</div>
|
96
|
+
)
|
97
|
+
}
|
98
|
+
|
99
|
+
export default SectionExamples
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import React, { useState } from 'react'
|
2
|
-
import { Switch, Switch2 } from '
|
2
|
+
import { Switch, Switch2 } from '
|
3
|
+
import { ExampleLayout, ExampleSection, ExampleSubsection, CodeSnippet } from './ExampleLayout'./switch'
|
3
4
|
|
4
5
|
/**
|
5
6
|
* Ejemplos de uso de los componentes Switch mejorados
|
@@ -45,9 +46,111 @@ export const SwitchExamples = () => {
|
|
45
46
|
}
|
46
47
|
}
|
47
48
|
|
49
|
+
// Definir secciones para el menú lateral
|
50
|
+
|
51
|
+
|
52
|
+
const sections =
|
53
|
+
|
54
|
+
[
|
55
|
+
|
56
|
+
|
57
|
+
{
|
58
|
+
|
59
|
+
|
60
|
+
"id": "overview",
|
61
|
+
|
62
|
+
|
63
|
+
"title": "Introducción",
|
64
|
+
|
65
|
+
|
66
|
+
"icon": "info"
|
67
|
+
|
68
|
+
|
69
|
+
},
|
70
|
+
|
71
|
+
|
72
|
+
{
|
73
|
+
|
74
|
+
|
75
|
+
"id": "basic-examples",
|
76
|
+
|
77
|
+
|
78
|
+
"title": "Ejemplos Básicos",
|
79
|
+
|
80
|
+
|
81
|
+
"icon": "widgets"
|
82
|
+
|
83
|
+
|
84
|
+
},
|
85
|
+
|
86
|
+
|
87
|
+
{
|
88
|
+
|
89
|
+
|
90
|
+
"id": "advanced-features",
|
91
|
+
|
92
|
+
|
93
|
+
"title": "Características Avanzadas",
|
94
|
+
|
95
|
+
|
96
|
+
"icon": "settings"
|
97
|
+
|
98
|
+
|
99
|
+
},
|
100
|
+
|
101
|
+
|
102
|
+
{
|
103
|
+
|
104
|
+
|
105
|
+
"id": "variants",
|
106
|
+
|
107
|
+
|
108
|
+
"title": "Variantes y Temas",
|
109
|
+
|
110
|
+
|
111
|
+
"icon": "palette"
|
112
|
+
|
113
|
+
|
114
|
+
},
|
115
|
+
|
116
|
+
|
117
|
+
{
|
118
|
+
|
119
|
+
|
120
|
+
"id": "states",
|
121
|
+
|
122
|
+
|
123
|
+
"title": "Estados",
|
124
|
+
|
125
|
+
|
126
|
+
"icon": "toggle_on"
|
127
|
+
|
128
|
+
|
129
|
+
},
|
130
|
+
|
131
|
+
|
132
|
+
{
|
133
|
+
|
134
|
+
|
135
|
+
"id": "sizes",
|
136
|
+
|
137
|
+
|
138
|
+
"title": "Tamaños",
|
139
|
+
|
140
|
+
|
141
|
+
"icon": "format_size"
|
142
|
+
|
143
|
+
|
144
|
+
}
|
145
|
+
|
146
|
+
|
147
|
+
]
|
148
|
+
|
149
|
+
|
150
|
+
|
48
151
|
return (
|
49
|
-
<
|
50
|
-
<
|
152
|
+
<ExampleLayout title="Switch Examples" sections={sections}>
|
153
|
+
<ExampleSection id="overview" title="Ejemplos de Componentes Switch Mejorados" icon="widgets">
|
51
154
|
|
52
155
|
{/* Prueba visual rápida */}
|
53
156
|
<section style={{ marginBottom: '2rem' }}>
|
@@ -454,7 +557,8 @@ export const SwitchExamples = () => {
|
|
454
557
|
{JSON.stringify(settings, null, 2)}
|
455
558
|
</pre>
|
456
559
|
</section>
|
457
|
-
|
560
|
+
</ExampleSection>
|
561
|
+
</ExampleLayout>
|
458
562
|
)
|
459
563
|
}
|
460
564
|
|