@everymatrix/general-input 0.0.1

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 (121) hide show
  1. package/dist/cjs/checkbox-group-input_10.cjs.entry.js +34870 -0
  2. package/dist/cjs/general-input.cjs.entry.js +51 -0
  3. package/dist/cjs/general-input.cjs.js +19 -0
  4. package/dist/cjs/index-1768513d.js +1286 -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 +22 -0
  8. package/dist/collection/components/checkbox-group-input/checkbox-group-input.css +62 -0
  9. package/dist/collection/components/checkbox-group-input/checkbox-group-input.js +344 -0
  10. package/dist/collection/components/checkbox-input/checkbox-input.css +62 -0
  11. package/dist/collection/components/checkbox-input/checkbox-input.js +322 -0
  12. package/dist/collection/components/date-input/date-input.css +85 -0
  13. package/dist/collection/components/date-input/date-input.js +341 -0
  14. package/dist/collection/components/email-input/email-input.css +83 -0
  15. package/dist/collection/components/email-input/email-input.js +382 -0
  16. package/dist/collection/components/general-input/general-input.css +3 -0
  17. package/dist/collection/components/general-input/general-input.js +296 -0
  18. package/dist/collection/components/number-input/number-input.css +90 -0
  19. package/dist/collection/components/number-input/number-input.js +349 -0
  20. package/dist/collection/components/password-input/password-input.css +86 -0
  21. package/dist/collection/components/password-input/password-input.js +395 -0
  22. package/dist/collection/components/radio-input/radio-input.css +43 -0
  23. package/dist/collection/components/radio-input/radio-input.js +298 -0
  24. package/dist/collection/components/select-input/select-input.css +93 -0
  25. package/dist/collection/components/select-input/select-input.js +412 -0
  26. package/dist/collection/components/tel-input/tel-input.css +116 -0
  27. package/dist/collection/components/tel-input/tel-input.js +421 -0
  28. package/dist/collection/components/text-input/text-input.css +83 -0
  29. package/dist/collection/components/text-input/text-input.js +406 -0
  30. package/dist/collection/index.js +1 -0
  31. package/dist/collection/utils/locale.utils.js +26 -0
  32. package/dist/collection/utils/tooltipIcon.svg +5 -0
  33. package/dist/collection/utils/types.js +1 -0
  34. package/dist/collection/utils/utils.js +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 +5793 -0
  39. package/dist/components/checkbox-input.d.ts +11 -0
  40. package/dist/components/checkbox-input.js +6 -0
  41. package/dist/components/checkbox-input2.js +127 -0
  42. package/dist/components/date-input.d.ts +11 -0
  43. package/dist/components/date-input.js +6 -0
  44. package/dist/components/date-input2.js +5182 -0
  45. package/dist/components/email-input.d.ts +11 -0
  46. package/dist/components/email-input.js +6 -0
  47. package/dist/components/email-input2.js +150 -0
  48. package/dist/components/field-mixin.js +12712 -0
  49. package/dist/components/general-input.d.ts +11 -0
  50. package/dist/components/general-input.js +140 -0
  51. package/dist/components/index.d.ts +26 -0
  52. package/dist/components/index.js +1 -0
  53. package/dist/components/input-field-shared-styles.js +1067 -0
  54. package/dist/components/number-input.d.ts +11 -0
  55. package/dist/components/number-input.js +6 -0
  56. package/dist/components/number-input2.js +139 -0
  57. package/dist/components/password-input.d.ts +11 -0
  58. package/dist/components/password-input.js +6 -0
  59. package/dist/components/password-input2.js +879 -0
  60. package/dist/components/pattern-mixin.js +85 -0
  61. package/dist/components/radio-input.d.ts +11 -0
  62. package/dist/components/radio-input.js +6 -0
  63. package/dist/components/radio-input2.js +115 -0
  64. package/dist/components/select-input.d.ts +11 -0
  65. package/dist/components/select-input.js +6 -0
  66. package/dist/components/select-input2.js +166 -0
  67. package/dist/components/tel-input.d.ts +11 -0
  68. package/dist/components/tel-input.js +6 -0
  69. package/dist/components/tel-input2.js +178 -0
  70. package/dist/components/text-input.d.ts +11 -0
  71. package/dist/components/text-input.js +6 -0
  72. package/dist/components/text-input2.js +157 -0
  73. package/dist/components/tooltipIcon.js +30 -0
  74. package/dist/components/vaadin-button.js +461 -0
  75. package/dist/components/vaadin-combo-box.js +4329 -0
  76. package/dist/components/virtual-keyboard-controller.js +2693 -0
  77. package/dist/esm/checkbox-group-input_10.entry.js +34857 -0
  78. package/dist/esm/general-input.entry.js +47 -0
  79. package/dist/esm/general-input.js +17 -0
  80. package/dist/esm/index-7e24a6f1.js +1259 -0
  81. package/dist/esm/index.js +1 -0
  82. package/dist/esm/loader.js +17 -0
  83. package/dist/esm/polyfills/core-js.js +11 -0
  84. package/dist/esm/polyfills/css-shim.js +1 -0
  85. package/dist/esm/polyfills/dom.js +79 -0
  86. package/dist/esm/polyfills/es5-html-element.js +1 -0
  87. package/dist/esm/polyfills/index.js +34 -0
  88. package/dist/esm/polyfills/system.js +6 -0
  89. package/dist/general-input/general-input.esm.js +1 -0
  90. package/dist/general-input/index.esm.js +0 -0
  91. package/dist/general-input/p-61d76ec3.entry.js +1 -0
  92. package/dist/general-input/p-a79eb0a3.entry.js +4413 -0
  93. package/dist/general-input/p-fb647820.js +1 -0
  94. package/dist/index.cjs.js +1 -0
  95. package/dist/index.js +1 -0
  96. package/dist/stencil.config.js +22 -0
  97. package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +2 -0
  98. package/dist/types/components/checkbox-group-input/checkbox-group-input.d.ts +72 -0
  99. package/dist/types/components/checkbox-input/checkbox-input.d.ts +64 -0
  100. package/dist/types/components/date-input/date-input.d.ts +70 -0
  101. package/dist/types/components/email-input/email-input.d.ts +77 -0
  102. package/dist/types/components/general-input/general-input.d.ts +60 -0
  103. package/dist/types/components/number-input/number-input.d.ts +70 -0
  104. package/dist/types/components/password-input/password-input.d.ts +79 -0
  105. package/dist/types/components/radio-input/radio-input.d.ts +59 -0
  106. package/dist/types/components/select-input/select-input.d.ts +82 -0
  107. package/dist/types/components/tel-input/tel-input.d.ts +85 -0
  108. package/dist/types/components/text-input/text-input.d.ts +81 -0
  109. package/dist/types/components.d.ts +1140 -0
  110. package/dist/types/index.d.ts +1 -0
  111. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  112. package/dist/types/utils/locale.utils.d.ts +5 -0
  113. package/dist/types/utils/types.d.ts +76 -0
  114. package/dist/types/utils/utils.d.ts +1 -0
  115. package/loader/cdn.js +3 -0
  116. package/loader/index.cjs.js +3 -0
  117. package/loader/index.d.ts +12 -0
  118. package/loader/index.es2017.js +3 -0
  119. package/loader/index.js +4 -0
  120. package/loader/package.json +10 -0
  121. package/package.json +26 -0
@@ -0,0 +1,406 @@
1
+ import { Component, h, Prop, State, Watch, Event, Listen } from '@stencil/core';
2
+ import { translate } from '../../utils/locale.utils';
3
+ import tooltipIcon from '../../utils/tooltipIcon.svg';
4
+ export class TextInput {
5
+ constructor() {
6
+ /**
7
+ * Default value for the input.
8
+ */
9
+ this.defaultValue = '';
10
+ /**
11
+ * Client custom styling via inline style
12
+ */
13
+ this.clientStyling = '';
14
+ this.errorMessage = '';
15
+ this.limitStylingAppends = false;
16
+ this.showTooltip = false;
17
+ this.value = '';
18
+ this.customRules = [];
19
+ this.validationPattern = '';
20
+ this.setClientStyling = () => {
21
+ let sheet = document.createElement('style');
22
+ sheet.innerHTML = this.clientStyling;
23
+ this.stylingContainer.prepend(sheet);
24
+ };
25
+ }
26
+ validityChanged() {
27
+ if (this.emitValue == true) {
28
+ this.valueHandler({ name: this.name, value: this.value });
29
+ }
30
+ }
31
+ emitValueHandler(newValue) {
32
+ if (newValue == true && this.isValid) {
33
+ this.valueHandler({ name: this.name, value: this.value });
34
+ }
35
+ }
36
+ validityStateHandler(inputStateEvent) {
37
+ this.sendValidityState.emit(inputStateEvent);
38
+ }
39
+ valueHandler(inputValueEvent) {
40
+ this.sendInputValue.emit(inputValueEvent);
41
+ }
42
+ handleClickOutside(event) {
43
+ if (event.composedPath()[0] === this.tooltipIconReference)
44
+ return;
45
+ if (event.composedPath()[0] !== this.tooltipReference)
46
+ this.showTooltip = false;
47
+ }
48
+ valueChangedHandler(event) {
49
+ if (this.isDuplicateInput) {
50
+ if (this.name === event.detail.name + 'Duplicate') {
51
+ this.duplicateInputValue = event.detail.value;
52
+ }
53
+ }
54
+ }
55
+ connectedCallback() {
56
+ this.validationPattern = this.setPattern();
57
+ }
58
+ componentDidRender() {
59
+ // start custom styling area
60
+ if (!this.limitStylingAppends && this.stylingContainer) {
61
+ if (this.clientStyling)
62
+ this.setClientStyling();
63
+ this.limitStylingAppends = true;
64
+ }
65
+ // end custom styling area
66
+ if (this.defaultValue) {
67
+ this.value = this.defaultValue;
68
+ this.valueHandler({ name: this.name, value: this.value });
69
+ }
70
+ }
71
+ handleInput(event) {
72
+ this.value = event.target.value;
73
+ this.isValid = this.setValidity();
74
+ this.errorMessage = this.setErrorMessage();
75
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
76
+ this.emitValueHandler(true);
77
+ }
78
+ setValidity() {
79
+ return this.inputReference.validity.valid;
80
+ }
81
+ setPattern() {
82
+ var _a, _b;
83
+ if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
84
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
85
+ }
86
+ }
87
+ setErrorMessage() {
88
+ var _a;
89
+ if (this.inputReference.validity.patternMismatch) {
90
+ return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
91
+ }
92
+ if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
93
+ return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
94
+ }
95
+ if (this.inputReference.validity.valueMissing) {
96
+ return translate('requiredError', this.language);
97
+ }
98
+ if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
99
+ return this.validation.custom.find(customRule => customRule.rule === 'duplicate-input').errorMessage;
100
+ }
101
+ }
102
+ renderTooltip() {
103
+ if (this.showTooltip) {
104
+ return (h("div", { class: `text__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
105
+ }
106
+ return null;
107
+ }
108
+ render() {
109
+ const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
110
+ return h("div", { class: 'text__wrapper', ref: el => this.stylingContainer = el },
111
+ h("div", { class: 'text__wrapper--flex' },
112
+ h("label", { class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName),
113
+ h("div", { class: 'text__wrapper--relative' },
114
+ this.tooltip &&
115
+ h("img", { class: 'text__tooltip-icon', src: tooltipIcon, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }),
116
+ this.renderTooltip())),
117
+ h("input", { name: this.name, id: `${this.name}__input`, value: this.defaultValue, type: 'text', class: `text__input ${invalidClass}`, placeholder: `${this.placeholder} ${this.placeholder && this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, readOnly: this.autofilled, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onBlur: (e) => { this.handleInput(e); } }),
118
+ h("small", { class: 'text__error-message' }, this.errorMessage));
119
+ }
120
+ static get is() { return "text-input"; }
121
+ static get encapsulation() { return "shadow"; }
122
+ static get originalStyleUrls() { return {
123
+ "$": ["text-input.scss"]
124
+ }; }
125
+ static get styleUrls() { return {
126
+ "$": ["text-input.css"]
127
+ }; }
128
+ static get properties() { return {
129
+ "name": {
130
+ "type": "string",
131
+ "mutable": false,
132
+ "complexType": {
133
+ "original": "string",
134
+ "resolved": "string",
135
+ "references": {}
136
+ },
137
+ "required": false,
138
+ "optional": false,
139
+ "docs": {
140
+ "tags": [],
141
+ "text": "Name of the input."
142
+ },
143
+ "attribute": "name",
144
+ "reflect": true
145
+ },
146
+ "displayName": {
147
+ "type": "string",
148
+ "mutable": false,
149
+ "complexType": {
150
+ "original": "string",
151
+ "resolved": "string",
152
+ "references": {}
153
+ },
154
+ "required": false,
155
+ "optional": false,
156
+ "docs": {
157
+ "tags": [],
158
+ "text": "Name of input to be shown to the user."
159
+ },
160
+ "attribute": "display-name",
161
+ "reflect": true
162
+ },
163
+ "placeholder": {
164
+ "type": "string",
165
+ "mutable": false,
166
+ "complexType": {
167
+ "original": "string",
168
+ "resolved": "string",
169
+ "references": {}
170
+ },
171
+ "required": false,
172
+ "optional": false,
173
+ "docs": {
174
+ "tags": [],
175
+ "text": "Placeholder text to be shown."
176
+ },
177
+ "attribute": "placeholder",
178
+ "reflect": true
179
+ },
180
+ "validation": {
181
+ "type": "unknown",
182
+ "mutable": false,
183
+ "complexType": {
184
+ "original": "ValidationSchema",
185
+ "resolved": "ValidationSchema",
186
+ "references": {
187
+ "ValidationSchema": {
188
+ "location": "import",
189
+ "path": "../../utils/types"
190
+ }
191
+ }
192
+ },
193
+ "required": false,
194
+ "optional": false,
195
+ "docs": {
196
+ "tags": [],
197
+ "text": "Object of validation rules for the input."
198
+ }
199
+ },
200
+ "defaultValue": {
201
+ "type": "string",
202
+ "mutable": false,
203
+ "complexType": {
204
+ "original": "string",
205
+ "resolved": "string",
206
+ "references": {}
207
+ },
208
+ "required": false,
209
+ "optional": false,
210
+ "docs": {
211
+ "tags": [],
212
+ "text": "Default value for the input."
213
+ },
214
+ "attribute": "default-value",
215
+ "reflect": true,
216
+ "defaultValue": "''"
217
+ },
218
+ "autofilled": {
219
+ "type": "boolean",
220
+ "mutable": false,
221
+ "complexType": {
222
+ "original": "boolean",
223
+ "resolved": "boolean",
224
+ "references": {}
225
+ },
226
+ "required": false,
227
+ "optional": false,
228
+ "docs": {
229
+ "tags": [],
230
+ "text": "Boolean. Determines if input should be readonly."
231
+ },
232
+ "attribute": "autofilled",
233
+ "reflect": true
234
+ },
235
+ "tooltip": {
236
+ "type": "string",
237
+ "mutable": false,
238
+ "complexType": {
239
+ "original": "string",
240
+ "resolved": "string",
241
+ "references": {}
242
+ },
243
+ "required": false,
244
+ "optional": false,
245
+ "docs": {
246
+ "tags": [],
247
+ "text": "Tooltip text."
248
+ },
249
+ "attribute": "tooltip",
250
+ "reflect": true
251
+ },
252
+ "language": {
253
+ "type": "string",
254
+ "mutable": false,
255
+ "complexType": {
256
+ "original": "string",
257
+ "resolved": "string",
258
+ "references": {}
259
+ },
260
+ "required": false,
261
+ "optional": false,
262
+ "docs": {
263
+ "tags": [],
264
+ "text": "Currently selected language."
265
+ },
266
+ "attribute": "language",
267
+ "reflect": true
268
+ },
269
+ "checkValidity": {
270
+ "type": "boolean",
271
+ "mutable": false,
272
+ "complexType": {
273
+ "original": "boolean",
274
+ "resolved": "boolean",
275
+ "references": {}
276
+ },
277
+ "required": false,
278
+ "optional": false,
279
+ "docs": {
280
+ "tags": [],
281
+ "text": "State passed down from the parent element. Will trigger the input to check for validity."
282
+ },
283
+ "attribute": "check-validity",
284
+ "reflect": true
285
+ },
286
+ "emitValue": {
287
+ "type": "boolean",
288
+ "mutable": false,
289
+ "complexType": {
290
+ "original": "boolean",
291
+ "resolved": "boolean",
292
+ "references": {}
293
+ },
294
+ "required": false,
295
+ "optional": false,
296
+ "docs": {
297
+ "tags": [],
298
+ "text": "State passed down from the parent element. Will trigger the input to send it's value through an event."
299
+ },
300
+ "attribute": "emit-value",
301
+ "reflect": true
302
+ },
303
+ "isDuplicateInput": {
304
+ "type": "boolean",
305
+ "mutable": false,
306
+ "complexType": {
307
+ "original": "boolean",
308
+ "resolved": "boolean",
309
+ "references": {}
310
+ },
311
+ "required": false,
312
+ "optional": false,
313
+ "docs": {
314
+ "tags": [],
315
+ "text": "Boolean that triggers certain validation rules, for duplicated inputs."
316
+ },
317
+ "attribute": "is-duplicate-input",
318
+ "reflect": true
319
+ },
320
+ "clientStyling": {
321
+ "type": "string",
322
+ "mutable": false,
323
+ "complexType": {
324
+ "original": "string",
325
+ "resolved": "string",
326
+ "references": {}
327
+ },
328
+ "required": false,
329
+ "optional": false,
330
+ "docs": {
331
+ "tags": [],
332
+ "text": "Client custom styling via inline style"
333
+ },
334
+ "attribute": "client-styling",
335
+ "reflect": true,
336
+ "defaultValue": "''"
337
+ }
338
+ }; }
339
+ static get states() { return {
340
+ "isValid": {},
341
+ "errorMessage": {},
342
+ "limitStylingAppends": {},
343
+ "showTooltip": {}
344
+ }; }
345
+ static get events() { return [{
346
+ "method": "sendValidityState",
347
+ "name": "sendValidityState",
348
+ "bubbles": true,
349
+ "cancelable": true,
350
+ "composed": true,
351
+ "docs": {
352
+ "tags": [],
353
+ "text": ""
354
+ },
355
+ "complexType": {
356
+ "original": "InputStateEvent",
357
+ "resolved": "InputStateEvent",
358
+ "references": {
359
+ "InputStateEvent": {
360
+ "location": "import",
361
+ "path": "../../utils/types"
362
+ }
363
+ }
364
+ }
365
+ }, {
366
+ "method": "sendInputValue",
367
+ "name": "sendInputValue",
368
+ "bubbles": true,
369
+ "cancelable": true,
370
+ "composed": true,
371
+ "docs": {
372
+ "tags": [],
373
+ "text": ""
374
+ },
375
+ "complexType": {
376
+ "original": "InputValueEvent",
377
+ "resolved": "InputValueEvent",
378
+ "references": {
379
+ "InputValueEvent": {
380
+ "location": "import",
381
+ "path": "../../utils/types"
382
+ }
383
+ }
384
+ }
385
+ }]; }
386
+ static get watchers() { return [{
387
+ "propName": "isValid",
388
+ "methodName": "validityChanged"
389
+ }, {
390
+ "propName": "emitValue",
391
+ "methodName": "emitValueHandler"
392
+ }]; }
393
+ static get listeners() { return [{
394
+ "name": "click",
395
+ "method": "handleClickOutside",
396
+ "target": "document",
397
+ "capture": false,
398
+ "passive": false
399
+ }, {
400
+ "name": "sendInputValue",
401
+ "method": "valueChangedHandler",
402
+ "target": "body",
403
+ "capture": false,
404
+ "passive": false
405
+ }]; }
406
+ }
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1,26 @@
1
+ const DEFAULT_LANGUAGE = 'en';
2
+ const TRANSLATIONS = {
3
+ "en": {
4
+ "dateError": 'The selected date should be between {min} and {max}',
5
+ "numberLengthError": 'The number should be between {min} and {max}',
6
+ "lengthError": `The length should be between {minLength} and {maxLength}`,
7
+ "requiredError": 'This input is required.',
8
+ },
9
+ "hu": {
10
+ "dateError": 'A választott dátumnak {min} és {max} között kell lennie',
11
+ "numberLengthError": 'A számnak {min} és {max} között kell lennie',
12
+ "lengthError": `A hossznak {minLength} és {maxLength} között kell lennie`,
13
+ "requiredError": 'Ez a beviteli mező kötelező.',
14
+ }
15
+ };
16
+ export const translate = (key, customLang, values) => {
17
+ const lang = customLang;
18
+ let translation = TRANSLATIONS[lang !== undefined ? lang : DEFAULT_LANGUAGE][key];
19
+ if (values !== undefined) {
20
+ for (const [key, value] of Object.entries(values.values)) {
21
+ const regex = new RegExp(`{${key}}`, 'g');
22
+ translation = translation.replace(regex, value);
23
+ }
24
+ }
25
+ return translation;
26
+ };
@@ -0,0 +1,5 @@
1
+ <svg width="22" height="21" viewBox="0 0 22 21" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="11.9099" y="16.15" width="1.82" height="7.60001" transform="rotate(-180 11.9099 16.15)" fill="#2B2D3F"/>
3
+ <rect x="11.9099" y="6.65002" width="1.82" height="1.90001" transform="rotate(-180 11.9099 6.65002)" fill="#2B2D3F"/>
4
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M0.98999 10.45C0.98999 4.67768 5.47197 0 11 0C16.528 0 21.01 4.67768 21.01 10.45C21.01 16.221 16.528 20.9 11 20.9C5.47197 20.9 0.98999 16.221 0.98999 10.45ZM2.80999 10.4506C2.80999 15.1723 6.47677 19 11 19C15.522 19 19.19 15.1723 19.19 10.4506C19.19 5.72891 15.522 1.90001 11 1.90001C6.47677 1.90001 2.80999 5.72891 2.80999 10.4506Z" fill="#2B2D3F"/>
5
+ </svg>
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export function formatName(name) {
2
+ return name
3
+ .replace(/([A-Z])/g, ' $1')
4
+ .replace(/^./, function (str) { return str.toUpperCase(); });
5
+ }