1.0.4 • Published 3 years ago

lightning-wizard-oss v1.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Salesforce Wizard Component

<template>
    <lightning-wizard header="My Account Wizard" variant="base" current-step="step-1">
        <lightning-wizard-step label="Enter Account" name="step-1">
            <lightning-input label="Account Name"></lightning-input>
            <lightning-input label="Account Type"></lightning-input>
        </lightning-wizard-step>
        <lightning-wizard-step label="Add Contact" name="step-2" before-change={validate} hide-next-button="false">
            <lightning-input label="Name"></lightning-input>
            <lightning-input label="Title"></lightning-input>

            <lightning-button slot="actions" label="Skip" onclick={skipCreateContact}>
        </lightning-wizard-step>
        <template if:true={shouldSync}>
            <lightning-wizard-step label="Sync with another system" name="step-3">
            </lightning-wizard-step>
        </template>
    </lightning-wizard>
</template>

About

This Web Component is a Web Component built from Lightning Wizard intended to use within a Lightning Web Component OSS Project.

It aims to provide a way to programatically build flows with Salesforce Flow styles and functionality, having full control of the wizard behavior in any scenario.

Features

  • Define wizard with Lightning Web components declaratively.
  • Override standard Navigation buttons definining specific step actions.
  • Customize flow using JavaScript function for step validation and post-processing.
  • Modify the flow steps using standard LWC templates.

Description

A lightning-wizard display a guided flow with multiple steps, only one is visible at a time. The progress is shown on the header along with a current step indicator.

Usage

As referenced on last LWC RFC, include the npm reference within your lwc.config.json or directly on your package.json.

At this moment, lightning-wizard does not work with native Shadow DOM. It requires Synthetic Shadow DOM. Import @lwc/synthetic-shadow before using the component.

package.json example

{
    "lwc": {
        "modules": [
            { 
                "npm": "lightning-wizard-oss" 
            }
        ]
    }
}

lwc.config.json example_

{
    "modules": [
        { 
            "npm": "lightning-wizard-oss" 
        }
    ]
}

Check the examples folder for implementation details.

Specification

lightning-wizard

Attributes

NameTypeAccessRequiredDefaultDescription
variantstringglobalbaseWizard style. Valid values are base, base-shaded and path.
previous-labelstringglobalPreviousPrevious button label.
next-labelstringglobalNextNext button label.
finish-labelstringglobalFinishFinish button label.
headerstringglobalHeader text shown on wizard. Leave blank for not displaying header.
current-stepstringglobalSets the current step of the wizard. Defaults to first lightning-wizard-step on the markup if null.

Slots

NameDescription
headerPlaceholder for wizard header. Overrides the header attribute set on the component.
defaultPlaceholder for lightning-wizard-step. Defines the wizard flow.

Custom Events

change

The event fired when the wizard advances or goes back following the configured step flow. An external change by setting the attribute current-step does not emit this event.

The change event returns the following parameters.

ParameterTypeDescription
currentStepstringThe step name the wizard is moving to.
oldStepstringThe step name the wizard is moving from

The change event properties are as follows.

PropertyValueDescription
bubblesfalseThis event does not bubble up through the DOM.
cancelablefalseThis event has no default behavior that can be canceled. You can't call preventDefault() on this event.
composedfalseThis event does not propagate outside of the component in which it was dispatched.
complete

The event fired when the wizard finishes and the user clicks on Finish button.

The complete event properties are as follows.

PropertyValueDescription
bubblesfalseThis event does not bubble up through the DOM.
cancelablefalseThis event has no default behavior that can be canceled. You can't call preventDefault() on this event.
composedfalseThis event does not propagate outside of the component in which it was dispatched.

lightning-wizard-step

Attributes

NameTypeAccessRequiredDefaultDescription
namestringglobaltrueStep unique name. Identifies the step.
labelstringglobaltrueStep label shown on wizard progress.
hide-previous-buttonBooleanglobalfalseHides the Previous button on this step.
hide-next-buttonstringglobalfalseHides the Next/Finish button on this step.
before-changefunctionglobalCustom function to execute to perform post-processing action before advancing to the next step. It should return a promise with a true/false; if resolved with a falsy value, the wizard will mark the step as error and will not advance to the next step.

Slots

NameDescription
actionsPlaceholder for actionable components on the step such as lightning-button. The components are positioned next to Next button. Overrides the header attribute set on the component.
defaultPlaceholder for step content.
1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago