@everymatrix/general-registration 1.10.5 → 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 +1124 -526
- package/dist/cjs/general-registration.cjs.js +2 -2
- package/dist/cjs/{index-ad0df8ea.js → index-68f93e1e.js} +9 -1
- 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 +142 -275
- package/dist/components/checkbox-input2.js +2 -2
- package/dist/components/date-input2.js +15 -1441
- package/dist/components/email-input2.js +18 -6
- package/dist/components/general-input2.js +6 -6
- package/dist/components/general-registration.js +100 -248
- package/dist/components/input-field-shared-styles.js +13776 -0
- package/dist/components/number-input2.js +1 -1
- package/dist/components/password-input2.js +738 -6
- package/dist/components/pattern-mixin.js +84 -0
- package/dist/components/radio-input2.js +1 -1
- package/dist/components/select-input2.js +4 -4
- package/dist/components/tel-input2.js +12 -8
- package/dist/components/text-input2.js +17 -13
- 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 +1124 -526
- package/dist/esm/general-registration.js +2 -2
- package/dist/esm/{index-bb9c8eb3.js → index-16916adb.js} +9 -1
- 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-8a77bab6.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 +4 -2
- 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-4800d8b4.js +0 -1
|
@@ -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 emailInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.email__wrapper{position:relative;
|
|
4
|
+
const emailInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.email{font-family:\"Roboto\";font-style:normal}.email__wrapper{position:relative;width:100%;padding-top:26px}.email__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.email__label--required::after{content:\"*\";font-family:inherit;color:#1F1F1F;margin-left:2px}.email__input{border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px;color:#2A2E3F;padding:8px 20px;width:inherit;position:relative;border:2px solid #DEE1EE}.email__input:focus{outline-color:#3E3E3E}.email__input--invalid{border:2px solid #cc0000b3}.email__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}";
|
|
5
5
|
|
|
6
6
|
const EmailInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
7
|
constructor() {
|
|
@@ -18,17 +18,24 @@ const EmailInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
18
18
|
this.valueHandler({ name: this.name, value: this.value });
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
validityStateHandler(inputStateEvent) {
|
|
22
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
23
|
-
}
|
|
24
21
|
emitValueHandler(newValue) {
|
|
25
22
|
if (newValue == true && this.isValid) {
|
|
26
23
|
this.valueHandler({ name: this.name, value: this.value });
|
|
27
24
|
}
|
|
28
25
|
}
|
|
26
|
+
validityStateHandler(inputStateEvent) {
|
|
27
|
+
this.sendValidityState.emit(inputStateEvent);
|
|
28
|
+
}
|
|
29
29
|
valueHandler(inputValueEvent) {
|
|
30
30
|
this.sendInputValue.emit(inputValueEvent);
|
|
31
31
|
}
|
|
32
|
+
valueChangedHandler(event) {
|
|
33
|
+
if (this.isDuplicateInput) {
|
|
34
|
+
if (this.name === event.detail.name + 'Duplicate') {
|
|
35
|
+
this.duplicateInputValue = event.detail.value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
32
39
|
connectedCallback() {
|
|
33
40
|
this.validationPattern = this.setPattern();
|
|
34
41
|
}
|
|
@@ -65,9 +72,13 @@ const EmailInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
65
72
|
if (this.inputReference.validity.valueMissing) {
|
|
66
73
|
return translate('requiredError', this.language);
|
|
67
74
|
}
|
|
75
|
+
if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
|
|
76
|
+
return this.validation.custom.find(customRule => customRule.rule === 'duplicate-input').errorMessage;
|
|
77
|
+
}
|
|
68
78
|
}
|
|
69
79
|
render() {
|
|
70
|
-
|
|
80
|
+
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'email__input--invalid';
|
|
81
|
+
return h("div", { class: 'email__wrapper' }, h("input", { id: `${this.name}__input`, type: 'email', class: `email__input ${invalidClass}`, value: this.defaultValue, readOnly: this.autofilled, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onBlur: (e) => this.handleInput(e) }), h("label", { class: `email__label ${this.validation.mandatory ? 'email__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("small", { class: 'email__error-message' }, this.errorMessage));
|
|
71
82
|
}
|
|
72
83
|
static get watchers() { return {
|
|
73
84
|
"isValid": ["validityChanged"],
|
|
@@ -82,9 +93,10 @@ const EmailInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
82
93
|
"autofilled": [4],
|
|
83
94
|
"language": [1],
|
|
84
95
|
"emitValue": [4, "emit-value"],
|
|
96
|
+
"isDuplicateInput": [4, "is-duplicate-input"],
|
|
85
97
|
"errorMessage": [32],
|
|
86
98
|
"isValid": [32]
|
|
87
|
-
}]);
|
|
99
|
+
}, [[16, "sendInputValue", "valueChangedHandler"]]]);
|
|
88
100
|
function defineCustomElement() {
|
|
89
101
|
if (typeof customElements === "undefined") {
|
|
90
102
|
return;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
|
-
import './
|
|
2
|
+
import './input-field-shared-styles.js';
|
|
3
3
|
import { d as defineCustomElement$8 } from './date-input2.js';
|
|
4
4
|
import { d as defineCustomElement$9 } from './checkbox-input2.js';
|
|
5
5
|
import { d as defineCustomElement$7 } from './email-input2.js';
|
|
@@ -25,9 +25,9 @@ const GeneralInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
25
25
|
render() {
|
|
26
26
|
switch (this.type.toLowerCase()) {
|
|
27
27
|
case 'text':
|
|
28
|
-
return h("text-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
28
|
+
return h("text-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput });
|
|
29
29
|
case 'email':
|
|
30
|
-
return h("email-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
30
|
+
return h("email-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput });
|
|
31
31
|
case 'number':
|
|
32
32
|
return h("number-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
33
33
|
case 'checkbox':
|
|
@@ -35,7 +35,7 @@ const GeneralInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
35
35
|
case 'datetime':
|
|
36
36
|
return h("date-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
37
37
|
case 'password':
|
|
38
|
-
return h("password-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
38
|
+
return h("password-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput });
|
|
39
39
|
case 'radio':
|
|
40
40
|
return h("radio-input", { name: this.name, displayName: this.displayName, optionsGroup: this.options, validation: this.validation, emitValue: this.emitValue, language: this.language });
|
|
41
41
|
case 'tel':
|
|
@@ -43,7 +43,6 @@ const GeneralInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
43
43
|
case 'dropdown':
|
|
44
44
|
return h("select-input", { name: this.name, action: this.action, defaultValue: this.defaultValue, displayName: this.displayName, options: this.options, validation: this.validation, emitValue: this.emitValue, autofilled: this.autofilled, language: this.language });
|
|
45
45
|
default:
|
|
46
|
-
// Nothing here
|
|
47
46
|
return h("p", null, "The ", this.type, " input type is not valid");
|
|
48
47
|
}
|
|
49
48
|
}
|
|
@@ -58,7 +57,8 @@ const GeneralInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
58
57
|
"language": [1],
|
|
59
58
|
"autofilled": [4],
|
|
60
59
|
"defaultValue": [8, "default-value"],
|
|
61
|
-
"emitValue": [4, "emit-value"]
|
|
60
|
+
"emitValue": [4, "emit-value"],
|
|
61
|
+
"isDuplicateInput": [4, "is-duplicate-input"]
|
|
62
62
|
}]);
|
|
63
63
|
function defineCustomElement() {
|
|
64
64
|
if (typeof customElements === "undefined") {
|
|
@@ -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';
|
|
@@ -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.
|
|
@@ -289,18 +105,22 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
289
105
|
this.stepsStateMachine({ event: 'set', type: 'values' });
|
|
290
106
|
}
|
|
291
107
|
componentWillLoad() {
|
|
292
|
-
// const mockCall = Promise.resolve(this.data);
|
|
293
|
-
// return mockCall.then((data) => {
|
|
294
|
-
// this.listOfInputs = data.content.fields.map((field) => {
|
|
295
|
-
// this.isLoading = false;
|
|
296
|
-
// return { ...field, isValid: false };
|
|
297
|
-
// });
|
|
298
|
-
// });
|
|
299
108
|
return this.getRegisterConfig().then((config) => {
|
|
300
109
|
this.formatConfig(config);
|
|
301
110
|
this.stepsStateMachine({ event: 'set', type: 'inputs' });
|
|
302
111
|
});
|
|
303
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
|
+
}
|
|
304
124
|
nextHandler(e) {
|
|
305
125
|
e.preventDefault();
|
|
306
126
|
// Trigger events in subwidgets.
|
|
@@ -309,8 +129,8 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
309
129
|
}
|
|
310
130
|
backHandler(e) {
|
|
311
131
|
e.preventDefault();
|
|
312
|
-
this.
|
|
313
|
-
this.registrationStep = this.
|
|
132
|
+
this.isLastStep = false;
|
|
133
|
+
this.registrationStep = this.stepChange('decrement');
|
|
314
134
|
this.stepsStateMachine({ event: 'get', type: 'inputs' });
|
|
315
135
|
this.stepsStateMachine({ event: 'get', type: 'values' });
|
|
316
136
|
}
|
|
@@ -319,10 +139,11 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
319
139
|
case 'set':
|
|
320
140
|
if (state.type == 'inputs') {
|
|
321
141
|
this.registrationStepsState[this.registrationStep].fields = this.listOfInputs;
|
|
142
|
+
this.registrationStepsState[this.registrationStep].actions = this.listOfActions;
|
|
322
143
|
}
|
|
323
144
|
if (state.type == 'values') {
|
|
324
145
|
this.registrationStepsState[this.registrationStep].registerUserData = this.listOfInputValues.reduce((acc, curr) => {
|
|
325
|
-
acc[curr.name] = curr.value;
|
|
146
|
+
acc[curr.name] = { value: curr.value, isDuplicate: curr.isDuplicate };
|
|
326
147
|
return acc;
|
|
327
148
|
}, {});
|
|
328
149
|
}
|
|
@@ -334,17 +155,19 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
334
155
|
return;
|
|
335
156
|
if (state.type == 'inputs') {
|
|
336
157
|
this.listOfInputs = this.registrationStepsState[this.registrationStep].fields;
|
|
158
|
+
this.listOfActions = this.registrationStepsState[this.registrationStep].actions;
|
|
337
159
|
}
|
|
338
160
|
if (state.type == 'values') {
|
|
339
161
|
const savedValues = savedUserData[this.registrationStep].registerUserData;
|
|
340
162
|
this.listOfInputValues = Object.keys(savedValues).map(name => {
|
|
341
|
-
return { name, value: savedValues[name] };
|
|
163
|
+
return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
|
|
342
164
|
});
|
|
343
165
|
// Give to each field the user input as the default value.
|
|
344
166
|
this.listOfInputValues.forEach(inputValue => {
|
|
345
167
|
const input = this.listOfInputs.find(input => input.name === inputValue.name);
|
|
346
168
|
if (input) {
|
|
347
169
|
input.defaultValue = inputValue.value;
|
|
170
|
+
console.log(input);
|
|
348
171
|
}
|
|
349
172
|
});
|
|
350
173
|
}
|
|
@@ -382,7 +205,9 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
382
205
|
const url = new URL(`${this.endpoint}/v1/player/legislation/registration/step`);
|
|
383
206
|
const registerStep = {
|
|
384
207
|
registrationId: this.registrationID,
|
|
385
|
-
registerUserDto: this.listOfInputValues
|
|
208
|
+
registerUserDto: this.listOfInputValues
|
|
209
|
+
.filter(input => !input.isDuplicate)
|
|
210
|
+
.reduce((acc, curr) => {
|
|
386
211
|
// Special case for "Mobile" as it needs to be split in two values -- API expects it this way.
|
|
387
212
|
if (curr.name == "Mobile") {
|
|
388
213
|
acc['MobilePrefix'] = curr.value.split('|')[0];
|
|
@@ -416,12 +241,22 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
416
241
|
this.setRegister();
|
|
417
242
|
}
|
|
418
243
|
else {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
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
|
+
}
|
|
425
260
|
}
|
|
426
261
|
})
|
|
427
262
|
.catch((err) => {
|
|
@@ -463,60 +298,77 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
463
298
|
}
|
|
464
299
|
formatConfig(config) {
|
|
465
300
|
// Populate the list of inputs and set as invalid in the beginning
|
|
466
|
-
|
|
467
|
-
|
|
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
|
+
}
|
|
468
312
|
});
|
|
469
|
-
this.listOfInputs = JSON.parse(JSON.stringify(newListOfInputs));
|
|
470
313
|
// Populate the list of inputs values and set as null in the beginning
|
|
471
|
-
this.listOfInputValues =
|
|
472
|
-
return { name: field.name, value: null };
|
|
314
|
+
this.listOfInputValues = this.listOfInputs.map(field => {
|
|
315
|
+
return { name: field.name, value: null, isDuplicate: field.isDuplicateInput || false };
|
|
473
316
|
});
|
|
474
317
|
// Set the list of actions
|
|
475
318
|
this.listOfActions = config.content.actions.map(action => action);
|
|
476
319
|
this.isLastStep = this.listOfActions.some(action => action == '/register');
|
|
477
320
|
this.registrationID = config.content.registrationID;
|
|
478
321
|
this.registrationStep = config.content.step;
|
|
479
|
-
this.steps.push(this.registrationStep);
|
|
480
322
|
// Add the step to the registrationStepsData
|
|
481
323
|
this.registrationStepsState.regId = this.registrationID;
|
|
482
324
|
if (!this.registrationStepsState[this.registrationStep]) {
|
|
483
325
|
this.registrationStepsState[this.registrationStep] = {
|
|
484
326
|
fields: [],
|
|
485
|
-
registerUserData: {}
|
|
327
|
+
registerUserData: {},
|
|
328
|
+
actions: []
|
|
486
329
|
};
|
|
487
330
|
}
|
|
488
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
|
+
}
|
|
489
341
|
getInvalidStatus(listOfInputs) {
|
|
490
342
|
return listOfInputs.filter(input => input.isValid == false).length > 0;
|
|
491
343
|
}
|
|
492
344
|
renderInputs() {
|
|
493
|
-
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 })));
|
|
494
346
|
}
|
|
495
347
|
;
|
|
496
348
|
renderButtons() {
|
|
497
|
-
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))));
|
|
498
350
|
}
|
|
499
351
|
render() {
|
|
500
352
|
if (this.isLoading) {
|
|
501
353
|
return h("p", null, "Please wait, loading ...");
|
|
502
354
|
}
|
|
503
|
-
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()));
|
|
504
356
|
}
|
|
505
357
|
static get watchers() { return {
|
|
506
|
-
"registrationStep": ["
|
|
358
|
+
"registrationStep": ["sendStep"]
|
|
507
359
|
}; }
|
|
508
360
|
static get style() { return generalRegistrationCss; }
|
|
509
361
|
}, [1, "general-registration", {
|
|
510
362
|
"endpoint": [1],
|
|
511
|
-
"tenantId": [1, "tenant-id"],
|
|
512
|
-
"clientId": [1, "client-id"],
|
|
513
|
-
"apiKey": [1, "api-key"],
|
|
514
363
|
"language": [1],
|
|
364
|
+
"clientStyling": [1, "client-styling"],
|
|
365
|
+
"clientStylingUrl": [1, "client-styling-url"],
|
|
515
366
|
"errorMessage": [32],
|
|
516
367
|
"emitValue": [32],
|
|
517
368
|
"isFormValid": [32],
|
|
518
369
|
"listOfInputs": [32],
|
|
519
370
|
"isLoading": [32],
|
|
371
|
+
"limitStylingAppends": [32],
|
|
520
372
|
"registrationStep": [32]
|
|
521
373
|
}, [[0, "sendValidityState", "checkInputsValidityHandler"], [0, "sendInputValue", "getInputsValueHandler"]]]);
|
|
522
374
|
function defineCustomElement$1() {
|