@everymatrix/general-registration 1.44.0 → 1.45.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 (87) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/checkbox-group-input_13.cjs.entry.js +4839 -2731
  3. package/dist/cjs/general-registration.cjs.js +17 -11
  4. package/dist/cjs/index-f6c5854f.js +1331 -0
  5. package/dist/cjs/index.cjs.js +12 -14
  6. package/dist/cjs/loader.cjs.js +7 -13
  7. package/dist/collection/collection-manifest.json +3 -3
  8. package/dist/collection/components/general-registration/general-registration.css +0 -1
  9. package/dist/collection/components/general-registration/general-registration.js +762 -769
  10. package/dist/collection/components/general-registration/index.js +1 -0
  11. package/dist/collection/index.js +12 -14
  12. package/dist/collection/utils/locale.utils.js +292 -292
  13. package/dist/collection/utils/utils.js +1 -1
  14. package/dist/esm/app-globals-0f993ce5.js +3 -0
  15. package/dist/esm/checkbox-group-input_13.entry.js +4839 -2731
  16. package/dist/esm/general-registration.js +14 -11
  17. package/dist/esm/index-8b4a4c93.js +1302 -0
  18. package/dist/esm/index.js +12 -14
  19. package/dist/esm/loader.js +7 -13
  20. package/dist/general-registration/general-registration.esm.js +1 -1
  21. package/dist/general-registration/index.esm.js +1 -1
  22. package/dist/general-registration/p-35ed5ec5.js +2 -0
  23. package/dist/general-registration/p-af4bdf25.entry.js +5431 -0
  24. package/dist/general-registration/p-e1255160.js +1 -0
  25. package/dist/stencil.config.dev.js +17 -0
  26. package/dist/stencil.config.js +14 -19
  27. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-registration/.stencil/packages/stencil/general-input/src/utils/types.d.ts +87 -0
  28. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-registration/.stencil/packages/stencil/general-registration/stencil.config.d.ts +2 -0
  29. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-registration/.stencil/packages/stencil/general-registration/stencil.config.dev.d.ts +2 -0
  30. package/dist/types/components/general-registration/general-registration.d.ts +91 -91
  31. package/dist/types/components/general-registration/index.d.ts +1 -0
  32. package/dist/types/components.d.ts +18 -2
  33. package/dist/types/stencil-public-runtime.d.ts +142 -33
  34. package/dist/types/utils/locale.utils.d.ts +8 -8
  35. package/loader/cdn.js +1 -3
  36. package/loader/index.cjs.js +1 -3
  37. package/loader/index.d.ts +13 -1
  38. package/loader/index.es2017.js +1 -3
  39. package/loader/index.js +1 -3
  40. package/loader/package.json +1 -0
  41. package/package.json +9 -2
  42. package/dist/cjs/index-0b9241d1.js +0 -1360
  43. package/dist/components/active-mixin.js +0 -975
  44. package/dist/components/checkbox-group-input.js +0 -6
  45. package/dist/components/checkbox-group-input2.js +0 -1078
  46. package/dist/components/checkbox-input.js +0 -6
  47. package/dist/components/checkbox-input2.js +0 -132
  48. package/dist/components/date-input.js +0 -6
  49. package/dist/components/date-input2.js +0 -11556
  50. package/dist/components/email-input.js +0 -6
  51. package/dist/components/email-input2.js +0 -171
  52. package/dist/components/field-mixin.js +0 -12426
  53. package/dist/components/general-input.js +0 -6
  54. package/dist/components/general-input2.js +0 -350
  55. package/dist/components/general-registration.d.ts +0 -11
  56. package/dist/components/general-registration.js +0 -961
  57. package/dist/components/index.d.ts +0 -26
  58. package/dist/components/index.js +0 -20
  59. package/dist/components/input-field-shared-styles.js +0 -1211
  60. package/dist/components/number-input.js +0 -6
  61. package/dist/components/number-input2.js +0 -158
  62. package/dist/components/password-input.js +0 -6
  63. package/dist/components/password-input2.js +0 -1059
  64. package/dist/components/radio-input.js +0 -6
  65. package/dist/components/radio-input2.js +0 -114
  66. package/dist/components/select-input.js +0 -6
  67. package/dist/components/select-input2.js +0 -183
  68. package/dist/components/tel-input.js +0 -6
  69. package/dist/components/tel-input2.js +0 -197
  70. package/dist/components/text-input.js +0 -6
  71. package/dist/components/text-input2.js +0 -199
  72. package/dist/components/toggle-checkbox-input.js +0 -6
  73. package/dist/components/tooltipIcon.js +0 -146
  74. package/dist/components/vaadin-button.js +0 -490
  75. package/dist/components/vaadin-combo-box.js +0 -4512
  76. package/dist/components/virtual-keyboard-controller.js +0 -2001
  77. package/dist/esm/index-a42c182c.js +0 -1332
  78. package/dist/esm/polyfills/core-js.js +0 -11
  79. package/dist/esm/polyfills/css-shim.js +0 -1
  80. package/dist/esm/polyfills/dom.js +0 -79
  81. package/dist/esm/polyfills/es5-html-element.js +0 -1
  82. package/dist/esm/polyfills/index.js +0 -34
  83. package/dist/esm/polyfills/system.js +0 -6
  84. package/dist/general-registration/p-4ff02444.js +0 -1
  85. package/dist/general-registration/p-bfb3458d.entry.js +0 -3647
  86. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/types.d.ts +0 -87
  87. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/general-registration/.stencil/packages/general-registration/stencil.config.d.ts +0 -2
@@ -1,788 +1,781 @@
1
- import { Component, h, Listen, Prop, State, Watch, Event, Element } from '@stencil/core';
2
- import { getTranslations, translate, TRANSLATIONS, DEFAULT_LANGUAGE } from '../../utils/locale.utils';
3
- import '@everymatrix/general-input';
1
+ import { h } from "@stencil/core";
2
+ import { getTranslations, translate, TRANSLATIONS, DEFAULT_LANGUAGE } from "../../utils/locale.utils";
3
+ import "../../../../../general-input/dist/types/index";
4
4
  export class GeneralRegistration {
5
- constructor() {
6
- /**
7
- * Currently selected language
8
- */
9
- this.language = 'en';
10
- /**
11
- * Client custom styling via inline styles
12
- */
13
- this.clientStyling = '';
14
- /**
15
- * Client custom styling via url
16
- */
17
- this.clientStylingUrl = '';
18
- /**
19
- * Translations via URL
20
- */
21
- this.translationUrl = '';
22
- /**
23
- * Affiliate code to be passed in and sent in the registration.
24
- */
25
- this.btag = null;
26
- /**
27
- * Boolean flag that tells inputs to emit an event on click.
28
- */
29
- this.emitOnClick = false;
30
- this.isLoading = true;
31
- this.forms = [];
32
- this.limitStylingAppends = false;
33
- this.autofilled = false;
34
- this.listOfInputValues = [];
35
- this.listOfInputValidity = [];
36
- this.listOfActions = [];
37
- this.listOfInputs = [];
38
- this.emitValue = false;
39
- this.backButtonPressed = false;
40
- this.registerErrors = false;
41
- this.extraActions = [];
42
- this.registrationStepsState = {
43
- regId: null
44
- };
45
- this.setClientStyling = () => {
46
- let sheet = document.createElement('style');
47
- sheet.innerHTML = this.clientStyling;
48
- this.host.shadowRoot.prepend(sheet);
49
- };
50
- this.setClientStylingURL = () => {
51
- let url = new URL(this.clientStylingUrl);
52
- let cssFile = document.createElement('style');
53
- fetch(url.href)
54
- .then((res) => res.text())
55
- .then((data) => {
56
- cssFile.innerHTML = data;
57
- this.clientStyling = data;
58
- setTimeout(() => { this.host.shadowRoot.prepend(cssFile); }, 1);
59
- });
60
- };
61
- }
62
- sendStep() {
63
- this.registrationStepUpdated.emit(this.registrationStep);
64
- window.postMessage({ type: 'registrationStepUpdated', step: this.registrationStep }, window.location.href);
65
- }
66
- handleStylingChange(newValue, oldValue) {
67
- if (newValue !== oldValue)
68
- this.setClientStyling();
69
- }
70
- handleStylingUrlChange(newValue, oldValue) {
71
- if (newValue !== oldValue)
72
- this.setClientStylingURL();
73
- }
74
- setFormValidity() {
75
- this.errorMessage = '';
76
- if (this.listOfInputValidity) {
77
- this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
78
- }
79
- //Check for autofilled.
80
- if (this.listOfInputs.some(inputs => inputs.autofill)) {
81
- this.autofilled = true;
82
- }
83
- }
84
- addBtag() {
85
- this.addBtagValue();
86
- }
87
- checkInputsValidityHandler(event) {
88
- // Set isValid state of the input in the list.
89
- this.listOfInputValidity.find(input => input.name == event.detail.name).isValid = event.detail.valid;
90
- // Check if any one is invalid.
91
- this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
92
- }
93
- getInputsValueHandler(event) {
94
- this.listOfInputValues.find(input => {
95
- if (input.name == event.detail.name) {
96
- input.value = event.detail.value;
97
- input.type = event.detail.type || null;
98
- }
99
- });
100
- this.stepsStateMachine({ event: 'set', type: 'values' });
101
- }
102
- componentWillLoad() {
103
- return this.getRegisterConfig()
104
- .then((config) => {
105
- this.formatConfig(config);
106
- this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
107
- this.stepsStateMachine({ event: 'set', type: 'inputs' });
108
- });
109
- }
110
- componentDidLoad() {
111
- this.registrationWidgetLoaded.emit();
112
- window.postMessage({ type: 'registrationWidgetLoaded' }, window.location.href);
113
- if (!this.limitStylingAppends && this.host) {
114
- if (this.clientStyling)
115
- this.setClientStyling();
116
- if (this.clientStylingUrl)
117
- this.setClientStylingURL();
118
- this.limitStylingAppends = true;
119
- }
120
- }
121
- nextHandler(e) {
122
- e.preventDefault();
123
- // Trigger events in subwidgets.
124
- this.emitValue = true;
125
- this.setRegisterStep();
126
- }
127
- backHandler(e) {
128
- e.preventDefault();
129
- this.registrationStep = this.stepChange('decrement');
130
- this.stepsStateMachine({ event: 'get', type: 'inputs' });
131
- this.stepsStateMachine({ event: 'get', type: 'values' });
132
- }
133
- dispatchRegisterCredentialsEvent() {
134
- const userNameEmail = this.registrationStepsState['Step1']['registerUserData']['Email']['value'];
135
- const userPassword = this.registrationStepsState['Step1']['registerUserData']['Password']['value'];
136
- this.registerCredentialsEvent = new CustomEvent('RegisterCredentials', {
137
- bubbles: true,
138
- detail: {
139
- userNameEmail: userNameEmail,
140
- userPassword: userPassword
141
- }
142
- });
143
- window.dispatchEvent(this.registerCredentialsEvent);
144
- }
145
- stepsStateMachine(state) {
146
- switch (state.event) {
147
- case 'set':
148
- if (state.type == 'inputs') {
149
- this.registrationStepsState[this.registrationStep].fields = this.listOfInputs;
150
- this.registrationStepsState[this.registrationStep].actions = this.listOfActions;
151
- this.registrationStepsState[this.registrationStep].fieldsValidity = this.listOfInputValidity;
5
+ constructor() {
6
+ this.listOfInputValues = [];
7
+ this.listOfInputValidity = [];
8
+ this.listOfActions = [];
9
+ this.listOfInputs = [];
10
+ this.emitValue = false;
11
+ this.backButtonPressed = false;
12
+ this.registerErrors = false;
13
+ this.extraActions = [];
14
+ this.registrationStepsState = {
15
+ regId: null
16
+ };
17
+ this.setClientStyling = () => {
18
+ let sheet = document.createElement('style');
19
+ sheet.innerHTML = this.clientStyling;
20
+ this.host.shadowRoot.prepend(sheet);
21
+ };
22
+ this.setClientStylingURL = () => {
23
+ let url = new URL(this.clientStylingUrl);
24
+ let cssFile = document.createElement('style');
25
+ fetch(url.href)
26
+ .then((res) => res.text())
27
+ .then((data) => {
28
+ cssFile.innerHTML = data;
29
+ this.clientStyling = data;
30
+ setTimeout(() => { this.host.shadowRoot.prepend(cssFile); }, 1);
31
+ });
32
+ };
33
+ this.endpoint = undefined;
34
+ this.language = 'en';
35
+ this.clientStyling = '';
36
+ this.clientStylingUrl = '';
37
+ this.translationUrl = '';
38
+ this.dateFormat = undefined;
39
+ this.buttonInsideForm = undefined;
40
+ this.btag = null;
41
+ this.emitOnClick = false;
42
+ this.errorMessage = undefined;
43
+ this.isFormValid = undefined;
44
+ this.isLoading = true;
45
+ this.isLoadingPOST = undefined;
46
+ this.registrationStep = undefined;
47
+ this.forms = [];
48
+ this.limitStylingAppends = false;
49
+ this.autofilled = false;
50
+ }
51
+ sendStep() {
52
+ this.registrationStepUpdated.emit(this.registrationStep);
53
+ window.postMessage({ type: 'registrationStepUpdated', step: this.registrationStep }, window.location.href);
54
+ }
55
+ handleStylingChange(newValue, oldValue) {
56
+ if (newValue !== oldValue)
57
+ this.setClientStyling();
58
+ }
59
+ handleStylingUrlChange(newValue, oldValue) {
60
+ if (newValue !== oldValue)
61
+ this.setClientStylingURL();
62
+ }
63
+ setFormValidity() {
64
+ this.errorMessage = '';
65
+ if (this.listOfInputValidity) {
66
+ this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
152
67
  }
153
- if (state.type == 'values') {
154
- this.registrationStepsState[this.registrationStep].registerUserData = this.listOfInputValues.reduce((acc, curr) => {
155
- acc[curr.name] = { value: curr.value, isDuplicate: curr.isDuplicate };
156
- return acc;
157
- }, {});
68
+ //Check for autofilled.
69
+ if (this.listOfInputs.some(inputs => inputs.autofill)) {
70
+ this.autofilled = true;
158
71
  }
159
- localStorage.setItem('registrationStepsState', JSON.stringify(this.registrationStepsState));
160
- break;
161
- case 'get':
162
- const savedUserData = JSON.parse(localStorage.getItem('registrationStepsState'));
163
- if (!savedUserData)
164
- return;
165
- if (state.type == 'inputs') {
166
- this.listOfInputs = this.registrationStepsState[this.registrationStep].fields;
167
- this.listOfActions = this.registrationStepsState[this.registrationStep].actions;
168
- this.listOfInputValidity = this.registrationStepsState[this.registrationStep].fieldsValidity;
72
+ }
73
+ addBtag() {
74
+ this.addBtagValue();
75
+ }
76
+ checkInputsValidityHandler(event) {
77
+ // Set isValid state of the input in the list.
78
+ this.listOfInputValidity.find(input => input.name == event.detail.name).isValid = event.detail.valid;
79
+ // Check if any one is invalid.
80
+ this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
81
+ }
82
+ getInputsValueHandler(event) {
83
+ this.listOfInputValues.find(input => {
84
+ if (input.name == event.detail.name) {
85
+ input.value = event.detail.value;
86
+ input.type = event.detail.type || null;
87
+ }
88
+ });
89
+ this.stepsStateMachine({ event: 'set', type: 'values' });
90
+ }
91
+ componentWillLoad() {
92
+ return this.getRegisterConfig()
93
+ .then((config) => {
94
+ this.formatConfig(config);
95
+ this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
96
+ this.stepsStateMachine({ event: 'set', type: 'inputs' });
97
+ });
98
+ }
99
+ componentDidLoad() {
100
+ this.registrationWidgetLoaded.emit();
101
+ window.postMessage({ type: 'registrationWidgetLoaded' }, window.location.href);
102
+ if (!this.limitStylingAppends && this.host) {
103
+ if (this.clientStyling)
104
+ this.setClientStyling();
105
+ if (this.clientStylingUrl)
106
+ this.setClientStylingURL();
107
+ this.limitStylingAppends = true;
169
108
  }
170
- if (state.type == 'values') {
171
- const savedValues = savedUserData[this.registrationStep].registerUserData;
172
- this.listOfInputValues = Object.keys(savedValues).map(name => {
173
- return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
174
- });
175
- // Give to each field the user input as the default value.
176
- this.listOfInputValues.forEach(inputValue => {
177
- const input = this.listOfInputs.find(input => input.name === inputValue.name);
178
- if (input) {
179
- input.defaultValue = inputValue.value;
109
+ }
110
+ nextHandler(e) {
111
+ e.preventDefault();
112
+ // Trigger events in subwidgets.
113
+ this.emitValue = true;
114
+ this.setRegisterStep();
115
+ }
116
+ backHandler(e) {
117
+ e.preventDefault();
118
+ this.registrationStep = this.stepChange('decrement');
119
+ this.stepsStateMachine({ event: 'get', type: 'inputs' });
120
+ this.stepsStateMachine({ event: 'get', type: 'values' });
121
+ }
122
+ dispatchRegisterCredentialsEvent() {
123
+ const userNameEmail = this.registrationStepsState['Step1']['registerUserData']['Email']['value'];
124
+ const userPassword = this.registrationStepsState['Step1']['registerUserData']['Password']['value'];
125
+ this.registerCredentialsEvent = new CustomEvent('RegisterCredentials', {
126
+ bubbles: true,
127
+ detail: {
128
+ userNameEmail: userNameEmail,
129
+ userPassword: userPassword
180
130
  }
181
- });
131
+ });
132
+ window.dispatchEvent(this.registerCredentialsEvent);
133
+ }
134
+ stepsStateMachine(state) {
135
+ switch (state.event) {
136
+ case 'set':
137
+ if (state.type == 'inputs') {
138
+ this.registrationStepsState[this.registrationStep].fields = this.listOfInputs;
139
+ this.registrationStepsState[this.registrationStep].actions = this.listOfActions;
140
+ this.registrationStepsState[this.registrationStep].fieldsValidity = this.listOfInputValidity;
141
+ }
142
+ if (state.type == 'values') {
143
+ this.registrationStepsState[this.registrationStep].registerUserData = this.listOfInputValues.reduce((acc, curr) => {
144
+ acc[curr.name] = { value: curr.value, isDuplicate: curr.isDuplicate };
145
+ return acc;
146
+ }, {});
147
+ }
148
+ localStorage.setItem('registrationStepsState', JSON.stringify(this.registrationStepsState));
149
+ break;
150
+ case 'get':
151
+ const savedUserData = JSON.parse(localStorage.getItem('registrationStepsState'));
152
+ if (!savedUserData)
153
+ return;
154
+ if (state.type == 'inputs') {
155
+ this.listOfInputs = this.registrationStepsState[this.registrationStep].fields;
156
+ this.listOfActions = this.registrationStepsState[this.registrationStep].actions;
157
+ this.listOfInputValidity = this.registrationStepsState[this.registrationStep].fieldsValidity;
158
+ }
159
+ if (state.type == 'values') {
160
+ const savedValues = savedUserData[this.registrationStep].registerUserData;
161
+ this.listOfInputValues = Object.keys(savedValues).map(name => {
162
+ return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
163
+ });
164
+ // Give to each field the user input as the default value.
165
+ this.listOfInputValues.forEach(inputValue => {
166
+ const input = this.listOfInputs.find(input => input.name === inputValue.name);
167
+ if (input) {
168
+ input.defaultValue = inputValue.value;
169
+ }
170
+ });
171
+ }
172
+ this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
173
+ break;
182
174
  }
183
- this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
184
- break;
185
- }
186
- }
187
- getRegisterConfig(registrationID) {
188
- const url = new URL(`${this.endpoint}/v1/player/legislation/registration/config`);
189
- const headers = new Headers();
190
- headers.append('Content-Type', 'application/json');
191
- headers.append('Accept', 'application/json');
192
- if (registrationID) {
193
- url.searchParams.append('registrationId', registrationID);
194
- }
195
- const options = {
196
- method: 'GET',
197
- headers
198
- };
199
- return new Promise((resolve, reject) => {
200
- this.isLoading = true;
201
- fetch(url.href, options)
202
- .then((res) => res.json())
203
- .then((config) => {
204
- this.isLoading = false;
205
- resolve(config);
206
- }).catch((err) => {
207
- this.isLoading = false;
208
- console.error(err);
209
- reject(err);
210
- }).finally(() => {
211
- this.isLoading = false;
212
- });
213
- });
214
- }
215
- setRegisterStep() {
216
- this.isLoadingPOST = true;
217
- const url = new URL(`${this.endpoint}/v1/player/legislation/registration/step`);
218
- const registerStep = {
219
- registrationId: this.registrationID,
220
- registerUserDto: this.listOfInputValues
221
- .filter(input => !input.isDuplicate)
222
- .reduce((acc, curr) => {
223
- // Because the API is very robust, some values need to be split as separate entities.
224
- if (curr.name === 'TypeOfPublicArea') {
225
- acc[curr.name] = curr.value.toLowerCase();
175
+ }
176
+ getRegisterConfig(registrationID) {
177
+ const url = new URL(`${this.endpoint}/v1/player/legislation/registration/config`);
178
+ const headers = new Headers();
179
+ headers.append('Content-Type', 'application/json');
180
+ headers.append('Accept', 'application/json');
181
+ if (registrationID) {
182
+ url.searchParams.append('registrationId', registrationID);
226
183
  }
227
- else if (curr.type === 'tel') {
228
- //@ts-ignore
229
- acc['MobilePrefix'] = curr.value.prefix;
230
- //@ts-ignore
231
- acc[curr.name] = curr.value.phone;
184
+ const options = {
185
+ method: 'GET',
186
+ headers
187
+ };
188
+ return new Promise((resolve, reject) => {
189
+ this.isLoading = true;
190
+ fetch(url.href, options)
191
+ .then((res) => res.json())
192
+ .then((config) => {
193
+ this.isLoading = false;
194
+ resolve(config);
195
+ }).catch((err) => {
196
+ this.isLoading = false;
197
+ console.error(err);
198
+ reject(err);
199
+ }).finally(() => {
200
+ this.isLoading = false;
201
+ });
202
+ });
203
+ }
204
+ setRegisterStep() {
205
+ this.isLoadingPOST = true;
206
+ const url = new URL(`${this.endpoint}/v1/player/legislation/registration/step`);
207
+ const registerStep = {
208
+ registrationId: this.registrationID,
209
+ registerUserDto: this.listOfInputValues
210
+ .filter(input => !input.isDuplicate)
211
+ .reduce((acc, curr) => {
212
+ // Because the API is very robust, some values need to be split as separate entities.
213
+ if (curr.name === 'TypeOfPublicArea') {
214
+ acc[curr.name] = curr.value.toLowerCase();
215
+ }
216
+ else if (curr.type === 'tel') {
217
+ //@ts-ignore
218
+ acc['MobilePrefix'] = curr.value.prefix;
219
+ //@ts-ignore
220
+ acc[curr.name] = curr.value.phone;
221
+ }
222
+ else if (curr.type === 'checkboxgroup') {
223
+ // Skip adding the parent of the checkboxgroup as a key.
224
+ if (curr.value !== null) {
225
+ Object.entries(curr.value).forEach(([key, value]) => {
226
+ acc[key] = value ? 'true' : 'false';
227
+ });
228
+ }
229
+ }
230
+ else {
231
+ acc[curr.name] = curr.value;
232
+ }
233
+ return acc;
234
+ }, {}),
235
+ step: this.registrationStep,
236
+ };
237
+ const headers = new Headers();
238
+ headers.append('Content-Type', 'application/json');
239
+ headers.append('Accept', 'application/json');
240
+ const options = {
241
+ method: 'POST',
242
+ body: JSON.stringify(registerStep),
243
+ headers
244
+ };
245
+ fetch(url.href, options)
246
+ .then((res) => {
247
+ if (!res.ok) {
248
+ return res.json().then(error => {
249
+ this.errorCode = error.thirdPartyResponse.errorCode;
250
+ // Show the idomsoft error if it is the case
251
+ if (this.errorCode == 'GmErr_BadRequest_IdomsoftVerification_ShouldRetry') {
252
+ this.errorMessage = error.thirdPartyResponse.message;
253
+ }
254
+ else if (this.errorCode === 'GmErr_Forbidden_UserAccount_NavExcluded') {
255
+ this.errorMessage = translate(`${this.errorCode}`, this.language);
256
+ }
257
+ else if (this.errorCode == 'GmErr_BadRequest') {
258
+ this.errorMessage = error.thirdPartyResponse.message;
259
+ }
260
+ else {
261
+ this.errorMessage = translate(`${this.errorCode}`, this.language) || translate(`generalError`, this.language);
262
+ }
263
+ });
264
+ }
265
+ return res.json();
266
+ })
267
+ .then((data) => {
268
+ this.isLoadingPOST = false;
269
+ this.registrationID = data.registrationId;
270
+ if (this.listOfActions.some(action => action == '/register')) {
271
+ if (this.listOfActions.some(action => action == '/generate-2FA-code/Generate2FACode')) {
272
+ this.extraActions.push('2fa');
273
+ }
274
+ this.setRegister();
275
+ }
276
+ else {
277
+ // After sending the current step, increment and check if the next one is in state.
278
+ this.registrationStep = this.stepChange('increment');
279
+ // If step is present in state do NOT fetch the next config.
280
+ if (Object.keys(this.registrationStepsState).find(key => key == this.registrationStep)) {
281
+ // Use the one from state
282
+ this.stepsStateMachine({ event: 'get', type: 'inputs' });
283
+ this.stepsStateMachine({ event: 'get', type: 'values' });
284
+ }
285
+ else {
286
+ this.getRegisterConfig(this.registrationID).then((config) => {
287
+ // Format the new step config.
288
+ this.formatConfig(config);
289
+ // Set it in local storage.
290
+ this.stepsStateMachine({ event: 'set', type: 'inputs' });
291
+ });
292
+ }
293
+ }
294
+ })
295
+ .catch((err) => {
296
+ this.isLoadingPOST = false;
297
+ console.error(err);
298
+ }).finally(() => {
299
+ this.isLoadingPOST = false;
300
+ });
301
+ }
302
+ setRegister() {
303
+ this.isLoading = true;
304
+ this.registerErrors = false;
305
+ const url = new URL(`${this.endpoint}/v1/player/legislation/register`);
306
+ const headers = new Headers();
307
+ headers.append('Content-Type', 'application/json');
308
+ headers.append('Accept', 'application/json');
309
+ const options = {
310
+ method: 'PUT',
311
+ body: JSON.stringify({ registrationId: this.registrationID }),
312
+ headers
313
+ };
314
+ fetch(url.href, options)
315
+ .then((res) => {
316
+ if (!res.ok) {
317
+ this.registerErrors = true;
318
+ return res.json().then(error => {
319
+ this.errorCode = error.thirdPartyResponse.errorCode;
320
+ // Show the idomsoft error if it is the case
321
+ if (this.errorCode == 'GmErr_BadRequest_IdomsoftVerification_ShouldRetry') {
322
+ this.errorMessage = error.thirdPartyResponse.message;
323
+ }
324
+ else if (this.errorCode == 'GmErr_BadRequest') {
325
+ this.errorMessage = error.thirdPartyResponse.message;
326
+ }
327
+ else {
328
+ this.errorMessage = translate(`${this.errorCode}`, this.language) || translate(`generalError`, this.language);
329
+ }
330
+ window.postMessage({ type: 'registrationFailed', errorMessage: error === null || error === void 0 ? void 0 : error.thirdPartyResponse.message }, window.location.href);
331
+ window.postMessage({ type: 'WidgetNotification', data: {
332
+ type: 'error',
333
+ message: this.errorMessage
334
+ } }, window.location.href);
335
+ });
336
+ }
337
+ return res.json();
338
+ })
339
+ .then((data) => {
340
+ this.isLoading = false;
341
+ if (!this.registerErrors) {
342
+ this.dispatchRegisterCredentialsEvent();
343
+ window.postMessage({ type: 'registrationSuccessful', userId: data === null || data === void 0 ? void 0 : data.userId, extraActions: this.extraActions }, window.location.href);
344
+ window.postMessage({ type: 'WidgetNotification', data: {
345
+ type: 'success',
346
+ message: translate('successMessage', this.language)
347
+ } }, window.location.href);
348
+ }
349
+ })
350
+ .catch((err) => {
351
+ this.isLoading = false;
352
+ console.error(err);
353
+ })
354
+ .finally(() => {
355
+ this.isLoading = false;
356
+ });
357
+ }
358
+ formatConfig(config) {
359
+ // Populate the list of inputs
360
+ this.listOfInputs = config.content.fields.flatMap((field) => {
361
+ // Special case for inputs that need to be duplicated.
362
+ const duplicateInputRule = field.validate.custom.find(customRule => customRule.rule === 'duplicate-input');
363
+ const inputElement = Object.assign({}, field);
364
+ if (duplicateInputRule) {
365
+ const duplicateInput = Object.assign(Object.assign({}, field), { name: `${field.name}Duplicate`, displayName: duplicateInputRule.displayName, isDuplicateInput: true });
366
+ return [inputElement, duplicateInput];
367
+ }
368
+ else {
369
+ return [inputElement];
370
+ }
371
+ });
372
+ this.listOfInputValidity = this.listOfInputs.reduce((acc, field) => {
373
+ var _a;
374
+ // If the field is a togglecheckbox, add its subfields
375
+ if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "togglecheckbox") {
376
+ field.data.subFields.forEach(subfield => {
377
+ acc.push({
378
+ name: subfield.name,
379
+ isValid: this.setInitialValidStatus(subfield)
380
+ });
381
+ });
382
+ }
383
+ else {
384
+ acc.push({
385
+ name: field.name,
386
+ isValid: this.setInitialValidStatus(field)
387
+ });
388
+ }
389
+ return acc;
390
+ }, []);
391
+ this.listOfInputValues = this.listOfInputs.reduce((acc, field) => {
392
+ var _a, _b, _c;
393
+ // If the field type is a 'togglecheckbox', add its subfields
394
+ if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "togglecheckbox") {
395
+ field.data.subFields.forEach(subfield => {
396
+ var _a, _b;
397
+ acc.push({
398
+ name: subfield.name,
399
+ value: ((_a = subfield.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) == 'checkbox' ? 'false' : null,
400
+ isDuplicate: subfield.isDuplicateInput || false,
401
+ type: ((_b = field.inputType) === null || _b === void 0 ? void 0 : _b.toLowerCase()) == 'togglecheckbox'
402
+ ? 'togglecheckbox'
403
+ : null
404
+ });
405
+ });
406
+ }
407
+ else {
408
+ acc.push({
409
+ name: field.name,
410
+ value: ((_b = field.inputType) === null || _b === void 0 ? void 0 : _b.toLowerCase()) == 'checkbox' ? 'false' : null,
411
+ isDuplicate: field.isDuplicateInput || false,
412
+ type: ((_c = field.inputType) === null || _c === void 0 ? void 0 : _c.toLowerCase()) == 'checkboxgroup' ? 'checkboxgroup' : null
413
+ });
414
+ }
415
+ return acc;
416
+ }, []);
417
+ if (this.btag)
418
+ this.addBtagValue();
419
+ // Set the list of actions
420
+ this.listOfActions = config.content.actions.map(action => action);
421
+ this.registrationID = config.content.registrationID;
422
+ this.registrationStep = config.content.step;
423
+ if (this.listOfActions.some(action => action == '/register')) {
424
+ this.lastStep = this.registrationStep;
232
425
  }
233
- else if (curr.type === 'checkboxgroup') {
234
- // Skip adding the parent of the checkboxgroup as a key.
235
- if (curr.value !== null) {
236
- Object.entries(curr.value).forEach(([key, value]) => {
237
- acc[key] = value ? 'true' : 'false';
426
+ ;
427
+ // The translations for fields happens here.
428
+ if (this.translationUrl) {
429
+ getTranslations(this.translationUrl).then(() => {
430
+ this.listOfInputs.forEach(field => {
431
+ var _a, _b;
432
+ this.addTranslation(field);
433
+ // Logic for field types that have subfields
434
+ if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'togglecheckbox') {
435
+ field.data.subFields.forEach(subField => this.addTranslation(subField));
436
+ }
437
+ if (((_b = field.inputType) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'checkboxgroup') {
438
+ this.addTranslation(field);
439
+ field.data.subFields.forEach(subField => this.addTranslation(subField));
440
+ }
441
+ return field;
442
+ });
443
+ })
444
+ .catch((error) => {
445
+ console.error('Failed to fetch translations:', error);
446
+ }).finally(() => {
447
+ this.forms = [...this.forms, { [this.registrationStep]: this.listOfInputs }];
238
448
  });
239
- }
240
449
  }
241
450
  else {
242
- acc[curr.name] = curr.value;
451
+ this.forms = [...this.forms, { [this.registrationStep]: this.listOfInputs }];
243
452
  }
244
- return acc;
245
- }, {}),
246
- step: this.registrationStep,
247
- };
248
- const headers = new Headers();
249
- headers.append('Content-Type', 'application/json');
250
- headers.append('Accept', 'application/json');
251
- const options = {
252
- method: 'POST',
253
- body: JSON.stringify(registerStep),
254
- headers
255
- };
256
- fetch(url.href, options)
257
- .then((res) => {
258
- if (!res.ok) {
259
- return res.json().then(error => {
260
- this.errorCode = error.thirdPartyResponse.errorCode;
261
- // Show the idomsoft error if it is the case
262
- if (this.errorCode == 'GmErr_BadRequest_IdomsoftVerification_ShouldRetry') {
263
- this.errorMessage = error.thirdPartyResponse.message;
264
- }
265
- else if (this.errorCode === 'GmErr_Forbidden_UserAccount_NavExcluded') {
266
- this.errorMessage = translate(`${this.errorCode}`, this.language);
267
- }
268
- else if (this.errorCode == 'GmErr_BadRequest') {
269
- this.errorMessage = error.thirdPartyResponse.message;
270
- }
271
- else {
272
- this.errorMessage = translate(`${this.errorCode}`, this.language) || translate(`generalError`, this.language);
273
- }
274
- });
275
- }
276
- return res.json();
277
- })
278
- .then((data) => {
279
- this.isLoadingPOST = false;
280
- this.registrationID = data.registrationId;
281
- if (this.listOfActions.some(action => action == '/register')) {
282
- if (this.listOfActions.some(action => action == '/generate-2FA-code/Generate2FACode')) {
283
- this.extraActions.push('2fa');
453
+ // Add the step to the registrationStepsData
454
+ this.registrationStepsState.regId = this.registrationID;
455
+ if (!this.registrationStepsState[this.registrationStep]) {
456
+ this.registrationStepsState[this.registrationStep] = {
457
+ fields: [],
458
+ fieldsValidity: [],
459
+ registerUserData: {},
460
+ actions: []
461
+ };
284
462
  }
285
- this.setRegister();
286
- }
287
- else {
288
- // After sending the current step, increment and check if the next one is in state.
289
- this.registrationStep = this.stepChange('increment');
290
- // If step is present in state do NOT fetch the next config.
291
- if (Object.keys(this.registrationStepsState).find(key => key == this.registrationStep)) {
292
- // Use the one from state
293
- this.stepsStateMachine({ event: 'get', type: 'inputs' });
294
- this.stepsStateMachine({ event: 'get', type: 'values' });
463
+ }
464
+ addBtagValue() {
465
+ const btagField = this.listOfInputs.find(input => input.name.toLowerCase() === 'btag');
466
+ if (btagField) {
467
+ btagField.defaultValue = this.btag;
295
468
  }
296
- else {
297
- this.getRegisterConfig(this.registrationID).then((config) => {
298
- // Format the new step config.
299
- this.formatConfig(config);
300
- // Set it in local storage.
301
- this.stepsStateMachine({ event: 'set', type: 'inputs' });
302
- });
469
+ const btagValue = this.listOfInputValues.find(input => input.name.toLowerCase() === 'btag');
470
+ if (btagValue) {
471
+ btagValue.value = this.btag;
303
472
  }
304
- }
305
- })
306
- .catch((err) => {
307
- this.isLoadingPOST = false;
308
- console.error(err);
309
- }).finally(() => {
310
- this.isLoadingPOST = false;
311
- });
312
- }
313
- setRegister() {
314
- this.isLoading = true;
315
- this.registerErrors = false;
316
- const url = new URL(`${this.endpoint}/v1/player/legislation/register`);
317
- const headers = new Headers();
318
- headers.append('Content-Type', 'application/json');
319
- headers.append('Accept', 'application/json');
320
- const options = {
321
- method: 'PUT',
322
- body: JSON.stringify({ registrationId: this.registrationID }),
323
- headers
324
- };
325
- fetch(url.href, options)
326
- .then((res) => {
327
- if (!res.ok) {
328
- this.registerErrors = true;
329
- return res.json().then(error => {
330
- this.errorCode = error.thirdPartyResponse.errorCode;
331
- // Show the idomsoft error if it is the case
332
- if (this.errorCode == 'GmErr_BadRequest_IdomsoftVerification_ShouldRetry') {
333
- this.errorMessage = error.thirdPartyResponse.message;
334
- }
335
- else if (this.errorCode == 'GmErr_BadRequest') {
336
- this.errorMessage = error.thirdPartyResponse.message;
337
- }
338
- else {
339
- this.errorMessage = translate(`${this.errorCode}`, this.language) || translate(`generalError`, this.language);
340
- }
341
- window.postMessage({ type: 'registrationFailed', errorMessage: error === null || error === void 0 ? void 0 : error.thirdPartyResponse.message }, window.location.href);
342
- window.postMessage({ type: 'WidgetNotification', data: {
343
- type: 'error',
344
- message: this.errorMessage
345
- } }, window.location.href);
346
- });
347
- }
348
- return res.json();
349
- })
350
- .then((data) => {
351
- this.isLoading = false;
352
- if (!this.registerErrors) {
353
- this.dispatchRegisterCredentialsEvent();
354
- window.postMessage({ type: 'registrationSuccessful', userId: data === null || data === void 0 ? void 0 : data.userId, extraActions: this.extraActions }, window.location.href);
355
- window.postMessage({ type: 'WidgetNotification', data: {
356
- type: 'success',
357
- message: translate('successMessage', this.language)
358
- } }, window.location.href);
359
- }
360
- })
361
- .catch((err) => {
362
- this.isLoading = false;
363
- console.error(err);
364
- })
365
- .finally(() => {
366
- this.isLoading = false;
367
- });
368
- }
369
- formatConfig(config) {
370
- // Populate the list of inputs
371
- this.listOfInputs = config.content.fields.flatMap((field) => {
372
- // Special case for inputs that need to be duplicated.
373
- const duplicateInputRule = field.validate.custom.find(customRule => customRule.rule === 'duplicate-input');
374
- const inputElement = Object.assign({}, field);
375
- if (duplicateInputRule) {
376
- const duplicateInput = Object.assign(Object.assign({}, field), { name: `${field.name}Duplicate`, displayName: duplicateInputRule.displayName, isDuplicateInput: true });
377
- return [inputElement, duplicateInput];
378
- }
379
- else {
380
- return [inputElement];
381
- }
382
- });
383
- this.listOfInputValidity = this.listOfInputs.reduce((acc, field) => {
384
- var _a;
385
- // If the field is a togglecheckbox, add its subfields
386
- if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "togglecheckbox") {
387
- field.data.subFields.forEach(subfield => {
388
- acc.push({
389
- name: subfield.name,
390
- isValid: this.setInitialValidStatus(subfield)
391
- });
392
- });
393
- }
394
- else {
395
- acc.push({
396
- name: field.name,
397
- isValid: this.setInitialValidStatus(field)
398
- });
399
- }
400
- return acc;
401
- }, []);
402
- this.listOfInputValues = this.listOfInputs.reduce((acc, field) => {
403
- var _a, _b, _c;
404
- // If the field type is a 'togglecheckbox', add its subfields
405
- if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "togglecheckbox") {
406
- field.data.subFields.forEach(subfield => {
407
- var _a, _b;
408
- acc.push({
409
- name: subfield.name,
410
- value: ((_a = subfield.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) == 'checkbox' ? 'false' : null,
411
- isDuplicate: subfield.isDuplicateInput || false,
412
- type: ((_b = field.inputType) === null || _b === void 0 ? void 0 : _b.toLowerCase()) == 'togglecheckbox'
413
- ? 'togglecheckbox'
414
- : null
415
- });
416
- });
417
- }
418
- else {
419
- acc.push({
420
- name: field.name,
421
- value: ((_b = field.inputType) === null || _b === void 0 ? void 0 : _b.toLowerCase()) == 'checkbox' ? 'false' : null,
422
- isDuplicate: field.isDuplicateInput || false,
423
- type: ((_c = field.inputType) === null || _c === void 0 ? void 0 : _c.toLowerCase()) == 'checkboxgroup' ? 'checkboxgroup' : null
473
+ }
474
+ addTranslation(field) {
475
+ const lang = TRANSLATIONS[this.language] ? this.language : DEFAULT_LANGUAGE;
476
+ if (TRANSLATIONS[lang][field.name]) {
477
+ Object.keys(TRANSLATIONS[this.language][field.name]).forEach((key) => {
478
+ field[key] = TRANSLATIONS[this.language][field.name][key];
479
+ });
480
+ }
481
+ }
482
+ setInitialValidStatus(field) {
483
+ var _a, _b;
484
+ // Input type checkbox, with no validation are valid
485
+ 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) {
486
+ return true;
487
+ }
488
+ //Inputs that have default value are valid.
489
+ if (field.defaultValue !== null) {
490
+ return true;
491
+ }
492
+ return false;
493
+ }
494
+ stepChange(action) {
495
+ const stepNum = parseInt(this.registrationStep.replace('Step', ''));
496
+ if (action === 'increment') {
497
+ return 'Step' + (stepNum + 1);
498
+ }
499
+ if (action === 'decrement') {
500
+ return 'Step' + (stepNum - 1);
501
+ }
502
+ }
503
+ getInvalidStatus(listOfInputs) {
504
+ return listOfInputs.filter(input => input.isValid == false).length > 0;
505
+ }
506
+ renderForm() {
507
+ return this.forms.map((form, index) => {
508
+ 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
509
+ ? (input.inputType.toLowerCase() == 'checkboxgroup' || input.inputType.toLowerCase() == 'togglecheckbox')
510
+ ? input.data.subFields
511
+ : input.data.values
512
+ : [], 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 })));
424
513
  });
425
- }
426
- return acc;
427
- }, []);
428
- if (this.btag)
429
- this.addBtagValue();
430
- // Set the list of actions
431
- this.listOfActions = config.content.actions.map(action => action);
432
- this.registrationID = config.content.registrationID;
433
- this.registrationStep = config.content.step;
434
- if (this.listOfActions.some(action => action == '/register')) {
435
- this.lastStep = this.registrationStep;
436
514
  }
437
515
  ;
438
- // The translations for fields happens here.
439
- if (this.translationUrl) {
440
- getTranslations(this.translationUrl).then(() => {
441
- this.listOfInputs.forEach(field => {
442
- var _a, _b;
443
- this.addTranslation(field);
444
- // Logic for field types that have subfields
445
- if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'togglecheckbox') {
446
- field.data.subFields.forEach(subField => this.addTranslation(subField));
447
- }
448
- if (((_b = field.inputType) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'checkboxgroup') {
449
- this.addTranslation(field);
450
- field.data.subFields.forEach(subField => this.addTranslation(subField));
451
- }
452
- return field;
453
- });
454
- })
455
- .catch((error) => {
456
- console.error('Failed to fetch translations:', error);
457
- }).finally(() => {
458
- this.forms = [...this.forms, { [this.registrationStep]: this.listOfInputs }];
459
- });
460
- }
461
- else {
462
- this.forms = [...this.forms, { [this.registrationStep]: this.listOfInputs }];
463
- }
464
- // Add the step to the registrationStepsData
465
- this.registrationStepsState.regId = this.registrationID;
466
- if (!this.registrationStepsState[this.registrationStep]) {
467
- this.registrationStepsState[this.registrationStep] = {
468
- fields: [],
469
- fieldsValidity: [],
470
- registerUserData: {},
471
- actions: []
472
- };
473
- }
474
- }
475
- addBtagValue() {
476
- const btagField = this.listOfInputs.find(input => input.name.toLowerCase() === 'btag');
477
- if (btagField) {
478
- btagField.defaultValue = this.btag;
479
- }
480
- const btagValue = this.listOfInputValues.find(input => input.name.toLowerCase() === 'btag');
481
- if (btagValue) {
482
- btagValue.value = this.btag;
483
- }
484
- }
485
- addTranslation(field) {
486
- const lang = TRANSLATIONS[this.language] ? this.language : DEFAULT_LANGUAGE;
487
- if (TRANSLATIONS[lang][field.name]) {
488
- Object.keys(TRANSLATIONS[this.language][field.name]).forEach((key) => {
489
- field[key] = TRANSLATIONS[this.language][field.name][key];
490
- });
491
- }
492
- }
493
- setInitialValidStatus(field) {
494
- var _a, _b;
495
- // Input type checkbox, with no validation are valid
496
- 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) {
497
- return true;
498
- }
499
- //Inputs that have default value are valid.
500
- if (field.defaultValue !== null) {
501
- return true;
502
- }
503
- return false;
504
- }
505
- stepChange(action) {
506
- const stepNum = parseInt(this.registrationStep.replace('Step', ''));
507
- if (action === 'increment') {
508
- return 'Step' + (stepNum + 1);
509
- }
510
- if (action === 'decrement') {
511
- return 'Step' + (stepNum - 1);
512
- }
513
- }
514
- getInvalidStatus(listOfInputs) {
515
- return listOfInputs.filter(input => input.isValid == false).length > 0;
516
- }
517
- renderForm() {
518
- return this.forms.map((form, index) => {
519
- return h("form", { action: '.', id: `RegistrationForm${this.registrationStep}`, class: `registration__form ${this.registrationStep !== `Step${index + 1}` ? 'hidden' : ''}`, ref: el => this.form = el },
520
- 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
521
- ? (input.inputType.toLowerCase() == 'checkboxgroup' || input.inputType.toLowerCase() == 'togglecheckbox')
522
- ? input.data.subFields
523
- : input.data.values
524
- : [], 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 })),
525
- this.buttonInsideForm && this.renderButtons(),
526
- h("div", { class: 'registration__wrapper--flex' },
527
- h("p", { class: 'registration__error-message', innerHTML: this.errorMessage })));
528
- });
529
- }
530
- ;
531
- renderButtons() {
532
- return (h("div", { class: `registration__buttons-wrapper ${this.autofilled ? 'registration__buttons-wrapper--autofilled' : ''}` },
533
- this.isLoadingPOST
534
- && h("slot", { name: 'spinner' })
535
- && h("svg", { class: "spinner", viewBox: "0 0 50 50" },
536
- h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" })),
537
- !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)),
538
- h("button", { class: `registration__button registration__button--back ${this.registrationStep == 'Step1' ? 'registration__button--first-step' : ''}`, onClick: (e) => this.backHandler(e) }, translate('backButton', this.language))));
539
- }
540
- render() {
541
- if (this.isLoading) {
542
- return h("p", null, "Please wait, loading ...");
543
- }
544
- return (h("div", { class: `registration registration__${this.registrationStep}` },
545
- this.renderForm(),
546
- !this.buttonInsideForm && this.renderButtons()));
547
- }
548
- static get is() { return "general-registration"; }
549
- static get encapsulation() { return "shadow"; }
550
- static get originalStyleUrls() { return {
551
- "$": ["general-registration.scss"]
552
- }; }
553
- static get styleUrls() { return {
554
- "$": ["general-registration.css"]
555
- }; }
556
- static get properties() { return {
557
- "endpoint": {
558
- "type": "string",
559
- "mutable": false,
560
- "complexType": {
561
- "original": "string",
562
- "resolved": "string",
563
- "references": {}
564
- },
565
- "required": true,
566
- "optional": false,
567
- "docs": {
568
- "tags": [],
569
- "text": "NorWAy Endpoint for all the calls."
570
- },
571
- "attribute": "endpoint",
572
- "reflect": true
573
- },
574
- "language": {
575
- "type": "string",
576
- "mutable": false,
577
- "complexType": {
578
- "original": "string",
579
- "resolved": "string",
580
- "references": {}
581
- },
582
- "required": false,
583
- "optional": false,
584
- "docs": {
585
- "tags": [],
586
- "text": "Currently selected language"
587
- },
588
- "attribute": "language",
589
- "reflect": true,
590
- "defaultValue": "'en'"
591
- },
592
- "clientStyling": {
593
- "type": "string",
594
- "mutable": true,
595
- "complexType": {
596
- "original": "string",
597
- "resolved": "string",
598
- "references": {}
599
- },
600
- "required": false,
601
- "optional": false,
602
- "docs": {
603
- "tags": [],
604
- "text": "Client custom styling via inline styles"
605
- },
606
- "attribute": "client-styling",
607
- "reflect": true,
608
- "defaultValue": "''"
609
- },
610
- "clientStylingUrl": {
611
- "type": "string",
612
- "mutable": false,
613
- "complexType": {
614
- "original": "string",
615
- "resolved": "string",
616
- "references": {}
617
- },
618
- "required": false,
619
- "optional": false,
620
- "docs": {
621
- "tags": [],
622
- "text": "Client custom styling via url"
623
- },
624
- "attribute": "client-styling-url",
625
- "reflect": true,
626
- "defaultValue": "''"
627
- },
628
- "translationUrl": {
629
- "type": "string",
630
- "mutable": false,
631
- "complexType": {
632
- "original": "string",
633
- "resolved": "string",
634
- "references": {}
635
- },
636
- "required": false,
637
- "optional": false,
638
- "docs": {
639
- "tags": [],
640
- "text": "Translations via URL"
641
- },
642
- "attribute": "translation-url",
643
- "reflect": true,
644
- "defaultValue": "''"
645
- },
646
- "dateFormat": {
647
- "type": "string",
648
- "mutable": false,
649
- "complexType": {
650
- "original": "string",
651
- "resolved": "string",
652
- "references": {}
653
- },
654
- "required": false,
655
- "optional": false,
656
- "docs": {
657
- "tags": [],
658
- "text": "Date format for date picker"
659
- },
660
- "attribute": "date-format",
661
- "reflect": true
662
- },
663
- "buttonInsideForm": {
664
- "type": "boolean",
665
- "mutable": false,
666
- "complexType": {
667
- "original": "boolean",
668
- "resolved": "boolean",
669
- "references": {}
670
- },
671
- "required": true,
672
- "optional": false,
673
- "docs": {
674
- "tags": [],
675
- "text": "Boolean that decides the position of the button. e.g. button inside -- true / outside -- false the form."
676
- },
677
- "attribute": "button-inside-form",
678
- "reflect": true
679
- },
680
- "btag": {
681
- "type": "string",
682
- "mutable": false,
683
- "complexType": {
684
- "original": "string",
685
- "resolved": "string",
686
- "references": {}
687
- },
688
- "required": false,
689
- "optional": false,
690
- "docs": {
691
- "tags": [],
692
- "text": "Affiliate code to be passed in and sent in the registration."
693
- },
694
- "attribute": "btag",
695
- "reflect": true,
696
- "defaultValue": "null"
697
- },
698
- "emitOnClick": {
699
- "type": "boolean",
700
- "mutable": false,
701
- "complexType": {
702
- "original": "boolean",
703
- "resolved": "boolean",
704
- "references": {}
705
- },
706
- "required": false,
707
- "optional": false,
708
- "docs": {
709
- "tags": [],
710
- "text": "Boolean flag that tells inputs to emit an event on click."
711
- },
712
- "attribute": "emit-on-click",
713
- "reflect": true,
714
- "defaultValue": "false"
715
- }
716
- }; }
717
- static get states() { return {
718
- "errorMessage": {},
719
- "isFormValid": {},
720
- "isLoading": {},
721
- "isLoadingPOST": {},
722
- "registrationStep": {},
723
- "forms": {},
724
- "limitStylingAppends": {},
725
- "autofilled": {}
726
- }; }
727
- static get events() { return [{
728
- "method": "registrationWidgetLoaded",
729
- "name": "registrationWidgetLoaded",
730
- "bubbles": true,
731
- "cancelable": true,
732
- "composed": true,
733
- "docs": {
734
- "tags": [],
735
- "text": ""
736
- },
737
- "complexType": {
738
- "original": "any",
739
- "resolved": "any",
740
- "references": {}
741
- }
742
- }, {
743
- "method": "registrationStepUpdated",
744
- "name": "registrationStepUpdated",
745
- "bubbles": true,
746
- "cancelable": true,
747
- "composed": true,
748
- "docs": {
749
- "tags": [],
750
- "text": ""
751
- },
752
- "complexType": {
753
- "original": "string",
754
- "resolved": "string",
755
- "references": {}
756
- }
757
- }]; }
758
- static get elementRef() { return "host"; }
759
- static get watchers() { return [{
760
- "propName": "registrationStep",
761
- "methodName": "sendStep"
762
- }, {
763
- "propName": "clientStyling",
764
- "methodName": "handleStylingChange"
765
- }, {
766
- "propName": "clientStylingUrl",
767
- "methodName": "handleStylingUrlChange"
768
- }, {
769
- "propName": "forms",
770
- "methodName": "setFormValidity"
771
- }, {
772
- "propName": "btag",
773
- "methodName": "addBtag"
774
- }]; }
775
- static get listeners() { return [{
776
- "name": "sendValidityState",
777
- "method": "checkInputsValidityHandler",
778
- "target": undefined,
779
- "capture": false,
780
- "passive": false
781
- }, {
782
- "name": "sendInputValue",
783
- "method": "getInputsValueHandler",
784
- "target": undefined,
785
- "capture": false,
786
- "passive": false
787
- }]; }
516
+ renderButtons() {
517
+ return (h("div", { class: `registration__buttons-wrapper ${this.autofilled ? 'registration__buttons-wrapper--autofilled' : ''}` }, this.isLoadingPOST
518
+ && h("slot", { name: 'spinner' })
519
+ && 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))));
520
+ }
521
+ render() {
522
+ if (this.isLoading) {
523
+ return h("p", null, "Please wait, loading ...");
524
+ }
525
+ return (h("div", { class: `registration registration__${this.registrationStep}` }, this.renderForm(), !this.buttonInsideForm && this.renderButtons()));
526
+ }
527
+ static get is() { return "general-registration"; }
528
+ static get encapsulation() { return "shadow"; }
529
+ static get originalStyleUrls() {
530
+ return {
531
+ "$": ["general-registration.scss"]
532
+ };
533
+ }
534
+ static get styleUrls() {
535
+ return {
536
+ "$": ["general-registration.css"]
537
+ };
538
+ }
539
+ static get properties() {
540
+ return {
541
+ "endpoint": {
542
+ "type": "string",
543
+ "mutable": false,
544
+ "complexType": {
545
+ "original": "string",
546
+ "resolved": "string",
547
+ "references": {}
548
+ },
549
+ "required": true,
550
+ "optional": false,
551
+ "docs": {
552
+ "tags": [],
553
+ "text": "NorWAy Endpoint for all the calls."
554
+ },
555
+ "attribute": "endpoint",
556
+ "reflect": true
557
+ },
558
+ "language": {
559
+ "type": "string",
560
+ "mutable": false,
561
+ "complexType": {
562
+ "original": "string",
563
+ "resolved": "string",
564
+ "references": {}
565
+ },
566
+ "required": false,
567
+ "optional": false,
568
+ "docs": {
569
+ "tags": [],
570
+ "text": "Currently selected language"
571
+ },
572
+ "attribute": "language",
573
+ "reflect": true,
574
+ "defaultValue": "'en'"
575
+ },
576
+ "clientStyling": {
577
+ "type": "string",
578
+ "mutable": true,
579
+ "complexType": {
580
+ "original": "string",
581
+ "resolved": "string",
582
+ "references": {}
583
+ },
584
+ "required": false,
585
+ "optional": false,
586
+ "docs": {
587
+ "tags": [],
588
+ "text": "Client custom styling via inline styles"
589
+ },
590
+ "attribute": "client-styling",
591
+ "reflect": true,
592
+ "defaultValue": "''"
593
+ },
594
+ "clientStylingUrl": {
595
+ "type": "string",
596
+ "mutable": false,
597
+ "complexType": {
598
+ "original": "string",
599
+ "resolved": "string",
600
+ "references": {}
601
+ },
602
+ "required": false,
603
+ "optional": false,
604
+ "docs": {
605
+ "tags": [],
606
+ "text": "Client custom styling via url"
607
+ },
608
+ "attribute": "client-styling-url",
609
+ "reflect": true,
610
+ "defaultValue": "''"
611
+ },
612
+ "translationUrl": {
613
+ "type": "string",
614
+ "mutable": false,
615
+ "complexType": {
616
+ "original": "string",
617
+ "resolved": "string",
618
+ "references": {}
619
+ },
620
+ "required": false,
621
+ "optional": false,
622
+ "docs": {
623
+ "tags": [],
624
+ "text": "Translations via URL"
625
+ },
626
+ "attribute": "translation-url",
627
+ "reflect": true,
628
+ "defaultValue": "''"
629
+ },
630
+ "dateFormat": {
631
+ "type": "string",
632
+ "mutable": false,
633
+ "complexType": {
634
+ "original": "string",
635
+ "resolved": "string",
636
+ "references": {}
637
+ },
638
+ "required": false,
639
+ "optional": false,
640
+ "docs": {
641
+ "tags": [],
642
+ "text": "Date format for date picker"
643
+ },
644
+ "attribute": "date-format",
645
+ "reflect": true
646
+ },
647
+ "buttonInsideForm": {
648
+ "type": "boolean",
649
+ "mutable": false,
650
+ "complexType": {
651
+ "original": "boolean",
652
+ "resolved": "boolean",
653
+ "references": {}
654
+ },
655
+ "required": true,
656
+ "optional": false,
657
+ "docs": {
658
+ "tags": [],
659
+ "text": "Boolean that decides the position of the button. e.g. button inside -- true / outside -- false the form."
660
+ },
661
+ "attribute": "button-inside-form",
662
+ "reflect": true
663
+ },
664
+ "btag": {
665
+ "type": "string",
666
+ "mutable": false,
667
+ "complexType": {
668
+ "original": "string",
669
+ "resolved": "string",
670
+ "references": {}
671
+ },
672
+ "required": false,
673
+ "optional": false,
674
+ "docs": {
675
+ "tags": [],
676
+ "text": "Affiliate code to be passed in and sent in the registration."
677
+ },
678
+ "attribute": "btag",
679
+ "reflect": true,
680
+ "defaultValue": "null"
681
+ },
682
+ "emitOnClick": {
683
+ "type": "boolean",
684
+ "mutable": false,
685
+ "complexType": {
686
+ "original": "boolean",
687
+ "resolved": "boolean",
688
+ "references": {}
689
+ },
690
+ "required": false,
691
+ "optional": false,
692
+ "docs": {
693
+ "tags": [],
694
+ "text": "Boolean flag that tells inputs to emit an event on click."
695
+ },
696
+ "attribute": "emit-on-click",
697
+ "reflect": true,
698
+ "defaultValue": "false"
699
+ }
700
+ };
701
+ }
702
+ static get states() {
703
+ return {
704
+ "errorMessage": {},
705
+ "isFormValid": {},
706
+ "isLoading": {},
707
+ "isLoadingPOST": {},
708
+ "registrationStep": {},
709
+ "forms": {},
710
+ "limitStylingAppends": {},
711
+ "autofilled": {}
712
+ };
713
+ }
714
+ static get events() {
715
+ return [{
716
+ "method": "registrationWidgetLoaded",
717
+ "name": "registrationWidgetLoaded",
718
+ "bubbles": true,
719
+ "cancelable": true,
720
+ "composed": true,
721
+ "docs": {
722
+ "tags": [],
723
+ "text": ""
724
+ },
725
+ "complexType": {
726
+ "original": "any",
727
+ "resolved": "any",
728
+ "references": {}
729
+ }
730
+ }, {
731
+ "method": "registrationStepUpdated",
732
+ "name": "registrationStepUpdated",
733
+ "bubbles": true,
734
+ "cancelable": true,
735
+ "composed": true,
736
+ "docs": {
737
+ "tags": [],
738
+ "text": ""
739
+ },
740
+ "complexType": {
741
+ "original": "string",
742
+ "resolved": "string",
743
+ "references": {}
744
+ }
745
+ }];
746
+ }
747
+ static get elementRef() { return "host"; }
748
+ static get watchers() {
749
+ return [{
750
+ "propName": "registrationStep",
751
+ "methodName": "sendStep"
752
+ }, {
753
+ "propName": "clientStyling",
754
+ "methodName": "handleStylingChange"
755
+ }, {
756
+ "propName": "clientStylingUrl",
757
+ "methodName": "handleStylingUrlChange"
758
+ }, {
759
+ "propName": "forms",
760
+ "methodName": "setFormValidity"
761
+ }, {
762
+ "propName": "btag",
763
+ "methodName": "addBtag"
764
+ }];
765
+ }
766
+ static get listeners() {
767
+ return [{
768
+ "name": "sendValidityState",
769
+ "method": "checkInputsValidityHandler",
770
+ "target": undefined,
771
+ "capture": false,
772
+ "passive": false
773
+ }, {
774
+ "name": "sendInputValue",
775
+ "method": "getInputsValueHandler",
776
+ "target": undefined,
777
+ "capture": false,
778
+ "passive": false
779
+ }];
780
+ }
788
781
  }