surveysparrow-ionic-plugin 2.0.3 → 2.0.4-beta.1

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 (125) hide show
  1. package/dist/angular-ui/fesm2022/angular-ui.mjs +1203 -998
  2. package/dist/angular-ui/fesm2022/angular-ui.mjs.map +1 -1
  3. package/dist/angular-ui/index.d.ts +119 -5
  4. package/dist/docs.json +13 -5
  5. package/dist/esm/angular-ui/lib/public-api.js.map +1 -1
  6. package/dist/esm/angular-ui/lib/spotcheck.component.d.ts +30 -1
  7. package/dist/esm/angular-ui/lib/spotcheck.component.js +194 -4
  8. package/dist/esm/angular-ui/lib/spotcheck.component.js.map +1 -1
  9. package/dist/esm/angular-ui/lib/spotchecks/components/builder.component.d.ts +57 -0
  10. package/dist/esm/angular-ui/lib/spotchecks/components/builder.component.js +284 -0
  11. package/dist/esm/angular-ui/lib/spotchecks/components/builder.component.js.map +1 -0
  12. package/dist/esm/angular-ui/lib/spotchecks/helpers/binding.d.ts +25 -0
  13. package/dist/esm/angular-ui/lib/spotchecks/helpers/binding.js +107 -0
  14. package/dist/esm/angular-ui/lib/spotchecks/helpers/binding.js.map +1 -0
  15. package/dist/esm/angular-ui/lib/spotchecks/helpers/device.d.ts +11 -0
  16. package/dist/esm/angular-ui/lib/spotchecks/helpers/device.js +48 -0
  17. package/dist/esm/angular-ui/lib/spotchecks/helpers/device.js.map +1 -0
  18. package/dist/esm/angular-ui/lib/spotchecks/helpers/executables.d.ts +4 -0
  19. package/dist/esm/angular-ui/lib/spotchecks/helpers/executables.js +113 -0
  20. package/dist/esm/angular-ui/lib/spotchecks/helpers/executables.js.map +1 -0
  21. package/dist/esm/angular-ui/lib/spotchecks/helpers/listener.d.ts +9 -0
  22. package/dist/esm/angular-ui/lib/spotchecks/helpers/listener.js +55 -0
  23. package/dist/esm/angular-ui/lib/spotchecks/helpers/listener.js.map +1 -0
  24. package/dist/esm/angular-ui/lib/spotchecks/helpers/render.d.ts +5 -0
  25. package/dist/esm/angular-ui/lib/spotchecks/helpers/render.js +43 -0
  26. package/dist/esm/angular-ui/lib/spotchecks/helpers/render.js.map +1 -0
  27. package/dist/esm/angular-ui/lib/spotchecks/helpers/sentry.d.ts +7 -0
  28. package/dist/esm/angular-ui/lib/spotchecks/helpers/sentry.js +115 -0
  29. package/dist/esm/angular-ui/lib/spotchecks/helpers/sentry.js.map +1 -0
  30. package/dist/esm/angular-ui/lib/spotchecks/helpers/storage.d.ts +3 -0
  31. package/dist/esm/angular-ui/lib/spotchecks/helpers/storage.js +40 -0
  32. package/dist/esm/angular-ui/lib/spotchecks/helpers/storage.js.map +1 -0
  33. package/dist/esm/angular-ui/lib/spotchecks/helpers/survey-page.d.ts +22 -0
  34. package/dist/esm/angular-ui/lib/spotchecks/helpers/survey-page.js +128 -0
  35. package/dist/esm/angular-ui/lib/spotchecks/helpers/survey-page.js.map +1 -0
  36. package/dist/esm/angular-ui/lib/spotchecks/helpers/version.d.ts +2 -0
  37. package/dist/esm/angular-ui/lib/spotchecks/helpers/version.js +4 -0
  38. package/dist/esm/angular-ui/lib/spotchecks/helpers/version.js.map +1 -0
  39. package/dist/esm/angular-ui/lib/spotchecks/index.d.ts +4 -3
  40. package/dist/esm/angular-ui/lib/spotchecks/index.js +2 -2
  41. package/dist/esm/angular-ui/lib/spotchecks/index.js.map +1 -1
  42. package/dist/esm/angular-ui/lib/spotchecks/spotcheck.d.ts +8 -0
  43. package/dist/esm/angular-ui/lib/spotchecks/spotcheck.js +147 -0
  44. package/dist/esm/angular-ui/lib/spotchecks/spotcheck.js.map +1 -0
  45. package/dist/esm/angular-ui/lib/spotchecks/state/store.d.ts +14 -0
  46. package/dist/esm/angular-ui/lib/spotchecks/state/store.js +109 -0
  47. package/dist/esm/angular-ui/lib/spotchecks/state/store.js.map +1 -0
  48. package/dist/esm/angular-ui/lib/spotchecks/types.d.ts +22 -58
  49. package/dist/esm/angular-ui/lib/spotchecks/types.js.map +1 -1
  50. package/dist/plugin.cjs.js +1211 -51762
  51. package/dist/plugin.cjs.js.map +1 -1
  52. package/dist/plugin.js +1209 -51761
  53. package/dist/plugin.js.map +1 -1
  54. package/package.json +4 -8
  55. package/src/angular-ui/lib/public-api.ts +1 -1
  56. package/src/angular-ui/lib/spotcheck.component.ts +202 -5
  57. package/src/angular-ui/lib/spotchecks/components/builder.component.ts +254 -0
  58. package/src/angular-ui/lib/spotchecks/helpers/binding.ts +126 -0
  59. package/src/angular-ui/lib/spotchecks/helpers/device.ts +51 -0
  60. package/src/angular-ui/lib/spotchecks/helpers/executables.ts +124 -0
  61. package/src/angular-ui/lib/spotchecks/helpers/listener.ts +61 -0
  62. package/src/angular-ui/lib/spotchecks/helpers/render.ts +44 -0
  63. package/src/angular-ui/lib/spotchecks/helpers/sentry.ts +127 -0
  64. package/src/angular-ui/lib/spotchecks/helpers/storage.ts +37 -0
  65. package/src/angular-ui/lib/spotchecks/helpers/survey-page.ts +120 -0
  66. package/src/angular-ui/lib/spotchecks/helpers/version.ts +3 -0
  67. package/src/angular-ui/lib/spotchecks/index.ts +11 -3
  68. package/src/angular-ui/lib/spotchecks/spotcheck.ts +150 -0
  69. package/src/angular-ui/lib/spotchecks/state/store.ts +126 -0
  70. package/src/angular-ui/lib/spotchecks/types.ts +26 -59
  71. package/src/angular-ui/ng-package.json +9 -12
  72. package/src/angular-ui/package.json +9 -8
  73. package/dist/angular-ui/esm2022/angular-ui.mjs +0 -5
  74. package/dist/angular-ui/esm2022/public-api.mjs +0 -3
  75. package/dist/angular-ui/esm2022/spotcheck.component.mjs +0 -17
  76. package/dist/angular-ui/esm2022/spotchecks/SpotCheck.mjs +0 -51
  77. package/dist/angular-ui/esm2022/spotchecks/SpotCheckComponent.mjs +0 -410
  78. package/dist/angular-ui/esm2022/spotchecks/SpotCheckEventListener.mjs +0 -26
  79. package/dist/angular-ui/esm2022/spotchecks/SpotcheckStateService.mjs +0 -67
  80. package/dist/angular-ui/esm2022/spotchecks/api.mjs +0 -230
  81. package/dist/angular-ui/esm2022/spotchecks/helpers.mjs +0 -338
  82. package/dist/angular-ui/esm2022/spotchecks/index.mjs +0 -3
  83. package/dist/angular-ui/esm2022/spotchecks/storage.mjs +0 -7
  84. package/dist/angular-ui/esm2022/spotchecks/types.mjs +0 -2
  85. package/dist/angular-ui/public-api.d.ts +0 -2
  86. package/dist/angular-ui/spotcheck.component.d.ts +0 -5
  87. package/dist/angular-ui/spotchecks/SpotCheck.d.ts +0 -4
  88. package/dist/angular-ui/spotchecks/SpotCheckComponent.d.ts +0 -65
  89. package/dist/angular-ui/spotchecks/SpotCheckEventListener.d.ts +0 -16
  90. package/dist/angular-ui/spotchecks/SpotcheckStateService.d.ts +0 -12
  91. package/dist/angular-ui/spotchecks/api.d.ts +0 -15
  92. package/dist/angular-ui/spotchecks/helpers.d.ts +0 -30
  93. package/dist/angular-ui/spotchecks/index.d.ts +0 -3
  94. package/dist/angular-ui/spotchecks/storage.d.ts +0 -2
  95. package/dist/angular-ui/spotchecks/types.d.ts +0 -80
  96. package/dist/esm/angular-ui/lib/spotchecks/SpotCheck.d.ts +0 -4
  97. package/dist/esm/angular-ui/lib/spotchecks/SpotCheck.js +0 -51
  98. package/dist/esm/angular-ui/lib/spotchecks/SpotCheck.js.map +0 -1
  99. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.d.ts +0 -56
  100. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js +0 -397
  101. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js.map +0 -1
  102. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.d.ts +0 -16
  103. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.js +0 -28
  104. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.js.map +0 -1
  105. package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.d.ts +0 -9
  106. package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.js +0 -72
  107. package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.js.map +0 -1
  108. package/dist/esm/angular-ui/lib/spotchecks/api.d.ts +0 -15
  109. package/dist/esm/angular-ui/lib/spotchecks/api.js +0 -232
  110. package/dist/esm/angular-ui/lib/spotchecks/api.js.map +0 -1
  111. package/dist/esm/angular-ui/lib/spotchecks/helpers.d.ts +0 -30
  112. package/dist/esm/angular-ui/lib/spotchecks/helpers.js +0 -304
  113. package/dist/esm/angular-ui/lib/spotchecks/helpers.js.map +0 -1
  114. package/dist/esm/angular-ui/lib/spotchecks/storage.d.ts +0 -2
  115. package/dist/esm/angular-ui/lib/spotchecks/storage.js +0 -7
  116. package/dist/esm/angular-ui/lib/spotchecks/storage.js.map +0 -1
  117. package/src/angular-ui/lib/spotchecks/SpotCheck.ts +0 -54
  118. package/src/angular-ui/lib/spotchecks/SpotCheckComponent.css +0 -7
  119. package/src/angular-ui/lib/spotchecks/SpotCheckComponent.html +0 -27
  120. package/src/angular-ui/lib/spotchecks/SpotCheckComponent.ts +0 -389
  121. package/src/angular-ui/lib/spotchecks/SpotCheckEventListener.ts +0 -50
  122. package/src/angular-ui/lib/spotchecks/SpotcheckStateService.ts +0 -66
  123. package/src/angular-ui/lib/spotchecks/api.ts +0 -286
  124. package/src/angular-ui/lib/spotchecks/helpers.ts +0 -414
  125. package/src/angular-ui/lib/spotchecks/storage.ts +0 -7
@@ -1,2 +1,31 @@
1
- export declare class SpotCheck {
1
+ import { OnDestroy, OnInit } from '@angular/core';
2
+ import type { BuilderContext, SchemaNode } from './spotchecks/helpers/binding';
3
+ export declare class SpotCheck implements OnInit, OnDestroy {
4
+ wrapperSchema: SchemaNode | null;
5
+ buttonSchema: SchemaNode | null;
6
+ wrapperCtx: BuilderContext;
7
+ buttonCtx: BuilderContext;
8
+ buttonReady: boolean;
9
+ private wrapperStyles;
10
+ private buttonStyles;
11
+ private destroyed;
12
+ private cleanups;
13
+ private lastInjectionKey;
14
+ private lastButtonKey;
15
+ private lastPath;
16
+ private readonly cdr;
17
+ private readonly zone;
18
+ private readonly router;
19
+ private readonly isBrowser;
20
+ private readonly webviewHandlers;
21
+ private readonly buttonHandlers;
22
+ private readonly scheduleRender;
23
+ private readonly scheduleWrapperStyles;
24
+ ngOnInit(): void;
25
+ ngOnDestroy(): void;
26
+ private onStateChange;
27
+ private render;
28
+ private hideAfterCrash;
29
+ private watchWindow;
30
+ private watchRouter;
2
31
  }
@@ -4,16 +4,206 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { Component } from '@angular/core';
8
- import { SpotCheckComponent } from './spotchecks/SpotCheckComponent';
7
+ import { ChangeDetectorRef, Component, NgZone, PLATFORM_ID, inject } from '@angular/core';
8
+ import { NgIf, isPlatformBrowser } from '@angular/common';
9
+ import { GuardsCheckEnd, NavigationEnd, Router } from '@angular/router';
10
+ import { SsNodeComponent } from './spotchecks/components/builder.component';
11
+ import { componentStore, spotcheckStore } from './spotchecks/state/store';
12
+ import { dispatchWrapper, execute } from './spotchecks/helpers/executables';
13
+ import { captureP1Error } from './spotchecks/helpers/sentry';
14
+ import { setAppRunner } from './spotchecks/helpers/listener';
15
+ import { batched, guardedDetectChanges, hasCrashed, onCrash } from './spotchecks/helpers/render';
16
+ // Path only: query or hash changes stay on the same screen.
17
+ const pathOf = (url) => (url || '').split(/[?#]/)[0];
18
+ // Only one <SpotCheck> renders; extra instances stay empty so they never touch the live page.
19
+ let owner = null;
20
+ // Keyboard cover below this is browser chrome, not a keyboard.
21
+ const MIN_KEYBOARD_HEIGHT = 80;
22
+ // Place once at the app root: <SpotCheck />. One Angular codebase for web, Android and iOS.
9
23
  let SpotCheck = class SpotCheck {
24
+ constructor() {
25
+ this.wrapperSchema = null;
26
+ this.buttonSchema = null;
27
+ this.wrapperCtx = {};
28
+ this.buttonCtx = {};
29
+ this.buttonReady = false;
30
+ this.wrapperStyles = {
31
+ overlayStyle: { position: 'fixed', height: 0, opacity: 0, zIndex: -999999, pointerEvents: 'none' },
32
+ wrapperStyle: {},
33
+ };
34
+ this.buttonStyles = {};
35
+ this.destroyed = false;
36
+ this.cleanups = [];
37
+ this.lastInjectionKey = [];
38
+ this.lastButtonKey = [];
39
+ this.lastPath = null;
40
+ this.cdr = inject(ChangeDetectorRef);
41
+ this.zone = inject(NgZone);
42
+ this.router = inject(Router, { optional: true });
43
+ this.isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
44
+ this.webviewHandlers = {
45
+ classicWebViewRefCallback: (ref) => execute('webviewComponent.classicWebViewRefCallback', { ref }),
46
+ chatWebViewRefCallback: (ref) => execute('webviewComponent.chatWebViewRefCallback', { ref }),
47
+ handleOnMessage: (event) => execute('webviewComponent.handleWebViewMessage', { event }),
48
+ handleOnError: (error) => execute('webviewComponent.handleWebViewError', { error }),
49
+ };
50
+ this.buttonHandlers = {
51
+ handleSpotCheckButtonPress: () => execute('spotCheckButton.handleSpotCheckButtonPress'),
52
+ handleSideTabLayout: (event) => execute('spotCheckButton.handleSideTabLayout', { event }),
53
+ };
54
+ this.scheduleRender = batched(() => {
55
+ if (!this.destroyed)
56
+ this.render();
57
+ });
58
+ this.scheduleWrapperStyles = batched(() => {
59
+ if (this.destroyed)
60
+ return;
61
+ execute('wrapper.getWrapperStyles', {
62
+ screenHeight: window.innerHeight,
63
+ screenWidth: window.innerWidth,
64
+ setStyles: (styles) => {
65
+ this.wrapperStyles = styles;
66
+ this.scheduleRender();
67
+ },
68
+ });
69
+ });
70
+ }
71
+ ngOnInit() {
72
+ // Server render (SSR) or a second instance: render nothing.
73
+ if (!this.isBrowser || owner)
74
+ return;
75
+ owner = this;
76
+ // App callbacks run inside Angular so the app's own UI updates.
77
+ setAppRunner((fn) => this.zone.run(fn));
78
+ this.cleanups.push(spotcheckStore.subscribe(() => this.onStateChange()));
79
+ this.cleanups.push(componentStore.subscribe(() => this.onStateChange()));
80
+ this.cleanups.push(onCrash(() => this.hideAfterCrash()));
81
+ this.watchWindow();
82
+ this.watchRouter();
83
+ this.onStateChange();
84
+ }
85
+ ngOnDestroy() {
86
+ if (owner === this)
87
+ owner = null;
88
+ this.destroyed = true;
89
+ this.cleanups.forEach((cleanup) => cleanup());
90
+ }
91
+ // Same triggers as the other SDKs' Wrapper / WebViewComponent / SpotCheckButton effects.
92
+ onStateChange() {
93
+ const state = spotcheckStore.getState().SpotCheckState;
94
+ const { webViewDetails, spotCheckDetails } = state;
95
+ this.scheduleWrapperStyles();
96
+ const injectionKey = [webViewDetails.isChatLoading, webViewDetails.isClassicLoading, webViewDetails.webViewInjectionData];
97
+ if (injectionKey.some((value, i) => value !== this.lastInjectionKey[i])) {
98
+ this.lastInjectionKey = injectionKey;
99
+ execute('webviewComponent.handleWebViewInjection');
100
+ }
101
+ const buttonKey = [spotCheckDetails.spotCheckButtonConfig, spotCheckDetails.isSpotCheckButton, spotCheckDetails.sideTabButtonWidth];
102
+ if (buttonKey.some((value, i) => value !== this.lastButtonKey[i])) {
103
+ this.lastButtonKey = buttonKey;
104
+ execute('spotCheckButton.getSpotCheckButtonStyles').then((result) => {
105
+ if (!result)
106
+ return;
107
+ this.buttonStyles = result;
108
+ this.scheduleRender();
109
+ });
110
+ }
111
+ this.scheduleRender();
112
+ }
113
+ render() {
114
+ if (hasCrashed())
115
+ return;
116
+ const state = spotcheckStore.getState().SpotCheckState;
117
+ const componentState = componentStore.getState().componentState;
118
+ const schemas = componentState.isLoaded ? componentState.schemas || {} : {};
119
+ this.wrapperSchema = schemas.wrapper || null;
120
+ this.buttonSchema = schemas.spotCheckButton || null;
121
+ this.wrapperCtx = {
122
+ state,
123
+ styles: this.wrapperStyles,
124
+ slots: {
125
+ children: {
126
+ schema: schemas.webviewComponent || null,
127
+ context: { state, handlers: this.webviewHandlers },
128
+ },
129
+ },
130
+ };
131
+ this.buttonCtx = { state, styles: this.buttonStyles, handlers: this.buttonHandlers };
132
+ // Wait for styles so the button never renders unstyled for a frame.
133
+ this.buttonReady = Object.keys(this.buttonStyles || {}).length > 0;
134
+ guardedDetectChanges(this.cdr, 'render');
135
+ }
136
+ // After a failed draw, SpotCheck renders nothing for the rest of the session (RN error boundary parity).
137
+ hideAfterCrash() {
138
+ this.wrapperSchema = null;
139
+ this.buttonSchema = null;
140
+ try {
141
+ this.cdr.detectChanges();
142
+ }
143
+ catch (_a) { }
144
+ }
145
+ // Screen size and the part of it the on-screen keyboard covers.
146
+ watchWindow() {
147
+ const vv = window.visualViewport;
148
+ const onResize = () => {
149
+ let keyboard = 0;
150
+ if (vv)
151
+ keyboard = Math.round(window.innerHeight - vv.height - vv.offsetTop);
152
+ if (keyboard < MIN_KEYBOARD_HEIGHT)
153
+ keyboard = 0;
154
+ const current = spotcheckStore.getState().SpotCheckState.spotCheckDetails.keyBoardHeight || 0;
155
+ if (keyboard !== current)
156
+ dispatchWrapper({ spotCheckDetails: { keyBoardHeight: keyboard } });
157
+ else
158
+ this.scheduleWrapperStyles();
159
+ };
160
+ this.zone.runOutsideAngular(() => {
161
+ window.addEventListener('resize', onResize);
162
+ vv === null || vv === void 0 ? void 0 : vv.addEventListener('resize', onResize);
163
+ vv === null || vv === void 0 ? void 0 : vv.addEventListener('scroll', onResize);
164
+ });
165
+ this.cleanups.push(() => {
166
+ window.removeEventListener('resize', onResize);
167
+ vv === null || vv === void 0 ? void 0 : vv.removeEventListener('resize', onResize);
168
+ vv === null || vv === void 0 ? void 0 : vv.removeEventListener('scroll', onResize);
169
+ });
170
+ }
171
+ // Leaving a screen closes its spotcheck. GuardsCheckEnd comes after guards and redirects
172
+ // (a blocked navigation keeps the survey) and before the new page's trackScreen.
173
+ watchRouter() {
174
+ if (!this.router)
175
+ return;
176
+ this.lastPath = this.router.navigated ? pathOf(this.router.url) : null;
177
+ const subscription = this.router.events.subscribe((event) => {
178
+ try {
179
+ if (event instanceof GuardsCheckEnd && event.shouldActivate) {
180
+ const next = pathOf(event.urlAfterRedirects);
181
+ if (this.lastPath !== null && next !== this.lastPath) {
182
+ execute('handleNavigationChange');
183
+ }
184
+ this.lastPath = next;
185
+ }
186
+ else if (event instanceof NavigationEnd) {
187
+ this.lastPath = pathOf(event.urlAfterRedirects);
188
+ }
189
+ }
190
+ catch (error) {
191
+ captureP1Error(error, 'GENERAL', { action: 'navigationListener', errorMessage: error === null || error === void 0 ? void 0 : error.message });
192
+ }
193
+ });
194
+ this.cleanups.push(() => subscription.unsubscribe());
195
+ }
10
196
  };
11
197
  SpotCheck = __decorate([
12
198
  Component({
13
199
  selector: 'SpotCheck',
14
- template: `<SpotCheckComponent />`,
15
200
  standalone: true,
16
- imports: [SpotCheckComponent],
201
+ imports: [NgIf, SsNodeComponent],
202
+ styles: [':host { display: contents; }'],
203
+ template: `
204
+ <ss-node *ngIf="wrapperSchema" [node]="wrapperSchema" [ctx]="wrapperCtx"></ss-node>
205
+ <ss-node *ngIf="buttonSchema && buttonReady" [node]="buttonSchema" [ctx]="buttonCtx"></ss-node>
206
+ `,
17
207
  })
18
208
  ], SpotCheck);
19
209
  export { SpotCheck };
@@ -1 +1 @@
1
- {"version":3,"file":"spotcheck.component.js","sourceRoot":"","sources":["../../../../src/angular-ui/lib/spotcheck.component.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAQ9D,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IANrB,SAAS,CAAC;QACT,QAAQ,EAAE,WAAW;QACrB,QAAQ,EAAE,wBAAwB;QAClC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,kBAAkB,CAAC;KAC9B,CAAC;GACW,SAAS,CAAG","sourcesContent":["import { Component } from '@angular/core';\nimport { SpotCheckComponent } from './spotchecks/SpotCheckComponent';\n\n@Component({\n selector: 'SpotCheck',\n template: `<SpotCheckComponent />`,\n standalone: true,\n imports: [SpotCheckComponent],\n})\nexport class SpotCheck {}\n"]}
1
+ {"version":3,"file":"spotcheck.component.js","sourceRoot":"","sources":["../../../../src/angular-ui/lib/spotcheck.component.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,EAAqB,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7G,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAGjG,4DAA4D;AAC5D,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7D,8FAA8F;AAC9F,IAAI,KAAK,GAAqB,IAAI,CAAC;AAEnC,+DAA+D;AAC/D,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,4FAA4F;AAWrF,IAAM,SAAS,GAAf,MAAM,SAAS;IAAf;QACL,kBAAa,GAAsB,IAAI,CAAC;QACxC,iBAAY,GAAsB,IAAI,CAAC;QACvC,eAAU,GAAmB,EAAE,CAAC;QAChC,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ACH,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,oBAAoB,EAAE,YAAY,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EAAE,CAAC,CAAC;YACnG,CAAC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;IACvD,CAAC;CACF,CAAA;AA/KY,SAAS;IAVrB,SAAS,CAAC;QACT,QAAQ,EAAE,WAAW;QACrB,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC;QAChC,MAAM,EAAE,CAAC,8BAA8B,CAAC;QACxC,QAAQ,EAAE;;;GAGT;KACF,CAAC;GACW,SAAS,CA+KrB","sourcesContent":["import { ChangeDetectorRef, Component, NgZone, OnDestroy, OnInit, PLATFORM_ID, inject } from '@angular/core';\nimport { NgIf, isPlatformBrowser } from '@angular/common';\nimport { GuardsCheckEnd, NavigationEnd, Router } from '@angular/router';\nimport { SsNodeComponent } from './spotchecks/components/builder.component';\nimport { componentStore, spotcheckStore } from './spotchecks/state/store';\nimport { dispatchWrapper, execute } from './spotchecks/helpers/executables';\nimport { captureP1Error } from './spotchecks/helpers/sentry';\nimport { setAppRunner } from './spotchecks/helpers/listener';\nimport { batched, guardedDetectChanges, hasCrashed, onCrash } from './spotchecks/helpers/render';\nimport type { BuilderContext, SchemaNode } from './spotchecks/helpers/binding';\n\n// Path only: query or hash changes stay on the same screen.\nconst pathOf = (url: string) => (url || '').split(/[?#]/)[0];\n\n// Only one <SpotCheck> renders; extra instances stay empty so they never touch the live page.\nlet owner: SpotCheck | null = null;\n\n// Keyboard cover below this is browser chrome, not a keyboard.\nconst MIN_KEYBOARD_HEIGHT = 80;\n\n// Place once at the app root: <SpotCheck />. One Angular codebase for web, Android and iOS.\n@Component({\n selector: 'SpotCheck',\n standalone: true,\n imports: [NgIf, SsNodeComponent],\n styles: [':host { display: contents; }'],\n template: `\n <ss-node *ngIf=\"wrapperSchema\" [node]=\"wrapperSchema\" [ctx]=\"wrapperCtx\"></ss-node>\n <ss-node *ngIf=\"buttonSchema && buttonReady\" [node]=\"buttonSchema\" [ctx]=\"buttonCtx\"></ss-node>\n `,\n})\nexport class SpotCheck implements OnInit, OnDestroy {\n wrapperSchema: SchemaNode | null = null;\n buttonSchema: SchemaNode | null = null;\n wrapperCtx: BuilderContext = {};\n buttonCtx: BuilderContext = {};\n buttonReady = false;\n\n private wrapperStyles: any = {\n overlayStyle: { position: 'fixed', height: 0, opacity: 0, zIndex: -999999, pointerEvents: 'none' },\n wrapperStyle: {},\n };\n private buttonStyles: any = {};\n private destroyed = false;\n private cleanups: Array<() => void> = [];\n private lastInjectionKey: any[] = [];\n private lastButtonKey: any[] = [];\n private lastPath: string | null = null;\n\n private readonly cdr = inject(ChangeDetectorRef);\n private readonly zone = inject(NgZone);\n private readonly router = inject(Router, { optional: true });\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n private readonly webviewHandlers = {\n classicWebViewRefCallback: (ref: any) => execute('webviewComponent.classicWebViewRefCallback', { ref }),\n chatWebViewRefCallback: (ref: any) => execute('webviewComponent.chatWebViewRefCallback', { ref }),\n handleOnMessage: (event: any) => execute('webviewComponent.handleWebViewMessage', { event }),\n handleOnError: (error: any) => execute('webviewComponent.handleWebViewError', { error }),\n };\n\n private readonly buttonHandlers = {\n handleSpotCheckButtonPress: () => execute('spotCheckButton.handleSpotCheckButtonPress'),\n handleSideTabLayout: (event: any) => execute('spotCheckButton.handleSideTabLayout', { event }),\n };\n\n private readonly scheduleRender = batched(() => {\n if (!this.destroyed) this.render();\n });\n\n private readonly scheduleWrapperStyles = batched(() => {\n if (this.destroyed) return;\n execute('wrapper.getWrapperStyles', {\n screenHeight: window.innerHeight,\n screenWidth: window.innerWidth,\n setStyles: (styles: any) => {\n this.wrapperStyles = styles;\n this.scheduleRender();\n },\n });\n });\n\n ngOnInit(): void {\n // Server render (SSR) or a second instance: render nothing.\n if (!this.isBrowser || owner) return;\n owner = this;\n // App callbacks run inside Angular so the app's own UI updates.\n setAppRunner((fn) => this.zone.run(fn));\n this.cleanups.push(spotcheckStore.subscribe(() => this.onStateChange()));\n this.cleanups.push(componentStore.subscribe(() => this.onStateChange()));\n this.cleanups.push(onCrash(() => this.hideAfterCrash()));\n this.watchWindow();\n this.watchRouter();\n this.onStateChange();\n }\n\n ngOnDestroy(): void {\n if (owner === this) owner = null;\n this.destroyed = true;\n this.cleanups.forEach((cleanup) => cleanup());\n }\n\n // Same triggers as the other SDKs' Wrapper / WebViewComponent / SpotCheckButton effects.\n private onStateChange(): void {\n const state = spotcheckStore.getState().SpotCheckState;\n const { webViewDetails, spotCheckDetails } = state;\n\n this.scheduleWrapperStyles();\n\n const injectionKey = [webViewDetails.isChatLoading, webViewDetails.isClassicLoading, webViewDetails.webViewInjectionData];\n if (injectionKey.some((value, i) => value !== this.lastInjectionKey[i])) {\n this.lastInjectionKey = injectionKey;\n execute('webviewComponent.handleWebViewInjection');\n }\n\n const buttonKey = [spotCheckDetails.spotCheckButtonConfig, spotCheckDetails.isSpotCheckButton, spotCheckDetails.sideTabButtonWidth];\n if (buttonKey.some((value, i) => value !== this.lastButtonKey[i])) {\n this.lastButtonKey = buttonKey;\n execute('spotCheckButton.getSpotCheckButtonStyles').then((result) => {\n if (!result) return;\n this.buttonStyles = result;\n this.scheduleRender();\n });\n }\n\n this.scheduleRender();\n }\n\n private render(): void {\n if (hasCrashed()) return;\n const state = spotcheckStore.getState().SpotCheckState;\n const componentState = componentStore.getState().componentState;\n const schemas = componentState.isLoaded ? componentState.schemas || {} : {};\n\n this.wrapperSchema = schemas.wrapper || null;\n this.buttonSchema = schemas.spotCheckButton || null;\n this.wrapperCtx = {\n state,\n styles: this.wrapperStyles,\n slots: {\n children: {\n schema: schemas.webviewComponent || null,\n context: { state, handlers: this.webviewHandlers },\n },\n },\n };\n this.buttonCtx = { state, styles: this.buttonStyles, handlers: this.buttonHandlers };\n // Wait for styles so the button never renders unstyled for a frame.\n this.buttonReady = Object.keys(this.buttonStyles || {}).length > 0;\n guardedDetectChanges(this.cdr, 'render');\n }\n\n // After a failed draw, SpotCheck renders nothing for the rest of the session (RN error boundary parity).\n private hideAfterCrash(): void {\n this.wrapperSchema = null;\n this.buttonSchema = null;\n try {\n this.cdr.detectChanges();\n } catch {}\n }\n\n // Screen size and the part of it the on-screen keyboard covers.\n private watchWindow(): void {\n const vv: any = (window as any).visualViewport;\n const onResize = () => {\n let keyboard = 0;\n if (vv) keyboard = Math.round(window.innerHeight - vv.height - vv.offsetTop);\n if (keyboard < MIN_KEYBOARD_HEIGHT) keyboard = 0;\n const current = spotcheckStore.getState().SpotCheckState.spotCheckDetails.keyBoardHeight || 0;\n if (keyboard !== current) dispatchWrapper({ spotCheckDetails: { keyBoardHeight: keyboard } });\n else this.scheduleWrapperStyles();\n };\n this.zone.runOutsideAngular(() => {\n window.addEventListener('resize', onResize);\n vv?.addEventListener('resize', onResize);\n vv?.addEventListener('scroll', onResize);\n });\n this.cleanups.push(() => {\n window.removeEventListener('resize', onResize);\n vv?.removeEventListener('resize', onResize);\n vv?.removeEventListener('scroll', onResize);\n });\n }\n\n // Leaving a screen closes its spotcheck. GuardsCheckEnd comes after guards and redirects\n // (a blocked navigation keeps the survey) and before the new page's trackScreen.\n private watchRouter(): void {\n if (!this.router) return;\n this.lastPath = this.router.navigated ? pathOf(this.router.url) : null;\n const subscription = this.router.events.subscribe((event) => {\n try {\n if (event instanceof GuardsCheckEnd && event.shouldActivate) {\n const next = pathOf(event.urlAfterRedirects);\n if (this.lastPath !== null && next !== this.lastPath) {\n execute('handleNavigationChange');\n }\n this.lastPath = next;\n } else if (event instanceof NavigationEnd) {\n this.lastPath = pathOf(event.urlAfterRedirects);\n }\n } catch (error: any) {\n captureP1Error(error, 'GENERAL', { action: 'navigationListener', errorMessage: error?.message });\n }\n });\n this.cleanups.push(() => subscription.unsubscribe());\n }\n}\n"]}
@@ -0,0 +1,57 @@
1
+ import { ChangeDetectorRef, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, OnInit } from '@angular/core';
2
+ import { BuilderContext, SchemaNode, SlotContent } from '../helpers/binding';
3
+ export declare class LayoutDirective implements OnInit, OnDestroy {
4
+ private el;
5
+ private zone;
6
+ ssLayout: EventEmitter<any>;
7
+ private observer?;
8
+ private last;
9
+ constructor(el: ElementRef<HTMLElement>, zone: NgZone);
10
+ ngOnInit(): void;
11
+ ngOnDestroy(): void;
12
+ }
13
+ export declare class WebViewRendererComponent implements OnChanges, OnDestroy {
14
+ private el;
15
+ uri: string;
16
+ canShow: boolean;
17
+ onMessage?: (event: any) => void;
18
+ onError?: (error: any) => void;
19
+ refCallback?: (ref: any) => void;
20
+ hostStyle: string;
21
+ private page?;
22
+ constructor(el: ElementRef<HTMLElement>);
23
+ ngOnChanges(): void;
24
+ ngOnDestroy(): void;
25
+ }
26
+ export declare class SsNodeComponent implements OnChanges {
27
+ node: SchemaNode;
28
+ ctx: BuilderContext;
29
+ visible: boolean;
30
+ kind: string;
31
+ role: string | null;
32
+ props: Record<string, any>;
33
+ css: Record<string, string> | null;
34
+ content: any;
35
+ slot: SlotContent | null;
36
+ svgSrc: string;
37
+ children: SchemaNode[];
38
+ ngOnChanges(): void;
39
+ byIndex(index: number): number;
40
+ press(event: Event): void;
41
+ layout(event: any): void;
42
+ }
43
+ export declare class CloseButtonComponent implements OnInit, OnDestroy {
44
+ private cdr;
45
+ schema: SchemaNode | null;
46
+ ctx: BuilderContext;
47
+ private styles;
48
+ private styleKey;
49
+ private unsubscribers;
50
+ private readonly handlers;
51
+ private destroyed;
52
+ private readonly scheduleRender;
53
+ constructor(cdr: ChangeDetectorRef);
54
+ ngOnInit(): void;
55
+ ngOnDestroy(): void;
56
+ private update;
57
+ }
@@ -0,0 +1,284 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { ChangeDetectorRef, Component, Directive, ElementRef, EventEmitter, Input, NgZone, Output, ViewEncapsulation, forwardRef, } from '@angular/core';
11
+ import { NgFor, NgIf, NgStyle, NgSwitch, NgSwitchCase } from '@angular/common';
12
+ import { componentStore, spotcheckStore } from '../state/store';
13
+ import { execute } from '../helpers/executables';
14
+ import { SurveyPage } from '../helpers/survey-page';
15
+ import { batched, guardedDetectChanges } from '../helpers/render';
16
+ import { evaluateCondition, resolveBinding, toCss, } from '../helpers/binding';
17
+ // Reports the element's untransformed width like RN onLayout ({ nativeEvent: { layout } }).
18
+ let LayoutDirective = class LayoutDirective {
19
+ constructor(el, zone) {
20
+ this.el = el;
21
+ this.zone = zone;
22
+ this.ssLayout = new EventEmitter();
23
+ this.last = '';
24
+ }
25
+ ngOnInit() {
26
+ if (typeof ResizeObserver === 'undefined')
27
+ return;
28
+ this.zone.runOutsideAngular(() => {
29
+ this.observer = new ResizeObserver(() => {
30
+ const node = this.el.nativeElement;
31
+ const layout = { x: node.offsetLeft, y: node.offsetTop, width: node.offsetWidth, height: node.offsetHeight };
32
+ const key = `${layout.width}x${layout.height}`;
33
+ if (key === this.last)
34
+ return;
35
+ this.last = key;
36
+ this.ssLayout.emit({ nativeEvent: { layout } });
37
+ });
38
+ this.observer.observe(this.el.nativeElement);
39
+ });
40
+ }
41
+ ngOnDestroy() {
42
+ var _a;
43
+ (_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
44
+ }
45
+ };
46
+ __decorate([
47
+ Output(),
48
+ __metadata("design:type", Object)
49
+ ], LayoutDirective.prototype, "ssLayout", void 0);
50
+ LayoutDirective = __decorate([
51
+ Directive({ selector: '[ssLayout]', standalone: true }),
52
+ __metadata("design:paramtypes", [ElementRef, NgZone])
53
+ ], LayoutDirective);
54
+ export { LayoutDirective };
55
+ // Hosts one survey page; mirrors the RN WebViewRenderer (hidden pages stay 1x1 off-screen and keep loading).
56
+ let WebViewRendererComponent = class WebViewRendererComponent {
57
+ constructor(el) {
58
+ this.el = el;
59
+ this.uri = '';
60
+ this.canShow = false;
61
+ this.hostStyle = '';
62
+ }
63
+ ngOnChanges() {
64
+ var _a;
65
+ this.hostStyle = this.canShow
66
+ ? 'display:block;position:relative;width:100%;height:100%;'
67
+ : 'display:block;position:absolute;left:-1000px;top:0;width:1px;height:1px;opacity:0;overflow:hidden;';
68
+ if (!this.uri)
69
+ return;
70
+ if (!this.page) {
71
+ this.page = new SurveyPage(this.el.nativeElement, {
72
+ onMessage: (data) => { var _a; return (_a = this.onMessage) === null || _a === void 0 ? void 0 : _a.call(this, { nativeEvent: { data } }); },
73
+ onError: (error) => { var _a; return (_a = this.onError) === null || _a === void 0 ? void 0 : _a.call(this, error); },
74
+ });
75
+ (_a = this.refCallback) === null || _a === void 0 ? void 0 : _a.call(this, this.page);
76
+ }
77
+ this.page.load(this.uri);
78
+ }
79
+ ngOnDestroy() {
80
+ var _a, _b;
81
+ (_a = this.refCallback) === null || _a === void 0 ? void 0 : _a.call(this, null);
82
+ (_b = this.page) === null || _b === void 0 ? void 0 : _b.destroy();
83
+ }
84
+ };
85
+ __decorate([
86
+ Input(),
87
+ __metadata("design:type", Object)
88
+ ], WebViewRendererComponent.prototype, "uri", void 0);
89
+ __decorate([
90
+ Input(),
91
+ __metadata("design:type", Object)
92
+ ], WebViewRendererComponent.prototype, "canShow", void 0);
93
+ __decorate([
94
+ Input(),
95
+ __metadata("design:type", Function)
96
+ ], WebViewRendererComponent.prototype, "onMessage", void 0);
97
+ __decorate([
98
+ Input(),
99
+ __metadata("design:type", Function)
100
+ ], WebViewRendererComponent.prototype, "onError", void 0);
101
+ __decorate([
102
+ Input(),
103
+ __metadata("design:type", Function)
104
+ ], WebViewRendererComponent.prototype, "refCallback", void 0);
105
+ WebViewRendererComponent = __decorate([
106
+ Component({
107
+ selector: 'ss-webview-renderer',
108
+ standalone: true,
109
+ template: '',
110
+ host: { '[style]': 'hostStyle' },
111
+ }),
112
+ __metadata("design:paramtypes", [ElementRef])
113
+ ], WebViewRendererComponent);
114
+ export { WebViewRendererComponent };
115
+ // Renders one backend schema node as HTML (same node rules as the other SDKs' Builder).
116
+ let SsNodeComponent = class SsNodeComponent {
117
+ constructor() {
118
+ this.ctx = {};
119
+ this.visible = false;
120
+ this.kind = '';
121
+ this.role = null;
122
+ this.props = {};
123
+ this.css = null;
124
+ this.content = null;
125
+ this.slot = null;
126
+ this.svgSrc = '';
127
+ this.children = [];
128
+ }
129
+ // Binding results are computed once per render so templates see stable values.
130
+ ngOnChanges() {
131
+ var _a, _b;
132
+ const node = this.node;
133
+ const ctx = this.ctx || {};
134
+ this.slot = null;
135
+ if (!node) {
136
+ this.visible = false;
137
+ return;
138
+ }
139
+ if (node.slot) {
140
+ this.kind = 'slot';
141
+ this.slot = ((_a = ctx.slots) === null || _a === void 0 ? void 0 : _a[node.slot]) || null;
142
+ this.visible = Boolean(this.slot);
143
+ return;
144
+ }
145
+ this.visible = node.if === undefined || evaluateCondition(node.if, ctx);
146
+ if (!this.visible)
147
+ return;
148
+ this.kind = node.type || '';
149
+ this.role = ((_b = node.meta) === null || _b === void 0 ? void 0 : _b.componentRole) || null;
150
+ this.props = node.props ? resolveBinding(node.props, ctx) || {} : {};
151
+ this.css = toCss(this.props['style']);
152
+ this.content = node.content !== undefined ? resolveBinding(node.content, ctx) : null;
153
+ this.children = node.children || [];
154
+ if (this.kind === 'SvgXml') {
155
+ const xml = typeof this.props['xml'] === 'string' ? this.props['xml'] : '';
156
+ // As an image, so markup in the icon can never run script.
157
+ this.svgSrc = xml ? `data:image/svg+xml;charset=utf-8,${encodeURIComponent(xml)}` : '';
158
+ }
159
+ }
160
+ byIndex(index) {
161
+ return index;
162
+ }
163
+ press(event) {
164
+ var _a, _b;
165
+ event.stopPropagation();
166
+ (_b = (_a = this.props)['onPress']) === null || _b === void 0 ? void 0 : _b.call(_a, event);
167
+ }
168
+ layout(event) {
169
+ var _a, _b;
170
+ (_b = (_a = this.props)['onLayout']) === null || _b === void 0 ? void 0 : _b.call(_a, event);
171
+ }
172
+ };
173
+ __decorate([
174
+ Input(),
175
+ __metadata("design:type", Object)
176
+ ], SsNodeComponent.prototype, "node", void 0);
177
+ __decorate([
178
+ Input(),
179
+ __metadata("design:type", Object)
180
+ ], SsNodeComponent.prototype, "ctx", void 0);
181
+ SsNodeComponent = __decorate([
182
+ Component({
183
+ selector: 'ss-node',
184
+ standalone: true,
185
+ encapsulation: ViewEncapsulation.None,
186
+ imports: [
187
+ NgIf, NgFor, NgStyle, NgSwitch, NgSwitchCase, LayoutDirective, WebViewRendererComponent,
188
+ forwardRef(() => CloseButtonComponent),
189
+ ],
190
+ styles: [`
191
+ ss-node, ss-close-button { display: contents; }
192
+ .ss-node-box, .ss-node-pressable, .ss-node-text, .ss-node-image, .ss-node-svg { box-sizing: border-box; }
193
+ .ss-node-pressable { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
194
+ .ss-node-pressable:active { opacity: 0.6; }
195
+ .ss-node-pressable:focus { outline: none; }
196
+ `],
197
+ template: `
198
+ <ng-container *ngIf="visible" [ngSwitch]="kind">
199
+ <ng-container *ngSwitchCase="'slot'">
200
+ <ss-node *ngIf="slot?.schema" [node]="slot!.schema!" [ctx]="slot!.context"></ss-node>
201
+ </ng-container>
202
+ <div *ngSwitchCase="'Box'" class="ss-node-box" [attr.data-ss-role]="role" [ngStyle]="css">
203
+ <ss-node *ngFor="let child of children; trackBy: byIndex" [node]="child" [ctx]="ctx"></ss-node>
204
+ </div>
205
+ <div *ngSwitchCase="'Pressable'" class="ss-node-pressable" role="button" tabindex="0"
206
+ [attr.data-ss-role]="role" [attr.aria-label]="props['ariaLabel'] || null" [ngStyle]="css"
207
+ (click)="press($event)" (keydown.enter)="press($event)" (ssLayout)="layout($event)">
208
+ <ss-node *ngFor="let child of children; trackBy: byIndex" [node]="child" [ctx]="ctx"></ss-node>
209
+ </div>
210
+ <span *ngSwitchCase="'Text'" class="ss-node-text" [ngStyle]="css">{{ content }}</span>
211
+ <!-- A failed image keeps its space but shows nothing, like iOS and Flutter. -->
212
+ <img *ngSwitchCase="'Image'" class="ss-node-image" [attr.data-ss-role]="role" [src]="props['src']" [ngStyle]="css" alt=""
213
+ (error)="$any($event.target).style.visibility = 'hidden'" (load)="$any($event.target).style.visibility = ''" />
214
+ <img *ngSwitchCase="'SvgXml'" class="ss-node-svg" [src]="svgSrc" [ngStyle]="css" alt="" />
215
+ <ss-close-button *ngSwitchCase="'CloseButton'"></ss-close-button>
216
+ <ss-webview-renderer *ngSwitchCase="'WebViewRenderer'"
217
+ [attr.data-ss-webview]="node.meta?.['webViewType']"
218
+ [uri]="props['uri']" [canShow]="props['canShow']" [onMessage]="props['onMessage']"
219
+ [onError]="props['onError']" [refCallback]="props['ref']"></ss-webview-renderer>
220
+ </ng-container>
221
+ `,
222
+ })
223
+ ], SsNodeComponent);
224
+ export { SsNodeComponent };
225
+ // Backend-driven close button (schema closeButton + closeButton.getCloseButtonStyles).
226
+ let CloseButtonComponent = class CloseButtonComponent {
227
+ constructor(cdr) {
228
+ this.cdr = cdr;
229
+ this.schema = null;
230
+ this.ctx = {};
231
+ this.styles = {};
232
+ this.styleKey = [];
233
+ this.unsubscribers = [];
234
+ this.handlers = {
235
+ handleClosePress: () => {
236
+ execute('closeButton.handleCloseButton');
237
+ },
238
+ };
239
+ this.destroyed = false;
240
+ this.scheduleRender = batched(() => {
241
+ if (this.destroyed)
242
+ return;
243
+ this.ctx = { state: spotcheckStore.getState().SpotCheckState, styles: this.styles, handlers: this.handlers };
244
+ guardedDetectChanges(this.cdr, 'closeButtonRender');
245
+ });
246
+ }
247
+ ngOnInit() {
248
+ this.unsubscribers.push(spotcheckStore.subscribe(() => this.update()));
249
+ this.unsubscribers.push(componentStore.subscribe(() => this.update()));
250
+ this.update();
251
+ }
252
+ ngOnDestroy() {
253
+ this.destroyed = true;
254
+ this.unsubscribers.forEach((unsubscribe) => unsubscribe());
255
+ }
256
+ update() {
257
+ var _a;
258
+ const state = spotcheckStore.getState().SpotCheckState;
259
+ const componentState = componentStore.getState().componentState;
260
+ this.schema = componentState.isLoaded ? ((_a = componentState.schemas) === null || _a === void 0 ? void 0 : _a.closeButton) || null : null;
261
+ const key = [state.spotCheckDetails.closeButton, state.spotCheckDetails.isRTLLanguage];
262
+ if (key[0] !== this.styleKey[0] || key[1] !== this.styleKey[1]) {
263
+ this.styleKey = key;
264
+ execute('closeButton.getCloseButtonStyles').then((result) => {
265
+ if (!result)
266
+ return;
267
+ this.styles = result;
268
+ this.scheduleRender();
269
+ });
270
+ }
271
+ this.scheduleRender();
272
+ }
273
+ };
274
+ CloseButtonComponent = __decorate([
275
+ Component({
276
+ selector: 'ss-close-button',
277
+ standalone: true,
278
+ imports: [NgIf, SsNodeComponent],
279
+ template: `<ss-node *ngIf="schema" [node]="schema" [ctx]="ctx"></ss-node>`,
280
+ }),
281
+ __metadata("design:paramtypes", [ChangeDetectorRef])
282
+ ], CloseButtonComponent);
283
+ export { CloseButtonComponent };
284
+ //# sourceMappingURL=builder.component.js.map