@everymatrix/general-registration 1.10.4 → 1.10.10
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.
- package/dist/cjs/checkbox-input_11.cjs.entry.js +1118 -487
- package/dist/cjs/general-registration.cjs.js +2 -2
- package/dist/cjs/{index-9a07d1e9.js → index-68f93e1e.js} +9 -5
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/general-registration/general-registration.css +40 -14
- package/dist/collection/components/general-registration/general-registration.js +153 -300
- package/dist/components/checkbox-input2.js +8 -2
- package/dist/components/date-input2.js +19 -1441
- package/dist/components/email-input2.js +28 -9
- package/dist/components/general-input2.js +6 -6
- package/dist/components/general-registration.js +112 -274
- package/dist/components/input-field-shared-styles.js +13776 -0
- package/dist/components/locale.utils.js +1 -1
- package/dist/components/number-input2.js +8 -2
- package/dist/components/password-input2.js +748 -9
- package/dist/components/pattern-mixin.js +84 -0
- package/dist/components/radio-input2.js +1 -1
- package/dist/components/select-input2.js +8 -4
- package/dist/components/tel-input2.js +22 -10
- package/dist/components/text-input2.js +27 -18
- package/dist/components/vaadin-button.js +1432 -0
- package/dist/components/vaadin-combo-box.js +3 -82
- package/dist/components/virtual-keyboard-controller.js +2136 -15909
- package/dist/esm/checkbox-input_11.entry.js +1118 -487
- package/dist/esm/general-registration.js +2 -2
- package/dist/esm/{index-0505440f.js → index-16916adb.js} +9 -5
- package/dist/esm/loader.js +2 -2
- package/dist/general-registration/general-registration.esm.js +1 -1
- package/dist/general-registration/p-8f644809.js +1 -0
- package/dist/general-registration/{p-6a27a1e0.entry.js → p-fb5bf415.entry.js} +210 -100
- package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/types.d.ts +6 -4
- package/dist/types/components/general-registration/general-registration.d.ts +20 -284
- package/dist/types/components.d.ts +11 -17
- package/package.json +3 -2
- package/dist/general-registration/p-1a88a312.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
2
|
import { d as defineCustomElement$b } from './checkbox-input2.js';
|
|
3
3
|
import { d as defineCustomElement$a } from './date-input2.js';
|
|
4
4
|
import { d as defineCustomElement$9 } from './email-input2.js';
|
|
@@ -15,7 +15,7 @@ const SUPPORTED_LANGUAGES = ['ro', 'en'];
|
|
|
15
15
|
const TRANSLATIONS = {
|
|
16
16
|
en: {
|
|
17
17
|
dateError: 'The selected date should be between {min} and {max}',
|
|
18
|
-
numberLengthError: 'The number should be between
|
|
18
|
+
numberLengthError: 'The number should be between {min} and {max}',
|
|
19
19
|
lengthError: `The length should be between {minLength} and {maxLength}`,
|
|
20
20
|
requiredError: 'This input is required.',
|
|
21
21
|
nextButton: 'Next',
|
|
@@ -39,240 +39,56 @@ const translate = (key, customLang, values) => {
|
|
|
39
39
|
return translation;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
const generalRegistrationCss = "
|
|
42
|
+
const generalRegistrationCss = "*,\n*::before,\n*::after {\n padding: 0;\n margin: 0;\n box-sizing: border-box;\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__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: row-reverse;\n justify-content: space-around;\n align-items: center;\n}\n.registration__button {\n text-transform: uppercase;\n width: 250px;\n height: 40px;\n border-radius: 3px;\n}\n.registration__button:hover {\n opacity: 0.8;\n}\n.registration__button:active {\n opacity: 1;\n}\n.registration__button--next {\n color: #FFFFFF;\n background-color: #B0B0B0;\n border: none;\n}\n.registration__button--back {\n color: #B0B0B0;\n background-color: #FFFFFF;\n border: 2px solid #B0B0B0;\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: column;\n gap: 15px;\n }\n}";
|
|
43
43
|
|
|
44
44
|
const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
45
45
|
constructor() {
|
|
46
46
|
super();
|
|
47
47
|
this.__registerHost();
|
|
48
48
|
this.__attachShadow();
|
|
49
|
-
this.
|
|
50
|
-
|
|
51
|
-
"content": {
|
|
52
|
-
"step": "step1",
|
|
53
|
-
"fields": [
|
|
54
|
-
{
|
|
55
|
-
"name": "firstName",
|
|
56
|
-
"displayName": "Username",
|
|
57
|
-
"defaultValue": null,
|
|
58
|
-
"validate": {
|
|
59
|
-
"mandatory": true,
|
|
60
|
-
"minLength": 3,
|
|
61
|
-
"maxLength": 20
|
|
62
|
-
},
|
|
63
|
-
"autofill": false
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"name": "lastName",
|
|
67
|
-
"displayName": "Last name",
|
|
68
|
-
"defaultValue": null,
|
|
69
|
-
"validate": {
|
|
70
|
-
"mandatory": true,
|
|
71
|
-
"minLength": 3,
|
|
72
|
-
"maxLength": 20
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"name": "telephone",
|
|
77
|
-
"displayName": "Telephone",
|
|
78
|
-
"action": "GET https://demo-api.stage.norway.everymatrix.com/v1/player/phonecodes",
|
|
79
|
-
"defaultValue": null,
|
|
80
|
-
"validate": {
|
|
81
|
-
"mandatory": true
|
|
82
|
-
},
|
|
83
|
-
"autofill": false,
|
|
84
|
-
"inputType": "tel"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"name": "dateOfBirth",
|
|
88
|
-
"displayName": "Date of Birth",
|
|
89
|
-
"defaultValue": null,
|
|
90
|
-
"validate": {
|
|
91
|
-
"min": "2022-05-01",
|
|
92
|
-
"max": "2022-05-29",
|
|
93
|
-
"mandatory": true,
|
|
94
|
-
},
|
|
95
|
-
"inputType": "datetime"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"name": "email",
|
|
99
|
-
"displayName": "Email",
|
|
100
|
-
"defaultValue": 'a@a.com',
|
|
101
|
-
"validate": {
|
|
102
|
-
"mandatory": true,
|
|
103
|
-
"custom": [
|
|
104
|
-
{
|
|
105
|
-
"rule": "regex",
|
|
106
|
-
"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
107
|
-
"errorMessage": "Please enter a valid email address"
|
|
108
|
-
}
|
|
109
|
-
]
|
|
110
|
-
},
|
|
111
|
-
"inputType": "email"
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
"name": "password",
|
|
115
|
-
"displayName": "Password",
|
|
116
|
-
"defaultValue": null,
|
|
117
|
-
"validate": {
|
|
118
|
-
"mandatory": true,
|
|
119
|
-
"minLength": 3,
|
|
120
|
-
"maxLength": 20,
|
|
121
|
-
"type": "password",
|
|
122
|
-
"custom": [
|
|
123
|
-
{
|
|
124
|
-
"rule": "regex",
|
|
125
|
-
"pattern": "(?=.*\\d+)(?=.*[A-Za-z]+).{8,20}",
|
|
126
|
-
"errorMessage": "Password must contain at least 1 letter and 1 digit, and its minimal length is 8."
|
|
127
|
-
}
|
|
128
|
-
]
|
|
129
|
-
},
|
|
130
|
-
"inputType": "password"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"name": "email",
|
|
134
|
-
"displayName": "Email",
|
|
135
|
-
"defaultValue": null,
|
|
136
|
-
"validate": {
|
|
137
|
-
"mandatory": true,
|
|
138
|
-
"type": "email",
|
|
139
|
-
"custom": [
|
|
140
|
-
{
|
|
141
|
-
"rule": "unique-email",
|
|
142
|
-
"errorMessage": "Please check your email"
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
"rule": "regex",
|
|
146
|
-
"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
147
|
-
"errorMessage": "Please enter a valid email address"
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
"rule": "duplicate-input",
|
|
151
|
-
"displayName": "pt al doilea input gen: Confirm Email",
|
|
152
|
-
"errorMessage": "Different Email! Pls."
|
|
153
|
-
}
|
|
154
|
-
]
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
"name": "termsAndConditions",
|
|
159
|
-
"displayName": "Terms and Conditions",
|
|
160
|
-
"validate": {
|
|
161
|
-
"mandatory": true,
|
|
162
|
-
"type": "boolean"
|
|
163
|
-
},
|
|
164
|
-
"inputType": "checkbox"
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
"name": "pepCheck",
|
|
168
|
-
"validate": {
|
|
169
|
-
"mandatory": true
|
|
170
|
-
},
|
|
171
|
-
"inputType": "checkbox"
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
"name": "gender",
|
|
175
|
-
"data": {
|
|
176
|
-
"values": [
|
|
177
|
-
{
|
|
178
|
-
"label": "🍆",
|
|
179
|
-
"value": "m"
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
"label": "🍑",
|
|
183
|
-
"value": "f"
|
|
184
|
-
}
|
|
185
|
-
]
|
|
186
|
-
},
|
|
187
|
-
"validate": {
|
|
188
|
-
"mandatory": true
|
|
189
|
-
},
|
|
190
|
-
"inputType": "radio"
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
"name": "dateOfBirth",
|
|
194
|
-
"validate": {
|
|
195
|
-
"mandatory": true,
|
|
196
|
-
"custom": [
|
|
197
|
-
{
|
|
198
|
-
"rule": "regex",
|
|
199
|
-
"pattern": "(?:19\\d{2}|20[01][0-9]|2020)[-/.](?:0[1-9]|1[012])[-/.](?:0[1-9]|[12][0-9]|3[01])",
|
|
200
|
-
"errorMessage": "Invalid date format"
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
"rule": "min-18-years",
|
|
204
|
-
"errorMessage": "Not old enough to ride the roller coaster"
|
|
205
|
-
}
|
|
206
|
-
]
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
"name": "city",
|
|
211
|
-
"displayName": "Cities",
|
|
212
|
-
"action": null,
|
|
213
|
-
"data": {
|
|
214
|
-
"values": [
|
|
215
|
-
{
|
|
216
|
-
"label": "Budapest",
|
|
217
|
-
"value": "Budapest"
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
"label": "Debrecen",
|
|
221
|
-
"value": "Debrecen"
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
"label": "Miskolc",
|
|
225
|
-
"value": "Miskolc"
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
"label": "Szeged",
|
|
229
|
-
"value": "Szeged"
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
"label": "Zuglo",
|
|
233
|
-
"value": "Zuglo"
|
|
234
|
-
}
|
|
235
|
-
]
|
|
236
|
-
},
|
|
237
|
-
"validate": {
|
|
238
|
-
"mandatory": true
|
|
239
|
-
},
|
|
240
|
-
"inputType": "dropdown"
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
"name": "city",
|
|
244
|
-
"displayName": "Cities",
|
|
245
|
-
"data": null,
|
|
246
|
-
"action": "GET https://demo-api.stage.norway.everymatrix.com/v1/player/countries",
|
|
247
|
-
"validate": {
|
|
248
|
-
"mandatory": true
|
|
249
|
-
},
|
|
250
|
-
"inputType": "dropdown"
|
|
251
|
-
}
|
|
252
|
-
],
|
|
253
|
-
"actions": [
|
|
254
|
-
"get-next-step",
|
|
255
|
-
"some-async-action-before-submitting",
|
|
256
|
-
"submit-step-data"
|
|
257
|
-
]
|
|
258
|
-
}
|
|
259
|
-
};
|
|
49
|
+
this.registrationWidgetLoaded = createEvent(this, "registrationWidgetLoaded", 7);
|
|
50
|
+
this.registrationStepUpdated = createEvent(this, "registrationStepUpdated", 7);
|
|
260
51
|
/**
|
|
261
52
|
* Currently selected language
|
|
262
53
|
*/
|
|
263
54
|
this.language = 'en';
|
|
55
|
+
/**
|
|
56
|
+
* Client custom styling via string
|
|
57
|
+
*/
|
|
58
|
+
this.clientStyling = '';
|
|
59
|
+
/**
|
|
60
|
+
* Client custom styling via url content
|
|
61
|
+
*/
|
|
62
|
+
this.clientStylingUrl = '';
|
|
264
63
|
this.emitValue = false;
|
|
265
64
|
this.listOfInputs = [];
|
|
266
65
|
this.isLoading = true;
|
|
66
|
+
this.limitStylingAppends = false;
|
|
267
67
|
this.listOfInputValues = [];
|
|
268
68
|
this.listOfActions = [];
|
|
269
|
-
this.
|
|
69
|
+
this.indexStep = 0;
|
|
270
70
|
this.registrationStepsState = {
|
|
271
71
|
regId: null
|
|
272
72
|
};
|
|
73
|
+
this.setClientStyling = () => {
|
|
74
|
+
let sheet = document.createElement('style');
|
|
75
|
+
sheet.innerHTML = this.clientStyling;
|
|
76
|
+
this.stylingContainer.prepend(sheet);
|
|
77
|
+
};
|
|
78
|
+
this.setClientStylingURL = () => {
|
|
79
|
+
let url = new URL(this.clientStylingUrl);
|
|
80
|
+
let cssFile = document.createElement('style');
|
|
81
|
+
fetch(url.href)
|
|
82
|
+
.then((res) => res.text())
|
|
83
|
+
.then((data) => {
|
|
84
|
+
cssFile.innerHTML = data;
|
|
85
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
86
|
+
});
|
|
87
|
+
};
|
|
273
88
|
}
|
|
274
|
-
|
|
275
|
-
|
|
89
|
+
sendStep() {
|
|
90
|
+
this.registrationStepUpdated.emit(this.registrationStep);
|
|
91
|
+
window.postMessage({ type: 'registrationStepUpdated', step: this.registrationStep }, window.location.href);
|
|
276
92
|
}
|
|
277
93
|
checkInputsValidityHandler(event) {
|
|
278
94
|
// Set isValid state of the input in the list.
|
|
@@ -281,25 +97,30 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
281
97
|
this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
|
|
282
98
|
}
|
|
283
99
|
getInputsValueHandler(event) {
|
|
284
|
-
this.listOfInputValues.find(input =>
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
100
|
+
this.listOfInputValues.find(input => {
|
|
101
|
+
if (input.name == event.detail.name) {
|
|
102
|
+
input.value = event.detail.value;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
288
105
|
this.stepsStateMachine({ event: 'set', type: 'values' });
|
|
289
106
|
}
|
|
290
107
|
componentWillLoad() {
|
|
291
|
-
// const mockCall = Promise.resolve(this.data);
|
|
292
|
-
// return mockCall.then((data) => {
|
|
293
|
-
// this.listOfInputs = data.content.fields.map((field) => {
|
|
294
|
-
// this.isLoading = false;
|
|
295
|
-
// return { ...field, isValid: false };
|
|
296
|
-
// });
|
|
297
|
-
// });
|
|
298
108
|
return this.getRegisterConfig().then((config) => {
|
|
299
109
|
this.formatConfig(config);
|
|
300
110
|
this.stepsStateMachine({ event: 'set', type: 'inputs' });
|
|
301
111
|
});
|
|
302
112
|
}
|
|
113
|
+
componentDidRender() {
|
|
114
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
115
|
+
this.setClientStyling();
|
|
116
|
+
this.setClientStylingURL();
|
|
117
|
+
this.limitStylingAppends = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
componentDidLoad() {
|
|
121
|
+
this.registrationWidgetLoaded.emit();
|
|
122
|
+
window.postMessage({ type: 'registrationWidgetLoaded' }, window.location.href);
|
|
123
|
+
}
|
|
303
124
|
nextHandler(e) {
|
|
304
125
|
e.preventDefault();
|
|
305
126
|
// Trigger events in subwidgets.
|
|
@@ -308,8 +129,8 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
308
129
|
}
|
|
309
130
|
backHandler(e) {
|
|
310
131
|
e.preventDefault();
|
|
311
|
-
this.
|
|
312
|
-
this.registrationStep = this.
|
|
132
|
+
this.isLastStep = false;
|
|
133
|
+
this.registrationStep = this.stepChange('decrement');
|
|
313
134
|
this.stepsStateMachine({ event: 'get', type: 'inputs' });
|
|
314
135
|
this.stepsStateMachine({ event: 'get', type: 'values' });
|
|
315
136
|
}
|
|
@@ -318,13 +139,11 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
318
139
|
case 'set':
|
|
319
140
|
if (state.type == 'inputs') {
|
|
320
141
|
this.registrationStepsState[this.registrationStep].fields = this.listOfInputs;
|
|
142
|
+
this.registrationStepsState[this.registrationStep].actions = this.listOfActions;
|
|
321
143
|
}
|
|
322
144
|
if (state.type == 'values') {
|
|
323
145
|
this.registrationStepsState[this.registrationStep].registerUserData = this.listOfInputValues.reduce((acc, curr) => {
|
|
324
|
-
|
|
325
|
-
if (curr.value != null) {
|
|
326
|
-
acc[curr.name] = curr.value;
|
|
327
|
-
}
|
|
146
|
+
acc[curr.name] = { value: curr.value, isDuplicate: curr.isDuplicate };
|
|
328
147
|
return acc;
|
|
329
148
|
}, {});
|
|
330
149
|
}
|
|
@@ -336,17 +155,19 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
336
155
|
return;
|
|
337
156
|
if (state.type == 'inputs') {
|
|
338
157
|
this.listOfInputs = this.registrationStepsState[this.registrationStep].fields;
|
|
158
|
+
this.listOfActions = this.registrationStepsState[this.registrationStep].actions;
|
|
339
159
|
}
|
|
340
160
|
if (state.type == 'values') {
|
|
341
161
|
const savedValues = savedUserData[this.registrationStep].registerUserData;
|
|
342
162
|
this.listOfInputValues = Object.keys(savedValues).map(name => {
|
|
343
|
-
return { name, value: savedValues[name] };
|
|
163
|
+
return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
|
|
344
164
|
});
|
|
345
165
|
// Give to each field the user input as the default value.
|
|
346
166
|
this.listOfInputValues.forEach(inputValue => {
|
|
347
167
|
const input = this.listOfInputs.find(input => input.name === inputValue.name);
|
|
348
168
|
if (input) {
|
|
349
169
|
input.defaultValue = inputValue.value;
|
|
170
|
+
console.log(input);
|
|
350
171
|
}
|
|
351
172
|
});
|
|
352
173
|
}
|
|
@@ -356,9 +177,6 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
356
177
|
getRegisterConfig(registrationID) {
|
|
357
178
|
const url = new URL(`${this.endpoint}/v1/player/legislation/registration/config`);
|
|
358
179
|
const headers = new Headers();
|
|
359
|
-
// headers.append('X-Tenant-ID', this.tenantId);
|
|
360
|
-
// headers.append('X-Client-ID', this.clientId);
|
|
361
|
-
// headers.append('X-Api-Key', this.apiKey);
|
|
362
180
|
headers.append('Content-Type', 'application/json');
|
|
363
181
|
headers.append('Accept', 'application/json');
|
|
364
182
|
if (registrationID) {
|
|
@@ -387,9 +205,15 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
387
205
|
const url = new URL(`${this.endpoint}/v1/player/legislation/registration/step`);
|
|
388
206
|
const registerStep = {
|
|
389
207
|
registrationId: this.registrationID,
|
|
390
|
-
registerUserDto: this.listOfInputValues
|
|
391
|
-
|
|
392
|
-
|
|
208
|
+
registerUserDto: this.listOfInputValues
|
|
209
|
+
.filter(input => !input.isDuplicate)
|
|
210
|
+
.reduce((acc, curr) => {
|
|
211
|
+
// Special case for "Mobile" as it needs to be split in two values -- API expects it this way.
|
|
212
|
+
if (curr.name == "Mobile") {
|
|
213
|
+
acc['MobilePrefix'] = curr.value.split('|')[0];
|
|
214
|
+
acc[curr.name] = curr.value.split('|')[1];
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
393
217
|
acc[curr.name] = curr.value;
|
|
394
218
|
}
|
|
395
219
|
return acc;
|
|
@@ -397,9 +221,6 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
397
221
|
step: this.registrationStep,
|
|
398
222
|
};
|
|
399
223
|
const headers = new Headers();
|
|
400
|
-
// headers.append('X-Tenant-ID', this.tenantId);
|
|
401
|
-
// headers.append('X-Client-ID', this.clientId);
|
|
402
|
-
// headers.append('X-Api-Key', this.apiKey);
|
|
403
224
|
headers.append('Content-Type', 'application/json');
|
|
404
225
|
headers.append('Accept', 'application/json');
|
|
405
226
|
const options = {
|
|
@@ -420,12 +241,22 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
420
241
|
this.setRegister();
|
|
421
242
|
}
|
|
422
243
|
else {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
244
|
+
// After sending the current step, increment and check if the next one is in state.
|
|
245
|
+
this.registrationStep = this.stepChange('increment');
|
|
246
|
+
// If step is present in state do NOT fetch the next config.
|
|
247
|
+
if (Object.keys(this.registrationStepsState).find(key => key == this.registrationStep)) {
|
|
248
|
+
// Use the one from state
|
|
249
|
+
this.stepsStateMachine({ event: 'get', type: 'inputs' });
|
|
250
|
+
this.stepsStateMachine({ event: 'get', type: 'values' });
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
this.getRegisterConfig(this.registrationID).then((config) => {
|
|
254
|
+
// Format the new step config.
|
|
255
|
+
this.formatConfig(config);
|
|
256
|
+
// Set it in local storage.
|
|
257
|
+
this.stepsStateMachine({ event: 'set', type: 'inputs' });
|
|
258
|
+
});
|
|
259
|
+
}
|
|
429
260
|
}
|
|
430
261
|
})
|
|
431
262
|
.catch((err) => {
|
|
@@ -439,19 +270,8 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
439
270
|
this.isLoading = true;
|
|
440
271
|
const url = new URL(`${this.endpoint}/v1/player/legislation/register`);
|
|
441
272
|
const headers = new Headers();
|
|
442
|
-
// headers.append('X-Tenant-ID', this.tenantId);
|
|
443
|
-
// headers.append('X-Client-ID', this.clientId);
|
|
444
|
-
// headers.append('X-Api-Key', this.apiKey);
|
|
445
273
|
headers.append('Content-Type', 'application/json');
|
|
446
274
|
headers.append('Accept', 'application/json');
|
|
447
|
-
// const registerStep = {
|
|
448
|
-
// registrationId: this.registrationID,
|
|
449
|
-
// registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
|
|
450
|
-
// acc[curr.name] = curr.value;
|
|
451
|
-
// return acc;
|
|
452
|
-
// }, {}),
|
|
453
|
-
// step: this.registrationStep,
|
|
454
|
-
// };
|
|
455
275
|
const options = {
|
|
456
276
|
method: 'PUT',
|
|
457
277
|
body: JSON.stringify({ registrationId: this.registrationID }),
|
|
@@ -478,59 +298,77 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
478
298
|
}
|
|
479
299
|
formatConfig(config) {
|
|
480
300
|
// Populate the list of inputs and set as invalid in the beginning
|
|
481
|
-
this.listOfInputs = config.content.fields.
|
|
482
|
-
|
|
301
|
+
this.listOfInputs = config.content.fields.flatMap((field) => {
|
|
302
|
+
// Special case for inputs that need to be duplicated.
|
|
303
|
+
const duplicateInputRule = field.validate.custom.find(customRule => customRule.rule === 'duplicate-input');
|
|
304
|
+
const inputElement = Object.assign(Object.assign({}, field), { isValid: false });
|
|
305
|
+
if (duplicateInputRule) {
|
|
306
|
+
const duplicateInput = Object.assign(Object.assign({}, field), { name: `${field.name}Duplicate`, displayName: duplicateInputRule.displayName, isValid: false, isDuplicateInput: true });
|
|
307
|
+
return [inputElement, duplicateInput];
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
return [inputElement];
|
|
311
|
+
}
|
|
483
312
|
});
|
|
484
313
|
// Populate the list of inputs values and set as null in the beginning
|
|
485
|
-
this.listOfInputValues =
|
|
486
|
-
return { name: field.name, value: null };
|
|
314
|
+
this.listOfInputValues = this.listOfInputs.map(field => {
|
|
315
|
+
return { name: field.name, value: null, isDuplicate: field.isDuplicateInput || false };
|
|
487
316
|
});
|
|
488
317
|
// Set the list of actions
|
|
489
318
|
this.listOfActions = config.content.actions.map(action => action);
|
|
490
319
|
this.isLastStep = this.listOfActions.some(action => action == '/register');
|
|
491
320
|
this.registrationID = config.content.registrationID;
|
|
492
321
|
this.registrationStep = config.content.step;
|
|
493
|
-
this.steps.push(this.registrationStep);
|
|
494
322
|
// Add the step to the registrationStepsData
|
|
495
323
|
this.registrationStepsState.regId = this.registrationID;
|
|
496
324
|
if (!this.registrationStepsState[this.registrationStep]) {
|
|
497
325
|
this.registrationStepsState[this.registrationStep] = {
|
|
498
326
|
fields: [],
|
|
499
|
-
registerUserData: {}
|
|
327
|
+
registerUserData: {},
|
|
328
|
+
actions: []
|
|
500
329
|
};
|
|
501
330
|
}
|
|
502
331
|
}
|
|
332
|
+
stepChange(action) {
|
|
333
|
+
const stepNum = parseInt(this.registrationStep.replace('Step', ''));
|
|
334
|
+
if (action === 'increment') {
|
|
335
|
+
return 'Step' + (stepNum + 1);
|
|
336
|
+
}
|
|
337
|
+
if (action === 'decrement') {
|
|
338
|
+
return 'Step' + (stepNum - 1);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
503
341
|
getInvalidStatus(listOfInputs) {
|
|
504
342
|
return listOfInputs.filter(input => input.isValid == false).length > 0;
|
|
505
343
|
}
|
|
506
344
|
renderInputs() {
|
|
507
|
-
return (this.listOfInputs.map(input => h("general-input", { type: input.inputType, name: input.name, displayName: input.displayName, validation: input.validate, action: input.action || null, options: input.data ? input.data.values : [], defaultValue: input.defaultValue, autofilled: input.autofill, emitValue: this.emitValue, language: this.language })));
|
|
345
|
+
return (this.listOfInputs.map(input => h("general-input", { type: input.inputType, name: input.name, displayName: input.displayName, validation: input.validate, action: input.action || null, options: input.data ? input.data.values : [], defaultValue: input.defaultValue, autofilled: input.autofill, emitValue: this.emitValue, language: this.language, isDuplicateInput: input.isDuplicateInput })));
|
|
508
346
|
}
|
|
509
347
|
;
|
|
510
348
|
renderButtons() {
|
|
511
|
-
return (h("div", { class: 'registration__buttons-wrapper' }, h("button", { class: `registration__button
|
|
349
|
+
return (h("div", { class: 'registration__buttons-wrapper' }, h("button", { class: `registration__button registration__button--next`, type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e) }, this.isLastStep ? 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))));
|
|
512
350
|
}
|
|
513
351
|
render() {
|
|
514
352
|
if (this.isLoading) {
|
|
515
353
|
return h("p", null, "Please wait, loading ...");
|
|
516
354
|
}
|
|
517
|
-
return (h("div", { class:
|
|
355
|
+
return (h("div", { class: `registration registration__${this.registrationStep}`, ref: el => this.stylingContainer = el }, h("form", { action: '.', id: 'RegistrationForm', class: 'registration__form' }, this.renderInputs()), this.renderButtons()));
|
|
518
356
|
}
|
|
519
357
|
static get watchers() { return {
|
|
520
|
-
"registrationStep": ["
|
|
358
|
+
"registrationStep": ["sendStep"]
|
|
521
359
|
}; }
|
|
522
360
|
static get style() { return generalRegistrationCss; }
|
|
523
361
|
}, [1, "general-registration", {
|
|
524
362
|
"endpoint": [1],
|
|
525
|
-
"tenantId": [1, "tenant-id"],
|
|
526
|
-
"clientId": [1, "client-id"],
|
|
527
|
-
"apiKey": [1, "api-key"],
|
|
528
363
|
"language": [1],
|
|
364
|
+
"clientStyling": [1, "client-styling"],
|
|
365
|
+
"clientStylingUrl": [1, "client-styling-url"],
|
|
529
366
|
"errorMessage": [32],
|
|
530
367
|
"emitValue": [32],
|
|
531
368
|
"isFormValid": [32],
|
|
532
369
|
"listOfInputs": [32],
|
|
533
370
|
"isLoading": [32],
|
|
371
|
+
"limitStylingAppends": [32],
|
|
534
372
|
"registrationStep": [32]
|
|
535
373
|
}, [[0, "sendValidityState", "checkInputsValidityHandler"], [0, "sendInputValue", "getInputsValueHandler"]]]);
|
|
536
374
|
function defineCustomElement$1() {
|