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/dist/index.cjs +17 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +17 -12
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +17 -12
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/textfield.js +12 -14
- package/src/site/site.js +4 -0
- package/src/site/site.test.js +1 -1
package/package.json
CHANGED
package/src/html/textfield.js
CHANGED
@@ -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
|
42
|
-
if (
|
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={
|
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
|
-
{
|
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
|
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
|
-
|
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
package/src/site/site.test.js
CHANGED
@@ -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.
|
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>
|