ywana-core8 0.0.137 → 0.0.138

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.137",
3
+ "version": "0.0.138",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -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 {
@@ -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,
@@ -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({ lose: () => {
33
- // DO NOTHING
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
- { label ? <label>{labelTxt}</label> : null }
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, srtFilter] = useState()
60
63
 
61
64
  useEffect(() => {
62
65
  if (Array.isArray(options)) {
@@ -65,13 +68,22 @@ export const DropDown = (props) => {
65
68
  }
66
69
  }, [value])
67
70
 
71
+ function change(id, value) {
72
+ if (canFilter) {
73
+ setFilter(value)
74
+ } else {
75
+ if (onChange) onChange(id, value)
76
+ }
77
+ }
68
78
 
69
79
  function toggle() {
70
80
  if (site) {
71
- site.changeFocus({ lose: () => {
72
- setOpen(false)
73
- }})
74
- }
81
+ site.changeFocus({
82
+ lose: () => {
83
+ setOpen(false)
84
+ }
85
+ })
86
+ }
75
87
  setOpen(!open)
76
88
  }
77
89
 
@@ -83,14 +95,20 @@ export const DropDown = (props) => {
83
95
  setOpen(false)
84
96
  }
85
97
 
98
+ const items = (open == true && Array.isArray(options)) ?
99
+ options
100
+ .filter(option => canFilter === false || filter.toUpperCase().indexOf(option.label.toUpperCase()) >= 0 )
101
+ .map(option => <li key={option.value} value={option.value}>{option.label}</li>)
102
+ : null
103
+
86
104
  return (
87
105
  <div className="dropdown">
88
- <TextField {...props} onClick={toggle} value={label} />
106
+ <TextField {...props} onClick={toggle} value={label} onChange={change} />
89
107
  <Icon icon="expand_more" clickable size="small" action={toggle} />
90
108
  {open == true ? (
91
109
  <menu>
92
110
  <ul onClick={select}>
93
- {Array.isArray(options) ? options.map(option => <li key={option.value} value={option.value}>{option.label}</li>) : null}
111
+ {items}
94
112
  </ul>
95
113
  </menu>
96
114
  ) : null}