ywana-core8 0.0.135 → 0.0.139

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.135",
3
+ "version": "0.0.139",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -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>
@@ -153,16 +153,16 @@ const TableSelector = (props) => {
153
153
  const { all, checked} = pageContext
154
154
 
155
155
  const count = `${checked.size}/${all.length}`
156
-
157
156
  const rows = all.filter(item => checked.has(item.id))
158
- console.log(count, rows)
159
-
160
157
  const table = {
161
158
  columns: [
162
159
  { id:"idMatricula", label: "ID Matricula" }
163
160
  ],
164
161
  rows: rows || []
165
162
  }
163
+ const buttons = actions.map(({label, action }) => {
164
+ return <Button label={label} raised action={() => action(rows)} />
165
+ })
166
166
 
167
167
  return (
168
168
  <div className="table-selector">
@@ -173,7 +173,7 @@ const TableSelector = (props) => {
173
173
  <DataTable {...table} />
174
174
  </main>
175
175
  <footer>
176
- { actions }
176
+ { buttons }
177
177
  </footer>
178
178
  </div>
179
179
  )
@@ -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, 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({ lose: () => {
72
- setOpen(false)
73
- }})
74
- }
82
+ site.changeFocus({
83
+ lose: () => {
84
+ setOpen(false)
85
+ }
86
+ })
87
+ }
75
88
  setOpen(!open)
76
89
  }
77
90
 
@@ -83,14 +96,20 @@ export const DropDown = (props) => {
83
96
  setOpen(false)
84
97
  }
85
98
 
99
+ const items = (open == true && Array.isArray(options)) ?
100
+ options
101
+ .filter(option => canFilter === false || filter.toUpperCase().indexOf(option.label.toUpperCase()) >= 0 )
102
+ .map(option => <li key={option.value} value={option.value}>{option.label}</li>)
103
+ : null
104
+
86
105
  return (
87
106
  <div className="dropdown">
88
- <TextField {...props} onClick={toggle} value={label} />
107
+ <TextField {...props} onClick={toggle} value={label} onChange={change} />
89
108
  <Icon icon="expand_more" clickable size="small" action={toggle} />
90
109
  {open == true ? (
91
110
  <menu>
92
111
  <ul onClick={select}>
93
- {Array.isArray(options) ? options.map(option => <li key={option.value} value={option.value}>{option.label}</li>) : null}
112
+ {items}
94
113
  </ul>
95
114
  </menu>
96
115
  ) : null}