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.
Files changed (172) hide show
  1. package/dist/index.css +4941 -324
  2. package/dist/index.js +42339 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/index.modern.js +37459 -31678
  5. package/dist/index.modern.js.map +1 -1
  6. package/dist/index.umd.js +39635 -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 +255 -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
@@ -0,0 +1,239 @@
1
+ import React, { useState } from 'react'
2
+ import { Tabs, Tab } from './tab.js'
3
+
4
+ /**
5
+ * Tabs básicos
6
+ */
7
+ export const BasicTabs = () => {
8
+ const [selectedTab, setSelectedTab] = useState(0)
9
+
10
+ const handleTabChange = (index) => {
11
+ setSelectedTab(index)
12
+ console.log('Tab seleccionado:', index)
13
+ }
14
+
15
+ return (
16
+ <div style={{ padding: '20px' }}>
17
+ <h3>Tabs Básicos</h3>
18
+ <div style={{
19
+ background: '#fff',
20
+ padding: '1.5rem',
21
+ borderRadius: '8px',
22
+ border: '1px solid #ddd'
23
+ }}>
24
+ <Tabs selected={selectedTab} onChange={handleTabChange}>
25
+ <Tab label="Home" icon="home" />
26
+ <Tab label="Profile" icon="person" />
27
+ <Tab label="Settings" icon="settings" />
28
+ <Tab label="Help" icon="help" />
29
+ </Tabs>
30
+
31
+ <div style={{ marginTop: '1rem', padding: '1rem', background: '#f8f9fa', borderRadius: '4px' }}>
32
+ <strong>Contenido del Tab {selectedTab + 1}</strong>
33
+ <p>Este es el contenido para el tab seleccionado..</p>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ )
38
+ }
39
+
40
+ /**
41
+ * Tabs con badges
42
+ */
43
+ export const TabsWithBadges = () => {
44
+ const [selectedTab, setSelectedTab] = useState(0)
45
+
46
+ const handleTabChange = (index) => {
47
+ setSelectedTab(index)
48
+ }
49
+
50
+ return (
51
+ <div style={{ padding: '20px' }}>
52
+ <h3>Tabs con Badges</h3>
53
+ <div style={{
54
+ background: '#fff',
55
+ padding: '1.5rem',
56
+ borderRadius: '8px',
57
+ border: '1px solid #ddd'
58
+ }}>
59
+ <Tabs selected={selectedTab} onChange={handleTabChange}>
60
+ <Tab
61
+ label="Messages"
62
+ icon="mail"
63
+ badge={5}
64
+ badgeColor="#dc3545"
65
+ />
66
+ <Tab
67
+ label="Notifications"
68
+ icon="notifications"
69
+ badge={12}
70
+ badgeColor="#28a745"
71
+ />
72
+ <Tab
73
+ label="Tasks"
74
+ icon="assignment"
75
+ badge={3}
76
+ badgeColor="#ffc107"
77
+ />
78
+ <Tab
79
+ label="Archive"
80
+ icon="archive"
81
+ badge={0}
82
+ />
83
+ </Tabs>
84
+
85
+ <div style={{ marginTop: '1rem', padding: '1rem', background: '#f8f9fa', borderRadius: '4px' }}>
86
+ {selectedTab === 0 && <p>📧 Tienes 5 mensajes nuevos</p>}
87
+ {selectedTab === 1 && <p>🔔 Tienes 12 notificaciones pendientes</p>}
88
+ {selectedTab === 2 && <p>📋 Tienes 3 tareas asignadas</p>}
89
+ {selectedTab === 3 && <p>📦 Archivo vacío</p>}
90
+ </div>
91
+ </div>
92
+ </div>
93
+ )
94
+ }
95
+
96
+ /**
97
+ * Tabs verticales
98
+ */
99
+ export const VerticalTabs = () => {
100
+ const [selectedVerticalTab, setSelectedVerticalTab] = useState(0)
101
+
102
+ return (
103
+ <div style={{ padding: '20px' }}>
104
+ <h3>Tabs Verticales</h3>
105
+ <div style={{
106
+ background: '#fff',
107
+ padding: '1.5rem',
108
+ borderRadius: '8px',
109
+ border: '1px solid #ddd'
110
+ }}>
111
+ <Tabs
112
+ selected={selectedVerticalTab}
113
+ onChange={setSelectedVerticalTab}
114
+ orientation="vertical"
115
+ style={{ minHeight: '200px' }}
116
+ >
117
+ <Tab label="Dashboard" icon="dashboard" />
118
+ <Tab label="Analytics" icon="analytics" />
119
+ <Tab label="Reports" icon="assessment" />
120
+ <Tab label="Users" icon="people" />
121
+ </Tabs>
122
+ </div>
123
+ </div>
124
+ )
125
+ }
126
+
127
+ /**
128
+ * Tabs con cierre
129
+ */
130
+ export const ClosableTabs = () => {
131
+ const [closableTabs, setClosableTabs] = useState([
132
+ { id: 1, label: 'Document 1', icon: 'description' },
133
+ { id: 2, label: 'Document 2', icon: 'description' },
134
+ { id: 3, label: 'Document 3', icon: 'description' }
135
+ ])
136
+ const [selectedTab, setSelectedTab] = useState(0)
137
+
138
+ const handleTabClose = (index) => {
139
+ const newTabs = closableTabs.filter((_, i) => i !== index)
140
+ setClosableTabs(newTabs)
141
+ if (selectedTab >= newTabs.length) {
142
+ setSelectedTab(Math.max(0, newTabs.length - 1))
143
+ }
144
+ }
145
+
146
+ const addNewTab = () => {
147
+ const newId = Math.max(...closableTabs.map(t => t.id), 0) + 1
148
+ setClosableTabs([...closableTabs, {
149
+ id: newId,
150
+ label: `Document ${newId}`,
151
+ icon: 'description'
152
+ }])
153
+ }
154
+
155
+ return (
156
+ <div style={{ padding: '20px' }}>
157
+ <h3>Tabs con Cierre</h3>
158
+ <div style={{
159
+ background: '#fff',
160
+ padding: '1.5rem',
161
+ borderRadius: '8px',
162
+ border: '1px solid #ddd'
163
+ }}>
164
+ <Tabs selected={selectedTab} onChange={setSelectedTab}>
165
+ {closableTabs.map((tab, index) => (
166
+ <Tab
167
+ key={tab.id}
168
+ label={tab.label}
169
+ icon={tab.icon}
170
+ closable={true}
171
+ onClose={() => handleTabClose(index)}
172
+ />
173
+ ))}
174
+ <Tab
175
+ label="Add New"
176
+ icon="add"
177
+ onClick={addNewTab}
178
+ />
179
+ </Tabs>
180
+
181
+ <div style={{ marginTop: '1rem', padding: '1rem', background: '#f8f9fa', borderRadius: '4px' }}>
182
+ {closableTabs.length > 0 ? (
183
+ <p>Contenido de: <strong>{closableTabs[selectedTab]?.label}</strong></p>
184
+ ) : (
185
+ <p>No hay tabs abiertos. Haz clic en "Add New" para crear uno.</p>
186
+ )}
187
+ </div>
188
+ </div>
189
+ </div>
190
+ )
191
+ }
192
+
193
+ /**
194
+ * Tabs con estados especiales
195
+ */
196
+ export const SpecialStateTabs = () => {
197
+ const [selectedTab, setSelectedTab] = useState(0)
198
+
199
+ return (
200
+ <div style={{ padding: '20px' }}>
201
+ <h3>Estados Especiales</h3>
202
+ <div style={{
203
+ background: '#fff',
204
+ padding: '1.5rem',
205
+ borderRadius: '8px',
206
+ border: '1px solid #ddd'
207
+ }}>
208
+ <Tabs
209
+ selected={selectedTab}
210
+ onChange={setSelectedTab}
211
+ disabled={false}
212
+ >
213
+ <Tab label="Tab 1" icon="looks_one" />
214
+ <Tab label="Tab 2" icon="looks_two" />
215
+ <Tab label="Tab 3 (Protected)" icon="looks_3" disabled={true} />
216
+ <Tab label="Tab 4" icon="looks_4" />
217
+ </Tabs>
218
+
219
+ <div style={{ marginTop: '1rem', padding: '1rem', background: '#f8f9fa', borderRadius: '4px' }}>
220
+ <p>Tab seleccionado: <strong>{selectedTab + 1}</strong></p>
221
+ <p><em>El Tab 3 está deshabilitado</em></p>
222
+ </div>
223
+ </div>
224
+ </div>
225
+ )
226
+ }
227
+
228
+ /**
229
+ * Todos los ejemplos
230
+ */
231
+ export const AllExamples = () => (
232
+ <div>
233
+ <BasicTabs />
234
+ <TabsWithBadges />
235
+ <VerticalTabs />
236
+ <ClosableTabs />
237
+ <SpecialStateTabs />
238
+ </div>
239
+ )
@@ -0,0 +1,188 @@
1
+ import React, { useState } from 'react'
2
+ import { DataTable } from './table.js'
3
+ import { DataTable2 } from './table2.js'
4
+
5
+ export default {
6
+ title: 'HTML/Table',
7
+ component: DataTable,
8
+ parameters: {
9
+ docs: {
10
+ description: {
11
+ component: 'DataTable components for displaying tabular data with sorting, filtering, and selection capabilities.'
12
+ }
13
+ }
14
+ }
15
+ }
16
+
17
+ /**
18
+ * DataTable básico
19
+ */
20
+ export const BasicDataTable = () => {
21
+ const columns = [
22
+ { id: 'name', label: 'Nombre', sortable: true },
23
+ { id: 'email', label: 'Email', sortable: true },
24
+ { id: 'role', label: 'Rol', sortable: false },
25
+ { id: 'status', label: 'Estado', sortable: true }
26
+ ]
27
+
28
+ const rows = [
29
+ { id: 1, name: 'Juan Pérez', email: 'juan@example.com', role: 'Admin', status: 'Activo' },
30
+ { id: 2, name: 'María García', email: 'maria@example.com', role: 'Usuario', status: 'Activo' },
31
+ { id: 3, name: 'Carlos López', email: 'carlos@example.com', role: 'Editor', status: 'Inactivo' },
32
+ { id: 4, name: 'Ana Martín', email: 'ana@example.com', role: 'Usuario', status: 'Activo' }
33
+ ]
34
+
35
+ const handleRowSelection = (selectedRows) => {
36
+ console.log('Filas seleccionadas:', selectedRows)
37
+ }
38
+
39
+ const handleSort = (sortConfig) => {
40
+ console.log('Ordenar por:', sortConfig)
41
+ }
42
+
43
+ return (
44
+ <div style={{ padding: '20px' }}>
45
+ <h3>DataTable Básico</h3>
46
+ <DataTable
47
+ columns={columns}
48
+ rows={rows}
49
+ onRowSelection={handleRowSelection}
50
+ onSort={handleSort}
51
+ outlined={true}
52
+ emptyMessage="No hay datos disponibles"
53
+ emptyIcon="inbox"
54
+ />
55
+ </div>
56
+ )
57
+ }
58
+
59
+ /**
60
+ * DataTable con funciones avanzadas
61
+ */
62
+ export const AdvancedDataTable = () => {
63
+ const [selectedRows, setSelectedRows] = useState([])
64
+
65
+ const columns = [
66
+ { id: 'id', label: 'ID', sortable: true, width: '80px' },
67
+ { id: 'product', label: 'Producto', sortable: true },
68
+ { id: 'category', label: 'Categoría', sortable: true },
69
+ { id: 'price', label: 'Precio', sortable: true, align: 'right' },
70
+ { id: 'stock', label: 'Stock', sortable: true, align: 'center' },
71
+ { id: 'actions', label: 'Acciones', sortable: false, width: '120px' }
72
+ ]
73
+
74
+ const rows = [
75
+ {
76
+ id: 1,
77
+ product: 'Laptop HP',
78
+ category: 'Electrónicos',
79
+ price: '$899.99',
80
+ stock: 15,
81
+ info: 'Información adicional sobre este producto...',
82
+ actions: '🔧 ✏️ 🗑️'
83
+ },
84
+ {
85
+ id: 2,
86
+ product: 'Mouse Logitech',
87
+ category: 'Accesorios',
88
+ price: '$29.99',
89
+ stock: 50,
90
+ actions: '🔧 ✏️ 🗑️'
91
+ },
92
+ {
93
+ id: 3,
94
+ product: 'Teclado Mecánico',
95
+ category: 'Accesorios',
96
+ price: '$129.99',
97
+ stock: 0,
98
+ info: 'Producto agotado - próxima reposición en 2 semanas',
99
+ actions: '🔧 ✏️ 🗑️'
100
+ }
101
+ ]
102
+
103
+ return (
104
+ <div style={{ padding: '20px' }}>
105
+ <h3>DataTable Avanzado</h3>
106
+ <DataTable
107
+ columns={columns}
108
+ rows={rows}
109
+ onRowSelection={setSelectedRows}
110
+ onSort={(config) => console.log('Sort:', config)}
111
+ onCheckAll={(checked) => console.log('Check all:', checked)}
112
+ outlined={true}
113
+ expanded={true}
114
+ multisort={true}
115
+ filterable={true}
116
+ editable={true}
117
+ onClearFilters={() => console.log('Limpiar filtros')}
118
+ />
119
+ <p>Filas seleccionadas: {selectedRows.length}</p>
120
+ </div>
121
+ )
122
+ }
123
+
124
+ /**
125
+ * DataTable vacío
126
+ */
127
+ export const EmptyDataTable = () => {
128
+ const columns = [
129
+ { id: 'name', label: 'Nombre', sortable: true },
130
+ { id: 'email', label: 'Email', sortable: true },
131
+ { id: 'role', label: 'Rol', sortable: false }
132
+ ]
133
+
134
+ return (
135
+ <div style={{ padding: '20px' }}>
136
+ <h3>DataTable Vacío</h3>
137
+ <DataTable
138
+ columns={columns}
139
+ rows={[]}
140
+ outlined={true}
141
+ emptyMessage="No se encontraron resultados"
142
+ emptyIcon="search_off"
143
+ />
144
+ </div>
145
+ )
146
+ }
147
+
148
+ /**
149
+ * DataTable2 (versión alternativa)
150
+ */
151
+ export const DataTable2Example = () => {
152
+ const columns = [
153
+ { id: 'task', label: 'Tarea', sortable: true },
154
+ { id: 'assignee', label: 'Asignado a', sortable: true },
155
+ { id: 'priority', label: 'Prioridad', sortable: true },
156
+ { id: 'due', label: 'Vencimiento', sortable: true }
157
+ ]
158
+
159
+ const rows = [
160
+ { id: 1, task: 'Revisar código', assignee: 'Juan', priority: 'Alta', due: '2024-01-15' },
161
+ { id: 2, task: 'Actualizar documentación', assignee: 'María', priority: 'Media', due: '2024-01-20' },
162
+ { id: 3, task: 'Testing de funcionalidades', assignee: 'Carlos', priority: 'Alta', due: '2024-01-18' }
163
+ ]
164
+
165
+ return (
166
+ <div style={{ padding: '20px' }}>
167
+ <h3>DataTable2</h3>
168
+ <DataTable2
169
+ columns={columns}
170
+ rows={rows}
171
+ outlined={true}
172
+ onRowSelection={(rows) => console.log('DataTable2 selection:', rows)}
173
+ />
174
+ </div>
175
+ )
176
+ }
177
+
178
+ /**
179
+ * Todos los ejemplos
180
+ */
181
+ export const AllExamples = () => (
182
+ <div>
183
+ <BasicDataTable />
184
+ <AdvancedDataTable />
185
+ <EmptyDataTable />
186
+ <DataTable2Example />
187
+ </div>
188
+ )
@@ -0,0 +1,238 @@
1
+ import React, { useState } from 'react'
2
+ import { DataTable2 } from './table2'
3
+ import { Button } from './button'
4
+ import { Icon } from './icon'
5
+ import { ActionsCell } from './actions-cell'
6
+
7
+ export default {
8
+ title: 'HTML/Table2',
9
+ component: DataTable2,
10
+ parameters: {
11
+ docs: {
12
+ description: {
13
+ component: 'Enhanced DataTable component with advanced features like sorting, filtering, column management, and more.'
14
+ }
15
+ }
16
+ }
17
+ }
18
+
19
+ // Sample data
20
+ const sampleUsers = [
21
+ { id: 1, name: 'Ana García', email: 'ana@example.com', role: 'Admin', status: 'Active', lastLogin: '2024-01-15' },
22
+ { id: 2, name: 'Carlos López', email: 'carlos@example.com', role: 'User', status: 'Active', lastLogin: '2024-01-14' },
23
+ { id: 3, name: 'María Rodríguez', email: 'maria@example.com', role: 'Editor', status: 'Inactive', lastLogin: '2024-01-10' },
24
+ { id: 4, name: 'Juan Martínez', email: 'juan@example.com', role: 'User', status: 'Active', lastLogin: '2024-01-16' },
25
+ { id: 5, name: 'Laura Sánchez', email: 'laura@example.com', role: 'Admin', status: 'Active', lastLogin: '2024-01-15' }
26
+ ]
27
+
28
+ const basicColumns = [
29
+ { key: 'name', label: 'Nombre', sortable: true },
30
+ { key: 'email', label: 'Email', sortable: true },
31
+ { key: 'role', label: 'Rol', sortable: true },
32
+ { key: 'status', label: 'Estado', sortable: true },
33
+ { key: 'lastLogin', label: 'Último acceso', sortable: true }
34
+ ]
35
+
36
+ /**
37
+ * Basic DataTable2 example
38
+ */
39
+ export const BasicTable = () => (
40
+ <div style={{ padding: '20px' }}>
41
+ <h3>🗂️ DataTable2 Básica</h3>
42
+ <DataTable2
43
+ columns={basicColumns}
44
+ rows={sampleUsers}
45
+ striped={true}
46
+ hover={true}
47
+ />
48
+ </div>
49
+ )
50
+
51
+ /**
52
+ * Table with actions
53
+ */
54
+ export const TableWithActions = () => {
55
+ const columnsWithActions = [
56
+ ...basicColumns,
57
+ {
58
+ key: 'actions',
59
+ label: 'Acciones',
60
+ render: (row) => (
61
+ <div style={{ display: 'flex', gap: '8px' }}>
62
+ <Icon
63
+ icon="edit"
64
+ size="small"
65
+ clickable
66
+ action={() => alert(`Editar ${row.name}`)}
67
+ title="Editar"
68
+ />
69
+ <Icon
70
+ icon="delete"
71
+ size="small"
72
+ clickable
73
+ action={() => alert(`Eliminar ${row.name}`)}
74
+ title="Eliminar"
75
+ />
76
+ </div>
77
+ )
78
+ }
79
+ ]
80
+
81
+ return (
82
+ <div style={{ padding: '20px' }}>
83
+ <h3>⚡ Tabla con Acciones</h3>
84
+ <DataTable2
85
+ columns={columnsWithActions}
86
+ rows={sampleUsers}
87
+ striped={true}
88
+ hover={true}
89
+ density="comfortable"
90
+ />
91
+ </div>
92
+ )
93
+ }
94
+
95
+ /**
96
+ * Table with advanced features
97
+ */
98
+ export const AdvancedTable = () => {
99
+ const [selectedRows, setSelectedRows] = useState([])
100
+
101
+ const advancedColumns = [
102
+ ...basicColumns,
103
+ {
104
+ key: 'actions',
105
+ label: 'Acciones',
106
+ render: (row) => (
107
+ <ActionsCell
108
+ actions={
109
+ <div style={{ display: 'flex', gap: '4px' }}>
110
+ <Icon icon="visibility" size="small" clickable action={() => alert('Ver')} title="Ver" />
111
+ <Icon icon="edit" size="small" clickable action={() => alert('Editar')} title="Editar" />
112
+ <Icon icon="share" size="small" clickable action={() => alert('Compartir')} title="Compartir" />
113
+ <Icon icon="delete" size="small" clickable action={() => alert('Eliminar')} title="Eliminar" />
114
+ </div>
115
+ }
116
+ maxWidth={120}
117
+ menuAlign="left"
118
+ />
119
+ )
120
+ }
121
+ ]
122
+
123
+ return (
124
+ <div style={{ padding: '20px' }}>
125
+ <h3>🚀 Tabla Avanzada</h3>
126
+ <p>Con selección múltiple, filtros y panel lateral</p>
127
+
128
+ <DataTable2
129
+ columns={advancedColumns}
130
+ rows={sampleUsers}
131
+ selectable={true}
132
+ selectedRows={selectedRows}
133
+ onSelectionChange={setSelectedRows}
134
+ searchable={true}
135
+ filterable={true}
136
+ exportable={true}
137
+ showPanel={true}
138
+ striped={true}
139
+ hover={true}
140
+ density="compact"
141
+ />
142
+
143
+ {selectedRows.length > 0 && (
144
+ <div style={{
145
+ marginTop: '16px',
146
+ padding: '12px',
147
+ background: '#e3f2fd',
148
+ borderRadius: '4px',
149
+ border: '1px solid #1976d2'
150
+ }}>
151
+ <strong>Filas seleccionadas:</strong> {selectedRows.length}
152
+ </div>
153
+ )}
154
+ </div>
155
+ )
156
+ }
157
+
158
+ /**
159
+ * Different density options
160
+ */
161
+ export const DensityOptions = () => (
162
+ <div style={{ padding: '20px' }}>
163
+ <h3>📏 Opciones de Densidad</h3>
164
+
165
+ <div style={{ marginBottom: '2rem' }}>
166
+ <h4>Compact</h4>
167
+ <DataTable2
168
+ columns={basicColumns.slice(0, 3)}
169
+ rows={sampleUsers.slice(0, 3)}
170
+ density="compact"
171
+ striped={true}
172
+ />
173
+ </div>
174
+
175
+ <div style={{ marginBottom: '2rem' }}>
176
+ <h4>Comfortable (Default)</h4>
177
+ <DataTable2
178
+ columns={basicColumns.slice(0, 3)}
179
+ rows={sampleUsers.slice(0, 3)}
180
+ density="comfortable"
181
+ striped={true}
182
+ />
183
+ </div>
184
+
185
+ <div>
186
+ <h4>Spacious</h4>
187
+ <DataTable2
188
+ columns={basicColumns.slice(0, 3)}
189
+ rows={sampleUsers.slice(0, 3)}
190
+ density="spacious"
191
+ striped={true}
192
+ />
193
+ </div>
194
+ </div>
195
+ )
196
+
197
+ /**
198
+ * Empty state
199
+ */
200
+ export const EmptyTable = () => (
201
+ <div style={{ padding: '20px' }}>
202
+ <h3>📭 Estado Vacío</h3>
203
+ <DataTable2
204
+ columns={basicColumns}
205
+ rows={[]}
206
+ emptyMessage="No hay usuarios para mostrar"
207
+ emptyIcon="people"
208
+ />
209
+ </div>
210
+ )
211
+
212
+ /**
213
+ * Loading state
214
+ */
215
+ export const LoadingTable = () => (
216
+ <div style={{ padding: '20px' }}>
217
+ <h3>⏳ Estado de Carga</h3>
218
+ <DataTable2
219
+ columns={basicColumns}
220
+ rows={sampleUsers}
221
+ loading={true}
222
+ />
223
+ </div>
224
+ )
225
+
226
+ /**
227
+ * All examples combined
228
+ */
229
+ export const AllExamples = () => (
230
+ <div>
231
+ <BasicTable />
232
+ <TableWithActions />
233
+ <AdvancedTable />
234
+ <DensityOptions />
235
+ <EmptyTable />
236
+ <LoadingTable />
237
+ </div>
238
+ )