ywana-core8 0.0.567 → 0.0.570

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.567",
3
+ "version": "0.0.570",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -29,7 +29,7 @@ export const CollectionPage = (props) => {
29
29
 
30
30
  const [pageContext, setPageContext] = useContext(PageContext)
31
31
  const context = CollectionContext(url, field, host, page, fetching)
32
- const [showFilter, setShowFilter] = useState(true)
32
+ const [showFilter, setShowFilter] = useState(false)
33
33
 
34
34
  useEffect(async () => {
35
35
  await context.load()
@@ -371,8 +371,13 @@ export const CollectionContext = (url, field, host, page, fetching) => {
371
371
  return {
372
372
 
373
373
  all: [],
374
+ filters: {},
374
375
  selected: null,
375
376
 
377
+ changeFilters(filters) {
378
+ this.filters = filters
379
+ },
380
+
376
381
  async load() {
377
382
  try {
378
383
  const data = await API.all(null, page);
@@ -150,12 +150,13 @@ export const DropDown = (props) => {
150
150
  if (!readOnly) setOpen(!open)
151
151
  }
152
152
 
153
- function select(event) {
154
- const next = event.target.getAttribute("value")
153
+ function select(value) {
154
+ const next = value
155
155
  const option = options.find(option => option.value === next)
156
156
  setOpen(false)
157
157
  const label = verbose ? option.label : ""
158
158
  setLabel(label)
159
+ console.log("dd.select", value)
159
160
  if (onChange) onChange(id, next)
160
161
  }
161
162
 
@@ -168,8 +169,8 @@ export const DropDown = (props) => {
168
169
  if (canShow) {
169
170
  const filterActive = predictive === true && label && label.length > 0
170
171
  const items = filterActive ? options.filter(option => option.label.toUpperCase().indexOf(label.toUpperCase()) >= 0) : options
171
- const lis = items.map(option => <li key={option.value} value={option.value}><Text>{option.label}</Text></li>)
172
- return <menu><ul onMouseDown={select}>{lis}</ul></menu>
172
+ const lis = items.map(option => <li key={option.value} value={option.value} onClick={() => select(option.value)}><Text>{option.label}</Text></li>)
173
+ return <menu><ul>{lis}</ul></menu>
173
174
  } else {
174
175
  return null
175
176
  }
@@ -30,6 +30,7 @@ const TextFieldTest = (prop) => {
30
30
  <>
31
31
  <DropDown id="b1" label="Boolean1" onChange={change} options={options2} value={form.b1} />
32
32
  <TokenField id="token1" label="Tokens" onChange={change} />
33
+ <TokenField id="token2" label="Tokens DropDown" onChange={change} options={options} tokens={form.token2}/>
33
34
  <TextField id="name" label="Name" value={form.name} onChange={change} />
34
35
  <DropDown id="gender1" label="Dropdown 1" value={form.gender1} onChange={change} options={options} predictive={false}/>
35
36
  <DropDown id="gender2" label="Dropdown 2" value={form.gender2} onChange={change} options={options} predictive={true}/>
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useRef, useState } from 'react'
1
+ import React, { useState } from 'react'
2
2
  import { Icon } from './icon';
3
3
  import { Text } from './text';
4
4
  import { DropDown } from './textfield';
@@ -24,6 +24,7 @@ export const TokenField = ({ id, label, tokens = [], readOnly, options, onChange
24
24
 
25
25
  function changeDropDown(fid, value) {
26
26
  const next = Array.isArray(tokens) ? tokens.concat(value) : [value]
27
+ console.log("next", next)
27
28
  if (onChange) onChange(id, next)
28
29
  setValue('')
29
30
  }
@@ -33,9 +34,11 @@ export const TokenField = ({ id, label, tokens = [], readOnly, options, onChange
33
34
  event.preventDefault()
34
35
  event.stopPropagation()
35
36
  const token = event.target.value
36
- const next = Array.isArray(tokens) ? tokens.concat(token) : [token]
37
- if (onChange) onChange(id, next)
38
- setValue('')
37
+ if (token && token.length > 0) {
38
+ const next = Array.isArray(tokens) ? tokens.concat(token) : [token]
39
+ if (onChange) onChange(id, next)
40
+ setValue('')
41
+ }
39
42
  }
40
43
 
41
44
  if (value === '' && tokens.length > 0 && event.key === 'Backspace') {
@@ -45,7 +48,7 @@ export const TokenField = ({ id, label, tokens = [], readOnly, options, onChange
45
48
  }
46
49
 
47
50
  const tks = Array.isArray(tokens) ? tokens : []
48
-
51
+ console.log("render", tks)
49
52
  return (
50
53
  <div className='tokenField'>
51
54
  <label>{label}</label>
@@ -93,13 +93,13 @@ export const Planner = ({ title, events = [], lanes = [], navigation = true, onS
93
93
  {navigation ? (
94
94
  <Header title={label}>
95
95
  &nbsp;&nbsp;
96
- <Button label="This Week" outlined action={showThisWeek}/>
96
+ <Button label="Esta Semana" outlined action={showThisWeek}/>
97
97
  <Icon icon="chevron_right" clickable action={next} />
98
- <TextField id="to" type="date" label="To" value={to} onChange={(id, value) => setTo(value)} />
98
+ <TextField id="to" type="date" label="Hasta" value={to} onChange={(id, value) => setTo(value)} />
99
99
  <div className="expand"></div>
100
- <DropDown id="ranges" label="Date Range" options={DATE_RANGE} value={dateRange} onChange={(id, value) => setDateRange(value)} />
100
+ <DropDown id="ranges" label="Rango" options={DATE_RANGE} value={dateRange} onChange={(id, value) => setDateRange(value)} />
101
101
  <div className="expand"></div>
102
- <TextField id="from" type="date" label="From" value={from} onChange={(id, value) => setFrom(value)} />
102
+ <TextField id="from" type="date" label="Desde" value={from} onChange={(id, value) => setFrom(value)} />
103
103
  <Icon icon="chevron_left" clickable action={prev} />
104
104
  </Header>
105
105
  ) : null}