ywana-core8 0.0.717 → 0.0.719

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.717",
3
+ "version": "0.0.719",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -19,9 +19,14 @@ export const CollectionContextProvider = (props) => {
19
19
  const [selected, setSelected] = useState(null)
20
20
 
21
21
  useEffect(() => {
22
- console.log("CONTEXT LOAD", filters, customFilters)
22
+ console.log("CONTEXT LOAD for Filters", filters)
23
23
  load()
24
- }, [filters, customFilters])
24
+ }, [filters])
25
+
26
+ useEffect(() => {
27
+ console.log("CONTEXT LOAD for CustomFilters", customFilters)
28
+ load()
29
+ }, [customFilters])
25
30
 
26
31
  async function load() {
27
32
 
@@ -52,14 +57,18 @@ export const CollectionContextProvider = (props) => {
52
57
  }
53
58
  }
54
59
 
55
- function addCustomFilter(id, filter) {
56
- setCustomFilters({ ...customFilters, [id]: filter })
60
+ async function addCustomFilter(id, filter) {
61
+ setCustomFilters( prevState => {
62
+ return { ...prevState, [id]: filter }
63
+ })
64
+ return
57
65
  }
58
66
 
59
- function removeCustomFilter(id) {
67
+ async function removeCustomFilter(id) {
60
68
  const next = { ...customFilters }
61
69
  delete next[id]
62
70
  setCustomFilters(next)
71
+ return
63
72
  }
64
73
 
65
74
  async function fetch(id) {
@@ -33,8 +33,8 @@ const CollectionPageTest = (prop) => {
33
33
  layout: "ide",
34
34
  title: <CustomTitle />,
35
35
  canFilter: true,
36
- customFilters: [<CustomFilter1 />, <CustomFilter2 />],
37
- filtersValue: { name: "333"},
36
+ customFilters: [<CustomFilters/>,],
37
+ filtersValue: {},
38
38
  listSearchBy: ["name"],
39
39
  listGroupBy: "name",
40
40
  listItemRenderer,
@@ -71,45 +71,28 @@ const CustomEditor = () => {
71
71
  )
72
72
  }
73
73
 
74
- const CustomFilter1 = (props) => {
75
-
76
- const context = useContext(CollectionContext)
77
- const [active, setActive] = useState(false)
78
-
79
- useEffect(() => {
80
- if (active) {
81
- context.addCustomFilter("custom1", filter)
82
- } else {
83
- context.removeCustomFilter("custom1")
84
- }
85
- }, [active])
86
-
87
- function change(id, value) {
88
- setActive(value)
89
- }
90
-
91
- function filter(all) {
92
- return all.filter(item => {
93
- return item.name.startsWith("1")
94
- })
95
- }
96
74
 
75
+ const CustomFilters = (props) => {
76
+
97
77
  return (
98
- <CheckBox id="custom1" value={active} label="Active" onChange={change} />
78
+ <>
79
+ <CustomFilter1 id="customfilter1" label="1"/>
80
+ <CustomFilter1 id="customfilter2" label="2"/>
81
+ </>
99
82
  )
100
83
  }
101
84
 
102
- const CustomFilter2 = (props) => {
85
+ const CustomFilter1 = (props) => {
103
86
 
104
- const { value = false } = props
87
+ const { id, label} = props
105
88
  const context = useContext(CollectionContext)
106
- const [active, setActive] = useState(value)
89
+ const [active, setActive] = useState(true)
107
90
 
108
- useEffect(() => {
91
+ useEffect(async () => {
109
92
  if (active) {
110
- context.addCustomFilter("custom2", filter)
93
+ await context.addCustomFilter(id, filter)
111
94
  } else {
112
- context.removeCustomFilter("custom2")
95
+ await context.removeCustomFilter(id)
113
96
  }
114
97
  }, [active])
115
98
 
@@ -119,11 +102,11 @@ const CustomFilter2 = (props) => {
119
102
 
120
103
  function filter(all) {
121
104
  return all.filter(item => {
122
- return item.name.endsWith("1")
105
+ return item.name.startsWith("1")
123
106
  })
124
107
  }
125
108
 
126
109
  return (
127
- <CheckBox id="custom1" value={active} label="Locked" onChange={change} />
110
+ <CheckBox id={id} value={active} label={label} onChange={change} />
128
111
  )
129
- }
112
+ }
@@ -50,7 +50,7 @@ export const Wizard = (props) => {
50
50
  })
51
51
  }
52
52
 
53
- const currentStep = React.cloneElement(steps[current], { ref: stepRef, onChange: validate })
53
+ const currentStep = React.cloneElement(steps[current], { ref: stepRef, onChange: validate, next: next })
54
54
  const nextButton = current < steps.length - 1 ? <Button label="Siguiente" action={next} raised disabled={!valid}/> : <Button label="Finish" action={finish} disabled={!valid}/>
55
55
  const prevButton = current > 0 ? <Button label="Atrás" action={prev} /> : null
56
56
 
@@ -7,12 +7,16 @@ export const Step1 = forwardRef((props, ref) => {
7
7
 
8
8
  const wizardContext = React.useContext(WizardContext)
9
9
  const { form } = wizardContext
10
- const { onChange } = props
10
+ const { next, onChange } = props
11
11
 
12
12
  useEffect(() => {
13
13
  onChange(form, isValid(form))
14
14
  }, [form])
15
15
 
16
+ useEffect(() => {
17
+ if (form.name && form.name === "ok" && next) next()
18
+ }, [form])
19
+
16
20
  function changeForm(id, value) {
17
21
  wizardContext.setForm({ ...form, [id]: value })
18
22
  }