ywana-core8 0.1.103 → 0.2.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.
Files changed (172) hide show
  1. package/dist/index.css +4941 -324
  2. package/dist/index.js +42338 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/index.modern.js +37458 -31678
  5. package/dist/index.modern.js.map +1 -1
  6. package/dist/index.umd.js +39634 -34010
  7. package/dist/index.umd.js.map +1 -1
  8. package/package.json +26 -29
  9. package/src/Test.stories.jsx +28 -0
  10. package/src/desktop/Desktop.stories.jsx +110 -0
  11. package/src/desktop/WindowContext.js +135 -0
  12. package/src/desktop/WindowManager.js +355 -0
  13. package/src/desktop/desktop.css +55 -4
  14. package/src/desktop/desktop.js +312 -6
  15. package/src/desktop/index.js +7 -0
  16. package/src/desktop/window.css +229 -36
  17. package/src/desktop/window.js +254 -20
  18. package/src/desktop.backup/desktop.css +6 -0
  19. package/src/desktop.backup/desktop.js +13 -0
  20. package/src/desktop.backup/window.css +58 -0
  21. package/src/desktop.backup/window.js +27 -0
  22. package/src/html/Accordion.stories.jsx +178 -0
  23. package/src/html/Button.stories.jsx +175 -0
  24. package/src/html/Checkbox.stories.jsx +131 -0
  25. package/src/html/Chip.stories.jsx +189 -0
  26. package/src/html/Color.stories.jsx +234 -0
  27. package/src/html/Form.stories.jsx +271 -0
  28. package/src/html/Icon.stories.jsx +233 -0
  29. package/src/html/Progress.stories.jsx +247 -0
  30. package/src/html/Radio.stories.jsx +289 -0
  31. package/src/html/StyleTest.stories.jsx +81 -0
  32. package/src/html/Switch.stories.jsx +329 -0
  33. package/src/html/Tab.stories.jsx +239 -0
  34. package/src/html/Table.stories.jsx +188 -0
  35. package/src/html/Table2.stories.jsx +238 -0
  36. package/src/html/TextField2.stories.jsx +337 -0
  37. package/src/html/Tree.stories.jsx +285 -0
  38. package/src/html/accordion.example.js +0 -74
  39. package/src/html/accordion.js +1 -6
  40. package/src/html/button.js +2 -13
  41. package/src/html/checkbox.js +1 -9
  42. package/src/html/chip.js +2 -19
  43. package/src/html/color.js +1 -14
  44. package/src/html/form.js +4 -15
  45. package/src/html/header2.js +1 -12
  46. package/src/html/icon.js +1 -7
  47. package/src/html/index.js +1 -1
  48. package/src/html/list.js +1 -19
  49. package/src/html/menu.js +9 -5
  50. package/src/html/progress.js +5 -53
  51. package/src/html/property.js +9 -25
  52. package/src/html/radio.js +2 -16
  53. package/src/html/section.js +1 -6
  54. package/src/html/selector.js +2 -19
  55. package/src/html/switch.css +134 -100
  56. package/src/html/switch.example.js +46 -36
  57. package/src/html/switch.js +43 -192
  58. package/src/html/tab.js +3 -24
  59. package/src/html/text.js +1 -12
  60. package/src/html/textfield2.js +5 -42
  61. package/src/html/thumbnail.js +1 -12
  62. package/src/html/tokenfield.js +2 -21
  63. package/src/html/tree.js +3 -35
  64. package/src/index.js +1 -0
  65. package/__previewjs__/Wrapper.tsx +0 -14
  66. package/build-doc.sh +0 -10
  67. package/db/db.json +0 -89
  68. package/db/routes.json +0 -0
  69. package/dist/index.cjs +0 -36722
  70. package/dist/index.cjs.map +0 -1
  71. package/dist/index.css.map +0 -1
  72. package/doc/README.md +0 -196
  73. package/doc/evalulations/ACCORDION_EVALUATION.md +0 -583
  74. package/doc/evalulations/CHECKBOX_EVALUATION.md +0 -273
  75. package/doc/evalulations/CHIP_EVALUATION.md +0 -542
  76. package/doc/evalulations/COLOR_EVALUATION.md +0 -524
  77. package/doc/evalulations/COMPONENTS_EVALUATION.md +0 -477
  78. package/doc/evalulations/FORM_EVALUATION.md +0 -459
  79. package/doc/evalulations/HEADER_EVALUATION.md +0 -436
  80. package/doc/evalulations/ICON_EVALUATION.md +0 -254
  81. package/doc/evalulations/LIST_EVALUATION.md +0 -574
  82. package/doc/evalulations/PROGRESS_EVALUATION.md +0 -450
  83. package/doc/evalulations/RADIO_EVALUATION.md +0 -439
  84. package/doc/evalulations/RADIO_VISUAL_FIX.md +0 -183
  85. package/doc/evalulations/SECTION_IMPROVEMENTS.md +0 -153
  86. package/doc/evalulations/SWITCH_EVALUATION.md +0 -335
  87. package/doc/evalulations/SWITCH_VISUAL_FIX.md +0 -232
  88. package/doc/evalulations/TAB_EVALUATION.md +0 -626
  89. package/doc/evalulations/TEXTFIELD_EVALUATION.md +0 -747
  90. package/doc/evalulations/TOOLTIP_FIX.md +0 -157
  91. package/doc/evalulations/TREE_EVALUATION.md +0 -708
  92. package/doc/index.html +0 -0
  93. package/doc/package-lock.json +0 -17298
  94. package/doc/package.json +0 -34
  95. package/doc/public/index.html +0 -24
  96. package/doc/scripts/generate-examples.js +0 -129
  97. package/doc/src/App.css +0 -171
  98. package/doc/src/App.js +0 -114
  99. package/doc/src/components/ExamplePage.js +0 -129
  100. package/doc/src/components/WelcomePage.js +0 -84
  101. package/doc/src/index.css +0 -246
  102. package/doc/src/index.js +0 -17
  103. package/doc/src/theme.css +0 -256
  104. package/jest.config.js +0 -24
  105. package/preview.config.js +0 -38
  106. package/publish.sh +0 -6
  107. package/src/desktop/dektop.test.js +0 -11
  108. package/src/domain/CollectionAPI.test.js +0 -19
  109. package/src/domain/ContentEditor.test.js +0 -52
  110. package/src/domain2/CollectionAPI.test.js +0 -19
  111. package/src/domain2/CollectionContext.test.js +0 -71
  112. package/src/domain2/CollectionPage.test.js +0 -112
  113. package/src/domain2/DynamicForm.test.js +0 -47
  114. package/src/html/accordion.test.js +0 -37
  115. package/src/html/accordion.unit.test.js +0 -334
  116. package/src/html/button.example.new.js +0 -416
  117. package/src/html/button.test.js +0 -422
  118. package/src/html/checkbox.test.js +0 -285
  119. package/src/html/chip.test.js +0 -425
  120. package/src/html/color.example.js.backup +0 -527
  121. package/src/html/color.test.js +0 -377
  122. package/src/html/components.example.js.backup +0 -492
  123. package/src/html/components_enhanced.test.js +0 -581
  124. package/src/html/form.example.js.backup +0 -385
  125. package/src/html/form.test.js +0 -369
  126. package/src/html/header2.example.js.backup +0 -411
  127. package/src/html/header2.test.js +0 -377
  128. package/src/html/icon.example.js.backup +0 -268
  129. package/src/html/icon.test.js +0 -231
  130. package/src/html/label.test.js +0 -0
  131. package/src/html/list.example.js.backup +0 -404
  132. package/src/html/list.test.js +0 -383
  133. package/src/html/progress.example.js.backup +0 -424
  134. package/src/html/progress.test.js +0 -313
  135. package/src/html/property.example.js.backup +0 -553
  136. package/src/html/property.test.js +0 -371
  137. package/src/html/radio.example.js.backup +0 -389
  138. package/src/html/radio.test.js +0 -318
  139. package/src/html/section.example.js.backup +0 -99
  140. package/src/html/section.test.js +0 -131
  141. package/src/html/selector.test.js +0 -20
  142. package/src/html/switch.example.js.backup +0 -461
  143. package/src/html/switch.test.js +0 -355
  144. package/src/html/tab.example.js.backup +0 -446
  145. package/src/html/tab.test.js +0 -25
  146. package/src/html/tab_enhanced.test.js +0 -504
  147. package/src/html/table.test.js +0 -70
  148. package/src/html/table2.test.js +0 -582
  149. package/src/html/text.test.js +0 -15
  150. package/src/html/textfield.test.js +0 -51
  151. package/src/html/textfield2.example.js.backup +0 -1370
  152. package/src/html/textfield2.test.js +0 -950
  153. package/src/html/tokenfield.example.js.backup +0 -503
  154. package/src/html/tokenfield.test.js +0 -423
  155. package/src/html/tree.example.js.backup +0 -475
  156. package/src/html/tree.test.js +0 -43
  157. package/src/html/tree_enhanced.test.js +0 -495
  158. package/src/http/token.test.js +0 -50
  159. package/src/incubator/pdfViewer.js +0 -33
  160. package/src/incubator/wizard.test.js +0 -127
  161. package/src/site/site.test.js +0 -230
  162. package/src/site/view.test.js +0 -41
  163. package/src/widgets/calendar/Calendar.test.js +0 -28
  164. package/src/widgets/explorer/Explorer.test.js +0 -121
  165. package/src/widgets/ide/editor.test.js +0 -33
  166. package/src/widgets/kanban/Kanban.test.js +0 -78
  167. package/src/widgets/login/LoginBox.test.js +0 -12
  168. package/src/widgets/login/ResetPasswordBox.test.js +0 -34
  169. package/src/widgets/login/validations.test.js +0 -51
  170. package/src/widgets/planner/Planner.test.js +0 -60
  171. package/src/widgets/upload/Upload.test.js +0 -32
  172. package/table2.test.js +0 -454
@@ -1,355 +0,0 @@
1
- import React from 'react'
2
- import { Switch, Switch2 } from './switch'
3
-
4
- // Mock react-switch
5
- jest.mock('react-switch', () => {
6
- return function MockRSwitch(props) {
7
- const mockReact = require('react')
8
- return mockReact.createElement('div', {
9
- 'data-testid': 'react-switch',
10
- 'data-checked': props.checked,
11
- 'data-disabled': props.disabled,
12
- onClick: () => props.onChange && props.onChange(!props.checked)
13
- }, 'MockSwitch')
14
- }
15
- })
16
-
17
- // Pruebas unitarias para los componentes Switch
18
- describe('Switch Components', () => {
19
- // Mock de los componentes dependientes
20
- const mockText = jest.fn()
21
- const mockIcon = jest.fn()
22
-
23
- beforeEach(() => {
24
- jest.clearAllMocks()
25
-
26
- // Mock del componente Text
27
- jest.doMock('./text', () => ({
28
- Text: mockText
29
- }))
30
-
31
- // Mock del componente Icon
32
- jest.doMock('./icon', () => ({
33
- Icon: mockIcon
34
- }))
35
-
36
- // Mock de console.warn para las pruebas
37
- jest.spyOn(console, 'warn').mockImplementation(() => {})
38
- })
39
-
40
- afterEach(() => {
41
- console.warn.mockRestore()
42
- })
43
-
44
- describe('Switch Component', () => {
45
- test('component exports correctly', () => {
46
- expect(Switch).toBeDefined()
47
- expect(typeof Switch).toBe('function')
48
- })
49
-
50
- test('component has correct PropTypes', () => {
51
- expect(Switch.propTypes).toBeDefined()
52
- expect(Switch.propTypes.id).toBeDefined()
53
- expect(Switch.propTypes.label).toBeDefined()
54
- expect(Switch.propTypes.checked).toBeDefined()
55
- expect(Switch.propTypes.disabled).toBeDefined()
56
- expect(Switch.propTypes.readOnly).toBeDefined()
57
- expect(Switch.propTypes.error).toBeDefined()
58
- expect(Switch.propTypes.required).toBeDefined()
59
- expect(Switch.propTypes.size).toBeDefined()
60
- expect(Switch.propTypes.className).toBeDefined()
61
- expect(Switch.propTypes.ariaLabel).toBeDefined()
62
- expect(Switch.propTypes.onChange).toBeDefined()
63
- expect(Switch.propTypes.onColor).toBeDefined()
64
- expect(Switch.propTypes.offColor).toBeDefined()
65
- })
66
-
67
- test('component has correct defaultProps', () => {
68
- expect(Switch.defaultProps).toBeDefined()
69
- expect(Switch.defaultProps.checked).toBe(false)
70
- expect(Switch.defaultProps.disabled).toBe(false)
71
- expect(Switch.defaultProps.readOnly).toBe(false)
72
- expect(Switch.defaultProps.error).toBe(false)
73
- expect(Switch.defaultProps.required).toBe(false)
74
- expect(Switch.defaultProps.size).toBe('normal')
75
- expect(Switch.defaultProps.className).toBe('')
76
- })
77
-
78
- test('warns when onChange is not a function', () => {
79
- const validateOnChange = (onChange) => {
80
- if (onChange && typeof onChange !== 'function') {
81
- console.warn('Switch component: onChange prop should be a function')
82
- }
83
- }
84
-
85
- validateOnChange('not a function')
86
- expect(console.warn).toHaveBeenCalledWith('Switch component: onChange prop should be a function')
87
-
88
- console.warn.mockClear()
89
- validateOnChange(() => {})
90
- expect(console.warn).not.toHaveBeenCalled()
91
- })
92
-
93
- test('size configuration works correctly', () => {
94
- const sizeConfig = {
95
- small: { height: 16, width: 32, handleDiameter: 14 },
96
- normal: { height: 20, width: 48, handleDiameter: 18 },
97
- large: { height: 24, width: 56, handleDiameter: 22 }
98
- }
99
-
100
- expect(sizeConfig.small.height).toBe(16)
101
- expect(sizeConfig.normal.width).toBe(48)
102
- expect(sizeConfig.large.handleDiameter).toBe(22)
103
- })
104
-
105
- test('change handler works correctly', () => {
106
- const mockOnChange = jest.fn()
107
-
108
- // Simular el comportamiento del change handler
109
- const simulateChange = (disabled, readOnly, onChange, id) => {
110
- const nextChecked = true
111
- const event = {}
112
-
113
- if (!disabled && !readOnly && onChange) {
114
- onChange(id || 'switch', nextChecked, event)
115
- }
116
- }
117
-
118
- // Change normal
119
- simulateChange(false, false, mockOnChange, 'test')
120
- expect(mockOnChange).toHaveBeenCalledWith('test', true, {})
121
-
122
- mockOnChange.mockClear()
123
-
124
- // Change con disabled
125
- simulateChange(true, false, mockOnChange, 'test')
126
- expect(mockOnChange).not.toHaveBeenCalled()
127
-
128
- // Change con readOnly
129
- simulateChange(false, true, mockOnChange, 'test')
130
- expect(mockOnChange).not.toHaveBeenCalled()
131
- })
132
-
133
- test('accessibility attributes generation works correctly', () => {
134
- const generateAriaAttributes = (ariaLabel, label, required, error, id) => {
135
- return {
136
- 'aria-label': ariaLabel || label || 'Toggle switch',
137
- 'aria-required': required,
138
- 'aria-invalid': error,
139
- 'aria-describedby': error && typeof error === 'string' ? `${id}-error` : undefined
140
- }
141
- }
142
-
143
- // Atributos básicos
144
- const basic = generateAriaAttributes(null, null, false, false, 'test')
145
- expect(basic['aria-label']).toBe('Toggle switch')
146
- expect(basic['aria-required']).toBe(false)
147
- expect(basic['aria-invalid']).toBe(false)
148
- expect(basic['aria-describedby']).toBeUndefined()
149
-
150
- // Con label personalizado
151
- const withLabel = generateAriaAttributes(null, 'Custom Label', false, false, 'test')
152
- expect(withLabel['aria-label']).toBe('Custom Label')
153
-
154
- // Con aria-label personalizado
155
- const withAriaLabel = generateAriaAttributes('Custom ARIA', 'Label', false, false, 'test')
156
- expect(withAriaLabel['aria-label']).toBe('Custom ARIA')
157
-
158
- // Con error
159
- const withError = generateAriaAttributes(null, null, false, 'Error message', 'test')
160
- expect(withError['aria-invalid']).toBe('Error message')
161
- expect(withError['aria-describedby']).toBe('test-error')
162
- })
163
- })
164
-
165
- describe('Switch2 Component', () => {
166
- test('component exports correctly', () => {
167
- expect(Switch2).toBeDefined()
168
- expect(typeof Switch2).toBe('function')
169
- })
170
-
171
- test('component has correct PropTypes', () => {
172
- expect(Switch2.propTypes).toBeDefined()
173
- expect(Switch2.propTypes.id).toBeDefined()
174
- expect(Switch2.propTypes.label).toBeDefined()
175
- expect(Switch2.propTypes.checked).toBeDefined()
176
- expect(Switch2.propTypes.disabled).toBeDefined()
177
- expect(Switch2.propTypes.readOnly).toBeDefined()
178
- expect(Switch2.propTypes.error).toBeDefined()
179
- expect(Switch2.propTypes.required).toBeDefined()
180
- expect(Switch2.propTypes.size).toBeDefined()
181
- expect(Switch2.propTypes.className).toBeDefined()
182
- expect(Switch2.propTypes.ariaLabel).toBeDefined()
183
- expect(Switch2.propTypes.onChange).toBeDefined()
184
- })
185
-
186
- test('component has correct defaultProps', () => {
187
- expect(Switch2.defaultProps).toBeDefined()
188
- expect(Switch2.defaultProps.checked).toBe(false)
189
- expect(Switch2.defaultProps.disabled).toBe(false)
190
- expect(Switch2.defaultProps.readOnly).toBe(false)
191
- expect(Switch2.defaultProps.error).toBe(false)
192
- expect(Switch2.defaultProps.required).toBe(false)
193
- expect(Switch2.defaultProps.size).toBe('normal')
194
- expect(Switch2.defaultProps.className).toBe('')
195
- })
196
-
197
- test('warns when onChange is not a function', () => {
198
- const validateOnChange = (onChange) => {
199
- if (onChange && typeof onChange !== 'function') {
200
- console.warn('Switch2 component: onChange prop should be a function')
201
- }
202
- }
203
-
204
- validateOnChange('not a function')
205
- expect(console.warn).toHaveBeenCalledWith('Switch2 component: onChange prop should be a function')
206
-
207
- console.warn.mockClear()
208
- validateOnChange(() => {})
209
- expect(console.warn).not.toHaveBeenCalled()
210
- })
211
-
212
- test('icon selection logic works correctly', () => {
213
- const getIcon = (checked) => {
214
- return checked ? "toggle_on" : "toggle_off"
215
- }
216
-
217
- expect(getIcon(true)).toBe('toggle_on')
218
- expect(getIcon(false)).toBe('toggle_off')
219
- })
220
-
221
- test('CSS classes generation works correctly', () => {
222
- const generateClasses = (disabled, readOnly, error, className) => {
223
- return [
224
- 'switch2',
225
- disabled && 'disabled',
226
- readOnly && 'readonly',
227
- error && 'error',
228
- className || ''
229
- ].filter(Boolean).join(' ')
230
- }
231
-
232
- expect(generateClasses(false, false, false, '')).toBe('switch2')
233
- expect(generateClasses(true, false, false, '')).toBe('switch2 disabled')
234
- expect(generateClasses(false, true, false, '')).toBe('switch2 readonly')
235
- expect(generateClasses(false, false, true, '')).toBe('switch2 error')
236
- expect(generateClasses(false, false, false, 'custom')).toBe('switch2 custom')
237
- expect(generateClasses(true, true, true, 'custom')).toBe('switch2 disabled readonly error custom')
238
- })
239
-
240
- test('toggle function works correctly', () => {
241
- const mockOnChange = jest.fn()
242
-
243
- // Simular el comportamiento del toggle
244
- const simulateToggle = (disabled, readOnly, checked, onChange, id) => {
245
- if (!disabled && !readOnly) {
246
- const nextValue = !checked
247
- if (onChange) {
248
- onChange(id || 'switch2', nextValue)
249
- }
250
- return nextValue
251
- }
252
- return checked
253
- }
254
-
255
- // Toggle normal
256
- const result1 = simulateToggle(false, false, false, mockOnChange, 'test')
257
- expect(result1).toBe(true)
258
- expect(mockOnChange).toHaveBeenCalledWith('test', true)
259
-
260
- mockOnChange.mockClear()
261
-
262
- // Toggle con disabled
263
- const result2 = simulateToggle(true, false, false, mockOnChange, 'test')
264
- expect(result2).toBe(false)
265
- expect(mockOnChange).not.toHaveBeenCalled()
266
-
267
- // Toggle con readOnly
268
- const result3 = simulateToggle(false, true, false, mockOnChange, 'test')
269
- expect(result3).toBe(false)
270
- expect(mockOnChange).not.toHaveBeenCalled()
271
- })
272
-
273
- test('keyboard event handling works correctly', () => {
274
- const mockToggle = jest.fn()
275
-
276
- // Simular el manejo de eventos de teclado
277
- const simulateKeyDown = (key, toggle) => {
278
- const event = {
279
- key,
280
- preventDefault: jest.fn()
281
- }
282
-
283
- if (event.key === ' ' || event.key === 'Enter') {
284
- event.preventDefault()
285
- toggle()
286
- }
287
-
288
- return event
289
- }
290
-
291
- // Space key
292
- const spaceEvent = simulateKeyDown(' ', mockToggle)
293
- expect(spaceEvent.preventDefault).toHaveBeenCalled()
294
- expect(mockToggle).toHaveBeenCalled()
295
-
296
- mockToggle.mockClear()
297
-
298
- // Enter key
299
- const enterEvent = simulateKeyDown('Enter', mockToggle)
300
- expect(enterEvent.preventDefault).toHaveBeenCalled()
301
- expect(mockToggle).toHaveBeenCalled()
302
-
303
- mockToggle.mockClear()
304
-
305
- // Other key (should not trigger)
306
- const otherEvent = simulateKeyDown('a', mockToggle)
307
- expect(otherEvent.preventDefault).not.toHaveBeenCalled()
308
- expect(mockToggle).not.toHaveBeenCalled()
309
- })
310
-
311
- test('container attributes generation works correctly', () => {
312
- const generateContainerAttributes = (checked, ariaLabel, label, required, error, id, disabled) => {
313
- return {
314
- role: 'switch',
315
- 'aria-checked': checked,
316
- 'aria-label': ariaLabel || label || 'Toggle switch',
317
- 'aria-required': required,
318
- 'aria-invalid': error,
319
- 'aria-describedby': error && typeof error === 'string' ? `${id}-error` : undefined,
320
- tabIndex: disabled ? -1 : 0
321
- }
322
- }
323
-
324
- const attrs = generateContainerAttributes(true, null, 'Test Label', false, false, 'test', false)
325
- expect(attrs.role).toBe('switch')
326
- expect(attrs['aria-checked']).toBe(true)
327
- expect(attrs['aria-label']).toBe('Test Label')
328
- expect(attrs.tabIndex).toBe(0)
329
-
330
- const disabledAttrs = generateContainerAttributes(false, null, null, false, false, 'test', true)
331
- expect(disabledAttrs.tabIndex).toBe(-1)
332
- })
333
-
334
- test('state synchronization works correctly', () => {
335
- // Simular la sincronización de estado con useEffect
336
- let internalState = false
337
-
338
- const syncState = (externalValue) => {
339
- internalState = externalValue
340
- }
341
-
342
- // Estado inicial
343
- syncState(false)
344
- expect(internalState).toBe(false)
345
-
346
- // Cambio externo
347
- syncState(true)
348
- expect(internalState).toBe(true)
349
-
350
- // Otro cambio
351
- syncState(false)
352
- expect(internalState).toBe(false)
353
- })
354
- })
355
- })