ywana-core8 0.1.75 → 0.1.76

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.
Files changed (122) hide show
  1. package/ACCORDION_EVALUATION.md +583 -0
  2. package/CHECKBOX_EVALUATION.md +273 -0
  3. package/CHIP_EVALUATION.md +542 -0
  4. package/COLOR_EVALUATION.md +524 -0
  5. package/COMPONENTS_EVALUATION.md +477 -0
  6. package/FORM_EVALUATION.md +459 -0
  7. package/HEADER_EVALUATION.md +436 -0
  8. package/ICON_EVALUATION.md +254 -0
  9. package/LIST_EVALUATION.md +574 -0
  10. package/PROGRESS_EVALUATION.md +450 -0
  11. package/RADIO_EVALUATION.md +439 -0
  12. package/RADIO_VISUAL_FIX.md +183 -0
  13. package/SECTION_IMPROVEMENTS.md +153 -0
  14. package/SWITCH_EVALUATION.md +335 -0
  15. package/SWITCH_VISUAL_FIX.md +232 -0
  16. package/TAB_EVALUATION.md +626 -0
  17. package/TEXTFIELD_EVALUATION.md +747 -0
  18. package/TOOLTIP_FIX.md +157 -0
  19. package/TREE_EVALUATION.md +708 -0
  20. package/dist/index.cjs +7900 -1615
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.css +6094 -1122
  23. package/dist/index.css.map +1 -1
  24. package/dist/index.modern.js +7929 -1645
  25. package/dist/index.modern.js.map +1 -1
  26. package/dist/index.umd.js +7900 -1615
  27. package/dist/index.umd.js.map +1 -1
  28. package/jest.config.js +24 -0
  29. package/package.json +10 -1
  30. package/src/html/accordion.css +208 -4
  31. package/src/html/accordion.example.js +390 -0
  32. package/src/html/accordion.js +284 -28
  33. package/src/html/accordion.unit.test.js +334 -0
  34. package/src/html/button.css +157 -16
  35. package/src/html/button.example.js +374 -0
  36. package/src/html/button.js +240 -60
  37. package/src/html/button.test.js +422 -0
  38. package/src/html/checkbox.css +74 -2
  39. package/src/html/checkbox.example.js +316 -0
  40. package/src/html/checkbox.js +113 -26
  41. package/src/html/checkbox.test.js +285 -0
  42. package/src/html/chip.css +230 -19
  43. package/src/html/chip.example.js +355 -0
  44. package/src/html/chip.js +321 -25
  45. package/src/html/chip.test.js +425 -0
  46. package/src/html/color.css +435 -6
  47. package/src/html/color.example.js +527 -0
  48. package/src/html/color.js +458 -9
  49. package/src/html/color.test.js +362 -4
  50. package/src/html/components.example.js +492 -0
  51. package/src/html/components_enhanced.test.js +581 -0
  52. package/src/html/form.css +70 -3
  53. package/src/html/form.example.js +385 -0
  54. package/src/html/form.js +232 -34
  55. package/src/html/form.test.js +369 -0
  56. package/src/html/header2.css +264 -0
  57. package/src/html/header2.example.js +411 -0
  58. package/src/html/header2.js +203 -0
  59. package/src/html/header2.test.js +377 -0
  60. package/src/html/icon.css +20 -2
  61. package/src/html/icon.example.js +268 -0
  62. package/src/html/icon.js +86 -16
  63. package/src/html/icon.test.js +231 -0
  64. package/src/html/index.js +1 -1
  65. package/src/html/list.css +393 -1
  66. package/src/html/list.example.js +404 -0
  67. package/src/html/list.js +583 -40
  68. package/src/html/list.test.js +383 -0
  69. package/src/html/progress.css +707 -17
  70. package/src/html/progress.example.js +424 -0
  71. package/src/html/progress.js +906 -9
  72. package/src/html/progress.test.js +313 -0
  73. package/src/html/property.css +399 -0
  74. package/src/html/property.example.js +553 -0
  75. package/src/html/property.js +393 -15
  76. package/src/html/property.test.js +351 -2
  77. package/src/html/radio-visual-test.js +289 -0
  78. package/src/html/radio.css +137 -11
  79. package/src/html/radio.example.js +389 -0
  80. package/src/html/radio.js +234 -10
  81. package/src/html/radio.test.js +318 -0
  82. package/src/html/section.example.js +99 -0
  83. package/src/html/section.js +40 -3
  84. package/src/html/section.test.js +131 -0
  85. package/src/html/selector.css +329 -3
  86. package/src/html/selector.js +369 -23
  87. package/src/html/switch-debug.js +197 -0
  88. package/src/html/switch-test-visual.js +294 -0
  89. package/src/html/switch.css +200 -0
  90. package/src/html/switch.example.js +461 -0
  91. package/src/html/switch.js +283 -23
  92. package/src/html/switch.test.js +355 -0
  93. package/src/html/tab.css +288 -0
  94. package/src/html/tab.example.js +446 -0
  95. package/src/html/tab.js +387 -22
  96. package/src/html/tab_enhanced.js +378 -0
  97. package/src/html/tab_enhanced.test.js +504 -0
  98. package/src/html/table2.css +576 -0
  99. package/src/html/table2.example.js +703 -0
  100. package/src/html/table2.js +1252 -0
  101. package/src/html/table2.migration.md +328 -0
  102. package/src/html/table2.test.js +582 -0
  103. package/src/html/text.css +375 -0
  104. package/src/html/text.js +311 -20
  105. package/src/html/textfield2.css +842 -0
  106. package/src/html/textfield2.example.js +499 -0
  107. package/src/html/textfield2.js +1130 -0
  108. package/src/html/textfield2.test.js +950 -0
  109. package/src/html/thumbnail.css +289 -2
  110. package/src/html/thumbnail.js +214 -9
  111. package/src/html/tokenfield.css +449 -1
  112. package/src/html/tokenfield.example.js +503 -0
  113. package/src/html/tokenfield.js +561 -56
  114. package/src/html/tokenfield.test.js +423 -0
  115. package/src/html/tooltip-positioning-demo.js +187 -0
  116. package/src/html/tooltip.css +25 -2
  117. package/src/html/tree.css +228 -0
  118. package/src/html/tree.example.js +475 -0
  119. package/src/html/tree.js +712 -28
  120. package/src/html/tree_enhanced.test.js +495 -0
  121. package/table2.test.js +454 -0
  122. package/src/html/button.tsx +0 -38
@@ -1,8 +1,355 @@
1
1
  import React, { useState } from 'react'
2
2
  import { Property } from './property'
3
3
 
4
- const PropertyTest = (prop) => {
4
+ // Pruebas unitarias para el componente Property mejorado
5
+ describe('Enhanced Property Component', () => {
6
+ // Mock de los componentes dependientes
7
+ const mockIcon = jest.fn()
8
+ const mockText = jest.fn()
5
9
 
10
+ beforeEach(() => {
11
+ jest.clearAllMocks()
12
+
13
+ // Mock de componentes
14
+ jest.doMock('./icon', () => ({ Icon: mockIcon }))
15
+ jest.doMock('./text', () => ({ Text: mockText }))
16
+
17
+ // Mock de console.warn
18
+ jest.spyOn(console, 'warn').mockImplementation(() => {})
19
+
20
+ // Mock de navigator.clipboard
21
+ global.navigator = {
22
+ clipboard: {
23
+ writeText: jest.fn().mockResolvedValue(undefined)
24
+ }
25
+ }
26
+ })
27
+
28
+ afterEach(() => {
29
+ console.warn.mockRestore()
30
+ })
31
+
32
+ // Property Component Tests
33
+ describe('Property Component', () => {
34
+ test('component exports correctly', () => {
35
+ expect(Property).toBeDefined()
36
+ expect(typeof Property).toBe('function')
37
+ })
38
+
39
+ test('component has correct PropTypes', () => {
40
+ expect(Property.propTypes).toBeDefined()
41
+ expect(Property.propTypes.id).toBeDefined()
42
+ expect(Property.propTypes.className).toBeDefined()
43
+ expect(Property.propTypes.label).toBeDefined()
44
+ expect(Property.propTypes.name).toBeDefined()
45
+ expect(Property.propTypes.initial).toBeDefined()
46
+ expect(Property.propTypes.value).toBeDefined()
47
+ expect(Property.propTypes.editable).toBeDefined()
48
+ expect(Property.propTypes.onChange).toBeDefined()
49
+ expect(Property.propTypes.options).toBeDefined()
50
+ expect(Property.propTypes.type).toBeDefined()
51
+ expect(Property.propTypes.disabled).toBeDefined()
52
+ expect(Property.propTypes.required).toBeDefined()
53
+ expect(Property.propTypes.multiline).toBeDefined()
54
+ expect(Property.propTypes.validateValue).toBeDefined()
55
+ })
56
+
57
+ test('component has correct defaultProps', () => {
58
+ expect(Property.defaultProps).toBeDefined()
59
+ expect(Property.defaultProps.editable).toBe(false)
60
+ expect(Property.defaultProps.type).toBe('text')
61
+ expect(Property.defaultProps.disabled).toBe(false)
62
+ expect(Property.defaultProps.required).toBe(false)
63
+ expect(Property.defaultProps.multiline).toBe(false)
64
+ expect(Property.defaultProps.rows).toBe(3)
65
+ expect(Property.defaultProps.size).toBe('medium')
66
+ expect(Property.defaultProps.variant).toBe('default')
67
+ expect(Property.defaultProps.layout).toBe('horizontal')
68
+ expect(Property.defaultProps.nameWidth).toBe('50%')
69
+ expect(Property.defaultProps.copyable).toBe(false)
70
+ expect(Property.defaultProps.clearable).toBe(true)
71
+ })
72
+
73
+ test('validates props correctly', () => {
74
+ const validateProps = (options) => {
75
+ if (options && !Array.isArray(options)) {
76
+ console.warn('Property: options prop must be an array')
77
+ }
78
+ }
79
+
80
+ // Invalid options prop
81
+ validateProps('not an array')
82
+ expect(console.warn).toHaveBeenCalledWith('Property: options prop must be an array')
83
+
84
+ console.warn.mockClear()
85
+
86
+ // Valid options prop
87
+ validateProps([{ label: 'Option 1', value: '1' }])
88
+ expect(console.warn).not.toHaveBeenCalled()
89
+
90
+ // Null options (valid)
91
+ validateProps(null)
92
+ expect(console.warn).not.toHaveBeenCalled()
93
+ })
94
+
95
+ test('validates value correctly', () => {
96
+ const validateValueFunc = (val, required, minLength, maxLength, pattern, validateValue) => {
97
+ if (!val && required) {
98
+ return { isValid: false, error: 'This field is required' }
99
+ }
100
+
101
+ if (val && minLength && val.length < minLength) {
102
+ return { isValid: false, error: `Minimum ${minLength} characters required` }
103
+ }
104
+
105
+ if (val && maxLength && val.length > maxLength) {
106
+ return { isValid: false, error: `Maximum ${maxLength} characters allowed` }
107
+ }
108
+
109
+ if (val && pattern) {
110
+ const regex = new RegExp(pattern)
111
+ if (!regex.test(val)) {
112
+ return { isValid: false, error: 'Invalid format' }
113
+ }
114
+ }
115
+
116
+ if (validateValue) {
117
+ const customValidation = validateValue(val)
118
+ if (customValidation && !customValidation.isValid) {
119
+ return customValidation
120
+ }
121
+ }
122
+
123
+ return { isValid: true }
124
+ }
125
+
126
+ // Required field empty
127
+ expect(validateValueFunc('', true, null, null, null, null))
128
+ .toEqual({ isValid: false, error: 'This field is required' })
129
+
130
+ // Min length validation
131
+ expect(validateValueFunc('ab', false, 3, null, null, null))
132
+ .toEqual({ isValid: false, error: 'Minimum 3 characters required' })
133
+
134
+ // Max length validation
135
+ expect(validateValueFunc('abcdef', false, null, 5, null, null))
136
+ .toEqual({ isValid: false, error: 'Maximum 5 characters allowed' })
137
+
138
+ // Pattern validation
139
+ expect(validateValueFunc('invalid', false, null, null, '^[0-9]+$', null))
140
+ .toEqual({ isValid: false, error: 'Invalid format' })
141
+
142
+ // Custom validation
143
+ const customValidator = () => ({ isValid: false, error: 'Custom error' })
144
+ expect(validateValueFunc('test', false, null, null, null, customValidator))
145
+ .toEqual({ isValid: false, error: 'Custom error' })
146
+
147
+ // Valid value
148
+ expect(validateValueFunc('valid', false, null, null, null, null))
149
+ .toEqual({ isValid: true })
150
+ })
151
+
152
+ test('handles change correctly', () => {
153
+ const mockOnChange = jest.fn()
154
+ const mockOnValidationError = jest.fn()
155
+
156
+ const change = (event, disabled, readOnly, validateValueFunc, onValidationError, onChange, id) => {
157
+ if (disabled || readOnly) return
158
+
159
+ const newValue = event.target.value
160
+
161
+ // Validate value
162
+ const validation = validateValueFunc(newValue)
163
+
164
+ if (!validation.isValid && onValidationError) {
165
+ onValidationError(validation.error, newValue)
166
+ }
167
+
168
+ if (onChange) {
169
+ onChange(id, newValue)
170
+ }
171
+ }
172
+
173
+ const mockEvent = { target: { value: 'new value' } }
174
+ const mockValidateFunc = jest.fn().mockReturnValue({ isValid: true })
175
+
176
+ // Normal change
177
+ change(mockEvent, false, false, mockValidateFunc, mockOnValidationError, mockOnChange, 'prop1')
178
+ expect(mockOnChange).toHaveBeenCalledWith('prop1', 'new value')
179
+ expect(mockValidateFunc).toHaveBeenCalledWith('new value')
180
+
181
+ mockOnChange.mockClear()
182
+
183
+ // Disabled change
184
+ change(mockEvent, true, false, mockValidateFunc, mockOnValidationError, mockOnChange, 'prop1')
185
+ expect(mockOnChange).not.toHaveBeenCalled()
186
+
187
+ // ReadOnly change
188
+ change(mockEvent, false, true, mockValidateFunc, mockOnValidationError, mockOnChange, 'prop1')
189
+ expect(mockOnChange).not.toHaveBeenCalled()
190
+
191
+ // Validation error
192
+ const mockValidateFuncError = jest.fn().mockReturnValue({ isValid: false, error: 'Validation error' })
193
+ change(mockEvent, false, false, mockValidateFuncError, mockOnValidationError, mockOnChange, 'prop1')
194
+ expect(mockOnValidationError).toHaveBeenCalledWith('Validation error', 'new value')
195
+ })
196
+
197
+ test('handles clear correctly', () => {
198
+ const mockOnChange = jest.fn()
199
+
200
+ const clear = (disabled, readOnly, onChange, id) => {
201
+ if (disabled || readOnly) return
202
+
203
+ if (onChange) onChange(id, "")
204
+ }
205
+
206
+ // Normal clear
207
+ clear(false, false, mockOnChange, 'prop1')
208
+ expect(mockOnChange).toHaveBeenCalledWith('prop1', '')
209
+
210
+ mockOnChange.mockClear()
211
+
212
+ // Disabled clear
213
+ clear(true, false, mockOnChange, 'prop1')
214
+ expect(mockOnChange).not.toHaveBeenCalled()
215
+
216
+ // ReadOnly clear
217
+ clear(false, true, mockOnChange, 'prop1')
218
+ expect(mockOnChange).not.toHaveBeenCalled()
219
+ })
220
+
221
+ test('handles copy correctly', async () => {
222
+ const handleCopy = async (copyable, value) => {
223
+ if (!copyable || !value) return
224
+
225
+ try {
226
+ await navigator.clipboard.writeText(value)
227
+ } catch (error) {
228
+ console.warn('Failed to copy property value:', error)
229
+ }
230
+ }
231
+
232
+ // Normal copy
233
+ await handleCopy(true, 'test value')
234
+ expect(navigator.clipboard.writeText).toHaveBeenCalledWith('test value')
235
+
236
+ navigator.clipboard.writeText.mockClear()
237
+
238
+ // Copy disabled
239
+ await handleCopy(false, 'test value')
240
+ expect(navigator.clipboard.writeText).not.toHaveBeenCalled()
241
+
242
+ // Empty value
243
+ await handleCopy(true, '')
244
+ expect(navigator.clipboard.writeText).not.toHaveBeenCalled()
245
+ })
246
+
247
+ test('processes value with options correctly', () => {
248
+ const processValue = (value, initial, options) => {
249
+ let value2 = value || initial || ''
250
+
251
+ if (options && Array.isArray(options)) {
252
+ const opt = options.find(option => option.value == value2)
253
+ if (opt) value2 = opt.label
254
+ }
255
+
256
+ return value2
257
+ }
258
+
259
+ const options = [
260
+ { label: 'Option One', value: '1' },
261
+ { label: 'Option Two', value: '2' }
262
+ ]
263
+
264
+ // Value with options
265
+ expect(processValue('1', '', options)).toBe('Option One')
266
+ expect(processValue('2', '', options)).toBe('Option Two')
267
+
268
+ // Value not in options
269
+ expect(processValue('3', '', options)).toBe('3')
270
+
271
+ // No options
272
+ expect(processValue('test', '', null)).toBe('test')
273
+
274
+ // Initial value
275
+ expect(processValue('', 'initial', options)).toBe('initial')
276
+
277
+ // Empty value and initial
278
+ expect(processValue('', '', options)).toBe('')
279
+ })
280
+
281
+ test('generates CSS classes correctly', () => {
282
+ const generateClasses = (id, size, variant, layout, disabled, readOnly, required, isFocused, error, isValid, loading, skeleton, copyable, className) => {
283
+ return [
284
+ 'property',
285
+ `property-${id}`,
286
+ `property--${size}`,
287
+ `property--${variant}`,
288
+ `property--${layout}`,
289
+ disabled && 'property--disabled',
290
+ readOnly && 'property--readonly',
291
+ required && 'property--required',
292
+ isFocused && 'property--focused',
293
+ error && 'property--error',
294
+ !isValid && 'property--invalid',
295
+ loading && 'property--loading',
296
+ skeleton && 'property--skeleton',
297
+ copyable && 'property--copyable',
298
+ className
299
+ ].filter(Boolean).join(' ')
300
+ }
301
+
302
+ expect(generateClasses('prop1', 'medium', 'default', 'horizontal', false, false, false, false, null, true, false, false, false, ''))
303
+ .toBe('property property-prop1 property--medium property--default property--horizontal')
304
+
305
+ expect(generateClasses('prop2', 'large', 'outlined', 'vertical', true, true, true, true, 'Error', false, true, true, true, 'custom'))
306
+ .toBe('property property-prop2 property--large property--outlined property--vertical property--disabled property--readonly property--required property--focused property--error property--invalid property--loading property--skeleton property--copyable custom')
307
+ })
308
+
309
+ test('handles keyboard events correctly', () => {
310
+ const handleKeyDown = (event, multiline, inputRef) => {
311
+ if (event.key === 'Enter' && !multiline) {
312
+ event.preventDefault()
313
+ if (inputRef.current) inputRef.current.blur()
314
+ }
315
+
316
+ if (event.key === 'Escape') {
317
+ if (inputRef.current) inputRef.current.blur()
318
+ }
319
+ }
320
+
321
+ const mockEvent = {
322
+ preventDefault: jest.fn(),
323
+ key: 'Enter'
324
+ }
325
+ const mockInputRef = {
326
+ current: {
327
+ blur: jest.fn()
328
+ }
329
+ }
330
+
331
+ // Enter key (not multiline)
332
+ handleKeyDown(mockEvent, false, mockInputRef)
333
+ expect(mockEvent.preventDefault).toHaveBeenCalled()
334
+ expect(mockInputRef.current.blur).toHaveBeenCalled()
335
+
336
+ mockEvent.preventDefault.mockClear()
337
+ mockInputRef.current.blur.mockClear()
338
+
339
+ // Enter key (multiline)
340
+ handleKeyDown(mockEvent, true, mockInputRef)
341
+ expect(mockEvent.preventDefault).not.toHaveBeenCalled()
342
+
343
+ // Escape key
344
+ const escapeEvent = { ...mockEvent, key: 'Escape' }
345
+ handleKeyDown(escapeEvent, false, mockInputRef)
346
+ expect(mockInputRef.current.blur).toHaveBeenCalled()
347
+ })
348
+ })
349
+ })
350
+
351
+ // Original test component (maintaining compatibility)
352
+ const PropertyTest = () => {
6
353
  const [form, setForm] = useState({
7
354
  name: 'John',
8
355
  address: 'Porto Colon'
@@ -19,4 +366,6 @@ const PropertyTest = (prop) => {
19
366
  <Property id="address" label="Address" initial="Porto Colon" value={form.address} editable={true} onChange={change}/>
20
367
  </>
21
368
  )
22
- }
369
+ }
370
+
371
+ export default PropertyTest
@@ -0,0 +1,289 @@
1
+ import React, { useState } from 'react'
2
+ import { RadioButton, RadioGroup } from './radio'
3
+
4
+ /**
5
+ * Componente de prueba visual para verificar la apariencia de los radio buttons
6
+ */
7
+ export const RadioVisualTest = () => {
8
+ const [selectedValue, setSelectedValue] = useState('option1')
9
+ const [groupValue, setGroupValue] = useState('medium')
10
+
11
+ return (
12
+ <div style={{
13
+ padding: '2rem',
14
+ maxWidth: '800px',
15
+ fontFamily: 'Arial, sans-serif'
16
+ }}>
17
+ <h1>🔧 Prueba Visual de Radio Buttons</h1>
18
+
19
+ <div style={{
20
+ background: '#fff3cd',
21
+ padding: '1rem',
22
+ borderRadius: '8px',
23
+ border: '1px solid #ffeaa7',
24
+ marginBottom: '2rem'
25
+ }}>
26
+ <h3>🎯 Verificación Visual</h3>
27
+ <p>Verifica que los radio buttons se vean correctamente:</p>
28
+ <ul>
29
+ <li><strong>Círculo externo:</strong> Borde de 2px, tamaño 1.2rem</li>
30
+ <li><strong>Indicador interno:</strong> Círculo de 0.4rem, perfectamente centrado</li>
31
+ <li><strong>Espaciado:</strong> Espacio uniforme entre borde e indicador</li>
32
+ <li><strong>Alineación:</strong> Centrado perfecto sin desplazamientos</li>
33
+ </ul>
34
+ </div>
35
+
36
+ {/* Prueba básica de estados */}
37
+ <section style={{ marginBottom: '2rem' }}>
38
+ <h3>Estados Básicos</h3>
39
+ <div style={{
40
+ background: '#ffffff',
41
+ padding: '2rem',
42
+ borderRadius: '8px',
43
+ border: '2px solid #007bff',
44
+ display: 'grid',
45
+ gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))',
46
+ gap: '1.5rem'
47
+ }}>
48
+ <div style={{ textAlign: 'center' }}>
49
+ <h4>No Seleccionado</h4>
50
+ <RadioButton
51
+ id="unselected"
52
+ name="test-basic"
53
+ label="Opción no seleccionada"
54
+ value="unselected"
55
+ checked={false}
56
+ onChange={() => {}}
57
+ />
58
+ <p style={{ fontSize: '0.8rem', color: '#666', marginTop: '0.5rem' }}>
59
+ Solo círculo externo con borde
60
+ </p>
61
+ </div>
62
+
63
+ <div style={{ textAlign: 'center' }}>
64
+ <h4>Seleccionado</h4>
65
+ <RadioButton
66
+ id="selected"
67
+ name="test-basic"
68
+ label="Opción seleccionada"
69
+ value="selected"
70
+ checked={true}
71
+ onChange={() => {}}
72
+ />
73
+ <p style={{ fontSize: '0.8rem', color: '#666', marginTop: '0.5rem' }}>
74
+ Círculo externo + indicador interno centrado
75
+ </p>
76
+ </div>
77
+
78
+ <div style={{ textAlign: 'center' }}>
79
+ <h4>Deshabilitado</h4>
80
+ <RadioButton
81
+ id="disabled"
82
+ name="test-basic"
83
+ label="Opción deshabilitada"
84
+ value="disabled"
85
+ checked={true}
86
+ disabled={true}
87
+ onChange={() => {}}
88
+ />
89
+ <p style={{ fontSize: '0.8rem', color: '#666', marginTop: '0.5rem' }}>
90
+ Colores atenuados, no interactivo
91
+ </p>
92
+ </div>
93
+
94
+ <div style={{ textAlign: 'center' }}>
95
+ <h4>Con Error</h4>
96
+ <RadioButton
97
+ id="error"
98
+ name="test-basic"
99
+ label="Opción con error"
100
+ value="error"
101
+ checked={true}
102
+ error="Error de validación"
103
+ onChange={() => {}}
104
+ />
105
+ <p style={{ fontSize: '0.8rem', color: '#666', marginTop: '0.5rem' }}>
106
+ Colores de error (rojo)
107
+ </p>
108
+ </div>
109
+ </div>
110
+ </section>
111
+
112
+ {/* Prueba interactiva */}
113
+ <section style={{ marginBottom: '2rem' }}>
114
+ <h3>Prueba Interactiva</h3>
115
+ <div style={{
116
+ background: '#ffffff',
117
+ padding: '1.5rem',
118
+ borderRadius: '8px',
119
+ border: '1px solid #dee2e6'
120
+ }}>
121
+ <p><strong>Selecciona diferentes opciones y verifica la apariencia:</strong></p>
122
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '1rem', marginTop: '1rem' }}>
123
+ <RadioButton
124
+ id="option1"
125
+ name="interactive"
126
+ label="Primera opción"
127
+ value="option1"
128
+ checked={selectedValue === 'option1'}
129
+ onChange={(id, value) => setSelectedValue(value)}
130
+ />
131
+ <RadioButton
132
+ id="option2"
133
+ name="interactive"
134
+ label="Segunda opción"
135
+ value="option2"
136
+ checked={selectedValue === 'option2'}
137
+ onChange={(id, value) => setSelectedValue(value)}
138
+ />
139
+ <RadioButton
140
+ id="option3"
141
+ name="interactive"
142
+ label="Tercera opción"
143
+ value="option3"
144
+ checked={selectedValue === 'option3'}
145
+ onChange={(id, value) => setSelectedValue(value)}
146
+ />
147
+ </div>
148
+ <p style={{ marginTop: '1rem', fontSize: '0.9rem', color: '#666' }}>
149
+ <strong>Valor seleccionado:</strong> {selectedValue}
150
+ </p>
151
+ </div>
152
+ </section>
153
+
154
+ {/* RadioGroup */}
155
+ <section style={{ marginBottom: '2rem' }}>
156
+ <h3>RadioGroup</h3>
157
+ <div style={{
158
+ background: '#ffffff',
159
+ padding: '1.5rem',
160
+ borderRadius: '8px',
161
+ border: '1px solid #dee2e6'
162
+ }}>
163
+ <RadioGroup
164
+ id="size-group"
165
+ label="Tamaño de la interfaz"
166
+ value={groupValue}
167
+ onChange={(id, value) => setGroupValue(value)}
168
+ options={[
169
+ { id: 'small', label: 'Pequeño', value: 'small' },
170
+ { id: 'medium', label: 'Mediano', value: 'medium' },
171
+ { id: 'large', label: 'Grande', value: 'large' }
172
+ ]}
173
+ />
174
+ <p style={{ marginTop: '1rem', fontSize: '0.9rem', color: '#666' }}>
175
+ <strong>Valor del grupo:</strong> {groupValue}
176
+ </p>
177
+ </div>
178
+ </section>
179
+
180
+ {/* Comparación de tamaños */}
181
+ <section style={{ marginBottom: '2rem' }}>
182
+ <h3>Verificación de Dimensiones</h3>
183
+ <div style={{
184
+ background: '#f8f9fa',
185
+ padding: '1.5rem',
186
+ borderRadius: '8px',
187
+ border: '1px solid #dee2e6'
188
+ }}>
189
+ <div style={{ display: 'flex', alignItems: 'center', gap: '2rem', flexWrap: 'wrap' }}>
190
+ <div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
191
+ <span>No seleccionado:</span>
192
+ <RadioButton
193
+ id="size-test-1"
194
+ name="size-test"
195
+ value="test1"
196
+ checked={false}
197
+ onChange={() => {}}
198
+ />
199
+ </div>
200
+ <div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
201
+ <span>Seleccionado:</span>
202
+ <RadioButton
203
+ id="size-test-2"
204
+ name="size-test"
205
+ value="test2"
206
+ checked={true}
207
+ onChange={() => {}}
208
+ />
209
+ </div>
210
+ </div>
211
+
212
+ <div style={{ marginTop: '1rem', fontSize: '0.9rem', color: '#666' }}>
213
+ <h4>Especificaciones esperadas:</h4>
214
+ <ul>
215
+ <li><strong>Círculo externo:</strong> 1.2rem × 1.2rem, borde 2px</li>
216
+ <li><strong>Indicador interno:</strong> 0.4rem × 0.4rem, perfectamente centrado</li>
217
+ <li><strong>Espaciado:</strong> ~0.2rem entre borde e indicador</li>
218
+ <li><strong>Alineación:</strong> Sin desplazamientos laterales</li>
219
+ </ul>
220
+ </div>
221
+ </div>
222
+ </section>
223
+
224
+ {/* Información de debug */}
225
+ <section>
226
+ <h3>📋 Información de Debug</h3>
227
+ <div style={{
228
+ background: '#e9ecef',
229
+ padding: '1.5rem',
230
+ borderRadius: '8px',
231
+ border: '1px solid #adb5bd'
232
+ }}>
233
+ <h4>¿Qué deberías ver?</h4>
234
+ <ul style={{ marginBottom: '1rem' }}>
235
+ <li><strong>Radio no seleccionado:</strong> Círculo con borde, fondo blanco/claro</li>
236
+ <li><strong>Radio seleccionado:</strong> Círculo con borde + punto interno centrado</li>
237
+ <li><strong>Indicador interno:</strong> Círculo sólido, bien centrado, con espacio uniforme</li>
238
+ <li><strong>Estados hover/focus:</strong> Indicadores visuales claros</li>
239
+ </ul>
240
+
241
+ <h4>Si el indicador se ve mal:</h4>
242
+ <ul style={{ marginBottom: '1rem' }}>
243
+ <li>Verifica que el CSS se esté aplicando correctamente</li>
244
+ <li>Inspecciona el elemento en DevTools</li>
245
+ <li>Revisa que no hay CSS conflictivo</li>
246
+ <li>Asegúrate de que las variables CSS están definidas</li>
247
+ </ul>
248
+
249
+ <h4>CSS aplicado:</h4>
250
+ <pre style={{
251
+ background: '#ffffff',
252
+ padding: '1rem',
253
+ borderRadius: '4px',
254
+ fontFamily: 'monospace',
255
+ fontSize: '0.8rem',
256
+ overflow: 'auto'
257
+ }}>
258
+ {`.radio .checkmark {
259
+ width: 1.2rem;
260
+ height: 1.2rem;
261
+ border: 2px solid var(--primary-color);
262
+ border-radius: 50%;
263
+ position: relative;
264
+ }
265
+
266
+ .radio .checkmark:after {
267
+ content: "";
268
+ width: 0.4rem;
269
+ height: 0.4rem;
270
+ border-radius: 50%;
271
+ background-color: var(--primary-color);
272
+ position: absolute;
273
+ top: 50%;
274
+ left: 50%;
275
+ transform: translate(-50%, -50%);
276
+ display: none;
277
+ }
278
+
279
+ input:checked ~ .checkmark:after {
280
+ display: block;
281
+ }`}
282
+ </pre>
283
+ </div>
284
+ </section>
285
+ </div>
286
+ )
287
+ }
288
+
289
+ export default RadioVisualTest