@smileid/web-components 1.4.7 → 1.5.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.
@@ -1,356 +1,409 @@
1
- import { IMAGE_TYPE } from '../../../domain/constants/src/Constants';
2
- import styles from '../../../styles/src/styles';
3
- import SmartCamera from '../../../domain/camera/src/SmartCamera';
4
-
5
- import './document-capture';
6
- import './document-capture-review';
7
- import './document-capture-instructions';
8
- import packageJson from '../../../package.json';
9
-
10
- const COMPONENTS_VERSION = packageJson.version;
11
-
12
- async function getPermissions(captureScreen) {
13
- try {
14
- await SmartCamera.getMedia({
15
- audio: false,
16
- video: SmartCamera.environmentOptions,
17
- });
18
- captureScreen.removeAttribute('data-camera-error');
19
- captureScreen.setAttribute('data-camera-ready', true);
20
- } catch (error) {
21
- captureScreen.removeAttribute('data-camera-ready');
22
- captureScreen.setAttribute(
23
- 'data-camera-error',
24
- SmartCamera.handleCameraError(error),
25
- );
26
- }
27
- }
28
-
29
- class DocumentCaptureScreens extends HTMLElement {
30
- constructor() {
31
- super();
32
- this.activeScreen = null;
33
- }
34
-
35
- connectedCallback() {
36
- this.innerHTML = `
37
- ${styles(this.themeColor)}
38
- <div>
39
- <document-capture-instructions theme-color='${this.themeColor}' id='document-capture-instructions-front' ${this.title}
40
- ${this.documentCaptureModes} ${this.showNavigation} ${this.hideInstructions ? 'hidden' : ''}
41
- ${this.hideAttribution}
42
- ></document-capture-instructions>
43
- <document-capture id='document-capture-front' side-of-id='Front'
44
- ${this.title} ${this.showNavigation} ${this.hideInstructions ? '' : 'hidden'} ${this.hideAttribution}
45
- ${this.documentCaptureModes} ${this.documentType} theme-color='${this.themeColor}'
46
- ></document-capture>
47
- <document-capture-instructions id='document-capture-instructions-back' side-of-id='Back' title='Submit Back of ID'
48
- ${this.documentCaptureModes} ${this.showNavigation} theme-color='${this.themeColor}' ${this.hideAttribution} hidden
49
- ></document-capture-instructions>
50
- <document-capture id='document-capture-back' side-of-id='Back' ${this.title} ${this.showNavigation}
51
- ${this.documentCaptureModes} theme-color='${this.themeColor}' ${this.hideAttribution}
52
- hidden
53
- ></document-capture>
54
- <document-capture-review id='front-of-document-capture-review' theme-color='${this.themeColor}' ${this.hideAttribution} hidden></document-capture-review>
55
- <document-capture-review id='back-of-document-capture-review' theme-color='${this.themeColor}' ${this.hideAttribution} hidden></document-capture-review>
56
- </div>
57
- `;
58
-
59
- this._data = {
60
- images: [],
61
- meta: {
62
- libraryVersion: COMPONENTS_VERSION,
63
- },
64
- };
65
-
66
- this.documentInstruction = this.querySelector(
67
- 'document-capture-instructions',
68
- );
69
- this.documentInstructionBack = this.querySelector(
70
- '#document-capture-instructions-back',
71
- );
72
- this.idCapture = this.querySelector('#document-capture-front');
73
- this.idReview = this.querySelector('#front-of-document-capture-review');
74
- this.idCaptureBack = this.querySelector('#document-capture-back');
75
- this.backOfIdReview = this.querySelector(
76
- '#back-of-document-capture-review',
77
- );
78
- this.thankYouScreen = this.querySelector('thank-you');
79
-
80
- if (this.hideInstructions) {
81
- getPermissions(this.idCapture);
82
- this.setActiveScreen(this.idCapture);
83
- } else {
84
- this.setActiveScreen(this.documentInstruction);
85
- }
86
-
87
- this.setUpEventListeners();
88
- }
89
-
90
- disconnectedCallback() {
91
- SmartCamera.stopMedia();
92
- if (this.activeScreen) {
93
- this.activeScreen.removeAttribute('hidden');
94
- }
95
- this.activeScreen = null;
96
- this.innerHTML = '';
97
- }
98
-
99
- setUpEventListeners() {
100
- this.documentInstruction.addEventListener(
101
- 'document-capture-instructions.cancelled',
102
- () => {
103
- this.handleBackEvents();
104
- },
105
- );
106
-
107
- this.documentInstruction.addEventListener(
108
- 'document-capture-instructions.capture',
109
- async () => {
110
- this.setActiveScreen(this.idCapture);
111
- await getPermissions(this.idCapture);
112
- },
113
- );
114
- this.documentInstruction.addEventListener(
115
- 'document-capture-instructions.upload',
116
- async (event) => {
117
- this.idReview.setAttribute('data-image', event.detail.previewImage);
118
- this._data.images.push({
119
- image: event.detail.image.split(',')[1],
120
- image_type_id: IMAGE_TYPE.ID_CARD_IMAGE_BASE64,
121
- });
122
- this.setActiveScreen(this.idReview);
123
- },
124
- );
125
-
126
- this.idCapture.addEventListener('document-capture.publish', (event) => {
127
- this.idReview.setAttribute('data-image', event.detail.previewImage);
128
- this._data.images.push({
129
- image: event.detail.image.split(',')[1],
130
- image_type_id: IMAGE_TYPE.ID_CARD_IMAGE_BASE64,
131
- });
132
- SmartCamera.stopMedia();
133
- this.setActiveScreen(this.idReview);
134
- });
135
-
136
- this.idCapture.addEventListener('document-capture.cancelled', () => {
137
- if (this.hideInstructions) {
138
- this.handleBackEvents();
139
- } else {
140
- this.setActiveScreen(this.documentInstruction);
141
- }
142
- });
143
-
144
- this.idReview.addEventListener(
145
- 'document-capture-review.rejected',
146
- async () => {
147
- this.idReview.removeAttribute('data-image');
148
- this._data.images.pop();
149
- if (this.hideInstructions) {
150
- this.setActiveScreen(this.idCapture);
151
- await getPermissions(this.idCapture);
152
- } else {
153
- this.setActiveScreen(this.documentInstruction);
154
- }
155
- },
156
- );
157
-
158
- this.idReview.addEventListener(
159
- 'document-capture-review.accepted',
160
- async () => {
161
- if (this.hideBackOfId) {
162
- this._publishSelectedImages();
163
- } else if (this.hideInstructions) {
164
- this.setActiveScreen(this.idCaptureBack);
165
- await getPermissions(this.idCaptureBack);
166
- } else {
167
- this.setActiveScreen(this.documentInstructionBack);
168
- }
169
- },
170
- );
171
-
172
- this.documentInstructionBack.addEventListener(
173
- 'document-capture-instructions.capture',
174
- async () => {
175
- this.setActiveScreen(this.idCaptureBack);
176
- await getPermissions(this.idCaptureBack);
177
- },
178
- );
179
-
180
- this.documentInstructionBack.addEventListener(
181
- 'document-capture-instructions.cancelled',
182
- async () => {
183
- this.idReview.removeAttribute('data-image');
184
- this._data.images.pop();
185
- if (this.hideInstructions) {
186
- this.setActiveScreen(this.idCapture);
187
- await getPermissions(this.idCapture);
188
- } else {
189
- this.setActiveScreen(this.documentInstruction);
190
- }
191
- },
192
- );
193
-
194
- this.documentInstructionBack.addEventListener(
195
- 'document-capture-instructions.upload',
196
- async (event) => {
197
- this.backOfIdReview.setAttribute('data-image', event.detail.image);
198
- this._data.images.push({
199
- image: event.detail.image.split(',')[1],
200
- image_type_id: IMAGE_TYPE.ID_CARD_BACK_IMAGE_BASE64,
201
- });
202
- this.setActiveScreen(this.backOfIdReview);
203
- },
204
- );
205
- this.idCaptureBack.addEventListener('document-capture.publish', (event) => {
206
- this.backOfIdReview.setAttribute('data-image', event.detail.previewImage);
207
- this._data.images.push({
208
- image: event.detail.image.split(',')[1],
209
- image_type_id: IMAGE_TYPE.ID_CARD_BACK_IMAGE_BASE64,
210
- });
211
- this.setActiveScreen(this.backOfIdReview);
212
- SmartCamera.stopMedia();
213
- });
214
-
215
- this.idCaptureBack.addEventListener(
216
- 'document-capture.cancelled',
217
- async () => {
218
- if (this.hideInstructions) {
219
- this.setActiveScreen(this.idCapture);
220
- await getPermissions(this.idCapture);
221
- } else {
222
- this.setActiveScreen(this.documentInstructionBack);
223
- }
224
- },
225
- );
226
-
227
- this.backOfIdReview.addEventListener(
228
- 'document-capture-review.rejected',
229
- async () => {
230
- this.backOfIdReview.removeAttribute('data-image');
231
- this._data.images.pop();
232
- if (this.hideInstructions) {
233
- this.setActiveScreen(this.idCaptureBack);
234
- await getPermissions(this.idCaptureBack);
235
- } else {
236
- this.setActiveScreen(this.documentInstructionBack);
237
- }
238
- },
239
- );
240
-
241
- this.backOfIdReview.addEventListener(
242
- 'document-capture-review.accepted',
243
- () => {
244
- this._publishSelectedImages();
245
- },
246
- );
247
-
248
- const screens = [
249
- this.documentInstruction,
250
- this.idCapture,
251
- this.documentInstructionBack,
252
- this.idCaptureBack,
253
- this.idReview,
254
- this.backOfIdReview,
255
- ];
256
-
257
- screens.forEach((screen) => {
258
- screen.addEventListener(`${screen.nodeName.toLowerCase()}.close`, () =>
259
- this.handleCloseEvents(),
260
- );
261
- });
262
- }
263
-
264
- _publishSelectedImages() {
265
- this.dispatchEvent(
266
- new CustomEvent('document-capture-screens.publish', {
267
- detail: this._data,
268
- }),
269
- );
270
- }
271
-
272
- get hideInstructions() {
273
- return this.hasAttribute('hide-instructions');
274
- }
275
-
276
- get hideBackOfId() {
277
- return this.hasAttribute('hide-back-of-id');
278
- }
279
-
280
- get showNavigation() {
281
- return this.hasAttribute('show-navigation') ? 'show-navigation' : '';
282
- }
283
-
284
- get title() {
285
- return this.hasAttribute('title')
286
- ? `title=${this.getAttribute('title')}`
287
- : '';
288
- }
289
-
290
- get documentCaptureModes() {
291
- return this.hasAttribute('document-capture-modes')
292
- ? `document-capture-modes='${this.getAttribute('document-capture-modes')}'`
293
- : '';
294
- }
295
-
296
- get documentType() {
297
- return this.hasAttribute('document-type')
298
- ? `document-type='${this.getAttribute('document-type')}'`
299
- : '';
300
- }
301
-
302
- get hideAttribution() {
303
- return this.hasAttribute('hide-attribution') ? 'hide-attribution' : '';
304
- }
305
-
306
- get themeColor() {
307
- return this.getAttribute('theme-color') || '#001096';
308
- }
309
-
310
- handleBackEvents() {
311
- this.dispatchEvent(new CustomEvent('document-capture-screens.cancelled'));
312
- }
313
-
314
- handleCloseEvents() {
315
- this.dispatchEvent(new CustomEvent('document-capture-screens.close'));
316
- }
317
-
318
- setActiveScreen(screen) {
319
- this.activeScreen?.setAttribute('hidden', '');
320
- screen.removeAttribute('hidden');
321
- this.activeScreen = screen;
322
- }
323
-
324
- static get observedAttributes() {
325
- return [
326
- 'document-capture-modes',
327
- 'document-type',
328
- 'hide-back-to-host',
329
- 'show-navigation',
330
- 'hide-back-of-id',
331
- ];
332
- }
333
-
334
- attributeChangedCallback(name) {
335
- switch (name) {
336
- case 'document-capture-modes':
337
- case 'document-type':
338
- case 'hide-back-of-id':
339
- case 'hide-back-to-host':
340
- case 'show-navigation':
341
- this.connectedCallback();
342
- break;
343
- default:
344
- break;
345
- }
346
- }
347
- }
348
-
349
- if (
350
- 'customElements' in window &&
351
- !customElements.get('document-capture-screens')
352
- ) {
353
- customElements.define('document-capture-screens', DocumentCaptureScreens);
354
- }
355
-
356
- export default DocumentCaptureScreens;
1
+ import { IMAGE_TYPE } from '../../../domain/constants/src/Constants';
2
+ import styles from '../../../styles/src/styles';
3
+ import SmartCamera from '../../../domain/camera/src/SmartCamera';
4
+
5
+ import './document-capture';
6
+ import './document-capture-review';
7
+ import './document-capture-instructions';
8
+ import packageJson from '../../../package.json';
9
+
10
+ const COMPONENTS_VERSION = packageJson.version;
11
+
12
+ const smartCameraWeb = document.querySelector('smart-camera-web');
13
+
14
+ async function getPermissions(captureScreen) {
15
+ try {
16
+ const stream = await SmartCamera.getMedia({
17
+ audio: false,
18
+ video: SmartCamera.environmentOptions,
19
+ });
20
+ const devices = await navigator.mediaDevices.enumerateDevices();
21
+ const videoDevice = devices.find(
22
+ (device) =>
23
+ device.kind === 'videoinput' &&
24
+ stream.getVideoTracks()[0].getSettings().deviceId === device.deviceId,
25
+ );
26
+ smartCameraWeb?.dispatchEvent(
27
+ new CustomEvent('metadata.camera-name', {
28
+ detail: { cameraName: videoDevice?.label },
29
+ }),
30
+ );
31
+ captureScreen.removeAttribute('data-camera-error');
32
+ captureScreen.setAttribute('data-camera-ready', true);
33
+ } catch (error) {
34
+ captureScreen.removeAttribute('data-camera-ready');
35
+ captureScreen.setAttribute(
36
+ 'data-camera-error',
37
+ SmartCamera.handleCameraError(error),
38
+ );
39
+ }
40
+ }
41
+
42
+ class DocumentCaptureScreens extends HTMLElement {
43
+ constructor() {
44
+ super();
45
+ this.activeScreen = null;
46
+ this.smartCameraWeb = this.closest('smart-camera-web');
47
+ smartCameraWeb?.dispatchEvent(new CustomEvent('metadata.initialize'));
48
+ }
49
+
50
+ connectedCallback() {
51
+ this.innerHTML = `
52
+ ${styles(this.themeColor)}
53
+ <div>
54
+ <document-capture-instructions theme-color='${this.themeColor}' id='document-capture-instructions-front' ${this.title}
55
+ ${this.documentCaptureModes} ${this.showNavigation} ${this.hideInstructions ? 'hidden' : ''}
56
+ ${this.hideAttribution}
57
+ ></document-capture-instructions>
58
+ <document-capture id='document-capture-front' side-of-id='Front'
59
+ ${this.title} ${this.showNavigation} ${this.hideInstructions ? '' : 'hidden'} ${this.hideAttribution}
60
+ ${this.documentCaptureModes} ${this.documentType} theme-color='${this.themeColor}'
61
+ ></document-capture>
62
+ <document-capture-instructions id='document-capture-instructions-back' side-of-id='Back' title='Submit Back of ID'
63
+ ${this.documentCaptureModes} ${this.showNavigation} theme-color='${this.themeColor}' ${this.hideAttribution} hidden
64
+ ></document-capture-instructions>
65
+ <document-capture id='document-capture-back' side-of-id='Back' ${this.title} ${this.showNavigation}
66
+ ${this.documentCaptureModes} theme-color='${this.themeColor}' ${this.hideAttribution}
67
+ hidden
68
+ ></document-capture>
69
+ <document-capture-review id='front-of-document-capture-review' theme-color='${this.themeColor}' ${this.hideAttribution} hidden></document-capture-review>
70
+ <document-capture-review id='back-of-document-capture-review' theme-color='${this.themeColor}' ${this.hideAttribution} hidden></document-capture-review>
71
+ </div>
72
+ `;
73
+
74
+ this._data = {
75
+ images: [],
76
+ meta: {
77
+ libraryVersion: COMPONENTS_VERSION,
78
+ },
79
+ };
80
+
81
+ this.documentInstruction = this.querySelector(
82
+ 'document-capture-instructions',
83
+ );
84
+ this.documentInstructionBack = this.querySelector(
85
+ '#document-capture-instructions-back',
86
+ );
87
+ this.idCapture = this.querySelector('#document-capture-front');
88
+ this.idReview = this.querySelector('#front-of-document-capture-review');
89
+ this.idCaptureBack = this.querySelector('#document-capture-back');
90
+ this.backOfIdReview = this.querySelector(
91
+ '#back-of-document-capture-review',
92
+ );
93
+ this.thankYouScreen = this.querySelector('thank-you');
94
+
95
+ if (this.hideInstructions) {
96
+ getPermissions(this.idCapture);
97
+ this.setActiveScreen(this.idCapture);
98
+ } else {
99
+ this.setActiveScreen(this.documentInstruction);
100
+ }
101
+
102
+ this.setUpEventListeners();
103
+ }
104
+
105
+ disconnectedCallback() {
106
+ SmartCamera.stopMedia();
107
+ if (this.activeScreen) {
108
+ this.activeScreen.removeAttribute('hidden');
109
+ }
110
+ this.activeScreen = null;
111
+ this.innerHTML = '';
112
+ }
113
+
114
+ setUpEventListeners() {
115
+ this.documentInstruction.addEventListener(
116
+ 'document-capture-instructions.cancelled',
117
+ () => {
118
+ this.handleBackEvents();
119
+ },
120
+ );
121
+
122
+ this.documentInstruction.addEventListener(
123
+ 'document-capture-instructions.capture',
124
+ async () => {
125
+ smartCameraWeb?.dispatchEvent(
126
+ new CustomEvent('metadata.document-front-capture-start'),
127
+ );
128
+ smartCameraWeb?.dispatchEvent(
129
+ new CustomEvent('metadata.document-front-origin', {
130
+ detail: { imageOrigin: 'camera_manual_capture' },
131
+ }),
132
+ );
133
+ this.setActiveScreen(this.idCapture);
134
+ await getPermissions(this.idCapture);
135
+ },
136
+ );
137
+ this.documentInstruction.addEventListener(
138
+ 'document-capture-instructions.upload',
139
+ async (event) => {
140
+ smartCameraWeb?.dispatchEvent(
141
+ new CustomEvent('metadata.document-front-origin', {
142
+ detail: { imageOrigin: 'gallery' },
143
+ }),
144
+ );
145
+ this.idReview.setAttribute('data-image', event.detail.previewImage);
146
+ this._data.images.push({
147
+ image: event.detail.image.split(',')[1],
148
+ image_type_id: IMAGE_TYPE.ID_CARD_IMAGE_BASE64,
149
+ });
150
+ this.setActiveScreen(this.idReview);
151
+ },
152
+ );
153
+
154
+ this.idCapture.addEventListener('document-capture.publish', (event) => {
155
+ smartCameraWeb?.dispatchEvent(
156
+ new CustomEvent('metadata.document-front-capture-end'),
157
+ );
158
+ this.idReview.setAttribute('data-image', event.detail.previewImage);
159
+ this._data.images.push({
160
+ image: event.detail.image.split(',')[1],
161
+ image_type_id: IMAGE_TYPE.ID_CARD_IMAGE_BASE64,
162
+ });
163
+ SmartCamera.stopMedia();
164
+ this.setActiveScreen(this.idReview);
165
+ });
166
+
167
+ this.idCapture.addEventListener('document-capture.cancelled', () => {
168
+ if (this.hideInstructions) {
169
+ this.handleBackEvents();
170
+ } else {
171
+ this.setActiveScreen(this.documentInstruction);
172
+ }
173
+ });
174
+
175
+ this.idReview.addEventListener(
176
+ 'document-capture-review.rejected',
177
+ async () => {
178
+ smartCameraWeb?.dispatchEvent(
179
+ new CustomEvent('metadata.document-front-capture-retry'),
180
+ );
181
+ this.idReview.removeAttribute('data-image');
182
+ this._data.images.pop();
183
+ if (this.hideInstructions) {
184
+ this.setActiveScreen(this.idCapture);
185
+ await getPermissions(this.idCapture);
186
+ } else {
187
+ this.setActiveScreen(this.documentInstruction);
188
+ }
189
+ },
190
+ );
191
+
192
+ this.idReview.addEventListener(
193
+ 'document-capture-review.accepted',
194
+ async () => {
195
+ if (this.hideBackOfId) {
196
+ this._publishSelectedImages();
197
+ } else if (this.hideInstructions) {
198
+ this.setActiveScreen(this.idCaptureBack);
199
+ await getPermissions(this.idCaptureBack);
200
+ } else {
201
+ this.setActiveScreen(this.documentInstructionBack);
202
+ }
203
+ },
204
+ );
205
+
206
+ this.documentInstructionBack.addEventListener(
207
+ 'document-capture-instructions.capture',
208
+ async () => {
209
+ smartCameraWeb?.dispatchEvent(
210
+ new CustomEvent('metadata.document-back-capture-start'),
211
+ );
212
+ smartCameraWeb?.dispatchEvent(
213
+ new CustomEvent('metadata.document-back-origin', {
214
+ detail: { imageOrigin: 'camera_manual_capture' },
215
+ }),
216
+ );
217
+ this.setActiveScreen(this.idCaptureBack);
218
+ await getPermissions(this.idCaptureBack);
219
+ },
220
+ );
221
+
222
+ this.documentInstructionBack.addEventListener(
223
+ 'document-capture-instructions.cancelled',
224
+ async () => {
225
+ this.idReview.removeAttribute('data-image');
226
+ this._data.images.pop();
227
+ if (this.hideInstructions) {
228
+ this.setActiveScreen(this.idCapture);
229
+ await getPermissions(this.idCapture);
230
+ } else {
231
+ this.setActiveScreen(this.documentInstruction);
232
+ }
233
+ },
234
+ );
235
+
236
+ this.documentInstructionBack.addEventListener(
237
+ 'document-capture-instructions.upload',
238
+ async (event) => {
239
+ smartCameraWeb?.dispatchEvent(
240
+ new CustomEvent('metadata.document-back-origin', {
241
+ detail: { imageOrigin: 'gallery' },
242
+ }),
243
+ );
244
+ this.backOfIdReview.setAttribute('data-image', event.detail.image);
245
+ this._data.images.push({
246
+ image: event.detail.image.split(',')[1],
247
+ image_type_id: IMAGE_TYPE.ID_CARD_BACK_IMAGE_BASE64,
248
+ });
249
+ this.setActiveScreen(this.backOfIdReview);
250
+ },
251
+ );
252
+ this.idCaptureBack.addEventListener('document-capture.publish', (event) => {
253
+ smartCameraWeb?.dispatchEvent(
254
+ new CustomEvent('metadata.document-back-capture-end'),
255
+ );
256
+ this.backOfIdReview.setAttribute('data-image', event.detail.previewImage);
257
+ this._data.images.push({
258
+ image: event.detail.image.split(',')[1],
259
+ image_type_id: IMAGE_TYPE.ID_CARD_BACK_IMAGE_BASE64,
260
+ });
261
+ this.setActiveScreen(this.backOfIdReview);
262
+ SmartCamera.stopMedia();
263
+ });
264
+
265
+ this.idCaptureBack.addEventListener(
266
+ 'document-capture.cancelled',
267
+ async () => {
268
+ if (this.hideInstructions) {
269
+ this.setActiveScreen(this.idCapture);
270
+ await getPermissions(this.idCapture);
271
+ } else {
272
+ this.setActiveScreen(this.documentInstructionBack);
273
+ }
274
+ },
275
+ );
276
+
277
+ this.backOfIdReview.addEventListener(
278
+ 'document-capture-review.rejected',
279
+ async () => {
280
+ smartCameraWeb?.dispatchEvent(
281
+ new CustomEvent('metadata.document-back-capture-retry'),
282
+ );
283
+ this.backOfIdReview.removeAttribute('data-image');
284
+ this._data.images.pop();
285
+ if (this.hideInstructions) {
286
+ this.setActiveScreen(this.idCaptureBack);
287
+ await getPermissions(this.idCaptureBack);
288
+ } else {
289
+ this.setActiveScreen(this.documentInstructionBack);
290
+ }
291
+ },
292
+ );
293
+
294
+ this.backOfIdReview.addEventListener(
295
+ 'document-capture-review.accepted',
296
+ () => {
297
+ this._publishSelectedImages();
298
+ },
299
+ );
300
+
301
+ const screens = [
302
+ this.documentInstruction,
303
+ this.idCapture,
304
+ this.documentInstructionBack,
305
+ this.idCaptureBack,
306
+ this.idReview,
307
+ this.backOfIdReview,
308
+ ];
309
+
310
+ screens.forEach((screen) => {
311
+ screen.addEventListener(`${screen.nodeName.toLowerCase()}.close`, () =>
312
+ this.handleCloseEvents(),
313
+ );
314
+ });
315
+ }
316
+
317
+ _publishSelectedImages() {
318
+ this.dispatchEvent(
319
+ new CustomEvent('document-capture-screens.publish', {
320
+ detail: this._data,
321
+ }),
322
+ );
323
+ }
324
+
325
+ get hideInstructions() {
326
+ return this.hasAttribute('hide-instructions');
327
+ }
328
+
329
+ get hideBackOfId() {
330
+ return this.hasAttribute('hide-back-of-id');
331
+ }
332
+
333
+ get showNavigation() {
334
+ return this.hasAttribute('show-navigation') ? 'show-navigation' : '';
335
+ }
336
+
337
+ get title() {
338
+ return this.hasAttribute('title')
339
+ ? `title=${this.getAttribute('title')}`
340
+ : '';
341
+ }
342
+
343
+ get documentCaptureModes() {
344
+ return this.hasAttribute('document-capture-modes')
345
+ ? `document-capture-modes='${this.getAttribute('document-capture-modes')}'`
346
+ : '';
347
+ }
348
+
349
+ get documentType() {
350
+ return this.hasAttribute('document-type')
351
+ ? `document-type='${this.getAttribute('document-type')}'`
352
+ : '';
353
+ }
354
+
355
+ get hideAttribution() {
356
+ return this.hasAttribute('hide-attribution') ? 'hide-attribution' : '';
357
+ }
358
+
359
+ get themeColor() {
360
+ return this.getAttribute('theme-color') || '#001096';
361
+ }
362
+
363
+ handleBackEvents() {
364
+ this.dispatchEvent(new CustomEvent('document-capture-screens.cancelled'));
365
+ }
366
+
367
+ handleCloseEvents() {
368
+ this.dispatchEvent(new CustomEvent('document-capture-screens.close'));
369
+ }
370
+
371
+ setActiveScreen(screen) {
372
+ this.activeScreen?.setAttribute('hidden', '');
373
+ screen.removeAttribute('hidden');
374
+ this.activeScreen = screen;
375
+ }
376
+
377
+ static get observedAttributes() {
378
+ return [
379
+ 'document-capture-modes',
380
+ 'document-type',
381
+ 'hide-back-to-host',
382
+ 'show-navigation',
383
+ 'hide-back-of-id',
384
+ ];
385
+ }
386
+
387
+ attributeChangedCallback(name) {
388
+ switch (name) {
389
+ case 'document-capture-modes':
390
+ case 'document-type':
391
+ case 'hide-back-of-id':
392
+ case 'hide-back-to-host':
393
+ case 'show-navigation':
394
+ this.connectedCallback();
395
+ break;
396
+ default:
397
+ break;
398
+ }
399
+ }
400
+ }
401
+
402
+ if (
403
+ 'customElements' in window &&
404
+ !customElements.get('document-capture-screens')
405
+ ) {
406
+ customElements.define('document-capture-screens', DocumentCaptureScreens);
407
+ }
408
+
409
+ export default DocumentCaptureScreens;