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/dist/index.cjs +31 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +31 -8
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +31 -8
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/incubator/wizard.js +47 -26
package/package.json
CHANGED
package/src/incubator/wizard.js
CHANGED
@@ -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
|
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
|
-
<
|
36
|
-
<div className="wizard
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
<div className="wizard-step
|
43
|
-
|
44
|
-
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
</
|
79
|
+
</WizardProvider>
|
59
80
|
)
|
60
81
|
}
|
61
82
|
|