@covalent/guided-tour 4.0.0-alpha.0 → 4.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,139 +1,27 @@
1
+ import * as i0 from '@angular/core';
1
2
  import { Injectable, NgModule } from '@angular/core';
2
3
  import { CommonModule } from '@angular/common';
3
4
  import { __awaiter } from 'tslib';
4
- import { HttpClient } from '@angular/common/http';
5
- import { NavigationStart, Router, ActivatedRoute } from '@angular/router';
5
+ import * as i1 from '@angular/router';
6
+ import { NavigationStart } from '@angular/router';
6
7
  import { first, takeUntil, skip, skipWhile, filter, debounceTime, tap, map } from 'rxjs/operators';
7
8
  import { Subject, merge, fromEvent, forkJoin, BehaviorSubject, timer } from 'rxjs';
8
9
  import Shepherd from 'shepherd.js';
10
+ import * as i2 from '@angular/common/http';
9
11
 
10
- /**
11
- * @fileoverview added by tsickle
12
- * Generated from: guided.tour.ts
13
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
14
- */
15
- /** @enum {string} */
16
- const ITourEvent = {
17
- 'click': "click",
18
- 'pointerover': "pointerover",
19
- 'keyup': "keyup",
20
- 'added': "added",
21
- 'removed': "removed",
22
- };
23
- /**
24
- * @record
25
- */
26
- function ITourEventOn() { }
27
- if (false) {
28
- /** @type {?|undefined} */
29
- ITourEventOn.prototype.selector;
30
- /** @type {?|undefined} */
31
- ITourEventOn.prototype.event;
32
- }
33
- /**
34
- * @record
35
- */
36
- function ITourEventOnOptions() { }
37
- if (false) {
38
- /** @type {?|undefined} */
39
- ITourEventOnOptions.prototype.timeBeforeShow;
40
- /** @type {?|undefined} */
41
- ITourEventOnOptions.prototype.interval;
42
- }
43
- /**
44
- * @record
45
- */
46
- function ITourAbortOn() { }
47
- /**
48
- * @record
49
- */
50
- function ITourOptions() { }
51
- if (false) {
52
- /** @type {?|undefined} */
53
- ITourOptions.prototype.abortOn;
54
- }
55
- /**
56
- * @record
57
- */
58
- function ITourStepAttachToOptions() { }
59
- if (false) {
60
- /** @type {?|undefined} */
61
- ITourStepAttachToOptions.prototype.highlight;
62
- /** @type {?|undefined} */
63
- ITourStepAttachToOptions.prototype.retries;
64
- /** @type {?|undefined} */
65
- ITourStepAttachToOptions.prototype.skipIfNotFound;
66
- /** @type {?|undefined} */
67
- ITourStepAttachToOptions.prototype.else;
68
- /** @type {?|undefined} */
69
- ITourStepAttachToOptions.prototype.goBackTo;
70
- /** @type {?|undefined} */
71
- ITourStepAttachToOptions.prototype.skipFromStepCount;
72
- }
73
- /**
74
- * @record
75
- */
76
- function ITourStepAdvanceOn() { }
77
- /**
78
- * @record
79
- */
80
- function ITourStepAdvanceOnOptions() { }
81
- if (false) {
82
- /** @type {?|undefined} */
83
- ITourStepAdvanceOnOptions.prototype.jumpTo;
84
- /** @type {?|undefined} */
85
- ITourStepAdvanceOnOptions.prototype.allowGoBack;
86
- }
87
- /**
88
- * @record
89
- */
90
- function ITourStep() { }
91
- if (false) {
92
- /** @type {?|undefined} */
93
- ITourStep.prototype.attachToOptions;
94
- /** @type {?|undefined} */
95
- ITourStep.prototype.advanceOnOptions;
96
- /** @type {?|undefined} */
97
- ITourStep.prototype.advanceOn;
98
- /** @type {?|undefined} */
99
- ITourStep.prototype.abortOn;
100
- /** @type {?|undefined} */
101
- ITourStep.prototype.count;
102
- }
103
- /**
104
- * @abstract
105
- */
12
+ var ITourEvent;
13
+ (function (ITourEvent) {
14
+ ITourEvent["click"] = "click";
15
+ ITourEvent["pointerover"] = "pointerover";
16
+ ITourEvent["keyup"] = "keyup";
17
+ ITourEvent["added"] = "added";
18
+ ITourEvent["removed"] = "removed";
19
+ })(ITourEvent || (ITourEvent = {}));
106
20
  class TourButtonsActions {
107
21
  }
108
- if (false) {
109
- /**
110
- * @abstract
111
- * @return {?}
112
- */
113
- TourButtonsActions.prototype.next = function () { };
114
- /**
115
- * @abstract
116
- * @return {?}
117
- */
118
- TourButtonsActions.prototype.back = function () { };
119
- /**
120
- * @abstract
121
- * @return {?}
122
- */
123
- TourButtonsActions.prototype.cancel = function () { };
124
- /**
125
- * @abstract
126
- * @return {?}
127
- */
128
- TourButtonsActions.prototype.finish = function () { };
129
- }
130
- /** @type {?} */
131
22
  const SHEPHERD_DEFAULT_FIND_TIME_BEFORE_SHOW = 100;
132
- /** @type {?} */
133
23
  const SHEPHERD_DEFAULT_FIND_INTERVAL = 500;
134
- /** @type {?} */
135
24
  const SHEPHERD_DEFAULT_FIND_ATTEMPTS = 20;
136
- /** @type {?} */
137
25
  const overriddenEvents = [
138
26
  ITourEvent.click,
139
27
  ITourEvent.pointerover,
@@ -141,37 +29,25 @@ const overriddenEvents = [
141
29
  ITourEvent.added,
142
30
  ITourEvent.keyup,
143
31
  ];
144
- /** @type {?} */
145
32
  const keyEvents = new Map([
146
33
  [13, 'enter'],
147
34
  [27, 'esc'],
148
35
  ]);
149
- /** @type {?} */
150
36
  const defaultStepOptions = {
151
37
  scrollTo: { behavior: 'smooth', block: 'center' },
152
38
  cancelIcon: {
153
39
  enabled: true,
154
40
  },
155
41
  };
156
- /** @type {?} */
157
42
  const MAT_ICON_BUTTON = 'mat-icon-button material-icons mat-button-base';
158
- /** @type {?} */
159
43
  const MAT_BUTTON = 'mat-button-base mat-button';
160
- /** @type {?} */
161
44
  const MAT_BUTTON_INVISIBLE = 'shepherd-void-button';
162
45
  class CovalentGuidedTour extends TourButtonsActions {
163
- /**
164
- * @param {?=} stepOptions
165
- */
166
46
  constructor(stepOptions = defaultStepOptions) {
167
47
  super();
168
48
  this.stepOptions = stepOptions;
169
49
  this.newTour();
170
50
  }
171
- /**
172
- * @param {?=} opts
173
- * @return {?}
174
- */
175
51
  newTour(opts) {
176
52
  this.shepherdTour = new Shepherd.Tour(Object.assign({
177
53
  defaultStepOptions: this.stepOptions,
@@ -180,133 +56,74 @@ class CovalentGuidedTour extends TourButtonsActions {
180
56
  // listen to cancel and complete to clean up abortOn events
181
57
  merge(fromEvent(this.shepherdTour, 'cancel'), fromEvent(this.shepherdTour, 'complete'))
182
58
  .pipe(first())
183
- .subscribe((/**
184
- * @return {?}
185
- */
186
- () => {
59
+ .subscribe(() => {
187
60
  this._destroyedEvent$.next();
188
61
  this._destroyedEvent$.complete();
189
- }));
62
+ });
190
63
  // if abortOn was passed, we bind the event and execute complete
191
64
  if (opts && opts.abortOn) {
192
- /** @type {?} */
193
65
  const abortArr$ = [];
194
- opts.abortOn.forEach((/**
195
- * @param {?} abortOn
196
- * @return {?}
197
- */
198
- (abortOn) => {
199
- /** @type {?} */
66
+ opts.abortOn.forEach((abortOn) => {
200
67
  const abortEvent$ = new Subject();
201
68
  abortArr$.push(abortEvent$);
202
69
  this._bindEvent(abortOn, undefined, abortEvent$, this._destroyedEvent$);
203
- }));
204
- /** @type {?} */
70
+ });
205
71
  const abortSubs = merge(...abortArr$)
206
72
  .pipe(takeUntil(this._destroyedEvent$))
207
- .subscribe((/**
208
- * @return {?}
209
- */
210
- () => {
73
+ .subscribe(() => {
211
74
  this.shepherdTour.complete();
212
75
  abortSubs.unsubscribe();
213
- }));
76
+ });
214
77
  }
215
78
  }
216
- /**
217
- * @return {?}
218
- */
219
79
  back() {
220
80
  this.shepherdTour.back();
221
81
  }
222
- /**
223
- * @return {?}
224
- */
225
82
  cancel() {
226
83
  this.shepherdTour.cancel();
227
84
  }
228
- /**
229
- * @return {?}
230
- */
231
85
  next() {
232
86
  this.shepherdTour.next();
233
87
  }
234
- /**
235
- * @return {?}
236
- */
237
88
  finish() {
238
89
  this.shepherdTour.complete();
239
90
  }
240
- /**
241
- * @param {?} steps
242
- * @return {?}
243
- */
244
91
  addSteps(steps) {
245
92
  this.shepherdTour.addSteps(this._prepareTour(steps));
246
93
  }
247
- /**
248
- * @return {?}
249
- */
250
94
  start() {
251
95
  this.shepherdTour.start();
252
96
  }
253
- /**
254
- * @protected
255
- * @param {?} originalSteps
256
- * @param {?=} finishLabel
257
- * @return {?}
258
- */
259
97
  _prepareTour(originalSteps, finishLabel = 'finish') {
260
98
  // create Subjects for back and forward events
261
- /** @type {?} */
262
99
  const backEvent$ = new Subject();
263
- /** @type {?} */
264
100
  const forwardEvent$ = new Subject();
265
- /** @type {?} */
266
101
  let _backFlow = false;
267
102
  // create Subject for your end
268
- /** @type {?} */
269
103
  const destroyedEvent$ = new Subject();
270
104
  /**
271
105
  * This function adds the step progress in the footer of the shepherd tooltip
272
- * @type {?}
273
- */
274
- const appendProgressFunc = (/**
275
- * @return {?}
276
106
  */
277
- function () {
107
+ const appendProgressFunc = function () {
278
108
  // get all the footers that are available in the DOM
279
- /** @type {?} */
280
109
  const footers = Array.from(document.querySelectorAll('.shepherd-footer'));
281
110
  // get the last footer since Shepherd always puts the active one at the end
282
- /** @type {?} */
283
111
  const footer = footers[footers.length - 1];
284
112
  // generate steps html element
285
- /** @type {?} */
286
113
  const progress = document.createElement('span');
287
114
  progress.className = 'shepherd-progress';
288
115
  progress.innerText = `${this.shepherdTour.currentStep.options.count}/${stepTotal}`;
289
116
  // insert into the footer before the first button
290
117
  footer.insertBefore(progress, footer.querySelector('.shepherd-button'));
291
- });
292
- /** @type {?} */
118
+ };
293
119
  let stepTotal = 0;
294
- /** @type {?} */
295
- const steps = originalSteps.map((/**
296
- * @param {?} step
297
- * @return {?}
298
- */
299
- (step) => {
120
+ const steps = originalSteps.map((step) => {
300
121
  var _a, _b, _c;
301
- /** @type {?} */
302
122
  let showProgress;
303
123
  if (((_a = step.attachToOptions) === null || _a === void 0 ? void 0 : _a.skipFromStepCount) === true) {
304
- showProgress = (/**
305
- * @return {?}
306
- */
307
- function () {
124
+ showProgress = function () {
308
125
  return;
309
- });
126
+ };
310
127
  }
311
128
  else if (((_b = step.attachToOptions) === null || _b === void 0 ? void 0 : _b.skipFromStepCount) === undefined ||
312
129
  ((_c = step.attachToOptions) === null || _c === void 0 ? void 0 : _c.skipFromStepCount) === false) {
@@ -318,65 +135,43 @@ class CovalentGuidedTour extends TourButtonsActions {
318
135
  show: showProgress,
319
136
  },
320
137
  });
321
- }));
322
- /** @type {?} */
138
+ });
323
139
  const finishButton = {
324
140
  text: finishLabel,
325
141
  action: this['finish'].bind(this),
326
142
  classes: MAT_BUTTON,
327
143
  };
328
- /** @type {?} */
329
144
  const voidButton = {
330
145
  text: '',
331
- /**
332
- * @return {?}
333
- */
334
146
  action() {
335
147
  return;
336
148
  },
337
149
  classes: MAT_BUTTON_INVISIBLE,
338
150
  };
339
151
  // listen to the destroyed event to clean up all the streams
340
- this._destroyedEvent$.pipe(first()).subscribe((/**
341
- * @return {?}
342
- */
343
- () => {
152
+ this._destroyedEvent$.pipe(first()).subscribe(() => {
344
153
  backEvent$.complete();
345
154
  forwardEvent$.complete();
346
155
  destroyedEvent$.next();
347
156
  destroyedEvent$.complete();
348
- }));
349
- /** @type {?} */
157
+ });
350
158
  const totalSteps = steps.length;
351
- steps.forEach((/**
352
- * @param {?} step
353
- * @param {?} index
354
- * @return {?}
355
- */
356
- (step, index) => {
159
+ steps.forEach((step, index) => {
357
160
  var _a;
358
161
  // create buttons specific for the step
359
162
  // this is done to create more control on events
360
- /** @type {?} */
361
163
  const nextButton = {
362
164
  text: 'chevron_right',
363
- action: (/**
364
- * @return {?}
365
- */
366
- () => {
165
+ action: () => {
367
166
  // intercept the next action and trigger event
368
167
  forwardEvent$.next();
369
168
  this.shepherdTour.next();
370
- }),
169
+ },
371
170
  classes: MAT_ICON_BUTTON,
372
171
  };
373
- /** @type {?} */
374
172
  const backButton = {
375
173
  text: 'chevron_left',
376
- action: (/**
377
- * @return {?}
378
- */
379
- () => {
174
+ action: () => {
380
175
  // intercept the back action and trigger event
381
176
  backEvent$.next();
382
177
  _backFlow = true;
@@ -387,7 +182,7 @@ class CovalentGuidedTour extends TourButtonsActions {
387
182
  else {
388
183
  this.shepherdTour.back();
389
184
  }
390
- }),
185
+ },
391
186
  classes: ((_a = step.advanceOnOptions) === null || _a === void 0 ? void 0 : _a.allowGoBack) === false ? MAT_BUTTON_INVISIBLE : MAT_ICON_BUTTON,
392
187
  };
393
188
  // check if highlight was provided for the step, else fallback into shepherds usage
@@ -408,7 +203,6 @@ class CovalentGuidedTour extends TourButtonsActions {
408
203
  }
409
204
  }
410
205
  // checks "advanceOn" to override listeners
411
- /** @type {?} */
412
206
  let advanceOn = step.advanceOn;
413
207
  // remove the shepherd "advanceOn" infavor of ours if the event is part of our list
414
208
  if ((typeof advanceOn === 'object' &&
@@ -420,45 +214,23 @@ class CovalentGuidedTour extends TourButtonsActions {
420
214
  step.advanceOnOptions && step.advanceOnOptions.allowGoBack ? [backButton, voidButton] : [voidButton];
421
215
  }
422
216
  // adds a default beforeShowPromise function
423
- step.beforeShowPromise = (/**
424
- * @return {?}
425
- */
426
- () => {
427
- return new Promise((/**
428
- * @param {?} resolve
429
- * @return {?}
430
- */
431
- (resolve) => {
432
- /** @type {?} */
433
- const additionalCapabilitiesSetup = (/**
434
- * @return {?}
435
- */
436
- () => {
217
+ step.beforeShowPromise = () => {
218
+ return new Promise((resolve) => {
219
+ const additionalCapabilitiesSetup = () => {
437
220
  if (advanceOn && !step.advanceOn) {
438
221
  if (!Array.isArray(advanceOn)) {
439
222
  advanceOn = [advanceOn];
440
223
  }
441
- /** @type {?} */
442
224
  const advanceArr$ = [];
443
- advanceOn.forEach((/**
444
- * @param {?} _
445
- * @param {?} i
446
- * @return {?}
447
- */
448
- (_, i) => {
449
- /** @type {?} */
225
+ advanceOn.forEach((_, i) => {
450
226
  const advanceEvent$ = new Subject();
451
227
  advanceArr$.push(advanceEvent$);
452
228
  // we start a timer of attempts to find an element in the dom
453
229
  this._bindEvent(advanceOn[i], step.advanceOnOptions, advanceEvent$, destroyedEvent$);
454
- }));
455
- /** @type {?} */
230
+ });
456
231
  const advanceSubs = forkJoin(...advanceArr$)
457
232
  .pipe(takeUntil(merge(destroyedEvent$, backEvent$)))
458
- .subscribe((/**
459
- * @return {?}
460
- */
461
- () => {
233
+ .subscribe(() => {
462
234
  // check if we need to advance to a specific step, else advance to next step
463
235
  if (step.advanceOnOptions && step.advanceOnOptions.jumpTo) {
464
236
  this.shepherdTour.show(step.advanceOnOptions.jumpTo);
@@ -468,41 +240,27 @@ class CovalentGuidedTour extends TourButtonsActions {
468
240
  }
469
241
  forwardEvent$.next();
470
242
  advanceSubs.unsubscribe();
471
- }));
243
+ });
472
244
  }
473
245
  // if abortOn was passed on the step, we bind the event and execute complete
474
246
  if (step.abortOn) {
475
- /** @type {?} */
476
247
  const abortArr$ = [];
477
- step.abortOn.forEach((/**
478
- * @param {?} abortOn
479
- * @return {?}
480
- */
481
- (abortOn) => {
482
- /** @type {?} */
248
+ step.abortOn.forEach((abortOn) => {
483
249
  const abortEvent$ = new Subject();
484
250
  abortArr$.push(abortEvent$);
485
251
  this._bindEvent(abortOn, undefined, abortEvent$, destroyedEvent$);
486
- }));
487
- /** @type {?} */
252
+ });
488
253
  const abortSubs = merge(...abortArr$)
489
254
  .pipe(takeUntil(merge(destroyedEvent$, backEvent$, forwardEvent$)))
490
- .subscribe((/**
491
- * @return {?}
492
- */
493
- () => {
255
+ .subscribe(() => {
494
256
  this.shepherdTour.complete();
495
257
  abortSubs.unsubscribe();
496
- }));
258
+ });
497
259
  }
498
- });
499
- /** @type {?} */
260
+ };
500
261
  const _stopTimer$ = new Subject();
501
- /** @type {?} */
502
262
  const _retriesReached$ = new Subject();
503
- /** @type {?} */
504
263
  const _retryAttempts$ = new BehaviorSubject(-1);
505
- /** @type {?} */
506
264
  let id;
507
265
  // checks if "attachTo" is a string or an object to get the id of an element
508
266
  if (typeof step.attachTo === 'string') {
@@ -515,28 +273,20 @@ class CovalentGuidedTour extends TourButtonsActions {
515
273
  if (id) {
516
274
  // if current step is the first step of the tour, we set the buttons to be only "next"
517
275
  // we had to use `any` since the tour doesnt expose the steps in any fashion nor a way to check if we have modified them at all
518
- if (this.shepherdTour.getCurrentStep() === ((/** @type {?} */ (this.shepherdTour))).steps[0]) {
276
+ if (this.shepherdTour.getCurrentStep() === this.shepherdTour.steps[0]) {
519
277
  this.shepherdTour.getCurrentStep().updateStepOptions({
520
278
  buttons: originalSteps[index].advanceOn ? [voidButton] : [nextButton],
521
279
  });
522
280
  }
523
281
  // register to the attempts observable to notify deeveloper when number has been reached
524
282
  _retryAttempts$
525
- .pipe(skip(1), takeUntil(merge(_stopTimer$.asObservable(), destroyedEvent$)), skipWhile((/**
526
- * @param {?} val
527
- * @return {?}
528
- */
529
- (val) => {
283
+ .pipe(skip(1), takeUntil(merge(_stopTimer$.asObservable(), destroyedEvent$)), skipWhile((val) => {
530
284
  if (step.attachToOptions && step.attachToOptions.retries !== undefined) {
531
285
  return val < step.attachToOptions.retries;
532
286
  }
533
287
  return val < SHEPHERD_DEFAULT_FIND_ATTEMPTS;
534
- })))
535
- .subscribe((/**
536
- * @param {?} attempts
537
- * @return {?}
538
- */
539
- (attempts) => {
288
+ }))
289
+ .subscribe((attempts) => {
540
290
  _retriesReached$.next();
541
291
  _retriesReached$.complete();
542
292
  // if attempts have been reached, we check "skipIfNotFound" to move on to the next step
@@ -545,7 +295,7 @@ class CovalentGuidedTour extends TourButtonsActions {
545
295
  // then we either check if its the first step and try going forward
546
296
  // or we keep going back until we find a step that actually exists
547
297
  if (_backFlow) {
548
- if (((/** @type {?} */ (this.shepherdTour))).steps.indexOf(this.shepherdTour.getCurrentStep()) === 0) {
298
+ if (this.shepherdTour.steps.indexOf(this.shepherdTour.getCurrentStep()) === 0) {
549
299
  this.shepherdTour.next();
550
300
  }
551
301
  else {
@@ -555,11 +305,10 @@ class CovalentGuidedTour extends TourButtonsActions {
555
305
  }
556
306
  else {
557
307
  // destroys current step if we need to skip it to remove it from the tour
558
- /** @type {?} */
559
308
  const currentStep = this.shepherdTour.getCurrentStep();
560
309
  currentStep.destroy();
561
310
  this.shepherdTour.next();
562
- this.shepherdTour.removeStep(((/** @type {?} */ (currentStep))).id);
311
+ this.shepherdTour.removeStep(currentStep.id);
563
312
  }
564
313
  }
565
314
  else if (step.attachToOptions && step.attachToOptions.else) {
@@ -572,17 +321,13 @@ class CovalentGuidedTour extends TourButtonsActions {
572
321
  // else we show the step regardless
573
322
  resolve();
574
323
  }
575
- }));
324
+ });
576
325
  // we start a timer of attempts to find an element in the dom
577
326
  timer((step.attachToOptions && step.attachToOptions.timeBeforeShow) || SHEPHERD_DEFAULT_FIND_TIME_BEFORE_SHOW, (step.attachToOptions && step.attachToOptions.interval) || SHEPHERD_DEFAULT_FIND_INTERVAL)
578
327
  .pipe(
579
328
  // the timer will continue either until we find the element or the number of attempts has been reached
580
329
  takeUntil(merge(_stopTimer$, _retriesReached$, destroyedEvent$)))
581
- .subscribe((/**
582
- * @return {?}
583
- */
584
- () => {
585
- /** @type {?} */
330
+ .subscribe(() => {
586
331
  const element = document.querySelector(id);
587
332
  // if the element has been found, we stop the timer and resolve the promise
588
333
  if (element) {
@@ -594,56 +339,35 @@ class CovalentGuidedTour extends TourButtonsActions {
594
339
  else {
595
340
  _retryAttempts$.next(_retryAttempts$.value + 1);
596
341
  }
597
- }));
342
+ });
598
343
  // stop find interval if user stops the tour
599
- destroyedEvent$.subscribe((/**
600
- * @return {?}
601
- */
602
- () => {
344
+ destroyedEvent$.subscribe(() => {
603
345
  _stopTimer$.next();
604
346
  _stopTimer$.complete();
605
347
  _retriesReached$.next();
606
348
  _retriesReached$.complete();
607
- }));
349
+ });
608
350
  }
609
351
  else {
610
352
  // resolve observable until the timeBeforeShow has passsed or use default
611
353
  timer((step.attachToOptions && step.attachToOptions.timeBeforeShow) || SHEPHERD_DEFAULT_FIND_TIME_BEFORE_SHOW)
612
354
  .pipe(takeUntil(merge(destroyedEvent$)))
613
- .subscribe((/**
614
- * @return {?}
615
- */
616
- () => {
355
+ .subscribe(() => {
617
356
  resolve();
618
- }));
357
+ });
619
358
  }
620
- }));
621
- });
622
- }));
359
+ });
360
+ };
361
+ });
623
362
  return steps;
624
363
  }
625
- /**
626
- * @private
627
- * @param {?} eventOn
628
- * @param {?} eventOnOptions
629
- * @param {?} event$
630
- * @param {?} destroyedEvent$
631
- * @return {?}
632
- */
633
364
  _bindEvent(eventOn, eventOnOptions, event$, destroyedEvent$) {
634
- /** @type {?} */
635
365
  const selector = eventOn.selector;
636
- /** @type {?} */
637
366
  const event = eventOn.event;
638
367
  // we start a timer of attempts to find an element in the dom
639
- /** @type {?} */
640
368
  const timerSubs = timer((eventOnOptions && eventOnOptions.timeBeforeShow) || SHEPHERD_DEFAULT_FIND_TIME_BEFORE_SHOW, (eventOnOptions && eventOnOptions.interval) || SHEPHERD_DEFAULT_FIND_INTERVAL)
641
369
  .pipe(takeUntil(destroyedEvent$))
642
- .subscribe((/**
643
- * @return {?}
644
- */
645
- () => {
646
- /** @type {?} */
370
+ .subscribe(() => {
647
371
  const element = document.querySelector(selector);
648
372
  // if the element has been found, we stop the timer and resolve the promise
649
373
  if (element) {
@@ -657,16 +381,10 @@ class CovalentGuidedTour extends TourButtonsActions {
657
381
  event === ITourEvent.pointerover ||
658
382
  event.indexOf(ITourEvent.keyup) > -1) {
659
383
  // we use normal listeners for mouseevents
660
- /** @type {?} */
661
384
  const mainEvent = event.split('.')[0];
662
- /** @type {?} */
663
385
  const subEvent = event.split('.')[1];
664
386
  fromEvent(element, mainEvent)
665
- .pipe(takeUntil(merge(event$.asObservable(), destroyedEvent$)), filter((/**
666
- * @param {?} $event
667
- * @return {?}
668
- */
669
- ($event) => {
387
+ .pipe(takeUntil(merge(event$.asObservable(), destroyedEvent$)), filter(($event) => {
670
388
  // only trigger if the event is a keyboard event and part of out list
671
389
  if ($event instanceof KeyboardEvent) {
672
390
  if (keyEvents.get($event.keyCode) === subEvent) {
@@ -677,105 +395,47 @@ class CovalentGuidedTour extends TourButtonsActions {
677
395
  else {
678
396
  return true;
679
397
  }
680
- })))
681
- .subscribe((/**
682
- * @return {?}
683
- */
684
- () => {
398
+ }))
399
+ .subscribe(() => {
685
400
  event$.next();
686
401
  event$.complete();
687
- }));
402
+ });
688
403
  }
689
404
  else if (event === ITourEvent.removed) {
690
405
  // and we will use MutationObserver for DOM events
691
- /** @type {?} */
692
- const observer = new MutationObserver((/**
693
- * @return {?}
694
- */
695
- () => {
406
+ const observer = new MutationObserver(() => {
696
407
  if (!document.body.contains(element)) {
697
408
  event$.next();
698
409
  event$.complete();
699
410
  observer.disconnect();
700
411
  }
701
- }));
412
+ });
702
413
  // stop listenining if tour is closed
703
- destroyedEvent$.subscribe((/**
704
- * @return {?}
705
- */
706
- () => {
414
+ destroyedEvent$.subscribe(() => {
707
415
  observer.disconnect();
708
- }));
416
+ });
709
417
  // observe for any DOM interaction in the element
710
418
  observer.observe(element, { childList: true, subtree: true, attributes: true });
711
419
  }
712
420
  }
713
- }));
421
+ });
714
422
  }
715
423
  }
716
- if (false) {
717
- /**
718
- * @type {?}
719
- * @private
720
- */
721
- CovalentGuidedTour.prototype._destroyedEvent$;
722
- /** @type {?} */
723
- CovalentGuidedTour.prototype.shepherdTour;
724
- /** @type {?} */
725
- CovalentGuidedTour.prototype.stepOptions;
726
- }
727
424
 
728
425
  /**
729
- * @fileoverview added by tsickle
730
- * Generated from: guided-tour.service.ts
731
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
732
- */
733
- /**
734
- * @record
735
- */
736
- function IGuidedTour() { }
737
- if (false) {
738
- /** @type {?} */
739
- IGuidedTour.prototype.steps;
740
- /** @type {?|undefined} */
741
- IGuidedTour.prototype.finishButtonText;
742
- }
743
- /**
744
- * @record
745
- */
746
- function IGuidedTourStep() { }
747
- if (false) {
748
- /** @type {?|undefined} */
749
- IGuidedTourStep.prototype.routing;
750
- }
751
- /** @enum {string} */
752
- const TourEvents = {
753
- complete: "complete",
754
- cancel: "cancel",
755
- hide: "hide",
756
- show: "show",
757
- start: "start",
758
- active: "active",
759
- inactive: "inactive",
760
- };
761
- /**
762
- * @record
426
+ * Router enabled Shepherd tour
763
427
  */
764
- function IGuidedTourEvent() { }
765
- if (false) {
766
- /** @type {?} */
767
- IGuidedTourEvent.prototype.step;
768
- /** @type {?} */
769
- IGuidedTourEvent.prototype.previous;
770
- /** @type {?} */
771
- IGuidedTourEvent.prototype.tour;
772
- }
428
+ var TourEvents;
429
+ (function (TourEvents) {
430
+ TourEvents["complete"] = "complete";
431
+ TourEvents["cancel"] = "cancel";
432
+ TourEvents["hide"] = "hide";
433
+ TourEvents["show"] = "show";
434
+ TourEvents["start"] = "start";
435
+ TourEvents["active"] = "active";
436
+ TourEvents["inactive"] = "inactive";
437
+ })(TourEvents || (TourEvents = {}));
773
438
  class CovalentGuidedTourService extends CovalentGuidedTour {
774
- /**
775
- * @param {?} _router
776
- * @param {?} _route
777
- * @param {?} _httpClient
778
- */
779
439
  constructor(_router, _route, _httpClient) {
780
440
  super();
781
441
  this._router = _router;
@@ -784,64 +444,34 @@ class CovalentGuidedTourService extends CovalentGuidedTour {
784
444
  this._toursMap = new Map();
785
445
  this._tourStepURLs = new Map();
786
446
  _router.events
787
- .pipe(filter((/**
788
- * @param {?} event
789
- * @return {?}
790
- */
791
- (event) => event instanceof NavigationStart && event.navigationTrigger === 'popstate')))
792
- .subscribe((/**
793
- * @param {?} event
794
- * @return {?}
795
- */
796
- (event) => {
447
+ .pipe(filter((event) => event instanceof NavigationStart && event.navigationTrigger === 'popstate'))
448
+ .subscribe((event) => {
797
449
  if (this.shepherdTour.isActive) {
798
450
  this.shepherdTour.cancel();
799
451
  }
800
- }));
452
+ });
801
453
  }
802
- /**
803
- * @param {?} str
804
- * @return {?}
805
- */
806
454
  tourEvent$(str) {
807
455
  return fromEvent(this.shepherdTour, str);
808
456
  }
809
- /**
810
- * @param {?} tourName
811
- * @param {?} tour
812
- * @return {?}
813
- */
814
457
  registerTour(tourName, tour) {
815
458
  return __awaiter(this, void 0, void 0, function* () {
816
- /** @type {?} */
817
459
  const guidedTour = typeof tour === 'string' ? yield this._loadTour(tour) : tour;
818
460
  this._toursMap.set(tourName, guidedTour);
819
461
  });
820
462
  }
821
- /**
822
- * @param {?} tourName
823
- * @return {?}
824
- */
825
463
  startTour(tourName) {
826
- /** @type {?} */
827
464
  const guidedTour = this._getTour(tourName);
828
465
  this.finish();
829
466
  if (guidedTour && guidedTour.steps && guidedTour.steps.length) {
830
467
  // remove steps from tour since we need to preprocess them first
831
468
  this.newTour(Object.assign({}, guidedTour, { steps: undefined }));
832
- /** @type {?} */
833
469
  const tourInstance = this.shepherdTour.addSteps(this._configureRoutesForSteps(this._prepareTour(guidedTour.steps, guidedTour.finishButtonText)));
834
470
  // init route transition if step URL is different then the current location.
835
- this.tourEvent$(TourEvents.show).subscribe((/**
836
- * @param {?} tourEvent
837
- * @return {?}
838
- */
839
- (tourEvent) => {
840
- /** @type {?} */
471
+ this.tourEvent$(TourEvents.show).subscribe((tourEvent) => {
841
472
  const currentURL = this._router.url.split(/[?#]/)[0];
842
473
  const { step: { id, options }, } = tourEvent;
843
474
  if (this._tourStepURLs.has(id)) {
844
- /** @type {?} */
845
475
  const stepRoute = this._tourStepURLs.get(id);
846
476
  if (stepRoute !== currentURL) {
847
477
  this._router.navigate([stepRoute]);
@@ -855,7 +485,7 @@ class CovalentGuidedTourService extends CovalentGuidedTour {
855
485
  this._tourStepURLs.set(id, currentURL);
856
486
  }
857
487
  }
858
- }));
488
+ });
859
489
  this.start();
860
490
  return tourInstance;
861
491
  }
@@ -866,27 +496,16 @@ class CovalentGuidedTourService extends CovalentGuidedTour {
866
496
  }
867
497
  // Finds the right registered tour by using queryParams
868
498
  // finishes any other tour and starts the new one.
869
- /**
870
- * @param {?=} queryParam
871
- * @return {?}
872
- */
873
499
  initializeOnQueryParams(queryParam = 'tour') {
874
- return this._route.queryParamMap.pipe(debounceTime(100), tap((/**
875
- * @param {?} params
876
- * @return {?}
877
- */
878
- (params) => {
879
- /** @type {?} */
500
+ return this._route.queryParamMap.pipe(debounceTime(100), tap((params) => {
880
501
  const tourParam = params.get(queryParam);
881
502
  if (tourParam) {
882
503
  this.startTour(tourParam);
883
504
  // get current search parameters
884
- /** @type {?} */
885
505
  const searchParams = new URLSearchParams(window.location.search);
886
506
  // delete tour queryParam
887
507
  searchParams.delete(queryParam);
888
508
  // build new URL string without it
889
- /** @type {?} */
890
509
  let url = window.location.protocol + '//' + window.location.host + window.location.pathname;
891
510
  if (searchParams.toString()) {
892
511
  url += '?' + searchParams.toString();
@@ -894,47 +513,27 @@ class CovalentGuidedTourService extends CovalentGuidedTour {
894
513
  // replace state in history without triggering a navigation
895
514
  window.history.replaceState({ path: url }, '', url);
896
515
  }
897
- })));
516
+ }));
898
517
  }
899
- /**
900
- * @param {?} stepId
901
- * @param {?} isDisabled
902
- * @return {?}
903
- */
904
518
  setNextBtnDisability(stepId, isDisabled) {
905
519
  if (this.shepherdTour.getById(stepId)) {
906
- /** @type {?} */
907
- const stepOptions = ((/** @type {?} */ (this.shepherdTour.getById(stepId)))).options;
908
- stepOptions.buttons.forEach((/**
909
- * @param {?} button
910
- * @return {?}
911
- */
912
- (button) => {
520
+ const stepOptions = this.shepherdTour.getById(stepId).options;
521
+ stepOptions.buttons.forEach((button) => {
913
522
  if (button.text === 'chevron_right') {
914
523
  button.disabled = isDisabled;
915
524
  }
916
- }));
525
+ });
917
526
  this.shepherdTour.getById(stepId).updateStepOptions(stepOptions);
918
527
  }
919
528
  }
920
- /**
921
- * @private
922
- * @param {?} tourUrl
923
- * @return {?}
924
- */
925
529
  _loadTour(tourUrl) {
926
530
  return __awaiter(this, void 0, void 0, function* () {
927
- /** @type {?} */
928
531
  const request = this._httpClient.get(tourUrl);
929
532
  try {
930
533
  return yield request
931
- .pipe(map((/**
932
- * @param {?} resultSet
933
- * @return {?}
934
- */
935
- (resultSet) => {
534
+ .pipe(map((resultSet) => {
936
535
  return JSON.parse(JSON.stringify(resultSet));
937
- })))
536
+ }))
938
537
  .toPromise();
939
538
  }
940
539
  catch (_a) {
@@ -942,125 +541,59 @@ class CovalentGuidedTourService extends CovalentGuidedTour {
942
541
  }
943
542
  });
944
543
  }
945
- /**
946
- * @private
947
- * @param {?} key
948
- * @return {?}
949
- */
950
544
  _getTour(key) {
951
545
  return this._toursMap.get(key);
952
546
  }
953
- /**
954
- * @private
955
- * @param {?} routedSteps
956
- * @return {?}
957
- */
958
547
  _configureRoutesForSteps(routedSteps) {
959
- routedSteps.forEach((/**
960
- * @param {?} step
961
- * @return {?}
962
- */
963
- (step) => {
548
+ routedSteps.forEach((step) => {
964
549
  if (step.routing) {
965
- /** @type {?} */
966
550
  const route = step.routing.route;
967
551
  // if there is a beforeShowPromise, then we save it and call it after the navigation
968
552
  if (step.beforeShowPromise) {
969
- /** @type {?} */
970
553
  const beforeShowPromise = step.beforeShowPromise;
971
- step.beforeShowPromise = (/**
972
- * @return {?}
973
- */
974
- () => {
975
- return this._router.navigate([route], step.routing.extras).then((/**
976
- * @return {?}
977
- */
978
- () => {
554
+ step.beforeShowPromise = () => {
555
+ return this._router.navigate([route], step.routing.extras).then(() => {
979
556
  return beforeShowPromise();
980
- }));
981
- });
557
+ });
558
+ };
982
559
  }
983
560
  else {
984
- step.beforeShowPromise = (/**
985
- * @return {?}
986
- */
987
- () => this._router.navigate([route]));
561
+ step.beforeShowPromise = () => this._router.navigate([route]);
988
562
  }
989
563
  }
990
- }));
564
+ });
991
565
  return routedSteps;
992
566
  }
993
567
  }
994
- CovalentGuidedTourService.decorators = [
995
- { type: Injectable }
996
- ];
997
- /** @nocollapse */
998
- CovalentGuidedTourService.ctorParameters = () => [
999
- { type: Router },
1000
- { type: ActivatedRoute },
1001
- { type: HttpClient }
1002
- ];
1003
- if (false) {
1004
- /**
1005
- * @type {?}
1006
- * @private
1007
- */
1008
- CovalentGuidedTourService.prototype._toursMap;
1009
- /**
1010
- * @type {?}
1011
- * @private
1012
- */
1013
- CovalentGuidedTourService.prototype._tourStepURLs;
1014
- /**
1015
- * @type {?}
1016
- * @private
1017
- */
1018
- CovalentGuidedTourService.prototype._router;
1019
- /**
1020
- * @type {?}
1021
- * @private
1022
- */
1023
- CovalentGuidedTourService.prototype._route;
1024
- /**
1025
- * @type {?}
1026
- * @private
1027
- */
1028
- CovalentGuidedTourService.prototype._httpClient;
1029
- }
568
+ /** @nocollapse */ /** @nocollapse */ CovalentGuidedTourService.ɵfac = function CovalentGuidedTourService_Factory(t) { return new (t || CovalentGuidedTourService)(i0.ɵɵinject(i1.Router), i0.ɵɵinject(i1.ActivatedRoute), i0.ɵɵinject(i2.HttpClient)); };
569
+ /** @nocollapse */ /** @nocollapse */ CovalentGuidedTourService.ɵprov = /** @pureOrBreakMyCode */ i0.ɵɵdefineInjectable({ token: CovalentGuidedTourService, factory: CovalentGuidedTourService.ɵfac });
570
+ (function () {
571
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CovalentGuidedTourService, [{
572
+ type: Injectable
573
+ }], function () { return [{ type: i1.Router }, { type: i1.ActivatedRoute }, { type: i2.HttpClient }]; }, null);
574
+ })();
1030
575
 
1031
- /**
1032
- * @fileoverview added by tsickle
1033
- * Generated from: guided-tour.module.ts
1034
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1035
- */
1036
576
  class CovalentGuidedTourModule {
1037
577
  }
1038
- CovalentGuidedTourModule.decorators = [
1039
- { type: NgModule, args: [{
1040
- imports: [CommonModule],
1041
- providers: [CovalentGuidedTourService],
1042
- declarations: [],
1043
- exports: [],
1044
- },] }
1045
- ];
1046
-
1047
- /**
1048
- * @fileoverview added by tsickle
1049
- * Generated from: public-api.ts
1050
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1051
- */
1052
-
1053
- /**
1054
- * @fileoverview added by tsickle
1055
- * Generated from: index.ts
1056
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1057
- */
578
+ /** @nocollapse */ /** @nocollapse */ CovalentGuidedTourModule.ɵfac = function CovalentGuidedTourModule_Factory(t) { return new (t || CovalentGuidedTourModule)(); };
579
+ /** @nocollapse */ /** @nocollapse */ CovalentGuidedTourModule.ɵmod = /** @pureOrBreakMyCode */ i0.ɵɵdefineNgModule({ type: CovalentGuidedTourModule });
580
+ /** @nocollapse */ /** @nocollapse */ CovalentGuidedTourModule.ɵinj = /** @pureOrBreakMyCode */ i0.ɵɵdefineInjector({ providers: [CovalentGuidedTourService], imports: [[CommonModule]] });
581
+ (function () {
582
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CovalentGuidedTourModule, [{
583
+ type: NgModule,
584
+ args: [{
585
+ imports: [CommonModule],
586
+ providers: [CovalentGuidedTourService],
587
+ declarations: [],
588
+ exports: [],
589
+ }]
590
+ }], null, null);
591
+ })();
592
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(CovalentGuidedTourModule, { imports: [CommonModule] }); })();
1058
593
 
1059
594
  /**
1060
- * @fileoverview added by tsickle
1061
- * Generated from: covalent-guided-tour.ts
1062
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
595
+ * Generated bundle index. Do not edit.
1063
596
  */
1064
597
 
1065
598
  export { CovalentGuidedTour, CovalentGuidedTourModule, CovalentGuidedTourService, ITourEvent, TourEvents };
1066
- //# sourceMappingURL=covalent-guided-tour.js.map
599
+ //# sourceMappingURL=covalent-guided-tour.mjs.map