ywana-core8 0.0.199 → 0.0.203
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 +31 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +31 -13
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +31 -13
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/table.js +23 -4
- package/src/test.js +41 -5
package/package.json
CHANGED
package/src/html/table.js
CHANGED
@@ -4,7 +4,7 @@ import { CheckBox } from './checkbox'
|
|
4
4
|
import { Icon } from './icon'
|
5
5
|
import { Text } from './text'
|
6
6
|
import './table.css'
|
7
|
-
import { FORMATS } from '../domain/ContentType'
|
7
|
+
import { FORMATS, TYPES } from '../domain/ContentType'
|
8
8
|
|
9
9
|
const isFunction = value => value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
|
10
10
|
|
@@ -74,10 +74,11 @@ export const DataTable = (props) => {
|
|
74
74
|
<table>
|
75
75
|
<thead>
|
76
76
|
<tr>
|
77
|
-
{columns.map(({ id, label, sortable }) => {
|
77
|
+
{columns.map(({ id, label, type, sortable }) => {
|
78
78
|
const sort = sortDir[id] ? sortDir[id] : null
|
79
|
+
const colspan = type === TYPES.ENTITY ? : 1
|
79
80
|
return (
|
80
|
-
<th>
|
81
|
+
<th rowSpan={2} colSpan={colspan}>
|
81
82
|
{id === "checked" ? <CheckBox onChange={checkAll} /> : <Text key={`th_${id}`}>{label}</Text>}
|
82
83
|
{sortable ? <Icon icon="arrow_up" size="small" clickable /> : null}
|
83
84
|
</th>
|
@@ -85,6 +86,13 @@ export const DataTable = (props) => {
|
|
85
86
|
})}
|
86
87
|
<th></th>
|
87
88
|
</tr>
|
89
|
+
<tr>x
|
90
|
+
{
|
91
|
+
columns
|
92
|
+
.filter(({ type }) => type === TYPES.ENTITY)
|
93
|
+
.map(({ label }) => <th>{label}</th>)
|
94
|
+
}
|
95
|
+
</tr>
|
88
96
|
</thead>
|
89
97
|
<tbody>
|
90
98
|
{
|
@@ -111,7 +119,7 @@ const DataTableRow = (props) => {
|
|
111
119
|
return (
|
112
120
|
<Fragment>
|
113
121
|
<tr onClick={ev => onSelect(row, ev)}>
|
114
|
-
{columns.map((column,index) => <DataTableCell key={`${column.id}_${index}`} row={row} column={column} cell={row[column.id]} editable={editable} />)}
|
122
|
+
{columns.map((column, index) => <DataTableCell key={`${column.id}_${index}`} row={row} column={column} cell={row[column.id]} editable={editable} />)}
|
115
123
|
{row.info ? <td><Icon icon={infoIcon} clickable action={() => toggleInfo(!isInfoOpen)} /></td> : <td></td>}
|
116
124
|
</tr>
|
117
125
|
{row.info && isInfoOpen ? (
|
@@ -152,6 +160,7 @@ const DataTableCell = ({ row, column, cell, editable }) => {
|
|
152
160
|
case "ICON": return <Icon icon={cell} />
|
153
161
|
case "Boolean": return <BooleanCellViewer id={id} value={cell} />
|
154
162
|
case "String": return <StringCellViewer id={id} value={cell} format={format} options={options} />
|
163
|
+
case TYPES.ENTITY: return <EntityCellViewer id={id} value={cell} />
|
155
164
|
default: return cell
|
156
165
|
}
|
157
166
|
}
|
@@ -162,6 +171,16 @@ const DataTableCell = ({ row, column, cell, editable }) => {
|
|
162
171
|
)
|
163
172
|
}
|
164
173
|
|
174
|
+
const EntityCellViewer = ({ id, value }) => {
|
175
|
+
console.log(id, value)
|
176
|
+
const subcells = value ? Object.values(value) : [1, 2, 3]
|
177
|
+
return (
|
178
|
+
<div className='entity-cell-viewer'>
|
179
|
+
{subcells.filter(v => !v).map(v => <div>{v}</div>)}
|
180
|
+
</div>
|
181
|
+
)
|
182
|
+
}
|
183
|
+
|
165
184
|
/**
|
166
185
|
* Boolean Cell Viewer
|
167
186
|
*/
|
package/src/test.js
CHANGED
@@ -1,5 +1,41 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
const Test = (props) => {
|
4
|
+
|
5
|
+
return (
|
6
|
+
|
7
|
+
|
8
|
+
<table border="1">
|
9
|
+
<thead>
|
10
|
+
<tr>
|
11
|
+
<th rowSpan={2}>Uno</th>
|
12
|
+
<th rowSpan={2}>Dos</th>
|
13
|
+
<th rowSpan={2}>Tres</th>
|
14
|
+
<th colspan="4">Cuatro</th>
|
15
|
+
<th rowSpan={2}>Ocho</th>
|
16
|
+
</tr>
|
17
|
+
<tr>
|
18
|
+
<th>a</th>
|
19
|
+
<th>b</th>
|
20
|
+
<th>c</th>
|
21
|
+
<th>d</th>
|
22
|
+
</tr>
|
23
|
+
</thead>
|
24
|
+
<tbody>
|
25
|
+
|
26
|
+
<tr>
|
27
|
+
<td>1</td>
|
28
|
+
<td>2</td>
|
29
|
+
<td>3</td>
|
30
|
+
<td>4</td>
|
31
|
+
<td>5</td>
|
32
|
+
<td>6</td>
|
33
|
+
<td>7</td>
|
34
|
+
<td>8</td>
|
35
|
+
</tr>
|
36
|
+
</tbody>
|
37
|
+
</table>
|
38
|
+
|
39
|
+
|
40
|
+
)
|
41
|
+
}
|