@covalent/guided-tour 4.0.0 → 4.1.0-develop.5

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.
Files changed (33) hide show
  1. package/README.md +32 -15
  2. package/_guided-tour-theme.scss +6 -6
  3. package/covalent-guided-tour.d.ts +2 -1
  4. package/esm2020/covalent-guided-tour.mjs +5 -0
  5. package/esm2020/lib/guided-tour.module.mjs +19 -0
  6. package/esm2020/lib/guided-tour.service.mjs +163 -0
  7. package/esm2020/lib/guided.tour.mjs +438 -0
  8. package/esm2020/public_api.mjs +4 -0
  9. package/fesm2015/{covalent-guided-tour.js → covalent-guided-tour.mjs} +180 -615
  10. package/fesm2015/covalent-guided-tour.mjs.map +1 -0
  11. package/fesm2020/covalent-guided-tour.mjs +619 -0
  12. package/fesm2020/covalent-guided-tour.mjs.map +1 -0
  13. package/lib/guided-tour.module.d.ts +7 -0
  14. package/{guided-tour.service.d.ts → lib/guided-tour.service.d.ts} +4 -1
  15. package/{guided.tour.d.ts → lib/guided.tour.d.ts} +3 -7
  16. package/package.json +25 -21
  17. package/public_api.d.ts +3 -0
  18. package/{_guided-tour.scss → styles/guided-tour.scss} +17 -2
  19. package/bundles/covalent-guided-tour.umd.js +0 -1369
  20. package/bundles/covalent-guided-tour.umd.js.map +0 -1
  21. package/bundles/covalent-guided-tour.umd.min.js +0 -16
  22. package/bundles/covalent-guided-tour.umd.min.js.map +0 -1
  23. package/covalent-guided-tour.metadata.json +0 -1
  24. package/esm2015/covalent-guided-tour.js +0 -10
  25. package/esm2015/guided-tour.module.js +0 -19
  26. package/esm2015/guided-tour.service.js +0 -312
  27. package/esm2015/guided.tour.js +0 -722
  28. package/esm2015/index.js +0 -7
  29. package/esm2015/public-api.js +0 -9
  30. package/fesm2015/covalent-guided-tour.js.map +0 -1
  31. package/guided-tour.module.d.ts +0 -2
  32. package/index.d.ts +0 -1
  33. package/public-api.d.ts +0 -3
@@ -0,0 +1,619 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, NgModule } from '@angular/core';
3
+ import { CommonModule } from '@angular/common';
4
+ import * as i2 from '@angular/common/http';
5
+ import * as i1 from '@angular/router';
6
+ import { NavigationStart } from '@angular/router';
7
+ import { first, takeUntil, skip, skipWhile, filter, debounceTime, tap, map } from 'rxjs/operators';
8
+ import { Subject, merge, fromEvent, forkJoin, BehaviorSubject, timer } from 'rxjs';
9
+ import Shepherd from 'shepherd.js';
10
+
11
+ var ITourEvent;
12
+ (function (ITourEvent) {
13
+ ITourEvent["click"] = "click";
14
+ ITourEvent["pointerover"] = "pointerover";
15
+ ITourEvent["keyup"] = "keyup";
16
+ ITourEvent["added"] = "added";
17
+ ITourEvent["removed"] = "removed";
18
+ })(ITourEvent || (ITourEvent = {}));
19
+ class TourButtonsActions {
20
+ }
21
+ const SHEPHERD_DEFAULT_FIND_TIME_BEFORE_SHOW = 100;
22
+ const SHEPHERD_DEFAULT_FIND_INTERVAL = 500;
23
+ const SHEPHERD_DEFAULT_FIND_ATTEMPTS = 20;
24
+ const overriddenEvents = [
25
+ ITourEvent.click,
26
+ ITourEvent.pointerover,
27
+ ITourEvent.removed,
28
+ ITourEvent.added,
29
+ ITourEvent.keyup,
30
+ ];
31
+ const keyEvents = new Map([
32
+ [13, 'enter'],
33
+ [27, 'esc'],
34
+ ]);
35
+ const defaultStepOptions = {
36
+ scrollTo: { behavior: 'smooth', block: 'center' },
37
+ cancelIcon: {
38
+ enabled: true,
39
+ },
40
+ };
41
+ const MAT_ICON_BUTTON = 'mat-icon-button material-icons mat-button-base';
42
+ const MAT_BUTTON = 'mat-button-base mat-button';
43
+ const MAT_BUTTON_INVISIBLE = 'shepherd-void-button';
44
+ class CovalentGuidedTour extends TourButtonsActions {
45
+ constructor(stepOptions = defaultStepOptions) {
46
+ super();
47
+ this.stepOptions = stepOptions;
48
+ this.newTour();
49
+ }
50
+ newTour(opts) {
51
+ this.shepherdTour = new Shepherd.Tour(Object.assign({
52
+ defaultStepOptions: this.stepOptions,
53
+ }, opts));
54
+ this._destroyedEvent$ = new Subject();
55
+ // listen to cancel and complete to clean up abortOn events
56
+ merge(fromEvent(this.shepherdTour, 'cancel'), fromEvent(this.shepherdTour, 'complete'))
57
+ .pipe(first())
58
+ .subscribe(() => {
59
+ this._destroyedEvent$.next();
60
+ this._destroyedEvent$.complete();
61
+ });
62
+ // if abortOn was passed, we bind the event and execute complete
63
+ if (opts && opts.abortOn) {
64
+ const abortArr$ = [];
65
+ opts.abortOn.forEach((abortOn) => {
66
+ const abortEvent$ = new Subject();
67
+ abortArr$.push(abortEvent$);
68
+ this._bindEvent(abortOn, undefined, abortEvent$, this._destroyedEvent$);
69
+ });
70
+ const abortSubs = merge(...abortArr$)
71
+ .pipe(takeUntil(this._destroyedEvent$))
72
+ .subscribe(() => {
73
+ this.shepherdTour.complete();
74
+ abortSubs.unsubscribe();
75
+ });
76
+ }
77
+ }
78
+ back() {
79
+ this.shepherdTour.back();
80
+ }
81
+ cancel() {
82
+ this.shepherdTour.cancel();
83
+ }
84
+ next() {
85
+ this.shepherdTour.next();
86
+ }
87
+ finish() {
88
+ this.shepherdTour.complete();
89
+ }
90
+ addSteps(steps) {
91
+ this.shepherdTour.addSteps(this._prepareTour(steps));
92
+ }
93
+ start() {
94
+ this.shepherdTour.start();
95
+ }
96
+ _prepareTour(originalSteps, finishLabel = 'finish') {
97
+ // create Subjects for back and forward events
98
+ const backEvent$ = new Subject();
99
+ const forwardEvent$ = new Subject();
100
+ let _backFlow = false;
101
+ // create Subject for your end
102
+ const destroyedEvent$ = new Subject();
103
+ /**
104
+ * This function adds the step progress in the footer of the shepherd tooltip
105
+ */
106
+ const appendProgressFunc = function () {
107
+ // get all the footers that are available in the DOM
108
+ const footers = Array.from(document.querySelectorAll('.shepherd-footer'));
109
+ // get the last footer since Shepherd always puts the active one at the end
110
+ const footer = footers[footers.length - 1];
111
+ // generate steps html element
112
+ const progress = document.createElement('span');
113
+ progress.className = 'shepherd-progress';
114
+ progress.innerText = `${this.shepherdTour.currentStep.options.count}/${stepTotal}`;
115
+ // insert into the footer before the first button
116
+ footer.insertBefore(progress, footer.querySelector('.shepherd-button'));
117
+ };
118
+ let stepTotal = 0;
119
+ const steps = originalSteps.map((step) => {
120
+ let showProgress = () => {
121
+ //
122
+ };
123
+ if (step.attachToOptions?.skipFromStepCount === true) {
124
+ showProgress = function () {
125
+ return;
126
+ };
127
+ }
128
+ else if (step.attachToOptions?.skipFromStepCount === undefined ||
129
+ step.attachToOptions?.skipFromStepCount === false) {
130
+ step.count = ++stepTotal;
131
+ showProgress = appendProgressFunc.bind(this);
132
+ }
133
+ return Object.assign({}, step, {
134
+ when: {
135
+ show: showProgress,
136
+ },
137
+ });
138
+ });
139
+ const finishButton = {
140
+ text: finishLabel,
141
+ action: this['finish'].bind(this),
142
+ classes: MAT_BUTTON,
143
+ };
144
+ const voidButton = {
145
+ text: '',
146
+ action() {
147
+ return;
148
+ },
149
+ classes: MAT_BUTTON_INVISIBLE,
150
+ };
151
+ // listen to the destroyed event to clean up all the streams
152
+ this._destroyedEvent$.pipe(first()).subscribe(() => {
153
+ backEvent$.complete();
154
+ forwardEvent$.complete();
155
+ destroyedEvent$.next();
156
+ destroyedEvent$.complete();
157
+ });
158
+ const totalSteps = steps.length;
159
+ steps.forEach((step, index) => {
160
+ // create buttons specific for the step
161
+ // this is done to create more control on events
162
+ const nextButton = {
163
+ text: 'chevron_right',
164
+ action: () => {
165
+ // intercept the next action and trigger event
166
+ forwardEvent$.next();
167
+ this.shepherdTour.next();
168
+ },
169
+ classes: MAT_ICON_BUTTON,
170
+ };
171
+ const backButton = {
172
+ text: 'chevron_left',
173
+ action: () => {
174
+ // intercept the back action and trigger event
175
+ backEvent$.next();
176
+ _backFlow = true;
177
+ // check if 'goBackTo' is set to jump to a particular step, else just go back
178
+ if (step.attachToOptions && step.attachToOptions.goBackTo) {
179
+ this.shepherdTour.show(step.attachToOptions.goBackTo, false);
180
+ }
181
+ else {
182
+ this.shepherdTour.back();
183
+ }
184
+ },
185
+ classes: step.advanceOnOptions?.allowGoBack === false
186
+ ? MAT_BUTTON_INVISIBLE
187
+ : MAT_ICON_BUTTON,
188
+ };
189
+ // check if highlight was provided for the step, else fallback into shepherds usage
190
+ step.highlightClass =
191
+ step.attachToOptions && step.attachToOptions.highlight
192
+ ? 'shepherd-highlight'
193
+ : step.highlightClass;
194
+ // Adding buttons in the steps if no buttons are defined
195
+ if (!step.buttons || step.buttons.length === 0) {
196
+ if (index === 0) {
197
+ // first step
198
+ step.buttons = [nextButton];
199
+ }
200
+ else if (index === totalSteps - 1) {
201
+ // last step
202
+ step.buttons = [backButton, finishButton];
203
+ }
204
+ else {
205
+ step.buttons = [backButton, nextButton];
206
+ }
207
+ }
208
+ // checks "advanceOn" to override listeners
209
+ let advanceOn = step.advanceOn;
210
+ // remove the shepherd "advanceOn" infavor of ours if the event is part of our list
211
+ if ((typeof advanceOn === 'object' &&
212
+ !Array.isArray(advanceOn) &&
213
+ advanceOn.event &&
214
+ overriddenEvents.indexOf(advanceOn.event.split('.')[0]) > -1) ||
215
+ advanceOn instanceof Array) {
216
+ step.advanceOn = undefined;
217
+ step.buttons =
218
+ step.advanceOnOptions && step.advanceOnOptions.allowGoBack
219
+ ? [backButton, voidButton]
220
+ : [voidButton];
221
+ }
222
+ // adds a default beforeShowPromise function
223
+ step.beforeShowPromise = () => {
224
+ return new Promise((resolve) => {
225
+ const additionalCapabilitiesSetup = () => {
226
+ if (advanceOn && !step.advanceOn) {
227
+ if (!Array.isArray(advanceOn)) {
228
+ advanceOn = [advanceOn];
229
+ }
230
+ const advanceArr$ = [];
231
+ advanceOn.forEach((_, i) => {
232
+ const advanceEvent$ = new Subject();
233
+ advanceArr$.push(advanceEvent$);
234
+ // we start a timer of attempts to find an element in the dom
235
+ this._bindEvent(_, step.advanceOnOptions, advanceEvent$, destroyedEvent$);
236
+ });
237
+ const advanceSubs = forkJoin(...advanceArr$)
238
+ .pipe(takeUntil(merge(destroyedEvent$, backEvent$)))
239
+ .subscribe(() => {
240
+ // check if we need to advance to a specific step, else advance to next step
241
+ if (step.advanceOnOptions && step.advanceOnOptions.jumpTo) {
242
+ this.shepherdTour.show(step.advanceOnOptions.jumpTo);
243
+ }
244
+ else {
245
+ this.shepherdTour.next();
246
+ }
247
+ forwardEvent$.next();
248
+ advanceSubs.unsubscribe();
249
+ });
250
+ }
251
+ // if abortOn was passed on the step, we bind the event and execute complete
252
+ if (step.abortOn) {
253
+ const abortArr$ = [];
254
+ step.abortOn.forEach((abortOn) => {
255
+ const abortEvent$ = new Subject();
256
+ abortArr$.push(abortEvent$);
257
+ this._bindEvent(abortOn, undefined, abortEvent$, destroyedEvent$);
258
+ });
259
+ const abortSubs = merge(...abortArr$)
260
+ .pipe(takeUntil(merge(destroyedEvent$, backEvent$, forwardEvent$)))
261
+ .subscribe(() => {
262
+ this.shepherdTour.complete();
263
+ abortSubs.unsubscribe();
264
+ });
265
+ }
266
+ };
267
+ const _stopTimer$ = new Subject();
268
+ const _retriesReached$ = new Subject();
269
+ const _retryAttempts$ = new BehaviorSubject(-1);
270
+ let id;
271
+ // checks if "attachTo" is a string or an object to get the id of an element
272
+ if (typeof step.attachTo === 'string') {
273
+ id = step.attachTo;
274
+ }
275
+ else if (typeof step.attachTo === 'object' &&
276
+ typeof step.attachTo.element === 'string') {
277
+ id = step.attachTo.element;
278
+ }
279
+ // if we have an id as a string in either case, we use it (we ignore it if its HTMLElement)
280
+ if (id) {
281
+ // if current step is the first step of the tour, we set the buttons to be only "next"
282
+ // 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
283
+ if (this.shepherdTour.getCurrentStep() ===
284
+ this.shepherdTour.steps[0]) {
285
+ this.shepherdTour.getCurrentStep()?.updateStepOptions({
286
+ buttons: originalSteps[index].advanceOn
287
+ ? [voidButton]
288
+ : [nextButton],
289
+ });
290
+ }
291
+ // register to the attempts observable to notify deeveloper when number has been reached
292
+ _retryAttempts$
293
+ .pipe(skip(1), takeUntil(merge(_stopTimer$.asObservable(), destroyedEvent$)), skipWhile((val) => {
294
+ if (step.attachToOptions &&
295
+ step.attachToOptions.retries !== undefined) {
296
+ return val < step.attachToOptions.retries;
297
+ }
298
+ return val < SHEPHERD_DEFAULT_FIND_ATTEMPTS;
299
+ }))
300
+ .subscribe((attempts) => {
301
+ _retriesReached$.next(1);
302
+ _retriesReached$.complete();
303
+ // if attempts have been reached, we check "skipIfNotFound" to move on to the next step
304
+ if (step.attachToOptions &&
305
+ step.attachToOptions.skipIfNotFound) {
306
+ // if we get to this step coming back from a step and it wasnt found
307
+ // then we either check if its the first step and try going forward
308
+ // or we keep going back until we find a step that actually exists
309
+ if (_backFlow) {
310
+ if (this.shepherdTour.steps.indexOf(this.shepherdTour.getCurrentStep()) === 0) {
311
+ this.shepherdTour.next();
312
+ }
313
+ else {
314
+ this.shepherdTour.back();
315
+ }
316
+ _backFlow = false;
317
+ }
318
+ else {
319
+ // destroys current step if we need to skip it to remove it from the tour
320
+ const currentStep = this.shepherdTour.getCurrentStep();
321
+ currentStep?.destroy();
322
+ this.shepherdTour.next();
323
+ this.shepherdTour.removeStep(currentStep?.id ?? '');
324
+ }
325
+ }
326
+ else if (step.attachToOptions && step.attachToOptions.else) {
327
+ // if "skipIfNotFound" is not true, then we check if "else" has been set to jump to a specific step
328
+ this.shepherdTour.show(step.attachToOptions.else);
329
+ }
330
+ else {
331
+ // tslint:disable-next-line:no-console
332
+ console.warn(`Retries reached trying to find ${id}. Retried ${attempts} times.`);
333
+ // else we show the step regardless
334
+ resolve();
335
+ }
336
+ });
337
+ // we start a timer of attempts to find an element in the dom
338
+ timer((step.attachToOptions && step.attachToOptions.timeBeforeShow) ||
339
+ SHEPHERD_DEFAULT_FIND_TIME_BEFORE_SHOW, (step.attachToOptions && step.attachToOptions.interval) ||
340
+ SHEPHERD_DEFAULT_FIND_INTERVAL)
341
+ .pipe(
342
+ // the timer will continue either until we find the element or the number of attempts has been reached
343
+ takeUntil(merge(_stopTimer$, _retriesReached$, destroyedEvent$)))
344
+ .subscribe(() => {
345
+ const element = document.querySelector(id ?? '');
346
+ // if the element has been found, we stop the timer and resolve the promise
347
+ if (element) {
348
+ _stopTimer$.next();
349
+ _stopTimer$.complete();
350
+ additionalCapabilitiesSetup();
351
+ resolve();
352
+ }
353
+ else {
354
+ _retryAttempts$.next(_retryAttempts$.value + 1);
355
+ }
356
+ });
357
+ // stop find interval if user stops the tour
358
+ destroyedEvent$.subscribe(() => {
359
+ _stopTimer$.next();
360
+ _stopTimer$.complete();
361
+ _retriesReached$.next(1);
362
+ _retriesReached$.complete();
363
+ });
364
+ }
365
+ else {
366
+ // resolve observable until the timeBeforeShow has passsed or use default
367
+ timer((step.attachToOptions && step.attachToOptions.timeBeforeShow) ||
368
+ SHEPHERD_DEFAULT_FIND_TIME_BEFORE_SHOW)
369
+ .pipe(takeUntil(merge(destroyedEvent$)))
370
+ .subscribe(() => {
371
+ resolve();
372
+ });
373
+ }
374
+ });
375
+ };
376
+ });
377
+ return steps;
378
+ }
379
+ _bindEvent(eventOn, eventOnOptions, event$, destroyedEvent$) {
380
+ const selector = eventOn.selector ?? '';
381
+ const event = eventOn.event;
382
+ // we start a timer of attempts to find an element in the dom
383
+ const timerSubs = timer((eventOnOptions && eventOnOptions.timeBeforeShow) ||
384
+ SHEPHERD_DEFAULT_FIND_TIME_BEFORE_SHOW, (eventOnOptions && eventOnOptions.interval) ||
385
+ SHEPHERD_DEFAULT_FIND_INTERVAL)
386
+ .pipe(takeUntil(destroyedEvent$))
387
+ .subscribe(() => {
388
+ const element = document.querySelector(selector);
389
+ // if the element has been found, we stop the timer and resolve the promise
390
+ if (element) {
391
+ timerSubs.unsubscribe();
392
+ if (event === ITourEvent.added) {
393
+ // if event is "Added" trigger a soon as this is attached.
394
+ event$.next();
395
+ event$.complete();
396
+ }
397
+ else if (event === ITourEvent.click ||
398
+ event === ITourEvent.pointerover ||
399
+ (event && event.indexOf(ITourEvent.keyup) > -1)) {
400
+ // we use normal listeners for mouseevents
401
+ const mainEvent = event?.split('.')[0];
402
+ const subEvent = event?.split('.')[1];
403
+ fromEvent(element, mainEvent)
404
+ .pipe(takeUntil(merge(event$.asObservable(), destroyedEvent$)), filter(($event) => {
405
+ // only trigger if the event is a keyboard event and part of out list
406
+ if ($event instanceof KeyboardEvent) {
407
+ if (keyEvents.get($event.keyCode) === subEvent) {
408
+ return true;
409
+ }
410
+ return false;
411
+ }
412
+ else {
413
+ return true;
414
+ }
415
+ }))
416
+ .subscribe(() => {
417
+ event$.next();
418
+ event$.complete();
419
+ });
420
+ }
421
+ else if (event === ITourEvent.removed) {
422
+ // and we will use MutationObserver for DOM events
423
+ const observer = new MutationObserver(() => {
424
+ if (!document.body.contains(element)) {
425
+ event$.next();
426
+ event$.complete();
427
+ observer.disconnect();
428
+ }
429
+ });
430
+ // stop listenining if tour is closed
431
+ destroyedEvent$.subscribe(() => {
432
+ observer.disconnect();
433
+ });
434
+ // observe for any DOM interaction in the element
435
+ observer.observe(element, {
436
+ childList: true,
437
+ subtree: true,
438
+ attributes: true,
439
+ });
440
+ }
441
+ }
442
+ });
443
+ }
444
+ }
445
+
446
+ /**
447
+ * Router enabled Shepherd tour
448
+ */
449
+ var TourEvents;
450
+ (function (TourEvents) {
451
+ TourEvents["complete"] = "complete";
452
+ TourEvents["cancel"] = "cancel";
453
+ TourEvents["hide"] = "hide";
454
+ TourEvents["show"] = "show";
455
+ TourEvents["start"] = "start";
456
+ TourEvents["active"] = "active";
457
+ TourEvents["inactive"] = "inactive";
458
+ })(TourEvents || (TourEvents = {}));
459
+ class CovalentGuidedTourService extends CovalentGuidedTour {
460
+ constructor(_router, _route, _httpClient) {
461
+ super();
462
+ this._router = _router;
463
+ this._route = _route;
464
+ this._httpClient = _httpClient;
465
+ this._toursMap = new Map();
466
+ this._tourStepURLs = new Map();
467
+ _router.events
468
+ .pipe(filter((event) => event instanceof NavigationStart &&
469
+ event.navigationTrigger === 'popstate'))
470
+ .subscribe(() => {
471
+ if (this.shepherdTour.isActive()) {
472
+ this.shepherdTour.cancel();
473
+ }
474
+ });
475
+ }
476
+ tourEvent$(str) {
477
+ return fromEvent(this.shepherdTour, str);
478
+ }
479
+ async registerTour(tourName, tour) {
480
+ const guidedTour = typeof tour === 'string' ? await this._loadTour(tour) : tour;
481
+ this._toursMap.set(tourName, guidedTour);
482
+ }
483
+ startTour(tourName) {
484
+ const guidedTour = this._getTour(tourName);
485
+ this.finish();
486
+ if (guidedTour && guidedTour.steps && guidedTour.steps.length) {
487
+ // remove steps from tour since we need to preprocess them first
488
+ this.newTour(Object.assign({}, guidedTour, { steps: undefined }));
489
+ const tourInstance = this.shepherdTour.addSteps(this._configureRoutesForSteps(this._prepareTour(guidedTour.steps, guidedTour.finishButtonText)));
490
+ // init route transition if step URL is different then the current location.
491
+ this.tourEvent$(TourEvents.show).subscribe((tourEvent) => {
492
+ const currentURL = this._router.url.split(/[?#]/)[0];
493
+ const { step: { id, options }, } = tourEvent;
494
+ if (this._tourStepURLs.has(id)) {
495
+ const stepRoute = this._tourStepURLs.get(id);
496
+ if (stepRoute !== currentURL) {
497
+ this._router.navigate([stepRoute]);
498
+ }
499
+ }
500
+ else {
501
+ if (options && options.routing) {
502
+ this._tourStepURLs.set(id, options.routing.route);
503
+ }
504
+ else {
505
+ this._tourStepURLs.set(id, currentURL);
506
+ }
507
+ }
508
+ });
509
+ this.start();
510
+ return tourInstance;
511
+ }
512
+ else {
513
+ // tslint:disable-next-line:no-console
514
+ console.warn(`Tour ${tourName} does not exist. Please try another tour.`);
515
+ return undefined;
516
+ }
517
+ }
518
+ // Finds the right registered tour by using queryParams
519
+ // finishes any other tour and starts the new one.
520
+ initializeOnQueryParams(queryParam = 'tour') {
521
+ return this._route.queryParamMap.pipe(debounceTime(100), tap((params) => {
522
+ const tourParam = params.get(queryParam);
523
+ if (tourParam) {
524
+ this.startTour(tourParam);
525
+ // get current search parameters
526
+ const searchParams = new URLSearchParams(window.location.search);
527
+ // delete tour queryParam
528
+ searchParams.delete(queryParam);
529
+ // build new URL string without it
530
+ let url = window.location.protocol +
531
+ '//' +
532
+ window.location.host +
533
+ window.location.pathname;
534
+ if (searchParams.toString()) {
535
+ url += '?' + searchParams.toString();
536
+ }
537
+ // replace state in history without triggering a navigation
538
+ window.history.replaceState({ path: url }, '', url);
539
+ }
540
+ }));
541
+ }
542
+ setNextBtnDisability(stepId, isDisabled) {
543
+ if (this.shepherdTour.getById(stepId)) {
544
+ const stepOptions = this.shepherdTour.getById(stepId)
545
+ .options;
546
+ stepOptions.buttons?.forEach((button) => {
547
+ if (button.text === 'chevron_right') {
548
+ button.disabled = isDisabled;
549
+ }
550
+ });
551
+ this.shepherdTour.getById(stepId)?.updateStepOptions(stepOptions);
552
+ }
553
+ }
554
+ async _loadTour(tourUrl) {
555
+ const request = this._httpClient.get(tourUrl);
556
+ try {
557
+ return await request
558
+ .pipe(map((resultSet) => {
559
+ return JSON.parse(JSON.stringify(resultSet));
560
+ }))
561
+ .toPromise();
562
+ }
563
+ catch {
564
+ return undefined;
565
+ }
566
+ }
567
+ _getTour(key) {
568
+ return this._toursMap.get(key);
569
+ }
570
+ _configureRoutesForSteps(routedSteps) {
571
+ routedSteps.forEach((step) => {
572
+ if (step.routing) {
573
+ const route = step.routing.route;
574
+ // if there is a beforeShowPromise, then we save it and call it after the navigation
575
+ if (step.beforeShowPromise) {
576
+ const beforeShowPromise = step.beforeShowPromise;
577
+ step.beforeShowPromise = () => {
578
+ return this._router
579
+ .navigate([route], step.routing?.extras)
580
+ .then(() => {
581
+ return beforeShowPromise();
582
+ });
583
+ };
584
+ }
585
+ else {
586
+ step.beforeShowPromise = () => this._router.navigate([route]);
587
+ }
588
+ }
589
+ });
590
+ return routedSteps;
591
+ }
592
+ }
593
+ CovalentGuidedTourService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentGuidedTourService, deps: [{ token: i1.Router }, { token: i1.ActivatedRoute }, { token: i2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
594
+ CovalentGuidedTourService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentGuidedTourService });
595
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentGuidedTourService, decorators: [{
596
+ type: Injectable
597
+ }], ctorParameters: function () { return [{ type: i1.Router }, { type: i1.ActivatedRoute }, { type: i2.HttpClient }]; } });
598
+
599
+ class CovalentGuidedTourModule {
600
+ }
601
+ CovalentGuidedTourModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentGuidedTourModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
602
+ CovalentGuidedTourModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentGuidedTourModule, imports: [CommonModule] });
603
+ CovalentGuidedTourModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentGuidedTourModule, providers: [CovalentGuidedTourService], imports: [[CommonModule]] });
604
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentGuidedTourModule, decorators: [{
605
+ type: NgModule,
606
+ args: [{
607
+ imports: [CommonModule],
608
+ providers: [CovalentGuidedTourService],
609
+ declarations: [],
610
+ exports: [],
611
+ }]
612
+ }] });
613
+
614
+ /**
615
+ * Generated bundle index. Do not edit.
616
+ */
617
+
618
+ export { CovalentGuidedTour, CovalentGuidedTourModule, CovalentGuidedTourService, ITourEvent, TourEvents };
619
+ //# sourceMappingURL=covalent-guided-tour.mjs.map