@smileid/web-components 11.0.0 → 11.0.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 (141) hide show
  1. package/README.md +15 -15
  2. package/dist/README.md +15 -0
  3. package/dist/components/README.md +14 -0
  4. package/dist/components/document/src/README.md +111 -0
  5. package/dist/components/document/src/document-capture/README.md +90 -0
  6. package/dist/components/document/src/document-capture-instructions/README.md +56 -0
  7. package/dist/components/document/src/document-capture-review/README.md +79 -0
  8. package/dist/components/selfie/README.md +225 -0
  9. package/dist/components/smart-camera-web/src/README.md +207 -0
  10. package/dist/domain/camera/src/README.md +38 -0
  11. package/dist/domain/file-upload/README.md +35 -0
  12. package/dist/esm/{DocumentCaptureScreens-RECPb0wH.js → DocumentCaptureScreens-DmH2JZDA.js} +2 -2
  13. package/dist/esm/DocumentCaptureScreens-DmH2JZDA.js.map +1 -0
  14. package/dist/esm/EndUserConsent-D4fd1ovG.js.map +1 -1
  15. package/dist/esm/Navigation-CTjK6tLU.js.map +1 -1
  16. package/dist/esm/PoweredBySmileId-CxbaihMu.js.map +1 -1
  17. package/dist/esm/{SelfieCaptureScreens-CqBVGEJk.js → SelfieCaptureScreens-DbdN2zNk.js} +2 -2
  18. package/dist/esm/SelfieCaptureScreens-DbdN2zNk.js.map +1 -0
  19. package/dist/esm/SignaturePad-C7MtmT8m.js.map +1 -1
  20. package/dist/esm/TotpConsent-CQU5jQi4.js.map +1 -1
  21. package/dist/esm/combobox.js.map +1 -1
  22. package/dist/esm/document.js +1 -1
  23. package/dist/esm/main.js +2 -2
  24. package/dist/esm/{package-BDJnoIAU.js → package-bgeQiff6.js} +2 -2
  25. package/dist/esm/package-bgeQiff6.js.map +1 -0
  26. package/dist/esm/selfie.js +1 -1
  27. package/dist/esm/smart-camera-web.js +3 -3
  28. package/dist/esm/smart-camera-web.js.map +1 -1
  29. package/dist/esm/styles-BOEZtbuc.js.map +1 -1
  30. package/dist/package-lock.json +4948 -0
  31. package/dist/package.json +59 -0
  32. package/dist/smart-camera-web.js +1 -1
  33. package/dist/smart-camera-web.js.gz +0 -0
  34. package/dist/smart-camera-web.js.map +1 -1
  35. package/dist/src/components/combobox/src/index.js +2 -0
  36. package/dist/src/components/combobox/src/index.js.map +7 -0
  37. package/dist/src/components/document/src/index.js +2 -0
  38. package/dist/src/components/document/src/index.js.map +7 -0
  39. package/dist/src/components/end-user-consent/src/index.js +14 -0
  40. package/dist/src/components/end-user-consent/src/index.js.map +7 -0
  41. package/dist/src/components/selfie/src/index.js +2 -0
  42. package/dist/src/components/selfie/src/index.js.map +7 -0
  43. package/dist/src/components/signature-pad/src/index.js +10 -0
  44. package/dist/src/components/signature-pad/src/index.js.map +7 -0
  45. package/dist/src/components/smart-camera-web/src/SmartCameraWeb.js +2 -0
  46. package/dist/src/components/smart-camera-web/src/SmartCameraWeb.js.map +7 -0
  47. package/dist/src/components/totp-consent/src/index.js +14 -0
  48. package/dist/src/components/totp-consent/src/index.js.map +7 -0
  49. package/dist/src/index.js.map +7 -0
  50. package/dist/styles/README.md +3 -0
  51. package/dist/types/combobox.d.ts +19 -19
  52. package/dist/types/document.d.ts +19 -19
  53. package/dist/types/end-user-consent.d.ts +19 -19
  54. package/dist/types/main.d.ts +24 -20
  55. package/dist/types/navigation.d.ts +19 -19
  56. package/dist/types/selfie.d.ts +19 -19
  57. package/dist/types/signature-pad.d.ts +19 -19
  58. package/dist/types/smart-camera-web.d.ts +19 -19
  59. package/dist/types/totp-consent.d.ts +19 -19
  60. package/lib/components/README.md +14 -14
  61. package/lib/components/attribution/PoweredBySmileId.js +42 -42
  62. package/lib/components/camera-permission/CameraPermission.js +139 -139
  63. package/lib/components/camera-permission/CameraPermission.stories.js +27 -27
  64. package/lib/components/combobox/src/Combobox.js +589 -589
  65. package/lib/components/combobox/src/index.js +1 -1
  66. package/lib/components/document/src/DocumentCaptureScreens.js +410 -410
  67. package/lib/components/document/src/DocumentCaptureScreens.stories.js +57 -57
  68. package/lib/components/document/src/README.md +111 -111
  69. package/lib/components/document/src/document-capture/DocumentCapture.js +760 -760
  70. package/lib/components/document/src/document-capture/DocumentCapture.stories.js +78 -78
  71. package/lib/components/document/src/document-capture/README.md +90 -90
  72. package/lib/components/document/src/document-capture/index.js +3 -3
  73. package/lib/components/document/src/document-capture-instructions/DocumentCaptureInstructions.js +545 -545
  74. package/lib/components/document/src/document-capture-instructions/DocumentCaptureInstructions.stories.js +24 -24
  75. package/lib/components/document/src/document-capture-instructions/README.md +56 -56
  76. package/lib/components/document/src/document-capture-instructions/index.js +3 -3
  77. package/lib/components/document/src/document-capture-review/DocumentCaptureReview.js +360 -360
  78. package/lib/components/document/src/document-capture-review/DocumentCaptureReview.stories.js +24 -24
  79. package/lib/components/document/src/document-capture-review/README.md +79 -79
  80. package/lib/components/document/src/document-capture-review/index.js +3 -3
  81. package/lib/components/document/src/index.js +3 -3
  82. package/lib/components/end-user-consent/src/EndUserConsent.js +795 -795
  83. package/lib/components/end-user-consent/src/EndUserConsent.stories.js +29 -29
  84. package/lib/components/end-user-consent/src/index.js +4 -4
  85. package/lib/components/navigation/src/Navigation.js +171 -171
  86. package/lib/components/navigation/src/Navigation.stories.js +24 -24
  87. package/lib/components/navigation/src/index.js +3 -3
  88. package/lib/components/selfie/README.md +225 -225
  89. package/lib/components/selfie/src/SelfieCaptureScreens.js +420 -420
  90. package/lib/components/selfie/src/SelfieCaptureScreens.stories.js +29 -29
  91. package/lib/components/selfie/src/index.js +3 -3
  92. package/lib/components/selfie/src/selfie-capture/SelfieCapture.js +1099 -1099
  93. package/lib/components/selfie/src/selfie-capture/SelfieCapture.stories.js +36 -36
  94. package/lib/components/selfie/src/selfie-capture/index.js +3 -3
  95. package/lib/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.js +689 -689
  96. package/lib/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.stories.js +23 -23
  97. package/lib/components/selfie/src/selfie-capture-instructions/index.js +3 -3
  98. package/lib/components/selfie/src/selfie-capture-review/SelfieCaptureReview.js +209 -209
  99. package/lib/components/selfie/src/selfie-capture-review/SelfieCaptureReview.stories.js +24 -24
  100. package/lib/components/selfie/src/selfie-capture-review/index.js +3 -3
  101. package/lib/components/selfie/src/selfie-capture-wrapper/SelfieCaptureWrapper.tsx +256 -256
  102. package/lib/components/selfie/src/selfie-capture-wrapper/index.ts +1 -1
  103. package/lib/components/selfie/src/smartselfie-capture/OvalProgress.tsx +81 -81
  104. package/lib/components/selfie/src/smartselfie-capture/SmartSelfieCapture.tsx +265 -265
  105. package/lib/components/selfie/src/smartselfie-capture/components/AlertDisplay.tsx +34 -34
  106. package/lib/components/selfie/src/smartselfie-capture/components/CameraPreview.tsx +97 -97
  107. package/lib/components/selfie/src/smartselfie-capture/components/CaptureControls.tsx +78 -78
  108. package/lib/components/selfie/src/smartselfie-capture/components/index.ts +3 -3
  109. package/lib/components/selfie/src/smartselfie-capture/constants.ts +23 -23
  110. package/lib/components/selfie/src/smartselfie-capture/hooks/index.ts +2 -2
  111. package/lib/components/selfie/src/smartselfie-capture/hooks/useCamera.ts +238 -238
  112. package/lib/components/selfie/src/smartselfie-capture/hooks/useFaceCapture.ts +618 -618
  113. package/lib/components/selfie/src/smartselfie-capture/index.ts +1 -1
  114. package/lib/components/selfie/src/smartselfie-capture/utils/alertMessages.ts +13 -13
  115. package/lib/components/selfie/src/smartselfie-capture/utils/canvas.ts +105 -105
  116. package/lib/components/selfie/src/smartselfie-capture/utils/faceDetection.ts +129 -129
  117. package/lib/components/selfie/src/smartselfie-capture/utils/imageCapture.ts +64 -64
  118. package/lib/components/selfie/src/smartselfie-capture/utils/index.ts +4 -4
  119. package/lib/components/selfie/src/smartselfie-capture/utils/mediapipeManager.ts +77 -77
  120. package/lib/components/signature-pad/package-lock.json +3009 -3009
  121. package/lib/components/signature-pad/package.json +30 -30
  122. package/lib/components/signature-pad/src/SignaturePad.js +484 -484
  123. package/lib/components/signature-pad/src/SignaturePad.stories.js +32 -32
  124. package/lib/components/signature-pad/src/index.js +3 -3
  125. package/lib/components/smart-camera-web/src/README.md +206 -206
  126. package/lib/components/smart-camera-web/src/SmartCameraWeb.js +305 -305
  127. package/lib/components/smart-camera-web/src/SmartCameraWeb.stories.js +57 -57
  128. package/lib/components/totp-consent/src/TotpConsent.js +949 -949
  129. package/lib/components/totp-consent/src/index.js +4 -4
  130. package/lib/domain/camera/src/README.md +38 -38
  131. package/lib/domain/camera/src/SmartCamera.js +109 -109
  132. package/lib/domain/constants/src/Constants.js +27 -27
  133. package/lib/domain/file-upload/README.md +35 -35
  134. package/lib/domain/file-upload/src/SmartFileUpload.js +65 -65
  135. package/lib/styles/README.md +3 -3
  136. package/lib/styles/src/styles.js +372 -372
  137. package/lib/styles/src/typography.js +52 -52
  138. package/package.json +111 -112
  139. package/dist/esm/DocumentCaptureScreens-RECPb0wH.js.map +0 -1
  140. package/dist/esm/SelfieCaptureScreens-CqBVGEJk.js.map +0 -1
  141. package/dist/esm/package-BDJnoIAU.js.map +0 -1
@@ -1,305 +1,305 @@
1
- import styles from '../../../styles/src/styles';
2
- import SmartCamera from '../../../domain/camera/src/SmartCamera';
3
-
4
- import '../../document/src';
5
- import '../../selfie/src';
6
- import '../../camera-permission/CameraPermission';
7
- import packageJson from '../../../../package.json';
8
-
9
- const COMPONENTS_VERSION = packageJson.version;
10
-
11
- function scwTemplateString() {
12
- return `
13
- <style>
14
- :host {
15
- display: block;
16
- height: 100%;
17
- }
18
- </style>
19
- ${styles(this.themeColor)}
20
- <div style="height: 100%;">
21
- <camera-permission ${this.applyComponentThemeColor} ${this.title} ${this.showNavigation} ${this.hideInstructions ? '' : 'hidden'} ${this.hideAttribution}></camera-permission>
22
- <selfie-capture-screens ${this.applyComponentThemeColor} ${this.title} ${this.showNavigation} ${this.disableImageTests} ${this.hideAttribution} ${this.hideInstructions} hidden
23
- ${this.hideBackToHost} ${this.allowAgentMode} ${this.allowAgentModeTests}
24
- ></selfie-capture-screens>
25
- <document-capture-screens ${this.applyComponentThemeColor} document-type=${this.documentType} ${this.title} ${this.documentCaptureModes} ${this.showNavigation} ${this.hideAttribution}
26
- ${this.hideBackOfId} ${this.applyComponentThemeColor} hidden></document-capture-screens>
27
- </div>
28
- `;
29
- }
30
- class SmartCameraWeb extends HTMLElement {
31
- constructor() {
32
- super();
33
- this.scwTemplateString = scwTemplateString.bind(this);
34
- this.render = () => this.scwTemplateString();
35
- this.attachShadow({ mode: 'open' });
36
- this.activeScreen = null;
37
- }
38
-
39
- connectedCallback() {
40
- this.shadowRoot.innerHTML = this.render();
41
-
42
- this._data = {
43
- images: [],
44
- meta: {
45
- libraryVersion: COMPONENTS_VERSION,
46
- },
47
- };
48
-
49
- if (
50
- 'mediaDevices' in navigator &&
51
- 'getUserMedia' in navigator.mediaDevices
52
- ) {
53
- this.setUpEventListeners();
54
- } else {
55
- this.shadowRoot.innerHTML =
56
- '<h1 class="error-message">Your browser does not support this integration</h1>';
57
- }
58
- }
59
-
60
- disconnectedCallback() {
61
- SmartCamera.stopMedia();
62
- if (this.activeScreen) {
63
- this.activeScreen.removeAttribute('hidden');
64
- }
65
- this.activeScreen = null;
66
- this.shadowRoot.innerHTML = '';
67
- }
68
-
69
- static get observedAttributes() {
70
- return [
71
- 'allow-agent-mode',
72
- 'disable-image-tests',
73
- 'document-capture-modes',
74
- 'document-type',
75
- 'hide-attribution',
76
- 'hide-back-of-id',
77
- 'hide-back-to-host',
78
- 'show-navigation',
79
- 'theme-color',
80
- ];
81
- }
82
-
83
- attributeChangedCallback(name) {
84
- switch (name) {
85
- case 'allow-agent-mode':
86
- case 'disable-image-tests':
87
- case 'document-capture-modes':
88
- case 'document-type':
89
- case 'hide-attribution':
90
- case 'hide-back-of-id':
91
- case 'hide-back-to-host':
92
- case 'show-navigation':
93
- case 'theme-color':
94
- this.disconnectedCallback();
95
- this.shadowRoot.innerHTML = this.render();
96
- this.setUpEventListeners();
97
- break;
98
- default:
99
- break;
100
- }
101
- }
102
-
103
- setUpEventListeners() {
104
- this.cameraPermission = this.shadowRoot.querySelector('camera-permission');
105
- this.SelfieCaptureScreens = this.shadowRoot.querySelector(
106
- 'selfie-capture-screens',
107
- );
108
- this.documentCapture = this.shadowRoot.querySelector(
109
- 'document-capture-screens',
110
- );
111
-
112
- if (this.hideInstructions) {
113
- this.setActiveScreen(this.cameraPermission);
114
- } else {
115
- this.setActiveScreen(this.SelfieCaptureScreens);
116
- }
117
- this.cameraPermission.addEventListener('camera-permission.granted', () => {
118
- this.setActiveScreen(this.SelfieCaptureScreens);
119
- this.SelfieCaptureScreens.removeAttribute('data-camera-error');
120
- this.SelfieCaptureScreens.setAttribute('data-camera-ready', true);
121
- });
122
-
123
- this.SelfieCaptureScreens.addEventListener(
124
- 'selfie-capture-screens.publish',
125
- (event) => {
126
- this._data.images = event.detail.images;
127
- if (!this.captureId) {
128
- this._publishSelectedImages();
129
- } else {
130
- this.setActiveScreen(this.documentCapture);
131
- }
132
- },
133
- );
134
-
135
- this.SelfieCaptureScreens.addEventListener(
136
- 'selfie-capture-screens.cancelled',
137
- () => {
138
- if (this.hideInstructions) {
139
- this.setActiveScreen(this.cameraPermission);
140
- } else {
141
- this.handleBackEvents();
142
- }
143
- },
144
- );
145
- this.SelfieCaptureScreens.addEventListener(
146
- 'selfie-capture-screens.back',
147
- () => {
148
- if (!this.hideInstructions) {
149
- this.setActiveScreen(this.cameraPermission);
150
- }
151
- },
152
- );
153
-
154
- this.documentCapture.addEventListener(
155
- 'document-capture-screens.publish',
156
- (event) => {
157
- this._data.images = [...this._data.images, ...event.detail.images];
158
- this._publishSelectedImages();
159
- },
160
- );
161
-
162
- this.documentCapture.addEventListener(
163
- 'document-capture-screens.cancelled',
164
- () => {
165
- this.SelfieCaptureScreens.setAttribute(
166
- 'initial-screen',
167
- 'selfie-capture',
168
- );
169
- this.setActiveScreen(this.SelfieCaptureScreens);
170
- this.SelfieCaptureScreens.removeAttribute('data-camera-error');
171
- this.SelfieCaptureScreens.setAttribute('data-camera-ready', true);
172
- },
173
- );
174
-
175
- [
176
- this.cameraPermission,
177
- this.SelfieCaptureScreens,
178
- this.documentCapture,
179
- ].forEach((screen) => {
180
- screen.addEventListener(`${screen.nodeName.toLowerCase()}.close`, () =>
181
- this.handleCloseEvent(),
182
- );
183
- });
184
- this.documentCapture.addEventListener(
185
- 'document-capture-screens.back',
186
- () => {
187
- this.setActiveScreen(this.SelfieCaptureScreens);
188
- this.reset();
189
- },
190
- );
191
- }
192
-
193
- reset() {
194
- this.disconnectedCallback();
195
- this.connectedCallback();
196
- }
197
-
198
- handleBackEvents() {
199
- this.dispatchEvent(new CustomEvent('smart-camera-web.cancelled'));
200
- }
201
-
202
- _publishSelectedImages() {
203
- this.dispatchEvent(
204
- new CustomEvent('smart-camera-web.publish', { detail: this._data }),
205
- );
206
- }
207
-
208
- get captureId() {
209
- return this.hasAttribute('capture-id');
210
- }
211
-
212
- get documentType() {
213
- return this.getAttribute('document-type');
214
- }
215
-
216
- get isPortraitCaptureView() {
217
- return this.getAttribute('document-type') === 'GREEN_BOOK';
218
- }
219
-
220
- get hideInstructions() {
221
- return this.hasAttribute('hide-instructions') ? 'hide-instructions' : '';
222
- }
223
-
224
- get hideBackOfId() {
225
- return this.hasAttribute('hide-back-of-id') ? 'hide-back-of-id' : '';
226
- }
227
-
228
- get showNavigation() {
229
- return this.hasAttribute('show-navigation') ? 'show-navigation' : '';
230
- }
231
-
232
- get hideBackToHost() {
233
- return this.hasAttribute('hide-back-to-host') ||
234
- this.hasAttribute('hide-back')
235
- ? 'hide-back'
236
- : '';
237
- }
238
-
239
- get allowAgentMode() {
240
- return this.hasAttribute('allow-agent-mode')
241
- ? `allow-agent-mode=${this.getAttribute('allow-agent-mode')}`
242
- : '';
243
- }
244
-
245
- get allowAgentModeTests() {
246
- return this.hasAttribute('show-agent-mode-for-tests')
247
- ? 'show-agent-mode-for-tests'
248
- : '';
249
- }
250
-
251
- get title() {
252
- return this.hasAttribute('title')
253
- ? `title=${this.getAttribute('title')}`
254
- : '';
255
- }
256
-
257
- get documentCaptureModes() {
258
- return this.hasAttribute('document-capture-modes')
259
- ? `document-capture-modes='${this.getAttribute('document-capture-modes')}'`
260
- : '';
261
- }
262
-
263
- get disableImageTests() {
264
- return this.hasAttribute('disable-image-tests')
265
- ? 'disable-image-tests'
266
- : '';
267
- }
268
-
269
- get hideAttribution() {
270
- return this.hasAttribute('hide-attribution') ? 'hide-attribution' : '';
271
- }
272
-
273
- get hasThemeColor() {
274
- return (
275
- this.hasAttribute('theme-color') &&
276
- ![null, undefined, 'null', 'undefined'].includes(
277
- this.getAttribute('theme-color'),
278
- )
279
- );
280
- }
281
-
282
- get themeColor() {
283
- return this.hasThemeColor ? this.getAttribute('theme-color') : '#001096';
284
- }
285
-
286
- get applyComponentThemeColor() {
287
- return this.hasThemeColor ? `theme-color='${this.themeColor}'` : '';
288
- }
289
-
290
- setActiveScreen(screen) {
291
- this.activeScreen?.setAttribute('hidden', '');
292
- screen.removeAttribute('hidden');
293
- this.activeScreen = screen;
294
- }
295
-
296
- handleCloseEvent() {
297
- this.dispatchEvent(new CustomEvent('smart-camera-web.close'));
298
- }
299
- }
300
-
301
- if ('customElements' in window && !customElements.get('smart-camera-web')) {
302
- customElements.define('smart-camera-web', SmartCameraWeb);
303
- }
304
-
305
- export default SmartCameraWeb;
1
+ import styles from '../../../styles/src/styles';
2
+ import SmartCamera from '../../../domain/camera/src/SmartCamera';
3
+
4
+ import '../../document/src';
5
+ import '../../selfie/src';
6
+ import '../../camera-permission/CameraPermission';
7
+ import packageJson from '../../../../package.json';
8
+
9
+ const COMPONENTS_VERSION = packageJson.version;
10
+
11
+ function scwTemplateString() {
12
+ return `
13
+ <style>
14
+ :host {
15
+ display: block;
16
+ height: 100%;
17
+ }
18
+ </style>
19
+ ${styles(this.themeColor)}
20
+ <div style="height: 100%;">
21
+ <camera-permission ${this.applyComponentThemeColor} ${this.title} ${this.showNavigation} ${this.hideInstructions ? '' : 'hidden'} ${this.hideAttribution}></camera-permission>
22
+ <selfie-capture-screens ${this.applyComponentThemeColor} ${this.title} ${this.showNavigation} ${this.disableImageTests} ${this.hideAttribution} ${this.hideInstructions} hidden
23
+ ${this.hideBackToHost} ${this.allowAgentMode} ${this.allowAgentModeTests}
24
+ ></selfie-capture-screens>
25
+ <document-capture-screens ${this.applyComponentThemeColor} document-type=${this.documentType} ${this.title} ${this.documentCaptureModes} ${this.showNavigation} ${this.hideAttribution}
26
+ ${this.hideBackOfId} ${this.applyComponentThemeColor} hidden></document-capture-screens>
27
+ </div>
28
+ `;
29
+ }
30
+ class SmartCameraWeb extends HTMLElement {
31
+ constructor() {
32
+ super();
33
+ this.scwTemplateString = scwTemplateString.bind(this);
34
+ this.render = () => this.scwTemplateString();
35
+ this.attachShadow({ mode: 'open' });
36
+ this.activeScreen = null;
37
+ }
38
+
39
+ connectedCallback() {
40
+ this.shadowRoot.innerHTML = this.render();
41
+
42
+ this._data = {
43
+ images: [],
44
+ meta: {
45
+ libraryVersion: COMPONENTS_VERSION,
46
+ },
47
+ };
48
+
49
+ if (
50
+ 'mediaDevices' in navigator &&
51
+ 'getUserMedia' in navigator.mediaDevices
52
+ ) {
53
+ this.setUpEventListeners();
54
+ } else {
55
+ this.shadowRoot.innerHTML =
56
+ '<h1 class="error-message">Your browser does not support this integration</h1>';
57
+ }
58
+ }
59
+
60
+ disconnectedCallback() {
61
+ SmartCamera.stopMedia();
62
+ if (this.activeScreen) {
63
+ this.activeScreen.removeAttribute('hidden');
64
+ }
65
+ this.activeScreen = null;
66
+ this.shadowRoot.innerHTML = '';
67
+ }
68
+
69
+ static get observedAttributes() {
70
+ return [
71
+ 'allow-agent-mode',
72
+ 'disable-image-tests',
73
+ 'document-capture-modes',
74
+ 'document-type',
75
+ 'hide-attribution',
76
+ 'hide-back-of-id',
77
+ 'hide-back-to-host',
78
+ 'show-navigation',
79
+ 'theme-color',
80
+ ];
81
+ }
82
+
83
+ attributeChangedCallback(name) {
84
+ switch (name) {
85
+ case 'allow-agent-mode':
86
+ case 'disable-image-tests':
87
+ case 'document-capture-modes':
88
+ case 'document-type':
89
+ case 'hide-attribution':
90
+ case 'hide-back-of-id':
91
+ case 'hide-back-to-host':
92
+ case 'show-navigation':
93
+ case 'theme-color':
94
+ this.disconnectedCallback();
95
+ this.shadowRoot.innerHTML = this.render();
96
+ this.setUpEventListeners();
97
+ break;
98
+ default:
99
+ break;
100
+ }
101
+ }
102
+
103
+ setUpEventListeners() {
104
+ this.cameraPermission = this.shadowRoot.querySelector('camera-permission');
105
+ this.SelfieCaptureScreens = this.shadowRoot.querySelector(
106
+ 'selfie-capture-screens',
107
+ );
108
+ this.documentCapture = this.shadowRoot.querySelector(
109
+ 'document-capture-screens',
110
+ );
111
+
112
+ if (this.hideInstructions) {
113
+ this.setActiveScreen(this.cameraPermission);
114
+ } else {
115
+ this.setActiveScreen(this.SelfieCaptureScreens);
116
+ }
117
+ this.cameraPermission.addEventListener('camera-permission.granted', () => {
118
+ this.setActiveScreen(this.SelfieCaptureScreens);
119
+ this.SelfieCaptureScreens.removeAttribute('data-camera-error');
120
+ this.SelfieCaptureScreens.setAttribute('data-camera-ready', true);
121
+ });
122
+
123
+ this.SelfieCaptureScreens.addEventListener(
124
+ 'selfie-capture-screens.publish',
125
+ (event) => {
126
+ this._data.images = event.detail.images;
127
+ if (!this.captureId) {
128
+ this._publishSelectedImages();
129
+ } else {
130
+ this.setActiveScreen(this.documentCapture);
131
+ }
132
+ },
133
+ );
134
+
135
+ this.SelfieCaptureScreens.addEventListener(
136
+ 'selfie-capture-screens.cancelled',
137
+ () => {
138
+ if (this.hideInstructions) {
139
+ this.setActiveScreen(this.cameraPermission);
140
+ } else {
141
+ this.handleBackEvents();
142
+ }
143
+ },
144
+ );
145
+ this.SelfieCaptureScreens.addEventListener(
146
+ 'selfie-capture-screens.back',
147
+ () => {
148
+ if (!this.hideInstructions) {
149
+ this.setActiveScreen(this.cameraPermission);
150
+ }
151
+ },
152
+ );
153
+
154
+ this.documentCapture.addEventListener(
155
+ 'document-capture-screens.publish',
156
+ (event) => {
157
+ this._data.images = [...this._data.images, ...event.detail.images];
158
+ this._publishSelectedImages();
159
+ },
160
+ );
161
+
162
+ this.documentCapture.addEventListener(
163
+ 'document-capture-screens.cancelled',
164
+ () => {
165
+ this.SelfieCaptureScreens.setAttribute(
166
+ 'initial-screen',
167
+ 'selfie-capture',
168
+ );
169
+ this.setActiveScreen(this.SelfieCaptureScreens);
170
+ this.SelfieCaptureScreens.removeAttribute('data-camera-error');
171
+ this.SelfieCaptureScreens.setAttribute('data-camera-ready', true);
172
+ },
173
+ );
174
+
175
+ [
176
+ this.cameraPermission,
177
+ this.SelfieCaptureScreens,
178
+ this.documentCapture,
179
+ ].forEach((screen) => {
180
+ screen.addEventListener(`${screen.nodeName.toLowerCase()}.close`, () =>
181
+ this.handleCloseEvent(),
182
+ );
183
+ });
184
+ this.documentCapture.addEventListener(
185
+ 'document-capture-screens.back',
186
+ () => {
187
+ this.setActiveScreen(this.SelfieCaptureScreens);
188
+ this.reset();
189
+ },
190
+ );
191
+ }
192
+
193
+ reset() {
194
+ this.disconnectedCallback();
195
+ this.connectedCallback();
196
+ }
197
+
198
+ handleBackEvents() {
199
+ this.dispatchEvent(new CustomEvent('smart-camera-web.cancelled'));
200
+ }
201
+
202
+ _publishSelectedImages() {
203
+ this.dispatchEvent(
204
+ new CustomEvent('smart-camera-web.publish', { detail: this._data }),
205
+ );
206
+ }
207
+
208
+ get captureId() {
209
+ return this.hasAttribute('capture-id');
210
+ }
211
+
212
+ get documentType() {
213
+ return this.getAttribute('document-type');
214
+ }
215
+
216
+ get isPortraitCaptureView() {
217
+ return this.getAttribute('document-type') === 'GREEN_BOOK';
218
+ }
219
+
220
+ get hideInstructions() {
221
+ return this.hasAttribute('hide-instructions') ? 'hide-instructions' : '';
222
+ }
223
+
224
+ get hideBackOfId() {
225
+ return this.hasAttribute('hide-back-of-id') ? 'hide-back-of-id' : '';
226
+ }
227
+
228
+ get showNavigation() {
229
+ return this.hasAttribute('show-navigation') ? 'show-navigation' : '';
230
+ }
231
+
232
+ get hideBackToHost() {
233
+ return this.hasAttribute('hide-back-to-host') ||
234
+ this.hasAttribute('hide-back')
235
+ ? 'hide-back'
236
+ : '';
237
+ }
238
+
239
+ get allowAgentMode() {
240
+ return this.hasAttribute('allow-agent-mode')
241
+ ? `allow-agent-mode=${this.getAttribute('allow-agent-mode')}`
242
+ : '';
243
+ }
244
+
245
+ get allowAgentModeTests() {
246
+ return this.hasAttribute('show-agent-mode-for-tests')
247
+ ? 'show-agent-mode-for-tests'
248
+ : '';
249
+ }
250
+
251
+ get title() {
252
+ return this.hasAttribute('title')
253
+ ? `title=${this.getAttribute('title')}`
254
+ : '';
255
+ }
256
+
257
+ get documentCaptureModes() {
258
+ return this.hasAttribute('document-capture-modes')
259
+ ? `document-capture-modes='${this.getAttribute('document-capture-modes')}'`
260
+ : '';
261
+ }
262
+
263
+ get disableImageTests() {
264
+ return this.hasAttribute('disable-image-tests')
265
+ ? 'disable-image-tests'
266
+ : '';
267
+ }
268
+
269
+ get hideAttribution() {
270
+ return this.hasAttribute('hide-attribution') ? 'hide-attribution' : '';
271
+ }
272
+
273
+ get hasThemeColor() {
274
+ return (
275
+ this.hasAttribute('theme-color') &&
276
+ ![null, undefined, 'null', 'undefined'].includes(
277
+ this.getAttribute('theme-color'),
278
+ )
279
+ );
280
+ }
281
+
282
+ get themeColor() {
283
+ return this.hasThemeColor ? this.getAttribute('theme-color') : '#001096';
284
+ }
285
+
286
+ get applyComponentThemeColor() {
287
+ return this.hasThemeColor ? `theme-color='${this.themeColor}'` : '';
288
+ }
289
+
290
+ setActiveScreen(screen) {
291
+ this.activeScreen?.setAttribute('hidden', '');
292
+ screen.removeAttribute('hidden');
293
+ this.activeScreen = screen;
294
+ }
295
+
296
+ handleCloseEvent() {
297
+ this.dispatchEvent(new CustomEvent('smart-camera-web.close'));
298
+ }
299
+ }
300
+
301
+ if ('customElements' in window && !customElements.get('smart-camera-web')) {
302
+ customElements.define('smart-camera-web', SmartCameraWeb);
303
+ }
304
+
305
+ export default SmartCameraWeb;