surveysparrow-ionic-plugin 2.0.2-beta.1 → 2.0.2-beta.3

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 (32) hide show
  1. package/dist/angular-ui/esm2022/spotchecks/SpotCheckComponent.mjs +87 -58
  2. package/dist/angular-ui/esm2022/spotchecks/SpotCheckEventListener.mjs +26 -0
  3. package/dist/angular-ui/esm2022/spotchecks/api.mjs +1 -1
  4. package/dist/angular-ui/esm2022/spotchecks/helpers.mjs +6 -3
  5. package/dist/angular-ui/esm2022/spotchecks/index.mjs +2 -1
  6. package/dist/angular-ui/fesm2022/angular-ui.mjs +116 -61
  7. package/dist/angular-ui/fesm2022/angular-ui.mjs.map +1 -1
  8. package/dist/angular-ui/spotchecks/SpotCheckComponent.d.ts +10 -4
  9. package/dist/angular-ui/spotchecks/SpotCheckEventListener.d.ts +16 -0
  10. package/dist/angular-ui/spotchecks/index.d.ts +1 -0
  11. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.d.ts +10 -4
  12. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js +82 -55
  13. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js.map +1 -1
  14. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.d.ts +16 -0
  15. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.js +28 -0
  16. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.js.map +1 -0
  17. package/dist/esm/angular-ui/lib/spotchecks/api.js.map +1 -1
  18. package/dist/esm/angular-ui/lib/spotchecks/helpers.js +5 -2
  19. package/dist/esm/angular-ui/lib/spotchecks/helpers.js.map +1 -1
  20. package/dist/esm/angular-ui/lib/spotchecks/index.d.ts +1 -0
  21. package/dist/esm/angular-ui/lib/spotchecks/index.js +1 -0
  22. package/dist/esm/angular-ui/lib/spotchecks/index.js.map +1 -1
  23. package/dist/plugin.cjs.js +110 -54
  24. package/dist/plugin.cjs.js.map +1 -1
  25. package/dist/plugin.js +110 -54
  26. package/dist/plugin.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/angular-ui/lib/spotchecks/SpotCheckComponent.ts +94 -62
  29. package/src/angular-ui/lib/spotchecks/SpotCheckEventListener.ts +50 -0
  30. package/src/angular-ui/lib/spotchecks/api.ts +2 -2
  31. package/src/angular-ui/lib/spotchecks/helpers.ts +6 -4
  32. package/src/angular-ui/lib/spotchecks/index.ts +3 -0
package/dist/plugin.js CHANGED
@@ -51134,6 +51134,33 @@ Please check that 1) the type for the parameter at index ${index} is correct and
51134
51134
  })
51135
51135
  ], SpotcheckStateService);
51136
51136
 
51137
+ class SpotCheckEventListenerService {
51138
+ constructor() {
51139
+ this.eventSubject = new Subject();
51140
+ this.event$ = this.eventSubject.asObservable();
51141
+ }
51142
+ emit(type, data) {
51143
+ this.eventSubject.next({ type, data });
51144
+ }
51145
+ addListener(eventType, callback) {
51146
+ return this.event$.subscribe((event) => {
51147
+ if (event.type === eventType) {
51148
+ callback(event.data);
51149
+ }
51150
+ });
51151
+ }
51152
+ }
51153
+ let globalInstance;
51154
+ const getSpotCheckEventListener = () => {
51155
+ if (!globalInstance) {
51156
+ globalInstance = new SpotCheckEventListenerService();
51157
+ }
51158
+ return globalInstance;
51159
+ };
51160
+ const addSpotCheckListener = (eventType, callback) => {
51161
+ return getSpotCheckEventListener().addListener(eventType, callback);
51162
+ };
51163
+
51137
51164
  let globalSpotcheckStateService;
51138
51165
  let globalOS = null;
51139
51166
  const getSpotcheckStateService = () => {
@@ -51312,7 +51339,10 @@ Please check that 1) the type for the parameter at index ${index} is correct and
51312
51339
  },
51313
51340
  body: JSON.stringify(payload),
51314
51341
  });
51315
- if (response.status != 200) {
51342
+ if (response.status == 200) {
51343
+ getSpotCheckEventListener().emit('surveyDismissed');
51344
+ }
51345
+ else {
51316
51346
  console.log(`Error: ${response.status}`);
51317
51347
  }
51318
51348
  }
@@ -51425,7 +51455,6 @@ Please check that 1) the type for the parameter at index ${index} is correct and
51425
51455
  };
51426
51456
  };
51427
51457
  const closeSpotCheckAndHandleSurveyEnd = async () => {
51428
- await closeSpotCheck();
51429
51458
  handleSurveyEnd();
51430
51459
  };
51431
51460
 
@@ -51439,8 +51468,10 @@ Please check that 1) the type for the parameter at index ${index} is correct and
51439
51468
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
51440
51469
  };
51441
51470
  let WebViewComponent = class WebViewComponent {
51442
- constructor(sanitizer) {
51471
+ constructor(sanitizer, ngZone, cdr) {
51443
51472
  this.sanitizer = sanitizer;
51473
+ this.ngZone = ngZone;
51474
+ this.cdr = cdr;
51444
51475
  this.url = '';
51445
51476
  this.webviewType = 'classic';
51446
51477
  this.isMiniCard = false;
@@ -51471,14 +51502,16 @@ Please check that 1) the type for the parameter at index ${index} is correct and
51471
51502
  setupIframeLoadListener() {
51472
51503
  const iframe = this.iframe.nativeElement;
51473
51504
  iframe.addEventListener('load', () => {
51474
- this.injectNativeBridgeAdapters(iframe);
51475
- const stateService = getSpotcheckStateService();
51476
- if (this.webviewType === 'classic') {
51477
- stateService.setState({ isClassicLoading: false });
51478
- }
51479
- else {
51480
- stateService.setState({ isChatLoading: false });
51481
- }
51505
+ this.ngZone.run(() => {
51506
+ this.injectNativeBridgeAdapters(iframe);
51507
+ const stateService = getSpotcheckStateService();
51508
+ if (this.webviewType === 'classic') {
51509
+ stateService.setState({ isClassicLoading: false });
51510
+ }
51511
+ else {
51512
+ stateService.setState({ isChatLoading: false });
51513
+ }
51514
+ });
51482
51515
  });
51483
51516
  }
51484
51517
  injectNativeBridgeAdapters(iframe) {
@@ -51521,40 +51554,45 @@ Please check that 1) the type for the parameter at index ${index} is correct and
51521
51554
  }
51522
51555
  }
51523
51556
  onMessage(event) {
51524
- const stateService = getSpotcheckStateService();
51525
- const { data } = event;
51526
- switch (data.type) {
51527
- case 'slideInFrame':
51528
- if (data.mounted) {
51529
- stateService.setState({ isMounted: true });
51530
- }
51531
- break;
51532
- case 'resizeWindow':
51533
- if (data.size) {
51534
- stateService.setState({
51535
- currentQuestionHeight: data.size.height,
51536
- });
51537
- }
51538
- else if (data.isCloseButtonEnabled) {
51539
- stateService.setState({
51540
- isCloseButtonEnabled: data.isCloseButtonEnabled,
51557
+ this.ngZone.run(() => {
51558
+ const stateService = getSpotcheckStateService();
51559
+ const { data } = event;
51560
+ switch (data.type) {
51561
+ case 'slideInFrame':
51562
+ if (data.mounted) {
51563
+ stateService.setState({ isMounted: true });
51564
+ }
51565
+ break;
51566
+ case 'resizeWindow':
51567
+ if (data.size) {
51568
+ stateService.setState({
51569
+ currentQuestionHeight: data.size.height,
51570
+ });
51571
+ }
51572
+ else if (data.isCloseButtonEnabled) {
51573
+ stateService.setState({
51574
+ isCloseButtonEnabled: data.isCloseButtonEnabled,
51575
+ });
51576
+ }
51577
+ break;
51578
+ case 'surveyCompleted':
51579
+ closeSpotCheckAndHandleSurveyEnd().then(() => {
51580
+ getSpotCheckEventListener().emit('surveyCompleted', data.response);
51581
+ this.cdr.detectChanges();
51541
51582
  });
51542
- }
51543
- break;
51544
- case 'surveyCompleted':
51545
- closeSpotCheckAndHandleSurveyEnd();
51546
- // spotchecksListener.emitSurveyCompleted(data.response);
51547
- break;
51548
- case 'surveyLoadStarted':
51549
- // spotchecksListener.emitSurveyLoadStarted(data.surveyDetails);
51550
- break;
51551
- case 'classicLoadEvent':
51552
- stateService.setState({ isClassicLoadEventReceived: true });
51553
- break;
51554
- case 'chatLoadEvent':
51555
- stateService.setState({ isChatLoadEventReceived: true });
51556
- break;
51557
- }
51583
+ break;
51584
+ case 'surveyLoadStarted':
51585
+ getSpotCheckEventListener().emit('surveyLoadStarted', data.surveyDetails);
51586
+ break;
51587
+ case 'classicLoadEvent':
51588
+ stateService.setState({ isClassicLoadEventReceived: true });
51589
+ break;
51590
+ case 'chatLoadEvent':
51591
+ stateService.setState({ isChatLoadEventReceived: true });
51592
+ break;
51593
+ }
51594
+ this.cdr.detectChanges();
51595
+ });
51558
51596
  }
51559
51597
  };
51560
51598
  __decorate$1([
@@ -51598,7 +51636,9 @@ Please check that 1) the type for the parameter at index ${index} is correct and
51598
51636
  standalone: true,
51599
51637
  imports: [CommonModule],
51600
51638
  }),
51601
- __metadata("design:paramtypes", [DomSanitizer])
51639
+ __metadata("design:paramtypes", [DomSanitizer,
51640
+ NgZone,
51641
+ ChangeDetectorRef])
51602
51642
  ], WebViewComponent);
51603
51643
  let CloseSVGComponent = class CloseSVGComponent {
51604
51644
  constructor() {
@@ -51644,7 +51684,9 @@ Please check that 1) the type for the parameter at index ${index} is correct and
51644
51684
  })
51645
51685
  ], CloseSVGComponent);
51646
51686
  let CloseButtonComponent = class CloseButtonComponent {
51647
- constructor() {
51687
+ constructor(ngZone, cdr) {
51688
+ this.ngZone = ngZone;
51689
+ this.cdr = cdr;
51648
51690
  this.size = 30;
51649
51691
  this.strokeWidth = 1.2;
51650
51692
  this.isVisible = false;
@@ -51653,13 +51695,19 @@ Please check that 1) the type for the parameter at index ${index} is correct and
51653
51695
  this.onClick = async () => {
51654
51696
  await closeSpotCheck();
51655
51697
  handleSurveyEnd();
51698
+ this.ngZone.run(() => {
51699
+ this.cdr.detectChanges();
51700
+ });
51656
51701
  };
51657
51702
  this.stateService = getSpotcheckStateService();
51658
51703
  this.state = this.stateService.getState();
51659
51704
  this.updateComponentState();
51660
51705
  this.stateSubscription = this.stateService.state$.subscribe((newState) => {
51661
- this.state = newState;
51662
- this.updateComponentState();
51706
+ this.ngZone.run(() => {
51707
+ this.state = newState;
51708
+ this.updateComponentState();
51709
+ this.cdr.detectChanges();
51710
+ });
51663
51711
  });
51664
51712
  }
51665
51713
  ngOnDestroy() {
@@ -51703,10 +51751,13 @@ Please check that 1) the type for the parameter at index ${index} is correct and
51703
51751
  standalone: true,
51704
51752
  imports: [CommonModule, CloseSVGComponent],
51705
51753
  }),
51706
- __metadata("design:paramtypes", [])
51754
+ __metadata("design:paramtypes", [NgZone,
51755
+ ChangeDetectorRef])
51707
51756
  ], CloseButtonComponent);
51708
51757
  let SpotCheckComponent = class SpotCheckComponent {
51709
- constructor() {
51758
+ constructor(ngZone, cdr) {
51759
+ this.ngZone = ngZone;
51760
+ this.cdr = cdr;
51710
51761
  this.componentStyles = {};
51711
51762
  this.avatarUrl = '';
51712
51763
  this.initializeComponent = async () => {
@@ -51749,9 +51800,12 @@ Please check that 1) the type for the parameter at index ${index} is correct and
51749
51800
  this.state = this.spotcheckStateService.getState();
51750
51801
  this.updateComponentStyles();
51751
51802
  this.stateSubscription = this.spotcheckStateService.state$.subscribe((newState) => {
51752
- this.state = newState;
51753
- this.updateComponentStyles();
51754
- this.avatarUrl = this.state.avatarUrl || "https://static.surveysparrow.com/application/images/profile.png";
51803
+ this.ngZone.run(() => {
51804
+ this.state = newState;
51805
+ this.updateComponentStyles();
51806
+ this.avatarUrl = this.state.avatarUrl || "https://static.surveysparrow.com/application/images/profile.png";
51807
+ this.cdr.detectChanges();
51808
+ });
51755
51809
  });
51756
51810
  }
51757
51811
  ngOnInit() {
@@ -51774,7 +51828,8 @@ Please check that 1) the type for the parameter at index ${index} is correct and
51774
51828
  standalone: true,
51775
51829
  imports: [CommonModule, WebViewComponent, CloseButtonComponent],
51776
51830
  }),
51777
- __metadata("design:paramtypes", [])
51831
+ __metadata("design:paramtypes", [NgZone,
51832
+ ChangeDetectorRef])
51778
51833
  ], SpotCheckComponent);
51779
51834
 
51780
51835
  var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
@@ -52081,6 +52136,7 @@ Please check that 1) the type for the parameter at index ${index} is correct and
52081
52136
  const SurveySparrowIonicPlugin = core.registerPlugin('SurveySparrowIonicPlugin');
52082
52137
 
52083
52138
  exports.SurveySparrowIonicPlugin = SurveySparrowIonicPlugin;
52139
+ exports.addSpotCheckListener = addSpotCheckListener;
52084
52140
  exports.initializeSpotChecks = initializeSpotChecks;
52085
52141
  exports.trackEvent = trackEvent;
52086
52142
  exports.trackScreen = trackScreen;