@everymatrix/general-registration 1.10.5 → 1.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/checkbox-input_11.cjs.entry.js +1124 -526
- package/dist/cjs/general-registration.cjs.js +2 -2
- package/dist/cjs/{index-ad0df8ea.js → index-68f93e1e.js} +9 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/general-registration/general-registration.css +40 -14
- package/dist/collection/components/general-registration/general-registration.js +142 -275
- package/dist/components/checkbox-input2.js +2 -2
- package/dist/components/date-input2.js +15 -1441
- package/dist/components/email-input2.js +18 -6
- package/dist/components/general-input2.js +6 -6
- package/dist/components/general-registration.js +100 -248
- package/dist/components/input-field-shared-styles.js +13776 -0
- package/dist/components/number-input2.js +1 -1
- package/dist/components/password-input2.js +738 -6
- package/dist/components/pattern-mixin.js +84 -0
- package/dist/components/radio-input2.js +1 -1
- package/dist/components/select-input2.js +4 -4
- package/dist/components/tel-input2.js +12 -8
- package/dist/components/text-input2.js +17 -13
- package/dist/components/vaadin-button.js +1432 -0
- package/dist/components/vaadin-combo-box.js +3 -82
- package/dist/components/virtual-keyboard-controller.js +2136 -15909
- package/dist/esm/checkbox-input_11.entry.js +1124 -526
- package/dist/esm/general-registration.js +2 -2
- package/dist/esm/{index-bb9c8eb3.js → index-16916adb.js} +9 -1
- package/dist/esm/loader.js +2 -2
- package/dist/general-registration/general-registration.esm.js +1 -1
- package/dist/general-registration/p-8f644809.js +1 -0
- package/dist/general-registration/{p-8a77bab6.entry.js → p-fb5bf415.entry.js} +210 -100
- package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/types.d.ts +4 -2
- package/dist/types/components/general-registration/general-registration.d.ts +20 -284
- package/dist/types/components.d.ts +11 -17
- package/package.json +3 -2
- package/dist/general-registration/p-4800d8b4.js +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-68f93e1e.js');
|
|
6
6
|
|
|
7
7
|
const DEFAULT_LANGUAGE$1 = 'en';
|
|
8
8
|
const SUPPORTED_LANGUAGES$1 = ['ro', 'en'];
|
|
@@ -33,7 +33,7 @@ const translate$2 = (key, customLang, values) => {
|
|
|
33
33
|
return translation;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
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
|
|
36
|
+
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}";
|
|
37
37
|
|
|
38
38
|
const CheckboxInput = class {
|
|
39
39
|
constructor(hostRef) {
|
|
@@ -84,7 +84,7 @@ const CheckboxInput = class {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
render() {
|
|
87
|
-
return index.h("div", { class: 'checkbox__wrapper' }, index.h("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() }), index.h("label", { htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), index.h("small", { class: 'checkbox__error-message' }, this.errorMessage));
|
|
87
|
+
return index.h("div", { class: 'checkbox__wrapper' }, index.h("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() }), index.h("label", { class: 'checkbox__label', htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), index.h("small", { class: 'checkbox__error-message' }, this.errorMessage));
|
|
88
88
|
}
|
|
89
89
|
static get watchers() { return {
|
|
90
90
|
"isValid": ["validityChanged"],
|
|
@@ -107,7 +107,7 @@ CheckboxInput.style = checkboxInputCss;
|
|
|
107
107
|
*/
|
|
108
108
|
class Lumo extends HTMLElement {
|
|
109
109
|
static get version() {
|
|
110
|
-
return '23.3.
|
|
110
|
+
return '23.3.14';
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -12980,7 +12980,7 @@ const registered = new Set();
|
|
|
12980
12980
|
const ElementMixin = (superClass) =>
|
|
12981
12981
|
class VaadinElementMixin extends DirMixin(superClass) {
|
|
12982
12982
|
static get version() {
|
|
12983
|
-
return '23.3.
|
|
12983
|
+
return '23.3.14';
|
|
12984
12984
|
}
|
|
12985
12985
|
|
|
12986
12986
|
/** @protected */
|
|
@@ -16278,7 +16278,7 @@ registerStyles('vaadin-date-picker-overlay', datePickerOverlayStyles, {
|
|
|
16278
16278
|
moduleId: 'vaadin-date-picker-overlay-styles',
|
|
16279
16279
|
});
|
|
16280
16280
|
|
|
16281
|
-
let memoizedTemplate$
|
|
16281
|
+
let memoizedTemplate$2;
|
|
16282
16282
|
|
|
16283
16283
|
/**
|
|
16284
16284
|
* An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
|
|
@@ -16292,12 +16292,12 @@ class DatePickerOverlay extends DisableUpgradeMixin(PositionMixin(Overlay)) {
|
|
|
16292
16292
|
}
|
|
16293
16293
|
|
|
16294
16294
|
static get template() {
|
|
16295
|
-
if (!memoizedTemplate$
|
|
16296
|
-
memoizedTemplate$
|
|
16297
|
-
memoizedTemplate$
|
|
16295
|
+
if (!memoizedTemplate$2) {
|
|
16296
|
+
memoizedTemplate$2 = super.template.cloneNode(true);
|
|
16297
|
+
memoizedTemplate$2.content.querySelector('[part~="overlay"]').removeAttribute('tabindex');
|
|
16298
16298
|
}
|
|
16299
16299
|
|
|
16300
|
-
return memoizedTemplate$
|
|
16300
|
+
return memoizedTemplate$2;
|
|
16301
16301
|
}
|
|
16302
16302
|
}
|
|
16303
16303
|
|
|
@@ -23035,7 +23035,7 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
|
|
|
23035
23035
|
|
|
23036
23036
|
customElements.define(DatePicker.is, DatePicker);
|
|
23037
23037
|
|
|
23038
|
-
const dateInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.date__wrapper{position:relative;
|
|
23038
|
+
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}";
|
|
23039
23039
|
|
|
23040
23040
|
const DateInput = class {
|
|
23041
23041
|
constructor(hostRef) {
|
|
@@ -23086,7 +23086,8 @@ const DateInput = class {
|
|
|
23086
23086
|
}
|
|
23087
23087
|
}
|
|
23088
23088
|
render() {
|
|
23089
|
-
|
|
23089
|
+
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'date__input--invalid';
|
|
23090
|
+
return index.h("div", { class: 'date__wrapper' }, index.h("label", { class: `date__label ${this.validation.mandatory ? 'date__label--required' : ''}}`, htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), index.h("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) }), index.h("small", { class: 'date__error-message' }, this.errorMessage));
|
|
23090
23091
|
}
|
|
23091
23092
|
get element() { return index.getElement(this); }
|
|
23092
23093
|
static get watchers() { return {
|
|
@@ -23096,7 +23097,7 @@ const DateInput = class {
|
|
|
23096
23097
|
};
|
|
23097
23098
|
DateInput.style = dateInputCss;
|
|
23098
23099
|
|
|
23099
|
-
const emailInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.email__wrapper{position:relative;
|
|
23100
|
+
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}";
|
|
23100
23101
|
|
|
23101
23102
|
const EmailInput = class {
|
|
23102
23103
|
constructor(hostRef) {
|
|
@@ -23111,17 +23112,24 @@ const EmailInput = class {
|
|
|
23111
23112
|
this.valueHandler({ name: this.name, value: this.value });
|
|
23112
23113
|
}
|
|
23113
23114
|
}
|
|
23114
|
-
validityStateHandler(inputStateEvent) {
|
|
23115
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
23116
|
-
}
|
|
23117
23115
|
emitValueHandler(newValue) {
|
|
23118
23116
|
if (newValue == true && this.isValid) {
|
|
23119
23117
|
this.valueHandler({ name: this.name, value: this.value });
|
|
23120
23118
|
}
|
|
23121
23119
|
}
|
|
23120
|
+
validityStateHandler(inputStateEvent) {
|
|
23121
|
+
this.sendValidityState.emit(inputStateEvent);
|
|
23122
|
+
}
|
|
23122
23123
|
valueHandler(inputValueEvent) {
|
|
23123
23124
|
this.sendInputValue.emit(inputValueEvent);
|
|
23124
23125
|
}
|
|
23126
|
+
valueChangedHandler(event) {
|
|
23127
|
+
if (this.isDuplicateInput) {
|
|
23128
|
+
if (this.name === event.detail.name + 'Duplicate') {
|
|
23129
|
+
this.duplicateInputValue = event.detail.value;
|
|
23130
|
+
}
|
|
23131
|
+
}
|
|
23132
|
+
}
|
|
23125
23133
|
connectedCallback() {
|
|
23126
23134
|
this.validationPattern = this.setPattern();
|
|
23127
23135
|
}
|
|
@@ -23158,9 +23166,13 @@ const EmailInput = class {
|
|
|
23158
23166
|
if (this.inputReference.validity.valueMissing) {
|
|
23159
23167
|
return translate$2('requiredError', this.language);
|
|
23160
23168
|
}
|
|
23169
|
+
if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
|
|
23170
|
+
return this.validation.custom.find(customRule => customRule.rule === 'duplicate-input').errorMessage;
|
|
23171
|
+
}
|
|
23161
23172
|
}
|
|
23162
23173
|
render() {
|
|
23163
|
-
|
|
23174
|
+
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'email__input--invalid';
|
|
23175
|
+
return index.h("div", { class: 'email__wrapper' }, index.h("input", { id: `${this.name}__input`, type: 'email', class: `email__input ${invalidClass}`, value: this.defaultValue, readOnly: this.autofilled, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onBlur: (e) => this.handleInput(e) }), index.h("label", { class: `email__label ${this.validation.mandatory ? 'email__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("small", { class: 'email__error-message' }, this.errorMessage));
|
|
23164
23176
|
}
|
|
23165
23177
|
static get watchers() { return {
|
|
23166
23178
|
"isValid": ["validityChanged"],
|
|
@@ -23182,9 +23194,9 @@ const GeneralInput = class {
|
|
|
23182
23194
|
render() {
|
|
23183
23195
|
switch (this.type.toLowerCase()) {
|
|
23184
23196
|
case 'text':
|
|
23185
|
-
return index.h("text-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
23197
|
+
return index.h("text-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput });
|
|
23186
23198
|
case 'email':
|
|
23187
|
-
return index.h("email-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
23199
|
+
return index.h("email-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput });
|
|
23188
23200
|
case 'number':
|
|
23189
23201
|
return index.h("number-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
23190
23202
|
case 'checkbox':
|
|
@@ -23192,7 +23204,7 @@ const GeneralInput = class {
|
|
|
23192
23204
|
case 'datetime':
|
|
23193
23205
|
return index.h("date-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
23194
23206
|
case 'password':
|
|
23195
|
-
return index.h("password-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language });
|
|
23207
|
+
return index.h("password-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput });
|
|
23196
23208
|
case 'radio':
|
|
23197
23209
|
return index.h("radio-input", { name: this.name, displayName: this.displayName, optionsGroup: this.options, validation: this.validation, emitValue: this.emitValue, language: this.language });
|
|
23198
23210
|
case 'tel':
|
|
@@ -23200,7 +23212,6 @@ const GeneralInput = class {
|
|
|
23200
23212
|
case 'dropdown':
|
|
23201
23213
|
return index.h("select-input", { name: this.name, action: this.action, defaultValue: this.defaultValue, displayName: this.displayName, options: this.options, validation: this.validation, emitValue: this.emitValue, autofilled: this.autofilled, language: this.language });
|
|
23202
23214
|
default:
|
|
23203
|
-
// Nothing here
|
|
23204
23215
|
return index.h("p", null, "The ", this.type, " input type is not valid");
|
|
23205
23216
|
}
|
|
23206
23217
|
}
|
|
@@ -23236,238 +23247,54 @@ const translate = (key, customLang, values) => {
|
|
|
23236
23247
|
return translation;
|
|
23237
23248
|
};
|
|
23238
23249
|
|
|
23239
|
-
const generalRegistrationCss = "
|
|
23250
|
+
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}";
|
|
23240
23251
|
|
|
23241
23252
|
const GeneralRegistration = class {
|
|
23242
23253
|
constructor(hostRef) {
|
|
23243
23254
|
index.registerInstance(this, hostRef);
|
|
23244
|
-
this.
|
|
23245
|
-
|
|
23246
|
-
"content": {
|
|
23247
|
-
"step": "step1",
|
|
23248
|
-
"fields": [
|
|
23249
|
-
{
|
|
23250
|
-
"name": "firstName",
|
|
23251
|
-
"displayName": "Username",
|
|
23252
|
-
"defaultValue": null,
|
|
23253
|
-
"validate": {
|
|
23254
|
-
"mandatory": true,
|
|
23255
|
-
"minLength": 3,
|
|
23256
|
-
"maxLength": 20
|
|
23257
|
-
},
|
|
23258
|
-
"autofill": false
|
|
23259
|
-
},
|
|
23260
|
-
{
|
|
23261
|
-
"name": "lastName",
|
|
23262
|
-
"displayName": "Last name",
|
|
23263
|
-
"defaultValue": null,
|
|
23264
|
-
"validate": {
|
|
23265
|
-
"mandatory": true,
|
|
23266
|
-
"minLength": 3,
|
|
23267
|
-
"maxLength": 20
|
|
23268
|
-
},
|
|
23269
|
-
},
|
|
23270
|
-
{
|
|
23271
|
-
"name": "telephone",
|
|
23272
|
-
"displayName": "Telephone",
|
|
23273
|
-
"action": "GET https://demo-api.stage.norway.everymatrix.com/v1/player/phonecodes",
|
|
23274
|
-
"defaultValue": null,
|
|
23275
|
-
"validate": {
|
|
23276
|
-
"mandatory": true
|
|
23277
|
-
},
|
|
23278
|
-
"autofill": false,
|
|
23279
|
-
"inputType": "tel"
|
|
23280
|
-
},
|
|
23281
|
-
{
|
|
23282
|
-
"name": "dateOfBirth",
|
|
23283
|
-
"displayName": "Date of Birth",
|
|
23284
|
-
"defaultValue": null,
|
|
23285
|
-
"validate": {
|
|
23286
|
-
"min": "2022-05-01",
|
|
23287
|
-
"max": "2022-05-29",
|
|
23288
|
-
"mandatory": true,
|
|
23289
|
-
},
|
|
23290
|
-
"inputType": "datetime"
|
|
23291
|
-
},
|
|
23292
|
-
{
|
|
23293
|
-
"name": "email",
|
|
23294
|
-
"displayName": "Email",
|
|
23295
|
-
"defaultValue": 'a@a.com',
|
|
23296
|
-
"validate": {
|
|
23297
|
-
"mandatory": true,
|
|
23298
|
-
"custom": [
|
|
23299
|
-
{
|
|
23300
|
-
"rule": "regex",
|
|
23301
|
-
"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
23302
|
-
"errorMessage": "Please enter a valid email address"
|
|
23303
|
-
}
|
|
23304
|
-
]
|
|
23305
|
-
},
|
|
23306
|
-
"inputType": "email"
|
|
23307
|
-
},
|
|
23308
|
-
{
|
|
23309
|
-
"name": "password",
|
|
23310
|
-
"displayName": "Password",
|
|
23311
|
-
"defaultValue": null,
|
|
23312
|
-
"validate": {
|
|
23313
|
-
"mandatory": true,
|
|
23314
|
-
"minLength": 3,
|
|
23315
|
-
"maxLength": 20,
|
|
23316
|
-
"type": "password",
|
|
23317
|
-
"custom": [
|
|
23318
|
-
{
|
|
23319
|
-
"rule": "regex",
|
|
23320
|
-
"pattern": "(?=.*\\d+)(?=.*[A-Za-z]+).{8,20}",
|
|
23321
|
-
"errorMessage": "Password must contain at least 1 letter and 1 digit, and its minimal length is 8."
|
|
23322
|
-
}
|
|
23323
|
-
]
|
|
23324
|
-
},
|
|
23325
|
-
"inputType": "password"
|
|
23326
|
-
},
|
|
23327
|
-
{
|
|
23328
|
-
"name": "email",
|
|
23329
|
-
"displayName": "Email",
|
|
23330
|
-
"defaultValue": null,
|
|
23331
|
-
"validate": {
|
|
23332
|
-
"mandatory": true,
|
|
23333
|
-
"type": "email",
|
|
23334
|
-
"custom": [
|
|
23335
|
-
{
|
|
23336
|
-
"rule": "unique-email",
|
|
23337
|
-
"errorMessage": "Please check your email"
|
|
23338
|
-
},
|
|
23339
|
-
{
|
|
23340
|
-
"rule": "regex",
|
|
23341
|
-
"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
23342
|
-
"errorMessage": "Please enter a valid email address"
|
|
23343
|
-
},
|
|
23344
|
-
{
|
|
23345
|
-
"rule": "duplicate-input",
|
|
23346
|
-
"displayName": "pt al doilea input gen: Confirm Email",
|
|
23347
|
-
"errorMessage": "Different Email! Pls."
|
|
23348
|
-
}
|
|
23349
|
-
]
|
|
23350
|
-
}
|
|
23351
|
-
},
|
|
23352
|
-
{
|
|
23353
|
-
"name": "termsAndConditions",
|
|
23354
|
-
"displayName": "Terms and Conditions",
|
|
23355
|
-
"validate": {
|
|
23356
|
-
"mandatory": true,
|
|
23357
|
-
"type": "boolean"
|
|
23358
|
-
},
|
|
23359
|
-
"inputType": "checkbox"
|
|
23360
|
-
},
|
|
23361
|
-
{
|
|
23362
|
-
"name": "pepCheck",
|
|
23363
|
-
"validate": {
|
|
23364
|
-
"mandatory": true
|
|
23365
|
-
},
|
|
23366
|
-
"inputType": "checkbox"
|
|
23367
|
-
},
|
|
23368
|
-
{
|
|
23369
|
-
"name": "gender",
|
|
23370
|
-
"data": {
|
|
23371
|
-
"values": [
|
|
23372
|
-
{
|
|
23373
|
-
"label": "🍆",
|
|
23374
|
-
"value": "m"
|
|
23375
|
-
},
|
|
23376
|
-
{
|
|
23377
|
-
"label": "🍑",
|
|
23378
|
-
"value": "f"
|
|
23379
|
-
}
|
|
23380
|
-
]
|
|
23381
|
-
},
|
|
23382
|
-
"validate": {
|
|
23383
|
-
"mandatory": true
|
|
23384
|
-
},
|
|
23385
|
-
"inputType": "radio"
|
|
23386
|
-
},
|
|
23387
|
-
{
|
|
23388
|
-
"name": "dateOfBirth",
|
|
23389
|
-
"validate": {
|
|
23390
|
-
"mandatory": true,
|
|
23391
|
-
"custom": [
|
|
23392
|
-
{
|
|
23393
|
-
"rule": "regex",
|
|
23394
|
-
"pattern": "(?:19\\d{2}|20[01][0-9]|2020)[-/.](?:0[1-9]|1[012])[-/.](?:0[1-9]|[12][0-9]|3[01])",
|
|
23395
|
-
"errorMessage": "Invalid date format"
|
|
23396
|
-
},
|
|
23397
|
-
{
|
|
23398
|
-
"rule": "min-18-years",
|
|
23399
|
-
"errorMessage": "Not old enough to ride the roller coaster"
|
|
23400
|
-
}
|
|
23401
|
-
]
|
|
23402
|
-
}
|
|
23403
|
-
},
|
|
23404
|
-
{
|
|
23405
|
-
"name": "city",
|
|
23406
|
-
"displayName": "Cities",
|
|
23407
|
-
"action": null,
|
|
23408
|
-
"data": {
|
|
23409
|
-
"values": [
|
|
23410
|
-
{
|
|
23411
|
-
"label": "Budapest",
|
|
23412
|
-
"value": "Budapest"
|
|
23413
|
-
},
|
|
23414
|
-
{
|
|
23415
|
-
"label": "Debrecen",
|
|
23416
|
-
"value": "Debrecen"
|
|
23417
|
-
},
|
|
23418
|
-
{
|
|
23419
|
-
"label": "Miskolc",
|
|
23420
|
-
"value": "Miskolc"
|
|
23421
|
-
},
|
|
23422
|
-
{
|
|
23423
|
-
"label": "Szeged",
|
|
23424
|
-
"value": "Szeged"
|
|
23425
|
-
},
|
|
23426
|
-
{
|
|
23427
|
-
"label": "Zuglo",
|
|
23428
|
-
"value": "Zuglo"
|
|
23429
|
-
}
|
|
23430
|
-
]
|
|
23431
|
-
},
|
|
23432
|
-
"validate": {
|
|
23433
|
-
"mandatory": true
|
|
23434
|
-
},
|
|
23435
|
-
"inputType": "dropdown"
|
|
23436
|
-
},
|
|
23437
|
-
{
|
|
23438
|
-
"name": "city",
|
|
23439
|
-
"displayName": "Cities",
|
|
23440
|
-
"data": null,
|
|
23441
|
-
"action": "GET https://demo-api.stage.norway.everymatrix.com/v1/player/countries",
|
|
23442
|
-
"validate": {
|
|
23443
|
-
"mandatory": true
|
|
23444
|
-
},
|
|
23445
|
-
"inputType": "dropdown"
|
|
23446
|
-
}
|
|
23447
|
-
],
|
|
23448
|
-
"actions": [
|
|
23449
|
-
"get-next-step",
|
|
23450
|
-
"some-async-action-before-submitting",
|
|
23451
|
-
"submit-step-data"
|
|
23452
|
-
]
|
|
23453
|
-
}
|
|
23454
|
-
};
|
|
23255
|
+
this.registrationWidgetLoaded = index.createEvent(this, "registrationWidgetLoaded", 7);
|
|
23256
|
+
this.registrationStepUpdated = index.createEvent(this, "registrationStepUpdated", 7);
|
|
23455
23257
|
/**
|
|
23456
23258
|
* Currently selected language
|
|
23457
23259
|
*/
|
|
23458
23260
|
this.language = 'en';
|
|
23261
|
+
/**
|
|
23262
|
+
* Client custom styling via string
|
|
23263
|
+
*/
|
|
23264
|
+
this.clientStyling = '';
|
|
23265
|
+
/**
|
|
23266
|
+
* Client custom styling via url content
|
|
23267
|
+
*/
|
|
23268
|
+
this.clientStylingUrl = '';
|
|
23459
23269
|
this.emitValue = false;
|
|
23460
23270
|
this.listOfInputs = [];
|
|
23461
23271
|
this.isLoading = true;
|
|
23272
|
+
this.limitStylingAppends = false;
|
|
23462
23273
|
this.listOfInputValues = [];
|
|
23463
23274
|
this.listOfActions = [];
|
|
23464
|
-
this.
|
|
23275
|
+
this.indexStep = 0;
|
|
23465
23276
|
this.registrationStepsState = {
|
|
23466
23277
|
regId: null
|
|
23467
23278
|
};
|
|
23279
|
+
this.setClientStyling = () => {
|
|
23280
|
+
let sheet = document.createElement('style');
|
|
23281
|
+
sheet.innerHTML = this.clientStyling;
|
|
23282
|
+
this.stylingContainer.prepend(sheet);
|
|
23283
|
+
};
|
|
23284
|
+
this.setClientStylingURL = () => {
|
|
23285
|
+
let url = new URL(this.clientStylingUrl);
|
|
23286
|
+
let cssFile = document.createElement('style');
|
|
23287
|
+
fetch(url.href)
|
|
23288
|
+
.then((res) => res.text())
|
|
23289
|
+
.then((data) => {
|
|
23290
|
+
cssFile.innerHTML = data;
|
|
23291
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
23292
|
+
});
|
|
23293
|
+
};
|
|
23468
23294
|
}
|
|
23469
|
-
|
|
23470
|
-
|
|
23295
|
+
sendStep() {
|
|
23296
|
+
this.registrationStepUpdated.emit(this.registrationStep);
|
|
23297
|
+
window.postMessage({ type: 'registrationStepUpdated', step: this.registrationStep }, window.location.href);
|
|
23471
23298
|
}
|
|
23472
23299
|
checkInputsValidityHandler(event) {
|
|
23473
23300
|
// Set isValid state of the input in the list.
|
|
@@ -23484,18 +23311,22 @@ const GeneralRegistration = class {
|
|
|
23484
23311
|
this.stepsStateMachine({ event: 'set', type: 'values' });
|
|
23485
23312
|
}
|
|
23486
23313
|
componentWillLoad() {
|
|
23487
|
-
// const mockCall = Promise.resolve(this.data);
|
|
23488
|
-
// return mockCall.then((data) => {
|
|
23489
|
-
// this.listOfInputs = data.content.fields.map((field) => {
|
|
23490
|
-
// this.isLoading = false;
|
|
23491
|
-
// return { ...field, isValid: false };
|
|
23492
|
-
// });
|
|
23493
|
-
// });
|
|
23494
23314
|
return this.getRegisterConfig().then((config) => {
|
|
23495
23315
|
this.formatConfig(config);
|
|
23496
23316
|
this.stepsStateMachine({ event: 'set', type: 'inputs' });
|
|
23497
23317
|
});
|
|
23498
23318
|
}
|
|
23319
|
+
componentDidRender() {
|
|
23320
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
23321
|
+
this.setClientStyling();
|
|
23322
|
+
this.setClientStylingURL();
|
|
23323
|
+
this.limitStylingAppends = true;
|
|
23324
|
+
}
|
|
23325
|
+
}
|
|
23326
|
+
componentDidLoad() {
|
|
23327
|
+
this.registrationWidgetLoaded.emit();
|
|
23328
|
+
window.postMessage({ type: 'registrationWidgetLoaded' }, window.location.href);
|
|
23329
|
+
}
|
|
23499
23330
|
nextHandler(e) {
|
|
23500
23331
|
e.preventDefault();
|
|
23501
23332
|
// Trigger events in subwidgets.
|
|
@@ -23504,8 +23335,8 @@ const GeneralRegistration = class {
|
|
|
23504
23335
|
}
|
|
23505
23336
|
backHandler(e) {
|
|
23506
23337
|
e.preventDefault();
|
|
23507
|
-
this.
|
|
23508
|
-
this.registrationStep = this.
|
|
23338
|
+
this.isLastStep = false;
|
|
23339
|
+
this.registrationStep = this.stepChange('decrement');
|
|
23509
23340
|
this.stepsStateMachine({ event: 'get', type: 'inputs' });
|
|
23510
23341
|
this.stepsStateMachine({ event: 'get', type: 'values' });
|
|
23511
23342
|
}
|
|
@@ -23514,10 +23345,11 @@ const GeneralRegistration = class {
|
|
|
23514
23345
|
case 'set':
|
|
23515
23346
|
if (state.type == 'inputs') {
|
|
23516
23347
|
this.registrationStepsState[this.registrationStep].fields = this.listOfInputs;
|
|
23348
|
+
this.registrationStepsState[this.registrationStep].actions = this.listOfActions;
|
|
23517
23349
|
}
|
|
23518
23350
|
if (state.type == 'values') {
|
|
23519
23351
|
this.registrationStepsState[this.registrationStep].registerUserData = this.listOfInputValues.reduce((acc, curr) => {
|
|
23520
|
-
acc[curr.name] = curr.value;
|
|
23352
|
+
acc[curr.name] = { value: curr.value, isDuplicate: curr.isDuplicate };
|
|
23521
23353
|
return acc;
|
|
23522
23354
|
}, {});
|
|
23523
23355
|
}
|
|
@@ -23529,17 +23361,19 @@ const GeneralRegistration = class {
|
|
|
23529
23361
|
return;
|
|
23530
23362
|
if (state.type == 'inputs') {
|
|
23531
23363
|
this.listOfInputs = this.registrationStepsState[this.registrationStep].fields;
|
|
23364
|
+
this.listOfActions = this.registrationStepsState[this.registrationStep].actions;
|
|
23532
23365
|
}
|
|
23533
23366
|
if (state.type == 'values') {
|
|
23534
23367
|
const savedValues = savedUserData[this.registrationStep].registerUserData;
|
|
23535
23368
|
this.listOfInputValues = Object.keys(savedValues).map(name => {
|
|
23536
|
-
return { name, value: savedValues[name] };
|
|
23369
|
+
return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
|
|
23537
23370
|
});
|
|
23538
23371
|
// Give to each field the user input as the default value.
|
|
23539
23372
|
this.listOfInputValues.forEach(inputValue => {
|
|
23540
23373
|
const input = this.listOfInputs.find(input => input.name === inputValue.name);
|
|
23541
23374
|
if (input) {
|
|
23542
23375
|
input.defaultValue = inputValue.value;
|
|
23376
|
+
console.log(input);
|
|
23543
23377
|
}
|
|
23544
23378
|
});
|
|
23545
23379
|
}
|
|
@@ -23577,7 +23411,9 @@ const GeneralRegistration = class {
|
|
|
23577
23411
|
const url = new URL(`${this.endpoint}/v1/player/legislation/registration/step`);
|
|
23578
23412
|
const registerStep = {
|
|
23579
23413
|
registrationId: this.registrationID,
|
|
23580
|
-
registerUserDto: this.listOfInputValues
|
|
23414
|
+
registerUserDto: this.listOfInputValues
|
|
23415
|
+
.filter(input => !input.isDuplicate)
|
|
23416
|
+
.reduce((acc, curr) => {
|
|
23581
23417
|
// Special case for "Mobile" as it needs to be split in two values -- API expects it this way.
|
|
23582
23418
|
if (curr.name == "Mobile") {
|
|
23583
23419
|
acc['MobilePrefix'] = curr.value.split('|')[0];
|
|
@@ -23611,12 +23447,22 @@ const GeneralRegistration = class {
|
|
|
23611
23447
|
this.setRegister();
|
|
23612
23448
|
}
|
|
23613
23449
|
else {
|
|
23614
|
-
|
|
23615
|
-
|
|
23616
|
-
|
|
23617
|
-
|
|
23618
|
-
|
|
23619
|
-
|
|
23450
|
+
// After sending the current step, increment and check if the next one is in state.
|
|
23451
|
+
this.registrationStep = this.stepChange('increment');
|
|
23452
|
+
// If step is present in state do NOT fetch the next config.
|
|
23453
|
+
if (Object.keys(this.registrationStepsState).find(key => key == this.registrationStep)) {
|
|
23454
|
+
// Use the one from state
|
|
23455
|
+
this.stepsStateMachine({ event: 'get', type: 'inputs' });
|
|
23456
|
+
this.stepsStateMachine({ event: 'get', type: 'values' });
|
|
23457
|
+
}
|
|
23458
|
+
else {
|
|
23459
|
+
this.getRegisterConfig(this.registrationID).then((config) => {
|
|
23460
|
+
// Format the new step config.
|
|
23461
|
+
this.formatConfig(config);
|
|
23462
|
+
// Set it in local storage.
|
|
23463
|
+
this.stepsStateMachine({ event: 'set', type: 'inputs' });
|
|
23464
|
+
});
|
|
23465
|
+
}
|
|
23620
23466
|
}
|
|
23621
23467
|
})
|
|
23622
23468
|
.catch((err) => {
|
|
@@ -23658,52 +23504,69 @@ const GeneralRegistration = class {
|
|
|
23658
23504
|
}
|
|
23659
23505
|
formatConfig(config) {
|
|
23660
23506
|
// Populate the list of inputs and set as invalid in the beginning
|
|
23661
|
-
|
|
23662
|
-
|
|
23507
|
+
this.listOfInputs = config.content.fields.flatMap((field) => {
|
|
23508
|
+
// Special case for inputs that need to be duplicated.
|
|
23509
|
+
const duplicateInputRule = field.validate.custom.find(customRule => customRule.rule === 'duplicate-input');
|
|
23510
|
+
const inputElement = Object.assign(Object.assign({}, field), { isValid: false });
|
|
23511
|
+
if (duplicateInputRule) {
|
|
23512
|
+
const duplicateInput = Object.assign(Object.assign({}, field), { name: `${field.name}Duplicate`, displayName: duplicateInputRule.displayName, isValid: false, isDuplicateInput: true });
|
|
23513
|
+
return [inputElement, duplicateInput];
|
|
23514
|
+
}
|
|
23515
|
+
else {
|
|
23516
|
+
return [inputElement];
|
|
23517
|
+
}
|
|
23663
23518
|
});
|
|
23664
|
-
this.listOfInputs = JSON.parse(JSON.stringify(newListOfInputs));
|
|
23665
23519
|
// Populate the list of inputs values and set as null in the beginning
|
|
23666
|
-
this.listOfInputValues =
|
|
23667
|
-
return { name: field.name, value: null };
|
|
23520
|
+
this.listOfInputValues = this.listOfInputs.map(field => {
|
|
23521
|
+
return { name: field.name, value: null, isDuplicate: field.isDuplicateInput || false };
|
|
23668
23522
|
});
|
|
23669
23523
|
// Set the list of actions
|
|
23670
23524
|
this.listOfActions = config.content.actions.map(action => action);
|
|
23671
23525
|
this.isLastStep = this.listOfActions.some(action => action == '/register');
|
|
23672
23526
|
this.registrationID = config.content.registrationID;
|
|
23673
23527
|
this.registrationStep = config.content.step;
|
|
23674
|
-
this.steps.push(this.registrationStep);
|
|
23675
23528
|
// Add the step to the registrationStepsData
|
|
23676
23529
|
this.registrationStepsState.regId = this.registrationID;
|
|
23677
23530
|
if (!this.registrationStepsState[this.registrationStep]) {
|
|
23678
23531
|
this.registrationStepsState[this.registrationStep] = {
|
|
23679
23532
|
fields: [],
|
|
23680
|
-
registerUserData: {}
|
|
23533
|
+
registerUserData: {},
|
|
23534
|
+
actions: []
|
|
23681
23535
|
};
|
|
23682
23536
|
}
|
|
23683
23537
|
}
|
|
23538
|
+
stepChange(action) {
|
|
23539
|
+
const stepNum = parseInt(this.registrationStep.replace('Step', ''));
|
|
23540
|
+
if (action === 'increment') {
|
|
23541
|
+
return 'Step' + (stepNum + 1);
|
|
23542
|
+
}
|
|
23543
|
+
if (action === 'decrement') {
|
|
23544
|
+
return 'Step' + (stepNum - 1);
|
|
23545
|
+
}
|
|
23546
|
+
}
|
|
23684
23547
|
getInvalidStatus(listOfInputs) {
|
|
23685
23548
|
return listOfInputs.filter(input => input.isValid == false).length > 0;
|
|
23686
23549
|
}
|
|
23687
23550
|
renderInputs() {
|
|
23688
|
-
return (this.listOfInputs.map(input => index.h("general-input", { type: input.inputType, name: input.name, displayName: input.displayName, validation: input.validate, action: input.action || null, options: input.data ? input.data.values : [], defaultValue: input.defaultValue, autofilled: input.autofill, emitValue: this.emitValue, language: this.language })));
|
|
23551
|
+
return (this.listOfInputs.map(input => index.h("general-input", { type: input.inputType, name: input.name, displayName: input.displayName, validation: input.validate, action: input.action || null, options: input.data ? input.data.values : [], defaultValue: input.defaultValue, autofilled: input.autofill, emitValue: this.emitValue, language: this.language, isDuplicateInput: input.isDuplicateInput })));
|
|
23689
23552
|
}
|
|
23690
23553
|
;
|
|
23691
23554
|
renderButtons() {
|
|
23692
|
-
return (index.h("div", { class: 'registration__buttons-wrapper' }, index.h("button", { class: `registration__button
|
|
23555
|
+
return (index.h("div", { class: 'registration__buttons-wrapper' }, index.h("button", { class: `registration__button registration__button--next`, type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e) }, this.isLastStep ? translate('doneButton', this.language) : translate('nextButton', this.language)), index.h("button", { class: `registration__button registration__button--back ${this.registrationStep == 'Step1' ? 'registration__button--first-step' : ''}`, onClick: (e) => this.backHandler(e) }, translate('backButton', this.language))));
|
|
23693
23556
|
}
|
|
23694
23557
|
render() {
|
|
23695
23558
|
if (this.isLoading) {
|
|
23696
23559
|
return index.h("p", null, "Please wait, loading ...");
|
|
23697
23560
|
}
|
|
23698
|
-
return (index.h("div", { class:
|
|
23561
|
+
return (index.h("div", { class: `registration registration__${this.registrationStep}`, ref: el => this.stylingContainer = el }, index.h("form", { action: '.', id: 'RegistrationForm', class: 'registration__form' }, this.renderInputs()), this.renderButtons()));
|
|
23699
23562
|
}
|
|
23700
23563
|
static get watchers() { return {
|
|
23701
|
-
"registrationStep": ["
|
|
23564
|
+
"registrationStep": ["sendStep"]
|
|
23702
23565
|
}; }
|
|
23703
23566
|
};
|
|
23704
23567
|
GeneralRegistration.style = generalRegistrationCss;
|
|
23705
23568
|
|
|
23706
|
-
const numberInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.number__wrapper{position:relative;
|
|
23569
|
+
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}";
|
|
23707
23570
|
|
|
23708
23571
|
const NumberInput = class {
|
|
23709
23572
|
constructor(hostRef) {
|
|
@@ -23763,176 +23626,985 @@ const NumberInput = class {
|
|
|
23763
23626
|
};
|
|
23764
23627
|
NumberInput.style = numberInputCss;
|
|
23765
23628
|
|
|
23766
|
-
|
|
23767
|
-
|
|
23768
|
-
|
|
23769
|
-
|
|
23770
|
-
|
|
23771
|
-
this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
|
|
23772
|
-
this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
|
|
23773
|
-
/**
|
|
23774
|
-
* Default value for the input.
|
|
23775
|
-
*/
|
|
23776
|
-
this.defaultValue = '';
|
|
23777
|
-
this.value = '';
|
|
23778
|
-
this.validationPattern = '';
|
|
23779
|
-
}
|
|
23780
|
-
validityChanged() {
|
|
23781
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
23782
|
-
if (this.emitValue == true) {
|
|
23783
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
23784
|
-
}
|
|
23785
|
-
}
|
|
23786
|
-
validityStateHandler(inputStateEvent) {
|
|
23787
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
23788
|
-
}
|
|
23789
|
-
emitValueHandler(newValue) {
|
|
23790
|
-
if (newValue == true && this.isValid) {
|
|
23791
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
23792
|
-
}
|
|
23793
|
-
}
|
|
23794
|
-
valueHandler(inputValueEvent) {
|
|
23795
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
23796
|
-
}
|
|
23797
|
-
connectedCallback() {
|
|
23798
|
-
this.validationPattern = this.setPattern();
|
|
23799
|
-
}
|
|
23800
|
-
componentDidLoad() {
|
|
23801
|
-
if (this.defaultValue) {
|
|
23802
|
-
this.value = this.defaultValue;
|
|
23803
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
23804
|
-
}
|
|
23805
|
-
}
|
|
23806
|
-
handleInput(event) {
|
|
23807
|
-
this.value = event.target.value;
|
|
23808
|
-
this.errorMessage = this.setErrorMessage();
|
|
23809
|
-
this.isValid = this.setValidity();
|
|
23810
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
23811
|
-
this.emitValueHandler(true);
|
|
23812
|
-
}
|
|
23813
|
-
setValidity() {
|
|
23814
|
-
return this.inputReference.validity.valid;
|
|
23815
|
-
}
|
|
23816
|
-
setPattern() {
|
|
23817
|
-
var _a, _b;
|
|
23818
|
-
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
23819
|
-
return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
|
|
23820
|
-
}
|
|
23821
|
-
}
|
|
23822
|
-
setErrorMessage() {
|
|
23823
|
-
var _a;
|
|
23824
|
-
if (this.inputReference.validity.patternMismatch) {
|
|
23825
|
-
return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
|
|
23826
|
-
}
|
|
23827
|
-
if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
|
|
23828
|
-
return translate$2('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
|
|
23829
|
-
}
|
|
23830
|
-
if (this.inputReference.validity.valueMissing) {
|
|
23831
|
-
return translate$2('requiredError', this.language);
|
|
23832
|
-
}
|
|
23833
|
-
}
|
|
23834
|
-
render() {
|
|
23835
|
-
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'password__input--invalid';
|
|
23836
|
-
return index.h("div", { class: 'password__wrapper' }, index.h("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) }), index.h("label", { class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("small", { class: 'password__error-message' }, this.errorMessage));
|
|
23837
|
-
}
|
|
23838
|
-
static get watchers() { return {
|
|
23839
|
-
"isValid": ["validityChanged"],
|
|
23840
|
-
"emitValue": ["emitValueHandler"]
|
|
23841
|
-
}; }
|
|
23842
|
-
};
|
|
23843
|
-
PasswordInput.style = passwordInputCss;
|
|
23844
|
-
|
|
23845
|
-
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:red}";
|
|
23629
|
+
/**
|
|
23630
|
+
* @license
|
|
23631
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
23632
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
23633
|
+
*/
|
|
23846
23634
|
|
|
23847
|
-
|
|
23848
|
-
|
|
23849
|
-
|
|
23850
|
-
this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
|
|
23851
|
-
this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
|
|
23852
|
-
}
|
|
23853
|
-
validityChanged() {
|
|
23854
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
23855
|
-
if (this.emitValue == true) {
|
|
23856
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
23857
|
-
}
|
|
23858
|
-
}
|
|
23859
|
-
emitValueHandler(newValue) {
|
|
23860
|
-
if (newValue == true && this.isValid) {
|
|
23861
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
23862
|
-
}
|
|
23863
|
-
}
|
|
23864
|
-
valueHandler(inputValueEvent) {
|
|
23865
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
23866
|
-
}
|
|
23867
|
-
validityStateHandler(inputStateEvent) {
|
|
23868
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
23869
|
-
}
|
|
23870
|
-
connectedCallback() {
|
|
23871
|
-
}
|
|
23872
|
-
handleClick(event) {
|
|
23873
|
-
this.value = event.target.value;
|
|
23874
|
-
this.isValid = this.setValidity();
|
|
23875
|
-
this.errorMessage = this.setErrorMessage();
|
|
23876
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
23877
|
-
this.emitValueHandler(true);
|
|
23878
|
-
}
|
|
23879
|
-
setValidity() {
|
|
23880
|
-
return this.inputReference.validity.valid;
|
|
23881
|
-
}
|
|
23882
|
-
setErrorMessage() {
|
|
23883
|
-
if (this.inputReference.validity.valueMissing) {
|
|
23884
|
-
return translate$2('requiredError', this.language);
|
|
23885
|
-
}
|
|
23886
|
-
}
|
|
23887
|
-
render() {
|
|
23888
|
-
return index.h("fieldset", { class: 'radio__fieldset' }, index.h("legend", { class: 'radio__legend' }, this.displayName, ":"), this.optionsGroup.map(option => index.h("div", { class: 'radio__wrapper' }, index.h("input", { type: "radio", class: 'radio__input', id: `${option.label}__input`, ref: (el) => this.inputReference = el, value: option.value, name: this.name, required: this.validation.mandatory, onClick: (e) => this.handleClick(e) }), index.h("label", { htmlFor: `${option.label}__input` }, option.label))), index.h("small", { class: 'radio__error-message' }, this.errorMessage));
|
|
23889
|
-
}
|
|
23890
|
-
static get watchers() { return {
|
|
23891
|
-
"isValid": ["validityChanged"],
|
|
23892
|
-
"emitValue": ["emitValueHandler"]
|
|
23893
|
-
}; }
|
|
23894
|
-
};
|
|
23895
|
-
RadioInput.style = radioInputCss;
|
|
23635
|
+
registerStyles('vaadin-text-field', inputFieldShared$1, {
|
|
23636
|
+
moduleId: 'lumo-text-field-styles',
|
|
23637
|
+
});
|
|
23896
23638
|
|
|
23897
23639
|
/**
|
|
23898
23640
|
* @license
|
|
23899
|
-
* Copyright (c) 2022 Vaadin Ltd.
|
|
23641
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
23900
23642
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
23901
23643
|
*/
|
|
23902
23644
|
|
|
23903
|
-
|
|
23904
|
-
|
|
23905
|
-
|
|
23906
|
-
|
|
23907
|
-
|
|
23908
|
-
|
|
23909
|
-
|
|
23910
|
-
|
|
23911
|
-
|
|
23912
|
-
|
|
23913
|
-
|
|
23914
|
-
|
|
23915
|
-
|
|
23916
|
-
|
|
23917
|
-
|
|
23918
|
-
|
|
23645
|
+
/**
|
|
23646
|
+
* A mixin to provide logic for vaadin-text-field and related components.
|
|
23647
|
+
*
|
|
23648
|
+
* @polymerMixin
|
|
23649
|
+
* @mixes InputControlMixin
|
|
23650
|
+
*/
|
|
23651
|
+
const InputFieldMixin = (superclass) =>
|
|
23652
|
+
class InputFieldMixinClass extends InputControlMixin(superclass) {
|
|
23653
|
+
static get properties() {
|
|
23654
|
+
return {
|
|
23655
|
+
/**
|
|
23656
|
+
* Whether the value of the control can be automatically completed by the browser.
|
|
23657
|
+
* List of available options at:
|
|
23658
|
+
* https://developer.mozilla.org/en/docs/Web/HTML/Element/input#attr-autocomplete
|
|
23659
|
+
*/
|
|
23660
|
+
autocomplete: {
|
|
23661
|
+
type: String,
|
|
23662
|
+
},
|
|
23919
23663
|
|
|
23920
|
-
|
|
23921
|
-
|
|
23922
|
-
|
|
23664
|
+
/**
|
|
23665
|
+
* This is a property supported by Safari that is used to control whether
|
|
23666
|
+
* autocorrection should be enabled when the user is entering/editing the text.
|
|
23667
|
+
* Possible values are:
|
|
23668
|
+
* on: Enable autocorrection.
|
|
23669
|
+
* off: Disable autocorrection.
|
|
23670
|
+
*/
|
|
23671
|
+
autocorrect: {
|
|
23672
|
+
type: String,
|
|
23673
|
+
},
|
|
23923
23674
|
|
|
23924
|
-
|
|
23925
|
-
|
|
23926
|
-
|
|
23675
|
+
/**
|
|
23676
|
+
* This is a property supported by Safari and Chrome that is used to control whether
|
|
23677
|
+
* autocapitalization should be enabled when the user is entering/editing the text.
|
|
23678
|
+
* Possible values are:
|
|
23679
|
+
* characters: Characters capitalization.
|
|
23680
|
+
* words: Words capitalization.
|
|
23681
|
+
* sentences: Sentences capitalization.
|
|
23682
|
+
* none: No capitalization.
|
|
23683
|
+
*/
|
|
23684
|
+
autocapitalize: {
|
|
23685
|
+
type: String,
|
|
23686
|
+
reflectToAttribute: true,
|
|
23687
|
+
},
|
|
23688
|
+
};
|
|
23927
23689
|
}
|
|
23928
23690
|
|
|
23929
|
-
|
|
23930
|
-
|
|
23691
|
+
static get delegateAttrs() {
|
|
23692
|
+
return [...super.delegateAttrs, 'autocapitalize', 'autocomplete', 'autocorrect'];
|
|
23931
23693
|
}
|
|
23932
|
-
}
|
|
23933
23694
|
|
|
23934
|
-
|
|
23935
|
-
|
|
23695
|
+
/**
|
|
23696
|
+
* @param {HTMLElement} input
|
|
23697
|
+
* @protected
|
|
23698
|
+
* @override
|
|
23699
|
+
*/
|
|
23700
|
+
_inputElementChanged(input) {
|
|
23701
|
+
super._inputElementChanged(input);
|
|
23702
|
+
|
|
23703
|
+
if (input) {
|
|
23704
|
+
// Discard value set on the custom slotted input.
|
|
23705
|
+
if (input.value && input.value !== this.value) {
|
|
23706
|
+
console.warn(`Please define value on the <${this.localName}> component!`);
|
|
23707
|
+
input.value = '';
|
|
23708
|
+
}
|
|
23709
|
+
|
|
23710
|
+
if (this.value) {
|
|
23711
|
+
input.value = this.value;
|
|
23712
|
+
}
|
|
23713
|
+
}
|
|
23714
|
+
}
|
|
23715
|
+
|
|
23716
|
+
// Workaround for https://github.com/Polymer/polymer/issues/5259
|
|
23717
|
+
get __data() {
|
|
23718
|
+
return this.__dataValue || {};
|
|
23719
|
+
}
|
|
23720
|
+
|
|
23721
|
+
set __data(value) {
|
|
23722
|
+
this.__dataValue = value;
|
|
23723
|
+
}
|
|
23724
|
+
|
|
23725
|
+
/**
|
|
23726
|
+
* Override an event listener from `FocusMixin`.
|
|
23727
|
+
* @param {boolean} focused
|
|
23728
|
+
* @protected
|
|
23729
|
+
* @override
|
|
23730
|
+
*/
|
|
23731
|
+
_setFocused(focused) {
|
|
23732
|
+
super._setFocused(focused);
|
|
23733
|
+
|
|
23734
|
+
if (!focused) {
|
|
23735
|
+
this.validate();
|
|
23736
|
+
}
|
|
23737
|
+
}
|
|
23738
|
+
|
|
23739
|
+
/**
|
|
23740
|
+
* Override an event listener from `InputMixin`
|
|
23741
|
+
* to mark as valid after user started typing.
|
|
23742
|
+
* @param {Event} event
|
|
23743
|
+
* @protected
|
|
23744
|
+
* @override
|
|
23745
|
+
*/
|
|
23746
|
+
_onInput(event) {
|
|
23747
|
+
super._onInput(event);
|
|
23748
|
+
|
|
23749
|
+
if (this.invalid) {
|
|
23750
|
+
this.validate();
|
|
23751
|
+
}
|
|
23752
|
+
}
|
|
23753
|
+
|
|
23754
|
+
/**
|
|
23755
|
+
* Override an observer from `InputMixin` to validate the field
|
|
23756
|
+
* when a new value is set programmatically.
|
|
23757
|
+
*
|
|
23758
|
+
* @param {string | undefined} newValue
|
|
23759
|
+
* @param {string | undefined} oldValue
|
|
23760
|
+
* @protected
|
|
23761
|
+
* @override
|
|
23762
|
+
*/
|
|
23763
|
+
_valueChanged(newValue, oldValue) {
|
|
23764
|
+
super._valueChanged(newValue, oldValue);
|
|
23765
|
+
|
|
23766
|
+
if (oldValue === undefined) {
|
|
23767
|
+
return;
|
|
23768
|
+
}
|
|
23769
|
+
|
|
23770
|
+
if (this.invalid) {
|
|
23771
|
+
this.validate();
|
|
23772
|
+
}
|
|
23773
|
+
}
|
|
23774
|
+
};
|
|
23775
|
+
|
|
23776
|
+
/**
|
|
23777
|
+
* @license
|
|
23778
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
23779
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
23780
|
+
*/
|
|
23781
|
+
|
|
23782
|
+
/**
|
|
23783
|
+
* A mixin to provide `pattern` and `preventInvalidInput` properties.
|
|
23784
|
+
*
|
|
23785
|
+
* @polymerMixin
|
|
23786
|
+
* @mixes InputConstraintsMixin
|
|
23787
|
+
*/
|
|
23788
|
+
const PatternMixin = (superclass) =>
|
|
23789
|
+
class PatternMixinClass extends InputConstraintsMixin(superclass) {
|
|
23790
|
+
static get properties() {
|
|
23791
|
+
return {
|
|
23792
|
+
/**
|
|
23793
|
+
* A regular expression that the value is checked against.
|
|
23794
|
+
* The pattern must match the entire value, not just some subset.
|
|
23795
|
+
*/
|
|
23796
|
+
pattern: {
|
|
23797
|
+
type: String,
|
|
23798
|
+
},
|
|
23799
|
+
|
|
23800
|
+
/**
|
|
23801
|
+
* When set to true, user is prevented from typing a value that
|
|
23802
|
+
* conflicts with the given `pattern`.
|
|
23803
|
+
* @attr {boolean} prevent-invalid-input
|
|
23804
|
+
* @deprecated Please use `allowedCharPattern` instead.
|
|
23805
|
+
*/
|
|
23806
|
+
preventInvalidInput: {
|
|
23807
|
+
type: Boolean,
|
|
23808
|
+
observer: '_preventInvalidInputChanged',
|
|
23809
|
+
},
|
|
23810
|
+
};
|
|
23811
|
+
}
|
|
23812
|
+
|
|
23813
|
+
static get delegateAttrs() {
|
|
23814
|
+
return [...super.delegateAttrs, 'pattern'];
|
|
23815
|
+
}
|
|
23816
|
+
|
|
23817
|
+
static get constraints() {
|
|
23818
|
+
return [...super.constraints, 'pattern'];
|
|
23819
|
+
}
|
|
23820
|
+
|
|
23821
|
+
/** @private */
|
|
23822
|
+
_checkInputValue() {
|
|
23823
|
+
if (this.preventInvalidInput) {
|
|
23824
|
+
const input = this.inputElement;
|
|
23825
|
+
if (input && input.value.length > 0 && !this.checkValidity()) {
|
|
23826
|
+
input.value = this.value || '';
|
|
23827
|
+
// Add input-prevented attribute for 200ms
|
|
23828
|
+
this.setAttribute('input-prevented', '');
|
|
23829
|
+
this._inputDebouncer = Debouncer$1.debounce(this._inputDebouncer, timeOut.after(200), () => {
|
|
23830
|
+
this.removeAttribute('input-prevented');
|
|
23831
|
+
});
|
|
23832
|
+
}
|
|
23833
|
+
}
|
|
23834
|
+
}
|
|
23835
|
+
|
|
23836
|
+
/**
|
|
23837
|
+
* @param {Event} event
|
|
23838
|
+
* @protected
|
|
23839
|
+
* @override
|
|
23840
|
+
*/
|
|
23841
|
+
_onInput(event) {
|
|
23842
|
+
this._checkInputValue();
|
|
23843
|
+
|
|
23844
|
+
super._onInput(event);
|
|
23845
|
+
}
|
|
23846
|
+
|
|
23847
|
+
/** @private */
|
|
23848
|
+
_preventInvalidInputChanged(preventInvalidInput) {
|
|
23849
|
+
if (preventInvalidInput) {
|
|
23850
|
+
console.warn(
|
|
23851
|
+
`WARNING: Since Vaadin 23.2, "preventInvalidInput" is deprecated. Please use "allowedCharPattern" instead.`,
|
|
23852
|
+
);
|
|
23853
|
+
}
|
|
23854
|
+
}
|
|
23855
|
+
};
|
|
23856
|
+
|
|
23857
|
+
/**
|
|
23858
|
+
* @license
|
|
23859
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
23860
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
23861
|
+
*/
|
|
23862
|
+
|
|
23863
|
+
registerStyles('vaadin-text-field', inputFieldShared, { moduleId: 'vaadin-text-field-styles' });
|
|
23864
|
+
|
|
23865
|
+
/**
|
|
23866
|
+
* `<vaadin-text-field>` is a web component that allows the user to input and edit text.
|
|
23867
|
+
*
|
|
23868
|
+
* ```html
|
|
23869
|
+
* <vaadin-text-field label="First Name"></vaadin-text-field>
|
|
23870
|
+
* ```
|
|
23871
|
+
*
|
|
23872
|
+
* ### Prefixes and suffixes
|
|
23873
|
+
*
|
|
23874
|
+
* These are child elements of a `<vaadin-text-field>` that are displayed
|
|
23875
|
+
* inline with the input, before or after.
|
|
23876
|
+
* In order for an element to be considered as a prefix, it must have the slot
|
|
23877
|
+
* attribute set to `prefix` (and similarly for `suffix`).
|
|
23878
|
+
*
|
|
23879
|
+
* ```html
|
|
23880
|
+
* <vaadin-text-field label="Email address">
|
|
23881
|
+
* <div slot="prefix">Sent to:</div>
|
|
23882
|
+
* <div slot="suffix">@vaadin.com</div>
|
|
23883
|
+
* </vaadin-text-field>
|
|
23884
|
+
* ```
|
|
23885
|
+
*
|
|
23886
|
+
* ### Styling
|
|
23887
|
+
*
|
|
23888
|
+
* The following custom properties are available for styling:
|
|
23889
|
+
*
|
|
23890
|
+
* Custom property | Description | Default
|
|
23891
|
+
* -------------------------------|----------------------------|---------
|
|
23892
|
+
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
23893
|
+
*
|
|
23894
|
+
* The following shadow DOM parts are available for styling:
|
|
23895
|
+
*
|
|
23896
|
+
* Part name | Description
|
|
23897
|
+
* ---------------------|----------------
|
|
23898
|
+
* `label` | The label element
|
|
23899
|
+
* `input-field` | The element that wraps prefix, value and suffix
|
|
23900
|
+
* `clear-button` | The clear button
|
|
23901
|
+
* `error-message` | The error message element
|
|
23902
|
+
* `helper-text` | The helper text element wrapper
|
|
23903
|
+
* `required-indicator` | The `required` state indicator element
|
|
23904
|
+
*
|
|
23905
|
+
* The following state attributes are available for styling:
|
|
23906
|
+
*
|
|
23907
|
+
* Attribute | Description | Part name
|
|
23908
|
+
* --------------------|-------------|------------
|
|
23909
|
+
* `disabled` | Set to a disabled text field | :host
|
|
23910
|
+
* `has-value` | Set when the element has a value | :host
|
|
23911
|
+
* `has-label` | Set when the element has a label | :host
|
|
23912
|
+
* `has-helper` | Set when the element has helper text or slot | :host
|
|
23913
|
+
* `has-error-message` | Set when the element has an error message | :host
|
|
23914
|
+
* `invalid` | Set when the element is invalid | :host
|
|
23915
|
+
* `input-prevented` | Temporarily set when invalid input is prevented | :host
|
|
23916
|
+
* `focused` | Set when the element is focused | :host
|
|
23917
|
+
* `focus-ring` | Set when the element is keyboard focused | :host
|
|
23918
|
+
* `readonly` | Set to a readonly text field | :host
|
|
23919
|
+
*
|
|
23920
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
23921
|
+
*
|
|
23922
|
+
* @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.
|
|
23923
|
+
* @fires {Event} change - Fired when the user commits a value change.
|
|
23924
|
+
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
23925
|
+
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
23926
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
23927
|
+
*
|
|
23928
|
+
* @extends HTMLElement
|
|
23929
|
+
* @mixes ElementMixin
|
|
23930
|
+
* @mixes ThemableMixin
|
|
23931
|
+
* @mixes PatternMixin
|
|
23932
|
+
* @mixes InputFieldMixin
|
|
23933
|
+
*/
|
|
23934
|
+
class TextField extends PatternMixin(InputFieldMixin(ThemableMixin(ElementMixin(PolymerElement)))) {
|
|
23935
|
+
static get is() {
|
|
23936
|
+
return 'vaadin-text-field';
|
|
23937
|
+
}
|
|
23938
|
+
|
|
23939
|
+
static get template() {
|
|
23940
|
+
return html`
|
|
23941
|
+
<style>
|
|
23942
|
+
[part='input-field'] {
|
|
23943
|
+
flex-grow: 0;
|
|
23944
|
+
}
|
|
23945
|
+
</style>
|
|
23946
|
+
|
|
23947
|
+
<div class="vaadin-field-container">
|
|
23948
|
+
<div part="label">
|
|
23949
|
+
<slot name="label"></slot>
|
|
23950
|
+
<span part="required-indicator" aria-hidden="true" on-click="focus"></span>
|
|
23951
|
+
</div>
|
|
23952
|
+
|
|
23953
|
+
<vaadin-input-container
|
|
23954
|
+
part="input-field"
|
|
23955
|
+
readonly="[[readonly]]"
|
|
23956
|
+
disabled="[[disabled]]"
|
|
23957
|
+
invalid="[[invalid]]"
|
|
23958
|
+
theme$="[[_theme]]"
|
|
23959
|
+
>
|
|
23960
|
+
<slot name="prefix" slot="prefix"></slot>
|
|
23961
|
+
<slot name="input"></slot>
|
|
23962
|
+
<slot name="suffix" slot="suffix"></slot>
|
|
23963
|
+
<div id="clearButton" part="clear-button" slot="suffix" aria-hidden="true"></div>
|
|
23964
|
+
</vaadin-input-container>
|
|
23965
|
+
|
|
23966
|
+
<div part="helper-text">
|
|
23967
|
+
<slot name="helper"></slot>
|
|
23968
|
+
</div>
|
|
23969
|
+
|
|
23970
|
+
<div part="error-message">
|
|
23971
|
+
<slot name="error-message"></slot>
|
|
23972
|
+
</div>
|
|
23973
|
+
</div>
|
|
23974
|
+
<slot name="tooltip"></slot>
|
|
23975
|
+
`;
|
|
23976
|
+
}
|
|
23977
|
+
|
|
23978
|
+
static get properties() {
|
|
23979
|
+
return {
|
|
23980
|
+
/**
|
|
23981
|
+
* Maximum number of characters (in Unicode code points) that the user can enter.
|
|
23982
|
+
*/
|
|
23983
|
+
maxlength: {
|
|
23984
|
+
type: Number,
|
|
23985
|
+
},
|
|
23986
|
+
|
|
23987
|
+
/**
|
|
23988
|
+
* Minimum number of characters (in Unicode code points) that the user can enter.
|
|
23989
|
+
*/
|
|
23990
|
+
minlength: {
|
|
23991
|
+
type: Number,
|
|
23992
|
+
},
|
|
23993
|
+
};
|
|
23994
|
+
}
|
|
23995
|
+
|
|
23996
|
+
static get delegateAttrs() {
|
|
23997
|
+
return [...super.delegateAttrs, 'maxlength', 'minlength'];
|
|
23998
|
+
}
|
|
23999
|
+
|
|
24000
|
+
static get constraints() {
|
|
24001
|
+
return [...super.constraints, 'maxlength', 'minlength'];
|
|
24002
|
+
}
|
|
24003
|
+
|
|
24004
|
+
constructor() {
|
|
24005
|
+
super();
|
|
24006
|
+
this._setType('text');
|
|
24007
|
+
}
|
|
24008
|
+
|
|
24009
|
+
/** @protected */
|
|
24010
|
+
get clearElement() {
|
|
24011
|
+
return this.$.clearButton;
|
|
24012
|
+
}
|
|
24013
|
+
|
|
24014
|
+
/** @protected */
|
|
24015
|
+
ready() {
|
|
24016
|
+
super.ready();
|
|
24017
|
+
|
|
24018
|
+
this.addController(
|
|
24019
|
+
new InputController(this, (input) => {
|
|
24020
|
+
this._setInputElement(input);
|
|
24021
|
+
this._setFocusElement(input);
|
|
24022
|
+
this.stateTarget = input;
|
|
24023
|
+
this.ariaTarget = input;
|
|
24024
|
+
}),
|
|
24025
|
+
);
|
|
24026
|
+
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
24027
|
+
|
|
24028
|
+
this._tooltipController = new TooltipController(this);
|
|
24029
|
+
this._tooltipController.setPosition('top');
|
|
24030
|
+
this.addController(this._tooltipController);
|
|
24031
|
+
}
|
|
24032
|
+
}
|
|
24033
|
+
|
|
24034
|
+
customElements.define(TextField.is, TextField);
|
|
24035
|
+
|
|
24036
|
+
/**
|
|
24037
|
+
* @license
|
|
24038
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
24039
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
24040
|
+
*/
|
|
24041
|
+
|
|
24042
|
+
const passwordFieldButton = i$1`
|
|
24043
|
+
:host {
|
|
24044
|
+
position: absolute;
|
|
24045
|
+
right: 0;
|
|
24046
|
+
top: 0;
|
|
24047
|
+
margin: 0;
|
|
24048
|
+
padding: 0;
|
|
24049
|
+
width: 100%;
|
|
24050
|
+
height: 100%;
|
|
24051
|
+
min-width: auto;
|
|
24052
|
+
background: transparent;
|
|
24053
|
+
outline: none;
|
|
24054
|
+
}
|
|
24055
|
+
`;
|
|
24056
|
+
|
|
24057
|
+
registerStyles('vaadin-password-field-button', [button, passwordFieldButton], {
|
|
24058
|
+
moduleId: 'lumo-password-field-button',
|
|
24059
|
+
});
|
|
24060
|
+
|
|
24061
|
+
/**
|
|
24062
|
+
* @license
|
|
24063
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
24064
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
24065
|
+
*/
|
|
24066
|
+
|
|
24067
|
+
const passwordField = i$1`
|
|
24068
|
+
[part='reveal-button']::before {
|
|
24069
|
+
content: var(--lumo-icons-eye);
|
|
24070
|
+
}
|
|
24071
|
+
|
|
24072
|
+
:host([password-visible]) [part='reveal-button']::before {
|
|
24073
|
+
content: var(--lumo-icons-eye-disabled);
|
|
24074
|
+
}
|
|
24075
|
+
|
|
24076
|
+
/* Make it easy to hide the button across the whole app */
|
|
24077
|
+
[part='reveal-button'] {
|
|
24078
|
+
position: relative;
|
|
24079
|
+
display: var(--lumo-password-field-reveal-button-display, block);
|
|
24080
|
+
}
|
|
24081
|
+
|
|
24082
|
+
[part='reveal-button'][hidden] {
|
|
24083
|
+
display: none !important;
|
|
24084
|
+
}
|
|
24085
|
+
`;
|
|
24086
|
+
|
|
24087
|
+
registerStyles('vaadin-password-field', [inputFieldShared$1, passwordField], { moduleId: 'lumo-password-field' });
|
|
24088
|
+
|
|
24089
|
+
/**
|
|
24090
|
+
* @license
|
|
24091
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
24092
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
24093
|
+
*/
|
|
24094
|
+
|
|
24095
|
+
/**
|
|
24096
|
+
* An element used internally by `<vaadin-password-field>`. Not intended to be used separately.
|
|
24097
|
+
*
|
|
24098
|
+
* @extends Button
|
|
24099
|
+
* @private
|
|
24100
|
+
*/
|
|
24101
|
+
class PasswordFieldButton extends Button {
|
|
24102
|
+
static get is() {
|
|
24103
|
+
return 'vaadin-password-field-button';
|
|
24104
|
+
}
|
|
24105
|
+
|
|
24106
|
+
static get template() {
|
|
24107
|
+
return html`
|
|
24108
|
+
<style>
|
|
24109
|
+
:host {
|
|
24110
|
+
display: block;
|
|
24111
|
+
}
|
|
24112
|
+
|
|
24113
|
+
:host([hidden]) {
|
|
24114
|
+
display: none !important;
|
|
24115
|
+
}
|
|
24116
|
+
</style>
|
|
24117
|
+
<slot name="tooltip"></slot>
|
|
24118
|
+
`;
|
|
24119
|
+
}
|
|
24120
|
+
}
|
|
24121
|
+
|
|
24122
|
+
customElements.define(PasswordFieldButton.is, PasswordFieldButton);
|
|
24123
|
+
|
|
24124
|
+
/**
|
|
24125
|
+
* @license
|
|
24126
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
24127
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
24128
|
+
*/
|
|
24129
|
+
|
|
24130
|
+
const ownTemplate = html`
|
|
24131
|
+
<div part="reveal-button" slot="suffix">
|
|
24132
|
+
<slot name="reveal"></slot>
|
|
24133
|
+
</div>
|
|
24134
|
+
`;
|
|
24135
|
+
|
|
24136
|
+
let memoizedTemplate$1;
|
|
24137
|
+
|
|
24138
|
+
/**
|
|
24139
|
+
* `<vaadin-password-field>` is an extension of `<vaadin-text-field>` component for entering passwords.
|
|
24140
|
+
*
|
|
24141
|
+
* ```html
|
|
24142
|
+
* <vaadin-password-field label="Password"></vaadin-password-field>
|
|
24143
|
+
* ```
|
|
24144
|
+
*
|
|
24145
|
+
* ### Styling
|
|
24146
|
+
*
|
|
24147
|
+
* `<vaadin-password-field>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.
|
|
24148
|
+
* See [`<vaadin-text-field>`](#/elements/vaadin-text-field) for the styling documentation.
|
|
24149
|
+
*
|
|
24150
|
+
* In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
|
|
24151
|
+
*
|
|
24152
|
+
* Part name | Description
|
|
24153
|
+
* ----------------|----------------------------------------------------
|
|
24154
|
+
* `reveal-button` | The eye icon which toggles the password visibility
|
|
24155
|
+
*
|
|
24156
|
+
* In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
|
|
24157
|
+
*
|
|
24158
|
+
* Attribute | Description
|
|
24159
|
+
* -------------------|---------------------------------
|
|
24160
|
+
* `password-visible` | Set when the password is visible
|
|
24161
|
+
*
|
|
24162
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
24163
|
+
*
|
|
24164
|
+
* @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.
|
|
24165
|
+
* @fires {Event} change - Fired when the user commits a value change.
|
|
24166
|
+
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
24167
|
+
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
24168
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
24169
|
+
*
|
|
24170
|
+
* @extends TextField
|
|
24171
|
+
*/
|
|
24172
|
+
class PasswordField extends TextField {
|
|
24173
|
+
static get is() {
|
|
24174
|
+
return 'vaadin-password-field';
|
|
24175
|
+
}
|
|
24176
|
+
|
|
24177
|
+
static get template() {
|
|
24178
|
+
if (!memoizedTemplate$1) {
|
|
24179
|
+
// Clone the superclass template
|
|
24180
|
+
memoizedTemplate$1 = super.template.cloneNode(true);
|
|
24181
|
+
|
|
24182
|
+
// Retrieve this element's dom-module template
|
|
24183
|
+
const revealButton = ownTemplate.content.querySelector('[part="reveal-button"]');
|
|
24184
|
+
|
|
24185
|
+
// Append reveal-button and styles to the text-field template
|
|
24186
|
+
const inputField = memoizedTemplate$1.content.querySelector('[part="input-field"]');
|
|
24187
|
+
inputField.appendChild(revealButton);
|
|
24188
|
+
}
|
|
24189
|
+
|
|
24190
|
+
return memoizedTemplate$1;
|
|
24191
|
+
}
|
|
24192
|
+
|
|
24193
|
+
static get properties() {
|
|
24194
|
+
return {
|
|
24195
|
+
/**
|
|
24196
|
+
* Set to true to hide the eye icon which toggles the password visibility.
|
|
24197
|
+
* @attr {boolean} reveal-button-hidden
|
|
24198
|
+
*/
|
|
24199
|
+
revealButtonHidden: {
|
|
24200
|
+
type: Boolean,
|
|
24201
|
+
observer: '_revealButtonHiddenChanged',
|
|
24202
|
+
value: false,
|
|
24203
|
+
},
|
|
24204
|
+
|
|
24205
|
+
/**
|
|
24206
|
+
* True if the password is visible ([type=text]).
|
|
24207
|
+
* @attr {boolean} password-visible
|
|
24208
|
+
*/
|
|
24209
|
+
passwordVisible: {
|
|
24210
|
+
type: Boolean,
|
|
24211
|
+
value: false,
|
|
24212
|
+
reflectToAttribute: true,
|
|
24213
|
+
observer: '_passwordVisibleChanged',
|
|
24214
|
+
readOnly: true,
|
|
24215
|
+
},
|
|
24216
|
+
|
|
24217
|
+
/**
|
|
24218
|
+
* An object with translated strings used for localization.
|
|
24219
|
+
* It has the following structure and default values:
|
|
24220
|
+
*
|
|
24221
|
+
* ```
|
|
24222
|
+
* {
|
|
24223
|
+
* // Translation of the reveal icon button accessible label
|
|
24224
|
+
* reveal: 'Show password'
|
|
24225
|
+
* }
|
|
24226
|
+
* ```
|
|
24227
|
+
*/
|
|
24228
|
+
i18n: {
|
|
24229
|
+
type: Object,
|
|
24230
|
+
value: () => {
|
|
24231
|
+
return {
|
|
24232
|
+
reveal: 'Show password',
|
|
24233
|
+
};
|
|
24234
|
+
},
|
|
24235
|
+
},
|
|
24236
|
+
};
|
|
24237
|
+
}
|
|
24238
|
+
|
|
24239
|
+
static get observers() {
|
|
24240
|
+
return ['__i18nChanged(i18n.*)'];
|
|
24241
|
+
}
|
|
24242
|
+
|
|
24243
|
+
/** @protected */
|
|
24244
|
+
get slotStyles() {
|
|
24245
|
+
const tag = this.localName;
|
|
24246
|
+
return [
|
|
24247
|
+
...super.slotStyles,
|
|
24248
|
+
`
|
|
24249
|
+
${tag} [slot="input"]::-ms-reveal {
|
|
24250
|
+
display: none;
|
|
24251
|
+
}
|
|
24252
|
+
`,
|
|
24253
|
+
];
|
|
24254
|
+
}
|
|
24255
|
+
|
|
24256
|
+
/** @protected */
|
|
24257
|
+
get _revealNode() {
|
|
24258
|
+
return this._revealButtonController && this._revealButtonController.node;
|
|
24259
|
+
}
|
|
24260
|
+
|
|
24261
|
+
constructor() {
|
|
24262
|
+
super();
|
|
24263
|
+
this._setType('password');
|
|
24264
|
+
this.__boundRevealButtonClick = this._onRevealButtonClick.bind(this);
|
|
24265
|
+
this.__boundRevealButtonTouchend = this._onRevealButtonTouchend.bind(this);
|
|
24266
|
+
}
|
|
24267
|
+
|
|
24268
|
+
/** @protected */
|
|
24269
|
+
ready() {
|
|
24270
|
+
super.ready();
|
|
24271
|
+
|
|
24272
|
+
this._revealPart = this.shadowRoot.querySelector('[part="reveal-button"]');
|
|
24273
|
+
|
|
24274
|
+
this._revealButtonController = new SlotController(
|
|
24275
|
+
this,
|
|
24276
|
+
'reveal',
|
|
24277
|
+
() => document.createElement('vaadin-password-field-button'),
|
|
24278
|
+
(host, btn) => {
|
|
24279
|
+
btn.disabled = host.disabled;
|
|
24280
|
+
|
|
24281
|
+
btn.addEventListener('click', host.__boundRevealButtonClick);
|
|
24282
|
+
btn.addEventListener('touchend', host.__boundRevealButtonTouchend);
|
|
24283
|
+
},
|
|
24284
|
+
);
|
|
24285
|
+
this.addController(this._revealButtonController);
|
|
24286
|
+
|
|
24287
|
+
this.__updateAriaLabel(this.i18n);
|
|
24288
|
+
|
|
24289
|
+
this._updateToggleState(false);
|
|
24290
|
+
this._toggleRevealHidden(this.revealButtonHidden);
|
|
24291
|
+
|
|
24292
|
+
if (this.inputElement) {
|
|
24293
|
+
this.inputElement.autocapitalize = 'off';
|
|
24294
|
+
}
|
|
24295
|
+
}
|
|
24296
|
+
|
|
24297
|
+
/**
|
|
24298
|
+
* Override method inherited from `FocusMixin` to mark field as focused
|
|
24299
|
+
* when focus moves to the reveal button using Shift Tab.
|
|
24300
|
+
* @param {Event} event
|
|
24301
|
+
* @return {boolean}
|
|
24302
|
+
* @protected
|
|
24303
|
+
*/
|
|
24304
|
+
_shouldSetFocus(event) {
|
|
24305
|
+
return event.target === this.inputElement || event.target === this._revealNode;
|
|
24306
|
+
}
|
|
24307
|
+
|
|
24308
|
+
/**
|
|
24309
|
+
* Override method inherited from `FocusMixin` to not hide password
|
|
24310
|
+
* when focus moves to the reveal button or back to the input.
|
|
24311
|
+
* @param {Event} event
|
|
24312
|
+
* @return {boolean}
|
|
24313
|
+
* @protected
|
|
24314
|
+
*/
|
|
24315
|
+
_shouldRemoveFocus(event) {
|
|
24316
|
+
return !(
|
|
24317
|
+
event.relatedTarget === this._revealNode ||
|
|
24318
|
+
(event.relatedTarget === this.inputElement && event.target === this._revealNode)
|
|
24319
|
+
);
|
|
24320
|
+
}
|
|
24321
|
+
|
|
24322
|
+
/**
|
|
24323
|
+
* Override method inherited from `FocusMixin` to toggle password visibility.
|
|
24324
|
+
* @param {boolean} focused
|
|
24325
|
+
* @protected
|
|
24326
|
+
* @override
|
|
24327
|
+
*/
|
|
24328
|
+
_setFocused(focused) {
|
|
24329
|
+
super._setFocused(focused);
|
|
24330
|
+
|
|
24331
|
+
if (!focused) {
|
|
24332
|
+
this._setPasswordVisible(false);
|
|
24333
|
+
} else {
|
|
24334
|
+
const isButtonFocused = this.getRootNode().activeElement === this._revealNode;
|
|
24335
|
+
// Remove focus-ring from the field when the reveal button gets focused
|
|
24336
|
+
this.toggleAttribute('focus-ring', this._keyboardActive && !isButtonFocused);
|
|
24337
|
+
}
|
|
24338
|
+
}
|
|
24339
|
+
|
|
24340
|
+
/** @private */
|
|
24341
|
+
__updateAriaLabel(i18n) {
|
|
24342
|
+
if (i18n.reveal && this._revealNode) {
|
|
24343
|
+
this._revealNode.setAttribute('aria-label', i18n.reveal);
|
|
24344
|
+
}
|
|
24345
|
+
}
|
|
24346
|
+
|
|
24347
|
+
/** @private */
|
|
24348
|
+
__i18nChanged(i18n) {
|
|
24349
|
+
this.__updateAriaLabel(i18n.base);
|
|
24350
|
+
}
|
|
24351
|
+
|
|
24352
|
+
/** @private */
|
|
24353
|
+
_revealButtonHiddenChanged(hidden) {
|
|
24354
|
+
this._toggleRevealHidden(hidden);
|
|
24355
|
+
}
|
|
24356
|
+
|
|
24357
|
+
/** @private */
|
|
24358
|
+
_togglePasswordVisibility() {
|
|
24359
|
+
this._setPasswordVisible(!this.passwordVisible);
|
|
24360
|
+
}
|
|
24361
|
+
|
|
24362
|
+
/** @private */
|
|
24363
|
+
_onRevealButtonClick() {
|
|
24364
|
+
this._togglePasswordVisibility();
|
|
24365
|
+
}
|
|
24366
|
+
|
|
24367
|
+
/** @private */
|
|
24368
|
+
_onRevealButtonTouchend(e) {
|
|
24369
|
+
// Cancel the following click event
|
|
24370
|
+
e.preventDefault();
|
|
24371
|
+
this._togglePasswordVisibility();
|
|
24372
|
+
// Focus the input to avoid problem with password still visible
|
|
24373
|
+
// when user clicks the reveal button and then clicks outside.
|
|
24374
|
+
this.inputElement.focus();
|
|
24375
|
+
}
|
|
24376
|
+
|
|
24377
|
+
/** @private */
|
|
24378
|
+
_toggleRevealHidden(hidden) {
|
|
24379
|
+
if (this._revealNode) {
|
|
24380
|
+
if (hidden) {
|
|
24381
|
+
this._revealPart.setAttribute('hidden', '');
|
|
24382
|
+
this._revealNode.setAttribute('tabindex', '-1');
|
|
24383
|
+
this._revealNode.setAttribute('aria-hidden', 'true');
|
|
24384
|
+
} else {
|
|
24385
|
+
this._revealPart.removeAttribute('hidden');
|
|
24386
|
+
this._revealNode.setAttribute('tabindex', '0');
|
|
24387
|
+
this._revealNode.removeAttribute('aria-hidden');
|
|
24388
|
+
}
|
|
24389
|
+
}
|
|
24390
|
+
}
|
|
24391
|
+
|
|
24392
|
+
/** @private */
|
|
24393
|
+
_updateToggleState(passwordVisible) {
|
|
24394
|
+
if (this._revealNode) {
|
|
24395
|
+
this._revealNode.setAttribute('aria-pressed', passwordVisible ? 'true' : 'false');
|
|
24396
|
+
}
|
|
24397
|
+
}
|
|
24398
|
+
|
|
24399
|
+
/** @private */
|
|
24400
|
+
_passwordVisibleChanged(passwordVisible) {
|
|
24401
|
+
this._setType(passwordVisible ? 'text' : 'password');
|
|
24402
|
+
|
|
24403
|
+
this._updateToggleState(passwordVisible);
|
|
24404
|
+
}
|
|
24405
|
+
|
|
24406
|
+
/**
|
|
24407
|
+
* Override method inherited from `DisabledMixin` to synchronize the reveal button
|
|
24408
|
+
* disabled state with the password field disabled state.
|
|
24409
|
+
* @param {boolean} disabled
|
|
24410
|
+
* @param {boolean} oldDisabled
|
|
24411
|
+
* @protected
|
|
24412
|
+
*/
|
|
24413
|
+
_disabledChanged(disabled, oldDisabled) {
|
|
24414
|
+
super._disabledChanged(disabled, oldDisabled);
|
|
24415
|
+
|
|
24416
|
+
if (this._revealNode) {
|
|
24417
|
+
this._revealNode.disabled = disabled;
|
|
24418
|
+
}
|
|
24419
|
+
}
|
|
24420
|
+
}
|
|
24421
|
+
|
|
24422
|
+
customElements.define(PasswordField.is, PasswordField);
|
|
24423
|
+
|
|
24424
|
+
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}";
|
|
24425
|
+
|
|
24426
|
+
const PasswordInput = class {
|
|
24427
|
+
constructor(hostRef) {
|
|
24428
|
+
index.registerInstance(this, hostRef);
|
|
24429
|
+
this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
|
|
24430
|
+
this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
|
|
24431
|
+
/**
|
|
24432
|
+
* Default value for the input.
|
|
24433
|
+
*/
|
|
24434
|
+
this.defaultValue = '';
|
|
24435
|
+
this.value = '';
|
|
24436
|
+
this.validationPattern = '';
|
|
24437
|
+
}
|
|
24438
|
+
validityChanged() {
|
|
24439
|
+
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
24440
|
+
if (this.emitValue == true) {
|
|
24441
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
24442
|
+
}
|
|
24443
|
+
}
|
|
24444
|
+
emitValueHandler(newValue) {
|
|
24445
|
+
if (newValue == true && this.isValid) {
|
|
24446
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
24447
|
+
}
|
|
24448
|
+
}
|
|
24449
|
+
validityStateHandler(inputStateEvent) {
|
|
24450
|
+
this.sendValidityState.emit(inputStateEvent);
|
|
24451
|
+
}
|
|
24452
|
+
valueHandler(inputValueEvent) {
|
|
24453
|
+
this.sendInputValue.emit(inputValueEvent);
|
|
24454
|
+
}
|
|
24455
|
+
valueChangedHandler(event) {
|
|
24456
|
+
if (this.isDuplicateInput) {
|
|
24457
|
+
if (this.name === event.detail.name + 'Duplicate') {
|
|
24458
|
+
this.duplicateInputValue = event.detail.value;
|
|
24459
|
+
}
|
|
24460
|
+
}
|
|
24461
|
+
}
|
|
24462
|
+
connectedCallback() {
|
|
24463
|
+
this.validationPattern = this.setPattern();
|
|
24464
|
+
}
|
|
24465
|
+
componentDidLoad() {
|
|
24466
|
+
this.inputReference = this.element.shadowRoot.querySelector('input');
|
|
24467
|
+
if (this.defaultValue) {
|
|
24468
|
+
this.value = this.defaultValue;
|
|
24469
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
24470
|
+
}
|
|
24471
|
+
}
|
|
24472
|
+
handleInput(event) {
|
|
24473
|
+
this.value = event.target.value;
|
|
24474
|
+
this.errorMessage = this.setErrorMessage();
|
|
24475
|
+
this.isValid = this.setValidity();
|
|
24476
|
+
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
24477
|
+
this.emitValueHandler(true);
|
|
24478
|
+
}
|
|
24479
|
+
setValidity() {
|
|
24480
|
+
return this.inputReference.validity.valid;
|
|
24481
|
+
}
|
|
24482
|
+
setPattern() {
|
|
24483
|
+
var _a, _b;
|
|
24484
|
+
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
24485
|
+
return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
|
|
24486
|
+
}
|
|
24487
|
+
}
|
|
24488
|
+
setErrorMessage() {
|
|
24489
|
+
var _a;
|
|
24490
|
+
if (this.inputReference.validity.patternMismatch) {
|
|
24491
|
+
return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
|
|
24492
|
+
}
|
|
24493
|
+
if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
|
|
24494
|
+
return translate$2('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
|
|
24495
|
+
}
|
|
24496
|
+
if (this.inputReference.validity.valueMissing) {
|
|
24497
|
+
return translate$2('requiredError', this.language);
|
|
24498
|
+
}
|
|
24499
|
+
if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
|
|
24500
|
+
return this.validation.custom.find(customRule => customRule.rule === 'duplicate-input').errorMessage;
|
|
24501
|
+
}
|
|
24502
|
+
}
|
|
24503
|
+
render() {
|
|
24504
|
+
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'password__input--invalid';
|
|
24505
|
+
return index.h("div", { class: 'password__wrapper' }, index.h("vaadin-password-field", { type: "password", id: `${this.name}__input`, class: `password__input ${invalidClass}`, name: this.name, readOnly: this.autofilled, value: this.defaultValue,
|
|
24506
|
+
// ref={(el) => this.inputReference = el as HTMLInputElement}
|
|
24507
|
+
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) }), index.h("label", { class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("small", { class: 'password__error-message' }, this.errorMessage));
|
|
24508
|
+
}
|
|
24509
|
+
get element() { return index.getElement(this); }
|
|
24510
|
+
static get watchers() { return {
|
|
24511
|
+
"isValid": ["validityChanged"],
|
|
24512
|
+
"emitValue": ["emitValueHandler"]
|
|
24513
|
+
}; }
|
|
24514
|
+
};
|
|
24515
|
+
PasswordInput.style = passwordInputCss;
|
|
24516
|
+
|
|
24517
|
+
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}";
|
|
24518
|
+
|
|
24519
|
+
const RadioInput = class {
|
|
24520
|
+
constructor(hostRef) {
|
|
24521
|
+
index.registerInstance(this, hostRef);
|
|
24522
|
+
this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
|
|
24523
|
+
this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
|
|
24524
|
+
}
|
|
24525
|
+
validityChanged() {
|
|
24526
|
+
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
24527
|
+
if (this.emitValue == true) {
|
|
24528
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
24529
|
+
}
|
|
24530
|
+
}
|
|
24531
|
+
emitValueHandler(newValue) {
|
|
24532
|
+
if (newValue == true && this.isValid) {
|
|
24533
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
24534
|
+
}
|
|
24535
|
+
}
|
|
24536
|
+
valueHandler(inputValueEvent) {
|
|
24537
|
+
this.sendInputValue.emit(inputValueEvent);
|
|
24538
|
+
}
|
|
24539
|
+
validityStateHandler(inputStateEvent) {
|
|
24540
|
+
this.sendValidityState.emit(inputStateEvent);
|
|
24541
|
+
}
|
|
24542
|
+
connectedCallback() {
|
|
24543
|
+
}
|
|
24544
|
+
handleClick(event) {
|
|
24545
|
+
this.value = event.target.value;
|
|
24546
|
+
this.isValid = this.setValidity();
|
|
24547
|
+
this.errorMessage = this.setErrorMessage();
|
|
24548
|
+
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
24549
|
+
this.emitValueHandler(true);
|
|
24550
|
+
}
|
|
24551
|
+
setValidity() {
|
|
24552
|
+
return this.inputReference.validity.valid;
|
|
24553
|
+
}
|
|
24554
|
+
setErrorMessage() {
|
|
24555
|
+
if (this.inputReference.validity.valueMissing) {
|
|
24556
|
+
return translate$2('requiredError', this.language);
|
|
24557
|
+
}
|
|
24558
|
+
}
|
|
24559
|
+
render() {
|
|
24560
|
+
return index.h("fieldset", { class: 'radio__fieldset' }, index.h("legend", { class: 'radio__legend' }, this.displayName, ":"), this.optionsGroup.map(option => index.h("div", { class: 'radio__wrapper' }, index.h("input", { type: "radio", class: 'radio__input', id: `${option.label}__input`, ref: (el) => this.inputReference = el, value: option.value, name: this.name, required: this.validation.mandatory, onClick: (e) => this.handleClick(e) }), index.h("label", { htmlFor: `${option.label}__input` }, option.label))), index.h("small", { class: 'radio__error-message' }, this.errorMessage));
|
|
24561
|
+
}
|
|
24562
|
+
static get watchers() { return {
|
|
24563
|
+
"isValid": ["validityChanged"],
|
|
24564
|
+
"emitValue": ["emitValueHandler"]
|
|
24565
|
+
}; }
|
|
24566
|
+
};
|
|
24567
|
+
RadioInput.style = radioInputCss;
|
|
24568
|
+
|
|
24569
|
+
/**
|
|
24570
|
+
* @license
|
|
24571
|
+
* Copyright (c) 2022 Vaadin Ltd.
|
|
24572
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
24573
|
+
*/
|
|
24574
|
+
|
|
24575
|
+
const loader = i$1`
|
|
24576
|
+
[part~='loader'] {
|
|
24577
|
+
box-sizing: border-box;
|
|
24578
|
+
width: var(--lumo-icon-size-s);
|
|
24579
|
+
height: var(--lumo-icon-size-s);
|
|
24580
|
+
border: 2px solid transparent;
|
|
24581
|
+
border-color: var(--lumo-primary-color-10pct) var(--lumo-primary-color-10pct) var(--lumo-primary-color)
|
|
24582
|
+
var(--lumo-primary-color);
|
|
24583
|
+
border-radius: calc(0.5 * var(--lumo-icon-size-s));
|
|
24584
|
+
opacity: 0;
|
|
24585
|
+
pointer-events: none;
|
|
24586
|
+
}
|
|
24587
|
+
|
|
24588
|
+
:host(:not([loading])) [part~='loader'] {
|
|
24589
|
+
display: none;
|
|
24590
|
+
}
|
|
24591
|
+
|
|
24592
|
+
:host([loading]) [part~='loader'] {
|
|
24593
|
+
animation: 1s linear infinite lumo-loader-rotate, 0.3s 0.1s lumo-loader-fade-in both;
|
|
24594
|
+
}
|
|
24595
|
+
|
|
24596
|
+
@keyframes lumo-loader-fade-in {
|
|
24597
|
+
0% {
|
|
24598
|
+
opacity: 0;
|
|
24599
|
+
}
|
|
24600
|
+
|
|
24601
|
+
100% {
|
|
24602
|
+
opacity: 1;
|
|
24603
|
+
}
|
|
24604
|
+
}
|
|
24605
|
+
|
|
24606
|
+
@keyframes lumo-loader-rotate {
|
|
24607
|
+
0% {
|
|
23936
24608
|
transform: rotate(0deg);
|
|
23937
24609
|
}
|
|
23938
24610
|
|
|
@@ -26250,87 +26922,6 @@ class ComboBoxScroller extends PolymerElement {
|
|
|
26250
26922
|
|
|
26251
26923
|
customElements.define(ComboBoxScroller.is, ComboBoxScroller);
|
|
26252
26924
|
|
|
26253
|
-
/**
|
|
26254
|
-
* @license
|
|
26255
|
-
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
26256
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
26257
|
-
*/
|
|
26258
|
-
|
|
26259
|
-
/**
|
|
26260
|
-
* A mixin to provide `pattern` and `preventInvalidInput` properties.
|
|
26261
|
-
*
|
|
26262
|
-
* @polymerMixin
|
|
26263
|
-
* @mixes InputConstraintsMixin
|
|
26264
|
-
*/
|
|
26265
|
-
const PatternMixin = (superclass) =>
|
|
26266
|
-
class PatternMixinClass extends InputConstraintsMixin(superclass) {
|
|
26267
|
-
static get properties() {
|
|
26268
|
-
return {
|
|
26269
|
-
/**
|
|
26270
|
-
* A regular expression that the value is checked against.
|
|
26271
|
-
* The pattern must match the entire value, not just some subset.
|
|
26272
|
-
*/
|
|
26273
|
-
pattern: {
|
|
26274
|
-
type: String,
|
|
26275
|
-
},
|
|
26276
|
-
|
|
26277
|
-
/**
|
|
26278
|
-
* When set to true, user is prevented from typing a value that
|
|
26279
|
-
* conflicts with the given `pattern`.
|
|
26280
|
-
* @attr {boolean} prevent-invalid-input
|
|
26281
|
-
* @deprecated Please use `allowedCharPattern` instead.
|
|
26282
|
-
*/
|
|
26283
|
-
preventInvalidInput: {
|
|
26284
|
-
type: Boolean,
|
|
26285
|
-
observer: '_preventInvalidInputChanged',
|
|
26286
|
-
},
|
|
26287
|
-
};
|
|
26288
|
-
}
|
|
26289
|
-
|
|
26290
|
-
static get delegateAttrs() {
|
|
26291
|
-
return [...super.delegateAttrs, 'pattern'];
|
|
26292
|
-
}
|
|
26293
|
-
|
|
26294
|
-
static get constraints() {
|
|
26295
|
-
return [...super.constraints, 'pattern'];
|
|
26296
|
-
}
|
|
26297
|
-
|
|
26298
|
-
/** @private */
|
|
26299
|
-
_checkInputValue() {
|
|
26300
|
-
if (this.preventInvalidInput) {
|
|
26301
|
-
const input = this.inputElement;
|
|
26302
|
-
if (input && input.value.length > 0 && !this.checkValidity()) {
|
|
26303
|
-
input.value = this.value || '';
|
|
26304
|
-
// Add input-prevented attribute for 200ms
|
|
26305
|
-
this.setAttribute('input-prevented', '');
|
|
26306
|
-
this._inputDebouncer = Debouncer$1.debounce(this._inputDebouncer, timeOut.after(200), () => {
|
|
26307
|
-
this.removeAttribute('input-prevented');
|
|
26308
|
-
});
|
|
26309
|
-
}
|
|
26310
|
-
}
|
|
26311
|
-
}
|
|
26312
|
-
|
|
26313
|
-
/**
|
|
26314
|
-
* @param {Event} event
|
|
26315
|
-
* @protected
|
|
26316
|
-
* @override
|
|
26317
|
-
*/
|
|
26318
|
-
_onInput(event) {
|
|
26319
|
-
this._checkInputValue();
|
|
26320
|
-
|
|
26321
|
-
super._onInput(event);
|
|
26322
|
-
}
|
|
26323
|
-
|
|
26324
|
-
/** @private */
|
|
26325
|
-
_preventInvalidInputChanged(preventInvalidInput) {
|
|
26326
|
-
if (preventInvalidInput) {
|
|
26327
|
-
console.warn(
|
|
26328
|
-
`WARNING: Since Vaadin 23.2, "preventInvalidInput" is deprecated. Please use "allowedCharPattern" instead.`,
|
|
26329
|
-
);
|
|
26330
|
-
}
|
|
26331
|
-
}
|
|
26332
|
-
};
|
|
26333
|
-
|
|
26334
26925
|
/**
|
|
26335
26926
|
* @license
|
|
26336
26927
|
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
@@ -28316,7 +28907,7 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
28316
28907
|
|
|
28317
28908
|
customElements.define(ComboBox.is, ComboBox);
|
|
28318
28909
|
|
|
28319
|
-
const selectInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.select__wrapper{position:relative;
|
|
28910
|
+
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}";
|
|
28320
28911
|
|
|
28321
28912
|
const SelectInput = class {
|
|
28322
28913
|
constructor(hostRef) {
|
|
@@ -28390,7 +28981,6 @@ const SelectInput = class {
|
|
|
28390
28981
|
this.isValid = this.setValidity();
|
|
28391
28982
|
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
28392
28983
|
this.emitValueHandler(true);
|
|
28393
|
-
this.inputReference.previousElementSibling.classList.remove('select__label--hidden');
|
|
28394
28984
|
}
|
|
28395
28985
|
setValidity() {
|
|
28396
28986
|
return this.inputReference.validity.valid;
|
|
@@ -28401,7 +28991,8 @@ const SelectInput = class {
|
|
|
28401
28991
|
}
|
|
28402
28992
|
}
|
|
28403
28993
|
render() {
|
|
28404
|
-
|
|
28994
|
+
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'select__input--invalid';
|
|
28995
|
+
return index.h("div", { class: 'select__wrapper' }, index.h("label", { class: 'select__label', htmlFor: `${this.name}__input` }, `${this.displayName} ${this.validation.mandatory ? '*' : ''}`), index.h("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) }), index.h("small", { class: 'select__error-message' }, this.errorMessage));
|
|
28405
28996
|
}
|
|
28406
28997
|
get element() { return index.getElement(this); }
|
|
28407
28998
|
static get watchers() { return {
|
|
@@ -28411,7 +29002,7 @@ const SelectInput = class {
|
|
|
28411
29002
|
};
|
|
28412
29003
|
SelectInput.style = selectInputCss;
|
|
28413
29004
|
|
|
28414
|
-
const telInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.tel__wrapper{position:relative;display:flex;
|
|
29005
|
+
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}";
|
|
28415
29006
|
|
|
28416
29007
|
const TelInput = class {
|
|
28417
29008
|
constructor(hostRef) {
|
|
@@ -28439,6 +29030,10 @@ const TelInput = class {
|
|
|
28439
29030
|
}
|
|
28440
29031
|
connectedCallback() {
|
|
28441
29032
|
this.validationPattern = this.setPattern();
|
|
29033
|
+
if (this.defaultValue) {
|
|
29034
|
+
this.prefixValue = this.defaultValue.split('|')[0];
|
|
29035
|
+
this.phoneValue = this.defaultValue.split('|')[1];
|
|
29036
|
+
}
|
|
28442
29037
|
}
|
|
28443
29038
|
componentWillLoad() {
|
|
28444
29039
|
if (this.action) {
|
|
@@ -28453,8 +29048,8 @@ const TelInput = class {
|
|
|
28453
29048
|
}
|
|
28454
29049
|
componentDidLoad() {
|
|
28455
29050
|
if (this.defaultValue) {
|
|
28456
|
-
this.
|
|
28457
|
-
this.valueHandler({ name: this.name, value:
|
|
29051
|
+
this.value = `${this.prefixValue}|${this.phoneValue}`;
|
|
29052
|
+
this.valueHandler({ name: this.name, value: this.value });
|
|
28458
29053
|
}
|
|
28459
29054
|
}
|
|
28460
29055
|
getPhoneCodes() {
|
|
@@ -28472,8 +29067,8 @@ const TelInput = class {
|
|
|
28472
29067
|
});
|
|
28473
29068
|
}
|
|
28474
29069
|
handleInput(event) {
|
|
28475
|
-
|
|
28476
|
-
this.value = `${this.prefixValue}|${
|
|
29070
|
+
this.phoneValue = event.target.value;
|
|
29071
|
+
this.value = `${this.prefixValue}|${this.phoneValue}`;
|
|
28477
29072
|
this.errorMessage = this.setErrorMessage();
|
|
28478
29073
|
this.isValid = this.setValidity();
|
|
28479
29074
|
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
@@ -28501,8 +29096,8 @@ const TelInput = class {
|
|
|
28501
29096
|
}
|
|
28502
29097
|
}
|
|
28503
29098
|
render() {
|
|
28504
|
-
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : '
|
|
28505
|
-
return index.h("div", { class: 'tel__wrapper' }, index.h("div", { class:
|
|
29099
|
+
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'tel__wrapper--flex--invalid';
|
|
29100
|
+
return index.h("div", { class: 'tel__wrapper' }, index.h("div", { class: `tel__wrapper--flex ${invalidClass}` }, index.h("vaadin-combo-box", { class: 'tel__prefix', items: this.phoneCodesOptions, value: this.prefixValue, readOnly: this.autofilled, onBlur: (e) => this.prefixValue = e.target.value }), index.h("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) })), index.h("label", { class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("small", { class: 'tel__error-message' }, this.errorMessage));
|
|
28506
29101
|
}
|
|
28507
29102
|
static get watchers() { return {
|
|
28508
29103
|
"isValid": ["validityChanged"],
|
|
@@ -28511,7 +29106,7 @@ const TelInput = class {
|
|
|
28511
29106
|
};
|
|
28512
29107
|
TelInput.style = telInputCss;
|
|
28513
29108
|
|
|
28514
|
-
const textInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.text__wrapper{position:relative;
|
|
29109
|
+
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}";
|
|
28515
29110
|
|
|
28516
29111
|
const TextInput = class {
|
|
28517
29112
|
constructor(hostRef) {
|
|
@@ -28532,17 +29127,24 @@ const TextInput = class {
|
|
|
28532
29127
|
this.valueHandler({ name: this.name, value: this.value });
|
|
28533
29128
|
}
|
|
28534
29129
|
}
|
|
28535
|
-
validityStateHandler(inputStateEvent) {
|
|
28536
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
28537
|
-
}
|
|
28538
29130
|
emitValueHandler(newValue) {
|
|
28539
29131
|
if (newValue == true && this.isValid) {
|
|
28540
29132
|
this.valueHandler({ name: this.name, value: this.value });
|
|
28541
29133
|
}
|
|
28542
29134
|
}
|
|
29135
|
+
validityStateHandler(inputStateEvent) {
|
|
29136
|
+
this.sendValidityState.emit(inputStateEvent);
|
|
29137
|
+
}
|
|
28543
29138
|
valueHandler(inputValueEvent) {
|
|
28544
29139
|
this.sendInputValue.emit(inputValueEvent);
|
|
28545
29140
|
}
|
|
29141
|
+
valueChangedHandler(event) {
|
|
29142
|
+
if (this.isDuplicateInput) {
|
|
29143
|
+
if (this.name === event.detail.name + 'Duplicate') {
|
|
29144
|
+
this.duplicateInputValue = event.detail.value;
|
|
29145
|
+
}
|
|
29146
|
+
}
|
|
29147
|
+
}
|
|
28546
29148
|
connectedCallback() {
|
|
28547
29149
|
this.validationPattern = this.setPattern();
|
|
28548
29150
|
}
|
|
@@ -28562,13 +29164,6 @@ const TextInput = class {
|
|
|
28562
29164
|
setValidity() {
|
|
28563
29165
|
return this.inputReference.validity.valid;
|
|
28564
29166
|
}
|
|
28565
|
-
// @TODO type here
|
|
28566
|
-
setCustomRules() {
|
|
28567
|
-
var _a;
|
|
28568
|
-
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
28569
|
-
return this.validation.custom.filter(customValidation => customValidation.rule !== 'regex');
|
|
28570
|
-
}
|
|
28571
|
-
}
|
|
28572
29167
|
setPattern() {
|
|
28573
29168
|
var _a, _b;
|
|
28574
29169
|
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
@@ -28586,10 +29181,13 @@ const TextInput = class {
|
|
|
28586
29181
|
if (this.inputReference.validity.valueMissing) {
|
|
28587
29182
|
return translate$2('requiredError', this.language);
|
|
28588
29183
|
}
|
|
29184
|
+
if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
|
|
29185
|
+
return this.validation.custom.find(customRule => customRule.rule === 'duplicate-input').errorMessage;
|
|
29186
|
+
}
|
|
28589
29187
|
}
|
|
28590
29188
|
render() {
|
|
28591
29189
|
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
|
|
28592
|
-
return index.h("div", { class: 'text__wrapper' }, index.h("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); } }), index.h("
|
|
29190
|
+
return index.h("div", { class: 'text__wrapper' }, index.h("label", { class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("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); } }), index.h("small", { class: 'text__error-message' }, this.errorMessage));
|
|
28593
29191
|
}
|
|
28594
29192
|
static get watchers() { return {
|
|
28595
29193
|
"isValid": ["validityChanged"],
|