ywana-core8 0.0.95 → 0.0.99
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 +37 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +37 -8
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +37 -8
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/TablePage.js +5 -1
- package/src/html/table.js +13 -8
package/package.json
CHANGED
package/src/domain/TablePage.js
CHANGED
@@ -224,6 +224,10 @@ const TableEditor = (props) => {
|
|
224
224
|
setPageContext(Object.assign({}, pageContext))
|
225
225
|
}
|
226
226
|
|
227
|
+
async function check(ids = []) {
|
228
|
+
console.log("check: ", ids)
|
229
|
+
}
|
230
|
+
|
227
231
|
function run(action, item) {
|
228
232
|
action.action(item.id, pageContext, async () => {
|
229
233
|
await pageContext.load()
|
@@ -281,7 +285,7 @@ const TableEditor = (props) => {
|
|
281
285
|
<Header title={groupName} >
|
282
286
|
<span className="size">{groupSize}</span>
|
283
287
|
</Header>
|
284
|
-
<DataTable {...table} onRowSelection={select} editable={editable} />
|
288
|
+
<DataTable {...table} onRowSelection={select} editable={editable} onCheckAll={check}/>
|
285
289
|
</Fragment>
|
286
290
|
)
|
287
291
|
})
|
package/src/html/table.js
CHANGED
@@ -10,7 +10,7 @@ import './table.css'
|
|
10
10
|
*/
|
11
11
|
export const DataTable = (props) => {
|
12
12
|
|
13
|
-
const { columns = [], rows = [], onRowSelection, onSort, editable, outlined } = props
|
13
|
+
const { columns = [], rows = [], onRowSelection, onSort, onCheckAll, editable, outlined } = props
|
14
14
|
const [sortDir, setSortDir] = useState({})
|
15
15
|
|
16
16
|
function multiSort(array, sortObject = {}) {
|
@@ -60,6 +60,11 @@ export const DataTable = (props) => {
|
|
60
60
|
if (onSort) onSort(dragged, dropped)
|
61
61
|
}
|
62
62
|
|
63
|
+
function checkAll() {
|
64
|
+
const ids = rows.map(row => row.id)
|
65
|
+
if (onCheckAll) onCheckAll(ids)
|
66
|
+
}
|
67
|
+
|
63
68
|
const style = outlined ? "outlined" : ""
|
64
69
|
return (
|
65
70
|
<div className={`datatable8 ${style}`}>
|
@@ -70,7 +75,7 @@ export const DataTable = (props) => {
|
|
70
75
|
const sort = sortDir[id] ? sortDir[id] : null
|
71
76
|
return (
|
72
77
|
<th>
|
73
|
-
<Text>{label}</Text>
|
78
|
+
{id === "checked" ? <CheckBox action={checkAll}/> : <Text>{label}</Text>}
|
74
79
|
{sortable ? <Icon icon="arrow_up" size="small" clickable /> : null}
|
75
80
|
</th>
|
76
81
|
)
|
@@ -80,7 +85,7 @@ export const DataTable = (props) => {
|
|
80
85
|
<tbody>
|
81
86
|
{
|
82
87
|
multiSort(rows, sortDir).map(row => (
|
83
|
-
<DataTableRow key={row.id} row={row} columns={columns} onSelect={select} onDrop={sort} editable={editable}/>
|
88
|
+
<DataTableRow key={row.id} row={row} columns={columns} onSelect={select} onDrop={sort} editable={editable} />
|
84
89
|
))
|
85
90
|
}
|
86
91
|
</tbody>
|
@@ -102,7 +107,7 @@ const DataTableRow = (props) => {
|
|
102
107
|
return (
|
103
108
|
<Fragment>
|
104
109
|
<tr onClick={ev => onSelect(row, ev)}>
|
105
|
-
{columns.map(column => <DataTableCell row={row} column={column} cell={row[column.id]} editable={editable}/>)}
|
110
|
+
{columns.map(column => <DataTableCell row={row} column={column} cell={row[column.id]} editable={editable} />)}
|
106
111
|
{row.info ? <Icon icon={infoIcon} clickable action={() => toggleInfo(!isInfoOpen)} /> : null}
|
107
112
|
</tr>
|
108
113
|
{row.info && isInfoOpen ? (
|
@@ -121,8 +126,8 @@ const DataTableCell = ({ row, column, cell, editable }) => {
|
|
121
126
|
|
122
127
|
const render = (type) => {
|
123
128
|
const { id, disabled = false, min, max, onChange, options } = column
|
124
|
-
if (id
|
125
|
-
<CheckBox id={id} value={cell} onChange={(id, value) => onChange(row.id, id, value)} />
|
129
|
+
if (id === "checked") {
|
130
|
+
return <CheckBox id={id} value={cell} onChange={(id, value) => onChange(row.id, id, value)} />
|
126
131
|
} else if (editable && onChange) {
|
127
132
|
switch (type) {
|
128
133
|
case "ICON": return <Icon icon={cell} />
|
@@ -155,7 +160,7 @@ const DataTableCell = ({ row, column, cell, editable }) => {
|
|
155
160
|
* Boolean Cell Viewer
|
156
161
|
*/
|
157
162
|
const BooleanCellViewer = ({ id, value = false }) => {
|
158
|
-
const icon = value === true ?
|
163
|
+
const icon = value === true ? "check_box" : "check_box_outline_blank"
|
159
164
|
return <Icon icon={icon} />
|
160
165
|
}
|
161
166
|
|
@@ -163,7 +168,7 @@ const BooleanCellViewer = ({ id, value = false }) => {
|
|
163
168
|
* String Cell Viewer
|
164
169
|
*/
|
165
170
|
const StringCellViewer = ({ id, value, options }) => {
|
166
|
-
const option = options ? options.find(
|
171
|
+
const option = options ? options.find(o => o.value === value) : null
|
167
172
|
const text = option ? option.label : value
|
168
173
|
return (<div className="field-editor string-editor">{text}</div>)
|
169
174
|
}
|