ywana-core8 0.0.409 → 0.0.410

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.409",
3
+ "version": "0.0.410",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
package/src/html/table.js CHANGED
@@ -15,6 +15,7 @@ export const DataTable = (props) => {
15
15
 
16
16
  const { columns = [], rows = [], onRowSelection, onSort, onCheckAll, editable, outlined, expanded = false } = props
17
17
  const [sortDir, setSortDir] = useState({})
18
+ const [allChecked, setAllChecked] = useState(false)
18
19
 
19
20
  function multiSort(array, sortObject = {}) {
20
21
 
@@ -65,6 +66,7 @@ export const DataTable = (props) => {
65
66
 
66
67
  function checkAll(id, value) {
67
68
  const ids = rows.map(row => row.id)
69
+ setAllChecked(value)
68
70
  if (onCheckAll) onCheckAll(ids, value)
69
71
  }
70
72
 
@@ -79,7 +81,7 @@ export const DataTable = (props) => {
79
81
  const [rowspan, colspan] = type === TYPES.ENTITY ? [1, Object.values(item).filter(v=>v.column===true).length] : [2, 1]
80
82
  return (
81
83
  <th key={id} rowSpan={rowspan} colSpan={colspan}>
82
- {id === "checked" ? <CheckBox onChange={checkAll} /> : <Text key={`th_${id}`}>{label}</Text>}
84
+ {id === "checked" ? <CheckBox onChange={checkAll} value={allChecked} /> : <Text key={`th_${id}`}>{label}</Text>}
83
85
  {sortable ? <Icon icon="arrow_up" size="small" clickable /> : null}
84
86
  </th>
85
87
  )
@@ -3,6 +3,14 @@ import { DataTable } from './table'
3
3
 
4
4
  const TableTest = (prop) => {
5
5
 
6
+
7
+ const [rows, setRows] = useState(
8
+ [
9
+ { id: 1, checked: false, name: "John Smith", thumb: "https://w7.pngwing.com/pngs/881/826/png-transparent-pikachu-ash-ketchum-pokemon-vrste-pikachu-leaf-flower-meme-thumbnail.png"},
10
+ { id: 2, checked: false, name: "Ann Martin" }
11
+ ]
12
+ )
13
+
6
14
  function select(row) {
7
15
  console.log('select',row)
8
16
  }
@@ -11,6 +19,11 @@ const TableTest = (prop) => {
11
19
  console.log('check', id, checked, c)
12
20
  }
13
21
 
22
+ function checkAll(ids, checked) {
23
+ const next = rows.map( row => Object.assign({}, row, { checked }))
24
+ setRows(next)
25
+ }
26
+
14
27
  const table = {
15
28
  columns : [
16
29
  { id: "checked", onChange: check },
@@ -18,15 +31,12 @@ const TableTest = (prop) => {
18
31
  { id: "thumb", label: "Thumb", type: "String", format: "IMG" },
19
32
 
20
33
  ],
21
- rows: [
22
- { checked: true, name: "John Smith", thumb: "https://w7.pngwing.com/pngs/881/826/png-transparent-pikachu-ash-ketchum-pokemon-vrste-pikachu-leaf-flower-meme-thumbnail.png"},
23
- { checked: false, name: "Ann Martin" },
24
- ]
34
+ rows
25
35
  }
26
36
 
27
37
  return (
28
38
  <>
29
- <DataTable {...table} onRowSelection={select}/>
39
+ <DataTable {...table} onRowSelection={select} onCheckAll={checkAll}/>
30
40
  </>
31
41
  )
32
42
  }
@@ -1,5 +1,4 @@
1
1
  .tokenField {
2
- max-height: 3.8rem;
3
2
  min-height: 3.8;
4
3
  position: relative;
5
4
  border-bottom: solid 1px var(--divider-color);