ywana-core8 0.0.139 → 0.0.143

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.139",
3
+ "version": "0.0.143",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -59,7 +59,6 @@ export const DropDown = (props) => {
59
59
  const { id, options = [], value, onChange, canFilter = false } = props
60
60
  const [open, setOpen] = useState(false)
61
61
  const [label, setLabel] = useState()
62
- const [filter, setFilter] = useState()
63
62
 
64
63
  useEffect(() => {
65
64
  if (Array.isArray(options)) {
@@ -71,7 +70,7 @@ export const DropDown = (props) => {
71
70
  function change(id, value) {
72
71
  console.log('dropdown change > canFilter:', canFilter, id, value)
73
72
  if (canFilter) {
74
- setFilter(value)
73
+ setLabel(value)
75
74
  } else {
76
75
  if (onChange) onChange(id, value)
77
76
  }
@@ -96,23 +95,24 @@ export const DropDown = (props) => {
96
95
  setOpen(false)
97
96
  }
98
97
 
99
- const items = (open == true && Array.isArray(options)) ?
100
- options
101
- .filter(option => canFilter === false || filter.toUpperCase().indexOf(option.label.toUpperCase()) >= 0 )
102
- .map(option => <li key={option.value} value={option.value}>{option.label}</li>)
103
- : null
98
+ function renderOptions() {
99
+ const canShow = open == true && Array.isArray(options)
100
+ if (canShow) {
101
+ const filterActive = canFilter && label && label.length > 0
102
+ const items = filterActive ? options.filter(option => option.label.toUpperCase().indexOf(label.toUpperCase()) >= 0) : options
103
+ console.log('filterActive: ',filterActive, label, items.length)
104
+ const lis = items.map(option => <li key={option.value} value={option.value}>{option.label}</li>)
105
+ return <menu><ul onClick={select}>{lis}</ul></menu>
106
+ } else {
107
+ return null
108
+ }
109
+ }
104
110
 
105
111
  return (
106
112
  <div className="dropdown">
107
113
  <TextField {...props} onClick={toggle} value={label} onChange={change} />
108
114
  <Icon icon="expand_more" clickable size="small" action={toggle} />
109
- {open == true ? (
110
- <menu>
111
- <ul onClick={select}>
112
- {items}
113
- </ul>
114
- </menu>
115
- ) : null}
115
+ {renderOptions()}
116
116
  </div>
117
117
  )
118
118
  }