@everymatrix/general-input 1.10.2 → 1.15.0
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-group-input_10.cjs.entry.js +35539 -0
- package/dist/cjs/general-input.cjs.entry.js +34 -13
- package/dist/cjs/general-input.cjs.js +2 -2
- package/dist/cjs/{index-64a5cb7f.js → index-132a0774.js} +119 -6
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/locale.utils-7665b010.js +71 -0
- package/dist/cjs/toggle-checkbox-input.cjs.entry.js +85 -0
- package/dist/cjs/tooltipIcon-092a795f.js +5 -0
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/checkbox-group-input/checkbox-group-input.css +62 -0
- package/dist/collection/components/checkbox-group-input/checkbox-group-input.js +366 -0
- package/dist/collection/components/checkbox-input/checkbox-input.css +47 -1
- package/dist/collection/components/checkbox-input/checkbox-input.js +143 -16
- package/dist/collection/components/date-input/date-input.css +64 -30
- package/dist/collection/components/date-input/date-input.js +194 -13
- package/dist/collection/components/email-input/email-input.css +63 -28
- package/dist/collection/components/email-input/email-input.js +197 -21
- package/dist/collection/components/general-input/general-input.js +163 -21
- package/dist/collection/components/number-input/number-input.css +65 -30
- package/dist/collection/components/number-input/number-input.js +174 -19
- package/dist/collection/components/password-input/password-input.css +120 -29
- package/dist/collection/components/password-input/password-input.js +341 -25
- package/dist/collection/components/radio-input/radio-input.css +22 -1
- package/dist/collection/components/radio-input/radio-input.js +89 -10
- package/dist/collection/components/select-input/select-input.css +75 -22
- package/dist/collection/components/select-input/select-input.js +180 -37
- package/dist/collection/components/tel-input/tel-input.css +91 -33
- package/dist/collection/components/tel-input/tel-input.js +202 -24
- package/dist/collection/components/text-input/text-input.css +63 -28
- package/dist/collection/components/text-input/text-input.js +208 -39
- package/dist/collection/components/toggle-checkbox-input/toggle-checkbox-input.css +76 -0
- package/dist/collection/components/toggle-checkbox-input/toggle-checkbox-input.js +324 -0
- package/dist/collection/utils/locale.utils.js +52 -13
- package/dist/collection/utils/tooltipIcon.svg +5 -0
- package/dist/components/active-mixin.js +975 -0
- package/dist/components/checkbox-group-input.d.ts +11 -0
- package/dist/components/checkbox-group-input.js +6 -0
- package/dist/components/checkbox-group-input2.js +1125 -0
- package/dist/components/checkbox-input2.js +62 -12
- package/dist/components/date-input2.js +10247 -15
- package/dist/components/email-input2.js +98 -21
- package/dist/components/field-mixin.js +12712 -0
- package/dist/components/general-input.js +1 -118
- package/dist/components/general-input2.js +331 -0
- package/dist/components/input-field-shared-styles.js +1114 -0
- package/dist/components/number-input2.js +92 -16
- package/dist/components/password-input2.js +924 -24
- package/dist/components/pattern-mixin.js +85 -0
- package/dist/components/radio-input2.js +45 -11
- package/dist/components/select-input2.js +87 -27
- package/dist/components/tel-input2.js +122 -22
- package/dist/components/text-input2.js +120 -34
- package/dist/components/toggle-checkbox-input.d.ts +11 -0
- package/dist/components/toggle-checkbox-input.js +6 -0
- package/dist/components/tooltipIcon.js +70 -0
- package/dist/components/vaadin-button.js +461 -0
- package/dist/components/vaadin-combo-box.js +4329 -0
- package/dist/components/virtual-keyboard-controller.js +2658 -0
- package/dist/esm/checkbox-group-input_10.entry.js +35526 -0
- package/dist/esm/general-input.entry.js +34 -13
- package/dist/esm/general-input.js +2 -2
- package/dist/esm/{index-df80f936.js → index-db76d5b5.js} +118 -7
- package/dist/esm/loader.js +2 -2
- package/dist/esm/locale.utils-95ea2605.js +68 -0
- package/dist/esm/toggle-checkbox-input.entry.js +81 -0
- package/dist/esm/tooltipIcon-99c1c7b7.js +3 -0
- package/dist/general-input/general-input.esm.js +1 -1
- package/dist/general-input/p-0966f523.entry.js +3581 -0
- package/dist/general-input/p-916a1319.entry.js +1 -0
- package/dist/general-input/p-b408093e.js +1 -0
- package/dist/general-input/p-c2d4d6ac.entry.js +1 -0
- package/dist/general-input/p-f4f4ccda.js +1 -0
- package/dist/general-input/p-f6132f1d.js +1 -0
- package/dist/types/components/checkbox-group-input/checkbox-group-input.d.ts +74 -0
- package/dist/types/components/checkbox-input/checkbox-input.d.ts +28 -2
- package/dist/types/components/date-input/date-input.d.ts +43 -1
- package/dist/types/components/email-input/email-input.d.ts +37 -3
- package/dist/types/components/general-input/general-input.d.ts +30 -0
- package/dist/types/components/number-input/number-input.d.ts +34 -3
- package/dist/types/components/password-input/password-input.d.ts +56 -7
- package/dist/types/components/radio-input/radio-input.d.ts +17 -1
- package/dist/types/components/select-input/select-input.d.ts +36 -3
- package/dist/types/components/tel-input/tel-input.d.ts +40 -5
- package/dist/types/components/text-input/text-input.d.ts +84 -0
- package/dist/types/components/toggle-checkbox-input/toggle-checkbox-input.d.ts +67 -0
- package/dist/types/components.d.ts +568 -9
- package/dist/types/utils/locale.utils.d.ts +9 -0
- package/dist/types/utils/types.d.ts +41 -9
- package/package.json +8 -1
- package/dist/cjs/checkbox-input_9.cjs.entry.js +0 -623
- package/dist/components/locale.utils.js +0 -29
- package/dist/esm/checkbox-input_9.entry.js +0 -611
- package/dist/general-input/p-1703fce3.entry.js +0 -1
- package/dist/general-input/p-d9f7fa2e.js +0 -1
- package/dist/general-input/p-dea0a4ac.entry.js +0 -1
- /package/dist/types/Users/{user/workspace/everymatrix → adrian.pripon/Documents/Work}/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +0 -0
|
@@ -1,623 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-64a5cb7f.js');
|
|
6
|
-
|
|
7
|
-
const DEFAULT_LANGUAGE = 'en';
|
|
8
|
-
const SUPPORTED_LANGUAGES = ['ro', 'en'];
|
|
9
|
-
const TRANSLATIONS = {
|
|
10
|
-
en: {
|
|
11
|
-
dateError: 'The selected date should be between {min} and {max}',
|
|
12
|
-
numberLengthError: 'The number should be between ${min} and ${max}',
|
|
13
|
-
lengthError: `The length should be between {minLength} and {maxLength}`,
|
|
14
|
-
requiredError: 'This input is required.',
|
|
15
|
-
nextButton: 'Next',
|
|
16
|
-
backButton: 'Back'
|
|
17
|
-
},
|
|
18
|
-
ro: {
|
|
19
|
-
lengthError: `Cuvântul introdus este prea scurt. {minLength} and {maxLength}`,
|
|
20
|
-
requiredError: 'Acest câmp este obligatoriu.'
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const translate = (key, customLang, values) => {
|
|
24
|
-
const lang = customLang;
|
|
25
|
-
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
26
|
-
if (values !== undefined) {
|
|
27
|
-
for (const [key, value] of Object.entries(values.values)) {
|
|
28
|
-
const regex = new RegExp(`{${key}}`, 'g');
|
|
29
|
-
translation = translation.replace(regex, value);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return translation;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
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:red}";
|
|
36
|
-
|
|
37
|
-
const CheckboxInput = class {
|
|
38
|
-
constructor(hostRef) {
|
|
39
|
-
index.registerInstance(this, hostRef);
|
|
40
|
-
this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
|
|
41
|
-
this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
|
|
42
|
-
}
|
|
43
|
-
validityChanged() {
|
|
44
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
45
|
-
if (this.emitValue == true) {
|
|
46
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
validityStateHandler(inputStateEvent) {
|
|
50
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
51
|
-
}
|
|
52
|
-
emitValueHandler(newValue) {
|
|
53
|
-
if (newValue == true && this.isValid) {
|
|
54
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
valueHandler(inputValueEvent) {
|
|
58
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
59
|
-
}
|
|
60
|
-
connectedCallback() {
|
|
61
|
-
}
|
|
62
|
-
handleClick() {
|
|
63
|
-
this.value = this.inputReference.checked;
|
|
64
|
-
this.errorMessage = this.setErrorMessage();
|
|
65
|
-
this.isValid = this.setValidity();
|
|
66
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
67
|
-
this.emitValueHandler(true);
|
|
68
|
-
}
|
|
69
|
-
setValidity() {
|
|
70
|
-
return this.inputReference.validity.valid;
|
|
71
|
-
}
|
|
72
|
-
setErrorMessage() {
|
|
73
|
-
if (this.inputReference.validity.valueMissing) {
|
|
74
|
-
return translate('requiredError', this.language);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
render() {
|
|
78
|
-
return index.h("div", { class: 'checkbox__wrapper' }, index.h("input", { type: "checkbox", id: `${this.name}__input`, ref: (el) => this.inputReference = el, name: this.name, required: this.validation.mandatory, value: 'jdjdj', onClick: () => this.handleClick() }), index.h("label", { htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), index.h("small", { class: 'checkbox__error-message' }, this.errorMessage));
|
|
79
|
-
}
|
|
80
|
-
static get watchers() { return {
|
|
81
|
-
"isValid": ["validityChanged"],
|
|
82
|
-
"emitValue": ["emitValueHandler"]
|
|
83
|
-
}; }
|
|
84
|
-
};
|
|
85
|
-
CheckboxInput.style = checkboxInputCss;
|
|
86
|
-
|
|
87
|
-
const dateInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.date__wrapper{position:relative;display:flex;flex-direction:column-reverse;padding-top:10px}.date__label{color:#474747;font-size:16px;position:absolute;bottom:15px;left:5px;transform:translateY(-25px);transition:all 0.3s cubic-bezier(0.5, 0, 0.5, 1)}.date__label--required::after{content:\"*\";margin-left:5px;color:#666666}.date__input{width:inherit;padding:15px 6px;position:relative;border:none;border-bottom:3px solid #666666;background-color:transparent;color:#666666;font-size:16px;font-family:inherit}.date__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.date__input::placeholder{color:#666666}.date__input--invalid{border-bottom:3px solid #cc0000}.date__input:placeholder-shown+.date__label{opacity:0;visibility:hidden;transform:translateY(0)}.date__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
|
|
88
|
-
|
|
89
|
-
const DateInput = class {
|
|
90
|
-
constructor(hostRef) {
|
|
91
|
-
index.registerInstance(this, hostRef);
|
|
92
|
-
this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
|
|
93
|
-
this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
|
|
94
|
-
}
|
|
95
|
-
validityChanged() {
|
|
96
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
97
|
-
if (this.emitValue == true) {
|
|
98
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
validityStateHandler(inputStateEvent) {
|
|
102
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
103
|
-
}
|
|
104
|
-
emitValueHandler(newValue) {
|
|
105
|
-
if (newValue == true && this.isValid) {
|
|
106
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
valueHandler(inputValueEvent) {
|
|
110
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
111
|
-
}
|
|
112
|
-
handleInput(event) {
|
|
113
|
-
this.value = event.target.value;
|
|
114
|
-
this.errorMessage = this.setErrorMessage();
|
|
115
|
-
this.isValid = this.setValidity();
|
|
116
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
117
|
-
this.emitValueHandler(true);
|
|
118
|
-
}
|
|
119
|
-
setValidity() {
|
|
120
|
-
return this.inputReference.validity.valid;
|
|
121
|
-
}
|
|
122
|
-
setErrorMessage() {
|
|
123
|
-
if (this.inputReference.validity.rangeUnderflow || this.inputReference.validity.rangeOverflow) {
|
|
124
|
-
return translate('dateError', this.language, { values: { min: this.validation.min, max: this.validation.max } });
|
|
125
|
-
}
|
|
126
|
-
if (this.inputReference.validity.valueMissing) {
|
|
127
|
-
return translate('requiredError', this.language);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
render() {
|
|
131
|
-
return index.h("div", { class: 'date__wrapper' }, index.h("input", { id: `${this.name}__input`, type: 'date', class: `date__input`, value: this.defaultValue, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, required: this.validation.mandatory, max: this.validation.max, min: this.validation.min, onInput: (e) => this.handleInput(e) }), index.h("label", { class: `date__label ${this.validation.mandatory ? 'date__label--required' : ''}}`, htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), index.h("small", { class: 'date__error-message' }, this.errorMessage));
|
|
132
|
-
}
|
|
133
|
-
static get watchers() { return {
|
|
134
|
-
"isValid": ["validityChanged"],
|
|
135
|
-
"emitValue": ["emitValueHandler"]
|
|
136
|
-
}; }
|
|
137
|
-
};
|
|
138
|
-
DateInput.style = dateInputCss;
|
|
139
|
-
|
|
140
|
-
const emailInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.email__wrapper{position:relative;display:flex;flex-direction:column-reverse;padding-top:10px}.email__label{color:#474747;font-size:16px;position:absolute;bottom:15px;left:5px;transform:translateY(-25px);transition:all 0.3s cubic-bezier(0.5, 0, 0.5, 1)}.email__label--required::after{content:\"*\";margin-left:5px;color:#666666}.email__input{width:inherit;padding:15px 6px;position:relative;border:none;border-bottom:3px solid #666666;background-color:transparent;color:#666666;font-size:16px;font-family:inherit}.email__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.email__input::placeholder{color:#666666}.email__input--invalid{border-bottom:3px solid #cc0000}.email__input:placeholder-shown+.email__label{opacity:0;visibility:hidden;transform:translateY(0)}.email__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
|
|
141
|
-
|
|
142
|
-
const EmailInput = class {
|
|
143
|
-
constructor(hostRef) {
|
|
144
|
-
index.registerInstance(this, hostRef);
|
|
145
|
-
this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
|
|
146
|
-
this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
|
|
147
|
-
this.validationPattern = '';
|
|
148
|
-
}
|
|
149
|
-
validityChanged() {
|
|
150
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
151
|
-
if (this.emitValue == true) {
|
|
152
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
validityStateHandler(inputStateEvent) {
|
|
156
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
157
|
-
}
|
|
158
|
-
emitValueHandler(newValue) {
|
|
159
|
-
if (newValue == true && this.isValid) {
|
|
160
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
valueHandler(inputValueEvent) {
|
|
164
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
165
|
-
}
|
|
166
|
-
connectedCallback() {
|
|
167
|
-
this.validationPattern = this.setPattern();
|
|
168
|
-
}
|
|
169
|
-
handleInput(event) {
|
|
170
|
-
this.value = event.target.value;
|
|
171
|
-
this.errorMessage = this.setErrorMessage();
|
|
172
|
-
this.isValid = this.setValidity();
|
|
173
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
174
|
-
this.emitValueHandler(true);
|
|
175
|
-
}
|
|
176
|
-
setValidity() {
|
|
177
|
-
return this.inputReference.validity.valid;
|
|
178
|
-
}
|
|
179
|
-
setPattern() {
|
|
180
|
-
var _a;
|
|
181
|
-
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
182
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
setErrorMessage() {
|
|
186
|
-
if (this.inputReference.validity.patternMismatch) {
|
|
187
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
|
|
188
|
-
}
|
|
189
|
-
if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
|
|
190
|
-
return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
|
|
191
|
-
}
|
|
192
|
-
if (this.inputReference.validity.valueMissing) {
|
|
193
|
-
return translate('requiredError', this.language);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
render() {
|
|
197
|
-
return index.h("div", { class: 'email__wrapper' }, index.h("input", { id: `${this.name}__input`, type: 'email', class: `email__input`, value: this.defaultValue, 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, onInput: (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));
|
|
198
|
-
}
|
|
199
|
-
static get watchers() { return {
|
|
200
|
-
"isValid": ["validityChanged"],
|
|
201
|
-
"emitValue": ["emitValueHandler"]
|
|
202
|
-
}; }
|
|
203
|
-
};
|
|
204
|
-
EmailInput.style = emailInputCss;
|
|
205
|
-
|
|
206
|
-
const numberInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.number__wrapper{position:relative;display:flex;flex-direction:column-reverse;padding-top:10px}.number__label{color:#474747;font-size:16px;position:absolute;bottom:15px;left:5px;transform:translateY(-25px);transition:all 0.3s cubic-bezier(0.5, 0, 0.5, 1)}.number__label--required::after{content:\"*\";margin-left:5px;color:#666666}.number__input{width:inherit;padding:15px 6px;position:relative;border:none;border-bottom:3px solid #666666;background-color:transparent;color:#666666;font-size:16px;font-family:inherit;-moz-appearance:textfield;}.number__input::-webkit-outer-spin-button,.number__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.number__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.number__input::placeholder{color:#666666}.number__input--invalid{border-bottom:3px solid #cc0000}.number__input:placeholder-shown+.number__label{opacity:0;visibility:hidden;transform:translateY(0)}.number__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
|
|
207
|
-
|
|
208
|
-
const NumberInput = class {
|
|
209
|
-
constructor(hostRef) {
|
|
210
|
-
index.registerInstance(this, hostRef);
|
|
211
|
-
this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
|
|
212
|
-
this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
|
|
213
|
-
}
|
|
214
|
-
validityChanged() {
|
|
215
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
216
|
-
if (this.emitValue == true) {
|
|
217
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
validityStateHandler(inputStateEvent) {
|
|
221
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
222
|
-
}
|
|
223
|
-
emitValueHandler(newValue) {
|
|
224
|
-
if (newValue == true && this.isValid) {
|
|
225
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
valueHandler(inputValueEvent) {
|
|
229
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
230
|
-
}
|
|
231
|
-
handleInput(event) {
|
|
232
|
-
this.value = event.target.value;
|
|
233
|
-
this.errorMessage = this.setErrorMessage();
|
|
234
|
-
this.isValid = this.setValidity();
|
|
235
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
236
|
-
this.emitValueHandler(true);
|
|
237
|
-
}
|
|
238
|
-
setValidity() {
|
|
239
|
-
return this.inputReference.validity.valid;
|
|
240
|
-
}
|
|
241
|
-
setErrorMessage() {
|
|
242
|
-
if (this.inputReference.validity.rangeUnderflow || this.inputReference.validity.rangeOverflow) {
|
|
243
|
-
return translate('numberLengthError', this.language, { values: { min: this.validation.min, max: this.validation.max } });
|
|
244
|
-
}
|
|
245
|
-
if (this.inputReference.validity.valueMissing) {
|
|
246
|
-
return translate('requiredError', this.language);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
render() {
|
|
250
|
-
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'number__input--invalid';
|
|
251
|
-
return index.h("div", { class: 'number__wrapper' }, index.h("input", { ref: (el) => this.inputReference = el, type: "number", value: this.defaultValue, id: `${this.name}__input`, class: `number__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, max: this.validation.max, min: this.validation.min, onInput: (e) => this.handleInput(e) }), index.h("label", { class: `number__label ${this.validation.mandatory ? 'number__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("small", { class: 'number__error-message' }, this.errorMessage));
|
|
252
|
-
}
|
|
253
|
-
static get watchers() { return {
|
|
254
|
-
"isValid": ["validityChanged"],
|
|
255
|
-
"emitValue": ["emitValueHandler"]
|
|
256
|
-
}; }
|
|
257
|
-
};
|
|
258
|
-
NumberInput.style = numberInputCss;
|
|
259
|
-
|
|
260
|
-
const passwordInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.password__wrapper{position:relative;display:flex;flex-direction:column-reverse;padding-top:10px}.password__label{color:#474747;font-size:16px;position:absolute;bottom:15px;left:5px;transform:translateY(-25px);transition:all 0.3s cubic-bezier(0.5, 0, 0.5, 1)}.password__label--required::after{content:\"*\";margin-left:5px;color:#666666}.password__input{width:inherit;padding:15px 6px;position:relative;border:none;border-bottom:3px solid #666666;background-color:transparent;color:#666666;font-size:16px;font-family:inherit}.password__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.password__input::placeholder{color:#666666}.password__input--invalid{border-bottom:3px solid #cc0000}.password__input:placeholder-shown+.password__label{opacity:0;visibility:hidden;transform:translateY(0)}.password__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
|
|
261
|
-
|
|
262
|
-
const PasswordInput = class {
|
|
263
|
-
constructor(hostRef) {
|
|
264
|
-
index.registerInstance(this, hostRef);
|
|
265
|
-
this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
|
|
266
|
-
this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
|
|
267
|
-
this.validationPattern = '';
|
|
268
|
-
}
|
|
269
|
-
validityChanged() {
|
|
270
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
271
|
-
if (this.emitValue == true) {
|
|
272
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
validityStateHandler(inputStateEvent) {
|
|
276
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
277
|
-
}
|
|
278
|
-
emitValueHandler(newValue) {
|
|
279
|
-
if (newValue == true && this.isValid) {
|
|
280
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
valueHandler(inputValueEvent) {
|
|
284
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
285
|
-
}
|
|
286
|
-
connectedCallback() {
|
|
287
|
-
this.validationPattern = this.setPattern();
|
|
288
|
-
}
|
|
289
|
-
handleInput(event) {
|
|
290
|
-
this.value = event.target.value;
|
|
291
|
-
this.errorMessage = this.setErrorMessage();
|
|
292
|
-
this.isValid = this.setValidity();
|
|
293
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
294
|
-
this.emitValueHandler(true);
|
|
295
|
-
}
|
|
296
|
-
setValidity() {
|
|
297
|
-
return this.inputReference.validity.valid;
|
|
298
|
-
}
|
|
299
|
-
setPattern() {
|
|
300
|
-
var _a;
|
|
301
|
-
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
302
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
setErrorMessage() {
|
|
306
|
-
if (this.inputReference.validity.patternMismatch) {
|
|
307
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
|
|
308
|
-
}
|
|
309
|
-
if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
|
|
310
|
-
return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
|
|
311
|
-
}
|
|
312
|
-
if (this.inputReference.validity.valueMissing) {
|
|
313
|
-
return translate('requiredError', this.language);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
render() {
|
|
317
|
-
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'password__input--invalid';
|
|
318
|
-
return index.h("div", { class: 'password__wrapper' }, index.h("input", { type: "password", id: `${this.name}__input`, class: `password__input ${invalidClass}`, name: this.name, 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));
|
|
319
|
-
}
|
|
320
|
-
static get watchers() { return {
|
|
321
|
-
"isValid": ["validityChanged"],
|
|
322
|
-
"emitValue": ["emitValueHandler"]
|
|
323
|
-
}; }
|
|
324
|
-
};
|
|
325
|
-
PasswordInput.style = passwordInputCss;
|
|
326
|
-
|
|
327
|
-
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}";
|
|
328
|
-
|
|
329
|
-
const RadioInput = class {
|
|
330
|
-
constructor(hostRef) {
|
|
331
|
-
index.registerInstance(this, hostRef);
|
|
332
|
-
this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
|
|
333
|
-
this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
|
|
334
|
-
}
|
|
335
|
-
validityChanged() {
|
|
336
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
337
|
-
if (this.emitValue == true) {
|
|
338
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
emitValueHandler(newValue) {
|
|
342
|
-
if (newValue == true && this.isValid) {
|
|
343
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
valueHandler(inputValueEvent) {
|
|
347
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
348
|
-
}
|
|
349
|
-
validityStateHandler(inputStateEvent) {
|
|
350
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
351
|
-
}
|
|
352
|
-
connectedCallback() {
|
|
353
|
-
}
|
|
354
|
-
handleClick(event) {
|
|
355
|
-
this.value = event.target.value;
|
|
356
|
-
this.isValid = this.setValidity();
|
|
357
|
-
this.errorMessage = this.setErrorMessage();
|
|
358
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
359
|
-
this.emitValueHandler(true);
|
|
360
|
-
}
|
|
361
|
-
setValidity() {
|
|
362
|
-
return this.inputReference.validity.valid;
|
|
363
|
-
}
|
|
364
|
-
setErrorMessage() {
|
|
365
|
-
if (this.inputReference.validity.valueMissing) {
|
|
366
|
-
return translate('requiredError', this.language);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
render() {
|
|
370
|
-
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));
|
|
371
|
-
}
|
|
372
|
-
static get watchers() { return {
|
|
373
|
-
"isValid": ["validityChanged"],
|
|
374
|
-
"emitValue": ["emitValueHandler"]
|
|
375
|
-
}; }
|
|
376
|
-
};
|
|
377
|
-
RadioInput.style = radioInputCss;
|
|
378
|
-
|
|
379
|
-
const selectInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.select__wrapper{position:relative;display:flex;padding-top:10px;width:100%}.select__label{color:#474747;font-size:16px;position:absolute;bottom:15px;left:5px;transform:translateY(-25px);transition:all 0.3s cubic-bezier(0.5, 0, 0.5, 1)}.select__label--hidden{opacity:0;visibility:hidden;transform:translateY(0)}.select__input{width:inherit;padding:15px 6px;position:relative;border:none;border-bottom:3px solid #666666;background-color:transparent;color:#666666;font-size:16px;font-family:inherit}.select__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.select__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
|
|
380
|
-
|
|
381
|
-
const SelectInput = class {
|
|
382
|
-
constructor(hostRef) {
|
|
383
|
-
index.registerInstance(this, hostRef);
|
|
384
|
-
this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
|
|
385
|
-
this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
|
|
386
|
-
/**
|
|
387
|
-
* Options of the input.
|
|
388
|
-
*/
|
|
389
|
-
this.options = [];
|
|
390
|
-
}
|
|
391
|
-
validityChanged() {
|
|
392
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
393
|
-
if (this.emitValue == true) {
|
|
394
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
validityStateHandler(inputStateEvent) {
|
|
398
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
399
|
-
}
|
|
400
|
-
emitValueHandler(newValue) {
|
|
401
|
-
if (newValue == true && this.isValid) {
|
|
402
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
valueHandler(inputValueEvent) {
|
|
406
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
407
|
-
}
|
|
408
|
-
connectedCallback() {
|
|
409
|
-
this.displayedOptions = this.options;
|
|
410
|
-
}
|
|
411
|
-
componentWillLoad() {
|
|
412
|
-
if (this.action && !this.options.length) {
|
|
413
|
-
if (this.action.split(" ")[0] == 'GET') {
|
|
414
|
-
return this.getOptions().then((options) => {
|
|
415
|
-
this.displayedOptions = options.countries.map(option => {
|
|
416
|
-
return { label: option.Name, value: option.Alpha2Code };
|
|
417
|
-
});
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
getOptions() {
|
|
423
|
-
// TEMPORARY FOR DEMO PURPOSES UNTIL NORWAY CONFIGURES AN ACTUAL ENDPOINT...
|
|
424
|
-
const url = new URL("https://demo-api.stage.norway.everymatrix.com/v1/player/countries");
|
|
425
|
-
return new Promise((resolve, reject) => {
|
|
426
|
-
fetch(url.href)
|
|
427
|
-
.then((res) => res.json())
|
|
428
|
-
.then((options) => {
|
|
429
|
-
resolve(options);
|
|
430
|
-
}).catch((err) => {
|
|
431
|
-
console.error(err);
|
|
432
|
-
reject(err);
|
|
433
|
-
});
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
handleChange(event) {
|
|
437
|
-
this.value = event.target.value;
|
|
438
|
-
this.errorMessage = this.setErrorMessage();
|
|
439
|
-
this.isValid = this.setValidity();
|
|
440
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
441
|
-
this.emitValueHandler(true);
|
|
442
|
-
this.inputReference.previousElementSibling.classList.remove('select__label--hidden');
|
|
443
|
-
}
|
|
444
|
-
setValidity() {
|
|
445
|
-
return this.inputReference.validity.valid;
|
|
446
|
-
}
|
|
447
|
-
setErrorMessage() {
|
|
448
|
-
if (this.inputReference.validity.valueMissing) {
|
|
449
|
-
return translate('requiredError', this.language);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
render() {
|
|
453
|
-
console.log('RENDER');
|
|
454
|
-
return index.h("div", { class: 'select__wrapper' }, index.h("label", { class: 'select__label select__label--hidden', htmlFor: `${this.name}__input` }, this.displayName, ":"), index.h("select", { ref: (el) => this.inputReference = el, name: this.name, id: `${this.name}__input`, required: this.validation.mandatory, class: 'select__input', onChange: (e) => this.handleChange(e) }, index.h("option", { value: "", selected: true, disabled: true }, " ", this.displayName, " "), this.displayedOptions.map(option => {
|
|
455
|
-
return index.h("option", { value: option.value }, " ", option.label, " ");
|
|
456
|
-
})), index.h("small", { class: 'select__error-message' }, this.errorMessage));
|
|
457
|
-
}
|
|
458
|
-
static get watchers() { return {
|
|
459
|
-
"isValid": ["validityChanged"],
|
|
460
|
-
"emitValue": ["emitValueHandler"]
|
|
461
|
-
}; }
|
|
462
|
-
};
|
|
463
|
-
SelectInput.style = selectInputCss;
|
|
464
|
-
|
|
465
|
-
const telInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.tel__wrapper{position:relative;display:flex;flex-direction:column-reverse;padding-top:10px}.tel__label{color:#474747;font-size:16px;position:absolute;bottom:15px;left:5px;transform:translateY(-25px);transition:all 0.3s cubic-bezier(0.5, 0, 0.5, 1)}.tel__label--required::after{content:\"*\";margin-left:5px;color:#666666}.tel__input{width:inherit;padding:15px 6px;position:relative;border:none;border-bottom:3px solid #666666;background-color:transparent;color:#666666;font-size:16px;font-family:inherit;-moz-appearance:textfield;}.tel__input::-webkit-outer-spin-button,.tel__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.tel__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.tel__input::placeholder{color:#666666}.tel__input--invalid{border-bottom:3px solid #cc0000}.tel__input:placeholder-shown+.tel__label{opacity:0;visibility:hidden;transform:translateY(0)}.tel__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
|
|
466
|
-
|
|
467
|
-
const TelInput = class {
|
|
468
|
-
constructor(hostRef) {
|
|
469
|
-
index.registerInstance(this, hostRef);
|
|
470
|
-
this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
|
|
471
|
-
this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
|
|
472
|
-
this.validationPattern = '';
|
|
473
|
-
}
|
|
474
|
-
validityChanged() {
|
|
475
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
476
|
-
if (this.emitValue == true) {
|
|
477
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
validityStateHandler(inputStateEvent) {
|
|
481
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
482
|
-
}
|
|
483
|
-
emitValueHandler(newValue) {
|
|
484
|
-
if (newValue == true && this.isValid) {
|
|
485
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
valueHandler(inputValueEvent) {
|
|
489
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
490
|
-
}
|
|
491
|
-
connectedCallback() {
|
|
492
|
-
this.validationPattern = this.setPattern();
|
|
493
|
-
}
|
|
494
|
-
handleInput(event) {
|
|
495
|
-
this.value = event.target.value;
|
|
496
|
-
this.errorMessage = this.setErrorMessage();
|
|
497
|
-
this.isValid = this.setValidity();
|
|
498
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
499
|
-
this.emitValueHandler(true);
|
|
500
|
-
}
|
|
501
|
-
setValidity() {
|
|
502
|
-
return this.inputReference.validity.valid;
|
|
503
|
-
}
|
|
504
|
-
setPattern() {
|
|
505
|
-
var _a;
|
|
506
|
-
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
507
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
setErrorMessage() {
|
|
511
|
-
if (this.inputReference.validity.patternMismatch) {
|
|
512
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
|
|
513
|
-
}
|
|
514
|
-
if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
|
|
515
|
-
return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
|
|
516
|
-
}
|
|
517
|
-
if (this.inputReference.validity.valueMissing) {
|
|
518
|
-
return translate('requiredError', this.language);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
render() {
|
|
522
|
-
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'tel__input--invalid';
|
|
523
|
-
return index.h("div", { class: 'tel__wrapper' }, index.h("input", { type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, value: this.defaultValue, class: `tel__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onInput: (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));
|
|
524
|
-
}
|
|
525
|
-
static get watchers() { return {
|
|
526
|
-
"isValid": ["validityChanged"],
|
|
527
|
-
"emitValue": ["emitValueHandler"]
|
|
528
|
-
}; }
|
|
529
|
-
};
|
|
530
|
-
TelInput.style = telInputCss;
|
|
531
|
-
|
|
532
|
-
const textInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.text__wrapper{position:relative;display:flex;flex-direction:column-reverse;padding-top:10px}.text__label{color:#474747;font-size:16px;position:absolute;bottom:15px;left:5px;transform:translateY(-25px);transition:all 0.3s cubic-bezier(0.5, 0, 0.5, 1)}.text__label--required::after{content:\"*\";margin-left:5px;color:#666666}.text__input{width:inherit;padding:15px 6px;position:relative;border:none;border-bottom:3px solid #666666;background-color:transparent;color:#666666;font-size:16px;font-family:inherit}.text__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.text__input::placeholder{color:#666666}.text__input--invalid{border-bottom:3px solid #cc0000}.text__input:placeholder-shown+.text__label{opacity:0;visibility:hidden;transform:translateY(0)}.text__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
|
|
533
|
-
|
|
534
|
-
const TextInput = class {
|
|
535
|
-
constructor(hostRef) {
|
|
536
|
-
index.registerInstance(this, hostRef);
|
|
537
|
-
this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
|
|
538
|
-
this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
|
|
539
|
-
/**
|
|
540
|
-
* Default value for the input.
|
|
541
|
-
*/
|
|
542
|
-
this.defaultValue = '';
|
|
543
|
-
this.errorMessage = '';
|
|
544
|
-
this.value = '';
|
|
545
|
-
this.customRules = [];
|
|
546
|
-
this.validationPattern = '';
|
|
547
|
-
}
|
|
548
|
-
validityChanged() {
|
|
549
|
-
if (this.emitValue == true) {
|
|
550
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
validityStateHandler(inputStateEvent) {
|
|
554
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
555
|
-
}
|
|
556
|
-
emitValueHandler(newValue) {
|
|
557
|
-
if (newValue == true && this.isValid) {
|
|
558
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
valueHandler(inputValueEvent) {
|
|
562
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
563
|
-
}
|
|
564
|
-
connectedCallback() {
|
|
565
|
-
// @TODO do something with customRules !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
566
|
-
this.customRules = this.setCustomRules();
|
|
567
|
-
this.validationPattern = this.setPattern();
|
|
568
|
-
}
|
|
569
|
-
handleInput(event) {
|
|
570
|
-
this.value = event.target.value;
|
|
571
|
-
this.isValid = this.setValidity();
|
|
572
|
-
this.errorMessage = this.setErrorMessage();
|
|
573
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
574
|
-
this.emitValueHandler(true);
|
|
575
|
-
}
|
|
576
|
-
setValidity() {
|
|
577
|
-
return this.inputReference.validity.valid;
|
|
578
|
-
}
|
|
579
|
-
// @TODO type here
|
|
580
|
-
setCustomRules() {
|
|
581
|
-
var _a;
|
|
582
|
-
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
583
|
-
return this.validation.custom.filter(customValidation => customValidation.rule !== 'regex');
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
setPattern() {
|
|
587
|
-
var _a;
|
|
588
|
-
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
589
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
setErrorMessage() {
|
|
593
|
-
if (this.inputReference.validity.patternMismatch) {
|
|
594
|
-
return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
|
|
595
|
-
}
|
|
596
|
-
if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
|
|
597
|
-
return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
|
|
598
|
-
}
|
|
599
|
-
if (this.inputReference.validity.valueMissing) {
|
|
600
|
-
return translate('requiredError', this.language);
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
render() {
|
|
604
|
-
const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
|
|
605
|
-
console.log('this', this.name, this.defaultValue, this.displayName);
|
|
606
|
-
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, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onBlur: (e) => { this.handleInput(e); } }), index.h("label", { class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("small", { class: 'text__error-message' }, this.errorMessage));
|
|
607
|
-
}
|
|
608
|
-
static get watchers() { return {
|
|
609
|
-
"isValid": ["validityChanged"],
|
|
610
|
-
"emitValue": ["emitValueHandler"]
|
|
611
|
-
}; }
|
|
612
|
-
};
|
|
613
|
-
TextInput.style = textInputCss;
|
|
614
|
-
|
|
615
|
-
exports.checkbox_input = CheckboxInput;
|
|
616
|
-
exports.date_input = DateInput;
|
|
617
|
-
exports.email_input = EmailInput;
|
|
618
|
-
exports.number_input = NumberInput;
|
|
619
|
-
exports.password_input = PasswordInput;
|
|
620
|
-
exports.radio_input = RadioInput;
|
|
621
|
-
exports.select_input = SelectInput;
|
|
622
|
-
exports.tel_input = TelInput;
|
|
623
|
-
exports.text_input = TextInput;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
-
const SUPPORTED_LANGUAGES = ['ro', 'en'];
|
|
3
|
-
const TRANSLATIONS = {
|
|
4
|
-
en: {
|
|
5
|
-
dateError: 'The selected date should be between {min} and {max}',
|
|
6
|
-
numberLengthError: 'The number should be between ${min} and ${max}',
|
|
7
|
-
lengthError: `The length should be between {minLength} and {maxLength}`,
|
|
8
|
-
requiredError: 'This input is required.',
|
|
9
|
-
nextButton: 'Next',
|
|
10
|
-
backButton: 'Back'
|
|
11
|
-
},
|
|
12
|
-
ro: {
|
|
13
|
-
lengthError: `Cuvântul introdus este prea scurt. {minLength} and {maxLength}`,
|
|
14
|
-
requiredError: 'Acest câmp este obligatoriu.'
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const translate = (key, customLang, values) => {
|
|
18
|
-
const lang = customLang;
|
|
19
|
-
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
20
|
-
if (values !== undefined) {
|
|
21
|
-
for (const [key, value] of Object.entries(values.values)) {
|
|
22
|
-
const regex = new RegExp(`{${key}}`, 'g');
|
|
23
|
-
translation = translation.replace(regex, value);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return translation;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export { translate as t };
|