ywana-core8 0.0.408 → 0.0.411

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.408",
3
+ "version": "0.0.411",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -249,7 +249,7 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
249
249
  case FORMATS.COLOR: return <ColorField id={id} onChange={change} value={value}/>
250
250
  case FORMATS.HTML: return <Editor id={id} value={value} onChange={change} content={content} />
251
251
  case FORMATS.DATE: return <TextField outlined={outlined} id={id} type="date" label={label} value={value} onChange={change} readOnly={!editable} />
252
- case FORMATS.TOKENS: return <TokenField id={id} label={label} onChange={change} readOnly={!editable} options={options} />
252
+ case FORMATS.TOKENS: return <TokenField id={id} label={label} onChange={change} readOnly={!editable} options={buildOptions()} />
253
253
  default:
254
254
  return options ? (
255
255
  <DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} predictive={predictive} />
@@ -3,15 +3,19 @@ import { ContentEditor } from './ContentEditor'
3
3
  import { Content, FORMATS, TYPES } from './ContentType'
4
4
  import './ContentEditor.test.css'
5
5
 
6
+ function buildTokenOptions() {
7
+ return [
8
+ {label: "One", value: 1 },
9
+ {label: "Two", value: 2 },
10
+ {label: "Thressse", value: 3 },
11
+ ]
12
+ }
13
+
6
14
  const schema = {
7
15
  name : { id: "name" , type: TYPES.STRING, format: FORMATS.NONE, required: true, label: "Name" },
8
16
  field1: { id: "field1", type: TYPES.STRING, format: FORMATS.NONE, required: true, label: "field1", multivalue: true },
9
17
  field2: { id: "field2", type: TYPES.STRING, format: FORMATS.NONE, required: true, label: "field2" },
10
- field3: { id: "field3", type: TYPES.STRING, format: FORMATS.TOKENS, required: true, label: "field3", options: [
11
- {label: "One", value: 1 },
12
- {label: "Two", value: 2 },
13
- {label: "Three", value: 3 },
14
- ] },
18
+ field3: { id: "field3", type: TYPES.STRING, format: FORMATS.TOKENS, required: true, label: "field3", options: buildTokenOptions },
15
19
  field4: { id: "field4", type: TYPES.STRING, format: FORMATS.COLOR, required: true, label: "Color" },
16
20
  }
17
21
 
@@ -265,10 +265,17 @@ const TableFilters = (props) => {
265
265
  for (var key in filterSchema) {
266
266
  if (filterSchema[key].filter === false) {
267
267
  delete filterSchema[key]
268
- } else if (filterSchema[key].type === TYPES.ENTITY) {
269
- const fs = filterSchema[key].item
270
- for (var key in fs) {
271
- if (fs[key].filter === false) delete fs[key]
268
+ } else {
269
+
270
+ if (filterSchema[key].type === TYPES.ENTITY) {
271
+ const fs = filterSchema[key].item
272
+ for (var key in fs) {
273
+ if (fs[key].filter === false) delete fs[key]
274
+ }
275
+ }
276
+ // TODO: check this
277
+ if (filterSchema[key].defValue) {
278
+ change({ [key] : defValue })
272
279
  }
273
280
  }
274
281
  }
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,13 @@ import { DataTable } from './table'
3
3
 
4
4
  const TableTest = (prop) => {
5
5
 
6
+ const [rows, setRows] = useState(
7
+ [
8
+ { 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"},
9
+ { id: 2, checked: false, name: "Ann Martin" }
10
+ ]
11
+ )
12
+
6
13
  function select(row) {
7
14
  console.log('select',row)
8
15
  }
@@ -11,6 +18,11 @@ const TableTest = (prop) => {
11
18
  console.log('check', id, checked, c)
12
19
  }
13
20
 
21
+ function checkAll(ids, checked) {
22
+ const next = rows.map( row => Object.assign({}, row, { checked }))
23
+ setRows(next)
24
+ }
25
+
14
26
  const table = {
15
27
  columns : [
16
28
  { id: "checked", onChange: check },
@@ -18,15 +30,12 @@ const TableTest = (prop) => {
18
30
  { id: "thumb", label: "Thumb", type: "String", format: "IMG" },
19
31
 
20
32
  ],
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
- ]
33
+ rows
25
34
  }
26
35
 
27
36
  return (
28
37
  <>
29
- <DataTable {...table} onRowSelection={select}/>
38
+ <DataTable {...table} onRowSelection={select} onCheckAll={checkAll}/>
30
39
  </>
31
40
  )
32
41
  }
@@ -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);