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