@smileid/web-components 11.0.3 → 11.1.0

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 (92) hide show
  1. package/README.md +61 -0
  2. package/dist/components/smart-camera-web/src/README.md +0 -1
  3. package/dist/esm/{DocumentCaptureScreens-C5BhNB-0.js → DocumentCaptureScreens-DHAfE8VG.js} +191 -185
  4. package/dist/esm/DocumentCaptureScreens-DHAfE8VG.js.map +1 -0
  5. package/dist/esm/{EndUserConsent-D4fd1ovG.js → EndUserConsent-DE6OBSGG.js} +65 -63
  6. package/dist/esm/EndUserConsent-DE6OBSGG.js.map +1 -0
  7. package/dist/esm/{Navigation-CTjK6tLU.js → Navigation-kjll5SgE.js} +17 -9
  8. package/dist/esm/Navigation-kjll5SgE.js.map +1 -0
  9. package/dist/esm/{SelfieCaptureScreens-KoQpCxtc.js → SelfieCaptureScreens-DaREKFi4.js} +3087 -3159
  10. package/dist/esm/SelfieCaptureScreens-DaREKFi4.js.map +1 -0
  11. package/dist/esm/{TotpConsent-CQU5jQi4.js → TotpConsent-DsMJhXD8.js} +13 -9
  12. package/dist/esm/TotpConsent-DsMJhXD8.js.map +1 -0
  13. package/dist/esm/combobox.js +20 -19
  14. package/dist/esm/combobox.js.map +1 -1
  15. package/dist/esm/document.js +1 -1
  16. package/dist/esm/end-user-consent.js +1 -1
  17. package/dist/esm/index-LJce6hoU.js +1360 -0
  18. package/dist/esm/index-LJce6hoU.js.map +1 -0
  19. package/dist/esm/localisation.js +21 -0
  20. package/dist/esm/localisation.js.map +1 -0
  21. package/dist/esm/main.js +34 -17
  22. package/dist/esm/main.js.map +1 -1
  23. package/dist/esm/navigation.js +1 -1
  24. package/dist/esm/{package-B-UwEdv7.js → package-BoRHLVSv.js} +25 -40
  25. package/dist/esm/package-BoRHLVSv.js.map +1 -0
  26. package/dist/esm/selfie.js +1 -1
  27. package/dist/esm/smart-camera-web.js +22 -18
  28. package/dist/esm/smart-camera-web.js.map +1 -1
  29. package/dist/esm/totp-consent.js +1 -1
  30. package/dist/smart-camera-web.js +136 -152
  31. package/dist/smart-camera-web.js.map +1 -1
  32. package/dist/src/components/combobox/src/index.js +424 -1
  33. package/dist/src/components/document/src/index.js +1422 -1
  34. package/dist/src/components/end-user-consent/src/index.js +1573 -1
  35. package/dist/src/components/selfie/src/index.js +1220 -1
  36. package/dist/src/components/signature-pad/src/index.js +787 -1
  37. package/dist/src/components/smart-camera-web/src/SmartCameraWeb.js +2753 -1
  38. package/dist/src/components/totp-consent/src/index.js +1292 -1
  39. package/dist/types/combobox.d.ts +2 -2
  40. package/dist/types/document.d.ts +2 -2
  41. package/dist/types/end-user-consent.d.ts +2 -2
  42. package/dist/types/locale.d.ts +19 -0
  43. package/dist/types/localisation.d.ts +21 -0
  44. package/dist/types/main.d.ts +35 -26
  45. package/dist/types/navigation.d.ts +2 -2
  46. package/dist/types/selfie.d.ts +2 -2
  47. package/dist/types/signature-pad.d.ts +2 -2
  48. package/dist/types/smart-camera-web.d.ts +2 -2
  49. package/dist/types/totp-consent.d.ts +2 -2
  50. package/lib/components/camera-permission/CameraPermission.js +8 -3
  51. package/lib/components/combobox/src/Combobox.js +4 -2
  52. package/lib/components/document/src/DocumentCaptureScreens.js +4 -3
  53. package/lib/components/document/src/DocumentCaptureScreens.stories.js +37 -13
  54. package/lib/components/document/src/document-capture/DocumentCapture.js +20 -14
  55. package/lib/components/document/src/document-capture/DocumentCapture.stories.js +11 -2
  56. package/lib/components/document/src/document-capture-instructions/DocumentCaptureInstructions.js +16 -11
  57. package/lib/components/document/src/document-capture-instructions/DocumentCaptureInstructions.stories.js +14 -5
  58. package/lib/components/document/src/document-capture-review/DocumentCaptureReview.js +11 -7
  59. package/lib/components/document/src/document-capture-review/DocumentCaptureReview.stories.js +14 -5
  60. package/lib/components/end-user-consent/src/EndUserConsent.js +30 -29
  61. package/lib/components/end-user-consent/src/EndUserConsent.stories.js +12 -2
  62. package/lib/components/navigation/src/Navigation.js +15 -2
  63. package/lib/components/navigation/src/Navigation.stories.js +20 -4
  64. package/lib/components/selfie/src/SelfieCaptureScreens.js +3 -7
  65. package/lib/components/selfie/src/SelfieCaptureScreens.stories.js +16 -4
  66. package/lib/components/selfie/src/selfie-capture/SelfieCapture.js +23 -16
  67. package/lib/components/selfie/src/selfie-capture/SelfieCapture.stories.js +19 -7
  68. package/lib/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.js +16 -11
  69. package/lib/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.stories.js +14 -5
  70. package/lib/components/selfie/src/selfie-capture-review/SelfieCaptureReview.js +10 -5
  71. package/lib/components/selfie/src/selfie-capture-review/SelfieCaptureReview.stories.js +14 -5
  72. package/lib/components/selfie/src/selfie-capture-wrapper/SelfieCaptureWrapper.tsx +2 -2
  73. package/lib/components/selfie/src/smartselfie-capture/SmartSelfieCapture.stories.js +47 -0
  74. package/lib/components/selfie/src/smartselfie-capture/SmartSelfieCapture.tsx +2 -2
  75. package/lib/components/selfie/src/smartselfie-capture/components/CaptureControls.tsx +5 -2
  76. package/lib/components/selfie/src/smartselfie-capture/hooks/useCamera.ts +4 -4
  77. package/lib/components/selfie/src/smartselfie-capture/hooks/useFaceCapture.ts +6 -5
  78. package/lib/components/selfie/src/smartselfie-capture/utils/alertMessages.ts +11 -9
  79. package/lib/components/selfie/src/smartselfie-capture/utils/imageCapture.ts +3 -1
  80. package/lib/components/signature-pad/package.json +1 -1
  81. package/lib/components/totp-consent/src/TotpConsent.js +8 -3
  82. package/lib/domain/camera/src/SmartCamera.js +7 -22
  83. package/lib/domain/constants/src/Constants.js +28 -0
  84. package/lib/domain/file-upload/src/SmartFileUpload.js +9 -10
  85. package/lib/domain/localisation/index.js +456 -0
  86. package/package.json +12 -6
  87. package/dist/esm/DocumentCaptureScreens-C5BhNB-0.js.map +0 -1
  88. package/dist/esm/EndUserConsent-D4fd1ovG.js.map +0 -1
  89. package/dist/esm/Navigation-CTjK6tLU.js.map +0 -1
  90. package/dist/esm/SelfieCaptureScreens-KoQpCxtc.js.map +0 -1
  91. package/dist/esm/TotpConsent-CQU5jQi4.js.map +0 -1
  92. package/dist/esm/package-B-UwEdv7.js.map +0 -1
@@ -14,8 +14,8 @@ declare module 'signature_pad' {
14
14
 
15
15
  isEmpty(): boolean;
16
16
 
17
- on(event: string, callback: Function): void;
17
+ on(event: string, callback: (...args: unknown[]) => void): void;
18
18
 
19
- off(event: string, callback: Function): void;
19
+ off(event: string, callback: (...args: unknown[]) => void): void;
20
20
  }
21
21
  }
@@ -14,8 +14,8 @@ declare module 'signature_pad' {
14
14
 
15
15
  isEmpty(): boolean;
16
16
 
17
- on(event: string, callback: Function): void;
17
+ on(event: string, callback: (...args: unknown[]) => void): void;
18
18
 
19
- off(event: string, callback: Function): void;
19
+ off(event: string, callback: (...args: unknown[]) => void): void;
20
20
  }
21
21
  }
@@ -14,8 +14,8 @@ declare module 'signature_pad' {
14
14
 
15
15
  isEmpty(): boolean;
16
16
 
17
- on(event: string, callback: Function): void;
17
+ on(event: string, callback: (...args: unknown[]) => void): void;
18
18
 
19
- off(event: string, callback: Function): void;
19
+ off(event: string, callback: (...args: unknown[]) => void): void;
20
20
  }
21
21
  }
@@ -0,0 +1,19 @@
1
+ export {};
2
+
3
+ declare module 'signature_pad' {
4
+ export default class SignaturePad {
5
+ constructor(canvas: HTMLCanvasElement, options?: any);
6
+
7
+ clear(): void;
8
+
9
+ toDataURL(type?: string): string;
10
+
11
+ fromDataURL(dataURL: string): void;
12
+
13
+ isEmpty(): boolean;
14
+
15
+ on(event: string, callback: Function): void;
16
+
17
+ off(event: string, callback: Function): void;
18
+ }
19
+ }
@@ -0,0 +1,21 @@
1
+ export { }
2
+
3
+
4
+
5
+ declare module 'signature_pad' {
6
+ export default class SignaturePad {
7
+ constructor(canvas: HTMLCanvasElement, options?: any);
8
+
9
+ clear(): void;
10
+
11
+ toDataURL(type?: string): string;
12
+
13
+ fromDataURL(dataURL: string): void;
14
+
15
+ isEmpty(): boolean;
16
+
17
+ on(event: string, callback: (...args: unknown[]) => void): void;
18
+
19
+ off(event: string, callback: (...args: unknown[]) => void): void;
20
+ }
21
+ }
@@ -60,12 +60,14 @@ export declare class DocumentCaptureScreens extends HTMLElement {
60
60
  activeScreen: any;
61
61
  smartCameraWeb: Element | null;
62
62
  connectedCallback(): void;
63
- _data: {
63
+ _data:
64
+ | {
64
65
  images: never[];
65
66
  meta: {
66
67
  libraryVersion: string;
67
68
  };
68
- } | undefined;
69
+ }
70
+ | undefined;
69
71
  documentInstruction: Element | null | undefined;
70
72
  documentInstructionBack: Element | null | undefined;
71
73
  idCapture: Element | null | undefined;
@@ -78,11 +80,11 @@ export declare class DocumentCaptureScreens extends HTMLElement {
78
80
  _publishSelectedImages(): void;
79
81
  get hideInstructions(): boolean;
80
82
  get hideBackOfId(): boolean;
81
- get showNavigation(): "" | "show-navigation";
83
+ get showNavigation(): '' | 'show-navigation';
82
84
  get title(): string;
83
85
  get documentCaptureModes(): string;
84
86
  get documentType(): string;
85
- get hideAttribution(): "" | "hide-attribution";
87
+ get hideAttribution(): '' | 'hide-attribution';
86
88
  get themeColor(): string;
87
89
  handleBackEvents(): void;
88
90
  handleCloseEvents(): void;
@@ -156,35 +158,40 @@ export declare class SelfieCaptureScreens extends HTMLElement {
156
158
  activeScreen: any;
157
159
  _remountKey: number;
158
160
  connectedCallback(): void;
159
- _data: {
161
+ _data:
162
+ | {
160
163
  images: never[];
161
164
  meta: {
162
165
  libraryVersion: string;
163
166
  };
164
- } | undefined;
167
+ }
168
+ | undefined;
165
169
  selfieInstruction: Element | null | undefined;
166
170
  selfieCapture: HTMLElement | Element | null | undefined;
167
171
  selfieReview: Element | null | undefined;
168
- getAgentMode(): "environment" | "user";
172
+ getAgentMode(): 'environment' | 'user';
169
173
  disconnectedCallback(): void;
170
- _selfieWrapperListeners: {
174
+ _selfieWrapperListeners:
175
+ | {
171
176
  event: string;
172
177
  handler: (event: any) => Promise<void>;
173
- }[] | null | undefined;
178
+ }[]
179
+ | null
180
+ | undefined;
174
181
  setUpEventListeners(): void;
175
182
  forceWrapperRemount(): Promise<any>;
176
183
  setActiveScreen(screen: any): void;
177
184
  setupSelfieWrapperEventListeners(): void;
178
185
  _publishSelectedImages(): void;
179
186
  get hideInstructions(): boolean;
180
- get hideAttribution(): "" | "hide-attribution=\"\"";
187
+ get hideAttribution(): '' | 'hide-attribution=""';
181
188
  get hideBackOfId(): boolean;
182
- get showNavigation(): "" | "show-navigation=\"\"";
189
+ get showNavigation(): '' | 'show-navigation=""';
183
190
  get inAgentMode(): boolean;
184
- get allowAgentMode(): "" | "allow-agent-mode=\"true\"";
185
- get allowAgentModeTests(): "" | "show-agent-mode-for-tests=\"\"";
186
- get hideBack(): "" | "hide-back=\"\"";
187
- get disableImageTests(): "" | "disable-image-tests=\"\"";
191
+ get allowAgentMode(): '' | 'allow-agent-mode="true"';
192
+ get allowAgentModeTests(): '' | 'show-agent-mode-for-tests=""';
193
+ get hideBack(): '' | 'hide-back=""';
194
+ get disableImageTests(): '' | 'disable-image-tests=""';
188
195
  get themeColor(): string;
189
196
  handleBackEvents(): void;
190
197
  handleCloseEvent(): void;
@@ -216,12 +223,14 @@ export declare class SmartCameraWeb extends HTMLElement {
216
223
  render: () => string;
217
224
  activeScreen: any;
218
225
  connectedCallback(): void;
219
- _data: {
226
+ _data:
227
+ | {
220
228
  images: never[];
221
229
  meta: {
222
230
  libraryVersion: string;
223
231
  };
224
- } | undefined;
232
+ }
233
+ | undefined;
225
234
  disconnectedCallback(): void;
226
235
  attributeChangedCallback(name: any): void;
227
236
  setUpEventListeners(): void;
@@ -234,16 +243,16 @@ export declare class SmartCameraWeb extends HTMLElement {
234
243
  get captureId(): boolean;
235
244
  get documentType(): string | null;
236
245
  get isPortraitCaptureView(): boolean;
237
- get hideInstructions(): "" | "hide-instructions";
238
- get hideBackOfId(): "" | "hide-back-of-id";
239
- get showNavigation(): "" | "show-navigation";
240
- get hideBackToHost(): "" | "hide-back";
246
+ get hideInstructions(): '' | 'hide-instructions';
247
+ get hideBackOfId(): '' | 'hide-back-of-id';
248
+ get showNavigation(): '' | 'show-navigation';
249
+ get hideBackToHost(): '' | 'hide-back';
241
250
  get allowAgentMode(): string;
242
- get allowAgentModeTests(): "" | "show-agent-mode-for-tests";
251
+ get allowAgentModeTests(): '' | 'show-agent-mode-for-tests';
243
252
  get title(): string;
244
253
  get documentCaptureModes(): string;
245
- get disableImageTests(): "" | "disable-image-tests";
246
- get hideAttribution(): "" | "hide-attribution";
254
+ get disableImageTests(): '' | 'disable-image-tests';
255
+ get hideAttribution(): '' | 'hide-attribution';
247
256
  get hasThemeColor(): boolean;
248
257
  get themeColor(): string | null;
249
258
  get applyComponentThemeColor(): string;
@@ -328,8 +337,8 @@ declare module 'signature_pad' {
328
337
 
329
338
  isEmpty(): boolean;
330
339
 
331
- on(event: string, callback: Function): void;
340
+ on(event: string, callback: (...args: unknown[]) => void): void;
332
341
 
333
- off(event: string, callback: Function): void;
342
+ off(event: string, callback: (...args: unknown[]) => void): void;
334
343
  }
335
344
  }
@@ -14,8 +14,8 @@ declare module 'signature_pad' {
14
14
 
15
15
  isEmpty(): boolean;
16
16
 
17
- on(event: string, callback: Function): void;
17
+ on(event: string, callback: (...args: unknown[]) => void): void;
18
18
 
19
- off(event: string, callback: Function): void;
19
+ off(event: string, callback: (...args: unknown[]) => void): void;
20
20
  }
21
21
  }
@@ -14,8 +14,8 @@ declare module 'signature_pad' {
14
14
 
15
15
  isEmpty(): boolean;
16
16
 
17
- on(event: string, callback: Function): void;
17
+ on(event: string, callback: (...args: unknown[]) => void): void;
18
18
 
19
- off(event: string, callback: Function): void;
19
+ off(event: string, callback: (...args: unknown[]) => void): void;
20
20
  }
21
21
  }
@@ -14,8 +14,8 @@ declare module 'signature_pad' {
14
14
 
15
15
  isEmpty(): boolean;
16
16
 
17
- on(event: string, callback: Function): void;
17
+ on(event: string, callback: (...args: unknown[]) => void): void;
18
18
 
19
- off(event: string, callback: Function): void;
19
+ off(event: string, callback: (...args: unknown[]) => void): void;
20
20
  }
21
21
  }
@@ -14,8 +14,8 @@ declare module 'signature_pad' {
14
14
 
15
15
  isEmpty(): boolean;
16
16
 
17
- on(event: string, callback: Function): void;
17
+ on(event: string, callback: (...args: unknown[]) => void): void;
18
18
 
19
- off(event: string, callback: Function): void;
19
+ off(event: string, callback: (...args: unknown[]) => void): void;
20
20
  }
21
21
  }
@@ -14,8 +14,8 @@ declare module 'signature_pad' {
14
14
 
15
15
  isEmpty(): boolean;
16
16
 
17
- on(event: string, callback: Function): void;
17
+ on(event: string, callback: (...args: unknown[]) => void): void;
18
18
 
19
- off(event: string, callback: Function): void;
19
+ off(event: string, callback: (...args: unknown[]) => void): void;
20
20
  }
21
21
  }
@@ -2,6 +2,7 @@ import SmartCamera from '../../domain/camera/src/SmartCamera';
2
2
  import styles from '../../styles/src/styles';
3
3
  import '../attribution/PoweredBySmileId';
4
4
  import '../navigation/src';
5
+ import { t, getDirection } from '../../domain/localisation';
5
6
 
6
7
  function templateString() {
7
8
  return `
@@ -30,7 +31,7 @@ function templateString() {
30
31
  text-align: center;
31
32
  }
32
33
  </style>
33
- <div class='camera-permission-screen flow center'>
34
+ <div class='camera-permission-screen flow center' dir='${this.direction}'>
34
35
  <smileid-navigation theme-color='${this.themeColor}' ${this.showNavigation ? 'show-navigation' : ''} ${this.hideBack ? 'hide-back' : ''}></smileid-navigation>
35
36
  <div class='flow center'>
36
37
  <p class='color-red | center' id='error'>
@@ -69,10 +70,10 @@ function templateString() {
69
70
  </clipPath>
70
71
  </defs>
71
72
  </svg>
72
- <p class='text-2xl font-bold'>We need access to your camera so that we can capture your details.</p>
73
+ <p class='text-2xl font-bold'>${t('camera.permission.description')}</p>
73
74
  <div class='flow action-buttons'>
74
75
  <button data-variant='solid full-width' class='button' type='button' id='request-camera-access'>
75
- Request Camera Access
76
+ ${t('camera.permission.requestButton')}
76
77
  </button>
77
78
  ${this.hideAttribution ? '' : '<powered-by-smile-id></powered-by-smile-id>'}
78
79
  </div>
@@ -130,6 +131,10 @@ class CameraPermission extends HTMLElement {
130
131
  get themeColor() {
131
132
  return this.getAttribute('theme-color') || '#001096';
132
133
  }
134
+
135
+ get direction() {
136
+ return this.getAttribute('dir') || getDirection() || 'ltr';
137
+ }
133
138
  }
134
139
 
135
140
  if (window.customElements && !window.customElements.get('camera-permission')) {
@@ -1,3 +1,5 @@
1
+ import { t } from '../../../domain/localisation';
2
+
1
3
  function generateId(prefix) {
2
4
  const id = [...Array(30)].map(() => Math.random().toString(36)[3]).join('');
3
5
  return `${prefix}-${id}`;
@@ -111,7 +113,7 @@ class ComboboxTrigger extends HTMLElement {
111
113
  this.disabled ? ' disabled ' : ''
112
114
  }type="text" placeholder="${this.label}" />
113
115
  <button ${this.disabled ? 'disabled ' : ''}tabindex='-1' type='button'>
114
- <span class="visually-hidden">Toggle</span>
116
+ <span class="visually-hidden">${t('common.toggle')}</span>
115
117
  </button>
116
118
  </div>
117
119
  `
@@ -336,7 +338,7 @@ class ComboboxListbox extends HTMLElement {
336
338
  get emptyState() {
337
339
  return `
338
340
  <p id='empty-state' style="text-align: center;">
339
- ${this.emptyLabel || 'No items'}
341
+ ${this.emptyLabel || t('combobox.noItems')}
340
342
  </p>
341
343
  `;
342
344
  }
@@ -1,6 +1,7 @@
1
1
  import { IMAGE_TYPE } from '../../../domain/constants/src/Constants';
2
2
  import styles from '../../../styles/src/styles';
3
3
  import SmartCamera from '../../../domain/camera/src/SmartCamera';
4
+ import { t } from '../../../domain/localisation';
4
5
 
5
6
  import './document-capture';
6
7
  import './document-capture-review';
@@ -56,13 +57,13 @@ class DocumentCaptureScreens extends HTMLElement {
56
57
  ${this.hideAttribution}
57
58
  ></document-capture-instructions>
58
59
  <document-capture id='document-capture-front' side-of-id='Front'
59
- ${this.title} ${this.showNavigation} ${this.hideInstructions ? '' : 'hidden'} ${this.hideAttribution}
60
+ ${this.title || `title='${t('document.title.front')}'`} ${this.showNavigation} ${this.hideInstructions ? '' : 'hidden'} ${this.hideAttribution}
60
61
  ${this.documentCaptureModes} ${this.documentType} theme-color='${this.themeColor}'
61
62
  ></document-capture>
62
- <document-capture-instructions id='document-capture-instructions-back' side-of-id='Back' title='Submit Back of ID'
63
+ <document-capture-instructions id='document-capture-instructions-back' side-of-id='Back' title='${t('document.title.back')}'
63
64
  ${this.documentCaptureModes} ${this.showNavigation} theme-color='${this.themeColor}' ${this.hideAttribution} hidden
64
65
  ></document-capture-instructions>
65
- <document-capture id='document-capture-back' side-of-id='Back' ${this.title} ${this.showNavigation}
66
+ <document-capture id='document-capture-back' side-of-id='Back' ${this.title || `title='${t('document.title.back')}'`} ${this.showNavigation}
66
67
  ${this.documentCaptureModes} theme-color='${this.themeColor}' ${this.hideAttribution}
67
68
  hidden
68
69
  ></document-capture>
@@ -1,12 +1,18 @@
1
1
  import './index';
2
+ import { setCurrentLocale } from '../../../domain/localisation';
2
3
 
3
4
  const meta = {
4
5
  args: {
5
6
  'hide-attribution': false,
7
+ language: 'en',
6
8
  'theme-color': '#001096',
7
9
  },
8
10
  argTypes: {
9
11
  'hide-attribution': { control: 'boolean' },
12
+ language: {
13
+ control: { type: 'select' },
14
+ options: ['en', 'ar'],
15
+ },
10
16
  'theme-color': { control: 'color' },
11
17
  },
12
18
  component: 'document-capture-screens',
@@ -15,43 +21,61 @@ const meta = {
15
21
  export default meta;
16
22
 
17
23
  export const DocumentCapture = {
18
- render: (args) => `
24
+ render: (args) => {
25
+ setCurrentLocale(args.language);
26
+ return `
19
27
  <document-capture-screens theme-color='${args['theme-color']}' ${args['hide-attribution'] ? 'hide-attribution' : ''}>
20
28
  </document-capture-screens>
21
- `,
29
+ `;
30
+ },
22
31
  };
23
32
 
24
33
  export const DocumentCaptureHiddenInstructions = {
25
- render: (args) => `
34
+ render: (args) => {
35
+ setCurrentLocale(args.language);
36
+ return `
26
37
  <document-capture-screens hide-instructions theme-color='${args['theme-color']}' ${args['hide-attribution'] ? 'hide-attribution' : ''}>
27
38
  </document-capture-screens>
28
- `,
39
+ `;
40
+ },
29
41
  };
30
42
 
31
43
  export const DocumentCaptureHideBackOfId = {
32
- render: (args) => `
44
+ render: (args) => {
45
+ setCurrentLocale(args.language);
46
+ return `
33
47
  <document-capture-screens hide-back-of-id theme-color='${args['theme-color']}' ${args['hide-attribution'] ? 'hide-attribution' : ''}>
34
48
  </document-capture-screens>
35
- `,
49
+ `;
50
+ },
36
51
  };
37
52
 
38
53
  export const DocumentCaptureAllowAttributes = {
39
- render: (args) => `
54
+ render: (args) => {
55
+ setCurrentLocale(args.language);
56
+ return `
40
57
  <document-capture-screens document-capture-screens-modes='camera,upload' theme-color='${args['theme-color']}' ${args['hide-attribution'] ? 'hide-attribution' : ''}>
41
58
  </document-capture-screens>
42
- `,
59
+ `;
60
+ },
43
61
  };
44
62
 
45
63
  export const DocumentCaptureHideInstructionNBackOfId = {
46
- render: (args) => `
64
+ render: (args) => {
65
+ setCurrentLocale(args.language);
66
+ return `
47
67
  <document-capture-screens hide-back-of-id hide-instructions theme-color='${args['theme-color']}' ${args['hide-attribution'] ? 'hide-attribution' : ''}>
48
68
  </document-capture-screens>
49
- `,
69
+ `;
70
+ },
50
71
  };
51
72
 
52
73
  export const DocumentCapturePortraitMode = {
53
- render: () => `
54
- <document-capture-screens hide-back-of-id hide-instructions document-type="GREEN_BOOK">
74
+ render: (args) => {
75
+ setCurrentLocale(args.language);
76
+ return `
77
+ <document-capture-screens hide-back-of-id hide-instructions theme-color='${args['theme-color']}' ${args['hide-attribution'] ? 'hide-attribution' : ''} document-type="GREEN_BOOK">
55
78
  </document-capture-screens>
56
- `,
79
+ `;
80
+ },
57
81
  };
@@ -1,6 +1,8 @@
1
1
  import SmartCamera from '../../../../domain/camera/src/SmartCamera';
2
2
  import styles from '../../../../styles/src/styles';
3
3
  import '../../../navigation/src';
4
+ import { t, getDirection } from '../../../../domain/localisation';
5
+ import { JPEG_QUALITY } from '../../../../domain/constants/src/Constants';
4
6
 
5
7
  function hasMoreThanNColors(data, n = 16) {
6
8
  const colors = new Set();
@@ -47,7 +49,7 @@ function templateString() {
47
49
  overflow: visible;
48
50
  margin: 0 auto;
49
51
  }
50
-
52
+
51
53
  @media (max-width: 600px) {
52
54
  .section {
53
55
  width: 99%;
@@ -80,7 +82,7 @@ function templateString() {
80
82
  -webkit-tap-highlight-color: transparent;
81
83
  content: normal;
82
84
  }
83
-
85
+
84
86
  .id-video {
85
87
  width: 99%;
86
88
  text-align: center;
@@ -111,7 +113,7 @@ function templateString() {
111
113
  box-sizing: border-box;
112
114
  inset: 0px;
113
115
  }
114
-
116
+
115
117
  .video-overlay .inner-border {
116
118
  position: absolute;
117
119
  border-width: 0.25rem;
@@ -127,7 +129,7 @@ function templateString() {
127
129
  border-style: solid;
128
130
  border-radius: 0.25rem;
129
131
  }
130
-
132
+
131
133
  .description {
132
134
  align-self: center;
133
135
  padding-bottom: 1.75rem;
@@ -141,7 +143,7 @@ function templateString() {
141
143
  .id-side {
142
144
  padding-bottom: 0.5rem;
143
145
  }
144
-
146
+
145
147
  .circle-progress {
146
148
  display: flex;
147
149
  flex-direction: column;
@@ -161,12 +163,12 @@ function templateString() {
161
163
  }
162
164
  </style>
163
165
  ${styles(this.themeColor)}
164
- <div id='document-capture-screen' class='flow center flex-column'>
166
+ <div id='document-capture-screen' class='flow center flex-column' dir='${this.direction}'>
165
167
  <smileid-navigation theme-color='${this.themeColor}' ${this.showNavigation ? 'show-navigation' : ''} ${this.hideBack ? 'hide-back' : ''}></smileid-navigation>
166
168
  <h2 class='text-base font-bold title-color'>${this.documentName}</h2>
167
169
  <div class="circle-progress" id="loader">
168
170
  ${this.cameraError ? '' : '<p class="spinner"></p>'}
169
- ${this.cameraError ? `<p style="--flow-space: 4rem" class='color-red | center'>${this.cameraError}</p>` : '<p style="--flow-space: 4rem">Checking permissions</p>'}
171
+ ${this.cameraError ? `<p style="--flow-space: 4rem" class='color-red | center'>${this.cameraError}</p>` : `<p style="--flow-space: 4rem">${t('document.capture.checkingPermissions')}</p>`}
170
172
  </div>
171
173
  <div class='section | flow ${this.isPortraitCaptureView ? 'portrait' : 'landscape'}' ${this.cameraError ? 'hidden' : ''}>
172
174
  <div class='id-video-container'>
@@ -174,13 +176,13 @@ function templateString() {
174
176
  </div>
175
177
  <div class='video-footer sticky'>
176
178
  <h2 class='text-base font-bold title-color reset-margin-block id-side'>${this.title}</h2>
177
- <h4 class='text-base font-normal title-color description reset-margin-block'>Make sure all corners are visible and there is no glare.</h4>
179
+ <h4 class='text-base font-normal title-color description reset-margin-block'>${t('document.capture.instructionText')}</h4>
178
180
  <div class='actions' hidden>
179
181
  <button id='capture-id-image' class='button icon-btn | center' type='button'>
180
182
  <svg xmlns="http://www.w3.org/2000/svg" width="70" height="70" viewBox="0 0 70 70" fill="none" aria-hidden="true" focusable="false">
181
183
  <path fill-rule="evenodd" clip-rule="evenodd" d="M35 70C54.33 70 70 54.33 70 35C70 15.67 54.33 0 35 0C15.67 0 0 15.67 0 35C0 54.33 15.67 70 35 70ZM61 35C61 49.3594 49.3594 61 35 61C20.6406 61 9 49.3594 9 35C9 20.6406 20.6406 9 35 9C49.3594 9 61 20.6406 61 35ZM65 35C65 51.5685 51.5685 65 35 65C18.4315 65 5 51.5685 5 35C5 18.4315 18.4315 5 35 5C51.5685 5 65 18.4315 65 35Z" fill="${this.themeColor}"/>
182
184
  </svg>
183
- <span class='visually-hidden'>Capture Document</span>
185
+ <span class='visually-hidden'>${t('document.capture.captureButton')}</span>
184
186
  </button>
185
187
  </div>
186
188
  ${this.hideAttribution ? '' : '<powered-by-smile-id></powered-by-smile-id>'}
@@ -261,8 +263,8 @@ class DocumentCapture extends HTMLElement {
261
263
 
262
264
  this.updatePortraitId(canvas, video, 1, 1);
263
265
  this.updatePortraitId(previewCanvas, video);
264
- const image = canvas.toDataURL('image/jpeg');
265
- const previewImage = previewCanvas.toDataURL('image/jpeg');
266
+ const image = canvas.toDataURL('image/jpeg', JPEG_QUALITY);
267
+ const previewImage = previewCanvas.toDataURL('image/jpeg', JPEG_QUALITY);
266
268
  return {
267
269
  image,
268
270
  originalHeight: canvas.height,
@@ -294,9 +296,9 @@ class DocumentCapture extends HTMLElement {
294
296
  this._drawLandscapeImage(canvas, video, 1, 1);
295
297
  this._drawLandscapeImage(previewCanvas, video);
296
298
  }
297
- const image = canvas.toDataURL('image/jpeg');
299
+ const image = canvas.toDataURL('image/jpeg', JPEG_QUALITY);
298
300
 
299
- const previewImage = previewCanvas.toDataURL('image/jpeg');
301
+ const previewImage = previewCanvas.toDataURL('image/jpeg', JPEG_QUALITY);
300
302
  return {
301
303
  image,
302
304
  originalHeight: canvas.height,
@@ -698,12 +700,16 @@ class DocumentCapture extends HTMLElement {
698
700
  return !this.isFrontOfId;
699
701
  }
700
702
 
703
+ get direction() {
704
+ return this.getAttribute('dir') || getDirection() || 'ltr';
705
+ }
706
+
701
707
  get documentType() {
702
708
  return this.getAttribute('document-type') || '';
703
709
  }
704
710
 
705
711
  get documentName() {
706
- return this.getAttribute('document-name') || 'Document';
712
+ return this.getAttribute('document-name') || t('document.name.default');
707
713
  }
708
714
 
709
715
  get isPortraitCaptureView() {
@@ -1,15 +1,23 @@
1
1
  import SmartCamera from '../../../../domain/camera/src/SmartCamera';
2
+ import { setCurrentLocale } from '../../../../domain/localisation';
2
3
  import './index';
3
4
 
4
5
  const meta = {
5
6
  args: {
7
+ language: 'en',
6
8
  'theme-color': '#001096',
7
9
  },
8
10
  argTypes: {
11
+ language: {
12
+ control: { type: 'select' },
13
+ options: ['en', 'ar'],
14
+ },
9
15
  'theme-color': { control: 'color' },
10
16
  },
11
17
  component: 'document-capture',
12
- render: (args) => `
18
+ render: (args) => {
19
+ setCurrentLocale(args.language);
20
+ return `
13
21
  <document-capture
14
22
  show-navigation
15
23
  document-capture-modes="camera,upload"
@@ -19,7 +27,8 @@ const meta = {
19
27
  theme-color='${args['theme-color']}'
20
28
  >
21
29
  </document-capture>
22
- `,
30
+ `;
31
+ },
23
32
  };
24
33
 
25
34
  export default meta;