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,369 +0,0 @@
1
- import React from 'react'
2
- import { Form } from './form'
3
-
4
- // Pruebas unitarias para el componente Form
5
- describe('Form Component', () => {
6
- // Mock de los componentes dependientes
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
- jest.spyOn(console, 'error').mockImplementation(() => {})
20
- })
21
-
22
- afterEach(() => {
23
- console.warn.mockRestore()
24
- console.error.mockRestore()
25
- })
26
-
27
- test('component exports correctly', () => {
28
- expect(Form).toBeDefined()
29
- expect(typeof Form).toBe('function')
30
- })
31
-
32
- test('component has correct PropTypes', () => {
33
- expect(Form.propTypes).toBeDefined()
34
- expect(Form.propTypes.id).toBeDefined()
35
- expect(Form.propTypes.title).toBeDefined()
36
- expect(Form.propTypes.columns).toBeDefined()
37
- expect(Form.propTypes.children).toBeDefined()
38
- expect(Form.propTypes.outlined).toBeDefined()
39
- expect(Form.propTypes.disabled).toBeDefined()
40
- expect(Form.propTypes.loading).toBeDefined()
41
- expect(Form.propTypes.autoComplete).toBeDefined()
42
- expect(Form.propTypes.noValidate).toBeDefined()
43
- expect(Form.propTypes.className).toBeDefined()
44
- expect(Form.propTypes.onChange).toBeDefined()
45
- expect(Form.propTypes.onSubmit).toBeDefined()
46
- expect(Form.propTypes.onReset).toBeDefined()
47
- expect(Form.propTypes.onValidationChange).toBeDefined()
48
- })
49
-
50
- test('component has correct defaultProps', () => {
51
- expect(Form.defaultProps).toBeDefined()
52
- expect(Form.defaultProps.columns).toBe(1)
53
- expect(Form.defaultProps.outlined).toBe(false)
54
- expect(Form.defaultProps.disabled).toBe(false)
55
- expect(Form.defaultProps.loading).toBe(false)
56
- expect(Form.defaultProps.autoComplete).toBe('on')
57
- expect(Form.defaultProps.noValidate).toBe(false)
58
- expect(Form.defaultProps.className).toBe('')
59
- })
60
-
61
- test('warns when children prop is missing', () => {
62
- const validateChildren = (children) => {
63
- if (!children) {
64
- console.warn('Form component: children prop is required')
65
- }
66
- }
67
-
68
- validateChildren(null)
69
- expect(console.warn).toHaveBeenCalledWith('Form component: children prop is required')
70
-
71
- console.warn.mockClear()
72
- validateChildren('some children')
73
- expect(console.warn).not.toHaveBeenCalled()
74
- })
75
-
76
- test('isEmpty function works correctly', () => {
77
- const isEmpty = (value) => value === void 0 || value === null || value === ''
78
-
79
- expect(isEmpty(undefined)).toBe(true)
80
- expect(isEmpty(null)).toBe(true)
81
- expect(isEmpty('')).toBe(true)
82
- expect(isEmpty('text')).toBe(false)
83
- expect(isEmpty(0)).toBe(false)
84
- expect(isEmpty(false)).toBe(false)
85
- expect(isEmpty([])).toBe(false)
86
- expect(isEmpty({})).toBe(false)
87
- })
88
-
89
- test('field initialization works correctly', () => {
90
- const mockChildren = [
91
- { props: { id: 'field1', value: 'test', required: true } },
92
- { props: { id: 'field2', value: '', required: false } },
93
- { props: { id: 'field3', value: 'valid', required: true, validation: (v) => v.length > 3 } },
94
- { props: {} }, // No id, should be filtered out
95
- null // Null child, should be filtered out
96
- ]
97
-
98
- const initFields = mockChildren
99
- .filter(child => child !== null && child !== '')
100
- .map(child => {
101
- if (!child.props) return null
102
- const { id, value, required = false, validation } = child.props
103
- if (!id) return null
104
-
105
- const isEmpty = (value) => value === void 0 || value === null || value === ''
106
- const valid = required ?
107
- validation ? validation(value) : !isEmpty(value) :
108
- true
109
- return { id, value, required, validation, valid }
110
- })
111
- .filter(field => field !== null)
112
-
113
- expect(initFields).toHaveLength(3)
114
- expect(initFields[0]).toEqual({ id: 'field1', value: 'test', required: true, validation: undefined, valid: true })
115
- expect(initFields[1]).toEqual({ id: 'field2', value: '', required: false, validation: undefined, valid: true })
116
- expect(initFields[2]).toEqual({ id: 'field3', value: 'valid', required: true, validation: expect.any(Function), valid: true })
117
- })
118
-
119
- test('field change logic works correctly', () => {
120
- const fields = [
121
- { id: 'field1', value: 'test', required: true, validation: undefined, valid: true },
122
- { id: 'field2', value: '', required: false, validation: undefined, valid: true }
123
- ]
124
-
125
- const changeField = (fields, id, value) => {
126
- const isEmpty = (value) => value === void 0 || value === null || value === ''
127
-
128
- return fields.map(field => {
129
- if (field.id === id) {
130
- const valid = field.required ?
131
- field.validation ? field.validation(value) : !isEmpty(value) :
132
- true
133
- return { ...field, value, valid }
134
- }
135
- return field
136
- })
137
- }
138
-
139
- // Change field1 to empty (should be invalid because required)
140
- const result1 = changeField(fields, 'field1', '')
141
- expect(result1[0].value).toBe('')
142
- expect(result1[0].valid).toBe(false)
143
-
144
- // Change field2 to empty (should be valid because not required)
145
- const result2 = changeField(fields, 'field2', '')
146
- expect(result2[1].value).toBe('')
147
- expect(result2[1].valid).toBe(true)
148
-
149
- // Change field1 to valid value
150
- const result3 = changeField(fields, 'field1', 'new value')
151
- expect(result3[0].value).toBe('new value')
152
- expect(result3[0].valid).toBe(true)
153
- })
154
-
155
- test('form data generation works correctly', () => {
156
- const fields = [
157
- { id: 'field1', value: 'test', required: true, valid: true },
158
- { id: 'field2', value: '', required: false, valid: true },
159
- { id: 'field3', value: null, required: false, valid: true },
160
- { id: 'field4', value: undefined, required: false, valid: true },
161
- { id: 'field5', value: 0, required: false, valid: true },
162
- { id: 'field6', value: false, required: false, valid: true }
163
- ]
164
-
165
- const formData = fields.reduce((data, { id, value }) => {
166
- if (value !== undefined && value !== null) {
167
- data[id] = value
168
- }
169
- return data
170
- }, {})
171
-
172
- expect(formData).toEqual({
173
- field1: 'test',
174
- field2: '',
175
- field5: 0,
176
- field6: false
177
- })
178
- })
179
-
180
- test('form validation works correctly', () => {
181
- const fields1 = [
182
- { id: 'field1', value: 'test', required: true, valid: true },
183
- { id: 'field2', value: '', required: false, valid: true }
184
- ]
185
-
186
- const fields2 = [
187
- { id: 'field1', value: 'test', required: true, valid: true },
188
- { id: 'field2', value: '', required: true, valid: false }
189
- ]
190
-
191
- const isFormValid = (fields) => fields.every(({ valid }) => valid === true)
192
-
193
- expect(isFormValid(fields1)).toBe(true)
194
- expect(isFormValid(fields2)).toBe(false)
195
- })
196
-
197
- test('CSS classes generation works correctly', () => {
198
- const generateClasses = (disabled, loading, className) => {
199
- return [
200
- 'form-grid',
201
- disabled && 'disabled',
202
- loading && 'loading',
203
- className || ''
204
- ].filter(Boolean).join(' ')
205
- }
206
-
207
- expect(generateClasses(false, false, '')).toBe('form-grid')
208
- expect(generateClasses(true, false, '')).toBe('form-grid disabled')
209
- expect(generateClasses(false, true, '')).toBe('form-grid loading')
210
- expect(generateClasses(true, true, '')).toBe('form-grid disabled loading')
211
- expect(generateClasses(false, false, 'custom')).toBe('form-grid custom')
212
- })
213
-
214
- test('grid layout generation works correctly', () => {
215
- const generateGridLayout = (columns) => {
216
- return {
217
- gridTemplateColumns: `repeat(${columns}, 1fr)`,
218
- gridAutoRows: 'auto'
219
- }
220
- }
221
-
222
- expect(generateGridLayout(1)).toEqual({
223
- gridTemplateColumns: 'repeat(1, 1fr)',
224
- gridAutoRows: 'auto'
225
- })
226
-
227
- expect(generateGridLayout(3)).toEqual({
228
- gridTemplateColumns: 'repeat(3, 1fr)',
229
- gridAutoRows: 'auto'
230
- })
231
- })
232
-
233
- test('accessibility attributes generation works correctly', () => {
234
- const generateAriaAttributes = (loading, isSubmitting, disabled, noValidate, autoComplete) => {
235
- return {
236
- 'aria-busy': loading || isSubmitting,
237
- 'aria-disabled': disabled,
238
- noValidate: noValidate,
239
- autoComplete: autoComplete
240
- }
241
- }
242
-
243
- const basic = generateAriaAttributes(false, false, false, false, 'on')
244
- expect(basic['aria-busy']).toBe(false)
245
- expect(basic['aria-disabled']).toBe(false)
246
- expect(basic.noValidate).toBe(false)
247
- expect(basic.autoComplete).toBe('on')
248
-
249
- const loading = generateAriaAttributes(true, false, false, false, 'on')
250
- expect(loading['aria-busy']).toBe(true)
251
-
252
- const submitting = generateAriaAttributes(false, true, false, false, 'on')
253
- expect(submitting['aria-busy']).toBe(true)
254
-
255
- const disabled = generateAriaAttributes(false, false, true, false, 'on')
256
- expect(disabled['aria-disabled']).toBe(true)
257
-
258
- const noValidate = generateAriaAttributes(false, false, false, true, 'off')
259
- expect(noValidate.noValidate).toBe(true)
260
- expect(noValidate.autoComplete).toBe('off')
261
- })
262
-
263
- test('form submission logic works correctly', async () => {
264
- const mockOnSubmit = jest.fn().mockResolvedValue()
265
-
266
- const simulateSubmit = async (disabled, loading, isSubmitting, fields, noValidate, onSubmit) => {
267
- const event = {
268
- preventDefault: jest.fn(),
269
- stopPropagation: jest.fn()
270
- }
271
-
272
- event.preventDefault()
273
- event.stopPropagation()
274
-
275
- if (disabled || loading || isSubmitting) return false
276
-
277
- const valid = fields.every(({ valid }) => valid === true)
278
- if (!valid && !noValidate) return false
279
-
280
- const formData = fields.reduce((data, { id, value }) => {
281
- if (value !== undefined && value !== null) {
282
- data[id] = value
283
- }
284
- return data
285
- }, {})
286
-
287
- if (onSubmit) {
288
- await onSubmit(formData, event)
289
- }
290
-
291
- return true
292
- }
293
-
294
- const validFields = [
295
- { id: 'field1', value: 'test', valid: true }
296
- ]
297
-
298
- const invalidFields = [
299
- { id: 'field1', value: '', valid: false }
300
- ]
301
-
302
- // Valid form submission
303
- const result1 = await simulateSubmit(false, false, false, validFields, false, mockOnSubmit)
304
- expect(result1).toBe(true)
305
- expect(mockOnSubmit).toHaveBeenCalledWith({ field1: 'test' }, expect.any(Object))
306
-
307
- mockOnSubmit.mockClear()
308
-
309
- // Invalid form submission (should not submit)
310
- const result2 = await simulateSubmit(false, false, false, invalidFields, false, mockOnSubmit)
311
- expect(result2).toBe(false)
312
- expect(mockOnSubmit).not.toHaveBeenCalled()
313
-
314
- // Invalid form submission with noValidate (should submit)
315
- const result3 = await simulateSubmit(false, false, false, invalidFields, true, mockOnSubmit)
316
- expect(result3).toBe(true)
317
- expect(mockOnSubmit).toHaveBeenCalled()
318
-
319
- mockOnSubmit.mockClear()
320
-
321
- // Disabled form (should not submit)
322
- const result4 = await simulateSubmit(true, false, false, validFields, false, mockOnSubmit)
323
- expect(result4).toBe(false)
324
- expect(mockOnSubmit).not.toHaveBeenCalled()
325
- })
326
-
327
- test('form reset logic works correctly', () => {
328
- const fields = [
329
- { id: 'field1', value: 'test', required: true, valid: true },
330
- { id: 'field2', value: 'data', required: false, valid: true }
331
- ]
332
-
333
- const resetFields = (fields) => {
334
- return fields.map(field => ({
335
- ...field,
336
- value: '',
337
- valid: !field.required
338
- }))
339
- }
340
-
341
- const result = resetFields(fields)
342
- expect(result[0]).toEqual({ id: 'field1', value: '', required: true, valid: false })
343
- expect(result[1]).toEqual({ id: 'field2', value: '', required: false, valid: true })
344
- })
345
-
346
- test('child enhancement works correctly', () => {
347
- const enhanceChild = (child, changeField, outlined, disabled, field) => {
348
- const enhancedProps = {
349
- onChange: changeField,
350
- outlined: outlined,
351
- disabled: disabled || child.props.disabled,
352
- error: field && !field.valid ? (field.required ? 'This field is required' : false) : child.props.error
353
- }
354
- return enhancedProps
355
- }
356
-
357
- const mockChild = { props: { disabled: false, error: false } }
358
- const mockField = { valid: false, required: true }
359
-
360
- const result = enhanceChild(mockChild, () => {}, true, false, mockField)
361
- expect(result.outlined).toBe(true)
362
- expect(result.disabled).toBe(false)
363
- expect(result.error).toBe('This field is required')
364
-
365
- const validField = { valid: true, required: true }
366
- const result2 = enhanceChild(mockChild, () => {}, false, false, validField)
367
- expect(result2.error).toBe(false)
368
- })
369
- })