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