ywana-core8 0.0.369 → 0.0.372
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 +40 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +40 -36
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +40 -36
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/textfield.js +12 -15
- package/src/http/client.js +5 -4
- 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>
|
@@ -158,7 +151,6 @@ export const DropDown = (props) => {
|
|
158
151
|
}
|
159
152
|
|
160
153
|
function select(event) {
|
161
|
-
console.log(event)
|
162
154
|
const next = event.target.getAttribute("value")
|
163
155
|
const option = options.find(option => option.value === next)
|
164
156
|
if (onChange) onChange(id, next)
|
@@ -166,13 +158,18 @@ export const DropDown = (props) => {
|
|
166
158
|
setOpen(false)
|
167
159
|
}
|
168
160
|
|
161
|
+
function blur() {
|
162
|
+
console.log("BLUR DD")
|
163
|
+
site.clearFocus()
|
164
|
+
}
|
165
|
+
|
169
166
|
function renderOptions() {
|
170
167
|
const canShow = open == true && Array.isArray(options)
|
171
168
|
if (canShow) {
|
172
169
|
const filterActive = predictive === true && label && label.length > 0
|
173
170
|
const items = filterActive ? options.filter(option => option.label.toUpperCase().indexOf(label.toUpperCase()) >= 0) : options
|
174
171
|
const lis = items.map(option => <li key={option.value} value={option.value}>{option.label}</li>)
|
175
|
-
return <menu><ul
|
172
|
+
return <menu><ul onMouseDown={select}>{lis}</ul></menu>
|
176
173
|
} else {
|
177
174
|
return null
|
178
175
|
}
|
@@ -180,7 +177,7 @@ export const DropDown = (props) => {
|
|
180
177
|
|
181
178
|
return (
|
182
179
|
<div className="dropdown">
|
183
|
-
|
180
|
+
<TextField {...props} onClick={toggle} value={label} onChange={change} onBlur={blur} readOnly={!predictive}/>
|
184
181
|
{!readOnly ? <Icon icon="expand_more" clickable size="small" action={toggle} /> : null }
|
185
182
|
{renderOptions()}
|
186
183
|
</div>
|
package/src/http/client.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
async function fetchAsync(method, URL, body = null, token) {
|
1
|
+
async function fetchAsync(method, URL, body = null, token, headers) {
|
2
2
|
|
3
3
|
console.log('FETCH', method, URL)
|
4
4
|
|
@@ -8,7 +8,8 @@ async function fetchAsync(method, URL, body = null, token) {
|
|
8
8
|
headers: {
|
9
9
|
"Accept": "application/json",
|
10
10
|
"Content-Type": "application/json",
|
11
|
-
"x-access-token": token
|
11
|
+
"x-access-token": token,
|
12
|
+
...headers
|
12
13
|
},
|
13
14
|
body
|
14
15
|
}
|
@@ -39,9 +40,9 @@ export const HTTPClient = (domain, securityCtx) => {
|
|
39
40
|
return fetchAsync('GET', domain + URL, undefined, token);
|
40
41
|
},
|
41
42
|
|
42
|
-
POST: (URL, body) => {
|
43
|
+
POST: (URL, body, headers) => {
|
43
44
|
const token = securityCtx ? securityCtx.token() : null;
|
44
|
-
return fetchAsync('POST', domain + URL, body, token);
|
45
|
+
return fetchAsync('POST', domain + URL, body, token, headers);
|
45
46
|
},
|
46
47
|
|
47
48
|
PUT: (URL, body) => {
|
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>
|