@everymatrix/general-registration 1.10.4 → 1.10.5

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.
@@ -15,7 +15,7 @@ const SUPPORTED_LANGUAGES = ['ro', 'en'];
15
15
  const TRANSLATIONS = {
16
16
  en: {
17
17
  dateError: 'The selected date should be between {min} and {max}',
18
- numberLengthError: 'The number should be between ${min} and ${max}',
18
+ numberLengthError: 'The number should be between {min} and {max}',
19
19
  lengthError: `The length should be between {minLength} and {maxLength}`,
20
20
  requiredError: 'This input is required.',
21
21
  nextButton: 'Next',
@@ -281,10 +281,11 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
281
281
  this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
282
282
  }
283
283
  getInputsValueHandler(event) {
284
- this.listOfInputValues.find(input => input.name == event.detail.name).value = event.detail.value;
285
- /*Note to self: -- what about the inputs that received a default value.
286
- They will send an undefined because there was no input
287
- Handle it somehow!!!!!, one idea can be that value equals defaultValue but dependes on how the api wants stuff*/
284
+ this.listOfInputValues.find(input => {
285
+ if (input.name == event.detail.name) {
286
+ input.value = event.detail.value;
287
+ }
288
+ });
288
289
  this.stepsStateMachine({ event: 'set', type: 'values' });
289
290
  }
290
291
  componentWillLoad() {
@@ -321,10 +322,7 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
321
322
  }
322
323
  if (state.type == 'values') {
323
324
  this.registrationStepsState[this.registrationStep].registerUserData = this.listOfInputValues.reduce((acc, curr) => {
324
- // @TODO remove this once GMCore is smart enough to understand the concept of UNIQUE KEYS
325
- if (curr.value != null) {
326
- acc[curr.name] = curr.value;
327
- }
325
+ acc[curr.name] = curr.value;
328
326
  return acc;
329
327
  }, {});
330
328
  }
@@ -356,9 +354,6 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
356
354
  getRegisterConfig(registrationID) {
357
355
  const url = new URL(`${this.endpoint}/v1/player/legislation/registration/config`);
358
356
  const headers = new Headers();
359
- // headers.append('X-Tenant-ID', this.tenantId);
360
- // headers.append('X-Client-ID', this.clientId);
361
- // headers.append('X-Api-Key', this.apiKey);
362
357
  headers.append('Content-Type', 'application/json');
363
358
  headers.append('Accept', 'application/json');
364
359
  if (registrationID) {
@@ -388,8 +383,12 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
388
383
  const registerStep = {
389
384
  registrationId: this.registrationID,
390
385
  registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
391
- // @TODO remove this once GMCore is smart enough to understand the concept of UNIQUE KEYS
392
- if (curr.value != null) {
386
+ // Special case for "Mobile" as it needs to be split in two values -- API expects it this way.
387
+ if (curr.name == "Mobile") {
388
+ acc['MobilePrefix'] = curr.value.split('|')[0];
389
+ acc[curr.name] = curr.value.split('|')[1];
390
+ }
391
+ else {
393
392
  acc[curr.name] = curr.value;
394
393
  }
395
394
  return acc;
@@ -397,9 +396,6 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
397
396
  step: this.registrationStep,
398
397
  };
399
398
  const headers = new Headers();
400
- // headers.append('X-Tenant-ID', this.tenantId);
401
- // headers.append('X-Client-ID', this.clientId);
402
- // headers.append('X-Api-Key', this.apiKey);
403
399
  headers.append('Content-Type', 'application/json');
404
400
  headers.append('Accept', 'application/json');
405
401
  const options = {
@@ -439,19 +435,8 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
439
435
  this.isLoading = true;
440
436
  const url = new URL(`${this.endpoint}/v1/player/legislation/register`);
441
437
  const headers = new Headers();
442
- // headers.append('X-Tenant-ID', this.tenantId);
443
- // headers.append('X-Client-ID', this.clientId);
444
- // headers.append('X-Api-Key', this.apiKey);
445
438
  headers.append('Content-Type', 'application/json');
446
439
  headers.append('Accept', 'application/json');
447
- // const registerStep = {
448
- // registrationId: this.registrationID,
449
- // registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
450
- // acc[curr.name] = curr.value;
451
- // return acc;
452
- // }, {}),
453
- // step: this.registrationStep,
454
- // };
455
440
  const options = {
456
441
  method: 'PUT',
457
442
  body: JSON.stringify({ registrationId: this.registrationID }),
@@ -478,9 +463,10 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
478
463
  }
479
464
  formatConfig(config) {
480
465
  // Populate the list of inputs and set as invalid in the beginning
481
- this.listOfInputs = config.content.fields.map((field) => {
466
+ let newListOfInputs = config.content.fields.map((field) => {
482
467
  return Object.assign(Object.assign({}, field), { isValid: false });
483
468
  });
469
+ this.listOfInputs = JSON.parse(JSON.stringify(newListOfInputs));
484
470
  // Populate the list of inputs values and set as null in the beginning
485
471
  this.listOfInputValues = config.content.fields.map(field => {
486
472
  return { name: field.name, value: null };
@@ -3,7 +3,7 @@ const SUPPORTED_LANGUAGES = ['ro', 'en'];
3
3
  const TRANSLATIONS = {
4
4
  en: {
5
5
  dateError: 'The selected date should be between {min} and {max}',
6
- numberLengthError: 'The number should be between ${min} and ${max}',
6
+ numberLengthError: 'The number should be between {min} and {max}',
7
7
  lengthError: `The length should be between {minLength} and {maxLength}`,
8
8
  requiredError: 'This input is required.',
9
9
  nextButton: 'Next',
@@ -28,6 +28,12 @@ const NumberInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
28
28
  valueHandler(inputValueEvent) {
29
29
  this.sendInputValue.emit(inputValueEvent);
30
30
  }
31
+ componentDidLoad() {
32
+ if (this.defaultValue) {
33
+ this.value = this.defaultValue;
34
+ this.valueHandler({ name: this.name, value: this.value });
35
+ }
36
+ }
31
37
  handleInput(event) {
32
38
  this.value = event.target.value;
33
39
  this.errorMessage = this.setErrorMessage();
@@ -59,7 +65,7 @@ const NumberInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
59
65
  "name": [1],
60
66
  "displayName": [1, "display-name"],
61
67
  "validation": [16],
62
- "defaultValue": [2, "default-value"],
68
+ "defaultValue": [1, "default-value"],
63
69
  "autofilled": [4],
64
70
  "language": [1],
65
71
  "emitValue": [4, "emit-value"],
@@ -37,6 +37,12 @@ const PasswordInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
37
37
  connectedCallback() {
38
38
  this.validationPattern = this.setPattern();
39
39
  }
40
+ componentDidLoad() {
41
+ if (this.defaultValue) {
42
+ this.value = this.defaultValue;
43
+ this.valueHandler({ name: this.name, value: this.value });
44
+ }
45
+ }
40
46
  handleInput(event) {
41
47
  this.value = event.target.value;
42
48
  this.errorMessage = this.setErrorMessage();
@@ -48,14 +54,15 @@ const PasswordInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
48
54
  return this.inputReference.validity.valid;
49
55
  }
50
56
  setPattern() {
51
- var _a;
57
+ var _a, _b;
52
58
  if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
53
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
59
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
54
60
  }
55
61
  }
56
62
  setErrorMessage() {
63
+ var _a;
57
64
  if (this.inputReference.validity.patternMismatch) {
58
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
65
+ return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
59
66
  }
60
67
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
61
68
  return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
@@ -54,6 +54,10 @@ const SelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
54
54
  }
55
55
  componentDidLoad() {
56
56
  this.inputReference = this.element.shadowRoot.querySelector('input');
57
+ if (this.defaultValue) {
58
+ this.value = this.defaultValue;
59
+ this.valueHandler({ name: this.name, value: this.value });
60
+ }
57
61
  }
58
62
  getOptions() {
59
63
  // TEMPORARY FOR DEMO PURPOSES UNTIL NORWAY CONFIGURES AN ACTUAL ENDPOINT...
@@ -39,12 +39,18 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
39
39
  if (this.action.split(" ")[0] == 'GET') {
40
40
  return this.getPhoneCodes().then((options) => {
41
41
  this.phoneCodesOptions = options.phoneCodes.map(code => {
42
- return { label: code.Prefix, value: code.CountryID };
42
+ return { label: code.Prefix, value: code.Prefix };
43
43
  });
44
44
  });
45
45
  }
46
46
  }
47
47
  }
48
+ componentDidLoad() {
49
+ if (this.defaultValue) {
50
+ this.prefixValue = this.defaultValue;
51
+ this.valueHandler({ name: this.name, value: `${this.prefixValue}|` });
52
+ }
53
+ }
48
54
  getPhoneCodes() {
49
55
  // TEMPORARY FOR DEMO PURPOSES UNTIL NORWAY CONFIGURES AN ACTUAL ENDPOINT...
50
56
  const url = new URL("https://demo-api.stage.norway.everymatrix.com/v1/player/phonecodes");
@@ -60,7 +66,8 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
60
66
  });
61
67
  }
62
68
  handleInput(event) {
63
- this.value = event.target.value;
69
+ // Kinda hack? Open to suggestions.
70
+ this.value = `${this.prefixValue}|${event.target.value}`;
64
71
  this.errorMessage = this.setErrorMessage();
65
72
  this.isValid = this.setValidity();
66
73
  this.validityStateHandler({ valid: this.isValid, name: this.name });
@@ -70,14 +77,15 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
70
77
  return this.inputReference.validity.valid;
71
78
  }
72
79
  setPattern() {
73
- var _a;
80
+ var _a, _b;
74
81
  if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
75
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
82
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
76
83
  }
77
84
  }
78
85
  setErrorMessage() {
86
+ var _a;
79
87
  if (this.inputReference.validity.patternMismatch) {
80
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
88
+ return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
81
89
  }
82
90
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
83
91
  return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
@@ -88,7 +96,7 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
88
96
  }
89
97
  render() {
90
98
  const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'tel__input--invalid';
91
- return h("div", { class: 'tel__wrapper' }, h("div", { class: 'tel__wrapper--flex' }, h("vaadin-combo-box", { items: this.phoneCodesOptions, value: this.defaultValue, readOnly: this.autofilled }), h("input", { type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, readOnly: this.autofilled, class: `tel__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onBlur: (e) => this.handleInput(e) })), h("label", { class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("small", { class: 'tel__error-message' }, this.errorMessage));
99
+ return h("div", { class: 'tel__wrapper' }, h("div", { class: 'tel__wrapper--flex' }, h("vaadin-combo-box", { items: this.phoneCodesOptions, value: this.defaultValue, readOnly: this.autofilled, onBlur: (e) => this.prefixValue = e.target.value }), h("input", { type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, readOnly: this.autofilled, class: `tel__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onBlur: (e) => this.handleInput(e) })), h("label", { class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("small", { class: 'tel__error-message' }, this.errorMessage));
92
100
  }
93
101
  static get watchers() { return {
94
102
  "isValid": ["validityChanged"],
@@ -101,7 +109,7 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
101
109
  "showLabels": [4, "show-labels"],
102
110
  "action": [1],
103
111
  "validation": [16],
104
- "defaultValue": [8, "default-value"],
112
+ "defaultValue": [1, "default-value"],
105
113
  "autofilled": [4],
106
114
  "language": [1],
107
115
  "emitValue": [4, "emit-value"],
@@ -36,10 +36,14 @@ const TextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
36
36
  this.sendInputValue.emit(inputValueEvent);
37
37
  }
38
38
  connectedCallback() {
39
- // @TODO do something with customRules !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
40
- this.customRules = this.setCustomRules();
41
39
  this.validationPattern = this.setPattern();
42
40
  }
41
+ componentDidLoad() {
42
+ if (this.defaultValue) {
43
+ this.value = this.defaultValue;
44
+ this.valueHandler({ name: this.name, value: this.value });
45
+ }
46
+ }
43
47
  handleInput(event) {
44
48
  this.value = event.target.value;
45
49
  this.isValid = this.setValidity();
@@ -58,14 +62,15 @@ const TextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
58
62
  }
59
63
  }
60
64
  setPattern() {
61
- var _a;
65
+ var _a, _b;
62
66
  if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
63
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
67
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
64
68
  }
65
69
  }
66
70
  setErrorMessage() {
71
+ var _a;
67
72
  if (this.inputReference.validity.patternMismatch) {
68
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
73
+ return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
69
74
  }
70
75
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
71
76
  return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
@@ -1,11 +1,11 @@
1
- import { r as registerInstance, c as createEvent, h as h$2, g as getElement } from './index-0505440f.js';
1
+ import { r as registerInstance, c as createEvent, h as h$2, g as getElement } from './index-bb9c8eb3.js';
2
2
 
3
3
  const DEFAULT_LANGUAGE$1 = 'en';
4
4
  const SUPPORTED_LANGUAGES$1 = ['ro', 'en'];
5
5
  const TRANSLATIONS$1 = {
6
6
  en: {
7
7
  dateError: 'The selected date should be between {min} and {max}',
8
- numberLengthError: 'The number should be between ${min} and ${max}',
8
+ numberLengthError: 'The number should be between {min} and {max}',
9
9
  lengthError: `The length should be between {minLength} and {maxLength}`,
10
10
  requiredError: 'This input is required.',
11
11
  nextButton: 'Next',
@@ -58,6 +58,12 @@ const CheckboxInput = class {
58
58
  valueHandler(inputValueEvent) {
59
59
  this.sendInputValue.emit(inputValueEvent);
60
60
  }
61
+ componentDidLoad() {
62
+ if (this.defaultValue) {
63
+ this.value = this.defaultValue;
64
+ this.valueHandler({ name: this.name, value: this.value });
65
+ }
66
+ }
61
67
  handleClick() {
62
68
  this.value = this.inputReference.checked.toString();
63
69
  this.errorMessage = this.setErrorMessage();
@@ -23052,6 +23058,10 @@ const DateInput = class {
23052
23058
  }
23053
23059
  componentDidLoad() {
23054
23060
  this.inputReference = this.element.shadowRoot.querySelector('input');
23061
+ if (this.defaultValue) {
23062
+ this.value = this.defaultValue;
23063
+ this.valueHandler({ name: this.name, value: this.value });
23064
+ }
23055
23065
  }
23056
23066
  handleInput(event) {
23057
23067
  this.value = event.target.value;
@@ -23111,6 +23121,12 @@ const EmailInput = class {
23111
23121
  connectedCallback() {
23112
23122
  this.validationPattern = this.setPattern();
23113
23123
  }
23124
+ componentDidLoad() {
23125
+ if (this.defaultValue) {
23126
+ this.value = this.defaultValue;
23127
+ this.valueHandler({ name: this.name, value: this.value });
23128
+ }
23129
+ }
23114
23130
  handleInput(event) {
23115
23131
  this.value = event.target.value;
23116
23132
  this.errorMessage = this.setErrorMessage();
@@ -23122,14 +23138,15 @@ const EmailInput = class {
23122
23138
  return this.inputReference.validity.valid;
23123
23139
  }
23124
23140
  setPattern() {
23125
- var _a;
23141
+ var _a, _b;
23126
23142
  if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
23127
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
23143
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
23128
23144
  }
23129
23145
  }
23130
23146
  setErrorMessage() {
23147
+ var _a;
23131
23148
  if (this.inputReference.validity.patternMismatch) {
23132
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
23149
+ return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
23133
23150
  }
23134
23151
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
23135
23152
  return translate$2('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
@@ -23191,7 +23208,7 @@ const SUPPORTED_LANGUAGES = ['ro', 'en'];
23191
23208
  const TRANSLATIONS = {
23192
23209
  en: {
23193
23210
  dateError: 'The selected date should be between {min} and {max}',
23194
- numberLengthError: 'The number should be between ${min} and ${max}',
23211
+ numberLengthError: 'The number should be between {min} and {max}',
23195
23212
  lengthError: `The length should be between {minLength} and {maxLength}`,
23196
23213
  requiredError: 'This input is required.',
23197
23214
  nextButton: 'Next',
@@ -23455,10 +23472,11 @@ const GeneralRegistration = class {
23455
23472
  this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
23456
23473
  }
23457
23474
  getInputsValueHandler(event) {
23458
- this.listOfInputValues.find(input => input.name == event.detail.name).value = event.detail.value;
23459
- /*Note to self: -- what about the inputs that received a default value.
23460
- They will send an undefined because there was no input
23461
- Handle it somehow!!!!!, one idea can be that value equals defaultValue but dependes on how the api wants stuff*/
23475
+ this.listOfInputValues.find(input => {
23476
+ if (input.name == event.detail.name) {
23477
+ input.value = event.detail.value;
23478
+ }
23479
+ });
23462
23480
  this.stepsStateMachine({ event: 'set', type: 'values' });
23463
23481
  }
23464
23482
  componentWillLoad() {
@@ -23495,10 +23513,7 @@ const GeneralRegistration = class {
23495
23513
  }
23496
23514
  if (state.type == 'values') {
23497
23515
  this.registrationStepsState[this.registrationStep].registerUserData = this.listOfInputValues.reduce((acc, curr) => {
23498
- // @TODO remove this once GMCore is smart enough to understand the concept of UNIQUE KEYS
23499
- if (curr.value != null) {
23500
- acc[curr.name] = curr.value;
23501
- }
23516
+ acc[curr.name] = curr.value;
23502
23517
  return acc;
23503
23518
  }, {});
23504
23519
  }
@@ -23530,9 +23545,6 @@ const GeneralRegistration = class {
23530
23545
  getRegisterConfig(registrationID) {
23531
23546
  const url = new URL(`${this.endpoint}/v1/player/legislation/registration/config`);
23532
23547
  const headers = new Headers();
23533
- // headers.append('X-Tenant-ID', this.tenantId);
23534
- // headers.append('X-Client-ID', this.clientId);
23535
- // headers.append('X-Api-Key', this.apiKey);
23536
23548
  headers.append('Content-Type', 'application/json');
23537
23549
  headers.append('Accept', 'application/json');
23538
23550
  if (registrationID) {
@@ -23562,8 +23574,12 @@ const GeneralRegistration = class {
23562
23574
  const registerStep = {
23563
23575
  registrationId: this.registrationID,
23564
23576
  registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
23565
- // @TODO remove this once GMCore is smart enough to understand the concept of UNIQUE KEYS
23566
- if (curr.value != null) {
23577
+ // Special case for "Mobile" as it needs to be split in two values -- API expects it this way.
23578
+ if (curr.name == "Mobile") {
23579
+ acc['MobilePrefix'] = curr.value.split('|')[0];
23580
+ acc[curr.name] = curr.value.split('|')[1];
23581
+ }
23582
+ else {
23567
23583
  acc[curr.name] = curr.value;
23568
23584
  }
23569
23585
  return acc;
@@ -23571,9 +23587,6 @@ const GeneralRegistration = class {
23571
23587
  step: this.registrationStep,
23572
23588
  };
23573
23589
  const headers = new Headers();
23574
- // headers.append('X-Tenant-ID', this.tenantId);
23575
- // headers.append('X-Client-ID', this.clientId);
23576
- // headers.append('X-Api-Key', this.apiKey);
23577
23590
  headers.append('Content-Type', 'application/json');
23578
23591
  headers.append('Accept', 'application/json');
23579
23592
  const options = {
@@ -23613,19 +23626,8 @@ const GeneralRegistration = class {
23613
23626
  this.isLoading = true;
23614
23627
  const url = new URL(`${this.endpoint}/v1/player/legislation/register`);
23615
23628
  const headers = new Headers();
23616
- // headers.append('X-Tenant-ID', this.tenantId);
23617
- // headers.append('X-Client-ID', this.clientId);
23618
- // headers.append('X-Api-Key', this.apiKey);
23619
23629
  headers.append('Content-Type', 'application/json');
23620
23630
  headers.append('Accept', 'application/json');
23621
- // const registerStep = {
23622
- // registrationId: this.registrationID,
23623
- // registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
23624
- // acc[curr.name] = curr.value;
23625
- // return acc;
23626
- // }, {}),
23627
- // step: this.registrationStep,
23628
- // };
23629
23631
  const options = {
23630
23632
  method: 'PUT',
23631
23633
  body: JSON.stringify({ registrationId: this.registrationID }),
@@ -23652,9 +23654,10 @@ const GeneralRegistration = class {
23652
23654
  }
23653
23655
  formatConfig(config) {
23654
23656
  // Populate the list of inputs and set as invalid in the beginning
23655
- this.listOfInputs = config.content.fields.map((field) => {
23657
+ let newListOfInputs = config.content.fields.map((field) => {
23656
23658
  return Object.assign(Object.assign({}, field), { isValid: false });
23657
23659
  });
23660
+ this.listOfInputs = JSON.parse(JSON.stringify(newListOfInputs));
23658
23661
  // Populate the list of inputs values and set as null in the beginning
23659
23662
  this.listOfInputValues = config.content.fields.map(field => {
23660
23663
  return { name: field.name, value: null };
@@ -23721,6 +23724,12 @@ const NumberInput = class {
23721
23724
  valueHandler(inputValueEvent) {
23722
23725
  this.sendInputValue.emit(inputValueEvent);
23723
23726
  }
23727
+ componentDidLoad() {
23728
+ if (this.defaultValue) {
23729
+ this.value = this.defaultValue;
23730
+ this.valueHandler({ name: this.name, value: this.value });
23731
+ }
23732
+ }
23724
23733
  handleInput(event) {
23725
23734
  this.value = event.target.value;
23726
23735
  this.errorMessage = this.setErrorMessage();
@@ -23784,6 +23793,12 @@ const PasswordInput = class {
23784
23793
  connectedCallback() {
23785
23794
  this.validationPattern = this.setPattern();
23786
23795
  }
23796
+ componentDidLoad() {
23797
+ if (this.defaultValue) {
23798
+ this.value = this.defaultValue;
23799
+ this.valueHandler({ name: this.name, value: this.value });
23800
+ }
23801
+ }
23787
23802
  handleInput(event) {
23788
23803
  this.value = event.target.value;
23789
23804
  this.errorMessage = this.setErrorMessage();
@@ -23795,14 +23810,15 @@ const PasswordInput = class {
23795
23810
  return this.inputReference.validity.valid;
23796
23811
  }
23797
23812
  setPattern() {
23798
- var _a;
23813
+ var _a, _b;
23799
23814
  if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
23800
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
23815
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
23801
23816
  }
23802
23817
  }
23803
23818
  setErrorMessage() {
23819
+ var _a;
23804
23820
  if (this.inputReference.validity.patternMismatch) {
23805
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
23821
+ return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
23806
23822
  }
23807
23823
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
23808
23824
  return translate$2('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
@@ -28345,6 +28361,10 @@ const SelectInput = class {
28345
28361
  }
28346
28362
  componentDidLoad() {
28347
28363
  this.inputReference = this.element.shadowRoot.querySelector('input');
28364
+ if (this.defaultValue) {
28365
+ this.value = this.defaultValue;
28366
+ this.valueHandler({ name: this.name, value: this.value });
28367
+ }
28348
28368
  }
28349
28369
  getOptions() {
28350
28370
  // TEMPORARY FOR DEMO PURPOSES UNTIL NORWAY CONFIGURES AN ACTUAL ENDPOINT...
@@ -28421,12 +28441,18 @@ const TelInput = class {
28421
28441
  if (this.action.split(" ")[0] == 'GET') {
28422
28442
  return this.getPhoneCodes().then((options) => {
28423
28443
  this.phoneCodesOptions = options.phoneCodes.map(code => {
28424
- return { label: code.Prefix, value: code.CountryID };
28444
+ return { label: code.Prefix, value: code.Prefix };
28425
28445
  });
28426
28446
  });
28427
28447
  }
28428
28448
  }
28429
28449
  }
28450
+ componentDidLoad() {
28451
+ if (this.defaultValue) {
28452
+ this.prefixValue = this.defaultValue;
28453
+ this.valueHandler({ name: this.name, value: `${this.prefixValue}|` });
28454
+ }
28455
+ }
28430
28456
  getPhoneCodes() {
28431
28457
  // TEMPORARY FOR DEMO PURPOSES UNTIL NORWAY CONFIGURES AN ACTUAL ENDPOINT...
28432
28458
  const url = new URL("https://demo-api.stage.norway.everymatrix.com/v1/player/phonecodes");
@@ -28442,7 +28468,8 @@ const TelInput = class {
28442
28468
  });
28443
28469
  }
28444
28470
  handleInput(event) {
28445
- this.value = event.target.value;
28471
+ // Kinda hack? Open to suggestions.
28472
+ this.value = `${this.prefixValue}|${event.target.value}`;
28446
28473
  this.errorMessage = this.setErrorMessage();
28447
28474
  this.isValid = this.setValidity();
28448
28475
  this.validityStateHandler({ valid: this.isValid, name: this.name });
@@ -28452,14 +28479,15 @@ const TelInput = class {
28452
28479
  return this.inputReference.validity.valid;
28453
28480
  }
28454
28481
  setPattern() {
28455
- var _a;
28482
+ var _a, _b;
28456
28483
  if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
28457
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
28484
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
28458
28485
  }
28459
28486
  }
28460
28487
  setErrorMessage() {
28488
+ var _a;
28461
28489
  if (this.inputReference.validity.patternMismatch) {
28462
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
28490
+ return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
28463
28491
  }
28464
28492
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
28465
28493
  return translate$2('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
@@ -28470,7 +28498,7 @@ const TelInput = class {
28470
28498
  }
28471
28499
  render() {
28472
28500
  const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'tel__input--invalid';
28473
- return h$2("div", { class: 'tel__wrapper' }, h$2("div", { class: 'tel__wrapper--flex' }, h$2("vaadin-combo-box", { items: this.phoneCodesOptions, value: this.defaultValue, readOnly: this.autofilled }), h$2("input", { type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, readOnly: this.autofilled, class: `tel__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onBlur: (e) => this.handleInput(e) })), h$2("label", { class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h$2("small", { class: 'tel__error-message' }, this.errorMessage));
28501
+ return h$2("div", { class: 'tel__wrapper' }, h$2("div", { class: 'tel__wrapper--flex' }, h$2("vaadin-combo-box", { items: this.phoneCodesOptions, value: this.defaultValue, readOnly: this.autofilled, onBlur: (e) => this.prefixValue = e.target.value }), h$2("input", { type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, readOnly: this.autofilled, class: `tel__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onBlur: (e) => this.handleInput(e) })), h$2("label", { class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h$2("small", { class: 'tel__error-message' }, this.errorMessage));
28474
28502
  }
28475
28503
  static get watchers() { return {
28476
28504
  "isValid": ["validityChanged"],
@@ -28512,10 +28540,14 @@ const TextInput = class {
28512
28540
  this.sendInputValue.emit(inputValueEvent);
28513
28541
  }
28514
28542
  connectedCallback() {
28515
- // @TODO do something with customRules !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28516
- this.customRules = this.setCustomRules();
28517
28543
  this.validationPattern = this.setPattern();
28518
28544
  }
28545
+ componentDidLoad() {
28546
+ if (this.defaultValue) {
28547
+ this.value = this.defaultValue;
28548
+ this.valueHandler({ name: this.name, value: this.value });
28549
+ }
28550
+ }
28519
28551
  handleInput(event) {
28520
28552
  this.value = event.target.value;
28521
28553
  this.isValid = this.setValidity();
@@ -28534,14 +28566,15 @@ const TextInput = class {
28534
28566
  }
28535
28567
  }
28536
28568
  setPattern() {
28537
- var _a;
28569
+ var _a, _b;
28538
28570
  if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
28539
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
28571
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
28540
28572
  }
28541
28573
  }
28542
28574
  setErrorMessage() {
28575
+ var _a;
28543
28576
  if (this.inputReference.validity.patternMismatch) {
28544
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
28577
+ return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
28545
28578
  }
28546
28579
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
28547
28580
  return translate$2('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
@@ -1,4 +1,4 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-0505440f.js';
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-bb9c8eb3.js';
2
2
 
3
3
  /*
4
4
  Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
@@ -13,5 +13,5 @@ const patchBrowser = () => {
13
13
  };
14
14
 
15
15
  patchBrowser().then(options => {
16
- return bootstrapLazy([["checkbox-input_11",[[1,"general-registration",{"endpoint":[1],"tenantId":[1,"tenant-id"],"clientId":[1,"client-id"],"apiKey":[1,"api-key"],"language":[1],"errorMessage":[32],"emitValue":[32],"isFormValid":[32],"listOfInputs":[32],"isLoading":[32],"registrationStep":[32]},[[0,"sendValidityState","checkInputsValidityHandler"],[0,"sendInputValue","getInputsValueHandler"]]],[1,"general-input",{"type":[1],"name":[1],"displayName":[1,"display-name"],"action":[1],"validation":[16],"options":[8],"language":[1],"autofilled":[4],"defaultValue":[8,"default-value"],"emitValue":[4,"emit-value"]}],[1,"checkbox-input",{"name":[1],"displayName":[1,"display-name"],"defaultValue":[1,"default-value"],"autofilled":[4],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"date-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"autofilled":[4],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"email-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"autofilled":[4],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"number-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[2,"default-value"],"autofilled":[4],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"password-input",{"name":[1],"displayName":[1,"display-name"],"defaultValue":[1,"default-value"],"autofilled":[4],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"radio-input",{"name":[1],"displayName":[1,"display-name"],"optionsGroup":[16],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"select-input",{"name":[1],"displayName":[1,"display-name"],"action":[1],"defaultValue":[1,"default-value"],"autofilled":[4],"options":[16],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"tel-input",{"name":[1],"displayName":[1,"display-name"],"showLabels":[4,"show-labels"],"action":[1],"validation":[16],"defaultValue":[8,"default-value"],"autofilled":[4],"language":[1],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"text-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"autofilled":[4],"rules":[1],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}]]]], options);
16
+ return bootstrapLazy([["checkbox-input_11",[[1,"general-registration",{"endpoint":[1],"tenantId":[1,"tenant-id"],"clientId":[1,"client-id"],"apiKey":[1,"api-key"],"language":[1],"errorMessage":[32],"emitValue":[32],"isFormValid":[32],"listOfInputs":[32],"isLoading":[32],"registrationStep":[32]},[[0,"sendValidityState","checkInputsValidityHandler"],[0,"sendInputValue","getInputsValueHandler"]]],[1,"general-input",{"type":[1],"name":[1],"displayName":[1,"display-name"],"action":[1],"validation":[16],"options":[8],"language":[1],"autofilled":[4],"defaultValue":[8,"default-value"],"emitValue":[4,"emit-value"]}],[1,"checkbox-input",{"name":[1],"displayName":[1,"display-name"],"defaultValue":[1,"default-value"],"autofilled":[4],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"date-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"autofilled":[4],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"email-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"autofilled":[4],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"number-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"autofilled":[4],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"password-input",{"name":[1],"displayName":[1,"display-name"],"defaultValue":[1,"default-value"],"autofilled":[4],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"radio-input",{"name":[1],"displayName":[1,"display-name"],"optionsGroup":[16],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"select-input",{"name":[1],"displayName":[1,"display-name"],"action":[1],"defaultValue":[1,"default-value"],"autofilled":[4],"options":[16],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"tel-input",{"name":[1],"displayName":[1,"display-name"],"showLabels":[4,"show-labels"],"action":[1],"validation":[16],"defaultValue":[1,"default-value"],"autofilled":[4],"language":[1],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"text-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"autofilled":[4],"rules":[1],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}]]]], options);
17
17
  });
@@ -765,10 +765,6 @@ const parsePropertyValue = (propValue, propType) => {
765
765
  // but we'll cheat here and say that the string "false" is the boolean false
766
766
  return propValue === 'false' ? false : propValue === '' || !!propValue;
767
767
  }
768
- if (propType & 2 /* Number */) {
769
- // force it to be a number
770
- return parseFloat(propValue);
771
- }
772
768
  if (propType & 1 /* String */) {
773
769
  // could have been passed as a number or boolean
774
770
  // but we still want it as a string