@everymatrix/general-registration 1.10.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.
- package/dist/cjs/checkbox-input_11.cjs.entry.js +1165 -0
- package/dist/cjs/general-registration.cjs.js +19 -0
- package/dist/cjs/index-c04f4a2a.js +1264 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/collection/collection-manifest.json +28 -0
- package/dist/collection/components/general-registration/general-registration.css +45 -0
- package/dist/collection/components/general-registration/general-registration.js +529 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/utils.js +3 -0
- package/dist/components/checkbox-input.js +6 -0
- package/dist/components/checkbox-input2.js +78 -0
- package/dist/components/date-input.js +6 -0
- package/dist/components/date-input2.js +90 -0
- package/dist/components/email-input.js +6 -0
- package/dist/components/email-input2.js +108 -0
- package/dist/components/general-input.js +6 -0
- package/dist/components/general-input2.js +120 -0
- package/dist/components/general-registration.d.ts +11 -0
- package/dist/components/general-registration.js +530 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/components/locale.utils.js +29 -0
- package/dist/components/number-input.js +6 -0
- package/dist/components/number-input2.js +96 -0
- package/dist/components/password-input.js +6 -0
- package/dist/components/password-input2.js +93 -0
- package/dist/components/radio-input.js +6 -0
- package/dist/components/radio-input2.js +89 -0
- package/dist/components/select-input.js +6 -0
- package/dist/components/select-input2.js +127 -0
- package/dist/components/tel-input.js +6 -0
- package/dist/components/tel-input2.js +111 -0
- package/dist/components/text-input.js +6 -0
- package/dist/components/text-input2.js +112 -0
- package/dist/esm/checkbox-input_11.entry.js +1151 -0
- package/dist/esm/general-registration.js +17 -0
- package/dist/esm/index-79f297c1.js +1238 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/general-registration/general-registration.esm.js +1 -0
- package/dist/general-registration/index.esm.js +0 -0
- package/dist/general-registration/p-0e7175cd.js +1 -0
- package/dist/general-registration/p-cadaffbe.entry.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.js +22 -0
- package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/locale.utils.d.ts +5 -0
- package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/types.d.ts +55 -0
- package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/general-registration/.stencil/packages/general-registration/stencil.config.d.ts +2 -0
- package/dist/types/components/general-registration/general-registration.d.ts +67 -0
- package/dist/types/components.d.ts +77 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +22 -0
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
|
+
import { d as defineCustomElement$b } from './checkbox-input2.js';
|
|
3
|
+
import { d as defineCustomElement$a } from './date-input2.js';
|
|
4
|
+
import { d as defineCustomElement$9 } from './email-input2.js';
|
|
5
|
+
import { d as defineCustomElement$8 } from './general-input2.js';
|
|
6
|
+
import { d as defineCustomElement$7 } from './number-input2.js';
|
|
7
|
+
import { d as defineCustomElement$6 } from './password-input2.js';
|
|
8
|
+
import { d as defineCustomElement$5 } from './radio-input2.js';
|
|
9
|
+
import { d as defineCustomElement$4 } from './select-input2.js';
|
|
10
|
+
import { d as defineCustomElement$3 } from './tel-input2.js';
|
|
11
|
+
import { d as defineCustomElement$2 } from './text-input2.js';
|
|
12
|
+
|
|
13
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
14
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en'];
|
|
15
|
+
const TRANSLATIONS = {
|
|
16
|
+
en: {
|
|
17
|
+
dateError: 'The selected date should be between {min} and {max}',
|
|
18
|
+
numberLengthError: 'The number should be between ${min} and ${max}',
|
|
19
|
+
lengthError: `The length should be between {minLength} and {maxLength}`,
|
|
20
|
+
requiredError: 'This input is required.',
|
|
21
|
+
nextButton: 'Next',
|
|
22
|
+
backButton: 'Back'
|
|
23
|
+
},
|
|
24
|
+
ro: {
|
|
25
|
+
lengthError: `Cuvântul introdus este prea scurt. {minLength} and {maxLength}`,
|
|
26
|
+
requiredError: 'Acest câmp este obligatoriu.'
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const translate = (key, customLang, values) => {
|
|
30
|
+
const lang = customLang;
|
|
31
|
+
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
32
|
+
if (values !== undefined) {
|
|
33
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
34
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
35
|
+
translation = translation.replace(regex, value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return translation;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const generalRegistrationCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.registration{display:flex;flex-direction:column;gap:20px;width:100%;height:100%}.registration__form{display:grid;grid-template-columns:repeat(2, minmax(min-content, 1fr));column-gap:65px;row-gap:30px;justify-items:stretch;align-content:flex-start;overflow:scroll;width:100%;height:100%}.registration__buttons-wrapper{display:flex;flex-direction:row-reverse;justify-content:space-between}.registration__button{background-color:#e69200;border-radius:30px;text-transform:uppercase;padding:10px 50px;border:none;box-shadow:0px 2px 2px rgba(0, 0, 0, 0.5)}.registration__button--disabled{background-color:grey}.registration__button--done{background-color:#176317}";
|
|
42
|
+
|
|
43
|
+
const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
44
|
+
constructor() {
|
|
45
|
+
super();
|
|
46
|
+
this.__registerHost();
|
|
47
|
+
this.__attachShadow();
|
|
48
|
+
this.data = {
|
|
49
|
+
"type": "default",
|
|
50
|
+
"content": {
|
|
51
|
+
"step": "step1",
|
|
52
|
+
"fields": [
|
|
53
|
+
{
|
|
54
|
+
"name": "firstName",
|
|
55
|
+
"displayName": "Username",
|
|
56
|
+
"defaultValue": null,
|
|
57
|
+
"validate": {
|
|
58
|
+
"mandatory": true,
|
|
59
|
+
"minLength": 3,
|
|
60
|
+
"maxLength": 20
|
|
61
|
+
},
|
|
62
|
+
"autofill": false
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "firstName",
|
|
66
|
+
"displayName": "Username",
|
|
67
|
+
"defaultValue": null,
|
|
68
|
+
"validate": {
|
|
69
|
+
"mandatory": true,
|
|
70
|
+
"minLength": 3,
|
|
71
|
+
"maxLength": 20
|
|
72
|
+
},
|
|
73
|
+
"autofill": false
|
|
74
|
+
},
|
|
75
|
+
// {
|
|
76
|
+
// "name": "tel",
|
|
77
|
+
// "displayName": "Telephone",
|
|
78
|
+
// "defaultValue": null,
|
|
79
|
+
// "validate": {
|
|
80
|
+
// "mandatory": true
|
|
81
|
+
// },
|
|
82
|
+
// "autofill": false,
|
|
83
|
+
// "inputType": "tel"
|
|
84
|
+
// },
|
|
85
|
+
// {
|
|
86
|
+
// "name": "dateOfBirth",
|
|
87
|
+
// "displayName": "Date of Birth",
|
|
88
|
+
// "defaultValue": null,
|
|
89
|
+
// "validate": {
|
|
90
|
+
// "min": "2023-04-01",
|
|
91
|
+
// "max": "2023-04-29",
|
|
92
|
+
// "mandatory": true,
|
|
93
|
+
// },
|
|
94
|
+
// "inputType": "datetime"
|
|
95
|
+
// },
|
|
96
|
+
// {
|
|
97
|
+
// "name": "email",
|
|
98
|
+
// "displayName": "Email",
|
|
99
|
+
// "defaultValue": 'a@a.com',
|
|
100
|
+
// "validate": {
|
|
101
|
+
// "mandatory": true,
|
|
102
|
+
// "custom": [
|
|
103
|
+
// {
|
|
104
|
+
// "rule": "regex",
|
|
105
|
+
// "pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
106
|
+
// "errorMessage": "Please enter a valid email address"
|
|
107
|
+
// }
|
|
108
|
+
// ]
|
|
109
|
+
// },
|
|
110
|
+
// "inputType": "email"
|
|
111
|
+
// },
|
|
112
|
+
// {
|
|
113
|
+
// "name": "lastName",
|
|
114
|
+
// "displayName": "Last name",
|
|
115
|
+
// "defaultValue": null,
|
|
116
|
+
// "validate": {
|
|
117
|
+
// "mandatory": true,
|
|
118
|
+
// "minLength": 3,
|
|
119
|
+
// "maxLength": 20
|
|
120
|
+
// },
|
|
121
|
+
// },
|
|
122
|
+
// {
|
|
123
|
+
// "name": "password",
|
|
124
|
+
// "displayName": "Password",
|
|
125
|
+
// "defaultValue": null,
|
|
126
|
+
// "validate": {
|
|
127
|
+
// "mandatory": true,
|
|
128
|
+
// "minLength": 3,
|
|
129
|
+
// "maxLength": 20,
|
|
130
|
+
// "type": "password",
|
|
131
|
+
// "custom": [
|
|
132
|
+
// {
|
|
133
|
+
// "rule": "regex",
|
|
134
|
+
// "pattern": "(?=.*\\d+)(?=.*[A-Za-z]+).{8,20}",
|
|
135
|
+
// "errorMessage": "Password must contain at least 1 letter and 1 digit, and its minimal length is 8."
|
|
136
|
+
// }
|
|
137
|
+
// ]
|
|
138
|
+
// },
|
|
139
|
+
// "inputType": "password"
|
|
140
|
+
// },
|
|
141
|
+
// {
|
|
142
|
+
// "name": "email",
|
|
143
|
+
// "defaultValue": null,
|
|
144
|
+
// "validate": {
|
|
145
|
+
// "mandatory": true,
|
|
146
|
+
// "type": "email",
|
|
147
|
+
// "custom": [
|
|
148
|
+
// {
|
|
149
|
+
// "rule": "unique-email",
|
|
150
|
+
// "errorMessage": "Please check your email"
|
|
151
|
+
// },
|
|
152
|
+
// {
|
|
153
|
+
// "rule": "regex",
|
|
154
|
+
// "pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
155
|
+
// "errorMessage": "Please enter a valid email address"
|
|
156
|
+
// }
|
|
157
|
+
// ]
|
|
158
|
+
// }
|
|
159
|
+
// },
|
|
160
|
+
// {
|
|
161
|
+
// "name": "termsAndConditions",
|
|
162
|
+
// "displayName": "Terms and Conditions",
|
|
163
|
+
// "validate": {
|
|
164
|
+
// "mandatory": true,
|
|
165
|
+
// "type": "boolean"
|
|
166
|
+
// },
|
|
167
|
+
// "inputType": "checkbox"
|
|
168
|
+
// },
|
|
169
|
+
// {
|
|
170
|
+
// "name": "pepCheck",
|
|
171
|
+
// "validate": {
|
|
172
|
+
// "mandatory": true
|
|
173
|
+
// },
|
|
174
|
+
// "inputType": "checkbox"
|
|
175
|
+
// },
|
|
176
|
+
// {
|
|
177
|
+
// "name": "gender",
|
|
178
|
+
// "data": {
|
|
179
|
+
// "values": [
|
|
180
|
+
// {
|
|
181
|
+
// "label": "🍆",
|
|
182
|
+
// "value": "m"
|
|
183
|
+
// },
|
|
184
|
+
// {
|
|
185
|
+
// "label": "🍑",
|
|
186
|
+
// "value": "f"
|
|
187
|
+
// }
|
|
188
|
+
// ]
|
|
189
|
+
// },
|
|
190
|
+
// "validate": {
|
|
191
|
+
// "mandatory": true
|
|
192
|
+
// },
|
|
193
|
+
// "inputType": "radio"
|
|
194
|
+
// },
|
|
195
|
+
// {
|
|
196
|
+
// "name": "dateOfBirth",
|
|
197
|
+
// "validate": {
|
|
198
|
+
// "mandatory": true,
|
|
199
|
+
// "custom": [
|
|
200
|
+
// {
|
|
201
|
+
// "rule": "regex",
|
|
202
|
+
// "pattern": "(?:19\\d{2}|20[01][0-9]|2020)[-/.](?:0[1-9]|1[012])[-/.](?:0[1-9]|[12][0-9]|3[01])",
|
|
203
|
+
// "errorMessage": "Invalid date format"
|
|
204
|
+
// },
|
|
205
|
+
// {
|
|
206
|
+
// "rule": "min-18-years",
|
|
207
|
+
// "errorMessage": "Not old enough to ride the roller coaster"
|
|
208
|
+
// }
|
|
209
|
+
// ]
|
|
210
|
+
// }
|
|
211
|
+
// },
|
|
212
|
+
// {
|
|
213
|
+
// "name": "city",
|
|
214
|
+
// "displayName": "Cities",
|
|
215
|
+
// "action": null,
|
|
216
|
+
// "data": {
|
|
217
|
+
// "values": [
|
|
218
|
+
// {
|
|
219
|
+
// "label": "Budapest",
|
|
220
|
+
// "value": "Budapest"
|
|
221
|
+
// },
|
|
222
|
+
// {
|
|
223
|
+
// "label": "Debrecen",
|
|
224
|
+
// "value": "Debrecen"
|
|
225
|
+
// },
|
|
226
|
+
// {
|
|
227
|
+
// "label": "Miskolc",
|
|
228
|
+
// "value": "Miskolc"
|
|
229
|
+
// },
|
|
230
|
+
// {
|
|
231
|
+
// "label": "Szeged",
|
|
232
|
+
// "value": "Szeged"
|
|
233
|
+
// },
|
|
234
|
+
// {
|
|
235
|
+
// "label": "Zuglo",
|
|
236
|
+
// "value": "Zuglo"
|
|
237
|
+
// }
|
|
238
|
+
// ]
|
|
239
|
+
// },
|
|
240
|
+
// "validate": {
|
|
241
|
+
// "mandatory": true
|
|
242
|
+
// },
|
|
243
|
+
// "inputType" : "dropdown"
|
|
244
|
+
// },
|
|
245
|
+
// {
|
|
246
|
+
// "name": "city",
|
|
247
|
+
// "displayName": "Cities",
|
|
248
|
+
// "data": null,
|
|
249
|
+
// "action": "GET https://demo-api.stage.norway.everymatrix.com/v1/player/countries",
|
|
250
|
+
// "validate": {
|
|
251
|
+
// "mandatory": true
|
|
252
|
+
// },
|
|
253
|
+
// "inputType" : "dropdown"
|
|
254
|
+
// }
|
|
255
|
+
],
|
|
256
|
+
"actions": [
|
|
257
|
+
"get-next-step",
|
|
258
|
+
"some-async-action-before-submitting",
|
|
259
|
+
"submit-step-data"
|
|
260
|
+
]
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Currently selected language
|
|
265
|
+
*/
|
|
266
|
+
this.language = 'en';
|
|
267
|
+
this.emitValue = false;
|
|
268
|
+
this.listOfInputs = [];
|
|
269
|
+
this.isLoading = false;
|
|
270
|
+
this.listOfInputValues = [];
|
|
271
|
+
this.listOfActions = [];
|
|
272
|
+
this.actionsStepIndex = 0;
|
|
273
|
+
}
|
|
274
|
+
validityStateHandler() {
|
|
275
|
+
console.log('bababa', this.isFormValid);
|
|
276
|
+
this.buttonReference.disabled = this.isFormValid ? false : true;
|
|
277
|
+
}
|
|
278
|
+
checkInputsValidityHandler(event) {
|
|
279
|
+
console.log('se ajunge aici');
|
|
280
|
+
// Set isValid state of the input in the list.
|
|
281
|
+
this.listOfInputs.find(input => input.name == event.detail.name).isValid = event.detail.valid;
|
|
282
|
+
// Check if any one is invalid.
|
|
283
|
+
this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
|
|
284
|
+
}
|
|
285
|
+
getInputsValueHandler(event) {
|
|
286
|
+
console.log('sendInputValue');
|
|
287
|
+
this.listOfInputValues.find(input => input.name == event.detail.name).inputValue = event.detail.value;
|
|
288
|
+
/*Note to self: -- what about the inputs that received a default value.
|
|
289
|
+
They will send an undefined because there was no input
|
|
290
|
+
Handle it somehow!!!!!, one idea can be that value equals defaultValue but dependes on how the api wants stuff*/
|
|
291
|
+
}
|
|
292
|
+
connectedCallback() {
|
|
293
|
+
}
|
|
294
|
+
componentWillLoad() {
|
|
295
|
+
// const mockCall = Promise.resolve(this.data);
|
|
296
|
+
// return mockCall.then((data) => {
|
|
297
|
+
// this.listOfInputs = data.content.fields.map((field) => {
|
|
298
|
+
// return { ...field, isValid: false };
|
|
299
|
+
// });
|
|
300
|
+
// });
|
|
301
|
+
// Initial Fetch
|
|
302
|
+
return this.getRegisterConfig().then((config) => {
|
|
303
|
+
this.formatConfig(config);
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
nextHandler(e) {
|
|
307
|
+
e.preventDefault();
|
|
308
|
+
// Trigger events in subwidgets.
|
|
309
|
+
this.emitValue = true;
|
|
310
|
+
if (this.isFormValid) {
|
|
311
|
+
this.setRegisterStep();
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
getRegisterConfig(registrationID) {
|
|
315
|
+
const url = new URL(`${this.endpoint}/api/v1.0/registerCfg/`);
|
|
316
|
+
const headers = new Headers();
|
|
317
|
+
headers.append('X-Tenant-ID', this.tenantId);
|
|
318
|
+
headers.append('X-Client-ID', this.clientId);
|
|
319
|
+
headers.append('X-Api-Key', this.apiKey);
|
|
320
|
+
headers.append('Content-Type', 'application/json');
|
|
321
|
+
headers.append('Accept', 'application/json');
|
|
322
|
+
if (registrationID) {
|
|
323
|
+
url.searchParams.append('registrationId', registrationID);
|
|
324
|
+
}
|
|
325
|
+
const options = {
|
|
326
|
+
method: 'GET',
|
|
327
|
+
headers
|
|
328
|
+
};
|
|
329
|
+
return new Promise((resolve, reject) => {
|
|
330
|
+
this.isLoading = true;
|
|
331
|
+
fetch(url.href, options)
|
|
332
|
+
.then((res) => res.json())
|
|
333
|
+
.then((config) => {
|
|
334
|
+
resolve(config);
|
|
335
|
+
}).catch((err) => {
|
|
336
|
+
console.error(err);
|
|
337
|
+
reject(err);
|
|
338
|
+
}).finally(() => {
|
|
339
|
+
this.isLoading = false;
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
setRegisterStep() {
|
|
344
|
+
this.emitValue = false;
|
|
345
|
+
const url = new URL(`${this.endpoint}/api/v1.0/registerStep/`);
|
|
346
|
+
const registerStep = {
|
|
347
|
+
registrationId: this.registrationID,
|
|
348
|
+
registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
|
|
349
|
+
acc[curr.name] = curr.inputValue;
|
|
350
|
+
return acc;
|
|
351
|
+
}, {}),
|
|
352
|
+
step: this.registrationStep,
|
|
353
|
+
};
|
|
354
|
+
const headers = new Headers();
|
|
355
|
+
headers.append('X-Tenant-ID', this.tenantId);
|
|
356
|
+
headers.append('X-Client-ID', this.clientId);
|
|
357
|
+
headers.append('X-Api-Key', this.apiKey);
|
|
358
|
+
headers.append('Content-Type', 'application/json');
|
|
359
|
+
headers.append('Accept', 'application/json');
|
|
360
|
+
const options = {
|
|
361
|
+
method: 'POST',
|
|
362
|
+
body: JSON.stringify(registerStep),
|
|
363
|
+
headers
|
|
364
|
+
};
|
|
365
|
+
fetch(url.href, options)
|
|
366
|
+
.then((res) => {
|
|
367
|
+
if (res.status >= 300) {
|
|
368
|
+
throw new Error('err');
|
|
369
|
+
}
|
|
370
|
+
})
|
|
371
|
+
.then((data) => {
|
|
372
|
+
this.registrationID = data.registrationId;
|
|
373
|
+
if (this.listOfActions.some(action => action == '/register')) {
|
|
374
|
+
this.setRegister();
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
this.getRegisterConfig(this.registrationID).then((config) => this.formatConfig(config));
|
|
378
|
+
}
|
|
379
|
+
})
|
|
380
|
+
.catch((err) => {
|
|
381
|
+
console.error(err);
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
setRegister() {
|
|
385
|
+
const url = new URL(`${this.endpoint}/api/v1.0/register/`);
|
|
386
|
+
const headers = new Headers();
|
|
387
|
+
headers.append('X-Tenant-ID', this.tenantId);
|
|
388
|
+
headers.append('X-Client-ID', this.clientId);
|
|
389
|
+
headers.append('X-Api-Key', this.apiKey);
|
|
390
|
+
headers.append('Content-Type', 'application/json');
|
|
391
|
+
headers.append('Accept', 'application/json');
|
|
392
|
+
const registerStep = {
|
|
393
|
+
registrationId: this.registrationID,
|
|
394
|
+
registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
|
|
395
|
+
acc[curr.name] = curr.inputValue;
|
|
396
|
+
return acc;
|
|
397
|
+
}, {}),
|
|
398
|
+
step: this.registrationStep,
|
|
399
|
+
};
|
|
400
|
+
const options = {
|
|
401
|
+
method: 'POST',
|
|
402
|
+
body: JSON.stringify(registerStep),
|
|
403
|
+
headers
|
|
404
|
+
};
|
|
405
|
+
fetch(url.href, options)
|
|
406
|
+
.then((res) => {
|
|
407
|
+
if (res.status >= 300) {
|
|
408
|
+
throw new Error('err');
|
|
409
|
+
}
|
|
410
|
+
})
|
|
411
|
+
.then((data) => {
|
|
412
|
+
console.log(data);
|
|
413
|
+
})
|
|
414
|
+
.catch((err) => {
|
|
415
|
+
console.log(err);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
formatConfig(config) {
|
|
419
|
+
// Populate the list of inputs and set as invalid in the beginning
|
|
420
|
+
this.listOfInputs = config.content.fields.map((field) => {
|
|
421
|
+
return Object.assign(Object.assign({}, field), { isValid: false });
|
|
422
|
+
});
|
|
423
|
+
// Populate the list of inputs values and set as null in the beginning
|
|
424
|
+
this.listOfInputValues = config.content.fields.map(field => {
|
|
425
|
+
return { name: field.name, inputValue: null };
|
|
426
|
+
});
|
|
427
|
+
// Set the list of actions
|
|
428
|
+
this.listOfActions = config.content.actions.map(action => action);
|
|
429
|
+
this.registrationID = config.content.registrationID;
|
|
430
|
+
this.registrationStep = config.content.step;
|
|
431
|
+
}
|
|
432
|
+
getInvalidStatus(listOfInputs) {
|
|
433
|
+
return listOfInputs.filter(input => input.isValid == false).length > 0;
|
|
434
|
+
}
|
|
435
|
+
renderInputs() {
|
|
436
|
+
/*let aux = this.listOfInputs;
|
|
437
|
+
this.listOfInputs = [];
|
|
438
|
+
this.listOfInputs = aux;*/
|
|
439
|
+
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, emitValue: this.emitValue, language: this.language })));
|
|
440
|
+
}
|
|
441
|
+
;
|
|
442
|
+
renderButtons() {
|
|
443
|
+
return (h("div", { class: 'registration__buttons-wrapper' }, h("button", { class: 'registration__button', type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e), ref: (el) => this.buttonReference = el }, translate('nextButton', this.language)), h("button", { class: 'registration__button' }, translate('backButton', this.language))));
|
|
444
|
+
}
|
|
445
|
+
render() {
|
|
446
|
+
return (h("div", { class: 'registration' }, h("form", { action: '.', id: 'RegistrationForm', class: 'registration__form' }, this.renderInputs()), this.renderButtons()));
|
|
447
|
+
}
|
|
448
|
+
static get watchers() { return {
|
|
449
|
+
"isFormValid": ["validityStateHandler"]
|
|
450
|
+
}; }
|
|
451
|
+
static get style() { return generalRegistrationCss; }
|
|
452
|
+
}, [1, "general-registration", {
|
|
453
|
+
"endpoint": [1],
|
|
454
|
+
"tenantId": [1, "tenant-id"],
|
|
455
|
+
"clientId": [1, "client-id"],
|
|
456
|
+
"apiKey": [1, "api-key"],
|
|
457
|
+
"language": [1],
|
|
458
|
+
"errorMessage": [32],
|
|
459
|
+
"emitValue": [32],
|
|
460
|
+
"isFormValid": [32],
|
|
461
|
+
"listOfInputs": [32]
|
|
462
|
+
}, [[0, "sendValidityState", "checkInputsValidityHandler"], [0, "sendInputValue", "getInputsValueHandler"]]]);
|
|
463
|
+
function defineCustomElement$1() {
|
|
464
|
+
if (typeof customElements === "undefined") {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const components = ["general-registration", "checkbox-input", "date-input", "email-input", "general-input", "number-input", "password-input", "radio-input", "select-input", "tel-input", "text-input"];
|
|
468
|
+
components.forEach(tagName => { switch (tagName) {
|
|
469
|
+
case "general-registration":
|
|
470
|
+
if (!customElements.get(tagName)) {
|
|
471
|
+
customElements.define(tagName, GeneralRegistration$1);
|
|
472
|
+
}
|
|
473
|
+
break;
|
|
474
|
+
case "checkbox-input":
|
|
475
|
+
if (!customElements.get(tagName)) {
|
|
476
|
+
defineCustomElement$b();
|
|
477
|
+
}
|
|
478
|
+
break;
|
|
479
|
+
case "date-input":
|
|
480
|
+
if (!customElements.get(tagName)) {
|
|
481
|
+
defineCustomElement$a();
|
|
482
|
+
}
|
|
483
|
+
break;
|
|
484
|
+
case "email-input":
|
|
485
|
+
if (!customElements.get(tagName)) {
|
|
486
|
+
defineCustomElement$9();
|
|
487
|
+
}
|
|
488
|
+
break;
|
|
489
|
+
case "general-input":
|
|
490
|
+
if (!customElements.get(tagName)) {
|
|
491
|
+
defineCustomElement$8();
|
|
492
|
+
}
|
|
493
|
+
break;
|
|
494
|
+
case "number-input":
|
|
495
|
+
if (!customElements.get(tagName)) {
|
|
496
|
+
defineCustomElement$7();
|
|
497
|
+
}
|
|
498
|
+
break;
|
|
499
|
+
case "password-input":
|
|
500
|
+
if (!customElements.get(tagName)) {
|
|
501
|
+
defineCustomElement$6();
|
|
502
|
+
}
|
|
503
|
+
break;
|
|
504
|
+
case "radio-input":
|
|
505
|
+
if (!customElements.get(tagName)) {
|
|
506
|
+
defineCustomElement$5();
|
|
507
|
+
}
|
|
508
|
+
break;
|
|
509
|
+
case "select-input":
|
|
510
|
+
if (!customElements.get(tagName)) {
|
|
511
|
+
defineCustomElement$4();
|
|
512
|
+
}
|
|
513
|
+
break;
|
|
514
|
+
case "tel-input":
|
|
515
|
+
if (!customElements.get(tagName)) {
|
|
516
|
+
defineCustomElement$3();
|
|
517
|
+
}
|
|
518
|
+
break;
|
|
519
|
+
case "text-input":
|
|
520
|
+
if (!customElements.get(tagName)) {
|
|
521
|
+
defineCustomElement$2();
|
|
522
|
+
}
|
|
523
|
+
break;
|
|
524
|
+
} });
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
const GeneralRegistration = GeneralRegistration$1;
|
|
528
|
+
const defineCustomElement = defineCustomElement$1;
|
|
529
|
+
|
|
530
|
+
export { GeneralRegistration, defineCustomElement };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* GeneralRegistration custom elements */
|
|
2
|
+
|
|
3
|
+
import type { Components, JSX } from "../types/components";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Used to manually set the base path where assets can be found.
|
|
7
|
+
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
8
|
+
* such as "setAssetPath(import.meta.url)". Other options include
|
|
9
|
+
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
10
|
+
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
11
|
+
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
12
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
13
|
+
* will have to ensure the static assets are copied to its build directory.
|
|
14
|
+
*/
|
|
15
|
+
export declare const setAssetPath: (path: string) => void;
|
|
16
|
+
|
|
17
|
+
export interface SetPlatformOptions {
|
|
18
|
+
raf?: (c: FrameRequestCallback) => number;
|
|
19
|
+
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
20
|
+
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|
|
23
|
+
|
|
24
|
+
export type { Components, JSX };
|
|
25
|
+
|
|
26
|
+
export * from '../types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en'];
|
|
3
|
+
const TRANSLATIONS = {
|
|
4
|
+
en: {
|
|
5
|
+
dateError: 'The selected date should be between {min} and {max}',
|
|
6
|
+
numberLengthError: 'The number should be between ${min} and ${max}',
|
|
7
|
+
lengthError: `The length should be between {minLength} and {maxLength}`,
|
|
8
|
+
requiredError: 'This input is required.',
|
|
9
|
+
nextButton: 'Next',
|
|
10
|
+
backButton: 'Back'
|
|
11
|
+
},
|
|
12
|
+
ro: {
|
|
13
|
+
lengthError: `Cuvântul introdus este prea scurt. {minLength} and {maxLength}`,
|
|
14
|
+
requiredError: 'Acest câmp este obligatoriu.'
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const translate = (key, customLang, values) => {
|
|
18
|
+
const lang = customLang;
|
|
19
|
+
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
20
|
+
if (values !== undefined) {
|
|
21
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
22
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
23
|
+
translation = translation.replace(regex, value);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return translation;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { translate as t };
|