surveysparrow-ionic-plugin 2.0.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 +80 -51
- package/dist/angular-ui/esm2022/spotchecks/SpotCheckEventListener.mjs +26 -0
- package/dist/angular-ui/esm2022/spotchecks/api.mjs +1 -1
- package/dist/angular-ui/esm2022/spotchecks/helpers.mjs +6 -3
- package/dist/angular-ui/esm2022/spotchecks/index.mjs +2 -1
- package/dist/angular-ui/fesm2022/angular-ui.mjs +109 -54
- package/dist/angular-ui/fesm2022/angular-ui.mjs.map +1 -1
- package/dist/angular-ui/spotchecks/SpotCheckComponent.d.ts +10 -4
- package/dist/angular-ui/spotchecks/SpotCheckEventListener.d.ts +16 -0
- package/dist/angular-ui/spotchecks/index.d.ts +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.d.ts +10 -4
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js +75 -48
- 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/api.js.map +1 -1
- package/dist/esm/angular-ui/lib/spotchecks/helpers.js +5 -2
- 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/plugin.cjs.js +103 -44
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +103 -44
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
- package/src/angular-ui/lib/spotchecks/SpotCheckComponent.ts +75 -44
- package/src/angular-ui/lib/spotchecks/SpotCheckEventListener.ts +50 -0
- package/src/angular-ui/lib/spotchecks/api.ts +2 -2
- package/src/angular-ui/lib/spotchecks/helpers.ts +6 -4
- package/src/angular-ui/lib/spotchecks/index.ts +3 -0
package/dist/plugin.cjs.js
CHANGED
|
@@ -51136,6 +51136,33 @@ SpotcheckStateService = __decorate$2([
|
|
|
51136
51136
|
})
|
|
51137
51137
|
], SpotcheckStateService);
|
|
51138
51138
|
|
|
51139
|
+
class SpotCheckEventListenerService {
|
|
51140
|
+
constructor() {
|
|
51141
|
+
this.eventSubject = new Subject();
|
|
51142
|
+
this.event$ = this.eventSubject.asObservable();
|
|
51143
|
+
}
|
|
51144
|
+
emit(type, data) {
|
|
51145
|
+
this.eventSubject.next({ type, data });
|
|
51146
|
+
}
|
|
51147
|
+
addListener(eventType, callback) {
|
|
51148
|
+
return this.event$.subscribe((event) => {
|
|
51149
|
+
if (event.type === eventType) {
|
|
51150
|
+
callback(event.data);
|
|
51151
|
+
}
|
|
51152
|
+
});
|
|
51153
|
+
}
|
|
51154
|
+
}
|
|
51155
|
+
let globalInstance;
|
|
51156
|
+
const getSpotCheckEventListener = () => {
|
|
51157
|
+
if (!globalInstance) {
|
|
51158
|
+
globalInstance = new SpotCheckEventListenerService();
|
|
51159
|
+
}
|
|
51160
|
+
return globalInstance;
|
|
51161
|
+
};
|
|
51162
|
+
const addSpotCheckListener = (eventType, callback) => {
|
|
51163
|
+
return getSpotCheckEventListener().addListener(eventType, callback);
|
|
51164
|
+
};
|
|
51165
|
+
|
|
51139
51166
|
let globalSpotcheckStateService;
|
|
51140
51167
|
const getSpotcheckStateService = () => {
|
|
51141
51168
|
if (!globalSpotcheckStateService) {
|
|
@@ -51312,7 +51339,10 @@ const closeSpotCheck = async () => {
|
|
|
51312
51339
|
},
|
|
51313
51340
|
body: JSON.stringify(payload),
|
|
51314
51341
|
});
|
|
51315
|
-
if (response.status
|
|
51342
|
+
if (response.status == 200) {
|
|
51343
|
+
getSpotCheckEventListener().emit('surveyDismissed');
|
|
51344
|
+
}
|
|
51345
|
+
else {
|
|
51316
51346
|
console.log(`Error: ${response.status}`);
|
|
51317
51347
|
}
|
|
51318
51348
|
}
|
|
@@ -51421,7 +51451,6 @@ const getSpotcheckComponentCssStyles = (state) => {
|
|
|
51421
51451
|
};
|
|
51422
51452
|
};
|
|
51423
51453
|
const closeSpotCheckAndHandleSurveyEnd = async () => {
|
|
51424
|
-
await closeSpotCheck();
|
|
51425
51454
|
handleSurveyEnd();
|
|
51426
51455
|
};
|
|
51427
51456
|
|
|
@@ -51435,8 +51464,10 @@ var __metadata = (undefined && undefined.__metadata) || function (k, v) {
|
|
|
51435
51464
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
51436
51465
|
};
|
|
51437
51466
|
let WebViewComponent = class WebViewComponent {
|
|
51438
|
-
constructor(sanitizer) {
|
|
51467
|
+
constructor(sanitizer, ngZone, cdr) {
|
|
51439
51468
|
this.sanitizer = sanitizer;
|
|
51469
|
+
this.ngZone = ngZone;
|
|
51470
|
+
this.cdr = cdr;
|
|
51440
51471
|
this.url = '';
|
|
51441
51472
|
this.webviewType = 'classic';
|
|
51442
51473
|
this.isMiniCard = false;
|
|
@@ -51467,41 +51498,51 @@ let WebViewComponent = class WebViewComponent {
|
|
|
51467
51498
|
setupIframeLoadListener() {
|
|
51468
51499
|
const iframe = this.iframe.nativeElement;
|
|
51469
51500
|
iframe.addEventListener('load', () => {
|
|
51470
|
-
|
|
51471
|
-
|
|
51472
|
-
|
|
51473
|
-
|
|
51474
|
-
|
|
51475
|
-
|
|
51476
|
-
|
|
51501
|
+
this.ngZone.run(() => {
|
|
51502
|
+
const stateService = getSpotcheckStateService();
|
|
51503
|
+
if (this.webviewType === 'classic') {
|
|
51504
|
+
stateService.setState({ isClassicLoading: false });
|
|
51505
|
+
}
|
|
51506
|
+
else {
|
|
51507
|
+
stateService.setState({ isChatLoading: false });
|
|
51508
|
+
}
|
|
51509
|
+
});
|
|
51477
51510
|
});
|
|
51478
51511
|
}
|
|
51479
51512
|
onMessage(event) {
|
|
51480
|
-
|
|
51481
|
-
|
|
51482
|
-
|
|
51483
|
-
|
|
51484
|
-
|
|
51485
|
-
|
|
51486
|
-
|
|
51487
|
-
|
|
51488
|
-
|
|
51489
|
-
|
|
51490
|
-
|
|
51491
|
-
|
|
51492
|
-
|
|
51493
|
-
|
|
51494
|
-
|
|
51495
|
-
|
|
51496
|
-
|
|
51513
|
+
this.ngZone.run(() => {
|
|
51514
|
+
const stateService = getSpotcheckStateService();
|
|
51515
|
+
const { data } = event;
|
|
51516
|
+
switch (data.type) {
|
|
51517
|
+
case 'slideInFrame':
|
|
51518
|
+
if (data.mounted) {
|
|
51519
|
+
stateService.setState({ isMounted: true });
|
|
51520
|
+
}
|
|
51521
|
+
break;
|
|
51522
|
+
case 'resizeWindow':
|
|
51523
|
+
if (data.size) {
|
|
51524
|
+
stateService.setState({
|
|
51525
|
+
currentQuestionHeight: data.size.height,
|
|
51526
|
+
});
|
|
51527
|
+
}
|
|
51528
|
+
else if (data.isCloseButtonEnabled) {
|
|
51529
|
+
stateService.setState({
|
|
51530
|
+
isCloseButtonEnabled: data.isCloseButtonEnabled,
|
|
51531
|
+
});
|
|
51532
|
+
}
|
|
51533
|
+
break;
|
|
51534
|
+
case 'surveyCompleted':
|
|
51535
|
+
closeSpotCheckAndHandleSurveyEnd().then(() => {
|
|
51536
|
+
getSpotCheckEventListener().emit('surveyCompleted', data.response);
|
|
51537
|
+
this.cdr.detectChanges();
|
|
51497
51538
|
});
|
|
51498
|
-
|
|
51499
|
-
|
|
51500
|
-
|
|
51501
|
-
|
|
51502
|
-
|
|
51503
|
-
|
|
51504
|
-
}
|
|
51539
|
+
break;
|
|
51540
|
+
case 'surveyLoadStarted':
|
|
51541
|
+
getSpotCheckEventListener().emit('surveyLoadStarted', data.surveyDetails);
|
|
51542
|
+
break;
|
|
51543
|
+
}
|
|
51544
|
+
this.cdr.detectChanges();
|
|
51545
|
+
});
|
|
51505
51546
|
}
|
|
51506
51547
|
};
|
|
51507
51548
|
__decorate$1([
|
|
@@ -51544,7 +51585,9 @@ WebViewComponent = __decorate$1([
|
|
|
51544
51585
|
standalone: true,
|
|
51545
51586
|
imports: [CommonModule],
|
|
51546
51587
|
}),
|
|
51547
|
-
__metadata("design:paramtypes", [DomSanitizer
|
|
51588
|
+
__metadata("design:paramtypes", [DomSanitizer,
|
|
51589
|
+
NgZone,
|
|
51590
|
+
ChangeDetectorRef])
|
|
51548
51591
|
], WebViewComponent);
|
|
51549
51592
|
let CloseSVGComponent = class CloseSVGComponent {
|
|
51550
51593
|
constructor() {
|
|
@@ -51590,7 +51633,9 @@ CloseSVGComponent = __decorate$1([
|
|
|
51590
51633
|
})
|
|
51591
51634
|
], CloseSVGComponent);
|
|
51592
51635
|
let CloseButtonComponent = class CloseButtonComponent {
|
|
51593
|
-
constructor() {
|
|
51636
|
+
constructor(ngZone, cdr) {
|
|
51637
|
+
this.ngZone = ngZone;
|
|
51638
|
+
this.cdr = cdr;
|
|
51594
51639
|
this.size = 30;
|
|
51595
51640
|
this.strokeWidth = 1.2;
|
|
51596
51641
|
this.isVisible = false;
|
|
@@ -51599,13 +51644,19 @@ let CloseButtonComponent = class CloseButtonComponent {
|
|
|
51599
51644
|
this.onClick = async () => {
|
|
51600
51645
|
await closeSpotCheck();
|
|
51601
51646
|
handleSurveyEnd();
|
|
51647
|
+
this.ngZone.run(() => {
|
|
51648
|
+
this.cdr.detectChanges();
|
|
51649
|
+
});
|
|
51602
51650
|
};
|
|
51603
51651
|
this.stateService = getSpotcheckStateService();
|
|
51604
51652
|
this.state = this.stateService.getState();
|
|
51605
51653
|
this.updateComponentState();
|
|
51606
51654
|
this.stateSubscription = this.stateService.state$.subscribe((newState) => {
|
|
51607
|
-
this.
|
|
51608
|
-
|
|
51655
|
+
this.ngZone.run(() => {
|
|
51656
|
+
this.state = newState;
|
|
51657
|
+
this.updateComponentState();
|
|
51658
|
+
this.cdr.detectChanges();
|
|
51659
|
+
});
|
|
51609
51660
|
});
|
|
51610
51661
|
}
|
|
51611
51662
|
ngOnDestroy() {
|
|
@@ -51649,10 +51700,13 @@ CloseButtonComponent = __decorate$1([
|
|
|
51649
51700
|
standalone: true,
|
|
51650
51701
|
imports: [CommonModule, CloseSVGComponent],
|
|
51651
51702
|
}),
|
|
51652
|
-
__metadata("design:paramtypes", [
|
|
51703
|
+
__metadata("design:paramtypes", [NgZone,
|
|
51704
|
+
ChangeDetectorRef])
|
|
51653
51705
|
], CloseButtonComponent);
|
|
51654
51706
|
let SpotCheckComponent = class SpotCheckComponent {
|
|
51655
|
-
constructor() {
|
|
51707
|
+
constructor(ngZone, cdr) {
|
|
51708
|
+
this.ngZone = ngZone;
|
|
51709
|
+
this.cdr = cdr;
|
|
51656
51710
|
this.componentStyles = {};
|
|
51657
51711
|
this.avatarUrl = '';
|
|
51658
51712
|
this.initializeComponent = async () => {
|
|
@@ -51695,9 +51749,12 @@ let SpotCheckComponent = class SpotCheckComponent {
|
|
|
51695
51749
|
this.state = this.spotcheckStateService.getState();
|
|
51696
51750
|
this.updateComponentStyles();
|
|
51697
51751
|
this.stateSubscription = this.spotcheckStateService.state$.subscribe((newState) => {
|
|
51698
|
-
this.
|
|
51699
|
-
|
|
51700
|
-
|
|
51752
|
+
this.ngZone.run(() => {
|
|
51753
|
+
this.state = newState;
|
|
51754
|
+
this.updateComponentStyles();
|
|
51755
|
+
this.avatarUrl = this.state.avatarUrl || "https://static.surveysparrow.com/application/images/profile.png";
|
|
51756
|
+
this.cdr.detectChanges();
|
|
51757
|
+
});
|
|
51701
51758
|
});
|
|
51702
51759
|
}
|
|
51703
51760
|
ngOnInit() {
|
|
@@ -51720,7 +51777,8 @@ SpotCheckComponent = __decorate$1([
|
|
|
51720
51777
|
standalone: true,
|
|
51721
51778
|
imports: [CommonModule, WebViewComponent, CloseButtonComponent],
|
|
51722
51779
|
}),
|
|
51723
|
-
__metadata("design:paramtypes", [
|
|
51780
|
+
__metadata("design:paramtypes", [NgZone,
|
|
51781
|
+
ChangeDetectorRef])
|
|
51724
51782
|
], SpotCheckComponent);
|
|
51725
51783
|
|
|
51726
51784
|
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -52026,6 +52084,7 @@ const trackEvent = async ({ screen, event }) => {
|
|
|
52026
52084
|
const SurveySparrowIonicPlugin = core.registerPlugin('SurveySparrowIonicPlugin');
|
|
52027
52085
|
|
|
52028
52086
|
exports.SurveySparrowIonicPlugin = SurveySparrowIonicPlugin;
|
|
52087
|
+
exports.addSpotCheckListener = addSpotCheckListener;
|
|
52029
52088
|
exports.initializeSpotChecks = initializeSpotChecks;
|
|
52030
52089
|
exports.trackEvent = trackEvent;
|
|
52031
52090
|
exports.trackScreen = trackScreen;
|