├── .gitignore
├── .npmignore
├── LICENSE
├── README.md
├── index.ts
├── package.json
├── src
├── ng2-wizard.module.ts
├── wizard-step-tab.component.ts
├── wizard-step.component.css
├── wizard-step.component.html
├── wizard-step.component.ts
├── wizard.component.css
├── wizard.component.html
└── wizard.component.ts
├── tsconfig-aot.json
└── tsconfig.json
/.gitignore:
--------------------------------------------------------------------------------
1 | .npmignore
2 | .gitignore
3 |
4 | *.tgz
5 | *.js
6 | *.map
7 | *.d.ts
8 | *.metadata.json
9 |
10 | /**/*.js
11 | /**/*.map
12 | /**/*.d.ts
13 | node_modules/
14 | dist/
15 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .npmignore
2 | .gitignore
3 |
4 | *.tgz
5 |
6 | typings/
7 | tsconfig.json
8 | tsconfig-aot.json
9 | typings.json
10 |
11 | /**/*.ts
12 | !/**/*.d.ts
13 |
14 | src/
15 | gulpfile.js
16 |
17 | node_modules/
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Flávio Silva
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://badge.fury.io/js/ng2-wizard)
2 |
3 | # WizardComponent
4 | @version 2.0.8
5 | @author: Flávio Silva
6 | @link: [https://github.com/fssolutions/ng2-wizard](https://github.com/fssolutions/ng2-wizard)
7 |
8 | ## Installation
9 |
10 | Wizard runs on angular 2 and is available as an NPM package. You can install ng2-wizard
11 | in your project's directory as usual:
12 |
13 | ```bash
14 | $ npm install --save ng2-wizard
15 | ```
16 |
17 | Component Wizard(step to step with tabs) for Angular 2.
18 | ```
19 |
20 | ```
21 |
22 | ## Example
23 | ### Template (.html)
24 | ```
25 |
26 |
27 | Title of first tab
28 | Hello World
29 |
30 |
31 | ```
32 | ### TypeScript (.ts)
33 | Import WizardComponent and WizardStepComponent
34 | ```
35 | import { Ng2WizardModule } from 'ng2-wizard';
36 | ```
37 |
38 | Add in your module
39 | ```
40 | @NgModule({
41 | imports: [
42 | Ng2WizardModule,
43 | ]
44 | })
45 | ```
46 |
47 | ## Contributing
48 |
49 | Contributions are welcome and appreciated. You can find ng2-combosearch on GitHub, feel free to start
50 | an issue or create a pull requests:
51 | [https://github.com/fssolutions/ng2-wizard](https://github.com/fssolutions/ng2-wizard)
52 |
53 |
54 | ## License
55 |
56 | Copyright (c) 2016 Flávio Silva [fssolutions](http://www.flaviosilva.net).
57 | Licensed under the MIT License (MIT)
58 |
--------------------------------------------------------------------------------
/index.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/wizard.component';
2 | export * from './dist/wizard-step.component';
3 | export * from './dist/wizard-step-tab.component';
4 |
5 | export * from './dist/ng2-wizard.module';
6 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ng2-wizard",
3 | "version": "2.0.8",
4 | "description": "Component wizard to angular 2",
5 | "main": "dist/index.js",
6 | "dependencies": {
7 | "@angular/common": "^5.2.9"
8 | },
9 | "devDependencies": {
10 | "@angular/cli": "^1.7.3",
11 | "@angular/compiler": "^5.2.9",
12 | "@angular/compiler-cli": "^5.2.10",
13 | "@angular/core": "^5.2.9",
14 | "@angular/platform-browser": "^5.2.9",
15 | "@types/core-js": "^0.9.46",
16 | "@types/node": "^9.6.1",
17 | "rxjs": "^5.5.8",
18 | "typescript": "^2.8.1",
19 | "typings": "^2.1.1",
20 | "zone.js": "^0.8.21",
21 | "gulp": "^3.9.1",
22 | "gulp-inline-ng2-template": "^4.0.0"
23 | },
24 | "scripts": {
25 | "prepublish": "gulp js:build && ngc --p tsconfig-aot.json",
26 | "pubtest": ""
27 | },
28 | "repository": {
29 | "type": "git",
30 | "url": "git+https://github.com/fssolutions/ng2-wizard.git"
31 | },
32 | "keywords": [
33 | "angular2",
34 | "wizard"
35 | ],
36 | "author": "fssolutions",
37 | "license": "MIT",
38 | "bugs": {
39 | "url": "https://github.com/fssolutions/ng2-wizard/issues"
40 | },
41 | "homepage": "https://github.com/fssolutions/ng2-wizard#readme"
42 | }
43 |
--------------------------------------------------------------------------------
/src/ng2-wizard.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import { WizardComponent } from './wizard.component';
5 | import { WizardStepComponent } from './wizard-step.component';
6 | import { WizardStepTabComponent } from './wizard-step-tab.component';
7 |
8 | @NgModule({
9 | imports: [
10 | CommonModule
11 | ],
12 | declarations: [ WizardComponent, WizardStepComponent, WizardStepTabComponent ],
13 | exports: [ WizardComponent, WizardStepComponent, WizardStepTabComponent ],
14 | })
15 | export class Ng2WizardModule { }
16 |
--------------------------------------------------------------------------------
/src/wizard-step-tab.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, ElementRef } from '@angular/core';
2 | import { SafeHtml, DomSanitizer } from '@angular/platform-browser';
3 |
4 |
5 | @Component({
6 | selector: 'wizard-step-tab',
7 | template: ''
8 | })
9 | export class WizardStepTabComponent {
10 |
11 | constructor(
12 | private elementRef: ElementRef,
13 | private domSanitizer: DomSanitizer
14 | ) { }
15 |
16 | public setDisplay(type: string){
17 | this.elementRef.nativeElement.style.display = type;
18 | }
19 |
20 | public getHTML(): SafeHtml {
21 | let html = this.elementRef.nativeElement.innerHTML;
22 | return this.domSanitizer.bypassSecurityTrustHtml(html);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/wizard-step.component.css:
--------------------------------------------------------------------------------
1 | .step {
2 | padding: 15px;
3 | padding-top: 20px;
4 | }
5 |
--------------------------------------------------------------------------------
/src/wizard-step.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/wizard-step.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, AfterContentInit, ElementRef, ContentChild } from '@angular/core';
2 | import { SafeHtml } from '@angular/platform-browser';
3 |
4 | import { WizardStepTabComponent } from './wizard-step-tab.component';
5 |
6 | /**
7 | * # WizardStepComponent
8 | *
9 | * Childrens component of WizardComponent
10 | *
11 | *```
12 | *
13 | * Title of your tab
14 | * Hello World - your content
15 | *
16 | *```
17 | *
18 | * ## Atention!!
19 | * The tag <wizard-step-tab> is o obrigatory
20 | *```
21 | * Title of your tab
22 | *```
23 | */
24 | @Component({
25 | selector: 'wizard-step',
26 | styleUrls: [
27 | './wizard-step.component.css'
28 | ],
29 | templateUrl: './wizard-step.component.html'
30 | })
31 |
32 | export class WizardStepComponent implements AfterContentInit {
33 | private tabName: SafeHtml;
34 |
35 | @ContentChild(WizardStepTabComponent) private wizardStepTabComponent: WizardStepTabComponent;
36 |
37 | public isActive: boolean = false;
38 |
39 | constructor(private elementRef: ElementRef) { }
40 |
41 | ngAfterContentInit() {
42 | if(this.wizardStepTabComponent){
43 | this.wizardStepTabComponent.setDisplay('none');
44 | this.tabName = this.wizardStepTabComponent.getHTML();
45 | }else
46 | throw new Error('WizardStepComponent: TagName "wizard-step-tab" was not found in step');
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/wizard.component.css:
--------------------------------------------------------------------------------
1 | .wizard {
2 | display: block;
3 | }
4 |
5 | .wizard-portrait .step {
6 | padding-top: 0px !important;
7 | }
8 |
9 | .wizard nav {
10 | display: -webkit-flex;
11 | display: flex;
12 | border-bottom: 1px solid #ddd;
13 | }
14 |
15 | .wizard nav.hidden {
16 | display: none !important;
17 | }
18 |
19 | .wizard nav label {
20 | padding-bottom: 5px;
21 | padding-left: 15px;
22 | padding-right: 15px;
23 | padding-top: 5px;
24 | margin-bottom: 0px;
25 | position: relative;
26 | font-weight: normal !important;
27 | border-bottom: 6px solid transparent;
28 | border-top: 6px solid transparent;
29 | overflow: hidden;
30 | text-overflow: ellipsis;
31 | white-space: nowrap;
32 | }
33 |
34 | .wizard nav label.active,
35 | .wizard nav label.enable:hover {
36 | background-color: rgb(245, 245, 245);
37 | border-bottom: 6px solid rgb(82, 145, 245);
38 | cursor: pointer;
39 | }
40 |
41 | .wizard nav label.disabled {
42 | cursor: not-allowed;
43 | }
44 |
45 | .wizard-portrait {
46 | display: -webkit-flex;
47 | display: flex;
48 | }
49 |
50 | .wizard-portrait nav {
51 | display: inline-block;
52 | -webkit-flex: 1;
53 | -ms-flex: 1;
54 | flex: 1;
55 | overflow: hidden;
56 | border-bottom: none;
57 | }
58 |
59 | .wizard-portrait > div {
60 | -webkit-flex: 4;
61 | -ms-flex: 4;
62 | flex: 4;
63 | }
64 |
65 | .wizard-portrait nav label {
66 | display: block;
67 | border-left: 6px solid transparent !important;
68 | }
69 |
70 | .wizard-portrait nav label.active,
71 | .wizard-portrait nav label.enable:hover {
72 | background-color: rgb(245, 245, 245);
73 | border-bottom-color: transparent !important;
74 | border-left: 6px solid rgb(82, 145, 245) !important;
75 | cursor: pointer;
76 | }
77 |
78 | .wizard-portrait nav label:hover::after,
79 | .wizard-portrait nav label.active::after {
80 | display: block;
81 | width: 20px;
82 | height: 20px;
83 | background: white;
84 | content: ' ';
85 | position: absolute;
86 | right: -10px;
87 | top: 5px;
88 | -webkit-transform: rotate(45deg);
89 | }
90 |
--------------------------------------------------------------------------------
/src/wizard.component.html:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/wizard.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, Input, Output, EventEmitter, ContentChildren, QueryList, AfterContentInit } from '@angular/core';
2 |
3 | import { WizardStepComponent } from './wizard-step.component'
4 | /**
5 | * # WizardComponent
6 | * @version 2.0.0
7 | * @author: Flávio Silva
8 | * @link: [https://github.com/fssolutions/ng2-wizard](https://github.com/fssolutions/ng2-wizard)
9 | *
10 | * Component Wizard(step to step with tabs) for Angular 2.
11 | *```
12 | *
13 | *```
14 | *
15 | * ## Example
16 | * ### Template (.html)
17 | *```
18 | *
19 | *
20 | * Title of first tab
21 | * Hello World
22 | *
23 | *
24 | *```
25 | * ### TypeScript (.ts)
26 | * Import WizardComponent and WizardStepComponent
27 | *```
28 | * import { WizardComponent, WizardStepComponent } from 'ng2-wizard';
29 | *```
30 | *
31 | * Add in your directives
32 | *```
33 | * directives: [WizardStepComponent, WizardComponent]
34 | *```
35 | */
36 | @Component({
37 | selector: 'wizard',
38 | styleUrls: [
39 | './wizard.component.css'
40 | ],
41 | templateUrl: './wizard.component.html'
42 | })
43 |
44 | export class WizardComponent implements AfterContentInit {
45 | private version: string = "1.0.3.0";
46 |
47 | /**
48 | * @property {object} defaults - The default values for wizard.
49 | * @property {string} defaults.orientation - The default orientation.
50 | * @property {boolean} defaults.disableTabs - The default disableTabs.
51 | * @property {array} defaults.disableTabsAt - The default tabs disabled.
52 | * @property {boolean} defaults.hiddenTabs - The default hiddenTabs.
53 | * @property {number} defaults.currentStep - The default current step.
54 | * @property {number} defaults.hiddenDisableSteps - The default hiddenDisableSteps.
55 | */
56 | public defaults = {
57 | orientation: "landscape",
58 | disableTabs: false,
59 | hiddenTabs: false,
60 | currentTab: 0,
61 | disableSteps: [-1],
62 | hiddenDisableSteps: false
63 | };
64 | @ContentChildren(WizardStepComponent) public wizardSteps: QueryList;
65 |
66 | /**
67 | * Set or get orientation of the navegation tab position
68 | * @params orientation {string} ["portrait","landscape"] - Orientation of the navegation;
69 | *
70 | * ### Example
71 | * #### Attribute (.html)
72 | * Implements in your html
73 | * ```
74 | *
75 | * ```
76 | *
77 | * #### TypeScript (.ts)
78 | * Implements in your file controller
79 | * ```
80 | * @ViewChild(WizardComponent) mWizard: WizardComponent;
81 | * toggleTabOrientation(){
82 | * console.info("hiddenTabs tabs:", this.mWizard.orientation);
83 | * this.mWizard.orientation = mWizard.orientation == 'portrait' ? 'landscape' : 'portrait';
84 | * }
85 | * ```
86 | * @return {string} ["portrait","landscape"]
87 | */
88 | @Input()
89 | set orientation(format: string) {
90 | this.defaults.orientation = format;
91 | };
92 | get orientation() {
93 | return this.defaults.orientation;
94 | }
95 |
96 | /**
97 | * Active manual steps(tabs) navegation;
98 | *
99 | * ### Example
100 | * #### Attribute (.html)
101 | * Implements in your html
102 | * ```
103 | *
104 | * ```
105 | *
106 | * #### TypeScript (.ts)
107 | * Implements in your file controller
108 | * ```
109 | * @ViewChild(WizardComponent) mWizard: WizardComponent;
110 | * toggleNavigationMode(){
111 | * console.info("is disable tabs:", this.mWizard.disableTabs);
112 | * this.mWizard.disableTabs = !this.mWizard.disableTabs;
113 | * // or mWizard.disableTabs = mWizard.disableTabs ? false : true;
114 | * console.info("is disable tabs:", this.mWizard.disableTabs);
115 | * }
116 | * ```
117 | * @return {boolean} - Navegation tab is enabled
118 | */
119 | @Input()
120 | set disableTabs(status: any) {
121 |
122 | if (typeof status == "boolean") {
123 | this.defaults.disableTabs = status;
124 | return;
125 | }
126 |
127 | if (typeof status == "string") {
128 | this.defaults.disableTabs = status == "yes";
129 | return;
130 | }
131 | }
132 | get disableTabs() {
133 | return this.defaults.disableTabs;
134 | }
135 |
136 | /**
137 | * Hidden tabs navegation;
138 | *
139 | * ### Example
140 | * #### Attribute (.html)
141 | * Implements in your html
142 | * ```
143 | *
144 | * ```
145 | *
146 | * #### TypeScript (.ts)
147 | * Implements in your file controller
148 | * ```
149 | * @ViewChild(WizardComponent) mWizard: WizardComponent;
150 | * toggleVisibleTab(){
151 | * console.info("hiddenTabs tabs:", this.mWizard.hiddenTabs);
152 | * mWizard.hiddenTabs = !this.mWizard.hiddenTabs;
153 | * // or mWizard.hiddenTabs = this.mWizard.hiddenTabs ? false : true;
154 | * console.info("hiddenTabs tabs:", this.mWizard.hiddenTabs);
155 | * }
156 | * ```
157 | * @return {boolean} - Navegation tab is show
158 | */
159 | @Input()
160 | set hiddenTabs(status: any) {
161 | if (typeof status == "boolean") {
162 | this.defaults.hiddenTabs = status;
163 | return;
164 | }
165 |
166 | if (typeof status == "string") {
167 | this.defaults.hiddenTabs = status == "yes";
168 | return;
169 | }
170 | }
171 | get hiddenTabs() {
172 | return this.defaults.hiddenTabs || false;
173 | }
174 |
175 | /**
176 | * Disable specific tabs navegation;
177 | *
178 | * ### Example
179 | * #### Attribute (.html)
180 | * Implements in your html
181 | * ```
182 | *
183 | * ```
184 | *
185 | * #### TypeScript (.ts)
186 | * Implements in your file controller
187 | * ```
188 | * @ViewChild(WizardComponent) mWizard: WizardComponent;
189 | * toggleNavigationMode(){
190 | * console.info("is disable steps:", this.mWizard.disableSteps);
191 | * this.mWizard.disableSteps = [2,4,5];
192 | * console.info("is disable steps:", this.mWizard.disableSteps);
193 | * }
194 | * ```
195 | * @return {boolean} - Navegation tab is enabled
196 | */
197 | @Input()
198 | set disableSteps(indexs: Array) {
199 | if (typeof indexs != 'object')
200 | return;
201 |
202 | this.defaults.disableSteps = indexs;
203 | };
204 | get disableSteps(): Array {
205 | return this.defaults.disableSteps;
206 | }
207 |
208 | /**
209 | * Hide navigation when step disabled;
210 | *
211 | * ### Example
212 | * #### Attribute (.html)
213 | * Implements in your html
214 | * ```
215 | *
216 | * ```
217 | *
218 | * #### TypeScript (.ts)
219 | * Implements in your file controller
220 | * ```
221 | * @ViewChild(WizardComponent) mWizard: WizardComponent;
222 | * toggleNavigationMode(){
223 | * console.info("show steps:", this.mWizard.hiddenDisableSteps);
224 | * this.mWizard.hiddenDisableSteps = true;
225 | * console.info("show steps:", this.mWizard.hiddenDisableSteps);
226 | * }
227 | * ```
228 | * @return {boolean} - Show tab when disabled
229 | */
230 | @Input()
231 | set hiddenDisableSteps(status: any) {
232 | if (typeof status == "boolean") {
233 | this.defaults.hiddenDisableSteps = status;
234 | return;
235 | }
236 |
237 | if (typeof status == "string") {
238 | this.defaults.hiddenDisableSteps = status == "yes";
239 | return;
240 | }
241 | };
242 | get hiddenDisableSteps() {
243 | return this.defaults.hiddenDisableSteps;
244 | }
245 |
246 | /**
247 | * Set or Get current step
248 | * @return {number} - Current number step
249 | *
250 | * ### Example
251 | * #### Attribute (.html)
252 | * Implements in your html
253 | * ```
254 | *
255 | * ```
256 | *
257 | * #### TypeScript (.ts)
258 | * Implements in your file controller [see setcurrentTab]{@link #setcurrentTab()}
259 | * ```
260 | * @ViewChild(WizardComponent) mWizard: WizardComponent;
261 | * nextStep(){
262 | * console.info("Current Step:", this.mWizard.currentStep);
263 | * this.mWizard.currentStep++;
264 | * // or mWizard.currentStep = this.mWizard.currentStep + 1;
265 | * console.info("Current Step:", this.mWizard.currentStep);
266 | * }
267 | * ```
268 | */
269 | @Input()
270 | set currentStep(index: number) {
271 | this.defaults.currentTab = this.getRealIndex(parseInt("" + index));
272 |
273 | //if change date
274 | if (this.wizardSteps != null && this.wizardSteps.length > 0) {
275 | this.setPanel(this.defaults.currentTab);
276 | }
277 | }
278 | get currentStep(): number { return this.defaults.currentTab; }
279 |
280 | //Event Listeners
281 | /**
282 | * Return Object
283 | * @params {boolean} isTab - Action when clicked in tab;
284 | * @params {number} currentStep - Current index step;
285 | * @event WizardComponent#stepChange
286 | *
287 | * Fire event when change current step
288 | * ### Example
289 | * #### Template (.html)
290 | * Implements in your html
291 | * ```
292 | *
293 | * ```
294 | *
295 | * #### TypeScript (.ts)
296 | * Implements in your file controller
297 | * ```
298 | * onTabChange(opt){
299 | * console.info("Change in tab ? ", opt.isTab);
300 | * console.info("Current step: ", opt.currentStep);
301 | * }
302 | * ```
303 | */
304 | @Output() stepChange: EventEmitter = new EventEmitter();
305 |
306 | /**
307 | * Set current number step
308 | *
309 | * ### Example
310 | * #### TypeScript (.ts)
311 | * Implements in your file controller
312 | * ```
313 | * @ViewChild(WizardComponent) mWizard: WizardComponent;
314 | * setStep(){
315 | * this.mWizard.setCurrentStep(1);
316 | * }
317 | * ```
318 | */
319 | setCurrentStep(index: number): void {
320 | this.setPanel(this.getRealIndex(index));
321 | }
322 |
323 | /**
324 | * Disable specific step
325 | * @params {number} index - Add index to disable tab
326 | *
327 | * ### Example
328 | * #### TypeScript (.ts)
329 | * Implements in your file controller
330 | * ```
331 | * @ViewChild(WizardComponent) mWizard: WizardComponent;
332 | * denyStep(){
333 | * this.mWizard.addDisabledSteps(1);
334 | * }
335 | * ```
336 | */
337 | addDisabledSteps(index: number): void {
338 | if (this.inArray(this.defaults.disableSteps, index))
339 | return;
340 |
341 | this.defaults.disableSteps.push(index);
342 | }
343 |
344 | /**
345 | * Remove disable specific step
346 | * @params {number} index - Remove index to disable tab
347 | *
348 | * ### Example
349 | * #### TypeScript (.ts)
350 | * Implements in your file controller
351 | * ```
352 | * @ViewChild(WizardComponent) mWizard: WizardComponent;
353 | * allowStep(){
354 | * this.mWizard.removeDisabledSteps(1);
355 | * }
356 | * ```
357 | */
358 | removeDisabledSteps(index: number): void {
359 | if (this.inArray(this.defaults.disableSteps, index))
360 | return;
361 |
362 | let i = this.defaults.disableSteps.indexOf(index);
363 | if(i > -1)
364 | this.defaults.disableSteps.splice(i, 1);
365 | }
366 |
367 | /**
368 | * Disable specific steps
369 | * @params {Array} index - Add index to disable tab
370 | *
371 | * ### Example
372 | * #### TypeScript (.ts)
373 | * Implements in your file controller
374 | * ```
375 | * @ViewChild(WizardComponent) mWizard: WizardComponent;
376 | * denySteps(){
377 | * this.mWizard.setDisabledSteps([1,2]);
378 | * }
379 | * ```
380 | */
381 | setDisabledSteps(indexs: Array): void {
382 | if (typeof indexs != 'object')
383 | return;
384 |
385 | this.defaults.disableSteps = indexs;
386 | }
387 |
388 | ngAfterContentInit() {
389 | if (this.wizardSteps.length == 0) {
390 | this.errorMessage('WizardComponent not found view childrens');
391 | }
392 |
393 | this.setPanel(this.getRealIndex(this.defaults.currentTab));
394 | }
395 |
396 | private getRealIndex(index: number) {
397 | if (this.wizardSteps == null)
398 | return index;
399 |
400 | let i = index > this.defaults.currentTab ? 1 : -1;
401 | let nindex = index;
402 | while (
403 | this.inArray(this.defaults.disableSteps, nindex)
404 | && nindex >= 0
405 | && nindex <= this.wizardSteps.length
406 | ) {
407 | nindex += i;
408 | }
409 |
410 | if (nindex == 0)
411 | return 0;
412 |
413 | if (nindex == this.wizardSteps.length)
414 | return this.defaults.currentTab;
415 |
416 | return nindex;
417 | }
418 |
419 | private hideAllContainer(): void {
420 | this.wizardSteps.forEach(step => {
421 | step.isActive = false;
422 | });
423 | }
424 |
425 | private errorMessage(m: string, o: Object = null): void {
426 | switch (arguments.length) {
427 | case 1:
428 | console.error('WizardComponet Error:', { Message: m, Version: this.version });
429 | break;
430 |
431 | case 2:
432 | console.error('WizardComponet Error:', { Message: m, Object: o, Version: this.version });
433 | break;
434 | }
435 | }
436 |
437 |
438 | public inArray(ar: Array, key: any): boolean {
439 | return !!ar.find(x => x == key);
440 | }
441 |
442 | public setPanel(index: number, isTab: boolean = false): void {
443 |
444 | if ((this.defaults.disableTabs && isTab) || this.wizardSteps == null || this.inArray(this.defaults.disableSteps, index)) {
445 | return;
446 | }
447 |
448 | if (index >= this.wizardSteps.length)
449 | this.defaults.currentTab = this.wizardSteps.length - 1;
450 | else if (index < 0)
451 | this.defaults.currentTab = 0;
452 | else
453 | this.defaults.currentTab = index;
454 |
455 | this.stepChange.emit({ currentStep: index, isTab: isTab });
456 | this.hideAllContainer();
457 | this.wizardSteps.toArray()[this.currentStep].isActive = true;
458 | }
459 | }
460 |
--------------------------------------------------------------------------------
/tsconfig-aot.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "rootDir": "dist",
4 | "target": "es5",
5 | "module": "es2015",
6 | "baseUrl": "src",
7 | "moduleResolution": "node",
8 | "sourceMap": true,
9 | "declaration": true,
10 | "emitDecoratorMetadata": true,
11 | "experimentalDecorators": true,
12 | "removeComments": false,
13 | "noImplicitAny": false,
14 | "suppressImplicitAnyIndexErrors": true,
15 | "lib": [
16 | "dom",
17 | "es6"
18 | ]
19 | },
20 | "include": [
21 | "dist/**/*",
22 | "index.ts"
23 | ],
24 | "angularCompilerOptions": {
25 | "genDir": "dist",
26 | "skipTemplateCodegen": true,
27 | "fullTemplateTypeCheck": true,
28 | "preserveWhiteSpace": false
29 | }
30 | }
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "noImplicitAny": true,
4 | "module": "commonjs",
5 | "outDir": "./dist",
6 | "sourceMap": true,
7 | "declaration": true,
8 | "moduleResolution": "node",
9 | "emitDecoratorMetadata": true,
10 | "experimentalDecorators": true,
11 | "target": "es5",
12 | "lib": [
13 | "es2015",
14 | "dom"
15 | ]
16 | },
17 | "files": [
18 | "index.ts"
19 | ],
20 | "exclude": [
21 | "node_modules"
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------