ywana-core8 0.0.370 → 0.0.371

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.370",
3
+ "version": "0.0.371",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@ import './textarea.css'
12
12
  export const TextField = (props) => {
13
13
 
14
14
  const site = useContext(SiteContext)
15
- const { id, type = 'text', label, placeholder, value, outlined, readOnly = false, canClear = true, onChange, onEnter, onClick } = props
15
+ const { id, type = 'text', label, placeholder, value, outlined, readOnly = false, canClear = true, onChange, onEnter, onClick, onBlur } = props
16
16
 
17
17
  function onKeyPress(event) {
18
18
  var key = event.charCode ? event.charCode : event.keyCode ? event.keyCode : 0;
@@ -38,14 +38,8 @@ export const TextField = (props) => {
38
38
  }
39
39
  }
40
40
 
41
- function focusOut() {
42
- if (site && site.changeFocus) {
43
- site.changeFocus({
44
- lose: () => {
45
- // DO NOTHING
46
- }
47
- })
48
- }
41
+ function blur() {
42
+ if (onBlur) onBlur()
49
43
  }
50
44
 
51
45
  function clear() {
@@ -59,7 +53,7 @@ export const TextField = (props) => {
59
53
 
60
54
  return (
61
55
  <div className={`${style}`} onClick={onClick}>
62
- <input id={id} type={type} placeholder={placeholder} value={value} required onChange={change} onKeyDown={onKeyPress} onFocus={focus} onBlur={focusOut} readOnly={readOnly} />
56
+ <input id={id} type={type} placeholder={placeholder} value={value} required onChange={change} onKeyDown={onKeyPress} onFocus={focus} onBlur={blur} readOnly={readOnly} />
63
57
  {canClear && value && value.length > 0 ? <Icon icon="close" clickable size="small" action={clear} /> : null }
64
58
  <span className="bar"></span>
65
59
  {label ? <label>{labelTxt}</label> : null}
@@ -87,7 +81,6 @@ export const TextField = (props) => {
87
81
  event.stopPropagation()
88
82
  event.preventDefault()
89
83
  const value = event.target.value
90
- console.log(value)
91
84
  if (onChange) onChange(id, value)
92
85
  }
93
86
 
@@ -112,7 +105,7 @@ export const TextField = (props) => {
112
105
  return (
113
106
  <div className={`${style}`} onClick={onClick}>
114
107
  <textarea id={id} placeholder={placeholder} value={value} required onChange={change} onKeyDown={onKeyPress} onFocus={focus} readOnly={readOnly} />
115
- {!readOnly && canClear && value && value.length > 0 ? <Icon icon="close" clickable size="small" action={clear} /> : null }
108
+ {canClear && value && value.length > 0 ? <Icon icon="close" clickable size="small" action={clear} /> : null }
116
109
  <span className="bar"></span>
117
110
  {label ? <label>{labelTxt}</label> : null}
118
111
  </div>
@@ -165,13 +158,18 @@ export const DropDown = (props) => {
165
158
  setOpen(false)
166
159
  }
167
160
 
161
+ function blur() {
162
+ console.log("BLUR DD")
163
+ site.clearFocus()
164
+ }
165
+
168
166
  function renderOptions() {
169
167
  const canShow = open == true && Array.isArray(options)
170
168
  if (canShow) {
171
169
  const filterActive = predictive === true && label && label.length > 0
172
170
  const items = filterActive ? options.filter(option => option.label.toUpperCase().indexOf(label.toUpperCase()) >= 0) : options
173
171
  const lis = items.map(option => <li key={option.value} value={option.value}>{option.label}</li>)
174
- return <menu><ul onClick={select}>{lis}</ul></menu>
172
+ return <menu><ul onMouseDown={select}>{lis}</ul></menu>
175
173
  } else {
176
174
  return null
177
175
  }
@@ -179,7 +177,7 @@ export const DropDown = (props) => {
179
177
 
180
178
  return (
181
179
  <div className="dropdown">
182
- <TextField {...props} onClick={toggle} value={label} onChange={change} readOnly={!predictive}/>
180
+ <TextField {...props} onClick={toggle} value={label} onChange={change} onBlur={blur} readOnly={!predictive}/>
183
181
  {!readOnly ? <Icon icon="expand_more" clickable size="small" action={toggle} /> : null }
184
182
  {renderOptions()}
185
183
  </div>
package/src/site/site.js CHANGED
@@ -42,6 +42,10 @@ export const SiteProvider = ({ children, siteLang, siteDictionary, showConsole }
42
42
  if (focused) focused.lose()
43
43
  setFocused(next)
44
44
  },
45
+ clearFocus: () => {
46
+ if (focused) focused.lose()
47
+ setFocused(null)
48
+ },
45
49
 
46
50
  sideNav,
47
51
  setSideNav,
@@ -51,7 +51,7 @@ const Page1 = (props) => {
51
51
  <main>
52
52
  <TextField id="name" label="Name" value={form.name} onChange={change} />
53
53
  <DropDown id="gender1" label="Dropdown 1" value={form.gender1} onChange={change} options={options} predictive={true} />
54
- <DropDown id="gender2" label="Dropdown 2" value={form.gender1} onChange={change} options={options} predictive={true} />
54
+ <DropDown id="gender2" label="Dropdown 2" value={form.gender2} onChange={change} options={options} predictive={false} />
55
55
  <TextArea id="text1" label="Text 1" value={form.text1} onChange={change} />
56
56
  <TextField id="date1" type="DATE" label="Date" value={form.date1} onChange={change} />
57
57
  </main>