ywana-core8 0.0.97 → 0.0.98

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.0.97",
3
+ "version": "0.0.98",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -224,6 +224,8 @@ const TableEditor = (props) => {
224
224
  setPageContext(Object.assign({}, pageContext))
225
225
  }
226
226
 
227
+ async function check(ids = []) {}
228
+
227
229
  function run(action, item) {
228
230
  action.action(item.id, pageContext, async () => {
229
231
  await pageContext.load()
@@ -281,7 +283,7 @@ const TableEditor = (props) => {
281
283
  <Header title={groupName} >
282
284
  <span className="size">{groupSize}</span>
283
285
  </Header>
284
- <DataTable {...table} onRowSelection={select} editable={editable} />
286
+ <DataTable {...table} onRowSelection={select} editable={editable} onCheckAll={check}/>
285
287
  </Fragment>
286
288
  )
287
289
  })
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
  )