@everymatrix/general-registration 1.10.14 → 1.10.16
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 +30 -11
- package/dist/cjs/general-registration.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/general-registration/general-registration.css +6 -0
- package/dist/collection/components/general-registration/general-registration.js +47 -10
- package/dist/collection/utils/locale.utils.js +28 -0
- package/dist/components/checkbox-input2.js +1 -1
- package/dist/components/general-registration.js +30 -12
- package/dist/esm/checkbox-input_11.entry.js +30 -11
- package/dist/esm/general-registration.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/general-registration/general-registration.esm.js +1 -1
- package/dist/general-registration/{p-3313fb60.entry.js → p-4142a899.entry.js} +2 -2
- package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/types.d.ts +1 -1
- package/dist/types/components/general-registration/general-registration.d.ts +8 -3
- package/dist/types/components.d.ts +8 -0
- package/dist/types/utils/locale.utils.d.ts +5 -0
- package/package.json +1 -1
|
@@ -103,7 +103,7 @@ const CheckboxInput = class {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
render() {
|
|
106
|
-
return index.h("div", { class: 'checkbox__wrapper', ref: el => this.stylingContainer = el }, index.h("input", { type: "checkbox", id: `${this.name}__input`, ref: (el) => this.inputReference = el, name: this.name, checked:
|
|
106
|
+
return index.h("div", { class: 'checkbox__wrapper', ref: el => this.stylingContainer = el }, index.h("input", { type: "checkbox", id: `${this.name}__input`, ref: (el) => this.inputReference = el, name: this.name, checked: this.defaultValue == "true", readOnly: this.autofilled, required: this.validation.mandatory, value: this.value, onClick: () => this.handleClick() }), index.h("label", { class: 'checkbox__label', htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), index.h("small", { class: 'checkbox__error-message' }, this.errorMessage));
|
|
107
107
|
}
|
|
108
108
|
static get watchers() { return {
|
|
109
109
|
"isValid": ["validityChanged"],
|
|
@@ -23309,7 +23309,7 @@ const translate = (key, customLang, values) => {
|
|
|
23309
23309
|
return translation;
|
|
23310
23310
|
};
|
|
23311
23311
|
|
|
23312
|
-
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}";
|
|
23312
|
+
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--disabled {\n opacity: 0.5;\n}\n.registration__button--disabled:hover {\n opacity: 0.5;\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}";
|
|
23313
23313
|
|
|
23314
23314
|
const GeneralRegistration = class {
|
|
23315
23315
|
constructor(hostRef) {
|
|
@@ -23328,13 +23328,16 @@ const GeneralRegistration = class {
|
|
|
23328
23328
|
* Client custom styling via url
|
|
23329
23329
|
*/
|
|
23330
23330
|
this.clientStylingUrl = '';
|
|
23331
|
-
|
|
23331
|
+
/**
|
|
23332
|
+
* Translations via URL
|
|
23333
|
+
*/
|
|
23334
|
+
this.translationsUrl = '';
|
|
23332
23335
|
this.listOfInputs = [];
|
|
23333
23336
|
this.isLoading = true;
|
|
23334
|
-
this.limitStylingAppends = false;
|
|
23335
23337
|
this.listOfInputValues = [];
|
|
23336
23338
|
this.listOfActions = [];
|
|
23337
23339
|
this.indexStep = 0;
|
|
23340
|
+
this.emitValue = false;
|
|
23338
23341
|
this.registrationStepsState = {
|
|
23339
23342
|
regId: null
|
|
23340
23343
|
};
|
|
@@ -23359,6 +23362,9 @@ const GeneralRegistration = class {
|
|
|
23359
23362
|
this.registrationStepUpdated.emit(this.registrationStep);
|
|
23360
23363
|
window.postMessage({ type: 'registrationStepUpdated', step: this.registrationStep }, window.location.href);
|
|
23361
23364
|
}
|
|
23365
|
+
setFormValidity() {
|
|
23366
|
+
this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
|
|
23367
|
+
}
|
|
23362
23368
|
checkInputsValidityHandler(event) {
|
|
23363
23369
|
// Set isValid state of the input in the list.
|
|
23364
23370
|
this.listOfInputs.find(input => input.name == event.detail.name).isValid = event.detail.valid;
|
|
@@ -23380,12 +23386,11 @@ const GeneralRegistration = class {
|
|
|
23380
23386
|
});
|
|
23381
23387
|
}
|
|
23382
23388
|
componentDidRender() {
|
|
23383
|
-
if (
|
|
23389
|
+
if (this.stylingContainer) {
|
|
23384
23390
|
if (this.clientStyling)
|
|
23385
23391
|
this.setClientStyling();
|
|
23386
23392
|
if (this.clientStylingUrl)
|
|
23387
23393
|
this.setClientStylingURL();
|
|
23388
|
-
this.limitStylingAppends = true;
|
|
23389
23394
|
}
|
|
23390
23395
|
}
|
|
23391
23396
|
componentDidLoad() {
|
|
@@ -23430,6 +23435,7 @@ const GeneralRegistration = class {
|
|
|
23430
23435
|
}
|
|
23431
23436
|
if (state.type == 'values') {
|
|
23432
23437
|
const savedValues = savedUserData[this.registrationStep].registerUserData;
|
|
23438
|
+
console.log(savedValues);
|
|
23433
23439
|
this.listOfInputValues = Object.keys(savedValues).map(name => {
|
|
23434
23440
|
return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
|
|
23435
23441
|
});
|
|
@@ -23438,7 +23444,6 @@ const GeneralRegistration = class {
|
|
|
23438
23444
|
const input = this.listOfInputs.find(input => input.name === inputValue.name);
|
|
23439
23445
|
if (input) {
|
|
23440
23446
|
input.defaultValue = inputValue.value;
|
|
23441
|
-
console.log(input);
|
|
23442
23447
|
}
|
|
23443
23448
|
});
|
|
23444
23449
|
}
|
|
@@ -23559,6 +23564,7 @@ const GeneralRegistration = class {
|
|
|
23559
23564
|
if (data.userId) {
|
|
23560
23565
|
alert(`User registered - the user ID is ${data.userId}`);
|
|
23561
23566
|
}
|
|
23567
|
+
window.postMessage({ type: 'registrationSuccessful' }, window.location.href);
|
|
23562
23568
|
})
|
|
23563
23569
|
.catch((err) => {
|
|
23564
23570
|
console.error(err);
|
|
@@ -23572,7 +23578,7 @@ const GeneralRegistration = class {
|
|
|
23572
23578
|
this.listOfInputs = config.content.fields.flatMap((field) => {
|
|
23573
23579
|
// Special case for inputs that need to be duplicated.
|
|
23574
23580
|
const duplicateInputRule = field.validate.custom.find(customRule => customRule.rule === 'duplicate-input');
|
|
23575
|
-
const inputElement = Object.assign(Object.assign({}, field), { isValid:
|
|
23581
|
+
const inputElement = Object.assign(Object.assign({}, field), { isValid: this.setInitialValidStatus(field) });
|
|
23576
23582
|
if (duplicateInputRule) {
|
|
23577
23583
|
const duplicateInput = Object.assign(Object.assign({}, field), { name: `${field.name}Duplicate`, displayName: duplicateInputRule.displayName, isValid: false, isDuplicateInput: true });
|
|
23578
23584
|
return [inputElement, duplicateInput];
|
|
@@ -23581,7 +23587,7 @@ const GeneralRegistration = class {
|
|
|
23581
23587
|
return [inputElement];
|
|
23582
23588
|
}
|
|
23583
23589
|
});
|
|
23584
|
-
// Populate the list of inputs values and set as null in the beginning
|
|
23590
|
+
// Populate the list of inputs values and set as null in the beginning (or false for checkbox type inputs)
|
|
23585
23591
|
this.listOfInputValues = this.listOfInputs.map(field => {
|
|
23586
23592
|
var _a;
|
|
23587
23593
|
return { name: field.name,
|
|
@@ -23603,6 +23609,18 @@ const GeneralRegistration = class {
|
|
|
23603
23609
|
};
|
|
23604
23610
|
}
|
|
23605
23611
|
}
|
|
23612
|
+
setInitialValidStatus(field) {
|
|
23613
|
+
var _a, _b;
|
|
23614
|
+
// Input type checkbox, with no validation are valid
|
|
23615
|
+
if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) == 'checkbox' && ((_b = field.validate) === null || _b === void 0 ? void 0 : _b.mandatory) == false) {
|
|
23616
|
+
return true;
|
|
23617
|
+
}
|
|
23618
|
+
//Inputs that have default value are valid.
|
|
23619
|
+
if (field.defaultValue !== null) {
|
|
23620
|
+
return true;
|
|
23621
|
+
}
|
|
23622
|
+
return false;
|
|
23623
|
+
}
|
|
23606
23624
|
stepChange(action) {
|
|
23607
23625
|
const stepNum = parseInt(this.registrationStep.replace('Step', ''));
|
|
23608
23626
|
if (action === 'increment') {
|
|
@@ -23620,7 +23638,7 @@ const GeneralRegistration = class {
|
|
|
23620
23638
|
}
|
|
23621
23639
|
;
|
|
23622
23640
|
renderButtons() {
|
|
23623
|
-
return (index.h("div", { class: 'registration__buttons-wrapper' }, index.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)), index.h("button", { class: `registration__button registration__button--back ${this.registrationStep == 'Step1' ? 'registration__button--first-step' : ''}`, onClick: (e) => this.backHandler(e) }, translate('backButton', this.language))));
|
|
23641
|
+
return (index.h("div", { class: 'registration__buttons-wrapper' }, index.h("button", { class: `registration__button registration__button--next ${this.isFormValid ? '' : 'registration__button--disabled'}`, type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e), disabled: !this.isFormValid }, this.isLastStep ? translate('doneButton', this.language) : translate('nextButton', this.language)), index.h("button", { class: `registration__button registration__button--back ${this.registrationStep == 'Step1' ? 'registration__button--first-step' : ''}`, onClick: (e) => this.backHandler(e) }, translate('backButton', this.language))));
|
|
23624
23642
|
}
|
|
23625
23643
|
render() {
|
|
23626
23644
|
if (this.isLoading) {
|
|
@@ -23629,7 +23647,8 @@ const GeneralRegistration = class {
|
|
|
23629
23647
|
return (index.h("div", { class: `registration registration__${this.registrationStep}`, ref: el => this.stylingContainer = el }, index.h("form", { action: '.', id: 'RegistrationForm', class: 'registration__form' }, this.renderInputs()), this.renderButtons()));
|
|
23630
23648
|
}
|
|
23631
23649
|
static get watchers() { return {
|
|
23632
|
-
"registrationStep": ["sendStep"]
|
|
23650
|
+
"registrationStep": ["sendStep"],
|
|
23651
|
+
"listOfInputs": ["setFormValidity"]
|
|
23633
23652
|
}; }
|
|
23634
23653
|
};
|
|
23635
23654
|
GeneralRegistration.style = generalRegistrationCss;
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["checkbox-input_11.cjs",[[1,"general-registration",{"endpoint":[513],"language":[513],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"
|
|
18
|
+
return index.bootstrapLazy([["checkbox-input_11.cjs",[[1,"general-registration",{"endpoint":[513],"language":[513],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationsUrl":[513,"translations-url"],"errorMessage":[32],"isFormValid":[32],"listOfInputs":[32],"isLoading":[32],"registrationStep":[32]},[[0,"sendValidityState","checkInputsValidityHandler"],[0,"sendInputValue","getInputsValueHandler"]]],[1,"general-input",{"type":[513],"name":[513],"displayName":[513,"display-name"],"action":[513],"validation":[16],"options":[520],"language":[513],"autofilled":[516],"defaultValue":[520,"default-value"],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[520,"client-styling"]}],[1,"checkbox-input",{"name":[513],"displayName":[513,"display-name"],"defaultValue":[513,"default-value"],"autofilled":[516],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"date-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"email-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]},[[16,"sendInputValue","valueChangedHandler"]]],[1,"number-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"password-input",{"name":[513],"displayName":[513,"display-name"],"defaultValue":[513,"default-value"],"autofilled":[516],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[513,"client-styling"],"isValid":[32],"errorMessage":[32],"limitStylingAppends":[32]},[[16,"sendInputValue","valueChangedHandler"]]],[1,"radio-input",{"name":[513],"displayName":[513,"display-name"],"optionsGroup":[16],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"select-input",{"name":[513],"displayName":[513,"display-name"],"action":[513],"defaultValue":[513,"default-value"],"autofilled":[516],"options":[16],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"tel-input",{"name":[513],"displayName":[513,"display-name"],"showLabels":[516,"show-labels"],"action":[513],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"isValid":[32],"errorMessage":[32],"limitStylingAppends":[32]}],[1,"text-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"rules":[513],"language":[513],"checkValidity":[516,"check-validity"],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[513,"client-styling"],"isValid":[32],"errorMessage":[32],"limitStylingAppends":[32]},[[16,"sendInputValue","valueChangedHandler"]]]]]], options);
|
|
19
19
|
});
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["checkbox-input_11.cjs",[[1,"general-registration",{"endpoint":[513],"language":[513],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"
|
|
17
|
+
return index.bootstrapLazy([["checkbox-input_11.cjs",[[1,"general-registration",{"endpoint":[513],"language":[513],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationsUrl":[513,"translations-url"],"errorMessage":[32],"isFormValid":[32],"listOfInputs":[32],"isLoading":[32],"registrationStep":[32]},[[0,"sendValidityState","checkInputsValidityHandler"],[0,"sendInputValue","getInputsValueHandler"]]],[1,"general-input",{"type":[513],"name":[513],"displayName":[513,"display-name"],"action":[513],"validation":[16],"options":[520],"language":[513],"autofilled":[516],"defaultValue":[520,"default-value"],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[520,"client-styling"]}],[1,"checkbox-input",{"name":[513],"displayName":[513,"display-name"],"defaultValue":[513,"default-value"],"autofilled":[516],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"date-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"email-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]},[[16,"sendInputValue","valueChangedHandler"]]],[1,"number-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"password-input",{"name":[513],"displayName":[513,"display-name"],"defaultValue":[513,"default-value"],"autofilled":[516],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[513,"client-styling"],"isValid":[32],"errorMessage":[32],"limitStylingAppends":[32]},[[16,"sendInputValue","valueChangedHandler"]]],[1,"radio-input",{"name":[513],"displayName":[513,"display-name"],"optionsGroup":[16],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"select-input",{"name":[513],"displayName":[513,"display-name"],"action":[513],"defaultValue":[513,"default-value"],"autofilled":[516],"options":[16],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"tel-input",{"name":[513],"displayName":[513,"display-name"],"showLabels":[516,"show-labels"],"action":[513],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"isValid":[32],"errorMessage":[32],"limitStylingAppends":[32]}],[1,"text-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"rules":[513],"language":[513],"checkValidity":[516,"check-validity"],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[513,"client-styling"],"isValid":[32],"errorMessage":[32],"limitStylingAppends":[32]},[[16,"sendInputValue","valueChangedHandler"]]]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -15,13 +15,16 @@ export class GeneralRegistration {
|
|
|
15
15
|
* Client custom styling via url
|
|
16
16
|
*/
|
|
17
17
|
this.clientStylingUrl = '';
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Translations via URL
|
|
20
|
+
*/
|
|
21
|
+
this.translationsUrl = '';
|
|
19
22
|
this.listOfInputs = [];
|
|
20
23
|
this.isLoading = true;
|
|
21
|
-
this.limitStylingAppends = false;
|
|
22
24
|
this.listOfInputValues = [];
|
|
23
25
|
this.listOfActions = [];
|
|
24
26
|
this.indexStep = 0;
|
|
27
|
+
this.emitValue = false;
|
|
25
28
|
this.registrationStepsState = {
|
|
26
29
|
regId: null
|
|
27
30
|
};
|
|
@@ -46,6 +49,9 @@ export class GeneralRegistration {
|
|
|
46
49
|
this.registrationStepUpdated.emit(this.registrationStep);
|
|
47
50
|
window.postMessage({ type: 'registrationStepUpdated', step: this.registrationStep }, window.location.href);
|
|
48
51
|
}
|
|
52
|
+
setFormValidity() {
|
|
53
|
+
this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
|
|
54
|
+
}
|
|
49
55
|
checkInputsValidityHandler(event) {
|
|
50
56
|
// Set isValid state of the input in the list.
|
|
51
57
|
this.listOfInputs.find(input => input.name == event.detail.name).isValid = event.detail.valid;
|
|
@@ -67,12 +73,11 @@ export class GeneralRegistration {
|
|
|
67
73
|
});
|
|
68
74
|
}
|
|
69
75
|
componentDidRender() {
|
|
70
|
-
if (
|
|
76
|
+
if (this.stylingContainer) {
|
|
71
77
|
if (this.clientStyling)
|
|
72
78
|
this.setClientStyling();
|
|
73
79
|
if (this.clientStylingUrl)
|
|
74
80
|
this.setClientStylingURL();
|
|
75
|
-
this.limitStylingAppends = true;
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
componentDidLoad() {
|
|
@@ -117,6 +122,7 @@ export class GeneralRegistration {
|
|
|
117
122
|
}
|
|
118
123
|
if (state.type == 'values') {
|
|
119
124
|
const savedValues = savedUserData[this.registrationStep].registerUserData;
|
|
125
|
+
console.log(savedValues);
|
|
120
126
|
this.listOfInputValues = Object.keys(savedValues).map(name => {
|
|
121
127
|
return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
|
|
122
128
|
});
|
|
@@ -125,7 +131,6 @@ export class GeneralRegistration {
|
|
|
125
131
|
const input = this.listOfInputs.find(input => input.name === inputValue.name);
|
|
126
132
|
if (input) {
|
|
127
133
|
input.defaultValue = inputValue.value;
|
|
128
|
-
console.log(input);
|
|
129
134
|
}
|
|
130
135
|
});
|
|
131
136
|
}
|
|
@@ -246,6 +251,7 @@ export class GeneralRegistration {
|
|
|
246
251
|
if (data.userId) {
|
|
247
252
|
alert(`User registered - the user ID is ${data.userId}`);
|
|
248
253
|
}
|
|
254
|
+
window.postMessage({ type: 'registrationSuccessful' }, window.location.href);
|
|
249
255
|
})
|
|
250
256
|
.catch((err) => {
|
|
251
257
|
console.error(err);
|
|
@@ -259,7 +265,7 @@ export class GeneralRegistration {
|
|
|
259
265
|
this.listOfInputs = config.content.fields.flatMap((field) => {
|
|
260
266
|
// Special case for inputs that need to be duplicated.
|
|
261
267
|
const duplicateInputRule = field.validate.custom.find(customRule => customRule.rule === 'duplicate-input');
|
|
262
|
-
const inputElement = Object.assign(Object.assign({}, field), { isValid:
|
|
268
|
+
const inputElement = Object.assign(Object.assign({}, field), { isValid: this.setInitialValidStatus(field) });
|
|
263
269
|
if (duplicateInputRule) {
|
|
264
270
|
const duplicateInput = Object.assign(Object.assign({}, field), { name: `${field.name}Duplicate`, displayName: duplicateInputRule.displayName, isValid: false, isDuplicateInput: true });
|
|
265
271
|
return [inputElement, duplicateInput];
|
|
@@ -268,7 +274,7 @@ export class GeneralRegistration {
|
|
|
268
274
|
return [inputElement];
|
|
269
275
|
}
|
|
270
276
|
});
|
|
271
|
-
// Populate the list of inputs values and set as null in the beginning
|
|
277
|
+
// Populate the list of inputs values and set as null in the beginning (or false for checkbox type inputs)
|
|
272
278
|
this.listOfInputValues = this.listOfInputs.map(field => {
|
|
273
279
|
var _a;
|
|
274
280
|
return { name: field.name,
|
|
@@ -290,6 +296,18 @@ export class GeneralRegistration {
|
|
|
290
296
|
};
|
|
291
297
|
}
|
|
292
298
|
}
|
|
299
|
+
setInitialValidStatus(field) {
|
|
300
|
+
var _a, _b;
|
|
301
|
+
// Input type checkbox, with no validation are valid
|
|
302
|
+
if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) == 'checkbox' && ((_b = field.validate) === null || _b === void 0 ? void 0 : _b.mandatory) == false) {
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
//Inputs that have default value are valid.
|
|
306
|
+
if (field.defaultValue !== null) {
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
293
311
|
stepChange(action) {
|
|
294
312
|
const stepNum = parseInt(this.registrationStep.replace('Step', ''));
|
|
295
313
|
if (action === 'increment') {
|
|
@@ -308,7 +326,7 @@ export class GeneralRegistration {
|
|
|
308
326
|
;
|
|
309
327
|
renderButtons() {
|
|
310
328
|
return (h("div", { class: 'registration__buttons-wrapper' },
|
|
311
|
-
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)),
|
|
329
|
+
h("button", { class: `registration__button registration__button--next ${this.isFormValid ? '' : 'registration__button--disabled'}`, type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e), disabled: !this.isFormValid }, this.isLastStep ? translate('doneButton', this.language) : translate('nextButton', this.language)),
|
|
312
330
|
h("button", { class: `registration__button registration__button--back ${this.registrationStep == 'Step1' ? 'registration__button--first-step' : ''}`, onClick: (e) => this.backHandler(e) }, translate('backButton', this.language))));
|
|
313
331
|
}
|
|
314
332
|
render() {
|
|
@@ -398,15 +416,31 @@ export class GeneralRegistration {
|
|
|
398
416
|
"attribute": "client-styling-url",
|
|
399
417
|
"reflect": true,
|
|
400
418
|
"defaultValue": "''"
|
|
419
|
+
},
|
|
420
|
+
"translationsUrl": {
|
|
421
|
+
"type": "string",
|
|
422
|
+
"mutable": false,
|
|
423
|
+
"complexType": {
|
|
424
|
+
"original": "string",
|
|
425
|
+
"resolved": "string",
|
|
426
|
+
"references": {}
|
|
427
|
+
},
|
|
428
|
+
"required": false,
|
|
429
|
+
"optional": false,
|
|
430
|
+
"docs": {
|
|
431
|
+
"tags": [],
|
|
432
|
+
"text": "Translations via URL"
|
|
433
|
+
},
|
|
434
|
+
"attribute": "translations-url",
|
|
435
|
+
"reflect": true,
|
|
436
|
+
"defaultValue": "''"
|
|
401
437
|
}
|
|
402
438
|
}; }
|
|
403
439
|
static get states() { return {
|
|
404
440
|
"errorMessage": {},
|
|
405
|
-
"emitValue": {},
|
|
406
441
|
"isFormValid": {},
|
|
407
442
|
"listOfInputs": {},
|
|
408
443
|
"isLoading": {},
|
|
409
|
-
"limitStylingAppends": {},
|
|
410
444
|
"registrationStep": {}
|
|
411
445
|
}; }
|
|
412
446
|
static get events() { return [{
|
|
@@ -443,6 +477,9 @@ export class GeneralRegistration {
|
|
|
443
477
|
static get watchers() { return [{
|
|
444
478
|
"propName": "registrationStep",
|
|
445
479
|
"methodName": "sendStep"
|
|
480
|
+
}, {
|
|
481
|
+
"propName": "listOfInputs",
|
|
482
|
+
"methodName": "setFormValidity"
|
|
446
483
|
}]; }
|
|
447
484
|
static get listeners() { return [{
|
|
448
485
|
"name": "sendValidityState",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en'];
|
|
3
|
+
const TRANSLATIONS = {
|
|
4
|
+
en: {
|
|
5
|
+
dateError: 'The selected date should be between {min} and {max}',
|
|
6
|
+
numberLengthError: 'The number should be between {min} and {max}',
|
|
7
|
+
lengthError: `The length should be between {minLength} and {maxLength}`,
|
|
8
|
+
requiredError: 'This input is required.',
|
|
9
|
+
nextButton: 'Next',
|
|
10
|
+
backButton: 'Back',
|
|
11
|
+
doneButton: 'Done'
|
|
12
|
+
},
|
|
13
|
+
ro: {
|
|
14
|
+
lengthError: `Cuvântul introdus este prea scurt. {minLength} and {maxLength}`,
|
|
15
|
+
requiredError: 'Acest câmp este obligatoriu.'
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export const translate = (key, customLang, values) => {
|
|
19
|
+
const lang = customLang;
|
|
20
|
+
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
21
|
+
if (values !== undefined) {
|
|
22
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
23
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
24
|
+
translation = translation.replace(regex, value);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return translation;
|
|
28
|
+
};
|
|
@@ -73,7 +73,7 @@ const CheckboxInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
render() {
|
|
76
|
-
return h("div", { class: 'checkbox__wrapper', ref: el => this.stylingContainer = el }, h("input", { type: "checkbox", id: `${this.name}__input`, ref: (el) => this.inputReference = el, name: this.name, checked:
|
|
76
|
+
return h("div", { class: 'checkbox__wrapper', ref: el => this.stylingContainer = el }, h("input", { type: "checkbox", id: `${this.name}__input`, ref: (el) => this.inputReference = el, name: this.name, checked: this.defaultValue == "true", readOnly: this.autofilled, required: this.validation.mandatory, value: this.value, onClick: () => this.handleClick() }), h("label", { class: 'checkbox__label', htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), h("small", { class: 'checkbox__error-message' }, this.errorMessage));
|
|
77
77
|
}
|
|
78
78
|
static get watchers() { return {
|
|
79
79
|
"isValid": ["validityChanged"],
|
|
@@ -39,7 +39,7 @@ const translate = (key, customLang, values) => {
|
|
|
39
39
|
return translation;
|
|
40
40
|
};
|
|
41
41
|
|
|
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}";
|
|
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--disabled {\n opacity: 0.5;\n}\n.registration__button--disabled:hover {\n opacity: 0.5;\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() {
|
|
@@ -60,13 +60,16 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
60
60
|
* Client custom styling via url
|
|
61
61
|
*/
|
|
62
62
|
this.clientStylingUrl = '';
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Translations via URL
|
|
65
|
+
*/
|
|
66
|
+
this.translationsUrl = '';
|
|
64
67
|
this.listOfInputs = [];
|
|
65
68
|
this.isLoading = true;
|
|
66
|
-
this.limitStylingAppends = false;
|
|
67
69
|
this.listOfInputValues = [];
|
|
68
70
|
this.listOfActions = [];
|
|
69
71
|
this.indexStep = 0;
|
|
72
|
+
this.emitValue = false;
|
|
70
73
|
this.registrationStepsState = {
|
|
71
74
|
regId: null
|
|
72
75
|
};
|
|
@@ -91,6 +94,9 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
91
94
|
this.registrationStepUpdated.emit(this.registrationStep);
|
|
92
95
|
window.postMessage({ type: 'registrationStepUpdated', step: this.registrationStep }, window.location.href);
|
|
93
96
|
}
|
|
97
|
+
setFormValidity() {
|
|
98
|
+
this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
|
|
99
|
+
}
|
|
94
100
|
checkInputsValidityHandler(event) {
|
|
95
101
|
// Set isValid state of the input in the list.
|
|
96
102
|
this.listOfInputs.find(input => input.name == event.detail.name).isValid = event.detail.valid;
|
|
@@ -112,12 +118,11 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
112
118
|
});
|
|
113
119
|
}
|
|
114
120
|
componentDidRender() {
|
|
115
|
-
if (
|
|
121
|
+
if (this.stylingContainer) {
|
|
116
122
|
if (this.clientStyling)
|
|
117
123
|
this.setClientStyling();
|
|
118
124
|
if (this.clientStylingUrl)
|
|
119
125
|
this.setClientStylingURL();
|
|
120
|
-
this.limitStylingAppends = true;
|
|
121
126
|
}
|
|
122
127
|
}
|
|
123
128
|
componentDidLoad() {
|
|
@@ -162,6 +167,7 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
162
167
|
}
|
|
163
168
|
if (state.type == 'values') {
|
|
164
169
|
const savedValues = savedUserData[this.registrationStep].registerUserData;
|
|
170
|
+
console.log(savedValues);
|
|
165
171
|
this.listOfInputValues = Object.keys(savedValues).map(name => {
|
|
166
172
|
return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
|
|
167
173
|
});
|
|
@@ -170,7 +176,6 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
170
176
|
const input = this.listOfInputs.find(input => input.name === inputValue.name);
|
|
171
177
|
if (input) {
|
|
172
178
|
input.defaultValue = inputValue.value;
|
|
173
|
-
console.log(input);
|
|
174
179
|
}
|
|
175
180
|
});
|
|
176
181
|
}
|
|
@@ -291,6 +296,7 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
291
296
|
if (data.userId) {
|
|
292
297
|
alert(`User registered - the user ID is ${data.userId}`);
|
|
293
298
|
}
|
|
299
|
+
window.postMessage({ type: 'registrationSuccessful' }, window.location.href);
|
|
294
300
|
})
|
|
295
301
|
.catch((err) => {
|
|
296
302
|
console.error(err);
|
|
@@ -304,7 +310,7 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
304
310
|
this.listOfInputs = config.content.fields.flatMap((field) => {
|
|
305
311
|
// Special case for inputs that need to be duplicated.
|
|
306
312
|
const duplicateInputRule = field.validate.custom.find(customRule => customRule.rule === 'duplicate-input');
|
|
307
|
-
const inputElement = Object.assign(Object.assign({}, field), { isValid:
|
|
313
|
+
const inputElement = Object.assign(Object.assign({}, field), { isValid: this.setInitialValidStatus(field) });
|
|
308
314
|
if (duplicateInputRule) {
|
|
309
315
|
const duplicateInput = Object.assign(Object.assign({}, field), { name: `${field.name}Duplicate`, displayName: duplicateInputRule.displayName, isValid: false, isDuplicateInput: true });
|
|
310
316
|
return [inputElement, duplicateInput];
|
|
@@ -313,7 +319,7 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
313
319
|
return [inputElement];
|
|
314
320
|
}
|
|
315
321
|
});
|
|
316
|
-
// Populate the list of inputs values and set as null in the beginning
|
|
322
|
+
// Populate the list of inputs values and set as null in the beginning (or false for checkbox type inputs)
|
|
317
323
|
this.listOfInputValues = this.listOfInputs.map(field => {
|
|
318
324
|
var _a;
|
|
319
325
|
return { name: field.name,
|
|
@@ -335,6 +341,18 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
335
341
|
};
|
|
336
342
|
}
|
|
337
343
|
}
|
|
344
|
+
setInitialValidStatus(field) {
|
|
345
|
+
var _a, _b;
|
|
346
|
+
// Input type checkbox, with no validation are valid
|
|
347
|
+
if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) == 'checkbox' && ((_b = field.validate) === null || _b === void 0 ? void 0 : _b.mandatory) == false) {
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
//Inputs that have default value are valid.
|
|
351
|
+
if (field.defaultValue !== null) {
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
338
356
|
stepChange(action) {
|
|
339
357
|
const stepNum = parseInt(this.registrationStep.replace('Step', ''));
|
|
340
358
|
if (action === 'increment') {
|
|
@@ -352,7 +370,7 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
352
370
|
}
|
|
353
371
|
;
|
|
354
372
|
renderButtons() {
|
|
355
|
-
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))));
|
|
373
|
+
return (h("div", { class: 'registration__buttons-wrapper' }, h("button", { class: `registration__button registration__button--next ${this.isFormValid ? '' : 'registration__button--disabled'}`, type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e), disabled: !this.isFormValid }, 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))));
|
|
356
374
|
}
|
|
357
375
|
render() {
|
|
358
376
|
if (this.isLoading) {
|
|
@@ -361,7 +379,8 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
361
379
|
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()));
|
|
362
380
|
}
|
|
363
381
|
static get watchers() { return {
|
|
364
|
-
"registrationStep": ["sendStep"]
|
|
382
|
+
"registrationStep": ["sendStep"],
|
|
383
|
+
"listOfInputs": ["setFormValidity"]
|
|
365
384
|
}; }
|
|
366
385
|
static get style() { return generalRegistrationCss; }
|
|
367
386
|
}, [1, "general-registration", {
|
|
@@ -369,12 +388,11 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
369
388
|
"language": [513],
|
|
370
389
|
"clientStyling": [1537, "client-styling"],
|
|
371
390
|
"clientStylingUrl": [513, "client-styling-url"],
|
|
391
|
+
"translationsUrl": [513, "translations-url"],
|
|
372
392
|
"errorMessage": [32],
|
|
373
|
-
"emitValue": [32],
|
|
374
393
|
"isFormValid": [32],
|
|
375
394
|
"listOfInputs": [32],
|
|
376
395
|
"isLoading": [32],
|
|
377
|
-
"limitStylingAppends": [32],
|
|
378
396
|
"registrationStep": [32]
|
|
379
397
|
}, [[0, "sendValidityState", "checkInputsValidityHandler"], [0, "sendInputValue", "getInputsValueHandler"]]]);
|
|
380
398
|
function defineCustomElement$1() {
|
|
@@ -99,7 +99,7 @@ const CheckboxInput = class {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
render() {
|
|
102
|
-
return h$2("div", { class: 'checkbox__wrapper', ref: el => this.stylingContainer = el }, h$2("input", { type: "checkbox", id: `${this.name}__input`, ref: (el) => this.inputReference = el, name: this.name, checked:
|
|
102
|
+
return h$2("div", { class: 'checkbox__wrapper', ref: el => this.stylingContainer = el }, h$2("input", { type: "checkbox", id: `${this.name}__input`, ref: (el) => this.inputReference = el, name: this.name, checked: this.defaultValue == "true", readOnly: this.autofilled, required: this.validation.mandatory, value: this.value, onClick: () => this.handleClick() }), h$2("label", { class: 'checkbox__label', htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), h$2("small", { class: 'checkbox__error-message' }, this.errorMessage));
|
|
103
103
|
}
|
|
104
104
|
static get watchers() { return {
|
|
105
105
|
"isValid": ["validityChanged"],
|
|
@@ -23305,7 +23305,7 @@ const translate = (key, customLang, values) => {
|
|
|
23305
23305
|
return translation;
|
|
23306
23306
|
};
|
|
23307
23307
|
|
|
23308
|
-
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}";
|
|
23308
|
+
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--disabled {\n opacity: 0.5;\n}\n.registration__button--disabled:hover {\n opacity: 0.5;\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}";
|
|
23309
23309
|
|
|
23310
23310
|
const GeneralRegistration = class {
|
|
23311
23311
|
constructor(hostRef) {
|
|
@@ -23324,13 +23324,16 @@ const GeneralRegistration = class {
|
|
|
23324
23324
|
* Client custom styling via url
|
|
23325
23325
|
*/
|
|
23326
23326
|
this.clientStylingUrl = '';
|
|
23327
|
-
|
|
23327
|
+
/**
|
|
23328
|
+
* Translations via URL
|
|
23329
|
+
*/
|
|
23330
|
+
this.translationsUrl = '';
|
|
23328
23331
|
this.listOfInputs = [];
|
|
23329
23332
|
this.isLoading = true;
|
|
23330
|
-
this.limitStylingAppends = false;
|
|
23331
23333
|
this.listOfInputValues = [];
|
|
23332
23334
|
this.listOfActions = [];
|
|
23333
23335
|
this.indexStep = 0;
|
|
23336
|
+
this.emitValue = false;
|
|
23334
23337
|
this.registrationStepsState = {
|
|
23335
23338
|
regId: null
|
|
23336
23339
|
};
|
|
@@ -23355,6 +23358,9 @@ const GeneralRegistration = class {
|
|
|
23355
23358
|
this.registrationStepUpdated.emit(this.registrationStep);
|
|
23356
23359
|
window.postMessage({ type: 'registrationStepUpdated', step: this.registrationStep }, window.location.href);
|
|
23357
23360
|
}
|
|
23361
|
+
setFormValidity() {
|
|
23362
|
+
this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
|
|
23363
|
+
}
|
|
23358
23364
|
checkInputsValidityHandler(event) {
|
|
23359
23365
|
// Set isValid state of the input in the list.
|
|
23360
23366
|
this.listOfInputs.find(input => input.name == event.detail.name).isValid = event.detail.valid;
|
|
@@ -23376,12 +23382,11 @@ const GeneralRegistration = class {
|
|
|
23376
23382
|
});
|
|
23377
23383
|
}
|
|
23378
23384
|
componentDidRender() {
|
|
23379
|
-
if (
|
|
23385
|
+
if (this.stylingContainer) {
|
|
23380
23386
|
if (this.clientStyling)
|
|
23381
23387
|
this.setClientStyling();
|
|
23382
23388
|
if (this.clientStylingUrl)
|
|
23383
23389
|
this.setClientStylingURL();
|
|
23384
|
-
this.limitStylingAppends = true;
|
|
23385
23390
|
}
|
|
23386
23391
|
}
|
|
23387
23392
|
componentDidLoad() {
|
|
@@ -23426,6 +23431,7 @@ const GeneralRegistration = class {
|
|
|
23426
23431
|
}
|
|
23427
23432
|
if (state.type == 'values') {
|
|
23428
23433
|
const savedValues = savedUserData[this.registrationStep].registerUserData;
|
|
23434
|
+
console.log(savedValues);
|
|
23429
23435
|
this.listOfInputValues = Object.keys(savedValues).map(name => {
|
|
23430
23436
|
return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
|
|
23431
23437
|
});
|
|
@@ -23434,7 +23440,6 @@ const GeneralRegistration = class {
|
|
|
23434
23440
|
const input = this.listOfInputs.find(input => input.name === inputValue.name);
|
|
23435
23441
|
if (input) {
|
|
23436
23442
|
input.defaultValue = inputValue.value;
|
|
23437
|
-
console.log(input);
|
|
23438
23443
|
}
|
|
23439
23444
|
});
|
|
23440
23445
|
}
|
|
@@ -23555,6 +23560,7 @@ const GeneralRegistration = class {
|
|
|
23555
23560
|
if (data.userId) {
|
|
23556
23561
|
alert(`User registered - the user ID is ${data.userId}`);
|
|
23557
23562
|
}
|
|
23563
|
+
window.postMessage({ type: 'registrationSuccessful' }, window.location.href);
|
|
23558
23564
|
})
|
|
23559
23565
|
.catch((err) => {
|
|
23560
23566
|
console.error(err);
|
|
@@ -23568,7 +23574,7 @@ const GeneralRegistration = class {
|
|
|
23568
23574
|
this.listOfInputs = config.content.fields.flatMap((field) => {
|
|
23569
23575
|
// Special case for inputs that need to be duplicated.
|
|
23570
23576
|
const duplicateInputRule = field.validate.custom.find(customRule => customRule.rule === 'duplicate-input');
|
|
23571
|
-
const inputElement = Object.assign(Object.assign({}, field), { isValid:
|
|
23577
|
+
const inputElement = Object.assign(Object.assign({}, field), { isValid: this.setInitialValidStatus(field) });
|
|
23572
23578
|
if (duplicateInputRule) {
|
|
23573
23579
|
const duplicateInput = Object.assign(Object.assign({}, field), { name: `${field.name}Duplicate`, displayName: duplicateInputRule.displayName, isValid: false, isDuplicateInput: true });
|
|
23574
23580
|
return [inputElement, duplicateInput];
|
|
@@ -23577,7 +23583,7 @@ const GeneralRegistration = class {
|
|
|
23577
23583
|
return [inputElement];
|
|
23578
23584
|
}
|
|
23579
23585
|
});
|
|
23580
|
-
// Populate the list of inputs values and set as null in the beginning
|
|
23586
|
+
// Populate the list of inputs values and set as null in the beginning (or false for checkbox type inputs)
|
|
23581
23587
|
this.listOfInputValues = this.listOfInputs.map(field => {
|
|
23582
23588
|
var _a;
|
|
23583
23589
|
return { name: field.name,
|
|
@@ -23599,6 +23605,18 @@ const GeneralRegistration = class {
|
|
|
23599
23605
|
};
|
|
23600
23606
|
}
|
|
23601
23607
|
}
|
|
23608
|
+
setInitialValidStatus(field) {
|
|
23609
|
+
var _a, _b;
|
|
23610
|
+
// Input type checkbox, with no validation are valid
|
|
23611
|
+
if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) == 'checkbox' && ((_b = field.validate) === null || _b === void 0 ? void 0 : _b.mandatory) == false) {
|
|
23612
|
+
return true;
|
|
23613
|
+
}
|
|
23614
|
+
//Inputs that have default value are valid.
|
|
23615
|
+
if (field.defaultValue !== null) {
|
|
23616
|
+
return true;
|
|
23617
|
+
}
|
|
23618
|
+
return false;
|
|
23619
|
+
}
|
|
23602
23620
|
stepChange(action) {
|
|
23603
23621
|
const stepNum = parseInt(this.registrationStep.replace('Step', ''));
|
|
23604
23622
|
if (action === 'increment') {
|
|
@@ -23616,7 +23634,7 @@ const GeneralRegistration = class {
|
|
|
23616
23634
|
}
|
|
23617
23635
|
;
|
|
23618
23636
|
renderButtons() {
|
|
23619
|
-
return (h$2("div", { class: 'registration__buttons-wrapper' }, h$2("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$2("button", { class: `registration__button registration__button--back ${this.registrationStep == 'Step1' ? 'registration__button--first-step' : ''}`, onClick: (e) => this.backHandler(e) }, translate('backButton', this.language))));
|
|
23637
|
+
return (h$2("div", { class: 'registration__buttons-wrapper' }, h$2("button", { class: `registration__button registration__button--next ${this.isFormValid ? '' : 'registration__button--disabled'}`, type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e), disabled: !this.isFormValid }, this.isLastStep ? translate('doneButton', this.language) : translate('nextButton', this.language)), h$2("button", { class: `registration__button registration__button--back ${this.registrationStep == 'Step1' ? 'registration__button--first-step' : ''}`, onClick: (e) => this.backHandler(e) }, translate('backButton', this.language))));
|
|
23620
23638
|
}
|
|
23621
23639
|
render() {
|
|
23622
23640
|
if (this.isLoading) {
|
|
@@ -23625,7 +23643,8 @@ const GeneralRegistration = class {
|
|
|
23625
23643
|
return (h$2("div", { class: `registration registration__${this.registrationStep}`, ref: el => this.stylingContainer = el }, h$2("form", { action: '.', id: 'RegistrationForm', class: 'registration__form' }, this.renderInputs()), this.renderButtons()));
|
|
23626
23644
|
}
|
|
23627
23645
|
static get watchers() { return {
|
|
23628
|
-
"registrationStep": ["sendStep"]
|
|
23646
|
+
"registrationStep": ["sendStep"],
|
|
23647
|
+
"listOfInputs": ["setFormValidity"]
|
|
23629
23648
|
}; }
|
|
23630
23649
|
};
|
|
23631
23650
|
GeneralRegistration.style = generalRegistrationCss;
|
|
@@ -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":[513],"language":[513],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"
|
|
16
|
+
return bootstrapLazy([["checkbox-input_11",[[1,"general-registration",{"endpoint":[513],"language":[513],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationsUrl":[513,"translations-url"],"errorMessage":[32],"isFormValid":[32],"listOfInputs":[32],"isLoading":[32],"registrationStep":[32]},[[0,"sendValidityState","checkInputsValidityHandler"],[0,"sendInputValue","getInputsValueHandler"]]],[1,"general-input",{"type":[513],"name":[513],"displayName":[513,"display-name"],"action":[513],"validation":[16],"options":[520],"language":[513],"autofilled":[516],"defaultValue":[520,"default-value"],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[520,"client-styling"]}],[1,"checkbox-input",{"name":[513],"displayName":[513,"display-name"],"defaultValue":[513,"default-value"],"autofilled":[516],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"date-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"email-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]},[[16,"sendInputValue","valueChangedHandler"]]],[1,"number-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"password-input",{"name":[513],"displayName":[513,"display-name"],"defaultValue":[513,"default-value"],"autofilled":[516],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[513,"client-styling"],"isValid":[32],"errorMessage":[32],"limitStylingAppends":[32]},[[16,"sendInputValue","valueChangedHandler"]]],[1,"radio-input",{"name":[513],"displayName":[513,"display-name"],"optionsGroup":[16],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"select-input",{"name":[513],"displayName":[513,"display-name"],"action":[513],"defaultValue":[513,"default-value"],"autofilled":[516],"options":[16],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"tel-input",{"name":[513],"displayName":[513,"display-name"],"showLabels":[516,"show-labels"],"action":[513],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"isValid":[32],"errorMessage":[32],"limitStylingAppends":[32]}],[1,"text-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"rules":[513],"language":[513],"checkValidity":[516,"check-validity"],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[513,"client-styling"],"isValid":[32],"errorMessage":[32],"limitStylingAppends":[32]},[[16,"sendInputValue","valueChangedHandler"]]]]]], options);
|
|
17
17
|
});
|
package/dist/esm/loader.js
CHANGED
|
@@ -10,7 +10,7 @@ const patchEsm = () => {
|
|
|
10
10
|
const defineCustomElements = (win, options) => {
|
|
11
11
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
12
12
|
return patchEsm().then(() => {
|
|
13
|
-
return bootstrapLazy([["checkbox-input_11",[[1,"general-registration",{"endpoint":[513],"language":[513],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"
|
|
13
|
+
return bootstrapLazy([["checkbox-input_11",[[1,"general-registration",{"endpoint":[513],"language":[513],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationsUrl":[513,"translations-url"],"errorMessage":[32],"isFormValid":[32],"listOfInputs":[32],"isLoading":[32],"registrationStep":[32]},[[0,"sendValidityState","checkInputsValidityHandler"],[0,"sendInputValue","getInputsValueHandler"]]],[1,"general-input",{"type":[513],"name":[513],"displayName":[513,"display-name"],"action":[513],"validation":[16],"options":[520],"language":[513],"autofilled":[516],"defaultValue":[520,"default-value"],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[520,"client-styling"]}],[1,"checkbox-input",{"name":[513],"displayName":[513,"display-name"],"defaultValue":[513,"default-value"],"autofilled":[516],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"date-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"email-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]},[[16,"sendInputValue","valueChangedHandler"]]],[1,"number-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"password-input",{"name":[513],"displayName":[513,"display-name"],"defaultValue":[513,"default-value"],"autofilled":[516],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[513,"client-styling"],"isValid":[32],"errorMessage":[32],"limitStylingAppends":[32]},[[16,"sendInputValue","valueChangedHandler"]]],[1,"radio-input",{"name":[513],"displayName":[513,"display-name"],"optionsGroup":[16],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"select-input",{"name":[513],"displayName":[513,"display-name"],"action":[513],"defaultValue":[513,"default-value"],"autofilled":[516],"options":[16],"validation":[16],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"errorMessage":[32],"isValid":[32],"limitStylingAppends":[32]}],[1,"tel-input",{"name":[513],"displayName":[513,"display-name"],"showLabels":[516,"show-labels"],"action":[513],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"language":[513],"emitValue":[516,"emit-value"],"clientStyling":[513,"client-styling"],"isValid":[32],"errorMessage":[32],"limitStylingAppends":[32]}],[1,"text-input",{"name":[513],"displayName":[513,"display-name"],"validation":[16],"defaultValue":[513,"default-value"],"autofilled":[516],"rules":[513],"language":[513],"checkValidity":[516,"check-validity"],"emitValue":[516,"emit-value"],"isDuplicateInput":[516,"is-duplicate-input"],"clientStyling":[513,"client-styling"],"isValid":[32],"errorMessage":[32],"limitStylingAppends":[32]},[[16,"sendInputValue","valueChangedHandler"]]]]]], options);
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,b as l}from"./p-35d6abbe.js";(()=>{const l=import.meta.url,a={};return""!==l&&(a.resourcesUrl=new URL(".",l).href),e(a)})().then((e=>l([["p-
|
|
1
|
+
import{p as e,b as l}from"./p-35d6abbe.js";(()=>{const l=import.meta.url,a={};return""!==l&&(a.resourcesUrl=new URL(".",l).href),e(a)})().then((e=>l([["p-4142a899",[[1,"general-registration",{endpoint:[513],language:[513],clientStyling:[1537,"client-styling"],clientStylingUrl:[513,"client-styling-url"],translationsUrl:[513,"translations-url"],errorMessage:[32],isFormValid:[32],listOfInputs:[32],isLoading:[32],registrationStep:[32]},[[0,"sendValidityState","checkInputsValidityHandler"],[0,"sendInputValue","getInputsValueHandler"]]],[1,"general-input",{type:[513],name:[513],displayName:[513,"display-name"],action:[513],validation:[16],options:[520],language:[513],autofilled:[516],defaultValue:[520,"default-value"],emitValue:[516,"emit-value"],isDuplicateInput:[516,"is-duplicate-input"],clientStyling:[520,"client-styling"]}],[1,"checkbox-input",{name:[513],displayName:[513,"display-name"],defaultValue:[513,"default-value"],autofilled:[516],validation:[16],language:[513],emitValue:[516,"emit-value"],clientStyling:[513,"client-styling"],errorMessage:[32],isValid:[32],limitStylingAppends:[32]}],[1,"date-input",{name:[513],displayName:[513,"display-name"],validation:[16],defaultValue:[513,"default-value"],autofilled:[516],language:[513],emitValue:[516,"emit-value"],clientStyling:[513,"client-styling"],errorMessage:[32],isValid:[32],limitStylingAppends:[32]}],[1,"email-input",{name:[513],displayName:[513,"display-name"],validation:[16],defaultValue:[513,"default-value"],autofilled:[516],language:[513],emitValue:[516,"emit-value"],isDuplicateInput:[516,"is-duplicate-input"],clientStyling:[513,"client-styling"],errorMessage:[32],isValid:[32],limitStylingAppends:[32]},[[16,"sendInputValue","valueChangedHandler"]]],[1,"number-input",{name:[513],displayName:[513,"display-name"],validation:[16],defaultValue:[513,"default-value"],autofilled:[516],language:[513],emitValue:[516,"emit-value"],clientStyling:[513,"client-styling"],errorMessage:[32],isValid:[32],limitStylingAppends:[32]}],[1,"password-input",{name:[513],displayName:[513,"display-name"],defaultValue:[513,"default-value"],autofilled:[516],validation:[16],language:[513],emitValue:[516,"emit-value"],isDuplicateInput:[516,"is-duplicate-input"],clientStyling:[513,"client-styling"],isValid:[32],errorMessage:[32],limitStylingAppends:[32]},[[16,"sendInputValue","valueChangedHandler"]]],[1,"radio-input",{name:[513],displayName:[513,"display-name"],optionsGroup:[16],validation:[16],language:[513],emitValue:[516,"emit-value"],clientStyling:[513,"client-styling"],errorMessage:[32],isValid:[32],limitStylingAppends:[32]}],[1,"select-input",{name:[513],displayName:[513,"display-name"],action:[513],defaultValue:[513,"default-value"],autofilled:[516],options:[16],validation:[16],language:[513],emitValue:[516,"emit-value"],clientStyling:[513,"client-styling"],errorMessage:[32],isValid:[32],limitStylingAppends:[32]}],[1,"tel-input",{name:[513],displayName:[513,"display-name"],showLabels:[516,"show-labels"],action:[513],validation:[16],defaultValue:[513,"default-value"],autofilled:[516],language:[513],emitValue:[516,"emit-value"],clientStyling:[513,"client-styling"],isValid:[32],errorMessage:[32],limitStylingAppends:[32]}],[1,"text-input",{name:[513],displayName:[513,"display-name"],validation:[16],defaultValue:[513,"default-value"],autofilled:[516],rules:[513],language:[513],checkValidity:[516,"check-validity"],emitValue:[516,"emit-value"],isDuplicateInput:[516,"is-duplicate-input"],clientStyling:[513,"client-styling"],isValid:[32],errorMessage:[32],limitStylingAppends:[32]},[[16,"sendInputValue","valueChangedHandler"]]]]]],e)));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as t,c as e,h as i,g as s}from"./p-35d6abbe.js";const o=["ro","en"],r={en:{dateError:"The selected date should be between {min} and {max}",numberLengthError:"The number should be between {min} and {max}",lengthError:"The length should be between {minLength} and {maxLength}",requiredError:"This input is required.",nextButton:"Next",backButton:"Back",doneButton:"Done"},ro:{lengthError:"Cuvântul introdus este prea scurt. {minLength} and {maxLength}",requiredError:"Acest câmp este obligatoriu."}},n=(t,e,i)=>{const s=e;let n=r[void 0!==s&&o.includes(s)?s:"en"][t];if(void 0!==i)for(const[t,e]of Object.entries(i.values)){const i=new RegExp(`{${t}}`,"g");n=n.replace(i,e)}return n},a=class{constructor(i){t(this,i),this.sendValidityState=e(this,"sendValidityState",7),this.sendInputValue=e(this,"sendInputValue",7),this.defaultValue="",this.clientStyling="",this.limitStylingAppends=!1,this.value="",this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}validityChanged(){1==this.emitValue&&this.valueHandler({name:this.name,value:this.value})}validityStateHandler(t){this.sendValidityState.emit(t)}emitValueHandler(t){1==t&&this.isValid&&this.valueHandler({name:this.name,value:this.value})}valueHandler(t){this.sendInputValue.emit(t)}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}componentDidLoad(){this.defaultValue&&(this.value=this.defaultValue,this.valueHandler({name:this.name,value:this.value}))}handleClick(){this.value=this.inputReference.checked.toString(),this.errorMessage=this.setErrorMessage(),this.isValid=this.setValidity(),this.validityStateHandler({valid:this.isValid,name:this.name}),this.emitValueHandler(!0)}setValidity(){return this.inputReference.validity.valid}setErrorMessage(){if(this.inputReference.validity.valueMissing)return n("requiredError",this.language)}render(){return i("div",{class:"checkbox__wrapper",ref:t=>this.stylingContainer=t},i("input",{type:"checkbox",id:`${this.name}__input`,ref:t=>this.inputReference=t,name:this.name,checked
|
|
1
|
+
import{r as t,c as e,h as i,g as s}from"./p-35d6abbe.js";const o=["ro","en"],r={en:{dateError:"The selected date should be between {min} and {max}",numberLengthError:"The number should be between {min} and {max}",lengthError:"The length should be between {minLength} and {maxLength}",requiredError:"This input is required.",nextButton:"Next",backButton:"Back",doneButton:"Done"},ro:{lengthError:"Cuvântul introdus este prea scurt. {minLength} and {maxLength}",requiredError:"Acest câmp este obligatoriu."}},n=(t,e,i)=>{const s=e;let n=r[void 0!==s&&o.includes(s)?s:"en"][t];if(void 0!==i)for(const[t,e]of Object.entries(i.values)){const i=new RegExp(`{${t}}`,"g");n=n.replace(i,e)}return n},a=class{constructor(i){t(this,i),this.sendValidityState=e(this,"sendValidityState",7),this.sendInputValue=e(this,"sendInputValue",7),this.defaultValue="",this.clientStyling="",this.limitStylingAppends=!1,this.value="",this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}validityChanged(){1==this.emitValue&&this.valueHandler({name:this.name,value:this.value})}validityStateHandler(t){this.sendValidityState.emit(t)}emitValueHandler(t){1==t&&this.isValid&&this.valueHandler({name:this.name,value:this.value})}valueHandler(t){this.sendInputValue.emit(t)}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}componentDidLoad(){this.defaultValue&&(this.value=this.defaultValue,this.valueHandler({name:this.name,value:this.value}))}handleClick(){this.value=this.inputReference.checked.toString(),this.errorMessage=this.setErrorMessage(),this.isValid=this.setValidity(),this.validityStateHandler({valid:this.isValid,name:this.name}),this.emitValueHandler(!0)}setValidity(){return this.inputReference.validity.valid}setErrorMessage(){if(this.inputReference.validity.valueMissing)return n("requiredError",this.language)}render(){return i("div",{class:"checkbox__wrapper",ref:t=>this.stylingContainer=t},i("input",{type:"checkbox",id:`${this.name}__input`,ref:t=>this.inputReference=t,name:this.name,checked:"true"==this.defaultValue,readOnly:this.autofilled,required:this.validation.mandatory,value:this.value,onClick:()=>this.handleClick()}),i("label",{class:"checkbox__label",htmlFor:`${this.name}__input`},this.displayName," ",this.validation.mandatory?"*":""),i("small",{class:"checkbox__error-message"},this.errorMessage))}static get watchers(){return{isValid:["validityChanged"],emitValue:["emitValueHandler"]}}};a.style='*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.checkbox{font-family:"Roboto";font-style:normal}.checkbox__wrapper{display:flex;gap:10px;position:relative;align-items:baseline}.checkbox__label{font-style:inherit;font-family:inherit;font-weight:400;font-size:16px;color:#2B2D3F;line-height:14px}.checkbox__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}';
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
@@ -2815,7 +2815,7 @@ class Br{constructor(t){this.host=t,t.addEventListener("opened-changed",(()=>{t.
|
|
|
2815
2815
|
</vaadin-date-picker-overlay>
|
|
2816
2816
|
|
|
2817
2817
|
<slot name="tooltip"></slot>
|
|
2818
|
-
`}get clearElement(){return this.$.clearButton}ready(){super.ready(),this.addController(new Or(this,(t=>{this._setInputElement(t),this._setFocusElement(t),this.stateTarget=t,this.ariaTarget=t}))),this.addController(new Fr(this.inputElement,this._labelController)),this._tooltipController=new ro(this),this.addController(this._tooltipController),this._tooltipController.setPosition("top"),this._tooltipController.setShouldShow((t=>!t.opened)),this.shadowRoot.querySelector('[part="toggle-button"]').addEventListener("mousedown",(t=>t.preventDefault()))}_initOverlay(){super._initOverlay(),this.$.overlay.addEventListener("vaadin-overlay-close",this._onVaadinOverlayClose.bind(this))}_onVaadinOverlayClose(t){t.detail.sourceEvent&&t.detail.sourceEvent.composedPath().includes(this)&&t.preventDefault()}_toggle(t){t.stopPropagation(),this[this._overlayInitialized&&this.$.overlay.opened?"close":"open"]()}_openedChanged(t){super._openedChanged(t),this.$.overlay.positionTarget=this.shadowRoot.querySelector('[part="input-field"]'),this.$.overlay.noVerticalOverlap=!0}}customElements.define(Vr.is,Vr);const $r=class{constructor(i){t(this,i),this.sendValidityState=e(this,"sendValidityState",7),this.sendInputValue=e(this,"sendInputValue",7),this.clientStyling="",this.limitStylingAppends=!1,this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}validityChanged(){this.validityStateHandler({valid:this.isValid,name:this.name}),1==this.emitValue&&this.valueHandler({name:this.name,value:this.value})}validityStateHandler(t){this.sendValidityState.emit(t)}emitValueHandler(t){1==t&&this.isValid&&this.valueHandler({name:this.name,value:this.value})}valueHandler(t){this.sendInputValue.emit(t)}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}componentDidLoad(){this.inputReference=this.element.shadowRoot.querySelector("input"),this.defaultValue&&(this.value=this.defaultValue,this.valueHandler({name:this.name,value:this.value}))}handleInput(t){this.value=t.target.value,this.errorMessage=this.setErrorMessage(),this.isValid=this.setValidity(),this.validityStateHandler({valid:this.isValid,name:this.name}),this.emitValueHandler(!0)}setValidity(){return this.inputReference.validity.valid}setErrorMessage(){return this.inputReference.validity.rangeUnderflow||this.inputReference.validity.rangeOverflow?n("dateError",this.language,{values:{min:this.validation.min,max:this.validation.max}}):this.inputReference.validity.valueMissing?n("requiredError",this.language):void 0}render(){const t=1==this.isValid||null==this.isValid?"":"date__input--invalid";return i("div",{class:"date__wrapper",ref:t=>this.stylingContainer=t},i("label",{class:`date__label ${this.validation.mandatory?"date__label--required":""}}`,htmlFor:`${this.name}__input`},this.displayName," ",this.validation.mandatory?"*":""),i("vaadin-date-picker",{id:`${this.name}__input`,type:"date",class:`date__input ${t}`,value:this.defaultValue,readOnly:this.autofilled,placeholder:`${this.displayName} ${this.validation.mandatory?"*":""}`,required:this.validation.mandatory,max:this.validation.max,min:this.validation.min,onBlur:t=>this.handleInput(t)}),i("small",{class:"date__error-message"},this.errorMessage))}get element(){return s(this)}static get watchers(){return{isValid:["validityChanged"],emitValue:["emitValueHandler"]}}};$r.style='*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.date{font-family:"Roboto";font-style:normal}.date__wrapper{position:relative;width:100%;padding-top:26px}.date__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.date__label--required::after{content:"*";font-family:inherit;color:#1F1F1F;margin-left:2px}.date__input{border:none;width:inherit;position:relative}.date__input[focused]::part(input-field){border-color:#3E3E3E}.date__input[invalid]::part(input-field){border-color:#cc0000b3}.date__input::part(input-field){border-radius:4px;background-color:#FFFFFF;border:2px solid #DEE1EE;color:#2A2E3F;border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px}.date__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}';const Lr=class{constructor(i){t(this,i),this.sendValidityState=e(this,"sendValidityState",7),this.sendInputValue=e(this,"sendInputValue",7),this.clientStyling="",this.limitStylingAppends=!1,this.validationPattern="",this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}validityChanged(){this.validityStateHandler({valid:this.isValid,name:this.name}),1==this.emitValue&&this.valueHandler({name:this.name,value:this.value})}emitValueHandler(t){1==t&&this.isValid&&this.valueHandler({name:this.name,value:this.value})}validityStateHandler(t){this.sendValidityState.emit(t)}valueHandler(t){this.sendInputValue.emit(t)}valueChangedHandler(t){this.isDuplicateInput&&this.name===t.detail.name+"Duplicate"&&(this.duplicateInputValue=t.detail.value)}connectedCallback(){this.validationPattern=this.setPattern()}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}componentDidLoad(){this.defaultValue&&(this.value=this.defaultValue,this.valueHandler({name:this.name,value:this.value}))}handleInput(t){this.value=t.target.value,this.errorMessage=this.setErrorMessage(),this.isValid=this.setValidity(),this.validityStateHandler({valid:this.isValid,name:this.name}),this.emitValueHandler(!0)}setValidity(){return this.inputReference.validity.valid}setPattern(){var t,e;if((null===(t=this.validation.custom)||void 0===t?void 0:t.length)>0)return null===(e=this.validation.custom.find((t=>"regex"===t.rule)))||void 0===e?void 0:e.pattern}setErrorMessage(){var t;return this.inputReference.validity.patternMismatch?null===(t=this.validation.custom.find((t=>"regex"===t.rule)))||void 0===t?void 0:t.errorMessage:this.inputReference.validity.tooShort||this.inputReference.validity.tooLong?n("lengthError",this.language,{values:{minLength:this.validation.minLength,maxLength:this.validation.maxLength}}):this.inputReference.validity.valueMissing?n("requiredError",this.language):this.isDuplicateInput&&this.duplicateInputValue!==this.value?this.validation.custom.find((t=>"duplicate-input"===t.rule)).errorMessage:void 0}render(){return i("div",{class:"email__wrapper",ref:t=>this.stylingContainer=t},i("input",{id:`${this.name}__input`,type:"email",class:"email__input "+(1==this.isValid||null==this.isValid?"":"email__input--invalid"),value:this.defaultValue,readOnly:this.autofilled,placeholder:`${this.displayName} ${this.validation.mandatory?"*":""}`,ref:t=>this.inputReference=t,pattern:this.validationPattern,required:this.validation.mandatory,minlength:this.validation.minLength,maxlength:this.validation.maxLength,onBlur:t=>this.handleInput(t)}),i("label",{class:"email__label "+(this.validation.mandatory?"email__label--required":""),htmlFor:`${this.name}__input`},this.displayName),i("small",{class:"email__error-message"},this.errorMessage))}static get watchers(){return{isValid:["validityChanged"],emitValue:["emitValueHandler"]}}};Lr.style='*,*::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}';const jr=class{constructor(e){t(this,e),this.type="text",this.clientStyling=""}render(){var t;switch(null===(t=this.type)||void 0===t?void 0:t.toLowerCase()){case"text":return i("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,"client-styling":this.clientStyling});case"email":return i("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,"client-styling":this.clientStyling});case"number":return i("number-input",{name:this.name,displayName:this.displayName,validation:this.validation,defaultValue:this.defaultValue,autofilled:this.autofilled,emitValue:this.emitValue,language:this.language,"client-styling":this.clientStyling});case"checkbox":return i("checkbox-input",{name:this.name,displayName:this.displayName,validation:this.validation,emitValue:this.emitValue,defaultValue:this.defaultValue,autofilled:this.autofilled,language:this.language,"client-styling":this.clientStyling});case"datetime":return i("date-input",{name:this.name,displayName:this.displayName,validation:this.validation,defaultValue:this.defaultValue,autofilled:this.autofilled,emitValue:this.emitValue,language:this.language,"client-styling":this.clientStyling});case"password":return i("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,"client-styling":this.clientStyling});case"radio":return i("radio-input",{name:this.name,displayName:this.displayName,optionsGroup:this.options,validation:this.validation,emitValue:this.emitValue,language:this.language,"client-styling":this.clientStyling});case"tel":return i("tel-input",{name:this.name,action:this.action,displayName:this.displayName,validation:this.validation,defaultValue:this.defaultValue,emitValue:this.emitValue,language:this.language,autofilled:this.autofilled,"client-styling":this.clientStyling});case"dropdown":return i("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,"client-styling":this.clientStyling});default:return i("p",null,"The ",this.type," input type is not valid")}}};jr.style=":host{display:block}";const Rr=["ro","en"],Hr={en:{dateError:"The selected date should be between {min} and {max}",numberLengthError:"The number should be between {min} and {max}",lengthError:"The length should be between {minLength} and {maxLength}",requiredError:"This input is required.",nextButton:"Next",backButton:"Back",doneButton:"Done"},ro:{lengthError:"Cuvântul introdus este prea scurt. {minLength} and {maxLength}",requiredError:"Acest câmp este obligatoriu."}},qr=(t,e,i)=>{const s=e;let o=Hr[void 0!==s&&Rr.includes(s)?s:"en"][t];if(void 0!==i)for(const[t,e]of Object.entries(i.values)){const i=new RegExp(`{${t}}`,"g");o=o.replace(i,e)}return o},Ur=class{constructor(i){t(this,i),this.registrationWidgetLoaded=e(this,"registrationWidgetLoaded",7),this.registrationStepUpdated=e(this,"registrationStepUpdated",7),this.language="en",this.clientStyling="",this.clientStylingUrl="",this.emitValue=!1,this.listOfInputs=[],this.isLoading=!0,this.limitStylingAppends=!1,this.listOfInputValues=[],this.listOfActions=[],this.indexStep=0,this.registrationStepsState={regId:null},this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)},this.setClientStylingURL=()=>{let t=new URL(this.clientStylingUrl),e=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{e.innerHTML=t,this.clientStyling=t,setTimeout((()=>{this.stylingContainer.prepend(e)}),1)}))}}sendStep(){this.registrationStepUpdated.emit(this.registrationStep),window.postMessage({type:"registrationStepUpdated",step:this.registrationStep},window.location.href)}checkInputsValidityHandler(t){this.listOfInputs.find((e=>e.name==t.detail.name)).isValid=t.detail.valid,this.isFormValid=!this.getInvalidStatus(this.listOfInputs)}getInputsValueHandler(t){this.listOfInputValues.find((e=>{e.name==t.detail.name&&(e.value=t.detail.value)})),this.stepsStateMachine({event:"set",type:"values"})}componentWillLoad(){return this.getRegisterConfig().then((t=>{this.formatConfig(t),this.stepsStateMachine({event:"set",type:"inputs"})}))}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL(),this.limitStylingAppends=!0)}componentDidLoad(){this.registrationWidgetLoaded.emit(),window.postMessage({type:"registrationWidgetLoaded"},window.location.href)}nextHandler(t){t.preventDefault(),this.emitValue=!0,this.setRegisterStep()}backHandler(t){t.preventDefault(),this.isLastStep=!1,this.registrationStep=this.stepChange("decrement"),this.stepsStateMachine({event:"get",type:"inputs"}),this.stepsStateMachine({event:"get",type:"values"})}stepsStateMachine(t){switch(t.event){case"set":"inputs"==t.type&&(this.registrationStepsState[this.registrationStep].fields=this.listOfInputs,this.registrationStepsState[this.registrationStep].actions=this.listOfActions),"values"==t.type&&(this.registrationStepsState[this.registrationStep].registerUserData=this.listOfInputValues.reduce(((t,e)=>(t[e.name]={value:e.value,isDuplicate:e.isDuplicate},t)),{})),localStorage.setItem("registrationStepsState",JSON.stringify(this.registrationStepsState));break;case"get":const e=JSON.parse(localStorage.getItem("registrationStepsState"));if(!e)return;if("inputs"==t.type&&(this.listOfInputs=this.registrationStepsState[this.registrationStep].fields,this.listOfActions=this.registrationStepsState[this.registrationStep].actions),"values"==t.type){const t=e[this.registrationStep].registerUserData;this.listOfInputValues=Object.keys(t).map((e=>({name:e,value:t[e].value,isDuplicate:t[e].isDuplicate}))),this.listOfInputValues.forEach((t=>{const e=this.listOfInputs.find((e=>e.name===t.name));e&&(e.defaultValue=t.value,console.log(e))}))}}}getRegisterConfig(t){const e=new URL(`${this.endpoint}/v1/player/legislation/registration/config`),i=new Headers;i.append("Content-Type","application/json"),i.append("Accept","application/json"),t&&e.searchParams.append("registrationId",t);const s={method:"GET",headers:i};return new Promise(((t,i)=>{this.isLoading=!0,fetch(e.href,s).then((t=>t.json())).then((e=>{t(e)})).catch((t=>{console.error(t),i(t)})).finally((()=>{this.isLoading=!1}))}))}setRegisterStep(){this.isLoading=!0;const t=new URL(`${this.endpoint}/v1/player/legislation/registration/step`),e={registrationId:this.registrationID,registerUserDto:this.listOfInputValues.filter((t=>!t.isDuplicate)).reduce(((t,e)=>("Mobile"==e.name?(t.MobilePrefix=e.value.split("|")[0],t[e.name]=e.value.split("|")[1]):t[e.name]=e.value,t)),{}),step:this.registrationStep},i=new Headers;i.append("Content-Type","application/json"),i.append("Accept","application/json");const s={method:"POST",body:JSON.stringify(e),headers:i};fetch(t.href,s).then((t=>{if(t.status>=300)throw new Error("err");return t.json()})).then((t=>{this.registrationID=t.registrationId,this.listOfActions.some((t=>"/register"==t))?this.setRegister():(this.registrationStep=this.stepChange("increment"),Object.keys(this.registrationStepsState).find((t=>t==this.registrationStep))?(this.stepsStateMachine({event:"get",type:"inputs"}),this.stepsStateMachine({event:"get",type:"values"})):this.getRegisterConfig(this.registrationID).then((t=>{this.formatConfig(t),this.stepsStateMachine({event:"set",type:"inputs"})})))})).catch((t=>{console.error(t)})).finally((()=>{this.isLoading=!1}))}setRegister(){this.isLoading=!0;const t=new URL(`${this.endpoint}/v1/player/legislation/register`),e=new Headers;e.append("Content-Type","application/json"),e.append("Accept","application/json");const i={method:"PUT",body:JSON.stringify({registrationId:this.registrationID}),headers:e};fetch(t.href,i).then((t=>{if(t.status>=300)throw new Error("err");return t.json()})).then((t=>{t.userId&&alert(`User registered - the user ID is ${t.userId}`)})).catch((t=>{console.error(t)})).finally((()=>{this.isLoading=!1}))}formatConfig(t){this.listOfInputs=t.content.fields.flatMap((t=>{const e=t.validate.custom.find((t=>"duplicate-input"===t.rule)),i=Object.assign(Object.assign({},t),{isValid:!1});return e?[i,Object.assign(Object.assign({},t),{name:`${t.name}Duplicate`,displayName:e.displayName,isValid:!1,isDuplicateInput:!0})]:[i]})),this.listOfInputValues=this.listOfInputs.map((t=>{var e;return{name:t.name,value:"checkbox"==(null===(e=t.inputType)||void 0===e?void 0:e.toLowerCase())?"false":null,isDuplicate:t.isDuplicateInput||!1}})),this.listOfActions=t.content.actions.map((t=>t)),this.isLastStep=this.listOfActions.some((t=>"/register"==t)),this.registrationID=t.content.registrationID,this.registrationStep=t.content.step,this.registrationStepsState.regId=this.registrationID,this.registrationStepsState[this.registrationStep]||(this.registrationStepsState[this.registrationStep]={fields:[],registerUserData:{},actions:[]})}stepChange(t){const e=parseInt(this.registrationStep.replace("Step",""));return"increment"===t?"Step"+(e+1):"decrement"===t?"Step"+(e-1):void 0}getInvalidStatus(t){return t.filter((t=>0==t.isValid)).length>0}renderInputs(){return this.listOfInputs.map((t=>i("general-input",{type:t.inputType,name:t.name,displayName:t.displayName,validation:t.validate,action:t.action||null,options:t.data?t.data.values:[],defaultValue:t.defaultValue,autofilled:t.autofill,emitValue:this.emitValue,language:this.language,isDuplicateInput:t.isDuplicateInput,"client-styling":this.clientStyling})))}renderButtons(){return i("div",{class:"registration__buttons-wrapper"},i("button",{class:"registration__button registration__button--next",type:"submit",form:"RegistrationForm",onClick:t=>this.nextHandler(t)},qr(this.isLastStep?"doneButton":"nextButton",this.language)),i("button",{class:"registration__button registration__button--back "+("Step1"==this.registrationStep?"registration__button--first-step":""),onClick:t=>this.backHandler(t)},qr("backButton",this.language)))}render(){return this.isLoading?i("p",null,"Please wait, loading ..."):i("div",{class:`registration registration__${this.registrationStep}`,ref:t=>this.stylingContainer=t},i("form",{action:".",id:"RegistrationForm",class:"registration__form"},this.renderInputs()),this.renderButtons())}static get watchers(){return{registrationStep:["sendStep"]}}};Ur.style='*,\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}';const Wr=class{constructor(i){t(this,i),this.sendValidityState=e(this,"sendValidityState",7),this.sendInputValue=e(this,"sendInputValue",7),this.clientStyling="",this.limitStylingAppends=!1,this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}validityChanged(){this.validityStateHandler({valid:this.isValid,name:this.name}),1==this.emitValue&&this.valueHandler({name:this.name,value:this.value})}validityStateHandler(t){this.sendValidityState.emit(t)}emitValueHandler(t){1==t&&this.isValid&&this.valueHandler({name:this.name,value:this.value})}valueHandler(t){this.sendInputValue.emit(t)}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}componentDidLoad(){this.defaultValue&&(this.value=this.defaultValue,this.valueHandler({name:this.name,value:this.value}))}handleInput(t){this.value=t.target.value,this.errorMessage=this.setErrorMessage(),this.isValid=this.setValidity(),this.validityStateHandler({valid:this.isValid,name:this.name}),this.emitValueHandler(!0)}setValidity(){return this.inputReference.validity.valid}setErrorMessage(){return this.inputReference.validity.rangeUnderflow||this.inputReference.validity.rangeOverflow?n("numberLengthError",this.language,{values:{min:this.validation.min,max:this.validation.max}}):this.inputReference.validity.valueMissing?n("requiredError",this.language):void 0}render(){return i("div",{class:"number__wrapper",ref:t=>this.stylingContainer=t},i("input",{ref:t=>this.inputReference=t,type:"number",value:this.defaultValue,readOnly:this.autofilled,id:`${this.name}__input`,class:"number__input "+(1==this.isValid||null==this.isValid?"":"number__input--invalid"),placeholder:`${this.displayName} ${this.validation.mandatory?"*":""}`,required:this.validation.mandatory,max:this.validation.max,min:this.validation.min,onBlur:t=>this.handleInput(t)}),i("label",{class:"number__label "+(this.validation.mandatory?"number__label--required":""),htmlFor:`${this.name}__input`},this.displayName),i("small",{class:"number__error-message"},this.errorMessage))}static get watchers(){return{isValid:["validityChanged"],emitValue:["emitValueHandler"]}}};Wr.style='*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.number{font-family:"Roboto";font-style:normal}.number__wrapper{position:relative;width:100%;padding-top:26px}.number__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.number__label--required::after{content:"*";font-family:inherit;color:#1F1F1F;margin-left:2px}.number__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;-moz-appearance:textfield;}.number__input:focus{outline-color:#3E3E3E}.number__input::-webkit-outer-spin-button,.number__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.number__input--invalid{border:2px solid #cc0000b3}.number__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}',
|
|
2818
|
+
`}get clearElement(){return this.$.clearButton}ready(){super.ready(),this.addController(new Or(this,(t=>{this._setInputElement(t),this._setFocusElement(t),this.stateTarget=t,this.ariaTarget=t}))),this.addController(new Fr(this.inputElement,this._labelController)),this._tooltipController=new ro(this),this.addController(this._tooltipController),this._tooltipController.setPosition("top"),this._tooltipController.setShouldShow((t=>!t.opened)),this.shadowRoot.querySelector('[part="toggle-button"]').addEventListener("mousedown",(t=>t.preventDefault()))}_initOverlay(){super._initOverlay(),this.$.overlay.addEventListener("vaadin-overlay-close",this._onVaadinOverlayClose.bind(this))}_onVaadinOverlayClose(t){t.detail.sourceEvent&&t.detail.sourceEvent.composedPath().includes(this)&&t.preventDefault()}_toggle(t){t.stopPropagation(),this[this._overlayInitialized&&this.$.overlay.opened?"close":"open"]()}_openedChanged(t){super._openedChanged(t),this.$.overlay.positionTarget=this.shadowRoot.querySelector('[part="input-field"]'),this.$.overlay.noVerticalOverlap=!0}}customElements.define(Vr.is,Vr);const $r=class{constructor(i){t(this,i),this.sendValidityState=e(this,"sendValidityState",7),this.sendInputValue=e(this,"sendInputValue",7),this.clientStyling="",this.limitStylingAppends=!1,this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}validityChanged(){this.validityStateHandler({valid:this.isValid,name:this.name}),1==this.emitValue&&this.valueHandler({name:this.name,value:this.value})}validityStateHandler(t){this.sendValidityState.emit(t)}emitValueHandler(t){1==t&&this.isValid&&this.valueHandler({name:this.name,value:this.value})}valueHandler(t){this.sendInputValue.emit(t)}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}componentDidLoad(){this.inputReference=this.element.shadowRoot.querySelector("input"),this.defaultValue&&(this.value=this.defaultValue,this.valueHandler({name:this.name,value:this.value}))}handleInput(t){this.value=t.target.value,this.errorMessage=this.setErrorMessage(),this.isValid=this.setValidity(),this.validityStateHandler({valid:this.isValid,name:this.name}),this.emitValueHandler(!0)}setValidity(){return this.inputReference.validity.valid}setErrorMessage(){return this.inputReference.validity.rangeUnderflow||this.inputReference.validity.rangeOverflow?n("dateError",this.language,{values:{min:this.validation.min,max:this.validation.max}}):this.inputReference.validity.valueMissing?n("requiredError",this.language):void 0}render(){const t=1==this.isValid||null==this.isValid?"":"date__input--invalid";return i("div",{class:"date__wrapper",ref:t=>this.stylingContainer=t},i("label",{class:`date__label ${this.validation.mandatory?"date__label--required":""}}`,htmlFor:`${this.name}__input`},this.displayName," ",this.validation.mandatory?"*":""),i("vaadin-date-picker",{id:`${this.name}__input`,type:"date",class:`date__input ${t}`,value:this.defaultValue,readOnly:this.autofilled,placeholder:`${this.displayName} ${this.validation.mandatory?"*":""}`,required:this.validation.mandatory,max:this.validation.max,min:this.validation.min,onBlur:t=>this.handleInput(t)}),i("small",{class:"date__error-message"},this.errorMessage))}get element(){return s(this)}static get watchers(){return{isValid:["validityChanged"],emitValue:["emitValueHandler"]}}};$r.style='*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.date{font-family:"Roboto";font-style:normal}.date__wrapper{position:relative;width:100%;padding-top:26px}.date__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.date__label--required::after{content:"*";font-family:inherit;color:#1F1F1F;margin-left:2px}.date__input{border:none;width:inherit;position:relative}.date__input[focused]::part(input-field){border-color:#3E3E3E}.date__input[invalid]::part(input-field){border-color:#cc0000b3}.date__input::part(input-field){border-radius:4px;background-color:#FFFFFF;border:2px solid #DEE1EE;color:#2A2E3F;border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px}.date__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}';const Lr=class{constructor(i){t(this,i),this.sendValidityState=e(this,"sendValidityState",7),this.sendInputValue=e(this,"sendInputValue",7),this.clientStyling="",this.limitStylingAppends=!1,this.validationPattern="",this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}validityChanged(){this.validityStateHandler({valid:this.isValid,name:this.name}),1==this.emitValue&&this.valueHandler({name:this.name,value:this.value})}emitValueHandler(t){1==t&&this.isValid&&this.valueHandler({name:this.name,value:this.value})}validityStateHandler(t){this.sendValidityState.emit(t)}valueHandler(t){this.sendInputValue.emit(t)}valueChangedHandler(t){this.isDuplicateInput&&this.name===t.detail.name+"Duplicate"&&(this.duplicateInputValue=t.detail.value)}connectedCallback(){this.validationPattern=this.setPattern()}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}componentDidLoad(){this.defaultValue&&(this.value=this.defaultValue,this.valueHandler({name:this.name,value:this.value}))}handleInput(t){this.value=t.target.value,this.errorMessage=this.setErrorMessage(),this.isValid=this.setValidity(),this.validityStateHandler({valid:this.isValid,name:this.name}),this.emitValueHandler(!0)}setValidity(){return this.inputReference.validity.valid}setPattern(){var t,e;if((null===(t=this.validation.custom)||void 0===t?void 0:t.length)>0)return null===(e=this.validation.custom.find((t=>"regex"===t.rule)))||void 0===e?void 0:e.pattern}setErrorMessage(){var t;return this.inputReference.validity.patternMismatch?null===(t=this.validation.custom.find((t=>"regex"===t.rule)))||void 0===t?void 0:t.errorMessage:this.inputReference.validity.tooShort||this.inputReference.validity.tooLong?n("lengthError",this.language,{values:{minLength:this.validation.minLength,maxLength:this.validation.maxLength}}):this.inputReference.validity.valueMissing?n("requiredError",this.language):this.isDuplicateInput&&this.duplicateInputValue!==this.value?this.validation.custom.find((t=>"duplicate-input"===t.rule)).errorMessage:void 0}render(){return i("div",{class:"email__wrapper",ref:t=>this.stylingContainer=t},i("input",{id:`${this.name}__input`,type:"email",class:"email__input "+(1==this.isValid||null==this.isValid?"":"email__input--invalid"),value:this.defaultValue,readOnly:this.autofilled,placeholder:`${this.displayName} ${this.validation.mandatory?"*":""}`,ref:t=>this.inputReference=t,pattern:this.validationPattern,required:this.validation.mandatory,minlength:this.validation.minLength,maxlength:this.validation.maxLength,onBlur:t=>this.handleInput(t)}),i("label",{class:"email__label "+(this.validation.mandatory?"email__label--required":""),htmlFor:`${this.name}__input`},this.displayName),i("small",{class:"email__error-message"},this.errorMessage))}static get watchers(){return{isValid:["validityChanged"],emitValue:["emitValueHandler"]}}};Lr.style='*,*::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}';const jr=class{constructor(e){t(this,e),this.type="text",this.clientStyling=""}render(){var t;switch(null===(t=this.type)||void 0===t?void 0:t.toLowerCase()){case"text":return i("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,"client-styling":this.clientStyling});case"email":return i("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,"client-styling":this.clientStyling});case"number":return i("number-input",{name:this.name,displayName:this.displayName,validation:this.validation,defaultValue:this.defaultValue,autofilled:this.autofilled,emitValue:this.emitValue,language:this.language,"client-styling":this.clientStyling});case"checkbox":return i("checkbox-input",{name:this.name,displayName:this.displayName,validation:this.validation,emitValue:this.emitValue,defaultValue:this.defaultValue,autofilled:this.autofilled,language:this.language,"client-styling":this.clientStyling});case"datetime":return i("date-input",{name:this.name,displayName:this.displayName,validation:this.validation,defaultValue:this.defaultValue,autofilled:this.autofilled,emitValue:this.emitValue,language:this.language,"client-styling":this.clientStyling});case"password":return i("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,"client-styling":this.clientStyling});case"radio":return i("radio-input",{name:this.name,displayName:this.displayName,optionsGroup:this.options,validation:this.validation,emitValue:this.emitValue,language:this.language,"client-styling":this.clientStyling});case"tel":return i("tel-input",{name:this.name,action:this.action,displayName:this.displayName,validation:this.validation,defaultValue:this.defaultValue,emitValue:this.emitValue,language:this.language,autofilled:this.autofilled,"client-styling":this.clientStyling});case"dropdown":return i("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,"client-styling":this.clientStyling});default:return i("p",null,"The ",this.type," input type is not valid")}}};jr.style=":host{display:block}";const Rr=["ro","en"],Hr={en:{dateError:"The selected date should be between {min} and {max}",numberLengthError:"The number should be between {min} and {max}",lengthError:"The length should be between {minLength} and {maxLength}",requiredError:"This input is required.",nextButton:"Next",backButton:"Back",doneButton:"Done"},ro:{lengthError:"Cuvântul introdus este prea scurt. {minLength} and {maxLength}",requiredError:"Acest câmp este obligatoriu."}},qr=(t,e,i)=>{const s=e;let o=Hr[void 0!==s&&Rr.includes(s)?s:"en"][t];if(void 0!==i)for(const[t,e]of Object.entries(i.values)){const i=new RegExp(`{${t}}`,"g");o=o.replace(i,e)}return o},Ur=class{constructor(i){t(this,i),this.registrationWidgetLoaded=e(this,"registrationWidgetLoaded",7),this.registrationStepUpdated=e(this,"registrationStepUpdated",7),this.language="en",this.clientStyling="",this.clientStylingUrl="",this.translationsUrl="",this.listOfInputs=[],this.isLoading=!0,this.listOfInputValues=[],this.listOfActions=[],this.indexStep=0,this.emitValue=!1,this.registrationStepsState={regId:null},this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)},this.setClientStylingURL=()=>{let t=new URL(this.clientStylingUrl),e=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{e.innerHTML=t,this.clientStyling=t,setTimeout((()=>{this.stylingContainer.prepend(e)}),1)}))}}sendStep(){this.registrationStepUpdated.emit(this.registrationStep),window.postMessage({type:"registrationStepUpdated",step:this.registrationStep},window.location.href)}setFormValidity(){this.isFormValid=!this.getInvalidStatus(this.listOfInputs)}checkInputsValidityHandler(t){this.listOfInputs.find((e=>e.name==t.detail.name)).isValid=t.detail.valid,this.isFormValid=!this.getInvalidStatus(this.listOfInputs)}getInputsValueHandler(t){this.listOfInputValues.find((e=>{e.name==t.detail.name&&(e.value=t.detail.value)})),this.stepsStateMachine({event:"set",type:"values"})}componentWillLoad(){return this.getRegisterConfig().then((t=>{this.formatConfig(t),this.stepsStateMachine({event:"set",type:"inputs"})}))}componentDidRender(){this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL())}componentDidLoad(){this.registrationWidgetLoaded.emit(),window.postMessage({type:"registrationWidgetLoaded"},window.location.href)}nextHandler(t){t.preventDefault(),this.emitValue=!0,this.setRegisterStep()}backHandler(t){t.preventDefault(),this.isLastStep=!1,this.registrationStep=this.stepChange("decrement"),this.stepsStateMachine({event:"get",type:"inputs"}),this.stepsStateMachine({event:"get",type:"values"})}stepsStateMachine(t){switch(t.event){case"set":"inputs"==t.type&&(this.registrationStepsState[this.registrationStep].fields=this.listOfInputs,this.registrationStepsState[this.registrationStep].actions=this.listOfActions),"values"==t.type&&(this.registrationStepsState[this.registrationStep].registerUserData=this.listOfInputValues.reduce(((t,e)=>(t[e.name]={value:e.value,isDuplicate:e.isDuplicate},t)),{})),localStorage.setItem("registrationStepsState",JSON.stringify(this.registrationStepsState));break;case"get":const e=JSON.parse(localStorage.getItem("registrationStepsState"));if(!e)return;if("inputs"==t.type&&(this.listOfInputs=this.registrationStepsState[this.registrationStep].fields,this.listOfActions=this.registrationStepsState[this.registrationStep].actions),"values"==t.type){const t=e[this.registrationStep].registerUserData;console.log(t),this.listOfInputValues=Object.keys(t).map((e=>({name:e,value:t[e].value,isDuplicate:t[e].isDuplicate}))),this.listOfInputValues.forEach((t=>{const e=this.listOfInputs.find((e=>e.name===t.name));e&&(e.defaultValue=t.value)}))}}}getRegisterConfig(t){const e=new URL(`${this.endpoint}/v1/player/legislation/registration/config`),i=new Headers;i.append("Content-Type","application/json"),i.append("Accept","application/json"),t&&e.searchParams.append("registrationId",t);const s={method:"GET",headers:i};return new Promise(((t,i)=>{this.isLoading=!0,fetch(e.href,s).then((t=>t.json())).then((e=>{t(e)})).catch((t=>{console.error(t),i(t)})).finally((()=>{this.isLoading=!1}))}))}setRegisterStep(){this.isLoading=!0;const t=new URL(`${this.endpoint}/v1/player/legislation/registration/step`),e={registrationId:this.registrationID,registerUserDto:this.listOfInputValues.filter((t=>!t.isDuplicate)).reduce(((t,e)=>("Mobile"==e.name?(t.MobilePrefix=e.value.split("|")[0],t[e.name]=e.value.split("|")[1]):t[e.name]=e.value,t)),{}),step:this.registrationStep},i=new Headers;i.append("Content-Type","application/json"),i.append("Accept","application/json");const s={method:"POST",body:JSON.stringify(e),headers:i};fetch(t.href,s).then((t=>{if(t.status>=300)throw new Error("err");return t.json()})).then((t=>{this.registrationID=t.registrationId,this.listOfActions.some((t=>"/register"==t))?this.setRegister():(this.registrationStep=this.stepChange("increment"),Object.keys(this.registrationStepsState).find((t=>t==this.registrationStep))?(this.stepsStateMachine({event:"get",type:"inputs"}),this.stepsStateMachine({event:"get",type:"values"})):this.getRegisterConfig(this.registrationID).then((t=>{this.formatConfig(t),this.stepsStateMachine({event:"set",type:"inputs"})})))})).catch((t=>{console.error(t)})).finally((()=>{this.isLoading=!1}))}setRegister(){this.isLoading=!0;const t=new URL(`${this.endpoint}/v1/player/legislation/register`),e=new Headers;e.append("Content-Type","application/json"),e.append("Accept","application/json");const i={method:"PUT",body:JSON.stringify({registrationId:this.registrationID}),headers:e};fetch(t.href,i).then((t=>{if(t.status>=300)throw new Error("err");return t.json()})).then((t=>{t.userId&&alert(`User registered - the user ID is ${t.userId}`),window.postMessage({type:"registrationSuccessful"},window.location.href)})).catch((t=>{console.error(t)})).finally((()=>{this.isLoading=!1}))}formatConfig(t){this.listOfInputs=t.content.fields.flatMap((t=>{const e=t.validate.custom.find((t=>"duplicate-input"===t.rule)),i=Object.assign(Object.assign({},t),{isValid:this.setInitialValidStatus(t)});return e?[i,Object.assign(Object.assign({},t),{name:`${t.name}Duplicate`,displayName:e.displayName,isValid:!1,isDuplicateInput:!0})]:[i]})),this.listOfInputValues=this.listOfInputs.map((t=>{var e;return{name:t.name,value:"checkbox"==(null===(e=t.inputType)||void 0===e?void 0:e.toLowerCase())?"false":null,isDuplicate:t.isDuplicateInput||!1}})),this.listOfActions=t.content.actions.map((t=>t)),this.isLastStep=this.listOfActions.some((t=>"/register"==t)),this.registrationID=t.content.registrationID,this.registrationStep=t.content.step,this.registrationStepsState.regId=this.registrationID,this.registrationStepsState[this.registrationStep]||(this.registrationStepsState[this.registrationStep]={fields:[],registerUserData:{},actions:[]})}setInitialValidStatus(t){var e,i;return"checkbox"==(null===(e=t.inputType)||void 0===e?void 0:e.toLowerCase())&&0==(null===(i=t.validate)||void 0===i?void 0:i.mandatory)||null!==t.defaultValue}stepChange(t){const e=parseInt(this.registrationStep.replace("Step",""));return"increment"===t?"Step"+(e+1):"decrement"===t?"Step"+(e-1):void 0}getInvalidStatus(t){return t.filter((t=>0==t.isValid)).length>0}renderInputs(){return this.listOfInputs.map((t=>i("general-input",{type:t.inputType,name:t.name,displayName:t.displayName,validation:t.validate,action:t.action||null,options:t.data?t.data.values:[],defaultValue:t.defaultValue,autofilled:t.autofill,emitValue:this.emitValue,language:this.language,isDuplicateInput:t.isDuplicateInput,"client-styling":this.clientStyling})))}renderButtons(){return i("div",{class:"registration__buttons-wrapper"},i("button",{class:"registration__button registration__button--next "+(this.isFormValid?"":"registration__button--disabled"),type:"submit",form:"RegistrationForm",onClick:t=>this.nextHandler(t),disabled:!this.isFormValid},qr(this.isLastStep?"doneButton":"nextButton",this.language)),i("button",{class:"registration__button registration__button--back "+("Step1"==this.registrationStep?"registration__button--first-step":""),onClick:t=>this.backHandler(t)},qr("backButton",this.language)))}render(){return this.isLoading?i("p",null,"Please wait, loading ..."):i("div",{class:`registration registration__${this.registrationStep}`,ref:t=>this.stylingContainer=t},i("form",{action:".",id:"RegistrationForm",class:"registration__form"},this.renderInputs()),this.renderButtons())}static get watchers(){return{registrationStep:["sendStep"],listOfInputs:["setFormValidity"]}}};Ur.style='*,\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--disabled {\n opacity: 0.5;\n}\n.registration__button--disabled:hover {\n opacity: 0.5;\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}';const Wr=class{constructor(i){t(this,i),this.sendValidityState=e(this,"sendValidityState",7),this.sendInputValue=e(this,"sendInputValue",7),this.clientStyling="",this.limitStylingAppends=!1,this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}validityChanged(){this.validityStateHandler({valid:this.isValid,name:this.name}),1==this.emitValue&&this.valueHandler({name:this.name,value:this.value})}validityStateHandler(t){this.sendValidityState.emit(t)}emitValueHandler(t){1==t&&this.isValid&&this.valueHandler({name:this.name,value:this.value})}valueHandler(t){this.sendInputValue.emit(t)}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}componentDidLoad(){this.defaultValue&&(this.value=this.defaultValue,this.valueHandler({name:this.name,value:this.value}))}handleInput(t){this.value=t.target.value,this.errorMessage=this.setErrorMessage(),this.isValid=this.setValidity(),this.validityStateHandler({valid:this.isValid,name:this.name}),this.emitValueHandler(!0)}setValidity(){return this.inputReference.validity.valid}setErrorMessage(){return this.inputReference.validity.rangeUnderflow||this.inputReference.validity.rangeOverflow?n("numberLengthError",this.language,{values:{min:this.validation.min,max:this.validation.max}}):this.inputReference.validity.valueMissing?n("requiredError",this.language):void 0}render(){return i("div",{class:"number__wrapper",ref:t=>this.stylingContainer=t},i("input",{ref:t=>this.inputReference=t,type:"number",value:this.defaultValue,readOnly:this.autofilled,id:`${this.name}__input`,class:"number__input "+(1==this.isValid||null==this.isValid?"":"number__input--invalid"),placeholder:`${this.displayName} ${this.validation.mandatory?"*":""}`,required:this.validation.mandatory,max:this.validation.max,min:this.validation.min,onBlur:t=>this.handleInput(t)}),i("label",{class:"number__label "+(this.validation.mandatory?"number__label--required":""),htmlFor:`${this.name}__input`},this.displayName),i("small",{class:"number__error-message"},this.errorMessage))}static get watchers(){return{isValid:["validityChanged"],emitValue:["emitValueHandler"]}}};Wr.style='*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.number{font-family:"Roboto";font-style:normal}.number__wrapper{position:relative;width:100%;padding-top:26px}.number__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.number__label--required::after{content:"*";font-family:inherit;color:#1F1F1F;margin-left:2px}.number__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;-moz-appearance:textfield;}.number__input:focus{outline-color:#3E3E3E}.number__input::-webkit-outer-spin-button,.number__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.number__input--invalid{border:2px solid #cc0000b3}.number__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}',
|
|
2819
2819
|
/**
|
|
2820
2820
|
* @license
|
|
2821
2821
|
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from '../../stencil-public-runtime';
|
|
2
|
-
import type { InputStateEvent, InputValueEvent, RegistrationConfig, StepState, InputValue } from '../../../../general-input/src/utils/types';
|
|
2
|
+
import type { InputStateEvent, InputValueEvent, RegistrationConfig, RegCfgContentField, StepState, InputValue } from '../../../../general-input/src/utils/types';
|
|
3
3
|
import '@everymatrix/general-input';
|
|
4
4
|
export declare class GeneralRegistration {
|
|
5
5
|
/**
|
|
@@ -18,19 +18,23 @@ export declare class GeneralRegistration {
|
|
|
18
18
|
* Client custom styling via url
|
|
19
19
|
*/
|
|
20
20
|
clientStylingUrl: string;
|
|
21
|
+
/**
|
|
22
|
+
* Translations via URL
|
|
23
|
+
*/
|
|
24
|
+
translationsUrl: string;
|
|
21
25
|
errorMessage: string;
|
|
22
|
-
emitValue: boolean;
|
|
23
26
|
isFormValid: boolean;
|
|
24
27
|
listOfInputs: any[];
|
|
25
28
|
isLoading: boolean;
|
|
26
|
-
limitStylingAppends: boolean;
|
|
27
29
|
registrationStep: string;
|
|
28
30
|
sendStep(): void;
|
|
31
|
+
setFormValidity(): void;
|
|
29
32
|
private registrationID;
|
|
30
33
|
listOfInputValues: InputValue[];
|
|
31
34
|
listOfActions: any[];
|
|
32
35
|
indexStep: number;
|
|
33
36
|
isLastStep: boolean;
|
|
37
|
+
emitValue: boolean;
|
|
34
38
|
stylingContainer: HTMLElement;
|
|
35
39
|
registrationStepsState: {
|
|
36
40
|
regId: any;
|
|
@@ -49,6 +53,7 @@ export declare class GeneralRegistration {
|
|
|
49
53
|
setRegisterStep(): void;
|
|
50
54
|
setRegister(): void;
|
|
51
55
|
formatConfig(config: RegistrationConfig): void;
|
|
56
|
+
setInitialValidStatus(field: RegCfgContentField): boolean;
|
|
52
57
|
stepChange(action: any): string;
|
|
53
58
|
getInvalidStatus(listOfInputs: any): boolean;
|
|
54
59
|
setClientStyling: () => void;
|
|
@@ -23,6 +23,10 @@ export namespace Components {
|
|
|
23
23
|
* Currently selected language
|
|
24
24
|
*/
|
|
25
25
|
"language": string;
|
|
26
|
+
/**
|
|
27
|
+
* Translations via URL
|
|
28
|
+
*/
|
|
29
|
+
"translationsUrl": string;
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
32
|
declare global {
|
|
@@ -56,6 +60,10 @@ declare namespace LocalJSX {
|
|
|
56
60
|
"language"?: string;
|
|
57
61
|
"onRegistrationStepUpdated"?: (event: CustomEvent<string>) => void;
|
|
58
62
|
"onRegistrationWidgetLoaded"?: (event: CustomEvent<any>) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Translations via URL
|
|
65
|
+
*/
|
|
66
|
+
"translationsUrl"?: string;
|
|
59
67
|
}
|
|
60
68
|
interface IntrinsicElements {
|
|
61
69
|
"general-registration": GeneralRegistration;
|