@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,235 +1,49 @@
|
|
|
1
|
-
import { Component, h, Listen, Prop, State, Watch } from '@stencil/core';
|
|
1
|
+
import { Component, h, Listen, Prop, State, Watch, Event } from '@stencil/core';
|
|
2
2
|
import { translate } from '../../../../general-input/src/utils/locale.utils';
|
|
3
3
|
import '@everymatrix/general-input';
|
|
4
4
|
export class GeneralRegistration {
|
|
5
5
|
constructor() {
|
|
6
|
-
this.data = {
|
|
7
|
-
"type": "default",
|
|
8
|
-
"content": {
|
|
9
|
-
"step": "step1",
|
|
10
|
-
"fields": [
|
|
11
|
-
{
|
|
12
|
-
"name": "firstName",
|
|
13
|
-
"displayName": "Username",
|
|
14
|
-
"defaultValue": null,
|
|
15
|
-
"validate": {
|
|
16
|
-
"mandatory": true,
|
|
17
|
-
"minLength": 3,
|
|
18
|
-
"maxLength": 20
|
|
19
|
-
},
|
|
20
|
-
"autofill": false
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"name": "lastName",
|
|
24
|
-
"displayName": "Last name",
|
|
25
|
-
"defaultValue": null,
|
|
26
|
-
"validate": {
|
|
27
|
-
"mandatory": true,
|
|
28
|
-
"minLength": 3,
|
|
29
|
-
"maxLength": 20
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"name": "telephone",
|
|
34
|
-
"displayName": "Telephone",
|
|
35
|
-
"action": "GET https://demo-api.stage.norway.everymatrix.com/v1/player/phonecodes",
|
|
36
|
-
"defaultValue": null,
|
|
37
|
-
"validate": {
|
|
38
|
-
"mandatory": true
|
|
39
|
-
},
|
|
40
|
-
"autofill": false,
|
|
41
|
-
"inputType": "tel"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"name": "dateOfBirth",
|
|
45
|
-
"displayName": "Date of Birth",
|
|
46
|
-
"defaultValue": null,
|
|
47
|
-
"validate": {
|
|
48
|
-
"min": "2022-05-01",
|
|
49
|
-
"max": "2022-05-29",
|
|
50
|
-
"mandatory": true,
|
|
51
|
-
},
|
|
52
|
-
"inputType": "datetime"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"name": "email",
|
|
56
|
-
"displayName": "Email",
|
|
57
|
-
"defaultValue": 'a@a.com',
|
|
58
|
-
"validate": {
|
|
59
|
-
"mandatory": true,
|
|
60
|
-
"custom": [
|
|
61
|
-
{
|
|
62
|
-
"rule": "regex",
|
|
63
|
-
"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
64
|
-
"errorMessage": "Please enter a valid email address"
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
"inputType": "email"
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"name": "password",
|
|
72
|
-
"displayName": "Password",
|
|
73
|
-
"defaultValue": null,
|
|
74
|
-
"validate": {
|
|
75
|
-
"mandatory": true,
|
|
76
|
-
"minLength": 3,
|
|
77
|
-
"maxLength": 20,
|
|
78
|
-
"type": "password",
|
|
79
|
-
"custom": [
|
|
80
|
-
{
|
|
81
|
-
"rule": "regex",
|
|
82
|
-
"pattern": "(?=.*\\d+)(?=.*[A-Za-z]+).{8,20}",
|
|
83
|
-
"errorMessage": "Password must contain at least 1 letter and 1 digit, and its minimal length is 8."
|
|
84
|
-
}
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
|
-
"inputType": "password"
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
"name": "email",
|
|
91
|
-
"displayName": "Email",
|
|
92
|
-
"defaultValue": null,
|
|
93
|
-
"validate": {
|
|
94
|
-
"mandatory": true,
|
|
95
|
-
"type": "email",
|
|
96
|
-
"custom": [
|
|
97
|
-
{
|
|
98
|
-
"rule": "unique-email",
|
|
99
|
-
"errorMessage": "Please check your email"
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
"rule": "regex",
|
|
103
|
-
"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
104
|
-
"errorMessage": "Please enter a valid email address"
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
"rule": "duplicate-input",
|
|
108
|
-
"displayName": "pt al doilea input gen: Confirm Email",
|
|
109
|
-
"errorMessage": "Different Email! Pls."
|
|
110
|
-
}
|
|
111
|
-
]
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
"name": "termsAndConditions",
|
|
116
|
-
"displayName": "Terms and Conditions",
|
|
117
|
-
"validate": {
|
|
118
|
-
"mandatory": true,
|
|
119
|
-
"type": "boolean"
|
|
120
|
-
},
|
|
121
|
-
"inputType": "checkbox"
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
"name": "pepCheck",
|
|
125
|
-
"validate": {
|
|
126
|
-
"mandatory": true
|
|
127
|
-
},
|
|
128
|
-
"inputType": "checkbox"
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
"name": "gender",
|
|
132
|
-
"data": {
|
|
133
|
-
"values": [
|
|
134
|
-
{
|
|
135
|
-
"label": "🍆",
|
|
136
|
-
"value": "m"
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
"label": "🍑",
|
|
140
|
-
"value": "f"
|
|
141
|
-
}
|
|
142
|
-
]
|
|
143
|
-
},
|
|
144
|
-
"validate": {
|
|
145
|
-
"mandatory": true
|
|
146
|
-
},
|
|
147
|
-
"inputType": "radio"
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
"name": "dateOfBirth",
|
|
151
|
-
"validate": {
|
|
152
|
-
"mandatory": true,
|
|
153
|
-
"custom": [
|
|
154
|
-
{
|
|
155
|
-
"rule": "regex",
|
|
156
|
-
"pattern": "(?:19\\d{2}|20[01][0-9]|2020)[-/.](?:0[1-9]|1[012])[-/.](?:0[1-9]|[12][0-9]|3[01])",
|
|
157
|
-
"errorMessage": "Invalid date format"
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
"rule": "min-18-years",
|
|
161
|
-
"errorMessage": "Not old enough to ride the roller coaster"
|
|
162
|
-
}
|
|
163
|
-
]
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
"name": "city",
|
|
168
|
-
"displayName": "Cities",
|
|
169
|
-
"action": null,
|
|
170
|
-
"data": {
|
|
171
|
-
"values": [
|
|
172
|
-
{
|
|
173
|
-
"label": "Budapest",
|
|
174
|
-
"value": "Budapest"
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
"label": "Debrecen",
|
|
178
|
-
"value": "Debrecen"
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
"label": "Miskolc",
|
|
182
|
-
"value": "Miskolc"
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
"label": "Szeged",
|
|
186
|
-
"value": "Szeged"
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
"label": "Zuglo",
|
|
190
|
-
"value": "Zuglo"
|
|
191
|
-
}
|
|
192
|
-
]
|
|
193
|
-
},
|
|
194
|
-
"validate": {
|
|
195
|
-
"mandatory": true
|
|
196
|
-
},
|
|
197
|
-
"inputType": "dropdown"
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
"name": "city",
|
|
201
|
-
"displayName": "Cities",
|
|
202
|
-
"data": null,
|
|
203
|
-
"action": "GET https://demo-api.stage.norway.everymatrix.com/v1/player/countries",
|
|
204
|
-
"validate": {
|
|
205
|
-
"mandatory": true
|
|
206
|
-
},
|
|
207
|
-
"inputType": "dropdown"
|
|
208
|
-
}
|
|
209
|
-
],
|
|
210
|
-
"actions": [
|
|
211
|
-
"get-next-step",
|
|
212
|
-
"some-async-action-before-submitting",
|
|
213
|
-
"submit-step-data"
|
|
214
|
-
]
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
6
|
/**
|
|
218
7
|
* Currently selected language
|
|
219
8
|
*/
|
|
220
9
|
this.language = 'en';
|
|
10
|
+
/**
|
|
11
|
+
* Client custom styling via string
|
|
12
|
+
*/
|
|
13
|
+
this.clientStyling = '';
|
|
14
|
+
/**
|
|
15
|
+
* Client custom styling via url content
|
|
16
|
+
*/
|
|
17
|
+
this.clientStylingUrl = '';
|
|
221
18
|
this.emitValue = false;
|
|
222
19
|
this.listOfInputs = [];
|
|
223
20
|
this.isLoading = true;
|
|
21
|
+
this.limitStylingAppends = false;
|
|
224
22
|
this.listOfInputValues = [];
|
|
225
23
|
this.listOfActions = [];
|
|
226
|
-
this.
|
|
24
|
+
this.indexStep = 0;
|
|
227
25
|
this.registrationStepsState = {
|
|
228
26
|
regId: null
|
|
229
27
|
};
|
|
28
|
+
this.setClientStyling = () => {
|
|
29
|
+
let sheet = document.createElement('style');
|
|
30
|
+
sheet.innerHTML = this.clientStyling;
|
|
31
|
+
this.stylingContainer.prepend(sheet);
|
|
32
|
+
};
|
|
33
|
+
this.setClientStylingURL = () => {
|
|
34
|
+
let url = new URL(this.clientStylingUrl);
|
|
35
|
+
let cssFile = document.createElement('style');
|
|
36
|
+
fetch(url.href)
|
|
37
|
+
.then((res) => res.text())
|
|
38
|
+
.then((data) => {
|
|
39
|
+
cssFile.innerHTML = data;
|
|
40
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
230
43
|
}
|
|
231
|
-
|
|
232
|
-
|
|
44
|
+
sendStep() {
|
|
45
|
+
this.registrationStepUpdated.emit(this.registrationStep);
|
|
46
|
+
window.postMessage({ type: 'registrationStepUpdated', step: this.registrationStep }, window.location.href);
|
|
233
47
|
}
|
|
234
48
|
checkInputsValidityHandler(event) {
|
|
235
49
|
// Set isValid state of the input in the list.
|
|
@@ -238,25 +52,30 @@ export class GeneralRegistration {
|
|
|
238
52
|
this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
|
|
239
53
|
}
|
|
240
54
|
getInputsValueHandler(event) {
|
|
241
|
-
this.listOfInputValues.find(input =>
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
55
|
+
this.listOfInputValues.find(input => {
|
|
56
|
+
if (input.name == event.detail.name) {
|
|
57
|
+
input.value = event.detail.value;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
245
60
|
this.stepsStateMachine({ event: 'set', type: 'values' });
|
|
246
61
|
}
|
|
247
62
|
componentWillLoad() {
|
|
248
|
-
// const mockCall = Promise.resolve(this.data);
|
|
249
|
-
// return mockCall.then((data) => {
|
|
250
|
-
// this.listOfInputs = data.content.fields.map((field) => {
|
|
251
|
-
// this.isLoading = false;
|
|
252
|
-
// return { ...field, isValid: false };
|
|
253
|
-
// });
|
|
254
|
-
// });
|
|
255
63
|
return this.getRegisterConfig().then((config) => {
|
|
256
64
|
this.formatConfig(config);
|
|
257
65
|
this.stepsStateMachine({ event: 'set', type: 'inputs' });
|
|
258
66
|
});
|
|
259
67
|
}
|
|
68
|
+
componentDidRender() {
|
|
69
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
70
|
+
this.setClientStyling();
|
|
71
|
+
this.setClientStylingURL();
|
|
72
|
+
this.limitStylingAppends = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
componentDidLoad() {
|
|
76
|
+
this.registrationWidgetLoaded.emit();
|
|
77
|
+
window.postMessage({ type: 'registrationWidgetLoaded' }, window.location.href);
|
|
78
|
+
}
|
|
260
79
|
nextHandler(e) {
|
|
261
80
|
e.preventDefault();
|
|
262
81
|
// Trigger events in subwidgets.
|
|
@@ -265,8 +84,8 @@ export class GeneralRegistration {
|
|
|
265
84
|
}
|
|
266
85
|
backHandler(e) {
|
|
267
86
|
e.preventDefault();
|
|
268
|
-
this.
|
|
269
|
-
this.registrationStep = this.
|
|
87
|
+
this.isLastStep = false;
|
|
88
|
+
this.registrationStep = this.stepChange('decrement');
|
|
270
89
|
this.stepsStateMachine({ event: 'get', type: 'inputs' });
|
|
271
90
|
this.stepsStateMachine({ event: 'get', type: 'values' });
|
|
272
91
|
}
|
|
@@ -275,13 +94,11 @@ export class GeneralRegistration {
|
|
|
275
94
|
case 'set':
|
|
276
95
|
if (state.type == 'inputs') {
|
|
277
96
|
this.registrationStepsState[this.registrationStep].fields = this.listOfInputs;
|
|
97
|
+
this.registrationStepsState[this.registrationStep].actions = this.listOfActions;
|
|
278
98
|
}
|
|
279
99
|
if (state.type == 'values') {
|
|
280
100
|
this.registrationStepsState[this.registrationStep].registerUserData = this.listOfInputValues.reduce((acc, curr) => {
|
|
281
|
-
|
|
282
|
-
if (curr.value != null) {
|
|
283
|
-
acc[curr.name] = curr.value;
|
|
284
|
-
}
|
|
101
|
+
acc[curr.name] = { value: curr.value, isDuplicate: curr.isDuplicate };
|
|
285
102
|
return acc;
|
|
286
103
|
}, {});
|
|
287
104
|
}
|
|
@@ -293,17 +110,19 @@ export class GeneralRegistration {
|
|
|
293
110
|
return;
|
|
294
111
|
if (state.type == 'inputs') {
|
|
295
112
|
this.listOfInputs = this.registrationStepsState[this.registrationStep].fields;
|
|
113
|
+
this.listOfActions = this.registrationStepsState[this.registrationStep].actions;
|
|
296
114
|
}
|
|
297
115
|
if (state.type == 'values') {
|
|
298
116
|
const savedValues = savedUserData[this.registrationStep].registerUserData;
|
|
299
117
|
this.listOfInputValues = Object.keys(savedValues).map(name => {
|
|
300
|
-
return { name, value: savedValues[name] };
|
|
118
|
+
return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
|
|
301
119
|
});
|
|
302
120
|
// Give to each field the user input as the default value.
|
|
303
121
|
this.listOfInputValues.forEach(inputValue => {
|
|
304
122
|
const input = this.listOfInputs.find(input => input.name === inputValue.name);
|
|
305
123
|
if (input) {
|
|
306
124
|
input.defaultValue = inputValue.value;
|
|
125
|
+
console.log(input);
|
|
307
126
|
}
|
|
308
127
|
});
|
|
309
128
|
}
|
|
@@ -313,9 +132,6 @@ export class GeneralRegistration {
|
|
|
313
132
|
getRegisterConfig(registrationID) {
|
|
314
133
|
const url = new URL(`${this.endpoint}/v1/player/legislation/registration/config`);
|
|
315
134
|
const headers = new Headers();
|
|
316
|
-
// headers.append('X-Tenant-ID', this.tenantId);
|
|
317
|
-
// headers.append('X-Client-ID', this.clientId);
|
|
318
|
-
// headers.append('X-Api-Key', this.apiKey);
|
|
319
135
|
headers.append('Content-Type', 'application/json');
|
|
320
136
|
headers.append('Accept', 'application/json');
|
|
321
137
|
if (registrationID) {
|
|
@@ -344,9 +160,15 @@ export class GeneralRegistration {
|
|
|
344
160
|
const url = new URL(`${this.endpoint}/v1/player/legislation/registration/step`);
|
|
345
161
|
const registerStep = {
|
|
346
162
|
registrationId: this.registrationID,
|
|
347
|
-
registerUserDto: this.listOfInputValues
|
|
348
|
-
|
|
349
|
-
|
|
163
|
+
registerUserDto: this.listOfInputValues
|
|
164
|
+
.filter(input => !input.isDuplicate)
|
|
165
|
+
.reduce((acc, curr) => {
|
|
166
|
+
// Special case for "Mobile" as it needs to be split in two values -- API expects it this way.
|
|
167
|
+
if (curr.name == "Mobile") {
|
|
168
|
+
acc['MobilePrefix'] = curr.value.split('|')[0];
|
|
169
|
+
acc[curr.name] = curr.value.split('|')[1];
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
350
172
|
acc[curr.name] = curr.value;
|
|
351
173
|
}
|
|
352
174
|
return acc;
|
|
@@ -354,9 +176,6 @@ export class GeneralRegistration {
|
|
|
354
176
|
step: this.registrationStep,
|
|
355
177
|
};
|
|
356
178
|
const headers = new Headers();
|
|
357
|
-
// headers.append('X-Tenant-ID', this.tenantId);
|
|
358
|
-
// headers.append('X-Client-ID', this.clientId);
|
|
359
|
-
// headers.append('X-Api-Key', this.apiKey);
|
|
360
179
|
headers.append('Content-Type', 'application/json');
|
|
361
180
|
headers.append('Accept', 'application/json');
|
|
362
181
|
const options = {
|
|
@@ -377,12 +196,22 @@ export class GeneralRegistration {
|
|
|
377
196
|
this.setRegister();
|
|
378
197
|
}
|
|
379
198
|
else {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
199
|
+
// After sending the current step, increment and check if the next one is in state.
|
|
200
|
+
this.registrationStep = this.stepChange('increment');
|
|
201
|
+
// If step is present in state do NOT fetch the next config.
|
|
202
|
+
if (Object.keys(this.registrationStepsState).find(key => key == this.registrationStep)) {
|
|
203
|
+
// Use the one from state
|
|
204
|
+
this.stepsStateMachine({ event: 'get', type: 'inputs' });
|
|
205
|
+
this.stepsStateMachine({ event: 'get', type: 'values' });
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
this.getRegisterConfig(this.registrationID).then((config) => {
|
|
209
|
+
// Format the new step config.
|
|
210
|
+
this.formatConfig(config);
|
|
211
|
+
// Set it in local storage.
|
|
212
|
+
this.stepsStateMachine({ event: 'set', type: 'inputs' });
|
|
213
|
+
});
|
|
214
|
+
}
|
|
386
215
|
}
|
|
387
216
|
})
|
|
388
217
|
.catch((err) => {
|
|
@@ -396,19 +225,8 @@ export class GeneralRegistration {
|
|
|
396
225
|
this.isLoading = true;
|
|
397
226
|
const url = new URL(`${this.endpoint}/v1/player/legislation/register`);
|
|
398
227
|
const headers = new Headers();
|
|
399
|
-
// headers.append('X-Tenant-ID', this.tenantId);
|
|
400
|
-
// headers.append('X-Client-ID', this.clientId);
|
|
401
|
-
// headers.append('X-Api-Key', this.apiKey);
|
|
402
228
|
headers.append('Content-Type', 'application/json');
|
|
403
229
|
headers.append('Accept', 'application/json');
|
|
404
|
-
// const registerStep = {
|
|
405
|
-
// registrationId: this.registrationID,
|
|
406
|
-
// registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
|
|
407
|
-
// acc[curr.name] = curr.value;
|
|
408
|
-
// return acc;
|
|
409
|
-
// }, {}),
|
|
410
|
-
// step: this.registrationStep,
|
|
411
|
-
// };
|
|
412
230
|
const options = {
|
|
413
231
|
method: 'PUT',
|
|
414
232
|
body: JSON.stringify({ registrationId: this.registrationID }),
|
|
@@ -435,45 +253,63 @@ export class GeneralRegistration {
|
|
|
435
253
|
}
|
|
436
254
|
formatConfig(config) {
|
|
437
255
|
// Populate the list of inputs and set as invalid in the beginning
|
|
438
|
-
this.listOfInputs = config.content.fields.
|
|
439
|
-
|
|
256
|
+
this.listOfInputs = config.content.fields.flatMap((field) => {
|
|
257
|
+
// Special case for inputs that need to be duplicated.
|
|
258
|
+
const duplicateInputRule = field.validate.custom.find(customRule => customRule.rule === 'duplicate-input');
|
|
259
|
+
const inputElement = Object.assign(Object.assign({}, field), { isValid: false });
|
|
260
|
+
if (duplicateInputRule) {
|
|
261
|
+
const duplicateInput = Object.assign(Object.assign({}, field), { name: `${field.name}Duplicate`, displayName: duplicateInputRule.displayName, isValid: false, isDuplicateInput: true });
|
|
262
|
+
return [inputElement, duplicateInput];
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
return [inputElement];
|
|
266
|
+
}
|
|
440
267
|
});
|
|
441
268
|
// Populate the list of inputs values and set as null in the beginning
|
|
442
|
-
this.listOfInputValues =
|
|
443
|
-
return { name: field.name, value: null };
|
|
269
|
+
this.listOfInputValues = this.listOfInputs.map(field => {
|
|
270
|
+
return { name: field.name, value: null, isDuplicate: field.isDuplicateInput || false };
|
|
444
271
|
});
|
|
445
272
|
// Set the list of actions
|
|
446
273
|
this.listOfActions = config.content.actions.map(action => action);
|
|
447
274
|
this.isLastStep = this.listOfActions.some(action => action == '/register');
|
|
448
275
|
this.registrationID = config.content.registrationID;
|
|
449
276
|
this.registrationStep = config.content.step;
|
|
450
|
-
this.steps.push(this.registrationStep);
|
|
451
277
|
// Add the step to the registrationStepsData
|
|
452
278
|
this.registrationStepsState.regId = this.registrationID;
|
|
453
279
|
if (!this.registrationStepsState[this.registrationStep]) {
|
|
454
280
|
this.registrationStepsState[this.registrationStep] = {
|
|
455
281
|
fields: [],
|
|
456
|
-
registerUserData: {}
|
|
282
|
+
registerUserData: {},
|
|
283
|
+
actions: []
|
|
457
284
|
};
|
|
458
285
|
}
|
|
459
286
|
}
|
|
287
|
+
stepChange(action) {
|
|
288
|
+
const stepNum = parseInt(this.registrationStep.replace('Step', ''));
|
|
289
|
+
if (action === 'increment') {
|
|
290
|
+
return 'Step' + (stepNum + 1);
|
|
291
|
+
}
|
|
292
|
+
if (action === 'decrement') {
|
|
293
|
+
return 'Step' + (stepNum - 1);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
460
296
|
getInvalidStatus(listOfInputs) {
|
|
461
297
|
return listOfInputs.filter(input => input.isValid == false).length > 0;
|
|
462
298
|
}
|
|
463
299
|
renderInputs() {
|
|
464
|
-
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 })));
|
|
300
|
+
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 })));
|
|
465
301
|
}
|
|
466
302
|
;
|
|
467
303
|
renderButtons() {
|
|
468
304
|
return (h("div", { class: 'registration__buttons-wrapper' },
|
|
469
|
-
h("button", { class: `registration__button
|
|
470
|
-
|
|
305
|
+
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)),
|
|
306
|
+
h("button", { class: `registration__button registration__button--back ${this.registrationStep == 'Step1' ? 'registration__button--first-step' : ''}`, onClick: (e) => this.backHandler(e) }, translate('backButton', this.language))));
|
|
471
307
|
}
|
|
472
308
|
render() {
|
|
473
309
|
if (this.isLoading) {
|
|
474
310
|
return h("p", null, "Please wait, loading ...");
|
|
475
311
|
}
|
|
476
|
-
return (h("div", { class:
|
|
312
|
+
return (h("div", { class: `registration registration__${this.registrationStep}`, ref: el => this.stylingContainer = el },
|
|
477
313
|
h("form", { action: '.', id: 'RegistrationForm', class: 'registration__form' }, this.renderInputs()),
|
|
478
314
|
this.renderButtons()));
|
|
479
315
|
}
|
|
@@ -494,7 +330,7 @@ export class GeneralRegistration {
|
|
|
494
330
|
"resolved": "string",
|
|
495
331
|
"references": {}
|
|
496
332
|
},
|
|
497
|
-
"required":
|
|
333
|
+
"required": true,
|
|
498
334
|
"optional": false,
|
|
499
335
|
"docs": {
|
|
500
336
|
"tags": [],
|
|
@@ -503,24 +339,7 @@ export class GeneralRegistration {
|
|
|
503
339
|
"attribute": "endpoint",
|
|
504
340
|
"reflect": false
|
|
505
341
|
},
|
|
506
|
-
"
|
|
507
|
-
"type": "string",
|
|
508
|
-
"mutable": false,
|
|
509
|
-
"complexType": {
|
|
510
|
-
"original": "string",
|
|
511
|
-
"resolved": "string",
|
|
512
|
-
"references": {}
|
|
513
|
-
},
|
|
514
|
-
"required": false,
|
|
515
|
-
"optional": false,
|
|
516
|
-
"docs": {
|
|
517
|
-
"tags": [],
|
|
518
|
-
"text": "The tenandId of the domain"
|
|
519
|
-
},
|
|
520
|
-
"attribute": "tenant-id",
|
|
521
|
-
"reflect": false
|
|
522
|
-
},
|
|
523
|
-
"clientId": {
|
|
342
|
+
"language": {
|
|
524
343
|
"type": "string",
|
|
525
344
|
"mutable": false,
|
|
526
345
|
"complexType": {
|
|
@@ -532,12 +351,13 @@ export class GeneralRegistration {
|
|
|
532
351
|
"optional": false,
|
|
533
352
|
"docs": {
|
|
534
353
|
"tags": [],
|
|
535
|
-
"text": "
|
|
354
|
+
"text": "Currently selected language"
|
|
536
355
|
},
|
|
537
|
-
"attribute": "
|
|
538
|
-
"reflect": false
|
|
356
|
+
"attribute": "language",
|
|
357
|
+
"reflect": false,
|
|
358
|
+
"defaultValue": "'en'"
|
|
539
359
|
},
|
|
540
|
-
"
|
|
360
|
+
"clientStyling": {
|
|
541
361
|
"type": "string",
|
|
542
362
|
"mutable": false,
|
|
543
363
|
"complexType": {
|
|
@@ -549,12 +369,13 @@ export class GeneralRegistration {
|
|
|
549
369
|
"optional": false,
|
|
550
370
|
"docs": {
|
|
551
371
|
"tags": [],
|
|
552
|
-
"text": "
|
|
372
|
+
"text": "Client custom styling via string"
|
|
553
373
|
},
|
|
554
|
-
"attribute": "
|
|
555
|
-
"reflect": false
|
|
374
|
+
"attribute": "client-styling",
|
|
375
|
+
"reflect": false,
|
|
376
|
+
"defaultValue": "''"
|
|
556
377
|
},
|
|
557
|
-
"
|
|
378
|
+
"clientStylingUrl": {
|
|
558
379
|
"type": "string",
|
|
559
380
|
"mutable": false,
|
|
560
381
|
"complexType": {
|
|
@@ -566,11 +387,11 @@ export class GeneralRegistration {
|
|
|
566
387
|
"optional": false,
|
|
567
388
|
"docs": {
|
|
568
389
|
"tags": [],
|
|
569
|
-
"text": "
|
|
390
|
+
"text": "Client custom styling via url content"
|
|
570
391
|
},
|
|
571
|
-
"attribute": "
|
|
392
|
+
"attribute": "client-styling-url",
|
|
572
393
|
"reflect": false,
|
|
573
|
-
"defaultValue": "'
|
|
394
|
+
"defaultValue": "''"
|
|
574
395
|
}
|
|
575
396
|
}; }
|
|
576
397
|
static get states() { return {
|
|
@@ -579,11 +400,43 @@ export class GeneralRegistration {
|
|
|
579
400
|
"isFormValid": {},
|
|
580
401
|
"listOfInputs": {},
|
|
581
402
|
"isLoading": {},
|
|
403
|
+
"limitStylingAppends": {},
|
|
582
404
|
"registrationStep": {}
|
|
583
405
|
}; }
|
|
406
|
+
static get events() { return [{
|
|
407
|
+
"method": "registrationWidgetLoaded",
|
|
408
|
+
"name": "registrationWidgetLoaded",
|
|
409
|
+
"bubbles": true,
|
|
410
|
+
"cancelable": true,
|
|
411
|
+
"composed": true,
|
|
412
|
+
"docs": {
|
|
413
|
+
"tags": [],
|
|
414
|
+
"text": ""
|
|
415
|
+
},
|
|
416
|
+
"complexType": {
|
|
417
|
+
"original": "any",
|
|
418
|
+
"resolved": "any",
|
|
419
|
+
"references": {}
|
|
420
|
+
}
|
|
421
|
+
}, {
|
|
422
|
+
"method": "registrationStepUpdated",
|
|
423
|
+
"name": "registrationStepUpdated",
|
|
424
|
+
"bubbles": true,
|
|
425
|
+
"cancelable": true,
|
|
426
|
+
"composed": true,
|
|
427
|
+
"docs": {
|
|
428
|
+
"tags": [],
|
|
429
|
+
"text": ""
|
|
430
|
+
},
|
|
431
|
+
"complexType": {
|
|
432
|
+
"original": "string",
|
|
433
|
+
"resolved": "string",
|
|
434
|
+
"references": {}
|
|
435
|
+
}
|
|
436
|
+
}]; }
|
|
584
437
|
static get watchers() { return [{
|
|
585
438
|
"propName": "registrationStep",
|
|
586
|
-
"methodName": "
|
|
439
|
+
"methodName": "sendStep"
|
|
587
440
|
}]; }
|
|
588
441
|
static get listeners() { return [{
|
|
589
442
|
"name": "sendValidityState",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
2
|
import { t as translate } from './locale.utils.js';
|
|
3
3
|
|
|
4
|
-
const checkboxInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.checkbox__wrapper{display:flex;gap:10px;position:relative;align-items:baseline}.checkbox__error-message{position:absolute;top:calc(100% + 5px);left:0;color
|
|
4
|
+
const checkboxInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.checkbox{font-family:\"Roboto\";font-style:normal}.checkbox__wrapper{display:flex;gap:10px;position:relative;align-items:baseline}.checkbox__label{font-style:inherit;font-family:inherit;font-weight:400;font-size:16px;color:#2B2D3F;line-height:14px}.checkbox__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}";
|
|
5
5
|
|
|
6
6
|
const CheckboxInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
7
|
constructor() {
|
|
@@ -32,6 +32,12 @@ const CheckboxInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
32
32
|
valueHandler(inputValueEvent) {
|
|
33
33
|
this.sendInputValue.emit(inputValueEvent);
|
|
34
34
|
}
|
|
35
|
+
componentDidLoad() {
|
|
36
|
+
if (this.defaultValue) {
|
|
37
|
+
this.value = this.defaultValue;
|
|
38
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
35
41
|
handleClick() {
|
|
36
42
|
this.value = this.inputReference.checked.toString();
|
|
37
43
|
this.errorMessage = this.setErrorMessage();
|
|
@@ -48,7 +54,7 @@ const CheckboxInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
56
|
render() {
|
|
51
|
-
return h("div", { class: 'checkbox__wrapper' }, h("input", { type: "checkbox", id: `${this.name}__input`, ref: (el) => this.inputReference = el, name: this.name, checked: !!this.defaultValue, readOnly: this.autofilled, required: this.validation.mandatory, value: this.value, onClick: () => this.handleClick() }), h("label", { htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), h("small", { class: 'checkbox__error-message' }, this.errorMessage));
|
|
57
|
+
return h("div", { class: 'checkbox__wrapper' }, h("input", { type: "checkbox", id: `${this.name}__input`, ref: (el) => this.inputReference = el, name: this.name, checked: !!this.defaultValue, readOnly: this.autofilled, required: this.validation.mandatory, value: this.value, onClick: () => this.handleClick() }), h("label", { class: 'checkbox__label', htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), h("small", { class: 'checkbox__error-message' }, this.errorMessage));
|
|
52
58
|
}
|
|
53
59
|
static get watchers() { return {
|
|
54
60
|
"isValid": ["validityChanged"],
|