@everymatrix/general-registration 1.10.5 → 1.10.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/cjs/checkbox-input_11.cjs.entry.js +1126 -526
  2. package/dist/cjs/general-registration.cjs.js +2 -2
  3. package/dist/cjs/{index-ad0df8ea.js → index-68f93e1e.js} +9 -1
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/collection/components/general-registration/general-registration.css +40 -14
  6. package/dist/collection/components/general-registration/general-registration.js +144 -275
  7. package/dist/components/checkbox-input2.js +2 -2
  8. package/dist/components/date-input2.js +15 -1441
  9. package/dist/components/email-input2.js +18 -6
  10. package/dist/components/general-input2.js +6 -6
  11. package/dist/components/general-registration.js +102 -248
  12. package/dist/components/input-field-shared-styles.js +13776 -0
  13. package/dist/components/number-input2.js +1 -1
  14. package/dist/components/password-input2.js +738 -6
  15. package/dist/components/pattern-mixin.js +84 -0
  16. package/dist/components/radio-input2.js +1 -1
  17. package/dist/components/select-input2.js +4 -4
  18. package/dist/components/tel-input2.js +12 -8
  19. package/dist/components/text-input2.js +17 -13
  20. package/dist/components/vaadin-button.js +1432 -0
  21. package/dist/components/vaadin-combo-box.js +3 -82
  22. package/dist/components/virtual-keyboard-controller.js +2136 -15909
  23. package/dist/esm/checkbox-input_11.entry.js +1126 -526
  24. package/dist/esm/general-registration.js +2 -2
  25. package/dist/esm/{index-bb9c8eb3.js → index-16916adb.js} +9 -1
  26. package/dist/esm/loader.js +2 -2
  27. package/dist/general-registration/general-registration.esm.js +1 -1
  28. package/dist/general-registration/p-8f644809.js +1 -0
  29. package/dist/general-registration/{p-8a77bab6.entry.js → p-b5f7ebdd.entry.js} +210 -100
  30. 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
  31. package/dist/types/components/general-registration/general-registration.d.ts +20 -284
  32. package/dist/types/components.d.ts +11 -17
  33. package/package.json +3 -2
  34. 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;display:flex;flex-direction:column-reverse;padding-top:10px}.email__label{color:#474747;font-size:16px;position:absolute;bottom:15px;left:5px;transform:translateY(-25px);transition:all 0.3s cubic-bezier(0.5, 0, 0.5, 1)}.email__label--required::after{content:\"*\";margin-left:5px;color:#666666}.email__input{width:inherit;padding:15px 6px;position:relative;border:none;border-bottom:3px solid #666666;background-color:transparent;color:#666666;font-size:16px;font-family:inherit}.email__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.email__input::placeholder{color:#666666}.email__input--invalid{border-bottom:3px solid #cc0000}.email__input:placeholder-shown+.email__label{opacity:0;visibility:hidden;transform:translateY(0)}.email__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
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
- return h("div", { class: 'email__wrapper' }, h("input", { id: `${this.name}__input`, type: 'email', class: `email__input`, 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));
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 './virtual-keyboard-controller.js';
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 = "*,*::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
+ 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.data = {
50
- "type": "default",
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.steps = [];
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
- logger() {
275
- console.log(this.registrationStep);
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,24 @@ 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
+ if (this.clientStyling)
116
+ this.setClientStyling();
117
+ if (this.clientStylingUrl)
118
+ this.setClientStylingURL();
119
+ this.limitStylingAppends = true;
120
+ }
121
+ }
122
+ componentDidLoad() {
123
+ this.registrationWidgetLoaded.emit();
124
+ window.postMessage({ type: 'registrationWidgetLoaded' }, window.location.href);
125
+ }
304
126
  nextHandler(e) {
305
127
  e.preventDefault();
306
128
  // Trigger events in subwidgets.
@@ -309,8 +131,8 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
309
131
  }
310
132
  backHandler(e) {
311
133
  e.preventDefault();
312
- this.steps.pop();
313
- this.registrationStep = this.steps.at(-1);
134
+ this.isLastStep = false;
135
+ this.registrationStep = this.stepChange('decrement');
314
136
  this.stepsStateMachine({ event: 'get', type: 'inputs' });
315
137
  this.stepsStateMachine({ event: 'get', type: 'values' });
316
138
  }
@@ -319,10 +141,11 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
319
141
  case 'set':
320
142
  if (state.type == 'inputs') {
321
143
  this.registrationStepsState[this.registrationStep].fields = this.listOfInputs;
144
+ this.registrationStepsState[this.registrationStep].actions = this.listOfActions;
322
145
  }
323
146
  if (state.type == 'values') {
324
147
  this.registrationStepsState[this.registrationStep].registerUserData = this.listOfInputValues.reduce((acc, curr) => {
325
- acc[curr.name] = curr.value;
148
+ acc[curr.name] = { value: curr.value, isDuplicate: curr.isDuplicate };
326
149
  return acc;
327
150
  }, {});
328
151
  }
@@ -334,17 +157,19 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
334
157
  return;
335
158
  if (state.type == 'inputs') {
336
159
  this.listOfInputs = this.registrationStepsState[this.registrationStep].fields;
160
+ this.listOfActions = this.registrationStepsState[this.registrationStep].actions;
337
161
  }
338
162
  if (state.type == 'values') {
339
163
  const savedValues = savedUserData[this.registrationStep].registerUserData;
340
164
  this.listOfInputValues = Object.keys(savedValues).map(name => {
341
- return { name, value: savedValues[name] };
165
+ return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
342
166
  });
343
167
  // Give to each field the user input as the default value.
344
168
  this.listOfInputValues.forEach(inputValue => {
345
169
  const input = this.listOfInputs.find(input => input.name === inputValue.name);
346
170
  if (input) {
347
171
  input.defaultValue = inputValue.value;
172
+ console.log(input);
348
173
  }
349
174
  });
350
175
  }
@@ -382,7 +207,9 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
382
207
  const url = new URL(`${this.endpoint}/v1/player/legislation/registration/step`);
383
208
  const registerStep = {
384
209
  registrationId: this.registrationID,
385
- registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
210
+ registerUserDto: this.listOfInputValues
211
+ .filter(input => !input.isDuplicate)
212
+ .reduce((acc, curr) => {
386
213
  // Special case for "Mobile" as it needs to be split in two values -- API expects it this way.
387
214
  if (curr.name == "Mobile") {
388
215
  acc['MobilePrefix'] = curr.value.split('|')[0];
@@ -416,12 +243,22 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
416
243
  this.setRegister();
417
244
  }
418
245
  else {
419
- this.getRegisterConfig(this.registrationID).then((config) => {
420
- // Format the new step config.
421
- this.formatConfig(config);
422
- // Set it in local storage
423
- this.stepsStateMachine({ event: 'set', type: 'inputs' });
424
- });
246
+ // After sending the current step, increment and check if the next one is in state.
247
+ this.registrationStep = this.stepChange('increment');
248
+ // If step is present in state do NOT fetch the next config.
249
+ if (Object.keys(this.registrationStepsState).find(key => key == this.registrationStep)) {
250
+ // Use the one from state
251
+ this.stepsStateMachine({ event: 'get', type: 'inputs' });
252
+ this.stepsStateMachine({ event: 'get', type: 'values' });
253
+ }
254
+ else {
255
+ this.getRegisterConfig(this.registrationID).then((config) => {
256
+ // Format the new step config.
257
+ this.formatConfig(config);
258
+ // Set it in local storage.
259
+ this.stepsStateMachine({ event: 'set', type: 'inputs' });
260
+ });
261
+ }
425
262
  }
426
263
  })
427
264
  .catch((err) => {
@@ -463,60 +300,77 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
463
300
  }
464
301
  formatConfig(config) {
465
302
  // Populate the list of inputs and set as invalid in the beginning
466
- let newListOfInputs = config.content.fields.map((field) => {
467
- return Object.assign(Object.assign({}, field), { isValid: false });
303
+ this.listOfInputs = config.content.fields.flatMap((field) => {
304
+ // Special case for inputs that need to be duplicated.
305
+ const duplicateInputRule = field.validate.custom.find(customRule => customRule.rule === 'duplicate-input');
306
+ const inputElement = Object.assign(Object.assign({}, field), { isValid: false });
307
+ if (duplicateInputRule) {
308
+ const duplicateInput = Object.assign(Object.assign({}, field), { name: `${field.name}Duplicate`, displayName: duplicateInputRule.displayName, isValid: false, isDuplicateInput: true });
309
+ return [inputElement, duplicateInput];
310
+ }
311
+ else {
312
+ return [inputElement];
313
+ }
468
314
  });
469
- this.listOfInputs = JSON.parse(JSON.stringify(newListOfInputs));
470
315
  // Populate the list of inputs values and set as null in the beginning
471
- this.listOfInputValues = config.content.fields.map(field => {
472
- return { name: field.name, value: null };
316
+ this.listOfInputValues = this.listOfInputs.map(field => {
317
+ return { name: field.name, value: null, isDuplicate: field.isDuplicateInput || false };
473
318
  });
474
319
  // Set the list of actions
475
320
  this.listOfActions = config.content.actions.map(action => action);
476
321
  this.isLastStep = this.listOfActions.some(action => action == '/register');
477
322
  this.registrationID = config.content.registrationID;
478
323
  this.registrationStep = config.content.step;
479
- this.steps.push(this.registrationStep);
480
324
  // Add the step to the registrationStepsData
481
325
  this.registrationStepsState.regId = this.registrationID;
482
326
  if (!this.registrationStepsState[this.registrationStep]) {
483
327
  this.registrationStepsState[this.registrationStep] = {
484
328
  fields: [],
485
- registerUserData: {}
329
+ registerUserData: {},
330
+ actions: []
486
331
  };
487
332
  }
488
333
  }
334
+ stepChange(action) {
335
+ const stepNum = parseInt(this.registrationStep.replace('Step', ''));
336
+ if (action === 'increment') {
337
+ return 'Step' + (stepNum + 1);
338
+ }
339
+ if (action === 'decrement') {
340
+ return 'Step' + (stepNum - 1);
341
+ }
342
+ }
489
343
  getInvalidStatus(listOfInputs) {
490
344
  return listOfInputs.filter(input => input.isValid == false).length > 0;
491
345
  }
492
346
  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 })));
347
+ 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
348
  }
495
349
  ;
496
350
  renderButtons() {
497
- return (h("div", { class: 'registration__buttons-wrapper' }, h("button", { class: `registration__button ${this.isLastStep ? 'registration__button--done' : ''}`, type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e) }, this.isLastStep ? translate('doneButton', this.language) : translate('nextButton', this.language)), this.registrationStep !== 'Step1' && h("button", { class: 'registration__button', onClick: (e) => this.backHandler(e) }, translate('backButton', this.language))));
351
+ 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
352
  }
499
353
  render() {
500
354
  if (this.isLoading) {
501
355
  return h("p", null, "Please wait, loading ...");
502
356
  }
503
- return (h("div", { class: 'registration' }, h("form", { action: '.', id: 'RegistrationForm', class: 'registration__form' }, this.renderInputs()), this.renderButtons()));
357
+ 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
358
  }
505
359
  static get watchers() { return {
506
- "registrationStep": ["logger"]
360
+ "registrationStep": ["sendStep"]
507
361
  }; }
508
362
  static get style() { return generalRegistrationCss; }
509
363
  }, [1, "general-registration", {
510
364
  "endpoint": [1],
511
- "tenantId": [1, "tenant-id"],
512
- "clientId": [1, "client-id"],
513
- "apiKey": [1, "api-key"],
514
365
  "language": [1],
366
+ "clientStyling": [1, "client-styling"],
367
+ "clientStylingUrl": [1, "client-styling-url"],
515
368
  "errorMessage": [32],
516
369
  "emitValue": [32],
517
370
  "isFormValid": [32],
518
371
  "listOfInputs": [32],
519
372
  "isLoading": [32],
373
+ "limitStylingAppends": [32],
520
374
  "registrationStep": [32]
521
375
  }, [[0, "sendValidityState", "checkInputsValidityHandler"], [0, "sendInputValue", "getInputsValueHandler"]]]);
522
376
  function defineCustomElement$1() {