ywana-core8 0.1.83 → 0.1.85
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/__previewjs__/Wrapper.tsx +8 -5
- package/build-doc.sh +10 -0
- package/dist/index.cjs +627 -194
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +353 -105
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +628 -196
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +629 -196
- package/dist/index.umd.js.map +1 -1
- package/doc/README.md +196 -0
- package/doc/craco.config.js +31 -0
- package/doc/generate-examples.cjs +310 -0
- package/doc/package-lock.json +17298 -0
- package/doc/package.json +33 -0
- package/doc/public/index.html +22 -0
- package/doc/src/App.css +171 -0
- package/doc/src/App.js +214 -0
- package/doc/src/components/ExamplePage.js +104 -0
- package/doc/src/components/WelcomePage.js +84 -0
- package/doc/src/examples/button.example.js +47 -0
- package/doc/src/examples/input.example.js +91 -0
- package/doc/src/index.css +237 -0
- package/doc/src/index.js +11 -0
- package/package.json +9 -2
- package/preview.config.js +38 -0
- package/src/html/accordion.example.js +2 -2
- package/src/html/actions-cell.css +108 -0
- package/src/html/actions-cell.example.js +587 -0
- package/src/html/actions-cell.js +260 -0
- package/src/html/checkbox.example.js +2 -2
- package/src/html/chip.example.js +2 -2
- package/src/html/color.example.js +2 -2
- package/src/html/form.example.js +2 -2
- package/src/html/header2.example.js +2 -2
- package/src/html/index.js +1 -0
- package/src/html/menu.css +9 -2
- package/src/html/menu.js +14 -2
- package/src/html/progress.example.js +2 -2
- package/src/html/property.example.js +2 -2
- package/src/html/radio.example.js +2 -2
- package/src/html/switch.example.js +2 -2
- package/src/html/tab.example.js +2 -2
- package/src/html/table.css +47 -1
- package/src/html/table.example.js +1012 -0
- package/src/html/table.js +12 -7
- package/src/html/table2-actions-test.js +138 -0
- package/src/html/table2.css +40 -3
- package/src/html/table2.example.js +330 -0
- package/src/html/table2.js +56 -13
- package/src/html/textfield.css +17 -4
- package/src/html/tokenfield.example.js +2 -2
- package/src/html/tree.css +42 -7
- package/src/html/tree.example.js +169 -7
- package/src/html/tree.js +216 -93
- package/src/widgets/calendar/Calendar.js +1 -1
- /package/{ACCORDION_EVALUATION.md → doc/evalulations/ACCORDION_EVALUATION.md} +0 -0
- /package/{CHECKBOX_EVALUATION.md → doc/evalulations/CHECKBOX_EVALUATION.md} +0 -0
- /package/{CHIP_EVALUATION.md → doc/evalulations/CHIP_EVALUATION.md} +0 -0
- /package/{COLOR_EVALUATION.md → doc/evalulations/COLOR_EVALUATION.md} +0 -0
- /package/{COMPONENTS_EVALUATION.md → doc/evalulations/COMPONENTS_EVALUATION.md} +0 -0
- /package/{FORM_EVALUATION.md → doc/evalulations/FORM_EVALUATION.md} +0 -0
- /package/{HEADER_EVALUATION.md → doc/evalulations/HEADER_EVALUATION.md} +0 -0
- /package/{ICON_EVALUATION.md → doc/evalulations/ICON_EVALUATION.md} +0 -0
- /package/{LIST_EVALUATION.md → doc/evalulations/LIST_EVALUATION.md} +0 -0
- /package/{PROGRESS_EVALUATION.md → doc/evalulations/PROGRESS_EVALUATION.md} +0 -0
- /package/{RADIO_EVALUATION.md → doc/evalulations/RADIO_EVALUATION.md} +0 -0
- /package/{RADIO_VISUAL_FIX.md → doc/evalulations/RADIO_VISUAL_FIX.md} +0 -0
- /package/{SECTION_IMPROVEMENTS.md → doc/evalulations/SECTION_IMPROVEMENTS.md} +0 -0
- /package/{SWITCH_EVALUATION.md → doc/evalulations/SWITCH_EVALUATION.md} +0 -0
- /package/{SWITCH_VISUAL_FIX.md → doc/evalulations/SWITCH_VISUAL_FIX.md} +0 -0
- /package/{TAB_EVALUATION.md → doc/evalulations/TAB_EVALUATION.md} +0 -0
- /package/{TEXTFIELD_EVALUATION.md → doc/evalulations/TEXTFIELD_EVALUATION.md} +0 -0
- /package/{TOOLTIP_FIX.md → doc/evalulations/TOOLTIP_FIX.md} +0 -0
- /package/{TREE_EVALUATION.md → doc/evalulations/TREE_EVALUATION.md} +0 -0
- /package/src/incubator/{PDFViewer.js → pdfViewer.js} +0 -0
package/src/html/table.js
CHANGED
@@ -19,6 +19,9 @@ export const DataTable = (props) => {
|
|
19
19
|
const [sortDir, setSortDir] = useState({})
|
20
20
|
const [allChecked, setAllChecked] = useState(false)
|
21
21
|
|
22
|
+
// Detectar si alguna fila tiene info para mostrar la columna de expansión
|
23
|
+
const hasInfoRows = rows.some(row => row.info)
|
24
|
+
|
22
25
|
function changeSort(id) {
|
23
26
|
if (multisort) {
|
24
27
|
const nextDir = sortDir[id] ? sortDir[id] * -1 : 1
|
@@ -94,16 +97,18 @@ export const DataTable = (props) => {
|
|
94
97
|
const resizableStyle = resizable ? "resizable-column" : ""
|
95
98
|
const sort = sortDir[id] ? sortDir[id] : null
|
96
99
|
const [rowspan, colspan] = type === TYPES.ENTITY ? [1, Object.values(item).filter(v => v.column === true).length] : [2, 1]
|
100
|
+
const headerClasses = `${resizableStyle} ${id}`.trim()
|
97
101
|
return (
|
98
|
-
<th key={id} className={
|
102
|
+
<th key={id} className={headerClasses} rowSpan={rowspan} colSpan={colspan}>
|
99
103
|
<div>
|
100
|
-
{id === "checked" && onCheckAll ? <CheckBox onChange={checkAll} value={allChecked} /> :
|
104
|
+
{id === "checked" && onCheckAll ? <CheckBox onChange={checkAll} value={allChecked} /> :
|
105
|
+
id === "actions" ? null : <Text key={`th_${id}`}>{label}</Text>}
|
101
106
|
{sortable ? <SortIcon sortDir={sortDir[id]} onChange={() => changeSort(id)} /> : null}
|
102
107
|
</div>
|
103
108
|
</th>
|
104
109
|
)
|
105
110
|
})}
|
106
|
-
<th rowSpan={2} colSpan={1}></th>
|
111
|
+
{hasInfoRows ? <th rowSpan={2} colSpan={1} style={{ width: '3rem' }}></th> : null}
|
107
112
|
</tr>
|
108
113
|
<tr>
|
109
114
|
{
|
@@ -125,7 +130,7 @@ export const DataTable = (props) => {
|
|
125
130
|
|
126
131
|
{rows.length > 0 ?
|
127
132
|
multiSort(rows, sortDir).map((row, index) => (
|
128
|
-
<DataTableRow key={row.id} index={index} row={row} columns={columns} onSelect={select} onDrop={moveRow} editable={editable} expanded={expanded} />
|
133
|
+
<DataTableRow key={row.id} index={index} row={row} columns={columns} onSelect={select} onDrop={moveRow} editable={editable} expanded={expanded} hasInfoRows={hasInfoRows} />
|
129
134
|
)) : (
|
130
135
|
<tr>
|
131
136
|
<td colSpan={1000}>
|
@@ -185,7 +190,7 @@ const DataTableFiltersRow = ({ columns, onClear }) => {
|
|
185
190
|
* DataTable Row
|
186
191
|
*/
|
187
192
|
const DataTableRow = (props) => {
|
188
|
-
const { index, row, columns = [], onSelect, editable, expanded = false } = props
|
193
|
+
const { index, row, columns = [], onSelect, editable, expanded = false, hasInfoRows = false } = props
|
189
194
|
const { selected = false, className } = row
|
190
195
|
const [isInfoOpen, toggleInfo] = useState(expanded)
|
191
196
|
const infoIcon = isInfoOpen ? 'expand_less' : 'expand_more'
|
@@ -195,11 +200,11 @@ const DataTableRow = (props) => {
|
|
195
200
|
<Fragment>
|
196
201
|
<tr className={`${style} ${className}`} onClick={ev => onSelect(row, ev)}>
|
197
202
|
{columns.map((column, cindex) => <DataTableCell key={`${column.id}_${cindex}`} index={index} row={row} column={column} cell={row[column.id]} editable={editable || column.editable} />)}
|
198
|
-
{row.info ? <td><Icon icon={infoIcon} clickable action={() => toggleInfo(!isInfoOpen)} /></td> : <td></td>}
|
203
|
+
{hasInfoRows ? (row.info ? <td><Icon icon={infoIcon} clickable action={() => toggleInfo(!isInfoOpen)} /></td> : <td></td>) : null}
|
199
204
|
</tr>
|
200
205
|
{row.info && isInfoOpen ? (
|
201
206
|
<tr className="table-row-info">
|
202
|
-
<td colSpan={columns.length + 1}>
|
207
|
+
<td colSpan={columns.length + (hasInfoRows ? 1 : 0)}>
|
203
208
|
{isFunction(row.info) ? row.info() : row.info}
|
204
209
|
</td>
|
205
210
|
</tr>
|
@@ -0,0 +1,138 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { DataTable2 } from './table2'
|
3
|
+
import { Button } from './button'
|
4
|
+
import { Icon } from './icon'
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Componente de prueba para la nueva funcionalidad de columnas de acciones
|
8
|
+
*/
|
9
|
+
export const ActionsColumnTest = () => {
|
10
|
+
// Datos de ejemplo con acciones
|
11
|
+
const columns = [
|
12
|
+
{ id: 'id', label: 'ID', width: 60 },
|
13
|
+
{ id: 'name', label: 'Nombre', sortable: true },
|
14
|
+
{ id: 'email', label: 'Email', sortable: true },
|
15
|
+
{ id: 'status', label: 'Estado', filterable: true },
|
16
|
+
{ id: 'actions', label: 'Acciones' } // ← Columna de acciones
|
17
|
+
]
|
18
|
+
|
19
|
+
const rows = [
|
20
|
+
{
|
21
|
+
id: 1,
|
22
|
+
name: 'Juan Pérez',
|
23
|
+
email: 'juan@example.com',
|
24
|
+
status: 'active',
|
25
|
+
actions: [
|
26
|
+
<Button
|
27
|
+
key="edit"
|
28
|
+
label="Editar"
|
29
|
+
size="small"
|
30
|
+
variant="primary"
|
31
|
+
action={() => alert('Editar Juan')}
|
32
|
+
/>,
|
33
|
+
<Button
|
34
|
+
key="delete"
|
35
|
+
label="Eliminar"
|
36
|
+
size="small"
|
37
|
+
variant="danger"
|
38
|
+
action={() => alert('Eliminar Juan')}
|
39
|
+
/>
|
40
|
+
]
|
41
|
+
},
|
42
|
+
{
|
43
|
+
id: 2,
|
44
|
+
name: 'María García',
|
45
|
+
email: 'maria@example.com',
|
46
|
+
status: 'pending',
|
47
|
+
actions: [
|
48
|
+
<Icon
|
49
|
+
key="approve"
|
50
|
+
icon="check_circle"
|
51
|
+
size="small"
|
52
|
+
clickable
|
53
|
+
action={() => alert('Aprobar María')}
|
54
|
+
title="Aprobar"
|
55
|
+
/>,
|
56
|
+
<Icon
|
57
|
+
key="reject"
|
58
|
+
icon="cancel"
|
59
|
+
size="small"
|
60
|
+
clickable
|
61
|
+
action={() => alert('Rechazar María')}
|
62
|
+
title="Rechazar"
|
63
|
+
/>
|
64
|
+
]
|
65
|
+
},
|
66
|
+
{
|
67
|
+
id: 3,
|
68
|
+
name: 'Carlos López',
|
69
|
+
email: 'carlos@example.com',
|
70
|
+
status: 'inactive',
|
71
|
+
actions: [
|
72
|
+
<Button
|
73
|
+
key="activate"
|
74
|
+
label="Activar"
|
75
|
+
size="small"
|
76
|
+
variant="success"
|
77
|
+
action={() => alert('Activar Carlos')}
|
78
|
+
/>
|
79
|
+
]
|
80
|
+
}
|
81
|
+
]
|
82
|
+
|
83
|
+
return (
|
84
|
+
<div style={{ padding: '2rem' }}>
|
85
|
+
<h1>Prueba de Columnas de Acciones</h1>
|
86
|
+
<p>Esta tabla demuestra la nueva funcionalidad de columnas de acciones con componentes React.</p>
|
87
|
+
|
88
|
+
<div style={{
|
89
|
+
background: '#fff',
|
90
|
+
padding: '1rem',
|
91
|
+
border: '1px solid #ddd',
|
92
|
+
borderRadius: '8px',
|
93
|
+
marginBottom: '2rem'
|
94
|
+
}}>
|
95
|
+
<h2>Ejemplo 1: Botones e Iconos Mixtos</h2>
|
96
|
+
<DataTable2
|
97
|
+
id="actions-test-1"
|
98
|
+
columns={columns}
|
99
|
+
rows={rows}
|
100
|
+
density="normal"
|
101
|
+
striped={true}
|
102
|
+
resizable={true}
|
103
|
+
/>
|
104
|
+
</div>
|
105
|
+
|
106
|
+
<div style={{
|
107
|
+
background: '#fff',
|
108
|
+
padding: '1rem',
|
109
|
+
border: '1px solid #ddd',
|
110
|
+
borderRadius: '8px'
|
111
|
+
}}>
|
112
|
+
<h2>Ejemplo 2: Solo Iconos (Compacto)</h2>
|
113
|
+
<DataTable2
|
114
|
+
id="actions-test-2"
|
115
|
+
columns={[
|
116
|
+
{ id: 'id', label: 'ID', width: 60 },
|
117
|
+
{ id: 'name', label: 'Nombre', sortable: true },
|
118
|
+
{ id: 'email', label: 'Email', sortable: true },
|
119
|
+
{ id: 'actions' } // Sin label
|
120
|
+
]}
|
121
|
+
rows={rows.map(row => ({
|
122
|
+
...row,
|
123
|
+
actions: [
|
124
|
+
<Icon key="edit" icon="edit" size="small" clickable action={() => alert(`Editar ${row.name}`)} title="Editar" />,
|
125
|
+
<Icon key="delete" icon="delete" size="small" clickable action={() => alert(`Eliminar ${row.name}`)} title="Eliminar" />,
|
126
|
+
<Icon key="more" icon="more_vert" size="small" clickable action={() => alert(`Más opciones para ${row.name}`)} title="Más" />
|
127
|
+
]
|
128
|
+
}))}
|
129
|
+
density="compact"
|
130
|
+
striped={true}
|
131
|
+
hover={true}
|
132
|
+
/>
|
133
|
+
</div>
|
134
|
+
</div>
|
135
|
+
)
|
136
|
+
}
|
137
|
+
|
138
|
+
export default ActionsColumnTest
|
package/src/html/table2.css
CHANGED
@@ -19,6 +19,8 @@
|
|
19
19
|
width: 100%;
|
20
20
|
border-collapse: collapse;
|
21
21
|
table-layout: auto;
|
22
|
+
overflow: visible !important;
|
23
|
+
|
22
24
|
}
|
23
25
|
|
24
26
|
/* Header styles */
|
@@ -1373,13 +1375,48 @@ body.datatable2-resizing {
|
|
1373
1375
|
}
|
1374
1376
|
|
1375
1377
|
/* Special cell types */
|
1376
|
-
.datatable2__select-cell
|
1377
|
-
|
1378
|
-
width: 48px;
|
1378
|
+
.datatable2__select-cell {
|
1379
|
+
width: auto;
|
1380
|
+
min-width: 48px;
|
1379
1381
|
text-align: center;
|
1380
1382
|
padding: 8px;
|
1381
1383
|
}
|
1382
1384
|
|
1385
|
+
.datatable2__actions-cell {
|
1386
|
+
width: 1%;
|
1387
|
+
white-space: nowrap;
|
1388
|
+
text-align: right;
|
1389
|
+
padding: 8px;
|
1390
|
+
vertical-align: middle;
|
1391
|
+
}
|
1392
|
+
|
1393
|
+
.datatable2__actions-header {
|
1394
|
+
width: 1%;
|
1395
|
+
white-space: nowrap;
|
1396
|
+
text-align: right;
|
1397
|
+
padding: 8px;
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
/* Actions container and items */
|
1401
|
+
.datatable2__actions-container {
|
1402
|
+
display: flex;
|
1403
|
+
align-items: center;
|
1404
|
+
justify-content: flex-end;
|
1405
|
+
gap: 4px;
|
1406
|
+
flex-wrap: nowrap;
|
1407
|
+
}
|
1408
|
+
|
1409
|
+
.datatable2__action-item {
|
1410
|
+
display: inline-flex;
|
1411
|
+
align-items: center;
|
1412
|
+
justify-content: center;
|
1413
|
+
flex-shrink: 0;
|
1414
|
+
}
|
1415
|
+
|
1416
|
+
.datatable2__expand-icon {
|
1417
|
+
margin-left: 4px;
|
1418
|
+
}
|
1419
|
+
|
1383
1420
|
.datatable2__row-number {
|
1384
1421
|
width: 60px;
|
1385
1422
|
text-align: center;
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import React, { useState, useCallback } from 'react'
|
2
2
|
import { DataTable2 } from './table2'
|
3
3
|
import { Button } from './button'
|
4
|
+
import { Icon } from './icon'
|
5
|
+
import { ActionsCell } from './actions-cell'
|
4
6
|
import { ExampleLayout, ExampleSection, ExampleSubsection, CodeSnippet } from './ExampleLayout'
|
5
7
|
|
6
8
|
// Ejemplo de componente personalizado para el panel
|
@@ -289,6 +291,15 @@ export const DataTable2Examples = () => {
|
|
289
291
|
{ id: 'row-numbers-only', title: 'Solo Números de Fila' }
|
290
292
|
]
|
291
293
|
},
|
294
|
+
{
|
295
|
+
id: 'actions-column',
|
296
|
+
title: '⚡ Columnas de Acciones',
|
297
|
+
icon: 'build',
|
298
|
+
subsections: [
|
299
|
+
{ id: 'actions-basic', title: 'Acciones Básicas con Iconos' },
|
300
|
+
{ id: 'actions-icons', title: 'Acciones con Iconos y ActionsCell' }
|
301
|
+
]
|
302
|
+
},
|
292
303
|
{
|
293
304
|
id: 'performance',
|
294
305
|
title: 'Rendimiento y Escalabilidad',
|
@@ -3121,6 +3132,325 @@ console.log(stats)
|
|
3121
3132
|
// ✅ Formateo específico por tipo de datos`}
|
3122
3133
|
/>
|
3123
3134
|
</ExampleSection>
|
3135
|
+
|
3136
|
+
{/* Nueva sección: Columnas de Acciones con Componentes React */}
|
3137
|
+
<ExampleSection id="actions-column" title="⚡ Columnas de Acciones con Componentes React" icon="build">
|
3138
|
+
<div style={{
|
3139
|
+
background: '#f0f9ff',
|
3140
|
+
padding: '1rem',
|
3141
|
+
borderRadius: '8px',
|
3142
|
+
marginBottom: '1.5rem',
|
3143
|
+
border: '1px solid #e0f2fe'
|
3144
|
+
}}>
|
3145
|
+
<h4 style={{ margin: '0 0 0.5rem 0', color: '#0277bd' }}>🎯 Nueva Funcionalidad</h4>
|
3146
|
+
<p style={{ margin: '0', fontSize: '0.875rem', color: '#01579b' }}>
|
3147
|
+
Ahora puedes especificar una columna <code>actions</code> en la lista de columnas y pasar un array de componentes React
|
3148
|
+
(botones, iconos, etc.) en cada fila. Los componentes se renderizan directamente en las celdas.
|
3149
|
+
</p>
|
3150
|
+
</div>
|
3151
|
+
|
3152
|
+
<ExampleSubsection id="actions-basic" title="Acciones Básicas con Iconos">
|
3153
|
+
{(() => {
|
3154
|
+
// Datos de ejemplo con acciones
|
3155
|
+
const actionsData = [
|
3156
|
+
{
|
3157
|
+
id: 1,
|
3158
|
+
name: 'Juan Pérez',
|
3159
|
+
email: 'juan@example.com',
|
3160
|
+
status: 'active',
|
3161
|
+
actions: [
|
3162
|
+
<Button key="edit" label="Editar" size="small" variant="primary" action={() => alert('Editar Juan')} />,
|
3163
|
+
<Button key="delete" label="Eliminar" size="small" variant="danger" action={() => alert('Eliminar Juan')} />
|
3164
|
+
]
|
3165
|
+
},
|
3166
|
+
{
|
3167
|
+
id: 2,
|
3168
|
+
name: 'María García',
|
3169
|
+
email: 'maria@example.com',
|
3170
|
+
status: 'pending',
|
3171
|
+
actions: [
|
3172
|
+
<Button key="approve" label="Aprobar" size="small" variant="success" action={() => alert('Aprobar María')} />,
|
3173
|
+
<Button key="reject" label="Rechazar" size="small" variant="danger" action={() => alert('Rechazar María')} />
|
3174
|
+
]
|
3175
|
+
},
|
3176
|
+
{
|
3177
|
+
id: 3,
|
3178
|
+
name: 'Carlos López',
|
3179
|
+
email: 'carlos@example.com',
|
3180
|
+
status: 'inactive',
|
3181
|
+
actions: [
|
3182
|
+
<Button key="activate" label="Activar" size="small" variant="success" action={() => alert('Activar Carlos')} />
|
3183
|
+
]
|
3184
|
+
}
|
3185
|
+
]
|
3186
|
+
|
3187
|
+
const actionsColumns = [
|
3188
|
+
{ id: 'id', label: 'ID', width: 60 },
|
3189
|
+
{ id: 'name', label: 'Nombre', sortable: true },
|
3190
|
+
{ id: 'email', label: 'Email', sortable: true },
|
3191
|
+
{ id: 'status', label: 'Estado', filterable: true },
|
3192
|
+
{ id: 'actions', label: 'Acciones' } // ← Columna de acciones
|
3193
|
+
]
|
3194
|
+
|
3195
|
+
return (
|
3196
|
+
<div style={{
|
3197
|
+
background: '#fff',
|
3198
|
+
padding: '1rem',
|
3199
|
+
border: '1px solid #ddd',
|
3200
|
+
borderRadius: '8px',
|
3201
|
+
marginBottom: '1rem'
|
3202
|
+
}}>
|
3203
|
+
<DataTable2
|
3204
|
+
id="actions-basic-demo"
|
3205
|
+
columns={actionsColumns}
|
3206
|
+
rows={actionsData}
|
3207
|
+
density="normal"
|
3208
|
+
striped={true}
|
3209
|
+
resizable={true}
|
3210
|
+
/>
|
3211
|
+
</div>
|
3212
|
+
)
|
3213
|
+
})()}
|
3214
|
+
|
3215
|
+
<CodeSnippet
|
3216
|
+
title="Código de Acciones Básicas"
|
3217
|
+
code={`import { DataTable2 } from './table2'
|
3218
|
+
import { Button } from './button'
|
3219
|
+
|
3220
|
+
// Definir columnas incluyendo la columna de acciones
|
3221
|
+
const columns = [
|
3222
|
+
{ id: 'id', label: 'ID', width: 60 },
|
3223
|
+
{ id: 'name', label: 'Nombre', sortable: true },
|
3224
|
+
{ id: 'email', label: 'Email', sortable: true },
|
3225
|
+
{ id: 'status', label: 'Estado', filterable: true },
|
3226
|
+
{ id: 'actions', label: 'Acciones' } // ← Columna de acciones
|
3227
|
+
]
|
3228
|
+
|
3229
|
+
// Datos con array de componentes React en la propiedad actions
|
3230
|
+
const rows = [
|
3231
|
+
{
|
3232
|
+
id: 1,
|
3233
|
+
name: 'Juan Pérez',
|
3234
|
+
email: 'juan@example.com',
|
3235
|
+
status: 'active',
|
3236
|
+
actions: [ // ← Array de componentes React
|
3237
|
+
<Button
|
3238
|
+
key="edit"
|
3239
|
+
label="Editar"
|
3240
|
+
size="small"
|
3241
|
+
variant="primary"
|
3242
|
+
action={() => alert('Editar Juan')}
|
3243
|
+
/>,
|
3244
|
+
<Button
|
3245
|
+
key="delete"
|
3246
|
+
label="Eliminar"
|
3247
|
+
size="small"
|
3248
|
+
variant="danger"
|
3249
|
+
action={() => alert('Eliminar Juan')}
|
3250
|
+
/>
|
3251
|
+
]
|
3252
|
+
},
|
3253
|
+
// ... más filas
|
3254
|
+
]
|
3255
|
+
|
3256
|
+
<DataTable2
|
3257
|
+
columns={columns}
|
3258
|
+
rows={rows}
|
3259
|
+
density="normal"
|
3260
|
+
striped={true}
|
3261
|
+
resizable={true}
|
3262
|
+
/>`}
|
3263
|
+
/>
|
3264
|
+
</ExampleSubsection>
|
3265
|
+
|
3266
|
+
<ExampleSubsection id="actions-icons" title="Acciones con Iconos y Tooltips">
|
3267
|
+
{(() => {
|
3268
|
+
|
3269
|
+
// Datos con acciones usando iconos
|
3270
|
+
const iconActionsData = [
|
3271
|
+
{
|
3272
|
+
id: 1,
|
3273
|
+
name: 'Documento.pdf',
|
3274
|
+
size: '2.5 MB',
|
3275
|
+
type: 'PDF',
|
3276
|
+
actions: [
|
3277
|
+
<Icon key="view" icon="visibility" size="small" clickable action={() => alert('Ver documento')} title="Ver" />,
|
3278
|
+
<Icon key="download" icon="download" size="small" clickable action={() => alert('Descargar')} title="Descargar" />,
|
3279
|
+
<Icon key="share" icon="share" size="small" clickable action={() => alert('Compartir')} title="Compartir" />,
|
3280
|
+
<Icon key="delete" icon="delete" size="small" clickable action={() => alert('Eliminar')} title="Eliminar" />
|
3281
|
+
]
|
3282
|
+
},
|
3283
|
+
{
|
3284
|
+
id: 2,
|
3285
|
+
name: 'Imagen.jpg',
|
3286
|
+
size: '1.2 MB',
|
3287
|
+
type: 'Imagen',
|
3288
|
+
actions: [
|
3289
|
+
<Icon key="view" icon="visibility" size="small" clickable action={() => alert('Ver imagen')} title="Ver" />,
|
3290
|
+
<Icon key="edit" icon="edit" size="small" clickable action={() => alert('Editar imagen')} title="Editar" />,
|
3291
|
+
<Icon key="download" icon="download" size="small" clickable action={() => alert('Descargar')} title="Descargar" />
|
3292
|
+
]
|
3293
|
+
},
|
3294
|
+
{
|
3295
|
+
id: 3,
|
3296
|
+
name: 'Video.mp4',
|
3297
|
+
size: '15.8 MB',
|
3298
|
+
type: 'Video',
|
3299
|
+
actions: [
|
3300
|
+
<Icon key="play" icon="play_arrow" size="small" clickable action={() => alert('Reproducir video')} title="Reproducir" />,
|
3301
|
+
<Icon key="download" icon="download" size="small" clickable action={() => alert('Descargar')} title="Descargar" />
|
3302
|
+
]
|
3303
|
+
},
|
3304
|
+
// Filas con ActionsCell para demostrar integración
|
3305
|
+
{
|
3306
|
+
id: 4,
|
3307
|
+
name: 'Proyecto.zip',
|
3308
|
+
size: '45.2 MB',
|
3309
|
+
type: 'Archivo',
|
3310
|
+
actions: [
|
3311
|
+
<ActionsCell
|
3312
|
+
key="actions-cell"
|
3313
|
+
actions={
|
3314
|
+
<div style={{ display: 'flex', gap: '4px' }}>
|
3315
|
+
<Icon icon="visibility" size="small" clickable action={() => alert('Ver proyecto')} title="Ver" />
|
3316
|
+
<Icon icon="download" size="small" clickable action={() => alert('Descargar')} title="Descargar" />
|
3317
|
+
<Icon icon="edit" size="small" clickable action={() => alert('Editar')} title="Editar" />
|
3318
|
+
<Icon icon="share" size="small" clickable action={() => alert('Compartir')} title="Compartir" />
|
3319
|
+
<Icon icon="copy" size="small" clickable action={() => alert('Copiar')} title="Copiar" />
|
3320
|
+
<Icon icon="delete" size="small" clickable action={() => alert('Eliminar')} title="Eliminar" />
|
3321
|
+
</div>
|
3322
|
+
}
|
3323
|
+
maxWidth={120}
|
3324
|
+
menuAlign="left"
|
3325
|
+
/>
|
3326
|
+
]
|
3327
|
+
},
|
3328
|
+
{
|
3329
|
+
id: 5,
|
3330
|
+
name: 'Presentación.pptx',
|
3331
|
+
size: '8.7 MB',
|
3332
|
+
type: 'Presentación',
|
3333
|
+
actions: [
|
3334
|
+
<ActionsCell
|
3335
|
+
key="actions-cell"
|
3336
|
+
actions={
|
3337
|
+
<div style={{ display: 'flex', gap: '4px' }}>
|
3338
|
+
<Button size="small" variant="outlined" label="Abrir" action={() => alert('Abrir presentación')} />
|
3339
|
+
<Button size="small" variant="outlined" label="Editar" action={() => alert('Editar presentación')} />
|
3340
|
+
<Button size="small" variant="outlined" label="Compartir" action={() => alert('Compartir presentación')} />
|
3341
|
+
</div>
|
3342
|
+
}
|
3343
|
+
maxWidth={150}
|
3344
|
+
menuAlign="left"
|
3345
|
+
/>
|
3346
|
+
]
|
3347
|
+
}
|
3348
|
+
]
|
3349
|
+
|
3350
|
+
const iconColumns = [
|
3351
|
+
{ id: 'id', label: 'ID', width: 60 },
|
3352
|
+
{ id: 'name', label: 'Archivo', sortable: true },
|
3353
|
+
{ id: 'size', label: 'Tamaño', sortable: true },
|
3354
|
+
{ id: 'type', label: 'Tipo', filterable: true },
|
3355
|
+
{ id: 'actions' } // ← Sin label para que no aparezca texto en la cabecera
|
3356
|
+
]
|
3357
|
+
|
3358
|
+
return (
|
3359
|
+
<div style={{
|
3360
|
+
background: '#fff',
|
3361
|
+
padding: '1rem',
|
3362
|
+
border: '1px solid #ddd',
|
3363
|
+
borderRadius: '8px',
|
3364
|
+
marginBottom: '1rem'
|
3365
|
+
}}>
|
3366
|
+
<DataTable2
|
3367
|
+
id="actions-icons-demo"
|
3368
|
+
columns={iconColumns}
|
3369
|
+
rows={iconActionsData}
|
3370
|
+
density="compact"
|
3371
|
+
striped={true}
|
3372
|
+
hover={true}
|
3373
|
+
/>
|
3374
|
+
</div>
|
3375
|
+
)
|
3376
|
+
})()}
|
3377
|
+
|
3378
|
+
<CodeSnippet
|
3379
|
+
title="Código de Acciones con Iconos y ActionsCell"
|
3380
|
+
code={`import { DataTable2 } from './table2'
|
3381
|
+
import { Icon } from './icon'
|
3382
|
+
import { ActionsCell } from './actions-cell'
|
3383
|
+
import { Button } from './button'
|
3384
|
+
|
3385
|
+
const columns = [
|
3386
|
+
{ id: 'id', label: 'ID', width: 60 },
|
3387
|
+
{ id: 'name', label: 'Archivo', sortable: true },
|
3388
|
+
{ id: 'size', label: 'Tamaño', sortable: true },
|
3389
|
+
{ id: 'type', label: 'Tipo', filterable: true },
|
3390
|
+
{ id: 'actions' } // ← Sin label para cabecera vacía
|
3391
|
+
]
|
3392
|
+
|
3393
|
+
const rows = [
|
3394
|
+
{
|
3395
|
+
id: 1,
|
3396
|
+
name: 'Documento.pdf',
|
3397
|
+
size: '2.5 MB',
|
3398
|
+
type: 'PDF',
|
3399
|
+
actions: [ // ← Array de iconos clickeables
|
3400
|
+
<Icon
|
3401
|
+
key="view"
|
3402
|
+
icon="visibility"
|
3403
|
+
size="small"
|
3404
|
+
clickable
|
3405
|
+
action={() => alert('Ver documento')}
|
3406
|
+
title="Ver"
|
3407
|
+
/>,
|
3408
|
+
<Icon
|
3409
|
+
key="download"
|
3410
|
+
icon="download"
|
3411
|
+
size="small"
|
3412
|
+
clickable
|
3413
|
+
action={() => alert('Descargar')}
|
3414
|
+
title="Descargar"
|
3415
|
+
/>
|
3416
|
+
]
|
3417
|
+
},
|
3418
|
+
{
|
3419
|
+
id: 2,
|
3420
|
+
name: 'Proyecto.zip',
|
3421
|
+
size: '45.2 MB',
|
3422
|
+
type: 'Archivo',
|
3423
|
+
actions: [ // ← Usando ActionsCell para muchas acciones
|
3424
|
+
<ActionsCell
|
3425
|
+
key="actions-cell"
|
3426
|
+
actions={
|
3427
|
+
<div style={{ display: 'flex', gap: '4px' }}>
|
3428
|
+
<Icon icon="visibility" size="small" clickable action={() => alert('Ver')} title="Ver" />
|
3429
|
+
<Icon icon="download" size="small" clickable action={() => alert('Descargar')} title="Descargar" />
|
3430
|
+
<Icon icon="edit" size="small" clickable action={() => alert('Editar')} title="Editar" />
|
3431
|
+
<Icon icon="share" size="small" clickable action={() => alert('Compartir')} title="Compartir" />
|
3432
|
+
<Icon icon="copy" size="small" clickable action={() => alert('Copiar')} title="Copiar" />
|
3433
|
+
<Icon icon="delete" size="small" clickable action={() => alert('Eliminar')} title="Eliminar" />
|
3434
|
+
</div>
|
3435
|
+
}
|
3436
|
+
maxWidth={120} // ← Se convierte en menú automáticamente
|
3437
|
+
menuAlign="left" // ← Se abre hacia la izquierda
|
3438
|
+
/>
|
3439
|
+
]
|
3440
|
+
},
|
3441
|
+
// ... más filas
|
3442
|
+
]
|
3443
|
+
|
3444
|
+
<DataTable2
|
3445
|
+
columns={columns}
|
3446
|
+
rows={rows}
|
3447
|
+
density="compact"
|
3448
|
+
striped={true}
|
3449
|
+
hover={true}
|
3450
|
+
/>`}
|
3451
|
+
/>
|
3452
|
+
</ExampleSubsection>
|
3453
|
+
</ExampleSection>
|
3124
3454
|
</ExampleLayout>
|
3125
3455
|
)
|
3126
3456
|
}
|