ywana-core8 0.0.657 → 0.0.659

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.657",
3
+ "version": "0.0.659",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -3,11 +3,30 @@ import { Icon } from '../html'
3
3
  import { Button } from '../html/button'
4
4
  import './wizard.css'
5
5
 
6
+ /**
7
+ * Wizard Context
8
+ */
9
+ export const WizardContext = React.createContext({})
10
+
11
+ /**
12
+ * Wizard Provider
13
+ */
14
+ export const WizardProvider = ({ children }) => {
15
+
16
+ const [form, setForm] = useState(context)
17
+
18
+ return (
19
+ <WizardContext.Provider value={{ form, setForm }}>
20
+ {children}
21
+ </WizardContext.Provider>
22
+ )
23
+ }
24
+
6
25
  export const Wizard = (props) => {
7
26
 
8
- const { init = 0, onClose, children } = props
9
- const [current=0, setCurrent] = useState(init)
10
-
27
+ const { init = 0, onClose, children } = props
28
+ const [current = 0, setCurrent] = useState(init)
29
+
11
30
  const steps = React.Children.toArray(children)
12
31
  const stepRef = useRef()
13
32
 
@@ -17,7 +36,7 @@ export const Wizard = (props) => {
17
36
 
18
37
  async function next() {
19
38
  await stepRef.current.onNext(() => {
20
- setCurrent(current + 1)
39
+ setCurrent(current + 1)
21
40
  })
22
41
  }
23
42
 
@@ -32,30 +51,32 @@ export const Wizard = (props) => {
32
51
  }, [current])
33
52
 
34
53
  return (
35
- <div className="wizard">
36
- <div className="wizard-steps">
37
- {steps.map((step, index) => {
38
- const active = index === current
39
- const done = index < current
40
- return (
41
- <div key={index} className="wizard-step">
42
- <div className="wizard-step-icon">
43
- {done && <Icon icon="check" />}
44
- {active && <Icon icon="play_arrow" />}
54
+ <WizardProvider >
55
+ <div className="wizard">
56
+ <div className="wizard-steps">
57
+ {steps.map((step, index) => {
58
+ const active = index === current
59
+ const done = index < current
60
+ return (
61
+ <div key={index} className="wizard-step">
62
+ <div className="wizard-step-icon">
63
+ {done && <Icon icon="check" />}
64
+ {active && <Icon icon="play_arrow" />}
65
+ </div>
66
+ <div className="wizard-step-label">{step.props.label}</div>
45
67
  </div>
46
- <div className="wizard-step-label">{step.props.label}</div>
47
- </div>
48
- )
49
- })}
50
- </div>
51
- <div className="wizard-content">
52
- {currentStep}
53
- </div>
54
- <div className="wizard-actions">
55
- <Button label="Anterior" disabled={current === 0} action={prev} />
56
- { current < steps.length -1 ? <Button label="Siguiente" disabled={stepRef && stepRef.current.isValid()} action={next} /> : <Button label="Finalizar" disabled={stepRef && stepRef.current.isValid()} action={finish} raised /> }
68
+ )
69
+ })}
70
+ </div>
71
+ <div className="wizard-content">
72
+ {currentStep}
73
+ </div>
74
+ <div className="wizard-actions">
75
+ <Button label="Anterior" disabled={current === 0} action={prev} />
76
+ {current < steps.length - 1 ? <Button label="Siguiente" disabled={stepRef.current && stepRef.current.isValid()} action={next} /> : <Button label="Finalizar" disabled={stepRef.current && stepRef.current.isValid()} action={finish} raised />}
77
+ </div>
57
78
  </div>
58
- </div>
79
+ </WizardProvider>
59
80
  )
60
81
  }
61
82