Git Product home page Git Product logo

ng-wizard's Introduction

ng-wizard

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

Screenshots

Default

Arrows

Circles

Dots

Dependencies

Getting started

Install ng-wizard through npm:

$ npm install --save ng-wizard

Include bootstrap CSS file (skip if already imported):

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

Include ng-wizard CSS files:

/* Mandatory */
@import '~ng-wizard/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/themes/ng_wizard_theme_arrows.min.css';
@import '~ng-wizard/themes/ng_wizard_theme_circles.min.css';
@import '~ng-wizard/themes/ng_wizard_theme_dots.min.css';

Import the ng-wizard module into your apps module:

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

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

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';

@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:

Name Type Default Value Description
title string Step title
description string Step description
state STEP_STATE STEP_STATE.normal Step State (normal, disabled, error, hidden)
component Component A 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:

Name Type Default Value Description
index number Step Index
status STEP_STATUS Step Status (untouched, done, active)
initialStatus STEP_STATUS Initial Step Status (untouched, done, active)
initialState STEP_STATE Step State (normal, disabled, error, hidden)
componentRef ComponentRef If the component input parameter is given, it is used to access the instance of this component.

NgWizardConfig properties:

Name Type Default Value Description
selected number 0 Initial selected step
keyNavigation boolean true Enable/Disable keyboard navigation (left and right keys are used if enabled)
cycleSteps boolean false Allows to cycle the navigation of steps
lang { next: string, previous: string } { next: 'Next', previous: 'Previous' } Language variables for buttons
toolbarSettings ToolbarSettings { toolbarPosition: TOOLBAR_POSITION.bottom, toolbarButtonPosition: TOOLBAR_BUTTON_POSITION.end, showNextButton: true, showPreviousButton: true, toolbarExtraButtons: [] } Toolbar settings
anchorSettings AnchorSettings { anchorClickable: true, enableAllAnchors: false, markDoneStep: true, markAllPreviousStepsAsDone: true, removeDoneStepOnNavigateBack: false, enableAnchorOnDoneStep: true } Anchor settings
theme THEME THEME.default Wizard theme (default, arrows, circles, dots)

ToolbarSettings properties:

Name Type Default Value Description
toolbarPosition TOOLBAR_POSITION TOOLBAR_POSITION.bottom Toolbar position (none, top, bottom, both)
toolbarButtonPosition TOOLBAR_BUTTON_POSITION TOOLBAR_BUTTON_POSITION.end Toolbar button position (start, end)
showNextButton boolean true show/hide Next button
showPreviousButton boolean true show/hide Previous button
toolbarExtraButtons ToolbarButton[] [] Extra buttons to show on toolbar, array of input/buttons elements

AnchorSettings properties:

Name Type Default Value Description
anchorClickable boolean true Enable/Disable anchor navigation
enableAllAnchors boolean false Activates all anchors clickable all times
markDoneStep boolean true Add done css
markAllPreviousStepsAsDone boolean true When a step selected, all previous steps are marked done
removeDoneStepOnNavigateBack boolean false While navigate back done step after active step will be cleared
enableAnchorOnDoneStep boolean[] true Enable/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

ng-wizard's People

Contributors

abdulkadirgenc avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ng-wizard's Issues

How can i validate Step?

I have to add a validation step before changing step to another? Can i capture event on nextButton click? Thank you nice work.

Validate step

Need to validate step process and proceed to next step only if validation has passed

[TS2532] - Object is possibly 'undefined'.

Hello,

when building in production mode of my app, I get this Typescript error:

ERROR in node_modules/ng-wizard/ng-wizard.d.ts.ɵc.html(12,53): Object is possibly 'undefined'.
node_modules/ng-wizard/ng-wizard.d.ts.ɵc.html(14,49): Object is possibly 'undefined'.
node_modules/ng-wizard/ng-wizard.d.ts.ɵc.html(18,21): Object is possibly 'undefined'.
node_modules/ng-wizard/ng-wizard.d.ts.ɵc.html(30,53): Object is possibly 'undefined'.
node_modules/ng-wizard/ng-wizard.d.ts.ɵc.html(32,49): Object is possibly 'undefined'.
node_modules/ng-wizard/ng-wizard.d.ts.ɵc.html(36,21): Object is possibly 'undefined'.

My version Typescript : 3.5.3

I found a workaround with strictNullChecks but I would like not to disable Typescript checks...

Uncaught (in promise): TypeError: Object(...) is not a function

I am working on Angular 6 and when I import ngwizard to my app , I got error below , please help me to resolve this problem

core.js:1673 ERROR Error: Uncaught (in promise): TypeError: Object(...) is not a function TypeError: Object(...) is not a function at ng-wizard.js:193 at Module.../node_modules/ng-wizard/fesm5/ng-wizard.js (ng-wizard.js:195) at __webpack_require__ (bootstrap:83) at Module../app/theme/pages/default/abm-package/new-abm-package/new-abm-package.component.ts (pages-default-abm-package-package-module.js:9276) at __webpack_require__ (bootstrap:83) at Module../app/theme/pages/default/abm-package/package.module.ts (open-criterion.component.ts:53) at __webpack_require__ (bootstrap:83) at $_lazy_route_resource lazy namespace object:157 at ZoneDelegate.push.../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391) at Object.onInvoke (core.js:3820) at resolvePromise (zone.js:831) at resolvePromise (zone.js:788) at zone.js:892

Features/Bugs

After using this package there a few things that can make it better

Features

  1. When the toolboxExtraButtons next/previous are disabled and the user is using external buttons we should have an observable from the NgWizardService which can be used to enable/disable external button just like the toolboxExtraButtons next/previous default operate.

Bugs/Unclear documentation

  1. canExit or canEnter doesn't seem to do anything
  1. when all the toolboxExtraButtons are removed there is extra padding would be easier to toggle the parent container.
  1. the ng-wizard-step > ul > li > a border arrows do not wrap property on small screen devices

more than 1 ng wizard config problem

When I use more than 1 ng-wizard component with different config params, different wizard toolbarExtraButtons affected and show same buttons. Could you help me about this problem?

Unable to hide Wizard Steps

There should be a way to hide a wizard step by either setting [hidden] = "true" or providing an array of hidden steps.
Currently, this functionality is missing or not documented.

Update to latest Angular

Are there any plans to update this project to Angular 14? We use ng-wizard in a project that required an update to Angular 14 which causes dependency conflicts with ng-wizard.

Ng-wizard steps are hiden if inside of modal

Hello,

I am using your ng-wizard component (but a 1.0.0 version, bacause of project's angular version) and I'm creating wizard steps from a dynamic array i'm creating.

If the wizard is not used inside of the modal - all the steps are created without any issue, but, if I create the wizard inside of a modal (yes, it is mandatory), I debug the wizard's instance and the wizard steps have a property hidden = true.

I've tried to edit the hidden property, but it's only a getter and not a setter.

Can you help me to fix this issue?

Very grateful.

Customizing css classes

Hello team.I wish to change the background colour on the wizard header that indicates the steps.How can i go about it?

Angular version updated to 13, not working

Recently, I updated the version of the project to angular13, ng-wizard can't work, and there is no error content, but the component no longer calls the stepChanged method, causing the component function to break

Error: BrowserModule has already been loaded

When the wizard exists in a sub-component (not app.component) and when lazy loading from the routing module, the BrowswerModule gets loaded twice causing the following error:

Uncaught (in promise): Error: BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.

RTL Support

Hello , how can I enable RTL and flip the design so it starts from right to left .. as unfortunately
when I applied it the design became weird .. how can I fix this please

image

New feature for step

Add possibility to add icon like (background-image or svg) on step without title and description

Hide 1st previous button & disable next button

Hi,

Is there a way to hide the "previous button" on the first step Pane ?
Setting the toolbarSettings.showPreviousButton to false it hides as expected the button.
But if I set it to true (in the stepChanged event) it doesn't display it back.

Also, how to "disable" and "enable" the next button until the "validation part" is done?

thanks

Cannot use the [component] feature

Could you show me an example of using the [component] feature since i cannot use it or write the Component name which will end as a string and cant be used.
Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.