surveysparrow-ionic-plugin 2.0.2-beta.1 → 2.0.2-beta.2
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/dist/angular-ui/esm2022/spotchecks/SpotCheckComponent.mjs +81 -100
- package/dist/angular-ui/esm2022/spotchecks/SpotCheckEventListener.mjs +26 -0
- package/dist/angular-ui/esm2022/spotchecks/SpotcheckStateService.mjs +1 -3
- package/dist/angular-ui/esm2022/spotchecks/api.mjs +3 -3
- package/dist/angular-ui/esm2022/spotchecks/helpers.mjs +14 -18
- package/dist/angular-ui/esm2022/spotchecks/index.mjs +2 -1
- package/dist/angular-ui/esm2022/spotchecks/types.mjs +1 -1
- package/dist/angular-ui/fesm2022/angular-ui.mjs +120 -122
- package/dist/angular-ui/fesm2022/angular-ui.mjs.map +1 -1
- package/dist/angular-ui/spotchecks/SpotCheckComponent.d.ts +10 -5
- package/dist/angular-ui/spotchecks/SpotCheckEventListener.d.ts +16 -0
- package/dist/angular-ui/spotchecks/helpers.d.ts +1 -2
- package/dist/angular-ui/spotchecks/index.d.ts +1 -0
- package/dist/angular-ui/spotchecks/types.d.ts +0 -2
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.d.ts +10 -5
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js +75 -95
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js.map +1 -1
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.d.ts +16 -0
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.js +28 -0
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.js.map +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.js +0 -2
- package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.js.map +1 -1
- package/dist/esm/angular-ui/lib/spotchecks/api.js +3 -4
- package/dist/esm/angular-ui/lib/spotchecks/api.js.map +1 -1
- package/dist/esm/angular-ui/lib/spotchecks/helpers.d.ts +1 -2
- package/dist/esm/angular-ui/lib/spotchecks/helpers.js +15 -18
- package/dist/esm/angular-ui/lib/spotchecks/helpers.js.map +1 -1
- package/dist/esm/angular-ui/lib/spotchecks/index.d.ts +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/index.js +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/index.js.map +1 -1
- package/dist/esm/angular-ui/lib/spotchecks/types.d.ts +0 -2
- package/dist/esm/angular-ui/lib/spotchecks/types.js.map +1 -1
- package/dist/plugin.cjs.js +116 -116
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +116 -116
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
- package/src/angular-ui/lib/spotchecks/SpotCheckComponent.ts +76 -98
- package/src/angular-ui/lib/spotchecks/SpotCheckEventListener.ts +50 -0
- package/src/angular-ui/lib/spotchecks/SpotcheckStateService.ts +0 -2
- package/src/angular-ui/lib/spotchecks/api.ts +4 -4
- package/src/angular-ui/lib/spotchecks/helpers.ts +14 -23
- package/src/angular-ui/lib/spotchecks/index.ts +3 -0
- package/src/angular-ui/lib/spotchecks/types.ts +0 -2
|
@@ -5,7 +5,7 @@ import { CommonModule } from '@angular/common';
|
|
|
5
5
|
import { v4 } from 'uuid';
|
|
6
6
|
import { Device } from '@capacitor/device';
|
|
7
7
|
import axios from 'axios';
|
|
8
|
-
import { BehaviorSubject } from 'rxjs';
|
|
8
|
+
import { BehaviorSubject, Subject } from 'rxjs';
|
|
9
9
|
import * as i1 from '@angular/platform-browser';
|
|
10
10
|
|
|
11
11
|
class SpotcheckStateService {
|
|
@@ -34,8 +34,6 @@ class SpotcheckStateService {
|
|
|
34
34
|
traceId: '',
|
|
35
35
|
isClassicLoading: true,
|
|
36
36
|
isChatLoading: true,
|
|
37
|
-
isClassicLoadEventReceived: false,
|
|
38
|
-
isChatLoadEventReceived: false,
|
|
39
37
|
classicUrl: '',
|
|
40
38
|
chatUrl: '',
|
|
41
39
|
classicWebViewRef: null,
|
|
@@ -72,8 +70,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
|
|
|
72
70
|
}]
|
|
73
71
|
}] });
|
|
74
72
|
|
|
73
|
+
class SpotCheckEventListenerService {
|
|
74
|
+
eventSubject = new Subject();
|
|
75
|
+
event$ = this.eventSubject.asObservable();
|
|
76
|
+
emit(type, data) {
|
|
77
|
+
this.eventSubject.next({ type, data });
|
|
78
|
+
}
|
|
79
|
+
addListener(eventType, callback) {
|
|
80
|
+
return this.event$.subscribe((event) => {
|
|
81
|
+
if (event.type === eventType) {
|
|
82
|
+
callback(event.data);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
let globalInstance;
|
|
88
|
+
const getSpotCheckEventListener = () => {
|
|
89
|
+
if (!globalInstance) {
|
|
90
|
+
globalInstance = new SpotCheckEventListenerService();
|
|
91
|
+
}
|
|
92
|
+
return globalInstance;
|
|
93
|
+
};
|
|
94
|
+
const addSpotCheckListener = (eventType, callback) => {
|
|
95
|
+
return getSpotCheckEventListener().addListener(eventType, callback);
|
|
96
|
+
};
|
|
97
|
+
|
|
75
98
|
let globalSpotcheckStateService;
|
|
76
|
-
let globalOS = null;
|
|
77
99
|
const getSpotcheckStateService = () => {
|
|
78
100
|
if (!globalSpotcheckStateService) {
|
|
79
101
|
globalSpotcheckStateService = new SpotcheckStateService();
|
|
@@ -93,8 +115,7 @@ const ischatSurvey = (type) => {
|
|
|
93
115
|
};
|
|
94
116
|
const getOS = async () => {
|
|
95
117
|
const info = await Device.getInfo();
|
|
96
|
-
|
|
97
|
-
return globalOS;
|
|
118
|
+
return info.operatingSystem;
|
|
98
119
|
};
|
|
99
120
|
const setAppearance = async (responseJson, screen, domainName, traceId, variables) => {
|
|
100
121
|
try {
|
|
@@ -150,11 +171,11 @@ const setAppearance = async (responseJson, screen, domainName, traceId, variable
|
|
|
150
171
|
spotcheckStateService.setState(updatedState);
|
|
151
172
|
try {
|
|
152
173
|
const response = await axios.get(fullSpotcheckURL);
|
|
153
|
-
const themeInfo = response.data
|
|
174
|
+
const themeInfo = response.data.config.generatedCSS;
|
|
154
175
|
const theme_payload = { type: 'THEME_UPDATE_SPOTCHECK', themeInfo };
|
|
155
176
|
state = spotcheckStateService.getState();
|
|
156
177
|
let webViewRef = chat ? state.chatWebViewRef : state.classicWebViewRef;
|
|
157
|
-
let isLoading = chat ? state.isChatLoading
|
|
178
|
+
let isLoading = chat ? state.isChatLoading : state.isClassicLoading;
|
|
158
179
|
const resetStateData = {
|
|
159
180
|
type: 'RESET_STATE',
|
|
160
181
|
state: {
|
|
@@ -197,8 +218,8 @@ const setAppearance = async (responseJson, screen, domainName, traceId, variable
|
|
|
197
218
|
else {
|
|
198
219
|
// todo: recheck this
|
|
199
220
|
const unsubscribe = spotcheckStateService.state$.subscribe((currentState) => {
|
|
200
|
-
const { isChatLoading, isClassicLoading, chatWebViewRef, classicWebViewRef,
|
|
201
|
-
if ((!isChatLoading && chat
|
|
221
|
+
const { isChatLoading, isClassicLoading, chatWebViewRef, classicWebViewRef, } = currentState;
|
|
222
|
+
if ((!isChatLoading && chat) || (!isClassicLoading && !chat)) {
|
|
202
223
|
unsubscribe.unsubscribe();
|
|
203
224
|
const activeWebViewRef = chat
|
|
204
225
|
? chatWebViewRef
|
|
@@ -221,8 +242,8 @@ const setAppearance = async (responseJson, screen, domainName, traceId, variable
|
|
|
221
242
|
? currentState.chatWebViewRef
|
|
222
243
|
: currentState.classicWebViewRef;
|
|
223
244
|
const updatedIsLoading = chat
|
|
224
|
-
? currentState.isChatLoading
|
|
225
|
-
: currentState.isClassicLoading
|
|
245
|
+
? currentState.isChatLoading
|
|
246
|
+
: currentState.isClassicLoading;
|
|
226
247
|
if (updatedWebViewRef) {
|
|
227
248
|
if (!updatedIsLoading) {
|
|
228
249
|
unsubscribeWebView.unsubscribe();
|
|
@@ -268,7 +289,10 @@ const closeSpotCheck = async () => {
|
|
|
268
289
|
},
|
|
269
290
|
body: JSON.stringify(payload),
|
|
270
291
|
});
|
|
271
|
-
if (response.status
|
|
292
|
+
if (response.status == 200) {
|
|
293
|
+
getSpotCheckEventListener().emit('surveyDismissed');
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
272
296
|
console.log(`Error: ${response.status}`);
|
|
273
297
|
}
|
|
274
298
|
}
|
|
@@ -324,15 +348,11 @@ const getSpotcheckComponentCssStyles = (state) => {
|
|
|
324
348
|
height: '100%',
|
|
325
349
|
};
|
|
326
350
|
}
|
|
327
|
-
let marginBottom = globalOS !== 'ios' ? 18 : 0;
|
|
328
351
|
if (state.isVisible && state.isMounted) {
|
|
329
352
|
let height = Math.min(state.currentQuestionHeight, (state.maxHeight * window.innerHeight));
|
|
330
353
|
if (state.spotChecksMode === 'miniCard') {
|
|
331
354
|
if (state.avatarEnabled) {
|
|
332
355
|
height = height - 56;
|
|
333
|
-
if (state.spotcheckPosition === 'bottom') {
|
|
334
|
-
marginBottom += 56;
|
|
335
|
-
}
|
|
336
356
|
}
|
|
337
357
|
if (state.isCloseButtonEnabled) {
|
|
338
358
|
height = height - 40;
|
|
@@ -384,7 +404,7 @@ const getSpotcheckComponentCssStyles = (state) => {
|
|
|
384
404
|
top: '0',
|
|
385
405
|
left: '0',
|
|
386
406
|
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
|
387
|
-
zIndex: '
|
|
407
|
+
zIndex: '99999999',
|
|
388
408
|
display: 'none',
|
|
389
409
|
flexDirection: 'column',
|
|
390
410
|
...wrapperStyles
|
|
@@ -393,25 +413,27 @@ const getSpotcheckComponentCssStyles = (state) => {
|
|
|
393
413
|
display: 'none',
|
|
394
414
|
flexDirection: 'column',
|
|
395
415
|
paddingTop: extraPaddingForMiniCardCloseButtonIfTopPosition + 'px',
|
|
396
|
-
marginBottom: marginBottom + 'px',
|
|
397
416
|
...styles,
|
|
398
417
|
}
|
|
399
418
|
};
|
|
400
419
|
};
|
|
401
420
|
const closeSpotCheckAndHandleSurveyEnd = async () => {
|
|
402
|
-
await closeSpotCheck();
|
|
403
421
|
handleSurveyEnd();
|
|
404
422
|
};
|
|
405
423
|
|
|
406
424
|
class WebViewComponent {
|
|
407
425
|
sanitizer;
|
|
426
|
+
ngZone;
|
|
427
|
+
cdr;
|
|
408
428
|
url = '';
|
|
409
429
|
webviewType = 'classic';
|
|
410
430
|
isMiniCard = false;
|
|
411
431
|
safeUrl = null;
|
|
412
432
|
iframe;
|
|
413
|
-
constructor(sanitizer) {
|
|
433
|
+
constructor(sanitizer, ngZone, cdr) {
|
|
414
434
|
this.sanitizer = sanitizer;
|
|
435
|
+
this.ngZone = ngZone;
|
|
436
|
+
this.cdr = cdr;
|
|
415
437
|
}
|
|
416
438
|
ngOnInit() {
|
|
417
439
|
if (this.url) {
|
|
@@ -438,99 +460,59 @@ class WebViewComponent {
|
|
|
438
460
|
setupIframeLoadListener() {
|
|
439
461
|
const iframe = this.iframe.nativeElement;
|
|
440
462
|
iframe.addEventListener('load', () => {
|
|
441
|
-
this.
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
stateService.setState({ isChatLoading: false });
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
injectNativeBridgeAdapters(iframe) {
|
|
452
|
-
if (iframe && iframe.contentWindow) {
|
|
453
|
-
try {
|
|
454
|
-
const iframeWindow = iframe.contentWindow;
|
|
455
|
-
if (!iframeWindow.SsAndroidSdk) {
|
|
456
|
-
iframeWindow.SsAndroidSdk = {
|
|
457
|
-
shareData: function () { },
|
|
458
|
-
sendPartialSubmissionData: function () { }
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
if (!iframeWindow.Android) {
|
|
462
|
-
iframeWindow.Android = {
|
|
463
|
-
onMessageReceive: function () { }
|
|
464
|
-
};
|
|
463
|
+
this.ngZone.run(() => {
|
|
464
|
+
const stateService = getSpotcheckStateService();
|
|
465
|
+
if (this.webviewType === 'classic') {
|
|
466
|
+
stateService.setState({ isClassicLoading: false });
|
|
465
467
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
messageHandlers: {
|
|
469
|
-
surveyResponse: {
|
|
470
|
-
postMessage: function () { }
|
|
471
|
-
},
|
|
472
|
-
spotCheckData: {
|
|
473
|
-
postMessage: function () { }
|
|
474
|
-
},
|
|
475
|
-
flutterSpotCheckData: {
|
|
476
|
-
postMessage: function () { }
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
if (!iframeWindow.flutterSpotCheckData) {
|
|
482
|
-
iframeWindow.flutterSpotCheckData = {
|
|
483
|
-
postMessage: function () { }
|
|
484
|
-
};
|
|
468
|
+
else {
|
|
469
|
+
stateService.setState({ isChatLoading: false });
|
|
485
470
|
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
}
|
|
471
|
+
});
|
|
472
|
+
});
|
|
489
473
|
}
|
|
490
474
|
onMessage(event) {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
475
|
+
this.ngZone.run(() => {
|
|
476
|
+
const stateService = getSpotcheckStateService();
|
|
477
|
+
const { data } = event;
|
|
478
|
+
switch (data.type) {
|
|
479
|
+
case 'slideInFrame':
|
|
480
|
+
if (data.mounted) {
|
|
481
|
+
stateService.setState({ isMounted: true });
|
|
482
|
+
}
|
|
483
|
+
break;
|
|
484
|
+
case 'resizeWindow':
|
|
485
|
+
if (data.size) {
|
|
486
|
+
stateService.setState({
|
|
487
|
+
currentQuestionHeight: data.size.height,
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
else if (data.isCloseButtonEnabled) {
|
|
491
|
+
stateService.setState({
|
|
492
|
+
isCloseButtonEnabled: data.isCloseButtonEnabled,
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
break;
|
|
496
|
+
case 'surveyCompleted':
|
|
497
|
+
closeSpotCheckAndHandleSurveyEnd().then(() => {
|
|
498
|
+
getSpotCheckEventListener().emit('surveyCompleted', data.response);
|
|
499
|
+
this.cdr.detectChanges();
|
|
508
500
|
});
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
case 'classicLoadEvent':
|
|
519
|
-
stateService.setState({ isClassicLoadEventReceived: true });
|
|
520
|
-
break;
|
|
521
|
-
case 'chatLoadEvent':
|
|
522
|
-
stateService.setState({ isChatLoadEventReceived: true });
|
|
523
|
-
break;
|
|
524
|
-
default:
|
|
525
|
-
break;
|
|
526
|
-
}
|
|
501
|
+
break;
|
|
502
|
+
case 'surveyLoadStarted':
|
|
503
|
+
getSpotCheckEventListener().emit('surveyLoadStarted', data.surveyDetails);
|
|
504
|
+
break;
|
|
505
|
+
default:
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
this.cdr.detectChanges();
|
|
509
|
+
});
|
|
527
510
|
}
|
|
528
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: WebViewComponent, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component });
|
|
511
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: WebViewComponent, deps: [{ token: i1.DomSanitizer }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
529
512
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.3", type: WebViewComponent, isStandalone: true, selector: "WebViewComponent", inputs: { url: "url", webviewType: "webviewType", isMiniCard: "isMiniCard" }, host: { listeners: { "window:message": "onMessage($event)" } }, viewQueries: [{ propertyName: "iframe", first: true, predicate: ["iframeRef"], descendants: true }], ngImport: i0, template: `
|
|
530
513
|
<div style="overflow: hidden; height: 100%; border-radius: {{isMiniCard ? 12 : 0}}px; padding-left: {{isMiniCard ? 12 : 0}}px; padding-right: {{isMiniCard ? 12 : 0}}px; box-sizing: border-box;">
|
|
531
514
|
<iframe
|
|
532
|
-
allow="camera; microphone; geolocation; display-capture; autoplay; clipboard-read; clipboard-write;
|
|
533
|
-
allowfullscreen
|
|
515
|
+
allow="camera; microphone; geolocation; display-capture; autoplay; clipboard-read; clipboard-write;"
|
|
534
516
|
#iframeRef
|
|
535
517
|
[src]="safeUrl"
|
|
536
518
|
style="width: 100%; height: 100%; display: block; border-radius: {{isMiniCard ? 12 : 0}}px;"
|
|
@@ -547,8 +529,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
|
|
|
547
529
|
template: `
|
|
548
530
|
<div style="overflow: hidden; height: 100%; border-radius: {{isMiniCard ? 12 : 0}}px; padding-left: {{isMiniCard ? 12 : 0}}px; padding-right: {{isMiniCard ? 12 : 0}}px; box-sizing: border-box;">
|
|
549
531
|
<iframe
|
|
550
|
-
allow="camera; microphone; geolocation; display-capture; autoplay; clipboard-read; clipboard-write;
|
|
551
|
-
allowfullscreen
|
|
532
|
+
allow="camera; microphone; geolocation; display-capture; autoplay; clipboard-read; clipboard-write;"
|
|
552
533
|
#iframeRef
|
|
553
534
|
[src]="safeUrl"
|
|
554
535
|
style="width: 100%; height: 100%; display: block; border-radius: {{isMiniCard ? 12 : 0}}px;"
|
|
@@ -560,7 +541,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
|
|
|
560
541
|
standalone: true,
|
|
561
542
|
imports: [CommonModule],
|
|
562
543
|
}]
|
|
563
|
-
}], ctorParameters: () => [{ type: i1.DomSanitizer }], propDecorators: { url: [{
|
|
544
|
+
}], ctorParameters: () => [{ type: i1.DomSanitizer }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }], propDecorators: { url: [{
|
|
564
545
|
type: Input
|
|
565
546
|
}], webviewType: [{
|
|
566
547
|
type: Input
|
|
@@ -628,6 +609,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
|
|
|
628
609
|
type: Input
|
|
629
610
|
}] } });
|
|
630
611
|
class CloseButtonComponent {
|
|
612
|
+
ngZone;
|
|
613
|
+
cdr;
|
|
631
614
|
size = 30;
|
|
632
615
|
strokeWidth = 1.2;
|
|
633
616
|
state;
|
|
@@ -636,13 +619,18 @@ class CloseButtonComponent {
|
|
|
636
619
|
isVisible = false;
|
|
637
620
|
isMiniCard = false;
|
|
638
621
|
stroke = 'black';
|
|
639
|
-
constructor() {
|
|
622
|
+
constructor(ngZone, cdr) {
|
|
623
|
+
this.ngZone = ngZone;
|
|
624
|
+
this.cdr = cdr;
|
|
640
625
|
this.stateService = getSpotcheckStateService();
|
|
641
626
|
this.state = this.stateService.getState();
|
|
642
627
|
this.updateComponentState();
|
|
643
628
|
this.stateSubscription = this.stateService.state$.subscribe((newState) => {
|
|
644
|
-
this.
|
|
645
|
-
|
|
629
|
+
this.ngZone.run(() => {
|
|
630
|
+
this.state = newState;
|
|
631
|
+
this.updateComponentState();
|
|
632
|
+
this.cdr.detectChanges();
|
|
633
|
+
});
|
|
646
634
|
});
|
|
647
635
|
}
|
|
648
636
|
ngOnDestroy() {
|
|
@@ -665,8 +653,11 @@ class CloseButtonComponent {
|
|
|
665
653
|
onClick = async () => {
|
|
666
654
|
await closeSpotCheck();
|
|
667
655
|
handleSurveyEnd();
|
|
656
|
+
this.ngZone.run(() => {
|
|
657
|
+
this.cdr.detectChanges();
|
|
658
|
+
});
|
|
668
659
|
};
|
|
669
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: CloseButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
660
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: CloseButtonComponent, deps: [{ token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
670
661
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.3", type: CloseButtonComponent, isStandalone: true, selector: "spotcheck-close-button", inputs: { size: "size", strokeWidth: "strokeWidth" }, ngImport: i0, template: `
|
|
671
662
|
<div style="position: absolute; top: -36px; right: 16px; z-index: 100001; cursor: pointer; background-color: white; border-radius: 50px;" (click)="onClick()" *ngIf="isVisible && isMiniCard">
|
|
672
663
|
<close-svg [size]="size" [stroke]="stroke" [strokeWidth]="strokeWidth" style="display: flex; align-items: center; justify-content: center;"/>
|
|
@@ -691,25 +682,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
|
|
|
691
682
|
standalone: true,
|
|
692
683
|
imports: [CommonModule, CloseSVGComponent],
|
|
693
684
|
}]
|
|
694
|
-
}], ctorParameters: () => [], propDecorators: { size: [{
|
|
685
|
+
}], ctorParameters: () => [{ type: i0.NgZone }, { type: i0.ChangeDetectorRef }], propDecorators: { size: [{
|
|
695
686
|
type: Input
|
|
696
687
|
}], strokeWidth: [{
|
|
697
688
|
type: Input
|
|
698
689
|
}] } });
|
|
699
690
|
class SpotCheckComponent {
|
|
691
|
+
ngZone;
|
|
692
|
+
cdr;
|
|
700
693
|
state;
|
|
701
694
|
spotcheckStateService;
|
|
702
695
|
stateSubscription;
|
|
703
696
|
componentStyles = {};
|
|
704
697
|
avatarUrl = '';
|
|
705
|
-
constructor() {
|
|
698
|
+
constructor(ngZone, cdr) {
|
|
699
|
+
this.ngZone = ngZone;
|
|
700
|
+
this.cdr = cdr;
|
|
706
701
|
this.spotcheckStateService = getSpotcheckStateService();
|
|
707
702
|
this.state = this.spotcheckStateService.getState();
|
|
708
703
|
this.updateComponentStyles();
|
|
709
704
|
this.stateSubscription = this.spotcheckStateService.state$.subscribe((newState) => {
|
|
710
|
-
this.
|
|
711
|
-
|
|
712
|
-
|
|
705
|
+
this.ngZone.run(() => {
|
|
706
|
+
this.state = newState;
|
|
707
|
+
this.updateComponentStyles();
|
|
708
|
+
this.avatarUrl = this.state.avatarUrl || "https://static.surveysparrow.com/application/images/profile.png";
|
|
709
|
+
this.cdr.detectChanges();
|
|
710
|
+
});
|
|
713
711
|
});
|
|
714
712
|
}
|
|
715
713
|
ngOnInit() {
|
|
@@ -758,13 +756,13 @@ class SpotCheckComponent {
|
|
|
758
756
|
console.log('Error initializing widget:', JSON.stringify(error));
|
|
759
757
|
}
|
|
760
758
|
};
|
|
761
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: SpotCheckComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
759
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: SpotCheckComponent, deps: [{ token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
762
760
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.3", type: SpotCheckComponent, isStandalone: true, selector: "SpotCheckComponent", ngImport: i0, template: "<div [ngStyle]=\"componentStyles.wrapperStyles\" class=\"safe-area\">\n <div [ngStyle]=\"componentStyles.styles\">\n <div style=\"position: relative; height: 100%;\">\n <spotcheck-close-button />\n \n <WebViewComponent\n *ngIf=\"state.classicUrl && state.classicUrl.length > 0 && state.spotcheckURL.length > 0 && state.spotCheckType === 'classic'\"\n [url]=\"state.classicUrl\"\n [webviewType]=\"'classic'\"\n [isMiniCard]=\"state.spotChecksMode === 'miniCard'\"\n />\n \n <WebViewComponent\n *ngIf=\"state.chatUrl && state.chatUrl.length > 0 && state.spotcheckURL.length > 0 && state.spotCheckType === 'chat'\"\n [url]=\"state.chatUrl\"\n [webviewType]=\"'chat'\"\n [isMiniCard]=\"state.spotChecksMode === 'miniCard'\"\n />\n\n <div *ngIf=\"state.spotChecksMode === 'miniCard' && state.avatarEnabled\">\n <div style=\"position: absolute; bottom: -66px; left: 16px; z-index: 100001;\">\n <img [src]=\"avatarUrl\" style=\"width: 56px; height: 56px; border-radius: 50px; background-color: white;\"/>\n </div>\n </div>\n </div>\n </div>\n</div>\n", styles: [".safe-area{padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom);padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right);box-sizing:border-box}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: WebViewComponent, selector: "WebViewComponent", inputs: ["url", "webviewType", "isMiniCard"] }, { kind: "component", type: CloseButtonComponent, selector: "spotcheck-close-button", inputs: ["size", "strokeWidth"] }] });
|
|
763
761
|
}
|
|
764
762
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: SpotCheckComponent, decorators: [{
|
|
765
763
|
type: Component,
|
|
766
764
|
args: [{ selector: 'SpotCheckComponent', standalone: true, imports: [CommonModule, WebViewComponent, CloseButtonComponent], template: "<div [ngStyle]=\"componentStyles.wrapperStyles\" class=\"safe-area\">\n <div [ngStyle]=\"componentStyles.styles\">\n <div style=\"position: relative; height: 100%;\">\n <spotcheck-close-button />\n \n <WebViewComponent\n *ngIf=\"state.classicUrl && state.classicUrl.length > 0 && state.spotcheckURL.length > 0 && state.spotCheckType === 'classic'\"\n [url]=\"state.classicUrl\"\n [webviewType]=\"'classic'\"\n [isMiniCard]=\"state.spotChecksMode === 'miniCard'\"\n />\n \n <WebViewComponent\n *ngIf=\"state.chatUrl && state.chatUrl.length > 0 && state.spotcheckURL.length > 0 && state.spotCheckType === 'chat'\"\n [url]=\"state.chatUrl\"\n [webviewType]=\"'chat'\"\n [isMiniCard]=\"state.spotChecksMode === 'miniCard'\"\n />\n\n <div *ngIf=\"state.spotChecksMode === 'miniCard' && state.avatarEnabled\">\n <div style=\"position: absolute; bottom: -66px; left: 16px; z-index: 100001;\">\n <img [src]=\"avatarUrl\" style=\"width: 56px; height: 56px; border-radius: 50px; background-color: white;\"/>\n </div>\n </div>\n </div>\n </div>\n</div>\n", styles: [".safe-area{padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom);padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right);box-sizing:border-box}\n"] }]
|
|
767
|
-
}], ctorParameters: () => [] });
|
|
765
|
+
}], ctorParameters: () => [{ type: i0.NgZone }, { type: i0.ChangeDetectorRef }] });
|
|
768
766
|
|
|
769
767
|
class SpotCheck {
|
|
770
768
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: SpotCheck, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -906,7 +904,7 @@ const sendTrackScreenRequest = async ({ screen, options, }) => {
|
|
|
906
904
|
}
|
|
907
905
|
}
|
|
908
906
|
}
|
|
909
|
-
throw new Error(responseJson?.reason
|
|
907
|
+
throw new Error(responseJson?.reason.toString());
|
|
910
908
|
}
|
|
911
909
|
else {
|
|
912
910
|
throw new Error(`Received status code ${response.status}`);
|
|
@@ -989,7 +987,7 @@ const sendTrackEventRequest = async ({ screen, event }) => {
|
|
|
989
987
|
return { valid: true };
|
|
990
988
|
}
|
|
991
989
|
}
|
|
992
|
-
throw new Error(responseJson?.reason
|
|
990
|
+
throw new Error(responseJson?.reason.toString());
|
|
993
991
|
}
|
|
994
992
|
else {
|
|
995
993
|
throw new Error(`Received status code ${response.status}`);
|
|
@@ -1066,5 +1064,5 @@ const trackEvent = async ({ screen, event }) => {
|
|
|
1066
1064
|
* Generated bundle index. Do not edit.
|
|
1067
1065
|
*/
|
|
1068
1066
|
|
|
1069
|
-
export { SpotCheck, initializeSpotChecks, trackEvent, trackScreen };
|
|
1067
|
+
export { SpotCheck, addSpotCheckListener, initializeSpotChecks, trackEvent, trackScreen };
|
|
1070
1068
|
//# sourceMappingURL=angular-ui.mjs.map
|