ywana-core8 0.1.103 → 0.2.2
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.css +4941 -324
- package/dist/index.js +42339 -0
- package/dist/index.js.map +1 -0
- package/dist/index.modern.js +37459 -31678
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +39635 -34010
- package/dist/index.umd.js.map +1 -1
- package/package.json +26 -29
- package/src/Test.stories.jsx +28 -0
- package/src/desktop/Desktop.stories.jsx +110 -0
- package/src/desktop/WindowContext.js +135 -0
- package/src/desktop/WindowManager.js +355 -0
- package/src/desktop/desktop.css +55 -4
- package/src/desktop/desktop.js +312 -6
- package/src/desktop/index.js +7 -0
- package/src/desktop/window.css +229 -36
- package/src/desktop/window.js +255 -20
- package/src/desktop.backup/desktop.css +6 -0
- package/src/desktop.backup/desktop.js +13 -0
- package/src/desktop.backup/window.css +58 -0
- package/src/desktop.backup/window.js +27 -0
- package/src/html/Accordion.stories.jsx +178 -0
- package/src/html/Button.stories.jsx +175 -0
- package/src/html/Checkbox.stories.jsx +131 -0
- package/src/html/Chip.stories.jsx +189 -0
- package/src/html/Color.stories.jsx +234 -0
- package/src/html/Form.stories.jsx +271 -0
- package/src/html/Icon.stories.jsx +233 -0
- package/src/html/Progress.stories.jsx +247 -0
- package/src/html/Radio.stories.jsx +289 -0
- package/src/html/StyleTest.stories.jsx +81 -0
- package/src/html/Switch.stories.jsx +329 -0
- package/src/html/Tab.stories.jsx +239 -0
- package/src/html/Table.stories.jsx +188 -0
- package/src/html/Table2.stories.jsx +238 -0
- package/src/html/TextField2.stories.jsx +337 -0
- package/src/html/Tree.stories.jsx +285 -0
- package/src/html/accordion.example.js +0 -74
- package/src/html/accordion.js +1 -6
- package/src/html/button.js +2 -13
- package/src/html/checkbox.js +1 -9
- package/src/html/chip.js +2 -19
- package/src/html/color.js +1 -14
- package/src/html/form.js +4 -15
- package/src/html/header2.js +1 -12
- package/src/html/icon.js +1 -7
- package/src/html/index.js +1 -1
- package/src/html/list.js +1 -19
- package/src/html/menu.js +9 -5
- package/src/html/progress.js +5 -53
- package/src/html/property.js +9 -25
- package/src/html/radio.js +2 -16
- package/src/html/section.js +1 -6
- package/src/html/selector.js +2 -19
- package/src/html/switch.css +134 -100
- package/src/html/switch.example.js +46 -36
- package/src/html/switch.js +43 -192
- package/src/html/tab.js +3 -24
- package/src/html/text.js +1 -12
- package/src/html/textfield2.js +5 -42
- package/src/html/thumbnail.js +1 -12
- package/src/html/tokenfield.js +2 -21
- package/src/html/tree.js +3 -35
- package/src/index.js +1 -0
- package/__previewjs__/Wrapper.tsx +0 -14
- package/build-doc.sh +0 -10
- package/db/db.json +0 -89
- package/db/routes.json +0 -0
- package/dist/index.cjs +0 -36722
- package/dist/index.cjs.map +0 -1
- package/dist/index.css.map +0 -1
- package/doc/README.md +0 -196
- package/doc/evalulations/ACCORDION_EVALUATION.md +0 -583
- package/doc/evalulations/CHECKBOX_EVALUATION.md +0 -273
- package/doc/evalulations/CHIP_EVALUATION.md +0 -542
- package/doc/evalulations/COLOR_EVALUATION.md +0 -524
- package/doc/evalulations/COMPONENTS_EVALUATION.md +0 -477
- package/doc/evalulations/FORM_EVALUATION.md +0 -459
- package/doc/evalulations/HEADER_EVALUATION.md +0 -436
- package/doc/evalulations/ICON_EVALUATION.md +0 -254
- package/doc/evalulations/LIST_EVALUATION.md +0 -574
- package/doc/evalulations/PROGRESS_EVALUATION.md +0 -450
- package/doc/evalulations/RADIO_EVALUATION.md +0 -439
- package/doc/evalulations/RADIO_VISUAL_FIX.md +0 -183
- package/doc/evalulations/SECTION_IMPROVEMENTS.md +0 -153
- package/doc/evalulations/SWITCH_EVALUATION.md +0 -335
- package/doc/evalulations/SWITCH_VISUAL_FIX.md +0 -232
- package/doc/evalulations/TAB_EVALUATION.md +0 -626
- package/doc/evalulations/TEXTFIELD_EVALUATION.md +0 -747
- package/doc/evalulations/TOOLTIP_FIX.md +0 -157
- package/doc/evalulations/TREE_EVALUATION.md +0 -708
- package/doc/index.html +0 -0
- package/doc/package-lock.json +0 -17298
- package/doc/package.json +0 -34
- package/doc/public/index.html +0 -24
- package/doc/scripts/generate-examples.js +0 -129
- package/doc/src/App.css +0 -171
- package/doc/src/App.js +0 -114
- package/doc/src/components/ExamplePage.js +0 -129
- package/doc/src/components/WelcomePage.js +0 -84
- package/doc/src/index.css +0 -246
- package/doc/src/index.js +0 -17
- package/doc/src/theme.css +0 -256
- package/jest.config.js +0 -24
- package/preview.config.js +0 -38
- package/publish.sh +0 -6
- package/src/desktop/dektop.test.js +0 -11
- package/src/domain/CollectionAPI.test.js +0 -19
- package/src/domain/ContentEditor.test.js +0 -52
- package/src/domain2/CollectionAPI.test.js +0 -19
- package/src/domain2/CollectionContext.test.js +0 -71
- package/src/domain2/CollectionPage.test.js +0 -112
- package/src/domain2/DynamicForm.test.js +0 -47
- package/src/html/accordion.test.js +0 -37
- package/src/html/accordion.unit.test.js +0 -334
- package/src/html/button.example.new.js +0 -416
- package/src/html/button.test.js +0 -422
- package/src/html/checkbox.test.js +0 -285
- package/src/html/chip.test.js +0 -425
- package/src/html/color.example.js.backup +0 -527
- package/src/html/color.test.js +0 -377
- package/src/html/components.example.js.backup +0 -492
- package/src/html/components_enhanced.test.js +0 -581
- package/src/html/form.example.js.backup +0 -385
- package/src/html/form.test.js +0 -369
- package/src/html/header2.example.js.backup +0 -411
- package/src/html/header2.test.js +0 -377
- package/src/html/icon.example.js.backup +0 -268
- package/src/html/icon.test.js +0 -231
- package/src/html/label.test.js +0 -0
- package/src/html/list.example.js.backup +0 -404
- package/src/html/list.test.js +0 -383
- package/src/html/progress.example.js.backup +0 -424
- package/src/html/progress.test.js +0 -313
- package/src/html/property.example.js.backup +0 -553
- package/src/html/property.test.js +0 -371
- package/src/html/radio.example.js.backup +0 -389
- package/src/html/radio.test.js +0 -318
- package/src/html/section.example.js.backup +0 -99
- package/src/html/section.test.js +0 -131
- package/src/html/selector.test.js +0 -20
- package/src/html/switch.example.js.backup +0 -461
- package/src/html/switch.test.js +0 -355
- package/src/html/tab.example.js.backup +0 -446
- package/src/html/tab.test.js +0 -25
- package/src/html/tab_enhanced.test.js +0 -504
- package/src/html/table.test.js +0 -70
- package/src/html/table2.test.js +0 -582
- package/src/html/text.test.js +0 -15
- package/src/html/textfield.test.js +0 -51
- package/src/html/textfield2.example.js.backup +0 -1370
- package/src/html/textfield2.test.js +0 -950
- package/src/html/tokenfield.example.js.backup +0 -503
- package/src/html/tokenfield.test.js +0 -423
- package/src/html/tree.example.js.backup +0 -475
- package/src/html/tree.test.js +0 -43
- package/src/html/tree_enhanced.test.js +0 -495
- package/src/http/token.test.js +0 -50
- package/src/incubator/pdfViewer.js +0 -33
- package/src/incubator/wizard.test.js +0 -127
- package/src/site/site.test.js +0 -230
- package/src/site/view.test.js +0 -41
- package/src/widgets/calendar/Calendar.test.js +0 -28
- package/src/widgets/explorer/Explorer.test.js +0 -121
- package/src/widgets/ide/editor.test.js +0 -33
- package/src/widgets/kanban/Kanban.test.js +0 -78
- package/src/widgets/login/LoginBox.test.js +0 -12
- package/src/widgets/login/ResetPasswordBox.test.js +0 -34
- package/src/widgets/login/validations.test.js +0 -51
- package/src/widgets/planner/Planner.test.js +0 -60
- package/src/widgets/upload/Upload.test.js +0 -32
- package/table2.test.js +0 -454
@@ -1,285 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import { CheckBox } from './checkbox'
|
3
|
-
|
4
|
-
// Pruebas unitarias para el componente CheckBox
|
5
|
-
describe('CheckBox Component', () => {
|
6
|
-
// Mock del componente Text
|
7
|
-
const mockText = jest.fn()
|
8
|
-
|
9
|
-
beforeEach(() => {
|
10
|
-
jest.clearAllMocks()
|
11
|
-
|
12
|
-
// Mock del componente Text
|
13
|
-
jest.doMock('./text', () => ({
|
14
|
-
Text: mockText
|
15
|
-
}))
|
16
|
-
|
17
|
-
// Mock de console.warn para las pruebas
|
18
|
-
jest.spyOn(console, 'warn').mockImplementation(() => {})
|
19
|
-
})
|
20
|
-
|
21
|
-
afterEach(() => {
|
22
|
-
console.warn.mockRestore()
|
23
|
-
})
|
24
|
-
|
25
|
-
test('component exports correctly', () => {
|
26
|
-
expect(CheckBox).toBeDefined()
|
27
|
-
expect(typeof CheckBox).toBe('function')
|
28
|
-
})
|
29
|
-
|
30
|
-
test('component has correct PropTypes', () => {
|
31
|
-
expect(CheckBox.propTypes).toBeDefined()
|
32
|
-
expect(CheckBox.propTypes.id).toBeDefined()
|
33
|
-
expect(CheckBox.propTypes.label).toBeDefined()
|
34
|
-
expect(CheckBox.propTypes.value).toBeDefined()
|
35
|
-
expect(CheckBox.propTypes.readOnly).toBeDefined()
|
36
|
-
expect(CheckBox.propTypes.disabled).toBeDefined()
|
37
|
-
expect(CheckBox.propTypes.indeterminate).toBeDefined()
|
38
|
-
expect(CheckBox.propTypes.error).toBeDefined()
|
39
|
-
expect(CheckBox.propTypes.required).toBeDefined()
|
40
|
-
expect(CheckBox.propTypes.className).toBeDefined()
|
41
|
-
expect(CheckBox.propTypes.ariaLabel).toBeDefined()
|
42
|
-
expect(CheckBox.propTypes.onChange).toBeDefined()
|
43
|
-
})
|
44
|
-
|
45
|
-
test('component has correct defaultProps', () => {
|
46
|
-
expect(CheckBox.defaultProps).toBeDefined()
|
47
|
-
expect(CheckBox.defaultProps.value).toBe(false)
|
48
|
-
expect(CheckBox.defaultProps.readOnly).toBe(false)
|
49
|
-
expect(CheckBox.defaultProps.disabled).toBe(false)
|
50
|
-
expect(CheckBox.defaultProps.indeterminate).toBe(false)
|
51
|
-
expect(CheckBox.defaultProps.error).toBe(false)
|
52
|
-
expect(CheckBox.defaultProps.required).toBe(false)
|
53
|
-
expect(CheckBox.defaultProps.className).toBe('')
|
54
|
-
})
|
55
|
-
|
56
|
-
test('returns null and warns when id prop is missing', () => {
|
57
|
-
// No podemos llamar directamente al componente como función debido a los hooks
|
58
|
-
// En su lugar, verificamos que la validación funciona conceptualmente
|
59
|
-
const validateId = (id) => {
|
60
|
-
if (!id) {
|
61
|
-
console.warn('CheckBox component: id prop is required')
|
62
|
-
return null
|
63
|
-
}
|
64
|
-
return true
|
65
|
-
}
|
66
|
-
|
67
|
-
const result = validateId(undefined)
|
68
|
-
expect(result).toBeNull()
|
69
|
-
expect(console.warn).toHaveBeenCalledWith('CheckBox component: id prop is required')
|
70
|
-
})
|
71
|
-
|
72
|
-
test('generates correct CSS classes for different states', () => {
|
73
|
-
// Simular la lógica de generación de clases
|
74
|
-
const generateClasses = (readOnly, disabled, error, className) => {
|
75
|
-
return [
|
76
|
-
'checkbox',
|
77
|
-
readOnly && 'readonly',
|
78
|
-
disabled && 'disabled',
|
79
|
-
error && 'error',
|
80
|
-
className || ''
|
81
|
-
].filter(Boolean).join(' ')
|
82
|
-
}
|
83
|
-
|
84
|
-
expect(generateClasses(false, false, false, '')).toBe('checkbox')
|
85
|
-
expect(generateClasses(true, false, false, '')).toBe('checkbox readonly')
|
86
|
-
expect(generateClasses(false, true, false, '')).toBe('checkbox disabled')
|
87
|
-
expect(generateClasses(false, false, true, '')).toBe('checkbox error')
|
88
|
-
expect(generateClasses(false, false, false, 'custom')).toBe('checkbox custom')
|
89
|
-
expect(generateClasses(true, true, true, 'custom')).toBe('checkbox readonly disabled error custom')
|
90
|
-
})
|
91
|
-
|
92
|
-
test('generates correct accessibility attributes', () => {
|
93
|
-
// Simular la lógica de atributos de accesibilidad
|
94
|
-
const generateAriaAttributes = (ariaLabel, label, required, error, id) => {
|
95
|
-
return {
|
96
|
-
'aria-label': ariaLabel || label,
|
97
|
-
'aria-required': required,
|
98
|
-
'aria-invalid': error,
|
99
|
-
'aria-describedby': error ? `${id}-error` : undefined
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
// Atributos básicos
|
104
|
-
const basic = generateAriaAttributes(null, 'Test Label', false, false, 'test')
|
105
|
-
expect(basic['aria-label']).toBe('Test Label')
|
106
|
-
expect(basic['aria-required']).toBe(false)
|
107
|
-
expect(basic['aria-invalid']).toBe(false)
|
108
|
-
expect(basic['aria-describedby']).toBeUndefined()
|
109
|
-
|
110
|
-
// Con aria-label personalizado
|
111
|
-
const customLabel = generateAriaAttributes('Custom Label', 'Test Label', false, false, 'test')
|
112
|
-
expect(customLabel['aria-label']).toBe('Custom Label')
|
113
|
-
|
114
|
-
// Requerido
|
115
|
-
const required = generateAriaAttributes(null, 'Test Label', true, false, 'test')
|
116
|
-
expect(required['aria-required']).toBe(true)
|
117
|
-
|
118
|
-
// Con error
|
119
|
-
const withError = generateAriaAttributes(null, 'Test Label', false, true, 'test')
|
120
|
-
expect(withError['aria-invalid']).toBe(true)
|
121
|
-
expect(withError['aria-describedby']).toBe('test-error')
|
122
|
-
})
|
123
|
-
|
124
|
-
test('change handler works correctly', () => {
|
125
|
-
const mockOnChange = jest.fn()
|
126
|
-
|
127
|
-
// Simular el comportamiento del change handler
|
128
|
-
const simulateChange = (readOnly, disabled, onChange, id) => {
|
129
|
-
const event = {
|
130
|
-
stopPropagation: jest.fn(),
|
131
|
-
target: { checked: true }
|
132
|
-
}
|
133
|
-
|
134
|
-
// Lógica del change handler
|
135
|
-
event.stopPropagation()
|
136
|
-
const nextValue = event.target.checked
|
137
|
-
|
138
|
-
if (onChange && !readOnly && !disabled) {
|
139
|
-
onChange(id, nextValue)
|
140
|
-
}
|
141
|
-
|
142
|
-
return { event, nextValue }
|
143
|
-
}
|
144
|
-
|
145
|
-
// Change normal
|
146
|
-
const { event: event1 } = simulateChange(false, false, mockOnChange, 'test')
|
147
|
-
expect(event1.stopPropagation).toHaveBeenCalled()
|
148
|
-
expect(mockOnChange).toHaveBeenCalledWith('test', true)
|
149
|
-
|
150
|
-
mockOnChange.mockClear()
|
151
|
-
|
152
|
-
// Change con readOnly
|
153
|
-
simulateChange(true, false, mockOnChange, 'test')
|
154
|
-
expect(mockOnChange).not.toHaveBeenCalled()
|
155
|
-
|
156
|
-
// Change con disabled
|
157
|
-
simulateChange(false, true, mockOnChange, 'test')
|
158
|
-
expect(mockOnChange).not.toHaveBeenCalled()
|
159
|
-
})
|
160
|
-
|
161
|
-
test('keyboard event handling works correctly', () => {
|
162
|
-
const mockOnChange = jest.fn()
|
163
|
-
|
164
|
-
// Simular el manejo de eventos de teclado
|
165
|
-
const simulateKeyDown = (key, readOnly, disabled, checked, onChange, id) => {
|
166
|
-
const event = {
|
167
|
-
key,
|
168
|
-
preventDefault: jest.fn()
|
169
|
-
}
|
170
|
-
|
171
|
-
// Lógica del keyboard handler
|
172
|
-
if (event.key === ' ') {
|
173
|
-
event.preventDefault()
|
174
|
-
if (!readOnly && !disabled) {
|
175
|
-
const nextValue = !checked
|
176
|
-
if (onChange) onChange(id, nextValue)
|
177
|
-
}
|
178
|
-
}
|
179
|
-
|
180
|
-
return event
|
181
|
-
}
|
182
|
-
|
183
|
-
// Space key
|
184
|
-
const spaceEvent = simulateKeyDown(' ', false, false, false, mockOnChange, 'test')
|
185
|
-
expect(spaceEvent.preventDefault).toHaveBeenCalled()
|
186
|
-
expect(mockOnChange).toHaveBeenCalledWith('test', true)
|
187
|
-
|
188
|
-
mockOnChange.mockClear()
|
189
|
-
|
190
|
-
// Other key (should not trigger)
|
191
|
-
const otherEvent = simulateKeyDown('Enter', false, false, false, mockOnChange, 'test')
|
192
|
-
expect(otherEvent.preventDefault).not.toHaveBeenCalled()
|
193
|
-
expect(mockOnChange).not.toHaveBeenCalled()
|
194
|
-
|
195
|
-
// Space key with readOnly (should not trigger onChange)
|
196
|
-
const readOnlyEvent = simulateKeyDown(' ', true, false, false, mockOnChange, 'test')
|
197
|
-
expect(readOnlyEvent.preventDefault).toHaveBeenCalled()
|
198
|
-
expect(mockOnChange).not.toHaveBeenCalled()
|
199
|
-
|
200
|
-
// Space key with disabled (should not trigger onChange)
|
201
|
-
const disabledEvent = simulateKeyDown(' ', false, true, false, mockOnChange, 'test')
|
202
|
-
expect(disabledEvent.preventDefault).toHaveBeenCalled()
|
203
|
-
expect(mockOnChange).not.toHaveBeenCalled()
|
204
|
-
})
|
205
|
-
|
206
|
-
test('state synchronization works correctly', () => {
|
207
|
-
// Simular la sincronización de estado con useEffect
|
208
|
-
let internalState = false
|
209
|
-
|
210
|
-
const syncState = (externalValue) => {
|
211
|
-
internalState = externalValue
|
212
|
-
}
|
213
|
-
|
214
|
-
// Estado inicial
|
215
|
-
syncState(false)
|
216
|
-
expect(internalState).toBe(false)
|
217
|
-
|
218
|
-
// Cambio externo
|
219
|
-
syncState(true)
|
220
|
-
expect(internalState).toBe(true)
|
221
|
-
|
222
|
-
// Otro cambio
|
223
|
-
syncState(false)
|
224
|
-
expect(internalState).toBe(false)
|
225
|
-
})
|
226
|
-
|
227
|
-
test('indeterminate state handling works correctly', () => {
|
228
|
-
// Simular el manejo del estado indeterminate
|
229
|
-
const mockInputRef = {
|
230
|
-
current: {
|
231
|
-
indeterminate: false
|
232
|
-
}
|
233
|
-
}
|
234
|
-
|
235
|
-
const setIndeterminate = (value) => {
|
236
|
-
if (mockInputRef.current) {
|
237
|
-
mockInputRef.current.indeterminate = value
|
238
|
-
}
|
239
|
-
}
|
240
|
-
|
241
|
-
// Establecer indeterminate
|
242
|
-
setIndeterminate(true)
|
243
|
-
expect(mockInputRef.current.indeterminate).toBe(true)
|
244
|
-
|
245
|
-
// Quitar indeterminate
|
246
|
-
setIndeterminate(false)
|
247
|
-
expect(mockInputRef.current.indeterminate).toBe(false)
|
248
|
-
})
|
249
|
-
|
250
|
-
test('error message rendering logic works correctly', () => {
|
251
|
-
// Simular la lógica de renderizado de mensajes de error
|
252
|
-
const shouldShowErrorMessage = (error) => {
|
253
|
-
return !!(error && typeof error === 'string' && error.length > 0)
|
254
|
-
}
|
255
|
-
|
256
|
-
expect(shouldShowErrorMessage(false)).toBe(false)
|
257
|
-
expect(shouldShowErrorMessage(true)).toBe(false)
|
258
|
-
expect(shouldShowErrorMessage('Error message')).toBe(true)
|
259
|
-
expect(shouldShowErrorMessage('')).toBe(false)
|
260
|
-
expect(shouldShowErrorMessage(null)).toBe(false)
|
261
|
-
expect(shouldShowErrorMessage(undefined)).toBe(false)
|
262
|
-
})
|
263
|
-
|
264
|
-
test('disabled state logic works correctly', () => {
|
265
|
-
// Simular la lógica de estado disabled
|
266
|
-
const isDisabled = (readOnly, disabled) => {
|
267
|
-
return readOnly || disabled
|
268
|
-
}
|
269
|
-
|
270
|
-
expect(isDisabled(false, false)).toBe(false)
|
271
|
-
expect(isDisabled(true, false)).toBe(true)
|
272
|
-
expect(isDisabled(false, true)).toBe(true)
|
273
|
-
expect(isDisabled(true, true)).toBe(true)
|
274
|
-
})
|
275
|
-
|
276
|
-
test('tabIndex logic works correctly', () => {
|
277
|
-
// Simular la lógica de tabIndex
|
278
|
-
const getTabIndex = (isDisabled) => {
|
279
|
-
return isDisabled ? -1 : 0
|
280
|
-
}
|
281
|
-
|
282
|
-
expect(getTabIndex(false)).toBe(0)
|
283
|
-
expect(getTabIndex(true)).toBe(-1)
|
284
|
-
})
|
285
|
-
})
|