ywana-core8 0.0.659 → 0.0.660
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 +9 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +9 -7
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +9 -7
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/incubator/wizard.js +5 -5
- package/src/incubator/wizard.test.js +16 -2
package/package.json
CHANGED
package/src/incubator/wizard.js
CHANGED
@@ -11,20 +11,20 @@ export const WizardContext = React.createContext({})
|
|
11
11
|
/**
|
12
12
|
* Wizard Provider
|
13
13
|
*/
|
14
|
-
export const WizardProvider = (
|
14
|
+
export const WizardProvider = (props) => {
|
15
15
|
|
16
|
-
const [form, setForm] = useState(
|
16
|
+
const [form, setForm] = useState(props.form)
|
17
17
|
|
18
18
|
return (
|
19
19
|
<WizardContext.Provider value={{ form, setForm }}>
|
20
|
-
{children}
|
20
|
+
{props.children}
|
21
21
|
</WizardContext.Provider>
|
22
22
|
)
|
23
23
|
}
|
24
24
|
|
25
25
|
export const Wizard = (props) => {
|
26
26
|
|
27
|
-
const { init = 0, onClose, children } = props
|
27
|
+
const { form = {}, init = 0, onClose, children } = props
|
28
28
|
const [current = 0, setCurrent] = useState(init)
|
29
29
|
|
30
30
|
const steps = React.Children.toArray(children)
|
@@ -51,7 +51,7 @@ export const Wizard = (props) => {
|
|
51
51
|
}, [current])
|
52
52
|
|
53
53
|
return (
|
54
|
-
<WizardProvider >
|
54
|
+
<WizardProvider form={form}>
|
55
55
|
<div className="wizard">
|
56
56
|
<div className="wizard-steps">
|
57
57
|
{steps.map((step, index) => {
|
@@ -1,10 +1,18 @@
|
|
1
1
|
import React, { forwardRef, useImperativeHandle, useState } from 'react'
|
2
|
-
import {
|
2
|
+
import { Property, TextField } from '../html'
|
3
|
+
import { Wizard, WizardContext} from './wizard'
|
3
4
|
|
4
5
|
export const Step1 = forwardRef((props, ref) => {
|
5
6
|
|
6
7
|
useImperativeHandle(ref, () => ({ onComplete }))
|
7
8
|
|
9
|
+
const wizardContext = React.useContext(WizardContext)
|
10
|
+
const { form } = wizardContext
|
11
|
+
|
12
|
+
function changeForm(id, value) {
|
13
|
+
wizardContext.setForm({ ...form, [id]: value })
|
14
|
+
}
|
15
|
+
|
8
16
|
function onComplete (onSuccess, onError) {
|
9
17
|
console.log("onComplete", props.label)
|
10
18
|
onSuccess()
|
@@ -13,6 +21,7 @@ export const Step1 = forwardRef((props, ref) => {
|
|
13
21
|
return (
|
14
22
|
<div>
|
15
23
|
<h1>Step</h1>
|
24
|
+
<TextField id="name" label="Name" value={form.name} onChange={changeForm} />
|
16
25
|
</div>
|
17
26
|
)
|
18
27
|
})
|
@@ -20,9 +29,14 @@ export const Step1 = forwardRef((props, ref) => {
|
|
20
29
|
|
21
30
|
const WizardTest = (prop) => {
|
22
31
|
|
32
|
+
const initForm = {
|
33
|
+
name: "John",
|
34
|
+
description: "Test Description"
|
35
|
+
}
|
36
|
+
|
23
37
|
return (
|
24
38
|
<>
|
25
|
-
<Wizard init={0} >
|
39
|
+
<Wizard init={0} form={initForm} >
|
26
40
|
<Step1 label="Paso 1"/>
|
27
41
|
<Step1 label="Paso 2"/>
|
28
42
|
<Step1 label="Paso 3"/>
|