1.7.0 • Published 5 months ago

@marianmeres/wizard v1.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@marianmeres/wizard

Utility for high level management of wizard data. Agnostic of the actual business or rendering. Store compatible.

Install

$ npm i @marianmeres/wizard

Example usage

const wizard = createWizardStore('foo', {
    steps: [
        { label: 'one', foo: 123 },
        {
            label: 'two',
            canGoNext: false,
            preNext: async (data, { context, wizard, set }) => {
                set({ canGoNext: data.hey === context.hey })
            },
            prePrevious: async (data, { set }) => {
                set({ canGoNext: false, data: {} });
            },
            preReset: async (data, { context, wizard, set }) => {
                // ...
            }
        },
        { label: 'three' },
        { label: 'four' },
    ],
    context: { hey: 'ho' },
    onDone: async ({ steps, context, set }) => '...', // will be called on the last .next()
});

wizard.subscribe(async ({ step, steps }) => {
    // step props
    const { label, index, data, canGoNext, error, isFirst, isLast } = step;

    // do something here...

    // step api
    step.set(/*{ data, error, canGoNext }*/)

    await step.next(data);
    await step.previous();
});

// wizard api
wizard.context; // reference to the context object
await wizard.next(/*data*/);
await wizard.previous();
await wizard.reset();
await wizard.goto(index, stepsData);

See tests for more...

1.7.0

5 months ago

1.2.0

7 months ago

1.1.0

7 months ago

1.6.1

6 months ago

1.6.0

6 months ago

1.5.0

6 months ago

1.4.1

7 months ago

1.4.0

7 months ago

1.3.1

7 months ago

1.3.0

7 months ago

1.0.0

1 year ago

0.2.8

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago