ywana-core8 0.0.653 → 0.0.654
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 +74 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +30 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +74 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +74 -0
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/incubator/index.js +1 -0
- package/src/incubator/wizard.css +30 -0
- package/src/incubator/wizard.js +57 -0
- package/src/incubator/wizard.test.js +16 -0
- package/src/index.js +3 -0
package/package.json
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export {Wizard } from './wizard'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
.wizard {
|
2
|
+
border: solid 1px red;
|
3
|
+
}
|
4
|
+
|
5
|
+
.wizard-steps {
|
6
|
+
display: flex;
|
7
|
+
border-bottom: solid 1px var(--divider-color);
|
8
|
+
}
|
9
|
+
|
10
|
+
.wizard-step {
|
11
|
+
flex: 1;
|
12
|
+
padding: 0 .5rem;
|
13
|
+
display: flex;
|
14
|
+
align-items: center;
|
15
|
+
}
|
16
|
+
|
17
|
+
.wizard-step:not(:last-child) {
|
18
|
+
border-right: solid 1px var(--divider-color);
|
19
|
+
}
|
20
|
+
|
21
|
+
.wizard-content {
|
22
|
+
min-height: 10rem;
|
23
|
+
}
|
24
|
+
|
25
|
+
.wizard-actions {
|
26
|
+
border-top: solid 1px var(--divider-color);
|
27
|
+
display: flex;
|
28
|
+
justify-content: space-between;
|
29
|
+
padding: .5rem;
|
30
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { Icon } from '../html'
|
3
|
+
import { Button } from '../html/button'
|
4
|
+
import './wizard.css'
|
5
|
+
|
6
|
+
export const Wizard = (props) => {
|
7
|
+
|
8
|
+
const { steps = [], init = 0, onClose } = props
|
9
|
+
const [current=0, setCurrent] = useState(init)
|
10
|
+
|
11
|
+
function prev() {
|
12
|
+
if (current > 0) setCurrent(current - 1)
|
13
|
+
}
|
14
|
+
|
15
|
+
function next() {
|
16
|
+
const step = steps[current]
|
17
|
+
if (step.onComplete) {
|
18
|
+
step.onComplete(() => { setCurrent(current + 1) })
|
19
|
+
} else {
|
20
|
+
setCurrent(current + 1)
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
function finish() {
|
25
|
+
const step = steps[current]
|
26
|
+
if (step.onComplete) step.onComplete(() => {
|
27
|
+
if (onClose) onClose()
|
28
|
+
})
|
29
|
+
}
|
30
|
+
|
31
|
+
return (
|
32
|
+
<div className="wizard">
|
33
|
+
<div className="wizard-steps">
|
34
|
+
{steps.map((step, index) => {
|
35
|
+
const active = index === current
|
36
|
+
const done = index < current
|
37
|
+
return (
|
38
|
+
<div key={index} className="wizard-step">
|
39
|
+
<div className="wizard-step-icon">
|
40
|
+
{done && <Icon icon="check" />}
|
41
|
+
{active && <Icon icon="play_arrow" />}
|
42
|
+
</div>
|
43
|
+
<div className="wizard-step-label">{step.label}</div>
|
44
|
+
</div>
|
45
|
+
)
|
46
|
+
})}
|
47
|
+
</div>
|
48
|
+
<div className="wizard-content">
|
49
|
+
{steps[current].content}
|
50
|
+
</div>
|
51
|
+
<div className="wizard-actions">
|
52
|
+
<Button label="Anterior" disabled={current === 0} action={prev} />
|
53
|
+
{ current < steps.length -1 ? <Button label="Siguiente" disabled={current === steps.length - 1} action={next} /> : <Button label="Finalizar" action={finish} raised /> }
|
54
|
+
</div>
|
55
|
+
</div>
|
56
|
+
)
|
57
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { Wizard } from './wizard'
|
3
|
+
|
4
|
+
const WizardTest = (prop) => {
|
5
|
+
|
6
|
+
return (
|
7
|
+
<>sa
|
8
|
+
<Wizard steps={[
|
9
|
+
{ label: "Paso 1", content: <div>Contenido 1</div>, onComplete: (onSuccess, onError) => { console.log("complete 1"); onSuccess() } },
|
10
|
+
{ label: "Paso 2", content: <div>Contenido 2</div>, onComplete: (onSuccess, onError) => { console.log("complete 2"); onSuccess() } },
|
11
|
+
{ label: "Paso 3", content: <div>Contenido 3</div>, onComplete: (onSuccess, onError) => { console.log("complete 3"); onSuccess() } },
|
12
|
+
{ label: "Paso 4", content: <div>Contenido 4</div>, onComplete: (onSuccess, onError) => { console.log("complete 4"); onSuccess() } },
|
13
|
+
]} init={0} />
|
14
|
+
</>
|
15
|
+
)
|
16
|
+
}
|
package/src/index.js
CHANGED
@@ -7,4 +7,7 @@ export * from './widgets'
|
|
7
7
|
export * from './site'
|
8
8
|
export * from './domain'
|
9
9
|
|
10
|
+
|
11
|
+
export * from './incubator'
|
12
|
+
|
10
13
|
export const isFunction = value => value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
|