@covalent/guided-tour 4.0.0 → 4.1.0-develop.10
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.
- package/README.md +32 -15
- package/_guided-tour-theme.scss +6 -6
- package/covalent-guided-tour.d.ts +2 -1
- package/esm2020/covalent-guided-tour.mjs +5 -0
- package/esm2020/lib/guided-tour.module.mjs +19 -0
- package/esm2020/lib/guided-tour.service.mjs +163 -0
- package/esm2020/lib/guided.tour.mjs +438 -0
- package/esm2020/public_api.mjs +4 -0
- package/fesm2015/{covalent-guided-tour.js → covalent-guided-tour.mjs} +180 -615
- package/fesm2015/covalent-guided-tour.mjs.map +1 -0
- package/fesm2020/covalent-guided-tour.mjs +619 -0
- package/fesm2020/covalent-guided-tour.mjs.map +1 -0
- package/lib/guided-tour.module.d.ts +7 -0
- package/{guided-tour.service.d.ts → lib/guided-tour.service.d.ts} +4 -1
- package/{guided.tour.d.ts → lib/guided.tour.d.ts} +3 -7
- package/package.json +26 -14
- package/public_api.d.ts +3 -0
- package/{_guided-tour.scss → styles/guided-tour.scss} +17 -2
- package/bundles/covalent-guided-tour.umd.js +0 -1369
- package/bundles/covalent-guided-tour.umd.js.map +0 -1
- package/bundles/covalent-guided-tour.umd.min.js +0 -16
- package/bundles/covalent-guided-tour.umd.min.js.map +0 -1
- package/covalent-guided-tour.metadata.json +0 -1
- package/esm2015/covalent-guided-tour.js +0 -10
- package/esm2015/guided-tour.module.js +0 -19
- package/esm2015/guided-tour.service.js +0 -312
- package/esm2015/guided.tour.js +0 -722
- package/esm2015/index.js +0 -7
- package/esm2015/public-api.js +0 -9
- package/fesm2015/covalent-guided-tour.js.map +0 -1
- package/guided-tour.module.d.ts +0 -2
- package/index.d.ts +0 -1
- package/public-api.d.ts +0 -3
|
@@ -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
|
|
5
|
-
import { NavigationStart
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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,76 @@ 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
|
-
|
|
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
|
-
|
|
302
|
-
|
|
122
|
+
let showProgress = () => {
|
|
123
|
+
//
|
|
124
|
+
};
|
|
303
125
|
if (((_a = step.attachToOptions) === null || _a === void 0 ? void 0 : _a.skipFromStepCount) === true) {
|
|
304
|
-
showProgress = (
|
|
305
|
-
* @return {?}
|
|
306
|
-
*/
|
|
307
|
-
function () {
|
|
126
|
+
showProgress = function () {
|
|
308
127
|
return;
|
|
309
|
-
}
|
|
128
|
+
};
|
|
310
129
|
}
|
|
311
130
|
else if (((_b = step.attachToOptions) === null || _b === void 0 ? void 0 : _b.skipFromStepCount) === undefined ||
|
|
312
131
|
((_c = step.attachToOptions) === null || _c === void 0 ? void 0 : _c.skipFromStepCount) === false) {
|
|
@@ -318,65 +137,43 @@ class CovalentGuidedTour extends TourButtonsActions {
|
|
|
318
137
|
show: showProgress,
|
|
319
138
|
},
|
|
320
139
|
});
|
|
321
|
-
})
|
|
322
|
-
/** @type {?} */
|
|
140
|
+
});
|
|
323
141
|
const finishButton = {
|
|
324
142
|
text: finishLabel,
|
|
325
143
|
action: this['finish'].bind(this),
|
|
326
144
|
classes: MAT_BUTTON,
|
|
327
145
|
};
|
|
328
|
-
/** @type {?} */
|
|
329
146
|
const voidButton = {
|
|
330
147
|
text: '',
|
|
331
|
-
/**
|
|
332
|
-
* @return {?}
|
|
333
|
-
*/
|
|
334
148
|
action() {
|
|
335
149
|
return;
|
|
336
150
|
},
|
|
337
151
|
classes: MAT_BUTTON_INVISIBLE,
|
|
338
152
|
};
|
|
339
153
|
// listen to the destroyed event to clean up all the streams
|
|
340
|
-
this._destroyedEvent$.pipe(first()).subscribe((
|
|
341
|
-
* @return {?}
|
|
342
|
-
*/
|
|
343
|
-
() => {
|
|
154
|
+
this._destroyedEvent$.pipe(first()).subscribe(() => {
|
|
344
155
|
backEvent$.complete();
|
|
345
156
|
forwardEvent$.complete();
|
|
346
157
|
destroyedEvent$.next();
|
|
347
158
|
destroyedEvent$.complete();
|
|
348
|
-
})
|
|
349
|
-
/** @type {?} */
|
|
159
|
+
});
|
|
350
160
|
const totalSteps = steps.length;
|
|
351
|
-
steps.forEach((
|
|
352
|
-
* @param {?} step
|
|
353
|
-
* @param {?} index
|
|
354
|
-
* @return {?}
|
|
355
|
-
*/
|
|
356
|
-
(step, index) => {
|
|
161
|
+
steps.forEach((step, index) => {
|
|
357
162
|
var _a;
|
|
358
163
|
// create buttons specific for the step
|
|
359
164
|
// this is done to create more control on events
|
|
360
|
-
/** @type {?} */
|
|
361
165
|
const nextButton = {
|
|
362
166
|
text: 'chevron_right',
|
|
363
|
-
action: (
|
|
364
|
-
* @return {?}
|
|
365
|
-
*/
|
|
366
|
-
() => {
|
|
167
|
+
action: () => {
|
|
367
168
|
// intercept the next action and trigger event
|
|
368
169
|
forwardEvent$.next();
|
|
369
170
|
this.shepherdTour.next();
|
|
370
|
-
}
|
|
171
|
+
},
|
|
371
172
|
classes: MAT_ICON_BUTTON,
|
|
372
173
|
};
|
|
373
|
-
/** @type {?} */
|
|
374
174
|
const backButton = {
|
|
375
175
|
text: 'chevron_left',
|
|
376
|
-
action: (
|
|
377
|
-
* @return {?}
|
|
378
|
-
*/
|
|
379
|
-
() => {
|
|
176
|
+
action: () => {
|
|
380
177
|
// intercept the back action and trigger event
|
|
381
178
|
backEvent$.next();
|
|
382
179
|
_backFlow = true;
|
|
@@ -387,12 +184,16 @@ class CovalentGuidedTour extends TourButtonsActions {
|
|
|
387
184
|
else {
|
|
388
185
|
this.shepherdTour.back();
|
|
389
186
|
}
|
|
390
|
-
}
|
|
391
|
-
classes: ((_a = step.advanceOnOptions) === null || _a === void 0 ? void 0 : _a.allowGoBack) === false
|
|
187
|
+
},
|
|
188
|
+
classes: ((_a = step.advanceOnOptions) === null || _a === void 0 ? void 0 : _a.allowGoBack) === false
|
|
189
|
+
? MAT_BUTTON_INVISIBLE
|
|
190
|
+
: MAT_ICON_BUTTON,
|
|
392
191
|
};
|
|
393
192
|
// check if highlight was provided for the step, else fallback into shepherds usage
|
|
394
193
|
step.highlightClass =
|
|
395
|
-
step.attachToOptions && step.attachToOptions.highlight
|
|
194
|
+
step.attachToOptions && step.attachToOptions.highlight
|
|
195
|
+
? 'shepherd-highlight'
|
|
196
|
+
: step.highlightClass;
|
|
396
197
|
// Adding buttons in the steps if no buttons are defined
|
|
397
198
|
if (!step.buttons || step.buttons.length === 0) {
|
|
398
199
|
if (index === 0) {
|
|
@@ -408,57 +209,38 @@ class CovalentGuidedTour extends TourButtonsActions {
|
|
|
408
209
|
}
|
|
409
210
|
}
|
|
410
211
|
// checks "advanceOn" to override listeners
|
|
411
|
-
/** @type {?} */
|
|
412
212
|
let advanceOn = step.advanceOn;
|
|
413
213
|
// remove the shepherd "advanceOn" infavor of ours if the event is part of our list
|
|
414
214
|
if ((typeof advanceOn === 'object' &&
|
|
415
215
|
!Array.isArray(advanceOn) &&
|
|
216
|
+
advanceOn.event &&
|
|
416
217
|
overriddenEvents.indexOf(advanceOn.event.split('.')[0]) > -1) ||
|
|
417
218
|
advanceOn instanceof Array) {
|
|
418
219
|
step.advanceOn = undefined;
|
|
419
220
|
step.buttons =
|
|
420
|
-
step.advanceOnOptions && step.advanceOnOptions.allowGoBack
|
|
221
|
+
step.advanceOnOptions && step.advanceOnOptions.allowGoBack
|
|
222
|
+
? [backButton, voidButton]
|
|
223
|
+
: [voidButton];
|
|
421
224
|
}
|
|
422
225
|
// adds a default beforeShowPromise function
|
|
423
|
-
step.beforeShowPromise = (
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
return new Promise((/**
|
|
428
|
-
* @param {?} resolve
|
|
429
|
-
* @return {?}
|
|
430
|
-
*/
|
|
431
|
-
(resolve) => {
|
|
432
|
-
/** @type {?} */
|
|
433
|
-
const additionalCapabilitiesSetup = (/**
|
|
434
|
-
* @return {?}
|
|
435
|
-
*/
|
|
436
|
-
() => {
|
|
226
|
+
step.beforeShowPromise = () => {
|
|
227
|
+
return new Promise((resolve) => {
|
|
228
|
+
var _a;
|
|
229
|
+
const additionalCapabilitiesSetup = () => {
|
|
437
230
|
if (advanceOn && !step.advanceOn) {
|
|
438
231
|
if (!Array.isArray(advanceOn)) {
|
|
439
232
|
advanceOn = [advanceOn];
|
|
440
233
|
}
|
|
441
|
-
/** @type {?} */
|
|
442
234
|
const advanceArr$ = [];
|
|
443
|
-
advanceOn.forEach((
|
|
444
|
-
* @param {?} _
|
|
445
|
-
* @param {?} i
|
|
446
|
-
* @return {?}
|
|
447
|
-
*/
|
|
448
|
-
(_, i) => {
|
|
449
|
-
/** @type {?} */
|
|
235
|
+
advanceOn.forEach((_, i) => {
|
|
450
236
|
const advanceEvent$ = new Subject();
|
|
451
237
|
advanceArr$.push(advanceEvent$);
|
|
452
238
|
// we start a timer of attempts to find an element in the dom
|
|
453
|
-
this._bindEvent(
|
|
454
|
-
})
|
|
455
|
-
/** @type {?} */
|
|
239
|
+
this._bindEvent(_, step.advanceOnOptions, advanceEvent$, destroyedEvent$);
|
|
240
|
+
});
|
|
456
241
|
const advanceSubs = forkJoin(...advanceArr$)
|
|
457
242
|
.pipe(takeUntil(merge(destroyedEvent$, backEvent$)))
|
|
458
|
-
.subscribe((
|
|
459
|
-
* @return {?}
|
|
460
|
-
*/
|
|
461
|
-
() => {
|
|
243
|
+
.subscribe(() => {
|
|
462
244
|
// check if we need to advance to a specific step, else advance to next step
|
|
463
245
|
if (step.advanceOnOptions && step.advanceOnOptions.jumpTo) {
|
|
464
246
|
this.shepherdTour.show(step.advanceOnOptions.jumpTo);
|
|
@@ -468,84 +250,69 @@ class CovalentGuidedTour extends TourButtonsActions {
|
|
|
468
250
|
}
|
|
469
251
|
forwardEvent$.next();
|
|
470
252
|
advanceSubs.unsubscribe();
|
|
471
|
-
})
|
|
253
|
+
});
|
|
472
254
|
}
|
|
473
255
|
// if abortOn was passed on the step, we bind the event and execute complete
|
|
474
256
|
if (step.abortOn) {
|
|
475
|
-
/** @type {?} */
|
|
476
257
|
const abortArr$ = [];
|
|
477
|
-
step.abortOn.forEach((
|
|
478
|
-
* @param {?} abortOn
|
|
479
|
-
* @return {?}
|
|
480
|
-
*/
|
|
481
|
-
(abortOn) => {
|
|
482
|
-
/** @type {?} */
|
|
258
|
+
step.abortOn.forEach((abortOn) => {
|
|
483
259
|
const abortEvent$ = new Subject();
|
|
484
260
|
abortArr$.push(abortEvent$);
|
|
485
261
|
this._bindEvent(abortOn, undefined, abortEvent$, destroyedEvent$);
|
|
486
|
-
})
|
|
487
|
-
/** @type {?} */
|
|
262
|
+
});
|
|
488
263
|
const abortSubs = merge(...abortArr$)
|
|
489
264
|
.pipe(takeUntil(merge(destroyedEvent$, backEvent$, forwardEvent$)))
|
|
490
|
-
.subscribe((
|
|
491
|
-
* @return {?}
|
|
492
|
-
*/
|
|
493
|
-
() => {
|
|
265
|
+
.subscribe(() => {
|
|
494
266
|
this.shepherdTour.complete();
|
|
495
267
|
abortSubs.unsubscribe();
|
|
496
|
-
})
|
|
268
|
+
});
|
|
497
269
|
}
|
|
498
|
-
}
|
|
499
|
-
/** @type {?} */
|
|
270
|
+
};
|
|
500
271
|
const _stopTimer$ = new Subject();
|
|
501
|
-
/** @type {?} */
|
|
502
272
|
const _retriesReached$ = new Subject();
|
|
503
|
-
/** @type {?} */
|
|
504
273
|
const _retryAttempts$ = new BehaviorSubject(-1);
|
|
505
|
-
/** @type {?} */
|
|
506
274
|
let id;
|
|
507
275
|
// checks if "attachTo" is a string or an object to get the id of an element
|
|
508
276
|
if (typeof step.attachTo === 'string') {
|
|
509
277
|
id = step.attachTo;
|
|
510
278
|
}
|
|
511
|
-
else if (typeof step.attachTo === 'object' &&
|
|
279
|
+
else if (typeof step.attachTo === 'object' &&
|
|
280
|
+
typeof step.attachTo.element === 'string') {
|
|
512
281
|
id = step.attachTo.element;
|
|
513
282
|
}
|
|
514
283
|
// if we have an id as a string in either case, we use it (we ignore it if its HTMLElement)
|
|
515
284
|
if (id) {
|
|
516
285
|
// if current step is the first step of the tour, we set the buttons to be only "next"
|
|
517
286
|
// 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() ===
|
|
519
|
-
this.shepherdTour.
|
|
520
|
-
|
|
287
|
+
if (this.shepherdTour.getCurrentStep() ===
|
|
288
|
+
this.shepherdTour.steps[0]) {
|
|
289
|
+
(_a = this.shepherdTour.getCurrentStep()) === null || _a === void 0 ? void 0 : _a.updateStepOptions({
|
|
290
|
+
buttons: originalSteps[index].advanceOn
|
|
291
|
+
? [voidButton]
|
|
292
|
+
: [nextButton],
|
|
521
293
|
});
|
|
522
294
|
}
|
|
523
295
|
// register to the attempts observable to notify deeveloper when number has been reached
|
|
524
296
|
_retryAttempts$
|
|
525
|
-
.pipe(skip(1), takeUntil(merge(_stopTimer$.asObservable(), destroyedEvent$)), skipWhile((
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
*/
|
|
529
|
-
(val) => {
|
|
530
|
-
if (step.attachToOptions && step.attachToOptions.retries !== undefined) {
|
|
297
|
+
.pipe(skip(1), takeUntil(merge(_stopTimer$.asObservable(), destroyedEvent$)), skipWhile((val) => {
|
|
298
|
+
if (step.attachToOptions &&
|
|
299
|
+
step.attachToOptions.retries !== undefined) {
|
|
531
300
|
return val < step.attachToOptions.retries;
|
|
532
301
|
}
|
|
533
302
|
return val < SHEPHERD_DEFAULT_FIND_ATTEMPTS;
|
|
534
|
-
}))
|
|
535
|
-
.subscribe((
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
*/
|
|
539
|
-
(attempts) => {
|
|
540
|
-
_retriesReached$.next();
|
|
303
|
+
}))
|
|
304
|
+
.subscribe((attempts) => {
|
|
305
|
+
var _a;
|
|
306
|
+
_retriesReached$.next(1);
|
|
541
307
|
_retriesReached$.complete();
|
|
542
308
|
// if attempts have been reached, we check "skipIfNotFound" to move on to the next step
|
|
543
|
-
if (step.attachToOptions &&
|
|
309
|
+
if (step.attachToOptions &&
|
|
310
|
+
step.attachToOptions.skipIfNotFound) {
|
|
544
311
|
// if we get to this step coming back from a step and it wasnt found
|
|
545
312
|
// then we either check if its the first step and try going forward
|
|
546
313
|
// or we keep going back until we find a step that actually exists
|
|
547
314
|
if (_backFlow) {
|
|
548
|
-
if (
|
|
315
|
+
if (this.shepherdTour.steps.indexOf(this.shepherdTour.getCurrentStep()) === 0) {
|
|
549
316
|
this.shepherdTour.next();
|
|
550
317
|
}
|
|
551
318
|
else {
|
|
@@ -555,11 +322,10 @@ class CovalentGuidedTour extends TourButtonsActions {
|
|
|
555
322
|
}
|
|
556
323
|
else {
|
|
557
324
|
// destroys current step if we need to skip it to remove it from the tour
|
|
558
|
-
/** @type {?} */
|
|
559
325
|
const currentStep = this.shepherdTour.getCurrentStep();
|
|
560
|
-
currentStep.destroy();
|
|
326
|
+
currentStep === null || currentStep === void 0 ? void 0 : currentStep.destroy();
|
|
561
327
|
this.shepherdTour.next();
|
|
562
|
-
this.shepherdTour.removeStep((
|
|
328
|
+
this.shepherdTour.removeStep((_a = currentStep === null || currentStep === void 0 ? void 0 : currentStep.id) !== null && _a !== void 0 ? _a : '');
|
|
563
329
|
}
|
|
564
330
|
}
|
|
565
331
|
else if (step.attachToOptions && step.attachToOptions.else) {
|
|
@@ -572,18 +338,16 @@ class CovalentGuidedTour extends TourButtonsActions {
|
|
|
572
338
|
// else we show the step regardless
|
|
573
339
|
resolve();
|
|
574
340
|
}
|
|
575
|
-
})
|
|
341
|
+
});
|
|
576
342
|
// we start a timer of attempts to find an element in the dom
|
|
577
|
-
timer((step.attachToOptions && step.attachToOptions.timeBeforeShow) ||
|
|
343
|
+
timer((step.attachToOptions && step.attachToOptions.timeBeforeShow) ||
|
|
344
|
+
SHEPHERD_DEFAULT_FIND_TIME_BEFORE_SHOW, (step.attachToOptions && step.attachToOptions.interval) ||
|
|
345
|
+
SHEPHERD_DEFAULT_FIND_INTERVAL)
|
|
578
346
|
.pipe(
|
|
579
347
|
// the timer will continue either until we find the element or the number of attempts has been reached
|
|
580
348
|
takeUntil(merge(_stopTimer$, _retriesReached$, destroyedEvent$)))
|
|
581
|
-
.subscribe((
|
|
582
|
-
|
|
583
|
-
*/
|
|
584
|
-
() => {
|
|
585
|
-
/** @type {?} */
|
|
586
|
-
const element = document.querySelector(id);
|
|
349
|
+
.subscribe(() => {
|
|
350
|
+
const element = document.querySelector(id !== null && id !== void 0 ? id : '');
|
|
587
351
|
// if the element has been found, we stop the timer and resolve the promise
|
|
588
352
|
if (element) {
|
|
589
353
|
_stopTimer$.next();
|
|
@@ -594,56 +358,39 @@ class CovalentGuidedTour extends TourButtonsActions {
|
|
|
594
358
|
else {
|
|
595
359
|
_retryAttempts$.next(_retryAttempts$.value + 1);
|
|
596
360
|
}
|
|
597
|
-
})
|
|
361
|
+
});
|
|
598
362
|
// stop find interval if user stops the tour
|
|
599
|
-
destroyedEvent$.subscribe((
|
|
600
|
-
* @return {?}
|
|
601
|
-
*/
|
|
602
|
-
() => {
|
|
363
|
+
destroyedEvent$.subscribe(() => {
|
|
603
364
|
_stopTimer$.next();
|
|
604
365
|
_stopTimer$.complete();
|
|
605
|
-
_retriesReached$.next();
|
|
366
|
+
_retriesReached$.next(1);
|
|
606
367
|
_retriesReached$.complete();
|
|
607
|
-
})
|
|
368
|
+
});
|
|
608
369
|
}
|
|
609
370
|
else {
|
|
610
371
|
// resolve observable until the timeBeforeShow has passsed or use default
|
|
611
|
-
timer((step.attachToOptions && step.attachToOptions.timeBeforeShow) ||
|
|
372
|
+
timer((step.attachToOptions && step.attachToOptions.timeBeforeShow) ||
|
|
373
|
+
SHEPHERD_DEFAULT_FIND_TIME_BEFORE_SHOW)
|
|
612
374
|
.pipe(takeUntil(merge(destroyedEvent$)))
|
|
613
|
-
.subscribe((
|
|
614
|
-
* @return {?}
|
|
615
|
-
*/
|
|
616
|
-
() => {
|
|
375
|
+
.subscribe(() => {
|
|
617
376
|
resolve();
|
|
618
|
-
})
|
|
377
|
+
});
|
|
619
378
|
}
|
|
620
|
-
})
|
|
621
|
-
}
|
|
622
|
-
})
|
|
379
|
+
});
|
|
380
|
+
};
|
|
381
|
+
});
|
|
623
382
|
return steps;
|
|
624
383
|
}
|
|
625
|
-
/**
|
|
626
|
-
* @private
|
|
627
|
-
* @param {?} eventOn
|
|
628
|
-
* @param {?} eventOnOptions
|
|
629
|
-
* @param {?} event$
|
|
630
|
-
* @param {?} destroyedEvent$
|
|
631
|
-
* @return {?}
|
|
632
|
-
*/
|
|
633
384
|
_bindEvent(eventOn, eventOnOptions, event$, destroyedEvent$) {
|
|
634
|
-
|
|
635
|
-
const selector = eventOn.selector;
|
|
636
|
-
/** @type {?} */
|
|
385
|
+
var _a;
|
|
386
|
+
const selector = (_a = eventOn.selector) !== null && _a !== void 0 ? _a : '';
|
|
637
387
|
const event = eventOn.event;
|
|
638
388
|
// we start a timer of attempts to find an element in the dom
|
|
639
|
-
|
|
640
|
-
|
|
389
|
+
const timerSubs = timer((eventOnOptions && eventOnOptions.timeBeforeShow) ||
|
|
390
|
+
SHEPHERD_DEFAULT_FIND_TIME_BEFORE_SHOW, (eventOnOptions && eventOnOptions.interval) ||
|
|
391
|
+
SHEPHERD_DEFAULT_FIND_INTERVAL)
|
|
641
392
|
.pipe(takeUntil(destroyedEvent$))
|
|
642
|
-
.subscribe((
|
|
643
|
-
* @return {?}
|
|
644
|
-
*/
|
|
645
|
-
() => {
|
|
646
|
-
/** @type {?} */
|
|
393
|
+
.subscribe(() => {
|
|
647
394
|
const element = document.querySelector(selector);
|
|
648
395
|
// if the element has been found, we stop the timer and resolve the promise
|
|
649
396
|
if (element) {
|
|
@@ -655,18 +402,12 @@ class CovalentGuidedTour extends TourButtonsActions {
|
|
|
655
402
|
}
|
|
656
403
|
else if (event === ITourEvent.click ||
|
|
657
404
|
event === ITourEvent.pointerover ||
|
|
658
|
-
event.indexOf(ITourEvent.keyup) > -1) {
|
|
405
|
+
(event && event.indexOf(ITourEvent.keyup) > -1)) {
|
|
659
406
|
// we use normal listeners for mouseevents
|
|
660
|
-
|
|
661
|
-
const
|
|
662
|
-
/** @type {?} */
|
|
663
|
-
const subEvent = event.split('.')[1];
|
|
407
|
+
const mainEvent = event === null || event === void 0 ? void 0 : event.split('.')[0];
|
|
408
|
+
const subEvent = event === null || event === void 0 ? void 0 : event.split('.')[1];
|
|
664
409
|
fromEvent(element, mainEvent)
|
|
665
|
-
.pipe(takeUntil(merge(event$.asObservable(), destroyedEvent$)), filter((
|
|
666
|
-
* @param {?} $event
|
|
667
|
-
* @return {?}
|
|
668
|
-
*/
|
|
669
|
-
($event) => {
|
|
410
|
+
.pipe(takeUntil(merge(event$.asObservable(), destroyedEvent$)), filter(($event) => {
|
|
670
411
|
// only trigger if the event is a keyboard event and part of out list
|
|
671
412
|
if ($event instanceof KeyboardEvent) {
|
|
672
413
|
if (keyEvents.get($event.keyCode) === subEvent) {
|
|
@@ -677,105 +418,51 @@ class CovalentGuidedTour extends TourButtonsActions {
|
|
|
677
418
|
else {
|
|
678
419
|
return true;
|
|
679
420
|
}
|
|
680
|
-
}))
|
|
681
|
-
.subscribe((
|
|
682
|
-
* @return {?}
|
|
683
|
-
*/
|
|
684
|
-
() => {
|
|
421
|
+
}))
|
|
422
|
+
.subscribe(() => {
|
|
685
423
|
event$.next();
|
|
686
424
|
event$.complete();
|
|
687
|
-
})
|
|
425
|
+
});
|
|
688
426
|
}
|
|
689
427
|
else if (event === ITourEvent.removed) {
|
|
690
428
|
// and we will use MutationObserver for DOM events
|
|
691
|
-
|
|
692
|
-
const observer = new MutationObserver((/**
|
|
693
|
-
* @return {?}
|
|
694
|
-
*/
|
|
695
|
-
() => {
|
|
429
|
+
const observer = new MutationObserver(() => {
|
|
696
430
|
if (!document.body.contains(element)) {
|
|
697
431
|
event$.next();
|
|
698
432
|
event$.complete();
|
|
699
433
|
observer.disconnect();
|
|
700
434
|
}
|
|
701
|
-
})
|
|
435
|
+
});
|
|
702
436
|
// stop listenining if tour is closed
|
|
703
|
-
destroyedEvent$.subscribe((
|
|
704
|
-
* @return {?}
|
|
705
|
-
*/
|
|
706
|
-
() => {
|
|
437
|
+
destroyedEvent$.subscribe(() => {
|
|
707
438
|
observer.disconnect();
|
|
708
|
-
})
|
|
439
|
+
});
|
|
709
440
|
// observe for any DOM interaction in the element
|
|
710
|
-
observer.observe(element, {
|
|
441
|
+
observer.observe(element, {
|
|
442
|
+
childList: true,
|
|
443
|
+
subtree: true,
|
|
444
|
+
attributes: true,
|
|
445
|
+
});
|
|
711
446
|
}
|
|
712
447
|
}
|
|
713
|
-
})
|
|
448
|
+
});
|
|
714
449
|
}
|
|
715
450
|
}
|
|
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
451
|
|
|
728
452
|
/**
|
|
729
|
-
*
|
|
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
|
|
453
|
+
* Router enabled Shepherd tour
|
|
763
454
|
*/
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
455
|
+
var TourEvents;
|
|
456
|
+
(function (TourEvents) {
|
|
457
|
+
TourEvents["complete"] = "complete";
|
|
458
|
+
TourEvents["cancel"] = "cancel";
|
|
459
|
+
TourEvents["hide"] = "hide";
|
|
460
|
+
TourEvents["show"] = "show";
|
|
461
|
+
TourEvents["start"] = "start";
|
|
462
|
+
TourEvents["active"] = "active";
|
|
463
|
+
TourEvents["inactive"] = "inactive";
|
|
464
|
+
})(TourEvents || (TourEvents = {}));
|
|
773
465
|
class CovalentGuidedTourService extends CovalentGuidedTour {
|
|
774
|
-
/**
|
|
775
|
-
* @param {?} _router
|
|
776
|
-
* @param {?} _route
|
|
777
|
-
* @param {?} _httpClient
|
|
778
|
-
*/
|
|
779
466
|
constructor(_router, _route, _httpClient) {
|
|
780
467
|
super();
|
|
781
468
|
this._router = _router;
|
|
@@ -784,64 +471,35 @@ class CovalentGuidedTourService extends CovalentGuidedTour {
|
|
|
784
471
|
this._toursMap = new Map();
|
|
785
472
|
this._tourStepURLs = new Map();
|
|
786
473
|
_router.events
|
|
787
|
-
.pipe(filter((
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
(event) => event instanceof NavigationStart && event.navigationTrigger === 'popstate')))
|
|
792
|
-
.subscribe((/**
|
|
793
|
-
* @param {?} event
|
|
794
|
-
* @return {?}
|
|
795
|
-
*/
|
|
796
|
-
(event) => {
|
|
797
|
-
if (this.shepherdTour.isActive) {
|
|
474
|
+
.pipe(filter((event) => event instanceof NavigationStart &&
|
|
475
|
+
event.navigationTrigger === 'popstate'))
|
|
476
|
+
.subscribe(() => {
|
|
477
|
+
if (this.shepherdTour.isActive()) {
|
|
798
478
|
this.shepherdTour.cancel();
|
|
799
479
|
}
|
|
800
|
-
})
|
|
480
|
+
});
|
|
801
481
|
}
|
|
802
|
-
/**
|
|
803
|
-
* @param {?} str
|
|
804
|
-
* @return {?}
|
|
805
|
-
*/
|
|
806
482
|
tourEvent$(str) {
|
|
807
483
|
return fromEvent(this.shepherdTour, str);
|
|
808
484
|
}
|
|
809
|
-
/**
|
|
810
|
-
* @param {?} tourName
|
|
811
|
-
* @param {?} tour
|
|
812
|
-
* @return {?}
|
|
813
|
-
*/
|
|
814
485
|
registerTour(tourName, tour) {
|
|
815
486
|
return __awaiter(this, void 0, void 0, function* () {
|
|
816
|
-
/** @type {?} */
|
|
817
487
|
const guidedTour = typeof tour === 'string' ? yield this._loadTour(tour) : tour;
|
|
818
488
|
this._toursMap.set(tourName, guidedTour);
|
|
819
489
|
});
|
|
820
490
|
}
|
|
821
|
-
/**
|
|
822
|
-
* @param {?} tourName
|
|
823
|
-
* @return {?}
|
|
824
|
-
*/
|
|
825
491
|
startTour(tourName) {
|
|
826
|
-
/** @type {?} */
|
|
827
492
|
const guidedTour = this._getTour(tourName);
|
|
828
493
|
this.finish();
|
|
829
494
|
if (guidedTour && guidedTour.steps && guidedTour.steps.length) {
|
|
830
495
|
// remove steps from tour since we need to preprocess them first
|
|
831
496
|
this.newTour(Object.assign({}, guidedTour, { steps: undefined }));
|
|
832
|
-
/** @type {?} */
|
|
833
497
|
const tourInstance = this.shepherdTour.addSteps(this._configureRoutesForSteps(this._prepareTour(guidedTour.steps, guidedTour.finishButtonText)));
|
|
834
498
|
// 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 {?} */
|
|
499
|
+
this.tourEvent$(TourEvents.show).subscribe((tourEvent) => {
|
|
841
500
|
const currentURL = this._router.url.split(/[?#]/)[0];
|
|
842
501
|
const { step: { id, options }, } = tourEvent;
|
|
843
502
|
if (this._tourStepURLs.has(id)) {
|
|
844
|
-
/** @type {?} */
|
|
845
503
|
const stepRoute = this._tourStepURLs.get(id);
|
|
846
504
|
if (stepRoute !== currentURL) {
|
|
847
505
|
this._router.navigate([stepRoute]);
|
|
@@ -855,86 +513,61 @@ class CovalentGuidedTourService extends CovalentGuidedTour {
|
|
|
855
513
|
this._tourStepURLs.set(id, currentURL);
|
|
856
514
|
}
|
|
857
515
|
}
|
|
858
|
-
})
|
|
516
|
+
});
|
|
859
517
|
this.start();
|
|
860
518
|
return tourInstance;
|
|
861
519
|
}
|
|
862
520
|
else {
|
|
863
521
|
// tslint:disable-next-line:no-console
|
|
864
522
|
console.warn(`Tour ${tourName} does not exist. Please try another tour.`);
|
|
523
|
+
return undefined;
|
|
865
524
|
}
|
|
866
525
|
}
|
|
867
526
|
// Finds the right registered tour by using queryParams
|
|
868
527
|
// finishes any other tour and starts the new one.
|
|
869
|
-
/**
|
|
870
|
-
* @param {?=} queryParam
|
|
871
|
-
* @return {?}
|
|
872
|
-
*/
|
|
873
528
|
initializeOnQueryParams(queryParam = 'tour') {
|
|
874
|
-
return this._route.queryParamMap.pipe(debounceTime(100), tap((
|
|
875
|
-
* @param {?} params
|
|
876
|
-
* @return {?}
|
|
877
|
-
*/
|
|
878
|
-
(params) => {
|
|
879
|
-
/** @type {?} */
|
|
529
|
+
return this._route.queryParamMap.pipe(debounceTime(100), tap((params) => {
|
|
880
530
|
const tourParam = params.get(queryParam);
|
|
881
531
|
if (tourParam) {
|
|
882
532
|
this.startTour(tourParam);
|
|
883
533
|
// get current search parameters
|
|
884
|
-
/** @type {?} */
|
|
885
534
|
const searchParams = new URLSearchParams(window.location.search);
|
|
886
535
|
// delete tour queryParam
|
|
887
536
|
searchParams.delete(queryParam);
|
|
888
537
|
// build new URL string without it
|
|
889
|
-
|
|
890
|
-
|
|
538
|
+
let url = window.location.protocol +
|
|
539
|
+
'//' +
|
|
540
|
+
window.location.host +
|
|
541
|
+
window.location.pathname;
|
|
891
542
|
if (searchParams.toString()) {
|
|
892
543
|
url += '?' + searchParams.toString();
|
|
893
544
|
}
|
|
894
545
|
// replace state in history without triggering a navigation
|
|
895
546
|
window.history.replaceState({ path: url }, '', url);
|
|
896
547
|
}
|
|
897
|
-
}))
|
|
548
|
+
}));
|
|
898
549
|
}
|
|
899
|
-
/**
|
|
900
|
-
* @param {?} stepId
|
|
901
|
-
* @param {?} isDisabled
|
|
902
|
-
* @return {?}
|
|
903
|
-
*/
|
|
904
550
|
setNextBtnDisability(stepId, isDisabled) {
|
|
551
|
+
var _a, _b;
|
|
905
552
|
if (this.shepherdTour.getById(stepId)) {
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
stepOptions.buttons.forEach((
|
|
909
|
-
* @param {?} button
|
|
910
|
-
* @return {?}
|
|
911
|
-
*/
|
|
912
|
-
(button) => {
|
|
553
|
+
const stepOptions = this.shepherdTour.getById(stepId)
|
|
554
|
+
.options;
|
|
555
|
+
(_a = stepOptions.buttons) === null || _a === void 0 ? void 0 : _a.forEach((button) => {
|
|
913
556
|
if (button.text === 'chevron_right') {
|
|
914
557
|
button.disabled = isDisabled;
|
|
915
558
|
}
|
|
916
|
-
})
|
|
917
|
-
this.shepherdTour.getById(stepId).updateStepOptions(stepOptions);
|
|
559
|
+
});
|
|
560
|
+
(_b = this.shepherdTour.getById(stepId)) === null || _b === void 0 ? void 0 : _b.updateStepOptions(stepOptions);
|
|
918
561
|
}
|
|
919
562
|
}
|
|
920
|
-
/**
|
|
921
|
-
* @private
|
|
922
|
-
* @param {?} tourUrl
|
|
923
|
-
* @return {?}
|
|
924
|
-
*/
|
|
925
563
|
_loadTour(tourUrl) {
|
|
926
564
|
return __awaiter(this, void 0, void 0, function* () {
|
|
927
|
-
/** @type {?} */
|
|
928
565
|
const request = this._httpClient.get(tourUrl);
|
|
929
566
|
try {
|
|
930
567
|
return yield request
|
|
931
|
-
.pipe(map((
|
|
932
|
-
* @param {?} resultSet
|
|
933
|
-
* @return {?}
|
|
934
|
-
*/
|
|
935
|
-
(resultSet) => {
|
|
568
|
+
.pipe(map((resultSet) => {
|
|
936
569
|
return JSON.parse(JSON.stringify(resultSet));
|
|
937
|
-
}))
|
|
570
|
+
}))
|
|
938
571
|
.toPromise();
|
|
939
572
|
}
|
|
940
573
|
catch (_a) {
|
|
@@ -942,125 +575,57 @@ class CovalentGuidedTourService extends CovalentGuidedTour {
|
|
|
942
575
|
}
|
|
943
576
|
});
|
|
944
577
|
}
|
|
945
|
-
/**
|
|
946
|
-
* @private
|
|
947
|
-
* @param {?} key
|
|
948
|
-
* @return {?}
|
|
949
|
-
*/
|
|
950
578
|
_getTour(key) {
|
|
951
579
|
return this._toursMap.get(key);
|
|
952
580
|
}
|
|
953
|
-
/**
|
|
954
|
-
* @private
|
|
955
|
-
* @param {?} routedSteps
|
|
956
|
-
* @return {?}
|
|
957
|
-
*/
|
|
958
581
|
_configureRoutesForSteps(routedSteps) {
|
|
959
|
-
routedSteps.forEach((
|
|
960
|
-
* @param {?} step
|
|
961
|
-
* @return {?}
|
|
962
|
-
*/
|
|
963
|
-
(step) => {
|
|
582
|
+
routedSteps.forEach((step) => {
|
|
964
583
|
if (step.routing) {
|
|
965
|
-
/** @type {?} */
|
|
966
584
|
const route = step.routing.route;
|
|
967
585
|
// if there is a beforeShowPromise, then we save it and call it after the navigation
|
|
968
586
|
if (step.beforeShowPromise) {
|
|
969
|
-
/** @type {?} */
|
|
970
587
|
const beforeShowPromise = step.beforeShowPromise;
|
|
971
|
-
step.beforeShowPromise = (
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
* @return {?}
|
|
977
|
-
*/
|
|
978
|
-
() => {
|
|
588
|
+
step.beforeShowPromise = () => {
|
|
589
|
+
var _a;
|
|
590
|
+
return this._router
|
|
591
|
+
.navigate([route], (_a = step.routing) === null || _a === void 0 ? void 0 : _a.extras)
|
|
592
|
+
.then(() => {
|
|
979
593
|
return beforeShowPromise();
|
|
980
|
-
})
|
|
981
|
-
}
|
|
594
|
+
});
|
|
595
|
+
};
|
|
982
596
|
}
|
|
983
597
|
else {
|
|
984
|
-
step.beforeShowPromise = (
|
|
985
|
-
* @return {?}
|
|
986
|
-
*/
|
|
987
|
-
() => this._router.navigate([route]));
|
|
598
|
+
step.beforeShowPromise = () => this._router.navigate([route]);
|
|
988
599
|
}
|
|
989
600
|
}
|
|
990
|
-
})
|
|
601
|
+
});
|
|
991
602
|
return routedSteps;
|
|
992
603
|
}
|
|
993
604
|
}
|
|
994
|
-
CovalentGuidedTourService
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
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
|
-
}
|
|
605
|
+
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 });
|
|
606
|
+
CovalentGuidedTourService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentGuidedTourService });
|
|
607
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentGuidedTourService, decorators: [{
|
|
608
|
+
type: Injectable
|
|
609
|
+
}], ctorParameters: function () { return [{ type: i1.Router }, { type: i1.ActivatedRoute }, { type: i2.HttpClient }]; } });
|
|
1030
610
|
|
|
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
611
|
class CovalentGuidedTourModule {
|
|
1037
612
|
}
|
|
1038
|
-
CovalentGuidedTourModule
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
]
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
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
|
-
*/
|
|
613
|
+
CovalentGuidedTourModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentGuidedTourModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
614
|
+
CovalentGuidedTourModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentGuidedTourModule, imports: [CommonModule] });
|
|
615
|
+
CovalentGuidedTourModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentGuidedTourModule, providers: [CovalentGuidedTourService], imports: [[CommonModule]] });
|
|
616
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentGuidedTourModule, decorators: [{
|
|
617
|
+
type: NgModule,
|
|
618
|
+
args: [{
|
|
619
|
+
imports: [CommonModule],
|
|
620
|
+
providers: [CovalentGuidedTourService],
|
|
621
|
+
declarations: [],
|
|
622
|
+
exports: [],
|
|
623
|
+
}]
|
|
624
|
+
}] });
|
|
1058
625
|
|
|
1059
626
|
/**
|
|
1060
|
-
*
|
|
1061
|
-
* Generated from: covalent-guided-tour.ts
|
|
1062
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
627
|
+
* Generated bundle index. Do not edit.
|
|
1063
628
|
*/
|
|
1064
629
|
|
|
1065
630
|
export { CovalentGuidedTour, CovalentGuidedTourModule, CovalentGuidedTourService, ITourEvent, TourEvents };
|
|
1066
|
-
//# sourceMappingURL=covalent-guided-tour.
|
|
631
|
+
//# sourceMappingURL=covalent-guided-tour.mjs.map
|