ywana-core8 0.0.212 → 0.0.216
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +26 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +26 -21
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +26 -21
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/table.js +21 -17
- package/src/test.js +2 -3
package/package.json
CHANGED
package/src/html/table.js
CHANGED
@@ -74,9 +74,9 @@ export const DataTable = (props) => {
|
|
74
74
|
<table>
|
75
75
|
<thead>
|
76
76
|
<tr>
|
77
|
-
{columns.map(({ id, label, type, sortable }) => {
|
77
|
+
{columns.map(({ id, label, type, item, sortable }) => {
|
78
78
|
const sort = sortDir[id] ? sortDir[id] : null
|
79
|
-
const [rowspan, colspan] = type === TYPES.ENTITY ? [1,
|
79
|
+
const [rowspan, colspan] = type === TYPES.ENTITY ? [1, Object.keys(item).length] : [2, 1]
|
80
80
|
return (
|
81
81
|
<th rowSpan={rowspan} colSpan={colspan}>
|
82
82
|
{id === "checked" ? <CheckBox onChange={checkAll} /> : <Text key={`th_${id}`}>{label}</Text>}
|
@@ -90,10 +90,12 @@ export const DataTable = (props) => {
|
|
90
90
|
{
|
91
91
|
columns
|
92
92
|
.filter(({ type }) => type === TYPES.ENTITY)
|
93
|
-
.map(
|
94
|
-
const { item
|
95
|
-
|
96
|
-
return
|
93
|
+
.map(column => {
|
94
|
+
const { item } = column
|
95
|
+
const fields = item ? Object.values(item) : []
|
96
|
+
return fields
|
97
|
+
.filter(field => field.column === true)
|
98
|
+
.map(field => <th>{field.label}</th>)
|
97
99
|
})
|
98
100
|
}
|
99
101
|
</tr>
|
@@ -143,7 +145,7 @@ const DataTableRow = (props) => {
|
|
143
145
|
const DataTableCell = ({ row, column, cell, editable }) => {
|
144
146
|
|
145
147
|
const render = (type) => {
|
146
|
-
const { id, disabled = false, min, max, onChange, format, options } = column
|
148
|
+
const { id, disabled = false, min, max, onChange, format, options, item } = column
|
147
149
|
if (id === "checked") {
|
148
150
|
return <CheckBox id={id} value={cell} onChange={(id, value) => onChange(row.id, id, value)} />
|
149
151
|
} else if (editable && onChange) {
|
@@ -164,25 +166,27 @@ const DataTableCell = ({ row, column, cell, editable }) => {
|
|
164
166
|
case "ICON": return <Icon icon={cell} />
|
165
167
|
case "Boolean": return <BooleanCellViewer id={id} value={cell} />
|
166
168
|
case "String": return <StringCellViewer id={id} value={cell} format={format} options={options} />
|
167
|
-
case TYPES.ENTITY: return <EntityCellViewer id={id} value={cell} />
|
168
169
|
default: return cell
|
169
170
|
}
|
170
171
|
}
|
171
172
|
}
|
172
173
|
|
173
|
-
return (
|
174
|
+
return column.type === TYPES.ENTITY ? <EntityCellViewer id={column.id} item={column.item} value={cell} /> : (
|
174
175
|
<td key={column.id} className={column.id}>{render(column.type)}</td>
|
175
176
|
)
|
176
177
|
}
|
177
178
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
)
|
179
|
+
/**
|
180
|
+
* Entity Cell Viewer
|
181
|
+
* @param {*} param0
|
182
|
+
* @returns
|
183
|
+
*/
|
184
|
+
const EntityCellViewer = ({ id, item, value }) => {
|
185
|
+
console.log(id, item, value)
|
186
|
+
const fields = Object.values(item).filter(field => field.column === true)
|
187
|
+
return fields.map( field => {
|
188
|
+
return (<td>{value[field.id]}</td>)
|
189
|
+
})
|
186
190
|
}
|
187
191
|
|
188
192
|
/**
|
package/src/test.js
CHANGED
@@ -6,7 +6,7 @@ const Test = (props) => {
|
|
6
6
|
|
7
7
|
<div>
|
8
8
|
|
9
|
-
<table>
|
9
|
+
<table border="1">
|
10
10
|
<thead>
|
11
11
|
<tr>
|
12
12
|
<th rowspan="2" colspan="1"><div class="checkbox"><input type="checkbox" value=""/><span class="checkmark"></span><label></label></div></th>
|
@@ -14,8 +14,7 @@ const Test = (props) => {
|
|
14
14
|
<th rowspan="2" colspan="1"><span>Fecha de Entrada</span></th>
|
15
15
|
<th rowspan="2" colspan="1"><span>Circuito</span></th>
|
16
16
|
<th rowspan="2" colspan="1"><span>Clase de Muestra</span></th>
|
17
|
-
<th
|
18
|
-
<th rowspan="2" colspan="1"></th>
|
17
|
+
<th colspan="3"><span>Referencia</span></th>
|
19
18
|
<th></th>
|
20
19
|
</tr>
|
21
20
|
<tr>
|