ywana-core8 0.0.136 → 0.0.140
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 +44 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +12 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +44 -11
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +44 -11
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/ContentEditor.js +1 -1
- package/src/html/textfield-outlined.css +6 -0
- package/src/html/textfield.css +6 -0
- package/src/html/textfield.js +38 -19
package/package.json
CHANGED
@@ -244,7 +244,7 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
|
|
244
244
|
<div className='field-editor string-editor'>
|
245
245
|
{
|
246
246
|
format === FORMATS.DATE ? <TextField outlined={outlined} id={id} type="date" label={label} value={value} onChange={change} readOnly={!editable} /> :
|
247
|
-
options ? <DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} /> :
|
247
|
+
options ? <DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} canFilter={true}/> :
|
248
248
|
<TextField outlined={outlined} id={id} label={label} value={value} onChange={change} readOnly={!editable} />
|
249
249
|
}
|
250
250
|
</div>
|
@@ -39,6 +39,12 @@
|
|
39
39
|
-webkit-transition: 0.2s ease all;
|
40
40
|
}
|
41
41
|
|
42
|
+
.textfield-outlined input[type="date"] ~ label {
|
43
|
+
top: .3rem;
|
44
|
+
font-size: .8rem;
|
45
|
+
color: var(--primary-color);
|
46
|
+
}
|
47
|
+
|
42
48
|
/* active state */
|
43
49
|
.textfield-outlined > input:focus ~ label,
|
44
50
|
.textfield-outlined > input:valid ~ label {
|
package/src/html/textfield.css
CHANGED
@@ -47,6 +47,12 @@ input:read-only {
|
|
47
47
|
border: 0px !important;
|
48
48
|
}
|
49
49
|
|
50
|
+
.textfield input[type="date"] ~ label {
|
51
|
+
top: .3rem;
|
52
|
+
font-size: .8rem;
|
53
|
+
color: var(--primary-color);
|
54
|
+
}
|
55
|
+
|
50
56
|
/* active state */
|
51
57
|
input:read-only ~ label,
|
52
58
|
.textfield > input:focus ~ label,
|
package/src/html/textfield.js
CHANGED
@@ -11,7 +11,7 @@ import './textfield.css'
|
|
11
11
|
export const TextField = (props) => {
|
12
12
|
|
13
13
|
const site = useContext(SiteContext)
|
14
|
-
const { id, type = 'text', label, placeholder, value, outlined, readOnly=false, onChange, onEnter, onClick } = props
|
14
|
+
const { id, type = 'text', label, placeholder, value, outlined, readOnly = false, onChange, onEnter, onClick } = props
|
15
15
|
|
16
16
|
function onKeyPress(event) {
|
17
17
|
var key = event.charCode ? event.charCode : event.keyCode ? event.keyCode : 0;
|
@@ -29,9 +29,11 @@ export const TextField = (props) => {
|
|
29
29
|
|
30
30
|
function focus() {
|
31
31
|
if (site) {
|
32
|
-
site.changeFocus({
|
33
|
-
|
34
|
-
|
32
|
+
site.changeFocus({
|
33
|
+
lose: () => {
|
34
|
+
// DO NOTHING
|
35
|
+
}
|
36
|
+
})
|
35
37
|
}
|
36
38
|
}
|
37
39
|
|
@@ -41,9 +43,9 @@ export const TextField = (props) => {
|
|
41
43
|
const labelTxt = <Text>{label}</Text>
|
42
44
|
return (
|
43
45
|
<div className={`${style}`} onClick={onClick}>
|
44
|
-
<input id={id} type={type} placeholder={placeholder} value={value} required onChange={change} onKeyDown={onKeyPress} onFocus={focus} readOnly={readOnly} onfocus="(this.type='date')" onfocusout="(this.type='text')"/>
|
46
|
+
<input id={id} type={type} placeholder={placeholder} value={value} required onChange={change} onKeyDown={onKeyPress} onFocus={focus} readOnly={readOnly} onfocus="(this.type='date')" onfocusout="(this.type='text')" />
|
45
47
|
<span className="bar"></span>
|
46
|
-
{
|
48
|
+
{label ? <label>{labelTxt}</label> : null}
|
47
49
|
</div>
|
48
50
|
)
|
49
51
|
}
|
@@ -54,9 +56,10 @@ export const TextField = (props) => {
|
|
54
56
|
export const DropDown = (props) => {
|
55
57
|
|
56
58
|
const site = useContext(SiteContext)
|
57
|
-
const { id, options = [], value, onChange } = props
|
59
|
+
const { id, options = [], value, onChange, canFilter = false } = props
|
58
60
|
const [open, setOpen] = useState(false)
|
59
61
|
const [label, setLabel] = useState()
|
62
|
+
const [filter, setFilter] = useState()
|
60
63
|
|
61
64
|
useEffect(() => {
|
62
65
|
if (Array.isArray(options)) {
|
@@ -65,13 +68,23 @@ export const DropDown = (props) => {
|
|
65
68
|
}
|
66
69
|
}, [value])
|
67
70
|
|
71
|
+
function change(id, value) {
|
72
|
+
console.log('dropdown change > canFilter:', canFilter, id, value)
|
73
|
+
if (canFilter) {
|
74
|
+
setFilter(value)
|
75
|
+
} else {
|
76
|
+
if (onChange) onChange(id, value)
|
77
|
+
}
|
78
|
+
}
|
68
79
|
|
69
80
|
function toggle() {
|
70
81
|
if (site) {
|
71
|
-
site.changeFocus({
|
72
|
-
|
73
|
-
|
74
|
-
|
82
|
+
site.changeFocus({
|
83
|
+
lose: () => {
|
84
|
+
setOpen(false)
|
85
|
+
}
|
86
|
+
})
|
87
|
+
}
|
75
88
|
setOpen(!open)
|
76
89
|
}
|
77
90
|
|
@@ -83,17 +96,23 @@ export const DropDown = (props) => {
|
|
83
96
|
setOpen(false)
|
84
97
|
}
|
85
98
|
|
99
|
+
function renderOptions() {
|
100
|
+
const canShow = open == true && Array.isArray(options)
|
101
|
+
if (canShow) {
|
102
|
+
const filterActive = canFilter && label && label.length > 0
|
103
|
+
const items = filterActive ? options.filter(option => canFilter === false || filter.toUpperCase().indexOf(option.label.toUpperCase()) >= 0) : options
|
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
|
+
}
|
110
|
+
|
86
111
|
return (
|
87
112
|
<div className="dropdown">
|
88
|
-
<TextField {...props} onClick={toggle} value={label} />
|
113
|
+
<TextField {...props} onClick={toggle} value={label} onChange={change} />
|
89
114
|
<Icon icon="expand_more" clickable size="small" action={toggle} />
|
90
|
-
{
|
91
|
-
<menu>
|
92
|
-
<ul onClick={select}>
|
93
|
-
{Array.isArray(options) ? options.map(option => <li key={option.value} value={option.value}>{option.label}</li>) : null}
|
94
|
-
</ul>
|
95
|
-
</menu>
|
96
|
-
) : null}
|
115
|
+
{renderOptions()}
|
97
116
|
</div>
|
98
117
|
)
|
99
118
|
}
|