@everymatrix/general-registration 1.10.4 → 1.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/checkbox-input_11.cjs.entry.js +1118 -487
- package/dist/cjs/general-registration.cjs.js +2 -2
- package/dist/cjs/{index-9a07d1e9.js → index-68f93e1e.js} +9 -5
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/general-registration/general-registration.css +40 -14
- package/dist/collection/components/general-registration/general-registration.js +153 -300
- package/dist/components/checkbox-input2.js +8 -2
- package/dist/components/date-input2.js +19 -1441
- package/dist/components/email-input2.js +28 -9
- package/dist/components/general-input2.js +6 -6
- package/dist/components/general-registration.js +112 -274
- package/dist/components/input-field-shared-styles.js +13776 -0
- package/dist/components/locale.utils.js +1 -1
- package/dist/components/number-input2.js +8 -2
- package/dist/components/password-input2.js +748 -9
- package/dist/components/pattern-mixin.js +84 -0
- package/dist/components/radio-input2.js +1 -1
- package/dist/components/select-input2.js +8 -4
- package/dist/components/tel-input2.js +22 -10
- package/dist/components/text-input2.js +27 -18
- package/dist/components/vaadin-button.js +1432 -0
- package/dist/components/vaadin-combo-box.js +3 -82
- package/dist/components/virtual-keyboard-controller.js +2136 -15909
- package/dist/esm/checkbox-input_11.entry.js +1118 -487
- package/dist/esm/general-registration.js +2 -2
- package/dist/esm/{index-0505440f.js → index-16916adb.js} +9 -5
- package/dist/esm/loader.js +2 -2
- package/dist/general-registration/general-registration.esm.js +1 -1
- package/dist/general-registration/p-8f644809.js +1 -0
- package/dist/general-registration/{p-6a27a1e0.entry.js → p-fb5bf415.entry.js} +210 -100
- package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/types.d.ts +6 -4
- package/dist/types/components/general-registration/general-registration.d.ts +20 -284
- package/dist/types/components.d.ts +11 -17
- package/package.json +3 -2
- package/dist/general-registration/p-1a88a312.js +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h as h$2, g as getElement } from './index-
|
|
1
|
+
import { r as registerInstance, c as createEvent, h as h$2, g as getElement } from './index-16916adb.js';
|
|
2
2
|
|
|
3
3
|
const DEFAULT_LANGUAGE$1 = 'en';
|
|
4
4
|
const SUPPORTED_LANGUAGES$1 = ['ro', 'en'];
|
|
5
5
|
const TRANSLATIONS$1 = {
|
|
6
6
|
en: {
|
|
7
7
|
dateError: 'The selected date should be between {min} and {max}',
|
|
8
|
-
numberLengthError: 'The number should be between
|
|
8
|
+
numberLengthError: 'The number should be between {min} and {max}',
|
|
9
9
|
lengthError: `The length should be between {minLength} and {maxLength}`,
|
|
10
10
|
requiredError: 'This input is required.',
|
|
11
11
|
nextButton: 'Next',
|
|
@@ -29,7 +29,7 @@ const translate$2 = (key, customLang, values) => {
|
|
|
29
29
|
return translation;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
const checkboxInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.checkbox__wrapper{display:flex;gap:10px;position:relative;align-items:baseline}.checkbox__error-message{position:absolute;top:calc(100% + 5px);left:0;color
|
|
32
|
+
const checkboxInputCss = "*,*::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}";
|
|
33
33
|
|
|
34
34
|
const CheckboxInput = class {
|
|
35
35
|
constructor(hostRef) {
|
|
@@ -58,6 +58,12 @@ const CheckboxInput = class {
|
|
|
58
58
|
valueHandler(inputValueEvent) {
|
|
59
59
|
this.sendInputValue.emit(inputValueEvent);
|
|
60
60
|
}
|
|
61
|
+
componentDidLoad() {
|
|
62
|
+
if (this.defaultValue) {
|
|
63
|
+
this.value = this.defaultValue;
|
|
64
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
61
67
|
handleClick() {
|
|
62
68
|
this.value = this.inputReference.checked.toString();
|
|
63
69
|
this.errorMessage = this.setErrorMessage();
|
|
@@ -74,7 +80,7 @@ const CheckboxInput = class {
|
|
|
74
80
|
}
|
|
75
81
|
}
|
|
76
82
|
render() {
|
|
77
|
-
return h$2("div", { class: 'checkbox__wrapper' }, h$2("input", { type: "checkbox", id: `${this.name}__input`, ref: (el) => this.inputReference = el, name: this.name, checked: !!this.defaultValue, readOnly: this.autofilled, required: this.validation.mandatory, value: this.value, onClick: () => this.handleClick() }), h$2("label", { htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), h$2("small", { class: 'checkbox__error-message' }, this.errorMessage));
|
|
83
|
+
return h$2("div", { class: 'checkbox__wrapper' }, h$2("input", { type: "checkbox", id: `${this.name}__input`, ref: (el) => this.inputReference = el, name: this.name, checked: !!this.defaultValue, 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));
|
|
78
84
|
}
|
|
79
85
|
static get watchers() { return {
|
|
80
86
|
"isValid": ["validityChanged"],
|
|
@@ -97,7 +103,7 @@ CheckboxInput.style = checkboxInputCss;
|
|
|
97
103
|
*/
|
|
98
104
|
class Lumo extends HTMLElement {
|
|
99
105
|
static get version() {
|
|
100
|
-
return '23.3.
|
|
106
|
+
return '23.3.14';
|
|
101
107
|
}
|
|
102
108
|
}
|
|
103
109
|
|
|
@@ -12970,7 +12976,7 @@ const registered = new Set();
|
|
|
12970
12976
|
const ElementMixin = (superClass) =>
|
|
12971
12977
|
class VaadinElementMixin extends DirMixin(superClass) {
|
|
12972
12978
|
static get version() {
|
|
12973
|
-
return '23.3.
|
|
12979
|
+
return '23.3.14';
|
|
12974
12980
|
}
|
|
12975
12981
|
|
|
12976
12982
|
/** @protected */
|
|
@@ -16268,7 +16274,7 @@ registerStyles('vaadin-date-picker-overlay', datePickerOverlayStyles, {
|
|
|
16268
16274
|
moduleId: 'vaadin-date-picker-overlay-styles',
|
|
16269
16275
|
});
|
|
16270
16276
|
|
|
16271
|
-
let memoizedTemplate$
|
|
16277
|
+
let memoizedTemplate$2;
|
|
16272
16278
|
|
|
16273
16279
|
/**
|
|
16274
16280
|
* An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
|
|
@@ -16282,12 +16288,12 @@ class DatePickerOverlay extends DisableUpgradeMixin(PositionMixin(Overlay)) {
|
|
|
16282
16288
|
}
|
|
16283
16289
|
|
|
16284
16290
|
static get template() {
|
|
16285
|
-
if (!memoizedTemplate$
|
|
16286
|
-
memoizedTemplate$
|
|
16287
|
-
memoizedTemplate$
|
|
16291
|
+
if (!memoizedTemplate$2) {
|
|
16292
|
+
memoizedTemplate$2 = super.template.cloneNode(true);
|
|
16293
|
+
memoizedTemplate$2.content.querySelector('[part~="overlay"]').removeAttribute('tabindex');
|
|
16288
16294
|
}
|
|
16289
16295
|
|
|
16290
|
-
return memoizedTemplate$
|
|
16296
|
+
return memoizedTemplate$2;
|
|
16291
16297
|
}
|
|
16292
16298
|
}
|
|
16293
16299
|
|
|
@@ -23025,7 +23031,7 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
|
|
|
23025
23031
|
|
|
23026
23032
|
customElements.define(DatePicker.is, DatePicker);
|
|
23027
23033
|
|
|
23028
|
-
const dateInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.date__wrapper{position:relative;
|
|
23034
|
+
const dateInputCss = "*,*::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}";
|
|
23029
23035
|
|
|
23030
23036
|
const DateInput = class {
|
|
23031
23037
|
constructor(hostRef) {
|
|
@@ -23052,6 +23058,10 @@ const DateInput = class {
|
|
|
23052
23058
|
}
|
|
23053
23059
|
componentDidLoad() {
|
|
23054
23060
|
this.inputReference = this.element.shadowRoot.querySelector('input');
|
|
23061
|
+
if (this.defaultValue) {
|
|
23062
|
+
this.value = this.defaultValue;
|
|
23063
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
23064
|
+
}
|
|
23055
23065
|
}
|
|
23056
23066
|
handleInput(event) {
|
|
23057
23067
|
this.value = event.target.value;
|
|
@@ -23072,7 +23082,8 @@ const DateInput = class {
|
|
|
23072
23082
|
}
|
|
23073
23083
|
}
|
|
23074
23084
|
render() {
|
|
23075
|
-
|
|
23085
|
+
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'date__input--invalid';
|
|
23086
|
+
return h$2("div", { class: 'date__wrapper' }, h$2("label", { class: `date__label ${this.validation.mandatory ? 'date__label--required' : ''}}`, htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), h$2("vaadin-date-picker", { id: `${this.name}__input`, type: 'date', class: `date__input ${invalidClass}`, 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: (e) => this.handleInput(e) }), h$2("small", { class: 'date__error-message' }, this.errorMessage));
|
|
23076
23087
|
}
|
|
23077
23088
|
get element() { return getElement(this); }
|
|
23078
23089
|
static get watchers() { return {
|
|
@@ -23082,7 +23093,7 @@ const DateInput = class {
|
|
|
23082
23093
|
};
|
|
23083
23094
|
DateInput.style = dateInputCss;
|
|
23084
23095
|
|
|
23085
|
-
const emailInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.email__wrapper{position:relative;
|
|
23096
|
+
const emailInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.email{font-family:\"Roboto\";font-style:normal}.email__wrapper{position:relative;width:100%;padding-top:26px}.email__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.email__label--required::after{content:\"*\";font-family:inherit;color:#1F1F1F;margin-left:2px}.email__input{border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px;color:#2A2E3F;padding:8px 20px;width:inherit;position:relative;border:2px solid #DEE1EE}.email__input:focus{outline-color:#3E3E3E}.email__input--invalid{border:2px solid #cc0000b3}.email__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}";
|
|
23086
23097
|
|
|
23087
23098
|
const EmailInput = class {
|
|
23088
23099
|
constructor(hostRef) {
|
|
@@ -23097,20 +23108,33 @@ const EmailInput = class {
|
|
|
23097
23108
|
this.valueHandler({ name: this.name, value: this.value });
|
|
23098
23109
|
}
|
|
23099
23110
|
}
|
|
23100
|
-
validityStateHandler(inputStateEvent) {
|
|
23101
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
23102
|
-
}
|
|
23103
23111
|
emitValueHandler(newValue) {
|
|
23104
23112
|
if (newValue == true && this.isValid) {
|
|
23105
23113
|
this.valueHandler({ name: this.name, value: this.value });
|
|
23106
23114
|
}
|
|
23107
23115
|
}
|
|
23116
|
+
validityStateHandler(inputStateEvent) {
|
|
23117
|
+
this.sendValidityState.emit(inputStateEvent);
|
|
23118
|
+
}
|
|
23108
23119
|
valueHandler(inputValueEvent) {
|
|
23109
23120
|
this.sendInputValue.emit(inputValueEvent);
|
|
23110
23121
|
}
|
|
23122
|
+
valueChangedHandler(event) {
|
|
23123
|
+
if (this.isDuplicateInput) {
|
|
23124
|
+
if (this.name === event.detail.name + 'Duplicate') {
|
|
23125
|
+
this.duplicateInputValue = event.detail.value;
|
|
23126
|
+
}
|
|
23127
|
+
}
|
|
23128
|
+
}
|
|
23111
23129
|
connectedCallback() {
|
|
23112
23130
|
this.validationPattern = this.setPattern();
|
|
23113
23131
|
}
|
|
23132
|
+
componentDidLoad() {
|
|
23133
|
+
if (this.defaultValue) {
|
|
23134
|
+
this.value = this.defaultValue;
|
|
23135
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
23136
|
+
}
|
|
23137
|
+
}
|
|
23114
23138
|
handleInput(event) {
|
|
23115
23139
|
this.value = event.target.value;
|
|
23116
23140
|
this.errorMessage = this.setErrorMessage();
|
|
@@ -23122,14 +23146,15 @@ const EmailInput = class {
|
|
|
23122
23146
|
return this.inputReference.validity.valid;
|
|
23123
23147
|
}
|
|
23124
23148
|
setPattern() {
|
|
23125
|
-
var _a;
|
|
23149
|
+
var _a, _b;
|
|
23126
23150
|
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
23127
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
|
|
23151
|
+
return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
|
|
23128
23152
|
}
|
|
23129
23153
|
}
|
|
23130
23154
|
setErrorMessage() {
|
|
23155
|
+
var _a;
|
|
23131
23156
|
if (this.inputReference.validity.patternMismatch) {
|
|
23132
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
|
|
23157
|
+
return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
|
|
23133
23158
|
}
|
|
23134
23159
|
if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
|
|
23135
23160
|
return translate$2('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
|
|
@@ -23137,9 +23162,13 @@ const EmailInput = class {
|
|
|
23137
23162
|
if (this.inputReference.validity.valueMissing) {
|
|
23138
23163
|
return translate$2('requiredError', this.language);
|
|
23139
23164
|
}
|
|
23165
|
+
if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
|
|
23166
|
+
return this.validation.custom.find(customRule => customRule.rule === 'duplicate-input').errorMessage;
|
|
23167
|
+
}
|
|
23140
23168
|
}
|
|
23141
23169
|
render() {
|
|
23142
|
-
|
|
23170
|
+
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'email__input--invalid';
|
|
23171
|
+
return h$2("div", { class: 'email__wrapper' }, h$2("input", { id: `${this.name}__input`, type: 'email', class: `email__input ${invalidClass}`, value: this.defaultValue, readOnly: this.autofilled, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onBlur: (e) => this.handleInput(e) }), h$2("label", { class: `email__label ${this.validation.mandatory ? 'email__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h$2("small", { class: 'email__error-message' }, this.errorMessage));
|
|
23143
23172
|
}
|
|
23144
23173
|
static get watchers() { return {
|
|
23145
23174
|
"isValid": ["validityChanged"],
|
|
@@ -23161,9 +23190,9 @@ const GeneralInput = class {
|
|
|
23161
23190
|
render() {
|
|
23162
23191
|
switch (this.type.toLowerCase()) {
|
|
23163
23192
|
case 'text':
|
|
23164
|
-
return h$2("text-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
23193
|
+
return h$2("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 });
|
|
23165
23194
|
case 'email':
|
|
23166
|
-
return h$2("email-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
23195
|
+
return h$2("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 });
|
|
23167
23196
|
case 'number':
|
|
23168
23197
|
return h$2("number-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
23169
23198
|
case 'checkbox':
|
|
@@ -23171,7 +23200,7 @@ const GeneralInput = class {
|
|
|
23171
23200
|
case 'datetime':
|
|
23172
23201
|
return h$2("date-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
23173
23202
|
case 'password':
|
|
23174
|
-
return h$2("password-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
23203
|
+
return h$2("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 });
|
|
23175
23204
|
case 'radio':
|
|
23176
23205
|
return h$2("radio-input", { name: this.name, displayName: this.displayName, optionsGroup: this.options, validation: this.validation, emitValue: this.emitValue, language: this.language });
|
|
23177
23206
|
case 'tel':
|
|
@@ -23179,7 +23208,6 @@ const GeneralInput = class {
|
|
|
23179
23208
|
case 'dropdown':
|
|
23180
23209
|
return h$2("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 });
|
|
23181
23210
|
default:
|
|
23182
|
-
// Nothing here
|
|
23183
23211
|
return h$2("p", null, "The ", this.type, " input type is not valid");
|
|
23184
23212
|
}
|
|
23185
23213
|
}
|
|
@@ -23191,7 +23219,7 @@ const SUPPORTED_LANGUAGES = ['ro', 'en'];
|
|
|
23191
23219
|
const TRANSLATIONS = {
|
|
23192
23220
|
en: {
|
|
23193
23221
|
dateError: 'The selected date should be between {min} and {max}',
|
|
23194
|
-
numberLengthError: 'The number should be between
|
|
23222
|
+
numberLengthError: 'The number should be between {min} and {max}',
|
|
23195
23223
|
lengthError: `The length should be between {minLength} and {maxLength}`,
|
|
23196
23224
|
requiredError: 'This input is required.',
|
|
23197
23225
|
nextButton: 'Next',
|
|
@@ -23215,238 +23243,54 @@ const translate = (key, customLang, values) => {
|
|
|
23215
23243
|
return translation;
|
|
23216
23244
|
};
|
|
23217
23245
|
|
|
23218
|
-
const generalRegistrationCss = "
|
|
23246
|
+
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}";
|
|
23219
23247
|
|
|
23220
23248
|
const GeneralRegistration = class {
|
|
23221
23249
|
constructor(hostRef) {
|
|
23222
23250
|
registerInstance(this, hostRef);
|
|
23223
|
-
this.
|
|
23224
|
-
|
|
23225
|
-
"content": {
|
|
23226
|
-
"step": "step1",
|
|
23227
|
-
"fields": [
|
|
23228
|
-
{
|
|
23229
|
-
"name": "firstName",
|
|
23230
|
-
"displayName": "Username",
|
|
23231
|
-
"defaultValue": null,
|
|
23232
|
-
"validate": {
|
|
23233
|
-
"mandatory": true,
|
|
23234
|
-
"minLength": 3,
|
|
23235
|
-
"maxLength": 20
|
|
23236
|
-
},
|
|
23237
|
-
"autofill": false
|
|
23238
|
-
},
|
|
23239
|
-
{
|
|
23240
|
-
"name": "lastName",
|
|
23241
|
-
"displayName": "Last name",
|
|
23242
|
-
"defaultValue": null,
|
|
23243
|
-
"validate": {
|
|
23244
|
-
"mandatory": true,
|
|
23245
|
-
"minLength": 3,
|
|
23246
|
-
"maxLength": 20
|
|
23247
|
-
},
|
|
23248
|
-
},
|
|
23249
|
-
{
|
|
23250
|
-
"name": "telephone",
|
|
23251
|
-
"displayName": "Telephone",
|
|
23252
|
-
"action": "GET https://demo-api.stage.norway.everymatrix.com/v1/player/phonecodes",
|
|
23253
|
-
"defaultValue": null,
|
|
23254
|
-
"validate": {
|
|
23255
|
-
"mandatory": true
|
|
23256
|
-
},
|
|
23257
|
-
"autofill": false,
|
|
23258
|
-
"inputType": "tel"
|
|
23259
|
-
},
|
|
23260
|
-
{
|
|
23261
|
-
"name": "dateOfBirth",
|
|
23262
|
-
"displayName": "Date of Birth",
|
|
23263
|
-
"defaultValue": null,
|
|
23264
|
-
"validate": {
|
|
23265
|
-
"min": "2022-05-01",
|
|
23266
|
-
"max": "2022-05-29",
|
|
23267
|
-
"mandatory": true,
|
|
23268
|
-
},
|
|
23269
|
-
"inputType": "datetime"
|
|
23270
|
-
},
|
|
23271
|
-
{
|
|
23272
|
-
"name": "email",
|
|
23273
|
-
"displayName": "Email",
|
|
23274
|
-
"defaultValue": 'a@a.com',
|
|
23275
|
-
"validate": {
|
|
23276
|
-
"mandatory": true,
|
|
23277
|
-
"custom": [
|
|
23278
|
-
{
|
|
23279
|
-
"rule": "regex",
|
|
23280
|
-
"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
23281
|
-
"errorMessage": "Please enter a valid email address"
|
|
23282
|
-
}
|
|
23283
|
-
]
|
|
23284
|
-
},
|
|
23285
|
-
"inputType": "email"
|
|
23286
|
-
},
|
|
23287
|
-
{
|
|
23288
|
-
"name": "password",
|
|
23289
|
-
"displayName": "Password",
|
|
23290
|
-
"defaultValue": null,
|
|
23291
|
-
"validate": {
|
|
23292
|
-
"mandatory": true,
|
|
23293
|
-
"minLength": 3,
|
|
23294
|
-
"maxLength": 20,
|
|
23295
|
-
"type": "password",
|
|
23296
|
-
"custom": [
|
|
23297
|
-
{
|
|
23298
|
-
"rule": "regex",
|
|
23299
|
-
"pattern": "(?=.*\\d+)(?=.*[A-Za-z]+).{8,20}",
|
|
23300
|
-
"errorMessage": "Password must contain at least 1 letter and 1 digit, and its minimal length is 8."
|
|
23301
|
-
}
|
|
23302
|
-
]
|
|
23303
|
-
},
|
|
23304
|
-
"inputType": "password"
|
|
23305
|
-
},
|
|
23306
|
-
{
|
|
23307
|
-
"name": "email",
|
|
23308
|
-
"displayName": "Email",
|
|
23309
|
-
"defaultValue": null,
|
|
23310
|
-
"validate": {
|
|
23311
|
-
"mandatory": true,
|
|
23312
|
-
"type": "email",
|
|
23313
|
-
"custom": [
|
|
23314
|
-
{
|
|
23315
|
-
"rule": "unique-email",
|
|
23316
|
-
"errorMessage": "Please check your email"
|
|
23317
|
-
},
|
|
23318
|
-
{
|
|
23319
|
-
"rule": "regex",
|
|
23320
|
-
"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
23321
|
-
"errorMessage": "Please enter a valid email address"
|
|
23322
|
-
},
|
|
23323
|
-
{
|
|
23324
|
-
"rule": "duplicate-input",
|
|
23325
|
-
"displayName": "pt al doilea input gen: Confirm Email",
|
|
23326
|
-
"errorMessage": "Different Email! Pls."
|
|
23327
|
-
}
|
|
23328
|
-
]
|
|
23329
|
-
}
|
|
23330
|
-
},
|
|
23331
|
-
{
|
|
23332
|
-
"name": "termsAndConditions",
|
|
23333
|
-
"displayName": "Terms and Conditions",
|
|
23334
|
-
"validate": {
|
|
23335
|
-
"mandatory": true,
|
|
23336
|
-
"type": "boolean"
|
|
23337
|
-
},
|
|
23338
|
-
"inputType": "checkbox"
|
|
23339
|
-
},
|
|
23340
|
-
{
|
|
23341
|
-
"name": "pepCheck",
|
|
23342
|
-
"validate": {
|
|
23343
|
-
"mandatory": true
|
|
23344
|
-
},
|
|
23345
|
-
"inputType": "checkbox"
|
|
23346
|
-
},
|
|
23347
|
-
{
|
|
23348
|
-
"name": "gender",
|
|
23349
|
-
"data": {
|
|
23350
|
-
"values": [
|
|
23351
|
-
{
|
|
23352
|
-
"label": "🍆",
|
|
23353
|
-
"value": "m"
|
|
23354
|
-
},
|
|
23355
|
-
{
|
|
23356
|
-
"label": "🍑",
|
|
23357
|
-
"value": "f"
|
|
23358
|
-
}
|
|
23359
|
-
]
|
|
23360
|
-
},
|
|
23361
|
-
"validate": {
|
|
23362
|
-
"mandatory": true
|
|
23363
|
-
},
|
|
23364
|
-
"inputType": "radio"
|
|
23365
|
-
},
|
|
23366
|
-
{
|
|
23367
|
-
"name": "dateOfBirth",
|
|
23368
|
-
"validate": {
|
|
23369
|
-
"mandatory": true,
|
|
23370
|
-
"custom": [
|
|
23371
|
-
{
|
|
23372
|
-
"rule": "regex",
|
|
23373
|
-
"pattern": "(?:19\\d{2}|20[01][0-9]|2020)[-/.](?:0[1-9]|1[012])[-/.](?:0[1-9]|[12][0-9]|3[01])",
|
|
23374
|
-
"errorMessage": "Invalid date format"
|
|
23375
|
-
},
|
|
23376
|
-
{
|
|
23377
|
-
"rule": "min-18-years",
|
|
23378
|
-
"errorMessage": "Not old enough to ride the roller coaster"
|
|
23379
|
-
}
|
|
23380
|
-
]
|
|
23381
|
-
}
|
|
23382
|
-
},
|
|
23383
|
-
{
|
|
23384
|
-
"name": "city",
|
|
23385
|
-
"displayName": "Cities",
|
|
23386
|
-
"action": null,
|
|
23387
|
-
"data": {
|
|
23388
|
-
"values": [
|
|
23389
|
-
{
|
|
23390
|
-
"label": "Budapest",
|
|
23391
|
-
"value": "Budapest"
|
|
23392
|
-
},
|
|
23393
|
-
{
|
|
23394
|
-
"label": "Debrecen",
|
|
23395
|
-
"value": "Debrecen"
|
|
23396
|
-
},
|
|
23397
|
-
{
|
|
23398
|
-
"label": "Miskolc",
|
|
23399
|
-
"value": "Miskolc"
|
|
23400
|
-
},
|
|
23401
|
-
{
|
|
23402
|
-
"label": "Szeged",
|
|
23403
|
-
"value": "Szeged"
|
|
23404
|
-
},
|
|
23405
|
-
{
|
|
23406
|
-
"label": "Zuglo",
|
|
23407
|
-
"value": "Zuglo"
|
|
23408
|
-
}
|
|
23409
|
-
]
|
|
23410
|
-
},
|
|
23411
|
-
"validate": {
|
|
23412
|
-
"mandatory": true
|
|
23413
|
-
},
|
|
23414
|
-
"inputType": "dropdown"
|
|
23415
|
-
},
|
|
23416
|
-
{
|
|
23417
|
-
"name": "city",
|
|
23418
|
-
"displayName": "Cities",
|
|
23419
|
-
"data": null,
|
|
23420
|
-
"action": "GET https://demo-api.stage.norway.everymatrix.com/v1/player/countries",
|
|
23421
|
-
"validate": {
|
|
23422
|
-
"mandatory": true
|
|
23423
|
-
},
|
|
23424
|
-
"inputType": "dropdown"
|
|
23425
|
-
}
|
|
23426
|
-
],
|
|
23427
|
-
"actions": [
|
|
23428
|
-
"get-next-step",
|
|
23429
|
-
"some-async-action-before-submitting",
|
|
23430
|
-
"submit-step-data"
|
|
23431
|
-
]
|
|
23432
|
-
}
|
|
23433
|
-
};
|
|
23251
|
+
this.registrationWidgetLoaded = createEvent(this, "registrationWidgetLoaded", 7);
|
|
23252
|
+
this.registrationStepUpdated = createEvent(this, "registrationStepUpdated", 7);
|
|
23434
23253
|
/**
|
|
23435
23254
|
* Currently selected language
|
|
23436
23255
|
*/
|
|
23437
23256
|
this.language = 'en';
|
|
23257
|
+
/**
|
|
23258
|
+
* Client custom styling via string
|
|
23259
|
+
*/
|
|
23260
|
+
this.clientStyling = '';
|
|
23261
|
+
/**
|
|
23262
|
+
* Client custom styling via url content
|
|
23263
|
+
*/
|
|
23264
|
+
this.clientStylingUrl = '';
|
|
23438
23265
|
this.emitValue = false;
|
|
23439
23266
|
this.listOfInputs = [];
|
|
23440
23267
|
this.isLoading = true;
|
|
23268
|
+
this.limitStylingAppends = false;
|
|
23441
23269
|
this.listOfInputValues = [];
|
|
23442
23270
|
this.listOfActions = [];
|
|
23443
|
-
this.
|
|
23271
|
+
this.indexStep = 0;
|
|
23444
23272
|
this.registrationStepsState = {
|
|
23445
23273
|
regId: null
|
|
23446
23274
|
};
|
|
23275
|
+
this.setClientStyling = () => {
|
|
23276
|
+
let sheet = document.createElement('style');
|
|
23277
|
+
sheet.innerHTML = this.clientStyling;
|
|
23278
|
+
this.stylingContainer.prepend(sheet);
|
|
23279
|
+
};
|
|
23280
|
+
this.setClientStylingURL = () => {
|
|
23281
|
+
let url = new URL(this.clientStylingUrl);
|
|
23282
|
+
let cssFile = document.createElement('style');
|
|
23283
|
+
fetch(url.href)
|
|
23284
|
+
.then((res) => res.text())
|
|
23285
|
+
.then((data) => {
|
|
23286
|
+
cssFile.innerHTML = data;
|
|
23287
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
23288
|
+
});
|
|
23289
|
+
};
|
|
23447
23290
|
}
|
|
23448
|
-
|
|
23449
|
-
|
|
23291
|
+
sendStep() {
|
|
23292
|
+
this.registrationStepUpdated.emit(this.registrationStep);
|
|
23293
|
+
window.postMessage({ type: 'registrationStepUpdated', step: this.registrationStep }, window.location.href);
|
|
23450
23294
|
}
|
|
23451
23295
|
checkInputsValidityHandler(event) {
|
|
23452
23296
|
// Set isValid state of the input in the list.
|
|
@@ -23455,25 +23299,30 @@ const GeneralRegistration = class {
|
|
|
23455
23299
|
this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
|
|
23456
23300
|
}
|
|
23457
23301
|
getInputsValueHandler(event) {
|
|
23458
|
-
this.listOfInputValues.find(input =>
|
|
23459
|
-
|
|
23460
|
-
|
|
23461
|
-
|
|
23302
|
+
this.listOfInputValues.find(input => {
|
|
23303
|
+
if (input.name == event.detail.name) {
|
|
23304
|
+
input.value = event.detail.value;
|
|
23305
|
+
}
|
|
23306
|
+
});
|
|
23462
23307
|
this.stepsStateMachine({ event: 'set', type: 'values' });
|
|
23463
23308
|
}
|
|
23464
23309
|
componentWillLoad() {
|
|
23465
|
-
// const mockCall = Promise.resolve(this.data);
|
|
23466
|
-
// return mockCall.then((data) => {
|
|
23467
|
-
// this.listOfInputs = data.content.fields.map((field) => {
|
|
23468
|
-
// this.isLoading = false;
|
|
23469
|
-
// return { ...field, isValid: false };
|
|
23470
|
-
// });
|
|
23471
|
-
// });
|
|
23472
23310
|
return this.getRegisterConfig().then((config) => {
|
|
23473
23311
|
this.formatConfig(config);
|
|
23474
23312
|
this.stepsStateMachine({ event: 'set', type: 'inputs' });
|
|
23475
23313
|
});
|
|
23476
23314
|
}
|
|
23315
|
+
componentDidRender() {
|
|
23316
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
23317
|
+
this.setClientStyling();
|
|
23318
|
+
this.setClientStylingURL();
|
|
23319
|
+
this.limitStylingAppends = true;
|
|
23320
|
+
}
|
|
23321
|
+
}
|
|
23322
|
+
componentDidLoad() {
|
|
23323
|
+
this.registrationWidgetLoaded.emit();
|
|
23324
|
+
window.postMessage({ type: 'registrationWidgetLoaded' }, window.location.href);
|
|
23325
|
+
}
|
|
23477
23326
|
nextHandler(e) {
|
|
23478
23327
|
e.preventDefault();
|
|
23479
23328
|
// Trigger events in subwidgets.
|
|
@@ -23482,8 +23331,8 @@ const GeneralRegistration = class {
|
|
|
23482
23331
|
}
|
|
23483
23332
|
backHandler(e) {
|
|
23484
23333
|
e.preventDefault();
|
|
23485
|
-
this.
|
|
23486
|
-
this.registrationStep = this.
|
|
23334
|
+
this.isLastStep = false;
|
|
23335
|
+
this.registrationStep = this.stepChange('decrement');
|
|
23487
23336
|
this.stepsStateMachine({ event: 'get', type: 'inputs' });
|
|
23488
23337
|
this.stepsStateMachine({ event: 'get', type: 'values' });
|
|
23489
23338
|
}
|
|
@@ -23492,13 +23341,11 @@ const GeneralRegistration = class {
|
|
|
23492
23341
|
case 'set':
|
|
23493
23342
|
if (state.type == 'inputs') {
|
|
23494
23343
|
this.registrationStepsState[this.registrationStep].fields = this.listOfInputs;
|
|
23344
|
+
this.registrationStepsState[this.registrationStep].actions = this.listOfActions;
|
|
23495
23345
|
}
|
|
23496
23346
|
if (state.type == 'values') {
|
|
23497
23347
|
this.registrationStepsState[this.registrationStep].registerUserData = this.listOfInputValues.reduce((acc, curr) => {
|
|
23498
|
-
|
|
23499
|
-
if (curr.value != null) {
|
|
23500
|
-
acc[curr.name] = curr.value;
|
|
23501
|
-
}
|
|
23348
|
+
acc[curr.name] = { value: curr.value, isDuplicate: curr.isDuplicate };
|
|
23502
23349
|
return acc;
|
|
23503
23350
|
}, {});
|
|
23504
23351
|
}
|
|
@@ -23510,17 +23357,19 @@ const GeneralRegistration = class {
|
|
|
23510
23357
|
return;
|
|
23511
23358
|
if (state.type == 'inputs') {
|
|
23512
23359
|
this.listOfInputs = this.registrationStepsState[this.registrationStep].fields;
|
|
23360
|
+
this.listOfActions = this.registrationStepsState[this.registrationStep].actions;
|
|
23513
23361
|
}
|
|
23514
23362
|
if (state.type == 'values') {
|
|
23515
23363
|
const savedValues = savedUserData[this.registrationStep].registerUserData;
|
|
23516
23364
|
this.listOfInputValues = Object.keys(savedValues).map(name => {
|
|
23517
|
-
return { name, value: savedValues[name] };
|
|
23365
|
+
return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
|
|
23518
23366
|
});
|
|
23519
23367
|
// Give to each field the user input as the default value.
|
|
23520
23368
|
this.listOfInputValues.forEach(inputValue => {
|
|
23521
23369
|
const input = this.listOfInputs.find(input => input.name === inputValue.name);
|
|
23522
23370
|
if (input) {
|
|
23523
23371
|
input.defaultValue = inputValue.value;
|
|
23372
|
+
console.log(input);
|
|
23524
23373
|
}
|
|
23525
23374
|
});
|
|
23526
23375
|
}
|
|
@@ -23530,9 +23379,6 @@ const GeneralRegistration = class {
|
|
|
23530
23379
|
getRegisterConfig(registrationID) {
|
|
23531
23380
|
const url = new URL(`${this.endpoint}/v1/player/legislation/registration/config`);
|
|
23532
23381
|
const headers = new Headers();
|
|
23533
|
-
// headers.append('X-Tenant-ID', this.tenantId);
|
|
23534
|
-
// headers.append('X-Client-ID', this.clientId);
|
|
23535
|
-
// headers.append('X-Api-Key', this.apiKey);
|
|
23536
23382
|
headers.append('Content-Type', 'application/json');
|
|
23537
23383
|
headers.append('Accept', 'application/json');
|
|
23538
23384
|
if (registrationID) {
|
|
@@ -23561,9 +23407,15 @@ const GeneralRegistration = class {
|
|
|
23561
23407
|
const url = new URL(`${this.endpoint}/v1/player/legislation/registration/step`);
|
|
23562
23408
|
const registerStep = {
|
|
23563
23409
|
registrationId: this.registrationID,
|
|
23564
|
-
registerUserDto: this.listOfInputValues
|
|
23565
|
-
|
|
23566
|
-
|
|
23410
|
+
registerUserDto: this.listOfInputValues
|
|
23411
|
+
.filter(input => !input.isDuplicate)
|
|
23412
|
+
.reduce((acc, curr) => {
|
|
23413
|
+
// Special case for "Mobile" as it needs to be split in two values -- API expects it this way.
|
|
23414
|
+
if (curr.name == "Mobile") {
|
|
23415
|
+
acc['MobilePrefix'] = curr.value.split('|')[0];
|
|
23416
|
+
acc[curr.name] = curr.value.split('|')[1];
|
|
23417
|
+
}
|
|
23418
|
+
else {
|
|
23567
23419
|
acc[curr.name] = curr.value;
|
|
23568
23420
|
}
|
|
23569
23421
|
return acc;
|
|
@@ -23571,9 +23423,6 @@ const GeneralRegistration = class {
|
|
|
23571
23423
|
step: this.registrationStep,
|
|
23572
23424
|
};
|
|
23573
23425
|
const headers = new Headers();
|
|
23574
|
-
// headers.append('X-Tenant-ID', this.tenantId);
|
|
23575
|
-
// headers.append('X-Client-ID', this.clientId);
|
|
23576
|
-
// headers.append('X-Api-Key', this.apiKey);
|
|
23577
23426
|
headers.append('Content-Type', 'application/json');
|
|
23578
23427
|
headers.append('Accept', 'application/json');
|
|
23579
23428
|
const options = {
|
|
@@ -23594,12 +23443,22 @@ const GeneralRegistration = class {
|
|
|
23594
23443
|
this.setRegister();
|
|
23595
23444
|
}
|
|
23596
23445
|
else {
|
|
23597
|
-
|
|
23598
|
-
|
|
23599
|
-
|
|
23600
|
-
|
|
23601
|
-
|
|
23602
|
-
|
|
23446
|
+
// After sending the current step, increment and check if the next one is in state.
|
|
23447
|
+
this.registrationStep = this.stepChange('increment');
|
|
23448
|
+
// If step is present in state do NOT fetch the next config.
|
|
23449
|
+
if (Object.keys(this.registrationStepsState).find(key => key == this.registrationStep)) {
|
|
23450
|
+
// Use the one from state
|
|
23451
|
+
this.stepsStateMachine({ event: 'get', type: 'inputs' });
|
|
23452
|
+
this.stepsStateMachine({ event: 'get', type: 'values' });
|
|
23453
|
+
}
|
|
23454
|
+
else {
|
|
23455
|
+
this.getRegisterConfig(this.registrationID).then((config) => {
|
|
23456
|
+
// Format the new step config.
|
|
23457
|
+
this.formatConfig(config);
|
|
23458
|
+
// Set it in local storage.
|
|
23459
|
+
this.stepsStateMachine({ event: 'set', type: 'inputs' });
|
|
23460
|
+
});
|
|
23461
|
+
}
|
|
23603
23462
|
}
|
|
23604
23463
|
})
|
|
23605
23464
|
.catch((err) => {
|
|
@@ -23613,19 +23472,8 @@ const GeneralRegistration = class {
|
|
|
23613
23472
|
this.isLoading = true;
|
|
23614
23473
|
const url = new URL(`${this.endpoint}/v1/player/legislation/register`);
|
|
23615
23474
|
const headers = new Headers();
|
|
23616
|
-
// headers.append('X-Tenant-ID', this.tenantId);
|
|
23617
|
-
// headers.append('X-Client-ID', this.clientId);
|
|
23618
|
-
// headers.append('X-Api-Key', this.apiKey);
|
|
23619
23475
|
headers.append('Content-Type', 'application/json');
|
|
23620
23476
|
headers.append('Accept', 'application/json');
|
|
23621
|
-
// const registerStep = {
|
|
23622
|
-
// registrationId: this.registrationID,
|
|
23623
|
-
// registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
|
|
23624
|
-
// acc[curr.name] = curr.value;
|
|
23625
|
-
// return acc;
|
|
23626
|
-
// }, {}),
|
|
23627
|
-
// step: this.registrationStep,
|
|
23628
|
-
// };
|
|
23629
23477
|
const options = {
|
|
23630
23478
|
method: 'PUT',
|
|
23631
23479
|
body: JSON.stringify({ registrationId: this.registrationID }),
|
|
@@ -23652,51 +23500,69 @@ const GeneralRegistration = class {
|
|
|
23652
23500
|
}
|
|
23653
23501
|
formatConfig(config) {
|
|
23654
23502
|
// Populate the list of inputs and set as invalid in the beginning
|
|
23655
|
-
this.listOfInputs = config.content.fields.
|
|
23656
|
-
|
|
23503
|
+
this.listOfInputs = config.content.fields.flatMap((field) => {
|
|
23504
|
+
// Special case for inputs that need to be duplicated.
|
|
23505
|
+
const duplicateInputRule = field.validate.custom.find(customRule => customRule.rule === 'duplicate-input');
|
|
23506
|
+
const inputElement = Object.assign(Object.assign({}, field), { isValid: false });
|
|
23507
|
+
if (duplicateInputRule) {
|
|
23508
|
+
const duplicateInput = Object.assign(Object.assign({}, field), { name: `${field.name}Duplicate`, displayName: duplicateInputRule.displayName, isValid: false, isDuplicateInput: true });
|
|
23509
|
+
return [inputElement, duplicateInput];
|
|
23510
|
+
}
|
|
23511
|
+
else {
|
|
23512
|
+
return [inputElement];
|
|
23513
|
+
}
|
|
23657
23514
|
});
|
|
23658
23515
|
// Populate the list of inputs values and set as null in the beginning
|
|
23659
|
-
this.listOfInputValues =
|
|
23660
|
-
return { name: field.name, value: null };
|
|
23516
|
+
this.listOfInputValues = this.listOfInputs.map(field => {
|
|
23517
|
+
return { name: field.name, value: null, isDuplicate: field.isDuplicateInput || false };
|
|
23661
23518
|
});
|
|
23662
23519
|
// Set the list of actions
|
|
23663
23520
|
this.listOfActions = config.content.actions.map(action => action);
|
|
23664
23521
|
this.isLastStep = this.listOfActions.some(action => action == '/register');
|
|
23665
23522
|
this.registrationID = config.content.registrationID;
|
|
23666
23523
|
this.registrationStep = config.content.step;
|
|
23667
|
-
this.steps.push(this.registrationStep);
|
|
23668
23524
|
// Add the step to the registrationStepsData
|
|
23669
23525
|
this.registrationStepsState.regId = this.registrationID;
|
|
23670
23526
|
if (!this.registrationStepsState[this.registrationStep]) {
|
|
23671
23527
|
this.registrationStepsState[this.registrationStep] = {
|
|
23672
23528
|
fields: [],
|
|
23673
|
-
registerUserData: {}
|
|
23529
|
+
registerUserData: {},
|
|
23530
|
+
actions: []
|
|
23674
23531
|
};
|
|
23675
23532
|
}
|
|
23676
23533
|
}
|
|
23534
|
+
stepChange(action) {
|
|
23535
|
+
const stepNum = parseInt(this.registrationStep.replace('Step', ''));
|
|
23536
|
+
if (action === 'increment') {
|
|
23537
|
+
return 'Step' + (stepNum + 1);
|
|
23538
|
+
}
|
|
23539
|
+
if (action === 'decrement') {
|
|
23540
|
+
return 'Step' + (stepNum - 1);
|
|
23541
|
+
}
|
|
23542
|
+
}
|
|
23677
23543
|
getInvalidStatus(listOfInputs) {
|
|
23678
23544
|
return listOfInputs.filter(input => input.isValid == false).length > 0;
|
|
23679
23545
|
}
|
|
23680
23546
|
renderInputs() {
|
|
23681
|
-
return (this.listOfInputs.map(input => h$2("general-input", { type: input.inputType, name: input.name, displayName: input.displayName, validation: input.validate, action: input.action || null, options: input.data ? input.data.values : [], defaultValue: input.defaultValue, autofilled: input.autofill, emitValue: this.emitValue, language: this.language })));
|
|
23547
|
+
return (this.listOfInputs.map(input => h$2("general-input", { type: input.inputType, name: input.name, displayName: input.displayName, validation: input.validate, action: input.action || null, options: input.data ? input.data.values : [], defaultValue: input.defaultValue, autofilled: input.autofill, emitValue: this.emitValue, language: this.language, isDuplicateInput: input.isDuplicateInput })));
|
|
23682
23548
|
}
|
|
23683
23549
|
;
|
|
23684
23550
|
renderButtons() {
|
|
23685
|
-
return (h$2("div", { class: 'registration__buttons-wrapper' }, h$2("button", { class: `registration__button
|
|
23551
|
+
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))));
|
|
23686
23552
|
}
|
|
23687
23553
|
render() {
|
|
23688
23554
|
if (this.isLoading) {
|
|
23689
23555
|
return h$2("p", null, "Please wait, loading ...");
|
|
23690
23556
|
}
|
|
23691
|
-
return (h$2("div", { class:
|
|
23557
|
+
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()));
|
|
23692
23558
|
}
|
|
23693
23559
|
static get watchers() { return {
|
|
23694
|
-
"registrationStep": ["
|
|
23560
|
+
"registrationStep": ["sendStep"]
|
|
23695
23561
|
}; }
|
|
23696
23562
|
};
|
|
23697
23563
|
GeneralRegistration.style = generalRegistrationCss;
|
|
23698
23564
|
|
|
23699
|
-
const numberInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.number__wrapper{position:relative;
|
|
23565
|
+
const numberInputCss = "*,*::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}";
|
|
23700
23566
|
|
|
23701
23567
|
const NumberInput = class {
|
|
23702
23568
|
constructor(hostRef) {
|
|
@@ -23721,6 +23587,12 @@ const NumberInput = class {
|
|
|
23721
23587
|
valueHandler(inputValueEvent) {
|
|
23722
23588
|
this.sendInputValue.emit(inputValueEvent);
|
|
23723
23589
|
}
|
|
23590
|
+
componentDidLoad() {
|
|
23591
|
+
if (this.defaultValue) {
|
|
23592
|
+
this.value = this.defaultValue;
|
|
23593
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
23594
|
+
}
|
|
23595
|
+
}
|
|
23724
23596
|
handleInput(event) {
|
|
23725
23597
|
this.value = event.target.value;
|
|
23726
23598
|
this.errorMessage = this.setErrorMessage();
|
|
@@ -23750,99 +23622,915 @@ const NumberInput = class {
|
|
|
23750
23622
|
};
|
|
23751
23623
|
NumberInput.style = numberInputCss;
|
|
23752
23624
|
|
|
23753
|
-
|
|
23625
|
+
/**
|
|
23626
|
+
* @license
|
|
23627
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
23628
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
23629
|
+
*/
|
|
23630
|
+
|
|
23631
|
+
registerStyles('vaadin-text-field', inputFieldShared$1, {
|
|
23632
|
+
moduleId: 'lumo-text-field-styles',
|
|
23633
|
+
});
|
|
23754
23634
|
|
|
23755
|
-
|
|
23756
|
-
|
|
23757
|
-
|
|
23758
|
-
|
|
23759
|
-
|
|
23760
|
-
|
|
23761
|
-
|
|
23762
|
-
|
|
23763
|
-
|
|
23764
|
-
|
|
23765
|
-
|
|
23766
|
-
|
|
23767
|
-
|
|
23768
|
-
|
|
23769
|
-
|
|
23770
|
-
|
|
23635
|
+
/**
|
|
23636
|
+
* @license
|
|
23637
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
23638
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
23639
|
+
*/
|
|
23640
|
+
|
|
23641
|
+
/**
|
|
23642
|
+
* A mixin to provide logic for vaadin-text-field and related components.
|
|
23643
|
+
*
|
|
23644
|
+
* @polymerMixin
|
|
23645
|
+
* @mixes InputControlMixin
|
|
23646
|
+
*/
|
|
23647
|
+
const InputFieldMixin = (superclass) =>
|
|
23648
|
+
class InputFieldMixinClass extends InputControlMixin(superclass) {
|
|
23649
|
+
static get properties() {
|
|
23650
|
+
return {
|
|
23651
|
+
/**
|
|
23652
|
+
* Whether the value of the control can be automatically completed by the browser.
|
|
23653
|
+
* List of available options at:
|
|
23654
|
+
* https://developer.mozilla.org/en/docs/Web/HTML/Element/input#attr-autocomplete
|
|
23655
|
+
*/
|
|
23656
|
+
autocomplete: {
|
|
23657
|
+
type: String,
|
|
23658
|
+
},
|
|
23659
|
+
|
|
23660
|
+
/**
|
|
23661
|
+
* This is a property supported by Safari that is used to control whether
|
|
23662
|
+
* autocorrection should be enabled when the user is entering/editing the text.
|
|
23663
|
+
* Possible values are:
|
|
23664
|
+
* on: Enable autocorrection.
|
|
23665
|
+
* off: Disable autocorrection.
|
|
23666
|
+
*/
|
|
23667
|
+
autocorrect: {
|
|
23668
|
+
type: String,
|
|
23669
|
+
},
|
|
23670
|
+
|
|
23671
|
+
/**
|
|
23672
|
+
* This is a property supported by Safari and Chrome that is used to control whether
|
|
23673
|
+
* autocapitalization should be enabled when the user is entering/editing the text.
|
|
23674
|
+
* Possible values are:
|
|
23675
|
+
* characters: Characters capitalization.
|
|
23676
|
+
* words: Words capitalization.
|
|
23677
|
+
* sentences: Sentences capitalization.
|
|
23678
|
+
* none: No capitalization.
|
|
23679
|
+
*/
|
|
23680
|
+
autocapitalize: {
|
|
23681
|
+
type: String,
|
|
23682
|
+
reflectToAttribute: true,
|
|
23683
|
+
},
|
|
23684
|
+
};
|
|
23771
23685
|
}
|
|
23772
|
-
|
|
23773
|
-
|
|
23774
|
-
|
|
23775
|
-
}
|
|
23776
|
-
emitValueHandler(newValue) {
|
|
23777
|
-
if (newValue == true && this.isValid) {
|
|
23778
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
23686
|
+
|
|
23687
|
+
static get delegateAttrs() {
|
|
23688
|
+
return [...super.delegateAttrs, 'autocapitalize', 'autocomplete', 'autocorrect'];
|
|
23779
23689
|
}
|
|
23780
|
-
|
|
23781
|
-
|
|
23782
|
-
|
|
23783
|
-
|
|
23784
|
-
|
|
23785
|
-
|
|
23786
|
-
|
|
23787
|
-
|
|
23788
|
-
|
|
23789
|
-
|
|
23790
|
-
|
|
23791
|
-
|
|
23792
|
-
|
|
23793
|
-
|
|
23794
|
-
|
|
23795
|
-
|
|
23796
|
-
|
|
23797
|
-
|
|
23798
|
-
|
|
23799
|
-
|
|
23800
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
|
|
23690
|
+
|
|
23691
|
+
/**
|
|
23692
|
+
* @param {HTMLElement} input
|
|
23693
|
+
* @protected
|
|
23694
|
+
* @override
|
|
23695
|
+
*/
|
|
23696
|
+
_inputElementChanged(input) {
|
|
23697
|
+
super._inputElementChanged(input);
|
|
23698
|
+
|
|
23699
|
+
if (input) {
|
|
23700
|
+
// Discard value set on the custom slotted input.
|
|
23701
|
+
if (input.value && input.value !== this.value) {
|
|
23702
|
+
console.warn(`Please define value on the <${this.localName}> component!`);
|
|
23703
|
+
input.value = '';
|
|
23704
|
+
}
|
|
23705
|
+
|
|
23706
|
+
if (this.value) {
|
|
23707
|
+
input.value = this.value;
|
|
23708
|
+
}
|
|
23709
|
+
}
|
|
23801
23710
|
}
|
|
23802
|
-
|
|
23803
|
-
|
|
23804
|
-
|
|
23805
|
-
return this.
|
|
23711
|
+
|
|
23712
|
+
// Workaround for https://github.com/Polymer/polymer/issues/5259
|
|
23713
|
+
get __data() {
|
|
23714
|
+
return this.__dataValue || {};
|
|
23806
23715
|
}
|
|
23807
|
-
|
|
23808
|
-
|
|
23716
|
+
|
|
23717
|
+
set __data(value) {
|
|
23718
|
+
this.__dataValue = value;
|
|
23809
23719
|
}
|
|
23810
|
-
|
|
23811
|
-
|
|
23720
|
+
|
|
23721
|
+
/**
|
|
23722
|
+
* Override an event listener from `FocusMixin`.
|
|
23723
|
+
* @param {boolean} focused
|
|
23724
|
+
* @protected
|
|
23725
|
+
* @override
|
|
23726
|
+
*/
|
|
23727
|
+
_setFocused(focused) {
|
|
23728
|
+
super._setFocused(focused);
|
|
23729
|
+
|
|
23730
|
+
if (!focused) {
|
|
23731
|
+
this.validate();
|
|
23732
|
+
}
|
|
23812
23733
|
}
|
|
23813
|
-
}
|
|
23814
|
-
render() {
|
|
23815
|
-
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'password__input--invalid';
|
|
23816
|
-
return h$2("div", { class: 'password__wrapper' }, h$2("input", { type: "password", id: `${this.name}__input`, class: `password__input ${invalidClass}`, name: this.name, readOnly: this.autofilled, value: this.defaultValue, ref: (el) => this.inputReference = el, required: this.validation.mandatory, maxlength: this.validation.maxLength, minlength: this.validation.minLength, pattern: this.validationPattern, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, onBlur: (e) => this.handleInput(e) }), h$2("label", { class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h$2("small", { class: 'password__error-message' }, this.errorMessage));
|
|
23817
|
-
}
|
|
23818
|
-
static get watchers() { return {
|
|
23819
|
-
"isValid": ["validityChanged"],
|
|
23820
|
-
"emitValue": ["emitValueHandler"]
|
|
23821
|
-
}; }
|
|
23822
|
-
};
|
|
23823
|
-
PasswordInput.style = passwordInputCss;
|
|
23824
23734
|
|
|
23825
|
-
|
|
23735
|
+
/**
|
|
23736
|
+
* Override an event listener from `InputMixin`
|
|
23737
|
+
* to mark as valid after user started typing.
|
|
23738
|
+
* @param {Event} event
|
|
23739
|
+
* @protected
|
|
23740
|
+
* @override
|
|
23741
|
+
*/
|
|
23742
|
+
_onInput(event) {
|
|
23743
|
+
super._onInput(event);
|
|
23826
23744
|
|
|
23827
|
-
|
|
23828
|
-
|
|
23829
|
-
|
|
23830
|
-
this.sendInputValue = createEvent(this, "sendInputValue", 7);
|
|
23831
|
-
this.sendValidityState = createEvent(this, "sendValidityState", 7);
|
|
23832
|
-
}
|
|
23833
|
-
validityChanged() {
|
|
23834
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
23835
|
-
if (this.emitValue == true) {
|
|
23836
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
23745
|
+
if (this.invalid) {
|
|
23746
|
+
this.validate();
|
|
23747
|
+
}
|
|
23837
23748
|
}
|
|
23838
|
-
|
|
23839
|
-
|
|
23840
|
-
|
|
23841
|
-
|
|
23749
|
+
|
|
23750
|
+
/**
|
|
23751
|
+
* Override an observer from `InputMixin` to validate the field
|
|
23752
|
+
* when a new value is set programmatically.
|
|
23753
|
+
*
|
|
23754
|
+
* @param {string | undefined} newValue
|
|
23755
|
+
* @param {string | undefined} oldValue
|
|
23756
|
+
* @protected
|
|
23757
|
+
* @override
|
|
23758
|
+
*/
|
|
23759
|
+
_valueChanged(newValue, oldValue) {
|
|
23760
|
+
super._valueChanged(newValue, oldValue);
|
|
23761
|
+
|
|
23762
|
+
if (oldValue === undefined) {
|
|
23763
|
+
return;
|
|
23764
|
+
}
|
|
23765
|
+
|
|
23766
|
+
if (this.invalid) {
|
|
23767
|
+
this.validate();
|
|
23768
|
+
}
|
|
23842
23769
|
}
|
|
23843
|
-
}
|
|
23844
|
-
|
|
23845
|
-
|
|
23770
|
+
};
|
|
23771
|
+
|
|
23772
|
+
/**
|
|
23773
|
+
* @license
|
|
23774
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
23775
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
23776
|
+
*/
|
|
23777
|
+
|
|
23778
|
+
/**
|
|
23779
|
+
* A mixin to provide `pattern` and `preventInvalidInput` properties.
|
|
23780
|
+
*
|
|
23781
|
+
* @polymerMixin
|
|
23782
|
+
* @mixes InputConstraintsMixin
|
|
23783
|
+
*/
|
|
23784
|
+
const PatternMixin = (superclass) =>
|
|
23785
|
+
class PatternMixinClass extends InputConstraintsMixin(superclass) {
|
|
23786
|
+
static get properties() {
|
|
23787
|
+
return {
|
|
23788
|
+
/**
|
|
23789
|
+
* A regular expression that the value is checked against.
|
|
23790
|
+
* The pattern must match the entire value, not just some subset.
|
|
23791
|
+
*/
|
|
23792
|
+
pattern: {
|
|
23793
|
+
type: String,
|
|
23794
|
+
},
|
|
23795
|
+
|
|
23796
|
+
/**
|
|
23797
|
+
* When set to true, user is prevented from typing a value that
|
|
23798
|
+
* conflicts with the given `pattern`.
|
|
23799
|
+
* @attr {boolean} prevent-invalid-input
|
|
23800
|
+
* @deprecated Please use `allowedCharPattern` instead.
|
|
23801
|
+
*/
|
|
23802
|
+
preventInvalidInput: {
|
|
23803
|
+
type: Boolean,
|
|
23804
|
+
observer: '_preventInvalidInputChanged',
|
|
23805
|
+
},
|
|
23806
|
+
};
|
|
23807
|
+
}
|
|
23808
|
+
|
|
23809
|
+
static get delegateAttrs() {
|
|
23810
|
+
return [...super.delegateAttrs, 'pattern'];
|
|
23811
|
+
}
|
|
23812
|
+
|
|
23813
|
+
static get constraints() {
|
|
23814
|
+
return [...super.constraints, 'pattern'];
|
|
23815
|
+
}
|
|
23816
|
+
|
|
23817
|
+
/** @private */
|
|
23818
|
+
_checkInputValue() {
|
|
23819
|
+
if (this.preventInvalidInput) {
|
|
23820
|
+
const input = this.inputElement;
|
|
23821
|
+
if (input && input.value.length > 0 && !this.checkValidity()) {
|
|
23822
|
+
input.value = this.value || '';
|
|
23823
|
+
// Add input-prevented attribute for 200ms
|
|
23824
|
+
this.setAttribute('input-prevented', '');
|
|
23825
|
+
this._inputDebouncer = Debouncer$1.debounce(this._inputDebouncer, timeOut.after(200), () => {
|
|
23826
|
+
this.removeAttribute('input-prevented');
|
|
23827
|
+
});
|
|
23828
|
+
}
|
|
23829
|
+
}
|
|
23830
|
+
}
|
|
23831
|
+
|
|
23832
|
+
/**
|
|
23833
|
+
* @param {Event} event
|
|
23834
|
+
* @protected
|
|
23835
|
+
* @override
|
|
23836
|
+
*/
|
|
23837
|
+
_onInput(event) {
|
|
23838
|
+
this._checkInputValue();
|
|
23839
|
+
|
|
23840
|
+
super._onInput(event);
|
|
23841
|
+
}
|
|
23842
|
+
|
|
23843
|
+
/** @private */
|
|
23844
|
+
_preventInvalidInputChanged(preventInvalidInput) {
|
|
23845
|
+
if (preventInvalidInput) {
|
|
23846
|
+
console.warn(
|
|
23847
|
+
`WARNING: Since Vaadin 23.2, "preventInvalidInput" is deprecated. Please use "allowedCharPattern" instead.`,
|
|
23848
|
+
);
|
|
23849
|
+
}
|
|
23850
|
+
}
|
|
23851
|
+
};
|
|
23852
|
+
|
|
23853
|
+
/**
|
|
23854
|
+
* @license
|
|
23855
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
23856
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
23857
|
+
*/
|
|
23858
|
+
|
|
23859
|
+
registerStyles('vaadin-text-field', inputFieldShared, { moduleId: 'vaadin-text-field-styles' });
|
|
23860
|
+
|
|
23861
|
+
/**
|
|
23862
|
+
* `<vaadin-text-field>` is a web component that allows the user to input and edit text.
|
|
23863
|
+
*
|
|
23864
|
+
* ```html
|
|
23865
|
+
* <vaadin-text-field label="First Name"></vaadin-text-field>
|
|
23866
|
+
* ```
|
|
23867
|
+
*
|
|
23868
|
+
* ### Prefixes and suffixes
|
|
23869
|
+
*
|
|
23870
|
+
* These are child elements of a `<vaadin-text-field>` that are displayed
|
|
23871
|
+
* inline with the input, before or after.
|
|
23872
|
+
* In order for an element to be considered as a prefix, it must have the slot
|
|
23873
|
+
* attribute set to `prefix` (and similarly for `suffix`).
|
|
23874
|
+
*
|
|
23875
|
+
* ```html
|
|
23876
|
+
* <vaadin-text-field label="Email address">
|
|
23877
|
+
* <div slot="prefix">Sent to:</div>
|
|
23878
|
+
* <div slot="suffix">@vaadin.com</div>
|
|
23879
|
+
* </vaadin-text-field>
|
|
23880
|
+
* ```
|
|
23881
|
+
*
|
|
23882
|
+
* ### Styling
|
|
23883
|
+
*
|
|
23884
|
+
* The following custom properties are available for styling:
|
|
23885
|
+
*
|
|
23886
|
+
* Custom property | Description | Default
|
|
23887
|
+
* -------------------------------|----------------------------|---------
|
|
23888
|
+
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
23889
|
+
*
|
|
23890
|
+
* The following shadow DOM parts are available for styling:
|
|
23891
|
+
*
|
|
23892
|
+
* Part name | Description
|
|
23893
|
+
* ---------------------|----------------
|
|
23894
|
+
* `label` | The label element
|
|
23895
|
+
* `input-field` | The element that wraps prefix, value and suffix
|
|
23896
|
+
* `clear-button` | The clear button
|
|
23897
|
+
* `error-message` | The error message element
|
|
23898
|
+
* `helper-text` | The helper text element wrapper
|
|
23899
|
+
* `required-indicator` | The `required` state indicator element
|
|
23900
|
+
*
|
|
23901
|
+
* The following state attributes are available for styling:
|
|
23902
|
+
*
|
|
23903
|
+
* Attribute | Description | Part name
|
|
23904
|
+
* --------------------|-------------|------------
|
|
23905
|
+
* `disabled` | Set to a disabled text field | :host
|
|
23906
|
+
* `has-value` | Set when the element has a value | :host
|
|
23907
|
+
* `has-label` | Set when the element has a label | :host
|
|
23908
|
+
* `has-helper` | Set when the element has helper text or slot | :host
|
|
23909
|
+
* `has-error-message` | Set when the element has an error message | :host
|
|
23910
|
+
* `invalid` | Set when the element is invalid | :host
|
|
23911
|
+
* `input-prevented` | Temporarily set when invalid input is prevented | :host
|
|
23912
|
+
* `focused` | Set when the element is focused | :host
|
|
23913
|
+
* `focus-ring` | Set when the element is keyboard focused | :host
|
|
23914
|
+
* `readonly` | Set to a readonly text field | :host
|
|
23915
|
+
*
|
|
23916
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
23917
|
+
*
|
|
23918
|
+
* @fires {Event} input - Fired when the value is changed by the user: on every typing keystroke, and the value is cleared using the clear button.
|
|
23919
|
+
* @fires {Event} change - Fired when the user commits a value change.
|
|
23920
|
+
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
23921
|
+
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
23922
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
23923
|
+
*
|
|
23924
|
+
* @extends HTMLElement
|
|
23925
|
+
* @mixes ElementMixin
|
|
23926
|
+
* @mixes ThemableMixin
|
|
23927
|
+
* @mixes PatternMixin
|
|
23928
|
+
* @mixes InputFieldMixin
|
|
23929
|
+
*/
|
|
23930
|
+
class TextField extends PatternMixin(InputFieldMixin(ThemableMixin(ElementMixin(PolymerElement)))) {
|
|
23931
|
+
static get is() {
|
|
23932
|
+
return 'vaadin-text-field';
|
|
23933
|
+
}
|
|
23934
|
+
|
|
23935
|
+
static get template() {
|
|
23936
|
+
return html`
|
|
23937
|
+
<style>
|
|
23938
|
+
[part='input-field'] {
|
|
23939
|
+
flex-grow: 0;
|
|
23940
|
+
}
|
|
23941
|
+
</style>
|
|
23942
|
+
|
|
23943
|
+
<div class="vaadin-field-container">
|
|
23944
|
+
<div part="label">
|
|
23945
|
+
<slot name="label"></slot>
|
|
23946
|
+
<span part="required-indicator" aria-hidden="true" on-click="focus"></span>
|
|
23947
|
+
</div>
|
|
23948
|
+
|
|
23949
|
+
<vaadin-input-container
|
|
23950
|
+
part="input-field"
|
|
23951
|
+
readonly="[[readonly]]"
|
|
23952
|
+
disabled="[[disabled]]"
|
|
23953
|
+
invalid="[[invalid]]"
|
|
23954
|
+
theme$="[[_theme]]"
|
|
23955
|
+
>
|
|
23956
|
+
<slot name="prefix" slot="prefix"></slot>
|
|
23957
|
+
<slot name="input"></slot>
|
|
23958
|
+
<slot name="suffix" slot="suffix"></slot>
|
|
23959
|
+
<div id="clearButton" part="clear-button" slot="suffix" aria-hidden="true"></div>
|
|
23960
|
+
</vaadin-input-container>
|
|
23961
|
+
|
|
23962
|
+
<div part="helper-text">
|
|
23963
|
+
<slot name="helper"></slot>
|
|
23964
|
+
</div>
|
|
23965
|
+
|
|
23966
|
+
<div part="error-message">
|
|
23967
|
+
<slot name="error-message"></slot>
|
|
23968
|
+
</div>
|
|
23969
|
+
</div>
|
|
23970
|
+
<slot name="tooltip"></slot>
|
|
23971
|
+
`;
|
|
23972
|
+
}
|
|
23973
|
+
|
|
23974
|
+
static get properties() {
|
|
23975
|
+
return {
|
|
23976
|
+
/**
|
|
23977
|
+
* Maximum number of characters (in Unicode code points) that the user can enter.
|
|
23978
|
+
*/
|
|
23979
|
+
maxlength: {
|
|
23980
|
+
type: Number,
|
|
23981
|
+
},
|
|
23982
|
+
|
|
23983
|
+
/**
|
|
23984
|
+
* Minimum number of characters (in Unicode code points) that the user can enter.
|
|
23985
|
+
*/
|
|
23986
|
+
minlength: {
|
|
23987
|
+
type: Number,
|
|
23988
|
+
},
|
|
23989
|
+
};
|
|
23990
|
+
}
|
|
23991
|
+
|
|
23992
|
+
static get delegateAttrs() {
|
|
23993
|
+
return [...super.delegateAttrs, 'maxlength', 'minlength'];
|
|
23994
|
+
}
|
|
23995
|
+
|
|
23996
|
+
static get constraints() {
|
|
23997
|
+
return [...super.constraints, 'maxlength', 'minlength'];
|
|
23998
|
+
}
|
|
23999
|
+
|
|
24000
|
+
constructor() {
|
|
24001
|
+
super();
|
|
24002
|
+
this._setType('text');
|
|
24003
|
+
}
|
|
24004
|
+
|
|
24005
|
+
/** @protected */
|
|
24006
|
+
get clearElement() {
|
|
24007
|
+
return this.$.clearButton;
|
|
24008
|
+
}
|
|
24009
|
+
|
|
24010
|
+
/** @protected */
|
|
24011
|
+
ready() {
|
|
24012
|
+
super.ready();
|
|
24013
|
+
|
|
24014
|
+
this.addController(
|
|
24015
|
+
new InputController(this, (input) => {
|
|
24016
|
+
this._setInputElement(input);
|
|
24017
|
+
this._setFocusElement(input);
|
|
24018
|
+
this.stateTarget = input;
|
|
24019
|
+
this.ariaTarget = input;
|
|
24020
|
+
}),
|
|
24021
|
+
);
|
|
24022
|
+
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
24023
|
+
|
|
24024
|
+
this._tooltipController = new TooltipController(this);
|
|
24025
|
+
this._tooltipController.setPosition('top');
|
|
24026
|
+
this.addController(this._tooltipController);
|
|
24027
|
+
}
|
|
24028
|
+
}
|
|
24029
|
+
|
|
24030
|
+
customElements.define(TextField.is, TextField);
|
|
24031
|
+
|
|
24032
|
+
/**
|
|
24033
|
+
* @license
|
|
24034
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
24035
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
24036
|
+
*/
|
|
24037
|
+
|
|
24038
|
+
const passwordFieldButton = i$1`
|
|
24039
|
+
:host {
|
|
24040
|
+
position: absolute;
|
|
24041
|
+
right: 0;
|
|
24042
|
+
top: 0;
|
|
24043
|
+
margin: 0;
|
|
24044
|
+
padding: 0;
|
|
24045
|
+
width: 100%;
|
|
24046
|
+
height: 100%;
|
|
24047
|
+
min-width: auto;
|
|
24048
|
+
background: transparent;
|
|
24049
|
+
outline: none;
|
|
24050
|
+
}
|
|
24051
|
+
`;
|
|
24052
|
+
|
|
24053
|
+
registerStyles('vaadin-password-field-button', [button, passwordFieldButton], {
|
|
24054
|
+
moduleId: 'lumo-password-field-button',
|
|
24055
|
+
});
|
|
24056
|
+
|
|
24057
|
+
/**
|
|
24058
|
+
* @license
|
|
24059
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
24060
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
24061
|
+
*/
|
|
24062
|
+
|
|
24063
|
+
const passwordField = i$1`
|
|
24064
|
+
[part='reveal-button']::before {
|
|
24065
|
+
content: var(--lumo-icons-eye);
|
|
24066
|
+
}
|
|
24067
|
+
|
|
24068
|
+
:host([password-visible]) [part='reveal-button']::before {
|
|
24069
|
+
content: var(--lumo-icons-eye-disabled);
|
|
24070
|
+
}
|
|
24071
|
+
|
|
24072
|
+
/* Make it easy to hide the button across the whole app */
|
|
24073
|
+
[part='reveal-button'] {
|
|
24074
|
+
position: relative;
|
|
24075
|
+
display: var(--lumo-password-field-reveal-button-display, block);
|
|
24076
|
+
}
|
|
24077
|
+
|
|
24078
|
+
[part='reveal-button'][hidden] {
|
|
24079
|
+
display: none !important;
|
|
24080
|
+
}
|
|
24081
|
+
`;
|
|
24082
|
+
|
|
24083
|
+
registerStyles('vaadin-password-field', [inputFieldShared$1, passwordField], { moduleId: 'lumo-password-field' });
|
|
24084
|
+
|
|
24085
|
+
/**
|
|
24086
|
+
* @license
|
|
24087
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
24088
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
24089
|
+
*/
|
|
24090
|
+
|
|
24091
|
+
/**
|
|
24092
|
+
* An element used internally by `<vaadin-password-field>`. Not intended to be used separately.
|
|
24093
|
+
*
|
|
24094
|
+
* @extends Button
|
|
24095
|
+
* @private
|
|
24096
|
+
*/
|
|
24097
|
+
class PasswordFieldButton extends Button {
|
|
24098
|
+
static get is() {
|
|
24099
|
+
return 'vaadin-password-field-button';
|
|
24100
|
+
}
|
|
24101
|
+
|
|
24102
|
+
static get template() {
|
|
24103
|
+
return html`
|
|
24104
|
+
<style>
|
|
24105
|
+
:host {
|
|
24106
|
+
display: block;
|
|
24107
|
+
}
|
|
24108
|
+
|
|
24109
|
+
:host([hidden]) {
|
|
24110
|
+
display: none !important;
|
|
24111
|
+
}
|
|
24112
|
+
</style>
|
|
24113
|
+
<slot name="tooltip"></slot>
|
|
24114
|
+
`;
|
|
24115
|
+
}
|
|
24116
|
+
}
|
|
24117
|
+
|
|
24118
|
+
customElements.define(PasswordFieldButton.is, PasswordFieldButton);
|
|
24119
|
+
|
|
24120
|
+
/**
|
|
24121
|
+
* @license
|
|
24122
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
24123
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
24124
|
+
*/
|
|
24125
|
+
|
|
24126
|
+
const ownTemplate = html`
|
|
24127
|
+
<div part="reveal-button" slot="suffix">
|
|
24128
|
+
<slot name="reveal"></slot>
|
|
24129
|
+
</div>
|
|
24130
|
+
`;
|
|
24131
|
+
|
|
24132
|
+
let memoizedTemplate$1;
|
|
24133
|
+
|
|
24134
|
+
/**
|
|
24135
|
+
* `<vaadin-password-field>` is an extension of `<vaadin-text-field>` component for entering passwords.
|
|
24136
|
+
*
|
|
24137
|
+
* ```html
|
|
24138
|
+
* <vaadin-password-field label="Password"></vaadin-password-field>
|
|
24139
|
+
* ```
|
|
24140
|
+
*
|
|
24141
|
+
* ### Styling
|
|
24142
|
+
*
|
|
24143
|
+
* `<vaadin-password-field>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.
|
|
24144
|
+
* See [`<vaadin-text-field>`](#/elements/vaadin-text-field) for the styling documentation.
|
|
24145
|
+
*
|
|
24146
|
+
* In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
|
|
24147
|
+
*
|
|
24148
|
+
* Part name | Description
|
|
24149
|
+
* ----------------|----------------------------------------------------
|
|
24150
|
+
* `reveal-button` | The eye icon which toggles the password visibility
|
|
24151
|
+
*
|
|
24152
|
+
* In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
|
|
24153
|
+
*
|
|
24154
|
+
* Attribute | Description
|
|
24155
|
+
* -------------------|---------------------------------
|
|
24156
|
+
* `password-visible` | Set when the password is visible
|
|
24157
|
+
*
|
|
24158
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
24159
|
+
*
|
|
24160
|
+
* @fires {Event} input - Fired when the value is changed by the user: on every typing keystroke, and the value is cleared using the clear button.
|
|
24161
|
+
* @fires {Event} change - Fired when the user commits a value change.
|
|
24162
|
+
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
24163
|
+
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
24164
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
24165
|
+
*
|
|
24166
|
+
* @extends TextField
|
|
24167
|
+
*/
|
|
24168
|
+
class PasswordField extends TextField {
|
|
24169
|
+
static get is() {
|
|
24170
|
+
return 'vaadin-password-field';
|
|
24171
|
+
}
|
|
24172
|
+
|
|
24173
|
+
static get template() {
|
|
24174
|
+
if (!memoizedTemplate$1) {
|
|
24175
|
+
// Clone the superclass template
|
|
24176
|
+
memoizedTemplate$1 = super.template.cloneNode(true);
|
|
24177
|
+
|
|
24178
|
+
// Retrieve this element's dom-module template
|
|
24179
|
+
const revealButton = ownTemplate.content.querySelector('[part="reveal-button"]');
|
|
24180
|
+
|
|
24181
|
+
// Append reveal-button and styles to the text-field template
|
|
24182
|
+
const inputField = memoizedTemplate$1.content.querySelector('[part="input-field"]');
|
|
24183
|
+
inputField.appendChild(revealButton);
|
|
24184
|
+
}
|
|
24185
|
+
|
|
24186
|
+
return memoizedTemplate$1;
|
|
24187
|
+
}
|
|
24188
|
+
|
|
24189
|
+
static get properties() {
|
|
24190
|
+
return {
|
|
24191
|
+
/**
|
|
24192
|
+
* Set to true to hide the eye icon which toggles the password visibility.
|
|
24193
|
+
* @attr {boolean} reveal-button-hidden
|
|
24194
|
+
*/
|
|
24195
|
+
revealButtonHidden: {
|
|
24196
|
+
type: Boolean,
|
|
24197
|
+
observer: '_revealButtonHiddenChanged',
|
|
24198
|
+
value: false,
|
|
24199
|
+
},
|
|
24200
|
+
|
|
24201
|
+
/**
|
|
24202
|
+
* True if the password is visible ([type=text]).
|
|
24203
|
+
* @attr {boolean} password-visible
|
|
24204
|
+
*/
|
|
24205
|
+
passwordVisible: {
|
|
24206
|
+
type: Boolean,
|
|
24207
|
+
value: false,
|
|
24208
|
+
reflectToAttribute: true,
|
|
24209
|
+
observer: '_passwordVisibleChanged',
|
|
24210
|
+
readOnly: true,
|
|
24211
|
+
},
|
|
24212
|
+
|
|
24213
|
+
/**
|
|
24214
|
+
* An object with translated strings used for localization.
|
|
24215
|
+
* It has the following structure and default values:
|
|
24216
|
+
*
|
|
24217
|
+
* ```
|
|
24218
|
+
* {
|
|
24219
|
+
* // Translation of the reveal icon button accessible label
|
|
24220
|
+
* reveal: 'Show password'
|
|
24221
|
+
* }
|
|
24222
|
+
* ```
|
|
24223
|
+
*/
|
|
24224
|
+
i18n: {
|
|
24225
|
+
type: Object,
|
|
24226
|
+
value: () => {
|
|
24227
|
+
return {
|
|
24228
|
+
reveal: 'Show password',
|
|
24229
|
+
};
|
|
24230
|
+
},
|
|
24231
|
+
},
|
|
24232
|
+
};
|
|
24233
|
+
}
|
|
24234
|
+
|
|
24235
|
+
static get observers() {
|
|
24236
|
+
return ['__i18nChanged(i18n.*)'];
|
|
24237
|
+
}
|
|
24238
|
+
|
|
24239
|
+
/** @protected */
|
|
24240
|
+
get slotStyles() {
|
|
24241
|
+
const tag = this.localName;
|
|
24242
|
+
return [
|
|
24243
|
+
...super.slotStyles,
|
|
24244
|
+
`
|
|
24245
|
+
${tag} [slot="input"]::-ms-reveal {
|
|
24246
|
+
display: none;
|
|
24247
|
+
}
|
|
24248
|
+
`,
|
|
24249
|
+
];
|
|
24250
|
+
}
|
|
24251
|
+
|
|
24252
|
+
/** @protected */
|
|
24253
|
+
get _revealNode() {
|
|
24254
|
+
return this._revealButtonController && this._revealButtonController.node;
|
|
24255
|
+
}
|
|
24256
|
+
|
|
24257
|
+
constructor() {
|
|
24258
|
+
super();
|
|
24259
|
+
this._setType('password');
|
|
24260
|
+
this.__boundRevealButtonClick = this._onRevealButtonClick.bind(this);
|
|
24261
|
+
this.__boundRevealButtonTouchend = this._onRevealButtonTouchend.bind(this);
|
|
24262
|
+
}
|
|
24263
|
+
|
|
24264
|
+
/** @protected */
|
|
24265
|
+
ready() {
|
|
24266
|
+
super.ready();
|
|
24267
|
+
|
|
24268
|
+
this._revealPart = this.shadowRoot.querySelector('[part="reveal-button"]');
|
|
24269
|
+
|
|
24270
|
+
this._revealButtonController = new SlotController(
|
|
24271
|
+
this,
|
|
24272
|
+
'reveal',
|
|
24273
|
+
() => document.createElement('vaadin-password-field-button'),
|
|
24274
|
+
(host, btn) => {
|
|
24275
|
+
btn.disabled = host.disabled;
|
|
24276
|
+
|
|
24277
|
+
btn.addEventListener('click', host.__boundRevealButtonClick);
|
|
24278
|
+
btn.addEventListener('touchend', host.__boundRevealButtonTouchend);
|
|
24279
|
+
},
|
|
24280
|
+
);
|
|
24281
|
+
this.addController(this._revealButtonController);
|
|
24282
|
+
|
|
24283
|
+
this.__updateAriaLabel(this.i18n);
|
|
24284
|
+
|
|
24285
|
+
this._updateToggleState(false);
|
|
24286
|
+
this._toggleRevealHidden(this.revealButtonHidden);
|
|
24287
|
+
|
|
24288
|
+
if (this.inputElement) {
|
|
24289
|
+
this.inputElement.autocapitalize = 'off';
|
|
24290
|
+
}
|
|
24291
|
+
}
|
|
24292
|
+
|
|
24293
|
+
/**
|
|
24294
|
+
* Override method inherited from `FocusMixin` to mark field as focused
|
|
24295
|
+
* when focus moves to the reveal button using Shift Tab.
|
|
24296
|
+
* @param {Event} event
|
|
24297
|
+
* @return {boolean}
|
|
24298
|
+
* @protected
|
|
24299
|
+
*/
|
|
24300
|
+
_shouldSetFocus(event) {
|
|
24301
|
+
return event.target === this.inputElement || event.target === this._revealNode;
|
|
24302
|
+
}
|
|
24303
|
+
|
|
24304
|
+
/**
|
|
24305
|
+
* Override method inherited from `FocusMixin` to not hide password
|
|
24306
|
+
* when focus moves to the reveal button or back to the input.
|
|
24307
|
+
* @param {Event} event
|
|
24308
|
+
* @return {boolean}
|
|
24309
|
+
* @protected
|
|
24310
|
+
*/
|
|
24311
|
+
_shouldRemoveFocus(event) {
|
|
24312
|
+
return !(
|
|
24313
|
+
event.relatedTarget === this._revealNode ||
|
|
24314
|
+
(event.relatedTarget === this.inputElement && event.target === this._revealNode)
|
|
24315
|
+
);
|
|
24316
|
+
}
|
|
24317
|
+
|
|
24318
|
+
/**
|
|
24319
|
+
* Override method inherited from `FocusMixin` to toggle password visibility.
|
|
24320
|
+
* @param {boolean} focused
|
|
24321
|
+
* @protected
|
|
24322
|
+
* @override
|
|
24323
|
+
*/
|
|
24324
|
+
_setFocused(focused) {
|
|
24325
|
+
super._setFocused(focused);
|
|
24326
|
+
|
|
24327
|
+
if (!focused) {
|
|
24328
|
+
this._setPasswordVisible(false);
|
|
24329
|
+
} else {
|
|
24330
|
+
const isButtonFocused = this.getRootNode().activeElement === this._revealNode;
|
|
24331
|
+
// Remove focus-ring from the field when the reveal button gets focused
|
|
24332
|
+
this.toggleAttribute('focus-ring', this._keyboardActive && !isButtonFocused);
|
|
24333
|
+
}
|
|
24334
|
+
}
|
|
24335
|
+
|
|
24336
|
+
/** @private */
|
|
24337
|
+
__updateAriaLabel(i18n) {
|
|
24338
|
+
if (i18n.reveal && this._revealNode) {
|
|
24339
|
+
this._revealNode.setAttribute('aria-label', i18n.reveal);
|
|
24340
|
+
}
|
|
24341
|
+
}
|
|
24342
|
+
|
|
24343
|
+
/** @private */
|
|
24344
|
+
__i18nChanged(i18n) {
|
|
24345
|
+
this.__updateAriaLabel(i18n.base);
|
|
24346
|
+
}
|
|
24347
|
+
|
|
24348
|
+
/** @private */
|
|
24349
|
+
_revealButtonHiddenChanged(hidden) {
|
|
24350
|
+
this._toggleRevealHidden(hidden);
|
|
24351
|
+
}
|
|
24352
|
+
|
|
24353
|
+
/** @private */
|
|
24354
|
+
_togglePasswordVisibility() {
|
|
24355
|
+
this._setPasswordVisible(!this.passwordVisible);
|
|
24356
|
+
}
|
|
24357
|
+
|
|
24358
|
+
/** @private */
|
|
24359
|
+
_onRevealButtonClick() {
|
|
24360
|
+
this._togglePasswordVisibility();
|
|
24361
|
+
}
|
|
24362
|
+
|
|
24363
|
+
/** @private */
|
|
24364
|
+
_onRevealButtonTouchend(e) {
|
|
24365
|
+
// Cancel the following click event
|
|
24366
|
+
e.preventDefault();
|
|
24367
|
+
this._togglePasswordVisibility();
|
|
24368
|
+
// Focus the input to avoid problem with password still visible
|
|
24369
|
+
// when user clicks the reveal button and then clicks outside.
|
|
24370
|
+
this.inputElement.focus();
|
|
24371
|
+
}
|
|
24372
|
+
|
|
24373
|
+
/** @private */
|
|
24374
|
+
_toggleRevealHidden(hidden) {
|
|
24375
|
+
if (this._revealNode) {
|
|
24376
|
+
if (hidden) {
|
|
24377
|
+
this._revealPart.setAttribute('hidden', '');
|
|
24378
|
+
this._revealNode.setAttribute('tabindex', '-1');
|
|
24379
|
+
this._revealNode.setAttribute('aria-hidden', 'true');
|
|
24380
|
+
} else {
|
|
24381
|
+
this._revealPart.removeAttribute('hidden');
|
|
24382
|
+
this._revealNode.setAttribute('tabindex', '0');
|
|
24383
|
+
this._revealNode.removeAttribute('aria-hidden');
|
|
24384
|
+
}
|
|
24385
|
+
}
|
|
24386
|
+
}
|
|
24387
|
+
|
|
24388
|
+
/** @private */
|
|
24389
|
+
_updateToggleState(passwordVisible) {
|
|
24390
|
+
if (this._revealNode) {
|
|
24391
|
+
this._revealNode.setAttribute('aria-pressed', passwordVisible ? 'true' : 'false');
|
|
24392
|
+
}
|
|
24393
|
+
}
|
|
24394
|
+
|
|
24395
|
+
/** @private */
|
|
24396
|
+
_passwordVisibleChanged(passwordVisible) {
|
|
24397
|
+
this._setType(passwordVisible ? 'text' : 'password');
|
|
24398
|
+
|
|
24399
|
+
this._updateToggleState(passwordVisible);
|
|
24400
|
+
}
|
|
24401
|
+
|
|
24402
|
+
/**
|
|
24403
|
+
* Override method inherited from `DisabledMixin` to synchronize the reveal button
|
|
24404
|
+
* disabled state with the password field disabled state.
|
|
24405
|
+
* @param {boolean} disabled
|
|
24406
|
+
* @param {boolean} oldDisabled
|
|
24407
|
+
* @protected
|
|
24408
|
+
*/
|
|
24409
|
+
_disabledChanged(disabled, oldDisabled) {
|
|
24410
|
+
super._disabledChanged(disabled, oldDisabled);
|
|
24411
|
+
|
|
24412
|
+
if (this._revealNode) {
|
|
24413
|
+
this._revealNode.disabled = disabled;
|
|
24414
|
+
}
|
|
24415
|
+
}
|
|
24416
|
+
}
|
|
24417
|
+
|
|
24418
|
+
customElements.define(PasswordField.is, PasswordField);
|
|
24419
|
+
|
|
24420
|
+
const passwordInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.password{font-family:\"Roboto\";font-style:normal}.password__wrapper{position:relative;width:100%;padding-top:26px}.password__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.password__label--required::after{content:\"*\";font-family:inherit;color:#1F1F1F;margin-left:2px}.password__input{width:inherit;border:none}.password__input[focused]::part(input-field){border-color:#3E3E3E}.password__input[invalid]::part(input-field){border-color:#cc0000b3}.password__input::part(input-field){border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px;color:#2A2E3F;width:100%;position:relative;border:2px solid #DEE1EE}.password__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}";
|
|
24421
|
+
|
|
24422
|
+
const PasswordInput = class {
|
|
24423
|
+
constructor(hostRef) {
|
|
24424
|
+
registerInstance(this, hostRef);
|
|
24425
|
+
this.sendValidityState = createEvent(this, "sendValidityState", 7);
|
|
24426
|
+
this.sendInputValue = createEvent(this, "sendInputValue", 7);
|
|
24427
|
+
/**
|
|
24428
|
+
* Default value for the input.
|
|
24429
|
+
*/
|
|
24430
|
+
this.defaultValue = '';
|
|
24431
|
+
this.value = '';
|
|
24432
|
+
this.validationPattern = '';
|
|
24433
|
+
}
|
|
24434
|
+
validityChanged() {
|
|
24435
|
+
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
24436
|
+
if (this.emitValue == true) {
|
|
24437
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
24438
|
+
}
|
|
24439
|
+
}
|
|
24440
|
+
emitValueHandler(newValue) {
|
|
24441
|
+
if (newValue == true && this.isValid) {
|
|
24442
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
24443
|
+
}
|
|
24444
|
+
}
|
|
24445
|
+
validityStateHandler(inputStateEvent) {
|
|
24446
|
+
this.sendValidityState.emit(inputStateEvent);
|
|
24447
|
+
}
|
|
24448
|
+
valueHandler(inputValueEvent) {
|
|
24449
|
+
this.sendInputValue.emit(inputValueEvent);
|
|
24450
|
+
}
|
|
24451
|
+
valueChangedHandler(event) {
|
|
24452
|
+
if (this.isDuplicateInput) {
|
|
24453
|
+
if (this.name === event.detail.name + 'Duplicate') {
|
|
24454
|
+
this.duplicateInputValue = event.detail.value;
|
|
24455
|
+
}
|
|
24456
|
+
}
|
|
24457
|
+
}
|
|
24458
|
+
connectedCallback() {
|
|
24459
|
+
this.validationPattern = this.setPattern();
|
|
24460
|
+
}
|
|
24461
|
+
componentDidLoad() {
|
|
24462
|
+
this.inputReference = this.element.shadowRoot.querySelector('input');
|
|
24463
|
+
if (this.defaultValue) {
|
|
24464
|
+
this.value = this.defaultValue;
|
|
24465
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
24466
|
+
}
|
|
24467
|
+
}
|
|
24468
|
+
handleInput(event) {
|
|
24469
|
+
this.value = event.target.value;
|
|
24470
|
+
this.errorMessage = this.setErrorMessage();
|
|
24471
|
+
this.isValid = this.setValidity();
|
|
24472
|
+
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
24473
|
+
this.emitValueHandler(true);
|
|
24474
|
+
}
|
|
24475
|
+
setValidity() {
|
|
24476
|
+
return this.inputReference.validity.valid;
|
|
24477
|
+
}
|
|
24478
|
+
setPattern() {
|
|
24479
|
+
var _a, _b;
|
|
24480
|
+
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
24481
|
+
return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
|
|
24482
|
+
}
|
|
24483
|
+
}
|
|
24484
|
+
setErrorMessage() {
|
|
24485
|
+
var _a;
|
|
24486
|
+
if (this.inputReference.validity.patternMismatch) {
|
|
24487
|
+
return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
|
|
24488
|
+
}
|
|
24489
|
+
if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
|
|
24490
|
+
return translate$2('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
|
|
24491
|
+
}
|
|
24492
|
+
if (this.inputReference.validity.valueMissing) {
|
|
24493
|
+
return translate$2('requiredError', this.language);
|
|
24494
|
+
}
|
|
24495
|
+
if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
|
|
24496
|
+
return this.validation.custom.find(customRule => customRule.rule === 'duplicate-input').errorMessage;
|
|
24497
|
+
}
|
|
24498
|
+
}
|
|
24499
|
+
render() {
|
|
24500
|
+
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'password__input--invalid';
|
|
24501
|
+
return h$2("div", { class: 'password__wrapper' }, h$2("vaadin-password-field", { type: "password", id: `${this.name}__input`, class: `password__input ${invalidClass}`, name: this.name, readOnly: this.autofilled, value: this.defaultValue,
|
|
24502
|
+
// ref={(el) => this.inputReference = el as HTMLInputElement}
|
|
24503
|
+
required: this.validation.mandatory, maxlength: this.validation.maxLength, minlength: this.validation.minLength, pattern: this.validationPattern, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, onBlur: (e) => this.handleInput(e) }), h$2("label", { class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h$2("small", { class: 'password__error-message' }, this.errorMessage));
|
|
24504
|
+
}
|
|
24505
|
+
get element() { return getElement(this); }
|
|
24506
|
+
static get watchers() { return {
|
|
24507
|
+
"isValid": ["validityChanged"],
|
|
24508
|
+
"emitValue": ["emitValueHandler"]
|
|
24509
|
+
}; }
|
|
24510
|
+
};
|
|
24511
|
+
PasswordInput.style = passwordInputCss;
|
|
24512
|
+
|
|
24513
|
+
const radioInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.radio__fieldset{border:none;position:relative}.radio__wrapper{display:flex;gap:5px}.radio__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}";
|
|
24514
|
+
|
|
24515
|
+
const RadioInput = class {
|
|
24516
|
+
constructor(hostRef) {
|
|
24517
|
+
registerInstance(this, hostRef);
|
|
24518
|
+
this.sendInputValue = createEvent(this, "sendInputValue", 7);
|
|
24519
|
+
this.sendValidityState = createEvent(this, "sendValidityState", 7);
|
|
24520
|
+
}
|
|
24521
|
+
validityChanged() {
|
|
24522
|
+
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
24523
|
+
if (this.emitValue == true) {
|
|
24524
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
24525
|
+
}
|
|
24526
|
+
}
|
|
24527
|
+
emitValueHandler(newValue) {
|
|
24528
|
+
if (newValue == true && this.isValid) {
|
|
24529
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
24530
|
+
}
|
|
24531
|
+
}
|
|
24532
|
+
valueHandler(inputValueEvent) {
|
|
24533
|
+
this.sendInputValue.emit(inputValueEvent);
|
|
23846
24534
|
}
|
|
23847
24535
|
validityStateHandler(inputStateEvent) {
|
|
23848
24536
|
this.sendValidityState.emit(inputStateEvent);
|
|
@@ -26230,87 +26918,6 @@ class ComboBoxScroller extends PolymerElement {
|
|
|
26230
26918
|
|
|
26231
26919
|
customElements.define(ComboBoxScroller.is, ComboBoxScroller);
|
|
26232
26920
|
|
|
26233
|
-
/**
|
|
26234
|
-
* @license
|
|
26235
|
-
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
26236
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
26237
|
-
*/
|
|
26238
|
-
|
|
26239
|
-
/**
|
|
26240
|
-
* A mixin to provide `pattern` and `preventInvalidInput` properties.
|
|
26241
|
-
*
|
|
26242
|
-
* @polymerMixin
|
|
26243
|
-
* @mixes InputConstraintsMixin
|
|
26244
|
-
*/
|
|
26245
|
-
const PatternMixin = (superclass) =>
|
|
26246
|
-
class PatternMixinClass extends InputConstraintsMixin(superclass) {
|
|
26247
|
-
static get properties() {
|
|
26248
|
-
return {
|
|
26249
|
-
/**
|
|
26250
|
-
* A regular expression that the value is checked against.
|
|
26251
|
-
* The pattern must match the entire value, not just some subset.
|
|
26252
|
-
*/
|
|
26253
|
-
pattern: {
|
|
26254
|
-
type: String,
|
|
26255
|
-
},
|
|
26256
|
-
|
|
26257
|
-
/**
|
|
26258
|
-
* When set to true, user is prevented from typing a value that
|
|
26259
|
-
* conflicts with the given `pattern`.
|
|
26260
|
-
* @attr {boolean} prevent-invalid-input
|
|
26261
|
-
* @deprecated Please use `allowedCharPattern` instead.
|
|
26262
|
-
*/
|
|
26263
|
-
preventInvalidInput: {
|
|
26264
|
-
type: Boolean,
|
|
26265
|
-
observer: '_preventInvalidInputChanged',
|
|
26266
|
-
},
|
|
26267
|
-
};
|
|
26268
|
-
}
|
|
26269
|
-
|
|
26270
|
-
static get delegateAttrs() {
|
|
26271
|
-
return [...super.delegateAttrs, 'pattern'];
|
|
26272
|
-
}
|
|
26273
|
-
|
|
26274
|
-
static get constraints() {
|
|
26275
|
-
return [...super.constraints, 'pattern'];
|
|
26276
|
-
}
|
|
26277
|
-
|
|
26278
|
-
/** @private */
|
|
26279
|
-
_checkInputValue() {
|
|
26280
|
-
if (this.preventInvalidInput) {
|
|
26281
|
-
const input = this.inputElement;
|
|
26282
|
-
if (input && input.value.length > 0 && !this.checkValidity()) {
|
|
26283
|
-
input.value = this.value || '';
|
|
26284
|
-
// Add input-prevented attribute for 200ms
|
|
26285
|
-
this.setAttribute('input-prevented', '');
|
|
26286
|
-
this._inputDebouncer = Debouncer$1.debounce(this._inputDebouncer, timeOut.after(200), () => {
|
|
26287
|
-
this.removeAttribute('input-prevented');
|
|
26288
|
-
});
|
|
26289
|
-
}
|
|
26290
|
-
}
|
|
26291
|
-
}
|
|
26292
|
-
|
|
26293
|
-
/**
|
|
26294
|
-
* @param {Event} event
|
|
26295
|
-
* @protected
|
|
26296
|
-
* @override
|
|
26297
|
-
*/
|
|
26298
|
-
_onInput(event) {
|
|
26299
|
-
this._checkInputValue();
|
|
26300
|
-
|
|
26301
|
-
super._onInput(event);
|
|
26302
|
-
}
|
|
26303
|
-
|
|
26304
|
-
/** @private */
|
|
26305
|
-
_preventInvalidInputChanged(preventInvalidInput) {
|
|
26306
|
-
if (preventInvalidInput) {
|
|
26307
|
-
console.warn(
|
|
26308
|
-
`WARNING: Since Vaadin 23.2, "preventInvalidInput" is deprecated. Please use "allowedCharPattern" instead.`,
|
|
26309
|
-
);
|
|
26310
|
-
}
|
|
26311
|
-
}
|
|
26312
|
-
};
|
|
26313
|
-
|
|
26314
26921
|
/**
|
|
26315
26922
|
* @license
|
|
26316
26923
|
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
@@ -28296,7 +28903,7 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
28296
28903
|
|
|
28297
28904
|
customElements.define(ComboBox.is, ComboBox);
|
|
28298
28905
|
|
|
28299
|
-
const selectInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.select__wrapper{position:relative;
|
|
28906
|
+
const selectInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.select{font-family:\"Roboto\";font-style:normal}.select__wrapper{position:relative;width:100%;padding-top:26px}.select__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.select__label--required::after{content:\"*\";font-family:inherit;color:#1F1F1F;margin-left:2px}.select__input{border:none;width:inherit;position:relative}.select__input[focused]::part(input-field){border-color:#3E3E3E}.select__input[invalid]::part(input-field){border-color:#cc0000b3}.select__input vaadin-date-picker-overlay-content>vaadin-button{color:#1F1F1F}.select__input vaadin-month-calendar::part(selected date){background-color:red}.select__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}.select__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}";
|
|
28300
28907
|
|
|
28301
28908
|
const SelectInput = class {
|
|
28302
28909
|
constructor(hostRef) {
|
|
@@ -28345,6 +28952,10 @@ const SelectInput = class {
|
|
|
28345
28952
|
}
|
|
28346
28953
|
componentDidLoad() {
|
|
28347
28954
|
this.inputReference = this.element.shadowRoot.querySelector('input');
|
|
28955
|
+
if (this.defaultValue) {
|
|
28956
|
+
this.value = this.defaultValue;
|
|
28957
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
28958
|
+
}
|
|
28348
28959
|
}
|
|
28349
28960
|
getOptions() {
|
|
28350
28961
|
// TEMPORARY FOR DEMO PURPOSES UNTIL NORWAY CONFIGURES AN ACTUAL ENDPOINT...
|
|
@@ -28366,7 +28977,6 @@ const SelectInput = class {
|
|
|
28366
28977
|
this.isValid = this.setValidity();
|
|
28367
28978
|
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
28368
28979
|
this.emitValueHandler(true);
|
|
28369
|
-
this.inputReference.previousElementSibling.classList.remove('select__label--hidden');
|
|
28370
28980
|
}
|
|
28371
28981
|
setValidity() {
|
|
28372
28982
|
return this.inputReference.validity.valid;
|
|
@@ -28377,7 +28987,8 @@ const SelectInput = class {
|
|
|
28377
28987
|
}
|
|
28378
28988
|
}
|
|
28379
28989
|
render() {
|
|
28380
|
-
|
|
28990
|
+
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'select__input--invalid';
|
|
28991
|
+
return h$2("div", { class: 'select__wrapper' }, h$2("label", { class: 'select__label', htmlFor: `${this.name}__input` }, `${this.displayName} ${this.validation.mandatory ? '*' : ''}`), h$2("vaadin-combo-box", { name: this.name, id: `${this.name}__input`, class: `select__input ${invalidClass}`, "item-label-path": "label", "item-value-path": "value", readOnly: this.autofilled, required: this.validation.mandatory, value: this.defaultValue, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, items: this.displayedOptions, onBlur: (e) => this.handleChange(e) }), h$2("small", { class: 'select__error-message' }, this.errorMessage));
|
|
28381
28992
|
}
|
|
28382
28993
|
get element() { return getElement(this); }
|
|
28383
28994
|
static get watchers() { return {
|
|
@@ -28387,7 +28998,7 @@ const SelectInput = class {
|
|
|
28387
28998
|
};
|
|
28388
28999
|
SelectInput.style = selectInputCss;
|
|
28389
29000
|
|
|
28390
|
-
const telInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.tel__wrapper{position:relative;display:flex;
|
|
29001
|
+
const telInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.tel{font-family:\"Roboto\";font-style:normal}.tel__wrapper{position:relative;width:100%;padding-top:26px}.tel__wrapper--flex{width:inherit;display:flex;align-items:stretch;border-radius:4px;border:2px solid #DEE1EE}.tel__wrapper--flex:focus-within{border:2px solid #3E3E3E}.tel__wrapper--flex--invalid{border:2px solid #cc0000b3}.tel__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.tel__label--required::after{content:\"*\";font-family:inherit;color:#1F1F1F;margin-left:2px}.tel__prefix{width:120px}.tel__prefix[focus]{outline:none}.tel__prefix::part(input-field){border-radius:0 4px 4px 0;background-color:#DEE1EE;color:#1F1F1F;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px}.tel__input{border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px;color:#2A2E3F;border:none;padding:8px 20px;width:inherit;position:relative;-moz-appearance:textfield;}.tel__input:focus{outline:none}.tel__input::-webkit-outer-spin-button,.tel__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.tel__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}";
|
|
28391
29002
|
|
|
28392
29003
|
const TelInput = class {
|
|
28393
29004
|
constructor(hostRef) {
|
|
@@ -28415,18 +29026,28 @@ const TelInput = class {
|
|
|
28415
29026
|
}
|
|
28416
29027
|
connectedCallback() {
|
|
28417
29028
|
this.validationPattern = this.setPattern();
|
|
29029
|
+
if (this.defaultValue) {
|
|
29030
|
+
this.prefixValue = this.defaultValue.split('|')[0];
|
|
29031
|
+
this.phoneValue = this.defaultValue.split('|')[1];
|
|
29032
|
+
}
|
|
28418
29033
|
}
|
|
28419
29034
|
componentWillLoad() {
|
|
28420
29035
|
if (this.action) {
|
|
28421
29036
|
if (this.action.split(" ")[0] == 'GET') {
|
|
28422
29037
|
return this.getPhoneCodes().then((options) => {
|
|
28423
29038
|
this.phoneCodesOptions = options.phoneCodes.map(code => {
|
|
28424
|
-
return { label: code.Prefix, value: code.
|
|
29039
|
+
return { label: code.Prefix, value: code.Prefix };
|
|
28425
29040
|
});
|
|
28426
29041
|
});
|
|
28427
29042
|
}
|
|
28428
29043
|
}
|
|
28429
29044
|
}
|
|
29045
|
+
componentDidLoad() {
|
|
29046
|
+
if (this.defaultValue) {
|
|
29047
|
+
this.value = `${this.prefixValue}|${this.phoneValue}`;
|
|
29048
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
29049
|
+
}
|
|
29050
|
+
}
|
|
28430
29051
|
getPhoneCodes() {
|
|
28431
29052
|
// TEMPORARY FOR DEMO PURPOSES UNTIL NORWAY CONFIGURES AN ACTUAL ENDPOINT...
|
|
28432
29053
|
const url = new URL("https://demo-api.stage.norway.everymatrix.com/v1/player/phonecodes");
|
|
@@ -28442,7 +29063,8 @@ const TelInput = class {
|
|
|
28442
29063
|
});
|
|
28443
29064
|
}
|
|
28444
29065
|
handleInput(event) {
|
|
28445
|
-
this.
|
|
29066
|
+
this.phoneValue = event.target.value;
|
|
29067
|
+
this.value = `${this.prefixValue}|${this.phoneValue}`;
|
|
28446
29068
|
this.errorMessage = this.setErrorMessage();
|
|
28447
29069
|
this.isValid = this.setValidity();
|
|
28448
29070
|
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
@@ -28452,14 +29074,15 @@ const TelInput = class {
|
|
|
28452
29074
|
return this.inputReference.validity.valid;
|
|
28453
29075
|
}
|
|
28454
29076
|
setPattern() {
|
|
28455
|
-
var _a;
|
|
29077
|
+
var _a, _b;
|
|
28456
29078
|
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
28457
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
|
|
29079
|
+
return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
|
|
28458
29080
|
}
|
|
28459
29081
|
}
|
|
28460
29082
|
setErrorMessage() {
|
|
29083
|
+
var _a;
|
|
28461
29084
|
if (this.inputReference.validity.patternMismatch) {
|
|
28462
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
|
|
29085
|
+
return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
|
|
28463
29086
|
}
|
|
28464
29087
|
if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
|
|
28465
29088
|
return translate$2('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
|
|
@@ -28469,8 +29092,8 @@ const TelInput = class {
|
|
|
28469
29092
|
}
|
|
28470
29093
|
}
|
|
28471
29094
|
render() {
|
|
28472
|
-
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : '
|
|
28473
|
-
return h$2("div", { class: 'tel__wrapper' }, h$2("div", { class:
|
|
29095
|
+
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'tel__wrapper--flex--invalid';
|
|
29096
|
+
return h$2("div", { class: 'tel__wrapper' }, h$2("div", { class: `tel__wrapper--flex ${invalidClass}` }, h$2("vaadin-combo-box", { class: 'tel__prefix', items: this.phoneCodesOptions, value: this.prefixValue, readOnly: this.autofilled, onBlur: (e) => this.prefixValue = e.target.value }), h$2("input", { type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, readOnly: this.autofilled, class: `tel__input`, value: this.phoneValue, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onBlur: (e) => this.handleInput(e) })), h$2("label", { class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h$2("small", { class: 'tel__error-message' }, this.errorMessage));
|
|
28474
29097
|
}
|
|
28475
29098
|
static get watchers() { return {
|
|
28476
29099
|
"isValid": ["validityChanged"],
|
|
@@ -28479,7 +29102,7 @@ const TelInput = class {
|
|
|
28479
29102
|
};
|
|
28480
29103
|
TelInput.style = telInputCss;
|
|
28481
29104
|
|
|
28482
|
-
const textInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.text__wrapper{position:relative;
|
|
29105
|
+
const textInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.text{font-family:\"Roboto\";font-style:normal}.text__wrapper{position:relative;width:100%;padding-top:26px}.text__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.text__label--required::after{content:\"*\";font-family:inherit;color:#1F1F1F;margin-left:2px}.text__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}.text__input:focus{outline-color:#3E3E3E}.text__input--invalid{border:2px solid #cc0000b3}.text__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}";
|
|
28483
29106
|
|
|
28484
29107
|
const TextInput = class {
|
|
28485
29108
|
constructor(hostRef) {
|
|
@@ -28500,22 +29123,33 @@ const TextInput = class {
|
|
|
28500
29123
|
this.valueHandler({ name: this.name, value: this.value });
|
|
28501
29124
|
}
|
|
28502
29125
|
}
|
|
28503
|
-
validityStateHandler(inputStateEvent) {
|
|
28504
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
28505
|
-
}
|
|
28506
29126
|
emitValueHandler(newValue) {
|
|
28507
29127
|
if (newValue == true && this.isValid) {
|
|
28508
29128
|
this.valueHandler({ name: this.name, value: this.value });
|
|
28509
29129
|
}
|
|
28510
29130
|
}
|
|
29131
|
+
validityStateHandler(inputStateEvent) {
|
|
29132
|
+
this.sendValidityState.emit(inputStateEvent);
|
|
29133
|
+
}
|
|
28511
29134
|
valueHandler(inputValueEvent) {
|
|
28512
29135
|
this.sendInputValue.emit(inputValueEvent);
|
|
28513
29136
|
}
|
|
29137
|
+
valueChangedHandler(event) {
|
|
29138
|
+
if (this.isDuplicateInput) {
|
|
29139
|
+
if (this.name === event.detail.name + 'Duplicate') {
|
|
29140
|
+
this.duplicateInputValue = event.detail.value;
|
|
29141
|
+
}
|
|
29142
|
+
}
|
|
29143
|
+
}
|
|
28514
29144
|
connectedCallback() {
|
|
28515
|
-
// @TODO do something with customRules !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
28516
|
-
this.customRules = this.setCustomRules();
|
|
28517
29145
|
this.validationPattern = this.setPattern();
|
|
28518
29146
|
}
|
|
29147
|
+
componentDidLoad() {
|
|
29148
|
+
if (this.defaultValue) {
|
|
29149
|
+
this.value = this.defaultValue;
|
|
29150
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
29151
|
+
}
|
|
29152
|
+
}
|
|
28519
29153
|
handleInput(event) {
|
|
28520
29154
|
this.value = event.target.value;
|
|
28521
29155
|
this.isValid = this.setValidity();
|
|
@@ -28526,22 +29160,16 @@ const TextInput = class {
|
|
|
28526
29160
|
setValidity() {
|
|
28527
29161
|
return this.inputReference.validity.valid;
|
|
28528
29162
|
}
|
|
28529
|
-
// @TODO type here
|
|
28530
|
-
setCustomRules() {
|
|
28531
|
-
var _a;
|
|
28532
|
-
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
28533
|
-
return this.validation.custom.filter(customValidation => customValidation.rule !== 'regex');
|
|
28534
|
-
}
|
|
28535
|
-
}
|
|
28536
29163
|
setPattern() {
|
|
28537
|
-
var _a;
|
|
29164
|
+
var _a, _b;
|
|
28538
29165
|
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
28539
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
|
|
29166
|
+
return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
|
|
28540
29167
|
}
|
|
28541
29168
|
}
|
|
28542
29169
|
setErrorMessage() {
|
|
29170
|
+
var _a;
|
|
28543
29171
|
if (this.inputReference.validity.patternMismatch) {
|
|
28544
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
|
|
29172
|
+
return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
|
|
28545
29173
|
}
|
|
28546
29174
|
if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
|
|
28547
29175
|
return translate$2('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
|
|
@@ -28549,10 +29177,13 @@ const TextInput = class {
|
|
|
28549
29177
|
if (this.inputReference.validity.valueMissing) {
|
|
28550
29178
|
return translate$2('requiredError', this.language);
|
|
28551
29179
|
}
|
|
29180
|
+
if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
|
|
29181
|
+
return this.validation.custom.find(customRule => customRule.rule === 'duplicate-input').errorMessage;
|
|
29182
|
+
}
|
|
28552
29183
|
}
|
|
28553
29184
|
render() {
|
|
28554
29185
|
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
|
|
28555
|
-
return h$2("div", { class: 'text__wrapper' }, h$2("input", { id: `${this.name}__input`, value: this.defaultValue, type: 'text', class: `text__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, readOnly: this.autofilled, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onBlur: (e) => { this.handleInput(e); } }), h$2("
|
|
29186
|
+
return h$2("div", { class: 'text__wrapper' }, h$2("label", { class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h$2("input", { name: this.name, id: `${this.name}__input`, value: this.defaultValue, type: 'text', class: `text__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, readOnly: this.autofilled, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onBlur: (e) => { this.handleInput(e); } }), h$2("small", { class: 'text__error-message' }, this.errorMessage));
|
|
28556
29187
|
}
|
|
28557
29188
|
static get watchers() { return {
|
|
28558
29189
|
"isValid": ["validityChanged"],
|