@everymatrix/general-registration 1.31.1 → 1.32.4

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 (79) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +4 -3
  3. package/dist/cjs/checkbox-group-input_13.cjs.entry.js +0 -36991
  4. package/dist/cjs/general-registration.cjs.js +0 -19
  5. package/dist/cjs/index-0b9241d1.js +0 -1360
  6. package/dist/cjs/index.cjs.js +0 -18
  7. package/dist/cjs/loader.cjs.js +0 -21
  8. package/dist/collection/collection-manifest.json +0 -30
  9. package/dist/collection/components/general-registration/general-registration.css +0 -122
  10. package/dist/collection/components/general-registration/general-registration.js +0 -774
  11. package/dist/collection/index.js +0 -17
  12. package/dist/collection/utils/locale.utils.js +0 -108
  13. package/dist/collection/utils/utils.js +0 -3
  14. package/dist/components/active-mixin.js +0 -975
  15. package/dist/components/checkbox-group-input.js +0 -6
  16. package/dist/components/checkbox-group-input2.js +0 -1078
  17. package/dist/components/checkbox-input.js +0 -6
  18. package/dist/components/checkbox-input2.js +0 -129
  19. package/dist/components/date-input.js +0 -6
  20. package/dist/components/date-input2.js +0 -11556
  21. package/dist/components/email-input.js +0 -6
  22. package/dist/components/email-input2.js +0 -171
  23. package/dist/components/field-mixin.js +0 -12426
  24. package/dist/components/general-input.js +0 -6
  25. package/dist/components/general-input2.js +0 -341
  26. package/dist/components/general-registration.d.ts +0 -11
  27. package/dist/components/general-registration.js +0 -754
  28. package/dist/components/index.d.ts +0 -26
  29. package/dist/components/index.js +0 -18
  30. package/dist/components/input-field-shared-styles.js +0 -1211
  31. package/dist/components/number-input.js +0 -6
  32. package/dist/components/number-input2.js +0 -158
  33. package/dist/components/password-input.js +0 -6
  34. package/dist/components/password-input2.js +0 -1041
  35. package/dist/components/radio-input.js +0 -6
  36. package/dist/components/radio-input2.js +0 -114
  37. package/dist/components/select-input.js +0 -6
  38. package/dist/components/select-input2.js +0 -183
  39. package/dist/components/tel-input.js +0 -6
  40. package/dist/components/tel-input2.js +0 -197
  41. package/dist/components/text-input.js +0 -6
  42. package/dist/components/text-input2.js +0 -199
  43. package/dist/components/toggle-checkbox-input.js +0 -6
  44. package/dist/components/tooltipIcon.js +0 -127
  45. package/dist/components/vaadin-button.js +0 -490
  46. package/dist/components/vaadin-combo-box.js +0 -4512
  47. package/dist/components/virtual-keyboard-controller.js +0 -2001
  48. package/dist/esm/checkbox-group-input_13.entry.js +0 -36975
  49. package/dist/esm/general-registration.js +0 -17
  50. package/dist/esm/index-a42c182c.js +0 -1332
  51. package/dist/esm/index.js +0 -16
  52. package/dist/esm/loader.js +0 -17
  53. package/dist/esm/polyfills/core-js.js +0 -11
  54. package/dist/esm/polyfills/css-shim.js +0 -1
  55. package/dist/esm/polyfills/dom.js +0 -79
  56. package/dist/esm/polyfills/es5-html-element.js +0 -1
  57. package/dist/esm/polyfills/index.js +0 -34
  58. package/dist/esm/polyfills/system.js +0 -6
  59. package/dist/general-registration/general-registration.esm.js +0 -1
  60. package/dist/general-registration/index.esm.js +0 -1
  61. package/dist/general-registration/p-4ff02444.js +0 -1
  62. package/dist/general-registration/p-8eaa2cfb.entry.js +0 -3647
  63. package/dist/index.cjs.js +0 -1
  64. package/dist/index.js +0 -1
  65. package/dist/stencil.config.js +0 -22
  66. package/dist/types/Users/sebastian.strulea/Documents/work/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/types.d.ts +0 -87
  67. package/dist/types/Users/sebastian.strulea/Documents/work/widgets-stencil/packages/general-registration/.stencil/packages/general-registration/stencil.config.d.ts +0 -2
  68. package/dist/types/components/general-registration/general-registration.d.ts +0 -93
  69. package/dist/types/components.d.ts +0 -111
  70. package/dist/types/index.d.ts +0 -1
  71. package/dist/types/stencil-public-runtime.d.ts +0 -1565
  72. package/dist/types/utils/locale.utils.d.ts +0 -17
  73. package/dist/types/utils/utils.d.ts +0 -1
  74. package/loader/cdn.js +0 -3
  75. package/loader/index.cjs.js +0 -3
  76. package/loader/index.d.ts +0 -12
  77. package/loader/index.es2017.js +0 -3
  78. package/loader/index.js +0 -4
  79. package/loader/package.json +0 -10
@@ -1,754 +0,0 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { d as defineCustomElement$d } from './checkbox-group-input2.js';
3
- import { d as defineCustomElement$c } from './checkbox-input2.js';
4
- import { d as defineCustomElement$b } from './date-input2.js';
5
- import { d as defineCustomElement$a } from './email-input2.js';
6
- import { a as defineCustomElement$2, d as defineCustomElement$9 } from './general-input2.js';
7
- import { d as defineCustomElement$8 } from './number-input2.js';
8
- import { d as defineCustomElement$7 } from './password-input2.js';
9
- import { d as defineCustomElement$6 } from './radio-input2.js';
10
- import { d as defineCustomElement$5 } from './select-input2.js';
11
- import { d as defineCustomElement$4 } from './tel-input2.js';
12
- import { d as defineCustomElement$3 } from './text-input2.js';
13
-
14
- const DEFAULT_LANGUAGE = 'en';
15
- const TRANSLATIONS = {
16
- "en": {
17
- "nextButton": 'Next',
18
- "backButton": 'Back',
19
- "doneButton": 'Done',
20
- "GmErr_BadRequest_Duplicate_User": 'A user with this information already exists.',
21
- "GmErr_BadRequest_PasswordContainsUsername": "The password cannot be the same as the username.",
22
- "GmErr_BadRequest_PasswordContainsEmail": "The password cannot be the same as the email.",
23
- "GmErr_BadRequest_Duplicate_PersonalId": "There is already a registration with the data you entered or you entered your data in an incorrect format.",
24
- "GmErr_Forbidden_UserAccount_NavExcluded": 'User is NAV Excluded. Registration was denied.',
25
- "GmErr_BadRequest_ModelValidationFailed": 'Something went wrong... Please try again.',
26
- "GmErr_BadInternalConfigs": 'Something went wrong... Please try again.',
27
- "GmErr_Unauthorized": 'Something went wrong... Please try again.',
28
- "GmErr_NotFound": 'Something went wrong... Please try again.',
29
- "GmErr_UnexpectedException": 'Something went wrong... Please try again.',
30
- "generalError": "Something went wrong... Please try again.",
31
- "successMessage": "Register successful"
32
- },
33
- "hu": {
34
- "nextButton": 'Következő',
35
- "backButton": 'Vissza',
36
- "doneButton": 'Kész',
37
- "GmErr_BadRequest_Duplicate_User": 'Már létezik felhasználó ezzel az információval.',
38
- "GmErr_BadRequest_PasswordContainsUsername": "The password cannot be the same as the username.",
39
- "GmErr_BadRequest_PasswordContainsEmail": "The password cannot be the same as the email.",
40
- "GmErr_BadRequest_Duplicate_PersonalId": "There is already a registration with the data you entered or you entered your data in an incorrect format.",
41
- "GmErr_Forbidden_UserAccount_NavExcluded": 'User is NAV Excluded. Registration was denied',
42
- "GmErr_BadRequest_ModelValidationFailed": 'Valami hiba történt... Kérjük, próbálja újra.',
43
- "GmErr_BadInternalConfigs": 'Valami hiba történt... Kérjük, próbálja újra.',
44
- "GmErr_Unauthorized": 'Valami hiba történt... Kérjük, próbálja újra.',
45
- "GmErr_NotFound": 'Valami hiba történt... Kérjük, próbálja újra.',
46
- "GmErr_UnexpectedException": 'Valami hiba történt... Kérjük, próbálja újra.',
47
- "generalError": "Valami hiba történt... Próbáld újra.",
48
- "successMessage": "Sikeres regisztráció"
49
- },
50
- "hr": {
51
- "nextButton": 'Sljedeće',
52
- "backButton": 'Nazad',
53
- "doneButton": 'Gotovo',
54
- "GmErr_BadRequest_Duplicate_User": 'Korisnik s ovim podacima već postoji.',
55
- "GmErr_BadRequest_PasswordContainsUsername": "The password cannot be the same as the username.",
56
- "GmErr_BadRequest_PasswordContainsEmail": "The password cannot be the same as the email.",
57
- "GmErr_BadRequest_Duplicate_PersonalId": "There is already a registration with the data you entered or you entered your data in an incorrect format.",
58
- "GmErr_Forbidden_UserAccount_NavExcluded": 'Korisnik je NAV isključen. Registracija je odbijena.',
59
- "GmErr_BadRequest_ModelValidationFailed": 'Nešto nije u redu... Molimo pokušajte ponovo',
60
- "GmErr_BadInternalConfigs": 'Nešto nije u redu... Molimo pokušajte ponovo',
61
- "GmErr_Unauthorized": 'Nešto nije u redu... Molimo pokušajte ponovo',
62
- "GmErr_NotFound": 'Nešto nije u redu... Molimo pokušajte ponovo',
63
- "GmErr_UnexpectedException": 'Nešto nije u redu... Molimo pokušajte ponovo',
64
- "generalError": "Nešto nije u redu... Molimo pokušajte ponovo",
65
- "successMessage": "Register successful"
66
- },
67
- 'pt-br': {
68
- "nextButton": 'Seguindo',
69
- "backButton": 'Voltar',
70
- "doneButton": 'Terminar',
71
- "GmErr_BadRequest_Duplicate_User": 'Já existe um usuário com esta informação',
72
- "GmErr_Forbidden_UserAccount_NavExcluded": 'O usuário está excluído NAV. O registro foi negado',
73
- "GmErr_BadRequest_ModelValidationFailed": 'Alguma coisa deu errado. Por favor tente outra vez.',
74
- "GmErr_BadInternalConfigs": 'Alguma coisa deu errado. Por favor tente outra vez',
75
- "GmErr_Unauthorized": 'Alguma coisa deu errado. Por favor tente outra vez',
76
- "GmErr_NotFound": 'Alguma coisa deu errado. Por favor tente outra vez',
77
- "GmErr_UnexpectedException": 'Alguma coisa deu errado. Por favor tente outra vez',
78
- "generalError": 'Alguma coisa deu errado. Por favor tente outra vez',
79
- "successMessage": 'Registro bem-sucedido'
80
- },
81
- 'es-mx': {
82
- "nextButton": 'Siguiente',
83
- "backButton": 'Atrás',
84
- "doneButton": 'Terminar',
85
- "GmErr_BadRequest_Duplicate_User": 'Un usuario con esta información ya existe',
86
- "GmErr_Forbidden_UserAccount_NavExcluded": 'Usuario es Excluído NA. Registro fue negado',
87
- "GmErr_BadRequest_ModelValidationFailed": 'Algo salió mal…por favor intente de nuevo.',
88
- "GmErr_BadInternalConfigs": 'Algo salió mal... Por favor intente de nuevo',
89
- "GmErr_Unauthorized": 'Algo salió mal... Por favor intente de nuevo',
90
- "GmErr_NotFound": 'Algo salió mal... Por favor intente de nuevo',
91
- "GmErr_UnexpectedException": 'Algo salió mal... Por favor intente de nuevo',
92
- "generalError": 'Algo salió mal... Por favor intente de nuevo',
93
- "successMessage": 'Registro exitoso'
94
- }
95
- };
96
- const getTranslations = (url) => {
97
- // fetch url, get the data, replace the TRANSLATIONS content
98
- return new Promise((resolve) => {
99
- fetch(url)
100
- .then((res) => res.json())
101
- .then((data) => {
102
- Object.keys(data).forEach((item) => {
103
- for (let key in data[item]) {
104
- TRANSLATIONS[item][key] = data[item][key];
105
- }
106
- });
107
- resolve(true);
108
- });
109
- });
110
- };
111
- const translate = (key, customLang, values) => {
112
- const lang = customLang;
113
- let translation = TRANSLATIONS[lang !== undefined ? lang : DEFAULT_LANGUAGE][key];
114
- if (values !== undefined) {
115
- for (const [key, value] of Object.entries(values.values)) {
116
- const regex = new RegExp(`{${key}}`, 'g');
117
- translation = translation.replace(regex, value);
118
- }
119
- }
120
- return translation;
121
- };
122
-
123
- const generalRegistrationCss = "*,\n*::before,\n*::after {\n padding: 0;\n margin: 0;\n box-sizing: border-box;\n}\n\n.registration__form.hidden {\n display: none;\n}\n\n.registration {\n font-family: \"Roboto\";\n font-style: normal;\n font-family: sans-serif;\n display: flex;\n flex-direction: column;\n gap: 24px;\n width: 100%;\n height: 100%;\n container-type: inline-size;\n}\n.registration__wrapper {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.registration__error-message {\n color: var(--emfe-w-color-error, var(--emfe-w-color-red, #ed0909));\n font-size: 13px;\n display: block;\n justify-content: center;\n text-align: center;\n}\n.registration__form {\n display: grid;\n grid-template-columns: repeat(1, 1fr);\n gap: 40px;\n justify-items: stretch;\n align-content: flex-start;\n overflow: auto;\n width: 100%;\n height: 100%;\n}\n.registration__buttons-wrapper {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n align-items: center;\n position: relative;\n}\n.registration__button {\n border-radius: 5px;\n background: var(--emfe-w-login-color-primary, var(--emfe-w-color-primary, #D0046C));\n border: 1px solid var(--emfe-w-login-color-primary, var(--emfe-w-color-primary, #D0046C));\n color: var(--emfe-w-button-typography, var(--emfe-w-color-white, #FFFFFF));\n text-transform: uppercase;\n font-size: 20px;\n height: 44px;\n width: 100%;\n margin: 0px auto;\n padding: 10px 20px;\n font-weight: normal;\n box-shadow: none;\n cursor: pointer;\n}\n.registration__button--disabled {\n background: var(--emfe-w-color-gray-100, #E6E6E6);\n border: 1px solid var(--emfe-w-color-gray-150, #828282);\n pointer-events: none;\n box-shadow: none;\n}\n.registration__button--first-step {\n display: none;\n}\n\n@container (min-width: 450px) {\n .registration__form {\n grid-template-columns: repeat(2, 1fr);\n }\n\n .registration__buttons-wrapper {\n flex-direction: row-reverse;\n gap: 15px;\n }\n}\n.spinner {\n animation: rotate 2s linear infinite;\n z-index: 2;\n position: absolute;\n top: 50%;\n left: 50%;\n margin: -25px 0 0 -25px;\n width: 50px;\n height: 50px;\n}\n.spinner .path {\n stroke: var(--emfe-w-login-color-primary, var(--emfe-w-color-primary, #D0046C));\n stroke-linecap: round;\n animation: dash 1.5s ease-in-out infinite;\n}\n\n@keyframes rotate {\n 100% {\n transform: rotate(360deg);\n }\n}\n@keyframes dash {\n 0% {\n stroke-dasharray: 1, 150;\n stroke-dashoffset: 0;\n }\n 50% {\n stroke-dasharray: 90, 150;\n stroke-dashoffset: -35;\n }\n 100% {\n stroke-dasharray: 90, 150;\n stroke-dashoffset: -124;\n }\n}";
124
-
125
- const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
126
- constructor() {
127
- super();
128
- this.__registerHost();
129
- this.__attachShadow();
130
- this.registrationWidgetLoaded = createEvent(this, "registrationWidgetLoaded", 7);
131
- this.registrationStepUpdated = createEvent(this, "registrationStepUpdated", 7);
132
- /**
133
- * Currently selected language
134
- */
135
- this.language = 'en';
136
- /**
137
- * Client custom styling via inline styles
138
- */
139
- this.clientStyling = '';
140
- /**
141
- * Client custom styling via url
142
- */
143
- this.clientStylingUrl = '';
144
- /**
145
- * Translations via URL
146
- */
147
- this.translationUrl = '';
148
- /**
149
- * Affiliate code to be passed in and sent in the registration.
150
- */
151
- this.btag = null;
152
- /**
153
- * Boolean flag that tells inputs to emit an event on click.
154
- */
155
- this.emitOnClick = false;
156
- this.isLoading = true;
157
- this.forms = [];
158
- this.limitStylingAppends = false;
159
- this.autofilled = false;
160
- this.listOfInputValues = [];
161
- this.listOfInputValidity = [];
162
- this.listOfActions = [];
163
- this.listOfInputs = [];
164
- this.emitValue = false;
165
- this.backButtonPressed = false;
166
- this.registerErrors = false;
167
- this.extraActions = [];
168
- this.registrationStepsState = {
169
- regId: null
170
- };
171
- this.setClientStyling = () => {
172
- let sheet = document.createElement('style');
173
- sheet.innerHTML = this.clientStyling;
174
- this.host.shadowRoot.prepend(sheet);
175
- };
176
- this.setClientStylingURL = () => {
177
- let url = new URL(this.clientStylingUrl);
178
- let cssFile = document.createElement('style');
179
- fetch(url.href)
180
- .then((res) => res.text())
181
- .then((data) => {
182
- cssFile.innerHTML = data;
183
- this.clientStyling = data;
184
- setTimeout(() => { this.host.shadowRoot.prepend(cssFile); }, 1);
185
- });
186
- };
187
- }
188
- sendStep() {
189
- this.registrationStepUpdated.emit(this.registrationStep);
190
- window.postMessage({ type: 'registrationStepUpdated', step: this.registrationStep }, window.location.href);
191
- }
192
- handleStylingChange(newValue, oldValue) {
193
- if (newValue !== oldValue)
194
- this.setClientStyling();
195
- }
196
- handleStylingUrlChange(newValue, oldValue) {
197
- if (newValue !== oldValue)
198
- this.setClientStylingURL();
199
- }
200
- setFormValidity() {
201
- this.errorMessage = '';
202
- if (this.listOfInputValidity) {
203
- this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
204
- }
205
- //Check for autofilled.
206
- if (this.listOfInputs.some(inputs => inputs.autofill)) {
207
- this.autofilled = true;
208
- }
209
- }
210
- addBtag() {
211
- this.addBtagValue();
212
- }
213
- checkInputsValidityHandler(event) {
214
- // Set isValid state of the input in the list.
215
- this.listOfInputValidity.find(input => input.name == event.detail.name).isValid = event.detail.valid;
216
- // Check if any one is invalid.
217
- this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
218
- }
219
- getInputsValueHandler(event) {
220
- this.listOfInputValues.find(input => {
221
- if (input.name == event.detail.name) {
222
- input.value = event.detail.value;
223
- input.type = event.detail.type || null;
224
- }
225
- });
226
- this.stepsStateMachine({ event: 'set', type: 'values' });
227
- }
228
- componentWillLoad() {
229
- return this.getRegisterConfig()
230
- .then((config) => {
231
- this.formatConfig(config);
232
- this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
233
- this.stepsStateMachine({ event: 'set', type: 'inputs' });
234
- });
235
- }
236
- componentDidLoad() {
237
- this.registrationWidgetLoaded.emit();
238
- window.postMessage({ type: 'registrationWidgetLoaded' }, window.location.href);
239
- if (!this.limitStylingAppends && this.host) {
240
- if (this.clientStyling)
241
- this.setClientStyling();
242
- if (this.clientStylingUrl)
243
- this.setClientStylingURL();
244
- this.limitStylingAppends = true;
245
- }
246
- }
247
- nextHandler(e) {
248
- e.preventDefault();
249
- // Trigger events in subwidgets.
250
- this.emitValue = true;
251
- this.setRegisterStep();
252
- }
253
- backHandler(e) {
254
- e.preventDefault();
255
- this.registrationStep = this.stepChange('decrement');
256
- this.stepsStateMachine({ event: 'get', type: 'inputs' });
257
- this.stepsStateMachine({ event: 'get', type: 'values' });
258
- }
259
- stepsStateMachine(state) {
260
- switch (state.event) {
261
- case 'set':
262
- if (state.type == 'inputs') {
263
- this.registrationStepsState[this.registrationStep].fields = this.listOfInputs;
264
- this.registrationStepsState[this.registrationStep].actions = this.listOfActions;
265
- this.registrationStepsState[this.registrationStep].fieldsValidity = this.listOfInputValidity;
266
- }
267
- if (state.type == 'values') {
268
- this.registrationStepsState[this.registrationStep].registerUserData = this.listOfInputValues.reduce((acc, curr) => {
269
- acc[curr.name] = { value: curr.value, isDuplicate: curr.isDuplicate };
270
- return acc;
271
- }, {});
272
- }
273
- localStorage.setItem('registrationStepsState', JSON.stringify(this.registrationStepsState));
274
- break;
275
- case 'get':
276
- const savedUserData = JSON.parse(localStorage.getItem('registrationStepsState'));
277
- if (!savedUserData)
278
- return;
279
- if (state.type == 'inputs') {
280
- this.listOfInputs = this.registrationStepsState[this.registrationStep].fields;
281
- this.listOfActions = this.registrationStepsState[this.registrationStep].actions;
282
- this.listOfInputValidity = this.registrationStepsState[this.registrationStep].fieldsValidity;
283
- }
284
- if (state.type == 'values') {
285
- const savedValues = savedUserData[this.registrationStep].registerUserData;
286
- this.listOfInputValues = Object.keys(savedValues).map(name => {
287
- return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
288
- });
289
- // Give to each field the user input as the default value.
290
- this.listOfInputValues.forEach(inputValue => {
291
- const input = this.listOfInputs.find(input => input.name === inputValue.name);
292
- if (input) {
293
- input.defaultValue = inputValue.value;
294
- }
295
- });
296
- }
297
- this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
298
- break;
299
- }
300
- }
301
- getRegisterConfig(registrationID) {
302
- const url = new URL(`${this.endpoint}/v1/player/legislation/registration/config`);
303
- const headers = new Headers();
304
- headers.append('Content-Type', 'application/json');
305
- headers.append('Accept', 'application/json');
306
- if (registrationID) {
307
- url.searchParams.append('registrationId', registrationID);
308
- }
309
- const options = {
310
- method: 'GET',
311
- headers
312
- };
313
- return new Promise((resolve, reject) => {
314
- this.isLoading = true;
315
- fetch(url.href, options)
316
- .then((res) => res.json())
317
- .then((config) => {
318
- this.isLoading = false;
319
- resolve(config);
320
- }).catch((err) => {
321
- this.isLoading = false;
322
- console.error(err);
323
- reject(err);
324
- }).finally(() => {
325
- this.isLoading = false;
326
- });
327
- });
328
- }
329
- setRegisterStep() {
330
- this.isLoadingPOST = true;
331
- const url = new URL(`${this.endpoint}/v1/player/legislation/registration/step`);
332
- const registerStep = {
333
- registrationId: this.registrationID,
334
- registerUserDto: this.listOfInputValues
335
- .filter(input => !input.isDuplicate)
336
- .reduce((acc, curr) => {
337
- // Because the API is very robust, some values need to be split as separate entities.
338
- if (curr.name === 'TypeOfPublicArea') {
339
- acc[curr.name] = curr.value.toLowerCase();
340
- }
341
- else if (curr.type === 'tel') {
342
- //@ts-ignore
343
- acc['MobilePrefix'] = curr.value.prefix;
344
- //@ts-ignore
345
- acc[curr.name] = curr.value.phone;
346
- }
347
- else if (curr.type === 'checkboxgroup') {
348
- // Skip adding the parent of the checkboxgroup as a key.
349
- if (curr.value !== null) {
350
- Object.entries(curr.value).forEach(([key, value]) => {
351
- acc[key] = value ? 'true' : 'false';
352
- });
353
- }
354
- }
355
- else {
356
- acc[curr.name] = curr.value;
357
- }
358
- return acc;
359
- }, {}),
360
- step: this.registrationStep,
361
- };
362
- const headers = new Headers();
363
- headers.append('Content-Type', 'application/json');
364
- headers.append('Accept', 'application/json');
365
- const options = {
366
- method: 'POST',
367
- body: JSON.stringify(registerStep),
368
- headers
369
- };
370
- fetch(url.href, options)
371
- .then((res) => {
372
- if (!res.ok) {
373
- return res.json().then(error => {
374
- this.errorCode = error.thirdPartyResponse.errorCode;
375
- // Show the idomsoft error if it is the case
376
- if (this.errorCode == 'GmErr_BadRequest_IdomsoftVerification_ShouldRetry') {
377
- this.errorMessage = error.thirdPartyResponse.message;
378
- }
379
- else if (this.errorCode === 'GmErr_Forbidden_UserAccount_NavExcluded') {
380
- this.errorMessage = translate(`${this.errorCode}`, this.language);
381
- }
382
- else if (this.errorCode == 'GmErr_BadRequest') {
383
- this.errorMessage = error.thirdPartyResponse.message;
384
- }
385
- else {
386
- this.errorMessage = translate(`${this.errorCode}`, this.language) || translate(`generalError`, this.language);
387
- }
388
- });
389
- }
390
- return res.json();
391
- })
392
- .then((data) => {
393
- this.isLoadingPOST = false;
394
- this.registrationID = data.registrationId;
395
- if (this.listOfActions.some(action => action == '/register')) {
396
- if (this.listOfActions.some(action => action == '/generate-2FA-code/Generate2FACode')) {
397
- this.extraActions.push('2fa');
398
- }
399
- this.setRegister();
400
- }
401
- else {
402
- // After sending the current step, increment and check if the next one is in state.
403
- this.registrationStep = this.stepChange('increment');
404
- // If step is present in state do NOT fetch the next config.
405
- if (Object.keys(this.registrationStepsState).find(key => key == this.registrationStep)) {
406
- // Use the one from state
407
- this.stepsStateMachine({ event: 'get', type: 'inputs' });
408
- this.stepsStateMachine({ event: 'get', type: 'values' });
409
- }
410
- else {
411
- this.getRegisterConfig(this.registrationID).then((config) => {
412
- // Format the new step config.
413
- this.formatConfig(config);
414
- // Set it in local storage.
415
- this.stepsStateMachine({ event: 'set', type: 'inputs' });
416
- });
417
- }
418
- }
419
- })
420
- .catch((err) => {
421
- this.isLoadingPOST = false;
422
- console.error(err);
423
- }).finally(() => {
424
- this.isLoadingPOST = false;
425
- });
426
- }
427
- setRegister() {
428
- this.isLoading = true;
429
- this.registerErrors = false;
430
- const url = new URL(`${this.endpoint}/v1/player/legislation/register`);
431
- const headers = new Headers();
432
- headers.append('Content-Type', 'application/json');
433
- headers.append('Accept', 'application/json');
434
- const options = {
435
- method: 'PUT',
436
- body: JSON.stringify({ registrationId: this.registrationID }),
437
- headers
438
- };
439
- fetch(url.href, options)
440
- .then((res) => {
441
- if (!res.ok) {
442
- this.registerErrors = true;
443
- return res.json().then(error => {
444
- this.errorCode = error.thirdPartyResponse.errorCode;
445
- // Show the idomsoft error if it is the case
446
- if (this.errorCode == 'GmErr_BadRequest_IdomsoftVerification_ShouldRetry') {
447
- this.errorMessage = error.thirdPartyResponse.message;
448
- }
449
- else if (this.errorCode == 'GmErr_BadRequest') {
450
- this.errorMessage = error.thirdPartyResponse.message;
451
- }
452
- else {
453
- this.errorMessage = translate(`${this.errorCode}`, this.language) || translate(`generalError`, this.language);
454
- }
455
- window.postMessage({ type: 'registrationFailed', errorMessage: error === null || error === void 0 ? void 0 : error.thirdPartyResponse.message }, window.location.href);
456
- window.postMessage({ type: 'WidgetNotification', data: {
457
- type: 'error',
458
- message: this.errorMessage
459
- } }, window.location.href);
460
- });
461
- }
462
- return res.json();
463
- })
464
- .then((data) => {
465
- this.isLoading = false;
466
- if (!this.registerErrors) {
467
- window.postMessage({ type: 'registrationSuccessful', userId: data === null || data === void 0 ? void 0 : data.userId, extraActions: this.extraActions }, window.location.href);
468
- window.postMessage({ type: 'WidgetNotification', data: {
469
- type: 'success',
470
- message: translate('successMessage', this.language)
471
- } }, window.location.href);
472
- }
473
- })
474
- .catch((err) => {
475
- this.isLoading = false;
476
- console.error(err);
477
- })
478
- .finally(() => {
479
- this.isLoading = false;
480
- });
481
- }
482
- formatConfig(config) {
483
- // Populate the list of inputs
484
- this.listOfInputs = config.content.fields.flatMap((field) => {
485
- // Special case for inputs that need to be duplicated.
486
- const duplicateInputRule = field.validate.custom.find(customRule => customRule.rule === 'duplicate-input');
487
- const inputElement = Object.assign({}, field);
488
- if (duplicateInputRule) {
489
- const duplicateInput = Object.assign(Object.assign({}, field), { name: `${field.name}Duplicate`, displayName: duplicateInputRule.displayName, isDuplicateInput: true });
490
- return [inputElement, duplicateInput];
491
- }
492
- else {
493
- return [inputElement];
494
- }
495
- });
496
- this.listOfInputValidity = this.listOfInputs.reduce((acc, field) => {
497
- var _a;
498
- // If the field is a togglecheckbox, add its subfields
499
- if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "togglecheckbox") {
500
- field.data.subFields.forEach(subfield => {
501
- acc.push({
502
- name: subfield.name,
503
- isValid: this.setInitialValidStatus(subfield)
504
- });
505
- });
506
- }
507
- else {
508
- acc.push({
509
- name: field.name,
510
- isValid: this.setInitialValidStatus(field)
511
- });
512
- }
513
- return acc;
514
- }, []);
515
- this.listOfInputValues = this.listOfInputs.reduce((acc, field) => {
516
- var _a, _b, _c;
517
- // If the field type is a 'togglecheckbox', add its subfields
518
- if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "togglecheckbox") {
519
- field.data.subFields.forEach(subfield => {
520
- var _a, _b;
521
- acc.push({
522
- name: subfield.name,
523
- value: ((_a = subfield.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) == 'checkbox' ? 'false' : null,
524
- isDuplicate: subfield.isDuplicateInput || false,
525
- type: ((_b = field.inputType) === null || _b === void 0 ? void 0 : _b.toLowerCase()) == 'togglecheckbox'
526
- ? 'togglecheckbox'
527
- : null
528
- });
529
- });
530
- }
531
- else {
532
- acc.push({
533
- name: field.name,
534
- value: ((_b = field.inputType) === null || _b === void 0 ? void 0 : _b.toLowerCase()) == 'checkbox' ? 'false' : null,
535
- isDuplicate: field.isDuplicateInput || false,
536
- type: ((_c = field.inputType) === null || _c === void 0 ? void 0 : _c.toLowerCase()) == 'checkboxgroup' ? 'checkboxgroup' : null
537
- });
538
- }
539
- return acc;
540
- }, []);
541
- if (this.btag)
542
- this.addBtagValue();
543
- // Set the list of actions
544
- this.listOfActions = config.content.actions.map(action => action);
545
- this.registrationID = config.content.registrationID;
546
- this.registrationStep = config.content.step;
547
- if (this.listOfActions.some(action => action == '/register')) {
548
- this.lastStep = this.registrationStep;
549
- }
550
- // The translations for fields happens here.
551
- if (this.translationUrl) {
552
- getTranslations(this.translationUrl).then(() => {
553
- this.listOfInputs.forEach(field => {
554
- var _a, _b;
555
- this.addTranslation(field);
556
- // Logic for field types that have subfields
557
- if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'togglecheckbox') {
558
- field.data.subFields.forEach(subField => this.addTranslation(subField));
559
- }
560
- if (((_b = field.inputType) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'checkboxgroup') {
561
- this.addTranslation(field);
562
- field.data.subFields.forEach(subField => this.addTranslation(subField));
563
- }
564
- return field;
565
- });
566
- })
567
- .catch((error) => {
568
- console.error('Failed to fetch translations:', error);
569
- }).finally(() => {
570
- this.forms = [...this.forms, { [this.registrationStep]: this.listOfInputs }];
571
- });
572
- }
573
- else {
574
- this.forms = [...this.forms, { [this.registrationStep]: this.listOfInputs }];
575
- }
576
- // Add the step to the registrationStepsData
577
- this.registrationStepsState.regId = this.registrationID;
578
- if (!this.registrationStepsState[this.registrationStep]) {
579
- this.registrationStepsState[this.registrationStep] = {
580
- fields: [],
581
- fieldsValidity: [],
582
- registerUserData: {},
583
- actions: []
584
- };
585
- }
586
- }
587
- addBtagValue() {
588
- const btagField = this.listOfInputs.find(input => input.name.toLowerCase() === 'btag');
589
- if (btagField) {
590
- btagField.defaultValue = this.btag;
591
- }
592
- const btagValue = this.listOfInputValues.find(input => input.name.toLowerCase() === 'btag');
593
- if (btagValue) {
594
- btagValue.value = this.btag;
595
- }
596
- }
597
- addTranslation(field) {
598
- if (TRANSLATIONS[this.language][field.name]) {
599
- Object.keys(TRANSLATIONS[this.language][field.name]).forEach((key) => {
600
- field[key] = TRANSLATIONS[this.language][field.name][key];
601
- });
602
- }
603
- }
604
- setInitialValidStatus(field) {
605
- var _a, _b;
606
- // Input type checkbox, with no validation are valid
607
- if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) == 'checkbox' && ((_b = field.validate) === null || _b === void 0 ? void 0 : _b.mandatory) == false) {
608
- return true;
609
- }
610
- //Inputs that have default value are valid.
611
- if (field.defaultValue !== null) {
612
- return true;
613
- }
614
- return false;
615
- }
616
- stepChange(action) {
617
- const stepNum = parseInt(this.registrationStep.replace('Step', ''));
618
- if (action === 'increment') {
619
- return 'Step' + (stepNum + 1);
620
- }
621
- if (action === 'decrement') {
622
- return 'Step' + (stepNum - 1);
623
- }
624
- }
625
- getInvalidStatus(listOfInputs) {
626
- return listOfInputs.filter(input => input.isValid == false).length > 0;
627
- }
628
- renderForm() {
629
- return this.forms.map((form, index) => {
630
- return h("form", { action: '.', id: `RegistrationForm${this.registrationStep}`, class: `registration__form ${this.registrationStep !== `Step${index + 1}` ? 'hidden' : ''}`, ref: el => this.form = el }, form[this.registrationStep] && form[this.registrationStep].map(input => h("general-input", { type: input.inputType, name: input.name, displayName: input.displayName, validation: input.validate, action: input.action || null, options: input.data
631
- ? (input.inputType.toLowerCase() == 'checkboxgroup' || input.inputType.toLowerCase() == 'togglecheckbox')
632
- ? input.data.subFields
633
- : input.data.values
634
- : [], defaultValue: input.defaultValue, autofilled: input.autofill, emitValue: this.emitValue, language: this.language, isDuplicateInput: input.isDuplicateInput, "client-styling": this.clientStyling, tooltip: input.tooltip, placeholder: input.placeholder == null ? '' : input.placeholder, dateFormat: this.dateFormat, "translation-url": this.translationUrl, emitOnClick: this.emitOnClick })), this.buttonInsideForm && this.renderButtons(), h("div", { class: 'registration__wrapper--flex' }, h("p", { class: 'registration__error-message', innerHTML: this.errorMessage })));
635
- });
636
- }
637
- ;
638
- renderButtons() {
639
- return (h("div", { class: `registration__buttons-wrapper ${this.autofilled ? 'registration__buttons-wrapper--autofilled' : ''}` }, this.isLoadingPOST
640
- && h("slot", { name: 'spinner' })
641
- && h("svg", { class: "spinner", viewBox: "0 0 50 50" }, h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" })), !this.isLoadingPOST && h("button", { class: `registration__button registration__button--next ${this.isFormValid ? '' : 'registration__button--disabled'}`, type: 'submit', form: `RegistrationForm${this.registrationStep}`, onClick: (e) => this.nextHandler(e), disabled: !this.isFormValid }, this.lastStep === this.registrationStep ? translate('doneButton', this.language) : translate('nextButton', this.language)), h("button", { class: `registration__button registration__button--back ${this.registrationStep == 'Step1' ? 'registration__button--first-step' : ''}`, onClick: (e) => this.backHandler(e) }, translate('backButton', this.language))));
642
- }
643
- render() {
644
- if (this.isLoading) {
645
- return h("p", null, "Please wait, loading ...");
646
- }
647
- return (h("div", { class: `registration registration__${this.registrationStep}` }, this.renderForm(), !this.buttonInsideForm && this.renderButtons()));
648
- }
649
- get host() { return this; }
650
- static get watchers() { return {
651
- "registrationStep": ["sendStep"],
652
- "clientStyling": ["handleStylingChange"],
653
- "clientStylingUrl": ["handleStylingUrlChange"],
654
- "forms": ["setFormValidity"],
655
- "btag": ["addBtag"]
656
- }; }
657
- static get style() { return generalRegistrationCss; }
658
- }, [1, "general-registration", {
659
- "endpoint": [513],
660
- "language": [513],
661
- "clientStyling": [1537, "client-styling"],
662
- "clientStylingUrl": [513, "client-styling-url"],
663
- "translationUrl": [513, "translation-url"],
664
- "dateFormat": [513, "date-format"],
665
- "buttonInsideForm": [516, "button-inside-form"],
666
- "btag": [513],
667
- "emitOnClick": [516, "emit-on-click"],
668
- "errorMessage": [32],
669
- "isFormValid": [32],
670
- "isLoading": [32],
671
- "isLoadingPOST": [32],
672
- "registrationStep": [32],
673
- "forms": [32],
674
- "limitStylingAppends": [32],
675
- "autofilled": [32]
676
- }, [[0, "sendValidityState", "checkInputsValidityHandler"], [0, "sendInputValue", "getInputsValueHandler"]]]);
677
- function defineCustomElement$1() {
678
- if (typeof customElements === "undefined") {
679
- return;
680
- }
681
- const components = ["general-registration", "checkbox-group-input", "checkbox-input", "date-input", "email-input", "general-input", "number-input", "password-input", "radio-input", "select-input", "tel-input", "text-input", "toggle-checkbox-input"];
682
- components.forEach(tagName => { switch (tagName) {
683
- case "general-registration":
684
- if (!customElements.get(tagName)) {
685
- customElements.define(tagName, GeneralRegistration$1);
686
- }
687
- break;
688
- case "checkbox-group-input":
689
- if (!customElements.get(tagName)) {
690
- defineCustomElement$d();
691
- }
692
- break;
693
- case "checkbox-input":
694
- if (!customElements.get(tagName)) {
695
- defineCustomElement$c();
696
- }
697
- break;
698
- case "date-input":
699
- if (!customElements.get(tagName)) {
700
- defineCustomElement$b();
701
- }
702
- break;
703
- case "email-input":
704
- if (!customElements.get(tagName)) {
705
- defineCustomElement$a();
706
- }
707
- break;
708
- case "general-input":
709
- if (!customElements.get(tagName)) {
710
- defineCustomElement$9();
711
- }
712
- break;
713
- case "number-input":
714
- if (!customElements.get(tagName)) {
715
- defineCustomElement$8();
716
- }
717
- break;
718
- case "password-input":
719
- if (!customElements.get(tagName)) {
720
- defineCustomElement$7();
721
- }
722
- break;
723
- case "radio-input":
724
- if (!customElements.get(tagName)) {
725
- defineCustomElement$6();
726
- }
727
- break;
728
- case "select-input":
729
- if (!customElements.get(tagName)) {
730
- defineCustomElement$5();
731
- }
732
- break;
733
- case "tel-input":
734
- if (!customElements.get(tagName)) {
735
- defineCustomElement$4();
736
- }
737
- break;
738
- case "text-input":
739
- if (!customElements.get(tagName)) {
740
- defineCustomElement$3();
741
- }
742
- break;
743
- case "toggle-checkbox-input":
744
- if (!customElements.get(tagName)) {
745
- defineCustomElement$2();
746
- }
747
- break;
748
- } });
749
- }
750
-
751
- const GeneralRegistration = GeneralRegistration$1;
752
- const defineCustomElement = defineCustomElement$1;
753
-
754
- export { GeneralRegistration, defineCustomElement };