ywana-core8 0.0.100 → 0.0.104
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 +40 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +40 -21
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +40 -21
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/TablePage.js +17 -4
- package/src/html/table.js +7 -5
package/package.json
CHANGED
package/src/domain/TablePage.js
CHANGED
@@ -224,8 +224,10 @@ const TableEditor = (props) => {
|
|
224
224
|
setPageContext(Object.assign({}, pageContext))
|
225
225
|
}
|
226
226
|
|
227
|
-
async function check(
|
228
|
-
|
227
|
+
async function check(id, value) {
|
228
|
+
const ids = Array.isArray(id) ? id : [id]
|
229
|
+
pageContext.check(ids, value)
|
230
|
+
setPageContext(Object.assign({}, pageContext))
|
229
231
|
}
|
230
232
|
|
231
233
|
function run(action, item) {
|
@@ -261,12 +263,13 @@ const TableEditor = (props) => {
|
|
261
263
|
id: field.id,
|
262
264
|
label: field.label,
|
263
265
|
type: field.type,
|
264
|
-
onChange: field.editable ? change : null,
|
266
|
+
onChange: field.id === "checked" ? check : field.editable ? change : null, /* checked has it´s own handler */
|
265
267
|
options
|
266
268
|
}
|
267
269
|
}),
|
268
270
|
rows: groups[groupName]
|
269
271
|
.map(item => {
|
272
|
+
item.checked = pageContext.checked.has(item.id)
|
270
273
|
item.actions = actions ? actions.map(action => {
|
271
274
|
return action.filter ?
|
272
275
|
action.filter(item) ? <Icon icon={action.icon} clickable size="small" action={() => run(action, item)} /> : null
|
@@ -285,7 +288,7 @@ const TableEditor = (props) => {
|
|
285
288
|
<Header title={groupName} >
|
286
289
|
<span className="size">{groupSize}</span>
|
287
290
|
</Header>
|
288
|
-
<DataTable {...table} onRowSelection={select} editable={editable} onCheckAll={check}/>
|
291
|
+
<DataTable {...table} onRowSelection={select} editable={editable} onCheckAll={check} />
|
289
292
|
</Fragment>
|
290
293
|
)
|
291
294
|
})
|
@@ -297,6 +300,7 @@ const TableEditor = (props) => {
|
|
297
300
|
.map(field => ({ label: field.label, value: field.id }))
|
298
301
|
}
|
299
302
|
|
303
|
+
console.log('table page checked', pageContext.checked)
|
300
304
|
return (
|
301
305
|
<Fragment>
|
302
306
|
<Header icon={icon} title={<Text>{title}</Text>}>
|
@@ -319,6 +323,7 @@ const TableContext = (url, field) => {
|
|
319
323
|
return {
|
320
324
|
|
321
325
|
all: [],
|
326
|
+
checked: new Set(),
|
322
327
|
selected: null,
|
323
328
|
filters: {},
|
324
329
|
|
@@ -339,6 +344,14 @@ const TableContext = (url, field) => {
|
|
339
344
|
return
|
340
345
|
},
|
341
346
|
|
347
|
+
check(ids, isChecked = true) {
|
348
|
+
if (isChecked) {
|
349
|
+
ids.forEach(id => this.checked.add(id))
|
350
|
+
} else {
|
351
|
+
ids.forEach(id => this.checked.delete(id))
|
352
|
+
}
|
353
|
+
},
|
354
|
+
|
342
355
|
select(id) {
|
343
356
|
const result = this.all.find(item => item.id === id);
|
344
357
|
this.selected = result;
|
package/src/html/table.js
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
import React, { Fragment, useState } from 'react'
|
2
|
+
import { DropDown, TextField } from './textfield'
|
2
3
|
import { CheckBox } from './checkbox'
|
3
4
|
import { Icon } from './icon'
|
4
5
|
import { Text } from './text'
|
5
|
-
import { DropDown, TextField } from './textfield'
|
6
6
|
import './table.css'
|
7
7
|
|
8
|
+
const isFunction = value => value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
|
9
|
+
|
8
10
|
/**
|
9
11
|
* DataTable
|
10
12
|
*/
|
@@ -60,9 +62,9 @@ export const DataTable = (props) => {
|
|
60
62
|
if (onSort) onSort(dragged, dropped)
|
61
63
|
}
|
62
64
|
|
63
|
-
function checkAll() {
|
65
|
+
function checkAll(id, value) {
|
64
66
|
const ids = rows.map(row => row.id)
|
65
|
-
if (onCheckAll) onCheckAll(ids)
|
67
|
+
if (onCheckAll) onCheckAll(ids, value)
|
66
68
|
}
|
67
69
|
|
68
70
|
const style = outlined ? "outlined" : ""
|
@@ -98,12 +100,12 @@ export const DataTable = (props) => {
|
|
98
100
|
* DataTable Row
|
99
101
|
*/
|
100
102
|
const DataTableRow = (props) => {
|
103
|
+
|
101
104
|
const { row, columns = [], onSelect, editable } = props
|
105
|
+
|
102
106
|
const [isInfoOpen, toggleInfo] = useState(false)
|
103
107
|
const infoIcon = isInfoOpen ? 'expand_more' : 'expand_less'
|
104
108
|
|
105
|
-
const isFunction = value => value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
|
106
|
-
|
107
109
|
return (
|
108
110
|
<Fragment>
|
109
111
|
<tr onClick={ev => onSelect(row, ev)}>
|