Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ng-wizard-v2

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-wizard-v2

Angular ng-wizard - Angular wizard | stepper

  • 4.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
67
decreased by-45.53%
Maintainers
1
Weekly downloads
 
Created
Source

ng-wizard-v2

ng-wizard-v2 is a stepper / wizard component that you can use in your Angular applications. You can access the sample demo project by clicking here.

Contributor

Varun P varunp5814@gmail.com

Screenshots

Default

Arrows

Circles

Dots

Dependencies

Getting started

Install ng-wizard-v2 through npm:

$ npm install --save ng-wizard-v2

Include bootstrap CSS file (skip if already imported):

@import '~bootstrap/dist/css/bootstrap.min.css';

Include ng-wizard-v2 CSS files:

/* Mandatory */
@import '~ng-wizard-v2/themes/ng_wizard.min.css';

/* Optional */
/* If a theme other than default is used, the css file for that theme is required. */
@import '~ng-wizard-v2/themes/ng_wizard_theme_arrows.min.css';
@import '~ng-wizard-v2/themes/ng_wizard_theme_circles.min.css';
@import '~ng-wizard-v2/themes/ng_wizard_theme_dots.min.css';

Import the ng-wizard-v2 module into your apps module:

import { NgModule } from '@angular/core';

import { NgWizardModule, NgWizardConfig, THEME } from 'ng-wizard-v2';

const ngWizardConfig: NgWizardConfig = {
  theme: THEME.default
};

@NgModule({
  imports: [
    NgWizardModule.forRoot(ngWizardConfig)
  ]
})
export class AppModule { }

Add an ng-wizard component to the html template of your component:

<ng-wizard [config]="config" (stepChanged)="stepChanged($event)">
  
  <ng-wizard-step [title]="'Step 1'" [description]="'Step 1 description'"
    [canEnter]="isValidTypeBoolean" [canExit]="isValidFunctionReturnsBoolean.bind(this)">
    <span>Step 1 content</span>
  </ng-wizard-step>
  
  <ng-wizard-step [title]="'Step 2'" [description]="'Step 2 description'" [state]="stepStates.disabled">
    <span>Step 2 content</span>
  </ng-wizard-step>
  
  <ng-wizard-step [title]="'Step 3'" [description]="'Step 3 description'"
    [canEnter]="isValidFunctionReturnsObservable.bind(this)" [canExit]="isValidFunctionReturnsBoolean.bind(this)">
    <span>Step 3 content</span>
  </ng-wizard-step>

<ng-wizard-step [title]="'Step 4'" [description]="'Step 4 description'">
    <span>Step 4 content</span>
  </ng-wizard-step>

  <ng-wizard-step [title]="'Step 5'" [description]="'Step 5 description'" [state]="stepStates.hidden">
    <span>Step 5 content</span>
  </ng-wizard-step>
  
  <ng-wizard-step [title]="'Step 6'" [description]="'Step 6 description'" [state]="stepStates.error">
    <span>Step 6 content</span>
  </ng-wizard-step>
  
  <ng-wizard-step [title]="'Step 7'" [description]="'Step 7 description'">
    <span>Step 7 content</span>
  </ng-wizard-step>
</ng-wizard>

[config] is an optional parameter for ng-wizard component.

If you want to override ng-wizard default configuration defined in apps module for a specific component, define [config] parameter in your ***.component.ts file.

import { Component, OnInit } from '@angular/core';
import { of } from 'rxjs';
import { NgWizardConfig, NgWizardService, StepChangedArgs, StepValidationArgs, STEP_STATE, THEME } from 'ng-wizard-v2';

@Component({
  templateUrl: 'app.component.html'
})
export class AppComponent implements OnInit {
  stepStates = {
    normal: STEP_STATE.normal,
    disabled: STEP_STATE.disabled,
    error: STEP_STATE.error,
    hidden: STEP_STATE.hidden
  };

  config: NgWizardConfig = {
    selected: 0,
    theme: THEME.arrows,
    toolbarSettings: {
      toolbarExtraButtons: [
        { text: 'Finish', class: 'btn btn-info', event: () => { alert("Finished!!!"); } }
      ],
    }
  };

  constructor(private ngWizardService: NgWizardService) {
  }

  ngOnInit() {
  }

  showPreviousStep(event?: Event) {
    this.ngWizardService.previous();
  }

  showNextStep(event?: Event) {
    this.ngWizardService.next();
  }

  resetWizard(event?: Event) {
    this.ngWizardService.reset();
  }

  setTheme(theme: THEME) {
    this.ngWizardService.theme(theme);
  }

  stepChanged(args: StepChangedArgs) {
    console.log(args.step);
  }

  isValidTypeBoolean: boolean = true;

  isValidFunctionReturnsBoolean(args: StepValidationArgs) {
    return true;
  }

  isValidFunctionReturnsObservable(args: StepValidationArgs) {
    return of(true);
  }
}

Configuration

NgWizardStep parameters:

Input parameters:
NameTypeDefault ValueDescription
titlestringStep title
descriptionstringStep description
stateSTEP_STATESTEP_STATE.normalStep State (normal, disabled, error, hidden)
componentComponentA component can be defined for step content.
canExit`boolean((args: StepValidationArgs) => boolean)((args: StepValidationArgs) => Observable)`
canEnter`boolean((args: StepValidationArgs) => boolean)((args: StepValidationArgs) => Observable)`
Output parameters:
NameTypeDefault ValueDescription
indexnumberStep Index
statusSTEP_STATUSStep Status (untouched, done, active)
initialStatusSTEP_STATUSInitial Step Status (untouched, done, active)
initialStateSTEP_STATEStep State (normal, disabled, error, hidden)
componentRefComponentRefIf the component input parameter is given, it is used to access the instance of this component.

NgWizardConfig properties:

NameTypeDefault ValueDescription
selectednumber0Initial selected step
keyNavigationbooleantrueEnable/Disable keyboard navigation (left and right keys are used if enabled)
cycleStepsbooleanfalseAllows to cycle the navigation of steps
lang{ next: string, previous: string }{ next: 'Next', previous: 'Previous' }Language variables for buttons
toolbarSettingsToolbarSettings{ toolbarPosition: TOOLBAR_POSITION.bottom, toolbarButtonPosition: TOOLBAR_BUTTON_POSITION.end, showNextButton: true, showPreviousButton: true, toolbarExtraButtons: [] }Toolbar settings
anchorSettingsAnchorSettings{ anchorClickable: true, enableAllAnchors: false, markDoneStep: true, markAllPreviousStepsAsDone: true, removeDoneStepOnNavigateBack: false, enableAnchorOnDoneStep: true }Anchor settings
themeTHEMETHEME.defaultWizard theme (default, arrows, circles, dots)

ToolbarSettings properties:

NameTypeDefault ValueDescription
toolbarPositionTOOLBAR_POSITIONTOOLBAR_POSITION.bottomToolbar position (none, top, bottom, both)
toolbarButtonPositionTOOLBAR_BUTTON_POSITIONTOOLBAR_BUTTON_POSITION.endToolbar button position (start, end)
showNextButtonbooleantrueshow/hide Next button
showPreviousButtonbooleantrueshow/hide Previous button
toolbarExtraButtonsToolbarButton[][]Extra buttons to show on toolbar, array of input/buttons elements

AnchorSettings properties:

NameTypeDefault ValueDescription
anchorClickablebooleantrueEnable/Disable anchor navigation
enableAllAnchorsbooleanfalseActivates all anchors clickable all times
markDoneStepbooleantrueAdd done css
markAllPreviousStepsAsDonebooleantrueWhen a step selected, all previous steps are marked done
removeDoneStepOnNavigateBackbooleanfalseWhile navigate back done step after active step will be cleared
enableAnchorOnDoneStepboolean[]trueEnable/Disable the done steps navigation

Thanks

This component was created by rewriting the jQuery Smart Wizard 4 in Angular. Thanks to TechLaboratory for .Css files.

License

MIT License

Keywords

FAQs

Package last updated on 03 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc